Thank you for the new version. On Wed, Jun 27, 2018 at 03:10:51PM -0500, Justin Pryzby wrote: > Thanks - I've done this in the attached. It works well for having minimal > logic.
I think everthing is OK. But I didn't notice in previous version of the patch that there is no braces in EXPLAIN and VACUUM conditions. I attached diff file to show it. Also I included TEXT, XML, JSON, YAML items for FORMAT option in the diff file. The patch shows ",", ")", "ON", "OFF" for all options, but FORMAT requires format type to be specified. Please consider this change only as a suggestion. > Thanks for your repeated reviews ; if this looks+works fine, please set to > R-F-C. > > Actually..another thought: since toast tables may be VACUUM-ed, should I > introduce Query_for_list_of_tpmt ? Unfortunately, I'm not sure about toast tables and I'm not aware about policy of completion toast tables. -- Arthur Zakirov Postgres Professional: http://www.postgrespro.com Russian Postgres Company
diff --git a/src/bin/psql/tab-complete.c b/src/bin/psql/tab-complete.c index e913b83091..1d235a3987 100644 --- a/src/bin/psql/tab-complete.c +++ b/src/bin/psql/tab-complete.c @@ -2998,7 +2998,7 @@ psql_completion(const char *text, int start, int end) else if (Matches1("EXECUTE")) COMPLETE_WITH_QUERY(Query_for_list_of_prepared_statements); -/* +/* * EXPLAIN [ ( option [, ...] ) ] statement * EXPLAIN [ ANALYZE ] [ VERBOSE ] statement */ @@ -3006,10 +3006,16 @@ psql_completion(const char *text, int start, int end) COMPLETE_WITH_LIST8("SELECT", "INSERT", "DELETE", "UPDATE", "DECLARE", "ANALYZE", "VERBOSE", "("); else if (HeadMatches2("EXPLAIN", "(")) + { if (ends_with(prev_wd, '(') || ends_with(prev_wd, ',')) COMPLETE_WITH_LIST7("ANALYZE", "VERBOSE", "COSTS", "BUFFERS", "TIMING", "SUMMARY", "FORMAT"); - else + else if (TailMatches1("FORMAT")) + COMPLETE_WITH_LIST4("TEXT", "XML", "JSON", "YAML"); + else if (TailMatches1("ANALYZE|VERBOSE|COSTS|BUFFERS|TIMING|SUMMARY")) COMPLETE_WITH_LIST4(",", ")", "ON", "OFF"); + else + COMPLETE_WITH_LIST2(",", ")"); + } else if (HeadMatches2("EXPLAIN", MatchAny) && ends_with(prev_wd, ')')) /* If the parenthesis are balanced, the list is apparently parsed as a single word */ COMPLETE_WITH_LIST5("SELECT", "INSERT", "DELETE", "UPDATE", "DECLARE"); @@ -3597,10 +3603,12 @@ psql_completion(const char *text, int start, int end) COMPLETE_WITH_SCHEMA_QUERY(Query_for_list_of_tpm, " UNION SELECT 'ANALYZE'"); else if (HeadMatches2("VACUUM", "(")) + { if (ends_with(prev_wd, ',') || ends_with(prev_wd, '(')) COMPLETE_WITH_LIST5("FULL", "FREEZE", "ANALYZE", "VERBOSE", "DISABLE_PAGE_SKIPPING"); else COMPLETE_WITH_LIST2(",", ")"); + } else if (HeadMatches1("VACUUM") && TailMatches1("(")) /* "VACUUM (" should be caught above */ COMPLETE_WITH_ATTR(prev2_wd, "");