MySQL Lists are EOL. Please join:

List:Commits« Previous MessageNext Message »
From:holyfoot Date:June 19 2006 5:11pm
Subject:bk commit into 4.1 tree (holyfoot:1.2498) BUG#20318
View as plain text  
Below is the list of changes that have just been committed into a local
4.1 repository of hf. When hf does a push these changes will
be propagated to the main repository and, within 24 hours after the
push, to the public repository.
For information on how to access the public repository
see http://dev.mysql.com/doc/mysql/en/installing-source-tree.html

ChangeSet
  1.2498 06/06/19 22:11:01 holyfoot@deer.(none) +5 -0
  bug #20318 (ctype_ucs2_def test fails with embedded)
  there was two problems about charsets in embedded server
  1. mysys/charset.c - defined there default_charset_info variable is
  modified by both server and client code (particularly when
  --default-charset option is handled)
  In embedded server we get two codelines modifying one variable.
  I created separate default_client_charset_info for client code
  
  2. mysql->charset and mysql->options.charset initialization isn't
  properly done for embedded server - necessary calls added

  sql/sql_parse.cc
    1.481 06/06/19 22:10:15 holyfoot@stripped +32 -27
    thread client charset initialization moved to thd_init_client_charset
    to avoid code duplication

  sql-common/client.c
    1.89 06/06/19 22:10:15 holyfoot@stripped +48 -36
    charset initialization moved to mysql_init_character_set to
    be used in embedded server

  libmysqld/libmysqld.c
    1.66 06/06/19 22:10:15 holyfoot@stripped +3 -45
    check_embedded_connection moved to client.c to avoid code duplication

  libmysqld/lib_sql.cc
    1.126 06/06/19 22:10:15 holyfoot@stripped +7 -0
    thd_init_client_charset calls added

  include/sql_common.h
    1.15 06/06/19 22:10:15 holyfoot@stripped +1 -0
    client charset info default declared

# This is a BitKeeper patch.  What follows are the unified diffs for the
# set of deltas contained in the patch.  The rest of the patch, the part
# that BitKeeper cares about, is below these diffs.
# User:	holyfoot
# Host:	deer.(none)
# Root:	/home/hf/work/mysql-4.1.20318

--- 1.480/sql/sql_parse.cc	Wed Apr 26 22:10:15 2006
+++ 1.481/sql/sql_parse.cc	Mon Jun 19 22:10:15 2006
@@ -667,6 +667,37 @@
 #endif /* NO_EMBEDDED_ACCESS_CHECKS */
 }
 
+void thd_init_client_charset(THD *thd, uint cs_number)
+{
+  /*
+   Use server character set and collation if
+   - opt_character_set_client_handshake is not set
+   - client has not specified a character set
+   - client character set is the same as the servers
+   - client character set doesn't exists in server
+  */
+  if (!opt_character_set_client_handshake ||
+      !(thd->variables.character_set_client= get_charset(cs_number, MYF(0))) ||
+      !my_strcasecmp(&my_charset_latin1,
+                     global_system_variables.character_set_client->name,
+                     thd->variables.character_set_client->name))
+  {
+    thd->variables.character_set_client=
+      global_system_variables.character_set_client;
+    thd->variables.collation_connection=
+      global_system_variables.collation_connection;
+    thd->variables.character_set_results=
+      global_system_variables.character_set_results;
+  }
+  else
+  {
+    thd->variables.character_set_results=
+      thd->variables.collation_connection= 
+      thd->variables.character_set_client;
+  }
+}
+
+
 /*
     Perform handshake, authorize client and update thd ACL variables.
   SYNOPSIS
@@ -809,33 +840,7 @@
     thd->client_capabilities|= ((ulong) uint2korr(net->read_pos+2)) << 16;
     thd->max_client_packet_length= uint4korr(net->read_pos+4);
     DBUG_PRINT("info", ("client_character_set: %d", (uint) net->read_pos[8]));
-    /*
-      Use server character set and collation if
-      - opt_character_set_client_handshake is not set
-      - client has not specified a character set
-      - client character set is the same as the servers
-      - client character set doesn't exists in server
-    */
-    if (!opt_character_set_client_handshake ||
-        !(thd->variables.character_set_client=
-	  get_charset((uint) net->read_pos[8], MYF(0))) ||
-	!my_strcasecmp(&my_charset_latin1,
-		       global_system_variables.character_set_client->name,
-		       thd->variables.character_set_client->name))
-    {
-      thd->variables.character_set_client=
-	global_system_variables.character_set_client;
-      thd->variables.collation_connection=
-	global_system_variables.collation_connection;
-      thd->variables.character_set_results=
-	global_system_variables.character_set_results;
-    }
-    else
-    {
-      thd->variables.character_set_results=
-      thd->variables.collation_connection= 
-	thd->variables.character_set_client;
-    }
+    thd_init_client_charset(thd, (uint) net->read_pos[8]);
     thd->update_charset();
     end= (char*) net->read_pos+32;
   }

