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/utils/adt/ruleutils.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/utils/adt/ruleutils.c')
-rw-r--r-- | src/backend/utils/adt/ruleutils.c | 27 |
1 files changed, 13 insertions, 14 deletions
diff --git a/src/backend/utils/adt/ruleutils.c b/src/backend/utils/adt/ruleutils.c index 814deff5e3a..2f8e86e4b06 100644 --- a/src/backend/utils/adt/ruleutils.c +++ b/src/backend/utils/adt/ruleutils.c @@ -3,7 +3,7 @@ * back to source text * * IDENTIFICATION - * $PostgreSQL: pgsql/src/backend/utils/adt/ruleutils.c,v 1.189 2005/03/29 00:17:08 tgl Exp $ + * $PostgreSQL: pgsql/src/backend/utils/adt/ruleutils.c,v 1.190 2005/04/06 16:34:06 tgl Exp $ * * This software is copyrighted by Jan Wieck - Hamburg. * @@ -1493,13 +1493,12 @@ deparse_context_for_subplan(const char *name, List *tlist, foreach(tl, tlist) { TargetEntry *tle = lfirst(tl); - Resdom *resdom = tle->resdom; nattrs++; - Assert(resdom->resno == nattrs); - if (resdom->resname) + Assert(tle->resno == nattrs); + if (tle->resname) { - attrs = lappend(attrs, makeString(resdom->resname)); + attrs = lappend(attrs, makeString(tle->resname)); continue; } if (tle->expr && IsA(tle->expr, Var)) @@ -1518,7 +1517,7 @@ deparse_context_for_subplan(const char *name, List *tlist, } } /* Fallback if can't get name */ - snprintf(buf, sizeof(buf), "?column%d?", resdom->resno); + snprintf(buf, sizeof(buf), "?column%d?", tle->resno); attrs = lappend(attrs, makeString(pstrdup(buf))); } @@ -1974,7 +1973,7 @@ get_basic_select_query(Query *query, deparse_context *context, TargetEntry *tle = (TargetEntry *) lfirst(l); char *colname; - if (tle->resdom->resjunk) + if (tle->resjunk) continue; /* ignore junk entries */ appendStringInfo(buf, sep); @@ -1992,7 +1991,7 @@ get_basic_select_query(Query *query, deparse_context *context, if (resultDesc && colno <= resultDesc->natts) colname = NameStr(resultDesc->attrs[colno - 1]->attname); else - colname = tle->resdom->resname; + colname = tle->resname; if (colname) /* resname could be NULL */ { @@ -2166,8 +2165,8 @@ get_rule_sortgroupclause(SortClause *srt, List *tlist, bool force_colno, */ if (force_colno || (expr && IsA(expr, Const))) { - Assert(!tle->resdom->resjunk); - appendStringInfo(buf, "%d", tle->resdom->resno); + Assert(!tle->resjunk); + appendStringInfo(buf, "%d", tle->resno); } else get_rule_expr(expr, context, true); @@ -2227,7 +2226,7 @@ get_insert_query_def(Query *query, deparse_context *context) { TargetEntry *tle = (TargetEntry *) lfirst(l); - if (tle->resdom->resjunk) + if (tle->resjunk) continue; /* ignore junk entries */ appendStringInfo(buf, sep); @@ -2239,7 +2238,7 @@ get_insert_query_def(Query *query, deparse_context *context) */ appendStringInfoString(buf, quote_identifier(get_relid_attribute_name(rte->relid, - tle->resdom->resno))); + tle->resno))); /* * Print any indirection needed (subfields or subscripts), and @@ -2299,7 +2298,7 @@ get_update_query_def(Query *query, deparse_context *context) TargetEntry *tle = (TargetEntry *) lfirst(l); Node *expr; - if (tle->resdom->resjunk) + if (tle->resjunk) continue; /* ignore junk entries */ appendStringInfo(buf, sep); @@ -2311,7 +2310,7 @@ get_update_query_def(Query *query, deparse_context *context) */ appendStringInfoString(buf, quote_identifier(get_relid_attribute_name(rte->relid, - tle->resdom->resno))); + tle->resno))); /* * Print any indirection needed (subfields or subscripts), and |