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-20 14:18:12
Message-ID: 200503201418.j2KEIC303047@candle.pha.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

Roy Badami wrote:
> Tom> Feel like hacking the code?
>
> Hmm, in principle I might take a look some time; in reality it's
> unlikely I'll have time any time soon...
>
> There are some design issues involved, though. If you have the type
> modifier, do you isnist on SQL syntax in the string?
>
> ie do you accept
>
> select interval '1 day 1 hour' day to second
>
> Personally I think it would be a bad idea to allow hybrid SQL/postgres
> syntax like this.

I am wondering why we allow the 'interval' data type specification to be
after the string. It seems this should be written as:

select interval day to second '1 day 1 hour'

However, we don't support that syntax, only the one with the
specification after.

Timestamp does it logically with 'time zone':

test=> select timestamp with time zone '2004-01-01';
timestamptz
------------------------
2004-01-01 00:00:00-05
(1 row)

test=> select timestamp '2004-01-01' with time zone;
ERROR: syntax error at or near "with" at character 31

So, I am thinking we should allow something like this:

interval day to second '1' hour

where the 'day to second' is the interval data type specification and
'hour' is the data value specification.

I realize this might break backward compatibility but we never
documented that syntax and we need to use it to be consistent with the
SQL standard.

--
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

Browse pgsql-bugs by date

  From Date Subject
Next Message Roy Badami 2005-03-20 14:20:09 Re: BUG #1517: SQL interval syntax is accepted by the parser,
Previous Message David B. 2005-03-20 06:21:54 pl/pgsql doesn't load