From: | Andrew Gierth <andrew(at)tao11(dot)riddles(dot)org(dot)uk> |
---|---|
To: | Andreas Karlsson <andreas(at)proxel(dot)se> |
Cc: | Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, David Fetter <david(at)fetter(dot)org>, Thomas Munro <thomas(dot)munro(at)enterprisedb(dot)com>, Pg Hackers <pgsql-hackers(at)postgresql(dot)org> |
Subject: | Re: Early WIP/PoC for inlining CTEs |
Date: | 2019-01-01 02:18:31 |
Message-ID: | 87r2dxrw1z.fsf@news-spur.riddles.org.uk |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | Postg사설 토토 사이트SQL |
>>>>> "Andreas" == Andreas Karlsson <andreas(at)proxel(dot)se> writes:
Andreas> + if (rte->rtekind == RTE_CTE &&
Andreas> + strcmp(rte->ctename, context->ctename) == 0 &&
Andreas> + rte->ctelevelsup == context->levelsup)
Andreas> + {
Andreas> + Query *newquery = copyObject(context->ctequery);
Andreas> +
Andreas> + /* Preserve outer references, for example to other CTEs */
Andreas> + if (context->levelsup > 0)
Andreas> + IncrementVarSublevelsUp((Node *) newquery, context->levelsup, 1);
I had a comment around here which seems to have been lost:
* Secondly, views (and explicit subqueries) currently have
* different behaviour w.r.t. SELECT FOR UPDATE than CTEs do. A
* FOR UPDATE clause is treated as extending into views and
* subqueries, but not into CTEs. We preserve this distinction
* by not trying to push rowmarks into the new subquery.
This comment seems to me to be worth preserving (unless this behavior is
changed). What I'm referring to is the following, which is unchanged by
the patch:
create table t1 as select 123 as a;
create view v1 as select * from t1;
select * from t1 for update; -- locks row in t1
select * from t1 for update of t1; -- locks row in t1
select * from v1 for update; -- locks row in t1
select * from v1 for update of v1; -- locks row in t1
select * from (select * from t1) s1 for update; -- locks row in t1
select * from (select * from t1) s1 for update of s1; -- locks row in t1
with c1 as (select * from t1)
select * from c1 for update; -- does NOT lock anything at all
with c1 as (select * from t1)
select * from c1 for update of c1; -- parse-time error
(Obviously, inlining decisions should not change what gets locked;
the behavior here should not be changed unless it is changed for both
inlined and non-inlined CTEs.)
--
Andrew (irc:RhodiumToad)
From | Date | Subject | |
---|---|---|---|
Next Message | Michael Paquier | 2019-01-01 02:24:11 | Re: [PATCH] check for ctags utility in make_ctags |
Previous Message | Michael Paquier | 2019-01-01 01:55:18 | Re: Removing --disable-strong-random from the code |