diff --git a/mysys/safemalloc.c b/mysys/safemalloc.c index da15b02345b..5ab6d0dda0d 100644 --- a/mysys/safemalloc.c +++ b/mysys/safemalloc.c @@ -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 */ static int _checkchunk(register struct st_irem *irem, const char *filename, diff --git a/sql/opt_range.cc b/sql/opt_range.cc index 5789c1a4ae3..76618c9e373 100644 --- a/sql/opt_range.cc +++ b/sql/opt_range.cc @@ -4183,7 +4183,6 @@ static bool ror_intersect_add(ROR_INTERSECT_INFO *info, } info->out_rows *= selectivity_mult; - DBUG_PRINT("info", ("info->total_cost= %g", info->total_cost)); if (is_cpk_scan) { diff --git a/storage/maria/ma_blockrec.c b/storage/maria/ma_blockrec.c index 1d7f96f6557..c747aaeb6cb 100644 --- a/storage/maria/ma_blockrec.c +++ b/storage/maria/ma_blockrec.c @@ -2056,7 +2056,9 @@ static my_bool write_block_record(MARIA_HA *info, blob_length-= (blob_length % FULL_PAGE_SIZE(block_size)); 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_entry_length+= blob_length; log_array_pos++; diff --git a/storage/maria/ma_check.c b/storage/maria/ma_check.c index 8755caf2445..8f10c98d0ee 100644 --- a/storage/maria/ma_check.c +++ b/storage/maria/ma_check.c @@ -742,7 +742,7 @@ static int chk_index(HA_CHECK *param, MARIA_HA *info, MARIA_KEYDEF *keyinfo, char llbuff[22]; uint diff_pos[2]; 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 */ if (keyinfo->flag & HA_SPATIAL) @@ -759,7 +759,7 @@ static int chk_index(HA_CHECK *param, MARIA_HA *info, MARIA_KEYDEF *keyinfo, else comp_flag=SEARCH_SAME; /* Keys in positionorder */ nod_flag=_ma_test_if_nod(buff); - used_length=maria_getint(buff); + used_length= maria_data_on_page(buff); keypos=buff+2+nod_flag; endpos=buff+used_length; @@ -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) { - used_length=maria_getint(buff); + used_length= maria_data_on_page(buff); keypos=buff+2+nod_flag; endpos=buff+used_length; for ( ;; ) @@ -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 */ - length=maria_getint(buff); + length= maria_data_on_page(buff); bzero((byte*) buff+length,keyinfo->block_length-length); if (my_pwrite(new_file,(byte*) buff,(uint) keyinfo->block_length, new_page_pos,MYF(MY_NABP | MY_WAIT_IF_FULL))) @@ -4403,7 +4403,7 @@ static int sort_insert_key(MARIA_SORT_PARAM *sort_param, lastkey=0; /* No previous key in block */ } else - a_length=maria_getint(anc_buff); + a_length= maria_data_on_page(anc_buff); /* Save pointer to previous block */ if (nod_flag) @@ -4440,7 +4440,7 @@ static int sort_insert_key(MARIA_SORT_PARAM *sort_param, else if (my_pwrite(info->s->kfile.file, anc_buff, (uint) keyinfo->block_length,filepos, param->myf_rw)) 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 */ 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) for (key_block=sort_info->key_block ; key_block->inited ; key_block++) { key_block->inited=0; - length=maria_getint(key_block->buff); + length= maria_data_on_page(key_block->buff); if (nod_flag) _ma_kpointer(info,key_block->end_pos,filepos); key_file_length=info->state->key_file_length; diff --git a/storage/maria/ma_dbug.c b/storage/maria/ma_dbug.c index 10c570c5794..150385607b6 100644 --- a/storage/maria/ma_dbug.c +++ b/storage/maria/ma_dbug.c @@ -45,6 +45,7 @@ void _ma_print_key(FILE *stream, register HA_KEYSEG *keyseg, fprintf(stream,"NULL"); continue; } + end++; } switch (keyseg->type) { diff --git a/storage/maria/ma_delete.c b/storage/maria/ma_delete.c index 436a65a52ce..54c6b7aaefc 100644 --- a/storage/maria/ma_delete.c +++ b/storage/maria/ma_delete.c @@ -187,7 +187,7 @@ static int _ma_ck_real_delete(register MARIA_HA *info, MARIA_KEYDEF *keyinfo, } 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; if (nod_flag) @@ -228,7 +228,7 @@ static int d_search(register MARIA_HA *info, register MARIA_KEYDEF *keyinfo, my_off_t leaf_page,next_block; byte lastkey[HA_MAX_KEY_BUFF]; 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; 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, else { /* Found key */ 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, &next_block))) goto err; @@ -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); } } - 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; 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, ret_value|= _ma_write_keypage(info,keyinfo,page,DFLT_INIT_HITS,anc_buff); 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); DBUG_PRINT("exit",("Return: %d",ret_value)); @@ -415,9 +415,9 @@ static int del(register MARIA_HA *info, register MARIA_KEYDEF *keyinfo, DBUG_ENTER("del"); DBUG_PRINT("enter",("leaf_page: %ld keypos: 0x%lx", (long) leaf_page, (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, &tmp))) DBUG_RETURN(-1); @@ -432,16 +432,16 @@ static int del(register MARIA_HA *info, register MARIA_KEYDEF *keyinfo, ret_value= -1; 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, 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) { ret_value=underflow(info,keyinfo,leaf_buff,next_page, 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; } @@ -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 */ - a_length=maria_getint(anc_buff); + a_length= maria_data_on_page(anc_buff); endpos=anc_buff+a_length; if (keypos != anc_buff+2+share->base.key_reflength && !_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, _ma_kpointer(info,keypos - share->base.key_reflength,next_block); 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 : (uint) keyinfo->underflow_block_length)); err: @@ -521,16 +521,16 @@ static int underflow(register MARIA_HA *info, register MARIA_KEYDEF *keyinfo, DBUG_ENTER("underflow"); DBUG_PRINT("enter",("leaf_page: %ld keypos: 0x%lx",(long) leaf_page, (ulong) keypos)); - DBUG_DUMP("anc_buff",anc_buff,maria_getint(anc_buff)); - DBUG_DUMP("leaf_buff",leaf_buff,maria_getint(leaf_buff)); + DBUG_DUMP("anc_buff",anc_buff,maria_data_on_page(anc_buff)); + DBUG_DUMP("leaf_buff",leaf_buff,maria_data_on_page(leaf_buff)); buff=info->buff; info->keyread_buff_used=1; next_keypos=keypos; nod_flag=_ma_test_if_nod(leaf_buff); p_length=nod_flag+2; - anc_length=maria_getint(anc_buff); - leaf_length=maria_getint(leaf_buff); + anc_length= maria_data_on_page(anc_buff); + leaf_length= maria_data_on_page(leaf_buff); key_reflength=share->base.key_reflength; if (info->s->keyinfo+info->lastinx == keyinfo) info->page_changed=1; @@ -557,7 +557,7 @@ static int underflow(register MARIA_HA *info, register MARIA_KEYDEF *keyinfo, next_page= _ma_kpos(key_reflength,next_keypos); if (!_ma_fetch_keypage(info,keyinfo,next_page,DFLT_INIT_HITS,buff,0)) goto err; - buff_length=maria_getint(buff); + buff_length= maria_data_on_page(buff); DBUG_DUMP("next",buff,buff_length); /* find keys to make a big key-page */ @@ -637,7 +637,7 @@ static int underflow(register MARIA_HA *info, register MARIA_KEYDEF *keyinfo, (byte*) 0, (byte*) 0, leaf_key, &s_temp); /* 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); (*keyinfo->store_key)(keyinfo,buff+p_length,&s_temp); 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, next_page= _ma_kpos(key_reflength,keypos); if (!_ma_fetch_keypage(info,keyinfo,next_page,DFLT_INIT_HITS,buff,0)) goto err; - buff_length=maria_getint(buff); + buff_length= maria_data_on_page(buff); endpos=buff+buff_length; DBUG_DUMP("prev",buff,buff_length); diff --git a/storage/maria/ma_init.c b/storage/maria/ma_init.c index c56e6704729..19b835a837f 100644 --- a/storage/maria/ma_init.c +++ b/storage/maria/ma_init.c @@ -18,6 +18,7 @@ #include "maria_def.h" #include #include "ma_blockrec.h" +#include "trnman_public.h" my_bool maria_inited= FALSE; pthread_mutex_t THR_LOCK_maria; diff --git a/storage/maria/ma_key.c b/storage/maria/ma_key.c index 920b59b5b54..941d5d0665e 100644 --- a/storage/maria/ma_key.c +++ b/storage/maria/ma_key.c @@ -324,6 +324,7 @@ uint _ma_pack_key(register MARIA_HA *info, uint keynr, byte *key, key+=length; } #endif + DBUG_PRINT("exit", ("length: %u", (uint) (key-start_key))); DBUG_RETURN((uint) (key-start_key)); } /* _ma_pack_key */ diff --git a/storage/maria/ma_loghandler.c b/storage/maria/ma_loghandler.c index 6d19f46310d..f398ec90897 100644 --- a/storage/maria/ma_loghandler.c +++ b/storage/maria/ma_loghandler.c @@ -700,7 +700,7 @@ static my_bool translog_buffer_lock(struct st_translog_buffer *buffer) } #else #define translog_buffer_lock(B) \ - pthread_mutex_lock(&B->mutex); + pthread_mutex_lock(&B->mutex) #endif @@ -734,7 +734,7 @@ static my_bool translog_buffer_unlock(struct st_translog_buffer *buffer) } #else #define translog_buffer_unlock(B) \ - pthread_mutex_unlock(&B->mutex); + pthread_mutex_unlock(&B->mutex) #endif @@ -1352,7 +1352,6 @@ static uint16 translog_get_total_chunk_length(byte *page, uint16 offset) if (rec_len + header_len < page_rest) DBUG_RETURN(rec_len + header_len); DBUG_RETURN(page_rest); - break; } case TRANSLOG_CHUNK_FIXED: { @@ -1373,36 +1372,33 @@ static uint16 translog_get_total_chunk_length(byte *page, uint16 offset) (uint) (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 */ + length= log_record_type_descriptor[type].fixed_length + 3; + for (i= 0; i < log_record_type_descriptor[type].compressed_LSN; i++) { - ptr= page + offset + 3; /* first compressed LSN */ - length= log_record_type_descriptor[type].fixed_length + 3; - for (i= 0; i < log_record_type_descriptor[type].compressed_LSN; i++) - { - /* first 2 bits is length - 2 */ - uint len= ((((uint8) (*ptr)) & TRANSLOG_CLSN_LEN_BITS) >> 6) + 2; - ptr+= len; - /* subtract economized bytes */ - length-= (TRANSLOG_CLSN_MAX_LEN - len); - } - DBUG_PRINT("info", ("Pseudo-fixed length: %u", length)); - DBUG_RETURN(length); + /* first 2 bits is length - 2 */ + uint len= ((((uint8) (*ptr)) & TRANSLOG_CLSN_LEN_BITS) >> 6) + 2; + ptr+= len; + /* subtract economized bytes */ + length-= (TRANSLOG_CLSN_MAX_LEN - len); } - break; + DBUG_PRINT("info", ("Pseudo-fixed length: %u", length)); + DBUG_RETURN(length); } case TRANSLOG_CHUNK_NOHDR: /* 2 no header chunk (till page end) */ DBUG_PRINT("info", ("TRANSLOG_CHUNK_NOHDR length: %u", (uint) (TRANSLOG_PAGE_SIZE - offset))); DBUG_RETURN(TRANSLOG_PAGE_SIZE - offset); - break; case TRANSLOG_CHUNK_LNGTH: /* 3 chunk with chunk length */ DBUG_PRINT("info", ("TRANSLOG_CHUNK_LNGTH")); DBUG_ASSERT(TRANSLOG_PAGE_SIZE - offset >= 3); DBUG_PRINT("info", ("length: %u", uint2korr(page + offset + 1) + 3)); DBUG_RETURN(uint2korr(page + offset + 1) + 3); - break; default: DBUG_ASSERT(0); + DBUG_RETURN(0); } } @@ -1839,9 +1835,9 @@ static uint16 translog_get_chunk_header_length(byte *page, uint16 offset) { /* TODO: fine header end */ DBUG_ASSERT(0); + DBUG_RETURN(0); /* Keep compiler happy */ } DBUG_RETURN(header_len); - break; } case TRANSLOG_CHUNK_FIXED: { @@ -1861,6 +1857,7 @@ static uint16 translog_get_chunk_header_length(byte *page, uint16 offset) break; default: DBUG_ASSERT(0); + DBUG_RETURN(0); /* Keep compiler happy */ } } @@ -2628,6 +2625,7 @@ translog_write_variable_record_chunk2_page(struct st_translog_parts *parts, DBUG_ENTER("translog_write_variable_record_chunk2_page"); chunk2_header[0]= TRANSLOG_CHUNK_NOHDR; + LINT_INIT(buffer_to_flush); rc= translog_page_next(horizon, cursor, &buffer_to_flush); if (buffer_to_flush != NULL) { @@ -2676,6 +2674,7 @@ translog_write_variable_record_chunk3_page(struct st_translog_parts *parts, byte chunk3_header[1 + 2]; DBUG_ENTER("translog_write_variable_record_chunk3_page"); + LINT_INIT(buffer_to_flush); rc= translog_page_next(horizon, cursor, &buffer_to_flush); if (buffer_to_flush != NULL) { @@ -4144,8 +4143,18 @@ my_bool translog_write_record(LSN *lsn, { uint i; uint len= 0; +#ifdef HAVE_PURIFY + ha_checksum checksum= 0; +#endif 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; + } DBUG_ASSERT(len == rec_len); } #endif @@ -5219,7 +5228,6 @@ static void translog_force_current_buffer_to_finish() } else { - left= 0; log_descriptor.bc.current_page_fill= 0; } diff --git a/storage/maria/ma_page.c b/storage/maria/ma_page.c index 2aaabb1257d..d6b8d5ecd7d 100644 --- a/storage/maria/ma_page.c +++ b/storage/maria/ma_page.c @@ -48,7 +48,7 @@ byte *_ma_fetch_keypage(register MARIA_HA *info, MARIA_KEYDEF *keyinfo, DBUG_RETURN(0); } 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) { 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, { DBUG_ENTER("_ma_write_keypage"); -#ifndef FAST /* Safety check */ +#ifdef EXTRA_DEBUG /* Safety check */ if (page < info->s->base.keystart || page+keyinfo->block_length > info->state->key_file_length || (page & (MARIA_MIN_KEY_BLOCK_LENGTH-1))) @@ -84,7 +84,16 @@ int _ma_write_keypage(register MARIA_HA *info, register MARIA_KEYDEF *keyinfo, DBUG_RETURN((-1)); } 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 DBUG_ASSERT(info->s->pagecache->block_size == keyinfo->block_length); diff --git a/storage/maria/ma_range.c b/storage/maria/ma_range.c index 798ca348f92..f91a61259d7 100644 --- a/storage/maria/ma_range.c +++ b/storage/maria/ma_range.c @@ -233,7 +233,7 @@ static uint _ma_keynr(MARIA_HA *info, register MARIA_KEYDEF *keyinfo, uint nod_flag,keynr,max_key; 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); page+=2+nod_flag; diff --git a/storage/maria/ma_rt_index.c b/storage/maria/ma_rt_index.c index b61e7ed49a8..27a83e433a4 100644 --- a/storage/maria/ma_rt_index.c +++ b/storage/maria/ma_rt_index.c @@ -824,7 +824,7 @@ static int maria_rtree_delete_req(MARIA_HA *info, MARIA_KEYDEF *keyinfo, if (_ma_write_keypage(info, keyinfo, page, DFLT_INIT_HITS, page_buf)) goto err1; - *page_size = maria_getint(page_buf); + *page_size = maria_data_on_page(page_buf); } goto ok; @@ -839,7 +839,7 @@ static int maria_rtree_delete_req(MARIA_HA *info, MARIA_KEYDEF *keyinfo, if (_ma_write_keypage(info, keyinfo, page, DFLT_INIT_HITS, page_buf)) goto err1; - *page_size = maria_getint(page_buf); + *page_size = maria_data_on_page(page_buf); res = 0; goto ok; } @@ -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)) { 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) { /* last key in the leaf */ @@ -963,7 +963,7 @@ int maria_rtree_delete(MARIA_HA *info, uint keynr, byte *key, uint key_length) info->buff, 0)) goto err1; 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)) { my_off_t new_root = _ma_kpos(nod_flag, diff --git a/storage/maria/ma_rt_index.h b/storage/maria/ma_rt_index.h index c98422144e2..eae43966aa0 100644 --- a/storage/maria/ma_rt_index.h +++ b/storage/maria/ma_rt_index.h @@ -22,7 +22,7 @@ #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 + \ (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) diff --git a/storage/maria/ma_rt_key.c b/storage/maria/ma_rt_key.c index d88b2582be4..a27ff23c006 100644 --- a/storage/maria/ma_rt_key.c +++ b/storage/maria/ma_rt_key.c @@ -32,7 +32,7 @@ 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 page_size = maria_getint(page_buf); + uint page_size = maria_data_on_page(page_buf); uint nod_flag = _ma_test_if_nod(page_buf); 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, int maria_rtree_delete_key(MARIA_HA *info, byte *page_buf, byte *key, 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; key_start= key - nod_flag; diff --git a/storage/maria/ma_rt_split.c b/storage/maria/ma_rt_split.c index 4e0abdcdb6d..6a66c4424eb 100644 --- a/storage/maria/ma_rt_split.c +++ b/storage/maria/ma_rt_split.c @@ -265,7 +265,7 @@ int maria_rtree_split_page(MARIA_HA *info, MARIA_KEYDEF *keyinfo, uint nod_flag= _ma_test_if_nod(page); uint full_length= key_length + (nod_flag ? nod_flag : 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; @@ -296,7 +296,7 @@ int maria_rtree_split_page(MARIA_HA *info, MARIA_KEYDEF *keyinfo, old_coord = next_coord; 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), 2, 2, &next_coord, n_dim)) { diff --git a/storage/maria/ma_search.c b/storage/maria/ma_search.c index 0ec36db59c5..f3e7a0d542a 100644 --- a/storage/maria/ma_search.c +++ b/storage/maria/ma_search.c @@ -80,14 +80,14 @@ int _ma_search(register MARIA_HA *info, register MARIA_KEYDEF *keyinfo, info->keyread_buff, test(!(nextflag & SEARCH_SAVE_BUFF))))) 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, &keypos,lastkey, &last_key); if (flag == MARIA_FOUND_WRONG_KEY) DBUG_RETURN(-1); nod_flag=_ma_test_if_nod(buff); - maxpos=buff+maria_getint(buff)-1; + maxpos=buff+maria_data_on_page(buff)-1; if (flag) { @@ -187,8 +187,8 @@ int _ma_bin_search(MARIA_HA *info, register MARIA_KEYDEF *keyinfo, byte *page, LINT_INIT(flag); totlength=keyinfo->keylength+(nod_flag=_ma_test_if_nod(page)); start=0; mid=1; - save_end=end=(int) ((maria_getint(page)-2-nod_flag)/totlength-1); - DBUG_PRINT("test",("page_length: %d end: %d",maria_getint(page),end)); + save_end=end=(int) ((maria_data_on_page(page)-2-nod_flag)/totlength-1); + DBUG_PRINT("test",("page_length: %d end: %d",maria_data_on_page(page),end)); page+=2+nod_flag; while (start != end) @@ -249,7 +249,7 @@ int _ma_seq_search(MARIA_HA *info, register MARIA_KEYDEF *keyinfo, byte *page, DBUG_ENTER("_ma_seq_search"); 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); page+=2+nod_flag; *ret_pos=page; @@ -314,7 +314,7 @@ int _ma_prefix_search(MARIA_HA *info, register MARIA_KEYDEF *keyinfo, LINT_INIT(saved_vseg); 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); page+=2+nod_flag; *ret_pos=page; @@ -1324,7 +1324,7 @@ int _ma_search_first(register MARIA_HA *info, register MARIA_KEYDEF *keyinfo, info->lastkey))) 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_keytree_version=keyinfo->version; info->last_search_keypage=info->last_keypage; @@ -1361,7 +1361,7 @@ int _ma_search_last(register MARIA_HA *info, register MARIA_KEYDEF *keyinfo, info->cur_row.lastpos= HA_OFFSET_ERROR; DBUG_RETURN(-1); } - page= buff+maria_getint(buff); + page= buff+maria_data_on_page(buff); nod_flag=_ma_test_if_nod(buff); } while ((pos= _ma_kpos(nod_flag,page)) != HA_OFFSET_ERROR); diff --git a/storage/maria/ma_test1.c b/storage/maria/ma_test1.c index 3546521e0d1..028e02ab9d1 100644 --- a/storage/maria/ma_test1.c +++ b/storage/maria/ma_test1.c @@ -631,7 +631,7 @@ static struct my_option my_long_options[] = static my_bool get_one_option(int optid, const struct my_option *opt __attribute__((unused)), - char *argument) + char *argument __attribute__((unused))) { switch(optid) { case 'a': diff --git a/storage/maria/ma_write.c b/storage/maria/ma_write.c index c16795c05f0..a87e2d76fc7 100644 --- a/storage/maria/ma_write.c +++ b/storage/maria/ma_write.c @@ -511,7 +511,7 @@ int _ma_insert(register MARIA_HA *info, register MARIA_KEYDEF *keyinfo, USE_WHOLE_KEY);); 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; prev_key=(key_pos == anc_buff+2+nod_flag ? (byte*) 0 : key_buff); t_length=(*keyinfo->pack_key)(keyinfo,nod_flag, @@ -630,7 +630,7 @@ int _ma_split_page(register MARIA_HA *info, register MARIA_KEYDEF *keyinfo, MARIA_KEY_PARAM s_temp; DBUG_ENTER("maria_split_page"); 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) info->page_changed=1; /* Info->buff is used */ @@ -646,7 +646,7 @@ int _ma_split_page(register MARIA_HA *info, register MARIA_KEYDEF *keyinfo, DBUG_RETURN(-1); length=(uint) (key_pos-buff); - a_length=maria_getint(buff); + a_length= maria_data_on_page(buff); maria_putint(buff,length,nod_flag); key_pos=after_key; @@ -699,7 +699,7 @@ byte *_ma_find_half_pos(uint nod_flag, MARIA_KEYDEF *keyinfo, byte *page, DBUG_ENTER("_ma_find_half_pos"); 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; if (!(keyinfo->flag & (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, DBUG_ENTER("_ma_find_last_pos"); key_ref_length=2; - length=maria_getint(page)-key_ref_length; + length= maria_data_on_page(page)-key_ref_length; page+=key_ref_length; if (!(keyinfo->flag & (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, DBUG_ENTER("_ma_balance_page"); 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; nod_flag=_ma_test_if_nod(curr_buff); curr_keylength=k_length+nod_flag; @@ -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)) 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 */ - left_length=maria_getint(curr_buff); - right_length=maria_getint(buff); + left_length= maria_data_on_page(curr_buff); + right_length= maria_data_on_page(buff); keys=(left_length+right_length-4-nod_flag*2)/curr_keylength; if ((right ? right_length : left_length) + curr_keylength <= diff --git a/storage/maria/maria_chk.c b/storage/maria/maria_chk.c index 36101e7d002..0b82a71f736 100644 --- a/storage/maria/maria_chk.c +++ b/storage/maria/maria_chk.c @@ -1670,7 +1670,7 @@ static int sort_record_index(MARIA_SORT_PARAM *sort_param,MARIA_HA *info, DBUG_RETURN(-1); } } - used_length=maria_getint(buff); + used_length= maria_data_on_page(buff); keypos=buff+2+nod_flag; endpos=buff+used_length; for ( ;; ) diff --git a/storage/maria/maria_def.h b/storage/maria/maria_def.h index 46ffac7cbc2..d9e31e800c4 100644 --- a/storage/maria/maria_def.h +++ b/storage/maria/maria_def.h @@ -485,7 +485,7 @@ struct st_maria_info #define READING_NEXT 1 #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);\ mi_int2store(x,boh); } #define _ma_test_if_nod(x) (x[0] & 128 ? info->s->base.key_reflength : 0) diff --git a/storage/maria/unittest/ma_pagecache_consist.c b/storage/maria/unittest/ma_pagecache_consist.c index 99eea9180a3..39170693573 100644 --- a/storage/maria/unittest/ma_pagecache_consist.c +++ b/storage/maria/unittest/ma_pagecache_consist.c @@ -289,7 +289,8 @@ static void *test_thread_writer(void *arg) 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_attr_t thr_attr; diff --git a/storage/maria/unittest/ma_pagecache_single.c b/storage/maria/unittest/ma_pagecache_single.c index 211f080e61d..7b77315e18c 100644 --- a/storage/maria/unittest/ma_pagecache_single.c +++ b/storage/maria/unittest/ma_pagecache_single.c @@ -421,7 +421,9 @@ int simple_big_test() static void *test_thread(void *arg) { - int param=*((int*) arg); +#ifndef DBUG_OFF + int param= *((int*) arg); +#endif my_thread_init(); DBUG_ENTER("test_thread"); @@ -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_attr_t thr_attr; diff --git a/storage/maria/unittest/ma_test_loghandler-t.c b/storage/maria/unittest/ma_test_loghandler-t.c index 047e9c12bfc..bff5864a5c0 100644 --- a/storage/maria/unittest/ma_test_loghandler-t.c +++ b/storage/maria/unittest/ma_test_loghandler-t.c @@ -92,7 +92,7 @@ static my_bool read_and_check_content(TRANSLOG_HEADER_BUFFER *rec, 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 rec_len; diff --git a/storage/maria/unittest/ma_test_loghandler_multigroup-t.c b/storage/maria/unittest/ma_test_loghandler_multigroup-t.c index f07ceab1a49..110c35b786a 100644 --- a/storage/maria/unittest/ma_test_loghandler_multigroup-t.c +++ b/storage/maria/unittest/ma_test_loghandler_multigroup-t.c @@ -108,7 +108,7 @@ static uint32 get_len() return rec_len; } -int main(int argc, char *argv[]) +int main(int argc __attribute__((unused)), char *argv[]) { uint32 i; uint32 rec_len; diff --git a/storage/maria/unittest/ma_test_loghandler_multithread-t.c b/storage/maria/unittest/ma_test_loghandler_multithread-t.c index 2651258e290..4afd2b23074 100644 --- a/storage/maria/unittest/ma_test_loghandler_multithread-t.c +++ b/storage/maria/unittest/ma_test_loghandler_multithread-t.c @@ -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; uint pagen; diff --git a/storage/maria/unittest/ma_test_loghandler_pagecache-t.c b/storage/maria/unittest/ma_test_loghandler_pagecache-t.c index 13b5afe7444..a56f3f875c6 100644 --- a/storage/maria/unittest/ma_test_loghandler_pagecache-t.c +++ b/storage/maria/unittest/ma_test_loghandler_pagecache-t.c @@ -18,7 +18,7 @@ static char *first_translog_file= (char*)"maria_log.00000001"; static char *file1_name= (char*)"page_cache_test_file_1"; static PAGECACHE_FILE file1; -int main(int argc, char *argv[]) +int main(int argc __attribute__((unused)), char *argv[]) { uint pagen; byte long_tr_id[6]; diff --git a/storage/myisam/mi_dbug.c b/storage/myisam/mi_dbug.c index 07c314c43e6..0808a7e85dd 100644 --- a/storage/myisam/mi_dbug.c +++ b/storage/myisam/mi_dbug.c @@ -45,6 +45,7 @@ void _mi_print_key(FILE *stream, register HA_KEYSEG *keyseg, fprintf(stream,"NULL"); continue; } + end++; } switch (keyseg->type) {