- Notifications
You must be signed in to change notification settings - Fork28
Commit8279eb4
committed
Fix planner's handling of outer PlaceHolderVars within subqueries.
For some reason, in the original coding of the PlaceHolderVar mechanismI had supposed that PlaceHolderVars couldn't propagate into subqueries.That is of course entirely possible. When it happens, we need to treatan outer-level PlaceHolderVar much like an outer Var or Aggref, that isSS_replace_correlation_vars() needs to replace the PlaceHolderVar witha Param, and then when building the finished SubPlan we have to providethe PlaceHolderVar expression as an actual parameter for the SubPlan.The handling of the contained expression is a bit delicate but it can betreated exactly like an Aggref's expression.In addition to the missing logic in subselect.c, prepjointree.c was failingto search subqueries for PlaceHolderVars that need their relids adjustedduring subquery pullup. It looks like everyplace else that touchesPlaceHolderVars got it right, though.Per report from Mark Murawski. In 9.1 and HEAD, queries affected by thisoversight would fail with "ERROR: Upper-level PlaceHolderVar found wherenot expected". But in 9.0 and 8.4, you'd silently get possibly-wronganswers, since the value transmitted into the subquery wouldn't go to nullwhen it should.1 parented61127 commit8279eb4
File tree
5 files changed
+195
-49
lines changed- src
- backend/optimizer
- plan
- prep
- include/nodes
- test/regress
- expected
- sql
5 files changed
+195
-49
lines changedLines changed: 107 additions & 44 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
191 | 191 |
| |
192 | 192 |
| |
193 | 193 |
| |
194 |
| - | |
195 |
| - | |
| 194 | + | |
| 195 | + | |
196 | 196 |
| |
197 |
| - | |
| 197 | + | |
198 | 198 |
| |
199 |
| - | |
200 |
| - | |
| 199 | + | |
| 200 | + | |
201 | 201 |
| |
202 |
| - | |
203 | 202 |
| |
204 | 203 |
| |
205 | 204 |
| |
206 | 205 |
| |
207 | 206 |
| |
208 |
| - | |
209 |
| - | |
| 207 | + | |
210 | 208 |
| |
211 | 209 |
| |
212 |
| - | |
213 | 210 |
| |
214 | 211 |
| |
215 | 212 |
| |
| |||
218 | 215 |
| |
219 | 216 |
| |
220 | 217 |
| |
| 218 | + | |
221 | 219 |
| |
222 |
| - | |
| 220 | + | |
223 | 221 |
| |
224 | 222 |
| |
225 | 223 |
| |
226 | 224 |
| |
227 |
| - | |
| 225 | + | |
| 226 | + | |
| 227 | + | |
228 | 228 |
| |
229 |
| - | |
230 |
| - | |
| 229 | + | |
| 230 | + | |
| 231 | + | |
231 | 232 |
| |
232 |
| - | |
233 |
| - | |
234 |
| - | |
| 233 | + | |
| 234 | + | |
| 235 | + | |
235 | 236 |
| |
236 |
| - | |
| 237 | + | |
237 | 238 |
| |
238 |
| - | |
239 |
| - | |
| 239 | + | |
| 240 | + | |
| 241 | + | |
| 242 | + | |
| 243 | + | |
| 244 | + | |
| 245 | + | |
| 246 | + | |
| 247 | + | |
| 248 | + | |
| 249 | + | |
| 250 | + | |
| 251 | + | |
| 252 | + | |
| 253 | + | |
| 254 | + | |
| 255 | + | |
| 256 | + | |
| 257 | + | |
| 258 | + | |
| 259 | + | |
| 260 | + | |
| 261 | + | |
| 262 | + | |
| 263 | + | |
| 264 | + | |
| 265 | + | |
| 266 | + | |
| 267 | + | |
| 268 | + | |
| 269 | + | |
| 270 | + | |
| 271 | + | |
| 272 | + | |
| 273 | + | |
| 274 | + | |
| 275 | + | |
| 276 | + | |
| 277 | + | |
| 278 | + | |
| 279 | + | |
| 280 | + | |
| 281 | + | |
| 282 | + | |
| 283 | + | |
| 284 | + | |
| 285 | + | |
| 286 | + | |
| 287 | + | |
| 288 | + | |
240 | 289 |
| |
241 | 290 |
| |
242 | 291 |
| |
| |||
555 | 604 |
| |
556 | 605 |
| |
557 | 606 |
| |
558 |
| - | |
559 |
| - | |
560 |
| - | |
| 607 | + | |
| 608 | + | |
| 609 | + | |
561 | 610 |
| |
562 | 611 |
| |
563 | 612 |
| |
564 | 613 |
| |
565 |
| - | |
566 |
| - | |
| 614 | + | |
| 615 | + | |
| 616 | + | |
567 | 617 |
| |
568 |
| - | |
| 618 | + | |
| 619 | + | |
569 | 620 |
| |
570 | 621 |
| |
571 | 622 |
| |
| |||
1668 | 1719 |
| |
1669 | 1720 |
| |
1670 | 1721 |
| |
1671 |
| - | |
| 1722 | + | |
1672 | 1723 |
| |
1673 | 1724 |
| |
1674 |
| - | |
1675 |
| - | |
1676 |
| - | |
1677 |
| - | |
1678 |
| - | |
1679 |
| - | |
1680 |
| - | |
1681 |
| - | |
1682 |
| - | |
1683 |
| - | |
| 1725 | + | |
| 1726 | + | |
| 1727 | + | |
| 1728 | + | |
| 1729 | + | |
| 1730 | + | |
| 1731 | + | |
| 1732 | + | |
| 1733 | + | |
| 1734 | + | |
| 1735 | + | |
1684 | 1736 |
| |
1685 | 1737 |
| |
1686 |
| - | |
1687 |
| - | |
1688 |
| - | |
| 1738 | + | |
| 1739 | + | |
| 1740 | + | |
1689 | 1741 |
| |
1690 | 1742 |
| |
1691 | 1743 |
| |
| |||
1705 | 1757 |
| |
1706 | 1758 |
| |
1707 | 1759 |
| |
| 1760 | + | |
| 1761 | + | |
| 1762 | + | |
| 1763 | + | |
| 1764 | + | |
| 1765 | + | |
1708 | 1766 |
| |
1709 | 1767 |
| |
1710 | 1768 |
| |
| |||
1764 | 1822 |
| |
1765 | 1823 |
| |
1766 | 1824 |
| |
1767 |
| - | |
1768 |
| - | |
1769 |
| - | |
1770 |
| - | |
| 1825 | + | |
| 1826 | + | |
| 1827 | + | |
| 1828 | + | |
1771 | 1829 |
| |
1772 |
| - | |
| 1830 | + | |
| 1831 | + | |
| 1832 | + | |
| 1833 | + | |
| 1834 | + | |
| 1835 | + | |
1773 | 1836 |
| |
1774 | 1837 |
| |
1775 | 1838 |
| |
|
Lines changed: 16 additions & 3 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
2069 | 2069 |
| |
2070 | 2070 |
| |
2071 | 2071 |
| |
2072 |
| - | |
2073 |
| - | |
2074 | 2072 |
| |
2075 | 2073 |
| |
2076 | 2074 |
| |
| |||
2081 | 2079 |
| |
2082 | 2080 |
| |
2083 | 2081 |
| |
| 2082 | + | |
2084 | 2083 |
| |
2085 | 2084 |
| |
2086 | 2085 |
| |
| |||
2094 | 2093 |
| |
2095 | 2094 |
| |
2096 | 2095 |
| |
2097 |
| - | |
| 2096 | + | |
| 2097 | + | |
2098 | 2098 |
| |
2099 | 2099 |
| |
2100 | 2100 |
| |
| |||
2103 | 2103 |
| |
2104 | 2104 |
| |
2105 | 2105 |
| |
| 2106 | + | |
| 2107 | + | |
| 2108 | + | |
| 2109 | + | |
| 2110 | + | |
| 2111 | + | |
| 2112 | + | |
| 2113 | + | |
| 2114 | + | |
| 2115 | + | |
| 2116 | + | |
| 2117 | + | |
2106 | 2118 |
| |
2107 | 2119 |
| |
2108 | 2120 |
| |
| |||
2119 | 2131 |
| |
2120 | 2132 |
| |
2121 | 2133 |
| |
| 2134 | + | |
2122 | 2135 |
| |
2123 | 2136 |
| |
2124 | 2137 |
| |
|
Lines changed: 4 additions & 2 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
1445 | 1445 |
| |
1446 | 1446 |
| |
1447 | 1447 |
| |
1448 |
| - | |
1449 |
| - | |
| 1448 | + | |
| 1449 | + | |
| 1450 | + | |
| 1451 | + | |
1450 | 1452 |
| |
1451 | 1453 |
| |
1452 | 1454 |
| |
|
Lines changed: 47 additions & 0 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
2571 | 2571 |
| |
2572 | 2572 |
| |
2573 | 2573 |
| |
| 2574 | + | |
| 2575 | + | |
| 2576 | + | |
| 2577 | + | |
| 2578 | + | |
| 2579 | + | |
| 2580 | + | |
| 2581 | + | |
| 2582 | + | |
| 2583 | + | |
| 2584 | + | |
| 2585 | + | |
| 2586 | + | |
| 2587 | + | |
| 2588 | + | |
| 2589 | + | |
| 2590 | + | |
| 2591 | + | |
| 2592 | + | |
| 2593 | + | |
| 2594 | + | |
| 2595 | + | |
| 2596 | + | |
| 2597 | + | |
| 2598 | + | |
| 2599 | + | |
| 2600 | + | |
| 2601 | + | |
| 2602 | + | |
| 2603 | + | |
| 2604 | + | |
| 2605 | + | |
| 2606 | + | |
| 2607 | + | |
| 2608 | + | |
| 2609 | + | |
| 2610 | + | |
| 2611 | + | |
| 2612 | + | |
| 2613 | + | |
| 2614 | + | |
| 2615 | + | |
| 2616 | + | |
| 2617 | + | |
| 2618 | + | |
| 2619 | + | |
| 2620 | + | |
2574 | 2621 |
| |
2575 | 2622 |
| |
2576 | 2623 |
| |
|
Lines changed: 21 additions & 0 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
662 | 662 |
| |
663 | 663 |
| |
664 | 664 |
| |
| 665 | + | |
| 666 | + | |
| 667 | + | |
| 668 | + | |
| 669 | + | |
| 670 | + | |
| 671 | + | |
| 672 | + | |
| 673 | + | |
| 674 | + | |
| 675 | + | |
| 676 | + | |
| 677 | + | |
| 678 | + | |
| 679 | + | |
| 680 | + | |
| 681 | + | |
| 682 | + | |
| 683 | + | |
| 684 | + | |
| 685 | + | |
665 | 686 |
| |
666 | 687 |
| |
667 | 688 |
| |
|
0 commit comments
Comments
(0)