Re: Restoring default privileges on objects

From: Stuart McGraw <smcg4191(at)mtneva(dot)com>
To: pgsql-general(at)lists(dot)postgresql(dot)org
Cc: Erik Wienhold <ewie(at)ewie(dot)name>, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Subject: Re: Restoring default privileges on objects
Date: 2023-08-29 20:44:48
Message-ID: e7387e04-0a17-3a77-8e0c-da6794625a30@mtneva.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general pgsql-hackers

On 8/29/23 13:27, Tom Lane wrote:
> Erik Wienhold <ewie(at)ewie(dot)name> writes:
>> On 29/08/2023 18:43 CEST Stuart McGraw <smcg4191(at)mtneva(dot)com> wrote:
>>> Shouldn't psql put *something* (like "(default)" or "-") in the
>>> "Access privileges" column to indicate that? Or conversely,
>>> something (like "(none)"?) in the revoked case?
>
>> Indeed, that's confusing. Command \dp always prints null as empty string [1].
>> So \pset null '(null)' has no effect.
>
> Yeah, perhaps. The reason it so seldom comes up is that a state of
> zero privileges is extremely rare (because it's useless in practice).
>
> That being the case, if we were to do something about this, I'd vote
> for changing the display of zero-privileges to "(none)" or something
> along that line, rather than changing the display of NULL, which
> people are accustomed to.
>
> Fixing \dp to honor "\pset null" for this might be a reasonable
> thing to do too. I'm actually a bit surprised that that doesn't
> work already.
>
> regards, tom lane

That change would still require someone using \dp to realize that
the "Access privileges" value could be either '' or NULL (I guess
that could be pointed out more obviously in the psql doc), and then
do a '\pset null' before doing \dp? That seems a little inconvenient.

As a possible alternative, in the query that \dp sends, what about
replacing the line:

select ...,
pg_catalog.array_to_string(c.relacl, E'\n') as "Access privileges"
...

with something like:

CASE array_length(c.relacl,1) WHEN 0 THEN '(none)' ELSE pg_catalog.array_to_string(c.relacl, E'\n') END as "Access privileges"

I realize that removes the ability to control with pset what is
displayed, but maybe a little more foolproof for naive users like
myself?

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Erik Wienhold 2023-08-30 00:44:18 createuser unexpectedly creates superuser with createdb and createrole
Previous Message Alan Stange 2023-08-29 20:09:16 Re: [INTERNET] Re: auto vacuum question

Browse pgsql-hackers by date

  From Date Subject
Next Message Nathan Bossart 2023-08-29 21:11:06 Re: Wrong usage of pqMsg_Close message code?
Previous Message Nathan Bossart 2023-08-29 20:40:08 Re: tablecmds.c/MergeAttributes() cleanup