diff options
author | Peter Eisentraut <peter_e@gmx.net> | 2016-01-20 21:27:46 -0500 |
---|---|---|
committer | Peter Eisentraut <peter_e@gmx.net> | 2016-01-20 21:27:46 -0500 |
commit | d0f2f53cd6f2f1fe6e53b8e3bfcce43c16ea851b (patch) | |
tree | fff6b771c4b697bec8eca7f00ab19cad1c0845a3 /src | |
parent | 422a55a68784fd00f4514834f3649140a9166fa5 (diff) | |
download | postgresql-d0f2f53cd6f2f1fe6e53b8e3bfcce43c16ea851b.tar.gz postgresql-d0f2f53cd6f2f1fe6e53b8e3bfcce43c16ea851b.zip |
psql: Add tab completion for COPY with query
From: Andreas Karlsson <andreas@proxel.se>
Diffstat (limited to 'src')
-rw-r--r-- | src/bin/psql/tab-complete.c | 13 |
1 files changed, 10 insertions, 3 deletions
diff --git a/src/bin/psql/tab-complete.c b/src/bin/psql/tab-complete.c index c3c77bd5876..f09e65c58dd 100644 --- a/src/bin/psql/tab-complete.c +++ b/src/bin/psql/tab-complete.c @@ -1934,11 +1934,18 @@ psql_completion(const char *text, int start, int end) /* COPY */ /* - * If we have COPY [BINARY] (which you'd have to type yourself), offer - * list of tables (Also cover the analogous backslash command) + * If we have COPY, offer list of tables or "(" (Also cover the analogous + * backslash command). */ - else if (Matches1("COPY|\\copy") || Matches2("COPY", "BINARY")) + else if (Matches1("COPY|\\copy")) + COMPLETE_WITH_SCHEMA_QUERY(Query_for_list_of_tables, + " UNION ALL SELECT '('"); + /* If we have COPY BINARY, complete with list of tables */ + else if (Matches2("COPY", "BINARY")) COMPLETE_WITH_SCHEMA_QUERY(Query_for_list_of_tables, NULL); + /* If we have COPY (, complete it with legal commands */ + else if (Matches2("COPY|\\copy", "(")) + COMPLETE_WITH_LIST7("SELECT", "TABLE", "VALUES", "INSERT", "UPDATE", "DELETE", "WITH"); /* If we have COPY [BINARY] <sth>, complete it with "TO" or "FROM" */ else if (Matches2("COPY|\\copy", MatchAny) || Matches3("COPY", "BINARY", MatchAny)) |