On Fri, Aug 22, 2014 at 8:14 AM, Stephen Frost <sfr...@snowman.net> wrote: > Alvaro, > > * Alvaro Herrera (alvhe...@2ndquadrant.com) wrote: >> ALTER TABLE ALL IN TABLESPACE xyz >> which AFAICS should work since ALL is already a reserved keyword. > > Pushed to master and REL9_4_STABLE.
You seem to have forgotten to update tab-complete.c. Attached patch updates that. Regards, -- Fujii Masao
*** a/src/bin/psql/tab-complete.c --- b/src/bin/psql/tab-complete.c *************** *** 953,958 **** psql_completion(const char *text, int start, int end) --- 953,965 ---- /* ALTER */ + /* ALTER TABLE */ + else if (pg_strcasecmp(prev2_wd, "ALTER") == 0 && + pg_strcasecmp(prev_wd, "TABLE") == 0) + { + COMPLETE_WITH_SCHEMA_QUERY(Query_for_list_of_tables, + "UNION SELECT 'ALL IN TABLESPACE'"); + } /* * complete with what you can alter (TABLE, GROUP, USER, ...) unless we're * in ALTER TABLE sth ALTER *************** *** 970,975 **** psql_completion(const char *text, int start, int end) --- 977,1001 ---- COMPLETE_WITH_LIST(list_ALTER); } + /* ALTER TABLE,INDEX,MATERIALIZED VIEW xxx ALL IN TABLESPACE xxx */ + else if (pg_strcasecmp(prev4_wd, "ALL") == 0 && + pg_strcasecmp(prev3_wd, "IN") == 0 && + pg_strcasecmp(prev2_wd, "TABLESPACE") == 0) + { + static const char *const list_ALTERALLINTSPC[] = + {"SET TABLESPACE", "OWNED BY", NULL}; + + COMPLETE_WITH_LIST(list_ALTERALLINTSPC); + } + /* ALTER TABLE,INDEX,MATERIALIZED VIEW xxx ALL IN TABLESPACE xxx OWNED BY */ + else if (pg_strcasecmp(prev6_wd, "ALL") == 0 && + pg_strcasecmp(prev5_wd, "IN") == 0 && + pg_strcasecmp(prev4_wd, "TABLESPACE") == 0 && + pg_strcasecmp(prev2_wd, "OWNED") == 0 && + pg_strcasecmp(prev4_wd, "BY") == 0) + { + COMPLETE_WITH_QUERY(Query_for_list_of_roles); + } /* ALTER AGGREGATE,FUNCTION <name> */ else if (pg_strcasecmp(prev3_wd, "ALTER") == 0 && (pg_strcasecmp(prev2_wd, "AGGREGATE") == 0 || *************** *** 1106,1111 **** psql_completion(const char *text, int start, int end) --- 1132,1144 ---- COMPLETE_WITH_LIST(list_ALTER_FOREIGN_TABLE); } + /* ALTER INDEX */ + else if (pg_strcasecmp(prev2_wd, "ALTER") == 0 && + pg_strcasecmp(prev_wd, "INDEX") == 0) + { + COMPLETE_WITH_SCHEMA_QUERY(Query_for_list_of_indexes, + "UNION SELECT 'ALL IN TABLESPACE'"); + } /* ALTER INDEX <name> */ else if (pg_strcasecmp(prev3_wd, "ALTER") == 0 && pg_strcasecmp(prev2_wd, "INDEX") == 0) *************** *** 1169,1175 **** psql_completion(const char *text, int start, int end) pg_strcasecmp(prev2_wd, "MATERIALIZED") == 0 && pg_strcasecmp(prev_wd, "VIEW") == 0) { ! COMPLETE_WITH_SCHEMA_QUERY(Query_for_list_of_matviews, NULL); } /* ALTER USER,ROLE <name> */ --- 1202,1209 ---- pg_strcasecmp(prev2_wd, "MATERIALIZED") == 0 && pg_strcasecmp(prev_wd, "VIEW") == 0) { ! COMPLETE_WITH_SCHEMA_QUERY(Query_for_list_of_matviews, ! "UNION SELECT 'ALL IN TABLESPACE'"); } /* ALTER USER,ROLE <name> */ *************** *** 1742,1753 **** psql_completion(const char *text, int start, int end) COMPLETE_WITH_CONST("IDENTITY"); } ! /* ALTER TABLESPACE <foo> with RENAME TO, OWNER TO, SET, RESET, MOVE */ else if (pg_strcasecmp(prev3_wd, "ALTER") == 0 && pg_strcasecmp(prev2_wd, "TABLESPACE") == 0) { static const char *const list_ALTERTSPC[] = ! {"RENAME TO", "OWNER TO", "SET", "RESET", "MOVE", NULL}; COMPLETE_WITH_LIST(list_ALTERTSPC); } --- 1776,1787 ---- COMPLETE_WITH_CONST("IDENTITY"); } ! /* ALTER TABLESPACE <foo> with RENAME TO, OWNER TO, SET, RESET */ else if (pg_strcasecmp(prev3_wd, "ALTER") == 0 && pg_strcasecmp(prev2_wd, "TABLESPACE") == 0) { static const char *const list_ALTERTSPC[] = ! {"RENAME TO", "OWNER TO", "SET", "RESET", NULL}; COMPLETE_WITH_LIST(list_ALTERTSPC); } *************** *** 1769,1795 **** psql_completion(const char *text, int start, int end) COMPLETE_WITH_LIST(list_TABLESPACEOPTIONS); } - /* ALTER TABLESPACE <foo> MOVE ALL|TABLES|INDEXES|MATERIALIZED VIEWS */ - else if (pg_strcasecmp(prev4_wd, "ALTER") == 0 && - pg_strcasecmp(prev3_wd, "TABLESPACE") == 0 && - pg_strcasecmp(prev_wd, "MOVE") == 0) - { - static const char *const list_TABLESPACEMOVETARGETS[] = - {"ALL", "TABLES", "INDEXES", "MATERIALIZED VIEWS", NULL}; - - COMPLETE_WITH_LIST(list_TABLESPACEMOVETARGETS); - } - else if ((pg_strcasecmp(prev4_wd, "TABLESPACE") == 0 && - pg_strcasecmp(prev2_wd, "MOVE") == 0) || - (pg_strcasecmp(prev5_wd, "TABLESPACE") == 0 && - pg_strcasecmp(prev3_wd, "MOVE") == 0 && - pg_strcasecmp(prev2_wd, "MATERIALIZED") == 0)) - { - static const char *const list_TABLESPACEMOVEOPTIONS[] = - {"OWNED BY", "TO", NULL}; - - COMPLETE_WITH_LIST(list_TABLESPACEMOVEOPTIONS); - } /* ALTER TEXT SEARCH */ else if (pg_strcasecmp(prev3_wd, "ALTER") == 0 && --- 1803,1808 ---- *************** *** 2791,2799 **** psql_completion(const char *text, int start, int end) * but we may as well tab-complete both: perhaps some users prefer one * variant or the other. */ ! else if ((pg_strcasecmp(prev3_wd, "FETCH") == 0 || ! pg_strcasecmp(prev3_wd, "MOVE") == 0) && ! pg_strcasecmp(prev_wd, "TO") != 0) { static const char *const list_FROMIN[] = {"FROM", "IN", NULL}; --- 2804,2811 ---- * but we may as well tab-complete both: perhaps some users prefer one * variant or the other. */ ! else if (pg_strcasecmp(prev3_wd, "FETCH") == 0 || ! pg_strcasecmp(prev3_wd, "MOVE") == 0) { static const char *const list_FROMIN[] = {"FROM", "IN", NULL};
-- Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-hackers