Re: Rules puzzle with "current" keyword.

From: wieck(at)debis(dot)com (Jan Wieck)
To: emkxp01(at)mtcc(dot)demon(dot)co(dot)uk
Cc: hackers(at)postgreSQL(dot)org, jwieck(at)debis(dot)com, lockhart(at)alumni(dot)caltech(dot)edu
Subject: Re: Rules puzzle with "current" keyword.
Date: 1999-06-02 10:11:27
Message-ID: m10p7zb-0003kGC@orion.SAPserv.Hamburg.dsh.de
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: 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?

Sure - I'm the one who added OLD to v6.4 and removed CURRENT
from v6.5. I think it was announced in the release notes for
v6.4 that CURRENT will disappear in v6.5.

Seems I missed that change myself in the utilities that make
up pg_views and pg_rules.

Anyway - OLD is the correct keyword in your case. I'll take
a look at it - thanks.

Jan

--

#======================================================================#
# It's easier to get forgiveness for being wrong than for being right. #
# Let's break this rule - forgive me. #
#======================================== jwieck(at)debis(dot)com (Jan Wieck) #

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Massimo Dal Zotto 1999-06-02 10:23:47 Re: [HACKERS] nonblocking lock?
Previous Message Jan Wieck 1999-06-02 10:05:48 Re: [HACKERS] Re: [SQL] Column name's length