diff options
author | unknown <serg@sergbook.mysql.com> | 2002-09-17 21:09:39 +0200 |
---|---|---|
committer | unknown <serg@sergbook.mysql.com> | 2002-09-17 21:09:39 +0200 |
commit | 475f7300e9a49933004a679d7f09a02122663aa3 (patch) | |
tree | d03f52c7c5e28872ad97ca33c37001056289acdb | |
parent | afe8d4fc2416a08fba8cc10068af8a7467d674cc (diff) | |
parent | 5f6bd7ddb14d5508fc51d032d53454c05cb009aa (diff) | |
download | mariadb-git-475f7300e9a49933004a679d7f09a02122663aa3.tar.gz |
Merge
Docs/manual.texi:
SCCS merged
-rw-r--r-- | Docs/manual.texi | 3 | ||||
-rw-r--r-- | myisam/ft_boolean_search.c | 22 | ||||
-rw-r--r-- | mysql-test/r/fulltext_order_by.result | 15 | ||||
-rw-r--r-- | mysql-test/t/fulltext_order_by.test | 14 | ||||
-rw-r--r-- | mysys/queues.c | 6 |
5 files changed, 54 insertions, 6 deletions
diff --git a/Docs/manual.texi b/Docs/manual.texi index e1ab6664313..34090190b44 100644 --- a/Docs/manual.texi +++ b/Docs/manual.texi @@ -50440,6 +50440,9 @@ each individual 4.0.x release. @itemize @bullet @item +Fixed bug in @code{MATCH ... AGAINST( ... IN BOOLEAN MODE)} +used with @code{ORDER BY}. +@item Added @code{LOCK TABLES} and @code{CREATE TEMPORARY TABLES} privilege on the database level. One must run the @code{ mysql_fix_privilege_tables} script on old installations to activate these. diff --git a/myisam/ft_boolean_search.c b/myisam/ft_boolean_search.c index 13f596cb282..16096b64515 100644 --- a/myisam/ft_boolean_search.c +++ b/myisam/ft_boolean_search.c @@ -93,6 +93,7 @@ typedef struct st_ft_info CHARSET_INFO *charset; enum { UNINITIALIZED, READY, INDEX_SEARCH, INDEX_DONE /*, SCAN*/ } state; uint with_scan; + my_off_t lastpos; FTB_EXPR *root; QUEUE queue; TREE no_dupes; @@ -297,6 +298,7 @@ FT_INFO * ft_init_boolean_search(MI_INFO *info, uint keynr, byte *query, default_charset_info : info->s->keyinfo[keynr].seg->charset); ftb->with_scan=0; + ftb->lastpos=0; bzero(& ftb->no_dupes, sizeof(TREE)); init_alloc_root(&ftb->mem_root, 1024, 1024); @@ -540,6 +542,21 @@ float ft_boolean_find_relevance(FT_INFO *ftb, byte *record, uint length) if (!ftb->queue.elements) return 0; + if (ftb->state != INDEX_SEARCH && docid < ftb->lastpos) + { + FTB_EXPR *x; + uint i; + + for (i=0; i < ftb->queue.elements; i++) + { + ftb->list[i]->docid[1]=HA_POS_ERROR; + for (x=ftb->list[i]->up; x; x=x->up) + x->docid[1]=HA_POS_ERROR; + } + } + + ftb->lastpos=docid; + if (ftb->keynr==NO_SUCH_KEY) _mi_ft_segiterator_dummy_init(record, length, &ftsi); else @@ -557,7 +574,7 @@ float ft_boolean_find_relevance(FT_INFO *ftb, byte *record, uint length) int a, b, c; for (a=0, b=ftb->queue.elements, c=(a+b)/2; b-a>1; c=(a+b)/2) { - ftbw=(FTB_WORD *)(ftb->list[c]); + ftbw=ftb->list[c]; if (_mi_compare_text(ftb->charset, word.pos, word.len, (uchar*) ftbw->word+1, ftbw->len-1, (my_bool) (ftbw->flags&FTB_FLAG_TRUNC)) >0) @@ -567,7 +584,7 @@ float ft_boolean_find_relevance(FT_INFO *ftb, byte *record, uint length) } for (; c>=0; c--) { - ftbw=(FTB_WORD *)(ftb->list[c]); + ftbw=ftb->list[c]; if (_mi_compare_text(ftb->charset, word.pos,word.len, (uchar*) ftbw->word+1,ftbw->len-1, (my_bool) (ftbw->flags&FTB_FLAG_TRUNC))) @@ -614,3 +631,4 @@ void ft_boolean_reinit_search(FT_INFO *ftb) { _ftb_init_index_search(ftb); } + diff --git a/mysql-test/r/fulltext_order_by.result b/mysql-test/r/fulltext_order_by.result index 8d88b8d6ebf..c0e72ff789f 100644 --- a/mysql-test/r/fulltext_order_by.result +++ b/mysql-test/r/fulltext_order_by.result @@ -64,3 +64,18 @@ a rel 4 1 7 1 drop table t1; +CREATE TABLE t1 ( +a INT AUTO_INCREMENT PRIMARY KEY, +message CHAR(20), +FULLTEXT(message) +); +INSERT INTO t1 (message) VALUES ("testbug"),("testbug foobar"); +SELECT a, MATCH (message) AGAINST ('t* f*' IN BOOLEAN MODE) as rel FROM t1; +a rel +1 1 +2 2 +SELECT a, MATCH (message) AGAINST ('t* f*' IN BOOLEAN MODE) as rel FROM t1 ORDER BY rel,a; +a rel +1 1 +2 2 +drop table t1; diff --git a/mysql-test/t/fulltext_order_by.test b/mysql-test/t/fulltext_order_by.test index d5cb99ef0ee..3b60ee77db2 100644 --- a/mysql-test/t/fulltext_order_by.test +++ b/mysql-test/t/fulltext_order_by.test @@ -30,3 +30,17 @@ SELECT a, MATCH (message) AGAINST ('steve') as rel FROM t1 ORDER BY rel; SELECT a, MATCH (message) AGAINST ('steve' IN BOOLEAN MODE) as rel FROM t1 ORDER BY rel; drop table t1; + +# +# reused boolean scan bug +# +CREATE TABLE t1 ( + a INT AUTO_INCREMENT PRIMARY KEY, + message CHAR(20), + FULLTEXT(message) +); +INSERT INTO t1 (message) VALUES ("testbug"),("testbug foobar"); +SELECT a, MATCH (message) AGAINST ('t* f*' IN BOOLEAN MODE) as rel FROM t1; +SELECT a, MATCH (message) AGAINST ('t* f*' IN BOOLEAN MODE) as rel FROM t1 ORDER BY rel,a; +drop table t1; + diff --git a/mysys/queues.c b/mysys/queues.c index c458c96e998..fe642131d74 100644 --- a/mysys/queues.c +++ b/mysys/queues.c @@ -174,10 +174,8 @@ static int queue_fix_cmp(QUEUE *queue, void **a, void **b) } /* - Fix heap when every element was changed - actually, it can be done in linear time, - not in n*log(n), but some code (myisam/ft_boolean_search.c) - requires a strict order here, not just a queue property + Fix heap when every element was changed, + actually, it can be done better, in linear time, not in n*log(n) */ void queue_fix(QUEUE *queue) |