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

Re: Proof of concept: auto updatable views [Review of Patch]

From: Dean Rasheed <dean(dot)a(dot)rasheed(at)gmail(dot)com>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: Peter Eisentraut <peter_e(at)gmx(dot)net>, Amit kapila <amit(dot)kapila(at)huawei(dot)com>, "robertmhaas(at)gmail(dot)com" <robertmhaas(at)gmail(dot)com>, "pgsql-hackers(at)postgresql(dot)org" <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: Proof of concept: auto updatable views [Review of Patch]
Date: 2012-11-08 00:30:03
Message-ID: (view raw, whole thread or download thread mbox)
Lists: pgsql-hackers
On 7 November 2012 22:04, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> wrote:
> Dean Rasheed <dean(dot)a(dot)rasheed(at)gmail(dot)com> writes:
>> Thanks for looking at this.
>> Attached is a rebased patch using new OIDs.
> I'm starting to look at this patch now.  I don't understand the intended
> interaction with qualified INSTEAD rules.  The code looks like
> +               if (!instead && rt_entry_relation->rd_rel->relkind == RELKIND_VIEW)
> +               {
> +                       Query  *query = qual_product ? qual_product : parsetree;
> +                       Query  *newquery = rewriteTargetView(query, rt_entry_relation);
> which has the effect that if there's a qualified INSTEAD rule, we'll
> apply the substitution transformation to the
> modified-by-addition-of-negated-qual query (ie, qual_product).

Yes that's what I was aiming for. I thought that if the rule's
qualifier isn't satisfied and the rule isn't fired, it should attempt
to go ahead with the view update. This might result in an INSTEAD OF
trigger firing, substitution of the base relation, or an error being

> This seems to me to be dangerous and unintuitive, not to mention
> underdocumented.  I think it would be better to just not do anything if
> there is any INSTEAD rule, period.  (I don't see any problem with DO
> ALSO rules, though, since they don't affect the behavior of the original
> query.)

Is this any more dangerous than what already happens with qualified rules?

If we did nothing here then it would go on to either fire any INSTEAD
OF triggers or raise an error if there aren't any. The problem with
that is that it makes trigger-updatable views and auto-updatable views
inconsistent in their behaviour with qualified INSTEAD rules. I don't
think the existing interaction between trigger-updatable views and
qualified INSTEAD rules is documented, so perhaps that's something
that needs work.


In response to


pgsql-hackers by date

Next:From: Josh BerkusDate: 2012-11-08 00:55:02
Subject: Re: auto_explain WAS: RFC: Timing Events
Previous:From: Greg SmithDate: 2012-11-07 23:54:15
Subject: Re: Proposal for Allow postgresql.conf values to be changed via SQL

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