Rules and locking within a transaction?... - Mailing list pgsql-general

From Net Virtual Mailing Lists
Subject Rules and locking within a transaction?...
Date
Msg-id 20041009235017.25998@mail.e-na.net
Whole thread Raw
Responses Tsearch2 trigger firing...
List pgsql-general
Hello,

If I have a rule like this:


CREATE OR REPLACE RULE sometable_update AS ON UPDATE TO table2 DO UPDATE
cache SET updated_dt=NULL WHERE tablename='sometable';
CREATE OR REPLACE RULE sometable_insert AS ON INSERT TO table2 DO UPDATE
cache SET updated_dt=NULL WHERE tablename='sometable';
CREATE OR REPLACE RULE sometable_delete AS ON DELETE TO table2 DO UPDATE
cache SET updated_dt=NULL WHERE tablename='sometable';


Then I begin inserting a bunch of records within a transaction into
table2, like this:


BEGIN;
INSERT INTO table2 (val1, val2) VALUES ('hello','world');
...(etc)
COMMIT;

...  It appears that there is a row lock in cache table for the duration
of the transaction....

First of all, is my premise correct or is there some hidden problem I'm
not seeing?...

Secondly, if there is no hidden problem, is there some way (short of
dropping and recreating the rule) to make it not perform the row lock and
execute the rule at the end of the transaction (if the transaction
succeeds of course)?...

Thanks!

- Greg




pgsql-general by date:

Previous
From: Bernard Clement
Date:
Subject: Re: install problem
Next
From: "David Parker"
Date:
Subject: external function libraries on non-build machine