Commit 913bbd8
committed
Improve the handling of result type coercions in SQL functions.
Use the parser's standard type coercion machinery to convert the
output column(s) of a SQL function's final SELECT or RETURNING
to the type(s) they should have according to the function's declared
result type. We'll allow any case where an assignment-level
coercion is available. Previously, we failed unless the required
coercion was a binary-compatible one (and the documentation ignored
this, falsely claiming that the types must match exactly).
Notably, the coercion now accounts for typmods, so that cases where
a SQL function is declared to return a composite type whose columns
are typmod-constrained now behave as one would expect. Arguably
this aspect is a bug fix, but the overall behavioral change here
seems too large to consider back-patching.
A nice side-effect is that functions can now be inlined in a
few cases where we previously failed to do so because of type
mismatches.
Discussion: https://postgr.es/m/18929.1574895430@sss.pgh.pa.us1 parent 8dd1511 commit 913bbd8
File tree
7 files changed
+656
-332
lines changed- doc/src/sgml
- src
- backend
- catalog
- executor
- optimizer/util
- include/executor
- test/regress
- expected
- sql
7 files changed
+656
-332
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
388 | 388 | | |
389 | 389 | | |
390 | 390 | | |
391 | | - | |
392 | | - | |
| 391 | + | |
| 392 | + | |
| 393 | + | |
| 394 | + | |
| 395 | + | |
| 396 | + | |
393 | 397 | | |
394 | 398 | | |
395 | | - | |
| 399 | + | |
396 | 400 | | |
397 | 401 | | |
398 | 402 | | |
399 | 403 | | |
400 | 404 | | |
401 | 405 | | |
402 | 406 | | |
403 | | - | |
404 | | - | |
405 | | - | |
406 | | - | |
407 | | - | |
408 | | - | |
409 | | - | |
410 | | - | |
411 | | - | |
412 | | - | |
| 407 | + | |
| 408 | + | |
| 409 | + | |
| 410 | + | |
413 | 411 | | |
414 | 412 | | |
415 | 413 | | |
| |||
503 | 501 | | |
504 | 502 | | |
505 | 503 | | |
506 | | - | |
507 | | - | |
| 504 | + | |
| 505 | + | |
508 | 506 | | |
509 | 507 | | |
510 | 508 | | |
511 | 509 | | |
512 | 510 | | |
513 | | - | |
514 | | - | |
| 511 | + | |
| 512 | + | |
515 | 513 | | |
516 | 514 | | |
517 | 515 | | |
518 | | - | |
| 516 | + | |
| 517 | + | |
519 | 518 | | |
520 | 519 | | |
521 | | - | |
522 | | - | |
| 520 | + | |
| 521 | + | |
523 | 522 | | |
524 | 523 | | |
525 | 524 | | |
| |||
542 | 541 | | |
543 | 542 | | |
544 | 543 | | |
545 | | - | |
546 | | - | |
| 544 | + | |
547 | 545 | | |
548 | 546 | | |
549 | 547 | | |
| |||
1263 | 1261 | | |
1264 | 1262 | | |
1265 | 1263 | | |
1266 | | - | |
| 1264 | + | |
1267 | 1265 | | |
1268 | 1266 | | |
1269 | 1267 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
923 | 923 | | |
924 | 924 | | |
925 | 925 | | |
| 926 | + | |
| 927 | + | |
926 | 928 | | |
927 | 929 | | |
928 | 930 | | |
| |||
943 | 945 | | |
944 | 946 | | |
945 | 947 | | |
946 | | - | |
947 | | - | |
948 | | - | |
| 948 | + | |
| 949 | + | |
| 950 | + | |
| 951 | + | |
| 952 | + | |
| 953 | + | |
949 | 954 | | |
950 | 955 | | |
951 | 956 | | |
| |||
0 commit comments