forked frompostgres/postgres
- Notifications
You must be signed in to change notification settings - Fork6
Commitdd73d10
committed
Fix handling of self-modified tuples in MERGE.
When an UPDATE or DELETE action in MERGE returns TM_SelfModified,there are 2 possible causes:1). The target tuple was already updated or deleted by the current command. This can happen if the target row joins to more than one source row, and the SQL standard explicitly says that this must be an error.2). The target tuple was already updated or deleted by a later command in the current transaction. This can happen if the tuple is modified by a BEFORE trigger or a volatile function used in the query, and should be an error for the same reason that it is in a plain UPDATE or DELETE command.In MERGE's primary error handling block, it failed to check for (2),causing it to return a misleading error message in such cases.In the secondary error handling block, following a concurrent updatefrom another session, it failed to check for (1), causing it tosilently ignore target rows joined to more than one source row,instead of reporting an error.Fix this, and add tests for both of these cases.Per report from Wenjiang Zhang. Back-patch to v15, where MERGE wasintroduced.Discussion:https://postgr.es/m/tencent_41DE0FF443FE14B94A5898D373792109E408%40qq.com1 parentc46817e commitdd73d10
File tree
5 files changed
+106
-8
lines changed- src
- backend/executor
- test
- isolation
- expected
- specs
- regress
- expected
- sql
5 files changed
+106
-8
lines changedLines changed: 38 additions & 8 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
2966 | 2966 |
| |
2967 | 2967 |
| |
2968 | 2968 |
| |
2969 |
| - | |
| 2969 | + | |
| 2970 | + | |
| 2971 | + | |
| 2972 | + | |
| 2973 | + | |
| 2974 | + | |
| 2975 | + | |
| 2976 | + | |
| 2977 | + | |
| 2978 | + | |
| 2979 | + | |
| 2980 | + | |
| 2981 | + | |
| 2982 | + | |
| 2983 | + | |
| 2984 | + | |
2970 | 2985 |
| |
| 2986 | + | |
| 2987 | + | |
| 2988 | + | |
| 2989 | + | |
| 2990 | + | |
| 2991 | + | |
2971 | 2992 |
| |
2972 | 2993 |
| |
2973 | 2994 |
| |
2974 | 2995 |
| |
2975 | 2996 |
| |
2976 | 2997 |
| |
2977 | 2998 |
| |
| 2999 | + | |
2978 | 3000 |
| |
2979 | 3001 |
| |
2980 | 3002 |
| |
| |||
3083 | 3105 |
| |
3084 | 3106 |
| |
3085 | 3107 |
| |
3086 |
| - | |
3087 |
| - | |
3088 |
| - | |
3089 |
| - | |
3090 |
| - | |
3091 |
| - | |
3092 |
| - | |
| 3108 | + | |
| 3109 | + | |
| 3110 | + | |
| 3111 | + | |
3093 | 3112 |
| |
3094 | 3113 |
| |
3095 | 3114 |
| |
3096 | 3115 |
| |
3097 | 3116 |
| |
3098 | 3117 |
| |
| 3118 | + | |
| 3119 | + | |
| 3120 | + | |
| 3121 | + | |
| 3122 | + | |
| 3123 | + | |
| 3124 | + | |
| 3125 | + | |
| 3126 | + | |
| 3127 | + | |
| 3128 | + | |
3099 | 3129 |
| |
3100 | 3130 |
| |
3101 | 3131 |
| |
|
Lines changed: 43 additions & 0 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
48 | 48 |
| |
49 | 49 |
| |
50 | 50 |
| |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
51 | 72 |
| |
52 | 73 |
| |
53 | 74 |
| |
| |||
312 | 333 |
| |
313 | 334 |
| |
314 | 335 |
| |
| 336 | + | |
| 337 | + | |
| 338 | + | |
| 339 | + | |
| 340 | + | |
| 341 | + | |
| 342 | + | |
| 343 | + | |
| 344 | + | |
| 345 | + | |
| 346 | + | |
| 347 | + | |
| 348 | + | |
| 349 | + | |
| 350 | + | |
| 351 | + | |
| 352 | + | |
| 353 | + | |
| 354 | + | |
| 355 | + | |
| 356 | + | |
| 357 | + |
Lines changed: 13 additions & 0 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
4 | 4 |
| |
5 | 5 |
| |
6 | 6 |
| |
| 7 | + | |
7 | 8 |
| |
8 | 9 |
| |
9 | 10 |
| |
| |||
134 | 135 |
| |
135 | 136 |
| |
136 | 137 |
| |
| 138 | + | |
| 139 | + | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
| 144 | + | |
| 145 | + | |
| 146 | + | |
137 | 147 |
| |
138 | 148 |
| |
139 | 149 |
| |
| 150 | + | |
140 | 151 |
| |
141 | 152 |
| |
142 | 153 |
| |
143 | 154 |
| |
144 | 155 |
| |
145 | 156 |
| |
| 157 | + | |
146 | 158 |
| |
147 | 159 |
| |
148 | 160 |
| |
| |||
154 | 166 |
| |
155 | 167 |
| |
156 | 168 |
| |
| 169 | + |
Lines changed: 8 additions & 0 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
1745 | 1745 |
| |
1746 | 1746 |
| |
1747 | 1747 |
| |
| 1748 | + | |
| 1749 | + | |
| 1750 | + | |
| 1751 | + | |
1748 | 1752 |
| |
1749 | 1753 |
| |
1750 | 1754 |
| |
| |||
1759 | 1763 |
| |
1760 | 1764 |
| |
1761 | 1765 |
| |
| 1766 | + | |
| 1767 | + | |
| 1768 | + | |
| 1769 | + | |
1762 | 1770 |
| |
1763 | 1771 |
| |
1764 | 1772 |
| |
|
Lines changed: 4 additions & 0 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
1186 | 1186 |
| |
1187 | 1187 |
| |
1188 | 1188 |
| |
| 1189 | + | |
| 1190 | + | |
1189 | 1191 |
| |
1190 | 1192 |
| |
1191 | 1193 |
| |
| 1194 | + | |
| 1195 | + | |
1192 | 1196 |
| |
1193 | 1197 |
| |
1194 | 1198 |
| |
|
0 commit comments
Comments
(0)