Skip to content
This repository was archived by the owner on Mar 1, 2026. It is now read-only.

Commit de98bbc

Browse files
hermanleefacebook-github-bot
authored andcommitted
Bug#35054579 Issue in Oracle MySQL Client using utf16 charset
Summary: Porting fix for Bug#35054579 from 8.0.33 back to 8.0.32. Drop patch when porting forward past 8.0.33. Description: If we try to connect the server with mysql client using --default-character-set=utf1 using a authentication plugin, the client connection is failing with below error ERROR 2059 (HY000): Authentication plugin '../../mysql_native_password' cannot be loaded: '../../mysql_native_password.so': cannot open shared object file: No such file or directory instead of ERROR 2059 (HY000): Authentication plugin '../../mysql_native_password' cannot be loaded: No paths allowed for shared library Analysis: As per mysql documentation utf16, utf32, ucs2 and utf16le are Impermissible Client Character Sets, so when the client tries to connect the server with these charsets, the client has to reject the connections. Fix: While parsing the mysq client options, detecting the Impermissible Client Character Sets and rejecting the connection. Change-Id: Ib0d6624c792214b7b44fbb7040646f04081fb3e0 Differential Revision: D55337684 fbshipit-source-id: ae3518a
1 parent c7d3371 commit de98bbc

5 files changed

Lines changed: 18 additions & 5 deletions

File tree

‎client/mysql.cc‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4792,7 +4792,7 @@ static bool init_connection_options(MYSQL *mysql) {
47924792
mysql_options(mysql, MYSQL_INIT_COMMAND, init_command);
47934793
}
47944794

4795-
mysql_set_character_set(mysql, default_charset);
4795+
if (mysql_set_character_set(mysql, default_charset)) return true;
47964796

47974797
if (opt_plugin_dir && *opt_plugin_dir)
47984798
mysql_options(mysql, MYSQL_PLUGIN_DIR, opt_plugin_dir);

‎include/errmsg.h‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,7 @@ extern const char *client_errors[]; /* Error messages */
132132
#define CR_MANDATORY_TRACKER_NOT_FOUND 2071
133133
#define CR_INVALID_FACTOR_NO 2072
134134
#define CR_CANT_GET_SESSION_DATA 2073
135-
#define CR_PLACEHOLDER_2074 2074
135+
#define CR_INVALID_CLIENT_CHARSET 2074
136136
#define CR_PLACEHOLDER_2075 2075
137137
#define CR_PLACEHOLDER_2076 2076
138138
#define CR_PLACEHOLDER_2077 2077
@@ -268,7 +268,7 @@ extern const char *client_errors[]; /* Error messages */
268268
#define CR_ERROR_LAST /*Copy last error nr:*/ 2203
269269
/* Add error numbers before CR_ERROR_LAST and change it accordingly. */
270270

271-
#define CR_PLACEHOLDER_FIRST CR_PLACEHOLDER_2074
271+
#define CR_PLACEHOLDER_FIRST CR_PLACEHOLDER_2075
272272
#define CR_PLACEHOLDER_LAST CR_PLACEHOLDER_2199
273273

274274
static inline bool isPlaceHolder(int client_errno) {

‎include/mysql.h.pp‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -414,7 +414,7 @@
414414
void finish_client_errs(void);
415415
extern const char *client_errors[];
416416
static inline bool isPlaceHolder(int client_errno) {
417-
return client_errno >= 2074 &&
417+
return client_errno >= 2075 &&
418418
client_errno <= 2199;
419419
}
420420
static inline const char *ER_CLIENT(int client_errno) {

‎libmysql/errmsg.cc‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,9 @@ const char *client_errors[] = {
119119
"Invalid first argument for MYSQL_OPT_USER_PASSWORD option. Valid value "
120120
"should be between 1 and 3 inclusive.",
121121
"Can't get session data: %s",
122-
"Placeholder 2074",
122+
"'%-.32s' character set is having more than 1 byte minimum character "
123+
"length, which cannot be used as a client character set. Please use any "
124+
"of the single byte minimum ones, e.g. utf8mb4, latin1 etc.",
123125
"Placeholder 2075",
124126
"Placeholder 2076",
125127
"Placeholder 2077",

‎sql-common/client.cc‎

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10248,6 +10248,17 @@ int STDCALL mysql_set_character_set(MYSQL *mysql, const char *cs_name) {
1024810248
cs_name = mysql->options.charset_name;
1024910249
}
1025010250

10251+
#ifndef MYSQL_SERVER
10252+
if (mysql->charset != nullptr) {
10253+
if (!is_supported_parser_charset(mysql->charset)) {
10254+
set_mysql_extended_error(mysql, CR_INVALID_CLIENT_CHARSET,
10255+
unknown_sqlstate,
10256+
ER_CLIENT(CR_INVALID_CLIENT_CHARSET), cs_name);
10257+
return 1;
10258+
}
10259+
}
10260+
#endif
10261+
1025110262
if (strlen(cs_name) < MY_CS_NAME_SIZE &&
1025210263
(cs = get_charset_by_csname(cs_name, MY_CS_PRIMARY, MYF(0)))) {
1025310264
char buff[MY_CS_NAME_SIZE + 10];

0 commit comments

Comments
 (0)