Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.92) (envelope-from ) id 1jEzZa-0004N5-9Z for pgsql-hackers@arkaria.postgresql.org; Thu, 19 Mar 2020 18:07:14 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1jEzZY-0002KS-WA for pgsql-hackers@arkaria.postgresql.org; Thu, 19 Mar 2020 18:07:12 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1jEzZY-0002KL-FO for pgsql-hackers@lists.postgresql.org; Thu, 19 Mar 2020 18:07:12 +0000 Received: from sss.pgh.pa.us ([66.207.139.130]) by makus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1jEzZW-0007GW-8B for pgsql-hackers@lists.postgresql.org; Thu, 19 Mar 2020 18:07:11 +0000 Received: from sss1.sss.pgh.pa.us (localhost [127.0.0.1]) by sss.pgh.pa.us (8.14.4/8.14.4) with ESMTP id 02JI740n005064; Thu, 19 Mar 2020 14:07:04 -0400 From: Tom Lane To: Andres Freund cc: Amit Kapila , Michael Paquier , Julien Rouhaud , Masahiko Sawada , PostgreSQL Hackers Subject: Re: Missing errcode() in ereport In-reply-to: <20200319175902.vjib2tslosw65iyr@alap3.anarazel.de> References: <20200317095839.GG2206@paquier.xyz> <32174.1584454158@sss.pgh.pa.us> <20200319175902.vjib2tslosw65iyr@alap3.anarazel.de> Comments: In-reply-to Andres Freund message dated "Thu, 19 Mar 2020 10:59:02 -0700" MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <5062.1584641224.1@sss.pgh.pa.us> Date: Thu, 19 Mar 2020 14:07:04 -0400 Message-ID: <5063.1584641224@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk Andres Freund writes: > On 2020-03-17 10:09:18 -0400, Tom Lane wrote: >> We might want to spend some effort thinking how to find or prevent >> additional bugs of the same ilk ... > Yea, that'd be good. Trying to help people new to postgres write their > first patches I found that ereport is very confusing to them - largely > because the syntax doesn't make much sense. Made worse by the compiler > error messages being terrible in many cases. > Not sure there's much we can do without changing ereport's "signature" > though :( Now that we can rely on having varargs macros, I think we could stop requiring the extra level of parentheses, ie instead of ereport(ERROR, (errcode(ERRCODE_DIVISION_BY_ZERO), errmsg("division by zero"))); it could be just ereport(ERROR, errcode(ERRCODE_DIVISION_BY_ZERO), errmsg("division by zero")); (The old syntax had better still work, of course. I'm not advocating running around and changing existing calls.) I'm not sure that this'd really move the goalposts much in terms of making it any less confusing, but possibly it would improve the compiler errors? Do you have any concrete examples of crummy error messages? regards, tom lane