summaryrefslogtreecommitdiff
path: root/sql/item_func.cc
diff options
context:
space:
mode:
authorserg@infomag.ape.relarn.ru <>2000-08-28 17:43:58 +0400
committerserg@infomag.ape.relarn.ru <>2000-08-28 17:43:58 +0400
commiteb8ad15751606cf9203caff2515ac868dd03c8d0 (patch)
tree485c3b99b43fae8c2b58b7a5ab72b383265423d2 /sql/item_func.cc
parent6236dfc7a34cd528b5d11fad4ce32d230720ce44 (diff)
downloadmariadb-git-eb8ad15751606cf9203caff2515ac868dd03c8d0.tar.gz
ft_optimization: identical queries merging. collection -> fulltext. Bugs fixed.
**************** !!! NOTE EVERYBODY: SYNTAX CHANGED !!! ******************** There's no COLLECTIONs now, full-text indexes can be created via the word FULLTEXT, which should be used like UNIQUE.
Diffstat (limited to 'sql/item_func.cc')
-rw-r--r--sql/item_func.cc69
1 files changed, 50 insertions, 19 deletions
diff --git a/sql/item_func.cc b/sql/item_func.cc
index 66e03e72f6b..65677690ed3 100644
--- a/sql/item_func.cc
+++ b/sql/item_func.cc
@@ -1837,26 +1837,8 @@ err:
double Item_func_match::val()
{
- my_off_t docid=table->file->row_position(); // HAVE to do it here...
-
if (first_call)
- {
- if (join_key=(table->file->get_index() == key &&
- (ft_handler=(FT_DOCLIST *)table->file->ft_handler)))
- ;
- else
- {
- /* join won't use this ft-key, but we must to init it anyway */
- String *ft_tmp=0;
- char tmp1[FT_QUERY_MAXLEN];
- String tmp2(tmp1,sizeof(tmp1));
-
- ft_tmp=key_item()->val_str(&tmp2);
- ft_handler=(FT_DOCLIST *)
- table->file->ft_init_ext(key, (byte*) ft_tmp->ptr(), ft_tmp->length());
- }
- first_call=0;
- }
+ init_search();
// Don't know how to return an error from val(), so NULL will be returned
if ((null_value=(ft_handler==NULL)))
@@ -1873,6 +1855,7 @@ double Item_func_match::val()
int a,b,c;
FT_DOC *docs=ft_handler->doc;
+ my_off_t docid=table->file->row_position();
if ((null_value=(docid==HA_OFFSET_ERROR)))
return 0.0;
@@ -1893,6 +1876,36 @@ double Item_func_match::val()
}
}
+void Item_func_match::init_search()
+{
+ if (!first_call)
+ return;
+ first_call=false;
+
+ if (master)
+ {
+ master->init_search();
+ ft_handler=master->ft_handler;
+ join_key=master->join_key;
+ return;
+ }
+
+ if (join_key)
+ {
+ ft_handler=((FT_DOCLIST *)table->file->ft_handler);
+ return;
+ }
+
+ /* join won't use this ft-key, but we must to init it anyway */
+ String *ft_tmp=0;
+ char tmp1[FT_QUERY_MAXLEN];
+ String tmp2(tmp1,sizeof(tmp1));
+
+ ft_tmp=key_item()->val_str(&tmp2);
+ ft_handler=(FT_DOCLIST *)
+ table->file->ft_init_ext(key, (byte*) ft_tmp->ptr(), ft_tmp->length());
+}
+
bool Item_func_match::fix_fields(THD *thd,struct st_table_list *tlist)
{
List_iterator<Item> li(fields);
@@ -1982,6 +1995,24 @@ bool Item_func_match::fix_index()
this->key=max_key;
first_call=1;
maybe_null=1;
+ join_key=0;
+
+ return 0;
+}
+
+bool Item_func_match::eq(const Item *item) const
+{
+ if (item->type() != FUNC_ITEM)
+ return 0;
+
+ if (func_name() != ((Item_func*)item)->func_name())
+ return 0;
+
+ Item_func_match *ifm=(Item_func_match*) item;
+
+ if (key == ifm->key && table == ifm->table &&
+ key_item()->eq(ifm->key_item()))
+ return 1;
return 0;
}