Re: [PATCH] psql: Complete GRANTED BY in GRANT and REVOKE

From: Neil Chen <carpenter(dot)nail(dot)cz(at)gmail(dot)com>
To: Chao Li <li(dot)evan(dot)chao(at)gmail(dot)com>
Cc: Postgres hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org>
Subject: Re: [PATCH] psql: Complete GRANTED BY in GRANT and REVOKE
Date: 2026-11-25 01:34:06
Message-ID: CAA3qoJk97GZDKx=LF6OuCXJ3U61=hGg-zqvcv2yigby4OihxTw@mail.gmail.com
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Hi Chao,

Thanks for the review.

On Wed, Nov 25, 2026 at 7:36 AM Chao Li <li(dot)evan(dot)chao(at)gmail(dot)com> wrote:

>
> After “GRANTED BY x”, [ CASCADE | RESTRICT ] can be specified, so we
> should support them as well.
>
>
I added both after the grantor and alongside GRANTED BY after the
grantee, since the grantor clause is optional.

>
> Is the check of comma really needed? At least for the latter 2 matches,
> prev2_wd would be OPTION|TRUE|FALSE, impossible to be comma.
>
> In the immediate next branch, the check on prev3_wd has a similar problem.
>
>
You're right about the WITH forms. The GROUP and comma checks are
now part of the grantee matches, where granted can be a role name,
as in FROM alice, granted. After the full GRANTED BY, a single rule
looks up the grantor for either command, even after a list. I removed
the second comma check there. The lookup leaves out PUBLIC, which
can't be a brantor.

I kept keyword completion to one grantee word or one WITH option,
following the existing GRANT completion rules.
For role membership options, the name can be quoted, so the rule
matches the value and uses a wildcard for the name.

Attached is v2.

Thanks,

--
Ze Chen (Neil)
HighGo Software Co., Ltd.
https://www.highgo.com/

Attachment Content-Type Size
v2-0001-psql-Complete-GRANTED-BY-in-GRANT-and-REVOKE.patch text/x-patch 4.5 KB

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Manu 2026-11-25 01:42:32 Re: pgsql: Don't trust NOT NULL on virtual generated columns of partitioned
Previous Message Amit Langote 2026-11-25 01:20:29 Re: Should we skip foreign key checks in binary upgrade mode?