summaryrefslogtreecommitdiff
path: root/sql
diff options
context:
space:
mode:
authorMarko Mäkelä <marko.makela@mariadb.com>2019-01-17 12:33:31 +0200
committerMarko Mäkelä <marko.makela@mariadb.com>2019-01-17 12:38:46 +0200
commit77cbaa96ad9a6077d271bf97b0c0dc8cdf5b5991 (patch)
treeba8d2c87f8d15d064657315f48ccb58aa117b95a /sql
parent62a0224666fd0b2790837288cafde009f02e2b52 (diff)
parent8e80fd6bfdf2ea7d1870662ecd4d8129f3c76301 (diff)
downloadmariadb-git-77cbaa96ad9a6077d271bf97b0c0dc8cdf5b5991.tar.gz
Merge 10.2 into 10.3
Diffstat (limited to 'sql')
-rw-r--r--sql/sql_class.cc21
-rw-r--r--sql/sql_lex.cc1
-rw-r--r--sql/sys_vars.cc8
3 files changed, 17 insertions, 13 deletions
diff --git a/sql/sql_class.cc b/sql/sql_class.cc
index 3881f6f28ad..2efdf91f6a9 100644
--- a/sql/sql_class.cc
+++ b/sql/sql_class.cc
@@ -1513,6 +1513,7 @@ void THD::cleanup(void)
auto_inc_intervals_in_cur_stmt_for_binlog.empty();
mysql_ull_cleanup(this);
+ stmt_map.reset();
/* All metadata locks must have been released by now. */
DBUG_ASSERT(!mdl_context.has_locks());
@@ -3983,11 +3984,13 @@ void Statement_map::erase(Statement *statement)
void Statement_map::reset()
{
/* Must be first, hash_free will reset st_hash.records */
- mysql_mutex_lock(&LOCK_prepared_stmt_count);
- DBUG_ASSERT(prepared_stmt_count >= st_hash.records);
- prepared_stmt_count-= st_hash.records;
- mysql_mutex_unlock(&LOCK_prepared_stmt_count);
-
+ if (st_hash.records)
+ {
+ mysql_mutex_lock(&LOCK_prepared_stmt_count);
+ DBUG_ASSERT(prepared_stmt_count >= st_hash.records);
+ prepared_stmt_count-= st_hash.records;
+ mysql_mutex_unlock(&LOCK_prepared_stmt_count);
+ }
my_hash_reset(&names_hash);
my_hash_reset(&st_hash);
last_found_statement= 0;
@@ -3996,12 +3999,8 @@ void Statement_map::reset()
Statement_map::~Statement_map()
{
- /* Must go first, hash_free will reset st_hash.records */
- mysql_mutex_lock(&LOCK_prepared_stmt_count);
- DBUG_ASSERT(prepared_stmt_count >= st_hash.records);
- prepared_stmt_count-= st_hash.records;
- mysql_mutex_unlock(&LOCK_prepared_stmt_count);
-
+ /* Statement_map::reset() should be called prior to destructor. */
+ DBUG_ASSERT(!st_hash.records);
my_hash_free(&names_hash);
my_hash_free(&st_hash);
}
diff --git a/sql/sql_lex.cc b/sql/sql_lex.cc
index c048aeeb585..40d5e53c7a0 100644
--- a/sql/sql_lex.cc
+++ b/sql/sql_lex.cc
@@ -4049,6 +4049,7 @@ bool st_select_lex::optimize_unflattened_subqueries(bool const_only)
inner_join->select_options|= SELECT_DESCRIBE;
}
res= inner_join->optimize();
+ sl->update_used_tables();
sl->update_correlated_cache();
is_correlated_unit|= sl->is_correlated;
inner_join->select_options= save_options;
diff --git a/sql/sys_vars.cc b/sql/sys_vars.cc
index 369c9a6222a..921d00eaf2a 100644
--- a/sql/sys_vars.cc
+++ b/sql/sys_vars.cc
@@ -3483,11 +3483,15 @@ static Sys_var_charptr Sys_system_time_zone(
CMD_LINE_HELP_ONLY,
IN_SYSTEM_CHARSET, DEFAULT(system_time_zone));
+/*
+ If One use views with prepared statements this should be bigger than
+ table_open_cache (now we allow 2 times bigger value)
+*/
static Sys_var_ulong Sys_table_def_size(
"table_definition_cache",
"The number of cached table definitions",
GLOBAL_VAR(tdc_size), CMD_LINE(REQUIRED_ARG),
- VALID_RANGE(TABLE_DEF_CACHE_MIN, 512*1024),
+ VALID_RANGE(TABLE_DEF_CACHE_MIN, 2*1024*1024),
DEFAULT(TABLE_DEF_CACHE_DEFAULT), BLOCK_SIZE(1));
@@ -3499,7 +3503,7 @@ static bool fix_table_open_cache(sys_var *, THD *, enum_var_type)
return false;
}
-
+/* Check the table_definition_cache comment if makes changes */
static Sys_var_ulong Sys_table_cache_size(
"table_open_cache", "The number of cached open tables",
GLOBAL_VAR(tc_size), CMD_LINE(REQUIRED_ARG),