Skip site navigation (1) Skip section navigation (2)

Change in rule behavior?

From: Sergio Pili <sergiop(at)sinectis(dot)com(dot)ar>
To: pgsql-hackers(at)postgresql(dot)org, Laura Celia Rivero <lrivero(at)exa(dot)unicen(dot)edu(dot)ar>, Jorge Doorn <jdoorn(at)exa(dot)unicen(dot)edu(dot)ar>
Subject: Change in rule behavior?
Date: 2001-11-25 22:21:44
Message-ID: 3C016EF8.AB649B9F@sinectis.com.ar (view raw or flat)
Thread:
Lists: pgsql-hackers
Hello,

I need use a notify in rules with where conditions. In 7.1.3, i found a
bug and i fix it. Then I downloaded the version 7.2 to verify the bug
and to send them the patch, but the behavior had been changed.

test=# select version();
                               version
---------------------------------------------------------------------
 PostgreSQL 7.1.3 on i686-pc-linux-gnu, compiled by GCC egcs-2.91.66
(1 row)


The tables:

test=# \d rd
          Table "rd"
 Column |   Type   | Modifiers
--------+----------+-----------
 a      | smallint |
 b      | smallint |
 c      | text     |

            Table "ri"
 Column |   Type   |  Modifiers
--------+----------+--------------
 d      | smallint |
 e      | text     |
 a      | smallint | default 1000
 b      | smallint | default 2000

When i try to create the rule:

CREATE RULE upd_rd
AS ON
UPDATE TO ri
WHERE
        NEW.a IS NOT NULL 
	AND NEW.b IS NOT NULL
DO (
        notify foo;
        update rd set a=new.a,b=new.b
        where a=old.a and b=old.b;
)

the output was:

psql:sql/rd_ri/bug_upd.sql:11: pqReadData() -- backend closed the
channel unexpectedly.
        This probably means the backend terminated abnormally
        before or while processing the request.
psql:sql/rd_ri/bug_upd.sql:11: connection to server was lost


I fix it with the attached patch and the rule works well. But in 7.2b2 i
can't do it...

With the same rule, when i when I try to create it in 7.2b3 the output
was:

test=# select version();
                               version
---------------------------------------------------------------------
 PostgreSQL 7.2b3 on i686-pc-linux-gnu, compiled by GCC egcs-2.91.66
(1 row)

psql:sql/rd_ri/bug_upd.sql:11: ERROR:  Rules with WHERE conditions may
only have SELECT, INSERT, UPDATE, or DELETE actions


Why was changed?
Is it possible to maintain the previous behavior  with my correction?

Thanks in advance,
Sergio

Attachment: patch_rule.patch
Description: text/plain (756 bytes)

Responses

pgsql-hackers by date

Next:From: Sergio PiliDate: 2001-11-25 22:24:16
Subject: Bug in pg_get_ruledef?
Previous:From: Peter EisentrautDate: 2001-11-25 22:19:45
Subject: Re: RPMs and regression tests (was Re: v7.2b3 packaged...)

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group