Commit db48877a authored by unknown's avatar unknown

sql_select.cc MATCH ... AGAINST (NULL) bug fixed

item_func.cc	MATCH ... AGAINST (NULL) bug fixed
fulltext.test	MATCH ... AGAINST (NULL) bug fixed
fulltext.result	MATCH ... AGAINST (NULL) bug fixed


mysql-test/r/fulltext.result:
  MATCH ... AGAINST (NULL) bug fixed
mysql-test/t/fulltext.test:
  MATCH ... AGAINST (NULL) bug fixed
sql/item_func.cc:
  MATCH ... AGAINST (NULL) bug fixed
sql/sql_select.cc:
  MATCH ... AGAINST (NULL) bug fixed
parent 68e3679a
...@@ -20,3 +20,4 @@ t2 CREATE TABLE `t2` ( ...@@ -20,3 +20,4 @@ t2 CREATE TABLE `t2` (
KEY `tig` (`ticket`), KEY `tig` (`ticket`),
FULLTEXT KEY `tix` (`inhalt`) FULLTEXT KEY `tix` (`inhalt`)
) TYPE=MyISAM ) TYPE=MyISAM
ticket inhalt
...@@ -21,21 +21,25 @@ CREATE TABLE t1 ( ...@@ -21,21 +21,25 @@ CREATE TABLE t1 (
ticket int(11), ticket int(11),
KEY ti (id), KEY ti (id),
KEY tit (ticket) KEY tit (ticket)
)/*! type=MyISAM */; );
INSERT INTO t1 VALUES (2,3),(1,2); INSERT INTO t1 VALUES (2,3),(1,2);
CREATE TABLE t2 ( CREATE TABLE t2 (
ticket int(11), ticket int(11),
inhalt text, inhalt text,
KEY tig (ticket), KEY tig (ticket),
fulltext index tix (inhalt(1)) /* this line modified by hand */ fulltext index tix (inhalt)
)/*! type=MyISAM */; );
INSERT INTO t2 VALUES (1,'foo'),(2,'bar'),(3,'foobar'); 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 # 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); 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'); 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 ...@@ -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 keys from t2;
show create table t2; show create table t2;
drop table t1,t2;
# check for bug reported by Stephan Skusa # check for bug reported by Stephan Skusa
drop table if exists fulltextTEST; select * from t2 where MATCH inhalt AGAINST (NULL);
CREATE TABLE fulltextTEST (
field1 varchar(40) NOT NULL, drop table t1,t2;
field2 varchar(20) NOT NULL,
field3 varchar(40) NOT NULL,
PRIMARY KEY (field1),
FULLTEXT idx_fulltext (field1, field2, field3)
);
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;
...@@ -1924,7 +1924,13 @@ void Item_func_match::init_search(bool no_order) ...@@ -1924,7 +1924,13 @@ void Item_func_match::init_search(bool no_order)
char tmp1[FT_QUERY_MAXLEN]; char tmp1[FT_QUERY_MAXLEN];
String tmp2(tmp1,sizeof(tmp1)); 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 *) ft_handler=(FT_DOCLIST *)
table->file->ft_init_ext(key, (byte*) ft_tmp->ptr(), ft_tmp->length(), table->file->ft_init_ext(key, (byte*) ft_tmp->ptr(), ft_tmp->length(),
join_key && !no_order); join_key && !no_order);
......
...@@ -1968,9 +1968,6 @@ get_best_combination(JOIN *join) ...@@ -1968,9 +1968,6 @@ get_best_combination(JOIN *join)
KEYUSE *keyuse; KEYUSE *keyuse;
KEY *keyinfo; KEY *keyinfo;
uint table_count; uint table_count;
String *ft_tmp=0;
char tmp1[FT_QUERY_MAXLEN];
String tmp2(tmp1,sizeof(tmp1));
table_count=join->tables; table_count=join->tables;
if (!(join->join_tab=join_tab= if (!(join->join_tab=join_tab=
...@@ -2026,8 +2023,7 @@ get_best_combination(JOIN *join) ...@@ -2026,8 +2023,7 @@ get_best_combination(JOIN *join)
{ {
Item_func_match *ifm=(Item_func_match *)keyuse->val; Item_func_match *ifm=(Item_func_match *)keyuse->val;
ft_tmp=ifm->key_item()->val_str(&tmp2); length=0;
length=ft_tmp->length();
keyparts=1; keyparts=1;
ifm->join_key=1; ifm->join_key=1;
} }
...@@ -2070,16 +2066,9 @@ get_best_combination(JOIN *join) ...@@ -2070,16 +2066,9 @@ get_best_combination(JOIN *join)
if (ftkey) if (ftkey)
{ {
j->ref.items[0]=((Item_func*)(keyuse->val))->key_item(); j->ref.items[0]=((Item_func*)(keyuse->val))->key_item();
if (!keyuse->used_tables) 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
{
return TRUE; // not supported yet. SerG return TRUE; // not supported yet. SerG
}
j->type=JT_FT; j->type=JT_FT;
} }
else else
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment