aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStephen Frost <sfrost@snowman.net>2014-09-07 08:04:35 -0400
committerStephen Frost <sfrost@snowman.net>2014-09-07 08:09:36 -0400
commit4231599328f75d6549831f65223a22236a43a5c9 (patch)
treeffa660267297e3778b9585a27934a785314a73cd
parent31189e8627cdbdb72d16d0314d95b1aea913e616 (diff)
downloadpostgresql-4231599328f75d6549831f65223a22236a43a5c9.tar.gz
postgresql-4231599328f75d6549831f65223a22236a43a5c9.zip
Tab completion for ALTER .. ALL IN TABLESPACE
Update the tab completion for the changes made in 3c4cf080879b386d4ed1814667aca025caafe608, which rework 'MOVE ALL' to be 'ALTER .. ALL IN TABLESPACE'. Fujii Masao Back-patch to 9.4, as the original change was.
-rw-r--r--src/bin/psql/tab-complete.c66
1 files changed, 39 insertions, 27 deletions
diff --git a/src/bin/psql/tab-complete.c b/src/bin/psql/tab-complete.c
index e0ee381a89e..d09b4256d1c 100644
--- a/src/bin/psql/tab-complete.c
+++ b/src/bin/psql/tab-complete.c
@@ -931,6 +931,13 @@ psql_completion(const char *text, int start, int end)
/* 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
@@ -948,6 +955,25 @@ psql_completion(const char *text, int start, int end)
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 ||
@@ -1083,6 +1109,13 @@ psql_completion(const char *text, int start, int end)
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)
@@ -1146,7 +1179,8 @@ 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);
+ COMPLETE_WITH_SCHEMA_QUERY(Query_for_list_of_matviews,
+ "UNION SELECT 'ALL IN TABLESPACE'");
}
/* ALTER USER,ROLE <name> */
@@ -1667,12 +1701,12 @@ psql_completion(const char *text, int start, int end)
COMPLETE_WITH_CONST("IDENTITY");
}
- /* ALTER TABLESPACE <foo> with RENAME TO, OWNER TO, SET, RESET, MOVE */
+ /* 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", "MOVE", NULL};
+ {"RENAME TO", "OWNER TO", "SET", "RESET", NULL};
COMPLETE_WITH_LIST(list_ALTERTSPC);
}
@@ -1694,27 +1728,6 @@ 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 &&
@@ -2669,9 +2682,8 @@ 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)
+ else if (pg_strcasecmp(prev3_wd, "FETCH") == 0 ||
+ pg_strcasecmp(prev3_wd, "MOVE") == 0)
{
static const char *const list_FROMIN[] =
{"FROM", "IN", NULL};