mirror of
https://github.com/postgres/postgres.git
synced 2025-07-08 11:42:09 +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:
@ -72,6 +72,18 @@ CreateConversionCommand(CreateConversionStmt *stmt)
|
||||
errmsg("destination encoding \"%s\" does not exist",
|
||||
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.
|
||||
|
Reference in New Issue
Block a user