summaryrefslogtreecommitdiff
path: root/sql
diff options
context:
space:
mode:
Diffstat (limited to 'sql')
-rw-r--r--sql/item.cc10
-rw-r--r--sql/item.h1
-rw-r--r--sql/item_cmpfunc.cc42
-rw-r--r--sql/item_func.cc6
-rw-r--r--sql/item_func.h8
-rw-r--r--sql/item_row.cc1
-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_prepare.cc8
-rw-r--r--sql/sql_select.cc6
-rw-r--r--sql/sql_statistics.cc4
-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
26 files changed, 193 insertions, 133 deletions
diff --git a/sql/item.cc b/sql/item.cc
index 0350b437e7d..876472c0bd9 100644
--- a/sql/item.cc
+++ b/sql/item.cc
@@ -477,7 +477,9 @@ Item::Item(THD *thd):
maybe_null=null_value=with_sum_func=with_window_func=with_field=0;
in_rollup= 0;
with_subselect= 0;
- /* Initially this item is not attached to any JOIN_TAB. */
+ with_param= 0;
+
+ /* Initially this item is not attached to any JOIN_TAB. */
join_tab_idx= MAX_TABLES;
/* Put item in free list so that we can free all items at end */
@@ -519,6 +521,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),
@@ -1533,6 +1536,9 @@ bool Item_sp_variable::fix_fields(THD *thd, Item **)
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);
@@ -7767,6 +7773,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;
@@ -8193,6 +8200,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;
name_length= item_arg->name_length;
diff --git a/sql/item.h b/sql/item.h
index 8921ee76f6a..6f6b8bf08ec 100644
--- a/sql/item.h
+++ b/sql/item.h
@@ -738,6 +738,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 44cc4f3cae9..72a4d99c968 100644
--- a/sql/item_cmpfunc.cc
+++ b/sql/item_cmpfunc.cc
@@ -1341,6 +1341,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()))
{
@@ -1389,6 +1390,7 @@ bool Item_in_optimizer::fix_fields(THD *thd, Item **ref)
with_subselect= 1;
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;
@@ -1938,6 +1940,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;
}
@@ -4478,6 +4481,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();
@@ -4540,26 +4544,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
{
@@ -4571,6 +4582,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;
with_subselect|= item->has_subquery();
with_window_func|= item->with_window_func;
@@ -4586,30 +4598,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 0c239b54f30..cd23c0b64fe 100644
--- a/sql/item_func.cc
+++ b/sql/item_func.cc
@@ -135,6 +135,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;
}
}
@@ -229,6 +230,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);
@@ -3467,6 +3469,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_subselect|= item->with_subselect;
func->used_tables_and_const_cache_join(item);
f_args.arg_type[i]=item->result_type();
@@ -6967,6 +6970,3 @@ void Item_func_last_value::fix_length_and_dec()
Type_std_attributes::set(last_value);
maybe_null= last_value->maybe_null;
}
-
-
-
diff --git a/sql/item_func.h b/sql/item_func.h
index 689bfb84034..3787b4f4924 100644
--- a/sql/item_func.h
+++ b/sql/item_func.h
@@ -75,16 +75,19 @@ public:
{
with_sum_func= 0;
with_field= 0;
+ with_param= 0;
}
Item_func(THD *thd, Item *a): Item_func_or_sum(thd, a), allowed_arg_cols(1)
{
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), allowed_arg_cols(1)
{
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):
@@ -92,6 +95,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), allowed_arg_cols(1)
@@ -100,6 +104,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), allowed_arg_cols(1)
@@ -108,6 +114,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), allowed_arg_cols(1)
diff --git a/sql/item_row.cc b/sql/item_row.cc
index 3660c983f87..24320d884dc 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;
with_subselect|= item->with_subselect;
+ with_param|= item->with_param;
}
fixed= 1;
return FALSE;
diff --git a/sql/item_sum.cc b/sql/item_sum.cc
index 94569aa66c9..4cf11e81d3d 100644
--- a/sql/item_sum.cc
+++ b/sql/item_sum.cc
@@ -1126,6 +1126,7 @@ Item_sum_num::fix_fields(THD *thd, Item **ref)
return TRUE;
set_if_bigger(decimals, args[i]->decimals);
with_subselect|= args[i]->with_subselect;
+ with_param|= args[i]->with_param;
with_window_func|= args[i]->with_window_func;
}
result_field=0;
@@ -1158,6 +1159,7 @@ Item_sum_hybrid::fix_fields(THD *thd, Item **ref)
return TRUE;
Type_std_attributes::set(args[0]);
with_subselect= args[0]->with_subselect;
+ with_param= args[0]->with_param;
with_window_func|= args[0]->with_window_func;
Item *item2= item->real_item();
@@ -3512,6 +3514,7 @@ Item_func_group_concat::fix_fields(THD *thd, Item **ref)
args[i]->check_cols(1))
return TRUE;
with_subselect|= args[i]->with_subselect;
+ 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 b28adae0a44..7b081218dea 100644
--- a/sql/opt_subselect.cc
+++ b/sql/opt_subselect.cc
@@ -3741,8 +3741,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
@@ -3750,10 +3749,22 @@ bool setup_sj_materialization_part1(JOIN_TAB *sjm_tab)
sjm->sjm_table_param.init();
sjm->sjm_table_param.bit_fields_as_long= TRUE;
SELECT_LEX *subq_select= emb_sj_nest->sj_subq_pred->unit->first_select();
- 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));
+ 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 b90fd47af83..713a668bfe8 100644
--- a/sql/slave.cc
+++ b/sql/slave.cc
@@ -4021,10 +4021,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)
{
@@ -4101,7 +4101,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 29f181320c7..04191a0c8c8 100644
--- a/sql/sql_acl.cc
+++ b/sql/sql_acl.cc
@@ -12233,6 +12233,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 48d16da9d0a..3306575b845 100644
--- a/sql/sql_admin.cc
+++ b/sql/sql_admin.cc
@@ -1170,7 +1170,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);
@@ -1204,7 +1206,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 e20ad15ae51..95ff41cb6f4 100644
--- a/sql/sql_base.cc
+++ b/sql/sql_base.cc
@@ -808,10 +808,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 ddb848a6576..87fe68ed967 100644
--- a/sql/sql_class.cc
+++ b/sql/sql_class.cc
@@ -865,7 +865,6 @@ THD::THD(my_thread_id id, bool is_wsrep_applier)
*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;
@@ -1593,9 +1592,6 @@ THD::~THD()
mysql_mutex_unlock(&LOCK_thd_data);
#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 cd31e0356e8..1e866e1da6d 100644
--- a/sql/sql_class.h
+++ b/sql/sql_class.h
@@ -4369,7 +4369,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 b4131614adb..99fc1e8c1aa 100644
--- a/sql/sql_connect.cc
+++ b/sql/sql_connect.cc
@@ -1340,9 +1340,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 f9843dd6418..a5f1249c139 100644
--- a/sql/sql_insert.cc
+++ b/sql/sql_insert.cc
@@ -4471,17 +4471,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 bc74cf358e2..52aa6bf9381 100644
--- a/sql/sql_parse.cc
+++ b/sql/sql_parse.cc
@@ -429,7 +429,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.
@@ -437,7 +437,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;
@@ -1198,13 +1198,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 */
@@ -1250,15 +1250,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();
}
@@ -1268,7 +1268,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 */
@@ -1281,13 +1281,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);
if (thd->wsrep_conflict_state == MUST_ABORT)
{
DBUG_PRINT("wsrep",("aborted for wsrep rollback: %lu", thd->real_id));
wsrep_client_rollback(thd);
}
- mysql_mutex_unlock(&thd->LOCK_wsrep_thd);
+ mysql_mutex_unlock(&thd->LOCK_thd_data);
}
#endif /* WITH_WSREP */
@@ -1562,7 +1562,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)
{
@@ -1579,14 +1579,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)
@@ -2353,10 +2353,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;
@@ -6248,6 +6248,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)
@@ -7726,13 +7730,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);
@@ -7741,8 +7754,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);
}
@@ -7784,13 +7800,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);
}
}
@@ -8807,7 +8823,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(kill_signal);
error=0;
diff --git a/sql/sql_parse.h b/sql/sql_parse.h
index eedb74df959..c1dcc0d3cb9 100644
--- a/sql/sql_parse.h
+++ b/sql/sql_parse.h
@@ -86,6 +86,7 @@ bool check_identifier_name(LEX_STRING *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, uint packet_length);
diff --git a/sql/sql_prepare.cc b/sql/sql_prepare.cc
index d0dbf90f093..8a95719069c 100644
--- a/sql/sql_prepare.cc
+++ b/sql/sql_prepare.cc
@@ -4207,7 +4207,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:
@@ -4224,7 +4224,7 @@ reexecute:
default:
break;
}
- mysql_mutex_unlock(&thd->LOCK_wsrep_thd);
+ mysql_mutex_unlock(&thd->LOCK_thd_data);
}
#endif /* WITH_WSREP */
@@ -4402,7 +4402,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:
@@ -4419,7 +4419,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 30ef26f67e2..4df4c0c87e1 100644
--- a/sql/sql_select.cc
+++ b/sql/sql_select.cc
@@ -1252,9 +1252,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 */
@@ -1318,6 +1315,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 e40e817ec8a..01947462cce 100644
--- a/sql/sql_statistics.cc
+++ b/sql/sql_statistics.cc
@@ -3993,11 +3993,11 @@ bool is_stat_table(const char *db, const char *table)
{
DBUG_ASSERT(db && table);
- if (!memcmp(db, stat_tables_db_name.str, stat_tables_db_name.length))
+ if (!my_strcasecmp(table_alias_charset, db, stat_tables_db_name.str))
{
for (uint i= 0; i < STATISTICS_TABLES; i ++)
{
- if (!memcmp(table, stat_table_name[i].str, stat_table_name[i].length))
+ if (!my_strcasecmp(table_alias_charset, table, stat_table_name[i].str))
return true;
}
}
diff --git a/sql/wsrep_applier.cc b/sql/wsrep_applier.cc
index a299ddf074f..be6297abd09 100644
--- a/sql/wsrep_applier.cc
+++ b/sql/wsrep_applier.cc
@@ -97,11 +97,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));
@@ -196,9 +196,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 e7c7b377e08..4672f286982 100644
--- a/sql/wsrep_hton.cc
+++ b/sql/wsrep_hton.cc
@@ -238,12 +238,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;
@@ -261,7 +261,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);
}
@@ -274,7 +274,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))
{
@@ -305,7 +305,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);
}
@@ -333,20 +333,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);
@@ -358,11 +358,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");
@@ -379,7 +379,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");
@@ -407,7 +407,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);
@@ -415,14 +415,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;
@@ -489,10 +489,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",
@@ -506,7 +506,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");
@@ -560,26 +560,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 a85b5a4ea7b..a5cd269fc87 100644
--- a/sql/wsrep_mysqld.cc
+++ b/sql/wsrep_mysqld.cc
@@ -141,7 +141,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,
@@ -161,7 +161,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},
@@ -1686,7 +1685,7 @@ int wsrep_to_isolation_begin(THD *thd, char *db_, 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)
{
@@ -1694,10 +1693,10 @@ int wsrep_to_isolation_begin(THD *thd, char *db_, char *table_,
(longlong) thd->thread_id,
(thd->db ? thd->db : "(null)"),
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
@@ -1880,14 +1879,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;
@@ -2051,9 +2050,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;
}
@@ -2063,9 +2062,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;
}
@@ -2448,13 +2447,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 eb37b63eff6..130c7e5ad39 100644
--- a/sql/wsrep_mysqld.h
+++ b/sql/wsrep_mysqld.h
@@ -271,8 +271,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 d62c38580b6..15eed2e10e6 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;
}
@@ -231,7 +231,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();
@@ -271,7 +271,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)
{
@@ -329,7 +329,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;
@@ -496,30 +496,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();
@@ -559,10 +559,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;
}
@@ -586,12 +586,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;
@@ -604,12 +604,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;
}
@@ -621,10 +621,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;
}