From f827ef9ed44f21b4d56dad2aa40d6aec60a995a7 Mon Sep 17 00:00:00 2001 From: Alexander Barkov Date: Thu, 19 Aug 2010 10:00:43 +0400 Subject: [PATCH] Backporting Bug#32391 Character sets: crash with --character-set-server from mysql-trunk-bugfixing (5.6.1-m5) from mysql-5.5-bugfixing (5.5.6-m3). --- mysql-test/r/ctype_utf16_def.result | 9 +++++++++ mysql-test/t/ctype_utf16_def-master.opt | 1 + mysql-test/t/ctype_utf16_def.test | 8 ++++++++ storage/myisam/ft_stopwords.c | 16 ++++++++++++++-- 4 files changed, 32 insertions(+), 2 deletions(-) create mode 100644 mysql-test/r/ctype_utf16_def.result create mode 100644 mysql-test/t/ctype_utf16_def-master.opt create mode 100644 mysql-test/t/ctype_utf16_def.test diff --git a/mysql-test/r/ctype_utf16_def.result b/mysql-test/r/ctype_utf16_def.result new file mode 100644 index 00000000000..6514734cb38 --- /dev/null +++ b/mysql-test/r/ctype_utf16_def.result @@ -0,0 +1,9 @@ +SHOW VARIABLES LIKE 'collation_server'; +Variable_name Value +collation_server utf16_general_ci +SHOW VARIABLES LIKE 'character_set_server'; +Variable_name Value +character_set_server utf16 +SHOW VARIABLES LIKE 'ft_stopword_file'; +Variable_name Value +ft_stopword_file (built-in) diff --git a/mysql-test/t/ctype_utf16_def-master.opt b/mysql-test/t/ctype_utf16_def-master.opt new file mode 100644 index 00000000000..55bb5d14bbd --- /dev/null +++ b/mysql-test/t/ctype_utf16_def-master.opt @@ -0,0 +1 @@ +--character-set-server=utf16,latin1 diff --git a/mysql-test/t/ctype_utf16_def.test b/mysql-test/t/ctype_utf16_def.test new file mode 100644 index 00000000000..d8ef4a4278b --- /dev/null +++ b/mysql-test/t/ctype_utf16_def.test @@ -0,0 +1,8 @@ +--source include/have_utf16.inc + +# +# Bug #32391 Character sets: crash with --character-set-server +# +SHOW VARIABLES LIKE 'collation_server'; +SHOW VARIABLES LIKE 'character_set_server'; +SHOW VARIABLES LIKE 'ft_stopword_file'; diff --git a/storage/myisam/ft_stopwords.c b/storage/myisam/ft_stopwords.c index 1467cc56759..e8d81cbbbb1 100644 --- a/storage/myisam/ft_stopwords.c +++ b/storage/myisam/ft_stopwords.c @@ -18,6 +18,10 @@ #include "ftdefs.h" #include "my_handler.h" + +static CHARSET_INFO *ft_stopword_cs= NULL; + + typedef struct st_ft_stopwords { const char * pos; @@ -29,7 +33,7 @@ static TREE *stopwords3=NULL; static int FT_STOPWORD_cmp(void* cmp_arg __attribute__((unused)), FT_STOPWORD *w1, FT_STOPWORD *w2) { - return ha_compare_text(default_charset_info, + return ha_compare_text(ft_stopword_cs, (uchar *)w1->pos,w1->len, (uchar *)w2->pos,w2->len,0,0); } @@ -59,6 +63,14 @@ int ft_init_stopwords() 0, (ft_stopword_file ? (tree_element_free)&FT_STOPWORD_free : 0), NULL); + /* + Stopword engine currently does not support tricky + character sets UCS2, UTF16, UTF32. + Use latin1 to compare stopwords in case of these character sets. + It's also fine to use latin1 with the built-in stopwords. + */ + ft_stopword_cs= default_charset_info->mbminlen == 1 ? + default_charset_info : &my_charset_latin1; } if (ft_stopword_file) @@ -80,7 +92,7 @@ int ft_init_stopwords() goto err0; len=my_read(fd, buffer, len, MYF(MY_WME)); end=start+len; - while (ft_simple_get_word(default_charset_info, &start, end, &w, TRUE)) + while (ft_simple_get_word(ft_stopword_cs, &start, end, &w, TRUE)) { if (ft_add_stopword(my_strndup((char*) w.pos, w.len, MYF(0)))) goto err1;