Re: Missing errcode() in ereport

2020-03-29 Thread Andres Freund
Hi, On 2020-03-30 11:54:03 +0800, Craig Ringer wrote: > On Fri, 20 Mar 2020, 01:59 Andres Freund, wrote: > > 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

Re: Missing errcode() in ereport

2020-03-29 Thread Tom Lane
Craig Ringer writes: > I'd have found it helpful to just have the docs explain clearly how it > works by chaining the comma operator using functions with ignored return > values. Want to write some text? > That would also help people understand how they can make parts of an > ereport conditional

Re: Missing errcode() in ereport

2020-03-29 Thread Craig Ringer
On Fri, 20 Mar 2020, 01:59 Andres Freund, wrote: > Hi, > > 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 > fir

Re: Missing errcode() in ereport

2020-03-25 Thread Tom Lane
I wrote: > Thomas Munro writes: >> I think this caused anole to say: >> "reloptions.c", line 1362: error #2042: operand types are incompatible >> ("void" and "int") >> errdetail_internal("%s", _(optenum->detailmsg)) : 0)); > Yeah, I was just looking at that :-( > We could revert the change to ha

Re: Missing errcode() in ereport

2020-03-24 Thread Tom Lane
Thomas Munro writes: > I think this caused anole to say: > "reloptions.c", line 1362: error #2042: operand types are incompatible > ("void" and "int") > errdetail_internal("%s", _(optenum->detailmsg)) : 0)); Yeah, I was just looking at that :-( We could revert the change to have these functio

Re: Missing errcode() in ereport

2020-03-24 Thread Thomas Munro
On Wed, Mar 25, 2020 at 9:30 AM Tom Lane wrote: > Andres Freund writes: > > On 2020-03-23 17:24:49 -0400, Tom Lane wrote: > >> Hearing no objections, I started to review Andres' patchset with > >> that plan in mind. > > > Thanks for pushing the first part! > > I pushed all of it, actually. I thi

Re: Missing errcode() in ereport

2020-03-24 Thread Tom Lane
Andres Freund writes: > On 2020-03-23 17:24:49 -0400, Tom Lane wrote: >> Hearing no objections, I started to review Andres' patchset with >> that plan in mind. > Thanks for pushing the first part! I pushed all of it, actually. regards, tom lane

Re: Missing errcode() in ereport

2020-03-24 Thread Andres Freund
On 2020-03-23 17:24:49 -0400, Tom Lane wrote: > Hearing no objections, I started to review Andres' patchset with > that plan in mind. Thanks for pushing the first part!

Re: Missing errcode() in ereport

2020-03-23 Thread Tom Lane
Andres Freund writes: > I wondered before whether there's a way we could move the elevel check > in errstart to the macro. For it to be a win we'd presumably have to > have a "synthesized" log_level variable, basically > min(log_min_messages, client_min_messages, ERROR). > Probably not worth it.

Re: Missing errcode() in ereport

2020-03-23 Thread Andres Freund
Hi, On 2020-03-23 17:24:49 -0400, Tom Lane wrote: > I wrote: > > On balance I'm leaning towards keeping the parens as preferred style > > for now, adjusting v12 so that the macro will allow paren omission > > but we don't break ABI, and not touching the older branches. > > Hearing no objections,

Re: Missing errcode() in ereport

2020-03-23 Thread Tom Lane
I wrote: > On balance I'm leaning towards keeping the parens as preferred style > for now, adjusting v12 so that the macro will allow paren omission > but we don't break ABI, and not touching the older branches. Hearing no objections, I started to review Andres' patchset with that plan in mind. I

Re: Missing errcode() in ereport

2020-03-20 Thread Alvaro Herrera
On 2020-Mar-19, Tom Lane wrote: > I think the key decision we'd have to make to move forward on this > is to decide whether it's still project style to prefer the extra > parens, or whether we want new code to do without them going > forward. If we don't want to risk requiring __VA_ARGS__ for the

Re: Missing errcode() in ereport

2020-03-20 Thread Tom Lane
Andres Freund writes: > On 2020-03-19 22:32:30 -0400, Tom Lane wrote: >> Could we get away with moving the compiler goalposts for the back >> branches? I dunno, but it's a fact that we aren't testing anymore >> with any compilers that would complain about unconditional use of >> __VA_ARGS__. So

Re: Missing errcode() in ereport

2020-03-19 Thread Andres Freund
Hi, On 2020-03-19 22:32:30 -0400, Tom Lane wrote: > Andres Freund writes: > > I wonder if it'd become a relevant backpatch pain if we started to have > > some ereports() without the additional parens in 13+. > > Yeah, it would be a nasty backpatch hazard. > > > Would it perhaps > > make sense t

Re: Missing errcode() in ereport

2020-03-19 Thread Tom Lane
Andres Freund writes: > I wonder if it'd become a relevant backpatch pain if we started to have > some ereports() without the additional parens in 13+. Yeah, it would be a nasty backpatch hazard. > Would it perhaps > make sense to backpatch just the part that removes the need for the > parents,

