Re: BUG #7498: Questionable interval parsing when in the form 'n m days'

From: Daniel Farina <daniel(at)heroku(dot)com>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: pgsql-bugs(at)postgresql(dot)org
Subject: Re: BUG #7498: Questionable interval parsing when in the form 'n m days'
Date: 2012-08-16 01:04:35
Message-ID: CAAZKuFYGhcYqZcvSn9=e8M6Y5KbaXKA0e+YUPNjwJuf+B7hi-A@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

On Wed, Aug 15, 2012 at 5:19 PM, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> wrote:
> daniel(at)heroku(dot)com writes:
>> select '1 5 hours'::interval = '1 day 5 hours'::interval;
>> ?column?
>> ----------
>> t
>> (1 row)
>
>> I think that the first spelling, a unit-less '1', should not be accepted.
>
> Not sure I agree. The syntax '1 05:00' is required by spec to mean
> '1 day 5 hours 0 minutes'. I would take that to mean that a unitless
> number directly to the left of an hours field is days. Anyway, the
> code in DecodeInterval is treating these cases the same.

Interesting. I see your point, but I think that a user writing a
symbolic name of the unit is probably different than the one relying
on '1 05:00'. My reasoning is that without any units specified that
what one has is a syntax that is contingent on position, whereas the
symbolic units are not:

select '3 minute 1 day'::interval = '1 day 3 minute'::interval;

And I think that's why '1 5 hours' is funny looking vs '1 5:00', borne
out more by the confusion as to why 'hours' is given this special
status but any other unit that I have tried is not. It also reads
much closer to "15 hours" than "1 5:00" does in my opinion.

I am hard pressed to imagine a person who would prefer the 'M N hours'
variant of the notation be accepted, but perhaps that is more of a
general problem with the positional syntax...consider:

select '1 5:'::interval = '1 day 5 hours'::interval;

Whereby the valid interval string is "1 5:".

--
fdr

In response to

Browse pgsql-bugs by date

  From Date Subject
Next Message Heikki Linnakangas 2012-08-16 10:02:19 Re: ERROR - CREATE GIST INDEX on 9.2 beta3
Previous Message Tom Lane 2012-08-16 00:37:47 Re: ProblemWithCharsOSX