Commit f24038b8 authored by Sergei Golubchik's avatar Sergei Golubchik

mark Aria allocations for temp tables as MY_THREAD_SPECIFIC

parent 9742cf42
...@@ -232,15 +232,16 @@ my_bool _ma_bitmap_init(MARIA_SHARE *share, File file, ...@@ -232,15 +232,16 @@ my_bool _ma_bitmap_init(MARIA_SHARE *share, File file,
uint max_page_size; uint max_page_size;
MARIA_FILE_BITMAP *bitmap= &share->bitmap; MARIA_FILE_BITMAP *bitmap= &share->bitmap;
uint size= share->block_size; uint size= share->block_size;
myf flag= MY_WME | (share->temporary ? MY_THREAD_SPECIFIC : 0);
pgcache_page_no_t first_bitmap_with_space; pgcache_page_no_t first_bitmap_with_space;
#ifndef DBUG_OFF #ifndef DBUG_OFF
/* We want to have a copy of the bitmap to be able to print differences */ /* We want to have a copy of the bitmap to be able to print differences */
size*= 2; size*= 2;
#endif #endif
if (((bitmap->map= (uchar*) my_malloc(size, MYF(MY_WME))) == NULL) || if (((bitmap->map= (uchar*) my_malloc(size, flag)) == NULL) ||
my_init_dynamic_array(&bitmap->pinned_pages, my_init_dynamic_array(&bitmap->pinned_pages,
sizeof(MARIA_PINNED_PAGE), 1, 1, MYF(0))) sizeof(MARIA_PINNED_PAGE), 1, 1, flag))
return 1; return 1;
bitmap->share= share; bitmap->share= share;
......
...@@ -485,10 +485,11 @@ my_bool _ma_init_block_record(MARIA_HA *info) ...@@ -485,10 +485,11 @@ my_bool _ma_init_block_record(MARIA_HA *info)
{ {
MARIA_ROW *row= &info->cur_row, *new_row= &info->new_row; MARIA_ROW *row= &info->cur_row, *new_row= &info->new_row;
MARIA_SHARE *share= info->s; MARIA_SHARE *share= info->s;
myf flag= MY_WME | (share->temporary ? MY_THREAD_SPECIFIC : 0);
uint default_extents; uint default_extents;
DBUG_ENTER("_ma_init_block_record"); DBUG_ENTER("_ma_init_block_record");
if (!my_multi_malloc(MY_WME, if (!my_multi_malloc(flag,
&row->empty_bits, share->base.pack_bytes, &row->empty_bits, share->base.pack_bytes,
&row->field_lengths, &row->field_lengths,
share->base.max_field_lengths + 2, share->base.max_field_lengths + 2,
...@@ -527,13 +528,12 @@ my_bool _ma_init_block_record(MARIA_HA *info) ...@@ -527,13 +528,12 @@ my_bool _ma_init_block_record(MARIA_HA *info)
FULL_PAGE_SIZE(share) / FULL_PAGE_SIZE(share) /
BLOB_SEGMENT_MIN_SIZE)); BLOB_SEGMENT_MIN_SIZE));
if (my_init_dynamic_array(&info->bitmap_blocks, if (my_init_dynamic_array(&info->bitmap_blocks, sizeof(MARIA_BITMAP_BLOCK),
sizeof(MARIA_BITMAP_BLOCK), default_extents, default_extents, 64, flag))
64, MYF(0)))
goto err; goto err;
info->cur_row.extents_buffer_length= default_extents * ROW_EXTENT_SIZE; info->cur_row.extents_buffer_length= default_extents * ROW_EXTENT_SIZE;
if (!(info->cur_row.extents= my_malloc(info->cur_row.extents_buffer_length, if (!(info->cur_row.extents= my_malloc(info->cur_row.extents_buffer_length,
MYF(MY_WME)))) flag)))
goto err; goto err;
info->row_base_length= share->base_length; info->row_base_length= share->base_length;
...@@ -2642,6 +2642,7 @@ static my_bool write_block_record(MARIA_HA *info, ...@@ -2642,6 +2642,7 @@ static my_bool write_block_record(MARIA_HA *info,
LSN lsn; LSN lsn;
my_off_t position; my_off_t position;
uint save_my_errno; uint save_my_errno;
myf myflag= MY_WME | (share->temporary ? MY_THREAD_SPECIFIC : 0);
DBUG_ENTER("write_block_record"); DBUG_ENTER("write_block_record");
head_block= bitmap_blocks->block; head_block= bitmap_blocks->block;
...@@ -2708,7 +2709,7 @@ static my_bool write_block_record(MARIA_HA *info, ...@@ -2708,7 +2709,7 @@ static my_bool write_block_record(MARIA_HA *info,
for every data segment we want to store. for every data segment we want to store.
*/ */
if (_ma_alloc_buffer(&info->rec_buff, &info->rec_buff_size, if (_ma_alloc_buffer(&info->rec_buff, &info->rec_buff_size,
row->head_length)) row->head_length, myflag))
DBUG_RETURN(1); DBUG_RETURN(1);
tmp_data_used= 0; /* Either 0 or last used uchar in 'data' */ tmp_data_used= 0; /* Either 0 or last used uchar in 'data' */
...@@ -4718,6 +4719,7 @@ int _ma_read_block_record2(MARIA_HA *info, uchar *record, ...@@ -4718,6 +4719,7 @@ int _ma_read_block_record2(MARIA_HA *info, uchar *record,
MARIA_EXTENT_CURSOR extent; MARIA_EXTENT_CURSOR extent;
MARIA_COLUMNDEF *column, *end_column; MARIA_COLUMNDEF *column, *end_column;
MARIA_ROW *cur_row= &info->cur_row; MARIA_ROW *cur_row= &info->cur_row;
myf myflag= MY_WME | (share->temporary ? MY_THREAD_SPECIFIC : 0);
DBUG_ENTER("_ma_read_block_record2"); DBUG_ENTER("_ma_read_block_record2");
start_of_data= data; start_of_data= data;
...@@ -4763,7 +4765,7 @@ int _ma_read_block_record2(MARIA_HA *info, uchar *record, ...@@ -4763,7 +4765,7 @@ int _ma_read_block_record2(MARIA_HA *info, uchar *record,
if (cur_row->extents_buffer_length < row_extent_size && if (cur_row->extents_buffer_length < row_extent_size &&
_ma_alloc_buffer(&cur_row->extents, _ma_alloc_buffer(&cur_row->extents,
&cur_row->extents_buffer_length, &cur_row->extents_buffer_length,
row_extent_size)) row_extent_size, myflag))
DBUG_RETURN(my_errno); DBUG_RETURN(my_errno);
memcpy(cur_row->extents, data, ROW_EXTENT_SIZE); memcpy(cur_row->extents, data, ROW_EXTENT_SIZE);
data+= ROW_EXTENT_SIZE; data+= ROW_EXTENT_SIZE;
...@@ -4944,7 +4946,7 @@ int _ma_read_block_record2(MARIA_HA *info, uchar *record, ...@@ -4944,7 +4946,7 @@ int _ma_read_block_record2(MARIA_HA *info, uchar *record,
cur_row->blob_length= blob_lengths; cur_row->blob_length= blob_lengths;
DBUG_PRINT("info", ("Total blob length: %lu", blob_lengths)); DBUG_PRINT("info", ("Total blob length: %lu", blob_lengths));
if (_ma_alloc_buffer(&info->blob_buff, &info->blob_buff_size, if (_ma_alloc_buffer(&info->blob_buff, &info->blob_buff_size,
blob_lengths)) blob_lengths, myflag))
DBUG_RETURN(my_errno); DBUG_RETURN(my_errno);
blob_buffer= info->blob_buff; blob_buffer= info->blob_buff;
} }
...@@ -5050,6 +5052,7 @@ static my_bool read_row_extent_info(MARIA_HA *info, uchar *buff, ...@@ -5050,6 +5052,7 @@ static my_bool read_row_extent_info(MARIA_HA *info, uchar *buff,
uint flag, row_extents, row_extents_size; uint flag, row_extents, row_extents_size;
uint field_lengths __attribute__ ((unused)); uint field_lengths __attribute__ ((unused));
uchar *extents, *end; uchar *extents, *end;
myf myflag= MY_WME | (share->temporary ? MY_THREAD_SPECIFIC : 0);
DBUG_ENTER("read_row_extent_info"); DBUG_ENTER("read_row_extent_info");
if (!(data= get_record_position(share, buff, if (!(data= get_record_position(share, buff,
...@@ -5073,7 +5076,7 @@ static my_bool read_row_extent_info(MARIA_HA *info, uchar *buff, ...@@ -5073,7 +5076,7 @@ static my_bool read_row_extent_info(MARIA_HA *info, uchar *buff,
if (info->cur_row.extents_buffer_length < row_extents_size && if (info->cur_row.extents_buffer_length < row_extents_size &&
_ma_alloc_buffer(&info->cur_row.extents, _ma_alloc_buffer(&info->cur_row.extents,
&info->cur_row.extents_buffer_length, &info->cur_row.extents_buffer_length,
row_extents_size)) row_extents_size, myflag))
DBUG_RETURN(1); DBUG_RETURN(1);
memcpy(info->cur_row.extents, data, ROW_EXTENT_SIZE); memcpy(info->cur_row.extents, data, ROW_EXTENT_SIZE);
data+= ROW_EXTENT_SIZE; data+= ROW_EXTENT_SIZE;
...@@ -5244,6 +5247,7 @@ my_bool _ma_cmp_block_unique(MARIA_HA *info, MARIA_UNIQUEDEF *def, ...@@ -5244,6 +5247,7 @@ my_bool _ma_cmp_block_unique(MARIA_HA *info, MARIA_UNIQUEDEF *def,
my_bool _ma_scan_init_block_record(MARIA_HA *info) my_bool _ma_scan_init_block_record(MARIA_HA *info)
{ {
MARIA_SHARE *share= info->s; MARIA_SHARE *share= info->s;
myf flag= MY_WME | (share->temporary ? MY_THREAD_SPECIFIC : 0);
DBUG_ENTER("_ma_scan_init_block_record"); DBUG_ENTER("_ma_scan_init_block_record");
DBUG_ASSERT(info->dfile.file == share->bitmap.file.file); DBUG_ASSERT(info->dfile.file == share->bitmap.file.file);
...@@ -5253,7 +5257,7 @@ my_bool _ma_scan_init_block_record(MARIA_HA *info) ...@@ -5253,7 +5257,7 @@ my_bool _ma_scan_init_block_record(MARIA_HA *info)
*/ */
if (!(info->scan.bitmap_buff || if (!(info->scan.bitmap_buff ||
((info->scan.bitmap_buff= ((info->scan.bitmap_buff=
(uchar *) my_malloc(share->block_size * 2, MYF(MY_WME)))))) (uchar *) my_malloc(share->block_size * 2, flag)))))
DBUG_RETURN(1); DBUG_RETURN(1);
info->scan.page_buff= info->scan.bitmap_buff + share->block_size; info->scan.page_buff= info->scan.bitmap_buff + share->block_size;
info->scan.bitmap_end= info->scan.bitmap_buff + share->bitmap.max_total_size; info->scan.bitmap_end= info->scan.bitmap_buff + share->bitmap.max_total_size;
......
...@@ -1271,6 +1271,7 @@ static int check_dynamic_record(HA_CHECK *param, MARIA_HA *info, int extend, ...@@ -1271,6 +1271,7 @@ static int check_dynamic_record(HA_CHECK *param, MARIA_HA *info, int extend,
ulong UNINIT_VAR(left_length); ulong UNINIT_VAR(left_length);
uint b_type; uint b_type;
char llbuff[22],llbuff2[22],llbuff3[22]; char llbuff[22],llbuff2[22],llbuff3[22];
myf myflag= MY_WME | (share->temporary ? MY_THREAD_SPECIFIC : 0);
DBUG_ENTER("check_dynamic_record"); DBUG_ENTER("check_dynamic_record");
pos= 0; pos= 0;
...@@ -1378,7 +1379,7 @@ static int check_dynamic_record(HA_CHECK *param, MARIA_HA *info, int extend, ...@@ -1378,7 +1379,7 @@ static int check_dynamic_record(HA_CHECK *param, MARIA_HA *info, int extend,
{ {
if (_ma_alloc_buffer(&info->rec_buff, &info->rec_buff_size, if (_ma_alloc_buffer(&info->rec_buff, &info->rec_buff_size,
block_info.rec_len + block_info.rec_len +
share->base.extra_rec_buff_size)) share->base.extra_rec_buff_size, myflag))
{ {
_ma_check_print_error(param, _ma_check_print_error(param,
...@@ -2694,7 +2695,7 @@ int maria_repair(HA_CHECK *param, register MARIA_HA *info, ...@@ -2694,7 +2695,7 @@ int maria_repair(HA_CHECK *param, register MARIA_HA *info,
(uchar *) my_malloc((uint) (uchar *) my_malloc((uint)
share->base.default_rec_buff_size, MYF(0))) || share->base.default_rec_buff_size, MYF(0))) ||
_ma_alloc_buffer(&sort_param.rec_buff, &sort_param.rec_buff_size, _ma_alloc_buffer(&sort_param.rec_buff, &sort_param.rec_buff_size,
share->base.default_rec_buff_size)) share->base.default_rec_buff_size, MYF(0)))
{ {
_ma_check_print_error(param, "Not enough memory for extra record"); _ma_check_print_error(param, "Not enough memory for extra record");
goto err; goto err;
...@@ -3782,7 +3783,7 @@ int maria_repair_by_sort(HA_CHECK *param, register MARIA_HA *info, ...@@ -3782,7 +3783,7 @@ int maria_repair_by_sort(HA_CHECK *param, register MARIA_HA *info,
(uchar*) my_malloc((size_t) share->base.default_rec_buff_size, (uchar*) my_malloc((size_t) share->base.default_rec_buff_size,
MYF(0))) || MYF(0))) ||
_ma_alloc_buffer(&sort_param.rec_buff, &sort_param.rec_buff_size, _ma_alloc_buffer(&sort_param.rec_buff, &sort_param.rec_buff_size,
share->base.default_rec_buff_size)) share->base.default_rec_buff_size, MYF(0)))
{ {
_ma_check_print_error(param, "Not enough memory for extra record"); _ma_check_print_error(param, "Not enough memory for extra record");
goto err; goto err;
...@@ -4425,7 +4426,7 @@ int maria_repair_parallel(HA_CHECK *param, register MARIA_HA *info, ...@@ -4425,7 +4426,7 @@ int maria_repair_parallel(HA_CHECK *param, register MARIA_HA *info,
sort_param[i].record= (((uchar *)(sort_param+share->base.keys))+ sort_param[i].record= (((uchar *)(sort_param+share->base.keys))+
(share->base.pack_reclength * i)); (share->base.pack_reclength * i));
if (_ma_alloc_buffer(&sort_param[i].rec_buff, &sort_param[i].rec_buff_size, if (_ma_alloc_buffer(&sort_param[i].rec_buff, &sort_param[i].rec_buff_size,
share->base.default_rec_buff_size)) share->base.default_rec_buff_size, MYF(0)))
{ {
_ma_check_print_error(param,"Not enough memory!"); _ma_check_print_error(param,"Not enough memory!");
goto err; goto err;
...@@ -5155,7 +5156,7 @@ static int sort_get_next_record(MARIA_SORT_PARAM *sort_param) ...@@ -5155,7 +5156,7 @@ static int sort_get_next_record(MARIA_SORT_PARAM *sort_param)
if (_ma_alloc_buffer(&sort_param->rec_buff, if (_ma_alloc_buffer(&sort_param->rec_buff,
&sort_param->rec_buff_size, &sort_param->rec_buff_size,
block_info.rec_len + block_info.rec_len +
share->base.extra_rec_buff_size)) share->base.extra_rec_buff_size, MYF(0)))
{ {
if (param->max_record_length >= block_info.rec_len) if (param->max_record_length >= block_info.rec_len)
......
...@@ -64,10 +64,10 @@ int maria_create(const char *name, enum data_file_type datafile_type, ...@@ -64,10 +64,10 @@ int maria_create(const char *name, enum data_file_type datafile_type,
uint uniques, MARIA_UNIQUEDEF *uniquedefs, uint uniques, MARIA_UNIQUEDEF *uniquedefs,
MARIA_CREATE_INFO *ci,uint flags) MARIA_CREATE_INFO *ci,uint flags)
{ {
register uint i,j; uint i,j;
File UNINIT_VAR(dfile), UNINIT_VAR(file); File UNINIT_VAR(dfile), UNINIT_VAR(file);
int errpos,save_errno, create_mode= O_RDWR | O_TRUNC, res; int errpos,save_errno, create_mode= O_RDWR | O_TRUNC, res;
myf create_flag; myf create_flag, common_flag= MY_WME, sync_dir= 0;
uint length,max_key_length,packed,pack_bytes,pointer,real_length_diff, uint length,max_key_length,packed,pack_bytes,pointer,real_length_diff,
key_length,info_length,key_segs,options,min_key_length, key_length,info_length,key_segs,options,min_key_length,
base_pos,long_varchar_count, base_pos,long_varchar_count,
...@@ -93,7 +93,6 @@ int maria_create(const char *name, enum data_file_type datafile_type, ...@@ -93,7 +93,6 @@ int maria_create(const char *name, enum data_file_type datafile_type,
MARIA_CREATE_INFO tmp_create_info; MARIA_CREATE_INFO tmp_create_info;
my_bool tmp_table= FALSE; /* cache for presence of HA_OPTION_TMP_TABLE */ my_bool tmp_table= FALSE; /* cache for presence of HA_OPTION_TMP_TABLE */
my_bool forced_packed; my_bool forced_packed;
myf sync_dir= 0;
uchar *log_data= NULL; uchar *log_data= NULL;
my_bool encrypted= maria_encrypt_tables && datafile_type == BLOCK_RECORD; my_bool encrypted= maria_encrypt_tables && datafile_type == BLOCK_RECORD;
my_bool insert_order= MY_TEST(flags & HA_PRESERVE_INSERT_ORDER); my_bool insert_order= MY_TEST(flags & HA_PRESERVE_INSERT_ORDER);
...@@ -104,6 +103,9 @@ int maria_create(const char *name, enum data_file_type datafile_type, ...@@ -104,6 +103,9 @@ int maria_create(const char *name, enum data_file_type datafile_type,
DBUG_ASSERT(maria_inited); DBUG_ASSERT(maria_inited);
if (flags & HA_CREATE_TMP_TABLE)
common_flag|= MY_THREAD_SPECIFIC;
if (!ci) if (!ci)
{ {
bzero((char*) &tmp_create_info,sizeof(tmp_create_info)); bzero((char*) &tmp_create_info,sizeof(tmp_create_info));
...@@ -148,7 +150,7 @@ int maria_create(const char *name, enum data_file_type datafile_type, ...@@ -148,7 +150,7 @@ int maria_create(const char *name, enum data_file_type datafile_type,
(double*) my_malloc((keys + uniques)*HA_MAX_KEY_SEG*sizeof(double) + (double*) my_malloc((keys + uniques)*HA_MAX_KEY_SEG*sizeof(double) +
(keys + uniques)*HA_MAX_KEY_SEG*sizeof(ulong) + (keys + uniques)*HA_MAX_KEY_SEG*sizeof(ulong) +
sizeof(uint16) * columns, sizeof(uint16) * columns,
MYF(MY_WME | MY_ZEROFILL)))) MYF(common_flag | MY_ZEROFILL))))
DBUG_RETURN(my_errno); DBUG_RETURN(my_errno);
nulls_per_key_part= (ulong*) (rec_per_key_part + nulls_per_key_part= (ulong*) (rec_per_key_part +
(keys + uniques) * HA_MAX_KEY_SEG); (keys + uniques) * HA_MAX_KEY_SEG);
...@@ -924,7 +926,7 @@ int maria_create(const char *name, enum data_file_type datafile_type, ...@@ -924,7 +926,7 @@ int maria_create(const char *name, enum data_file_type datafile_type,
if ((file= mysql_file_create_with_symlink(key_file_kfile, klinkname_ptr, if ((file= mysql_file_create_with_symlink(key_file_kfile, klinkname_ptr,
kfilename, 0, create_mode, kfilename, 0, create_mode,
MYF(MY_WME|create_flag))) < 0) MYF(common_flag|create_flag))) < 0)
goto err; goto err;
errpos=1; errpos=1;
...@@ -1027,7 +1029,7 @@ int maria_create(const char *name, enum data_file_type datafile_type, ...@@ -1027,7 +1029,7 @@ int maria_create(const char *name, enum data_file_type datafile_type,
MARIA_COLUMNDEF **col_order, **pos; MARIA_COLUMNDEF **col_order, **pos;
if (!(col_order= (MARIA_COLUMNDEF**) my_malloc(share.base.fields * if (!(col_order= (MARIA_COLUMNDEF**) my_malloc(share.base.fields *
sizeof(MARIA_COLUMNDEF*), sizeof(MARIA_COLUMNDEF*),
MYF(MY_WME)))) common_flag)))
goto err; goto err;
for (column= columndef, pos= col_order ; for (column= columndef, pos= col_order ;
column != end_column ; column != end_column ;
...@@ -1206,8 +1208,8 @@ int maria_create(const char *name, enum data_file_type datafile_type, ...@@ -1206,8 +1208,8 @@ int maria_create(const char *name, enum data_file_type datafile_type,
} }
if ((dfile= if ((dfile=
mysql_file_create_with_symlink(key_file_dfile, dlinkname_ptr, mysql_file_create_with_symlink(key_file_dfile, dlinkname_ptr,
dfilename, 0, create_mode, dfilename, 0, create_mode,
MYF(MY_WME | create_flag | sync_dir))) < 0) MYF(common_flag | create_flag | sync_dir))) < 0)
goto err; goto err;
errpos=3; errpos=3;
......
...@@ -1477,6 +1477,8 @@ int _ma_read_dynamic_record(MARIA_HA *info, uchar *buf, ...@@ -1477,6 +1477,8 @@ int _ma_read_dynamic_record(MARIA_HA *info, uchar *buf,
File file; File file;
uchar *UNINIT_VAR(to); uchar *UNINIT_VAR(to);
uint UNINIT_VAR(left_length); uint UNINIT_VAR(left_length);
MARIA_SHARE *share= info->s;
myf flag= MY_WME | (share->temporary ? MY_THREAD_SPECIFIC : 0);
DBUG_ENTER("_ma_read_dynamic_record"); DBUG_ENTER("_ma_read_dynamic_record");
if (filepos == HA_OFFSET_ERROR) if (filepos == HA_OFFSET_ERROR)
...@@ -1507,13 +1509,13 @@ int _ma_read_dynamic_record(MARIA_HA *info, uchar *buf, ...@@ -1507,13 +1509,13 @@ int _ma_read_dynamic_record(MARIA_HA *info, uchar *buf,
if (block_of_record++ == 0) /* First block */ if (block_of_record++ == 0) /* First block */
{ {
info->cur_row.total_length= block_info.rec_len; info->cur_row.total_length= block_info.rec_len;
if (block_info.rec_len > (uint) info->s->base.max_pack_length) if (block_info.rec_len > (uint) share->base.max_pack_length)
goto panic; goto panic;
if (info->s->base.blobs) if (share->base.blobs)
{ {
if (_ma_alloc_buffer(&info->rec_buff, &info->rec_buff_size, if (_ma_alloc_buffer(&info->rec_buff, &info->rec_buff_size,
block_info.rec_len + block_info.rec_len +
info->s->base.extra_rec_buff_size)) share->base.extra_rec_buff_size, flag))
goto err; goto err;
} }
to= info->rec_buff; to= info->rec_buff;
...@@ -1549,7 +1551,7 @@ int _ma_read_dynamic_record(MARIA_HA *info, uchar *buf, ...@@ -1549,7 +1551,7 @@ int _ma_read_dynamic_record(MARIA_HA *info, uchar *buf,
there is no equivalent without seeking. We are at the right there is no equivalent without seeking. We are at the right
position already. :( position already. :(
*/ */
if (info->s->file_read(info, to, block_info.data_len, if (share->file_read(info, to, block_info.data_len,
filepos, MYF(MY_NABP))) filepos, MYF(MY_NABP)))
goto panic; goto panic;
left_length-=block_info.data_len; left_length-=block_info.data_len;
...@@ -1769,6 +1771,7 @@ int _ma_read_rnd_dynamic_record(MARIA_HA *info, ...@@ -1769,6 +1771,7 @@ int _ma_read_rnd_dynamic_record(MARIA_HA *info,
uchar *UNINIT_VAR(to); uchar *UNINIT_VAR(to);
MARIA_BLOCK_INFO block_info; MARIA_BLOCK_INFO block_info;
MARIA_SHARE *share= info->s; MARIA_SHARE *share= info->s;
myf flag= MY_WME | (share->temporary ? MY_THREAD_SPECIFIC : 0);
DBUG_ENTER("_ma_read_rnd_dynamic_record"); DBUG_ENTER("_ma_read_rnd_dynamic_record");
#ifdef MARIA_EXTERNAL_LOCKING #ifdef MARIA_EXTERNAL_LOCKING
...@@ -1859,7 +1862,7 @@ int _ma_read_rnd_dynamic_record(MARIA_HA *info, ...@@ -1859,7 +1862,7 @@ int _ma_read_rnd_dynamic_record(MARIA_HA *info,
{ {
if (_ma_alloc_buffer(&info->rec_buff, &info->rec_buff_size, if (_ma_alloc_buffer(&info->rec_buff, &info->rec_buff_size,
block_info.rec_len + block_info.rec_len +
info->s->base.extra_rec_buff_size)) share->base.extra_rec_buff_size, flag))
goto err; goto err;
} }
to= info->rec_buff; to= info->rec_buff;
......
...@@ -533,6 +533,7 @@ int maria_reset(MARIA_HA *info) ...@@ -533,6 +533,7 @@ int maria_reset(MARIA_HA *info)
{ {
int error= 0; int error= 0;
MARIA_SHARE *share= info->s; MARIA_SHARE *share= info->s;
myf flag= MY_WME | (share->temporary ? MY_THREAD_SPECIFIC : 0);
DBUG_ENTER("maria_reset"); DBUG_ENTER("maria_reset");
/* /*
Free buffers and reset the following flags: Free buffers and reset the following flags:
...@@ -553,13 +554,13 @@ int maria_reset(MARIA_HA *info) ...@@ -553,13 +554,13 @@ int maria_reset(MARIA_HA *info)
{ {
info->rec_buff_size= 1; /* Force realloc */ info->rec_buff_size= 1; /* Force realloc */
_ma_alloc_buffer(&info->rec_buff, &info->rec_buff_size, _ma_alloc_buffer(&info->rec_buff, &info->rec_buff_size,
share->base.default_rec_buff_size); share->base.default_rec_buff_size, flag);
} }
if (info->blob_buff_size > MARIA_SMALL_BLOB_BUFFER) if (info->blob_buff_size > MARIA_SMALL_BLOB_BUFFER)
{ {
info->blob_buff_size= 1; /* Force realloc */ info->blob_buff_size= 1; /* Force realloc */
_ma_alloc_buffer(&info->blob_buff, &info->blob_buff_size, _ma_alloc_buffer(&info->blob_buff, &info->blob_buff_size,
MARIA_SMALL_BLOB_BUFFER); MARIA_SMALL_BLOB_BUFFER, flag);
} }
} }
#if defined(HAVE_MMAP) && defined(HAVE_MADVISE) #if defined(HAVE_MMAP) && defined(HAVE_MADVISE)
......
...@@ -39,7 +39,7 @@ static void maria_scan_end_dummy(MARIA_HA *info); ...@@ -39,7 +39,7 @@ static void maria_scan_end_dummy(MARIA_HA *info);
static my_bool maria_once_init_dummy(MARIA_SHARE *, File); static my_bool maria_once_init_dummy(MARIA_SHARE *, File);
static my_bool maria_once_end_dummy(MARIA_SHARE *); static my_bool maria_once_end_dummy(MARIA_SHARE *);
static uchar *_ma_base_info_read(uchar *ptr, MARIA_BASE_INFO *base); static uchar *_ma_base_info_read(uchar *ptr, MARIA_BASE_INFO *base);
static uchar *_ma_state_info_read(uchar *ptr, MARIA_STATE_INFO *state); static uchar *_ma_state_info_read(uchar *, MARIA_STATE_INFO *, myf);
#define get_next_element(to,pos,size) { memcpy((char*) to,pos,(size_t) size); \ #define get_next_element(to,pos,size) { memcpy((char*) to,pos,(size_t) size); \
pos+=size;} pos+=size;}
...@@ -98,6 +98,7 @@ static MARIA_HA *maria_clone_internal(MARIA_SHARE *share, ...@@ -98,6 +98,7 @@ static MARIA_HA *maria_clone_internal(MARIA_SHARE *share,
uint errpos; uint errpos;
MARIA_HA info,*m_info; MARIA_HA info,*m_info;
my_bitmap_map *changed_fields_bitmap; my_bitmap_map *changed_fields_bitmap;
myf flag= MY_WME | (share->temporary ? MY_THREAD_SPECIFIC : 0);
DBUG_ENTER("maria_clone_internal"); DBUG_ENTER("maria_clone_internal");
errpos= 0; errpos= 0;
...@@ -115,7 +116,7 @@ static MARIA_HA *maria_clone_internal(MARIA_SHARE *share, ...@@ -115,7 +116,7 @@ static MARIA_HA *maria_clone_internal(MARIA_SHARE *share,
errpos= 5; errpos= 5;
/* alloc and set up private structure parts */ /* alloc and set up private structure parts */
if (!my_multi_malloc(MY_WME, if (!my_multi_malloc(flag,
&m_info,sizeof(MARIA_HA), &m_info,sizeof(MARIA_HA),
&info.blobs,sizeof(MARIA_BLOB)*share->base.blobs, &info.blobs,sizeof(MARIA_BLOB)*share->base.blobs,
&info.buff,(share->base.max_key_block_length*2+ &info.buff,(share->base.max_key_block_length*2+
...@@ -163,10 +164,9 @@ static MARIA_HA *maria_clone_internal(MARIA_SHARE *share, ...@@ -163,10 +164,9 @@ static MARIA_HA *maria_clone_internal(MARIA_SHARE *share,
goto err; goto err;
/* The following should be big enough for all pinning purposes */ /* The following should be big enough for all pinning purposes */
if (my_init_dynamic_array(&info.pinned_pages, if (my_init_dynamic_array(&info.pinned_pages, sizeof(MARIA_PINNED_PAGE),
sizeof(MARIA_PINNED_PAGE),
MY_MAX(share->base.blobs*2 + 4, MY_MAX(share->base.blobs*2 + 4,
MARIA_MAX_TREE_LEVELS*3), 16, MYF(0))) MARIA_MAX_TREE_LEVELS*3), 16, flag))
goto err; goto err;
...@@ -202,7 +202,7 @@ static MARIA_HA *maria_clone_internal(MARIA_SHARE *share, ...@@ -202,7 +202,7 @@ static MARIA_HA *maria_clone_internal(MARIA_SHARE *share,
/* Allocate buffer for one record */ /* Allocate buffer for one record */
/* prerequisites: info->rec_buffer == 0 && info->rec_buff_size == 0 */ /* prerequisites: info->rec_buffer == 0 && info->rec_buff_size == 0 */
if (_ma_alloc_buffer(&info.rec_buff, &info.rec_buff_size, if (_ma_alloc_buffer(&info.rec_buff, &info.rec_buff_size,
share->base.default_rec_buff_size)) share->base.default_rec_buff_size, flag))
goto err; goto err;
bzero(info.rec_buff, share->base.default_rec_buff_size); bzero(info.rec_buff, share->base.default_rec_buff_size);
...@@ -265,6 +265,7 @@ MARIA_HA *maria_open(const char *name, int mode, uint open_flags) ...@@ -265,6 +265,7 @@ MARIA_HA *maria_open(const char *name, int mode, uint open_flags)
uint i,j,len,errpos,head_length,base_pos,keys, realpath_err, uint i,j,len,errpos,head_length,base_pos,keys, realpath_err,
key_parts,base_key_parts,unique_key_parts,fulltext_keys,uniques; key_parts,base_key_parts,unique_key_parts,fulltext_keys,uniques;
uint internal_table= MY_TEST(open_flags & HA_OPEN_INTERNAL_TABLE); uint internal_table= MY_TEST(open_flags & HA_OPEN_INTERNAL_TABLE);
myf common_flag= open_flags & HA_OPEN_TMP_TABLE ? MY_THREAD_SPECIFIC : 0;
uint file_version; uint file_version;
size_t info_length; size_t info_length;
char name_buff[FN_REFLEN], org_name[FN_REFLEN], index_name[FN_REFLEN], char name_buff[FN_REFLEN], org_name[FN_REFLEN], index_name[FN_REFLEN],
...@@ -322,13 +323,13 @@ MARIA_HA *maria_open(const char *name, int mode, uint open_flags) ...@@ -322,13 +323,13 @@ MARIA_HA *maria_open(const char *name, int mode, uint open_flags)
DEBUG_SYNC_C("mi_open_kfile"); DEBUG_SYNC_C("mi_open_kfile");
if ((kfile=mysql_file_open(key_file_kfile, name_buff, if ((kfile=mysql_file_open(key_file_kfile, name_buff,
(open_mode=O_RDWR) | O_SHARE | O_NOFOLLOW | O_CLOEXEC, (open_mode=O_RDWR) | O_SHARE | O_NOFOLLOW | O_CLOEXEC,
MYF(MY_NOSYMLINKS))) < 0) MYF(common_flag | MY_NOSYMLINKS))) < 0)
{ {
if ((errno != EROFS && errno != EACCES) || if ((errno != EROFS && errno != EACCES) ||
mode != O_RDONLY || mode != O_RDONLY ||
(kfile=mysql_file_open(key_file_kfile, name_buff, (kfile=mysql_file_open(key_file_kfile, name_buff,
(open_mode=O_RDONLY) | O_SHARE | O_NOFOLLOW | O_CLOEXEC, (open_mode=O_RDONLY) | O_SHARE | O_NOFOLLOW | O_CLOEXEC,
MYF(MY_NOSYMLINKS))) < 0) MYF(common_flag | MY_NOSYMLINKS))) < 0)
goto err; goto err;
} }
share->mode=open_mode; share->mode=open_mode;
...@@ -393,7 +394,7 @@ MARIA_HA *maria_open(const char *name, int mode, uint open_flags) ...@@ -393,7 +394,7 @@ MARIA_HA *maria_open(const char *name, int mode, uint open_flags)
Allocate space for header information and for data that is too Allocate space for header information and for data that is too
big to keep on stack big to keep on stack
*/ */
if (!(disk_cache= my_malloc(info_length+128, MYF(MY_WME)))) if (!(disk_cache= my_malloc(info_length+128, MYF(MY_WME | common_flag))))
{ {
my_errno=ENOMEM; my_errno=ENOMEM;
goto err; goto err;
...@@ -420,7 +421,7 @@ MARIA_HA *maria_open(const char *name, int mode, uint open_flags) ...@@ -420,7 +421,7 @@ MARIA_HA *maria_open(const char *name, int mode, uint open_flags)
} }
share->state_diff_length=len-MARIA_STATE_INFO_SIZE; share->state_diff_length=len-MARIA_STATE_INFO_SIZE;
if (!_ma_state_info_read(disk_cache, &share->state)) if (!_ma_state_info_read(disk_cache, &share->state, common_flag))
goto err; goto err;
len= mi_uint2korr(share->state.header.base_info_length); len= mi_uint2korr(share->state.header.base_info_length);
if (len != MARIA_BASE_INFO_SIZE) if (len != MARIA_BASE_INFO_SIZE)
...@@ -561,12 +562,10 @@ MARIA_HA *maria_open(const char *name, int mode, uint open_flags) ...@@ -561,12 +562,10 @@ MARIA_HA *maria_open(const char *name, int mode, uint open_flags)
share->index_file_name.length= strlen(index_name); share->index_file_name.length= strlen(index_name);
share->data_file_name.length= strlen(data_name); share->data_file_name.length= strlen(data_name);
share->open_file_name.length= strlen(name); share->open_file_name.length= strlen(name);
if (!my_multi_malloc(MY_WME, if (!my_multi_malloc(MYF(MY_WME | common_flag),
&share,sizeof(*share), &share,sizeof(*share),
&rec_per_key_part, &rec_per_key_part, sizeof(double) * key_parts,
sizeof(double) * key_parts, &nulls_per_key_part, sizeof(long)* key_parts,
&nulls_per_key_part,
sizeof(long)* key_parts,
&share->keyinfo,keys*sizeof(MARIA_KEYDEF), &share->keyinfo,keys*sizeof(MARIA_KEYDEF),
&share->uniqueinfo,uniques*sizeof(MARIA_UNIQUEDEF), &share->uniqueinfo,uniques*sizeof(MARIA_UNIQUEDEF),
&share->keyparts, &share->keyparts,
...@@ -883,9 +882,9 @@ MARIA_HA *maria_open(const char *name, int mode, uint open_flags) ...@@ -883,9 +882,9 @@ MARIA_HA *maria_open(const char *name, int mode, uint open_flags)
share->options|= HA_OPTION_READ_ONLY_DATA; share->options|= HA_OPTION_READ_ONLY_DATA;
share->is_log_table= FALSE; share->is_log_table= FALSE;
if (open_flags & HA_OPEN_TMP_TABLE || if (open_flags & HA_OPEN_TMP_TABLE || share->options & HA_OPTION_TMP_TABLE)
(share->options & HA_OPTION_TMP_TABLE))
{ {
common_flag|= MY_THREAD_SPECIFIC;
share->options|= HA_OPTION_TMP_TABLE; share->options|= HA_OPTION_TMP_TABLE;
share->temporary= share->delay_key_write= 1; share->temporary= share->delay_key_write= 1;
share->write_flag=MYF(MY_NABP); share->write_flag=MYF(MY_NABP);
...@@ -1113,13 +1112,13 @@ MARIA_HA *maria_open(const char *name, int mode, uint open_flags) ...@@ -1113,13 +1112,13 @@ MARIA_HA *maria_open(const char *name, int mode, uint open_flags)
*/ */
my_bool _ma_alloc_buffer(uchar **old_addr, size_t *old_size, my_bool _ma_alloc_buffer(uchar **old_addr, size_t *old_size,
size_t new_size) size_t new_size, myf flag)
{ {
if (*old_size < new_size) if (*old_size < new_size)
{ {
uchar *addr; uchar *addr;
if (!(addr= (uchar*) my_realloc(*old_addr, new_size, if (!(addr= (uchar*) my_realloc(*old_addr, new_size,
MYF(MY_ALLOW_ZERO_PTR)))) MYF(MY_ALLOW_ZERO_PTR | flag))))
return 1; return 1;
*old_addr= addr; *old_addr= addr;
*old_size= new_size; *old_size= new_size;
...@@ -1498,7 +1497,7 @@ uint _ma_state_info_write_sub(File file, MARIA_STATE_INFO *state, uint pWrite) ...@@ -1498,7 +1497,7 @@ uint _ma_state_info_write_sub(File file, MARIA_STATE_INFO *state, uint pWrite)
} }
static uchar *_ma_state_info_read(uchar *ptr, MARIA_STATE_INFO *state) static uchar *_ma_state_info_read(uchar *ptr, MARIA_STATE_INFO *state, myf flag)
{ {
uint i,keys,key_parts; uint i,keys,key_parts;
DBUG_ENTER("_ma_state_info_read"); DBUG_ENTER("_ma_state_info_read");
...@@ -1510,7 +1509,7 @@ static uchar *_ma_state_info_read(uchar *ptr, MARIA_STATE_INFO *state) ...@@ -1510,7 +1509,7 @@ static uchar *_ma_state_info_read(uchar *ptr, MARIA_STATE_INFO *state)
/* Allocate memory for key parts if not already done */ /* Allocate memory for key parts if not already done */
if (!state->rec_per_key_part && if (!state->rec_per_key_part &&
!my_multi_malloc(MY_WME, !my_multi_malloc(MYF(MY_WME | flag),
&state->rec_per_key_part, &state->rec_per_key_part,
sizeof(*state->rec_per_key_part) * key_parts, sizeof(*state->rec_per_key_part) * key_parts,
&state->nulls_per_key_part, &state->nulls_per_key_part,
...@@ -1955,6 +1954,8 @@ void _ma_set_index_pagecache_callbacks(PAGECACHE_FILE *file, ...@@ -1955,6 +1954,8 @@ void _ma_set_index_pagecache_callbacks(PAGECACHE_FILE *file,
int _ma_open_datafile(MARIA_HA *info, MARIA_SHARE *share) int _ma_open_datafile(MARIA_HA *info, MARIA_SHARE *share)
{ {
myf flags= MY_WME | (share->mode & O_NOFOLLOW ? MY_NOSYMLINKS : 0); myf flags= MY_WME | (share->mode & O_NOFOLLOW ? MY_NOSYMLINKS : 0);
if (share->temporary)
flags|= MY_THREAD_SPECIFIC;
DEBUG_SYNC_C("mi_open_datafile"); DEBUG_SYNC_C("mi_open_datafile");
info->dfile.file= share->bitmap.file.file= info->dfile.file= share->bitmap.file.file=
mysql_file_open(key_file_dfile, share->data_file_name.str, mysql_file_open(key_file_dfile, share->data_file_name.str,
......
...@@ -1413,10 +1413,12 @@ uint _ma_pack_get_block_info(MARIA_HA *maria, MARIA_BIT_BUFF *bit_buff, ...@@ -1413,10 +1413,12 @@ uint _ma_pack_get_block_info(MARIA_HA *maria, MARIA_BIT_BUFF *bit_buff,
{ {
uchar *header= info->header; uchar *header= info->header;
uint head_length,UNINIT_VAR(ref_length); uint head_length,UNINIT_VAR(ref_length);
MARIA_SHARE *share= maria->s;
myf flag= MY_WME | (share->temporary ? MY_THREAD_SPECIFIC : 0);
if (file >= 0) if (file >= 0)
{ {
ref_length=maria->s->pack.ref_length; ref_length=share->pack.ref_length;
/* /*
We can't use my_pread() here because _ma_read_rnd_pack_record assumes We can't use my_pread() here because _ma_read_rnd_pack_record assumes
position is ok position is ok
...@@ -1426,11 +1428,11 @@ uint _ma_pack_get_block_info(MARIA_HA *maria, MARIA_BIT_BUFF *bit_buff, ...@@ -1426,11 +1428,11 @@ uint _ma_pack_get_block_info(MARIA_HA *maria, MARIA_BIT_BUFF *bit_buff,
return BLOCK_FATAL_ERROR; return BLOCK_FATAL_ERROR;
DBUG_DUMP("header", header, ref_length); DBUG_DUMP("header", header, ref_length);
} }
head_length= read_pack_length((uint) maria->s->pack.version, header, head_length= read_pack_length((uint) share->pack.version, header,
&info->rec_len); &info->rec_len);
if (maria->s->base.blobs) if (share->base.blobs)
{ {
head_length+= read_pack_length((uint) maria->s->pack.version, head_length+= read_pack_length((uint) share->pack.version,
header + head_length, &info->blob_len); header + head_length, &info->blob_len);
/* /*
Ensure that the record buffer is big enough for the compressed Ensure that the record buffer is big enough for the compressed
...@@ -1439,7 +1441,7 @@ uint _ma_pack_get_block_info(MARIA_HA *maria, MARIA_BIT_BUFF *bit_buff, ...@@ -1439,7 +1441,7 @@ uint _ma_pack_get_block_info(MARIA_HA *maria, MARIA_BIT_BUFF *bit_buff,
*/ */
if (_ma_alloc_buffer(rec_buff_p, rec_buff_size_p, if (_ma_alloc_buffer(rec_buff_p, rec_buff_size_p,
info->rec_len + info->blob_len + info->rec_len + info->blob_len +
maria->s->base.extra_rec_buff_size)) share->base.extra_rec_buff_size, flag))
return BLOCK_FATAL_ERROR; /* not enough memory */ return BLOCK_FATAL_ERROR; /* not enough memory */
bit_buff->blob_pos= *rec_buff_p + info->rec_len; bit_buff->blob_pos= *rec_buff_p + info->rec_len;
bit_buff->blob_end= bit_buff->blob_pos + info->blob_len; bit_buff->blob_end= bit_buff->blob_pos + info->blob_len;
...@@ -1580,15 +1582,18 @@ _ma_mempack_get_block_info(MARIA_HA *maria, ...@@ -1580,15 +1582,18 @@ _ma_mempack_get_block_info(MARIA_HA *maria,
size_t *rec_buff_size_p, size_t *rec_buff_size_p,
uchar *header) uchar *header)
{ {
header+= read_pack_length((uint) maria->s->pack.version, header, MARIA_SHARE *share= maria->s;
myf flag= MY_WME | (share->temporary ? MY_THREAD_SPECIFIC : 0);
header+= read_pack_length((uint) share->pack.version, header,
&info->rec_len); &info->rec_len);
if (maria->s->base.blobs) if (share->base.blobs)
{ {
header+= read_pack_length((uint) maria->s->pack.version, header, header+= read_pack_length((uint) share->pack.version, header,
&info->blob_len); &info->blob_len);
/* _ma_alloc_rec_buff sets my_errno on error */ /* _ma_alloc_rec_buff sets my_errno on error */
if (_ma_alloc_buffer(rec_buff_p, rec_buff_size_p, if (_ma_alloc_buffer(rec_buff_p, rec_buff_size_p,
info->blob_len + maria->s->base.extra_rec_buff_size)) info->blob_len + share->base.extra_rec_buff_size, flag))
return 0; /* not enough memory */ return 0; /* not enough memory */
bit_buff->blob_pos= *rec_buff_p; bit_buff->blob_pos= *rec_buff_p;
bit_buff->blob_end= *rec_buff_p + info->blob_len; bit_buff->blob_end= *rec_buff_p + info->blob_len;
......
...@@ -1198,7 +1198,7 @@ extern my_bool _ma_read_cache(MARIA_HA *, IO_CACHE *info, uchar *buff, ...@@ -1198,7 +1198,7 @@ extern my_bool _ma_read_cache(MARIA_HA *, IO_CACHE *info, uchar *buff,
uint re_read_if_possibly); uint re_read_if_possibly);
extern ulonglong ma_retrieve_auto_increment(const uchar *key, uint8 key_type); extern ulonglong ma_retrieve_auto_increment(const uchar *key, uint8 key_type);
extern my_bool _ma_alloc_buffer(uchar **old_addr, size_t *old_size, extern my_bool _ma_alloc_buffer(uchar **old_addr, size_t *old_size,
size_t new_size); size_t new_size, myf flag);
extern size_t _ma_rec_unpack(MARIA_HA *info, uchar *to, uchar *from, extern size_t _ma_rec_unpack(MARIA_HA *info, uchar *to, uchar *from,
size_t reclength); size_t reclength);
extern my_bool _ma_rec_check(MARIA_HA *info, const uchar *record, extern my_bool _ma_rec_check(MARIA_HA *info, const uchar *record,
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment