]> git.ipfire.org Git - thirdparty/postgresql.git/commitdiff
Allow 60 in seconds fields of timestamp, time, interval input values.
authorTom Lane <tgl@sss.pgh.pa.us>
Sun, 4 May 2003 04:30:35 +0000 (04:30 +0000)
committerTom Lane <tgl@sss.pgh.pa.us>
Sun, 4 May 2003 04:30:35 +0000 (04:30 +0000)
Per recent discussion on pgsql-general, this is appropriate for spec
compliance, and has the nice side-effect of easing porting from old
pg_dump files that exhibit the 59.999=>60.000 roundoff problem.

src/backend/utils/adt/datetime.c
src/backend/utils/adt/nabstime.c

index 0ce56d0774638cda81b5c472cdfeab83000de3f6..20c45bee32dfa582ee3b86f96af5b251990b1847 100644 (file)
@@ -8,7 +8,7 @@
  *
  *
  * IDENTIFICATION
- *       $Header: /cvsroot/pgsql/src/backend/utils/adt/datetime.c,v 1.96.2.4 2003/02/20 05:25:24 tgl Exp $
+ *       $Header: /cvsroot/pgsql/src/backend/utils/adt/datetime.c,v 1.96.2.5 2003/05/04 04:30:35 tgl Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -2061,15 +2061,16 @@ DecodeTimeOnly(char **field, int *ftype, int nf,
                tm->tm_hour += 12;
 
 #ifdef HAVE_INT64_TIMESTAMP
-       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))
+       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)))
                return -1;
 #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 + *fsec) >= 60)))
+       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))
                return -1;
 #endif
 
@@ -2294,14 +2295,14 @@ DecodeTime(char *str, int fmask, int *tmask, struct tm * tm, fsec_t *fsec)
 #ifdef HAVE_INT64_TIMESTAMP
        if ((tm->tm_hour < 0)
                || (tm->tm_min < 0) || (tm->tm_min > 59)
-               || (tm->tm_sec < 0) || (tm->tm_sec > 59)
-               || (*fsec >= INT64CONST(1000000)))
+               || (tm->tm_sec < 0) || (tm->tm_sec > 60)
+               || (*fsec < INT64CONST(0)) || (*fsec >= INT64CONST(1000000)))
                return -1;
 #else
        if ((tm->tm_hour < 0)
                || (tm->tm_min < 0) || (tm->tm_min > 59)
-               || (tm->tm_sec < 0) || (tm->tm_sec > 59)
-               || (*fsec >= 1))
+               || (tm->tm_sec < 0) || (tm->tm_sec > 60)
+               || (*fsec < 0) || (*fsec >= 1))
                return -1;
 #endif
 
index 6de79aaa9cdf78f64bf87c0337c47a11ea07ff81..0d1dea214a2698b9c9c9a35299880ab84de25a50 100644 (file)
@@ -9,7 +9,7 @@
  *
  *
  * IDENTIFICATION
- *       $Header: /cvsroot/pgsql/src/backend/utils/adt/nabstime.c,v 1.100.2.3 2003/02/20 05:25:24 tgl Exp $
+ *       $Header: /cvsroot/pgsql/src/backend/utils/adt/nabstime.c,v 1.100.2.4 2003/05/04 04:30:35 tgl Exp $
  *
  * NOTES
  *
@@ -427,9 +427,9 @@ tm2abstime(struct tm * tm, int tz)
        if (tm->tm_year < 1901 || tm->tm_year > 2038
                || tm->tm_mon < 1 || tm->tm_mon > 12
                || tm->tm_mday < 1 || tm->tm_mday > 31
-               || tm->tm_hour < 0 || tm->tm_hour >= 24
+               || tm->tm_hour < 0 || tm->tm_hour > 23
                || tm->tm_min < 0 || tm->tm_min > 59
-               || tm->tm_sec < 0 || tm->tm_sec > 59)
+               || tm->tm_sec < 0 || tm->tm_sec > 60)
                return INVALID_ABSTIME;
 
        day = (date2j(tm->tm_year, tm->tm_mon, tm->tm_mday) - date2j(1970, 1, 1));