From: Tom Lane Date: Tue, 18 Aug 2009 21:23:58 +0000 (+0000) Subject: Fix overflow for INTERVAL 'x ms' where x is more than a couple million, X-Git-Tag: REL7_4_26~7 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=2e78dc85e0b3f0a65c58905a65279f6ab18da36e;p=postgresql 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 cb57d8182f..5e929b0f17 100644 --- a/src/backend/utils/adt/datetime.c +++ b/src/backend/utils/adt/datetime.c @@ -8,7 +8,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/utils/adt/datetime.c,v 1.118.2.12 2009/05/01 19:29:42 tgl Exp $ + * $Header: /cvsroot/pgsql/src/backend/utils/adt/datetime.c,v 1.118.2.13 2009/08/18 21:23:58 tgl Exp $ * *------------------------------------------------------------------------- */ @@ -3093,6 +3093,9 @@ DecodeInterval(char **field, int *ftype, int nf, int *dtype, struct tm * tm, fse 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