]> granicus.if.org Git - postgresql/commitdiff
The 8.2 patch that added support for an alias on the target table of
authorTom Lane <tgl@sss.pgh.pa.us>
Sat, 3 May 2008 23:19:27 +0000 (23:19 +0000)
committerTom Lane <tgl@sss.pgh.pa.us>
Sat, 3 May 2008 23:19:27 +0000 (23:19 +0000)
UPDATE/DELETE forgot to teach ruleutils.c to display the alias.
Per bug #4141 from Mathias Seiler.

src/backend/utils/adt/ruleutils.c

index db86d69efe5fa29379ee163df838dc11baf67c19..8578b5c7cb54ca0633f3d76b47d08a2eb6289fb4 100644 (file)
@@ -9,7 +9,7 @@
  *
  *
  * IDENTIFICATION
- *       $PostgreSQL: pgsql/src/backend/utils/adt/ruleutils.c,v 1.269 2008/01/06 01:03:16 tgl Exp $
+ *       $PostgreSQL: pgsql/src/backend/utils/adt/ruleutils.c,v 1.269.2.1 2008/05/03 23:19:27 tgl Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -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);