Re: Re: Updated interval patches (SQL std output, ISO8601 intervals, and interval rounding)

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Ron Mayer <rm_pg(at)cheapcomplexdevices(dot)com>
Cc: Brendan Jurd <direvus(at)gmail(dot)com>, pgsql-hackers(at)postgresql(dot)org
Subject: Re: Re: Updated interval patches (SQL std output, ISO8601 intervals, and interval rounding)
Date: 2008-11-12 01:40:47
Message-ID: 21192.1226454047@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Ron Mayer <rm_pg(at)cheapcomplexdevices(dot)com> writes:
> Brendan Jurd wrote:
>> I don't have any further gripes regarding this patch, apart from the
>> code style stuff I sent through in my previous post. Did you have any
>> response to those?

> Yup - you were right again.
> Applied them and updated the website and attaching the patch.

Applied with another round of mostly-stylistic revisions, plus a little
extra work to factor out some more code duplication (around strtod
calls, which were insufficiently error-checked too).

There was one part I left out because it worried me:

***************
*** 2980,3010 ****
switch (type)
{
case DTK_MICROSEC:
! #ifdef HAVE_INT64_TIMESTAMP
! *fsec += rint(val + fval);
! #else
! *fsec += (val + fval) * 1e-6;
! #endif
tmask = DTK_M(MICROSECOND);
break;

case DTK_MILLISEC:
! #ifdef HAVE_INT64_TIMESTAMP
! *fsec += rint((val + fval) * 1000);
! #else
! *fsec += (val + fval) * 1e-3;
! #endif
tmask = DTK_M(MILLISECOND);
break;

case DTK_SECOND:
tm->tm_sec += val;
! #ifdef HAVE_INT64_TIMESTAMP
! *fsec += rint(fval * 1000000);
! #else
! *fsec += fval;
! #endif
!
/*
* If any subseconds were specified, consider this
* microsecond and millisecond input as well.
--- 2897,2914 ----
switch (type)
{
case DTK_MICROSEC:
! AdjustFractSeconds((val + fval) * 1e-6, tm, fsec, 1);
tmask = DTK_M(MICROSECOND);
break;

case DTK_MILLISEC:
! AdjustFractSeconds((val + fval) * 1e-3, tm, fsec, 1);
tmask = DTK_M(MILLISECOND);
break;

case DTK_SECOND:
tm->tm_sec += val;
! AdjustFractSeconds(fval, tm, fsec, 1);
/*
* If any subseconds were specified, consider this
* microsecond and millisecond input as well.

The original INT64 coding here is exact (at least for the common case
where fval is zero) but I'm not convinced that your revision can't
suffer from roundoff error.

regards, tom lane

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Unicron 2008-11-12 01:47:05 Result for "Automatically update view"
Previous Message Alvaro Herrera 2008-11-12 01:10:26 Re: Message-ID should surely not be shown as a mailto: URL