Skip site navigation (1) Skip section navigation (2)

Rule action ordering

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Jan Wieck <wieck(at)hub(dot)org>
Cc: pgsql-hackers(at)postgreSQL(dot)org
Subject: Rule action ordering
Date: 2001-07-06 18:29:03
Message-ID: 17658.994444143@sss.pgh.pa.us (view raw or flat)
Thread:
Lists: pgsql-committerspgsql-hackers
Jan Wieck <wieck(at)hub(dot)org> writes:
> 	Fire rule actions ON INSERT after original statement (if not INSTEAD).

It seems to me that this change of ordering should apply to
qual_products (ie, original statement with negation of a conditional
INSTEAD rule's condition) as well as to the unvarnished original
statement in the non-INSTEAD case.  Otherwise it's just about impossible
to give a coherent statement of what the behavior is.

However, when I tried making that change, a whole bunch of differences
popped up in the rules regression test.  They seemed to come from this
example:

create rule rtest_nothn_r1 as on insert to rtest_nothn1
	where new.a >= 10 and new.a < 20 do instead (select 1);

In the old regime, the SELECT got done before the INSERT, so psql throws
away the SELECT result and you see no output.  In the new regime, the
SELECT gets done last and you see its output.  What might be even more
confusing to newbies, you see SELECT output of zero rows when the rule's
WHERE condition fails (since the select is done anyway, but with a false
condition).

My feeling is that I should make the change and adjust the rule test's
expected output (probably by changing this rule to DO INSTEAD NOTHING).
Comments?

			regards, tom lane

In response to

pgsql-hackers by date

Next:From: Tom LaneDate: 2001-07-06 18:33:36
Subject: Re: FE/BE protocol oddity
Previous:From: Bruce MomjianDate: 2001-07-06 18:23:16
Subject: Re: pgsql/src/backend/rewrite rewriteHandler.c

pgsql-committers by date

Next:From: Bruce MomjianDate: 2001-07-06 18:52:22
Subject: Re: pgsql/src/interfaces/libpq fe-connect.c fe-exe ...
Previous:From: Bruce MomjianDate: 2001-07-06 18:23:16
Subject: Re: pgsql/src/backend/rewrite rewriteHandler.c

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group