Commit fdfb5148 authored by unknown's avatar unknown

Fixed compiler warnings

Fixed bug in ma_dbug.c that gave valgrind warning (only relevant when using --debug)
Fixed bug in blob logging (Fixes valgrind warning)
maria_getint() -> maria_data_on_page()


mysys/safemalloc.c:
  Added debug function to print out where a piece of memory was allocated
sql/opt_range.cc:
  Remove DBUG_PRINT of unitailized memory
storage/maria/ma_blockrec.c:
  Fixed bug in blob logging
storage/maria/ma_check.c:
  Fixed compiler warning
storage/maria/ma_dbug.c:
  Added missed end++; Caused usage of unitialized memory for nullable keys that was not NULL
storage/maria/ma_delete.c:
  maria_getint() -> maria_data_on_page()
storage/maria/ma_init.c:
  Added header file to get rid of warning
storage/maria/ma_key.c:
  More debugging
storage/maria/ma_loghandler.c:
  Removed some wrong ';' to get rid of compiler errors when compiling without debugging
  Indentation fixes
  Removed not needed 'break's
  Fixed some compiler warnings
  Added code to detect logging of unitialized memory
storage/maria/ma_page.c:
  maria_getint() -> maria_data_on_page()
  Clear rest of index page before writing when used with valgrind
  (Fixes warning of writing pages with unitialized data)
storage/maria/ma_range.c:
  maria_getint() -> maria_data_on_page()
storage/maria/ma_rt_index.c:
  maria_getint() -> maria_data_on_page()
storage/maria/ma_rt_index.h:
  maria_getint() -> maria_data_on_page()
storage/maria/ma_rt_key.c:
  maria_getint() -> maria_data_on_page()
storage/maria/ma_rt_split.c:
  maria_getint() -> maria_data_on_page()
storage/maria/ma_search.c:
  maria_getint() -> maria_data_on_page()
storage/maria/ma_test1.c:
  Fixed compiler warning
storage/maria/ma_write.c:
  maria_getint() -> maria_data_on_page()
storage/maria/maria_chk.c:
  maria_getint() -> maria_data_on_page()
storage/maria/maria_def.h:
  maria_getint() -> maria_data_on_page()
storage/maria/unittest/ma_pagecache_consist.c:
  Fixed compiler warning
storage/maria/unittest/ma_pagecache_single.c:
  Fixed compiler warning
storage/maria/unittest/ma_test_loghandler-t.c:
  Fixed compiler warning
storage/maria/unittest/ma_test_loghandler_multigroup-t.c:
  Fixed compiler warning
storage/maria/unittest/ma_test_loghandler_multithread-t.c:
  Fixed compiler warning
storage/maria/unittest/ma_test_loghandler_pagecache-t.c:
  Fixed compiler warning
storage/myisam/mi_dbug.c:
  Added missed end++; Caused usage of unitialized memory for nullable keys that was not NULL
