16
16
/* Remove a row from a MyISAM table */
18
18
#include "myisamdef.h"
19
#include <drizzled/util/test.h>
21
static int d_search(MI_INFO *info,MI_KEYDEF *keyinfo,uint32_t comp_flag,
22
unsigned char *key,uint32_t key_length,my_off_t page,unsigned char *anc_buff);
23
static int del(MI_INFO *info,MI_KEYDEF *keyinfo,unsigned char *key,unsigned char *anc_buff,
24
my_off_t leaf_page,unsigned char *leaf_buff,unsigned char *keypos,
25
my_off_t next_block,unsigned char *ret_key);
26
static int underflow(MI_INFO *info,MI_KEYDEF *keyinfo,unsigned char *anc_buff,
27
my_off_t leaf_page,unsigned char *leaf_buff,unsigned char *keypos);
28
static uint32_t remove_key(MI_KEYDEF *keyinfo,uint32_t nod_flag,unsigned char *keypos,
29
unsigned char *lastkey,unsigned char *page_end,
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,
30
29
my_off_t *next_block);
31
30
static int _mi_ck_real_delete(register MI_INFO *info,MI_KEYDEF *keyinfo,
32
unsigned char *key, uint32_t key_length, my_off_t *root);
35
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)
38
unsigned char *old_key;
42
41
MYISAM_SHARE *share=info->s;
42
DBUG_ENTER("mi_delete");
44
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););
45
52
if (!(info->update & HA_STATE_AKTIV))
47
return(my_errno=HA_ERR_KEY_NOT_FOUND); /* No database read */
54
DBUG_RETURN(my_errno=HA_ERR_KEY_NOT_FOUND); /* No database read */
49
56
if (share->options & HA_OPTION_READ_ONLY_DATA)
51
return(my_errno=EACCES);
58
DBUG_RETURN(my_errno=EACCES);
53
60
if (_mi_readinfo(info,F_WRLCK,1))
61
DBUG_RETURN(my_errno);
55
62
if (info->s->calc_checksum)
56
63
info->checksum=(*info->s->calc_checksum)(info,record);
57
64
if ((*share->compare_record)(info,record))
86
93
info->state->records--;
88
95
mi_sizestore(lastpos,info->lastpos);
89
_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));
90
98
if (info->invalidator != 0)
100
DBUG_PRINT("info", ("invalidator... '%s' (delete)", info->filename));
92
101
(*info->invalidator)(info->filename);
93
102
info->invalidator=0;
98
107
save_errno=my_errno;
99
108
mi_sizestore(lastpos,info->lastpos);
109
myisam_log_command(MI_LOG_DELETE,info,(uchar*) lastpos, sizeof(lastpos),0);
100
110
if (save_errno != HA_ERR_RECORD_CHANGED)
102
112
mi_print_error(info->s, HA_ERR_CRASHED);
103
113
mi_mark_crashed(info); /* mark table crashed */
105
_mi_writeinfo(info,WRITEINFO_UPDATE_KEYFILE);
115
VOID(_mi_writeinfo(info,WRITEINFO_UPDATE_KEYFILE));
106
116
info->update|=HA_STATE_WRITTEN; /* Buffer changed */
107
117
my_errno=save_errno;
108
118
if (save_errno == HA_ERR_KEY_NOT_FOUND)
128
138
static int _mi_ck_real_delete(register MI_INFO *info, MI_KEYDEF *keyinfo,
129
unsigned char *key, uint32_t key_length, my_off_t *root)
139
uchar *key, uint key_length, my_off_t *root)
133
143
my_off_t old_root;
134
unsigned char *root_buff;
145
DBUG_ENTER("_mi_ck_real_delete");
136
147
if ((old_root=*root) == HA_OFFSET_ERROR)
138
149
mi_print_error(info->s, HA_ERR_CRASHED);
139
return(my_errno=HA_ERR_CRASHED);
150
DBUG_RETURN(my_errno=HA_ERR_CRASHED);
141
if (!(root_buff= (unsigned char*) my_alloca((uint) keyinfo->block_length+
152
if (!(root_buff= (uchar*) my_alloca((uint) keyinfo->block_length+
142
153
MI_MAX_KEY_BUFF*2)))
144
return(my_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));
146
159
if (!_mi_fetch_keypage(info,keyinfo,old_root,DFLT_INIT_HITS,root_buff,0))
188
203
static int d_search(register MI_INFO *info, register MI_KEYDEF *keyinfo,
189
uint32_t comp_flag, unsigned char *key, uint32_t key_length,
190
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)
192
207
int flag,ret_value,save_flag;
193
uint32_t length,nod_flag,search_key_length;
195
unsigned char *leaf_buff,*keypos;
208
uint length,nod_flag,search_key_length;
210
uchar *leaf_buff,*keypos;
196
211
my_off_t leaf_page= 0, next_block;
197
unsigned char lastkey[MI_MAX_KEY_BUFF];
212
uchar lastkey[MI_MAX_KEY_BUFF];
213
DBUG_ENTER("d_search");
214
DBUG_DUMP("page",(uchar*) anc_buff,mi_getint(anc_buff));
199
216
search_key_length= (comp_flag & SEARCH_FIND) ? key_length : USE_WHOLE_KEY;
200
217
flag=(*keyinfo->bin_search)(info,keyinfo,anc_buff,key, search_key_length,
201
218
comp_flag, &keypos, lastkey, &last_key);
202
219
if (flag == MI_FOUND_WRONG_KEY)
221
DBUG_PRINT("error",("Found wrong key"));
206
224
nod_flag=mi_test_if_nod(anc_buff);
263
285
ret_value= underflow(info,keyinfo,anc_buff,leaf_page,leaf_buff,keypos);
265
287
{ /* This happens only with packed keys */
288
DBUG_PRINT("test",("Enlarging of key when deleting"));
266
289
if (!_mi_get_last_key(info,keyinfo,anc_buff,lastkey,keypos,&length))
270
293
ret_value=_mi_insert(info,keyinfo,key,anc_buff,keypos,lastkey,
271
(unsigned char*) 0,(unsigned char*) 0,(my_off_t) 0,(bool) 0);
294
(uchar*) 0,(uchar*) 0,(my_off_t) 0,(my_bool) 0);
274
297
if (ret_value == 0 && mi_getint(anc_buff) > keyinfo->block_length)
279
302
if (save_flag && ret_value != 1)
280
303
ret_value|=_mi_write_keypage(info,keyinfo,page,DFLT_INIT_HITS,anc_buff);
281
my_afree((unsigned char*) leaf_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);
285
my_afree((unsigned char*) leaf_buff);
313
my_afree((uchar*) leaf_buff);
314
DBUG_PRINT("exit",("Error: %d",my_errno));
290
319
/* Remove a key that has a page-reference */
292
static int del(register MI_INFO *info, register MI_KEYDEF *keyinfo, unsigned char *key,
293
unsigned char *anc_buff, my_off_t leaf_page, unsigned char *leaf_buff,
294
unsigned char *keypos, /* Pos to where deleted key was */
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 */
295
324
my_off_t next_block,
296
unsigned char *ret_key) /* key before keypos in anc_buff */
325
uchar *ret_key) /* key before keypos in anc_buff */
298
327
int ret_value,length;
299
uint32_t a_length,nod_flag,tmp;
328
uint a_length,nod_flag,tmp;
300
329
my_off_t next_page;
301
unsigned char keybuff[MI_MAX_KEY_BUFF],*endpos,*next_buff,*key_start, *prev_key;
330
uchar keybuff[MI_MAX_KEY_BUFF],*endpos,*next_buff,*key_start, *prev_key;
302
331
MYISAM_SHARE *share=info->s;
303
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));
305
338
endpos=leaf_buff+mi_getint(leaf_buff);
306
339
if (!(key_start=_mi_get_last_key(info,keyinfo,leaf_buff,keybuff,endpos,
310
343
if ((nod_flag=mi_test_if_nod(leaf_buff)))
312
345
next_page= _mi_kpos(nod_flag,endpos);
313
if (!(next_buff= (unsigned char*) my_alloca((uint) keyinfo->block_length+
346
if (!(next_buff= (uchar*) my_alloca((uint) keyinfo->block_length+
314
347
MI_MAX_KEY_BUFF*2)))
316
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));
320
354
if ((ret_value=del(info,keyinfo,key,anc_buff,next_page,next_buff,
321
355
keypos,next_block,ret_key)) >0)
369
DBUG_PRINT("test",("Inserting of key when deleting"));
335
370
if (!_mi_get_last_key(info,keyinfo,leaf_buff,keybuff,endpos,
338
373
ret_value=_mi_insert(info,keyinfo,key,leaf_buff,endpos,keybuff,
339
(unsigned char*) 0,(unsigned char*) 0,(my_off_t) 0,0);
374
(uchar*) 0,(uchar*) 0,(my_off_t) 0,0);
342
377
if (_mi_write_keypage(info,keyinfo,leaf_page,DFLT_INIT_HITS,leaf_buff))
345
my_afree((unsigned char*) next_buff);
380
my_afree((uchar*) next_buff);
381
DBUG_RETURN(ret_value);
349
384
/* Remove last key from leaf page */
362
397
prev_key=(keypos == anc_buff+2+share->base.key_reflength ?
364
399
length=(*keyinfo->pack_key)(keyinfo,share->base.key_reflength,
365
keypos == endpos ? (unsigned char*) 0 : keypos,
400
keypos == endpos ? (uchar*) 0 : keypos,
366
401
prev_key, prev_key,
367
402
keybuff,&s_temp);
369
bmove_upp((unsigned char*) endpos+length,(unsigned char*) endpos,(uint) (endpos-keypos));
404
bmove_upp((uchar*) endpos+length,(uchar*) endpos,(uint) (endpos-keypos));
371
memcpy(keypos,keypos-length, (int) (endpos-keypos)+length);
406
bmove(keypos,keypos-length, (int) (endpos-keypos)+length);
372
407
(*keyinfo->store_key)(keyinfo,keypos,&s_temp);
373
408
/* Save pointer to next leaf */
374
409
if (!(*keyinfo->get_key)(keyinfo,share->base.key_reflength,&keypos,ret_key))
376
411
_mi_kpointer(info,keypos - share->base.key_reflength,next_block);
377
412
mi_putint(anc_buff,a_length+length,share->base.key_reflength);
379
return( mi_getint(leaf_buff) <=
414
DBUG_RETURN( mi_getint(leaf_buff) <=
380
415
(info->quick_mode ? MI_MIN_KEYBLOCK_LENGTH :
381
416
(uint) keyinfo->underflow_block_length));
387
422
/* Balances adjacent pages if underflow occours */
389
424
static int underflow(register MI_INFO *info, register MI_KEYDEF *keyinfo,
390
unsigned char *anc_buff,
391
426
my_off_t leaf_page,/* Ancestor page and underflow page */
392
unsigned char *leaf_buff,
393
unsigned char *keypos) /* Position to pos after key */
428
uchar *keypos) /* Position to pos after key */
396
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,
397
432
key_reflength,key_length;
398
433
my_off_t next_page;
399
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],
400
435
*buff,*endpos,*next_keypos,*anc_pos,*half_pos,*temp_pos,*prev_key,
402
437
MI_KEY_PARAM s_temp;
403
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));
406
446
info->buff_used=1;
434
476
if (!_mi_fetch_keypage(info,keyinfo,next_page,DFLT_INIT_HITS,buff,0))
436
478
buff_length=mi_getint(buff);
479
DBUG_DUMP("next",(uchar*) buff,buff_length);
438
481
/* find keys to make a big key-page */
439
memcpy(next_keypos - key_reflength, buff + 2, key_reflength);
482
bmove((uchar*) next_keypos-key_reflength,(uchar*) buff+2,
440
484
if (!_mi_get_last_key(info,keyinfo,anc_buff,anc_key,next_keypos,&length)
441
485
|| !_mi_get_last_key(info,keyinfo,leaf_buff,leaf_key,
442
486
leaf_buff+leaf_length,&length))
445
489
/* merge pages and put parting key from anc_buff between */
446
prev_key=(leaf_length == p_length ? (unsigned char*) 0 : leaf_key);
490
prev_key=(leaf_length == p_length ? (uchar*) 0 : leaf_key);
447
491
t_length=(*keyinfo->pack_key)(keyinfo,nod_flag,buff+p_length,
448
492
prev_key, prev_key,
449
493
anc_key, &s_temp);
450
494
length=buff_length-p_length;
451
495
endpos=buff+length+leaf_length+t_length;
452
496
/* buff will always be larger than before !*/
453
bmove_upp((unsigned char*) endpos, (unsigned char*) buff+buff_length,length);
454
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);
455
499
(*keyinfo->store_key)(keyinfo,buff+leaf_length,&s_temp);
456
500
buff_length=(uint) (endpos-buff);
457
501
mi_putint(buff,buff_length,nod_flag);
468
512
if (buff_length <= keyinfo->block_length)
469
513
{ /* Keys in one page */
470
memcpy(leaf_buff, buff, buff_length);
514
memcpy((uchar*) leaf_buff,(uchar*) buff,(size_t) buff_length);
471
515
if (_mi_dispose(info,keyinfo,next_page,DFLT_INIT_HITS))
475
519
{ /* Page is full */
476
520
endpos=anc_buff+anc_length;
521
DBUG_PRINT("test",("anc_buff: 0x%lx endpos: 0x%lx",
522
(long) anc_buff, (long) endpos));
477
523
if (keypos != anc_buff+2+key_reflength &&
478
524
!_mi_get_last_key(info,keyinfo,anc_buff,anc_key,keypos,&length))
481
527
&key_length, &after_key)))
483
529
length=(uint) (half_pos-buff);
484
memcpy(leaf_buff, buff, length);
530
memcpy((uchar*) leaf_buff,(uchar*) buff,(size_t) length);
485
531
mi_putint(leaf_buff,length,nod_flag);
487
533
/* Correct new keypointer to leaf_page */
488
534
half_pos=after_key;
489
535
_mi_kpointer(info,leaf_key+key_length,next_page);
490
536
/* Save key in anc_buff */
491
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),
492
538
t_length=(*keyinfo->pack_key)(keyinfo,key_reflength,
493
(keypos == endpos ? (unsigned char*) 0 :
539
(keypos == endpos ? (uchar*) 0 :
495
541
prev_key, prev_key,
496
542
leaf_key, &s_temp);
497
543
if (t_length >= 0)
498
bmove_upp((unsigned char*) endpos+t_length,(unsigned char*) endpos,
544
bmove_upp((uchar*) endpos+t_length,(uchar*) endpos,
499
545
(uint) (endpos-keypos));
501
memcpy(keypos,keypos-t_length,(uint) (endpos-keypos)+t_length);
547
bmove(keypos,keypos-t_length,(uint) (endpos-keypos)+t_length);
502
548
(*keyinfo->store_key)(keyinfo,keypos,&s_temp);
503
549
mi_putint(anc_buff,(anc_length+=t_length),key_reflength);
505
551
/* Store key first in new page */
507
memcpy(buff + 2, half_pos - nod_flag, nod_flag);
553
bmove((uchar*) buff+2,(uchar*) half_pos-nod_flag,(size_t) nod_flag);
508
554
if (!(*keyinfo->get_key)(keyinfo,nod_flag,&half_pos,leaf_key))
510
t_length=(int) (*keyinfo->pack_key)(keyinfo, nod_flag, (unsigned char*) 0,
511
(unsigned char*) 0, (unsigned char *) 0,
556
t_length=(int) (*keyinfo->pack_key)(keyinfo, nod_flag, (uchar*) 0,
557
(uchar*) 0, (uchar *) 0,
512
558
leaf_key, &s_temp);
513
559
/* t_length will always be > 0 for a new page !*/
514
560
length=(uint) ((buff+mi_getint(buff))-half_pos);
515
memcpy(buff + p_length + t_length, half_pos, length);
561
bmove((uchar*) buff+p_length+t_length,(uchar*) half_pos,(size_t) length);
516
562
(*keyinfo->store_key)(keyinfo,buff+p_length,&s_temp);
517
563
mi_putint(buff,length+t_length+p_length,nod_flag);
546
596
/* merge pages and put parting key from anc_buff between */
547
prev_key=(leaf_length == p_length ? (unsigned char*) 0 : leaf_key);
597
prev_key=(leaf_length == p_length ? (uchar*) 0 : leaf_key);
548
598
t_length=(*keyinfo->pack_key)(keyinfo,nod_flag,
549
599
(leaf_length == p_length ?
550
(unsigned char*) 0 : leaf_buff+p_length),
600
(uchar*) 0 : leaf_buff+p_length),
551
601
prev_key, prev_key,
552
602
anc_key, &s_temp);
553
603
if (t_length >= 0)
554
memcpy(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));
555
606
else /* We gained space */
556
memcpy(endpos, leaf_buff+((int) p_length-t_length),
557
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));
559
610
(*keyinfo->store_key)(keyinfo,endpos,&s_temp);
560
611
buff_length=buff_length+leaf_length-p_length+t_length;
587
638
_mi_kpointer(info,leaf_key+key_length,leaf_page);
588
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);
590
643
temp_pos=anc_buff+anc_length;
591
644
t_length=(*keyinfo->pack_key)(keyinfo,key_reflength,
592
keypos == temp_pos ? (unsigned char*) 0
645
keypos == temp_pos ? (uchar*) 0
594
647
anc_pos, anc_pos,
595
648
leaf_key,&s_temp);
596
649
if (t_length > 0)
597
bmove_upp((unsigned char*) temp_pos+t_length,(unsigned char*) temp_pos,
650
bmove_upp((uchar*) temp_pos+t_length,(uchar*) temp_pos,
598
651
(uint) (temp_pos-keypos));
600
memcpy(keypos,keypos-t_length,(uint) (temp_pos-keypos)+t_length);
653
bmove(keypos,keypos-t_length,(uint) (temp_pos-keypos)+t_length);
601
654
(*keyinfo->store_key)(keyinfo,keypos,&s_temp);
602
655
mi_putint(anc_buff,(anc_length+=t_length),key_reflength);
604
657
/* Store first key on new page */
606
memcpy(leaf_buff+2, half_pos - nod_flag, nod_flag);
659
bmove((uchar*) leaf_buff+2,(uchar*) half_pos-nod_flag,(size_t) nod_flag);
607
660
if (!(length=(*keyinfo->get_key)(keyinfo,nod_flag,&half_pos,leaf_key)))
609
t_length=(*keyinfo->pack_key)(keyinfo,nod_flag, (unsigned char*) 0,
610
(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);
611
665
length=(uint) ((buff+buff_length)-half_pos);
612
memcpy(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,
613
669
(*keyinfo->store_key)(keyinfo,leaf_buff+p_length,&s_temp);
614
670
mi_putint(leaf_buff,length+t_length+p_length,nod_flag);
615
671
if (_mi_write_keypage(info,keyinfo,leaf_page,DFLT_INIT_HITS,leaf_buff))
632
688
returns how many chars was removed or 0 on error
635
static uint32_t remove_key(MI_KEYDEF *keyinfo, uint32_t nod_flag,
636
unsigned char *keypos, /* Where key starts */
637
unsigned char *lastkey, /* key to be removed */
638
unsigned char *page_end, /* End of page */
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 */
639
695
my_off_t *next_block) /* ptr to next block */
642
unsigned char *start;
699
DBUG_ENTER("remove_key");
700
DBUG_PRINT("enter",("keypos: 0x%lx page_end: 0x%lx",(long) keypos, (long) page_end));
645
703
if (!(keyinfo->flag &