From: | Alexander Korotkov <a(dot)korotkov(at)postgrespro(dot)ru> |
---|---|
To: | prabhat(dot)sahu(at)enterprisedb(dot)com |
Cc: | amul sul <sulamul(at)gmail(dot)com>, "David G(dot) Johnston" <david(dot)g(dot)johnston(at)gmail(dot)com>, Artur Zakirov <a(dot)zakirov(at)postgrespro(dot)ru>, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, Dmitry Dolgov <9erthalion6(at)gmail(dot)com>, Robert Haas <robertmhaas(at)gmail(dot)com>, Thomas Munro <thomas(dot)munro(at)enterprisedb(dot)com>, Pavel Stehule <pavel(dot)stehule(at)gmail(dot)com>, Alex Ignatov <a(dot)ignatov(at)postgrespro(dot)ru>, Bruce Momjian <bruce(at)momjian(dot)us>, amul sul <sul_amul(at)yahoo(dot)co(dot)in>, pgsql-hackers <pgsql-hackers(at)postgresql(dot)org> |
Subject: | Re: [HACKERS] Bug in to_timestamp(). |
Date: | 2018-09-19 09:27:35 |
Message-ID: | CAPpHfdskk-EYKb8iC7zgJAQFoqE+Y1uTNbBb41bjVXLVgtOADg@mail.gmail.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-hackers |
On Tue, Sep 18, 2018 at 4:42 PM Alexander Korotkov
<a(dot)korotkov(at)postgrespro(dot)ru> wrote:
> But, I found related issue in cf9846724. Before it was:
>
> # select to_timestamp('2018 01 01', 'YYYY9MM9DD');
> to_timestamp
> ------------------------
> 2018-01-01 00:00:00+03
> (1 row)
>
> But after it becomes so.
>
> # select to_timestamp('2018 01 01', 'YYYY9MM9DD');
> ERROR: invalid value "1 " for "MM"
> DETAIL: Field requires 2 characters, but only 1 could be parsed.
> HINT: If your source string is not fixed-width, try using the "FM" modifier.
>
> That happens because we've already skipped space "for free", and then
> NODE_TYPE_CHAR eats digit. I've checked that Oracle doesn't allow
> random charaters/digits to appear in format string.
>
> select to_timestamp('2018 01 01', 'YYYY9MM9DD') from dual
> ORA-01821: date format not recognized
>
> So, Oracle compatibility isn't argument here. Therefore I'm going to
> propose following fix for that: let NODE_TYPE_CHAR eat characters only
> if we didn't skip input string characters more than it was in format
> string. I'm sorry for vague explanation. I'll come up with patch
> later, and it should be clear then.
Please find attached patch for fixing this issue. It makes handling
of format string text characters be similar to pre cf984672 behavior.
See the examples in regression tests and explanation in the commit
message. I'm going to commit this if no objections.
------
Alexander Korotkov
Postgres Professional: http://www.postgrespro.com
The Russian Postgres Company
Attachment | Content-Type | Size |
---|---|---|
to_timestamp_fix.patch | application/octet-stream | 3.0 KB |
From | Date | Subject | |
---|---|---|---|
Next Message | amul sul | 2018-09-19 10:21:37 | Re: [HACKERS] Bug in to_timestamp(). |
Previous Message | Pavel Stehule | 2018-09-19 08:30:31 | Re: [HACKERS] proposal: schema variables |