Skip to content

Commit d0f2f53

Browse files
committed
psql: Add tab completion for COPY with query
From: Andreas Karlsson <andreas@proxel.se>
1 parent 422a55a commit d0f2f53

File tree

1 file changed

+10
-3
lines changed

1 file changed

+10
-3
lines changed

src/bin/psql/tab-complete.c

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1934,11 +1934,18 @@ psql_completion(const char *text, int start, int end)
19341934
/* COPY */
19351935

19361936
/*
1937-
* If we have COPY [BINARY] (which you'd have to type yourself), offer
1938-
* list of tables (Also cover the analogous backslash command)
1937+
* If we have COPY, offer list of tables or "(" (Also cover the analogous
1938+
* backslash command).
19391939
*/
1940-
else if (Matches1("COPY|\\copy") || Matches2("COPY", "BINARY"))
1940+
else if (Matches1("COPY|\\copy"))
1941+
COMPLETE_WITH_SCHEMA_QUERY(Query_for_list_of_tables,
1942+
" UNION ALL SELECT '('");
1943+
/* If we have COPY BINARY, complete with list of tables */
1944+
else if (Matches2("COPY", "BINARY"))
19411945
COMPLETE_WITH_SCHEMA_QUERY(Query_for_list_of_tables, NULL);
1946+
/* If we have COPY (, complete it with legal commands */
1947+
else if (Matches2("COPY|\\copy", "("))
1948+
COMPLETE_WITH_LIST7("SELECT", "TABLE", "VALUES", "INSERT", "UPDATE", "DELETE", "WITH");
19421949
/* If we have COPY [BINARY] <sth>, complete it with "TO" or "FROM" */
19431950
else if (Matches2("COPY|\\copy", MatchAny) ||
19441951
Matches3("COPY", "BINARY", MatchAny))

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy