Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit0ab1a2e

Browse files
committed
Remove dead encoding-conversion functions.
The code for conversions SQL_ASCII <-> MULE_INTERNAL andSQL_ASCII <-> UTF8 was unreachable, because we long ago changedthe wrapper functions pg_do_encoding_conversion() et al so thatthey have hard-wired behaviors for conversions involving SQL_ASCII.(At least some of those fast paths date back to 2002, though itlooks like we may not have been totally consistent about this untillater.) Given the lack of complaints, nobody is dissatisfied withthis state of affairs. Hence, let's just remove the unreachable code.Also, change CREATE CONVERSION so that it rejects attempts todefine such conversions. Since we consider that SQL_ASCII representslack of knowledge about the encoding in use, such a conversion wouldbe semantically dubious even if it were reachable.Adjust a couple of regression test cases that had randomly decidedto rely on these conversion functions rather than any other ones.Discussion:https://postgr.es/m/41163.1559156593@sss.pgh.pa.us
1 parentef777cb commit0ab1a2e

File tree

18 files changed

+44
-269
lines changed

18 files changed

+44
-269
lines changed

‎doc/src/sgml/charset.sgml

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1896,7 +1896,11 @@ RESET client_encoding;
18961896
<para>
18971897
If the client character set is defined as <literal>SQL_ASCII</literal>,
18981898
encoding conversion is disabled, regardless of the server's character
1899-
set. Just as for the server, use of <literal>SQL_ASCII</literal> is unwise
1899+
set. (However, if the server's character set is
1900+
not <literal>SQL_ASCII</literal>, the server will still check that
1901+
incoming data is valid for that encoding; so the net effect is as
1902+
though the client character set were the same as the server's.)
1903+
Just as for the server, use of <literal>SQL_ASCII</literal> is unwise
19001904
unless you are working with all-ASCII data.
19011905
</para>
19021906
</sect2>

‎doc/src/sgml/func.sgml

Lines changed: 0 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -2496,18 +2496,6 @@
24962496
</thead>
24972497

24982498
<tbody>
2499-
<row>
2500-
<entry><literal>ascii_to_mic</literal></entry>
2501-
<entry><literal>SQL_ASCII</literal></entry>
2502-
<entry><literal>MULE_INTERNAL</literal></entry>
2503-
</row>
2504-
2505-
<row>
2506-
<entry><literal>ascii_to_utf8</literal></entry>
2507-
<entry><literal>SQL_ASCII</literal></entry>
2508-
<entry><literal>UTF8</literal></entry>
2509-
</row>
2510-
25112499
<row>
25122500
<entry><literal>big5_to_euc_tw</literal></entry>
25132501
<entry><literal>BIG5</literal></entry>
@@ -2778,12 +2766,6 @@
27782766
<entry><literal>UTF8</literal></entry>
27792767
</row>
27802768

2781-
<row>
2782-
<entry><literal>mic_to_ascii</literal></entry>
2783-
<entry><literal>MULE_INTERNAL</literal></entry>
2784-
<entry><literal>SQL_ASCII</literal></entry>
2785-
</row>
2786-
27872769
<row>
27882770
<entry><literal>mic_to_big5</literal></entry>
27892771
<entry><literal>MULE_INTERNAL</literal></entry>
@@ -2904,12 +2886,6 @@
29042886
<entry><literal>UTF8</literal></entry>
29052887
</row>
29062888

2907-
<row>
2908-
<entry><literal>utf8_to_ascii</literal></entry>
2909-
<entry><literal>UTF8</literal></entry>
2910-
<entry><literal>SQL_ASCII</literal></entry>
2911-
</row>
2912-
29132889
<row>
29142890
<entry><literal>utf8_to_big5</literal></entry>
29152891
<entry><literal>UTF8</literal></entry>

‎doc/src/sgml/ref/create_conversion.sgml

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -28,12 +28,15 @@ CREATE [ DEFAULT ] CONVERSION <replaceable>name</replaceable>
2828

2929
<para>
3030
<command>CREATE CONVERSION</command> defines a new conversion between
31-
character set encodings. Also, conversions that
32-
are marked <literal>DEFAULT</literal> can be used for automatic encoding
33-
conversion between
34-
client and server. For this purpose, two conversions, from encoding A to
35-
B <emphasis>and</emphasis> from encoding B to A, must be defined.
36-
</para>
31+
two character set encodings.
32+
</para>
33+
34+
<para>
35+
Conversions that are marked <literal>DEFAULT</literal> can be used for
36+
automatic encoding conversion between client and server. To support that
37+
usage, two conversions, from encoding A to B <emphasis>and</emphasis>
38+
from encoding B to A, must be defined.
39+
</para>
3740

3841
<para>
3942
To be able to create a conversion, you must have <literal>EXECUTE</literal> privilege
@@ -122,6 +125,13 @@ conv_proc(
122125
<refsect1 id="sql-createconversion-notes">
123126
<title>Notes</title>
124127

128+
<para>
129+
Neither the source nor the destination encoding can
130+
be <literal>SQL_ASCII</literal>, as the server's behavior for cases
131+
involving the <literal>SQL_ASCII</literal> <quote>encoding</quote> is
132+
hard-wired.
133+
</para>
134+
125135
<para>
126136
Use <command>DROP CONVERSION</command> to remove user-defined conversions.
127137
</para>

‎src/backend/commands/conversioncmds.c

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,18 @@ CreateConversionCommand(CreateConversionStmt *stmt)
7272
errmsg("destination encoding \"%s\" does not exist",
7373
to_encoding_name)));
7474

