From: | Dean Rasheed <dean(dot)a(dot)rasheed(at)gmail(dot)com> |
---|---|
To: | Andres Freund <andres(at)2ndquadrant(dot)com> |
Cc: | PostgreSQL Hackers <pgsql-hackers(at)postgresql(dot)org> |
Subject: | Re: missing locking in at least INSERT INTO view WITH CHECK |
Date: | 2013-10-23 20:20:58 |
Message-ID: | CAEZATCXZFc5_v3hjH-Zgfc24xqRSYojTKG1c6P4oe-Vwm5pLkw@mail.gmail.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-hackers |
On 23 October 2013 21:08, Andres Freund <andres(at)2ndquadrant(dot)com> wrote:
> On 2013-10-23 20:51:27 +0100, Dean Rasheed wrote:
>> On 23 October 2013 02:18, Andres Freund <andres(at)2ndquadrant(dot)com> wrote:
>> > Hi,
>> >
>> > Using the same debugging hack^Wpatch (0001) as in the matview patch
>> > (0002) an hour or so ago I noticed that INSERT INTO view WITH CHECK
>> > doesn't lock the underlying relations properly.
>> >
>> > I've attached a sort-of-working (0003) hack but I really doubt it's the
>> > correct approach, I don't really know enough about that area of the
>> > code.
>> > This looks like something that needs to be fixed.
>> >
>>
>> Hmm, my first thought is that rewriteTargetView() should be calling
>> AcquireRewriteLocks() on viewquery, before doing too much with it.
>> There may be sub-queries in viewquery's quals (and also now in its
>> targetlist) and I don't think the relations referred to by those
>> sub-queries are getting locked.
>
> Well, that wouldn't follow the currently documented rule ontop
> of QueryRewrite:
> * NOTE: the parsetree must either have come straight from the parser,
> * or have been scanned by AcquireRewriteLocks to acquire suitable locks.
>
> It might still be the right thing to do, but it seems suspicious that
> the rules need to be tweaked like that.
>
Well it matches what already happens in other places in the rewriter
--- see rewriteRuleAction() and ApplyRetrieveRule(). It's precisely
because the rule action's query hasn't come from the parser that it
needs to be processed in this way.
Regards,
Dean
From | Date | Subject | |
---|---|---|---|
Next Message | Peter Geoghegan | 2013-10-23 20:26:15 | Re: Add min and max execute statement time in pg_stat_statement |
Previous Message | Stephen Frost | 2013-10-23 20:17:53 | Re: Add min and max execute statement time in pg_stat_statement |