]> granicus.if.org Git - postgresql/commitdiff
Fix overflow for INTERVAL 'x ms' where x is more than a couple million,
authorTom Lane <tgl@sss.pgh.pa.us>
Tue, 18 Aug 2009 21:23:28 +0000 (21:23 +0000)
committerTom Lane <tgl@sss.pgh.pa.us>
Tue, 18 Aug 2009 21:23:28 +0000 (21:23 +0000)
and integer datetimes are in use.  Per bug report from Hubert Depesz
Lubaczewski.

Alex Hunsaker

src/backend/utils/adt/datetime.c

index e2300a3f07b0439372797772a993d8939c296306..1408d67a4a49022e5c31c563ef30adb88e2089ba 100644 (file)
@@ -8,7 +8,7 @@
  *
  *
  * IDENTIFICATION
- *       $PostgreSQL: pgsql/src/backend/utils/adt/datetime.c,v 1.184.2.4 2009/05/01 19:29:13 tgl Exp $
+ *       $PostgreSQL: pgsql/src/backend/utils/adt/datetime.c,v 1.184.2.5 2009/08/18 21:23:28 tgl Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -2828,6 +2828,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