- Notifications
You must be signed in to change notification settings - Fork28
Commita11b3bd
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 parent7fc7dac commita11b3bd
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 | |
---|---|---|---|
| |||
497 | 497 |
| |
498 | 498 |
| |
499 | 499 |
| |
| 500 | + | |
500 | 501 |
| |
501 |
| - | |
| 502 | + | |
502 | 503 |
| |
503 | 504 |
| |
504 | 505 |
| |
|
Lines changed: 30 additions & 0 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
2672 | 2672 |
| |
2673 | 2673 |
| |
2674 | 2674 |
| |
| 2675 | + | |
| 2676 | + | |
| 2677 | + | |
| 2678 | + | |
| 2679 | + | |
| 2680 | + | |
| 2681 | + | |
| 2682 | + | |
| 2683 | + | |
| 2684 | + | |
| 2685 | + | |
| 2686 | + | |
| 2687 | + | |
| 2688 | + | |
| 2689 | + | |
| 2690 | + | |
| 2691 | + | |
| 2692 | + | |
| 2693 | + | |
| 2694 | + | |
| 2695 | + | |
| 2696 | + | |
| 2697 | + | |
| 2698 | + | |
| 2699 | + | |
| 2700 | + | |
| 2701 | + | |
| 2702 | + | |
| 2703 | + | |
| 2704 | + | |
2675 | 2705 |
| |
2676 | 2706 |
| |
2677 | 2707 |
| |
|
Lines changed: 20 additions & 0 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
673 | 673 |
| |
674 | 674 |
| |
675 | 675 |
| |
| 676 | + | |
| 677 | + | |
| 678 | + | |
| 679 | + | |
| 680 | + | |
| 681 | + | |
| 682 | + | |
| 683 | + | |
| 684 | + | |
| 685 | + | |
| 686 | + | |
| 687 | + | |
| 688 | + | |
| 689 | + | |
| 690 | + | |
| 691 | + | |
| 692 | + | |
| 693 | + | |
| 694 | + | |
| 695 | + | |
676 | 696 |
| |
677 | 697 |
| |
678 | 698 |
| |
|
0 commit comments
Comments
(0)