ALTER TABLE DISABLE RULE does not work inside of a transaction

Started by Alex Hunsakerover 17 years ago3 messagesbugs
Jump to latest
#1Alex Hunsaker
badalex@gmail.com

Namely it does not disable the rule... Enabling inside of the
transaction seems to work though

Tried both CVS and 8.3.5...

create table trule (a int);
insert into trule (a) values (1);
create rule trule_rule as on update to trule do instead nothing;

update trule set a = 2;
UPDATE 0

begin;
ALTER TABLE trule DISABLE RULE trule_rule;
update trule set a = 2;
UPDATE 0

\d trule
Table "public.trule"
Column | Type | Modifiers
--------+---------+-----------
a | integer |
Disabled rules:
trule_rule AS
ON UPDATE TO trule DO INSTEAD NOTHING

rollback;

ALTER TABLE trule DISABLE RULE trule_rule;
update trule set a = 2;
UPDATE 1

#2Alex Hunsaker
badalex@gmail.com
In reply to: Alex Hunsaker (#1)
Re: ALTER TABLE DISABLE RULE does not work inside of a transaction

On Mon, Dec 29, 2008 at 15:07, Alex Hunsaker <badalex@gmail.com> wrote:

Namely it does not disable the rule...

Enabling inside of the transaction seems to work though

Hrm the above turned out to be false... must have gotten confused when
testing with triggers

If i turn on RELCACHE_FORCE_RELEASE or CLOBBER_CACHE_ALWAYS then it
works as expected. Maybe this will make someone who understands the
relcache stuff better go Ahh ha!

#3Tom Lane
tgl@sss.pgh.pa.us
In reply to: Alex Hunsaker (#1)
Re: ALTER TABLE DISABLE RULE does not work inside of a transaction

"Alex Hunsaker" <badalex@gmail.com> writes:

Namely it does not disable the rule... Enabling inside of the
transaction seems to work though

Fixed, thanks ...

Index: relcache.c
===================================================================
RCS file: /cvsroot/pgsql/src/backend/utils/cache/relcache.c,v
retrieving revision 1.266.2.4
diff -c -r1.266.2.4 relcache.c
*** relcache.c	10 Aug 2008 19:02:46 -0000	1.266.2.4
--- relcache.c	30 Dec 2008 03:53:15 -0000
***************
*** 770,775 ****
--- 770,777 ----
  				return false;
  			if (rule1->attrno != rule2->attrno)
  				return false;
+ 			if (rule1->enabled != rule2->enabled)
+ 				return false;
  			if (rule1->isInstead != rule2->isInstead)
  				return false;
  			if (!equal(rule1->qual, rule2->qual))

regards, tom lane