Re: Bug in pg_get_ruledef? - Mailing list pgsql-hackers

From Tom Lane
Subject Re: Bug in pg_get_ruledef?
Date
Msg-id 6963.1006734659@sss.pgh.pa.us
Whole thread Raw
In response to Bug in pg_get_ruledef?  (Sergio Pili <sergiop@sinectis.com.ar>)
List pgsql-hackers
Sergio Pili <sergiop@sinectis.com.ar> writes:
> pg_get_ruledef cannot read the following rule:

Fix committed --- many thanks for the report!

Attached is the patch against current sources, if you need it.
        regards, tom lane


*** src/backend/utils/adt/ruleutils.c.orig    Mon Nov 19 14:51:20 2001
--- src/backend/utils/adt/ruleutils.c    Sun Nov 25 19:18:32 2001
***************
*** 769,775 ****
--- 769,788 ----         appendStringInfo(buf, " WHERE ");          qual = stringToNode(ev_qual);
+ 
+         /*
+          * We need to make a context for recognizing any Vars in the qual
+          * (which can only be references to OLD and NEW).  Use the rtable
+          * of the first query in the action list for this purpose.
+          */         query = (Query *) lfirst(actions);
+ 
+         /*
+          * If the action is INSERT...SELECT, OLD/NEW have been pushed
+          * down into the SELECT, and that's what we need to look at.
+          * (Ugly kluge ... try to fix this when we redesign querytrees.)
+          */
+         query = getInsertSelectQuery(query, NULL);          context.buf = buf;         context.namespaces =
makeList1(&dpns);


pgsql-hackers by date:

Previous
From: Hiroshi Inoue
Date:
Subject: Re: pg_config.h.win32
Next
From: Bruce Momjian
Date:
Subject: Re: Call for objections: deprecate postmaster -o switch?