From 7cd2095cde11af4ac0478c5ff9a221a832e23586 Mon Sep 17 00:00:00 2001 From: Monty Date: Fri, 23 Oct 2015 18:44:13 +0300 Subject: Sage cleanup in heap storage engine Removed old not needed code withing #if Changed 0x%lx to %p --- storage/heap/_check.c | 8 +++---- storage/heap/hp_delete.c | 6 ++--- storage/heap/hp_hash.c | 13 +---------- storage/heap/hp_info.c | 15 ------------ storage/heap/hp_open.c | 6 ++--- storage/heap/hp_rkey.c | 2 +- storage/heap/hp_rrnd.c | 60 ++---------------------------------------------- storage/heap/hp_test1.c | 25 -------------------- storage/heap/hp_test2.c | 41 --------------------------------- storage/heap/hp_write.c | 8 +++---- 10 files changed, 18 insertions(+), 166 deletions(-) (limited to 'storage') diff --git a/storage/heap/_check.c b/storage/heap/_check.c index b64c9ab1831..910a0d20256 100644 --- a/storage/heap/_check.c +++ b/storage/heap/_check.c @@ -128,8 +128,8 @@ static int check_one_key(HP_KEYDEF *keydef, uint keynr, ulong records, if ((rec_link= hp_mask(hash_info->hash_of_key, blength, records)) != i) { DBUG_PRINT("error", - ("Record in wrong link: Link %lu Record: 0x%lx Record-link %lu", - i, (long) hash_info->ptr_to_rec, rec_link)); + ("Record in wrong link: Link %lu Record: %p Record-link %lu", + i, hash_info->ptr_to_rec, rec_link)); error=1; } else @@ -186,8 +186,8 @@ static int check_one_rb_key(HP_INFO *info, uint keynr, ulong records, key_length, SEARCH_FIND | SEARCH_SAME, not_used)) { error= 1; - DBUG_PRINT("error",("Record in wrong link: key: %u Record: 0x%lx\n", - keynr, (long) recpos)); + DBUG_PRINT("error",("Record in wrong link: key: %u Record: %p\n", + keynr, recpos)); } else found++; diff --git a/storage/heap/hp_delete.c b/storage/heap/hp_delete.c index 1cbfe7408d4..0c1c2c4c8f8 100644 --- a/storage/heap/hp_delete.c +++ b/storage/heap/hp_delete.c @@ -23,7 +23,7 @@ int heap_delete(HP_INFO *info, const uchar *record) HP_SHARE *share=info->s; HP_KEYDEF *keydef, *end, *p_lastinx; DBUG_ENTER("heap_delete"); - DBUG_PRINT("enter",("info: 0x%lx record: 0x%lx", (long) info, (long) record)); + DBUG_PRINT("enter",("info: %p record: %p", info, record)); test_active(info); @@ -139,8 +139,8 @@ int hp_delete_key(HP_INFO *info, register HP_KEYDEF *keyinfo, /* Save for heap_rnext/heap_rprev */ info->current_hash_ptr=last_ptr; info->current_ptr = last_ptr ? last_ptr->ptr_to_rec : 0; - DBUG_PRINT("info",("Corrected current_ptr to point at: 0x%lx", - (long) info->current_ptr)); + DBUG_PRINT("info",("Corrected current_ptr to point at: %p", + info->current_ptr)); } empty=pos; if (gpos) diff --git a/storage/heap/hp_hash.c b/storage/heap/hp_hash.c index aba7e8383da..b727c71d3de 100644 --- a/storage/heap/hp_hash.c +++ b/storage/heap/hp_hash.c @@ -19,8 +19,6 @@ #include "heapdef.h" #include - - /* Find out how many rows there is in the given range @@ -120,7 +118,7 @@ uchar *hp_search(HP_INFO *info, HP_KEYDEF *keyinfo, const uchar *key, { switch (nextflag) { case 0: /* Search after key */ - DBUG_PRINT("exit", ("found key at 0x%lx", (long) pos->ptr_to_rec)); + DBUG_PRINT("exit", ("found key at %p", pos->ptr_to_rec)); info->current_hash_ptr=pos; DBUG_RETURN(info->current_ptr= pos->ptr_to_rec); case 1: /* Search next */ @@ -878,17 +876,8 @@ uint hp_rb_pack_key(HP_KEYDEF *keydef, uchar *key, const uchar *old, /* Convert NULL from MySQL representation into HEAP's. */ if (!(*key++= (char) 1 - *old++)) { -#if 0 - /* - Skip length part of a variable length field. - Length of key-part used with heap_rkey() always 2. - See also hp_hashnr(). - */ - if (seg->flag & (HA_VAR_LENGTH_PART | HA_BLOB_PART)) -#else /* Add key pack length (2) to key for VARCHAR segments */ if (seg->type == HA_KEYTYPE_VARTEXT1) -#endif old+= 2; continue; } diff --git a/storage/heap/hp_info.c b/storage/heap/hp_info.c index c30cc010b60..10047fb2eac 100644 --- a/storage/heap/hp_info.c +++ b/storage/heap/hp_info.c @@ -25,21 +25,6 @@ uchar *heap_position(HP_INFO *info) } -#ifdef WANT_OLD_HEAP_VERSION - -/* - The following should NOT be used anymore as this can't be used together with - heap_rkey() -*/ - -ulong heap_position_old(HP_INFO *info) -{ - return ((info->update & HA_STATE_AKTIV) ? info->current_record : - (ulong) ~0L); -} - -#endif /* WANT_OLD_HEAP_CODE */ - /* Note that heap_info does NOT return information about the current position anymore; Use heap_position instead */ diff --git a/storage/heap/hp_open.c b/storage/heap/hp_open.c index 43b366639bb..611eda4e734 100644 --- a/storage/heap/hp_open.c +++ b/storage/heap/hp_open.c @@ -49,8 +49,8 @@ HP_INFO *heap_open_from_share(HP_SHARE *share, int mode) #ifndef DBUG_OFF info->opt_flag= READ_CHECK_USED; /* Check when changing */ #endif - DBUG_PRINT("exit",("heap: 0x%lx reclength: %d records_in_block: %lu", - (long) info, share->reclength, + DBUG_PRINT("exit",("heap: %p reclength: %d records_in_block: %lu", + info, share->reclength, share->block.records_in_block)); DBUG_RETURN(info); } @@ -142,7 +142,7 @@ HP_SHARE *hp_find_named_heap(const char *name) info= (HP_SHARE*) pos->data; if (!strcmp(name, info->name)) { - DBUG_PRINT("exit", ("Old heap_database: 0x%lx", (long) info)); + DBUG_PRINT("exit", ("Old heap_database: %p", info)); DBUG_RETURN(info); } } diff --git a/storage/heap/hp_rkey.c b/storage/heap/hp_rkey.c index 138d65f9d25..692e1a01b61 100644 --- a/storage/heap/hp_rkey.c +++ b/storage/heap/hp_rkey.c @@ -23,7 +23,7 @@ int heap_rkey(HP_INFO *info, uchar *record, int inx, const uchar *key, HP_SHARE *share= info->s; HP_KEYDEF *keyinfo= share->keydef + inx; DBUG_ENTER("heap_rkey"); - DBUG_PRINT("enter",("info: 0x%lx inx: %d", (long) info, inx)); + DBUG_PRINT("enter",("info: %p inx: %d", info, inx)); if ((uint) inx >= share->keys) { diff --git a/storage/heap/hp_rrnd.c b/storage/heap/hp_rrnd.c index 8e0d51a78ca..6bf1888275e 100644 --- a/storage/heap/hp_rrnd.c +++ b/storage/heap/hp_rrnd.c @@ -29,7 +29,7 @@ int heap_rrnd(register HP_INFO *info, uchar *record, uchar *pos) { HP_SHARE *share=info->s; DBUG_ENTER("heap_rrnd"); - DBUG_PRINT("enter",("info: 0x%lx pos: %lx",(long) info, (long) pos)); + DBUG_PRINT("enter",("info: %p pos: %p", info, pos)); info->lastinx= -1; if (!(info->current_ptr= pos)) @@ -44,63 +44,7 @@ int heap_rrnd(register HP_INFO *info, uchar *record, uchar *pos) } info->update=HA_STATE_PREV_FOUND | HA_STATE_NEXT_FOUND | HA_STATE_AKTIV; memcpy(record,info->current_ptr,(size_t) share->reclength); - DBUG_PRINT("exit", ("found record at 0x%lx", (long) info->current_ptr)); + DBUG_PRINT("exit", ("found record at %p", info->current_ptr)); info->current_hash_ptr=0; /* Can't use rnext */ DBUG_RETURN(0); } /* heap_rrnd */ - - -#ifdef WANT_OLD_HEAP_VERSION - -/* - If pos == -1 then read next record - Returns one of following values: - 0 = Ok. - HA_ERR_RECORD_DELETED = Record is deleted. - HA_ERR_END_OF_FILE = EOF. -*/ - -int heap_rrnd_old(register HP_INFO *info, uchar *record, ulong pos) -{ - HP_SHARE *share=info->s; - DBUG_ENTER("heap_rrnd"); - DBUG_PRINT("enter",("info: 0x%lx pos: %ld",info,pos)); - - info->lastinx= -1; - if (pos == (ulong) -1) - { - pos= ++info->current_record; - if (pos % share->block.records_in_block && /* Quick next record */ - pos < share->records+share->deleted && - (info->update & HA_STATE_PREV_FOUND)) - { - info->current_ptr+=share->block.recbuffer; - goto end; - } - } - else - info->current_record=pos; - - if (pos >= share->records+share->deleted) - { - info->update= 0; - DBUG_RETURN(my_errno= HA_ERR_END_OF_FILE); - } - - /* Find record number pos */ - hp_find_record(info, pos); - -end: - if (!info->current_ptr[share->reclength]) - { - info->update= HA_STATE_PREV_FOUND | HA_STATE_NEXT_FOUND; - DBUG_RETURN(my_errno=HA_ERR_RECORD_DELETED); - } - info->update=HA_STATE_PREV_FOUND | HA_STATE_NEXT_FOUND | HA_STATE_AKTIV; - memcpy(record,info->current_ptr,(size_t) share->reclength); - DBUG_PRINT("exit",("found record at 0x%lx",info->current_ptr)); - info->current_hash_ptr=0; /* Can't use rnext */ - DBUG_RETURN(0); -} /* heap_rrnd */ - -#endif /* WANT_OLD_HEAP_VERSION */ diff --git a/storage/heap/hp_test1.c b/storage/heap/hp_test1.c index e6283f171c4..9b14610fe30 100644 --- a/storage/heap/hp_test1.c +++ b/storage/heap/hp_test1.c @@ -136,31 +136,6 @@ int main(int argc, char **argv) } } -#ifdef OLD_HEAP_VERSION - { - int found; - printf("- Reading records with position\n"); - for (i=1,found=0 ; i <= 30 ; i++) - { - my_errno=0; - if ((error=heap_rrnd(file,record,i == 1 ? 0L : (ulong) -1)) == - HA_ERR_END_OF_FILE) - { - if (found != 25-deleted) - printf("Found only %d of %d records\n",found,25-deleted); - break; - } - if (!error) - found++; - if (verbose || (error != 0 && error != HA_ERR_RECORD_DELETED)) - { - printf("pos: %2d ni_rrnd: %3d my_errno: %3d record: %s\n", - i-1,error,my_errno,(char*) record+1); - } - } - } -#endif - if (heap_close(file) || hp_panic(HA_PANIC_CLOSE)) goto err; my_end(MY_GIVE_INFO); diff --git a/storage/heap/hp_test2.c b/storage/heap/hp_test2.c index 13b49fbb7ec..657d5bcd01e 100644 --- a/storage/heap/hp_test2.c +++ b/storage/heap/hp_test2.c @@ -428,39 +428,6 @@ int main(int argc, char *argv[]) } } -#ifdef OLD_HEAP_VERSION - { - uint check; - printf("- Read through all records with rnd\n"); - if (heap_extra(file,HA_EXTRA_RESET) || heap_extra(file,HA_EXTRA_CACHE)) - { - puts("got error from heap_extra"); - goto end; - } - ant=check=0; - while ((error=heap_rrnd(file,record,(ulong) -1)) != HA_ERR_END_OF_FILE && - ant < write_count + 10) - { - if (!error) - { - ant++; - check+=calc_check(record,reclength); - } - } - if (ant != write_count-opt_delete) - { - printf("rrnd: I can only find: %d records of %d\n", ant, - write_count-opt_delete); - goto end; - } - if (heap_extra(file,HA_EXTRA_NO_CACHE)) - { - puts("got error from heap_extra(HA_EXTRA_NO_CACHE)"); - goto end; - } - } -#endif - printf("- Read through all records with scan\n"); if (heap_reset(file) || heap_extra(file,HA_EXTRA_CACHE)) { @@ -484,14 +451,6 @@ int main(int argc, char *argv[]) write_count-opt_delete); goto end; } -#ifdef OLD_HEAP_VERSION - if (check != check2) - { - puts("scan: Checksum didn't match reading with rrnd"); - goto end; - } -#endif - if (heap_extra(file,HA_EXTRA_NO_CACHE)) { diff --git a/storage/heap/hp_write.c b/storage/heap/hp_write.c index c6205508a90..a1d81fd808d 100644 --- a/storage/heap/hp_write.c +++ b/storage/heap/hp_write.c @@ -144,7 +144,7 @@ static uchar *next_free_record_pos(HP_SHARE *info) pos=info->del_link; info->del_link= *((uchar**) pos); info->deleted--; - DBUG_PRINT("exit",("Used old position: 0x%lx",(long) pos)); + DBUG_PRINT("exit",("Used old position: %p", pos)); DBUG_RETURN(pos); } if (!(block_pos=(info->records % info->block.records_in_block))) @@ -166,9 +166,9 @@ static uchar *next_free_record_pos(HP_SHARE *info) DBUG_RETURN(NULL); info->data_length+=length; } - DBUG_PRINT("exit",("Used new position: 0x%lx", - (long) ((uchar*) info->block.level_info[0].last_blocks+ - block_pos * info->block.recbuffer))); + DBUG_PRINT("exit",("Used new position: %p", + ((uchar*) info->block.level_info[0].last_blocks+ + block_pos * info->block.recbuffer))); DBUG_RETURN((uchar*) info->block.level_info[0].last_blocks+ block_pos*info->block.recbuffer); } -- cgit v1.2.1