aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTom Lane <tgl@sss.pgh.pa.us>2009-05-01 19:29:42 +0000
committerTom Lane <tgl@sss.pgh.pa.us>2009-05-01 19:29:42 +0000
commit2a0f7d1b31b5b5d84488f18424406f980d43e535 (patch)
treedb2f3cc105665e0f2a0890f6a0c9a69cbb8a3776
parent9af91a527bd61673ef257642a315dad0765a807a (diff)
downloadpostgresql-2a0f7d1b31b5b5d84488f18424406f980d43e535.tar.gz
postgresql-2a0f7d1b31b5b5d84488f18424406f980d43e535.zip
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.
-rw-r--r--src/backend/utils/adt/datetime.c10
1 files changed, 5 insertions, 5 deletions
diff --git a/src/backend/utils/adt/datetime.c b/src/backend/utils/adt/datetime.c
index c2a8a46b301..cb57d8182fe 100644
--- a/src/backend/utils/adt/datetime.c
+++ b/src/backend/utils/adt/datetime.c
@@ -8,7 +8,7 @@
*
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/backend/utils/adt/datetime.c,v 1.118.2.11 2009/03/05 14:29:26 heikki Exp $
+ * $Header: /cvsroot/pgsql/src/backend/utils/adt/datetime.c,v 1.118.2.12 2009/05/01 19:29:42 tgl Exp $
*
*-------------------------------------------------------------------------
*/
@@ -2217,13 +2217,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
@@ -2482,13 +2482,13 @@ DecodeTime(char *str, int fmask, int *tmask, struct 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