summaryrefslogtreecommitdiff
path: root/sql
diff options
context:
space:
mode:
authorMarko Mäkelä <marko.makela@mariadb.com>2017-11-10 16:12:45 +0200
committerMarko Mäkelä <marko.makela@mariadb.com>2017-11-10 16:12:45 +0200
commita48aa0cd569eda88bef98ed4abe41b0b570fcd51 (patch)
tree6008b19aabfe0554432c87614d1022594f08fc5f /sql
parent8409f721ffe2d91b11d3fc03c6872ff57051bbf8 (diff)
parent386e5d476e9bf8f216c760c9076ae0ecdc99054d (diff)
downloadmariadb-git-a48aa0cd569eda88bef98ed4abe41b0b570fcd51.tar.gz
Merge bb-10.2-ext into 10.3
Diffstat (limited to 'sql')
-rw-r--r--sql/datadict.cc20
-rw-r--r--sql/handler.cc9
-rw-r--r--sql/item.cc25
-rw-r--r--sql/item.h25
-rw-r--r--sql/item_cmpfunc.cc25
-rw-r--r--sql/item_cmpfunc.h10
-rw-r--r--sql/item_func.cc5
-rw-r--r--sql/item_func.h9
-rw-r--r--sql/item_geofunc.cc2
-rw-r--r--sql/item_inetfunc.cc7
-rw-r--r--sql/item_inetfunc.h6
-rw-r--r--sql/item_row.cc5
-rw-r--r--sql/item_row.h2
-rw-r--r--sql/item_strfunc.h6
-rw-r--r--sql/item_subselect.cc15
-rw-r--r--sql/item_subselect.h4
-rw-r--r--sql/item_sum.cc12
-rw-r--r--sql/item_sum.h1
-rw-r--r--sql/item_xmlfunc.cc30
-rw-r--r--sql/lock.cc6
-rw-r--r--sql/log.cc32
-rw-r--r--sql/mysqld.cc133
-rw-r--r--sql/mysqld.h7
-rw-r--r--sql/opt_subselect.cc9
-rw-r--r--sql/share/errmsg-utf8.txt38
-rw-r--r--sql/sp_head.cc2
-rw-r--r--sql/sql_class.h7
-rw-r--r--sql/sql_const.h5
-rw-r--r--sql/sql_cte.cc22
-rw-r--r--sql/sql_delete.cc6
-rw-r--r--sql/sql_derived.cc6
-rw-r--r--sql/sql_insert.cc8
-rw-r--r--sql/sql_load.cc4
-rw-r--r--sql/sql_parse.cc17
-rw-r--r--sql/sql_partition_admin.cc2
-rw-r--r--sql/sql_profile.h2
-rw-r--r--sql/sql_select.cc183
-rw-r--r--sql/sql_select.h3
-rw-r--r--sql/sql_show.cc37
-rw-r--r--sql/sql_table.cc2
-rw-r--r--sql/sql_union.cc18
-rw-r--r--sql/sql_update.cc4
-rw-r--r--sql/sql_view.cc1
-rw-r--r--sql/winservice.c11
-rw-r--r--sql/wsrep_applier.cc24
-rw-r--r--sql/wsrep_hton.cc2
-rw-r--r--sql/wsrep_mysqld.cc2
-rw-r--r--sql/wsrep_thd.cc6
48 files changed, 512 insertions, 305 deletions
diff --git a/sql/datadict.cc b/sql/datadict.cc
index 7ea83236cd6..4425f278e12 100644
--- a/sql/datadict.cc
+++ b/sql/datadict.cc
@@ -46,11 +46,13 @@ static int read_string(File file, uchar**to, size_t length)
engine_name is a LEX_CSTRING, where engine_name->str must point to
a buffer of at least NAME_CHAR_LEN+1 bytes.
+ If engine_name is 0, then the function will only test if the file is a
+ view or not
@param[out] is_sequence 1 if table is a SEQUENCE, 0 otherwise
@retval TABLE_TYPE_UNKNOWN error
- @retval TABLE_TYPE_TABLE table
+ @retval TABLE_TYPE_NORMAL table
@retval TABLE_TYPE_SEQUENCE sequence table
@retval TABLE_TYPE_VIEW view
*/
@@ -80,12 +82,26 @@ Table_type dd_frm_type(THD *thd, char *path, LEX_CSTRING *engine_name,
goto err;
}
+ /*
+ We return TABLE_TYPE_NORMAL if we can read the .frm file. This allows us
+ to drop a bad .frm file with DROP TABLE
+ */
type= TABLE_TYPE_NORMAL;
- if (!is_binary_frm_header(header) || !engine_name)
+ /* engine_name is 0 if we only want to know if table is view or not */
+ if (!engine_name)
goto err;
+ /*
+ Initialize engine name in case we are not able to find it out
+ The cast is safe, as engine_name->str points to a usable buffer.
+ */
engine_name->length= 0;
+ ((char*) (engine_name->str))[0]= 0;
+
+ if (!is_binary_frm_header(header))
+ goto err;
+
dbt= header[3];
if (((header[39] >> 4) & 3) == HA_CHOICE_YES)
diff --git a/sql/handler.cc b/sql/handler.cc
index 5e392fa02e6..c260b5da54d 100644
--- a/sql/handler.cc
+++ b/sql/handler.cc
@@ -2247,7 +2247,7 @@ int ha_start_consistent_snapshot(THD *thd)
*/
if (warn)
push_warning(thd, Sql_condition::WARN_LEVEL_WARN, ER_UNKNOWN_ERROR,
- "This MySQL server does not support any "
+ "This MariaDB server does not support any "
"consistent-read capable storage engine");
return 0;
}
@@ -5101,8 +5101,13 @@ bool ha_table_exists(THD *thd, const char *db, const char *table_name,
{
char engine_buf[NAME_CHAR_LEN + 1];
LEX_CSTRING engine= { engine_buf, 0 };
+ Table_type type;
- if (dd_frm_type(thd, path, &engine, is_sequence) != TABLE_TYPE_VIEW)
+ if ((type= dd_frm_type(thd, path, &engine, is_sequence)) ==
+ TABLE_TYPE_UNKNOWN)
+ DBUG_RETURN(0);
+
+ if (type != TABLE_TYPE_VIEW)
{
plugin_ref p= plugin_lock_by_name(thd, &engine,
MYSQL_STORAGE_ENGINE_PLUGIN);
diff --git a/sql/item.cc b/sql/item.cc
index d36e6516fb9..2285ae28041 100644
--- a/sql/item.cc
+++ b/sql/item.cc
@@ -3237,7 +3237,8 @@ table_map Item_field::all_used_tables() const
return (get_depended_from() ? OUTER_REF_TABLE_BIT : field->table->map);
}
-void Item_field::fix_after_pullout(st_select_lex *new_parent, Item **ref)
+void Item_field::fix_after_pullout(st_select_lex *new_parent, Item **ref,
+ bool merge)
{
if (new_parent == get_depended_from())
depended_from= NULL;
@@ -3281,6 +3282,19 @@ void Item_field::fix_after_pullout(st_select_lex *new_parent, Item **ref)
if (!need_change)
return;
+ if (!merge)
+ {
+ /*
+ It is transformation without merge.
+ This field was "outer" for the inner SELECT where it was taken and
+ moved up.
+ "Outer" fields uses normal SELECT_LEX context of upper SELECTs for
+ name resolution, so we can switch everything to it safely.
+ */
+ this->context= &new_parent->context;
+ return;
+ }
+
Name_resolution_context *ctx= new Name_resolution_context();
if (context->select_lex == new_parent)
{
@@ -8704,18 +8718,19 @@ bool Item_outer_ref::fix_fields(THD *thd, Item **reference)
void Item_outer_ref::fix_after_pullout(st_select_lex *new_parent,
- Item **ref_arg)
+ Item **ref_arg, bool merge)
{
if (get_depended_from() == new_parent)
{
*ref_arg= outer_ref;
- (*ref_arg)->fix_after_pullout(new_parent, ref_arg);
+ (*ref_arg)->fix_after_pullout(new_parent, ref_arg, merge);
}
}
-void Item_ref::fix_after_pullout(st_select_lex *new_parent, Item **refptr)
+void Item_ref::fix_after_pullout(st_select_lex *new_parent, Item **refptr,
+ bool merge)
{
- (*ref)->fix_after_pullout(new_parent, ref);
+ (*ref)->fix_after_pullout(new_parent, ref, merge);
if (get_depended_from() == new_parent)
depended_from= NULL;
}
diff --git a/sql/item.h b/sql/item.h
index c7ef5202389..dbbc93c5e9d 100644
--- a/sql/item.h
+++ b/sql/item.h
@@ -733,7 +733,9 @@ public:
Fix after some tables has been pulled out. Basically re-calculate all
attributes that are dependent on the tables.
*/
- virtual void fix_after_pullout(st_select_lex *new_parent, Item **ref) {};
+ virtual void fix_after_pullout(st_select_lex *new_parent, Item **ref,
+ bool merge)
+ {};
/*
This method should be used in case where we are sure that we do not need
@@ -2762,7 +2764,7 @@ public:
bool send(Protocol *protocol, st_value *buffer);
void reset_field(Field *f);
bool fix_fields(THD *, Item **);
- void fix_after_pullout(st_select_lex *new_parent, Item **ref);
+ void fix_after_pullout(st_select_lex *new_parent, Item **ref, bool merge);
void make_field(THD *thd, Send_field *tmp_field);
int save_in_field(Field *field,bool no_conversions);
void save_org_in_field(Field *field, fast_field_copier optimizer_data);
@@ -3028,6 +3030,17 @@ public:
Field *result_field;
Item_null_result(THD *thd): Item_null(thd), result_field(0) {}
bool is_result_field() { return result_field != 0; }
+#if MARIADB_VERSION_ID < 100300
+ enum_field_types field_type() const
+ {
+ return result_field->type();
+ }
+#else
+ const Type_handler *type_handler() const
+ {
+ return result_field->type_handler();
+ }
+#endif
void save_in_result_field(bool no_conversions)
{
save_in_field(result_field, no_conversions);
@@ -4392,7 +4405,7 @@ public:
bool send(Protocol *prot, st_value *buffer);
void make_field(THD *thd, Send_field *field);
bool fix_fields(THD *, Item **);
- void fix_after_pullout(st_select_lex *new_parent, Item **ref);
+ void fix_after_pullout(st_select_lex *new_parent, Item **ref, bool merge);
int save_in_field(Field *field, bool no_conversions);
void save_org_in_field(Field *field, fast_field_copier optimizer_data);
fast_field_copier setup_fast_field_copier(Field *field)
@@ -4700,9 +4713,9 @@ public:
Item *it= ((Item *) item)->real_item();
return orig_item->eq(it, binary_cmp);
}
- void fix_after_pullout(st_select_lex *new_parent, Item **refptr)
+ void fix_after_pullout(st_select_lex *new_parent, Item **refptr, bool merge)
{
- orig_item->fix_after_pullout(new_parent, &orig_item);
+ orig_item->fix_after_pullout(new_parent, &orig_item, merge);
}
int save_in_field(Field *to, bool no_conversions);
const Type_handler *type_handler() const { return orig_item->type_handler(); }
@@ -4971,7 +4984,7 @@ public:
outer_ref->save_org_in_field(result_field, NULL);
}
bool fix_fields(THD *, Item **);
- void fix_after_pullout(st_select_lex *new_parent, Item **ref);
+ void fix_after_pullout(st_select_lex *new_parent, Item **ref, bool merge);
table_map used_tables() const
{
return (*ref)->const_item() ? 0 : OUTER_REF_TABLE_BIT;
diff --git a/sql/item_cmpfunc.cc b/sql/item_cmpfunc.cc
index 775fb425000..fe73bfc3622 100644
--- a/sql/item_cmpfunc.cc
+++ b/sql/item_cmpfunc.cc
@@ -1220,10 +1220,11 @@ bool Item_in_optimizer::is_top_level_item()
}
-void Item_in_optimizer::fix_after_pullout(st_select_lex *new_parent, Item **ref)
+void Item_in_optimizer::fix_after_pullout(st_select_lex *new_parent,
+ Item **ref, bool merge)
{
/* This will re-calculate attributes of our Item_in_subselect: */
- Item_bool_func::fix_after_pullout(new_parent, ref);
+ Item_bool_func::fix_after_pullout(new_parent, ref, merge);
/* Then, re-calculate not_null_tables_cache: */
eval_not_null_tables(NULL);
@@ -2050,10 +2051,11 @@ bool Item_func_between::count_sargable_conds(void *arg)
}
-void Item_func_between::fix_after_pullout(st_select_lex *new_parent, Item **ref)
+void Item_func_between::fix_after_pullout(st_select_lex *new_parent,
+ Item **ref, bool merge)
{
/* This will re-calculate attributes of the arguments */
- Item_func_opt_neg::fix_after_pullout(new_parent, ref);
+ Item_func_opt_neg::fix_after_pullout(new_parent, ref, merge);
/* Then, re-calculate not_null_tables_cache according to our special rules */
eval_not_null_tables(NULL);
}
@@ -2378,10 +2380,11 @@ Item_func_if::eval_not_null_tables(void *opt_arg)
}
-void Item_func_if::fix_after_pullout(st_select_lex *new_parent, Item **ref)
+void Item_func_if::fix_after_pullout(st_select_lex *new_parent,
+ Item **ref, bool merge)
{
/* This will re-calculate attributes of the arguments */
- Item_func::fix_after_pullout(new_parent, ref);
+ Item_func::fix_after_pullout(new_parent, ref, merge);
/* Then, re-calculate not_null_tables_cache according to our special rules */
eval_not_null_tables(NULL);
}
@@ -4144,10 +4147,11 @@ Item_func_in::eval_not_null_tables(void *opt_arg)
}
-void Item_func_in::fix_after_pullout(st_select_lex *new_parent, Item **ref)
+void Item_func_in::fix_after_pullout(st_select_lex *new_parent, Item **ref,
+ bool merge)
{
/* This will re-calculate attributes of the arguments */
- Item_func_opt_neg::fix_after_pullout(new_parent, ref);
+ Item_func_opt_neg::fix_after_pullout(new_parent, ref, merge);
/* Then, re-calculate not_null_tables_cache according to our special rules */
eval_not_null_tables(NULL);
}
@@ -4671,7 +4675,8 @@ Item_cond::eval_not_null_tables(void *opt_arg)
}
-void Item_cond::fix_after_pullout(st_select_lex *new_parent, Item **ref)
+void Item_cond::fix_after_pullout(st_select_lex *new_parent, Item **ref,
+ bool merge)
{
List_iterator<Item> li(list);
Item *item;
@@ -4684,7 +4689,7 @@ void Item_cond::fix_after_pullout(st_select_lex *new_parent, Item **ref)
while ((item=li++))
{
table_map tmp_table_map;
- item->fix_after_pullout(new_parent, li.ref());
+ item->fix_after_pullout(new_parent, li.ref(), merge);
item= *li.ref();
used_tables_and_const_cache_join(item);
diff --git a/sql/item_cmpfunc.h b/sql/item_cmpfunc.h
index 2cb46deaafc..7bab02db263 100644
--- a/sql/item_cmpfunc.h
+++ b/sql/item_cmpfunc.h
@@ -375,7 +375,7 @@ public:
virtual void get_cache_parameters(List<Item> &parameters);
bool is_top_level_item();
bool eval_not_null_tables(void *opt_arg);
- void fix_after_pullout(st_select_lex *new_parent, Item **ref);
+ void fix_after_pullout(st_select_lex *new_parent, Item **ref, bool merge);
bool invisible_mode();
void reset_cache() { cache= NULL; }
Item *get_copy(THD *thd, MEM_ROOT *mem_root)
@@ -908,7 +908,7 @@ public:
bool fix_length_and_dec_numeric(THD *);
virtual void print(String *str, enum_query_type query_type);
bool eval_not_null_tables(void *opt_arg);
- void fix_after_pullout(st_select_lex *new_parent, Item **ref);
+ void fix_after_pullout(st_select_lex *new_parent, Item **ref, bool merge);
bool count_sargable_conds(void *arg);
void add_key_fields(JOIN *join, KEY_FIELD **key_fields,
uint *and_level, table_map usable_tables,
@@ -1144,7 +1144,7 @@ public:
}
const char *func_name() const { return "if"; }
bool eval_not_null_tables(void *opt_arg);
- void fix_after_pullout(st_select_lex *new_parent, Item **ref);
+ void fix_after_pullout(st_select_lex *new_parent, Item **ref, bool merge);
Item *get_copy(THD *thd, MEM_ROOT *mem_root)
{ return get_item_copy<Item_func_if>(thd, mem_root, this); }
private:
@@ -2382,7 +2382,7 @@ public:
const char *func_name() const { return "in"; }
enum precedence precedence() const { return CMP_PRECEDENCE; }
bool eval_not_null_tables(void *opt_arg);
- void fix_after_pullout(st_select_lex *new_parent, Item **ref);
+ void fix_after_pullout(st_select_lex *new_parent, Item **ref, bool merge);
bool count_sargable_conds(void *arg);
Item *get_copy(THD *thd, MEM_ROOT *mem_root)
{ return get_item_copy<Item_func_in>(thd, mem_root, this); }
@@ -2910,7 +2910,7 @@ public:
list.append(nlist);
}
bool fix_fields(THD *, Item **ref);
- void fix_after_pullout(st_select_lex *new_parent, Item **ref);
+ void fix_after_pullout(st_select_lex *new_parent, Item **ref, bool merge);
enum Type type() const { return COND_ITEM; }
List<Item>* argument_list() { return &list; }
diff --git a/sql/item_func.cc b/sql/item_func.cc
index 28690ff2bee..0d32fdf1824 100644
--- a/sql/item_func.cc
+++ b/sql/item_func.cc
@@ -406,7 +406,8 @@ Item_func::eval_not_null_tables(void *opt_arg)
}
-void Item_func::fix_after_pullout(st_select_lex *new_parent, Item **ref)
+void Item_func::fix_after_pullout(st_select_lex *new_parent, Item **ref,
+ bool merge)
{
Item **arg,**arg_end;
@@ -417,7 +418,7 @@ void Item_func::fix_after_pullout(st_select_lex *new_parent, Item **ref)
{
for (arg=args, arg_end=args+arg_count; arg != arg_end ; arg++)
{
- (*arg)->fix_after_pullout(new_parent, arg);
+ (*arg)->fix_after_pullout(new_parent, arg, merge);
Item *item= *arg;
used_tables_and_const_cache_join(item);
diff --git a/sql/item_func.h b/sql/item_func.h
index de213df0fc5..3ba2ebf9d86 100644
--- a/sql/item_func.h
+++ b/sql/item_func.h
@@ -129,7 +129,7 @@ public:
Item_func_or_sum::cleanup();
used_tables_and_const_cache_init();
}
- void fix_after_pullout(st_select_lex *new_parent, Item **ref);
+ void fix_after_pullout(st_select_lex *new_parent, Item **ref, bool merge);
void quick_fix_field();
table_map not_null_tables() const;
void update_used_tables()
@@ -2809,6 +2809,13 @@ public:
return sp_result_field->val_decimal(dec_buf);
}
+ bool get_date(MYSQL_TIME *ltime, ulonglong fuzzydate)
+ {
+ if (execute())
+ return true;
+ return sp_result_field->get_date(ltime, fuzzydate);
+ }
+
String *val_str(String *str)
{
String buf;
diff --git a/sql/item_geofunc.cc b/sql/item_geofunc.cc
index fe089e6283d..a060ed221bf 100644
--- a/sql/item_geofunc.cc
+++ b/sql/item_geofunc.cc
@@ -135,7 +135,7 @@ String *Item_func_geometry_from_json::val_str(String *str)
{
String *sv= args[1]->val_str(&tmp_js);
my_error(ER_WRONG_VALUE_FOR_TYPE, MYF(0),
- "option", sv->c_ptr(), "ST_GeometryFromJSON");
+ "option", sv->c_ptr_safe(), "ST_GeometryFromJSON");
null_value= 1;
return 0;
}
diff --git a/sql/item_inetfunc.cc b/sql/item_inetfunc.cc
index c434953ad43..d4788a39d5e 100644
--- a/sql/item_inetfunc.cc
+++ b/sql/item_inetfunc.cc
@@ -181,7 +181,8 @@ String *Item_func_inet_str_base::val_str_ascii(String *buffer)
return NULL;
}
- String *arg_str= args[0]->val_str(buffer);
+ StringBuffer<STRING_BUFFER_USUAL_SIZE> tmp;
+ String *arg_str= args[0]->val_str(&tmp);
if (!arg_str) // Out-of memory happened. The error has been reported.
{ // Or: the underlying field is NULL
null_value= true;
@@ -679,7 +680,7 @@ static void ipv6_to_str(const in6_addr *ipv6, char *str)
@retval true The string has been converted sucessfully.
*/
-bool Item_func_inet6_aton::calc_value(String *arg, String *buffer)
+bool Item_func_inet6_aton::calc_value(const String *arg, String *buffer)
{
// ipv4-string -> varbinary(4)
// ipv6-string -> varbinary(16)
@@ -719,7 +720,7 @@ bool Item_func_inet6_aton::calc_value(String *arg, String *buffer)
@retval true The string has been converted sucessfully.
*/
-bool Item_func_inet6_ntoa::calc_value(String *arg, String *buffer)
+bool Item_func_inet6_ntoa::calc_value(const String *arg, String *buffer)
{
if (arg->charset() != &my_charset_bin)
return false;
diff --git a/sql/item_inetfunc.h b/sql/item_inetfunc.h
index 13ce003a374..bd0a95b5270 100644
--- a/sql/item_inetfunc.h
+++ b/sql/item_inetfunc.h
@@ -105,7 +105,7 @@ public:
virtual String *val_str_ascii(String *buffer);
protected:
- virtual bool calc_value(String *arg, String *buffer) = 0;
+ virtual bool calc_value(const String *arg, String *buffer) = 0;
};
@@ -134,7 +134,7 @@ public:
{ return get_item_copy<Item_func_inet6_aton>(thd, mem_root, this); }
protected:
- virtual bool calc_value(String *arg, String *buffer);
+ virtual bool calc_value(const String *arg, String *buffer);
};
@@ -168,7 +168,7 @@ public:
{ return get_item_copy<Item_func_inet6_ntoa>(thd, mem_root, this); }
protected:
- virtual bool calc_value(String *arg, String *buffer);
+ virtual bool calc_value(const String *arg, String *buffer);
};
diff --git a/sql/item_row.cc b/sql/item_row.cc
index 3b8bd8d3e59..9c029b16292 100644
--- a/sql/item_row.cc
+++ b/sql/item_row.cc
@@ -110,13 +110,14 @@ void Item_row::split_sum_func(THD *thd, Ref_ptr_array ref_pointer_array,
}
-void Item_row::fix_after_pullout(st_select_lex *new_parent, Item **ref)
+void Item_row::fix_after_pullout(st_select_lex *new_parent, Item **ref,
+ bool merge)
{
used_tables_and_const_cache_init();
not_null_tables_cache= 0;
for (uint i= 0; i < arg_count; i++)
{
- args[i]->fix_after_pullout(new_parent, &args[i]);
+ args[i]->fix_after_pullout(new_parent, &args[i], merge);
used_tables_and_const_cache_join(args[i]);
not_null_tables_cache|= args[i]->not_null_tables();
}
diff --git a/sql/item_row.h b/sql/item_row.h
index 83e9743fede..a6fdd2b212c 100644
--- a/sql/item_row.h
+++ b/sql/item_row.h
@@ -81,7 +81,7 @@ public:
return 0;
};
bool fix_fields(THD *thd, Item **ref);
- void fix_after_pullout(st_select_lex *new_parent, Item **ref);
+ void fix_after_pullout(st_select_lex *new_parent, Item **ref, bool merge);
void cleanup();
void split_sum_func(THD *thd, Ref_ptr_array ref_pointer_array,
List<Item> &fields, uint flags);
diff --git a/sql/item_strfunc.h b/sql/item_strfunc.h
index c322136bef2..fbcf69d00ce 100644
--- a/sql/item_strfunc.h
+++ b/sql/item_strfunc.h
@@ -400,8 +400,7 @@ public:
bool fix_fields(THD *thd, Item **ref);
void fix_length_and_dec();
const char *func_name() const { return "regexp_replace"; }
- Item *get_copy(THD *thd, MEM_ROOT *mem_root)
- { return get_item_copy<Item_func_regexp_replace>(thd, mem_root, this); }
+ Item *get_copy(THD *thd, MEM_ROOT *mem_root) { return 0;}
};
@@ -423,8 +422,7 @@ public:
bool fix_fields(THD *thd, Item **ref);
void fix_length_and_dec();
const char *func_name() const { return "regexp_substr"; }
- Item *get_copy(THD *thd, MEM_ROOT *mem_root)
- { return get_item_copy<Item_func_regexp_substr>(thd, mem_root, this); }
+ Item *get_copy(THD *thd, MEM_ROOT *mem_root) { return 0; }
};
diff --git a/sql/item_subselect.cc b/sql/item_subselect.cc
index aa92ae1e6b1..3a7d8582913 100644
--- a/sql/item_subselect.cc
+++ b/sql/item_subselect.cc
@@ -460,7 +460,8 @@ bool Item_subselect::mark_as_dependent(THD *thd, st_select_lex *select,
OUTER_REF_TABLE_BIT.
*/
-void Item_subselect::fix_after_pullout(st_select_lex *new_parent, Item **ref)
+void Item_subselect::fix_after_pullout(st_select_lex *new_parent,
+ Item **ref, bool merge)
{
recalc_used_tables(new_parent, TRUE);
parent_select= new_parent;
@@ -1168,7 +1169,8 @@ Item_singlerow_subselect::select_transformer(JOIN *join)
/*
as far as we moved content to upper level we have to fix dependences & Co
*/
- substitution->fix_after_pullout(select_lex->outer_select(), &substitution);
+ substitution->fix_after_pullout(select_lex->outer_select(),
+ &substitution, TRUE);
}
DBUG_RETURN(false);
}
@@ -2945,7 +2947,7 @@ bool Item_exists_subselect::exists2in_processor(void *opt_arg)
goto out;
}
}
- outer_exp->fix_after_pullout(unit->outer_select(), &outer_exp);
+ outer_exp->fix_after_pullout(unit->outer_select(), &outer_exp, FALSE);
outer_exp->update_used_tables();
outer.push_back(outer_exp, thd->mem_root);
}
@@ -3326,10 +3328,11 @@ err:
}
-void Item_in_subselect::fix_after_pullout(st_select_lex *new_parent, Item **ref)
+void Item_in_subselect::fix_after_pullout(st_select_lex *new_parent,
+ Item **ref, bool merge)
{
- left_expr->fix_after_pullout(new_parent, &left_expr);
- Item_subselect::fix_after_pullout(new_parent, ref);
+ left_expr->fix_after_pullout(new_parent, &left_expr, merge);
+ Item_subselect::fix_after_pullout(new_parent, ref, merge);
used_tables_cache |= left_expr->used_tables();
}
diff --git a/sql/item_subselect.h b/sql/item_subselect.h
index 14394bf6342..9e548e94ac1 100644
--- a/sql/item_subselect.h
+++ b/sql/item_subselect.h
@@ -183,7 +183,7 @@ public:
}
bool fix_fields(THD *thd, Item **ref);
bool mark_as_dependent(THD *thd, st_select_lex *select, Item *item);
- void fix_after_pullout(st_select_lex *new_parent, Item **ref);
+ void fix_after_pullout(st_select_lex *new_parent, Item **ref, bool merge);
void recalc_used_tables(st_select_lex *new_parent, bool after_pullout);
virtual bool exec();
/*
@@ -625,7 +625,7 @@ public:
enum precedence precedence() const { return CMP_PRECEDENCE; }
bool fix_fields(THD *thd, Item **ref);
void fix_length_and_dec();
- void fix_after_pullout(st_select_lex *new_parent, Item **ref);
+ void fix_after_pullout(st_select_lex *new_parent, Item **ref, bool merge);
bool const_item() const
{
return Item_subselect::const_item() && left_expr->const_item();
diff --git a/sql/item_sum.cc b/sql/item_sum.cc
index b047dc4ea4d..269190ef3df 100644
--- a/sql/item_sum.cc
+++ b/sql/item_sum.cc
@@ -2019,6 +2019,18 @@ void Item_sum_hybrid::clear()
null_value= 1;
}
+bool
+Item_sum_hybrid::get_date(MYSQL_TIME *ltime, ulonglong fuzzydate)
+{
+ DBUG_ASSERT(fixed == 1);
+ if (null_value)
+ return true;
+ bool retval= value->get_date(ltime, fuzzydate);
+ if ((null_value= value->null_value))
+ DBUG_ASSERT(retval == true);
+ return retval;
+}
+
double Item_sum_hybrid::val_real()
{
DBUG_ASSERT(fixed == 1);
diff --git a/sql/item_sum.h b/sql/item_sum.h
index 467a77c8983..e91728a1aa1 100644
--- a/sql/item_sum.h
+++ b/sql/item_sum.h
@@ -1035,6 +1035,7 @@ protected:
double val_real();
longlong val_int();
my_decimal *val_decimal(my_decimal *);
+ bool get_date(MYSQL_TIME *ltime, ulonglong fuzzydate);
void reset_field();
String *val_str(String *);
const Type_handler *real_type_handler() const
diff --git a/sql/item_xmlfunc.cc b/sql/item_xmlfunc.cc
index ee307ba2194..b08d43f041c 100644
--- a/sql/item_xmlfunc.cc
+++ b/sql/item_xmlfunc.cc
@@ -2464,6 +2464,21 @@ static int my_xpath_parse_UnaryExpr(MY_XPATH *xpath)
}
+/**
+ A helper class to make a null-terminated string from XPath fragments.
+ The string is allocated on the THD memory root.
+*/
+class XPath_cstring_null_terminated: public LEX_CSTRING
+{
+public:
+ XPath_cstring_null_terminated(THD *thd, const char *str, size_t length)
+ {
+ if (thd->make_lex_string(this, str, length))
+ static_cast<LEX_CSTRING>(*this)= empty_clex_str;
+ }
+};
+
+
/*
Scan Number
@@ -2498,14 +2513,15 @@ static int my_xpath_parse_Number(MY_XPATH *xpath)
thd= xpath->thd;
if (!my_xpath_parse_term(xpath, MY_XPATH_LEX_DOT))
{
- xpath->item= new (thd->mem_root) Item_int(thd, xpath->prevtok.beg,
- (uint)(xpath->prevtok.end - xpath->prevtok.beg));
- return 1;
+ XPath_cstring_null_terminated nr(thd, beg, xpath->prevtok.end - beg);
+ xpath->item= new (thd->mem_root) Item_int(thd, nr.str, (uint) nr.length);
+ }
+ else
+ {
+ my_xpath_parse_term(xpath, MY_XPATH_LEX_DIGITS);
+ XPath_cstring_null_terminated nr(thd, beg, xpath->prevtok.end - beg);
+ xpath->item= new (thd->mem_root) Item_float(thd, nr.str, (uint) nr.length);
}
- my_xpath_parse_term(xpath, MY_XPATH_LEX_DIGITS);
-
- xpath->item= new (thd->mem_root) Item_float(thd, beg,
- (uint)(xpath->prevtok.end - beg));
return 1;
}
diff --git a/sql/lock.cc b/sql/lock.cc
index 6fa68786b93..8e43001e742 100644
--- a/sql/lock.cc
+++ b/sql/lock.cc
@@ -421,8 +421,11 @@ void mysql_unlock_tables(THD *thd, MYSQL_LOCK *sql_lock)
void mysql_unlock_tables(THD *thd, MYSQL_LOCK *sql_lock, bool free_lock)
{
- DBUG_ENTER("mysql_unlock_tables");
bool errors= thd->is_error();
+ PSI_stage_info org_stage;
+ DBUG_ENTER("mysql_unlock_tables");
+
+ thd->backup_stage(&org_stage);
THD_STAGE_INFO(thd, stage_unlocking_tables);
if (sql_lock->table_count)
@@ -433,6 +436,7 @@ void mysql_unlock_tables(THD *thd, MYSQL_LOCK *sql_lock, bool free_lock)
my_free(sql_lock);
if (!errors)
thd->clear_error();
+ THD_STAGE_INFO(thd, org_stage);
DBUG_VOID_RETURN;
}
diff --git a/sql/log.cc b/sql/log.cc
index 008cc0b59aa..09bd23be2bf 100644
--- a/sql/log.cc
+++ b/sql/log.cc
@@ -109,6 +109,13 @@ static ulonglong binlog_status_group_commit_trigger_timeout;
static char binlog_snapshot_file[FN_REFLEN];
static ulonglong binlog_snapshot_position;
+static const char *fatal_log_error=
+ "Could not use %s for logging (error %d). "
+ "Turning logging off for the whole duration of the MariaDB server process. "
+ "To turn it on again: fix the cause, shutdown the MariaDB server and "
+ "restart it.";
+
+
static SHOW_VAR binlog_status_vars_detail[]=
{
{"commits",
@@ -2002,7 +2009,9 @@ static bool trans_cannot_safely_rollback(THD *thd, bool all)
static int binlog_commit(handlerton *hton, THD *thd, bool all)
{
int error= 0;
+ PSI_stage_info org_stage;
DBUG_ENTER("binlog_commit");
+
binlog_cache_mngr *const cache_mngr=
(binlog_cache_mngr*) thd_get_ha_data(thd, binlog_hton);
@@ -2019,6 +2028,9 @@ static int binlog_commit(handlerton *hton, THD *thd, bool all)
YESNO(thd->transaction.all.modified_non_trans_table),
YESNO(thd->transaction.stmt.modified_non_trans_table)));
+
+ thd->backup_stage(&org_stage);
+ THD_STAGE_INFO(thd, stage_binlog_write);
if (!cache_mngr->stmt_cache.empty())
{
error= binlog_commit_flush_stmt_cache(thd, all, cache_mngr);
@@ -2030,6 +2042,7 @@ static int binlog_commit(handlerton *hton, THD *thd, bool all)
we're here because cache_log was flushed in MYSQL_BIN_LOG::log_xid()
*/
cache_mngr->reset(false, true);
+ THD_STAGE_INFO(thd, org_stage);
DBUG_RETURN(error);
}
@@ -2048,6 +2061,7 @@ static int binlog_commit(handlerton *hton, THD *thd, bool all)
if (!all)
cache_mngr->trx_cache.set_prev_position(MY_OFF_T_UNDEF);
+ THD_STAGE_INFO(thd, org_stage);
DBUG_RETURN(error);
}
@@ -2683,10 +2697,7 @@ bool MYSQL_LOG::open(
DBUG_RETURN(0);
err:
- sql_print_error("Could not use %s for logging (error %d). \
-Turning logging off for the whole duration of the MySQL server process. \
-To turn it on again: fix the cause, \
-shutdown the MySQL server and restart it.", name, errno);
+ sql_print_error(fatal_log_error, name, errno);
if (file >= 0)
mysql_file_close(file, MYF(0));
end_io_cache(&log_file);
@@ -3794,15 +3805,13 @@ bool MYSQL_BIN_LOG::open(const char *log_name,
DBUG_RETURN(0);
err:
+ int tmp_errno= errno;
#ifdef HAVE_REPLICATION
if (is_inited_purge_index_file())
purge_index_entry(NULL, NULL, need_mutex);
close_purge_index_file();
#endif
- sql_print_error("Could not use %s for logging (error %d). \
-Turning logging off for the whole duration of the MySQL server process. \
-To turn it on again: fix the cause, \
-shutdown the MySQL server and restart it.", name, errno);
+ sql_print_error(fatal_log_error, name, tmp_errno);
if (new_xid_list_entry)
my_free(new_xid_list_entry);
if (file >= 0)
@@ -5229,12 +5238,7 @@ end:
- ...
*/
close(LOG_CLOSE_INDEX);
- sql_print_error("Could not open %s for logging (error %d). "
- "Turning logging off for the whole duration "
- "of the MySQL server process. To turn it on "
- "again: fix the cause, shutdown the MySQL "
- "server and restart it.",
- new_name_ptr, errno);
+ sql_print_error(fatal_log_error, new_name_ptr, errno);
}
mysql_mutex_unlock(&LOCK_index);
diff --git a/sql/mysqld.cc b/sql/mysqld.cc
index 1e435f0beec..6433ecfb25f 100644
--- a/sql/mysqld.cc
+++ b/sql/mysqld.cc
@@ -384,6 +384,7 @@ mysql_cond_t COND_thread_cache;
static mysql_cond_t COND_flush_thread_cache;
mysql_cond_t COND_slave_background;
static DYNAMIC_ARRAY all_options;
+static longlong start_memory_used;
/* Global variables */
@@ -4061,6 +4062,8 @@ static void my_malloc_size_cb_func(long long size, my_bool is_thread_specific)
(longlong) thd->status_var.local_memory_used,
size));
thd->status_var.local_memory_used+= size;
+ set_if_bigger(thd->status_var.max_local_memory_used,
+ thd->status_var.local_memory_used);
if (size > 0 &&
thd->status_var.local_memory_used > (int64)thd->variables.max_mem_used &&
!thd->killed && !thd->get_stmt_da()->is_set())
@@ -6121,6 +6124,9 @@ int mysqld_main(int argc, char **argv)
MYSQL_SET_STAGE(0 ,__FILE__, __LINE__);
+ /* Memory used when everything is setup */
+ start_memory_used= global_status_var.global_memory_used;
+
#if defined(_WIN32) || defined(HAVE_SMEM)
handle_connections_methods();
#else
@@ -8526,6 +8532,7 @@ SHOW_VAR status_vars[]= {
{"Master_gtid_wait_time", (char*) offsetof(STATUS_VAR, master_gtid_wait_time), SHOW_LONGLONG_STATUS},
{"Max_used_connections", (char*) &max_used_connections, SHOW_LONG},
{"Memory_used", (char*) &show_memory_used, SHOW_SIMPLE_FUNC},
+ {"Memory_used_initial", (char*) &start_memory_used, SHOW_LONGLONG},
{"Not_flushed_delayed_rows", (char*) &delayed_rows_in_use, SHOW_LONG_NOFLUSH},
{"Open_files", (char*) &my_file_opened, SHOW_LONG_NOFLUSH},
{"Open_streams", (char*) &my_stream_opened, SHOW_LONG_NOFLUSH},
@@ -10167,104 +10174,110 @@ static PSI_file_info all_server_files[]=
};
#endif /* HAVE_PSI_INTERFACE */
-PSI_stage_info stage_after_apply_event= { 0, "after apply log event", 0};
+PSI_stage_info stage_after_apply_event= { 0, "After apply log event", 0};
PSI_stage_info stage_after_create= { 0, "After create", 0};
PSI_stage_info stage_after_opening_tables= { 0, "After opening tables", 0};
PSI_stage_info stage_after_table_lock= { 0, "After table lock", 0};
-PSI_stage_info stage_allocating_local_table= { 0, "allocating local table", 0};
-PSI_stage_info stage_alter_inplace_prepare= { 0, "preparing for alter table", 0};
-PSI_stage_info stage_alter_inplace= { 0, "altering table", 0};
-PSI_stage_info stage_alter_inplace_commit= { 0, "committing alter table to storage engine", 0};
-PSI_stage_info stage_apply_event= { 0, "apply log event", 0};
+PSI_stage_info stage_allocating_local_table= { 0, "Allocating local table", 0};
+PSI_stage_info stage_alter_inplace_prepare= { 0, "Preparing for alter table", 0};
+PSI_stage_info stage_alter_inplace= { 0, "Altering table", 0};
+PSI_stage_info stage_alter_inplace_commit= { 0, "Committing alter table to storage engine", 0};
+PSI_stage_info stage_apply_event= { 0, "Apply log event", 0};
PSI_stage_info stage_changing_master= { 0, "Changing master", 0};
PSI_stage_info stage_checking_master_version= { 0, "Checking master version", 0};
-PSI_stage_info stage_checking_permissions= { 0, "checking permissions", 0};
-PSI_stage_info stage_checking_privileges_on_cached_query= { 0, "checking privileges on cached query", 0};
-PSI_stage_info stage_checking_query_cache_for_query= { 0, "checking query cache for query", 0};
-PSI_stage_info stage_cleaning_up= { 0, "cleaning up", 0};
-PSI_stage_info stage_closing_tables= { 0, "closing tables", 0};
+PSI_stage_info stage_checking_permissions= { 0, "Checking permissions", 0};
+PSI_stage_info stage_checking_privileges_on_cached_query= { 0, "Checking privileges on cached query", 0};
+PSI_stage_info stage_checking_query_cache_for_query= { 0, "Checking query cache for query", 0};
+PSI_stage_info stage_cleaning_up= { 0, "Reset for next command", 0};
+PSI_stage_info stage_closing_tables= { 0, "Closing tables", 0};
PSI_stage_info stage_connecting_to_master= { 0, "Connecting to master", 0};
-PSI_stage_info stage_converting_heap_to_myisam= { 0, "converting HEAP to " TMP_ENGINE_NAME, 0};
+PSI_stage_info stage_converting_heap_to_myisam= { 0, "Converting HEAP to " TMP_ENGINE_NAME, 0};
PSI_stage_info stage_copying_to_group_table= { 0, "Copying to group table", 0};
PSI_stage_info stage_copying_to_tmp_table= { 0, "Copying to tmp table", 0};
-PSI_stage_info stage_copy_to_tmp_table= { 0, "copy to tmp table", 0};
+PSI_stage_info stage_copy_to_tmp_table= { 0, "Copy to tmp table", 0};
PSI_stage_info stage_creating_delayed_handler= { 0, "Creating delayed handler", 0};
PSI_stage_info stage_creating_sort_index= { 0, "Creating sort index", 0};
-PSI_stage_info stage_creating_table= { 0, "creating table", 0};
+PSI_stage_info stage_creating_table= { 0, "Creating table", 0};
PSI_stage_info stage_creating_tmp_table= { 0, "Creating tmp table", 0};
-PSI_stage_info stage_deleting_from_main_table= { 0, "deleting from main table", 0};
-PSI_stage_info stage_deleting_from_reference_tables= { 0, "deleting from reference tables", 0};
-PSI_stage_info stage_discard_or_import_tablespace= { 0, "discard_or_import_tablespace", 0};
-PSI_stage_info stage_enabling_keys= { 0, "enabling keys", 0};
-PSI_stage_info stage_end= { 0, "end", 0};
-PSI_stage_info stage_executing= { 0, "executing", 0};
+PSI_stage_info stage_deleting_from_main_table= { 0, "Deleting from main table", 0};
+PSI_stage_info stage_deleting_from_reference_tables= { 0, "Deleting from reference tables", 0};
+PSI_stage_info stage_discard_or_import_tablespace= { 0, "Discard_or_import_tablespace", 0};
+PSI_stage_info stage_enabling_keys= { 0, "Enabling keys", 0};
+PSI_stage_info stage_end= { 0, "End of update loop", 0};
+PSI_stage_info stage_executing= { 0, "Executing", 0};
PSI_stage_info stage_execution_of_init_command= { 0, "Execution of init_command", 0};
-PSI_stage_info stage_explaining= { 0, "explaining", 0};
+PSI_stage_info stage_explaining= { 0, "Explaining", 0};
PSI_stage_info stage_finding_key_cache= { 0, "Finding key cache", 0};
PSI_stage_info stage_finished_reading_one_binlog_switching_to_next_binlog= { 0, "Finished reading one binlog; switching to next binlog", 0};
PSI_stage_info stage_flushing_relay_log_and_master_info_repository= { 0, "Flushing relay log and master info repository.", 0};
PSI_stage_info stage_flushing_relay_log_info_file= { 0, "Flushing relay-log info file.", 0};
-PSI_stage_info stage_freeing_items= { 0, "freeing items", 0};
-PSI_stage_info stage_fulltext_initialization= { 0, "FULLTEXT initialization", 0};
-PSI_stage_info stage_got_handler_lock= { 0, "got handler lock", 0};
-PSI_stage_info stage_got_old_table= { 0, "got old table", 0};
-PSI_stage_info stage_init= { 0, "init", 0};
-PSI_stage_info stage_insert= { 0, "insert", 0};
-PSI_stage_info stage_invalidating_query_cache_entries_table= { 0, "invalidating query cache entries (table)", 0};
-PSI_stage_info stage_invalidating_query_cache_entries_table_list= { 0, "invalidating query cache entries (table list)", 0};
+PSI_stage_info stage_freeing_items= { 0, "Freeing items", 0};
+PSI_stage_info stage_fulltext_initialization= { 0, "Fulltext initialization", 0};
+PSI_stage_info stage_got_handler_lock= { 0, "Got handler lock", 0};
+PSI_stage_info stage_got_old_table= { 0, "Got old table", 0};
+PSI_stage_info stage_init= { 0, "Init", 0};
+PSI_stage_info stage_init_update= { 0, "Init for update", 0};
+PSI_stage_info stage_insert= { 0, "Insert", 0};
+PSI_stage_info stage_invalidating_query_cache_entries_table= { 0, "Invalidating query cache entries (table)", 0};
+PSI_stage_info stage_invalidating_query_cache_entries_table_list= { 0, "Invalidating query cache entries (table list)", 0};
PSI_stage_info stage_killing_slave= { 0, "Killing slave", 0};
-PSI_stage_info stage_logging_slow_query= { 0, "logging slow query", 0};
+PSI_stage_info stage_logging_slow_query= { 0, "Logging slow query", 0};
PSI_stage_info stage_making_temp_file_append_before_load_data= { 0, "Making temporary file (append) before replaying LOAD DATA INFILE.", 0};
PSI_stage_info stage_making_temp_file_create_before_load_data= { 0, "Making temporary file (create) before replaying LOAD DATA INFILE.", 0};
-PSI_stage_info stage_manage_keys= { 0, "manage keys", 0};
+PSI_stage_info stage_manage_keys= { 0, "Manage keys", 0};
PSI_stage_info stage_master_has_sent_all_binlog_to_slave= { 0, "Master has sent all binlog to slave; waiting for binlog to be updated", 0};
PSI_stage_info stage_opening_tables= { 0, "Opening tables", 0};
-PSI_stage_info stage_optimizing= { 0, "optimizing", 0};
-PSI_stage_info stage_preparing= { 0, "preparing", 0};
+PSI_stage_info stage_optimizing= { 0, "Optimizing", 0};
+PSI_stage_info stage_preparing= { 0, "Preparing", 0};
PSI_stage_info stage_purging_old_relay_logs= { 0, "Purging old relay logs", 0};
-PSI_stage_info stage_query_end= { 0, "query end", 0};
+PSI_stage_info stage_query_end= { 0, "Query end", 0};
+PSI_stage_info stage_starting_cleanup= { 0, "Starting cleanup", 0};
+PSI_stage_info stage_rollback= { 0, "Rollback", 0};
+PSI_stage_info stage_rollback_implicit= { 0, "Rollback_implicit", 0};
+PSI_stage_info stage_commit= { 0, "Commit", 0};
+PSI_stage_info stage_commit_implicit= { 0, "Commit_implicit", 0};
PSI_stage_info stage_queueing_master_event_to_the_relay_log= { 0, "Queueing master event to the relay log", 0};
PSI_stage_info stage_reading_event_from_the_relay_log= { 0, "Reading event from the relay log", 0};
-PSI_stage_info stage_recreating_table= { 0, "recreating table", 0};
+PSI_stage_info stage_recreating_table= { 0, "Recreating table", 0};
PSI_stage_info stage_registering_slave_on_master= { 0, "Registering slave on master", 0};
PSI_stage_info stage_removing_duplicates= { 0, "Removing duplicates", 0};
-PSI_stage_info stage_removing_tmp_table= { 0, "removing tmp table", 0};
-PSI_stage_info stage_rename= { 0, "rename", 0};
-PSI_stage_info stage_rename_result_table= { 0, "rename result table", 0};
+PSI_stage_info stage_removing_tmp_table= { 0, "Removing tmp table", 0};
+PSI_stage_info stage_rename= { 0, "Rename", 0};
+PSI_stage_info stage_rename_result_table= { 0, "Rename result table", 0};
PSI_stage_info stage_requesting_binlog_dump= { 0, "Requesting binlog dump", 0};
-PSI_stage_info stage_reschedule= { 0, "reschedule", 0};
+PSI_stage_info stage_reschedule= { 0, "Reschedule", 0};
PSI_stage_info stage_searching_rows_for_update= { 0, "Searching rows for update", 0};
PSI_stage_info stage_sending_binlog_event_to_slave= { 0, "Sending binlog event to slave", 0};
-PSI_stage_info stage_sending_cached_result_to_client= { 0, "sending cached result to client", 0};
+PSI_stage_info stage_sending_cached_result_to_client= { 0, "Sending cached result to client", 0};
PSI_stage_info stage_sending_data= { 0, "Sending data", 0};
-PSI_stage_info stage_setup= { 0, "setup", 0};
-PSI_stage_info stage_show_explain= { 0, "show explain", 0};
+PSI_stage_info stage_setup= { 0, "Setup", 0};
+PSI_stage_info stage_show_explain= { 0, "Show explain", 0};
PSI_stage_info stage_slave_has_read_all_relay_log= { 0, "Slave has read all relay log; waiting for the slave I/O thread to update it", 0};
PSI_stage_info stage_sorting= { 0, "Sorting", 0};
PSI_stage_info stage_sorting_for_group= { 0, "Sorting for group", 0};
PSI_stage_info stage_sorting_for_order= { 0, "Sorting for order", 0};
PSI_stage_info stage_sorting_result= { 0, "Sorting result", 0};
-PSI_stage_info stage_statistics= { 0, "statistics", 0};
+PSI_stage_info stage_statistics= { 0, "Statistics", 0};
PSI_stage_info stage_sql_thd_waiting_until_delay= { 0, "Waiting until MASTER_DELAY seconds after master executed event", 0 };
-PSI_stage_info stage_storing_result_in_query_cache= { 0, "storing result in query cache", 0};
-PSI_stage_info stage_storing_row_into_queue= { 0, "storing row into queue", 0};
+PSI_stage_info stage_storing_result_in_query_cache= { 0, "Storing result in query cache", 0};
+PSI_stage_info stage_storing_row_into_queue= { 0, "Storing row into queue", 0};
PSI_stage_info stage_system_lock= { 0, "System lock", 0};
PSI_stage_info stage_unlocking_tables= { 0, "Unlocking tables", 0};
PSI_stage_info stage_table_lock= { 0, "Table lock", 0};
PSI_stage_info stage_filling_schema_table= { 0, "Filling schema table", 0};
-PSI_stage_info stage_update= { 0, "update", 0};
-PSI_stage_info stage_updating= { 0, "updating", 0};
-PSI_stage_info stage_updating_main_table= { 0, "updating main table", 0};
-PSI_stage_info stage_updating_reference_tables= { 0, "updating reference tables", 0};
-PSI_stage_info stage_upgrading_lock= { 0, "upgrading lock", 0};
+PSI_stage_info stage_update= { 0, "Update", 0};
+PSI_stage_info stage_updating= { 0, "Updating", 0};
+PSI_stage_info stage_updating_main_table= { 0, "Updating main table", 0};
+PSI_stage_info stage_updating_reference_tables= { 0, "Updating reference tables", 0};
+PSI_stage_info stage_upgrading_lock= { 0, "Upgrading lock", 0};
PSI_stage_info stage_user_lock= { 0, "User lock", 0};
PSI_stage_info stage_user_sleep= { 0, "User sleep", 0};
-PSI_stage_info stage_verifying_table= { 0, "verifying table", 0};
-PSI_stage_info stage_waiting_for_delay_list= { 0, "waiting for delay_list", 0};
-PSI_stage_info stage_waiting_for_gtid_to_be_written_to_binary_log= { 0, "waiting for GTID to be written to binary log", 0};
-PSI_stage_info stage_waiting_for_handler_insert= { 0, "waiting for handler insert", 0};
-PSI_stage_info stage_waiting_for_handler_lock= { 0, "waiting for handler lock", 0};
-PSI_stage_info stage_waiting_for_handler_open= { 0, "waiting for handler open", 0};
+PSI_stage_info stage_verifying_table= { 0, "Verifying table", 0};
+PSI_stage_info stage_waiting_for_delay_list= { 0, "Waiting for delay_list", 0};
+PSI_stage_info stage_waiting_for_gtid_to_be_written_to_binary_log= { 0, "Waiting for GTID to be written to binary log", 0};
+PSI_stage_info stage_waiting_for_handler_insert= { 0, "Waiting for handler insert", 0};
+PSI_stage_info stage_waiting_for_handler_lock= { 0, "Waiting for handler lock", 0};
+PSI_stage_info stage_waiting_for_handler_open= { 0, "Waiting for handler open", 0};
PSI_stage_info stage_waiting_for_insert= { 0, "Waiting for INSERT", 0};
PSI_stage_info stage_waiting_for_master_to_send_event= { 0, "Waiting for master to send event", 0};
PSI_stage_info stage_waiting_for_master_update= { 0, "Waiting for master update", 0};
@@ -10278,6 +10291,7 @@ PSI_stage_info stage_waiting_for_the_slave_thread_to_advance_position= { 0, "Wai
PSI_stage_info stage_waiting_to_finalize_termination= { 0, "Waiting to finalize termination", 0};
PSI_stage_info stage_waiting_to_get_readlock= { 0, "Waiting to get readlock", 0};
PSI_stage_info stage_binlog_waiting_background_tasks= { 0, "Waiting for background binlog tasks", 0};
+PSI_stage_info stage_binlog_write= { 0, "Writing to binlog", 0};
PSI_stage_info stage_binlog_processing_checkpoint_notify= { 0, "Processing binlog checkpoint notification", 0};
PSI_stage_info stage_binlog_stopping_background_thread= { 0, "Stopping binlog background thread", 0};
PSI_stage_info stage_waiting_for_work_from_sql_thread= { 0, "Waiting for work from SQL thread", 0};
@@ -10308,6 +10322,7 @@ PSI_stage_info *all_server_stages[]=
& stage_alter_inplace_commit,
& stage_alter_inplace_prepare,
& stage_apply_event,
+ & stage_binlog_write,
& stage_binlog_processing_checkpoint_notify,
& stage_binlog_stopping_background_thread,
& stage_binlog_waiting_background_tasks,
@@ -10318,6 +10333,8 @@ PSI_stage_info *all_server_stages[]=
& stage_checking_query_cache_for_query,
& stage_cleaning_up,
& stage_closing_tables,
+ & stage_commit,
+ & stage_commit_implicit,
& stage_connecting_to_master,
& stage_converting_heap_to_myisam,
& stage_copy_to_tmp_table,
@@ -10344,6 +10361,7 @@ PSI_stage_info *all_server_stages[]=
& stage_got_handler_lock,
& stage_got_old_table,
& stage_init,
+ & stage_init_update,
& stage_insert,
& stage_invalidating_query_cache_entries_table,
& stage_invalidating_query_cache_entries_table_list,
@@ -10357,6 +10375,7 @@ PSI_stage_info *all_server_stages[]=
& stage_optimizing,
& stage_preparing,
& stage_purging_old_relay_logs,
+ & stage_starting_cleanup,
& stage_query_end,
& stage_queueing_master_event_to_the_relay_log,
& stage_reading_event_from_the_relay_log,
@@ -10368,6 +10387,8 @@ PSI_stage_info *all_server_stages[]=
& stage_rename_result_table,
& stage_requesting_binlog_dump,
& stage_reschedule,
+ & stage_rollback,
+ & stage_rollback_implicit,
& stage_searching_rows_for_update,
& stage_sending_binlog_event_to_slave,
& stage_sending_cached_result_to_client,
diff --git a/sql/mysqld.h b/sql/mysqld.h
index 8364eecdb7c..7dc81787de1 100644
--- a/sql/mysqld.h
+++ b/sql/mysqld.h
@@ -415,6 +415,7 @@ extern PSI_stage_info stage_fulltext_initialization;
extern PSI_stage_info stage_got_handler_lock;
extern PSI_stage_info stage_got_old_table;
extern PSI_stage_info stage_init;
+extern PSI_stage_info stage_init_update;
extern PSI_stage_info stage_insert;
extern PSI_stage_info stage_invalidating_query_cache_entries_table;
extern PSI_stage_info stage_invalidating_query_cache_entries_table_list;
@@ -429,6 +430,11 @@ extern PSI_stage_info stage_optimizing;
extern PSI_stage_info stage_preparing;
extern PSI_stage_info stage_purging_old_relay_logs;
extern PSI_stage_info stage_query_end;
+extern PSI_stage_info stage_starting_cleanup;
+extern PSI_stage_info stage_rollback;
+extern PSI_stage_info stage_rollback_implicit;
+extern PSI_stage_info stage_commit;
+extern PSI_stage_info stage_commit_implicit;
extern PSI_stage_info stage_queueing_master_event_to_the_relay_log;
extern PSI_stage_info stage_reading_event_from_the_relay_log;
extern PSI_stage_info stage_recreating_table;
@@ -484,6 +490,7 @@ extern PSI_stage_info stage_waiting_for_the_slave_thread_to_advance_position;
extern PSI_stage_info stage_waiting_to_finalize_termination;
extern PSI_stage_info stage_waiting_to_get_readlock;
extern PSI_stage_info stage_binlog_waiting_background_tasks;
+extern PSI_stage_info stage_binlog_write;
extern PSI_stage_info stage_binlog_processing_checkpoint_notify;
extern PSI_stage_info stage_binlog_stopping_background_thread;
extern PSI_stage_info stage_waiting_for_work_from_sql_thread;
diff --git a/sql/opt_subselect.cc b/sql/opt_subselect.cc
index 25b98434ef3..b6378685268 100644
--- a/sql/opt_subselect.cc
+++ b/sql/opt_subselect.cc
@@ -1644,7 +1644,7 @@ static bool convert_subq_to_sj(JOIN *parent_join, Item_in_subselect *subq_pred)
{
tl->jtbm_table_no= table_no;
Item *dummy= tl->jtbm_subselect;
- tl->jtbm_subselect->fix_after_pullout(parent_lex, &dummy);
+ tl->jtbm_subselect->fix_after_pullout(parent_lex, &dummy, true);
DBUG_ASSERT(dummy == tl->jtbm_subselect);
}
SELECT_LEX *old_sl= tl->select_lex;
@@ -1785,7 +1785,8 @@ static bool convert_subq_to_sj(JOIN *parent_join, Item_in_subselect *subq_pred)
Walk through sj nest's WHERE and ON expressions and call
item->fix_table_changes() for all items.
*/
- sj_nest->sj_on_expr->fix_after_pullout(parent_lex, &sj_nest->sj_on_expr);
+ sj_nest->sj_on_expr->fix_after_pullout(parent_lex, &sj_nest->sj_on_expr,
+ TRUE);
fix_list_after_tbl_changes(parent_lex, &sj_nest->nested_join->join_list);
@@ -1944,7 +1945,7 @@ static bool convert_subq_to_jtbm(JOIN *parent_join,
DBUG_ASSERT(parent_join->table_count < MAX_TABLES);
Item *conds= hash_sj_engine->semi_join_conds;
- conds->fix_after_pullout(parent_lex, &conds);
+ conds->fix_after_pullout(parent_lex, &conds, TRUE);
DBUG_EXECUTE("where", print_where(conds,"SJ-EXPR", QT_ORDINARY););
@@ -1996,7 +1997,7 @@ void fix_list_after_tbl_changes(SELECT_LEX *new_parent, List<TABLE_LIST> *tlist)
while ((table= it++))
{
if (table->on_expr)
- table->on_expr->fix_after_pullout(new_parent, &table->on_expr);
+ table->on_expr->fix_after_pullout(new_parent, &table->on_expr, TRUE);
if (table->nested_join)
fix_list_after_tbl_changes(new_parent, &table->nested_join->join_list);
}
diff --git a/sql/share/errmsg-utf8.txt b/sql/share/errmsg-utf8.txt
index 76486ae8734..e7afe7a679a 100644
--- a/sql/share/errmsg-utf8.txt
+++ b/sql/share/errmsg-utf8.txt
@@ -2649,7 +2649,7 @@ ER_INVALID_GROUP_FUNC_USE
swe "Felaktig användning av SQL grupp function"
ukr "Хибне використання функції групування"
ER_UNSUPPORTED_EXTENSION 42000
- cze "Tabulka '%-.192s' používá rozšíření, které v této verzi MySQL není"
+ cze "Tabulka '%-.192s' používá rozšíření, které v této verzi MariaDB není"
dan "Tabellen '%-.192s' bruger et filtypenavn som ikke findes i denne MariaDB version"
nla "Tabel '%-.192s' gebruikt een extensie, die niet in deze MariaDB-versie voorkomt"
eng "Table '%-.192s' uses an extension that doesn't exist in this MariaDB version"
@@ -2660,7 +2660,7 @@ ER_UNSUPPORTED_EXTENSION 42000
hindi "टेबल '%-.192s' जिस इक्स्टेन्शन का उपयोग कर रहा है, वह इस MariaDB संस्करण में उपलब्ध नहीं है"
hun "A(z) '%-.192s' tabla olyan bovitest hasznal, amely nem letezik ebben a MariaDB versioban"
ita "La tabella '%-.192s' usa un'estensione che non esiste in questa versione di MariaDB"
- jpn "表 '%-.192s' は、このMySQLバージョンには無い機能を使用しています。"
+ jpn "表 '%-.192s' は、このMariaDBバージョンには無い機能を使用しています。"
kor "테이블 '%-.192s'는 확장명령을 이용하지만 현재의 MariaDB 버젼에서는 존재하지 않습니다."
nor "Table '%-.192s' uses a extension that doesn't exist in this MariaDB version"
norwegian-ny "Table '%-.192s' uses a extension that doesn't exist in this MariaDB version"
@@ -2740,7 +2740,7 @@ ER_UNKNOWN_CHARACTER_SET 42000
swe "Okänd teckenuppsättning: '%-.64s'"
ukr "Невідома кодова таблиця: '%-.64s'"
ER_TOO_MANY_TABLES
- cze "Příliš mnoho tabulek, MySQL jich může mít v joinu jen %d"
+ cze "Příliš mnoho tabulek, MariaDB jich může mít v joinu jen %d"
dan "For mange tabeller. MariaDB kan kun bruge %d tabeller i et join"
nla "Teveel tabellen. MariaDB kan slechts %d tabellen in een join bevatten"
eng "Too many tables; MariaDB can only use %d tables in a join"
@@ -2751,7 +2751,7 @@ ER_TOO_MANY_TABLES
hindi "बहुत अधिक टेबल्स, MariaDB एक JOIN में केवल %d टेबल्स का उपयोग कर सकता है"
hun "Tul sok tabla. A MariaDB csak %d tablat tud kezelni osszefuzeskor"
ita "Troppe tabelle. MariaDB puo` usare solo %d tabelle in una join"
- jpn "表が多すぎます。MySQLがJOINできる表は %d 個までです。"
+ jpn "表が多すぎます。MariaDBがJOINできる表は %d 個までです。"
kor "너무 많은 테이블이 Join되었습니다. MariaDB에서는 JOIN시 %d개의 테이블만 사용할 수 있습니다."
por "Tabelas demais. O MariaDB pode usar somente %d tabelas em uma junção (JOIN)"
rum "Prea multe tabele. MariaDB nu poate folosi mai mult de %d tabele intr-un join"
@@ -3023,7 +3023,7 @@ ER_HOST_IS_BLOCKED
swe "Denna dator, '%-.64s', är blockerad pga många felaktig paket. Gör 'mysqladmin flush-hosts' för att ta bort alla blockeringarna"
ukr "Хост '%-.64s' заблоковано з причини великої кількості помилок з'єднання. Для розблокування використовуйте 'mysqladmin flush-hosts'"
ER_HOST_NOT_PRIVILEGED
- cze "Stroj '%-.64s' nemá povoleno se k tomuto MySQL serveru připojit"
+ cze "Stroj '%-.64s' nemá povoleno se k tomuto MariaDB serveru připojit"
dan "Værten '%-.64s' kan ikke tilkoble denne MariaDB-server"
nla "Het is host '%-.64s' is niet toegestaan verbinding te maken met deze MariaDB server"
eng "Host '%-.64s' is not allowed to connect to this MariaDB server"
@@ -3034,7 +3034,7 @@ ER_HOST_NOT_PRIVILEGED
hindi "होस्ट '%-.64s' को इस MariaDB सर्वर से कनेक्ट करने के लिए अनुमति नहीं है"
hun "A '%-.64s' host szamara nem engedelyezett a kapcsolodas ehhez a MariaDB szerverhez"
ita "Al sistema '%-.64s' non e` consentita la connessione a questo server MariaDB"
- jpn "ホスト '%-.64s' からのこの MySQL server への接続は許可されていません。"
+ jpn "ホスト '%-.64s' からのこの MariaDB server への接続は許可されていません。"
kor "'%-.64s' 호스트는 이 MariaDB서버에 접속할 허가를 받지 못했습니다."
por "'Host' '%-.64s' não tem permissão para se conectar com este servidor MariaDB"
rum "Host-ul '%-.64s' nu este permis a se conecta la aceste server MariaDB"
@@ -3044,7 +3044,7 @@ ER_HOST_NOT_PRIVILEGED
swe "Denna dator, '%-.64s', har inte privileger att använda denna MariaDB server"
ukr "Хосту '%-.64s' не доволено зв'язуватись з цим сервером MariaDB"
ER_PASSWORD_ANONYMOUS_USER 42000
- cze "Používáte MySQL jako anonymní uživatel a anonymní uživatelé nemají povoleno měnit hesla"
+ cze "Používáte MariaDB jako anonymní uživatel a anonymní uživatelé nemají povoleno měnit hesla"
dan "Du bruger MariaDB som anonym bruger. Anonyme brugere må ikke ændre adgangskoder"
nla "U gebruikt MariaDB als anonieme gebruiker en deze mogen geen wachtwoorden wijzigen"
eng "You are using MariaDB as an anonymous user and anonymous users are not allowed to modify user settings"
@@ -3055,7 +3055,7 @@ ER_PASSWORD_ANONYMOUS_USER 42000
hindi "आप MariaDB का उपयोग एक बेनाम यूज़र की तरह कर रहे हैं; बेनाम यूज़र्स को 'यूज़र सेटिंग्स' बदलने की अनुमति नहीं है"
hun "Nevtelen (anonymous) felhasznalokent nem negedelyezett a jelszovaltoztatas"
ita "Impossibile cambiare la password usando MariaDB come utente anonimo"
- jpn "MySQL を匿名ユーザーで使用しているので、パスワードの変更はできません。"
+ jpn "MariaDB を匿名ユーザーで使用しているので、パスワードの変更はできません。"
kor "당신은 MariaDB서버에 익명의 사용자로 접속을 하셨습니다.익명의 사용자는 암호를 변경할 수 없습니다."
por "Você está usando o MariaDB como usuário anônimo e usuários anônimos não têm permissão para mudar senhas"
rum "Dumneavoastra folositi MariaDB ca un utilizator anonim si utilizatorii anonimi nu au voie sa schimbe setarile utilizatorilor"
@@ -3394,7 +3394,7 @@ ER_NONEXISTING_TABLE_GRANT 42000
swe "Det finns inget privilegium definierat för användare '%-.48s' på '%-.64s' för tabell '%-.192s'"
ukr "Повноважень не визначено для користувача '%-.48s' з хосту '%-.64s' для таблиці '%-.192s'"
ER_NOT_ALLOWED_COMMAND 42000
- cze "Použitý příkaz není v této verzi MySQL povolen"
+ cze "Použitý příkaz není v této verzi MariaDB povolen"
dan "Den brugte kommando er ikke tilladt med denne udgave af MariaDB"
nla "Het used commando is niet toegestaan in deze MariaDB versie"
eng "The used command is not allowed with this MariaDB version"
@@ -3404,7 +3404,7 @@ ER_NOT_ALLOWED_COMMAND 42000
hindi "यह कमांड इस MariaDB संस्करण के साथ इस्तेमाल नहीं किया जा सकता है"
hun "A hasznalt parancs nem engedelyezett ebben a MariaDB verzioban"
ita "Il comando utilizzato non e` supportato in questa versione di MariaDB"
- jpn "このMySQLバージョンでは利用できないコマンドです。"
+ jpn "このMariaDBバージョンでは利用できないコマンドです。"
kor "사용된 명령은 현재의 MariaDB 버젼에서는 이용되지 않습니다."
por "Comando usado não é permitido para esta versão do MariaDB"
rum "Comanda folosita nu este permisa pentru aceasta versiune de MariaDB"
@@ -3907,7 +3907,7 @@ ER_REQUIRES_PRIMARY_KEY 42000
swe "Denna tabelltyp kräver en PRIMARY KEY"
ukr "Цей тип таблиці потребує первинного ключа"
ER_NO_RAID_COMPILED
- cze "Tato verze MySQL není zkompilována s podporou RAID"
+ cze "Tato verze MariaDB není zkompilována s podporou RAID"
dan "Denne udgave af MariaDB er ikke oversat med understøttelse af RAID"
nla "Deze versie van MariaDB is niet gecompileerd met RAID ondersteuning"
eng "This version of MariaDB is not compiled with RAID support"
@@ -3917,7 +3917,7 @@ ER_NO_RAID_COMPILED
hindi "MariaDB का यह संस्करण RAID सपोर्ट के साथ कॉम्पाईल्ड नहीं है"
hun "Ezen leforditott MariaDB verzio nem tartalmaz RAID support-ot"
ita "Questa versione di MYSQL non e` compilata con il supporto RAID"
- jpn "このバージョンのMySQLはRAIDサポートを含めてコンパイルされていません。"
+ jpn "このバージョンのMariaDBはRAIDサポートを含めてコンパイルされていません。"
por "Esta versão do MariaDB não foi compilada com suporte a RAID"
rum "Aceasta versiune de MariaDB, nu a fost compilata cu suport pentru RAID"
rus "Эта версия MariaDB скомпилирована без поддержки RAID"
@@ -5042,7 +5042,7 @@ ER_UNKNOWN_COLLATION
ER_SLAVE_IGNORED_SSL_PARAMS
eng "SSL parameters in CHANGE MASTER are ignored because this MariaDB slave was compiled without SSL support; they can be used later if MariaDB slave with SSL is started"
ger "SSL-Parameter in CHANGE MASTER werden ignoriert, weil dieser MariaDB-Slave ohne SSL-Unterstützung kompiliert wurde. Sie können aber später verwendet werden, wenn ein MariaDB-Slave mit SSL gestartet wird"
- jpn "このMySQLスレーブはSSLサポートを含めてコンパイルされていないので、CHANGE MASTER のSSLパラメータは無視されました。今後SSLサポートを持つMySQLスレーブを起動する際に利用されます。"
+ jpn "このMariaDBスレーブはSSLサポートを含めてコンパイルされていないので、CHANGE MASTER のSSLパラメータは無視されました。今後SSLサポートを持つMariaDBスレーブを起動する際に利用されます。"
por "SSL parâmetros em CHANGE MASTER são ignorados porque este escravo MariaDB foi compilado sem o SSL suporte. Os mesmos podem ser usados mais tarde quando o escravo MariaDB com SSL seja iniciado."
spa "Parametros SSL en CHANGE MASTER son ignorados porque este slave MariaDB fue compilado sin soporte SSL; pueden ser usados despues cuando el slave MariaDB con SSL sea inicializado"
ER_SERVER_IS_IN_SECURE_AUTH_MODE
@@ -6753,7 +6753,7 @@ ER_INSECURE_PLAIN_TEXT
eng "Sending passwords in plain text without SSL/TLS is extremely insecure"
ER_INSECURE_CHANGE_MASTER
- eng "Storing MySQL user name or password information in the master.info repository is not secure and is therefore not recommended. Please see the MySQL Manual for more about this issue and possible alternatives"
+ eng "Storing MariaDB user name or password information in the master.info repository is not secure and is therefore not recommended. Please see the MariaDB Manual for more about this issue and possible alternatives"
ER_FOREIGN_DUPLICATE_KEY_WITH_CHILD_INFO 23000 S1009
eng "Foreign key constraint for table '%.192s', record '%-.192s' would lead to a duplicate entry in table '%.192s', key '%.192s'"
@@ -6860,7 +6860,7 @@ ER_TOO_LONG_TABLE_PARTITION_COMMENT
eng "Comment for table partition '%-.64s' is too long (max = %lu)"
ER_SLAVE_CONFIGURATION
- eng "Slave is not configured or failed to initialize properly. You must at least set --server-id to enable either a master or a slave. Additional error messages can be found in the MySQL error log"
+ eng "Slave is not configured or failed to initialize properly. You must at least set --server-id to enable either a master or a slave. Additional error messages can be found in the MariaDB error log"
ER_INNODB_FT_LIMIT
eng "InnoDB presently supports one FULLTEXT index creation at a time"
@@ -6887,10 +6887,10 @@ ER_MTS_CHANGE_MASTER_CANT_RUN_WITH_GAPS
eng "CHANGE MASTER cannot be executed when the slave was stopped with an error or killed in MTS mode. Consider using RESET SLAVE or START SLAVE UNTIL"
ER_MTS_RECOVERY_FAILURE
- eng "Cannot recover after SLAVE errored out in parallel execution mode. Additional error messages can be found in the MySQL error log"
+ eng "Cannot recover after SLAVE errored out in parallel execution mode. Additional error messages can be found in the MariaDB error log"
ER_MTS_RESET_WORKERS
- eng "Cannot clean up worker info tables. Additional error messages can be found in the MySQL error log"
+ eng "Cannot clean up worker info tables. Additional error messages can be found in the MariaDB error log"
ER_COL_COUNT_DOESNT_MATCH_CORRUPTED_V2
eng "Column count of %s.%s is wrong. Expected %d, found %d. The table is probably corrupted"
@@ -7398,8 +7398,8 @@ ER_FK_DEPTH_EXCEEDED
eng "Foreign key cascade delete/update exceeds max depth of %d."
ER_COL_COUNT_DOESNT_MATCH_PLEASE_UPDATE_V2
- eng "Column count of %s.%s is wrong. Expected %d, found %d. Created with MySQL %d, now running %d. Please use mysql_upgrade to fix this error."
- ger "Spaltenanzahl von %s.%s falsch. %d erwartet, aber %d erhalten. Erzeugt mit MySQL %d, jetzt unter %d. Bitte benutzen Sie mysql_upgrade, um den Fehler zu beheben"
+ eng "Column count of %s.%s is wrong. Expected %d, found %d. Created with MariaDB %d, now running %d. Please use mysql_upgrade to fix this error."
+ ger "Spaltenanzahl von %s.%s falsch. %d erwartet, aber %d erhalten. Erzeugt mit MariaDB %d, jetzt unter %d. Bitte benutzen Sie mysql_upgrade, um den Fehler zu beheben"
ER_WARN_TRIGGER_DOESNT_HAVE_CREATED
eng "Trigger %s.%s.%s does not have CREATED attribute."
diff --git a/sql/sp_head.cc b/sql/sp_head.cc
index df9471880d9..f402b4919b9 100644
--- a/sql/sp_head.cc
+++ b/sql/sp_head.cc
@@ -2002,7 +2002,6 @@ sp_head::execute_procedure(THD *thd, List<Item> *args)
thd->get_stmt_da()->set_overwrite_status(false);
}
- thd_proc_info(thd, "closing tables");
close_thread_tables(thd);
thd_proc_info(thd, 0);
@@ -3125,7 +3124,6 @@ sp_lex_keeper::reset_lex_and_exec_core(THD *thd, uint *nextp,
thd->is_error() ? trans_rollback_stmt(thd) : trans_commit_stmt(thd);
thd->get_stmt_da()->set_overwrite_status(false);
}
- thd_proc_info(thd, "closing tables");
close_thread_tables(thd);
thd_proc_info(thd, 0);
diff --git a/sql/sql_class.h b/sql/sql_class.h
index 6a1cfe07e66..1358fe09f4c 100644
--- a/sql/sql_class.h
+++ b/sql/sql_class.h
@@ -693,7 +693,6 @@ typedef struct system_variables
ulong session_track_transaction_info;
my_bool session_track_schema;
my_bool session_track_state_change;
- my_bool sequence_read_skip_cache;
ulong threadpool_priority;
@@ -831,6 +830,7 @@ typedef struct system_status_var
double cpu_time, busy_time;
/* Don't initialize */
/* Memory used for thread local storage */
+ int64 max_local_memory_used;
volatile int64 local_memory_used;
/* Memory allocated for global usage */
volatile int64 global_memory_used;
@@ -2225,12 +2225,13 @@ public:
const char *calling_file,
const unsigned int calling_line)
{
- DBUG_PRINT("THD::enter_stage", ("%s:%d", calling_file, calling_line));
+ DBUG_PRINT("THD::enter_stage", ("%s at %s:%d", stage->m_name,
+ calling_file, calling_line));
DBUG_ASSERT(stage);
m_current_stage_key= stage->m_key;
proc_info= stage->m_name;
#if defined(ENABLED_PROFILING)
- profiling.status_change(stage->m_name, calling_func, calling_file,
+ profiling.status_change(proc_info, calling_func, calling_file,
calling_line);
#endif
#ifdef HAVE_PSI_THREAD_INTERFACE
diff --git a/sql/sql_const.h b/sql/sql_const.h
index a5756aa1f39..007b7faeebb 100644
--- a/sql/sql_const.h
+++ b/sql/sql_const.h
@@ -175,6 +175,11 @@
#define TABLE_ALLOC_BLOCK_SIZE 1024
#define WARN_ALLOC_BLOCK_SIZE 2048
#define WARN_ALLOC_PREALLOC_SIZE 1024
+/*
+ Note that if we are using 32K or less, then TCmalloc will use a local
+ heap without locks!
+*/
+#define SHOW_ALLOC_BLOCK_SIZE (32768-MALLOC_OVERHEAD)
/*
The following parameters is to decide when to use an extra cache to
diff --git a/sql/sql_cte.cc b/sql/sql_cte.cc
index ad37ef36e2c..487c2b3a0bb 100644
--- a/sql/sql_cte.cc
+++ b/sql/sql_cte.cc
@@ -366,7 +366,10 @@ void With_element::check_dependencies_in_select(st_select_lex *sl,
/* Now look for the dependencies in the subqueries of sl */
st_select_lex_unit *inner_unit= sl->first_inner_unit();
for (; inner_unit; inner_unit= inner_unit->next_unit())
- check_dependencies_in_unit(inner_unit, ctxt, in_subq, dep_map);
+ {
+ if (!inner_unit->with_element)
+ check_dependencies_in_unit(inner_unit, ctxt, in_subq, dep_map);
+ }
}
@@ -854,7 +857,6 @@ st_select_lex_unit *With_element::clone_parsed_spec(THD *thd,
with_table->next_global= spec_tables;
}
res= &lex->unit;
- res->set_with_clause(owner);
lex->unit.include_down(with_table->select_lex);
lex->unit.set_slave(with_select);
@@ -863,6 +865,8 @@ st_select_lex_unit *With_element::clone_parsed_spec(THD *thd,
insert_chain_before(
(st_select_lex_node **) &(old_lex->all_selects_list),
with_select));
+ if (check_dependencies_in_with_clauses(lex->with_clauses_list))
+ res= NULL;
lex_end(lex);
err:
if (arena)
@@ -1006,14 +1010,18 @@ With_element *st_select_lex::find_table_def_in_with_clauses(TABLE_LIST *table)
and it was unsuccesful. Yet for units cloned from the spec it has not
been done yet.
*/
- if (with_elem && sl->master_unit() == with_elem->spec)
+ With_clause *attached_with_clause=sl->get_with_clause();
+ if (attached_with_clause &&
+ (found= attached_with_clause->find_table_def(table, NULL)))
break;
- With_clause *with_clause=sl->get_with_clause();
- if (with_clause)
+ if (with_elem)
{
- With_element *barrier= with_clause->with_recursive ? NULL : with_elem;
- if ((found= with_clause->find_table_def(table, barrier)))
+ With_clause *containing_with_clause= with_elem->get_owner();
+ With_element *barrier= containing_with_clause->with_recursive ?
+ NULL : with_elem;
+ if ((found= containing_with_clause->find_table_def(table, barrier)))
break;
+ sl= sl->master_unit()->outer_select();
}
master_unit= sl->master_unit();
/* Do not look for the table's definition beyond the scope of the view */
diff --git a/sql/sql_delete.cc b/sql/sql_delete.cc
index c880374f9ab..d0fc422c2f9 100644
--- a/sql/sql_delete.cc
+++ b/sql/sql_delete.cc
@@ -273,6 +273,7 @@ bool mysql_delete(THD *thd, TABLE_LIST *table_list, COND *conds,
if (open_and_lock_tables(thd, table_list, TRUE, 0))
DBUG_RETURN(TRUE);
+ THD_STAGE_INFO(thd, stage_init_update);
if (mysql_handle_list_of_derived(thd->lex, table_list, DT_MERGE_FOR_INSERT))
DBUG_RETURN(TRUE);
if (mysql_handle_list_of_derived(thd->lex, table_list, DT_PREPARE))
@@ -289,7 +290,6 @@ bool mysql_delete(THD *thd, TABLE_LIST *table_list, COND *conds,
table_list->view_db.str, table_list->view_name.str);
DBUG_RETURN(TRUE);
}
- THD_STAGE_INFO(thd, stage_init);
table->map=1;
query_plan.select_lex= &thd->lex->select_lex;
query_plan.table= table;
@@ -556,7 +556,6 @@ bool mysql_delete(THD *thd, TABLE_LIST *table_list, COND *conds,
goto got_error;
init_ftfuncs(thd, select_lex, 1);
- THD_STAGE_INFO(thd, stage_updating);
if (table->prepare_triggers_for_delete_stmt_or_event())
{
@@ -588,6 +587,8 @@ bool mysql_delete(THD *thd, TABLE_LIST *table_list, COND *conds,
deltempfile= new (thd->mem_root) Unique (refpos_order_cmp, table->file,
table->file->ref_length,
MEM_STRIP_BUF_SIZE);
+
+ THD_STAGE_INFO(thd, stage_searching_rows_for_update);
while (!(error=info.read_record()) && !thd->killed &&
! thd->is_error())
{
@@ -613,6 +614,7 @@ bool mysql_delete(THD *thd, TABLE_LIST *table_list, COND *conds,
delete_record= true;
}
+ THD_STAGE_INFO(thd, stage_updating);
while (!(error=info.read_record()) && !thd->killed &&
! thd->is_error())
{
diff --git a/sql/sql_derived.cc b/sql/sql_derived.cc
index 2df3af03af5..6eb6466427d 100644
--- a/sql/sql_derived.cc
+++ b/sql/sql_derived.cc
@@ -468,7 +468,8 @@ bool mysql_derived_merge(THD *thd, LEX *lex, TABLE_LIST *derived)
// Update used tables cache according to new table map
if (derived->on_expr)
{
- derived->on_expr->fix_after_pullout(parent_lex, &derived->on_expr);
+ derived->on_expr->fix_after_pullout(parent_lex, &derived->on_expr,
+ TRUE);
fix_list_after_tbl_changes(parent_lex, &derived->nested_join->join_list);
}
}
@@ -641,7 +642,8 @@ bool mysql_derived_prepare(THD *thd, LEX *lex, TABLE_LIST *derived)
SELECT_LEX_UNIT *unit= derived->get_unit();
DBUG_ENTER("mysql_derived_prepare");
bool res= FALSE;
- DBUG_PRINT("enter", ("unit %p", unit));
+ DBUG_PRINT("enter", ("unit: %p table_list: %p Alias '%s'",
+ unit, derived, derived->alias));
if (!unit)
DBUG_RETURN(FALSE);
diff --git a/sql/sql_insert.cc b/sql/sql_insert.cc
index b12b470209c..32695a450c4 100644
--- a/sql/sql_insert.cc
+++ b/sql/sql_insert.cc
@@ -761,9 +761,8 @@ bool mysql_insert(THD *thd,TABLE_LIST *table_list,
DBUG_RETURN(TRUE);
}
+ THD_STAGE_INFO(thd, stage_init_update);
lock_type= table_list->lock_type;
-
- THD_STAGE_INFO(thd, stage_init);
thd->lex->used_tables=0;
values= its++;
if (bulk_parameters_set(thd))
@@ -860,7 +859,6 @@ bool mysql_insert(THD *thd,TABLE_LIST *table_list,
#endif
error=0;
- THD_STAGE_INFO(thd, stage_update);
if (duplic == DUP_REPLACE &&
(!table->triggers || !table->triggers->has_delete_triggers()))
table->file->extra(HA_EXTRA_WRITE_CAN_REPLACE);
@@ -940,6 +938,8 @@ bool mysql_insert(THD *thd,TABLE_LIST *table_list,
goto values_loop_end;
}
}
+
+ THD_STAGE_INFO(thd, stage_update);
do
{
DBUG_PRINT("info", ("iteration %llu", iteration));
@@ -3357,7 +3357,7 @@ bool Delayed_insert::handle_inserts(void)
}
if (WSREP((&thd)))
- thd_proc_info(&thd, "insert done");
+ thd_proc_info(&thd, "Insert done");
else
thd_proc_info(&thd, 0);
mysql_mutex_unlock(&mutex);
diff --git a/sql/sql_load.cc b/sql/sql_load.cc
index cf676d5f706..d972947c718 100644
--- a/sql/sql_load.cc
+++ b/sql/sql_load.cc
@@ -348,7 +348,7 @@ int mysql_load(THD *thd,sql_exchange *ex,TABLE_LIST *table_list,
{
DBUG_RETURN(TRUE);
}
- thd_proc_info(thd, "executing");
+ thd_proc_info(thd, "Executing");
/*
Let us emit an error if we are loading data to table which is used
in subselect in SET clause like we do it for INSERT.
@@ -574,7 +574,7 @@ int mysql_load(THD *thd,sql_exchange *ex,TABLE_LIST *table_list,
}
}
- thd_proc_info(thd, "reading file");
+ thd_proc_info(thd, "Reading file");
if (!(error= MY_TEST(read_info.error)))
{
table->reset_default_fields();
diff --git a/sql/sql_parse.cc b/sql/sql_parse.cc
index 2f886d91780..b3a9ad144d5 100644
--- a/sql/sql_parse.cc
+++ b/sql/sql_parse.cc
@@ -2375,7 +2375,7 @@ com_multi_end:
(thd->open_tables == NULL ||
(thd->locked_tables_mode == LTM_LOCK_TABLES)));
- thd_proc_info(thd, "updating status");
+ thd_proc_info(thd, "Updating status");
/* Finalize server status flags after executing a command. */
thd->update_server_status();
if (command != COM_MULTI)
@@ -6275,10 +6275,14 @@ finish:
thd->reset_kill_query();
}
if (thd->is_error() || (thd->variables.option_bits & OPTION_MASTER_SQL_ERROR))
+ {
+ THD_STAGE_INFO(thd, stage_rollback);
trans_rollback_stmt(thd);
+ }
else
{
/* If commit fails, we should be able to reset the OK status. */
+ THD_STAGE_INFO(thd, stage_commit);
thd->get_stmt_da()->set_overwrite_status(true);
trans_commit_stmt(thd);
thd->get_stmt_da()->set_overwrite_status(false);
@@ -6288,12 +6292,13 @@ finish:
#endif
}
- /* Free tables */
+ /* Free tables. Set stage 'closing tables' */
close_thread_tables(thd);
#ifdef WITH_WSREP
thd->wsrep_consistency_check= NO_CONSISTENCY_CHECK;
#endif /* WITH_WSREP */
+
#ifndef DBUG_OFF
if (lex->sql_command != SQLCOM_SET_OPTION && ! thd->in_sub_stmt)
DEBUG_SYNC(thd, "execute_command_after_close_tables");
@@ -6311,6 +6316,7 @@ finish:
one of storage engines (e.g. due to deadlock). Rollback transaction in
all storage engines including binary log.
*/
+ THD_STAGE_INFO(thd, stage_rollback_implicit);
trans_rollback_implicit(thd);
thd->mdl_context.release_transactional_locks();
}
@@ -6320,6 +6326,7 @@ finish:
DBUG_ASSERT(! thd->in_sub_stmt);
if (!(thd->variables.option_bits & OPTION_GTID_BEGIN))
{
+ THD_STAGE_INFO(thd, stage_commit_implicit);
/* If commit fails, we should be able to reset the OK status. */
thd->get_stmt_da()->set_overwrite_status(true);
/* Commit the normal transaction if one is active. */
@@ -6347,6 +6354,8 @@ finish:
thd->mdl_context.release_statement_locks();
}
+ THD_STAGE_INFO(thd, stage_starting_cleanup);
+
TRANSACT_TRACKER(add_trx_state_from_thd(thd));
WSREP_TO_ISOLATION_END;
@@ -6615,7 +6624,9 @@ check_access(THD *thd, ulong want_access, const char *db, ulong *save_priv,
dummy= 0;
}
- THD_STAGE_INFO(thd, stage_checking_permissions);
+ /* check access may be called twice in a row. Don't change to same stage */
+ if (thd->proc_info != stage_checking_permissions.m_name)
+ THD_STAGE_INFO(thd, stage_checking_permissions);
if ((!db || !db[0]) && !thd->db && !dont_check_global_grants)
{
DBUG_PRINT("error",("No database"));
diff --git a/sql/sql_partition_admin.cc b/sql/sql_partition_admin.cc
index 0c1c9fb02de..efddcbf3857 100644
--- a/sql/sql_partition_admin.cc
+++ b/sql/sql_partition_admin.cc
@@ -596,7 +596,7 @@ bool Sql_cmd_alter_table_exchange_partition::
/* Table and partition has same structure/options, OK to exchange */
- thd_proc_info(thd, "verifying data with partition");
+ thd_proc_info(thd, "Verifying data with partition");
if (verify_data_with_partition(swap_table, part_table, swap_part_id))
DBUG_RETURN(TRUE);
diff --git a/sql/sql_profile.h b/sql/sql_profile.h
index 38682f3ddec..c96828fc678 100644
--- a/sql/sql_profile.h
+++ b/sql/sql_profile.h
@@ -287,7 +287,7 @@ public:
@param initial_state (optional) name of period before first state change
*/
- void start_new_query(const char *initial_state= "starting")
+ void start_new_query(const char *initial_state= "Starting")
{
DBUG_ASSERT(!current);
if (unlikely(enabled))
diff --git a/sql/sql_select.cc b/sql/sql_select.cc
index fe87dd9afbb..abbf2616537 100644
--- a/sql/sql_select.cc
+++ b/sql/sql_select.cc
@@ -2267,6 +2267,76 @@ derived_exit:
DBUG_RETURN(0);
}
+/**
+ Add having condition as a where clause condition of the given temp table.
+
+ @param tab Table to which having condition is added.
+
+ @returns false if success, true if error.
+*/
+
+bool JOIN::add_having_as_table_cond(JOIN_TAB *tab)
+{
+ tmp_having->update_used_tables();
+ table_map used_tables= tab->table->map | OUTER_REF_TABLE_BIT;
+
+ /* If tmp table is not used then consider conditions of const table also */
+ if (!need_tmp)
+ used_tables|= const_table_map;
+
+ DBUG_ENTER("JOIN::add_having_as_table_cond");
+
+ Item* sort_table_cond= make_cond_for_table(thd, tmp_having, used_tables,
+ (table_map) 0, false,
+ false, false);
+ if (sort_table_cond)
+ {
+ if (!tab->select)
+ {
+ if (!(tab->select= new SQL_SELECT))
+ DBUG_RETURN(true);
+ tab->select->head= tab->table;
+ }
+ if (!tab->select->cond)
+ tab->select->cond= sort_table_cond;
+ else
+ {
+ if (!(tab->select->cond=
+ new (thd->mem_root) Item_cond_and(thd,
+ tab->select->cond,
+ sort_table_cond)))
+ DBUG_RETURN(true);
+ }
+ if (tab->pre_idx_push_select_cond)
+ {
+ if (sort_table_cond->type() == Item::COND_ITEM)
+ sort_table_cond= sort_table_cond->copy_andor_structure(thd);
+ if (!(tab->pre_idx_push_select_cond=
+ new (thd->mem_root) Item_cond_and(thd,
+ tab->pre_idx_push_select_cond,
+ sort_table_cond)))
+ DBUG_RETURN(true);
+ }
+ if (tab->select->cond && !tab->select->cond->fixed)
+ tab->select->cond->fix_fields(thd, 0);
+ if (tab->pre_idx_push_select_cond && !tab->pre_idx_push_select_cond->fixed)
+ tab->pre_idx_push_select_cond->fix_fields(thd, 0);
+ tab->select->pre_idx_push_select_cond= tab->pre_idx_push_select_cond;
+ tab->set_select_cond(tab->select->cond, __LINE__);
+ tab->select_cond->top_level_item();
+ DBUG_EXECUTE("where",print_where(tab->select->cond,
+ "select and having",
+ QT_ORDINARY););
+
+ having= make_cond_for_table(thd, tmp_having, ~ (table_map) 0,
+ ~used_tables, false, false, false);
+ DBUG_EXECUTE("where",
+ print_where(having, "having after sort", QT_ORDINARY););
+ }
+
+ DBUG_RETURN(false);
+}
+
/**
Set info for aggregation tables
@@ -2296,6 +2366,7 @@ bool JOIN::make_aggr_tables_info()
TABLE *exec_tmp_table= NULL;
bool distinct= false;
bool keep_row_order= false;
+ bool is_having_added_as_table_cond= false;
DBUG_ENTER("JOIN::make_aggr_tables_info");
const bool has_group_by= this->group;
@@ -2482,29 +2553,6 @@ bool JOIN::make_aggr_tables_info()
if (exec_tmp_table->distinct)
optimize_distinct();
- /*
- We don't have to store rows in temp table that doesn't match HAVING if:
- - we are sorting the table and writing complete group rows to the
- temp table.
- - We are using DISTINCT without resolving the distinct as a GROUP BY
- on all columns.
-
- If having is not handled here, it will be checked before the row
- is sent to the client.
-
- In the case of window functions however, we *must* make sure to not
- store any rows which don't match HAVING within the temp table,
- as rows will end up being used during their computation.
- */
- if (having &&
- (sort_and_group || (exec_tmp_table->distinct && !group_list) ||
- select_lex->have_window_funcs()))
- {
- /* Attach HAVING to tmp table's condition */
- curr_tab->having= having;
- having= NULL; /* Already done */
- }
-
/* Change sum_fields reference to calculated fields in tmp_table */
items1= ref_ptr_array_slice(2);
if ((sort_and_group || curr_tab->table->group ||
@@ -2532,6 +2580,38 @@ bool JOIN::make_aggr_tables_info()
curr_tab->fields= &tmp_fields_list1;
set_postjoin_aggr_write_func(curr_tab);
+ /*
+ If having is not handled here, it will be checked before the row is sent
+ to the client.
+ */
+ if (tmp_having &&
+ (sort_and_group || (exec_tmp_table->distinct && !group_list) ||
+ select_lex->have_window_funcs()))
+ {
+ /*
+ If there is no select distinct and there are no window functions
+ then move the having to table conds of tmp table.
+ NOTE : We cannot apply having after distinct or window functions
+ If columns of having are not part of select distinct,
+ then distinct may remove rows which can satisfy having.
+ In the case of window functions we *must* make sure to not
+ store any rows which don't match HAVING within the temp table,
+ as rows will end up being used during their computation.
+ */
+ if (!select_distinct && !select_lex->have_window_funcs() &&
+ add_having_as_table_cond(curr_tab))
+ DBUG_RETURN(true);
+ is_having_added_as_table_cond= tmp_having != having;
+
+ /*
+ Having condition which we are not able to add as tmp table conds are
+ kept as before. And, this will be applied before storing the rows in
+ tmp table.
+ */
+ curr_tab->having= having;
+ having= NULL; // Already done
+ }
+
tmp_table_param.func_count= 0;
tmp_table_param.field_count+= tmp_table_param.func_count;
if (sort_and_group || curr_tab->table->group)
@@ -2721,60 +2801,11 @@ bool JOIN::make_aggr_tables_info()
DBUG_PRINT("info",("Sorting for send_result_set_metadata"));
THD_STAGE_INFO(thd, stage_sorting_result);
/* If we have already done the group, add HAVING to sorted table */
- if (tmp_having && !group_list && !sort_and_group)
+ if (tmp_having && !is_having_added_as_table_cond &&
+ !group_list && !sort_and_group)
{
- // Some tables may have been const
- tmp_having->update_used_tables();
- table_map used_tables= (const_table_map | curr_tab->table->map);
-
- Item* sort_table_cond= make_cond_for_table(thd, tmp_having, used_tables,
- (table_map) 0, false,
- false, false);
- if (sort_table_cond)
- {
- if (!curr_tab->select)
- {
- if (!(curr_tab->select= new SQL_SELECT))
- DBUG_RETURN(true);
- curr_tab->select->head= curr_tab->table;
- }
- if (!curr_tab->select->cond)
- curr_tab->select->cond= sort_table_cond;
- else
- {
- if (!(curr_tab->select->cond=
- new (thd->mem_root) Item_cond_and(thd, curr_tab->select->cond,
- sort_table_cond)))
- DBUG_RETURN(true);
- }
- if (curr_tab->pre_idx_push_select_cond)
- {
- if (sort_table_cond->type() == Item::COND_ITEM)
- sort_table_cond= sort_table_cond->copy_andor_structure(thd);
- if (!(curr_tab->pre_idx_push_select_cond=
- new (thd->mem_root) Item_cond_and(thd,
- curr_tab->pre_idx_push_select_cond,
- sort_table_cond)))
- DBUG_RETURN(true);
- }
- if (curr_tab->select->cond && !curr_tab->select->cond->fixed)
- curr_tab->select->cond->fix_fields(thd, 0);
- if (curr_tab->pre_idx_push_select_cond &&
- !curr_tab->pre_idx_push_select_cond->fixed)
- curr_tab->pre_idx_push_select_cond->fix_fields(thd, 0);
- curr_tab->select->pre_idx_push_select_cond=
- curr_tab->pre_idx_push_select_cond;
- curr_tab->set_select_cond(curr_tab->select->cond, __LINE__);
- curr_tab->select_cond->top_level_item();
- DBUG_EXECUTE("where",print_where(curr_tab->select->cond,
- "select and having",
- QT_ORDINARY););
-
- having= make_cond_for_table(thd, tmp_having, ~ (table_map) 0,
- ~used_tables, false, false, false);
- DBUG_EXECUTE("where",
- print_where(having, "having after sort", QT_ORDINARY););
- }
+ if (add_having_as_table_cond(curr_tab))
+ DBUG_RETURN(true);
}
if (group)
diff --git a/sql/sql_select.h b/sql/sql_select.h
index 260b86029c6..cc52cae02da 100644
--- a/sql/sql_select.h
+++ b/sql/sql_select.h
@@ -1464,6 +1464,8 @@ public:
ordered_index_usage= ordered_index_void;
need_distinct= 0;
skip_sort_order= 0;
+ with_two_phase_optimization= 0;
+ is_for_splittable_grouping_derived= 0;
need_tmp= 0;
hidden_group_fields= 0; /*safety*/
error= 0;
@@ -1708,6 +1710,7 @@ private:
void optimize_distinct();
void cleanup_item_list(List<Item> &items) const;
+ bool add_having_as_table_cond(JOIN_TAB *tab);
bool make_aggr_tables_info();
};
diff --git a/sql/sql_show.cc b/sql/sql_show.cc
index f5fd3427fa6..2df84b473b8 100644
--- a/sql/sql_show.cc
+++ b/sql/sql_show.cc
@@ -93,7 +93,6 @@ enum enum_i_s_events_fields
#define USERNAME_WITH_HOST_CHAR_LENGTH (USERNAME_CHAR_LENGTH + HOSTNAME_LENGTH + 2)
-
static const LEX_CSTRING trg_action_time_type_names[]=
{
{ STRING_WITH_LEN("BEFORE") },
@@ -3103,17 +3102,17 @@ int fill_schema_processlist(THD* thd, TABLE_LIST* tables, COND* cond)
{
table->field[7]->store(tmp->query(),
MY_MIN(PROCESS_LIST_INFO_WIDTH,
- tmp->query_length()), cs);
+ tmp->query_length()), cs);
table->field[7]->set_notnull();
}
/* INFO_BINARY */
if (tmp->query())
{
- table->field[15]->store(tmp->query(),
+ table->field[16]->store(tmp->query(),
MY_MIN(PROCESS_LIST_INFO_WIDTH,
tmp->query_length()), &my_charset_bin);
- table->field[15]->set_notnull();
+ table->field[16]->set_notnull();
}
/*
@@ -3136,14 +3135,14 @@ int fill_schema_processlist(THD* thd, TABLE_LIST* tables, COND* cond)
*/
table->field[12]->store((longlong) tmp->status_var.local_memory_used,
FALSE);
- table->field[12]->set_notnull();
- table->field[13]->store((longlong) tmp->get_examined_row_count(), TRUE);
- table->field[13]->set_notnull();
+ table->field[13]->store((longlong) tmp->status_var.max_local_memory_used,
+ FALSE);
+ table->field[14]->store((longlong) tmp->get_examined_row_count(), TRUE);
/* QUERY_ID */
- table->field[14]->store(tmp->query_id, TRUE);
+ table->field[15]->store(tmp->query_id, TRUE);
- table->field[16]->store(tmp->os_thread_id);
+ table->field[17]->store(tmp->os_thread_id);
if (schema_table_store_record(thd, table))
{
@@ -4304,14 +4303,15 @@ static void get_table_engine_for_i_s(THD *thd, char *buf, TABLE_LIST *tl,
@retval TRUE - Failure.
*/
static bool
-fill_schema_table_by_open(THD *thd, bool is_show_fields_or_keys,
+fill_schema_table_by_open(THD *thd, MEM_ROOT *mem_root,
+ bool is_show_fields_or_keys,
TABLE *table, ST_SCHEMA_TABLE *schema_table,
LEX_CSTRING *orig_db_name,
LEX_CSTRING *orig_table_name,
Open_tables_backup *open_tables_state_backup,
bool can_deadlock)
{
- Query_arena i_s_arena(thd->mem_root,
+ Query_arena i_s_arena(mem_root,
Query_arena::STMT_CONVENTIONAL_EXECUTION),
backup_arena, *old_arena;
LEX *old_lex= thd->lex, temp_lex, *lex;
@@ -4888,8 +4888,11 @@ int get_all_tables(THD *thd, TABLE_LIST *tables, COND *cond)
#endif
uint table_open_method= tables->table_open_method;
bool can_deadlock;
+ MEM_ROOT tmp_mem_root;
DBUG_ENTER("get_all_tables");
+ bzero(&tmp_mem_root, sizeof(tmp_mem_root));
+
/*
In cases when SELECT from I_S table being filled by this call is
part of statement which also uses other tables or is being executed
@@ -4925,7 +4928,7 @@ int get_all_tables(THD *thd, TABLE_LIST *tables, COND *cond)
table_name.str= lsel->table_list.first->table_name;
table_name.length= lsel->table_list.first->table_name_length;
- error= fill_schema_table_by_open(thd, TRUE,
+ error= fill_schema_table_by_open(thd, thd->mem_root, TRUE,
table, schema_table,
&db_name, &table_name,
&open_tables_state_backup,
@@ -4950,6 +4953,11 @@ int get_all_tables(THD *thd, TABLE_LIST *tables, COND *cond)
if (make_db_list(thd, &db_names, &plan->lookup_field_vals))
goto err;
+
+ /* Use tmp_mem_root to allocate data for opened tables */
+ init_alloc_root(&tmp_mem_root, SHOW_ALLOC_BLOCK_SIZE, SHOW_ALLOC_BLOCK_SIZE,
+ MY_THREAD_SPECIFIC);
+
for (size_t i=0; i < db_names.elements(); i++)
{
LEX_CSTRING *db_name= db_names.at(i);
@@ -5035,12 +5043,13 @@ int get_all_tables(THD *thd, TABLE_LIST *tables, COND *cond)
}
DEBUG_SYNC(thd, "before_open_in_get_all_tables");
- if (fill_schema_table_by_open(thd, FALSE,
+ if (fill_schema_table_by_open(thd, &tmp_mem_root, FALSE,
table, schema_table,
db_name, table_name,
&open_tables_state_backup,
can_deadlock))
goto err;
+ free_root(&tmp_mem_root, MY_MARK_BLOCKS_FREE);
}
}
}
@@ -5050,6 +5059,7 @@ int get_all_tables(THD *thd, TABLE_LIST *tables, COND *cond)
error= 0;
err:
thd->restore_backup_open_tables_state(&open_tables_state_backup);
+ free_root(&tmp_mem_root, 0);
DBUG_RETURN(error);
}
@@ -9074,6 +9084,7 @@ ST_FIELD_INFO processlist_fields_info[]=
{"PROGRESS", 703, MYSQL_TYPE_DECIMAL, 0, 0, "Progress",
SKIP_OPEN_TABLE},
{"MEMORY_USED", 7, MYSQL_TYPE_LONGLONG, 0, 0, "Memory_used", SKIP_OPEN_TABLE},
+ {"MAX_MEMORY_USED", 7, MYSQL_TYPE_LONGLONG, 0, 0, "Max_memory_used", SKIP_OPEN_TABLE},
{"EXAMINED_ROWS", 7, MYSQL_TYPE_LONG, 0, 0, "Examined_rows", SKIP_OPEN_TABLE},
{"QUERY_ID", 4, MYSQL_TYPE_LONGLONG, 0, 0, 0, SKIP_OPEN_TABLE},
{"INFO_BINARY", PROCESS_LIST_INFO_WIDTH, MYSQL_TYPE_BLOB, 0, 1,
diff --git a/sql/sql_table.cc b/sql/sql_table.cc
index 7371889cc7f..58a6666b219 100644
--- a/sql/sql_table.cc
+++ b/sql/sql_table.cc
@@ -8603,7 +8603,7 @@ bool mysql_alter_table(THD *thd, const char *new_db, const char *new_name,
#endif
}
- THD_STAGE_INFO(thd, stage_init);
+ THD_STAGE_INFO(thd, stage_init_update);
/*
Code below can handle only base tables so ensure that we won't open a view.
diff --git a/sql/sql_union.cc b/sql/sql_union.cc
index fd988d53e53..8cce7f33057 100644
--- a/sql/sql_union.cc
+++ b/sql/sql_union.cc
@@ -713,13 +713,7 @@ bool st_select_lex_unit::join_union_type_handlers(THD *thd_arg,
holders[pos].set_handler(item_type_handler);
else
{
- if (first_sl->item_list.elements != sl->item_list.elements)
- {
- my_message(ER_WRONG_NUMBER_OF_COLUMNS_IN_SELECT,
- ER_THD(thd_arg, ER_WRONG_NUMBER_OF_COLUMNS_IN_SELECT),
- MYF(0));
- DBUG_RETURN(true);
- }
+ DBUG_ASSERT(first_sl->item_list.elements == sl->item_list.elements);
if (holders[pos].aggregate_for_result(item_type_handler))
{
my_error(ER_ILLEGAL_PARAMETER_DATA_TYPES2_FOR_OPERATION, MYF(0),
@@ -988,6 +982,16 @@ bool st_select_lex_unit::prepare(THD *thd_arg, select_result *sel_result,
goto err;
}
}
+ else
+ {
+ if (first_sl->item_list.elements != sl->item_list.elements)
+ {
+ my_message(ER_WRONG_NUMBER_OF_COLUMNS_IN_SELECT,
+ ER_THD(thd_arg, ER_WRONG_NUMBER_OF_COLUMNS_IN_SELECT),
+ MYF(0));
+ goto err;
+ }
+ }
if (is_recursive)
{
if (!with_element->is_anchor(sl))
diff --git a/sql/sql_update.cc b/sql/sql_update.cc
index 96f48be5ff2..47ec8b89d48 100644
--- a/sql/sql_update.cc
+++ b/sql/sql_update.cc
@@ -305,12 +305,12 @@ int mysql_update(THD *thd,
if (lock_tables(thd, table_list, table_count, 0))
DBUG_RETURN(1);
+ THD_STAGE_INFO(thd, stage_init_update);
if (table_list->handle_derived(thd->lex, DT_MERGE_FOR_INSERT))
DBUG_RETURN(1);
if (table_list->handle_derived(thd->lex, DT_PREPARE))
DBUG_RETURN(1);
- THD_STAGE_INFO(thd, stage_init);
table= table_list->table;
if (!table_list->single_table_updatable())
@@ -707,7 +707,6 @@ int mysql_update(THD *thd,
*/
thd->count_cuted_fields= CHECK_FIELD_WARN;
thd->cuted_fields=0L;
- THD_STAGE_INFO(thd, stage_updating);
transactional_table= table->file->has_transactions();
thd->abort_on_warning= !ignore && thd->is_strict_mode();
@@ -735,6 +734,7 @@ int mysql_update(THD *thd,
can_compare_record= records_are_comparable(table);
explain->tracker.on_scan_init();
+ THD_STAGE_INFO(thd, stage_updating);
while (!(error=info.read_record()) && !thd->killed)
{
explain->tracker.on_record_read();
diff --git a/sql/sql_view.cc b/sql/sql_view.cc
index 2d8129fd223..dd8c6b70446 100644
--- a/sql/sql_view.cc
+++ b/sql/sql_view.cc
@@ -705,7 +705,6 @@ bool mysql_create_view(THD *thd, TABLE_LIST *views,
DBUG_RETURN(0);
err:
- THD_STAGE_INFO(thd, stage_end);
lex->link_first_table_back(view, link_to_local);
unit->cleanup();
DBUG_RETURN(res || thd->is_error());
diff --git a/sql/winservice.c b/sql/winservice.c
index efbbb527c9b..388ea886cea 100644
--- a/sql/winservice.c
+++ b/sql/winservice.c
@@ -147,12 +147,13 @@ int get_mysql_service_properties(const wchar_t *bin_path,
if(numargs == 2)
{
/*
- There are rare cases where service config does not have
- --defaults-filein the binary parth . There services were registered with
- plain mysqld --install, the data directory is next to "bin" in this case.
- Service name (second parameter) must be MySQL.
+ There are rare cases where service config does not have
+ --defaults-file in the binary parth . There services were
+ registered with plain mysqld --install, the data directory is
+ next to "bin" in this case. Service name (second parameter)
+ must be MySQL.
*/
- if(wcscmp(args[1], L"MySQL") != 0)
+ if (wcscmp(args[1], L"MySQL") != 0)
goto end;
have_inifile= FALSE;
}
diff --git a/sql/wsrep_applier.cc b/sql/wsrep_applier.cc
index 465d1f25b5b..a5c39887cbd 100644
--- a/sql/wsrep_applier.cc
+++ b/sql/wsrep_applier.cc
@@ -235,11 +235,11 @@ wsrep_cb_status_t wsrep_apply_cb(void* const ctx,
#ifdef WSREP_PROC_INFO
snprintf(thd->wsrep_info, sizeof(thd->wsrep_info) - 1,
- "applying write set %lld: %p, %zu",
+ "Applying write set %lld: %p, %zu",
(long long)wsrep_thd_trx_seqno(thd), buf, buf_len);
thd_proc_info(thd, thd->wsrep_info);
#else
- thd_proc_info(thd, "applying write set");
+ thd_proc_info(thd, "Applying write set");
#endif /* WSREP_PROC_INFO */
/* tune FK and UK checking policy */
@@ -269,10 +269,10 @@ wsrep_cb_status_t wsrep_apply_cb(void* const ctx,
#ifdef WSREP_PROC_INFO
snprintf(thd->wsrep_info, sizeof(thd->wsrep_info) - 1,
- "applied write set %lld", (long long)wsrep_thd_trx_seqno(thd));
+ "Applied write set %lld", (long long)wsrep_thd_trx_seqno(thd));
thd_proc_info(thd, thd->wsrep_info);
#else
- thd_proc_info(thd, "applied write set");
+ thd_proc_info(thd, "Applied write set");
#endif /* WSREP_PROC_INFO */
if (WSREP_CB_SUCCESS != rcode)
@@ -294,10 +294,10 @@ static wsrep_cb_status_t wsrep_commit(THD* const thd)
{
#ifdef WSREP_PROC_INFO
snprintf(thd->wsrep_info, sizeof(thd->wsrep_info) - 1,
- "committing %lld", (long long)wsrep_thd_trx_seqno(thd));
+ "Committing %lld", (long long)wsrep_thd_trx_seqno(thd));
thd_proc_info(thd, thd->wsrep_info);
#else
- thd_proc_info(thd, "committing");
+ thd_proc_info(thd, "Committing");
#endif /* WSREP_PROC_INFO */
wsrep_cb_status_t const rcode(trans_commit(thd) ?
@@ -318,10 +318,10 @@ static wsrep_cb_status_t wsrep_commit(THD* const thd)
#ifdef WSREP_PROC_INFO
snprintf(thd->wsrep_info, sizeof(thd->wsrep_info) - 1,
- "committed %lld", (long long) wsrep_thd_trx_seqno(thd));
+ "Committed %lld", (long long) wsrep_thd_trx_seqno(thd));
thd_proc_info(thd, thd->wsrep_info);
#else
- thd_proc_info(thd, "committed");
+ thd_proc_info(thd, "Committed");
#endif /* WSREP_PROC_INFO */
return rcode;
@@ -331,10 +331,10 @@ static wsrep_cb_status_t wsrep_rollback(THD* const thd)
{
#ifdef WSREP_PROC_INFO
snprintf(thd->wsrep_info, sizeof(thd->wsrep_info) - 1,
- "rolling back %lld", (long long)wsrep_thd_trx_seqno(thd));
+ "Rolling back %lld", (long long)wsrep_thd_trx_seqno(thd));
thd_proc_info(thd, thd->wsrep_info);
#else
- thd_proc_info(thd, "rolling back");
+ thd_proc_info(thd, "Rolling back");
#endif /* WSREP_PROC_INFO */
wsrep_cb_status_t const rcode(trans_rollback(thd) ?
@@ -342,10 +342,10 @@ static wsrep_cb_status_t wsrep_rollback(THD* const thd)
#ifdef WSREP_PROC_INFO
snprintf(thd->wsrep_info, sizeof(thd->wsrep_info) - 1,
- "rolled back %lld", (long long)wsrep_thd_trx_seqno(thd));
+ "Rolled back %lld", (long long)wsrep_thd_trx_seqno(thd));
thd_proc_info(thd, thd->wsrep_info);
#else
- thd_proc_info(thd, "rolled back");
+ thd_proc_info(thd, "Rolled back");
#endif /* WSREP_PROC_INFO */
return rcode;
diff --git a/sql/wsrep_hton.cc b/sql/wsrep_hton.cc
index e0d46159697..50ecacd9960 100644
--- a/sql/wsrep_hton.cc
+++ b/sql/wsrep_hton.cc
@@ -384,7 +384,7 @@ wsrep_run_wsrep_commit(THD *thd, bool all)
mysql_mutex_unlock(&thd->LOCK_wsrep_thd);
mysql_mutex_lock(&thd->mysys_var->mutex);
- thd_proc_info(thd, "wsrep waiting on replaying");
+ thd_proc_info(thd, "WSREP waiting on replaying");
thd->mysys_var->current_mutex= &LOCK_wsrep_replaying;
thd->mysys_var->current_cond= &COND_wsrep_replaying;
mysql_mutex_unlock(&thd->mysys_var->mutex);
diff --git a/sql/wsrep_mysqld.cc b/sql/wsrep_mysqld.cc
index 63d153a7af4..fd759717aaf 100644
--- a/sql/wsrep_mysqld.cc
+++ b/sql/wsrep_mysqld.cc
@@ -527,7 +527,7 @@ static void wsrep_synced_cb(void* app_ctx)
if (wsrep_restart_slave_activated)
{
int rcode;
- WSREP_INFO("MySQL slave restart");
+ WSREP_INFO("MariaDB slave restart");
wsrep_restart_slave_activated= FALSE;
mysql_mutex_lock(&LOCK_active_mi);
diff --git a/sql/wsrep_thd.cc b/sql/wsrep_thd.cc
index 04ecf0fcb59..32b812a9bb2 100644
--- a/sql/wsrep_thd.cc
+++ b/sql/wsrep_thd.cc
@@ -252,7 +252,7 @@ void wsrep_replay_transaction(THD *thd)
MYSQL_END_STATEMENT(thd->m_statement_psi, thd->get_stmt_da());
thd->m_statement_psi= NULL;
thd->m_digest= NULL;
- thd_proc_info(thd, "wsrep replaying trx");
+ thd_proc_info(thd, "WSREP replaying trx");
WSREP_DEBUG("replay trx: %s %lld",
thd->query() ? thd->query() : "void",
(long long)wsrep_thd_trx_seqno(thd));
@@ -463,7 +463,7 @@ static void wsrep_rollback_process(THD *thd)
wsrep_aborting_thd= NULL;
while (thd->killed == NOT_KILLED) {
- thd_proc_info(thd, "wsrep aborter idle");
+ thd_proc_info(thd, "WSREP aborter idle");
thd->mysys_var->current_mutex= &LOCK_wsrep_rollback;
thd->mysys_var->current_cond= &COND_wsrep_rollback;
@@ -472,7 +472,7 @@ static void wsrep_rollback_process(THD *thd)
WSREP_DEBUG("WSREP rollback thread wakes for signal");
mysql_mutex_lock(&thd->mysys_var->mutex);
- thd_proc_info(thd, "wsrep aborter active");
+ thd_proc_info(thd, "WSREP aborter active");
thd->mysys_var->current_mutex= 0;
thd->mysys_var->current_cond= 0;
mysql_mutex_unlock(&thd->mysys_var->mutex);