16
16
/* Remove a row from a MyISAM table */
18
#include "myisam_priv.h"
19
#include "drizzled/internal/m_string.h"
20
#include <drizzled/util/test.h>
22
using namespace drizzled;
24
static int d_search(MI_INFO *info,MI_KEYDEF *keyinfo,uint32_t comp_flag,
25
unsigned char *key,uint32_t key_length,internal::my_off_t page,unsigned char *anc_buff);
26
static int del(MI_INFO *info,MI_KEYDEF *keyinfo,unsigned char *key,unsigned char *anc_buff,
27
internal::my_off_t leaf_page,unsigned char *leaf_buff,unsigned char *keypos,
28
internal::my_off_t next_block,unsigned char *ret_key);
29
static int underflow(MI_INFO *info,MI_KEYDEF *keyinfo,unsigned char *anc_buff,
30
internal::my_off_t leaf_page,unsigned char *leaf_buff,unsigned char *keypos);
31
static uint32_t remove_key(MI_KEYDEF *keyinfo,uint32_t nod_flag,unsigned char *keypos,
32
unsigned char *lastkey,unsigned char *page_end,
33
internal::my_off_t *next_block);
18
#include "myisamdef.h"
20
static int d_search(MI_INFO *info,MI_KEYDEF *keyinfo,uint comp_flag,
21
uchar *key,uint key_length,my_off_t page,uchar *anc_buff);
22
static int del(MI_INFO *info,MI_KEYDEF *keyinfo,uchar *key,uchar *anc_buff,
23
my_off_t leaf_page,uchar *leaf_buff,uchar *keypos,
24
my_off_t next_block,uchar *ret_key);
25
static int underflow(MI_INFO *info,MI_KEYDEF *keyinfo,uchar *anc_buff,
26
my_off_t leaf_page,uchar *leaf_buff,uchar *keypos);
27
static uint remove_key(MI_KEYDEF *keyinfo,uint nod_flag,uchar *keypos,
28
uchar *lastkey,uchar *page_end,
29
my_off_t *next_block);
34
30
static int _mi_ck_real_delete(register MI_INFO *info,MI_KEYDEF *keyinfo,
35
unsigned char *key, uint32_t key_length, internal::my_off_t *root);
38
int mi_delete(MI_INFO *info,const unsigned char *record)
31
uchar *key, uint key_length, my_off_t *root);
34
int mi_delete(MI_INFO *info,const uchar *record)
41
unsigned char *old_key;
45
41
MYISAM_SHARE *share=info->s;
42
DBUG_ENTER("mi_delete");
47
44
/* Test if record is in datafile */
46
DBUG_EXECUTE_IF("myisam_pretend_crashed_table_on_usage",
47
mi_print_error(info->s, HA_ERR_CRASHED);
48
DBUG_RETURN(my_errno= HA_ERR_CRASHED););
49
DBUG_EXECUTE_IF("my_error_test_undefined_error",
50
mi_print_error(info->s, INT_MAX);
51
DBUG_RETURN(my_errno= INT_MAX););
48
52
if (!(info->update & HA_STATE_AKTIV))
50
return(errno=HA_ERR_KEY_NOT_FOUND); /* No database read */
54
DBUG_RETURN(my_errno=HA_ERR_KEY_NOT_FOUND); /* No database read */
52
56
if (share->options & HA_OPTION_READ_ONLY_DATA)
58
DBUG_RETURN(my_errno=EACCES);
56
60
if (_mi_readinfo(info,F_WRLCK,1))
61
DBUG_RETURN(my_errno);
58
62
if (info->s->calc_checksum)
59
63
info->checksum=(*info->s->calc_checksum)(info,record);
60
64
if ((*share->compare_record)(info,record))
89
93
info->state->records--;
91
95
mi_sizestore(lastpos,info->lastpos);
92
_mi_writeinfo(info,WRITEINFO_UPDATE_KEYFILE);
96
myisam_log_command(MI_LOG_DELETE,info,(uchar*) lastpos,sizeof(lastpos),0);
97
VOID(_mi_writeinfo(info,WRITEINFO_UPDATE_KEYFILE));
98
if (info->invalidator != 0)
100
DBUG_PRINT("info", ("invalidator... '%s' (delete)", info->filename));
101
(*info->invalidator)(info->filename);
97
108
mi_sizestore(lastpos,info->lastpos);
109
myisam_log_command(MI_LOG_DELETE,info,(uchar*) lastpos, sizeof(lastpos),0);
98
110
if (save_errno != HA_ERR_RECORD_CHANGED)
100
112
mi_print_error(info->s, HA_ERR_CRASHED);
101
113
mi_mark_crashed(info); /* mark table crashed */
103
_mi_writeinfo(info,WRITEINFO_UPDATE_KEYFILE);
115
VOID(_mi_writeinfo(info,WRITEINFO_UPDATE_KEYFILE));
104
116
info->update|=HA_STATE_WRITTEN; /* Buffer changed */
106
118
if (save_errno == HA_ERR_KEY_NOT_FOUND)
108
120
mi_print_error(info->s, HA_ERR_CRASHED);
109
errno=HA_ERR_CRASHED;
121
my_errno=HA_ERR_CRASHED;
124
DBUG_RETURN(my_errno);
113
125
} /* mi_delete */
116
128
/* Remove a key from the btree index */
118
int _mi_ck_delete(register MI_INFO *info, uint32_t keynr, unsigned char *key,
130
int _mi_ck_delete(register MI_INFO *info, uint keynr, uchar *key,
121
133
return _mi_ck_real_delete(info, info->s->keyinfo+keynr, key, key_length,
122
134
&info->s->state.key_root[keynr]);
126
138
static int _mi_ck_real_delete(register MI_INFO *info, MI_KEYDEF *keyinfo,
127
unsigned char *key, uint32_t key_length, internal::my_off_t *root)
139
uchar *key, uint key_length, my_off_t *root)
131
internal::my_off_t old_root;
132
unsigned char *root_buff;
145
DBUG_ENTER("_mi_ck_real_delete");
134
147
if ((old_root=*root) == HA_OFFSET_ERROR)
136
149
mi_print_error(info->s, HA_ERR_CRASHED);
137
return(errno=HA_ERR_CRASHED);
150
DBUG_RETURN(my_errno=HA_ERR_CRASHED);
139
if (!(root_buff= (unsigned char*) malloc(keyinfo->block_length+
152
if (!(root_buff= (uchar*) my_alloca((uint) keyinfo->block_length+
140
153
MI_MAX_KEY_BUFF*2)))
142
return(errno=ENOMEM);
155
DBUG_PRINT("error",("Couldn't allocate memory"));
156
DBUG_RETURN(my_errno=ENOMEM);
158
DBUG_PRINT("info",("root_page: %ld", (long) old_root));
144
159
if (!_mi_fetch_keypage(info,keyinfo,old_root,DFLT_INIT_HITS,root_buff,0))
186
203
static int d_search(register MI_INFO *info, register MI_KEYDEF *keyinfo,
187
uint32_t comp_flag, unsigned char *key, uint32_t key_length,
188
internal::my_off_t page, unsigned char *anc_buff)
204
uint comp_flag, uchar *key, uint key_length,
205
my_off_t page, uchar *anc_buff)
190
207
int flag,ret_value,save_flag;
191
uint32_t length,nod_flag,search_key_length;
193
unsigned char *leaf_buff,*keypos;
194
internal::my_off_t leaf_page= 0, next_block;
195
unsigned char lastkey[MI_MAX_KEY_BUFF];
208
uint length,nod_flag,search_key_length;
210
uchar *leaf_buff,*keypos;
211
my_off_t leaf_page= 0, next_block;
212
uchar lastkey[MI_MAX_KEY_BUFF];
213
DBUG_ENTER("d_search");
214
DBUG_DUMP("page",(uchar*) anc_buff,mi_getint(anc_buff));
197
216
search_key_length= (comp_flag & SEARCH_FIND) ? key_length : USE_WHOLE_KEY;
198
217
flag=(*keyinfo->bin_search)(info,keyinfo,anc_buff,key, search_key_length,
199
218
comp_flag, &keypos, lastkey, &last_key);
200
219
if (flag == MI_FOUND_WRONG_KEY)
221
DBUG_PRINT("error",("Found wrong key"));
204
224
nod_flag=mi_test_if_nod(anc_buff);
261
285
ret_value= underflow(info,keyinfo,anc_buff,leaf_page,leaf_buff,keypos);
263
287
{ /* This happens only with packed keys */
288
DBUG_PRINT("test",("Enlarging of key when deleting"));
264
289
if (!_mi_get_last_key(info,keyinfo,anc_buff,lastkey,keypos,&length))
268
293
ret_value=_mi_insert(info,keyinfo,key,anc_buff,keypos,lastkey,
269
(unsigned char*) 0,(unsigned char*) 0,(internal::my_off_t) 0,(bool) 0);
294
(uchar*) 0,(uchar*) 0,(my_off_t) 0,(my_bool) 0);
272
297
if (ret_value == 0 && mi_getint(anc_buff) > keyinfo->block_length)
277
302
if (save_flag && ret_value != 1)
278
303
ret_value|=_mi_write_keypage(info,keyinfo,page,DFLT_INIT_HITS,anc_buff);
306
DBUG_DUMP("page",(uchar*) anc_buff,mi_getint(anc_buff));
308
my_afree((uchar*) leaf_buff);
309
DBUG_PRINT("exit",("Return: %d",ret_value));
310
DBUG_RETURN(ret_value);
313
my_afree((uchar*) leaf_buff);
314
DBUG_PRINT("exit",("Error: %d",my_errno));
288
319
/* Remove a key that has a page-reference */
290
static int del(register MI_INFO *info, register MI_KEYDEF *keyinfo, unsigned char *key,
291
unsigned char *anc_buff, internal::my_off_t leaf_page, unsigned char *leaf_buff,
292
unsigned char *keypos, /* Pos to where deleted key was */
293
internal::my_off_t next_block,
294
unsigned char *ret_key) /* key before keypos in anc_buff */
321
static int del(register MI_INFO *info, register MI_KEYDEF *keyinfo, uchar *key,
322
uchar *anc_buff, my_off_t leaf_page, uchar *leaf_buff,
323
uchar *keypos, /* Pos to where deleted key was */
325
uchar *ret_key) /* key before keypos in anc_buff */
296
327
int ret_value,length;
297
uint32_t a_length,nod_flag,tmp;
298
internal::my_off_t next_page;
299
unsigned char keybuff[MI_MAX_KEY_BUFF],*endpos,*next_buff,*key_start, *prev_key;
328
uint a_length,nod_flag,tmp;
330
uchar keybuff[MI_MAX_KEY_BUFF],*endpos,*next_buff,*key_start, *prev_key;
300
331
MYISAM_SHARE *share=info->s;
301
332
MI_KEY_PARAM s_temp;
334
DBUG_PRINT("enter",("leaf_page: %ld keypos: 0x%lx", (long) leaf_page,
336
DBUG_DUMP("leaf_buff",(uchar*) leaf_buff,mi_getint(leaf_buff));
303
338
endpos=leaf_buff+mi_getint(leaf_buff);
304
339
if (!(key_start=_mi_get_last_key(info,keyinfo,leaf_buff,keybuff,endpos,
308
343
if ((nod_flag=mi_test_if_nod(leaf_buff)))
310
345
next_page= _mi_kpos(nod_flag,endpos);
311
if (!(next_buff= (unsigned char*) malloc(keyinfo->block_length+
346
if (!(next_buff= (uchar*) my_alloca((uint) keyinfo->block_length+
312
347
MI_MAX_KEY_BUFF*2)))
314
349
if (!_mi_fetch_keypage(info,keyinfo,next_page,DFLT_INIT_HITS,next_buff,0))
353
DBUG_DUMP("next_page",(uchar*) next_buff,mi_getint(next_buff));
318
354
if ((ret_value=del(info,keyinfo,key,anc_buff,next_page,next_buff,
319
355
keypos,next_block,ret_key)) >0)
369
DBUG_PRINT("test",("Inserting of key when deleting"));
333
370
if (!_mi_get_last_key(info,keyinfo,leaf_buff,keybuff,endpos,
336
373
ret_value=_mi_insert(info,keyinfo,key,leaf_buff,endpos,keybuff,
337
(unsigned char*) 0,(unsigned char*) 0,(internal::my_off_t) 0,0);
374
(uchar*) 0,(uchar*) 0,(my_off_t) 0,0);
340
377
if (_mi_write_keypage(info,keyinfo,leaf_page,DFLT_INIT_HITS,leaf_buff))
380
my_afree((uchar*) next_buff);
381
DBUG_RETURN(ret_value);
347
384
/* Remove last key from leaf page */
360
397
prev_key=(keypos == anc_buff+2+share->base.key_reflength ?
362
399
length=(*keyinfo->pack_key)(keyinfo,share->base.key_reflength,
363
keypos == endpos ? (unsigned char*) 0 : keypos,
400
keypos == endpos ? (uchar*) 0 : keypos,
364
401
prev_key, prev_key,
365
402
keybuff,&s_temp);
367
internal::bmove_upp((unsigned char*) endpos+length,(unsigned char*) endpos,(uint) (endpos-keypos));
404
bmove_upp((uchar*) endpos+length,(uchar*) endpos,(uint) (endpos-keypos));
369
memmove(keypos,keypos-length, (int) (endpos-keypos)+length);
406
bmove(keypos,keypos-length, (int) (endpos-keypos)+length);
370
407
(*keyinfo->store_key)(keyinfo,keypos,&s_temp);
371
408
/* Save pointer to next leaf */
372
409
if (!(*keyinfo->get_key)(keyinfo,share->base.key_reflength,&keypos,ret_key))
374
411
_mi_kpointer(info,keypos - share->base.key_reflength,next_block);
375
412
mi_putint(anc_buff,a_length+length,share->base.key_reflength);
377
return( mi_getint(leaf_buff) <=
414
DBUG_RETURN( mi_getint(leaf_buff) <=
378
415
(info->quick_mode ? MI_MIN_KEYBLOCK_LENGTH :
379
416
(uint) keyinfo->underflow_block_length));
385
422
/* Balances adjacent pages if underflow occours */
387
424
static int underflow(register MI_INFO *info, register MI_KEYDEF *keyinfo,
388
unsigned char *anc_buff,
389
internal::my_off_t leaf_page,/* Ancestor page and underflow page */
390
unsigned char *leaf_buff,
391
unsigned char *keypos) /* Position to pos after key */
426
my_off_t leaf_page,/* Ancestor page and underflow page */
428
uchar *keypos) /* Position to pos after key */
394
uint32_t length,anc_length,buff_length,leaf_length,p_length,s_length,nod_flag,
431
uint length,anc_length,buff_length,leaf_length,p_length,s_length,nod_flag,
395
432
key_reflength,key_length;
396
internal::my_off_t next_page;
397
unsigned char anc_key[MI_MAX_KEY_BUFF],leaf_key[MI_MAX_KEY_BUFF],
434
uchar anc_key[MI_MAX_KEY_BUFF],leaf_key[MI_MAX_KEY_BUFF],
398
435
*buff,*endpos,*next_keypos,*anc_pos,*half_pos,*temp_pos,*prev_key,
400
437
MI_KEY_PARAM s_temp;
401
438
MYISAM_SHARE *share=info->s;
439
DBUG_ENTER("underflow");
440
DBUG_PRINT("enter",("leaf_page: %ld keypos: 0x%lx",(long) leaf_page,
442
DBUG_DUMP("anc_buff",(uchar*) anc_buff,mi_getint(anc_buff));
443
DBUG_DUMP("leaf_buff",(uchar*) leaf_buff,mi_getint(leaf_buff));
404
446
info->buff_used=1;
432
476
if (!_mi_fetch_keypage(info,keyinfo,next_page,DFLT_INIT_HITS,buff,0))
434
478
buff_length=mi_getint(buff);
479
DBUG_DUMP("next",(uchar*) buff,buff_length);
436
481
/* find keys to make a big key-page */
437
memmove(next_keypos - key_reflength, buff + 2, key_reflength);
482
bmove((uchar*) next_keypos-key_reflength,(uchar*) buff+2,
438
484
if (!_mi_get_last_key(info,keyinfo,anc_buff,anc_key,next_keypos,&length)
439
485
|| !_mi_get_last_key(info,keyinfo,leaf_buff,leaf_key,
440
486
leaf_buff+leaf_length,&length))
443
489
/* merge pages and put parting key from anc_buff between */
444
prev_key=(leaf_length == p_length ? (unsigned char*) 0 : leaf_key);
490
prev_key=(leaf_length == p_length ? (uchar*) 0 : leaf_key);
445
491
t_length=(*keyinfo->pack_key)(keyinfo,nod_flag,buff+p_length,
446
492
prev_key, prev_key,
447
493
anc_key, &s_temp);
448
494
length=buff_length-p_length;
449
495
endpos=buff+length+leaf_length+t_length;
450
496
/* buff will always be larger than before !*/
451
internal::bmove_upp((unsigned char*) endpos, (unsigned char*) buff+buff_length,length);
452
memcpy(buff, leaf_buff, leaf_length);
497
bmove_upp((uchar*) endpos, (uchar*) buff+buff_length,length);
498
memcpy((uchar*) buff, (uchar*) leaf_buff,(size_t) leaf_length);
453
499
(*keyinfo->store_key)(keyinfo,buff+leaf_length,&s_temp);
454
500
buff_length=(uint) (endpos-buff);
455
501
mi_putint(buff,buff_length,nod_flag);
466
512
if (buff_length <= keyinfo->block_length)
467
513
{ /* Keys in one page */
468
memcpy(leaf_buff, buff, buff_length);
514
memcpy((uchar*) leaf_buff,(uchar*) buff,(size_t) buff_length);
469
515
if (_mi_dispose(info,keyinfo,next_page,DFLT_INIT_HITS))
473
519
{ /* Page is full */
474
520
endpos=anc_buff+anc_length;
521
DBUG_PRINT("test",("anc_buff: 0x%lx endpos: 0x%lx",
522
(long) anc_buff, (long) endpos));
475
523
if (keypos != anc_buff+2+key_reflength &&
476
524
!_mi_get_last_key(info,keyinfo,anc_buff,anc_key,keypos,&length))
479
527
&key_length, &after_key)))
481
529
length=(uint) (half_pos-buff);
482
memcpy(leaf_buff, buff, length);
530
memcpy((uchar*) leaf_buff,(uchar*) buff,(size_t) length);
483
531
mi_putint(leaf_buff,length,nod_flag);
485
533
/* Correct new keypointer to leaf_page */
486
534
half_pos=after_key;
487
535
_mi_kpointer(info,leaf_key+key_length,next_page);
488
536
/* Save key in anc_buff */
489
prev_key=(keypos == anc_buff+2+key_reflength ? (unsigned char*) 0 : anc_key),
537
prev_key=(keypos == anc_buff+2+key_reflength ? (uchar*) 0 : anc_key),
490
538
t_length=(*keyinfo->pack_key)(keyinfo,key_reflength,
491
(keypos == endpos ? (unsigned char*) 0 :
539
(keypos == endpos ? (uchar*) 0 :
493
541
prev_key, prev_key,
494
542
leaf_key, &s_temp);
495
543
if (t_length >= 0)
496
internal::bmove_upp((unsigned char*) endpos+t_length,(unsigned char*) endpos,
544
bmove_upp((uchar*) endpos+t_length,(uchar*) endpos,
497
545
(uint) (endpos-keypos));
499
memmove(keypos,keypos-t_length,(uint) (endpos-keypos)+t_length);
547
bmove(keypos,keypos-t_length,(uint) (endpos-keypos)+t_length);
500
548
(*keyinfo->store_key)(keyinfo,keypos,&s_temp);
501
549
mi_putint(anc_buff,(anc_length+=t_length),key_reflength);
503
551
/* Store key first in new page */
505
memmove(buff + 2, half_pos - nod_flag, nod_flag);
553
bmove((uchar*) buff+2,(uchar*) half_pos-nod_flag,(size_t) nod_flag);
506
554
if (!(*keyinfo->get_key)(keyinfo,nod_flag,&half_pos,leaf_key))
508
t_length=(int) (*keyinfo->pack_key)(keyinfo, nod_flag, (unsigned char*) 0,
509
(unsigned char*) 0, (unsigned char *) 0,
556
t_length=(int) (*keyinfo->pack_key)(keyinfo, nod_flag, (uchar*) 0,
557
(uchar*) 0, (uchar *) 0,
510
558
leaf_key, &s_temp);
511
559
/* t_length will always be > 0 for a new page !*/
512
560
length=(uint) ((buff+mi_getint(buff))-half_pos);
513
memmove(buff + p_length + t_length, half_pos, length);
561
bmove((uchar*) buff+p_length+t_length,(uchar*) half_pos,(size_t) length);
514
562
(*keyinfo->store_key)(keyinfo,buff+p_length,&s_temp);
515
563
mi_putint(buff,length+t_length+p_length,nod_flag);
544
596
/* merge pages and put parting key from anc_buff between */
545
prev_key=(leaf_length == p_length ? (unsigned char*) 0 : leaf_key);
597
prev_key=(leaf_length == p_length ? (uchar*) 0 : leaf_key);
546
598
t_length=(*keyinfo->pack_key)(keyinfo,nod_flag,
547
599
(leaf_length == p_length ?
548
(unsigned char*) 0 : leaf_buff+p_length),
600
(uchar*) 0 : leaf_buff+p_length),
549
601
prev_key, prev_key,
550
602
anc_key, &s_temp);
551
603
if (t_length >= 0)
552
memmove(endpos+t_length,leaf_buff+p_length, leaf_length-p_length);
604
bmove((uchar*) endpos+t_length,(uchar*) leaf_buff+p_length,
605
(size_t) (leaf_length-p_length));
553
606
else /* We gained space */
554
memmove(endpos, leaf_buff+((int) p_length-t_length),
555
leaf_length - p_length + t_length);
607
bmove((uchar*) endpos,(uchar*) leaf_buff+((int) p_length-t_length),
608
(size_t) (leaf_length-p_length+t_length));
557
610
(*keyinfo->store_key)(keyinfo,endpos,&s_temp);
558
611
buff_length=buff_length+leaf_length-p_length+t_length;
585
638
_mi_kpointer(info,leaf_key+key_length,leaf_page);
586
639
/* Save key in anc_buff */
640
DBUG_DUMP("anc_buff",(uchar*) anc_buff,anc_length);
641
DBUG_DUMP("key_to_anc",(uchar*) leaf_key,key_length);
588
643
temp_pos=anc_buff+anc_length;
589
644
t_length=(*keyinfo->pack_key)(keyinfo,key_reflength,
590
keypos == temp_pos ? (unsigned char*) 0
645
keypos == temp_pos ? (uchar*) 0
592
647
anc_pos, anc_pos,
593
648
leaf_key,&s_temp);
594
649
if (t_length > 0)
595
internal::bmove_upp((unsigned char*) temp_pos+t_length,(unsigned char*) temp_pos,
650
bmove_upp((uchar*) temp_pos+t_length,(uchar*) temp_pos,
596
651
(uint) (temp_pos-keypos));
598
memmove(keypos,keypos-t_length,(uint) (temp_pos-keypos)+t_length);
653
bmove(keypos,keypos-t_length,(uint) (temp_pos-keypos)+t_length);
599
654
(*keyinfo->store_key)(keyinfo,keypos,&s_temp);
600
655
mi_putint(anc_buff,(anc_length+=t_length),key_reflength);
602
657
/* Store first key on new page */
604
memmove(leaf_buff+2, half_pos - nod_flag, nod_flag);
659
bmove((uchar*) leaf_buff+2,(uchar*) half_pos-nod_flag,(size_t) nod_flag);
605
660
if (!(length=(*keyinfo->get_key)(keyinfo,nod_flag,&half_pos,leaf_key)))
607
t_length=(*keyinfo->pack_key)(keyinfo,nod_flag, (unsigned char*) 0,
608
(unsigned char*) 0, (unsigned char*) 0, leaf_key, &s_temp);
662
DBUG_DUMP("key_to_leaf",(uchar*) leaf_key,length);
663
t_length=(*keyinfo->pack_key)(keyinfo,nod_flag, (uchar*) 0,
664
(uchar*) 0, (uchar*) 0, leaf_key, &s_temp);
609
665
length=(uint) ((buff+buff_length)-half_pos);
610
memmove(leaf_buff + p_length + t_length, half_pos, length);
666
DBUG_PRINT("info",("t_length: %d length: %d",t_length,(int) length));
667
bmove((uchar*) leaf_buff+p_length+t_length,(uchar*) half_pos,
611
669
(*keyinfo->store_key)(keyinfo,leaf_buff+p_length,&s_temp);
612
670
mi_putint(leaf_buff,length+t_length+p_length,nod_flag);
613
671
if (_mi_write_keypage(info,keyinfo,leaf_page,DFLT_INIT_HITS,leaf_buff))
630
688
returns how many chars was removed or 0 on error
633
static uint32_t remove_key(MI_KEYDEF *keyinfo, uint32_t nod_flag,
634
unsigned char *keypos, /* Where key starts */
635
unsigned char *lastkey, /* key to be removed */
636
unsigned char *page_end, /* End of page */
637
internal::my_off_t *next_block) /* ptr to next block */
691
static uint remove_key(MI_KEYDEF *keyinfo, uint nod_flag,
692
uchar *keypos, /* Where key starts */
693
uchar *lastkey, /* key to be removed */
694
uchar *page_end, /* End of page */
695
my_off_t *next_block) /* ptr to next block */
640
unsigned char *start;
699
DBUG_ENTER("remove_key");
700
DBUG_PRINT("enter",("keypos: 0x%lx page_end: 0x%lx",(long) keypos, (long) page_end));
643
703
if (!(keyinfo->flag &
662
722
if (keyinfo->flag & HA_BINARY_PACK_KEY)
664
unsigned char *old_key=start;
665
uint32_t next_length,prev_length,prev_pack_length;
724
uchar *old_key=start;
725
uint next_length,prev_length,prev_pack_length;
666
726
get_key_length(next_length,keypos);
667
727
get_key_pack_length(prev_length,prev_pack_length,old_key);
668
728
if (next_length > prev_length)
670
730
/* We have to copy data from the current key to the next key */
671
internal::bmove_upp(keypos, (lastkey+next_length),
731
bmove_upp(keypos, (lastkey+next_length),
672
732
(next_length-prev_length));
673
733
keypos-=(next_length-prev_length)+prev_pack_length;
674
734
store_key_length(keypos,prev_length);