1
0
mirror of https://github.com/mariadb-corporation/mariadb-connector-c.git synced 2025-08-07 02:42:49 +03:00

Fix for CONC-315:

If no default client character set was specified, the utf8 character set will be used by default (instead of setting the client character set to server character set)
This commit is contained in:
Georg Richter
2018-04-11 13:21:05 +02:00
committed by Sergei Golubchik
parent dae524d079
commit f39db18ec3
3 changed files with 21 additions and 5 deletions

View File

@@ -22,7 +22,7 @@
#include <mariadb_ctype.h> #include <mariadb_ctype.h>
#include <ma_string.h> #include <ma_string.h>
MARIADB_CHARSET_INFO *ma_default_charset_info = (MARIADB_CHARSET_INFO *)&mariadb_compiled_charsets[5]; MARIADB_CHARSET_INFO *ma_default_charset_info = (MARIADB_CHARSET_INFO *)&mariadb_compiled_charsets[21];
MARIADB_CHARSET_INFO *ma_charset_bin= (MARIADB_CHARSET_INFO *)&mariadb_compiled_charsets[32]; MARIADB_CHARSET_INFO *ma_charset_bin= (MARIADB_CHARSET_INFO *)&mariadb_compiled_charsets[32];
MARIADB_CHARSET_INFO *ma_charset_latin1= (MARIADB_CHARSET_INFO *)&mariadb_compiled_charsets[5]; MARIADB_CHARSET_INFO *ma_charset_latin1= (MARIADB_CHARSET_INFO *)&mariadb_compiled_charsets[5];
MARIADB_CHARSET_INFO *ma_charset_utf8_general_ci= (MARIADB_CHARSET_INFO *)&mariadb_compiled_charsets[21]; MARIADB_CHARSET_INFO *ma_charset_utf8_general_ci= (MARIADB_CHARSET_INFO *)&mariadb_compiled_charsets[21];

View File

@@ -1471,8 +1471,6 @@ MYSQL *mthd_my_real_connect(MYSQL *mysql, const char *host, const char *user,
/* Set character set */ /* Set character set */
if (mysql->options.charset_name) if (mysql->options.charset_name)
mysql->charset= mysql_find_charset_name(mysql->options.charset_name); mysql->charset= mysql_find_charset_name(mysql->options.charset_name);
else if (mysql->server_language)
mysql->charset= mysql_find_charset_nr(mysql->server_language);
else else
mysql->charset=ma_default_charset_info; mysql->charset=ma_default_charset_info;
@@ -1721,8 +1719,6 @@ my_bool STDCALL mysql_change_user(MYSQL *mysql, const char *user,
if (mysql->options.charset_name) if (mysql->options.charset_name)
mysql->charset =mysql_find_charset_name(mysql->options.charset_name); mysql->charset =mysql_find_charset_name(mysql->options.charset_name);
else if (mysql->server_language)
mysql->charset=mysql_find_charset_nr(mysql->server_language);
else else
mysql->charset=ma_default_charset_info; mysql->charset=ma_default_charset_info;

View File

@@ -1358,7 +1358,27 @@ static int test_expired_pw(MYSQL *my)
return OK; return OK;
} }
static int test_conc315(MYSQL *mysql)
{
int rc;
const char *csname;
if (!is_mariadb)
return SKIP;
mysql_get_optionv(mysql, MYSQL_SET_CHARSET_NAME, &csname);
FAIL_UNLESS(strcmp(csname, "utf8") == 0, "Wrong default character set");
rc= mysql_change_user(mysql, username, password, schema);
check_mysql_rc(rc, mysql);
mysql_get_optionv(mysql, MYSQL_SET_CHARSET_NAME, &csname);
FAIL_UNLESS(strcmp(csname, "utf8") == 0, "Wrong default character set");
return OK;
}
struct my_tests_st my_tests[] = { struct my_tests_st my_tests[] = {
{"test_conc315", test_conc315, TEST_CONNECTION_DEFAULT, 0, NULL, NULL},
{"test_expired_pw", test_expired_pw, TEST_CONNECTION_DEFAULT, 0, NULL, NULL}, {"test_expired_pw", test_expired_pw, TEST_CONNECTION_DEFAULT, 0, NULL, NULL},
{"test_conc276", test_conc276, TEST_CONNECTION_NONE, 0, NULL, NULL}, {"test_conc276", test_conc276, TEST_CONNECTION_NONE, 0, NULL, NULL},
{"test_mdev13100", test_mdev13100, TEST_CONNECTION_DEFAULT, 0, NULL, NULL}, {"test_mdev13100", test_mdev13100, TEST_CONNECTION_DEFAULT, 0, NULL, NULL},