pg.ddx.io  pgsql-committers@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Tom Lane <tgl@sss.pgh.pa.us>
To: pgsql-committers@lists.postgresql.org
Subject: pgsql: Invent "MatchAnyN" option for tab-complete.c's Matches/MatchesCS
Date: Mon, 07 Oct 2024 16:31:49 +0000
Message-ID: <E1sxqeD-002ZUH-3w@gemulon.postgresql.org> (raw)

Invent "MatchAnyN" option for tab-complete.c's Matches/MatchesCS.

This argument matches any number (including zero) of previous words.
Use it to replace the common coding pattern

        if (HeadMatches("A", "B") && TailMatches("X", "Y"))

with

        if (Matches("A", "B", MatchAnyN, "X", "Y"))

In itself this feature doesn't do much except (arguably) make the
code slightly shorter and more readable.  However, it reduces the
number of complex if-condition patterns that have to be dealt with
in the next commits in this series.

While here, restructure the *Matches implementation functions so
that the actual work is done in functions that take a char **
array of pattern strings, and the versions taking variadic arguments
are thin wrappers around the array ones.  This simplifies the
new Matches logic considerably.  At the end of this patch series,
the array functions will be the only ones that are material to
performance, so having the variadic ones be wrappers makes sense.

Discussion: https://postgr.es/m/2208466.1720729502@sss.pgh.pa.us

Branch
------
master

Details
-------
https://git.postgresql.org/pg/commitdiff/ef0938f7bdd0838857da38b9a660191ec8411696

Modified Files
--------------
src/bin/psql/tab-complete.c | 400 ++++++++++++++++++++++++++++----------------
1 file changed, 258 insertions(+), 142 deletions(-)



Message-ID: <E1sxqeD-002ZUH-3w@gemulon.postgresql.org>
Permalink:  ../E1sxqeD-002ZUH-3w@gemulon.postgresql.org/
Also on:    postgresql.org/message-id/E1sxqeD-002ZUH-3w@gemulon.postgresql.org

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-committers@postgresql.org
  Cc: tgl@sss.pgh.pa.us, pgsql-committers@lists.postgresql.org
  Subject: Re: pgsql: Invent "MatchAnyN" option for tab-complete.c's Matches/MatchesCS
  In-Reply-To: <E1sxqeD-002ZUH-3w@gemulon.postgresql.org>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox