Re: Miscellaneous tab completion issue fixes

From: Dagfinn Ilmari Mannsåker <ilmari(at)ilmari(dot)org>
To: vignesh C <vignesh21(at)gmail(dot)com>
Cc: PostgreSQL Hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org>
Subject: Re: Miscellaneous tab completion issue fixes
Date: 2022-10-03 17:29:32
Message-ID: 875yh0lssj.fsf@wibble.ilmari.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

vignesh C <vignesh21(at)gmail(dot)com> writes:

> Hi,
>
> There were a couple of tab completion issues present:
> a) \dRp and \dRs tab completion displays tables instead of displaying
> publications and subscriptions.
> b) "ALTER ... OWNER TO" does not include displaying of CURRENT_ROLE,
> CURRENT_USER and SESSION_USER.
>
> The attached patch has the changes to handle the same.

Good catches! Just a few comments:

> + else if (TailMatchesCS("\\dRp*"))
> + COMPLETE_WITH_QUERY(Query_for_list_of_publications[0].query);
> + else if (TailMatchesCS("\\dRs*"))
> + COMPLETE_WITH_QUERY(Query_for_list_of_subscriptions[0].query);

These are version-specific queries, so should be passed in their
entirety to COMPLETE_WITH_VERSIONED_QUERY() so that psql can pick the
right version, and avoid sending the query at all if the server is too
old.

> +/* add these to Query_for_list_of_roles in OWNER TO contexts */
> +#define Keywords_for_list_of_owner_to_roles \
> +"CURRENT_ROLE", "CURRENT_USER", "SESSION_USER"

I think this would read better without the TO, both in the comment and
the constant name, similar to the below only having GRANT without TO:

> /* add these to Query_for_list_of_roles in GRANT contexts */
> #define Keywords_for_list_of_grant_roles \
> "PUBLIC", "CURRENT_ROLE", "CURRENT_USER", "SESSION_USER"

- ilmari

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Matthias van de Meent 2022-10-03 17:40:30 Re: problems with making relfilenodes 56-bits
Previous Message Tomas Vondra 2022-10-03 17:21:55 Re: Question: test "aggregates" failed in 32-bit machine