neilc=# select '1 day 1 millisecond'::interval;
interval
--------------------
1 day 00:00:00.001
(1 row)
neilc=# select '1 millisecond'::interval;
ERROR: invalid input syntax for type interval: "1 millisecond"
neilc=# select '0.001 seconds'::interval;
interval
--------------
00:00:00.001
(1 row)
Similarly for "microsecond".
I think allowing the first input but not the second is pretty
inconsistent. Attached is a patch that fixes this for both milliseconds
and microseconds. The previous coding allowed "x seconds y milliseconds"
to be specified, so this patch preserves that behavior. It *also* allows
"x seconds y seconds" as valid input, although you could make a
consistency argument for that anyway: (with CVS HEAD, unpatched)
neilc=# select '5 days 10 days'::interval;
interval
----------
15 days
neilc=# select '1 week 2 week 3 weeks'::interval;
interval
----------
42 days
neilc=# select '1 second 2 second'::interval;
ERROR: invalid input syntax for type interval: "1 second 2 second"
Is there any reason to why DecodeInterval() is willing to accept
multiple specifications for some time units but not others?
-Neil