- Notifications
You must be signed in to change notification settings - Fork5
Commit72daabc
committed
Disallow pushing volatile quals past set-returning functions.
Pushing an upper-level restriction clause into an unflattenedsubquery-in-FROM is okay when the subquery contains no SRFs in itstargetlist, or when it does but the SRFs are unreferenced by the clause*and the clause is not volatile*. Otherwise, we're changing the numberof times the clause is evaluated, which is bad for volatile quals, andpossibly changing the result, since a volatile qual might succeed for someSRF output rows and not others despite not referencing any of the changingcolumns. (Indeed, if the clause is something like "random() > 0.5", theuser is probably expecting exactly that behavior.)We had most of these restrictions down, but not the one about the upperclause not being volatile. Fix that, and add a regression test toillustrate the expected behavior.Although this is definitely a bug, it doesn't seem like back-patchmaterial, since possibly some users don't realize that the brokenbehavior is broken and are relying on what happens now. Also, whilethe added test is quite cheap in the wake of commita4c35ea, it wouldbe much more expensive (or else messier) in older branches.Per report from Tom van Tilburg.Discussion: <CAP3PPDiucxYCNev52=YPVkrQAPVF1C5PFWnrQPT7iMzO1fiKFQ@mail.gmail.com>1 parent0109ab2 commit72daabc
File tree
3 files changed
+154
-2
lines changed- src
- backend/optimizer/path
- test/regress
- expected
- sql
3 files changed
+154
-2
lines changedLines changed: 10 additions & 2 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
2254 | 2254 |
| |
2255 | 2255 |
| |
2256 | 2256 |
| |
| 2257 | + | |
| 2258 | + | |
| 2259 | + | |
| 2260 | + | |
| 2261 | + | |
| 2262 | + | |
2257 | 2263 |
| |
2258 | 2264 |
| |
2259 | 2265 |
| |
| |||
2298 | 2304 |
| |
2299 | 2305 |
| |
2300 | 2306 |
| |
2301 |
| - | |
2302 |
| - | |
| 2307 | + | |
| 2308 | + | |
| 2309 | + | |
| 2310 | + | |
2303 | 2311 |
| |
2304 | 2312 |
| |
2305 | 2313 |
| |
|
Lines changed: 100 additions & 0 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
880 | 880 |
| |
881 | 881 |
| |
882 | 882 |
| |
| 883 | + | |
| 884 | + | |
| 885 | + | |
| 886 | + | |
| 887 | + | |
| 888 | + | |
| 889 | + | |
| 890 | + | |
| 891 | + | |
| 892 | + | |
| 893 | + | |
| 894 | + | |
| 895 | + | |
| 896 | + | |
| 897 | + | |
| 898 | + | |
| 899 | + | |
| 900 | + | |
| 901 | + | |
| 902 | + | |
| 903 | + | |
| 904 | + | |
| 905 | + | |
| 906 | + | |
| 907 | + | |
| 908 | + | |
| 909 | + | |
| 910 | + | |
| 911 | + | |
| 912 | + | |
| 913 | + | |
| 914 | + | |
| 915 | + | |
| 916 | + | |
| 917 | + | |
| 918 | + | |
| 919 | + | |
| 920 | + | |
| 921 | + | |
| 922 | + | |
| 923 | + | |
| 924 | + | |
| 925 | + | |
| 926 | + | |
| 927 | + | |
| 928 | + | |
| 929 | + | |
| 930 | + | |
| 931 | + | |
| 932 | + | |
| 933 | + | |
| 934 | + | |
| 935 | + | |
| 936 | + | |
| 937 | + | |
| 938 | + | |
| 939 | + | |
| 940 | + | |
| 941 | + | |
| 942 | + | |
| 943 | + | |
| 944 | + | |
| 945 | + | |
| 946 | + | |
| 947 | + | |
| 948 | + | |
| 949 | + | |
| 950 | + | |
| 951 | + | |
| 952 | + | |
| 953 | + | |
| 954 | + | |
| 955 | + | |
| 956 | + | |
| 957 | + | |
| 958 | + | |
| 959 | + | |
| 960 | + | |
| 961 | + | |
| 962 | + | |
| 963 | + | |
| 964 | + | |
| 965 | + | |
| 966 | + | |
| 967 | + | |
| 968 | + | |
| 969 | + | |
| 970 | + | |
| 971 | + | |
| 972 | + | |
| 973 | + | |
| 974 | + | |
| 975 | + | |
| 976 | + | |
| 977 | + | |
| 978 | + | |
| 979 | + | |
| 980 | + | |
| 981 | + | |
| 982 | + |
Lines changed: 44 additions & 0 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
481 | 481 |
| |
482 | 482 |
| |
483 | 483 |
| |
| 484 | + | |
| 485 | + | |
| 486 | + | |
| 487 | + | |
| 488 | + | |
| 489 | + | |
| 490 | + | |
| 491 | + | |
| 492 | + | |
| 493 | + | |
| 494 | + | |
| 495 | + | |
| 496 | + | |
| 497 | + | |
| 498 | + | |
| 499 | + | |
| 500 | + | |
| 501 | + | |
| 502 | + | |
| 503 | + | |
| 504 | + | |
| 505 | + | |
| 506 | + | |
| 507 | + | |
| 508 | + | |
| 509 | + | |
| 510 | + | |
| 511 | + | |
| 512 | + | |
| 513 | + | |
| 514 | + | |
| 515 | + | |
| 516 | + | |
| 517 | + | |
| 518 | + | |
| 519 | + | |
| 520 | + | |
| 521 | + | |
| 522 | + | |
| 523 | + | |
| 524 | + | |
| 525 | + | |
| 526 | + | |
| 527 | + |
0 commit comments
Comments
(0)