diff options
author | Tom Lane <tgl@sss.pgh.pa.us> | 2005-04-06 16:34:07 +0000 |
---|---|---|
committer | Tom Lane <tgl@sss.pgh.pa.us> | 2005-04-06 16:34:07 +0000 |
commit | ad161bcc8a3792d18ef2f3ebe66bb1e22d42b6f2 (patch) | |
tree | 18ec8963fbd1d6dd62ad214bfe3552fc2e7d06eb /src/backend/nodes/makefuncs.c | |
parent | 0f3748a28c42d09d794ff00af3f1f992eaa5fd7c (diff) | |
download | postgresql-ad161bcc8a3792d18ef2f3ebe66bb1e22d42b6f2.tar.gz postgresql-ad161bcc8a3792d18ef2f3ebe66bb1e22d42b6f2.zip |
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.
Diffstat (limited to 'src/backend/nodes/makefuncs.c')
-rw-r--r-- | src/backend/nodes/makefuncs.c | 63 |
1 files changed, 32 insertions, 31 deletions
diff --git a/src/backend/nodes/makefuncs.c b/src/backend/nodes/makefuncs.c index 026b962bb99..e1e6c3da836 100644 --- a/src/backend/nodes/makefuncs.c +++ b/src/backend/nodes/makefuncs.c @@ -9,7 +9,7 @@ * * * IDENTIFICATION - * $PostgreSQL: pgsql/src/backend/nodes/makefuncs.c,v 1.46 2004/12/31 21:59:55 pgsql Exp $ + * $PostgreSQL: pgsql/src/backend/nodes/makefuncs.c,v 1.47 2005/04/06 16:34:05 tgl Exp $ * *------------------------------------------------------------------------- */ @@ -87,48 +87,49 @@ makeVar(Index varno, /* * makeTargetEntry - - * creates a TargetEntry node (contains a Resdom) + * creates a TargetEntry node */ TargetEntry * -makeTargetEntry(Resdom *resdom, Expr *expr) +makeTargetEntry(Expr *expr, + AttrNumber resno, + char *resname, + bool resjunk) { - TargetEntry *rt = makeNode(TargetEntry); + TargetEntry *tle = makeNode(TargetEntry); - rt->resdom = resdom; - rt->expr = expr; - return rt; -} - -/* - * makeResdom - - * creates a Resdom (Result Domain) node - */ -Resdom * -makeResdom(AttrNumber resno, - Oid restype, - int32 restypmod, - char *resname, - bool resjunk) -{ - Resdom *resdom = makeNode(Resdom); - - resdom->resno = resno; - resdom->restype = restype; - resdom->restypmod = restypmod; - resdom->resname = resname; + tle->expr = expr; + tle->resno = resno; + tle->resname = resname; /* * We always set these fields to 0. If the caller wants to change them * he must do so explicitly. Few callers do that, so omitting these * arguments reduces the chance of error. */ - resdom->ressortgroupref = 0; - resdom->resorigtbl = InvalidOid; - resdom->resorigcol = 0; + tle->ressortgroupref = 0; + tle->resorigtbl = InvalidOid; + tle->resorigcol = 0; + + tle->resjunk = resjunk; - resdom->resjunk = resjunk; + return tle; +} + +/* + * flatCopyTargetEntry - + * duplicate a TargetEntry, but don't copy substructure + * + * This is commonly used when we just want to modify the resno or substitute + * a new expression. + */ +TargetEntry * +flatCopyTargetEntry(TargetEntry *src_tle) +{ + TargetEntry *tle = makeNode(TargetEntry); - return resdom; + Assert(IsA(src_tle, TargetEntry)); + memcpy(tle, src_tle, sizeof(TargetEntry)); + return tle; } /* |