Commit 714f2794 authored by Itagaki Takahiro's avatar Itagaki Takahiro

Add psql tab completion for DO blocks.

Also adjust documentation of DO.

Patch from David Fetter and subsequent discussion.
parent 34ebccdd
<!--
$PostgreSQL: pgsql/doc/src/sgml/ref/do.sgml,v 1.3 2010/01/26 16:33:40 tgl Exp $
$PostgreSQL: pgsql/doc/src/sgml/ref/do.sgml,v 1.4 2010/02/15 02:55:01 itagaki Exp $
PostgreSQL documentation
-->
......@@ -25,7 +25,7 @@ PostgreSQL documentation
<refsynopsisdiv>
<synopsis>
DO <replaceable class="PARAMETER">code</replaceable> [ LANGUAGE <replaceable class="PARAMETER">lang_name</replaceable> ]
DO { [ LANGUAGE <replaceable class="PARAMETER">lang_name</replaceable> ] | <replaceable class="PARAMETER">code</replaceable> } ...
</synopsis>
</refsynopsisdiv>
......
......@@ -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 &&
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment