MySQL Lists are EOL. Please join:

List:Commits« Previous MessageNext Message »
From:Sergey Vojtovich Date:November 11 2008 9:11am
Subject:bzr commit into mysql-5.0-bugteam branch (svoj:2712) Bug#38842
View as plain text  
#At file:///home/svoj/devel/bzr-mysql/mysql-5.0-bugteam-bug38842/

 2712 Sergey Vojtovich	2008-11-11
      BUG#38842 - Fix for 25951 seems incorrect
      
      With fix for bug 25951 index hints are ignored for fulltext
      searches, as handling of fulltext indexes is different from
      handling regular indexes. Meaning it is not possible to
      implement true index hints support for fulltext indexes within
      the scope of current fulltext architecture.
      
      The problem is that prior to fix for bug 25951, some useful
      index hints still could be given for boolean mode searches.
      
      This patch implements special index hints support for fulltext
      indexes with the following characteristics:
      - all index hints are still ignored for NLQ mode searches -
        it cannot work without an index;
      - for 5.1 and up index hints FOR ORDER BY and FOR GROUP BY are
        still ignored for fulltext indexes;
      - boolean mode searches honor USE/FORCE/IGNORE INDEX hints;
      - as opposed to index hints for regular indexes, index hints
        for fulltext BOOLEAN mode searches affect the usage of the
        index for the whole query.
modified:
  mysql-test/r/fulltext.result
  mysql-test/t/fulltext.test
  sql/item_func.cc

per-file messages:
  mysql-test/r/fulltext.result
    A test case for BUG#38842.
  mysql-test/t/fulltext.test
    A test case for BUG#38842.
  sql/item_func.cc
    For boolean mode searches, which can work without fulltext
    index, use keys_in_use_for_query bitmap instead of keys_in_use.
    
    The effect is that boolean mode searches now honor index hints.
=== modified file 'mysql-test/r/fulltext.result'
--- a/mysql-test/r/fulltext.result	2007-11-02 08:58:20 +0000
+++ b/mysql-test/r/fulltext.result	2008-11-11 09:10:51 +0000
@@ -469,3 +469,31 @@ SELECT * FROM t1 WHERE MATCH(a) AGAINST 
 a
  aaaaa aaaa
 DROP TABLE t1;
+CREATE TABLE t1 (a VARCHAR(255), b INT, FULLTEXT(a), KEY(b));
+INSERT INTO t1 VALUES('test', 1),('test', 1),('test', 1),('test', 1),
+('test', 1),('test', 2),('test', 3),('test', 4);
+EXPLAIN SELECT * FROM t1
+WHERE MATCH(a) AGAINST('test' IN BOOLEAN MODE) AND b=1;
+id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
+1	SIMPLE	t1	fulltext	b,a	a	0		1	Using where
+EXPLAIN SELECT * FROM t1 USE INDEX(a)
+WHERE MATCH(a) AGAINST('test' IN BOOLEAN MODE) AND b=1;
+id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
+1	SIMPLE	t1	fulltext	a	a	0		1	Using where
+EXPLAIN SELECT * FROM t1 FORCE INDEX(a)
+WHERE MATCH(a) AGAINST('test' IN BOOLEAN MODE) AND b=1;
+id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
+1	SIMPLE	t1	fulltext	a	a	0		1	Using where
+EXPLAIN SELECT * FROM t1 IGNORE INDEX(a)
+WHERE MATCH(a) AGAINST('test' IN BOOLEAN MODE) AND b=1;
+id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
+1	SIMPLE	t1	ref	b	b	5	const	4	Using where
+EXPLAIN SELECT * FROM t1 USE INDEX(b)
+WHERE MATCH(a) AGAINST('test' IN BOOLEAN MODE) AND b=1;
+id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
+1	SIMPLE	t1	ref	b	b	5	const	4	Using where
+EXPLAIN SELECT * FROM t1 FORCE INDEX(b)
+WHERE MATCH(a) AGAINST('test' IN BOOLEAN MODE) AND b=1;
+id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
+1	SIMPLE	t1	ref	b	b	5	const	4	Using where
+DROP TABLE t1;

=== modified file 'mysql-test/t/fulltext.test'
--- a/mysql-test/t/fulltext.test	2007-11-02 08:58:20 +0000
+++ b/mysql-test/t/fulltext.test	2008-11-11 09:10:51 +0000
@@ -396,3 +396,30 @@ SELECT * FROM t1 WHERE MATCH(a) AGAINST 
 DROP TABLE t1;
 
 # End of 4.1 tests
+
+#
+# BUG#38842 - Fix for 25951 seems incorrect
+#
+CREATE TABLE t1 (a VARCHAR(255), b INT, FULLTEXT(a), KEY(b));
+INSERT INTO t1 VALUES('test', 1),('test', 1),('test', 1),('test', 1),
+                     ('test', 1),('test', 2),('test', 3),('test', 4);
+
+EXPLAIN SELECT * FROM t1
+WHERE MATCH(a) AGAINST('test' IN BOOLEAN MODE) AND b=1;
+
+EXPLAIN SELECT * FROM t1 USE INDEX(a)
+WHERE MATCH(a) AGAINST('test' IN BOOLEAN MODE) AND b=1;
+
+EXPLAIN SELECT * FROM t1 FORCE INDEX(a)
+WHERE MATCH(a) AGAINST('test' IN BOOLEAN MODE) AND b=1;
+
+EXPLAIN SELECT * FROM t1 IGNORE INDEX(a)
+WHERE MATCH(a) AGAINST('test' IN BOOLEAN MODE) AND b=1;
+
+EXPLAIN SELECT * FROM t1 USE INDEX(b)
+WHERE MATCH(a) AGAINST('test' IN BOOLEAN MODE) AND b=1;
+
+EXPLAIN SELECT * FROM t1 FORCE INDEX(b)
+WHERE MATCH(a) AGAINST('test' IN BOOLEAN MODE) AND b=1;
+
+DROP TABLE t1;

=== modified file 'sql/item_func.cc'
--- a/sql/item_func.cc	2008-07-30 11:07:37 +0000
+++ b/sql/item_func.cc	2008-11-11 09:10:51 +0000
@@ -5022,7 +5022,9 @@ bool Item_func_match::fix_index()
   for (keynr=0 ; keynr < table->s->keys ; keynr++)
   {
     if ((table->key_info[keynr].flags & HA_FULLTEXT) &&
-        (table->s->keys_in_use.is_set(keynr)))
+        (flags & FT_BOOL ? table->keys_in_use_for_query.is_set(keynr) :
+                           table->s->keys_in_use.is_set(keynr)))
+
     {
       ft_to_key[fts]=keynr;
       ft_cnt[fts]=0;

Thread
bzr commit into mysql-5.0-bugteam branch (svoj:2712) Bug#38842Sergey Vojtovich11 Nov