Commit 680d0219 authored by unknown's avatar unknown

removed ftfuncs argument for mysql_select

it uses now thd->lex.ftfunc_list
moved ft-initialization to a separate function
re-disabled implicit ft initialization


sql/item_func.cc:
  re-disabled implicit initialization that was re-enabled (by me)
  for reasons unknown (at least the code passed all the tests)
sql/mysql_priv.h:
  removed ftfuncs argument for mysql_select
  it uses now thd->lex.ftfunc_list
  moved ft-initialization to a separate function
sql/sql_base.cc:
  removed ftfuncs argument for mysql_select
  it uses now thd->lex.ftfunc_list
  moved ft-initialization to a separate function
sql/sql_parse.cc:
  removed ftfuncs argument for mysql_select
  it uses now thd->lex.ftfunc_list
  moved ft-initialization to a separate function
sql/sql_select.cc:
  removed ftfuncs argument for mysql_select
  it uses now thd->lex.ftfunc_list
  moved ft-initialization to a separate function
parent e6309ed9
...@@ -1906,10 +1906,7 @@ err: ...@@ -1906,10 +1906,7 @@ err:
double Item_func_match::val() double Item_func_match::val()
{ {
if (ft_handler==NULL) if (ft_handler==NULL)
init_search(1); return -1.0;
if ((null_value= (ft_handler==NULL)))
return 0.0;
if (join_key) if (join_key)
{ {
......
...@@ -309,7 +309,6 @@ int setup_order(THD *thd,TABLE_LIST *tables, List<Item> &fields, ...@@ -309,7 +309,6 @@ int setup_order(THD *thd,TABLE_LIST *tables, List<Item> &fields,
List <Item> &all_fields, ORDER *order); List <Item> &all_fields, ORDER *order);
int mysql_select(THD *thd,TABLE_LIST *tables,List<Item> &list,COND *conds, int mysql_select(THD *thd,TABLE_LIST *tables,List<Item> &list,COND *conds,
List<Item_func_match> &ftfuncs,
ORDER *order, ORDER *group,Item *having,ORDER *proc_param, ORDER *order, ORDER *group,Item *having,ORDER *proc_param,
uint select_type,select_result *result); uint select_type,select_result *result);
Field *create_tmp_field(TABLE *table,Item *item, Item::Type type, Field *create_tmp_field(TABLE *table,Item *item, Item::Type type,
...@@ -417,7 +416,8 @@ bool setup_tables(TABLE_LIST *tables); ...@@ -417,7 +416,8 @@ bool setup_tables(TABLE_LIST *tables);
int setup_fields(THD *thd,TABLE_LIST *tables,List<Item> &item, int setup_fields(THD *thd,TABLE_LIST *tables,List<Item> &item,
bool set_query_id,List<Item> *sum_func_list); bool set_query_id,List<Item> *sum_func_list);
int setup_conds(THD *thd,TABLE_LIST *tables,COND **conds); int setup_conds(THD *thd,TABLE_LIST *tables,COND **conds);
int setup_ftfuncs(THD *thd,TABLE_LIST *tables, List<Item_func_match> &ftfuncs); int setup_ftfuncs(THD *thd);
int init_ftfuncs(THD *thd, bool no_order);
void wait_for_refresh(THD *thd); void wait_for_refresh(THD *thd);
int open_tables(THD *thd,TABLE_LIST *tables); int open_tables(THD *thd,TABLE_LIST *tables);
int open_and_lock_tables(THD *thd,TABLE_LIST *tables); int open_and_lock_tables(THD *thd,TABLE_LIST *tables);
......
...@@ -2199,17 +2199,18 @@ bool remove_table_from_cache(THD *thd, const char *db, const char *table_name, ...@@ -2199,17 +2199,18 @@ bool remove_table_from_cache(THD *thd, const char *db, const char *table_name,
DBUG_RETURN(result); DBUG_RETURN(result);
} }
int setup_ftfuncs(THD *thd,TABLE_LIST *tables, List<Item_func_match> &ftfuncs) int setup_ftfuncs(THD *thd)
{ {
List_iterator<Item_func_match> li(ftfuncs), li2(ftfuncs); List_iterator<Item_func_match> li(thd->lex.ftfunc_list),
lj(thd->lex.ftfunc_list);
Item_func_match *ftf, *ftf2; Item_func_match *ftf, *ftf2;
while ((ftf=li++)) while ((ftf=li++))
{ {
if (ftf->fix_index()) if (ftf->fix_index())
return 1; return 1;
li2.rewind(); lj.rewind();
while ((ftf2=li2++) != ftf) while ((ftf2=lj++) != ftf)
{ {
if (ftf->eq(ftf2) && !ftf2->master) if (ftf->eq(ftf2) && !ftf2->master)
ftf2->master=ftf; ftf2->master=ftf;
...@@ -2218,3 +2219,19 @@ int setup_ftfuncs(THD *thd,TABLE_LIST *tables, List<Item_func_match> &ftfuncs) ...@@ -2218,3 +2219,19 @@ int setup_ftfuncs(THD *thd,TABLE_LIST *tables, List<Item_func_match> &ftfuncs)
return 0; return 0;
} }
int init_ftfuncs(THD *thd, bool no_order)
{
List_iterator<Item_func_match> li(thd->lex.ftfunc_list);
Item_func_match *ifm;
DBUG_PRINT("info",("Performing FULLTEXT search"));
thd->proc_info="FULLTEXT initialization";
while ((ifm=li++))
{
ifm->init_search(no_order);
}
return 0;
}
...@@ -1133,7 +1133,6 @@ mysql_execute_command(void) ...@@ -1133,7 +1133,6 @@ mysql_execute_command(void)
{ {
res=mysql_select(thd,tables,lex->item_list, res=mysql_select(thd,tables,lex->item_list,
lex->where, lex->where,
lex->ftfunc_list,
(ORDER*) lex->order_list.first, (ORDER*) lex->order_list.first,
(ORDER*) lex->group_list.first, (ORDER*) lex->group_list.first,
lex->having, lex->having,
...@@ -1283,7 +1282,6 @@ mysql_execute_command(void) ...@@ -1283,7 +1282,6 @@ mysql_execute_command(void)
{ {
res=mysql_select(thd,tables->next,lex->item_list, res=mysql_select(thd,tables->next,lex->item_list,
lex->where, lex->where,
lex->ftfunc_list,
(ORDER*) lex->order_list.first, (ORDER*) lex->order_list.first,
(ORDER*) lex->group_list.first, (ORDER*) lex->group_list.first,
lex->having, lex->having,
...@@ -1577,7 +1575,6 @@ mysql_execute_command(void) ...@@ -1577,7 +1575,6 @@ mysql_execute_command(void)
{ {
res=mysql_select(thd,tables->next,lex->item_list, res=mysql_select(thd,tables->next,lex->item_list,
lex->where, lex->where,
lex->ftfunc_list,
(ORDER*) lex->order_list.first, (ORDER*) lex->order_list.first,
(ORDER*) lex->group_list.first, (ORDER*) lex->group_list.first,
lex->having, lex->having,
......
...@@ -35,11 +35,10 @@ const char *join_type_str[]={ "UNKNOWN","system","const","eq_ref","ref", ...@@ -35,11 +35,10 @@ const char *join_type_str[]={ "UNKNOWN","system","const","eq_ref","ref",
"MAYBE_REF","ALL","range","index","fulltext" }; "MAYBE_REF","ALL","range","index","fulltext" };
static bool make_join_statistics(JOIN *join,TABLE_LIST *tables,COND *conds, static bool make_join_statistics(JOIN *join,TABLE_LIST *tables,COND *conds,
DYNAMIC_ARRAY *keyuse,List<Item_func_match> &ftfuncs); DYNAMIC_ARRAY *keyuse);
static bool update_ref_and_keys(THD *thd, DYNAMIC_ARRAY *keyuse, static bool update_ref_and_keys(THD *thd, DYNAMIC_ARRAY *keyuse,
JOIN_TAB *join_tab, JOIN_TAB *join_tab,
uint tables,COND *conds,table_map table_map, uint tables,COND *conds,table_map table_map);
List<Item_func_match> &ftfuncs);
static int sort_keyuse(KEYUSE *a,KEYUSE *b); static int sort_keyuse(KEYUSE *a,KEYUSE *b);
static void set_position(JOIN *join,uint index,JOIN_TAB *table,KEYUSE *key); static void set_position(JOIN *join,uint index,JOIN_TAB *table,KEYUSE *key);
static void find_best_combination(JOIN *join,table_map rest_tables); static void find_best_combination(JOIN *join,table_map rest_tables);
...@@ -150,7 +149,6 @@ static void describe_info(THD *thd, const char *info); ...@@ -150,7 +149,6 @@ static void describe_info(THD *thd, const char *info);
int int
mysql_select(THD *thd,TABLE_LIST *tables,List<Item> &fields,COND *conds, mysql_select(THD *thd,TABLE_LIST *tables,List<Item> &fields,COND *conds,
List<Item_func_match> &ftfuncs,
ORDER *order, ORDER *group,Item *having,ORDER *proc_param, ORDER *order, ORDER *group,Item *having,ORDER *proc_param,
uint select_options,select_result *result) uint select_options,select_result *result)
{ {
...@@ -193,7 +191,7 @@ mysql_select(THD *thd,TABLE_LIST *tables,List<Item> &fields,COND *conds, ...@@ -193,7 +191,7 @@ mysql_select(THD *thd,TABLE_LIST *tables,List<Item> &fields,COND *conds,
if (having->with_sum_func) if (having->with_sum_func)
having->split_sum_func(all_fields); having->split_sum_func(all_fields);
} }
if (setup_ftfuncs(thd,tables,ftfuncs)) /* should be after having->fix_fields */ if (setup_ftfuncs(thd)) /* should be after having->fix_fields */
DBUG_RETURN(-1); DBUG_RETURN(-1);
/* /*
Check if one one uses a not constant column with group functions Check if one one uses a not constant column with group functions
...@@ -378,7 +376,7 @@ mysql_select(THD *thd,TABLE_LIST *tables,List<Item> &fields,COND *conds, ...@@ -378,7 +376,7 @@ mysql_select(THD *thd,TABLE_LIST *tables,List<Item> &fields,COND *conds,
/* Calculate how to do the join */ /* Calculate how to do the join */
thd->proc_info="statistics"; thd->proc_info="statistics";
if (make_join_statistics(&join,tables,conds,&keyuse,ftfuncs) || if (make_join_statistics(&join,tables,conds,&keyuse) ||
thd->fatal_error) thd->fatal_error)
goto err; goto err;
thd->proc_info="preparing"; thd->proc_info="preparing";
...@@ -493,8 +491,8 @@ mysql_select(THD *thd,TABLE_LIST *tables,List<Item> &fields,COND *conds, ...@@ -493,8 +491,8 @@ mysql_select(THD *thd,TABLE_LIST *tables,List<Item> &fields,COND *conds,
(group && order) || (group && order) ||
test(select_options & OPTION_BUFFER_RESULT))); test(select_options & OPTION_BUFFER_RESULT)));
make_join_readinfo(&join, (select_options & SELECT_DESCRIBE) | make_join_readinfo(&join, (select_options & SELECT_DESCRIBE) |
(ftfuncs.elements ? 0 : SELECT_USE_CACHE)); // No cache for MATCH (thd->lex.ftfunc_list.elements ? 0 : SELECT_USE_CACHE)); // No cache for MATCH
/* Need to tell Innobase that to play it safe, it should fetch all /* Need to tell Innobase that to play it safe, it should fetch all
columns of the tables: this is because MySQL columns of the tables: this is because MySQL
...@@ -560,18 +558,8 @@ mysql_select(THD *thd,TABLE_LIST *tables,List<Item> &fields,COND *conds, ...@@ -560,18 +558,8 @@ mysql_select(THD *thd,TABLE_LIST *tables,List<Item> &fields,COND *conds,
} }
/* Perform FULLTEXT search before all regular searches */ /* Perform FULLTEXT search before all regular searches */
if (ftfuncs.elements) init_ftfuncs(thd, test(order));
{
List_iterator<Item_func_match> li(ftfuncs);
Item_func_match *ifm;
DBUG_PRINT("info",("Performing FULLTEXT search"));
thd->proc_info="FULLTEXT searching";
while ((ifm=li++))
{
ifm->init_search(test(order));
}
}
/* Create a tmp table if distinct or if the sort is too complicated */ /* Create a tmp table if distinct or if the sort is too complicated */
if (need_tmp) if (need_tmp)
{ {
...@@ -833,8 +821,7 @@ static ha_rows get_quick_record_count(SQL_SELECT *select,TABLE *table, ...@@ -833,8 +821,7 @@ static ha_rows get_quick_record_count(SQL_SELECT *select,TABLE *table,
static bool static bool
make_join_statistics(JOIN *join,TABLE_LIST *tables,COND *conds, make_join_statistics(JOIN *join,TABLE_LIST *tables,COND *conds,
DYNAMIC_ARRAY *keyuse_array, DYNAMIC_ARRAY *keyuse_array)
List<Item_func_match> &ftfuncs)
{ {
int error; int error;
uint i,table_count,const_count,found_ref,refs,key,const_ref,eq_part; uint i,table_count,const_count,found_ref,refs,key,const_ref,eq_part;
...@@ -946,7 +933,7 @@ make_join_statistics(JOIN *join,TABLE_LIST *tables,COND *conds, ...@@ -946,7 +933,7 @@ make_join_statistics(JOIN *join,TABLE_LIST *tables,COND *conds,
if (conds || outer_join) if (conds || outer_join)
if (update_ref_and_keys(join->thd,keyuse_array,stat,join->tables, if (update_ref_and_keys(join->thd,keyuse_array,stat,join->tables,
conds,~outer_join,ftfuncs)) conds,~outer_join))
DBUG_RETURN(1); DBUG_RETURN(1);
/* loop until no more const tables are found */ /* loop until no more const tables are found */
...@@ -1453,8 +1440,7 @@ sort_keyuse(KEYUSE *a,KEYUSE *b) ...@@ -1453,8 +1440,7 @@ sort_keyuse(KEYUSE *a,KEYUSE *b)
static bool static bool
update_ref_and_keys(THD *thd, DYNAMIC_ARRAY *keyuse,JOIN_TAB *join_tab, update_ref_and_keys(THD *thd, DYNAMIC_ARRAY *keyuse,JOIN_TAB *join_tab,
uint tables, COND *cond, table_map normal_tables, uint tables, COND *cond, table_map normal_tables)
List<Item_func_match> &ftfuncs)
{ {
uint and_level,i,found_eq_constant; uint and_level,i,found_eq_constant;
...@@ -1482,7 +1468,7 @@ update_ref_and_keys(THD *thd, DYNAMIC_ARRAY *keyuse,JOIN_TAB *join_tab, ...@@ -1482,7 +1468,7 @@ update_ref_and_keys(THD *thd, DYNAMIC_ARRAY *keyuse,JOIN_TAB *join_tab,
add_key_part(keyuse,field); add_key_part(keyuse,field);
} }
if (ftfuncs.elements) if (thd->lex.ftfunc_list.elements)
{ {
add_ft_keys(keyuse,join_tab,cond,normal_tables); add_ft_keys(keyuse,join_tab,cond,normal_tables);
} }
......
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