- Notifications
You must be signed in to change notification settings - Fork28
Commit46c508f
committed
Fix PARAM_EXEC assignment mechanism to be safe in the presence of WITH.
The planner previously assumed that parameter Vars having the same absolutequery level, varno, and varattno could safely be assigned the same runtimePARAM_EXEC slot, even though they might be different Vars appearing indifferent subqueries. This was (probably) safe before the introduction ofCTEs, but the lazy-evalution mechanism used for CTEs means that a CTE canbe executed during execution of some other subquery, causing the lifespanof Params at the same syntactic nesting level as the CTE to overlap withuse of the same slots inside the CTE. In 9.1 we created additional hazardsby using the same parameter-assignment technology for nestloop inner scanparameters, but it was broken before that, as illustrated by the addedregression test.To fix, restructure the planner's management of PlannerParamItems so thatitems having different semantic lifespans are kept rigorously separated.This will probably result in complex queries using more runtime PARAM_EXECslots than before, but the slots are cheap enough that this hardly matters.Also, stop generating PlannerParamItems containing Params for subqueryoutputs: all we really need to do is reserve the PARAM_EXEC slot number,and that now only takes incrementing a counter. The planning code issimpler and probably faster than before, as well as being more correct.Per report from Vik Reykja.These changes will mostly also need to be made in the back branches, butI'm going to hold off on that until after 9.2.0 wraps.1 parente20a90e commit46c508f
File tree
11 files changed
+269
-212
lines changed- src
- backend
- nodes
- optimizer
- path
- plan
- prep
- util
- include/nodes
- test/regress
- expected
- sql
11 files changed
+269
-212
lines changedLines changed: 4 additions & 2 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
1666 | 1666 |
| |
1667 | 1667 |
| |
1668 | 1668 |
| |
1669 |
| - | |
1670 | 1669 |
| |
1671 | 1670 |
| |
1672 | 1671 |
| |
1673 | 1672 |
| |
1674 | 1673 |
| |
1675 | 1674 |
| |
1676 | 1675 |
| |
| 1676 | + | |
1677 | 1677 |
| |
1678 | 1678 |
| |
1679 | 1679 |
| |
| |||
1688 | 1688 |
| |
1689 | 1689 |
| |
1690 | 1690 |
| |
| 1691 | + | |
1691 | 1692 |
| |
1692 | 1693 |
| |
1693 | 1694 |
| |
| |||
1754 | 1755 |
| |
1755 | 1756 |
| |
1756 | 1757 |
| |
| 1758 | + | |
1757 | 1759 |
| |
1758 | 1760 |
| |
1759 | 1761 |
| |
| |||
1950 | 1952 |
| |
1951 | 1953 |
| |
1952 | 1954 |
| |
1953 |
| - | |
| 1955 | + | |
1954 | 1956 |
| |
1955 | 1957 |
| |
1956 | 1958 |
| |
|
Lines changed: 7 additions & 0 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
1145 | 1145 |
| |
1146 | 1146 |
| |
1147 | 1147 |
| |
| 1148 | + | |
| 1149 | + | |
| 1150 | + | |
1148 | 1151 |
| |
1149 | 1152 |
| |
1150 | 1153 |
| |
1151 | 1154 |
| |
1152 | 1155 |
| |
1153 | 1156 |
| |
1154 | 1157 |
| |
| 1158 | + | |
| 1159 | + | |
| 1160 | + | |
| 1161 | + | |
1155 | 1162 |
| |
1156 | 1163 |
| |
1157 | 1164 |
| |
|
Lines changed: 32 additions & 31 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
84 | 84 |
| |
85 | 85 |
| |
86 | 86 |
| |
87 |
| - | |
| 87 | + | |
| 88 | + | |
88 | 89 |
| |
89 | 90 |
| |
90 | 91 |
| |
| |||
188 | 189 |
| |
189 | 190 |
| |
190 | 191 |
| |
| 192 | + | |
| 193 | + | |
| 194 | + | |
191 | 195 |
| |
192 | 196 |
| |
193 | 197 |
| |
| |||
199 | 203 |
| |
200 | 204 |
| |
201 | 205 |
| |
| 206 | + | |
| 207 | + | |
| 208 | + | |
| 209 | + | |
| 210 | + | |
| 211 | + | |
202 | 212 |
| |
203 | 213 |
| |
204 | 214 |
| |
| |||
1662 | 1672 |
| |
1663 | 1673 |
| |
1664 | 1674 |
| |
1665 |
| - | |
| 1675 | + | |
| 1676 | + | |
1666 | 1677 |
| |
1667 | 1678 |
| |
1668 | 1679 |
| |
| |||
2620 | 2631 |
| |
2621 | 2632 |
| |
2622 | 2633 |
| |
2623 |
| - | |
2624 |
| - | |
| 2634 | + | |
| 2635 | + | |
2625 | 2636 |
| |
2626 | 2637 |
| |
| 2638 | + | |
| 2639 | + | |
| 2640 | + | |
2627 | 2641 |
| |
2628 | 2642 |
| |
2629 | 2643 |
| |
2630 | 2644 |
| |
2631 | 2645 |
| |
2632 | 2646 |
| |
2633 |
| - | |
| 2647 | + | |
2634 | 2648 |
| |
2635 |
| - | |
2636 |
| - | |
| 2649 | + | |
2637 | 2650 |
| |
2638 |
| - | |
2639 |
| - | |
2640 |
| - | |
| 2651 | + | |
2641 | 2652 |
| |
2642 |
| - | |
2643 |
| - | |
2644 |
| - | |
2645 |
| - | |
2646 |
| - | |
| 2653 | + | |
2647 | 2654 |
| |
2648 | 2655 |
| |
2649 | 2656 |
| |
2650 | 2657 |
| |
2651 | 2658 |
| |
2652 | 2659 |
| |
2653 | 2660 |
| |
2654 |
| - | |
| 2661 | + | |
2655 | 2662 |
| |
2656 |
| - | |
| 2663 | + | |
2657 | 2664 |
| |
2658 | 2665 |
| |
2659 | 2666 |
| |
2660 | 2667 |
| |
2661 |
| - | |
| 2668 | + | |
2662 | 2669 |
| |
2663 | 2670 |
| |
2664 | 2671 |
| |
| |||
2669 | 2676 |
| |
2670 | 2677 |
| |
2671 | 2678 |
| |
2672 |
| - | |
| 2679 | + | |
2673 | 2680 |
| |
2674 | 2681 |
| |
2675 | 2682 |
| |
| |||
2680 | 2687 |
| |
2681 | 2688 |
| |
2682 | 2689 |
| |
2683 |
| - | |
2684 |
| - | |
2685 |
| - | |
2686 |
| - | |
2687 |
| - | |
2688 |
| - | |
2689 |
| - | |
2690 |
| - | |
| 2690 | + | |
2691 | 2691 |
| |
2692 | 2692 |
| |
2693 |
| - | |
| 2693 | + | |
2694 | 2694 |
| |
2695 | 2695 |
| |
2696 | 2696 |
| |
2697 | 2697 |
| |
2698 |
| - | |
| 2698 | + | |
2699 | 2699 |
| |
2700 | 2700 |
| |
2701 | 2701 |
| |
| |||
2706 | 2706 |
| |
2707 | 2707 |
| |
2708 | 2708 |
| |
2709 |
| - | |
| 2709 | + | |
2710 | 2710 |
| |
2711 | 2711 |
| |
2712 | 2712 |
| |
2713 | 2713 |
| |
| 2714 | + | |
| 2715 | + | |
2714 | 2716 |
| |
2715 |
| - | |
2716 | 2717 |
| |
2717 | 2718 |
| |
2718 | 2719 |
| |
|
Lines changed: 4 additions & 3 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
155 | 155 |
| |
156 | 156 |
| |
157 | 157 |
| |
158 |
| - | |
159 | 158 |
| |
160 | 159 |
| |
161 | 160 |
| |
| |||
164 | 163 |
| |
165 | 164 |
| |
166 | 165 |
| |
| 166 | + | |
167 | 167 |
| |
168 | 168 |
| |
169 | 169 |
| |
| |||
243 | 243 |
| |
244 | 244 |
| |
245 | 245 |
| |
246 |
| - | |
| 246 | + | |
247 | 247 |
| |
248 | 248 |
| |
249 | 249 |
| |
| |||
295 | 295 |
| |
296 | 296 |
| |
297 | 297 |
| |
| 298 | + | |
298 | 299 |
| |
299 | 300 |
| |
300 | 301 |
| |
| |||
586 | 587 |
| |
587 | 588 |
| |
588 | 589 |
| |
589 |
| - | |
| 590 | + | |
590 | 591 |
| |
591 | 592 |
| |
592 | 593 |
| |
|
0 commit comments
Comments
(0)