Re: improving user.c error messages

From: Nathan Bossart <nathandbossart(at)gmail(dot)com>
To: Peter Eisentraut <peter(dot)eisentraut(at)enterprisedb(dot)com>
Cc: Alvaro Herrera <alvherre(at)alvh(dot)no-ip(dot)org>, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, Robert Haas <robertmhaas(at)gmail(dot)com>, "pgsql-hackers(at)postgresql(dot)org" <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: improving user.c error messages
Date: 2023-03-10 00:03:13
Message-ID: 20230310000313.GA3992372@nathanxps13
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

On Thu, Mar 09, 2023 at 09:58:46AM -0800, Nathan Bossart wrote:
> On Thu, Mar 09, 2023 at 10:55:54AM +0100, Peter Eisentraut wrote:
>> On 20.02.23 23:58, Nathan Bossart wrote:
>>> For now, I've reworded these as "must inherit privileges of".
>> I don't have a good mental model of all this role inheritance, personally,
>> but I fear that this change makes the messages more jargony and less clear.
>> Maybe the original wording was good enough.
> I'm fine with that.

I used the original wording in v7.

>> "admin option" is sort of a natural language term, I think, so we don't need
>> to parametrize it as "%s option". Also, there are no other "options" in
>> this context, I think.
> v16 introduces the INHERIT and SET options. I don't have a strong opinion
> about parameterizing it, though. My intent was to consistently capitalize
> all the attributes and options.

I didn't change this in v7, but I can do so if you still think it shouldn't
be parameterized.

>> A general thought: It seems we currently don't have any error messages that
>> address the user like "You must do this". Do we want to go there? Should we
>> try for a more impersonal wording like
>> "You must have the %s attribute to create roles."
>> "Current user must have the %s attribute to create roles."
>> "%s attribute is required to create roles."
> I think I like the last option the most. In general, I agree with trying
> to avoid the second-person phrasing.

I ended up using the "current user must have" wording in a few places, and
for most others, I used "only roles with X may do Y." That seemed to flow
relatively well, and IMO it made the required privileges abundantly clear.
I initially was going to use the "X attribute is required to Y" wording,
but I was worried that didn't make it sufficiently clear that the _role_
must have the attribute. In any case, I'm not wedded to the approach I
used in the patch and am willing to try out other wordings.

BTW I did find one example of a "you must" message while I was updating the

write_stderr("%s does not know where to find the server configuration file.\n"
"You must specify the --config-file or -D invocation "
"option or set the PGDATA environment variable.\n",

I don't think it's a common style, though.

>> By the way, I'm not sure what the separation between 0001 and 0002 is
>> supposed to be.
> I'll combine them. I first started with user.c only, but we kept finding
> new messages to improve.

I combined the patches in v7.

Nathan Bossart
Amazon Web Services:

Attachment Content-Type Size
v7-0001-Improve-several-permission-related-error-messages.patch text/x-diff 50.1 KB

In response to


Browse pgsql-hackers by date

  From Date Subject
Next Message Thomas Munro 2023-03-10 00:05:27 Re: Sub-millisecond [autovacuum_]vacuum_cost_delay broken
Previous Message Andrew Dunstan 2023-03-09 23:31:10 Re: buildfarm + meson