mirror of https://github.com/postgres/postgres
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.uspull/47/head
parent
ef777cb093
commit
0ab1a2e39b
@ -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 |
@ -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(); |
||||
} |
@ -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 |
@ -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(); |
||||
} |
Loading…
Reference in new issue