Fix longstanding oversight in ruleutils.c: it doesn't regurgitate
authorTom Lane <tgl@sss.pgh.pa.us>
Mon, 30 May 2005 01:57:27 +0000 (01:57 +0000)
committerTom Lane <tgl@sss.pgh.pa.us>
Mon, 30 May 2005 01:57:27 +0000 (01:57 +0000)
a FOR UPDATE clause, if one is present.

src/backend/utils/adt/ruleutils.c

index 56813eec39dbcd190c4cd3c65de462dba5d9858b..d10459a9bfe07b9226136a5595298b0c407e0559 100644 (file)
@@ -3,7 +3,7 @@
  *             back to source text
  *
  * IDENTIFICATION
- *   $PostgreSQL: pgsql/src/backend/utils/adt/ruleutils.c,v 1.196 2005/05/27 00:57:49 neilc Exp $
+ *   $PostgreSQL: pgsql/src/backend/utils/adt/ruleutils.c,v 1.197 2005/05/30 01:57:27 tgl Exp $
  *
  *   This software is copyrighted by Jan Wieck - Hamburg.
  *
@@ -1919,6 +1919,28 @@ get_select_query_def(Query *query, deparse_context *context,
        else
            get_rule_expr(query->limitCount, context, false);
    }
+
+   /* Add the FOR UPDATE/SHARE clause if present */
+   if (query->rowMarks != NIL)
+   {
+       if (query->forUpdate)
+           appendContextKeyword(context, " FOR UPDATE OF ",
+                                -PRETTYINDENT_STD, PRETTYINDENT_STD, 0);
+       else
+           appendContextKeyword(context, " FOR SHARE OF ",
+                                -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 = ", ";
+       }
+   }
 }
 
 static void