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: 200503240339.j2O3dRh06332@candle.pha.pa.us (view raw or flat)
Thread:
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';
	 interval
	----------
	 01:01:00
	(1 row)

and
	
	test=> select interval '1 hour 1 second' hour to minute;
	 interval
	----------
	 01:00:00
	(1 row)

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

-- 
  Bruce Momjian                        |  http://candle.pha.pa.us
  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

Responses

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-2014 The PostgreSQL Global Development Group