Re: PATCH: psql tab completion for SELECT

Edmund Horner <ejrh00@gmail.com>

From: Edmund Horner <ejrh00@gmail.com>
To: Joao De Almeida Pereira <jdealmeidapereira@pivotal.io>
Cc: Heikki Linnakangas <hlinnaka@iki.fi>, PostgreSQL Developers <pgsql-hackers@lists.postgresql.org>
Date: 2018-07-17T01:44:59Z
Lists: pgsql-hackers
On 17 July 2018 at 03:27, Joao De Almeida Pereira
<jdealmeidapereira@pivotal.io> wrote:
> After playing alittle bit around with the patch I noticed that a comma was
> missing in line 1214
> + 1202                 /* min_server_version */
> + 1203                 90000,
> + 1204                 /* catname */
> + 1205                 "pg_catalog.pg_proc p",
> + 1206                 /* selcondition */
> + 1207                 "p.prorettype NOT IN ('trigger'::regtype,
> 'internal'::regtype) "
> + 1208                 "AND 'internal'::regtype != ALL (p.proargtypes) "
> + 1209                 "AND p.oid NOT IN (SELECT
> unnest(array[typinput,typoutput,typreceive,typsend,typmodin,typmodout,typanalyze])
> FROM pg_type) "
> + 1210                 "AND p.oid NOT IN (SELECT
> unnest(array[aggtransfn,aggfinalfn]) FROM pg_aggregate) "
> + 1211                 "AND p.oid NOT IN (SELECT
> unnest(array[oprcode,oprrest,oprjoin]) FROM pg_operator) "
> + 1212                 "AND p.oid NOT IN (SELECT
> unnest(array[lanplcallfoid,laninline,lanvalidator]) FROM pg_language) "
> + 1213                 "AND p.oid NOT IN (SELECT castfunc FROM pg_cast) "
> + 1214                 "AND p.oid NOT IN (SELECT amproc FROM pg_amproc) "
> + 1215                 /* viscondition */
> + 1216                 "pg_catalog.pg_function_is_visible(p.oid)",
>
> To catch these typos would be good if we could get some testing around psql.
> (Newbie question: do we have any kind of testing around tools like psql?)
>
> Thanks
> Joao

Hi Joao,

Ah yes, the embarrassing missing comma.  I kind of wish my IDE or
compiler had pointed it out to me, but how was it to know that I
foolishly combining two struct fields?  Sadly, I think the best
defence right now is to have others scrutinise the code.

I attached a new version of the patch in reply to Heikki.  Would you
care to take a careful look for me?

I think some automated test framework for the tab completion queries
is possible, by calling psql_completion and examining the results.
Maybe someone will volunteer...

Edmund


Commits

  1. In psql, restore old behavior of Query_for_list_of_functions.

  2. Add infrastructure to support server-version-dependent tab completion.