]> granicus.if.org Git - postgresql/commitdiff
Add tab-completion for ALTER TABLE ALTER CONSTRAINT in psql.
authorFujii Masao <fujii@postgresql.org>
Fri, 28 Nov 2014 12:29:45 +0000 (21:29 +0900)
committerFujii Masao <fujii@postgresql.org>
Fri, 28 Nov 2014 12:30:20 +0000 (21:30 +0900)
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

index afb5e9962e020a315b3ace21293c316499fbddfc..6126f7407aee87d1601c1972a0951ae7e34ce3d4 100644 (file)
@@ -1483,7 +1483,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 &&
@@ -1533,12 +1533,13 @@ psql_completion(const char *text, int start, int end)
                COMPLETE_WITH_ATTR(prev3_wd, "");
 
        /*
-        * If we have ALTER TABLE <sth> DROP|RENAME|VALIDATE CONSTRAINT, provide
-        * list of constraints
+        * If we have ALTER TABLE <sth> 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)