diff options
author | Tom Lane <tgl@sss.pgh.pa.us> | 2009-05-01 19:29:34 +0000 |
---|---|---|
committer | Tom Lane <tgl@sss.pgh.pa.us> | 2009-05-01 19:29:34 +0000 |
commit | 7c26416ffdf1ed336c811842c5bb0aa76a61c140 (patch) | |
tree | fe55aeadd5b9148b207a90f246b282f2926ea625 /src | |
parent | 6e7b2d846c678b59435e20851db921903a5be7db (diff) |
When checking for datetime field overflow, we should allow a fractional-second
part that rounds up to exactly 1.0 second. The previous coding rejected input
like "00:12:57.9999999999999999999999999999", with the exact number of nines
needed to cause failure varying depending on float-timestamp option and
possibly on platform. Obviously this should round up to the next integral
second, if we don't have enough precision to distinguish the value from that.
Per bug #4789 from Robert Kruus.
In passing, fix a missed check for fractional seconds in one copy of the
"is it greater than 24:00:00" code.
Broken all the way back, so patch all the way back.
Diffstat (limited to 'src')
-rw-r--r-- | src/backend/utils/adt/datetime.c | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/src/backend/utils/adt/datetime.c b/src/backend/utils/adt/datetime.c index 6ed5ea5e2c1..063c1c4dd81 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.8 2009/03/05 14:29:12 heikki Exp $ + * $PostgreSQL: pgsql/src/backend/utils/adt/datetime.c,v 1.137.4.9 2009/05/01 19:29:34 tgl Exp $ * *------------------------------------------------------------------------- */ @@ -2207,13 +2207,13 @@ DecodeTimeOnly(char **field, int *ftype, int nf, if ((tm->tm_hour < 0) || (tm->tm_hour > 23) || (tm->tm_min < 0) || (tm->tm_min > 59) || (tm->tm_sec < 0) || (tm->tm_sec > 60) - || (*fsec < INT64CONST(0)) || (*fsec >= INT64CONST(1000000))) + || (*fsec < INT64CONST(0)) || (*fsec > INT64CONST(1000000))) return DTERR_FIELD_OVERFLOW; #else if ((tm->tm_hour < 0) || (tm->tm_hour > 23) || (tm->tm_min < 0) || (tm->tm_min > 59) || (tm->tm_sec < 0) || (tm->tm_sec > 60) - || (*fsec < 0) || (*fsec >= 1)) + || (*fsec < 0) || (*fsec > 1)) return DTERR_FIELD_OVERFLOW; #endif @@ -2493,13 +2493,13 @@ DecodeTime(char *str, int fmask, int *tmask, struct pg_tm * tm, fsec_t *fsec) if ((tm->tm_hour < 0) || (tm->tm_min < 0) || (tm->tm_min > 59) || (tm->tm_sec < 0) || (tm->tm_sec > 60) - || (*fsec < INT64CONST(0)) || (*fsec >= INT64CONST(1000000))) + || (*fsec < INT64CONST(0)) || (*fsec > INT64CONST(1000000))) return DTERR_FIELD_OVERFLOW; #else if ((tm->tm_hour < 0) || (tm->tm_min < 0) || (tm->tm_min > 59) || (tm->tm_sec < 0) || (tm->tm_sec > 60) - || (*fsec < 0) || (*fsec >= 1)) + || (*fsec < 0) || (*fsec > 1)) return DTERR_FIELD_OVERFLOW; #endif |