75+
/*
76+
* We consider conversions to or from SQL_ASCII to be meaningless. (If
77+
* you wish to change this, note that pg_do_encoding_conversion() and its
78+
* sister functions have hard-wired fast paths for any conversion in which
79+
* the source or target encoding is SQL_ASCII, so that an encoding
80+
* conversion function declared for such a case will never be used.)
81+
*/
82+
if (from_encoding==PG_SQL_ASCII||to_encoding==PG_SQL_ASCII)
83+
ereport(ERROR,
84+
(errcode(ERRCODE_INVALID_OBJECT_DEFINITION),
85+
errmsg("encoding conversion to or from \"SQL_ASCII\" is not supported")));
86+
7587
/*
7688
* Check the existence of the conversion function. Function name could be
7789
* a qualified name.

‎src/backend/utils/mb/conv.c

Lines changed: 0 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -132,51 +132,6 @@ mic2latin(const unsigned char *mic, unsigned char *p, int len,
132132
}
133133

134134

135-
/*
136-
* ASCII ---> MIC
137-
*
138-
* While ordinarily SQL_ASCII encoding is forgiving of high-bit-set
139-
* characters, here we must take a hard line because we don't know
140-
* the appropriate MIC equivalent.
141-
*/
142-
void
143-
pg_ascii2mic(constunsignedchar*l,unsignedchar*p,intlen)
144-
{
145-
intc1;
146-
147-
while (len>0)
148-
{
149-
c1=*l;
150-
if (c1==0||IS_HIGHBIT_SET(c1))
151-
report_invalid_encoding(PG_SQL_ASCII, (constchar*)l,len);
152-
*p++=c1;
153-
l++;
154-
len--;
155-
}
156-
*p='\0';
157-
}
158-
159-
/*
160-
* MIC ---> ASCII
161-
*/
162-
void
163-
pg_mic2ascii(constunsignedchar*mic,unsignedchar*p,intlen)
164-
{
165-
intc1;
166-
167-
while (len>0)
168-
{
169-
c1=*mic;
170-
if (c1==0||IS_HIGHBIT_SET(c1))
171-
report_untranslatable_char(PG_MULE_INTERNAL,PG_SQL_ASCII,
172-
(constchar*)mic,len);
173-
*p++=c1;
174-
mic++;
175-
len--;
176-
}
177-
*p='\0';
178-
}
179-
180135
/*
181136
* latin2mic_with_table: a generic single byte charset encoding
182137
* conversion from a local charset to the mule internal code.

‎src/backend/utils/mb/conversion_procs/Makefile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,9 @@ top_builddir = ../../../../..
1414
include$(top_builddir)/src/Makefile.global
1515

1616
SUBDIRS =\
17-
ascii_and_miccyrillic_and_mic euc_cn_and_mic euc_jp_and_sjis\
17+
cyrillic_and_mic euc_cn_and_mic euc_jp_and_sjis\
1818
euc_kr_and_mic euc_tw_and_big5 latin2_and_win1250 latin_and_mic\
19-
utf8_and_asciiutf8_and_big5 utf8_and_cyrillic utf8_and_euc_cn\
19+
utf8_and_big5 utf8_and_cyrillic utf8_and_euc_cn\
2020
utf8_and_euc_jp utf8_and_euc_kr utf8_and_euc_tw utf8_and_gb18030\
2121
utf8_and_gbk utf8_and_iso8859 utf8_and_iso8859_1 utf8_and_johab\
2222
utf8_and_sjis utf8_and_win utf8_and_uhc\

‎src/backend/utils/mb/conversion_procs/ascii_and_mic/Makefile

Lines changed: 0 additions & 13 deletions
This file was deleted.

‎src/backend/utils/mb/conversion_procs/ascii_and_mic/ascii_and_mic.c

Lines changed: 0 additions & 60 deletions
This file was deleted.

‎src/backend/utils/mb/conversion_procs/utf8_and_ascii/Makefile

Lines changed: 0 additions & 13 deletions
This file was deleted.

‎src/backend/utils/mb/conversion_procs/utf8_and_ascii/utf8_and_ascii.c

Lines changed: 0 additions & 62 deletions
This file was deleted.

‎src/include/catalog/catversion.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,6 @@
5353
*/
5454

