aboutsummaryrefslogtreecommitdiff
path: root/src/backend/executor/nodeWorktablescan.c
diff options
context:
space:
mode:
authorTom Lane <tgl@sss.pgh.pa.us>2009-03-27 18:30:21 +0000
committerTom Lane <tgl@sss.pgh.pa.us>2009-03-27 18:30:21 +0000
commit25bf7f8b9b3ce0f04b498988bb98d9d5cf9bad67 (patch)
tree9d96a158b6c03def3242d5d4af85d843cd5490e0 /src/backend/executor/nodeWorktablescan.c
parenta95307b639ad94fb94c898eb6b4a3c95c407bf44 (diff)
downloadpostgresql-25bf7f8b9b3ce0f04b498988bb98d9d5cf9bad67.tar.gz
postgresql-25bf7f8b9b3ce0f04b498988bb98d9d5cf9bad67.zip
Fix possible failures when a tuplestore switches from in-memory to on-disk
mode while callers hold pointers to in-memory tuples. I reported this for the case of nodeWindowAgg's primary scan tuple, but inspection of the code shows that all of the calls in nodeWindowAgg and nodeCtescan are at risk. For the moment, fix it with a rather brute-force approach of copying whenever one of the at-risk callers requests a tuple. Later we might think of some sort of reference-count approach to reduce tuple copying.
Diffstat (limited to 'src/backend/executor/nodeWorktablescan.c')
-rw-r--r--src/backend/executor/nodeWorktablescan.c8
1 files changed, 6 insertions, 2 deletions
diff --git a/src/backend/executor/nodeWorktablescan.c b/src/backend/executor/nodeWorktablescan.c
index aaac9d19a8c..24fd2c5f736 100644
--- a/src/backend/executor/nodeWorktablescan.c
+++ b/src/backend/executor/nodeWorktablescan.c
@@ -8,7 +8,7 @@
*
*
* IDENTIFICATION
- * $PostgreSQL: pgsql/src/backend/executor/nodeWorktablescan.c,v 1.5 2009/01/01 17:23:42 momjian Exp $
+ * $PostgreSQL: pgsql/src/backend/executor/nodeWorktablescan.c,v 1.6 2009/03/27 18:30:21 tgl Exp $
*
*-------------------------------------------------------------------------
*/
@@ -43,6 +43,10 @@ WorkTableScanNext(WorkTableScanState *node)
* worktable plan node, since it cannot appear high enough in the plan
* tree of a scrollable cursor to be exposed to a backward-scan
* requirement. So it's not worth expending effort to support it.
+ *
+ * Note: we are also assuming that this node is the only reader of the
+ * worktable. Therefore, we don't need a private read pointer for the
+ * tuplestore, nor do we need to tell tuplestore_gettupleslot to copy.
*/
estate = node->ss.ps.state;
Assert(ScanDirectionIsForward(estate->es_direction));
@@ -53,7 +57,7 @@ WorkTableScanNext(WorkTableScanState *node)
* Get the next tuple from tuplestore. Return NULL if no more tuples.
*/
slot = node->ss.ss_ScanTupleSlot;
- (void) tuplestore_gettupleslot(tuplestorestate, true, slot);
+ (void) tuplestore_gettupleslot(tuplestorestate, true, false, slot);
return slot;
}