aboutsummaryrefslogtreecommitdiff
path: root/src/backend/utils/adt/ruleutils.c
diff options
context:
space:
mode:
authorTom Lane <tgl@sss.pgh.pa.us>2000-02-21 20:18:11 +0000
committerTom Lane <tgl@sss.pgh.pa.us>2000-02-21 20:18:11 +0000
commite1a95def8b38393d2b0819d27a33ce9a15f6510a (patch)
tree3f315f90840f54f429cfe38894e8ac5799f97079 /src/backend/utils/adt/ruleutils.c
parentc8009959c9320e9cf1e73324bc0f7dee966131d3 (diff)
downloadpostgresql-e1a95def8b38393d2b0819d27a33ce9a15f6510a.tar.gz
postgresql-e1a95def8b38393d2b0819d27a33ce9a15f6510a.zip
Quick hack solution so that pg_dump of views works. Needs repair after
Thomas gets back, but better this than nonfunctional pg_dump in the beta.
Diffstat (limited to 'src/backend/utils/adt/ruleutils.c')
-rw-r--r--src/backend/utils/adt/ruleutils.c41
1 files changed, 29 insertions, 12 deletions
diff --git a/src/backend/utils/adt/ruleutils.c b/src/backend/utils/adt/ruleutils.c
index 0267fc2c576..985c0c03093 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.42 2000/02/20 21:32:12 tgl Exp $
+ * $Header: /cvsroot/pgsql/src/backend/utils/adt/ruleutils.c,v 1.43 2000/02/21 20:18:10 tgl Exp $
*
* This software is copyrighted by Jan Wieck - Hamburg.
*
@@ -991,22 +991,39 @@ get_select_query_def(Query *query, deparse_context *context)
appendStringInfo(buf, "%s%s",
quote_identifier(rte->relname),
inherit_marker(rte));
+ /*
+ * NOTE: SQL92 says you can't write column aliases unless
+ * you write a table alias --- but the table alias could
+ * be spelled the same as the table's real name. This
+ * logic is therefore all wet: it should go something like
+ * IF we-need-to-dump-column-aliases OR relname != refname
+ * THEN print refname;
+ * IF we-need-to-dump-column-aliases
+ * THEN print column alias list.
+ * But currently we can't tell whether we need to dump
+ * column aliases or not... without that, this clearly
+ * backwards logic seems the best short-term approach.
+ * Since we don't really support SQL joins yet, dropping
+ * the list of column aliases doesn't hurt anything...
+ */
if (strcmp(rte->relname, rte->ref->relname) != 0)
+ {
appendStringInfo(buf, " %s",
quote_identifier(rte->ref->relname));
- if (rte->ref->attrs != NIL)
- {
- List *col;
-
- appendStringInfo(buf, " (");
- foreach(col, rte->ref->attrs)
+ if (rte->ref->attrs != NIL)
{
- if (col != rte->ref->attrs)
- appendStringInfo(buf, ", ");
- appendStringInfo(buf, "%s",
- quote_identifier(strVal(lfirst(col))));
+ List *col;
+
+ appendStringInfo(buf, " (");
+ foreach(col, rte->ref->attrs)
+ {
+ if (col != rte->ref->attrs)
+ appendStringInfo(buf, ", ");
+ appendStringInfo(buf, "%s",
+ quote_identifier(strVal(lfirst(col))));
+ }
+ appendStringInfoChar(buf, ')');
}
- appendStringInfoChar(buf, ')');
}
}
}