summaryrefslogtreecommitdiff
path: root/sql/log_event.cc
diff options
context:
space:
mode:
authormats@mysql.com <>2006-03-21 14:35:49 +0100
committermats@mysql.com <>2006-03-21 14:35:49 +0100
commit1d4ee057ee6d0e1e0c71adaccdcd8b4d58842e46 (patch)
treea303ad6570ce2e7f70c098ba3441aef72e5ee8c8 /sql/log_event.cc
parentc5337540af078722ca006287fb9e0d55e70dd845 (diff)
downloadmariadb-git-1d4ee057ee6d0e1e0c71adaccdcd8b4d58842e46.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.
Diffstat (limited to 'sql/log_event.cc')
-rw-r--r--sql/log_event.cc31
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.
*/