From 714cf5688b71f7a14a9412a8c5d9155e5394b3e7 Mon Sep 17 00:00:00 2001 From: "svoj@april.(none)" <> Date: Thu, 26 Jan 2006 15:12:59 +0400 Subject: [PATCH 1/4] BUG#16722 - Fulltext: implicit limit for query word number (depends on length of the query) Remove implicit limit for query word number. --- mysql-test/r/fulltext.result | 10 ++++----- storage/myisam/ft_boolean_search.c | 33 ++++++++++++++++++------------ 2 files changed, 25 insertions(+), 18 deletions(-) diff --git a/mysql-test/r/fulltext.result b/mysql-test/r/fulltext.result index af09b2ef866..4ee95cffb00 100644 --- a/mysql-test/r/fulltext.result +++ b/mysql-test/r/fulltext.result @@ -182,13 +182,13 @@ create table t1 (a varchar(200) not null, fulltext (a)); insert t1 values ("aaa10 bbb20"), ("aaa20 bbb15"), ("aaa30 bbb10"); select * from t1 where match a against ("+aaa* +bbb*" in boolean mode); a -aaa10 bbb20 -aaa20 bbb15 aaa30 bbb10 +aaa20 bbb15 +aaa10 bbb20 select * from t1 where match a against ("+aaa* +bbb1*" in boolean mode); a -aaa20 bbb15 aaa30 bbb10 +aaa20 bbb15 select * from t1 where match a against ("+aaa* +ccc*" in boolean mode); a select * from t1 where match a against ("+aaa10 +(bbb*)" in boolean mode); @@ -196,12 +196,12 @@ a aaa10 bbb20 select * from t1 where match a against ("+(+aaa* +bbb1*)" in boolean mode); a -aaa20 bbb15 aaa30 bbb10 +aaa20 bbb15 select * from t1 where match a against ("(+aaa* +bbb1*)" in boolean mode); a -aaa20 bbb15 aaa30 bbb10 +aaa20 bbb15 drop table t1; CREATE TABLE t1 ( id int(11), diff --git a/storage/myisam/ft_boolean_search.c b/storage/myisam/ft_boolean_search.c index fbd8e03f75c..ea179df0c56 100644 --- a/storage/myisam/ft_boolean_search.c +++ b/storage/myisam/ft_boolean_search.c @@ -107,6 +107,7 @@ typedef struct st_ftb_word my_off_t key_root; my_off_t *max_docid; MI_KEYDEF *keyinfo; + struct st_ftb_word *prev; float weight; uint ndepth; uint len; @@ -121,6 +122,7 @@ typedef struct st_ft_info CHARSET_INFO *charset; FTB_EXPR *root; FTB_WORD **list; + FTB_WORD *last_word; MEM_ROOT mem_root; QUEUE queue; TREE no_dupes; @@ -199,7 +201,9 @@ static int ftb_query_add_word(void *param, byte *word, uint word_len, memcpy(ftbw->word + 1, word, word_len); ftbw->word[0]= word_len; if (info->yesno > 0) ftbw->up->ythresh++; - queue_insert(&ftb_param->ftb->queue, (byte *)ftbw); + ftb_param->ftb->queue.max_elements++; + ftbw->prev= ftb_param->ftb->last_word; + ftb_param->ftb->last_word= ftbw; ftb_param->ftb->with_scan|= (info->trunc & FTB_FLAG_TRUNC); for (tmp_expr= ftb_param->ftbe; tmp_expr->up; tmp_expr= tmp_expr->up) if (! (tmp_expr->flags & FTB_FLAG_YES)) @@ -505,7 +509,7 @@ FT_INFO * ft_init_boolean_search(MI_INFO *info, uint keynr, byte *query, { FTB *ftb; FTB_EXPR *ftbe; - uint res; + FTB_WORD *ftbw; if (!(ftb=(FTB *)my_malloc(sizeof(FTB), MYF(MY_WME)))) return 0; @@ -518,19 +522,10 @@ FT_INFO * ft_init_boolean_search(MI_INFO *info, uint keynr, byte *query, ftb->with_scan=0; ftb->lastpos=HA_OFFSET_ERROR; bzero(& ftb->no_dupes, sizeof(TREE)); + ftb->last_word= 0; init_alloc_root(&ftb->mem_root, 1024, 1024); - - /* - Hack: instead of init_queue, we'll use reinit queue to be able - to alloc queue with alloc_root() - */ - res=ftb->queue.max_elements=1+query_len/2; - if (!(ftb->queue.root= - (byte **)alloc_root(&ftb->mem_root, (res+1)*sizeof(void*)))) - goto err; - reinit_queue(& ftb->queue, res, 0, 0, - (int (*)(void*,byte*,byte*))FTB_WORD_cmp, 0); + ftb->queue.max_elements= 0; if (!(ftbe=(FTB_EXPR *)alloc_root(&ftb->mem_root, sizeof(FTB_EXPR)))) goto err; ftbe->weight=1; @@ -545,6 +540,18 @@ FT_INFO * ft_init_boolean_search(MI_INFO *info, uint keynr, byte *query, _ftb_parse_query(ftb, query, query_len, keynr == NO_SUCH_KEY ? &ft_default_parser : info->s->keyinfo[keynr].parser); + /* + Hack: instead of init_queue, we'll use reinit queue to be able + to alloc queue with alloc_root() + */ + if (! (ftb->queue.root= (byte **)alloc_root(&ftb->mem_root, + (ftb->queue.max_elements + 1) * + sizeof(void *)))) + goto err; + reinit_queue(&ftb->queue, ftb->queue.max_elements, 0, 0, + (int (*)(void*, byte*, byte*))FTB_WORD_cmp, 0); + for (ftbw= ftb->last_word; ftbw; ftbw= ftbw->prev) + queue_insert(&ftb->queue, (byte *)ftbw); ftb->list=(FTB_WORD **)alloc_root(&ftb->mem_root, sizeof(FTB_WORD *)*ftb->queue.elements); memcpy(ftb->list, ftb->queue.root+1, sizeof(FTB_WORD *)*ftb->queue.elements); From 01ef1d13f854157b7912e4f1bf8d945e7af49776 Mon Sep 17 00:00:00 2001 From: "serg@serg.mylan" <> Date: Mon, 30 Jan 2006 11:25:47 +0100 Subject: [PATCH 2/4] __attribute__ is (of course) not portable --- plugin/fulltext/plugin_example.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/plugin/fulltext/plugin_example.c b/plugin/fulltext/plugin_example.c index 84dc58e99a6..4ab8bc237af 100644 --- a/plugin/fulltext/plugin_example.c +++ b/plugin/fulltext/plugin_example.c @@ -97,8 +97,7 @@ static int simple_parser_plugin_deinit(void) 1 failure (cannot happen) */ -static int simple_parser_init(MYSQL_FTPARSER_PARAM *param - __attribute__((unused))) +static int simple_parser_init(MYSQL_FTPARSER_PARAM *param) { return(0); } From 6f9f3221eadfd536134747fb83842faa19bb0c50 Mon Sep 17 00:00:00 2001 From: "knielsen@mysql.com" <> Date: Mon, 30 Jan 2006 12:42:27 +0100 Subject: [PATCH 3/4] Fix another non-portable __attribute__ --- plugin/fulltext/plugin_example.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/plugin/fulltext/plugin_example.c b/plugin/fulltext/plugin_example.c index 4ab8bc237af..11b0822f3f8 100644 --- a/plugin/fulltext/plugin_example.c +++ b/plugin/fulltext/plugin_example.c @@ -117,8 +117,7 @@ static int simple_parser_init(MYSQL_FTPARSER_PARAM *param) 1 failure (cannot happen) */ -static int simple_parser_deinit(MYSQL_FTPARSER_PARAM *param - __attribute__((unused))) +static int simple_parser_deinit(MYSQL_FTPARSER_PARAM *param) { return(0); } From 81e0de3ebf6dbe6d887d4fab84567b65371c96af Mon Sep 17 00:00:00 2001 From: "mats@mysql.com" <> Date: Mon, 30 Jan 2006 15:16:49 +0100 Subject: [PATCH 4/4] Fixing minor problem causing the rpl_row_basic_11bugs test to fail when executed using the Perl version of mysql-test-run. --- mysql-test/t/rpl_row_basic_11bugs-master.opt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mysql-test/t/rpl_row_basic_11bugs-master.opt b/mysql-test/t/rpl_row_basic_11bugs-master.opt index d5ae999b180..ad03cdaa6d1 100644 --- a/mysql-test/t/rpl_row_basic_11bugs-master.opt +++ b/mysql-test/t/rpl_row_basic_11bugs-master.opt @@ -1 +1 @@ ---binlog_ignore_db=test_ignore; +--binlog_ignore_db=test_ignore