pg.ddx.io pgsql-sql@postgresql.org mailing list archive
help / color / mirror / Atom feedCompatibility Issue of CREATE RULE in 7.2
4+ messages / 3 participants
[nested] [flat]
* Compatibility Issue of CREATE RULE in 7.2
@ 2002-05-22 12:16 Bhuvan A <bhuvansql@yahoo.com>
0 siblings, 1 reply; 4+ messages in thread
From: Bhuvan A @ 2002-05-22 12:16 UTC (permalink / raw)
To: 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 get executed BEFORE for all the events.
But in 7.2, action get 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.
^ permalink raw reply [nested|flat] 4+ messages in thread
* Compatibility Issue of CREATE RULE in 7.2
@ 2002-05-22 12:24 Bhuvan A <bhuvansql@linuxfreemail.com>
0 siblings, 0 replies; 4+ messages in thread
From: Bhuvan A @ 2002-05-22 12:24 UTC (permalink / raw)
To: 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.
^ permalink raw reply [nested|flat] 4+ messages in thread
* Re: Compatibility Issue of CREATE RULE in 7.2
@ 2002-05-22 13:55 Tom Lane <tgl@sss.pgh.pa.us>
parent: Bhuvan A <bhuvansql@yahoo.com>
0 siblings, 0 replies; 4+ messages in thread
From: Tom Lane @ 2002-05-22 13:55 UTC (permalink / raw)
To: Bhuvan A <bhuvansql@yahoo.com>; +Cc: pgsql-sql
Bhuvan A <bhuvansql@yahoo.com> writes:
> bhuvan=# CREATE RULE rule_test_rule AS ON insert TO rule_test do
> delete from rule_test where key = new.key;
You could probably make this work by doing it in a BEFORE INSERT
trigger, instead of a rule.
regards, tom lane
^ permalink raw reply [nested|flat] 4+ messages in thread
* Compatibility Issue of CREATE RULE in 7.2
@ 2002-05-23 05:57 Bhuvan A <bhuvansql@linuxfreemail.com>
0 siblings, 0 replies; 4+ messages in thread
From: Bhuvan A @ 2002-05-23 05:57 UTC (permalink / raw)
To: 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.
^ permalink raw reply [nested|flat] 4+ messages in thread
end of thread, other threads:[~2002-05-23 05:57 UTC | newest]
Thread overview: 4+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2002-05-22 12:16 Compatibility Issue of CREATE RULE in 7.2 Bhuvan A <bhuvansql@yahoo.com>
2002-05-22 13:55 ` Tom Lane <tgl@sss.pgh.pa.us>
2002-05-22 12:24 Compatibility Issue of CREATE RULE in 7.2 Bhuvan A <bhuvansql@linuxfreemail.com>
2002-05-23 05:57 Compatibility Issue of CREATE RULE in 7.2 Bhuvan A <bhuvansql@linuxfreemail.com>
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