Re: Missing errcode() in ereport

2020-03-19 Thread Andres Freund
Hi, On 2020-03-19 21:03:17 -0400, Tom Lane wrote: > I wrote: > > 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 t

Re: Missing errcode() in ereport

2020-03-19 Thread Andres Freund
Hi, On 2020-03-19 19:32:55 -0400, Tom Lane wrote: > Andres Freund 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: > >

Re: Missing errcode() in ereport

2020-03-19 Thread Tom Lane
I wrote: > 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? Yeah, t

Re: Missing errcode() in ereport

2020-03-19 Thread Tom Lane
Andres Freund 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/sr

Re: Missing errcode() in ereport

2020-03-19 Thread Andres Freund
Hi, On 2020-03-19 14:07:04 -0400, Tom Lane wrote: > 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 po

Re: Missing errcode() in ereport

2020-03-19 Thread Tom Lane
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

Re: Missing errcode() in ereport

2020-03-19 Thread Andres Freund
Hi, 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 - large

Re: Missing errcode() in ereport

2020-03-18 Thread Masahiko Sawada
On Wed, 18 Mar 2020 at 13:57, Amit Kapila wrote: > > On Wed, Mar 18, 2020 at 9:01 AM Amit Kapila wrote: > > > > On Tue, Mar 17, 2020 at 7:39 PM Tom Lane wrote: > > > > > > Amit Kapila writes: > > > > On Tue, Mar 17, 2020 at 3:28 PM Michael Paquier > > > > wrote: > > > >> Definitely an oversig

Re: Missing errcode() in ereport

2020-03-17 Thread Amit Kapila
On Wed, Mar 18, 2020 at 9:01 AM Amit Kapila wrote: > > On Tue, Mar 17, 2020 at 7:39 PM Tom Lane wrote: > > > > Amit Kapila writes: > > > On Tue, Mar 17, 2020 at 3:28 PM Michael Paquier > > > wrote: > > >> Definitely an oversight. All stable branches down to 9.5 have > > >> mistakes in the sam

Re: Missing errcode() in ereport

2020-03-17 Thread Amit Kapila
On Tue, Mar 17, 2020 at 7:39 PM Tom Lane wrote: > > Amit Kapila writes: > > On Tue, Mar 17, 2020 at 3:28 PM Michael Paquier wrote: > >> Definitely an oversight. All stable branches down to 9.5 have > >> mistakes in the same area, with nothing extra by grepping around. > >> Amit, I guess that yo

Re: Missing errcode() in ereport

2020-03-17 Thread Tom Lane
Amit Kapila writes: > On Tue, Mar 17, 2020 at 3:28 PM Michael Paquier wrote: >> Definitely an oversight. All stable branches down to 9.5 have >> mistakes in the same area, with nothing extra by grepping around. >> Amit, I guess that you will take care of it? > Yes, I will unless I see any objec

Re: Missing errcode() in ereport

2020-03-17 Thread Amit Kapila
On Tue, Mar 17, 2020 at 3:28 PM Michael Paquier wrote: > > On Tue, Mar 17, 2020 at 10:26:57AM +0100, Julien Rouhaud wrote: > > On Tue, Mar 17, 2020 at 10:00 AM Amit Kapila > > wrote: > >> +1. This looks like an oversight to me. > > > > good catch! And patch LGTM. > > Definitely an oversight.

Re: Missing errcode() in ereport

2020-03-17 Thread Michael Paquier
On Tue, Mar 17, 2020 at 10:26:57AM +0100, Julien Rouhaud wrote: > On Tue, Mar 17, 2020 at 10:00 AM Amit Kapila wrote: >> +1. This looks like an oversight to me. > > good catch! And patch LGTM. Definitely an oversight. All stable branches down to 9.5 have mistakes in the same area, with nothin

Re: Missing errcode() in ereport

2020-03-17 Thread Julien Rouhaud
On Tue, Mar 17, 2020 at 10:00 AM Amit Kapila wrote: > > On Tue, Mar 17, 2020 at 2:08 PM Masahiko Sawada > wrote: > > > > Hi, > > > > In PageIsVerified() we report a WARNING as follows: > > > > ereport(WARNING, > > (ERRCODE_DATA_CORRUPTED, > > errmsg("page

Re: Missing errcode() in ereport

2020-03-17 Thread Amit Kapila
On Tue, Mar 17, 2020 at 2:08 PM Masahiko Sawada wrote: > > Hi, > > In PageIsVerified() we report a WARNING as follows: > > ereport(WARNING, > (ERRCODE_DATA_CORRUPTED, > errmsg("page verification failed, calculated checksum > %u but expected %u", >

Missing errcode() in ereport

2020-03-17 Thread Masahiko Sawada
Hi, In PageIsVerified() we report a WARNING as follows: ereport(WARNING, (ERRCODE_DATA_CORRUPTED, errmsg("page verification failed, calculated checksum %u but expected %u", checksum, p->pd_checksum))); However the error message won