summaryrefslogtreecommitdiff
path: root/mysys/charset.c
diff options
context:
space:
mode:
authorelliot@mysql.com <>2005-08-17 04:26:32 -0400
committerelliot@mysql.com <>2005-08-17 04:26:32 -0400
commit197782605f836ccb038c93b98548297e0cc20655 (patch)
treeb76748cc6afbe1d56a804e77de0da089c9098565 /mysys/charset.c
parent3b64651683a6f8d9276fd49843832f672312f880 (diff)
downloadmariadb-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 'mysys/charset.c')
-rw-r--r--mysys/charset.c18
1 files changed, 18 insertions, 0 deletions
diff --git a/mysys/charset.c b/mysys/charset.c
index 3a39fce9437..df3f1cfa279 100644
--- a/mysys/charset.c
+++ b/mysys/charset.c
@@ -663,3 +663,21 @@ CHARSET_INFO *fs_character_set()
return fs_cset_cache;
}
#endif
+
+/*
+ Transforms a string into hex form.
+ */
+char *bare_str_to_hex(char *to, const char *from, uint len)
+{
+ char *p= to;
+ uint i;
+ for (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;
+ return p; // pointer to end 0 of 'to'
+}