Thread: pgsql: Fix possible failures when a tuplestore switches from in-memory

pgsql: Fix possible failures when a tuplestore switches from in-memory

From
tgl@postgresql.org (Tom Lane)
Date:
Log Message:
-----------
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.

Modified Files:
--------------
    pgsql/src/backend/executor:
        execQual.c (r1.242 -> r1.243)
        (http://anoncvs.postgresql.org/cvsweb.cgi/pgsql/src/backend/executor/execQual.c?r1=1.242&r2=1.243)
        functions.c (r1.132 -> r1.133)
        (http://anoncvs.postgresql.org/cvsweb.cgi/pgsql/src/backend/executor/functions.c?r1=1.132&r2=1.133)
        nodeCtescan.c (r1.3 -> r1.4)
        (http://anoncvs.postgresql.org/cvsweb.cgi/pgsql/src/backend/executor/nodeCtescan.c?r1=1.3&r2=1.4)
        nodeFunctionscan.c (r1.50 -> r1.51)
        (http://anoncvs.postgresql.org/cvsweb.cgi/pgsql/src/backend/executor/nodeFunctionscan.c?r1=1.50&r2=1.51)
        nodeMaterial.c (r1.65 -> r1.66)
        (http://anoncvs.postgresql.org/cvsweb.cgi/pgsql/src/backend/executor/nodeMaterial.c?r1=1.65&r2=1.66)
        nodeWindowAgg.c (r1.3 -> r1.4)
        (http://anoncvs.postgresql.org/cvsweb.cgi/pgsql/src/backend/executor/nodeWindowAgg.c?r1=1.3&r2=1.4)
        nodeWorktablescan.c (r1.5 -> r1.6)
        (http://anoncvs.postgresql.org/cvsweb.cgi/pgsql/src/backend/executor/nodeWorktablescan.c?r1=1.5&r2=1.6)
    pgsql/src/backend/tcop:
        pquery.c (r1.129 -> r1.130)
        (http://anoncvs.postgresql.org/cvsweb.cgi/pgsql/src/backend/tcop/pquery.c?r1=1.129&r2=1.130)
    pgsql/src/backend/utils/sort:
        tuplestore.c (r1.46 -> r1.47)
        (http://anoncvs.postgresql.org/cvsweb.cgi/pgsql/src/backend/utils/sort/tuplestore.c?r1=1.46&r2=1.47)
    pgsql/src/include/utils:
        tuplestore.h (r1.28 -> r1.29)
        (http://anoncvs.postgresql.org/cvsweb.cgi/pgsql/src/include/utils/tuplestore.h?r1=1.28&r2=1.29)