- Notifications
You must be signed in to change notification settings - Fork28
Commitf13e2d1
committed
Fix failure with initplans used conditionally during EvalPlanQual rechecks.
The EvalPlanQual machinery assumes that any initplans (that is,uncorrelated sub-selects) used during an EPQ recheck would have alreadybeen evaluated during the main query; this is implicit in the fact thatexecPlan pointers are not copied into the EPQ estate's es_param_exec_vals.But it's possible for that assumption to fail, if the initplan is onlyreached conditionally. For example, a sub-select inside a CASE expressioncould be reached during a recheck when it had not been previously, if theCASE test depends on a column that was just updated.This bug is old, appearing to date back to my rewrite of EvalPlanQual incommit9f2ee8f, but was not detected until Kyle Samson reported a case.To fix, force all not-yet-evaluated initplans used within the EPQ plansubtree to be evaluated at the start of the recheck, before entering theEPQ environment. This could be inefficient, if such an initplan isexpensive and goes unused again during the recheck --- but that's pilingone layer of improbability atop another. It doesn't seem worth addingmore complexity to prevent that, at least not in the back branches.It was convenient to use the new-in-v11 ExecEvalParamExecParams functionto implement this, but I didn't like either its name or the specifics ofits API, so revise that.Back-patch all the way. Rather than rewrite the patch to avoid dependingon bms_next_member() in the oldest branches, I chose to back-patch thatfunction into 9.4 and 9.3. (This isn't the first time back-patches haveneeded that, and it exhausted my patience.) I also chose to back-patchsome test cases added by commits71404af and342a1ff into 9.4 and 9.3,so that the 9.x versions of eval-plan-qual.spec are all the same.Andrew Gierth diagnosed the problem and contributed the added test cases,though the actual code changes are by me.Discussion:https://postgr.es/m/A033A40A-B234-4324-BE37-272279F7B627@tripadvisor.com1 parent444455c commitf13e2d1
File tree
8 files changed
+147
-37
lines changed- src
- backend/executor
- include/executor
- test/isolation
- expected
- specs
8 files changed
+147
-37
lines changedLines changed: 0 additions & 27 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
2252 | 2252 |
| |
2253 | 2253 |
| |
2254 | 2254 |
| |
2255 |
| - | |
2256 |
| - | |
2257 |
| - | |
2258 |
| - | |
2259 |
| - | |
2260 |
| - | |
2261 |
| - | |
2262 |
| - | |
2263 |
| - | |
2264 |
| - | |
2265 |
| - | |
2266 |
| - | |
2267 |
| - | |
2268 |
| - | |
2269 |
| - | |
2270 |
| - | |
2271 |
| - | |
2272 |
| - | |
2273 |
| - | |
2274 |
| - | |
2275 |
| - | |
2276 |
| - | |
2277 |
| - | |
2278 |
| - | |
2279 |
| - | |
2280 |
| - | |
2281 |
| - | |
2282 | 2255 |
| |
2283 | 2256 |
| |
2284 | 2257 |
| |
|
Lines changed: 36 additions & 4 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
46 | 46 |
| |
47 | 47 |
| |
48 | 48 |
| |
| 49 | + | |
49 | 50 |
| |
50 | 51 |
| |
51 | 52 |
| |
| |||
1727 | 1728 |
| |
1728 | 1729 |
| |
1729 | 1730 |
| |
1730 |
| - | |
1731 |
| - | |
| 1731 | + | |
| 1732 | + | |
1732 | 1733 |
| |
1733 | 1734 |
| |
1734 | 1735 |
| |
| |||
1778 | 1779 |
| |
1779 | 1780 |
| |
1780 | 1781 |
| |
1781 |
| - | |
1782 |
| - | |
| 1782 | + | |
| 1783 | + | |
1783 | 1784 |
| |
1784 | 1785 |
| |
1785 | 1786 |
| |
| |||
3078 | 3079 |
| |
3079 | 3080 |
| |
3080 | 3081 |
| |
| 3082 | + | |
| 3083 | + | |
| 3084 | + | |
| 3085 | + | |
| 3086 | + | |
| 3087 | + | |
| 3088 | + | |
| 3089 | + | |
3081 | 3090 |
| |
3082 | 3091 |
| |
3083 | 3092 |
| |
| |||
3170 | 3179 |
| |
3171 | 3180 |
| |
3172 | 3181 |
| |
| 3182 | + | |
| 3183 | + | |
| 3184 | + | |
| 3185 | + | |
| 3186 | + | |
| 3187 | + | |
| 3188 | + | |
| 3189 | + | |
| 3190 | + | |
| 3191 | + | |
| 3192 | + | |
| 3193 | + | |
| 3194 | + | |
| 3195 | + | |
| 3196 | + | |
| 3197 | + | |
| 3198 | + | |
| 3199 | + | |
| 3200 | + | |
| 3201 | + | |
| 3202 | + | |
| 3203 | + | |
3173 | 3204 |
| |
3174 | 3205 |
| |
3175 | 3206 |
| |
| 3207 | + | |
3176 | 3208 |
| |
3177 | 3209 |
| |
3178 | 3210 |
| |
|
Lines changed: 19 additions & 5 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
23 | 23 |
| |
24 | 24 |
| |
25 | 25 |
| |
26 |
| - | |
27 | 26 |
| |
28 | 27 |
| |
29 | 28 |
| |
| |||
36 | 35 |
| |
37 | 36 |
| |
38 | 37 |
| |
| 38 | + | |
39 | 39 |
| |
40 | 40 |
| |
41 | 41 |
| |
| |||
581 | 581 |
| |
582 | 582 |
| |
583 | 583 |
| |
584 |
| - | |
585 |
| - | |
| 584 | + | |
| 585 | + | |
| 586 | + | |
| 587 | + | |
| 588 | + | |
| 589 | + | |
| 590 | + | |
| 591 | + | |
| 592 | + | |
| 593 | + | |
| 594 | + | |
| 595 | + | |
586 | 596 |
| |
587 | 597 |
| |
588 | 598 |
| |
| |||
831 | 841 |
| |
832 | 842 |
| |
833 | 843 |
| |
834 |
| - | |
835 |
| - | |
| 844 | + | |
| 845 | + | |
| 846 | + | |
| 847 | + | |
| 848 | + | |
| 849 | + | |
836 | 850 |
| |
837 | 851 |
| |
838 | 852 |
| |
|
Lines changed: 42 additions & 0 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
1009 | 1009 |
| |
1010 | 1010 |
| |
1011 | 1011 |
| |
| 1012 | + | |
| 1013 | + | |
| 1014 | + | |
| 1015 | + | |
| 1016 | + | |
| 1017 | + | |
| 1018 | + | |
| 1019 | + | |
| 1020 | + | |
| 1021 | + | |
| 1022 | + | |
1012 | 1023 |
| |
1013 | 1024 |
| |
1014 | 1025 |
| |
| |||
1195 | 1206 |
| |
1196 | 1207 |
| |
1197 | 1208 |
| |
| 1209 | + | |
| 1210 | + | |
| 1211 | + | |
| 1212 | + | |
| 1213 | + | |
| 1214 | + | |
| 1215 | + | |
| 1216 | + | |
| 1217 | + | |
| 1218 | + | |
| 1219 | + | |
| 1220 | + | |
| 1221 | + | |
| 1222 | + | |
| 1223 | + | |
| 1224 | + | |
| 1225 | + | |
| 1226 | + | |
| 1227 | + | |
| 1228 | + | |
| 1229 | + | |
| 1230 | + | |
| 1231 | + | |
| 1232 | + | |
| 1233 | + | |
| 1234 | + | |
| 1235 | + | |
| 1236 | + | |
| 1237 | + | |
| 1238 | + | |
| 1239 | + | |
1198 | 1240 |
| |
1199 | 1241 |
| |
1200 | 1242 |
| |
|
Lines changed: 0 additions & 1 deletion
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
697 | 697 |
| |
698 | 698 |
| |
699 | 699 |
| |
700 |
| - | |
701 | 700 |
| |
702 | 701 |
| |
703 | 702 |
| |
|
Lines changed: 2 additions & 0 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
28 | 28 |
| |
29 | 29 |
| |
30 | 30 |
| |
| 31 | + | |
| 32 | + | |
31 | 33 |
|
Lines changed: 31 additions & 0 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
184 | 184 |
| |
185 | 185 |
| |
186 | 186 |
| |
| 187 | + | |
| 188 | + | |
| 189 | + | |
| 190 | + | |
| 191 | + | |
| 192 | + | |
| 193 | + | |
| 194 | + | |
| 195 | + | |
| 196 | + | |
| 197 | + | |
| 198 | + | |
| 199 | + | |
| 200 | + | |
| 201 | + | |
| 202 | + | |
| 203 | + | |
| 204 | + | |
| 205 | + | |
| 206 | + | |
| 207 | + | |
| 208 | + | |
| 209 | + | |
| 210 | + | |
| 211 | + | |
| 212 | + | |
| 213 | + | |
| 214 | + | |
| 215 | + | |
| 216 | + | |
| 217 | + | |
187 | 218 |
| |
188 | 219 |
| |
189 | 220 |
| |
|
Lines changed: 17 additions & 0 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
92 | 92 |
| |
93 | 93 |
| |
94 | 94 |
| |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
95 | 102 |
| |
96 | 103 |
| |
97 | 104 |
| |
| |||
129 | 136 |
| |
130 | 137 |
| |
131 | 138 |
| |
| 139 | + | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
| 144 | + | |
| 145 | + | |
132 | 146 |
| |
133 | 147 |
| |
134 | 148 |
| |
| |||
137 | 151 |
| |
138 | 152 |
| |
139 | 153 |
| |
| 154 | + | |
140 | 155 |
| |
141 | 156 |
| |
142 | 157 |
| |
| |||
171 | 186 |
| |
172 | 187 |
| |
173 | 188 |
| |
| 189 | + | |
| 190 | + | |
174 | 191 |
| |
175 | 192 |
| |
176 | 193 |
|
0 commit comments
Comments
(0)