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

Remove dead encoding-conversion functions.

The code for conversions SQL_ASCII <-> MULE_INTERNAL and
SQL_ASCII <-> UTF8 was unreachable, because we long ago changed
the wrapper functions pg_do_encoding_conversion() et al so that
they have hard-wired behaviors for conversions involving SQL_ASCII.
(At least some of those fast paths date back to 2002, though it
looks like we may not have been totally consistent about this until
later.)  Given the lack of complaints, nobody is dissatisfied with
this state of affairs.  Hence, let's just remove the unreachable code.

Also, change CREATE CONVERSION so that it rejects attempts to
define such conversions.  Since we consider that SQL_ASCII represents
lack of knowledge about the encoding in use, such a conversion would
be semantically dubious even if it were reachable.

Adjust a couple of regression test cases that had randomly decided
to rely on these conversion functions rather than any other ones.

Discussion: https://postgr.es/m/41163.1559156593@sss.pgh.pa.us
This commit is contained in:
Tom Lane
2019-07-05 14:17:27 -04:00
parent ef777cb093
commit 0ab1a2e39b
18 changed files with 44 additions and 269 deletions

View File

@ -1896,7 +1896,11 @@ RESET client_encoding;
<para>
If the client character set is defined as <literal>SQL_ASCII</literal>,
encoding conversion is disabled, regardless of the server's character
set. Just as for the server, use of <literal>SQL_ASCII</literal> is unwise
set. (However, if the server's character set is
not <literal>SQL_ASCII</literal>, the server will still check that
incoming data is valid for that encoding; so the net effect is as
though the client character set were the same as the server's.)
Just as for the server, use of <literal>SQL_ASCII</literal> is unwise
unless you are working with all-ASCII data.
</para>
</sect2>

View File

@ -2496,18 +2496,6 @@
</thead>
<tbody>
<row>
<entry><literal>ascii_to_mic</literal></entry>
<entry><literal>SQL_ASCII</literal></entry>
<entry><literal>MULE_INTERNAL</literal></entry>
</row>
<row>
<entry><literal>ascii_to_utf8</literal></entry>
<entry><literal>SQL_ASCII</literal></entry>
<entry><literal>UTF8</literal></entry>
</row>
<row>
<entry><literal>big5_to_euc_tw</literal></entry>
<entry><literal>BIG5</literal></entry>
@ -2778,12 +2766,6 @@
<entry><literal>UTF8</literal></entry>
</row>
<row>
<entry><literal>mic_to_ascii</literal></entry>
<entry><literal>MULE_INTERNAL</literal></entry>
<entry><literal>SQL_ASCII</literal></entry>
</row>
<row>
<entry><literal>mic_to_big5</literal></entry>
<entry><literal>MULE_INTERNAL</literal></entry>
@ -2904,12 +2886,6 @@
<entry><literal>UTF8</literal></entry>
</row>
<row>
<entry><literal>utf8_to_ascii</literal></entry>
<entry><literal>UTF8</literal></entry>
<entry><literal>SQL_ASCII</literal></entry>
</row>
<row>
<entry><literal>utf8_to_big5</literal></entry>
<entry><literal>UTF8</literal></entry>

View File

@ -28,12 +28,15 @@ CREATE [ DEFAULT ] CONVERSION <replaceable>name</replaceable>
<para>
<command>CREATE CONVERSION</command> defines a new conversion between
character set encodings. Also, conversions that
are marked <literal>DEFAULT</literal> can be used for automatic encoding
conversion between
client and server. For this purpose, two conversions, from encoding A to
B <emphasis>and</emphasis> from encoding B to A, must be defined.
</para>
two character set encodings.
</para>
<para>
Conversions that are marked <literal>DEFAULT</literal> can be used for
automatic encoding conversion between client and server. To support that
usage, two conversions, from encoding A to B <emphasis>and</emphasis>
from encoding B to A, must be defined.
</para>
<para>
To be able to create a conversion, you must have <literal>EXECUTE</literal> privilege
@ -122,6 +125,13 @@ conv_proc(
<refsect1 id="sql-createconversion-notes">
<title>Notes</title>
<para>
Neither the source nor the destination encoding can
be <literal>SQL_ASCII</literal>, as the server's behavior for cases
involving the <literal>SQL_ASCII</literal> <quote>encoding</quote> is
hard-wired.
</para>
<para>
Use <command>DROP CONVERSION</command> to remove user-defined conversions.
</para>