forked frompostgres/postgres
- Notifications
You must be signed in to change notification settings - Fork0
Commit340d63b
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 parent4957398 commit340d63b
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 |
| |
| |||
176 | 183 |
| |
177 | 184 |
| |
178 | 185 |
| |
| 186 | + | |
| 187 | + | |
| 188 | + | |
| 189 | + | |
| 190 | + | |
| 191 | + | |
179 | 192 |
| |
180 | 193 |
| |
181 | 194 |
| |
|
Lines changed: 15 additions & 0 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
184 | 184 |
| |
185 | 185 |
| |
186 | 186 |
| |
| 187 | + | |
| 188 | + | |
| 189 | + | |
| 190 | + | |
| 191 | + | |
| 192 | + | |
| 193 | + | |
| 194 | + | |
| 195 | + | |
| 196 | + | |
| 197 | + | |
| 198 | + | |
| 199 | + | |
| 200 | + | |
| 201 | + |
Lines changed: 9 additions & 0 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
124 | 124 |
| |
125 | 125 |
| |
126 | 126 |
| |
| 127 | + | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
127 | 135 |
| |
128 | 136 |
| |
129 | 137 |
| |
| |||
135 | 143 |
| |
136 | 144 |
| |
137 | 145 |
| |
| 146 | + |
0 commit comments
Comments
(0)