]> granicus.if.org Git - postgresql/commitdiff
Fix tab completion for ALTER ... TABLESPACE ... OWNED BY.
authorAndres Freund <andres@anarazel.de>
Sat, 19 Dec 2015 16:37:11 +0000 (17:37 +0100)
committerAndres Freund <andres@anarazel.de>
Sat, 19 Dec 2015 16:37:11 +0000 (17:37 +0100)
Previously the completion used the wrong word to match 'BY'. This was
introduced brokenly, in b2de2a. While at it, also add completion of
IN TABLESPACE ... OWNED BY and fix comments referencing nonexistent
syntax.

Reported-By: Michael Paquier
Author: Michael Paquier and Andres Freund
Discussion: CAB7nPqSHDdSwsJqX0d2XzjqOHr==HdWiubCi4L=Zs7YFTUne8w@mail.gmail.com
Backpatch: 9.4, like the commit introducing the bug

src/bin/psql/tab-complete.c

index 8c4888119d861e586395889a066e2df8a67981c4..9ce0978b714ed5ba745c665b2c1d82f7c1f2ea15 100644 (file)
@@ -1025,7 +1025,7 @@ psql_completion(const char *text, int start, int end)
 
                COMPLETE_WITH_LIST(list_ALTER);
        }
-       /* ALTER TABLE,INDEX,MATERIALIZED VIEW xxx ALL IN TABLESPACE xxx */
+       /* ALTER TABLE,INDEX,MATERIALIZED VIEW ALL IN TABLESPACE xxx */
        else if (pg_strcasecmp(prev4_wd, "ALL") == 0 &&
                         pg_strcasecmp(prev3_wd, "IN") == 0 &&
                         pg_strcasecmp(prev2_wd, "TABLESPACE") == 0)
@@ -1035,15 +1035,23 @@ psql_completion(const char *text, int start, int end)
 
                COMPLETE_WITH_LIST(list_ALTERALLINTSPC);
        }
-       /* ALTER TABLE,INDEX,MATERIALIZED VIEW xxx ALL IN TABLESPACE xxx OWNED BY */
+       /* ALTER TABLE,INDEX,MATERIALIZED VIEW 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)
+                        pg_strcasecmp(prev_wd, "BY") == 0)
        {
                COMPLETE_WITH_QUERY(Query_for_list_of_roles);
        }
+       /* ALTER TABLE,INDEX,MATERIALIZED VIEW ALL IN TABLESPACE xxx OWNED BY xxx */
+       else if (pg_strcasecmp(prev6_wd, "IN") == 0 &&
+                        pg_strcasecmp(prev5_wd, "TABLESPACE") == 0 &&
+                        pg_strcasecmp(prev3_wd, "OWNED") == 0 &&
+                        pg_strcasecmp(prev2_wd, "BY") == 0)
+       {
+               COMPLETE_WITH_CONST("SET TABLESPACE");
+       }
        /* ALTER AGGREGATE,FUNCTION <name> */
        else if (pg_strcasecmp(prev3_wd, "ALTER") == 0 &&
                         (pg_strcasecmp(prev2_wd, "AGGREGATE") == 0 ||