diff options
author | unknown <svoj@mysql.com/june.mysql.com> | 2007-10-24 16:09:30 +0500 |
---|---|---|
committer | unknown <svoj@mysql.com/june.mysql.com> | 2007-10-24 16:09:30 +0500 |
commit | 660d66263ba1e9c5ec197cc29ddc425b200b58ca (patch) | |
tree | ead3e129281c65f52e3d4f313afe9583ab920b1b /mysys/charset.c | |
parent | d244374f2bfc11ff26058e3110941c9cc799488b (diff) | |
download | mariadb-git-660d66263ba1e9c5ec197cc29ddc425b200b58ca.tar.gz |
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.
include/my_sys.h:
Added a function to find compatible character set with ctype array
available. Currently used by fulltext search to find compatible
substitute for ucs2 collations.
mysql-test/r/ctype_ucs.result:
A test case for BUG#31159.
mysql-test/t/ctype_ucs.test:
A test case for BUG#31159.
mysys/charset.c:
Added a function to find compatible character set with ctype array
available. Currently used by fulltext search to find compatible
substitute for ucs2 collations.
sql/item_func.cc:
Convert ucs2 fields to utf8. Fulltext requires ctype array, but
ucs2 doesn't provide it.
Diffstat (limited to 'mysys/charset.c')
-rw-r--r-- | mysys/charset.c | 40 |
1 files changed, 40 insertions, 0 deletions
diff --git a/mysys/charset.c b/mysys/charset.c index 6f2d4d3c347..f0ac61ceed5 100644 --- a/mysys/charset.c +++ b/mysys/charset.c @@ -673,3 +673,43 @@ CHARSET_INFO *fs_character_set() return fs_cset_cache; } #endif + + +/** + @brief Find compatible character set with ctype. + + @param[in] original_cs Original character set + + @note + 128 my_charset_ucs2_general_uca ->192 my_charset_utf8_general_uca_ci + 129 my_charset_ucs2_icelandic_uca_ci ->193 my_charset_utf8_icelandic_uca_ci + 130 my_charset_ucs2_latvian_uca_ci ->194 my_charset_utf8_latvian_uca_ci + 131 my_charset_ucs2_romanian_uca_ci ->195 my_charset_utf8_romanian_uca_ci + 132 my_charset_ucs2_slovenian_uca_ci ->196 my_charset_utf8_slovenian_uca_ci + 133 my_charset_ucs2_polish_uca_ci ->197 my_charset_utf8_polish_uca_ci + 134 my_charset_ucs2_estonian_uca_ci ->198 my_charset_utf8_estonian_uca_ci + 135 my_charset_ucs2_spanish_uca_ci ->199 my_charset_utf8_spanish_uca_ci + 136 my_charset_ucs2_swedish_uca_ci ->200 my_charset_utf8_swedish_uca_ci + 137 my_charset_ucs2_turkish_uca_ci ->201 my_charset_utf8_turkish_uca_ci + 138 my_charset_ucs2_czech_uca_ci ->202 my_charset_utf8_czech_uca_ci + 139 my_charset_ucs2_danish_uca_ci ->203 my_charset_utf8_danish_uca_ci + 140 my_charset_ucs2_lithuanian_uca_ci->204 my_charset_utf8_lithuanian_uca_ci + 141 my_charset_ucs2_slovak_uca_ci ->205 my_charset_utf8_slovak_uca_ci + 142 my_charset_ucs2_spanish2_uca_ci ->206 my_charset_utf8_spanish2_uca_ci + 143 my_charset_ucs2_roman_uca_ci ->207 my_charset_utf8_roman_uca_ci + 144 my_charset_ucs2_persian_uca_ci ->208 my_charset_utf8_persian_uca_ci + + @return Compatible character set or NULL. +*/ + +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))) && + (!compatible_cs->ctype || + strcmp(original_cs->name + 4, compatible_cs->name + 4))) + compatible_cs= 0; + DBUG_RETURN(compatible_cs); +} |