forked frompostgres/postgres
- Notifications
You must be signed in to change notification settings - Fork6
Commita477bfc
committed
Suppress unnecessary RelabelType nodes in more cases.
eval_const_expressions sometimes produced RelabelType nodes thatwere useless because they just relabeled an expression to the sameexposed type it already had. This is worth avoiding because it cancause two equivalent expressions to not be equal(), preventingrecognition of useful optimizations. In the test case added here,an unpatched planner fails to notice that the "sqli = constant" clauserenders a sort step unnecessary, because one code path produces anextra RelabelType and another doesn't.Fix by ensuring that eval_const_expressions_mutator's T_RelabelTypecase will not add in an unnecessary RelabelType. Also save somecode by sharing a subroutine with the effectively-equivalent casesfor CollateExpr and CoerceToDomain. (CollateExpr had no bug, andI think that the case couldn't arise with CoerceToDomain, butit seems prudent to do the same check for all three cases.)Back-patch to v12. In principle this has been wrong all along,but I haven't seen a case where it causes visible misbehaviorbefore v12, so refrain from changing stable branches unnecessarily.Per investigation of a report from Eric Gillum.Discussion:https://postgr.es/m/CAMmjdmvAZsUEskHYj=KT9sTukVVCiCSoe_PBKOXsncFeAUDPCQ@mail.gmail.com1 parent3acfe6b commita477bfc
File tree
3 files changed
+101
-97
lines changed- src
- backend/optimizer/util
- test/regress
- expected
- sql
3 files changed
+101
-97
lines changedLines changed: 82 additions & 97 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
119 | 119 |
| |
120 | 120 |
| |
121 | 121 |
| |
| 122 | + | |
| 123 | + | |
| 124 | + | |
122 | 125 |
| |
123 | 126 |
| |
124 | 127 |
| |
| |||
2774 | 2777 |
| |
2775 | 2778 |
| |
2776 | 2779 |
| |
2777 |
| - | |
2778 |
| - | |
2779 |
| - | |
2780 |
| - | |
2781 |
| - | |
2782 |
| - | |
2783 | 2780 |
| |
2784 | 2781 |
| |
2785 | 2782 |
| |
| 2783 | + | |
2786 | 2784 |
| |
2787 | 2785 |
| |
2788 |
| - | |
2789 |
| - | |
2790 |
| - | |
2791 |
| - | |
2792 |
| - | |
2793 |
| - | |
2794 |
| - | |
2795 |
| - | |
2796 |
| - | |
2797 |
| - | |
2798 |
| - | |
2799 |
| - | |
2800 |
| - | |
2801 |
| - | |
2802 |
| - | |
2803 |
| - | |
2804 |
| - | |
2805 |
| - | |
2806 |
| - | |
2807 |
| - | |
2808 |
| - | |
2809 |
| - | |
2810 |
| - | |
2811 |
| - | |
2812 |
| - | |
2813 |
| - | |
2814 |
| - | |
2815 |
| - | |
2816 |
| - | |
| 2786 | + | |
| 2787 | + | |
| 2788 | + | |
| 2789 | + | |
| 2790 | + | |
| 2791 | + | |
| 2792 | + | |
2817 | 2793 |
| |
2818 | 2794 |
| |
2819 | 2795 |
| |
| |||
2947 | 2923 |
| |
2948 | 2924 |
| |
2949 | 2925 |
| |
2950 |
| - | |
2951 |
| - | |
2952 |
| - | |
2953 |
| - | |
2954 |
| - | |
2955 |
| - | |
| 2926 | + | |
| 2927 | + | |
| 2928 | + | |
| 2929 | + | |
| 2930 | + | |
2956 | 2931 |
| |
2957 | 2932 |
| |
2958 | 2933 |
| |
2959 | 2934 |
| |
| 2935 | + | |
2960 | 2936 |
| |
2961 | 2937 |
| |
2962 |
| - | |
2963 |
| - | |
2964 |
| - | |
2965 |
| - | |
2966 |
| - | |
2967 |
| - | |
2968 |
| - | |
2969 |
| - | |
2970 |
| - | |
2971 |
| - | |
2972 |
| - | |
2973 |
| - | |
2974 |
| - | |
2975 |
| - | |
2976 |
| - | |
2977 |
| - | |
2978 |
| - | |
2979 |
| - | |
2980 |
| - | |
2981 |
| - | |
2982 |
| - | |
2983 |
| - | |
2984 |
| - | |
2985 |
| - | |
2986 |
| - | |
2987 |
| - | |
2988 |
| - | |
2989 |
| - | |
2990 |
| - | |
2991 |
| - | |
| 2938 | + | |
| 2939 | + | |
| 2940 | + | |
| 2941 | + | |
| 2942 | + | |
| 2943 | + | |
| 2944 | + | |
2992 | 2945 |
| |
2993 | 2946 |
| |
2994 | 2947 |
| |
| |||
3490 | 3443 |
| |
3491 | 3444 |
| |
3492 | 3445 |
| |
3493 |
| - | |
3494 |
| - | |
3495 |
| - | |
3496 |
| - | |
3497 |
| - | |
3498 |
| - | |
3499 |
| - | |
3500 |
| - | |
3501 |
| - | |
3502 |
| - | |
3503 |
| - | |
3504 |
| - | |
3505 |
| - | |
3506 |
| - | |
3507 |
| - | |
3508 |
| - | |
3509 |
| - | |
3510 |
| - | |
3511 |
| - | |
3512 |
| - | |
3513 |
| - | |
3514 |
| - | |
3515 |
| - | |
3516 |
| - | |
3517 |
| - | |
3518 |
| - | |
| 3446 | + | |
| 3447 | + | |
| 3448 | + | |
| 3449 | + | |
| 3450 | + | |
| 3451 | + | |
3519 | 3452 |
| |
3520 | 3453 |
| |
3521 | 3454 |
| |
| |||
3648 | 3581 |
| |
3649 | 3582 |
| |
3650 | 3583 |
| |
| 3584 | + | |
| 3585 | + | |
| 3586 | + | |
| 3587 | + | |
| 3588 | + | |
| 3589 | + | |
| 3590 | + | |
| 3591 | + | |
| 3592 | + | |
| 3593 | + | |
| 3594 | + | |
| 3595 | + | |
| 3596 | + | |
| 3597 | + | |
| 3598 | + | |
| 3599 | + | |
| 3600 | + | |
| 3601 | + | |
| 3602 | + | |
| 3603 | + | |
| 3604 | + | |
| 3605 | + | |
| 3606 | + | |
| 3607 | + | |
| 3608 | + | |
| 3609 | + | |
| 3610 | + | |
| 3611 | + | |
| 3612 | + | |
| 3613 | + | |
| 3614 | + | |
| 3615 | + | |
| 3616 | + | |
| 3617 | + | |
| 3618 | + | |
| 3619 | + | |
| 3620 | + | |
| 3621 | + | |
| 3622 | + | |
| 3623 | + | |
| 3624 | + | |
| 3625 | + | |
| 3626 | + | |
| 3627 | + | |
| 3628 | + | |
| 3629 | + | |
| 3630 | + | |
| 3631 | + | |
| 3632 | + | |
| 3633 | + | |
| 3634 | + | |
| 3635 | + | |
3651 | 3636 |
| |
3652 | 3637 |
| |
3653 | 3638 |
| |
|
Lines changed: 12 additions & 0 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
439 | 439 |
| |
440 | 440 |
| |
441 | 441 |
| |
| 442 | + | |
| 443 | + | |
| 444 | + | |
| 445 | + | |
| 446 | + | |
| 447 | + | |
| 448 | + | |
| 449 | + | |
| 450 | + | |
| 451 | + | |
| 452 | + | |
| 453 | + |
Lines changed: 7 additions & 0 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
262 | 262 |
| |
263 | 263 |
| |
264 | 264 |
| |
| 265 | + | |
| 266 | + | |
| 267 | + | |
| 268 | + | |
| 269 | + | |
| 270 | + | |
| 271 | + |
0 commit comments
Comments
(0)