diff options
author | unknown <mats@mysql.com> | 2006-03-21 14:35:49 +0100 |
---|---|---|
committer | unknown <mats@mysql.com> | 2006-03-21 14:35:49 +0100 |
commit | 83ba974a3de1528c7a4749546c1690b66baf4bf3 (patch) | |
tree | a303ad6570ce2e7f70c098ba3441aef72e5ee8c8 /sql/log_event.cc | |
parent | aa3411f54b2d5e2b6069b122085926f771133437 (diff) | |
download | mariadb-git-83ba974a3de1528c7a4749546c1690b66baf4bf3.tar.gz |
BUG#18293 (Values in stored procedures written to binlog unescaped):
Generating character set-independent quoting of strings for the
binary log when executing statements from inside stored procedure.
mysql-test/r/ctype_cp932_binlog.result:
Result change
mysql-test/t/ctype_cp932_binlog.test:
Adding check that string literals are written correctly for multi-byte
character sets.
sql/item.cc:
Cutting out character set-independent string escaping code and putting it
in a separate function.
sql/log_event.cc:
Adding characters set-independent code to separate function.
sql/mysql_priv.h:
Adding new function.
sql/sp_head.cc:
Escaping string value representing a string item.
Diffstat (limited to 'sql/log_event.cc')
-rw-r--r-- | sql/log_event.cc | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/sql/log_event.cc b/sql/log_event.cc index 5ca7c00ee8f..266d6b064bd 100644 --- a/sql/log_event.cc +++ b/sql/log_event.cc @@ -240,6 +240,37 @@ char *str_to_hex(char *to, const char *from, uint len) } /* + 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. */ |