Re: BUG #1533: "*OLD*" relation not recognized in CREATE RULE

Lists: pgsql-bugs
From: "Henk van den Toorn" <vdtoorn(at)hotmail(dot)com>
To: pgsql-bugs(at)postgresql(dot)org
Subject: BUG #1533: "*OLD*" relation not recognized in CREATE RULE
Date: 2005-03-10 09:38:32
Message-ID: 20050310093832.97FEAF115C@svr2.postgresql.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-bugs


The following bug has been logged online:

Bug reference: 1533
Logged by: Henk van den Toorn
Email address: vdtoorn(at)hotmail(dot)com
PostgreSQL version: 7.4.3-7
Operating system: Freebsd 5.3
Description: "*OLD*" relation not recognized in CREATE RULE
Details:

When creating a rule:

CREATE RULE rulename AS ON UPDATE
table WHERE OLD.index = NEW.index
DO INSTEAD NOTHING;

Postgresql responds with

ERROR: relation "*OLD*" does not exist

All kind of variations on "*OLD*"
like:

old.index; OLD.index; "*OLD*".index

do not work, nor does changing the order of the elements in the WHERE
clause.


From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: "Henk van den Toorn" <vdtoorn(at)hotmail(dot)com>
Cc: pgsql-bugs(at)postgresql(dot)org
Subject: Re: BUG #1533: "*OLD*" relation not recognized in CREATE RULE
Date: 2005-03-14 05:53:16
Message-ID: 5251.1110779596@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-bugs

"Henk van den Toorn" <vdtoorn(at)hotmail(dot)com> writes:
> CREATE RULE rulename AS ON UPDATE
> table WHERE OLD.index = NEW.index
> DO INSTEAD NOTHING;

> Postgresql responds with

> ERROR: relation "*OLD*" does not exist

Hm, works for me:

regression=# create table tab1 (index serial primary key, data text);
NOTICE: CREATE TABLE will create implicit sequence "tab1_index_seq" for "serial" column "tab1.index"
NOTICE: CREATE TABLE / PRIMARY KEY will create implicit index "tab1_pkey" for table "tab1"
CREATE TABLE
regression=# create rule r as on update to tab1 where old.index = new.index do instead nothing;
CREATE RULE
regression=# select version();
version
---------------------------------------------------------------
PostgreSQL 7.4.7 on hppa-hp-hpux10.20, compiled by GCC 2.95.3
(1 row)

regards, tom lane