mirror of
https://git.postgresql.org/git/postgresql.git
synced 2024-11-27 07:21:09 +08:00
Add query text to auto_explain output.
Still to be done: fix docs and fix regression failures under auto_explain.
This commit is contained in:
parent
56adf3703c
commit
fc5173ad51
@ -6,7 +6,7 @@
|
||||
* Copyright (c) 2008-2010, PostgreSQL Global Development Group
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $PostgreSQL: pgsql/contrib/auto_explain/auto_explain.c,v 1.12 2010/01/06 18:07:19 tgl Exp $
|
||||
* $PostgreSQL: pgsql/contrib/auto_explain/auto_explain.c,v 1.13 2010/02/16 22:19:59 adunstan Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
@ -240,6 +240,7 @@ explain_ExecutorEnd(QueryDesc *queryDesc)
|
||||
es.format = auto_explain_log_format;
|
||||
|
||||
ExplainBeginOutput(&es);
|
||||
ExplainQueryText(&es, queryDesc);
|
||||
ExplainPrintPlan(&es, queryDesc);
|
||||
ExplainEndOutput(&es);
|
||||
|
||||
@ -255,7 +256,8 @@ explain_ExecutorEnd(QueryDesc *queryDesc)
|
||||
*/
|
||||
ereport(LOG,
|
||||
(errmsg("duration: %.3f ms plan:\n%s",
|
||||
msec, es.str->data)));
|
||||
msec, es.str->data),
|
||||
errhidestmt(true)));
|
||||
|
||||
pfree(es.str->data);
|
||||
}
|
||||
|
@ -7,7 +7,7 @@
|
||||
* Portions Copyright (c) 1994-5, Regents of the University of California
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $PostgreSQL: pgsql/src/backend/commands/explain.c,v 1.202 2010/02/16 20:07:13 stark Exp $
|
||||
* $PostgreSQL: pgsql/src/backend/commands/explain.c,v 1.203 2010/02/16 22:19:59 adunstan Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
@ -487,6 +487,21 @@ ExplainPrintPlan(ExplainState *es, QueryDesc *queryDesc)
|
||||
NULL, NULL, NULL, es);
|
||||
}
|
||||
|
||||
/*
|
||||
* ExplainQueryText -
|
||||
* add a "Query Text" node that contains the actual text of the query
|
||||
*
|
||||
* The caller should have set up the options fields of *es, as well as
|
||||
* initializing the output buffer es->str.
|
||||
*
|
||||
*/
|
||||
void
|
||||
ExplainQueryText(ExplainState *es, QueryDesc *queryDesc)
|
||||
{
|
||||
if (queryDesc->sourceText)
|
||||
ExplainPropertyText("Query Text", queryDesc->sourceText, es);
|
||||
}
|
||||
|
||||
/*
|
||||
* report_triggers -
|
||||
* report execution stats for a single relation's triggers
|
||||
|
@ -6,7 +6,7 @@
|
||||
* Portions Copyright (c) 1996-2010, PostgreSQL Global Development Group
|
||||
* Portions Copyright (c) 1994-5, Regents of the University of California
|
||||
*
|
||||
* $PostgreSQL: pgsql/src/include/commands/explain.h,v 1.45 2010/01/02 16:58:03 momjian Exp $
|
||||
* $PostgreSQL: pgsql/src/include/commands/explain.h,v 1.46 2010/02/16 22:19:59 adunstan Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
@ -66,6 +66,8 @@ extern void ExplainOnePlan(PlannedStmt *plannedstmt, ExplainState *es,
|
||||
|
||||
extern void ExplainPrintPlan(ExplainState *es, QueryDesc *queryDesc);
|
||||
|
||||
extern void ExplainQueryText(ExplainState *es, QueryDesc *queryDesc);
|
||||
|
||||
extern void ExplainBeginOutput(ExplainState *es);
|
||||
extern void ExplainEndOutput(ExplainState *es);
|
||||
extern void ExplainSeparatePlans(ExplainState *es);
|
||||
|
Loading…
Reference in New Issue
Block a user