Bug #46666 character_set_connection and character_set_result are not set correctly

Submitted: 12 Aug 2009 4:18
Reporter: Mikiya Okuno Email Updates:
Status: Verified Impact on me:
None 
Category:MySQL Server: C API (client library) Severity:S3 (Non-critical)
Version:5.1.37 OS:Any
Assigned to: CPU Architecture:Any

[12 Aug 2009 4:18] Mikiya Okuno
Description:
Connection character sets are not set to eucjpms correctly via mysql_options() API function. It changes character_set_client correctly, but character_set_result and character_set_connection are unchanged. The impacted character set is eucjpms only for Japanese character set.

How to repeat:
#include <stdio.h>
#include <strings.h>
#include <mysql.h>
#include <assert.h>
#include <stdlib.h>

int main()
{
  MYSQL *dbh;
  MYSQL_RES *query_result;
  MYSQL_ROW row;
  int status;

  /* INIT */
  dbh = mysql_init(NULL);
  status = mysql_options(dbh, MYSQL_SET_CHARSET_NAME, (void*)"eucjpms");
  if(status != 0) {
    printf("Cannot change the option: %s", mysql_error(dbh));
    exit(1);
  }
  if (!mysql_real_connect(dbh, NULL, "user", "password", "test", 3306, NULL, 0)) {
    printf("Cannot connect %s", mysql_error(dbh));
    exit(1);
  };

  char *sql = "SHOW VARIABLES LIKE 'c%'";
  mysql_real_query(dbh, sql, strlen(sql));
  query_result = mysql_store_result(dbh);
  while((row = mysql_fetch_row(query_result))) {
    printf("%s\t%s\n", row[0], row[1]);
  }
  mysql_free_result(query_result);

  mysql_close(dbh);
}

You will see the output like below:

character_set_client	eucjpms
character_set_connection	utf8
character_set_database	utf8
character_set_filesystem	binary
character_set_results	utf8
character_set_server	utf8
character_set_system	utf8
character_sets_dir	/usr/local/mysql-5.1.37/share/mysql/charsets/
collation_connection	utf8_general_ci
collation_database	utf8_general_ci
collation_server	utf8_general_ci
completion_type	0
concurrent_insert	1
connect_timeout	10

Suggested fix:
nada

Portions of this website are copyright © 2001, 2002 The PHP Group

Page generated in 0.038 sec. using MySQL 8.4.7-u6-cloud

Timestamp references displayed by the system are UTC.
Content reproduced on this site is the property of the respective copyright holders.
It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.