forked frompostgres/postgres
- Notifications
You must be signed in to change notification settings - Fork6
Commit739f1d6
committed
Fix mis-handling of outer join quals generated by EquivalenceClasses.
It's possible, in admittedly-rather-contrived cases, for an eclassto generate a derived "join" qual that constrains the post-outer-joinvalue(s) of some RHS variable(s) without mentioning the LHS at all.While the mechanisms were set up to work for this, we fell foul ofthe "get_common_eclass_indexes" filter installed by commit3373c71:it could decide that such an eclass wasn't relevant to the join, sothat the required qual clause wouldn't get emitted there or anywhereelse.To fix, apply get_common_eclass_indexes only at inner joins, whereits rule is still valid. At an outer join, fall back to examining alleclasses that mention either input (or the OJ relid, though it shouldbe impossible for an eclass to mention that without mentioning eitherinput). Perhaps we can improve on that later, but the cost/benefit ofadding more complexity to skip some irrelevant eclasses is dubious.To allow cheaply distinguishing outer from inner joins, pass theojrelid to generate_join_implied_equalities as a separate argument.This also allows cleaning up some sloppiness that had crept intothe definition of its join_relids argument, and it allows accuratecalculation of nominal_join_relids for a child outer join. (Thelatter oversight seems not to have been a live bug, but it certainlycould have caused problems in future.)Also fix what might be a live bug in check_index_predicates: it wasbeing sloppy about what it passed to generate_join_implied_equalities.Per report from Richard Guo.Discussion:https://postgr.es/m/CAMbWs4-DsTBfOvXuw64GdFss2=M5cwtEhY=0DCS7t2gT7P6hSA@mail.gmail.com1 parent03d02f5 commit739f1d6
File tree
7 files changed
+107
-18
lines changed- src
- backend/optimizer
- path
- plan
- util
- include/optimizer
- test/regress
- expected
- sql
7 files changed
+107
-18
lines changedLines changed: 42 additions & 8 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
1366 | 1366 |
| |
1367 | 1367 |
| |
1368 | 1368 |
| |
1369 |
| - | |
1370 |
| - | |
1371 |
| - | |
| 1369 | + | |
| 1370 | + | |
| 1371 | + | |
| 1372 | + | |
| 1373 | + | |
| 1374 | + | |
1372 | 1375 |
| |
1373 | 1376 |
| |
1374 | 1377 |
| |
1375 | 1378 |
| |
1376 | 1379 |
| |
1377 |
| - | |
| 1380 | + | |
| 1381 | + | |
1378 | 1382 |
| |
1379 | 1383 |
| |
1380 | 1384 |
| |
| |||
1392 | 1396 |
| |
1393 | 1397 |
| |
1394 | 1398 |
| |
| 1399 | + | |
| 1400 | + | |
1395 | 1401 |
| |
1396 | 1402 |
| |
1397 | 1403 |
| |
| |||
1400 | 1406 |
| |
1401 | 1407 |
| |
1402 | 1408 |
| |
1403 |
| - | |
| 1409 | + | |
| 1410 | + | |
| 1411 | + | |
| 1412 | + | |
| 1413 | + | |
| 1414 | + | |
| 1415 | + | |
| 1416 | + | |
| 1417 | + | |
| 1418 | + | |
| 1419 | + | |
1404 | 1420 |
| |
1405 |
| - | |
1406 |
| - | |
| 1421 | + | |
| 1422 | + | |
| 1423 | + | |
| 1424 | + | |
| 1425 | + | |
1407 | 1426 |
| |
1408 | 1427 |
| |
1409 | 1428 |
| |
| |||
1447 | 1466 |
| |
1448 | 1467 |
| |
1449 | 1468 |
| |
| 1469 | + | |
| 1470 | + | |
| 1471 | + | |
| 1472 | + | |
1450 | 1473 |
| |
1451 | 1474 |
| |
1452 | 1475 |
| |
| |||
2970 | 2993 |
| |
2971 | 2994 |
| |
2972 | 2995 |
| |
| 2996 | + | |
| 2997 | + | |
2973 | 2998 |
| |
2974 | 2999 |
| |
2975 | 3000 |
| |
| |||
2978 | 3003 |
| |
2979 | 3004 |
| |
2980 | 3005 |
| |
2981 |
| - | |
| 3006 | + | |
| 3007 | + | |
| 3008 | + | |
| 3009 | + | |
| 3010 | + | |
| 3011 | + | |
| 3012 | + | |
| 3013 | + | |
| 3014 | + | |
| 3015 | + | |
2982 | 3016 |
| |
2983 | 3017 |
| |
2984 | 3018 |
| |
|
Lines changed: 5 additions & 1 deletion
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
3349 | 3349 |
| |
3350 | 3350 |
| |
3351 | 3351 |
| |
| 3352 | + | |
| 3353 | + | |
3352 | 3354 |
| |
3353 | 3355 |
| |
3354 | 3356 |
| |
3355 | 3357 |
| |
3356 | 3358 |
| |
3357 | 3359 |
| |
| 3360 | + | |
3358 | 3361 |
| |
3359 | 3362 |
| |
3360 | 3363 |
| |
| |||
3363 | 3366 |
| |
3364 | 3367 |
| |
3365 | 3368 |
| |
3366 |
| - | |
| 3369 | + | |
| 3370 | + | |
3367 | 3371 |
| |
3368 | 3372 |
| |
3369 | 3373 |
| |
|
Lines changed: 2 additions & 1 deletion
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
669 | 669 |
| |
670 | 670 |
| |
671 | 671 |
| |
672 |
| - | |
| 672 | + | |
| 673 | + | |
673 | 674 |
| |
674 | 675 |
| |
675 | 676 |
| |
|
Lines changed: 15 additions & 7 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
47 | 47 |
| |
48 | 48 |
| |
49 | 49 |
| |
50 |
| - | |
| 50 | + | |
| 51 | + | |
51 | 52 |
| |
52 | 53 |
| |
53 | 54 |
| |
| |||
667 | 668 |
| |
668 | 669 |
| |
669 | 670 |
| |
670 |
| - | |
| 671 | + | |
| 672 | + | |
671 | 673 |
| |
672 | 674 |
| |
673 | 675 |
| |
| |||
779 | 781 |
| |
780 | 782 |
| |
781 | 783 |
| |
782 |
| - | |
| 784 | + | |
| 785 | + | |
783 | 786 |
| |
784 | 787 |
| |
785 | 788 |
| |
| |||
1220 | 1223 |
| |
1221 | 1224 |
| |
1222 | 1225 |
| |
| 1226 | + | |
1223 | 1227 |
| |
1224 | 1228 |
| |
1225 | 1229 |
| |
| |||
1234 | 1238 |
| |
1235 | 1239 |
| |
1236 | 1240 |
| |
1237 |
| - | |
| 1241 | + | |
| 1242 | + | |
1238 | 1243 |
| |
1239 | 1244 |
| |
1240 | 1245 |
| |
| |||
1260 | 1265 |
| |
1261 | 1266 |
| |
1262 | 1267 |
| |
1263 |
| - | |
| 1268 | + | |
| 1269 | + | |
1264 | 1270 |
| |
1265 | 1271 |
| |
1266 | 1272 |
| |
| |||
1543 | 1549 |
| |
1544 | 1550 |
| |
1545 | 1551 |
| |
1546 |
| - | |
| 1552 | + | |
| 1553 | + | |
1547 | 1554 |
| |
1548 | 1555 |
| |
1549 | 1556 |
| |
| |||
1665 | 1672 |
| |
1666 | 1673 |
| |
1667 | 1674 |
| |
1668 |
| - | |
| 1675 | + | |
| 1676 | + | |
1669 | 1677 |
| |
1670 | 1678 |
| |
1671 | 1679 |
| |
|
Lines changed: 2 additions & 1 deletion
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
149 | 149 |
| |
150 | 150 |
| |
151 | 151 |
| |
152 |
| - | |
| 152 | + | |
| 153 | + | |
153 | 154 |
| |
154 | 155 |
| |
155 | 156 |
| |
|
Lines changed: 32 additions & 0 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
4100 | 4100 |
| |
4101 | 4101 |
| |
4102 | 4102 |
| |
| 4103 | + | |
| 4104 | + | |
| 4105 | + | |
| 4106 | + | |
| 4107 | + | |
| 4108 | + | |
| 4109 | + | |
| 4110 | + | |
| 4111 | + | |
| 4112 | + | |
| 4113 | + | |
| 4114 | + | |
| 4115 | + | |
| 4116 | + | |
| 4117 | + | |
| 4118 | + | |
| 4119 | + | |
| 4120 | + | |
| 4121 | + | |
| 4122 | + | |
| 4123 | + | |
| 4124 | + | |
| 4125 | + | |
| 4126 | + | |
| 4127 | + | |
| 4128 | + | |
| 4129 | + | |
| 4130 | + | |
| 4131 | + | |
| 4132 | + | |
| 4133 | + | |
| 4134 | + | |
4103 | 4135 |
| |
4104 | 4136 |
| |
4105 | 4137 |
| |
|
Lines changed: 9 additions & 0 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
1386 | 1386 |
| |
1387 | 1387 |
| |
1388 | 1388 |
| |
| 1389 | + | |
| 1390 | + | |
| 1391 | + | |
| 1392 | + | |
| 1393 | + | |
| 1394 | + | |
| 1395 | + | |
| 1396 | + | |
| 1397 | + | |
1389 | 1398 |
| |
1390 | 1399 |
| |
1391 | 1400 |
| |
|
0 commit comments
Comments
(0)