Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitadaf342

Browse files
committed
Improve ruleutils' printout of LATERAL references within subplans.
Commit1cc29fe, which taught EXPLAIN to print PARAM_EXEC Params asthe referenced expressions, included some checks to prevent matchingParams found in SubPlans or InitPlans to NestLoopParams of upper querylevels. At the time, this seemed possibly necessary to avoid falsematches because of the planner's habit of re-using the same PARAM_EXECslot in multiple places in a plan. Furthermore, in the absence ofLATERAL no such reference could be valid anyway. But it's possiblenow that we have LATERAL, and in the wake of46c508f and1db5667I believe the false-match hazard is gone. Hence, remove thein_same_plan_level checks. As shown in the regression test changes,this provides a useful improvement in readability for EXPLAIN ofLATERAL-using subplans.Richard Guo, reviewed by Greg Stark and myselfDiscussion:https://postgr.es/m/CAMbWs4-YSOcQXAagJetP95cAeZPqzOy5kM5yijG0PVW5ztRb4w@mail.gmail.com
1 parent5db195f commitadaf342

File tree

3 files changed

+9
-34
lines changed

3 files changed

+9
-34
lines changed

‎src/backend/utils/adt/ruleutils.c

Lines changed: 4 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -7896,26 +7896,21 @@ find_param_referent(Param *param, deparse_context *context,
78967896
{
78977897
deparse_namespace*dpns;
78987898
Plan*child_plan;
7899-
boolin_same_plan_level;
79007899
ListCell*lc;
79017900

79027901
dpns= (deparse_namespace*)linitial(context->namespaces);
79037902
child_plan=dpns->plan;
7904-
in_same_plan_level= true;
79057903

79067904
foreach(lc,dpns->ancestors)
79077905
{
79087906
Node*ancestor= (Node*)lfirst(lc);
79097907
ListCell*lc2;
79107908

79117909
/*
7912-
* NestLoops transmit params to their inner child only; also, once
7913-
* we've crawled up out of a subplan, this couldn't possibly be
7914-
* the right match.
7910+
* NestLoops transmit params to their inner child only.
79157911
*/
79167912
if (IsA(ancestor,NestLoop)&&
7917-
child_plan==innerPlan(ancestor)&&
7918-
in_same_plan_level)
7913+
child_plan==innerPlan(ancestor))
79197914
{
79207915
NestLoop*nl= (NestLoop*)ancestor;
79217916

@@ -7973,34 +7968,14 @@ find_param_referent(Param *param, deparse_context *context,
79737968
}
79747969
}
79757970

7976-
/* We have emerged from a subplan. */
7977-
in_same_plan_level= false;
7978-
79797971
/* SubPlan isn't a kind of Plan, so skip the rest */
79807972
continue;
79817973
}
79827974

79837975
/*
7984-
* Check to see if we're emerging from an initplan of the current
7985-
* ancestor plan. Initplans never have any parParams, so no need
7986-
* to search that list, but we need to know if we should reset
7987-
* in_same_plan_level.
7976+
* We need not consider the ancestor's initPlan list, since
7977+
* initplans never have any parParams.
79887978
*/
7989-
foreach(lc2, ((Plan*)ancestor)->initPlan)
7990-
{
7991-
SubPlan*subplan=lfirst_node(SubPlan,lc2);
7992-
7993-
if (child_plan!= (Plan*)list_nth(dpns->subplans,
7994-
subplan->plan_id-1))
7995-
continue;
7996-
7997-
/* No parameters to be had here. */
7998-
Assert(subplan->parParam==NIL);
7999-
8000-
/* We have emerged from an initplan. */
8001-
in_same_plan_level= false;
8002-
break;
8003-
}
80047979

80057980
/* No luck, crawl up to next ancestor */
80067981
child_plan= (Plan*)ancestor;

‎src/test/regress/expected/join.out

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6074,8 +6074,8 @@ lateral (select * from int8_tbl t1,
60746074
where q2 = (select greatest(t1.q1,t2.q2))
60756075
and (select v.id=0)) offset 0) ss2) ss
60766076
where t1.q1 = ss.q2) ss0;
6077-
QUERY PLAN
6078-
-----------------------------------------------------------------
6077+
QUERY PLAN
6078+
----------------------------------------------------------------------
60796079
Nested Loop
60806080
Output: "*VALUES*".column1, t1.q1, t1.q2, ss2.q1, ss2.q2
60816081
-> Seq Scan on public.int8_tbl t1
@@ -6096,10 +6096,10 @@ lateral (select * from int8_tbl t1,
60966096
One-Time Filter: $4
60976097
InitPlan 1 (returns $2)
60986098
-> Result
6099-
Output: GREATEST($0, t2.q2)
6099+
Output: GREATEST(t1.q1, t2.q2)
61006100
InitPlan 2 (returns $4)
61016101
-> Result
6102-
Output: ($3 = 0)
6102+
Output: ("*VALUES*".column1 = 0)
61036103
-> Seq Scan on public.int8_tbl t3
61046104
Output: t3.q1, t3.q2
61056105
Filter: (t3.q2 = $2)

‎src/test/regress/expected/subselect.out

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1155,7 +1155,7 @@ where o.ten = 0;
11551155
SubPlan 1
11561156
-> Seq Scan on public.int4_tbl
11571157
Output: int4_tbl.f1
1158-
Filter: (int4_tbl.f1 <=$0)
1158+
Filter: (int4_tbl.f1 <=o.hundred)
11591159
(14 rows)
11601160

11611161
select sum(ss.tst::int) from

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp