Re: BUG #1871: operations with data types

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Michael Fuhr <mike(at)fuhr(dot)org>
Cc: anris(at)polynet(dot)lviv(dot)ua, pgsql-bugs(at)postgresql(dot)org
Subject: Re: BUG #1871: operations with data types
Date: 2005-09-13 13:54:16
Message-ID: 22678.1126619656@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

Michael Fuhr <mike(at)fuhr(dot)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

In response to

Responses

Browse pgsql-bugs by date

  From Date Subject
Next Message Abdulkadir Nazif 2005-09-13 14:14:54 BUG #1880: Installation failure
Previous Message Michael Fuhr 2005-09-13 13:10:16 Re: BUG #1871: operations with data types