Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit0183df5

Browse files
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

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

‎src/backend/executor/nodeCtescan.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -224,9 +224,13 @@ ExecInitCteScan(CteScan *node, EState *estate, int eflags)
224224
{
225225
/* Not the leader */
226226
Assert(IsA(scanstate->leader,CteScanState));
227+
/* Create my own read pointer, and ensure it is at start */
227228
scanstate->readptr=
228229
tuplestore_alloc_read_pointer(scanstate->leader->cte_table,
229230
scanstate->eflags);
231+
tuplestore_select_read_pointer(scanstate->leader->cte_table,
232+
scanstate->readptr);
233+
tuplestore_rescan(scanstate->leader->cte_table);
230234
}
231235

232236
/*

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp