forked frompostgres/postgres
- Notifications
You must be signed in to change notification settings - Fork6
Commit7c337b6
committed
Centralize the logic for protective copying of utility statements.
In the "simple Query" code path, it's fine for parse analysis orexecution of a utility statement to scribble on the statement's nodetree, since that'll just be thrown away afterwards. However it'snot fine if the node tree is in the plan cache, as then it'd becorrupted for subsequent executions. Up to now we've dealt withthat by having individual utility-statement functions applycopyObject() if they were going to modify the tree. But that'sprone to errors of omission. Bug #17053 from Charles Samborskishows that CREATE/ALTER DOMAIN didn't get this memo, and cancrash if executed repeatedly from plan cache.In the back branches, we'll just apply a narrow band-aid for that,but in HEAD it seems prudent to have a more principled fix thatwill close off the possibility of other similar bugs in future.Hence, let's hoist the responsibility for doing copyObject up intoProcessUtility from its children, thus ensuring that it happens forall utility statement types.Also, modify ProcessUtility's API so that its callers can tell itwhether a copy step is necessary. It turns out that in all cases,the immediate caller knows whether the node tree is transient, sothis doesn't involve a huge amount of code thrashing. In this way,while we lose a little bit in the execute-from-cache code path dueto sometimes copying node trees that wouldn't be mutated anyway,we gain something in the simple-Query code path by not copyingthrowaway node trees. Statements that are complex enough to beexpensive to copy are almost certainly ones that would have to becopied anyway, so the loss in the cache code path shouldn't be much.(Note that this whole problem applies only to utility statements.Optimizable statements don't have the issue because we long ago madethe executor treat Plan trees as read-only. Perhaps someday we willmake utility statement execution act likewise, but I'm not holdingmy breath.)Discussion:https://postgr.es/m/931771.1623893989@sss.pgh.pa.usDiscussion:https://postgr.es/m/17053-3ca3f501bbc212b4@postgresql.org1 parent0a4efdc commit7c337b6
File tree
19 files changed
+56
-91
lines changed- contrib
- pg_stat_statements
- sepgsql
- src
- backend
- commands
- executor
- parser
- tcop
- include/tcop
19 files changed
+56
-91
lines changedLines changed: 6 additions & 4 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
320 | 320 |
| |
321 | 321 |
| |
322 | 322 |
| |
| 323 | + | |
323 | 324 |
| |
324 | 325 |
| |
325 | 326 |
| |
| |||
1069 | 1070 |
| |
1070 | 1071 |
| |
1071 | 1072 |
| |
| 1073 | + | |
1072 | 1074 |
| |
1073 | 1075 |
| |
1074 | 1076 |
| |
| |||
1126 | 1128 |
| |
1127 | 1129 |
| |
1128 | 1130 |
| |
1129 |
| - | |
| 1131 | + | |
1130 | 1132 |
| |
1131 | 1133 |
| |
1132 | 1134 |
| |
1133 |
| - | |
| 1135 | + | |
1134 | 1136 |
| |
1135 | 1137 |
| |
1136 | 1138 |
| |
| |||
1176 | 1178 |
| |
1177 | 1179 |
| |
1178 | 1180 |
| |
1179 |
| - | |
| 1181 | + | |
1180 | 1182 |
| |
1181 | 1183 |
| |
1182 | 1184 |
| |
1183 |
| - | |
| 1185 | + | |
1184 | 1186 |
| |
1185 | 1187 |
| |
1186 | 1188 |
| |
|
Lines changed: 3 additions & 2 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
313 | 313 |
| |
314 | 314 |
| |
315 | 315 |
| |
| 316 | + | |
316 | 317 |
| |
317 | 318 |
| |
318 | 319 |
| |
| |||
378 | 379 |
| |
379 | 380 |
| |
380 | 381 |
| |
381 |
| - | |
| 382 | + | |
382 | 383 |
| |
383 | 384 |
| |
384 | 385 |
| |
385 |
| - | |
| 386 | + | |
386 | 387 |
| |
387 | 388 |
| |
388 | 389 |
| |
|
Lines changed: 1 addition & 7 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
438 | 438 |
| |
439 | 439 |
| |
440 | 440 |
| |
441 |
| - | |
442 |
| - | |
443 |
| - | |
444 |
| - | |
445 |
| - | |
446 |
| - | |
447 | 441 |
| |
448 |
| - | |
| 442 | + | |
449 | 443 |
| |
450 | 444 |
| |
451 | 445 |
| |
|
Lines changed: 1 addition & 7 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
299 | 299 |
| |
300 | 300 |
| |
301 | 301 |
| |
302 |
| - | |
303 |
| - | |
304 |
| - | |
305 |
| - | |
306 |
| - | |
307 |
| - | |
308 | 302 |
| |
309 |
| - | |
| 303 | + | |
310 | 304 |
| |
311 | 305 |
| |
312 | 306 |
| |
|
Lines changed: 4 additions & 10 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
256 | 256 |
| |
257 | 257 |
| |
258 | 258 |
| |
259 |
| - | |
260 |
| - | |
261 |
| - | |
262 |
| - | |
263 |
| - | |
264 |
| - | |
265 | 259 |
| |
266 |
| - | |
| 260 | + | |
267 | 261 |
| |
268 | 262 |
| |
269 | 263 |
| |
| |||
427 | 421 |
| |
428 | 422 |
| |
429 | 423 |
| |
430 |
| - | |
| 424 | + | |
| 425 | + | |
431 | 426 |
| |
432 | 427 |
| |
433 | 428 |
| |
| |||
441 | 436 |
| |
442 | 437 |
| |
443 | 438 |
| |
444 |
| - | |
445 |
| - | |
| 439 | + | |
446 | 440 |
| |
447 | 441 |
| |
448 | 442 |
| |
|
Lines changed: 1 addition & 0 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
786 | 786 |
| |
787 | 787 |
| |
788 | 788 |
| |
| 789 | + | |
789 | 790 |
| |
790 | 791 |
| |
791 | 792 |
| |
|
Lines changed: 1 addition & 2 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
1570 | 1570 |
| |
1571 | 1571 |
| |
1572 | 1572 |
| |
1573 |
| - | |
1574 |
| - | |
| 1573 | + | |
1575 | 1574 |
| |
1576 | 1575 |
| |
1577 | 1576 |
| |
|
Lines changed: 4 additions & 4 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
747 | 747 |
| |
748 | 748 |
| |
749 | 749 |
| |
750 |
| - | |
| 750 | + | |
751 | 751 |
| |
752 | 752 |
| |
753 | 753 |
| |
754 | 754 |
| |
755 |
| - | |
| 755 | + | |
756 | 756 |
| |
757 | 757 |
| |
758 | 758 |
| |
| |||
922 | 922 |
| |
923 | 923 |
| |
924 | 924 |
| |
925 |
| - | |
| 925 | + | |
926 | 926 |
| |
927 | 927 |
| |
928 | 928 |
| |
| |||
946 | 946 |
| |
947 | 947 |
| |
948 | 948 |
| |
949 |
| - | |
| 949 | + | |
950 | 950 |
| |
951 | 951 |
| |
952 | 952 |
| |
|
Lines changed: 1 addition & 7 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
76 | 76 |
| |
77 | 77 |
| |
78 | 78 |
| |
79 |
| - | |
80 |
| - | |
81 |
| - | |
82 |
| - | |
83 |
| - | |
84 |
| - | |
85 | 79 |
| |
86 |
| - | |
| 80 | + | |
87 | 81 |
| |
88 | 82 |
| |
89 | 83 |
| |
|
Lines changed: 1 addition & 4 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
78 | 78 |
| |
79 | 79 |
| |
80 | 80 |
| |
81 |
| - | |
82 |
| - | |
83 |
| - | |
84 | 81 |
| |
85 | 82 |
| |
86 |
| - | |
| 83 | + | |
87 | 84 |
| |
88 | 85 |
| |
89 | 86 |
| |
|
Lines changed: 1 addition & 0 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
191 | 191 |
| |
192 | 192 |
| |
193 | 193 |
| |
| 194 | + | |
194 | 195 |
| |
195 | 196 |
| |
196 | 197 |
| |
|
Lines changed: 1 addition & 2 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
4408 | 4408 |
| |
4409 | 4409 |
| |
4410 | 4410 |
| |
4411 |
| - | |
4412 |
| - | |
| 4411 | + | |
4413 | 4412 |
| |
4414 | 4413 |
| |
4415 | 4414 |
| |
|
Lines changed: 1 addition & 4 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
417 | 417 |
| |
418 | 418 |
| |
419 | 419 |
| |
420 |
| - | |
421 |
| - | |
422 |
| - | |
423 | 420 |
| |
424 | 421 |
| |
425 |
| - | |
| 422 | + | |
426 | 423 |
| |
427 | 424 |
| |
428 | 425 |
| |
|
Lines changed: 1 addition & 0 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
886 | 886 |
| |
887 | 887 |
| |
888 | 888 |
| |
| 889 | + | |
889 | 890 |
| |
890 | 891 |
| |
891 | 892 |
| |
|
Lines changed: 1 addition & 0 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
2545 | 2545 |
| |
2546 | 2546 |
| |
2547 | 2547 |
| |
| 2548 | + | |
2548 | 2549 |
| |
2549 | 2550 |
| |
2550 | 2551 |
| |
|
Lines changed: 2 additions & 34 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
11 | 11 |
| |
12 | 12 |
| |
13 | 13 |
| |
14 |
| - | |
15 |
| - | |
16 |
| - | |
17 |
| - | |
18 | 14 |
| |
19 | 15 |
| |
20 | 16 |
| |
| |||
177 | 173 |
| |
178 | 174 |
| |
179 | 175 |
| |
180 |
| - | |
181 |
| - | |
182 |
| - | |
183 |
| - | |
184 |
| - | |
185 |
| - | |
186 | 176 |
| |
187 | 177 |
| |
188 | 178 |
| |
| |||
2824 | 2814 |
| |
2825 | 2815 |
| |
2826 | 2816 |
| |
2827 |
| - | |
2828 |
| - | |
2829 |
| - | |
2830 |
| - | |
2831 |
| - | |
2832 |
| - | |
2833 | 2817 |
| |
2834 | 2818 |
| |
2835 | 2819 |
| |
| |||
2925 | 2909 |
| |
2926 | 2910 |
| |
2927 | 2911 |
| |
2928 |
| - | |
2929 |
| - | |
2930 |
| - | |
2931 |
| - | |
2932 |
| - | |
2933 |
| - | |
2934 | 2912 |
| |
2935 | 2913 |
| |
2936 | 2914 |
| |
| |||
2993 | 2971 |
| |
2994 | 2972 |
| |
2995 | 2973 |
| |
2996 |
| - | |
2997 |
| - | |
2998 |
| - | |
2999 | 2974 |
| |
3000 | 2975 |
| |
3001 | 2976 |
| |
| |||
3070 | 3045 |
| |
3071 | 3046 |
| |
3072 | 3047 |
| |
3073 |
| - | |
| 3048 | + | |
3074 | 3049 |
| |
3075 | 3050 |
| |
3076 | 3051 |
| |
| |||
3142 | 3117 |
| |
3143 | 3118 |
| |
3144 | 3119 |
| |
3145 |
| - | |
3146 |
| - | |
| 3120 | + | |
3147 | 3121 |
| |
3148 | 3122 |
| |
3149 | 3123 |
| |
| |||
3325 | 3299 |
| |
3326 | 3300 |
| |
3327 | 3301 |
| |
3328 |
| - | |
3329 |
| - | |
3330 |
| - | |
3331 |
| - | |
3332 |
| - | |
3333 |
| - | |
3334 | 3302 |
| |
3335 | 3303 |
| |
3336 | 3304 |
| |
|
Lines changed: 1 addition & 0 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
1146 | 1146 |
| |
1147 | 1147 |
| |
1148 | 1148 |
| |
| 1149 | + | |
1149 | 1150 |
| |
1150 | 1151 |
| |
1151 | 1152 |
| |
|
0 commit comments
Comments
(0)