Hi!
On Oct 19, Sergey Vojtovich wrote:
> ChangeSet@stripped, 2007-10-19 14:24:59+05:00, svoj@stripped +5 -0
> BUG#31159 - fulltext search on ucs2 column crashes server
>
> ucs2 doesn't provide required by fulltext ctype array. Crash
> happens because fulltext attempts to use unitialized ctype
> array.
>
> Fixed by converting ucs2 fields to compatible utf8 analogue.
>
> sql/item_func.cc@stripped, 2007-10-19 14:24:59+05:00, svoj@stripped +24 -1
> Convert ucs2 fields to utf8. Fulltext requires ctype array, but
> ucs2 doesn't provide it.
>
> diff -Nrup a/mysys/charset.c b/mysys/charset.c
> --- a/mysys/charset.c 2006-09-15 08:05:03 +05:00
> +++ b/mysys/charset.c 2007-10-19 14:24:59 +05:00
> +
> +CHARSET_INFO *get_compatible_charset_with_ctype(CHARSET_INFO *original_cs)
> +{
> + CHARSET_INFO *compatible_cs= 0;
> + DBUG_ENTER("get_compatible_charset_with_ctype");
> + if (!strcmp(original_cs->csname, "ucs2") &&
> + (compatible_cs= get_charset(original_cs->number + 64, MYF(0))) &&
> + strcmp(original_cs->name + 4, compatible_cs->name + 4))
as you call the function get_compatible_charset_*with_ctype*, add a
check here to ensure that compatible_cs->collation.collation->ctype != 0
> + compatible_cs= 0;
> + DBUG_RETURN(compatible_cs);
> +}
> diff -Nrup a/sql/item_func.cc b/sql/item_func.cc
> --- a/sql/item_func.cc 2007-06-13 16:32:58 +05:00
> +++ b/sql/item_func.cc 2007-10-19 14:24:59 +05:00
> @@ -3135,13 +3135,36 @@ bool Item_func_match::fix_fields(THD *th
> my_error(ER_WRONG_ARGUMENTS,MYF(0),"MATCH");
> return 1;
> }
> - table= ((Item_field *)item)->field->table;
> + table= ((Item_field *)item)->field ? ((Item_field *)item)->field->table
> :
> + ((Item_field *)((Item_func_conv
> *)item)->key_item())->field->table;
What is this ?
> 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);
hmm, when you aggregate ucs2 and utf8, does utf8 win ?
> + 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);
> }
>
Regards / Mit vielen Grüssen,
Sergei
--
__ ___ ___ ____ __
/ |/ /_ __/ __/ __ \/ / Sergei Golubchik <serg@stripped>
/ /|_/ / // /\ \/ /_/ / /__ Principal Software Developer
/_/ /_/\_, /___/\___\_\___/ MySQL GmbH, Dachauer Str. 37, D-80335 München
<___/ Geschäftsführer: Kaj Arnö - HRB
München 162140