Fix overflow in extract(epoch from interval) for intervals exceeding 68 years.

Seems to have been introduced in 8.1 by careless SECS_PER_DAY
search-and-replace.
This commit is contained in:
Tom Lane 2007-09-16 15:56:32 +00:00
parent ee24168d2c
commit eb4f4f5b7c

View File

@ -8,7 +8,7 @@
*
*
* IDENTIFICATION
* $PostgreSQL: pgsql/src/backend/utils/adt/timestamp.c,v 1.169 2006/11/11 01:14:19 tgl Exp $
* $PostgreSQL: pgsql/src/backend/utils/adt/timestamp.c,v 1.169.2.1 2007/09/16 15:56:32 tgl Exp $
*
*-------------------------------------------------------------------------
*/
@ -4190,9 +4190,9 @@ interval_part(PG_FUNCTION_ARGS)
#else
result = interval->time;
#endif
result += (DAYS_PER_YEAR * SECS_PER_DAY) * (interval->month / MONTHS_PER_YEAR);
result += ((double) DAYS_PER_YEAR * SECS_PER_DAY) * (interval->month / MONTHS_PER_YEAR);
result += ((double) DAYS_PER_MONTH * SECS_PER_DAY) * (interval->month % MONTHS_PER_YEAR);
result += interval->day * SECS_PER_DAY;
result += ((double) SECS_PER_DAY) * interval->day;
}
else
{