parent e30e21f0
...@@ -428,6 +428,29 @@ void TERMINATE(FILE *file) ...@@ -428,6 +428,29 @@ void TERMINATE(FILE *file)
} }
/*
Report where a piece of memory was allocated
This is usefull to call from withing a debugger
*/
void sf_malloc_report_allocated(void *memory)
{
struct st_irem *irem;
for (irem= sf_malloc_root ; irem ; irem=irem->next)
{
char *data= (((char*) irem) + ALIGN_SIZE(sizeof(struct st_irem)) +
sf_malloc_prehunc);
if (data <= (char*) memory && (char*) memory <= data + irem->datasize)
{
printf("%u bytes at 0x%lx, allocated at line %u in '%s'\n",
irem->datasize, (long) data, irem->linenum, irem->filename);
break;
}
}
}
/* Returns 0 if chunk is ok */ /* Returns 0 if chunk is ok */
static int _checkchunk(register struct st_irem *irem, const char *filename, static int _checkchunk(register struct st_irem *irem, const char *filename,
......
...@@ -4183,7 +4183,6 @@ static bool ror_intersect_add(ROR_INTERSECT_INFO *info, ...@@ -4183,7 +4183,6 @@ static bool ror_intersect_add(ROR_INTERSECT_INFO *info,
} }
info->out_rows *= selectivity_mult; info->out_rows *= selectivity_mult;
DBUG_PRINT("info", ("info->total_cost= %g", info->total_cost));
if (is_cpk_scan) if (is_cpk_scan)
{ {
......
...@@ -2056,7 +2056,9 @@ static my_bool write_block_record(MARIA_HA *info, ...@@ -2056,7 +2056,9 @@ static my_bool write_block_record(MARIA_HA *info,
blob_length-= (blob_length % FULL_PAGE_SIZE(block_size)); blob_length-= (blob_length % FULL_PAGE_SIZE(block_size));
if (blob_length) if (blob_length)
{ {
log_array_pos->str= (char*) record + column->offset + length; memcpy_fixed((byte*) &log_array_pos->str,
record + column->offset + length,
sizeof(byte*));
log_array_pos->length= blob_length; log_array_pos->length= blob_length;
log_entry_length+= blob_length; log_entry_length+= blob_length;
log_array_pos++; log_array_pos++;
......
...@@ -742,7 +742,7 @@ static int chk_index(HA_CHECK *param, MARIA_HA *info, MARIA_KEYDEF *keyinfo, ...@@ -742,7 +742,7 @@ static int chk_index(HA_CHECK *param, MARIA_HA *info, MARIA_KEYDEF *keyinfo,
char llbuff[22]; char llbuff[22];
uint diff_pos[2]; uint diff_pos[2];
DBUG_ENTER("chk_index"); DBUG_ENTER("chk_index");
DBUG_DUMP("buff",(byte*) buff,maria_getint(buff)); DBUG_DUMP("buff",(byte*) buff,maria_data_on_page(buff));
/* TODO: implement appropriate check for RTree keys */ /* TODO: implement appropriate check for RTree keys */
if (keyinfo->flag & HA_SPATIAL) if (keyinfo->flag & HA_SPATIAL)
...@@ -759,7 +759,7 @@ static int chk_index(HA_CHECK *param, MARIA_HA *info, MARIA_KEYDEF *keyinfo, ...@@ -759,7 +759,7 @@ static int chk_index(HA_CHECK *param, MARIA_HA *info, MARIA_KEYDEF *keyinfo,
else else
comp_flag=SEARCH_SAME; /* Keys in positionorder */ comp_flag=SEARCH_SAME; /* Keys in positionorder */
nod_flag=_ma_test_if_nod(buff); nod_flag=_ma_test_if_nod(buff);
used_length=maria_getint(buff); used_length= maria_data_on_page(buff);
keypos=buff+2+nod_flag; keypos=buff+2+nod_flag;
endpos=buff+used_length; endpos=buff+used_length;
...@@ -2447,7 +2447,7 @@ static int sort_one_index(HA_CHECK *param, MARIA_HA *info, ...@@ -2447,7 +2447,7 @@ static int sort_one_index(HA_CHECK *param, MARIA_HA *info,
} }
if ((nod_flag=_ma_test_if_nod(buff)) || keyinfo->flag & HA_FULLTEXT) if ((nod_flag=_ma_test_if_nod(buff)) || keyinfo->flag & HA_FULLTEXT)
{ {
used_length=maria_getint(buff); used_length= maria_data_on_page(buff);
keypos=buff+2+nod_flag; keypos=buff+2+nod_flag;
endpos=buff+used_length; endpos=buff+used_length;
for ( ;; ) for ( ;; )
...@@ -2491,7 +2491,7 @@ static int sort_one_index(HA_CHECK *param, MARIA_HA *info, ...@@ -2491,7 +2491,7 @@ static int sort_one_index(HA_CHECK *param, MARIA_HA *info,
} }
/* Fill block with zero and write it to the new index file */ /* Fill block with zero and write it to the new index file */
length=maria_getint(buff); length= maria_data_on_page(buff);
bzero((byte*) buff+length,keyinfo->block_length-length); bzero((byte*) buff+length,keyinfo->block_length-length);
if (my_pwrite(new_file,(byte*) buff,(uint) keyinfo->block_length, if (my_pwrite(new_file,(byte*) buff,(uint) keyinfo->block_length,
new_page_pos,MYF(MY_NABP | MY_WAIT_IF_FULL))) new_page_pos,MYF(MY_NABP | MY_WAIT_IF_FULL)))
...@@ -4403,7 +4403,7 @@ static int sort_insert_key(MARIA_SORT_PARAM *sort_param, ...@@ -4403,7 +4403,7 @@ static int sort_insert_key(MARIA_SORT_PARAM *sort_param,
lastkey=0; /* No previous key in block */ lastkey=0; /* No previous key in block */
} }
else else
a_length=maria_getint(anc_buff); a_length= maria_data_on_page(anc_buff);
/* Save pointer to previous block */ /* Save pointer to previous block */
if (nod_flag) if (nod_flag)
...@@ -4440,7 +4440,7 @@ static int sort_insert_key(MARIA_SORT_PARAM *sort_param, ...@@ -4440,7 +4440,7 @@ static int sort_insert_key(MARIA_SORT_PARAM *sort_param,
else if (my_pwrite(info->s->kfile.file, anc_buff, else if (my_pwrite(info->s->kfile.file, anc_buff,
(uint) keyinfo->block_length,filepos, param->myf_rw)) (uint) keyinfo->block_length,filepos, param->myf_rw))
DBUG_RETURN(1); DBUG_RETURN(1);
DBUG_DUMP("buff",anc_buff,maria_getint(anc_buff)); DBUG_DUMP("buff",anc_buff,maria_data_on_page(anc_buff));
/* Write separator-key to block in next level */ /* Write separator-key to block in next level */
if (sort_insert_key(sort_param,key_block+1,key_block->lastkey,filepos)) if (sort_insert_key(sort_param,key_block+1,key_block->lastkey,filepos))
...@@ -4532,7 +4532,7 @@ int _ma_flush_pending_blocks(MARIA_SORT_PARAM *sort_param) ...@@ -4532,7 +4532,7 @@ int _ma_flush_pending_blocks(MARIA_SORT_PARAM *sort_param)
for (key_block=sort_info->key_block ; key_block->inited ; key_block++) for (key_block=sort_info->key_block ; key_block->inited ; key_block++)
{ {
key_block->inited=0; key_block->inited=0;
length=maria_getint(key_block->buff); length= maria_data_on_page(key_block->buff);
if (nod_flag) if (nod_flag)
_ma_kpointer(info,key_block->end_pos,filepos); _ma_kpointer(info,key_block->end_pos,filepos);
key_file_length=info->state->key_file_length; key_file_length=info->state->key_file_length;
......
...@@ -45,6 +45,7 @@ void _ma_print_key(FILE *stream, register HA_KEYSEG *keyseg, ...@@ -45,6 +45,7 @@ void _ma_print_key(FILE *stream, register HA_KEYSEG *keyseg,
fprintf(stream,"NULL"); fprintf(stream,"NULL");
continue; continue;
} }
end++;
} }
switch (keyseg->type) { switch (keyseg->type) {
......
...@@ -187,7 +187,7 @@ static int _ma_ck_real_delete(register MARIA_HA *info, MARIA_KEYDEF *keyinfo, ...@@ -187,7 +187,7 @@ static int _ma_ck_real_delete(register MARIA_HA *info, MARIA_KEYDEF *keyinfo,
} }
else /* error == 1 */ else /* error == 1 */
{ {
if (maria_getint(root_buff) <= (nod_flag=_ma_test_if_nod(root_buff))+3) if (maria_data_on_page(root_buff) <= (nod_flag=_ma_test_if_nod(root_buff))+3)
{ {
error=0; error=0;
if (nod_flag) if (nod_flag)
...@@ -228,7 +228,7 @@ static int d_search(register MARIA_HA *info, register MARIA_KEYDEF *keyinfo, ...@@ -228,7 +228,7 @@ static int d_search(register MARIA_HA *info, register MARIA_KEYDEF *keyinfo,
my_off_t leaf_page,next_block; my_off_t leaf_page,next_block;
byte lastkey[HA_MAX_KEY_BUFF]; byte lastkey[HA_MAX_KEY_BUFF];
DBUG_ENTER("d_search"); DBUG_ENTER("d_search");
DBUG_DUMP("page",anc_buff,maria_getint(anc_buff)); DBUG_DUMP("page",anc_buff,maria_data_on_page(anc_buff));
search_key_length= (comp_flag & SEARCH_FIND) ? key_length : USE_WHOLE_KEY; search_key_length= (comp_flag & SEARCH_FIND) ? key_length : USE_WHOLE_KEY;
flag=(*keyinfo->bin_search)(info,keyinfo,anc_buff,key, search_key_length, flag=(*keyinfo->bin_search)(info,keyinfo,anc_buff,key, search_key_length,
...@@ -338,7 +338,7 @@ static int d_search(register MARIA_HA *info, register MARIA_KEYDEF *keyinfo, ...@@ -338,7 +338,7 @@ static int d_search(register MARIA_HA *info, register MARIA_KEYDEF *keyinfo,
else else
{ /* Found key */ { /* Found key */
uint tmp; uint tmp;
length=maria_getint(anc_buff); length= maria_data_on_page(anc_buff);
if (!(tmp= remove_key(keyinfo,nod_flag,keypos,lastkey,anc_buff+length, if (!(tmp= remove_key(keyinfo,nod_flag,keypos,lastkey,anc_buff+length,
&next_block))) &next_block)))
goto err; goto err;
...@@ -375,7 +375,7 @@ static int d_search(register MARIA_HA *info, register MARIA_KEYDEF *keyinfo, ...@@ -375,7 +375,7 @@ static int d_search(register MARIA_HA *info, register MARIA_KEYDEF *keyinfo,
(byte*) 0,(byte*) 0,(my_off_t) 0,(my_bool) 0); (byte*) 0,(byte*) 0,(my_off_t) 0,(my_bool) 0);
} }
} }
if (ret_value == 0 && maria_getint(anc_buff) > keyinfo->block_length) if (ret_value == 0 && maria_data_on_page(anc_buff) > keyinfo->block_length)
{ {
save_flag=1; save_flag=1;
ret_value= _ma_split_page(info,keyinfo,key,anc_buff,lastkey,0) | 2; ret_value= _ma_split_page(info,keyinfo,key,anc_buff,lastkey,0) | 2;
...@@ -384,7 +384,7 @@ static int d_search(register MARIA_HA *info, register MARIA_KEYDEF *keyinfo, ...@@ -384,7 +384,7 @@ static int d_search(register MARIA_HA *info, register MARIA_KEYDEF *keyinfo,
ret_value|= _ma_write_keypage(info,keyinfo,page,DFLT_INIT_HITS,anc_buff); ret_value|= _ma_write_keypage(info,keyinfo,page,DFLT_INIT_HITS,anc_buff);
else else
{ {
DBUG_DUMP("page",anc_buff,maria_getint(anc_buff)); DBUG_DUMP("page",anc_buff,maria_data_on_page(anc_buff));
} }
my_afree(leaf_buff); my_afree(leaf_buff);
DBUG_PRINT("exit",("Return: %d",ret_value)); DBUG_PRINT("exit",("Return: %d",ret_value));
...@@ -415,9 +415,9 @@ static int del(register MARIA_HA *info, register MARIA_KEYDEF *keyinfo, ...@@ -415,9 +415,9 @@ static int del(register MARIA_HA *info, register MARIA_KEYDEF *keyinfo,
DBUG_ENTER("del"); DBUG_ENTER("del");
DBUG_PRINT("enter",("leaf_page: %ld keypos: 0x%lx", (long) leaf_page, DBUG_PRINT("enter",("leaf_page: %ld keypos: 0x%lx", (long) leaf_page,
(ulong) keypos)); (ulong) keypos));
DBUG_DUMP("leaf_buff",leaf_buff,maria_getint(leaf_buff)); DBUG_DUMP("leaf_buff",leaf_buff,maria_data_on_page(leaf_buff));
endpos= leaf_buff+ maria_getint(leaf_buff); endpos= leaf_buff+ maria_data_on_page(leaf_buff);
if (!(key_start= _ma_get_last_key(info,keyinfo,leaf_buff,keybuff,endpos, if (!(key_start= _ma_get_last_key(info,keyinfo,leaf_buff,keybuff,endpos,
&tmp))) &tmp)))
DBUG_RETURN(-1); DBUG_RETURN(-1);
...@@ -432,16 +432,16 @@ static int del(register MARIA_HA *info, register MARIA_KEYDEF *keyinfo, ...@@ -432,16 +432,16 @@ static int del(register MARIA_HA *info, register MARIA_KEYDEF *keyinfo,
ret_value= -1; ret_value= -1;
else else
{ {
DBUG_DUMP("next_page",next_buff,maria_getint(next_buff)); DBUG_DUMP("next_page",next_buff,maria_data_on_page(next_buff));
if ((ret_value=del(info,keyinfo,key,anc_buff,next_page,next_buff, if ((ret_value=del(info,keyinfo,key,anc_buff,next_page,next_buff,
keypos,next_block,ret_key)) >0) keypos,next_block,ret_key)) >0)
{ {
endpos=leaf_buff+maria_getint(leaf_buff); endpos=leaf_buff+maria_data_on_page(leaf_buff);
if (ret_value == 1) if (ret_value == 1)
{ {
ret_value=underflow(info,keyinfo,leaf_buff,next_page, ret_value=underflow(info,keyinfo,leaf_buff,next_page,
next_buff,endpos); next_buff,endpos);
if (ret_value == 0 && maria_getint(leaf_buff) > keyinfo->block_length) if (ret_value == 0 && maria_data_on_page(leaf_buff) > keyinfo->block_length)
{ {
ret_value= _ma_split_page(info,keyinfo,key,leaf_buff,ret_key,0) | 2; ret_value= _ma_split_page(info,keyinfo,key,leaf_buff,ret_key,0) | 2;
} }
...@@ -471,7 +471,7 @@ static int del(register MARIA_HA *info, register MARIA_KEYDEF *keyinfo, ...@@ -471,7 +471,7 @@ static int del(register MARIA_HA *info, register MARIA_KEYDEF *keyinfo,
/* Place last key in ancestor page on deleted key position */ /* Place last key in ancestor page on deleted key position */
a_length=maria_getint(anc_buff); a_length= maria_data_on_page(anc_buff);
endpos=anc_buff+a_length; endpos=anc_buff+a_length;
if (keypos != anc_buff+2+share->base.key_reflength && if (keypos != anc_buff+2+share->base.key_reflength &&
!_ma_get_last_key(info,keyinfo,anc_buff,ret_key,keypos,&tmp)) !_ma_get_last_key(info,keyinfo,anc_buff,ret_key,keypos,&tmp))
...@@ -493,7 +493,7 @@ static int del(register MARIA_HA *info, register MARIA_KEYDEF *keyinfo, ...@@ -493,7 +493,7 @@ static int del(register MARIA_HA *info, register MARIA_KEYDEF *keyinfo,
_ma_kpointer(info,keypos - share->base.key_reflength,next_block); _ma_kpointer(info,keypos - share->base.key_reflength,next_block);
maria_putint(anc_buff,a_length+length,share->base.key_reflength); maria_putint(anc_buff,a_length+length,share->base.key_reflength);
DBUG_RETURN( maria_getint(leaf_buff) <= DBUG_RETURN( maria_data_on_page(leaf_buff) <=
(info->quick_mode ? MARIA_MIN_KEYBLOCK_LENGTH : (info->quick_mode ? MARIA_MIN_KEYBLOCK_LENGTH :
(uint) keyinfo->underflow_block_length)); (uint) keyinfo->underflow_block_length));
err: err:
...@@ -521,16 +521,16 @@ static int underflow(register MARIA_HA *info, register MARIA_KEYDEF *keyinfo, ...@@ -521,16 +521,16 @@ static int underflow(register MARIA_HA *info, register MARIA_KEYDEF *keyinfo,
DBUG_ENTER("underflow"); DBUG_ENTER("underflow");
DBUG_PRINT("enter",("leaf_page: %ld keypos: 0x%lx",(long) leaf_page, DBUG_PRINT("enter",("leaf_page: %ld keypos: 0x%lx",(long) leaf_page,
(ulong) keypos)); (ulong) keypos));
DBUG_DUMP("anc_buff",anc_buff,maria_getint(anc_buff)); DBUG_DUMP("anc_buff",anc_buff,maria_data_on_page(anc_buff));
DBUG_DUMP("leaf_buff",leaf_buff,maria_getint(leaf_buff)); DBUG_DUMP("leaf_buff",leaf_buff,maria_data_on_page(leaf_buff));
buff=info->buff; buff=info->buff;
info->keyread_buff_used=1; info->keyread_buff_used=1;
next_keypos=keypos; next_keypos=keypos;
nod_flag=_ma_test_if_nod(leaf_buff); nod_flag=_ma_test_if_nod(leaf_buff);
p_length=nod_flag+2; p_length=nod_flag+2;
anc_length=maria_getint(anc_buff); anc_length= maria_data_on_page(anc_buff);
leaf_length=maria_getint(leaf_buff); leaf_length= maria_data_on_page(leaf_buff);
key_reflength=share->base.key_reflength; key_reflength=share->base.key_reflength;
if (info->s->keyinfo+info->lastinx == keyinfo) if (info->s->keyinfo+info->lastinx == keyinfo)
info->page_changed=1; info->page_changed=1;
...@@ -557,7 +557,7 @@ static int underflow(register MARIA_HA *info, register MARIA_KEYDEF *keyinfo, ...@@ -557,7 +557,7 @@ static int underflow(register MARIA_HA *info, register MARIA_KEYDEF *keyinfo,
next_page= _ma_kpos(key_reflength,next_keypos); next_page= _ma_kpos(key_reflength,next_keypos);
if (!_ma_fetch_keypage(info,keyinfo,next_page,DFLT_INIT_HITS,buff,0)) if (!_ma_fetch_keypage(info,keyinfo,next_page,DFLT_INIT_HITS,buff,0))
goto err; goto err;
buff_length=maria_getint(buff); buff_length= maria_data_on_page(buff);
DBUG_DUMP("next",buff,buff_length); DBUG_DUMP("next",buff,buff_length);
/* find keys to make a big key-page */ /* find keys to make a big key-page */
...@@ -637,7 +637,7 @@ static int underflow(register MARIA_HA *info, register MARIA_KEYDEF *keyinfo, ...@@ -637,7 +637,7 @@ static int underflow(register MARIA_HA *info, register MARIA_KEYDEF *keyinfo,
(byte*) 0, (byte*) 0, (byte*) 0, (byte*) 0,
leaf_key, &s_temp); leaf_key, &s_temp);
/* t_length will always be > 0 for a new page !*/ /* t_length will always be > 0 for a new page !*/
length=(uint) ((buff+maria_getint(buff))-half_pos); length=(uint) ((buff+maria_data_on_page(buff))-half_pos);
bmove(buff+p_length+t_length, half_pos, (size_t) length); bmove(buff+p_length+t_length, half_pos, (size_t) length);
(*keyinfo->store_key)(keyinfo,buff+p_length,&s_temp); (*keyinfo->store_key)(keyinfo,buff+p_length,&s_temp);
maria_putint(buff,length+t_length+p_length,nod_flag); maria_putint(buff,length+t_length+p_length,nod_flag);
...@@ -659,7 +659,7 @@ static int underflow(register MARIA_HA *info, register MARIA_KEYDEF *keyinfo, ...@@ -659,7 +659,7 @@ static int underflow(register MARIA_HA *info, register MARIA_KEYDEF *keyinfo,
next_page= _ma_kpos(key_reflength,keypos); next_page= _ma_kpos(key_reflength,keypos);
if (!_ma_fetch_keypage(info,keyinfo,next_page,DFLT_INIT_HITS,buff,0)) if (!_ma_fetch_keypage(info,keyinfo,next_page,DFLT_INIT_HITS,buff,0))
goto err; goto err;
buff_length=maria_getint(buff); buff_length= maria_data_on_page(buff);
endpos=buff+buff_length; endpos=buff+buff_length;
DBUG_DUMP("prev",buff,buff_length); DBUG_DUMP("prev",buff,buff_length);
......
...@@ -18,6 +18,7 @@ ...@@ -18,6 +18,7 @@
#include "maria_def.h" #include "maria_def.h"
#include <ft_global.h> #include <ft_global.h>
#include "ma_blockrec.h" #include "ma_blockrec.h"
#include "trnman_public.h"
my_bool maria_inited= FALSE; my_bool maria_inited= FALSE;
pthread_mutex_t THR_LOCK_maria; pthread_mutex_t THR_LOCK_maria;
......
...@@ -324,6 +324,7 @@ uint _ma_pack_key(register MARIA_HA *info, uint keynr, byte *key, ...@@ -324,6 +324,7 @@ uint _ma_pack_key(register MARIA_HA *info, uint keynr, byte *key,
key+=length; key+=length;
} }
#endif #endif
DBUG_PRINT("exit", ("length: %u", (uint) (key-start_key)));
DBUG_RETURN((uint) (key-start_key)); DBUG_RETURN((uint) (key-start_key));
} /* _ma_pack_key */ } /* _ma_pack_key */
......
...@@ -700,7 +700,7 @@ static my_bool translog_buffer_lock(struct st_translog_buffer *buffer) ...@@ -700,7 +700,7 @@ static my_bool translog_buffer_lock(struct st_translog_buffer *buffer)
} }
#else #else
#define translog_buffer_lock(B) \ #define translog_buffer_lock(B) \
pthread_mutex_lock(&B->mutex); pthread_mutex_lock(&B->mutex)
#endif #endif
...@@ -734,7 +734,7 @@ static my_bool translog_buffer_unlock(struct st_translog_buffer *buffer) ...@@ -734,7 +734,7 @@ static my_bool translog_buffer_unlock(struct st_translog_buffer *buffer)
} }
#else #else
#define translog_buffer_unlock(B) \ #define translog_buffer_unlock(B) \
pthread_mutex_unlock(&B->mutex); pthread_mutex_unlock(&B->mutex)
#endif #endif
...@@ -1352,7 +1352,6 @@ static uint16 translog_get_total_chunk_length(byte *page, uint16 offset) ...@@ -1352,7 +1352,6 @@ static uint16 translog_get_total_chunk_length(byte *page, uint16 offset)
if (rec_len + header_len < page_rest) if (rec_len + header_len < page_rest)
DBUG_RETURN(rec_len + header_len); DBUG_RETURN(rec_len + header_len);
DBUG_RETURN(page_rest); DBUG_RETURN(page_rest);
break;
} }
case TRANSLOG_CHUNK_FIXED: case TRANSLOG_CHUNK_FIXED:
{ {
...@@ -1373,7 +1372,7 @@ static uint16 translog_get_total_chunk_length(byte *page, uint16 offset) ...@@ -1373,7 +1372,7 @@ static uint16 translog_get_total_chunk_length(byte *page, uint16 offset)
(uint) (log_record_type_descriptor[type].fixed_length + 3))); (uint) (log_record_type_descriptor[type].fixed_length + 3)));
DBUG_RETURN(log_record_type_descriptor[type].fixed_length + 3); DBUG_RETURN(log_record_type_descriptor[type].fixed_length + 3);
} }
{
ptr= page + offset + 3; /* first compressed LSN */ ptr= page + offset + 3; /* first compressed LSN */
length= log_record_type_descriptor[type].fixed_length + 3; length= log_record_type_descriptor[type].fixed_length + 3;
for (i= 0; i < log_record_type_descriptor[type].compressed_LSN; i++) for (i= 0; i < log_record_type_descriptor[type].compressed_LSN; i++)
...@@ -1387,22 +1386,19 @@ static uint16 translog_get_total_chunk_length(byte *page, uint16 offset) ...@@ -1387,22 +1386,19 @@ static uint16 translog_get_total_chunk_length(byte *page, uint16 offset)
DBUG_PRINT("info", ("Pseudo-fixed length: %u", length)); DBUG_PRINT("info", ("Pseudo-fixed length: %u", length));
DBUG_RETURN(length); DBUG_RETURN(length);
} }
break;
}
case TRANSLOG_CHUNK_NOHDR: case TRANSLOG_CHUNK_NOHDR:
/* 2 no header chunk (till page end) */ /* 2 no header chunk (till page end) */
DBUG_PRINT("info", ("TRANSLOG_CHUNK_NOHDR length: %u", DBUG_PRINT("info", ("TRANSLOG_CHUNK_NOHDR length: %u",
(uint) (TRANSLOG_PAGE_SIZE - offset))); (uint) (TRANSLOG_PAGE_SIZE - offset)));
DBUG_RETURN(TRANSLOG_PAGE_SIZE - offset); DBUG_RETURN(TRANSLOG_PAGE_SIZE - offset);
break;
case TRANSLOG_CHUNK_LNGTH: /* 3 chunk with chunk length */ case TRANSLOG_CHUNK_LNGTH: /* 3 chunk with chunk length */
DBUG_PRINT("info", ("TRANSLOG_CHUNK_LNGTH")); DBUG_PRINT("info", ("TRANSLOG_CHUNK_LNGTH"));
DBUG_ASSERT(TRANSLOG_PAGE_SIZE - offset >= 3); DBUG_ASSERT(TRANSLOG_PAGE_SIZE - offset >= 3);
DBUG_PRINT("info", ("length: %u", uint2korr(page + offset + 1) + 3)); DBUG_PRINT("info", ("length: %u", uint2korr(page + offset + 1) + 3));
DBUG_RETURN(uint2korr(page + offset + 1) + 3); DBUG_RETURN(uint2korr(page + offset + 1) + 3);
break;
default: default:
DBUG_ASSERT(0); DBUG_ASSERT(0);
DBUG_RETURN(0);
} }
} }
...@@ -1839,9 +1835,9 @@ static uint16 translog_get_chunk_header_length(byte *page, uint16 offset) ...@@ -1839,9 +1835,9 @@ static uint16 translog_get_chunk_header_length(byte *page, uint16 offset)
{ {
/* TODO: fine header end */ /* TODO: fine header end */
DBUG_ASSERT(0); DBUG_ASSERT(0);
DBUG_RETURN(0); /* Keep compiler happy */
} }
DBUG_RETURN(header_len); DBUG_RETURN(header_len);
break;
} }
case TRANSLOG_CHUNK_FIXED: case TRANSLOG_CHUNK_FIXED:
{ {
...@@ -1861,6 +1857,7 @@ static uint16 translog_get_chunk_header_length(byte *page, uint16 offset) ...@@ -1861,6 +1857,7 @@ static uint16 translog_get_chunk_header_length(byte *page, uint16 offset)
break; break;
default: default:
DBUG_ASSERT(0); DBUG_ASSERT(0);
DBUG_RETURN(0); /* Keep compiler happy */
} }
} }
...@@ -2628,6 +2625,7 @@ translog_write_variable_record_chunk2_page(struct st_translog_parts *parts, ...@@ -2628,6 +2625,7 @@ translog_write_variable_record_chunk2_page(struct st_translog_parts *parts,
DBUG_ENTER("translog_write_variable_record_chunk2_page"); DBUG_ENTER("translog_write_variable_record_chunk2_page");
chunk2_header[0]= TRANSLOG_CHUNK_NOHDR; chunk2_header[0]= TRANSLOG_CHUNK_NOHDR;
LINT_INIT(buffer_to_flush);
rc= translog_page_next(horizon, cursor, &buffer_to_flush); rc= translog_page_next(horizon, cursor, &buffer_to_flush);
if (buffer_to_flush != NULL) if (buffer_to_flush != NULL)
{ {
...@@ -2676,6 +2674,7 @@ translog_write_variable_record_chunk3_page(struct st_translog_parts *parts, ...@@ -2676,6 +2674,7 @@ translog_write_variable_record_chunk3_page(struct st_translog_parts *parts,
byte chunk3_header[1 + 2]; byte chunk3_header[1 + 2];
DBUG_ENTER("translog_write_variable_record_chunk3_page"); DBUG_ENTER("translog_write_variable_record_chunk3_page");
LINT_INIT(buffer_to_flush);
rc= translog_page_next(horizon, cursor, &buffer_to_flush); rc= translog_page_next(horizon, cursor, &buffer_to_flush);
if (buffer_to_flush != NULL) if (buffer_to_flush != NULL)
{ {
...@@ -4144,8 +4143,18 @@ my_bool translog_write_record(LSN *lsn, ...@@ -4144,8 +4143,18 @@ my_bool translog_write_record(LSN *lsn,
{ {
uint i; uint i;
uint len= 0; uint len= 0;
#ifdef HAVE_PURIFY
ha_checksum checksum= 0;
#endif
for (i= TRANSLOG_INTERNAL_PARTS; i < part_no; i++) for (i= TRANSLOG_INTERNAL_PARTS; i < part_no; i++)
{
#ifdef HAVE_PURIFY
/* Find unitialized bytes early */
checksum+= my_checksum(checksum, parts_data[i].str,
parts_data[i].length);
#endif
len+= parts_data[i].length; len+= parts_data[i].length;
}
DBUG_ASSERT(len == rec_len); DBUG_ASSERT(len == rec_len);
} }
#endif #endif
...@@ -5219,7 +5228,6 @@ static void translog_force_current_buffer_to_finish() ...@@ -5219,7 +5228,6 @@ static void translog_force_current_buffer_to_finish()
} }
else else
{ {
left= 0;
log_descriptor.bc.current_page_fill= 0; log_descriptor.bc.current_page_fill= 0;
} }
......
...@@ -48,7 +48,7 @@ byte *_ma_fetch_keypage(register MARIA_HA *info, MARIA_KEYDEF *keyinfo, ...@@ -48,7 +48,7 @@ byte *_ma_fetch_keypage(register MARIA_HA *info, MARIA_KEYDEF *keyinfo,
DBUG_RETURN(0); DBUG_RETURN(0);
} }
info->last_keypage=page; info->last_keypage=page;
page_size=maria_getint(tmp); page_size= maria_data_on_page(tmp);
if (page_size < 4 || page_size > keyinfo->block_length) if (page_size < 4 || page_size > keyinfo->block_length)
{ {
DBUG_PRINT("error",("page %lu had wrong page length: %u", DBUG_PRINT("error",("page %lu had wrong page length: %u",
...@@ -70,7 +70,7 @@ int _ma_write_keypage(register MARIA_HA *info, register MARIA_KEYDEF *keyinfo, ...@@ -70,7 +70,7 @@ int _ma_write_keypage(register MARIA_HA *info, register MARIA_KEYDEF *keyinfo,
{ {
DBUG_ENTER("_ma_write_keypage"); DBUG_ENTER("_ma_write_keypage");
#ifndef FAST /* Safety check */ #ifdef EXTRA_DEBUG /* Safety check */
if (page < info->s->base.keystart || if (page < info->s->base.keystart ||
page+keyinfo->block_length > info->state->key_file_length || page+keyinfo->block_length > info->state->key_file_length ||
(page & (MARIA_MIN_KEY_BLOCK_LENGTH-1))) (page & (MARIA_MIN_KEY_BLOCK_LENGTH-1)))
...@@ -84,7 +84,16 @@ int _ma_write_keypage(register MARIA_HA *info, register MARIA_KEYDEF *keyinfo, ...@@ -84,7 +84,16 @@ int _ma_write_keypage(register MARIA_HA *info, register MARIA_KEYDEF *keyinfo,
DBUG_RETURN((-1)); DBUG_RETURN((-1));
} }
DBUG_PRINT("page",("write page at: %lu",(long) page)); DBUG_PRINT("page",("write page at: %lu",(long) page));
DBUG_DUMP("buff",(byte*) buff,maria_getint(buff)); DBUG_DUMP("buff",(byte*) buff,maria_data_on_page(buff));
#endif
#ifdef HAVE_purify
{
/* Clear unitialized part of page to avoid valgrind/purify warnings */
uint length= maria_data_on_page(buff);
bzero((byte*) buff+length,keyinfo->block_length-length);
length=keyinfo->block_length;
}
#endif #endif
DBUG_ASSERT(info->s->pagecache->block_size == keyinfo->block_length); DBUG_ASSERT(info->s->pagecache->block_size == keyinfo->block_length);
......
...@@ -233,7 +233,7 @@ static uint _ma_keynr(MARIA_HA *info, register MARIA_KEYDEF *keyinfo, ...@@ -233,7 +233,7 @@ static uint _ma_keynr(MARIA_HA *info, register MARIA_KEYDEF *keyinfo,
uint nod_flag,keynr,max_key; uint nod_flag,keynr,max_key;
byte t_buff[HA_MAX_KEY_BUFF],*end; byte t_buff[HA_MAX_KEY_BUFF],*end;
end= page+maria_getint(page); end= page+maria_data_on_page(page);
nod_flag=_ma_test_if_nod(page); nod_flag=_ma_test_if_nod(page);
page+=2+nod_flag; page+=2+nod_flag;
......
...@@ -824,7 +824,7 @@ static int maria_rtree_delete_req(MARIA_HA *info, MARIA_KEYDEF *keyinfo, ...@@ -824,7 +824,7 @@ static int maria_rtree_delete_req(MARIA_HA *info, MARIA_KEYDEF *keyinfo,
if (_ma_write_keypage(info, keyinfo, page, if (_ma_write_keypage(info, keyinfo, page,
DFLT_INIT_HITS, page_buf)) DFLT_INIT_HITS, page_buf))
goto err1; goto err1;
*page_size = maria_getint(page_buf); *page_size = maria_data_on_page(page_buf);
} }
goto ok; goto ok;
...@@ -839,7 +839,7 @@ static int maria_rtree_delete_req(MARIA_HA *info, MARIA_KEYDEF *keyinfo, ...@@ -839,7 +839,7 @@ static int maria_rtree_delete_req(MARIA_HA *info, MARIA_KEYDEF *keyinfo,
if (_ma_write_keypage(info, keyinfo, page, if (_ma_write_keypage(info, keyinfo, page,
DFLT_INIT_HITS, page_buf)) DFLT_INIT_HITS, page_buf))
goto err1; goto err1;
*page_size = maria_getint(page_buf); *page_size = maria_data_on_page(page_buf);
res = 0; res = 0;
goto ok; goto ok;
} }
...@@ -857,7 +857,7 @@ static int maria_rtree_delete_req(MARIA_HA *info, MARIA_KEYDEF *keyinfo, ...@@ -857,7 +857,7 @@ static int maria_rtree_delete_req(MARIA_HA *info, MARIA_KEYDEF *keyinfo,
if (!maria_rtree_key_cmp(keyinfo->seg, key, k, key_length, MBR_EQUAL | MBR_DATA)) if (!maria_rtree_key_cmp(keyinfo->seg, key, k, key_length, MBR_EQUAL | MBR_DATA))
{ {
maria_rtree_delete_key(info, page_buf, k, key_length, nod_flag); maria_rtree_delete_key(info, page_buf, k, key_length, nod_flag);
*page_size = maria_getint(page_buf); *page_size = maria_data_on_page(page_buf);
if (*page_size == 2) if (*page_size == 2)
{ {
/* last key in the leaf */ /* last key in the leaf */
...@@ -963,7 +963,7 @@ int maria_rtree_delete(MARIA_HA *info, uint keynr, byte *key, uint key_length) ...@@ -963,7 +963,7 @@ int maria_rtree_delete(MARIA_HA *info, uint keynr, byte *key, uint key_length)
info->buff, 0)) info->buff, 0))
goto err1; goto err1;
nod_flag = _ma_test_if_nod(info->buff); nod_flag = _ma_test_if_nod(info->buff);
page_size = maria_getint(info->buff); page_size = maria_data_on_page(info->buff);
if (nod_flag && (page_size == 2 + key_length + nod_flag)) if (nod_flag && (page_size == 2 + key_length + nod_flag))
{ {
my_off_t new_root = _ma_kpos(nod_flag, my_off_t new_root = _ma_kpos(nod_flag,
......
...@@ -22,7 +22,7 @@ ...@@ -22,7 +22,7 @@
#define rt_PAGE_FIRST_KEY(page, nod_flag) (page + 2 + nod_flag) #define rt_PAGE_FIRST_KEY(page, nod_flag) (page + 2 + nod_flag)
#define rt_PAGE_NEXT_KEY(key, key_length, nod_flag) (key + key_length + \ #define rt_PAGE_NEXT_KEY(key, key_length, nod_flag) (key + key_length + \
(nod_flag ? nod_flag : info->s->base.rec_reflength)) (nod_flag ? nod_flag : info->s->base.rec_reflength))
#define rt_PAGE_END(page) (page + maria_getint(page)) #define rt_PAGE_END(page) (page + maria_data_on_page(page))
#define rt_PAGE_MIN_SIZE(block_length) ((uint)(block_length) / 3) #define rt_PAGE_MIN_SIZE(block_length) ((uint)(block_length) / 3)
......
...@@ -32,7 +32,7 @@ ...@@ -32,7 +32,7 @@
int maria_rtree_add_key(MARIA_HA *info, MARIA_KEYDEF *keyinfo, byte *key, int maria_rtree_add_key(MARIA_HA *info, MARIA_KEYDEF *keyinfo, byte *key,
uint key_length, byte *page_buf, my_off_t *new_page) uint key_length, byte *page_buf, my_off_t *new_page)
{ {
uint page_size = maria_getint(page_buf); uint page_size = maria_data_on_page(page_buf);
uint nod_flag = _ma_test_if_nod(page_buf); uint nod_flag = _ma_test_if_nod(page_buf);
if (page_size + key_length + info->s->base.rec_reflength <= if (page_size + key_length + info->s->base.rec_reflength <=
...@@ -68,7 +68,7 @@ int maria_rtree_add_key(MARIA_HA *info, MARIA_KEYDEF *keyinfo, byte *key, ...@@ -68,7 +68,7 @@ int maria_rtree_add_key(MARIA_HA *info, MARIA_KEYDEF *keyinfo, byte *key,
int maria_rtree_delete_key(MARIA_HA *info, byte *page_buf, byte *key, int maria_rtree_delete_key(MARIA_HA *info, byte *page_buf, byte *key,
uint key_length, uint nod_flag) uint key_length, uint nod_flag)
{ {
uint16 page_size = maria_getint(page_buf); uint16 page_size = maria_data_on_page(page_buf);
byte *key_start; byte *key_start;
key_start= key - nod_flag; key_start= key - nod_flag;
......
...@@ -265,7 +265,7 @@ int maria_rtree_split_page(MARIA_HA *info, MARIA_KEYDEF *keyinfo, ...@@ -265,7 +265,7 @@ int maria_rtree_split_page(MARIA_HA *info, MARIA_KEYDEF *keyinfo,
uint nod_flag= _ma_test_if_nod(page); uint nod_flag= _ma_test_if_nod(page);
uint full_length= key_length + (nod_flag ? nod_flag : uint full_length= key_length + (nod_flag ? nod_flag :
info->s->base.rec_reflength); info->s->base.rec_reflength);
int max_keys= (maria_getint(page)-2) / (full_length); int max_keys= (maria_data_on_page(page)-2) / (full_length);
n_dim = keyinfo->keysegs / 2; n_dim = keyinfo->keysegs / 2;
...@@ -296,7 +296,7 @@ int maria_rtree_split_page(MARIA_HA *info, MARIA_KEYDEF *keyinfo, ...@@ -296,7 +296,7 @@ int maria_rtree_split_page(MARIA_HA *info, MARIA_KEYDEF *keyinfo,
old_coord = next_coord; old_coord = next_coord;
if (split_maria_rtree_node(task, max_keys + 1, if (split_maria_rtree_node(task, max_keys + 1,
maria_getint(page) + full_length + 2, full_length, maria_data_on_page(page) + full_length + 2, full_length,
rt_PAGE_MIN_SIZE(keyinfo->block_length), rt_PAGE_MIN_SIZE(keyinfo->block_length),
2, 2, &next_coord, n_dim)) 2, 2, &next_coord, n_dim))
{ {
......
...@@ -80,14 +80,14 @@ int _ma_search(register MARIA_HA *info, register MARIA_KEYDEF *keyinfo, ...@@ -80,14 +80,14 @@ int _ma_search(register MARIA_HA *info, register MARIA_KEYDEF *keyinfo,
info->keyread_buff, info->keyread_buff,
test(!(nextflag & SEARCH_SAVE_BUFF))))) test(!(nextflag & SEARCH_SAVE_BUFF)))))
goto err; goto err;
DBUG_DUMP("page", buff, maria_getint(buff)); DBUG_DUMP("page", buff, maria_data_on_page(buff));
flag=(*keyinfo->bin_search)(info,keyinfo,buff,key,key_len,nextflag, flag=(*keyinfo->bin_search)(info,keyinfo,buff,key,key_len,nextflag,
&keypos,lastkey, &last_key); &keypos,lastkey, &last_key);
if (flag == MARIA_FOUND_WRONG_KEY) if (flag == MARIA_FOUND_WRONG_KEY)
DBUG_RETURN(-1); DBUG_RETURN(-1);
nod_flag=_ma_test_if_nod(buff); nod_flag=_ma_test_if_nod(buff);
maxpos=buff+maria_getint(buff)-1; maxpos=buff+maria_data_on_page(buff)-1;
if (flag) if (flag)
{ {
...@@ -187,8 +187,8 @@ int _ma_bin_search(MARIA_HA *info, register MARIA_KEYDEF *keyinfo, byte *page, ...@@ -187,8 +187,8 @@ int _ma_bin_search(MARIA_HA *info, register MARIA_KEYDEF *keyinfo, byte *page,
LINT_INIT(flag); LINT_INIT(flag);
totlength=keyinfo->keylength+(nod_flag=_ma_test_if_nod(page)); totlength=keyinfo->keylength+(nod_flag=_ma_test_if_nod(page));
start=0; mid=1; start=0; mid=1;
save_end=end=(int) ((maria_getint(page)-2-nod_flag)/totlength-1); save_end=end=(int) ((maria_data_on_page(page)-2-nod_flag)/totlength-1);
DBUG_PRINT("test",("page_length: %d end: %d",maria_getint(page),end)); DBUG_PRINT("test",("page_length: %d end: %d",maria_data_on_page(page),end));
page+=2+nod_flag; page+=2+nod_flag;
while (start != end) while (start != end)
...@@ -249,7 +249,7 @@ int _ma_seq_search(MARIA_HA *info, register MARIA_KEYDEF *keyinfo, byte *page, ...@@ -249,7 +249,7 @@ int _ma_seq_search(MARIA_HA *info, register MARIA_KEYDEF *keyinfo, byte *page,
DBUG_ENTER("_ma_seq_search"); DBUG_ENTER("_ma_seq_search");
LINT_INIT(flag); LINT_INIT(length); LINT_INIT(flag); LINT_INIT(length);
end= page+maria_getint(page); end= page+maria_data_on_page(page);
nod_flag=_ma_test_if_nod(page); nod_flag=_ma_test_if_nod(page);
page+=2+nod_flag; page+=2+nod_flag;
*ret_pos=page; *ret_pos=page;
...@@ -314,7 +314,7 @@ int _ma_prefix_search(MARIA_HA *info, register MARIA_KEYDEF *keyinfo, ...@@ -314,7 +314,7 @@ int _ma_prefix_search(MARIA_HA *info, register MARIA_KEYDEF *keyinfo,
LINT_INIT(saved_vseg); LINT_INIT(saved_vseg);
t_buff[0]=0; /* Avoid bugs */ t_buff[0]=0; /* Avoid bugs */
end= page+maria_getint(page); end= page+maria_data_on_page(page);
nod_flag=_ma_test_if_nod(page); nod_flag=_ma_test_if_nod(page);
page+=2+nod_flag; page+=2+nod_flag;
*ret_pos=page; *ret_pos=page;
...@@ -1324,7 +1324,7 @@ int _ma_search_first(register MARIA_HA *info, register MARIA_KEYDEF *keyinfo, ...@@ -1324,7 +1324,7 @@ int _ma_search_first(register MARIA_HA *info, register MARIA_KEYDEF *keyinfo,
info->lastkey))) info->lastkey)))
DBUG_RETURN(-1); /* Crashed */ DBUG_RETURN(-1); /* Crashed */
info->int_keypos=page; info->int_maxpos=info->keyread_buff+maria_getint(info->keyread_buff)-1; info->int_keypos=page; info->int_maxpos=info->keyread_buff+maria_data_on_page(info->keyread_buff)-1;
info->int_nod_flag=nod_flag; info->int_nod_flag=nod_flag;
info->int_keytree_version=keyinfo->version; info->int_keytree_version=keyinfo->version;
info->last_search_keypage=info->last_keypage; info->last_search_keypage=info->last_keypage;
...@@ -1361,7 +1361,7 @@ int _ma_search_last(register MARIA_HA *info, register MARIA_KEYDEF *keyinfo, ...@@ -1361,7 +1361,7 @@ int _ma_search_last(register MARIA_HA *info, register MARIA_KEYDEF *keyinfo,
info->cur_row.lastpos= HA_OFFSET_ERROR; info->cur_row.lastpos= HA_OFFSET_ERROR;
DBUG_RETURN(-1); DBUG_RETURN(-1);
} }
page= buff+maria_getint(buff); page= buff+maria_data_on_page(buff);
nod_flag=_ma_test_if_nod(buff); nod_flag=_ma_test_if_nod(buff);
} while ((pos= _ma_kpos(nod_flag,page)) != HA_OFFSET_ERROR); } while ((pos= _ma_kpos(nod_flag,page)) != HA_OFFSET_ERROR);
......
...@@ -631,7 +631,7 @@ static struct my_option my_long_options[] = ...@@ -631,7 +631,7 @@ static struct my_option my_long_options[] =
static my_bool static my_bool
get_one_option(int optid, const struct my_option *opt __attribute__((unused)), get_one_option(int optid, const struct my_option *opt __attribute__((unused)),
char *argument) char *argument __attribute__((unused)))
{ {
switch(optid) { switch(optid) {
case 'a': case 'a':
......
...@@ -511,7 +511,7 @@ int _ma_insert(register MARIA_HA *info, register MARIA_KEYDEF *keyinfo, ...@@ -511,7 +511,7 @@ int _ma_insert(register MARIA_HA *info, register MARIA_KEYDEF *keyinfo,
USE_WHOLE_KEY);); USE_WHOLE_KEY););
nod_flag=_ma_test_if_nod(anc_buff); nod_flag=_ma_test_if_nod(anc_buff);
a_length=maria_getint(anc_buff); a_length= maria_data_on_page(anc_buff);
endpos= anc_buff+ a_length; endpos= anc_buff+ a_length;
prev_key=(key_pos == anc_buff+2+nod_flag ? (byte*) 0 : key_buff); prev_key=(key_pos == anc_buff+2+nod_flag ? (byte*) 0 : key_buff);
t_length=(*keyinfo->pack_key)(keyinfo,nod_flag, t_length=(*keyinfo->pack_key)(keyinfo,nod_flag,
...@@ -630,7 +630,7 @@ int _ma_split_page(register MARIA_HA *info, register MARIA_KEYDEF *keyinfo, ...@@ -630,7 +630,7 @@ int _ma_split_page(register MARIA_HA *info, register MARIA_KEYDEF *keyinfo,
MARIA_KEY_PARAM s_temp; MARIA_KEY_PARAM s_temp;
DBUG_ENTER("maria_split_page"); DBUG_ENTER("maria_split_page");
LINT_INIT(after_key); LINT_INIT(after_key);
DBUG_DUMP("buff",(byte*) buff,maria_getint(buff)); DBUG_DUMP("buff",(byte*) buff,maria_data_on_page(buff));
if (info->s->keyinfo+info->lastinx == keyinfo) if (info->s->keyinfo+info->lastinx == keyinfo)
info->page_changed=1; /* Info->buff is used */ info->page_changed=1; /* Info->buff is used */
...@@ -646,7 +646,7 @@ int _ma_split_page(register MARIA_HA *info, register MARIA_KEYDEF *keyinfo, ...@@ -646,7 +646,7 @@ int _ma_split_page(register MARIA_HA *info, register MARIA_KEYDEF *keyinfo,
DBUG_RETURN(-1); DBUG_RETURN(-1);
length=(uint) (key_pos-buff); length=(uint) (key_pos-buff);
a_length=maria_getint(buff); a_length= maria_data_on_page(buff);
maria_putint(buff,length,nod_flag); maria_putint(buff,length,nod_flag);
key_pos=after_key; key_pos=after_key;
...@@ -699,7 +699,7 @@ byte *_ma_find_half_pos(uint nod_flag, MARIA_KEYDEF *keyinfo, byte *page, ...@@ -699,7 +699,7 @@ byte *_ma_find_half_pos(uint nod_flag, MARIA_KEYDEF *keyinfo, byte *page,
DBUG_ENTER("_ma_find_half_pos"); DBUG_ENTER("_ma_find_half_pos");
key_ref_length=2+nod_flag; key_ref_length=2+nod_flag;
length=maria_getint(page)-key_ref_length; length= maria_data_on_page(page)-key_ref_length;
page+=key_ref_length; page+=key_ref_length;
if (!(keyinfo->flag & if (!(keyinfo->flag &
(HA_PACK_KEY | HA_SPACE_PACK_USED | HA_VAR_LENGTH_KEY | (HA_PACK_KEY | HA_SPACE_PACK_USED | HA_VAR_LENGTH_KEY |
...@@ -746,7 +746,7 @@ static byte *_ma_find_last_pos(MARIA_KEYDEF *keyinfo, byte *page, ...@@ -746,7 +746,7 @@ static byte *_ma_find_last_pos(MARIA_KEYDEF *keyinfo, byte *page,
DBUG_ENTER("_ma_find_last_pos"); DBUG_ENTER("_ma_find_last_pos");
key_ref_length=2; key_ref_length=2;
length=maria_getint(page)-key_ref_length; length= maria_data_on_page(page)-key_ref_length;
page+=key_ref_length; page+=key_ref_length;
if (!(keyinfo->flag & if (!(keyinfo->flag &
(HA_PACK_KEY | HA_SPACE_PACK_USED | HA_VAR_LENGTH_KEY | (HA_PACK_KEY | HA_SPACE_PACK_USED | HA_VAR_LENGTH_KEY |
...@@ -803,7 +803,7 @@ static int _ma_balance_page(register MARIA_HA *info, MARIA_KEYDEF *keyinfo, ...@@ -803,7 +803,7 @@ static int _ma_balance_page(register MARIA_HA *info, MARIA_KEYDEF *keyinfo,
DBUG_ENTER("_ma_balance_page"); DBUG_ENTER("_ma_balance_page");
k_length=keyinfo->keylength; k_length=keyinfo->keylength;
father_length=maria_getint(father_buff); father_length= maria_data_on_page(father_buff);
father_keylength=k_length+info->s->base.key_reflength; father_keylength=k_length+info->s->base.key_reflength;
nod_flag=_ma_test_if_nod(curr_buff); nod_flag=_ma_test_if_nod(curr_buff);
curr_keylength=k_length+nod_flag; curr_keylength=k_length+nod_flag;
...@@ -831,12 +831,12 @@ static int _ma_balance_page(register MARIA_HA *info, MARIA_KEYDEF *keyinfo, ...@@ -831,12 +831,12 @@ static int _ma_balance_page(register MARIA_HA *info, MARIA_KEYDEF *keyinfo,
if (!_ma_fetch_keypage(info,keyinfo,next_page,DFLT_INIT_HITS,info->buff,0)) if (!_ma_fetch_keypage(info,keyinfo,next_page,DFLT_INIT_HITS,info->buff,0))
goto err; goto err;
DBUG_DUMP("next",(byte*) info->buff,maria_getint(info->buff)); DBUG_DUMP("next",(byte*) info->buff,maria_data_on_page(info->buff));
/* Test if there is room to share keys */ /* Test if there is room to share keys */
left_length=maria_getint(curr_buff); left_length= maria_data_on_page(curr_buff);
right_length=maria_getint(buff); right_length= maria_data_on_page(buff);
keys=(left_length+right_length-4-nod_flag*2)/curr_keylength; keys=(left_length+right_length-4-nod_flag*2)/curr_keylength;
if ((right ? right_length : left_length) + curr_keylength <= if ((right ? right_length : left_length) + curr_keylength <=
......
...@@ -1670,7 +1670,7 @@ static int sort_record_index(MARIA_SORT_PARAM *sort_param,MARIA_HA *info, ...@@ -1670,7 +1670,7 @@ static int sort_record_index(MARIA_SORT_PARAM *sort_param,MARIA_HA *info,
DBUG_RETURN(-1); DBUG_RETURN(-1);
} }
} }
used_length=maria_getint(buff); used_length= maria_data_on_page(buff);
keypos=buff+2+nod_flag; keypos=buff+2+nod_flag;
endpos=buff+used_length; endpos=buff+used_length;
for ( ;; ) for ( ;; )
......
...@@ -485,7 +485,7 @@ struct st_maria_info ...@@ -485,7 +485,7 @@ struct st_maria_info
#define READING_NEXT 1 #define READING_NEXT 1
#define READING_HEADER 2 #define READING_HEADER 2
#define maria_getint(x) ((uint) mi_uint2korr(x) & 32767) #define maria_data_on_page(x) ((uint) mi_uint2korr(x) & 32767)
#define maria_putint(x,y,nod) { uint16 boh=(nod ? (uint16) 32768 : 0) + (uint16) (y);\ #define maria_putint(x,y,nod) { uint16 boh=(nod ? (uint16) 32768 : 0) + (uint16) (y);\
mi_int2store(x,boh); } mi_int2store(x,boh); }
#define _ma_test_if_nod(x) (x[0] & 128 ? info->s->base.key_reflength : 0) #define _ma_test_if_nod(x) (x[0] & 128 ? info->s->base.key_reflength : 0)
......
...@@ -289,7 +289,8 @@ static void *test_thread_writer(void *arg) ...@@ -289,7 +289,8 @@ static void *test_thread_writer(void *arg)
DBUG_RETURN(0); DBUG_RETURN(0);
} }
int main(int argc, char **argv __attribute__((unused))) int main(int argc __attribute__((unused)),
char **argv __attribute__((unused)))
{ {
pthread_t tid; pthread_t tid;
pthread_attr_t thr_attr; pthread_attr_t thr_attr;
......
...@@ -421,7 +421,9 @@ int simple_big_test() ...@@ -421,7 +421,9 @@ int simple_big_test()
static void *test_thread(void *arg) static void *test_thread(void *arg)
{ {
int param=*((int*) arg); #ifndef DBUG_OFF
int param= *((int*) arg);
#endif
my_thread_init(); my_thread_init();
DBUG_ENTER("test_thread"); DBUG_ENTER("test_thread");
...@@ -452,7 +454,8 @@ static void *test_thread(void *arg) ...@@ -452,7 +454,8 @@ static void *test_thread(void *arg)
} }
int main(int argc, char **argv __attribute__((unused))) int main(int argc __attribute__((unused)),
char **argv __attribute__((unused)))
{ {
pthread_t tid; pthread_t tid;
pthread_attr_t thr_attr; pthread_attr_t thr_attr;
......
...@@ -92,7 +92,7 @@ static my_bool read_and_check_content(TRANSLOG_HEADER_BUFFER *rec, ...@@ -92,7 +92,7 @@ static my_bool read_and_check_content(TRANSLOG_HEADER_BUFFER *rec,
return check_content(buffer + skip, rec->record_length - skip); return check_content(buffer + skip, rec->record_length - skip);
} }
int main(int argc, char *argv[]) int main(int argc __attribute__((unused)), char *argv[])
{ {
uint32 i; uint32 i;
uint32 rec_len; uint32 rec_len;
......
...@@ -108,7 +108,7 @@ static uint32 get_len() ...@@ -108,7 +108,7 @@ static uint32 get_len()
return rec_len; return rec_len;
} }
int main(int argc, char *argv[]) int main(int argc __attribute__((unused)), char *argv[])
{ {
uint32 i; uint32 i;
uint32 rec_len; uint32 rec_len;
......
...@@ -188,7 +188,8 @@ static void *test_thread_writer(void *arg) ...@@ -188,7 +188,8 @@ static void *test_thread_writer(void *arg)
} }
int main(int argc, char **argv __attribute__ ((unused))) int main(int argc __attribute__((unused)),
char **argv __attribute__ ((unused)))
{ {
uint32 i; uint32 i;
uint pagen; uint pagen;
......
...@@ -18,7 +18,7 @@ static char *first_translog_file= (char*)"maria_log.00000001"; ...@@ -18,7 +18,7 @@ static char *first_translog_file= (char*)"maria_log.00000001";
static char *file1_name= (char*)"page_cache_test_file_1"; static char *file1_name= (char*)"page_cache_test_file_1";
static PAGECACHE_FILE file1; static PAGECACHE_FILE file1;
int main(int argc, char *argv[]) int main(int argc __attribute__((unused)), char *argv[])
{ {
uint pagen; uint pagen;
byte long_tr_id[6]; byte long_tr_id[6];
......
...@@ -45,6 +45,7 @@ void _mi_print_key(FILE *stream, register HA_KEYSEG *keyseg, ...@@ -45,6 +45,7 @@ void _mi_print_key(FILE *stream, register HA_KEYSEG *keyseg,
fprintf(stream,"NULL"); fprintf(stream,"NULL");
continue; continue;
} }
end++;
} }
switch (keyseg->type) { switch (keyseg->type) {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment