forked frompostgres/postgres
- Notifications
You must be signed in to change notification settings - Fork6
Commit9e7e29c
committed
Fix planner problems with LATERAL references in PlaceHolderVars.
The planner largely failed to consider the possibility that aPlaceHolderVar's expression might contain a lateral reference to a Varcoming from somewhere outside the PHV's syntactic scope. We had a previousreport of a problem in this area, which I tried to fix in a quick-hack wayin commit4da6439, but Antonin Houskapointed out that there were still some problems, and investigation turnedup other issues. This patch largely reverts that commit in favor of a morethoroughly thought-through solution. The new theory is that a PHV'sph_eval_at level cannot be higher than its original syntactic level. If itcontains lateral references, those don't change the ph_eval_at level, butrather they create a lateral-reference requirement for the ph_eval_at joinrelation. The code in joinpath.c needs to handle that.Another issue is that createplan.c wasn't handling nested PlaceHolderVarsproperly.In passing, push knowledge of lateral-reference checks for join clausesinto join_clause_is_movable_to. This is mainly so that FDWs don't needto deal with it.This patch doesn't fix the original join-qual-placement problem reported byJeremy Evans (and indeed, one of the new regression test cases shows thewrong answer because of that). But the PlaceHolderVar problems need to befixed before that issue can be addressed, so committing this separatelyseems reasonable.1 parent175ec8d commit9e7e29c
File tree
25 files changed
+838
-309
lines changed- contrib/postgres_fdw
- src
- backend
- nodes
- optimizer
- path
- plan
- prep
- util
- include
- nodes
- optimizer
- test/regress
- expected
- sql
25 files changed
+838
-309
lines changedLines changed: 3 additions & 28 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
540 | 540 |
| |
541 | 541 |
| |
542 | 542 |
| |
543 |
| - | |
544 | 543 |
| |
545 | 544 |
| |
546 | 545 |
| |
| |||
579 | 578 |
| |
580 | 579 |
| |
581 | 580 |
| |
582 |
| - | |
583 |
| - | |
584 |
| - | |
585 |
| - | |
586 |
| - | |
587 |
| - | |
588 |
| - | |
589 |
| - | |
590 |
| - | |
591 |
| - | |
592 |
| - | |
593 |
| - | |
594 |
| - | |
595 |
| - | |
596 |
| - | |
597 |
| - | |
598 |
| - | |
599 | 581 |
| |
600 | 582 |
| |
601 | 583 |
| |
602 | 584 |
| |
603 | 585 |
| |
604 | 586 |
| |
605 |
| - | |
606 |
| - | |
607 |
| - | |
608 |
| - | |
609 |
| - | |
| 587 | + | |
610 | 588 |
| |
611 | 589 |
| |
612 | 590 |
| |
| |||
667 | 645 |
| |
668 | 646 |
| |
669 | 647 |
| |
670 |
| - | |
| 648 | + | |
671 | 649 |
| |
672 | 650 |
| |
673 | 651 |
| |
| |||
682 | 660 |
| |
683 | 661 |
| |
684 | 662 |
| |
685 |
| - | |
| 663 | + | |
686 | 664 |
| |
687 | 665 |
| |
688 |
| - | |
689 |
| - | |
690 |
| - | |
691 | 666 |
| |
692 | 667 |
| |
693 | 668 |
| |
|
Lines changed: 2 additions & 1 deletion
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
1921 | 1921 |
| |
1922 | 1922 |
| |
1923 | 1923 |
| |
1924 |
| - | |
1925 | 1924 |
| |
| 1925 | + | |
1926 | 1926 |
| |
1927 | 1927 |
| |
1928 | 1928 |
| |
| |||
1956 | 1956 |
| |
1957 | 1957 |
| |
1958 | 1958 |
| |
| 1959 | + | |
1959 | 1960 |
| |
1960 | 1961 |
| |
1961 | 1962 |
| |
|
Lines changed: 13 additions & 8 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
763 | 763 |
| |
764 | 764 |
| |
765 | 765 |
| |
766 |
| - | |
767 |
| - | |
768 |
| - | |
769 |
| - | |
770 |
| - | |
| 766 | + | |
| 767 | + | |
| 768 | + | |
| 769 | + | |
| 770 | + | |
| 771 | + | |
| 772 | + | |
| 773 | + | |
771 | 774 |
| |
772 | 775 |
| |
| 776 | + | |
| 777 | + | |
773 | 778 |
| |
774 |
| - | |
775 | 779 |
| |
776 | 780 |
| |
777 | 781 |
| |
| |||
796 | 800 |
| |
797 | 801 |
| |
798 | 802 |
| |
799 |
| - | |
800 | 803 |
| |
| 804 | + | |
801 | 805 |
| |
802 | 806 |
| |
803 | 807 |
| |
| |||
819 | 823 |
| |
820 | 824 |
| |
821 | 825 |
| |
822 |
| - | |
| 826 | + | |
823 | 827 |
| |
| 828 | + | |
824 | 829 |
| |
825 | 830 |
| |
826 | 831 |
| |
|
Lines changed: 3 additions & 1 deletion
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
1756 | 1756 |
| |
1757 | 1757 |
| |
1758 | 1758 |
| |
| 1759 | + | |
1759 | 1760 |
| |
1760 | 1761 |
| |
1761 | 1762 |
| |
| |||
1913 | 1914 |
| |
1914 | 1915 |
| |
1915 | 1916 |
| |
1916 |
| - | |
1917 | 1917 |
| |
| 1918 | + | |
1918 | 1919 |
| |
1919 | 1920 |
| |
1920 | 1921 |
| |
| |||
1938 | 1939 |
| |
1939 | 1940 |
| |
1940 | 1941 |
| |
| 1942 | + | |
1941 | 1943 |
| |
1942 | 1944 |
| |
1943 | 1945 |
| |
|
Lines changed: 14 additions & 0 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
802 | 802 |
| |
803 | 803 |
| |
804 | 804 |
| |
| 805 | + | |
| 806 | + | |
| 807 | + | |
| 808 | + | |
| 809 | + | |
| 810 | + | |
| 811 | + | |
| 812 | + | |
| 813 | + | |
| 814 | + | |
| 815 | + | |
| 816 | + | |
| 817 | + | |
| 818 | + | |
805 | 819 |
| |
806 | 820 |
|
Lines changed: 6 additions & 10 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
386 | 386 |
| |
387 | 387 |
| |
388 | 388 |
| |
389 |
| - | |
390 |
| - | |
| 389 | + | |
391 | 390 |
| |
392 | 391 |
| |
393 | 392 |
| |
| |||
550 | 549 |
| |
551 | 550 |
| |
552 | 551 |
| |
553 |
| - | |
554 |
| - | |
| 552 | + | |
| 553 | + | |
555 | 554 |
| |
556 | 555 |
| |
557 | 556 |
| |
| |||
1355 | 1354 |
| |
1356 | 1355 |
| |
1357 | 1356 |
| |
1358 |
| - | |
1359 |
| - | |
| 1357 | + | |
1360 | 1358 |
| |
1361 | 1359 |
| |
1362 | 1360 |
| |
| |||
1408 | 1406 |
| |
1409 | 1407 |
| |
1410 | 1408 |
| |
1411 |
| - | |
1412 |
| - | |
1413 |
| - | |
1414 |
| - | |
| 1409 | + | |
| 1410 | + | |
1415 | 1411 |
| |
1416 | 1412 |
| |
1417 | 1413 |
| |
|
Lines changed: 3 additions & 4 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
3943 | 3943 |
| |
3944 | 3944 |
| |
3945 | 3945 |
| |
3946 |
| - | |
3947 |
| - | |
3948 |
| - | |
3949 |
| - | |
| 3946 | + | |
| 3947 | + | |
| 3948 | + | |
3950 | 3949 |
| |
3951 | 3950 |
| |
3952 | 3951 |
| |
|
Lines changed: 13 additions & 39 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
141 | 141 |
| |
142 | 142 |
| |
143 | 143 |
| |
144 |
| - | |
145 | 144 |
| |
146 | 145 |
| |
147 | 146 |
| |
148 | 147 |
| |
149 |
| - | |
150 | 148 |
| |
151 | 149 |
| |
152 | 150 |
| |
| |||
220 | 218 |
| |
221 | 219 |
| |
222 | 220 |
| |
223 |
| - | |
224 |
| - | |
225 |
| - | |
226 |
| - | |
227 |
| - | |
228 |
| - | |
229 |
| - | |
230 |
| - | |
| 221 | + | |
| 222 | + | |
| 223 | + | |
| 224 | + | |
| 225 | + | |
| 226 | + | |
| 227 | + | |
| 228 | + | |
231 | 229 |
| |
232 | 230 |
| |
233 | 231 |
| |
| |||
236 | 234 |
| |
237 | 235 |
| |
238 | 236 |
| |
239 |
| - | |
240 | 237 |
| |
241 | 238 |
| |
242 | 239 |
| |
| |||
246 | 243 |
| |
247 | 244 |
| |
248 | 245 |
| |
249 |
| - | |
250 |
| - | |
251 |
| - | |
252 |
| - | |
253 |
| - | |
254 |
| - | |
255 |
| - | |
256 |
| - | |
257 |
| - | |
258 |
| - | |
259 |
| - | |
260 |
| - | |
261 |
| - | |
262 |
| - | |
263 |
| - | |
264 |
| - | |
265 |
| - | |
266 | 246 |
| |
267 | 247 |
| |
268 | 248 |
| |
| |||
303 | 283 |
| |
304 | 284 |
| |
305 | 285 |
| |
306 |
| - | |
| 286 | + | |
307 | 287 |
| |
308 | 288 |
| |
309 | 289 |
| |
310 | 290 |
| |
311 | 291 |
| |
312 | 292 |
| |
313 | 293 |
| |
314 |
| - | |
| 294 | + | |
315 | 295 |
| |
316 | 296 |
| |
317 | 297 |
| |
| |||
1957 | 1937 |
| |
1958 | 1938 |
| |
1959 | 1939 |
| |
1960 |
| - | |
1961 | 1940 |
| |
1962 | 1941 |
| |
1963 | 1942 |
| |
| |||
1969 | 1948 |
| |
1970 | 1949 |
| |
1971 | 1950 |
| |
1972 |
| - | |
1973 |
| - | |
1974 |
| - | |
1975 |
| - | |
1976 |
| - | |
| 1951 | + | |
1977 | 1952 |
| |
1978 | 1953 |
| |
1979 | 1954 |
| |
| |||
1991 | 1966 |
| |
1992 | 1967 |
| |
1993 | 1968 |
| |
1994 |
| - | |
1995 | 1969 |
| |
1996 | 1970 |
| |
1997 | 1971 |
| |
| |||
2012 | 1986 |
| |
2013 | 1987 |
| |
2014 | 1988 |
| |
2015 |
| - | |
| 1989 | + | |
2016 | 1990 |
| |
2017 | 1991 |
| |
2018 | 1992 |
| |
| |||
2644 | 2618 |
| |
2645 | 2619 |
| |
2646 | 2620 |
| |
2647 |
| - | |
| 2621 | + | |
2648 | 2622 |
| |
2649 | 2623 |
| |
2650 | 2624 |
| |
|
0 commit comments
Comments
(0)