1
0
mirror of https://github.com/postgres/postgres.git synced 2025-06-16 06:01:02 +03:00

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
This commit is contained in:
Tom Lane
2009-08-18 21:23:14 +00:00
parent e31b35faa5
commit 3bd2241135
2 changed files with 7 additions and 2 deletions

View File

@ -8,7 +8,7 @@
*
*
* IDENTIFICATION
* $PostgreSQL: pgsql/src/backend/utils/adt/datetime.c,v 1.208 2009/06/11 14:49:03 momjian Exp $
* $PostgreSQL: pgsql/src/backend/utils/adt/datetime.c,v 1.209 2009/08/18 21:23:14 tgl Exp $
*
*-------------------------------------------------------------------------
*/
@ -2986,6 +2986,9 @@ DecodeInterval(char **field, int *ftype, int nf, int range,
break;
case DTK_MILLISEC:
/* avoid overflowing the fsec field */
tm->tm_sec += val / 1000;
val -= (val / 1000) * 1000;
#ifdef HAVE_INT64_TIMESTAMP
*fsec += rint((val + fval) * 1000);
#else