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

From Roy Badami
Subject Re: BUG #1517: SQL interval syntax is accepted by the parser,
Date
Msg-id 16961.54371.882191.556057@giles.gnomon.org.uk
Whole thread Raw
In response to Re: BUG #1517: SQL interval syntax is accepted by the parser,  (Bruce Momjian <pgman@candle.pha.pa.us>)
Responses Re: BUG #1517: SQL interval syntax is accepted by the parser,  (Bruce Momjian <pgman@candle.pha.pa.us>)
List pgsql-bugs
Bruce> The reason I added it is that usually people think of the
    Bruce> PG syntax as '1 hour 30 seconds'.  The '1:30' is a kind of
    Bruce> subtle because both PG and ANSI support that syntax and we
    Bruce> need to handle that.  The tricky part is that we can't say
    Bruce> by looking at '1:30' whether it is PG or ANSI, and that
    Bruce> will affect how we deal with the clause after it.

It could be either in ANSI:

   INTERVAL '1:30' MINUTE TO SECOND
   INTERVAL '1:30' HOUR TO MINUTE

Similarly, pg interprets

   INTERVAL '1'

as

   INTERVAL '1 second'

In ANSI, it could be any one of

   INTERVAL '1' SECOND
   INTERVAL '1' MINUTE
   INTERVAL '1' HOUR
   INTERVAL '1' DAY
   INTERVAL '1' MONTH
   INTERVAL '1' YEAR

In ANSI you can only parse the string by reference to the interval type.

   -roy

pgsql-bugs by date:

Previous
From: Bruce Momjian
Date:
Subject: Re: BUG #1517: SQL interval syntax is accepted by the parser,
Next
From: Keith Browne
Date:
Subject: Re: BUG #1552: massive performance hit between 7.4 and 8.0.1