Re: [HACKERS] New to_timestamp implementation is pretty strict

2008-12-02 Thread Heikki Linnakangas
Tom Lane wrote: After thinking about it I'm inclined to feel that SS and friends should insist on exactly 2 digits. If you want to allow 1-or-2-digits then use FMSS, just like the error message tells you. (However, I have a vague feeling that Oracle doesn't insist on this, and in the end we

[HACKERS] New to_timestamp implementation is pretty strict

2008-12-01 Thread Heikki Linnakangas
I like strict in general, but this doesn't seem logical: postgres=# SELECT to_timestamp('29-12-2005 01:2:03', 'DD-MM- HH24:MI:SS'); -- works to_timestamp 2005-12-29 01:02:03+02 (1 row) postgres=# SELECT to_timestamp('29-12-2005 01:02:3', 'DD-MM-

Re: [HACKERS] New to_timestamp implementation is pretty strict

2008-12-01 Thread David E. Wheeler
On Dec 1, 2008, at 1:08 PM, Heikki Linnakangas wrote: postgres=# SELECT to_timestamp('29-12-2005 01:02:3', 'DD-MM- HH24:MI:SS'); -- doesn't work ERROR: source string too short for SS formatting field DETAIL: Field requires 2 characters, but only 1 remain. HINT: If your source string is

Re: [HACKERS] New to_timestamp implementation is pretty strict

2008-12-01 Thread Tom Lane
David E. Wheeler [EMAIL PROTECTED] writes: On Dec 1, 2008, at 1:08 PM, Heikki Linnakangas wrote: I think the end of string should be treated like a field separator, colon in this example, and we should accept both of the above. Opinions? I'm generally in favor of being generous in the

Re: [HACKERS] New to_timestamp implementation is pretty strict

2008-12-01 Thread Dave Page
On Mon, Dec 1, 2008 at 2:45 PM, David E. Wheeler [EMAIL PROTECTED] wrote: On Dec 1, 2008, at 1:08 PM, Heikki Linnakangas wrote: postgres=# SELECT to_timestamp('29-12-2005 01:02:3', 'DD-MM- HH24:MI:SS'); -- doesn't work ERROR: source string too short for SS formatting field DETAIL:

Re: [HACKERS] New to_timestamp implementation is pretty strict

2008-12-01 Thread David E. Wheeler
On Dec 1, 2008, at 3:52 PM, Tom Lane wrote: I'm generally in favor of being generous in the input one can accept, but in this case it seems ambiguous to me. Is that supposed to be :30 or :03? There's no way to tell. But notice that we are allowing a single digit for the hour and minute

Re: [HACKERS] New to_timestamp implementation is pretty strict

2008-12-01 Thread David E. Wheeler
On Dec 1, 2008, at 3:55 PM, Dave Page wrote: I'm generally in favor of being generous in the input one can accept, but in this case it seems ambiguous to me. Is that supposed to be :30 or : 03? There's no way to tell. How is it ambiguous? The leading zero is technically redundant. A

Re: [HACKERS] New to_timestamp implementation is pretty strict

2008-12-01 Thread Alvaro Herrera
David E. Wheeler wrote: Oh, well yeah, it should be consistent. But I'm still not sure that :3 should be allowed. OTOH, who does that, anyway? Anyone who prints times as %d:%d:%d. You can find those in the wild. -- Alvaro Herrera

Re: [HACKERS] New to_timestamp implementation is pretty strict

2008-12-01 Thread Dave Page
On Mon, Dec 1, 2008 at 3:02 PM, David E. Wheeler [EMAIL PROTECTED] wrote: it depends on how you look at it, I suppose. If you look at :xy as x being the 10s position and y being the 1s position, it makes no sense. Suffice it to say, I don't look at it that way :-). I'd wager most people

Re: [HACKERS] New to_timestamp implementation is pretty strict

2008-12-01 Thread David E. Wheeler
On Dec 1, 2008, at 4:07 PM, Alvaro Herrera wrote: David E. Wheeler wrote: Oh, well yeah, it should be consistent. But I'm still not sure that :3 should be allowed. OTOH, who does that, anyway? Anyone who prints times as %d:%d:%d. You can find those in the wild. I guess I should have

