Thread: Bug #568: RULE ON SELECT with old values.

Bug #568: RULE ON SELECT with old values.

From
pgsql-bugs@postgresql.org
Date:
Vadim Passynkov (Vadim.Passynkov) reports a bug with a severity of 4
The lower the number the more severe it is.

Short Description
RULE ON SELECT with old values.

Long Description
# SELECT version();
                           version
--------------------------------------------------------------
 PostgreSQL 7.1.3 on i386--freebsd4.4, compiled by GCC 2.95.3

# \d  routers_password

    Table "routers_password"
 Attribute |  Type   | Modifier
-----------+---------+----------
 obj_id    | integer | not null
 userpwd   | text    |
 super     | text    |
Index: routers_password_pkey
Constraints: (userpwd !~ '[[:space:]]'::text)
             (super !~ '[[:space:]]'::text)


# CREATE RULE routers_password_test AS ON SELECT TO routers_password DO INSTEAD SELECT old.obj_id, old.userpwd,
old.super;

ERROR:  ON SELECT rule may not use OLD


From PostgreSQL Documentation:

Within the condition  and action, the special table names new and old may be used to refer to values in the referenced
table(the object). new is valid in ON INSERT and ON UPDATE rules to refer to the new row being inserted or updated. old
isvalid in ON SELECT, ON UPDATE, and ON DELETE rules to refer to the existing row being selected, updated, or deleted. 

--
Vadim Passynkov

Sample Code


No file was uploaded with this report

Re: Bug #568: RULE ON SELECT with old values.

From
Tom Lane
Date:
pgsql-bugs@postgresql.org writes:
>> From PostgreSQL Documentation:

> Within the condition  and action, the special table names new and old may be used to refer to values in the
referencedtable (the object). new is valid in ON INSERT and ON UPDATE rules to refer to the new row being inserted or
updated.old is valid in ON SELECT, ON UPDATE, and ON DELETE rules to refer to the existing row being selected, updated,
ordeleted. 

This is a documentation error.  Thanks for catching it.

            regards, tom lane