mirror of
https://github.com/MariaDB/server.git
synced 2025-01-17 12:32:27 +01:00
Merge bk-internal:/home/bk/mysql-4.0/
into serg.mylan:/usr/home/serg/Abk/mysql-4.0
This commit is contained in:
commit
c0d60e83a7
3 changed files with 65 additions and 38 deletions
|
@ -5,9 +5,6 @@ INSERT INTO t1 VALUES('MySQL has now support', 'for full-text search'),
|
|||
('Only MyISAM tables','support collections'),
|
||||
('Function MATCH ... AGAINST()','is used to do a search'),
|
||||
('Full-text search in MySQL', 'implements vector space model');
|
||||
explain select * from t1 where MATCH(a,b) AGAINST ("collections");
|
||||
table type possible_keys key key_len ref rows Extra
|
||||
t1 fulltext a a 0 1 Using where
|
||||
select * from t1 where MATCH(a,b) AGAINST ("collections");
|
||||
a b
|
||||
Only MyISAM tables support collections
|
||||
|
@ -19,11 +16,36 @@ select * from t1 where MATCH(a,b) AGAINST ("indexes collections");
|
|||
a b
|
||||
Full-text indexes are called collections
|
||||
Only MyISAM tables support collections
|
||||
select * from t1 where MATCH(a,b) AGAINST ("collections") UNION ALL select * from t1 where MATCH(a,b) AGAINST ("indexes");
|
||||
a b
|
||||
Only MyISAM tables support collections
|
||||
Full-text indexes are called collections
|
||||
Full-text indexes are called collections
|
||||
explain select * from t1 where MATCH(a,b) AGAINST ("collections");
|
||||
table type possible_keys key key_len ref rows Extra
|
||||
t1 fulltext a a 0 1 Using where
|
||||
explain select * from t1 where MATCH(a,b) AGAINST ("collections")>0;
|
||||
table type possible_keys key key_len ref rows Extra
|
||||
t1 fulltext a a 0 1 Using where
|
||||
explain select * from t1 where MATCH(a,b) AGAINST ("collections")>1;
|
||||
table type possible_keys key key_len ref rows Extra
|
||||
t1 fulltext a a 0 1 Using where
|
||||
explain select * from t1 where MATCH(a,b) AGAINST ("collections")>=0;
|
||||
table type possible_keys key key_len ref rows Extra
|
||||
t1 ALL NULL NULL NULL NULL 5 Using where
|
||||
explain select * from t1 where MATCH(a,b) AGAINST ("collections")>=1;
|
||||
table type possible_keys key key_len ref rows Extra
|
||||
t1 fulltext a a 0 1 Using where
|
||||
explain select * from t1 where 0<MATCH(a,b) AGAINST ("collections");
|
||||
table type possible_keys key key_len ref rows Extra
|
||||
t1 fulltext a a 0 1 Using where
|
||||
explain select * from t1 where 1<MATCH(a,b) AGAINST ("collections");
|
||||
table type possible_keys key key_len ref rows Extra
|
||||
t1 fulltext a a 0 1 Using where
|
||||
explain select * from t1 where 0<=MATCH(a,b) AGAINST ("collections");
|
||||
table type possible_keys key key_len ref rows Extra
|
||||
t1 ALL NULL NULL NULL NULL 5 Using where
|
||||
explain select * from t1 where 1<=MATCH(a,b) AGAINST ("collections");
|
||||
table type possible_keys key key_len ref rows Extra
|
||||
t1 fulltext a a 0 1 Using where
|
||||
explain select * from t1 where MATCH(a,b) AGAINST ("collections")>0 and a like '%ll%';
|
||||
table type possible_keys key key_len ref rows Extra
|
||||
t1 fulltext a a 0 1 Using where
|
||||
select * from t1 where MATCH(a,b) AGAINST("support -collections" IN BOOLEAN MODE);
|
||||
a b
|
||||
MySQL has now support for full-text search
|
||||
|
@ -98,6 +120,11 @@ select * from t1 where MATCH b AGAINST ("sear*" IN BOOLEAN MODE);
|
|||
a b
|
||||
MySQL has now support for full-text search
|
||||
Function MATCH ... AGAINST() is used to do a search
|
||||
select * from t1 where MATCH(a,b) AGAINST ("collections") UNION ALL select * from t1 where MATCH(a,b) AGAINST ("indexes");
|
||||
a b
|
||||
Only MyISAM tables support collections
|
||||
Full-text indexes are called collections
|
||||
Full-text indexes are called collections
|
||||
delete from t1 where a like "MySQL%";
|
||||
update t1 set a='some test foobar' where MATCH a,b AGAINST ('model');
|
||||
delete from t1 where MATCH(a,b) AGAINST ("indexes");
|
||||
|
|
|
@ -12,14 +12,24 @@ INSERT INTO t1 VALUES('MySQL has now support', 'for full-text search'),
|
|||
('Full-text search in MySQL', 'implements vector space model');
|
||||
|
||||
# nl search
|
||||
|
||||
explain select * from t1 where MATCH(a,b) AGAINST ("collections");
|
||||
|
||||
select * from t1 where MATCH(a,b) AGAINST ("collections");
|
||||
select * from t1 where MATCH(a,b) AGAINST ("indexes");
|
||||
select * from t1 where MATCH(a,b) AGAINST ("indexes collections");
|
||||
|
||||
# UNION of fulltext's
|
||||
select * from t1 where MATCH(a,b) AGAINST ("collections") UNION ALL select * from t1 where MATCH(a,b) AGAINST ("indexes");
|
||||
|
||||
# add_ft_keys() tests
|
||||
|
||||
explain select * from t1 where MATCH(a,b) AGAINST ("collections");
|
||||
explain select * from t1 where MATCH(a,b) AGAINST ("collections")>0;
|
||||
explain select * from t1 where MATCH(a,b) AGAINST ("collections")>1;
|
||||
explain select * from t1 where MATCH(a,b) AGAINST ("collections")>=0;
|
||||
explain select * from t1 where MATCH(a,b) AGAINST ("collections")>=1;
|
||||
explain select * from t1 where 0<MATCH(a,b) AGAINST ("collections");
|
||||
explain select * from t1 where 1<MATCH(a,b) AGAINST ("collections");
|
||||
explain select * from t1 where 0<=MATCH(a,b) AGAINST ("collections");
|
||||
explain select * from t1 where 1<=MATCH(a,b) AGAINST ("collections");
|
||||
explain select * from t1 where MATCH(a,b) AGAINST ("collections")>0 and a like '%ll%';
|
||||
|
||||
# boolean search
|
||||
|
||||
|
@ -48,6 +58,10 @@ select * from t1 where MATCH a,b AGAINST ('"text i"' IN BOOLEAN MODE);
|
|||
select * from t1 where MATCH a AGAINST ("search" IN BOOLEAN MODE);
|
||||
select * from t1 where MATCH b AGAINST ("sear*" IN BOOLEAN MODE);
|
||||
|
||||
# UNION of fulltext's
|
||||
|
||||
select * from t1 where MATCH(a,b) AGAINST ("collections") UNION ALL select * from t1 where MATCH(a,b) AGAINST ("indexes");
|
||||
|
||||
#update/delete with fulltext index
|
||||
|
||||
delete from t1 where a like "MySQL%";
|
||||
|
|
|
@ -1655,17 +1655,17 @@ add_ft_keys(DYNAMIC_ARRAY *keyuse_array,
|
|||
{
|
||||
Item_func *arg0=(Item_func *)(func->arguments()[0]),
|
||||
*arg1=(Item_func *)(func->arguments()[1]);
|
||||
if ((functype == Item_func::GE_FUNC ||
|
||||
functype == Item_func::GT_FUNC) &&
|
||||
arg0->type() == Item::FUNC_ITEM &&
|
||||
arg0->functype() == Item_func::FT_FUNC &&
|
||||
arg1->const_item() && arg1->val()>0)
|
||||
if (arg1->const_item() &&
|
||||
((functype == Item_func::GE_FUNC && arg1->val()> 0) ||
|
||||
(functype == Item_func::GT_FUNC && arg1->val()>=0)) &&
|
||||
arg0->type() == Item::FUNC_ITEM &&
|
||||
arg0->functype() == Item_func::FT_FUNC)
|
||||
cond_func=(Item_func_match *) arg0;
|
||||
else if ((functype == Item_func::LE_FUNC ||
|
||||
functype == Item_func::LT_FUNC) &&
|
||||
else if (arg0->const_item() &&
|
||||
((functype == Item_func::LE_FUNC && arg0->val()> 0) ||
|
||||
(functype == Item_func::LT_FUNC && arg0->val()>=0)) &&
|
||||
arg1->type() == Item::FUNC_ITEM &&
|
||||
arg1->functype() == Item_func::FT_FUNC &&
|
||||
arg0->const_item() && arg0->val()>0)
|
||||
arg1->functype() == Item_func::FT_FUNC)
|
||||
cond_func=(Item_func_match *) arg1;
|
||||
}
|
||||
}
|
||||
|
@ -1676,26 +1676,13 @@ add_ft_keys(DYNAMIC_ARRAY *keyuse_array,
|
|||
if (((Item_cond*) cond)->functype() == Item_func::COND_AND_FUNC)
|
||||
{
|
||||
Item *item;
|
||||
/*
|
||||
I'm (Sergei) too lazy to implement proper recursive descent here,
|
||||
and anyway, nobody will use such a stupid queries
|
||||
that will require it :-)
|
||||
May be later...
|
||||
*/
|
||||
while ((item=li++))
|
||||
{
|
||||
if (item->type() == Item::FUNC_ITEM &&
|
||||
((Item_func *)item)->functype() == Item_func::FT_FUNC)
|
||||
{
|
||||
cond_func=(Item_func_match *)item;
|
||||
break;
|
||||
}
|
||||
}
|
||||
add_ft_keys(keyuse_array,stat,item,usable_tables);
|
||||
}
|
||||
}
|
||||
|
||||
if ((!cond_func || cond_func->key == NO_SUCH_KEY) ||
|
||||
(!(usable_tables & cond_func->table->map)))
|
||||
if (!cond_func || cond_func->key == NO_SUCH_KEY ||
|
||||
!(usable_tables & cond_func->table->map))
|
||||
return;
|
||||
|
||||
KEYUSE keyuse;
|
||||
|
@ -1707,7 +1694,6 @@ add_ft_keys(DYNAMIC_ARRAY *keyuse_array,
|
|||
VOID(insert_dynamic(keyuse_array,(gptr) &keyuse));
|
||||
}
|
||||
|
||||
|
||||
static int
|
||||
sort_keyuse(KEYUSE *a,KEYUSE *b)
|
||||
{
|
||||
|
|
Loading…
Reference in a new issue