Commit 202cbdf7 authored by Fujii Masao's avatar Fujii Masao

Add tab-completion for ALTER TABLE ALTER CONSTRAINT in psql.

Back-patch to 9.4 where ALTER TABLE ALTER CONSTRAINT was added.

Michael Paquier, bug reported by Andrey Lizenko.
parent afeacd27
...@@ -1605,7 +1605,7 @@ psql_completion(const char *text, int start, int end) ...@@ -1605,7 +1605,7 @@ psql_completion(const char *text, int start, int end)
else if (pg_strcasecmp(prev4_wd, "ALTER") == 0 && else if (pg_strcasecmp(prev4_wd, "ALTER") == 0 &&
pg_strcasecmp(prev3_wd, "TABLE") == 0 && pg_strcasecmp(prev3_wd, "TABLE") == 0 &&
pg_strcasecmp(prev_wd, "ALTER") == 0) pg_strcasecmp(prev_wd, "ALTER") == 0)
COMPLETE_WITH_ATTR(prev2_wd, " UNION SELECT 'COLUMN'"); COMPLETE_WITH_ATTR(prev2_wd, " UNION SELECT 'COLUMN' UNION SELECT 'CONSTRAINT'");
/* ALTER TABLE xxx RENAME */ /* ALTER TABLE xxx RENAME */
else if (pg_strcasecmp(prev4_wd, "ALTER") == 0 && else if (pg_strcasecmp(prev4_wd, "ALTER") == 0 &&
...@@ -1655,12 +1655,13 @@ psql_completion(const char *text, int start, int end) ...@@ -1655,12 +1655,13 @@ psql_completion(const char *text, int start, int end)
COMPLETE_WITH_ATTR(prev3_wd, ""); COMPLETE_WITH_ATTR(prev3_wd, "");
/* /*
* If we have ALTER TABLE <sth> DROP|RENAME|VALIDATE CONSTRAINT, provide * If we have ALTER TABLE <sth> ALTER|DROP|RENAME|VALIDATE CONSTRAINT,
* list of constraints * provide list of constraints
*/ */
else if (pg_strcasecmp(prev5_wd, "ALTER") == 0 && else if (pg_strcasecmp(prev5_wd, "ALTER") == 0 &&
pg_strcasecmp(prev4_wd, "TABLE") == 0 && pg_strcasecmp(prev4_wd, "TABLE") == 0 &&
(pg_strcasecmp(prev2_wd, "DROP") == 0 || (pg_strcasecmp(prev2_wd, "ALTER") == 0 ||
pg_strcasecmp(prev2_wd, "DROP") == 0 ||
pg_strcasecmp(prev2_wd, "RENAME") == 0 || pg_strcasecmp(prev2_wd, "RENAME") == 0 ||
pg_strcasecmp(prev2_wd, "VALIDATE") == 0) && pg_strcasecmp(prev2_wd, "VALIDATE") == 0) &&
pg_strcasecmp(prev_wd, "CONSTRAINT") == 0) pg_strcasecmp(prev_wd, "CONSTRAINT") == 0)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment