pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Bhuvan A <bhuvansql@linuxfreemail.com>
To: pgsql-sql@postgresql.org
Subject: Compatibility Issue of CREATE RULE in 7.2
Date: Wed, 22 May 2002 17:54:53 +0530 (IST)
Message-ID: <Pine.LNX.4.20.0205221750480.31195-100000@Larry> (raw)

hi,

Recently, i have migrated from 7.1.2 to 7.2. Here found a problem in
7.2 while using RULEs.

In 7.1.2, action of the rules gets executed BEFORE for all the events.  
But in 7.2, action gets executed BEFORE for INSERT alone and AFTER for
all other events.

In 7.1.2,

bhuvan=# CREATE TABLE rule_test (key text, value text);
CREATE
bhuvan=# CREATE RULE rule_test_rule AS ON insert TO rule_test do
delete from rule_test where key = new.key;
CREATE
bhuvan=# INSERT INTO rule_test values ('key', 'oldvalue');
INSERT 22317402 1
bhuvan=# SELECT * from rule_test ;
 key |  value
-----+----------
 key | oldvalue
(1 row)

bhuvan=# INSERT INTO rule_test values ('key', 'newvalue');
INSERT 22317403 1
bhuvan=# SELECT * from rule_test ;
 key |  value
-----+----------
 key | newvalue
(1 row)

bhuvan=#
// since the rule has been executed BEFORE INSERT

But in 7.2,

// the same results in deleting 2 records :) 
// since the rule gets executed AFTER INSERT.

So would like to know an alternate way to fix this problem. Since i
wont like checking for existence of the key and do insert or update
accordingly, everytime from my code.

Hope there would be some lights on to solve this problem.

regards,
bhuvaneswaran.





view thread (4+ messages)  latest in thread

Message-ID: <Pine.LNX.4.20.0205221750480.31195-100000@Larry>
Permalink:  ../Pine.LNX.4.20.0205221750480.31195-100000@Larry/
Also on:    postgresql.org/message-id/Pine.LNX.4.20.0205221750480.31195-100000@Larry

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-sql@postgresql.org
  Cc: bhuvansql@linuxfreemail.com
  Subject: Re: Compatibility Issue of CREATE RULE in 7.2
  In-Reply-To: <Pine.LNX.4.20.0205221750480.31195-100000@Larry>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox