From: | Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> |
---|---|
To: | Andres Freund <andres(at)anarazel(dot)de> |
Cc: | Amit Kapila <amit(dot)kapila16(at)gmail(dot)com>, Michael Paquier <michael(at)paquier(dot)xyz>, Julien Rouhaud <rjuju123(at)gmail(dot)com>, Masahiko Sawada <masahiko(dot)sawada(at)2ndquadrant(dot)com>, PostgreSQL Hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org> |
Subject: | Re: Missing errcode() in ereport |
Date: | 2020-03-19 23:32:55 |
Message-ID: | 5995.1584660775@sss.pgh.pa.us |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-hackers |
Andres Freund <andres(at)anarazel(dot)de> writes:
> On 2020-03-19 14:07:04 -0400, Tom Lane wrote:
>> Now that we can rely on having varargs macros, I think we could
>> stop requiring the extra level of parentheses,
> I think that'd be an improvement, because:
> ane of the ones I saw confuse people is just:
> /home/andres/src/postgresql/src/backend/tcop/postgres.c:3727:4: error: ‘ereport’ undeclared (first use in this function); did you mean ‘rresvport’?
> 3727 | ereport(FATAL,
> | ^~~~~~~
> | rresvport
> /home/andres/src/postgresql/src/backend/tcop/postgres.c:3727:4: note: each undeclared identifier is reported only once for each function it appears in
> because the extra parens haven't been added.
Ah, so the macro isn't expanded at all if it appears to have more than
two parameters? That seems odd, but I suppose some compilers might
work that way. Switching to varargs would improve that for sure.
> Another one I've both seen and committed byself is converting an elog to
> an ereport, and not adding an errcode() around the error code - which
> silently looks like it works.
You mean not adding errmsg() around the error string? Yeah, I can
believe that one easily. It's sort of the same problem as forgetting
to wrap errcode() around the ERRCODE_ constant.
I think that at least some compilers will complain about side-effect-free
subexpressions of a comma expression. Could we restructure things so
that the errcode/errmsg/etc calls form a standalone comma expression
rather than appearing to be arguments of a varargs function? The
compiler's got no hope of realizing there's anything wrong when it
thinks it's passing an integer or string constant to a function it knows
nothing about. But if it could see that nothing at all is being done with
the constant, maybe we'd get somewhere.
regards, tom lane
From | Date | Subject | |
---|---|---|---|
Next Message | Peter Geoghegan | 2020-03-20 00:00:19 | Re: nbtree: assertion failure in _bt_killitems() for posting tuple |
Previous Message | Andres Freund | 2020-03-19 23:04:46 | Re: Missing errcode() in ereport |