From: | Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> |
---|---|
To: | Ron Mayer <rm_pg(at)cheapcomplexdevices(dot)com> |
Cc: | pgsql-hackers(at)postgresql(dot)org |
Subject: | Re: Patch for SQL-standard negative valued year-month literals |
Date: | 2008-09-16 21:52:45 |
Message-ID: | 18013.1221601965@sss.pgh.pa.us |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-hackers |
Ron Mayer <rm_pg(at)cheapcomplexdevices(dot)com> writes:
> Short summary:
> I think this patch fixes a bug with sql-spec negative interval literals.
Hmm. I'm a bit concerned about possible side-effects on other cases:
what had been seen as two separate tokens will now become one token
for *all* datetime types, not just interval. However, I can't
immediately think of any likely input formats where this would be a
problem.
Something else I noticed while poking at it is this inconsistency:
regression=# select interval '1';
interval
----------
00:00:01
(1 row)
regression=# select interval '-1';
interval
-----------
-01:00:00
(1 row)
regression=# select interval '+1';
interval
----------
01:00:00
(1 row)
regression=# select interval '1' day;
interval
----------
1 day
(1 row)
regression=# select interval '+1' day;
interval
----------
00:00:00
(1 row)
regression=# select interval '-1' day;
interval
----------
00:00:00
(1 row)
regression=# select interval '1' hour to minute;
interval
----------
00:01:00
(1 row)
regression=# select interval '-1' hour to minute;
interval
-----------
-01:00:00
(1 row)
regression=# select interval '+1' hour to minute;
interval
----------
01:00:00
(1 row)
As soon as you throw in a sign, it gets wacky :-(.
The reason for this bizarreness is this chunk of code at the end of
DecodeInterval's DTK_TZ case:
else if (type == IGNORE_DTF)
{
if (*cp == '.')
{
/*
* Got a decimal point? Then assume some sort of
* seconds specification
*/
type = DTK_SECOND;
}
else if (*cp == '\0')
{
/*
* Only a signed integer? Then must assume a
* timezone-like usage
*/
type = DTK_HOUR;
}
}
which means that a signed integer gets forced to be "hours" if there
isn't an explicit unit spec in the literal, while a signed float gets
forced to be "seconds". I can't see any reason why that's a good idea,
and propose that while we're making incompatible changes in corner cases,
we should just drop the code quoted above.
regards, tom lane
From | Date | Subject | |
---|---|---|---|
Next Message | Ron Mayer | 2008-09-16 22:20:02 | Re: Patch for SQL-standard negative valued year-month literals |
Previous Message | Zdenek Kotala | 2008-09-16 20:40:46 | Re: New FSM patch |