New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Rewind tuple store to fix scrollable with hold cursor fetches #7014
Conversation
7b15608
to
c89a559
Compare
Codecov Report
@@ Coverage Diff @@
## main #7014 +/- ##
==========================================
- Coverage 93.33% 93.10% -0.24%
==========================================
Files 273 273
Lines 58469 58474 +5
==========================================
- Hits 54572 54441 -131
- Misses 3897 4033 +136 |
c89a559
to
5f60985
Compare
{ } | ||
{ | ||
CitusScanState *scanState = (CitusScanState *) node; | ||
if (scanState->tuplestorestate) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
other, similar scan nodes in PG also have
if (node->ss.ps.ps_ResultTupleSlot)
ExecClearTuple(node->ss.ps.ps_ResultTupleSlot);
ExecScanReScan(&node->ss);
do we need that there too?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yep. We need to free slot for the heap tuple. And ExecScanReScan
must be called according to the comments on the function. (refer function's comments)
5f60985
to
9b0f451
Compare
9b0f451
to
62fcde8
Compare
We need to rewind the tuplestorestate's tuple index to get correct results on fetching scrollable with hold cursors. `PersistHoldablePortal` is responsible for persisting out tuplestorestate inside a with hold cursor before commiting a transaction. It rewinds the cursor like below (`ExecutorRewindcalls` calls `rescan`): ```c if (portal->cursorOptions & CURSOR_OPT_SCROLL) { ExecutorRewind(queryDesc); } ``` At the end, it adjusts tuple index for holdStore in the portal properly. ```c if (portal->cursorOptions & CURSOR_OPT_SCROLL) { if (!tuplestore_skiptuples(portal->holdStore, portal->portalPos, true)) elog(ERROR, "unexpected end of tuple stream"); } ``` DESCRIPTION: Fixes incorrect results on fetching scrollable with hold cursors. Fixes #7010 (cherry picked from commit f667f14)
We need to rewind the tuplestorestate's tuple index to get correct results on fetching scrollable with hold cursors. `PersistHoldablePortal` is responsible for persisting out tuplestorestate inside a with hold cursor before commiting a transaction. It rewinds the cursor like below (`ExecutorRewindcalls` calls `rescan`): ```c if (portal->cursorOptions & CURSOR_OPT_SCROLL) { ExecutorRewind(queryDesc); } ``` At the end, it adjusts tuple index for holdStore in the portal properly. ```c if (portal->cursorOptions & CURSOR_OPT_SCROLL) { if (!tuplestore_skiptuples(portal->holdStore, portal->portalPos, true)) elog(ERROR, "unexpected end of tuple stream"); } ``` DESCRIPTION: Fixes incorrect results on fetching scrollable with hold cursors. Fixes #7010 (cherry picked from commit f667f14)
We need to rewind the tuplestorestate's tuple index to get correct results on fetching scrollable with hold cursors. `PersistHoldablePortal` is responsible for persisting out tuplestorestate inside a with hold cursor before commiting a transaction. It rewinds the cursor like below (`ExecutorRewindcalls` calls `rescan`): ```c if (portal->cursorOptions & CURSOR_OPT_SCROLL) { ExecutorRewind(queryDesc); } ``` At the end, it adjusts tuple index for holdStore in the portal properly. ```c if (portal->cursorOptions & CURSOR_OPT_SCROLL) { if (!tuplestore_skiptuples(portal->holdStore, portal->portalPos, true)) elog(ERROR, "unexpected end of tuple stream"); } ``` DESCRIPTION: Fixes incorrect results on fetching scrollable with hold cursors. Fixes #7010 (cherry picked from commit f667f14)
We need to rewind the tuplestorestate's tuple index to get correct results on fetching scrollable with hold cursors.
PersistHoldablePortal
is responsible for persisting out tuplestorestate inside a scrollable with hold cursor before commiting a transaction.It rewinds the scroll like below (
ExecutorRewindcalls
callsrescan
):At the end, it adjusts tuple index for holdStore in the portal properly.
DESCRIPTION: Fixes incorrect results on fetching scrollable with hold cursors.
Fixes #7010