]> git.ipfire.org Git - thirdparty/postgresql.git/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:42 +0000 (21:23 +0000)
committerTom Lane <tgl@sss.pgh.pa.us>
Tue, 18 Aug 2009 21:23:42 +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 a1082fa09e18b346ba799218a1a167a9e76259f8..4375a92040f0dd20eee6317d36af02d72bfcb7d2 100644 (file)
@@ -8,7 +8,7 @@
  *
  *
  * IDENTIFICATION
- *       $PostgreSQL: pgsql/src/backend/utils/adt/datetime.c,v 1.160.2.9 2009/05/01 19:29:27 tgl Exp $
+ *       $PostgreSQL: pgsql/src/backend/utils/adt/datetime.c,v 1.160.2.10 2009/08/18 21:23:42 tgl Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -3135,6 +3135,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