Обсуждение: Dead encoding conversion functions

Поиск
Список
Период
Сортировка

Dead encoding conversion functions

От
Tom Lane
Дата:
Pursuant to today's discussion at PGCon about code coverage, I went
nosing into some of the particularly under-covered subdirectories
in our tree, and immediately tripped over an interesting factoid:
the ASCII<->MIC and ASCII<->UTF8 encoding conversion functions are
untested ... not because the regression tests don't try, but because
those conversions are unreachable.  pg_do_encoding_conversion() and
its sister functions have hard-wired fast paths for any conversion
in which the source or target encoding is SQL_ASCII, so that an
encoding conversion function declared for such a case will never
be used.

(The coverage results do show ascii_to_utf8 as being covered, but
that's just because alter_table.sql randomly chose to test
ALTER CONVERSION using a user-defined conversion from SQL_ASCII
to UTF8, rather than any other case.  CreateConversionCommand()
will invoke the specified function on an empty string just to see
if it works, so that's where that "coverage" comes from.)

This situation seems kinda silly.  My inclination is to delete
these functions as useless, but I suppose another approach is
to suppress the fast paths if there's a declared conversion function.
(Doing so would likely require added catalog lookups in places we
might not want them...)

If we do delete them as useless, it might also be advisable to change
CreateConversionCommand() to refuse creation of conversions to/from
SQL_ASCII, to prevent future confusion.

Thoughts?

            regards, tom lane



Re: Dead encoding conversion functions

От
Daniel Gustafsson
Дата:
> On 29 May 2019, at 15:03, Tom Lane <tgl@sss.pgh.pa.us> wrote:
>
> Pursuant to today's discussion at PGCon about code coverage, I went
> nosing into some of the particularly under-covered subdirectories
> in our tree,

On a similar, but much less important/interesting note.  I fat-fingered when
compiling isolationtester on the plane over here and happened to compile
src/test/examples, and in there testlo.c and testlo64.c has two dead functions
for which the callsites have been commented out since the Postgres95 import
(and now cause a warning).  Is there any (historic?) reason to keep that code?
It also seems kind of broken as it doesn’t really handle the open() call
failure very well.

cheers ./daniel


Re: Dead encoding conversion functions

От
Noah Misch
Дата:
On Wed, May 29, 2019 at 03:03:13PM -0400, Tom Lane wrote:
> Pursuant to today's discussion at PGCon about code coverage, I went
> nosing into some of the particularly under-covered subdirectories
> in our tree, and immediately tripped over an interesting factoid:
> the ASCII<->MIC and ASCII<->UTF8 encoding conversion functions are
> untested ... not because the regression tests don't try, but because
> those conversions are unreachable.  pg_do_encoding_conversion() and
> its sister functions have hard-wired fast paths for any conversion
> in which the source or target encoding is SQL_ASCII, so that an
> encoding conversion function declared for such a case will never
> be used.

> This situation seems kinda silly.  My inclination is to delete
> these functions as useless, but I suppose another approach is
> to suppress the fast paths if there's a declared conversion function.
> (Doing so would likely require added catalog lookups in places we
> might not want them...)

Removing the fast paths to make ascii_to_utf8() reachable would cause ERROR
when server_encoding=SQL_ASCII, client_encoding=UTF8, and a query would
otherwise send the client any character outside 7-bit ASCII.  That's fairly
defensible, but doing it for only UTF8 and MULE_INTERNAL is not.  So if we
like the ascii_to_utf8() behavior, I think the action would be to replace the
fast path with an encoding-independent verification that all bytes are 7-bit
ASCII.  (The check would not apply when both server_encoding and
client_encoding are SQL_ASCII, of course.)  Alternately, one might prefer to
replace the fast path with an encoding verification; in the SQL_ASCII-to-UTF8
case, we'd allow byte sequences that are valid UTF8, even though the validity
may be a coincidence and mojibake may ensue.  SQL_ASCII is for being casual
about encoding, so it's not clear to me whether or not either prospective
behavior change would be an improvement.  However, I do find it clear to
delete ascii_to_utf8() and ascii_to_mic().

> If we do delete them as useless, it might also be advisable to change
> CreateConversionCommand() to refuse creation of conversions to/from
> SQL_ASCII, to prevent future confusion.

Sounds good.



Re: Dead encoding conversion functions

От
Peter Eisentraut
Дата:
On 2019-05-29 21:03, Tom Lane wrote:
> If we do delete them as useless, it might also be advisable to change
> CreateConversionCommand() to refuse creation of conversions to/from
> SQL_ASCII, to prevent future confusion.

It seems nonsensical by definition to allow that.

-- 
Peter Eisentraut              http://www.2ndQuadrant.com/
PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services



Re: Dead encoding conversion functions

От
Tom Lane
Дата:
Peter Eisentraut <peter.eisentraut@2ndquadrant.com> writes:
> On 2019-05-29 21:03, Tom Lane wrote:
>> If we do delete them as useless, it might also be advisable to change
>> CreateConversionCommand() to refuse creation of conversions to/from
>> SQL_ASCII, to prevent future confusion.

> It seems nonsensical by definition to allow that.

Here's a completed patch for that.  Obviously this is a bit late
for v12, but if there aren't objections I'll push this soon after
v13 opens.

            regards, tom lane

diff --git a/doc/src/sgml/charset.sgml b/doc/src/sgml/charset.sgml
index a2a46c6..29fe33a 100644
--- a/doc/src/sgml/charset.sgml
+++ b/doc/src/sgml/charset.sgml
@@ -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>
diff --git a/doc/src/sgml/func.sgml b/doc/src/sgml/func.sgml
index 3a8581d..7b6e530 100644
--- a/doc/src/sgml/func.sgml
+++ b/doc/src/sgml/func.sgml
@@ -2497,18 +2497,6 @@

      <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>
        <entry><literal>EUC_TW</literal></entry>
@@ -2779,12 +2767,6 @@
       </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>
        <entry><literal>BIG5</literal></entry>
@@ -2905,12 +2887,6 @@
       </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>
        <entry><literal>BIG5</literal></entry>
diff --git a/doc/src/sgml/ref/create_conversion.sgml b/doc/src/sgml/ref/create_conversion.sgml
index 4ddbcfa..67b4bd2 100644
--- a/doc/src/sgml/ref/create_conversion.sgml
+++ b/doc/src/sgml/ref/create_conversion.sgml
@@ -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
@@ -123,6 +126,13 @@ conv_proc(
   <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>

diff --git a/src/backend/commands/conversioncmds.c b/src/backend/commands/conversioncmds.c
index 5afe867..cb856e8 100644
--- a/src/backend/commands/conversioncmds.c
+++ b/src/backend/commands/conversioncmds.c
@@ -73,6 +73,18 @@ CreateConversionCommand(CreateConversionStmt *stmt)
                         to_encoding_name)));

     /*
+     * We consider conversions to or from SQL_ASCII to be meaningless.  (If
+     * you wish to change this, note that pg_do_encoding_conversion() and its
+     * sister functions have hard-wired fast paths for any conversion in which
+     * the source or target encoding is SQL_ASCII, so that an encoding
+     * conversion function declared for such a case will never be used.)
+     */
+    if (from_encoding == PG_SQL_ASCII || to_encoding == PG_SQL_ASCII)
+        ereport(ERROR,
+                (errcode(ERRCODE_INVALID_OBJECT_DEFINITION),
+                 errmsg("encoding conversion to or from \"SQL_ASCII\" is not supported")));
+
+    /*
      * Check the existence of the conversion function. Function name could be
      * a qualified name.
      */
