forked frompostgres/postgres
- Notifications
You must be signed in to change notification settings - Fork6
Commitb97ee66
committed
Make contain_volatile_functions/contain_mutable_functions look into SubLinks.
This change prevents us from doing inappropriate subquery flattening incases such as dangerous functions hidden inside a sub-SELECT in thetargetlist of another sub-SELECT. That could result in unexpected behaviordue to multiple evaluations of a volatile function, as in a recentcomplaint from Etienne Dube. It's been questionable from the verybeginning whether these functions should look into subqueries (as noted intheir comments), and this case seems to provide proof that they should.Because the new code only descends into SubLinks, not SubPlans orInitPlans, the change only affects the planner's behavior duringprepjointree processing and not later on --- for example, you can still getit to use a volatile function in an indexqual if you wrap the function in(SELECT ...). That's a historical behavior, for sure, but it's reasonablegiven that the executor's evaluation rules for subplans don't depend onwhether there are volatile functions inside them. In any case, we need toconstrain the behavioral change as narrowly as we can to make thisreasonable to back-patch.1 parent060b22a commitb97ee66
File tree
3 files changed
+107
-6
lines changed- src
- backend/optimizer/util
- test/regress
- expected
- sql
3 files changed
+107
-6
lines changedLines changed: 27 additions & 6 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
833 | 833 |
| |
834 | 834 |
| |
835 | 835 |
| |
836 |
| - | |
837 |
| - | |
| 836 | + | |
| 837 | + | |
838 | 838 |
| |
839 | 839 |
| |
840 | 840 |
| |
| |||
931 | 931 |
| |
932 | 932 |
| |
933 | 933 |
| |
| 934 | + | |
| 935 | + | |
| 936 | + | |
| 937 | + | |
| 938 | + | |
| 939 | + | |
| 940 | + | |
934 | 941 |
| |
935 | 942 |
| |
936 | 943 |
| |
| |||
945 | 952 |
| |
946 | 953 |
| |
947 | 954 |
| |
948 |
| - | |
949 |
| - | |
| 955 | + | |
| 956 | + | |
950 | 957 |
| |
951 |
| - | |
952 |
| - | |
| 958 | + | |
| 959 | + | |
| 960 | + | |
| 961 | + | |
| 962 | + | |
| 963 | + | |
| 964 | + | |
| 965 | + | |
| 966 | + | |
953 | 967 |
| |
954 | 968 |
| |
955 | 969 |
| |
| |||
1047 | 1061 |
| |
1048 | 1062 |
| |
1049 | 1063 |
| |
| 1064 | + | |
| 1065 | + | |
| 1066 | + | |
| 1067 | + | |
| 1068 | + | |
| 1069 | + | |
| 1070 | + | |
1050 | 1071 |
| |
1051 | 1072 |
| |
1052 | 1073 |
| |
|
Lines changed: 64 additions & 0 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
636 | 636 |
| |
637 | 637 |
| |
638 | 638 |
| |
| 639 | + | |
| 640 | + | |
| 641 | + | |
| 642 | + | |
| 643 | + | |
| 644 | + | |
| 645 | + | |
| 646 | + | |
| 647 | + | |
| 648 | + | |
| 649 | + | |
| 650 | + | |
| 651 | + | |
| 652 | + | |
| 653 | + | |
| 654 | + | |
| 655 | + | |
| 656 | + | |
| 657 | + | |
| 658 | + | |
| 659 | + | |
| 660 | + | |
| 661 | + | |
| 662 | + | |
| 663 | + | |
| 664 | + | |
| 665 | + | |
| 666 | + | |
| 667 | + | |
| 668 | + | |
| 669 | + | |
| 670 | + | |
| 671 | + | |
| 672 | + | |
| 673 | + | |
| 674 | + | |
| 675 | + | |
| 676 | + | |
| 677 | + | |
| 678 | + | |
| 679 | + | |
| 680 | + | |
| 681 | + | |
| 682 | + | |
| 683 | + | |
| 684 | + | |
| 685 | + | |
| 686 | + | |
| 687 | + | |
| 688 | + | |
| 689 | + | |
| 690 | + | |
| 691 | + | |
| 692 | + | |
| 693 | + | |
| 694 | + | |
| 695 | + | |
| 696 | + | |
| 697 | + | |
| 698 | + | |
| 699 | + | |
| 700 | + | |
| 701 | + | |
| 702 | + |
Lines changed: 16 additions & 0 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
389 | 389 |
| |
390 | 390 |
| |
391 | 391 |
| |
| 392 | + | |
| 393 | + | |
| 394 | + | |
| 395 | + | |
| 396 | + | |
| 397 | + | |
| 398 | + | |
| 399 | + | |
| 400 | + | |
| 401 | + | |
| 402 | + | |
| 403 | + | |
| 404 | + | |
| 405 | + | |
| 406 | + | |
| 407 | + |
0 commit comments
Comments
(0)