Re: Tab completion for CREATE SCHEMAAUTHORIZATION

From: Michael Paquier <michael(at)paquier(dot)xyz>
To: Dagfinn Ilmari Mannsåker <ilmari(at)ilmari(dot)org>
Cc: Suraj Khamkar <khamkarsuraj(dot)b(at)gmail(dot)com>, pgsql-hackers(at)lists(dot)postgresql(dot)org
Subject: Re: Tab completion for CREATE SCHEMAAUTHORIZATION
Date: 2021-08-11 01:16:15
Message-ID: YRMk378EUuVmJ2Fq@paquier.xyz
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Mon, Aug 09, 2021 at 07:00:02PM +0100, Dagfinn Ilmari Mannsåker wrote:
> Thanks for the review. Updated patch attached, with the CURRENT/SESSION
> ROLE/USER changes for other commands separated out.

+#define Query_for_list_of_owner_roles \
+Query_for_list_of_roles \
" UNION ALL SELECT 'CURRENT_ROLE'"\
" UNION ALL SELECT 'CURRENT_USER'"\
" UNION ALL SELECT 'SESSION_USER'"
I don't object to the refactoring you are doing here with three
Query_for_list_of_*_roles each one depending on the other for clarity.
Neither do I really object to not using COMPLETE_WITH_QUERY() with
some extra UNION ALL hardcoded in each code path as there 6 cases for
_owner_, 6 for _grant_ and 6 for _roles if my count is right. Still,
if I may ask, wouldn't it be better to document a bit what's the
expectation behind each one of them? Perhaps the names of the queries
are too generic for the purposes where they are used (say _grant_ for
CREATE USER MAPPING looks confusing)?

+ else if (Matches("CREATE", "SCHEMA", "AUTHORIZATION"))
+ COMPLETE_WITH_QUERY(Query_for_list_of_owner_roles);
+ else if (Matches("CREATE", "SCHEMA", MatchAny, "AUTHORIZATION"))
+ COMPLETE_WITH_QUERY(Query_for_list_of_owner_roles);
+ else if (Matches("CREATE", "SCHEMA", MatchAny, "AUTHORIZATION", MatchAny))
+ COMPLETE_WITH("CREATE", "GRANT");
+ else if (Matches("CREATE", "SCHEMA", MatchAny))
+ COMPLETE_WITH("AUTHORIZATION", "CREATE", "GRANT");
Looks like you forgot the case "CREATE SCHEMA AUTHORIZATION MatchAny"
that should be completed by GRANT and CREATE.
--
Michael

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Michael Paquier 2021-08-11 01:25:02 Re: Postgres perl module namespace
Previous Message Peter Geoghegan 2021-08-11 00:48:19 Re: Postgres picks suboptimal index after building of an extended statistics