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

Commit97c4ee9

Browse files
committed
Include the target table in EXPLAIN output for ModifyTable nodes.
Per discussion, this seems important for plans involving writable CTEs,since there can now be more than one ModifyTable node in the plan.To retain the same formatting as for target tables of scan nodes, weshow only one target table, which will be the parent table in case ofan UPDATE or DELETE on an inheritance tree. Individual child tablescan be determined by inspecting the child plan trees if needed.
1 parent59d6a75 commit97c4ee9

File tree

1 file changed

+34
-3
lines changed

1 file changed

+34
-3
lines changed

‎src/backend/commands/explain.c

Lines changed: 34 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,8 @@ static void show_hash_info(HashState *hashstate, ExplainState *es);
8484
staticvoidshow_foreignscan_info(ForeignScanState*fsstate,ExplainState*es);
8585
staticconstchar*explain_get_index_name(OidindexId);
8686
staticvoidExplainScanTarget(Scan*plan,ExplainState*es);
87+
staticvoidExplainModifyTarget(ModifyTable*plan,ExplainState*es);
88+
staticvoidExplainTargetRel(Plan*plan,Indexrti,ExplainState*es);
8789
staticvoidExplainMemberNodes(List*plans,PlanState**planstates,
8890
List*ancestors,ExplainState*es);
8991
staticvoidExplainSubPlans(List*plans,List*ancestors,
@@ -851,6 +853,9 @@ ExplainNode(PlanState *planstate, List *ancestors,
851853
ExplainPropertyText("Index Name",indexname,es);
852854
}
853855
break;
856+
caseT_ModifyTable:
857+
ExplainModifyTarget((ModifyTable*)plan,es);
858+
break;
854859
caseT_NestLoop:
855860
caseT_MergeJoin:
856861
caseT_HashJoin:
@@ -1553,15 +1558,40 @@ explain_get_index_name(Oid indexId)
15531558
*/
15541559
staticvoid
15551560
ExplainScanTarget(Scan*plan,ExplainState*es)
1561+
{
1562+
ExplainTargetRel((Plan*)plan,plan->scanrelid,es);
1563+
}
1564+
1565+
/*
1566+
* Show the target of a ModifyTable node
1567+
*/
1568+
staticvoid
1569+
ExplainModifyTarget(ModifyTable*plan,ExplainState*es)
1570+
{
1571+
Indexrti;
1572+
1573+
/*
1574+
* We show the name of the first target relation. In multi-target-table
1575+
* cases this should always be the parent of the inheritance tree.
1576+
*/
1577+
Assert(plan->resultRelations!=NIL);
1578+
rti=linitial_int(plan->resultRelations);
1579+
1580+
ExplainTargetRel((Plan*)plan,rti,es);
1581+
}
1582+
1583+
/*
1584+
* Show the target relation of a scan or modify node
1585+
*/
1586+
staticvoid
1587+
ExplainTargetRel(Plan*plan,Indexrti,ExplainState*es)
15561588
{
15571589
char*objectname=NULL;
15581590
char*namespace=NULL;
15591591
constchar*objecttag=NULL;
15601592
RangeTblEntry*rte;
15611593

1562-
if (plan->scanrelid <=0)/* Is this still possible? */
1563-
return;
1564-
rte=rt_fetch(plan->scanrelid,es->rtable);
1594+
rte=rt_fetch(rti,es->rtable);
15651595

15661596
switch (nodeTag(plan))
15671597
{
@@ -1570,6 +1600,7 @@ ExplainScanTarget(Scan *plan, ExplainState *es)
15701600
caseT_BitmapHeapScan:
15711601
caseT_TidScan:
15721602
caseT_ForeignScan:
1603+
caseT_ModifyTable:
15731604
/* Assert it's on a real relation */
15741605
Assert(rte->rtekind==RTE_RELATION);
15751606
objectname=get_rel_name(rte->relid);

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp