1
/* Copyright (C) 2000-2002, 2004-2006 MySQL AB
1
/* Copyright (C) 2000-2002, 2004-200 MySQL AB
3
3
This program is free software; you can redistribute it and/or modify
4
4
it under the terms of the GNU General Public License as published by
12
12
You should have received a copy of the GNU General Public License
13
13
along with this program; if not, write to the Free Software
14
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */
14
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
16
16
/* remove current record in heap-database */
18
#include "heap_priv.h"
20
20
int heap_delete(HP_INFO *info, const unsigned char *record)
22
22
unsigned char *pos;
23
HP_SHARE *share=info->getShare();
23
HP_SHARE *share=info->s;
24
24
HP_KEYDEF *keydef, *end, *p_lastinx;
25
uint32_t rec_length, chunk_count;
28
29
if (info->opt_flag & READ_CHECK_USED)
29
return(errno); /* Record changed */
30
return(my_errno); /* Record changed */
33
rec_length = hp_get_encoded_data_length(share, record, &chunk_count);
32
35
if ( --(share->records) < share->blength >> 1) share->blength>>=1;
33
36
pos=info->current_ptr;
35
38
p_lastinx = share->keydef + info->lastinx;
36
for (keydef = share->keydef, end = keydef + share->keys; keydef < end;
39
for (keydef = share->keydef, end = keydef + share->keys; keydef < end;
39
if (hp_delete_key(info, keydef, record, pos, keydef == p_lastinx))
42
if ((*keydef->delete_key)(info, keydef, record, pos, keydef == p_lastinx))
49
52
if (++(share->records) == share->blength)
50
53
share->blength+= share->blength;
59
Remove one key from rb-tree
62
int hp_rb_delete_key(HP_INFO *info, register HP_KEYDEF *keyinfo,
63
const unsigned char *record, unsigned char *recpos, int flag)
65
heap_rb_param custom_arg;
66
uint32_t old_allocated;
70
info->last_pos= NULL; /* For heap_rnext/heap_rprev */
72
custom_arg.keyseg= keyinfo->seg;
73
custom_arg.key_length= hp_rb_make_key(keyinfo, info->recbuf, record, recpos);
74
custom_arg.search_flag= SEARCH_SAME;
75
old_allocated= keyinfo->rb_tree.allocated;
76
res= tree_delete(&keyinfo->rb_tree, info->recbuf, custom_arg.key_length,
78
info->s->index_length-= (old_allocated - keyinfo->rb_tree.allocated);
74
102
uint32_t blength,pos2,pos_hashnr,lastpos_hashnr;
75
103
HASH_INFO *lastpos,*gpos,*pos,*pos3,*empty,*last_ptr;
76
HP_SHARE *share=info->getShare();
104
HP_SHARE *share=info->s;
78
106
blength=share->blength;
79
107
if (share->records+1 == blength)