Re: BUG #1517: SQL interval syntax is accepted by the parser,

From: Ron Mayer <rm_pg(at)cheapcomplexdevices(dot)com>
To: Bruce Momjian <pgman(at)candle(dot)pha(dot)pa(dot)us>
Subject: Re: BUG #1517: SQL interval syntax is accepted by the parser,
Date: 2005-03-24 00:02:33
Message-ID: 42420399.9070405@cheapcomplexdevices.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

Bruce Momjian wrote:
> This is going to be a backward compatibility problem

You say that as if it's a bad thing.

In a previous thread, I think Bruce and Tom both commented on
ripping out some of the weird undocumented interval behavior:

http://archives.postgresql.org/pgsql-patches/2003-09/msg00134.php
http://archives.postgresql.org/pgsql-patches/2003-09/msg00123.php

There be a lot of dragons in the PostgreSQL interval syntax.

Some examples from that old thread:
Why is
'0.001 years'::interval
less than
'0.001 months'::interval
or
While does PostgreSQL think the interval
'1Y1M'::interval'
means "1 year and one minute, which is confusing
because the very similar ISO 8601 time interval
'P1Y1M'
means "1 year and one month" to the ISO-8601 spec?

At some point I think breaking backward computability for
some of the weird undocumented behavior of PostgreSQL's
interval syntax would be a good thing. Or perhaps a GUC
variable for IntervalStyle kinda like how DateStyle lets
you pick ISO or SQL or Postgres styles - but that's ugly
in different ways....

Ron

Personally I avoid these problems by still using this hack (a
rejected patch
http://archives.postgresql.org/pgsql-patches/2003-12/msg00196.php
) that allows ISO 8601 "Time Intervals With Time Unit Designators"
in either ISO-8601's "basic format" or "extended format". If anyone's
wants the patch for ISO-8601 ( ftp://ftp.qsl.net/pub/g1smd/154N362_.PDF)
intervals, let me know and I can send a version ported to 8.X.

In my mind ISO-8601 intervals actually make sense while the PostgreSQL
intervals and the ISO-SQL intervals are confusing as heck.

In response to

Browse pgsql-bugs by date

  From Date Subject
Next Message Bruce Momjian 2005-03-24 02:11:46 Re: BUG #1517: SQL interval syntax is accepted by the parser,
Previous Message Roy Badami 2005-03-23 23:57:22 Re: BUG #1517: SQL interval syntax is accepted by the parser,