From 714f279457de23cbc81efc6961f4b5d611723db6 Mon Sep 17 00:00:00 2001 From: Itagaki Takahiro Date: Mon, 15 Feb 2010 02:55:01 +0000 Subject: [PATCH] Add psql tab completion for DO blocks. Also adjust documentation of DO. Patch from David Fetter and subsequent discussion. --- doc/src/sgml/ref/do.sgml | 4 ++-- src/bin/psql/tab-complete.c | 16 ++++++++++++++-- 2 files changed, 16 insertions(+), 4 deletions(-) diff --git a/doc/src/sgml/ref/do.sgml b/doc/src/sgml/ref/do.sgml index a85d598c6a..f9e06ca092 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 cecd88d522..19b9b1f3ef 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 && -- 2.40.0