- Notifications
You must be signed in to change notification settings - Fork5.3k
Commitb853974
committed
Don't allow CTEs to determine semantic levels of aggregates.
The fix for bug #19055 (commitb0cc0a7) allowed CTE references insub-selects within aggregate functions to affect the semantic levelsassigned to such aggregates. It turns out this broke some relatedcases, leading to assertion failures or strange planner errors suchas "unexpected outer reference in CTE query". After experimentingwith some alternative rules for assigning the semantic level insuch cases, we've come to the conclusion that changing the levelis more likely to break things than be helpful.Therefore, this patch undoes whatb0cc0a7 changed, and insteadinstalls logic to throw an error if there is any reference to aCTE that's below the semantic level that standard SQL rules wouldassign to the aggregate based on its contained Var and Aggref nodes.(The SQL standard disallows sub-selects within aggregate functions,so it can't reach the troublesome case and hence has no rule forwhat to do.)Perhaps someone will come along with a legitimate query that thislogic rejects, and if so probably the example will help us crafta level-adjustment rule that works better than whatb0cc0a7 did.I'm not holding my breath for that though, because the previouslogic had been there for a very long time before bug #19055 withoutcomplaints, and that bug report sure looks to have originated fromfuzzing not from real usage.Likeb0cc0a7, back-patch to all supported branches, thoughsadly that no longer includes v13.Bug: #19106Reported-by: Kamil Monicz <kamil@monicz.dev>Author: Tom Lane <tgl@sss.pgh.pa.us>Discussion:https://postgr.es/m/19106-9dd3668a0734cd72@postgresql.orgBackpatch-through: 141 parent29a3e22 commitb853974
File tree
3 files changed
+88
-43
lines changed- src
- backend/parser
- test/regress
- expected
- sql
3 files changed
+88
-43
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
35 | 35 | | |
36 | 36 | | |
37 | 37 | | |
| 38 | + | |
| 39 | + | |
38 | 40 | | |
39 | 41 | | |
40 | 42 | | |
| |||
54 | 56 | | |
55 | 57 | | |
56 | 58 | | |
57 | | - | |
| 59 | + | |
| 60 | + | |
58 | 61 | | |
59 | 62 | | |
60 | 63 | | |
| |||
332 | 335 | | |
333 | 336 | | |
334 | 337 | | |
335 | | - | |
| 338 | + | |
| 339 | + | |
336 | 340 | | |
337 | 341 | | |
338 | 342 | | |
| |||
626 | 630 | | |
627 | 631 | | |
628 | 632 | | |
629 | | - | |
| 633 | + | |
| 634 | + | |
630 | 635 | | |
631 | 636 | | |
632 | 637 | | |
633 | 638 | | |
634 | 639 | | |
635 | 640 | | |
636 | 641 | | |
| 642 | + | |
| 643 | + | |
637 | 644 | | |
638 | 645 | | |
639 | 646 | | |
| |||
671 | 678 | | |
672 | 679 | | |
673 | 680 | | |
| 681 | + | |
| 682 | + | |
| 683 | + | |
| 684 | + | |
| 685 | + | |
| 686 | + | |
| 687 | + | |
| 688 | + | |
| 689 | + | |
| 690 | + | |
| 691 | + | |
| 692 | + | |
| 693 | + | |
| 694 | + | |
674 | 695 | | |
675 | 696 | | |
676 | 697 | | |
| |||
684 | 705 | | |
685 | 706 | | |
686 | 707 | | |
| 708 | + | |
687 | 709 | | |
688 | 710 | | |
689 | 711 | | |
| |||
699 | 721 | | |
700 | 722 | | |
701 | 723 | | |
| 724 | + | |
| 725 | + | |
| 726 | + | |
| 727 | + | |
| 728 | + | |
| 729 | + | |
| 730 | + | |
702 | 731 | | |
703 | 732 | | |
704 | 733 | | |
| |||
779 | 808 | | |
780 | 809 | | |
781 | 810 | | |
782 | | - | |
783 | | - | |
784 | | - | |
785 | | - | |
786 | | - | |
787 | 811 | | |
788 | 812 | | |
789 | 813 | | |
| |||
795 | 819 | | |
796 | 820 | | |
797 | 821 | | |
798 | | - | |
799 | | - | |
800 | | - | |
| 822 | + | |
| 823 | + | |
| 824 | + | |
| 825 | + | |
| 826 | + | |
| 827 | + | |
801 | 828 | | |
802 | 829 | | |
803 | 830 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2195 | 2195 | | |
2196 | 2196 | | |
2197 | 2197 | | |
2198 | | - | |
2199 | | - | |
2200 | | - | |
| 2198 | + | |
| 2199 | + | |
| 2200 | + | |
| 2201 | + | |
2201 | 2202 | | |
2202 | 2203 | | |
2203 | 2204 | | |
2204 | | - | |
2205 | | - | |
2206 | | - | |
2207 | | - | |
2208 | | - | |
| 2205 | + | |
| 2206 | + | |
| 2207 | + | |
| 2208 | + | |
| 2209 | + | |
| 2210 | + | |
| 2211 | + | |
| 2212 | + | |
| 2213 | + | |
| 2214 | + | |
| 2215 | + | |
| 2216 | + | |
| 2217 | + | |
| 2218 | + | |
| 2219 | + | |
| 2220 | + | |
| 2221 | + | |
2209 | 2222 | | |
2210 | | - | |
2211 | | - | |
2212 | | - | |
2213 | | - | |
2214 | | - | |
2215 | | - | |
2216 | | - | |
2217 | | - | |
2218 | | - | |
2219 | | - | |
2220 | | - | |
2221 | | - | |
2222 | | - | |
2223 | | - | |
2224 | | - | |
2225 | | - | |
2226 | | - | |
2227 | | - | |
| 2223 | + | |
| 2224 | + | |
| 2225 | + | |
| 2226 | + | |
| 2227 | + | |
| 2228 | + | |
| 2229 | + | |
| 2230 | + | |
| 2231 | + | |
| 2232 | + | |
| 2233 | + | |
| 2234 | + | |
| 2235 | + | |
2228 | 2236 | | |
2229 | 2237 | | |
2230 | 2238 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1059 | 1059 | | |
1060 | 1060 | | |
1061 | 1061 | | |
1062 | | - | |
1063 | | - | |
1064 | | - | |
| 1062 | + | |
| 1063 | + | |
| 1064 | + | |
| 1065 | + | |
1065 | 1066 | | |
1066 | 1067 | | |
1067 | 1068 | | |
1068 | 1069 | | |
1069 | | - | |
1070 | | - | |
1071 | | - | |
| 1070 | + | |
| 1071 | + | |
| 1072 | + | |
| 1073 | + | |
| 1074 | + | |
| 1075 | + | |
| 1076 | + | |
| 1077 | + | |
| 1078 | + | |
| 1079 | + | |
| 1080 | + | |
| 1081 | + | |
1072 | 1082 | | |
1073 | 1083 | | |
1074 | 1084 | | |
| |||
0 commit comments
Comments
(0)