Re: [HACKERS] New to_timestamp implementation is pretty strict

2008-12-01 Thread David E. Wheeler
On Dec 1, 2008, at 4:09 PM, Dave Page wrote: On Mon, Dec 1, 2008 at 3:02 PM, David E. Wheeler [EMAIL PROTECTED] wrote: it depends on how you look at it, I suppose. If you look at :xy as x being the 10s position and y being the 1s position, it makes no sense. Suffice it to say, I don't

Re: [HACKERS] New to_timestamp implementation is pretty strict

2008-12-01 Thread Andrew Dunstan
Dave Page wrote: On Mon, Dec 1, 2008 at 3:02 PM, David E. Wheeler [EMAIL PROTECTED] wrote: it depends on how you look at it, I suppose. If you look at :xy as x being the 10s position and y being the 1s position, it makes no sense. Suffice it to say, I don't look at it that way :-).

Re: [HACKERS] New to_timestamp implementation is pretty strict

2008-12-01 Thread Greg Stark
How would you parse an input format of just 'SS' ? is there something ambiguous about '3' ? I don't see anything bad about using %d to output an integer number of seconds. -- greg -- Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org) To make changes to your subscription:

Re: [HACKERS] New to_timestamp implementation is pretty strict

2008-12-01 Thread Robert Haas
On Mon, Dec 1, 2008 at 10:33 AM, Greg Stark [EMAIL PROTECTED] wrote: How would you parse an input format of just 'SS' ? is there something ambiguous about '3' ? I don't see anything bad about using %d to output an integer number of seconds. +1. It seems to me that it's pretty silly to say

Re: [HACKERS] New to_timestamp implementation is pretty strict

2008-12-01 Thread Andrew Dunstan
Greg Stark wrote: How would you parse an input format of just 'SS' ? is there something ambiguous about '3' ? I don't see anything bad about using %d to output an integer number of seconds. The docs say that SS corresponds to second (00-59), so clearly it should expect a two digit zero

Re: [HACKERS] New to_timestamp implementation is pretty strict

2008-12-01 Thread Robert Haas
Another point here is that we have always accepted single digits in dates: portal= select '2008-11-1'::date; date 2008-11-01 (1 row) portal= select '2008-1-11'::date; date 2008-01-11 (1 row) If we're going to handle dates and timestamps inconsistently, there

Re: [HACKERS] New to_timestamp implementation is pretty strict

2008-12-01 Thread Tom Lane
Robert Haas [EMAIL PROTECTED] writes: Another point here is that we have always accepted single digits in dates: Yeah, but that's the general datetime input code, which has rather different goals than to_timestamp(). After thinking about it I'm inclined to feel that SS and friends should insist

Re: [HACKERS] New to_timestamp implementation is pretty strict

2008-12-01 Thread Heikki Linnakangas
Robert Haas wrote: On Mon, Dec 1, 2008 at 10:33 AM, Greg Stark [EMAIL PROTECTED] wrote: How would you parse an input format of just 'SS' ? is there something ambiguous about '3' ? I don't see anything bad about using %d to output an integer number of seconds. +1. It seems to me that it's

Re: [HACKERS] New to_timestamp implementation is pretty strict

2008-12-01 Thread Robert Haas
For better or worse, we also allow these more questionable inputs: Wow. Those are all pretty atrocious. Even so, it's not clear to me that there's a lot of merit to changing the behavior. If to_timestamp() isn't rigorous enough, you can always stick some additional error checking in front of

Re: [HACKERS] New to_timestamp implementation is pretty strict

2008-12-01 Thread Brendan Jurd
On Mon, Dec 1, 2008 at 11:08 PM, Heikki Linnakangas [EMAIL PROTECTED] wrote: postgres=# SELECT to_timestamp('29-12-2005 01:02:3', 'DD-MM- HH24:MI:SS'); -- doesn't work ... I think the end of string should be treated like a field separator, colon in this example, and we should accept both