forked frompostgres/postgres
- Notifications
You must be signed in to change notification settings - Fork6
Commite0df808
committed
Fix type-checking of RECORD-returning functions in FROM, redux.
Commit2ed8f9a intended to institute a policy that if aRangeTblFunction has a coldeflist, then the function return type iscertainly RECORD, and we should use the coldeflist as the source oftruth about what the columns of the record type are. When theoriginal function has been folded to a constant, inspection of theconstant might give a different answer. This situation will lead toa tuple-type-mismatch error at execution, but up until that point weneed to consistently believe the coldeflist, or we'll have problemsfrom different bits of code reaching different conclusions.expandRTE didn't get that memo though, and would try to produce atupdesc based on the constant in this situation, leading to anassertion failure. (Desultory testing suggests that non-assertbuilds often manage to give the expected error, although I alsosaw a "cache lookup failed for type 0" error, and it seems atleast possible that a crash could happen.)Some other callers of get_expr_result_type and get_expr_result_tupdescwere also being incautious about this. While none of them seem tohave actual bugs, they're working harder than necessary in this case,besides which it seems safest to have an explicit policy of not usingthose functions on an RTE with a coldeflist. Adjust the codeaccordingly, and add commentary to funcapi.c about this policy.Also fix an obsolete comment that claimed "get_expr_result_type()doesn't know how to extract type info from a RECORD constant".That hasn't been true since commitd575347.Per bug #18422 from Alexander Lakhin.As with the previous commit, back-patch to all supported branches.Discussion:https://postgr.es/m/18422-89ca86c8eac5246d@postgresql.org1 parentcee8db3 commite0df808
File tree
7 files changed
+41
-13
lines changed- src
- backend
- catalog
- optimizer
- prep
- util
- parser
- utils/fmgr
- test/regress
- expected
- sql
7 files changed
+41
-13
lines changedLines changed: 5 additions & 1 deletion
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
2337 | 2337 |
| |
2338 | 2338 |
| |
2339 | 2339 |
| |
2340 |
| - | |
| 2340 | + | |
| 2341 | + | |
| 2342 | + | |
| 2343 | + | |
| 2344 | + | |
2341 | 2345 |
| |
2342 | 2346 |
| |
2343 | 2347 |
| |
|
Lines changed: 4 additions & 0 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
1854 | 1854 |
| |
1855 | 1855 |
| |
1856 | 1856 |
| |
| 1857 | + | |
| 1858 | + | |
| 1859 | + | |
| 1860 | + | |
1857 | 1861 |
| |
1858 | 1862 |
| |
1859 | 1863 |
| |
|
Lines changed: 5 additions & 6 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
4431 | 4431 |
| |
4432 | 4432 |
| |
4433 | 4433 |
| |
4434 |
| - | |
4435 |
| - | |
4436 |
| - | |
4437 |
| - | |
4438 |
| - | |
4439 |
| - | |
| 4434 | + | |
| 4435 | + | |
| 4436 | + | |
| 4437 | + | |
| 4438 | + | |
4440 | 4439 |
| |
4441 | 4440 |
| |
4442 | 4441 |
| |
|
Lines changed: 14 additions & 5 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
2738 | 2738 |
| |
2739 | 2739 |
| |
2740 | 2740 |
| |
2741 |
| - | |
2742 |
| - | |
| 2741 | + | |
| 2742 | + | |
| 2743 | + | |
| 2744 | + | |
| 2745 | + | |
| 2746 | + | |
| 2747 | + | |
| 2748 | + | |
| 2749 | + | |
| 2750 | + | |
2743 | 2751 |
| |
2744 |
| - | |
2745 |
| - | |
2746 |
| - | |
2747 | 2752 |
| |
2748 | 2753 |
| |
2749 | 2754 |
| |
| |||
3369 | 3374 |
| |
3370 | 3375 |
| |
3371 | 3376 |
| |
| 3377 | + | |
| 3378 | + | |
| 3379 | + | |
| 3380 | + | |
3372 | 3381 |
| |
3373 | 3382 |
| |
3374 | 3383 |
| |
|
Lines changed: 9 additions & 1 deletion
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
287 | 287 |
| |
288 | 288 |
| |
289 | 289 |
| |
| 290 | + | |
| 291 | + | |
| 292 | + | |
| 293 | + | |
| 294 | + | |
| 295 | + | |
| 296 | + | |
290 | 297 |
| |
291 | 298 |
| |
292 | 299 |
| |
| |||
537 | 544 |
| |
538 | 545 |
| |
539 | 546 |
| |
540 |
| - | |
| 547 | + | |
| 548 | + | |
541 | 549 |
| |
542 | 550 |
| |
543 | 551 |
| |
|
Lines changed: 3 additions & 0 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
2498 | 2498 |
| |
2499 | 2499 |
| |
2500 | 2500 |
| |
| 2501 | + | |
| 2502 | + | |
| 2503 | + |
Lines changed: 1 addition & 0 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
824 | 824 |
| |
825 | 825 |
| |
826 | 826 |
| |
| 827 | + |
0 commit comments
Comments
(0)