From 5af12e463549e4bbc2ce6ab720d78937d5e5db4e Mon Sep 17 00:00:00 2001 From: Igor Babaev Date: Thu, 12 Mar 2020 23:50:20 -0700 Subject: [PATCH 01/13] MDEV-21932 A fast plan with ROR index-merge is ignored when 'index_merge_sort_union=off' When index_merge_sort_union is set to 'off' and index_merge_union is set to 'on' then any evaluated index merge scan must consist only of ROR scans. The cheapest out of such index merges must be chosen. This index merge might not be the cheapest index merge. --- mysql-test/r/index_merge_myisam.result | 52 ++++++++++++++++++++++++ mysql-test/r/range_vs_index_merge.result | 2 +- mysql-test/t/index_merge_myisam.test | 48 ++++++++++++++++++++++ sql/opt_range.cc | 7 ++++ 4 files changed, 108 insertions(+), 1 deletion(-) diff --git a/mysql-test/r/index_merge_myisam.result b/mysql-test/r/index_merge_myisam.result index 091719095fb..0720dceac9a 100644 --- a/mysql-test/r/index_merge_myisam.result +++ b/mysql-test/r/index_merge_myisam.result @@ -1704,3 +1704,55 @@ id select_type table type possible_keys key key_len ref rows Extra 1 SIMPLE t1 ALL PRIMARY,c1,i,c2 NULL NULL NULL 69 Using where DROP TABLE t1; set optimizer_switch= @optimizer_switch_save; +# +# MDEV-21932: ROR union with index_merge_sort_union=off +# +create table t0 (a int); +insert into t0 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9); +insert into t0 select a+10 from t0; +insert into t0 select a+20 from t0; +insert into t0 select a+40 from t0; +insert into t0 select a+80 from t0; +insert into t0 select a+160 from t0; +delete from t0 where a > 300; +create table t1 ( +f1 int, f2 int, f3 int, f4 int, +primary key (f1), key (f3), key(f4) +) engine=myisam; +insert into t1 select a+100, a+100, a+100, a+100 from t0; +insert into t1 VALUES (9,0,2,6), (9930,0,0,NULL); +analyze table t1; +Table Op Msg_type Msg_text +test.t1 analyze status OK +set optimizer_switch='index_merge_sort_union=off'; +set optimizer_switch='index_merge_union=on'; +explain select * from t1 +where (( f3 = 1 or f1 = 7 ) and f1 < 10) or +(f3 between 2 and 2 and ( f3 = 1 or f4 < 7 )); +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t1 index_merge PRIMARY,f3,f4 f3,PRIMARY,f3 5,4,5 NULL 3 Using union(f3,PRIMARY,f3); Using where +select * from t1 +where (( f3 = 1 or f1 = 7 ) and f1 < 10) or +(f3 between 2 and 2 and ( f3 = 1 or f4 < 7 )); +f1 f2 f3 f4 +9 0 2 6 +insert into t1 values (52,0,1,0),(53,0,1,0); +insert into t1 values (50,0,1,0),(51,0,1,0); +insert into t1 values (48,0,1,0),(49,0,1,0); +insert into t1 values (46,0,1,0),(47,0,1,0); +insert into t1 values (44,0,1,0),(45,0,1,0); +analyze table t1; +Table Op Msg_type Msg_text +test.t1 analyze status OK +explain select * from t1 +where (( f3 = 1 or f1 = 7 ) and f1 < 10) or +(f3 between 2 and 2 and ( f3 = 1 or f4 < 7 )); +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t1 index_merge PRIMARY,f3,f4 f3,PRIMARY,f3 5,4,5 NULL 13 Using union(f3,PRIMARY,f3); Using where +select * from t1 +where (( f3 = 1 or f1 = 7 ) and f1 < 10) or +(f3 between 2 and 2 and ( f3 = 1 or f4 < 7 )); +f1 f2 f3 f4 +9 0 2 6 +drop table t0,t1; +set optimizer_switch= @optimizer_switch_save; diff --git a/mysql-test/r/range_vs_index_merge.result b/mysql-test/r/range_vs_index_merge.result index 0acaed37d22..752554ac53d 100644 --- a/mysql-test/r/range_vs_index_merge.result +++ b/mysql-test/r/range_vs_index_merge.result @@ -1653,7 +1653,7 @@ SELECT * FROM t1 FORCE KEY (PRIMARY,f3,f4) WHERE ( f3 = 1 OR f1 = 7 ) AND f1 < 10 OR f3 BETWEEN 2 AND 2 AND ( f3 = 1 OR f4 != 1 ); id select_type table type possible_keys key key_len ref rows Extra -1 SIMPLE t1 ALL PRIMARY,f3,f4 NULL NULL NULL 2 Using where +1 SIMPLE t1 index_merge PRIMARY,f3,f4 f3,PRIMARY,f3 5,4,5 NULL 3 Using union(f3,PRIMARY,f3); Using where SELECT * FROM t1 FORCE KEY (PRIMARY,f3,f4) WHERE ( f3 = 1 OR f1 = 7 ) AND f1 < 10 OR f3 BETWEEN 2 AND 2 AND ( f3 = 1 OR f4 != 1 ); diff --git a/mysql-test/t/index_merge_myisam.test b/mysql-test/t/index_merge_myisam.test index 82d0474e28e..79aa5447215 100644 --- a/mysql-test/t/index_merge_myisam.test +++ b/mysql-test/t/index_merge_myisam.test @@ -243,3 +243,51 @@ DROP TABLE t1; set optimizer_switch= @optimizer_switch_save; +--echo # +--echo # MDEV-21932: ROR union with index_merge_sort_union=off +--echo # + +create table t0 (a int); +insert into t0 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9); +insert into t0 select a+10 from t0; +insert into t0 select a+20 from t0; +insert into t0 select a+40 from t0; +insert into t0 select a+80 from t0; +insert into t0 select a+160 from t0; +delete from t0 where a > 300; + +create table t1 ( + f1 int, f2 int, f3 int, f4 int, + primary key (f1), key (f3), key(f4) +) engine=myisam; +insert into t1 select a+100, a+100, a+100, a+100 from t0; +insert into t1 VALUES (9,0,2,6), (9930,0,0,NULL); +analyze table t1; + +set optimizer_switch='index_merge_sort_union=off'; +set optimizer_switch='index_merge_union=on'; + +let $q1= +select * from t1 + where (( f3 = 1 or f1 = 7 ) and f1 < 10) or + (f3 between 2 and 2 and ( f3 = 1 or f4 < 7 )); +eval explain $q1; +eval $q1; + +insert into t1 values (52,0,1,0),(53,0,1,0); +insert into t1 values (50,0,1,0),(51,0,1,0); +insert into t1 values (48,0,1,0),(49,0,1,0); +insert into t1 values (46,0,1,0),(47,0,1,0); +insert into t1 values (44,0,1,0),(45,0,1,0); +analyze table t1; + +let $q2= +select * from t1 + where (( f3 = 1 or f1 = 7 ) and f1 < 10) or + (f3 between 2 and 2 and ( f3 = 1 or f4 < 7 )); +eval explain $q2; +eval $q2; + +drop table t0,t1; + +set optimizer_switch= @optimizer_switch_save; diff --git a/sql/opt_range.cc b/sql/opt_range.cc index ca6f500fec6..70c1786dd83 100644 --- a/sql/opt_range.cc +++ b/sql/opt_range.cc @@ -6802,6 +6802,13 @@ static TRP_RANGE *get_key_scans_params(PARAM *param, SEL_TREE *tree, update_tbl_stats, &mrr_flags, &buf_size, &cost); + if (!param->is_ror_scan && + !optimizer_flag(param->thd, OPTIMIZER_SWITCH_INDEX_MERGE_SORT_UNION)) + { + /* The scan is not a ROR-scan, just skip it */ + continue; + } + if (found_records != HA_POS_ERROR && tree->index_scans && (index_scan= (INDEX_SCAN_INFO *)alloc_root(param->mem_root, sizeof(INDEX_SCAN_INFO)))) From 407b0a6ae7c300f34535be59dcdb8ba8f84d1ce5 Mon Sep 17 00:00:00 2001 From: Igor Babaev Date: Sat, 14 Mar 2020 19:58:57 -0700 Subject: [PATCH 02/13] MDEV-10466 Server crashed in SEL_ARG::store_min() with extended_keys=on This bug could manifest itself in a very rare cases when the optimizer chose an execution plan by which a joined table was accessed by a table scan and the optimizer was checking whether ranges checked for each record could improve this plan. In such cases the optimizer evaluates range conditions over a table that depend on other tables. For such conditions the constructed SEL_ARG trees are marked as MAYBE_KEY. If a SEL_ARG object constructed for a sargable condition marked as RANGE_KEY had the same first key part as a MAYBE_KEY SEL_ARG object and the key_and() function was called for this pair of SEL_ARG objects then an invalid SEL_ARG object could be constructed that ultimately could lead to a crash before the execution phase. --- mysql-test/r/range_innodb.result | 25 +++++++++++++++++++++++++ mysql-test/t/range_innodb.test | 25 +++++++++++++++++++++++++ sql/opt_range.cc | 2 +- 3 files changed, 51 insertions(+), 1 deletion(-) diff --git a/mysql-test/r/range_innodb.result b/mysql-test/r/range_innodb.result index 794e6c7b3cc..50e967bef3e 100644 --- a/mysql-test/r/range_innodb.result +++ b/mysql-test/r/range_innodb.result @@ -37,3 +37,28 @@ id select_type table type possible_keys key key_len ref rows Extra 1 SIMPLE t0 ALL NULL NULL NULL NULL 10 1 SIMPLE t2 range a,b b 5 NULL 201 Using where; Using join buffer (flat, BNL join) drop table t0,t1,t2; +# +# MDEV-10466: constructing an invalid SEL_ARG +# +create table t1 ( +pk int, a int, b int, +primary key (pk), index idx1(b), index idx2(b) +) engine=innodb; +insert into t1 values (1,6,0),(2,1,0),(3,5,2),(4,8,0); +create table t2 (c int) engine=innodb; +insert into t2 values (1),(2); +create table t3 (d int) engine=innodb; +insert into t3 values (3),(-1),(4); +set @save_optimizer_switch=@@optimizer_switch; +set optimizer_switch='extended_keys=on'; +explain +select pk, a, b from t1,t2,t3 where b >= d and pk < c and b = '0'; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t2 ALL NULL NULL NULL NULL 2 +1 SIMPLE t3 ALL NULL NULL NULL NULL 3 Using join buffer (flat, BNL join) +1 SIMPLE t1 ALL PRIMARY,idx1,idx2 NULL NULL NULL 4 Using where; Using join buffer (incremental, BNL join) +select pk, a, b from t1,t2,t3 where b >= d and pk < c and b = '0'; +pk a b +1 6 0 +set optimizer_switch=@save_optimizer_switch; +drop table t1,t2,t3; diff --git a/mysql-test/t/range_innodb.test b/mysql-test/t/range_innodb.test index f76794814ef..3b97f4f1727 100644 --- a/mysql-test/t/range_innodb.test +++ b/mysql-test/t/range_innodb.test @@ -45,3 +45,28 @@ explain select * from t0 left join t2 on t2.a = d and pk < c and b = '0'; +select pk, a, b from t1,t2,t3 where b >= d and pk < c and b = '0'; + +set optimizer_switch=@save_optimizer_switch; + +drop table t1,t2,t3; diff --git a/sql/opt_range.cc b/sql/opt_range.cc index 70c1786dd83..37ca3a22c77 100644 --- a/sql/opt_range.cc +++ b/sql/opt_range.cc @@ -8837,7 +8837,7 @@ key_and(RANGE_OPT_PARAM *param, SEL_ARG *key1, SEL_ARG *key2, uint clone_flag) if (key2->next_key_part) { key1->use_count--; // Incremented in and_all_keys - return and_all_keys(param, key1, key2, clone_flag); + return and_all_keys(param, key1, key2->next_key_part, clone_flag); } key2->use_count--; // Key2 doesn't have a tree } From 24cb76b8dd86bf54f264352be41506995b6c89c4 Mon Sep 17 00:00:00 2001 From: Vladislav Vaintroub Date: Tue, 24 Mar 2020 23:30:40 +0100 Subject: [PATCH 03/13] MDEV-22032 update HeidiSQL to version 11 --- win/packaging/heidisql.cmake | 2 +- win/packaging/heidisql.wxi.in | 28 +++++++++++++++++++--------- 2 files changed, 20 insertions(+), 10 deletions(-) diff --git a/win/packaging/heidisql.cmake b/win/packaging/heidisql.cmake index 1b9fb3d110c..1b8223072d2 100644 --- a/win/packaging/heidisql.cmake +++ b/win/packaging/heidisql.cmake @@ -1,4 +1,4 @@ -SET(HEIDISQL_BASE_NAME "HeidiSQL_10.2_32_Portable") +SET(HEIDISQL_BASE_NAME "HeidiSQL_11.0_32_Portable") SET(HEIDISQL_ZIP "${HEIDISQL_BASE_NAME}.zip") SET(HEIDISQL_URL "http://www.heidisql.com/downloads/releases/${HEIDISQL_ZIP}") SET(HEIDISQL_DOWNLOAD_DIR ${THIRD_PARTY_DOWNLOAD_LOCATION}/${HEIDISQL_BASE_NAME}) diff --git a/win/packaging/heidisql.wxi.in b/win/packaging/heidisql.wxi.in index e8e01700032..70849e67998 100644 --- a/win/packaging/heidisql.wxi.in +++ b/win/packaging/heidisql.wxi.in @@ -33,20 +33,25 @@ + + + + + - - + + - - + + - - + + @@ -54,6 +59,9 @@ + + + @@ -76,11 +84,13 @@ - - - + + + + + From 31eaa2029f3c2a4f8e5609ce8b87682286238d9a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marko=20M=C3=A4kel=C3=A4?= Date: Wed, 1 Apr 2020 15:16:11 +0300 Subject: [PATCH 04/13] MDEV-19740: Have MYSQL_MAINTAINER_MODE only enable -Werror Let us enable all GCC and clang warnings independently of the MYSQL_MAINTAINER_MODE setting for both Debug and RelWithDebInfo builds, and have MYSQL_MAINTAINER_MODE only enable -Werror. The default setting of MYSQL_MAINTAINER_MODE=AUTO will continue to apply the -Werror only to CMAKE_BUILD_TYPE=Debug. To build a debug version without -Werror, MYSQL_MAINTAINER_MODE=OFF can be used. --- cmake/maintainer.cmake | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/cmake/maintainer.cmake b/cmake/maintainer.cmake index 8c2deeb8e40..9c51cb797bb 100644 --- a/cmake/maintainer.cmake +++ b/cmake/maintainer.cmake @@ -1,4 +1,5 @@ # Copyright (c) 2010, 2014, Oracle and/or its affiliates. All rights reserved. +# Copyright (c) 2020, MariaDB # # 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 @@ -28,11 +29,16 @@ SET(MY_WARNING_FLAGS -Woverloaded-virtual -Wvla -Wwrite-strings - -Werror ) +FOREACH(F ${MY_WARNING_FLAGS}) + MY_CHECK_AND_SET_COMPILER_FLAG(${F} DEBUG RELWITHDEBINFO) +ENDFOREACH() + +SET(MY_ERROR_FLAGS -Werror) + IF(CMAKE_COMPILER_IS_GNUCC AND CMAKE_C_COMPILER_VERSION VERSION_LESS "6.0.0") - SET(MY_WARNING_FLAGS ${MY_WARNING_FLAGS} -Wno-error=maybe-uninitialized) + SET(MY_ERROR_FLAGS ${MY_ERROR_FLAGS} -Wno-error=maybe-uninitialized) ENDIF() IF(MYSQL_MAINTAINER_MODE MATCHES "OFF") @@ -41,7 +47,7 @@ ELSEIF(MYSQL_MAINTAINER_MODE MATCHES "AUTO") SET(WHERE DEBUG) ENDIF() -FOREACH(F ${MY_WARNING_FLAGS}) +FOREACH(F ${MY_ERROR_FLAGS}) MY_CHECK_AND_SET_COMPILER_FLAG(${F} ${WHERE}) ENDFOREACH() From 64b70b09e6ac253b7915f6120ade5e69fa750b18 Mon Sep 17 00:00:00 2001 From: Hannu Hartikainen Date: Mon, 30 Mar 2020 16:36:48 +0300 Subject: [PATCH 05/13] my.cnf: mention that config files must be *.cnf It took me a long time to debug why my configs were not being loaded, and judging from online discussions I'm not the only one. Make the comment in the default my.cnf a bit more helpful. The !includedir directive is implemented in mysys/my_default.c. - f_extensions[] is a list of file extensions. It includes .ini and .cnf on Windows, and only .cnf on all other platforms. - search_default_file_with_ext() contains the !includedir directive. It filters files in the directory to those matching f_extensions[]. This file should only be applicable on Unix-like platforms, so only files with the .cnf extension are read. Closes #1485 --- support-files/rpm/my.cnf | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/support-files/rpm/my.cnf b/support-files/rpm/my.cnf index 913b88f8328..8c6a7139de5 100644 --- a/support-files/rpm/my.cnf +++ b/support-files/rpm/my.cnf @@ -5,7 +5,7 @@ [client-server] # -# include all files from the config directory +# include *.cnf from the config directory # !includedir /etc/my.cnf.d From 241ac3f4873007cced7b547837f311da5c1261ce Mon Sep 17 00:00:00 2001 From: "Alexander E. Patrakov" Date: Thu, 28 Nov 2019 17:37:57 +0500 Subject: [PATCH 06/13] MDEV-21140 Make galera_recovery.sh work with fs.protected_regular = 1 (#1417) The log file is opened as root since commit bb7a70c, so there is no need to chown it. --- scripts/galera_recovery.sh | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/scripts/galera_recovery.sh b/scripts/galera_recovery.sh index 709c4b0eed5..8df2abc3fd5 100644 --- a/scripts/galera_recovery.sh +++ b/scripts/galera_recovery.sh @@ -101,8 +101,7 @@ wsrep_recover_position() { # Safety checks if [ -n "$log_file" -a -f "$log_file" ]; then - [ "$euid" = "0" ] && chown $user $log_file - chmod 600 $log_file + chmod 600 $log_file else log "WSREP: mktemp failed" fi From 5720db2b43491e5aec9265bce9637e00c72fa0aa Mon Sep 17 00:00:00 2001 From: Rasmus Johansson Date: Tue, 7 Apr 2020 07:45:49 +0000 Subject: [PATCH 07/13] MDEV-22176 Add JUnit support to MTR to generate XML test result A new parameter has been added called xml-report, with which the filename of the XML file is given to which the XML result is written. There is also xml-package for adding a package value in the XML output. Example usage: ./mysql-test-run.pl main.events_bugs innodb.count_distinct main.explain_json innodb.file_format_defaults json.json_no_table --suite=main,innodb,json --force --xml-report=build123456789.xml --xml-package=simpletestrun --- mysql-test/lib/My/Tee.pm | 2 +- mysql-test/lib/mtr_report.pm | 90 ++++++++++++++++++++++++++++++++++++ mysql-test/mysql-test-run.pl | 8 +++- 3 files changed, 97 insertions(+), 3 deletions(-) diff --git a/mysql-test/lib/My/Tee.pm b/mysql-test/lib/My/Tee.pm index 5985fe33739..8d6b4ddd52f 100644 --- a/mysql-test/lib/My/Tee.pm +++ b/mysql-test/lib/My/Tee.pm @@ -10,7 +10,7 @@ sub PUSHED open($copyfh, '>', "$::opt_vardir/log/stdout.log") or die "open(>$::opt_vardir/log/stdout.log): $!" unless $copyfh; - bless { }, shift; + bless { }, shift; } sub WRITE diff --git a/mysql-test/lib/mtr_report.pm b/mysql-test/lib/mtr_report.pm index 3701ad79b15..a3282704dd2 100644 --- a/mysql-test/lib/mtr_report.pm +++ b/mysql-test/lib/mtr_report.pm @@ -20,7 +20,9 @@ # same name. package mtr_report; + use strict; +use Sys::Hostname; use base qw(Exporter); our @EXPORT= qw(report_option mtr_print_line mtr_print_thick_line @@ -253,6 +255,7 @@ sub mtr_report_stats ($$$$) { # Find out how we where doing # ---------------------------------------------------------------------- + my $tot_disabled = 0; my $tot_skipped= 0; my $tot_skipdetect= 0; my $tot_passed= 0; @@ -273,6 +276,7 @@ sub mtr_report_stats ($$$$) { { # Test was skipped (disabled not counted) $tot_skipped++ unless $tinfo->{'disable'}; + $tot_disabled++ if $tinfo->{'disable'}; $tot_skipdetect++ if $tinfo->{'skip_detected_by_test'}; } elsif ( $tinfo->{'result'} eq 'MTR_RES_PASSED' ) @@ -402,6 +406,92 @@ sub mtr_report_stats ($$$$) { print "All $tot_tests tests were successful.\n\n"; } + if ($::opt_xml_report) { + my $xml_report = ""; + my @sorted_tests = sort {$a->{'name'} cmp $b->{'name'}} @$tests; + my $last_suite = ""; + my $current_suite = ""; + my $timest = isotime(time); + my %suite_totals; + my %suite_time; + my %suite_tests; + my %suite_failed; + my %suite_disabled; + my %suite_skipped; + my $host = hostname; + my $suiteNo = 0; + + # loop through test results to count totals + foreach my $test ( @sorted_tests ) { + $current_suite = $test->{'suite'}->{'name'}; + + if ($test->{'timer'} eq "") { + $test->{'timer'} = 0; + } + + $suite_time{$current_suite} = $suite_time{$current_suite} + $test->{'timer'}; + $suite_tests{$current_suite} = $suite_tests{$current_suite} + 1; + + if ($test->{'result'} eq "MTR_RES_FAILED") { + $suite_failed{$current_suite} = $suite_failed{$current_suite} + 1; + } elsif ($test->{'result'} eq "MTR_RES_SKIPPED" && $test->{'disable'}) { + $suite_disabled{$current_suite} = $suite_disabled{$current_suite} + 1; + } elsif ($test->{'result'} eq "MTR_RES_SKIPPED") { + $suite_skipped{$current_suite} = $suite_skipped{$current_suite} + 1; + } + + $suite_totals{"all_time"} = $suite_totals{"all_time"} + $test->{'timer'}; + } + + my $all_time = sprintf("%.3f", $suite_totals{"all_time"} / 1000); + my $suite_time = 0; + my $test_time = 0; + + # generate xml + $xml_report = "\n"; + $xml_report .= qq(\n); + + foreach my $test ( @sorted_tests ) { + $current_suite = $test->{'suite'}->{'name'}; + + if ($current_suite ne $last_suite) { + if ($last_suite ne "") { + $xml_report .= "\t\n"; + $suiteNo++; + } + + $suite_time = sprintf("%.3f", $suite_time{$current_suite} / 1000); + $xml_report .= qq(\t\n); + $last_suite = $current_suite; + } + + $test_time = sprintf("%.3f", $test->{timer} / 1000); + $xml_report .= qq(\t\t{'comment'}; + $comment =~ s/[\"]//g; + + if ($test->{'result'} eq "MTR_RES_FAILED") { + $xml_report .= qq(>\n\t\t\t\n{'logfile'}]]>\n\t\t\t\n\t\t\n); + } elsif ($test->{'result'} eq "MTR_RES_SKIPPED" && $test->{'disable'}) { + $xml_report .= qq(>\n\t\t\t\n\t\t\n); + } elsif ($test->{'result'} eq "MTR_RES_SKIPPED") { + $xml_report .= qq(>\n\t\t\t\n\t\t\n); + } else { + $xml_report .= " />\n"; + } + } + + $xml_report .= "\t\n\n"; + + # save to file + my $xml_file = $::opt_xml_report; + + open XML_FILE, ">", $xml_file or die "Cannot create file $xml_file: $!"; + print XML_FILE $xml_report; + close XML_FILE; + } + if (@$extra_warnings) { print < \$opt_usage, # list-options is internal, not listed in help 'list-options' => \$opt_list_options, - 'skip-test-list=s' => \@opt_skip_test_list + 'skip-test-list=s' => \@opt_skip_test_list, + 'xml-report=s' => \$opt_xml_report ); # fix options (that take an optional argument and *only* after = sign @@ -6281,6 +6284,7 @@ Misc options phases of test execution. stress=ARGS Run stress test, providing options to mysql-stress-test.pl. Options are separated by comma. + xml-report= Output jUnit xml file of the results. Some options that control enabling a feature for normal test runs, can be turned off by prepending 'no' to the option, e.g. --notimer. From c8e0c524af83149e77c88e9a6fd763221dea9277 Mon Sep 17 00:00:00 2001 From: Julius Goryavsky Date: Tue, 31 Mar 2020 14:18:06 +0200 Subject: [PATCH 08/13] MDEV-20676: systemd script not working When trying to start mariadb via systemctl, WSREP failed to start mysqld for wsrep recovery, because the binary "galera-recovery" is neither searching the mysqld in the same folder as the binary itself nor in the path variable but instead expects the root to be /usr/local/mysql. This fix changes the current directory to the desired directory before starting mysqld. --- support-files/mariadb.service.in | 2 +- support-files/mariadb@.service.in | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/support-files/mariadb.service.in b/support-files/mariadb.service.in index 38f55cb7e8f..1cc37dcc3e6 100644 --- a/support-files/mariadb.service.in +++ b/support-files/mariadb.service.in @@ -70,7 +70,7 @@ PermissionsStartOnly=true # Do not panic if galera_recovery script is not available. (MDEV-10538) ExecStartPre=/bin/sh -c "systemctl unset-environment _WSREP_START_POSITION" ExecStartPre=/bin/sh -c "[ ! -e @bindir@/galera_recovery ] && VAR= || \ - VAR=`@bindir@/galera_recovery`; [ $? -eq 0 ] \ + VAR=`cd @bindir@/..; @bindir@/galera_recovery`; [ $? -eq 0 ] \ && systemctl set-environment _WSREP_START_POSITION=$VAR || exit 1" # Needed to create system tables etc. diff --git a/support-files/mariadb@.service.in b/support-files/mariadb@.service.in index 475f3830a78..7b8c2b72cc0 100644 --- a/support-files/mariadb@.service.in +++ b/support-files/mariadb@.service.in @@ -76,14 +76,14 @@ PermissionsStartOnly=true ExecStartPre=/bin/sh -c "systemctl unset-environment _WSREP_START_POSITION%I" ExecStartPre=/bin/sh -c "[ ! -e @bindir@/galera_recovery ] && VAR= || \ - VAR=`@bindir@/galera_recovery --defaults-file=@sysconf2dir@/my%I.cnf`; [ $? -eq 0 ] \ + VAR=`cd @bindir@/..; @bindir@/galera_recovery --defaults-file=@sysconf2dir@/my%I.cnf`; [ $? -eq 0 ] \ && systemctl set-environment _WSREP_START_POSITION%I=$VAR || exit 1" # Alternate: (remove ConditionPathExists above) # use [mysqld.INSTANCENAME] as sections in my.cnf # #ExecStartPre=/bin/sh -c "[ ! -e @bindir@/galera_recovery ] && VAR= || \ -# VAR=`@bindir@/galera_recovery --defaults-group-suffix=%I`; [ $? -eq 0 ] \ +# VAR=`cd @bindir@/..; @bindir@/galera_recovery --defaults-group-suffix=%I`; [ $? -eq 0 ] \ # && systemctl set-environment _WSREP_START_POSITION%I=$VAR || exit 1" # Needed to create system tables etc. From c1394ab6b5c0830ec09f6afdae11fa82bae1a123 Mon Sep 17 00:00:00 2001 From: Varun Gupta Date: Wed, 8 Apr 2020 17:39:27 +0530 Subject: [PATCH 09/13] MDEV-22191: Range access is not picked when index_merge_sort_union is turned off When index_merge_sort_union is turned off only ror scans were considered for range scans, which is wrong. To fix the problem ensure both ror scans and non ror scans are considered for range access --- mysql-test/r/range.result | 19 +++++++++++++++++++ mysql-test/r/range_mrr_icp.result | 19 +++++++++++++++++++ mysql-test/t/range.test | 14 ++++++++++++++ sql/opt_range.cc | 16 ++++++++++------ 4 files changed, 62 insertions(+), 6 deletions(-) diff --git a/mysql-test/r/range.result b/mysql-test/r/range.result index 630a692cef6..e4973160812 100644 --- a/mysql-test/r/range.result +++ b/mysql-test/r/range.result @@ -2144,3 +2144,22 @@ value1 1000685 12345 value1 1003560 12345 value1 1004807 12345 drop table t1; +# +# MDEV-22191: Range access is not picked when index_merge_sort_union is turned off +# +set @save_optimizer_switch=@@optimizer_switch; +set @save_optimizer_switch="index_merge_sort_union=OFF"; +CREATE TABLE t1 (a INT, INDEX(a)); +INSERT INTO t1 VALUES (0),(1),(2),(3),(4),(5),(6),(7),(8),(9); +explain +SELECT * FROM t1 WHERE a > 5; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t1 range a a 5 NULL 5 Using where; Using index +SELECT * FROM t1 WHERE a > 5; +a +6 +7 +8 +9 +set @@optimizer_switch=@save_optimizer_switch; +drop table t1; diff --git a/mysql-test/r/range_mrr_icp.result b/mysql-test/r/range_mrr_icp.result index 3f5de5b0189..308d877e1a3 100644 --- a/mysql-test/r/range_mrr_icp.result +++ b/mysql-test/r/range_mrr_icp.result @@ -2146,4 +2146,23 @@ value1 1000685 12345 value1 1003560 12345 value1 1004807 12345 drop table t1; +# +# MDEV-22191: Range access is not picked when index_merge_sort_union is turned off +# +set @save_optimizer_switch=@@optimizer_switch; +set @save_optimizer_switch="index_merge_sort_union=OFF"; +CREATE TABLE t1 (a INT, INDEX(a)); +INSERT INTO t1 VALUES (0),(1),(2),(3),(4),(5),(6),(7),(8),(9); +explain +SELECT * FROM t1 WHERE a > 5; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t1 range a a 5 NULL 5 Using where; Using index +SELECT * FROM t1 WHERE a > 5; +a +6 +7 +8 +9 +set @@optimizer_switch=@save_optimizer_switch; +drop table t1; set optimizer_switch=@mrr_icp_extra_tmp; diff --git a/mysql-test/t/range.test b/mysql-test/t/range.test index 393ca68e945..e93eff1b1af 100644 --- a/mysql-test/t/range.test +++ b/mysql-test/t/range.test @@ -1718,3 +1718,17 @@ where (key1varchar='value1' AND (key2int <=1 OR key2int > 1)); --echo # The following must show col1=12345 for all rows: select * from t1; drop table t1; + +--echo # +--echo # MDEV-22191: Range access is not picked when index_merge_sort_union is turned off +--echo # + +set @save_optimizer_switch=@@optimizer_switch; +set @save_optimizer_switch="index_merge_sort_union=OFF"; +CREATE TABLE t1 (a INT, INDEX(a)); +INSERT INTO t1 VALUES (0),(1),(2),(3),(4),(5),(6),(7),(8),(9); +explain +SELECT * FROM t1 WHERE a > 5; +SELECT * FROM t1 WHERE a > 5; +set @@optimizer_switch=@save_optimizer_switch; +drop table t1; diff --git a/sql/opt_range.cc b/sql/opt_range.cc index 37ca3a22c77..746f25c57ab 100644 --- a/sql/opt_range.cc +++ b/sql/opt_range.cc @@ -949,7 +949,8 @@ QUICK_RANGE_SELECT *get_quick_select(PARAM *param,uint index, static TRP_RANGE *get_key_scans_params(PARAM *param, SEL_TREE *tree, bool index_read_must_be_used, bool update_tbl_stats, - double read_time); + double read_time, + bool ror_scans_required); static TRP_INDEX_INTERSECT *get_best_index_intersect(PARAM *param, SEL_TREE *tree, double read_time); @@ -3146,7 +3147,7 @@ int SQL_SELECT::test_quick_select(THD *thd, key_map keys_to_use, /* Get best 'range' plan and prepare data for making other plans */ if ((range_trp= get_key_scans_params(¶m, tree, FALSE, TRUE, - best_read_time))) + best_read_time, FALSE))) { best_trp= range_trp; best_read_time= best_trp->read_cost; @@ -4708,7 +4709,8 @@ TABLE_READ_PLAN *get_best_disjunct_quick(PARAM *param, SEL_IMERGE *imerge, { DBUG_EXECUTE("info", print_sel_tree(param, *ptree, &(*ptree)->keys_map, "tree in SEL_IMERGE");); - if (!(*cur_child= get_key_scans_params(param, *ptree, TRUE, FALSE, read_time))) + if (!(*cur_child= get_key_scans_params(param, *ptree, TRUE, FALSE, + read_time, TRUE))) { /* One of index scans in this index_merge is more expensive than entire @@ -5030,7 +5032,7 @@ TABLE_READ_PLAN *merge_same_index_scans(PARAM *param, SEL_IMERGE *imerge, index merge retrievals are not well calibrated */ trp= get_key_scans_params(param, *imerge->trees, FALSE, TRUE, - read_time); + read_time, TRUE); } DBUG_RETURN(trp); @@ -6747,6 +6749,7 @@ TRP_ROR_INTERSECT *get_best_covering_ror_intersect(PARAM *param, index_read_must_be_used if TRUE, assume 'index only' option will be set (except for clustered PK indexes) read_time don't create read plans with cost > read_time. + ror_scans_required set to TRUE for index merge RETURN Best range read plan NULL if no plan found or error occurred @@ -6755,7 +6758,8 @@ TRP_ROR_INTERSECT *get_best_covering_ror_intersect(PARAM *param, static TRP_RANGE *get_key_scans_params(PARAM *param, SEL_TREE *tree, bool index_read_must_be_used, bool update_tbl_stats, - double read_time) + double read_time, + bool ror_scans_required) { uint idx; SEL_ARG **key,**end, **key_to_read= NULL; @@ -6802,7 +6806,7 @@ static TRP_RANGE *get_key_scans_params(PARAM *param, SEL_TREE *tree, update_tbl_stats, &mrr_flags, &buf_size, &cost); - if (!param->is_ror_scan && + if (ror_scans_required && !param->is_ror_scan && !optimizer_flag(param->thd, OPTIMIZER_SWITCH_INDEX_MERGE_SORT_UNION)) { /* The scan is not a ROR-scan, just skip it */ From 1749a68968064278e13b43abfe93aff11e46b9a2 Mon Sep 17 00:00:00 2001 From: Daniel Black Date: Sun, 12 Apr 2020 10:31:56 +1000 Subject: [PATCH 10/13] mtr: remove --binary from patch args This causes problems on FreeBSD which doesn't have a patch that supports this. Linux and Windows don't require it either. Was added in c39877071a5ce8ba3c8dc7a1963e3c542e6cc83b without explaination. --- mysql-test/mysql-test-run.pl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mysql-test/mysql-test-run.pl b/mysql-test/mysql-test-run.pl index 677dd58f99b..51e0ef1b0dc 100755 --- a/mysql-test/mysql-test-run.pl +++ b/mysql-test/mysql-test-run.pl @@ -3385,7 +3385,7 @@ sub do_before_run_mysqltest($) # to be able to distinguish them from manually created # version-controlled results, and to ignore them in git. my $dest = "$base_file$suites.result~"; - my @cmd = ($exe_patch, qw/--binary -r - -f -s -o/, + my @cmd = ($exe_patch, qw/-r - -f -s -o/, $dest, $base_result, $resfile); if (-w $resdir) { # don't rebuild a file if it's up to date From 7937fed917a0815b250d329ec67048d950dfecbf Mon Sep 17 00:00:00 2001 From: Daniel Black Date: Sun, 12 Apr 2020 10:36:47 +1000 Subject: [PATCH 11/13] appveyor: config backport from 10.2 Include CMAKE_C{XX,}_FLAGS=/W0 as 10k warnings exist in 10.1 branch which cause the build to fail. --- appveyor.yml | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) create mode 100644 appveyor.yml diff --git a/appveyor.yml b/appveyor.yml new file mode 100644 index 00000000000..d94b58b524e --- /dev/null +++ b/appveyor.yml @@ -0,0 +1,22 @@ +version: build-{build}~branch-{branch} + +before_build: + - md %APPVEYOR_BUILD_FOLDER%\win_build + - cd %APPVEYOR_BUILD_FOLDER%\win_build + - cmake .. -G "Visual Studio 15 2017 Win64" -DWITH_UNIT_TESTS=0 -DWITH_MARIABACKUP=0 -DMYSQL_MAINTAINER_MODE=ERR -DPLUGIN_ROCKSDB=NO -DPLUGIN_CONNECT=NO -DBISON_EXECUTABLE=C:\cygwin64\bin\bison -DCMAKE_CXX_FLAGS='/W0' -DCMAKE_C_FLAGS='/W0' +# note, don't merge /W0 to 10.2 + +build: + project: win_build\MySQL.sln + parallel: true + verbosity: minimal + +configuration: RelWithDebInfo +platform: x64 + +test_script: + - set PATH=%PATH%;C:\Program Files (x86)\Windows Kits\10\Debuggers\x64 + - cd %APPVEYOR_BUILD_FOLDER%\win_build\mysql-test + - perl mysql-test-run.pl --force --max-test-fail=10 --parallel=4 --testcase-timeout=10 --skip-test-list=unstable-tests --suite=main + +image: Visual Studio 2017 From 613bc18a361f59378e7c5096b9761de9ae59cdac Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Vicen=C8=9Biu=20Ciorbaru?= Date: Mon, 13 Apr 2020 14:22:58 +0300 Subject: [PATCH 12/13] sysvars_server_* tests need to have performance schema enabled Tests will fail otherwise. Backport change from: 867809f23a8f09b1ac0aa8f9212ac8afd572efc --- mysql-test/suite/sys_vars/inc/sysvars_server.inc | 1 + 1 file changed, 1 insertion(+) diff --git a/mysql-test/suite/sys_vars/inc/sysvars_server.inc b/mysql-test/suite/sys_vars/inc/sysvars_server.inc index cffc7e7fa62..29e8d412c07 100644 --- a/mysql-test/suite/sys_vars/inc/sysvars_server.inc +++ b/mysql-test/suite/sys_vars/inc/sysvars_server.inc @@ -1,3 +1,4 @@ +--source include/have_perfschema.inc --source include/word_size.inc --vertical_results From 0b7a79c6b0d460c522f42f12cc73a1c79ae4e9a8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Vicen=C8=9Biu=20Ciorbaru?= Date: Mon, 13 Apr 2020 16:25:32 +0300 Subject: [PATCH 13/13] Revert "mtr: remove --binary from patch args" This reverts commit 1749a68968064278e13b43abfe93aff11e46b9a2. The reason why we need --binary for patch is because of a bug in patch.exe 2.5.9. We need to supply binary otherwise the patch program crashes. --- mysql-test/mysql-test-run.pl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mysql-test/mysql-test-run.pl b/mysql-test/mysql-test-run.pl index 51e0ef1b0dc..677dd58f99b 100755 --- a/mysql-test/mysql-test-run.pl +++ b/mysql-test/mysql-test-run.pl @@ -3385,7 +3385,7 @@ sub do_before_run_mysqltest($) # to be able to distinguish them from manually created # version-controlled results, and to ignore them in git. my $dest = "$base_file$suites.result~"; - my @cmd = ($exe_patch, qw/-r - -f -s -o/, + my @cmd = ($exe_patch, qw/--binary -r - -f -s -o/, $dest, $base_result, $resfile); if (-w $resdir) { # don't rebuild a file if it's up to date