Pavel Stehule escribió:
> It was my mistake - I was confused from timestamp with time zone type,
> what has zero related to date and time.
>
> fixed to immutable,
> fixed duplicate oid
Thanks. I wasn't sure about the error message returned when times are
outside range; how about this instead? I'm not wedded to this approach
-- I can return to yours if this one isn't liked -- but I think the
more specific messages are better. I realize this is inconsistent with
the make_date case which always displays the full date instead of
specific fields, but I think it's more likely that someone is doing
arithmetic to enter time fields than date. (Anyway maybe this is not an
important enough issue to create more work for translators.)
+ if (tm_hour < 0 || tm_hour > HOURS_PER_DAY)
+ ereport(ERROR,
+ (errcode(ERRCODE_DATETIME_FIELD_OVERFLOW),
+ errmsg("hours field in time value out of range: \"%02d\"",
+ tm_hour)));
+
+ if (tm_min < 0 || tm_min > MINS_PER_HOUR - 1)
+ ereport(ERROR,
+ (errcode(ERRCODE_DATETIME_FIELD_OVERFLOW),
+ errmsg("minutes field in time value out of range: \"%02d\"",
+ tm_min)));
+
+ if (sec < 0.0 || sec > (float8) SECS_PER_MINUTE)
+ ereport(ERROR,
+ (errcode(ERRCODE_DATETIME_FIELD_OVERFLOW),
+ errmsg("seconds field in time value out of range: \"%0*.*f\"",
+ MAX_TIME_PRECISION + 3,
+ MAX_TIME_PRECISION, fabs(sec))));
+
+ /* test for > 24:00:00 */
+ if ((tm_hour == HOURS_PER_DAY && (tm_min > 0 || sec > 0.0)))
+ ereport(ERROR,
+ (errcode(ERRCODE_DATETIME_FIELD_OVERFLOW),
+ errmsg("time value out of range: \"%02d:%02d:%0*.*f\"",
+ tm_hour, tm_min,
+ MAX_TIME_PRECISION + 3,
+ MAX_TIME_PRECISION, fabs(sec))));
Other than that (and fixing regression tests as appropriate), I think
the attached, which has mild corrections over your v5, is ready to
commit. (You had one missing semicolon in the float timestamp case.)
--
Álvaro Herrera http://www.2ndQuadrant.com/
PostgreSQL Development, 24x7 Support, Training & Services