Loading libmysql/libmysql.c +2 −1 Original line number Diff line number Diff line Loading @@ -2816,6 +2816,7 @@ my_bool STDCALL mysql_stmt_attr_get(MYSQL_STMT *stmt, { switch (attr_type) { case STMT_ATTR_UPDATE_MAX_LENGTH: *(my_bool*) value= stmt->update_max_length; break; case STMT_ATTR_CURSOR_TYPE: *(ulong*) value= stmt->flags; Loading mysql-test/r/ctype_cp932_binlog_stm.result +29 −0 Original line number Diff line number Diff line Loading @@ -15,3 +15,32 @@ SELECT HEX(f1) FROM t1; HEX(f1) 8300 DROP table t1; CREATE TABLE t4 (s1 CHAR(50) CHARACTER SET latin1, s2 CHAR(50) CHARACTER SET cp932, d DECIMAL(10,2))| CREATE PROCEDURE bug18293 (IN ins1 CHAR(50), IN ins2 CHAR(50) CHARACTER SET cp932, IN ind DECIMAL(10,2)) BEGIN INSERT INTO t4 VALUES (ins1, ins2, ind); END| CALL bug18293("Foo's a Bar", _cp932 0xED40ED41ED42, 47.93)| SELECT HEX(s1),HEX(s2),d FROM t4| HEX(s1) HEX(s2) d 466F6F2773206120426172 ED40ED41ED42 47.93 DROP PROCEDURE bug18293| DROP TABLE t4| SHOW BINLOG EVENTS FROM 397| Log_name Pos Event_type Server_id End_log_pos Info master-bin.000001 397 Query 1 560 use `test`; CREATE TABLE t4 (s1 CHAR(50) CHARACTER SET latin1, s2 CHAR(50) CHARACTER SET cp932, d DECIMAL(10,2)) master-bin.000001 560 Query 1 805 use `test`; CREATE DEFINER=`root`@`localhost` PROCEDURE bug18293 (IN ins1 CHAR(50), IN ins2 CHAR(50) CHARACTER SET cp932, IN ind DECIMAL(10,2)) BEGIN INSERT INTO t4 VALUES (ins1, ins2, ind); END master-bin.000001 805 Query 1 1010 use `test`; INSERT INTO t4 VALUES ( NAME_CONST('ins1',_latin1'Foo\'s a Bar'), NAME_CONST('ins2',_cp932 0xED40ED41ED42), NAME_CONST('ind',47.93)) master-bin.000001 1010 Query 1 1096 use `test`; DROP PROCEDURE bug18293 master-bin.000001 1096 Query 1 1172 use `test`; DROP TABLE t4 mysql-test/t/ctype_cp932_binlog_stm.test +24 −0 Original line number Diff line number Diff line Loading @@ -3,3 +3,27 @@ -- source include/have_binlog_format_statement.inc -- source extra/binlog_tests/ctype_cp932_binlog.test # # Bug#18293: Values in stored procedure written to binlog unescaped # delimiter |; CREATE TABLE t4 (s1 CHAR(50) CHARACTER SET latin1, s2 CHAR(50) CHARACTER SET cp932, d DECIMAL(10,2))| CREATE PROCEDURE bug18293 (IN ins1 CHAR(50), IN ins2 CHAR(50) CHARACTER SET cp932, IN ind DECIMAL(10,2)) BEGIN INSERT INTO t4 VALUES (ins1, ins2, ind); END| CALL bug18293("Foo's a Bar", _cp932 0xED40ED41ED42, 47.93)| SELECT HEX(s1),HEX(s2),d FROM t4| DROP PROCEDURE bug18293| DROP TABLE t4| SHOW BINLOG EVENTS FROM 397| delimiter ;| # End of 5.0 tests sql/item.cc +1 −18 Original line number Diff line number Diff line Loading @@ -2646,25 +2646,8 @@ const String *Item_param::query_val_str(String* str) const case STRING_VALUE: case LONG_DATA_VALUE: { char *buf, *ptr; str->length(0); if (str->reserve(str_value.length()*2+3)) break; buf= str->c_ptr_quick(); ptr= buf; if (value.cs_info.character_set_client->escape_with_backslash_is_dangerous) { ptr= str_to_hex(ptr, str_value.ptr(), str_value.length()); } else { *ptr++= '\''; ptr+= escape_string_for_mysql(str_value.charset(), ptr, 0, str_value.ptr(), str_value.length()); *ptr++='\''; } str->length((uint32) (ptr - buf)); append_query_string(value.cs_info.character_set_client, &str_value, str); break; } case NULL_VALUE: Loading sql/log_event.cc +31 −0 Original line number Diff line number Diff line Loading @@ -256,6 +256,37 @@ char *str_to_hex(char *to, const char *from, uint len) return to; // pointer to end 0 of 'to' } /* Append a version of the 'from' string suitable for use in a query to the 'to' string. To generate a correct escaping, the character set information in 'csinfo' is used. */ #ifndef MYSQL_CLIENT int append_query_string(CHARSET_INFO *csinfo, String const *from, String *to) { char *beg, *ptr; uint32 const orig_len= to->length(); if (to->reserve(orig_len + from->length()*2+3)) return 1; beg= to->c_ptr_quick() + to->length(); ptr= beg; if (csinfo->escape_with_backslash_is_dangerous) ptr= str_to_hex(ptr, from->ptr(), from->length()); else { *ptr++= '\''; ptr+= escape_string_for_mysql(from->charset(), ptr, 0, from->ptr(), from->length()); *ptr++='\''; } to->length(orig_len + ptr - beg); return 0; } #endif /* Prints a "session_var=value" string. Used by mysqlbinlog to print some SET commands just before it prints a query. Loading Loading
libmysql/libmysql.c +2 −1 Original line number Diff line number Diff line Loading @@ -2816,6 +2816,7 @@ my_bool STDCALL mysql_stmt_attr_get(MYSQL_STMT *stmt, { switch (attr_type) { case STMT_ATTR_UPDATE_MAX_LENGTH: *(my_bool*) value= stmt->update_max_length; break; case STMT_ATTR_CURSOR_TYPE: *(ulong*) value= stmt->flags; Loading
mysql-test/r/ctype_cp932_binlog_stm.result +29 −0 Original line number Diff line number Diff line Loading @@ -15,3 +15,32 @@ SELECT HEX(f1) FROM t1; HEX(f1) 8300 DROP table t1; CREATE TABLE t4 (s1 CHAR(50) CHARACTER SET latin1, s2 CHAR(50) CHARACTER SET cp932, d DECIMAL(10,2))| CREATE PROCEDURE bug18293 (IN ins1 CHAR(50), IN ins2 CHAR(50) CHARACTER SET cp932, IN ind DECIMAL(10,2)) BEGIN INSERT INTO t4 VALUES (ins1, ins2, ind); END| CALL bug18293("Foo's a Bar", _cp932 0xED40ED41ED42, 47.93)| SELECT HEX(s1),HEX(s2),d FROM t4| HEX(s1) HEX(s2) d 466F6F2773206120426172 ED40ED41ED42 47.93 DROP PROCEDURE bug18293| DROP TABLE t4| SHOW BINLOG EVENTS FROM 397| Log_name Pos Event_type Server_id End_log_pos Info master-bin.000001 397 Query 1 560 use `test`; CREATE TABLE t4 (s1 CHAR(50) CHARACTER SET latin1, s2 CHAR(50) CHARACTER SET cp932, d DECIMAL(10,2)) master-bin.000001 560 Query 1 805 use `test`; CREATE DEFINER=`root`@`localhost` PROCEDURE bug18293 (IN ins1 CHAR(50), IN ins2 CHAR(50) CHARACTER SET cp932, IN ind DECIMAL(10,2)) BEGIN INSERT INTO t4 VALUES (ins1, ins2, ind); END master-bin.000001 805 Query 1 1010 use `test`; INSERT INTO t4 VALUES ( NAME_CONST('ins1',_latin1'Foo\'s a Bar'), NAME_CONST('ins2',_cp932 0xED40ED41ED42), NAME_CONST('ind',47.93)) master-bin.000001 1010 Query 1 1096 use `test`; DROP PROCEDURE bug18293 master-bin.000001 1096 Query 1 1172 use `test`; DROP TABLE t4
mysql-test/t/ctype_cp932_binlog_stm.test +24 −0 Original line number Diff line number Diff line Loading @@ -3,3 +3,27 @@ -- source include/have_binlog_format_statement.inc -- source extra/binlog_tests/ctype_cp932_binlog.test # # Bug#18293: Values in stored procedure written to binlog unescaped # delimiter |; CREATE TABLE t4 (s1 CHAR(50) CHARACTER SET latin1, s2 CHAR(50) CHARACTER SET cp932, d DECIMAL(10,2))| CREATE PROCEDURE bug18293 (IN ins1 CHAR(50), IN ins2 CHAR(50) CHARACTER SET cp932, IN ind DECIMAL(10,2)) BEGIN INSERT INTO t4 VALUES (ins1, ins2, ind); END| CALL bug18293("Foo's a Bar", _cp932 0xED40ED41ED42, 47.93)| SELECT HEX(s1),HEX(s2),d FROM t4| DROP PROCEDURE bug18293| DROP TABLE t4| SHOW BINLOG EVENTS FROM 397| delimiter ;| # End of 5.0 tests
sql/item.cc +1 −18 Original line number Diff line number Diff line Loading @@ -2646,25 +2646,8 @@ const String *Item_param::query_val_str(String* str) const case STRING_VALUE: case LONG_DATA_VALUE: { char *buf, *ptr; str->length(0); if (str->reserve(str_value.length()*2+3)) break; buf= str->c_ptr_quick(); ptr= buf; if (value.cs_info.character_set_client->escape_with_backslash_is_dangerous) { ptr= str_to_hex(ptr, str_value.ptr(), str_value.length()); } else { *ptr++= '\''; ptr+= escape_string_for_mysql(str_value.charset(), ptr, 0, str_value.ptr(), str_value.length()); *ptr++='\''; } str->length((uint32) (ptr - buf)); append_query_string(value.cs_info.character_set_client, &str_value, str); break; } case NULL_VALUE: Loading
sql/log_event.cc +31 −0 Original line number Diff line number Diff line Loading @@ -256,6 +256,37 @@ char *str_to_hex(char *to, const char *from, uint len) return to; // pointer to end 0 of 'to' } /* Append a version of the 'from' string suitable for use in a query to the 'to' string. To generate a correct escaping, the character set information in 'csinfo' is used. */ #ifndef MYSQL_CLIENT int append_query_string(CHARSET_INFO *csinfo, String const *from, String *to) { char *beg, *ptr; uint32 const orig_len= to->length(); if (to->reserve(orig_len + from->length()*2+3)) return 1; beg= to->c_ptr_quick() + to->length(); ptr= beg; if (csinfo->escape_with_backslash_is_dangerous) ptr= str_to_hex(ptr, from->ptr(), from->length()); else { *ptr++= '\''; ptr+= escape_string_for_mysql(from->charset(), ptr, 0, from->ptr(), from->length()); *ptr++='\''; } to->length(orig_len + ptr - beg); return 0; } #endif /* Prints a "session_var=value" string. Used by mysqlbinlog to print some SET commands just before it prints a query. Loading