Skip to content

Commit

Permalink
Fix for CONC-315:
Browse files Browse the repository at this point in the history
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).
  • Loading branch information
9EOR9 committed Apr 9, 2018
1 parent 2bd29c2 commit f71b4f8
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 5 deletions.
2 changes: 1 addition & 1 deletion libmariadb/charset.c
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
#include <m_string.h>
#include <my_dir.h>

CHARSET_INFO *default_charset_info = (CHARSET_INFO *)&compiled_charsets[5];
CHARSET_INFO *default_charset_info = (CHARSET_INFO *)&compiled_charsets[21];
CHARSET_INFO *my_charset_bin= (CHARSET_INFO *)&compiled_charsets[32];
CHARSET_INFO *my_charset_latin1= (CHARSET_INFO *)&compiled_charsets[5];
CHARSET_INFO *my_charset_utf8_general_ci= (CHARSET_INFO *)&compiled_charsets[21];
Expand Down
4 changes: 0 additions & 4 deletions libmariadb/libmariadb.c
Original file line number Diff line number Diff line change
Expand Up @@ -2020,8 +2020,6 @@ MYSQL *mthd_my_real_connect(MYSQL *mysql, const char *host, const char *user,
/* Set character set */
if (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
mysql->charset=default_charset_info;

Expand Down Expand Up @@ -2202,8 +2200,6 @@ my_bool STDCALL mysql_change_user(MYSQL *mysql, const char *user,

if (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
mysql->charset=default_charset_info;

Expand Down
17 changes: 17 additions & 0 deletions unittest/libmariadb/connection.c
Original file line number Diff line number Diff line change
Expand Up @@ -792,7 +792,24 @@ static int test_read_timeout(MYSQL *my __attribute__((unused)))
return OK;
}

static int test_conc315(MYSQL *mysql)
{
int rc;
const char *csname;

csname= mysql_character_set_name(mysql);
FAIL_UNLESS(strcmp(csname, "utf8") == 0, "Wrong default character set");

rc= mysql_change_user(mysql, username, password, schema);
check_mysql_rc(rc, mysql);
csname= mysql_character_set_name(mysql);
FAIL_UNLESS(strcmp(csname, "utf8") == 0, "Wrong default character set");
return OK;
}


struct my_tests_st my_tests[] = {
{"test_conc315", test_conc315, TEST_CONNECTION_DEFAULT, 0, NULL, NULL},
{"test_read_timeout", test_read_timeout, TEST_CONNECTION_NONE, 0, NULL, NULL},
{"test_conc_163", test_conc_163, TEST_CONNECTION_DEFAULT, 0, NULL, NULL},
{"test_bind_address", test_bind_address, TEST_CONNECTION_DEFAULT, 0, NULL, NULL},
Expand Down

0 comments on commit f71b4f8

Please sign in to comment.