Re: "ON INSERT rule may not use OLD" on simple query

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Brandon Craig Rhodes <brandon(at)oit(dot)gatech(dot)edu>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: "ON INSERT rule may not use OLD" on simple query
Date: 2003-02-11 04:19:39
Message-ID: 21805.1044937179@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Brandon Craig Rhodes <brandon(at)oit(dot)gatech(dot)edu> writes:
> Postgresql 7.3.2 gives the error "ON INSERT rule may not use OLD" when
> trying to define the following rule:

Hm, I guess no one's tried to use UNION/INTERSECT/EXCEPT in ON INSERT
rules lately :-(

I've applied the attached patch, which seems to fix this problem without
introducing any new ones (leftmostRTI is one anyway in the better-tested
cases). There may be some other issues lurking in this general area,
though...

Thanks for the report! (BTW, CVS tip has some code in it to address
your outer-join optimization complaint of a couple months back.)

regards, tom lane

*** src/backend/parser/analyze.c.orig Mon Oct 21 18:06:19 2002
--- src/backend/parser/analyze.c Mon Feb 10 22:59:32 2003
***************
*** 1796,1801 ****
--- 1796,1806 ----
* leftmost select and common datatypes of topmost set operation. Also
* make lists of the dummy vars and their names for use in parsing
* ORDER BY.
+ *
+ * Note: we use leftmostRTI as the varno of the dummy variables.
+ * It shouldn't matter too much which RT index they have, as long
+ * as they have one that corresponds to a real RT entry; else funny
+ * things may happen when the tree is mashed by rule rewriting.
*/
qry->targetList = NIL;
targetvars = NIL;
***************
*** 1814,1820 ****
-1,
colName,
false);
! expr = (Node *) makeVar(1,
leftResdom->resno,
colType,
-1,
--- 1819,1825 ----
-1,
colName,
false);
! expr = (Node *) makeVar(leftmostRTI,
leftResdom->resno,
colType,
-1,

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Shridhar Daithankar 2003-02-11 07:08:10 Re: PostgreSQL x Oracle
Previous Message Nigel J. Andrews 2003-02-11 01:26:40 Re: PostgreSQL x Oracle