Michael Fuhr <[EMAIL PROTECTED]> 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

---------------------------(end of broadcast)---------------------------
TIP 3: Have you checked our extensive FAQ?

               http://www.postgresql.org/docs/faq

Reply via email to