diff options
author | Tom Lane <tgl@sss.pgh.pa.us> | 2009-08-18 21:23:28 +0000 |
---|---|---|
committer | Tom Lane <tgl@sss.pgh.pa.us> | 2009-08-18 21:23:28 +0000 |
commit | f57d5b7b4bafeac0dac377f8824e4d99547f327c (patch) | |
tree | e19ed0f696684dc61a2df2b69e8f6d3bfab736dc /src | |
parent | 2792c59a82dcaa2ef13a886031231381bf1980dd (diff) |
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
Diffstat (limited to 'src')
-rw-r--r-- | src/backend/utils/adt/datetime.c | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/src/backend/utils/adt/datetime.c b/src/backend/utils/adt/datetime.c index e2300a3f07b..1408d67a4a4 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.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 |