Re: operator suggest " interval / interval = numeric"

From: "Warren Turkal" <wturkal(at)gmail(dot)com>
To: "Brendan Jurd" <direvus(at)gmail(dot)com>
Cc: "Tom Lane" <tgl(at)sss(dot)pgh(dot)pa(dot)us>, Ilya А(dot) Кovalenko <shadow(at)oganer(dot)net>, pgsql-hackers(at)postgresql(dot)org
Subject: Re: operator suggest " interval / interval = numeric"
Date: 2008-01-10 05:38:31
Message-ID: 7fdf8c4d0801092138i75f781dfiafceacbc59aa4cd1@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Jan 9, 2008 9:29 PM, Brendan Jurd <direvus(at)gmail(dot)com> wrote:
> Sorry, a correction. The issue of years vs. days isn't ignored. A
> year is just 12 months, which yields 12 * 30 = 360 days, which is
> actually a pretty significant error (1.4% on average).

YEAR TO MONTH and DAY TO {HOUR,MINUTE,SECOND} intervals should not
combine. PostgreSQL correctly doesn't allow {YEAR,MONTH} TO
{DAY,HOUR,MINUTE,SECOND} intervals, and it shouldn't allow operating
on invalid intervals combinations either. One mistake that PG does
make is that it allows a "FULL RANGE" interval. This weirdness is
essentially a YEAR TO SECOND interval that isn't allowed when
explicitly requested.

wt-time=> select INTERVAL '1 year 1 month 1 day 1:1:1';
interval
-----------------------------
1 year 1 mon 1 day 01:01:01
(1 row)

wt-time=> select INTERVAL '1 year 1 month 1 day 1:1:1' YEAR TO SECOND;
ERROR: syntax error at or near "SECOND"
LINE 1: select INTERVAL '1 year 1 month 1 day 1:1:1' YEAR TO SECOND;
^
This is inconsistent. I would like to ultimately not allow operations
on interval combinations that are not allowed by the SQL standard.

wt

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Tom Lane 2008-01-10 05:51:26 Re: flex/bison output wrongly created in the source directory
Previous Message Brendan Jurd 2008-01-10 05:29:07 Re: operator suggest " interval / interval = numeric"