From: Itagaki Takahiro Date: Mon, 15 Feb 2010 02:55:01 +0000 (+0000) Subject: Add psql tab completion for DO blocks. X-Git-Tag: REL9_0_ALPHA4~49 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=714f279457de23cbc81efc6961f4b5d611723db6;p=thirdparty%2Fpostgresql.git Add psql tab completion for DO blocks. Also adjust documentation of DO. Patch from David Fetter and subsequent discussion. --- diff --git a/doc/src/sgml/ref/do.sgml b/doc/src/sgml/ref/do.sgml index a85d598c6a3..f9e06ca092b 100644 --- a/doc/src/sgml/ref/do.sgml +++ b/doc/src/sgml/ref/do.sgml @@ -1,5 +1,5 @@ @@ -25,7 +25,7 @@ PostgreSQL documentation -DO code [ LANGUAGE lang_name ] +DO { [ LANGUAGE lang_name ] | code } ... diff --git a/src/bin/psql/tab-complete.c b/src/bin/psql/tab-complete.c index cecd88d522a..19b9b1f3ef5 100644 --- a/src/bin/psql/tab-complete.c +++ b/src/bin/psql/tab-complete.c @@ -3,7 +3,7 @@ * * Copyright (c) 2000-2010, PostgreSQL Global Development Group * - * $PostgreSQL: pgsql/src/bin/psql/tab-complete.c,v 1.192 2010/01/25 18:23:09 heikki Exp $ + * $PostgreSQL: pgsql/src/bin/psql/tab-complete.c,v 1.193 2010/02/15 02:55:01 itagaki Exp $ */ /*---------------------------------------------------------------------- @@ -618,7 +618,7 @@ psql_completion(char *text, int start, int end) static const char *const sql_commands[] = { "ABORT", "ALTER", "ANALYZE", "BEGIN", "CHECKPOINT", "CLOSE", "CLUSTER", "COMMENT", "COMMIT", "COPY", "CREATE", "DEALLOCATE", "DECLARE", - "DELETE FROM", "DISCARD", "DROP", "END", "EXECUTE", "EXPLAIN", "FETCH", + "DELETE FROM", "DISCARD", "DO", "DROP", "END", "EXECUTE", "EXPLAIN", "FETCH", "GRANT", "INSERT", "LISTEN", "LOAD", "LOCK", "MOVE", "NOTIFY", "PREPARE", "REASSIGN", "REINDEX", "RELEASE", "RESET", "REVOKE", "ROLLBACK", "SAVEPOINT", "SELECT", "SET", "SHOW", "START", "TABLE", "TRUNCATE", "UNLISTEN", @@ -1532,6 +1532,18 @@ psql_completion(char *text, int start, int end) COMPLETE_WITH_LIST(list_DISCARD); } +/* DO */ + /* + * Complete DO with LANGUAGE. + */ + else if (pg_strcasecmp(prev_wd, "DO") == 0) + { + static const char *const list_DO[] = + {"LANGUAGE", NULL}; + + COMPLETE_WITH_LIST(list_DO); + } + /* DROP (when not the previous word) */ /* DROP AGGREGATE */ else if (pg_strcasecmp(prev3_wd, "DROP") == 0 &&