From: | Bhuvan A <bhuvansql(at)linuxfreemail(dot)com> |
---|---|
To: | pgsql-sql(at)postgresql(dot)org |
Subject: | Compatibility Issue of CREATE RULE in 7.2 |
Date: | 2002-05-23 05:57:04 |
Message-ID: | Pine.LNX.4.20.0205231125390.18865-100000@Larry |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-sql |
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.
From | Date | Subject | |
---|---|---|---|
Next Message | Denis | 2002-05-23 08:18:17 | Re: Further info : Very high load average but no cpu utilization ? |
Previous Message | Josh Berkus | 2002-05-22 23:48:39 | Re: Speeding up SELECT MAX(),... GROUP BY ... ? |