Andres Freund <and...@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