diff --git a/doc/src/sgml/ref/explain.sgml b/doc/src/sgml/ref/explain.sgml index 1c19e254dc..906b2ccd50 100644 --- a/doc/src/sgml/ref/explain.sgml +++ b/doc/src/sgml/ref/explain.sgml @@ -187,8 +187,7 @@ ROLLBACK; query processing. The number of blocks shown for an upper-level node includes those used by all its child nodes. In text - format, only non-zero values are printed. This parameter may only be - used when ANALYZE is also enabled. It defaults to + format, only non-zero values are printed. It defaults to FALSE. diff --git a/src/backend/commands/explain.c b/src/backend/commands/explain.c index 4cb3215728..7289054209 100644 --- a/src/backend/commands/explain.c +++ b/src/backend/commands/explain.c @@ -223,10 +223,13 @@ ExplainQuery(ParseState *pstate, ExplainStmt *stmt, parser_errposition(pstate, opt->location))); } - if (es->buffers && !es->analyze) + /* if the summary was not set explicitly, enable it if buffers are */ + es->summary = (summary_set) ? es->summary : es->buffers; + + if (es->buffers && !es->analyze && !es->summary) ereport(ERROR, (errcode(ERRCODE_INVALID_PARAMETER_VALUE), - errmsg("EXPLAIN option BUFFERS requires ANALYZE"))); + errmsg("EXPLAIN option BUFFERS requires ANALYZE or SUMMARY"))); if (es->wal && !es->analyze) ereport(ERROR, @@ -242,8 +245,8 @@ ExplainQuery(ParseState *pstate, ExplainStmt *stmt, (errcode(ERRCODE_INVALID_PARAMETER_VALUE), errmsg("EXPLAIN option TIMING requires ANALYZE"))); - /* if the summary was not set explicitly, set default value */ - es->summary = (summary_set) ? es->summary : es->analyze; + /* if the summary was not set explicitly, enable it if analyze is on. */ + es->summary |= (summary_set) ? es->summary : es->analyze; /* * Parse analysis was done already, but we still have to run the rule