pg.ddx.io pgsql-bugs@postgresql.org mailing list archive
help / color / mirror / Atom feedBUG #7498: Questionable interval parsing when in the form 'n m days'
3+ messages / 3 participants
[nested] [flat]
* BUG #7498: Questionable interval parsing when in the form 'n m days'
@ 2012-08-15 23:06 daniel@heroku.com
0 siblings, 1 reply; 3+ messages in thread
From: daniel@heroku.com @ 2012-08-15 23:06 UTC (permalink / raw)
To: pgsql-bugs
The following bug has been logged on the website:
Bug reference: 7498
Logged by: Daniel Farina
Email address: daniel@heroku.com
PostgreSQL version: 9.1.4
Operating system: Ubuntu 12.04
Description:
This is an expression that should probably have an error and not evaluate to
"true":
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.
Other unit combinations agree:
select '1 5 minutes'::interval;
ERROR: invalid input syntax for type interval: "1 5 minutes"
LINE 1: select '1 5 minutes'::interval;
^
select '1 5 months'::interval;
ERROR: invalid input syntax for type interval: "1 5 months"
LINE 1: select '1 5 months'::interval;
^
select '1 5 seconds'::interval;
ERROR: invalid input syntax for type interval: "1 5 seconds"
LINE 1: select '1 5 seconds'::interval;
^ permalink raw reply [nested|flat] 3+ messages in thread
* Re: BUG #7498: Questionable interval parsing when in the form 'n m days'
@ 2012-08-16 00:19 Tom Lane <tgl@sss.pgh.pa.us>
parent: daniel@heroku.com
0 siblings, 1 reply; 3+ messages in thread
From: Tom Lane @ 2012-08-16 00:19 UTC (permalink / raw)
To: daniel@heroku.com; +Cc: pgsql-bugs
daniel@heroku.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.
regards, tom lane
^ permalink raw reply [nested|flat] 3+ messages in thread
* Re: BUG #7498: Questionable interval parsing when in the form 'n m days'
@ 2012-08-16 01:04 Daniel Farina <daniel@heroku.com>
parent: Tom Lane <tgl@sss.pgh.pa.us>
0 siblings, 0 replies; 3+ messages in thread
From: Daniel Farina @ 2012-08-16 01:04 UTC (permalink / raw)
To: Tom Lane <tgl@sss.pgh.pa.us>; +Cc: pgsql-bugs
On Wed, Aug 15, 2012 at 5:19 PM, Tom Lane <tgl@sss.pgh.pa.us> wrote:
> daniel@heroku.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
^ permalink raw reply [nested|flat] 3+ messages in thread
end of thread, other threads:[~2012-08-16 01:04 UTC | newest]
Thread overview: 3+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2012-08-15 23:06 BUG #7498: Questionable interval parsing when in the form 'n m days' daniel@heroku.com
2012-08-16 00:19 ` Tom Lane <tgl@sss.pgh.pa.us>
2012-08-16 01:04 ` Daniel Farina <daniel@heroku.com>
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox