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

Commitd2458e3

Browse files
committed
Expose a routine to print triggers during EXPLAIN ANALYZE
This is so that auto_explain can use it.Kyotaro HORIGUCHI
1 parentfe0c690 commitd2458e3

File tree

2 files changed

+38
-23
lines changed

2 files changed

+38
-23
lines changed

‎src/backend/commands/explain.c

Lines changed: 37 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -486,29 +486,7 @@ ExplainOnePlan(PlannedStmt *plannedstmt, IntoClause *into, ExplainState *es,
486486

487487
/* Print info about runtime of triggers */
488488
if (es->analyze)
489-
{
490-
ResultRelInfo*rInfo;
491-
boolshow_relname;
492-
intnumrels=queryDesc->estate->es_num_result_relations;
493-
List*targrels=queryDesc->estate->es_trig_target_relations;
494-
intnr;
495-
ListCell*l;
496-
497-
ExplainOpenGroup("Triggers","Triggers", false,es);
498-
499-
show_relname= (numrels>1||targrels!=NIL);
500-
rInfo=queryDesc->estate->es_result_relations;
501-
for (nr=0;nr<numrels;rInfo++,nr++)
502-
report_triggers(rInfo,show_relname,es);
503-
504-
foreach(l,targrels)
505-
{
506-
rInfo= (ResultRelInfo*)lfirst(l);
507-
report_triggers(rInfo,show_relname,es);
508-
}
509-
510-
ExplainCloseGroup("Triggers","Triggers", false,es);
511-
}
489+
ExplainPrintTriggers(es,queryDesc);
512490

513491
/*
514492
* Close down the query and free resources. Include time for this in the
@@ -564,6 +542,42 @@ ExplainPrintPlan(ExplainState *es, QueryDesc *queryDesc)
564542
ExplainNode(queryDesc->planstate,NIL,NULL,NULL,es);
565543
}
566544

545+
/*
546+
* ExplainPrintTriggers -
547+
548+
* convert a QueryDesc's trigger statistics to text and append it to
549+
* es->str
550+
*
551+
* The caller should have set up the options fields of *es, as well as
552+
* initializing the output buffer es->str.Other fields in *es are
553+
* initialized here.
554+
*/
555+
void
556+
ExplainPrintTriggers(ExplainState*es,QueryDesc*queryDesc)
557+
{
558+
ResultRelInfo*rInfo;
559+
boolshow_relname;
560+
intnumrels=queryDesc->estate->es_num_result_relations;
561+
List*targrels=queryDesc->estate->es_trig_target_relations;
562+
intnr;
563+
ListCell*l;
564+
565+
ExplainOpenGroup("Triggers","Triggers", false,es);
566+
567+
show_relname= (numrels>1||targrels!=NIL);
568+
rInfo=queryDesc->estate->es_result_relations;
569+
for (nr=0;nr<numrels;rInfo++,nr++)
570+
report_triggers(rInfo,show_relname,es);
571+
572+
foreach(l,targrels)
573+
{
574+
rInfo= (ResultRelInfo*)lfirst(l);
575+
report_triggers(rInfo,show_relname,es);
576+
}
577+
578+
ExplainCloseGroup("Triggers","Triggers", false,es);
579+
}
580+
567581
/*
568582
* ExplainQueryText -
569583
* add a "Query Text" node that contains the actual text of the query

‎src/include/commands/explain.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,7 @@ extern void ExplainOnePlan(PlannedStmt *plannedstmt, IntoClause *into,
7171
constchar*queryString,ParamListInfoparams);
7272

7373
externvoidExplainPrintPlan(ExplainState*es,QueryDesc*queryDesc);
74+
externvoidExplainPrintTriggers(ExplainState*es,QueryDesc*queryDesc);
7475

7576
externvoidExplainQueryText(ExplainState*es,QueryDesc*queryDesc);
7677

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp