From d58981633445c5a3fa71fdcfac1ecea22748a5c9 Mon Sep 17 00:00:00 2001 From: Miwa-Haruna Date: Thu, 1 Oct 2026 06:26:31 +0000 Subject: [PATCH v3] psql: avoid CREATE command completion after GRANT/REVOKE CREATE Prevent the generic CREATE command completion logic from being triggered when completing GRANT CREATE or REVOKE CREATE statements. Signed-off-by: Haruna Miwa --- src/bin/psql/tab-complete.in.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/bin/psql/tab-complete.in.c b/src/bin/psql/tab-complete.in.c index 8e1a1d69740..035fe488cf4 100644 --- a/src/bin/psql/tab-complete.in.c +++ b/src/bin/psql/tab-complete.in.c @@ -2184,8 +2184,13 @@ match_previous_words(int pattern_id, /* BEGIN GEN_TABCOMPLETE */ /* CREATE */ - /* complete with something you can create */ - else if (TailMatches("CREATE")) +/* + * Complete with something you can create. If CREATE is a privilege + * name, leave it to the GRANT/REVOKE rules below. + */ + else if (TailMatches("CREATE") && + !TailMatches("GRANT|REVOKE", "CREATE") && + !TailMatches("REVOKE", "GRANT", "OPTION", "FOR", "CREATE")) { /* only some object types can be created as part of CREATE SCHEMA */ if (HeadMatches("CREATE", "SCHEMA")) -- 2.47.3