From 1fb26e286e949080758e5a7854ef764c6465d3a7 Mon Sep 17 00:00:00 2001 From: Miwa-Haruna Date: Thu, 1 Oct 2026 06:26:31 +0000 Subject: [PATCH v2] 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, 8 insertions(+), 1 deletion(-) diff --git a/src/bin/psql/tab-complete.in.c b/src/bin/psql/tab-complete.in.c index 8e1a1d69740..8e559e6e6c1 100644 --- a/src/bin/psql/tab-complete.in.c +++ b/src/bin/psql/tab-complete.in.c @@ -2185,7 +2185,14 @@ match_previous_words(int pattern_id, /* CREATE */ /* complete with something you can create */ - else if (TailMatches("CREATE")) + else if (TailMatches("CREATE") && + + /* + * exclude cases of GRANT/REVOKE CREATE and REVOKE GRANT OPTION FOR + * 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