Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion src/backend/executor/execExpr.c
Original file line number Diff line number Diff line change
Expand Up @@ -2927,7 +2927,8 @@ ExecInitWholeRowVar(ExprEvalStep *scratch, Var *variable, ExprState *state)
scratch->d.wholerow.junkFilter =
ExecInitJunkFilter(subplan->plan->targetlist,
ExecInitExtraTupleSlot(parent->state, NULL,
&TTSOpsVirtual));
&TTSOpsVirtual),
NULL);
}
}
}
Expand Down
25 changes: 23 additions & 2 deletions src/backend/executor/execJunk.c
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,9 @@

#include "executor/executor.h"

static TupleTableSlot *ExecFilterJunkInternal(JunkFilter *junkfilter,
TupleTableSlot *slot);

/*-------------------------------------------------------------------------
* XXX this stuff should be rewritten to take advantage
* of ExecProject() and the ProjectionInfo node.
Expand Down Expand Up @@ -55,9 +58,11 @@
* The source targetlist is passed in. The output tuple descriptor is
* built from the non-junk tlist entries.
* An optional resultSlot can be passed as well; otherwise, we create one.
* An optional execFilterJunkFunc can be passed as well; otherwise, we use ExecFilterJunk.
*/
JunkFilter *
ExecInitJunkFilter(List *targetList, TupleTableSlot *slot)
ExecInitJunkFilter(List *targetList, TupleTableSlot *slot,
ExecFilterJunkFunc execFilterJunkFunc)
{
JunkFilter *junkfilter;
TupleDesc cleanTupType;
Expand Down Expand Up @@ -120,6 +125,9 @@ ExecInitJunkFilter(List *targetList, TupleTableSlot *slot)
junkfilter->jf_cleanMap = cleanMap;
junkfilter->jf_resultSlot = slot;

Assert(execFilterJunkFunc != ExecFilterJunk);
junkfilter->jf_execFilterJunkFunc = execFilterJunkFunc;

return junkfilter;
}

Expand All @@ -136,7 +144,8 @@ ExecInitJunkFilter(List *targetList, TupleTableSlot *slot)
JunkFilter *
ExecInitJunkFilterConversion(List *targetList,
TupleDesc cleanTupType,
TupleTableSlot *slot)
TupleTableSlot *slot,
ExecFilterJunkFunc execFilterJunkFunc)
{
JunkFilter *junkfilter;
int cleanLength;
Expand Down Expand Up @@ -197,6 +206,9 @@ ExecInitJunkFilterConversion(List *targetList,
junkfilter->jf_cleanMap = cleanMap;
junkfilter->jf_resultSlot = slot;

Assert(execFilterJunkFunc != ExecFilterJunk);
junkfilter->jf_execFilterJunkFunc = execFilterJunkFunc;

return junkfilter;
}

Expand Down Expand Up @@ -245,6 +257,15 @@ ExecFindJunkAttributeInTlist(List *targetlist, const char *attrName)
*/
TupleTableSlot *
ExecFilterJunk(JunkFilter *junkfilter, TupleTableSlot *slot)
{
if (junkfilter->jf_execFilterJunkFunc)
return junkfilter->jf_execFilterJunkFunc(junkfilter, slot);

return ExecFilterJunkInternal(junkfilter, slot);
}

static TupleTableSlot *
ExecFilterJunkInternal(JunkFilter *junkfilter, TupleTableSlot *slot)
{
TupleTableSlot *resultSlot;
AttrNumber *cleanMap;
Expand Down
3 changes: 2 additions & 1 deletion src/backend/executor/execMain.c
Original file line number Diff line number Diff line change
Expand Up @@ -2027,7 +2027,8 @@ InitPlan(QueryDesc *queryDesc, int eflags)

slot = ExecInitExtraTupleSlot(estate, NULL, &TTSOpsVirtual);
j = ExecInitJunkFilter(planstate->plan->targetlist,
slot);
slot,
NULL);
estate->es_junkFilter = j;

/* Want to return the cleaned tuple type */
Expand Down
5 changes: 3 additions & 2 deletions src/backend/executor/functions.c
Original file line number Diff line number Diff line change
Expand Up @@ -895,9 +895,10 @@ init_sql_fcache(FunctionCallInfo fcinfo, Oid collation, bool lazyEvalOK)
if (rettupdesc && fcache->returnsTuple)
fcache->junkFilter = ExecInitJunkFilterConversion(resulttlist,
rettupdesc,
slot);
slot,
NULL);
else
fcache->junkFilter = ExecInitJunkFilter(resulttlist, slot);
fcache->junkFilter = ExecInitJunkFilter(resulttlist, slot, NULL);
}

if (fcache->returnsTuple)
Expand Down
3 changes: 2 additions & 1 deletion src/backend/executor/nodeTableFunction.c
Original file line number Diff line number Diff line change
Expand Up @@ -395,7 +395,8 @@ ExecInitTableFunction(TableFunctionScan *node, EState *estate, int eflags)
/* Determine projection information for subplan */
scanstate->inputscan->junkfilter =
ExecInitJunkFilter(subplan->plan->targetlist,
NULL /* slot */);
NULL /* slot */,
NULL);
BlessTupleDesc(scanstate->inputscan->junkfilter->jf_cleanTupType);

/*
Expand Down
6 changes: 4 additions & 2 deletions src/include/executor/executor.h
Original file line number Diff line number Diff line change
Expand Up @@ -175,10 +175,12 @@ extern void ResetTupleHashTable(TupleHashTable hashtable);
* prototypes from functions in execJunk.c
*/
extern JunkFilter *ExecInitJunkFilter(List *targetList,
TupleTableSlot *slot);
TupleTableSlot *slot,
ExecFilterJunkFunc execFilterJunkFunc);
extern JunkFilter *ExecInitJunkFilterConversion(List *targetList,
TupleDesc cleanTupType,
TupleTableSlot *slot);
TupleTableSlot *slot,
ExecFilterJunkFunc execFilterJunkFunc);
extern AttrNumber ExecFindJunkAttribute(JunkFilter *junkfilter,
const char *attrName);
extern AttrNumber ExecFindJunkAttributeInTlist(List *targetlist,
Expand Down
6 changes: 6 additions & 0 deletions src/include/nodes/execnodes.h
Original file line number Diff line number Diff line change
Expand Up @@ -374,15 +374,21 @@ typedef struct ProjectionInfo
* attribute numbers of the "original" tuple and the
* attribute numbers of the "clean" tuple.
* resultSlot: tuple slot used to hold cleaned tuple.
* execFilterJunk: function pointer to the function that will be used
* to filter the junk attributes from the input tuple.
* ----------------
*/
typedef struct JunkFilter JunkFilter;
typedef TupleTableSlot* (*ExecFilterJunkFunc)(JunkFilter *junkfilter,
TupleTableSlot *slot);
typedef struct JunkFilter
{
NodeTag type;
List *jf_targetList;
TupleDesc jf_cleanTupType;
AttrNumber *jf_cleanMap;
TupleTableSlot *jf_resultSlot;
ExecFilterJunkFunc jf_execFilterJunkFunc;
Comment thread
my-ship-it marked this conversation as resolved.
} JunkFilter;

/*
Expand Down
Loading