Bug #568: RULE ON SELECT with old values.

Поиск
Список
Период
Сортировка
Искать

Bug #568: RULE ON SELECT with old values.

От:
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

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

От:
Tom Lane <tgl@sss.pgh.pa.us>
Дата:
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
FAQ