Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1pKrKS-0003hD-To for pgsql-hackers@arkaria.postgresql.org; Thu, 26 Jan 2023 01:45:28 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1pKrKR-0004lj-GH for pgsql-hackers@arkaria.postgresql.org; Thu, 26 Jan 2023 01:45:27 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1pKrKR-0004lZ-70 for pgsql-hackers@lists.postgresql.org; Thu, 26 Jan 2023 01:45:27 +0000 Received: from sss.pgh.pa.us ([66.207.139.130]) by makus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1pKrKO-0008U6-FJ for pgsql-hackers@postgresql.org; Thu, 26 Jan 2023 01:45:26 +0000 Received: from sss1.sss.pgh.pa.us (localhost [127.0.0.1]) by sss.pgh.pa.us (8.15.2/8.15.2) with ESMTP id 30Q1jMhe2873639; Wed, 25 Jan 2023 20:45:22 -0500 From: Tom Lane To: Nathan Bossart cc: Robert Haas , "pgsql-hackers@postgresql.org" Subject: Re: improving user.c error messages In-reply-to: <20230126002251.GA1506128@nathanxps13> References: <20230118231749.GA3790025@nathanxps13> <20230126002251.GA1506128@nathanxps13> Comments: In-reply-to Nathan Bossart message dated "Wed, 25 Jan 2023 16:22:51 -0800" MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <2873637.1674697522.1@sss.pgh.pa.us> Date: Wed, 25 Jan 2023 20:45:22 -0500 Message-ID: <2873638.1674697522@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk Nathan Bossart writes: > On Thu, Jan 19, 2023 at 10:20:33AM -0500, Robert Haas wrote: >> That would be great. I agree that it's good to try to improve the >> error messages. It hasn't been entirely clear to me how to do that. >> For instance, I don't think we want to say something like: >> >> ERROR: must have CREATEROLE privilege and ADMIN OPTION on the target >> role, or in lieu of both of those to be superuser, to set the >> CONNECTION LIMIT for another role >> ERROR: must have CREATEROLE privilege and ADMIN OPTION on the target >> role, plus also CREATEDB, or in lieu of all that to be superuser, to >> remove the CREATEDB property from another role > Here is an early draft of some modest improvements to the user.c error > messages. I basically just tried to standardize the style of and add > context to the existing error messages. I used errhint() for this extra > context, but errdetail() would work, too. Yeah, I think the right fix is to keep the primary message pretty terse and add detail in secondary messages. IMO most of these are errdetail not errhint, because they are factual details about the rules [1]. But other than that quibble, Nathan's draft looked pretty good in a quick once-over. regards, tom lane [1] https://www.postgresql.org/docs/devel/error-style-guide.html