Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit c88850f

Browse files
committed
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.
1 parent bdc7dd6 commit c88850f

File tree

1 file changed

+10
-3
lines changed

1 file changed

+10
-3
lines changed

src/backend/utils/adt/ruleutils.c

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
*
1010
*
1111
* IDENTIFICATION
12-
* $PostgreSQL: pgsql/src/backend/utils/adt/ruleutils.c,v 1.272 2008/03/28 00:21:56 tgl Exp $
12+
* $PostgreSQL: pgsql/src/backend/utils/adt/ruleutils.c,v 1.273 2008/05/03 23:19:20 tgl Exp $
1313
*
1414
*-------------------------------------------------------------------------
1515
*/
@@ -2443,9 +2443,13 @@ get_update_query_def(Query *query, deparse_context *context)
24432443
appendStringInfoChar(buf, ' ');
24442444
context->indentLevel += PRETTYINDENT_STD;
24452445
}
2446-
appendStringInfo(buf, "UPDATE %s%s SET ",
2446+
appendStringInfo(buf, "UPDATE %s%s",
24472447
only_marker(rte),
24482448
generate_relation_name(rte->relid));
2449+
if (rte->alias != NULL)
2450+
appendStringInfo(buf, " %s",
2451+
quote_identifier(rte->alias->aliasname));
2452+
appendStringInfoString(buf, " SET ");
24492453

24502454
/* Add the comma separated list of 'attname = value' */
24512455
sep = "";
@@ -2517,12 +2521,15 @@ get_delete_query_def(Query *query, deparse_context *context)
25172521
Assert(rte->rtekind == RTE_RELATION);
25182522
if (PRETTY_INDENT(context))
25192523
{
2520-
context->indentLevel += PRETTYINDENT_STD;
25212524
appendStringInfoChar(buf, ' ');
2525+
context->indentLevel += PRETTYINDENT_STD;
25222526
}
25232527
appendStringInfo(buf, "DELETE FROM %s%s",
25242528
only_marker(rte),
25252529
generate_relation_name(rte->relid));
2530+
if (rte->alias != NULL)
2531+
appendStringInfo(buf, " %s",
2532+
quote_identifier(rte->alias->aliasname));
25262533

25272534
/* Add the USING clause if given */
25282535
get_from_clause(query, " USING ", context);

0 commit comments

Comments
 (0)