1
0
mirror of https://github.com/postgres/postgres.git synced 2025-07-02 09:02:37 +03:00

Merge Resdom nodes into TargetEntry nodes to simplify code and save a

few palloc's.  I also chose to eliminate the restype and restypmod fields
entirely, since they are redundant with information stored in the node's
contained expression; re-examining the expression at need seems simpler
and more reliable than trying to keep restype/restypmod up to date.

initdb forced due to change in contents of stored rules.
This commit is contained in:
Tom Lane
2005-04-06 16:34:07 +00:00
parent 0f3748a28c
commit ad161bcc8a
43 changed files with 537 additions and 799 deletions

View File

@ -8,7 +8,7 @@
*
*
* IDENTIFICATION
* $PostgreSQL: pgsql/src/backend/executor/execJunk.c,v 1.48 2005/03/16 21:38:06 tgl Exp $
* $PostgreSQL: pgsql/src/backend/executor/execJunk.c,v 1.49 2005/04/06 16:34:04 tgl Exp $
*
*-------------------------------------------------------------------------
*/
@ -31,8 +31,8 @@
* of some system attributes like "ctid" or rule locks.
*
* The general idea is the following: A target list consists of a list of
* Resdom nodes & expression pairs. Each Resdom node has an attribute
* called 'resjunk'. If the value of this attribute is true then the
* TargetEntry nodes containing expressions. Each TargetEntry has a field
* called 'resjunk'. If the value of this field is true then the
* corresponding attribute is a "junk" attribute.
*
* When we initialize a plan we call 'ExecInitJunkFilter' to create
@ -101,11 +101,10 @@ ExecInitJunkFilter(List *targetList, bool hasoid, TupleTableSlot *slot)
foreach(t, targetList)
{
TargetEntry *tle = lfirst(t);
Resdom *resdom = tle->resdom;
if (!resdom->resjunk)
if (!tle->resjunk)
{
cleanMap[cleanResno - 1] = resdom->resno;
cleanMap[cleanResno - 1] = tle->resno;
cleanResno++;
}
}
@ -177,12 +176,11 @@ ExecInitJunkFilterConversion(List *targetList,
for (;;)
{
TargetEntry *tle = lfirst(t);
Resdom *resdom = tle->resdom;
t = lnext(t);
if (!resdom->resjunk)
if (!tle->resjunk)
{
cleanMap[i] = resdom->resno;
cleanMap[i] = tle->resno;
break;
}
}
@ -228,13 +226,12 @@ ExecGetJunkAttribute(JunkFilter *junkfilter,
foreach(t, junkfilter->jf_targetList)
{
TargetEntry *tle = lfirst(t);
Resdom *resdom = tle->resdom;
if (resdom->resjunk && resdom->resname &&
(strcmp(resdom->resname, attrName) == 0))
if (tle->resjunk && tle->resname &&
(strcmp(tle->resname, attrName) == 0))
{
/* We found it ! */
*value = slot_getattr(slot, resdom->resno, isNull);
*value = slot_getattr(slot, tle->resno, isNull);
return true;
}
}

View File

@ -26,7 +26,7 @@
*
*
* IDENTIFICATION
* $PostgreSQL: pgsql/src/backend/executor/execMain.c,v 1.244 2005/03/25 21:57:58 tgl Exp $
* $PostgreSQL: pgsql/src/backend/executor/execMain.c,v 1.245 2005/04/06 16:34:04 tgl Exp $
*
*-------------------------------------------------------------------------
*/
@ -640,7 +640,7 @@ InitPlan(QueryDesc *queryDesc, bool explainOnly)
{
TargetEntry *tle = (TargetEntry *) lfirst(tlist);
if (tle->resdom->resjunk)
if (tle->resjunk)
{
junk_filter_needed = true;
break;

View File

@ -8,7 +8,7 @@
*
*
* IDENTIFICATION
* $PostgreSQL: pgsql/src/backend/executor/execQual.c,v 1.175 2005/03/29 00:16:59 tgl Exp $
* $PostgreSQL: pgsql/src/backend/executor/execQual.c,v 1.176 2005/04/06 16:34:04 tgl Exp $
*
*-------------------------------------------------------------------------
*/
@ -3467,7 +3467,7 @@ ExecCleanTargetListLength(List *targetlist)
TargetEntry *curTle = (TargetEntry *) lfirst(tl);
Assert(IsA(curTle, TargetEntry));
if (!curTle->resdom->resjunk)
if (!curTle->resjunk)
len++;
}
return len;
@ -3516,7 +3516,7 @@ ExecTargetList(List *targetlist,
{
GenericExprState *gstate = (GenericExprState *) lfirst(tl);
TargetEntry *tle = (TargetEntry *) gstate->xprstate.expr;
AttrNumber resind = tle->resdom->resno - 1;
AttrNumber resind = tle->resno - 1;
values[resind] = ExecEvalExpr(gstate->arg,
econtext,
@ -3568,7 +3568,7 @@ ExecTargetList(List *targetlist,
{
GenericExprState *gstate = (GenericExprState *) lfirst(tl);
TargetEntry *tle = (TargetEntry *) gstate->xprstate.expr;
AttrNumber resind = tle->resdom->resno - 1;
AttrNumber resind = tle->resno - 1;
if (itemIsDone[resind] == ExprEndResult)
{
@ -3602,7 +3602,7 @@ ExecTargetList(List *targetlist,
{
GenericExprState *gstate = (GenericExprState *) lfirst(tl);
TargetEntry *tle = (TargetEntry *) gstate->xprstate.expr;
AttrNumber resind = tle->resdom->resno - 1;
AttrNumber resind = tle->resno - 1;
while (itemIsDone[resind] == ExprMultipleResult)
{

View File

@ -15,7 +15,7 @@
*
*
* IDENTIFICATION
* $PostgreSQL: pgsql/src/backend/executor/execTuples.c,v 1.86 2005/03/17 15:25:51 tgl Exp $
* $PostgreSQL: pgsql/src/backend/executor/execTuples.c,v 1.87 2005/04/06 16:34:04 tgl Exp $
*
*-------------------------------------------------------------------------
*/
@ -784,15 +784,14 @@ ExecTypeFromTLInternal(List *targetList, bool hasoid, bool skipjunk)
foreach(l, targetList)
{
TargetEntry *tle = lfirst(l);
Resdom *resdom = tle->resdom;
if (skipjunk && resdom->resjunk)
if (skipjunk && tle->resjunk)
continue;
TupleDescInitEntry(typeInfo,
cur_resno++,
resdom->resname,
resdom->restype,
resdom->restypmod,
tle->resname,
exprType((Node *) tle->expr),
exprTypmod((Node *) tle->expr),
0);
}

View File

@ -8,7 +8,7 @@
*
*
* IDENTIFICATION
* $PostgreSQL: pgsql/src/backend/executor/execUtils.c,v 1.119 2005/03/21 01:24:03 tgl Exp $
* $PostgreSQL: pgsql/src/backend/executor/execUtils.c,v 1.120 2005/04/06 16:34:04 tgl Exp $
*
*-------------------------------------------------------------------------
*/
@ -561,7 +561,7 @@ ExecBuildProjectionInfo(List *targetList,
Var *variable = (Var *) gstate->arg->expr;
AttrNumber attnum = variable->varattno;
TargetEntry *tle = (TargetEntry *) gstate->xprstate.expr;
AttrNumber resind = tle->resdom->resno - 1;
AttrNumber resind = tle->resno - 1;
Assert(resind >= 0 && resind < len);
varNumbers[resind] = attnum;

View File

@ -8,7 +8,7 @@
*
*
* IDENTIFICATION
* $PostgreSQL: pgsql/src/backend/executor/functions.c,v 1.95 2005/03/31 22:46:08 tgl Exp $
* $PostgreSQL: pgsql/src/backend/executor/functions.c,v 1.96 2005/04/06 16:34:04 tgl Exp $
*
*-------------------------------------------------------------------------
*/
@ -935,7 +935,7 @@ check_sql_fn_retval(Oid func_id, Oid rettype, List *queryTreeList,
format_type_be(rettype)),
errdetail("Final SELECT must return exactly one column.")));
restype = ((TargetEntry *) linitial(tlist))->resdom->restype;
restype = exprType((Node *) ((TargetEntry *) linitial(tlist))->expr);
if (!IsBinaryCoercible(restype, rettype))
ereport(ERROR,
(errcode(ERRCODE_INVALID_FUNCTION_DEFINITION),
@ -961,7 +961,7 @@ check_sql_fn_retval(Oid func_id, Oid rettype, List *queryTreeList,
*/
if (tlistlen == 1)
{
restype = ((TargetEntry *) linitial(tlist))->resdom->restype;
restype = exprType((Node *) ((TargetEntry *) linitial(tlist))->expr);
if (IsBinaryCoercible(restype, rettype))
return false; /* NOT returning whole tuple */
}
@ -996,7 +996,7 @@ check_sql_fn_retval(Oid func_id, Oid rettype, List *queryTreeList,
Oid tletype;
Oid atttype;
if (tle->resdom->resjunk)
if (tle->resjunk)
continue;
do

View File

@ -7,7 +7,7 @@
* Portions Copyright (c) 1994, Regents of the University of California
*
* IDENTIFICATION
* $PostgreSQL: pgsql/src/backend/executor/nodeSubplan.c,v 1.67 2005/03/16 21:38:08 tgl Exp $
* $PostgreSQL: pgsql/src/backend/executor/nodeSubplan.c,v 1.68 2005/04/06 16:34:04 tgl Exp $
*
*-------------------------------------------------------------------------
*/
@ -828,12 +828,10 @@ ExecInitSubPlan(SubPlanState *node, EState *estate)
/* Process lefthand argument */
exstate = (ExprState *) linitial(fstate->args);
expr = exstate->expr;
tle = makeTargetEntry(makeResdom(i,
exprType((Node *) expr),
exprTypmod((Node *) expr),
NULL,
false),
expr);
tle = makeTargetEntry(expr,
i,
NULL,
false);
tlestate = makeNode(GenericExprState);
tlestate->xprstate.expr = (Expr *) tle;
tlestate->xprstate.evalfunc = NULL;
@ -844,12 +842,10 @@ ExecInitSubPlan(SubPlanState *node, EState *estate)
/* Process righthand argument */
exstate = (ExprState *) lsecond(fstate->args);
expr = exstate->expr;
tle = makeTargetEntry(makeResdom(i,
exprType((Node *) expr),
exprTypmod((Node *) expr),
NULL,
false),
expr);
tle = makeTargetEntry(expr,
i,
NULL,
false);
tlestate = makeNode(GenericExprState);
tlestate->xprstate.expr = (Expr *) tle;
tlestate->xprstate.evalfunc = NULL;