summaryrefslogtreecommitdiff
path: root/sql
diff options
context:
space:
mode:
authorMarko Mäkelä <marko.makela@mariadb.com>2017-06-08 12:45:08 +0300
committerMarko Mäkelä <marko.makela@mariadb.com>2017-06-08 12:45:08 +0300
commit2d8fdfbde5d5d32df64bacfaa7574ecf83b0bc03 (patch)
treecea7cfc27b7f5c3c9d116a82330fef01350b08f4 /sql
parentc4cbc7a8807250d2d5b5938b218fd9c423a0b30a (diff)
parentfbeb9489cd7d6ad859a49ae5ab8f876f3d988470 (diff)
downloadmariadb-git-2d8fdfbde5d5d32df64bacfaa7574ecf83b0bc03.tar.gz
Merge 10.1 into 10.2
Replace have_innodb_zip.inc with innodb_page_size_small.inc.
Diffstat (limited to 'sql')
-rw-r--r--sql/handler.cc14
-rw-r--r--sql/item_cmpfunc.cc8
-rw-r--r--sql/item_cmpfunc.h7
-rw-r--r--sql/item_func.h29
-rw-r--r--sql/item_strfunc.cc4
-rw-r--r--sql/log_event.cc1
-rw-r--r--sql/rpl_mi.cc51
-rw-r--r--sql/rpl_mi.h2
-rw-r--r--sql/sql_reload.cc8
-rw-r--r--sql/sql_select.cc3
-rw-r--r--sql/table.cc39
11 files changed, 145 insertions, 21 deletions
diff --git a/sql/handler.cc b/sql/handler.cc
index 1537f003d99..919fd74191e 100644
--- a/sql/handler.cc
+++ b/sql/handler.cc
@@ -5668,6 +5668,20 @@ bool handler::check_table_binlog_row_based_internal(bool binlog_row)
table->file->partition_ht()->db_type != DB_TYPE_INNODB) ||
(thd->wsrep_ignore_table == true)))
return 0;
+
+ /* enforce wsrep_max_ws_rows */
+ if (WSREP(thd) && table->s->tmp_table == NO_TMP_TABLE)
+ {
+ thd->wsrep_affected_rows++;
+ if (wsrep_max_ws_rows &&
+ thd->wsrep_exec_mode != REPL_RECV &&
+ thd->wsrep_affected_rows > wsrep_max_ws_rows)
+ {
+ trans_rollback_stmt(thd) || trans_rollback(thd);
+ my_message(ER_ERROR_DURING_COMMIT, "wsrep_max_ws_rows exceeded", MYF(0));
+ return ER_ERROR_DURING_COMMIT;
+ }
+ }
#endif
return (table->s->cached_row_logging_check &&
diff --git a/sql/item_cmpfunc.cc b/sql/item_cmpfunc.cc
index a923befb8bc..f4fae535670 100644
--- a/sql/item_cmpfunc.cc
+++ b/sql/item_cmpfunc.cc
@@ -5566,7 +5566,7 @@ int Regexp_processor_pcre::pcre_exec_with_warn(const pcre *code,
bool Regexp_processor_pcre::exec(const char *str, int length, int offset)
{
m_pcre_exec_rc= pcre_exec_with_warn(m_pcre, &m_pcre_extra, str, length, offset, 0,
- m_SubStrVec, m_subpatterns_needed * 3);
+ m_SubStrVec, array_elements(m_SubStrVec));
return false;
}
@@ -5579,7 +5579,7 @@ bool Regexp_processor_pcre::exec(String *str, int offset,
m_pcre_exec_rc= pcre_exec_with_warn(m_pcre, &m_pcre_extra,
str->c_ptr_safe(), str->length(),
offset, 0,
- m_SubStrVec, m_subpatterns_needed * 3);
+ m_SubStrVec, array_elements(m_SubStrVec));
if (m_pcre_exec_rc > 0)
{
uint i;
@@ -5637,7 +5637,7 @@ Item_func_regex::fix_length_and_dec()
if (agg_arg_charsets_for_comparison(cmp_collation, args, 2))
return;
- re.init(cmp_collation.collation, 0, 0);
+ re.init(cmp_collation.collation, 0);
re.fix_owner(this, args[0], args[1]);
}
@@ -5661,7 +5661,7 @@ Item_func_regexp_instr::fix_length_and_dec()
if (agg_arg_charsets_for_comparison(cmp_collation, args, 2))
return;
- re.init(cmp_collation.collation, 0, 1);
+ re.init(cmp_collation.collation, 0);
re.fix_owner(this, args[0], args[1]);
}
diff --git a/sql/item_cmpfunc.h b/sql/item_cmpfunc.h
index 12eb5cbff6d..18ce611d306 100644
--- a/sql/item_cmpfunc.h
+++ b/sql/item_cmpfunc.h
@@ -2020,7 +2020,6 @@ class Regexp_processor_pcre
String m_prev_pattern;
int m_pcre_exec_rc;
int m_SubStrVec[30];
- uint m_subpatterns_needed;
void pcre_exec_warn(int rc) const;
int pcre_exec_with_warn(const pcre *code, const pcre_extra *extra,
const char *subject, int length, int startoffset,
@@ -2034,15 +2033,14 @@ public:
m_pcre(NULL), m_conversion_is_needed(true), m_is_const(0),
m_library_flags(0),
m_data_charset(&my_charset_utf8_general_ci),
- m_library_charset(&my_charset_utf8_general_ci),
- m_subpatterns_needed(0)
+ m_library_charset(&my_charset_utf8_general_ci)
{
m_pcre_extra.flags= PCRE_EXTRA_MATCH_LIMIT_RECURSION;
m_pcre_extra.match_limit_recursion= 100L;
}
int default_regex_flags();
void set_recursion_limit(THD *);
- void init(CHARSET_INFO *data_charset, int extra_flags, uint nsubpatterns_arg)
+ void init(CHARSET_INFO *data_charset, int extra_flags)
{
m_library_flags= default_regex_flags() | extra_flags |
(data_charset != &my_charset_bin ?
@@ -2056,7 +2054,6 @@ public:
m_conversion_is_needed= (data_charset != &my_charset_bin) &&
!my_charset_same(data_charset, m_library_charset);
- m_subpatterns_needed= nsubpatterns_arg;
}
void fix_owner(Item_func *owner, Item *subject_arg, Item *pattern_arg);
bool compile(String *pattern, bool send_error);
diff --git a/sql/item_func.h b/sql/item_func.h
index 7ee4b67b097..0919685bbf3 100644
--- a/sql/item_func.h
+++ b/sql/item_func.h
@@ -1270,7 +1270,11 @@ public:
longlong val_int();
const char *func_name() const { return "coercibility"; }
void fix_length_and_dec() { max_length=10; maybe_null= 0; }
- table_map not_null_tables() const { return 0; }
+ bool eval_not_null_tables(void *)
+ {
+ not_null_tables_cache= 0;
+ return false;
+ }
Item* propagate_equal_fields(THD *thd, const Context &ctx, COND_EQUAL *cond)
{ return this; }
bool const_item() const { return true; }
@@ -1588,7 +1592,11 @@ public:
}
void cleanup();
Item_result result_type () const { return udf.result_type(); }
- table_map not_null_tables() const { return 0; }
+ bool eval_not_null_tables(void *opt_arg)
+ {
+ not_null_tables_cache= 0;
+ return 0;
+ }
bool is_expensive() { return 1; }
virtual void print(String *str, enum_query_type query_type);
bool check_vcol_func_processor(void *arg)
@@ -2118,7 +2126,11 @@ public:
bool is_expensive_processor(void *arg) { return TRUE; }
enum Functype functype() const { return FT_FUNC; }
const char *func_name() const { return "match"; }
- table_map not_null_tables() const { return 0; }
+ bool eval_not_null_tables(void *opt_arg)
+ {
+ not_null_tables_cache= 0;
+ return 0;
+ }
bool fix_fields(THD *thd, Item **ref);
bool eq(const Item *, bool binary_cmp) const;
/* The following should be safe, even if we compare doubles */
@@ -2401,6 +2413,11 @@ public:
clone->sp_result_field= NULL;
return clone;
}
+ bool eval_not_null_tables(void *opt_arg)
+ {
+ not_null_tables_cache= 0;
+ return 0;
+ }
};
@@ -2453,7 +2470,11 @@ public:
void fix_length_and_dec();
enum Item_result result_type () const { return last_value->result_type(); }
const char *func_name() const { return "last_value"; }
- table_map not_null_tables() const { return 0; }
+ bool eval_not_null_tables(void *)
+ {
+ not_null_tables_cache= 0;
+ return 0;
+ }
enum_field_types field_type() const { return last_value->field_type(); }
bool const_item() const { return 0; }
void evaluate_sideeffects();
diff --git a/sql/item_strfunc.cc b/sql/item_strfunc.cc
index 5b38518b13d..e91cf64fd04 100644
--- a/sql/item_strfunc.cc
+++ b/sql/item_strfunc.cc
@@ -1277,7 +1277,7 @@ void Item_func_regexp_replace::fix_length_and_dec()
if (agg_arg_charsets_for_string_result_with_comparison(collation, args, 3))
return;
max_length= MAX_BLOB_WIDTH;
- re.init(collation.collation, 0, 10);
+ re.init(collation.collation, 0);
re.fix_owner(this, args[0], args[1]);
}
@@ -1412,7 +1412,7 @@ void Item_func_regexp_substr::fix_length_and_dec()
if (agg_arg_charsets_for_string_result_with_comparison(collation, args, 2))
return;
fix_char_length(args[0]->max_char_length());
- re.init(collation.collation, 0, 10);
+ re.init(collation.collation, 0);
re.fix_owner(this, args[0], args[1]);
}
diff --git a/sql/log_event.cc b/sql/log_event.cc
index 406b14cc2a9..6ff0211e536 100644
--- a/sql/log_event.cc
+++ b/sql/log_event.cc
@@ -8402,7 +8402,6 @@ int Xid_log_event::do_apply_event(rpl_group_info *rgi)
consistent.
*/
#ifdef WITH_WSREP
- /*Set wsrep_affected_rows = 0 */
thd->wsrep_affected_rows= 0;
#endif
diff --git a/sql/rpl_mi.cc b/sql/rpl_mi.cc
index 15b2907c95b..093bc5df666 100644
--- a/sql/rpl_mi.cc
+++ b/sql/rpl_mi.cc
@@ -41,7 +41,7 @@ Master_info::Master_info(LEX_STRING *connection_name_arg,
master_id(0), prev_master_id(0),
using_gtid(USE_GTID_NO), events_queued_since_last_gtid(0),
gtid_reconnect_event_skip_count(0), gtid_event_seen(false),
- in_start_all_slaves(0), in_stop_all_slaves(0),
+ in_start_all_slaves(0), in_stop_all_slaves(0), in_flush_all_relay_logs(0),
users(0), killed(0)
{
host[0] = 0; user[0] = 0; password[0] = 0;
@@ -1980,4 +1980,53 @@ void prot_store_ids(THD *thd, DYNAMIC_ARRAY *ids)
return;
}
+bool Master_info_index::flush_all_relay_logs()
+{
+ DBUG_ENTER("flush_all_relay_logs");
+ bool result= false;
+ int error= 0;
+ mysql_mutex_lock(&LOCK_active_mi);
+ for (uint i= 0; i< master_info_hash.records; i++)
+ {
+ Master_info *mi;
+ mi= (Master_info *) my_hash_element(&master_info_hash, i);
+ mi->in_flush_all_relay_logs= 0;
+ }
+ for (uint i=0; i < master_info_hash.records;)
+ {
+ Master_info *mi;
+ mi= (Master_info *)my_hash_element(&master_info_hash, i);
+ DBUG_ASSERT(mi);
+
+ if (mi->in_flush_all_relay_logs)
+ {
+ i++;
+ continue;
+ }
+ mi->in_flush_all_relay_logs= 1;
+
+ mysql_mutex_lock(&mi->sleep_lock);
+ mi->users++; // Mark used
+ mysql_mutex_unlock(&mi->sleep_lock);
+ mysql_mutex_unlock(&LOCK_active_mi);
+
+ mysql_mutex_lock(&mi->data_lock);
+ error= rotate_relay_log(mi);
+ mysql_mutex_unlock(&mi->data_lock);
+ mi->release();
+ mysql_mutex_lock(&LOCK_active_mi);
+
+ if (error)
+ {
+ result= true;
+ break;
+ }
+ /* Restart from first element as master_info_hash may have changed */
+ i= 0;
+ continue;
+ }
+ mysql_mutex_unlock(&LOCK_active_mi);
+ DBUG_RETURN(result);
+}
+
#endif /* HAVE_REPLICATION */
diff --git a/sql/rpl_mi.h b/sql/rpl_mi.h
index 31c0f280ac1..d0f6171815c 100644
--- a/sql/rpl_mi.h
+++ b/sql/rpl_mi.h
@@ -302,6 +302,7 @@ class Master_info : public Slave_reporting_capability
/* gtid_event_seen is false until we receive first GTID event from master. */
bool gtid_event_seen;
bool in_start_all_slaves, in_stop_all_slaves;
+ bool in_flush_all_relay_logs;
uint users; /* Active user for object */
uint killed;
@@ -354,6 +355,7 @@ public:
bool start_all_slaves(THD *thd);
bool stop_all_slaves(THD *thd);
void free_connections();
+ bool flush_all_relay_logs();
};
diff --git a/sql/sql_reload.cc b/sql/sql_reload.cc
index 463989b3805..313c77cc014 100644
--- a/sql/sql_reload.cc
+++ b/sql/sql_reload.cc
@@ -181,8 +181,12 @@ bool reload_acl_and_cache(THD *thd, unsigned long long options,
slave is not likely to have the same connection names.
*/
tmp_write_to_binlog= 0;
-
- if (!(mi= (get_master_info(&connection_name,
+ if (connection_name.length == 0)
+ {
+ if (master_info_index->flush_all_relay_logs())
+ *write_to_binlog= -1;
+ }
+ else if (!(mi= (get_master_info(&connection_name,
Sql_condition::WARN_LEVEL_ERROR))))
{
result= 1;
diff --git a/sql/sql_select.cc b/sql/sql_select.cc
index 7bdc99cdbc2..4c64cf29467 100644
--- a/sql/sql_select.cc
+++ b/sql/sql_select.cc
@@ -14552,7 +14552,8 @@ simplify_joins(JOIN *join, List<TABLE_LIST> *join_list, COND *conds, bool top,
table->table->maybe_null= FALSE;
table->outer_join= 0;
if (!(straight_join || table->straight))
- table->dep_tables= table->embedding? table->embedding->dep_tables: 0;
+ table->dep_tables= table->embedding && !table->embedding->sj_subq_pred ?
+ table->embedding->dep_tables : 0;
if (table->on_expr)
{
/* Add ON expression to the WHERE or upper-level ON condition. */
diff --git a/sql/table.cc b/sql/table.cc
index 398383efccd..a856799ddd5 100644
--- a/sql/table.cc
+++ b/sql/table.cc
@@ -2039,6 +2039,7 @@ int TABLE_SHARE::init_from_binary_frm_image(THD *thd, bool write,
keyinfo= share->key_info;
uint primary_key= my_strcasecmp(system_charset_info, share->keynames.type_names[0],
primary_key_name) ? MAX_KEY : 0;
+ KEY* key_first_info;
if (primary_key >= MAX_KEY && keyinfo->flags & HA_NOSAME)
{
@@ -2118,19 +2119,38 @@ int TABLE_SHARE::init_from_binary_frm_image(THD *thd, bool write,
keyinfo->name_length+1);
}
+ if (!key)
+ key_first_info= keyinfo;
+
if (ext_key_parts > share->key_parts && key)
{
KEY_PART_INFO *new_key_part= (keyinfo-1)->key_part +
(keyinfo-1)->ext_key_parts;
uint add_keyparts_for_this_key= add_first_key_parts;
+ uint length_bytes= 0, len_null_byte= 0, ext_key_length= 0;
+ Field *field;
/*
Do not extend the key that contains a component
defined over the beginning of a field.
*/
for (i= 0; i < keyinfo->user_defined_key_parts; i++)
- {
+ {
uint fieldnr= keyinfo->key_part[i].fieldnr;
+ field= share->field[keyinfo->key_part[i].fieldnr-1];
+
+ if (field->null_ptr)
+ len_null_byte= HA_KEY_NULL_LENGTH;
+
+ if (field->type() == MYSQL_TYPE_BLOB ||
+ field->real_type() == MYSQL_TYPE_VARCHAR ||
+ field->type() == MYSQL_TYPE_GEOMETRY)
+ {
+ length_bytes= HA_KEY_BLOB_LENGTH;
+ }
+
+ ext_key_length+= keyinfo->key_part[i].length + len_null_byte
+ + length_bytes;
if (share->field[fieldnr-1]->key_length() !=
keyinfo->key_part[i].length)
{
@@ -2139,6 +2159,23 @@ int TABLE_SHARE::init_from_binary_frm_image(THD *thd, bool write,
}
}
+ if (add_keyparts_for_this_key)
+ {
+ for (i= 0; i < add_keyparts_for_this_key; i++)
+ {
+ uint pk_part_length= key_first_info->key_part[i].store_length;
+ if (keyinfo->ext_key_part_map & 1<<i)
+ {
+ if (ext_key_length + pk_part_length > MAX_KEY_LENGTH)
+ {
+ add_keyparts_for_this_key= i;
+ break;
+ }
+ ext_key_length+= pk_part_length;
+ }
+ }
+ }
+
if (add_keyparts_for_this_key < (keyinfo->ext_key_parts -
keyinfo->user_defined_key_parts))
{