Rules puzzle with "current" keyword. - Mailing list pgsql-hackers

From Keith Parks
Subject Rules puzzle with "current" keyword.
Date
Msg-id 199906020933.KAA27740@mtcc.demon.co.uk
Whole thread Raw
Responses Re: Rules puzzle with "current" keyword.
List pgsql-hackers
Hi,

Looking at a previous bug report I noticed a strange behaviour
in rule creation and display.


postgres=> CREATE RULE rule1 AS ON UPDATE TO test1 DO INSERT INTO test2 SELECT * FROM
postgres-> test1 WHERE oid=current.oid;
ERROR:  current: Table does not exist.

Above we do not recognise "current" as a special case.

If I substitute "old" for "current" the definition is accepted.

postgres=> CREATE RULE rule1 AS ON UPDATE TO test1 DO INSERT INTO test2 SELECT * FROM
postgres-> test1 WHERE oid=old.oid;
CREATE

Things get spooky when pg_rules shows the keyword "current" where I said "old".

postgres=> select * from pg_rules where rulename like '%rule1%';
tablename|rulename|definition
   
 

---------+--------+------------------------------------------------------------------------------------------------------------------
-----------------------------------------
test1    |rule1   |CREATE RULE "rule1" AS ON UPDATE TO "test1" DO INSERT INTO "test2" ("field1", "field2") SELECT
"field1","field2" 
 
FROM "test1" WHERE "oid" = current."oid";
(1 row)

It could be that just the parser and rule decoder are out of step?

I'm not sure which is correct now "old" or "current", anyone care to comment?

Keith.



pgsql-hackers by date:

Previous
From: Vadim Mikheev
Date:
Subject: Re: [HACKERS] Re: [SQL] Column name's length
Next
From: Thierry Holtzer
Date:
Subject: 6.4.2/AIX: syslog support seems alright ?