summaryrefslogtreecommitdiff
path: root/src/backend/utils/adt
diff options
context:
space:
mode:
Diffstat (limited to 'src/backend/utils/adt')
-rw-r--r--src/backend/utils/adt/datetime.c26
-rw-r--r--src/backend/utils/adt/timestamp.c6
2 files changed, 25 insertions, 7 deletions
diff --git a/src/backend/utils/adt/datetime.c b/src/backend/utils/adt/datetime.c
index 6712d6d8d44..a1cf2b4ed54 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.191 2008/09/10 18:29:41 tgl Exp $
+ * $PostgreSQL: pgsql/src/backend/utils/adt/datetime.c,v 1.192 2008/09/11 15:27:30 tgl Exp $
*
*-------------------------------------------------------------------------
*/
@@ -2256,9 +2256,25 @@ DecodeTime(char *str, int fmask, int range,
tm->tm_hour = 0;
}
}
- else if (*cp != ':')
- return DTERR_BAD_FORMAT;
- else
+ else if (*cp == '.')
+ {
+ /* always assume mm:ss.sss is MINUTE TO SECOND */
+ double frac;
+
+ str = cp;
+ frac = strtod(str, &cp);
+ if (*cp != '\0')
+ return DTERR_BAD_FORMAT;
+#ifdef HAVE_INT64_TIMESTAMP
+ *fsec = rint(frac * 1000000);
+#else
+ *fsec = frac;
+#endif
+ tm->tm_sec = tm->tm_min;
+ tm->tm_min = tm->tm_hour;
+ tm->tm_hour = 0;
+ }
+ else if (*cp == ':')
{
str = cp + 1;
errno = 0;
@@ -2284,6 +2300,8 @@ DecodeTime(char *str, int fmask, int range,
else
return DTERR_BAD_FORMAT;
}
+ else
+ return DTERR_BAD_FORMAT;
/* do a sanity check */
#ifdef HAVE_INT64_TIMESTAMP
diff --git a/src/backend/utils/adt/timestamp.c b/src/backend/utils/adt/timestamp.c
index 9060b989f9c..acfc89ba047 100644
--- a/src/backend/utils/adt/timestamp.c
+++ b/src/backend/utils/adt/timestamp.c
@@ -8,7 +8,7 @@
*
*
* IDENTIFICATION
- * $PostgreSQL: pgsql/src/backend/utils/adt/timestamp.c,v 1.191 2008/09/10 18:29:41 tgl Exp $
+ * $PostgreSQL: pgsql/src/backend/utils/adt/timestamp.c,v 1.192 2008/09/11 15:27:30 tgl Exp $
*
*-------------------------------------------------------------------------
*/
@@ -744,7 +744,7 @@ intervaltypmodin(PG_FUNCTION_ARGS)
tl = ArrayGetIntegerTypmods(ta, &n);
/*
- * tl[0] - opt_interval tl[1] - Iconst (optional)
+ * tl[0] - interval range (fields bitmask) tl[1] - precision (optional)
*
* Note we must validate tl[0] even though it's normally guaranteed
* correct by the grammar --- consider SELECT 'foo'::"interval"(1000).
@@ -881,7 +881,7 @@ intervaltypmodout(PG_FUNCTION_ARGS)
}
if (precision != INTERVAL_FULL_PRECISION)
- snprintf(res, 64, "(%d)%s", precision, fieldstr);
+ snprintf(res, 64, "%s(%d)", fieldstr, precision);
else
snprintf(res, 64, "%s", fieldstr);