diff --git a/src/backend/utils/mb/conv.c b/src/backend/utils/mb/conv.c
index f2b51ac..3ecc92b 100644
--- a/src/backend/utils/mb/conv.c
+++ b/src/backend/utils/mb/conv.c
@@ -133,51 +133,6 @@ mic2latin(const unsigned char *mic, unsigned char *p, int len,


 /*
- * ASCII ---> MIC
- *
- * While ordinarily SQL_ASCII encoding is forgiving of high-bit-set
- * characters, here we must take a hard line because we don't know
- * the appropriate MIC equivalent.
- */
-void
-pg_ascii2mic(const unsigned char *l, unsigned char *p, int len)
-{
-    int            c1;
-
-    while (len > 0)
-    {
-        c1 = *l;
-        if (c1 == 0 || IS_HIGHBIT_SET(c1))
-            report_invalid_encoding(PG_SQL_ASCII, (const char *) l, len);
-        *p++ = c1;
-        l++;
-        len--;
-    }
-    *p = '\0';
-}
-
-/*
- * MIC ---> ASCII
- */
-void
-pg_mic2ascii(const unsigned char *mic, unsigned char *p, int len)
-{
-    int            c1;
-
-    while (len > 0)
-    {
-        c1 = *mic;
-        if (c1 == 0 || IS_HIGHBIT_SET(c1))
-            report_untranslatable_char(PG_MULE_INTERNAL, PG_SQL_ASCII,
-                                       (const char *) mic, len);
-        *p++ = c1;
-        mic++;
-        len--;
-    }
-    *p = '\0';
-}
-
-/*
  * latin2mic_with_table: a generic single byte charset encoding
  * conversion from a local charset to the mule internal code.
  *
diff --git a/src/backend/utils/mb/conversion_procs/Makefile b/src/backend/utils/mb/conversion_procs/Makefile
index 258ffec..413aeb9 100644
--- a/src/backend/utils/mb/conversion_procs/Makefile
+++ b/src/backend/utils/mb/conversion_procs/Makefile
@@ -14,9 +14,9 @@ top_builddir = ../../../../..
 include $(top_builddir)/src/Makefile.global

 SUBDIRS = \
-    ascii_and_mic cyrillic_and_mic euc_cn_and_mic euc_jp_and_sjis \
+    cyrillic_and_mic euc_cn_and_mic euc_jp_and_sjis \
     euc_kr_and_mic euc_tw_and_big5 latin2_and_win1250 latin_and_mic \
-    utf8_and_ascii utf8_and_big5 utf8_and_cyrillic utf8_and_euc_cn \
+    utf8_and_big5 utf8_and_cyrillic utf8_and_euc_cn \
     utf8_and_euc_jp utf8_and_euc_kr utf8_and_euc_tw utf8_and_gb18030 \
     utf8_and_gbk utf8_and_iso8859 utf8_and_iso8859_1 utf8_and_johab \
     utf8_and_sjis utf8_and_win utf8_and_uhc \
diff --git a/src/backend/utils/mb/conversion_procs/ascii_and_mic/Makefile
b/src/backend/utils/mb/conversion_procs/ascii_and_mic/Makefile
deleted file mode 100644
index fa65eba..0000000
--- a/src/backend/utils/mb/conversion_procs/ascii_and_mic/Makefile
+++ /dev/null
@@ -1,13 +0,0 @@
-#-------------------------------------------------------------------------
-#
-# src/backend/utils/mb/conversion_procs/ascii_and_mic/Makefile
-#
-#-------------------------------------------------------------------------
-subdir = src/backend/utils/mb/conversion_procs/ascii_and_mic
-top_builddir = ../../../../../..
-include $(top_builddir)/src/Makefile.global
-
-NAME        = ascii_and_mic
-PGFILEDESC    = "ascii <-> mic text conversions"
-
-include $(srcdir)/../proc.mk
diff --git a/src/backend/utils/mb/conversion_procs/ascii_and_mic/ascii_and_mic.c
b/src/backend/utils/mb/conversion_procs/ascii_and_mic/ascii_and_mic.c
deleted file mode 100644
index 95ecc94..0000000
--- a/src/backend/utils/mb/conversion_procs/ascii_and_mic/ascii_and_mic.c
+++ /dev/null
@@ -1,60 +0,0 @@
-/*-------------------------------------------------------------------------
- *
- *      ASCII and MULE_INTERNAL
- *
- * Portions Copyright (c) 1996-2019, PostgreSQL Global Development Group
- * Portions Copyright (c) 1994, Regents of the University of California
- *
- * IDENTIFICATION
- *      src/backend/utils/mb/conversion_procs/ascii_and_mic/ascii_and_mic.c
- *
- *-------------------------------------------------------------------------
- */
-
-#include "postgres.h"
-#include "fmgr.h"
-#include "mb/pg_wchar.h"
-
-PG_MODULE_MAGIC;
-
-PG_FUNCTION_INFO_V1(ascii_to_mic);
-PG_FUNCTION_INFO_V1(mic_to_ascii);
-
-/* ----------
- * conv_proc(
- *        INTEGER,    -- source encoding id
- *        INTEGER,    -- destination encoding id
- *        CSTRING,    -- source string (null terminated C string)
- *        CSTRING,    -- destination string (null terminated C string)
- *        INTEGER        -- source string length
- * ) returns VOID;
- * ----------
- */
-
-Datum
-ascii_to_mic(PG_FUNCTION_ARGS)
-{
-    unsigned char *src = (unsigned char *) PG_GETARG_CSTRING(2);
-    unsigned char *dest = (unsigned char *) PG_GETARG_CSTRING(3);
-    int            len = PG_GETARG_INT32(4);
-
-    CHECK_ENCODING_CONVERSION_ARGS(PG_SQL_ASCII, PG_MULE_INTERNAL);
-
-    pg_ascii2mic(src, dest, len);
-
-    PG_RETURN_VOID();
-}
-
-Datum
-mic_to_ascii(PG_FUNCTION_ARGS)
-{
-    unsigned char *src = (unsigned char *) PG_GETARG_CSTRING(2);
-    unsigned char *dest = (unsigned char *) PG_GETARG_CSTRING(3);
-    int            len = PG_GETARG_INT32(4);
-
-    CHECK_ENCODING_CONVERSION_ARGS(PG_MULE_INTERNAL, PG_SQL_ASCII);
-
-    pg_mic2ascii(src, dest, len);
-
-    PG_RETURN_VOID();
-}
diff --git a/src/backend/utils/mb/conversion_procs/utf8_and_ascii/Makefile
b/src/backend/utils/mb/conversion_procs/utf8_and_ascii/Makefile
deleted file mode 100644
index 7bd68e2..0000000
--- a/src/backend/utils/mb/conversion_procs/utf8_and_ascii/Makefile
+++ /dev/null
@@ -1,13 +0,0 @@
-#-------------------------------------------------------------------------
-#
-# src/backend/utils/mb/conversion_procs/utf8_and_ascii/Makefile
-#
-#-------------------------------------------------------------------------
-subdir = src/backend/utils/mb/conversion_procs/utf8_and_ascii
-top_builddir = ../../../../../..
-include $(top_builddir)/src/Makefile.global
-
-NAME        = utf8_and_ascii
-PGFILEDESC    = "utf8 <-> ascii text conversions"
-
-include $(srcdir)/../proc.mk
diff --git a/src/backend/utils/mb/conversion_procs/utf8_and_ascii/utf8_and_ascii.c
b/src/backend/utils/mb/conversion_procs/utf8_and_ascii/utf8_and_ascii.c
deleted file mode 100644
index 37db193..0000000
--- a/src/backend/utils/mb/conversion_procs/utf8_and_ascii/utf8_and_ascii.c
+++ /dev/null
@@ -1,62 +0,0 @@
-/*-------------------------------------------------------------------------
- *
- *      ASCII <--> UTF8
- *
- * Portions Copyright (c) 1996-2019, PostgreSQL Global Development Group
- * Portions Copyright (c) 1994, Regents of the University of California
- *
- * IDENTIFICATION
- *      src/backend/utils/mb/conversion_procs/utf8_and_ascii/utf8_and_ascii.c
- *
- *-------------------------------------------------------------------------
- */
-
-#include "postgres.h"
-#include "fmgr.h"
-#include "mb/pg_wchar.h"
-
-PG_MODULE_MAGIC;
-
-PG_FUNCTION_INFO_V1(ascii_to_utf8);
-PG_FUNCTION_INFO_V1(utf8_to_ascii);
-
-/* ----------
- * conv_proc(
- *        INTEGER,    -- source encoding id
- *        INTEGER,    -- destination encoding id
- *        CSTRING,    -- source string (null terminated C string)
- *        CSTRING,    -- destination string (null terminated C string)
- *        INTEGER        -- source string length
- * ) returns VOID;
- * ----------
- */
-
-Datum
-ascii_to_utf8(PG_FUNCTION_ARGS)
-{
-    unsigned char *src = (unsigned char *) PG_GETARG_CSTRING(2);
-    unsigned char *dest = (unsigned char *) PG_GETARG_CSTRING(3);
-    int            len = PG_GETARG_INT32(4);
-
-    CHECK_ENCODING_CONVERSION_ARGS(PG_SQL_ASCII, PG_UTF8);
-
-    /* this looks wrong, but basically we're just rejecting high-bit-set */
-    pg_ascii2mic(src, dest, len);
-
-    PG_RETURN_VOID();
-}
-
-Datum
-utf8_to_ascii(PG_FUNCTION_ARGS)
-{
-    unsigned char *src = (unsigned char *) PG_GETARG_CSTRING(2);
-    unsigned char *dest = (unsigned char *) PG_GETARG_CSTRING(3);
-    int            len = PG_GETARG_INT32(4);
-
-    CHECK_ENCODING_CONVERSION_ARGS(PG_UTF8, PG_SQL_ASCII);
-
-    /* this looks wrong, but basically we're just rejecting high-bit-set */
-    pg_mic2ascii(src, dest, len);
-
-    PG_RETURN_VOID();
-}
diff --git a/src/include/catalog/pg_conversion.dat b/src/include/catalog/pg_conversion.dat
index 17eff20..2dacc59 100644
--- a/src/include/catalog/pg_conversion.dat
+++ b/src/include/catalog/pg_conversion.dat
@@ -15,12 +15,6 @@

 [

-{ oid => '4400', descr => 'conversion for SQL_ASCII to MULE_INTERNAL',
-  conname => 'ascii_to_mic', conforencoding => 'PG_SQL_ASCII',
-  contoencoding => 'PG_MULE_INTERNAL', conproc => 'ascii_to_mic' },
-{ oid => '4401', descr => 'conversion for MULE_INTERNAL to SQL_ASCII',
-  conname => 'mic_to_ascii', conforencoding => 'PG_MULE_INTERNAL',
-  contoencoding => 'PG_SQL_ASCII', conproc => 'mic_to_ascii' },
 { oid => '4402', descr => 'conversion for KOI8R to MULE_INTERNAL',
   conname => 'koi8_r_to_mic', conforencoding => 'PG_KOI8R',
   contoencoding => 'PG_MULE_INTERNAL', conproc => 'koi8r_to_mic' },
@@ -165,12 +159,6 @@
 { oid => '4449', descr => 'conversion for MULE_INTERNAL to LATIN4',
   conname => 'mic_to_iso_8859_4', conforencoding => 'PG_MULE_INTERNAL',
   contoencoding => 'PG_LATIN4', conproc => 'mic_to_latin4' },
-{ oid => '4450', descr => 'conversion for SQL_ASCII to UTF8',
-  conname => 'ascii_to_utf8', conforencoding => 'PG_SQL_ASCII',
-  contoencoding => 'PG_UTF8', conproc => 'ascii_to_utf8' },
-{ oid => '4451', descr => 'conversion for UTF8 to SQL_ASCII',
-  conname => 'utf8_to_ascii', conforencoding => 'PG_UTF8',
-  contoencoding => 'PG_SQL_ASCII', conproc => 'utf8_to_ascii' },
 { oid => '4452', descr => 'conversion for BIG5 to UTF8',
   conname => 'big5_to_utf8', conforencoding => 'PG_BIG5',
   contoencoding => 'PG_UTF8', conproc => 'big5_to_utf8' },
diff --git a/src/include/catalog/pg_proc.dat b/src/include/catalog/pg_proc.dat
index 8733524..68719cd 100644
--- a/src/include/catalog/pg_proc.dat
+++ b/src/include/catalog/pg_proc.dat
@@ -10070,16 +10070,6 @@
   prosrc => 'binary_upgrade_set_missing_value' },

 # conversion functions
-{ oid => '4300',
-  descr => 'internal conversion function for SQL_ASCII to MULE_INTERNAL',
-  proname => 'ascii_to_mic', prolang => 'c', prorettype => 'void',
-  proargtypes => 'int4 int4 cstring internal int4', prosrc => 'ascii_to_mic',
-  probin => '$libdir/ascii_and_mic' },
-{ oid => '4301',
-  descr => 'internal conversion function for MULE_INTERNAL to SQL_ASCII',
-  proname => 'mic_to_ascii', prolang => 'c', prorettype => 'void',
-  proargtypes => 'int4 int4 cstring internal int4', prosrc => 'mic_to_ascii',
-  probin => '$libdir/ascii_and_mic' },
 { oid => '4302',
   descr => 'internal conversion function for KOI8R to MULE_INTERNAL',
   proname => 'koi8r_to_mic', prolang => 'c', prorettype => 'void',
@@ -10312,16 +10302,6 @@
   proname => 'mic_to_latin4', prolang => 'c', prorettype => 'void',
   proargtypes => 'int4 int4 cstring internal int4', prosrc => 'mic_to_latin4',
   probin => '$libdir/latin_and_mic' },
-{ oid => '4350',
-  descr => 'internal conversion function for SQL_ASCII to UTF8',
-  proname => 'ascii_to_utf8', prolang => 'c', prorettype => 'void',
-  proargtypes => 'int4 int4 cstring internal int4', prosrc => 'ascii_to_utf8',
-  probin => '$libdir/utf8_and_ascii' },
-{ oid => '4351',
-  descr => 'internal conversion function for UTF8 to SQL_ASCII',
-  proname => 'utf8_to_ascii', prolang => 'c', prorettype => 'void',
-  proargtypes => 'int4 int4 cstring internal int4', prosrc => 'utf8_to_ascii',
-  probin => '$libdir/utf8_and_ascii' },
 { oid => '4352', descr => 'internal conversion function for BIG5 to UTF8',
   proname => 'big5_to_utf8', prolang => 'c', prorettype => 'void',
   proargtypes => 'int4 int4 cstring internal int4', prosrc => 'big5_to_utf8',
diff --git a/src/include/mb/pg_wchar.h b/src/include/mb/pg_wchar.h
index ec101a8..60c5615 100644
--- a/src/include/mb/pg_wchar.h
+++ b/src/include/mb/pg_wchar.h
@@ -614,8 +614,6 @@ extern void report_untranslatable_char(int src_encoding, int dest_encoding,

 extern void local2local(const unsigned char *l, unsigned char *p, int len,
                         int src_encoding, int dest_encoding, const unsigned char *tab);
-extern void pg_ascii2mic(const unsigned char *l, unsigned char *p, int len);
-extern void pg_mic2ascii(const unsigned char *mic, unsigned char *p, int len);
 extern void latin2mic(const unsigned char *l, unsigned char *p, int len,
                       int lc, int encoding);
 extern void mic2latin(const unsigned char *mic, unsigned char *p, int len,
diff --git a/src/test/regress/expected/alter_table.out b/src/test/regress/expected/alter_table.out
index e687150..52e9baf 100644
--- a/src/test/regress/expected/alter_table.out
+++ b/src/test/regress/expected/alter_table.out
@@ -2713,7 +2713,7 @@ as 'select $1.f1 is not distinct from $2.f1 and $1.f2 is not distinct from $2.f2
 create operator alter1.=(procedure = alter1.same, leftarg  = alter1.ctype, rightarg = alter1.ctype);
 create operator class alter1.ctype_hash_ops default for type alter1.ctype using hash as
   operator 1 alter1.=(alter1.ctype, alter1.ctype);
-create conversion alter1.ascii_to_utf8 for 'sql_ascii' to 'utf8' from ascii_to_utf8;
+create conversion alter1.latin1_to_utf8 for 'latin1' to 'utf8' from iso8859_1_to_utf8;
 create text search parser alter1.prs(start = prsd_start, gettoken = prsd_nexttoken, end = prsd_end, lextypes =
prsd_lextype);
 create text search configuration alter1.cfg(parser = alter1.prs);
 create text search template alter1.tmpl(init = dsimple_init, lexize = dsimple_lexize);
@@ -2731,7 +2731,7 @@ alter operator alter1.=(alter1.ctype, alter1.ctype) set schema alter2;
 alter function alter1.same(alter1.ctype, alter1.ctype) set schema alter2;
 alter type alter1.ctype set schema alter1; -- no-op, same schema
 alter type alter1.ctype set schema alter2;
-alter conversion alter1.ascii_to_utf8 set schema alter2;
+alter conversion alter1.latin1_to_utf8 set schema alter2;
 alter text search parser alter1.prs set schema alter2;
 alter text search configuration alter1.cfg set schema alter2;
 alter text search template alter1.tmpl set schema alter2;
@@ -2775,7 +2775,7 @@ drop cascades to type alter2.ctype
 drop cascades to function alter2.same(alter2.ctype,alter2.ctype)
 drop cascades to operator alter2.=(alter2.ctype,alter2.ctype)
 drop cascades to operator family alter2.ctype_hash_ops for access method hash
-drop cascades to conversion alter2.ascii_to_utf8
+drop cascades to conversion alter2.latin1_to_utf8
 drop cascades to text search parser alter2.prs
 drop cascades to text search configuration alter2.cfg
 drop cascades to text search template alter2.tmpl
diff --git a/src/test/regress/expected/object_address.out b/src/test/regress/expected/object_address.out
index de75b9a..cdbde29 100644
--- a/src/test/regress/expected/object_address.out
+++ b/src/test/regress/expected/object_address.out
@@ -394,7 +394,7 @@ WITH objects (type, name, args) AS (VALUES
                 ('collation', '{default}', '{}'),
                 ('table constraint', '{addr_nsp, gentable, a_chk}', '{}'),
                 ('domain constraint', '{addr_nsp.gendomain}', '{domconstr}'),
-                ('conversion', '{pg_catalog, ascii_to_mic}', '{}'),
+                ('conversion', '{pg_catalog, koi8_r_to_mic}', '{}'),
                 ('default value', '{addr_nsp, gentable, b}', '{}'),
                 ('language', '{plpgsql}', '{}'),
                 -- large object
@@ -468,7 +468,7 @@ SELECT (pg_identify_object(addr1.classid, addr1.objid, addr1.objsubid)).*,
  cast                      |            |                   | (bigint AS integer)
           | t 
  table constraint          | addr_nsp   |                   | a_chk on addr_nsp.gentable
           | t 
  domain constraint         | addr_nsp   |                   | domconstr on addr_nsp.gendomain
           | t 
- conversion                | pg_catalog | ascii_to_mic      | pg_catalog.ascii_to_mic
           | t 
+ conversion                | pg_catalog | koi8_r_to_mic     | pg_catalog.koi8_r_to_mic
           | t 
  language                  |            | plpgsql           | plpgsql
           | t 
  schema                    |            | addr_nsp          | addr_nsp
           | t 
  operator class            | pg_catalog | int4_ops          | pg_catalog.int4_ops USING btree
           | t 
diff --git a/src/test/regress/sql/alter_table.sql b/src/test/regress/sql/alter_table.sql
index 8016f8a..99af0b8 100644
--- a/src/test/regress/sql/alter_table.sql
+++ b/src/test/regress/sql/alter_table.sql
@@ -1735,7 +1735,7 @@ create operator alter1.=(procedure = alter1.same, leftarg  = alter1.ctype, right
 create operator class alter1.ctype_hash_ops default for type alter1.ctype using hash as
   operator 1 alter1.=(alter1.ctype, alter1.ctype);

-create conversion alter1.ascii_to_utf8 for 'sql_ascii' to 'utf8' from ascii_to_utf8;
+create conversion alter1.latin1_to_utf8 for 'latin1' to 'utf8' from iso8859_1_to_utf8;

 create text search parser alter1.prs(start = prsd_start, gettoken = prsd_nexttoken, end = prsd_end, lextypes =
prsd_lextype);
 create text search configuration alter1.cfg(parser = alter1.prs);
@@ -1756,7 +1756,7 @@ alter operator alter1.=(alter1.ctype, alter1.ctype) set schema alter2;
 alter function alter1.same(alter1.ctype, alter1.ctype) set schema alter2;
 alter type alter1.ctype set schema alter1; -- no-op, same schema
 alter type alter1.ctype set schema alter2;
-alter conversion alter1.ascii_to_utf8 set schema alter2;
+alter conversion alter1.latin1_to_utf8 set schema alter2;
 alter text search parser alter1.prs set schema alter2;
 alter text search configuration alter1.cfg set schema alter2;
 alter text search template alter1.tmpl set schema alter2;
diff --git a/src/test/regress/sql/object_address.sql b/src/test/regress/sql/object_address.sql
index bd94cd6..725bc39 100644
--- a/src/test/regress/sql/object_address.sql
+++ b/src/test/regress/sql/object_address.sql
@@ -164,7 +164,7 @@ WITH objects (type, name, args) AS (VALUES
                 ('collation', '{default}', '{}'),
                 ('table constraint', '{addr_nsp, gentable, a_chk}', '{}'),
                 ('domain constraint', '{addr_nsp.gendomain}', '{domconstr}'),
-                ('conversion', '{pg_catalog, ascii_to_mic}', '{}'),
+                ('conversion', '{pg_catalog, koi8_r_to_mic}', '{}'),
                 ('default value', '{addr_nsp, gentable, b}', '{}'),
                 ('language', '{plpgsql}', '{}'),
                 -- large object