From dbb643d64e0981f56b6c7b35586f430b08091834 Mon Sep 17 00:00:00 2001 From: Georgi Kodinov Date: Wed, 14 Jul 2010 14:54:51 +0300 Subject: Bug #51876: crash/memory underrun when loading data with ucs2 and reverse() function 3 problems fixed : 1. The reported problem : caused by incorrect parsing of the file as ucs data resulting in wrong length of the parsed string. Fixed by truncating the invalid trailing bytes (non-complete multibyte characters) when reading from the file 2. LOAD DATA when reading from a proper UCS2 file wasn't recognizing the new line characters. Fixed by first looking if a byte is a new line (or any other special) character before reading it as a part of a multibyte character. 3. When using user variables to hold the column data in LOAD DATA the character set of the user variable was set incorrectly to the database charset. Fixed by setting it to the charset specified by LOAD DATA (if any). --- sql/item_func.cc | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'sql/item_func.cc') diff --git a/sql/item_func.cc b/sql/item_func.cc index 1e31755179b..1bec4700bff 100644 --- a/sql/item_func.cc +++ b/sql/item_func.cc @@ -4715,6 +4715,7 @@ bool Item_func_get_user_var::set_value(THD *thd, bool Item_user_var_as_out_param::fix_fields(THD *thd, Item **ref) { DBUG_ASSERT(fixed == 0); + DBUG_ASSERT(thd->lex->exchange); if (Item::fix_fields(thd, ref) || !(entry= get_variable(&thd->user_vars, name, 1))) return TRUE; @@ -4724,7 +4725,9 @@ bool Item_user_var_as_out_param::fix_fields(THD *thd, Item **ref) of fields in LOAD DATA INFILE. (Since Item_user_var_as_out_param is used only there). */ - entry->collation.set(thd->variables.collation_database); + entry->collation.set(thd->lex->exchange->cs ? + thd->lex->exchange->cs : + thd->variables.collation_database); entry->update_query_id= thd->query_id; return FALSE; } -- cgit v1.2.1