Re: Fix output of zero privileges in psql

From: Laurenz Albe <laurenz(dot)albe(at)cybertec(dot)at>
To: "David G(dot) Johnston" <david(dot)g(dot)johnston(at)gmail(dot)com>
Cc: Erik Wienhold <ewie(at)ewie(dot)name>, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, PostgreSQL Hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org>
Subject: Re: Fix output of zero privileges in psql
Date: 2023-10-23 14:10:09
Message-ID: 70e1463fe1850cdbc4180809b0db80d6cea41be3.camel@cybertec.at
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Mon, 2023-10-23 at 07:03 -0700, David G. Johnston wrote:
> On Monday, October 23, 2023, Laurenz Albe <laurenz(dot)albe(at)cybertec(dot)at> wrote:
> >
> >   --- a/src/bin/psql/describe.c
> >   +++ b/src/bin/psql/describe.c
> >   @@ -6718,7 +6680,13 @@ static void
> >    printACLColumn(PQExpBuffer buf, const char *colname)
> >    {
> >       appendPQExpBuffer(buf,
> >   -                     "pg_catalog.array_to_string(%s, E'\\n') AS \"%s\"",
> >   +                     "CASE\n"
> >   +                     "  WHEN %s IS NULL THEN ''\n"
> >   +                     "  WHEN pg_catalog.cardinality(%s) = 0 THEN '%s'\n"
> >   +                     "  ELSE pg_catalog.array_to_string(%s, E'\\n')\n"
> >   +                     "END AS \"%s\"",
> >   +                     colname,
> >   +                     colname, gettext_noop("(none)"),
> >                         colname, gettext_noop("Access privileges"));
> >    }
> >
> > This erroneously displays NULL as empty string and subverts my changes.
> > I have removed the first branch of the CASE expression.
>
> There is no error here, the current consensus which this patch implements is to
> not change the documented “default privileges display as blank”.  We are solving
> the empty privileges are not distinguishable complaint by printing (none) for them.

Erik's latest patch included my changes to display NULL as NULL in psql,
so that "\pset null" works as expected.
But he left the above hunk from his original patch, and that hunk replaces
NULL with an empty string, so "\pset null" wouldn't work for the display
of default provoleges.

He didn't notice it because he didn't have a regression test that displays
default privileges with non-empty "\pset null".

Yours,
Laurenz Albe

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Robert Haas 2023-10-23 14:10:45 Re: controlling meson's parallelism (and some whining)
Previous Message David G. Johnston 2023-10-23 14:03:54 Re: Fix output of zero privileges in psql