Skip site navigation (1) Skip section navigation (2)

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

From: Bruce Momjian <pgman(at)candle(dot)pha(dot)pa(dot)us>
To: Roy Badami <roy(at)gnomon(dot)org(dot)uk>
Cc: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, pgsql-bugs(at)postgresql(dot)org
Subject: Re: BUG #1517: SQL interval syntax is accepted by the parser,
Date: 2005-03-24 03:39:27
Message-ID: (view raw, whole thread or download thread mbox)
Lists: pgsql-bugs
Roy Badami wrote:
>     Roy> The 'constraint' (interval type descriptor or whatever it's
>     Roy> really called) is mandatory in standard SQL, I think, so
>     Roy> there's no ambiguity anyway, unless anyone is using this
>     Roy> undocumented syntax at the moment...
> Incidentally, this was the ratinale behind my earlier suggestion, that:
>  * if the interval type descriptor is absent, parse the interval as a
>    traditional postgres interval
>  * if the interval type descriptor is present, parse the interval according
>    to the standard syntax
> I have no objection to allowing things like
>    '1 hour 10 minutes' DAY TO SECOND
> but I'm just wondering whether the hybrid syntax is an unnecessary
> complication.

Added to TODO:

        o For syntax that isn't uniquely ISO or PG syntax, like '1:30' or
          '1', treat as ISO if there is a range specification clause,
          and as PG if there no clause is present, e.g. interpret '1:30'
          MINUTE TO SECOND as '1 minute 30 seconds', and interpret '1:30'
          as '1 hour, 30 minutes'

This brings up the issue of how we are to output interval values. 
Currently we do:
	test=> select interval '1 hour 1 minute';
	(1 row)

	test=> select interval '1 hour 1 second' hour to minute;
	(1 row)

so I think we are OK because we don't output ambiguous syntax.

  Bruce Momjian                        |
  pgman(at)candle(dot)pha(dot)pa(dot)us               |  (610) 359-1001
  +  If your life is a hard drive,     |  13 Roberts Road
  +  Christ can be your backup.        |  Newtown Square, Pennsylvania 19073

In response to


pgsql-bugs by date

Next:From: Bruce MomjianDate: 2005-03-24 03:49:48
Subject: Re: BUG #1518: Conversions to (undocumented) SQL year-month and
Previous:From: Bruce MomjianDate: 2005-03-24 02:11:46
Subject: Re: BUG #1517: SQL interval syntax is accepted by the parser,

Privacy Policy | About PostgreSQL
Copyright © 1996-2017 The PostgreSQL Global Development Group