aboutsummaryrefslogtreecommitdiff
path: root/src/backend/utils/adt/ruleutils.c
diff options
context:
space:
mode:
authorThomas G. Lockhart <lockhart@fourpalms.org>2000-02-15 03:38:29 +0000
committerThomas G. Lockhart <lockhart@fourpalms.org>2000-02-15 03:38:29 +0000
commita344a6e7b5d7b2b87f33a155c3ef88bdfdce3fd8 (patch)
tree78c19baad416cfe014237bc726baff63aff2b150 /src/backend/utils/adt/ruleutils.c
parent92c8437d8de8efeb5324fcccb0175beec8e66619 (diff)
downloadpostgresql-a344a6e7b5d7b2b87f33a155c3ef88bdfdce3fd8.tar.gz
postgresql-a344a6e7b5d7b2b87f33a155c3ef88bdfdce3fd8.zip
Carry column aliases from the parser frontend. Enables queries like
SELECT a FROM t1 tx (a); Allow join syntax, including queries like SELECT * FROM t1 NATURAL JOIN t2; Update RTE structure to hold column aliases in an Attr structure.
Diffstat (limited to 'src/backend/utils/adt/ruleutils.c')
-rw-r--r--src/backend/utils/adt/ruleutils.c34
1 files changed, 22 insertions, 12 deletions
diff --git a/src/backend/utils/adt/ruleutils.c b/src/backend/utils/adt/ruleutils.c
index c4e31491604..d3c25345057 100644
--- a/src/backend/utils/adt/ruleutils.c
+++ b/src/backend/utils/adt/ruleutils.c
@@ -3,7 +3,7 @@
* out of its tuple
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/backend/utils/adt/ruleutils.c,v 1.39 2000/01/15 22:43:24 tgl Exp $
+ * $Header: /cvsroot/pgsql/src/backend/utils/adt/ruleutils.c,v 1.40 2000/02/15 03:37:56 thomas Exp $
*
* This software is copyrighted by Jan Wieck - Hamburg.
*
@@ -922,9 +922,9 @@ get_select_query_def(Query *query, deparse_context *context)
continue;
rte = (RangeTblEntry *) lfirst(l);
- if (!strcmp(rte->refname, "*NEW*"))
+ if (!strcmp(rte->ref->relname, "*NEW*"))
continue;
- if (!strcmp(rte->refname, "*CURRENT*"))
+ if (!strcmp(rte->ref->relname, "*CURRENT*"))
continue;
rt_constonly = FALSE;
@@ -980,10 +980,10 @@ get_select_query_def(Query *query, deparse_context *context)
{
rte = (RangeTblEntry *) lfirst(l);
- if (!strcmp(rte->refname, "*NEW*"))
+ if (!strcmp(rte->ref->relname, "*NEW*"))
continue;
- if (!strcmp(rte->refname, "*CURRENT*"))
+ if (!strcmp(rte->ref->relname, "*CURRENT*"))
continue;
appendStringInfo(buf, sep);
@@ -991,9 +991,19 @@ get_select_query_def(Query *query, deparse_context *context)
appendStringInfo(buf, "%s%s",
quote_identifier(rte->relname),
inherit_marker(rte));
- if (strcmp(rte->relname, rte->refname) != 0)
+ if (strcmp(rte->relname, rte->ref->relname) != 0)
+ {
+ List *col;
appendStringInfo(buf, " %s",
- quote_identifier(rte->refname));
+ quote_identifier(rte->ref->relname));
+ appendStringInfo(buf, " (");
+ foreach (col, rte->ref->attrs)
+ {
+ if (col != lfirst(rte->ref->attrs))
+ appendStringInfo(buf, ", ");
+ appendStringInfo(buf, "%s", strVal(col));
+ }
+ }
}
}
}
@@ -1071,9 +1081,9 @@ get_insert_query_def(Query *query, deparse_context *context)
continue;
rte = (RangeTblEntry *) lfirst(l);
- if (!strcmp(rte->refname, "*NEW*"))
+ if (!strcmp(rte->ref->relname, "*NEW*"))
continue;
- if (!strcmp(rte->refname, "*CURRENT*"))
+ if (!strcmp(rte->ref->relname, "*CURRENT*"))
continue;
rt_constonly = FALSE;
@@ -1241,13 +1251,13 @@ get_rule_expr(Node *node, deparse_context *context)
if (context->varprefix)
{
- if (!strcmp(rte->refname, "*NEW*"))
+ if (!strcmp(rte->ref->relname, "*NEW*"))
appendStringInfo(buf, "new.");
- else if (!strcmp(rte->refname, "*CURRENT*"))
+ else if (!strcmp(rte->ref->relname, "*CURRENT*"))
appendStringInfo(buf, "old.");
else
appendStringInfo(buf, "%s.",
- quote_identifier(rte->refname));
+ quote_identifier(rte->ref->relname));
}
appendStringInfo(buf, "%s",
quote_identifier(get_attribute_name(rte->relid,