From 202cbdf7821b4e83694794bfa9f05a376ccad8cd Mon Sep 17 00:00:00 2001 From: Fujii Masao Date: Fri, 28 Nov 2014 21:29:45 +0900 Subject: [PATCH] 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. --- src/bin/psql/tab-complete.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/bin/psql/tab-complete.c b/src/bin/psql/tab-complete.c index 1bb5a8373f..7a509c1e45 100644 --- a/src/bin/psql/tab-complete.c +++ b/src/bin/psql/tab-complete.c @@ -1605,7 +1605,7 @@ psql_completion(const char *text, int start, int end) else if (pg_strcasecmp(prev4_wd, "ALTER") == 0 && pg_strcasecmp(prev3_wd, "TABLE") == 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 */ else if (pg_strcasecmp(prev4_wd, "ALTER") == 0 && @@ -1655,12 +1655,13 @@ psql_completion(const char *text, int start, int end) COMPLETE_WITH_ATTR(prev3_wd, ""); /* - * If we have ALTER TABLE DROP|RENAME|VALIDATE CONSTRAINT, provide - * list of constraints + * If we have ALTER TABLE ALTER|DROP|RENAME|VALIDATE CONSTRAINT, + * provide list of constraints */ else if (pg_strcasecmp(prev5_wd, "ALTER") == 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, "VALIDATE") == 0) && pg_strcasecmp(prev_wd, "CONSTRAINT") == 0) -- 2.40.0