From 212698b152609a7b17b45f9499fd650229985558 Mon Sep 17 00:00:00 2001 From: Alexander Barkov Date: Wed, 23 Sep 2015 13:04:28 +0400 Subject: MDEV-8253 EXPLAIN SELECT prints unexpected characters Item_string::clone_item() creates a new Item_string that points exactly to the same buffer that the original one does. Later, Item_string::print() uses c_ptr() for the original Item_string, which reallocs the original buffer, and the clone remain with the old freed buffer. Refactoring the code not to use c_ptr() in Item_string::print(). --- sql/sql_string.h | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) (limited to 'sql/sql_string.h') diff --git a/sql/sql_string.h b/sql/sql_string.h index 99fe6b60d37..51a11c7a4ff 100644 --- a/sql/sql_string.h +++ b/sql/sql_string.h @@ -568,7 +568,15 @@ public: str_length+= arg_length; return FALSE; } - void print(String *print) const; + void print(String *to) const; + void print_with_conversion(String *to, CHARSET_INFO *cs) const; + void print(String *to, CHARSET_INFO *cs) const + { + if (my_charset_same(charset(), cs)) + print(to); + else + print_with_conversion(to, cs); + } bool append_for_single_quote(const char *st, uint len); bool append_for_single_quote(const String *s) -- cgit v1.2.1