MySQL Lists are EOL. Please join:

List:Internals« Previous MessageNext Message »
From:Elliot Murphy Date:August 18 2005 6:46pm
Subject:bk commit into 4.1 tree (elliot:1.2386) BUG#11338
View as plain text  
Below is the list of changes that have just been committed into a local
4.1 repository of emurphy. When emurphy 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.2386 05/08/18 14:46:34 elliot@stripped +8 -0
  BUG#11338 (logging of prepared statement w/ blob type)
  Some rework based on review comments from Konstantin and Monty
  Will make it possible to merge with 5.0 now
  No functionality change, added partial test case.

  mysql-test/t/rpl_ps_cp932.test
    1.1 05/08/18 14:46:27 elliot@stripped +51 -0
    Partial test for bug#11338 (logging of prepared statement w/ blob type)

  mysql-test/t/rpl_ps_cp932-slave.opt
    1.1 05/08/18 14:46:27 elliot@stripped +2 -0
    Partial test for bug#11338 (logging of prepared statement w/ blob type)

  mysql-test/t/rpl_ps_cp932-master.opt
    1.1 05/08/18 14:46:27 elliot@stripped +2 -0
    Partial test for bug#11338 (logging of prepared statement w/ blob type)

  mysql-test/t/rpl_ps_cp932.test
    1.0 05/08/18 14:46:27 elliot@stripped +0 -0
    BitKeeper file /Users/emurphy/src/work/mysql-4.1-bug11338/mysql-test/t/rpl_ps_cp932.test

  mysql-test/t/rpl_ps_cp932-slave.opt
    1.0 05/08/18 14:46:27 elliot@stripped +0 -0
    BitKeeper file /Users/emurphy/src/work/mysql-4.1-bug11338/mysql-test/t/rpl_ps_cp932-slave.opt

  mysql-test/t/rpl_ps_cp932-master.opt
    1.0 05/08/18 14:46:27 elliot@stripped +0 -0
    BitKeeper file /Users/emurphy/src/work/mysql-4.1-bug11338/mysql-test/t/rpl_ps_cp932-master.opt

  mysql-test/r/rpl_ps_cp932.result
    1.1 05/08/18 14:46:26 elliot@stripped +27 -0
    Partial test for bug#11338 (logging of prepared statement w/ blob type)

  sql/sql_prepare.cc
    1.153 05/08/18 14:46:26 elliot@stripped +6 -4
    BUG#11338 (logging of prepared statement w/ blob type)
    Some rework based on review comments from Konstantin and Monty
    Will make it possible to merge with 5.0 now
    No functionality change.

  sql/log_event.cc
    1.184 05/08/18 14:46:26 elliot@stripped +18 -26
    BUG#11338 (logging of prepared statement w/ blob type)
    Some rework based on review comments from Konstantin and Monty
    Will make it possible to merge with 5.0 now
    No functionality change.

  sql/item.h
    1.191 05/08/18 14:46:26 elliot@stripped +2 -1
    BUG#11338 (logging of prepared statement w/ blob type)
    Some rework based on review comments from Konstantin and Monty
    Will make it possible to merge with 5.0 now
    No functionality change.

  mysql-test/r/rpl_ps_cp932.result
    1.0 05/08/18 14:46:26 elliot@stripped +0 -0
    BitKeeper file /Users/emurphy/src/work/mysql-4.1-bug11338/mysql-test/r/rpl_ps_cp932.result

  sql/item.cc
    1.217 05/08/18 14:46:25 elliot@stripped +6 -6
    BUG#11338 (logging of prepared statement w/ blob type)
    Some rework based on review comments from Konstantin and Monty
    Will make it possible to merge with 5.0 now
    No functionality change.

# 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:	elliot
# Host:	agony.local
# Root:	/Users/emurphy/src/work/mysql-4.1-bug11338

--- 1.216/sql/item.cc	2005-08-17 04:26:27 -04:00
+++ 1.217/sql/item.cc	2005-08-18 14:46:25 -04:00
@@ -1230,7 +1230,7 @@
       CHARSET_INFO *tocs= thd->variables.collation_connection;
       uint32 dummy_offset;
 
-      value.cs_info.character_set_client= fromcs;
+      value.cs_info.character_set_of_placeholder= fromcs;
       /*
         Setup source and destination character sets so that they
         are different only if conversion is necessary: this will
@@ -1443,7 +1443,7 @@
   and avoid one more memcpy/alloc between str and log string.
 */
 
