Skip to content

Commit 9f74926

Browse files
committed
Fix tab completion for ALTER ... TABLESPACE ... OWNED BY.
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
1 parent acb6c64 commit 9f74926

File tree

1 file changed

+11
-3
lines changed

1 file changed

+11
-3
lines changed

src/bin/psql/tab-complete.c

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -956,7 +956,7 @@ psql_completion(const char *text, int start, int end)
956956

957957
COMPLETE_WITH_LIST(list_ALTER);
958958
}
959-
/* ALTER TABLE,INDEX,MATERIALIZED VIEW xxx ALL IN TABLESPACE xxx */
959+
/* ALTER TABLE,INDEX,MATERIALIZED VIEW ALL IN TABLESPACE xxx */
960960
else if (pg_strcasecmp(prev4_wd, "ALL") == 0 &&
961961
pg_strcasecmp(prev3_wd, "IN") == 0 &&
962962
pg_strcasecmp(prev2_wd, "TABLESPACE") == 0)
@@ -966,15 +966,23 @@ psql_completion(const char *text, int start, int end)
966966

967967
COMPLETE_WITH_LIST(list_ALTERALLINTSPC);
968968
}
969-
/* ALTER TABLE,INDEX,MATERIALIZED VIEW xxx ALL IN TABLESPACE xxx OWNED BY */
969+
/* ALTER TABLE,INDEX,MATERIALIZED VIEW ALL IN TABLESPACE xxx OWNED BY */
970970
else if (pg_strcasecmp(prev6_wd, "ALL") == 0 &&
971971
pg_strcasecmp(prev5_wd, "IN") == 0 &&
972972
pg_strcasecmp(prev4_wd, "TABLESPACE") == 0 &&
973973
pg_strcasecmp(prev2_wd, "OWNED") == 0 &&
974-
pg_strcasecmp(prev4_wd, "BY") == 0)
974+
pg_strcasecmp(prev_wd, "BY") == 0)
975975
{
976976
COMPLETE_WITH_QUERY(Query_for_list_of_roles);
977977
}
978+
/* ALTER TABLE,INDEX,MATERIALIZED VIEW ALL IN TABLESPACE xxx OWNED BY xxx */
979+
else if (pg_strcasecmp(prev6_wd, "IN") == 0 &&
980+
pg_strcasecmp(prev5_wd, "TABLESPACE") == 0 &&
981+
pg_strcasecmp(prev3_wd, "OWNED") == 0 &&
982+
pg_strcasecmp(prev2_wd, "BY") == 0)
983+
{
984+
COMPLETE_WITH_CONST("SET TABLESPACE");
985+
}
978986
/* ALTER AGGREGATE,FUNCTION <name> */
979987
else if (pg_strcasecmp(prev3_wd, "ALTER") == 0 &&
980988
(pg_strcasecmp(prev2_wd, "AGGREGATE") == 0 ||

0 commit comments

Comments
 (0)