mirror of
https://github.com/MariaDB/server.git
synced 2025-07-30 16:24:05 +03:00
Sage cleanup in heap storage engine
Removed old not needed code withing #if Changed 0x%lx to %p
This commit is contained in:
@ -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++;
|
||||
|
@ -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)
|
||||
|
@ -19,8 +19,6 @@
|
||||
#include "heapdef.h"
|
||||
#include <m_ctype.h>
|
||||
|
||||
|
||||
|
||||
/*
|
||||
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;
|
||||
}
|
||||
|
@ -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 */
|
||||
|
||||
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
@ -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)
|
||||
{
|
||||
|
@ -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 */
|
||||
|
@ -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);
|
||||
|
@ -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))
|
||||
{
|
||||
|
@ -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,8 +166,8 @@ 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+
|
||||
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);
|
||||
|
Reference in New Issue
Block a user