forked frompostgres/postgres
- Notifications
You must be signed in to change notification settings - Fork6
Commitcad5692
committed
Fix up join removal's interaction with PlaceHolderVars.
The portion of join_is_removable() that checks PlaceHolderVarscan be made a little more accurate and intelligible than it was.The key point is that we can allow join removal even if a PHVmentions the target rel in ph_eval_at, if that mention was onlyadded as a consequence of forcing the PHV up to a join levelthat's at/above the outer join we're trying to get rid of.We can check that by testing for the OJ's relid appearing inph_eval_at, indicating that it's supposed to be evaluated afterthe outer join, plus the existing test that the containedexpression doesn't actually mention the target rel.While here, add an explicit check that there'll be something leftin ph_eval_at after we remove the target rel and OJ relid. Thereis an Assert later on about that, and I'm not too sure that thecase could happen for a PHV satisfying the other constraints,but let's just check. (There was previously a bms_is_subset testthat meant to cover this risk, but it's broken now because itdoesn't account for the fact that we'll also remove the OJ relid.)The real reason for revisiting this code though is that theAssert I left behind in8538519 turns out to be easilyreachable, because if a PHV of this sort appears in an upper-levelqual clause then that clause's clause_relids will include thePHV's ph_eval_at relids. This is a mirage though: we have or soonwill remove these relids from the PHV's ph_eval_at, and thereforethey no longer belong in qual clauses' clause_relids either.Remove that Assert in join_is_removable, and replace the similarone in remove_rel_from_query with code to remove the deleted relidsfrom clause_relids.Per bug #17773 from Robins Tharakan.Discussion:https://postgr.es/m/17773-a592e6cedbc7bac5@postgresql.org1 parent7ba09ef commitcad5692
File tree
3 files changed
+58
-22
lines changed- src
- backend/optimizer/plan
- test/regress
- expected
- sql
3 files changed
+58
-22
lines changedLines changed: 30 additions & 22 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
217 | 217 |
| |
218 | 218 |
| |
219 | 219 |
| |
220 |
| - | |
221 |
| - | |
222 |
| - | |
223 |
| - | |
224 |
| - | |
225 |
| - | |
| 220 | + | |
| 221 | + | |
| 222 | + | |
| 223 | + | |
| 224 | + | |
| 225 | + | |
226 | 226 |
| |
227 | 227 |
| |
228 | 228 |
| |
229 | 229 |
| |
230 | 230 |
| |
231 | 231 |
| |
232 | 232 |
| |
233 |
| - | |
234 |
| - | |
235 | 233 |
| |
236 | 234 |
| |
237 |
| - | |
| 235 | + | |
| 236 | + | |
| 237 | + | |
| 238 | + | |
| 239 | + | |
| 240 | + | |
| 241 | + | |
| 242 | + | |
| 243 | + | |
| 244 | + | |
238 | 245 |
| |
| 246 | + | |
239 | 247 |
| |
240 | 248 |
| |
241 |
| - | |
| 249 | + | |
242 | 250 |
| |
243 | 251 |
| |
244 | 252 |
| |
| |||
270 | 278 |
| |
271 | 279 |
| |
272 | 280 |
| |
273 |
| - | |
274 |
| - | |
275 |
| - | |
276 |
| - | |
277 |
| - | |
278 |
| - | |
279 |
| - | |
280 | 281 |
| |
281 |
| - | |
282 | 282 |
| |
283 | 283 |
| |
284 | 284 |
| |
| |||
465 | 465 |
| |
466 | 466 |
| |
467 | 467 |
| |
468 |
| - | |
469 |
| - | |
470 |
| - | |
471 | 468 |
| |
472 |
| - | |
| 469 | + | |
| 470 | + | |
| 471 | + | |
| 472 | + | |
| 473 | + | |
| 474 | + | |
473 | 475 |
| |
474 | 476 |
| |
| 477 | + | |
| 478 | + | |
| 479 | + | |
| 480 | + | |
| 481 | + | |
| 482 | + | |
475 | 483 |
| |
476 | 484 |
| |
477 | 485 |
| |
|
Lines changed: 20 additions & 0 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
5213 | 5213 |
| |
5214 | 5214 |
| |
5215 | 5215 |
| |
| 5216 | + | |
| 5217 | + | |
| 5218 | + | |
| 5219 | + | |
| 5220 | + | |
| 5221 | + | |
| 5222 | + | |
| 5223 | + | |
| 5224 | + | |
| 5225 | + | |
| 5226 | + | |
| 5227 | + | |
| 5228 | + | |
| 5229 | + | |
| 5230 | + | |
| 5231 | + | |
| 5232 | + | |
| 5233 | + | |
| 5234 | + | |
| 5235 | + | |
5216 | 5236 |
| |
5217 | 5237 |
| |
5218 | 5238 |
| |
|
Lines changed: 8 additions & 0 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
1888 | 1888 |
| |
1889 | 1889 |
| |
1890 | 1890 |
| |
| 1891 | + | |
| 1892 | + | |
| 1893 | + | |
| 1894 | + | |
| 1895 | + | |
| 1896 | + | |
| 1897 | + | |
| 1898 | + | |
1891 | 1899 |
| |
1892 | 1900 |
| |
1893 | 1901 |
| |
|
0 commit comments
Comments
(0)