Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
M
MariaDB
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
nexedi
MariaDB
Commits
f24038b8
Commit
f24038b8
authored
Mar 07, 2021
by
Sergei Golubchik
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
mark Aria allocations for temp tables as MY_THREAD_SPECIFIC
parent
9742cf42
Changes
9
Hide whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
81 additions
and
63 deletions
+81
-63
storage/maria/ma_bitmap.c
storage/maria/ma_bitmap.c
+3
-2
storage/maria/ma_blockrec.c
storage/maria/ma_blockrec.c
+14
-10
storage/maria/ma_check.c
storage/maria/ma_check.c
+6
-5
storage/maria/ma_create.c
storage/maria/ma_create.c
+10
-8
storage/maria/ma_dynrec.c
storage/maria/ma_dynrec.c
+8
-5
storage/maria/ma_extra.c
storage/maria/ma_extra.c
+3
-2
storage/maria/ma_open.c
storage/maria/ma_open.c
+22
-21
storage/maria/ma_packrec.c
storage/maria/ma_packrec.c
+14
-9
storage/maria/maria_def.h
storage/maria/maria_def.h
+1
-1
No files found.
storage/maria/ma_bitmap.c
View file @
f24038b8
...
...
@@ -232,15 +232,16 @@ my_bool _ma_bitmap_init(MARIA_SHARE *share, File file,
uint
max_page_size
;
MARIA_FILE_BITMAP
*
bitmap
=
&
share
->
bitmap
;
uint
size
=
share
->
block_size
;
myf
flag
=
MY_WME
|
(
share
->
temporary
?
MY_THREAD_SPECIFIC
:
0
);
pgcache_page_no_t
first_bitmap_with_space
;
#ifndef DBUG_OFF
/* We want to have a copy of the bitmap to be able to print differences */
size
*=
2
;
#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
,
sizeof
(
MARIA_PINNED_PAGE
),
1
,
1
,
MYF
(
0
)
))
sizeof
(
MARIA_PINNED_PAGE
),
1
,
1
,
flag
))
return
1
;
bitmap
->
share
=
share
;
...
...
storage/maria/ma_blockrec.c
View file @
f24038b8
...
...
@@ -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_SHARE
*
share
=
info
->
s
;
myf
flag
=
MY_WME
|
(
share
->
temporary
?
MY_THREAD_SPECIFIC
:
0
);
uint
default_extents
;
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
->
field_lengths
,
share
->
base
.
max_field_lengths
+
2
,
...
...
@@ -527,13 +528,12 @@ my_bool _ma_init_block_record(MARIA_HA *info)
FULL_PAGE_SIZE
(
share
)
/
BLOB_SEGMENT_MIN_SIZE
));
if
(
my_init_dynamic_array
(
&
info
->
bitmap_blocks
,
sizeof
(
MARIA_BITMAP_BLOCK
),
default_extents
,
64
,
MYF
(
0
)))
if
(
my_init_dynamic_array
(
&
info
->
bitmap_blocks
,
sizeof
(
MARIA_BITMAP_BLOCK
),
default_extents
,
64
,
flag
))
goto
err
;
info
->
cur_row
.
extents_buffer_length
=
default_extents
*
ROW_EXTENT_SIZE
;
if
(
!
(
info
->
cur_row
.
extents
=
my_malloc
(
info
->
cur_row
.
extents_buffer_length
,
MYF
(
MY_WME
)
)))
flag
)))
goto
err
;
info
->
row_base_length
=
share
->
base_length
;
...
...
@@ -2642,6 +2642,7 @@ static my_bool write_block_record(MARIA_HA *info,
LSN
lsn
;
my_off_t
position
;
uint
save_my_errno
;
myf
myflag
=
MY_WME
|
(
share
->
temporary
?
MY_THREAD_SPECIFIC
:
0
);
DBUG_ENTER
(
"write_block_record"
);
head_block
=
bitmap_blocks
->
block
;
...
...
@@ -2708,7 +2709,7 @@ static my_bool write_block_record(MARIA_HA *info,
for every data segment we want to store.
*/
if
(
_ma_alloc_buffer
(
&
info
->
rec_buff
,
&
info
->
rec_buff_size
,
row
->
head_length
))
row
->
head_length
,
myflag
))
DBUG_RETURN
(
1
);
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,
MARIA_EXTENT_CURSOR
extent
;
MARIA_COLUMNDEF
*
column
,
*
end_column
;
MARIA_ROW
*
cur_row
=
&
info
->
cur_row
;
myf
myflag
=
MY_WME
|
(
share
->
temporary
?
MY_THREAD_SPECIFIC
:
0
);
DBUG_ENTER
(
"_ma_read_block_record2"
);
start_of_data
=
data
;
...
...
@@ -4763,7 +4765,7 @@ int _ma_read_block_record2(MARIA_HA *info, uchar *record,
if
(
cur_row
->
extents_buffer_length
<
row_extent_size
&&
_ma_alloc_buffer
(
&
cur_row
->
extents
,
&
cur_row
->
extents_buffer_length
,
row_extent_size
))
row_extent_size
,
myflag
))
DBUG_RETURN
(
my_errno
);
memcpy
(
cur_row
->
extents
,
data
,
ROW_EXTENT_SIZE
);
data
+=
ROW_EXTENT_SIZE
;
...
...
@@ -4944,7 +4946,7 @@ int _ma_read_block_record2(MARIA_HA *info, uchar *record,
cur_row
->
blob_length
=
blob_lengths
;
DBUG_PRINT
(
"info"
,
(
"Total blob length: %lu"
,
blob_lengths
));
if
(
_ma_alloc_buffer
(
&
info
->
blob_buff
,
&
info
->
blob_buff_size
,
blob_lengths
))
blob_lengths
,
myflag
))
DBUG_RETURN
(
my_errno
);
blob_buffer
=
info
->
blob_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
field_lengths
__attribute__
((
unused
));
uchar
*
extents
,
*
end
;
myf
myflag
=
MY_WME
|
(
share
->
temporary
?
MY_THREAD_SPECIFIC
:
0
);
DBUG_ENTER
(
"read_row_extent_info"
);
if
(
!
(
data
=
get_record_position
(
share
,
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
&&
_ma_alloc_buffer
(
&
info
->
cur_row
.
extents
,
&
info
->
cur_row
.
extents_buffer_length
,
row_extents_size
))
row_extents_size
,
myflag
))
DBUG_RETURN
(
1
);
memcpy
(
info
->
cur_row
.
extents
,
data
,
ROW_EXTENT_SIZE
);
data
+=
ROW_EXTENT_SIZE
;
...
...
@@ -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
)
{
MARIA_SHARE
*
share
=
info
->
s
;
myf
flag
=
MY_WME
|
(
share
->
temporary
?
MY_THREAD_SPECIFIC
:
0
);
DBUG_ENTER
(
"_ma_scan_init_block_record"
);
DBUG_ASSERT
(
info
->
dfile
.
file
==
share
->
bitmap
.
file
.
file
);
...
...
@@ -5253,7 +5257,7 @@ my_bool _ma_scan_init_block_record(MARIA_HA *info)
*/
if
(
!
(
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
);
info
->
scan
.
page_buff
=
info
->
scan
.
bitmap_buff
+
share
->
block_size
;
info
->
scan
.
bitmap_end
=
info
->
scan
.
bitmap_buff
+
share
->
bitmap
.
max_total_size
;
...
...
storage/maria/ma_check.c
View file @
f24038b8
...
...
@@ -1271,6 +1271,7 @@ static int check_dynamic_record(HA_CHECK *param, MARIA_HA *info, int extend,
ulong
UNINIT_VAR
(
left_length
);
uint
b_type
;
char
llbuff
[
22
],
llbuff2
[
22
],
llbuff3
[
22
];
myf
myflag
=
MY_WME
|
(
share
->
temporary
?
MY_THREAD_SPECIFIC
:
0
);
DBUG_ENTER
(
"check_dynamic_record"
);
pos
=
0
;
...
...
@@ -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
,
block_info
.
rec_len
+
share
->
base
.
extra_rec_buff_size
))
share
->
base
.
extra_rec_buff_size
,
myflag
))
{
_ma_check_print_error
(
param
,
...
...
@@ -2694,7 +2695,7 @@ int maria_repair(HA_CHECK *param, register MARIA_HA *info,
(
uchar
*
)
my_malloc
((
uint
)
share
->
base
.
default_rec_buff_size
,
MYF
(
0
)))
||
_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"
);
goto
err
;
...
...
@@ -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
,
MYF
(
0
)))
||
_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"
);
goto
err
;
...
...
@@ -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
))
+
(
share
->
base
.
pack_reclength
*
i
));
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!"
);
goto
err
;
...
...
@@ -5155,7 +5156,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
+
share
->
base
.
extra_rec_buff_size
))
share
->
base
.
extra_rec_buff_size
,
MYF
(
0
)
))
{
if
(
param
->
max_record_length
>=
block_info
.
rec_len
)
...
...
storage/maria/ma_create.c
View file @
f24038b8
...
...
@@ -64,10 +64,10 @@ int maria_create(const char *name, enum data_file_type datafile_type,
uint
uniques
,
MARIA_UNIQUEDEF
*
uniquedefs
,
MARIA_CREATE_INFO
*
ci
,
uint
flags
)
{
register
uint
i
,
j
;
uint
i
,
j
;
File
UNINIT_VAR
(
dfile
),
UNINIT_VAR
(
file
);
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
,
key_length
,
info_length
,
key_segs
,
options
,
min_key_length
,
base_pos
,
long_varchar_count
,
...
...
@@ -93,7 +93,6 @@ int maria_create(const char *name, enum data_file_type datafile_type,
MARIA_CREATE_INFO
tmp_create_info
;
my_bool
tmp_table
=
FALSE
;
/* cache for presence of HA_OPTION_TMP_TABLE */
my_bool
forced_packed
;
myf
sync_dir
=
0
;
uchar
*
log_data
=
NULL
;
my_bool
encrypted
=
maria_encrypt_tables
&&
datafile_type
==
BLOCK_RECORD
;
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,
DBUG_ASSERT
(
maria_inited
);
if
(
flags
&
HA_CREATE_TMP_TABLE
)
common_flag
|=
MY_THREAD_SPECIFIC
;
if
(
!
ci
)
{
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,
(
double
*
)
my_malloc
((
keys
+
uniques
)
*
HA_MAX_KEY_SEG
*
sizeof
(
double
)
+
(
keys
+
uniques
)
*
HA_MAX_KEY_SEG
*
sizeof
(
ulong
)
+
sizeof
(
uint16
)
*
columns
,
MYF
(
MY_WME
|
MY_ZEROFILL
))))
MYF
(
common_flag
|
MY_ZEROFILL
))))
DBUG_RETURN
(
my_errno
);
nulls_per_key_part
=
(
ulong
*
)
(
rec_per_key_part
+
(
keys
+
uniques
)
*
HA_MAX_KEY_SEG
);
...
...
@@ -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
,
kfilename
,
0
,
create_mode
,
MYF
(
MY_WME
|
create_flag
)))
<
0
)
MYF
(
common_flag
|
create_flag
)))
<
0
)
goto
err
;
errpos
=
1
;
...
...
@@ -1027,7 +1029,7 @@ int maria_create(const char *name, enum data_file_type datafile_type,
MARIA_COLUMNDEF
**
col_order
,
**
pos
;
if
(
!
(
col_order
=
(
MARIA_COLUMNDEF
**
)
my_malloc
(
share
.
base
.
fields
*
sizeof
(
MARIA_COLUMNDEF
*
),
MYF
(
MY_WME
)
)))
common_flag
)))
goto
err
;
for
(
column
=
columndef
,
pos
=
col_order
;
column
!=
end_column
;
...
...
@@ -1206,8 +1208,8 @@ int maria_create(const char *name, enum data_file_type datafile_type,
}
if
((
dfile
=
mysql_file_create_with_symlink
(
key_file_dfile
,
dlinkname_ptr
,
dfilename
,
0
,
create_mode
,
MYF
(
MY_WME
|
create_flag
|
sync_dir
)))
<
0
)
dfilename
,
0
,
create_mode
,
MYF
(
common_flag
|
create_flag
|
sync_dir
)))
<
0
)
goto
err
;
errpos
=
3
;
...
...
storage/maria/ma_dynrec.c
View file @
f24038b8
...
...
@@ -1477,6 +1477,8 @@ int _ma_read_dynamic_record(MARIA_HA *info, uchar *buf,
File
file
;
uchar
*
UNINIT_VAR
(
to
);
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"
);
if
(
filepos
==
HA_OFFSET_ERROR
)
...
...
@@ -1507,13 +1509,13 @@ int _ma_read_dynamic_record(MARIA_HA *info, uchar *buf,
if
(
block_of_record
++
==
0
)
/* First block */
{
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
;
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
,
flag
))
goto
err
;
}
to
=
info
->
rec_buff
;
...
...
@@ -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
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
)))
goto
panic
;
left_length
-=
block_info
.
data_len
;
...
...
@@ -1769,6 +1771,7 @@ int _ma_read_rnd_dynamic_record(MARIA_HA *info,
uchar
*
UNINIT_VAR
(
to
);
MARIA_BLOCK_INFO
block_info
;
MARIA_SHARE
*
share
=
info
->
s
;
myf
flag
=
MY_WME
|
(
share
->
temporary
?
MY_THREAD_SPECIFIC
:
0
);
DBUG_ENTER
(
"_ma_read_rnd_dynamic_record"
);
#ifdef MARIA_EXTERNAL_LOCKING
...
...
@@ -1859,7 +1862,7 @@ int _ma_read_rnd_dynamic_record(MARIA_HA *info,
{
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
,
flag
))
goto
err
;
}
to
=
info
->
rec_buff
;
...
...
storage/maria/ma_extra.c
View file @
f24038b8
...
...
@@ -533,6 +533,7 @@ int maria_reset(MARIA_HA *info)
{
int
error
=
0
;
MARIA_SHARE
*
share
=
info
->
s
;
myf
flag
=
MY_WME
|
(
share
->
temporary
?
MY_THREAD_SPECIFIC
:
0
);
DBUG_ENTER
(
"maria_reset"
);
/*
Free buffers and reset the following flags:
...
...
@@ -553,13 +554,13 @@ int maria_reset(MARIA_HA *info)
{
info
->
rec_buff_size
=
1
;
/* Force realloc */
_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
)
{
info
->
blob_buff_size
=
1
;
/* Force realloc */
_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)
...
...
storage/maria/ma_open.c
View file @
f24038b8
...
...
@@ -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_end_dummy
(
MARIA_SHARE
*
);
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); \
pos+=size;}
...
...
@@ -98,6 +98,7 @@ static MARIA_HA *maria_clone_internal(MARIA_SHARE *share,
uint
errpos
;
MARIA_HA
info
,
*
m_info
;
my_bitmap_map
*
changed_fields_bitmap
;
myf
flag
=
MY_WME
|
(
share
->
temporary
?
MY_THREAD_SPECIFIC
:
0
);
DBUG_ENTER
(
"maria_clone_internal"
);
errpos
=
0
;
...
...
@@ -115,7 +116,7 @@ static MARIA_HA *maria_clone_internal(MARIA_SHARE *share,
errpos
=
5
;
/* alloc and set up private structure parts */
if
(
!
my_multi_malloc
(
MY_WME
,
if
(
!
my_multi_malloc
(
flag
,
&
m_info
,
sizeof
(
MARIA_HA
),
&
info
.
blobs
,
sizeof
(
MARIA_BLOB
)
*
share
->
base
.
blobs
,
&
info
.
buff
,(
share
->
base
.
max_key_block_length
*
2
+
...
...
@@ -163,10 +164,9 @@ static MARIA_HA *maria_clone_internal(MARIA_SHARE *share,
goto
err
;
/* The following should be big enough for all pinning purposes */
if
(
my_init_dynamic_array
(
&
info
.
pinned_pages
,
sizeof
(
MARIA_PINNED_PAGE
),
if
(
my_init_dynamic_array
(
&
info
.
pinned_pages
,
sizeof
(
MARIA_PINNED_PAGE
),
MY_MAX
(
share
->
base
.
blobs
*
2
+
4
,
MARIA_MAX_TREE_LEVELS
*
3
),
16
,
MYF
(
0
)
))
MARIA_MAX_TREE_LEVELS
*
3
),
16
,
flag
))
goto
err
;
...
...
@@ -202,7 +202,7 @@ static MARIA_HA *maria_clone_internal(MARIA_SHARE *share,
/* Allocate buffer for one record */
/* prerequisites: info->rec_buffer == 0 && info->rec_buff_size == 0 */
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
;
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)
uint
i
,
j
,
len
,
errpos
,
head_length
,
base_pos
,
keys
,
realpath_err
,
key_parts
,
base_key_parts
,
unique_key_parts
,
fulltext_keys
,
uniques
;
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
;
size_t
info_length
;
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)
DEBUG_SYNC_C
(
"mi_open_kfile"
);
if
((
kfile
=
mysql_file_open
(
key_file_kfile
,
name_buff
,
(
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
)
||
mode
!=
O_RDONLY
||
(
kfile
=
mysql_file_open
(
key_file_kfile
,
name_buff
,
(
open_mode
=
O_RDONLY
)
|
O_SHARE
|
O_NOFOLLOW
|
O_CLOEXEC
,
MYF
(
MY_NOSYMLINKS
)))
<
0
)
MYF
(
common_flag
|
MY_NOSYMLINKS
)))
<
0
)
goto
err
;
}
share
->
mode
=
open_mode
;
...
...
@@ -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
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
;
goto
err
;
...
...
@@ -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
;
if
(
!
_ma_state_info_read
(
disk_cache
,
&
share
->
state
))
if
(
!
_ma_state_info_read
(
disk_cache
,
&
share
->
state
,
common_flag
))
goto
err
;
len
=
mi_uint2korr
(
share
->
state
.
header
.
base_info_length
);
if
(
len
!=
MARIA_BASE_INFO_SIZE
)
...
...
@@ -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
->
data_file_name
.
length
=
strlen
(
data_name
);
share
->
open_file_name
.
length
=
strlen
(
name
);
if
(
!
my_multi_malloc
(
MY
_WME
,
if
(
!
my_multi_malloc
(
MY
F
(
MY_WME
|
common_flag
)
,
&
share
,
sizeof
(
*
share
),
&
rec_per_key_part
,
sizeof
(
double
)
*
key_parts
,
&
nulls_per_key_part
,
sizeof
(
long
)
*
key_parts
,
&
rec_per_key_part
,
sizeof
(
double
)
*
key_parts
,
&
nulls_per_key_part
,
sizeof
(
long
)
*
key_parts
,
&
share
->
keyinfo
,
keys
*
sizeof
(
MARIA_KEYDEF
),
&
share
->
uniqueinfo
,
uniques
*
sizeof
(
MARIA_UNIQUEDEF
),
&
share
->
keyparts
,
...
...
@@ -883,9 +882,9 @@ MARIA_HA *maria_open(const char *name, int mode, uint open_flags)
share
->
options
|=
HA_OPTION_READ_ONLY_DATA
;
share
->
is_log_table
=
FALSE
;
if
(
open_flags
&
HA_OPEN_TMP_TABLE
||
(
share
->
options
&
HA_OPTION_TMP_TABLE
))
if
(
open_flags
&
HA_OPEN_TMP_TABLE
||
share
->
options
&
HA_OPTION_TMP_TABLE
)
{
common_flag
|=
MY_THREAD_SPECIFIC
;
share
->
options
|=
HA_OPTION_TMP_TABLE
;
share
->
temporary
=
share
->
delay_key_write
=
1
;
share
->
write_flag
=
MYF
(
MY_NABP
);
...
...
@@ -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
,
size_t
new_size
)
size_t
new_size
,
myf
flag
)
{
if
(
*
old_size
<
new_size
)
{
uchar
*
addr
;
if
(
!
(
addr
=
(
uchar
*
)
my_realloc
(
*
old_addr
,
new_size
,
MYF
(
MY_ALLOW_ZERO_PTR
))))
MYF
(
MY_ALLOW_ZERO_PTR
|
flag
))))
return
1
;
*
old_addr
=
addr
;
*
old_size
=
new_size
;
...
...
@@ -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
;
DBUG_ENTER
(
"_ma_state_info_read"
);
...
...
@@ -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 */
if
(
!
state
->
rec_per_key_part
&&
!
my_multi_malloc
(
MY
_WME
,
!
my_multi_malloc
(
MY
F
(
MY_WME
|
flag
)
,
&
state
->
rec_per_key_part
,
sizeof
(
*
state
->
rec_per_key_part
)
*
key_parts
,
&
state
->
nulls_per_key_part
,
...
...
@@ -1955,6 +1954,8 @@ void _ma_set_index_pagecache_callbacks(PAGECACHE_FILE *file,
int
_ma_open_datafile
(
MARIA_HA
*
info
,
MARIA_SHARE
*
share
)
{
myf
flags
=
MY_WME
|
(
share
->
mode
&
O_NOFOLLOW
?
MY_NOSYMLINKS
:
0
);
if
(
share
->
temporary
)
flags
|=
MY_THREAD_SPECIFIC
;
DEBUG_SYNC_C
(
"mi_open_datafile"
);
info
->
dfile
.
file
=
share
->
bitmap
.
file
.
file
=
mysql_file_open
(
key_file_dfile
,
share
->
data_file_name
.
str
,
...
...
storage/maria/ma_packrec.c
View file @
f24038b8
...
...
@@ -1413,10 +1413,12 @@ uint _ma_pack_get_block_info(MARIA_HA *maria, MARIA_BIT_BUFF *bit_buff,
{
uchar
*
header
=
info
->
header
;
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
)
{
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
position is ok
...
...
@@ -1426,11 +1428,11 @@ uint _ma_pack_get_block_info(MARIA_HA *maria, MARIA_BIT_BUFF *bit_buff,
return
BLOCK_FATAL_ERROR
;
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
);
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
);
/*
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,
*/
if
(
_ma_alloc_buffer
(
rec_buff_p
,
rec_buff_size_p
,
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 */
bit_buff
->
blob_pos
=
*
rec_buff_p
+
info
->
rec_len
;
bit_buff
->
blob_end
=
bit_buff
->
blob_pos
+
info
->
blob_len
;
...
...
@@ -1580,15 +1582,18 @@ _ma_mempack_get_block_info(MARIA_HA *maria,
size_t
*
rec_buff_size_p
,
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
);
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
);
/* _ma_alloc_rec_buff sets my_errno on error */
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 */
bit_buff
->
blob_pos
=
*
rec_buff_p
;
bit_buff
->
blob_end
=
*
rec_buff_p
+
info
->
blob_len
;
...
...
storage/maria/maria_def.h
View file @
f24038b8
...
...
@@ -1198,7 +1198,7 @@ extern my_bool _ma_read_cache(MARIA_HA *, IO_CACHE *info, uchar *buff,
uint
re_read_if_possibly
);
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
,
size_t
new_size
);
size_t
new_size
,
myf
flag
);
extern
size_t
_ma_rec_unpack
(
MARIA_HA
*
info
,
uchar
*
to
,
uchar
*
from
,
size_t
reclength
);
extern
my_bool
_ma_rec_check
(
MARIA_HA
*
info
,
const
uchar
*
record
,
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment