BUG #1518: Conversions to (undocumented) SQL year-month and day-time interval types silently discard data

From: "Roy Badami" <roy(at)gnomon(dot)org(dot)uk>
To: pgsql-bugs(at)postgresql(dot)org
Subject: BUG #1518: Conversions to (undocumented) SQL year-month and day-time interval types silently discard data
Date: 2005-03-02 22:22:15
Message-ID: 20050302222215.CB550F1274@svr2.postgresql.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs


The following bug has been logged online:

Bug reference: 1518
Logged by: Roy Badami
Email address: roy(at)gnomon(dot)org(dot)uk
PostgreSQL version: 8.0.1
Operating system: Solaris 9
Description: Conversions to (undocumented) SQL year-month and
day-time interval types silently discard data
Details:

Conversions to the (undocumented) SQL year-month and day-time intervals
silently discard data, instead of raising an exception.

Note, the following examples intentinally use non-standard interval syntax,
since SQL standard interval syntax appears to be broken...

radius=# create table foo (year_month interval year to month);
CREATE TABLE
radius=# insert into foo values ('1 year 1 month');
INSERT 19963 1
radius=# select * from foo;
year_month
--------------
1 year 1 mon
(1 row)

-- correct

radius=# insert into foo values ('1 hour 1 minute');
INSERT 19964 1

-- should be an error, I think?

radius=# select * from foo;
year_month
--------------
1 year 1 mon
00:00:00
(2 rows)

-- but instead the interval has been replaced by a zero interval

radius=# create table bar (day_time interval day to second);
CREATE TABLE
radius=# insert into bar values ('1 hour 1 minute');
INSERT 19968 1
radius=# select * from bar;
day_time
----------
01:01:00
(1 row)

-- correct

radius=# insert into bar values ('1 year 1 month');
INSERT 19969 1

-- should be an error, I think?

radius=# select * from bar;
day_time
----------
01:01:00
00:00:00
(2 rows)

-- but instead has been converted to a zero interval

Responses

Browse pgsql-bugs by date

  From Date Subject
Next Message Roy Badami 2005-03-02 22:32:40 Re: BUG #1516: DOC BUG: Interval type syntax and interval literal
Previous Message Roy Badami 2005-03-02 21:56:19 BUG #1517: SQL interval syntax is accepted by the parser, but the interpretation is bogus