summaryrefslogtreecommitdiff
path: root/sql
diff options
context:
space:
mode:
authorunknown <serg@serg.mysql.com>2001-11-28 18:01:50 +0100
committerunknown <serg@serg.mysql.com>2001-11-28 18:01:50 +0100
commitd987ee7651cf1ed21d7082399ef02fa551c3e9f5 (patch)
tree0ab79a595aa567c880823477d9a52a1b59b1d1ca /sql
parenta7f23db34072e523cc3aec2a14ce5de47d529c6f (diff)
parentf3918c8413199fff3339a62498ecc42d8c540c3a (diff)
downloadmariadb-git-d987ee7651cf1ed21d7082399ef02fa551c3e9f5.tar.gz
Merge
sql/sql_select.cc: Auto merged Docs/manual.texi: SCCS merged
Diffstat (limited to 'sql')
-rw-r--r--sql/item_func.cc104
-rw-r--r--sql/item_func.h27
-rw-r--r--sql/sql_select.cc4
3 files changed, 46 insertions, 89 deletions
diff --git a/sql/item_func.cc b/sql/item_func.cc
index 86cc3283955..fe68d8f47c2 100644
--- a/sql/item_func.cc
+++ b/sql/item_func.cc
@@ -2004,6 +2004,9 @@ void Item_func_match::init_search(bool no_order)
return;
}
+ if (key == NO_SUCH_KEY)
+ concat=new Item_func_concat_ws (new Item_string(" ",1), fields);
+
String *ft_tmp=0;
char tmp1[FT_QUERY_MAXLEN];
String tmp2(tmp1,sizeof(tmp1));
@@ -2015,7 +2018,8 @@ void Item_func_match::init_search(bool no_order)
tmp2.set("",0);
}
- ft_handler_init(ft_tmp->ptr(), ft_tmp->length(), join_key && !no_order);
+ ft_handler=table->file->ft_init_ext(mode, key,
+ ft_tmp->ptr(), ft_tmp->length(), join_key && !no_order);
if (join_key)
{
@@ -2032,12 +2036,11 @@ bool Item_func_match::fix_fields(THD *thd,struct st_table_list *tlist)
maybe_null=1;
join_key=0;
- /* Serg:
- I'd rather say now that const_item is assumed in quite a bit of
- places, so it would be difficult to remove; If it would ever to be
- removed, this should include modifications to find_best and auto_close
- as complement to auto_init code above.
- */
+ /* const_item is assumed in quite a bit of places, so it would be difficult
+ to remove; If it would ever to be removed, this should include
+ modifications to find_best and auto_close as complement to auto_init code
+ above.
+ */
if (Item_func::fix_fields(thd,tlist) || !const_item())
{
my_error(ER_WRONG_ARGUMENTS,MYF(0),"AGAINST");
@@ -2051,21 +2054,20 @@ bool Item_func_match::fix_fields(THD *thd,struct st_table_list *tlist)
if (item->type() == Item::REF_ITEM)
li.replace(item= *((Item_ref *)item)->ref);
if (item->type() != Item::FIELD_ITEM || !item->used_tables())
- {
- my_error(ER_WRONG_ARGUMENTS,MYF(0),"MATCH");
- return 1;
- }
+ key=NO_SUCH_KEY;
used_tables_cache|=item->used_tables();
}
/* check that all columns come from the same table */
if (count_bits(used_tables_cache) != 1)
+ key=NO_SUCH_KEY;
+ const_item_cache=0;
+ table=((Item_field *)fields.head())->field->table;
+ record=table->record[0];
+ if (key == NO_SUCH_KEY && mode != FT_BOOL)
{
my_error(ER_WRONG_ARGUMENTS,MYF(0),"MATCH");
return 1;
}
- const_item_cache=0;
- table=((Item_field *)fields.head())->field->table;
- record=table->record[0];
return 0;
}
@@ -2074,6 +2076,10 @@ bool Item_func_match::fix_index()
List_iterator_fast<Item> li(fields);
Item_field *item;
uint ft_to_key[MAX_KEY], ft_cnt[MAX_KEY], fts=0, key;
+ uint max_cnt=0, mkeys=0;
+
+ if (this->key == NO_SUCH_KEY)
+ return 0;
for (key=0 ; key<table->keys ; key++)
{
@@ -2087,11 +2093,7 @@ bool Item_func_match::fix_index()
}
if (!fts)
- {
- my_printf_error(ER_FT_MATCHING_KEY_NOT_FOUND,
- ER(ER_FT_MATCHING_KEY_NOT_FOUND),MYF(0));
- return 1;
- }
+ goto err;
while ((item=(Item_field*)(li++)))
{
@@ -2108,7 +2110,6 @@ bool Item_func_match::fix_index()
}
}
- uint max_cnt=0, mkeys=0;
for (key=0 ; key<fts ; key++)
{
if (ft_cnt[key] > max_cnt)
@@ -2139,6 +2140,12 @@ bool Item_func_match::fix_index()
return 0;
}
+err:
+ if (mode == FT_BOOL)
+ {
+ this->key=NO_SUCH_KEY;
+ return 0;
+ }
my_printf_error(ER_FT_MATCHING_KEY_NOT_FOUND,
ER(ER_FT_MATCHING_KEY_NOT_FOUND),MYF(0));
return 1;
@@ -2174,61 +2181,18 @@ double Item_func_match::val()
join_key=0;
}
- my_off_t docid=table->file->row_position();
-
- if ((null_value=(docid==HA_OFFSET_ERROR)))
- return 0.0;
- else
- return ft_handler->please->find_relevance(ft_handler, docid, record);
-}
-
-#if 0
-double Item_func_match_nl::val()
-{
- if (ft_handler==NULL)
- init_search(1);
-
- if ((null_value= (ft_handler==NULL)))
- return 0.0;
-
- if (join_key)
+ if (key == NO_SUCH_KEY)
{
- if (table->file->ft_handler)
- return ft_handler->please->get_relevance(ft_handler);
-
- join_key=0;
+ String *a=concat->val_str(&value);
+ if (null_value=(a==0))
+ return 0;
+ return ft_handler->please->find_relevance(ft_handler,
+ (byte *)a->ptr(), a->length());
}
-
- my_off_t docid=table->file->row_position();
-
- if ((null_value=(docid==HA_OFFSET_ERROR)))
- return 0.0;
else
- return ft_handler->please->find_relevance(ft_handler, docid, record);
+ return ft_handler->please->find_relevance(ft_handler, record, 0);
}
-double Item_func_match_bool::val()
-{
- if (ft_handler==NULL)
- init_search(1);
-
- if ((null_value= (ft_handler==NULL)))
- return 0.0;
-
- if (join_key)
- {
- if (table->file->ft_handler)
- return ft_handler->please->get_relevance(ft_handler);
-
- join_key=0;
- }
-
- return ft_handler->please->find_relevance(ft_handler, docid, record);
- //null_value=1;
- //return -1.0;
-}
-#endif
-
/***************************************************************************
System variables
This has to be recoded after we get more than 3 system variables
diff --git a/sql/item_func.h b/sql/item_func.h
index 182daf9f74e..2bf272f24ed 100644
--- a/sql/item_func.h
+++ b/sql/item_func.h
@@ -862,15 +862,18 @@ class Item_func_match :public Item_real_func
{
public:
List<Item> fields;
+ Item *concat;
+ String value;
TABLE *table;
- uint key;
+ uint key, mode;
bool join_key;
Item_func_match *master;
FT_INFO * ft_handler;
byte *record;
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),
+ key(0), concat(0) {}
~Item_func_match()
{
if (!master && ft_handler)
@@ -880,8 +883,8 @@ public:
if(join_key)
table->file->ft_handler=0;
}
+ if (concat) delete concat;
}
- virtual int ft_handler_init(const byte *key, uint keylen, bool presort) =0;
enum Functype functype() const { return FT_FUNC; }
void update_used_tables() {}
bool fix_fields(THD *thd,struct st_table_list *tlist);
@@ -896,26 +899,16 @@ public:
class Item_func_match_nl :public Item_func_match
{
public:
- Item_func_match_nl(List<Item> &a, Item *b): Item_func_match(a,b) {}
+ Item_func_match_nl(List<Item> &a, Item *b):
+ Item_func_match(a,b) { mode=FT_NL; }
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(FT_NL,key, query, querylen, presort);
- return 0;
- }
};
class Item_func_match_bool :public Item_func_match
{
public:
- Item_func_match_bool(List<Item> &a, Item *b): Item_func_match(a,b) {}
+ Item_func_match_bool(List<Item> &a, Item *b):
+ Item_func_match(a,b) { mode=FT_BOOL; }
const char *func_name() const { return "match_bool"; }
-// double val();
- int ft_handler_init(const byte *query, uint querylen, bool presort)
- {
- ft_handler=table->file->ft_init_ext(FT_BOOL,key, query, querylen, presort);
- return 0;
- }
};
diff --git a/sql/sql_select.cc b/sql/sql_select.cc
index ae9477d048e..660702d4117 100644
--- a/sql/sql_select.cc
+++ b/sql/sql_select.cc
@@ -1457,7 +1457,7 @@ add_ft_keys(DYNAMIC_ARRAY *keyuse_array,
{
Item *item;
/*
- I, (Sergei) too lazy to implement proper recursive descent here,
+ 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...
@@ -1474,7 +1474,7 @@ add_ft_keys(DYNAMIC_ARRAY *keyuse_array,
}
}
- if (!cond_func)
+ if (!cond_func || cond_func->key == NO_SUCH_KEY)
return;
KEYUSE keyuse;