summaryrefslogtreecommitdiff
path: root/sql
diff options
context:
space:
mode:
authorSergei Golubchik <serg@mariadb.org>2018-05-11 13:12:18 +0200
committerSergei Golubchik <serg@mariadb.org>2018-05-11 13:15:10 +0200
commitc9717dc0190731c656cce31fa6e39a3db123e3af (patch)
tree3db056a3f50e565294d127edb5339afb0a994749 /sql
parent33721d91389759a917463a044fbd6f0b7654d629 (diff)
parent1d411a8a440922f0538c1be254d6f4396af453a1 (diff)
downloadmariadb-git-c9717dc0190731c656cce31fa6e39a3db123e3af.tar.gz
Merge branch '10.2' into 10.3
Diffstat (limited to 'sql')
-rw-r--r--sql/ha_partition.cc2
-rw-r--r--sql/item.cc8
-rw-r--r--sql/item.h1
-rw-r--r--sql/item_cmpfunc.cc42
-rw-r--r--sql/item_func.cc3
-rw-r--r--sql/item_func.h8
-rw-r--r--sql/item_row.cc2
-rw-r--r--sql/item_sum.cc3
-rw-r--r--sql/opt_subselect.cc23
-rw-r--r--sql/slave.cc6
-rw-r--r--sql/sql_acl.cc1
-rw-r--r--sql/sql_admin.cc7
-rw-r--r--sql/sql_base.cc3
-rw-r--r--sql/sql_class.cc4
-rw-r--r--sql/sql_class.h1
-rw-r--r--sql/sql_connect.cc4
-rw-r--r--sql/sql_insert.cc6
-rw-r--r--sql/sql_parse.cc54
-rw-r--r--sql/sql_parse.h1
-rw-r--r--sql/sql_partition.cc9
-rw-r--r--sql/sql_prepare.cc8
-rw-r--r--sql/sql_select.cc6
-rw-r--r--sql/sql_statistics.cc4
-rw-r--r--sql/table.cc2
-rw-r--r--sql/wsrep_applier.cc8
-rw-r--r--sql/wsrep_hton.cc44
-rw-r--r--sql/wsrep_mysqld.cc35
-rw-r--r--sql/wsrep_mysqld.h2
-rw-r--r--sql/wsrep_thd.cc38
29 files changed, 203 insertions, 132 deletions
diff --git a/sql/ha_partition.cc b/sql/ha_partition.cc
index 7df76fcc298..c119e379998 100644
--- a/sql/ha_partition.cc
+++ b/sql/ha_partition.cc
@@ -10645,6 +10645,8 @@ int ha_partition::check_misplaced_rows(uint read_part_id, bool do_repair)
{
/* Only need to read the partitioning fields. */
bitmap_union(table->read_set, &m_part_info->full_part_field_set);
+ if (table->vcol_set)
+ bitmap_union(table->vcol_set, &m_part_info->full_part_field_set);
}
if ((result= m_file[read_part_id]->ha_rnd_init(1)))
diff --git a/sql/item.cc b/sql/item.cc
index 448c22432d7..bfd5ed78bf8 100644
--- a/sql/item.cc
+++ b/sql/item.cc
@@ -508,6 +508,8 @@ Item::Item(THD *thd):
marker= 0;
maybe_null=null_value=with_sum_func=with_window_func=with_field=0;
in_rollup= 0;
+ with_param= 0;
+
/* Initially this item is not attached to any JOIN_TAB. */
join_tab_idx= MAX_TABLES;
@@ -549,6 +551,7 @@ Item::Item(THD *thd, Item *item):
in_rollup(item->in_rollup),
null_value(item->null_value),
with_sum_func(item->with_sum_func),
+ with_param(item->with_param),
with_window_func(item->with_window_func),
with_field(item->with_field),
fixed(item->fixed),
@@ -1687,6 +1690,9 @@ bool Item_sp_variable::fix_fields_from_item(THD *thd, Item **, const Item *it)
max_length= it->max_length;
decimals= it->decimals;
unsigned_flag= it->unsigned_flag;
+ with_param= 1;
+ if (thd->lex->current_select && thd->lex->current_select->master_unit()->item)
+ thd->lex->current_select->master_unit()->item->with_param= 1;
fixed= 1;
collation.set(it->collation.collation, it->collation.derivation);
@@ -8144,6 +8150,7 @@ void Item_ref::set_properties()
split_sum_func() doesn't try to change the reference.
*/
with_sum_func= (*ref)->with_sum_func;
+ with_param= (*ref)->with_param;
with_window_func= (*ref)->with_window_func;
with_field= (*ref)->with_field;
fixed= 1;
@@ -8569,6 +8576,7 @@ Item_cache_wrapper::Item_cache_wrapper(THD *thd, Item *item_arg):
Type_std_attributes::set(orig_item);
maybe_null= orig_item->maybe_null;
with_sum_func= orig_item->with_sum_func;
+ with_param= orig_item->with_param;
with_field= orig_item->with_field;
name= item_arg->name;
m_with_subquery= orig_item->with_subquery();
diff --git a/sql/item.h b/sql/item.h
index 88dee1ae067..a9750e0619b 100644
--- a/sql/item.h
+++ b/sql/item.h
@@ -751,6 +751,7 @@ public:
of a query with ROLLUP */
bool null_value; /* if item is null */
bool with_sum_func; /* True if item contains a sum func */
+ bool with_param; /* True if contains an SP parameter */
bool with_window_func; /* True if item contains a window func */
/**
True if any item except Item_sum contains a field. Set during parsing.
diff --git a/sql/item_cmpfunc.cc b/sql/item_cmpfunc.cc
index 78a557f5a1b..a912c834f94 100644
--- a/sql/item_cmpfunc.cc
+++ b/sql/item_cmpfunc.cc
@@ -1292,6 +1292,7 @@ bool Item_in_optimizer::fix_left(THD *thd)
}
eval_not_null_tables(NULL);
with_sum_func= args[0]->with_sum_func;
+ with_param= args[0]->with_param || args[1]->with_param;
with_field= args[0]->with_field;
if ((const_item_cache= args[0]->const_item()))
{
@@ -1340,6 +1341,7 @@ bool Item_in_optimizer::fix_fields(THD *thd, Item **ref)
m_with_subquery= true;
with_sum_func= with_sum_func || args[1]->with_sum_func;
with_field= with_field || args[1]->with_field;
+ with_param= args[0]->with_param || args[1]->with_param;
used_tables_and_const_cache_join(args[1]);
fixed= 1;
return FALSE;
@@ -1889,6 +1891,7 @@ void Item_func_interval::fix_length_and_dec()
used_tables_and_const_cache_join(row);
not_null_tables_cache= row->not_null_tables();
with_sum_func= with_sum_func || row->with_sum_func;
+ with_param= with_param || row->with_param;
with_field= with_field || row->with_field;
}
@@ -4526,6 +4529,7 @@ Item_cond::fix_fields(THD *thd, Item **ref)
List_iterator<Item> li(list);
Item *item;
uchar buff[sizeof(char*)]; // Max local vars in function
+ bool is_and_cond= functype() == Item_func::COND_AND_FUNC;
not_null_tables_cache= 0;
used_tables_and_const_cache_init();
@@ -4588,26 +4592,33 @@ Item_cond::fix_fields(THD *thd, Item **ref)
(item= *li.ref())->check_cols(1))
return TRUE; /* purecov: inspected */
used_tables_cache|= item->used_tables();
- if (item->const_item())
+ if (item->const_item() && !item->with_param &&
+ !item->is_expensive() && !cond_has_datetime_is_null(item))
{
- if (!item->is_expensive() && !cond_has_datetime_is_null(item) &&
- item->val_int() == 0)
+ if (item->val_int() == is_and_cond && top_level())
{
/*
- This is "... OR false_cond OR ..."
+ a. This is "... AND true_cond AND ..."
+ In this case, true_cond has no effect on cond_and->not_null_tables()
+ b. This is "... OR false_cond/null cond OR ..."
In this case, false_cond has no effect on cond_or->not_null_tables()
*/
}
else
{
/*
- This is "... OR const_cond OR ..."
+ a. This is "... AND false_cond/null_cond AND ..."
+ The whole condition is FALSE/UNKNOWN.
+ b. This is "... OR const_cond OR ..."
In this case, cond_or->not_null_tables()=0, because the condition
const_cond might evaluate to true (regardless of whether some tables
were NULL-complemented).
*/
+ not_null_tables_cache= (table_map) 0;
and_tables_cache= (table_map) 0;
}
+ if (thd->is_error())
+ return TRUE;
}
else
{
@@ -4619,6 +4630,7 @@ Item_cond::fix_fields(THD *thd, Item **ref)
}
with_sum_func|= item->with_sum_func;
+ with_param|= item->with_param;
with_field|= item->with_field;
m_with_subquery|= item->with_subquery();
with_window_func|= item->with_window_func;
@@ -4634,30 +4646,36 @@ bool
Item_cond::eval_not_null_tables(void *opt_arg)
{
Item *item;
+ bool is_and_cond= functype() == Item_func::COND_AND_FUNC;
List_iterator<Item> li(list);
not_null_tables_cache= (table_map) 0;
and_tables_cache= ~(table_map) 0;
while ((item=li++))
{
table_map tmp_table_map;
- if (item->const_item())
+ if (item->const_item() && !item->with_param &&
+ !item->is_expensive() && !cond_has_datetime_is_null(item))
{
- if (!item->is_expensive() && !cond_has_datetime_is_null(item) &&
- item->val_int() == 0)
+ if (item->val_int() == is_and_cond && top_level())
{
/*
- This is "... OR false_cond OR ..."
+ a. This is "... AND true_cond AND ..."
+ In this case, true_cond has no effect on cond_and->not_null_tables()
+ b. This is "... OR false_cond/null cond OR ..."
In this case, false_cond has no effect on cond_or->not_null_tables()
*/
}
else
{
/*
- This is "... OR const_cond OR ..."
+ a. This is "... AND false_cond/null_cond AND ..."
+ The whole condition is FALSE/UNKNOWN.
+ b. This is "... OR const_cond OR ..."
In this case, cond_or->not_null_tables()=0, because the condition
- some_cond_or might be true regardless of what tables are
- NULL-complemented.
+ const_cond might evaluate to true (regardless of whether some tables
+ were NULL-complemented).
*/
+ not_null_tables_cache= (table_map) 0;
and_tables_cache= (table_map) 0;
}
}
diff --git a/sql/item_func.cc b/sql/item_func.cc
index ff2ab6ec6da..43aa8cd6613 100644
--- a/sql/item_func.cc
+++ b/sql/item_func.cc
@@ -148,6 +148,7 @@ void Item_func::sync_with_sum_func_and_with_field(List<Item> &list)
with_sum_func|= item->with_sum_func;
with_window_func|= item->with_window_func;
with_field|= item->with_field;
+ with_param|= item->with_param;
}
}
@@ -367,6 +368,7 @@ Item_func::fix_fields(THD *thd, Item **ref)
maybe_null=1;
with_sum_func= with_sum_func || item->with_sum_func;
+ with_param= with_param || item->with_param;
with_window_func= with_window_func || item->with_window_func;
with_field= with_field || item->with_field;
used_tables_and_const_cache_join(item);
@@ -3301,6 +3303,7 @@ udf_handler::fix_fields(THD *thd, Item_func_or_sum *func,
func->maybe_null=1;
func->with_sum_func= func->with_sum_func || item->with_sum_func;
func->with_field= func->with_field || item->with_field;
+ func->with_param= func->with_param || item->with_param;
func->With_subquery_cache::join(item);
func->used_tables_and_const_cache_join(item);
f_args.arg_type[i]=item->result_type();
diff --git a/sql/item_func.h b/sql/item_func.h
index 29ff14f7b39..8504fe41f37 100644
--- a/sql/item_func.h
+++ b/sql/item_func.h
@@ -82,16 +82,19 @@ public:
{
with_sum_func= 0;
with_field= 0;
+ with_param= 0;
}
Item_func(THD *thd, Item *a): Item_func_or_sum(thd, a)
{
with_sum_func= a->with_sum_func;
+ with_param= a->with_param;
with_field= a->with_field;
}
Item_func(THD *thd, Item *a, Item *b):
Item_func_or_sum(thd, a, b)
{
with_sum_func= a->with_sum_func || b->with_sum_func;
+ with_param= a->with_param || b->with_param;
with_field= a->with_field || b->with_field;
}
Item_func(THD *thd, Item *a, Item *b, Item *c):
@@ -99,6 +102,7 @@ public:
{
with_sum_func= a->with_sum_func || b->with_sum_func || c->with_sum_func;
with_field= a->with_field || b->with_field || c->with_field;
+ with_param= a->with_param || b->with_param || c->with_param;
}
Item_func(THD *thd, Item *a, Item *b, Item *c, Item *d):
Item_func_or_sum(thd, a, b, c, d)
@@ -107,6 +111,8 @@ public:
c->with_sum_func || d->with_sum_func;
with_field= a->with_field || b->with_field ||
c->with_field || d->with_field;
+ with_param= a->with_param || b->with_param ||
+ c->with_param || d->with_param;
}
Item_func(THD *thd, Item *a, Item *b, Item *c, Item *d, Item* e):
Item_func_or_sum(thd, a, b, c, d, e)
@@ -115,6 +121,8 @@ public:
c->with_sum_func || d->with_sum_func || e->with_sum_func;
with_field= a->with_field || b->with_field ||
c->with_field || d->with_field || e->with_field;
+ with_param= a->with_param || b->with_param ||
+ c->with_param || d->with_param || e->with_param;
}
Item_func(THD *thd, List<Item> &list):
Item_func_or_sum(thd, list)
diff --git a/sql/item_row.cc b/sql/item_row.cc
index 64794093bec..74ea9ecc0c2 100644
--- a/sql/item_row.cc
+++ b/sql/item_row.cc
@@ -65,6 +65,7 @@ bool Item_row::fix_fields(THD *thd, Item **ref)
with_window_func = with_window_func || item->with_window_func;
with_field= with_field || item->with_field;
m_with_subquery|= item->with_subquery();
+ with_param|= item->with_param;
}
fixed= 1;
return FALSE;
@@ -178,4 +179,3 @@ Item* Item_row::build_clone(THD *thd)
}
return copy;
}
-
diff --git a/sql/item_sum.cc b/sql/item_sum.cc
index 62cf339d708..607ed0a135a 100644
--- a/sql/item_sum.cc
+++ b/sql/item_sum.cc
@@ -1133,6 +1133,7 @@ Item_sum_num::fix_fields(THD *thd, Item **ref)
return TRUE;
set_if_bigger(decimals, args[i]->decimals);
m_with_subquery|= args[i]->with_subquery();
+ with_param|= args[i]->with_param;
with_window_func|= args[i]->with_window_func;
}
result_field=0;
@@ -1166,6 +1167,7 @@ Item_sum_hybrid::fix_fields(THD *thd, Item **ref)
DBUG_RETURN(TRUE);
m_with_subquery= args[0]->with_subquery();
+ with_param= args[0]->with_param;
with_window_func|= args[0]->with_window_func;
fix_length_and_dec();
@@ -3898,6 +3900,7 @@ Item_func_group_concat::fix_fields(THD *thd, Item **ref)
args[i]->check_cols(1))
return TRUE;
m_with_subquery|= args[i]->with_subquery();
+ with_param|= args[i]->with_param;
with_window_func|= args[i]->with_window_func;
}
diff --git a/sql/opt_subselect.cc b/sql/opt_subselect.cc
index ef69f27bb1e..1d2fd5548a5 100644
--- a/sql/opt_subselect.cc
+++ b/sql/opt_subselect.cc
@@ -3708,8 +3708,7 @@ bool setup_sj_materialization_part1(JOIN_TAB *sjm_tab)
sjm= emb_sj_nest->sj_mat_info;
thd= tab->join->thd;
/* First the calls come to the materialization function */
- //List<Item> &item_list= emb_sj_nest->sj_subq_pred->unit->first_select()->item_list;
-
+
DBUG_ASSERT(sjm->is_used);
/*
Set up the table to write to, do as select_union::create_result_table does
@@ -3718,10 +3717,22 @@ bool setup_sj_materialization_part1(JOIN_TAB *sjm_tab)
sjm->sjm_table_param.bit_fields_as_long= TRUE;
SELECT_LEX *subq_select= emb_sj_nest->sj_subq_pred->unit->first_select();
const LEX_CSTRING sj_materialize_name= { STRING_WITH_LEN("sj-materialize") };
- Ref_ptr_array p_items= subq_select->ref_pointer_array;
- for (uint i= 0; i < subq_select->item_list.elements; i++)
- sjm->sjm_table_cols.push_back(p_items[i], thd->mem_root);
-
+ List_iterator<Item> it(subq_select->item_list);
+ Item *item;
+ while((item= it++))
+ {
+ /*
+ This semi-join replaced the subquery (subq_select) and so on
+ re-executing it will not be prepared. To use the Items from its
+ select list we have to prepare (fix_fields) them
+ */
+ if (!item->fixed && item->fix_fields(thd, it.ref()))
+ DBUG_RETURN(TRUE);
+ item= *(it.ref()); // it can be changed by fix_fields
+ DBUG_ASSERT(!item->name.length || item->name.length == strlen(item->name.str));
+ sjm->sjm_table_cols.push_back(item, thd->mem_root);
+ }
+
sjm->sjm_table_param.field_count= subq_select->item_list.elements;
sjm->sjm_table_param.force_not_null_cols= TRUE;
diff --git a/sql/slave.cc b/sql/slave.cc
index cdf3dfaae45..483c4675b3b 100644
--- a/sql/slave.cc
+++ b/sql/slave.cc
@@ -4358,10 +4358,10 @@ static int exec_relay_log_event(THD* thd, Relay_log_info* rli,
DBUG_RETURN(1);
#ifdef WITH_WSREP
- mysql_mutex_lock(&thd->LOCK_wsrep_thd);
+ mysql_mutex_lock(&thd->LOCK_thd_data);
if (thd->wsrep_conflict_state == NO_CONFLICT)
{
- mysql_mutex_unlock(&thd->LOCK_wsrep_thd);
+ mysql_mutex_unlock(&thd->LOCK_thd_data);
#endif /* WITH_WSREP */
if (slave_trans_retries)
{
@@ -4439,7 +4439,7 @@ static int exec_relay_log_event(THD* thd, Relay_log_info* rli,
#ifdef WITH_WSREP
}
else
- mysql_mutex_unlock(&thd->LOCK_wsrep_thd);
+ mysql_mutex_unlock(&thd->LOCK_thd_data);
#endif /* WITH_WSREP */
thread_safe_increment64(&rli->executed_entries);
diff --git a/sql/sql_acl.cc b/sql/sql_acl.cc
index 2b783b0835a..adad8622bc3 100644
--- a/sql/sql_acl.cc
+++ b/sql/sql_acl.cc
@@ -12276,6 +12276,7 @@ static bool send_plugin_request_packet(MPVIO_EXT *mpvio,
const char *client_auth_plugin=
((st_mysql_auth *) (plugin_decl(mpvio->plugin)->info))->client_auth_plugin;
+ DBUG_EXECUTE_IF("auth_disconnect", { vio_close(net->vio); DBUG_RETURN(1); });
DBUG_ASSERT(client_auth_plugin);
/*
diff --git a/sql/sql_admin.cc b/sql/sql_admin.cc
index 8c11886998e..f2523b44317 100644
--- a/sql/sql_admin.cc
+++ b/sql/sql_admin.cc
@@ -1175,7 +1175,9 @@ send_result_message:
}
else
{
- if (trans_commit_stmt(thd) || trans_commit_implicit(thd))
+ if (trans_commit_stmt(thd) ||
+ (stmt_causes_implicit_commit(thd, CF_IMPLICIT_COMMIT_END) &&
+ trans_commit_implicit(thd)))
goto err;
}
close_thread_tables(thd);
@@ -1209,7 +1211,8 @@ send_result_message:
err:
/* Make sure this table instance is not reused after the failure. */
trans_rollback_stmt(thd);
- trans_rollback(thd);
+ if (stmt_causes_implicit_commit(thd, CF_IMPLICIT_COMMIT_END))
+ trans_rollback(thd);
if (table && table->table)
{
table->table->m_needs_reopen= true;
diff --git a/sql/sql_base.cc b/sql/sql_base.cc
index daae00fac76..6f5d4875b04 100644
--- a/sql/sql_base.cc
+++ b/sql/sql_base.cc
@@ -811,10 +811,7 @@ void close_thread_tables(THD *thd)
we will exit this function a few lines below.
*/
if (! thd->lex->requires_prelocking())
- {
- thd->locked_tables_list.reopen_tables(thd, true);
DBUG_VOID_RETURN;
- }
/*
We are in the top-level statement of a prelocked statement,
diff --git a/sql/sql_class.cc b/sql/sql_class.cc
index 36f1dc72342..92795a8f797 100644
--- a/sql/sql_class.cc
+++ b/sql/sql_class.cc
@@ -881,7 +881,6 @@ THD::THD(my_thread_id id, bool is_wsrep_applier, bool skip_global_sys_var_lock)
*scramble= '\0';
#ifdef WITH_WSREP
- mysql_mutex_init(key_LOCK_wsrep_thd, &LOCK_wsrep_thd, MY_MUTEX_INIT_FAST);
wsrep_ws_handle.trx_id = WSREP_UNDEFINED_TRX_ID;
wsrep_ws_handle.opaque = NULL;
wsrep_retry_counter = 0;
@@ -1718,9 +1717,6 @@ THD::~THD()
mysql_mutex_unlock(&LOCK_thd_kill);
#ifdef WITH_WSREP
- mysql_mutex_lock(&LOCK_wsrep_thd);
- mysql_mutex_unlock(&LOCK_wsrep_thd);
- mysql_mutex_destroy(&LOCK_wsrep_thd);
delete wsrep_rgi;
#endif
if (!free_connection_done)
diff --git a/sql/sql_class.h b/sql/sql_class.h
index 232af1db02a..49b6267c656 100644
--- a/sql/sql_class.h
+++ b/sql/sql_class.h
@@ -4632,7 +4632,6 @@ public:
query_id_t wsrep_last_query_id;
enum wsrep_query_state wsrep_query_state;
enum wsrep_conflict_state wsrep_conflict_state;
- mysql_mutex_t LOCK_wsrep_thd;
wsrep_trx_meta_t wsrep_trx_meta;
uint32 wsrep_rand;
Relay_log_info *wsrep_rli;
diff --git a/sql/sql_connect.cc b/sql/sql_connect.cc
index 2f9c6c0b17a..b48070b9c8f 100644
--- a/sql/sql_connect.cc
+++ b/sql/sql_connect.cc
@@ -1407,9 +1407,9 @@ void do_handle_one_connection(CONNECT *connect)
#ifdef WITH_WSREP
if (WSREP(thd))
{
- mysql_mutex_lock(&thd->LOCK_wsrep_thd);
+ mysql_mutex_lock(&thd->LOCK_thd_data);
thd->wsrep_query_state= QUERY_EXITING;
- mysql_mutex_unlock(&thd->LOCK_wsrep_thd);
+ mysql_mutex_unlock(&thd->LOCK_thd_data);
}
#endif
end_thread:
diff --git a/sql/sql_insert.cc b/sql/sql_insert.cc
index fa92a3256df..d36d9aa82d2 100644
--- a/sql/sql_insert.cc
+++ b/sql/sql_insert.cc
@@ -4586,17 +4586,17 @@ bool select_create::send_eof()
#ifdef WITH_WSREP
if (WSREP_ON)
{
- mysql_mutex_lock(&thd->LOCK_wsrep_thd);
+ mysql_mutex_lock(&thd->LOCK_thd_data);
if (thd->wsrep_conflict_state != NO_CONFLICT)
{
WSREP_DEBUG("select_create commit failed, thd: %lld err: %d %s",
(longlong) thd->thread_id, thd->wsrep_conflict_state,
thd->query());
- mysql_mutex_unlock(&thd->LOCK_wsrep_thd);
+ mysql_mutex_unlock(&thd->LOCK_thd_data);
abort_result_set();
DBUG_RETURN(true);
}
- mysql_mutex_unlock(&thd->LOCK_wsrep_thd);
+ mysql_mutex_unlock(&thd->LOCK_thd_data);
}
#endif /* WITH_WSREP */
}
diff --git a/sql/sql_parse.cc b/sql/sql_parse.cc
index fde23b613bf..e821a8f59de 100644
--- a/sql/sql_parse.cc
+++ b/sql/sql_parse.cc
@@ -420,7 +420,7 @@ static bool some_non_temp_table_to_be_updated(THD *thd, TABLE_LIST *tables)
/*
- Implicitly commit a active transaction if statement requires so.
+ Check whether the statement implicitly commits an active transaction.
@param thd Thread handle.
@param mask Bitmask used for the SQL command match.
@@ -428,7 +428,7 @@ static bool some_non_temp_table_to_be_updated(THD *thd, TABLE_LIST *tables)
@return 0 No implicit commit
@return 1 Do a commit
*/
-static bool stmt_causes_implicit_commit(THD *thd, uint mask)
+bool stmt_causes_implicit_commit(THD *thd, uint mask)
{
LEX *lex= thd->lex;
bool skip= FALSE;
@@ -1214,13 +1214,13 @@ bool do_command(THD *thd)
#ifdef WITH_WSREP
if (WSREP(thd))
{
- mysql_mutex_lock(&thd->LOCK_wsrep_thd);
+ mysql_mutex_lock(&thd->LOCK_thd_data);
thd->wsrep_query_state= QUERY_IDLE;
if (thd->wsrep_conflict_state==MUST_ABORT)
{
wsrep_client_rollback(thd);
}
- mysql_mutex_unlock(&thd->LOCK_wsrep_thd);
+ mysql_mutex_unlock(&thd->LOCK_thd_data);
}
#endif /* WITH_WSREP */
@@ -1266,15 +1266,15 @@ bool do_command(THD *thd)
packet_length= my_net_read_packet(net, 1);
#ifdef WITH_WSREP
if (WSREP(thd)) {
- mysql_mutex_lock(&thd->LOCK_wsrep_thd);
+ mysql_mutex_lock(&thd->LOCK_thd_data);
/* these THD's are aborted or are aborting during being idle */
if (thd->wsrep_conflict_state == ABORTING)
{
while (thd->wsrep_conflict_state == ABORTING) {
- mysql_mutex_unlock(&thd->LOCK_wsrep_thd);
+ mysql_mutex_unlock(&thd->LOCK_thd_data);
my_sleep(1000);
- mysql_mutex_lock(&thd->LOCK_wsrep_thd);
+ mysql_mutex_lock(&thd->LOCK_thd_data);
}
thd->store_globals();
}
@@ -1284,7 +1284,7 @@ bool do_command(THD *thd)
}
thd->wsrep_query_state= QUERY_EXEC;
- mysql_mutex_unlock(&thd->LOCK_wsrep_thd);
+ mysql_mutex_unlock(&thd->LOCK_thd_data);
}
#endif /* WITH_WSREP */
@@ -1297,14 +1297,14 @@ bool do_command(THD *thd)
#ifdef WITH_WSREP
if (WSREP(thd))
{
- mysql_mutex_lock(&thd->LOCK_wsrep_thd);
+ mysql_mutex_lock(&thd->LOCK_thd_data);
if (thd->wsrep_conflict_state == MUST_ABORT)
{
DBUG_PRINT("wsrep",("aborted for wsrep rollback: %lu",
(ulong) thd->real_id));
wsrep_client_rollback(thd);
}
- mysql_mutex_unlock(&thd->LOCK_wsrep_thd);
+ mysql_mutex_unlock(&thd->LOCK_thd_data);
}
#endif /* WITH_WSREP */
@@ -1582,7 +1582,7 @@ bool dispatch_command(enum enum_server_command command, THD *thd,
thd->wsrep_PA_safe= true;
}
- mysql_mutex_lock(&thd->LOCK_wsrep_thd);
+ mysql_mutex_lock(&thd->LOCK_thd_data);
thd->wsrep_query_state= QUERY_EXEC;
if (thd->wsrep_conflict_state== RETRY_AUTOCOMMIT)
{
@@ -1599,14 +1599,14 @@ bool dispatch_command(enum enum_server_command command, THD *thd,
my_message(ER_LOCK_DEADLOCK, "Deadlock: wsrep aborted transaction",
MYF(0));
WSREP_DEBUG("Deadlock error for: %s", thd->query());
- mysql_mutex_unlock(&thd->LOCK_wsrep_thd);
+ mysql_mutex_unlock(&thd->LOCK_thd_data);
thd->reset_killed();
thd->mysys_var->abort = 0;
thd->wsrep_conflict_state = NO_CONFLICT;
thd->wsrep_retry_counter = 0;
goto dispatch_end;
}
- mysql_mutex_unlock(&thd->LOCK_wsrep_thd);
+ mysql_mutex_unlock(&thd->LOCK_thd_data);
}
#endif /* WITH_WSREP */
#if defined(ENABLED_PROFILING)
@@ -2378,10 +2378,10 @@ com_multi_end:
DBUG_ASSERT((command != COM_QUIT && command != COM_STMT_CLOSE)
|| thd->get_stmt_da()->is_disabled());
/* wsrep BF abort in query exec phase */
- mysql_mutex_lock(&thd->LOCK_wsrep_thd);
+ mysql_mutex_lock(&thd->LOCK_thd_data);
do_end_of_statement= thd->wsrep_conflict_state != REPLAYING &&
thd->wsrep_conflict_state != RETRY_AUTOCOMMIT;
- mysql_mutex_unlock(&thd->LOCK_wsrep_thd);
+ mysql_mutex_unlock(&thd->LOCK_thd_data);
}
else
do_end_of_statement= true;
@@ -6307,6 +6307,10 @@ finish:
lex->unit.cleanup();
+ /* close/reopen tables that were marked to need reopen under LOCK TABLES */
+ if (! thd->lex->requires_prelocking())
+ thd->locked_tables_list.reopen_tables(thd, true);
+
if (! thd->in_sub_stmt)
{
if (thd->killed != NOT_KILLED)
@@ -7805,13 +7809,22 @@ static void wsrep_mysql_parse(THD *thd, char *rawbuf, uint length,
com_statement_info[thd->get_command()].m_key);
MYSQL_SET_STATEMENT_TEXT(thd->m_statement_psi, thd->query(),
thd->query_length());
+
+ DBUG_EXECUTE_IF("sync.wsrep_retry_autocommit",
+ {
+ const char act[]=
+ "now "
+ "SIGNAL wsrep_retry_autocommit_reached "
+ "WAIT_FOR wsrep_retry_autocommit_continue";
+ DBUG_ASSERT(!debug_sync_set_action(thd, STRING_WITH_LEN(act)));
+ });
}
mysql_parse(thd, rawbuf, length, parser_state, is_com_multi,
is_next_command);
if (WSREP(thd)) {
/* wsrep BF abort in query exec phase */
- mysql_mutex_lock(&thd->LOCK_wsrep_thd);
+ mysql_mutex_lock(&thd->LOCK_thd_data);
if (thd->wsrep_conflict_state == MUST_ABORT) {
wsrep_client_rollback(thd);
@@ -7820,8 +7833,11 @@ static void wsrep_mysql_parse(THD *thd, char *rawbuf, uint length,
if (thd->wsrep_conflict_state == MUST_REPLAY)
{
+ mysql_mutex_unlock(&thd->LOCK_thd_data);
if (thd->lex->explain)
delete_explain_query(thd->lex);
+ mysql_mutex_lock(&thd->LOCK_thd_data);
+
wsrep_replay_transaction(thd);
}
@@ -7863,13 +7879,13 @@ static void wsrep_mysql_parse(THD *thd, char *rawbuf, uint length,
if (thd->wsrep_conflict_state != REPLAYING)
thd->wsrep_retry_counter= 0; // reset
}
- mysql_mutex_unlock(&thd->LOCK_wsrep_thd);
+ mysql_mutex_unlock(&thd->LOCK_thd_data);
thd->reset_killed();
}
else
{
set_if_smaller(thd->wsrep_retry_counter, 0); // reset; eventually ok
- mysql_mutex_unlock(&thd->LOCK_wsrep_thd);
+ mysql_mutex_unlock(&thd->LOCK_thd_data);
}
}
@@ -8898,7 +8914,7 @@ kill_one_thread(THD *thd, longlong id, killed_state kill_signal, killed_type typ
if (((thd->security_ctx->master_access & SUPER_ACL) ||
thd->security_ctx->user_matches(tmp->security_ctx)) &&
- !wsrep_thd_is_BF(tmp, true))
+ !wsrep_thd_is_BF(tmp, false))
{
tmp->awake_no_mutex(kill_signal);
error=0;
diff --git a/sql/sql_parse.h b/sql/sql_parse.h
index 5e5f7b50ba3..1027872898a 100644
--- a/sql/sql_parse.h
+++ b/sql/sql_parse.h
@@ -85,6 +85,7 @@ bool check_identifier_name(LEX_CSTRING *str, uint max_char_length,
uint err_code, const char *param_for_err_msg);
bool mysql_test_parse_for_slave(THD *thd,char *inBuf,uint length);
bool sqlcom_can_generate_row_events(const THD *thd);
+bool stmt_causes_implicit_commit(THD *thd, uint mask);
bool is_update_query(enum enum_sql_command command);
bool is_log_table_write_query(enum enum_sql_command command);
bool alloc_query(THD *thd, const char *packet, size_t packet_length);
diff --git a/sql/sql_partition.cc b/sql/sql_partition.cc
index fb33a893a12..ae5d3de557d 100644
--- a/sql/sql_partition.cc
+++ b/sql/sql_partition.cc
@@ -525,9 +525,16 @@ static bool create_full_part_field_array(THD *thd, TABLE *table,
full_part_field_array may be NULL if storage engine supports native
partitioning.
*/
+ table->vcol_set= table->read_set= &part_info->full_part_field_set;
if ((ptr= part_info->full_part_field_array))
for (; *ptr; ptr++)
- bitmap_set_bit(&part_info->full_part_field_set, (*ptr)->field_index);
+ {
+ if ((*ptr)->vcol_info)
+ table->mark_virtual_col(*ptr);
+ else
+ bitmap_fast_test_and_set(table->read_set, (*ptr)->field_index);
+ }
+ table->default_column_bitmaps();
end:
DBUG_RETURN(result);
diff --git a/sql/sql_prepare.cc b/sql/sql_prepare.cc
index f763613064c..6db7bc777cf 100644
--- a/sql/sql_prepare.cc
+++ b/sql/sql_prepare.cc
@@ -4196,7 +4196,7 @@ reexecute:
if (WSREP_ON)
{
- mysql_mutex_lock(&thd->LOCK_wsrep_thd);
+ mysql_mutex_lock(&thd->LOCK_thd_data);
switch (thd->wsrep_conflict_state)
{
case CERT_FAILURE:
@@ -4213,7 +4213,7 @@ reexecute:
default:
break;
}
- mysql_mutex_unlock(&thd->LOCK_wsrep_thd);
+ mysql_mutex_unlock(&thd->LOCK_thd_data);
}
#endif /* WITH_WSREP */
@@ -4392,7 +4392,7 @@ reexecute:
if (WSREP_ON)
{
- mysql_mutex_lock(&thd->LOCK_wsrep_thd);
+ mysql_mutex_lock(&thd->LOCK_thd_data);
switch (thd->wsrep_conflict_state)
{
case CERT_FAILURE:
@@ -4409,7 +4409,7 @@ reexecute:
default:
break;
}
- mysql_mutex_unlock(&thd->LOCK_wsrep_thd);
+ mysql_mutex_unlock(&thd->LOCK_thd_data);
}
#endif /* WITH_WSREP */
diff --git a/sql/sql_select.cc b/sql/sql_select.cc
index 390600083c7..799828cd38e 100644
--- a/sql/sql_select.cc
+++ b/sql/sql_select.cc
@@ -1553,9 +1553,6 @@ JOIN::optimize_inner()
eval_select_list_used_tables();
- if (optimize_constant_subqueries())
- DBUG_RETURN(1);
-
table_count= select_lex->leaf_tables.elements;
if (setup_ftfuncs(select_lex)) /* should be after having->fix_fields */
@@ -1619,6 +1616,9 @@ JOIN::optimize_inner()
thd->restore_active_arena(arena, &backup);
}
+ if (optimize_constant_subqueries())
+ DBUG_RETURN(1);
+
if (setup_jtbm_semi_joins(this, join_list, &conds))
DBUG_RETURN(1);
diff --git a/sql/sql_statistics.cc b/sql/sql_statistics.cc
index ec0f5582ab0..37d994e8de7 100644
--- a/sql/sql_statistics.cc
+++ b/sql/sql_statistics.cc
@@ -3990,11 +3990,11 @@ bool is_stat_table(const LEX_CSTRING *db, LEX_CSTRING *table)
{
DBUG_ASSERT(db->str && table->str);
- if (!cmp(db, &MYSQL_SCHEMA_NAME))
+ if (!my_strcasecmp(table_alias_charset, db->str, MYSQL_SCHEMA_NAME.str))
{
for (uint i= 0; i < STATISTICS_TABLES; i ++)
{
- if (cmp(table, &stat_table_name[i]) == 0)
+ if (!my_strcasecmp(table_alias_charset, table->str, stat_table_name[i].str))
return true;
}
}
diff --git a/sql/table.cc b/sql/table.cc
index 9b5089c19b0..1ae0b526d10 100644
--- a/sql/table.cc
+++ b/sql/table.cc
@@ -6743,7 +6743,7 @@ bool TABLE::mark_virtual_columns_for_write(bool insert_fl)
if (bitmap_is_set(write_set, tmp_vfield->field_index))
bitmap_updated= mark_virtual_col(tmp_vfield);
else if (tmp_vfield->vcol_info->stored_in_db ||
- (tmp_vfield->flags & PART_KEY_FLAG))
+ (tmp_vfield->flags & (PART_KEY_FLAG | FIELD_IN_PART_FUNC_FLAG)))
{
if (insert_fl)
{
diff --git a/sql/wsrep_applier.cc b/sql/wsrep_applier.cc
index a5c39887cbd..f2d90def5ef 100644
--- a/sql/wsrep_applier.cc
+++ b/sql/wsrep_applier.cc
@@ -98,11 +98,11 @@ static wsrep_cb_status_t wsrep_apply_events(THD* thd,
DBUG_RETURN(WSREP_CB_FAILURE);
}
- mysql_mutex_lock(&thd->LOCK_wsrep_thd);
+ mysql_mutex_lock(&thd->LOCK_thd_data);
thd->wsrep_query_state= QUERY_EXEC;
if (thd->wsrep_conflict_state!= REPLAYING)
thd->wsrep_conflict_state= NO_CONFLICT;
- mysql_mutex_unlock(&thd->LOCK_wsrep_thd);
+ mysql_mutex_unlock(&thd->LOCK_thd_data);
if (!buf_len) WSREP_DEBUG("empty rbr buffer to apply: %lld",
(long long) wsrep_thd_trx_seqno(thd));
@@ -197,9 +197,9 @@ static wsrep_cb_status_t wsrep_apply_events(THD* thd,
}
error:
- mysql_mutex_lock(&thd->LOCK_wsrep_thd);
+ mysql_mutex_lock(&thd->LOCK_thd_data);
thd->wsrep_query_state= QUERY_IDLE;
- mysql_mutex_unlock(&thd->LOCK_wsrep_thd);
+ mysql_mutex_unlock(&thd->LOCK_thd_data);
assert(thd->wsrep_exec_mode== REPL_RECV);
diff --git a/sql/wsrep_hton.cc b/sql/wsrep_hton.cc
index 8044b7a3548..3ffd5d7706b 100644
--- a/sql/wsrep_hton.cc
+++ b/sql/wsrep_hton.cc
@@ -240,12 +240,12 @@ static int wsrep_rollback(handlerton *hton, THD *thd, bool all)
DBUG_RETURN(0);
}
- mysql_mutex_lock(&thd->LOCK_wsrep_thd);
+ mysql_mutex_lock(&thd->LOCK_thd_data);
switch (thd->wsrep_exec_mode)
{
case TOTAL_ORDER:
case REPL_RECV:
- mysql_mutex_unlock(&thd->LOCK_wsrep_thd);
+ mysql_mutex_unlock(&thd->LOCK_thd_data);
WSREP_DEBUG("Avoiding wsrep rollback for failed DDL: %s", thd->query());
DBUG_RETURN(0);
default: break;
@@ -262,7 +262,7 @@ static int wsrep_rollback(handlerton *hton, THD *thd, bool all)
}
wsrep_cleanup_transaction(thd);
}
- mysql_mutex_unlock(&thd->LOCK_wsrep_thd);
+ mysql_mutex_unlock(&thd->LOCK_thd_data);
DBUG_RETURN(0);
}
@@ -275,7 +275,7 @@ int wsrep_commit(handlerton *hton, THD *thd, bool all)
DBUG_RETURN(0);
}
- mysql_mutex_lock(&thd->LOCK_wsrep_thd);
+ mysql_mutex_lock(&thd->LOCK_thd_data);
if ((all || !thd_test_options(thd, OPTION_NOT_AUTOCOMMIT | OPTION_BEGIN)) &&
(thd->variables.wsrep_on && thd->wsrep_conflict_state != MUST_REPLAY))
{
@@ -306,7 +306,7 @@ int wsrep_commit(handlerton *hton, THD *thd, bool all)
wsrep_cleanup_transaction(thd);
}
}
- mysql_mutex_unlock(&thd->LOCK_wsrep_thd);
+ mysql_mutex_unlock(&thd->LOCK_thd_data);
DBUG_RETURN(0);
}
@@ -334,20 +334,20 @@ wsrep_run_wsrep_commit(THD *thd, bool all)
if (thd->wsrep_exec_mode == REPL_RECV) {
- mysql_mutex_lock(&thd->LOCK_wsrep_thd);
+ mysql_mutex_lock(&thd->LOCK_thd_data);
if (thd->wsrep_conflict_state == MUST_ABORT) {
if (wsrep_debug)
WSREP_INFO("WSREP: must abort for BF");
DBUG_PRINT("wsrep", ("BF apply commit fail"));
thd->wsrep_conflict_state = NO_CONFLICT;
- mysql_mutex_unlock(&thd->LOCK_wsrep_thd);
+ mysql_mutex_unlock(&thd->LOCK_thd_data);
//
// TODO: test all calls of the rollback.
// rollback must happen automagically innobase_rollback(hton, thd, 1);
//
DBUG_RETURN(WSREP_TRX_ERROR);
}
- mysql_mutex_unlock(&thd->LOCK_wsrep_thd);
+ mysql_mutex_unlock(&thd->LOCK_thd_data);
}
if (thd->wsrep_exec_mode != LOCAL_STATE) DBUG_RETURN(WSREP_TRX_OK);
@@ -359,11 +359,11 @@ wsrep_run_wsrep_commit(THD *thd, bool all)
DBUG_PRINT("wsrep", ("replicating commit"));
- mysql_mutex_lock(&thd->LOCK_wsrep_thd);
+ mysql_mutex_lock(&thd->LOCK_thd_data);
if (thd->wsrep_conflict_state == MUST_ABORT) {
DBUG_PRINT("wsrep", ("replicate commit fail"));
thd->wsrep_conflict_state = ABORTED;
- mysql_mutex_unlock(&thd->LOCK_wsrep_thd);
+ mysql_mutex_unlock(&thd->LOCK_thd_data);
if (wsrep_debug) {
WSREP_INFO("innobase_commit, abort %s",
(thd->query()) ? thd->query() : "void");
@@ -385,7 +385,7 @@ wsrep_run_wsrep_commit(THD *thd, bool all)
{
mysql_mutex_unlock(&LOCK_wsrep_replaying);
- mysql_mutex_unlock(&thd->LOCK_wsrep_thd);
+ mysql_mutex_unlock(&thd->LOCK_thd_data);
mysql_mutex_lock(&thd->mysys_var->mutex);
thd_proc_info(thd, "WSREP waiting on replaying");
@@ -413,7 +413,7 @@ wsrep_run_wsrep_commit(THD *thd, bool all)
thd->mysys_var->current_cond= 0;
mysql_mutex_unlock(&thd->mysys_var->mutex);
- mysql_mutex_lock(&thd->LOCK_wsrep_thd);
+ mysql_mutex_lock(&thd->LOCK_thd_data);
mysql_mutex_lock(&LOCK_wsrep_replaying);
}
mysql_mutex_unlock(&LOCK_wsrep_replaying);
@@ -421,14 +421,14 @@ wsrep_run_wsrep_commit(THD *thd, bool all)
if (thd->wsrep_conflict_state == MUST_ABORT) {
DBUG_PRINT("wsrep", ("replicate commit fail"));
thd->wsrep_conflict_state = ABORTED;
- mysql_mutex_unlock(&thd->LOCK_wsrep_thd);
+ mysql_mutex_unlock(&thd->LOCK_thd_data);
WSREP_DEBUG("innobase_commit abort after replaying wait %s",
(thd->query()) ? thd->query() : "void");
DBUG_RETURN(WSREP_TRX_CERT_FAIL);
}
thd->wsrep_query_state = QUERY_COMMITTING;
- mysql_mutex_unlock(&thd->LOCK_wsrep_thd);
+ mysql_mutex_unlock(&thd->LOCK_thd_data);
cache = get_trans_log(thd);
rcode = 0;
@@ -500,10 +500,10 @@ wsrep_run_wsrep_commit(THD *thd, bool all)
WSREP_DEBUG("thd: %lld seqno: %lld BF aborted by provider, will replay",
(longlong) thd->thread_id,
(longlong) thd->wsrep_trx_meta.gtid.seqno);
- mysql_mutex_lock(&thd->LOCK_wsrep_thd);
+ mysql_mutex_lock(&thd->LOCK_thd_data);
thd->wsrep_conflict_state = MUST_REPLAY;
DBUG_ASSERT(wsrep_thd_trx_seqno(thd) > 0);
- mysql_mutex_unlock(&thd->LOCK_wsrep_thd);
+ mysql_mutex_unlock(&thd->LOCK_thd_data);
mysql_mutex_lock(&LOCK_wsrep_replaying);
wsrep_replaying++;
WSREP_DEBUG("replaying increased: %d, thd: %lld",
@@ -517,7 +517,7 @@ wsrep_run_wsrep_commit(THD *thd, bool all)
DBUG_RETURN(WSREP_TRX_ERROR);
}
- mysql_mutex_lock(&thd->LOCK_wsrep_thd);
+ mysql_mutex_lock(&thd->LOCK_thd_data);
DEBUG_SYNC(thd, "wsrep_after_replication");
@@ -574,26 +574,26 @@ wsrep_run_wsrep_commit(THD *thd, bool all)
WSREP_LOG_CONFLICT(NULL, thd, FALSE);
}
}
- mysql_mutex_unlock(&thd->LOCK_wsrep_thd);
+ mysql_mutex_unlock(&thd->LOCK_thd_data);
DBUG_RETURN(WSREP_TRX_CERT_FAIL);
case WSREP_SIZE_EXCEEDED:
WSREP_ERROR("transaction size exceeded");
- mysql_mutex_unlock(&thd->LOCK_wsrep_thd);
+ mysql_mutex_unlock(&thd->LOCK_thd_data);
DBUG_RETURN(WSREP_TRX_SIZE_EXCEEDED);
case WSREP_CONN_FAIL:
WSREP_ERROR("connection failure");
- mysql_mutex_unlock(&thd->LOCK_wsrep_thd);
+ mysql_mutex_unlock(&thd->LOCK_thd_data);
DBUG_RETURN(WSREP_TRX_ERROR);
default:
WSREP_ERROR("unknown connection failure");
- mysql_mutex_unlock(&thd->LOCK_wsrep_thd);
+ mysql_mutex_unlock(&thd->LOCK_thd_data);
DBUG_RETURN(WSREP_TRX_ERROR);
}
thd->wsrep_query_state= QUERY_EXEC;
- mysql_mutex_unlock(&thd->LOCK_wsrep_thd);
+ mysql_mutex_unlock(&thd->LOCK_thd_data);
DBUG_RETURN(WSREP_TRX_OK);
}
diff --git a/sql/wsrep_mysqld.cc b/sql/wsrep_mysqld.cc
index def52cb2675..0c051d384c9 100644
--- a/sql/wsrep_mysqld.cc
+++ b/sql/wsrep_mysqld.cc
@@ -142,7 +142,7 @@ ulong wsrep_running_threads = 0; // # of currently running wsrep threads
ulong my_bind_addr;
#ifdef HAVE_PSI_INTERFACE
-PSI_mutex_key key_LOCK_wsrep_rollback, key_LOCK_wsrep_thd,
+PSI_mutex_key key_LOCK_wsrep_rollback,
key_LOCK_wsrep_replaying, key_LOCK_wsrep_ready, key_LOCK_wsrep_sst,
key_LOCK_wsrep_sst_thread, key_LOCK_wsrep_sst_init,
key_LOCK_wsrep_slave_threads, key_LOCK_wsrep_desync,
@@ -162,7 +162,6 @@ static PSI_mutex_info wsrep_mutexes[]=
{ &key_LOCK_wsrep_sst_init, "LOCK_wsrep_sst_init", PSI_FLAG_GLOBAL},
{ &key_LOCK_wsrep_sst, "LOCK_wsrep_sst", PSI_FLAG_GLOBAL},
{ &key_LOCK_wsrep_rollback, "LOCK_wsrep_rollback", PSI_FLAG_GLOBAL},
- { &key_LOCK_wsrep_thd, "THD::LOCK_wsrep_thd", 0},
{ &key_LOCK_wsrep_replaying, "LOCK_wsrep_replaying", PSI_FLAG_GLOBAL},
{ &key_LOCK_wsrep_slave_threads, "LOCK_wsrep_slave_threads", PSI_FLAG_GLOBAL},
{ &key_LOCK_wsrep_desync, "LOCK_wsrep_desync", PSI_FLAG_GLOBAL},
@@ -1688,16 +1687,16 @@ int wsrep_to_isolation_begin(THD *thd, const char *db_, const char *table_,
if (thd->wsrep_exec_mode == REPL_RECV)
return 0;
- mysql_mutex_lock(&thd->LOCK_wsrep_thd);
+ mysql_mutex_lock(&thd->LOCK_thd_data);
if (thd->wsrep_conflict_state == MUST_ABORT)
{
WSREP_INFO("thread: %lld schema: %s query: %s has been aborted due to multi-master conflict",
(longlong) thd->thread_id, thd->get_db(), thd->query());
- mysql_mutex_unlock(&thd->LOCK_wsrep_thd);
+ mysql_mutex_unlock(&thd->LOCK_thd_data);
return WSREP_TRX_FAIL;
}
- mysql_mutex_unlock(&thd->LOCK_wsrep_thd);
+ mysql_mutex_unlock(&thd->LOCK_thd_data);
DBUG_ASSERT(thd->wsrep_exec_mode == LOCAL_STATE);
DBUG_ASSERT(thd->wsrep_trx_meta.gtid.seqno == WSREP_SEQNO_UNDEFINED);
@@ -1812,7 +1811,7 @@ bool wsrep_grant_mdl_exception(MDL_context *requestor_ctx,
const char* schema= key->db_name();
int schema_len= key->db_name_length();
- mysql_mutex_lock(&request_thd->LOCK_wsrep_thd);
+ mysql_mutex_lock(&request_thd->LOCK_thd_data);
/*
We consider granting MDL exceptions only for appliers (BF THD) and ones
@@ -1836,19 +1835,19 @@ bool wsrep_grant_mdl_exception(MDL_context *requestor_ctx,
if (request_thd->wsrep_exec_mode == TOTAL_ORDER ||
request_thd->wsrep_exec_mode == REPL_RECV)
{
- mysql_mutex_unlock(&request_thd->LOCK_wsrep_thd);
+ mysql_mutex_unlock(&request_thd->LOCK_thd_data);
WSREP_MDL_LOG(DEBUG, "MDL conflict ", schema, schema_len,
request_thd, granted_thd);
ticket->wsrep_report(wsrep_debug);
- mysql_mutex_lock(&granted_thd->LOCK_wsrep_thd);
+ mysql_mutex_lock(&granted_thd->LOCK_thd_data);
if (granted_thd->wsrep_exec_mode == TOTAL_ORDER ||
granted_thd->wsrep_exec_mode == REPL_RECV)
{
WSREP_MDL_LOG(INFO, "MDL BF-BF conflict", schema, schema_len,
request_thd, granted_thd);
ticket->wsrep_report(true);
- mysql_mutex_unlock(&granted_thd->LOCK_wsrep_thd);
+ mysql_mutex_unlock(&granted_thd->LOCK_thd_data);
ret= true;
}
else if (granted_thd->lex->sql_command == SQLCOM_FLUSH ||
@@ -1856,7 +1855,7 @@ bool wsrep_grant_mdl_exception(MDL_context *requestor_ctx,
{
WSREP_DEBUG("BF thread waiting for FLUSH");
ticket->wsrep_report(wsrep_debug);
- mysql_mutex_unlock(&granted_thd->LOCK_wsrep_thd);
+ mysql_mutex_unlock(&granted_thd->LOCK_thd_data);
ret= false;
}
else
@@ -1881,14 +1880,14 @@ bool wsrep_grant_mdl_exception(MDL_context *requestor_ctx,
ticket->wsrep_report(true);
}
- mysql_mutex_unlock(&granted_thd->LOCK_wsrep_thd);
+ mysql_mutex_unlock(&granted_thd->LOCK_thd_data);
wsrep_abort_thd((void *) request_thd, (void *) granted_thd, 1);
ret= false;
}
}
else
{
- mysql_mutex_unlock(&request_thd->LOCK_wsrep_thd);
+ mysql_mutex_unlock(&request_thd->LOCK_thd_data);
}
return ret;
@@ -2045,9 +2044,9 @@ static inline bool is_replaying_connection(THD *thd)
{
bool ret;
- mysql_mutex_lock(&thd->LOCK_wsrep_thd);
+ mysql_mutex_lock(&thd->LOCK_thd_data);
ret= (thd->wsrep_conflict_state == REPLAYING) ? true : false;
- mysql_mutex_unlock(&thd->LOCK_wsrep_thd);
+ mysql_mutex_unlock(&thd->LOCK_thd_data);
return ret;
}
@@ -2057,9 +2056,9 @@ static inline bool is_committing_connection(THD *thd)
{
bool ret;
- mysql_mutex_lock(&thd->LOCK_wsrep_thd);
+ mysql_mutex_lock(&thd->LOCK_thd_data);
ret= (thd->wsrep_query_state == QUERY_COMMITTING) ? true : false;
- mysql_mutex_unlock(&thd->LOCK_wsrep_thd);
+ mysql_mutex_unlock(&thd->LOCK_thd_data);
return ret;
}
@@ -2440,13 +2439,13 @@ wsrep_ws_handle_t* wsrep_thd_ws_handle(THD *thd)
void wsrep_thd_LOCK(THD *thd)
{
- mysql_mutex_lock(&thd->LOCK_wsrep_thd);
+ mysql_mutex_lock(&thd->LOCK_thd_data);
}
void wsrep_thd_UNLOCK(THD *thd)
{
- mysql_mutex_unlock(&thd->LOCK_wsrep_thd);
+ mysql_mutex_unlock(&thd->LOCK_thd_data);
}
diff --git a/sql/wsrep_mysqld.h b/sql/wsrep_mysqld.h
index c6b1f42ce14..5a13575d904 100644
--- a/sql/wsrep_mysqld.h
+++ b/sql/wsrep_mysqld.h
@@ -266,8 +266,6 @@ extern my_bool wsrep_preordered_opt;
extern handlerton *wsrep_hton;
#ifdef HAVE_PSI_INTERFACE
-extern PSI_mutex_key key_LOCK_wsrep_thd;
-extern PSI_cond_key key_COND_wsrep_thd;
extern PSI_mutex_key key_LOCK_wsrep_ready;
extern PSI_mutex_key key_COND_wsrep_ready;
extern PSI_mutex_key key_LOCK_wsrep_sst;
diff --git a/sql/wsrep_thd.cc b/sql/wsrep_thd.cc
index e8dda53c95f..ce6d9688cb3 100644
--- a/sql/wsrep_thd.cc
+++ b/sql/wsrep_thd.cc
@@ -47,7 +47,7 @@ int wsrep_show_bf_aborts (THD *thd, SHOW_VAR *var, char *buff,
return 0;
}
-/* must have (&thd->LOCK_wsrep_thd) */
+/* must have (&thd->LOCK_thd_data) */
void wsrep_client_rollback(THD *thd)
{
WSREP_DEBUG("client rollback due to BF abort for (%lld), query: %s",
@@ -56,7 +56,7 @@ void wsrep_client_rollback(THD *thd)
WSREP_ATOMIC_ADD_LONG(&wsrep_bf_aborts_counter, 1);
thd->wsrep_conflict_state= ABORTING;
- mysql_mutex_unlock(&thd->LOCK_wsrep_thd);
+ mysql_mutex_unlock(&thd->LOCK_thd_data);
trans_rollback(thd);
if (thd->locked_tables_mode && thd->lock)
@@ -86,7 +86,7 @@ void wsrep_client_rollback(THD *thd)
(longlong) thd->thread_id);
thd->clear_binlog_table_maps();
}
- mysql_mutex_lock(&thd->LOCK_wsrep_thd);
+ mysql_mutex_lock(&thd->LOCK_thd_data);
thd->wsrep_conflict_state= ABORTED;
}
@@ -232,7 +232,7 @@ void wsrep_replay_transaction(THD *thd)
thd->get_stmt_da()->reset_diagnostics_area();
thd->wsrep_conflict_state= REPLAYING;
- mysql_mutex_unlock(&thd->LOCK_wsrep_thd);
+ mysql_mutex_unlock(&thd->LOCK_thd_data);
thd->reset_for_next_command();
thd->reset_killed();
@@ -272,7 +272,7 @@ void wsrep_replay_transaction(THD *thd)
if (thd->wsrep_conflict_state!= REPLAYING)
WSREP_WARN("lost replaying mode: %d", thd->wsrep_conflict_state );
- mysql_mutex_lock(&thd->LOCK_wsrep_thd);
+ mysql_mutex_lock(&thd->LOCK_thd_data);
switch (rcode)
{
@@ -328,7 +328,7 @@ void wsrep_replay_transaction(THD *thd)
/* we're now in inconsistent state, must abort */
/* http://bazaar.launchpad.net/~codership/codership-mysql/5.6/revision/3962#sql/wsrep_thd.cc */
- mysql_mutex_unlock(&thd->LOCK_wsrep_thd);
+ mysql_mutex_unlock(&thd->LOCK_thd_data);
unireg_abort(1);
break;
@@ -495,30 +495,30 @@ static void wsrep_rollback_process(THD *thd)
*/
mysql_mutex_unlock(&LOCK_wsrep_rollback);
- mysql_mutex_lock(&aborting->LOCK_wsrep_thd);
+ mysql_mutex_lock(&aborting->LOCK_thd_data);
if (aborting->wsrep_conflict_state== ABORTED)
{
WSREP_DEBUG("WSREP, thd already aborted: %llu state: %d",
(long long)aborting->real_id,
aborting->wsrep_conflict_state);
- mysql_mutex_unlock(&aborting->LOCK_wsrep_thd);
+ mysql_mutex_unlock(&aborting->LOCK_thd_data);
mysql_mutex_lock(&LOCK_wsrep_rollback);
continue;
}
aborting->wsrep_conflict_state= ABORTING;
- mysql_mutex_unlock(&aborting->LOCK_wsrep_thd);
+ mysql_mutex_unlock(&aborting->LOCK_thd_data);
set_current_thd(aborting);
aborting->store_globals();
- mysql_mutex_lock(&aborting->LOCK_wsrep_thd);
+ mysql_mutex_lock(&aborting->LOCK_thd_data);
wsrep_client_rollback(aborting);
WSREP_DEBUG("WSREP rollbacker aborted thd: (%lld %lld)",
(longlong) aborting->thread_id,
(longlong) aborting->real_id);
- mysql_mutex_unlock(&aborting->LOCK_wsrep_thd);
+ mysql_mutex_unlock(&aborting->LOCK_thd_data);
set_current_thd(thd);
thd->store_globals();
@@ -558,10 +558,10 @@ enum wsrep_conflict_state wsrep_thd_conflict_state(THD *thd, my_bool sync)
enum wsrep_conflict_state state = NO_CONFLICT;
if (thd)
{
- if (sync) mysql_mutex_lock(&thd->LOCK_wsrep_thd);
+ if (sync) mysql_mutex_lock(&thd->LOCK_thd_data);
state = thd->wsrep_conflict_state;
- if (sync) mysql_mutex_unlock(&thd->LOCK_wsrep_thd);
+ if (sync) mysql_mutex_unlock(&thd->LOCK_thd_data);
}
return state;
}
@@ -585,12 +585,12 @@ my_bool wsrep_thd_is_BF(THD *thd, my_bool sync)
if (wsrep_thd_is_wsrep(thd))
{
if (sync)
- mysql_mutex_lock(&thd->LOCK_wsrep_thd);
+ mysql_mutex_lock(&thd->LOCK_thd_data);
status = ((thd->wsrep_exec_mode == REPL_RECV) ||
(thd->wsrep_exec_mode == TOTAL_ORDER));
if (sync)
- mysql_mutex_unlock(&thd->LOCK_wsrep_thd);
+ mysql_mutex_unlock(&thd->LOCK_thd_data);
}
}
return status;
@@ -603,12 +603,12 @@ my_bool wsrep_thd_is_BF_or_commit(void *thd_ptr, my_bool sync)
if (thd_ptr)
{
THD* thd = (THD*)thd_ptr;
- if (sync) mysql_mutex_lock(&thd->LOCK_wsrep_thd);
+ if (sync) mysql_mutex_lock(&thd->LOCK_thd_data);
status = ((thd->wsrep_exec_mode == REPL_RECV) ||
(thd->wsrep_exec_mode == TOTAL_ORDER) ||
(thd->wsrep_exec_mode == LOCAL_COMMIT));
- if (sync) mysql_mutex_unlock(&thd->LOCK_wsrep_thd);
+ if (sync) mysql_mutex_unlock(&thd->LOCK_thd_data);
}
return status;
}
@@ -620,10 +620,10 @@ my_bool wsrep_thd_is_local(void *thd_ptr, my_bool sync)
if (thd_ptr)
{
THD* thd = (THD*)thd_ptr;
- if (sync) mysql_mutex_lock(&thd->LOCK_wsrep_thd);
+ if (sync) mysql_mutex_lock(&thd->LOCK_thd_data);
status = (thd->wsrep_exec_mode == LOCAL_STATE);
- if (sync) mysql_mutex_unlock(&thd->LOCK_wsrep_thd);
+ if (sync) mysql_mutex_unlock(&thd->LOCK_thd_data);
}
return status;
}