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
57e4c8ef
Commit
57e4c8ef
authored
Sep 21, 2001
by
serg@serg.mysql.com
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Initial checkin of the new boolean fulltext search code
parent
c18a94f3
Changes
7
Expand all
Hide 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 @
57e4c8ef
...
...
@@ -53,8 +53,8 @@ void ft_free_stopwords(void);
FT_DOCLIST
*
ft_init_search
(
void
*
,
uint
,
byte
*
,
uint
,
my_bool
);
int
ft_read_next
(
FT_DOCLIST
*
,
char
*
);
#define ft_close_search(handler) my_free(((gptr)(handler)),MYF(0))
#define ft_get_relevance(handler) ((
handler)->doc[(handler
)->curdoc].weight)
#define ft_get_docid(handler) ((
handler)->doc[(handler
)->curdoc].dpos)
#define ft_get_relevance(handler) ((
(FT_DOCLIST *)(handler))->doc[((FT_DOCLIST *)(handler)
)->curdoc].weight)
#define ft_get_docid(handler) ((
(FT_DOCLIST *)(handler))->doc[((FT_DOCLIST *)(handler)
)->curdoc].dpos)
#define ft_reinit_search(handler) (((FT_DOCLIST *)(handler))->curdoc=-1)
#ifdef __cplusplus
...
...
myisam/ft_boolean_search.c
View file @
57e4c8ef
This diff is collapsed.
Click to expand it.
myisam/ft_search.c
View file @
57e4c8ef
...
...
@@ -38,9 +38,9 @@ FT_DOCLIST *ft_init_search(void *info, uint keynr, byte *query,
return
NULL
;
/* black magic OFF */
if
(
is_boolean
(
query
,
query_len
))
dlist
=
ft_boolean_search
(
info
,
keynr
,
query
,
query_len
);
else
//
if (is_boolean(query, query_len))
//
dlist=ft_boolean_search(info,keynr,query,query_len);
//
else
dlist
=
ft_nlq_search
(
info
,
keynr
,
query
,
query_len
);
if
(
dlist
&&
presort
)
...
...
@@ -72,3 +72,4 @@ int ft_read_next(FT_DOCLIST *handler, char *record)
}
return
my_errno
;
}
sql/item_func.cc
View file @
57e4c8ef
...
...
@@ -1903,7 +1903,7 @@ longlong Item_func_inet_aton::val_int()
return
0
;
}
double
Item_func_match
::
val
()
double
Item_func_match
_nl
::
val
()
{
if
(
ft_handler
==
NULL
)
init_search
(
1
);
...
...
@@ -1922,7 +1922,7 @@ double Item_func_match::val()
/* we'll have to find ft_relevance manually in ft_handler array */
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
();
if
((
null_value
=
(
docid
==
HA_OFFSET_ERROR
)))
...
...
@@ -1930,7 +1930,7 @@ double Item_func_match::val()
// 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
)
b
=
c
;
...
...
@@ -1941,7 +1941,6 @@ double Item_func_match::val()
return
docs
[
a
].
weight
;
else
return
0.0
;
}
void
Item_func_match
::
init_search
(
bool
no_order
)
...
...
@@ -1962,16 +1961,14 @@ void Item_func_match::init_search(bool no_order)
char
tmp1
[
FT_QUERY_MAXLEN
];
String
tmp2
(
tmp1
,
sizeof
(
tmp1
));
// MATCH ... AGAINST (NULL) is meaningless, but possible
// 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
);
ft_handler_init
(
ft_tmp
->
ptr
(),
ft_tmp
->
length
(),
join_key
&&
!
no_order
);
if
(
join_key
)
{
...
...
@@ -2024,7 +2021,6 @@ bool Item_func_match::fix_fields(THD *thd,struct st_table_list *tlist)
return
0
;
}
bool
Item_func_match
::
fix_index
()
{
List_iterator_fast
<
Item
>
li
(
fields
);
...
...
sql/item_func.h
View file @
57e4c8ef
...
...
@@ -863,30 +863,40 @@ class Item_func_match :public Item_real_func
uint
key
;
bool
join_key
;
Item_func_match
*
master
;
FT_DOCLIST
*
ft_handler
;
void
*
ft_handler
;
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
()
{
if
(
!
master
)
if
(
!
master
&&
ft_handler
)
{
if
(
ft_handler
)
{
ft_close_search
(
ft_handler
);
if
(
join_key
)
table
->
file
->
ft_handler
=
0
;
}
ft_handler_close
();
if
(
join_key
)
table
->
file
->
ft_handler
=
0
;
}
}
const
char
*
func_name
()
const
{
return
"match"
;
}
virtual
int
ft_handler_init
(
const
byte
*
key
,
uint
keylen
,
bool
presort
)
{
return
1
;
}
virtual
int
ft_handler_close
()
{
return
1
;
}
enum
Functype
functype
()
const
{
return
FT_FUNC
;
}
void
update_used_tables
()
{}
bool
fix_fields
(
THD
*
thd
,
struct
st_table_list
*
tlist
);
bool
eq
(
const
Item
*
)
const
;
double
val
();
longlong
val_int
()
{
return
val
()
!=
0.0
;
}
bool
fix_index
();
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 @
57e4c8ef
...
...
@@ -532,7 +532,7 @@ mysql_select(THD *thd,TABLE_LIST *tables,List<Item> &fields,COND *conds,
// No cache for MATCH
make_join_readinfo
(
&
join
,
(
select_options
&
(
SELECT_DESCRIBE
|
SELECT_NO_JOIN_CACHE
))
|
SELECT_NO_JOIN_CACHE
))
|
(
ftfuncs
.
elements
?
SELECT_NO_JOIN_CACHE
:
0
));
/* Need to tell Innobase that to play it safe, it should fetch all
...
...
@@ -605,7 +605,7 @@ mysql_select(THD *thd,TABLE_LIST *tables,List<Item> &fields,COND *conds,
List_iterator_fast
<
Item_func_match
>
li
(
ftfuncs
);
Item_func_match
*
ifm
;
DBUG_PRINT
(
"info"
,(
"Performing FULLTEXT search"
));
thd
->
proc_info
=
"FULLTEXT search
ing
"
;
thd
->
proc_info
=
"FULLTEXT search
init
"
;
while
((
ifm
=
li
++
))
{
...
...
@@ -1453,15 +1453,15 @@ add_ft_keys(DYNAMIC_ARRAY *keyuse_array,
*
arg1
=
(
Item_func
*
)(
func
->
arguments
()[
1
]);
if
((
functype
==
Item_func
::
GE_FUNC
||
functype
==
Item_func
::
GT_FUNC
)
&&
arg0
->
type
()
==
Item
::
FUNC_ITEM
&&
arg0
->
type
()
==
Item
::
FUNC_ITEM
&&
arg0
->
functype
()
==
Item_func
::
FT_FUNC
&&
arg1
->
const_item
()
&&
arg1
->
val
()
>
=
0
)
arg1
->
const_item
()
&&
arg1
->
val
()
>
0
)
cond_func
=
(
Item_func_match
*
)
arg0
;
else
if
((
functype
==
Item_func
::
LE_FUNC
||
functype
==
Item_func
::
LT_FUNC
)
&&
arg1
->
type
()
==
Item
::
FUNC_ITEM
&&
arg1
->
functype
()
==
Item_func
::
FT_FUNC
&&
arg0
->
const_item
()
&&
arg0
->
val
()
>
=
0
)
arg0
->
const_item
()
&&
arg0
->
val
()
>
0
)
cond_func
=
(
Item_func_match
*
)
arg1
;
}
}
...
...
@@ -1473,7 +1473,7 @@ add_ft_keys(DYNAMIC_ARRAY *keyuse_array,
{
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
that will require it :-)
May be later...
...
...
@@ -3413,7 +3413,7 @@ create_tmp_table(THD *thd,TMP_TABLE_PARAM *param,List<Item> &fields,
temp_pool_slot
=
bitmap_set_next
(
&
temp_pool
);
if
(
temp_pool_slot
!=
MY_BIT_NONE
)
// we got a slot
sprintf
(
path
,
"%s%s_%lx_%i"
,
mysql_tmpdir
,
tmp_file_prefix
,
sprintf
(
path
,
"%s%s_%lx_%i"
,
mysql_tmpdir
,
tmp_file_prefix
,
current_pid
,
temp_pool_slot
);
else
// if we run out of slots or we are not using tempool
sprintf
(
path
,
"%s%s%lx_%lx_%x"
,
mysql_tmpdir
,
tmp_file_prefix
,
current_pid
,
...
...
@@ -5063,7 +5063,7 @@ end_write_group(JOIN *join, JOIN_TAB *join_tab __attribute__((unused)),
/*****************************************************************************
** Remove calculation with tables that aren't yet read. Remove also tests
** against fields that are read through key where the table is not a
** against fields that are read through key where the table is not a
** outer join table.
** We can't remove tests that are made against columns which are stored
** in sorted order.
...
...
@@ -5706,7 +5706,7 @@ static int remove_dup_with_hash_index(THD *thd, TABLE *table,
if
((
error
=
file
->
delete_row
(
record
)))
goto
err
;
continue
;
}
}
/* copy fields to key buffer */
field_length
=
field_lengths
;
...
...
@@ -6242,7 +6242,7 @@ count_field_types(TMP_TABLE_PARAM *param, List<Item> &fields,
List_iterator
<
Item
>
li
(
fields
);
Item
*
field
;
param
->
field_count
=
param
->
sum_func_count
=
param
->
func_count
=
param
->
field_count
=
param
->
sum_func_count
=
param
->
func_count
=
param
->
hidden_field_count
=
0
;
param
->
quick_group
=
1
;
while
((
field
=
li
++
))
...
...
sql/sql_yacc.yy
View file @
57e4c8ef
...
...
@@ -1549,10 +1549,10 @@ simple_expr:
| '{' ident expr '}' { $$= $3; }
| MATCH '(' ident_list ')' AGAINST '(' expr ')'
{ 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 ')'
{ 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); }
| CASE_SYM opt_expr WHEN_SYM when_list opt_else END
{ $$= 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