Re: BUG #1517: SQL interval syntax is accepted by the parser, - Mailing list pgsql-bugs

From Bruce Momjian
Subject Re: BUG #1517: SQL interval syntax is accepted by the parser,
Date
Msg-id 200503201439.j2KEdFE16841@candle.pha.pa.us
Whole thread Raw
In response to Re: BUG #1517: SQL interval syntax is accepted by the parser,  (Roy Badami <roy@gnomon.org.uk>)
Responses Re: BUG #1517: SQL interval syntax is accepted by the parser,  (Roy Badami <roy@gnomon.org.uk>)
Re: BUG #1517: SQL interval syntax is accepted by the parser,  (Tom Lane <tgl@sss.pgh.pa.us>)
List pgsql-bugs
Roy Badami wrote:
>     Bruce>     select interval day to second '1 day 1 hour'
>
>     Bruce> However, we don't support that syntax, only the one with
>     Bruce> the specification after.
>
> Is that valid ANSI SQL?

I guess my point is that we should allow:

    select interval '1' day '1' hour

as SQL standard and equavalent to:

    select interval '1 day 1 hour'

and if we need to specify the data type we would add it before
the data value:

    select interval day to second '1' day '1' hour

I see no way to support the SQL syntax and allow the data type
specification after the data value, and it doesn't make any sense to do
so because it isn't logical and probably not used by anyone, though we
might be able to support it as a specialized case.

We could accept:

    select interval year to month '1' month
    select interval year to month '1 month'

and as a special case:

    select interval '1 month' year to month

but not:

    select interval '1' year to month
    select interval year to month '1'

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

pgsql-bugs by date:

Previous
From: Roy Badami
Date:
Subject: Re: BUG #1517: SQL interval syntax is accepted by the parser,
Next
From: Roy Badami
Date:
Subject: Re: BUG #1517: SQL interval syntax is accepted by the parser,