I don't think the changes made in PG 12 are documented accurately.  It
currently says:

        to_timestamp and to_date matches any single separator in the input
        string or is skipped

However, I think it is more accurate to say _multiple_ whitespace can
also be matched by a single separator:

        SELECT to_timestamp('%1976','_YYYY');
              to_timestamp
        ------------------------
         1976-01-01 00:00:00-05
        
        SELECT to_timestamp('%%1976','_YYYY');
        ERROR:  invalid value "%197" for "YYYY"
        DETAIL:  Value must be an integer.
        
        -- two spaces
-->     SELECT to_timestamp('  1976','_YYYY');
              to_timestamp
        ------------------------
         1976-01-01 00:00:00-05

-->     SELECT to_timestamp(E'\t\t\t1976','_YYYY');
              to_timestamp
        ------------------------
         1976-01-01 00:00:00-05

Proposed patch attached.

-- 
  Bruce Momjian  <br...@momjian.us>        http://momjian.us
  EnterpriseDB                             http://enterprisedb.com

+ As you are, so once was I.  As I am, so you will be. +
+                      Ancient Roman grave inscription +
diff --git a/doc/src/sgml/func.sgml b/doc/src/sgml/func.sgml
new file mode 100644
index d751766..b27f4d4
*** a/doc/src/sgml/func.sgml
--- b/doc/src/sgml/func.sgml
*************** SELECT regexp_match('abc01234xyz', '(?:(
*** 6390,6396 ****
        <para>
         A separator (a space or non-letter/non-digit character) in the template string of
         <function>to_timestamp</function> and <function>to_date</function>
!        matches any single separator in the input string or is skipped,
         unless the <literal>FX</literal> option is used.
         For example, <literal>to_timestamp('2000JUN', 'YYYY///MON')</literal> and
         <literal>to_timestamp('2000/JUN', 'YYYY MON')</literal> work, but
--- 6390,6396 ----
        <para>
         A separator (a space or non-letter/non-digit character) in the template string of
         <function>to_timestamp</function> and <function>to_date</function>
!        matches multiple whitespace characters in the input string, a single separator, or nothing,
         unless the <literal>FX</literal> option is used.
         For example, <literal>to_timestamp('2000JUN', 'YYYY///MON')</literal> and
         <literal>to_timestamp('2000/JUN', 'YYYY MON')</literal> work, but

Reply via email to