postgres.git / summary / log / commit / refs

commit    68dfd1de9e80f6eb9f624cfdb86221759de12169
Author:   Tom Lane <tgl@sss.pgh.pa.us>
Date:     Tue Aug 18 21:23:50 2009 +0000
First released in: 9.0.0, 7.4.26, 8.0.22, 8.1.18, 8.2.14, 8.3.8, 8.4.1

    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


src/backend/utils/adt/datetime.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/backend/utils/adt/datetime.c b/src/backend/utils/adt/datetime.c index 063c1c4dd81..dbc7e575173 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.137.4.9 2009/05/01 19:29:34 tgl Exp $ + * $PostgreSQL: pgsql/src/backend/utils/adt/datetime.c,v 1.137.4.10 2009/08/18 21:23:50 tgl Exp $ * *------------------------------------------------------------------------- */ @@ -3103,6 +3103,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 [parent: 484fe4188445]