Tom Lane <[EMAIL PROTECTED]> writes: > Michael Fuhr <[EMAIL PROTECTED]> 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 underflow occurs, strtol() returns LONG_MIN. If an overflow occurs, strtol() returns LONG_MAX. In both cases, errno is set to ERANGE. Precisely the same holds for strtoll() (with LLONG_MIN and LLONG_MAX instead of LONG_MIN and LONG_MAX). -- greg ---------------------------(end of broadcast)--------------------------- TIP 1: if posting/reading through Usenet, please send an appropriate subscribe-nomail command to [EMAIL PROTECTED] so that your message can get through to the mailing list cleanly