~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to storage/myisam/mi_delete.c

  • Committer: Brian Aker
  • Date: 2008-07-06 07:32:43 UTC
  • Revision ID: brian@tangent.org-20080706073243-bah88yxqo79m2tpj
Next pass on fulltext.

Show diffs side-by-side

added added

removed removed

Lines of Context:
15
15
 
16
16
/* Remove a row from a MyISAM table */
17
17
 
18
 
#include "fulltext.h"
 
18
#include "myisamdef.h"
19
19
 
20
20
static int d_search(MI_INFO *info,MI_KEYDEF *keyinfo,uint comp_flag,
21
21
                    uchar *key,uint key_length,my_off_t page,uchar *anc_buff);
75
75
    if (mi_is_key_active(info->s->state.key_map, i))
76
76
    {
77
77
      info->s->keyinfo[i].version++;
78
 
      if (info->s->keyinfo[i].flag & HA_FULLTEXT )
79
 
      {
80
 
        if (_mi_ft_del(info,i, old_key,record,info->lastpos))
81
 
          goto err;
82
 
      }
83
 
      else
84
78
      {
85
79
        if (info->s->keyinfo[i].ck_delete(info,i,old_key,
86
80
                _mi_make_key(info,i,old_key,record,info->lastpos)))
167
161
    error= -1;
168
162
    goto err;
169
163
  }
170
 
  if ((error=d_search(info,keyinfo,
171
 
                      (keyinfo->flag & HA_FULLTEXT ? SEARCH_FIND | SEARCH_UPDATE
172
 
                                                   : SEARCH_SAME),
173
 
                       key,key_length,old_root,root_buff)) >0)
 
164
  if ((error=d_search(info,keyinfo, (SEARCH_SAME), key,key_length,old_root,root_buff)) > 0)
174
165
  {
175
166
    if (error == 2)
176
167
    {
232
223
  }
233
224
  nod_flag=mi_test_if_nod(anc_buff);
234
225
 
235
 
  if (!flag && keyinfo->flag & HA_FULLTEXT)
236
 
  {
237
 
    uint off;
238
 
    int  subkeys;
239
 
 
240
 
    get_key_full_length_rdonly(off, lastkey);
241
 
    subkeys=ft_sintXkorr(lastkey+off);
242
 
    DBUG_ASSERT(info->ft1_to_ft2==0 || subkeys >=0);
243
 
    comp_flag=SEARCH_SAME;
244
 
    if (subkeys >= 0)
245
 
    {
246
 
      /* normal word, one-level tree structure */
247
 
      if (info->ft1_to_ft2)
248
 
      {
249
 
        /* we're in ft1->ft2 conversion mode. Saving key data */
250
 
        insert_dynamic(info->ft1_to_ft2, (lastkey+off));
251
 
      }
252
 
      else
253
 
      {
254
 
        /* we need exact match only if not in ft1->ft2 conversion mode */
255
 
        flag=(*keyinfo->bin_search)(info,keyinfo,anc_buff,key,USE_WHOLE_KEY,
256
 
                                    comp_flag, &keypos, lastkey, &last_key);
257
 
      }
258
 
      /* fall through to normal delete */
259
 
    }
260
 
    else
261
 
    {
262
 
      /* popular word. two-level tree. going down */
263
 
      uint tmp_key_length;
264
 
      my_off_t root;
265
 
      uchar *kpos=keypos;
266
 
 
267
 
      if (!(tmp_key_length=(*keyinfo->get_key)(keyinfo,nod_flag,&kpos,lastkey)))
268
 
      {
269
 
        mi_print_error(info->s, HA_ERR_CRASHED);
270
 
        my_errno= HA_ERR_CRASHED;
271
 
        DBUG_RETURN(-1);
272
 
      }
273
 
      root=_mi_dpos(info,nod_flag,kpos);
274
 
      if (subkeys == -1)
275
 
      {
276
 
        /* the last entry in sub-tree */
277
 
        if (_mi_dispose(info, keyinfo, root,DFLT_INIT_HITS))
278
 
          DBUG_RETURN(-1);
279
 
        /* fall through to normal delete */
280
 
      }
281
 
      else
282
 
      {
283
 
        keyinfo=&info->s->ft2_keyinfo;
284
 
        kpos-=keyinfo->keylength+nod_flag; /* we'll modify key entry 'in vivo' */
285
 
        get_key_full_length_rdonly(off, key);
286
 
        key+=off;
287
 
        ret_value=_mi_ck_real_delete(info, &info->s->ft2_keyinfo,
288
 
            key, HA_FT_WLEN, &root);
289
 
        _mi_dpointer(info, kpos+HA_FT_WLEN, root);
290
 
        subkeys++;
291
 
        ft_intXstore(kpos, subkeys);
292
 
        if (!ret_value)
293
 
          ret_value=_mi_write_keypage(info,keyinfo,page,
294
 
                                      DFLT_INIT_HITS,anc_buff);
295
 
        DBUG_PRINT("exit",("Return: %d",ret_value));
296
 
        DBUG_RETURN(ret_value);
297
 
      }
298
 
    }
299
 
  }
300
226
  leaf_buff= 0;
301
227
  if (nod_flag)
302
228
  {