Skip to content

Commit bf4817e

Browse files
committed
Fix incorrect tab-completion for GRANT and REVOKE
Previously "GRANT * ON * TO " was tab-completed to add an extra "TO", rather than with a list of roles. This is the bug that commit 2f88807 introduced unexpectedly. This commit fixes that incorrect tab-completion. Thomas Munro, reviewed by Jeff Janes.
1 parent 21995d3 commit bf4817e

File tree

1 file changed

+9
-9
lines changed

1 file changed

+9
-9
lines changed

src/bin/psql/tab-complete.c

+9-9
Original file line numberDiff line numberDiff line change
@@ -3227,15 +3227,6 @@ psql_completion(const char *text, int start, int end)
32273227
COMPLETE_WITH_CONST("FROM");
32283228
}
32293229

3230-
/* Complete "GRANT/REVOKE * ON * *" with TO/FROM */
3231-
else if (pg_strcasecmp(prev5_wd, "GRANT") == 0 &&
3232-
pg_strcasecmp(prev3_wd, "ON") == 0)
3233-
COMPLETE_WITH_CONST("TO");
3234-
3235-
else if (pg_strcasecmp(prev5_wd, "REVOKE") == 0 &&
3236-
pg_strcasecmp(prev3_wd, "ON") == 0)
3237-
COMPLETE_WITH_CONST("FROM");
3238-
32393230
/* Complete "GRANT/REVOKE * ON ALL * IN SCHEMA *" with TO/FROM */
32403231
else if ((pg_strcasecmp(prev8_wd, "GRANT") == 0 ||
32413232
pg_strcasecmp(prev8_wd, "REVOKE") == 0) &&
@@ -3295,6 +3286,15 @@ psql_completion(const char *text, int start, int end)
32953286
pg_strcasecmp(prev_wd, "FROM") == 0))
32963287
COMPLETE_WITH_QUERY(Query_for_list_of_grant_roles);
32973288

3289+
/* Complete "GRANT/REVOKE * ON * *" with TO/FROM */
3290+
else if (pg_strcasecmp(prev5_wd, "GRANT") == 0 &&
3291+
pg_strcasecmp(prev3_wd, "ON") == 0)
3292+
COMPLETE_WITH_CONST("TO");
3293+
3294+
else if (pg_strcasecmp(prev5_wd, "REVOKE") == 0 &&
3295+
pg_strcasecmp(prev3_wd, "ON") == 0)
3296+
COMPLETE_WITH_CONST("FROM");
3297+
32983298
/*
32993299
* Complete "GRANT/REVOKE * TO/FROM" with username, PUBLIC,
33003300
* CURRENT_USER, or SESSION_USER.

0 commit comments

Comments
 (0)