Re: Strange interval arithmetic

From: Alvaro Herrera <alvherre(at)commandprompt(dot)com>
To: Michael Fuhr <mike(at)fuhr(dot)org>
Cc: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, Christopher Kings-Lynne <chriskl(at)familyhealth(dot)com(dot)au>, PostgreSQL-development <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: Strange interval arithmetic
Date: 2005-11-30 22:06:42
Message-ID: 20051130220642.GA15341@surnet.cl
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers pgsql-patches

Michael Fuhr wrote:

> Agreed. I'm thinking about rewriting strtol() calls in datetime.c
> to look like this:
>
> errno = 0;
> val = strtol(field[i], &cp, 10);
> if (errno == ERANGE)
> return DTERR_FIELD_OVERFLOW;

Hmm, why not check both the return value _and_ errno:

val = strtol(field[i], &cp, 10);
if (val == LONG_MAX && errno == ERANGE)
return DTERR_FIELD_OVERFLOW;

--
Alvaro Herrera http://www.CommandPrompt.com/
PostgreSQL Replication, Consulting, Custom Development, 24x7 support

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Michael Fuhr 2005-11-30 22:18:23 Re: Strange interval arithmetic
Previous Message Kevin Grittner 2005-11-30 21:53:33 Re: [ADMIN] ERROR: could not read block

Browse pgsql-patches by date

  From Date Subject
Next Message Michael Fuhr 2005-11-30 22:18:23 Re: Strange interval arithmetic
Previous Message Michael Fuhr 2005-11-30 21:50:18 Re: Strange interval arithmetic