From d53b541389a02c36448a4ebe21f2a7de7d53f9b3 Mon Sep 17 00:00:00 2001 From: Daniel Bartholomew Date: Thu, 13 Apr 2017 09:35:57 -0400 Subject: [PATCH 01/10] bump the VERSION --- VERSION | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/VERSION b/VERSION index bc0b19220b6..ade2e129c54 100644 --- a/VERSION +++ b/VERSION @@ -1,4 +1,4 @@ MYSQL_VERSION_MAJOR=5 MYSQL_VERSION_MINOR=5 -MYSQL_VERSION_PATCH=55 +MYSQL_VERSION_PATCH=56 MYSQL_VERSION_EXTRA= From d185f1d68bb1f37bea10d8ac6188e5a04faf4522 Mon Sep 17 00:00:00 2001 From: Oleksandr Byelkin Date: Wed, 19 Apr 2017 14:30:52 +0200 Subject: [PATCH 02/10] Fix use of `require` in mysql-test-run. The motivation for this is that Perl is moving towards not having current directory ./ in @INC by default. This is causing mysql-test-run.pl to fail in latest Debian Unstable: https://lists.debian.org/debian-devel-announce/2016/08/msg00013.html However, we have `use "lib"`, there is no need for current directory in @INC, except for a gross hack. In mtr_cases.pm, there is a `require "mtr_misc.pl"`, which hides mtr_misc.pl away in mtr_cases namespace. And things only work because mysql-test-run.pl loads it with a different name, `require "lib/mtr_misc.pl"`! (Perl will `require` only once for each unique filename). Fix this by only using `require` in main program, and referencing functions with :: scope from other namespaces. For multi-use in different namespaces, proper `use` modules should be used. Signed-off-by: Kristian Nielsen --- mysql-test/lib/mtr_cases.pm | 4 +--- mysql-test/lib/mtr_report.pm | 3 +-- mysql-test/mysql-test-run.pl | 10 +++++----- 3 files changed, 7 insertions(+), 10 deletions(-) diff --git a/mysql-test/lib/mtr_cases.pm b/mysql-test/lib/mtr_cases.pm index 870df115f58..642cc6ce282 100644 --- a/mysql-test/lib/mtr_cases.pm +++ b/mysql-test/lib/mtr_cases.pm @@ -60,8 +60,6 @@ use My::Test; use My::Find; use My::Suite; -require "mtr_misc.pl"; - # locate plugin suites, depending on whether it's a build tree or installed my @plugin_suitedirs; my $plugin_suitedir_regex; @@ -1098,7 +1096,7 @@ sub get_tags_from_file($$) { $file_to_tags{$file}= $tags; $file_to_master_opts{$file}= $master_opts; $file_to_slave_opts{$file}= $slave_opts; - $file_combinations{$file}= [ uniq(@combinations) ]; + $file_combinations{$file}= [ ::uniq(@combinations) ]; $file_in_overlay{$file} = 1 if $in_overlay; return @{$tags}; } diff --git a/mysql-test/lib/mtr_report.pm b/mysql-test/lib/mtr_report.pm index 9ab82c454ed..97ace54f0fb 100644 --- a/mysql-test/lib/mtr_report.pm +++ b/mysql-test/lib/mtr_report.pm @@ -34,7 +34,6 @@ use mtr_match; use My::Platform; use POSIX qw[ _exit ]; use IO::Handle qw[ flush ]; -require "mtr_io.pl"; use mtr_results; my $tot_real_time= 0; @@ -92,7 +91,7 @@ sub mtr_report_test_passed ($) { my $timer_str= ""; if ( $timer and -f "$::opt_vardir/log/timer" ) { - $timer_str= mtr_fromfile("$::opt_vardir/log/timer"); + $timer_str= ::mtr_fromfile("$::opt_vardir/log/timer"); $tinfo->{timer}= $timer_str; resfile_test_info('duration', $timer_str) if $::opt_resfile; } diff --git a/mysql-test/mysql-test-run.pl b/mysql-test/mysql-test-run.pl index 02ca2fc4a83..0d9626b77e1 100755 --- a/mysql-test/mysql-test-run.pl +++ b/mysql-test/mysql-test-run.pl @@ -102,11 +102,11 @@ use mtr_results; use IO::Socket::INET; use IO::Select; -require "lib/mtr_process.pl"; -require "lib/mtr_io.pl"; -require "lib/mtr_gcov.pl"; -require "lib/mtr_gprof.pl"; -require "lib/mtr_misc.pl"; +require "mtr_process.pl"; +require "mtr_io.pl"; +require "mtr_gcov.pl"; +require "mtr_gprof.pl"; +require "mtr_misc.pl"; $SIG{INT}= sub { mtr_error("Got ^C signal"); }; $SIG{HUP}= sub { mtr_error("Hangup detected on controlling terminal"); }; From 39f1917f467139d9ea3ab2f6415ce8f5fb934a69 Mon Sep 17 00:00:00 2001 From: Kristian Nielsen Date: Sat, 10 Sep 2016 20:42:20 +0200 Subject: [PATCH 03/10] Attempt to fix strange rpm dependency issue following prior patch --- cmake/cpack_rpm.cmake | 3 +++ 1 file changed, 3 insertions(+) diff --git a/cmake/cpack_rpm.cmake b/cmake/cpack_rpm.cmake index c5af3e68984..5789eb7694a 100644 --- a/cmake/cpack_rpm.cmake +++ b/cmake/cpack_rpm.cmake @@ -218,6 +218,9 @@ SETA(CPACK_RPM_test_PACKAGE_PROVIDES "perl(mtr_io.pl)" "perl(mtr_match)" "perl(mtr_misc.pl)" + "perl(mtr_gcov.pl)" + "perl(mtr_gprof.pl)" + "perl(mtr_process.pl)" "perl(mtr_report)" "perl(mtr_results)" "perl(mtr_unique)") From 786363e89b834629410932afd3191af72b4001eb Mon Sep 17 00:00:00 2001 From: Sergei Golubchik Date: Tue, 18 Apr 2017 10:29:59 +0200 Subject: [PATCH 04/10] compiler warning way-too-smart compilers don't like the "confusing indentation" --- sql/item_sum.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sql/item_sum.cc b/sql/item_sum.cc index 02d2875195d..9a2e2e6cd4c 100644 --- a/sql/item_sum.cc +++ b/sql/item_sum.cc @@ -3429,7 +3429,7 @@ Item_func_group_concat::fix_fields(THD *thd, Item **ref) args[i]->fix_fields(thd, args + i)) || args[i]->check_cols(1)) return TRUE; - with_subselect|= args[i]->with_subselect; + with_subselect|= args[i]->with_subselect; } /* skip charset aggregation for order columns */ From 036b689f187361848a315a192a83556256c0fe96 Mon Sep 17 00:00:00 2001 From: Sergei Golubchik Date: Tue, 18 Apr 2017 11:29:02 +0200 Subject: [PATCH 05/10] MDEV-12310 openat(, ...O_EXEC) fails on Illumos / Solaris it could be * O_SEARCH on Illumos * O_EXEC on FreeBSD * O_PATH on Linux ugh --- mysys/mysys_priv.h | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/mysys/mysys_priv.h b/mysys/mysys_priv.h index 4b489504c26..661c4c184f1 100644 --- a/mysys/mysys_priv.h +++ b/mysys/mysys_priv.h @@ -89,9 +89,13 @@ void sf_free(void *ptr); void my_error_unregister_all(void); -#if !defined(O_PATH) && defined(O_EXEC) /* FreeBSD */ +#ifndef O_PATH /* not Linux */ +#if defined(O_SEARCH) /* Illumos */ +#define O_PATH O_SEARCH +#elif defined(O_EXEC) /* FreeBSD */ #define O_PATH O_EXEC #endif +#endif #ifdef O_PATH #define HAVE_OPEN_PARENT_DIR_NOSYMLINKS From 0001049be0af0d5386cbf6009aeb2101243b311a Mon Sep 17 00:00:00 2001 From: Sergei Golubchik Date: Tue, 18 Apr 2017 11:36:11 +0200 Subject: [PATCH 06/10] MDEV-12276 Missing DBUG_RETURN or DBUG_VOID_RETURN macro in function "do_exec" --- client/mysqltest.cc | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/client/mysqltest.cc b/client/mysqltest.cc index 5327bb7717b..b22959677d0 100644 --- a/client/mysqltest.cc +++ b/client/mysqltest.cc @@ -1038,7 +1038,7 @@ void do_eval(DYNAMIC_STRING *query_eval, const char *query, if (!(v= var_get(p, &p, 0, 0))) { report_or_die( "Bad variable in eval"); - return; + DBUG_VOID_RETURN; } dynstr_append_mem(query_eval, v->str_val, v->str_val_len); } @@ -1753,7 +1753,7 @@ static int run_command(char* cmd, if (!(res_file= popen(cmd, "r"))) { report_or_die("popen(\"%s\", \"r\") failed", cmd); - return -1; + DBUG_RETURN(-1); } while (fgets(buf, sizeof(buf), res_file)) @@ -2661,7 +2661,7 @@ void var_query_set(VAR *var, const char *query, const char** query_end) report_or_die("Query '%s' didn't return a result set", ds_query.str); dynstr_free(&ds_query); eval_expr(var, "", 0); - return; + DBUG_VOID_RETURN; } dynstr_free(&ds_query); @@ -2852,7 +2852,7 @@ void var_set_query_get_value(struct st_command *command, VAR *var) dynstr_free(&ds_query); dynstr_free(&ds_col); eval_expr(var, "", 0); - return; + DBUG_VOID_RETURN; } { @@ -2877,7 +2877,7 @@ void var_set_query_get_value(struct st_command *command, VAR *var) ds_col.str, ds_query.str); dynstr_free(&ds_query); dynstr_free(&ds_col); - return; + DBUG_VOID_RETURN; } DBUG_PRINT("info", ("Found column %d with name '%s'", i, fields[i].name)); @@ -3323,7 +3323,7 @@ void do_exec(struct st_command *command) if (!*cmd) { report_or_die("Missing argument in exec"); - return; + DBUG_VOID_RETURN; } command->last_argument= command->end; @@ -3357,7 +3357,7 @@ void do_exec(struct st_command *command) dynstr_free(&ds_cmd); if (command->abort_on_error) report_or_die("popen(\"%s\", \"r\") failed", command->first_argument); - return; + DBUG_VOID_RETURN; } ds_result= &ds_res; @@ -3415,7 +3415,7 @@ void do_exec(struct st_command *command) ds_cmd.str, error, status, errno, ds_res.str); dynstr_free(&ds_cmd); - return; + DBUG_VOID_RETURN; } DBUG_PRINT("info", @@ -3547,7 +3547,7 @@ void do_system(struct st_command *command) if (strlen(command->first_argument) == 0) { report_or_die("Missing arguments to system, nothing to do!"); - return; + DBUG_VOID_RETURN; } init_dynamic_string(&ds_cmd, 0, command->query_len + 64, 256); @@ -4540,7 +4540,7 @@ void do_perl(struct st_command *command) if (command->abort_on_error) die("popen(\"%s\", \"r\") failed", buf); dynstr_free(&ds_delimiter); - return; + DBUG_VOID_RETURN; } while (fgets(buf, sizeof(buf), res_file)) From 4fe65ca33a6012ec60c665f6eeb5ff08969fb267 Mon Sep 17 00:00:00 2001 From: Sergei Golubchik Date: Tue, 18 Apr 2017 12:35:05 +0200 Subject: [PATCH 07/10] =?UTF-8?q?MDEV-12230=20include/my=5Fsys.h:600:43:?= =?UTF-8?q?=20error:=20unknown=20type=20name=20=E2=80=98PSI=5Ffile=5Fkey?= =?UTF-8?q?=E2=80=99"=20when=20-DWITHOUT=5FSERVER=3D1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit cherry-pick 2c2bd8c155 (MDEV-12261 build failure without P_S) from 10.0 --- include/my_sys.h | 3 +- include/mysql/psi/mysql_file.h | 47 ++++++++++++++++++++++++++++++++ mysys/my_symlink2.c | 14 ++++------ sql/handler.cc | 2 +- sql/sql_db.cc | 4 +-- storage/maria/ma_delete_table.c | 4 +-- storage/myisam/mi_delete_table.c | 4 +-- 7 files changed, 61 insertions(+), 17 deletions(-) diff --git a/include/my_sys.h b/include/my_sys.h index 10551e119ac..27940683dad 100644 --- a/include/my_sys.h +++ b/include/my_sys.h @@ -580,8 +580,7 @@ extern File my_create_with_symlink(const char *linkname, const char *filename, myf MyFlags); extern int my_rename_with_symlink(const char *from,const char *to,myf MyFlags); extern int my_symlink(const char *content, const char *linkname, myf MyFlags); -extern int my_handler_delete_with_symlink(PSI_file_key key, const char *name, - const char *ext, myf sync_dir); +extern int my_handler_delete_with_symlink(const char *filename, myf sync_dir); extern size_t my_read(File Filedes,uchar *Buffer,size_t Count,myf MyFlags); extern size_t my_pread(File Filedes,uchar *Buffer,size_t Count,my_off_t offset, diff --git a/include/mysql/psi/mysql_file.h b/include/mysql/psi/mysql_file.h index 4a0f3fdd68b..aa3ed7e901d 100644 --- a/include/mysql/psi/mysql_file.h +++ b/include/mysql/psi/mysql_file.h @@ -434,6 +434,20 @@ inline_mysql_file_create_with_symlink(P1, P2, P3, P4, P5) #endif +/** + @def mysql_file_delete_with_symlink(K, P1, P2, P3) + Instrumented delete with symbolic link. + @c mysql_file_delete_with_symlink is a replacement + for @c my_handler_delete_with_symlink. +*/ +#ifdef HAVE_PSI_INTERFACE + #define mysql_file_delete_with_symlink(K, P1, P2, P3) \ + inline_mysql_file_delete_with_symlink(K, __FILE__, __LINE__, P1, P2, P3) +#else + #define mysql_file_delete_with_symlink(K, P1, P2, P3) \ + inline_mysql_file_delete_with_symlink(P1, P2, P3) +#endif + /** @def mysql_file_rename_with_symlink(K, P1, P2, P3) Instrumented rename with symbolic link. @@ -1305,6 +1319,7 @@ inline_mysql_file_rename( return result; } + static inline File inline_mysql_file_create_with_symlink( #ifdef HAVE_PSI_INTERFACE @@ -1334,6 +1349,38 @@ inline_mysql_file_create_with_symlink( return file; } +static inline int +inline_mysql_file_delete_with_symlink( +#ifdef HAVE_PSI_INTERFACE + PSI_file_key key, const char *src_file, uint src_line, +#endif + const char *name, const char *ext, myf flags) +{ + int result; + char fullname[FN_REFLEN]; +#ifdef HAVE_PSI_INTERFACE + struct PSI_file_locker *locker= NULL; + PSI_file_locker_state state; +#endif + fn_format(fullname, name, "", ext, MY_UNPACK_FILENAME | MY_APPEND_EXT); +#ifdef HAVE_PSI_INTERFACE + if (likely(PSI_server != NULL)) + { + locker= PSI_server->get_thread_file_name_locker(&state, key, PSI_FILE_DELETE, + fullname, &locker); + if (likely(locker != NULL)) + PSI_server->start_file_wait(locker, (size_t) 0, src_file, src_line); + } +#endif + result= my_handler_delete_with_symlink(fullname, flags); +#ifdef HAVE_PSI_INTERFACE + if (likely(locker != NULL)) + PSI_server->end_file_wait(locker, (size_t) 0); +#endif + return result; +} + + static inline int inline_mysql_file_rename_with_symlink( #ifdef HAVE_PSI_INTERFACE diff --git a/mysys/my_symlink2.c b/mysys/my_symlink2.c index 5fe7b8fcae9..c851468ce1b 100644 --- a/mysys/my_symlink2.c +++ b/mysys/my_symlink2.c @@ -170,22 +170,20 @@ int my_rename_with_symlink(const char *from, const char *to, myf MyFlags) in this case both the symlink and the symlinked file are deleted, but only if the symlinked file is not in the datadir. */ -int my_handler_delete_with_symlink(PSI_file_key key, const char *name, - const char *ext, myf sync_dir) +int my_handler_delete_with_symlink(const char *filename, myf sync_dir) { - char orig[FN_REFLEN], real[FN_REFLEN]; + char real[FN_REFLEN]; int res= 0; DBUG_ENTER("my_handler_delete_with_symlink"); - fn_format(orig, name, "", ext, MY_UNPACK_FILENAME | MY_APPEND_EXT); - if (my_is_symlink(orig)) + if (my_is_symlink(filename)) { /* Delete the symlinked file only if the symlink is not pointing into datadir. */ - if (!(my_realpath(real, orig, MYF(0)) || mysys_test_invalid_symlink(real))) - res= mysql_file_delete(key, real, MYF(MY_NOSYMLINKS | MY_WME | sync_dir)); + if (!(my_realpath(real, filename, MYF(0)) || mysys_test_invalid_symlink(real))) + res= my_delete(real, MYF(MY_NOSYMLINKS | sync_dir)); } - DBUG_RETURN(mysql_file_delete(key, orig, MYF(MY_WME | sync_dir)) || res); + DBUG_RETURN(my_delete(filename, MYF(sync_dir)) || res); } diff --git a/sql/handler.cc b/sql/handler.cc index 2ae144a86cc..dc40e34bc3d 100644 --- a/sql/handler.cc +++ b/sql/handler.cc @@ -3381,7 +3381,7 @@ int handler::delete_table(const char *name) for (const char **ext=bas_ext(); *ext ; ext++) { - if (my_handler_delete_with_symlink(key_file_misc, name, *ext, 0)) + if (mysql_file_delete_with_symlink(key_file_misc, name, *ext, 0)) { if (my_errno != ENOENT) { diff --git a/sql/sql_db.cc b/sql/sql_db.cc index 7bb4f0fa60e..580590b38a3 100644 --- a/sql/sql_db.cc +++ b/sql/sql_db.cc @@ -1085,7 +1085,7 @@ static bool find_db_tables_and_rm_known_files(THD *thd, MY_DIR *dirp, We ignore ENOENT error in order to skip files that was deleted by concurrently running statement like REPAIR TABLE ... */ - if (my_handler_delete_with_symlink(key_file_misc, filePath, "", MYF(0)) && + if (mysql_file_delete_with_symlink(key_file_misc, filePath, "", MYF(0)) && my_errno != ENOENT) { my_error(EE_DELETE, MYF(0), filePath, my_errno); @@ -1206,7 +1206,7 @@ long mysql_rm_arc_files(THD *thd, MY_DIR *dirp, const char *org_path) continue; } strxmov(filePath, org_path, "/", file->name, NullS); - if (my_handler_delete_with_symlink(key_file_misc, filePath, "", MYF(MY_WME))) + if (mysql_file_delete_with_symlink(key_file_misc, filePath, "", MYF(MY_WME))) { goto err; } diff --git a/storage/maria/ma_delete_table.c b/storage/maria/ma_delete_table.c index c4bcd5ba060..f80ec1384b3 100644 --- a/storage/maria/ma_delete_table.c +++ b/storage/maria/ma_delete_table.c @@ -86,8 +86,8 @@ int maria_delete_table_files(const char *name, myf sync_dir) { DBUG_ENTER("maria_delete_table_files"); - if (my_handler_delete_with_symlink(key_file_kfile, name, MARIA_NAME_IEXT, sync_dir) || - my_handler_delete_with_symlink(key_file_dfile, name, MARIA_NAME_DEXT, sync_dir)) + if (mysql_file_delete_with_symlink(key_file_kfile, name, MARIA_NAME_IEXT, sync_dir) || + mysql_file_delete_with_symlink(key_file_dfile, name, MARIA_NAME_DEXT, sync_dir)) DBUG_RETURN(my_errno); DBUG_RETURN(0); } diff --git a/storage/myisam/mi_delete_table.c b/storage/myisam/mi_delete_table.c index ebedfbda343..ca395ffbef5 100644 --- a/storage/myisam/mi_delete_table.c +++ b/storage/myisam/mi_delete_table.c @@ -28,8 +28,8 @@ int mi_delete_table(const char *name) check_table_is_closed(name,"delete"); #endif - if (my_handler_delete_with_symlink(mi_key_file_kfile, name, MI_NAME_IEXT, 0) || - my_handler_delete_with_symlink(mi_key_file_dfile, name, MI_NAME_DEXT, 0)) + if (mysql_file_delete_with_symlink(mi_key_file_kfile, name, MI_NAME_IEXT, 0) || + mysql_file_delete_with_symlink(mi_key_file_dfile, name, MI_NAME_DEXT, 0)) DBUG_RETURN(my_errno); DBUG_RETURN(0); } From c6ee3fe9d4056dcd6ee9f9aabd3424c1b27fc506 Mon Sep 17 00:00:00 2001 From: Sergei Golubchik Date: Wed, 19 Apr 2017 20:31:05 +0200 Subject: [PATCH 08/10] respect client's desire to force ssl even when WITH_SSL=NO of course, this combination can never succeed, we must fail to connect here. --- sql-common/client.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/sql-common/client.c b/sql-common/client.c index b348afcff2d..e0412fca6bc 100644 --- a/sql-common/client.c +++ b/sql-common/client.c @@ -1815,8 +1815,8 @@ mysql_ssl_set(MYSQL *mysql __attribute__((unused)) , mysql->options.ssl_ca= set_ssl_option_unpack_path(ca); mysql->options.ssl_capath= set_ssl_option_unpack_path(capath); mysql->options.ssl_cipher= strdup_if_not_null(cipher); - mysql->options.use_ssl= TRUE; #endif /* HAVE_OPENSSL && !EMBEDDED_LIBRARY */ + mysql->options.use_ssl= TRUE; DBUG_RETURN(0); } @@ -2563,7 +2563,6 @@ static int send_client_reply_packet(MCPVIO_EXT *mpvio, int3store(buff+2, net->max_packet_size); end= buff+5; } -#ifdef HAVE_OPENSSL /* If client uses ssl and client also has to verify the server @@ -2581,6 +2580,7 @@ static int send_client_reply_packet(MCPVIO_EXT *mpvio, goto error; } +#ifdef HAVE_OPENSSL if (mysql->client_flag & CLIENT_SSL) { /* Do the SSL layering. */ From 2e7ba70a94b5950a7d1d733c177d1b2a24916213 Mon Sep 17 00:00:00 2001 From: Igor Babaev Date: Sat, 22 Apr 2017 10:30:55 -0700 Subject: [PATCH 09/10] Fixed the bug mdev-10693. The code that chooses between materialization of a non-correlated IN subquery and its transformation into an EXISTS correlated subquery assumes that the execution plan for the outer select has been already built. However it was not always so if subqueries occurred in the expressions used for ref access to tables of the outer select. A call of the function create_ref_for_key() in get_best_combination() could trigger a premature execution of the above mentioned code when the execution plan structures for the outer select were not fully built. This could cause a crash of the server. The fix postpones the calls of create_ref_for_key() until the structures for the execution plan is fully built. --- mysql-test/r/subselect_innodb.result | 14 ++++++++++++++ mysql-test/t/subselect_innodb.test | 22 ++++++++++++++++++++++ sql/sql_select.cc | 21 +++++++++++++++------ 3 files changed, 51 insertions(+), 6 deletions(-) diff --git a/mysql-test/r/subselect_innodb.result b/mysql-test/r/subselect_innodb.result index 06cfb8b45d2..f92615f22cf 100644 --- a/mysql-test/r/subselect_innodb.result +++ b/mysql-test/r/subselect_innodb.result @@ -469,3 +469,17 @@ f1 f2 set join_cache_level = default; drop view v1; drop table t1,t2; +# +# MDEV-10693: cost-based choice between materialization and in-to-exists +# for a subquery from the expression used in ref access +# +CREATE TABLE t1 (i1 INT PRIMARY KEY) ENGINE=InnoDB; +INSERT INTO t1 VALUES (1),(2); +CREATE TABLE t2 (i2 INT) ENGINE=InnoDB; +CREATE TABLE t3 (i3 INT PRIMARY KEY) ENGINE=InnoDB; +INSERT INTO t3 VALUES (3); +SELECT * FROM t1 +WHERE NULL IN ( SELECT i2 FROM t2 +WHERE i1 IN ( i2 IN ( SELECT i3 FROM t3 ) ) AND i2 = 2 ); +i1 +DROP TABLE t1,t2,t3; diff --git a/mysql-test/t/subselect_innodb.test b/mysql-test/t/subselect_innodb.test index d764c435c82..3945c6b10b9 100644 --- a/mysql-test/t/subselect_innodb.test +++ b/mysql-test/t/subselect_innodb.test @@ -453,3 +453,25 @@ SELECT * FROM v1, t2 WHERE ( f1, f2 ) IN ( SELECT f1, f1 FROM t1 ); set join_cache_level = default; drop view v1; drop table t1,t2; + +--echo # +--echo # MDEV-10693: cost-based choice between materialization and in-to-exists +--echo # for a subquery from the expression used in ref access +--echo # + +--source include/have_innodb.inc + +CREATE TABLE t1 (i1 INT PRIMARY KEY) ENGINE=InnoDB; +INSERT INTO t1 VALUES (1),(2); + +CREATE TABLE t2 (i2 INT) ENGINE=InnoDB; + +CREATE TABLE t3 (i3 INT PRIMARY KEY) ENGINE=InnoDB; +INSERT INTO t3 VALUES (3); + +SELECT * FROM t1 + WHERE NULL IN ( SELECT i2 FROM t2 + WHERE i1 IN ( i2 IN ( SELECT i3 FROM t3 ) ) AND i2 = 2 ); + +DROP TABLE t1,t2,t3; + diff --git a/sql/sql_select.cc b/sql/sql_select.cc index d83e8e2bfce..c5f2a83fc01 100644 --- a/sql/sql_select.cc +++ b/sql/sql_select.cc @@ -7728,8 +7728,6 @@ get_best_combination(JOIN *join) join->full_join=0; join->hash_join= FALSE; - used_tables= OUTER_REF_TABLE_BIT; // Outer row is already read - fix_semijoin_strategies_for_picked_join_order(join); JOIN_TAB_RANGE *root_range; @@ -7791,7 +7789,6 @@ get_best_combination(JOIN *join) j->bush_root_tab= sjm_nest_root; form=join->table[tablenr]=j->table; - used_tables|= form->map; form->reginfo.join_tab=j; DBUG_PRINT("info",("type: %d", j->type)); if (j->type == JT_CONST) @@ -7818,9 +7815,6 @@ get_best_combination(JOIN *join) join->best_positions[tablenr].loosescan_picker.loosescan_key); j->index= join->best_positions[tablenr].loosescan_picker.loosescan_key; }*/ - - if (keyuse && create_ref_for_key(join, j, keyuse, TRUE, used_tables)) - DBUG_RETURN(TRUE); // Something went wrong if ((j->type == JT_REF || j->type == JT_EQ_REF) && is_hash_join_key_no(j->ref.key)) @@ -7845,6 +7839,21 @@ get_best_combination(JOIN *join) } root_range->end= j; + used_tables= OUTER_REF_TABLE_BIT; // Outer row is already read + for (j=join_tab, tablenr=0 ; tablenr < table_count ; tablenr++,j++) + { + if (j->bush_children) + j= j->bush_children->start; + + used_tables|= j->table->map; + if ((keyuse= join->best_positions[tablenr].key) && + create_ref_for_key(join, j, keyuse, TRUE, used_tables)) + DBUG_RETURN(TRUE); // Something went wrong + + if (j->last_leaf_in_bush) + j= j->bush_root_tab; + } + join->top_join_tab_count= join->join_tab_ranges.head()->end - join->join_tab_ranges.head()->start; /* From dbe2c3c5f21fd479fbe0993b045c0c30493ca07a Mon Sep 17 00:00:00 2001 From: Daniel Black Date: Sun, 30 Apr 2017 13:29:56 +1000 Subject: [PATCH 10/10] mysqld_safe_help - remove warning /home/travis/build/MariaDB/server/extra/mysqld_safe_helper.c:62:21: warning: too many arguments in call to 'do_usage' do_usage(argv[0]); ~~~~~~~~ ^ 1 warning generated. --- extra/mysqld_safe_helper.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/extra/mysqld_safe_helper.c b/extra/mysqld_safe_helper.c index 09e507c6e1c..2ccff20b910 100644 --- a/extra/mysqld_safe_helper.c +++ b/extra/mysqld_safe_helper.c @@ -59,7 +59,7 @@ int main(int argc, char *argv[]) MY_INIT(argv[0]); if (argc < 3) - do_usage(argv[0]); + do_usage(); user_info= my_check_user(argv[1], MYF(0)); if (user_info ? my_set_user(argv[1], user_info, MYF(MY_WME))