pg.ddx.io  pgsql-hackers@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Tom Lane <tgl@sss.pgh.pa.us>
To: Andres Freund <andres@anarazel.de>
Cc: Amit Kapila <amit.kapila16@gmail.com>
Cc: Michael Paquier <michael@paquier.xyz>
Cc: Julien Rouhaud <rjuju123@gmail.com>
Cc: Masahiko Sawada <masahiko.sawada@2ndquadrant.com>
Cc: PostgreSQL Hackers <pgsql-hackers@lists.postgresql.org>
Subject: Re: Missing errcode() in ereport
Date: Thu, 19 Mar 2020 14:07:04 -0400
Message-ID: <5063.1584641224@sss.pgh.pa.us> (raw)
In-Reply-To: <20200319175902.vjib2tslosw65iyr@alap3.anarazel.de>
References: <CA+fd4k6N8EjNvZpM8nme+y+05mz-SM8Z_BgkixzkA34R+ej0Kw@mail.gmail.com>
	<CAA4eK1KKmr-Dt-8=C=uoeKk7b6WqOTjjpMt_MXs4eFN1=kAX5w@mail.gmail.com>
	<CAOBaU_bb7FR5cF9RKN42kPHf6pk9CeQ=wTuieJv-t3MroU_q0g@mail.gmail.com>
	<20200317095839.GG2206@paquier.xyz>
	<CAA4eK1+powcFw2EAoVgvH4P3fspAJhxU-VTy0_cR2XpcBZGMAA@mail.gmail.com>
	<32174.1584454158@sss.pgh.pa.us>
	<20200319175902.vjib2tslosw65iyr@alap3.anarazel.de>

Andres Freund <andres@anarazel.de> 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





view thread (31+ messages)  latest in thread

Message-ID: <5063.1584641224@sss.pgh.pa.us>
Permalink:  ../5063.1584641224@sss.pgh.pa.us/
Also on:    postgresql.org/message-id/5063.1584641224@sss.pgh.pa.us

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-hackers@postgresql.org
  Cc: tgl@sss.pgh.pa.us, andres@anarazel.de, amit.kapila16@gmail.com, michael@paquier.xyz, rjuju123@gmail.com, masahiko.sawada@2ndquadrant.com, pgsql-hackers@lists.postgresql.org
  Subject: Re: Missing errcode() in ereport
  In-Reply-To: <5063.1584641224@sss.pgh.pa.us>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox