diff options
author | elliot@mysql.com <> | 2005-08-17 04:26:32 -0400 |
---|---|---|
committer | elliot@mysql.com <> | 2005-08-17 04:26:32 -0400 |
commit | 197782605f836ccb038c93b98548297e0cc20655 (patch) | |
tree | b76748cc6afbe1d56a804e77de0da089c9098565 /sql/item.cc | |
parent | 3b64651683a6f8d9276fd49843832f672312f880 (diff) | |
download | mariadb-git-197782605f836ccb038c93b98548297e0cc20655.tar.gz |
BUG#11338 (logging of prepared statement w/ blob type)
In cp932, '\' character can be the second byte in a
multi-byte character stream. This makes it difficult to use
mysql_escape_string. Added flag to indicate which languages allow
'\' as second byte of multibyte sequence so that when putting a prepared
statement into the binlog we can decide at runtime whether hex encoding
is really needed.
Diffstat (limited to 'sql/item.cc')
-rw-r--r-- | sql/item.cc | 18 |
1 files changed, 13 insertions, 5 deletions
diff --git a/sql/item.cc b/sql/item.cc index b3d2932acf6..79579eeeb67 100644 --- a/sql/item.cc +++ b/sql/item.cc @@ -1443,7 +1443,7 @@ String *Item_param::val_str(String* str) and avoid one more memcpy/alloc between str and log string. */ -const String *Item_param::query_val_str(String* str) const +const String *Item_param::query_val_str(String* str, THD *thd) const { switch (state) { case INT_VALUE: @@ -1482,10 +1482,18 @@ const String *Item_param::query_val_str(String* str) const buf= str->c_ptr_quick(); ptr= buf; - *ptr++= '\''; - ptr+= escape_string_for_mysql(str_value.charset(), ptr, - str_value.ptr(), str_value.length()); - *ptr++= '\''; + if (thd->charset()->escape_with_backslash_is_dangerous) + { + ptr= strmov(ptr, "x\'"); + ptr= bare_str_to_hex(ptr, str_value.ptr(), str_value.length()); + } + else + { + *ptr++= '\''; + ptr+= escape_string_for_mysql(str_value.charset(), ptr, + str_value.ptr(), str_value.length()); + } + *ptr++='\''; str->length(ptr - buf); break; } |