#include "postgres.h"#include "executor/executor.h"
Go to the source code of this file.
Functions | |
| JunkFilter * | ExecInitJunkFilter (List *targetList, bool hasoid, TupleTableSlot *slot) |
| JunkFilter * | ExecInitJunkFilterConversion (List *targetList, TupleDesc cleanTupType, TupleTableSlot *slot) |
| AttrNumber | ExecFindJunkAttribute (JunkFilter *junkfilter, const char *attrName) |
| AttrNumber | ExecFindJunkAttributeInTlist (List *targetlist, const char *attrName) |
| Datum | ExecGetJunkAttribute (TupleTableSlot *slot, AttrNumber attno, bool *isNull) |
| TupleTableSlot * | ExecFilterJunk (JunkFilter *junkfilter, TupleTableSlot *slot) |
| TupleTableSlot* ExecFilterJunk | ( | JunkFilter * | junkfilter, | |
| TupleTableSlot * | slot | |||
| ) |
Definition at line 262 of file execJunk.c.
References ExecClearTuple(), ExecStoreVirtualTuple(), i, JunkFilter::jf_cleanMap, JunkFilter::jf_cleanTupType, JunkFilter::jf_resultSlot, tupleDesc::natts, slot_getallattrs(), TupleTableSlot::tts_isnull, TupleTableSlot::tts_values, and values.
Referenced by ExecBRUpdateTriggers(), ExecEvalWholeRowFast(), ExecEvalWholeRowSlow(), ExecEvalWholeRowVar(), ExecModifyTable(), ExecUpdate(), ExecutePlan(), and sqlfunction_receive().
{
TupleTableSlot *resultSlot;
AttrNumber *cleanMap;
TupleDesc cleanTupType;
int cleanLength;
int i;
Datum *values;
bool *isnull;
Datum *old_values;
bool *old_isnull;
/*
* Extract all the values of the old tuple.
*/
slot_getallattrs(slot);
old_values = slot->tts_values;
old_isnull = slot->tts_isnull;
/*
* get info from the junk filter
*/
cleanTupType = junkfilter->jf_cleanTupType;
cleanLength = cleanTupType->natts;
cleanMap = junkfilter->jf_cleanMap;
resultSlot = junkfilter->jf_resultSlot;
/*
* Prepare to build a virtual result tuple.
*/
ExecClearTuple(resultSlot);
values = resultSlot->tts_values;
isnull = resultSlot->tts_isnull;
/*
* Transpose data into proper fields of the new tuple.
*/
for (i = 0; i < cleanLength; i++)
{
int j = cleanMap[i];
if (j == 0)
{
values[i] = (Datum) 0;
isnull[i] = true;
}
else
{
values[i] = old_values[j - 1];
isnull[i] = old_isnull[j - 1];
}
}
/*
* And return the virtual tuple.
*/
return ExecStoreVirtualTuple(resultSlot);
}
| AttrNumber ExecFindJunkAttribute | ( | JunkFilter * | junkfilter, | |
| const char * | attrName | |||
| ) |
Definition at line 209 of file execJunk.c.
References ExecFindJunkAttributeInTlist(), and JunkFilter::jf_targetList.
Referenced by ExecInitModifyTable().
{
return ExecFindJunkAttributeInTlist(junkfilter->jf_targetList, attrName);
}
| AttrNumber ExecFindJunkAttributeInTlist | ( | List * | targetlist, | |
| const char * | attrName | |||
| ) |
Definition at line 221 of file execJunk.c.
References lfirst, TargetEntry::resjunk, TargetEntry::resname, and TargetEntry::resno.
Referenced by ExecBuildAuxRowMark(), ExecFindJunkAttribute(), and postgresBeginForeignModify().
| Datum ExecGetJunkAttribute | ( | TupleTableSlot * | slot, | |
| AttrNumber | attno, | |||
| bool * | isNull | |||
| ) |
Definition at line 248 of file execJunk.c.
References Assert, and slot_getattr().
Referenced by EvalPlanQualFetchRowMarks(), ExecLockRows(), ExecModifyTable(), postgresExecForeignDelete(), and postgresExecForeignUpdate().
{
Assert(attno > 0);
return slot_getattr(slot, attno, isNull);
}
| JunkFilter* ExecInitJunkFilter | ( | List * | targetList, | |
| bool | hasoid, | |||
| TupleTableSlot * | slot | |||
| ) |
Definition at line 61 of file execJunk.c.
References ExecCleanTypeFromTL(), ExecSetSlotDescriptor(), JunkFilter::jf_cleanMap, JunkFilter::jf_cleanTupType, JunkFilter::jf_resultSlot, JunkFilter::jf_targetList, lfirst, makeNode, MakeSingleTupleTableSlot(), tupleDesc::natts, palloc(), TargetEntry::resjunk, and TargetEntry::resno.
Referenced by check_sql_fn_retval(), ExecEvalWholeRowVar(), ExecInitModifyTable(), and InitPlan().
{
JunkFilter *junkfilter;
TupleDesc cleanTupType;
int cleanLength;
AttrNumber *cleanMap;
ListCell *t;
AttrNumber cleanResno;
/*
* Compute the tuple descriptor for the cleaned tuple.
*/
cleanTupType = ExecCleanTypeFromTL(targetList, hasoid);
/*
* Use the given slot, or make a new slot if we weren't given one.
*/
if (slot)
ExecSetSlotDescriptor(slot, cleanTupType);
else
slot = MakeSingleTupleTableSlot(cleanTupType);
/*
* Now calculate the mapping between the original tuple's attributes and
* the "clean" tuple's attributes.
*
* The "map" is an array of "cleanLength" attribute numbers, i.e. one
* entry for every attribute of the "clean" tuple. The value of this entry
* is the attribute number of the corresponding attribute of the
* "original" tuple. (Zero indicates a NULL output attribute, but we do
* not use that feature in this routine.)
*/
cleanLength = cleanTupType->natts;
if (cleanLength > 0)
{
cleanMap = (AttrNumber *) palloc(cleanLength * sizeof(AttrNumber));
cleanResno = 1;
foreach(t, targetList)
{
TargetEntry *tle = lfirst(t);
if (!tle->resjunk)
{
cleanMap[cleanResno - 1] = tle->resno;
cleanResno++;
}
}
}
else
cleanMap = NULL;
/*
* Finally create and initialize the JunkFilter struct.
*/
junkfilter = makeNode(JunkFilter);
junkfilter->jf_targetList = targetList;
junkfilter->jf_cleanTupType = cleanTupType;
junkfilter->jf_cleanMap = cleanMap;
junkfilter->jf_resultSlot = slot;
return junkfilter;
}
| JunkFilter* ExecInitJunkFilterConversion | ( | List * | targetList, | |
| TupleDesc | cleanTupType, | |||
| TupleTableSlot * | slot | |||
| ) |
Definition at line 136 of file execJunk.c.
References tupleDesc::attrs, ExecSetSlotDescriptor(), i, JunkFilter::jf_cleanMap, JunkFilter::jf_cleanTupType, JunkFilter::jf_resultSlot, JunkFilter::jf_targetList, lfirst, list_head(), lnext, makeNode, MakeSingleTupleTableSlot(), tupleDesc::natts, palloc0(), TargetEntry::resjunk, and TargetEntry::resno.
Referenced by check_sql_fn_retval().
{
JunkFilter *junkfilter;
int cleanLength;
AttrNumber *cleanMap;
ListCell *t;
int i;
/*
* Use the given slot, or make a new slot if we weren't given one.
*/
if (slot)
ExecSetSlotDescriptor(slot, cleanTupType);
else
slot = MakeSingleTupleTableSlot(cleanTupType);
/*
* Calculate the mapping between the original tuple's attributes and the
* "clean" tuple's attributes.
*
* The "map" is an array of "cleanLength" attribute numbers, i.e. one
* entry for every attribute of the "clean" tuple. The value of this entry
* is the attribute number of the corresponding attribute of the
* "original" tuple. We store zero for any deleted attributes, marking
* that a NULL is needed in the output tuple.
*/
cleanLength = cleanTupType->natts;
if (cleanLength > 0)
{
cleanMap = (AttrNumber *) palloc0(cleanLength * sizeof(AttrNumber));
t = list_head(targetList);
for (i = 0; i < cleanLength; i++)
{
if (cleanTupType->attrs[i]->attisdropped)
continue; /* map entry is already zero */
for (;;)
{
TargetEntry *tle = lfirst(t);
t = lnext(t);
if (!tle->resjunk)
{
cleanMap[i] = tle->resno;
break;
}
}
}
}
else
cleanMap = NULL;
/*
* Finally create and initialize the JunkFilter struct.
*/
junkfilter = makeNode(JunkFilter);
junkfilter->jf_targetList = targetList;
junkfilter->jf_cleanTupType = cleanTupType;
junkfilter->jf_cleanMap = cleanMap;
junkfilter->jf_resultSlot = slot;
return junkfilter;
}
1.7.1