- Notifications
You must be signed in to change notification settings - Fork4.9k
Commit0183df5
committed
Be sure to rewind the tuplestore read pointer in non-leader CTEScan nodes.
ExecInitCteScan supposed that it didn't have to do anything to the extratuplestore read pointer it gets from tuplestore_alloc_read_pointer.However, it needs this read pointer to be positioned at the start of thetuplestore, while tuplestore_alloc_read_pointer is actually defined ascloning the current position of read pointer 0. In normal situationsthat accidentally works because we initialize the whole plan tree at once,before anything gets read. But it fails in an EvalPlanQual recheck, asillustrated in bug #14328 from Dima Pavlov. To fix, just forcibly rewindthe pointer after tuplestore_alloc_read_pointer. The cost of doing so isnegligible unless the tuplestore is already in TSS_READFILE state, whichwouldn't happen in normal cases. We could consider altering tuplestore'sAPI to make that case cheaper, but that would make for a more invasiveback-patch and it doesn't seem worth it.This has been broken probably for as long as we've had CTEs, so back-patchto all supported branches.Discussion: <32468.1474548308@sss.pgh.pa.us>1 parentee33250 commit0183df5
1 file changed
+4
-0
lines changedLines changed: 4 additions & 0 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
224 | 224 |
| |
225 | 225 |
| |
226 | 226 |
| |
| 227 | + | |
227 | 228 |
| |
228 | 229 |
| |
229 | 230 |
| |
| 231 | + | |
| 232 | + | |
| 233 | + | |
230 | 234 |
| |
231 | 235 |
| |
232 | 236 |
| |
|
0 commit comments
Comments
(0)