diff options
author | unknown <serg@infomag.ape.relarn.ru> | 2000-08-17 19:30:36 +0400 |
---|---|---|
committer | unknown <serg@infomag.ape.relarn.ru> | 2000-08-17 19:30:36 +0400 |
commit | f02d7772d9a18c312fba536784511f6858f0706f (patch) | |
tree | 6619554e62beb76cf3c8b15d68b4a3b36f96223a | |
parent | 3843d8e5a7138c71361cd9901eb6f8271ff10f19 (diff) | |
download | mariadb-git-f02d7772d9a18c312fba536784511f6858f0706f.tar.gz |
Many MATCH'es per query now allowed (i.e. AND's and OR's now work, but
slow - full table scan); ORDER BY now works with MATCH (slow, full table
scan)
myisam/ft_eval.c:
ft_read_next compatibility
myisam/ft_test1.c:
ft_read_next compatibility
include/ft_global.h:
ft_read_next redesigned, ft_get_relevance introduced
sql/ha_myisam.cc:
Many MATCH'es per query now allowed
sql/ha_myisam.h:
Many MATCH'es per query now allowed
sql/handler.h:
Many MATCH'es per query now allowed
sql/item_func.cc:
Many MATCH'es per query now allowed
sql/item_func.h:
Many MATCH'es per query now allowed
sql/sql_select.cc:
Many MATCH'es per query now allowed
myisam/ft_search.c:
HA_KEY_NOT_FOUND => HA_END_OF_FILE
-rw-r--r-- | include/ft_global.h | 11 | ||||
-rw-r--r-- | myisam/ft_eval.c | 13 | ||||
-rw-r--r-- | myisam/ft_search.c | 18 | ||||
-rw-r--r-- | myisam/ft_test1.c | 19 | ||||
-rw-r--r-- | sql/ha_myisam.cc | 56 | ||||
-rw-r--r-- | sql/ha_myisam.h | 15 | ||||
-rw-r--r-- | sql/handler.h | 18 | ||||
-rw-r--r-- | sql/item_func.cc | 60 | ||||
-rw-r--r-- | sql/item_func.h | 21 | ||||
-rw-r--r-- | sql/sql_select.cc | 6 |
10 files changed, 121 insertions, 116 deletions
diff --git a/include/ft_global.h b/include/ft_global.h index cbd4ba1a2c2..0de13974027 100644 --- a/include/ft_global.h +++ b/include/ft_global.h @@ -1,15 +1,15 @@ /* Copyright (C) 2000 MySQL AB & MySQL Finland AB & TCX DataKonsult AB - + This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. - + This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - + You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ @@ -43,8 +43,9 @@ typedef struct st_ft_doclist { int ft_init_stopwords(const char **); FT_DOCLIST * ft_init_search(void *, uint, byte *, uint, my_bool); -double ft_read_next(FT_DOCLIST *, char *); -#define ft_close_search(handler) my_free(((gptr)(handler)),MYF(0)) +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) #ifdef __cplusplus } diff --git a/myisam/ft_eval.c b/myisam/ft_eval.c index eeb414a7505..6739e631d8c 100644 --- a/myisam/ft_eval.c +++ b/myisam/ft_eval.c @@ -1,15 +1,15 @@ /* Copyright (C) 2000 MySQL AB & MySQL Finland AB & TCX DataKonsult AB - + This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. - + This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - + You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ @@ -82,7 +82,7 @@ int main(int argc,char *argv[]) if (!silent) printf("- Reading rows with key\n"); for(i=1;create_record(record,qf);i++) { - FT_DOCLIST *result; double w; int t; + FT_DOCLIST *result; double w; int t,err; result=ft_init_search(file,0,blob_record,(uint) strlen(blob_record),1); if(!result) { @@ -91,11 +91,12 @@ int main(int argc,char *argv[]) } if (!silent) printf("Query %d. Found: %d.\n",i,result->ndocs); - for(j=0;(w=ft_read_next(result, read_record))>0;j++) { + for(j=0;(err=ft_read_next(result, read_record))==0;j++) { t=uint2korr(read_record); + w=ft_get_relevance(result); printf("%d %.*s %f\n",i,t,read_record+2,w); } - if(w<0) { + if(err != HA_ERR_KEY_NOT_FOUND) { printf("ft_read_next %d failed with errno %3d\n",j,my_errno); goto err; } diff --git a/myisam/ft_search.c b/myisam/ft_search.c index db3afd3057b..31cbd680406 100644 --- a/myisam/ft_search.c +++ b/myisam/ft_search.c @@ -1,15 +1,15 @@ /* Copyright (C) 2000 MySQL AB & MySQL Finland AB & TCX DataKonsult AB - + This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. - + This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - + You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ @@ -187,7 +187,7 @@ FT_DOCLIST * ft_init_search(void *info, uint keynr, byte *key, goto err; dlist->ndocs=aio.dtree.elements_in_tree; - dlist->curdoc=0; + dlist->curdoc=-1; dlist->info=aio.info; dptr=dlist->doc; @@ -205,19 +205,19 @@ err: return dlist; } -double ft_read_next(FT_DOCLIST *handler, char *record) +int ft_read_next(FT_DOCLIST *handler, char *record) { MI_INFO *info=handler->info; - if (handler->curdoc >= handler->ndocs) - return 0; + if (++handler->curdoc >= handler->ndocs) + return HA_ERR_END_OF_FILE; info->update&= (HA_STATE_CHANGED | HA_STATE_ROW_CHANGED); if (!(*info->read_record)(info,handler->doc[handler->curdoc].dpos,record)) { info->update|= HA_STATE_AKTIV; /* Record is read */ - return handler->doc[handler->curdoc++].weight; + return 0; } - return -my_errno; + return my_errno; } diff --git a/myisam/ft_test1.c b/myisam/ft_test1.c index 377fa808d52..780e4f44b6f 100644 --- a/myisam/ft_test1.c +++ b/myisam/ft_test1.c @@ -1,15 +1,15 @@ /* Copyright (C) 2000 MySQL AB & MySQL Finland AB & TCX DataKonsult AB - + This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. - + This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - + You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ @@ -145,15 +145,16 @@ static int run_test(const char *filename) } printf("Query %d: `%s'. Found: %d. Top five documents:\n", i,query[i],result->ndocs); - for(j=0;j<5;j++) { double w; - w=ft_read_next(result, read_record); - if(w<0) { - printf("ft_read_next %d failed with errno %3d\n",j,my_errno); - break; - } else if (w==0) { + for(j=0;j<5;j++) { double w; int err; + err=ft_read_next(result, read_record); + if(err==HA_ERR_KEY_NOT_FOUND) { printf("No more matches!\n"); break; + } else if (err) { + printf("ft_read_next %d failed with errno %3d\n",j,my_errno); + break; } + w=ft_get_relevance(result); if(key_field == FIELD_VARCHAR) { uint l; char *p; diff --git a/sql/ha_myisam.cc b/sql/ha_myisam.cc index 187cf703ce8..1635c6edf9a 100644 --- a/sql/ha_myisam.cc +++ b/sql/ha_myisam.cc @@ -1,15 +1,15 @@ /* Copyright (C) 2000 MySQL AB & MySQL Finland AB & TCX DataKonsult AB - + This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. - + This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - + You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ @@ -72,7 +72,7 @@ static void mi_check_print_msg(MI_CHECK *param, const char* msg_type, fprintf(stderr, "Failed on my_net_write, writing to stderr instead: %s\n", msgbuf); - return; + return; } extern "C" { @@ -134,7 +134,7 @@ int ha_myisam::net_read_dump(NET* net) goto err; } } - + err: return error; } @@ -186,7 +186,7 @@ int ha_myisam::dump(THD* thd, int fd) my_net_write(net, "", 0); net_flush(net); } - + err: my_free((gptr) buf, MYF(0)); return error; @@ -233,7 +233,7 @@ int ha_myisam::check(THD* thd, HA_CHECK_OPT* check_opt) int error ; MI_CHECK param; MYISAM_SHARE* share = file->s; - + myisamchk_init(¶m); param.thd = thd; param.op_name = (char*)"check"; @@ -241,7 +241,7 @@ int ha_myisam::check(THD* thd, HA_CHECK_OPT* check_opt) param.testflag = check_opt->flags | T_CHECK | T_SILENT; if (check_opt->quick) param.testflag |= T_FAST; - + if (!(table->db_stat & HA_READ_ONLY)) param.testflag|= T_STATISTICS; param.using_global_keycache = 1; @@ -268,7 +268,7 @@ int ha_myisam::check(THD* thd, HA_CHECK_OPT* check_opt) } } if (!error) - { + { if (share->state.changed) { file->update|=HA_STATE_CHANGED | HA_STATE_ROW_CHANGED; @@ -290,7 +290,7 @@ int ha_myisam::check(THD* thd, HA_CHECK_OPT* check_opt) mi_mark_crashed(file); file->update |= HA_STATE_CHANGED | HA_STATE_ROW_CHANGED; } - + return error ? HA_CHECK_CORRUPT : HA_CHECK_OK; } @@ -306,7 +306,7 @@ int ha_myisam::analyze(THD *thd) int error; MI_CHECK param; MYISAM_SHARE* share = file->s; - + myisamchk_init(¶m); param.thd = thd; param.op_name = (char*)" analyze"; @@ -317,7 +317,7 @@ int ha_myisam::analyze(THD *thd) error = chk_key(¶m, file); if (!error) - { + { pthread_mutex_lock(&share->intern_lock); #ifndef HAVE_PREAD pthread_mutex_lock(&THR_LOCK_keycache); // QQ; Has to be removed! @@ -345,7 +345,7 @@ int ha_myisam::repair(THD* thd, HA_CHECK_OPT *check_opt) param.op_name = (char*) "repair"; param.testflag = (check_opt->flags | T_SILENT|T_FORCE_CREATE|T_REP_BY_SORT| T_STATISTICS); - if (check_opt->quick) + if (check_opt->quick) param.opt_rep_quick++; param.sort_buffer_length= check_opt->sort_buffer_size; return repair(thd,param); @@ -365,11 +365,11 @@ int ha_myisam::repair(THD *thd, MI_CHECK ¶m) VOID(fn_format(fixed_name,file->filename,"",MI_NAME_IEXT, 4+ (param.opt_follow_links ? 16 : 0))); if (mi_test_if_sort_rep(file,file->state->records)) - error = mi_repair_by_sort(¶m, file, fixed_name, param.opt_rep_quick); + error = mi_repair_by_sort(¶m, file, fixed_name, param.opt_rep_quick); else - error= mi_repair(¶m, file, fixed_name, param.opt_rep_quick); + error= mi_repair(¶m, file, fixed_name, param.opt_rep_quick); if (!error) - { + { if (share->state.changed) { share->state.changed = 0; @@ -400,7 +400,7 @@ int ha_myisam::repair(THD *thd, MI_CHECK ¶m) if (param.out_flag & O_NEW_DATA) error|=change_to_newfile(fixed_name,MI_NAME_DEXT, DATA_TMP_EXT, 0); - + if (param.out_flag & O_NEW_INDEX) error|=change_to_newfile(fixed_name,MI_NAME_IEXT, INDEX_TMP_EXT,0); @@ -433,7 +433,7 @@ bool ha_myisam::activate_all_index(THD *thd) thd->proc_info="creating index"; myisamchk_init(¶m); param.op_name = (char*) "recreating_index"; - param.testflag = (T_SILENT | T_REP_BY_SORT | + param.testflag = (T_SILENT | T_REP_BY_SORT | T_STATISTICS | T_CREATE_MISSING_KEYS | T_TRUST_HEADER); param.myf_rw&= ~MY_WAIT_IF_FULL; param.sort_buffer_length= myisam_sort_buffer_size; @@ -491,7 +491,7 @@ int ha_myisam::index_prev(byte * buf) table->status=error ? STATUS_NOT_FOUND: 0; return error; } - + int ha_myisam::index_first(byte * buf) { statistic_increment(ha_read_first_count,&LOCK_status); @@ -626,7 +626,7 @@ int ha_myisam::delete_table(const char *name) int ha_myisam::external_lock(THD *thd, int lock_type) { return mi_lock_database(file,lock_type); -} +} THR_LOCK_DATA **ha_myisam::store_lock(THD *thd, @@ -833,8 +833,8 @@ int ha_myisam::create(const char *name, register TABLE *form, ((options & HA_OPTION_CHECKSUM) ? HA_CREATE_CHECKSUM : 0) | ((options & HA_OPTION_DELAY_KEY_WRITE) ? HA_CREATE_DELAY_KEY_WRITE : 0))); - - + + my_free((gptr) recinfo,MYF(0)); DBUG_RETURN(error); } @@ -904,15 +904,13 @@ int ha_myisam::ft_read(byte * buf) { int error; + if (!ft_handler) + return -1; + thread_safe_increment(ha_read_next_count,&LOCK_status); // why ? - if (ft_handler) - ft_relevance=ft_read_next((FT_DOCLIST *) ft_handler,(char*) buf); - else - ft_relevance=0; - error=((ft_relevance == 0) ? HA_ERR_END_OF_FILE : - (ft_relevance > 0) ? 0 : - (int) -ft_relevance); + error=ft_read_next((FT_DOCLIST *) ft_handler,(char*) buf); + table->status=error ? STATUS_NOT_FOUND: 0; return error; } diff --git a/sql/ha_myisam.h b/sql/ha_myisam.h index 8e391f6e3c2..c065c60825d 100644 --- a/sql/ha_myisam.h +++ b/sql/ha_myisam.h @@ -1,15 +1,15 @@ /* Copyright (C) 2000 MySQL AB & MySQL Finland AB & TCX DataKonsult AB - + This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. - + This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - + You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ @@ -37,10 +37,10 @@ class ha_myisam: public handler int_option_flag(HA_READ_NEXT+HA_READ_PREV+HA_READ_RND_SAME+ HA_KEYPOS_TO_RNDPOS+ HA_READ_ORDER+ HA_LASTKEY_ORDER+ HA_HAVE_KEY_READ_ONLY+ HA_READ_NOT_EXACT_KEY+ - HA_LONGLONG_KEYS+ HA_NULL_KEY + + HA_LONGLONG_KEYS+ HA_NULL_KEY + HA_DUPP_POS + HA_BLOB_KEY + HA_AUTO_PART_KEY) {} - ~ha_myisam() { ft_close(); } + ~ha_myisam() {} const char *table_type() const { return "MyISAM"; } const char **bas_ext() const; ulong option_flag() const { return int_option_flag; } @@ -63,9 +63,10 @@ class ha_myisam: public handler int index_first(byte * buf); int index_last(byte * buf); int index_next_same(byte *buf, const byte *key, uint keylen); - int ft_init(uint inx,const byte *key, uint keylen, bool presort); + int ft_init(uint inx,const byte *key, uint keylen, bool presort=1); + void *ft_init_ext(uint inx,const byte *key, uint keylen, bool presort=0) + { return ft_init_search(file,inx,(byte*) key,keylen,presort); } int ft_read(byte *buf); - int ft_close() { if(ft_handler) ft_close_search(ft_handler); ft_handler=0; return 0;} int rnd_init(bool scan=1); int rnd_next(byte *buf); int rnd_pos(byte * buf, byte *pos); diff --git a/sql/handler.h b/sql/handler.h index 208ae989218..c89728b3bbc 100644 --- a/sql/handler.h +++ b/sql/handler.h @@ -1,15 +1,15 @@ /* Copyright (C) 2000 MySQL AB & MySQL Finland AB & TCX DataKonsult AB - + This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. - + This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - + You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ @@ -189,7 +189,6 @@ public: time_t check_time; time_t update_time; ulong mean_rec_length; /* physical reclength */ - double ft_relevance; void *ft_handler; handler(TABLE *table_arg) : table(table_arg),active_index(MAX_REF_PARTS), @@ -198,7 +197,7 @@ public: delete_length(0), auto_increment_value(0), raid_type(0), key_used_on_scan(MAX_KEY), create_time(0), check_time(0), update_time(0), mean_rec_length(0), - ft_relevance(0.0), ft_handler(0) + ft_handler(0) {} virtual ~handler(void) { my_free((char*) ref,MYF(MY_ALLOW_ZERO_PTR)); } int ha_open(const char *name, int mode, int test_if_locked); @@ -231,10 +230,11 @@ public: virtual int index_first(byte * buf)=0; virtual int index_last(byte * buf)=0; virtual int index_next_same(byte *buf, const byte *key, uint keylen); - virtual int ft_init(uint inx,const byte *key, uint keylen, bool presort) - { return -1; } + virtual int ft_init(uint inx,const byte *key, uint keylen, bool presort=1) + { return -1; } + virtual void *ft_init_ext(uint inx,const byte *key, uint keylen, bool presort=0) + { return (void *)NULL; } virtual int ft_read(byte *buf) { return -1; } - virtual int ft_close() { return -1; } virtual int rnd_init(bool scan=1)=0; virtual int rnd_end() { return 0; } virtual int rnd_next(byte *buf)=0; @@ -266,7 +266,7 @@ public: // not implemented by default virtual int net_read_dump(NET* net) { return ER_DUMP_NOT_IMPLEMENTED; } - + /* The following can be called without an open handler */ virtual const char *table_type() const =0; virtual const char **bas_ext() const =0; diff --git a/sql/item_func.cc b/sql/item_func.cc index 90201597873..0f0c444cb32 100644 --- a/sql/item_func.cc +++ b/sql/item_func.cc @@ -1837,43 +1837,49 @@ err: double Item_func_match::val() { - int a,b,c; - FT_DOC *docs; - my_off_t docid; + my_off_t docid=table->file->row_position(); // HAVE to do it here... - docid = table->file->row_position(); // HAVE to do it here... - - if (table->file->ft_handler==NULL && !auto_init_was_done) + if (first_call) { - /* 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); - table->file->ft_init(key, (byte*) ft_tmp->ptr(), ft_tmp->length(), FALSE); - auto_init_was_done=1; + 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; } // Don't know how to return an error from val(), so NULL will be returned - if ((null_value=(table->file->ft_handler==NULL))) + if ((null_value=(ft_handler==NULL))) return 0.0; - if (auto_init_was_done) + if (join_key) { - /* implicit initialization was done, so nobody will set proper - ft_relevance for us. We'll look for it in ft_handler array */ + return ft_get_relevance(ft_handler); + } + else + { + /* implicit initialization was done, so we'll have to find + ft_relevance manually in ft_handler array */ - docs = ((FT_DOCLIST *)table->file->ft_handler)->doc; -// docid = table->file->row_position(); + int a,b,c; + FT_DOC *docs=ft_handler->doc; if ((null_value=(docid==HA_OFFSET_ERROR))) return 0.0; // Assuming docs[] is sorted by dpos... - a=0, b=((FT_DOCLIST *)table->file->ft_handler)->ndocs; - for (c=(a+b)/2; b-a>1; c=(a+b)/2) + for (a=0, b=ft_handler->ndocs, c=(a+b)/2; b-a>1; c=(a+b)/2) { if (docs[c].dpos > docid) b=c; @@ -1881,12 +1887,10 @@ double Item_func_match::val() a=c; } if (docs[a].dpos == docid) - table->file->ft_relevance=docs[a].weight; + return docs[a].weight; else - table->file->ft_relevance=0; + return 0.0; } - - return table->file->ft_relevance; } bool Item_func_match::fix_fields(THD *thd,struct st_table_list *tlist) @@ -1912,8 +1916,6 @@ bool Item_func_match::fix_fields(THD *thd,struct st_table_list *tlist) return 1; const_item_cache=0; table=((Item_field *)fields.head())->field->table; - auto_init_was_done=0; - table->file->ft_close(); // It's a bad solution to do it here, I know :-( return 0; } @@ -1978,7 +1980,7 @@ bool Item_func_match::fix_index() } this->key=max_key; - + first_call=1; maybe_null=1; return 0; diff --git a/sql/item_func.h b/sql/item_func.h index bd66ebde3c2..0e99673ead2 100644 --- a/sql/item_func.h +++ b/sql/item_func.h @@ -1,15 +1,15 @@ /* Copyright (C) 2000 MySQL AB & MySQL Finland AB & TCX DataKonsult AB - + This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. - + This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - + You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ @@ -817,7 +817,7 @@ public: void fix_length_and_dec(); enum Item_result result_type() const; const char *func_name() const { return "get_user_var"; } -}; +}; class Item_func_inet_aton : public Item_int_func { @@ -830,22 +830,23 @@ public: /* SerG: for fulltext search */ +#include <ft_global.h> class Item_func_match :public Item_real_func { public: - // handler *File; List<Item> fields; TABLE *table; uint key; - bool auto_init_was_done; + bool first_call, join_key; + FT_DOCLIST *ft_handler; Item_func_match(List<Item> &a, Item *b): Item_real_func(b), - fields(a), table(0) - {} - ~Item_func_match() {} + fields(a), table(0), ft_handler(0) + {} + ~Item_func_match() { ft_close_search(ft_handler); + if(join_key) table->file->ft_handler=0; } const char *func_name() const { return "match"; } - //optimize_type select_optimize() const { return OPTIMIZE_FT; } enum Functype functype() const { return FT_FUNC; } void update_used_tables() {} bool fix_fields(THD *thd,struct st_table_list *tlist); diff --git a/sql/sql_select.cc b/sql/sql_select.cc index 749bbb5b1f5..fb5125ac79f 100644 --- a/sql/sql_select.cc +++ b/sql/sql_select.cc @@ -476,6 +476,7 @@ mysql_select(THD *thd,TABLE_LIST *tables,List<Item> &fields,COND *conds, as in other cases the join is done before the sort. */ if ((order || group) && join.join_tab[join.const_tables].type != JT_ALL && + join.join_tab[join.const_tables].type != JT_FT && /* Beware! SerG */ (order && simple_order || group && simple_group)) { if (add_ref_to_table_cond(thd,&join.join_tab[join.const_tables])) @@ -4281,7 +4282,7 @@ join_ft_read_first(JOIN_TAB *tab) #endif if ((error=table->file->ft_init(tab->ref.key, tab->ref.key_buff, - tab->ref.key_length,TRUE))) + tab->ref.key_length))) { if (error != HA_ERR_KEY_NOT_FOUND) { @@ -4303,7 +4304,6 @@ join_ft_read_first(JOIN_TAB *tab) table->file->print_error(error,MYF(0)); return 1; } - table->file->ft_close(); return -1; } return 0; @@ -4322,7 +4322,6 @@ join_ft_read_next(READ_RECORD *info) info->file->print_error(error,MYF(0)); return 1; } - info->file->ft_close(); return -1; } return 0; @@ -4974,6 +4973,7 @@ create_sort_index(JOIN_TAB *tab,ORDER *order,ha_rows select_limit) } } else + if (tab->type != JT_FT) /* Beware! SerG */ { /* We have a ref on a const; Change this to a range that filesort |