Interval input: usec, msec

Поиск
Список
Период
Сортировка
От Neil Conway
Тема Interval input: usec, msec
Дата
Msg-id 1180327472.6152.16.camel@goldbach
обсуждение исходный текст
Ответы Re: Interval input: usec, msec  (Tom Lane <tgl@sss.pgh.pa.us>)
Список pgsql-patches
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


Вложения

В списке pgsql-patches по дате отправления:

Предыдущее
От: "Jim C. Nasby"
Дата:
Сообщение: Re: Maintaining cluster order on insert
Следующее
От: Tom Lane
Дата:
Сообщение: Re: Interval input: usec, msec