diff options
author | unknown <istruewing@stella.local> | 2007-10-31 12:31:36 +0100 |
---|---|---|
committer | unknown <istruewing@stella.local> | 2007-10-31 12:31:36 +0100 |
commit | c4f35d7c23dab8460b850dc31cf386512c0345ac (patch) | |
tree | 5d1b40f431fc140512303b69ff281c5dd01d97fb /sql | |
parent | fa0e1d6b6b9f93b7ad84f8ba490d0e2de5a4553d (diff) | |
parent | 0724eb88e2540cdbecb3c58a02dc79dba2358359 (diff) | |
download | mariadb-git-c4f35d7c23dab8460b850dc31cf386512c0345ac.tar.gz |
Merge stella.local:/home2/mydev/mysql-5.0-amain
into stella.local:/home2/mydev/mysql-5.0-axmrg
mysql-test/r/ctype_ucs.result:
Auto merged
mysql-test/t/ctype_ucs.test:
Auto merged
sql/item_func.cc:
Auto merged
Diffstat (limited to 'sql')
-rw-r--r-- | sql/item_func.cc | 33 |
1 files changed, 32 insertions, 1 deletions
diff --git a/sql/item_func.cc b/sql/item_func.cc index 22b0044242c..148cc77f4a9 100644 --- a/sql/item_func.cc +++ b/sql/item_func.cc @@ -4944,13 +4944,44 @@ bool Item_func_match::fix_fields(THD *thd, Item **ref) my_error(ER_WRONG_ARGUMENTS,MYF(0),"MATCH"); return TRUE; } - table=((Item_field *)item)->field->table; + /* + With prepared statements Item_func_match::fix_fields is called twice. + When it is called first time we have original item tree here and add + conversion layer for character sets that do not have ctype array a few + lines below. When it is called second time, we already have conversion + layer in item tree. + */ + table= (item->type() == Item::FIELD_ITEM) ? + ((Item_field *)item)->field->table : + ((Item_field *)((Item_func_conv *)item)->key_item())->field->table; if (!(table->file->table_flags() & HA_CAN_FULLTEXT)) { my_error(ER_TABLE_CANT_HANDLE_FT, MYF(0)); return 1; } table->fulltext_searched=1; + /* A workaround for ucs2 character set */ + if (!args[1]->collation.collation->ctype) + { + CHARSET_INFO *compatible_cs= + get_compatible_charset_with_ctype(args[1]->collation.collation); + bool rc= 1; + if (compatible_cs) + { + Item_string *conv_item= new Item_string("", 0, compatible_cs, + DERIVATION_EXPLICIT); + item= args[0]; + args[0]= conv_item; + rc= agg_item_charsets(cmp_collation, func_name(), args, arg_count, + MY_COLL_ALLOW_SUPERSET_CONV | + MY_COLL_ALLOW_COERCIBLE_CONV | + MY_COLL_DISALLOW_NONE, 1); + args[0]= item; + } + else + my_error(ER_WRONG_ARGUMENTS, MYF(0), "MATCH"); + return rc; + } return agg_arg_collations_for_comparison(cmp_collation, args+1, arg_count-1, 0); } |