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
24232ec1
Commit
24232ec1
authored
Oct 09, 2019
by
Marko Mäkelä
Browse files
Options
Browse Files
Download
Plain Diff
Merge 10.1 into 10.2
parents
ed0793e0
d95f96ad
Changes
8
Show whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
62 additions
and
131 deletions
+62
-131
sql/sql_base.cc
sql/sql_base.cc
+0
-26
sql/sql_class.cc
sql/sql_class.cc
+0
-1
sql/sql_class.h
sql/sql_class.h
+0
-3
sql/sql_show.cc
sql/sql_show.cc
+1
-4
sql/sql_statistics.cc
sql/sql_statistics.cc
+60
-74
sql/sql_statistics.h
sql/sql_statistics.h
+1
-2
storage/innobase/include/buf0flu.h
storage/innobase/include/buf0flu.h
+0
-10
storage/xtradb/include/buf0flu.h
storage/xtradb/include/buf0flu.h
+0
-11
No files found.
sql/sql_base.cc
View file @
24232ec1
...
...
@@ -3635,32 +3635,6 @@ open_and_process_table(THD *thd, TABLE_LIST *tables, uint *counter, uint flags,
goto
end
;
}
if
(
get_use_stat_tables_mode
(
thd
)
>
NEVER
&&
tables
->
table
)
{
TABLE_SHARE
*
table_share
=
tables
->
table
->
s
;
if
(
table_share
&&
table_share
->
table_category
==
TABLE_CATEGORY_USER
&&
table_share
->
tmp_table
==
NO_TMP_TABLE
)
{
if
(
table_share
->
stats_cb
.
stats_can_be_read
||
!
alloc_statistics_for_table_share
(
thd
,
table_share
,
FALSE
))
{
if
(
table_share
->
stats_cb
.
stats_can_be_read
)
{
KEY
*
key_info
=
table_share
->
key_info
;
KEY
*
key_info_end
=
key_info
+
table_share
->
keys
;
KEY
*
table_key_info
=
tables
->
table
->
key_info
;
for
(
;
key_info
<
key_info_end
;
key_info
++
,
table_key_info
++
)
table_key_info
->
read_stats
=
key_info
->
read_stats
;
Field
**
field_ptr
=
table_share
->
field
;
Field
**
table_field_ptr
=
tables
->
table
->
field
;
for
(
;
*
field_ptr
;
field_ptr
++
,
table_field_ptr
++
)
(
*
table_field_ptr
)
->
read_stats
=
(
*
field_ptr
)
->
read_stats
;
tables
->
table
->
stats_is_read
=
table_share
->
stats_cb
.
stats_is_read
;
}
}
}
}
process_view_routines:
/*
Again we may need cache all routines used by this view and add
...
...
sql/sql_class.cc
View file @
24232ec1
...
...
@@ -843,7 +843,6 @@ THD::THD(my_thread_id id, bool is_wsrep_applier)
memset
(
&
invoker_host
,
0
,
sizeof
(
invoker_host
));
prepare_derived_at_open
=
FALSE
;
create_tmp_table_for_derived
=
FALSE
;
force_read_stats
=
FALSE
;
save_prep_leaf_list
=
FALSE
;
org_charset
=
0
;
/* Restore THR_THD */
...
...
sql/sql_class.h
View file @
24232ec1
...
...
@@ -2391,9 +2391,6 @@ class THD :public Statement,
*/
bool
create_tmp_table_for_derived
;
/* The flag to force reading statistics from EITS tables */
bool
force_read_stats
;
bool
save_prep_leaf_list
;
/* container for handler's private per-connection data */
...
...
sql/sql_show.cc
View file @
24232ec1
...
...
@@ -4398,7 +4398,6 @@ fill_schema_table_by_open(THD *thd, bool is_show_fields_or_keys,
SQLCOM_SHOW_FIELDS is used because it satisfies
'only_view_structure()'.
*/
thd
->
force_read_stats
=
get_schema_table_idx
(
schema_table
)
==
SCH_STATISTICS
;
lex
->
sql_command
=
SQLCOM_SHOW_FIELDS
;
result
=
(
thd
->
open_temporary_tables
(
table_list
)
||
open_normal_and_derived_tables
(
thd
,
table_list
,
...
...
@@ -4414,9 +4413,6 @@ fill_schema_table_by_open(THD *thd, bool is_show_fields_or_keys,
*/
lex
->
sql_command
=
old_lex
->
sql_command
;
(
void
)
read_statistics_for_tables_if_needed
(
thd
,
table_list
);
thd
->
force_read_stats
=
false
;
DEBUG_SYNC
(
thd
,
"after_open_table_ignore_flush"
);
/*
...
...
@@ -6284,6 +6280,7 @@ static int get_schema_stat_record(THD *thd, TABLE_LIST *tables,
KEY
*
key_info
=
show_table
->
s
->
key_info
;
if
(
show_table
->
file
)
{
(
void
)
read_statistics_for_tables
(
thd
,
tables
);
show_table
->
file
->
info
(
HA_STATUS_VARIABLE
|
HA_STATUS_NO_LOCK
|
HA_STATUS_TIME
);
...
...
sql/sql_statistics.cc
View file @
24232ec1
...
...
@@ -2171,54 +2171,6 @@ int alloc_statistics_for_table(THD* thd, TABLE *table)
}
/**
@brief
Check whether any persistent statistics for the processed command is needed
@param
thd The thread handle
@details
The function checks whether any persitent statistics for the processed
command is needed to be read.
@retval
TRUE statistics is needed to be read
@retval
FALSE Otherwise
*/
static
inline
bool
statistics_for_command_is_needed
(
THD
*
thd
)
{
if
(
thd
->
bootstrap
||
thd
->
variables
.
use_stat_tables
==
NEVER
)
return
FALSE
;
if
(
thd
->
force_read_stats
)
return
TRUE
;
switch
(
thd
->
lex
->
sql_command
)
{
case
SQLCOM_SELECT
:
case
SQLCOM_INSERT
:
case
SQLCOM_INSERT_SELECT
:
case
SQLCOM_UPDATE
:
case
SQLCOM_UPDATE_MULTI
:
case
SQLCOM_DELETE
:
case
SQLCOM_DELETE_MULTI
:
case
SQLCOM_REPLACE
:
case
SQLCOM_REPLACE_SELECT
:
case
SQLCOM_CREATE_TABLE
:
case
SQLCOM_SET_OPTION
:
case
SQLCOM_DO
:
break
;
default:
return
FALSE
;
}
return
TRUE
;
}
/**
@brief
Allocate memory for the statistical data used by a table share
...
...
@@ -2227,8 +2179,6 @@ inline bool statistics_for_command_is_needed(THD *thd)
thd Thread handler
@param
table_share Table share for which the memory for statistical data is allocated
@param
is_safe TRUE <-> at any time only one thread can perform the function
@note
The function allocates the memory for the statistical data on a table in the
...
...
@@ -2237,8 +2187,6 @@ inline bool statistics_for_command_is_needed(THD *thd)
mysql.index_stats. The memory is allocated for the statistics on the table,
on the tables's columns, and on the table's indexes. The memory is allocated
in the table_share's mem_root.
If the parameter is_safe is TRUE then it is guaranteed that at any given time
only one thread is executed the code of the function.
@retval
0 If the memory for all statistical data has been successfully allocated
...
...
@@ -2257,16 +2205,10 @@ inline bool statistics_for_command_is_needed(THD *thd)
Here the second and the third threads try to allocate the memory for
statistical data at the same time. The precautions are taken to
guarantee the correctness of the allocation.
@note
Currently the function always is called with the parameter is_safe set
to FALSE.
*/
int
alloc_statistics_for_table_share
(
THD
*
thd
,
TABLE_SHARE
*
table_share
,
bool
is_safe
)
static
int
alloc_statistics_for_table_share
(
THD
*
thd
,
TABLE_SHARE
*
table_share
)
{
Field
**
field_ptr
;
KEY
*
key_info
,
*
end
;
TABLE_STATISTICS_CB
*
stats_cb
=
&
table_share
->
stats_cb
;
...
...
@@ -2276,15 +2218,10 @@ int alloc_statistics_for_table_share(THD* thd, TABLE_SHARE *table_share,
DEBUG_SYNC
(
thd
,
"statistics_mem_alloc_start1"
);
DEBUG_SYNC
(
thd
,
"statistics_mem_alloc_start2"
);
if
(
!
statistics_for_command_is_needed
(
thd
))
DBUG_RETURN
(
1
);
if
(
!
is_safe
)
mysql_mutex_lock
(
&
table_share
->
LOCK_share
);
if
(
stats_cb
->
stats_can_be_read
)
{
if
(
!
is_safe
)
mysql_mutex_unlock
(
&
table_share
->
LOCK_share
);
DBUG_RETURN
(
0
);
}
...
...
@@ -2296,7 +2233,6 @@ int alloc_statistics_for_table_share(THD* thd, TABLE_SHARE *table_share,
sizeof
(
Table_statistics
));
if
(
!
table_stats
)
{
if
(
!
is_safe
)
mysql_mutex_unlock
(
&
table_share
->
LOCK_share
);
DBUG_RETURN
(
1
);
}
...
...
@@ -2369,7 +2305,6 @@ int alloc_statistics_for_table_share(THD* thd, TABLE_SHARE *table_share,
if
(
column_stats
&&
index_stats
&&
idx_avg_frequency
)
stats_cb
->
stats_can_be_read
=
TRUE
;
if
(
!
is_safe
)
mysql_mutex_unlock
(
&
table_share
->
LOCK_share
);
DBUG_RETURN
(
0
);
...
...
@@ -3145,9 +3080,6 @@ bool statistics_for_tables_is_needed(THD *thd, TABLE_LIST *tables)
if
(
!
tables
)
return
FALSE
;
if
(
!
statistics_for_command_is_needed
(
thd
))
return
FALSE
;
/*
Do not read statistics for any query that explicity involves
statistical tables, failure to to do so we may end up
...
...
@@ -3278,11 +3210,65 @@ int read_histograms_for_table(THD *thd, TABLE *table, TABLE_LIST *stat_tables)
*/
int
read_statistics_for_tables_if_needed
(
THD
*
thd
,
TABLE_LIST
*
tables
)
{
switch
(
thd
->
lex
->
sql_command
)
{
case
SQLCOM_SELECT
:
case
SQLCOM_INSERT
:
case
SQLCOM_INSERT_SELECT
:
case
SQLCOM_UPDATE
:
case
SQLCOM_UPDATE_MULTI
:
case
SQLCOM_DELETE
:
case
SQLCOM_DELETE_MULTI
:
case
SQLCOM_REPLACE
:
case
SQLCOM_REPLACE_SELECT
:
case
SQLCOM_CREATE_TABLE
:
case
SQLCOM_SET_OPTION
:
case
SQLCOM_DO
:
return
read_statistics_for_tables
(
thd
,
tables
);
default:
return
0
;
}
}
int
read_statistics_for_tables
(
THD
*
thd
,
TABLE_LIST
*
tables
)
{
TABLE_LIST
stat_tables
[
STATISTICS_TABLES
];
Open_tables_backup
open_tables_backup
;
DBUG_ENTER
(
"read_statistics_for_tables_if_needed"
);
DBUG_ENTER
(
"read_statistics_for_tables"
);
if
(
thd
->
bootstrap
||
thd
->
variables
.
use_stat_tables
==
NEVER
)
DBUG_RETURN
(
0
);
for
(
TABLE_LIST
*
tl
=
tables
;
tl
;
tl
=
tl
->
next_global
)
{
if
(
tl
->
table
)
{
TABLE_SHARE
*
table_share
=
tl
->
table
->
s
;
if
(
table_share
&&
table_share
->
table_category
==
TABLE_CATEGORY_USER
&&
table_share
->
tmp_table
==
NO_TMP_TABLE
)
{
if
(
table_share
->
stats_cb
.
stats_can_be_read
||
!
alloc_statistics_for_table_share
(
thd
,
table_share
))
{
if
(
table_share
->
stats_cb
.
stats_can_be_read
)
{
KEY
*
key_info
=
table_share
->
key_info
;
KEY
*
key_info_end
=
key_info
+
table_share
->
keys
;
KEY
*
table_key_info
=
tl
->
table
->
key_info
;
for
(
;
key_info
<
key_info_end
;
key_info
++
,
table_key_info
++
)
table_key_info
->
read_stats
=
key_info
->
read_stats
;
Field
**
field_ptr
=
table_share
->
field
;
Field
**
table_field_ptr
=
tl
->
table
->
field
;
for
(
;
*
field_ptr
;
field_ptr
++
,
table_field_ptr
++
)
(
*
table_field_ptr
)
->
read_stats
=
(
*
field_ptr
)
->
read_stats
;
tl
->
table
->
stats_is_read
=
table_share
->
stats_cb
.
stats_is_read
;
}
}
}
}
}
DEBUG_SYNC
(
thd
,
"statistics_read_start"
);
...
...
sql/sql_statistics.h
View file @
24232ec1
...
...
@@ -89,9 +89,8 @@ Use_stat_tables_mode get_use_stat_tables_mode(THD *thd)
}
int
read_statistics_for_tables_if_needed
(
THD
*
thd
,
TABLE_LIST
*
tables
);
int
read_statistics_for_tables
(
THD
*
thd
,
TABLE_LIST
*
tables
);
int
collect_statistics_for_table
(
THD
*
thd
,
TABLE
*
table
);
int
alloc_statistics_for_table_share
(
THD
*
thd
,
TABLE_SHARE
*
share
,
bool
is_safe
);
void
delete_stat_values_for_table_share
(
TABLE_SHARE
*
table_share
);
int
alloc_statistics_for_table
(
THD
*
thd
,
TABLE
*
table
);
int
update_statistics_for_table
(
THD
*
thd
,
TABLE
*
table
);
...
...
storage/innobase/include/buf0flu.h
View file @
24232ec1
...
...
@@ -167,16 +167,6 @@ void
buf_flush_wait_flushed
(
lsn_t
new_oldest
);
/******************************************************************//**
Waits until a flush batch of the given type ends. This is called by
a thread that only wants to wait for a flush to end but doesn't do
any flushing itself. */
void
buf_flush_wait_batch_end_wait_only
(
/*===============================*/
buf_pool_t
*
buf_pool
,
/*!< in: buffer pool instance */
buf_flush_t
type
);
/*!< in: BUF_FLUSH_LRU
or BUF_FLUSH_LIST */
/********************************************************************//**
This function should be called at a mini-transaction commit, if a page was
modified in it. Puts the block to the list of modified blocks, if it not
...
...
storage/xtradb/include/buf0flu.h
View file @
24232ec1
...
...
@@ -142,17 +142,6 @@ buf_flush_wait_batch_end(
buf_pool_t
*
buf_pool
,
/*!< in: buffer pool instance */
buf_flush_t
type
);
/*!< in: BUF_FLUSH_LRU
or BUF_FLUSH_LIST */
/******************************************************************//**
Waits until a flush batch of the given type ends. This is called by
a thread that only wants to wait for a flush to end but doesn't do
any flushing itself. */
UNIV_INTERN
void
buf_flush_wait_batch_end_wait_only
(
/*===============================*/
buf_pool_t
*
buf_pool
,
/*!< in: buffer pool instance */
buf_flush_t
type
);
/*!< in: BUF_FLUSH_LRU
or BUF_FLUSH_LIST */
/********************************************************************//**
This function should be called at a mini-transaction commit, if a page was
modified in it. Puts the block to the list of modified blocks, if it not
...
...
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