aboutsummaryrefslogtreecommitdiff
path: root/src/backend/utils/adt/ruleutils.c
diff options
context:
space:
mode:
authorTom Lane <tgl@sss.pgh.pa.us>2006-04-30 18:30:40 +0000
committerTom Lane <tgl@sss.pgh.pa.us>2006-04-30 18:30:40 +0000
commit986085a7f08c72219abf47f8b968213e81ab943c (patch)
treea80d30e59cffd042ed9adb024afc5f5d6bf00e16 /src/backend/utils/adt/ruleutils.c
parent931bfc96644b8f51a49161f780d43506e55d2b13 (diff)
downloadpostgresql-986085a7f08c72219abf47f8b968213e81ab943c.tar.gz
postgresql-986085a7f08c72219abf47f8b968213e81ab943c.zip
Improve the representation of FOR UPDATE/FOR SHARE so that we can
support both FOR UPDATE and FOR SHARE in one command, as well as both NOWAIT and normal WAIT behavior. The more general code is actually simpler and cleaner.
Diffstat (limited to 'src/backend/utils/adt/ruleutils.c')
-rw-r--r--src/backend/utils/adt/ruleutils.c30
1 files changed, 12 insertions, 18 deletions
diff --git a/src/backend/utils/adt/ruleutils.c b/src/backend/utils/adt/ruleutils.c
index c0db64bf896..67897a2938a 100644
--- a/src/backend/utils/adt/ruleutils.c
+++ b/src/backend/utils/adt/ruleutils.c
@@ -2,7 +2,7 @@
* ruleutils.c - Functions to convert stored expressions/querytrees
* back to source text
*
- * $PostgreSQL: pgsql/src/backend/utils/adt/ruleutils.c,v 1.220 2006/04/22 01:26:00 tgl Exp $
+ * $PostgreSQL: pgsql/src/backend/utils/adt/ruleutils.c,v 1.221 2006/04/30 18:30:40 tgl Exp $
**********************************************************************/
#include "postgres.h"
@@ -1858,27 +1858,21 @@ get_select_query_def(Query *query, deparse_context *context,
get_rule_expr(query->limitCount, context, false);
}
- /* Add the FOR UPDATE/SHARE clause if present */
- if (query->rowMarks != NIL)
+ /* Add FOR UPDATE/SHARE clauses if present */
+ foreach(l, query->rowMarks)
{
- if (query->forUpdate)
- appendContextKeyword(context, " FOR UPDATE OF ",
+ RowMarkClause *rc = (RowMarkClause *) lfirst(l);
+ RangeTblEntry *rte = rt_fetch(rc->rti, query->rtable);
+
+ if (rc->forUpdate)
+ appendContextKeyword(context, " FOR UPDATE",
-PRETTYINDENT_STD, PRETTYINDENT_STD, 0);
else
- appendContextKeyword(context, " FOR SHARE OF ",
+ appendContextKeyword(context, " FOR SHARE",
-PRETTYINDENT_STD, PRETTYINDENT_STD, 0);
- sep = "";
- foreach(l, query->rowMarks)
- {
- int rtindex = lfirst_int(l);
- RangeTblEntry *rte = rt_fetch(rtindex, query->rtable);
-
- appendStringInfo(buf, "%s%s",
- sep,
- quote_identifier(rte->eref->aliasname));
- sep = ", ";
- }
- if (query->rowNoWait)
+ appendStringInfo(buf, " OF %s",
+ quote_identifier(rte->eref->aliasname));
+ if (rc->noWait)
appendStringInfo(buf, " NOWAIT");
}
}