Bug #568: RULE ON SELECT with old values.

Started by PostgreSQL Bugs Listabout 24 years ago2 messagesbugs
Jump to latest
#1PostgreSQL Bugs List
pgsql-bugs@postgresql.org

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 is valid 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

#2Tom Lane
tgl@sss.pgh.pa.us
In reply to: PostgreSQL Bugs List (#1)
Re: Bug #568: RULE ON SELECT with old values.

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 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 is valid in ON SELECT, ON UPDATE, and ON DELETE rules to refer to the existing row being selected, updated, or deleted.

This is a documentation error. Thanks for catching it.

regards, tom lane