postgres.git / summary / log / commit / refs
commit a87ae38be844a140786bf2fb3f3f8a094d51fa26
Author: Fujii Masao <fujii@postgresql.org>
Date: Fri Jan 31 16:45:48 2014 +0000
First released in: 9.4.0
Add tab completion for ALTER TABLESPACE MOVE in psql.
src/bin/psql/tab-complete.c | 30 ++++++++++++++++++++++++++----
1 file changed, 26 insertions(+), 4 deletions(-)
diff --git a/src/bin/psql/tab-complete.c b/src/bin/psql/tab-complete.c
index 5a6fe7d2d79..1d69b953878 100644
--- a/src/bin/psql/tab-complete.c
+++ b/src/bin/psql/tab-complete.c
@@ -1622,12 +1622,12 @@ psql_completion(char *text, int start, int end)
COMPLETE_WITH_CONST("IDENTITY");
}
- /* ALTER TABLESPACE <foo> with RENAME TO, OWNER TO, SET, RESET */
+ /* 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", NULL};
+ {"RENAME TO", "OWNER TO", "SET", "RESET", "MOVE", NULL};
COMPLETE_WITH_LIST(list_ALTERTSPC);
}
@@ -1649,6 +1649,27 @@ psql_completion(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 &&
@@ -2559,8 +2580,9 @@ psql_completion(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)
+ 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};
[parent: 5ff47acf8f2d]