1
0
mirror of https://github.com/postgres/postgres.git synced 2025-07-30 11:03:19 +03:00

Add ENCODING option to COPY TO/FROM and file_fdw.

File encodings can be specified separately from client encoding.
If not specified, client encoding is used for backward compatibility.

Cases when the encoding doesn't match client encoding are slower
than matched cases because we don't have conversion procs for other
encodings. Performance improvement would be be a future work.

Original patch by Hitoshi Harada, and modified by me.
This commit is contained in:
Itagaki Takahiro
2011-02-21 14:08:04 +09:00
parent 48d25bac9f
commit 3cba8240a1
9 changed files with 119 additions and 37 deletions

View File

@ -97,6 +97,17 @@
</listitem>
</varlistentry>
<varlistentry>
<term><literal>encoding</literal></term>
<listitem>
<para>
Specifies the file's encoding.
the same as <command>COPY</>'s <literal>ENCODING</literal> option.
</para>
</listitem>
</varlistentry>
</variablelist>
<para>

View File

@ -40,7 +40,8 @@ COPY { <replaceable class="parameter">table_name</replaceable> [ ( <replaceable
QUOTE '<replaceable class="parameter">quote_character</replaceable>'
ESCAPE '<replaceable class="parameter">escape_character</replaceable>'
FORCE_QUOTE { ( <replaceable class="parameter">column</replaceable> [, ...] ) | * }
FORCE_NOT_NULL ( <replaceable class="parameter">column</replaceable> [, ...] )
FORCE_NOT_NULL ( <replaceable class="parameter">column</replaceable> [, ...] ) |
ENCODING '<replaceable class="parameter">encoding_name</replaceable>'
</synopsis>
</refsynopsisdiv>
@ -282,6 +283,18 @@ COPY { <replaceable class="parameter">table_name</replaceable> [ ( <replaceable
</listitem>
</varlistentry>
<varlistentry>
<term><literal>ENCODING</></term>
<listitem>
<para>
Specifies that the file is encoded in the <replaceable
class="parameter">encoding_name</replaceable>. If this option is
omitted, the current client encoding is used. See the Notes below
for more details.
</para>
</listitem>
</varlistentry>
</variablelist>
</refsect1>
@ -377,8 +390,9 @@ COPY <replaceable class="parameter">count</replaceable>
</para>
<para>
Input data is interpreted according to the current client encoding,
and output data is encoded in the current client encoding, even
Input data is interpreted according to <literal>ENCODING</literal>
option or the current client encoding, and output data is encoded
in <literal>ENCODING</literal> or the current client encoding, even
if the data does not pass through the client but is read from or
written to a file directly by the server.
</para>