Re: Strange interval arithmetic - Mailing list pgsql-hackers

From Greg Stark
Subject Re: Strange interval arithmetic
Date
Msg-id 87k6eohed1.fsf@stark.xeocode.com
Whole thread Raw
In response to Re: Strange interval arithmetic  (Tom Lane <tgl@sss.pgh.pa.us>)
Responses Re: Strange interval arithmetic  (Greg Stark <gsstark@mit.edu>)
List pgsql-hackers
Tom Lane <tgl@sss.pgh.pa.us> writes:

> Michael Fuhr <mike@fuhr.org> writes:
> > I usually check both in my own code but I noticed several places
> > where PostgreSQL doesn't, so I kept that style.  I'll check both
> > if that's preferred.
> 
> I'd say not --- it's more code and it makes a possibly unwarranted
> assumption about strtol's behavior.
> 

Generally speaking looking at errno when you haven't received an error return
from a libc function is asking for trouble. It could be leftover from any
previous libc error. 

That's how you get programs saying things like "strtol: No such file or
directory" ...

   The strtol() function returns the result of the conversion, unless the value   would underflow or overflow. If an
underflowoccurs, strtol() returns   LONG_MIN. If an overflow occurs, strtol() returns LONG_MAX. In both cases,   errno
isset to ERANGE. Precisely the same holds for strtoll() (with LLONG_MIN   and LLONG_MAX instead of LONG_MIN and
LONG_MAX).


-- 
greg



pgsql-hackers by date:

Previous
From: "Qingqing Zhou"
Date:
Subject: Re: [PATCHES] A couple of proposed pgbench changes
Next
From: Greg Stark
Date:
Subject: Re: Strange interval arithmetic