@@ -1934,11 +1934,18 @@ psql_completion(const char *text, int start, int end)
1934
1934
/* COPY */
1935
1935
1936
1936
/*
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).
1939
1939
*/
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" ))
1941
1945
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" );
1942
1949
/* If we have COPY [BINARY] <sth>, complete it with "TO" or "FROM" */
1943
1950
else if (Matches2 ("COPY|\\copy" ,MatchAny )||
1944
1951
Matches3 ("COPY" ,"BINARY" ,MatchAny ))