Re: BUG #1871: operations with data types

Поиск
Список
Период
Сортировка
От Tom Lane
Тема Re: BUG #1871: operations with data types
Дата
Msg-id 22678.1126619656@sss.pgh.pa.us
обсуждение исходный текст
Ответ на Re: BUG #1871: operations with data types  (Michael Fuhr <mike@fuhr.org>)
Ответы Re: BUG #1871: operations with data types  (Bruce Momjian <pgman@candle.pha.pa.us>)
Список pgsql-bugs
Michael Fuhr <mike@fuhr.org> writes:
> I just noticed something in PostgreSQL that might be considered
> surprising (although I do see "Add ISO INTERVAL handling" in the
> TODO list):

>   test=> select interval '1' month;
>    interval
>   ----------
>    00:00:00
>   (1 row)

> What's the parser doing here?

Not getting it right ;-).  Trying this in historical versions is
amusing:

7.0:
regression=# select interval '1' month;
ERROR:  parser: parse error at or near "month"

7.1:
regression=# select interval '1' month;
ERROR:  Bad interval external representation '1'

7.2:
regression=# select interval '1' month;
 interval
----------
 00:00
(1 row)

7.3:
regression=# select interval '1' month;
 interval
----------
 00:00:01
(1 row)

7.4 and up:
regression=# select interval '1' month;
 interval
----------
 00:00:00
(1 row)

What is happening in the current versions is that coerce_type thinks
it can coerce the literal string to interval without supplying the
modifier, and then use interval_scale() to apply the typmod.  This
works OK for most of the data types, but not for interval it seems...

Basically the support for these weird syntaxes is something that Tom
Lockhart never finished, and no one has bothered to pick up the work
since he left the project.

            regards, tom lane

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

Предыдущее
От: Michael Fuhr
Дата:
Сообщение: Re: BUG #1871: operations with data types
Следующее
От: Tom Lane
Дата:
Сообщение: Re: Race-condition with failed block-write?