5555
/*yyyymmddN */
56-
#defineCATALOG_VERSION_NO201907053
56+
#defineCATALOG_VERSION_NO201907054
5757

5858
#endif

‎src/include/catalog/pg_conversion.dat

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -15,12 +15,6 @@
1515

1616
[
1717

18-
{ oid => '4400', descr => 'conversion for SQL_ASCII to MULE_INTERNAL',
19-
conname => 'ascii_to_mic', conforencoding => 'PG_SQL_ASCII',
20-
contoencoding => 'PG_MULE_INTERNAL', conproc => 'ascii_to_mic' },
21-
{ oid => '4401', descr => 'conversion for MULE_INTERNAL to SQL_ASCII',
22-
conname => 'mic_to_ascii', conforencoding => 'PG_MULE_INTERNAL',
23-
contoencoding => 'PG_SQL_ASCII', conproc => 'mic_to_ascii' },
2418
{ oid => '4402', descr => 'conversion for KOI8R to MULE_INTERNAL',
2519
conname => 'koi8_r_to_mic', conforencoding => 'PG_KOI8R',
2620
contoencoding => 'PG_MULE_INTERNAL', conproc => 'koi8r_to_mic' },
@@ -165,12 +159,6 @@
165159
{ oid => '4449', descr => 'conversion for MULE_INTERNAL to LATIN4',
166160
conname => 'mic_to_iso_8859_4', conforencoding => 'PG_MULE_INTERNAL',
167161
contoencoding => 'PG_LATIN4', conproc => 'mic_to_latin4' },
168-
{ oid => '4450', descr => 'conversion for SQL_ASCII to UTF8',
169-
conname => 'ascii_to_utf8', conforencoding => 'PG_SQL_ASCII',
170-
contoencoding => 'PG_UTF8', conproc => 'ascii_to_utf8' },
171-
{ oid => '4451', descr => 'conversion for UTF8 to SQL_ASCII',
172-
conname => 'utf8_to_ascii', conforencoding => 'PG_UTF8',
173-
contoencoding => 'PG_SQL_ASCII', conproc => 'utf8_to_ascii' },
174162
{ oid => '4452', descr => 'conversion for BIG5 to UTF8',
175163
conname => 'big5_to_utf8', conforencoding => 'PG_BIG5',
176164
contoencoding => 'PG_UTF8', conproc => 'big5_to_utf8' },

‎src/include/catalog/pg_proc.dat

Lines changed: 0 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -10082,16 +10082,6 @@
1008210082
prosrc => 'binary_upgrade_set_missing_value' },
1008310083

1008410084
# conversion functions
10085-
{ oid => '4300',
10086-
descr => 'internal conversion function for SQL_ASCII to MULE_INTERNAL',
10087-
proname => 'ascii_to_mic', prolang => 'c', prorettype => 'void',
10088-
proargtypes => 'int4 int4 cstring internal int4', prosrc => 'ascii_to_mic',
10089-
probin => '$libdir/ascii_and_mic' },
10090-
{ oid => '4301',
10091-
descr => 'internal conversion function for MULE_INTERNAL to SQL_ASCII',
10092-
proname => 'mic_to_ascii', prolang => 'c', prorettype => 'void',
10093-
proargtypes => 'int4 int4 cstring internal int4', prosrc => 'mic_to_ascii',
10094-
probin => '$libdir/ascii_and_mic' },
1009510085
{ oid => '4302',
1009610086
descr => 'internal conversion function for KOI8R to MULE_INTERNAL',
1009710087
proname => 'koi8r_to_mic', prolang => 'c', prorettype => 'void',
@@ -10324,16 +10314,6 @@
1032410314
proname => 'mic_to_latin4', prolang => 'c', prorettype => 'void',
1032510315
proargtypes => 'int4 int4 cstring internal int4', prosrc => 'mic_to_latin4',
1032610316
probin => '$libdir/latin_and_mic' },
10327-
{ oid => '4350',
10328-
descr => 'internal conversion function for SQL_ASCII to UTF8',
10329-
proname => 'ascii_to_utf8', prolang => 'c', prorettype => 'void',
10330-
proargtypes => 'int4 int4 cstring internal int4', prosrc => 'ascii_to_utf8',
10331-
probin => '$libdir/utf8_and_ascii' },
10332-
{ oid => '4351',
10333-
descr => 'internal conversion function for UTF8 to SQL_ASCII',
10334-
proname => 'utf8_to_ascii', prolang => 'c', prorettype => 'void',
10335-
proargtypes => 'int4 int4 cstring internal int4', prosrc => 'utf8_to_ascii',
10336-
probin => '$libdir/utf8_and_ascii' },
1033710317
{ oid => '4352', descr => 'internal conversion function for BIG5 to UTF8',
1033810318
proname => 'big5_to_utf8', prolang => 'c', prorettype => 'void',
1033910319
proargtypes => 'int4 int4 cstring internal int4', prosrc => 'big5_to_utf8',

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp