revision-id: 3167fedb42f63035eac1c93527da162dae454e73 (mariadb-10.2.16-52-g3167fedb42f) parent(s): fd378fc613851a12be346329d32e1666f10610d7 a0d33dc6ef6f380fb5a2d166e75ed6fed2dfce9d author: Oleksandr Byelkin committer: Oleksandr Byelkin timestamp: 2018-07-31 16:53:12 +0200 message: Merge 10.1 (part) into 10.2 client/mysqlbinlog.cc | 2 +- cmake/dtrace.cmake | 4 + cmake/package_name.cmake | 3 + extra/mariabackup/backup_copy.cc | 30 +++-- mysql-test/r/derived.result | 33 ++++++ mysql-test/r/join.result | 40 +++++++ mysql-test/r/join_cache.result | 33 ++++++ mysql-test/r/stat_tables.result | 129 +++++++++++++++++++++ mysql-test/r/stat_tables_innodb.result | 129 +++++++++++++++++++++ mysql-test/r/subselect_sj2_mat.result | 51 ++++++++ .../suite/binlog/include/check_binlog_size.inc | 31 +++++ .../suite/binlog/r/binlog_tmp_table_row.result | 7 ++ .../suite/binlog/t/binlog_tmp_table_row.test | 30 +++++ .../sys_vars/r/sysvars_server_embedded.result | 14 +++ .../sys_vars/r/sysvars_server_notembedded.result | 14 +++ mysql-test/t/derived.test | 21 ++++ mysql-test/t/join.test | 53 +++++++++ mysql-test/t/join_cache.test | 32 ++++- mysql-test/t/stat_tables.test | 112 ++++++++++++++++++ mysql-test/t/subselect_sj2_mat.test | 49 ++++++++ mysql-test/valgrind.supp | 13 +++ scripts/mysql_install_db.sh | 5 + scripts/wsrep_sst_mariabackup.sh | 32 +++-- scripts/wsrep_sst_rsync.sh | 2 + scripts/wsrep_sst_xtrabackup-v2.sh | 23 +++- sql/field.cc | 8 +- sql/log.cc | 11 +- sql/mysqld.cc | 10 +- sql/mysqld.h | 3 +- sql/opt_subselect.cc | 3 +- sql/sql_base.cc | 12 +- sql/sql_parse.cc | 26 ++++- sql/sql_select.cc | 4 +- sql/sql_statistics.cc | 33 ++++++ sql/sql_statistics.h | 1 + sql/sql_table.cc | 4 + sql/sys_vars.cc | 6 + sql/table.cc | 19 ++- sql/table_cache.cc | 2 + sql/wsrep_binlog.cc | 52 +++++++-- sql/wsrep_mysqld.cc | 26 ++++- sql/wsrep_sst.cc | 26 +++-- storage/mroonga/vendor/groonga/config.h.cmake | 1 + .../mroonga/vendor/groonga/lib/ts/ts_expr_node.c | 2 +- storage/xtradb/os/os0file.cc | 41 ++++++- 45 files changed, 1109 insertions(+), 73 deletions(-) diff --cc mysql-test/r/join_cache.result index eea397402ad,01339f7c191..fde6e0fec6b --- a/mysql-test/r/join_cache.result +++ b/mysql-test/r/join_cache.result @@@ -5925,6 -5922,39 +5925,39 @@@ SET join_buffer_space_limit= default set optimizer_switch=@save_optimizer_switch; DROP TABLE t1,t4,t5,t2; # + # MDEV-16603: BNLH for query with materialized semi-join + # + set join_cache_level=4; + CREATE TABLE t1 ( i1 int, v1 varchar(1)) ENGINE=InnoDB; + INSERT INTO t1 VALUES (7,'x'); + CREATE TABLE t2 (i1 int, v1 varchar(1), KEY v1 (v1,i1)) ENGINE=InnoDB; + INSERT INTO t2 VALUES + (NULL,'x'),(1,'x'),(3,'x'),(5,'x'),(8,'x'),(48,'x'), + (228,'x'),(3,'y'),(1,'z'),(9,'z'); + CREATE TABLE temp + SELECT t1.i1 AS f1, t1.v1 AS f2 FROM (t2 JOIN t1 ON (t1.v1 = t2.v1)); + SELECT * FROM temp + WHERE (f1,f2) IN (SELECT t1.i1, t1.v1 FROM (t2 JOIN t1 ON (t1.v1 = t2.v1))); + f1 f2 + 7 x + 7 x + 7 x + 7 x + 7 x + 7 x + 7 x + EXPLAIN EXTENDED SELECT * FROM temp + WHERE (f1,f2) IN (SELECT t1.i1, t1.v1 FROM (t2 JOIN t1 ON (t1.v1 = t2.v1))); + id select_type table type possible_keys key key_len ref rows filtered Extra + 1 PRIMARY <subquery2> ALL distinct_key NULL NULL NULL 1 100.00 + 1 PRIMARY temp hash_ALL NULL #hash#$hj 9 test.t1.i1,test.t1.v1 7 100.00 Using where; Using join buffer (flat, BNLH join) + 2 MATERIALIZED t1 ALL NULL NULL NULL NULL 1 100.00 Using where -2 MATERIALIZED t2 hash_index v1 #hash#v1:v1 4:9 test.t1.v1 10 10.00 Using join buffer (flat, BNLH join) ++2 MATERIALIZED t2 hash_index v1 #hash#v1:v1 4:9 test.t1.v1 10 10.00 Using index; Using join buffer (flat, BNLH join) + Warnings: -Note 1003 select `test`.`temp`.`f1` AS `f1`,`test`.`temp`.`f2` AS `f2` from `test`.`temp` semi join (`test`.`t2` join `test`.`t1`) where ((`test`.`temp`.`f1` = `test`.`t1`.`i1`) and (`test`.`t2`.`v1` = `test`.`t1`.`v1`) and (`test`.`temp`.`f2` = `test`.`t1`.`v1`)) ++Note 1003 select `test`.`temp`.`f1` AS `f1`,`test`.`temp`.`f2` AS `f2` from `test`.`temp` semi join (`test`.`t2` join `test`.`t1`) where `test`.`temp`.`f1` = `test`.`t1`.`i1` and `test`.`t2`.`v1` = `test`.`t1`.`v1` and `test`.`temp`.`f2` = `test`.`t1`.`v1` + DROP TABLE t1,t2,temp; + SET join_cache_level = default; + # # MDEV-5123 Remove duplicated conditions pushed both to join_tab->select_cond and join_tab->cache_select->cond for blocked joins. # set join_cache_level=default; diff --cc mysql-test/t/join_cache.test index b775725903c,24dd637052c..df89fc30dee --- a/mysql-test/t/join_cache.test +++ b/mysql-test/t/join_cache.test @@@ -3945,18 -3976,5 +3976,17 @@@ SELECT * FROM INFORMATION_SCHEMA.PROFIL set join_cache_level=default; +# +# MDEV-12580 Wrong query result in join when using an index (Version > "10.2.3") +# +create table t1 (c1 date not null, key (c1)) engine=innodb; +insert t1 values ('2017-12-27'); +create table t2 (pk int, f1 int, f2 int); +insert t2 values (4,1,1), (6,1,1); +set join_buffer_size = 222222208; +select f2 from t2,t1 where f2 = 0; +drop table t1, t2; +set join_buffer_size = default; + # The following command must be the last one the file - # this must be the last command in the file set @@optimizer_switch=@save_optimizer_switch; diff --cc sql/sql_parse.cc index 3ec7b54e0a9,1d57e8f54fa..dd16200539d --- a/sql/sql_parse.cc +++ b/sql/sql_parse.cc @@@ -1577,10 -1274,9 +1580,10 @@@ bool dispatch_command(enum enum_server_ if (thd->wsrep_conflict_state == ABORTED && command != COM_STMT_CLOSE && command != COM_QUIT) { + mysql_mutex_unlock(&thd->LOCK_thd_data); - my_error(ER_LOCK_DEADLOCK, MYF(0), "wsrep aborted transaction"); + my_message(ER_LOCK_DEADLOCK, "Deadlock: wsrep aborted transaction", + MYF(0)); WSREP_DEBUG("Deadlock error for: %s", thd->query()); - mysql_mutex_unlock(&thd->LOCK_thd_data); thd->reset_killed(); thd->mysys_var->abort = 0; thd->wsrep_conflict_state = NO_CONFLICT; @@@ -7843,14 -7315,16 +7851,18 @@@ static void wsrep_mysql_parse(THD *thd } else { - WSREP_DEBUG("%s, thd: %lld is_AC: %d, retry: %lu - %lu SQL: %s", - (thd->wsrep_conflict_state == ABORTED) ? + mysql_mutex_unlock(&thd->LOCK_thd_data); + // This does dirty read to wsrep variables but it is only a debug code - WSREP_DEBUG("%s, thd: %lu is_AC: %d, retry: %lu - %lu SQL: %s", ++ WSREP_DEBUG("%s, thd: %lld is_AC: %d, retry: %lu - %lu SQL: %s", + (thd->wsrep_conflict_state == ABORTED) ? "BF Aborted" : "cert failure", - thd->thread_id, is_autocommit, thd->wsrep_retry_counter, + (longlong) thd->thread_id, is_autocommit, - thd->wsrep_retry_counter, ++ thd->wsrep_retry_counter, thd->variables.wsrep_retry_autocommit, thd->query()); - my_error(ER_LOCK_DEADLOCK, MYF(0), "wsrep aborted transaction"); + my_message(ER_LOCK_DEADLOCK, "Deadlock: wsrep aborted transaction", + MYF(0)); + + mysql_mutex_lock(&thd->LOCK_thd_data); thd->wsrep_conflict_state= NO_CONFLICT; if (thd->wsrep_conflict_state != REPLAYING) thd->wsrep_retry_counter= 0; // reset diff --cc sql/wsrep_binlog.cc index 483da2296ad,c7674cd0169..672e1d77f47 --- a/sql/wsrep_binlog.cc +++ b/sql/wsrep_binlog.cc @@@ -318,13 -318,28 +318,28 @@@ int wsrep_write_cache(wsrep_t* const w void wsrep_dump_rbr_buf(THD *thd, const void* rbr_buf, size_t buf_len) { - char filename[PATH_MAX]= {0}; - int len= snprintf(filename, PATH_MAX, "%s/GRA_%lld_%lld.log", - int len= snprintf(NULL, 0, "%s/GRA_%ld_%lld.log", - wsrep_data_home_dir, thd->thread_id, - (long long)wsrep_thd_trx_seqno(thd)); ++ int len= snprintf(NULL, 0, "%s/GRA_%lld_%lld.log", + wsrep_data_home_dir, (longlong) thd->thread_id, + (longlong) wsrep_thd_trx_seqno(thd)); - if (len >= PATH_MAX) + if (len < 0) { - WSREP_ERROR("RBR dump path too long: %d, skipping dump.", len); + WSREP_ERROR("snprintf error: %d, skipping dump.", len); + return; + } + /* + len doesn't count the \0 end-of-string. Use len+1 below + to alloc and pass as an argument to snprintf. + */ + + char *filename= (char *)malloc(len+1); - int len1= snprintf(filename, len+1, "%s/GRA_%ld_%lld.log", - wsrep_data_home_dir, thd->thread_id, ++ int len1= snprintf(filename, len+1, "%s/GRA_%lld_%lld.log", ++ wsrep_data_home_dir, (longlong) thd->thread_id, + (long long)wsrep_thd_trx_seqno(thd)); + + if (len > len1) + { + WSREP_ERROR("RBR dump path truncated: %d, skipping dump.", len); + free(filename); return; } @@@ -454,13 -469,30 +469,29 @@@ void wsrep_dump_rbr_buf_with_header(TH Log_event_writer writer(&cache); Format_description_log_event *ev=NULL; - int len= my_snprintf(filename, PATH_MAX, "%s/GRA_%lld_%lld_v2.log", - wsrep_data_home_dir, (longlong) thd->thread_id, - (long long) wsrep_thd_trx_seqno(thd)); + longlong thd_trx_seqno= (long long)wsrep_thd_trx_seqno(thd); - - int len= snprintf(NULL, 0, "%s/GRA_%ld_%lld_v2.log", - wsrep_data_home_dir, thd->thread_id, ++ int len= snprintf(NULL, 0, "%s/GRA_%lld_%lld_v2.log", ++ wsrep_data_home_dir, (longlong)thd->thread_id, + thd_trx_seqno); + /* + len doesn't count the \0 end-of-string. Use len+1 below + to alloc and pass as an argument to snprintf. + */ + char *filename; + if (len < 0 || !(filename= (char*)malloc(len+1))) + { + WSREP_ERROR("snprintf error: %d, skipping dump.", len); + DBUG_VOID_RETURN; + } + - int len1= snprintf(filename, len+1, "%s/GRA_%ld_%lld_v2.log", - wsrep_data_home_dir, thd->thread_id, ++ int len1= snprintf(filename, len+1, "%s/GRA_%lld_%lld_v2.log", ++ wsrep_data_home_dir, (longlong) thd->thread_id, + thd_trx_seqno); - if (len >= PATH_MAX) + if (len > len1) { - WSREP_ERROR("RBR dump path too long: %d, skipping dump.", len); + WSREP_ERROR("RBR dump path truncated: %d, skipping dump.", len); + free(filename); DBUG_VOID_RETURN; }