From: Tom Lane Date: Tue, 18 Aug 2009 21:23:35 +0000 (+0000) Subject: Fix overflow for INTERVAL 'x ms' where x is more than a couple million, X-Git-Tag: REL8_2_14~9 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=0302a8eaa7ac28099b0365d3d28c31771ad48f28;p=thirdparty%2Fpostgresql.git Fix overflow for INTERVAL 'x ms' where x is more than a couple million, and integer datetimes are in use. Per bug report from Hubert Depesz Lubaczewski. Alex Hunsaker --- diff --git a/src/backend/utils/adt/datetime.c b/src/backend/utils/adt/datetime.c index cf30b765947..c4446dedf85 100644 --- a/src/backend/utils/adt/datetime.c +++ b/src/backend/utils/adt/datetime.c @@ -8,7 +8,7 @@ * * * IDENTIFICATION - * $PostgreSQL: pgsql/src/backend/utils/adt/datetime.c,v 1.174.2.6 2009/05/01 19:29:20 tgl Exp $ + * $PostgreSQL: pgsql/src/backend/utils/adt/datetime.c,v 1.174.2.7 2009/08/18 21:23:35 tgl Exp $ * *------------------------------------------------------------------------- */ @@ -2825,6 +2825,9 @@ DecodeInterval(char **field, int *ftype, int nf, int *dtype, struct pg_tm * tm, break; case DTK_MILLISEC: + /* avoid overflowing the fsec field */ + tm->tm_sec += val / 1000; + val -= (val / 1000) * 1000; #ifdef HAVE_INT64_TIMESTAMP *fsec += (val + fval) * 1000; #else