forked frompostgres/postgres
- Notifications
You must be signed in to change notification settings - Fork6
Commit01d9676
committed
Fix dangling pointer in EvalPlanQual machinery.
EvalPlanQualStart() supposed that it could re-use the relsubs_rowmarkand relsubs_done arrays from a prior instantiation. But since they areallocated in the es_query_cxt of the recheckestate, that's just wrong;EvalPlanQualEnd() will blow away that storage. Therefore we were usingstorage that could have been reallocated to something else, causing allsorts of havoc.I think this was modeled on the old code's handling of es_epqTupleSlot,but since the code was anyway clearing the arrays at re-use, there'sclearly no expectation of importing any outside state. So it's justa dubious savings of a couple of pallocs, which is negligible comparedto setting up a new planstate tree. Therefore, just allocate thearrays always. (I moved the allocations slightly for readability.)In principle this bug could cause a problem whenever EPQ rechecks areneeded in more than one target table of a ModifyTable plan node.In practice it seems not quite so easy to trigger as that; I couldn'treadily duplicate a crash with a partitioned target table, for instance.That's probably down to incidental choices about when to free orreallocate stuff. The added isolation test case does seem to reliablyshow an assertion failure, though.Per report from Oleksii Kliukin. Back-patch to v12 where the bug wasintroduced (evidently by commit3fb307b).Discussion:https://postgr.es/m/EEF05F66-2871-4786-992B-5F45C92FEE2E@hintbits.com1 parent30012a0 commit01d9676
File tree
3 files changed
+22
-23
lines changed- src
- backend/executor
- test/isolation
- expected
- specs
3 files changed
+22
-23
lines changedLines changed: 11 additions & 23 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
2887 | 2887 |
| |
2888 | 2888 |
| |
2889 | 2889 |
| |
2890 |
| - | |
2891 |
| - | |
2892 |
| - | |
2893 |
| - | |
2894 |
| - | |
2895 |
| - | |
2896 |
| - | |
2897 |
| - | |
2898 |
| - | |
2899 |
| - | |
2900 |
| - | |
2901 |
| - | |
2902 |
| - | |
2903 |
| - | |
2904 |
| - | |
2905 |
| - | |
2906 |
| - | |
2907 |
| - | |
2908 |
| - | |
2909 |
| - | |
2910 |
| - | |
2911 |
| - | |
2912 | 2890 |
| |
2913 | 2891 |
| |
2914 | 2892 |
| |
2915 | 2893 |
| |
2916 | 2894 |
| |
| 2895 | + | |
| 2896 | + | |
2917 | 2897 |
| |
2918 | 2898 |
| |
2919 | 2899 |
| |
2920 | 2900 |
| |
2921 | 2901 |
| |
2922 | 2902 |
| |
2923 | 2903 |
| |
| 2904 | + | |
| 2905 | + | |
| 2906 | + | |
| 2907 | + | |
| 2908 | + | |
| 2909 | + | |
2924 | 2910 |
| |
2925 | 2911 |
| |
2926 | 2912 |
| |
| |||
2989 | 2975 |
| |
2990 | 2976 |
| |
2991 | 2977 |
| |
| 2978 | + | |
2992 | 2979 |
| |
2993 | 2980 |
| |
2994 |
| - | |
| 2981 | + | |
| 2982 | + | |
2995 | 2983 |
|
Lines changed: 7 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 | + | |
676 | 683 |
| |
677 | 684 |
| |
678 | 685 |
| |
|
Lines changed: 4 additions & 0 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
97 | 97 |
| |
98 | 98 |
| |
99 | 99 |
| |
| 100 | + | |
100 | 101 |
| |
101 | 102 |
| |
102 | 103 |
| |
103 | 104 |
| |
| 105 | + | |
104 | 106 |
| |
105 | 107 |
| |
106 | 108 |
| |
| |||
203 | 205 |
| |
204 | 206 |
| |
205 | 207 |
| |
| 208 | + | |
206 | 209 |
| |
207 | 210 |
| |
208 | 211 |
| |
| |||
338 | 341 |
| |
339 | 342 |
| |
340 | 343 |
| |
| 344 | + | |
341 | 345 |
| |
342 | 346 |
| |
343 | 347 |
| |
|
0 commit comments
Comments
(0)