summaryrefslogtreecommitdiff
path: root/storage
diff options
context:
space:
mode:
Diffstat (limited to 'storage')
-rw-r--r--storage/maria/ma_blockrec.c2
-rw-r--r--storage/maria/ma_check.c417
-rw-r--r--storage/maria/ma_close.c2
-rw-r--r--storage/maria/ma_create.c43
-rw-r--r--storage/maria/ma_dbug.c2
-rw-r--r--storage/maria/ma_delete.c221
-rw-r--r--storage/maria/ma_delete_all.c2
-rw-r--r--storage/maria/ma_dynrec.c2
-rw-r--r--storage/maria/ma_extra.c98
-rw-r--r--storage/maria/ma_ft_update.c15
-rw-r--r--storage/maria/ma_info.c2
-rw-r--r--storage/maria/ma_key_recover.c17
-rw-r--r--storage/maria/ma_locking.c10
-rw-r--r--storage/maria/ma_loghandler.c116
-rw-r--r--storage/maria/ma_loghandler.h2
-rw-r--r--storage/maria/ma_open.c2
-rw-r--r--storage/maria/ma_packrec.c10
-rw-r--r--storage/maria/ma_page.c73
-rw-r--r--storage/maria/ma_preload.c4
-rw-r--r--storage/maria/ma_range.c4
-rw-r--r--storage/maria/ma_rkey.c2
-rw-r--r--storage/maria/ma_rprev.c2
-rw-r--r--storage/maria/ma_rt_index.c127
-rw-r--r--storage/maria/ma_rt_index.h8
-rw-r--r--storage/maria/ma_rt_key.c28
-rw-r--r--storage/maria/ma_rt_mbr.c43
-rw-r--r--storage/maria/ma_rt_split.c35
-rw-r--r--storage/maria/ma_search.c44
-rw-r--r--storage/maria/ma_sort.c2
-rw-r--r--storage/maria/ma_statrec.c2
-rw-r--r--storage/maria/ma_test1.c18
-rw-r--r--storage/maria/ma_test2.c22
-rwxr-xr-xstorage/maria/ma_test_recovery5
-rw-r--r--storage/maria/ma_test_recovery.expected298
-rw-r--r--storage/maria/ma_update.c2
-rw-r--r--storage/maria/ma_write.c219
-rw-r--r--storage/maria/maria_chk.c23
-rw-r--r--storage/maria/maria_def.h28
38 files changed, 1169 insertions, 783 deletions
diff --git a/storage/maria/ma_blockrec.c b/storage/maria/ma_blockrec.c
index 57754d64385..2efce902ae4 100644
--- a/storage/maria/ma_blockrec.c
+++ b/storage/maria/ma_blockrec.c
@@ -212,7 +212,7 @@
to handle DROP COLUMN, we must store in the index header the fields
that has been dropped. When unpacking a row we will ignore dropped
fields. When storing a row, we will mark a dropped field either with a
- null in the null bit map or in the empty_bits and not store any data
+ null in the null bit map or in the empty_bits and not store any data
for it.
TODO: Add code for handling dropped fields.
diff --git a/storage/maria/ma_check.c b/storage/maria/ma_check.c
index d3e472c3ebb..1a6a507ebff 100644
--- a/storage/maria/ma_check.c
+++ b/storage/maria/ma_check.c
@@ -121,7 +121,7 @@ void maria_chk_init(HA_CHECK *param)
int maria_chk_status(HA_CHECK *param, register MARIA_HA *info)
{
- MARIA_SHARE *share=info->s;
+ MARIA_SHARE *share= info->s;
if (maria_is_crashed_on_repair(info))
_ma_check_print_warning(param,
@@ -129,7 +129,7 @@ int maria_chk_status(HA_CHECK *param, register MARIA_HA *info)
else if (maria_is_crashed(info))
_ma_check_print_warning(param,
"Table is marked as crashed");
- if (share->state.open_count != (uint) (info->s->global_changed ? 1 : 0))
+ if (share->state.open_count != (uint) (share->global_changed ? 1 : 0))
{
/* Don't count this as a real warning, as check can correct this ! */
uint save=param->warning_printed;
@@ -151,6 +151,7 @@ int maria_chk_status(HA_CHECK *param, register MARIA_HA *info)
int maria_chk_del(HA_CHECK *param, register MARIA_HA *info, uint test_flag)
{
+ MARIA_SHARE *share= info->s;
reg2 ha_rows i;
uint delete_link_length;
my_off_t empty,next_link,old_link;
@@ -159,17 +160,17 @@ int maria_chk_del(HA_CHECK *param, register MARIA_HA *info, uint test_flag)
LINT_INIT(old_link);
- if (info->s->data_file_type == BLOCK_RECORD)
+ if (share->data_file_type == BLOCK_RECORD)
DBUG_RETURN(0); /* No delete links here */
param->record_checksum=0;
- delete_link_length=((info->s->options & HA_OPTION_PACK_RECORD) ? 20 :
- info->s->rec_reflength+1);
+ delete_link_length=((share->options & HA_OPTION_PACK_RECORD) ? 20 :
+ share->rec_reflength+1);
if (!(test_flag & T_SILENT))
puts("- check record delete-chain");
- next_link=info->s->state.dellink;
+ next_link=share->state.dellink;
if (info->state->del == 0)
{
if (test_flag & T_VERBOSE)
@@ -205,7 +206,7 @@ int maria_chk_del(HA_CHECK *param, register MARIA_HA *info, uint test_flag)
llstr(next_link,buff));
goto wrong;
}
- if (info->s->options & HA_OPTION_PACK_RECORD)
+ if (share->options & HA_OPTION_PACK_RECORD)
{
my_off_t prev_link=mi_sizekorr(buff+12);
if (empty && prev_link != old_link)
@@ -222,7 +223,7 @@ int maria_chk_del(HA_CHECK *param, register MARIA_HA *info, uint test_flag)
{
param->record_checksum+=(ha_checksum) next_link;
next_link= _ma_rec_pos(info, buff+1);
- empty+=info->s->base.pack_reclength;
+ empty+=share->base.pack_reclength;
}
}
if (test_flag & T_VERBOSE)
@@ -265,7 +266,8 @@ wrong:
static int check_k_link(HA_CHECK *param, register MARIA_HA *info,
my_off_t next_link)
{
- uint block_size= info->s->block_size;
+ MARIA_SHARE *share= info->s;
+ uint block_size= share->block_size;
ha_rows records;
char llbuff[21], llbuff2[21];
uchar *buff;
@@ -303,9 +305,9 @@ static int check_k_link(HA_CHECK *param, register MARIA_HA *info,
/* purecov: end */
}
- DBUG_ASSERT(info->s->pagecache->block_size == block_size);
- if (!(buff= pagecache_read(info->s->pagecache,
- &info->s->kfile, next_link/block_size,
+ DBUG_ASSERT(share->pagecache->block_size == block_size);
+ if (!(buff= pagecache_read(share->pagecache,
+ &share->kfile, next_link/block_size,
DFLT_INIT_HITS,
(uchar*) info->buff,
PAGECACHE_READ_UNKNOWN_PAGE,
@@ -317,11 +319,11 @@ static int check_k_link(HA_CHECK *param, register MARIA_HA *info,
DBUG_RETURN(1);
/* purecov: end */
}
- if (_ma_get_keynr(info, buff) != MARIA_DELETE_KEY_NR)
+ if (_ma_get_keynr(info->s, buff) != MARIA_DELETE_KEY_NR)
_ma_check_print_error(param, "Page at %s is not delete marked",
llstr(next_link, llbuff));
- next_link= mi_sizekorr(buff + info->s->keypage_header);
+ next_link= mi_sizekorr(buff + share->keypage_header);
records--;
param->key_file_blocks+=block_size;
}
@@ -340,6 +342,7 @@ static int check_k_link(HA_CHECK *param, register MARIA_HA *info,
int maria_chk_size(HA_CHECK *param, register MARIA_HA *info)
{
+ MARIA_SHARE *share= info->s;
int error;
register my_off_t skr,size;
char buff[22],buff2[22];
@@ -357,11 +360,11 @@ int maria_chk_size(HA_CHECK *param, register MARIA_HA *info)
FLUSH_FORCE_WRITE, FLUSH_FORCE_WRITE)))
_ma_check_print_error(param, "Failed to flush data or index file");
- size= my_seek(info->s->kfile.file, 0L, MY_SEEK_END, MYF(MY_THREADSAFE));
+ size= my_seek(share->kfile.file, 0L, MY_SEEK_END, MYF(MY_THREADSAFE));
if ((skr=(my_off_t) info->state->key_file_length) != size)
{
/* Don't give error if file generated by mariapack */
- if (skr > size && maria_is_any_key_active(info->s->state.key_map))
+ if (skr > size && maria_is_any_key_active(share->state.key_map))
{
error=1;
_ma_check_print_error(param,
@@ -374,21 +377,21 @@ int maria_chk_size(HA_CHECK *param, register MARIA_HA *info)
llstr(size,buff), llstr(skr,buff2));
}
if (!(param->testflag & T_VERY_SILENT) &&
- ! (info->s->options & HA_OPTION_COMPRESS_RECORD) &&
+ ! (share->options & HA_OPTION_COMPRESS_RECORD) &&
ulonglong2double(info->state->key_file_length) >
- ulonglong2double(info->s->base.margin_key_file_length)*0.9)
+ ulonglong2double(share->base.margin_key_file_length)*0.9)
_ma_check_print_warning(param,"Keyfile is almost full, %10s of %10s used",
llstr(info->state->key_file_length,buff),
- llstr(info->s->base.max_key_file_length-1,buff));
+ llstr(share->base.max_key_file_length-1,buff));
size= my_seek(info->dfile.file, 0L, MY_SEEK_END, MYF(0));
skr=(my_off_t) info->state->data_file_length;
- if (info->s->options & HA_OPTION_COMPRESS_RECORD)
+ if (share->options & HA_OPTION_COMPRESS_RECORD)
skr+= MEMMAP_EXTRA_MARGIN;
#ifdef USE_RELOC
if (info->data_file_type == STATIC_RECORD &&
- skr < (my_off_t) info->s->base.reloc*info->s->base.min_pack_length)
- skr=(my_off_t) info->s->base.reloc*info->s->base.min_pack_length;
+ skr < (my_off_t) share->base.reloc*share->base.min_pack_length)
+ skr=(my_off_t) share->base.reloc*share->base.min_pack_length;
#endif
if (skr != size)
{
@@ -408,12 +411,12 @@ int maria_chk_size(HA_CHECK *param, register MARIA_HA *info)
}
}
if (!(param->testflag & T_VERY_SILENT) &&
- !(info->s->options & HA_OPTION_COMPRESS_RECORD) &&
+ !(share->options & HA_OPTION_COMPRESS_RECORD) &&
ulonglong2double(info->state->data_file_length) >
- (ulonglong2double(info->s->base.max_data_file_length)*0.9))
+ (ulonglong2double(share->base.max_data_file_length)*0.9))
_ma_check_print_warning(param, "Datafile is almost full, %10s of %10s used",
llstr(info->state->data_file_length,buff),
- llstr(info->s->base.max_data_file_length-1,buff2));
+ llstr(share->base.max_data_file_length-1,buff2));
DBUG_RETURN(error);
} /* maria_chk_size */
@@ -427,7 +430,7 @@ int maria_chk_key(HA_CHECK *param, register MARIA_HA *info)
ha_checksum old_record_checksum,init_checksum;
my_off_t all_keydata,all_totaldata,key_totlength,length;
double *rec_per_key_part;
- MARIA_SHARE *share=info->s;
+ MARIA_SHARE *share= info->s;
MARIA_KEYDEF *keyinfo;
char buff[22],buff2[22];
DBUG_ENTER("maria_chk_key");
@@ -435,8 +438,8 @@ int maria_chk_key(HA_CHECK *param, register MARIA_HA *info)
if (!(param->testflag & T_SILENT))
puts("- check key delete-chain");
- param->key_file_blocks=info->s->base.keystart;
- if (check_k_link(param, info, info->s->state.key_del))
+ param->key_file_blocks=share->base.keystart;
+ if (check_k_link(param, info, share->state.key_del))
{
if (param->testflag & T_VERBOSE) puts("");
_ma_check_print_error(param,"key delete-link-chain corrupted");
@@ -538,18 +541,18 @@ int maria_chk_key(HA_CHECK *param, register MARIA_HA *info)
info->lastinx=key;
_ma_read_key_record(info, info->rec_buff, 0);
auto_increment= ma_retrieve_auto_increment(info, info->rec_buff);
- if (auto_increment > info->s->state.auto_increment)
+ if (auto_increment > share->state.auto_increment)
{
_ma_check_print_warning(param, "Auto-increment value: %s is smaller "
"than max used value: %s",
- llstr(info->s->state.auto_increment,buff2),
+ llstr(share->state.auto_increment,buff2),
llstr(auto_increment, buff));
}
if (param->testflag & T_AUTO_INC)
{
- set_if_bigger(info->s->state.auto_increment,
+ set_if_bigger(share->state.auto_increment,
auto_increment);
- set_if_bigger(info->s->state.auto_increment,
+ set_if_bigger(share->state.auto_increment,
param->auto_increment_value);
}
@@ -766,10 +769,11 @@ static int chk_index(HA_CHECK *param, MARIA_HA *info, MARIA_KEYDEF *keyinfo,
uint used_length,comp_flag,nod_flag,key_length=0;
uchar key[HA_MAX_POSSIBLE_KEY_BUFF],*temp_buff,*keypos,*old_keypos,*endpos;
my_off_t next_page,record;
+ MARIA_SHARE *share= info->s;
char llbuff[22];
uint diff_pos[2];
DBUG_ENTER("chk_index");
- DBUG_DUMP("buff", buff, _ma_get_page_used(info, buff));
+ DBUG_DUMP("buff", buff, _ma_get_page_used(share, buff));
/* TODO: implement appropriate check for RTree keys */
if (keyinfo->flag & HA_SPATIAL)
@@ -786,8 +790,8 @@ static int chk_index(HA_CHECK *param, MARIA_HA *info, MARIA_KEYDEF *keyinfo,
else
comp_flag=SEARCH_SAME; /* Keys in positionorder */
- _ma_get_used_and_nod(info, buff, used_length, nod_flag);
- keypos= buff + info->s->keypage_header + nod_flag;
+ _ma_get_used_and_nod(share, buff, used_length, nod_flag);
+ keypos= buff + share->keypage_header + nod_flag;
endpos= buff + used_length;
param->keydata+= used_length;
@@ -796,10 +800,10 @@ static int chk_index(HA_CHECK *param, MARIA_HA *info, MARIA_KEYDEF *keyinfo,
if (level > param->max_level)
param->max_level=level;
- if (_ma_get_keynr(info, buff) != (uint) (keyinfo - info->s->keyinfo))
+ if (_ma_get_keynr(share, buff) != (uint) (keyinfo - share->keyinfo))
_ma_check_print_error(param, "Page at %s is not marked for index %u",
llstr(page, llbuff),
- (uint) (keyinfo - info->s->keyinfo));
+ (uint) (keyinfo - share->keyinfo));
if (used_length > keyinfo->block_length)
{
@@ -870,7 +874,7 @@ static int chk_index(HA_CHECK *param, MARIA_HA *info, MARIA_KEYDEF *keyinfo,
}
}
(*key_checksum)+= maria_byte_checksum((uchar*) key,
- key_length- info->s->rec_reflength);
+ key_length- share->rec_reflength);
record= _ma_dpos(info,0,key+key_length);
if (keyinfo->flag & HA_FULLTEXT) /* special handling for ft2 */
{
@@ -881,7 +885,7 @@ static int chk_index(HA_CHECK *param, MARIA_HA *info, MARIA_KEYDEF *keyinfo,
if (subkeys < 0)
{
ha_rows tmp_keys=0;
- if (chk_index_down(param,info,&info->s->ft2_keyinfo,record,
+ if (chk_index_down(param,info,&share->ft2_keyinfo,record,
temp_buff,&tmp_keys,key_checksum,1))
goto err;
if (tmp_keys + subkeys)
@@ -1003,6 +1007,7 @@ static void record_pos_to_txt(MARIA_HA *info, my_off_t recpos,
static int check_keys_in_record(HA_CHECK *param, MARIA_HA *info, int extend,
my_off_t start_recpos, uchar *record)
{
+ MARIA_SHARE *share= info->s;
MARIA_KEYDEF *keyinfo;
char llbuff[22+4];
uint key;
@@ -1016,10 +1021,10 @@ static int check_keys_in_record(HA_CHECK *param, MARIA_HA *info, int extend,
}
/* Check if keys match the record */
- for (key=0, keyinfo= info->s->keyinfo; key < info->s->base.keys;
+ for (key=0, keyinfo= share->keyinfo; key < share->base.keys;
key++,keyinfo++)
{
- if (maria_is_key_active(info->s->state.key_map, key))
+ if (maria_is_key_active(share->state.key_map, key))
{
if(!(keyinfo->flag & HA_FULLTEXT))
{
@@ -1037,7 +1042,7 @@ static int check_keys_in_record(HA_CHECK *param, MARIA_HA *info, int extend,
MBR_EQUAL | MBR_DATA) :
#endif
_ma_search(info,keyinfo,info->lastkey,key_length,
- SEARCH_SAME, info->s->state.key_root[key]);
+ SEARCH_SAME, share->state.key_root[key]);
if (search_result)
{
record_pos_to_txt(info, start_recpos, llbuff);
@@ -1074,6 +1079,7 @@ static int check_keys_in_record(HA_CHECK *param, MARIA_HA *info, int extend,
static int check_static_record(HA_CHECK *param, MARIA_HA *info, int extend,
uchar *record)
{
+ MARIA_SHARE *share= info->s;
my_off_t start_recpos, pos;
char llbuff[22];
@@ -1083,7 +1089,7 @@ static int check_static_record(HA_CHECK *param, MARIA_HA *info, int extend,
if (*_ma_killed_ptr(param))
return -1;
if (my_b_read(&param->read_cache,(uchar*) record,
- info->s->base.pack_reclength))
+ share->base.pack_reclength))
{
_ma_check_print_error(param,
"got error: %d when reading datafile at position: %s",
@@ -1091,16 +1097,16 @@ static int check_static_record(HA_CHECK *param, MARIA_HA *info, int extend,
return 1;
}
start_recpos= pos;
- pos+= info->s->base.pack_reclength;
+ pos+= share->base.pack_reclength;
param->splits++;
if (*record == '\0')
{
param->del_blocks++;
- param->del_length+= info->s->base.pack_reclength;
+ param->del_length+= share->base.pack_reclength;
continue; /* Record removed */
}
param->glob_crc+= _ma_static_checksum(info,record);
- param->used+= info->s->base.pack_reclength;
+ param->used+= share->base.pack_reclength;
if (check_keys_in_record(param, info, extend, start_recpos, record))
return 1;
}
@@ -1112,6 +1118,7 @@ static int check_dynamic_record(HA_CHECK *param, MARIA_HA *info, int extend,
uchar *record)
{
MARIA_BLOCK_INFO block_info;
+ MARIA_SHARE *share= info->s;
my_off_t start_recpos, start_block, pos;
uchar *to;
ulong left_length;
@@ -1171,7 +1178,7 @@ static int check_dynamic_record(HA_CHECK *param, MARIA_HA *info, int extend,
}
if (b_type & BLOCK_DELETED)
{
- if (block_info.block_len < info->s->base.min_block_length)
+ if (block_info.block_len < share->base.min_block_length)
{
_ma_check_print_error(param,
"Deleted block with impossible length %lu at %s",
@@ -1213,7 +1220,7 @@ static int check_dynamic_record(HA_CHECK *param, MARIA_HA *info, int extend,
{
start_recpos=pos;
pos=block_info.filepos+block_info.block_len;
- if (block_info.rec_len > (uint) info->s->base.max_pack_length)
+ if (block_info.rec_len > (uint) share->base.max_pack_length)
{
_ma_check_print_error(param,"Found too long record (%lu) at %s",
(ulong) block_info.rec_len,
@@ -1221,11 +1228,11 @@ static int check_dynamic_record(HA_CHECK *param, MARIA_HA *info, int extend,
got_error=1;
break;
}
- if (info->s->base.blobs)
+ if (share->base.blobs)
{
if (_ma_alloc_buffer(&info->rec_buff, &info->rec_buff_size,
block_info.rec_len +
- info->s->base.extra_rec_buff_size))
+ share->base.extra_rec_buff_size))
{
_ma_check_print_error(param,
@@ -1296,13 +1303,13 @@ static int check_dynamic_record(HA_CHECK *param, MARIA_HA *info, int extend,
else
{
ha_checksum checksum= 0;
- if (info->s->calc_checksum)
- checksum= (*info->s->calc_checksum)(info, record);
+ if (share->calc_checksum)
+ checksum= (*share->calc_checksum)(info, record);
if (param->testflag & (T_EXTEND | T_MEDIUM | T_VERBOSE))
{
if (_ma_rec_check(info,record, info->rec_buff,block_info.rec_len,
- test(info->s->calc_checksum), checksum))
+ test(share->calc_checksum), checksum))
{
_ma_check_print_error(param,"Found wrong packed record at %s",
llstr(start_recpos,llbuff));
@@ -1334,20 +1341,21 @@ next:;
static int check_compressed_record(HA_CHECK *param, MARIA_HA *info, int extend,
uchar *record)
{
+ MARIA_BLOCK_INFO block_info;
+ MARIA_SHARE *share= info->s;
my_off_t start_recpos, pos;
char llbuff[22];
bool got_error= 0;
- MARIA_BLOCK_INFO block_info;
DBUG_ENTER("check_compressed_record");
- pos= info->s->pack.header_length; /* Skip header */
+ pos= share->pack.header_length; /* Skip header */
while (pos < info->state->data_file_length)
{
if (*_ma_killed_ptr(param))
DBUG_RETURN(-1);
if (_ma_read_cache(&param->read_cache,(uchar*) block_info.header, pos,
- info->s->pack.ref_length, READING_NEXT))
+ share->pack.ref_length, READING_NEXT))
{
_ma_check_print_error(param,
"got error: %d when reading datafile at position: %s",
@@ -1361,8 +1369,8 @@ static int check_compressed_record(HA_CHECK *param, MARIA_HA *info, int extend,
&info->rec_buff, &info->rec_buff_size, -1,
start_recpos));
pos=block_info.filepos+block_info.rec_len;
- if (block_info.rec_len < (uint) info->s->min_pack_length ||
- block_info.rec_len > (uint) info->s->max_pack_length)
+ if (block_info.rec_len < (uint) share->min_pack_length ||
+ block_info.rec_len > (uint) share->max_pack_length)
{
_ma_check_print_error(param,
"Found block with wrong recordlength: %d at %s",
@@ -1386,7 +1394,7 @@ static int check_compressed_record(HA_CHECK *param, MARIA_HA *info, int extend,
got_error=1;
goto end;
}
- param->glob_crc+= (*info->s->calc_checksum)(info,record);
+ param->glob_crc+= (*share->calc_checksum)(info,record);
param->link_used+= (block_info.filepos - start_recpos);
param->used+= (pos-start_recpos);
@@ -1472,8 +1480,8 @@ static int check_page_layout(HA_CHECK *param, MARIA_HA *info,
}
/* Check directry */
- dir_entry= page+ info->s->block_size - PAGE_SUFFIX_SIZE;
- first_dir_entry= (info->s->block_size - row_count* DIR_ENTRY_SIZE -
+ dir_entry= page+ block_size - PAGE_SUFFIX_SIZE;
+ first_dir_entry= (block_size - row_count * DIR_ENTRY_SIZE -
PAGE_SUFFIX_SIZE);
for (row= 0 ; row < row_count ; row++)
{
@@ -1554,12 +1562,13 @@ static my_bool check_head_page(HA_CHECK *param, MARIA_HA *info, uchar *record,
int extend, my_off_t page_pos, uchar *page_buff,
uint row_count)
{
+ MARIA_SHARE *share= info->s;
uchar *dir_entry;
uint row;
char llbuff[22], llbuff2[22];
DBUG_ENTER("check_head_page");
- dir_entry= page_buff+ info->s->block_size - PAGE_SUFFIX_SIZE;
+ dir_entry= page_buff+ share->block_size - PAGE_SUFFIX_SIZE;
for (row= 0 ; row < row_count ; row++)
{
uint pos, length, flag;
@@ -1568,7 +1577,7 @@ static my_bool check_head_page(HA_CHECK *param, MARIA_HA *info, uchar *record,
if (!pos)
continue;
length= uint2korr(dir_entry+2);
- if (length < info->s->base.min_block_length)
+ if (length < share->base.min_block_length)
{
_ma_check_print_error(param,
"Page %9s: Row %3u is too short (%d bytes)",
@@ -1582,9 +1591,9 @@ static my_bool check_head_page(HA_CHECK *param, MARIA_HA *info, uchar *record,
llstr(page_pos, llbuff), row, flag);
DBUG_PRINT("info", ("rowid: %s page: %lu row: %u",
- llstr(ma_recordpos(page_pos/info->s->block_size, row),
+ llstr(ma_recordpos(page_pos/share->block_size, row),
llbuff),
- (ulong) (page_pos / info->s->block_size), row));
+ (ulong) (page_pos / share->block_size), row));
if (_ma_read_block_record2(info, record, page_buff+pos,
page_buff+pos+length))
{
@@ -1595,9 +1604,9 @@ static my_bool check_head_page(HA_CHECK *param, MARIA_HA *info, uchar *record,
DBUG_RETURN(1);
continue;
}
- if (info->s->calc_checksum)
+ if (share->calc_checksum)
{
- ha_checksum checksum= (*info->s->calc_checksum)(info, record);
+ ha_checksum checksum= (*share->calc_checksum)(info, record);
if (info->cur_row.checksum != (checksum & 255))
_ma_check_print_error(param, "Page %9s: Row %3d has wrong checksum",
llstr(page_pos, llbuff), row);
@@ -1629,7 +1638,7 @@ static my_bool check_head_page(HA_CHECK *param, MARIA_HA *info, uchar *record,
_ma_check_print_error(param,
"Page %9s: Row: %3d has an extent with wrong information in bitmap: Page %9s Page_type: %d Bitmap: %d",
llstr(page_pos, llbuff), row,
- llstr(page * info->s->bitmap.block_size,
+ llstr(page * share->bitmap.block_size,
llbuff2),
page_type,
bitmap_pattern);
@@ -1642,7 +1651,7 @@ static my_bool check_head_page(HA_CHECK *param, MARIA_HA *info, uchar *record,
param->full_page_count+= info->cur_row.full_page_count;
param->tail_count+= info->cur_row.tail_count;
if (check_keys_in_record(param, info, extend,
- ma_recordpos(page_pos/info->s->block_size, row),
+ ma_recordpos(page_pos/share->block_size, row),
record))
DBUG_RETURN(1);
}
@@ -1657,10 +1666,11 @@ static my_bool check_head_page(HA_CHECK *param, MARIA_HA *info, uchar *record,
static int check_block_record(HA_CHECK *param, MARIA_HA *info, int extend,
uchar *record)
{
+ MARIA_SHARE *share= info->s;
my_off_t pos;
uchar *page_buff, *bitmap_buff, *data;
char llbuff[22], llbuff2[22];
- uint block_size= info->s->block_size;
+ uint block_size= share->block_size;
ha_rows full_page_count, tail_count;
my_bool full_dir;
uint offset_page, offset;
@@ -1692,10 +1702,10 @@ static int check_block_record(HA_CHECK *param, MARIA_HA *info, int extend,
_ma_scan_end_block_record(info);
return -1;
}
- if (((pos / block_size) % info->s->bitmap.pages_covered) == 0)
+ if (((pos / block_size) % share->bitmap.pages_covered) == 0)
{
/* Bitmap page */
- if (pagecache_read(info->s->pagecache,
+ if (pagecache_read(share->pagecache,
&info->dfile,
(pos / block_size), 1,
bitmap_buff,
@@ -1712,7 +1722,7 @@ static int check_block_record(HA_CHECK *param, MARIA_HA *info, int extend,
continue;
}
/* Skip pages marked as empty in bitmap */
- offset_page= (((pos / block_size) % info->s->bitmap.pages_covered) -1) * 3;
+ offset_page= (((pos / block_size) % share->bitmap.pages_covered) -1) * 3;
offset= offset_page & 7;
data= bitmap_buff + offset_page / 8;
bitmap_pattern= uint2korr(data);
@@ -1724,11 +1734,11 @@ static int check_block_record(HA_CHECK *param, MARIA_HA *info, int extend,
continue;
}
- if (pagecache_read(info->s->pagecache,
+ if (pagecache_read(share->pagecache,
&info->dfile,
(pos / block_size), 1,
page_buff,
- info->s->page_type,
+ share->page_type,
PAGECACHE_LOCK_LEFT_UNLOCKED, 0) == 0)
{
_ma_check_print_error(param,
@@ -1812,26 +1822,26 @@ static int check_block_record(HA_CHECK *param, MARIA_HA *info, int extend,
/* Verify that rest of bitmap is zero */
- if ((pos / block_size) % info->s->bitmap.pages_covered)
+ if ((pos / block_size) % share->bitmap.pages_covered)
{
/* Not at end of bitmap */
uint bitmap_pattern;
- offset_page= (((pos / block_size) % info->s->bitmap.pages_covered) -1) * 3;
+ offset_page= (((pos / block_size) % share->bitmap.pages_covered) -1) * 3;
offset= offset_page & 7;
data= bitmap_buff + offset_page / 8;
bitmap_pattern= uint2korr(data);
if (((bitmap_pattern >> offset)) ||
- (data + 2 < bitmap_buff + info->s->bitmap.total_size &&
- _ma_check_if_zero(data+2, bitmap_buff + info->s->bitmap.total_size -
+ (data + 2 < bitmap_buff + share->bitmap.total_size &&
+ _ma_check_if_zero(data+2, bitmap_buff + share->bitmap.total_size -
data - 2)))
{
ulonglong bitmap_page;
- bitmap_page= pos / block_size / info->s->bitmap.pages_covered;
- bitmap_page*= info->s->bitmap.pages_covered;
+ bitmap_page= pos / block_size / share->bitmap.pages_covered;
+ bitmap_page*= share->bitmap.pages_covered;
_ma_check_print_error(param, "Bitmap at %s has pages reserved outside of data file length",
llstr(bitmap_page, llbuff));
- DBUG_EXECUTE("bitmap", _ma_print_bitmap(&info->s->bitmap, bitmap_buff,
+ DBUG_EXECUTE("bitmap", _ma_print_bitmap(&share->bitmap, bitmap_buff,
bitmap_page););
}
}
@@ -1848,7 +1858,7 @@ static int check_block_record(HA_CHECK *param, MARIA_HA *info, int extend,
llstr(tail_count, llbuff2));
/* Update splits to avoid warning */
- info->s->state.split= param->splits;
+ share->state.split= param->splits;
info->state->del= param->del_blocks;
return param->error_printed != 0;
@@ -1862,6 +1872,7 @@ err:
int maria_chk_data_link(HA_CHECK *param, MARIA_HA *info,int extend)
{
+ MARIA_SHARE *share= info->s;
int error;
uchar *record;
char llbuff[22],llbuff2[22],llbuff3[22];
@@ -1875,7 +1886,7 @@ int maria_chk_data_link(HA_CHECK *param, MARIA_HA *info,int extend)
puts("- check record links");
}
- if (!(record= (uchar*) my_malloc(info->s->base.pack_reclength,MYF(0))))
+ if (!(record= (uchar*) my_malloc(share->base.pack_reclength,MYF(0))))
{
_ma_check_print_error(param,"Not enough memory for record");
DBUG_RETURN(-1);
@@ -1886,12 +1897,12 @@ int maria_chk_data_link(HA_CHECK *param, MARIA_HA *info,int extend)
param->err_count= 0;
error= 0;
- param->empty= info->s->pack.header_length;
+ param->empty= share->pack.header_length;
bzero((char*) param->tmp_key_crc,
- info->s->base.keys * sizeof(param->tmp_key_crc[0]));
+ share->base.keys * sizeof(param->tmp_key_crc[0]));
- switch (info->s->data_file_type) {
+ switch (share->data_file_type) {
case BLOCK_RECORD:
error= check_block_record(param, info, extend, record);
break;
@@ -1929,7 +1940,7 @@ int maria_chk_data_link(HA_CHECK *param, MARIA_HA *info,int extend)
error=1;
}
else if (param->glob_crc != info->state->checksum &&
- (info->s->options &
+ (share->options &
(HA_OPTION_CHECKSUM | HA_OPTION_COMPRESS_RECORD)))
{
_ma_check_print_warning(param,
@@ -1939,10 +1950,10 @@ int maria_chk_data_link(HA_CHECK *param, MARIA_HA *info,int extend)
else if (!extend)
{
uint key;
- for (key=0 ; key < info->s->base.keys; key++)
+ for (key=0 ; key < share->base.keys; key++)
{
if (param->tmp_key_crc[key] != param->key_crc[key] &&
- !(info->s->keyinfo[key].flag & (HA_FULLTEXT | HA_SPATIAL)))
+ !(share->keyinfo[key].flag & (HA_FULLTEXT | HA_SPATIAL)))
{
_ma_check_print_error(param,"Checksum for key: %2d doesn't match checksum for records",
key+1);
@@ -1979,12 +1990,12 @@ int maria_chk_data_link(HA_CHECK *param, MARIA_HA *info,int extend)
llstr(param->del_blocks,llbuff),
llstr(info->state->del,llbuff2));
}
- if (param->splits != info->s->state.split)
+ if (param->splits != share->state.split)
{
_ma_check_print_warning(param,
"Found %10s parts Should be: %s parts",
llstr(param->splits, llbuff),
- llstr(info->s->state.split,llbuff2));
+ llstr(share->state.split,llbuff2));
}
if (param->testflag & T_INFO)
{
@@ -1997,11 +2008,11 @@ int maria_chk_data_link(HA_CHECK *param, MARIA_HA *info,int extend)
printf("Records:%18s M.recordlength:%9lu Packed:%14.0f%%\n",
llstr(param->records,llbuff),
(long)((param->used - param->link_used)/param->records),
- (info->s->base.blobs ? 0.0 :
- (ulonglong2double((ulonglong) info->s->base.reclength *
+ (share->base.blobs ? 0.0 :
+ (ulonglong2double((ulonglong) share->base.reclength *
param->records)-
my_off_t2double(param->used))/
- ulonglong2double((ulonglong) info->s->base.reclength *
+ ulonglong2double((ulonglong) share->base.reclength *
param->records)*100.0));
printf("Recordspace used:%9.0f%% Empty space:%12d%% Blocks/Record: %6.2f\n",
(ulonglong2double(param->used - param->link_used)/
@@ -2101,12 +2112,12 @@ int maria_repair(HA_CHECK *param, register MARIA_HA *info,
ha_rows start_records,new_header_length;
my_off_t del;
File new_file;
- MARIA_SHARE *share=info->s;
+ MARIA_SHARE *share= info->s;
char llbuff[22],llbuff2[22];
MARIA_SORT_INFO sort_info;
MARIA_SORT_PARAM sort_param;
my_bool block_record, scan_inited= 0;
- enum data_file_type org_data_file_type= info->s->data_file_type;
+ enum data_file_type org_data_file_type= share->data_file_type;
myf sync_dir= ((share->now_transactional && !share->temporary) ?
MY_SYNC_DIR : 0);
DBUG_ENTER("maria_repair");
@@ -2152,7 +2163,7 @@ int maria_repair(HA_CHECK *param, register MARIA_HA *info,
maria_filecopy(param, new_file, info->dfile.file, 0L,
new_header_length, "datafile-header"))
goto err;
- info->s->state.dellink= HA_OFFSET_ERROR;
+ share->state.dellink= HA_OFFSET_ERROR;
info->rec_cache.file= new_file; /* For sort_delete_record */
if (share->data_file_type == BLOCK_RECORD ||
(param->testflag & T_UNPACK))
@@ -2196,7 +2207,7 @@ int maria_repair(HA_CHECK *param, register MARIA_HA *info,
if (!(sort_param.record=(uchar*) my_malloc((uint) share->base.pack_reclength,
MYF(0))) ||
_ma_alloc_buffer(&sort_param.rec_buff, &sort_param.rec_buff_size,
- info->s->base.default_rec_buff_size))
+ share->base.default_rec_buff_size))
{
_ma_check_print_error(param, "Not enough memory for extra record");
goto err;
@@ -2218,7 +2229,7 @@ int maria_repair(HA_CHECK *param, register MARIA_HA *info,
Clear all keys. Note that all key blocks allocated until now remain
"dead" parts of the key file. (Bug #4692)
*/
- for (i=0 ; i < info->s->base.keys ; i++)
+ for (i=0 ; i < share->base.keys ; i++)
share->state.key_root[i]= HA_OFFSET_ERROR;
/* Drop the delete chain. */
@@ -2338,7 +2349,7 @@ int maria_repair(HA_CHECK *param, register MARIA_HA *info,
_ma_check_print_error(param, "Got error %d on close", my_errno);
goto err;
}
- copy_data_file_state(&info->s->state, &save_state);
+ copy_data_file_state(&share->state, &save_state);
new_file= -1;
sort_info.new_info= info;
}
@@ -2432,25 +2443,26 @@ err:
static int writekeys(MARIA_SORT_PARAM *sort_param)
{
- register uint i;
+ uint i;
uchar *key;
- MARIA_HA *info= sort_param->sort_info->info;
- uchar *buff= sort_param->record;
- my_off_t filepos= sort_param->current_filepos;
+ MARIA_HA *info= sort_param->sort_info->info;
+ MARIA_SHARE *share= info->s;
+ uchar *buff= sort_param->record;
+ my_off_t filepos= sort_param->current_filepos;
DBUG_ENTER("writekeys");
- key= info->lastkey+info->s->base.max_key_length;
- for (i=0 ; i < info->s->base.keys ; i++)
+ key= info->lastkey+share->base.max_key_length;
+ for (i=0 ; i < share->base.keys ; i++)
{
- if (maria_is_key_active(info->s->state.key_map, i))
+ if (maria_is_key_active(share->state.key_map, i))
{
- if (info->s->keyinfo[i].flag & HA_FULLTEXT )
+ if (share->keyinfo[i].flag & HA_FULLTEXT )
{
if (_ma_ft_add(info,i, key,buff,filepos))
goto err;
}
#ifdef HAVE_SPATIAL
- else if (info->s->keyinfo[i].flag & HA_SPATIAL)
+ else if (share->keyinfo[i].flag & HA_SPATIAL)
{
uint key_length= _ma_make_key(info,i,key,buff,filepos);
if (maria_rtree_insert(info, i, key, key_length))
@@ -2473,9 +2485,9 @@ static int writekeys(MARIA_SORT_PARAM *sort_param)
info->errkey=(int) i; /* This key was found */
while ( i-- > 0 )
{
- if (maria_is_key_active(info->s->state.key_map, i))
+ if (maria_is_key_active(share->state.key_map, i))
{
- if (info->s->keyinfo[i].flag & HA_FULLTEXT)
+ if (share->keyinfo[i].flag & HA_FULLTEXT)
{
if (_ma_ft_del(info,i,key,buff,filepos))
break;
@@ -2506,26 +2518,27 @@ int maria_movepoint(register MARIA_HA *info, uchar *record,
register uint i;
uchar *key;
uint key_length;
+ MARIA_SHARE *share= info->s;
DBUG_ENTER("maria_movepoint");
- key= info->lastkey+info->s->base.max_key_length;
- for (i=0 ; i < info->s->base.keys; i++)
+ key= info->lastkey+share->base.max_key_length;
+ for (i=0 ; i < share->base.keys; i++)
{
- if (i != prot_key && maria_is_key_active(info->s->state.key_map, i))
+ if (i != prot_key && maria_is_key_active(share->state.key_map, i))
{
key_length= _ma_make_key(info,i,key,record,oldpos);
- if (info->s->keyinfo[i].flag & HA_NOSAME)
+ if (share->keyinfo[i].flag & HA_NOSAME)
{ /* Change pointer direct */
uint nod_flag;
MARIA_KEYDEF *keyinfo;
- keyinfo=info->s->keyinfo+i;
+ keyinfo=share->keyinfo+i;
if (_ma_search(info,keyinfo,key,USE_WHOLE_KEY,
(uint) (SEARCH_SAME | SEARCH_SAVE_BUFF),
- info->s->state.key_root[i]))
+ share->state.key_root[i]))
DBUG_RETURN(-1);
- nod_flag=_ma_test_if_nod(info, info->buff);
+ nod_flag= _ma_test_if_nod(share, info->buff);
_ma_dpointer(info,info->int_keypos-nod_flag-
- info->s->rec_reflength,newpos);
+ share->rec_reflength,newpos);
if (_ma_write_keypage(info, keyinfo, info->last_keypage,
PAGECACHE_LOCK_LEFT_UNLOCKED, DFLT_INIT_HITS,
info->buff))
@@ -2597,7 +2610,7 @@ int maria_sort_index(HA_CHECK *param, register MARIA_HA *info, char *name)
my_off_t index_pos[HA_MAX_POSSIBLE_KEY];
uint r_locks,w_locks;
int old_lock;
- MARIA_SHARE *share=info->s;
+ MARIA_SHARE *share= info->s;
MARIA_STATE_INFO old_state;
myf sync_dir= (share->now_transactional && !share->temporary) ?
MY_SYNC_DIR : 0;
@@ -2630,7 +2643,7 @@ int maria_sort_index(HA_CHECK *param, register MARIA_HA *info, char *name)
for (key= 0,keyinfo= &share->keyinfo[0]; key < share->base.keys ;
key++,keyinfo++)
{
- if (! maria_is_key_active(info->s->state.key_map, key))
+ if (! maria_is_key_active(share->state.key_map, key))
continue;
if (share->state.key_root[key] != HA_OFFSET_ERROR)
@@ -2676,11 +2689,11 @@ int maria_sort_index(HA_CHECK *param, register MARIA_HA *info, char *name)
info->state->key_file_length=param->new_file_pos;
info->update= (short) (HA_STATE_CHANGED | HA_STATE_ROW_CHANGED);
- for (key=0 ; key < info->s->base.keys ; key++)
- info->s->state.key_root[key]=index_pos[key];
- info->s->state.key_del= HA_OFFSET_ERROR;
+ for (key=0 ; key < share->base.keys ; key++)
+ share->state.key_root[key]=index_pos[key];
+ share->state.key_del= HA_OFFSET_ERROR;
- info->s->state.changed&= ~STATE_NOT_SORTED_PAGES;
+ share->state.changed&= ~STATE_NOT_SORTED_PAGES;
DBUG_RETURN(0);
err:
@@ -2701,6 +2714,7 @@ static int sort_one_index(HA_CHECK *param, MARIA_HA *info,
uchar *buff,*keypos,*endpos;
uchar key[HA_MAX_POSSIBLE_KEY_BUFF];
my_off_t new_page_pos,next_page;
+ MARIA_SHARE *share= info->s;
DBUG_ENTER("sort_one_index");
/* cannot walk over R-tree indices */
@@ -2719,10 +2733,10 @@ static int sort_one_index(HA_CHECK *param, MARIA_HA *info,
report_keypage_fault(param, pagepos);
goto err;
}
- if ((nod_flag=_ma_test_if_nod(info, buff)) || keyinfo->flag & HA_FULLTEXT)
+ if ((nod_flag=_ma_test_if_nod(share, buff)) || keyinfo->flag & HA_FULLTEXT)
{
- used_length= _ma_get_page_used(info, buff);
- keypos=buff + info->s->keypage_header + nod_flag;
+ used_length= _ma_get_page_used(share, buff);
+ keypos=buff + share->keypage_header + nod_flag;
endpos=buff + used_length;
for ( ;; )
{
@@ -2754,9 +2768,9 @@ static int sort_one_index(HA_CHECK *param, MARIA_HA *info,
if (subkeys < 0)
{
next_page= _ma_dpos(info,0,key+key_length);
- _ma_dpointer(info,keypos-nod_flag-info->s->rec_reflength,
+ _ma_dpointer(info,keypos-nod_flag-share->rec_reflength,
param->new_file_pos); /* Save new pos */
- if (sort_one_index(param,info,&info->s->ft2_keyinfo,
+ if (sort_one_index(param,info,&share->ft2_keyinfo,
next_page,new_file))
goto err;
}
@@ -2765,7 +2779,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= _ma_get_page_used(info, buff);
+ length= _ma_get_page_used(share, buff);
bzero((uchar*) buff+length,keyinfo->block_length-length);
if (my_pwrite(new_file,(uchar*) buff,(uint) keyinfo->block_length,
new_page_pos,MYF(MY_NABP | MY_WAIT_IF_FULL)))
@@ -2872,7 +2886,7 @@ int maria_repair_by_sort(HA_CHECK *param, register MARIA_HA *info,
my_off_t new_header_length, org_header_length, del;
File new_file;
MARIA_SORT_PARAM sort_param;
- MARIA_SHARE *share=info->s;
+ MARIA_SHARE *share= info->s;
HA_KEYSEG *keyseg;
double *rec_per_key_part;
char llbuff[22];
@@ -2942,7 +2956,7 @@ int maria_repair_by_sort(HA_CHECK *param, register MARIA_HA *info,
goto err;
sort_info.key_block_end=sort_info.key_block+param->sort_key_blocks;
- if (info->s->data_file_type != BLOCK_RECORD)
+ if (share->data_file_type != BLOCK_RECORD)
{
/* We need a read buffer to read rows in big blocks */
if (init_io_cache(&param->read_cache, info->dfile.file,
@@ -2967,7 +2981,7 @@ int maria_repair_by_sort(HA_CHECK *param, register MARIA_HA *info,
if (!(sort_param.record=(uchar*) my_malloc((uint) share->base.pack_reclength,
MYF(0))) ||
_ma_alloc_buffer(&sort_param.rec_buff, &sort_param.rec_buff_size,
- info->s->base.default_rec_buff_size))
+ share->base.default_rec_buff_size))
{
_ma_check_print_error(param, "Not enough memory for extra record");
goto err;
@@ -3149,7 +3163,7 @@ int maria_repair_by_sort(HA_CHECK *param, register MARIA_HA *info,
_ma_check_print_error(param, "Got error %d on close", my_errno);
goto err;
}
- copy_data_file_state(&info->s->state, &save_state);
+ copy_data_file_state(&share->state, &save_state);
new_file= -1;
sort_info.new_info= info;
}
@@ -3176,7 +3190,7 @@ int maria_repair_by_sort(HA_CHECK *param, register MARIA_HA *info,
restore_data_file_type(share);
org_header_length= share->pack.header_length;
- sort_info.org_data_file_type= info->s->data_file_type;
+ sort_info.org_data_file_type= share->data_file_type;
sort_info.filelength= info->state->data_file_length;
sort_param.fix_datafile=0;
}
@@ -3343,7 +3357,7 @@ int maria_repair_parallel(HA_CHECK *param, register MARIA_HA *info,
my_off_t new_header_length,del;
File new_file;
MARIA_SORT_PARAM *sort_param=0, tmp_sort_param;
- MARIA_SHARE *share=info->s;
+ MARIA_SHARE *share= info->s;
double *rec_per_key_part;
HA_KEYSEG *keyseg;
char llbuff[22];
@@ -3941,7 +3955,7 @@ static int sort_get_next_record(MARIA_SORT_PARAM *sort_param)
MARIA_SORT_INFO *sort_info=sort_param->sort_info;
HA_CHECK *param=sort_info->param;
MARIA_HA *info=sort_info->info;
- MARIA_SHARE *share=info->s;
+ MARIA_SHARE *share= info->s;
char llbuff[22],llbuff2[22];
DBUG_ENTER("sort_get_next_record");
@@ -3976,8 +3990,8 @@ static int sort_get_next_record(MARIA_SORT_PARAM *sort_param)
if (sort_param->calc_checksum)
{
ha_checksum checksum;
- checksum= (*info->s->calc_check_checksum)(info, sort_param->record);
- if (info->s->calc_checksum &&
+ checksum= (*share->calc_check_checksum)(info, sort_param->record);
+ if (share->calc_checksum &&
info->cur_row.checksum != (checksum & 255))
{
if (param->testflag & T_VERBOSE)
@@ -4223,7 +4237,7 @@ static int sort_get_next_record(MARIA_SORT_PARAM *sort_param)
if (_ma_alloc_buffer(&sort_param->rec_buff,
&sort_param->rec_buff_size,
block_info.rec_len +
- info->s->base.extra_rec_buff_size))
+ share->base.extra_rec_buff_size))
{
if (param->max_record_length >= block_info.rec_len)
@@ -4316,14 +4330,14 @@ static int sort_get_next_record(MARIA_SORT_PARAM *sort_param)
if (sort_param->read_cache.error < 0)
DBUG_RETURN(1);
if (sort_param->calc_checksum)
- checksum= (info->s->calc_check_checksum)(info, sort_param->record);
+ checksum= (share->calc_check_checksum)(info, sort_param->record);
if ((param->testflag & (T_EXTEND | T_REP)) || searching)
{
if (_ma_rec_check(info, sort_param->record, sort_param->rec_buff,
sort_param->find_length,
(param->testflag & T_QUICK) &&
sort_param->calc_checksum &&
- test(info->s->calc_checksum), checksum))
+ test(share->calc_checksum), checksum))
{
_ma_check_print_info(param,"Found wrong packed record at %s",
llstr(sort_param->start_recpos,llbuff));
@@ -4387,7 +4401,7 @@ static int sort_get_next_record(MARIA_SORT_PARAM *sort_param)
}
#ifdef HAVE_purify
bzero(sort_param->rec_buff + block_info.rec_len,
- info->s->base.extra_rec_buff_size);
+ share->base.extra_rec_buff_size);
#endif
if (_ma_pack_rec_unpack(info, &sort_param->bit_buff, sort_param->record,
sort_param->rec_buff, block_info.rec_len))
@@ -4409,7 +4423,7 @@ static int sort_get_next_record(MARIA_SORT_PARAM *sort_param)
if (sort_param->calc_checksum)
{
- info->cur_row.checksum= (*info->s->calc_check_checksum)(info,
+ info->cur_row.checksum= (*share->calc_check_checksum)(info,
sort_param->
record);
param->glob_crc+= info->cur_row.checksum;
@@ -4449,7 +4463,7 @@ int _ma_sort_write_record(MARIA_SORT_PARAM *sort_param)
MARIA_SORT_INFO *sort_info=sort_param->sort_info;
HA_CHECK *param= sort_info->param;
MARIA_HA *info= sort_info->new_info;
- MARIA_SHARE *share=info->s;
+ MARIA_SHARE *share= info->s;
DBUG_ENTER("_ma_sort_write_record");
if (sort_param->fix_datafile)
@@ -4472,7 +4486,7 @@ int _ma_sort_write_record(MARIA_SORT_PARAM *sort_param)
DBUG_RETURN(1);
}
sort_param->filepos+=share->base.pack_reclength;
- info->s->state.split++;
+ share->state.split++;
break;
case DYNAMIC_RECORD:
if (! info->blobs)
@@ -4480,7 +4494,7 @@ int _ma_sort_write_record(MARIA_SORT_PARAM *sort_param)
else
{
/* must be sure that local buffer is big enough */
- reclength=info->s->base.pack_reclength+
+ reclength=share->base.pack_reclength+
_ma_calc_total_blob_length(info,sort_param->record)+
ALIGN_SIZE(MARIA_MAX_DYN_BLOCK_HEADER)+MARIA_SPLIT_LENGTH+
MARIA_DYN_DELETE_BLOCK_HEADER;
@@ -4495,7 +4509,7 @@ int _ma_sort_write_record(MARIA_SORT_PARAM *sort_param)
from=sort_info->buff+ALIGN_SIZE(MARIA_MAX_DYN_BLOCK_HEADER);
}
/* We can use info->checksum here as only one thread calls this */
- info->cur_row.checksum= (*info->s->calc_check_checksum)(info,
+ info->cur_row.checksum= (*share->calc_check_checksum)(info,
sort_param->
record);
reclength= _ma_rec_pack(info,from,sort_param->record);
@@ -4518,14 +4532,14 @@ int _ma_sort_write_record(MARIA_SORT_PARAM *sort_param)
DBUG_RETURN(1);
}
sort_param->filepos+=block_length;
- info->s->state.split++;
+ share->state.split++;
} while (reclength);
break;
case COMPRESSED_RECORD:
reclength=info->packed_length;
length= _ma_save_pack_length((uint) share->pack.version, block_buff,
reclength);
- if (info->s->base.blobs)
+ if (share->base.blobs)
length+= _ma_save_pack_length((uint) share->pack.version,
block_buff + length, info->blob_length);
if (my_b_write(&info->rec_cache,block_buff,length) ||
@@ -4535,7 +4549,7 @@ int _ma_sort_write_record(MARIA_SORT_PARAM *sort_param)
DBUG_RETURN(1);
}
sort_param->filepos+=reclength+length;
- info->s->state.split++;
+ share->state.split++;
break;
}
}
@@ -4683,8 +4697,9 @@ static int sort_maria_ft_key_write(MARIA_SORT_PARAM *sort_param,
MARIA_SORT_INFO *sort_info= sort_param->sort_info;
SORT_FT_BUF *ft_buf= sort_info->ft_buf;
SORT_KEY_BLOCKS *key_block= sort_info->key_block;
+ MARIA_SHARE *share= sort_info->info->s;
- val_len=HA_FT_WLEN+sort_info->info->s->base.rec_reflength;
+ val_len=HA_FT_WLEN+share->base.rec_reflength;
get_key_full_length_rdonly(a_len, (uchar *)a);
if (!ft_buf)
@@ -4693,9 +4708,9 @@ static int sort_maria_ft_key_write(MARIA_SORT_PARAM *sort_param,
use two-level tree only if key_reflength fits in rec_reflength place
and row format is NOT static - for _ma_dpointer not to garble offsets
*/
- if ((sort_info->info->s->base.key_reflength <=
- sort_info->info->s->base.rec_reflength) &&
- (sort_info->info->s->options &
+ if ((share->base.key_reflength <=
+ share->base.rec_reflength) &&
+ (share->options &
(HA_OPTION_PACK_RECORD | HA_OPTION_COMPRESS_RECORD)))
ft_buf= (SORT_FT_BUF *)my_malloc(sort_param->keyinfo->block_length +
sizeof(SORT_FT_BUF), MYF(MY_WME));
@@ -4734,7 +4749,7 @@ static int sort_maria_ft_key_write(MARIA_SORT_PARAM *sort_param,
while (key_block->inited)
key_block++;
sort_info->key_block=key_block;
- sort_param->keyinfo=& sort_info->info->s->ft2_keyinfo;
+ sort_param->keyinfo= &share->ft2_keyinfo;
ft_buf->count=(ft_buf->buf - p)/val_len;
/* flushing buffer to second-level tree */
@@ -4785,18 +4800,18 @@ static int sort_insert_key(MARIA_SORT_PARAM *sort_param,
my_off_t filepos,key_file_length;
uchar *anc_buff,*lastkey;
MARIA_KEY_PARAM s_temp;
- MARIA_HA *info;
MARIA_KEYDEF *keyinfo=sort_param->keyinfo;
MARIA_SORT_INFO *sort_info= sort_param->sort_info;
HA_CHECK *param=sort_info->param;
MARIA_PINNED_PAGE tmp_page_link, *page_link= &tmp_page_link;
+ MARIA_HA *info= sort_info->info;
+ MARIA_SHARE *share= info->s;
DBUG_ENTER("sort_insert_key");
anc_buff= key_block->buff;
- info=sort_info->info;
lastkey=key_block->lastkey;
nod_flag= (key_block == sort_info->key_block ? 0 :
- info->s->base.key_reflength);
+ share->base.key_reflength);
if (!key_block->inited)
{
@@ -4806,20 +4821,20 @@ static int sort_insert_key(MARIA_SORT_PARAM *sort_param,
_ma_check_print_error(param,"To many key-block-levels; Try increasing sort_key_blocks");
DBUG_RETURN(1);
}
- a_length= info->s->keypage_header + nod_flag;
- key_block->end_pos= anc_buff + info->s->keypage_header;
- bzero(anc_buff, info->s->keypage_header);
- _ma_store_keynr(info, anc_buff, (uint) (sort_param->keyinfo -
- info->s->keyinfo));
+ a_length= share->keypage_header + nod_flag;
+ key_block->end_pos= anc_buff + share->keypage_header;
+ bzero(anc_buff, share->keypage_header);
+ _ma_store_keynr(share, anc_buff, (uint) (sort_param->keyinfo -
+ share->keyinfo));
lastkey=0; /* No previous key in block */
}
else
- a_length= _ma_get_page_used(info, anc_buff);
+ a_length= _ma_get_page_used(share, anc_buff);
/* Save pointer to previous block */
if (nod_flag)
{
- _ma_store_keypage_flag(info, anc_buff, KEYPAGE_FLAG_ISNOD);
+ _ma_store_keypage_flag(share, anc_buff, KEYPAGE_FLAG_ISNOD);
_ma_kpointer(info,key_block->end_pos,prev_block);
}
@@ -4828,7 +4843,7 @@ static int sort_insert_key(MARIA_SORT_PARAM *sort_param,
&s_temp);
(*keyinfo->store_key)(keyinfo, key_block->end_pos+nod_flag,&s_temp);
a_length+=t_length;
- _ma_store_page_used(info, anc_buff, a_length);
+ _ma_store_page_used(share, anc_buff, a_length);
key_block->end_pos+=t_length;
if (a_length <= keyinfo->block_length)
{
@@ -4838,7 +4853,7 @@ static int sort_insert_key(MARIA_SORT_PARAM *sort_param,
}
/* Fill block with end-zero and write filled block */
- _ma_store_page_used(info, anc_buff, key_block->last_length);
+ _ma_store_page_used(share, anc_buff, key_block->last_length);
bzero(anc_buff+key_block->last_length,
keyinfo->block_length- key_block->last_length);
key_file_length=info->state->key_file_length;
@@ -4854,10 +4869,10 @@ static int sort_insert_key(MARIA_SORT_PARAM *sort_param,
DFLT_INIT_HITS, anc_buff))
DBUG_RETURN(1);
}
- else if (my_pwrite(info->s->kfile.file, anc_buff,
+ else if (my_pwrite(share->kfile.file, anc_buff,
(uint) keyinfo->block_length,filepos, param->myf_rw))
DBUG_RETURN(1);
- DBUG_DUMP("buff", anc_buff, _ma_get_page_used(info, anc_buff));
+ DBUG_DUMP("buff", anc_buff, _ma_get_page_used(share, anc_buff));
/* Write separator-key to block in next level */
if (sort_insert_key(sort_param,key_block+1,key_block->lastkey,filepos))
@@ -4956,7 +4971,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= _ma_get_page_used(info, key_block->buff);
+ length= _ma_get_page_used(info->s, key_block->buff);
if (nod_flag)
_ma_kpointer(info,key_block->end_pos,filepos);
key_file_length=info->state->key_file_length;
@@ -5013,13 +5028,15 @@ static SORT_KEY_BLOCKS *alloc_key_blocks(HA_CHECK *param, uint blocks,
int maria_test_if_almost_full(MARIA_HA *info)
{
- if (info->s->options & HA_OPTION_COMPRESS_RECORD)
+ MARIA_SHARE *share= info->s;
+
+ if (share->options & HA_OPTION_COMPRESS_RECORD)
return 0;
- return my_seek(info->s->kfile.file, 0L, MY_SEEK_END,
+ return my_seek(share->kfile.file, 0L, MY_SEEK_END,
MYF(MY_THREADSAFE))/10*9 >
- (my_off_t) info->s->base.max_key_file_length ||
+ (my_off_t) share->base.max_key_file_length ||
my_seek(info->dfile.file, 0L, MY_SEEK_END, MYF(0)) / 10 * 9 >
- (my_off_t) info->s->base.max_data_file_length;
+ (my_off_t) share->base.max_data_file_length;
}
/* Recreate table with bigger more alloced record-data */
@@ -5236,7 +5253,7 @@ int maria_write_data_suffix(MARIA_SORT_INFO *sort_info, my_bool fix_datafile)
int maria_update_state_info(HA_CHECK *param, MARIA_HA *info,uint update)
{
- MARIA_SHARE *share=info->s;
+ MARIA_SHARE *share= info->s;
DBUG_ENTER("maria_update_state_info");
if (update & UPDATE_OPEN_COUNT)
@@ -5310,11 +5327,12 @@ err:
void _ma_update_auto_increment_key(HA_CHECK *param, MARIA_HA *info,
my_bool repair_only)
{
+ MARIA_SHARE *share= info->s;
uchar *record;
DBUG_ENTER("update_auto_increment_key");
- if (!info->s->base.auto_key ||
- ! maria_is_key_active(info->s->state.key_map, info->s->base.auto_key - 1))
+ if (!share->base.auto_key ||
+ ! maria_is_key_active(share->state.key_map, share->base.auto_key - 1))
{
if (!(param->testflag & T_VERY_SILENT))
_ma_check_print_info(param,
@@ -5329,7 +5347,7 @@ void _ma_update_auto_increment_key(HA_CHECK *param, MARIA_HA *info,
We have to use an allocated buffer instead of info->rec_buff as
_ma_put_key_in_record() may use info->rec_buff
*/
- if (!(record= (uchar*) my_malloc((uint) info->s->base.pack_reclength,
+ if (!(record= (uchar*) my_malloc((uint) share->base.pack_reclength,
MYF(0))))
{
_ma_check_print_error(param,"Not enough memory for extra record");
@@ -5337,7 +5355,7 @@ void _ma_update_auto_increment_key(HA_CHECK *param, MARIA_HA *info,
}
maria_extra(info,HA_EXTRA_KEYREAD,0);
- if (maria_rlast(info, record, info->s->base.auto_key-1))
+ if (maria_rlast(info, record, share->base.auto_key-1))
{
if (my_errno != HA_ERR_END_OF_FILE)
{
@@ -5347,14 +5365,14 @@ void _ma_update_auto_increment_key(HA_CHECK *param, MARIA_HA *info,
DBUG_VOID_RETURN;
}
if (!repair_only)
- info->s->state.auto_increment=param->auto_increment_value;
+ share->state.auto_increment=param->auto_increment_value;
}
else
{
ulonglong auto_increment= ma_retrieve_auto_increment(info, record);
- set_if_bigger(info->s->state.auto_increment,auto_increment);
+ set_if_bigger(share->state.auto_increment,auto_increment);
if (!repair_only)
- set_if_bigger(info->s->state.auto_increment, param->auto_increment_value);
+ set_if_bigger(share->state.auto_increment, param->auto_increment_value);
}
maria_extra(info,HA_EXTRA_NO_KEYREAD,0);
my_free((char*) record, MYF(0));
@@ -5491,7 +5509,7 @@ static my_bool maria_too_big_key_for_sort(MARIA_KEYDEF *key, ha_rows rows)
void maria_disable_non_unique_index(MARIA_HA *info, ha_rows rows)
{
- MARIA_SHARE *share=info->s;
+ MARIA_SHARE *share= info->s;
MARIA_KEYDEF *key=share->keyinfo;
uint i;
@@ -5500,7 +5518,7 @@ void maria_disable_non_unique_index(MARIA_HA *info, ha_rows rows)
for (i=0 ; i < share->base.keys ; i++,key++)
{
if (!(key->flag & (HA_NOSAME | HA_SPATIAL | HA_AUTO_KEY)) &&
- ! maria_too_big_key_for_sort(key,rows) && info->s->base.auto_key != i+1)
+ ! maria_too_big_key_for_sort(key,rows) && share->base.auto_key != i+1)
{
maria_clear_key_active(share->state.key_map, i);
info->update|= HA_STATE_CHANGED;
@@ -5518,7 +5536,7 @@ void maria_disable_non_unique_index(MARIA_HA *info, ha_rows rows)
my_bool maria_test_if_sort_rep(MARIA_HA *info, ha_rows rows,
ulonglong key_map, my_bool force)
{
- MARIA_SHARE *share=info->s;
+ MARIA_SHARE *share= info->s;
MARIA_KEYDEF *key=share->keyinfo;
uint i;
@@ -5689,6 +5707,7 @@ static void copy_data_file_state(MARIA_STATE_INFO *to,
static int _ma_safe_scan_block_record(MARIA_SORT_INFO *sort_info,
MARIA_HA *info, uchar *record)
{
+ MARIA_SHARE *share= info->s;
uint record_pos= info->cur_row.nextpos;
ulonglong page= sort_info->page;
DBUG_ENTER("_ma_safe_scan_block_record");
@@ -5723,7 +5742,7 @@ static int _ma_safe_scan_block_record(MARIA_SORT_INFO *sort_info,
info->scan.dir-= DIR_ENTRY_SIZE; /* Point to previous row */
if (end_of_data > info->scan.dir_end ||
- offset < PAGE_HEADER_SIZE || length < info->s->base.min_block_length)
+ offset < PAGE_HEADER_SIZE || length < share->base.min_block_length)
{
_ma_check_print_info(sort_info->param,
"Wrong directory entry %3u at page %s",
@@ -5747,11 +5766,11 @@ read_next_page:
sort_info->page++; /* In case of errors */
page++;
- if (!(page % info->s->bitmap.pages_covered))
+ if (!(page % share->bitmap.pages_covered))
page++; /* Skip bitmap */
- if ((page + 1) * info->s->block_size > sort_info->filelength)
+ if ((page + 1) * share->block_size > sort_info->filelength)
DBUG_RETURN(HA_ERR_END_OF_FILE);
- if (!(pagecache_read(info->s->pagecache,
+ if (!(pagecache_read(share->pagecache,
&info->dfile,
page, 0, info->scan.page_buff,
PAGECACHE_READ_UNKNOWN_PAGE,
@@ -5767,19 +5786,19 @@ read_next_page:
break;
_ma_check_print_info(sort_info->param,
"Wrong head page at %s",
- llstr(page * info->s->block_size, llbuff));
+ llstr(page * share->block_size, llbuff));
}
else if (page_type >= MAX_PAGE_TYPE)
{
_ma_check_print_info(sort_info->param,
"Found wrong page type: %d at %s",
- page_type, llstr(page * info->s->block_size,
+ page_type, llstr(page * share->block_size,
llbuff));
}
}
/* New head page */
- info->scan.dir= (info->scan.page_buff + info->s->block_size -
+ info->scan.dir= (info->scan.page_buff + share->block_size -
PAGE_SUFFIX_SIZE - DIR_ENTRY_SIZE);
info->scan.dir_end= (info->scan.dir -
(info->scan.number_of_rows - 1) *
@@ -5816,9 +5835,9 @@ static int write_log_record_for_repair(const HA_CHECK *param, MARIA_HA *info)
MARIA_SHARE *share= info->s;
/* in case this is maria_chk or recovery... */
if (translog_inited && !maria_in_recovery &&
- info->s->base.born_transactional)
+ share->base.born_transactional)
{
- my_bool save_now_transactional= info->s->now_transactional;
+ my_bool save_now_transactional= share->now_transactional;
/*
For now this record is only informative. It could serve when applying
@@ -5852,7 +5871,7 @@ static int write_log_record_for_repair(const HA_CHECK *param, MARIA_HA *info)
log_array[TRANSLOG_INTERNAL_PARTS + 0].str= (char*) log_data;
log_array[TRANSLOG_INTERNAL_PARTS + 0].length= sizeof(log_data);
- info->s->now_transactional= 1;
+ share->now_transactional= 1;
if (unlikely(translog_write_record(&lsn, LOGREC_REDO_REPAIR_TABLE,
&dummy_transaction_object, info,
sizeof(log_data),
@@ -5868,7 +5887,7 @@ static int write_log_record_for_repair(const HA_CHECK *param, MARIA_HA *info)
*/
if (_ma_update_create_rename_lsn(share, lsn, TRUE))
return 1;
- info->s->now_transactional= save_now_transactional;
+ share->now_transactional= save_now_transactional;
}
return 0;
}
diff --git a/storage/maria/ma_close.c b/storage/maria/ma_close.c
index 70a6ef9bf35..87021820be5 100644
--- a/storage/maria/ma_close.c
+++ b/storage/maria/ma_close.c
@@ -26,7 +26,7 @@ int maria_close(register MARIA_HA *info)
{
int error=0,flag;
my_bool share_can_be_freed= FALSE;
- MARIA_SHARE *share=info->s;
+ MARIA_SHARE *share= info->s;
DBUG_ENTER("maria_close");
DBUG_PRINT("enter",("base: 0x%lx reopen: %u locks: %u",
(long) info, (uint) share->reopen,
diff --git a/storage/maria/ma_create.c b/storage/maria/ma_create.c
index 95e1fa1fdcb..14534650ca0 100644
--- a/storage/maria/ma_create.c
+++ b/storage/maria/ma_create.c
@@ -47,7 +47,7 @@ int maria_create(const char *name, enum data_file_type datafile_type,
int errpos,save_errno, create_mode= O_RDWR | O_TRUNC, res;
myf create_flag;
uint length,max_key_length,packed,pack_bytes,pointer,real_length_diff,
- key_length,info_length,key_segs,options,min_key_length_skip,
+ key_length,info_length,key_segs,options,min_key_length,
base_pos,long_varchar_count,varchar_length,
unique_key_parts,fulltext_keys,offset, not_block_record_extra_length;
uint max_field_lengths, extra_header_size, column_nr;
@@ -396,8 +396,8 @@ int maria_create(const char *name, enum data_file_type datafile_type,
for (i=0, keydef=keydefs ; i < keys ; i++ , keydef++)
{
share.state.key_root[i]= HA_OFFSET_ERROR;
- min_key_length_skip=length=real_length_diff=0;
- key_length=pointer;
+ length= real_length_diff= 0;
+ min_key_length= key_length= pointer;
if (keydef->flag & HA_SPATIAL)
{
#ifdef HAVE_SPATIAL
@@ -431,7 +431,7 @@ int maria_create(const char *name, enum data_file_type datafile_type,
keydef->keysegs+=sp_segs;
key_length+=SPLEN*sp_segs;
length++; /* At least one length uchar */
- min_key_length_skip+=SPLEN*2*SPDIMS;
+ min_key_length++;
#else
my_errno= HA_ERR_UNSUPPORTED;
goto err_no_lock;
@@ -467,7 +467,7 @@ int maria_create(const char *name, enum data_file_type datafile_type,
fulltext_keys++;
key_length+= HA_FT_MAXBYTELEN+HA_FT_WLEN;
length++; /* At least one length uchar */
- min_key_length_skip+=HA_FT_MAXBYTELEN;
+ min_key_length+= 1 + HA_FT_WLEN;
real_length_diff=HA_FT_MAXBYTELEN-FT_MAX_WORD_LEN_FOR_SORT;
}
else
@@ -536,35 +536,44 @@ int maria_create(const char *name, enum data_file_type datafile_type,
}
if (keyseg->flag & HA_SPACE_PACK)
{
- DBUG_ASSERT(!(keyseg->flag & HA_VAR_LENGTH_PART));
+ DBUG_ASSERT(!(keyseg->flag & (HA_VAR_LENGTH_PART | HA_BLOB_PART)));
keydef->flag |= HA_SPACE_PACK_USED | HA_VAR_LENGTH_KEY;
options|=HA_OPTION_PACK_KEYS; /* Using packed keys */
length++; /* At least one length uchar */
- min_key_length_skip+=keyseg->length;
+ min_key_length++;
+ key_length+= keyseg->length;
if (keyseg->length >= 255)
- { /* prefix may be 3 bytes */
- min_key_length_skip+=2;
- length+=2;
+ {
+ /* prefix may be 3 bytes */
+ length+= 2;
}
}
- if (keyseg->flag & (HA_VAR_LENGTH_PART | HA_BLOB_PART))
+ else if (keyseg->flag & (HA_VAR_LENGTH_PART | HA_BLOB_PART))
{
DBUG_ASSERT(!test_all_bits(keyseg->flag,
(HA_VAR_LENGTH_PART | HA_BLOB_PART)));
keydef->flag|=HA_VAR_LENGTH_KEY;
length++; /* At least one length uchar */
+ min_key_length++;
options|=HA_OPTION_PACK_KEYS; /* Using packed keys */
- min_key_length_skip+=keyseg->length;
+ key_length+= keyseg->length;
if (keyseg->length >= 255)
- { /* prefix may be 3 bytes */
- min_key_length_skip+=2;
- length+=2;
+ {
+ /* prefix may be 3 bytes */
+ length+= 2;
}
}
- key_length+= keyseg->length;
+ else
+ {
+ key_length+= keyseg->length;
+ if (!keyseg->null_bit)
+ min_key_length+= keyseg->length;
+ }
if (keyseg->null_bit)
{
key_length++;
+ /* min key part is 1 byte */
+ min_key_length++;
options|=HA_OPTION_PACK_KEYS;
keyseg->flag|=HA_NULL_PART;
keydef->flag|=HA_VAR_LENGTH_KEY | HA_NULL_PART_KEY;
@@ -598,7 +607,7 @@ int maria_create(const char *name, enum data_file_type datafile_type,
}
keydef->block_length= maria_block_size;
keydef->keylength= (uint16) key_length;
- keydef->minlength= (uint16) (length-min_key_length_skip);
+ keydef->minlength= (uint16) min_key_length;
keydef->maxlength= (uint16) length;
if (length > max_key_length)
diff --git a/storage/maria/ma_dbug.c b/storage/maria/ma_dbug.c
index 5996e42a101..c706fd253cd 100644
--- a/storage/maria/ma_dbug.c
+++ b/storage/maria/ma_dbug.c
@@ -177,7 +177,7 @@ my_bool _ma_check_table_is_closed(const char *name, const char *where)
for (pos=maria_open_list ; pos ; pos=pos->next)
{
MARIA_HA *info=(MARIA_HA*) pos->data;
- MARIA_SHARE *share=info->s;
+ MARIA_SHARE *share= info->s;
if (!strcmp(share->unique_file_name,filename))
{
if (share->last_version)
diff --git a/storage/maria/ma_delete.c b/storage/maria/ma_delete.c
index 58203de0568..1388d81df67 100644
--- a/storage/maria/ma_delete.c
+++ b/storage/maria/ma_delete.c
@@ -45,7 +45,7 @@ int maria_delete(MARIA_HA *info,const uchar *record)
uchar *old_key;
int save_errno;
char lastpos[8];
- MARIA_SHARE *share=info->s;
+ MARIA_SHARE *share= info->s;
DBUG_ENTER("maria_delete");
/* Test if record is in datafile */
@@ -153,22 +153,23 @@ err:
int _ma_ck_delete(register MARIA_HA *info, uint keynr, uchar *key,
uint key_length)
{
+ MARIA_SHARE *share= info->s;
int res;
LSN lsn= LSN_IMPOSSIBLE;
- my_off_t new_root= info->s->state.key_root[keynr];
+ my_off_t new_root= share->state.key_root[keynr];
uchar key_buff[HA_MAX_KEY_BUFF];
DBUG_ENTER("_ma_ck_delete");
- if (info->s->now_transactional)
+ if (share->now_transactional)
{
/* Save original value as the key may change */
- memcpy(key_buff, key, key_length + info->s->rec_reflength);
+ memcpy(key_buff, key, key_length + share->rec_reflength);
}
- res= _ma_ck_real_delete(info, info->s->keyinfo+keynr, key, key_length,
+ res= _ma_ck_real_delete(info, share->keyinfo+keynr, key, key_length,
&new_root);
- if (!res && info->s->now_transactional)
+ if (!res && share->now_transactional)
{
uchar log_data[LSN_STORE_SIZE + FILEID_STORE_SIZE +
KEY_NR_STORE_SIZE + PAGE_STORE_SIZE], *log_pos;
@@ -181,23 +182,23 @@ int _ma_ck_delete(register MARIA_HA *info, uint keynr, uchar *key,
key_nr_store(log_data + LSN_STORE_SIZE + FILEID_STORE_SIZE, keynr);
log_pos= log_data + LSN_STORE_SIZE + FILEID_STORE_SIZE + KEY_NR_STORE_SIZE;
- if (new_root != info->s->state.key_root[keynr])
+ if (new_root != share->state.key_root[keynr])
{
my_off_t page;
page= ((new_root == HA_OFFSET_ERROR) ? IMPOSSIBLE_PAGE_NO :
- new_root / info->s->block_size);
+ new_root / share->block_size);
page_store(log_pos, page);
log_pos+= PAGE_STORE_SIZE;
log_type= LOGREC_UNDO_KEY_DELETE_WITH_ROOT;
}
- key_length+= info->s->rec_reflength;
+ key_length+= share->rec_reflength;
log_array[TRANSLOG_INTERNAL_PARTS + 0].str= (char*) log_data;
log_array[TRANSLOG_INTERNAL_PARTS + 0].length= (uint) (log_pos - log_data);
log_array[TRANSLOG_INTERNAL_PARTS + 1].str= (char*) key_buff;
log_array[TRANSLOG_INTERNAL_PARTS + 1].length= key_length;
- msg.root= &info->s->state.key_root[keynr];
+ msg.root= &share->state.key_root[keynr];
msg.value= new_root;
if (translog_write_record(&lsn, log_type,
@@ -210,7 +211,7 @@ int _ma_ck_delete(register MARIA_HA *info, uint keynr, uchar *key,
}
else
{
- info->s->state.key_root[keynr]= new_root;
+ share->state.key_root[keynr]= new_root;
_ma_fast_unlock_key_del(info);
}
_ma_unpin_all_pages_and_finalize_row(info, lsn);
@@ -260,13 +261,14 @@ int _ma_ck_real_delete(register MARIA_HA *info, MARIA_KEYDEF *keyinfo,
else /* error == 1 */
{
uint used_length;
- _ma_get_used_and_nod(info, root_buff, used_length, nod_flag);
+ MARIA_SHARE *share= info->s;
+ _ma_get_used_and_nod(share, root_buff, used_length, nod_flag);
page_link->changed= 1;
- if (used_length <= nod_flag + info->s->keypage_header + 1)
+ if (used_length <= nod_flag + share->keypage_header + 1)
{
error=0;
if (nod_flag)
- *root= _ma_kpos(nod_flag, root_buff +info->s->keypage_header +
+ *root= _ma_kpos(nod_flag, root_buff +share->keypage_header +
nod_flag);
else
*root=HA_OFFSET_ERROR;
@@ -311,8 +313,9 @@ static int d_search(register MARIA_HA *info, register MARIA_KEYDEF *keyinfo,
uchar lastkey[HA_MAX_KEY_BUFF];
MARIA_PINNED_PAGE *leaf_page_link;
MARIA_KEY_PARAM s_temp;
+ MARIA_SHARE *share= info->s;
DBUG_ENTER("d_search");
- DBUG_DUMP("page",anc_buff,_ma_get_page_used(info, anc_buff));
+ DBUG_DUMP("page",anc_buff,_ma_get_page_used(share, 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,
@@ -322,9 +325,9 @@ static int d_search(register MARIA_HA *info, register MARIA_KEYDEF *keyinfo,
DBUG_PRINT("error",("Found wrong key"));
DBUG_RETURN(-1);
}
- nod_flag=_ma_test_if_nod(info, anc_buff);
+ nod_flag= _ma_test_if_nod(share, anc_buff);
- if (!flag && keyinfo->flag & HA_FULLTEXT)
+ if (!flag && (keyinfo->flag & HA_FULLTEXT))
{
uint off;
int subkeys;
@@ -359,7 +362,7 @@ static int d_search(register MARIA_HA *info, register MARIA_KEYDEF *keyinfo,
if (!(tmp_key_length=(*keyinfo->get_key)(keyinfo,nod_flag,&kpos,
lastkey)))
{
- maria_print_error(info->s, HA_ERR_CRASHED);
+ maria_print_error(share, HA_ERR_CRASHED);
my_errno= HA_ERR_CRASHED;
DBUG_RETURN(-1);
}
@@ -373,12 +376,12 @@ static int d_search(register MARIA_HA *info, register MARIA_KEYDEF *keyinfo,
}
else
{
- keyinfo=&info->s->ft2_keyinfo;
+ keyinfo=&share->ft2_keyinfo;
/* we'll modify key entry 'in vivo' */
kpos-=keyinfo->keylength+nod_flag;
get_key_full_length_rdonly(off, key);
key+=off;
- ret_value= _ma_ck_real_delete(info, &info->s->ft2_keyinfo,
+ ret_value= _ma_ck_real_delete(info, &share->ft2_keyinfo,
key, HA_FT_WLEN, &root);
_ma_dpointer(info, kpos+HA_FT_WLEN, root);
subkeys++;
@@ -399,6 +402,7 @@ static int d_search(register MARIA_HA *info, register MARIA_KEYDEF *keyinfo,
LINT_INIT(leaf_page);
if (nod_flag)
{
+ /* Read left child page */
leaf_page= _ma_kpos(nod_flag,keypos);
if (!(leaf_buff= (uchar*) my_alloca((uint) keyinfo->block_length+
HA_MAX_KEY_BUFF*2)))
@@ -418,7 +422,7 @@ static int d_search(register MARIA_HA *info, register MARIA_KEYDEF *keyinfo,
if (!nod_flag)
{
DBUG_PRINT("error",("Didn't find key"));
- maria_print_error(info->s, HA_ERR_CRASHED);
+ maria_print_error(share, HA_ERR_CRASHED);
my_errno=HA_ERR_CRASHED; /* This should newer happend */
goto err;
}
@@ -429,7 +433,7 @@ static int d_search(register MARIA_HA *info, register MARIA_KEYDEF *keyinfo,
else
{ /* Found key */
uint tmp;
- uint anc_buff_length= _ma_get_page_used(info, anc_buff);
+ uint anc_buff_length= _ma_get_page_used(share, anc_buff);
if (!(tmp= remove_key(keyinfo,nod_flag,keypos,lastkey,
anc_buff + anc_buff_length,
&next_block, &s_temp)))
@@ -437,23 +441,23 @@ static int d_search(register MARIA_HA *info, register MARIA_KEYDEF *keyinfo,
anc_page_link->changed= 1;
anc_buff_length-= tmp;
- _ma_store_page_used(info, anc_buff, anc_buff_length);
+ _ma_store_page_used(share, anc_buff, anc_buff_length);
/*
Log initial changes on pages
If there is an underflow, there will be more changes logged to the
page
*/
- if (info->s->now_transactional &&
+ if (share->now_transactional &&
_ma_log_delete(info, anc_page, anc_buff, s_temp.key_pos,
s_temp.changed_length, s_temp.move_length))
DBUG_RETURN(-1);
if (!nod_flag)
{ /* On leaf page */
- if (test(anc_buff_length <= (info->quick_mode ?
- MARIA_MIN_KEYBLOCK_LENGTH :
- (uint) keyinfo->underflow_block_length)))
+ if (anc_buff_length <= (info->quick_mode ?
+ MARIA_MIN_KEYBLOCK_LENGTH :
+ (uint) keyinfo->underflow_block_length))
{
/* Page will be written by caller if we return 1 */
DBUG_RETURN(1);
@@ -485,7 +489,7 @@ static int d_search(register MARIA_HA *info, register MARIA_KEYDEF *keyinfo,
(MARIA_PINNED_PAGE*) 0, (uchar*) 0, (my_bool) 0);
}
}
- if (ret_value == 0 && _ma_get_page_used(info, anc_buff) >
+ if (ret_value == 0 && _ma_get_page_used(share, anc_buff) >
(uint) (keyinfo->block_length - KEYPAGE_CHECKSUM_SIZE))
{
/* parent buffer got too big ; We have to split the page */
@@ -504,7 +508,7 @@ static int d_search(register MARIA_HA *info, register MARIA_KEYDEF *keyinfo,
}
else
{
- DBUG_DUMP("page", anc_buff, _ma_get_page_used(info, anc_buff));
+ DBUG_DUMP("page", anc_buff, _ma_get_page_used(share, anc_buff));
}
my_afree(leaf_buff);
DBUG_PRINT("exit",("Return: %d",ret_value));
@@ -532,13 +536,15 @@ err:
@param ret_key Key before keypos in anc_buff
@notes
- leaf_buff is written to disk
- anc_buff is not updated on disk. Caller should do this
+ leaf_buff must be written to disk if retval > 0
+ anc_buff is not updated on disk. Caller should do this
@return
@retval < 0 Error
- @retval 0 OK
+ @retval 0 OK. leaf_buff is written to disk
+
@retval 1 key contains key to upper level (from balance page)
+ leaf_buff has underflow
@retval 2 key contains key to upper level (from split space)
*/
@@ -549,17 +555,17 @@ static int del(register MARIA_HA *info, MARIA_KEYDEF *keyinfo,
uchar *keypos, my_off_t next_block, uchar *ret_key)
{
int ret_value,length;
- uint a_length, nod_flag, leaf_length, tmp;
+ uint a_length, nod_flag, leaf_length, new_leaf_length, tmp;
my_off_t next_page;
uchar keybuff[HA_MAX_KEY_BUFF],*endpos,*next_buff,*key_start, *prev_key;
- MARIA_SHARE *share=info->s;
+ MARIA_SHARE *share= info->s;
MARIA_KEY_PARAM s_temp;
MARIA_PINNED_PAGE *next_page_link;
DBUG_ENTER("del");
DBUG_PRINT("enter",("leaf_page: %ld keypos: 0x%lx", (long) leaf_page,
(ulong) keypos));
- _ma_get_used_and_nod(info, leaf_buff, leaf_length, nod_flag);
+ _ma_get_used_and_nod(share, leaf_buff, leaf_length, nod_flag);
DBUG_DUMP("leaf_buff", leaf_buff, leaf_length);
endpos= leaf_buff + leaf_length;
@@ -578,19 +584,19 @@ static int del(register MARIA_HA *info, MARIA_KEYDEF *keyinfo,
ret_value= -1;
else
{
- DBUG_DUMP("next_page", next_buff, _ma_get_page_used(info, next_buff));
+ DBUG_DUMP("next_page", next_buff, _ma_get_page_used(share, next_buff));
if ((ret_value= del(info, keyinfo, key, anc_page, anc_buff, next_page,
next_buff, next_page_link, keypos, next_block,
ret_key)) >0)
{
/* Get new length after key was deleted */
- endpos=leaf_buff+_ma_get_page_used(info, leaf_buff);
+ endpos=leaf_buff+_ma_get_page_used(share, leaf_buff);
if (ret_value == 1)
{
ret_value= underflow(info, keyinfo, leaf_page, leaf_buff, next_page,
next_buff, next_page_link, endpos);
if (ret_value == 0 &&
- _ma_get_page_used(info, leaf_buff) >
+ _ma_get_page_used(share, leaf_buff) >
(uint) (keyinfo->block_length - KEYPAGE_CHECKSUM_SIZE))
{
ret_value= (_ma_split_page(info, keyinfo, key,
@@ -613,37 +619,59 @@ static int del(register MARIA_HA *info, MARIA_KEYDEF *keyinfo,
}
}
leaf_page_link->changed= 1;
- if (_ma_write_keypage(info, keyinfo, leaf_page,
- PAGECACHE_LOCK_LEFT_WRITELOCKED,
- DFLT_INIT_HITS, leaf_buff))
+ /*
+ If ret_value <> 0, then leaf_page underflowed and caller will have
+ to handle underflow and write leaf_page to disk.
+ We can't write it here, as if leaf_page is empty we get an assert
+ in _ma_write_keypage.
+ */
+ if (ret_value == 0 && _ma_write_keypage(info, keyinfo, leaf_page,
+ PAGECACHE_LOCK_LEFT_WRITELOCKED,
+ DFLT_INIT_HITS, leaf_buff))
goto err;
}
my_afree(next_buff);
DBUG_RETURN(ret_value);
}
- /* Remove last key from leaf page */
- _ma_store_page_used(info, leaf_buff, key_start-leaf_buff);
+ /*
+ Remove last key from leaf page
+ Note that leaf_page page may only have had one key (can normally only
+ happen in quick mode), in which ase it will now temporary have 0 keys
+ on it. This will be corrected by the caller as we will return 0.
+ */
+ new_leaf_length= (uint) (key_start - leaf_buff);
+ _ma_store_page_used(share, leaf_buff, new_leaf_length);
- if (info->s->now_transactional &&
+ if (share->now_transactional &&
_ma_log_suffix(info, leaf_page, leaf_buff, leaf_length,
- (uint) (key_start - leaf_buff)))
+ new_leaf_length))
goto err;
- leaf_page_link->changed= 1;
- if (_ma_write_keypage(info, keyinfo, leaf_page,
- PAGECACHE_LOCK_LEFT_WRITELOCKED, DFLT_INIT_HITS,
- leaf_buff))
- goto err;
+ if (new_leaf_length <= (info->quick_mode ? MARIA_MIN_KEYBLOCK_LENGTH :
+ (uint) keyinfo->underflow_block_length))
+ {
+ /* Underflow, leaf_page will be written by caller */
+ ret_value= 1;
+ leaf_page_link->changed= 1; /* Safety */
+ }
+ else
+ {
+ ret_value= 0;
+ if (_ma_write_keypage(info, keyinfo, leaf_page,
+ PAGECACHE_LOCK_LEFT_WRITELOCKED, DFLT_INIT_HITS,
+ leaf_buff))
+ goto err;
+ }
- /* Place last key in ancestor page on deleted key position */
+ /* Place last key in ancestor page on deleted key position */
- a_length= _ma_get_page_used(info, anc_buff);
+ a_length= _ma_get_page_used(share, anc_buff);
endpos=anc_buff+a_length;
- if (keypos != anc_buff+info->s->keypage_header + share->base.key_reflength &&
+ if (keypos != anc_buff+share->keypage_header + share->base.key_reflength &&
!_ma_get_last_key(info,keyinfo,anc_buff,ret_key,keypos,&tmp))
goto err;
- prev_key= (keypos == anc_buff + info->s->keypage_header +
+ prev_key= (keypos == anc_buff + share->keypage_header +
share->base.key_reflength ? 0 : ret_key);
length=(*keyinfo->pack_key)(keyinfo,share->base.key_reflength,
keypos == endpos ? (uchar*) 0 : keypos,
@@ -660,14 +688,14 @@ static int del(register MARIA_HA *info, MARIA_KEYDEF *keyinfo,
if (!(*keyinfo->get_key)(keyinfo,share->base.key_reflength,&keypos,ret_key))
goto err;
_ma_kpointer(info,keypos - share->base.key_reflength,next_block);
- _ma_store_page_used(info, anc_buff, a_length + length);
+ _ma_store_page_used(share, anc_buff, a_length + length);
- if (info->s->now_transactional &&
+ if (share->now_transactional &&
_ma_log_add(info, anc_page, anc_buff, a_length,
key_start, s_temp.changed_length, s_temp.move_length, 1))
goto err;
- DBUG_RETURN(_ma_get_page_used(info, leaf_buff) <=
+ DBUG_RETURN(new_leaf_length <=
(info->quick_mode ? MARIA_MIN_KEYBLOCK_LENGTH :
(uint) keyinfo->underflow_block_length));
err:
@@ -687,6 +715,7 @@ err:
@note
This function writes redo entries for all changes
+ leaf_page is saved to disk
Caller must save anc_buff
@return
@@ -710,26 +739,26 @@ static int underflow(register MARIA_HA *info, register MARIA_KEYDEF *keyinfo,
uchar *buff,*endpos,*next_keypos,*anc_pos,*half_pos,*prev_key;
uchar *after_key, *anc_end_pos;
MARIA_KEY_PARAM key_deleted, key_inserted;
- MARIA_SHARE *share=info->s;
+ MARIA_SHARE *share= info->s;
MARIA_PINNED_PAGE *next_page_link;
my_bool first_key;
DBUG_ENTER("underflow");
DBUG_PRINT("enter",("leaf_page: %ld keypos: 0x%lx",(long) leaf_page,
(ulong) keypos));
- DBUG_DUMP("anc_buff", anc_buff, _ma_get_page_used(info, anc_buff));
- DBUG_DUMP("leaf_buff", leaf_buff, _ma_get_page_used(info, leaf_buff));
+ DBUG_DUMP("anc_buff", anc_buff, _ma_get_page_used(share, anc_buff));
+ DBUG_DUMP("leaf_buff", leaf_buff, _ma_get_page_used(share, leaf_buff));
buff=info->buff;
info->keyread_buff_used=1;
next_keypos=keypos;
- nod_flag= _ma_test_if_nod(info, leaf_buff);
- p_length= nod_flag+info->s->keypage_header;
- anc_length= _ma_get_page_used(info, anc_buff);
- leaf_length= _ma_get_page_used(info, leaf_buff);
+ nod_flag= _ma_test_if_nod(share, leaf_buff);
+ p_length= nod_flag+share->keypage_header;
+ anc_length= _ma_get_page_used(share, anc_buff);
+ leaf_length= _ma_get_page_used(share, leaf_buff);
key_reflength=share->base.key_reflength;
- if (info->s->keyinfo+info->lastinx == keyinfo)
+ if (share->keyinfo+info->lastinx == keyinfo)
info->page_changed=1;
- first_key= keypos == anc_buff + info->s->keypage_header + key_reflength;
+ first_key= keypos == anc_buff + share->keypage_header + key_reflength;
if ((keypos < anc_buff + anc_length && (info->state->records & 1)) ||
first_key)
@@ -755,11 +784,11 @@ static int underflow(register MARIA_HA *info, register MARIA_KEYDEF *keyinfo,
if (!_ma_fetch_keypage(info,keyinfo, next_page, PAGECACHE_LOCK_WRITE,
DFLT_INIT_HITS, buff, 0, &next_page_link))
goto err;
- next_buff_length= _ma_get_page_used(info, buff);
+ next_buff_length= _ma_get_page_used(share, buff);
DBUG_DUMP("next", buff, next_buff_length);
/* find keys to make a big key-page */
- bmove(next_keypos-key_reflength, buff + info->s->keypage_header,
+ bmove(next_keypos-key_reflength, buff + share->keypage_header,
key_reflength);
if (!_ma_get_last_key(info,keyinfo,anc_buff,anc_key,next_keypos,&length) ||
!_ma_get_last_key(info,keyinfo,leaf_buff,leaf_key,
@@ -778,7 +807,7 @@ static int underflow(register MARIA_HA *info, register MARIA_KEYDEF *keyinfo,
memcpy(buff, leaf_buff,(size_t) leaf_length);
(*keyinfo->store_key)(keyinfo, buff+leaf_length, &key_inserted);
buff_length= (uint) (endpos-buff);
- _ma_store_page_used(info, buff, buff_length);
+ _ma_store_page_used(share, buff, buff_length);
/* remove key from anc_buff */
if (!(s_length=remove_key(keyinfo,key_reflength,keypos,anc_key,
@@ -787,7 +816,7 @@ static int underflow(register MARIA_HA *info, register MARIA_KEYDEF *keyinfo,
goto err;
new_anc_length= anc_length - s_length;
- _ma_store_page_used(info, anc_buff, new_anc_length);
+ _ma_store_page_used(share, anc_buff, new_anc_length);
if (buff_length <= (uint) (keyinfo->block_length - KEYPAGE_CHECKSUM_SIZE))
{
@@ -798,7 +827,7 @@ static int underflow(register MARIA_HA *info, register MARIA_KEYDEF *keyinfo,
memcpy(leaf_buff, buff, (size_t) buff_length);
- if (info->s->now_transactional)
+ if (share->now_transactional)
{
/* Log changes to parent page */
if (_ma_log_delete(info, anc_page, anc_buff, key_deleted.key_pos,
@@ -838,7 +867,7 @@ static int underflow(register MARIA_HA *info, register MARIA_KEYDEF *keyinfo,
goto err;
new_leaf_length= (uint) (half_pos-buff);
memcpy(leaf_buff, buff, (size_t) new_leaf_length);
- _ma_store_page_used(info, leaf_buff, new_leaf_length);
+ _ma_store_page_used(share, leaf_buff, new_leaf_length);
/* Correct new keypointer to leaf_page */
half_pos=after_key;
@@ -858,11 +887,11 @@ static int underflow(register MARIA_HA *info, register MARIA_KEYDEF *keyinfo,
bmove(keypos,keypos-t_length,(uint) (anc_end_pos-keypos)+t_length);
(*keyinfo->store_key)(keyinfo,keypos, &anc_key_inserted);
new_anc_length+= t_length;
- _ma_store_page_used(info, anc_buff, new_anc_length);
+ _ma_store_page_used(share, anc_buff, new_anc_length);
/* Store key first in new page */
if (nod_flag)
- bmove(buff+info->s->keypage_header, half_pos-nod_flag,
+ bmove(buff+share->keypage_header, half_pos-nod_flag,
(size_t) nod_flag);
if (!(*keyinfo->get_key)(keyinfo,nod_flag,&half_pos,leaf_key))
goto err;
@@ -874,9 +903,9 @@ static int underflow(register MARIA_HA *info, register MARIA_KEYDEF *keyinfo,
bmove(buff+p_length+t_length, half_pos, (size_t) length);
(*keyinfo->store_key)(keyinfo,buff+p_length, &key_inserted);
new_buff_length= length + t_length + p_length;
- _ma_store_page_used(info, buff, new_buff_length);
+ _ma_store_page_used(share, buff, new_buff_length);
- if (info->s->now_transactional)
+ if (share->now_transactional)
{
/*
Log changes to parent page
@@ -940,8 +969,9 @@ static int underflow(register MARIA_HA *info, register MARIA_KEYDEF *keyinfo,
PAGECACHE_LOCK_LEFT_WRITELOCKED, DFLT_INIT_HITS,
leaf_buff))
goto err;
- DBUG_RETURN(new_anc_length <= ((info->quick_mode ? MARIA_MIN_BLOCK_LENGTH :
- (uint) keyinfo->underflow_block_length)));
+ DBUG_RETURN(new_anc_length <=
+ ((info->quick_mode ? MARIA_MIN_KEYBLOCK_LENGTH :
+ (uint) keyinfo->underflow_block_length)));
}
DBUG_PRINT("test",("use left page"));
@@ -953,12 +983,12 @@ static int underflow(register MARIA_HA *info, register MARIA_KEYDEF *keyinfo,
if (!_ma_fetch_keypage(info, keyinfo, next_page, PAGECACHE_LOCK_WRITE,
DFLT_INIT_HITS, buff, 0, &next_page_link))
goto err;
- buff_length= _ma_get_page_used(info, buff);
+ buff_length= _ma_get_page_used(share, buff);
endpos= buff + buff_length;
DBUG_DUMP("prev",buff,buff_length);
/* find keys to make a big key-page */
- bmove(next_keypos - key_reflength, leaf_buff + info->s->keypage_header,
+ bmove(next_keypos - key_reflength, leaf_buff + share->keypage_header,
key_reflength);
next_keypos=keypos;
if (!(*keyinfo->get_key)(keyinfo,key_reflength,&next_keypos,
@@ -988,7 +1018,7 @@ static int underflow(register MARIA_HA *info, register MARIA_KEYDEF *keyinfo,
key_inserted.move_length);
new_buff_length= buff_length + leaf_length - p_length + t_length;
- _ma_store_page_used(info, buff, new_buff_length);
+ _ma_store_page_used(share, buff, new_buff_length);
/* remove key from anc_buff */
if (!(s_length= remove_key(keyinfo,key_reflength,keypos,anc_key,
@@ -997,7 +1027,7 @@ static int underflow(register MARIA_HA *info, register MARIA_KEYDEF *keyinfo,
goto err;
new_anc_length= anc_length - s_length;
- _ma_store_page_used(info, anc_buff, new_anc_length);
+ _ma_store_page_used(share, anc_buff, new_anc_length);
if (new_buff_length <= (uint) (keyinfo->block_length -
KEYPAGE_CHECKSUM_SIZE))
@@ -1007,7 +1037,7 @@ static int underflow(register MARIA_HA *info, register MARIA_KEYDEF *keyinfo,
if (_ma_dispose(info, leaf_page, 0))
goto err;
- if (info->s->now_transactional)
+ if (share->now_transactional)
{
/* Log changes to parent page */
if (_ma_log_delete(info, anc_page, anc_buff, key_deleted.key_pos,
@@ -1064,11 +1094,11 @@ static int underflow(register MARIA_HA *info, register MARIA_KEYDEF *keyinfo,
bmove(keypos,keypos-t_length,(uint) (anc_end_pos-keypos)+t_length);
(*keyinfo->store_key)(keyinfo,keypos, &anc_key_inserted);
new_anc_length+= t_length;
- _ma_store_page_used(info, anc_buff, new_anc_length);
+ _ma_store_page_used(share, anc_buff, new_anc_length);
/* Store first key on new page */
if (nod_flag)
- bmove(leaf_buff + info->s->keypage_header, half_pos-nod_flag,
+ bmove(leaf_buff + share->keypage_header, half_pos-nod_flag,
(size_t) nod_flag);
if (!(length=(*keyinfo->get_key)(keyinfo,nod_flag,&half_pos,leaf_key)))
goto err;
@@ -1082,11 +1112,11 @@ static int underflow(register MARIA_HA *info, register MARIA_KEYDEF *keyinfo,
bmove(leaf_buff+p_length+t_length, half_pos, (size_t) length);
(*keyinfo->store_key)(keyinfo,leaf_buff+p_length, &key_inserted);
new_leaf_length= length + t_length + p_length;
- _ma_store_page_used(info, leaf_buff, new_leaf_length);
+ _ma_store_page_used(share, leaf_buff, new_leaf_length);
new_buff_length= (uint) (endpos - buff);
- _ma_store_page_used(info, buff, new_buff_length);
+ _ma_store_page_used(share, buff, new_buff_length);
- if (info->s->now_transactional)
+ if (share->now_transactional)
{
/*
Log changes to parent page
@@ -1136,8 +1166,10 @@ static int underflow(register MARIA_HA *info, register MARIA_KEYDEF *keyinfo,
if (_ma_write_keypage(info, keyinfo, next_page,
PAGECACHE_LOCK_LEFT_WRITELOCKED, DFLT_INIT_HITS, buff))
goto err;
- DBUG_RETURN(new_anc_length <= (uint)
- (keyinfo->block_length - KEYPAGE_CHECKSUM_SIZE)/2);
+
+ DBUG_RETURN(new_anc_length <=
+ ((info->quick_mode ? MARIA_MIN_KEYBLOCK_LENGTH :
+ (uint) keyinfo->underflow_block_length)));
err:
DBUG_RETURN(-1);
@@ -1326,16 +1358,17 @@ static my_bool _ma_log_delete(MARIA_HA *info, my_off_t page, uchar *buff,
LSN lsn;
uchar log_data[FILEID_STORE_SIZE + PAGE_STORE_SIZE + 9 + 7], *log_pos;
LEX_STRING log_array[TRANSLOG_INTERNAL_PARTS + 3];
+ MARIA_SHARE *share= info->s;
uint translog_parts;
uint offset= (uint) (key_pos - buff);
DBUG_ENTER("_ma_log_delete");
DBUG_PRINT("enter", ("page: %lu changed_length: %u move_length: %d",
(ulong) page, changed_length, move_length));
- DBUG_ASSERT(info->s->now_transactional && move_length);
- DBUG_ASSERT(offset + changed_length <= _ma_get_page_used(info, buff));
+ DBUG_ASSERT(share->now_transactional && move_length);
+ DBUG_ASSERT(offset + changed_length <= _ma_get_page_used(share, buff));
/* Store address of new root page */
- page/= info->s->block_size;
+ page/= share->block_size;
page_store(log_data + FILEID_STORE_SIZE, page);
log_pos= log_data+ FILEID_STORE_SIZE + PAGE_STORE_SIZE;
log_pos[0]= KEY_OP_OFFSET;
@@ -1356,7 +1389,7 @@ static my_bool _ma_log_delete(MARIA_HA *info, my_off_t page, uchar *buff,
#ifdef EXTRA_DEBUG_KEY_CHANGES
{
- int page_length= _ma_get_page_used(info, buff);
+ int page_length= _ma_get_page_used(share, buff);
ha_checksum crc;
crc= my_checksum(0, buff + LSN_STORE_SIZE, page_length - LSN_STORE_SIZE);
log_pos[0]= KEY_OP_CHECK;
diff --git a/storage/maria/ma_delete_all.c b/storage/maria/ma_delete_all.c
index 14dfe8cf7e0..43bdd42588a 100644
--- a/storage/maria/ma_delete_all.c
+++ b/storage/maria/ma_delete_all.c
@@ -31,7 +31,7 @@
int maria_delete_all_rows(MARIA_HA *info)
{
- MARIA_SHARE *share=info->s;
+ MARIA_SHARE *share= info->s;
my_bool log_record;
DBUG_ENTER("maria_delete_all_rows");
diff --git a/storage/maria/ma_dynrec.c b/storage/maria/ma_dynrec.c
index 0b3e84b76d6..f12344e3474 100644
--- a/storage/maria/ma_dynrec.c
+++ b/storage/maria/ma_dynrec.c
@@ -1671,7 +1671,7 @@ int _ma_read_rnd_dynamic_record(MARIA_HA *info,
uint left_len,b_type;
uchar *to;
MARIA_BLOCK_INFO block_info;
- MARIA_SHARE *share=info->s;
+ MARIA_SHARE *share= info->s;
DBUG_ENTER("_ma_read_rnd_dynamic_record");
info_read=0;
diff --git a/storage/maria/ma_extra.c b/storage/maria/ma_extra.c
index b0b4ce12652..31d03c5f224 100644
--- a/storage/maria/ma_extra.c
+++ b/storage/maria/ma_extra.c
@@ -41,11 +41,10 @@ static void maria_extra_keyflag(MARIA_HA *info,
int maria_extra(MARIA_HA *info, enum ha_extra_function function,
void *extra_arg)
{
- int error=0;
+ int error= 0;
ulong cache_size;
- MARIA_SHARE *share=info->s;
- my_bool block_records= share->data_file_type == BLOCK_RECORD;
-
+ MARIA_SHARE *share= info->s;
+ my_bool block_records= share->data_file_type == BLOCK_RECORD;
DBUG_ENTER("maria_extra");
DBUG_PRINT("enter",("function: %d",(int) function));
@@ -53,7 +52,7 @@ int maria_extra(MARIA_HA *info, enum ha_extra_function function,
case HA_EXTRA_RESET_STATE: /* Reset state (don't free buffers) */
info->lastinx= 0; /* Use first index as def */
info->last_search_keypage= info->cur_row.lastpos= HA_OFFSET_ERROR;
- info->page_changed=1;
+ info->page_changed= 1;
/* Next/prev gives first/last */
if (info->opt_flag & READ_CACHE_USED)
{
@@ -72,8 +71,8 @@ int maria_extra(MARIA_HA *info, enum ha_extra_function function,
if (info->lock_type == F_UNLCK &&
(share->options & HA_OPTION_PACK_RECORD))
{
- error=1; /* Not possibly if not locked */
- my_errno=EACCES;
+ error= 1; /* Not possibly if not locked */
+ my_errno= EACCES;
break;
}
if (info->s->file_map) /* Don't use cache if mmap */
@@ -97,7 +96,7 @@ int maria_extra(MARIA_HA *info, enum ha_extra_function function,
if (info->opt_flag & WRITE_CACHE_USED)
{
info->opt_flag&= ~WRITE_CACHE_USED;
- if ((error=end_io_cache(&info->rec_cache)))
+ if ((error= end_io_cache(&info->rec_cache)))
break;
}
if (!(info->opt_flag &
@@ -111,11 +110,11 @@ int maria_extra(MARIA_HA *info, enum ha_extra_function function,
READ_CACHE,0L,(pbool) (info->lock_type != F_UNLCK),
MYF(share->write_flag & MY_WAIT_IF_FULL))))
{
- info->opt_flag|=READ_CACHE_USED;
- info->update&= ~HA_STATE_ROW_CHANGED;
+ info->opt_flag|= READ_CACHE_USED;
+ info->update&= ~HA_STATE_ROW_CHANGED;
}
if (share->concurrent_insert)
- info->rec_cache.end_of_file=info->state->data_file_length;
+ info->rec_cache.end_of_file= info->state->data_file_length;
}
break;
case HA_EXTRA_REINIT_CACHE:
@@ -126,13 +125,13 @@ int maria_extra(MARIA_HA *info, enum ha_extra_function function,
(pbool) test(info->update & HA_STATE_ROW_CHANGED));
info->update&= ~HA_STATE_ROW_CHANGED;
if (share->concurrent_insert)
- info->rec_cache.end_of_file=info->state->data_file_length;
+ info->rec_cache.end_of_file= info->state->data_file_length;
}
break;
case HA_EXTRA_WRITE_CACHE:
if (info->lock_type == F_UNLCK)
{
- error=1; /* Not possibly if not locked */
+ error= 1; /* Not possibly if not locked */
break;
}
if (block_records)
@@ -148,10 +147,10 @@ int maria_extra(MARIA_HA *info, enum ha_extra_function function,
(pbool) (info->lock_type != F_UNLCK),
MYF(share->write_flag & MY_WAIT_IF_FULL))))
{
- info->opt_flag|=WRITE_CACHE_USED;
- info->update&= ~(HA_STATE_ROW_CHANGED |
- HA_STATE_WRITE_AT_END |
- HA_STATE_EXTEND_BLOCK);
+ info->opt_flag|= WRITE_CACHE_USED;
+ info->update&= ~(HA_STATE_ROW_CHANGED |
+ HA_STATE_WRITE_AT_END |
+ HA_STATE_EXTEND_BLOCK);
}
break;
case HA_EXTRA_PREPARE_FOR_UPDATE:
@@ -162,7 +161,7 @@ int maria_extra(MARIA_HA *info, enum ha_extra_function function,
if (info->opt_flag & (READ_CACHE_USED | WRITE_CACHE_USED))
{
info->opt_flag&= ~(READ_CACHE_USED | WRITE_CACHE_USED);
- error=end_io_cache(&info->rec_cache);
+ error= end_io_cache(&info->rec_cache);
/* Sergei will insert full text index caching here */
}
#if defined(HAVE_MMAP) && defined(HAVE_MADVISE)
@@ -174,7 +173,7 @@ int maria_extra(MARIA_HA *info, enum ha_extra_function function,
case HA_EXTRA_FLUSH_CACHE:
if (info->opt_flag & WRITE_CACHE_USED)
{
- if ((error=flush_io_cache(&info->rec_cache)))
+ if ((error= flush_io_cache(&info->rec_cache)))
{
maria_print_error(info->s, HA_ERR_CRASHED);
maria_mark_crashed(info); /* Fatal error found */
@@ -189,18 +188,18 @@ int maria_extra(MARIA_HA *info, enum ha_extra_function function,
break;
case HA_EXTRA_KEYREAD: /* Read only keys to record */
case HA_EXTRA_REMEMBER_POS:
- info->opt_flag |= REMEMBER_OLD_POS;
+ info->opt_flag|= REMEMBER_OLD_POS;
bmove((uchar*) info->lastkey+share->base.max_key_length*2,
(uchar*) info->lastkey,info->lastkey_length);
info->save_update= info->update;
info->save_lastinx= info->lastinx;
info->save_lastpos= info->cur_row.lastpos;
- info->save_lastkey_length=info->lastkey_length;
+ info->save_lastkey_length= info->lastkey_length;
if (function == HA_EXTRA_REMEMBER_POS)
break;
/* fall through */
case HA_EXTRA_KEYREAD_CHANGE_POS:
- info->opt_flag |= KEY_READ_USED;
+ info->opt_flag|= KEY_READ_USED;
info->read_record= _ma_read_key_record;
break;
case HA_EXTRA_NO_KEYREAD:
@@ -212,8 +211,8 @@ int maria_extra(MARIA_HA *info, enum ha_extra_function function,
info->save_lastkey_length);
info->update= info->save_update | HA_STATE_WRITTEN;
info->lastinx= info->save_lastinx;
- info->cur_row.lastpos= info->save_lastpos;
- info->lastkey_length=info->save_lastkey_length;
+ info->cur_row.lastpos= info->save_lastpos;
+ info->lastkey_length= info->save_lastkey_length;
}
info->read_record= share->read_record;
info->opt_flag&= ~(KEY_READ_USED | REMEMBER_OLD_POS);
@@ -222,10 +221,10 @@ int maria_extra(MARIA_HA *info, enum ha_extra_function function,
info->lock_type= F_EXTRA_LCK; /* Simulate as locked */
break;
case HA_EXTRA_WAIT_LOCK:
- info->lock_wait=0;
+ info->lock_wait= 0;
break;
case HA_EXTRA_NO_WAIT_LOCK:
- info->lock_wait=MY_DONT_WAIT;
+ info->lock_wait= MY_DONT_WAIT;
break;
case HA_EXTRA_NO_KEYS:
/* we're going to modify pieces of the state, stall Checkpoint */
@@ -233,14 +232,14 @@ int maria_extra(MARIA_HA *info, enum ha_extra_function function,
if (info->lock_type == F_UNLCK)
{
pthread_mutex_unlock(&share->intern_lock);
- error=1; /* Not possibly if not lock */
+ error= 1; /* Not possibly if not lock */
break;
}
if (maria_is_any_key_active(share->state.key_map))
{
- MARIA_KEYDEF *key=share->keyinfo;
+ MARIA_KEYDEF *key= share->keyinfo;
uint i;
- for (i=0 ; i < share->base.keys ; i++,key++)
+ for (i =0 ; i < share->base.keys ; i++,key++)
{
if (!(key->flag & HA_NOSAME) && info->s->base.auto_key != i+1)
{
@@ -252,10 +251,10 @@ int maria_extra(MARIA_HA *info, enum ha_extra_function function,
if (!share->changed)
{
share->state.changed|= STATE_CHANGED | STATE_NOT_ANALYZED;
- share->changed=1; /* Update on close */
+ share->changed= 1; /* Update on close */
if (!share->global_changed)
{
- share->global_changed=1;
+ share->global_changed= 1;
share->state.open_count++;
}
}
@@ -280,11 +279,15 @@ int maria_extra(MARIA_HA *info, enum ha_extra_function function,
*/
/** @todo consider porting these flush-es to MyISAM */
error= _ma_flush_table_files(info, MARIA_FLUSH_DATA | MARIA_FLUSH_INDEX,
- FLUSH_FORCE_WRITE, FLUSH_FORCE_WRITE) ||
- _ma_state_info_write(share, 1|2|4);
-#ifdef ASK_MONTY
- || (share->changed= 0);
-#endif
+ FLUSH_FORCE_WRITE, FLUSH_FORCE_WRITE);
+ if (!error && share->changed)
+ {
+ pthread_mutex_lock(&share->intern_lock);
+ if (!(error= _ma_state_info_write(share, 1|2)))
+ share->changed= 0;
+ pthread_mutex_unlock(&share->intern_lock);
+ }
+
/**
@todo RECOVERY BUG
Though we flushed the state, IF some other thread may have the same
@@ -308,6 +311,7 @@ int maria_extra(MARIA_HA *info, enum ha_extra_function function,
case HA_EXTRA_PREPARE_FOR_RENAME:
{
my_bool do_flush= test(function != HA_EXTRA_PREPARE_FOR_DROP);
+ enum flush_type type;
pthread_mutex_lock(&THR_LOCK_maria);
/*
This share, to have last_version=0, needs to save all its data/index
@@ -325,12 +329,12 @@ int maria_extra(MARIA_HA *info, enum ha_extra_function function,
if (share->kfile.file >= 0)
_ma_decrement_open_count(info);
pthread_mutex_lock(&share->intern_lock);
- enum flush_type type= do_flush ? FLUSH_RELEASE : FLUSH_IGNORE_CHANGED;
+ type= do_flush ? FLUSH_RELEASE : FLUSH_IGNORE_CHANGED;
if (_ma_flush_table_files(info, MARIA_FLUSH_DATA | MARIA_FLUSH_INDEX,
type, type))
{
error=my_errno;
- share->changed=1;
+ share->changed= 1;
}
if (info->opt_flag & (READ_CACHE_USED | WRITE_CACHE_USED))
{
@@ -378,12 +382,12 @@ int maria_extra(MARIA_HA *info, enum ha_extra_function function,
#endif
if (share->not_flushed)
{
- share->not_flushed=0;
+ share->not_flushed= 0;
if (_ma_sync_table_files(info))
error= my_errno;
if (error)
{
- share->changed=1;
+ share->changed= 1;
maria_print_error(info->s, HA_ERR_CRASHED);
maria_mark_crashed(info); /* Fatal error found */
}
@@ -397,10 +401,10 @@ int maria_extra(MARIA_HA *info, enum ha_extra_function function,
}
break;
case HA_EXTRA_NORMAL: /* Theese isn't in use */
- info->quick_mode=0;
+ info->quick_mode= 0;
break;
case HA_EXTRA_QUICK:
- info->quick_mode=1;
+ info->quick_mode= 1;
break;
case HA_EXTRA_NO_ROWS:
if (!share->state.header.uniques)
@@ -434,7 +438,7 @@ int maria_extra(MARIA_HA *info, enum ha_extra_function function,
}
else
{
- share->file_read= _ma_mmap_pread;
+ share->file_read= _ma_mmap_pread;
share->file_write= _ma_mmap_pwrite;
}
}
@@ -451,10 +455,6 @@ int maria_extra(MARIA_HA *info, enum ha_extra_function function,
default:
break;
}
- {
- char tmp[1];
- tmp[0]=function;
- }
DBUG_RETURN(error);
} /* maria_extra */
@@ -487,7 +487,7 @@ static void maria_extra_keyflag(MARIA_HA *info,
int maria_reset(MARIA_HA *info)
{
int error= 0;
- MARIA_SHARE *share=info->s;
+ MARIA_SHARE *share= info->s;
DBUG_ENTER("maria_reset");
/*
Free buffers and reset the following flags:
@@ -514,7 +514,7 @@ int maria_reset(MARIA_HA *info)
MADV_RANDOM);
#endif
info->opt_flag&= ~(KEY_READ_USED | REMEMBER_OLD_POS);
- info->quick_mode=0;
+ info->quick_mode= 0;
info->lastinx= 0; /* Use first index as def */
info->last_search_keypage= info->cur_row.lastpos= HA_OFFSET_ERROR;
info->page_changed= 1;
diff --git a/storage/maria/ma_ft_update.c b/storage/maria/ma_ft_update.c
index 841b83e01f3..c6bed0e8e51 100644
--- a/storage/maria/ma_ft_update.c
+++ b/storage/maria/ma_ft_update.c
@@ -304,9 +304,10 @@ uint _ma_ft_make_key(MARIA_HA *info, uint keynr, uchar *keybuf, FT_WORD *wptr,
uint _ma_ft_convert_to_ft2(MARIA_HA *info, uint keynr, uchar *key)
{
+ MARIA_SHARE *share= info->s;
my_off_t root;
DYNAMIC_ARRAY *da=info->ft1_to_ft2;
- MARIA_KEYDEF *keyinfo=&info->s->ft2_keyinfo;
+ MARIA_KEYDEF *keyinfo=&share->ft2_keyinfo;
uchar *key_ptr= (uchar*) dynamic_array_ptr(da, 0), *end;
uint length, key_length;
MARIA_PINNED_PAGE tmp_page_link, *page_link= &tmp_page_link;
@@ -328,10 +329,10 @@ uint _ma_ft_convert_to_ft2(MARIA_HA *info, uint keynr, uchar *key)
}
/* creating pageful of keys */
- bzero(info->buff, info->s->keypage_header);
- _ma_store_keynr(info, info->buff, keynr);
- _ma_store_page_used(info, info->buff, length + info->s->keypage_header);
- memcpy(info->buff + info->s->keypage_header, key_ptr, length);
+ bzero(info->buff, share->keypage_header);
+ _ma_store_keynr(share, info->buff, keynr);
+ _ma_store_page_used(share, info->buff, length + share->keypage_header);
+ memcpy(info->buff + share->keypage_header, key_ptr, length);
info->keyread_buff_used= info->page_changed=1; /* info->buff is used */
if ((root= _ma_new(info, DFLT_INIT_HITS, &page_link)) == HA_OFFSET_ERROR ||
_ma_write_keypage(info, keyinfo, root, page_link->write_lock,
@@ -349,8 +350,8 @@ uint _ma_ft_convert_to_ft2(MARIA_HA *info, uint keynr, uchar *key)
_ma_dpointer(info, key+key_length+HA_FT_WLEN, root);
DBUG_RETURN(_ma_ck_real_write_btree(info,
- info->s->keyinfo+keynr,
+ share->keyinfo+keynr,
key, 0,
- &info->s->state.key_root[keynr],
+ &share->state.key_root[keynr],
SEARCH_SAME));
}
diff --git a/storage/maria/ma_info.c b/storage/maria/ma_info.c
index 4aecc33f816..0e1135087c3 100644
--- a/storage/maria/ma_info.c
+++ b/storage/maria/ma_info.c
@@ -34,7 +34,7 @@ MARIA_RECORD_POS maria_position(MARIA_HA *info)
int maria_status(MARIA_HA *info, register MARIA_INFO *x, uint flag)
{
MY_STAT state;
- MARIA_SHARE *share=info->s;
+ MARIA_SHARE *share= info->s;
DBUG_ENTER("maria_status");
x->recpos= info->cur_row.lastpos;
diff --git a/storage/maria/ma_key_recover.c b/storage/maria/ma_key_recover.c
index b5ca96b4023..520d1a002db 100644
--- a/storage/maria/ma_key_recover.c
+++ b/storage/maria/ma_key_recover.c
@@ -258,7 +258,7 @@ my_bool _ma_log_prefix(MARIA_HA *info, my_off_t page,
#ifdef EXTRA_DEBUG_KEY_CHANGES
{
- int page_length= _ma_get_page_used(info, buff);
+ int page_length= _ma_get_page_used(info->s, buff);
ha_checksum crc;
crc= my_checksum(0, buff + LSN_STORE_SIZE, page_length - LSN_STORE_SIZE);
log_pos[0]= KEY_OP_CHECK;
@@ -442,10 +442,11 @@ my_bool _ma_log_add(MARIA_HA *info, my_off_t page, uchar *buff,
#ifdef EXTRA_DEBUG_KEY_CHANGES
{
+ MARIA_SHARE *share= info->s;
ha_checksum crc;
- uint save_page_length= _ma_get_page_used(info, buff);
+ uint save_page_length= _ma_get_page_used(share, buff);
uint new_length= buff_length + move_length;
- _ma_store_page_used(info, buff, new_length);
+ _ma_store_page_used(share, buff, new_length);
crc= my_checksum(0, buff + LSN_STORE_SIZE, new_length - LSN_STORE_SIZE);
log_pos[0]= KEY_OP_CHECK;
int2store(log_pos+1, new_length);
@@ -455,7 +456,7 @@ my_bool _ma_log_add(MARIA_HA *info, my_off_t page, uchar *buff,
log_array[TRANSLOG_INTERNAL_PARTS + translog_parts].length= 7;
changed_length+= 7;
translog_parts++;
- _ma_store_page_used(info, buff, save_page_length);
+ _ma_store_page_used(share, buff, save_page_length);
}
#endif
@@ -635,7 +636,7 @@ uint _ma_apply_redo_index_free_page(MARIA_HA *info,
}
/* Free page */
bzero(buff + LSN_STORE_SIZE, share->keypage_header - LSN_STORE_SIZE);
- _ma_store_keynr(info, buff, (uchar) MARIA_DELETE_KEY_NR);
+ _ma_store_keynr(info->s, buff, (uchar) MARIA_DELETE_KEY_NR);
mi_sizestore(buff + share->keypage_header, old_link);
share->state.changed|= STATE_NOT_SORTED_PAGES;
@@ -727,7 +728,7 @@ uint _ma_apply_redo_index(MARIA_HA *info,
goto err;
}
- _ma_get_used_and_nod(info, buff, page_length, nod_flag);
+ _ma_get_used_and_nod(share, buff, page_length, nod_flag);
keypage_header= share->keypage_header;
org_page_length= page_length;
DBUG_PRINT("info", ("page_length: %u", page_length));
@@ -818,7 +819,7 @@ uint _ma_apply_redo_index(MARIA_HA *info,
ha_checksum crc;
check_page_length= uint2korr(header);
crc= uint4korr(header+2);
- _ma_store_page_used(info, buff, page_length);
+ _ma_store_page_used(share, buff, page_length);
DBUG_ASSERT(check_page_length == page_length);
DBUG_ASSERT(crc == (uint32) my_checksum(0, buff + LSN_STORE_SIZE,
page_length- LSN_STORE_SIZE));
@@ -836,7 +837,7 @@ uint _ma_apply_redo_index(MARIA_HA *info,
DBUG_ASSERT(header == header_end);
/* Write modified page */
- _ma_store_page_used(info, buff, page_length);
+ _ma_store_page_used(share, buff, page_length);
/*
Clean old stuff up. Gives us better compression of we archive things
diff --git a/storage/maria/ma_locking.c b/storage/maria/ma_locking.c
index aee9d729d53..a25820b81fb 100644
--- a/storage/maria/ma_locking.c
+++ b/storage/maria/ma_locking.c
@@ -28,7 +28,7 @@ int maria_lock_database(MARIA_HA *info, int lock_type)
{
int error;
uint count;
- MARIA_SHARE *share=info->s;
+ MARIA_SHARE *share= info->s;
DBUG_ENTER("maria_lock_database");
DBUG_PRINT("enter",("lock_type: %d old lock %d r_locks: %u w_locks: %u "
"global_changed: %d open_count: %u name: '%s'",
@@ -383,7 +383,7 @@ int _ma_readinfo(register MARIA_HA *info __attribute__ ((unused)),
if (info->lock_type == F_UNLCK)
{
- MARIA_SHARE *share=info->s;
+ MARIA_SHARE *share= info->s;
if (!share->tot_locks)
{
/* should not be done for transactional tables */
@@ -471,7 +471,7 @@ int _ma_writeinfo(register MARIA_HA *info, uint operation)
int _ma_test_if_changed(register MARIA_HA *info)
{
#ifdef EXTERNAL_LOCKING
- MARIA_SHARE *share=info->s;
+ MARIA_SHARE *share= info->s;
if (share->state.process != share->last_process ||
share->state.unique != info->last_unique ||
share->state.update_count != info->last_loop)
@@ -518,7 +518,7 @@ int _ma_test_if_changed(register MARIA_HA *info)
int _ma_mark_file_changed(MARIA_HA *info)
{
uchar buff[3];
- register MARIA_SHARE *share=info->s;
+ register MARIA_SHARE *share= info->s;
DBUG_ENTER("_ma_mark_file_changed");
if (!(share->state.changed & STATE_CHANGED) || ! share->global_changed)
@@ -556,7 +556,7 @@ int _ma_mark_file_changed(MARIA_HA *info)
int _ma_decrement_open_count(MARIA_HA *info)
{
uchar buff[2];
- register MARIA_SHARE *share=info->s;
+ register MARIA_SHARE *share= info->s;
int lock_error=0,write_error=0;
if (share->global_changed)
{
diff --git a/storage/maria/ma_loghandler.c b/storage/maria/ma_loghandler.c
index 1b603632088..c5a3a4eb4b3 100644
--- a/storage/maria/ma_loghandler.c
+++ b/storage/maria/ma_loghandler.c
@@ -63,30 +63,6 @@
#define COMPRESSED_LSN_MAX_STORE_SIZE (2 + LSN_STORE_SIZE)
#define MAX_NUMBER_OF_LSNS_PER_RECORD 2
-#ifndef DBUG_OFF
-static int translog_mutex_lock(pthread_mutex_t *M)
-{
- int rc;
- DBUG_PRINT("info", ("Going to lock mutex 0x%lx", (ulong)M));
- rc= pthread_mutex_lock(M);
- DBUG_PRINT("info", ("Mutex locked 0x%lx rc: %d", (ulong)M, rc));
- return (rc);
-}
-
-static int translog_mutex_unlock(pthread_mutex_t *M)
-{
- int rc;
- DBUG_PRINT("info", ("Going to unlock mutex 0x%lx", (ulong)M));
- rc= pthread_mutex_unlock(M);
- DBUG_PRINT("info", ("Mutex unlocked 0x%lx rc: %d", (ulong)M, rc));
- return(rc);
-}
-
-#else
-#define translog_mutex_lock(M) pthread_mutex_lock(M)
-#define translog_mutex_unlock(M) pthread_mutex_unlock(M)
-#endif
-
/* log write buffer descriptor */
struct st_translog_buffer
@@ -377,8 +353,8 @@ static LOG_DESC INIT_LOGREC_REDO_INSERT_ROW_TAIL=
write_hook_for_redo, NULL, 0,
"redo_insert_row_tail", LOGREC_NOT_LAST_IN_GROUP, NULL, NULL};
-/** @todo RECOVERY BUG unused, remove? */
-static LOG_DESC INIT_LOGREC_REDO_INSERT_ROW_BLOB=
+/* Use this entry next time we need to add a new entry */
+static LOG_DESC INIT_LOGREC_REDO_NOT_USED=
{LOGRECTYPE_VARIABLE_LENGTH, 0, 8, NULL, write_hook_for_redo, NULL, 0,
"redo_insert_row_blob", LOGREC_NOT_LAST_IN_GROUP, NULL, NULL};
@@ -565,8 +541,8 @@ static void loghandler_init()
INIT_LOGREC_REDO_INSERT_ROW_HEAD;
log_record_type_descriptor[LOGREC_REDO_INSERT_ROW_TAIL]=
INIT_LOGREC_REDO_INSERT_ROW_TAIL;
- log_record_type_descriptor[LOGREC_REDO_INSERT_ROW_BLOB]=
- INIT_LOGREC_REDO_INSERT_ROW_BLOB;
+ log_record_type_descriptor[LOGREC_REDO_NOT_USED]=
+ INIT_LOGREC_REDO_NOT_USED;
log_record_type_descriptor[LOGREC_REDO_INSERT_ROW_BLOBS]=
INIT_LOGREC_REDO_INSERT_ROW_BLOBS;
log_record_type_descriptor[LOGREC_REDO_PURGE_ROW_HEAD]=
@@ -951,7 +927,7 @@ static my_bool translog_set_lsn_for_files(uint32 from_file, uint32 to_file,
translog_unlock();
/* Checks finished files if they are */
- translog_mutex_lock(&log_descriptor.file_header_lock);
+ pthread_mutex_lock(&log_descriptor.file_header_lock);
for (file= from_file; file <= to_file; file++)
{
LOGHANDLER_FILE_INFO info;
@@ -962,7 +938,7 @@ static my_bool translog_set_lsn_for_files(uint32 from_file, uint32 to_file,
translog_max_lsn_to_header(fd, lsn)))
DBUG_RETURN(1);
}
- translog_mutex_unlock(&log_descriptor.file_header_lock);
+ pthread_mutex_unlock(&log_descriptor.file_header_lock);
DBUG_RETURN(0);
}
@@ -991,7 +967,7 @@ static void translog_mark_file_unfinished(uint32 file)
DBUG_ENTER("translog_mark_file_unfinished");
DBUG_PRINT("enter", ("file: %lu", (ulong) file));
- translog_mutex_lock(&log_descriptor.unfinished_files_lock);
+ pthread_mutex_lock(&log_descriptor.unfinished_files_lock);
if (log_descriptor.unfinished_files.elements == 0)
{
@@ -1042,7 +1018,7 @@ static void translog_mark_file_unfinished(uint32 file)
place + 1, struct st_file_counter *),
&fc, sizeof(struct st_file_counter));
end:
- translog_mutex_unlock(&log_descriptor.unfinished_files_lock);
+ pthread_mutex_unlock(&log_descriptor.unfinished_files_lock);
DBUG_VOID_RETURN;
}
@@ -1063,7 +1039,7 @@ static void translog_mark_file_finished(uint32 file)
LINT_INIT(fc_ptr);
- translog_mutex_lock(&log_descriptor.unfinished_files_lock);
+ pthread_mutex_lock(&log_descriptor.unfinished_files_lock);
DBUG_ASSERT(log_descriptor.unfinished_files.elements > 0);
for (i= 0;
@@ -1081,7 +1057,7 @@ static void translog_mark_file_finished(uint32 file)
if (! --fc_ptr->counter)
delete_dynamic_element(&log_descriptor.unfinished_files, i);
- translog_mutex_unlock(&log_descriptor.unfinished_files_lock);
+ pthread_mutex_unlock(&log_descriptor.unfinished_files_lock);
DBUG_VOID_RETURN;
}
@@ -1104,7 +1080,7 @@ LSN translog_get_file_max_lsn_stored(uint32 file)
DBUG_PRINT("enter", ("file: %lu", (ulong)file));
DBUG_ASSERT(translog_inited == 1);
- translog_mutex_lock(&log_descriptor.unfinished_files_lock);
+ pthread_mutex_lock(&log_descriptor.unfinished_files_lock);
/* find file with minimum file number "in progress" */
if (log_descriptor.unfinished_files.elements > 0)
@@ -1114,7 +1090,7 @@ LSN translog_get_file_max_lsn_stored(uint32 file)
0, struct st_file_counter *);
limit= fc_ptr->file; /* minimal file number "in progress" */
}
- translog_mutex_unlock(&log_descriptor.unfinished_files_lock);
+ pthread_mutex_unlock(&log_descriptor.unfinished_files_lock);
/*
if there is no "in progress file" then unfinished file is in progress
@@ -1280,7 +1256,7 @@ static my_bool translog_buffer_lock(struct st_translog_buffer *buffer)
("Lock buffer #%u: (0x%lx) mutex: 0x%lx",
(uint) buffer->buffer_no, (ulong) buffer,
(ulong) &buffer->mutex));
- res= (translog_mutex_lock(&buffer->mutex) != 0);
+ res= (pthread_mutex_lock(&buffer->mutex) != 0);
DBUG_RETURN(test(res));
}
#else
@@ -1311,8 +1287,8 @@ static my_bool translog_buffer_unlock(struct st_translog_buffer *buffer)
(uint) buffer->buffer_no, (ulong) buffer,
(ulong) &buffer->mutex));
- res= (translog_mutex_unlock(&buffer->mutex) != 0);
- DBUG_PRINT("enter", ("Unlocked buffer... #%u: 0x%lx mutex: 0x%lx",
+ res= (pthread_mutex_unlock(&buffer->mutex) != 0);
+ DBUG_PRINT("exit", ("Unlocked buffer... #%u: 0x%lx mutex: 0x%lx",
(uint) buffer->buffer_no, (ulong) buffer,
(ulong) &buffer->mutex));
DBUG_RETURN(res);
@@ -1779,7 +1755,7 @@ static my_bool translog_buffer_next(TRANSLOG_ADDRESS *horizon,
static void translog_set_sent_to_disk(LSN lsn, TRANSLOG_ADDRESS in_buffers)
{
DBUG_ENTER("translog_set_sent_to_disk");
- translog_mutex_lock(&log_descriptor.sent_to_disk_lock);
+ pthread_mutex_lock(&log_descriptor.sent_to_disk_lock);
DBUG_PRINT("enter", ("lsn: (%lu,0x%lx) in_buffers: (%lu,0x%lx) "
"in_buffers_only: (%lu,0x%lx)",
LSN_IN_PARTS(lsn),
@@ -1793,7 +1769,7 @@ static void translog_set_sent_to_disk(LSN lsn, TRANSLOG_ADDRESS in_buffers)
log_descriptor.in_buffers_only= in_buffers;
DBUG_PRINT("info", ("set new in_buffers_only"));
}
- translog_mutex_unlock(&log_descriptor.sent_to_disk_lock);
+ pthread_mutex_unlock(&log_descriptor.sent_to_disk_lock);
DBUG_VOID_RETURN;
}
@@ -1810,7 +1786,7 @@ static void translog_set_sent_to_disk(LSN lsn, TRANSLOG_ADDRESS in_buffers)
static void translog_set_only_in_buffers(TRANSLOG_ADDRESS in_buffers)
{
DBUG_ENTER("translog_set_only_in_buffers");
- translog_mutex_lock(&log_descriptor.sent_to_disk_lock);
+ pthread_mutex_lock(&log_descriptor.sent_to_disk_lock);
DBUG_PRINT("enter", ("in_buffers: (%lu,0x%lx) "
"in_buffers_only: (%lu,0x%lx)",
LSN_IN_PARTS(in_buffers),
@@ -1821,7 +1797,7 @@ static void translog_set_only_in_buffers(TRANSLOG_ADDRESS in_buffers)
log_descriptor.in_buffers_only= in_buffers;
DBUG_PRINT("info", ("set new in_buffers_only"));
}
- translog_mutex_unlock(&log_descriptor.sent_to_disk_lock);
+ pthread_mutex_unlock(&log_descriptor.sent_to_disk_lock);
DBUG_VOID_RETURN;
}
@@ -1840,9 +1816,9 @@ static TRANSLOG_ADDRESS translog_only_in_buffers()
{
register TRANSLOG_ADDRESS addr;
DBUG_ENTER("translog_only_in_buffers");
- translog_mutex_lock(&log_descriptor.sent_to_disk_lock);
+ pthread_mutex_lock(&log_descriptor.sent_to_disk_lock);
addr= log_descriptor.in_buffers_only;
- translog_mutex_unlock(&log_descriptor.sent_to_disk_lock);
+ pthread_mutex_unlock(&log_descriptor.sent_to_disk_lock);
DBUG_RETURN(addr);
}
@@ -1861,9 +1837,9 @@ static LSN translog_get_sent_to_disk()
{
register LSN lsn;
DBUG_ENTER("translog_get_sent_to_disk");
- translog_mutex_lock(&log_descriptor.sent_to_disk_lock);
+ pthread_mutex_lock(&log_descriptor.sent_to_disk_lock);
lsn= log_descriptor.sent_to_disk;
- translog_mutex_unlock(&log_descriptor.sent_to_disk_lock);
+ pthread_mutex_unlock(&log_descriptor.sent_to_disk_lock);
DBUG_RETURN(lsn);
}
@@ -2075,8 +2051,7 @@ static my_bool translog_buffer_flush(struct st_translog_buffer *buffer)
PAGECACHE_FILE file;
DBUG_ENTER("translog_buffer_flush");
DBUG_PRINT("enter",
- ("Buffer: #%u 0x%lx: "
- "file: %d offset: (%lu,0x%lx) size: %lu",
+ ("Buffer: #%u 0x%lx file: %d offset: (%lu,0x%lx) size: %lu",
(uint) buffer->buffer_no, (ulong) buffer,
buffer->file,
LSN_IN_PARTS(buffer->offset),
@@ -3648,7 +3623,7 @@ translog_buffer_increase_writers(struct st_translog_buffer *buffer)
DBUG_ENTER("translog_buffer_increase_writers");
translog_buffer_lock_assert_owner(buffer);
buffer->copy_to_buffer_in_progress++;
- DBUG_PRINT("info", ("copy_to_buffer_in_progress. Buffer #%u 0x%lx: %d",
+ DBUG_PRINT("info", ("copy_to_buffer_in_progress. Buffer #%u 0x%lx progress: %d",
(uint) buffer->buffer_no, (ulong) buffer,
buffer->copy_to_buffer_in_progress));
DBUG_VOID_RETURN;
@@ -3669,9 +3644,10 @@ static void translog_buffer_decrease_writers(struct st_translog_buffer *buffer)
DBUG_ENTER("translog_buffer_decrease_writers");
translog_buffer_lock_assert_owner(buffer);
buffer->copy_to_buffer_in_progress--;
- DBUG_PRINT("info", ("copy_to_buffer_in_progress. Buffer #%u 0x%lx: %d",
- (uint) buffer->buffer_no, (ulong) buffer,
- buffer->copy_to_buffer_in_progress));
+ DBUG_PRINT("info",
+ ("copy_to_buffer_in_progress. Buffer #%u 0x%lx progress: %d",
+ (uint) buffer->buffer_no, (ulong) buffer,
+ buffer->copy_to_buffer_in_progress));
if (buffer->copy_to_buffer_in_progress == 0 &&
buffer->waiting_filling_buffer.last_thread != NULL)
wqueue_release_queue(&buffer->waiting_filling_buffer);
@@ -6620,7 +6596,7 @@ my_bool translog_flush(LSN lsn)
DBUG_ASSERT(translog_inited == 1);
LINT_INIT(sent_to_disk);
- translog_mutex_lock(&log_descriptor.log_flush_lock);
+ pthread_mutex_lock(&log_descriptor.log_flush_lock);
translog_lock();
flush_horizon= LSN_IMPOSSIBLE;
old_flushed= log_descriptor.flushed;
@@ -6630,16 +6606,16 @@ my_bool translog_flush(LSN lsn)
uint16 buffer_start= buffer_no;
struct st_translog_buffer *buffer_unlock= log_descriptor.bc.buffer;
struct st_translog_buffer *buffer= log_descriptor.bc.buffer;
- if (cmp_translog_addr(log_descriptor.flushed, lsn) >= 0 ||
- full_circle)
+ if (cmp_translog_addr(log_descriptor.flushed, lsn) >= 0)
{
DBUG_PRINT("info", ("already flushed: (%lu,0x%lx)",
LSN_IN_PARTS(log_descriptor.flushed)));
- goto sync;
+ translog_unlock();
+ goto out;
}
/* send to the file if it is not sent */
sent_to_disk= translog_get_sent_to_disk();
- if (cmp_translog_addr(sent_to_disk, lsn) >= 0)
+ if (cmp_translog_addr(sent_to_disk, lsn) >= 0 || full_circle)
break;
do
@@ -6679,6 +6655,8 @@ my_bool translog_flush(LSN lsn)
if ((log_descriptor.log_file_num[cache_index]=
open_logfile_by_number_no_cache(fn)) == -1)
{
+ /* We don't need translog_unlock() here */
+ translog_buffer_unlock(buffer);
rc= 1;
goto out;
}
@@ -6694,13 +6672,9 @@ my_bool translog_flush(LSN lsn)
rc= translog_buffer_flush(buffer);
translog_buffer_unlock(buffer);
if (rc)
- {
- rc= 1;
- goto out;
- }
+ goto out; /* rc is 1 */
translog_lock();
}
-sync:
translog_unlock();
{
@@ -6723,7 +6697,7 @@ sync:
rc|= my_sync(log_descriptor.directory_fd, MYF(MY_WME | MY_IGNORE_BADFD));
log_descriptor.previous_flush_horizon= flush_horizon;
out:
- translog_mutex_unlock(&log_descriptor.log_flush_lock);
+ pthread_mutex_unlock(&log_descriptor.log_flush_lock);
DBUG_RETURN(rc);
}
@@ -6754,7 +6728,7 @@ int translog_assign_id_to_share(MARIA_HA *tbl_info, TRN *trn)
*/
DBUG_ASSERT(share->data_file_type == BLOCK_RECORD);
/* re-check under mutex to avoid having 2 ids for the same share */
- translog_mutex_lock(&share->intern_lock);
+ pthread_mutex_lock(&share->intern_lock);
if (likely(share->id == 0))
{
/* Inspired by set_short_trid() of trnman.c */
@@ -6801,7 +6775,7 @@ int translog_assign_id_to_share(MARIA_HA *tbl_info, TRN *trn)
log_array, log_data, NULL)))
return 1;
}
- translog_mutex_unlock(&share->intern_lock);
+ pthread_mutex_unlock(&share->intern_lock);
return 0;
}
@@ -6878,14 +6852,14 @@ static uint32 translog_first_file(TRANSLOG_ADDRESS horizon, int is_protected)
uint min_file= 1, max_file;
DBUG_ENTER("translog_first_file");
if (!is_protected)
- translog_mutex_lock(&log_descriptor.purger_lock);
+ pthread_mutex_lock(&log_descriptor.purger_lock);
if (log_descriptor.min_file_number &&
translog_is_file(log_descriptor.min_file_number))
{
DBUG_PRINT("info", ("cached %lu",
(ulong) log_descriptor.min_file_number));
if (!is_protected)
- translog_mutex_unlock(&log_descriptor.purger_lock);
+ pthread_mutex_unlock(&log_descriptor.purger_lock);
DBUG_RETURN(log_descriptor.min_file_number);
}
@@ -6912,7 +6886,7 @@ static uint32 translog_first_file(TRANSLOG_ADDRESS horizon, int is_protected)
}
log_descriptor.min_file_number= max_file;
if (!is_protected)
- translog_mutex_unlock(&log_descriptor.purger_lock);
+ pthread_mutex_unlock(&log_descriptor.purger_lock);
DBUG_RETURN(max_file);
}
@@ -7102,7 +7076,7 @@ my_bool translog_purge(TRANSLOG_ADDRESS low)
DBUG_PRINT("enter", ("low: (%lu,0x%lx)", LSN_IN_PARTS(low)));
DBUG_ASSERT(translog_inited == 1);
- translog_mutex_lock(&log_descriptor.purger_lock);
+ pthread_mutex_lock(&log_descriptor.purger_lock);
if (LSN_FILE_NO(log_descriptor.last_lsn_checked) < last_need_file)
{
uint32 i;
@@ -7130,6 +7104,6 @@ my_bool translog_purge(TRANSLOG_ADDRESS low)
}
}
- translog_mutex_unlock(&log_descriptor.purger_lock);
+ pthread_mutex_unlock(&log_descriptor.purger_lock);
DBUG_RETURN(rc);
}
diff --git a/storage/maria/ma_loghandler.h b/storage/maria/ma_loghandler.h
index 1324cd92208..a67d6857098 100644
--- a/storage/maria/ma_loghandler.h
+++ b/storage/maria/ma_loghandler.h
@@ -105,7 +105,7 @@ enum translog_record_type
LOGREC_RESERVED_FOR_CHUNKS23= 0,
LOGREC_REDO_INSERT_ROW_HEAD,
LOGREC_REDO_INSERT_ROW_TAIL,
- LOGREC_REDO_INSERT_ROW_BLOB,
+ LOGREC_REDO_NOT_USED, /* Reserver for next tag */
LOGREC_REDO_INSERT_ROW_BLOBS,
LOGREC_REDO_PURGE_ROW_HEAD,
LOGREC_REDO_PURGE_ROW_TAIL,
diff --git a/storage/maria/ma_open.c b/storage/maria/ma_open.c
index 24293b79a1a..e679f5a0831 100644
--- a/storage/maria/ma_open.c
+++ b/storage/maria/ma_open.c
@@ -64,7 +64,7 @@ MARIA_HA *_ma_test_if_reopen(const char *filename)
for (pos=maria_open_list ; pos ; pos=pos->next)
{
MARIA_HA *info=(MARIA_HA*) pos->data;
- MARIA_SHARE *share=info->s;
+ MARIA_SHARE *share= info->s;
if (!strcmp(share->unique_file_name,filename) && share->last_version)
return info;
}
diff --git a/storage/maria/ma_packrec.c b/storage/maria/ma_packrec.c
index 5d04b9d705a..7ef9f6ba857 100644
--- a/storage/maria/ma_packrec.c
+++ b/storage/maria/ma_packrec.c
@@ -774,7 +774,7 @@ int _ma_pack_rec_unpack(register MARIA_HA *info, MARIA_BIT_BUFF *bit_buff,
uchar *end_field;
reg3 MARIA_COLUMNDEF *end;
MARIA_COLUMNDEF *current_field;
- MARIA_SHARE *share=info->s;
+ MARIA_SHARE *share= info->s;
DBUG_ENTER("_ma_pack_rec_unpack");
if (info->s->base.null_bytes)
@@ -1349,7 +1349,7 @@ int _ma_read_rnd_pack_record(MARIA_HA *info,
{
File file;
MARIA_BLOCK_INFO block_info;
- MARIA_SHARE *share=info->s;
+ MARIA_SHARE *share= info->s;
DBUG_ENTER("_ma_read_rnd_pack_record");
if (filepos >= info->state->data_file_length)
@@ -1544,7 +1544,7 @@ static int _ma_read_rnd_mempack_record(MARIA_HA*, uchar *, MARIA_RECORD_POS,
my_bool _ma_memmap_file(MARIA_HA *info)
{
- MARIA_SHARE *share=info->s;
+ MARIA_SHARE *share= info->s;
DBUG_ENTER("maria_memmap_file");
if (!info->s->file_map)
@@ -1601,7 +1601,7 @@ static int _ma_read_mempack_record(MARIA_HA *info, uchar *buf,
MARIA_RECORD_POS filepos)
{
MARIA_BLOCK_INFO block_info;
- MARIA_SHARE *share=info->s;
+ MARIA_SHARE *share= info->s;
uchar *pos;
DBUG_ENTER("maria_read_mempack_record");
@@ -1627,7 +1627,7 @@ static int _ma_read_rnd_mempack_record(MARIA_HA *info,
__attribute__((unused)))
{
MARIA_BLOCK_INFO block_info;
- MARIA_SHARE *share=info->s;
+ MARIA_SHARE *share= info->s;
uchar *pos,*start;
DBUG_ENTER("_ma_read_rnd_mempack_record");
diff --git a/storage/maria/ma_page.c b/storage/maria/ma_page.c
index 906c6161faf..0940dd4a62f 100644
--- a/storage/maria/ma_page.c
+++ b/storage/maria/ma_page.c
@@ -30,14 +30,15 @@ uchar *_ma_fetch_keypage(register MARIA_HA *info,
{
uchar *tmp;
uint page_size;
- uint block_size= info->s->block_size;
MARIA_PINNED_PAGE page_link;
+ MARIA_SHARE *share= info->s;
+ uint block_size= share->block_size;
DBUG_ENTER("_ma_fetch_keypage");
DBUG_PRINT("enter",("page: %ld", (long) page));
- tmp= pagecache_read(info->s->pagecache, &info->s->kfile,
+ tmp= pagecache_read(share->pagecache, &share->kfile,
page / block_size, level, buff,
- info->s->page_type, lock, &page_link.link);
+ share->page_type, lock, &page_link.link);
if (lock != PAGECACHE_LOCK_LEFT_UNLOCKED)
{
@@ -56,22 +57,22 @@ uchar *_ma_fetch_keypage(register MARIA_HA *info,
{
DBUG_PRINT("error",("Got errno: %d from pagecache_read",my_errno));
info->last_keypage=HA_OFFSET_ERROR;
- maria_print_error(info->s, HA_ERR_CRASHED);
+ maria_print_error(share, HA_ERR_CRASHED);
my_errno=HA_ERR_CRASHED;
DBUG_RETURN(0);
}
info->last_keypage=page;
#ifdef EXTRA_DEBUG
- page_size= _ma_get_page_used(info, tmp);
+ page_size= _ma_get_page_used(share, tmp);
if (page_size < 4 || page_size > block_size ||
- _ma_get_keynr(info, tmp) != keyinfo->key_nr)
+ _ma_get_keynr(share, tmp) != keyinfo->key_nr)
{
DBUG_PRINT("error",("page %lu had wrong page length: %u keynr: %u",
(ulong) page, page_size,
- _ma_get_keynr(info, tmp)));
+ _ma_get_keynr(share, tmp)));
DBUG_DUMP("page", (char*) tmp, page_size);
info->last_keypage = HA_OFFSET_ERROR;
- maria_print_error(info->s, HA_ERR_CRASHED);
+ maria_print_error(share, HA_ERR_CRASHED);
my_errno= HA_ERR_CRASHED;
tmp= 0;
}
@@ -86,30 +87,38 @@ int _ma_write_keypage(register MARIA_HA *info, register MARIA_KEYDEF *keyinfo,
my_off_t page, enum pagecache_page_lock lock,
int level, uchar *buff)
{
- uint block_size= info->s->block_size;
+ MARIA_SHARE *share= info->s;
MARIA_PINNED_PAGE page_link;
+ uint block_size= share->block_size;
int res;
DBUG_ENTER("_ma_write_keypage");
#ifdef EXTRA_DEBUG /* Safety check */
- if (page < info->s->base.keystart ||
- page+block_size > info->state->key_file_length ||
- (page & (MARIA_MIN_KEY_BLOCK_LENGTH-1)))
{
- DBUG_PRINT("error",("Trying to write inside key status region: "
- "key_start: %lu length: %lu page: %lu",
- (long) info->s->base.keystart,
- (long) info->state->key_file_length,
- (long) page));
- my_errno=EINVAL;
- DBUG_RETURN((-1));
+ uint page_length, nod;
+ _ma_get_used_and_nod(share, buff, page_length, nod);
+ if (page < share->base.keystart ||
+ page+block_size > info->state->key_file_length ||
+ (page & (MARIA_MIN_KEY_BLOCK_LENGTH-1)))
+ {
+ DBUG_PRINT("error",("Trying to write inside key status region: "
+ "key_start: %lu length: %lu page: %lu",
+ (long) share->base.keystart,
+ (long) info->state->key_file_length,
+ (long) page));
+ my_errno=EINVAL;
+ DBUG_ASSERT(0);
+ DBUG_RETURN((-1));
+ }
+ DBUG_PRINT("page",("write page at: %lu",(long) page));
+ DBUG_DUMP("buff", buff, page_length);
+ DBUG_ASSERT(page_length >= share->keypage_header + nod +
+ keyinfo->minlength || maria_in_recovery);
}
- DBUG_PRINT("page",("write page at: %lu",(long) page));
- DBUG_DUMP("buff", buff,_ma_get_page_used(info, buff));
#endif
/* Verify that keynr is correct */
- DBUG_ASSERT(_ma_get_keynr(info, buff) == keyinfo->key_nr);
+ DBUG_ASSERT(_ma_get_keynr(share, buff) == keyinfo->key_nr);
#if defined(EXTRA_DEBUG) && defined(HAVE_purify)
{
@@ -121,19 +130,19 @@ int _ma_write_keypage(register MARIA_HA *info, register MARIA_KEYDEF *keyinfo,
#ifdef IDENTICAL_PAGES_AFTER_RECOVERY
{
- uint length= _ma_get_page_used(info, buff);
+ uint length= _ma_get_page_used(share, buff);
DBUG_ASSERT(length <= block_size - KEYPAGE_CHECKSUM_SIZE);
bzero(buff + length, block_size - length);
}
#endif
- DBUG_ASSERT(info->s->pagecache->block_size == block_size);
- if (!(info->s->options & HA_OPTION_PAGE_CHECKSUM))
+ DBUG_ASSERT(share->pagecache->block_size == block_size);
+ if (!(share->options & HA_OPTION_PAGE_CHECKSUM))
bfill(buff + block_size - KEYPAGE_CHECKSUM_SIZE,
KEYPAGE_CHECKSUM_SIZE, (uchar) 255);
- res= pagecache_write(info->s->pagecache,
- &info->s->kfile, page / block_size,
- level, buff, info->s->page_type,
+ res= pagecache_write(share->pagecache,
+ &share->kfile, page / block_size,
+ level, buff, share->page_type,
lock,
lock == PAGECACHE_LOCK_LEFT_WRITELOCKED ?
PAGECACHE_PIN_LEFT_PINNED :
@@ -191,11 +200,11 @@ int _ma_dispose(register MARIA_HA *info, my_off_t pos, my_bool page_not_read)
share->current_key_del= pos;
page_no= pos / block_size;
bzero(buff, share->keypage_header);
- _ma_store_keynr(info, buff, (uchar) MARIA_DELETE_KEY_NR);
+ _ma_store_keynr(share, buff, (uchar) MARIA_DELETE_KEY_NR);
mi_sizestore(buff + share->keypage_header, old_link);
share->state.changed|= STATE_NOT_SORTED_PAGES;
- if (info->s->now_transactional)
+ if (share->now_transactional)
{
LSN lsn;
uchar log_data[FILEID_STORE_SIZE + PAGE_STORE_SIZE * 2];
@@ -207,7 +216,7 @@ int _ma_dispose(register MARIA_HA *info, my_off_t pos, my_bool page_not_read)
/* Store link to next unused page (the link that is written to page) */
page= (old_link == HA_OFFSET_ERROR ? IMPOSSIBLE_PAGE_NO :
- old_link / info->s->block_size);
+ old_link / block_size);
page_store(log_data + FILEID_STORE_SIZE + PAGE_STORE_SIZE, page);
log_array[TRANSLOG_INTERNAL_PARTS + 0].str= (char*) log_data;
@@ -315,7 +324,7 @@ my_off_t _ma_new(register MARIA_HA *info, int level,
else
{
share->current_key_del= mi_sizekorr(buff+share->keypage_header);
- DBUG_ASSERT(share->current_key_del != info->s->state.key_del &&
+ DBUG_ASSERT(share->current_key_del != share->state.key_del &&
share->current_key_del);
}
diff --git a/storage/maria/ma_preload.c b/storage/maria/ma_preload.c
index f293b18213f..c2a6d405932 100644
--- a/storage/maria/ma_preload.c
+++ b/storage/maria/ma_preload.c
@@ -73,8 +73,8 @@ int maria_preload(MARIA_HA *info, ulonglong key_map, my_bool ignore_leaves)
for (end= buff + length ; buff < end ; buff+= block_length)
{
- uint keynr= _ma_get_keynr(info, buff);
- if ((ignore_leaves && !_ma_test_if_nod(info, buff)) ||
+ uint keynr= _ma_get_keynr(share, buff);
+ if ((ignore_leaves && !_ma_test_if_nod(share, buff)) ||
keynr == MARIA_DELETE_KEY_NR ||
!(key_map & ((ulonglong) 1 << keynr)))
{
diff --git a/storage/maria/ma_range.c b/storage/maria/ma_range.c
index 2fd172793ba..056629319e5 100644
--- a/storage/maria/ma_range.c
+++ b/storage/maria/ma_range.c
@@ -217,7 +217,7 @@ static double _ma_search_pos(register MARIA_HA *info,
goto err;
flag=(*keyinfo->bin_search)(info, keyinfo, buff, key, key_len, nextflag,
&keypos,info->lastkey, &after_key);
- nod_flag=_ma_test_if_nod(info, buff);
+ nod_flag=_ma_test_if_nod(info->s, buff);
keynr= _ma_keynr(info,keyinfo,buff,keypos,&max_keynr);
if (flag)
@@ -272,7 +272,7 @@ static uint _ma_keynr(MARIA_HA *info, register MARIA_KEYDEF *keyinfo,
uint nod_flag, used_length, keynr, max_key;
uchar t_buff[HA_MAX_KEY_BUFF],*end;
- _ma_get_used_and_nod(info, page, used_length, nod_flag);
+ _ma_get_used_and_nod(info->s, page, used_length, nod_flag);
end= page+ used_length;
page+= info->s->keypage_header + nod_flag;
diff --git a/storage/maria/ma_rkey.c b/storage/maria/ma_rkey.c
index ff1110e5344..e6033cdc4a8 100644
--- a/storage/maria/ma_rkey.c
+++ b/storage/maria/ma_rkey.c
@@ -25,7 +25,7 @@ int maria_rkey(MARIA_HA *info, uchar *buf, int inx, const uchar *key,
key_part_map keypart_map, enum ha_rkey_function search_flag)
{
uchar *key_buff;
- MARIA_SHARE *share=info->s;
+ MARIA_SHARE *share= info->s;
MARIA_KEYDEF *keyinfo;
HA_KEYSEG *last_used_keyseg;
uint pack_key_length, use_key_length, nextflag;
diff --git a/storage/maria/ma_rprev.c b/storage/maria/ma_rprev.c
index 753ff604975..c41c88c154b 100644
--- a/storage/maria/ma_rprev.c
+++ b/storage/maria/ma_rprev.c
@@ -26,7 +26,7 @@ int maria_rprev(MARIA_HA *info, uchar *buf, int inx)
{
int error,changed;
register uint flag;
- MARIA_SHARE *share=info->s;
+ MARIA_SHARE *share= info->s;
DBUG_ENTER("maria_rprev");
if ((inx = _ma_check_index(info,inx)) < 0)
diff --git a/storage/maria/ma_rt_index.c b/storage/maria/ma_rt_index.c
index 50d4e9e0fd2..29a9bab4f72 100644
--- a/storage/maria/ma_rt_index.c
+++ b/storage/maria/ma_rt_index.c
@@ -56,6 +56,7 @@ static int maria_rtree_find_req(MARIA_HA *info, MARIA_KEYDEF *keyinfo,
uint search_flag,
uint nod_cmp_flag, my_off_t page, int level)
{
+ MARIA_SHARE *share= info->s;
uint nod_flag;
int res;
uchar *page_buf, *k, *last;
@@ -70,9 +71,9 @@ static int maria_rtree_find_req(MARIA_HA *info, MARIA_KEYDEF *keyinfo,
if (!_ma_fetch_keypage(info, keyinfo, page, PAGECACHE_LOCK_LEFT_UNLOCKED,
DFLT_INIT_HITS, page_buf, 0, 0))
goto err1;
- nod_flag= _ma_test_if_nod(info, page_buf);
+ nod_flag= _ma_test_if_nod(share, page_buf);
- k_len= keyinfo->keylength - info->s->base.rec_reflength;
+ k_len= keyinfo->keylength - share->base.rec_reflength;
if (info->maria_rtree_recursion_depth >= level)
{
@@ -80,11 +81,11 @@ static int maria_rtree_find_req(MARIA_HA *info, MARIA_KEYDEF *keyinfo,
}
else
{
- k= rt_PAGE_FIRST_KEY(info, page_buf, nod_flag);
+ k= rt_PAGE_FIRST_KEY(share, page_buf, nod_flag);
}
- last= rt_PAGE_END(info, page_buf);
+ last= rt_PAGE_END(share, page_buf);
- for (; k < last; k= rt_PAGE_NEXT_KEY(k, k_len, nod_flag))
+ for (; k < last; k= rt_PAGE_NEXT_KEY(share, k, k_len, nod_flag))
{
if (nod_flag)
{
@@ -116,9 +117,9 @@ static int maria_rtree_find_req(MARIA_HA *info, MARIA_KEYDEF *keyinfo,
if (!maria_rtree_key_cmp(keyinfo->seg, info->first_mbr_key,
k, info->last_rkey_length, search_flag))
{
- uchar *after_key= (uchar*) rt_PAGE_NEXT_KEY(k, k_len, nod_flag);
+ uchar *after_key= (uchar*) rt_PAGE_NEXT_KEY(share, k, k_len, nod_flag);
info->cur_row.lastpos= _ma_dpos(info, 0, after_key);
- info->lastkey_length= k_len + info->s->base.rec_reflength;
+ info->lastkey_length= k_len + share->base.rec_reflength;
memcpy(info->lastkey, k, info->lastkey_length);
info->maria_rtree_recursion_depth= level;
*saved_key= last - page_buf;
@@ -280,6 +281,7 @@ int maria_rtree_find_next(MARIA_HA *info, uint keynr, uint search_flag)
static int maria_rtree_get_req(MARIA_HA *info, MARIA_KEYDEF *keyinfo,
uint key_length, my_off_t page, int level)
{
+ MARIA_SHARE *share= info->s;
uchar *page_buf, *last, *k;
uint nod_flag, k_len;
int res;
@@ -290,9 +292,9 @@ static int maria_rtree_get_req(MARIA_HA *info, MARIA_KEYDEF *keyinfo,
if (!_ma_fetch_keypage(info, keyinfo, page, PAGECACHE_LOCK_LEFT_UNLOCKED,
DFLT_INIT_HITS, page_buf, 0, 0))
goto err1;
- nod_flag= _ma_test_if_nod(info, page_buf);
+ nod_flag= _ma_test_if_nod(share, page_buf);
- k_len= keyinfo->keylength - info->s->base.rec_reflength;
+ k_len= keyinfo->keylength - share->base.rec_reflength;
if(info->maria_rtree_recursion_depth >= level)
{
@@ -301,16 +303,16 @@ static int maria_rtree_get_req(MARIA_HA *info, MARIA_KEYDEF *keyinfo,
{
/* Only leaf pages contain data references. */
/* Need to check next key with data reference. */
- k= rt_PAGE_NEXT_KEY(k, k_len, nod_flag);
+ k= rt_PAGE_NEXT_KEY(share, k, k_len, nod_flag);
}
}
else
{
- k= rt_PAGE_FIRST_KEY(info, page_buf, nod_flag);
+ k= rt_PAGE_FIRST_KEY(share, page_buf, nod_flag);
}
- last= rt_PAGE_END(info, page_buf);
+ last= rt_PAGE_END(share, page_buf);
- for (; k < last; k= rt_PAGE_NEXT_KEY(k, k_len, nod_flag))
+ for (; k < last; k= rt_PAGE_NEXT_KEY(share, k, k_len, nod_flag))
{
if (nod_flag)
{
@@ -332,9 +334,9 @@ static int maria_rtree_get_req(MARIA_HA *info, MARIA_KEYDEF *keyinfo,
else
{
/* this is a leaf */
- uchar *after_key= rt_PAGE_NEXT_KEY(k, k_len, nod_flag);
+ uchar *after_key= rt_PAGE_NEXT_KEY(share, k, k_len, nod_flag);
info->cur_row.lastpos= _ma_dpos(info, 0, after_key);
- info->lastkey_length= k_len + info->s->base.rec_reflength;
+ info->lastkey_length= k_len + share->base.rec_reflength;
memcpy(info->lastkey, k, info->lastkey_length);
info->maria_rtree_recursion_depth= level;
@@ -344,7 +346,7 @@ static int maria_rtree_get_req(MARIA_HA *info, MARIA_KEYDEF *keyinfo,
{
info->int_keypos= (uchar*) saved_key;
memcpy(info->buff, page_buf, keyinfo->block_length);
- info->int_maxpos= rt_PAGE_END(info, info->buff);
+ info->int_maxpos= rt_PAGE_END(share, info->buff);
info->keyread_buff_used= 0;
}
else
@@ -491,18 +493,19 @@ static uchar *maria_rtree_pick_key(MARIA_HA *info, MARIA_KEYDEF *keyinfo,
uint key_length, uchar *page_buf,
uint nod_flag)
{
+ MARIA_SHARE *share= info->s;
double increase;
double best_incr= DBL_MAX;
double area;
double best_area;
uchar *best_key;
- uchar *k= rt_PAGE_FIRST_KEY(info, page_buf, nod_flag);
- uchar *last= rt_PAGE_END(info, page_buf);
+ uchar *k= rt_PAGE_FIRST_KEY(share, page_buf, nod_flag);
+ uchar *last= rt_PAGE_END(share, page_buf);
LINT_INIT(best_area);
LINT_INIT(best_key);
- for (; k < last; k= rt_PAGE_NEXT_KEY(k, key_length, nod_flag))
+ for (; k < last; k= rt_PAGE_NEXT_KEY(share, k, key_length, nod_flag))
{
/* The following is safe as -1.0 is an exact number */
if ((increase= maria_rtree_area_increase(keyinfo->seg, k, key, key_length,
@@ -561,7 +564,7 @@ static int maria_rtree_insert_req(MARIA_HA *info, MARIA_KEYDEF *keyinfo,
if (!_ma_fetch_keypage(info, keyinfo, page, PAGECACHE_LOCK_WRITE,
DFLT_INIT_HITS, page_buf, 0, &page_link))
goto err1;
- nod_flag= _ma_test_if_nod(info, page_buf);
+ nod_flag= _ma_test_if_nod(info->s, page_buf);
DBUG_PRINT("rtree", ("page: %lu level: %d ins_level: %d nod_flag: %u",
(ulong) page, level, ins_level, nod_flag));
@@ -646,13 +649,14 @@ static int maria_rtree_insert_level(MARIA_HA *info, uint keynr, uchar *key,
uint key_length, int ins_level)
{
my_off_t old_root;
- MARIA_KEYDEF *keyinfo= info->s->keyinfo + keynr;
+ MARIA_SHARE *share= info->s;
+ MARIA_KEYDEF *keyinfo= share->keyinfo + keynr;
int res;
my_off_t new_page;
MARIA_PINNED_PAGE *page_link;
DBUG_ENTER("maria_rtree_insert_level");
- if ((old_root= info->s->state.key_root[keynr]) == HA_OFFSET_ERROR)
+ if ((old_root= share->state.key_root[keynr]) == HA_OFFSET_ERROR)
{
MARIA_PINNED_PAGE tmp_page_link;
page_link= &tmp_page_link;
@@ -660,9 +664,9 @@ static int maria_rtree_insert_level(MARIA_HA *info, uint keynr, uchar *key,
HA_OFFSET_ERROR)
DBUG_RETURN(-1);
info->keyread_buff_used= 1;
- bzero(info->buff, info->s->keypage_header);
- _ma_store_keynr(info, info->buff, keynr);
- _ma_store_page_used(info, info->buff, info->s->keypage_header);
+ bzero(info->buff, share->keypage_header);
+ _ma_store_keynr(share, info->buff, keynr);
+ _ma_store_page_used(share, info->buff, share->keypage_header);
res= maria_rtree_add_key(info, keyinfo, key, key_length, info->buff,
NULL);
@@ -670,7 +674,7 @@ static int maria_rtree_insert_level(MARIA_HA *info, uint keynr, uchar *key,
page_link->write_lock,
DFLT_INIT_HITS, info->buff))
DBUG_RETURN(1);
- info->s->state.key_root[keynr]= old_root;
+ share->state.key_root[keynr]= old_root;
DBUG_RETURN(res);
}
@@ -685,7 +689,7 @@ static int maria_rtree_insert_level(MARIA_HA *info, uint keynr, uchar *key,
{
uchar *new_root_buf, *new_key;
my_off_t new_root;
- uint nod_flag= info->s->base.key_reflength;
+ uint nod_flag= share->base.key_reflength;
MARIA_PINNED_PAGE tmp_page_link;
page_link= &tmp_page_link;
@@ -697,11 +701,11 @@ static int maria_rtree_insert_level(MARIA_HA *info, uint keynr, uchar *key,
DBUG_RETURN(-1); /* purecov: inspected */
}
- bzero(new_root_buf, info->s->keypage_header);
+ bzero(new_root_buf, share->keypage_header);
if (nod_flag)
- _ma_store_keypage_flag(info, new_root_buf, KEYPAGE_FLAG_ISNOD);
- _ma_store_keynr(info, new_root_buf, keynr);
- _ma_store_page_used(info, new_root_buf, info->s->keypage_header);
+ _ma_store_keypage_flag(share, new_root_buf, KEYPAGE_FLAG_ISNOD);
+ _ma_store_keynr(share, new_root_buf, keynr);
+ _ma_store_page_used(share, new_root_buf, share->keypage_header);
if ((new_root= _ma_new(info, DFLT_INIT_HITS, &page_link)) ==
HA_OFFSET_ERROR)
goto err1;
@@ -727,10 +731,10 @@ static int maria_rtree_insert_level(MARIA_HA *info, uint keynr, uchar *key,
if (_ma_write_keypage(info, keyinfo, new_root, page_link->write_lock,
DFLT_INIT_HITS, new_root_buf))
goto err1;
- info->s->state.key_root[keynr]= new_root;
+ share->state.key_root[keynr]= new_root;
DBUG_PRINT("rtree", ("new root page: %lu level: %d nod_flag: %u",
(ulong) new_root, 0,
- _ma_test_if_nod(info, new_root_buf)));
+ _ma_test_if_nod(share, new_root_buf)));
my_afree((uchar*)new_root_buf);
break;
@@ -817,6 +821,7 @@ static int maria_rtree_delete_req(MARIA_HA *info, MARIA_KEYDEF *keyinfo,
int res;
uchar *page_buf, *last, *k;
MARIA_PINNED_PAGE *page_link;
+ MARIA_SHARE *share= info->s;
DBUG_ENTER("maria_rtree_delete_req");
if (!(page_buf= (uchar*) my_alloca((uint)keyinfo->block_length)))
@@ -827,14 +832,16 @@ static int maria_rtree_delete_req(MARIA_HA *info, MARIA_KEYDEF *keyinfo,
if (!_ma_fetch_keypage(info, keyinfo, page, PAGECACHE_LOCK_WRITE,
DFLT_INIT_HITS, page_buf, 0, &page_link))
goto err1;
- nod_flag= _ma_test_if_nod(info, page_buf);
+ nod_flag= _ma_test_if_nod(share, page_buf);
DBUG_PRINT("rtree", ("page: %lu level: %d nod_flag: %u",
(ulong) page, level, nod_flag));
- k= rt_PAGE_FIRST_KEY(info, page_buf, nod_flag);
- last= rt_PAGE_END(info, page_buf);
+ k= rt_PAGE_FIRST_KEY(share, page_buf, nod_flag);
+ last= rt_PAGE_END(share, page_buf);
- for (i= 0; k < last; k= rt_PAGE_NEXT_KEY(k, key_length, nod_flag), i++)
+ for (i= 0;
+ k < last;
+ k= rt_PAGE_NEXT_KEY(share, k, key_length, nod_flag), i++)
{
if (nod_flag)
{
@@ -887,7 +894,7 @@ static int maria_rtree_delete_req(MARIA_HA *info, MARIA_KEYDEF *keyinfo,
PAGECACHE_LOCK_LEFT_WRITELOCKED,
DFLT_INIT_HITS, page_buf))
goto err1;
- *page_size= _ma_get_page_used(info, page_buf);
+ *page_size= _ma_get_page_used(share, page_buf);
}
goto ok;
@@ -904,7 +911,7 @@ static int maria_rtree_delete_req(MARIA_HA *info, MARIA_KEYDEF *keyinfo,
PAGECACHE_LOCK_LEFT_WRITELOCKED,
DFLT_INIT_HITS, page_buf))
goto err1;
- *page_size= _ma_get_page_used(info, page_buf);
+ *page_size= _ma_get_page_used(share, page_buf);
res= 0;
goto ok;
}
@@ -925,7 +932,7 @@ static int maria_rtree_delete_req(MARIA_HA *info, MARIA_KEYDEF *keyinfo,
page_link->changed= 1;
maria_rtree_delete_key(info, page_buf, k, key_length, nod_flag);
- *page_size= _ma_get_page_used(info, page_buf);
+ *page_size= _ma_get_page_used(share, page_buf);
if (*page_size == info->s->keypage_header)
{
/* last key in the leaf */
@@ -967,6 +974,7 @@ err1:
int maria_rtree_delete(MARIA_HA *info, uint keynr, uchar *key, uint key_length)
{
+ MARIA_SHARE *share= info->s;
uint page_size;
stPageList ReinsertList;
my_off_t old_root;
@@ -974,7 +982,7 @@ int maria_rtree_delete(MARIA_HA *info, uint keynr, uchar *key, uint key_length)
MARIA_PINNED_PAGE *page_link, *root_page_link;
DBUG_ENTER("maria_rtree_delete");
- if ((old_root= info->s->state.key_root[keynr]) == HA_OFFSET_ERROR)
+ if ((old_root= share->state.key_root[keynr]) == HA_OFFSET_ERROR)
{
my_errno= HA_ERR_END_OF_FILE;
DBUG_RETURN(-1); /* purecov: inspected */
@@ -990,7 +998,7 @@ int maria_rtree_delete(MARIA_HA *info, uint keynr, uchar *key, uint key_length)
&page_size, &ReinsertList, 0)) {
case 2: /* empty */
{
- info->s->state.key_root[keynr]= HA_OFFSET_ERROR;
+ share->state.key_root[keynr]= HA_OFFSET_ERROR;
DBUG_RETURN(0);
}
case 0: /* deleted */
@@ -1010,15 +1018,15 @@ int maria_rtree_delete(MARIA_HA *info, uint keynr, uchar *key, uint key_length)
PAGECACHE_LOCK_WRITE,
DFLT_INIT_HITS, page_buf, 0, &page_link))
goto err1;
- nod_flag= _ma_test_if_nod(info, page_buf);
+ nod_flag= _ma_test_if_nod(share, page_buf);
DBUG_PRINT("rtree", ("reinserting keys from "
"page: %lu level: %d nod_flag: %u",
(ulong) ReinsertList.pages[i].offs,
ReinsertList.pages[i].level, nod_flag));
- k= rt_PAGE_FIRST_KEY(info, page_buf, nod_flag);
- last= rt_PAGE_END(info, page_buf);
- for (; k < last; k= rt_PAGE_NEXT_KEY(k, key_length, nod_flag))
+ k= rt_PAGE_FIRST_KEY(share, page_buf, nod_flag);
+ last= rt_PAGE_END(share, page_buf);
+ for (; k < last; k= rt_PAGE_NEXT_KEY(share, k, key_length, nod_flag))
{
int res;
if ((res=
@@ -1050,24 +1058,24 @@ int maria_rtree_delete(MARIA_HA *info, uint keynr, uchar *key, uint key_length)
my_free((uchar*) ReinsertList.pages, MYF(0));
/* check for redundant root (not leaf, 1 child) and eliminate */
- if ((old_root= info->s->state.key_root[keynr]) == HA_OFFSET_ERROR)
+ if ((old_root= share->state.key_root[keynr]) == HA_OFFSET_ERROR)
goto err1;
if (!_ma_fetch_keypage(info, keyinfo, old_root,
PAGECACHE_LOCK_WRITE,
DFLT_INIT_HITS, info->buff, 0, &root_page_link))
goto err1;
- nod_flag= _ma_test_if_nod(info, info->buff);
- page_size= _ma_get_page_used(info, info->buff);
- if (nod_flag && (page_size == info->s->keypage_header + key_length +
+ nod_flag= _ma_test_if_nod(share, info->buff);
+ page_size= _ma_get_page_used(share, info->buff);
+ if (nod_flag && (page_size == share->keypage_header + key_length +
nod_flag))
{
my_off_t new_root= _ma_kpos(nod_flag,
- rt_PAGE_FIRST_KEY(info, info->buff,
+ rt_PAGE_FIRST_KEY(share, info->buff,
nod_flag));
root_page_link->changed= 1;
if (_ma_dispose(info, old_root, 0))
goto err1;
- info->s->state.key_root[keynr]= new_root;
+ share->state.key_root[keynr]= new_root;
}
info->update= HA_STATE_DELETED;
DBUG_RETURN(0);
@@ -1097,7 +1105,8 @@ err1:
ha_rows maria_rtree_estimate(MARIA_HA *info, uint keynr, uchar *key,
uint key_length, uint flag)
{
- MARIA_KEYDEF *keyinfo= info->s->keyinfo + keynr;
+ MARIA_SHARE *share= info->s;
+ MARIA_KEYDEF *keyinfo= share->keyinfo + keynr;
my_off_t root;
uint i= 0;
uint nod_flag, k_len;
@@ -1108,21 +1117,21 @@ ha_rows maria_rtree_estimate(MARIA_HA *info, uint keynr, uchar *key,
if (flag & MBR_DISJOINT)
return info->state->records;
- if ((root= info->s->state.key_root[keynr]) == HA_OFFSET_ERROR)
+ if ((root= share->state.key_root[keynr]) == HA_OFFSET_ERROR)
return HA_POS_ERROR;
if (!(page_buf= (uchar*) my_alloca((uint)keyinfo->block_length)))
return HA_POS_ERROR;
if (!_ma_fetch_keypage(info, keyinfo, root, PAGECACHE_LOCK_LEFT_UNLOCKED,
DFLT_INIT_HITS, page_buf, 0, 0))
goto err1;
- nod_flag= _ma_test_if_nod(info, page_buf);
+ nod_flag= _ma_test_if_nod(share, page_buf);
- k_len= keyinfo->keylength - info->s->base.rec_reflength;
+ k_len= keyinfo->keylength - share->base.rec_reflength;
- k= rt_PAGE_FIRST_KEY(info, page_buf, nod_flag);
- last= rt_PAGE_END(info, page_buf);
+ k= rt_PAGE_FIRST_KEY(share, page_buf, nod_flag);
+ last= rt_PAGE_END(share, page_buf);
- for (; k < last; k= rt_PAGE_NEXT_KEY(k, k_len, nod_flag), i++)
+ for (; k < last; k= rt_PAGE_NEXT_KEY(share, k, k_len, nod_flag), i++)
{
if (nod_flag)
{
diff --git a/storage/maria/ma_rt_index.h b/storage/maria/ma_rt_index.h
index af2fcabaa44..999b41bc805 100644
--- a/storage/maria/ma_rt_index.h
+++ b/storage/maria/ma_rt_index.h
@@ -19,10 +19,10 @@
#ifdef HAVE_RTREE_KEYS
-#define rt_PAGE_FIRST_KEY(info, page, nod_flag) (page + info->s->keypage_header + 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(info, page) (page + _ma_get_page_used(info, page))
+#define rt_PAGE_FIRST_KEY(share, page, nod_flag) (page + share->keypage_header + nod_flag)
+#define rt_PAGE_NEXT_KEY(share, key, key_length, nod_flag) (key + key_length +\
+ (nod_flag ? nod_flag : share->base.rec_reflength))
+#define rt_PAGE_END(share, page) (page + _ma_get_page_used(share, page))
#define rt_PAGE_MIN_SIZE(block_length) ((uint)(block_length - KEYPAGE_CHECKSUM_SIZE) / 3)
diff --git a/storage/maria/ma_rt_key.c b/storage/maria/ma_rt_key.c
index a976c252a93..a7b43406d4f 100644
--- a/storage/maria/ma_rt_key.c
+++ b/storage/maria/ma_rt_key.c
@@ -32,11 +32,12 @@
int maria_rtree_add_key(MARIA_HA *info, MARIA_KEYDEF *keyinfo, uchar *key,
uint key_length, uchar *page_buf, my_off_t *new_page)
{
- uint page_size= _ma_get_page_used(info, page_buf);
- uint nod_flag= _ma_test_if_nod(info, page_buf);
+ MARIA_SHARE *share= info->s;
+ uint page_size= _ma_get_page_used(share, page_buf);
+ uint nod_flag= _ma_test_if_nod(share, page_buf);
DBUG_ENTER("maria_rtree_add_key");
- if (page_size + key_length + info->s->base.rec_reflength <=
+ if (page_size + key_length + share->base.rec_reflength <=
keyinfo->block_length)
{
/* split won't be necessary */
@@ -44,7 +45,7 @@ int maria_rtree_add_key(MARIA_HA *info, MARIA_KEYDEF *keyinfo, uchar *key,
{
/* save key */
DBUG_ASSERT(_ma_kpos(nod_flag, key) < info->state->key_file_length);
- memcpy(rt_PAGE_END(info, page_buf), key - nod_flag,
+ memcpy(rt_PAGE_END(share, page_buf), key - nod_flag,
key_length + nod_flag);
page_size+= key_length + nod_flag;
}
@@ -52,14 +53,14 @@ int maria_rtree_add_key(MARIA_HA *info, MARIA_KEYDEF *keyinfo, uchar *key,
{
/* save key */
DBUG_ASSERT(_ma_dpos(info, nod_flag, key + key_length +
- info->s->base.rec_reflength) <
+ share->base.rec_reflength) <
info->state->data_file_length +
- info->s->base.pack_reclength);
- memcpy(rt_PAGE_END(info, page_buf), key, key_length +
- info->s->base.rec_reflength);
- page_size+= key_length + info->s->base.rec_reflength;
+ share->base.pack_reclength);
+ memcpy(rt_PAGE_END(share, page_buf), key, key_length +
+ share->base.rec_reflength);
+ page_size+= key_length + share->base.rec_reflength;
}
- _ma_store_page_used(info, page_buf, page_size);
+ _ma_store_page_used(share, page_buf, page_size);
DBUG_RETURN(0);
}
@@ -75,18 +76,19 @@ int maria_rtree_add_key(MARIA_HA *info, MARIA_KEYDEF *keyinfo, uchar *key,
int maria_rtree_delete_key(MARIA_HA *info, uchar *page_buf, uchar *key,
uint key_length, uint nod_flag)
{
- uint16 page_size= _ma_get_page_used(info, page_buf);
+ MARIA_SHARE *share= info->s;
+ uint16 page_size= _ma_get_page_used(share, page_buf);
uchar *key_start;
key_start= key - nod_flag;
if (!nod_flag)
- key_length+= info->s->base.rec_reflength;
+ key_length+= share->base.rec_reflength;
memmove(key_start, key + key_length, page_size - key_length -
(key - page_buf));
page_size-= key_length + nod_flag;
- _ma_store_page_used(info, page_buf, page_size);
+ _ma_store_page_used(share, page_buf, page_size);
return 0;
}
diff --git a/storage/maria/ma_rt_mbr.c b/storage/maria/ma_rt_mbr.c
index 4f17ce6d074..dbde616401a 100644
--- a/storage/maria/ma_rt_mbr.c
+++ b/storage/maria/ma_rt_mbr.c
@@ -687,13 +687,13 @@ double maria_rtree_perimeter_increase(HA_KEYSEG *keyseg, uchar* a, uchar* b,
}
-#define RT_PAGE_MBR_KORR(type, korr_func, store_func, len) \
+#define RT_PAGE_MBR_KORR(share, type, korr_func, store_func, len) \
{ \
type amin, amax, bmin, bmax; \
amin= korr_func(k + inc); \
amax= korr_func(k + inc + len); \
- k= rt_PAGE_NEXT_KEY(k, k_len, nod_flag); \
- for (; k < last; k= rt_PAGE_NEXT_KEY(k, k_len, nod_flag)) \
+ k= rt_PAGE_NEXT_KEY(share, k, k_len, nod_flag); \
+ for (; k < last; k= rt_PAGE_NEXT_KEY(share, k, k_len, nod_flag)) \
{ \
bmin= korr_func(k + inc); \
bmax= korr_func(k + inc + len); \
@@ -709,13 +709,13 @@ double maria_rtree_perimeter_increase(HA_KEYSEG *keyseg, uchar* a, uchar* b,
inc += 2 * len; \
}
-#define RT_PAGE_MBR_GET(type, get_func, store_func, len) \
+#define RT_PAGE_MBR_GET(share, type, get_func, store_func, len) \
{ \
type amin, amax, bmin, bmax; \
get_func(amin, k + inc); \
get_func(amax, k + inc + len); \
- k= rt_PAGE_NEXT_KEY(k, k_len, nod_flag); \
- for (; k < last; k= rt_PAGE_NEXT_KEY(k, k_len, nod_flag)) \
+ k= rt_PAGE_NEXT_KEY(share, k, k_len, nod_flag); \
+ for (; k < last; k= rt_PAGE_NEXT_KEY(share, k, k_len, nod_flag)) \
{ \
get_func(bmin, k + inc); \
get_func(bmax, k + inc + len); \
@@ -737,11 +737,12 @@ double maria_rtree_perimeter_increase(HA_KEYSEG *keyseg, uchar* a, uchar* b,
int maria_rtree_page_mbr(MARIA_HA *info, HA_KEYSEG *keyseg, uchar *page_buf,
uchar *c, uint key_length)
{
+ MARIA_SHARE *share= info->s;
uint inc= 0;
uint k_len= key_length;
- uint nod_flag= _ma_test_if_nod(info, page_buf);
+ uint nod_flag= _ma_test_if_nod(share, page_buf);
uchar *k;
- uchar *last= rt_PAGE_END(info, page_buf);
+ uchar *last= rt_PAGE_END(share, page_buf);
for (; (int)key_length > 0; keyseg += 2)
{
@@ -753,46 +754,46 @@ int maria_rtree_page_mbr(MARIA_HA *info, HA_KEYSEG *keyseg, uchar *page_buf,
return 1;
}
- k= rt_PAGE_FIRST_KEY(info, page_buf, nod_flag);
+ k= rt_PAGE_FIRST_KEY(share, page_buf, nod_flag);
switch ((enum ha_base_keytype) keyseg->type) {
case HA_KEYTYPE_INT8:
- RT_PAGE_MBR_KORR(int8, mi_sint1korr, mi_int1store, 1);
+ RT_PAGE_MBR_KORR(share, int8, mi_sint1korr, mi_int1store, 1);
break;
case HA_KEYTYPE_BINARY:
- RT_PAGE_MBR_KORR(uint8, mi_uint1korr, mi_int1store, 1);
+ RT_PAGE_MBR_KORR(share, uint8, mi_uint1korr, mi_int1store, 1);
break;
case HA_KEYTYPE_SHORT_INT:
- RT_PAGE_MBR_KORR(int16, mi_sint2korr, mi_int2store, 2);
+ RT_PAGE_MBR_KORR(share, int16, mi_sint2korr, mi_int2store, 2);
break;
case HA_KEYTYPE_USHORT_INT:
- RT_PAGE_MBR_KORR(uint16, mi_uint2korr, mi_int2store, 2);
+ RT_PAGE_MBR_KORR(share, uint16, mi_uint2korr, mi_int2store, 2);
break;
case HA_KEYTYPE_INT24:
- RT_PAGE_MBR_KORR(int32, mi_sint3korr, mi_int3store, 3);
+ RT_PAGE_MBR_KORR(share, int32, mi_sint3korr, mi_int3store, 3);
break;
case HA_KEYTYPE_UINT24:
- RT_PAGE_MBR_KORR(uint32, mi_uint3korr, mi_int3store, 3);
+ RT_PAGE_MBR_KORR(share, uint32, mi_uint3korr, mi_int3store, 3);
break;
case HA_KEYTYPE_LONG_INT:
- RT_PAGE_MBR_KORR(int32, mi_sint4korr, mi_int4store, 4);
+ RT_PAGE_MBR_KORR(share, int32, mi_sint4korr, mi_int4store, 4);
break;
case HA_KEYTYPE_ULONG_INT:
- RT_PAGE_MBR_KORR(uint32, mi_uint4korr, mi_int4store, 4);
+ RT_PAGE_MBR_KORR(share, uint32, mi_uint4korr, mi_int4store, 4);
break;
#ifdef HAVE_LONG_LONG
case HA_KEYTYPE_LONGLONG:
- RT_PAGE_MBR_KORR(longlong, mi_sint8korr, mi_int8store, 8);
+ RT_PAGE_MBR_KORR(share, longlong, mi_sint8korr, mi_int8store, 8);
break;
case HA_KEYTYPE_ULONGLONG:
- RT_PAGE_MBR_KORR(ulonglong, mi_uint8korr, mi_int8store, 8);
+ RT_PAGE_MBR_KORR(share, ulonglong, mi_uint8korr, mi_int8store, 8);
break;
#endif
case HA_KEYTYPE_FLOAT:
- RT_PAGE_MBR_GET(float, mi_float4get, mi_float4store, 4);
+ RT_PAGE_MBR_GET(share, float, mi_float4get, mi_float4store, 4);
break;
case HA_KEYTYPE_DOUBLE:
- RT_PAGE_MBR_GET(double, mi_float8get, mi_float8store, 8);
+ RT_PAGE_MBR_GET(share, double, mi_float8get, mi_float8store, 8);
break;
case HA_KEYTYPE_END:
return 0;
diff --git a/storage/maria/ma_rt_split.c b/storage/maria/ma_rt_split.c
index b9583241366..c6228cd65f3 100644
--- a/storage/maria/ma_rt_split.c
+++ b/storage/maria/ma_rt_split.c
@@ -251,6 +251,7 @@ int maria_rtree_split_page(MARIA_HA *info, MARIA_KEYDEF *keyinfo,
uchar *page, uchar *key,
uint key_length, my_off_t *new_page_offs)
{
+ MARIA_SHARE *share= info->s;
int n1, n2; /* Number of items in groups */
SplitStruct *task;
SplitStruct *cur;
@@ -262,10 +263,10 @@ int maria_rtree_split_page(MARIA_HA *info, MARIA_KEYDEF *keyinfo,
uchar *source_cur, *cur1, *cur2;
uchar *new_page;
int err_code= 0;
- uint nod_flag= _ma_test_if_nod(info, page);
+ uint nod_flag= _ma_test_if_nod(share, page);
uint full_length= key_length + (nod_flag ? nod_flag :
- info->s->base.rec_reflength);
- int max_keys= ((_ma_get_page_used(info, page) - info->s->keypage_header) /
+ share->base.rec_reflength);
+ int max_keys= ((_ma_get_page_used(share, page) - share->keypage_header) /
(full_length));
MARIA_PINNED_PAGE tmp_page_link, *page_link= &tmp_page_link;
DBUG_ENTER("maria_rtree_split_page");
@@ -283,10 +284,12 @@ int maria_rtree_split_page(MARIA_HA *info, MARIA_KEYDEF *keyinfo,
next_coord= coord_buf;
stop= task + max_keys;
- source_cur= rt_PAGE_FIRST_KEY(info, page, nod_flag);
+ source_cur= rt_PAGE_FIRST_KEY(share, page, nod_flag);
- for (cur= task; cur < stop; cur++, source_cur= rt_PAGE_NEXT_KEY(source_cur,
- key_length, nod_flag))
+ for (cur= task;
+ cur < stop;
+ cur++, source_cur= rt_PAGE_NEXT_KEY(share, source_cur, key_length,
+ nod_flag))
{
cur->coords= reserve_coords(&next_coord, n_dim);
cur->key= source_cur;
@@ -300,7 +303,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,
- _ma_get_page_used(info, page) + full_length + 2,
+ _ma_get_page_used(share, page) + full_length + 2,
full_length,
rt_PAGE_MIN_SIZE(keyinfo->block_length),
2, 2, &next_coord, n_dim))
@@ -316,8 +319,8 @@ int maria_rtree_split_page(MARIA_HA *info, MARIA_KEYDEF *keyinfo,
}
stop= task + (max_keys + 1);
- cur1= rt_PAGE_FIRST_KEY(info, page, nod_flag);
- cur2= rt_PAGE_FIRST_KEY(info, new_page, nod_flag);
+ cur1= rt_PAGE_FIRST_KEY(share, page, nod_flag);
+ cur2= rt_PAGE_FIRST_KEY(share, new_page, nod_flag);
n1= n2= 0;
for (cur= task; cur < stop; cur++)
@@ -326,25 +329,25 @@ int maria_rtree_split_page(MARIA_HA *info, MARIA_KEYDEF *keyinfo,
if (cur->n_node == 1)
{
to= cur1;
- cur1= rt_PAGE_NEXT_KEY(cur1, key_length, nod_flag);
+ cur1= rt_PAGE_NEXT_KEY(share, cur1, key_length, nod_flag);
n1++;
}
else
{
to= cur2;
- cur2= rt_PAGE_NEXT_KEY(cur2, key_length, nod_flag);
+ cur2= rt_PAGE_NEXT_KEY(share, cur2, key_length, nod_flag);
n2++;
}
if (to != cur->key)
memcpy(to - nod_flag, cur->key - nod_flag, full_length);
}
- bzero(new_page, info->s->keypage_header);
+ bzero(new_page, share->keypage_header);
if (nod_flag)
- _ma_store_keypage_flag(info, new_page, KEYPAGE_FLAG_ISNOD);
- _ma_store_keynr(info, new_page, keyinfo->key_nr);
- _ma_store_page_used(info, page, info->s->keypage_header + n1 * full_length)
- _ma_store_page_used(info, new_page, info->s->keypage_header +
+ _ma_store_keypage_flag(share, new_page, KEYPAGE_FLAG_ISNOD);
+ _ma_store_keynr(share, new_page, keyinfo->key_nr);
+ _ma_store_page_used(share, page, share->keypage_header + n1 * full_length)
+ _ma_store_page_used(share, new_page, share->keypage_header +
n2 * full_length);
if ((*new_page_offs= _ma_new(info, DFLT_INIT_HITS, &page_link)) ==
diff --git a/storage/maria/ma_search.c b/storage/maria/ma_search.c
index 78e787eae4d..a76e9dfd63d 100644
--- a/storage/maria/ma_search.c
+++ b/storage/maria/ma_search.c
@@ -84,13 +84,13 @@ int _ma_search(register MARIA_HA *info, register MARIA_KEYDEF *keyinfo,
DFLT_INIT_HITS, info->keyread_buff,
test(!(nextflag & SEARCH_SAVE_BUFF)), 0)))
goto err;
- DBUG_DUMP("page", buff, _ma_get_page_used(info, buff));
+ DBUG_DUMP("page", buff, _ma_get_page_used(info->s, 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);
- _ma_get_used_and_nod(info, buff, used_length, nod_flag);
+ _ma_get_used_and_nod(info->s, buff, used_length, nod_flag);
maxpos= buff + used_length -1;
if (flag)
@@ -189,18 +189,21 @@ int _ma_bin_search(MARIA_HA *info, register MARIA_KEYDEF *keyinfo,
int flag;
uint start, mid, end, save_end, totlength, nod_flag, used_length;
uint not_used[2];
+ MARIA_SHARE *share= info->s;
DBUG_ENTER("_ma_bin_search");
LINT_INIT(flag);
- _ma_get_used_and_nod(info, page, used_length, nod_flag);
+ _ma_get_used_and_nod(share, page, used_length, nod_flag);
totlength= keyinfo->keylength + nod_flag;
+ DBUG_ASSERT(used_length >= share->keypage_header + nod_flag + totlength);
+
start=0;
mid=1;
- save_end= end= ((used_length - nod_flag - info->s->keypage_header) /
+ save_end= end= ((used_length - nod_flag - share->keypage_header) /
totlength-1);
DBUG_PRINT("test",("page_length: %u end: %u", used_length, end));
- page+= info->s->keypage_header + nod_flag;
+ page+= share->keypage_header + nod_flag;
while (start != end)
{
@@ -255,6 +258,7 @@ int _ma_seq_search(MARIA_HA *info, register MARIA_KEYDEF *keyinfo,
uint comp_flag, uchar **ret_pos,
uchar *buff, my_bool *last_key)
{
+ MARIA_SHARE *share= info->s;
int flag;
uint nod_flag, length, used_length, not_used[2];
uchar t_buff[HA_MAX_KEY_BUFF], *end;
@@ -263,9 +267,9 @@ int _ma_seq_search(MARIA_HA *info, register MARIA_KEYDEF *keyinfo,
LINT_INIT(flag);
LINT_INIT(length);
- _ma_get_used_and_nod(info, page, used_length, nod_flag);
+ _ma_get_used_and_nod(share, page, used_length, nod_flag);
end= page + used_length;
- page+= info->s->keypage_header + nod_flag;
+ page+= share->keypage_header + nod_flag;
*ret_pos= (uchar*) page;
t_buff[0]=0; /* Avoid bugs */
while (page < end)
@@ -273,7 +277,7 @@ int _ma_seq_search(MARIA_HA *info, register MARIA_KEYDEF *keyinfo,
length=(*keyinfo->get_key)(keyinfo,nod_flag,&page,t_buff);
if (length == 0 || page > end)
{
- maria_print_error(info->s, HA_ERR_CRASHED);
+ maria_print_error(share, HA_ERR_CRASHED);
my_errno=HA_ERR_CRASHED;
DBUG_PRINT("error",
("Found wrong key: length: %u page: 0x%lx end: 0x%lx",
@@ -303,6 +307,7 @@ int _ma_prefix_search(MARIA_HA *info, register MARIA_KEYDEF *keyinfo,
uint nextflag, uchar **ret_pos, uchar *buff,
my_bool *last_key)
{
+ MARIA_SHARE *share= info->s;
/*
my_flag is raw comparison result to be changed according to
SEARCH_NO_FIND,SEARCH_LAST and HA_REVERSE_SORT flags.
@@ -330,9 +335,9 @@ int _ma_prefix_search(MARIA_HA *info, register MARIA_KEYDEF *keyinfo,
LINT_INIT(saved_vseg);
t_buff[0]=0; /* Avoid bugs */
- _ma_get_used_and_nod(info, page, used_length, nod_flag);
+ _ma_get_used_and_nod(share, page, used_length, nod_flag);
end= page + used_length;
- page+= info->s->keypage_header + nod_flag;
+ page+= share->keypage_header + nod_flag;
*ret_pos= page;
kseg= key;
@@ -434,7 +439,7 @@ int _ma_prefix_search(MARIA_HA *info, register MARIA_KEYDEF *keyinfo,
if (page > end)
{
- maria_print_error(info->s, HA_ERR_CRASHED);
+ maria_print_error(share, HA_ERR_CRASHED);
my_errno=HA_ERR_CRASHED;
DBUG_PRINT("error",
("Found wrong key: length: %u page: 0x%lx end: %lx",
@@ -1112,7 +1117,7 @@ uchar *_ma_get_key(MARIA_HA *info, MARIA_KEYDEF *keyinfo, uchar *page,
uint nod_flag;
DBUG_ENTER("_ma_get_key");
- nod_flag=_ma_test_if_nod(info, page);
+ nod_flag=_ma_test_if_nod(info->s, page);
if (! (keyinfo->flag & (HA_VAR_LENGTH_KEY | HA_BINARY_PACK_KEY)))
{
bmove((uchar*) key,(uchar*) keypos,keyinfo->keylength+nod_flag);
@@ -1154,7 +1159,7 @@ static my_bool _ma_get_prev_key(MARIA_HA *info, MARIA_KEYDEF *keyinfo,
uint nod_flag;
DBUG_ENTER("_ma_get_prev_key");
- nod_flag=_ma_test_if_nod(info, page);
+ nod_flag=_ma_test_if_nod(info->s, page);
if (! (keyinfo->flag & (HA_VAR_LENGTH_KEY | HA_BINARY_PACK_KEY)))
{
*return_key_length=keyinfo->keylength;
@@ -1200,7 +1205,7 @@ uchar *_ma_get_last_key(MARIA_HA *info, MARIA_KEYDEF *keyinfo, uchar *page,
DBUG_PRINT("enter",("page: 0x%lx endpos: 0x%lx", (long) page,
(long) endpos));
- nod_flag=_ma_test_if_nod(info, page);
+ nod_flag= _ma_test_if_nod(info->s, page);
if (! (keyinfo->flag & (HA_VAR_LENGTH_KEY | HA_BINARY_PACK_KEY)))
{
lastpos=endpos-keyinfo->keylength-nod_flag;
@@ -1348,7 +1353,7 @@ int _ma_search_next(register MARIA_HA *info, register MARIA_KEYDEF *keyinfo,
}
/* Last used buffer is in info->keyread_buff */
- nod_flag=_ma_test_if_nod(info, info->keyread_buff);
+ nod_flag= _ma_test_if_nod(info->s, info->keyread_buff);
if (nextflag & SEARCH_BIGGER) /* Next key */
{
@@ -1400,6 +1405,7 @@ int _ma_search_first(register MARIA_HA *info, register MARIA_KEYDEF *keyinfo,
{
uint nod_flag;
uchar *page;
+ MARIA_SHARE *share= info->s;
DBUG_ENTER("_ma_search_first");
if (pos == HA_OFFSET_ERROR)
@@ -1417,8 +1423,8 @@ int _ma_search_first(register MARIA_HA *info, register MARIA_KEYDEF *keyinfo,
info->cur_row.lastpos= HA_OFFSET_ERROR;
DBUG_RETURN(-1);
}
- nod_flag=_ma_test_if_nod(info, info->keyread_buff);
- page= info->keyread_buff + info->s->keypage_header + nod_flag;
+ nod_flag=_ma_test_if_nod(share, info->keyread_buff);
+ page= info->keyread_buff + share->keypage_header + nod_flag;
} while ((pos= _ma_kpos(nod_flag,page)) != HA_OFFSET_ERROR);
if (!(info->lastkey_length=(*keyinfo->get_key)(keyinfo,nod_flag,&page,
@@ -1427,7 +1433,7 @@ int _ma_search_first(register MARIA_HA *info, register MARIA_KEYDEF *keyinfo,
info->int_keypos=page;
info->int_maxpos= (info->keyread_buff +
- _ma_get_page_used(info, info->keyread_buff)-1);
+ _ma_get_page_used(share, info->keyread_buff)-1);
info->int_nod_flag=nod_flag;
info->int_keytree_version=keyinfo->version;
info->last_search_keypage=info->last_keypage;
@@ -1466,7 +1472,7 @@ int _ma_search_last(register MARIA_HA *info, register MARIA_KEYDEF *keyinfo,
info->cur_row.lastpos= HA_OFFSET_ERROR;
DBUG_RETURN(-1);
}
- _ma_get_used_and_nod(info, buff, used_length, nod_flag);
+ _ma_get_used_and_nod(info->s, buff, used_length, nod_flag);
end_of_page= buff + used_length;
} while ((pos= _ma_kpos(nod_flag, end_of_page)) != HA_OFFSET_ERROR);
diff --git a/storage/maria/ma_sort.c b/storage/maria/ma_sort.c
index 69a95db2e09..874d6fcd6e0 100644
--- a/storage/maria/ma_sort.c
+++ b/storage/maria/ma_sort.c
@@ -499,7 +499,7 @@ int _ma_thr_write_keys(MARIA_SORT_PARAM *sort_param)
int got_error=sort_info->got_error;
uint i;
MARIA_HA *info=sort_info->info;
- MARIA_SHARE *share=info->s;
+ MARIA_SHARE *share= info->s;
MARIA_SORT_PARAM *sinfo;
uchar *mergebuf=0;
DBUG_ENTER("_ma_thr_write_keys");
diff --git a/storage/maria/ma_statrec.c b/storage/maria/ma_statrec.c
index b0422f067f5..b189bce67da 100644
--- a/storage/maria/ma_statrec.c
+++ b/storage/maria/ma_statrec.c
@@ -208,7 +208,7 @@ int _ma_read_rnd_static_record(MARIA_HA *info, uchar *buf,
{
int locked,error,cache_read;
uint cache_length;
- MARIA_SHARE *share=info->s;
+ MARIA_SHARE *share= info->s;
DBUG_ENTER("_ma_read_rnd_static_record");
cache_read=0;
diff --git a/storage/maria/ma_test1.c b/storage/maria/ma_test1.c
index 5c362723fa8..e8eba720449 100644
--- a/storage/maria/ma_test1.c
+++ b/storage/maria/ma_test1.c
@@ -452,8 +452,8 @@ end:
Flush changed pages go to disk. That will also flush log. Recovery
will skip REDOs and apply UNDOs.
*/
- _ma_flush_table_files(file, MARIA_FLUSH_DATA, FLUSH_RELEASE,
- FLUSH_RELEASE);
+ _ma_flush_table_files(file, MARIA_FLUSH_DATA | MARIA_FLUSH_INDEX,
+ FLUSH_RELEASE, FLUSH_RELEASE);
break;
case 2:
/*
@@ -469,6 +469,20 @@ end:
will then do nothing.
*/
break;
+ case 4:
+ /*
+ Flush changed data pages go to disk. Changed index pages are not
+ flushed. Recovery will skip some REDOs and apply UNDOs.
+ */
+ _ma_flush_table_files(file, MARIA_FLUSH_DATA, FLUSH_RELEASE,
+ FLUSH_RELEASE);
+ /*
+ We have to flush log separately as the redo for the last key page
+ may not be flushed
+ */
+ if (translog_flush(file->trn->undo_lsn))
+ goto err;
+ break;
}
printf("Dying on request without maria_commit()/maria_close()\n");
exit(0);
diff --git a/storage/maria/ma_test2.c b/storage/maria/ma_test2.c
index 60c6a3be8b4..8f73372cb97 100644
--- a/storage/maria/ma_test2.c
+++ b/storage/maria/ma_test2.c
@@ -901,11 +901,11 @@ end:
switch (die_in_middle_of_transaction) {
case 1:
/*
- Flush changed pages go to disk. That will also flush log. Recovery
- will skip REDOs and apply UNDOs.
+ Flush changed data and index pages go to disk
+ That will also flush log. Recovery will skip REDOs and apply UNDOs.
*/
- _ma_flush_table_files(file, MARIA_FLUSH_DATA, FLUSH_RELEASE,
- FLUSH_RELEASE);
+ _ma_flush_table_files(file, MARIA_FLUSH_DATA | MARIA_FLUSH_INDEX,
+ FLUSH_RELEASE, FLUSH_RELEASE);
break;
case 2:
/*
@@ -921,6 +921,20 @@ end:
will then do nothing.
*/
break;
+ case 4:
+ /*
+ Flush changed data pages go to disk. Changed index pages are not
+ flushed. Recovery will skip some REDOs and apply UNDOs.
+ */
+ _ma_flush_table_files(file, MARIA_FLUSH_DATA, FLUSH_RELEASE,
+ FLUSH_RELEASE);
+ /*
+ We have to flush log separately as the redo for the last key page
+ may not be flushed
+ */
+ if (translog_flush(file->trn->undo_lsn))
+ goto err;
+ break;
}
printf("Dying on request without maria_commit()/maria_close()\n");
exit(0);
diff --git a/storage/maria/ma_test_recovery b/storage/maria/ma_test_recovery
index 87b343e9301..38972b66764 100755
--- a/storage/maria/ma_test_recovery
+++ b/storage/maria/ma_test_recovery
@@ -1,5 +1,6 @@
#!/bin/sh
+#set -x -v
set -e
silent="-s"
if [ -z "$maria_path" ]
@@ -121,7 +122,7 @@ for take_checkpoint in "no" "yes"
do
for blobs in "" "-b" # we test table without blobs and then table with blobs
do
- for test_undo in 1 2 3
+ for test_undo in 1 2 3 4
do
# first iteration tests rollback of insert, second tests rollback of delete
set -- "ma_test1 $silent -M -T -c -N $blobs -H1" "--testflag=1" "--testflag=2 --test-undo=" "ma_test1 $silent -M -T -c -N $blobs -H2" "--testflag=3" "--testflag=4 --test-undo=" "ma_test1 $silent -M -T -c -N $blobs -H2 " "--testflag=2" "--testflag=3 --test-undo=" "ma_test2 $silent -L -K -W -P -M -T -c $blobs -H1" "-t1" "-t2 -u"
@@ -154,7 +155,7 @@ do
rm -f $tmp/maria_log.* $tmp/maria_log_control
cp $maria_path/maria_log* $tmp
- if [ $test_undo -lt 3 ]
+ if [ "$test_undo" != "3" ]
then
apply_log "shouldchangelog" # should undo aborted work
else
diff --git a/storage/maria/ma_test_recovery.expected b/storage/maria/ma_test_recovery.expected
index 4c853476a28..56f545b983a 100644
--- a/storage/maria/ma_test_recovery.expected
+++ b/storage/maria/ma_test_recovery.expected
@@ -222,6 +222,76 @@ Differences in maria_chk -dvv, recovery not yet perfect !
---
> Datafile length: 114688 Keyfile length: 204800
========DIFF END=======
+TEST WITH ma_test1 -s -M -T -c -N --testflag=1 (commit at end)
+TEST WITH ma_test1 -s -M -T -c -N --testflag=2 --test-undo=4 (additional aborted work)
+Terminating after inserts
+Dying on request without maria_commit()/maria_close()
+applying log
+testing idempotency
+applying log
+testing applying of CLRs to recreate table
+applying log
+TEST WITH ma_test1 -s -M -T -c -N --testflag=3 (commit at end)
+Terminating after updates
+TEST WITH ma_test1 -s -M -T -c -N --testflag=4 --test-undo=4 (additional aborted work)
+Terminating after deletes
+Dying on request without maria_commit()/maria_close()
+applying log
+testing idempotency
+applying log
+testing applying of CLRs to recreate table
+applying log
+TEST WITH ma_test1 -s -M -T -c -N --testflag=2 (commit at end)
+Terminating after inserts
+TEST WITH ma_test1 -s -M -T -c -N --testflag=3 --test-undo=4 (additional aborted work)
+Terminating after updates
+Dying on request without maria_commit()/maria_close()
+applying log
+testing idempotency
+applying log
+testing applying of CLRs to recreate table
+applying log
+TEST WITH ma_test2 -s -L -K -W -P -M -T -c -t1 (commit at end)
+TEST WITH ma_test2 -s -L -K -W -P -M -T -c -t2 -u4 (additional aborted work)
+Dying on request without maria_commit()/maria_close()
+applying log
+Differences in maria_chk -dvv, recovery not yet perfect !
+========DIFF START=======
+6c6
+< Status: checked,analyzed,optimized keys,sorted index pages
+---
+> Status: changed
+11c11
+< Datafile length: 8192 Keyfile length: 8192
+---
+> Datafile length: 114688 Keyfile length: 204800
+========DIFF END=======
+testing idempotency
+applying log
+Differences in maria_chk -dvv, recovery not yet perfect !
+========DIFF START=======
+6c6
+< Status: checked,analyzed,optimized keys,sorted index pages
+---
+> Status: changed
+11c11
+< Datafile length: 8192 Keyfile length: 8192
+---
+> Datafile length: 114688 Keyfile length: 204800
+========DIFF END=======
+testing applying of CLRs to recreate table
+applying log
+Differences in maria_chk -dvv, recovery not yet perfect !
+========DIFF START=======
+6c6
+< Status: checked,analyzed,optimized keys,sorted index pages
+---
+> Status: changed
+11c11
+< Datafile length: 8192 Keyfile length: 8192
+---
+> Datafile length: 114688 Keyfile length: 204800
+========DIFF END=======
TEST WITH ma_test1 -s -M -T -c -N -b --testflag=1 (commit at end)
TEST WITH ma_test1 -s -M -T -c -N -b --testflag=2 --test-undo=1 (additional aborted work)
Terminating after inserts
@@ -404,7 +474,77 @@ Differences in maria_chk -dvv, recovery not yet perfect !
11c11
< Datafile length: 8192 Keyfile length: 8192
---
-> Datafile length: 122880 Keyfile length: 212992
+> Datafile length: 147456 Keyfile length: 212992
+========DIFF END=======
+testing idempotency
+applying log
+Differences in maria_chk -dvv, recovery not yet perfect !
+========DIFF START=======
+6c6
+< Status: checked,analyzed,optimized keys,sorted index pages
+---
+> Status: changed
+11c11
+< Datafile length: 8192 Keyfile length: 8192
+---
+> Datafile length: 147456 Keyfile length: 212992
+========DIFF END=======
+testing applying of CLRs to recreate table
+applying log
+Differences in maria_chk -dvv, recovery not yet perfect !
+========DIFF START=======
+6c6
+< Status: checked,analyzed,optimized keys,sorted index pages
+---
+> Status: changed
+11c11
+< Datafile length: 8192 Keyfile length: 8192
+---
+> Datafile length: 147456 Keyfile length: 212992
+========DIFF END=======
+TEST WITH ma_test1 -s -M -T -c -N -b --testflag=1 (commit at end)
+TEST WITH ma_test1 -s -M -T -c -N -b --testflag=2 --test-undo=4 (additional aborted work)
+Terminating after inserts
+Dying on request without maria_commit()/maria_close()
+applying log
+testing idempotency
+applying log
+testing applying of CLRs to recreate table
+applying log
+TEST WITH ma_test1 -s -M -T -c -N -b --testflag=3 (commit at end)
+Terminating after updates
+TEST WITH ma_test1 -s -M -T -c -N -b --testflag=4 --test-undo=4 (additional aborted work)
+Terminating after deletes
+Dying on request without maria_commit()/maria_close()
+applying log
+testing idempotency
+applying log
+testing applying of CLRs to recreate table
+applying log
+TEST WITH ma_test1 -s -M -T -c -N -b --testflag=2 (commit at end)
+Terminating after inserts
+TEST WITH ma_test1 -s -M -T -c -N -b --testflag=3 --test-undo=4 (additional aborted work)
+Terminating after updates
+Dying on request without maria_commit()/maria_close()
+applying log
+testing idempotency
+applying log
+testing applying of CLRs to recreate table
+applying log
+TEST WITH ma_test2 -s -L -K -W -P -M -T -c -b -t1 (commit at end)
+TEST WITH ma_test2 -s -L -K -W -P -M -T -c -b -t2 -u4 (additional aborted work)
+Dying on request without maria_commit()/maria_close()
+applying log
+Differences in maria_chk -dvv, recovery not yet perfect !
+========DIFF START=======
+6c6
+< Status: checked,analyzed,optimized keys,sorted index pages
+---
+> Status: changed
+11c11
+< Datafile length: 8192 Keyfile length: 8192
+---
+> Datafile length: 155648 Keyfile length: 212992
========DIFF END=======
testing idempotency
applying log
@@ -570,7 +710,7 @@ Differences in maria_chk -dvv, recovery not yet perfect !
11c11
< Datafile length: 8192 Keyfile length: 8192
---
-> Datafile length: 90112 Keyfile length: 204800
+> Datafile length: 114688 Keyfile length: 204800
========DIFF END=======
TEST WITH ma_test1 -s -M -T -c -N -H1 --testflag=1 (commit at end)
TEST WITH ma_test1 -s -M -T -c -N -H1 --testflag=2 --test-undo=3 (additional aborted work)
@@ -614,7 +754,7 @@ Differences in maria_chk -dvv, recovery not yet perfect !
11c11
< Datafile length: 8192 Keyfile length: 8192
---
-> Datafile length: 81920 Keyfile length: 204800
+> Datafile length: 114688 Keyfile length: 204800
========DIFF END=======
testing idempotency
applying log
@@ -627,7 +767,7 @@ Differences in maria_chk -dvv, recovery not yet perfect !
11c11
< Datafile length: 8192 Keyfile length: 8192
---
-> Datafile length: 81920 Keyfile length: 204800
+> Datafile length: 114688 Keyfile length: 204800
========DIFF END=======
testing applying of CLRs to recreate table
applying log
@@ -640,7 +780,77 @@ Differences in maria_chk -dvv, recovery not yet perfect !
11c11
< Datafile length: 8192 Keyfile length: 8192
---
-> Datafile length: 81920 Keyfile length: 204800
+> Datafile length: 114688 Keyfile length: 204800
+========DIFF END=======
+TEST WITH ma_test1 -s -M -T -c -N -H1 --testflag=1 (commit at end)
+TEST WITH ma_test1 -s -M -T -c -N -H1 --testflag=2 --test-undo=4 (additional aborted work)
+Terminating after inserts
+Dying on request without maria_commit()/maria_close()
+applying log
+testing idempotency
+applying log
+testing applying of CLRs to recreate table
+applying log
+TEST WITH ma_test1 -s -M -T -c -N -H2 --testflag=3 (commit at end)
+Terminating after updates
+TEST WITH ma_test1 -s -M -T -c -N -H2 --testflag=4 --test-undo=4 (additional aborted work)
+Terminating after deletes
+Dying on request without maria_commit()/maria_close()
+applying log
+testing idempotency
+applying log
+testing applying of CLRs to recreate table
+applying log
+TEST WITH ma_test1 -s -M -T -c -N -H2 --testflag=2 (commit at end)
+Terminating after inserts
+TEST WITH ma_test1 -s -M -T -c -N -H2 --testflag=3 --test-undo=4 (additional aborted work)
+Terminating after updates
+Dying on request without maria_commit()/maria_close()
+applying log
+testing idempotency
+applying log
+testing applying of CLRs to recreate table
+applying log
+TEST WITH ma_test2 -s -L -K -W -P -M -T -c -H1 -t1 (commit at end)
+TEST WITH ma_test2 -s -L -K -W -P -M -T -c -H1 -t2 -u4 (additional aborted work)
+Dying on request without maria_commit()/maria_close()
+applying log
+Differences in maria_chk -dvv, recovery not yet perfect !
+========DIFF START=======
+6c6
+< Status: checked,analyzed,optimized keys,sorted index pages
+---
+> Status: changed
+11c11
+< Datafile length: 8192 Keyfile length: 8192
+---
+> Datafile length: 114688 Keyfile length: 204800
+========DIFF END=======
+testing idempotency
+applying log
+Differences in maria_chk -dvv, recovery not yet perfect !
+========DIFF START=======
+6c6
+< Status: checked,analyzed,optimized keys,sorted index pages
+---
+> Status: changed
+11c11
+< Datafile length: 8192 Keyfile length: 8192
+---
+> Datafile length: 114688 Keyfile length: 204800
+========DIFF END=======
+testing applying of CLRs to recreate table
+applying log
+Differences in maria_chk -dvv, recovery not yet perfect !
+========DIFF START=======
+6c6
+< Status: checked,analyzed,optimized keys,sorted index pages
+---
+> Status: changed
+11c11
+< Datafile length: 8192 Keyfile length: 8192
+---
+> Datafile length: 114688 Keyfile length: 204800
========DIFF END=======
TEST WITH ma_test1 -s -M -T -c -N -b -H1 --testflag=1 (commit at end)
TEST WITH ma_test1 -s -M -T -c -N -b -H1 --testflag=2 --test-undo=1 (additional aborted work)
@@ -754,7 +964,7 @@ Differences in maria_chk -dvv, recovery not yet perfect !
11c11
< Datafile length: 8192 Keyfile length: 8192
---
-> Datafile length: 122880 Keyfile length: 212992
+> Datafile length: 155648 Keyfile length: 212992
========DIFF END=======
testing idempotency
applying log
@@ -767,7 +977,7 @@ Differences in maria_chk -dvv, recovery not yet perfect !
11c11
< Datafile length: 8192 Keyfile length: 8192
---
-> Datafile length: 122880 Keyfile length: 212992
+> Datafile length: 155648 Keyfile length: 212992
========DIFF END=======
testing applying of CLRs to recreate table
applying log
@@ -780,7 +990,7 @@ Differences in maria_chk -dvv, recovery not yet perfect !
11c11
< Datafile length: 8192 Keyfile length: 8192
---
-> Datafile length: 122880 Keyfile length: 212992
+> Datafile length: 155648 Keyfile length: 212992
========DIFF END=======
TEST WITH ma_test1 -s -M -T -c -N -b -H1 --testflag=1 (commit at end)
TEST WITH ma_test1 -s -M -T -c -N -b -H1 --testflag=2 --test-undo=3 (additional aborted work)
@@ -824,7 +1034,77 @@ Differences in maria_chk -dvv, recovery not yet perfect !
11c11
< Datafile length: 8192 Keyfile length: 8192
---
-> Datafile length: 122880 Keyfile length: 212992
+> Datafile length: 147456 Keyfile length: 212992
+========DIFF END=======
+testing idempotency
+applying log
+Differences in maria_chk -dvv, recovery not yet perfect !
+========DIFF START=======
+6c6
+< Status: checked,analyzed,optimized keys,sorted index pages
+---
+> Status: changed
+11c11
+< Datafile length: 8192 Keyfile length: 8192
+---
+> Datafile length: 147456 Keyfile length: 212992
+========DIFF END=======
+testing applying of CLRs to recreate table
+applying log
+Differences in maria_chk -dvv, recovery not yet perfect !
+========DIFF START=======
+6c6
+< Status: checked,analyzed,optimized keys,sorted index pages
+---
+> Status: changed
+11c11
+< Datafile length: 8192 Keyfile length: 8192
+---
+> Datafile length: 147456 Keyfile length: 212992
+========DIFF END=======
+TEST WITH ma_test1 -s -M -T -c -N -b -H1 --testflag=1 (commit at end)
+TEST WITH ma_test1 -s -M -T -c -N -b -H1 --testflag=2 --test-undo=4 (additional aborted work)
+Terminating after inserts
+Dying on request without maria_commit()/maria_close()
+applying log
+testing idempotency
+applying log
+testing applying of CLRs to recreate table
+applying log
+TEST WITH ma_test1 -s -M -T -c -N -b -H2 --testflag=3 (commit at end)
+Terminating after updates
+TEST WITH ma_test1 -s -M -T -c -N -b -H2 --testflag=4 --test-undo=4 (additional aborted work)
+Terminating after deletes
+Dying on request without maria_commit()/maria_close()
+applying log
+testing idempotency
+applying log
+testing applying of CLRs to recreate table
+applying log
+TEST WITH ma_test1 -s -M -T -c -N -b -H2 --testflag=2 (commit at end)
+Terminating after inserts
+TEST WITH ma_test1 -s -M -T -c -N -b -H2 --testflag=3 --test-undo=4 (additional aborted work)
+Terminating after updates
+Dying on request without maria_commit()/maria_close()
+applying log
+testing idempotency
+applying log
+testing applying of CLRs to recreate table
+applying log
+TEST WITH ma_test2 -s -L -K -W -P -M -T -c -b -H1 -t1 (commit at end)
+TEST WITH ma_test2 -s -L -K -W -P -M -T -c -b -H1 -t2 -u4 (additional aborted work)
+Dying on request without maria_commit()/maria_close()
+applying log
+Differences in maria_chk -dvv, recovery not yet perfect !
+========DIFF START=======
+6c6
+< Status: checked,analyzed,optimized keys,sorted index pages
+---
+> Status: changed
+11c11
+< Datafile length: 8192 Keyfile length: 8192
+---
+> Datafile length: 155648 Keyfile length: 212992
========DIFF END=======
testing idempotency
applying log
diff --git a/storage/maria/ma_update.c b/storage/maria/ma_update.c
index 3c10cdab976..c09faed721c 100644
--- a/storage/maria/ma_update.c
+++ b/storage/maria/ma_update.c
@@ -26,7 +26,7 @@ int maria_update(register MARIA_HA *info, const uchar *oldrec, uchar *newrec)
uchar old_key[HA_MAX_KEY_BUFF],*new_key;
bool auto_key_changed=0;
ulonglong changed;
- MARIA_SHARE *share=info->s;
+ MARIA_SHARE *share= info->s;
DBUG_ENTER("maria_update");
LINT_INIT(new_key);
LINT_INIT(changed);
diff --git a/storage/maria/ma_write.c b/storage/maria/ma_write.c
index 9116ca7cce4..9ceafc51cf7 100644
--- a/storage/maria/ma_write.c
+++ b/storage/maria/ma_write.c
@@ -92,7 +92,7 @@ my_bool _ma_write_abort_default(MARIA_HA *info __attribute__((unused)))
int maria_write(MARIA_HA *info, uchar *record)
{
- MARIA_SHARE *share=info->s;
+ MARIA_SHARE *share= info->s;
uint i;
int save_errno;
MARIA_RECORD_POS filepos;
@@ -101,7 +101,7 @@ int maria_write(MARIA_HA *info, uchar *record)
my_bool fatal_error;
DBUG_ENTER("maria_write");
DBUG_PRINT("enter",("index_file: %d data_file: %d",
- info->s->kfile.file, info->dfile.file));
+ share->kfile.file, info->dfile.file));
DBUG_EXECUTE_IF("maria_pretend_crashed_table_on_usage",
maria_print_error(info->s, HA_ERR_CRASHED);
@@ -215,7 +215,7 @@ int maria_write(MARIA_HA *info, uchar *record)
if updated here, it's not recoverable (no mutex => checkpoint may see a
crazy value and flush it into the table's state on disk).
*/
- set_if_bigger(info->s->state.auto_increment,
+ set_if_bigger(share->state.auto_increment,
ma_retrieve_auto_increment(info, record));
}
info->update= (HA_STATE_CHANGED | HA_STATE_AKTIV | HA_STATE_WRITTEN |
@@ -225,8 +225,9 @@ int maria_write(MARIA_HA *info, uchar *record)
VOID(_ma_writeinfo(info, WRITEINFO_UPDATE_KEYFILE));
if (info->invalidator != 0)
{
- DBUG_PRINT("info", ("invalidator... '%s' (update)", info->s->open_file_name));
- (*info->invalidator)(info->s->open_file_name);
+ DBUG_PRINT("info", ("invalidator... '%s' (update)",
+ share->open_file_name));
+ (*info->invalidator)(share->open_file_name);
info->invalidator=0;
}
@@ -376,21 +377,22 @@ static int _ma_ck_write_btree_with_log(MARIA_HA *info, MARIA_KEYDEF *keyinfo,
uchar *key, uint key_length,
my_off_t *root, uint comp_flag)
{
+ MARIA_SHARE *share= info->s;
LSN lsn= LSN_IMPOSSIBLE;
int error;
my_off_t new_root= *root;
uchar key_buff[HA_MAX_KEY_BUFF];
DBUG_ENTER("_ma_ck_write_btree_with_log");
- if (info->s->now_transactional)
+ if (share->now_transactional)
{
/* Save original value as the key may change */
- memcpy(key_buff, key, key_length + info->s->rec_reflength);
+ memcpy(key_buff, key, key_length + share->rec_reflength);
}
error= _ma_ck_real_write_btree(info, keyinfo, key, key_length, &new_root,
comp_flag);
- if (!error && info->s->now_transactional)
+ if (!error && share->now_transactional)
{
uchar log_data[LSN_STORE_SIZE + FILEID_STORE_SIZE +
KEY_NR_STORE_SIZE];
@@ -402,7 +404,7 @@ static int _ma_ck_write_btree_with_log(MARIA_HA *info, MARIA_KEYDEF *keyinfo,
lsn_store(log_data, info->trn->undo_lsn);
key_nr_store(log_data + LSN_STORE_SIZE + FILEID_STORE_SIZE,
keyinfo->key_nr);
- key_length+= info->s->rec_reflength;
+ key_length+= share->rec_reflength;
log_array[TRANSLOG_INTERNAL_PARTS + 0].str= (char*) log_data;
log_array[TRANSLOG_INTERNAL_PARTS + 0].length= sizeof(log_data);
log_array[TRANSLOG_INTERNAL_PARTS + 1].str= (char*) key_buff;
@@ -466,24 +468,24 @@ int _ma_enlarge_root(MARIA_HA *info, MARIA_KEYDEF *keyinfo, const uchar *key,
{
uint t_length, nod_flag, page_length;
MARIA_KEY_PARAM s_temp;
- MARIA_SHARE *share=info->s;
+ MARIA_SHARE *share= info->s;
MARIA_PINNED_PAGE tmp_page_link, *page_link= &tmp_page_link;
int res= 0;
DBUG_ENTER("_ma_enlarge_root");
nod_flag= (*root != HA_OFFSET_ERROR) ? share->base.key_reflength : 0;
/* Store pointer to prev page if nod */
- _ma_kpointer(info, info->buff + info->s->keypage_header, *root);
+ _ma_kpointer(info, info->buff + share->keypage_header, *root);
t_length=(*keyinfo->pack_key)(keyinfo,nod_flag,(uchar*) 0,
(uchar*) 0, (uchar*) 0, key,&s_temp);
- page_length= info->s->keypage_header + t_length + nod_flag;
+ page_length= share->keypage_header + t_length + nod_flag;
- bzero(info->buff, info->s->keypage_header);
- _ma_store_keynr(info, info->buff, keyinfo->key_nr);
- _ma_store_page_used(info, info->buff, page_length);
+ bzero(info->buff, share->keypage_header);
+ _ma_store_keynr(share, info->buff, keyinfo->key_nr);
+ _ma_store_page_used(share, info->buff, page_length);
if (nod_flag)
- _ma_store_keypage_flag(info, info->buff, KEYPAGE_FLAG_ISNOD);
- (*keyinfo->store_key)(keyinfo, info->buff + info->s->keypage_header +
+ _ma_store_keypage_flag(share, info->buff, KEYPAGE_FLAG_ISNOD);
+ (*keyinfo->store_key)(keyinfo, info->buff + share->keypage_header +
nod_flag, &s_temp);
/* Mark that info->buff was used */
@@ -500,7 +502,7 @@ int _ma_enlarge_root(MARIA_HA *info, MARIA_KEYDEF *keyinfo, const uchar *key,
bzero(info->buff + page_length, share->block_size - page_length);
- if (info->s->now_transactional &&
+ if (share->now_transactional &&
_ma_log_new(info, *root, info->buff, page_length, keyinfo->key_nr, 1))
res= -1;
if (_ma_write_keypage(info, keyinfo, *root, page_link->write_lock,
@@ -533,6 +535,7 @@ static int w_search(register MARIA_HA *info, register MARIA_KEYDEF *keyinfo,
my_bool was_last_key;
my_off_t next_page, dup_key_pos;
MARIA_PINNED_PAGE *page_link;
+ MARIA_SHARE *share= info->s;
DBUG_ENTER("w_search");
DBUG_PRINT("enter",("page: %ld", (long) page));
@@ -546,7 +549,7 @@ static int w_search(register MARIA_HA *info, register MARIA_KEYDEF *keyinfo,
flag=(*keyinfo->bin_search)(info,keyinfo,temp_buff,key,search_key_length,
comp_flag, &keypos, keybuff, &was_last_key);
- nod_flag= _ma_test_if_nod(info, temp_buff);
+ nod_flag= _ma_test_if_nod(share, temp_buff);
if (flag == 0)
{
uint tmp_key_length;
@@ -576,7 +579,7 @@ static int w_search(register MARIA_HA *info, register MARIA_KEYDEF *keyinfo,
{
/* popular word. two-level tree. going down */
my_off_t root=dup_key_pos;
- keyinfo=&info->s->ft2_keyinfo;
+ keyinfo= &share->ft2_keyinfo;
get_key_full_length_rdonly(off, key);
key+=off;
/* we'll modify key entry 'in vivo' */
@@ -674,22 +677,23 @@ int _ma_insert(register MARIA_HA *info, register MARIA_KEYDEF *keyinfo,
int t_length;
uchar *endpos, *prev_key;
MARIA_KEY_PARAM s_temp;
+ MARIA_SHARE *share= info->s;
DBUG_ENTER("_ma_insert");
DBUG_PRINT("enter",("key_pos: 0x%lx", (ulong) key_pos));
DBUG_EXECUTE("key", _ma_print_key(DBUG_FILE,keyinfo->seg,key,
USE_WHOLE_KEY););
- _ma_get_used_and_nod(info, anc_buff, a_length, nod_flag);
+ _ma_get_used_and_nod(share, anc_buff, a_length, nod_flag);
org_anc_length= a_length;
endpos= anc_buff+ a_length;
- prev_key= (key_pos == anc_buff + info->s->keypage_header + nod_flag ?
+ prev_key= (key_pos == anc_buff + share->keypage_header + nod_flag ?
(uchar*) 0 : key_buff);
t_length=(*keyinfo->pack_key)(keyinfo,nod_flag,
(key_pos == endpos ? (uchar*) 0 : key_pos),
prev_key, prev_key,
key,&s_temp);
#ifndef DBUG_OFF
- if (key_pos != anc_buff + info->s->keypage_header + nod_flag &&
+ if (key_pos != anc_buff + share->keypage_header + nod_flag &&
(keyinfo->flag & (HA_BINARY_PACK_KEY | HA_PACK_KEY)))
{
DBUG_DUMP("prev_key",(uchar*) key_buff, _ma_keylength(keyinfo,key_buff));
@@ -706,7 +710,7 @@ int _ma_insert(register MARIA_HA *info, register MARIA_KEYDEF *keyinfo,
{
if (t_length >= keyinfo->maxlength*2+MAX_POINTER_LENGTH)
{
- maria_print_error(info->s, HA_ERR_CRASHED);
+ maria_print_error(share, HA_ERR_CRASHED);
my_errno=HA_ERR_CRASHED;
DBUG_RETURN(-1);
}
@@ -716,7 +720,7 @@ int _ma_insert(register MARIA_HA *info, register MARIA_KEYDEF *keyinfo,
{
if (-t_length >= keyinfo->maxlength*2+MAX_POINTER_LENGTH)
{
- maria_print_error(info->s, HA_ERR_CRASHED);
+ maria_print_error(share, HA_ERR_CRASHED);
my_errno=HA_ERR_CRASHED;
DBUG_RETURN(-1);
}
@@ -724,7 +728,7 @@ int _ma_insert(register MARIA_HA *info, register MARIA_KEYDEF *keyinfo,
}
(*keyinfo->store_key)(keyinfo,key_pos,&s_temp);
a_length+=t_length;
- _ma_store_page_used(info, anc_buff, a_length);
+ _ma_store_page_used(share, anc_buff, a_length);
/*
Check if the new key fits totally into the the page
@@ -734,16 +738,16 @@ int _ma_insert(register MARIA_HA *info, register MARIA_KEYDEF *keyinfo,
{
if (keyinfo->block_length - KEYPAGE_CHECKSUM_SIZE - a_length < 32 &&
(keyinfo->flag & HA_FULLTEXT) && key_pos == endpos &&
- info->s->base.key_reflength <= info->s->base.rec_reflength &&
- info->s->options & (HA_OPTION_PACK_RECORD | HA_OPTION_COMPRESS_RECORD))
+ share->base.key_reflength <= share->base.rec_reflength &&
+ share->options & (HA_OPTION_PACK_RECORD | HA_OPTION_COMPRESS_RECORD))
{
/*
Normal word. One-level tree. Page is almost full.
Let's consider converting.
We'll compare 'key' and the first key at anc_buff
*/
- const uchar *a= key, *b= anc_buff + info->s->keypage_header + nod_flag;
- uint alen, blen, ft2len=info->s->ft2_keyinfo.keylength;
+ const uchar *a= key, *b= anc_buff + share->keypage_header + nod_flag;
+ uint alen, blen, ft2len= share->ft2_keyinfo.keylength;
/* the very first key on the page is always unpacked */
DBUG_ASSERT((*b & 128) == 0);
#if HA_FT_MAXLEN >= 127
@@ -777,7 +781,7 @@ int _ma_insert(register MARIA_HA *info, register MARIA_KEYDEF *keyinfo,
insert_dynamic(info->ft1_to_ft2, (uchar*) b);
/* fixing the page's length - it contains only one key now */
- _ma_store_page_used(info, anc_buff, info->s->keypage_header + blen +
+ _ma_store_page_used(share, anc_buff, share->keypage_header + blen +
ft2len + 2);
}
/* the rest will be done when we're back from recursion */
@@ -785,7 +789,7 @@ int _ma_insert(register MARIA_HA *info, register MARIA_KEYDEF *keyinfo,
}
else
{
- if (info->s->now_transactional &&
+ if (share->now_transactional &&
_ma_log_add(info, anc_page, anc_buff, (uint) (endpos - anc_buff),
key_pos, s_temp.changed_length, t_length, 0))
DBUG_RETURN(-1);
@@ -796,7 +800,7 @@ int _ma_insert(register MARIA_HA *info, register MARIA_KEYDEF *keyinfo,
if (nod_flag)
insert_last=0;
if (!(keyinfo->flag & (HA_VAR_LENGTH_KEY | HA_BINARY_PACK_KEY)) &&
- father_buff && !insert_last)
+ father_buff && !insert_last && !info->quick_mode)
{
s_temp.key_pos= key_pos;
father_page_link->changed= 1;
@@ -848,17 +852,18 @@ int _ma_split_page(register MARIA_HA *info, register MARIA_KEYDEF *keyinfo,
my_off_t new_pos;
MARIA_KEY_PARAM s_temp;
MARIA_PINNED_PAGE tmp_page_link, *page_link= &tmp_page_link;
+ MARIA_SHARE *share= info->s;
int res;
DBUG_ENTER("maria_split_page");
LINT_INIT(after_key);
- DBUG_DUMP("buff", split_buff, _ma_get_page_used(info, split_buff));
+ DBUG_DUMP("buff", split_buff, _ma_get_page_used(share, split_buff));
info->page_changed=1; /* Info->buff is used */
info->keyread_buff_used=1;
new_buff= info->buff;
- nod_flag=_ma_test_if_nod(info, split_buff);
- key_ref_length= info->s->keypage_header + nod_flag;
+ nod_flag= _ma_test_if_nod(share, split_buff);
+ key_ref_length= share->keypage_header + nod_flag;
if (insert_last_key)
key_pos= _ma_find_last_pos(info, keyinfo, split_buff,
key_buff, &key_length,
@@ -870,15 +875,15 @@ int _ma_split_page(register MARIA_HA *info, register MARIA_KEYDEF *keyinfo,
DBUG_RETURN(-1);
split_length= (uint) (key_pos - split_buff);
- a_length= _ma_get_page_used(info, split_buff);
- _ma_store_page_used(info, split_buff, split_length);
+ a_length= _ma_get_page_used(share, split_buff);
+ _ma_store_page_used(share, split_buff, split_length);
key_pos=after_key;
if (nod_flag)
{
DBUG_PRINT("test",("Splitting nod"));
pos=key_pos-nod_flag;
- memcpy((uchar*) new_buff + info->s->keypage_header, (uchar*) pos,
+ memcpy((uchar*) new_buff + share->keypage_header, (uchar*) pos,
(size_t) nod_flag);
}
@@ -901,28 +906,28 @@ int _ma_split_page(register MARIA_HA *info, register MARIA_KEYDEF *keyinfo,
(*keyinfo->store_key)(keyinfo,new_buff+key_ref_length,&s_temp);
page_length= length + t_length + key_ref_length;
- bzero(new_buff, info->s->keypage_header);
+ bzero(new_buff, share->keypage_header);
if (nod_flag)
- _ma_store_keypage_flag(info, new_buff, KEYPAGE_FLAG_ISNOD);
- _ma_store_page_used(info, new_buff, page_length);
+ _ma_store_keypage_flag(share, new_buff, KEYPAGE_FLAG_ISNOD);
+ _ma_store_page_used(share, new_buff, page_length);
/* Copy key number */
- new_buff[info->s->keypage_header - KEYPAGE_USED_SIZE - KEYPAGE_KEYID_SIZE -
+ new_buff[share->keypage_header - KEYPAGE_USED_SIZE - KEYPAGE_KEYID_SIZE -
KEYPAGE_FLAG_SIZE]=
- split_buff[info->s->keypage_header - KEYPAGE_USED_SIZE -
+ split_buff[share->keypage_header - KEYPAGE_USED_SIZE -
KEYPAGE_KEYID_SIZE - KEYPAGE_FLAG_SIZE];
res= 2; /* Middle key up */
- if (info->s->now_transactional &&
+ if (share->now_transactional &&
_ma_log_new(info, new_pos, new_buff, page_length, keyinfo->key_nr, 0))
res= -1;
- bzero(new_buff + page_length, info->s->block_size - page_length);
+ bzero(new_buff + page_length, share->block_size - page_length);
if (_ma_write_keypage(info, keyinfo, new_pos, page_link->write_lock,
DFLT_INIT_HITS, new_buff))
res= -1;
/* Save changes to split pages */
- if (info->s->now_transactional &&
+ if (share->now_transactional &&
_ma_log_split(info, split_page, split_buff, org_split_length,
split_length,
inserted_key_pos, changed_length, move_length,
@@ -949,10 +954,11 @@ uchar *_ma_find_half_pos(MARIA_HA *info, uint nod_flag, MARIA_KEYDEF *keyinfo,
{
uint keys,length,key_ref_length;
uchar *end,*lastpos;
+ MARIA_SHARE *share= info->s;
DBUG_ENTER("_ma_find_half_pos");
- key_ref_length= info->s->keypage_header + nod_flag;
- length= _ma_get_page_used(info, page) - key_ref_length;
+ key_ref_length= share->keypage_header + nod_flag;
+ length= _ma_get_page_used(share, page) - key_ref_length;
page+= key_ref_length; /* Point to first key */
if (!(keyinfo->flag &
(HA_PACK_KEY | HA_SPACE_PACK_USED | HA_VAR_LENGTH_KEY |
@@ -997,10 +1003,11 @@ static uchar *_ma_find_last_pos(MARIA_HA *info, MARIA_KEYDEF *keyinfo,
uint keys,length,last_length,key_ref_length;
uchar *end,*lastpos,*prevpos;
uchar key_buff[HA_MAX_KEY_BUFF];
+ MARIA_SHARE *share= info->s;
DBUG_ENTER("_ma_find_last_pos");
- key_ref_length= info->s->keypage_header;
- length= _ma_get_page_used(info, page) - key_ref_length;
+ key_ref_length= share->keypage_header;
+ length= _ma_get_page_used(share, page) - key_ref_length;
page+=key_ref_length;
if (!(keyinfo->flag &
(HA_PACK_KEY | HA_SPACE_PACK_USED | HA_VAR_LENGTH_KEY |
@@ -1063,6 +1070,7 @@ static int _ma_balance_page(register MARIA_HA *info, MARIA_KEYDEF *keyinfo,
{
MARIA_PINNED_PAGE *next_page_link;
MARIA_PINNED_PAGE tmp_page_link, *new_page_link= &tmp_page_link;
+ MARIA_SHARE *share= info->s;
my_bool right;
uint k_length,father_length,father_keylength,nod_flag,curr_keylength;
uint right_length,left_length,new_right_length,new_left_length,extra_length;
@@ -1073,19 +1081,19 @@ static int _ma_balance_page(register MARIA_HA *info, MARIA_KEYDEF *keyinfo,
DBUG_ENTER("_ma_balance_page");
k_length=keyinfo->keylength;
- father_length= _ma_get_page_used(info, father_buff);
- father_keylength= k_length + info->s->base.key_reflength;
- nod_flag=_ma_test_if_nod(info, curr_buff);
+ father_length= _ma_get_page_used(share, father_buff);
+ father_keylength= k_length + share->base.key_reflength;
+ nod_flag= _ma_test_if_nod(share, curr_buff);
curr_keylength=k_length+nod_flag;
info->page_changed=1;
if ((father_key_pos != father_buff+father_length &&
(info->state->records & 1)) ||
- father_key_pos == father_buff+ info->s->keypage_header +
- info->s->base.key_reflength)
+ father_key_pos == father_buff+ share->keypage_header +
+ share->base.key_reflength)
{
right=1;
- next_page= _ma_kpos(info->s->base.key_reflength,
+ next_page= _ma_kpos(share->base.key_reflength,
father_key_pos+father_keylength);
buff=info->buff;
DBUG_PRINT("info", ("use right page: %lu", (ulong) next_page));
@@ -1094,7 +1102,7 @@ static int _ma_balance_page(register MARIA_HA *info, MARIA_KEYDEF *keyinfo,
{
right=0;
father_key_pos-=father_keylength;
- next_page= _ma_kpos(info->s->base.key_reflength,father_key_pos);
+ next_page= _ma_kpos(share->base.key_reflength,father_key_pos);
/* Move curr_buff so that it's on the left */
buff= curr_buff;
curr_buff= info->buff;
@@ -1105,23 +1113,23 @@ static int _ma_balance_page(register MARIA_HA *info, MARIA_KEYDEF *keyinfo,
DFLT_INIT_HITS, info->buff, 0, &next_page_link))
goto err;
next_page_link->changed= 1;
- DBUG_DUMP("next", info->buff, _ma_get_page_used(info, info->buff));
+ DBUG_DUMP("next", info->buff, _ma_get_page_used(share, info->buff));
/* Test if there is room to share keys */
- left_length= _ma_get_page_used(info, curr_buff);
- right_length= _ma_get_page_used(info, buff);
- keys= ((left_length+right_length-info->s->keypage_header*2-nod_flag*2)/
+ left_length= _ma_get_page_used(share, curr_buff);
+ right_length= _ma_get_page_used(share, buff);
+ keys= ((left_length+right_length-share->keypage_header*2-nod_flag*2)/
curr_keylength);
if ((right ? right_length : left_length) + curr_keylength <=
(uint) keyinfo->block_length - KEYPAGE_CHECKSUM_SIZE)
{
/* Enough space to hold all keys in the two buffers ; Balance bufferts */
- new_left_length= info->s->keypage_header+nod_flag+(keys/2)*curr_keylength;
- new_right_length=info->s->keypage_header+nod_flag+(((keys+1)/2)*
+ new_left_length= share->keypage_header+nod_flag+(keys/2)*curr_keylength;
+ new_right_length=share->keypage_header+nod_flag+(((keys+1)/2)*
curr_keylength);
- _ma_store_page_used(info, curr_buff, new_left_length);
- _ma_store_page_used(info, buff, new_right_length);
+ _ma_store_page_used(share, curr_buff, new_left_length);
+ _ma_store_page_used(share, buff, new_right_length);
DBUG_PRINT("info", ("left_length: %u -> %u right_length: %u -> %u",
left_length, new_left_length,
@@ -1134,13 +1142,13 @@ static int _ma_balance_page(register MARIA_HA *info, MARIA_KEYDEF *keyinfo,
/* Move keys buff -> curr_buff */
pos=curr_buff+left_length;
memcpy(pos,father_key_pos, (size_t) k_length);
- memcpy(pos+k_length, buff + info->s->keypage_header,
+ memcpy(pos+k_length, buff + share->keypage_header,
(size_t) (length=new_left_length - left_length - k_length));
- pos= buff + info->s->keypage_header + length;
+ pos= buff + share->keypage_header + length;
memcpy(father_key_pos, pos, (size_t) k_length);
- bmove(buff + info->s->keypage_header, pos + k_length, new_right_length);
+ bmove(buff + share->keypage_header, pos + k_length, new_right_length);
- if (info->s->now_transactional)
+ if (share->now_transactional)
{
if (right)
{
@@ -1197,15 +1205,15 @@ static int _ma_balance_page(register MARIA_HA *info, MARIA_KEYDEF *keyinfo,
DBUG_PRINT("info", ("move keys to start of buff"));
bmove_upp(buff + new_right_length, buff + right_length,
- right_length - info->s->keypage_header);
+ right_length - share->keypage_header);
length= new_right_length -right_length - k_length;
- memcpy(buff + info->s->keypage_header + length, father_key_pos,
+ memcpy(buff + share->keypage_header + length, father_key_pos,
(size_t) k_length);
pos=curr_buff+new_left_length;
memcpy(father_key_pos, pos, (size_t) k_length);
- memcpy(buff + info->s->keypage_header, pos+k_length, (size_t) length);
+ memcpy(buff + share->keypage_header, pos+k_length, (size_t) length);
- if (info->s->now_transactional)
+ if (share->now_transactional)
{
if (right)
{
@@ -1246,7 +1254,7 @@ static int _ma_balance_page(register MARIA_HA *info, MARIA_KEYDEF *keyinfo,
s_temp->changed_length,
s_temp->move_length,
KEY_OP_ADD_PREFIX,
- buff + info->s->keypage_header,
+ buff + share->keypage_header,
diff_length, diff_length + k_length))
goto err;
/*
@@ -1261,7 +1269,7 @@ static int _ma_balance_page(register MARIA_HA *info, MARIA_KEYDEF *keyinfo,
/* Log changes to father (one level up) page */
- if (info->s->now_transactional &&
+ if (share->now_transactional &&
_ma_log_change(info, father_page, father_buff, father_key_pos,
k_length))
goto err;
@@ -1282,8 +1290,8 @@ static int _ma_balance_page(register MARIA_HA *info, MARIA_KEYDEF *keyinfo,
/* curr_buff[] and buff[] are full, lets split and make new nod */
- extra_buff= info->buff+info->s->base.max_key_block_length;
- new_left_length= new_right_length= (info->s->keypage_header + nod_flag +
+ extra_buff= info->buff+share->base.max_key_block_length;
+ new_left_length= new_right_length= (share->keypage_header + nod_flag +
(keys+1) / 3 * curr_keylength);
/*
5 is the minum number of keys we can have here. This comes from
@@ -1294,42 +1302,42 @@ static int _ma_balance_page(register MARIA_HA *info, MARIA_KEYDEF *keyinfo,
new_left_length-=curr_keylength;
extra_length= (nod_flag + left_length + right_length -
new_left_length - new_right_length - curr_keylength);
- extra_buff_length= extra_length + info->s->keypage_header;
+ extra_buff_length= extra_length + share->keypage_header;
DBUG_PRINT("info",("left_length: %d right_length: %d new_left_length: %d new_right_length: %d extra_length: %d",
left_length, right_length,
new_left_length, new_right_length,
extra_length));
- _ma_store_page_used(info, curr_buff, new_left_length);
- _ma_store_page_used(info, buff, new_right_length);
+ _ma_store_page_used(share, curr_buff, new_left_length);
+ _ma_store_page_used(share, buff, new_right_length);
- bzero(extra_buff, info->s->keypage_header);
+ bzero(extra_buff, share->keypage_header);
if (nod_flag)
- _ma_store_keypage_flag(info, extra_buff, KEYPAGE_FLAG_ISNOD);
+ _ma_store_keypage_flag(share, extra_buff, KEYPAGE_FLAG_ISNOD);
/* Copy key number */
- extra_buff[info->s->keypage_header - KEYPAGE_USED_SIZE - KEYPAGE_KEYID_SIZE -
+ extra_buff[share->keypage_header - KEYPAGE_USED_SIZE - KEYPAGE_KEYID_SIZE -
KEYPAGE_FLAG_SIZE]=
- buff[info->s->keypage_header - KEYPAGE_USED_SIZE - KEYPAGE_KEYID_SIZE -
+ buff[share->keypage_header - KEYPAGE_USED_SIZE - KEYPAGE_KEYID_SIZE -
KEYPAGE_FLAG_SIZE];
- _ma_store_page_used(info, extra_buff, extra_buff_length);
+ _ma_store_page_used(share, extra_buff, extra_buff_length);
/* move first largest keys to new page */
pos=buff+right_length-extra_length;
- memcpy(extra_buff + info->s->keypage_header, pos, extra_length);
+ memcpy(extra_buff + share->keypage_header, pos, extra_length);
/* Zero old data from buffer */
bzero(extra_buff + extra_buff_length,
- info->s->block_size - extra_buff_length);
+ share->block_size - extra_buff_length);
/* Save new parting key between buff and extra_buff */
memcpy(tmp_part_key, pos-k_length,k_length);
/* Make place for new keys */
bmove_upp(buff+ new_right_length, pos - k_length,
- right_length - extra_length - k_length - info->s->keypage_header);
+ right_length - extra_length - k_length - share->keypage_header);
/* Copy keys from left page */
pos= curr_buff+new_left_length;
- memcpy(buff + info->s->keypage_header, pos + k_length,
+ memcpy(buff + share->keypage_header, pos + k_length,
(size_t) (tmp_length= left_length - new_left_length - k_length));
/* Copy old parting key */
- parting_key= buff + info->s->keypage_header + tmp_length;
+ parting_key= buff + share->keypage_header + tmp_length;
memcpy(parting_key, father_key_pos, (size_t) k_length);
/* Move new parting keys up to caller */
@@ -1341,7 +1349,7 @@ static int _ma_balance_page(register MARIA_HA *info, MARIA_KEYDEF *keyinfo,
goto err;
_ma_kpointer(info,key+k_length,new_pos);
- if (info->s->now_transactional)
+ if (share->now_transactional)
{
if (right)
{
@@ -1416,7 +1424,7 @@ static int _ma_balance_page(register MARIA_HA *info, MARIA_KEYDEF *keyinfo,
}
/* Log changes to father (one level up) page */
- if (info->s->now_transactional &&
+ if (share->now_transactional &&
_ma_log_change(info, father_page, father_buff, father_key_pos,
k_length))
goto err;
@@ -1481,27 +1489,28 @@ static int keys_free(uchar *key, TREE_FREE mode, bulk_insert_param *param)
Probably I can use info->lastkey here, but I'm not sure,
and to be safe I'd better use local lastkey.
*/
+ MARIA_SHARE *share= param->info->s;
uchar lastkey[HA_MAX_KEY_BUFF];
uint keylen;
MARIA_KEYDEF *keyinfo;
switch (mode) {
case free_init:
- if (param->info->s->concurrent_insert)
+ if (share->concurrent_insert)
{
- rw_wrlock(&param->info->s->key_root_lock[param->keynr]);
- param->info->s->keyinfo[param->keynr].version++;
+ rw_wrlock(&share->key_root_lock[param->keynr]);
+ share->keyinfo[param->keynr].version++;
}
return 0;
case free_free:
- keyinfo=param->info->s->keyinfo+param->keynr;
+ keyinfo=share->keyinfo+param->keynr;
keylen= _ma_keylength(keyinfo, key);
memcpy(lastkey, key, keylen);
return _ma_ck_write_btree(param->info, param->keynr, lastkey,
- keylen - param->info->s->rec_reflength);
+ keylen - share->rec_reflength);
case free_end:
- if (param->info->s->concurrent_insert)
- rw_unlock(&param->info->s->key_root_lock[param->keynr]);
+ if (share->concurrent_insert)
+ rw_unlock(&share->key_root_lock[param->keynr]);
return 0;
}
return -1;
@@ -1510,7 +1519,7 @@ static int keys_free(uchar *key, TREE_FREE mode, bulk_insert_param *param)
int maria_init_bulk_insert(MARIA_HA *info, ulong cache_size, ha_rows rows)
{
- MARIA_SHARE *share=info->s;
+ MARIA_SHARE *share= info->s;
MARIA_KEYDEF *key=share->keyinfo;
bulk_insert_param *params;
uint i, num_keys, total_keylength;
@@ -1619,14 +1628,14 @@ static my_bool _ma_log_new(MARIA_HA *info, my_off_t page, uchar *buff,
uchar log_data[FILEID_STORE_SIZE + PAGE_STORE_SIZE * 2 + KEY_NR_STORE_SIZE
+1];
LEX_STRING log_array[TRANSLOG_INTERNAL_PARTS + 2];
- MARIA_SHARE *share=info->s;
+ MARIA_SHARE *share= info->s;
DBUG_ENTER("_ma_log_new");
DBUG_PRINT("enter", ("page: %lu", (ulong) page));
- DBUG_ASSERT(info->s->now_transactional);
+ DBUG_ASSERT(share->now_transactional);
/* Store address of new root page */
- page/= info->s->block_size;
+ page/= share->block_size;
page_store(log_data + FILEID_STORE_SIZE, page);
/* Store link to next unused page */
@@ -1634,7 +1643,7 @@ static my_bool _ma_log_new(MARIA_HA *info, my_off_t page, uchar *buff,
page= 0; /* key_del not changed */
else
page= ((share->current_key_del == HA_OFFSET_ERROR) ? IMPOSSIBLE_PAGE_NO :
- share->current_key_del / info->s->block_size);
+ share->current_key_del / share->block_size);
page_store(log_data + FILEID_STORE_SIZE + PAGE_STORE_SIZE, page);
key_nr_store(log_data + FILEID_STORE_SIZE + PAGE_STORE_SIZE*2, key_nr);
diff --git a/storage/maria/maria_chk.c b/storage/maria/maria_chk.c
index 7bae30655be..994bce2cfb4 100644
--- a/storage/maria/maria_chk.c
+++ b/storage/maria/maria_chk.c
@@ -855,7 +855,7 @@ static int maria_chk(HA_CHECK *param, char *filename)
}
DBUG_RETURN(1);
}
- share=info->s;
+ share= info->s;
share->tot_locks-= share->r_locks;
share->r_locks=0;
maria_block_size= share->base.block_size;
@@ -958,7 +958,7 @@ static int maria_chk(HA_CHECK *param, char *filename)
printf("- '%s' has old table-format. Recreating index\n",filename);
rep_quick|=T_QUICK;
}
- share=info->s;
+ share= info->s;
share->tot_locks-= share->r_locks;
share->r_locks=0;
}
@@ -1244,7 +1244,7 @@ static void descript(HA_CHECK *param, register MARIA_HA *info, char *name)
reg4 const char *text;
char buff[160],length[10],*pos,*end;
enum en_fieldtype type;
- MARIA_SHARE *share=info->s;
+ MARIA_SHARE *share= info->s;
char llbuff[22],llbuff2[22];
DBUG_ENTER("describe");
@@ -1514,7 +1514,7 @@ static int maria_sort_records(HA_CHECK *param,
File new_file;
uchar *temp_buff;
ha_rows old_record_count;
- MARIA_SHARE *share=info->s;
+ MARIA_SHARE *share= info->s;
char llbuff[22],llbuff2[22];
MARIA_SORT_INFO sort_info;
MARIA_SORT_PARAM sort_param;
@@ -1684,6 +1684,7 @@ static int sort_record_index(MARIA_SORT_PARAM *sort_param,MARIA_HA *info,
my_off_t page, uchar *buff, uint sort_key,
File new_file,my_bool update_index)
{
+ MARIA_SHARE *share= info->s;
uint nod_flag,used_length,key_length;
uchar *temp_buff,*keypos,*endpos;
my_off_t next_page,rec_pos;
@@ -1693,7 +1694,7 @@ static int sort_record_index(MARIA_SORT_PARAM *sort_param,MARIA_HA *info,
HA_CHECK *param=sort_info->param;
DBUG_ENTER("sort_record_index");
- nod_flag=_ma_test_if_nod(info, buff);
+ nod_flag=_ma_test_if_nod(share, buff);
temp_buff=0;
if (nod_flag)
@@ -1704,8 +1705,8 @@ static int sort_record_index(MARIA_SORT_PARAM *sort_param,MARIA_HA *info,
DBUG_RETURN(-1);
}
}
- used_length= _ma_get_page_used(info, buff);
- keypos= buff + info->s->keypage_header + nod_flag;
+ used_length= _ma_get_page_used(share, buff);
+ keypos= buff + share->keypage_header + nod_flag;
endpos= buff + used_length;
for ( ;; )
{
@@ -1713,7 +1714,7 @@ static int sort_record_index(MARIA_SORT_PARAM *sort_param,MARIA_HA *info,
if (nod_flag)
{
next_page= _ma_kpos(nod_flag, keypos);
- if (my_pread(info->s->kfile.file, (uchar*)temp_buff,
+ if (my_pread(share->kfile.file, (uchar*)temp_buff,
(uint) keyinfo->block_length, next_page,
MYF(MY_NABP+MY_WME)))
{
@@ -1733,14 +1734,14 @@ static int sort_record_index(MARIA_SORT_PARAM *sort_param,MARIA_HA *info,
break;
rec_pos= _ma_dpos(info,0,lastkey+key_length);
- if ((*info->s->read_record)(info,sort_param->record,rec_pos))
+ if ((*share->read_record)(info,sort_param->record,rec_pos))
{
_ma_check_print_error(param,"%d when reading datafile",my_errno);
goto err;
}
if (rec_pos != sort_param->filepos && update_index)
{
- _ma_dpointer(info,keypos-nod_flag-info->s->rec_reflength,
+ _ma_dpointer(info,keypos-nod_flag-share->rec_reflength,
sort_param->filepos);
if (maria_movepoint(info,sort_param->record,rec_pos,sort_param->filepos,
sort_key))
@@ -1754,7 +1755,7 @@ static int sort_record_index(MARIA_SORT_PARAM *sort_param,MARIA_HA *info,
}
/* Clear end of block to get better compression if the table is backuped */
bzero((uchar*) buff+used_length,keyinfo->block_length-used_length);
- if (my_pwrite(info->s->kfile.file, (uchar*)buff, (uint)keyinfo->block_length,
+ if (my_pwrite(share->kfile.file, (uchar*)buff, (uint)keyinfo->block_length,
page,param->myf_rw))
{
_ma_check_print_error(param,"%d when updating keyblock",my_errno);
diff --git a/storage/maria/maria_def.h b/storage/maria/maria_def.h
index bf02793b0ee..5e2ecdea00d 100644
--- a/storage/maria/maria_def.h
+++ b/storage/maria/maria_def.h
@@ -550,26 +550,26 @@ struct st_maria_handler
TRANSID_SIZE)
#define KEYPAGE_FLAG_ISNOD 1
-#define _ma_get_page_used(info,x) \
- ((uint) mi_uint2korr((x) + (info)->s->keypage_header - KEYPAGE_USED_SIZE))
-#define _ma_store_page_used(info,x,y) \
- mi_int2store((x) + (info)->s->keypage_header - KEYPAGE_USED_SIZE, (y))
-#define _ma_test_if_nod(info,x) \
- ((_ma_get_keypage_flag(info,x) & KEYPAGE_FLAG_ISNOD) ? (info)->s->base.key_reflength : 0)
-
-#define _ma_get_used_and_nod(info,buff,length,nod) \
+#define _ma_get_page_used(share,x) \
+ ((uint) mi_uint2korr((x) + (share)->keypage_header - KEYPAGE_USED_SIZE))
+#define _ma_store_page_used(share,x,y) \
+ mi_int2store((x) + (share)->keypage_header - KEYPAGE_USED_SIZE, (y))
+#define _ma_test_if_nod(share,x) \
+ ((_ma_get_keypage_flag(share,x) & KEYPAGE_FLAG_ISNOD) ? (share)->base.key_reflength : 0)
+
+#define _ma_get_used_and_nod(share,buff,length,nod) \
{ \
- nod= _ma_test_if_nod((info),(buff)); \
- length= _ma_get_page_used((info),(buff)); \
+ nod= _ma_test_if_nod((share),(buff)); \
+ length= _ma_get_page_used((share),(buff)); \
}
-#define _ma_store_keynr(info, x, nr) x[(info)->s->keypage_header - KEYPAGE_KEYID_SIZE - KEYPAGE_FLAG_SIZE - KEYPAGE_USED_SIZE]= (nr)
-#define _ma_get_keynr(info, x) ((uchar) x[(info)->s->keypage_header - KEYPAGE_KEYID_SIZE - KEYPAGE_FLAG_SIZE - KEYPAGE_USED_SIZE])
+#define _ma_store_keynr(share, x, nr) x[(share)->keypage_header - KEYPAGE_KEYID_SIZE - KEYPAGE_FLAG_SIZE - KEYPAGE_USED_SIZE]= (nr)
+#define _ma_get_keynr(share, x) ((uchar) x[(share)->keypage_header - KEYPAGE_KEYID_SIZE - KEYPAGE_FLAG_SIZE - KEYPAGE_USED_SIZE])
#define _ma_store_transid(buff, transid) \
int6store((buff) + LSN_STORE_SIZE, (transid))
#define _ma_korr_transid(buff) \
uint6korr((buff) + LSN_STORE_SIZE)
-#define _ma_get_keypage_flag(info,x) x[(info)->s->keypage_header - KEYPAGE_USED_SIZE - KEYPAGE_FLAG_SIZE]
-#define _ma_store_keypage_flag(info,x,flag) x[(info)->s->keypage_header - KEYPAGE_USED_SIZE - KEYPAGE_FLAG_SIZE]= (flag)
+#define _ma_get_keypage_flag(share,x) x[(share)->keypage_header - KEYPAGE_USED_SIZE - KEYPAGE_FLAG_SIZE]
+#define _ma_store_keypage_flag(share,x,flag) x[(share)->keypage_header - KEYPAGE_USED_SIZE - KEYPAGE_FLAG_SIZE]= (flag)
#define maria_mark_crashed(x) do{(x)->s->state.changed|= STATE_CRASHED; \