Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
M
MariaDB
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
nexedi
MariaDB
Commits
a4c3f0d7
Commit
a4c3f0d7
authored
Jul 07, 2003
by
unknown
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
finally proper recursive descent for parsing expressions with MATCH ... AGAINST in add_ft_keys()
parent
7ff9378a
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
56 additions
and
29 deletions
+56
-29
mysql-test/r/fulltext.result
mysql-test/r/fulltext.result
+35
-8
mysql-test/t/fulltext.test
mysql-test/t/fulltext.test
+18
-4
sql/sql_select.cc
sql/sql_select.cc
+3
-17
No files found.
mysql-test/r/fulltext.result
View file @
a4c3f0d7
...
@@ -5,9 +5,6 @@ INSERT INTO t1 VALUES('MySQL has now support', 'for full-text search'),
...
@@ -5,9 +5,6 @@ INSERT INTO t1 VALUES('MySQL has now support', 'for full-text search'),
('Only MyISAM tables','support collections'),
('Only MyISAM tables','support collections'),
('Function MATCH ... AGAINST()','is used to do a search'),
('Function MATCH ... AGAINST()','is used to do a search'),
('Full-text search in MySQL', 'implements vector space model');
('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");
select * from t1 where MATCH(a,b) AGAINST ("collections");
a b
a b
Only MyISAM tables support collections
Only MyISAM tables support collections
...
@@ -19,11 +16,36 @@ select * from t1 where MATCH(a,b) AGAINST ("indexes collections");
...
@@ -19,11 +16,36 @@ select * from t1 where MATCH(a,b) AGAINST ("indexes collections");
a b
a b
Full-text indexes are called collections
Full-text indexes are called collections
Only MyISAM tables support 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");
explain select * from t1 where MATCH(a,b) AGAINST ("collections");
a b
table type possible_keys key key_len ref rows Extra
Only MyISAM tables support collections
t1 fulltext a a 0 1 Using where
Full-text indexes are called collections
explain select * from t1 where MATCH(a,b) AGAINST ("collections")>0;
Full-text indexes are called 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")>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);
select * from t1 where MATCH(a,b) AGAINST("support -collections" IN BOOLEAN MODE);
a b
a b
MySQL has now support for full-text search
MySQL has now support for full-text search
...
@@ -98,6 +120,11 @@ select * from t1 where MATCH b AGAINST ("sear*" IN BOOLEAN MODE);
...
@@ -98,6 +120,11 @@ select * from t1 where MATCH b AGAINST ("sear*" IN BOOLEAN MODE);
a b
a b
MySQL has now support for full-text search
MySQL has now support for full-text search
Function MATCH ... AGAINST() is used to do a 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%";
delete from t1 where a like "MySQL%";
update t1 set a='some test foobar' where MATCH a,b AGAINST ('model');
update t1 set a='some test foobar' where MATCH a,b AGAINST ('model');
delete from t1 where MATCH(a,b) AGAINST ("indexes");
delete from t1 where MATCH(a,b) AGAINST ("indexes");
...
...
mysql-test/t/fulltext.test
View file @
a4c3f0d7
...
@@ -12,14 +12,24 @@ INSERT INTO t1 VALUES('MySQL has now support', 'for full-text search'),
...
@@ -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'
);
(
'Full-text search in MySQL'
,
'implements vector space model'
);
# nl search
# 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
(
"collections"
);
select
*
from
t1
where
MATCH
(
a
,
b
)
AGAINST
(
"indexes"
);
select
*
from
t1
where
MATCH
(
a
,
b
)
AGAINST
(
"indexes"
);
select
*
from
t1
where
MATCH
(
a
,
b
)
AGAINST
(
"indexes collections"
);
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
# boolean search
...
@@ -48,6 +58,10 @@ select * from t1 where MATCH a,b AGAINST ('"text i"' IN BOOLEAN MODE);
...
@@ -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
a
AGAINST
(
"search"
IN
BOOLEAN
MODE
);
select
*
from
t1
where
MATCH
b
AGAINST
(
"sear*"
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
#update/delete with fulltext index
delete
from
t1
where
a
like
"MySQL%"
;
delete
from
t1
where
a
like
"MySQL%"
;
...
...
sql/sql_select.cc
View file @
a4c3f0d7
...
@@ -1676,26 +1676,13 @@ add_ft_keys(DYNAMIC_ARRAY *keyuse_array,
...
@@ -1676,26 +1676,13 @@ add_ft_keys(DYNAMIC_ARRAY *keyuse_array,
if
(((
Item_cond
*
)
cond
)
->
functype
()
==
Item_func
::
COND_AND_FUNC
)
if
(((
Item_cond
*
)
cond
)
->
functype
()
==
Item_func
::
COND_AND_FUNC
)
{
{
Item
*
item
;
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
++
))
while
((
item
=
li
++
))
{
add_ft_keys
(
keyuse_array
,
stat
,
item
,
usable_tables
);
if
(
item
->
type
()
==
Item
::
FUNC_ITEM
&&
((
Item_func
*
)
item
)
->
functype
()
==
Item_func
::
FT_FUNC
)
{
cond_func
=
(
Item_func_match
*
)
item
;
break
;
}
}
}
}
}
}
if
(
(
!
cond_func
||
cond_func
->
key
==
NO_SUCH_KEY
)
||
if
(
!
cond_func
||
cond_func
->
key
==
NO_SUCH_KEY
||
(
!
(
usable_tables
&
cond_func
->
table
->
map
)
))
!
(
usable_tables
&
cond_func
->
table
->
map
))
return
;
return
;
KEYUSE
keyuse
;
KEYUSE
keyuse
;
...
@@ -1707,7 +1694,6 @@ add_ft_keys(DYNAMIC_ARRAY *keyuse_array,
...
@@ -1707,7 +1694,6 @@ add_ft_keys(DYNAMIC_ARRAY *keyuse_array,
VOID
(
insert_dynamic
(
keyuse_array
,(
gptr
)
&
keyuse
));
VOID
(
insert_dynamic
(
keyuse_array
,(
gptr
)
&
keyuse
));
}
}
static
int
static
int
sort_keyuse
(
KEYUSE
*
a
,
KEYUSE
*
b
)
sort_keyuse
(
KEYUSE
*
a
,
KEYUSE
*
b
)
{
{
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment