Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
doc: \123 and \x12 escapes in COPY are in database encoding.
authorHeikki Linnakangas <heikki.linnakangas@iki.fi>
Tue, 17 Aug 2021 07:00:06 +0000 (10:00 +0300)
committerHeikki Linnakangas <heikki.linnakangas@iki.fi>
Tue, 17 Aug 2021 08:21:27 +0000 (11:21 +0300)
The backslash sequences, including \123 and \x12 escapes, are interpreted
after encoding conversion. The docs failed to mention that.

Backpatch to all supported versions.

Reported-by: Andreas Grob
Discussion: https://www.postgresql.org/message-id/17142-9181542ca1df75ab%40postgresql.org

doc/src/sgml/ref/copy.sgml

index 4807dbc371632f3fd2d6705b7a4088c433848cd9..90806a241ea058ada68617759a4e4d37649da7c9 100644 (file)
@@ -599,12 +599,12 @@ COPY <replaceable class="parameter">count</replaceable>
       <row>
        <entry><literal>\</><replaceable>digits</></entry>
        <entry>Backslash followed by one to three octal digits specifies
-       the character with that numeric code</entry>
+       the byte with that numeric code</entry>
       </row>
       <row>
        <entry><literal>\x</><replaceable>digits</></entry>
        <entry>Backslash <literal>x</> followed by one or two hex digits specifies
-       the character with that numeric code</entry>
+       the byte with that numeric code</entry>
       </row>
      </tbody>
     </tgroup>
@@ -636,6 +636,12 @@ COPY <replaceable class="parameter">count</replaceable>
     or vice versa).
    </para>
 
+   <para>
+     All backslash sequences are interpreted after encoding conversion.
+     The bytes specified with the octal and hex-digit backslash sequences must
+     form valid characters in the database encoding.
+   </para>
+
    <para>
     <command>COPY TO</command> will terminate each row with a Unix-style
     newline (<quote><literal>\n</></>).  Servers running on Microsoft Windows instead