Commit 72bc949c 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 064c7adf
......@@ -20,3 +20,4 @@ t2 CREATE TABLE `t2` (
KEY `tig` (`ticket`),
FULLTEXT KEY `tix` (`inhalt`)
) TYPE=MyISAM
ticket inhalt
......@@ -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;
......@@ -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);
......
......@@ -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
......
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