From 7a7ff835c4bf61c0e904749a7c5c18d580ca36ec Mon Sep 17 00:00:00 2001 From: David Christensen Date: Thu, 19 May 2016 14:47:19 -0500 Subject: [PATCH] Add EXPLAIN (ALL) shorthand To: pgsql-hackers@postgresql.org Add EXPLAIN (ALL) as a synonym for the options (ANALYZE, VERBOSE, COSTS, TIMING, BUFFERS). --- doc/src/sgml/ref/explain.sgml | 10 ++++++++++ src/backend/commands/explain.c | 17 ++++++++++++----- src/backend/parser/gram.y | 1 + 3 files changed, 23 insertions(+), 5 deletions(-) diff --git a/doc/src/sgml/ref/explain.sgml b/doc/src/sgml/ref/explain.sgml index f14a58d..9cfeeac 100644 --- a/doc/src/sgml/ref/explain.sgml +++ b/doc/src/sgml/ref/explain.sgml @@ -36,6 +36,7 @@ EXPLAIN [ ANALYZE ] [ VERBOSE ] statementwhere option can be one of: + ALL ANALYZE [ boolean ] VERBOSE [ boolean ] COSTS [ boolean ] @@ -116,6 +117,15 @@ ROLLBACK; + ALL + + + This option is shorthand for specifying EXPLAIN (ANALYZE, VERBOSE, COSTS, BUFFERS, TIMING). + + + + + ANALYZE diff --git a/src/backend/commands/explain.c b/src/backend/commands/explain.c index 379fc5c..e1960da 100644 --- a/src/backend/commands/explain.c +++ b/src/backend/commands/explain.c @@ -147,21 +147,28 @@ ExplainQuery(ExplainStmt *stmt, const char *queryString, List *rewritten; ListCell *lc; bool timing_set = false; + bool all_set = false; /* Parse options list. */ foreach(lc, stmt->options) { DefElem *opt = (DefElem *) lfirst(lc); - if (strcmp(opt->defname, "analyze") == 0) + if (strcmp(opt->defname, "all") == 0) + { + all_set = true; + timing_set = true; + es->analyze = es->verbose = es->costs = es->buffers = es->timing = defGetBoolean(opt); + } + else if (!all_set && strcmp(opt->defname, "analyze") == 0) es->analyze = defGetBoolean(opt); - else if (strcmp(opt->defname, "verbose") == 0) + else if (!all_set && strcmp(opt->defname, "verbose") == 0) es->verbose = defGetBoolean(opt); - else if (strcmp(opt->defname, "costs") == 0) + else if (!all_set && strcmp(opt->defname, "costs") == 0) es->costs = defGetBoolean(opt); - else if (strcmp(opt->defname, "buffers") == 0) + else if (!all_set && strcmp(opt->defname, "buffers") == 0) es->buffers = defGetBoolean(opt); - else if (strcmp(opt->defname, "timing") == 0) + else if (!all_set && strcmp(opt->defname, "timing") == 0) { timing_set = true; es->timing = defGetBoolean(opt); diff --git a/src/backend/parser/gram.y b/src/backend/parser/gram.y index 18ec5f0..80790c9 100644 --- a/src/backend/parser/gram.y +++ b/src/backend/parser/gram.y @@ -9493,6 +9493,7 @@ explain_option_elem: explain_option_name: NonReservedWord { $$ = $1; } | analyze_keyword { $$ = "analyze"; } + | ALL { $$ = "all"; } ; explain_option_arg: -- 2.7.4 (Apple Git-66)