Re: [HACKERS] Bug in to_timestamp().

From: Liudmila Mantrova <l(dot)mantrova(at)postgrespro(dot)ru>
To: Alexander Korotkov <a(dot)korotkov(at)postgrespro(dot)ru>, Artur Zakirov <a(dot)zakirov(at)postgrespro(dot)ru>
Cc: "David G(dot) Johnston" <david(dot)g(dot)johnston(at)gmail(dot)com>, 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>, amul sul <sulamul(at)gmail(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-08-16 13:57:41
Message-ID: 6b86fc5d-46d6-3684-5bd5-3ee1ee5a53e8@postgrespro.ru
Views: Raw Message | Whole Thread | Download mbox
Thread:
Lists: pgsql-hackers


On 08/14/2018 06:38 PM, Alexander Korotkov wrote:
> On Thu, Aug 2, 2018 at 9:06 PM Alexander Korotkov
> <a(dot)korotkov(at)postgrespro(dot)ru> wrote:
>> On Thu, Aug 2, 2018 at 6:17 PM Alexander Korotkov
>> <a(dot)korotkov(at)postgrespro(dot)ru> wrote:
>>> After some experiments I found that when you mix spaces and separators
>>> between two fields, then Oracle takes into account only length of last
>>> group of spaces/separators.
>>>
>>> # SELECT to_timestamp('2018- -01 02', 'YYYY---- --- --MM-DD') FROM
>>> dual2018-01-01 00:00:00 -10:00
>>> (length of last spaces/separators group is 2)
>>>
>>> # SELECT to_timestamp('2018- -01 02', 'YYYY---- --- --MM-DD') FROM dual
>>> 2018-01-01 00:00:00 -10:00
>>> (length of last spaces/separators group is 3)
>>>
>>> # SELECT to_timestamp('2018- -01 02', 'YYYY---- -- ---MM-DD') FROM dual
>>> 02.01.2018 00:00:00
>>> (length of last spaces/separators group is 2)
>> Ooops... I'm sorry, but I've posted wrong results here. Correct
>> version is here.
>>
>> # SELECT to_timestamp('2018- -01 02', 'YYYY---- --- --MM-DD') FROM dual
>> ORA-01843: not a valid month
>> (length of last spaces/separators group is 2)
>>
>> # SELECT to_timestamp('2018- -01 02', 'YYYY---- -- ---MM-DD') FROM dual
>> 02.01.2018 00:00:00
>> (length of last spaces/separators group is 3)
>>
>> So length of last group of spaces/separators in the pattern should be
>> greater or equal to length of spaces/separators in the input string.
>> Other previous groups are ignored in Oracle. And that seems
>> ridiculous for me.
> BTW, I've also revised documentation and regression tests. Patch is attached.
>
> ------
> Alexander Korotkov
> Postgres Professional: http://www.postgrespro.com
> The Russian Postgres Company
Hi,
Please consider some further documentation improvements in the attached
patch.

--
Liudmila Mantrova
Technical writer at Postgres Professional: http://www.postgrespro.com
The Russian Postgres Company

Attachment Content-Type Size
0001-to-timestamp-format-checking-v16.patch text/x-patch 17.2 KB

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Andres Freund 2018-08-16 13:59:28 Re: remove ancient pre-dlopen dynloader code
Previous Message Dian Fay 2018-08-16 13:36:29 Re: docs: note ownership requirement for refreshing materialized views