mirror of
https://github.com/postgres/postgres.git
synced 2025-07-27 12:41:57 +03:00
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.
This commit is contained in:
@ -8,7 +8,7 @@
|
||||
*
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $PostgreSQL: pgsql/src/backend/executor/nodeCtescan.c,v 1.3 2009/01/01 17:23:41 momjian Exp $
|
||||
* $PostgreSQL: pgsql/src/backend/executor/nodeCtescan.c,v 1.4 2009/03/27 18:30:21 tgl Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
@ -71,10 +71,14 @@ CteScanNext(CteScanState *node)
|
||||
|
||||
/*
|
||||
* If we can fetch another tuple from the tuplestore, return it.
|
||||
*
|
||||
* Note: we have to use copy=true in the tuplestore_gettupleslot call,
|
||||
* because we are sharing the tuplestore with other nodes that might
|
||||
* write into the tuplestore before we get called again.
|
||||
*/
|
||||
if (!eof_tuplestore)
|
||||
{
|
||||
if (tuplestore_gettupleslot(tuplestorestate, forward, slot))
|
||||
if (tuplestore_gettupleslot(tuplestorestate, forward, true, slot))
|
||||
return slot;
|
||||
if (forward)
|
||||
eof_tuplestore = true;
|
||||
|
Reference in New Issue
Block a user