summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--mysql-test/r/fulltext.result1
-rw-r--r--mysql-test/t/fulltext.test32
-rw-r--r--sql/item_func.cc8
-rw-r--r--sql/sql_select.cc17
4 files changed, 23 insertions, 35 deletions
diff --git a/mysql-test/r/fulltext.result b/mysql-test/r/fulltext.result
index 025cd022cd4..a616b09781f 100644
--- a/mysql-test/r/fulltext.result
+++ b/mysql-test/r/fulltext.result
@@ -20,3 +20,4 @@ t2 CREATE TABLE `t2` (
KEY `tig` (`ticket`),
FULLTEXT KEY `tix` (`inhalt`)
) TYPE=MyISAM
+ticket inhalt
diff --git a/mysql-test/t/fulltext.test b/mysql-test/t/fulltext.test
index 555c543664e..5535e422db8 100644
--- a/mysql-test/t/fulltext.test
+++ b/mysql-test/t/fulltext.test
@@ -21,21 +21,25 @@ CREATE TABLE t1 (
ticket int(11),
KEY ti (id),
KEY tit (ticket)
-)/*! type=MyISAM */;
+);
INSERT INTO t1 VALUES (2,3),(1,2);
CREATE TABLE t2 (
ticket int(11),
inhalt text,
KEY tig (ticket),
- fulltext index tix (inhalt(1)) /* this line modified by hand */
-)/*! type=MyISAM */;
+ fulltext index tix (inhalt)
+);
INSERT INTO t2 VALUES (1,'foo'),(2,'bar'),(3,'foobar');
-select t1.id FROM t2 as ttxt,t1,t1 as ticket2 WHERE ticket2.id = ttxt.ticket AND t1.id = ticket2.ticket and match(ttxt.inhalt) against ('foobar');
+select t1.id FROM t2 as ttxt,t1,t1 as ticket2
+WHERE ticket2.id = ttxt.ticket AND t1.id = ticket2.ticket and
+match(ttxt.inhalt) against ('foobar');
# In the following query MySQL didn't use the fulltext index
-select t1.id FROM t2 as ttxt,t1 INNER JOIN t1 as ticket2 ON ticket2.id = ttxt.ticket WHERE t1.id = ticket2.ticket and match(ttxt.inhalt) against ('foobar');
+select t1.id FROM t2 as ttxt,t1 INNER JOIN t1 as ticket2 ON
+ticket2.id = ttxt.ticket
+WHERE t1.id = ticket2.ticket and match(ttxt.inhalt) against ('foobar');
INSERT INTO t1 VALUES (3,3);
select t1.id FROM t2 as ttxt,t1 INNER JOIN t1 as ticket2 ON ticket2.id = ttxt.ticket WHERE t1.id = ticket2.ticket and match(ttxt.inhalt) against ('foobar');
@@ -44,22 +48,10 @@ select t1.id FROM t2 as ttxt,t1 INNER JOIN t1 as ticket2 ON ticket2.id = ttxt.ti
show keys from t2;
show create table t2;
-drop table t1,t2;
# check for bug reported by Stephan Skusa
-drop table if exists fulltextTEST;
-CREATE TABLE fulltextTEST (
- field1 varchar(40) NOT NULL,
- field2 varchar(20) NOT NULL,
- field3 varchar(40) NOT NULL,
- PRIMARY KEY (field1),
- FULLTEXT idx_fulltext (field1, field2, field3)
-);
+select * from t2 where MATCH inhalt AGAINST (NULL);
+
+drop table t1,t2;
-INSERT INTO fulltextTEST VALUES ( 'test1', 'test1.1', 'test1.1.1');
-INSERT INTO fulltextTEST VALUES ( 'test2', 'test2.1', 'test2.1.1');
-select *
-from fulltextTEST
-where MATCH (field1,field2,field3) AGAINST (NULL);
-drop table fulltextTEST;
diff --git a/sql/item_func.cc b/sql/item_func.cc
index 7e23c2784e5..ef46a624aaf 100644
--- a/sql/item_func.cc
+++ b/sql/item_func.cc
@@ -1924,7 +1924,13 @@ void Item_func_match::init_search(bool no_order)
char tmp1[FT_QUERY_MAXLEN];
String tmp2(tmp1,sizeof(tmp1));
- ft_tmp=key_item()->val_str(&tmp2);
+ // MATCH ... AGAINST (NULL) is meaningless, but possible
+ if (!(ft_tmp=key_item()->val_str(&tmp2)))
+ {
+ ft_tmp=&tmp2;
+ tmp2.set("",0);
+ }
+
ft_handler=(FT_DOCLIST *)
table->file->ft_init_ext(key, (byte*) ft_tmp->ptr(), ft_tmp->length(),
join_key && !no_order);
diff --git a/sql/sql_select.cc b/sql/sql_select.cc
index db1d3b7d774..1995274f9fc 100644
--- a/sql/sql_select.cc
+++ b/sql/sql_select.cc
@@ -1968,9 +1968,6 @@ get_best_combination(JOIN *join)
KEYUSE *keyuse;
KEY *keyinfo;
uint table_count;
- String *ft_tmp=0;
- char tmp1[FT_QUERY_MAXLEN];
- String tmp2(tmp1,sizeof(tmp1));
table_count=join->tables;
if (!(join->join_tab=join_tab=
@@ -2026,8 +2023,7 @@ get_best_combination(JOIN *join)
{
Item_func_match *ifm=(Item_func_match *)keyuse->val;
- ft_tmp=ifm->key_item()->val_str(&tmp2);
- length=ft_tmp->length();
+ length=0;
keyparts=1;
ifm->join_key=1;
}
@@ -2070,16 +2066,9 @@ get_best_combination(JOIN *join)
if (ftkey)
{
j->ref.items[0]=((Item_func*)(keyuse->val))->key_item();
- if (!keyuse->used_tables)
- {
- // AFAIK key_buff is zeroed...
- // We don't need to free ft_tmp as the buffer will be freed atom.
- memcpy((gptr)key_buff, (gptr) ft_tmp->ptr(), ft_tmp->length());
- }
- else
- {
+ if (keyuse->used_tables)
return TRUE; // not supported yet. SerG
- }
+
j->type=JT_FT;
}
else