summaryrefslogtreecommitdiff
path: root/sql
diff options
context:
space:
mode:
authorJan Lindström <jan.lindstrom@mariadb.com>2015-08-03 23:09:43 +0300
committerJan Lindström <jan.lindstrom@mariadb.com>2015-08-03 23:09:43 +0300
commit9a5787db51ef571e2beaeda1402cf7578c95eaf6 (patch)
tree3dc0e3cfc17077929d701b1e3701c7c9f92f7aa7 /sql
parent4188ba9c1e0ea195adf00d9e6d11b29ef18b2109 (diff)
parent96badb16afcf8a6ae3d03918419fc51ace4be236 (diff)
downloadmariadb-git-9a5787db51ef571e2beaeda1402cf7578c95eaf6.tar.gz
Merge commit '96badb16afcf' into 10.0
Conflicts: client/mysql_upgrade.c mysql-test/r/func_misc.result mysql-test/suite/binlog/r/binlog_stm_mix_innodb_myisam.result mysql-test/suite/innodb/r/innodb-fk.result mysql-test/t/subselect_sj_mat.test sql/item.cc sql/item_func.cc sql/log.cc sql/log_event.cc sql/rpl_utility.cc sql/slave.cc sql/sql_class.cc sql/sql_class.h sql/sql_select.cc storage/innobase/dict/dict0crea.c storage/innobase/dict/dict0dict.c storage/innobase/handler/ha_innodb.cc storage/xtradb/dict/dict0crea.c storage/xtradb/dict/dict0dict.c storage/xtradb/handler/ha_innodb.cc vio/viosslfactories.c
Diffstat (limited to 'sql')
-rw-r--r--sql/item.cc44
-rw-r--r--sql/item.h7
-rw-r--r--sql/item_func.cc18
-rw-r--r--sql/item_subselect.cc6
-rw-r--r--sql/item_sum.cc13
-rw-r--r--sql/item_sum.h1
-rw-r--r--sql/log.cc33
-rw-r--r--sql/mysqld.cc10
-rw-r--r--sql/rpl_handler.cc54
-rw-r--r--sql/rpl_utility.cc21
-rw-r--r--sql/slave.cc10
-rw-r--r--sql/sql_base.cc1
-rw-r--r--sql/sql_class.cc4
-rw-r--r--sql/sql_class.h16
-rw-r--r--sql/sql_lex.cc2
-rw-r--r--sql/sql_lex.h2
-rw-r--r--sql/sql_select.cc14
-rw-r--r--sql/sql_select.h4
-rw-r--r--sql/sql_show.cc5
-rw-r--r--sql/sql_test.cc7
-rw-r--r--sql/sql_union.cc3
-rw-r--r--sql/table.cc2
22 files changed, 168 insertions, 109 deletions
diff --git a/sql/item.cc b/sql/item.cc
index bffa7e2990d..934846c4815 100644
--- a/sql/item.cc
+++ b/sql/item.cc
@@ -4363,18 +4363,23 @@ static bool mark_as_dependent(THD *thd, SELECT_LEX *last, SELECT_LEX *current,
Item_ident *resolved_item,
Item_ident *mark_item)
{
- const char *db_name= (resolved_item->db_name ?
- resolved_item->db_name : "");
- const char *table_name= (resolved_item->table_name ?
- resolved_item->table_name : "");
+ DBUG_ENTER("mark_as_dependent");
+
/* store pointer on SELECT_LEX from which item is dependent */
if (mark_item && mark_item->can_be_depended)
+ {
+ DBUG_PRINT("info", ("mark_item: %p lex: %p", mark_item, last));
mark_item->depended_from= last;
- if (current->mark_as_dependent(thd, last, /** resolved_item psergey-thu
- **/mark_item))
- return TRUE;
+ }
+ if (current->mark_as_dependent(thd, last,
+ /** resolved_item psergey-thu **/ mark_item))
+ DBUG_RETURN(TRUE);
if (thd->lex->describe & DESCRIBE_EXTENDED)
{
+ const char *db_name= (resolved_item->db_name ?
+ resolved_item->db_name : "");
+ const char *table_name= (resolved_item->table_name ?
+ resolved_item->table_name : "");
push_warning_printf(thd, Sql_condition::WARN_LEVEL_NOTE,
ER_WARN_FIELD_RESOLVED, ER(ER_WARN_FIELD_RESOLVED),
db_name, (db_name[0] ? "." : ""),
@@ -4382,7 +4387,7 @@ static bool mark_as_dependent(THD *thd, SELECT_LEX *last, SELECT_LEX *current,
resolved_item->field_name,
current->select_number, last->select_number);
}
- return FALSE;
+ DBUG_RETURN(FALSE);
}
@@ -4831,7 +4836,7 @@ Item_field::fix_outer_field(THD *thd, Field **from_field, Item **reference)
non aggregated fields of the outer select.
*/
marker= select->cur_pos_in_select_list;
- select->non_agg_fields.push_back(this);
+ select->join->non_agg_fields.push_back(this);
}
if (*from_field != view_ref_found)
{
@@ -5247,9 +5252,10 @@ bool Item_field::fix_fields(THD *thd, Item **reference)
fixed= 1;
if (thd->variables.sql_mode & MODE_ONLY_FULL_GROUP_BY &&
!outer_fixed && !thd->lex->in_sum_func &&
- thd->lex->current_select->cur_pos_in_select_list != UNDEF_POS)
+ thd->lex->current_select->cur_pos_in_select_list != UNDEF_POS &&
+ thd->lex->current_select->join)
{
- thd->lex->current_select->non_agg_fields.push_back(this);
+ thd->lex->current_select->join->non_agg_fields.push_back(this);
marker= thd->lex->current_select->cur_pos_in_select_list;
}
mark_non_agg_field:
@@ -6730,7 +6736,7 @@ Item_ref::Item_ref(Name_resolution_context *context_arg,
/*
This constructor used to create some internals references over fixed items
*/
- if (ref && *ref && (*ref)->fixed)
+ if ((set_properties_only= (ref && *ref && (*ref)->fixed)))
set_properties();
}
@@ -6774,7 +6780,7 @@ Item_ref::Item_ref(TABLE_LIST *view_arg, Item **item,
/*
This constructor is used to create some internal references over fixed items
*/
- if (ref && *ref && (*ref)->fixed)
+ if ((set_properties_only= (ref && *ref && (*ref)->fixed)))
set_properties();
}
@@ -6849,7 +6855,11 @@ bool Item_ref::fix_fields(THD *thd, Item **reference)
DBUG_ASSERT(fixed == 0);
SELECT_LEX *current_sel= thd->lex->current_select;
- if (!ref || ref == not_found_item)
+ if (set_properties_only)
+ {
+ /* do nothing */
+ }
+ else if (!ref || ref == not_found_item)
{
DBUG_ASSERT(reference_trough_name != 0);
if (!(ref= resolve_ref_in_select_and_group(thd, this,
@@ -6867,7 +6877,7 @@ bool Item_ref::fix_fields(THD *thd, Item **reference)
{
/* The current reference cannot be resolved in this query. */
my_error(ER_BAD_FIELD_ERROR,MYF(0),
- this->full_name(), current_thd->where);
+ this->full_name(), thd->where);
goto error;
}
@@ -7002,7 +7012,7 @@ bool Item_ref::fix_fields(THD *thd, Item **reference)
goto error;
thd->change_item_tree(reference, fld);
mark_as_dependent(thd, last_checked_context->select_lex,
- thd->lex->current_select, fld, fld);
+ current_sel, fld, fld);
/*
A reference is resolved to a nest level that's outer or the same as
the nest level of the enclosing set function : adjust the value of
@@ -7019,7 +7029,7 @@ bool Item_ref::fix_fields(THD *thd, Item **reference)
{
/* The item was not a table field and not a reference */
my_error(ER_BAD_FIELD_ERROR, MYF(0),
- this->full_name(), current_thd->where);
+ this->full_name(), thd->where);
goto error;
}
/* Should be checked in resolve_ref_in_select_and_group(). */
diff --git a/sql/item.h b/sql/item.h
index 171bdb05310..353c9e0f6bc 100644
--- a/sql/item.h
+++ b/sql/item.h
@@ -657,7 +657,7 @@ public:
*/
uint name_length; /* Length of name */
uint decimals;
- int8 marker;
+ int marker;
bool maybe_null; /* If item may be null */
bool in_rollup; /* If used in GROUP BY list
of a query with ROLLUP */
@@ -3356,6 +3356,7 @@ class Item_ref :public Item_ident
{
protected:
void set_properties();
+ bool set_properties_only; // the item doesn't need full fix_fields
public:
enum Ref_Type { REF, DIRECT_REF, VIEW_REF, OUTER_REF, AGGREGATE_REF };
Field *result_field; /* Save result here */
@@ -3365,7 +3366,7 @@ public:
const char *db_arg, const char *table_name_arg,
const char *field_name_arg)
:Item_ident(context_arg, db_arg, table_name_arg, field_name_arg),
- result_field(0), ref(0), reference_trough_name(1) {}
+ set_properties_only(0), result_field(0), ref(0), reference_trough_name(1) {}
/*
This constructor is used in two scenarios:
A) *item = NULL
@@ -3388,7 +3389,7 @@ public:
/* Constructor need to process subselect with temporary tables (see Item) */
Item_ref(THD *thd, Item_ref *item)
- :Item_ident(thd, item), result_field(item->result_field), ref(item->ref) {}
+ :Item_ident(thd, item), set_properties_only(0), result_field(item->result_field), ref(item->ref) {}
enum Type type() const { return REF_ITEM; }
enum Type real_type() const { return ref ? (*ref)->type() :
REF_ITEM; }
diff --git a/sql/item_func.cc b/sql/item_func.cc
index 0dabd06d423..4d7e10b6577 100644
--- a/sql/item_func.cc
+++ b/sql/item_func.cc
@@ -4268,6 +4268,24 @@ longlong Item_func_get_lock::val_int()
if (thd->slave_thread)
{
null_value= 0;
+ }
+
+ if (args[1]->null_value ||
+ (!args[1]->unsigned_flag && ((longlong) timeout < 0)))
+ {
+ char buf[22];
+ if (args[1]->null_value)
+ strmov(buf, "NULL");
+ else
+ llstr(((longlong) timeout), buf);
+ push_warning_printf(thd, Sql_condition::WARN_LEVEL_WARN,
+ ER_WRONG_VALUE_FOR_TYPE, ER(ER_WRONG_VALUE_FOR_TYPE),
+ "timeout", buf, "get_lock");
+ null_value= 1;
+ DBUG_RETURN(0);
+ }
+ {
+ null_value= 0;
DBUG_RETURN(1);
}
diff --git a/sql/item_subselect.cc b/sql/item_subselect.cc
index a0fca36452c..fe2352f3008 100644
--- a/sql/item_subselect.cc
+++ b/sql/item_subselect.cc
@@ -477,6 +477,7 @@ void Item_subselect::recalc_used_tables(st_select_lex *new_parent,
{
List_iterator_fast<Ref_to_outside> it(upper_refs);
Ref_to_outside *upper;
+ DBUG_ENTER("recalc_used_tables");
used_tables_cache= 0;
while ((upper= it++))
@@ -536,6 +537,8 @@ void Item_subselect::recalc_used_tables(st_select_lex *new_parent,
he has done const table detection, and that will be our chance to update
const_tables_cache.
*/
+ DBUG_PRINT("exit", ("used_tables_cache: %llx", used_tables_cache));
+ DBUG_VOID_RETURN;
}
@@ -2002,7 +2005,7 @@ bool Item_allany_subselect::is_maxmin_applicable(JOIN *join)
*/
bool
-Item_in_subselect::create_single_in_to_exists_cond(JOIN * join,
+Item_in_subselect::create_single_in_to_exists_cond(JOIN *join,
Item **where_item,
Item **having_item)
{
@@ -2012,7 +2015,6 @@ Item_in_subselect::create_single_in_to_exists_cond(JOIN * join,
during JOIN::optimize: this->tmp_having= this->having; this->having= 0;
*/
Item* join_having= join->having ? join->having : join->tmp_having;
-
DBUG_ENTER("Item_in_subselect::create_single_in_to_exists_cond");
*where_item= NULL;
diff --git a/sql/item_sum.cc b/sql/item_sum.cc
index 1c5682417a5..29dc94eb5af 100644
--- a/sql/item_sum.cc
+++ b/sql/item_sum.cc
@@ -3527,9 +3527,16 @@ bool Item_func_group_concat::setup(THD *thd)
"all_fields". The resulting field list is used as input to create
tmp table columns.
*/
- if (arg_count_order &&
- setup_order(thd, args, context->table_list, list, all_fields, *order))
- DBUG_RETURN(TRUE);
+ if (arg_count_order)
+ {
+ uint n_elems= arg_count_order + all_fields.elements;
+ ref_pointer_array= static_cast<Item**>(thd->alloc(sizeof(Item*) * n_elems));
+ memcpy(ref_pointer_array, args, arg_count * sizeof(Item*));
+ if (!ref_pointer_array ||
+ setup_order(thd, ref_pointer_array, context->table_list, list,
+ all_fields, *order))
+ DBUG_RETURN(TRUE);
+ }
count_field_types(select_lex, tmp_table_param, all_fields, 0);
tmp_table_param->force_copy_fields= force_copy_fields;
diff --git a/sql/item_sum.h b/sql/item_sum.h
index d28c654c438..09a20487226 100644
--- a/sql/item_sum.h
+++ b/sql/item_sum.h
@@ -1394,6 +1394,7 @@ class Item_func_group_concat : public Item_sum
String *separator;
TREE tree_base;
TREE *tree;
+ Item **ref_pointer_array;
/**
If DISTINCT is used with this GROUP_CONCAT, this member is used to filter
diff --git a/sql/log.cc b/sql/log.cc
index 50c036ef650..d22333a0f49 100644
--- a/sql/log.cc
+++ b/sql/log.cc
@@ -4129,6 +4129,7 @@ int MYSQL_BIN_LOG::purge_first_log(Relay_log_info* rli, bool included)
int error;
char *to_purge_if_included= NULL;
inuse_relaylog *ir;
+ ulonglong log_space_reclaimed= 0;
DBUG_ENTER("purge_first_log");
DBUG_ASSERT(is_open());
@@ -4200,17 +4201,13 @@ int MYSQL_BIN_LOG::purge_first_log(Relay_log_info* rli, bool included)
DBUG_EXECUTE_IF("crash_before_purge_logs", DBUG_SUICIDE(););
- mysql_mutex_lock(&rli->log_space_lock);
rli->relay_log.purge_logs(to_purge_if_included, included,
- 0, 0, &rli->log_space_total);
- mysql_mutex_unlock(&rli->log_space_lock);
+ 0, 0, &log_space_reclaimed);
- /*
- Ok to broadcast after the critical region as there is no risk of
- the mutex being destroyed by this thread later - this helps save
- context switches
- */
+ mysql_mutex_lock(&rli->log_space_lock);
+ rli->log_space_total-= log_space_reclaimed;
mysql_cond_broadcast(&rli->log_space_cond);
+ mysql_mutex_unlock(&rli->log_space_lock);
/*
* Need to update the log pos because purge logs has been called
@@ -4259,8 +4256,8 @@ int MYSQL_BIN_LOG::update_log_index(LOG_INFO* log_info, bool need_update_threads
@param need_mutex
@param need_update_threads If we want to update the log coordinates of
all threads. False for relay logs, true otherwise.
- @param freed_log_space If not null, decrement this variable of
- the amount of log space freed
+ @param reclaimeed_log_space If not null, increment this variable to
+ the amount of log space freed
@note
If any of the logs before the deleted one is in use,
@@ -4276,10 +4273,10 @@ int MYSQL_BIN_LOG::update_log_index(LOG_INFO* log_info, bool need_update_threads
*/
int MYSQL_BIN_LOG::purge_logs(const char *to_log,
- bool included,
- bool need_mutex,
- bool need_update_threads,
- ulonglong *decrease_log_space)
+ bool included,
+ bool need_mutex,
+ bool need_update_threads,
+ ulonglong *reclaimed_space)
{
int error= 0;
bool exit_loop= 0;
@@ -4343,7 +4340,7 @@ int MYSQL_BIN_LOG::purge_logs(const char *to_log,
err:
/* Read each entry from purge_index_file and delete the file. */
if (is_inited_purge_index_file() &&
- (error= purge_index_entry(thd, decrease_log_space, FALSE)))
+ (error= purge_index_entry(thd, reclaimed_space, FALSE)))
sql_print_error("MSYQL_BIN_LOG::purge_logs failed to process registered files"
" that would be purged.");
close_purge_index_file();
@@ -4448,7 +4445,7 @@ int MYSQL_BIN_LOG::register_create_index_entry(const char *entry)
DBUG_RETURN(register_purge_index_entry(entry));
}
-int MYSQL_BIN_LOG::purge_index_entry(THD *thd, ulonglong *decrease_log_space,
+int MYSQL_BIN_LOG::purge_index_entry(THD *thd, ulonglong *reclaimed_space,
bool need_mutex)
{
DBUG_ENTER("MYSQL_BIN_LOG:purge_index_entry");
@@ -4568,8 +4565,8 @@ int MYSQL_BIN_LOG::purge_index_entry(THD *thd, ulonglong *decrease_log_space,
DBUG_PRINT("info",("purging %s",log_info.log_file_name));
if (!my_delete(log_info.log_file_name, MYF(0)))
{
- if (decrease_log_space)
- *decrease_log_space-= s.st_size;
+ if (reclaimed_space)
+ *reclaimed_space+= s.st_size;
}
else
{
diff --git a/sql/mysqld.cc b/sql/mysqld.cc
index c9682e15eae..7cb3072e7c4 100644
--- a/sql/mysqld.cc
+++ b/sql/mysqld.cc
@@ -2768,6 +2768,16 @@ void unlink_thd(THD *thd)
sync feature has been shut down at this point.
*/
DBUG_EXECUTE_IF("sleep_after_lock_thread_count_before_delete_thd", sleep(5););
+ if (unlikely(abort_loop))
+ {
+ /*
+ During shutdown, we have to delete thd inside the mutex
+ to not refer to mutexes that may be deleted during shutdown
+ */
+ delete thd;
+ thd= 0;
+ }
+ thread_count--;
mysql_mutex_unlock(&LOCK_thread_count);
delete thd;
diff --git a/sql/rpl_handler.cc b/sql/rpl_handler.cc
index 09e221e9bd5..917a9d11b5a 100644
--- a/sql/rpl_handler.cc
+++ b/sql/rpl_handler.cc
@@ -39,8 +39,6 @@ typedef struct Trans_binlog_info {
char log_file[FN_REFLEN];
} Trans_binlog_info;
-static pthread_key(Trans_binlog_info*, RPL_TRANS_BINLOG_INFO);
-
int get_user_var_int(const char *name,
long long int *value, int *null_value)
{
@@ -144,13 +142,6 @@ int delegates_init()
}
#endif
- if (pthread_key_create(&RPL_TRANS_BINLOG_INFO, NULL))
- {
- sql_print_error("Error while creating pthread specific data key for replication. "
- "Please report a bug.");
- return 1;
- }
-
return 0;
}
@@ -196,27 +187,27 @@ void delegates_destroy()
int Trans_delegate::after_commit(THD *thd, bool all)
{
Trans_param param;
+ Trans_binlog_info *log_info;
bool is_real_trans= (all || thd->transaction.all.ha_list == 0);
+ int ret= 0;
param.flags = is_real_trans ? TRANS_IS_REAL_TRANS : 0;
- Trans_binlog_info *log_info=
- my_pthread_getspecific_ptr(Trans_binlog_info*, RPL_TRANS_BINLOG_INFO);
+ log_info= thd->semisync_info;
- param.log_file= log_info ? log_info->log_file : 0;
+ param.log_file= log_info && log_info->log_file[0] ? log_info->log_file : 0;
param.log_pos= log_info ? log_info->log_pos : 0;
- int ret= 0;
FOREACH_OBSERVER(ret, after_commit, false, (&param));
/*
This is the end of a real transaction or autocommit statement, we
- can free the memory allocated for binlog file and position.
+ can mark the memory unused.
*/
if (is_real_trans && log_info)
{
- my_pthread_setspecific_ptr(RPL_TRANS_BINLOG_INFO, NULL);
- my_free(log_info);
+ log_info->log_file[0]= 0;
+ log_info->log_pos= 0;
}
return ret;
}
@@ -224,27 +215,27 @@ int Trans_delegate::after_commit(THD *thd, bool all)
int Trans_delegate::after_rollback(THD *thd, bool all)
{
Trans_param param;
+ Trans_binlog_info *log_info;
bool is_real_trans= (all || thd->transaction.all.ha_list == 0);
+ int ret= 0;
param.flags = is_real_trans ? TRANS_IS_REAL_TRANS : 0;
- Trans_binlog_info *log_info=
- my_pthread_getspecific_ptr(Trans_binlog_info*, RPL_TRANS_BINLOG_INFO);
-
- param.log_file= log_info ? log_info->log_file : 0;
+ log_info= thd->semisync_info;
+
+ param.log_file= log_info && log_info->log_file[0] ? log_info->log_file : 0;
param.log_pos= log_info ? log_info->log_pos : 0;
- int ret= 0;
FOREACH_OBSERVER(ret, after_rollback, false, (&param));
/*
This is the end of a real transaction or autocommit statement, we
- can free the memory allocated for binlog file and position.
+ can mark the memory unused.
*/
if (is_real_trans && log_info)
{
- my_pthread_setspecific_ptr(RPL_TRANS_BINLOG_INFO, NULL);
- my_free(log_info);
+ log_info->log_file[0]= 0;
+ log_info->log_pos= 0;
}
return ret;
}
@@ -255,25 +246,24 @@ int Binlog_storage_delegate::after_flush(THD *thd,
bool synced)
{
Binlog_storage_param param;
+ Trans_binlog_info *log_info;
uint32 flags=0;
+ int ret= 0;
+
if (synced)
flags |= BINLOG_STORAGE_IS_SYNCED;
- Trans_binlog_info *log_info=
- my_pthread_getspecific_ptr(Trans_binlog_info*, RPL_TRANS_BINLOG_INFO);
-
- if (!log_info)
+ if (!(log_info= thd->semisync_info))
{
if(!(log_info=
- (Trans_binlog_info *)my_malloc(sizeof(Trans_binlog_info), MYF(0))))
+ (Trans_binlog_info*) my_malloc(sizeof(Trans_binlog_info), MYF(0))))
return 1;
- my_pthread_setspecific_ptr(RPL_TRANS_BINLOG_INFO, log_info);
+ thd->semisync_info= log_info;
}
-
+
strcpy(log_info->log_file, log_file+dirname_length(log_file));
log_info->log_pos = log_pos;
- int ret= 0;
FOREACH_OBSERVER(ret, after_flush, false,
(&param, log_info->log_file, log_info->log_pos, flags));
return ret;
diff --git a/sql/rpl_utility.cc b/sql/rpl_utility.cc
index 6a8dee229bb..27a7a0478b6 100644
--- a/sql/rpl_utility.cc
+++ b/sql/rpl_utility.cc
@@ -947,6 +947,7 @@ TABLE *table_def::create_conversion_table(THD *thd, rpl_group_info *rgi,
{
Create_field *field_def=
(Create_field*) alloc_root(thd->mem_root, sizeof(Create_field));
+ bool unsigned_flag= 0;
if (field_list.push_back(field_def))
DBUG_RETURN(NULL);
@@ -956,8 +957,7 @@ TABLE *table_def::create_conversion_table(THD *thd, rpl_group_info *rgi,
uint32 max_length=
max_display_length_for_field(type(col), field_metadata(col));
- switch(type(col))
- {
+ switch(type(col)) {
int precision;
case MYSQL_TYPE_ENUM:
case MYSQL_TYPE_SET:
@@ -996,6 +996,18 @@ TABLE *table_def::create_conversion_table(THD *thd, rpl_group_info *rgi,
pack_length= field_metadata(col) & 0x00ff;
break;
+ case MYSQL_TYPE_TINY:
+ case MYSQL_TYPE_SHORT:
+ case MYSQL_TYPE_INT24:
+ case MYSQL_TYPE_LONG:
+ case MYSQL_TYPE_LONGLONG:
+ /*
+ As we don't know if the integer was signed or not on the master,
+ assume we have same sign on master and slave. This is true when not
+ using conversions so it should be true also when using conversions.
+ */
+ unsigned_flag= ((Field_num*) target_table->field[col])->unsigned_flag;
+ break;
default:
break;
}
@@ -1003,12 +1015,13 @@ TABLE *table_def::create_conversion_table(THD *thd, rpl_group_info *rgi,
DBUG_PRINT("debug", ("sql_type: %d, target_field: '%s', max_length: %d, decimals: %d,"
" maybe_null: %d, unsigned_flag: %d, pack_length: %u",
binlog_type(col), target_table->field[col]->field_name,
- max_length, decimals, TRUE, FALSE, pack_length));
+ max_length, decimals, TRUE, unsigned_flag,
+ pack_length));
field_def->init_for_tmp_table(type(col),
max_length,
decimals,
TRUE, // maybe_null
- FALSE, // unsigned_flag
+ unsigned_flag,
pack_length);
field_def->charset= target_table->field[col]->charset();
field_def->interval= interval;
diff --git a/sql/slave.cc b/sql/slave.cc
index dde57bc16fb..0243272c443 100644
--- a/sql/slave.cc
+++ b/sql/slave.cc
@@ -4523,9 +4523,7 @@ pthread_handler_t handle_slave_sql(void *arg)
rli->parallel.reset();
//tell the I/O thread to take relay_log_space_limit into account from now on
- mysql_mutex_lock(&rli->log_space_lock);
rli->ignore_log_space_limit= 0;
- mysql_mutex_unlock(&rli->log_space_lock);
serial_rgi->gtid_sub_id= 0;
serial_rgi->gtid_pending= false;
@@ -6626,14 +6624,8 @@ static Log_event* next_event(rpl_group_info *rgi, ulonglong *event_size)
rli->ignore_log_space_limit= true;
}
- /*
- If the I/O thread is blocked, unblock it. Ok to broadcast
- after unlock, because the mutex is only destroyed in
- ~Relay_log_info(), i.e. when rli is destroyed, and rli will
- not be destroyed before we exit the present function.
- */
- mysql_mutex_unlock(&rli->log_space_lock);
mysql_cond_broadcast(&rli->log_space_cond);
+ mysql_mutex_unlock(&rli->log_space_lock);
// Note that wait_for_update_relay_log unlocks lock_log !
rli->relay_log.wait_for_update_relay_log(rli->sql_driver_thd);
// re-acquire data lock since we released it earlier
diff --git a/sql/sql_base.cc b/sql/sql_base.cc
index 13b8625ebe6..643ad4b41cb 100644
--- a/sql/sql_base.cc
+++ b/sql/sql_base.cc
@@ -6583,6 +6583,7 @@ find_field_in_tables(THD *thd, Item_ident *item,
if (item->cached_table)
{
+ DBUG_PRINT("info", ("using cached table"));
/*
This shortcut is used by prepared statements. We assume that
TABLE_LIST *first_table is not changed during query execution (which
diff --git a/sql/sql_class.cc b/sql/sql_class.cc
index cf0c4a1b84f..d2221d210e0 100644
--- a/sql/sql_class.cc
+++ b/sql/sql_class.cc
@@ -960,6 +960,7 @@ THD::THD()
file_id = 0;
query_id= 0;
query_name_consts= 0;
+ semisync_info= 0;
db_charset= global_system_variables.collation_database;
bzero(ha_data, sizeof(ha_data));
mysys_var=0;
@@ -1395,6 +1396,7 @@ void THD::init(void)
bzero((char *) &org_status_var, sizeof(org_status_var));
start_bytes_received= 0;
last_commit_gtid.seq_no= 0;
+ status_in_global= 0;
if (variables.sql_log_bin)
variables.option_bits|= OPTION_BIN_LOG;
@@ -1500,6 +1502,7 @@ void THD::change_user(void)
cleanup();
reset_killed();
cleanup_done= 0;
+ status_in_global= 0;
init();
stmt_map.reset();
my_hash_init(&user_vars, system_charset_info, USER_VARS_HASH_SIZE, 0, 0,
@@ -1630,6 +1633,7 @@ THD::~THD()
mysql_audit_free_thd(this);
if (rgi_slave)
rgi_slave->cleanup_after_session();
+ my_free(semisync_info);
#endif
free_root(&main_mem_root, MYF(0));
diff --git a/sql/sql_class.h b/sql/sql_class.h
index a8d8444571e..f577935f545 100644
--- a/sql/sql_class.h
+++ b/sql/sql_class.h
@@ -64,7 +64,6 @@ class Reprepare_observer;
class Relay_log_info;
struct rpl_group_info;
class Rpl_filter;
-
class Query_log_event;
class Load_log_event;
class Slave_log_event;
@@ -75,6 +74,7 @@ class Parser_state;
class Rows_log_event;
class Sroutine_hash_entry;
class user_var_entry;
+struct Trans_binlog_info;
class rpl_io_thread_info;
class rpl_sql_thread_info;
@@ -1959,6 +1959,9 @@ public:
*/
const char *where;
+ /* Needed by MariaDB semi sync replication */
+ Trans_binlog_info *semisync_info;
+
ulong client_capabilities; /* What the client supports */
ulong max_client_packet_length;
@@ -2027,11 +2030,11 @@ public:
/* Do not set socket timeouts for wait_timeout (used with threadpool) */
bool skip_wait_timeout;
- /* container for handler's private per-connection data */
- Ha_data ha_data[MAX_HA];
-
bool prepare_derived_at_open;
+ /* Set to 1 if status of this THD is already in global status */
+ bool status_in_global;
+
/*
To signal that the tmp table to be created is created for materialized
derived table or a view.
@@ -2040,6 +2043,9 @@ public:
bool save_prep_leaf_list;
+ /* container for handler's private per-connection data */
+ Ha_data ha_data[MAX_HA];
+
#ifndef MYSQL_CLIENT
binlog_cache_mngr * binlog_setup_trx_data();
@@ -3687,6 +3693,8 @@ public:
{
mysql_mutex_lock(&LOCK_status);
add_to_status(&global_status_var, &status_var);
+ /* Mark that this THD status has already been added in global status */
+ status_in_global= 1;
mysql_mutex_unlock(&LOCK_status);
}
diff --git a/sql/sql_lex.cc b/sql/sql_lex.cc
index 2026d5f5059..3f3bc40ad59 100644
--- a/sql/sql_lex.cc
+++ b/sql/sql_lex.cc
@@ -1910,7 +1910,6 @@ void st_select_lex::init_select()
with_sum_func= 0;
is_correlated= 0;
cur_pos_in_select_list= UNDEF_POS;
- non_agg_fields.empty();
cond_value= having_value= Item::COND_UNDEF;
inner_refs_list.empty();
insert_tables= 0;
@@ -1918,6 +1917,7 @@ void st_select_lex::init_select()
m_non_agg_field_used= false;
m_agg_func_used= false;
name_visibility_map= 0;
+ join= 0;
}
/*
diff --git a/sql/sql_lex.h b/sql/sql_lex.h
index dcd8ddfce91..3d008723f66 100644
--- a/sql/sql_lex.h
+++ b/sql/sql_lex.h
@@ -823,8 +823,6 @@ public:
bool no_wrap_view_item;
/* exclude this select from check of unique_table() */
bool exclude_from_table_unique_test;
- /* List of fields that aren't under an aggregate function */
- List<Item_field> non_agg_fields;
/* index in the select list of the expression currently being fixed */
int cur_pos_in_select_list;
diff --git a/sql/sql_select.cc b/sql/sql_select.cc
index e0f560f0b3a..aa9a3f2da0e 100644
--- a/sql/sql_select.cc
+++ b/sql/sql_select.cc
@@ -5185,6 +5185,8 @@ update_ref_and_keys(THD *thd, DYNAMIC_ARRAY *keyuse,JOIN_TAB *join_tab,
KEY_FIELD *key_fields, *end, *field;
uint sz;
uint m= MY_MAX(select_lex->max_equal_elems,1);
+ DBUG_ENTER("update_ref_and_keys");
+ DBUG_PRINT("enter", ("normal_tables: %llx", normal_tables));
SELECT_LEX *sel=thd->lex->current_select;
sel->cond_count= 0;
@@ -5231,7 +5233,7 @@ update_ref_and_keys(THD *thd, DYNAMIC_ARRAY *keyuse,JOIN_TAB *join_tab,
sz= MY_MAX(sizeof(KEY_FIELD),sizeof(SARGABLE_PARAM))*
((sel->cond_count*2 + sel->between_count)*m+1);
if (!(key_fields=(KEY_FIELD*) thd->alloc(sz)))
- return TRUE; /* purecov: inspected */
+ DBUG_RETURN(TRUE); /* purecov: inspected */
and_level= 0;
field= end= key_fields;
*sargables= (SARGABLE_PARAM *) key_fields +
@@ -5241,7 +5243,7 @@ update_ref_and_keys(THD *thd, DYNAMIC_ARRAY *keyuse,JOIN_TAB *join_tab,
if (my_init_dynamic_array(keyuse,sizeof(KEYUSE),20,64,
MYF(MY_THREAD_SPECIFIC)))
- return TRUE;
+ DBUG_RETURN(TRUE);
if (cond)
{
@@ -5291,16 +5293,16 @@ update_ref_and_keys(THD *thd, DYNAMIC_ARRAY *keyuse,JOIN_TAB *join_tab,
for ( ; field != end ; field++)
{
if (add_key_part(keyuse,field))
- return TRUE;
+ DBUG_RETURN(TRUE);
}
if (select_lex->ftfunc_list->elements)
{
if (add_ft_keys(keyuse,join_tab,cond,normal_tables))
- return TRUE;
+ DBUG_RETURN(TRUE);
}
- return FALSE;
+ DBUG_RETURN(FALSE);
}
@@ -21544,7 +21546,7 @@ setup_group(THD *thd, Item **ref_pointer_array, TABLE_LIST *tables,
Item_field *field;
int cur_pos_in_select_list= 0;
List_iterator<Item> li(fields);
- List_iterator<Item_field> naf_it(thd->lex->current_select->non_agg_fields);
+ List_iterator<Item_field> naf_it(thd->lex->current_select->join->non_agg_fields);
field= naf_it++;
while (field && (item=li++))
diff --git a/sql/sql_select.h b/sql/sql_select.h
index 5aa29715dc3..61157130f50 100644
--- a/sql/sql_select.h
+++ b/sql/sql_select.h
@@ -934,6 +934,9 @@ public:
Item *pre_sort_idx_pushed_cond;
void clean_pre_sort_join_tab();
+ /* List of fields that aren't under an aggregate function */
+ List<Item_field> non_agg_fields;
+
/*
For "Using temporary+Using filesort" queries, JOIN::join_tab can point to
either:
@@ -1326,6 +1329,7 @@ public:
all_fields= fields_arg;
if (&fields_list != &fields_arg) /* Avoid valgrind-warning */
fields_list= fields_arg;
+ non_agg_fields.empty();
bzero((char*) &keyuse,sizeof(keyuse));
tmp_table_param.init();
tmp_table_param.end_write_records= HA_POS_ERROR;
diff --git a/sql/sql_show.cc b/sql/sql_show.cc
index 2413cb5ba53..103d39e7fd0 100644
--- a/sql/sql_show.cc
+++ b/sql/sql_show.cc
@@ -3512,7 +3512,10 @@ void calc_sum_of_all_status(STATUS_VAR *to)
/* Add to this status from existing threads */
while ((tmp= it++))
- add_to_status(to, &tmp->status_var);
+ {
+ if (!tmp->status_in_global)
+ add_to_status(to, &tmp->status_var);
+ }
mysql_mutex_unlock(&LOCK_thread_count);
DBUG_VOID_RETURN;
diff --git a/sql/sql_test.cc b/sql/sql_test.cc
index 82abc861ec4..d73b6db830e 100644
--- a/sql/sql_test.cc
+++ b/sql/sql_test.cc
@@ -222,7 +222,7 @@ TEST_join(JOIN *join)
#define FT_KEYPART (MAX_FIELDS+10)
-void print_keyuse(KEYUSE *keyuse)
+static void print_keyuse(KEYUSE *keyuse)
{
char buff[256];
char buf2[64];
@@ -240,14 +240,11 @@ void print_keyuse(KEYUSE *keyuse)
else
fieldname= key_info->key_part[keyuse->keypart].field->field_name;
ll2str(keyuse->used_tables, buf2, 16, 0);
- DBUG_LOCK_FILE;
fprintf(DBUG_FILE, "KEYUSE: %s.%s=%s optimize: %u used_tables: %s "
"ref_table_rows: %lu keypart_map: %0lx\n",
keyuse->table->alias.c_ptr(), fieldname, str.ptr(),
(uint) keyuse->optimize, buf2, (ulong) keyuse->ref_table_rows,
(ulong) keyuse->keypart_map);
- DBUG_UNLOCK_FILE;
- //key_part_map keypart_map; --?? there can be several?
}
@@ -256,9 +253,9 @@ void print_keyuse_array(DYNAMIC_ARRAY *keyuse_array)
{
DBUG_LOCK_FILE;
fprintf(DBUG_FILE, "KEYUSE array (%d elements)\n", keyuse_array->elements);
- DBUG_UNLOCK_FILE;
for(uint i=0; i < keyuse_array->elements; i++)
print_keyuse((KEYUSE*)dynamic_array_ptr(keyuse_array, i));
+ DBUG_UNLOCK_FILE;
}
diff --git a/sql/sql_union.cc b/sql/sql_union.cc
index 77a3b1eec8f..a316fbad726 100644
--- a/sql/sql_union.cc
+++ b/sql/sql_union.cc
@@ -1029,7 +1029,6 @@ bool st_select_lex::cleanup()
{
error= (bool) ((uint) error | (uint) lex_unit->cleanup());
}
- non_agg_fields.empty();
inner_refs_list.empty();
exclude_from_table_unique_test= FALSE;
DBUG_RETURN(error);
@@ -1040,6 +1039,7 @@ void st_select_lex::cleanup_all_joins(bool full)
{
SELECT_LEX_UNIT *unit;
SELECT_LEX *sl;
+ DBUG_ENTER("st_select_lex::cleanup_all_joins");
if (join)
join->cleanup(full);
@@ -1047,6 +1047,7 @@ void st_select_lex::cleanup_all_joins(bool full)
for (unit= first_inner_unit(); unit; unit= unit->next_unit())
for (sl= unit->first_select(); sl; sl= sl->next_select())
sl->cleanup_all_joins(full);
+ DBUG_VOID_RETURN;
}
diff --git a/sql/table.cc b/sql/table.cc
index 053269ab435..cdc7b4381cd 100644
--- a/sql/table.cc
+++ b/sql/table.cc
@@ -5271,7 +5271,7 @@ Item *Field_iterator_table::create_item(THD *thd)
if (item && thd->variables.sql_mode & MODE_ONLY_FULL_GROUP_BY &&
!thd->lex->in_sum_func && select->cur_pos_in_select_list != UNDEF_POS)
{
- select->non_agg_fields.push_back(item);
+ select->join->non_agg_fields.push_back(item);
item->marker= select->cur_pos_in_select_list;
select->set_non_agg_field_used(true);
}