Re: PATCH: psql tab completion for SELECT

Joao De Almeida Pereira <jdealmeidapereira@pivotal.io>

From: Joao De Almeida Pereira <jdealmeidapereira@pivotal.io>
To: ejrh00@gmail.com, hlinnaka@iki.fi
Cc: pgsql-hackers@lists.postgresql.org
Date: 2018-07-16T15:27:27Z
Lists: pgsql-hackers
Hello,

postgres=# select partkey, partc[TAB]
> [no completions]
>

From the thread, I believe that this feature will be implemented in a after
patch.

>
> And I'd love this case, where go back to edit the SELECT list, after
> already typing the FROM part, to be smarter:
>
> postgres=# select p[TAB] FROM lp;
> Display all 370 possibilities? (y or n)
>

I believe this would be a very interesting feature indeed.


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

Commits

  1. In psql, restore old behavior of Query_for_list_of_functions.

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