From: Liudmila Mantrova <l.mantrova@postgrespro.ru>
To: Alexander Korotkov <a.korotkov@postgrespro.ru>
To: amul sul <sulamul@gmail.com>
Cc: prabhat.sahu@enterprisedb.com, "David G. Johnston" <david.g.johnston@gmail.com>
Cc: Artur Zakirov <a.zakirov@postgrespro.ru>
Cc: Tom Lane <tgl@sss.pgh.pa.us>
Cc: Dmitry Dolgov <9erthalion6@gmail.com>
Cc: Robert Haas <robertmhaas@gmail.com>
Cc: Thomas Munro <thomas.munro@enterprisedb.com>
Cc: Pavel Stehule <pavel.stehule@gmail.com>
Cc: Alex Ignatov <a.ignatov@postgrespro.ru>
Cc: Bruce Momjian <bruce@momjian.us>
Cc: amul sul <sul_amul@yahoo.co.in>
Cc: pgsql-hackers <pgsql-hackers@postgresql.org>
Subject: Re: [HACKERS] Bug in to_timestamp().
Date: Wed, 26 Sep 2018 17:40:04 +0300
Message-ID: <ae0f68ba-3b56-ad40-925b-726636d42443@postgrespro.ru> (raw)
In-Reply-To: <CAPpHfdu-QM0CmP=XZMQh8uhniLUknMiw-oWjHsaAn=nEKsfCYA@mail.gmail.com>
References: <CAPpHfdvznd2bfykLSYYE0LL+1WiiDp8FtpVWxfZ_Ty_Rq23Y-Q@mail.gmail.com>
<CAAJ_b95ZO=2rLoN3qGKekDWfDH6gAyJonQjE7EbNkBjcum=WTA@mail.gmail.com>
<CAPpHfdsNJBXNGf2cOk_G7wVMkUsWhu85ibf42U2savS8OCy3HA@mail.gmail.com>
<CAPpHfdsUiWA8sSiyt20Jj_TubsN7JT3X+n2fZy3tU25iYq_OZw@mail.gmail.com>
<CAPpHfdtBJsfmb_Cwghf+JH0xLrU9TF9bYk+NPXJNuAFVBDjjxg@mail.gmail.com>
<CANEvxPonsPsNWZzBK5aOO_=h1yQHODOADsVBcO6ZJWq49+dB9Q@mail.gmail.com>
<CAPpHfdv9=8ZoriVcx0=Tu2v5nQPnuv=7ZAjn2ybSEpMviXuuQA@mail.gmail.com>
<CAPpHfdskk-EYKb8iC7zgJAQFoqE+Y1uTNbBb41bjVXLVgtOADg@mail.gmail.com>
<CAAJ_b95nAuZ9tdJd4ruuZd5D2qW4-mHut=w0Wv-VXJqZG0Dx8g@mail.gmail.com>
<CAAJ_b97cyyM6n8smP7Zw8HOw49+=bH0HZH1q_p-NLyZtMH+WfA@mail.gmail.com>
<CAPpHfdvRjrk6fam5F49=pUj2UT2Cy8geh43Nu3zJKnoHZeuOMg@mail.gmail.com>
<CAAJ_b944rJu6Y3ryz6z84Ecnyc=c8eCja8XaqbyWExdsQ9qYmQ@mail.gmail.com>
<CAPpHfdv4x3J0NOO2Qb7bv2JoBYRuKK11+v6zew_7yoerX0QRXA@mail.gmail.com>
<CAPpHfdu-QM0CmP=XZMQh8uhniLUknMiw-oWjHsaAn=nEKsfCYA@mail.gmail.com>
On 09/22/2018 10:00 PM, Alexander Korotkov wrote:
> On Thu, Sep 20, 2018 at 3:52 PM Alexander Korotkov
> <a.korotkov@postgrespro.ru> wrote:
>> On Thu, Sep 20, 2018 at 6:09 AM amul sul <sulamul@gmail.com> wrote:
>>> Agreed, thanks for working on this.
>> Pushed, thanks.
> Please, find attached patch improving documentation about
> letters/digits in to_date()/to_timestamp() template string. I think
> it needs review from native English speaker.
>
> ------
> Alexander Korotkov
> Postgres Professional: http://www.postgrespro.com
> The Russian Postgres Company
>
Hi Alexander,
I'm not a native speaker, but let me try to help. A new doc version is
attached.
--
Liudmila Mantrova
Technical writer at Postgres Professional: http://www.postgrespro.com
The Russian Postgres Company
Attachments:to_timestamp_letters_digits-0001.patch (text/x-patch, 3.0K) downloaddiff --git a/doc/src/sgml/func.sgml b/doc/src/sgml/func.sgmlindex 9a7f683..1532bcc 100644--- a/doc/src/sgml/func.sgml+++ b/doc/src/sgml/func.sgml@@ -6286,13 +6286,46 @@ SELECT regexp_match('abc01234xyz', '(?:(.*?)(\d+)(.*)){1,1}');
exceeds the number of separators in the template.
</para>
<para>
- If <literal>FX</literal> is specified, separator in template string- matches to exactly one character in input string. Notice we don't insist- input string character to be the same as template string separator.+ If <literal>FX</literal> is specified, a separator in the template+ string matches exactly one character in the input string. The+ input string character does not need to be the same as the template+ string separator.
For example, <literal>to_timestamp('2000/JUN', 'FXYYYY MON')</literal>
works, but <literal>to_timestamp('2000/JUN', 'FXYYYY MON')</literal>
- returns an error because a space second template string space consumed- letter <literal>J</literal> from the input string.+ returns an error because the second space in the template string+ consumes letter <literal>J</literal> of the input string.+ </para>+ </listitem>++ <listitem>+ <para>+ Template strings of <function>to_timestamp</function> and+ <function>to_date</function> functions can also contain arbitrary+ letters/digits between patterns. Such letters/digits can match+ any characters in the input string. For example,+ <literal>to_timestamp('2000yJUN', 'YYYYxMON')</literal> works.+ </para>+ <para>+ Letters/digits consume an input string character only if the number+ of extra characters at the beginning of the input string or between+ the identified date/time values is less than or equal to the number+ of the corresponding characters in the template string. This ensures+ that the template string does not consume any characters of date/time+ values when used without the <literal>FX</literal> option, even if+ a letter/digit separator in the input string appears after a space.+ For example, <literal>to_timestamp('2000y JUN', 'YYYYxMON')</literal>+ works, but <literal>to_timestamp('2000 yJUN', 'YYYYxMON')</literal>+ returns an error.+ </para>+ <para>+ Note that if the template string contains an arbitrary letter,+ the pattern that precedes this letter becomes greedy and tries+ to match as many characters as possible. For example,+ <literal>to_timestamp('2000906901', 'YYYYxMMxDD')</literal>+ fails because the <literal>YYYY</literal> pattern matches+ the whole input string instead of the first four characters.+ Patterns separated by digits are non-greedy, so+ <literal>to_timestamp('2000906901', 'YYYY0MM0DD')</literal> works fine.
</para>
</listitem>
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients using the --to and --cc options:
reply via email
To: pgsql-hackers@postgresql.org
Cc: l.mantrova@postgrespro.ru, a.korotkov@postgrespro.ru, sulamul@gmail.com, david.g.johnston@gmail.com, a.zakirov@postgrespro.ru, tgl@sss.pgh.pa.us, 9erthalion6@gmail.com, robertmhaas@gmail.com, thomas.munro@enterprisedb.com, pavel.stehule@gmail.com, a.ignatov@postgrespro.ru, bruce@momjian.us, sul_amul@yahoo.co.in
Subject: Re: [HACKERS] Bug in to_timestamp().
In-Reply-To: <ae0f68ba-3b56-ad40-925b-726636d42443@postgrespro.ru>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
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