1
0
mirror of https://github.com/postgres/postgres.git synced 2025-07-28 23:42:10 +03:00

When using a junkfilter, the output tuple should NOT be stored back into

the same tuple slot that the raw tuple came from, because that slot has
the wrong tuple descriptor.  Store it into its own slot with the correct
descriptor, instead.  This repairs problems with SPI functions seeing
inappropriate tuple descriptors --- for example, plpgsql code failing to
cope with SELECT FOR UPDATE.
This commit is contained in:
Tom Lane
2001-05-27 20:48:51 +00:00
parent a3855c5761
commit 9e7243063c
4 changed files with 50 additions and 23 deletions

View File

@ -8,7 +8,7 @@
*
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/executor/execJunk.c,v 1.27 2001/03/22 06:16:12 momjian Exp $
* $Header: /cvsroot/pgsql/src/backend/executor/execJunk.c,v 1.28 2001/05/27 20:48:51 tgl Exp $
*
*-------------------------------------------------------------------------
*/
@ -56,10 +56,12 @@
* Initialize the Junk filter.
*
* The initial targetlist and associated tuple descriptor are passed in.
* An optional resultSlot can be passed as well.
*-------------------------------------------------------------------------
*/
JunkFilter *
ExecInitJunkFilter(List *targetList, TupleDesc tupType)
ExecInitJunkFilter(List *targetList, TupleDesc tupType,
TupleTableSlot *slot)
{
MemoryContext oldContext;
MemoryContext junkContext;
@ -245,6 +247,10 @@ ExecInitJunkFilter(List *targetList, TupleDesc tupType)
junkfilter->jf_cleanTupType = cleanTupType;
junkfilter->jf_cleanMap = cleanMap;
junkfilter->jf_junkContext = junkContext;
junkfilter->jf_resultSlot = slot;
if (slot)
ExecSetSlotDescriptor(slot, cleanTupType, false);
MemoryContextSwitchTo(oldContext);
@ -260,7 +266,6 @@ ExecInitJunkFilter(List *targetList, TupleDesc tupType)
void
ExecFreeJunkFilter(JunkFilter *junkfilter)
{
/*
* Since the junkfilter is inside its own context, we just have to
* delete the context and we're set.
@ -336,6 +341,10 @@ ExecGetJunkAttribute(JunkFilter *junkfilter,
* ExecRemoveJunk
*
* Construct and return a tuple with all the junk attributes removed.
*
* Note: for historical reasons, this does not store the constructed
* tuple into the junkfilter's resultSlot. The caller should do that
* if it wants to.
*-------------------------------------------------------------------------
*/
HeapTuple