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
1fa7e75f
Commit
1fa7e75f
authored
Sep 10, 2024
by
Sergei Golubchik
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
cleanup: TABLE_SHARE::lock_share() helper
also: renames, s/const/constexpr/ for consistency
parent
d51c0518
Changes
6
Show whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
29 additions
and
36 deletions
+29
-36
sql/sql_base.cc
sql/sql_base.cc
+6
-14
sql/sql_table.cc
sql/sql_table.cc
+9
-7
sql/sql_table.h
sql/sql_table.h
+5
-5
sql/table.cc
sql/table.cc
+2
-4
sql/table.h
sql/table.h
+3
-0
sql/vector_mhnsw.cc
sql/vector_mhnsw.cc
+4
-6
No files found.
sql/sql_base.cc
View file @
1fa7e75f
...
...
@@ -9838,12 +9838,10 @@ int TABLE::hlindex_open(uint nr)
DBUG_ASSERT
(
nr
==
s
->
keys
);
if
(
!
hlindex
)
{
if
(
s
->
tmp_table
==
NO_TMP_TABLE
)
mysql_mutex_lock
(
&
s
->
LOCK_share
);
s
->
lock_share
();
if
(
!
s
->
hlindex
)
{
if
(
s
->
tmp_table
==
NO_TMP_TABLE
)
mysql_mutex_unlock
(
&
s
->
LOCK_share
);
s
->
unlock_share
();
TABLE_SHARE
*
share
;
char
*
path
=
NULL
;
size_t
path_len
=
s
->
normalized_path
.
length
+
HLINDEX_BUF_LEN
;
...
...
@@ -9867,26 +9865,20 @@ int TABLE::hlindex_open(uint nr)
return
1
;
}
if
(
s
->
tmp_table
==
NO_TMP_TABLE
)
mysql_mutex_lock
(
&
s
->
LOCK_share
);
s
->
lock_share
();
if
(
!
s
->
hlindex
)
{
s
->
hlindex
=
share
;
if
(
s
->
tmp_table
==
NO_TMP_TABLE
)
mysql_mutex_unlock
(
&
s
->
LOCK_share
);
s
->
unlock_share
();
}
else
{
if
(
s
->
tmp_table
==
NO_TMP_TABLE
)
mysql_mutex_unlock
(
&
s
->
LOCK_share
);
s
->
unlock_share
();
free_table_share
(
share
);
}
}
else
{
if
(
s
->
tmp_table
==
NO_TMP_TABLE
)
mysql_mutex_unlock
(
&
s
->
LOCK_share
);
}
s
->
unlock_share
();
TABLE
*
table
=
(
TABLE
*
)
alloc_root
(
&
mem_root
,
sizeof
(
*
table
));
if
(
!
table
||
open_table_from_share
(
in_use
,
s
->
hlindex
,
&
empty_clex_str
,
db_stat
,
EXTRA_RECORD
,
in_use
->
open_options
,
table
,
0
))
...
...
sql/sql_table.cc
View file @
1fa7e75f
...
...
@@ -2082,13 +2082,14 @@ bool log_drop_table(THD *thd, const LEX_CSTRING *db_name,
}
static
int
get_hlindex_keys
(
THD
*
thd
,
const
LEX_CSTRING
*
db
,
const
LEX_CSTRING
*
table_name
,
const
char
*
path
,
uint
*
keys
,
uint
*
total_keys
)
static
int
get_hlindex_keys_by_open
(
THD
*
thd
,
const
LEX_CSTRING
*
db
,
const
LEX_CSTRING
*
table_name
,
const
char
*
path
,
uint
*
keys
,
uint
*
total_keys
)
{
TABLE_SHARE
share
;
int
error
;
DBUG_ENTER
(
"get_hlindex_keys"
);
DBUG_ENTER
(
"get_hlindex_keys
_by_open
"
);
init_tmp_table_share
(
thd
,
&
share
,
db
->
str
,
0
,
table_name
->
str
,
path
,
1
);
error
=
open_table_def
(
thd
,
&
share
,
GTS_TABLE
|
GTS_USE_DISCOVERY
);
...
...
@@ -2145,8 +2146,8 @@ bool quick_rm_table(THD *thd, handlerton *base, const LEX_CSTRING *db,
if
(
flags
&
QRMT_HANDLER
)
{
uint
keys
,
total_keys
;
int
hlindex_error
=
get_hlindex_keys
(
thd
,
db
,
table_name
,
path
,
&
keys
,
&
total_keys
);
int
hlindex_error
=
get_hlindex_keys
_by_open
(
thd
,
db
,
table_name
,
path
,
&
keys
,
&
total_keys
);
error
|=
ha_delete_table
(
thd
,
base
,
path
,
db
,
table_name
,
0
)
>
0
;
if
(
!
hlindex_error
)
{
...
...
@@ -5423,7 +5424,8 @@ mysql_rename_table(handlerton *base, const LEX_CSTRING *old_db,
char
*
idx_to_end
=
strmov
(
idx_to
,
to_base
);
uint
keys
,
total_keys
;
if
(
!
get_hlindex_keys
(
thd
,
new_db
,
new_name
,
to
,
&
keys
,
&
total_keys
))
if
(
!
get_hlindex_keys_by_open
(
thd
,
new_db
,
new_name
,
to
,
&
keys
,
&
total_keys
))
{
for
(
uint
i
=
keys
;
i
<
total_keys
;
i
++
)
{
...
...
sql/sql_table.h
View file @
1fa7e75f
...
...
@@ -63,9 +63,9 @@ enum enum_explain_filename_mode
#define WFRM_BACKUP_ORIGINAL 16
/* Flags for conversion functions. */
static
const
uint
FN_FROM_IS_TMP
=
1
<<
0
;
static
const
uint
FN_TO_IS_TMP
=
1
<<
1
;
static
const
uint
FN_IS_TMP
=
FN_FROM_IS_TMP
|
FN_TO_IS_TMP
;
static
const
expr
uint
FN_FROM_IS_TMP
=
1
<<
0
;
static
const
expr
uint
FN_TO_IS_TMP
=
1
<<
1
;
static
const
expr
uint
FN_IS_TMP
=
FN_FROM_IS_TMP
|
FN_TO_IS_TMP
;
/* Remove .frm table metadata. */
static
constexpr
uint
QRMT_FRM
=
1
<<
2
;
/* Remove .par partitioning metadata. */
...
...
@@ -75,9 +75,9 @@ static constexpr uint QRMT_HANDLER= 1 << 4;
/* Default behaviour is to drop .FRM and handler, but not .par. */
static
constexpr
uint
QRMT_DEFAULT
=
QRMT_FRM
|
QRMT_HANDLER
;
/** Don't resolve MySQL's fake "foo.sym" symbolic directory names. */
static
const
uint
SKIP_SYMDIR_ACCESS
=
1
<<
5
;
static
const
expr
uint
SKIP_SYMDIR_ACCESS
=
1
<<
5
;
/** Don't check foreign key constraints while renaming table */
static
const
uint
NO_FK_CHECKS
=
1
<<
6
;
static
const
expr
uint
NO_FK_CHECKS
=
1
<<
6
;
uint
filename_to_tablename
(
const
char
*
from
,
char
*
to
,
size_t
to_length
,
bool
stay_quiet
=
false
);
...
...
sql/table.cc
View file @
1fa7e75f
...
...
@@ -8284,8 +8284,7 @@ void TABLE::mark_columns_used_by_virtual_fields(void)
if
(
s
->
check_set_initialized
)
return
;
if
(
s
->
tmp_table
==
NO_TMP_TABLE
)
mysql_mutex_lock
(
&
s
->
LOCK_share
);
s
->
lock_share
();
if
(
s
->
check_set
)
{
/* Mark fields used by check constraint */
...
...
@@ -8325,8 +8324,7 @@ void TABLE::mark_columns_used_by_virtual_fields(void)
bitmap_clear_all
(
&
tmp_set
);
}
s
->
check_set_initialized
=
v_keys
;
if
(
s
->
tmp_table
==
NO_TMP_TABLE
)
mysql_mutex_unlock
(
&
s
->
LOCK_share
);
s
->
unlock_share
();
}
/* Add fields used by CHECK CONSTRAINT to read map */
...
...
sql/table.h
View file @
1fa7e75f
...
...
@@ -728,6 +728,9 @@ struct TABLE_SHARE
mysql_mutex_t
LOCK_share
;
/* To protect TABLE_SHARE */
mysql_mutex_t
LOCK_statistics
;
/* To protect against concurrent load */
void
lock_share
()
{
if
(
!
tmp_table
)
mysql_mutex_lock
(
&
LOCK_share
);
}
void
unlock_share
()
{
if
(
!
tmp_table
)
mysql_mutex_unlock
(
&
LOCK_share
);
}
TDC_element
*
tdc
;
LEX_CUSTRING
tabledef_version
;
...
...
sql/vector_mhnsw.cc
View file @
1fa7e75f
...
...
@@ -392,13 +392,13 @@ class MHNSW_Context : public Sql_alloc
virtual
void
reset
(
TABLE_SHARE
*
share
)
{
mysql_mutex_lock
(
&
share
->
LOCK_share
);
share
->
lock_share
(
);
if
(
static_cast
<
MHNSW_Context
*>
(
share
->
hlindex
->
hlindex_data
)
==
this
)
{
share
->
hlindex
->
hlindex_data
=
nullptr
;
--
refcnt
;
}
mysql_mutex_unlock
(
&
share
->
LOCK_share
);
share
->
unlock_share
(
);
}
void
release
(
TABLE
*
table
)
...
...
@@ -603,8 +603,7 @@ MHNSW_Trx *MHNSW_Trx::get_from_thd(TABLE *table, bool for_update)
MHNSW_Context
*
MHNSW_Context
::
get_from_share
(
TABLE_SHARE
*
share
,
TABLE
*
table
)
{
if
(
share
->
tmp_table
==
NO_TMP_TABLE
)
mysql_mutex_lock
(
&
share
->
LOCK_share
);
share
->
lock_share
();
auto
ctx
=
static_cast
<
MHNSW_Context
*>
(
share
->
hlindex
->
hlindex_data
);
if
(
!
ctx
&&
table
)
{
...
...
@@ -615,8 +614,7 @@ MHNSW_Context *MHNSW_Context::get_from_share(TABLE_SHARE *share, TABLE *table)
}
if
(
ctx
)
ctx
->
refcnt
++
;
if
(
share
->
tmp_table
==
NO_TMP_TABLE
)
mysql_mutex_unlock
(
&
share
->
LOCK_share
);
share
->
unlock_share
();
return
ctx
;
}
...
...
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