Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1hO2xF-0002my-V3 for pgsql-hackers@arkaria.postgresql.org; Tue, 07 May 2019 16:28:34 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1hO2xE-0008NY-FH for pgsql-hackers@arkaria.postgresql.org; Tue, 07 May 2019 16:28:32 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1hO2xE-0008L2-2F for pgsql-hackers@lists.postgresql.org; Tue, 07 May 2019 16:28:32 +0000 Received: from xvm-110-146.dc2.ghst.net ([46.226.110.146] helo=fetter.org) by makus.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1hO2x7-0007dI-4b for pgsql-hackers@postgresql.org; Tue, 07 May 2019 16:28:30 +0000 Received: by fetter.org (Postfix, from userid 1001) id 26DD042BC5; Tue, 7 May 2019 18:28:23 +0200 (CEST) Date: Tue, 7 May 2019 18:28:22 +0200 From: David Fetter To: Sergei Kornilov Cc: PostgreSQL Development Subject: Re: New EXPLAIN option: ALL Message-ID: <20190507162822.GK28936@fetter.org> References: <20190507073046.GI28936@fetter.org> <20190507075047.GJ28936@fetter.org> <505561557216795@sas2-857317bd6599.qloud-c.yandex.net> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="hSZb4FHl1C2xfsUy" Content-Disposition: inline In-Reply-To: <505561557216795@sas2-857317bd6599.qloud-c.yandex.net> User-Agent: Mutt/1.9.4 (2018-02-28) List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk --hSZb4FHl1C2xfsUy Content-Type: text/plain; charset=us-ascii Content-Disposition: inline On Tue, May 07, 2019 at 11:13:15AM +0300, Sergei Kornilov wrote: > Hi > > I liked this idea. > > + timing_set = true; > + es->timing = defGetBoolean(opt); > + summary_set = true; > + es->timing = defGetBoolean(opt); > > second es->timing should be es->summary, right? You are correct! Sorry about the copy-paste-o. Best, David. -- David Fetter http://fetter.org/ Phone: +1 415 235 3778 Remember to vote! Consider donating to Postgres: http://www.postgresql.org/about/donate --hSZb4FHl1C2xfsUy Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="v2-0001-Add-an-ALL-option-to-EXPLAIN.patch" From 424d82c9ff519c02ae266700ed1f4b40ac9c495f Mon Sep 17 00:00:00 2001 From: David Fetter Date: Tue, 7 May 2019 00:26:29 -0700 Subject: [PATCH v2] Add an ALL option to EXPLAIN To: hackers MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="------------2.21.0" This is a multi-part message in MIME format. --------------2.21.0 Content-Type: text/plain; charset=UTF-8; format=fixed Content-Transfer-Encoding: 8bit which starts all boolean options at once. diff --git a/doc/src/sgml/ref/explain.sgml b/doc/src/sgml/ref/explain.sgml index 385d10411f..ade3793c5f 100644 --- a/doc/src/sgml/ref/explain.sgml +++ b/doc/src/sgml/ref/explain.sgml @@ -43,6 +43,7 @@ EXPLAIN [ ANALYZE ] [ VERBOSE ] statementboolean ] TIMING [ boolean ] SUMMARY [ boolean ] + ALL [ boolean ] FORMAT { TEXT | XML | JSON | YAML } @@ -224,6 +225,16 @@ ROLLBACK; + + ALL + + + Include (or exclude) all of the above settings before examining the rest + of the options. It defaults to FALSE. + + + + FORMAT diff --git a/src/backend/commands/explain.c b/src/backend/commands/explain.c index a6c6de78f1..f58b9d7290 100644 --- a/src/backend/commands/explain.c +++ b/src/backend/commands/explain.c @@ -151,6 +151,26 @@ ExplainQuery(ParseState *pstate, ExplainStmt *stmt, const char *queryString, bool summary_set = false; /* Parse options list. */ + /* First, see whether ALL is set */ + foreach(lc, stmt->options) + { + DefElem *opt = (DefElem *) lfirst(lc); + + if (strcmp(opt->defname, "all") == 0) + { + es->analyze = defGetBoolean(opt); + es->verbose = defGetBoolean(opt); + es->costs = defGetBoolean(opt); + es->buffers = defGetBoolean(opt); + es->settings = defGetBoolean(opt); + timing_set = true; + es->timing = defGetBoolean(opt); + summary_set = true; + es->summary_set = defGetBoolean(opt); + } + } + + /* If you add another boolean option here, remember to add it above, too */ foreach(lc, stmt->options) { DefElem *opt = (DefElem *) lfirst(lc); @@ -194,6 +214,8 @@ ExplainQuery(ParseState *pstate, ExplainStmt *stmt, const char *queryString, opt->defname, p), parser_errposition(pstate, opt->location))); } + else if (strcmp(opt->defname, "all") == 0) + ; /* Do nothing */ else ereport(ERROR, (errcode(ERRCODE_SYNTAX_ERROR), diff --git a/src/backend/parser/gram.y b/src/backend/parser/gram.y index 3dc0e8a4fb..4a69f9711c 100644 --- a/src/backend/parser/gram.y +++ b/src/backend/parser/gram.y @@ -10704,6 +10704,7 @@ explain_option_elem: explain_option_name: NonReservedWord { $$ = $1; } | analyze_keyword { $$ = "analyze"; } + | ALL { $$ = "all"; } ; explain_option_arg: diff --git a/src/bin/psql/tab-complete.c b/src/bin/psql/tab-complete.c index bcddc7601e..8177f9c6da 100644 --- a/src/bin/psql/tab-complete.c +++ b/src/bin/psql/tab-complete.c @@ -2862,9 +2862,9 @@ psql_completion(const char *text, int start, int end) * one word, so the above test is correct. */ if (ends_with(prev_wd, '(') || ends_with(prev_wd, ',')) - COMPLETE_WITH("ANALYZE", "VERBOSE", "COSTS", "BUFFERS", + COMPLETE_WITH("ALL", "ANALYZE", "VERBOSE", "COSTS", "BUFFERS", "TIMING", "SUMMARY", "FORMAT"); - else if (TailMatches("ANALYZE|VERBOSE|COSTS|BUFFERS|TIMING|SUMMARY")) + else if (TailMatches("ALL|ANALYZE|VERBOSE|COSTS|BUFFERS|TIMING|SUMMARY")) COMPLETE_WITH("ON", "OFF"); else if (TailMatches("FORMAT")) COMPLETE_WITH("TEXT", "XML", "JSON", "YAML"); @@ -2874,7 +2874,8 @@ psql_completion(const char *text, int start, int end) "VERBOSE"); else if (Matches("EXPLAIN", "(*)") || Matches("EXPLAIN", "VERBOSE") || - Matches("EXPLAIN", "ANALYZE", "VERBOSE")) + Matches("EXPLAIN", "ANALYZE", "VERBOSE") || + Matches("EXPLAIN", "ALL")) COMPLETE_WITH("SELECT", "INSERT", "DELETE", "UPDATE", "DECLARE"); /* FETCH && MOVE */ --------------2.21.0-- --hSZb4FHl1C2xfsUy--