]> granicus.if.org Git - postgresql/commitdiff
Fix breakage of rules using NOTIFY actions, per bug report and patch
authorTom Lane <tgl@sss.pgh.pa.us>
Wed, 3 Jan 2001 22:01:05 +0000 (22:01 +0000)
committerTom Lane <tgl@sss.pgh.pa.us>
Wed, 3 Jan 2001 22:01:05 +0000 (22:01 +0000)
from sergiop@sinectis.com.ar.

src/backend/rewrite/rewriteHandler.c
src/backend/utils/adt/ruleutils.c

index 753475aa820889eb877d16b16a2f2cb13b4f58cb..9b54fcd33fef6c285a4441665d7328fb189ac276 100644 (file)
@@ -7,7 +7,7 @@
  *
  *
  * IDENTIFICATION
- *       $Header: /cvsroot/pgsql/src/backend/rewrite/rewriteHandler.c,v 1.86 2000/12/07 01:22:25 tgl Exp $
+ *       $Header: /cvsroot/pgsql/src/backend/rewrite/rewriteHandler.c,v 1.87 2001/01/03 22:01:05 tgl Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -124,6 +124,7 @@ gatherRewriteMeta(Query *parsetree,
         * Note that if the rule refers to OLD, its jointree will add back
         * a reference to rt_index.
         */
+       if (sub_action->jointree != NULL)
        {
                bool    found;
                List   *newjointree = adjustJoinTreeList(parsetree,
index 99818c324acf170c2b854431735016a128d880da..3f9264308dd28b3443ac459f6ce78698b8b31099 100644 (file)
@@ -3,7 +3,7 @@
  *                             back to source text
  *
  * IDENTIFICATION
- *       $Header: /cvsroot/pgsql/src/backend/utils/adt/ruleutils.c,v 1.70 2000/11/18 04:40:18 tgl Exp $
+ *       $Header: /cvsroot/pgsql/src/backend/utils/adt/ruleutils.c,v 1.71 2001/01/03 22:01:05 tgl Exp $
  *
  *       This software is copyrighted by Jan Wieck - Hamburg.
  *
@@ -97,6 +97,7 @@ static void get_select_query_def(Query *query, deparse_context *context);
 static void get_insert_query_def(Query *query, deparse_context *context);
 static void get_update_query_def(Query *query, deparse_context *context);
 static void get_delete_query_def(Query *query, deparse_context *context);
+static void get_utility_query_def(Query *query, deparse_context *context);
 static void get_basic_select_query(Query *query, deparse_context *context);
 static void get_setop_query(Node *setOp, Query *query,
                                                        deparse_context *context, bool toplevel);
@@ -874,6 +875,10 @@ get_query_def(Query *query, StringInfo buf, List *parentrtables)
                        appendStringInfo(buf, "NOTHING");
                        break;
 
+               case CMD_UTILITY:
+                       get_utility_query_def(query, &context);
+                       break;
+
                default:
                        elog(ERROR, "get_ruledef of %s: query command type %d not implemented yet",
                                 rulename, query->commandType);
@@ -1310,6 +1315,26 @@ get_delete_query_def(Query *query, deparse_context *context)
        }
 }
 
+
+/* ----------
+ * get_utility_query_def                       - Parse back a UTILITY parsetree
+ * ----------
+ */
+static void
+get_utility_query_def(Query *query, deparse_context *context)
+{
+       StringInfo      buf = context->buf;
+
+       if (query->utilityStmt && IsA(query->utilityStmt, NotifyStmt))
+       {
+               NotifyStmt *stmt = (NotifyStmt *) query->utilityStmt;
+               appendStringInfo(buf, "NOTIFY %s", quote_identifier(stmt->relname));
+       }
+       else
+               elog(ERROR, "get_utility_query_def: unexpected statement type");
+}
+
+
 /*
  * Find the RTE referenced by a (possibly nonlocal) Var.
  */