forked frompostgres/postgres
- Notifications
You must be signed in to change notification settings - Fork6
Commit4f11245

Richard Guo
Check the validity of commutators for merge/hash clauses
When creating merge or hash join plans in createplan.c, the merge orhash clauses may need to get commuted to ensure that the outer var ison the left and the inner var is on the right if they are not alreadyin the expected form. This requires that their operators havecommutators. Failing to find a commutator at this stage would resultin 'ERROR: could not find commutator for operator xxx', with noopportunity to select an alternative plan.Typically, this is not an issue because mergejoinable or hashableoperators are expected to always have valid commutators. But in someartificial cases this assumption may not hold true. Therefore, herein this patch we check the validity of commutators for clauses in theform "inner op outer" when selecting mergejoin/hash clauses, andconsider a clause unusable for the current pair of outer and innerrelations if it lacks a commutator.There are not (and should not be) any such operators built intoPostgres that are mergejoinable or hashable but have no commutators;so we leverage the alias type 'int8alias1' created in equivclass.sqlto build the test case. This is why the test case is included inequivclass.sql rather than in join.sql.Although this is arguably a bug fix, it cannot be reproduced withoutinstalling an incomplete opclass, which is unlikely to happen inpractice, so no back-patch.Reported-by: Alexander PyhalovAuthor: Richard GuoReviewed-by: Tom LaneDiscussion:https://postgr.es/m/c59ec04a2fef94d9ffc35a9b17dfc081@postgrespro.ru1 parent08b9b9e commit4f11245
File tree
3 files changed
+114
-0
lines changed- src
- backend/optimizer/path
- test/regress
- expected
- sql
3 files changed
+114
-0
lines changedLines changed: 32 additions & 0 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
25 | 25 |
| |
26 | 26 |
| |
27 | 27 |
| |
| 28 | + | |
28 | 29 |
| |
29 | 30 |
| |
30 | 31 |
| |
| |||
2266 | 2267 |
| |
2267 | 2268 |
| |
2268 | 2269 |
| |
| 2270 | + | |
| 2271 | + | |
| 2272 | + | |
| 2273 | + | |
| 2274 | + | |
| 2275 | + | |
| 2276 | + | |
| 2277 | + | |
| 2278 | + | |
| 2279 | + | |
| 2280 | + | |
| 2281 | + | |
| 2282 | + | |
| 2283 | + | |
2269 | 2284 |
| |
2270 | 2285 |
| |
2271 | 2286 |
| |
| |||
2540 | 2555 |
| |
2541 | 2556 |
| |
2542 | 2557 |
| |
| 2558 | + | |
| 2559 | + | |
| 2560 | + | |
| 2561 | + | |
| 2562 | + | |
| 2563 | + | |
| 2564 | + | |
| 2565 | + | |
| 2566 | + | |
| 2567 | + | |
| 2568 | + | |
| 2569 | + | |
| 2570 | + | |
| 2571 | + | |
| 2572 | + | |
| 2573 | + | |
| 2574 | + | |
2543 | 2575 |
| |
2544 | 2576 |
| |
2545 | 2577 |
| |
|
Lines changed: 48 additions & 0 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
451 | 451 |
| |
452 | 452 |
| |
453 | 453 |
| |
| 454 | + | |
| 455 | + | |
| 456 | + | |
| 457 | + | |
| 458 | + | |
| 459 | + | |
| 460 | + | |
| 461 | + | |
| 462 | + | |
| 463 | + | |
| 464 | + | |
| 465 | + | |
| 466 | + | |
| 467 | + | |
| 468 | + | |
| 469 | + | |
| 470 | + | |
| 471 | + | |
| 472 | + | |
| 473 | + | |
| 474 | + | |
| 475 | + | |
| 476 | + | |
| 477 | + | |
| 478 | + | |
| 479 | + | |
| 480 | + | |
| 481 | + | |
| 482 | + | |
| 483 | + | |
| 484 | + | |
| 485 | + | |
| 486 | + | |
| 487 | + | |
| 488 | + | |
| 489 | + | |
| 490 | + | |
| 491 | + | |
| 492 | + | |
| 493 | + | |
| 494 | + | |
| 495 | + | |
| 496 | + | |
| 497 | + | |
| 498 | + | |
| 499 | + | |
| 500 | + | |
| 501 | + |
Lines changed: 34 additions & 0 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
269 | 269 |
| |
270 | 270 |
| |
271 | 271 |
| |
| 272 | + | |
| 273 | + | |
| 274 | + | |
| 275 | + | |
| 276 | + | |
| 277 | + | |
| 278 | + | |
| 279 | + | |
| 280 | + | |
| 281 | + | |
| 282 | + | |
| 283 | + | |
| 284 | + | |
| 285 | + | |
| 286 | + | |
| 287 | + | |
| 288 | + | |
| 289 | + | |
| 290 | + | |
| 291 | + | |
| 292 | + | |
| 293 | + | |
| 294 | + | |
| 295 | + | |
| 296 | + | |
| 297 | + | |
| 298 | + | |
| 299 | + | |
| 300 | + | |
| 301 | + | |
| 302 | + | |
| 303 | + | |
| 304 | + | |
| 305 | + |
0 commit comments
Comments
(0)