Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit 22d98e7

Browse files
committed
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.
1 parent e92da1a commit 22d98e7

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

src/backend/utils/adt/timestamp.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
*
99
*
1010
* IDENTIFICATION
11-
* $PostgreSQL: pgsql/src/backend/utils/adt/timestamp.c,v 1.181 2007/08/04 01:26:54 tgl Exp $
11+
* $PostgreSQL: pgsql/src/backend/utils/adt/timestamp.c,v 1.182 2007/09/16 15:56:20 tgl Exp $
1212
*
1313
*-------------------------------------------------------------------------
1414
*/
@@ -4395,9 +4395,9 @@ interval_part(PG_FUNCTION_ARGS)
43954395
#else
43964396
result = interval->time;
43974397
#endif
4398-
result += (DAYS_PER_YEAR * SECS_PER_DAY) * (interval->month / MONTHS_PER_YEAR);
4398+
result += ((double) DAYS_PER_YEAR * SECS_PER_DAY) * (interval->month / MONTHS_PER_YEAR);
43994399
result += ((double) DAYS_PER_MONTH * SECS_PER_DAY) * (interval->month % MONTHS_PER_YEAR);
4400-
result += interval->day * SECS_PER_DAY;
4400+
result += ((double) SECS_PER_DAY) * interval->day;
44014401
}
44024402
else
44034403
{

0 commit comments

Comments
 (0)