aboutsummaryrefslogtreecommitdiff
path: root/src/backend/utils/adt/datetime.c
diff options
context:
space:
mode:
authorNeil Conway <neilc@samurai.com>2007-05-29 04:58:43 +0000
committerNeil Conway <neilc@samurai.com>2007-05-29 04:58:43 +0000
commit6af04882de5c519d7e49af8e69a031d2b3b46adc (patch)
treeb134e2f4f34897c2b0fe1a663c3d97d17f9f35f9 /src/backend/utils/adt/datetime.c
parente78720ff2f93dcb82484a310d86ce9875385bc20 (diff)
downloadpostgresql-6af04882de5c519d7e49af8e69a031d2b3b46adc.tar.gz
postgresql-6af04882de5c519d7e49af8e69a031d2b3b46adc.zip
Fix a bug in input processing for the "interval" type. Previously,
"microsecond" and "millisecond" units were not considered valid input by themselves, which caused inputs like "1 millisecond" to be rejected erroneously. Update the docs, add regression tests, and backport to 8.2 and 8.1
Diffstat (limited to 'src/backend/utils/adt/datetime.c')
-rw-r--r--src/backend/utils/adt/datetime.c16
1 files changed, 14 insertions, 2 deletions
diff --git a/src/backend/utils/adt/datetime.c b/src/backend/utils/adt/datetime.c
index 9d1fdd5f40c..b5cc2461589 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.179 2007/05/27 20:32:16 neilc Exp $
+ * $PostgreSQL: pgsql/src/backend/utils/adt/datetime.c,v 1.180 2007/05/29 04:58:43 neilc Exp $
*
*-------------------------------------------------------------------------
*/
@@ -924,6 +924,7 @@ DecodeDateTime(char **field, int *ftype, int nf,
#else
*fsec = frac;
#endif
+ tmask = DTK_ALL_SECS_M;
}
break;
@@ -1699,6 +1700,7 @@ DecodeTimeOnly(char **field, int *ftype, int nf,
#else
*fsec = frac;
#endif
+ tmask = DTK_ALL_SECS_M;
}
break;
@@ -2805,6 +2807,7 @@ DecodeInterval(char **field, int *ftype, int nf, int *dtype, struct pg_tm * tm,
#else
*fsec += (val + fval) * 1e-6;
#endif
+ tmask = DTK_M(MICROSECOND);
break;
case DTK_MILLISEC:
@@ -2813,6 +2816,7 @@ DecodeInterval(char **field, int *ftype, int nf, int *dtype, struct pg_tm * tm,
#else
*fsec += (val + fval) * 1e-3;
#endif
+ tmask = DTK_M(MILLISECOND);
break;
case DTK_SECOND:
@@ -2822,7 +2826,15 @@ DecodeInterval(char **field, int *ftype, int nf, int *dtype, struct pg_tm * tm,
#else
*fsec += fval;
#endif
- tmask = DTK_M(SECOND);
+ /*
+ * If any subseconds were specified, consider
+ * this microsecond and millisecond input as
+ * well.
+ */
+ if (fval == 0)
+ tmask = DTK_M(SECOND);
+ else
+ tmask = DTK_ALL_SECS_M;
break;
case DTK_MINUTE: