RE: Psql meta-command conninfo+

From: Maiquel Grassi <grassi(at)hotmail(dot)com(dot)br>
To: Jim Jones <jim(dot)jones(at)uni-muenster(dot)de>, Erik Wienhold <ewie(at)ewie(dot)name>
Cc: Pavel Luzanov <p(dot)luzanov(at)postgrespro(dot)ru>, Nathan Bossart <nathandbossart(at)gmail(dot)com>, "pgsql-hackers(at)postgresql(dot)org" <pgsql-hackers(at)postgresql(dot)org>
Subject: RE: Psql meta-command conninfo+
Date: 2024-02-09 02:00:11
Message-ID: CP8P284MB2496BA609AD64698B5550A58EC4B2@CP8P284MB2496.BRAP284.PROD.OUTLOOK.COM
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On 08.02.24 21:37, Erik Wienhold wrote:
>> Modifiers such as + or S in \dS are not covered by autocompletion.
>> src/bin/psql/tab-complete.c only specifies backslash commands in their
>> basic form (without modifiers).
>>
>> (\dS<TAB> actually autocompletes to \ds to my surprise)
>>
>Aha... I never noticed it. Well, with most commands having 1 - 3
>characters it is not a surprised I never used it :)
>That "\dS<TAB>" autocompletes to "\ds " surprises me even more.
>Thanks for pointing out!

--//--

Good evening, dear all!

Here is the mechanism that implements this:

https://github.com/postgres/postgres/blob/b619852086ed2b5df76631f5678f60d3bebd3745/src/bin/psql/tab-complete.h

.
.
.
1673       /* Match the last N words before point, case-sensitively. */

1674 #define TailMatchesCS(...) \
1675       TailMatchesImpl(true, previous_words_count, previous_words, \

1676                               VA_ARGS_NARGS(__VA_ARGS__), __VA_ARGS__)
.
.
.
4824       else if (TailMatchesCS("\\ds*"))
4825             COMPLETE_WITH_SCHEMA_QUERY(Query_for_list_of_sequences);
.
.
.

There is a rather large list of meta-commands that are handled by TailMatchesCS(...).

For example:
\ENCODING<TAB> autocompletes to \encoding
\eNcOdInG<TAB> autocompletes to \encoding
\dU<TAB> or \DU<TAB> autocompletes to \du

Including the command under discussion:
\CONNINFO<TAB> autocompletes to \conninfo

For the meta-commands[+], there is no autocomplete.

Regards,
Maiquel Grassi.

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Jeevan Chalke 2024-02-09 02:02:50 Re: recently added jsonpath method change jsonb_path_query, jsonb_path_query_first immutability
Previous Message Michael Paquier 2024-02-09 00:54:53 Re: Make COPY format extendable: Extract COPY TO format implementations