Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit 714f279

Browse files
committed
Add psql tab completion for DO blocks.
Also adjust documentation of DO. Patch from David Fetter and subsequent discussion.
1 parent 34ebccd commit 714f279

File tree

2 files changed

+16
-4
lines changed

2 files changed

+16
-4
lines changed

doc/src/sgml/ref/do.sgml

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<!--
2-
$PostgreSQL: pgsql/doc/src/sgml/ref/do.sgml,v 1.3 2010/01/26 16:33:40 tgl Exp $
2+
$PostgreSQL: pgsql/doc/src/sgml/ref/do.sgml,v 1.4 2010/02/15 02:55:01 itagaki Exp $
33
PostgreSQL documentation
44
-->
55

@@ -25,7 +25,7 @@ PostgreSQL documentation
2525

2626
<refsynopsisdiv>
2727
<synopsis>
28-
DO <replaceable class="PARAMETER">code</replaceable> [ LANGUAGE <replaceable class="PARAMETER">lang_name</replaceable> ]
28+
DO { [ LANGUAGE <replaceable class="PARAMETER">lang_name</replaceable> ] | <replaceable class="PARAMETER">code</replaceable> } ...
2929
</synopsis>
3030
</refsynopsisdiv>
3131

src/bin/psql/tab-complete.c

+14-2
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
*
44
* Copyright (c) 2000-2010, PostgreSQL Global Development Group
55
*
6-
* $PostgreSQL: pgsql/src/bin/psql/tab-complete.c,v 1.192 2010/01/25 18:23:09 heikki Exp $
6+
* $PostgreSQL: pgsql/src/bin/psql/tab-complete.c,v 1.193 2010/02/15 02:55:01 itagaki Exp $
77
*/
88

99
/*----------------------------------------------------------------------
@@ -618,7 +618,7 @@ psql_completion(char *text, int start, int end)
618618
static const char *const sql_commands[] = {
619619
"ABORT", "ALTER", "ANALYZE", "BEGIN", "CHECKPOINT", "CLOSE", "CLUSTER",
620620
"COMMENT", "COMMIT", "COPY", "CREATE", "DEALLOCATE", "DECLARE",
621-
"DELETE FROM", "DISCARD", "DROP", "END", "EXECUTE", "EXPLAIN", "FETCH",
621+
"DELETE FROM", "DISCARD", "DO", "DROP", "END", "EXECUTE", "EXPLAIN", "FETCH",
622622
"GRANT", "INSERT", "LISTEN", "LOAD", "LOCK", "MOVE", "NOTIFY", "PREPARE",
623623
"REASSIGN", "REINDEX", "RELEASE", "RESET", "REVOKE", "ROLLBACK",
624624
"SAVEPOINT", "SELECT", "SET", "SHOW", "START", "TABLE", "TRUNCATE", "UNLISTEN",
@@ -1532,6 +1532,18 @@ psql_completion(char *text, int start, int end)
15321532
COMPLETE_WITH_LIST(list_DISCARD);
15331533
}
15341534

1535+
/* DO */
1536+
/*
1537+
* Complete DO with LANGUAGE.
1538+
*/
1539+
else if (pg_strcasecmp(prev_wd, "DO") == 0)
1540+
{
1541+
static const char *const list_DO[] =
1542+
{"LANGUAGE", NULL};
1543+
1544+
COMPLETE_WITH_LIST(list_DO);
1545+
}
1546+
15351547
/* DROP (when not the previous word) */
15361548
/* DROP AGGREGATE */
15371549
else if (pg_strcasecmp(prev3_wd, "DROP") == 0 &&

0 commit comments

Comments
 (0)