diff options
author | unknown <konstantin@mysql.com> | 2004-09-23 18:01:55 +0400 |
---|---|---|
committer | unknown <konstantin@mysql.com> | 2004-09-23 18:01:55 +0400 |
commit | edcccfbc4b71152af849f53fc3760a05e1e0d4bb (patch) | |
tree | 2deae2cf9d86f0f0b7e370d20237a5287f1d7dbe /sql/item_cmpfunc.cc | |
parent | 3f76fd69a454176dde8264c1ac4e676e92e28fdf (diff) | |
download | mariadb-git-edcccfbc4b71152af849f53fc3760a05e1e0d4bb.tar.gz |
A fix and test case for bug#5688 "Upgraded 4.1.5 Server seg faults"
mysql-test/r/ps.result:
Test results fixed: the test case for bug#5688 "Upgraded 4.1.5 Server
seg faults"
mysql-test/t/ps.test:
Test case for bug#5688 "Upgraded 4.1.5 Server seg faults"
sql/item_cmpfunc.cc:
A fix for bug#5688 "Upgraded 4.1.5 Server seg faults":
fix just another place where we use wrong memory root for an Item
in statement prepare.
In addition, make the check for charsets in Item_bool_func2
more generic (fixes the test case when we use LIKE to compare BLOBs
with TEXT data).
Diffstat (limited to 'sql/item_cmpfunc.cc')
-rw-r--r-- | sql/item_cmpfunc.cc | 26 |
1 files changed, 14 insertions, 12 deletions
diff --git a/sql/item_cmpfunc.cc b/sql/item_cmpfunc.cc index 85b22d1eddd..8950ad0c594 100644 --- a/sql/item_cmpfunc.cc +++ b/sql/item_cmpfunc.cc @@ -188,17 +188,27 @@ void Item_bool_func2::fix_length_and_dec() { uint strong= 0; uint weak= 0; + uint32 dummy_offset; DTCollation coll; if (args[0]->result_type() == STRING_RESULT && args[1]->result_type() == STRING_RESULT && - !my_charset_same(args[0]->collation.collation, - args[1]->collation.collation) && + String::needs_conversion(0, args[0]->collation.collation, + args[1]->collation.collation, + &dummy_offset) && !coll.set(args[0]->collation, args[1]->collation, TRUE)) { Item* conv= 0; + THD *thd= current_thd; + Item_arena *arena= thd->current_arena, backup; strong= coll.strong; weak= strong ? 0 : 1; + /* + In case we're in statement prepare, create conversion item + in its memory: it will be reused on each execute. + */ + if (arena->is_stmt_prepare()) + thd->set_n_backup_item_arena(arena, &backup); if (args[weak]->type() == STRING_ITEM) { String tmp, cstr; @@ -211,21 +221,13 @@ void Item_bool_func2::fix_length_and_dec() } else { - THD *thd= current_thd; - /* - In case we're in statement prepare, create conversion item - in its memory: it will be reused on each execute. - */ - Item_arena *arena= thd->current_arena, backup; - if (arena->is_stmt_prepare()) - thd->set_n_backup_item_arena(arena, &backup); conv= new Item_func_conv_charset(args[weak], args[strong]->collation.collation); - if (arena->is_stmt_prepare()) - thd->restore_backup_item_arena(arena, &backup); conv->collation.set(args[weak]->collation.derivation); conv->fix_fields(thd, 0, &conv); } + if (arena->is_stmt_prepare()) + thd->restore_backup_item_arena(arena, &backup); args[weak]= conv ? conv : args[weak]; } } |