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
90a48a45
Commit
90a48a45
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
bc954e75
Changes
6
Hide 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 @
90a48a45
...
@@ -9838,12 +9838,10 @@ int TABLE::hlindex_open(uint nr)
...
@@ -9838,12 +9838,10 @@ int TABLE::hlindex_open(uint nr)
DBUG_ASSERT
(
nr
==
s
->
keys
);
DBUG_ASSERT
(
nr
==
s
->
keys
);
if
(
!
hlindex
)
if
(
!
hlindex
)
{
{
if
(
s
->
tmp_table
==
NO_TMP_TABLE
)
s
->
lock_share
();
mysql_mutex_lock
(
&
s
->
LOCK_share
);
if
(
!
s
->
hlindex
)
if
(
!
s
->
hlindex
)
{
{
if
(
s
->
tmp_table
==
NO_TMP_TABLE
)
s
->
unlock_share
();
mysql_mutex_unlock
(
&
s
->
LOCK_share
);
TABLE_SHARE
*
share
;
TABLE_SHARE
*
share
;
char
*
path
=
NULL
;
char
*
path
=
NULL
;
size_t
path_len
=
s
->
normalized_path
.
length
+
HLINDEX_BUF_LEN
;
size_t
path_len
=
s
->
normalized_path
.
length
+
HLINDEX_BUF_LEN
;
...
@@ -9867,26 +9865,20 @@ int TABLE::hlindex_open(uint nr)
...
@@ -9867,26 +9865,20 @@ int TABLE::hlindex_open(uint nr)
return
1
;
return
1
;
}
}
if
(
s
->
tmp_table
==
NO_TMP_TABLE
)
s
->
lock_share
();
mysql_mutex_lock
(
&
s
->
LOCK_share
);
if
(
!
s
->
hlindex
)
if
(
!
s
->
hlindex
)
{
{
s
->
hlindex
=
share
;
s
->
hlindex
=
share
;
if
(
s
->
tmp_table
==
NO_TMP_TABLE
)
s
->
unlock_share
();
mysql_mutex_unlock
(
&
s
->
LOCK_share
);
}
}
else
else
{
{
if
(
s
->
tmp_table
==
NO_TMP_TABLE
)
s
->
unlock_share
();
mysql_mutex_unlock
(
&
s
->
LOCK_share
);
free_table_share
(
share
);
free_table_share
(
share
);
}
}
}
}
else
else
{
s
->
unlock_share
();
if
(
s
->
tmp_table
==
NO_TMP_TABLE
)
mysql_mutex_unlock
(
&
s
->
LOCK_share
);
}
TABLE
*
table
=
(
TABLE
*
)
alloc_root
(
&
mem_root
,
sizeof
(
*
table
));
TABLE
*
table
=
(
TABLE
*
)
alloc_root
(
&
mem_root
,
sizeof
(
*
table
));
if
(
!
table
||
open_table_from_share
(
in_use
,
s
->
hlindex
,
&
empty_clex_str
,
if
(
!
table
||
open_table_from_share
(
in_use
,
s
->
hlindex
,
&
empty_clex_str
,
db_stat
,
EXTRA_RECORD
,
in_use
->
open_options
,
table
,
0
))
db_stat
,
EXTRA_RECORD
,
in_use
->
open_options
,
table
,
0
))
...
...
sql/sql_table.cc
View file @
90a48a45
...
@@ -2083,13 +2083,14 @@ bool log_drop_table(THD *thd, const LEX_CSTRING *db_name,
...
@@ -2083,13 +2083,14 @@ bool log_drop_table(THD *thd, const LEX_CSTRING *db_name,
}
}
static
int
get_hlindex_keys
(
THD
*
thd
,
const
LEX_CSTRING
*
db
,
static
int
get_hlindex_keys_by_open
(
THD
*
thd
,
const
LEX_CSTRING
*
db
,
const
LEX_CSTRING
*
table_name
,
const
char
*
path
,
const
LEX_CSTRING
*
table_name
,
uint
*
keys
,
uint
*
total_keys
)
const
char
*
path
,
uint
*
keys
,
uint
*
total_keys
)
{
{
TABLE_SHARE
share
;
TABLE_SHARE
share
;
int
error
;
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
);
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
);
error
=
open_table_def
(
thd
,
&
share
,
GTS_TABLE
|
GTS_USE_DISCOVERY
);
...
@@ -2146,8 +2147,8 @@ bool quick_rm_table(THD *thd, handlerton *base, const LEX_CSTRING *db,
...
@@ -2146,8 +2147,8 @@ bool quick_rm_table(THD *thd, handlerton *base, const LEX_CSTRING *db,
if
(
flags
&
QRMT_HANDLER
)
if
(
flags
&
QRMT_HANDLER
)
{
{
uint
keys
,
total_keys
;
uint
keys
,
total_keys
;
int
hlindex_error
=
get_hlindex_keys
(
thd
,
db
,
table_name
,
path
,
&
keys
,
int
hlindex_error
=
get_hlindex_keys
_by_open
(
thd
,
db
,
table_name
,
path
,
&
total_keys
);
&
keys
,
&
total_keys
);
error
|=
ha_delete_table
(
thd
,
base
,
path
,
db
,
table_name
,
0
)
>
0
;
error
|=
ha_delete_table
(
thd
,
base
,
path
,
db
,
table_name
,
0
)
>
0
;
if
(
!
hlindex_error
)
if
(
!
hlindex_error
)
{
{
...
@@ -5424,7 +5425,8 @@ mysql_rename_table(handlerton *base, const LEX_CSTRING *old_db,
...
@@ -5424,7 +5425,8 @@ mysql_rename_table(handlerton *base, const LEX_CSTRING *old_db,
char
*
idx_to_end
=
strmov
(
idx_to
,
to_base
);
char
*
idx_to_end
=
strmov
(
idx_to
,
to_base
);
uint
keys
,
total_keys
;
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
++
)
for
(
uint
i
=
keys
;
i
<
total_keys
;
i
++
)
{
{
...
...
sql/sql_table.h
View file @
90a48a45
...
@@ -63,9 +63,9 @@ enum enum_explain_filename_mode
...
@@ -63,9 +63,9 @@ enum enum_explain_filename_mode
#define WFRM_BACKUP_ORIGINAL 16
#define WFRM_BACKUP_ORIGINAL 16
/* Flags for conversion functions. */
/* Flags for conversion functions. */
static
const
uint
FN_FROM_IS_TMP
=
1
<<
0
;
static
const
expr
uint
FN_FROM_IS_TMP
=
1
<<
0
;
static
const
uint
FN_TO_IS_TMP
=
1
<<
1
;
static
const
expr
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_IS_TMP
=
FN_FROM_IS_TMP
|
FN_TO_IS_TMP
;
/* Remove .frm table metadata. */
/* Remove .frm table metadata. */
static
constexpr
uint
QRMT_FRM
=
1
<<
2
;
static
constexpr
uint
QRMT_FRM
=
1
<<
2
;
/* Remove .par partitioning metadata. */
/* Remove .par partitioning metadata. */
...
@@ -75,9 +75,9 @@ static constexpr uint QRMT_HANDLER= 1 << 4;
...
@@ -75,9 +75,9 @@ static constexpr uint QRMT_HANDLER= 1 << 4;
/* Default behaviour is to drop .FRM and handler, but not .par. */
/* Default behaviour is to drop .FRM and handler, but not .par. */
static
constexpr
uint
QRMT_DEFAULT
=
QRMT_FRM
|
QRMT_HANDLER
;
static
constexpr
uint
QRMT_DEFAULT
=
QRMT_FRM
|
QRMT_HANDLER
;
/** Don't resolve MySQL's fake "foo.sym" symbolic directory names. */
/** 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 */
/** 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
,
uint
filename_to_tablename
(
const
char
*
from
,
char
*
to
,
size_t
to_length
,
bool
stay_quiet
=
false
);
bool
stay_quiet
=
false
);
...
...
sql/table.cc
View file @
90a48a45
...
@@ -8284,8 +8284,7 @@ void TABLE::mark_columns_used_by_virtual_fields(void)
...
@@ -8284,8 +8284,7 @@ void TABLE::mark_columns_used_by_virtual_fields(void)
if
(
s
->
check_set_initialized
)
if
(
s
->
check_set_initialized
)
return
;
return
;
if
(
s
->
tmp_table
==
NO_TMP_TABLE
)
s
->
lock_share
();
mysql_mutex_lock
(
&
s
->
LOCK_share
);
if
(
s
->
check_set
)
if
(
s
->
check_set
)
{
{
/* Mark fields used by check constraint */
/* Mark fields used by check constraint */
...
@@ -8325,8 +8324,7 @@ void TABLE::mark_columns_used_by_virtual_fields(void)
...
@@ -8325,8 +8324,7 @@ void TABLE::mark_columns_used_by_virtual_fields(void)
bitmap_clear_all
(
&
tmp_set
);
bitmap_clear_all
(
&
tmp_set
);
}
}
s
->
check_set_initialized
=
v_keys
;
s
->
check_set_initialized
=
v_keys
;
if
(
s
->
tmp_table
==
NO_TMP_TABLE
)
s
->
unlock_share
();
mysql_mutex_unlock
(
&
s
->
LOCK_share
);
}
}
/* Add fields used by CHECK CONSTRAINT to read map */
/* Add fields used by CHECK CONSTRAINT to read map */
...
...
sql/table.h
View file @
90a48a45
...
@@ -728,6 +728,9 @@ struct TABLE_SHARE
...
@@ -728,6 +728,9 @@ struct TABLE_SHARE
mysql_mutex_t
LOCK_share
;
/* To protect TABLE_SHARE */
mysql_mutex_t
LOCK_share
;
/* To protect TABLE_SHARE */
mysql_mutex_t
LOCK_statistics
;
/* To protect against concurrent load */
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
;
TDC_element
*
tdc
;
LEX_CUSTRING
tabledef_version
;
LEX_CUSTRING
tabledef_version
;
...
...
sql/vector_mhnsw.cc
View file @
90a48a45
...
@@ -437,13 +437,13 @@ class MHNSW_Context : public Sql_alloc
...
@@ -437,13 +437,13 @@ class MHNSW_Context : public Sql_alloc
virtual
void
reset
(
TABLE_SHARE
*
share
)
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
)
if
(
static_cast
<
MHNSW_Context
*>
(
share
->
hlindex
->
hlindex_data
)
==
this
)
{
{
share
->
hlindex
->
hlindex_data
=
nullptr
;
share
->
hlindex
->
hlindex_data
=
nullptr
;
--
refcnt
;
--
refcnt
;
}
}
mysql_mutex_unlock
(
&
share
->
LOCK_share
);
share
->
unlock_share
(
);
}
}
void
release
(
TABLE
*
table
)
void
release
(
TABLE
*
table
)
...
@@ -648,8 +648,7 @@ MHNSW_Trx *MHNSW_Trx::get_from_thd(TABLE *table, bool for_update)
...
@@ -648,8 +648,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
)
MHNSW_Context
*
MHNSW_Context
::
get_from_share
(
TABLE_SHARE
*
share
,
TABLE
*
table
)
{
{
if
(
share
->
tmp_table
==
NO_TMP_TABLE
)
share
->
lock_share
();
mysql_mutex_lock
(
&
share
->
LOCK_share
);
auto
ctx
=
static_cast
<
MHNSW_Context
*>
(
share
->
hlindex
->
hlindex_data
);
auto
ctx
=
static_cast
<
MHNSW_Context
*>
(
share
->
hlindex
->
hlindex_data
);
if
(
!
ctx
&&
table
)
if
(
!
ctx
&&
table
)
{
{
...
@@ -660,8 +659,7 @@ MHNSW_Context *MHNSW_Context::get_from_share(TABLE_SHARE *share, TABLE *table)
...
@@ -660,8 +659,7 @@ MHNSW_Context *MHNSW_Context::get_from_share(TABLE_SHARE *share, TABLE *table)
}
}
if
(
ctx
)
if
(
ctx
)
ctx
->
refcnt
++
;
ctx
->
refcnt
++
;
if
(
share
->
tmp_table
==
NO_TMP_TABLE
)
share
->
unlock_share
();
mysql_mutex_unlock
(
&
share
->
LOCK_share
);
return
ctx
;
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