--- 1.14/include/sql_common.h	Fri Oct 15 23:03:07 2004
+++ 1.15/include/sql_common.h	Mon Jun 19 22:10:15 2006
@@ -22,6 +22,7 @@
 extern "C" {
 #endif
 
+extern CHARSET_INFO *default_client_charset_info;
 MYSQL_FIELD *unpack_fields(MYSQL_DATA *data,MEM_ROOT *alloc,uint fields,
 			   my_bool default_value, uint server_capabilities);
 void free_rows(MYSQL_DATA *cur);

--- 1.88/sql-common/client.c	Mon Nov 21 16:08:39 2005
+++ 1.89/sql-common/client.c	Mon Jun 19 22:10:15 2006
@@ -133,6 +133,8 @@
 static int wait_for_data(my_socket fd, uint timeout);
 #endif
 
+CHARSET_INFO *default_client_charset_info = &my_charset_latin1;
+
 
 /****************************************************************************
   A modified version of connect().  my_connect() allows you to specify
@@ -1424,7 +1426,7 @@
     bzero((char*) (mysql),sizeof(*(mysql)));
   mysql->options.connect_timeout= CONNECT_TIMEOUT;
   mysql->last_used_con= mysql->next_slave= mysql->master = mysql;
-  mysql->charset=default_charset_info;
+  mysql->charset=default_client_charset_info;
   strmov(mysql->net.sqlstate, not_error_sqlstate);
   /*
     By default, we are a replication pivot. The caller must reset it
@@ -1537,6 +1539,50 @@
 #endif
 };
 
+C_MODE_START
+int mysql_init_character_set(MYSQL *mysql)
+{
+  NET		*net= &mysql->net;
+  /* Set character set */
+  if (!mysql->options.charset_name &&
+      !(mysql->options.charset_name= 
+       my_strdup(MYSQL_DEFAULT_CHARSET_NAME,MYF(MY_WME))))
+    return 1;
+  
+  {
+    const char *save= charsets_dir;
+    if (mysql->options.charset_dir)
+      charsets_dir=mysql->options.charset_dir;
+    mysql->charset=get_charset_by_csname(mysql->options.charset_name,
+                                         MY_CS_PRIMARY, MYF(MY_WME));
+    charsets_dir= save;
+  }
+  
+  if (!mysql->charset)
+  {
+    net->last_errno=CR_CANT_READ_CHARSET;
+    strmov(net->sqlstate, unknown_sqlstate);
+    if (mysql->options.charset_dir)
+      my_snprintf(net->last_error, sizeof(net->last_error)-1,
+                  ER(net->last_errno),
+                  mysql->options.charset_name,
+                  mysql->options.charset_dir);
+    else
+    {
+      char cs_dir_name[FN_REFLEN];
+      get_charsets_dir(cs_dir_name);
+      my_snprintf(net->last_error, sizeof(net->last_error)-1,
+                  ER(net->last_errno),
+                  mysql->options.charset_name,
+                  cs_dir_name);
+    }
+    return 1;
+  }
+  return 0;
+}
+C_MODE_END
+
+
 MYSQL * STDCALL 
 CLI_MYSQL_REAL_CONNECT(MYSQL *mysql,const char *host, const char *user,
 		       const char *passwd, const char *db,
@@ -1875,42 +1921,8 @@
     goto error;
   }
 
