forked frompostgres/postgres
- Notifications
You must be signed in to change notification settings - Fork6
Commit2c7ed9f
committed
Fix DEFAULT handling for multi-row INSERT rules.
When updating a relation with a rule whose action performed an INSERTfrom a multi-row VALUES list, the rewriter might skip processing theVALUES list, and therefore fail to replace any DEFAULTs in it. Thiswould lead to an "unrecognized node type" error.The reason was that RewriteQuery() assumed that a query doing anINSERT from a multi-row VALUES list would necessarily only have oneitem in its fromlist, pointing to the VALUES RTE to read from. Thatassumption is correct for the original query, but not for productqueries produced for rule actions. In such cases, there may bemultiple items in the fromlist, possibly including multiple VALUESRTEs.What is required instead is for RewriteQuery() to skip any RTEs fromthe product query's originating query, which might include one or morealready-processed VALUES RTEs. What's left should then include at mostone VALUES RTE (from the rule action) to be processed.Patch by me. Thanks to Tom Lane for reviewing.Back-patch to all supported branches.Discussion:https://postgr.es/m/CAEZATCV39OOW7LAR_Xq4i%2BLc1Byux%3DeK3Q%3DHD_pF1o9LBt%3DphA%40mail.gmail.com1 parent6344bc0 commit2c7ed9f
File tree
3 files changed
+99
-54
lines changed- src
- backend/rewrite
- test/regress
- expected
- sql
3 files changed
+99
-54
lines changedLines changed: 38 additions & 9 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
418 | 418 |
| |
419 | 419 |
| |
420 | 420 |
| |
| 421 | + | |
| 422 | + | |
| 423 | + | |
| 424 | + | |
421 | 425 |
| |
422 | 426 |
| |
423 | 427 |
| |
| |||
3612 | 3616 |
| |
3613 | 3617 |
| |
3614 | 3618 |
| |
| 3619 | + | |
| 3620 | + | |
| 3621 | + | |
| 3622 | + | |
3615 | 3623 |
| |
3616 | 3624 |
| |
3617 |
| - | |
| 3625 | + | |
3618 | 3626 |
| |
3619 | 3627 |
| |
3620 | 3628 |
| |
| |||
3638 | 3646 |
| |
3639 | 3647 |
| |
3640 | 3648 |
| |
3641 |
| - | |
| 3649 | + | |
3642 | 3650 |
| |
3643 | 3651 |
| |
3644 | 3652 |
| |
| |||
3712 | 3720 |
| |
3713 | 3721 |
| |
3714 | 3722 |
| |
| 3723 | + | |
3715 | 3724 |
| |
3716 | 3725 |
| |
3717 | 3726 |
| |
| |||
3733 | 3742 |
| |
3734 | 3743 |
| |
3735 | 3744 |
| |
| 3745 | + | |
3736 | 3746 |
| |
3737 | 3747 |
| |
3738 | 3748 |
| |
3739 |
| - | |
3740 |
| - | |
| 3749 | + | |
| 3750 | + | |
| 3751 | + | |
| 3752 | + | |
3741 | 3753 |
| |
3742 |
| - | |
| 3754 | + | |
3743 | 3755 |
| |
3744 |
| - | |
| 3756 | + | |
3745 | 3757 |
| |
3746 |
| - | |
| 3758 | + | |
3747 | 3759 |
| |
3748 | 3760 |
| |
3749 | 3761 |
| |
3750 | 3762 |
| |
3751 | 3763 |
| |
3752 | 3764 |
| |
| 3765 | + | |
| 3766 | + | |
| 3767 | + | |
| 3768 | + | |
3753 | 3769 |
| |
3754 | 3770 |
| |
3755 | 3771 |
| |
| |||
3821 | 3837 |
| |
3822 | 3838 |
| |
3823 | 3839 |
| |
| 3840 | + | |
3824 | 3841 |
| |
3825 | 3842 |
| |
3826 | 3843 |
| |
| |||
3977 | 3994 |
| |
3978 | 3995 |
| |
3979 | 3996 |
| |
3980 |
| - | |
| 3997 | + | |
| 3998 | + | |
| 3999 | + | |
| 4000 | + | |
| 4001 | + | |
| 4002 | + | |
| 4003 | + | |
| 4004 | + | |
| 4005 | + | |
| 4006 | + | |
| 4007 | + | |
| 4008 | + | |
| 4009 | + | |
3981 | 4010 |
| |
3982 | 4011 |
| |
3983 | 4012 |
| |
| |||
4129 | 4158 |
| |
4130 | 4159 |
| |
4131 | 4160 |
| |
4132 |
| - | |
| 4161 | + | |
4133 | 4162 |
| |
4134 | 4163 |
| |
4135 | 4164 |
| |
|
Lines changed: 52 additions & 39 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
3103 | 3103 |
| |
3104 | 3104 |
| |
3105 | 3105 |
| |
3106 |
| - | |
3107 |
| - | |
| 3106 | + | |
| 3107 | + | |
3108 | 3108 |
| |
3109 | 3109 |
| |
3110 |
| - | |
| 3110 | + | |
3111 | 3111 |
| |
3112 | 3112 |
| |
3113 | 3113 |
| |
| |||
3118 | 3118 |
| |
3119 | 3119 |
| |
3120 | 3120 |
| |
3121 |
| - | |
3122 |
| - | |
3123 |
| - | |
3124 |
| - | |
3125 |
| - | |
3126 |
| - | |
3127 |
| - | |
3128 |
| - | |
3129 |
| - | |
3130 |
| - | |
| 3121 | + | |
| 3122 | + | |
| 3123 | + | |
| 3124 | + | |
| 3125 | + | |
| 3126 | + | |
| 3127 | + | |
| 3128 | + | |
| 3129 | + | |
| 3130 | + | |
3131 | 3131 |
| |
3132 | 3132 |
| |
3133 | 3133 |
| |
| |||
3141 | 3141 |
| |
3142 | 3142 |
| |
3143 | 3143 |
| |
| 3144 | + | |
| 3145 | + | |
| 3146 | + | |
3144 | 3147 |
| |
3145 | 3148 |
| |
3146 | 3149 |
| |
3147 | 3150 |
| |
3148 | 3151 |
| |
3149 |
| - | |
| 3152 | + | |
| 3153 | + | |
| 3154 | + | |
3150 | 3155 |
| |
3151 | 3156 |
| |
3152 |
| - | |
3153 |
| - | |
3154 |
| - | |
3155 |
| - | |
3156 |
| - | |
3157 |
| - | |
3158 |
| - | |
3159 |
| - | |
3160 |
| - | |
3161 |
| - | |
3162 |
| - | |
3163 |
| - | |
3164 |
| - | |
3165 |
| - | |
3166 |
| - | |
3167 |
| - | |
3168 |
| - | |
| 3157 | + | |
| 3158 | + | |
| 3159 | + | |
| 3160 | + | |
| 3161 | + | |
| 3162 | + | |
| 3163 | + | |
| 3164 | + | |
| 3165 | + | |
| 3166 | + | |
| 3167 | + | |
| 3168 | + | |
| 3169 | + | |
| 3170 | + | |
| 3171 | + | |
| 3172 | + | |
| 3173 | + | |
| 3174 | + | |
| 3175 | + | |
| 3176 | + | |
| 3177 | + | |
3169 | 3178 |
| |
3170 | 3179 |
| |
3171 | 3180 |
| |
3172 | 3181 |
| |
3173 | 3182 |
| |
3174 |
| - | |
| 3183 | + | |
3175 | 3184 |
| |
3176 | 3185 |
| |
3177 |
| - | |
| 3186 | + | |
3178 | 3187 |
| |
3179 | 3188 |
| |
3180 | 3189 |
| |
| 3190 | + | |
| 3191 | + | |
3181 | 3192 |
| |
3182 | 3193 |
| |
3183 | 3194 |
| |
3184 | 3195 |
| |
3185 | 3196 |
| |
3186 | 3197 |
| |
3187 |
| - | |
3188 |
| - | |
| 3198 | + | |
| 3199 | + | |
3189 | 3200 |
| |
3190 | 3201 |
| |
3191 | 3202 |
| |
3192 | 3203 |
| |
3193 | 3204 |
| |
3194 |
| - | |
| 3205 | + | |
3195 | 3206 |
| |
3196 | 3207 |
| |
3197 |
| - | |
| 3208 | + | |
3198 | 3209 |
| |
3199 | 3210 |
| |
3200 | 3211 |
| |
| 3212 | + | |
| 3213 | + | |
3201 | 3214 |
| |
3202 | 3215 |
| |
3203 |
| - | |
| 3216 | + | |
3204 | 3217 |
| |
3205 | 3218 |
| |
3206 | 3219 |
| |
3207 | 3220 |
| |
3208 |
| - | |
| 3221 | + | |
3209 | 3222 |
| |
3210 | 3223 |
| |
3211 | 3224 |
| |
|
Lines changed: 9 additions & 6 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
1016 | 1016 |
| |
1017 | 1017 |
| |
1018 | 1018 |
| |
1019 |
| - | |
1020 |
| - | |
| 1019 | + | |
| 1020 | + | |
1021 | 1021 |
| |
1022 | 1022 |
| |
1023 |
| - | |
| 1023 | + | |
1024 | 1024 |
| |
1025 | 1025 |
| |
1026 | 1026 |
| |
1027 | 1027 |
| |
1028 | 1028 |
| |
1029 | 1029 |
| |
1030 | 1030 |
| |
| 1031 | + | |
| 1032 | + | |
| 1033 | + | |
1031 | 1034 |
| |
1032 | 1035 |
| |
1033 |
| - | |
| 1036 | + | |
1034 | 1037 |
| |
1035 | 1038 |
| |
1036 | 1039 |
| |
1037 | 1040 |
| |
1038 | 1041 |
| |
1039 |
| - | |
1040 |
| - | |
| 1042 | + | |
| 1043 | + | |
1041 | 1044 |
| |
1042 | 1045 |
| |
1043 | 1046 |
| |
|
0 commit comments
Comments
(0)