Re: BUG #1609: Bug in interval datatype for 64 Bit timestamps

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Oliver Siegmar <oliver(at)siegmar(dot)net>
Cc: pgsql-bugs(at)postgresql(dot)org
Subject: Re: BUG #1609: Bug in interval datatype for 64 Bit timestamps
Date: 2005-04-20 17:15:59
Message-ID: 3036.1114017359@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

I've applied this patch.

regards, tom lane

Index: datetime.c
===================================================================
RCS file: /cvsroot/pgsql/src/backend/utils/adt/datetime.c,v
retrieving revision 1.137
diff -c -r1.137 datetime.c
*** datetime.c 11 Jan 2005 18:33:45 -0000 1.137
--- datetime.c 20 Apr 2005 17:09:57 -0000
***************
*** 3883,3899 ****
/* fractional seconds? */
if (fsec != 0)
{
#ifdef HAVE_INT64_TIMESTAMP
if (is_before || ((!is_nonzero) && (tm->tm_sec < 0)))
tm->tm_sec = -tm->tm_sec;
sprintf(cp, "%s%d.%02d secs", (is_nonzero ? " " : ""),
! tm->tm_sec, (((int) fsec) / 10000));
cp += strlen(cp);
- if (!is_nonzero)
- is_before = (fsec < 0);
#else
- fsec_t sec;
-
fsec += tm->tm_sec;
sec = fsec;
if (is_before || ((!is_nonzero) && (fsec < 0)))
--- 3883,3907 ----
/* fractional seconds? */
if (fsec != 0)
{
+ fsec_t sec;
+
#ifdef HAVE_INT64_TIMESTAMP
+ sec = fsec;
if (is_before || ((!is_nonzero) && (tm->tm_sec < 0)))
+ {
tm->tm_sec = -tm->tm_sec;
+ sec = -sec;
+ is_before = TRUE;
+ }
+ else if ((!is_nonzero) && (tm->tm_sec == 0) && (fsec < 0))
+ {
+ sec = -sec;
+ is_before = TRUE;
+ }
sprintf(cp, "%s%d.%02d secs", (is_nonzero ? " " : ""),
! tm->tm_sec, (((int) sec) / 10000));
cp += strlen(cp);
#else
fsec += tm->tm_sec;
sec = fsec;
if (is_before || ((!is_nonzero) && (fsec < 0)))
***************
*** 3905,3913 ****
is_before = (fsec < 0);
#endif
is_nonzero = TRUE;
-
- /* otherwise, integer seconds only? */
}
else if (tm->tm_sec != 0)
{
int sec = tm->tm_sec;
--- 3913,3920 ----
is_before = (fsec < 0);
#endif
is_nonzero = TRUE;
}
+ /* otherwise, integer seconds only? */
else if (tm->tm_sec != 0)
{
int sec = tm->tm_sec;

In response to

Browse pgsql-bugs by date

  From Date Subject
Next Message Tom Lane 2005-04-20 20:25:45 Re: BUG #1608: integer negative limit in plpgsql function arguments
Previous Message Tom Lane 2005-04-20 16:10:45 Re: BUG #1609: Bug in interval datatype for 64 Bit timestamps