-const String *Item_param::query_val_str(String* str, THD *thd) const
+const String *Item_param::query_val_str(String* str) const
 {
   switch (state) {
   case INT_VALUE:
@@ -1477,12 +1477,12 @@
     {
       char *buf, *ptr;
       str->length(0);
-      if (str->reserve(str_value.length()*2+3))
+      if (str->reserve(str_value.length()*2+4))
         break;
 
       buf= str->c_ptr_quick();
       ptr= buf;
-      if (thd->charset()->escape_with_backslash_is_dangerous)
+      if (value.cs_info.character_set_client->escape_with_backslash_is_dangerous)
       {
         ptr= strmov(ptr, "x\'");
         ptr= bare_str_to_hex(ptr, str_value.ptr(), str_value.length());
@@ -1523,10 +1523,10 @@
       here only if conversion is really necessary.
     */
     if (value.cs_info.final_character_set_of_str_value !=
-        value.cs_info.character_set_client)
+        value.cs_info.character_set_of_placeholder)
     {
       rc= thd->convert_string(&str_value,
-                              value.cs_info.character_set_client,
+                              value.cs_info.character_set_of_placeholder,
                               value.cs_info.final_character_set_of_str_value);
     }
     else

--- 1.190/sql/item.h	2005-08-17 04:32:25 -04:00
+++ 1.191/sql/item.h	2005-08-18 14:46:26 -04:00
@@ -532,6 +532,7 @@
     struct CONVERSION_INFO
     {
       CHARSET_INFO *character_set_client;
+      CHARSET_INFO *character_set_of_placeholder;
       /*
         This points at character set of connection if conversion
         to it is required (i. e. if placeholder typecode is not BLOB).
@@ -591,7 +592,7 @@
   */
   void (*set_param_func)(Item_param *param, uchar **pos, ulong len);
 
-  const String *query_val_str(String *str, THD *thd) const;
+  const String *query_val_str(String *str) const;
 
   bool convert_str_value(THD *thd);
 

--- 1.183/sql/log_event.cc	2005-07-19 12:24:59 -04:00
+++ 1.184/sql/log_event.cc	2005-08-18 14:46:26 -04:00
@@ -204,30 +204,6 @@
   return 0;
 }
 
-/*
-  Transforms a string into "" or its expression in 0x... form.
-*/
-static char *str_to_hex(char *to, char *from, uint len)
-{
-  char *p= to;
-  if (len)
-  {
-    p= strmov(p, "0x");
-    for (uint i= 0; i < len; i++, p+= 2)
-    {
-      /* val[i] is char. Casting to uchar helps greatly if val[i] < 0 */
-      uint tmp= (uint) (uchar) from[i];
-      p[0]= _dig_vec_upper[tmp >> 4];
-      p[1]= _dig_vec_upper[tmp & 15];
-    }
-    *p= 0;
-  }
-  else
-    p= strmov(p, "\"\"");
-  return p; // pointer to end 0 of 'to'
-}
-
-
 /**************************************************************************
 	Log_event methods
 **************************************************************************/
@@ -2317,7 +2293,14 @@
       else
       {
         char *p= strxmov(buf + val_offset, "_", cs->csname, " ", NullS);
-        p= str_to_hex(p, val, val_len);
+        if (val_len) 
+        {
+          p= strmov(p, "0x");
+          p= bare_str_to_hex(p, val, val_len);
+        }
+        else
+          p= strmov(p, "\"\"");
+
         p= strxmov(p, " COLLATE ", cs->name, NullS);
         event_len= p-buf;
       }
@@ -2466,7 +2449,16 @@
 
       if (!(hex_str= (char *)my_alloca(2*val_len+1+2))) // 2 hex digits / byte
         break; // no error, as we are 'void'
-      str_to_hex(hex_str, val, val_len);
+
+      if (val_len) 
+      {
+        char *p= hex_str;
+        p= strmov(p, "0x");
+        bare_str_to_hex(p, val, val_len);
+      }
+      else
+        strmov(hex_str, "\"\"");
+
       /*
         For proper behaviour when mysqlbinlog|mysql, we need to explicitely
         specify the variable's collation. It will however cause problems when
--- New file ---
+++ mysql-test/r/rpl_ps_cp932.result	05/08/18 14:46:26
stop slave;
drop table if exists t1,t2,t3,t4,t5,t6,t7,t8,t9;
reset master;
reset slave;
drop table if exists t1,t2,t3,t4,t5,t6,t7,t8,t9;
start slave;
drop table if exists t1;
set character_set_client=cp932;
create table t1(f1 blob);
prepare stmt1 from 'insert into t1 values (?)';
set @var1= x'8300';
execute stmt1 using @var1;
show binlog events;
Log_name	Pos	Event_type	Server_id	Orig_log_pos	Info
master-bin.000001	4	Start	1	4	Server ver: 4.1.15-debug-log, Binlog ver: 3
master-bin.000001	79	Query	1	79	use `test`; SET ONE_SHOT CHARACTER_SET_CLIENT=8,COLLATION_CONNECTION=8,COLLATION_DATABASE=95,COLLATION_SERVER=95
master-bin.000001	214	Query	1	214	use `test`; drop table if exists t1
master-bin.000001	272	Query	1	272	use `test`; SET ONE_SHOT CHARACTER_SET_CLIENT=95,COLLATION_CONNECTION=8,COLLATION_DATABASE=95,COLLATION_SERVER=95
master-bin.000001	408	Query	1	408	use `test`; create table t1(f1 blob)
master-bin.000001	467	Query	1	467	use `test`; SET ONE_SHOT CHARACTER_SET_CLIENT=95,COLLATION_CONNECTION=8,COLLATION_DATABASE=95,COLLATION_SERVER=95
master-bin.000001	603	User var	1	603	@`var1`=_binary 0x8300 COLLATE binary
master-bin.000001	642	Query	1	642	use `test`; insert into t1 values (@'var1')
select HEX(f1) from t1;
HEX(f1)
8300
drop table t1;
stop slave;

--- New file ---
+++ mysql-test/t/rpl_ps_cp932-master.opt	05/08/18 14:46:27
--character-set-server=cp932
--default-character-set=cp932

--- New file ---
+++ mysql-test/t/rpl_ps_cp932-slave.opt	05/08/18 14:46:27
--character-set-server=cp932
--default-character-set=cp932

--- New file ---
+++ mysql-test/t/rpl_ps_cp932.test	05/08/18 14:46:27
#
# Test prepared statement with 0x8300 sequence in parameter while
# running under cp932.
# Bug#11338 (logging of prepared statement w/ blob type)
# CSC#5631 (wrong binary data is written into binary log)
#
source include/master-slave.inc;

--disable_warnings
drop table if exists t1;
--enable_warnings

#set connection to cp932
set character_set_client=cp932;

create table t1(f1 blob);

prepare stmt1 from 'insert into t1 values (?)';

# Insert binary data into DB
set @var1= x'8300';
execute stmt1 using @var1;

# check what was written into binary log to see that hex encoding of
# parameter was used
# TODO: This doesn't actually test the code which was added for bug#11338
# because...if we use the SQL syntax for prepared statements, then PS are
# replicated differently that when a real PS is handled because variable names 
# are inserted into the binlog instead of values. 
# The real goal of this test is to check the code that
# was added to Item_param::query_val_str() in order to do hex encoding of
# PS parameters when the client character set is cp932.
show binlog events;

# Check that data made it to the slave correctly
save_master_pos;
connection slave;
sync_with_master;
select HEX(f1) from t1;

# And finally clean everything up.
connection master;

drop table t1;

save_master_pos;
connection slave;
sync_with_master;
stop slave;

# End of 4.1 tests


--- 1.152/sql/sql_prepare.cc	2005-08-17 04:26:27 -04:00
+++ 1.153/sql/sql_prepare.cc	2005-08-18 14:46:26 -04:00
@@ -528,7 +528,7 @@
   case MYSQL_TYPE_LONG_BLOB:
   case MYSQL_TYPE_BLOB:
     param->set_param_func= set_param_str;
-    param->value.cs_info.character_set_client= &my_charset_bin;
+    param->value.cs_info.character_set_of_placeholder= &my_charset_bin;
     param->value.cs_info.final_character_set_of_str_value= &my_charset_bin;
     param->item_type= Item::STRING_ITEM;
     param->item_result_type= STRING_RESULT;
@@ -544,7 +544,7 @@
       CHARSET_INFO *tocs= thd->variables.collation_connection;
       uint32 dummy_offset;
 
-      param->value.cs_info.character_set_client= fromcs;
+      param->value.cs_info.character_set_of_placeholder= fromcs;
 
       /*
         Setup source and destination character sets so that they
@@ -564,6 +564,8 @@
     }
   }
   param->param_type= (enum enum_field_types) param_type;
+  param->value.cs_info.character_set_client= 
+    thd->variables.character_set_client;
 }
 
 #ifndef EMBEDDED_LIBRARY
@@ -601,7 +603,7 @@
         param->set_param_func(param, &read_pos, data_end - read_pos);
       }
     }
-    res= param->query_val_str(&str, thd);
+    res= param->query_val_str(&str);
     if (param->convert_str_value(thd))
       DBUG_RETURN(1);                           /* out of memory */
 
@@ -749,7 +751,7 @@
                               client_param->buffer_length);
       }
     }
-    res= param->query_val_str(&str, thd);
+    res= param->query_val_str(&str);
     if (param->convert_str_value(thd))
       DBUG_RETURN(1);                           /* out of memory */
 
Thread
bk commit into 4.1 tree (elliot:1.2386) BUG#11338Elliot Murphy18 Aug