From: Tom Lane Date: Sat, 3 May 2008 23:19:27 +0000 (+0000) Subject: The 8.2 patch that added support for an alias on the target table of X-Git-Url: http://waps.l3s.uni-hannover.de/gitweb/?a=commitdiff_plain;h=fed321825aafb7411254d89fd62165791942f5c5;p=users%2Fbernd%2Fpostgres.git The 8.2 patch that added support for an alias on the target table of UPDATE/DELETE forgot to teach ruleutils.c to display the alias. Per bug #4141 from Mathias Seiler. --- diff --git a/src/backend/utils/adt/ruleutils.c b/src/backend/utils/adt/ruleutils.c index 7ce10562bf..8bd859c18e 100644 --- a/src/backend/utils/adt/ruleutils.c +++ b/src/backend/utils/adt/ruleutils.c @@ -2437,9 +2437,13 @@ get_update_query_def(Query *query, deparse_context *context) appendStringInfoChar(buf, ' '); context->indentLevel += PRETTYINDENT_STD; } - appendStringInfo(buf, "UPDATE %s%s SET ", + appendStringInfo(buf, "UPDATE %s%s", only_marker(rte), generate_relation_name(rte->relid)); + if (rte->alias != NULL) + appendStringInfo(buf, " %s", + quote_identifier(rte->alias->aliasname)); + appendStringInfoString(buf, " SET "); /* Add the comma separated list of 'attname = value' */ sep = ""; @@ -2511,12 +2515,15 @@ get_delete_query_def(Query *query, deparse_context *context) Assert(rte->rtekind == RTE_RELATION); if (PRETTY_INDENT(context)) { - context->indentLevel += PRETTYINDENT_STD; appendStringInfoChar(buf, ' '); + context->indentLevel += PRETTYINDENT_STD; } appendStringInfo(buf, "DELETE FROM %s%s", only_marker(rte), generate_relation_name(rte->relid)); + if (rte->alias != NULL) + appendStringInfo(buf, " %s", + quote_identifier(rte->alias->aliasname)); /* Add the USING clause if given */ get_from_clause(query, " USING ", context);