Re: Getting PSQL in Windows to support TAB/Autocomplete via modified readline... - Mailing list pgsql-general

From Kirk Wolak
Subject Re: Getting PSQL in Windows to support TAB/Autocomplete via modified readline...
Date
Msg-id CACLU5mS3DxRTaQ81Mu8qXvbBm50Ezk0N0a1KuvYgNupzUPU8QQ@mail.gmail.com
Whole thread Raw
In response to Re: Getting PSQL in Windows to support TAB/Autocomplete via modified readline...  (Tom Lane <tgl@sss.pgh.pa.us>)
List pgsql-general
On Wed, Nov 23, 2022 at 9:57 PM Tom Lane <tgl@sss.pgh.pa.us> wrote:
Andres Freund <andres@anarazel.de> writes:
> I think it'd be easier to deal with this if COMPLETE_WITH_* caused the the
> containing function to return. Then the completions wouldn't need to be in one
> huge if-else if. Leaving msvc aside, that also seems nice for efficiency.

Yeah, that could be an easy quick-fix.  We'd need to refactor so that
the cleanup housekeeping at the bottom of psql_completion() was in a
wrapper function, but perhaps that wouldn't be too messy.

                        regards, tom lane

Thinking about how this code is structured, maybe psql_completion() becomes the wrapper:
psql_completion()
{
// Pre-amble, setup
  psql_parse_completion(...); // if/else structure moved
// house keeping for the returns
}

psql_parse_completion(...)
{
// more complex preamble stuff
...
// an EXTRA trap if nothing matched unexpectedly is now possible if everything else returns?
}

After dealing with this code, the flow was hard to follow, something like this makes it easier.
Also, at some point, if we wanted to write an alternative "grammar driven" approach, we could
literally call both procedures and compare the results for validation...

regards Kirk



pgsql-general by date:

Previous
From: Kirk Wolak
Date:
Subject: Re: Getting PSQL in Windows to support TAB/Autocomplete via modified readline...
Next
From: Nikolas Hanry
Date:
Subject: Fwd: Change the auth. postgresql and GIS