forked frompostgres/postgres
- Notifications
You must be signed in to change notification settings - Fork6
Commitace3c7c
committed
Fix misprocessing of equivalence classes involving record_eq().
canonicalize_ec_expression() is supposed to agree with coerce_type() as towhether a RelabelType should be inserted to make a subexpression be validinput for the operators of a given opclass. However, it did the wrongthing with named-composite-type inputs to record_eq(): it put in aRelabelType to RECORDOID, which the parser doesn't. In some cases this washarmless because all code paths involving a particular equivalence classdid the same thing, but in other cases this would result in failing torecognize a composite-type expression as being a member of an equivalenceclass that it actually is a member of. The most obvious bad effect was tofail to recognize that an index on a composite column could provide thesort order needed for a mergejoin on that column, as reported by TeodorSigaev. I think there might be other, subtler, cases that result inmisoptimization. It also seems possible that an unwanted RelabelTypewould sometimes get into an emitted plan --- but because record_eq andfriends don't examine the declared type of their input expressions, thatwould not create any visible problems.To fix, just treat RECORDOID as if it were a polymorphic type, which insome sense it is. We might want to consider formalizing that a bit moresomeday, but for the moment this seems to be the only place where anIsPolymorphicType() test ought to include RECORDOID as well.This has been broken for a long time, so back-patch to all supportedbranches.Discussion:https://postgr.es/m/a6b22369-e3bf-4d49-f59d-0c41d3551e81@sigaev.ru1 parentf924911 commitace3c7c
File tree
3 files changed
+52
-1
lines changed- src
- backend/optimizer/path
- test/regress
- expected
- sql
3 files changed
+52
-1
lines changedLines changed: 2 additions & 1 deletion
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
424 | 424 |
| |
425 | 425 |
| |
426 | 426 |
| |
| 427 | + | |
427 | 428 |
| |
428 |
| - | |
| 429 | + | |
429 | 430 |
| |
430 | 431 |
| |
431 | 432 |
| |
|
Lines changed: 30 additions & 0 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
2650 | 2650 |
| |
2651 | 2651 |
| |
2652 | 2652 |
| |
| 2653 | + | |
| 2654 | + | |
| 2655 | + | |
| 2656 | + | |
| 2657 | + | |
| 2658 | + | |
| 2659 | + | |
| 2660 | + | |
| 2661 | + | |
| 2662 | + | |
| 2663 | + | |
| 2664 | + | |
| 2665 | + | |
| 2666 | + | |
| 2667 | + | |
| 2668 | + | |
| 2669 | + | |
| 2670 | + | |
| 2671 | + | |
| 2672 | + | |
| 2673 | + | |
| 2674 | + | |
| 2675 | + | |
| 2676 | + | |
| 2677 | + | |
| 2678 | + | |
| 2679 | + | |
| 2680 | + | |
| 2681 | + | |
| 2682 | + | |
2653 | 2683 |
| |
2654 | 2684 |
| |
2655 | 2685 |
| |
|
Lines changed: 20 additions & 0 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
664 | 664 |
| |
665 | 665 |
| |
666 | 666 |
| |
| 667 | + | |
| 668 | + | |
| 669 | + | |
| 670 | + | |
| 671 | + | |
| 672 | + | |
| 673 | + | |
| 674 | + | |
| 675 | + | |
| 676 | + | |
| 677 | + | |
| 678 | + | |
| 679 | + | |
| 680 | + | |
| 681 | + | |
| 682 | + | |
| 683 | + | |
| 684 | + | |
| 685 | + | |
| 686 | + | |
667 | 687 |
| |
668 | 688 |
| |
669 | 689 |
| |
|
0 commit comments
Comments
(0)