Tom Lane wrote:
> Michael Glaesemann <[EMAIL PROTECTED]> writes:
> > Please find attached diffs for documentation and simple regression
> > tests for the new interval->day changes.
>
> The buildfarm results suggest that justify_days is broken in the
> integer-datetimes case, eg from panda:
>
> *** ./expected/interval.out Sat Jul 30 16:20:48 2005
> --- ./results/interval.out Sat Jul 30 16:24:31 2005
> ***************
> *** 238,243 ****
> SELECT justify_days(interval '6 months 36 days 5 hours 4 minutes 3
> seconds') as "7 mons 6 days 5 hours 4 mins 3 seconds";
> 7 mons 6 days 5 hours 4 mins 3 seconds
> ----------------------------------------
> ! @ 7 mons 6 days 5 hours 4 mins 3 secs
> (1 row)
>
> --- 238,243 ----
> SELECT justify_days(interval '6 months 36 days 5 hours 4 minutes 3
> seconds') as "7 mons 6 days 5 hours 4 mins 3 seconds";
> 7 mons 6 days 5 hours 4 mins 3 seconds
> ----------------------------------------
> ! @ 1 mon 186 days 5 hours 4 mins 3 secs
> (1 row)
Thanks, fixed and code cleaned up.
--
Bruce Momjian | http://candle.pha.pa.us
[email protected] | (610) 359-1001
+ If your life is a hard drive, | 13 Roberts Road
+ Christ can be your backup. | Newtown Square, Pennsylvania 19073
Index: src/backend/utils/adt/timestamp.c
===================================================================
RCS file: /cvsroot/pgsql/src/backend/utils/adt/timestamp.c,v
retrieving revision 1.146
diff -c -c -r1.146 timestamp.c
*** src/backend/utils/adt/timestamp.c 24 Jul 2005 04:37:07 -0000 1.146
--- src/backend/utils/adt/timestamp.c 30 Jul 2005 18:19:14 -0000
***************
*** 1915,1922 ****
#ifdef HAVE_INT64_TIMESTAMP
result->time += span->day * USECS_PER_DAY;
! result->day = result->time / USECS_PER_DAY;
! result->time -= result->day * USECS_PER_DAY;
#else
result->time += span->day * (double)SECS_PER_DAY;
TMODULO(result->time, result->day, (double)SECS_PER_DAY);
--- 1915,1921 ----
#ifdef HAVE_INT64_TIMESTAMP
result->time += span->day * USECS_PER_DAY;
! TMODULO(result->time, result->day, USECS_PER_DAY);
#else
result->time += span->day * (double)SECS_PER_DAY;
TMODULO(result->time, result->day, (double)SECS_PER_DAY);
***************
*** 1939,1952 ****
result->day = span->day;
result->time = span->time;
! #ifdef HAVE_INT64_TIMESTAMP
! result->day += span->month * (double)DAYS_PER_MONTH;
! result->month = span->day / DAYS_PER_MONTH;
! result->day -= result->month * DAYS_PER_MONTH;
! #else
! result->day += span->month * (double)DAYS_PER_MONTH;
! TMODULO(result->day, result->month, (double)DAYS_PER_MONTH);
! #endif
PG_RETURN_INTERVAL_P(result);
}
--- 1938,1945 ----
result->day = span->day;
result->time = span->time;
! result->day += span->month * DAYS_PER_MONTH;
! TMODULO(result->day, result->month, DAYS_PER_MONTH);
PG_RETURN_INTERVAL_P(result);
}
---------------------------(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