summaryrefslogtreecommitdiff
path: root/contrib/auto_explain
diff options
context:
space:
mode:
authorTom Lane <tgl@sss.pgh.pa.us>2009-07-26 23:34:18 +0000
committerTom Lane <tgl@sss.pgh.pa.us>2009-07-26 23:34:18 +0000
commitd4382c4ae7ea1e272f4fee388aac8ff99421471a (patch)
treea6fdb904bcdb849f15f68c9ad5541186d0b4216e /contrib/auto_explain
parenta07e5acebbc0647c82c8577f17f912561e69aff4 (diff)
downloadpostgresql-d4382c4ae7ea1e272f4fee388aac8ff99421471a.tar.gz
Extend EXPLAIN to allow generic options to be specified.
The original syntax made it difficult to add options without making them into reserved words. This change parenthesizes the options to avoid that problem, and makes provision for an explicit (and perhaps non-Boolean) value for each option. The original syntax is still supported, but only for the two original options ANALYZE and VERBOSE. As a test case, add a COSTS option that can suppress the planner cost estimates. This may be useful for including EXPLAIN output in the regression tests, which are otherwise unable to cope with cross-platform variations in cost estimates. Robert Haas
Diffstat (limited to 'contrib/auto_explain')
-rw-r--r--contrib/auto_explain/auto_explain.c21
1 files changed, 11 insertions, 10 deletions
diff --git a/contrib/auto_explain/auto_explain.c b/contrib/auto_explain/auto_explain.c
index 9108a77ba1..eb2bc04aed 100644
--- a/contrib/auto_explain/auto_explain.c
+++ b/contrib/auto_explain/auto_explain.c
@@ -6,7 +6,7 @@
* Copyright (c) 2008-2009, PostgreSQL Global Development Group
*
* IDENTIFICATION
- * $PostgreSQL: pgsql/contrib/auto_explain/auto_explain.c,v 1.5 2009/06/11 14:48:50 momjian Exp $
+ * $PostgreSQL: pgsql/contrib/auto_explain/auto_explain.c,v 1.6 2009/07/26 23:34:17 tgl Exp $
*
*-------------------------------------------------------------------------
*/
@@ -196,16 +196,17 @@ explain_ExecutorEnd(QueryDesc *queryDesc)
msec = queryDesc->totaltime->total * 1000.0;
if (msec >= auto_explain_log_min_duration)
{
- StringInfoData buf;
+ ExplainState es;
- initStringInfo(&buf);
- ExplainPrintPlan(&buf, queryDesc,
- queryDesc->doInstrument && auto_explain_log_analyze,
- auto_explain_log_verbose);
+ ExplainInitState(&es);
+ es.analyze = (queryDesc->doInstrument && auto_explain_log_analyze);
+ es.verbose = auto_explain_log_verbose;
+
+ ExplainPrintPlan(&es, queryDesc);
/* Remove last line break */
- if (buf.len > 0 && buf.data[buf.len - 1] == '\n')
- buf.data[--buf.len] = '\0';
+ if (es.str->len > 0 && es.str->data[es.str->len - 1] == '\n')
+ es.str->data[--es.str->len] = '\0';
/*
* Note: we rely on the existing logging of context or
@@ -215,9 +216,9 @@ explain_ExecutorEnd(QueryDesc *queryDesc)
*/
ereport(LOG,
(errmsg("duration: %.3f ms plan:\n%s",
- msec, buf.data)));
+ msec, es.str->data)));
- pfree(buf.data);
+ pfree(es.str->data);
}
}