Skip to content

Commit 0832fb7

Browse files
committed
Fix longstanding oversight in ruleutils.c: it doesn't regurgitate
a FOR UPDATE clause, if one is present.
1 parent cfd9be9 commit 0832fb7

File tree

1 file changed

+23
-1
lines changed

1 file changed

+23
-1
lines changed

src/backend/utils/adt/ruleutils.c

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
* back to source text
44
*
55
* IDENTIFICATION
6-
* $PostgreSQL: pgsql/src/backend/utils/adt/ruleutils.c,v 1.196 2005/05/27 00:57:49 neilc Exp $
6+
* $PostgreSQL: pgsql/src/backend/utils/adt/ruleutils.c,v 1.197 2005/05/30 01:57:27 tgl Exp $
77
*
88
* This software is copyrighted by Jan Wieck - Hamburg.
99
*
@@ -1919,6 +1919,28 @@ get_select_query_def(Query *query, deparse_context *context,
19191919
else
19201920
get_rule_expr(query->limitCount, context, false);
19211921
}
1922+
1923+
/* Add the FOR UPDATE/SHARE clause if present */
1924+
if (query->rowMarks != NIL)
1925+
{
1926+
if (query->forUpdate)
1927+
appendContextKeyword(context, " FOR UPDATE OF ",
1928+
-PRETTYINDENT_STD, PRETTYINDENT_STD, 0);
1929+
else
1930+
appendContextKeyword(context, " FOR SHARE OF ",
1931+
-PRETTYINDENT_STD, PRETTYINDENT_STD, 0);
1932+
sep = "";
1933+
foreach(l, query->rowMarks)
1934+
{
1935+
int rtindex = lfirst_int(l);
1936+
RangeTblEntry *rte = rt_fetch(rtindex, query->rtable);
1937+
1938+
appendStringInfo(buf, "%s%s",
1939+
sep,
1940+
quote_identifier(rte->eref->aliasname));
1941+
sep = ", ";
1942+
}
1943+
}
19221944
}
19231945

19241946
static void

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy