From: | Dean Rasheed <dean(dot)a(dot)rasheed(at)gmail(dot)com> |
---|---|
To: | Andres Freund <andres(at)anarazel(dot)de> |
Cc: | PostgreSQL Hackers <pgsql-hackers(at)postgresql(dot)org> |
Subject: | Re: missing locking in at least INSERT INTO view WITH CHECK |
Date: | 2015-08-27 17:37:10 |
Message-ID: | CAEZATCX8Orge-Rai1ZNyn1SbVqp_ihu3eLKwoSw2iVzgv1UsZA@mail.gmail.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-hackers |
On 27 August 2015 at 12:18, Andres Freund <andres(at)anarazel(dot)de> wrote:
> On 2013-10-24 20:58:55 +0100, Dean Rasheed wrote:
>> So I
>> think the only thing missing from rewriteTargetView() is to lock any
>> relations from any sublink subqueries in viewquery using
>> acquireLocksOnSubLinks() -- patch attached.
>
> This is still an open problem :(
>
Oh yes, I forgot to follow up on this.
>> diff --git a/src/backend/rewrite/rewriteHandler.c b/src/backend/rewrite/rewriteHandler.c
>> new file mode 100644
>> index c52a374..e6a9e7b
>> *** a/src/backend/rewrite/rewriteHandler.c
>> --- b/src/backend/rewrite/rewriteHandler.c
>> *************** rewriteTargetView(Query *parsetree, Rela
>> *** 2589,2594 ****
>> --- 2589,2604 ----
>> heap_close(base_rel, NoLock);
>>
>> /*
>> + * If the view query contains any sublink subqueries, we should also
>> + * acquire locks on any relations they refer to. We know that there won't
>> + * be any subqueries in the range table or CTEs, so we can skip those, as
>> + * in AcquireRewriteLocks.
>> + */
>> + if (viewquery->hasSubLinks)
>> + query_tree_walker(viewquery, acquireLocksOnSubLinks, NULL,
>> + QTW_IGNORE_RC_SUBQUERIES);
>> +
>> + /*
>> * Create a new target RTE describing the base relation, and add it to the
>> * outer query's rangetable. (What's happening in the next few steps is
>> * very much like what the planner would do to "pull up" the view into the
>
> These days this seems to require a context parameter being passed
> down. Other than that this patch still fixes the problem.
>
Yes, I concur. It now needs an acquireLocksOnSubLinks_context with
for_execute = true, but otherwise it should work.
I have a feeling that RLS might suffer from the same issue, but I
haven't looked yet.
Regards,
Dean
From | Date | Subject | |
---|---|---|---|
Next Message | Andres Freund | 2015-08-27 17:44:16 | Re: missing locking in at least INSERT INTO view WITH CHECK |
Previous Message | Bruce Momjian | 2015-08-27 17:12:44 | Re: [COMMITTERS] pgsql: psql: show proper row count in \x mode for zero-column output |