~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to storage/myisam/mi_delete.c

Merging trunk changes from over weekend.

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