*
  *
  * 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 $
  *
  *-------------------------------------------------------------------------
  */
        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 = "";
    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);