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
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
mariadb
Commits
51c261ff
Commit
51c261ff
authored
Sep 21, 2001
by
unknown
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Initial checkin of the new boolean fulltext search code
parent
2204fbea
Changes
7
Expand all
Show whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
294 additions
and
197 deletions
+294
-197
include/ft_global.h
include/ft_global.h
+2
-2
myisam/ft_boolean_search.c
myisam/ft_boolean_search.c
+250
-160
myisam/ft_search.c
myisam/ft_search.c
+4
-3
sql/item_func.cc
sql/item_func.cc
+5
-9
sql/item_func.h
sql/item_func.h
+21
-11
sql/sql_select.cc
sql/sql_select.cc
+10
-10
sql/sql_yacc.yy
sql/sql_yacc.yy
+2
-2
No files found.
include/ft_global.h
View file @
51c261ff
...
@@ -53,8 +53,8 @@ void ft_free_stopwords(void);
...
@@ -53,8 +53,8 @@ void ft_free_stopwords(void);
FT_DOCLIST
*
ft_init_search
(
void
*
,
uint
,
byte
*
,
uint
,
my_bool
);
FT_DOCLIST
*
ft_init_search
(
void
*
,
uint
,
byte
*
,
uint
,
my_bool
);
int
ft_read_next
(
FT_DOCLIST
*
,
char
*
);
int
ft_read_next
(
FT_DOCLIST
*
,
char
*
);
#define ft_close_search(handler) my_free(((gptr)(handler)),MYF(0))
#define ft_close_search(handler) my_free(((gptr)(handler)),MYF(0))
#define ft_get_relevance(handler) ((
handler)->doc[(handler
)->curdoc].weight)
#define ft_get_relevance(handler) ((
(FT_DOCLIST *)(handler))->doc[((FT_DOCLIST *)(handler)
)->curdoc].weight)
#define ft_get_docid(handler) ((
handler)->doc[(handler
)->curdoc].dpos)
#define ft_get_docid(handler) ((
(FT_DOCLIST *)(handler))->doc[((FT_DOCLIST *)(handler)
)->curdoc].dpos)
#define ft_reinit_search(handler) (((FT_DOCLIST *)(handler))->curdoc=-1)
#define ft_reinit_search(handler) (((FT_DOCLIST *)(handler))->curdoc=-1)
#ifdef __cplusplus
#ifdef __cplusplus
...
...
myisam/ft_boolean_search.c
View file @
51c261ff
This diff is collapsed.
Click to expand it.
myisam/ft_search.c
View file @
51c261ff
...
@@ -38,9 +38,9 @@ FT_DOCLIST *ft_init_search(void *info, uint keynr, byte *query,
...
@@ -38,9 +38,9 @@ FT_DOCLIST *ft_init_search(void *info, uint keynr, byte *query,
return
NULL
;
return
NULL
;
/* black magic OFF */
/* black magic OFF */
if
(
is_boolean
(
query
,
query_len
))
//
if (is_boolean(query, query_len))
dlist
=
ft_boolean_search
(
info
,
keynr
,
query
,
query_len
);
//
dlist=ft_boolean_search(info,keynr,query,query_len);
else
//
else
dlist
=
ft_nlq_search
(
info
,
keynr
,
query
,
query_len
);
dlist
=
ft_nlq_search
(
info
,
keynr
,
query
,
query_len
);
if
(
dlist
&&
presort
)
if
(
dlist
&&
presort
)
...
@@ -72,3 +72,4 @@ int ft_read_next(FT_DOCLIST *handler, char *record)
...
@@ -72,3 +72,4 @@ int ft_read_next(FT_DOCLIST *handler, char *record)
}
}
return
my_errno
;
return
my_errno
;
}
}
sql/item_func.cc
View file @
51c261ff
...
@@ -1903,7 +1903,7 @@ err:
...
@@ -1903,7 +1903,7 @@ err:
return
0
;
return
0
;
}
}
double
Item_func_match
::
val
()
double
Item_func_match
_nl
::
val
()
{
{
if
(
ft_handler
==
NULL
)
if
(
ft_handler
==
NULL
)
init_search
(
1
);
init_search
(
1
);
...
@@ -1922,7 +1922,7 @@ double Item_func_match::val()
...
@@ -1922,7 +1922,7 @@ double Item_func_match::val()
/* we'll have to find ft_relevance manually in ft_handler array */
/* we'll have to find ft_relevance manually in ft_handler array */
int
a
,
b
,
c
;
int
a
,
b
,
c
;
FT_DOC
*
docs
=
ft_handler
->
doc
;
FT_DOC
*
docs
=
((
FT_DOCLIST
*
)
ft_handler
)
->
doc
;
my_off_t
docid
=
table
->
file
->
row_position
();
my_off_t
docid
=
table
->
file
->
row_position
();
if
((
null_value
=
(
docid
==
HA_OFFSET_ERROR
)))
if
((
null_value
=
(
docid
==
HA_OFFSET_ERROR
)))
...
@@ -1930,7 +1930,7 @@ double Item_func_match::val()
...
@@ -1930,7 +1930,7 @@ double Item_func_match::val()
// Assuming docs[] is sorted by dpos...
// Assuming docs[] is sorted by dpos...
for
(
a
=
0
,
b
=
ft_handler
->
ndocs
,
c
=
(
a
+
b
)
/
2
;
b
-
a
>
1
;
c
=
(
a
+
b
)
/
2
)
for
(
a
=
0
,
b
=
((
FT_DOCLIST
*
)
ft_handler
)
->
ndocs
,
c
=
(
a
+
b
)
/
2
;
b
-
a
>
1
;
c
=
(
a
+
b
)
/
2
)
{
{
if
(
docs
[
c
].
dpos
>
docid
)
if
(
docs
[
c
].
dpos
>
docid
)
b
=
c
;
b
=
c
;
...
@@ -1941,7 +1941,6 @@ double Item_func_match::val()
...
@@ -1941,7 +1941,6 @@ double Item_func_match::val()
return
docs
[
a
].
weight
;
return
docs
[
a
].
weight
;
else
else
return
0.0
;
return
0.0
;
}
}
void
Item_func_match
::
init_search
(
bool
no_order
)
void
Item_func_match
::
init_search
(
bool
no_order
)
...
@@ -1969,9 +1968,7 @@ void Item_func_match::init_search(bool no_order)
...
@@ -1969,9 +1968,7 @@ void Item_func_match::init_search(bool no_order)
tmp2
.
set
(
""
,
0
);
tmp2
.
set
(
""
,
0
);
}
}
ft_handler
=
(
FT_DOCLIST
*
)
ft_handler_init
(
ft_tmp
->
ptr
(),
ft_tmp
->
length
(),
join_key
&&
!
no_order
);
table
->
file
->
ft_init_ext
(
key
,
(
byte
*
)
ft_tmp
->
ptr
(),
ft_tmp
->
length
(),
join_key
&&
!
no_order
);
if
(
join_key
)
if
(
join_key
)
{
{
...
@@ -2024,7 +2021,6 @@ bool Item_func_match::fix_fields(THD *thd,struct st_table_list *tlist)
...
@@ -2024,7 +2021,6 @@ bool Item_func_match::fix_fields(THD *thd,struct st_table_list *tlist)
return
0
;
return
0
;
}
}
bool
Item_func_match
::
fix_index
()
bool
Item_func_match
::
fix_index
()
{
{
List_iterator_fast
<
Item
>
li
(
fields
);
List_iterator_fast
<
Item
>
li
(
fields
);
...
...
sql/item_func.h
View file @
51c261ff
...
@@ -863,30 +863,40 @@ public:
...
@@ -863,30 +863,40 @@ public:
uint
key
;
uint
key
;
bool
join_key
;
bool
join_key
;
Item_func_match
*
master
;
Item_func_match
*
master
;
FT_DOCLIST
*
ft_handler
;
void
*
ft_handler
;
Item_func_match
(
List
<
Item
>
&
a
,
Item
*
b
)
:
Item_real_func
(
b
),
Item_func_match
(
List
<
Item
>
&
a
,
Item
*
b
)
:
Item_real_func
(
b
),
fields
(
a
),
table
(
0
),
join_key
(
0
),
master
(
0
),
ft_handler
(
0
)
{}
fields
(
a
),
table
(
0
),
join_key
(
0
),
master
(
0
),
ft_handler
(
0
)
{}
~
Item_func_match
()
~
Item_func_match
()
{
{
if
(
!
master
)
if
(
!
master
&&
ft_handler
)
{
{
if
(
ft_handler
)
ft_handler_close
();
{
ft_close_search
(
ft_handler
);
if
(
join_key
)
if
(
join_key
)
table
->
file
->
ft_handler
=
0
;
table
->
file
->
ft_handler
=
0
;
}
}
}
}
}
virtual
int
ft_handler_init
(
const
byte
*
key
,
uint
keylen
,
bool
presort
)
const
char
*
func_name
()
const
{
return
"match"
;
}
{
return
1
;
}
virtual
int
ft_handler_close
()
{
return
1
;
}
enum
Functype
functype
()
const
{
return
FT_FUNC
;
}
enum
Functype
functype
()
const
{
return
FT_FUNC
;
}
void
update_used_tables
()
{}
void
update_used_tables
()
{}
bool
fix_fields
(
THD
*
thd
,
struct
st_table_list
*
tlist
);
bool
fix_fields
(
THD
*
thd
,
struct
st_table_list
*
tlist
);
bool
eq
(
const
Item
*
)
const
;
bool
eq
(
const
Item
*
)
const
;
double
val
();
longlong
val_int
()
{
return
val
()
!=
0.0
;
}
longlong
val_int
()
{
return
val
()
!=
0.0
;
}
bool
fix_index
();
bool
fix_index
();
void
init_search
(
bool
no_order
);
void
init_search
(
bool
no_order
);
};
};
class
Item_func_match_nl
:
public
Item_func_match
{
public:
Item_func_match_nl
(
List
<
Item
>
&
a
,
Item
*
b
)
:
Item_func_match
(
a
,
b
)
{}
const
char
*
func_name
()
const
{
return
"match_NL"
;
}
double
val
();
int
ft_handler_init
(
const
byte
*
query
,
uint
querylen
,
bool
presort
)
{
ft_handler
=
table
->
file
->
ft_init_ext
(
key
,
query
,
querylen
,
presort
);
}
int
ft_handler_close
()
{
ft_close_search
(
ft_handler
);
ft_handler
=
0
;
}
};
sql/sql_select.cc
View file @
51c261ff
...
@@ -605,7 +605,7 @@ mysql_select(THD *thd,TABLE_LIST *tables,List<Item> &fields,COND *conds,
...
@@ -605,7 +605,7 @@ mysql_select(THD *thd,TABLE_LIST *tables,List<Item> &fields,COND *conds,
List_iterator_fast
<
Item_func_match
>
li
(
ftfuncs
);
List_iterator_fast
<
Item_func_match
>
li
(
ftfuncs
);
Item_func_match
*
ifm
;
Item_func_match
*
ifm
;
DBUG_PRINT
(
"info"
,(
"Performing FULLTEXT search"
));
DBUG_PRINT
(
"info"
,(
"Performing FULLTEXT search"
));
thd
->
proc_info
=
"FULLTEXT search
ing
"
;
thd
->
proc_info
=
"FULLTEXT search
init
"
;
while
((
ifm
=
li
++
))
while
((
ifm
=
li
++
))
{
{
...
@@ -1455,13 +1455,13 @@ add_ft_keys(DYNAMIC_ARRAY *keyuse_array,
...
@@ -1455,13 +1455,13 @@ add_ft_keys(DYNAMIC_ARRAY *keyuse_array,
functype
==
Item_func
::
GT_FUNC
)
&&
functype
==
Item_func
::
GT_FUNC
)
&&
arg0
->
type
()
==
Item
::
FUNC_ITEM
&&
arg0
->
type
()
==
Item
::
FUNC_ITEM
&&
arg0
->
functype
()
==
Item_func
::
FT_FUNC
&&
arg0
->
functype
()
==
Item_func
::
FT_FUNC
&&
arg1
->
const_item
()
&&
arg1
->
val
()
>
=
0
)
arg1
->
const_item
()
&&
arg1
->
val
()
>
0
)
cond_func
=
(
Item_func_match
*
)
arg0
;
cond_func
=
(
Item_func_match
*
)
arg0
;
else
if
((
functype
==
Item_func
::
LE_FUNC
||
else
if
((
functype
==
Item_func
::
LE_FUNC
||
functype
==
Item_func
::
LT_FUNC
)
&&
functype
==
Item_func
::
LT_FUNC
)
&&
arg1
->
type
()
==
Item
::
FUNC_ITEM
&&
arg1
->
type
()
==
Item
::
FUNC_ITEM
&&
arg1
->
functype
()
==
Item_func
::
FT_FUNC
&&
arg1
->
functype
()
==
Item_func
::
FT_FUNC
&&
arg0
->
const_item
()
&&
arg0
->
val
()
>
=
0
)
arg0
->
const_item
()
&&
arg0
->
val
()
>
0
)
cond_func
=
(
Item_func_match
*
)
arg1
;
cond_func
=
(
Item_func_match
*
)
arg1
;
}
}
}
}
...
@@ -1473,7 +1473,7 @@ add_ft_keys(DYNAMIC_ARRAY *keyuse_array,
...
@@ -1473,7 +1473,7 @@ add_ft_keys(DYNAMIC_ARRAY *keyuse_array,
{
{
Item
*
item
;
Item
*
item
;
/*
/*
I
'
, (Sergei) too lazy to implement proper recursive descent here,
I, (Sergei) too lazy to implement proper recursive descent here,
and anyway, nobody will use such a stupid queries
and anyway, nobody will use such a stupid queries
that will require it :-)
that will require it :-)
May be later...
May be later...
...
...
sql/sql_yacc.yy
View file @
51c261ff
...
@@ -1549,10 +1549,10 @@ simple_expr:
...
@@ -1549,10 +1549,10 @@ simple_expr:
| '{' ident expr '}' { $$= $3; }
| '{' ident expr '}' { $$= $3; }
| MATCH '(' ident_list ')' AGAINST '(' expr ')'
| MATCH '(' ident_list ')' AGAINST '(' expr ')'
{ Select->ftfunc_list.push_back(
{ Select->ftfunc_list.push_back(
(Item_func_match *)($$=new Item_func_match(*$3,$7))); }
(Item_func_match *)($$=new Item_func_match
_nl
(*$3,$7))); }
| MATCH ident_list AGAINST '(' expr ')'
| MATCH ident_list AGAINST '(' expr ')'
{ Select->ftfunc_list.push_back(
{ Select->ftfunc_list.push_back(
(Item_func_match *)($$=new Item_func_match(*$2,$5))); }
(Item_func_match *)($$=new Item_func_match
_nl
(*$2,$5))); }
| BINARY expr %prec NEG { $$= new Item_func_binary($2); }
| BINARY expr %prec NEG { $$= new Item_func_binary($2); }
| CASE_SYM opt_expr WHEN_SYM when_list opt_else END
| CASE_SYM opt_expr WHEN_SYM when_list opt_else END
{ $$= new Item_func_case(* $4, $2, $5 ) }
{ $$= new Item_func_case(* $4, $2, $5 ) }
...
...
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