forked frompostgres/postgres
- Notifications
You must be signed in to change notification settings - Fork6
Commit159efe4
committed
Fix misbehavior of CTE-used-in-a-subplan during EPQ rechecks.
An updating query that reads a CTE within an InitPlan or SubPlan could getincorrect results if it updates rows that are concurrently being modified.This is caused by CteScanNext supposing that nothing inside its recursiveExecProcNode call could change which read pointer is selected in the CTE'sshared tuplestore. While that's normally true because of scopingconsiderations, it can break down if an EPQ plan tree gets built during thecall, because EvalPlanQualStart builds execution trees for all subplanswhether they're going to be used during the recheck or not. And it seemslike a pretty shaky assumption anyway, so let's just reselect our own readpointer here.Per bug #14870 from Andrei Gorita. This has been broken since CTEs wereimplemented, so back-patch to all supported branches.Discussion:https://postgr.es/m/20171024155358.1471.82377@wrigleys.postgresql.org1 parent4108a28 commit159efe4
File tree
3 files changed
+37
-0
lines changed- src
- backend/executor
- test/isolation
- expected
- specs
3 files changed
+37
-0
lines changedLines changed: 13 additions & 0 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
107 | 107 |
| |
108 | 108 |
| |
109 | 109 |
| |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
110 | 117 |
| |
111 | 118 |
| |
112 | 119 |
| |
| |||
178 | 185 |
| |
179 | 186 |
| |
180 | 187 |
| |
| 188 | + | |
| 189 | + | |
| 190 | + | |
| 191 | + | |
| 192 | + | |
| 193 | + | |
181 | 194 |
| |
182 | 195 |
| |
183 | 196 |
| |
|
Lines changed: 15 additions & 0 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
217 | 217 |
| |
218 | 218 |
| |
219 | 219 |
| |
| 220 | + | |
| 221 | + | |
| 222 | + | |
| 223 | + | |
| 224 | + | |
| 225 | + | |
| 226 | + | |
| 227 | + | |
| 228 | + | |
| 229 | + | |
| 230 | + | |
| 231 | + | |
| 232 | + | |
| 233 | + | |
| 234 | + |
Lines changed: 9 additions & 0 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
139 | 139 |
| |
140 | 140 |
| |
141 | 141 |
| |
| 142 | + | |
| 143 | + | |
| 144 | + | |
| 145 | + | |
| 146 | + | |
| 147 | + | |
| 148 | + | |
| 149 | + | |
142 | 150 |
| |
143 | 151 |
| |
144 | 152 |
| |
| |||
151 | 159 |
| |
152 | 160 |
| |
153 | 161 |
| |
| 162 | + |
0 commit comments
Comments
(0)