@@ -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" ))
19411945COMPLETE_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" */
19431950else if (Matches2 ("COPY|\\copy" ,MatchAny )||
19441951Matches3 ("COPY" ,"BINARY" ,MatchAny ))