-  /* Set character set */
-  if (!mysql->options.charset_name &&
-      !(mysql->options.charset_name= 
-       my_strdup(MYSQL_DEFAULT_CHARSET_NAME,MYF(MY_WME))))
-    goto error;
-  
-  {
-    const char *save= charsets_dir;
-    if (mysql->options.charset_dir)
-      charsets_dir=mysql->options.charset_dir;
-    mysql->charset=get_charset_by_csname(mysql->options.charset_name,
-                                         MY_CS_PRIMARY, MYF(MY_WME));
-    charsets_dir= save;
-  }
-  
-  if (!mysql->charset)
-  {
-    net->last_errno=CR_CANT_READ_CHARSET;
-    strmov(net->sqlstate, unknown_sqlstate);
-    if (mysql->options.charset_dir)
-      my_snprintf(net->last_error, sizeof(net->last_error)-1,
-                  ER(net->last_errno),
-                  mysql->options.charset_name,
-                  mysql->options.charset_dir);
-    else
-    {
-      char cs_dir_name[FN_REFLEN];
-      get_charsets_dir(cs_dir_name);
-      my_snprintf(net->last_error, sizeof(net->last_error)-1,
-                  ER(net->last_errno),
-                  mysql->options.charset_name,
-                  cs_dir_name);
-    }
+  if (mysql_init_character_set(mysql))
     goto error;
-  }
-
 
   /* Save connection information */
   if (!my_multi_malloc(MYF(0),

--- 1.125/libmysqld/lib_sql.cc	Wed Sep 28 00:35:58 2005
+++ 1.126/libmysqld/lib_sql.cc	Mon Jun 19 22:10:15 2006
@@ -41,6 +41,8 @@
 int check_user(THD *thd, enum enum_server_command command, 
 	       const char *passwd, uint passwd_len, const char *db,
 	       bool check_count);
+void thd_init_client_charset(THD *thd, uint cs_number);
+
 C_MODE_START
 #include <mysql.h>
 #undef ER
@@ -532,10 +534,13 @@
   return NULL;
 }
 
+
 #ifdef NO_EMBEDDED_ACCESS_CHECKS
 int check_embedded_connection(MYSQL *mysql)
 {
   THD *thd= (THD*)mysql->thd;
+  thd_init_client_charset(thd, mysql->charset->number);
+  thd->update_charset();
   thd->host= (char*)my_localhost;
   thd->host_or_ip= thd->host;
   thd->user= my_strdup(mysql->user, MYF(0));
@@ -551,6 +556,8 @@
   char scramble_buff[SCRAMBLE_LENGTH];
   int passwd_len;
 
+  thd_init_client_charset(thd, mysql->charset->number);
+  thd->update_charset();
   if (mysql->options.client_ip)
   {
     thd->host= my_strdup(mysql->options.client_ip, MYF(0));

--- 1.65/libmysqld/libmysqld.c	Thu Aug  4 13:28:51 2005
+++ 1.66/libmysqld/libmysqld.c	Mon Jun 19 22:10:15 2006
@@ -85,49 +85,7 @@
 }
 
 
-static int mysql_init_charset(MYSQL *mysql)
-{
-  char charset_name_buff[16], *charset_name;
-
-  if ((charset_name=mysql->options.charset_name))
-  {
-    const char *save=charsets_dir;
-    if (mysql->options.charset_dir)
-      charsets_dir=mysql->options.charset_dir;
-    mysql->charset=get_charset_by_name(mysql->options.charset_name,
-                                       MYF(MY_WME));
-    charsets_dir=save;
-  }
-  else if (mysql->server_language)
-  {
-    charset_name=charset_name_buff;
-    sprintf(charset_name,"%d",mysql->server_language);	/* In case of errors */
-    mysql->charset=get_charset((uint8) mysql->server_language, MYF(MY_WME));
-  }
-  else
-    mysql->charset=default_charset_info;
-
-  if (!mysql->charset)
-  {
-    mysql->net.last_errno=CR_CANT_READ_CHARSET;
-    strmov(mysql->net.sqlstate, "HY0000");
-    if (mysql->options.charset_dir)
-      sprintf(mysql->net.last_error,ER(mysql->net.last_errno),
-              charset_name ? charset_name : "unknown",
-              mysql->options.charset_dir);
-    else
-    {
-      char cs_dir_name[FN_REFLEN];
-      get_charsets_dir(cs_dir_name);
-      sprintf(mysql->net.last_error,ER(mysql->net.last_errno),
-              charset_name ? charset_name : "unknown",
-              cs_dir_name);
-    }
-    return mysql->net.last_errno;
-  }
-  return 0;
-}
-
+int mysql_init_character_set(MYSQL *mysql);
 
 MYSQL * STDCALL
 mysql_real_connect(MYSQL *mysql,const char *host, const char *user,
@@ -203,10 +161,10 @@
 
   init_embedded_mysql(mysql, client_flag, db_name);
 
-  if (check_embedded_connection(mysql))
+  if (mysql_init_character_set(mysql))
     goto error;
 
-  if (mysql_init_charset(mysql))
+  if (check_embedded_connection(mysql))
     goto error;
 
   /* Send client information for access check */
Thread
bk commit into 4.1 tree (holyfoot:1.2498) BUG#20318holyfoot19 Jun