Skip to content

Commit 8ae22e7

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 2c5b57e commit 8ae22e7

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
@@ -1001,7 +1001,7 @@ psql_completion(const char *text, int start, int end)
10011001

10021002
COMPLETE_WITH_LIST(list_ALTER);
10031003
}
1004-
/* ALTER TABLE,INDEX,MATERIALIZED VIEW xxx ALL IN TABLESPACE xxx */
1004+
/* ALTER TABLE,INDEX,MATERIALIZED VIEW ALL IN TABLESPACE xxx */
10051005
else if (pg_strcasecmp(prev4_wd, "ALL") == 0 &&
10061006
pg_strcasecmp(prev3_wd, "IN") == 0 &&
10071007
pg_strcasecmp(prev2_wd, "TABLESPACE") == 0)
@@ -1011,15 +1011,23 @@ psql_completion(const char *text, int start, int end)
10111011

10121012
COMPLETE_WITH_LIST(list_ALTERALLINTSPC);
10131013
}
1014-
/* ALTER TABLE,INDEX,MATERIALIZED VIEW xxx ALL IN TABLESPACE xxx OWNED BY */
1014+
/* ALTER TABLE,INDEX,MATERIALIZED VIEW ALL IN TABLESPACE xxx OWNED BY */
10151015
else if (pg_strcasecmp(prev6_wd, "ALL") == 0 &&
10161016
pg_strcasecmp(prev5_wd, "IN") == 0 &&
10171017
pg_strcasecmp(prev4_wd, "TABLESPACE") == 0 &&
10181018
pg_strcasecmp(prev2_wd, "OWNED") == 0 &&
1019-
pg_strcasecmp(prev4_wd, "BY") == 0)
1019+
pg_strcasecmp(prev_wd, "BY") == 0)
10201020
{
10211021
COMPLETE_WITH_QUERY(Query_for_list_of_roles);
10221022
}
1023+
/* ALTER TABLE,INDEX,MATERIALIZED VIEW ALL IN TABLESPACE xxx OWNED BY xxx */
1024+
else if (pg_strcasecmp(prev6_wd, "IN") == 0 &&
1025+
pg_strcasecmp(prev5_wd, "TABLESPACE") == 0 &&
1026+
pg_strcasecmp(prev3_wd, "OWNED") == 0 &&
1027+
pg_strcasecmp(prev2_wd, "BY") == 0)
1028+
{
1029+
COMPLETE_WITH_CONST("SET TABLESPACE");
1030+
}
10231031
/* ALTER AGGREGATE,FUNCTION <name> */
10241032
else if (pg_strcasecmp(prev3_wd, "ALTER") == 0 &&
10251033
(pg_strcasecmp(prev2_wd, "AGGREGATE") == 0 ||

0 commit comments

Comments
 (0)