diff options
author | Marko Mäkelä <marko.makela@mariadb.com> | 2018-11-06 09:40:39 +0200 |
---|---|---|
committer | Marko Mäkelä <marko.makela@mariadb.com> | 2018-11-06 09:40:39 +0200 |
commit | df563e0c037f9b2cdb22e145575f92a121b4b529 (patch) | |
tree | 31d39796cebcef916eb7e0888537c18f946170ff /sql | |
parent | e058a251c10350f3727ca1df022dc5786933535b (diff) | |
parent | bdfe2784d5b73a1fdcdacb3d9adcc9dc71af344b (diff) | |
download | mariadb-git-df563e0c037f9b2cdb22e145575f92a121b4b529.tar.gz |
Merge 10.2 into 10.3
main.derived_cond_pushdown: Move all 10.3 tests to the end,
trim trailing white space, and add an "End of 10.3 tests" marker.
Add --sorted_result to tests where the ordering is not deterministic.
main.win_percentile: Add --sorted_result to tests where the
ordering is no longer deterministic.
Diffstat (limited to 'sql')
36 files changed, 187 insertions, 100 deletions
diff --git a/sql/CMakeLists.txt b/sql/CMakeLists.txt index f2c1eeb6566..d85e588abeb 100644 --- a/sql/CMakeLists.txt +++ b/sql/CMakeLists.txt @@ -317,7 +317,7 @@ DTRACE_INSTRUMENT_STATIC_LIBS(mysqld SET(WITH_MYSQLD_LDFLAGS "" CACHE STRING "Additional linker flags for mysqld") MARK_AS_ADVANCED(WITH_MYSQLD_LDFLAGS) IF(WITH_MYSQLD_LDFLAGS) - GET_TARGET_PROPERTY(mysqld LINK_FLAGS MYSQLD_LINK_FLAGS) + GET_TARGET_PROPERTY(MYSQLD_LINK_FLAGS mysqld LINK_FLAGS) IF(NOT MYSQLD_LINK_FLAGS) SET(MYSQLD_LINK_FLAGS) ENDIF() diff --git a/sql/compat56.cc b/sql/compat56.cc index 16c25924d6e..d1cb8b0042c 100644 --- a/sql/compat56.cc +++ b/sql/compat56.cc @@ -254,6 +254,9 @@ void TIME_from_longlong_datetime_packed(MYSQL_TIME *ltime, longlong tmp) { longlong ymd, hms; longlong ymdhms, ym; + + DBUG_ASSERT(tmp != LONGLONG_MIN); + if ((ltime->neg= (tmp < 0))) tmp= -tmp; diff --git a/sql/events.cc b/sql/events.cc index 5723cf2eaa4..c3a578f1097 100644 --- a/sql/events.cc +++ b/sql/events.cc @@ -419,10 +419,10 @@ Events::create_event(THD *thd, Event_parse_data *parse_data) thd->restore_stmt_binlog_format(save_binlog_format); DBUG_RETURN(ret); -#ifdef WITH_WSREP - error: + +WSREP_ERROR_LABEL: DBUG_RETURN(TRUE); -#endif /* WITH_WSREP */ + } @@ -550,10 +550,9 @@ Events::update_event(THD *thd, Event_parse_data *parse_data, thd->restore_stmt_binlog_format(save_binlog_format); DBUG_RETURN(ret); -#ifdef WITH_WSREP -error: + +WSREP_ERROR_LABEL: DBUG_RETURN(TRUE); -#endif /* WITH_WSREP */ } @@ -618,10 +617,9 @@ Events::drop_event(THD *thd, const LEX_CSTRING *dbname, thd->restore_stmt_binlog_format(save_binlog_format); DBUG_RETURN(ret); -#ifdef WITH_WSREP -error: + +WSREP_ERROR_LABEL: DBUG_RETURN(TRUE); -#endif /* WITH_WSREP */ } diff --git a/sql/field_conv.cc b/sql/field_conv.cc index 64d0bc6c452..dddb2182051 100644 --- a/sql/field_conv.cc +++ b/sql/field_conv.cc @@ -1,5 +1,5 @@ /* Copyright (c) 2000, 2016, Oracle and/or its affiliates. - Copyright (c) 2010, 2016, MariaDB + Copyright (c) 2010, 2018, MariaDB Corporation This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/sql/ha_partition.cc b/sql/ha_partition.cc index 40380ffeec5..c985ada64e6 100644 --- a/sql/ha_partition.cc +++ b/sql/ha_partition.cc @@ -4034,9 +4034,14 @@ THR_LOCK_DATA **ha_partition::store_lock(THD *thd, } else { - for (i= bitmap_get_first_set(&(m_part_info->lock_partitions)); + MY_BITMAP *used_partitions= lock_type == TL_UNLOCK || + lock_type == TL_IGNORE ? + &m_locked_partitions : + &m_part_info->lock_partitions; + + for (i= bitmap_get_first_set(used_partitions); i < m_tot_parts; - i= bitmap_get_next_set(&m_part_info->lock_partitions, i)) + i= bitmap_get_next_set(used_partitions, i)) { DBUG_PRINT("info", ("store lock %u iteration", i)); to= m_file[i]->store_lock(thd, to, lock_type); diff --git a/sql/ha_partition.h b/sql/ha_partition.h index 82877806243..202f27840dc 100644 --- a/sql/ha_partition.h +++ b/sql/ha_partition.h @@ -349,7 +349,6 @@ private: /* Variables for lock structures. */ - THR_LOCK_DATA lock; /* MySQL lock */ bool auto_increment_lock; /**< lock reading/updating auto_inc */ /** diff --git a/sql/item_cmpfunc.cc b/sql/item_cmpfunc.cc index 92f1391c9f8..ccbae1bad34 100644 --- a/sql/item_cmpfunc.cc +++ b/sql/item_cmpfunc.cc @@ -4272,12 +4272,21 @@ bool Item_func_in::value_list_convert_const_to_int(THD *thd) if (field_item->field_type() == MYSQL_TYPE_LONGLONG || field_item->field_type() == MYSQL_TYPE_YEAR) { - bool all_converted= TRUE; + bool all_converted= true; Item **arg, **arg_end; for (arg=args+1, arg_end=args+arg_count; arg != arg_end ; arg++) { - if (!convert_const_to_int(thd, field_item, &arg[0])) - all_converted= FALSE; + /* + Explicit NULLs should not affect data cmp_type resolution: + - we ignore NULLs when calling collect_cmp_type() + - we ignore NULLs here + So this expression: + year_column IN (DATE'2001-01-01', NULL) + switches from TIME_RESULT to INT_RESULT. + */ + if (arg[0]->type() != Item::NULL_ITEM && + !convert_const_to_int(thd, field_item, &arg[0])) + all_converted= false; } if (all_converted) m_comparator.set_handler(&type_handler_longlong); diff --git a/sql/lock.cc b/sql/lock.cc index 17629f17291..5420e9f42b5 100644 --- a/sql/lock.cc +++ b/sql/lock.cc @@ -596,22 +596,6 @@ void mysql_lock_remove(THD *thd, MYSQL_LOCK *locked,TABLE *table) } -/** Abort all other threads waiting to get lock in table. */ - -void mysql_lock_abort(THD *thd, TABLE *table, bool upgrade_lock) -{ - MYSQL_LOCK *locked; - DBUG_ENTER("mysql_lock_abort"); - - if ((locked= get_lock_data(thd, &table, 1, GET_LOCK_UNLOCK | GET_LOCK_ON_THD))) - { - for (uint i=0; i < locked->lock_count; i++) - thr_abort_locks(locked->locks[i]->lock, upgrade_lock); - } - DBUG_VOID_RETURN; -} - - /** Abort one thread / table combination. diff --git a/sql/lock.h b/sql/lock.h index 35cb3043d57..e9324c80d89 100644 --- a/sql/lock.h +++ b/sql/lock.h @@ -33,7 +33,6 @@ void mysql_unlock_tables(THD *thd, MYSQL_LOCK *sql_lock); void mysql_unlock_read_tables(THD *thd, MYSQL_LOCK *sql_lock); void mysql_unlock_some_tables(THD *thd, TABLE **table,uint count, uint flag); void mysql_lock_remove(THD *thd, MYSQL_LOCK *locked,TABLE *table); -void mysql_lock_abort(THD *thd, TABLE *table, bool upgrade_lock); bool mysql_lock_abort_for_thread(THD *thd, TABLE *table); MYSQL_LOCK *mysql_lock_merge(MYSQL_LOCK *a,MYSQL_LOCK *b); /* Lock based on name */ diff --git a/sql/log_event.cc b/sql/log_event.cc index 8813d20578e..72db2717680 100644 --- a/sql/log_event.cc +++ b/sql/log_event.cc @@ -264,6 +264,27 @@ static void inline slave_rows_error_report(enum loglevel level, int ha_error, } #endif +#if defined(HAVE_REPLICATION) && !defined(MYSQL_CLIENT) +static void set_thd_db(THD *thd, Rpl_filter *rpl_filter, + const char *db, uint32 db_len) +{ + char lcase_db_buf[NAME_LEN +1]; + LEX_CSTRING new_db; + new_db.length= db_len; + if (lower_case_table_names == 1) + { + strmov(lcase_db_buf, db); + my_casedn_str(system_charset_info, lcase_db_buf); + new_db.str= lcase_db_buf; + } + else + new_db.str= db; + /* TODO WARNING this makes rewrite_db respect lower_case_table_names values + * for more info look MDEV-17446 */ + new_db.str= rpl_filter->get_rewrite_db(new_db.str, &new_db.length); + thd->set_db(&new_db); +} +#endif /* Cache that will automatically be written to a dedicated file on destruction. @@ -5376,7 +5397,6 @@ bool test_if_equal_repl_errors(int expected_error, int actual_error) int Query_log_event::do_apply_event(rpl_group_info *rgi, const char *query_arg, uint32 q_len_arg) { - LEX_CSTRING new_db; int expected_error,actual_error= 0; Schema_specification_st db_options; uint64 sub_id= 0; @@ -5408,9 +5428,7 @@ int Query_log_event::do_apply_event(rpl_group_info *rgi, goto end; } - new_db.length= db_len; - new_db.str= (char *) rpl_filter->get_rewrite_db(db, &new_db.length); - thd->set_db(&new_db); /* allocates a copy of 'db' */ + set_thd_db(thd, rpl_filter, db, db_len); /* Setting the character set and collation of the current database thd->db. @@ -7240,15 +7258,12 @@ void Load_log_event::set_fields(const char* affected_db, int Load_log_event::do_apply_event(NET* net, rpl_group_info *rgi, bool use_rli_only_for_errors) { - LEX_CSTRING new_db; Relay_log_info const *rli= rgi->rli; Rpl_filter *rpl_filter= rli->mi->rpl_filter; DBUG_ENTER("Load_log_event::do_apply_event"); - new_db.length= db_len; - new_db.str= rpl_filter->get_rewrite_db(db, &new_db.length); - thd->set_db(&new_db); DBUG_ASSERT(thd->query() == 0); + set_thd_db(thd, rpl_filter, db, db_len); thd->clear_error(1); /* see Query_log_event::do_apply_event() and BUG#13360 */ @@ -7292,6 +7307,8 @@ int Load_log_event::do_apply_event(NET* net, rpl_group_info *rgi, TABLE_LIST tables; LEX_CSTRING db_name= { thd->strmake(thd->db.str, thd->db.length), thd->db.length }; + if (lower_case_table_names) + my_casedn_str(system_charset_info, (char *)table_name); LEX_CSTRING tbl_name= { table_name, strlen(table_name) }; tables.init_one_table(&db_name, &tbl_name, 0, TL_WRITE); tables.updating= 1; @@ -12577,7 +12594,7 @@ check_table_map(rpl_group_info *rgi, RPL_TABLE_LIST *table_list) int Table_map_log_event::do_apply_event(rpl_group_info *rgi) { RPL_TABLE_LIST *table_list; - char *db_mem, *tname_mem; + char *db_mem, *tname_mem, *ptr; size_t dummy_len, db_mem_length, tname_mem_length; void *memory; Rpl_filter *filter; @@ -12594,10 +12611,20 @@ int Table_map_log_event::do_apply_event(rpl_group_info *rgi) NullS))) DBUG_RETURN(HA_ERR_OUT_OF_MEM); + db_mem_length= strmov(db_mem, m_dbnam) - db_mem; + tname_mem_length= strmov(tname_mem, m_tblnam) - tname_mem; + if (lower_case_table_names) + { + my_casedn_str(files_charset_info, (char*)tname_mem); + my_casedn_str(files_charset_info, (char*)db_mem); + } + /* call from mysql_client_binlog_statement() will not set rli->mi */ filter= rgi->thd->slave_thread ? rli->mi->rpl_filter : global_rpl_filter; - db_mem_length= strmov(db_mem, filter->get_rewrite_db(m_dbnam, &dummy_len))- db_mem; - tname_mem_length= strmov(tname_mem, m_tblnam)- tname_mem; + + /* rewrite rules changed the database */ + if (((ptr= (char*) filter->get_rewrite_db(db_mem, &dummy_len)) != db_mem)) + db_mem_length= strmov(db_mem, ptr) - db_mem; LEX_CSTRING tmp_db_name= {db_mem, db_mem_length }; LEX_CSTRING tmp_tbl_name= {tname_mem, tname_mem_length }; diff --git a/sql/mysqld.cc b/sql/mysqld.cc index afef4a5f52c..6f0f517eade 100644 --- a/sql/mysqld.cc +++ b/sql/mysqld.cc @@ -1807,7 +1807,14 @@ static void close_connections(void) (ulong) tmp->thread_id, (tmp->main_security_ctx.user ? tmp->main_security_ctx.user : "")); + /* + close_connection() might need a valid current_thd + for memory allocation tracking. + */ + THD* save_thd= current_thd; + set_current_thd(tmp); close_connection(tmp,ER_SERVER_SHUTDOWN); + set_current_thd(save_thd); } #endif @@ -4472,6 +4479,11 @@ static int init_common_variables() /* MyISAM requires two file handles per table. */ wanted_files= (extra_files + max_connections + extra_max_connections + tc_size * 2); +#if defined(HAVE_POOL_OF_THREADS) && !defined(__WIN__) + // add epoll or kevent fd for each threadpool group, in case pool of threads is used + wanted_files+= (thread_handling > SCHEDULER_NO_THREADS) ? 0 : threadpool_size; +#endif + min_tc_size= MY_MIN(tc_size, TABLE_OPEN_CACHE_MIN); org_max_connections= max_connections; org_tc_size= tc_size; diff --git a/sql/opt_range.cc b/sql/opt_range.cc index 636100f9c4e..94cfae2664a 100644 --- a/sql/opt_range.cc +++ b/sql/opt_range.cc @@ -3136,6 +3136,12 @@ bool calculate_cond_selectivity_for_table(THD *thd, TABLE *table, Item **cond) } + if (quick && (quick->get_type() == QUICK_SELECT_I::QS_TYPE_ROR_UNION || + quick->get_type() == QUICK_SELECT_I::QS_TYPE_INDEX_MERGE)) + { + table->cond_selectivity*= (quick->records/table_records); + } + bitmap_union(used_fields, &handled_columns); /* Check if we can improve selectivity estimates by using sampling */ diff --git a/sql/rpl_gtid.cc b/sql/rpl_gtid.cc index fabd09adaa7..322b84130f2 100644 --- a/sql/rpl_gtid.cc +++ b/sql/rpl_gtid.cc @@ -2054,10 +2054,10 @@ rpl_binlog_state::drop_domain(DYNAMIC_ARRAY *ids, for (ulong i= 0; i < ids->elements; i++) { rpl_binlog_state::element *elem= NULL; - ulong *ptr_domain_id; + uint32 *ptr_domain_id; bool not_match; - ptr_domain_id= (ulong*) dynamic_array_ptr(ids, i); + ptr_domain_id= (uint32*) dynamic_array_ptr(ids, i); elem= (rpl_binlog_state::element *) my_hash_search(&hash, (const uchar *) ptr_domain_id, 0); if (!elem) @@ -2078,7 +2078,7 @@ rpl_binlog_state::drop_domain(DYNAMIC_ARRAY *ids, if (not_match) { - sprintf(errbuf, "binlog files may contain gtids from the domain ('%lu') " + sprintf(errbuf, "binlog files may contain gtids from the domain ('%u') " "being deleted. Make sure to first purge those files", *ptr_domain_id); errmsg= errbuf; diff --git a/sql/sql_acl.cc b/sql/sql_acl.cc index bf18581de4f..3727bf7d7ce 100644 --- a/sql/sql_acl.cc +++ b/sql/sql_acl.cc @@ -1956,7 +1956,9 @@ static bool acl_load(THD *thd, const Grant_tables& tables) user_table.authentication_string())); user.auth_string.length= strlen(user.auth_string.str); - if (user.auth_string.length && password_len) + if (user.auth_string.length && password_len && + (user.auth_string.length != password_len || + memcmp(user.auth_string.str, password, password_len))) { sql_print_warning("'user' entry '%s@%s' has both a password " "and an authentication plugin specified. The " @@ -3333,7 +3335,7 @@ end: close_mysql_tables(thd); #ifdef WITH_WSREP -error: // this label is used in WSREP_TO_ISOLATION_BEGIN +WSREP_ERROR_LABEL: if (WSREP(thd) && !thd->wsrep_applier) { WSREP_TO_ISOLATION_END; @@ -3496,7 +3498,7 @@ int acl_set_default_role(THD *thd, const char *host, const char *user, } #ifdef WITH_WSREP -error: // this label is used in WSREP_TO_ISOLATION_END +WSREP_ERROR_LABEL: if (WSREP(thd) && !thd->wsrep_applier) { WSREP_TO_ISOLATION_END; @@ -3829,7 +3831,6 @@ static bool update_user_table(THD *thd, const User_table& user_table, { set_authentication_plugin_from_password(user_table, new_password, new_password_len); - new_password_len= 0; } if (user_table.password()) diff --git a/sql/sql_admin.cc b/sql/sql_admin.cc index 21bb086f013..c17567e6a89 100644 --- a/sql/sql_admin.cc +++ b/sql/sql_admin.cc @@ -1325,6 +1325,7 @@ bool Sql_cmd_analyze_table::execute(THD *thd) m_lex->query_tables= first_table; error: +WSREP_ERROR_LABEL: DBUG_RETURN(res); } @@ -1382,6 +1383,7 @@ bool Sql_cmd_optimize_table::execute(THD *thd) m_lex->query_tables= first_table; error: +WSREP_ERROR_LABEL: DBUG_RETURN(res); } @@ -1417,5 +1419,6 @@ bool Sql_cmd_repair_table::execute(THD *thd) m_lex->query_tables= first_table; error: +WSREP_ERROR_LABEL: DBUG_RETURN(res); } diff --git a/sql/sql_alter.cc b/sql/sql_alter.cc index d2893b5fbff..5fc9ff8209c 100644 --- a/sql/sql_alter.cc +++ b/sql/sql_alter.cc @@ -498,13 +498,9 @@ bool Sql_cmd_alter_table::execute(THD *thd) DBUG_RETURN(result); -#ifdef WITH_WSREP -error: /* Used by WSREP_TO_ISOLATION_BEGIN_ALTER */ -#endif - { - WSREP_WARN("ALTER TABLE isolation failure"); - DBUG_RETURN(TRUE); - } +WSREP_ERROR_LABEL: + WSREP_WARN("ALTER TABLE isolation failure"); + DBUG_RETURN(TRUE); } bool Sql_cmd_discard_import_tablespace::execute(THD *thd) diff --git a/sql/sql_alter.h b/sql/sql_alter.h index 108b98afdd7..14242015bd2 100644 --- a/sql/sql_alter.h +++ b/sql/sql_alter.h @@ -83,7 +83,7 @@ public: // Columns and keys to be dropped. List<Alter_drop> drop_list; - // Columns for ALTER_COLUMN_CHANGE_DEFAULT. + // Columns for ALTER_CHANGE_COLUMN_DEFAULT. List<Alter_column> alter_list; // List of keys, used by both CREATE and ALTER TABLE. List<Key> key_list; diff --git a/sql/sql_base.cc b/sql/sql_base.cc index d9e68d919ef..52259e4b9e2 100644 --- a/sql/sql_base.cc +++ b/sql/sql_base.cc @@ -4295,6 +4295,7 @@ restart: } error: +WSREP_ERROR_LABEL: THD_STAGE_INFO(thd, stage_after_opening_tables); thd_proc_info(thd, 0); diff --git a/sql/sql_class.cc b/sql/sql_class.cc index eaf4e4c3019..e4f3171bd14 100644 --- a/sql/sql_class.cc +++ b/sql/sql_class.cc @@ -4789,6 +4789,14 @@ extern "C" int thd_slave_thread(const MYSQL_THD thd) return(thd->slave_thread); } + +extern "C" int thd_rpl_stmt_based(const MYSQL_THD thd) +{ + return !thd->is_current_stmt_binlog_format_row() && + !thd->is_current_stmt_binlog_disabled(); +} + + /* Returns high resolution timestamp for the start of the current query. */ extern "C" unsigned long long thd_start_utime(const MYSQL_THD thd) diff --git a/sql/sql_get_diagnostics.cc b/sql/sql_get_diagnostics.cc index 1b64819732c..b7da889340f 100644 --- a/sql/sql_get_diagnostics.cc +++ b/sql/sql_get_diagnostics.cc @@ -11,7 +11,7 @@ You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02111-1307 USA */ + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02111-1301 USA */ #include "mariadb.h" #include "sql_list.h" // Sql_alloc, List, List_iterator diff --git a/sql/sql_get_diagnostics.h b/sql/sql_get_diagnostics.h index f34820757f5..6f1652bb146 100644 --- a/sql/sql_get_diagnostics.h +++ b/sql/sql_get_diagnostics.h @@ -11,7 +11,7 @@ You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02111-1307 USA */ + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02111-1301 USA */ #ifndef SQL_GET_DIAGNOSTICS_H #define SQL_GET_DIAGNOSTICS_H diff --git a/sql/sql_insert.cc b/sql/sql_insert.cc index 52a465f7613..6e2fa5767f5 100644 --- a/sql/sql_insert.cc +++ b/sql/sql_insert.cc @@ -2516,7 +2516,8 @@ TABLE *Delayed_insert::get_local_table(THD* client_thd) The thread could be killed with an error message if di->handle_inserts() or di->open_and_lock_table() fails. The thread could be killed without an error message if - killed using kill_delayed_threads_for_table(). + killed using THD::notify_shared_lock() or + kill_delayed_threads_for_table(). */ if (!thd.is_error()) my_message(ER_QUERY_INTERRUPTED, ER_THD(&thd, ER_QUERY_INTERRUPTED), diff --git a/sql/sql_lex.cc b/sql/sql_lex.cc index 6f60b479153..11bb50a4231 100644 --- a/sql/sql_lex.cc +++ b/sql/sql_lex.cc @@ -3100,7 +3100,7 @@ LEX::LEX() INITIAL_LEX_PLUGIN_LIST_SIZE, 0); reset_query_tables_list(TRUE); mi.init(); - init_dynamic_array2(&delete_gtid_domain, sizeof(ulong*), + init_dynamic_array2(&delete_gtid_domain, sizeof(uint32), gtid_domain_static_buffer, initial_gtid_domain_buffer_size, initial_gtid_domain_buffer_size, 0); diff --git a/sql/sql_lex.h b/sql/sql_lex.h index 61063d06349..48363fdd670 100644 --- a/sql/sql_lex.h +++ b/sql/sql_lex.h @@ -3133,7 +3133,7 @@ public: */ DYNAMIC_ARRAY delete_gtid_domain; static const ulong initial_gtid_domain_buffer_size= 16; - ulong gtid_domain_static_buffer[initial_gtid_domain_buffer_size]; + uint32 gtid_domain_static_buffer[initial_gtid_domain_buffer_size]; inline void set_limit_rows_examined() { diff --git a/sql/sql_parse.cc b/sql/sql_parse.cc index fa350379ee8..d6473d58821 100644 --- a/sql/sql_parse.cc +++ b/sql/sql_parse.cc @@ -3077,9 +3077,7 @@ static int mysql_create_routine(THD *thd, LEX *lex) #endif return false; } -#ifdef WITH_WSREP -error: /* Used by WSREP_TO_ISOLATION_BEGIN */ -#endif +WSREP_ERROR_LABEL: return true; } @@ -6298,6 +6296,7 @@ end_with_restore_list: goto finish; error: +WSREP_ERROR_LABEL: res= TRUE; finish: diff --git a/sql/sql_partition_admin.cc b/sql/sql_partition_admin.cc index 99fe09d5afe..2d3c640b758 100644 --- a/sql/sql_partition_admin.cc +++ b/sql/sql_partition_admin.cc @@ -1,6 +1,6 @@ /* Copyright (c) 2010, 2013, Oracle and/or its affiliates. All rights reserved. Copyright (c) 2014, SkySQL Ab. - Copyright (c) 2016, MariaDB Corporation + Copyright (c) 2016, 2018, MariaDB Corporation. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -99,7 +99,7 @@ bool Sql_cmd_alter_table_exchange_partition::execute(THD *thd) thd->prepare_logs_for_admin_command(); DBUG_RETURN(exchange_partition(thd, first_table, &alter_info)); #ifdef WITH_WSREP - error: + wsrep_error_label: /* handle errors in TO_ISOLATION here */ DBUG_RETURN(true); #endif /* WITH_WSREP */ diff --git a/sql/sql_plugin.cc b/sql/sql_plugin.cc index 8c231d9b8f7..b2ceb1627a1 100644 --- a/sql/sql_plugin.cc +++ b/sql/sql_plugin.cc @@ -2221,10 +2221,9 @@ err: if (argv) free_defaults(argv); DBUG_RETURN(error); -#ifdef WITH_WSREP -error: + +WSREP_ERROR_LABEL: DBUG_RETURN(TRUE); -#endif /* WITH_WSREP */ } @@ -2367,10 +2366,9 @@ bool mysql_uninstall_plugin(THD *thd, const LEX_CSTRING *name, mysql_mutex_unlock(&LOCK_plugin); DBUG_RETURN(error); -#ifdef WITH_WSREP -error: + +WSREP_ERROR_LABEL: DBUG_RETURN(TRUE); -#endif /* WITH_WSREP */ } diff --git a/sql/sql_select.cc b/sql/sql_select.cc index a99b991af96..f1230666026 100644 --- a/sql/sql_select.cc +++ b/sql/sql_select.cc @@ -23247,7 +23247,8 @@ setup_group(THD *thd, Ref_ptr_array ref_pointer_array, TABLE_LIST *tables, return 1; } } - if (thd->variables.sql_mode & MODE_ONLY_FULL_GROUP_BY) + if (thd->variables.sql_mode & MODE_ONLY_FULL_GROUP_BY && + context_analysis_place == IN_GROUP_BY) { /* Don't allow one to use fields that is not used in GROUP BY @@ -27369,9 +27370,10 @@ AGGR_OP::end_send() // Update ref array join_tab->join->set_items_ref_array(*join_tab->ref_array); + bool keep_last_filesort_result = join_tab->filesort ? false : true; if (join_tab->window_funcs_step) { - if (join_tab->window_funcs_step->exec(join)) + if (join_tab->window_funcs_step->exec(join, keep_last_filesort_result)) return NESTED_LOOP_ERROR; } @@ -27425,6 +27427,12 @@ AGGR_OP::end_send() } } + if (keep_last_filesort_result) + { + delete join_tab->filesort_result; + join_tab->filesort_result= NULL; + } + // Finish rnd scn after sending records if (join_tab->table->file->inited) join_tab->table->file->ha_rnd_end(); diff --git a/sql/sql_trigger.cc b/sql/sql_trigger.cc index 60eff5ebc88..dde93dc6ed6 100644 --- a/sql/sql_trigger.cc +++ b/sql/sql_trigger.cc @@ -622,10 +622,9 @@ end: my_ok(thd); DBUG_RETURN(result); -#ifdef WITH_WSREP - error: + +WSREP_ERROR_LABEL: DBUG_RETURN(true); -#endif /* WITH_WSREP */ } diff --git a/sql/sql_view.cc b/sql/sql_view.cc index f262daad89d..07230b2205b 100644 --- a/sql/sql_view.cc +++ b/sql/sql_view.cc @@ -711,10 +711,10 @@ bool mysql_create_view(THD *thd, TABLE_LIST *views, lex->link_first_table_back(view, link_to_local); DBUG_RETURN(0); -#ifdef WITH_WSREP - error: + +WSREP_ERROR_LABEL: res= TRUE; -#endif /* WITH_WSREP */ + err: lex->link_first_table_back(view, link_to_local); unit->cleanup(); @@ -1559,9 +1559,8 @@ bool mysql_make_view(THD *thd, TABLE_SHARE *share, TABLE_LIST *table, { /* We have to keep the lock type for sequence tables */ if (!tbl->sequence) - tbl->lock_type= table->lock_type; - tbl->mdl_request.set_type((tbl->lock_type >= TL_WRITE_ALLOW_WRITE) ? - MDL_SHARED_WRITE : MDL_SHARED_READ); + tbl->lock_type= table->lock_type; + tbl->mdl_request.set_type(table->mdl_request.type); } /* If the view is mergeable, we might want to diff --git a/sql/sql_window.cc b/sql/sql_window.cc index e4d69f2fa5e..dcc6a7bac1c 100644 --- a/sql/sql_window.cc +++ b/sql/sql_window.cc @@ -2941,7 +2941,7 @@ bool Window_func_runner::exec(THD *thd, TABLE *tbl, SORT_INFO *filesort_result) } -bool Window_funcs_sort::exec(JOIN *join) +bool Window_funcs_sort::exec(JOIN *join, bool keep_filesort_result) { THD *thd= join->thd; JOIN_TAB *join_tab= join->join_tab + join->total_join_tab_cnt(); @@ -2956,8 +2956,11 @@ bool Window_funcs_sort::exec(JOIN *join) bool is_error= runner.exec(thd, tbl, filesort_result); - delete join_tab->filesort_result; - join_tab->filesort_result= NULL; + if (!keep_filesort_result) + { + delete join_tab->filesort_result; + join_tab->filesort_result= NULL; + } return is_error; } @@ -3066,14 +3069,18 @@ bool Window_funcs_computation::setup(THD *thd, } -bool Window_funcs_computation::exec(JOIN *join) +bool Window_funcs_computation::exec(JOIN *join, bool keep_last_filesort_result) { List_iterator<Window_funcs_sort> it(win_func_sorts); Window_funcs_sort *srt; + uint counter= 0; /* Count how many sorts we've executed. */ /* Execute each sort */ while ((srt = it++)) { - if (srt->exec(join)) + counter++; + bool keep_filesort_result= keep_last_filesort_result && + counter == win_func_sorts.elements; + if (srt->exec(join, keep_filesort_result)) return true; } return false; diff --git a/sql/sql_window.h b/sql/sql_window.h index bf59f00d764..21f2c8af108 100644 --- a/sql/sql_window.h +++ b/sql/sql_window.h @@ -213,7 +213,7 @@ class Window_funcs_sort : public Sql_alloc public: bool setup(THD *thd, SQL_SELECT *sel, List_iterator<Item_window_func> &it, st_join_table *join_tab); - bool exec(JOIN *join); + bool exec(JOIN *join, bool keep_filesort_result); void cleanup() { delete filesort; } friend class Window_funcs_computation; @@ -243,7 +243,7 @@ class Window_funcs_computation : public Sql_alloc List<Window_funcs_sort> win_func_sorts; public: bool setup(THD *thd, List<Item_window_func> *window_funcs, st_join_table *tab); - bool exec(JOIN *join); + bool exec(JOIN *join, bool keep_last_filesort_result); Explain_aggr_window_funcs *save_explain_plan(MEM_ROOT *mem_root, bool is_analyze); void cleanup(); diff --git a/sql/sql_yacc.yy b/sql/sql_yacc.yy index caa070090b6..f47bcfb5022 100644 --- a/sql/sql_yacc.yy +++ b/sql/sql_yacc.yy @@ -14378,9 +14378,18 @@ delete_domain_id_list: ; delete_domain_id: - ulong_num + ulonglong_num { - insert_dynamic(&Lex->delete_gtid_domain, (uchar*) &($1)); + uint32 value= (uint32) $1; + if ($1 > UINT_MAX32) + { + my_printf_error(ER_BINLOG_CANT_DELETE_GTID_DOMAIN, + "The value of gtid domain being deleted ('%llu') " + "exceeds its maximum size " + "of 32 bit unsigned integer", MYF(0), $1); + MYSQL_YYABORT; + } + insert_dynamic(&Lex->delete_gtid_domain, (uchar*) &value); } ; diff --git a/sql/table.cc b/sql/table.cc index 54261c76ddc..ccb580badf3 100644 --- a/sql/table.cc +++ b/sql/table.cc @@ -3129,6 +3129,7 @@ enum open_frm_error open_table_from_share(THD *thd, TABLE_SHARE *share, uchar *record, *bitmaps; Field **field_ptr; uint8 save_context_analysis_only= thd->lex->context_analysis_only; + TABLE_SHARE::enum_v_keys check_set_initialized= share->check_set_initialized; DBUG_ENTER("open_table_from_share"); DBUG_PRINT("enter",("name: '%s.%s' form: %p", share->db.str, share->table_name.str, outparam)); @@ -3248,6 +3249,8 @@ enum open_frm_error open_table_from_share(THD *thd, TABLE_SHARE *share, } (*field_ptr)= 0; // End marker + DEBUG_SYNC(thd, "TABLE_after_field_clone"); + outparam->vers_write= share->versioned; if (share->found_next_number_field) @@ -3507,6 +3510,16 @@ partititon_err: } outparam->mark_columns_used_by_virtual_fields(); + if (!check_set_initialized && + share->check_set_initialized == TABLE_SHARE::V_KEYS) + { + // copy PART_INDIRECT_KEY_FLAG that was set meanwhile by *some* thread + for (uint i= 0 ; i < share->fields ; i++) + { + if (share->field[i]->flags & PART_INDIRECT_KEY_FLAG) + outparam->field[i]->flags|= PART_INDIRECT_KEY_FLAG; + } + } if (db_stat) { @@ -6871,6 +6884,7 @@ void TABLE::mark_columns_used_by_virtual_fields(void) { MY_BITMAP *save_read_set; Field **vfield_ptr; + TABLE_SHARE::enum_v_keys v_keys= TABLE_SHARE::NO_V_KEYS; /* If there is virtual fields are already initialized */ if (s->check_set_initialized) @@ -6911,12 +6925,12 @@ void TABLE::mark_columns_used_by_virtual_fields(void) if (bitmap_is_set(&tmp_set, i)) { s->field[i]->flags|= PART_INDIRECT_KEY_FLAG; - field[i]->flags|= PART_INDIRECT_KEY_FLAG; + v_keys= TABLE_SHARE::V_KEYS; } } bitmap_clear_all(&tmp_set); } - s->check_set_initialized= 1; + s->check_set_initialized= v_keys; if (s->tmp_table == NO_TMP_TABLE) mysql_mutex_unlock(&s->LOCK_share); } diff --git a/sql/table.h b/sql/table.h index 9f0825573cf..7236fb91b0f 100644 --- a/sql/table.h +++ b/sql/table.h @@ -720,6 +720,9 @@ struct TABLE_SHARE uint column_bitmap_size; uchar frm_version; + enum enum_v_keys { NOT_INITIALIZED=0, NO_V_KEYS, V_KEYS }; + enum_v_keys check_set_initialized; + bool use_ext_keys; /* Extended keys can be used */ bool null_field_first; bool system; /* Set if system table (one record) */ @@ -731,7 +734,6 @@ struct TABLE_SHARE bool table_creation_was_logged; bool non_determinstic_insert; bool vcols_need_refixing; - bool check_set_initialized; bool has_update_default_function; bool can_do_row_logging; /* 1 if table supports RBR */ diff --git a/sql/wsrep_mysqld.cc b/sql/wsrep_mysqld.cc index 886119a2327..89eac6b3d00 100644 --- a/sql/wsrep_mysqld.cc +++ b/sql/wsrep_mysqld.cc @@ -2731,7 +2731,7 @@ bool wsrep_create_like_table(THD* thd, TABLE_LIST* table, return(false); -error: +WSREP_ERROR_LABEL: thd->wsrep_TOI_pre_query= NULL; return (true); } |