aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorFujii Masao <fujii@postgresql.org>2025-07-15 18:51:17 +0900
committerFujii Masao <fujii@postgresql.org>2025-07-15 18:51:17 +0900
commitff0bcb248e6ef337902cb26266606c1ab4ea4048 (patch)
treea3ca7c9c320c57ae95f5927a672e06fd8761e184 /src
parent006fc975a2b984249283e953900ac0ee814c5d6b (diff)
downloadpostgresql-ff0bcb248e6ef337902cb26266606c1ab4ea4048.tar.gz
postgresql-ff0bcb248e6ef337902cb26266606c1ab4ea4048.zip
psql: Fix tab-completion after GRANT/REVOKE on LARGE OBJECT and FOREIGN SERVER.
Previously, when pressing Tab after GRANT or REVOKE ... ON LARGE OBJECT or ON FOREIGN SERVER, TO or FROM was incorrectly suggested by psql's tab-completion. This was not appropriate, as those clauses are not valid at that point. This commit fixes the issue by preventing TO and FROM from being offered immediately after those specific GRANT/REVOKE statements. Author: Yugo Nagata <nagata@sraoss.co.jp> Reviewed-by: Fujii Masao <masao.fujii@gmail.com> Discussion: https://postgr.es/m/20250408122857.b2b06dde4e6a08290af02336@sraoss.co.jp
Diffstat (limited to 'src')
-rw-r--r--src/bin/psql/tab-complete.in.c12
1 files changed, 8 insertions, 4 deletions
diff --git a/src/bin/psql/tab-complete.in.c b/src/bin/psql/tab-complete.in.c
index 6872653c6c8..37524364290 100644
--- a/src/bin/psql/tab-complete.in.c
+++ b/src/bin/psql/tab-complete.in.c
@@ -4619,10 +4619,14 @@ match_previous_words(int pattern_id,
else if (Matches("ALTER", "DEFAULT", "PRIVILEGES", MatchAnyN, "TO", MatchAny))
COMPLETE_WITH("WITH GRANT OPTION");
/* Complete "GRANT/REVOKE ... ON * *" with TO/FROM */
- else if (Matches("GRANT", MatchAnyN, "ON", MatchAny, MatchAny))
- COMPLETE_WITH("TO");
- else if (Matches("REVOKE", MatchAnyN, "ON", MatchAny, MatchAny))
- COMPLETE_WITH("FROM");
+ else if (Matches("GRANT|REVOKE", MatchAnyN, "ON", MatchAny, MatchAny) &&
+ !TailMatches("FOREIGN", "SERVER") && !TailMatches("LARGE", "OBJECT"))
+ {
+ if (Matches("GRANT", MatchAnyN, "ON", MatchAny, MatchAny))
+ COMPLETE_WITH("TO");
+ else
+ COMPLETE_WITH("FROM");
+ }
/* Complete "GRANT/REVOKE * ON ALL * IN SCHEMA *" with TO/FROM */
else if (TailMatches("GRANT|REVOKE", MatchAny, "ON", "ALL", MatchAny, "IN", "SCHEMA", MatchAny) ||