Commit ff8df2c4 authored by serg@serg.mysql.com's avatar serg@serg.mysql.com
Browse files

Ill-minded FULLTEXT impilict initialization hack removed.

From now on FULLTEXT search is initialized expilictly in mysql_select()
parent a896b872
Loading
Loading
Loading
Loading
+0 −4
Original line number Diff line number Diff line
@@ -158,7 +158,6 @@ FT_DOCLIST * ft_init_search(void *info, uint keynr, byte *key,
  ALL_IN_ONE aio;
  FT_DOCLIST *dlist;
  FT_DOC     *dptr;
  my_off_t    saved_lastpos;

/* black magic ON */
  if ((int) (keynr = _mi_check_index((MI_INFO *)info,keynr)) < 0)
@@ -174,8 +173,6 @@ FT_DOCLIST * ft_init_search(void *info, uint keynr, byte *key,
  aio.keyinfo=aio.info->s->keyinfo+keynr;
  aio.key_root=aio.info->s->state.key_root[keynr];

  saved_lastpos=aio.info->lastpos;

  if (!(wtree=ft_parse(NULL,key,key_len))) return NULL;

  init_tree(&aio.dtree,0,sizeof(FT_SUPERDOC),(qsort_cmp)&FT_SUPERDOC_cmp,0,
@@ -204,7 +201,6 @@ FT_DOCLIST * ft_init_search(void *info, uint keynr, byte *key,
  }

err:
  aio.info->lastpos=saved_lastpos;
  delete_tree(&aio.dtree);
  delete_tree(wtree);
  my_free((char*) wtree,MYF(0));
+8 −22
Original line number Diff line number Diff line
@@ -1079,20 +1079,6 @@ ha_rows ha_myisam::records_in_range(int inx,
				       end_search_flag);
}

int ha_myisam::ft_init(uint inx, const byte *key, uint keylen, bool presort)
{
  if (ft_handler)
    return -1;

  // Do the search!
  ft_handler=ft_init_search(file,inx,(byte*) key,keylen,presort);

  if (!ft_handler)
    return (my_errno ? my_errno : -1);

  return 0;
}

int ha_myisam::ft_read(byte * buf)
{
  int error;
+3 −2
Original line number Diff line number Diff line
@@ -71,8 +71,9 @@ 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=1);
  void *ft_init_ext(uint inx,const byte *key, uint keylen, bool presort=0)
  int ft_init()
         { if(!ft_handler) return 1; ft_reinit_search(ft_handler); return 0; }
  void *ft_init_ext(uint inx,const byte *key, uint keylen, bool presort)
               { return ft_init_search(file,inx,(byte*) key,keylen,presort); }
  int ft_read(byte *buf);
  int rnd_init(bool scan=1);
+3 −3
Original line number Diff line number Diff line
@@ -222,9 +222,9 @@ class handler :public Sql_alloc
  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=1)
  virtual int ft_init()
                                 { return -1; }
  virtual void *ft_init_ext(uint inx,const byte *key, uint keylen, bool presort=0)
  virtual void *ft_init_ext(uint inx,const byte *key, uint keylen, bool presort)
                                 { return (void *)NULL; }
  virtual int ft_read(byte *buf) { return -1; }
  virtual int rnd_init(bool scan=1)=0;
+11 −16
Original line number Diff line number Diff line
@@ -1840,9 +1840,6 @@ longlong Item_func_inet_aton::val_int()

double Item_func_match::val()
{
  if (first_call)
    init_search();

  // Don't know how to return an error from val(), so NULL will be returned
  if ((null_value=(ft_handler==NULL)))
    return 0.0;
@@ -1853,8 +1850,7 @@ double Item_func_match::val()
  }
  else
  {
    /* implicit initialization was done, so we'll have to find
       ft_relevance manually in ft_handler array */
    /* we'll have to find ft_relevance manually in ft_handler array */

    int a,b,c;
    FT_DOC  *docs=ft_handler->doc;
@@ -1881,9 +1877,8 @@ double Item_func_match::val()

void Item_func_match::init_search()
{
  if (!first_call)
  if (ft_handler)
    return;
  first_call=false;

  if (master)
  {
@@ -1893,20 +1888,19 @@ void Item_func_match::init_search()
    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());
     table->file->ft_init_ext(key, (byte*) ft_tmp->ptr(), ft_tmp->length(), join_key);

  if (join_key)
  {
    table->file->ft_handler=ft_handler;
    return;
  }
}

bool Item_func_match::fix_fields(THD *thd,struct st_table_list *tlist)
@@ -1917,6 +1911,8 @@ bool Item_func_match::fix_fields(THD *thd,struct st_table_list *tlist)
  /* Why testing for const_item ? Monty */
  /* I'll remove it later, but this should include modifications to
     find_best and auto_close as complement to auto_init code above. SerG */
  /* I'd rather say now that const_item is assumed in quite a bit of
     places, so it would be difficult to remove. SerG */
  if (Item_func::fix_fields(thd,tlist) || !const_item())
    return 1;

@@ -1996,7 +1992,6 @@ bool Item_func_match::fix_index()
  }

  this->key=max_key;
  first_call=1;
  maybe_null=1;
  join_key=0;

Loading