Documentation of psql's \df no longer matches reality

Started by Tom Lanealmost 3 years ago2 messages
#1Tom Lane
tgl@sss.pgh.pa.us

While preparing 3dfae91f7 I couldn't help noticing that what
psql-ref.sgml has to say about \df's "function type" column:

... and function types, which are classified as <quote>agg</quote>
(aggregate), <quote>normal</quote>, <quote>procedure</quote>, <quote>trigger</quote>, or <quote>window</quote>.

no longer corresponds very well to what the code actually does,
when dealing with a v11-or-later server:

" CASE p.prokind\n"
" WHEN 'a' THEN '%s'\n"
" WHEN 'w' THEN '%s'\n"
" WHEN 'p' THEN '%s'\n"
" ELSE '%s'\n"
" END as \"%s\"",
...
/* translator: "agg" is short for "aggregate" */
gettext_noop("agg"),
gettext_noop("window"),
gettext_noop("proc"),
gettext_noop("func"),
gettext_noop("Type"));

I was going to just fix the docs to match the code, but removing
"trigger" from the list seems very confusing, because the docs
go on to say

To display only functions
of specific type(s), add the corresponding letters <literal>a</literal>,
<literal>n</literal>, <literal>p</literal>, <literal>t</literal>, or <literal>w</literal> to the command.

and indeed filtering triggers in or out still seems to work.
Moreover, if you are inspecting a pre-v11 server then you do
still get the old classification, which is bizarrely inconsistent.

It seems like we should either restore "trigger" as its own
type classification, or remove it from the list of properties
you can filter on, or adjust the docs to describe "t" as a
special filter condition. I'm kind of inclined to the second
option, because treating trigger as a different prokind sure
seems like a wart. But back in 2009 people thought that was
a good idea; what is our opinion now?

regards, tom lane

#2David G. Johnston
david.g.johnston@gmail.com
In reply to: Tom Lane (#1)
Re: Documentation of psql's \df no longer matches reality

On Thu, Mar 2, 2023 at 3:34 PM Tom Lane <tgl@sss.pgh.pa.us> wrote:

It seems like we should either restore "trigger" as its own
type classification, or remove it from the list of properties
you can filter on, or adjust the docs to describe "t" as a
special filter condition. I'm kind of inclined to the second
option, because treating trigger as a different prokind sure
seems like a wart. But back in 2009 people thought that was
a good idea; what is our opinion now?

Personally, I'd go for option 1, bring back the formal concept of a trigger
function to this view. Admit the mistake and back-patch so we are
consistent again.

Or, to improve things, " \df func_name - trigger " should be made to
provide a pattern filter on the output type, in which case people could
then filter on any type they want, not just trigger. Incorporating
set-returning functions into such a filtering mechanism would be a bonus
worth striving for.

Between choices 2 and 3 above I'd go with 3 before 2. I can imagine the
change to label the output of \dft as "func" would easily go unnoticed but
removing the existing filtering feature seems likely to draw valid
complaints. If we had the more powerful alternative described above to
replace it with maybe I'd go for 2. Absent that it is a special case wart
necessitated by the lack of being able to readily specify the return type
filter in a manner similar to the existing input type filtering.

David J.