diff options
author | Sergei Golubchik <sergii@pisem.net> | 2011-11-22 18:51:33 +0100 |
---|---|---|
committer | Sergei Golubchik <sergii@pisem.net> | 2011-11-22 18:51:33 +0100 |
commit | feba65a55495ce5cd9f5d8e6e0af8345485b52a1 (patch) | |
tree | 092f039bd213fbd1580a89f003cfd5d5690f5a86 | |
parent | c104d31404c68b5622dc676d53308d02349755d1 (diff) | |
parent | b81d8b2e5ab7baa9623d0af002083057cda28a97 (diff) | |
download | mariadb-git-feba65a55495ce5cd9f5d8e6e0af8345485b52a1.tar.gz |
merged
1449 files changed, 30562 insertions, 9619 deletions
diff --git a/.bzrignore b/.bzrignore index 0d70e0375e1..a2947f9afe3 100644 --- a/.bzrignore +++ b/.bzrignore @@ -145,8 +145,6 @@ COPYING COPYING.LIB core core.* -CPackConfig.cmake -CPackSourceConfig.cmake cscope.in.out cscope.out cscope.po.out @@ -479,8 +477,6 @@ ma_test_recovery.output make_dist.cmake Makefile Makefile.in -maria_log.00000* -maria_log_control MinSizeRel/ MIRRORS missing @@ -1067,10 +1063,6 @@ vio/test-sslserver vio/viotest-ssl vio/viotest-sslconnect.cpp vio/viotest.cpp -win/configure.data -win/vs71cache.txt -win/vs8cache.txt -win/nmake_cache.txt ylwrap zlib/*.ds? sql-bench/test-table-elimination @@ -1098,6 +1090,8 @@ sql/share/slovak sql/share/spanish sql/share/swedish sql/share/ukrainian +CPackConfig.cmake +CPackSourceConfig.cmake Docs/INFO_BIN Docs/INFO_SRC tags @@ -1123,7 +1117,6 @@ storage/pbxt/bin/xtstat libmysqld/sql_expression_cache.cc mysql-test/mtr_command scripts/convert-debug-for-diff -plugin/handler_socket/client/hsclient client/strings_def.h libmysql/strings_def.h libmysql_r/strings_def.h @@ -1131,3 +1124,11 @@ storage/maria/aria_log_control scripts/mytop include/*.h.tmp cmd-line-utils/libedit/emacs.h +mysql-test/collections/default.release +support-files/plugins.files +client/mysql_plugin +plugin/handler_socket/perl-Net-HandlerSocket/HandlerSocket.c +plugin/handler_socket/perl-Net-HandlerSocket/blib +plugin/handler_socket/perl-Net-HandlerSocket/pm_to_blib +plugin/handler_socket/perl-Net-HandlerSocket/HandlerSocket.bs +plugin/handler_socket/perl-Net-HandlerSocket/Makefile.PL diff --git a/BUILD-CMAKE b/BUILD-CMAKE index 68c40167da5..2f46a4581f9 100644 --- a/BUILD-CMAKE +++ b/BUILD-CMAKE @@ -1,3 +1,5 @@ +Copyright (c) 2009, 2010 Sun Microsystems, Inc. + How to Build MySQL server with CMake WHAT YOU NEED diff --git a/BUILD/FINISH.sh b/BUILD/FINISH.sh index 3c30485ec5e..fb4add74d8b 100644 --- a/BUILD/FINISH.sh +++ b/BUILD/FINISH.sh @@ -1,4 +1,4 @@ -# Copyright (C) 2000, 2005 MySQL AB, 2008 Sun Microsystems, Inc. +# Copyright (c) 2000, 2010, Oracle and/or its affiliates. All rights reserved. # # This program is free software; you can redistribute it and/or # modify it under the terms of the GNU Library General Public @@ -12,8 +12,8 @@ # # You should have received a copy of the GNU Library General Public # License along with this library; if not, write to the Free -# Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, -# MA 02111-1307, USA +# Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, +# MA 02110-1301, USA cflags="$c_warnings $extra_flags $EXTRA_FLAGS $EXTRA_CFLAGS" cxxflags="$cxx_warnings $base_cxxflags $extra_flags $EXTRA_FLAGS $EXTRA_CXXFLAGS" diff --git a/BUILD/autorun.sh b/BUILD/autorun.sh index e9d92c4ebae..1d7cf5561ad 100755 --- a/BUILD/autorun.sh +++ b/BUILD/autorun.sh @@ -1,6 +1,6 @@ #!/bin/sh -# Copyright (C) 2005 MySQL AB +# Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved. # # This program is free software; you can redistribute it and/or # modify it under the terms of the GNU Library General Public @@ -14,8 +14,8 @@ # # You should have received a copy of the GNU Library General Public # License along with this library; if not, write to the Free -# Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, -# MA 02111-1307, USA +# Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, +# MA 02110-1301, USA # Create MySQL cmake configure wrapper diff --git a/BUILD/build_mccge.sh b/BUILD/build_mccge.sh index 057e21ad02f..78e5350dc1b 100755 --- a/BUILD/build_mccge.sh +++ b/BUILD/build_mccge.sh @@ -15,8 +15,8 @@ # # You should have received a copy of the GNU Library General Public # License along with this library; if not, write to the Free -# Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, -# MA 02111-1307, USA +# Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, +# MA 02110-1301, USA die() { diff --git a/BUILD/cmake_configure.sh b/BUILD/cmake_configure.sh index 887408f9bfa..668d6a81b5c 100644 --- a/BUILD/cmake_configure.sh +++ b/BUILD/cmake_configure.sh @@ -1,6 +1,6 @@ #!/bin/sh -# Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved. +# Copyright (c) 2009, 2010, Oracle and/or its affiliates. All rights reserved. # # This program is free software; you can redistribute it and/or # modify it under the terms of the GNU Library General Public @@ -14,8 +14,8 @@ # # You should have received a copy of the GNU Library General Public # License along with this library; if not, write to the Free -# Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, -# MA 02111-1307, USA +# Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, +# MA 02110-1301, USA # Ensure cmake and perl are there cmake -P cmake/check_minimal_version.cmake >/dev/null 2>&1 || HAVE_CMAKE=no diff --git a/BUILD/compile-ia64-debug-max b/BUILD/compile-ia64-debug-max index 85807e3752e..508cadf73e2 100755 --- a/BUILD/compile-ia64-debug-max +++ b/BUILD/compile-ia64-debug-max @@ -1,6 +1,6 @@ #! /bin/sh -# Copyright (C) 2001, 2005 MySQL AB +# Copyright (c) 2001, 2010, Oracle and/or its affiliates. All rights reserved. # # 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 @@ -13,7 +13,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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA gmake -k maintainer-clean || true /bin/rm -f */.deps/*.P config.cache storage/innobase/config.cache diff --git a/BUILD/compile-pentium-debug b/BUILD/compile-pentium-debug index 83de3c68152..faeb1b89597 100755 --- a/BUILD/compile-pentium-debug +++ b/BUILD/compile-pentium-debug @@ -1,6 +1,6 @@ #! /bin/sh -# Copyright (C) 2000, 2007 MySQL AB +# Copyright (c) 2000, 2010, Oracle and/or its affiliates. All rights reserved. # # 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 @@ -13,7 +13,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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA path=`dirname $0` . "$path/SETUP.sh" diff --git a/BUILD/compile-pentium-debug-max b/BUILD/compile-pentium-debug-max index 37e4a30337b..0c925d8426f 100755 --- a/BUILD/compile-pentium-debug-max +++ b/BUILD/compile-pentium-debug-max @@ -1,6 +1,6 @@ #! /bin/sh -# Copyright (C) 2001, 2007 MySQL AB +# Copyright (c) 2001, 2010, Oracle and/or its affiliates. All rights reserved. # # 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 @@ -13,7 +13,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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA path=`dirname $0` . "$path/SETUP.sh" diff --git a/BUILD/compile-pentium-debug-openssl b/BUILD/compile-pentium-debug-openssl index 67e2327cb08..abf6b41a2d2 100755 --- a/BUILD/compile-pentium-debug-openssl +++ b/BUILD/compile-pentium-debug-openssl @@ -1,6 +1,6 @@ #! /bin/sh -# Copyright (C) 2001, 2003 MySQL AB +# Copyright (c) 2001, 2010, Oracle and/or its affiliates. All rights reserved. # # 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 @@ -13,7 +13,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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA path=`dirname $0` . "$path/SETUP.sh" diff --git a/BUILD/compile-pentium-debug-yassl b/BUILD/compile-pentium-debug-yassl index 29242a6853b..e8cfff6cb07 100755 --- a/BUILD/compile-pentium-debug-yassl +++ b/BUILD/compile-pentium-debug-yassl @@ -1,6 +1,6 @@ #! /bin/sh -# Copyright (C) 2005 MySQL AB +# Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved. # # 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 @@ -13,7 +13,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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA path=`dirname $0` . "$path/SETUP.sh" diff --git a/BUILD/compile-pentium-icc-valgrind-max b/BUILD/compile-pentium-icc-valgrind-max index ebefb1b3fd0..b26df4b1bd6 100755 --- a/BUILD/compile-pentium-icc-valgrind-max +++ b/BUILD/compile-pentium-icc-valgrind-max @@ -1,6 +1,6 @@ #! /bin/sh -# Copyright (C) 2005 MySQL AB +# Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved. # # 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 @@ -13,7 +13,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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA path=`dirname $0` . "$path/SETUP.sh" diff --git a/BUILD/compile-pentium-valgrind-max b/BUILD/compile-pentium-valgrind-max index ef4d7267e5f..7a2c6ae4980 100755 --- a/BUILD/compile-pentium-valgrind-max +++ b/BUILD/compile-pentium-valgrind-max @@ -1,6 +1,6 @@ #! /bin/sh -# Copyright (C) 2002, 2005 MySQL AB +# Copyright (c) 2002, 2010, Oracle and/or its affiliates. All rights reserved. # # 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 @@ -13,7 +13,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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA path=`dirname $0` . "$path/SETUP.sh" diff --git a/BUILD/compile-pentium64-debug b/BUILD/compile-pentium64-debug index 01c15836a54..74909c346ec 100755 --- a/BUILD/compile-pentium64-debug +++ b/BUILD/compile-pentium64-debug @@ -1,6 +1,6 @@ #! /bin/sh -# Copyright (C) 2005, 2007 MySQL AB +# Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved. # # 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 @@ -13,7 +13,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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA path=`dirname $0` . "$path/SETUP.sh" diff --git a/BUILD/compile-pentium64-debug-max b/BUILD/compile-pentium64-debug-max index 375f15e9908..49a9c7daf3a 100755 --- a/BUILD/compile-pentium64-debug-max +++ b/BUILD/compile-pentium64-debug-max @@ -1,6 +1,6 @@ #! /bin/sh -# Copyright (C) 2005, 2007 MySQL AB +# Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved. # # 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 @@ -13,7 +13,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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA path=`dirname $0` . "$path/SETUP.sh" diff --git a/BUILD/compile-pentium64-valgrind-max b/BUILD/compile-pentium64-valgrind-max index e29fa64d261..cec7f734ef5 100755 --- a/BUILD/compile-pentium64-valgrind-max +++ b/BUILD/compile-pentium64-valgrind-max @@ -1,6 +1,6 @@ #! /bin/sh -# Copyright (C) 2005 MySQL AB +# Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved. # # 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 @@ -13,7 +13,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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA path=`dirname $0` . "$path/SETUP.sh" diff --git a/BUILD/compile-solaris-sparc-forte b/BUILD/compile-solaris-sparc-forte index 087fe22a591..14cb3ce1ff9 100755 --- a/BUILD/compile-solaris-sparc-forte +++ b/BUILD/compile-solaris-sparc-forte @@ -1,6 +1,7 @@ #! /bin/sh -# Copyright (C) 2001, 2005 MySQL AB +# Copyright (c) 2001, 2002, 2005, 2007 MySQL AB, 2008 Sun Microsystems, Inc. +# Use is subject to license terms. # # 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 @@ -13,7 +14,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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA # Assume Forte is installed in /opt/SUNWSpro and ld is installed in # /usr/ccs/bin @@ -1,4 +1,4 @@ MYSQL_VERSION_MAJOR=5 MYSQL_VERSION_MINOR=5 -MYSQL_VERSION_PATCH=15 +MYSQL_VERSION_PATCH=18 MYSQL_VERSION_EXTRA=-MariaDB diff --git a/client/CMakeLists.txt b/client/CMakeLists.txt index 97fb4289872..25ae9370829 100644 --- a/client/CMakeLists.txt +++ b/client/CMakeLists.txt @@ -55,6 +55,9 @@ ADD_DEPENDENCIES(mysql_upgrade GenFixPrivs) MYSQL_ADD_EXECUTABLE(mysqlshow mysqlshow.c) TARGET_LINK_LIBRARIES(mysqlshow mysqlclient) +MYSQL_ADD_EXECUTABLE(mysql_plugin mysql_plugin.c) +TARGET_LINK_LIBRARIES(mysql_plugin mysqlclient) + MYSQL_ADD_EXECUTABLE(mysqlbinlog mysqlbinlog.cc) TARGET_LINK_LIBRARIES(mysqlbinlog mysqlclient) @@ -70,7 +73,7 @@ IF(WIN32) MYSQL_ADD_EXECUTABLE(echo echo.c) ENDIF(WIN32) -SET_TARGET_PROPERTIES (mysqlcheck mysqldump mysqlimport mysql_upgrade mysqlshow mysqlslap +SET_TARGET_PROPERTIES (mysqlcheck mysqldump mysqlimport mysql_upgrade mysqlshow mysqlslap mysql_plugin PROPERTIES HAS_CXX TRUE) ADD_DEFINITIONS(-DHAVE_DLOPEN) diff --git a/client/client_priv.h b/client/client_priv.h index d6fe90b2644..607bd3997c1 100644 --- a/client/client_priv.h +++ b/client/client_priv.h @@ -1,4 +1,5 @@ -/* Copyright (C) 2001-2006 MySQL AB, 2009 Sun Microsystems, Inc +/* + Copyright (c) 2001, 2011, Oracle and/or its affiliates. All rights reserved. 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 @@ -11,7 +12,8 @@ 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +*/ /* Common defines for all clients */ diff --git a/client/completion_hash.cc b/client/completion_hash.cc index dc7f0329db8..9ffb2082c06 100644 --- a/client/completion_hash.cc +++ b/client/completion_hash.cc @@ -1,4 +1,4 @@ -/* Copyright (C) 2000 MySQL AB +/* Copyright (c) 2000, 2010, Oracle and/or its affiliates. All rights reserved. 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 @@ -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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ /* Quick & light hash implementation for tab completion purposes * diff --git a/client/my_readline.h b/client/my_readline.h index 276e279f43d..d288a33e1cc 100644 --- a/client/my_readline.h +++ b/client/my_readline.h @@ -1,7 +1,8 @@ #ifndef CLIENT_MY_READLINE_INCLUDED #define CLIENT_MY_READLINE_INCLUDED -/* Copyright (C) 2000 MySQL AB +/* + Copyright (c) 2000, 2011, Oracle and/or its affiliates. All rights reserved. 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 @@ -14,7 +15,8 @@ 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +*/ /* readline for batch mode */ diff --git a/client/mysql.cc b/client/mysql.cc index b66b4263f54..5debadee26c 100644 --- a/client/mysql.cc +++ b/client/mysql.cc @@ -13,7 +13,8 @@ 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +*/ /* mysql command tool * Commands compatible with mSQL by David J. Hughes @@ -45,7 +46,7 @@ #include <locale.h> #endif -const char *VER= "15.0"; +const char *VER= "15.1"; /* Don't try to make a nice table if the data is too big */ #define MAX_COLUMN_LENGTH 1024 @@ -1189,7 +1190,7 @@ int main(int argc,char *argv[]) mysql_thread_id(&mysql), server_version_string(&mysql)); put_info((char*) glob_buffer.ptr(),INFO_INFO); - put_info(ORACLE_WELCOME_COPYRIGHT_NOTICE("2000, 2010"), INFO_INFO); + put_info(ORACLE_WELCOME_COPYRIGHT_NOTICE("2000, 2011"), INFO_INFO); #ifdef HAVE_READLINE initialize_readline((char*) my_progname); @@ -1620,7 +1621,7 @@ static void usage(int version) if (version) return; - puts(ORACLE_WELCOME_COPYRIGHT_NOTICE("2000, 2010")); + puts(ORACLE_WELCOME_COPYRIGHT_NOTICE("2000, 2011")); printf("Usage: %s [OPTIONS] [database]\n", my_progname); my_print_help(my_long_options); print_defaults("my", load_default_groups); @@ -2249,7 +2250,7 @@ static bool add_line(String &buffer,char *line,char *in_string, break; } else if (!*in_string && inchar == '/' && *(pos+1) == '*' && - *(pos+2) != '!') + !(*(pos+2) == '!' || (*(pos+2) == 'M' && *(pos+3) == '!'))) { if (preserve_comments) { @@ -4409,7 +4410,7 @@ sql_real_connect(char *host,char *database,char *user,char *password, { char init_command[100]; sprintf(init_command, - "SET SQL_SAFE_UPDATES=1,SQL_SELECT_LIMIT=%lu,SQL_MAX_JOIN_SIZE=%lu", + "SET SQL_SAFE_UPDATES=1,SQL_SELECT_LIMIT=%lu,MAX_JOIN_SIZE=%lu", select_limit,max_join_size); mysql_options(&mysql, MYSQL_INIT_COMMAND, init_command); } diff --git a/client/mysql_plugin.c b/client/mysql_plugin.c new file mode 100644 index 00000000000..825c962c486 --- /dev/null +++ b/client/mysql_plugin.c @@ -0,0 +1,1202 @@ +/* + Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved. + + 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 + the Free Software Foundation; version 2 of the License. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +*/ + +#include <m_string.h> +#include <mysql.h> +#include <my_getopt.h> +#include <my_dir.h> +#include <my_global.h> +#include <stdio.h> +#include <string.h> + + +#define SHOW_VERSION "1.0.0" +#define PRINT_VERSION do { printf("%s Ver %s Distrib %s\n", \ + my_progname, SHOW_VERSION, MYSQL_SERVER_VERSION); \ + } while(0) + +/* Global variables. */ +static uint my_end_arg= 0; +static uint opt_verbose=0; +static uint opt_no_defaults= 0; +static uint opt_print_defaults= 0; +static char *opt_datadir=0, *opt_basedir=0, + *opt_plugin_dir=0, *opt_plugin_ini=0, + *opt_mysqld=0, *opt_my_print_defaults=0; +static char bootstrap[FN_REFLEN]; + + +/* plugin struct */ +struct st_plugin +{ + const char *name; /* plugin name */ + const char *so_name; /* plugin so (library) name */ + const char *components[16]; /* components to load */ +} plugin_data; + + +/* Options */ +static struct my_option my_long_options[] = +{ + {"help", '?', "Display this help and exit.", 0, 0, 0, GET_NO_ARG, NO_ARG, + 0, 0, 0, 0, 0, 0}, + {"basedir", 'b', "The basedir for the server.", + 0, 0, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, + {"datadir", 'd', "The datadir for the server.", + 0, 0, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, + {"plugin-dir", 'p', "The plugin dir for the server.", + 0, 0, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, + {"plugin-ini", 'i', "Read plugin information from configuration file " + "specified instead of from <plugin-dir>/<plugin_name>.ini.", + 0, 0, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, + {"no-defaults", 'n', "Do not read values from configuration file.", + 0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0}, + {"print-defaults", 'P', "Show default values from configuration file.", + 0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0}, + {"mysqld", 'm', "Path to mysqld executable. Example: /sbin/temp1/mysql/bin", + 0, 0, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, + {"my-print-defaults", 'f', "Path to my_print_defaults executable. " + "Example: /source/temp11/extra", + 0, 0, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, + {"verbose", 'v', + "More verbose output; you can use this multiple times to get even more " + "verbose output.", + 0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0}, + {"version", 'V', "Output version information and exit.", 0, 0, 0, GET_NO_ARG, + NO_ARG, 0, 0, 0, 0, 0, 0}, + {0, 0, 0, 0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0} +}; + + +/* Methods */ +static int process_options(int argc, char *argv[], char *operation); +static int check_access(); +static int find_tool(const char *tool_name, char *tool_path); +static int find_plugin(char *tp_path); +static int build_bootstrap_file(char *operation, char *bootstrap); +static int dump_bootstrap_file(char *bootstrap_file); +static int bootstrap_server(char *server_path, char *bootstrap_file); + + +int main(int argc,char *argv[]) +{ + int error= 0; + char tp_path[FN_REFLEN]; + char server_path[FN_REFLEN]; + char operation[16]; + + MY_INIT(argv[0]); + plugin_data.name= 0; // initialize name + + /* + The following operations comprise the method for enabling or disabling + a plugin. We begin by processing the command options then check the + directories specified for --datadir, --basedir, --plugin-dir, and + --plugin-ini (if specified). If the directories are Ok, we then look + for the mysqld executable and the plugin soname. Finally, we build a + bootstrap command file for use in bootstraping the server. + + If any step fails, the method issues an error message and the tool exits. + + 1) Parse, execute, and verify command options. + 2) Check access to directories. + 3) Look for mysqld executable. + 4) Look for the plugin. + 5) Build a bootstrap file with commands to enable or disable plugin. + + */ + if ((error= process_options(argc, argv, operation)) || + (error= check_access()) || + (error= find_tool("mysqld" FN_EXEEXT, server_path)) || + (error= find_plugin(tp_path)) || + (error= build_bootstrap_file(operation, bootstrap))) + goto exit; + + /* Dump the bootstrap file if --verbose specified. */ + if (opt_verbose && ((error= dump_bootstrap_file(bootstrap)))) + goto exit; + + /* Start the server in bootstrap mode and execute bootstrap commands */ + error= bootstrap_server(server_path, bootstrap); + +exit: + /* Remove file */ + my_delete(bootstrap, MYF(0)); + if (opt_verbose && error == 0) + { + printf("# Operation succeeded.\n"); + } + + my_end(my_end_arg); + exit(error ? 1 : 0); + return 0; /* No compiler warnings */ +} + + +/** + Get a temporary file name. + + @param[out] filename The file name of the temporary file + @param[in] ext An extension for the file (optional) + + @retval int error = 1, success = 0 +*/ + +static int make_tempfile(char *filename, const char *ext) +{ + int fd= 0; + + if ((fd=create_temp_file(filename, NullS, ext, O_CREAT | O_WRONLY, + MYF(MY_WME))) < 0) + { + fprintf(stderr, "ERROR: Cannot generate temporary file. Error code: %d.\n", + fd); + return 1; + } + my_close(fd, MYF(0)); + return 0; +} + + +/** + Get the value of an option from a string read from my_print_defaults output. + + @param[in] line The line (string) read from the file + @param[in] item The option to search for (e.g. --datadir) + + @returns NULL if not found, string containing value if found +*/ + +static char *get_value(char *line, const char *item) +{ + char *destination= 0; + int item_len= (int)strlen(item); + int line_len = (int)strlen(line); + + if ((strncasecmp(line, item, item_len) == 0)) + { + int start= 0; + char *s= 0; + + s = line + item_len + 1; + destination= my_strndup(s, line_len - start, MYF(MY_FAE)); + destination[line_len - item_len - 2]= 0; + } + return destination; +} + + +/** + Run a command in a shell. + + This function will attempt to execute the command specified by using the + popen() method to open a shell and execute the command passed and store the + output in a result file. If the --verbose option was specified, it will open + the result file and print the contents to stdout. + + @param[in] cmd The command to execute. + @param[in] mode The mode for popen() (e.g. "r", "w", "rw") + + @return int error code or 0 for success. +*/ + +static int run_command(char* cmd, const char *mode) +{ + char buf[512]= {0}; + FILE *res_file; + int error; + + if (!(res_file= popen(cmd, mode))) + return -1; + + if (opt_verbose) + { + while (fgets(buf, sizeof(buf), res_file)) + { + fprintf(stdout, "%s", buf); + } + } + error= pclose(res_file); + return error; +} + + +#ifdef __WIN__ +/** + Check to see if there are spaces in a path. + + @param[in] path The Windows path to examine. + + @retval int spaces found = 1, no spaces = 0 +*/ +static int has_spaces(const char *path) +{ + if (strchr(path, ' ') != NULL) + return 1; + return 0; +} + + +/** + Convert a Unix path to a Windows path. + + @param[in] path The Windows path to examine. + + @returns string containing path with / changed to \\ +*/ +static char *convert_path(const char *argument) +{ + /* Convert / to \\ to make Windows paths */ + char *winfilename= my_strdup(argument, MYF(MY_FAE)); + char *pos, *end; + int length= strlen(argument); + + for (pos= winfilename, end= pos+length ; pos < end ; pos++) + { + if (*pos == '/') + { + *pos= '\\'; + } + } + return winfilename; +} + + +/** + Add quotes if the path has spaces in it. + + @param[in] path The Windows path to examine. + + @returns string containing excaped quotes if spaces found in path +*/ +static char *add_quotes(const char *path) +{ + char windows_cmd_friendly[FN_REFLEN]; + + if (has_spaces(path)) + snprintf(windows_cmd_friendly, sizeof(windows_cmd_friendly), + "\"%s\"", path); + else + snprintf(windows_cmd_friendly, sizeof(windows_cmd_friendly), + "%s", path); + return my_strdup(windows_cmd_friendly, MYF(MY_FAE)); +} +#endif + + +/** + Get the default values from the my.cnf file. + + This method gets the default values for the following parameters: + + --datadir + --basedir + --plugin-dir + --plugin-ini + + These values are used if the user has not specified a value. + + @retval int error = 1, success = 0 +*/ + +static int get_default_values() +{ + char tool_path[FN_REFLEN]; + char defaults_cmd[FN_REFLEN]; + char defaults_file[FN_REFLEN]; + char line[FN_REFLEN]; + int error= 0; + int ret= 0; + FILE *file= 0; + + bzero(tool_path, FN_REFLEN); + if ((error= find_tool("my_print_defaults" FN_EXEEXT, tool_path))) + goto exit; + else + { + if ((error= make_tempfile(defaults_file, "txt"))) + goto exit; + +#ifdef __WIN__ + { + char *format_str= 0; + + if (has_spaces(tool_path) || has_spaces(defaults_file)) + format_str = "\"%s mysqld > %s\""; + else + format_str = "%s mysqld > %s"; + + snprintf(defaults_cmd, sizeof(defaults_cmd), format_str, + add_quotes(tool_path), add_quotes(defaults_file)); + if (opt_verbose) + { + printf("# my_print_defaults found: %s\n", tool_path); + } + } +#else + snprintf(defaults_cmd, sizeof(defaults_cmd), + "%s mysqld > %s", tool_path, defaults_file); +#endif + + /* Execute the command */ + if (opt_verbose) + { + printf("# Command: %s\n", defaults_cmd); + } + error= run_command(defaults_cmd, "r"); + if (error) + { + fprintf(stderr, "ERROR: my_print_defaults failed. Error code: %d.\n", + ret); + goto exit; + } + /* Now open the file and read the defaults we want. */ + file= fopen(defaults_file, "r"); + while (fgets(line, FN_REFLEN, file) != NULL) + { + char *value= 0; + + if ((opt_datadir == 0) && ((value= get_value(line, "--datadir")))) + { + opt_datadir= my_strdup(value, MYF(MY_FAE)); + } + if ((opt_basedir == 0) && ((value= get_value(line, "--basedir")))) + { + opt_basedir= my_strdup(value, MYF(MY_FAE)); + } + if ((opt_plugin_dir == 0) && ((value= get_value(line, "--plugin_dir")))) + { + opt_plugin_dir= my_strdup(value, MYF(MY_FAE)); + } + if ((opt_plugin_ini == 0) && ((value= get_value(line, "--plugin_ini")))) + { + opt_plugin_ini= my_strdup(value, MYF(MY_FAE)); + } + } + } +exit: + if (file) + { + fclose(file); + /* Remove file */ + my_delete(defaults_file, MYF(0)); + } + return error; +} + + +/** + Print usage. +*/ + +static void usage(void) +{ + PRINT_VERSION; + puts("Copyright (c) 2011, Oracle and/or its affiliates. " + "All rights reserved.\n"); + puts("Enable or disable plugins."); + printf("\nUsage: %s [options] <plugin> ENABLE|DISABLE\n\nOptions:\n", + my_progname); + my_print_help(my_long_options); + puts("\n"); +} + + +/** + Print the default values as read from the my.cnf file. + + This method displays the default values for the following parameters: + + --datadir + --basedir + --plugin-dir + --plugin-ini + +*/ + +static void print_default_values(void) +{ + printf("%s would have been started with the following arguments:\n", + my_progname); + get_default_values(); + if (opt_datadir) + { + printf("--datadir=%s ", opt_datadir); + } + if (opt_basedir) + { + printf("--basedir=%s ", opt_basedir); + } + if (opt_plugin_dir) + { + printf("--plugin_dir=%s ", opt_plugin_dir); + } + if (opt_plugin_ini) + { + printf("--plugin_ini=%s ", opt_plugin_ini); + } + if (opt_mysqld) + { + printf("--mysqld=%s ", opt_mysqld); + } + if (opt_my_print_defaults) + { + printf("--my_print_defaults=%s ", opt_my_print_defaults); + } + printf("\n"); +} + + +/** + Process the arguments and identify an option and store its value. + + @param[in] optid The single character shortcut for the argument. + @param[in] my_option Structure of legal options. + @param[in] argument The argument value to process. +*/ + +static my_bool +get_one_option(int optid, + const struct my_option *opt __attribute__((unused)), + char *argument) +{ + switch(optid) { + case 'n': + opt_no_defaults++; + break; + case 'P': + opt_print_defaults++; + print_default_values(); + break; + case 'v': + opt_verbose++; + break; + case 'V': + PRINT_VERSION; + exit(0); + break; + case '?': + case 'I': /* Info */ + usage(); + exit(0); + case 'd': + opt_datadir= my_strdup(argument, MYF(MY_FAE)); + break; + case 'b': + opt_basedir= my_strdup(argument, MYF(MY_FAE)); + break; + case 'p': + opt_plugin_dir= my_strdup(argument, MYF(MY_FAE)); + break; + case 'i': + opt_plugin_ini= my_strdup(argument, MYF(MY_FAE)); + break; + case 'm': + opt_mysqld= my_strdup(argument, MYF(MY_FAE)); + break; + case 'f': + opt_my_print_defaults= my_strdup(argument, MYF(MY_FAE)); + break; + } + return 0; +} + + +/** + Check to see if a file exists. + + @param[in] filename File to locate. + + @retval int file not found = 1, file found = 0 +*/ + +static int file_exists(char * filename) +{ + MY_STAT stat_arg; + + if (!my_stat(filename, &stat_arg, MYF(0))) + { + return 0; + } + return 1; +} + + +/** + Search a specific path and sub directory for a file name. + + @param[in] base_path Original path to use. + @param[in] tool_name Name of the tool to locate. + @param[in] subdir The sub directory to search. + @param[out] tool_path If tool found, return complete path. + + @retval int error = 1, success = 0 +*/ + +static int search_dir(const char * base_path, const char *tool_name, + const char *subdir, char *tool_path) +{ + char new_path[FN_REFLEN]; + char source_path[FN_REFLEN]; + + strcpy(source_path, base_path); + strcat(source_path, subdir); + fn_format(new_path, tool_name, source_path, "", MY_UNPACK_FILENAME); + if (file_exists(new_path)) + { + strcpy(tool_path, new_path); + return 1; + } + return 0; +} + + +/** + Search known common paths and sub directories for a file name. + + @param[in] base_path Original path to use. + @param[in] tool_name Name of the tool to locate. + @param[out] tool_path If tool found, return complete path. + + @retval int error = 1, success = 0 +*/ + +static int search_paths(const char *base_path, const char *tool_name, + char *tool_path) +{ + int i= 0; + + static const char *paths[]= { + "", "/share/", "/scripts/", "/bin/", "/sbin/", "/libexec/", + "/mysql/", "/sql/", + }; + for (i = 0 ; i < (int)array_elements(paths); i++) + { + if (search_dir(base_path, tool_name, paths[i], tool_path)) + { + return 1; + } + } + return 0; +} + + +/** + Read the plugin ini file. + + This function attempts to read the plugin config file from the plugin_dir + path saving the data in the the st_plugin structure. If the file is not + found or the file cannot be read, an error is generated. + + @retval int error = 1, success = 0 +*/ + +static int load_plugin_data(char *plugin_name, char *config_file) +{ + FILE *file_ptr; + char path[FN_REFLEN]; + char line[1024]; + char *reason= 0; + char *res; + int i= -1; + + if (opt_plugin_ini == 0) + { + fn_format(path, config_file, opt_plugin_dir, "", MYF(0)); + opt_plugin_ini= my_strdup(path, MYF(MY_FAE)); + } + if (!file_exists(opt_plugin_ini)) + { + reason= (char *)"File does not exist."; + goto error; + } + + file_ptr= fopen(opt_plugin_ini, "r"); + if (file_ptr == NULL) + { + reason= (char *)"Cannot open file."; + goto error; + } + + /* save name */ + plugin_data.name= my_strdup(plugin_name, MYF(MY_WME)); + + /* Read plugin components */ + while (i < 16) + { + res= fgets(line, sizeof(line), file_ptr); + /* strip /n */ + if (line[strlen(line)-1] == '\n') + { + line[strlen(line)-1]= '\0'; + } + if (res == NULL) + { + if (i < 1) + { + reason= (char *)"Bad format in plugin configuration file."; + fclose(file_ptr); + goto error; + } + break; + } + if ((line[0] == '#') || (line[0] == '\n')) // skip comment and blank lines + { + continue; + } + if (i == -1) // if first pass, read this line as so_name + { + /* Add proper file extension for soname */ + strcat(line, FN_SOEXT); + /* save so_name */ + plugin_data.so_name= my_strdup(line, MYF(MY_WME|MY_ZEROFILL)); + i++; + } + else + { + if (strlen(line) > 0) + { + plugin_data.components[i]= my_strdup(line, MYF(MY_WME)); + i++; + } + else + { + plugin_data.components[i]= NULL; + } + } + } + + fclose(file_ptr); + return 0; + +error: + fprintf(stderr, "ERROR: Cannot read plugin config file %s. %s\n", + plugin_name, reason); + return 1; +} + + +/** + Check the options for validity. + + This function checks the arguments for validity issuing the appropriate + error message if arguments are missing or invalid. On success, @operation + is set to either "ENABLE" or "DISABLE". + + @param[in] argc The number of arguments. + @param[in] argv The arguments. + @param[out] operation The operation chosen (enable|disable) + + @retval int error = 1, success = 0 +*/ + +static int check_options(int argc, char **argv, char *operation) +{ + int i= 0; // loop counter + int num_found= 0; // number of options found (shortcut loop) + char config_file[FN_REFLEN]; // configuration file name + char plugin_name[FN_REFLEN]; // plugin name + + /* Form prefix strings for the options. */ + const char *basedir_prefix = "--basedir="; + int basedir_len= strlen(basedir_prefix); + const char *datadir_prefix = "--datadir="; + int datadir_len= strlen(datadir_prefix); + const char *plugin_dir_prefix = "--plugin_dir="; + int plugin_dir_len= strlen(plugin_dir_prefix); + + strcpy(plugin_name, ""); + for (i = 0; i < argc && num_found < 5; i++) + { + + if (!argv[i]) + { + continue; + } + if ((strcasecmp(argv[i], "ENABLE") == 0) || + (strcasecmp(argv[i], "DISABLE") == 0)) + { + strcpy(operation, argv[i]); + num_found++; + } + else if ((strncasecmp(argv[i], basedir_prefix, basedir_len) == 0) && + !opt_basedir) + { + opt_basedir= my_strndup(argv[i]+basedir_len, + strlen(argv[i])-basedir_len, MYF(MY_FAE)); + num_found++; + } + else if ((strncasecmp(argv[i], datadir_prefix, datadir_len) == 0) && + !opt_datadir) + { + opt_datadir= my_strndup(argv[i]+datadir_len, + strlen(argv[i])-datadir_len, MYF(MY_FAE)); + num_found++; + } + else if ((strncasecmp(argv[i], plugin_dir_prefix, plugin_dir_len) == 0) && + !opt_plugin_dir) + { + opt_plugin_dir= my_strndup(argv[i]+plugin_dir_len, + strlen(argv[i])-plugin_dir_len, MYF(MY_FAE)); + num_found++; + } + /* read the plugin config file and check for match against argument */ + else + { + strcpy(plugin_name, argv[i]); + strcpy(config_file, argv[i]); + strcat(config_file, ".ini"); + } + } + + if (!opt_basedir) + { + fprintf(stderr, "ERROR: Missing --basedir option.\n"); + return 1; + } + + if (!opt_datadir) + { + fprintf(stderr, "ERROR: Missing --datadir option.\n"); + return 1; + } + + if (!opt_plugin_dir) + { + fprintf(stderr, "ERROR: Missing --plugin_dir option.\n"); + return 1; + } + /* If a plugin was specified, read the config file. */ + else if (strlen(plugin_name) > 0) + { + if (load_plugin_data(plugin_name, config_file)) + { + return 1; + } + if (strcasecmp(plugin_data.name, plugin_name) != 0) + { + fprintf(stderr, "ERROR: plugin name requested does not match config " + "file data.\n"); + return 1; + } + } + else + { + fprintf(stderr, "ERROR: No plugin specified.\n"); + return 1; + } + + if ((strlen(operation) == 0)) + { + fprintf(stderr, "ERROR: missing operation. Please specify either " + "'<plugin> ENABLE' or '<plugin> DISABLE'.\n"); + return 1; + } + + return 0; +} + + +/** + Parse, execute, and verify command options. + + This method handles all of the option processing including the optional + features for displaying data (--print-defaults, --help ,etc.) that do not + result in an attempt to ENABLE or DISABLE of a plugin. + + @param[in] arc Count of arguments + @param[in] argv Array of arguments + @param[out] operation Operation (ENABLE or DISABLE) + + @retval int error = 1, success = 0, exit program = -1 +*/ + +static int process_options(int argc, char *argv[], char *operation) +{ + int error= 0; + int i= 0; + + /* Parse and execute command-line options */ + if ((error= handle_options(&argc, &argv, my_long_options, get_one_option))) + goto exit; + + /* If the print defaults option used, exit. */ + if (opt_print_defaults) + { + error= -1; + goto exit; + } + + /* Add a trailing directory separator if not present */ + if (opt_basedir) + { + i= (int)strlength(opt_basedir); + if (opt_basedir[i-1] != FN_LIBCHAR || opt_basedir[i-1] != FN_LIBCHAR2) + { + char buff[FN_REFLEN]; + + strncpy(buff, opt_basedir, sizeof(buff) - 1); +#ifdef __WIN__ + strncat(buff, "/", sizeof(buff) - strlen(buff) - 1); +#else + strncat(buff, FN_DIRSEP, sizeof(buff) - strlen(buff) - 1); +#endif + buff[sizeof(buff) - 1]= 0; + my_delete(opt_basedir, MYF(0)); + opt_basedir= my_strdup(buff, MYF(MY_FAE)); + } + } + + /* + If the user did not specify the option to skip loading defaults from a + config file and the required options are not present or there was an error + generated when the defaults were read from the file, exit. + */ + if (!opt_no_defaults && ((error= get_default_values()))) + { + error= -1; + goto exit; + } + + /* + Check to ensure required options are present and validate the operation. + Note: this method also validates the plugin specified by attempting to + read a configuration file named <plugin_name>.ini from the --plugin-dir + or --plugin-ini location if the --plugin-ini option presented. + */ + strcpy(operation, ""); + if ((error = check_options(argc, argv, operation))) + { + goto exit; + } + + if (opt_verbose) + { + printf("# basedir = %s\n", opt_basedir); + printf("# plugin_dir = %s\n", opt_plugin_dir); + printf("# datadir = %s\n", opt_datadir); + printf("# plugin_ini = %s\n", opt_plugin_ini); + } + +exit: + return error; +} + + +/** + Check access + + This method checks to ensure all of the directories (opt_basedir, + opt_plugin_dir, opt_datadir, and opt_plugin_ini) are accessible by + the user. + + @retval int error = 1, success = 0 +*/ + +static int check_access() +{ + int error= 0; + + if ((error= my_access(opt_basedir, F_OK))) + { + fprintf(stderr, "ERROR: Cannot access basedir at '%s'.\n", + opt_basedir); + goto exit; + } + if ((error= my_access(opt_plugin_dir, F_OK))) + { + fprintf(stderr, "ERROR: Cannot access plugin_dir at '%s'.\n", + opt_plugin_dir); + goto exit; + } + if ((error= my_access(opt_datadir, F_OK))) + { + fprintf(stderr, "ERROR: Cannot access datadir at '%s'.\n", + opt_datadir); + goto exit; + } + if ((error= my_access(opt_plugin_ini, F_OK))) + { + fprintf(stderr, "ERROR: Cannot access plugin config file at '%s'.\n", + opt_plugin_ini); + goto exit; + } + if ((error= my_access(opt_mysqld, F_OK))) + { + fprintf(stderr, "ERROR: Cannot access mysqld path '%s'.\n", + opt_mysqld); + goto exit; + } + if ((error= my_access(opt_my_print_defaults, F_OK))) + { + fprintf(stderr, "ERROR: Cannot access my-print-defaults path '%s'.\n", + opt_my_print_defaults); + goto exit; + } + +exit: + return error; +} + + +/** + Locate the tool and form tool path. + + @param[in] tool_name Name of the tool to locate. + @param[out] tool_path If tool found, return complete path. + + @retval int error = 1, success = 0 +*/ + +static int find_tool(const char *tool_name, char *tool_path) +{ + int i= 0; + + const char *paths[]= { + opt_basedir, opt_mysqld, opt_my_print_defaults, "/usr", + "/usr/local/mysql", "/usr/sbin", "/usr/share", "/extra", "/extra/debug", + "/extra/release", "/bin", "/usr/bin", "/mysql/bin" + }; + for (i= 0; i < (int)array_elements(paths); i++) + { + if (paths[i] && (search_paths(paths[i], tool_name, tool_path))) + goto found; + } + fprintf(stderr, "WARNING: Cannot find %s.\n", tool_name); + return 1; +found: + if (opt_verbose) + printf("# Found tool '%s' as '%s'.\n", tool_name, tool_path); + return 0; +} + + +/** + Find the plugin library. + + This function attempts to use the @c plugin_dir option passed on the + command line to locate the plugin. + + @param[out] tp_path The actual path to plugin with FN_SOEXT applied. + + @retval int error = 1, success = 0 +*/ + +static int find_plugin(char *tp_path) +{ + /* Check for existance of plugin */ + fn_format(tp_path, plugin_data.so_name, opt_plugin_dir, "", MYF(0)); + if (!file_exists(tp_path)) + { + fprintf(stderr, "ERROR: The plugin library is missing or in a different" + " location.\n"); + return 1; + } + else if (opt_verbose) + { + printf("# Found plugin '%s' as '%s'\n", plugin_data.name, tp_path); + } + return 0; +} + + +/** + Build the boostrap file. + + Create a new file and populate it with SQL commands to ENABLE or DISABLE + the plugin via INSERT and DELETE operations on the mysql.plugin table. + + param[in] operation The type of operation (ENABLE or DISABLE) + param[out] bootstrap A FILE* pointer + + @retval int error = 1, success = 0 +*/ + +static int build_bootstrap_file(char *operation, char *bootstrap) +{ + int error= 0; + FILE *file= 0; + + /* + Perform plugin operation : ENABLE or DISABLE + + The following creates a temporary bootstrap file and populates it with + the appropriate SQL commands for the operation. For ENABLE, INSERT + statements are created. For DISABLE, DELETE statements are created. The + values for these statements are derived from the plugin_data read from the + <plugin_name>.ini configuration file. Once the file is built, a call to + mysqld is made in read only, bootstrap modes to read the SQL statements + and execute them. + */ + if ((error= make_tempfile(bootstrap, "sql"))) + { + /* Fail if we cannot create a temporary file for the bootstrap commands. */ + fprintf(stderr, "ERROR: Cannot create bootstrap file.\n"); + goto exit; + } + if ((file= fopen(bootstrap, "w+")) == NULL) + { + fprintf(stderr, "ERROR: Cannot open bootstrap file for writing.\n"); + error= 1; + goto exit; + } + if (strcasecmp(operation, "enable") == 0) + { + int i= 0; + fprintf(file, "INSERT IGNORE INTO mysql.plugin VALUES "); + for (i= 0; i < (int)array_elements(plugin_data.components); i++) + { + /* stop when we read the end of the symbol list - marked with NULL */ + if (plugin_data.components[i] == NULL) + { + break; + } + if (i > 0) + { + fprintf(file, ", "); + } + fprintf(file, "('%s','%s')", + plugin_data.components[i], plugin_data.so_name); + } + fprintf(file, ";\n"); + if (opt_verbose) + { + printf("# Enabling %s...\n", plugin_data.name); + } + } + else + { + fprintf(file, + "DELETE FROM mysql.plugin WHERE name = '%s';", plugin_data.name); + if (opt_verbose) + { + printf("# Disabling %s...\n", plugin_data.name); + } + } + +exit: + fclose(file); + return error; +} + + +/** + Dump bootstrap file. + + Read the contents of the bootstrap file and print it out. + + @param[in] bootstrap_file Name of bootstrap file to read + + @retval int error = 1, success = 0 +*/ + +static int dump_bootstrap_file(char *bootstrap_file) +{ + char *ret= 0; + int error= 0; + char query_str[512]; + FILE *file= 0; + + if ((file= fopen(bootstrap_file, "r")) == NULL) + { + fprintf(stderr, "ERROR: Cannot open bootstrap file for reading.\n"); + error= 1; + goto exit; + } + ret= fgets(query_str, 512, file); + if (ret == 0) + { + fprintf(stderr, "ERROR: Cannot read bootstrap file.\n"); + error= 1; + goto exit; + } + printf("# Query: %s", query_str); + +exit: + if (file) + { + fclose(file); + } + return error; +} + + +/** + Bootstrap the server + + Create a command line sequence to launch mysqld in bootstrap mode. This + will allow mysqld to launch a minimal server instance to read and + execute SQL commands from a file piped in (the boostrap file). We use + the --no-defaults option to skip reading values from the config file. + + The bootstrap mode skips loading of plugins and many other subsystems. + This allows the mysql_plugin tool to insert the correct rows into the + mysql.plugin table (for ENABLE) or delete the rows (for DISABLE). Once + the server is launched in normal mode, the plugin will be loaded + (for ENABLE) or not loaded (for DISABLE). In this way, we avoid the + (sometimes) complicated LOAD PLUGIN commands. + + @param[in] server_path Path to server executable + @param[in] bootstrap_file Name of bootstrap file to read + + @retval int error = 1, success = 0 +*/ + +static int bootstrap_server(char *server_path, char *bootstrap_file) +{ + char bootstrap_cmd[FN_REFLEN]; + int error= 0; + int ret= 0; + +#ifdef __WIN__ + char *format_str= 0; + const char *verbose_str= NULL; + + + if (opt_verbose) + verbose_str= "--console"; + else + verbose_str= ""; + if (has_spaces(opt_datadir) || has_spaces(opt_basedir) || + has_spaces(bootstrap_file)) + format_str= "\"%s %s --bootstrap --datadir=%s --basedir=%s < %s\""; + else + format_str= "%s %s --bootstrap --datadir=%s --basedir=%s < %s"; + + snprintf(bootstrap_cmd, sizeof(bootstrap_cmd), format_str, + add_quotes(convert_path(server_path)), verbose_str, + add_quotes(opt_datadir), add_quotes(opt_basedir), + add_quotes(bootstrap_file)); +#else + snprintf(bootstrap_cmd, sizeof(bootstrap_cmd), + "%s --no-defaults --bootstrap --datadir=%s --basedir=%s" + " < %s", server_path, opt_datadir, opt_basedir, bootstrap_file); +#endif + + /* Execute the command */ + if (opt_verbose) + { + printf("# Command: %s\n", bootstrap_cmd); + } + error= run_command(bootstrap_cmd, "r"); + if (error) + fprintf(stderr, + "ERROR: Unexpected result from bootstrap. Error code: %d.\n", + ret); + + return error; +} diff --git a/client/mysql_upgrade.c b/client/mysql_upgrade.c index 73acc241912..424d847c187 100644 --- a/client/mysql_upgrade.c +++ b/client/mysql_upgrade.c @@ -1,4 +1,4 @@ -/* Copyright (c) 2000, 2010, Oracle and/or its affiliates. All rights reserved. +/* Copyright (c) 2000, 2010, Oracle and/or its affiliates. Copyright (C) 2010 Monty Program Ab This program is free software; you can redistribute it and/or modify @@ -12,7 +12,8 @@ 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +*/ #include "client_priv.h" #include <sslopt-vars.h> @@ -247,6 +248,7 @@ get_one_option(int optid, const struct my_option *opt, switch (optid) { case '?': + puts(ORACLE_WELCOME_COPYRIGHT_NOTICE("2000, 2011")); printf("%s Ver %s Distrib %s, for %s (%s)\n", my_progname, VER, MYSQL_SERVER_VERSION, SYSTEM_TYPE, MACHINE_TYPE); puts(ORACLE_WELCOME_COPYRIGHT_NOTICE("2000, 2010")); diff --git a/client/mysqladmin.cc b/client/mysqladmin.cc index 4335acdfb9c..463ec37fae2 100644 --- a/client/mysqladmin.cc +++ b/client/mysqladmin.cc @@ -700,7 +700,7 @@ static int execute_commands(MYSQL *mysql,int argc, char **argv) case ADMIN_VER: new_line=1; print_version(); - puts(ORACLE_WELCOME_COPYRIGHT_NOTICE("2000, 2010")); + puts(ORACLE_WELCOME_COPYRIGHT_NOTICE("2000, 2011")); printf("Server version\t\t%s\n", mysql_get_server_info(mysql)); printf("Protocol version\t%d\n", mysql_get_proto_info(mysql)); printf("Connection\t\t%s\n",mysql_get_host_info(mysql)); @@ -1172,7 +1172,7 @@ static void print_version(void) static void usage(void) { print_version(); - puts(ORACLE_WELCOME_COPYRIGHT_NOTICE("2000, 2010")); + puts(ORACLE_WELCOME_COPYRIGHT_NOTICE("2000, 2011")); puts("Administration program for the mysqld daemon."); printf("Usage: %s [OPTIONS] command command....\n", my_progname); my_print_help(my_long_options); diff --git a/client/mysqlbinlog.cc b/client/mysqlbinlog.cc index e5af12bf49a..4de571b546d 100644 --- a/client/mysqlbinlog.cc +++ b/client/mysqlbinlog.cc @@ -1,4 +1,5 @@ -/* Copyright (c) 2001, 2010, Oracle and/or its affiliates. All rights reserved. +/* + Copyright (c) 2000, 2011, Oracle and/or its affiliates. All rights reserved. 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 @@ -11,7 +12,8 @@ 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +*/ /* @@ -114,7 +116,7 @@ static ulonglong rec_count= 0; static short binlog_flags = 0; static MYSQL* mysql = NULL; static const char* dirname_for_local_load= 0; -static bool opt_skip_annotate_rows_events= 0; +static bool opt_skip_annotate_row_events= 0; /** Pointer to the Format_description_log_event of the currently active binlog. @@ -1038,7 +1040,7 @@ Exit_status process_event(PRINT_EVENT_INFO *print_event_info, Log_event *ev, break; } case ANNOTATE_ROWS_EVENT: - if (!opt_skip_annotate_rows_events) + if (!opt_skip_annotate_row_events) { /* We don't print Annotate event just now because all subsequent @@ -1346,10 +1348,10 @@ that may lead to an endless loop.", "Updates to a database with a different name than the original. \ Example: rewrite-db='from->to'.", 0, 0, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, - {"skip-annotate-rows-events", OPT_SKIP_ANNOTATE_ROWS_EVENTS, + {"skip-annotate-row-events", OPT_SKIP_ANNOTATE_ROWS_EVENTS, "Don't print Annotate_rows events stored in the binary log.", - (uchar**) &opt_skip_annotate_rows_events, - (uchar**) &opt_skip_annotate_rows_events, + (uchar**) &opt_skip_annotate_row_events, + (uchar**) &opt_skip_annotate_row_events, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0}, {0, 0, 0, 0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0} }; @@ -1443,7 +1445,7 @@ static void print_version() static void usage() { print_version(); - puts(ORACLE_WELCOME_COPYRIGHT_NOTICE("2001, 2010")); + puts(ORACLE_WELCOME_COPYRIGHT_NOTICE("2000, 2011")); printf("\ Dumps a MySQL binary log in a format usable for viewing or for piping to\n\ the mysql command line client.\n\n"); @@ -1825,7 +1827,7 @@ static Exit_status dump_remote_log_entries(PRINT_EVENT_INFO *print_event_info, cast to uint32. */ int4store(buf, (uint32)start_position); - if (!opt_skip_annotate_rows_events) + if (!opt_skip_annotate_row_events) binlog_flags|= BINLOG_SEND_ANNOTATE_ROWS_EVENT; int2store(buf + BIN_LOG_HEADER_SIZE, binlog_flags); diff --git a/client/mysqlcheck.c b/client/mysqlcheck.c index e0a2bce1e85..445f4522cef 100644 --- a/client/mysqlcheck.c +++ b/client/mysqlcheck.c @@ -1,4 +1,4 @@ -/* Copyright (c) 2000, 2010, Oracle and/or its affiliates. All rights reserved. +/* Copyright (c) 2000, 2010, Oracle and/or its affiliates. Copyright (C) 2010-2011 Monty Program Ab This program is free software; you can redistribute it and/or modify @@ -12,7 +12,8 @@ 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +*/ /* By Jani Tolonen, 2001-04-20, MySQL Development Team */ @@ -228,7 +229,7 @@ static void usage(void) { DBUG_ENTER("usage"); print_version(); - puts(ORACLE_WELCOME_COPYRIGHT_NOTICE("2000, 2010")); + puts(ORACLE_WELCOME_COPYRIGHT_NOTICE("2000, 2011")); printf("Usage: %s [OPTIONS] database [tables]\n", my_progname); printf("OR %s [OPTIONS] --databases DB1 [DB2 DB3...]\n", my_progname); diff --git a/client/mysqldump.c b/client/mysqldump.c index 4103d8ccb04..0d209bd7034 100644 --- a/client/mysqldump.c +++ b/client/mysqldump.c @@ -1,4 +1,5 @@ -/* Copyright (c) 2000, 2011, Oracle and/or its affiliates. All rights reserved. +/* + Copyright (c) 2000, 2011, Oracle and/or its affiliates. All rights reserved. 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 @@ -11,7 +12,8 @@ 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +*/ /* mysqldump.c - Dump a tables contents and format to an ASCII file ** @@ -53,6 +55,8 @@ #include <welcome_copyright_notice.h> /* ORACLE_WELCOME_COPYRIGHT_NOTICE */ +#include <welcome_copyright_notice.h> /* ORACLE_WELCOME_COPYRIGHT_NOTICE */ + /* Exit codes */ #define EX_USAGE 1 @@ -598,7 +602,7 @@ static void short_usage_sub(void) static void usage(void) { print_version(); - puts(ORACLE_WELCOME_COPYRIGHT_NOTICE("2000, 2010")); + puts(ORACLE_WELCOME_COPYRIGHT_NOTICE("2000, 2011")); puts("Dumping structure and contents of MySQL databases and tables."); short_usage_sub(); print_defaults("my",load_default_groups); diff --git a/client/mysqlimport.c b/client/mysqlimport.c index 33fd70d6316..3b9939d7c6d 100644 --- a/client/mysqlimport.c +++ b/client/mysqlimport.c @@ -1,4 +1,5 @@ -/* Copyright (c) 2000, 2010, Oracle and/or its affiliates. All rights reserved. +/* + Copyright (c) 2000, 2011, Oracle and/or its affiliates. All rights reserved. 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 @@ -11,19 +12,14 @@ 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +*/ /* ** mysqlimport.c - Imports all given files ** into a table(s). -** -** ************************* -** * * -** * AUTHOR: Monty & Jani * -** * DATE: June 24, 1997 * -** * * -** ************************* */ + #define IMPORT_VERSION "3.7" #include "client_priv.h" @@ -42,6 +38,8 @@ pthread_mutex_t counter_mutex; pthread_cond_t count_threshhold; #endif +#include <welcome_copyright_notice.h> /* ORACLE_WELCOME_COPYRIGHT_NOTICE */ + static void db_error_with_table(MYSQL *mysql, char *table); static void db_error(MYSQL *mysql); static char *field_escape(char *to,const char *from,uint length); @@ -202,7 +200,7 @@ static void print_version(void) static void usage(void) { print_version(); - puts(ORACLE_WELCOME_COPYRIGHT_NOTICE("2000, 2010")); + puts(ORACLE_WELCOME_COPYRIGHT_NOTICE("2000, 2011")); printf("\ Loads tables from text files in various formats. The base name of the\n\ text file must be the name of the table that should be used.\n\ diff --git a/client/mysqlshow.c b/client/mysqlshow.c index 30e2cfcc06c..1f299753587 100644 --- a/client/mysqlshow.c +++ b/client/mysqlshow.c @@ -1,4 +1,5 @@ -/* Copyright (c) 2000, 2010, Oracle and/or its affiliates. All rights reserved. +/* + Copyright (c) 2000, 2011, Oracle and/or its affiliates. All rights reserved. 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 @@ -11,7 +12,8 @@ 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +*/ /* Show databases, tables or columns */ @@ -263,7 +265,7 @@ static void print_version(void) static void usage(void) { print_version(); - puts(ORACLE_WELCOME_COPYRIGHT_NOTICE("2000, 2010)")); + puts(ORACLE_WELCOME_COPYRIGHT_NOTICE("2000, 2011)")); puts("Shows the structure of a MySQL database (databases, tables, and columns).\n"); printf("Usage: %s [OPTIONS] [database [table [column]]]\n",my_progname); puts("\n\ diff --git a/client/mysqlslap.c b/client/mysqlslap.c index fa9a1e4d2a7..0f8a1edc476 100644 --- a/client/mysqlslap.c +++ b/client/mysqlslap.c @@ -1,4 +1,5 @@ -/* Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved. +/* + Copyright (c) 2005, 2011, Oracle and/or its affiliates. All rights reserved. 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 @@ -11,7 +12,8 @@ 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +*/ /* MySQL Slap diff --git a/client/mysqltest.cc b/client/mysqltest.cc index 23b9eb578c6..29235dbd234 100644 --- a/client/mysqltest.cc +++ b/client/mysqltest.cc @@ -23,13 +23,6 @@ http://dev.mysql.com/doc/mysqltest/en/index.html Please keep the test framework tools identical in all versions! - - Written by: - Sasha Pachev <sasha@mysql.com> - Matt Wagner <matt@mysql.com> - Monty - Jani - Holyfoot */ #define MTEST_VERSION "3.3" @@ -129,6 +122,41 @@ static const char *load_default_groups[]= { "mysqltest", "client", "client-server", "client-mariadb", 0 }; static char line_buffer[MAX_DELIMITER_LENGTH], *line_buffer_pos= line_buffer; +/* Info on properties that can be set with --enable_X and --disable_X */ + +struct property { + my_bool *var; /* Actual variable */ + my_bool set; /* Has been set for ONE command */ + my_bool old; /* If set, thus is the old value */ + my_bool reverse; /* Varible is true if disabled */ + const char *env_name; /* Env. variable name */ +}; + +static struct property prop_list[] = { + { &abort_on_error, 0, 1, 0, "$ENABLED_ABORT_ON_ERROR" }, + { &disable_connect_log, 0, 1, 1, "$ENABLED_CONNECT_LOG" }, + { &disable_info, 0, 1, 1, "$ENABLED_INFO" }, + { &display_metadata, 0, 0, 0, "$ENABLED_METADATA" }, + { &ps_protocol_enabled, 0, 0, 0, "$ENABLED_PS_PROTOCOL" }, + { &disable_query_log, 0, 0, 1, "$ENABLED_QUERY_LOG" }, + { &disable_result_log, 0, 0, 1, "$ENABLED_RESULT_LOG" }, + { &disable_warnings, 0, 0, 1, "$ENABLED_WARNINGS" } +}; + +static my_bool once_property= FALSE; + +enum enum_prop { + P_ABORT= 0, + P_CONNECT, + P_INFO, + P_META, + P_PS, + P_QUERY, + P_RESULT, + P_WARN, + P_MAX +}; + static uint start_lineno= 0; /* Start line of current command */ static uint my_end_arg= 0; @@ -488,6 +516,7 @@ TYPELIB command_typelib= {array_elements(command_names),"", DYNAMIC_STRING ds_res; /* Points to ds_warning in run_query, so it can be freed */ DYNAMIC_STRING *ds_warn= 0; +struct st_command *curr_command= 0; char builtin_echo[FN_REFLEN]; @@ -519,6 +548,7 @@ void str_to_file(const char *fname, char *str, int size); void str_to_file2(const char *fname, char *str, int size, my_bool append); void fix_win_paths(const char *val, int len); +const char *get_errname_from_code (uint error_code); #ifdef __WIN__ void free_tmp_sh_file(); @@ -741,6 +771,7 @@ void handle_error(struct st_command*, unsigned int err_errno, const char *err_error, const char *err_sqlstate, DYNAMIC_STRING *ds); void handle_no_error(struct st_command*); +void revert_properties(); #ifdef EMBEDDED_LIBRARY @@ -1211,6 +1242,7 @@ void handle_command_error(struct st_command *command, uint error, DBUG_PRINT("info", ("command \"%.*s\" failed with expected error: %u, errno: %d", command->first_word_len, command->query, error, sys_errno)); + revert_properties(); DBUG_VOID_RETURN; } if (command->expected_errors.count > 0) @@ -1225,6 +1257,7 @@ void handle_command_error(struct st_command *command, uint error, command->first_word_len, command->query, command->expected_errors.err[0].code.errnum); } + revert_properties(); DBUG_VOID_RETURN; } @@ -2345,6 +2378,51 @@ void var_set_int(const char* name, int value) void var_set_errno(int sql_errno) { var_set_int("$mysql_errno", sql_errno); + var_set_string("$mysql_errname", get_errname_from_code(sql_errno)); +} + +/* Functions to handle --disable and --enable properties */ + +void set_once_property(enum_prop prop, my_bool val) +{ + property &pr= prop_list[prop]; + pr.set= 1; + pr.old= *pr.var; + *pr.var= val; + var_set_int(pr.env_name, (val != pr.reverse)); + once_property= TRUE; +} + +void set_property(st_command *command, enum_prop prop, my_bool val) +{ + char* p= command->first_argument; + if (p && !strcmp (p, "ONCE")) + { + command->last_argument= p + 4; + set_once_property(prop, val); + return; + } + property &pr= prop_list[prop]; + *pr.var= val; + pr.set= 0; + var_set_int(pr.env_name, (val != pr.reverse)); +} + +void revert_properties() +{ + if (! once_property) + return; + for (int i= 0; i < (int) P_MAX; i++) + { + property &pr= prop_list[i]; + if (pr.set) + { + *pr.var= pr.old; + pr.set= 0; + var_set_int(pr.env_name, (pr.old != pr.reverse)); + } + } + once_property=FALSE; } @@ -2398,9 +2476,16 @@ void var_query_set(VAR *var, const char *query, const char** query_end) init_dynamic_string(&ds_query, 0, (end - query) + 32, 256); do_eval(&ds_query, query, end, FALSE); - if (mysql_real_query(mysql, ds_query.str, ds_query.length)) - die("Error running query '%s': %d %s", ds_query.str, - mysql_errno(mysql), mysql_error(mysql)); + if (mysql_real_query(mysql, ds_query.str, ds_query.length)) + { + handle_error (curr_command, mysql_errno(mysql), mysql_error(mysql), + mysql_sqlstate(mysql), &ds_res); + /* If error was acceptable, return empty string */ + dynstr_free(&ds_query); + eval_expr(var, "", 0); + DBUG_VOID_RETURN; + } + if (!(res= mysql_store_result(mysql))) die("Query '%s' didn't return a result set", ds_query.str); dynstr_free(&ds_query); @@ -2554,8 +2639,15 @@ void var_set_query_get_value(struct st_command *command, VAR *var) /* Run the query */ if (mysql_real_query(mysql, ds_query.str, ds_query.length)) - die("Error running query '%s': %d %s", ds_query.str, - mysql_errno(mysql), mysql_error(mysql)); + { + handle_error (curr_command, mysql_errno(mysql), mysql_error(mysql), + mysql_sqlstate(mysql), &ds_res); + /* If error was acceptable, return empty string */ + dynstr_free(&ds_query); + eval_expr(var, "", 0); + DBUG_VOID_RETURN; + } + if (!(res= mysql_store_result(mysql))) die("Query '%s' didn't return a result set", ds_query.str); @@ -4510,6 +4602,7 @@ void do_let(struct st_command *command) var_set(var_name, var_name_end, let_rhs_expr.str, (let_rhs_expr.str + let_rhs_expr.length)); dynstr_free(&let_rhs_expr); + revert_properties(); DBUG_VOID_RETURN; } @@ -4756,8 +4849,7 @@ void do_shutdown_server(struct st_command *command) } -#if MYSQL_VERSION_ID >= 50000 -/* List of error names to error codes, available from 5.0 */ +/* List of error names to error codes */ typedef struct { const char *name; @@ -4767,6 +4859,7 @@ typedef struct static st_error global_error_names[] = { + { "<No error>", -1, "" }, #include <mysqld_ername.h> { 0, 0, 0 } }; @@ -4797,16 +4890,28 @@ uint get_errcode_from_name(char *error_name, char *error_end) die("Unknown SQL error name '%s'", error_name); DBUG_RETURN(0); } -#else -uint get_errcode_from_name(char *error_name __attribute__((unused)), - char *error_end __attribute__((unused))) + +const char *get_errname_from_code (uint error_code) { - abort_not_in_this_version(); - return 0; /* Never reached */ -} -#endif + st_error *e= global_error_names; + DBUG_ENTER("get_errname_from_code"); + DBUG_PRINT("enter", ("error_code: %d", error_code)); + if (! error_code) + { + DBUG_RETURN(""); + } + for (; e->name; e++) + { + if (e->code == error_code) + { + DBUG_RETURN(e->name); + } + } + /* Apparently, errors without known names may occur */ + DBUG_RETURN("<Unknown>"); +} void do_get_errcodes(struct st_command *command) { @@ -5339,6 +5444,7 @@ do_handle_error: var_set_errno(0); handle_no_error(command); + revert_properties(); return 1; /* Connected */ } @@ -5375,7 +5481,8 @@ void do_connect(struct st_command *command) int con_port= opt_port; char *con_options; my_bool con_ssl= 0, con_compress= 0; - my_bool con_pipe= 0, con_shm= 0; + my_bool con_pipe= 0; + my_bool con_shm __attribute__ ((unused))= 0; struct st_connection* con_slot; static DYNAMIC_STRING ds_connection_name; @@ -6517,7 +6624,7 @@ void print_version(void) void usage() { print_version(); - puts(ORACLE_WELCOME_COPYRIGHT_NOTICE("2000, 2010")); + puts(ORACLE_WELCOME_COPYRIGHT_NOTICE("2000, 2011")); printf("Runs a test against the mysql server and compares output with a results file.\n\n"); printf("Usage: %s [OPTIONS] [database] < test_file\n", my_progname); my_print_help(my_long_options); @@ -7319,6 +7426,7 @@ void run_query_normal(struct st_connection *cn, struct st_command *command, /* If we come here the query is both executed and read successfully */ handle_no_error(command); + revert_properties(); end: @@ -7452,6 +7560,7 @@ void handle_error(struct st_command *command, dynstr_append(ds,"Got one of the listed errors\n"); } /* OK */ + revert_properties(); DBUG_VOID_RETURN; } @@ -7479,6 +7588,7 @@ void handle_error(struct st_command *command, command->expected_errors.err[0].code.sqlstate); } + revert_properties(); DBUG_VOID_RETURN; } @@ -7512,7 +7622,6 @@ void handle_no_error(struct st_command *command) die("query '%s' succeeded - should have failed with sqlstate %s...", command->query, command->expected_errors.err[0].code.sqlstate); } - DBUG_VOID_RETURN; } @@ -7727,6 +7836,8 @@ end: var_set_errno(mysql_stmt_errno(stmt)); + revert_properties(); + /* Close the statement if reconnect, need new prepare */ if (mysql->reconnect) { @@ -8580,6 +8691,8 @@ int main(int argc, char **argv) { command->last_argument= command->first_argument; processed = 1; + /* Need to remember this for handle_error() */ + curr_command= command; switch (command->type) { case Q_CONNECT: do_connect(command); @@ -8591,60 +8704,46 @@ int main(int argc, char **argv) case Q_ENABLE_PREPARE_WARNINGS: prepare_warnings_enabled=1; break; case Q_DISABLE_PREPARE_WARNINGS: prepare_warnings_enabled=0; break; case Q_ENABLE_QUERY_LOG: - disable_query_log= 0; - var_set_int("$ENABLED_QUERY_LOG", 1); + set_property(command, P_QUERY, 0); break; case Q_DISABLE_QUERY_LOG: - disable_query_log= 1; - var_set_int("$ENABLED_QUERY_LOG", 0); + set_property(command, P_QUERY, 1); break; case Q_ENABLE_ABORT_ON_ERROR: - abort_on_error= 1; - var_set_int("$ENABLED_ABORT_ON_ERROR", 1); + set_property(command, P_ABORT, 1); break; case Q_DISABLE_ABORT_ON_ERROR: - abort_on_error= 0; - var_set_int("$ENABLED_ABORT_ON_ERROR", 0); + set_property(command, P_ABORT, 0); break; case Q_ENABLE_RESULT_LOG: - disable_result_log= 0; - var_set_int("$ENABLED_RESULT_LOG", 1); + set_property(command, P_RESULT, 0); break; case Q_DISABLE_RESULT_LOG: - disable_result_log=1; - var_set_int("$ENABLED_RESULT_LOG", 0); + set_property(command, P_RESULT, 1); break; case Q_ENABLE_CONNECT_LOG: - disable_connect_log=0; - var_set_int("$ENABLED_CONNECT_LOG", 1); + set_property(command, P_CONNECT, 0); break; case Q_DISABLE_CONNECT_LOG: - disable_connect_log=1; - var_set_int("$ENABLED_CONNECT_LOG", 0); + set_property(command, P_CONNECT, 1); break; case Q_ENABLE_WARNINGS: - disable_warnings= 0; - var_set_int("$ENABLED_WARNINGS", 1); + set_property(command, P_WARN, 0); break; case Q_DISABLE_WARNINGS: - disable_warnings= 1; - var_set_int("$ENABLED_WARNINGS", 0); + set_property(command, P_WARN, 1); break; case Q_ENABLE_INFO: - disable_info= 0; - var_set_int("$ENABLED_INFO", 1); + set_property(command, P_INFO, 0); break; case Q_DISABLE_INFO: - disable_info= 1; - var_set_int("$ENABLED_INFO", 0); + set_property(command, P_INFO, 1); break; case Q_ENABLE_METADATA: - display_metadata= 1; - var_set_int("$ENABLED_METADATA", 1); + set_property(command, P_META, 1); break; case Q_DISABLE_METADATA: - display_metadata= 0; - var_set_int("$ENABLED_METADATA", 0); + set_property(command, P_META, 0); break; case Q_ENABLE_COLUMN_NAMES: disable_column_names= 0; @@ -8870,12 +8969,12 @@ int main(int argc, char **argv) do_set_charset(command); break; case Q_DISABLE_PS_PROTOCOL: - ps_protocol_enabled= 0; + set_property(command, P_PS, 0); /* Close any open statements */ close_statements(); break; case Q_ENABLE_PS_PROTOCOL: - ps_protocol_enabled= ps_protocol; + set_property(command, P_PS, ps_protocol); break; case Q_DISABLE_RECONNECT: set_reconnect(cur_con->mysql, 0); diff --git a/client/readline.cc b/client/readline.cc index 51cbd89f29f..e451baff341 100644 --- a/client/readline.cc +++ b/client/readline.cc @@ -1,4 +1,5 @@ -/* Copyright (C) 2000 MySQL AB +/* + Copyright (c) 2000, 2011, Oracle and/or its affiliates. All rights reserved. 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 @@ -11,7 +12,8 @@ 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +*/ /* readline for batch mode */ diff --git a/client/sql_string.cc b/client/sql_string.cc index 684e9f337af..26181722b11 100644 --- a/client/sql_string.cc +++ b/client/sql_string.cc @@ -1,4 +1,5 @@ -/* Copyright (C) 2000 MySQL AB +/* + Copyright (c) 2000, 2010, Oracle and/or its affiliates. All rights reserved. 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 @@ -11,7 +12,8 @@ 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +*/ /* This file is originally from the mysql distribution. Coded by monty */ diff --git a/client/sql_string.h b/client/sql_string.h index 60f3c557367..26f3b330f20 100644 --- a/client/sql_string.h +++ b/client/sql_string.h @@ -1,7 +1,7 @@ #ifndef SQL_STRING_INCLUDED #define SQL_STRING_INCLUDED -/* Copyright (C) 2000 MySQL AB +/* Copyright (c) 2000, 2010, Oracle and/or its affiliates. All rights reserved. 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 @@ -14,7 +14,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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ /* This file is originally from the mysql distribution. Coded by monty */ diff --git a/cmake/abi_check.cmake b/cmake/abi_check.cmake index a671aeff342..9948f526b7a 100644 --- a/cmake/abi_check.cmake +++ b/cmake/abi_check.cmake @@ -1,4 +1,4 @@ -# Copyright (C) 2009 Sun Microsystems, Inc +# Copyright (c) 2009, 2011, Oracle and/or its affiliates. All rights reserved. # # 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/cmake/bison.cmake b/cmake/bison.cmake index 1dd5d10cd33..d5c725fbbde 100644 --- a/cmake/bison.cmake +++ b/cmake/bison.cmake @@ -1,4 +1,5 @@ -# Copyright (C) 2009 Sun Microsystems, Inc +# Copyright (c) 2009 Sun Microsystems, Inc. +# Use is subject to license terms. # # 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/cmake/build_configurations/mysql_release.cmake b/cmake/build_configurations/mysql_release.cmake index 91d598db465..ee6d6b85004 100644 --- a/cmake/build_configurations/mysql_release.cmake +++ b/cmake/build_configurations/mysql_release.cmake @@ -1,4 +1,4 @@ -# Copyright (C) 2010 Sun Microsystems, Inc +# Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved. # # 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 @@ -210,8 +210,8 @@ IF(UNIX) IF(CMAKE_SYSTEM_PROCESSOR MATCHES "i386") SET(COMMON_C_FLAGS "-g -mt -fsimple=1 -ftrap=%none -nofstore -xbuiltin=%all -xlibmil -xlibmopt -xtarget=generic") SET(COMMON_CXX_FLAGS "-g0 -mt -fsimple=1 -ftrap=%none -nofstore -xbuiltin=%all -features=no%except -xlibmil -xlibmopt -xtarget=generic") - SET(CMAKE_C_FLAGS_DEBUG "${COMMON_C_FLAGS}") - SET(CMAKE_CXX_FLAGS_DEBUG "${COMMON_CXX_FLAGS}") + SET(CMAKE_C_FLAGS_DEBUG "-xO1 ${COMMON_C_FLAGS}") + SET(CMAKE_CXX_FLAGS_DEBUG "-xO1 ${COMMON_CXX_FLAGS}") IF(32BIT) SET(CMAKE_C_FLAGS_RELWITHDEBINFO "-xO2 ${COMMON_C_FLAGS}") SET(CMAKE_CXX_FLAGS_RELWITHDEBINFO "-xO2 ${COMMON_CXX_FLAGS}") diff --git a/cmake/cat.cmake b/cmake/cat.cmake index 532f4115104..1ffe2ecfa1d 100644 --- a/cmake/cat.cmake +++ b/cmake/cat.cmake @@ -1,4 +1,5 @@ -# Copyright (C) 2009 Sun Microsystems, Inc +# Copyright (c) 2009 Sun Microsystems, Inc. +# Use is subject to license terms. # # 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/cmake/check_minimal_version.cmake b/cmake/check_minimal_version.cmake index 4f134712fae..d96c6a93418 100644 --- a/cmake/check_minimal_version.cmake +++ b/cmake/check_minimal_version.cmake @@ -1,4 +1,5 @@ -# Copyright (C) 2009 Sun Microsystems, Inc +# Copyright (c) 2009 Sun Microsystems, Inc. +# Use is subject to license terms. # # 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/cmake/cmake_parse_arguments.cmake b/cmake/cmake_parse_arguments.cmake index db540ae9020..487fe2bacd9 100644 --- a/cmake/cmake_parse_arguments.cmake +++ b/cmake/cmake_parse_arguments.cmake @@ -1,5 +1,5 @@ -# Copyright (C) 2007 MySQL AB, 2009 Sun Microsystems,Inc +# Copyright (c) 2007, 2010, Oracle and/or its affiliates. All rights reserved. # # 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/cmake/configure.pl b/cmake/configure.pl index bf872264953..565de571452 100644 --- a/cmake/configure.pl +++ b/cmake/configure.pl @@ -1,4 +1,20 @@ #!/usr/bin/perl + +# Copyright (c) 2009, 2011, Oracle and/or its affiliates. All rights reserved. +# +# 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 +# the Free Software Foundation; version 2 of the License. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# 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 02110-1301 USA + use strict; use Cwd 'abs_path'; use File::Basename; diff --git a/cmake/cpack_source_ignore_files.cmake b/cmake/cpack_source_ignore_files.cmake index 5eef20dccc6..5db383ae73f 100644 --- a/cmake/cpack_source_ignore_files.cmake +++ b/cmake/cpack_source_ignore_files.cmake @@ -1,3 +1,18 @@ +# Copyright (c) 2009, 2010, Oracle and/or its affiliates. All rights reserved. +# +# 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 +# the Free Software Foundation; version 2 of the License. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# 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 02110-1301 USA + SET(CPACK_SOURCE_IGNORE_FILES \\\\.bzr/ \\\\.bzr-mysql diff --git a/cmake/create_initial_db.cmake.in b/cmake/create_initial_db.cmake.in index 881afe265ef..e37f41255e0 100644 --- a/cmake/create_initial_db.cmake.in +++ b/cmake/create_initial_db.cmake.in @@ -1,4 +1,4 @@ -# Copyright (C) 2009 Sun Microsystems, Inc +# Copyright (c) 2009, 2010, Oracle and/or its affiliates. All rights reserved. # # 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/cmake/do_abi_check.cmake b/cmake/do_abi_check.cmake index 96943e1a4c4..e42f11abde2 100644 --- a/cmake/do_abi_check.cmake +++ b/cmake/do_abi_check.cmake @@ -1,4 +1,4 @@ -# Copyright (C) 2009 Sun Microsystems, Inc +# Copyright (c) 2009, 2010, Oracle and/or its affiliates. All rights reserved. # # 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/cmake/dtrace.cmake b/cmake/dtrace.cmake index 5beb45ca524..882ea0de6aa 100644 --- a/cmake/dtrace.cmake +++ b/cmake/dtrace.cmake @@ -1,4 +1,4 @@ -# Copyright (C) 2009 Sun Microsystems, Inc +# Copyright (c) 2009, 2010, Oracle and/or its affiliates. All rights reserved. # # 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/cmake/dtrace_prelink.cmake b/cmake/dtrace_prelink.cmake index 37e560cdaf8..0efc2bb64bb 100644 --- a/cmake/dtrace_prelink.cmake +++ b/cmake/dtrace_prelink.cmake @@ -1,4 +1,5 @@ -# Copyright (C) 2009 Sun Microsystems, Inc +# Copyright (c) 2009 Sun Microsystems, Inc. +# Use is subject to license terms. # # 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/cmake/install_layout.cmake b/cmake/install_layout.cmake index bbf29c2e46c..9f9dc7dc9a3 100644 --- a/cmake/install_layout.cmake +++ b/cmake/install_layout.cmake @@ -1,4 +1,4 @@ -# Copyright (C) 2010 Sun Microsystems, Inc +# Copyright (c) 2010, 2011, Oracle and/or its affiliates. All rights reserved. # # 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/cmake/install_macros.cmake b/cmake/install_macros.cmake index e244e4262e0..a8a84e48455 100644 --- a/cmake/install_macros.cmake +++ b/cmake/install_macros.cmake @@ -1,4 +1,4 @@ -# Copyright (C) 2009 Sun Microsystems, Inc +# Copyright (c) 2009, 2010, Oracle and/or its affiliates. All rights reserved. # # 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/cmake/libutils.cmake b/cmake/libutils.cmake index 93e8994b021..bb90f7d2a6c 100644 --- a/cmake/libutils.cmake +++ b/cmake/libutils.cmake @@ -1,4 +1,4 @@ -# Copyright (C) 2009 Sun Microsystems, Inc +# Copyright (c) 2009, 2010, Oracle and/or its affiliates. All rights reserved. # # 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/cmake/maintainer.cmake b/cmake/maintainer.cmake index d24211a6ff8..a91905a281b 100644 --- a/cmake/maintainer.cmake +++ b/cmake/maintainer.cmake @@ -1,4 +1,4 @@ -# Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved. +# Copyright (c) 2010, 2011, Oracle and/or its affiliates. All rights reserved. # # 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/cmake/merge_archives_unix.cmake.in b/cmake/merge_archives_unix.cmake.in index a9a060ab49e..d05336d6c91 100644 --- a/cmake/merge_archives_unix.cmake.in +++ b/cmake/merge_archives_unix.cmake.in @@ -1,4 +1,5 @@ -# Copyright (C) 2009 Sun Microsystems, Inc +# Copyright (c) 2009 Sun Microsystems, Inc. +# Use is subject to license terms. # # 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/cmake/mysql_add_executable.cmake b/cmake/mysql_add_executable.cmake index ac812fbcdfd..b1e1d3129e6 100644 --- a/cmake/mysql_add_executable.cmake +++ b/cmake/mysql_add_executable.cmake @@ -1,4 +1,4 @@ -# Copyright (C) 2009 Sun Microsystems, Inc
+# Copyright (c) 2009, 2010, Oracle and/or its affiliates. All rights reserved.
#
# 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/cmake/mysql_version.cmake b/cmake/mysql_version.cmake index 5b18dd97756..4a9f35e6b35 100644 --- a/cmake/mysql_version.cmake +++ b/cmake/mysql_version.cmake @@ -1,4 +1,4 @@ -# Copyright (C) 2009 Sun Microsystems, Inc +# Copyright (c) 2009, 2011, Oracle and/or its affiliates. All rights reserved. # # 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/cmake/os/AIX.cmake b/cmake/os/AIX.cmake index c08cbbdc0cf..c86392f8bc4 100644 --- a/cmake/os/AIX.cmake +++ b/cmake/os/AIX.cmake @@ -1,4 +1,4 @@ -# Copyright (C) 2010 Sun Microsystems, Inc +# Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved. # # 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/cmake/os/Cygwin.cmake b/cmake/os/Cygwin.cmake index 5b2d82c19b8..9c29277c626 100644 --- a/cmake/os/Cygwin.cmake +++ b/cmake/os/Cygwin.cmake @@ -1,4 +1,5 @@ -# Copyright (C) 2010 Sun Microsystems, Inc +# Copyright (c) 2010 Sun Microsystems, Inc. +# Use is subject to license terms. # # 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/cmake/os/Darwin.cmake b/cmake/os/Darwin.cmake index 09d82bed7bd..0d8bac106f0 100644 --- a/cmake/os/Darwin.cmake +++ b/cmake/os/Darwin.cmake @@ -1,4 +1,5 @@ -# Copyright (C) 2010 Sun Microsystems, Inc +# Copyright (c) 2010 Sun Microsystems, Inc. +# Use is subject to license terms. # # 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/cmake/os/HP-UX.cmake b/cmake/os/HP-UX.cmake index 5eaa0477040..4cadddc7b18 100644 --- a/cmake/os/HP-UX.cmake +++ b/cmake/os/HP-UX.cmake @@ -1,4 +1,5 @@ -# Copyright (C) 2010 Sun Microsystems, Inc +# Copyright (c) 2010 Sun Microsystems, Inc. +# Use is subject to license terms. # # 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/cmake/os/Linux.cmake b/cmake/os/Linux.cmake index 13fa1c3f148..ccdf7e8d931 100644 --- a/cmake/os/Linux.cmake +++ b/cmake/os/Linux.cmake @@ -1,5 +1,5 @@ -# Copyright (C) 2010 Sun Microsystems, Inc +# Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved. # # 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/cmake/os/OS400.cmake b/cmake/os/OS400.cmake index b8cad2917f9..502eeccc30a 100644 --- a/cmake/os/OS400.cmake +++ b/cmake/os/OS400.cmake @@ -1,4 +1,5 @@ -# Copyright (C) 2010 Sun Microsystems, Inc +# Copyright (c) 2010 Sun Microsystems, Inc. +# Use is subject to license terms. # # 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/cmake/os/SunOS.cmake b/cmake/os/SunOS.cmake index 9e8ca0ef11f..3d2b4b8949a 100644 --- a/cmake/os/SunOS.cmake +++ b/cmake/os/SunOS.cmake @@ -1,4 +1,4 @@ -# Copyright (C) 2010 Sun Microsystems, Inc +# Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved. # # 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/cmake/os/Windows.cmake b/cmake/os/Windows.cmake index 6a8c027daf8..0ccdc3cb6a4 100644 --- a/cmake/os/Windows.cmake +++ b/cmake/os/Windows.cmake @@ -1,4 +1,4 @@ -# Copyright (C) 2010, 2011, Oracle and/or its affiliates. All rights reserved. +# Copyright (c) 2010, 2011, Oracle and/or its affiliates. All rights reserved. # # 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/cmake/os/WindowsCache.cmake b/cmake/os/WindowsCache.cmake index 68bbb337e15..897012896c8 100644 --- a/cmake/os/WindowsCache.cmake +++ b/cmake/os/WindowsCache.cmake @@ -1,4 +1,4 @@ -# Copyright (C) 2010 Sun Microsystems, Inc +# Copyright (c) 2010, 2011, Oracle and/or its affiliates. All rights reserved. # # 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/cmake/package_name.cmake b/cmake/package_name.cmake index 7d6e4d7348a..212fa99d7f0 100644 --- a/cmake/package_name.cmake +++ b/cmake/package_name.cmake @@ -1,4 +1,4 @@ -# Copyright (C) 2010 Sun Microsystems, Inc +# Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved. # # 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/cmake/plugin.cmake b/cmake/plugin.cmake index 615b1d7a717..5e59b71fd91 100644 --- a/cmake/plugin.cmake +++ b/cmake/plugin.cmake @@ -196,6 +196,10 @@ MACRO(MYSQL_ADD_PLUGIN) # Install dynamic library MYSQL_INSTALL_TARGETS(${target} DESTINATION ${INSTALL_PLUGINDIR} COMPONENT Server) INSTALL_DEBUG_TARGET(${target} DESTINATION ${INSTALL_PLUGINDIR}/debug) + # Add installed files to list for RPMs + FILE(APPEND ${CMAKE_BINARY_DIR}/support-files/plugins.files + "%attr(755, root, root) %{_prefix}/${INSTALL_PLUGINDIR}/${ARG_MODULE_OUTPUT_NAME}.so\n" + "%attr(755, root, root) %{_prefix}/${INSTALL_PLUGINDIR}/debug/${ARG_MODULE_OUTPUT_NAME}.so\n") # For internal testing in PB2, append collections files IF(DEFINED ENV{PB2WORKDIR}) PLUGIN_APPEND_COLLECTIONS(${plugin}) diff --git a/cmake/readline.cmake b/cmake/readline.cmake index 5b6d23fc14e..4840229a82e 100644 --- a/cmake/readline.cmake +++ b/cmake/readline.cmake @@ -1,4 +1,5 @@ -# Copyright (C) 2009 Sun Microsystems, Inc +# Copyright (c) 2009, 2010 Sun Microsystems, Inc. +# Use is subject to license terms. # # 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/cmake/ssl.cmake b/cmake/ssl.cmake index c5aa2de2721..9b16bf09394 100644 --- a/cmake/ssl.cmake +++ b/cmake/ssl.cmake @@ -1,4 +1,4 @@ -# Copyright (C) 2009 Sun Microsystems, Inc +# Copyright (c) 2009, 2010, Oracle and/or its affiliates. All rights reserved. # # 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/cmake/stack_direction.c b/cmake/stack_direction.c index 11bcf803bfa..d75bbbfa035 100644 --- a/cmake/stack_direction.c +++ b/cmake/stack_direction.c @@ -1,4 +1,6 @@ -/* Copyright (C) 2009 Sun Microsystems, Inc +/* + Copyright (c) 2009 Sun Microsystems, Inc. + Use is subject to license terms. 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,4 +30,4 @@ int main() { int a; return ptr_f(&a); -}
\ No newline at end of file +} diff --git a/cmake/versioninfo.rc.in b/cmake/versioninfo.rc.in index fc3e72f33ac..6eb853936d2 100644 --- a/cmake/versioninfo.rc.in +++ b/cmake/versioninfo.rc.in @@ -1,3 +1,18 @@ +// Copyright (c) 2009, 2010, Oracle and/or its affiliates. All rights reserved.
+//
+// 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
+// the Free Software Foundation; version 2 of the License.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// 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 02110-1301 USA
+
#include <windows.h>
VS_VERSION_INFO VERSIONINFO
FILEVERSION @MAJOR_VERSION@,@MINOR_VERSION@,@PATCH_VERSION@,@TINY_VERSION@
diff --git a/cmake/zlib.cmake b/cmake/zlib.cmake index 59f1f7ba68e..3ede3aba228 100644 --- a/cmake/zlib.cmake +++ b/cmake/zlib.cmake @@ -1,4 +1,5 @@ -# Copyright (C) 2009 Sun Microsystems, Inc +# Copyright (c) 2009 Sun Microsystems, Inc. +# Use is subject to license terms. # # 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/cmd-line-utils/readline/CMakeLists.txt b/cmd-line-utils/readline/CMakeLists.txt index be84f22f210..abe83b5a85c 100644 --- a/cmd-line-utils/readline/CMakeLists.txt +++ b/cmd-line-utils/readline/CMakeLists.txt @@ -1,4 +1,4 @@ -# Copyright (c) 2006, 2010, Oracle and/or its affiliates. All rights reserved. +# Copyright (c) 2006, 2011, Oracle and/or its affiliates. All rights reserved. # # 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/config.h.cmake b/config.h.cmake index 6de3d997a55..8da37135cc1 100644 --- a/config.h.cmake +++ b/config.h.cmake @@ -219,7 +219,6 @@ #cmakedefine HAVE_PTHREAD_ATTR_SETSTACKSIZE 1 #cmakedefine HAVE_PTHREAD_CONDATTR_CREATE 1 #cmakedefine HAVE_PTHREAD_CONDATTR_SETCLOCK 1 -#cmakedefine HAVE_PTHREAD_INIT 1 #cmakedefine HAVE_PTHREAD_KEY_DELETE 1 #cmakedefine HAVE_PTHREAD_KEY_DELETE 1 #cmakedefine HAVE_PTHREAD_KILL 1 diff --git a/configure.cmake b/configure.cmake index c0043664486..6363a616b41 100644 --- a/configure.cmake +++ b/configure.cmake @@ -1,5 +1,5 @@ -# Copyright (C) 2009 Sun Microsystems,Inc +# Copyright (c) 2009, 2011, Oracle and/or its affiliates. All rights reserved. # # 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 @@ -257,6 +257,7 @@ CHECK_INCLUDE_FILES ("stdlib.h;sys/un.h" HAVE_SYS_UN_H) CHECK_INCLUDE_FILES (vis.h HAVE_VIS_H) CHECK_INCLUDE_FILES (wchar.h HAVE_WCHAR_H) CHECK_INCLUDE_FILES (wctype.h HAVE_WCTYPE_H) +CHECK_INCLUDE_FILES (sys/sockio.h HAVE_SYS_SOCKIO_H) IF(HAVE_SYS_STREAM_H) # Needs sys/stream.h on Solaris @@ -391,7 +392,6 @@ CHECK_FUNCTION_EXISTS (pthread_attr_setscope HAVE_PTHREAD_ATTR_SETSCOPE) CHECK_FUNCTION_EXISTS (pthread_attr_setstacksize HAVE_PTHREAD_ATTR_SETSTACKSIZE) CHECK_FUNCTION_EXISTS (pthread_condattr_create HAVE_PTHREAD_CONDATTR_CREATE) CHECK_FUNCTION_EXISTS (pthread_condattr_setclock HAVE_PTHREAD_CONDATTR_SETCLOCK) -CHECK_FUNCTION_EXISTS (pthread_init HAVE_PTHREAD_INIT) CHECK_FUNCTION_EXISTS (pthread_key_delete HAVE_PTHREAD_KEY_DELETE) CHECK_FUNCTION_EXISTS (pthread_rwlock_rdlock HAVE_PTHREAD_RWLOCK_RDLOCK) CHECK_FUNCTION_EXISTS (pthread_sigmask HAVE_PTHREAD_SIGMASK) diff --git a/dbug/dbug.c b/dbug/dbug.c index 16ac5277707..3dce91cd2ca 100644 --- a/dbug/dbug.c +++ b/dbug/dbug.c @@ -1863,7 +1863,6 @@ static void DBUGOpenFile(CODE_STATE *cs, const char *name,const char *end,int append) { FILE *fp; - BOOLEAN newfile; if (name != NULL) { @@ -1892,7 +1891,6 @@ static void DBUGOpenFile(CODE_STATE *cs, } else { - newfile= !EXISTS(name); if (!(fp= fopen(name, append ? "a+" : "w"))) { (void) fprintf(stderr, ERR_OPEN, cs->process, name); diff --git a/dbug/dbug_add_tags.pl b/dbug/dbug_add_tags.pl index 9653124cfd0..fe3637b4d12 100755 --- a/dbug/dbug_add_tags.pl +++ b/dbug/dbug_add_tags.pl @@ -1,5 +1,21 @@ #!/usr/bin/perl +# Copyright (c) 2002 MySQL AB, 2009 Sun Microsystems, Inc. +# Use is subject to license terms. +# +# 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 +# the Free Software Foundation; version 2 of the License. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# 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 02110-1301 USA + die "No files specified\n" unless $ARGV[0]; $ctags="exctags -x -f - --c-types=f -u"; diff --git a/dbug/tests.c b/dbug/tests.c index 837a477aef3..5fb84d48ffc 100644 --- a/dbug/tests.c +++ b/dbug/tests.c @@ -44,9 +44,6 @@ int main (int argc, char *argv[]) if (argc == 1) return 0; -#if defined(HAVE_PTHREAD_INIT) - pthread_init(); /* Must be called before DBUG_ENTER */ -#endif my_thread_global_init(); dup2(1, 2); diff --git a/extra/comp_err.c b/extra/comp_err.c index f1159232087..718b1ef7c36 100644 --- a/extra/comp_err.c +++ b/extra/comp_err.c @@ -1,4 +1,5 @@ -/* Copyright (C) 2004 MySQL AB +/* + Copyright (c) 2000, 2011, Oracle and/or its affiliates. All rights reserved. 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 @@ -11,7 +12,8 @@ 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +*/ /* Written by Anjuta Widenius diff --git a/extra/innochecksum.c b/extra/innochecksum.c index 9bd4bfcc0cd..b55b510b888 100644 --- a/extra/innochecksum.c +++ b/extra/innochecksum.c @@ -1,4 +1,5 @@ -/* Copyright (C) 2000-2005 MySQL AB & Innobase Oy +/* + Copyright (c) 2005, 2011, Oracle and/or its affiliates. All rights reserved. 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 @@ -11,7 +12,8 @@ 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +*/ /* InnoDB offline file checksum utility. 85% of the code in this file @@ -23,12 +25,7 @@ Published with a permission. */ -/* needed to have access to 64 bit file functions */ -#define _LARGEFILE_SOURCE -#define _LARGEFILE64_SOURCE - -#define _XOPEN_SOURCE 500 /* needed to include getopt.h on some platforms. */ - +#include <my_global.h> #include <stdio.h> #include <stdlib.h> #include <time.h> @@ -51,7 +48,6 @@ /* another argument to specify page ranges... seek to right spot and go from there */ typedef unsigned long int ulint; -typedef unsigned char uchar; /* innodb function in name; modified slightly to not have the ASM version (lots of #ifs that didn't apply) */ ulint mach_read_from_4(uchar *b) diff --git a/extra/my_print_defaults.c b/extra/my_print_defaults.c index 3f172a11042..d38ce1b49ff 100644 --- a/extra/my_print_defaults.c +++ b/extra/my_print_defaults.c @@ -1,5 +1,6 @@ -/* Copyright (C) 2000 MySQL AB +/* + Copyright (c) 2000, 2011, Oracle and/or its affiliates. All rights reserved. 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 @@ -12,7 +13,8 @@ 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +*/ /* ** print_default.c: diff --git a/extra/mysql_waitpid.c b/extra/mysql_waitpid.c index d5c9f2f42ae..23177eb51cb 100644 --- a/extra/mysql_waitpid.c +++ b/extra/mysql_waitpid.c @@ -1,4 +1,4 @@ -/* Copyright (C) 2003 MySQL AB +/* Copyright (c) 2003, 2010, Oracle and/or its affiliates. All rights reserved. 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 @@ -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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ /* Wait until a program dies */ diff --git a/extra/perror.c b/extra/perror.c index 3c00b9b11d7..af5d95d3c5b 100644 --- a/extra/perror.c +++ b/extra/perror.c @@ -1,4 +1,5 @@ -/* Copyright (C) 2000 MySQL AB +/* + Copyright (c) 2000, 2011, Oracle and/or its affiliates. All rights reserved. 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 @@ -11,7 +12,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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ /* Return error-text for system error messages and handler messages */ @@ -64,7 +65,8 @@ static struct my_option my_long_options[] = &ndb_code, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0}, #endif #ifdef HAVE_SYS_ERRLIST - {"all", 'a', "Print all the error messages and the number.", + {"all", 'a', "Print all the error messages and the number. Deprecated," + " will be removed in a future release.", &print_all_codes, &print_all_codes, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0}, #endif @@ -295,6 +297,8 @@ int main(int argc,char *argv[]) if (print_all_codes) { HA_ERRORS *ha_err_ptr; + printf("WARNING: option '-a/--all' is deprecated and will be removed in a" + " future release.\n"); for (code=1 ; code < sys_nerr ; code++) { if (sys_errlist[code] && sys_errlist[code][0]) diff --git a/extra/replace.c b/extra/replace.c index 1afc373ef38..f09d0454eef 100644 --- a/extra/replace.c +++ b/extra/replace.c @@ -1,4 +1,5 @@ -/* Copyright (c) 2000, 2011, Oracle and/or its affiliates. All rights reserved. +/* + Copyright (c) 2000, 2011, Oracle and/or its affiliates. All rights reserved. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License diff --git a/extra/resolve_stack_dump.c b/extra/resolve_stack_dump.c index 6ea818c601b..3422b7ef4de 100644 --- a/extra/resolve_stack_dump.c +++ b/extra/resolve_stack_dump.c @@ -1,4 +1,4 @@ -/* Copyright (C) 2000 MySQL AB +/* Copyright (c) 2001, 2010, Oracle and/or its affiliates. All rights reserved. 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 @@ -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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ /* Resolve numeric stack dump produced by mysqld 3.23.30 and later versions into symbolic names. By Sasha Pachev <sasha@mysql.com> diff --git a/extra/resolveip.c b/extra/resolveip.c index 094dfecae59..f69aa7fec5f 100644 --- a/extra/resolveip.c +++ b/extra/resolveip.c @@ -1,4 +1,4 @@ -/* Copyright (C) 2000 MySQL AB +/* Copyright (c) 2000, 2010, Oracle and/or its affiliates. All rights reserved. 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 @@ -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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ /* Resolves IP's to hostname and hostnames to IP's */ diff --git a/extra/yassl/include/cert_wrapper.hpp b/extra/yassl/include/cert_wrapper.hpp index 572b9f87293..d07e5b627b0 100644 --- a/extra/yassl/include/cert_wrapper.hpp +++ b/extra/yassl/include/cert_wrapper.hpp @@ -1,5 +1,6 @@ /* - Copyright (C) 2000-2007 MySQL AB + Copyright (c) 2005-2007 MySQL AB, 2008 Sun Microsystems, Inc. + Use is subject to license terms. 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/extra/yassl/include/openssl/prefix_ssl.h b/extra/yassl/include/openssl/prefix_ssl.h index fcd91cd5b9a..024cb0a9aff 100644 --- a/extra/yassl/include/openssl/prefix_ssl.h +++ b/extra/yassl/include/openssl/prefix_ssl.h @@ -1,5 +1,6 @@ /* - Copyright (C) 2006, 2007 MySQL AB + Copyright (c) 2006, 2007 MySQL AB, 2008 Sun Microsystems, Inc. + Use is subject to license terms. 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/extra/yassl/include/openssl/ssl.h b/extra/yassl/include/openssl/ssl.h index 05b34a0dc45..ba5fa51f34c 100644 --- a/extra/yassl/include/openssl/ssl.h +++ b/extra/yassl/include/openssl/ssl.h @@ -1,5 +1,6 @@ /* - Copyright (C) 2000-2007 MySQL AB + Copyright (c) 2005-2007 MySQL AB, 2008 Sun Microsystems, Inc. + Use is subject to license terms. 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/extra/yassl/include/yassl_error.hpp b/extra/yassl/include/yassl_error.hpp index d2473fb3e2b..87bb4c55e96 100644 --- a/extra/yassl/include/yassl_error.hpp +++ b/extra/yassl/include/yassl_error.hpp @@ -1,5 +1,6 @@ /* - Copyright (C) 2000-2007 MySQL AB + Copyright (c) 2005-2007 MySQL AB, 2010 Sun Microsystems, Inc. + Use is subject to license terms. 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/extra/yassl/include/yassl_imp.hpp b/extra/yassl/include/yassl_imp.hpp index 8893ba8a8ba..04e85c16a04 100644 --- a/extra/yassl/include/yassl_imp.hpp +++ b/extra/yassl/include/yassl_imp.hpp @@ -1,5 +1,6 @@ /* - Copyright (C) 2000-2007 MySQL AB + Copyright (c) 2005-2007 MySQL AB, 2008 Sun Microsystems, Inc. + Use is subject to license terms. 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/extra/yassl/include/yassl_int.hpp b/extra/yassl/include/yassl_int.hpp index 1cc4200d10c..433649c545b 100644 --- a/extra/yassl/include/yassl_int.hpp +++ b/extra/yassl/include/yassl_int.hpp @@ -1,5 +1,5 @@ /* - Copyright 2000-2008 MySQL AB, 2008 Sun Microsystems, Inc. + Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved. 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/extra/yassl/include/yassl_types.hpp b/extra/yassl/include/yassl_types.hpp index 28535792828..c73a54a7c15 100644 --- a/extra/yassl/include/yassl_types.hpp +++ b/extra/yassl/include/yassl_types.hpp @@ -1,5 +1,6 @@ /* - Copyright 2000-2008 MySQL AB, 2008 Sun Microsystems, Inc. + Copyright (c) 2005-2007 MySQL AB, 2008 Sun Microsystems, Inc. + Use is subject to license terms. 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/extra/yassl/src/buffer.cpp b/extra/yassl/src/buffer.cpp index 5bd69905772..a5028e7bb53 100644 --- a/extra/yassl/src/buffer.cpp +++ b/extra/yassl/src/buffer.cpp @@ -1,5 +1,6 @@ /* - Copyright (C) 2000-2007 MySQL AB + Copyright (c) 2005-2007 MySQL AB, 2009 Sun Microsystems, Inc. + Use is subject to license terms. 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/extra/yassl/src/cert_wrapper.cpp b/extra/yassl/src/cert_wrapper.cpp index ebec0882265..d8660533f2e 100644 --- a/extra/yassl/src/cert_wrapper.cpp +++ b/extra/yassl/src/cert_wrapper.cpp @@ -1,5 +1,6 @@ /* - Copyright 2000-2008 MySQL AB, 2008 Sun Microsystems, Inc. + Copyright (c) 2005-2007 MySQL AB, 2008, 2009 Sun Microsystems, Inc. + Use is subject to license terms. 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/extra/yassl/src/crypto_wrapper.cpp b/extra/yassl/src/crypto_wrapper.cpp index 09afc835fce..41b03f037a7 100644 --- a/extra/yassl/src/crypto_wrapper.cpp +++ b/extra/yassl/src/crypto_wrapper.cpp @@ -1,5 +1,5 @@ /* - Copyright (C) 2000-2007 MySQL AB + Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved. 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/extra/yassl/src/handshake.cpp b/extra/yassl/src/handshake.cpp index b4d9005af15..08fae4ac17d 100644 --- a/extra/yassl/src/handshake.cpp +++ b/extra/yassl/src/handshake.cpp @@ -1,5 +1,6 @@ /* - Copyright (C) 2000-2007 MySQL AB + Copyright (c) 2005-2008 MySQL AB, 2009 Sun Microsystems, Inc. + Use is subject to license terms. 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/extra/yassl/src/socket_wrapper.cpp b/extra/yassl/src/socket_wrapper.cpp index cebbd9c5529..3cf6c14c4b3 100644 --- a/extra/yassl/src/socket_wrapper.cpp +++ b/extra/yassl/src/socket_wrapper.cpp @@ -1,5 +1,5 @@ /* - Copyright (C) 2000-2007 MySQL AB + Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved. 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/extra/yassl/src/ssl.cpp b/extra/yassl/src/ssl.cpp index 4d8b6ac69b8..67d2d428e51 100644 --- a/extra/yassl/src/ssl.cpp +++ b/extra/yassl/src/ssl.cpp @@ -1,5 +1,6 @@ /* - Copyright 2000-2008 MySQL AB, 2008 Sun Microsystems, Inc. + Copyright (c) 2005-2007 MySQL AB, 2008-2010 Sun Microsystems, Inc. + Use is subject to license terms. 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/extra/yassl/src/yassl_error.cpp b/extra/yassl/src/yassl_error.cpp index 4bd38445a6b..9f042ddbcd5 100644 --- a/extra/yassl/src/yassl_error.cpp +++ b/extra/yassl/src/yassl_error.cpp @@ -1,5 +1,5 @@ /* - Copyright 2000-2008 MySQL AB, 2008 Sun Microsystems, Inc. + Copyright (c) 2005, 2011, Oracle and/or its affiliates. All rights reserved. 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/extra/yassl/src/yassl_imp.cpp b/extra/yassl/src/yassl_imp.cpp index 5128c00418e..48afc86ae20 100644 --- a/extra/yassl/src/yassl_imp.cpp +++ b/extra/yassl/src/yassl_imp.cpp @@ -1,5 +1,5 @@ /* - Copyright 2000-2008 MySQL AB, 2008 Sun Microsystems, Inc. + Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved. 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/extra/yassl/src/yassl_int.cpp b/extra/yassl/src/yassl_int.cpp index 5af2f180bb1..66a854e6922 100644 --- a/extra/yassl/src/yassl_int.cpp +++ b/extra/yassl/src/yassl_int.cpp @@ -1,5 +1,5 @@ /* - Copyright 2000-2008 MySQL AB, 2008 Sun Microsystems, Inc. + Copyright (c) 2005, 2011, Oracle and/or its affiliates. All rights reserved. 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/extra/yassl/taocrypt/include/asn.hpp b/extra/yassl/taocrypt/include/asn.hpp index 168b8a8c755..ece7140741a 100644 --- a/extra/yassl/taocrypt/include/asn.hpp +++ b/extra/yassl/taocrypt/include/asn.hpp @@ -1,5 +1,6 @@ /* - Copyright (C) 2000-2007 MySQL AB + Copyright (c) 2005-2007 MySQL AB, 2010 Sun Microsystems, Inc. + Use is subject to license terms. 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/extra/yassl/taocrypt/include/block.hpp b/extra/yassl/taocrypt/include/block.hpp index d5bc8756fdd..9885c44d2c9 100644 --- a/extra/yassl/taocrypt/include/block.hpp +++ b/extra/yassl/taocrypt/include/block.hpp @@ -1,5 +1,6 @@ /* - Copyright (C) 2000-2007 MySQL AB + Copyright (c) 2005-2007 MySQL AB, 2009 Sun Microsystems, Inc. + Use is subject to license terms. 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/extra/yassl/taocrypt/include/blowfish.hpp b/extra/yassl/taocrypt/include/blowfish.hpp index 94bbab7aea8..99d932353df 100644 --- a/extra/yassl/taocrypt/include/blowfish.hpp +++ b/extra/yassl/taocrypt/include/blowfish.hpp @@ -1,5 +1,5 @@ /* - Copyright (C) 2000-2007 MySQL AB + Copyright (c) 2006, 2010, Oracle and/or its affiliates. All rights reserved. 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/extra/yassl/taocrypt/include/misc.hpp b/extra/yassl/taocrypt/include/misc.hpp index 431316b84d1..a375b17eb1e 100644 --- a/extra/yassl/taocrypt/include/misc.hpp +++ b/extra/yassl/taocrypt/include/misc.hpp @@ -1,5 +1,5 @@ /* - Copyright (C) 2000-2007 MySQL AB + Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved. 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/extra/yassl/taocrypt/include/modes.hpp b/extra/yassl/taocrypt/include/modes.hpp index 4575fe1414b..2285bd0e845 100644 --- a/extra/yassl/taocrypt/include/modes.hpp +++ b/extra/yassl/taocrypt/include/modes.hpp @@ -1,5 +1,6 @@ /* - Copyright (C) 2000-2007 MySQL AB + Copyright (c) 2005-2007 MySQL AB, 2009 Sun Microsystems, Inc. + Use is subject to license terms. 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/extra/yassl/taocrypt/include/runtime.hpp b/extra/yassl/taocrypt/include/runtime.hpp index 9d12b253dd6..ad66a5bf9d0 100644 --- a/extra/yassl/taocrypt/include/runtime.hpp +++ b/extra/yassl/taocrypt/include/runtime.hpp @@ -1,5 +1,5 @@ /* - Copyright (C) 2000-2007 MySQL AB + Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved. 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/extra/yassl/taocrypt/src/aes.cpp b/extra/yassl/taocrypt/src/aes.cpp index 42cb0622e56..a3fbd9b7d74 100644 --- a/extra/yassl/taocrypt/src/aes.cpp +++ b/extra/yassl/taocrypt/src/aes.cpp @@ -1,5 +1,5 @@ /* - Copyright (C) 2000-2007 MySQL AB + Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved. 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/extra/yassl/taocrypt/src/algebra.cpp b/extra/yassl/taocrypt/src/algebra.cpp index 437563b9093..6da0040c6d9 100644 --- a/extra/yassl/taocrypt/src/algebra.cpp +++ b/extra/yassl/taocrypt/src/algebra.cpp @@ -1,5 +1,5 @@ /* - Copyright (C) 2000-2007 MySQL AB + Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved. 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/extra/yassl/taocrypt/src/asn.cpp b/extra/yassl/taocrypt/src/asn.cpp index f87b466502e..1b81db4f0a4 100644 --- a/extra/yassl/taocrypt/src/asn.cpp +++ b/extra/yassl/taocrypt/src/asn.cpp @@ -1,5 +1,6 @@ /* - Copyright (C) 2000-2007 MySQL AB + Copyright (c) 2005-2007 MySQL AB, 2009, 2010 Sun Microsystems, Inc. + Use is subject to license terms. 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/extra/yassl/taocrypt/src/blowfish.cpp b/extra/yassl/taocrypt/src/blowfish.cpp index 2a5ae7ffadf..445de6d8935 100644 --- a/extra/yassl/taocrypt/src/blowfish.cpp +++ b/extra/yassl/taocrypt/src/blowfish.cpp @@ -1,5 +1,5 @@ /* - Copyright (C) 2000-2007 MySQL AB + Copyright (c) 2006, 2010, Oracle and/or its affiliates. All rights reserved. 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/extra/yassl/taocrypt/src/coding.cpp b/extra/yassl/taocrypt/src/coding.cpp index 7fc681e1a05..7c6a6a8bd8b 100644 --- a/extra/yassl/taocrypt/src/coding.cpp +++ b/extra/yassl/taocrypt/src/coding.cpp @@ -1,5 +1,5 @@ /* - Copyright (C) 2000-2007 MySQL AB + Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved. 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/extra/yassl/taocrypt/src/integer.cpp b/extra/yassl/taocrypt/src/integer.cpp index b054e98bef4..c00815df8cf 100644 --- a/extra/yassl/taocrypt/src/integer.cpp +++ b/extra/yassl/taocrypt/src/integer.cpp @@ -1,5 +1,5 @@ /* - Copyright (C) 2000-2007 MySQL AB + Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved. 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/extra/yassl/taocrypt/src/misc.cpp b/extra/yassl/taocrypt/src/misc.cpp index 978665b2f7c..b0382d0ba69 100644 --- a/extra/yassl/taocrypt/src/misc.cpp +++ b/extra/yassl/taocrypt/src/misc.cpp @@ -1,5 +1,5 @@ /* - Copyright (C) 2000-2007 MySQL AB + Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved. 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/extra/yassl/taocrypt/src/random.cpp b/extra/yassl/taocrypt/src/random.cpp index 729421fc71d..1be0fed612f 100644 --- a/extra/yassl/taocrypt/src/random.cpp +++ b/extra/yassl/taocrypt/src/random.cpp @@ -1,5 +1,5 @@ /* - Copyright (C) 2000-2007 MySQL AB + Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved. 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/extra/yassl/taocrypt/src/twofish.cpp b/extra/yassl/taocrypt/src/twofish.cpp index 85feaa23280..c7f2e27d4f3 100644 --- a/extra/yassl/taocrypt/src/twofish.cpp +++ b/extra/yassl/taocrypt/src/twofish.cpp @@ -1,5 +1,5 @@ /* - Copyright (C) 2000-2007 MySQL AB + Copyright (c) 2006, 2010, Oracle and/or its affiliates. All rights reserved. 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/extra/yassl/testsuite/test.hpp b/extra/yassl/testsuite/test.hpp index e7de3268ec4..e14cdc54ae0 100644 --- a/extra/yassl/testsuite/test.hpp +++ b/extra/yassl/testsuite/test.hpp @@ -1,5 +1,5 @@ /* - Copyright (C) 2006, 2007 MySQL AB + Copyright (c) 2006, 2010, Oracle and/or its affiliates. All rights reserved. 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/include/CMakeLists.txt b/include/CMakeLists.txt index 773c26f9d0a..5d9c701fda8 100644 --- a/include/CMakeLists.txt +++ b/include/CMakeLists.txt @@ -1,4 +1,4 @@ -# Copyright (c) 2006, 2010, Oracle and/or its affiliates. All rights reserved. +# Copyright (c) 2006, 2011, Oracle and/or its affiliates. All rights reserved. # # 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/include/atomic/gcc_builtins.h b/include/atomic/gcc_builtins.h index d03d28f572e..fb6a537d204 100644 --- a/include/atomic/gcc_builtins.h +++ b/include/atomic/gcc_builtins.h @@ -1,7 +1,7 @@ #ifndef ATOMIC_GCC_BUILTINS_INCLUDED #define ATOMIC_GCC_BUILTINS_INCLUDED -/* Copyright (C) 2008 MySQL AB +/* Copyright (c) 2008, 2010, Oracle and/or its affiliates. All rights reserved. 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 @@ -14,7 +14,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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ #define make_atomic_add_body(S) \ v= __sync_fetch_and_add(a, v); diff --git a/include/atomic/generic-msvc.h b/include/atomic/generic-msvc.h index a84cde6b2c3..6c5272c98f4 100644 --- a/include/atomic/generic-msvc.h +++ b/include/atomic/generic-msvc.h @@ -1,4 +1,5 @@ -/* Copyright (C) 2006-2008 MySQL AB, 2008-2009 Sun Microsystems, Inc. +/* Copyright (c) 2006-2008 MySQL AB, 2009 Sun Microsystems, Inc. + Use is subject to license terms. 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 @@ -11,7 +12,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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ #ifndef _atomic_h_cleanup_ #define _atomic_h_cleanup_ "atomic/generic-msvc.h" diff --git a/include/atomic/nolock.h b/include/atomic/nolock.h index 4c871473b60..1da184158ab 100644 --- a/include/atomic/nolock.h +++ b/include/atomic/nolock.h @@ -1,7 +1,7 @@ #ifndef ATOMIC_NOLOCK_INCLUDED #define ATOMIC_NOLOCK_INCLUDED -/* Copyright (C) 2006 MySQL AB +/* Copyright (c) 2006, 2010, Oracle and/or its affiliates. All rights reserved. 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 @@ -14,7 +14,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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ #if defined(__i386__) || defined(_MSC_VER) || defined(__x86_64__) \ || defined(HAVE_GCC_ATOMIC_BUILTINS) \ diff --git a/include/atomic/rwlock.h b/include/atomic/rwlock.h index a31f8ed6ca1..f6bf7d0b76f 100644 --- a/include/atomic/rwlock.h +++ b/include/atomic/rwlock.h @@ -1,7 +1,8 @@ #ifndef ATOMIC_RWLOCK_INCLUDED #define ATOMIC_RWLOCK_INCLUDED -/* Copyright (C) 2006 MySQL AB, 2009 Sun Microsystems, Inc. +/* Copyright (c) 2006 MySQL AB, 2009 Sun Microsystems, Inc. + Use is subject to license terms. 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 @@ -14,7 +15,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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ #define MY_ATOMIC_MODE_RWLOCKS 1 diff --git a/include/atomic/solaris.h b/include/atomic/solaris.h index 5643f878cd2..7b6f0561ff0 100644 --- a/include/atomic/solaris.h +++ b/include/atomic/solaris.h @@ -1,4 +1,4 @@ -/* Copyright (C) 2008 MySQL AB, 2009 Sun Microsystems, Inc +/* Copyright (c) 2008, 2010, Oracle and/or its affiliates. All rights reserved. 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 @@ -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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ #ifndef _atomic_h_cleanup_ #define _atomic_h_cleanup_ "atomic/solaris.h" diff --git a/include/atomic/x86-gcc.h b/include/atomic/x86-gcc.h index ea3202aa9c9..2238347d419 100644 --- a/include/atomic/x86-gcc.h +++ b/include/atomic/x86-gcc.h @@ -1,7 +1,7 @@ #ifndef ATOMIC_X86_GCC_INCLUDED #define ATOMIC_X86_GCC_INCLUDED -/* Copyright (C) 2006 MySQL AB +/* Copyright (c) 2006, 2010, Oracle and/or its affiliates. All rights reserved. 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 @@ -14,7 +14,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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ /* XXX 64-bit atomic operations can be implemented using diff --git a/include/decimal.h b/include/decimal.h index bc948125f22..935d341437d 100644 --- a/include/decimal.h +++ b/include/decimal.h @@ -1,4 +1,4 @@ -/* Copyright (C) 2000 MySQL AB +/* Copyright (c) 2000, 2011, Oracle and/or its affiliates. All rights reserved. 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 @@ -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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ #ifndef _decimal_h #define _decimal_h @@ -21,6 +21,15 @@ typedef enum decimal_round_mode; typedef int32 decimal_digit_t; +/** + intg is the number of *decimal* digits (NOT number of decimal_digit_t's !) + before the point + frac is the number of decimal digits after the point + len is the length of buf (length of allocated space) in decimal_digit_t's, + not in bytes + sign false means positive, true means negative + buf is an array of decimal_digit_t's + */ typedef struct st_decimal_t { int intg, frac, len; my_bool sign; diff --git a/include/errmsg.h b/include/errmsg.h index f1d7dd65f97..64ec2df395c 100644 --- a/include/errmsg.h +++ b/include/errmsg.h @@ -1,7 +1,7 @@ #ifndef ERRMSG_INCLUDED #define ERRMSG_INCLUDED -/* Copyright (C) 2000 MySQL AB +/* Copyright (c) 2000, 2010, Oracle and/or its affiliates. All rights reserved. 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 @@ -14,7 +14,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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ /* Error messages for MySQL clients */ /* (Error messages for the daemon are in sql/share/errmsg.txt) */ diff --git a/include/ft_global.h b/include/ft_global.h index eb1f84d307b..8a1069d6e62 100644 --- a/include/ft_global.h +++ b/include/ft_global.h @@ -1,4 +1,5 @@ -/* Copyright (C) 2000-2003 MySQL AB +/* Copyright (c) 2000-2007 MySQL AB, 2009 Sun Microsystems, Inc. + Use is subject to license terms. 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 @@ -11,7 +12,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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ /* Written by Sergei A. Golubchik, who has a shared copyright to this code */ diff --git a/include/hash.h b/include/hash.h index ae3f017a03e..98bcf911db2 100644 --- a/include/hash.h +++ b/include/hash.h @@ -1,4 +1,4 @@ -/* Copyright 2000-2008 MySQL AB, 2008 Sun Microsystems, Inc. +/* Copyright (c) 2000, 2010, Oracle and/or its affiliates. All rights reserved. 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 @@ -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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ /* Dynamic hashing of record with different key-length */ diff --git a/include/heap.h b/include/heap.h index b23ec47db67..6ce95c88521 100644 --- a/include/heap.h +++ b/include/heap.h @@ -1,5 +1,5 @@ -/* Copyright (C) 2000, 2011, Oracle and/or its affiliates. All rights - reserved +/* + Copyright (c) 2000, 2011, Oracle and/or its affiliates. All rights reserved. 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 @@ -12,7 +12,8 @@ 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +*/ /* This file should be included when using heap_database_functions */ /* Author: Michael Widenius */ @@ -50,6 +51,7 @@ typedef struct st_heapinfo /* Struct from heap_info */ uint reclength; /* Length of one record */ int errkey; ulonglong auto_increment; + time_t create_time; } HEAPINFO; @@ -148,6 +150,7 @@ typedef struct st_heap_share uint open_count; uchar *del_link; /* Link to next block with del. rec */ char * name; /* Name of "memory-file" */ + time_t create_time; THR_LOCK lock; mysql_mutex_t intern_lock; /* Locking for use with _locking */ my_bool delete_on_close; diff --git a/include/keycache.h b/include/keycache.h index bc14bdef0bf..da6624725e7 100644 --- a/include/keycache.h +++ b/include/keycache.h @@ -1,4 +1,4 @@ -/* Copyright (C) 2003 MySQL AB, 2009 Sun Microsystems, Inc +/* Copyright (c) 2003, 2010, Oracle and/or its affiliates. All rights reserved. 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 @@ -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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ /* Key cache variable structures */ diff --git a/include/lf.h b/include/lf.h index 9698086bacf..cdd24c07502 100644 --- a/include/lf.h +++ b/include/lf.h @@ -1,4 +1,4 @@ -/* Copyright (C) 2007-2008 MySQL AB, 2008-2009 Sun Microsystems, Inc. +/* Copyright (c) 2007, 2010, Oracle and/or its affiliates. All rights reserved. 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 @@ -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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ #ifndef _lf_h #define _lf_h diff --git a/include/m_ctype.h b/include/m_ctype.h index ff0a870b268..2a7175f739a 100644 --- a/include/m_ctype.h +++ b/include/m_ctype.h @@ -1,4 +1,4 @@ -/* Copyright (C) 2000 MySQL AB +/* Copyright (c) 2000, 2011, Oracle and/or its affiliates. All rights reserved. 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 @@ -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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ /* A better inplementation of the UNIX ctype(3) library. diff --git a/include/m_string.h b/include/m_string.h index ba906e2e62c..6268888028f 100644 --- a/include/m_string.h +++ b/include/m_string.h @@ -1,4 +1,5 @@ -/* Copyright (C) 2000 MySQL AB +/* + Copyright (c) 2000, 2011, Oracle and/or its affiliates. All rights reserved. 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 @@ -11,7 +12,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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ /* There may be prolems include all of theese. Try to test in configure with ones are needed? */ diff --git a/include/ma_dyncol.h b/include/ma_dyncol.h index 687823a4e73..6174328d62a 100644 --- a/include/ma_dyncol.h +++ b/include/ma_dyncol.h @@ -79,15 +79,15 @@ struct st_dynamic_column_value unsigned long long ulong_value; double double_value; struct { - LEX_STRING string_value; + LEX_STRING value; CHARSET_INFO *charset; - }; + } string; struct { - decimal_digit_t decimal_buffer[DECIMAL_BUFF_LENGTH]; - decimal_t decimal_value; - }; + decimal_digit_t buffer[DECIMAL_BUFF_LENGTH]; + decimal_t value; + } decimal; MYSQL_TIME time_value; - }; + } x; }; typedef struct st_dynamic_column_value DYNAMIC_COLUMN_VALUE; diff --git a/include/maria.h b/include/maria.h index 08febdb1a40..3ee5b6b9df8 100644 --- a/include/maria.h +++ b/include/maria.h @@ -461,6 +461,8 @@ void maria_change_pagecache(PAGECACHE *old_key_cache, int maria_preload(MARIA_HA *info, ulonglong key_map, my_bool ignore_leaves); void maria_versioning(MARIA_HA *info, my_bool versioning); void maria_ignore_trids(MARIA_HA *info); +uint maria_max_key_length(void); +#define maria_max_key_segments() HA_MAX_KEY_SEG /* fulltext functions */ FT_INFO *maria_ft_init_search(uint,void *, uint, uchar *, size_t, diff --git a/include/my_aes.h b/include/my_aes.h index 2e2a66b4968..58a78919023 100644 --- a/include/my_aes.h +++ b/include/my_aes.h @@ -1,7 +1,8 @@ #ifndef MY_AES_INCLUDED #define MY_AES_INCLUDED -/* Copyright (C) 2002 MySQL AB +/* Copyright (c) 2002, 2006 MySQL AB, 2009 Sun Microsystems, Inc. + Use is subject to license terms. 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 @@ -14,7 +15,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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ /* Header file for my_aes.c */ diff --git a/include/my_alarm.h b/include/my_alarm.h index fa396cf02f9..57d86f56755 100644 --- a/include/my_alarm.h +++ b/include/my_alarm.h @@ -1,4 +1,4 @@ -/* Copyright (C) 2000 MySQL AB +/* Copyright (c) 2000, 2010, Oracle and/or its affiliates. All rights reserved. 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 @@ -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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ /* File to include when we want to use alarm or a loop_counter to display diff --git a/include/my_alloc.h b/include/my_alloc.h index 11e1331988b..85ac75fc666 100644 --- a/include/my_alloc.h +++ b/include/my_alloc.h @@ -1,4 +1,4 @@ -/* Copyright (C) 2000 MySQL AB +/* Copyright (c) 2000, 2010, Oracle and/or its affiliates. All rights reserved. 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 @@ -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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ /* Data structures for mysys/my_alloc.c (root memory allocator) diff --git a/include/my_atomic.h b/include/my_atomic.h index 849b54f3532..7c589cd776a 100644 --- a/include/my_atomic.h +++ b/include/my_atomic.h @@ -1,6 +1,7 @@ #ifndef MY_ATOMIC_INCLUDED #define MY_ATOMIC_INCLUDED -/* Copyright (C) 2006 MySQL AB + +/* Copyright (c) 2006, 2010, Oracle and/or its affiliates. All rights reserved. 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 @@ -13,7 +14,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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ /* This header defines five atomic operations: diff --git a/include/my_attribute.h b/include/my_attribute.h index 13d1dc42fc1..14ed35cfe24 100644 --- a/include/my_attribute.h +++ b/include/my_attribute.h @@ -1,4 +1,4 @@ -/* Copyright (C) 2000-2003 MySQL AB +/* Copyright (c) 2000, 2010, Oracle and/or its affiliates. All rights reserved. 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 @@ -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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ /* Helper macros used for setting different __attributes__ diff --git a/include/my_base.h b/include/my_base.h index c71df96dbed..4edecf63d18 100644 --- a/include/my_base.h +++ b/include/my_base.h @@ -1,4 +1,4 @@ -/* Copyright (C) 2000, 2011, Oracle and/or its affiliates. All rights +/* Copyright (c) 2000, 2011, Oracle and/or its affiliates. All rights reserved. reserved This program is free software; you can redistribute it and/or modify @@ -12,7 +12,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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ /* This file includes constants used with all databases */ @@ -456,11 +456,13 @@ enum ha_base_keytype { #define HA_ERR_FILE_TOO_SHORT 175 /* File too short */ #define HA_ERR_WRONG_CRC 176 /* Wrong CRC on page */ #define HA_ERR_TOO_MANY_CONCURRENT_TRXS 177 /*Too many active concurrent transactions */ -#define HA_ERR_INDEX_COL_TOO_LONG 178 /* Index column length exceeds limit */ -#define HA_ERR_ROW_NOT_VISIBLE 179 -#define HA_ERR_ABORTED_BY_USER 180 -#define HA_ERR_DISK_FULL 181 -#define HA_ERR_LAST 181 /* Copy of last error nr */ +#define HA_ERR_INDEX_COL_TOO_LONG 178 /* Index column length exceeds limit */ +#define HA_ERR_INDEX_CORRUPT 179 /* Index corrupted */ +#define HA_ERR_UNDO_REC_TOO_BIG 180 /* Undo log record too big */ +#define HA_ERR_ROW_NOT_VISIBLE 181 +#define HA_ERR_ABORTED_BY_USER 182 +#define HA_ERR_DISK_FULL 183 +#define HA_ERR_LAST 183 /* Copy of last error nr */ /* Number of different errors */ #define HA_ERR_ERRORS (HA_ERR_LAST - HA_ERR_FIRST + 1) diff --git a/include/my_bitmap.h b/include/my_bitmap.h index 0edda50de05..7b78252ea27 100644 --- a/include/my_bitmap.h +++ b/include/my_bitmap.h @@ -55,6 +55,10 @@ extern my_bool bitmap_test_and_clear(MY_BITMAP *map, uint bitmap_bit); extern my_bool bitmap_fast_test_and_set(MY_BITMAP *map, uint bitmap_bit); extern my_bool bitmap_union_is_set_all(const MY_BITMAP *map1, const MY_BITMAP *map2); +extern my_bool bitmap_exists_intersection(const MY_BITMAP **bitmap_array, + uint bitmap_count, + uint start_bit, uint end_bit); + extern uint bitmap_set_next(MY_BITMAP *map); extern uint bitmap_get_first(const MY_BITMAP *map); extern uint bitmap_get_first_set(const MY_BITMAP *map); diff --git a/include/my_compare.h b/include/my_compare.h index 39186e40a15..b47eb65199e 100644 --- a/include/my_compare.h +++ b/include/my_compare.h @@ -135,6 +135,8 @@ extern HA_KEYSEG *ha_find_null(HA_KEYSEG *keyseg, const uchar *a); if we're scanning "t.key BETWEEN 10 AND 20" and got a "t.key=21" tuple (the engine should stop scanning and return HA_ERR_END_OF_FILE right away). + 3=ICP_ABORTED_BY_USER - engine must stop scanning and should return + HA_ERR_ABORTED_BY_USER right away -1= ICP_ERROR - Reserved for internal errors in engines. Should not be returned by index_cond_func_xxx */ @@ -143,7 +145,8 @@ typedef enum icp_result { ICP_ERROR=-1, ICP_NO_MATCH=0, ICP_MATCH=1, - ICP_OUT_OF_RANGE=2 + ICP_OUT_OF_RANGE=2, + ICP_ABORTED_BY_USER=3 } ICP_RESULT; typedef ICP_RESULT (*index_cond_func_t)(void *param); diff --git a/include/my_compiler.h b/include/my_compiler.h index 9fe8de574a7..000d4e42848 100644 --- a/include/my_compiler.h +++ b/include/my_compiler.h @@ -1,7 +1,7 @@ #ifndef MY_COMPILER_INCLUDED #define MY_COMPILER_INCLUDED -/* Copyright (c) 2010, Oracle and/or its affiliates. +/* Copyright (c) 2010, 2011, Oracle and/or its affiliates. All rights reserved. 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/include/my_dbug.h b/include/my_dbug.h index e4de723e1d7..920ba4d4f90 100644 --- a/include/my_dbug.h +++ b/include/my_dbug.h @@ -1,5 +1,5 @@ -/* Copyright (c) 2009-2011 Monty Program Ab - Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved. +/* Copyright (c) 2000, 2010, Oracle and/or its affiliates. + Copyright (c) 2009-2011 Monty Program Ab 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 @@ -12,7 +12,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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ #ifndef _my_dbug_h #define _my_dbug_h diff --git a/include/my_dir.h b/include/my_dir.h index de21bee7385..1ee002cc380 100644 --- a/include/my_dir.h +++ b/include/my_dir.h @@ -1,4 +1,4 @@ -/* Copyright (C) 2000 MySQL AB +/* Copyright (c) 2000, 2010, Oracle and/or its affiliates. All rights reserved. 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 @@ -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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ #ifndef MY_DIR_H #define MY_DIR_H diff --git a/include/my_getopt.h b/include/my_getopt.h index 6c1db277db8..092accc05a1 100644 --- a/include/my_getopt.h +++ b/include/my_getopt.h @@ -1,4 +1,5 @@ -/* Copyright (c) 2002, 2011, Oracle and/or its affiliates. All rights reserved. +/* + Copyright (c) 2002, 2011, Oracle and/or its affiliates. All rights reserved. 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/include/my_global.h b/include/my_global.h index 5590570df94..451cb9127a3 100644 --- a/include/my_global.h +++ b/include/my_global.h @@ -1,4 +1,5 @@ -/* Copyright (c) 2000, 2011, Oracle and/or its affiliates. All rights reserved. +/* + Copyright (c) 2001, 2011, Oracle and/or its affiliates. All rights reserved. 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 @@ -626,6 +627,8 @@ typedef SOCKET_SIZE_TYPE size_socket; #define FN_LIBCHAR '\\' #define FN_LIBCHAR2 '/' #define FN_DIRSEP "/\\" /* Valid directory separators */ +#define FN_EXEEXT ".exe" +#define FN_SOEXT ".dll" #define FN_ROOTDIR "\\" #define FN_DEVCHAR ':' #define FN_NETWORK_DRIVES /* Uses \\ to indicate network drives */ @@ -634,6 +637,8 @@ typedef SOCKET_SIZE_TYPE size_socket; #define FN_LIBCHAR '/' #define FN_LIBCHAR2 '/' #define FN_DIRSEP "/" /* Valid directory separators */ +#define FN_EXEEXT "" +#define FN_SOEXT ".so" #define FN_ROOTDIR "/" #endif diff --git a/include/my_libwrap.h b/include/my_libwrap.h index 8235c00d8f3..9a017611408 100644 --- a/include/my_libwrap.h +++ b/include/my_libwrap.h @@ -1,7 +1,8 @@ #ifndef MY_LIBWRAP_INCLUDED #define MY_LIBWRAP_INCLUDED -/* Copyright (C) 2000 MySQL AB +/* Copyright (c) 2000, 2006 MySQL AB, 2009 Sun Microsystems, Inc. + Use is subject to license terms. 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 @@ -14,7 +15,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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ #ifdef HAVE_LIBWRAP #include <tcpd.h> diff --git a/include/my_list.h b/include/my_list.h index ff086e1725b..294be663d0e 100644 --- a/include/my_list.h +++ b/include/my_list.h @@ -1,4 +1,4 @@ -/* Copyright (C) 2000 MySQL AB +/* Copyright (c) 2000, 2010, Oracle and/or its affiliates. All rights reserved. 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 @@ -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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ #ifndef _list_h_ #define _list_h_ diff --git a/include/my_nosys.h b/include/my_nosys.h index 93d70a6cfa6..97f36d00c57 100644 --- a/include/my_nosys.h +++ b/include/my_nosys.h @@ -1,4 +1,4 @@ -/* Copyright (C) 2000 MySQL AB +/* Copyright (c) 2000, 2010, Oracle and/or its affiliates. All rights reserved. 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 @@ -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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ /* Header to remove use of my_functions in functions where we need speed and diff --git a/include/my_rdtsc.h b/include/my_rdtsc.h index 81bc1aafb58..38ab0de8040 100644 --- a/include/my_rdtsc.h +++ b/include/my_rdtsc.h @@ -1,4 +1,5 @@ -/* Copyright (C) 2008, 2009 Sun Microsystems, Inc +/* Copyright (c) 2008 MySQL AB, 2009 Sun Microsystems, Inc. + Use is subject to license terms. 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 @@ -11,7 +12,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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ /* rdtsc3 -- multi-platform timer code diff --git a/include/my_stacktrace.h b/include/my_stacktrace.h index 8c2c97c68e5..df5741fa3d8 100644 --- a/include/my_stacktrace.h +++ b/include/my_stacktrace.h @@ -1,4 +1,4 @@ -/* Copyright (C) 2000 MySQL AB +/* Copyright (c) 2001, 2010, Oracle and/or its affiliates. All rights reserved. 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 @@ -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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ #ifndef _my_stacktrace_h_ #define _my_stacktrace_h_ diff --git a/include/my_sys.h b/include/my_sys.h index ca27e0f76a5..554ee487a4f 100644 --- a/include/my_sys.h +++ b/include/my_sys.h @@ -63,7 +63,6 @@ typedef struct my_aio_result { #define MY_WME 16 /* Write message on error */ #define MY_WAIT_IF_FULL 32 /* Wait and try again if disk full error */ #define MY_IGNORE_BADFD 32 /* my_sync: ignore 'bad descriptor' errors */ -#define MY_SYNC_DIR 8192 /* my_create/delete/rename: sync directory */ #define MY_UNUSED 64 /* Unused (was support for RAID) */ #define MY_FULL_IO 512 /* For my_read - loop intil I/O is complete */ #define MY_DONT_CHECK_FILESIZE 128 /* Option to init_io_cache() */ @@ -84,6 +83,7 @@ typedef struct my_aio_result { #define MY_DONT_OVERWRITE_FILE 2048 /* my_copy: Don't overwrite file */ #define MY_THREADSAFE 2048 /* my_seek(): lock fd mutex */ #define MY_SYNC 4096 /* my_copy(): sync dst file */ +#define MY_SYNC_DIR 32768 /* my_create/delete/rename: sync directory */ #define MY_CHECK_ERROR 1 /* Params to my_end; Check open-close */ #define MY_GIVE_INFO 2 /* Give time info about process*/ @@ -233,7 +233,8 @@ extern ulong my_file_total_opened; extern ulong my_sync_count; extern uint mysys_usage_id; extern my_bool my_init_done; - +extern my_bool my_assert_on_error; +extern myf my_global_flags; /* Set to MY_WME for more error messages */ /* Point to current my_message() */ extern void (*my_sigtstp_cleanup)(void), /* Executed before jump to shell */ diff --git a/include/my_time.h b/include/my_time.h index a2ae32df742..668b57fc052 100644 --- a/include/my_time.h +++ b/include/my_time.h @@ -1,4 +1,4 @@ -/* Copyright (C) 2004-2005 MySQL AB +/* Copyright (c) 2004, 2011, Oracle and/or its affiliates. All rights reserved. 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 @@ -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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ /* This is a private header of sql-common library, containing diff --git a/include/my_tree.h b/include/my_tree.h index 3524c82a2bc..3dd92712af2 100644 --- a/include/my_tree.h +++ b/include/my_tree.h @@ -1,4 +1,4 @@ -/* Copyright (C) 2000 MySQL AB +/* Copyright (c) 2000, 2010, Oracle and/or its affiliates. All rights reserved. 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 @@ -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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ #ifndef _tree_h #define _tree_h diff --git a/include/my_uctype.h b/include/my_uctype.h index 580eb646e11..80ef01c079a 100644 --- a/include/my_uctype.h +++ b/include/my_uctype.h @@ -1,7 +1,8 @@ #ifndef MY_UCTYPE_INCLUDED #define MY_UCTYPE_INCLUDED -/* Copyright (C) 2006 MySQL AB +/* Copyright (c) 2006 MySQL AB, 2009 Sun Microsystems, Inc. + Use is subject to license terms. 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/include/myisam.h b/include/myisam.h index 0fd87839057..0aa8fe79c27 100644 --- a/include/myisam.h +++ b/include/myisam.h @@ -1,5 +1,5 @@ -/* Copyright (C) 2000, 2011, Oracle and/or its affiliates. All rights - reserved +/* + Copyright (c) 2000, 2011, Oracle and/or its affiliates. All rights reserved. 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 @@ -12,7 +12,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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ /* This file should be included when using myisam_funktions */ @@ -292,6 +292,8 @@ extern ulong _mi_calc_blob_length(uint length , const uchar *pos); extern uint mi_get_pointer_length(ulonglong file_length, uint def); extern int mi_make_backup_of_index(struct st_myisam_info *info, time_t backup_time, myf flags); +#define myisam_max_key_length() HA_MAX_KEY_LENGTH +#define myisam_max_key_segments() HA_MAX_KEY_SEG #define MEMMAP_EXTRA_MARGIN 7 /* Write this as a suffix for mmap file */ /* this is used to pass to mysql_myisamchk_table */ diff --git a/include/myisamchk.h b/include/myisamchk.h index bd184c75e7e..9478936c748 100644 --- a/include/myisamchk.h +++ b/include/myisamchk.h @@ -144,7 +144,7 @@ typedef struct st_handler_check_param time_t backup_time; /* To sign backup files */ ulong rec_per_key_part[HA_MAX_KEY_SEG * HA_MAX_POSSIBLE_KEY]; double new_rec_per_key_part[HA_MAX_KEY_SEG * HA_MAX_POSSIBLE_KEY]; - uint out_flag, warning_printed, error_printed, verbose; + uint out_flag, warning_printed, error_printed, note_printed, verbose; uint opt_sort_key, total_files, max_level; uint key_cache_block_size, pagecache_block_size; int tmpfile_createflag, err_count; diff --git a/include/myisammrg.h b/include/myisammrg.h index 3277510705b..84b2d637892 100644 --- a/include/myisammrg.h +++ b/include/myisammrg.h @@ -1,4 +1,5 @@ -/* Copyright (C) 2000 MySQL AB, 2008-2009 Sun Microsystems, Inc +/* Copyright (c) 2000-2002, 2004, 2006-2008 MySQL AB, 2009 Sun Microsystems, Inc. + Use is subject to license terms. 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 @@ -11,7 +12,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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ /* This file should be included when using merge_isam_funktions */ diff --git a/include/myisampack.h b/include/myisampack.h index 41b53f26a5f..a065de378d8 100644 --- a/include/myisampack.h +++ b/include/myisampack.h @@ -1,7 +1,8 @@ #ifndef MYISAMPACK_INCLUDED #define MYISAMPACK_INCLUDED -/* Copyright (C) 2000 MySQL AB +/* Copyright (c) 2000-2002, 2004, 2006 MySQL AB, 2009 Sun Microsystems, Inc. + Use is subject to license terms. 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 @@ -14,7 +15,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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ /* Storing of values in high byte first order. diff --git a/include/mysql.h b/include/mysql.h index 2b1c90b0fd9..d06db7ed25d 100644 --- a/include/mysql.h +++ b/include/mysql.h @@ -1,4 +1,4 @@ -/* Copyright (C) 2000-2003 MySQL AB +/* Copyright (c) 2000, 2011, Oracle and/or its affiliates. All rights reserved. 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 @@ -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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ /* This file defines the client API to MySQL and also the ABI of the diff --git a/include/mysql.h.pp b/include/mysql.h.pp index eed977aff50..556ba91c7b9 100644 --- a/include/mysql.h.pp +++ b/include/mysql.h.pp @@ -67,8 +67,8 @@ enum mysql_enum_shutdown_level { SHUTDOWN_WAIT_UPDATES= (unsigned char)(1 << 3), SHUTDOWN_WAIT_ALL_BUFFERS= ((unsigned char)(1 << 3) << 1), SHUTDOWN_WAIT_CRITICAL_BUFFERS= ((unsigned char)(1 << 3) << 1) + 1, - KILL_QUERY= 254, - KILL_CONNECTION= 255 + SHUTDOWN_KILL_QUERY= 254, + SHUTDOWN_KILL_CONNECTION= 255 }; enum enum_cursor_type { diff --git a/include/mysql/client_plugin.h b/include/mysql/client_plugin.h index eb1c74d7c0b..35b415fdaf0 100644 --- a/include/mysql/client_plugin.h +++ b/include/mysql/client_plugin.h @@ -1,5 +1,6 @@ #ifndef MYSQL_CLIENT_PLUGIN_INCLUDED /* Copyright (C) 2010 Sergei Golubchik and Monty Program Ab + Copyright (c) 2010, 2011, Oracle and/or its affiliates. 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 @@ -12,7 +13,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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ /** @file diff --git a/include/mysql/plugin.h b/include/mysql/plugin.h index 2e5e6b5c9b0..4f70fe45d43 100644 --- a/include/mysql/plugin.h +++ b/include/mysql/plugin.h @@ -1,4 +1,4 @@ -/* Copyright (C) 2005 MySQL AB, 2009 Sun Microsystems, Inc. +/* Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved. Copyright (C) 2009-2011 Monty Program Ab This program is free software; you can redistribute it and/or modify @@ -12,7 +12,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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ #ifndef _my_plugin_h #define _my_plugin_h @@ -73,7 +73,7 @@ typedef struct st_mysql_xid MYSQL_XID; */ /* MySQL plugin interface version */ -#define MYSQL_PLUGIN_INTERFACE_VERSION 0x0102 +#define MYSQL_PLUGIN_INTERFACE_VERSION 0x0103 /* MariaDB plugin interface version */ #define MARIA_PLUGIN_INTERFACE_VERSION 0x0101 @@ -151,7 +151,7 @@ MARIA_DECLARE_PLUGIN__(NAME, \ builtin_maria_ ## NAME ## _sizeof_struct_st_plugin, \ builtin_maria_ ## NAME ## _plugin) -#define mysql_declare_plugin_end ,{0,0,0,0,0,0,0,0,0,0,0,0}} +#define mysql_declare_plugin_end ,{0,0,0,0,0,0,0,0,0,0,0,0,0}} #define maria_declare_plugin_end ,{0,0,0,0,0,0,0,0,0,0,0,0,0}} /* @@ -159,12 +159,18 @@ MARIA_DECLARE_PLUGIN__(NAME, \ */ enum enum_mysql_show_type { - SHOW_UNDEF, SHOW_BOOL, SHOW_INT, SHOW_LONG, - SHOW_LONGLONG, SHOW_CHAR, SHOW_CHAR_PTR, + SHOW_UNDEF, SHOW_BOOL, SHOW_UINT, SHOW_ULONG, + SHOW_ULONGLONG, SHOW_CHAR, SHOW_CHAR_PTR, SHOW_ARRAY, SHOW_FUNC, SHOW_DOUBLE, + SHOW_SINT, SHOW_SLONG, SHOW_SLONGLONG, SHOW_always_last }; +/* backward compatibility mapping. */ +#define SHOW_INT SHOW_UINT +#define SHOW_LONG SHOW_ULONG +#define SHOW_LONGLONG SHOW_ULONGLONG + struct st_mysql_show_var { const char *name; char *value; @@ -176,6 +182,14 @@ typedef int (*mysql_show_var_func)(MYSQL_THD, struct st_mysql_show_var*, char *) /* + Constants for plugin flags. + */ + +#define PLUGIN_OPT_NO_INSTALL 1UL /* Not dynamically loadable */ +#define PLUGIN_OPT_NO_UNINSTALL 2UL /* Not dynamically unloadable */ + + +/* declarations for server variables and command line options */ @@ -447,6 +461,7 @@ struct st_mysql_plugin struct st_mysql_show_var *status_vars; struct st_mysql_sys_var **system_vars; void * __reserved1; /* reserved for dependency checking */ + unsigned long flags; /* flags for plugin */ }; /* diff --git a/include/mysql/plugin_audit.h b/include/mysql/plugin_audit.h index 5072ad2b44c..eee32a9e523 100644 --- a/include/mysql/plugin_audit.h +++ b/include/mysql/plugin_audit.h @@ -1,17 +1,18 @@ -/* Copyright (C) 2007 MySQL AB +/* Copyright (c) 2007, 2011, Oracle and/or its affiliates. All rights reserved. - 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 - the Free Software Foundation; version 2 of the License. + 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 the Free Software Foundation; version 2 of + the License. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ #ifndef _my_audit_h #define _my_audit_h diff --git a/include/mysql/plugin_audit.h.pp b/include/mysql/plugin_audit.h.pp index a435c7c64b2..cdd9324a5f7 100644 --- a/include/mysql/plugin_audit.h.pp +++ b/include/mysql/plugin_audit.h.pp @@ -89,9 +89,10 @@ struct st_mysql_xid { typedef struct st_mysql_xid MYSQL_XID; enum enum_mysql_show_type { - SHOW_UNDEF, SHOW_BOOL, SHOW_INT, SHOW_LONG, - SHOW_LONGLONG, SHOW_CHAR, SHOW_CHAR_PTR, + SHOW_UNDEF, SHOW_BOOL, SHOW_UINT, SHOW_ULONG, + SHOW_ULONGLONG, SHOW_CHAR, SHOW_CHAR_PTR, SHOW_ARRAY, SHOW_FUNC, SHOW_DOUBLE, + SHOW_SINT, SHOW_SLONG, SHOW_SLONGLONG, SHOW_always_last }; struct st_mysql_show_var { @@ -122,6 +123,7 @@ struct st_mysql_plugin struct st_mysql_show_var *status_vars; struct st_mysql_sys_var **system_vars; void * __reserved1; + unsigned long flags; }; struct st_maria_plugin { diff --git a/include/mysql/plugin_auth.h b/include/mysql/plugin_auth.h index fcfd1bc6f0b..75e7fba5266 100644 --- a/include/mysql/plugin_auth.h +++ b/include/mysql/plugin_auth.h @@ -1,6 +1,6 @@ #ifndef MYSQL_PLUGIN_AUTH_INCLUDED /* Copyright (C) 2010 Sergei Golubchik and Monty Program Ab - Copyright (C) 2010 Sun Microsystems, Inc. + Copyright (c) 2010, Oracle and/or its affiliates. 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 @@ -13,7 +13,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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ /** @file diff --git a/include/mysql/plugin_auth.h.pp b/include/mysql/plugin_auth.h.pp index 7a40ee5b9f7..e06494746dd 100644 --- a/include/mysql/plugin_auth.h.pp +++ b/include/mysql/plugin_auth.h.pp @@ -89,9 +89,10 @@ struct st_mysql_xid { typedef struct st_mysql_xid MYSQL_XID; enum enum_mysql_show_type { - SHOW_UNDEF, SHOW_BOOL, SHOW_INT, SHOW_LONG, - SHOW_LONGLONG, SHOW_CHAR, SHOW_CHAR_PTR, + SHOW_UNDEF, SHOW_BOOL, SHOW_UINT, SHOW_ULONG, + SHOW_ULONGLONG, SHOW_CHAR, SHOW_CHAR_PTR, SHOW_ARRAY, SHOW_FUNC, SHOW_DOUBLE, + SHOW_SINT, SHOW_SLONG, SHOW_SLONGLONG, SHOW_always_last }; struct st_mysql_show_var { @@ -122,6 +123,7 @@ struct st_mysql_plugin struct st_mysql_show_var *status_vars; struct st_mysql_sys_var **system_vars; void * __reserved1; + unsigned long flags; }; struct st_maria_plugin { diff --git a/include/mysql/plugin_auth_common.h b/include/mysql/plugin_auth_common.h index 2f6642abac1..820d299bf88 100644 --- a/include/mysql/plugin_auth_common.h +++ b/include/mysql/plugin_auth_common.h @@ -1,6 +1,6 @@ #ifndef MYSQL_PLUGIN_AUTH_COMMON_INCLUDED /* Copyright (C) 2010 Sergei Golubchik and Monty Program Ab - Copyright (C) 2010 Sun Microsystems, Inc. + Copyright (c) 2010, Oracle and/or its affiliates. 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 @@ -13,7 +13,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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ #ifdef _WIN32 #include <windows.h> diff --git a/include/mysql/plugin_ftparser.h b/include/mysql/plugin_ftparser.h index 37bc96b0e08..324fce7ae86 100644 --- a/include/mysql/plugin_ftparser.h +++ b/include/mysql/plugin_ftparser.h @@ -1,4 +1,5 @@ -/* Copyright (C) 2005 MySQL AB +/* Copyright (c) 2005 MySQL AB, 2009 Sun Microsystems, Inc. + Use is subject to license terms. 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 @@ -11,7 +12,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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ #ifndef _my_plugin_ftparser_h #define _my_plugin_ftparser_h diff --git a/include/mysql/plugin_ftparser.h.pp b/include/mysql/plugin_ftparser.h.pp index 527be747cb4..a990c62e8e9 100644 --- a/include/mysql/plugin_ftparser.h.pp +++ b/include/mysql/plugin_ftparser.h.pp @@ -89,9 +89,10 @@ struct st_mysql_xid { typedef struct st_mysql_xid MYSQL_XID; enum enum_mysql_show_type { - SHOW_UNDEF, SHOW_BOOL, SHOW_INT, SHOW_LONG, - SHOW_LONGLONG, SHOW_CHAR, SHOW_CHAR_PTR, + SHOW_UNDEF, SHOW_BOOL, SHOW_UINT, SHOW_ULONG, + SHOW_ULONGLONG, SHOW_CHAR, SHOW_CHAR_PTR, SHOW_ARRAY, SHOW_FUNC, SHOW_DOUBLE, + SHOW_SINT, SHOW_SLONG, SHOW_SLONGLONG, SHOW_always_last }; struct st_mysql_show_var { @@ -122,6 +123,7 @@ struct st_mysql_plugin struct st_mysql_show_var *status_vars; struct st_mysql_sys_var **system_vars; void * __reserved1; + unsigned long flags; }; struct st_maria_plugin { diff --git a/include/mysql/service_my_snprintf.h b/include/mysql/service_my_snprintf.h index 4395ea17ab7..57b67f1416d 100644 --- a/include/mysql/service_my_snprintf.h +++ b/include/mysql/service_my_snprintf.h @@ -1,5 +1,5 @@ #ifndef MYSQL_SERVICE_MY_SNPRINTF_INCLUDED -/* Copyright (C) 2009 Sun Microsystems, Inc. +/* Copyright (c) 2009, 2010, Oracle and/or its affiliates. All rights reserved. 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 @@ -12,7 +12,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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ /** @file diff --git a/include/mysql/service_thd_alloc.h b/include/mysql/service_thd_alloc.h index 7061c2bd4d5..645fb310cbc 100644 --- a/include/mysql/service_thd_alloc.h +++ b/include/mysql/service_thd_alloc.h @@ -1,5 +1,5 @@ #ifndef MYSQL_SERVICE_THD_ALLOC_INCLUDED -/* Copyright (C) 2009 Sun Microsystems, Inc. +/* Copyright (c) 2009, 2010, Oracle and/or its affiliates. All rights reserved. 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 @@ -12,7 +12,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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ /** @file diff --git a/include/mysql/service_thd_wait.h b/include/mysql/service_thd_wait.h index f5d2a75f5fc..6b47a4ff21e 100644 --- a/include/mysql/service_thd_wait.h +++ b/include/mysql/service_thd_wait.h @@ -1,4 +1,4 @@ -/* Copyright (C) 2010, Oracle and/or its affiliates. All rights reserved. +/* Copyright (c) 2010, 2011, Oracle and/or its affiliates. All rights reserved. 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 @@ -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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ #ifndef MYSQL_SERVICE_THD_WAIT_INCLUDED #define MYSQL_SERVICE_THD_WAIT_INCLUDED diff --git a/include/mysql/service_thread_scheduler.h b/include/mysql/service_thread_scheduler.h index a4396b721bd..5a5e0e2f520 100644 --- a/include/mysql/service_thread_scheduler.h +++ b/include/mysql/service_thread_scheduler.h @@ -1,5 +1,5 @@ /* - Copyright (C) 2010, Oracle and/or its affiliates. All rights reserved. + Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved. 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 @@ -12,7 +12,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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ #ifndef SERVICE_THREAD_SCHEDULER_INCLUDED diff --git a/include/mysql/services.h b/include/mysql/services.h index bd029e55b78..eca0e88c8da 100644 --- a/include/mysql/services.h +++ b/include/mysql/services.h @@ -1,5 +1,5 @@ #ifndef MYSQL_SERVICES_INCLUDED -/* Copyright (C) 2009 Sun Microsystems, Inc. +/* Copyright (c) 2009, 2010, Oracle and/or its affiliates. All rights reserved. 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 @@ -12,7 +12,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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ #ifdef __cplusplus extern "C" { diff --git a/include/mysql/thread_pool_priv.h b/include/mysql/thread_pool_priv.h index f56242fd74f..4060cf51733 100644 --- a/include/mysql/thread_pool_priv.h +++ b/include/mysql/thread_pool_priv.h @@ -1,6 +1,6 @@ #error don't use /* - Copyright (C) 2010, 2011 Oracle and/or its affiliates. All rights reserved. + Copyright (c) 2010, 2011, Oracle and/or its affiliates. All rights reserved. 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 @@ -13,7 +13,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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ #ifndef THREAD_POOL_PRIV_INCLUDED diff --git a/include/mysql_com.h b/include/mysql_com.h index 1ffb6557117..adba1ba141a 100644 --- a/include/mysql_com.h +++ b/include/mysql_com.h @@ -1,4 +1,5 @@ -/* Copyright (C) 2000 MySQL AB +/* Copyright (c) 2000, 2011, Oracle and/or its affiliates. + Copyright (c) 2010, 2011, Monty Program Ab 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 @@ -11,7 +12,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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ /* ** Common definition between mysql server & client @@ -427,12 +428,15 @@ enum mysql_enum_shutdown_level { /* don't flush InnoDB buffers, flush other storage engines' buffers*/ SHUTDOWN_WAIT_CRITICAL_BUFFERS= (MYSQL_SHUTDOWN_KILLABLE_UPDATE << 1) + 1, /* Now the 2 levels of the KILL command */ -#if MYSQL_VERSION_ID >= 50000 - KILL_QUERY= 254, -#endif - KILL_CONNECTION= 255 + SHUTDOWN_KILL_QUERY= 254, + SHUTDOWN_KILL_CONNECTION= 255 }; +/* Compatibility */ +#if !defined(MYSQL_SERVER) && defined(USE_OLD_FUNCTIONS) +#define KILL_QUERY SHUTDOWN_KILL_QUERY +#define KILL_CONNECTION SHUTDOWN_KILL_CONNECTION +#endif enum enum_cursor_type { diff --git a/include/mysql_embed.h b/include/mysql_embed.h index 3b6f851bd6f..b96083d07db 100644 --- a/include/mysql_embed.h +++ b/include/mysql_embed.h @@ -1,7 +1,7 @@ #ifndef MYSQL_EMBED_INCLUDED #define MYSQL_EMBED_INCLUDED -/* Copyright (C) 2000 MySQL AB +/* Copyright (c) 2000, 2011, Oracle and/or its affiliates. All rights reserved. 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 @@ -14,7 +14,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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ /* Defines that are unique to the embedded version of MySQL */ diff --git a/include/mysys_err.h b/include/mysys_err.h index 1308c645d16..42c1bf3175a 100644 --- a/include/mysys_err.h +++ b/include/mysys_err.h @@ -1,4 +1,4 @@ -/* Copyright (C) 2000 MySQL AB +/* Copyright (c) 2000, 2010, Oracle and/or its affiliates. All rights reserved. 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 @@ -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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ #ifndef _mysys_err_h #define _mysys_err_h diff --git a/include/password.h b/include/password.h index e75b09297a3..082f917e7c0 100644 --- a/include/password.h +++ b/include/password.h @@ -1,4 +1,4 @@ -/* Copyright 2006-2008 MySQL AB, 2008-2009 Sun Microsystems, Inc. +/* Copyright (c) 2006, 2010, Oracle and/or its affiliates. All rights reserved. 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/include/probes_mysql.d.base b/include/probes_mysql.d.base index 958e3042dde..02eb9ec1a6b 100644 --- a/include/probes_mysql.d.base +++ b/include/probes_mysql.d.base @@ -1,4 +1,5 @@ -/* Copyright (C) 2008 MySQL AB +/* Copyright (c) 2008, 2009 Sun Microsystems, Inc. + Use is subject to license terms. 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 @@ -11,7 +12,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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ /* The actual probe names in DTrace scripts will replace '__' by '-'. Thus diff --git a/include/probes_mysql.h b/include/probes_mysql.h index 13491c661fd..191860d0b94 100644 --- a/include/probes_mysql.h +++ b/include/probes_mysql.h @@ -1,3 +1,19 @@ +/* Copyright (c) 2008 Sun Microsystems, Inc. + Use is subject to license terms. + + 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 + the Free Software Foundation; version 2 of the License. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + 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 02110-1301 USA */ + #ifndef PROBES_MYSQL_H #define PROBES_MYSQL_H diff --git a/include/rijndael.h b/include/rijndael.h index 71df1c48dbf..474b3250dcb 100644 --- a/include/rijndael.h +++ b/include/rijndael.h @@ -1,7 +1,8 @@ #ifndef RIJNDAEL_INCLUDED #define RIJNDAEL_INCLUDED -/* Copyright (C) 2002 MySQL AB +/* Copyright (c) 2002, 2006 MySQL AB, 2009 Sun Microsystems, Inc. + Use is subject to license terms. 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 @@ -14,7 +15,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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ /* diff --git a/include/service_versions.h b/include/service_versions.h index 135243593f9..ee50d4856e9 100644 --- a/include/service_versions.h +++ b/include/service_versions.h @@ -1,4 +1,4 @@ -/* Copyright (C) 2009 Sun Microsystems, Inc. +/* Copyright (c) 2009, 2010, Oracle and/or its affiliates. All rights reserved. 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 @@ -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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ #ifdef _WIN32 #define SERVICE_VERSION __declspec(dllexport) void * diff --git a/include/sha1.h b/include/sha1.h index d60d5e17c60..c3469333c27 100644 --- a/include/sha1.h +++ b/include/sha1.h @@ -1,7 +1,8 @@ #ifndef SHA1_INCLUDED #define SHA1_INCLUDED -/* Copyright (C) 2002, 2006 MySQL AB +/* Copyright (c) 2002, 2006 MySQL AB, 2009 Sun Microsystems, Inc. + Use is subject to license terms. 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/include/sha2.h b/include/sha2.h index e67a4100ff2..737658e9ced 100644 --- a/include/sha2.h +++ b/include/sha2.h @@ -1,4 +1,4 @@ -/* Copyright (C) 2007 MySQL AB +/* Copyright (c) 2007, 2010, Oracle and/or its affiliates. All rights reserved. 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 @@ -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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ #ifndef included_sha2_h #define included_sha2_h diff --git a/include/sql_common.h b/include/sql_common.h index 2ea6c05d717..875d5d5361f 100644 --- a/include/sql_common.h +++ b/include/sql_common.h @@ -1,6 +1,7 @@ #ifndef SQL_COMMON_INCLUDED #define SQL_COMMON_INCLUDED -/* Copyright (C) 2003-2004, 2006 MySQL AB +/* Copyright (c) 2003, 2010, Oracle and/or its affiliates. + Copyright (c) 2010, 2011, Monty Program Ab 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 @@ -13,7 +14,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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ #ifdef __cplusplus extern "C" { diff --git a/include/sslopt-case.h b/include/sslopt-case.h index 3b64a225fe2..2da5ff317e1 100644 --- a/include/sslopt-case.h +++ b/include/sslopt-case.h @@ -1,7 +1,7 @@ #ifndef SSLOPT_CASE_INCLUDED #define SSLOPT_CASE_INCLUDED -/* Copyright (C) 2000 MySQL AB +/* Copyright (c) 2000, 2010, Oracle and/or its affiliates. All rights reserved. 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 @@ -14,7 +14,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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ #if defined(HAVE_OPENSSL) && !defined(EMBEDDED_LIBRARY) case OPT_SSL_KEY: diff --git a/include/sslopt-longopts.h b/include/sslopt-longopts.h index 5315b2e12b1..db99d1dfa26 100644 --- a/include/sslopt-longopts.h +++ b/include/sslopt-longopts.h @@ -1,7 +1,7 @@ #ifndef SSLOPT_LONGOPTS_INCLUDED #define SSLOPT_LONGOPTS_INCLUDED -/* Copyright (C) 2000 MySQL AB +/* Copyright (c) 2000, 2010, Oracle and/or its affiliates. All rights reserved. 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 @@ -14,7 +14,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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ #if defined(HAVE_OPENSSL) && !defined(EMBEDDED_LIBRARY) diff --git a/include/sslopt-vars.h b/include/sslopt-vars.h index d0eec3b6d74..01093feceaf 100644 --- a/include/sslopt-vars.h +++ b/include/sslopt-vars.h @@ -1,7 +1,7 @@ #ifndef SSLOPT_VARS_INCLUDED #define SSLOPT_VARS_INCLUDED -/* Copyright (C) 2000 MySQL AB +/* Copyright (c) 2000, 2010, Oracle and/or its affiliates. All rights reserved. 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 @@ -14,7 +14,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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ #if defined(HAVE_OPENSSL) && !defined(EMBEDDED_LIBRARY) #ifdef SSL_VARS_NOT_STATIC diff --git a/include/thr_alarm.h b/include/thr_alarm.h index 15df74c1588..f4823b618f7 100644 --- a/include/thr_alarm.h +++ b/include/thr_alarm.h @@ -1,4 +1,4 @@ -/* Copyright (C) 2000 MySQL AB +/* Copyright (c) 2000, 2011, Oracle and/or its affiliates. All rights reserved. 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 @@ -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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ /* Prototypes when using thr_alarm library functions */ diff --git a/include/thr_lock.h b/include/thr_lock.h index a744fab8aec..3f7a5ca988f 100644 --- a/include/thr_lock.h +++ b/include/thr_lock.h @@ -1,4 +1,4 @@ -/* Copyright 2000-2008 MySQL AB, 2008-2009 Sun Microsystems, Inc. +/* Copyright (c) 2000, 2010, Oracle and/or its affiliates. All rights reserved. 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 @@ -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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ /* For use with thr_lock:s */ diff --git a/include/welcome_copyright_notice.h b/include/welcome_copyright_notice.h index b4a2828f4a8..26c2bb2b097 100644 --- a/include/welcome_copyright_notice.h +++ b/include/welcome_copyright_notice.h @@ -1,4 +1,4 @@ -/* Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved. +/* Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved. 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 @@ -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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ #ifndef _welcome_copyright_notice_h_ #define _welcome_copyright_notice_h_ @@ -21,7 +21,7 @@ program on start, or on help screen. */ #define ORACLE_WELCOME_COPYRIGHT_NOTICE(years) \ - "Copyright (c) " years ", Oracle and/or its affiliates. All rights reserved.\n" \ + "Copyright (c) " years ", Oracle and/or its affiliates.\n" \ "2009-2011 Monty Program Ab\n" \ "\n" \ "This software comes with ABSOLUTELY NO WARRANTY. This is free software,\n" \ diff --git a/libmysql/CMakeLists.txt b/libmysql/CMakeLists.txt index 6cd9b287262..9826c2d62f9 100644 --- a/libmysql/CMakeLists.txt +++ b/libmysql/CMakeLists.txt @@ -142,7 +142,6 @@ SET(CLIENT_SOURCES ../sql-common/my_time.c ../sql-common/client_plugin.c ../sql/net_serv.cc - ../sql-common/client_plugin.c ../sql-common/pack.c ../sql/password.c ) diff --git a/libmysql/client_settings.h b/libmysql/client_settings.h index c5a08ce1fcc..ecc9a7773ca 100644 --- a/libmysql/client_settings.h +++ b/libmysql/client_settings.h @@ -1,4 +1,4 @@ -/* Copyright (C) 2003-2005 MySQL AB +/* Copyright (c) 2003, 2011, Oracle and/or its affiliates. All rights reserved. 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 @@ -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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ #ifndef CLIENT_SETTINGS_INCLUDED #define CLIENT_SETTINGS_INCLUDED @@ -22,6 +22,11 @@ extern uint mysql_port; extern char * mysql_unix_port; +/* + Note: CLIENT_CAPABILITIES is also defined in sql/client_settings.h. + When adding capabilities here, consider if they should be also added to + the server's version. +*/ #define CLIENT_CAPABILITIES (CLIENT_LONG_PASSWORD | \ CLIENT_LONG_FLAG | \ CLIENT_TRANSACTIONS | \ diff --git a/libmysql/errmsg.c b/libmysql/errmsg.c index a2d066b1eba..498ba6e9829 100644 --- a/libmysql/errmsg.c +++ b/libmysql/errmsg.c @@ -1,4 +1,4 @@ -/* Copyright (C) 2000-2004 MySQL AB +/* Copyright (c) 2000, 2011, Oracle and/or its affiliates. All rights reserved. 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 @@ -14,7 +14,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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ /* Error messages for MySQL clients */ /* (Error messages for the daemon are in share/language/errmsg.sys) */ diff --git a/libmysql/get_password.c b/libmysql/get_password.c index 455b4b3c8f1..55b7bf41cee 100644 --- a/libmysql/get_password.c +++ b/libmysql/get_password.c @@ -1,4 +1,4 @@ -/* Copyright (C) 2000-2004 MySQL AB +/* Copyright (c) 2000, 2011, Oracle and/or its affiliates. All rights reserved. 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 @@ -14,7 +14,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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ /* ** Ask for a password from tty diff --git a/libmysql/libmysql.c b/libmysql/libmysql.c index 36e6a80f2b2..1294bb0062b 100644 --- a/libmysql/libmysql.c +++ b/libmysql/libmysql.c @@ -1,4 +1,4 @@ -/* Copyright (C) 2000-2004 MySQL AB +/* Copyright (c) 2000, 2011, Oracle and/or its affiliates. All rights reserved. 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 @@ -15,7 +15,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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ #include <my_global.h> #include <my_sys.h> diff --git a/libmysqld/CMakeLists.txt b/libmysqld/CMakeLists.txt index 9bafd7bad49..483e0ca05fd 100644 --- a/libmysqld/CMakeLists.txt +++ b/libmysqld/CMakeLists.txt @@ -83,11 +83,10 @@ SET(SQL_EMBEDDED_SOURCES emb_qcache.cc libmysqld.c lib_sql.cc ../sql/sql_alter.cc ../sql/sql_partition_admin.cc ../sql/event_parse_data.cc ../sql/sql_signal.cc ../sql/rpl_handler.cc - ../sql/rpl_utility.cc ../sql/sys_vars.cc ${CMAKE_BINARY_DIR}/sql/sql_builtin.cc ../sql/mdl.cc ../sql/transaction.cc - ../sql-common/client_plugin.c ../sql/sql_join_cache.cc + ../sql/sql_join_cache.cc ../sql/multi_range_read.cc ../sql/opt_index_cond_pushdown.cc ../sql/opt_subselect.cc diff --git a/libmysqld/emb_qcache.cc b/libmysqld/emb_qcache.cc index 245dcb7f538..d263e5d5fe8 100644 --- a/libmysqld/emb_qcache.cc +++ b/libmysqld/emb_qcache.cc @@ -1,4 +1,4 @@ -/* Copyright (C) 2000-2003 MySQL AB +/* Copyright (c) 2000, 2010, Oracle and/or its affiliates. All rights reserved. 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 @@ -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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ #include "sql_priv.h" #include "my_global.h" // HAVE_* diff --git a/libmysqld/emb_qcache.h b/libmysqld/emb_qcache.h index 71e5cdd6dac..8fd166df88d 100644 --- a/libmysqld/emb_qcache.h +++ b/libmysqld/emb_qcache.h @@ -1,4 +1,4 @@ -/* Copyright (C) 2003, 2005 MySQL AB +/* Copyright (c) 2003, 2010, Oracle and/or its affiliates. All rights reserved. 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 @@ -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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ #include "sql_cache.h" /* Query_cache_block */ diff --git a/libmysqld/embedded_priv.h b/libmysqld/embedded_priv.h index c246693594b..c096954a460 100644 --- a/libmysqld/embedded_priv.h +++ b/libmysqld/embedded_priv.h @@ -1,4 +1,4 @@ -/* Copyright (C) 2001-2004, 2006 MySQL AB +/* Copyright (c) 2001, 2010, Oracle and/or its affiliates. All rights reserved. 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 @@ -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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ /* Prototypes for the embedded version of MySQL */ diff --git a/libmysqld/examples/CMakeLists.txt b/libmysqld/examples/CMakeLists.txt index a9495922f77..8d76698117a 100644 --- a/libmysqld/examples/CMakeLists.txt +++ b/libmysqld/examples/CMakeLists.txt @@ -23,9 +23,7 @@ INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR}/include ADD_DEFINITIONS(-DEMBEDDED_LIBRARY -UMYSQL_CLIENT) -# We never use "mysql_embedded", is more of a linktest, so we don't -# use MYSQL_ADD_EXECUTABLE as that would install it and package it -ADD_EXECUTABLE(mysql_embedded ../../client/completion_hash.cc +MYSQL_ADD_EXECUTABLE(mysql_embedded ../../client/completion_hash.cc ../../client/mysql.cc ../../client/readline.cc) TARGET_LINK_LIBRARIES(mysql_embedded mysqlserver) IF(UNIX) diff --git a/libmysqld/examples/builder-sample/emb_sample.bpr b/libmysqld/examples/builder-sample/emb_sample.bpr index 07b39a6832b..100e5b98dfd 100644 --- a/libmysqld/examples/builder-sample/emb_sample.bpr +++ b/libmysqld/examples/builder-sample/emb_sample.bpr @@ -1,3 +1,19 @@ +# Copyright (c) 2002 MySQL AB +# Use is subject to license terms. +# +# 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 +# the Free Software Foundation; version 2 of the License. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# 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 02110-1301 USA + # --------------------------------------------------------------------------- !if !$d(BCB) BCB = $(MAKEDIR)\.. diff --git a/libmysqld/examples/builder-sample/emb_sample.cpp b/libmysqld/examples/builder-sample/emb_sample.cpp index 5ad3bd69319..0c8f4fa0598 100644 --- a/libmysqld/examples/builder-sample/emb_sample.cpp +++ b/libmysqld/examples/builder-sample/emb_sample.cpp @@ -1,3 +1,19 @@ +// Copyright (c) 2002 MySQL AB +// Use is subject to license terms. +// +// 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 +// the Free Software Foundation; version 2 of the License. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// 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 02110-1301 USA + //--------------------------------------------------------------------------- #include <vcl.h> #pragma hdrstop diff --git a/libmysqld/examples/builder-sample/emb_samples.cpp b/libmysqld/examples/builder-sample/emb_samples.cpp index be3f1931af5..aab1385f6e6 100644 --- a/libmysqld/examples/builder-sample/emb_samples.cpp +++ b/libmysqld/examples/builder-sample/emb_samples.cpp @@ -1,3 +1,19 @@ +// Copyright (c) 2002, 2004, 2007 MySQL AB +// Use is subject to license terms. +// +// 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 +// the Free Software Foundation; version 2 of the License. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// 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 02110-1301 USA + //--------------------------------------------------------------------------- #include <vcl.h> #pragma hdrstop diff --git a/libmysqld/examples/builder-sample/emb_samples.h b/libmysqld/examples/builder-sample/emb_samples.h index 0562bc783cd..3024e75d533 100644 --- a/libmysqld/examples/builder-sample/emb_samples.h +++ b/libmysqld/examples/builder-sample/emb_samples.h @@ -1,3 +1,19 @@ +// Copyright (c) 2002 MySQL AB +// Use is subject to license terms. +// +// 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 +// the Free Software Foundation; version 2 of the License. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// 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 02110-1301 USA + //--------------------------------------------------------------------------- #ifndef emb_samplesH #define emb_samplesH diff --git a/libmysqld/lib_sql.cc b/libmysqld/lib_sql.cc index f35e3cc9552..1ba54350883 100644 --- a/libmysqld/lib_sql.cc +++ b/libmysqld/lib_sql.cc @@ -1149,8 +1149,7 @@ bool net_send_error_packet(THD *thd, uint sql_errno, const char *err, const char *sqlstate) { uint error; - uchar converted_err[MYSQL_ERRMSG_SIZE]; - uint32 converted_err_len; + char converted_err[MYSQL_ERRMSG_SIZE]; MYSQL_DATA *data= thd->cur_data; struct embedded_query_result *ei; @@ -1165,12 +1164,12 @@ bool net_send_error_packet(THD *thd, uint sql_errno, const char *err, ei= data->embedded_info; ei->last_errno= sql_errno; - converted_err_len= convert_error_message((char*)converted_err, - sizeof(converted_err), - thd->variables.character_set_results, - err, strlen(err), - system_charset_info, &error); - strmake(ei->info, (const char*) converted_err, sizeof(ei->info)-1); + convert_error_message(converted_err, sizeof(converted_err), + thd->variables.character_set_results, + err, strlen(err), + system_charset_info, &error); + /* Converted error message is always null-terminated. */ + strmake(ei->info, converted_err, sizeof(ei->info)-1); strmov(ei->sqlstate, sqlstate); ei->server_status= thd->server_status; thd->cur_data= 0; diff --git a/libmysqld/libmysqld.c b/libmysqld/libmysqld.c index e875ff76201..36728cf573c 100644 --- a/libmysqld/libmysqld.c +++ b/libmysqld/libmysqld.c @@ -1,4 +1,4 @@ -/* Copyright (C) 2000 MySQL AB +/* Copyright (c) 2001, 2010, Oracle and/or its affiliates. All rights reserved. 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 @@ -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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ #include <my_global.h> #include <mysql.h> diff --git a/libservices/HOWTO b/libservices/HOWTO index b4960cb11dc..7edafa89268 100644 --- a/libservices/HOWTO +++ b/libservices/HOWTO @@ -1,3 +1,5 @@ +Copyright (c) 2009 Sun Microsystems, Inc. + How to create a new service ^^^^^^^^^^^^^^^^^^^^^^^^^^^ diff --git a/libservices/my_snprintf_service.c b/libservices/my_snprintf_service.c index 40d778e4b8d..8ac507394b0 100644 --- a/libservices/my_snprintf_service.c +++ b/libservices/my_snprintf_service.c @@ -1,4 +1,5 @@ -/* Copyright (C) 2009 Sun Microsystems, Inc. +/* Copyright (c) 2009 Sun Microsystems, Inc. + Use is subject to license terms. 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 @@ -11,7 +12,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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ #include <service_versions.h> SERVICE_VERSION my_snprintf_service= (void*)VERSION_my_snprintf; diff --git a/libservices/my_thread_scheduler_service.c b/libservices/my_thread_scheduler_service.c index dc8d40c6713..0bbad39dd0a 100644 --- a/libservices/my_thread_scheduler_service.c +++ b/libservices/my_thread_scheduler_service.c @@ -1,19 +1,18 @@ /* - Copyright (C) 2010, Oracle and/or its affiliates. All rights reserved. + Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved. 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 the Free Software Foundation; version 2 of the License. - This program is distributed in the hope that it will be useful, but - WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - General Public License for more details. + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 - USA + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ #include <service_versions.h> diff --git a/libservices/thd_alloc_service.c b/libservices/thd_alloc_service.c index 5d4d496774c..65e3fc490c8 100644 --- a/libservices/thd_alloc_service.c +++ b/libservices/thd_alloc_service.c @@ -1,4 +1,5 @@ -/* Copyright (C) 2009 Sun Microsystems, Inc. +/* Copyright (c) 2009 Sun Microsystems, Inc. + Use is subject to license terms. 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 @@ -11,7 +12,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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ #include <service_versions.h> SERVICE_VERSION *thd_alloc_service= (void*)VERSION_thd_alloc; diff --git a/libservices/thd_wait_service.c b/libservices/thd_wait_service.c index 3c87a2d0d1b..8cec4eecf77 100644 --- a/libservices/thd_wait_service.c +++ b/libservices/thd_wait_service.c @@ -1,5 +1,5 @@ /* - Copyright (C) 2010, Oracle and/or its affiliates. All rights reserved. + Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved. 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 @@ -12,7 +12,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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ #include <service_versions.h> diff --git a/mysql-test/CMakeLists.txt b/mysql-test/CMakeLists.txt index f18b2ae341c..954e9c44311 100644 --- a/mysql-test/CMakeLists.txt +++ b/mysql-test/CMakeLists.txt @@ -1,4 +1,4 @@ -# Copyright (c) 2006, 2010, Oracle and/or its affiliates. All rights reserved. +# Copyright (c) 2009, 2010, Oracle and/or its affiliates. All rights reserved. # # 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 @@ -132,3 +132,26 @@ ADD_CUSTOM_TARGET(test-bt-debug COMMAND ${MTR_FORCE} --comment=debug --timer --skip-ndbcluster --skip-rpl --report-features ${EXP} ) +# Process .in files with includes in collections/ + +MACRO(PROCESS_COLLECTION_INCLUDE collin collection) + FILE(STRINGS ${collin} inlines) + FOREACH(line ${inlines}) + IF(${line} MATCHES "#include .*") + STRING(REPLACE "#include " "collections/" incfile ${line}) + FILE(READ ${incfile} contents) + FILE(APPEND ${collection} "${contents}") + ELSE() + FILE(APPEND ${collection} "${line}\n") + ENDIF() + ENDFOREACH() +ENDMACRO() + +FILE(GLOB infiles "collections/*.in") +FOREACH(collin ${infiles}) + STRING(REPLACE ".in" "" collection ${collin}) + # Only generate file once + IF(NOT EXISTS ${collection}) + PROCESS_COLLECTION_INCLUDE(${collin} ${collection}) + ENDIF() +ENDFOREACH() diff --git a/mysql-test/collections/README b/mysql-test/collections/README index 9af84646a40..f64c089ee99 100644 --- a/mysql-test/collections/README +++ b/mysql-test/collections/README @@ -28,3 +28,11 @@ these steps: 5) The commands from the collection are run line by line via execv() or similar system calls. They are not run as a shell script. Shell expansions are not guaranteed to work and most likely won't. + +The directory may contain collections that are "super sets" of others, +identified by a file name suffix ".in". These files may contain lines +"#include <filename>", or lines with mysql-test-run.pl invocations. +CMake will create a new file without the .in suffix where +the include lines are replaced with the contents of the referred +file. Filename is local to the collections directory, and includes do +not nest. diff --git a/mysql-test/collections/default.experimental b/mysql-test/collections/default.experimental index 6ef1a377b6c..b3623402065 100644 --- a/mysql-test/collections/default.experimental +++ b/mysql-test/collections/default.experimental @@ -8,16 +8,15 @@ funcs_1.charset_collation_1 # depends on compile-time decisions main.func_math @freebsd # Bug#11751977 2010-05-04 alik main.func_math fails on FreeBSD in PB2 main.lock_multi_bug38499 # Bug#11755645 2009-09-19 alik main.lock_multi_bug38499 times out sporadically main.outfile_loaddata @solaris # Bug#11755168 2010-01-20 alik Test "outfile_loaddata" fails (reproducible) -main.signal_demo3 @solaris # Bug#11755949 2010-01-20 alik Several test cases fail on Solaris with error Thread stack overrun -main.sp @solaris # Bug#11755949 2010-01-20 alik Several test cases fail on Solaris with error Thread stack overrun +main.signal_demo3 @solaris # Bug#11753919 2010-01-20 alik Several test cases fail on Solaris with error Thread stack overrun +main.sp @solaris # Bug#11753919 2010-01-20 alik Several test cases fail on Solaris with error Thread stack overrun main.wait_timeout @solaris # Bug#11758972 2010-04-26 alik wait_timeout fails on OpenSolaris -rpl.rpl_innodb_bug28430 # Bug#11754425 -rpl.rpl_bug37426 # WL#5867: skozlov: test case moved from unused bugs suite rpl.rpl_heartbeat_basic # BUG#12403008 2011-04-27 sven fails sporadically -rpl.rpl_show_slave_hosts # BUG#12416700 2011-05-02 sven fails sporadically +rpl.rpl_innodb_bug28430 # Bug#11754425 +rpl.rpl_row_sp011 @solaris # Bug#11753919 2011-07-25 sven Several test cases fail on Solaris with error Thread stack overrun -sys_vars.max_sp_recursion_depth_func @solaris # Bug#11755949 2010-01-20 alik Several test cases fail on Solaris with error Thread stack overrun +sys_vars.max_sp_recursion_depth_func @solaris # Bug#11753919 2010-01-20 alik Several test cases fail on Solaris with error Thread stack overrun sys_vars.wait_timeout_func # Bug#11750645 2010-04-26 alik wait_timeout_func fails # BUG #59055 : All ndb tests should be removed from the repository diff --git a/mysql-test/collections/default.release b/mysql-test/collections/default.release.in index 108e1032ca2..0e3ad30671b 100644 --- a/mysql-test/collections/default.release +++ b/mysql-test/collections/default.release.in @@ -1,3 +1,9 @@ +# This file contains the old default.release, the plan is to replace that +# with something like the below (remove space after #): + +# include default.daily +# include default.weekly + perl mysql-test-run.pl --force --timer --parallel=auto --experimental=collections/default.experimental --comment=debug --vardir=var-debug --skip-ndbcluster --skip-rpl --report-features --debug-server perl mysql-test-run.pl --force --timer --parallel=auto --experimental=collections/default.experimental --comment=normal --vardir=var-normal --skip-ndbcluster --report-features perl mysql-test-run.pl --force --timer --parallel=auto --experimental=collections/default.experimental --comment=ps --vardir=var-ps --skip-ndbcluster --ps-protocol diff --git a/mysql-test/extra/rpl_tests/rpl_insert_duplicate.test b/mysql-test/extra/rpl_tests/rpl_insert_duplicate.test deleted file mode 100644 index a81eeba3231..00000000000 --- a/mysql-test/extra/rpl_tests/rpl_insert_duplicate.test +++ /dev/null @@ -1,59 +0,0 @@ -# BUG#59338 Inconsistency in binlog for statements that don't change any rows STATEMENT SBR -# In SBR, if a statement does not fail, it is always written to the binary log, -# regardless if rows are changed or not. If there is a failure, a statement is -# only written to the binary log if a non-transactional (.e.g. MyIsam) engine -# is updated. INSERT ON DUPLICATE KEY UPDATE was not following the rule above -# and was not written to the binary log, if then engine was Innodb. -# -# In this test case, we check if INSERT ON DUPLICATE KEY UPDATE that does not -# change anything is still written to the binary log. - -# Prepare environment ---connection master - -eval CREATE TABLE t1 ( - a INT UNSIGNED NOT NULL PRIMARY KEY -) ENGINE=$engine_type; - -eval CREATE TABLE t2 ( - a INT UNSIGNED -) ENGINE=$engine_type; - -INSERT INTO t1 VALUES (1); -INSERT INTO t2 VALUES (1); - -# An insert duplicate that does not update anything must be written to the binary -# log in SBR and MIXED modes. We check this property by summing a before and after -# the update and comparing the binlog positions. The sum should be the same at both -# points and the statement should be in the binary log. ---let $binlog_file= query_get_value("SHOW MASTER STATUS", File, 1) ---let $binlog_start= query_get_value("SHOW MASTER STATUS", Position, 1) ---let $statement_file=INSERT INTO t1 SELECT t2.a FROM t2 ORDER BY t2.a ON DUPLICATE KEY UPDATE t1.a= t1.a ---eval $statement_file - ---let $assert_cond= SUM(a) = 1 FROM t1 ---let $assert_text= Sum of elements in t1 should be 1. ---source include/assert.inc - -if (`SELECT @@BINLOG_FORMAT = 'ROW'`) -{ - --let $binlog_position_cmp= = - --let $assert_cond= [SHOW MASTER STATUS, Position, 1] $binlog_position_cmp $binlog_start - --let $assert_text= In SBR or MIXED modes, the event in the binlog should be the same that was executed. In RBR mode, binlog position should stay unchanged. -} -if (`SELECT @@BINLOG_FORMAT != 'ROW'`) -{ - --let $assert_cond= \'[\'SHOW BINLOG EVENTS IN "$binlog_file" FROM $binlog_start LIMIT 1, 1\', Info, 1]\' LIKE \'%$statement_file\' - --let $assert_text= In SBR or MIXED modes, the event in the binlog should be the same that was executed. In RBR mode, binlog position should stay unchanged. -} ---source include/assert.inc - -# Compare master and slave ---sync_slave_with_master ---let $diff_tables= master:test.t1 , slave:test.t1 ---source include/diff_tables.inc - -# Clean up ---connection master -drop table t1, t2; ---sync_slave_with_master diff --git a/mysql-test/extra/rpl_tests/rpl_insert_id.test b/mysql-test/extra/rpl_tests/rpl_insert_id.test index 565ab4a67ad..32d861bd45a 100644 --- a/mysql-test/extra/rpl_tests/rpl_insert_id.test +++ b/mysql-test/extra/rpl_tests/rpl_insert_id.test @@ -77,6 +77,7 @@ eval create table t2(b int auto_increment, c int, key(b)) engine=$engine_type; insert into t1 values (10); insert into t1 values (null),(null),(null); insert into t2 values (5,0); +--disable_warnings ONCE insert into t2 (c) select * from t1 ORDER BY a; select * from t2 ORDER BY b; sync_slave_with_master; @@ -113,8 +114,10 @@ set @@session.sql_auto_is_null=1; eval create table t1(a int auto_increment, key(a)) engine=$engine_type; eval create table t2(a int) engine=$engine_type; insert into t1 (a) values (null); +--disable_warnings insert into t2 (a) select a from t1 where a is null; insert into t2 (a) select a from t1 where a is null; +--enable_warnings select * from t2; sync_slave_with_master; connection slave; @@ -172,17 +175,15 @@ begin end| delimiter ;| ---disable_warnings +--disable_warnings ONCE insert into t1 (last_id) values (0); ---enable_warnings drop trigger t1_bi; # Check that nested call doesn't affect outer context. select last_insert_id(); ---disable_warnings +--disable_warnings ONCE select bug15728_insert(); ---enable_warnings select last_insert_id(); insert into t1 (last_id) values (bug15728()); # This should be exactly one greater than in the previous call. @@ -190,9 +191,8 @@ select last_insert_id(); # BUG#20339 - stored procedure using LAST_INSERT_ID() does not # replicate statement-based ---disable_warnings +--disable_warnings ONCE drop procedure if exists foo; ---enable_warnings delimiter |; create procedure foo() begin @@ -252,6 +252,7 @@ select * from t1 order by n; # table's counter, the counter for next row is bigger than the # after-value of the updated row. connection master; +--disable_warnings ONCE insert into t1 values (NULL,400),(3,500),(NULL,600) on duplicate key UPDATE n=1000; select * from t1 order by n; sync_slave_with_master; @@ -270,6 +271,7 @@ delete from t1 where b <> 100; select * from t1 order by n; connection master; +--disable_warnings ONCE insert into t1 values(null,100),(null,350) on duplicate key update n=2; select * from t1 order by n; sync_slave_with_master; @@ -287,6 +289,7 @@ connection master; # testcase with INSERT VALUES eval CREATE TABLE t1 (a INT NOT NULL PRIMARY KEY AUTO_INCREMENT, b INT, UNIQUE(b)) ENGINE=$engine_type; +--disable_warnings ONCE INSERT INTO t1(b) VALUES(1),(1),(2) ON DUPLICATE KEY UPDATE t1.b=10; SELECT * FROM t1 ORDER BY a; sync_slave_with_master; @@ -314,19 +317,23 @@ INSERT INTO t2 (field_a, field_b, field_c) VALUES (3, 'c', '3c'); INSERT INTO t2 (field_a, field_b, field_c) VALUES (4, 'd', '4d'); INSERT INTO t2 (field_a, field_b, field_c) VALUES (5, 'e', '5e'); # Updating table t1 based on values from table t2 +--disable_warnings INSERT INTO t1 (field_1, field_2, field_3) SELECT t2.field_a, t2.field_b, t2.field_c FROM t2 ON DUPLICATE KEY UPDATE t1.field_3 = t2.field_c; +--enable_warnings # Inserting new record into t2 INSERT INTO t2 (field_a, field_b, field_c) VALUES (6, 'f', '6f'); # Updating t1 again +--disable_warnings INSERT INTO t1 (field_1, field_2, field_3) SELECT t2.field_a, t2.field_b, t2.field_c FROM t2 ON DUPLICATE KEY UPDATE t1.field_3 = t2.field_c; +--enable_warnings SELECT * FROM t1 ORDER BY id; sync_slave_with_master; SELECT * FROM t1 ORDER BY id; @@ -433,9 +440,8 @@ delimiter ;| INSERT INTO t1 VALUES (NULL, -1); CALL p1(); ---disable_warnings +--disable_warnings ONCE SELECT f1(); ---enable_warnings INSERT INTO t1 VALUES (NULL, f2()), (NULL, LAST_INSERT_ID()), (NULL, LAST_INSERT_ID()), (NULL, f2()), (NULL, f2()); INSERT INTO t1 VALUES (NULL, f2()); @@ -504,16 +510,14 @@ insert into t2 (id) values(1),(2),(3); delete from t2; set sql_log_bin=1; #inside SELECT, then inside INSERT ---disable_warnings +--disable_warnings ONCE select insid(); ---enable_warnings set sql_log_bin=0; insert into t2 (id) values(5),(6),(7); delete from t2 where id>=5; set sql_log_bin=1; ---disable_warnings +--disable_warnings ONCE insert into t1 select insid(); ---enable_warnings select * from t1 order by id; select * from t2 order by id; @@ -537,6 +541,7 @@ begin insert into t2 values(null,3); end| delimiter ;| +--disable_warnings ONCE call foo(); select * from t1 order by n; select * from t2 order by id; diff --git a/mysql-test/extra/rpl_tests/rpl_insert_ignore.test b/mysql-test/extra/rpl_tests/rpl_insert_ignore.test index 270dde7675c..f422ef35f8c 100644 --- a/mysql-test/extra/rpl_tests/rpl_insert_ignore.test +++ b/mysql-test/extra/rpl_tests/rpl_insert_ignore.test @@ -31,7 +31,7 @@ INSERT INTO t2 VALUES (3, 5); INSERT INTO t2 VALUES (4, 3); INSERT INTO t2 VALUES (5, 4); INSERT INTO t2 VALUES (6, 6); - +--disable_warnings ONCE INSERT IGNORE INTO t1 SELECT NULL, t2.b FROM t2 ORDER BY t2.a; --let $assert_cond= COUNT(*) = 6 FROM t1 --let $assert_text= Count of elements in t1 should be 6. @@ -51,25 +51,70 @@ INSERT IGNORE INTO t1 SELECT NULL, t2.b FROM t2 ORDER BY t2.a; --let $binlog_file= query_get_value("SHOW MASTER STATUS", File, 1) --let $binlog_start= query_get_value("SHOW MASTER STATUS", Position, 1) --let $statement_file=INSERT IGNORE INTO t1 SELECT NULL, t2.b FROM t2 ORDER BY t2.a +--disable_warnings ONCE --eval $statement_file --let $assert_cond= COUNT(*) = 6 FROM t1 --let $assert_text= Count of elements in t1 should be 6. --source include/assert.inc -if (`SELECT @@BINLOG_FORMAT = 'ROW'`) +if (`SELECT @@BINLOG_FORMAT != 'STATEMENT'`) { --let $binlog_position_cmp= = --let $assert_cond= [SHOW MASTER STATUS, Position, 1] $binlog_position_cmp $binlog_start --let $assert_text= In SBR or MIXED modes, the event in the binlog should be the same that was executed. In RBR mode, binlog position should stay unchanged. } -if (`SELECT @@BINLOG_FORMAT != 'ROW'`) +if (`SELECT @@BINLOG_FORMAT = 'STATEMENT'`) { --let $assert_cond= \'[\'SHOW BINLOG EVENTS IN "$binlog_file" FROM $binlog_start LIMIT 2, 1\', Info, 1]\' LIKE \'%$statement_file\' --let $assert_text= In SBR or MIXED modes, the event in the binlog should be the same that was executed. In RBR mode, binlog position should stay unchanged. } + +--source include/assert.inc + +# An insert duplicate that does not update anything must be written to the binary +# log in SBR and MIXED modes. We check this property by summing a before and after +# the update and comparing the binlog positions. The sum should be the same at both +# points and the statement should be in the binary log. +--disable_warnings +DROP TABLE t1; +DROP TABLE t2; +--enable_warnings +eval CREATE TABLE t1 ( + a INT UNSIGNED NOT NULL PRIMARY KEY +) ENGINE=$engine_type; + +eval CREATE TABLE t2 ( + a INT UNSIGNED +) ENGINE=$engine_type; + +INSERT INTO t1 VALUES (1); +INSERT INTO t2 VALUES (1); + +--let $binlog_file= query_get_value("SHOW MASTER STATUS", File, 1) +--let $binlog_start= query_get_value("SHOW MASTER STATUS", Position, 1) +--let $statement_file=INSERT INTO t1 SELECT t2.a FROM t2 ORDER BY t2.a ON DUPLICATE KEY UPDATE t1.a= t1.a +--disable_warnings ONCE +--eval $statement_file + +--let $assert_cond= SUM(a) = 1 FROM t1 +--let $assert_text= Sum of elements in t1 should be 1. +--source include/assert.inc + +if (`SELECT @@BINLOG_FORMAT != 'STATEMENT'`) +{ + --let $binlog_position_cmp= = + --let $assert_cond= [SHOW MASTER STATUS, Position, 1] $binlog_position_cmp $binlog_start + --let $assert_text= In SBR or MIXED modes, the event in the binlog should be the same that was executed. In RBR mode, binlog position should stay unchanged. +} +if (`SELECT @@BINLOG_FORMAT = 'STATEMENT'`) +{ + --let $assert_cond= \'[\'SHOW BINLOG EVENTS IN "$binlog_file" FROM $binlog_start LIMIT 1, 1\', Info, 1]\' LIKE \'%$statement_file\' + --let $assert_text= In SBR or MIXED modes, the event in the binlog should be the same that was executed. In RBR mode, binlog position should stay unchanged. +} --source include/assert.inc + # Clean up --connection master drop table t1, t2; diff --git a/mysql-test/extra/rpl_tests/rpl_reset_slave.test b/mysql-test/extra/rpl_tests/rpl_reset_slave.test index 89a9a4e8e3b..17d949a7790 100644 --- a/mysql-test/extra/rpl_tests/rpl_reset_slave.test +++ b/mysql-test/extra/rpl_tests/rpl_reset_slave.test @@ -80,5 +80,31 @@ reset slave; source include/check_slave_no_error.inc; change master to master_user='root'; ---let $rpl_only_running_threads= 1 + +# +# BUG#11809016 - NO WAY TO DISCOVER AN INSTANCE IS NO LONGER A SLAVE FOLLOWING MYSQL BUG#28796 +# + +reset slave; +--source include/start_slave.inc + +--source include/stop_slave.inc +--let $_slave_master_host= query_get_value(SHOW SLAVE STATUS, Master_Host, 1) +--let $_slave_master_user= query_get_value(SHOW SLAVE STATUS, Master_User, 1) +--let $_slave_master_port= query_get_value(SHOW SLAVE STATUS, Master_Port, 1) + +reset slave all; +--error ER_BAD_SLAVE +start slave; + +--let $_show_master_host= query_get_value(SHOW SLAVE STATUS, Master_Host, 1) +if ($_show_master_host != No such row) +{ + die; +} + +--replace_result $_slave_master_host MASTER_HOST $_slave_master_user MASTER_USER $_slave_master_port MASTER_PORT +--eval CHANGE MASTER TO MASTER_HOST= '$_slave_master_host', MASTER_USER= '$_slave_master_user', MASTER_PORT= $_slave_master_port +--source include/start_slave.inc + --source include/rpl_end.inc diff --git a/mysql-test/extra/rpl_tests/rpl_row_annotate.test b/mysql-test/extra/rpl_tests/rpl_row_annotate.test index 77c5f626e28..f3d8006ce01 100644 --- a/mysql-test/extra/rpl_tests/rpl_row_annotate.test +++ b/mysql-test/extra/rpl_tests/rpl_row_annotate.test @@ -1,8 +1,8 @@ ######################################################################## # WL47: Store in binlog text of statements that caused RBR events # new event : ANNOTATE_ROWS_EVENT -# new master option : --binlog-annotate-rows-events -# new slave option : --replicate-annotate-rows-events +# new master option : --binlog-annotate-row-events +# new slave option : --replicate-annotate-row-events ######################################################################## --source include/master-slave.inc connect (master2,127.0.0.1,root,,test,$MASTER_MYPORT,); @@ -29,11 +29,11 @@ CREATE TABLE t5 ( b VARCHAR(10) CHARACTER SET utf8 COLLATE utf8_bin ); -SET SESSION binlog_annotate_rows_events = OFF; +SET SESSION binlog_annotate_row_events = OFF; INSERT INTO t1 VALUES (0,0), (1,1); -SET SESSION binlog_annotate_rows_events = ON; +SET SESSION binlog_annotate_row_events = ON; UPDATE t1 SET b = b + 1; REPLACE t1 VALUES (1,1), (2,2), (3,3); @@ -84,7 +84,7 @@ SELECT * FROM t5 ORDER BY a; --echo ######################################################################## --echo # EVENTS ON SLAVE -let $annotate= `select @@global.replicate_annotate_rows_events`; +let $annotate= `select @@global.replicate_annotate_row_events`; if ($annotate) { --echo # The following Annotate_rows events should appear below: @@ -116,7 +116,7 @@ let $start_pos= `select @binlog_start_pos`; --echo # INSERTs DELAYED ON MASTERs --echo ######################################################################## connection master; -SET SESSION binlog_annotate_rows_events = ON; +SET SESSION binlog_annotate_row_events = ON; INSERT DELAYED INTO test1.t4 VALUES (1,1); FLUSH TABLES; SELECT * FROM test1.t4 ORDER BY a; diff --git a/mysql-test/extra/rpl_tests/rpl_row_func003.test b/mysql-test/extra/rpl_tests/rpl_row_func003.test index 6b58dc11644..d12b5a3306a 100644 --- a/mysql-test/extra/rpl_tests/rpl_row_func003.test +++ b/mysql-test/extra/rpl_tests/rpl_row_func003.test @@ -59,9 +59,6 @@ if (`SELECT UPPER(LEFT('$engine_type', 3)) != 'NDB'`) { sync_slave_with_master; connection master; } -# Sync master and slave for NDB engine -let $wait_time= 6; ---source include/wait_for_ndb_to_binlog.inc # Time to dump the databases and so we can see if they match diff --git a/mysql-test/include/commit.inc b/mysql-test/include/commit.inc index 9df1571a849..fdb9ef1f563 100644 --- a/mysql-test/include/commit.inc +++ b/mysql-test/include/commit.inc @@ -521,10 +521,34 @@ commit; call p_verify_status_increment(2, 2, 2, 2); --echo # 15. Read-write statement: UPDATE IGNORE, change 0 rows. --echo # +--disable_warnings update ignore t1 set a=2 where a=1; -call p_verify_status_increment(2, 2, 1, 0); -commit; -call p_verify_status_increment(2, 2, 1, 0); +--enable_warnings +if (`select @@binlog_format = 'STATEMENT'`) +{ + --disable_query_log + call p_verify_status_increment(2, 2, 1, 0); + --enable_query_log +} +if (`select @@binlog_format != 'STATEMENT'`) +{ + --disable_query_log + call p_verify_status_increment(1, 0, 1, 0); + --enable_query_log +} +commit; +if (`select @@binlog_format = 'STATEMENT'`) +{ + --disable_query_log + call p_verify_status_increment(2, 2, 1, 0); + --enable_query_log +} +if (`select @@binlog_format != 'STATEMENT'`) +{ + --disable_query_log + call p_verify_status_increment(1, 0, 1, 0); + --enable_query_log +} --echo # --echo # Create a stored function that modifies a --echo # non-transactional table. Demonstrate that changes in @@ -603,7 +627,9 @@ call p_verify_status_increment(2, 0, 1, 0); --echo # 21. Read-write statement: UPDATE, change 0 (transactional) rows. --echo # +--disable_warnings update t1 set a=2 where a=f1()+10; +--enable_warnings call p_verify_status_increment(2, 0, 1, 0); commit; call p_verify_status_increment(2, 0, 1, 0); @@ -703,7 +729,9 @@ call p_verify_status_increment(4, 4, 4, 4); --echo # insert into t2 select a from t1; commit; +--disable_warnings replace into t2 select a from t1; +--enable_warnings commit; call p_verify_status_increment(8, 8, 8, 8); # diff --git a/mysql-test/include/daemon_example_bad_format.ini b/mysql-test/include/daemon_example_bad_format.ini new file mode 100644 index 00000000000..8f880ef0ba0 --- /dev/null +++ b/mysql-test/include/daemon_example_bad_format.ini @@ -0,0 +1,8 @@ +# +# Plugin configuration file. Place the following on a separate line: +# +# library binary file name (without .so or .dll) +# component_name +# [component_name] - additional components in plugin +# +libdaemon_example diff --git a/mysql-test/include/daemon_example_bad_soname.ini b/mysql-test/include/daemon_example_bad_soname.ini new file mode 100644 index 00000000000..5f42b5a6214 --- /dev/null +++ b/mysql-test/include/daemon_example_bad_soname.ini @@ -0,0 +1,9 @@ +# +# Plugin configuration file. Place the following on a separate line: +# +# library binary file name (without .so or .dll) +# component_name +# [component_name] - additional components in plugin +# +libdaemon_BADNAME +daemon_BADNAME diff --git a/mysql-test/include/default_my.cnf b/mysql-test/include/default_my.cnf index a4f3b14fd54..ef7e9f60dd7 100644 --- a/mysql-test/include/default_my.cnf +++ b/mysql-test/include/default_my.cnf @@ -1,4 +1,4 @@ -# Copyright (C) 2009 Sun Microsystems, Inc +# Copyright (c) 2007 MySQL AB, 2009, 2010 Sun Microsystems, Inc. # # 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 @@ -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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA # Use default setting for mysqld processes !include default_mysqld.cnf diff --git a/mysql-test/include/default_mysqld.cnf b/mysql-test/include/default_mysqld.cnf index 3a8c4c100f2..0354e375d53 100644 --- a/mysql-test/include/default_mysqld.cnf +++ b/mysql-test/include/default_mysqld.cnf @@ -1,4 +1,4 @@ -# Copyright (C) 2009 Sun Microsystems, Inc +# Copyright (c) 2007, 2010, Oracle and/or its affiliates. All rights reserved. # # 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 @@ -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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA # Default values that applies to all MySQL Servers [mysqld] @@ -36,6 +36,8 @@ max_heap_table_size= 1M loose-skip-innodb loose-skip-pbxt loose-skip-federated +loose-skip-feedback +loose-feedback-user-info= mysql-test loose-innodb_data_file_path= ibdata1:10M:autoextend loose-innodb_buffer_pool_size= 8M diff --git a/mysql-test/include/icp_tests.inc b/mysql-test/include/icp_tests.inc index 4af8bf9c452..ea4fc6439d2 100644 --- a/mysql-test/include/icp_tests.inc +++ b/mysql-test/include/icp_tests.inc @@ -87,6 +87,152 @@ SELECT * FROM t1 WHERE c2 <=> NULL ORDER BY c1,c2 LIMIT 2; DROP TABLE t1; --echo # +--echo # Bug#43617 - Innodb returns wrong results with timestamp's range value +--echo # in IN clause +--echo # (Note: Fixed by patch for BUG#42580) +--echo # + +CREATE TABLE t1( + c1 TIMESTAMP NOT NULL, + c2 TIMESTAMP NULL, + c3 DATE, + c4 DATETIME, + PRIMARY KEY(c1), + UNIQUE INDEX(c2) +); + +INSERT INTO t1 VALUES + ('0000-00-00 00:00:00','0000-00-00 00:00:00','2008-01-04','2008-01-05 00:00:00'), + ('1971-01-01 00:00:01','1980-01-01 00:00:01','2009-01-01','2009-01-02 00:00:00'), + ('1999-01-01 00:00:00','1999-01-01 00:00:00', NULL, NULL), + ('2007-05-23 09:15:28','2007-05-23 09:15:28','2007-05-24','2007-05-24 09:15:28'), + ('2007-05-27 00:00:00','2007-05-25 00:00:00','2007-05-26','2007-05-26 00:00:00'), + ('2008-01-01 00:00:00', NULL, '2008-01-02','2008-01-03 00:00:00'), + ('2009-01-29 11:11:27','2009-01-29 11:11:27','2009-01-29','2009-01-29 11:11:27'), + ('2038-01-09 03:14:07','2038-01-09 03:14:07','2009-01-05','2009-01-06 00:00:00'); + +--echo +SELECT * +FROM t1 +WHERE c2 IN ('1971-01-01 00:00:01','2038-01-09 03:14:07') +ORDER BY c2; + +--echo +SELECT * +FROM t1 +WHERE c2 IN ('1971-01-01 00:00:01','2038-01-09 03:14:07') +ORDER BY c2 LIMIT 2; + +--echo +SELECT * +FROM t1 +WHERE c2 IN ('1971-01-01 00:00:01','2038-01-09 03:14:07') +ORDER BY c2 DESC; + +--echo +SELECT * +FROM t1 +WHERE c2 IN ('1971-01-01 00:00:01','2038-01-09 03:14:07') +ORDER BY c2 DESC LIMIT 2; + +--echo +DROP TABLE t1; + +--echo # +--echo # BUG#43618: MyISAM&Maria returns wrong results with 'between' +--echo # on timestamp +--echo # + +CREATE TABLE t1( + ts TIMESTAMP NOT NULL, + c char NULL, + PRIMARY KEY(ts) +); + +INSERT INTO t1 VALUES + ('1971-01-01','a'), + ('2007-05-25','b'), + ('2008-01-01','c'), + ('2038-01-09','d'); + +--disable_warnings + +--echo +--echo # Execute select with invalid timestamp, desc ordering +SELECT * +FROM t1 +WHERE ts BETWEEN '0000-00-00' AND '2010-00-01 00:00:00' +ORDER BY ts DESC +LIMIT 2; + +--echo +--echo # Should use index condition +EXPLAIN +SELECT * +FROM t1 +WHERE ts BETWEEN '0000-00-00' AND '2010-00-01 00:00:00' +ORDER BY ts DESC +LIMIT 2; +--echo + +--enable_warnings + +DROP TABLE t1; + +--echo # +--echo # BUG#49906: Assertion failed - Field_varstring::val_str in field.cc +--echo # (Note: Fixed by patch for LP BUG#625841) +--echo # + +CREATE TABLE t1 ( + f1 VARCHAR(1024), + f2 VARCHAR(10), + INDEX test_idx USING BTREE (f2,f1(5)) +); + +INSERT INTO t1 VALUES ('a','c'), ('b','d'); + +SELECT f1 +FROM t1 +WHERE f2 LIKE 'd' +ORDER BY f1; + +DROP TABLE t1; + +--echo # +--echo # Bug#52660 - "Perf. regr. using ICP for MyISAM on range queries on +--echo # an index containing TEXT" +--echo # + +CREATE TABLE t1 (a INT); +INSERT INTO t1 VALUES (0),(1),(2),(3),(4),(5),(6),(7),(8),(9); + +CREATE TABLE t2 (a INT); +INSERT INTO t2 SELECT A.a + 10*(B.a) FROM t1 A, t1 B; + +CREATE TABLE t3 ( + c1 TINYTEXT NOT NULL, + i1 INT NOT NULL, + KEY (c1(6),i1) +); + +INSERT INTO t3 SELECT CONCAT('c-',1000+t2.a,'=w'), 1 FROM t2; + +EXPLAIN +SELECT c1 FROM t3 WHERE c1 >= 'c-1004=w' and c1 <= 'c-1006=w'; +SELECT c1 FROM t3 WHERE c1 >= 'c-1004=w' and c1 <= 'c-1006=w'; + +EXPLAIN +SELECT c1 FROM t3 WHERE c1 >= 'c-1004=w' and c1 <= 'c-1006=w' and i1 > 2; +SELECT c1 FROM t3 WHERE c1 >= 'c-1004=w' and c1 <= 'c-1006=w' and i1 > 2; + +EXPLAIN +SELECT c1 FROM t3 WHERE c1 >= 'c-1004=w' and c1 <= 'c-1006=w' or i1 > 2; +SELECT c1 FROM t3 WHERE c1 >= 'c-1004=w' and c1 <= 'c-1006=w' or i1 > 2; + +DROP TABLE t1, t2, t3; + +--echo # --echo # Bug#40992 - InnoDB: Crash when engine_condition_pushdown is on --echo # @@ -102,6 +248,7 @@ SELECT * FROM t WHERE a > 2 FOR UPDATE; DROP TABLE t; + --echo # --echo # Bug#35080 - Innodb crash at mem_block_get_len line 72 --echo # @@ -227,6 +374,273 @@ DROP PROCEDURE insert_data; DROP TABLE t1, t2, t3; --echo # +--echo # Bug#57372 "Multi-table updates and deletes fail when running with ICP +--echo # against InnoDB" +--echo # + +CREATE TABLE t1 ( + a INT KEY, + b INT +); + +CREATE TABLE t2 ( + a INT KEY, + b INT +); + +INSERT INTO t1 VALUES (1, 101), (2, 102), (3, 103), (4, 104), (5, 105); +INSERT INTO t2 VALUES (1, 1), (2, 2), (3, 3), (4, 4), (5, 5); + +UPDATE t1, t2 +SET t1.a = t1.a + 100, t2.b = t1.a + 10 +WHERE t1.a BETWEEN 2 AND 4 AND t2.a = t1.b - 100; + +--sorted_result +SELECT * FROM t1; +--sorted_result +SELECT * FROM t2; + +DROP TABLE t1, t2; + +--echo # +--echo # Bug#52605 - "Adding LIMIT 1 clause to query with complex range +--echo # predicate causes wrong results" +--echo # + +CREATE TABLE t1 ( + pk INT NOT NULL, + c1 INT, + PRIMARY KEY (pk), + KEY k1 (c1) +); + +INSERT INTO t1 VALUES (1,NULL); +INSERT INTO t1 VALUES (2,6); +INSERT INTO t1 VALUES (3,NULL); +INSERT INTO t1 VALUES (4,6); +INSERT INTO t1 VALUES (5,NULL); +INSERT INTO t1 VALUES (6,NULL); +INSERT INTO t1 VALUES (7,9); +INSERT INTO t1 VALUES (8,0); + +SELECT pk, c1 +FROM t1 +WHERE (pk BETWEEN 4 AND 5 OR pk < 2) AND c1 < 240 +ORDER BY c1 +LIMIT 1; + +EXPLAIN SELECT pk, c1 +FROM t1 +WHERE (pk BETWEEN 4 AND 5 OR pk < 2) AND c1 < 240 +ORDER BY c1 +LIMIT 1; + +DROP TABLE t1; + +--echo # +--echo # Bug#59259 "Incorrect rows returned for a correlated subquery +--echo # when ICP is on" +--echo # + +CREATE TABLE t1 (pk INTEGER PRIMARY KEY, i INTEGER NOT NULL) ENGINE=InnoDB; + +INSERT INTO t1 VALUES (11,0); +INSERT INTO t1 VALUES (12,5); +INSERT INTO t1 VALUES (15,0); + +CREATE TABLE t2 (pk INTEGER PRIMARY KEY, i INTEGER NOT NULL) ENGINE=InnoDB; + +INSERT INTO t2 VALUES (11,1); +INSERT INTO t2 VALUES (12,2); +INSERT INTO t2 VALUES (15,4); + +set @save_optimizer_switch= @@optimizer_switch; +set optimizer_switch='semijoin=off'; + +EXPLAIN +SELECT * FROM t1 +WHERE pk IN (SELECT it.pk FROM t2 JOIN t2 AS it ON it.i=it.i WHERE it.pk-t1.i<10); +SELECT * FROM t1 +WHERE pk IN (SELECT it.pk FROM t2 JOIN t2 AS it ON it.i=it.i WHERE it.pk-t1.i<10); + +set optimizer_switch=@save_optimizer_switch; + +DROP TABLE t1, t2; + +--echo # +--echo # Bug #58816 "Extra temporary duplicate rows in result set when +--echo # switching ICP off" +--echo # + +set @save_optimizer_switch= @@optimizer_switch; + +CREATE TABLE t1 ( + pk INT NOT NULL, + c1 INT NOT NULL, + PRIMARY KEY (pk) +); + +INSERT INTO t1 VALUES (1,9),(2,7),(3,6),(4,3),(5,1); + +EXPLAIN SELECT pk, c1 FROM t1 WHERE pk <> 3; + +SET SESSION optimizer_switch='index_condition_pushdown=off'; + +SELECT pk, c1 FROM t1 WHERE pk <> 3; + +DROP TABLE t1; + +set optimizer_switch= @save_optimizer_switch; + +--echo # +--echo # Bug#58837: ICP crash or valgrind error due to uninitialized +--echo # value in innobase_index_cond +--echo # + +CREATE TABLE t1 ( + t1_int INT, + t1_time TIME +); + +CREATE TABLE t2 ( + t2_int int PRIMARY KEY, + t2_int2 INT +); + +--disable_warnings +INSERT INTO t2 VALUES (); +INSERT INTO t1 VALUES (); +--enable_warnings + +SELECT * FROM t1 AS t1a + WHERE NOT EXISTS (SELECT * FROM t1 AS t1b + WHERE t1b.t1_int NOT IN + (SELECT t2.t2_int FROM t2 + WHERE t1b.t1_time LIKE t1b.t1_int + OR t1b.t1_time <> t2.t2_int2 + AND 6=7)); + +DROP TABLE t1,t2; + +--echo # +--echo # Bug#59186: Wrong results of join when ICP is enabled +--echo # (fixed by the patch for LP bug #694092) +--echo # + +CREATE TABLE t1 ( + pk INTEGER NOT NULL, + c1 VARCHAR(3) NOT NULL, + PRIMARY KEY (pk) +); +INSERT INTO t1 VALUES (1,'y'),(0,'or'); + +CREATE TABLE t2 ( + pk INTEGER NOT NULL, + c1 VARCHAR(3) NOT NULL, + c2 VARCHAR(6) NOT NULL, + PRIMARY KEY (pk) +); +INSERT INTO t2 VALUES (6,'y','RPOYT'),(10,'m','JINQE'); + +EXPLAIN +SELECT c2 FROM t1 JOIN t2 ON t1.c1 = t2.c1 +WHERE (t2.pk <= 4 AND t1.pk IN (2,1)) OR + (t1.pk > 1 AND t2.pk BETWEEN 6 AND 6); +SELECT c2 FROM t1 JOIN t2 ON t1.c1 = t2.c1 +WHERE (t2.pk <= 4 AND t1.pk IN (2,1)) OR + (t1.pk > 1 AND t2.pk BETWEEN 6 AND 6); + +DROP TABLE t1, t2; + +--echo # +--echo # Bug#58838: "Wrong results with HAVING + LIMIT without GROUP BY when +--echo # ICP is enabled". +--echo # (Fixed by the patches for LP bugs #668644, #702322) +--echo # + +CREATE TABLE t1 ( + pk INT NOT NULL, + c1 INT, + PRIMARY KEY (pk), + KEY col_int_key (c1) +); + +INSERT INTO t1 VALUES (1,37),(2,8),(3,-25),(4,NULL),(5,55); + +SELECT pk FROM t1 WHERE c1 <> 1 HAVING pk = 3 ORDER BY pk LIMIT 0; +SELECT pk FROM t1 WHERE c1 <> 1 HAVING pk = 3 ORDER BY pk LIMIT 1; +SELECT pk FROM t1 WHERE c1 <> 1 HAVING pk = 3 ORDER BY pk LIMIT 2; +SELECT pk FROM t1 WHERE c1 <> 1 HAVING pk = 3 ORDER BY pk LIMIT 5; + +DROP TABLE t1; + +--echo # +--echo # Bug#59483 "Crash on INSERT/REPLACE in +--echo # rec_convert_dtuple_to_rec_comp with ICP on" +--echo # + +CREATE TABLE t1 ( + pk INTEGER AUTO_INCREMENT PRIMARY KEY, + i1 INTEGER, + c1 CHAR(6), + i2 INTEGER NOT NULL, + KEY (i2) +); + +INSERT INTO t1 VALUES + (NULL, 4, 'that', 8), + (NULL, 1, 'she', 6), + (NULL, 6, 'tell', 2); + +SELECT * FROM t1 WHERE i2 IN (3, 6) LIMIT 2 FOR UPDATE; +INSERT INTO t1 (i2) VALUES (1); + +DROP TABLE t1; + +--echo # +--echo # Bug #11766678 - 59843: +--echo # USING UNINITIALISED VALUE IN USES_INDEX_FIELDS_ONLY +--echo # + +CREATE TABLE t1 ( + col999 FLOAT NOT NULL, + COL1000 VARBINARY(179) NOT NULL, + col1003 DATE DEFAULT NULL, + KEY idx4267 (col1000, col1003) +); + +INSERT INTO t1 VALUES (),(); +SELECT col999 FROM t1 WHERE col1000 = "3" AND col1003 <=> sysdate(); + +DROP TABLE t1; + +--echo # +--echo # BUG#12822678 - ICP WITH STRAIGHT_JOIN +--echo # + +CREATE TABLE t1 ( + i1 INTEGER NOT NULL, + d1 DOUBLE, + KEY k1 (d1) +); +INSERT INTO t1 VALUES (10,1), (17,NULL), (22,NULL); + +CREATE TABLE t2 ( + pk INTEGER NOT NULL, + i1 INTEGER NOT NULL, + PRIMARY KEY (pk) +); +INSERT INTO t2 VALUES (4,1); + +EXPLAIN +SELECT t1.d1, t2.pk, t2.i1 FROM t1 STRAIGHT_JOIN t2 ON t2.i1 + WHERE t2.pk <> t1.d1 AND t2.pk = 4; +SELECT t1.d1, t2.pk, t2.i1 FROM t1 STRAIGHT_JOIN t2 ON t2.i1 + WHERE t2.pk <> t1.d1 AND t2.pk = 4; + +DROP TABLE t1, t2; + +--echo # --echo # BUG#778434 Wrong result with in_to_exists=on in maria-5.3-mwl89 --echo # CREATE TABLE t1 ( f11 int) ; @@ -254,3 +668,79 @@ WHERE (6, 234) IN ( DROP TABLE t1,t2,t3,t4; set optimizer_switch= @tmp_778434; + +--echo # +--echo # Bug#885168: ICP for one index + potential ORDER BY for another +--echo # + +CREATE TABLE t1 (a varchar(64), b varchar(10), INDEX(a), INDEX(b)) ; +INSERT INTO t1 VALUES + ('Ohio','Iowa'), ('k','d'), ('bdkpj','mbdkpjdanp'), ('d','xdmbdkpjda'), + ('fkxdmbdkpjdanpje','o'), ('f','Pennsylvan'), ('Virginia','ei'); + +SET SESSION optimizer_switch='index_condition_pushdown=off'; +EXPLAIN +SELECT * FROM t1 + WHERE NOT(b = 'Texas') AND b BETWEEN 'wy' AND 'y' OR b = 'Pennsylvania' + ORDER BY a; +SELECT * FROM t1 + WHERE NOT(b = 'Texas') AND b BETWEEN 'wy' AND 'y' OR b = 'Pennsylvania' + ORDER BY a; + +SET SESSION optimizer_switch='index_condition_pushdown=on'; +EXPLAIN +SELECT * FROM t1 + WHERE NOT(b = 'Texas') AND b BETWEEN 'wy' AND 'y' OR b = 'Pennsylvania' + ORDER BY a; +SELECT * FROM t1 + WHERE NOT(b = 'Texas') AND b BETWEEN 'wy' AND 'y' OR b = 'Pennsylvania' + ORDER BY a; + +DROP TABLE t1; + +--echo # +--echo # Bug#886145: join with ICP + ORDER BY +--echo # + +CREATE TABLE t1 (b int NOT NULL, c int, a varchar(1024), PRIMARY KEY (b)); +INSERT INTO t1 VALUES (1,4,'Ill'); + +CREATE TABLE t2 (a varchar(1024), KEY (a(512))); +INSERT INTO t2 VALUES + ('Ill'), ('eckqzsflbzaffti'), ('w'), ('she'), ('gxbwypqtjzwywwer'), ('w'); + +SET SESSION optimizer_switch='index_condition_pushdown=off'; +EXPLAIN +SELECT t1.b, t1.c FROM t1, t2 WHERE t1.a = t2.a AND t1.b != 0 + HAVING t1.c != 5 ORDER BY t1.c; +SELECT t1.b, t1.c FROM t1, t2 WHERE t1.a = t2.a AND t1.b != 0 + HAVING t1.c != 5 ORDER BY t1.c; + +SET SESSION optimizer_switch='index_condition_pushdown=on'; +EXPLAIN +SELECT t1.b, t1.c FROM t1, t2 WHERE t1.a = t2.a AND t1.b != 0 + HAVING t1.c != 5 ORDER BY t1.c; +SELECT t1.b, t1.c FROM t1, t2 WHERE t1.a = t2.a AND t1.b != 0 + HAVING t1.c != 5 ORDER BY t1.c; + +DROP TABLE t1,t2; + +--echo # +--echo # Bug#879871: InnoDB: possible ICP + GROUP BY primary index +--echo # + +CREATE TABLE t1 ( + a int NOT NULL, b int, c varchar(1), d varchar(1), + PRIMARY KEY (a), KEY c (c,b) +); +INSERT INTO t1 VALUES (10,8,'g','g'); + +SET SESSION optimizer_switch='index_condition_pushdown=off'; +SELECT a FROM t1 WHERE c IS NULL AND d IS NOT NULL GROUP BY 1; + +SET SESSION optimizer_switch='index_condition_pushdown=on'; +SELECT a FROM t1 WHERE c IS NULL AND d IS NOT NULL GROUP BY 1; + +DROP TABLE t1; + + diff --git a/mysql-test/include/mtr_check.sql b/mysql-test/include/mtr_check.sql index fcd5eebc269..c9708f988de 100644 --- a/mysql-test/include/mtr_check.sql +++ b/mysql-test/include/mtr_check.sql @@ -1,3 +1,18 @@ +-- Copyright (c) 2008, 2010, Oracle and/or its affiliates. All rights reserved. +-- +-- 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 +-- the Free Software Foundation; version 2 of the License. +-- +-- This program is distributed in the hope that it will be useful, +-- but WITHOUT ANY WARRANTY; without even the implied warranty of +-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +-- GNU General Public License for more details. +-- +-- You should have received a copy of the GNU General Public License +-- along with this program; if not, write to the Free Software Foundation, +-- 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + delimiter ||; use mtr|| @@ -12,11 +27,9 @@ BEGIN -- Dump all global variables except those -- that are supposed to change SELECT * FROM INFORMATION_SCHEMA.GLOBAL_VARIABLES - WHERE variable_name != 'timestamp' + WHERE variable_name NOT IN ('timestamp', 'innodb_file_format_max') AND variable_name not like "Last_IO_Err*" - AND variable_name != 'INNODB_IBUF_MAX_SIZE' AND - variable_name != 'INNODB_FILE_FORMAT_CHECK' - ORDER BY variable_name; + ORDER BY VARIABLE_NAME; -- Dump all databases, there should be none -- except those that was created during bootstrap @@ -61,3 +74,13 @@ BEGIN mysql.user; END|| + +-- +-- Procedure used by test case used to force all +-- servers to restart after testcase and thus skipping +-- check test case after test +-- +CREATE DEFINER=root@localhost PROCEDURE force_restart() +BEGIN + SELECT 1 INTO OUTFILE 'force_restart'; +END|| diff --git a/mysql-test/include/mtr_warnings.sql b/mysql-test/include/mtr_warnings.sql index 57cd04d81a1..ce1563fc993 100644 --- a/mysql-test/include/mtr_warnings.sql +++ b/mysql-test/include/mtr_warnings.sql @@ -1,3 +1,18 @@ +-- Copyright (c) 2008, 2011, Oracle and/or its affiliates. All rights reserved. +-- +-- 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 +-- the Free Software Foundation; version 2 of the License. +-- +-- This program is distributed in the hope that it will be useful, +-- but WITHOUT ANY WARRANTY; without even the implied warranty of +-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +-- GNU General Public License for more details. +-- +-- You should have received a copy of the GNU General Public License +-- along with this program; if not, write to the Free Software Foundation, +-- 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + delimiter ||; use mtr|| diff --git a/mysql-test/include/mysqld--help.inc b/mysql-test/include/mysqld--help.inc index 3b8fdd482fc..346a3a7cb18 100644 --- a/mysql-test/include/mysqld--help.inc +++ b/mysql-test/include/mysqld--help.inc @@ -21,12 +21,12 @@ perl; datadir slave-load-tmpdir tmpdir socket/; # Plugins which may or may not be there: - @plugins=qw/innodb ndb archive blackhole federated partition ndbcluster debug temp-pool ssl des-key-file + @plugins=qw/innodb ndb archive blackhole federated partition ndbcluster feedback debug temp-pool ssl des-key-file xtradb thread-concurrency super-large-pages mutex-deadlock-detector null-audit maria aria pbxt oqgraph sphinx/; # And substitute the content some environment variables with their # names: - @env=qw/MYSQLTEST_VARDIR MYSQL_TEST_DIR MYSQL_LIBDIR MYSQL_CHARSETSDIR MYSQL_SHAREDIR/; + @env=qw/MYSQLTEST_VARDIR MYSQL_TEST_DIR MYSQL_CHARSETSDIR MYSQL_SHAREDIR/; $re1=join('|', @skipvars, @plugins); $re2=join('|', @plugins); diff --git a/mysql-test/include/plugin.defs b/mysql-test/include/plugin.defs index e07c603c8e5..6fbe4f68328 100644 --- a/mysql-test/include/plugin.defs +++ b/mysql-test/include/plugin.defs @@ -39,3 +39,4 @@ ha_archive storage/archive ARCHIVE_PLUGIN ha_blackhole storage/blackhole BLACKHOLE_PLUGIN ha_federated storage/federated FEDERATED_PLUGIN mypluglib plugin/fulltext SIMPLE_PARSER +libdaemon_example plugin/daemon_example DAEMONEXAMPLE diff --git a/mysql-test/include/set_binlog_format_mixed.sql b/mysql-test/include/set_binlog_format_mixed.sql index 836992d1080..65c779ef141 100644 --- a/mysql-test/include/set_binlog_format_mixed.sql +++ b/mysql-test/include/set_binlog_format_mixed.sql @@ -1,2 +1,18 @@ +# Copyright (c) 2007 MySQL AB +# Use is subject to license terms. +# +# 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 +# the Free Software Foundation; version 2 of the License. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software Foundation, +# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + SET GLOBAL BINLOG_FORMAT=MIXED; SET SESSION BINLOG_FORMAT=MIXED; diff --git a/mysql-test/include/set_binlog_format_row.sql b/mysql-test/include/set_binlog_format_row.sql index 49f34c8ccd1..0400ed48be9 100644 --- a/mysql-test/include/set_binlog_format_row.sql +++ b/mysql-test/include/set_binlog_format_row.sql @@ -1,2 +1,18 @@ +# Copyright (c) 2007 MySQL AB +# Use is subject to license terms. +# +# 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 +# the Free Software Foundation; version 2 of the License. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software Foundation, +# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + SET GLOBAL BINLOG_FORMAT=ROW; SET SESSION BINLOG_FORMAT=ROW; diff --git a/mysql-test/include/set_binlog_format_statement.sql b/mysql-test/include/set_binlog_format_statement.sql index ed286e7e3cc..b582230e648 100644 --- a/mysql-test/include/set_binlog_format_statement.sql +++ b/mysql-test/include/set_binlog_format_statement.sql @@ -1,2 +1,18 @@ +# Copyright (c) 2007 MySQL AB +# Use is subject to license terms. +# +# 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 +# the Free Software Foundation; version 2 of the License. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software Foundation, +# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + SET GLOBAL BINLOG_FORMAT=STATEMENT; SET SESSION BINLOG_FORMAT=STATEMENT; diff --git a/mysql-test/lib/My/Config.pm b/mysql-test/lib/My/Config.pm index bf6629754a1..23f29b53ff3 100644 --- a/mysql-test/lib/My/Config.pm +++ b/mysql-test/lib/My/Config.pm @@ -1,5 +1,20 @@ # -*- cperl -*- +# Copyright (c) 2007, 2010, Oracle and/or its affiliates. All rights reserved. +# +# 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 +# the Free Software Foundation; version 2 of the License. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# 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 02110-1301 USA + package My::Config::Option; use strict; diff --git a/mysql-test/lib/My/ConfigFactory.pm b/mysql-test/lib/My/ConfigFactory.pm index 02fd556a047..1bc9977cf4a 100644 --- a/mysql-test/lib/My/ConfigFactory.pm +++ b/mysql-test/lib/My/ConfigFactory.pm @@ -1,5 +1,5 @@ # -*- cperl -*- -# Copyright (c) 2008, 2011, Oracle and/or its affiliates. All rights reserved. +# Copyright (c) 2007, 2011, Oracle and/or its affiliates. All rights reserved. # # This program is free software; you can redistribute it and/or # modify it under the terms of the GNU Library General Public diff --git a/mysql-test/lib/My/CoreDump.pm b/mysql-test/lib/My/CoreDump.pm index b0c4a1337d8..419a0e7f39f 100644 --- a/mysql-test/lib/My/CoreDump.pm +++ b/mysql-test/lib/My/CoreDump.pm @@ -81,7 +81,7 @@ sub _gdb { return if $? >> 8; return unless $gdb_output; - resfile_print <<EOF, $gdb_output, "\n"; + resfile_print <<EOF . $gdb_output . "\n"; Output from gdb follows. The first stack trace is from the failing thread. The following stack traces are from all threads (so the failing one is duplicated). @@ -245,7 +245,7 @@ sub _cdb { $cdb_output=~ s/^Child\-SP RetAddr Call Site//gm; $cdb_output=~ s/\+0x([0-9a-fA-F]+)//gm; - resfile_print <<EOF, $cdb_output, "\n"; + resfile_print <<EOF . $cdb_output . "\n"; Output from cdb follows. Faulting thread is printed twice,with and without function parameters Search for STACK_TEXT to see the stack trace of the faulting thread. Callstacks of other threads are printed after it. diff --git a/mysql-test/lib/My/File/Path.pm b/mysql-test/lib/My/File/Path.pm index 14fb43e8d98..1b7982d6b36 100644 --- a/mysql-test/lib/My/File/Path.pm +++ b/mysql-test/lib/My/File/Path.pm @@ -1,5 +1,6 @@ # -*- cperl -*- -# Copyright (C) 2008 MySQL AB, 2009 Sun Microsystems, Inc. +# Copyright (c) 2007 MySQL AB, 2008, 2009 Sun Microsystems, Inc. +# Use is subject to license terms. # # 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/mysql-test/lib/My/Find.pm b/mysql-test/lib/My/Find.pm index ec937eb90b4..bd153becaf7 100644 --- a/mysql-test/lib/My/Find.pm +++ b/mysql-test/lib/My/Find.pm @@ -1,5 +1,5 @@ # -*- cperl -*- -# Copyright (c) 2004, 2011, Oracle and/or its affiliates. +# Copyright (c) 2007, 2011, Oracle and/or its affiliates. # # 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/mysql-test/lib/My/Handles.pm b/mysql-test/lib/My/Handles.pm index 66ee22b403f..d120eb7b1d4 100644 --- a/mysql-test/lib/My/Handles.pm +++ b/mysql-test/lib/My/Handles.pm @@ -1,5 +1,5 @@ # -*- cperl -*- -# Copyright (C) 2008 MySQL AB +# Copyright (c) 2008, 2010, Oracle and/or its affiliates. All rights reserved. # # 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/mysql-test/lib/My/Options.pm b/mysql-test/lib/My/Options.pm index dcd934084e2..55d1010aad8 100644 --- a/mysql-test/lib/My/Options.pm +++ b/mysql-test/lib/My/Options.pm @@ -1,5 +1,5 @@ # -*- cperl -*- -# Copyright (C) 2008 MySQL AB +# Copyright (c) 2008, 2010, Oracle and/or its affiliates. All rights reserved. # # 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/mysql-test/lib/My/Platform.pm b/mysql-test/lib/My/Platform.pm index cbe8f929d71..483bf0bd4f3 100644 --- a/mysql-test/lib/My/Platform.pm +++ b/mysql-test/lib/My/Platform.pm @@ -1,5 +1,6 @@ # -*- cperl -*- -# Copyright (C) 2008 MySQL AB, 2009 Sun Microsystems, Inc. +# Copyright (c) 2008 MySQL AB, 2008, 2009 Sun Microsystems, Inc. +# Use is subject to license terms. # # 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/mysql-test/lib/My/SafeProcess.pm b/mysql-test/lib/My/SafeProcess.pm index 1f00065fae2..e7917f8fb16 100644 --- a/mysql-test/lib/My/SafeProcess.pm +++ b/mysql-test/lib/My/SafeProcess.pm @@ -1,5 +1,5 @@ # -*- cperl -*- -# Copyright (c) 2008, 2011, Oracle and/or its affiliates. +# Copyright (c) 2007, 2011, Oracle and/or its affiliates. # Copyright (c) 2009, 2011 Monty Program Ab # # This program is free software; you can redistribute it and/or diff --git a/mysql-test/lib/My/SafeProcess/Base.pm b/mysql-test/lib/My/SafeProcess/Base.pm index c0c70e48082..0e8c191c440 100644 --- a/mysql-test/lib/My/SafeProcess/Base.pm +++ b/mysql-test/lib/My/SafeProcess/Base.pm @@ -1,5 +1,6 @@ # -*- cperl -*- -# Copyright (C) 2008 MySQL AB, 2009 Sun Microsystems, Inc. +# Copyright (c) 2007 MySQL AB, 2008, 2009 Sun Microsystems, Inc. +# Use is subject to license terms. # # 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/mysql-test/lib/My/SafeProcess/safe_kill_win.cc b/mysql-test/lib/My/SafeProcess/safe_kill_win.cc index 72fe874e621..2ac29c61bc7 100644 --- a/mysql-test/lib/My/SafeProcess/safe_kill_win.cc +++ b/mysql-test/lib/My/SafeProcess/safe_kill_win.cc @@ -1,4 +1,4 @@ -/* Copyright (C) 2008 MySQL AB, 2009 Sun Microsystems, Inc. +/* Copyright (c) 2007, 2010, Oracle and/or its affiliates. All rights reserved. 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 @@ -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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ /* diff --git a/mysql-test/lib/My/SafeProcess/safe_process.pl b/mysql-test/lib/My/SafeProcess/safe_process.pl index 54b0073f8df..1b3c0aa9a5f 100644 --- a/mysql-test/lib/My/SafeProcess/safe_process.pl +++ b/mysql-test/lib/My/SafeProcess/safe_process.pl @@ -1,6 +1,21 @@ #!/usr/bin/perl # -*- cperl -*- +# Copyright (c) 2007, 2011, Oracle and/or its affiliates. All rights reserved. +# +# 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 +# the Free Software Foundation; version 2 of the License. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# 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 02110-1301 USA + use strict; use warnings; diff --git a/mysql-test/lib/My/SafeProcess/safe_process_win.cc b/mysql-test/lib/My/SafeProcess/safe_process_win.cc index 7e0ae68b4de..87a14481e25 100644 --- a/mysql-test/lib/My/SafeProcess/safe_process_win.cc +++ b/mysql-test/lib/My/SafeProcess/safe_process_win.cc @@ -1,4 +1,4 @@ -/* Copyright (c) 2008, 2011, Oracle and/or its affiliates. All rights reserved. +/* Copyright (c) 2007, 2011, Oracle and/or its affiliates. All rights reserved. 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 @@ -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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ /* diff --git a/mysql-test/lib/My/SysInfo.pm b/mysql-test/lib/My/SysInfo.pm index b8569e415e8..28660f44bae 100644 --- a/mysql-test/lib/My/SysInfo.pm +++ b/mysql-test/lib/My/SysInfo.pm @@ -1,5 +1,6 @@ # -*- cperl -*- -# Copyright (C) 2008 MySQL AB +# Copyright (c) 2008 MySQL AB, 2008 Sun Microsystems, Inc. +# Use is subject to license terms. # # 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/mysql-test/lib/mtr_cases.pm b/mysql-test/lib/mtr_cases.pm index bf85bd91047..2d8f111f054 100644 --- a/mysql-test/lib/mtr_cases.pm +++ b/mysql-test/lib/mtr_cases.pm @@ -339,17 +339,41 @@ sub collect_one_suite for my $skip (@disabled_collection) { if ( open(DISABLED, $skip ) ) - { - while ( <DISABLED> ) - { - chomp; - if ( /^\s*(\S+)\s*:\s*(.*?)\s*$/ ) - { - $disabled{$1}= $2 if not exists $disabled{$1}; - } - } - close DISABLED; - } + { + # $^O on Windows considered not generic enough + my $plat= (IS_WINDOWS) ? 'windows' : $^O; + + while ( <DISABLED> ) + { + chomp; + #diasble the test case if platform matches + if ( /\@/ ) + { + if ( /\@$plat/ ) + { + /^\s*(\S+)\s*\@$plat.*:\s*(.*?)\s*$/ ; + $disabled{$1}= $2 if not exists $disabled{$1}; + } + elsif ( /\@!(\S*)/ ) + { + if ( $1 ne $plat) + { + /^\s*(\S+)\s*\@!.*:\s*(.*?)\s*$/ ; + $disabled{$1}= $2 if not exists $disabled{$1}; + } + } + } + elsif ( /^\s*(\S+)\s*:\s*(.*?)\s*$/ ) + { + chomp; + if ( /^\s*(\S+)\s*:\s*(.*?)\s*$/ ) + { + $disabled{$1}= $2 if not exists $disabled{$1}; + } + } + } + close DISABLED; + } } # Read suite.opt file diff --git a/mysql-test/lib/mtr_gprof.pl b/mysql-test/lib/mtr_gprof.pl index a5e05b28723..15aad17a3d4 100644 --- a/mysql-test/lib/mtr_gprof.pl +++ b/mysql-test/lib/mtr_gprof.pl @@ -1,5 +1,5 @@ # -*- cperl -*- -# Copyright (C) 2004 MySQL AB, 2009 Sun Microsystems, Inc. +# Copyright (c) 2004, 2011, Oracle and/or its affiliates. All rights reserved. # # 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/mysql-test/lib/mtr_io.pl b/mysql-test/lib/mtr_io.pl index 6a6b3a3d028..8c2803f0427 100644 --- a/mysql-test/lib/mtr_io.pl +++ b/mysql-test/lib/mtr_io.pl @@ -1,5 +1,6 @@ # -*- cperl -*- -# Copyright (C) 2004-2007 MySQL AB, 2008 Sun Microsystems, Inc. +# Copyright (c) 2004-2008 MySQL AB, 2008 Sun Microsystems, Inc. +# Use is subject to license terms. # # 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/mysql-test/lib/mtr_stress.pl b/mysql-test/lib/mtr_stress.pl index ab4214791d0..6ab607e6439 100644 --- a/mysql-test/lib/mtr_stress.pl +++ b/mysql-test/lib/mtr_stress.pl @@ -1,5 +1,6 @@ # -*- cperl -*- -# Copyright (C) 2004-2007 MySQL AB, 2009 Sun Microsystems, Inc. +# Copyright (c) 2004-2007 MySQL AB, 2009 Sun Microsystems, Inc. +# Use is subject to license terms. # # 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/mysql-test/lib/mtr_unique.pm b/mysql-test/lib/mtr_unique.pm index 506af448266..8d719786283 100644 --- a/mysql-test/lib/mtr_unique.pm +++ b/mysql-test/lib/mtr_unique.pm @@ -1,5 +1,6 @@ # -*- cperl -*- -# Copyright (C) 2006-2008 MySQL AB, 2009 Sun Microsystems, Inc. +# Copyright (c) 2006, 2008 MySQL AB, 2009 Sun Microsystems, Inc. +# Use is subject to license terms. # # 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/mysql-test/lib/t/Base.t b/mysql-test/lib/t/Base.t index 6ca7657d421..b540944f3a1 100644 --- a/mysql-test/lib/t/Base.t +++ b/mysql-test/lib/t/Base.t @@ -1,4 +1,21 @@ # -*- cperl -*- + +# Copyright (c) 2007 MySQL AB +# Use is subject to license terms. +# +# 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 +# the Free Software Foundation; version 2 of the License. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# 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 02110-1301 USA + use Test::More qw(no_plan); use strict; diff --git a/mysql-test/lib/t/Find.t b/mysql-test/lib/t/Find.t index 90489ba06dd..d609fd86dd9 100644 --- a/mysql-test/lib/t/Find.t +++ b/mysql-test/lib/t/Find.t @@ -1,4 +1,21 @@ # -*- cperl -*- + +# Copyright (c) 2007 MySQL AB +# Use is subject to license terms. +# +# 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 +# the Free Software Foundation; version 2 of the License. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# 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 02110-1301 USA + use Test::More qw(no_plan); use strict; diff --git a/mysql-test/lib/t/Options.t b/mysql-test/lib/t/Options.t index 3824c838627..c832b885cb7 100644 --- a/mysql-test/lib/t/Options.t +++ b/mysql-test/lib/t/Options.t @@ -1,5 +1,20 @@ - # -*- cperl -*- + +# Copyright (c) 2008, 2010, Oracle and/or its affiliates. All rights reserved. +# +# 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 +# the Free Software Foundation; version 2 of the License. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# 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 02110-1301 USA + use Test::More qw(no_plan); use strict; diff --git a/mysql-test/lib/t/Platform.t b/mysql-test/lib/t/Platform.t index a8cb7751925..c78c22ddb5a 100644 --- a/mysql-test/lib/t/Platform.t +++ b/mysql-test/lib/t/Platform.t @@ -1,4 +1,21 @@ # -*- cperl -*- + +# Copyright (c) 2008 MySQL AB +# Use is subject to license terms. +# +# 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 +# the Free Software Foundation; version 2 of the License. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# 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 02110-1301 USA + use Test::More qw(no_plan); use strict; diff --git a/mysql-test/lib/t/SafeProcess.t b/mysql-test/lib/t/SafeProcess.t index d4a62ff8cca..0fab69b9088 100644 --- a/mysql-test/lib/t/SafeProcess.t +++ b/mysql-test/lib/t/SafeProcess.t @@ -1,5 +1,21 @@ # -*- cperl -*- +# Copyright (c) 2007 MySQL AB +# Use is subject to license terms. +# +# 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 +# the Free Software Foundation; version 2 of the License. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# 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 02110-1301 USA + use strict; use FindBin; use IO::File; diff --git a/mysql-test/lib/t/SafeProcessStress.pl b/mysql-test/lib/t/SafeProcessStress.pl index 0f7a59d67f0..a5dbeecfb4b 100755 --- a/mysql-test/lib/t/SafeProcessStress.pl +++ b/mysql-test/lib/t/SafeProcessStress.pl @@ -1,6 +1,22 @@ #!/usr/bin/perl # -*- cperl -*- +# Copyright (c) 2007, 2008 MySQL AB +# Use is subject to license terms. +# +# 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 +# the Free Software Foundation; version 2 of the License. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# 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 02110-1301 USA + use strict; use FindBin; use My::SafeProcess; diff --git a/mysql-test/lib/t/copytree.t b/mysql-test/lib/t/copytree.t index 15e4d1a7b1b..cdb99b851c4 100644 --- a/mysql-test/lib/t/copytree.t +++ b/mysql-test/lib/t/copytree.t @@ -1,6 +1,22 @@ #!/usr/bin/perl # -*- cperl -*- +# Copyright (c) 2007 MySQL AB +# Use is subject to license terms. +# +# 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 +# the Free Software Foundation; version 2 of the License. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# 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 02110-1301 USA + use strict; use My::File::Path; diff --git a/mysql-test/lib/t/dummyd.pl b/mysql-test/lib/t/dummyd.pl index 07336e3c2d2..fae747354d7 100644 --- a/mysql-test/lib/t/dummyd.pl +++ b/mysql-test/lib/t/dummyd.pl @@ -1,6 +1,22 @@ #!/usr/bin/perl # -*- cperl -*- +# Copyright (c) 2007 MySQL AB +# Use is subject to license terms. +# +# 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 +# the Free Software Foundation; version 2 of the License. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# 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 02110-1301 USA + use strict; use Getopt::Long; use IO::File; diff --git a/mysql-test/lib/t/rmtree.t b/mysql-test/lib/t/rmtree.t index 08c9077d001..8c9863a1edd 100644 --- a/mysql-test/lib/t/rmtree.t +++ b/mysql-test/lib/t/rmtree.t @@ -1,6 +1,22 @@ #!/usr/bin/perl # -*- cperl -*- +# Copyright (c) 2007 MySQL AB +# Use is subject to license terms. +# +# 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 +# the Free Software Foundation; version 2 of the License. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# 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 02110-1301 USA + use strict; use My::File::Path; diff --git a/mysql-test/lib/t/testMyConfig.t b/mysql-test/lib/t/testMyConfig.t index da08cb8b4d1..f79e8776676 100755 --- a/mysql-test/lib/t/testMyConfig.t +++ b/mysql-test/lib/t/testMyConfig.t @@ -1,6 +1,22 @@ #!/usr/bin/perl # -*- cperl -*- +# Copyright (c) 2007 MySQL AB +# Use is subject to license terms. +# +# 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 +# the Free Software Foundation; version 2 of the License. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# 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 02110-1301 USA + use strict; use warnings; use File::Temp qw / tempdir /; diff --git a/mysql-test/lib/t/testMyConfigFactory.t b/mysql-test/lib/t/testMyConfigFactory.t index e3ab5d54b5b..9f43bed3d98 100755 --- a/mysql-test/lib/t/testMyConfigFactory.t +++ b/mysql-test/lib/t/testMyConfigFactory.t @@ -1,6 +1,22 @@ #!/usr/bin/perl # -*- cperl -*- +# Copyright (c) 2007 MySQL AB, 2009 Sun Microsystems, Inc. +# Use is subject to license terms. +# +# 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 +# the Free Software Foundation; version 2 of the License. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# 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 02110-1301 USA + use strict; use warnings; diff --git a/mysql-test/lib/t/test_child.pl b/mysql-test/lib/t/test_child.pl index 99f4e68003d..38d9f906738 100755 --- a/mysql-test/lib/t/test_child.pl +++ b/mysql-test/lib/t/test_child.pl @@ -1,6 +1,22 @@ #!/usr/bin/perl # -*- cperl -*- +# Copyright (c) 2007 MySQL AB +# Use is subject to license terms. +# +# 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 +# the Free Software Foundation; version 2 of the License. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# 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 02110-1301 USA + use strict; use Getopt::Long; diff --git a/mysql-test/lib/v1/My/Config.pm b/mysql-test/lib/v1/My/Config.pm index 5491e341ddc..cc4c34b2d62 100644 --- a/mysql-test/lib/v1/My/Config.pm +++ b/mysql-test/lib/v1/My/Config.pm @@ -1,5 +1,21 @@ # -*- cperl -*- +# Copyright (c) 2008 Sun Microsystems, Inc. +# Use is subject to license terms. +# +# 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 +# the Free Software Foundation; version 2 of the License. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# 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 02110-1301 USA + package My::Config::Option; use strict; diff --git a/mysql-test/lib/v1/mtr_cases.pl b/mysql-test/lib/v1/mtr_cases.pl index 288e8c22b44..baeab24f519 100644 --- a/mysql-test/lib/v1/mtr_cases.pl +++ b/mysql-test/lib/v1/mtr_cases.pl @@ -1,5 +1,6 @@ # -*- cperl -*- -# Copyright (C) 2005-2006 MySQL AB +# Copyright (c) 2005, 2006 MySQL AB, 2008, 2009 Sun Microsystems, Inc. +# Use is subject to license terms. # # 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/mysql-test/lib/v1/mtr_gcov.pl b/mysql-test/lib/v1/mtr_gcov.pl index a2de1fcbdff..56942be72a8 100644 --- a/mysql-test/lib/v1/mtr_gcov.pl +++ b/mysql-test/lib/v1/mtr_gcov.pl @@ -1,5 +1,6 @@ # -*- cperl -*- -# Copyright (C) 2004, 2006 MySQL AB +# Copyright (c) 2004, 2006 MySQL AB, 2008 Sun Microsystems, Inc. +# Use is subject to license terms. # # 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/mysql-test/lib/v1/mtr_gprof.pl b/mysql-test/lib/v1/mtr_gprof.pl index f6615301dd7..04c6eced28a 100644 --- a/mysql-test/lib/v1/mtr_gprof.pl +++ b/mysql-test/lib/v1/mtr_gprof.pl @@ -1,5 +1,6 @@ # -*- cperl -*- -# Copyright (C) 2004 MySQL AB +# Copyright (c) 2004 MySQL AB, 2008 Sun Microsystems, Inc. +# Use is subject to license terms. # # 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/mysql-test/lib/v1/mtr_im.pl b/mysql-test/lib/v1/mtr_im.pl index c8e332498d7..c34acc9c82f 100644 --- a/mysql-test/lib/v1/mtr_im.pl +++ b/mysql-test/lib/v1/mtr_im.pl @@ -1,5 +1,6 @@ # -*- cperl -*- -# Copyright (C) 2006 MySQL AB +# Copyright (c) 2006 MySQL AB, 2008 Sun Microsystems, Inc. +# Use is subject to license terms. # # 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/mysql-test/lib/v1/mtr_io.pl b/mysql-test/lib/v1/mtr_io.pl index 952b8f1f4ba..5769240bf7f 100644 --- a/mysql-test/lib/v1/mtr_io.pl +++ b/mysql-test/lib/v1/mtr_io.pl @@ -1,5 +1,5 @@ # -*- cperl -*- -# Copyright (C) 2004-2006 MySQL AB +# Copyright (c) 2004, 2010, Oracle and/or its affiliates. All rights reserved. # # 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/mysql-test/lib/v1/mtr_match.pl b/mysql-test/lib/v1/mtr_match.pl index 96aa43f4fa2..5cc74efb8c9 100644 --- a/mysql-test/lib/v1/mtr_match.pl +++ b/mysql-test/lib/v1/mtr_match.pl @@ -1,5 +1,6 @@ # -*- cperl -*- -# Copyright (C) 2004-2006 MySQL AB +# Copyright (c) 2004-2006 MySQL AB, 2008 Sun Microsystems, Inc. +# Use is subject to license terms. # # 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/mysql-test/lib/v1/mtr_misc.pl b/mysql-test/lib/v1/mtr_misc.pl index da2395a8a95..07b50e865ab 100644 --- a/mysql-test/lib/v1/mtr_misc.pl +++ b/mysql-test/lib/v1/mtr_misc.pl @@ -1,5 +1,5 @@ # -*- cperl -*- -# Copyright (C) 2004-2006 MySQL AB +# Copyright (c) 2004, 2010, Oracle and/or its affiliates. All rights reserved. # # 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/mysql-test/lib/v1/mtr_process.pl b/mysql-test/lib/v1/mtr_process.pl index 33a39d1f0b6..f86f9e5dec0 100644 --- a/mysql-test/lib/v1/mtr_process.pl +++ b/mysql-test/lib/v1/mtr_process.pl @@ -1,5 +1,6 @@ # -*- cperl -*- -# Copyright (C) 2004-2006 MySQL AB +# Copyright (c) 2004-2006 MySQL AB, 2008 Sun Microsystems, Inc. +# Use is subject to license terms. # # 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/mysql-test/lib/v1/mtr_report.pl b/mysql-test/lib/v1/mtr_report.pl index dde093ff674..7166eb523f2 100644 --- a/mysql-test/lib/v1/mtr_report.pl +++ b/mysql-test/lib/v1/mtr_report.pl @@ -1,5 +1,5 @@ # -*- cperl -*- -# Copyright (C) 2004-2006 MySQL AB +# Copyright (c) 2004, 2010, Oracle and/or its affiliates. All rights reserved. # # 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/mysql-test/lib/v1/mtr_stress.pl b/mysql-test/lib/v1/mtr_stress.pl index 40800c9729b..7f92c417271 100644 --- a/mysql-test/lib/v1/mtr_stress.pl +++ b/mysql-test/lib/v1/mtr_stress.pl @@ -1,5 +1,6 @@ # -*- cperl -*- -# Copyright (C) 2006 MySQL AB +# Copyright (c) 2006 MySQL AB, 2008, 2009 Sun Microsystems, Inc. +# Use is subject to license terms. # # 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/mysql-test/lib/v1/mtr_timer.pl b/mysql-test/lib/v1/mtr_timer.pl index 326fbea74ec..4fc68afa364 100644 --- a/mysql-test/lib/v1/mtr_timer.pl +++ b/mysql-test/lib/v1/mtr_timer.pl @@ -1,5 +1,6 @@ # -*- cperl -*- -# Copyright (C) 2005-2006 MySQL AB +# Copyright (c) 2005, 2006 MySQL AB, 2008 Sun Microsystems, Inc. +# Use is subject to license terms. # # 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/mysql-test/lib/v1/mtr_unique.pl b/mysql-test/lib/v1/mtr_unique.pl index a668fc097c7..4e4e720e689 100644 --- a/mysql-test/lib/v1/mtr_unique.pl +++ b/mysql-test/lib/v1/mtr_unique.pl @@ -1,5 +1,6 @@ # -*- cperl -*- -# Copyright (C) 2006 MySQL AB +# Copyright (c) 2006 MySQL AB, 2008 Sun Microsystems, Inc. +# Use is subject to license terms. # # 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/mysql-test/lib/v1/mysql-test-run.pl b/mysql-test/lib/v1/mysql-test-run.pl index df91d887c23..61ec3476ed7 100755 --- a/mysql-test/lib/v1/mysql-test-run.pl +++ b/mysql-test/lib/v1/mysql-test-run.pl @@ -1,7 +1,21 @@ #!/usr/bin/perl # -*- cperl -*- -# +# Copyright (c) 2008, 2010, Oracle and/or its affiliates. All rights reserved. +# +# 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 +# the Free Software Foundation; version 2 of the License. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# 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 02110-1301 USA + ############################################################################## # # mysql-test-run.pl @@ -2335,8 +2349,11 @@ sub remove_stale_vardir () { mtr_report("WARNING: Using the 'mysql-test/var' symlink"); # Make sure the directory where it points exist - mtr_error("The destination for symlink $opt_vardir does not exist") - if ! -d readlink($opt_vardir); + if (! -d readlink($opt_vardir)) + { + mtr_report("The destination for symlink $opt_vardir does not exist; Removing it and creating a new var directory"); + unlink($opt_vardir); + } foreach my $bin ( glob("$opt_vardir/*") ) { @@ -2395,8 +2412,11 @@ sub setup_vardir() { # it's a symlink # Make sure the directory where it points exist - mtr_error("The destination for symlink $opt_vardir does not exist") - if ! -d readlink($opt_vardir); + if (! -d readlink($opt_vardir)) + { + mtr_report("The destination for symlink $opt_vardir does not exist; Removing it and creating a new var directory"); + unlink($opt_vardir); + } } elsif ( $opt_mem ) { diff --git a/mysql-test/mysql-stress-test.pl b/mysql-test/mysql-stress-test.pl index 143ea78e739..860be1c1251 100755 --- a/mysql-test/mysql-stress-test.pl +++ b/mysql-test/mysql-stress-test.pl @@ -222,9 +222,9 @@ GetOptions("server-host=s", "server-logs-dir=s", "server-port=s", "test-duration=i", "test-suffix=s", "check-tests-file", "verbose", "log-error-details", "cleanup", "mysqltest=s", # OBN: (changing 'abort-on-error' to numberic for WL-4626/4685) - "abort-on-error=i" => \$opt_abort_on_error, "help") || usage(); + "abort-on-error=i" => \$opt_abort_on_error, "help") || usage(1); -usage() if ($opt_help); +usage(0) if ($opt_help); #$opt_abort_on_error=1; @@ -1115,6 +1115,7 @@ sub sig_TERM_handler sub usage { + my $retcode= shift; print <<EOF; The MySQL Stress suite Ver $stress_suite_version @@ -1218,7 +1219,7 @@ perl mysql-stress-test.pl \ --cleanup \ EOF -exit(0); +exit($retcode); } diff --git a/mysql-test/mysql-test-run.pl b/mysql-test/mysql-test-run.pl index 6bbbceb6017..25427b81eff 100755 --- a/mysql-test/mysql-test-run.pl +++ b/mysql-test/mysql-test-run.pl @@ -186,9 +186,11 @@ my $opt_suites; our $opt_verbose= 0; # Verbose output, enable with --verbose our $exe_mysql; +our $exe_mysql_plugin; our $exe_mysqladmin; our $exe_mysqltest; our $exe_libtool; +our $exe_mysql_embedded; our $opt_big_test= 0; our $opt_staging_run= 0; @@ -198,6 +200,8 @@ our @opt_combinations; our @opt_extra_mysqld_opt; our @opt_mysqld_envs; +my $opt_stress; + my $opt_compress; my $opt_ssl; my $opt_skip_ssl; @@ -237,10 +241,13 @@ our %gprof_dirs; our $glob_debugger= 0; our $opt_gdb; our $opt_client_gdb; +my $opt_boot_gdb; our $opt_dbx; our $opt_client_dbx; +my $opt_boot_dbx; our $opt_ddd; our $opt_client_ddd; +my $opt_boot_ddd; our $opt_manual_gdb; our $opt_manual_dbx; our $opt_manual_ddd; @@ -404,6 +411,7 @@ sub main { } } } + mtr_report("Using suites: $opt_suites") unless @opt_cases; print "vardir: $opt_vardir\n"; initialize_servers(); @@ -469,8 +477,8 @@ sub main { } $ENV{MTR_PARALLEL} = $opt_parallel; - if ($opt_parallel > 1 && $opt_start_exit) { - mtr_warning("Parallel and --start-and-exit cannot be combined\n" . + if ($opt_parallel > 1 && ($opt_start_exit || $opt_stress)) { + mtr_warning("Parallel cannot be used with --start-and-exit or --stress\n" . "Setting parallel to 1"); $opt_parallel= 1; } @@ -693,8 +701,9 @@ sub run_test_server ($$$) { my $core_file= $File::Find::name; my $core_name= basename($core_file); - if ($core_name =~ /^core/ or # Starting with core - (IS_WINDOWS and $core_name =~ /\.dmp$/)){ + # Name beginning with core, not ending in .gz + if (($core_name =~ /^core/ and $core_name !~ /\.gz$/) + or (IS_WINDOWS and $core_name =~ /\.dmp$/)){ # Ending with .dmp mtr_report(" - found '$core_name'", "($num_saved_cores/$opt_max_save_core)"); @@ -1167,14 +1176,17 @@ sub command_line_setup { 'gdb' => \$opt_gdb, 'client-gdb' => \$opt_client_gdb, 'manual-gdb' => \$opt_manual_gdb, + 'boot-gdb' => \$opt_boot_gdb, 'manual-debug' => \$opt_manual_debug, 'ddd' => \$opt_ddd, 'client-ddd' => \$opt_client_ddd, 'manual-ddd' => \$opt_manual_ddd, + 'boot-ddd' => \$opt_boot_ddd, 'dbx' => \$opt_dbx, 'client-dbx' => \$opt_client_dbx, 'manual-dbx' => \$opt_manual_dbx, 'debugger=s' => \$opt_debugger, + 'boot-dbx' => \$opt_boot_dbx, 'client-debugger=s' => \$opt_client_debugger, 'strace' => \$opt_strace, 'strace-client:s' => \$opt_strace_client, @@ -1247,6 +1259,7 @@ sub command_line_setup { 'default-myisam!' => \&collect_option, 'report-times' => \$opt_report_times, 'result-file' => \$opt_resfile, + 'stress=s' => \$opt_stress, 'help|h' => \$opt_usage, # list-options is internal, not listed in help @@ -1690,6 +1703,21 @@ sub command_line_setup { } # -------------------------------------------------------------------------- + # Gather stress-test options and modify behavior + # -------------------------------------------------------------------------- + + if ($opt_stress) + { + $opt_stress=~ s/,/ /g; + $opt_user_args= 1; + mtr_error("--stress cannot be combined with named ordinary suites or tests") + if $opt_suites || @opt_cases; + $opt_suites="stress"; + @opt_cases= ("wrapper"); + $ENV{MST_OPTIONS}= $opt_stress; + } + + # -------------------------------------------------------------------------- # Check timeout arguments # -------------------------------------------------------------------------- @@ -2025,6 +2053,9 @@ sub executable_setup () { # Look for the client binaries $exe_mysqladmin= mtr_exe_exists("$path_client_bindir/mysqladmin"); $exe_mysql= mtr_exe_exists("$path_client_bindir/mysql"); + $exe_mysql_plugin= mtr_exe_exists("$path_client_bindir/mysql_plugin"); + + $exe_mysql_embedded= mtr_exe_maybe_exists("$basedir/libmysqld/examples/mysql_embedded"); if ( ! $opt_skip_ndbcluster ) { @@ -2243,8 +2274,10 @@ sub find_plugin($$) my $lib_plugin= mtr_file_exists(vs_config_dirs($location,$plugin_filename), "$basedir/lib/plugin/".$plugin_filename, + "$basedir/lib64/plugin/".$plugin_filename, "$basedir/$location/.libs/".$plugin_filename, "$basedir/lib/mysql/plugin/".$plugin_filename, + "$basedir/lib64/mysql/plugin/".$plugin_filename, ); return $lib_plugin; } @@ -2354,12 +2387,6 @@ sub environment_setup { $ENV{'DEFAULT_MASTER_PORT'}= $mysqld_variables{'port'}; $ENV{'MYSQL_TMP_DIR'}= $opt_tmpdir; $ENV{'MYSQLTEST_VARDIR'}= $opt_vardir; - # Used for guessing default plugin dir, we can't really know for sure - $ENV{'MYSQL_LIBDIR'}= "$basedir/lib"; - # Override if this does not exist, but lib64 does (best effort) - if (! -d "$basedir/lib" && -d "$basedir/lib64") { - $ENV{'MYSQL_LIBDIR'}= "$basedir/lib64"; - } $ENV{'MYSQL_BINDIR'}= "$bindir"; $ENV{'MYSQL_SHAREDIR'}= $path_language; $ENV{'MYSQL_CHARSETSDIR'}= $path_charsetsdir; @@ -2427,6 +2454,14 @@ sub environment_setup { $ENV{'MYSQLADMIN'}= client_arguments("mysqladmin"); $ENV{'MYSQL_CLIENT_TEST'}= mysql_client_test_arguments(); $ENV{'EXE_MYSQL'}= $exe_mysql; + $ENV{'MYSQL_PLUGIN'}= $exe_mysql_plugin; + $ENV{'MYSQL_EMBEDDED'}= $exe_mysql_embedded; + + my $exe_mysqld= find_mysqld($basedir); + $ENV{'MYSQLD'}= $exe_mysqld; + my $extra_opts= join (" ", @opt_extra_mysqld_opt); + $ENV{'MYSQLD_CMD'}= "$exe_mysqld --defaults-group-suffix=.1 ". + "--defaults-file=$path_config_file $extra_opts"; # ---------------------------------------------------- # bug25714 executable may _not_ exist in @@ -3127,7 +3162,6 @@ sub mysql_server_start($) { } if (-d $datadir ) { - preserve_error_log($mysqld); mtr_verbose(" - removing '$datadir'"); rmtree($datadir); } @@ -3156,7 +3190,6 @@ sub mysql_server_start($) { unless -d $datadir; } - restore_error_log($mysqld); # Create the servers tmpdir my $tmpdir= $mysqld->value('tmpdir'); @@ -3475,6 +3508,19 @@ sub mysql_install_db { # ---------------------------------------------------------------------- my $bootstrap_sql_file= "$opt_vardir/tmp/bootstrap.sql"; + if ($opt_boot_gdb) { + gdb_arguments(\$args, \$exe_mysqld_bootstrap, $mysqld->name(), + $bootstrap_sql_file); + } + if ($opt_boot_dbx) { + dbx_arguments(\$args, \$exe_mysqld_bootstrap, $mysqld->name(), + $bootstrap_sql_file); + } + if ($opt_boot_ddd) { + ddd_arguments(\$args, \$exe_mysqld_bootstrap, $mysqld->name(), + $bootstrap_sql_file); + } + my $path_sql= my_find_file($install_basedir, ["mysql", "sql/share", "share/mariadb", "share/mysql", "share", "scripts"], @@ -4489,30 +4535,6 @@ sub run_testcase ($$) { } -# We want to preserve the error log between server restarts, as it may contain -# valuable debugging information even if there is no test failure recorded. -sub _preserve_error_log_names { - my ($mysqld)= @_; - my $error_log_file= $mysqld->if_exist('#log-error'); - return (undef, undef) unless $error_log_file; - my $error_log_dir= dirname($error_log_file); - my $save_name= $error_log_dir ."/../". $mysqld->name() .".error.log"; - return ($error_log_file, $save_name); -} - -sub preserve_error_log { - my ($mysqld)= @_; - my ($error_log_file, $save_name)= _preserve_error_log_names($mysqld); - rename($error_log_file, $save_name) if $save_name; - # Ignore any errors, as it's just a best-effort to keep the log if possible. -} - -sub restore_error_log { - my ($mysqld)= @_; - my ($error_log_file, $save_name)= _preserve_error_log_names($mysqld); - rename($save_name, $error_log_file) if $save_name; -} - # Keep track of last position in mysqld error log where we scanned for # warnings, so we can attribute any warnings found to the correct test # suite or server restart. @@ -4577,6 +4599,11 @@ sub extract_server_log ($$) { else { push(@lines, $line); + if (scalar(@lines) > 1000000) { + $Ferr = undef; + mtr_warning("Too much log from test, bailing out from extracting"); + return (); + } } } else @@ -4723,6 +4750,8 @@ sub extract_warning_lines ($$) { qr| entry '.*' ignored in --skip-name-resolve mode|, qr|mysqld got signal 6|, qr|Error while setting value 'pool-of-threads' to 'thread_handling'|, + qr|Access denied for user|, + qr|Aborted connection|, qr|table.*is full|, ); @@ -5035,7 +5064,6 @@ sub clean_datadir { for (all_servers()) { - preserve_error_log($_); # or at least, try to my $dir= "$opt_vardir/".$_->{name}; mtr_verbose(" - removing '$dir'"); rmtree($dir); @@ -5906,16 +5934,19 @@ sub gdb_arguments { my $args= shift; my $exe= shift; my $type= shift; + my $input= shift; - # Write $args to gdb init file - my $str= join " ", map { s/"/\\"/g; "\"$_\""; } @$$args; my $gdb_init_file= "$opt_vardir/tmp/gdbinit.$type"; # Remove the old gdbinit file unlink($gdb_init_file); + # Put $args into a single string + my $str= join(" ", @$$args); + $input = $input ? "< $input" : ""; + # write init file for mysqld or client - mtr_tofile($gdb_init_file, "set args $str\n"); + mtr_tofile($gdb_init_file, "set args $str $input\n"); if ( $opt_manual_gdb ) { @@ -5954,16 +5985,19 @@ sub ddd_arguments { my $args= shift; my $exe= shift; my $type= shift; + my $input= shift; - # Write $args to ddd init file - my $str= join " ", map { s/"/\\"/g; "\"$_\""; } @$$args; my $gdb_init_file= "$opt_vardir/tmp/gdbinit.$type"; # Remove the old gdbinit file unlink($gdb_init_file); + # Put $args into a single string + my $str= join(" ", @$$args); + $input = $input ? "< $input" : ""; + # write init file for mysqld or client - mtr_tofile($gdb_init_file, "file $$exe\nset args $str\n"); + mtr_tofile($gdb_init_file, "file $$exe\nset args $str $input\n"); if ( $opt_manual_ddd ) { @@ -5999,14 +6033,16 @@ sub dbx_arguments { my $args= shift; my $exe= shift; my $type= shift; + my $input= shift; # Put $args into a single string my $str= join " ", @$$args; + my $runline= $input ? "run $str < $input" : "run $str"; if ( $opt_manual_dbx ) { print "\nTo start dbx for $type, type in another window:\n"; print "cd $glob_mysql_test_dir; dbx -c \"stop in main; " . - "run $str\" $$exe\n"; + "$runline\" $$exe\n"; # Indicate the exe should not be started $$exe= undef; @@ -6025,7 +6061,7 @@ sub dbx_arguments { mtr_add_arg($$args, "dbx"); mtr_add_arg($$args, "-c"); - mtr_add_arg($$args, "stop in main; run $str"); + mtr_add_arg($$args, "stop in main; $runline"); mtr_add_arg($$args, "$$exe"); $$exe= "xterm"; @@ -6319,11 +6355,15 @@ Options to run test on running server Options for debugging the product + boot-dbx Start bootstrap server in dbx + boot-ddd Start bootstrap server in ddd + boot-gdb Start bootstrap server in gdb + client-dbx Start mysqltest client in dbx client-ddd Start mysqltest client in ddd client-debugger=NAME Start mysqltest in the selected debugger client-gdb Start mysqltest client in gdb - client-dbx Start mysqltest client in dbx - ddd Start mysqld in ddd + dbx Start the mysqld(s) in dbx + ddd Start the mysqld(s) in ddd debug Dump trace output for all servers and client programs debug-common Same as debug, but sets 'd' debug flags to "query,info,error,enter,exit" @@ -6331,7 +6371,6 @@ Options for debugging the product tracing debugger=NAME Start mysqld in the selected debugger gdb Start the mysqld(s) in gdb - dbx Start the mysqld(s) in dbx manual-debug Let user manually start mysqld in debugger, before running test(s) manual-gdb Let user manually start mysqld in gdb, before running @@ -6446,6 +6485,8 @@ Misc options engine to InnoDB. report-times Report how much time has been spent on different phases of test execution. + stress=ARGS Run stress test, providing options to + mysql-stress-test.pl. Options are separated by comma. Some options that control enabling a feature for normal test runs, can be turned off by prepending 'no' to the option, e.g. --notimer. diff --git a/mysql-test/r/alter_table.result b/mysql-test/r/alter_table.result index 723855867f3..b62da05b4a2 100644 --- a/mysql-test/r/alter_table.result +++ b/mysql-test/r/alter_table.result @@ -1252,6 +1252,35 @@ DROP TABLE t1; CREATE TABLE t1 (a TEXT, id INT, b INT); ALTER TABLE t1 DROP COLUMN a, ADD COLUMN c TEXT FIRST; DROP TABLE t1; +# +# Test for bug #12652385 - "61493: REORDERING COLUMNS TO POSITION +# FIRST CAN CAUSE DATA TO BE CORRUPTED". +# +drop table if exists t1; +# Use MyISAM engine as the fact that InnoDB doesn't support +# in-place ALTER TABLE in cases when columns are being renamed +# hides some bugs. +create table t1 (i int, j int) engine=myisam; +insert into t1 value (1, 2); +# First, test for original problem described in the bug report. +select * from t1; +i j +1 2 +# Change of column order by the below ALTER TABLE statement should +# affect both column names and column contents. +alter table t1 modify column j int first; +select * from t1; +j i +2 1 +# Now test for similar problem with the same root. +# The below ALTER TABLE should change not only the name but +# also the value for the last column of the table. +alter table t1 drop column i, add column k int default 0; +select * from t1; +j k +2 0 +# Clean-up. +drop table t1; End of 5.1 tests CREATE TABLE t1(c CHAR(10), i INT UNSIGNED AUTO_INCREMENT NOT NULL PRIMARY KEY); diff --git a/mysql-test/r/auth_rpl.result b/mysql-test/r/auth_rpl.result new file mode 100644 index 00000000000..70626b02b2b --- /dev/null +++ b/mysql-test/r/auth_rpl.result @@ -0,0 +1,24 @@ +include/master-slave.inc +[connection master] +[connection slave] +include/stop_slave.inc +[connection master] +CREATE USER 'plug_user' IDENTIFIED WITH 'test_plugin_server' AS 'plug_user'; +GRANT REPLICATION SLAVE ON *.* TO plug_user; +FLUSH PRIVILEGES; +[connection slave] +CHANGE MASTER TO +MASTER_USER= 'plug_user', +MASTER_PASSWORD= 'plug_user'; +include/start_slave.inc +# Slave in-sync with master now. +SELECT user, plugin, authentication_string FROM mysql.user WHERE user LIKE 'plug_user'; +user plugin authentication_string +plug_user test_plugin_server plug_user +# Cleanup (on slave). +include/stop_slave.inc +CHANGE MASTER TO MASTER_USER='root'; +DROP USER 'plug_user'; +# Cleanup (on master). +DROP USER 'plug_user'; +include/rpl_end.inc diff --git a/mysql-test/r/case.result b/mysql-test/r/case.result index 40d900a0389..a95975f1097 100644 --- a/mysql-test/r/case.result +++ b/mysql-test/r/case.result @@ -220,3 +220,10 @@ a d 3 11120436154190595086 drop table t1, t2; End of 5.0 tests +create table t1 (f1 time); +insert t1 values ('00:00:00'),('00:01:00'); +select case t1.f1 when '00:00:00' then 1 end from t1; +case t1.f1 when '00:00:00' then 1 end +1 +NULL +drop table t1; diff --git a/mysql-test/r/cast.result b/mysql-test/r/cast.result index 5e6078c5f39..918122385e9 100644 --- a/mysql-test/r/cast.result +++ b/mysql-test/r/cast.result @@ -105,9 +105,9 @@ cast("2011-02-03 10:11:12.123456" as datetime(6)) select cast("2011-02-03 10:11:12" as datetime(6)); cast("2011-02-03 10:11:12" as datetime(6)) 2011-02-03 10:11:12.000000 -select cast(cast(20010203101112.1 as double) as datetime(1)); -cast(cast(20010203101112.1 as double) as datetime(1)) -2001-02-03 10:11:12.1 +select cast(cast(20010203101112.5 as double) as datetime(1)); +cast(cast(20010203101112.5 as double) as datetime(1)) +2001-02-03 10:11:12.5 select cast(cast(010203101112.12 as double) as datetime(2)); cast(cast(010203101112.12 as double) as datetime(2)) 0001-02-03 10:11:12.12 @@ -750,3 +750,8 @@ select cast(f1 as unsigned), cast(f2 as unsigned), cast(f3 as unsigned) from t1; cast(f1 as unsigned) cast(f2 as unsigned) cast(f3 as unsigned) 112233 20111213 20111213112233 drop table t1; +SELECT CAST(TIME('10:20:30') AS DATE) + INTERVAL 1 DAY; +CAST(TIME('10:20:30') AS DATE) + INTERVAL 1 DAY +NULL +Warnings: +Warning 1292 Truncated incorrect date value: '0000-00-00' diff --git a/mysql-test/r/comments.result b/mysql-test/r/comments.result index 99fab38d7a7..77c520b0c64 100644 --- a/mysql-test/r/comments.result +++ b/mysql-test/r/comments.result @@ -26,6 +26,20 @@ select 1 # The rest of the row will be ignored 1 1 /* line with only comment */; +select 1 /*M! +1 */; +1 +1 +2 +select 1 /*M!50000 +1 */; +1 +1 +2 +select 1 /*M!50300 +1 */; +1 +1 +2 +select 2 /*M!99999 +1 */; +2 +2 +select 2 /*M!0000 +1 */; +ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '0000 +1 */' at line 1 select 1/*!2*/; ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '2*/' at line 1 select 1/*!000002*/; diff --git a/mysql-test/r/commit_1innodb.result b/mysql-test/r/commit_1innodb.result index fb1552b6c28..3e3d75f66e4 100644 --- a/mysql-test/r/commit_1innodb.result +++ b/mysql-test/r/commit_1innodb.result @@ -549,11 +549,9 @@ SUCCESS # 15. Read-write statement: UPDATE IGNORE, change 0 rows. # update ignore t1 set a=2 where a=1; -call p_verify_status_increment(2, 2, 1, 0); SUCCESS commit; -call p_verify_status_increment(2, 2, 1, 0); SUCCESS # diff --git a/mysql-test/r/compare.result b/mysql-test/r/compare.result index 010c3becdbb..6ee01349022 100644 --- a/mysql-test/r/compare.result +++ b/mysql-test/r/compare.result @@ -88,7 +88,7 @@ id select_type table type possible_keys key key_len ref rows filtered Extra Warnings: Note 1276 Field or reference 'test.t2.a' of SELECT #2 was resolved in SELECT #1 Note 1276 Field or reference 'test.t2.a' of SELECT #2 was resolved in SELECT #1 -Note 1003 select `test`.`t2`.`a` AS `a`,(select count(0) from `test`.`t1` where ((`test`.`t1`.`b` = `test`.`t2`.`a`) and (concat(`test`.`t1`.`b`,`test`.`t1`.`c`) = concat('0',`test`.`t2`.`a`,'01')))) AS `x` from `test`.`t2` order by `test`.`t2`.`a` +Note 1003 select `test`.`t2`.`a` AS `a`,<expr_cache><`test`.`t2`.`a`>((select count(0) from `test`.`t1` where ((`test`.`t1`.`b` = `test`.`t2`.`a`) and (concat(`test`.`t1`.`b`,`test`.`t1`.`c`) = concat('0',`test`.`t2`.`a`,'01'))))) AS `x` from `test`.`t2` order by `test`.`t2`.`a` DROP TABLE t1,t2; CREATE TABLE t1 (a TIMESTAMP); INSERT INTO t1 VALUES (NOW()),(NOW()),(NOW()); diff --git a/mysql-test/r/ctype_errors.result b/mysql-test/r/ctype_errors.result index d8218e40e6f..b3632454eb1 100644 --- a/mysql-test/r/ctype_errors.result +++ b/mysql-test/r/ctype_errors.result @@ -29,4 +29,14 @@ SET lc_messages=cs_CZ; SET NAMES UTF8; USE nonexistant; ERROR 42000: Nezn-Bámá databáze 'nonexistant' -End of 5.4 tests +# +# Bug#12736295: Buffer overflow for variable converted_err +# with non-latin1 server error message +# +# Connection con1 +SET lc_messages=ru_RU; +SET NAMES latin1; +SELECT '01234567890123456789012345678901234\'; +ERROR 42000: \0423 \0432\0430\0441 \043E\0448\0438\0431\043A\0430 \0432 \0437\0430\043F\0440\043E\0441\0435. \0418\0437\0443\0447\0438\0442\0435 \0434\043E\043A\0443\043C\0435\043D\0442\0430\0446\0438\044E \043F\043E \0438\0441\043F\043E\043B\044C\0437\0443\0435\043C\043E\0439 \0432\0435\0440\0441\0438\0438 MySQL \043D\0430 \043F\0440\0435\0434\043C\0435\0442 \043A\043E\0440\0440\0435\043A\0442\043D\043E\0433\043E \0441\0438\043D\0442\0430\043A\0441\0438\0441\0430 \043E\043A\043E\043B\043E ''012345678901234567890123456 +# Connection default +End of 5.5 tests diff --git a/mysql-test/r/ctype_utf16.result b/mysql-test/r/ctype_utf16.result index 8b63da168ce..a9878b25c29 100644 --- a/mysql-test/r/ctype_utf16.result +++ b/mysql-test/r/ctype_utf16.result @@ -1118,5 +1118,14 @@ CASE s1 WHEN 'a' THEN 'b' ELSE 'c' END b DROP TABLE t1; # +# Bug#12340997 +# DATE_ADD/DATE_SUB WITH INTERVAL CRASHES IN GET_INTERVAL_VALUE() +# +SELECT space(date_add(101, INTERVAL CHAR('1' USING utf16) hour_second)); +space(date_add(101, INTERVAL CHAR('1' USING utf16) hour_second)) +NULL +Warnings: +Warning 1301 Result of repeat() was larger than max_allowed_packet (1048576) - truncated +# # End of 5.5 tests # diff --git a/mysql-test/r/ctype_utf32_uca.result b/mysql-test/r/ctype_utf32_uca.result index fd5a4199217..a9f056b2e44 100644 --- a/mysql-test/r/ctype_utf32_uca.result +++ b/mysql-test/r/ctype_utf32_uca.result @@ -2415,5 +2415,25 @@ HEX(s1) 00000061 DROP TABLE t1; # +# Bug #12319710 : INVALID MEMORY READ AND/OR CRASH IN +# MY_UCA_CHARCMP WITH UTF32 +# +SET collation_connection=utf32_unicode_ci; +CREATE TABLE t1 (a TEXT CHARACTER SET utf32 COLLATE utf32_turkish_ci NOT NULL); +INSERT INTO t1 VALUES ('a'), ('b'); +CREATE TABLE t2 (b VARBINARY(5) NOT NULL); +#insert chars outside of BMP +INSERT INTO t2 VALUEs (0x082837),(0x082837); +#test for read-out-of-bounds with non-BMP chars as a LIKE pattern +SELECT * FROM t1,t2 WHERE a LIKE b; +a b +#test the original statement +SELECT 1 FROM t1 AS t1_0 NATURAL LEFT OUTER JOIN t2 AS t2_0 +RIGHT JOIN t1 AS t1_1 ON t1_0.a LIKE t2_0.b; +1 +1 +1 +DROP TABLE t1,t2; +# # End of 5.5 tests # diff --git a/mysql-test/r/derived.result b/mysql-test/r/derived.result index 575fdbe04b4..0fc7804297c 100644 --- a/mysql-test/r/derived.result +++ b/mysql-test/r/derived.result @@ -190,13 +190,13 @@ pla_id test explain SELECT STRAIGHT_JOIN d.pla_id, m2.mat_id FROM t1 m2 INNER JOIN (SELECT mp.pla_id, MIN(m1.matintnum) AS matintnum FROM t2 mp INNER JOIN t1 m1 ON mp.mat_id=m1.mat_id GROUP BY mp.pla_id) d ON d.matintnum=m2.matintnum; id select_type table type possible_keys key key_len ref rows Extra 1 PRIMARY m2 ALL NULL NULL NULL NULL 9 -1 PRIMARY <derived2> ALL NULL $hj 7 test.m2.matintnum 9 Using where +1 PRIMARY <derived2> ALL NULL NULL NULL NULL 9 Using where 2 DERIVED mp ALL NULL NULL NULL NULL 9 Using temporary; Using filesort 2 DERIVED m1 eq_ref PRIMARY PRIMARY 3 test.mp.mat_id 1 explain SELECT STRAIGHT_JOIN d.pla_id, m2.test FROM t1 m2 INNER JOIN (SELECT mp.pla_id, MIN(m1.matintnum) AS matintnum FROM t2 mp INNER JOIN t1 m1 ON mp.mat_id=m1.mat_id GROUP BY mp.pla_id) d ON d.matintnum=m2.matintnum; id select_type table type possible_keys key key_len ref rows Extra 1 PRIMARY m2 ALL NULL NULL NULL NULL 9 -1 PRIMARY <derived2> ALL NULL $hj 7 test.m2.matintnum 9 Using where +1 PRIMARY <derived2> ALL NULL NULL NULL NULL 9 Using where 2 DERIVED mp ALL NULL NULL NULL NULL 9 Using temporary; Using filesort 2 DERIVED m1 eq_ref PRIMARY PRIMARY 3 test.mp.mat_id 1 drop table t1,t2; diff --git a/mysql-test/r/derived_view.result b/mysql-test/r/derived_view.result index 37157162e61..30c4d330e64 100644 --- a/mysql-test/r/derived_view.result +++ b/mysql-test/r/derived_view.result @@ -714,8 +714,8 @@ SELECT t.a FROM t1 LEFT JOIN GROUP BY t.a; id select_type table type possible_keys key key_len ref rows filtered Extra 1 SIMPLE t1 ALL NULL NULL NULL NULL 2 100.00 Using temporary; Using filesort -1 SIMPLE t3 ALL NULL NULL NULL NULL 2 100.00 Using where 1 SIMPLE t2 ALL NULL NULL NULL NULL 2 100.00 Using where +1 SIMPLE t3 ALL NULL NULL NULL NULL 2 100.00 Using where Warnings: Note 1003 select `test`.`t2`.`a` AS `a` from `test`.`t1` left join (`test`.`t2` join `test`.`t3`) on(((`test`.`t2`.`a` >= 1) and (`test`.`t3`.`b` > 5))) where 1 group by `test`.`t2`.`a` SELECT t.a FROM t1 LEFT JOIN @@ -730,8 +730,8 @@ SELECT t.a FROM t1 LEFT JOIN GROUP BY t.a; id select_type table type possible_keys key key_len ref rows filtered Extra 1 SIMPLE t1 ALL NULL NULL NULL NULL 2 100.00 Using temporary; Using filesort -1 SIMPLE t3 ALL NULL NULL NULL NULL 2 100.00 Using where 1 SIMPLE t2 ALL NULL NULL NULL NULL 2 100.00 Using where +1 SIMPLE t3 ALL NULL NULL NULL NULL 2 100.00 Using where Warnings: Note 1003 select `test`.`t2`.`a` AS `a` from `test`.`t1` left join (`test`.`t2` join `test`.`t3`) on(((`test`.`t2`.`a` >= 1) and (`test`.`t3`.`b` > 5))) where 1 group by `test`.`t2`.`a` SELECT t.a FROM t1 LEFT JOIN @@ -749,15 +749,17 @@ INSERT INTO t1 VALUES ('c'); CREATE TABLE t2 (a varchar(1) , KEY (a)) ; INSERT INTO t2 VALUES ('c'), (NULL), ('r'); CREATE TABLE t3 (a varchar(1), b varchar(1)); -INSERT INTO t3 VALUES ('e', 'c'), ('c', 'c'), ('c', 'r'); +INSERT INTO t3 VALUES +('e', 'c'), ('c', 'c'), ('c', 'r'), ('g', 'a'), ('b', 'x'), ('b', 'y'), +('h', 'w'), ('d', 'z'), ('k', 'v'), ('j', 's'), ('m', 'p'), ('l', 'q'); CREATE VIEW v1 AS SELECT a, MIN(b) AS b FROM t3 GROUP BY a; EXPLAIN SELECT * FROM t1, t2, v1 WHERE t2.a=t1.a AND t2.a=v1.a AND t2.a=v1.b; id select_type table type possible_keys key key_len ref rows Extra 1 PRIMARY t1 system NULL NULL NULL NULL 1 1 PRIMARY t2 ref a a 4 const 1 Using index -1 PRIMARY <derived2> ref key1 key1 10 test.t1.a,test.t1.a 2 -2 DERIVED t3 ALL NULL NULL NULL NULL 3 Using temporary; Using filesort +1 PRIMARY <derived2> ref key0 key0 10 const,const 1 +2 DERIVED t3 ALL NULL NULL NULL NULL 12 Using temporary; Using filesort SELECT * FROM t1, t2, v1 WHERE t2.a=t1.a AND t2.a=v1.a AND t2.a=v1.b; a a a b c c c c @@ -789,11 +791,11 @@ SELECT * FROM t3 WHERE t3.a IN (SELECT v1.a FROM v1, t2 WHERE t2.a = v1.b); id select_type table type possible_keys key key_len ref rows filtered Extra 1 PRIMARY t3 ALL NULL NULL NULL NULL 4 100.00 Using where -2 DEPENDENT SUBQUERY <derived3> ref key0 key0 5 func 2 100.00 +2 DEPENDENT SUBQUERY <derived3> ref key1 key1 5 func 2 100.00 2 DEPENDENT SUBQUERY t2 ALL NULL NULL NULL NULL 3 100.00 Using where; Using join buffer (flat, BNL join) 3 DERIVED t1 ALL NULL NULL NULL NULL 3 100.00 Using temporary; Using filesort Warnings: -Note 1003 select `test`.`t3`.`a` AS `a` from `test`.`t3` where <in_optimizer>(`test`.`t3`.`a`,<exists>(select `v1`.`a` from `test`.`v1` join `test`.`t2` where ((`test`.`t2`.`a` = `v1`.`b`) and (<cache>(`test`.`t3`.`a`) = `v1`.`a`)))) +Note 1003 select `test`.`t3`.`a` AS `a` from `test`.`t3` where <expr_cache><`test`.`t3`.`a`>(<in_optimizer>(`test`.`t3`.`a`,<exists>(select `v1`.`a` from `test`.`v1` join `test`.`t2` where ((`test`.`t2`.`a` = `v1`.`b`) and (<cache>(`test`.`t3`.`a`) = `v1`.`a`))))) SELECT * FROM t3 WHERE t3.a IN (SELECT v1.a FROM v1, t2 WHERE t2.a = v1.b); a @@ -997,10 +999,10 @@ SELECT * FROM t2 RIGHT JOIN (SELECT * FROM t1) AS t ON t.a != 0 WHERE t.a IN (SELECT b FROM t1); id select_type table type possible_keys key key_len ref rows filtered Extra 1 PRIMARY t1 system NULL NULL NULL NULL 1 100.00 +1 PRIMARY t1 system NULL NULL NULL NULL 1 100.00 1 PRIMARY t2 ALL NULL NULL NULL NULL 2 100.00 Using where -3 DEPENDENT SUBQUERY t1 system NULL NULL NULL NULL 1 100.00 Warnings: -Note 1003 select `test`.`t2`.`a` AS `a`,0 AS `a`,0 AS `b` from `test`.`t2` where <in_optimizer>(0,<exists>(select 0 from dual where (<cache>(0) = 0))) +Note 1003 select `test`.`t2`.`a` AS `a`,0 AS `a`,0 AS `b` from `test`.`t2` semi join (dual) where 1 SELECT * FROM t2 RIGHT JOIN v1 AS t ON t.a != 0 WHERE t.a IN (SELECT b FROM t1); a a b @@ -1010,10 +1012,10 @@ SELECT * FROM t2 RIGHT JOIN v1 AS t ON t.a != 0 WHERE t.a IN (SELECT b FROM t1); id select_type table type possible_keys key key_len ref rows filtered Extra 1 PRIMARY t1 system NULL NULL NULL NULL 1 100.00 +1 PRIMARY t1 system NULL NULL NULL NULL 1 100.00 1 PRIMARY t2 ALL NULL NULL NULL NULL 2 100.00 Using where -2 DEPENDENT SUBQUERY t1 system NULL NULL NULL NULL 1 100.00 Warnings: -Note 1003 select `test`.`t2`.`a` AS `a`,0 AS `a`,0 AS `b` from `test`.`t2` where <in_optimizer>(0,<exists>(select 0 from dual where (<cache>(0) = 0))) +Note 1003 select `test`.`t2`.`a` AS `a`,0 AS `a`,0 AS `b` from `test`.`t2` semi join (dual) where 1 DROP VIEW v1; DROP TABLE t1,t2; # @@ -1024,7 +1026,9 @@ INSERT INTO t1 VALUES (0); CREATE TABLE t2 (a varchar(32), b int, KEY (a)) ; INSERT INTO t2 VALUES ('j',28), ('c',29), ('i',26), ('c',29), ('k',27), -('j',28), ('c',29), ('i',25), ('d',26), ('k',27); +('j',28), ('c',29), ('i',25), ('d',26), ('k',27), +('n',28), ('d',29), ('m',26), ('e',29), ('p',27), +('w',28), ('x',29), ('y',25), ('z',26), ('s',27); CREATE TABLE t3 (a varchar(32)); INSERT INTO t3 VALUES ('j'), ('c'); CREATE VIEW v1 AS SELECT DISTINCT t2.b FROM t1,t2,t3 WHERE t3.a = t2.a; @@ -1085,7 +1089,7 @@ id select_type table type possible_keys key key_len ref rows filtered Extra 1 PRIMARY t3 system NULL NULL NULL NULL 1 100.00 2 DEPENDENT SUBQUERY NULL NULL NULL NULL NULL NULL NULL NULL No tables used Warnings: -Note 1003 select 6 AS `a`,5 AS `b` from `test`.`t3` where (not(<in_optimizer>((6,5),<exists>(select 7,5 having (trigcond(((<cache>(6) = 7) or isnull(7))) and trigcond(((<cache>(5) = 5) or isnull(5))) and trigcond(<is_not_null_test>(7)) and trigcond(<is_not_null_test>(5))))))) +Note 1003 select 6 AS `a`,5 AS `b` from `test`.`t3` where (not(<expr_cache><6,5>(<in_optimizer>((6,5),<exists>(select 7,5 having (trigcond(((<cache>(6) = 7) or isnull(7))) and trigcond(((<cache>(5) = 5) or isnull(5))) and trigcond(<is_not_null_test>(7)) and trigcond(<is_not_null_test>(5)))))))) SELECT t.a,t.b FROM t3 RIGHT JOIN ((SELECT * FROM t1) AS t, t2) ON t2.b != 0 WHERE (t.a,t.b) NOT IN (SELECT 7, 5); a b @@ -1094,12 +1098,12 @@ EXPLAIN EXTENDED SELECT t.a,t.b FROM t3 RIGHT JOIN ((SELECT * FROM t1) AS t, t2) ON t2.b != 0 WHERE (t.a,t.b) NOT IN (SELECT 7, 5); id select_type table type possible_keys key key_len ref rows filtered Extra -1 PRIMARY t2 system NULL NULL NULL NULL 1 100.00 1 PRIMARY t1 system NULL NULL NULL NULL 1 100.00 +1 PRIMARY t2 system NULL NULL NULL NULL 1 100.00 1 PRIMARY t3 system NULL NULL NULL NULL 1 100.00 3 DEPENDENT SUBQUERY NULL NULL NULL NULL NULL NULL NULL NULL No tables used Warnings: -Note 1003 select 6 AS `a`,5 AS `b` from `test`.`t3` where (not(<in_optimizer>((6,5),<exists>(select 7,5 having (trigcond(((<cache>(6) = 7) or isnull(7))) and trigcond(((<cache>(5) = 5) or isnull(5))) and trigcond(<is_not_null_test>(7)) and trigcond(<is_not_null_test>(5))))))) +Note 1003 select 6 AS `a`,5 AS `b` from `test`.`t3` where (not(<expr_cache><6,5>(<in_optimizer>((6,5),<exists>(select 7,5 having (trigcond(((<cache>(6) = 7) or isnull(7))) and trigcond(((<cache>(5) = 5) or isnull(5))) and trigcond(<is_not_null_test>(7)) and trigcond(<is_not_null_test>(5)))))))) SELECT t.a,t.b FROM t3 RIGHT JOIN (v1 AS t, t2) ON t2.b != 0 WHERE (t.a,t.b) NOT IN (SELECT 7, 5); a b @@ -1108,12 +1112,12 @@ EXPLAIN EXTENDED SELECT t.a,t.b FROM t3 RIGHT JOIN (v1 AS t, t2) ON t2.b != 0 WHERE (t.a,t.b) NOT IN (SELECT 7, 5); id select_type table type possible_keys key key_len ref rows filtered Extra -1 PRIMARY t2 system NULL NULL NULL NULL 1 100.00 1 PRIMARY t1 system NULL NULL NULL NULL 1 100.00 +1 PRIMARY t2 system NULL NULL NULL NULL 1 100.00 1 PRIMARY t3 system NULL NULL NULL NULL 1 100.00 2 DEPENDENT SUBQUERY NULL NULL NULL NULL NULL NULL NULL NULL No tables used Warnings: -Note 1003 select 6 AS `a`,5 AS `b` from `test`.`t3` where (not(<in_optimizer>((6,5),<exists>(select 7,5 having (trigcond(((<cache>(6) = 7) or isnull(7))) and trigcond(((<cache>(5) = 5) or isnull(5))) and trigcond(<is_not_null_test>(7)) and trigcond(<is_not_null_test>(5))))))) +Note 1003 select 6 AS `a`,5 AS `b` from `test`.`t3` where (not(<expr_cache><6,5>(<in_optimizer>((6,5),<exists>(select 7,5 having (trigcond(((<cache>(6) = 7) or isnull(7))) and trigcond(((<cache>(5) = 5) or isnull(5))) and trigcond(<is_not_null_test>(7)) and trigcond(<is_not_null_test>(5)))))))) DROP VIEW v1; DROP TABLE t1,t2,t3; # @@ -1153,7 +1157,7 @@ EXPLAIN SELECT a FROM t1 WHERE (a,b) IN (SELECT * FROM v1); id select_type table type possible_keys key key_len ref rows Extra 1 PRIMARY t1 ALL NULL NULL NULL NULL 2 Using where -2 DEPENDENT SUBQUERY <derived3> index_subquery key0 key0 10 func,func 2 Using where +1 PRIMARY <derived3> ref key0 key0 10 test.t1.a,test.t1.b 2 FirstMatch(t1) 3 DERIVED t2 ALL NULL NULL NULL NULL 6 Using temporary; Using filesort SELECT * FROM v2; a b @@ -1173,7 +1177,7 @@ EXPLAIN SELECT a FROM t1 WHERE (a,b) IN (SELECT * FROM v2); id select_type table type possible_keys key key_len ref rows Extra 1 PRIMARY t1 ALL NULL NULL NULL NULL 2 Using where -2 DEPENDENT SUBQUERY <derived3> index_subquery key0 key0 10 func,func 2 Using where +1 PRIMARY <derived3> ref key0 key0 10 test.t1.a,test.t1.b 2 FirstMatch(t1) 3 DERIVED t2 ALL NULL NULL NULL NULL 6 4 UNION t3 ALL NULL NULL NULL NULL 4 NULL UNION RESULT <union3,4> ALL NULL NULL NULL NULL NULL @@ -1272,7 +1276,7 @@ id select_type table type possible_keys key key_len ref rows filtered Extra 3 DEPENDENT SUBQUERY t3 ALL NULL NULL NULL NULL 2 100.00 Using where Warnings: Note 1276 Field or reference 't.a' of SELECT #3 was resolved in SELECT #1 -Note 1003 select `test`.`t1`.`a` AS `a` from `test`.`t1` where exists(select 28 from `test`.`t3` where ('j' < `test`.`t1`.`a`)) +Note 1003 select `test`.`t1`.`a` AS `a` from `test`.`t1` where <expr_cache><`test`.`t1`.`a`>(exists(select 28 from `test`.`t3` where ('j' < `test`.`t1`.`a`))) SELECT * FROM (SELECT * FROM t1) AS t WHERE EXISTS (SELECT t2.a FROM t3 RIGHT JOIN t2 ON (t3.a = t2.a) WHERE t2.b < t.a); @@ -1280,4 +1284,591 @@ a r p DROP TABLE t1,t2,t3; +# +# LP bug #824463: nested outer join using a merged view +# as an inner table +# +CREATE TABLE t1 (b int, a int) ; +CREATE TABLE t2 (a int) ; +INSERT INTO t2 VALUES (5), (6); +CREATE TABLE t3 (a int , c int) ; +INSERT INTO t3 VALUES (22,1), (23,-1); +CREATE TABLE t4 (a int); +CREATE TABLE t5 (d int) ; +INSERT INTO t5 VALUES (0), (7), (3), (5); +CREATE VIEW v2 AS SELECT * FROM t2; +CREATE VIEW v3 AS SELECT * FROM t3; +EXPLAIN EXTENDED +SELECT STRAIGHT_JOIN * +FROM ( t2 AS s2 +JOIN +( t3 AS s3 +LEFT JOIN +( t4 LEFT JOIN t3 ON t4.a != 0 ) +ON s3.a != 0) +ON s2.a != 0) +JOIN t5 ON s3.c != 0 AND t5.d = 0; +id select_type table type possible_keys key key_len ref rows filtered Extra +1 SIMPLE s2 ALL NULL NULL NULL NULL 2 100.00 Using where +1 SIMPLE s3 ALL NULL NULL NULL NULL 2 100.00 Using where; Using join buffer (flat, BNL join) +1 SIMPLE t4 ALL NULL NULL NULL NULL 0 0.00 Using where +1 SIMPLE t3 ALL NULL NULL NULL NULL 2 100.00 Using where +1 SIMPLE t5 ALL NULL NULL NULL NULL 4 100.00 Using where; Using join buffer (flat, BNL join) +Warnings: +Note 1003 select straight_join `test`.`s2`.`a` AS `a`,`test`.`s3`.`a` AS `a`,`test`.`s3`.`c` AS `c`,`test`.`t4`.`a` AS `a`,`test`.`t3`.`a` AS `a`,`test`.`t3`.`c` AS `c`,`test`.`t5`.`d` AS `d` from `test`.`t2` `s2` join `test`.`t3` `s3` left join (`test`.`t4` left join `test`.`t3` on((`test`.`t4`.`a` <> 0))) on((`test`.`s3`.`a` <> 0)) join `test`.`t5` where ((`test`.`t5`.`d` = 0) and (`test`.`s3`.`c` <> 0) and (`test`.`s2`.`a` <> 0)) +SELECT STRAIGHT_JOIN * +FROM ( t2 AS s2 +JOIN +( t3 AS s3 +LEFT JOIN +( t4 LEFT JOIN t3 ON t4.a != 0 ) +ON s3.a != 0) +ON s2.a != 0) +JOIN t5 ON s3.c != 0 AND t5.d = 0; +a a c a a c d +5 22 1 NULL NULL NULL 0 +6 22 1 NULL NULL NULL 0 +5 23 -1 NULL NULL NULL 0 +6 23 -1 NULL NULL NULL 0 +EXPLAIN EXTENDED +SELECT STRAIGHT_JOIN * +FROM t2 AS s2 , t5, +(t3 LEFT JOIN (t4 LEFT JOIN t3 AS s3 ON t4.a != 0) ON t3.a != 0) +WHERE s2.a != 0 AND t3.c != 0 AND t5.d = 0; +id select_type table type possible_keys key key_len ref rows filtered Extra +1 SIMPLE s2 ALL NULL NULL NULL NULL 2 100.00 Using where +1 SIMPLE t5 ALL NULL NULL NULL NULL 4 100.00 Using where; Using join buffer (flat, BNL join) +1 SIMPLE t3 ALL NULL NULL NULL NULL 2 100.00 Using where; Using join buffer (flat, BNL join) +1 SIMPLE t4 ALL NULL NULL NULL NULL 0 0.00 Using where +1 SIMPLE s3 ALL NULL NULL NULL NULL 2 100.00 Using where +Warnings: +Note 1003 select straight_join `test`.`s2`.`a` AS `a`,`test`.`t5`.`d` AS `d`,`test`.`t3`.`a` AS `a`,`test`.`t3`.`c` AS `c`,`test`.`t4`.`a` AS `a`,`test`.`s3`.`a` AS `a`,`test`.`s3`.`c` AS `c` from `test`.`t2` `s2` join `test`.`t5` join `test`.`t3` left join (`test`.`t4` left join `test`.`t3` `s3` on((`test`.`t4`.`a` <> 0))) on((`test`.`t3`.`a` <> 0)) where ((`test`.`t5`.`d` = 0) and (`test`.`s2`.`a` <> 0) and (`test`.`t3`.`c` <> 0)) +SELECT STRAIGHT_JOIN * +FROM t2 AS s2 , t5, +(t3 LEFT JOIN (t4 LEFT JOIN t3 AS s3 ON t4.a != 0) ON t3.a != 0) +WHERE s2.a != 0 AND t3.c != 0 AND t5.d = 0; +a d a c a a c +5 0 22 1 NULL NULL NULL +6 0 22 1 NULL NULL NULL +5 0 23 -1 NULL NULL NULL +6 0 23 -1 NULL NULL NULL +EXPLAIN EXTENDED +SELECT STRAIGHT_JOIN * +FROM v2 AS s2 , t5, +(t3 LEFT JOIN (t4 LEFT JOIN v3 AS s3 ON t4.a != 0) ON t3.a != 0) +WHERE s2.a != 0 AND t3.c != 0 AND t5.d = 0; +id select_type table type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 ALL NULL NULL NULL NULL 2 100.00 Using where +1 SIMPLE t5 ALL NULL NULL NULL NULL 4 100.00 Using where; Using join buffer (flat, BNL join) +1 SIMPLE t3 ALL NULL NULL NULL NULL 2 100.00 Using where; Using join buffer (flat, BNL join) +1 SIMPLE t4 ALL NULL NULL NULL NULL 0 0.00 Using where +1 SIMPLE t3 ALL NULL NULL NULL NULL 2 100.00 Using where +Warnings: +Note 1003 select straight_join `test`.`t2`.`a` AS `a`,`test`.`t5`.`d` AS `d`,`test`.`t3`.`a` AS `a`,`test`.`t3`.`c` AS `c`,`test`.`t4`.`a` AS `a`,`test`.`t3`.`a` AS `a`,`test`.`t3`.`c` AS `c` from `test`.`t2` join `test`.`t5` join `test`.`t3` left join (`test`.`t4` left join (`test`.`t3`) on((`test`.`t4`.`a` <> 0))) on((`test`.`t3`.`a` <> 0)) where ((`test`.`t5`.`d` = 0) and (`test`.`t2`.`a` <> 0) and (`test`.`t3`.`c` <> 0)) +SELECT STRAIGHT_JOIN * +FROM v2 AS s2 , t5, +(t3 LEFT JOIN (t4 LEFT JOIN v3 AS s3 ON t4.a != 0) ON t3.a != 0) +WHERE s2.a != 0 AND t3.c != 0 AND t5.d = 0; +a d a c a a c +5 0 22 1 NULL NULL NULL +6 0 22 1 NULL NULL NULL +5 0 23 -1 NULL NULL NULL +6 0 23 -1 NULL NULL NULL +SELECT STRAIGHT_JOIN * +FROM ( ( t2 AS s2 +LEFT JOIN +( t3 AS s3 +LEFT JOIN +( t4 AS s4 JOIN t3 ON s4.a != 0) +ON s3.a != 0 ) +ON s2.a != 0) +LEFT JOIN +t1 AS s1 +ON s1.a != 0) +JOIN t5 ON s3.c != 0; +a a c a a c b a d +5 22 1 NULL NULL NULL NULL NULL 0 +6 22 1 NULL NULL NULL NULL NULL 0 +5 23 -1 NULL NULL NULL NULL NULL 0 +6 23 -1 NULL NULL NULL NULL NULL 0 +5 22 1 NULL NULL NULL NULL NULL 7 +6 22 1 NULL NULL NULL NULL NULL 7 +5 23 -1 NULL NULL NULL NULL NULL 7 +6 23 -1 NULL NULL NULL NULL NULL 7 +5 22 1 NULL NULL NULL NULL NULL 3 +6 22 1 NULL NULL NULL NULL NULL 3 +5 23 -1 NULL NULL NULL NULL NULL 3 +6 23 -1 NULL NULL NULL NULL NULL 3 +5 22 1 NULL NULL NULL NULL NULL 5 +6 22 1 NULL NULL NULL NULL NULL 5 +5 23 -1 NULL NULL NULL NULL NULL 5 +6 23 -1 NULL NULL NULL NULL NULL 5 +SELECT STRAIGHT_JOIN * +FROM ( ( v2 AS s2 +LEFT JOIN +( v3 AS s3 +LEFT JOIN +( t4 AS s4 JOIN v3 ON s4.a != 0) +ON s3.a != 0 ) +ON s2.a != 0) +LEFT JOIN +t1 AS s1 +ON s1.a != 0) +JOIN t5 ON s3.c != 0; +a a c a a c b a d +5 22 1 NULL NULL NULL NULL NULL 0 +6 22 1 NULL NULL NULL NULL NULL 0 +5 23 -1 NULL NULL NULL NULL NULL 0 +6 23 -1 NULL NULL NULL NULL NULL 0 +5 22 1 NULL NULL NULL NULL NULL 7 +6 22 1 NULL NULL NULL NULL NULL 7 +5 23 -1 NULL NULL NULL NULL NULL 7 +6 23 -1 NULL NULL NULL NULL NULL 7 +5 22 1 NULL NULL NULL NULL NULL 3 +6 22 1 NULL NULL NULL NULL NULL 3 +5 23 -1 NULL NULL NULL NULL NULL 3 +6 23 -1 NULL NULL NULL NULL NULL 3 +5 22 1 NULL NULL NULL NULL NULL 5 +6 22 1 NULL NULL NULL NULL NULL 5 +5 23 -1 NULL NULL NULL NULL NULL 5 +6 23 -1 NULL NULL NULL NULL NULL 5 +DROP VIEW v2,v3; +DROP TABLE t1,t2,t3,t4,t5; +# +# LP bug #872735: derived used in a NOT IN subquery +# +CREATE TABLE t1 (b int NOT NULL); +INSERT INTO t1 VALUES (9), (7); +CREATE TABLE t2 (a int NOT NULL) ; +INSERT INTO t2 VALUES (1), (2); +CREATE TABLE t3 ( +a int NOT NULL , c int NOT NULL, d varchar(1) NOT NULL, +KEY (c,a) , PRIMARY KEY (a) +); +INSERT INTO t3 VALUES +(14,4,'a'), (15,7,'b'), (16,4,'c'), (17,1,'d'), (18,9,'e'), +(19,4,'f'), (20,8,'g'); +SET SESSION optimizer_switch='derived_merge=on,subquery_cache=off'; +# The following two EXPLAINs must return the same execution plan +EXPLAIN +SELECT * FROM t1 , t2 +WHERE (t2.a ,t1.b) NOT IN (SELECT DISTINCT c,a FROM t3 t); +id select_type table type possible_keys key key_len ref rows Extra +1 PRIMARY t1 ALL NULL NULL NULL NULL 2 +1 PRIMARY t2 ALL NULL NULL NULL NULL 2 Using where; Using join buffer (flat, BNL join) +2 DEPENDENT SUBQUERY t ref PRIMARY,c c 4 func 2 Using where; Using index +EXPLAIN +SELECT * FROM t1 , t2 +WHERE (t2.a ,t1.b) NOT IN (SELECT DISTINCT c,a FROM (SELECT * FROM t3) t); +id select_type table type possible_keys key key_len ref rows Extra +1 PRIMARY t1 ALL NULL NULL NULL NULL 2 +1 PRIMARY t2 ALL NULL NULL NULL NULL 2 Using where; Using join buffer (flat, BNL join) +2 DEPENDENT SUBQUERY t3 ref PRIMARY,c c 4 func 2 Using where; Using index +SELECT * FROM t1 , t2 +WHERE (t2.a ,t1.b) NOT IN (SELECT DISTINCT c,a FROM (SELECT * FROM t3) t); +b a +9 1 +7 1 +9 2 +7 2 +DROP TABLE t1,t2,t3; +# +# LP bug #874006: materialized view used in IN subquery +# +CREATE TABLE t3 (a int NOT NULL, b varchar(1), c varchar(1)); +INSERT INTO t3 VALUES (19,NULL,NULL), (20,'r','r'); +CREATE TABLE t1 (a int, b varchar(1) , c varchar(1)); +INSERT INTO t1 VALUES (1,NULL,NULL), (5,'r','r'), (7,'y','y'); +CREATE TABLE t2 (a int NOT NULL , b int, c varchar(1)); +INSERT INTO t2 VALUES (4,3,'r'); +CREATE ALGORITHM=TEMPTABLE VIEW v1 AS SELECT * FROM t1; +SET SESSION optimizer_switch='derived_with_keys=off'; +EXPLAIN +SELECT * FROM t3 +WHERE t3.b IN (SELECT v1.b FROM v1, t2 +WHERE t2.c = v1.c AND t2.c = v1.b AND v1.b = t3.c); +id select_type table type possible_keys key key_len ref rows Extra +1 PRIMARY t2 system NULL NULL NULL NULL 1 +1 PRIMARY t3 ALL NULL NULL NULL NULL 2 Using where; Start temporary +1 PRIMARY <derived3> ALL NULL NULL NULL NULL 3 Using where; End temporary +3 DERIVED t1 ALL NULL NULL NULL NULL 3 +SELECT * FROM t3 +WHERE t3.b IN (SELECT v1.b FROM v1, t2 +WHERE t2.c = v1.c AND t2.c = v1.b AND v1.b = t3.c); +a b c +20 r r +SET SESSION optimizer_switch='derived_with_keys=on'; +EXPLAIN +SELECT * FROM t3 +WHERE t3.b IN (SELECT v1.b FROM v1, t2 +WHERE t2.c = v1.c AND t2.c = v1.b AND v1.b = t3.c); +id select_type table type possible_keys key key_len ref rows Extra +1 PRIMARY t2 system NULL NULL NULL NULL 1 +1 PRIMARY <derived3> ref key1 key1 10 const,const 0 Start temporary +1 PRIMARY t3 ALL NULL NULL NULL NULL 2 Using where; End temporary; Using join buffer (flat, BNL join) +3 DERIVED t1 ALL NULL NULL NULL NULL 3 +SELECT * FROM t3 +WHERE t3.b IN (SELECT v1.b FROM v1, t2 +WHERE t2.c = v1.c AND t2.c = v1.b AND v1.b = t3.c); +a b c +20 r r +DROP VIEW v1; +DROP TABLE t1,t2,t3; +# +# LP bug #873263: materialized view used in correlated IN subquery +# +CREATE TABLE t1 (a int, b int) ; +INSERT INTO t1 VALUES (5,4), (9,8); +CREATE TABLE t2 (a int, b int) ; +INSERT INTO t2 VALUES (4,5), (5,1); +CREATE ALGORITHM=TEMPTABLE VIEW v2 AS SELECT * FROM t2; +SET SESSION optimizer_switch='derived_with_keys=on'; +EXPLAIN +SELECT * FROM t1 WHERE t1.b IN (SELECT v2.a FROM v2 WHERE v2.b = t1.a); +id select_type table type possible_keys key key_len ref rows Extra +1 PRIMARY t1 ALL NULL NULL NULL NULL 2 Using where +1 PRIMARY <derived3> ref key0 key0 10 test.t1.b,test.t1.a 2 FirstMatch(t1) +3 DERIVED t2 ALL NULL NULL NULL NULL 2 +SELECT * FROM t1 WHERE t1.b IN (SELECT v2.a FROM v2 WHERE v2.b = t1.a); +a b +5 4 +DROP VIEW v2; +DROP TABLE t1,t2; +# +# LP bug #877316: query over a view with correlated subquery in WHERE +# +CREATE TABLE t1 (a int, b int, PRIMARY KEY (a)) ; +INSERT INTO t1 VALUES (18,2), (19,9); +CREATE TABLE t2 (a int, b int) ; +INSERT INTO t2 VALUES (10,8), (5,10); +CREATE VIEW v1 AS SELECT * FROM t1; +SELECT t1.a FROM t1 +WHERE EXISTS (SELECT t2.a FROM t2 WHERE t2.b < t1.b); +a +19 +EXPLAIN +SELECT t1.a FROM t1 +WHERE EXISTS (SELECT t2.a FROM t2 WHERE t2.b < t1.b); +id select_type table type possible_keys key key_len ref rows Extra +1 PRIMARY t1 ALL NULL NULL NULL NULL 2 Using where +2 DEPENDENT SUBQUERY t2 ALL NULL NULL NULL NULL 2 Using where +SELECT v1.a FROM v1 +WHERE EXISTS (SELECT t2.a FROM t2 WHERE t2.b < v1.b); +a +19 +EXPLAIN +SELECT v1.a FROM v1 +WHERE EXISTS (SELECT t2.a FROM t2 WHERE t2.b < v1.b); +id select_type table type possible_keys key key_len ref rows Extra +1 PRIMARY t1 ALL NULL NULL NULL NULL 2 Using where +2 DEPENDENT SUBQUERY t2 ALL NULL NULL NULL NULL 2 Using where +DROP VIEW v1; +DROP TABLE t1,t2; +# +# LP bug #878199: join of two materialized views +# +CREATE TABLE t1 (a int, b varchar(1)) ; +INSERT INTO t1 VALUES (7,'c'), (3,'h'), (7,'c'); +CREATE TABLE t2 (b varchar(1)) ; +INSERT INTO t2 VALUES ('p'), ('c'), ('j'), ('c'), ('p'); +CREATE VIEW v1 AS SELECT * FROM t1 GROUP BY a,b; +CREATE VIEW v2 AS SELECT * FROM t2 GROUP BY b; +SET SESSION optimizer_switch = 'derived_with_keys=on'; +SELECT v1.a FROM v1,v2 WHERE v2.b = v1.b ORDER BY 1; +a +7 +EXPLAIN +SELECT v1.a FROM v1,v2 WHERE v2.b = v1.b ORDER BY 1; +id select_type table type possible_keys key key_len ref rows Extra +1 PRIMARY <derived2> ALL key0 NULL NULL NULL 3 Using where; Using filesort +1 PRIMARY <derived3> ref key0 key0 5 v1.b 2 +3 DERIVED t2 ALL NULL NULL NULL NULL 5 Using temporary; Using filesort +2 DERIVED t1 ALL NULL NULL NULL NULL 3 Using temporary; Using filesort +DROP VIEW v1,v2; +DROP TABLE t1,t2; +# +# Bug #743378: join over merged view employing BNL +# +CREATE TABLE t1 ( d varchar(1) NOT NULL) ; +INSERT INTO t1 VALUES ('j'),('v'),('c'); +CREATE TABLE t2 (h time NOT NULL, d varchar(1) NOT NULL) ; +INSERT INTO t2 VALUES ('05:03:03','w'),('02:59:24','d'),('00:01:58','e'); +CREATE TABLE t3 ( +b int NOT NULL, e varchar(1) NOT NULL, d varchar(1) NOT NULL, KEY (e,b) +); +INSERT INTO t3 VALUES (4,'x','x'),(9,'w','w'),(4,'d','d'),(8,'e','e'); +CREATE TABLE t4 (i int NOT NULL, m varchar(1) NOT NULL) ; +INSERT INTO t4 VALUES (8,'m'),(9,'d'),(2,'s'),(4,'r'),(8,'m'); +CREATE TABLE t5 ( +a int NOT NULL, c int NOT NULL, b int NOT NULL, f date NOT NULL, +g date NOT NULL, h time NOT NULL, j time NOT NULL, k datetime NOT NULL +); +INSERT INTO t5 VALUES +(1,4,0,'0000-00-00','0000-00-00','21:22:34','21:22:34','2002-02-13 17:30'), +(2,6,8,'2004-09-18','2004-09-18','10:50:38','10:50:38','2008-09-27 00:34'); +CREATE VIEW v3 AS SELECT t3.*, t4.i FROM t3, t4, t5; +SET SESSION join_cache_level = 1; +SET SESSION join_buffer_size = 512; +EXPLAIN +SELECT t2.d FROM t1,t2,v3 WHERE v3.e = t2.d AND v3.i < 3; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t2 ALL NULL NULL NULL NULL 3 +1 SIMPLE t3 ref e e 3 test.t2.d 1 Using index +1 SIMPLE t5 ALL NULL NULL NULL NULL 2 Using join buffer (flat, BNL join) +1 SIMPLE t1 ALL NULL NULL NULL NULL 3 Using join buffer (flat, BNL join) +1 SIMPLE t4 ALL NULL NULL NULL NULL 5 Using where; Using join buffer (flat, BNL join) +SELECT t2.d FROM t1,t2,v3 WHERE v3.e = t2.d AND v3.i < 3; +d +w +d +e +w +d +e +w +d +e +w +d +e +w +d +e +w +d +e +SET SESSION join_cache_level = DEFAULT; +SET SESSION join_buffer_size = DEFAULT; +DROP VIEW v3; +DROP TABLE t1,t2,t3,t4,t5; +# +# Bug #879882: right join within mergeable derived table +# +CREATE TABLE t1 (a varchar(1)); +INSERT INTO t1 VALUES ('c'), ('a'); +CREATE TABLE t2 (a int, b int, c varchar(1)); +INSERT INTO t2 VALUES (29,8,'c'), (39,7,'b'); +CREATE TABLE t3 (b int); +EXPLAIN EXTENDED +SELECT t.b, t.c, t1.a +FROM t1, (SELECT t2.b, t2.c FROM t3 RIGHT JOIN t2 ON t2.a = t3.b) AS t +WHERE t.b AND t.c = t1.a; +id select_type table type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 system NULL NULL NULL NULL 0 0.00 const row not found +1 SIMPLE t1 ALL NULL NULL NULL NULL 2 100.00 +1 SIMPLE t2 ALL NULL NULL NULL NULL 2 100.00 Using where; Using join buffer (flat, BNL join) +Warnings: +Note 1003 select `test`.`t2`.`b` AS `b`,`test`.`t2`.`c` AS `c`,`test`.`t1`.`a` AS `a` from `test`.`t1` join `test`.`t2` where ((`test`.`t2`.`c` = `test`.`t1`.`a`) and `test`.`t2`.`b`) +SELECT t.b, t.c, t1.a +FROM t1, (SELECT t2.b, t2.c FROM t3 RIGHT JOIN t2 ON t2.a = t3.b) AS t +WHERE t.b AND t.c = t1.a; +b c a +8 c c +EXPLAIN EXTENDED +SELECT t.b, t.c, t1.a +FROM t1, (SELECT t2.b, t2.c FROM t3 RIGHT JOIN t2 ON t2.a = t3.b) AS t +WHERE t.b <> 0 AND t.c = t1.a; +id select_type table type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t3 system NULL NULL NULL NULL 0 0.00 const row not found +1 SIMPLE t1 ALL NULL NULL NULL NULL 2 100.00 +1 SIMPLE t2 ALL NULL NULL NULL NULL 2 100.00 Using where; Using join buffer (flat, BNL join) +Warnings: +Note 1003 select `test`.`t2`.`b` AS `b`,`test`.`t2`.`c` AS `c`,`test`.`t1`.`a` AS `a` from `test`.`t1` join `test`.`t2` where ((`test`.`t2`.`c` = `test`.`t1`.`a`) and (`test`.`t2`.`b` <> 0)) +SELECT t.b, t.c, t1.a +FROM t1, (SELECT t2.b, t2.c FROM t3 RIGHT JOIN t2 ON t2.a = t3.b) AS t +WHERE t.b <> 0 AND t.c = t1.a; +b c a +8 c c +INSERT INTO t3 VALUES (100), (200); +EXPLAIN EXTENDED +SELECT t.b, t.c, t1.a +FROM t1, (SELECT t2.b, t2.c FROM t3 RIGHT JOIN t2 ON t2.a = t3.b) AS t +WHERE t.b AND t.c = t1.a; +id select_type table type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 ALL NULL NULL NULL NULL 2 100.00 +1 SIMPLE t2 ALL NULL NULL NULL NULL 2 100.00 Using where; Using join buffer (flat, BNL join) +1 SIMPLE t3 ALL NULL NULL NULL NULL 2 100.00 Using where +Warnings: +Note 1003 select `test`.`t2`.`b` AS `b`,`test`.`t2`.`c` AS `c`,`test`.`t1`.`a` AS `a` from `test`.`t1` join `test`.`t2` left join `test`.`t3` on((`test`.`t3`.`b` = `test`.`t2`.`a`)) where ((`test`.`t2`.`c` = `test`.`t1`.`a`) and `test`.`t2`.`b`) +SELECT t.b, t.c, t1.a +FROM t1, (SELECT t2.b, t2.c FROM t3 RIGHT JOIN t2 ON t2.a = t3.b) AS t +WHERE t.b AND t.c = t1.a; +b c a +8 c c +EXPLAIN EXTENDED +SELECT t.b, t.c, t1.a +FROM t1, (SELECT t2.b, t2.c FROM t3 RIGHT JOIN t2 ON t2.a = t3.b) AS t +WHERE t.b <> 0 AND t.c = t1.a; +id select_type table type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 ALL NULL NULL NULL NULL 2 100.00 +1 SIMPLE t2 ALL NULL NULL NULL NULL 2 100.00 Using where; Using join buffer (flat, BNL join) +1 SIMPLE t3 ALL NULL NULL NULL NULL 2 100.00 Using where +Warnings: +Note 1003 select `test`.`t2`.`b` AS `b`,`test`.`t2`.`c` AS `c`,`test`.`t1`.`a` AS `a` from `test`.`t1` join `test`.`t2` left join `test`.`t3` on((`test`.`t3`.`b` = `test`.`t2`.`a`)) where ((`test`.`t2`.`c` = `test`.`t1`.`a`) and (`test`.`t2`.`b` <> 0)) +SELECT t.b, t.c, t1.a +FROM t1, (SELECT t2.b, t2.c FROM t3 RIGHT JOIN t2 ON t2.a = t3.b) AS t +WHERE t.b <> 0 AND t.c = t1.a; +b c a +8 c c +DROP TABLE t1,t2,t3; +# +# Bug #880724: materialized const view as inner table of outer join +# +CREATE TABLE t1 (a int, b varchar(1)); +INSERT INTO t1 VALUES (9,NULL), (6,'r'), (7,'c'); +CREATE TABLE t2 (a int); +INSERT INTO t2 VALUES (6); +CREATE ALGORITHM=TEMPTABLE VIEW v2 AS SELECT * FROM t2; +SET SESSION optimizer_switch = 'derived_with_keys=on'; +SET SESSION join_cache_level = 4; +EXPLAIN +SELECT t1.b,v2.a FROM t1 LEFT JOIN v2 ON v2.a = t1.a; +id select_type table type possible_keys key key_len ref rows Extra +1 PRIMARY t1 ALL NULL NULL NULL NULL 3 +1 PRIMARY <derived2> ALL NULL NULL NULL NULL 1 Using where +2 DERIVED t2 system NULL NULL NULL NULL 1 +SELECT t1.b,v2.a FROM t1 LEFT JOIN v2 ON v2.a = t1.a; +b a +NULL NULL +r 6 +c NULL +CREATE TABLE t3 (a int, b varchar(1)); +INSERT INTO t3 VALUES (8,'x'), (5,'r'), (9,'y'); +EXPLAIN +SELECT * FROM t3 +WHERE t3.b <> ANY (SELECT t1.b FROM t1 LEFT JOIN v2 ON v2.a = t1.a); +id select_type table type possible_keys key key_len ref rows Extra +1 PRIMARY t3 ALL NULL NULL NULL NULL 3 Using where +2 DEPENDENT SUBQUERY t1 ALL NULL NULL NULL NULL 3 Using where +2 DEPENDENT SUBQUERY <derived3> ALL NULL NULL NULL NULL 1 Using where +3 DERIVED t2 system NULL NULL NULL NULL 1 +SELECT * FROM t3 +WHERE t3.b <> ANY (SELECT t1.b FROM t1 LEFT JOIN v2 ON v2.a = t1.a); +a b +8 x +5 r +9 y +SET SESSION join_cache_level = default; +DROP VIEW v2; +DROP TABLE t1,t2,t3; +# +# Bug #881449: OUTER JOIN usin a merged view within IN subquery +# +CREATE TABLE t1 (a varchar(1)) ; +INSERT INTO t1 VALUES ('y'), ('x'); +CREATE TABLE t2 (a int, PRIMARY KEY (a)) ; +INSERT INTO t2 VALUES (1), (2); +CREATE TABLE t3 (a int, b varchar(1)) ; +INSERT INTO t3 VALUES (1,'x'); +CREATE VIEW v3 AS SELECT * FROM t3; +SET SESSION optimizer_switch='semijoin=on'; +EXPLAIN +SELECT * FROM t1 WHERE a IN (SELECT v3.b FROM t2 RIGHT JOIN v3 ON v3.a = t2.a); +id select_type table type possible_keys key key_len ref rows Extra +1 PRIMARY t3 system NULL NULL NULL NULL 1 +1 PRIMARY t2 const PRIMARY PRIMARY 4 const 1 Using index +1 PRIMARY t1 ALL NULL NULL NULL NULL 2 Using where +SELECT * FROM t1 WHERE a IN (SELECT v3.b FROM t2 RIGHT JOIN v3 ON v3.a = t2.a); +a +x +set optimizer_switch= @save_optimizer_switch; +DROP VIEW v3; +DROP TABLE t1,t2,t3; +# +# Bug #874035: view as an inner table of a materialized derived +# +CREATE TABLE t2 (a int NOT NULL); +INSERT INTO t2 VALUES (7), (4); +CREATE TABLE t1 (b int NOT NULL); +INSERT INTO t1 VALUES (5), (7); +CREATE ALGORITHM=MERGE VIEW v1 AS SELECT * FROM t1; +SET SESSION optimizer_switch='derived_merge=off'; +PREPARE st1 FROM +'SELECT * FROM (SELECT * FROM t2 LEFT JOIN v1 ON t2.a = v1.b) AS t'; +EXECUTE st1; +a b +7 7 +4 NULL +EXECUTE st1; +a b +7 7 +4 NULL +DEALLOCATE PREPARE st1; +DROP VIEW v1; +DROP TABLE t1,t2; +SET SESSION optimizer_switch='derived_merge=on'; +# +# LP bug #879939: assertion in ha_maria::enable_indexes +# with derived_with_keys=on +# +CREATE TABLE t2 (a varchar(3)); +INSERT INTO t2 VALUES ('USA'), ('USA'), ('USA'), ('USA'), ('USA'); +CREATE TABLE t1 (a varchar(3), b varchar(35)); +INSERT INTO t1 VALUES +('USA','Lansing'), ('USA','Laredo'), ('USA','Las Vegas'), +('USA','Lexington-Fayett'), ('USA','Lincoln'), ('USA','Little Rock'), +('USA','Livonia'), ('USA','Long Beach'), ('USA','Los Angeles'), +('USA','Louisville'), ('USA','Lowell'), ('USA','Lubbock'), +('USA','Macon'), ('USA','Madison'), ('USA','Manchester'), +('USA','McAllen'), ('USA','Memphis'), ('USA','Mesa'), +('USA','Mesquite'), ('USA','Metairie'), ('USA','Miami'); +CREATE TABLE t3 (a varchar(35)); +INSERT INTO t3 VALUES ('Miami'); +SET optimizer_switch = 'derived_with_keys=on'; +SET @@tmp_table_size=1024*4; +explain SELECT * FROM (SELECT t1.* FROM t1, t2) AS t JOIN t3 ON t3.a = t.b; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t3 system NULL NULL NULL NULL 1 +1 SIMPLE t2 ALL NULL NULL NULL NULL 5 +1 SIMPLE t1 ALL NULL NULL NULL NULL 21 Using where; Using join buffer (flat, BNL join) +SELECT * FROM (SELECT t1.* FROM t1, t2) AS t JOIN t3 ON t3.a = t.b; +a b a +USA Miami Miami +USA Miami Miami +USA Miami Miami +USA Miami Miami +USA Miami Miami +SET @@tmp_table_size=1024*1024*16; +SELECT * FROM (SELECT t1.* FROM t1, t2) AS t JOIN t3 ON t3.a = t.b; +a b a +USA Miami Miami +USA Miami Miami +USA Miami Miami +USA Miami Miami +USA Miami Miami +SET @@tmp_table_size=default; +drop table t1,t2,t3; +# +# BUG#882994: Crash in QUICK_RANGE_SELECT::reset with derived_with_keys +# +CREATE TABLE t2 ( +pk varchar(33), +col_varchar_key varchar(3) NOT NULL, +col_varchar_nokey varchar(52) NOT NULL); +INSERT INTO t2 VALUES ('NICSpanish','NIC','Spanish'), +('NERHausa','NER','Hausa'),('NGAJoruba','NGA','Joruba'), +('NIUNiue','NIU','Niue'),('NFKEnglish','NFK','English'), +('NORNorwegian','NOR','Norwegian'),('CIVAkan','CIV','Akan'), +('OMNArabic','OMN','Arabic'),('PAKPunjabi','PAK','Punjabi'), +('PLWPalau','PLW','Palau'),('PANSpanish','PAN','Spanish'), +('PNGPapuan Langua','PNG','Papuan Languages'), ('PRYSpanish','PRY','Spanish'), +('PERSpanish','PER','Spanish'), ('PCNPitcairnese','PCN','Pitcairnese'), +('MNPPhilippene La','MNP','Philippene Langu'),('PRTPortuguese','PRT','Portuguese'), +('PRISpanish','PRI','Spanish'),('POLPolish','POL','Polish'),('GNQFang','GNQ','Fang'); +CREATE TABLE t1 ( col_varchar_nokey varchar(52) NOT NULL ) ; +INSERT INTO t1 VALUES ('Chinese'),('English'),('French'),('German'), +('Italian'),('Japanese'),('Korean'),('Polish'),('Portuguese'),('Spanish'), +('Tagalog'),('Vietnamese'); +CREATE TABLE t3 ( col_varchar_key varchar(52)) ; +INSERT INTO t3 VALUES ('United States'); +set @tmp_882994= @@max_heap_table_size; +set max_heap_table_size=1; +SELECT * +FROM t3 JOIN +( SELECT t2.* FROM t1, t2 ) AS alias2 +ON ( alias2.col_varchar_nokey = t3.col_varchar_key ) +ORDER BY CONCAT(alias2.col_varchar_nokey); +col_varchar_key pk col_varchar_key col_varchar_nokey +set max_heap_table_size= @tmp_882994; +drop table t1,t2,t3; set optimizer_switch=@exit_optimizer_switch; diff --git a/mysql-test/r/dyncol.result b/mysql-test/r/dyncol.result index 60f9dca0dd7..f4a858c3029 100644 --- a/mysql-test/r/dyncol.result +++ b/mysql-test/r/dyncol.result @@ -838,9 +838,7 @@ column_get(column_create(1, "2001021"), 1 as date) set @@sql_mode="allow_invalid_dates"; select column_get(column_create(1, "2011-02-30 18:46:06.23434" AS CHAR), 1 as date); column_get(column_create(1, "2011-02-30 18:46:06.23434" AS CHAR), 1 as date) -NULL -Warnings: -Warning 1292 Truncated incorrect date value: '2011-02-30' +2011-02-30 select column_get(column_create(1, "0000-00-000" AS CHAR), 1 as date); column_get(column_create(1, "0000-00-000" AS CHAR), 1 as date) 0000-00-00 diff --git a/mysql-test/r/execution_constants.result b/mysql-test/r/execution_constants.result index 293c88dc506..86eed447b83 100644 --- a/mysql-test/r/execution_constants.result +++ b/mysql-test/r/execution_constants.result @@ -7,6 +7,6 @@ PRIMARY KEY (`ID_MEMBER`,`ID_BOARD`), KEY `logTime` (`logTime`) ) ENGINE=MyISAM DEFAULT CHARSET=cp1251 COLLATE=cp1251_bulgarian_ci; INSERT INTO `t_bug21476` VALUES (2,2,1154870939,0),(1,2,1154870957,0),(2,183,1154941362,0),(2,84,1154904301,0),(1,84,1154905867,0),(2,13,1154947484,10271),(3,84,1154880549,0),(1,6,1154892183,0),(2,25,1154947581,10271),(3,25,1154904760,0),(1,25,1154947373,10271),(1,179,1154899992,0),(2,179,1154899410,0),(5,25,1154901666,0),(2,329,1154902026,0),(3,329,1154902040,0),(1,329,1154902058,0),(1,13,1154930841,0),(3,85,1154904987,0),(1,183,1154929665,0),(3,13,1154931268,0),(1,85,1154936888,0),(1,169,1154937959,0),(2,169,1154941717,0),(3,183,1154939810,0),(3,169,1154941734,0); -Assertion: mysql_errno 1436 == 1436 +Assertion: mysql_errname ER_STACK_OVERRUN_NEED_MORE == ER_STACK_OVERRUN_NEED_MORE DROP TABLE `t_bug21476`; End of 5.0 tests. diff --git a/mysql-test/r/explain.result b/mysql-test/r/explain.result index 81c122f2c76..65bc5b22ba8 100644 --- a/mysql-test/r/explain.result +++ b/mysql-test/r/explain.result @@ -171,7 +171,7 @@ DROP TABLE t1; # Bug#48295: # explain extended crash with subquery and ONLY_FULL_GROUP_BY sql_mode # -CREATE TABLE t1 (f1 INT); +CREATE TABLE t1 (f1 INT not null); SELECT @@session.sql_mode INTO @old_sql_mode; SET SESSION sql_mode='ONLY_FULL_GROUP_BY'; EXPLAIN EXTENDED SELECT 1 FROM t1 @@ -182,9 +182,6 @@ id select_type table type possible_keys key key_len ref rows filtered Extra 2 SUBQUERY t system NULL NULL NULL NULL 0 0.00 const row not found Warnings: Note 1003 select 1 AS `1` from `test`.`t1` where 0 -SHOW WARNINGS; -Level Code Message -Note 1003 select 1 AS `1` from `test`.`t1` where 0 SET SESSION sql_mode=@old_sql_mode; DROP TABLE t1; End of 5.0 tests. @@ -199,16 +196,16 @@ insert into t2 values ('2001-01-01 1:1:1'), ('2001-01-01 1:1:1'); flush tables; EXPLAIN SELECT OUTR.dt FROM t1 AS OUTR WHERE OUTR.dt IN (SELECT INNR.dt FROM t2 AS INNR WHERE OUTR.dt IS NULL ); id select_type table type possible_keys key key_len ref rows Extra -1 PRIMARY OUTR ALL NULL NULL NULL NULL 2 Using where -2 DEPENDENT SUBQUERY INNR ALL NULL NULL NULL NULL 2 Using where +1 PRIMARY OUTR ALL NULL NULL NULL NULL 2 Using where; Start temporary +1 PRIMARY INNR ALL NULL NULL NULL NULL 2 Using where; End temporary flush tables; SELECT OUTR.dt FROM t1 AS OUTR WHERE OUTR.dt IN (SELECT INNR.dt FROM t2 AS INNR WHERE OUTR.dt IS NULL ); dt flush tables; EXPLAIN SELECT OUTR.dt FROM t1 AS OUTR WHERE OUTR.dt IN ( SELECT INNR.dt FROM t2 AS INNR WHERE OUTR.t < '2005-11-13 7:41:31' ); id select_type table type possible_keys key key_len ref rows Extra -1 PRIMARY OUTR ALL NULL NULL NULL NULL 2 Using where -2 DEPENDENT SUBQUERY INNR ALL NULL NULL NULL NULL 2 Using where +1 PRIMARY OUTR ALL NULL NULL NULL NULL 2 Using where; Start temporary +1 PRIMARY INNR ALL NULL NULL NULL NULL 2 Using where; End temporary flush tables; SELECT OUTR.dt FROM t1 AS OUTR WHERE OUTR.dt IN ( SELECT INNR.dt FROM t2 AS INNR WHERE OUTR.t < '2005-11-13 7:41:31' ); dt @@ -228,7 +225,7 @@ id select_type table type possible_keys key key_len ref rows filtered Extra 2 DEPENDENT SUBQUERY t2 ALL NULL NULL NULL NULL 2 100.00 Using where Warnings: Note 1276 Field or reference 'test.t1.c' of SELECT #2 was resolved in SELECT #1 -Note 1003 select (select 1 from `test`.`t2` where (`test`.`t2`.`d` = NULL)) AS `(SELECT 1 FROM t2 WHERE d = c)` from dual +Note 1003 select <expr_cache><NULL>((select 1 from `test`.`t2` where (`test`.`t2`.`d` = NULL))) AS `(SELECT 1 FROM t2 WHERE d = c)` from dual DROP TABLE t1, t2; # # Bug#30302: Tables that were optimized away are printed in the diff --git a/mysql-test/r/feedback_plugin_install.result b/mysql-test/r/feedback_plugin_install.result new file mode 100644 index 00000000000..b1b35072a08 --- /dev/null +++ b/mysql-test/r/feedback_plugin_install.result @@ -0,0 +1,13 @@ +install plugin feedback soname 'feedback.so'; +select plugin_status from information_schema.plugins where plugin_name='feedback'; +plugin_status +ACTIVE +select * from information_schema.feedback where variable_name like 'feed%' + and variable_name not like '%_uid'; +VARIABLE_NAME VARIABLE_VALUE +FEEDBACK 1.1 +FEEDBACK_SEND_RETRY_WAIT 60 +FEEDBACK_SEND_TIMEOUT 60 +FEEDBACK_URL http://mariadb.org/feedback_plugin/post +FEEDBACK_USER_INFO mysql-test +uninstall plugin feedback; diff --git a/mysql-test/r/feedback_plugin_load.result b/mysql-test/r/feedback_plugin_load.result new file mode 100644 index 00000000000..d434d1282c5 --- /dev/null +++ b/mysql-test/r/feedback_plugin_load.result @@ -0,0 +1,11 @@ +select plugin_status from information_schema.plugins where plugin_name='feedback'; +plugin_status +ACTIVE +select * from information_schema.feedback where variable_name like 'feed%' + and variable_name not like '%_uid'; +VARIABLE_NAME VARIABLE_VALUE +FEEDBACK 1.1 +FEEDBACK_SEND_RETRY_WAIT 60 +FEEDBACK_SEND_TIMEOUT 60 +FEEDBACK_URL http://mariadb.org/feedback_plugin/post +FEEDBACK_USER_INFO mysql-test diff --git a/mysql-test/r/feedback_plugin_send.result b/mysql-test/r/feedback_plugin_send.result new file mode 100644 index 00000000000..db622cb3f97 --- /dev/null +++ b/mysql-test/r/feedback_plugin_send.result @@ -0,0 +1,15 @@ +select plugin_status from information_schema.plugins where plugin_name='feedback'; +plugin_status +ACTIVE +select * from information_schema.feedback where variable_name like 'feed%' + and variable_name not like '%_uid'; +VARIABLE_NAME VARIABLE_VALUE +FEEDBACK 1.1 +FEEDBACK_SEND_RETRY_WAIT 60 +FEEDBACK_SEND_TIMEOUT 60 +FEEDBACK_URL http://mariadb.org/feedback_plugin/post +FEEDBACK_USER_INFO mysql-test +feedback plugin: report to 'http://mariadb.org/feedback_plugin/post' was sent +feedback plugin: server replied 'ok' +feedback plugin: report to 'http://mariadb.org/feedback_plugin/post' was sent +feedback plugin: server replied 'ok' diff --git a/mysql-test/r/flush.result b/mysql-test/r/flush.result index 246cd40fd26..340a0863790 100644 --- a/mysql-test/r/flush.result +++ b/mysql-test/r/flush.result @@ -466,3 +466,26 @@ ALTER TABLE t1 COMMENT 'test'; ERROR HY000: Table 't1' was locked with a READ lock and can't be updated UNLOCK TABLES; DROP TABLE t1; +# +# Test for bug #12641342 - "61401: UPDATE PERFORMANCE DEGRADES +# GRADUALLY IF A TRIGGER EXISTS". +# +# One of side-effects of this bug was that a transaction which +# involved DML statements requiring prelocking blocked concurrent +# FLUSH TABLES WITH READ LOCK for the whole its duration, while +# correct behavior in this case is to block FTWRL only for duration +# of individual DML statements. +DROP TABLE IF EXISTS t1; +CREATE TABLE t1 (id INT PRIMARY KEY, value INT); +INSERT INTO t1 VALUES (1, 1); +CREATE TRIGGER t1_au AFTER UPDATE ON t1 FOR EACH ROW SET @var = "a"; +BEGIN; +UPDATE t1 SET value= value + 1 WHERE id = 1; +# Switching to connection 'con1'. +# The below FLUSH TABLES WITH READ LOCK should succeed and +# should not be blocked by the transaction in default connection. +FLUSH TABLES WITH READ LOCK; +UNLOCK TABLES; +# Switching to connection 'default'. +COMMIT; +DROP TABLE t1; diff --git a/mysql-test/r/fulltext.result b/mysql-test/r/fulltext.result index a76abaa4544..c96937fea34 100644 --- a/mysql-test/r/fulltext.result +++ b/mysql-test/r/fulltext.result @@ -505,6 +505,8 @@ Level Code Message CREATE TABLE t1 (a VARCHAR(255), b INT, FULLTEXT(a), KEY(b)); INSERT INTO t1 VALUES('test', 1),('test', 1),('test', 1),('test', 1), ('test', 1),('test', 2),('test', 3),('test', 4); +INSERT INTO t1 VALUES('test', 5),('test', 6),('test', 7),('test', 8), +('test', 5),('test', 6),('test', 7),('test', 8); EXPLAIN SELECT * FROM t1 WHERE MATCH(a) AGAINST('test' IN BOOLEAN MODE) AND b=1; id select_type table type possible_keys key key_len ref rows Extra @@ -520,15 +522,15 @@ id select_type table type possible_keys key key_len ref rows Extra EXPLAIN SELECT * FROM t1 IGNORE INDEX(a) WHERE MATCH(a) AGAINST('test' IN BOOLEAN MODE) AND b=1; id select_type table type possible_keys key key_len ref rows Extra -1 SIMPLE t1 ref b b 5 const 4 Using where +1 SIMPLE t1 ref b b 5 const 5 Using where EXPLAIN SELECT * FROM t1 USE INDEX(b) WHERE MATCH(a) AGAINST('test' IN BOOLEAN MODE) AND b=1; id select_type table type possible_keys key key_len ref rows Extra -1 SIMPLE t1 ref b b 5 const 4 Using where +1 SIMPLE t1 ref b b 5 const 5 Using where EXPLAIN SELECT * FROM t1 FORCE INDEX(b) WHERE MATCH(a) AGAINST('test' IN BOOLEAN MODE) AND b=1; id select_type table type possible_keys key key_len ref rows Extra -1 SIMPLE t1 ref b b 5 const 4 Using where +1 SIMPLE t1 ref b b 5 const 5 Using where DROP TABLE t1; create table t1(a text,b date,fulltext index(a))engine=myisam; insert into t1 set a='water',b='2008-08-04'; diff --git a/mysql-test/r/func_group.result b/mysql-test/r/func_group.result index 433f8ca6a65..0a1d136b55e 100644 --- a/mysql-test/r/func_group.result +++ b/mysql-test/r/func_group.result @@ -1811,6 +1811,15 @@ MAX(f1) 2001 DROP TABLE t1; # +# LP BUG#813418 - incorrect optimisation of max/min by index for +# negated BETWEEN +CREATE TABLE t1 (a int, KEY (a)); +INSERT INTO t1 VALUES (1),(2),(3),(4),(5),(6),(7),(8),(9),(10); +SELECT MAX(a) FROM t1 WHERE a NOT BETWEEN 3 AND 9; +MAX(a) +10 +drop table t1; +# End of 5.1 tests # # BUG#46680 - Assertion failed in file item_subselect.cc, diff --git a/mysql-test/r/func_in.result b/mysql-test/r/func_in.result index 9f98ffbe706..779049f8b4c 100644 --- a/mysql-test/r/func_in.result +++ b/mysql-test/r/func_in.result @@ -544,9 +544,15 @@ id select_type table type possible_keys key key_len ref rows Extra select f2 from t2 where f2 in ('a','b'); f2 0 +Warnings: +Warning 1292 Truncated incorrect DOUBLE value: 'a' +Warning 1292 Truncated incorrect DOUBLE value: 'b' explain select f2 from t2 where f2 in ('a','b'); id select_type table type possible_keys key key_len ref rows Extra 1 SIMPLE t2 index t2f2 t2f2 5 NULL 3 Using where; Using index +Warnings: +Warning 1292 Truncated incorrect DOUBLE value: 'a' +Warning 1292 Truncated incorrect DOUBLE value: 'b' select f2 from t2 where f2 in (1,'b'); f2 0 @@ -771,3 +777,18 @@ SELECT 1 IN (YEAR(FROM_UNIXTIME(NULL)) ,1); 1 # End of 5.1 tests +create table t1 (a bigint, b int); +insert t1 values (1,1),(2,2),(3,3); +select * from t1 where a in ('2.1'); +a b +2 2 +select * from t1 where b in ('2.1'); +a b +select * from t1 where a='2.1'; +a b +2 2 +select * from t1 where b='2.1'; +a b +select * from t1 where IF(1,a,a)='2.1'; +a b +drop table t1; diff --git a/mysql-test/r/func_math.result b/mysql-test/r/func_math.result index 4a61a16bbec..fff6e86862c 100644 --- a/mysql-test/r/func_math.result +++ b/mysql-test/r/func_math.result @@ -527,7 +527,7 @@ select "123456789012345678901234567890.123456789012345678901234567890" div 1 as ERROR 22003: BIGINT value is out of range in '('123456789012345678901234567890.123456789012345678901234567890' DIV 1)' SHOW WARNINGS; Level Code Message -Warning 1916 Got overflow when converting '123456789012345678901234567890.123456789012345678901234567890000000' to INT. Value truncated. +Warning 1916 Got overflow when converting '123456789012345678901234567890' to INT. Value truncated. Error 1690 BIGINT value is out of range in '('123456789012345678901234567890.123456789012345678901234567890' DIV 1)' # # Bug#57810 case/when/then : Assertion failed: length || !scale @@ -727,3 +727,32 @@ select (1.175494351E-37 div 1.7976931348623157E+308); 0 Warnings: Warning 1916 Got overflow when converting '' to DECIMAL. Value truncated. +# +# Bug#12537160 ASSERTION FAILED: +# STOP0 <= &TO->BUF[TO->LEN] WITH LARGE NUMBER. +# +select 999999999999999999999999999999999999999999999999999999999999999999999999999999999 % 0.1 as foo; +foo +0.0 +select 999999999999999999999999999999999999999999999999999999999999999999999999999999999 % 0.0 as foo; +foo +NULL +# +# Bug#12711164 - 61676: +# RESULT OF DIV WITH DECIMAL AND INTEGER DOES NOT MAKE SENSE +# +select 5 div 2; +5 div 2 +2 +select 5.0 div 2.0; +5.0 div 2.0 +2 +select 5.0 div 2; +5.0 div 2 +2 +select 5 div 2.0; +5 div 2.0 +2 +select 5.9 div 2, 1.23456789e3 DIV 2, 1.23456789e9 DIV 2, 1.23456789e19 DIV 2; +5.9 div 2 1.23456789e3 DIV 2 1.23456789e9 DIV 2 1.23456789e19 DIV 2 +2 617 617283945 6172839450000000000 diff --git a/mysql-test/r/func_str.result b/mysql-test/r/func_str.result index 62429ae1bce..4d512601216 100644 --- a/mysql-test/r/func_str.result +++ b/mysql-test/r/func_str.result @@ -2786,5 +2786,40 @@ format(123,2,'no_NO') 123,00 DROP TABLE t1; # +# Bug#12985030 SIMPLE QUERY WITH DECIMAL NUMBERS LEAKS MEMORY +# +SELECT (rpad(1.0,2048,1)) IS NOT FALSE; +(rpad(1.0,2048,1)) IS NOT FALSE +1 +SELECT ((+0) IN +((0b111111111111111111111111111111111111111111111111111),(rpad(1.0,2048,1)), +(32767.1))); +((+0) IN +((0b111111111111111111111111111111111111111111111111111),(rpad(1.0,2048,1)), +(32767.1))) +0 +SELECT ((rpad(1.0,2048,1)) = ('4(') ^ (0.1)); +((rpad(1.0,2048,1)) = ('4(') ^ (0.1)) +0 +Warnings: +Warning 1292 Truncated incorrect INTEGER value: '4(' +SELECT +pow((rpad(10.0,2048,1)),(b'1111111111111111111111111111111111111111111')); +ERROR 22003: DOUBLE value is out of range in 'pow(rpad(10.0,2048,1),0x07ffffffffff)' +SELECT ((rpad(1.0,2048,1)) + (0) ^ ('../')); +((rpad(1.0,2048,1)) + (0) ^ ('../')) +1.011111111111111 +Warnings: +Warning 1292 Truncated incorrect INTEGER value: '../' +SELECT stddev_samp(rpad(1.0,2048,1)); +stddev_samp(rpad(1.0,2048,1)) +NULL +SELECT ((127.1) not in ((rpad(1.0,2048,1)),(''),(-1.1))); +((127.1) not in ((rpad(1.0,2048,1)),(''),(-1.1))) +1 +SELECT ((0xf3) * (rpad(1.0,2048,1)) << (0xcc)); +((0xf3) * (rpad(1.0,2048,1)) << (0xcc)) +0 +# # End of 5.5 tests # diff --git a/mysql-test/r/func_time.result b/mysql-test/r/func_time.result index 8c6aadb15fb..6e0a0d84115 100644 --- a/mysql-test/r/func_time.result +++ b/mysql-test/r/func_time.result @@ -27,6 +27,10 @@ sec_to_time('9001.1') sec_to_time('1234567890123.123') 02:30:01.100000 838:59:59.999999 Warnings: Warning 1292 Truncated incorrect time value: '1234567890123.123' +select sec_to_time(-9001.1), sec_to_time(-9001.1) / 1, +sec_to_time(-9001.1) / 1e0, sec_to_time(-9001) div 1; +sec_to_time(-9001.1) sec_to_time(-9001.1) / 1 sec_to_time(-9001.1) / 1e0 sec_to_time(-9001) div 1 +-02:30:01.1 -23001.10000 -23001.1 -23001 select sec_to_time(90011e-1), sec_to_time(1234567890123e30); sec_to_time(90011e-1) sec_to_time(1234567890123e30) 02:30:01.100000 838:59:59.999999 @@ -1426,6 +1430,12 @@ NULL SELECT WEEK(DATE_ADD(FROM_DAYS(1),INTERVAL 1 MONTH), 1); WEEK(DATE_ADD(FROM_DAYS(1),INTERVAL 1 MONTH), 1) NULL +# +# Bug#12584302 AFTER FIX FOR #12403504: ASSERTION FAILED: DELSUM+(INT) Y/4-TEMP > 0, +# +DO WEEK((DATE_ADD((CAST(0 AS DATE)), INTERVAL 1 YEAR_MONTH)), 5); +Warnings: +Warning 1292 Truncated incorrect date value: '0000-00-00' End of 5.1 tests # # Bug#57039: constant subtime expression returns incorrect result. diff --git a/mysql-test/r/gis.result b/mysql-test/r/gis.result index 03ced4653cb..40007dd3a05 100644 --- a/mysql-test/r/gis.result +++ b/mysql-test/r/gis.result @@ -1076,4 +1076,21 @@ SPATIAL INDEX i1 (col1, col2) ); ERROR HY000: Incorrect arguments to SPATIAL INDEX DROP TABLE t0, t1, t2; +# +# Bug#11908153: CRASH AND/OR VALGRIND ERRORS IN FIELD_BLOB::GET_KEY_IMAGE +# +CREATE TABLE g1 +(a geometry NOT NULL, UNIQUE KEY i (a(151))) engine=myisam; +INSERT INTO g1 VALUES (geomfromtext('point(1 1)')); +INSERT INTO g1 VALUES (geomfromtext('point(1 2)')); +FLUSH TABLES; +SELECT 1 FROM g1 +FORCE INDEX(i) WHERE a = date_sub(now(), interval 2808.4 year_month) +; +1 +Warnings: +Warning 1292 Incorrect datetime value: '\x00\x00\x00\x00\x01\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\xF0?\x00\x00\x00\x00\x00\x00\xF0?' +Warning 1441 Datetime function: datetime field overflow +Warning 1292 Incorrect datetime value: '\x00\x00\x00\x00\x01\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\xF0?\x00\x00\x00\x00\x00\x00\x00@' +DROP TABLE g1; End of 5.5 tests diff --git a/mysql-test/r/group_by.result b/mysql-test/r/group_by.result index faa9d039d7b..7b22b450b62 100644 --- a/mysql-test/r/group_by.result +++ b/mysql-test/r/group_by.result @@ -1543,8 +1543,8 @@ id select_type table type possible_keys key key_len ref rows Extra EXPLAIN SELECT 1 FROM t1 WHERE a IN (SELECT a FROM t1 USE INDEX (i2) IGNORE INDEX (i2)); id select_type table type possible_keys key key_len ref rows Extra -1 PRIMARY t1 index NULL PRIMARY 4 NULL 144 Using where; Using index -2 DEPENDENT SUBQUERY t1 ALL NULL NULL NULL NULL 144 Using where +1 PRIMARY t1 index PRIMARY,i2 PRIMARY 4 NULL 144 Using index +1 PRIMARY t1 ALL NULL NULL NULL NULL 144 Using where; FirstMatch(t1) CREATE TABLE t2 (a INT, b INT, KEY(a)); INSERT INTO t2 VALUES (1, 1), (2, 2), (3,3), (4,4); EXPLAIN SELECT a, SUM(b) FROM t2 GROUP BY a LIMIT 2; @@ -1556,8 +1556,8 @@ id select_type table type possible_keys key key_len ref rows Extra EXPLAIN SELECT 1 FROM t2 WHERE a IN (SELECT a FROM t1 USE INDEX (i2) IGNORE INDEX (i2)); id select_type table type possible_keys key key_len ref rows Extra -1 PRIMARY t2 index NULL a 5 NULL 4 Using where; Using index -2 DEPENDENT SUBQUERY t1 ALL NULL NULL NULL NULL 144 Using where +1 PRIMARY t2 index a a 5 NULL 4 Using index +1 PRIMARY t1 ALL NULL NULL NULL NULL 144 Using where; FirstMatch(t2) DROP TABLE t1, t2; CREATE TABLE t1( a INT, @@ -1671,7 +1671,7 @@ c (SELECT a FROM t1 WHERE b = c) SELECT b c, (SELECT a FROM t1 WHERE b = c) FROM t1 HAVING b = 10; -ERROR 42000: non-grouping field 'b' is used in HAVING clause +ERROR 42000: Non-grouping field 'b' is used in HAVING clause SELECT MAX(b) c, (SELECT a FROM t1 WHERE b = c) FROM t1 HAVING b = 10; @@ -1738,7 +1738,7 @@ id select_type table type possible_keys key key_len ref rows filtered Extra 2 DEPENDENT SUBQUERY NULL NULL NULL NULL NULL NULL NULL NULL No tables used Warnings: Note 1276 Field or reference 'test.t1.a' of SELECT #2 was resolved in SELECT #1 -Note 1003 select (select `test`.`t1`.`a`) AS `aa`,count(distinct `test`.`t1`.`b`) AS `COUNT(DISTINCT b)` from `test`.`t1` group by ((select `test`.`t1`.`a`) + 0) +Note 1003 select <expr_cache><`test`.`t1`.`a`>((select `test`.`t1`.`a`)) AS `aa`,count(distinct `test`.`t1`.`b`) AS `COUNT(DISTINCT b)` from `test`.`t1` group by (<expr_cache><`test`.`t1`.`a`>((select `test`.`t1`.`a`)) + 0) EXPLAIN EXTENDED SELECT (SELECT t1.a) aa, COUNT(DISTINCT b) FROM t1 GROUP BY -aa; id select_type table type possible_keys key key_len ref rows filtered Extra @@ -1746,7 +1746,7 @@ id select_type table type possible_keys key key_len ref rows filtered Extra 2 DEPENDENT SUBQUERY NULL NULL NULL NULL NULL NULL NULL NULL No tables used Warnings: Note 1276 Field or reference 'test.t1.a' of SELECT #2 was resolved in SELECT #1 -Note 1003 select (select `test`.`t1`.`a`) AS `aa`,count(distinct `test`.`t1`.`b`) AS `COUNT(DISTINCT b)` from `test`.`t1` group by -((select `test`.`t1`.`a`)) +Note 1003 select <expr_cache><`test`.`t1`.`a`>((select `test`.`t1`.`a`)) AS `aa`,count(distinct `test`.`t1`.`b`) AS `COUNT(DISTINCT b)` from `test`.`t1` group by -(<expr_cache><`test`.`t1`.`a`>((select `test`.`t1`.`a`))) # should return only one record SELECT (SELECT tt.a FROM t1 tt LIMIT 1) aa, COUNT(DISTINCT b) FROM t1 GROUP BY aa; @@ -1904,6 +1904,38 @@ a AVG(t1.b) t11c t12c 1 4.0000 6 6 2 2.0000 7 7 DROP TABLE t1; +# +# Bug#11765254 (58200): Assertion failed: param.sort_length when grouping +# by functions +# +SET SQL_BIG_TABLES=1; +CREATE TABLE t1(a INT); +INSERT INTO t1 VALUES (0),(0); +SELECT 1 FROM t1 GROUP BY IF(`a`,'',''); +1 +1 +SELECT 1 FROM t1 GROUP BY TRIM(LEADING RAND() FROM ''); +1 +1 +SELECT 1 FROM t1 GROUP BY SUBSTRING('',SLEEP(0),''); +1 +1 +Warnings: +Warning 1292 Truncated incorrect INTEGER value: '' +Warning 1292 Truncated incorrect INTEGER value: '' +Warning 1292 Truncated incorrect INTEGER value: '' +SELECT 1 FROM t1 GROUP BY SUBSTRING(SYSDATE() FROM 'K' FOR 'jxW<'); +1 +1 +Warnings: +Warning 1292 Truncated incorrect INTEGER value: 'K' +Warning 1292 Truncated incorrect INTEGER value: 'jxW<' +Warning 1292 Truncated incorrect INTEGER value: 'K' +Warning 1292 Truncated incorrect INTEGER value: 'jxW<' +Warning 1292 Truncated incorrect INTEGER value: 'K' +Warning 1292 Truncated incorrect INTEGER value: 'jxW<' +DROP TABLE t1; +SET SQL_BIG_TABLES=0; # End of 5.1 tests # # Bug#49771: Incorrect MIN (date) when minimum value is 0000-00-00 @@ -1934,3 +1966,18 @@ f1 MIN(f2) MAX(f2) 4 00:25:00 00:25:00 DROP TABLE t1; #End of test#49771 +# +# lp:872702: Crash in add_ref_to_table_cond() when grouping by a PK +# +CREATE TABLE t1 (a int, PRIMARY KEY (a)) ; +INSERT INTO t1 VALUES (14),(15),(16),(17),(18),(19),(20); +CREATE TABLE t2 (a int) ; +SELECT a +FROM t1 +WHERE a = ( +SELECT t2.a +FROM t2 +) OR t1.a = 73 +GROUP BY 1; +a +DROP TABLE t1, t2; diff --git a/mysql-test/r/group_min_max.result b/mysql-test/r/group_min_max.result index 3affad5b7de..047ae5e1307 100644 --- a/mysql-test/r/group_min_max.result +++ b/mysql-test/r/group_min_max.result @@ -1432,7 +1432,7 @@ group by a1,a2,b; id select_type table type possible_keys key key_len ref rows Extra 1 PRIMARY t1 range NULL idx_t1_1 147 NULL 17 Using where; Using index for group-by 2 DEPENDENT SUBQUERY t2 index NULL idx_t2_1 163 NULL 164 Using where; Using index -3 DEPENDENT SUBQUERY t3 index NULL idx_t3_1 10 NULL 192 Using where; Using index +2 DEPENDENT SUBQUERY t3 index NULL idx_t3_1 10 NULL 192 Using where; Using index; FirstMatch(t2) select a1,a2,b,c,min(c), max(c) from t1 where exists ( select * from t2 where t2.c in (select c from t3 where t3.c > t1.b) and @@ -1489,7 +1489,7 @@ group by a1,a2,b; id select_type table type possible_keys key key_len ref rows Extra 1 PRIMARY t1 index NULL idx_t1_1 163 NULL 128 Using where; Using index 2 DEPENDENT SUBQUERY t2 index NULL idx_t2_1 163 NULL 164 Using where; Using index -3 DEPENDENT SUBQUERY t3 index NULL idx_t3_1 10 NULL 192 Using where; Using index +2 DEPENDENT SUBQUERY t3 index NULL idx_t3_1 10 NULL 192 Using where; Using index; FirstMatch(t2) select a1,a2,b,c,min(c), max(c) from t1 where exists ( select * from t2 where t2.c in (select c from t3 where t3.c > t1.c) and @@ -2900,7 +2900,7 @@ NULL EXPLAIN SELECT MIN( a ) FROM t1 WHERE a = (SELECT a FROM t1 WHERE a < 0); id select_type table type possible_keys key key_len ref rows Extra -x x x x x x x x x Impossible WHERE noticed after reading const tables +x x x x x x x x x Using where; Using index x x x x x x x x x Using where; Using index SELECT MIN( a ) FROM t1 WHERE a = (SELECT a FROM t1 WHERE a < 0); MIN( a ) diff --git a/mysql-test/r/having.result b/mysql-test/r/having.result index 68e4c12f278..1c9c8016ea6 100644 --- a/mysql-test/r/having.result +++ b/mysql-test/r/having.result @@ -419,7 +419,7 @@ select f1 from t1 group by f1 having max(f1)=f1; f1 set session sql_mode='ONLY_FULL_GROUP_BY'; select f1 from t1 having max(f1)=f1; -ERROR 42000: non-grouping field 'f1' is used in HAVING clause +ERROR 42000: Non-grouping field 'f1' is used in HAVING clause select f1 from t1 group by f1 having max(f1)=f1; f1 set session sql_mode=''; diff --git a/mysql-test/r/heap.result b/mysql-test/r/heap.result index ed8ada1b4cc..f058c9f9c72 100644 --- a/mysql-test/r/heap.result +++ b/mysql-test/r/heap.result @@ -715,8 +715,8 @@ create table t1 (c char(10)) engine=memory; create table t2 (c varchar(10)) engine=memory; show table status like 't_'; Name Engine Version Row_format Rows Avg_row_length Data_length Max_data_length Index_length Data_free Auto_increment Create_time Update_time Check_time Collation Checksum Create_options Comment -t1 MEMORY 10 Fixed 0 11 0 # 0 0 NULL NULL NULL NULL latin1_swedish_ci NULL -t2 MEMORY 10 Fixed 0 12 0 # 0 0 NULL NULL NULL NULL latin1_swedish_ci NULL +t1 MEMORY 10 Fixed 0 11 0 # 0 0 NULL # NULL NULL latin1_swedish_ci NULL +t2 MEMORY 10 Fixed 0 12 0 # 0 0 NULL # NULL NULL latin1_swedish_ci NULL drop table t1, t2; CREATE TABLE t1(a VARCHAR(1), b VARCHAR(2), c VARCHAR(256), KEY(a), KEY(b), KEY(c)) ENGINE=MEMORY; diff --git a/mysql-test/r/index_merge_myisam.result b/mysql-test/r/index_merge_myisam.result index 3db268a18b1..00c924988da 100644 --- a/mysql-test/r/index_merge_myisam.result +++ b/mysql-test/r/index_merge_myisam.result @@ -1594,4 +1594,24 @@ id select_type table type possible_keys key key_len ref rows Extra 1 SIMPLE t1 index_merge a,b,c a,c 5,5 NULL 54 Using sort_union(a,c); Using where set optimizer_switch=default; drop table t0, t1; +# +# BUG#834514 Assertion `!table || (!table->read_set || bitmap_is_set(...' with aggregates +# +CREATE TABLE t1 ( a int , b int, c int, KEY (b), PRIMARY KEY (a)) ; +INSERT INTO t1 VALUES (1,4,0),(5,0,0),(6,7,0),(7,7,0),(8,1,0),(9,7,0),(10,1,0); +CREATE TABLE t2 ( b int, c int, KEY (c,b)) ; +INSERT INTO t2 VALUES (7,0),(1,0),(7,0),(1,0); +CREATE TABLE t3 ( a int ) ; +SELECT COUNT(DISTINCT t2.b), CONCAT(t1.c) +FROM t1, t2 +WHERE (t2.c = t1.c) +AND ( +t1.b IN ( 4 ) +OR t1.a = 137 +AND EXISTS ( SELECT a FROM t3 ) +) +GROUP BY 2; +COUNT(DISTINCT t2.b) CONCAT(t1.c) +2 0 +DROP TABLE t1,t2,t3; set optimizer_switch= @optimizer_switch_save; diff --git a/mysql-test/r/information_schema.result b/mysql-test/r/information_schema.result index d75c668c819..170cc855e29 100644 --- a/mysql-test/r/information_schema.result +++ b/mysql-test/r/information_schema.result @@ -1814,5 +1814,119 @@ unlock tables; drop table t1; drop view v1; # +# Test for bug #12828477 - "MDL SUBSYSTEM CREATES BIG OVERHEAD FOR +# CERTAIN QUERIES TO INFORMATION_SCHEMA". +# +# Check that metadata locks which are acquired during the process +# of opening tables/.FRMs/.TRG files while filling I_S table are +# not kept to the end of statement. Keeping the locks has caused +# performance problems in cases when big number of tables (.FRMs +# or .TRG files) were scanned as cost of new lock acquisition has +# increased linearly. +drop database if exists mysqltest; +create database mysqltest; +use mysqltest; +create table t0 (i int); +create table t1 (j int); +create table t2 (k int); +# +# Test that we don't keep locks in case when we to fill +# I_S table we perform full-blown table open. +# +# Acquire lock on 't2' so upcoming RENAME is +# blocked. +lock tables t2 read; +# +# Switching to connection 'con12828477_1'. +# +# The below RENAME should wait on 't2' while +# keeping X lock on 't1'. +rename table t1 to t3, t2 to t1, t3 to t2; +# +# Switching to connection 'con12828477_2'. +# +# Wait while the above RENAME is blocked. +# Issue query to I_S which will open 't0' and get +# blocked on 't1' because of RENAME. +select table_name, auto_increment from information_schema.tables where table_schema='mysqltest'; +# +# Switching to connection 'con12828477_3'. +# +# Wait while the above SELECT is blocked. +# +# Check that it holds no lock on 't0' so it can be renamed. +rename table t0 to t4; +# +# Switching to connection 'default'. +# +# +# Unblock the first RENAME. +unlock tables; +# +# Switching to connection 'con12828477_1'. +# +# Reap the first RENAME +# +# Switching to connection 'con12828477_2'. +# +# Reap SELECT to I_S. +table_name auto_increment +t0 NULL +t1 NULL +t2 NULL +# +# Switching to connection 'default'. +# +# +# Now test that we don't keep locks in case when we to fill +# I_S table we read .FRM or .TRG file only (this was the case +# for which problem existed). +# +rename table t4 to t0; +# Acquire lock on 't2' so upcoming RENAME is +# blocked. +lock tables t2 read; +# +# Switching to connection 'con12828477_1'. +# +# The below RENAME should wait on 't2' while +# keeping X lock on 't1'. +rename table t1 to t3, t2 to t1, t3 to t2; +# +# Switching to connection 'con12828477_2'. +# +# Wait while the above RENAME is blocked. +# Issue query to I_S which will open 't0' and get +# blocked on 't1' because of RENAME. +select event_object_table, trigger_name from information_schema.triggers where event_object_schema='mysqltest'; +# +# Switching to connection 'con12828477_3'. +# +# Wait while the above SELECT is blocked. +# +# Check that it holds no lock on 't0' so it can be renamed. +rename table t0 to t4; +# +# Switching to connection 'default'. +# +# +# Unblock the first RENAME. +unlock tables; +# +# Switching to connection 'con12828477_1'. +# +# Reap the first RENAME +# +# Switching to connection 'con12828477_2'. +# +# Reap SELECT to I_S. +event_object_table trigger_name +# +# Switching to connection 'default'. +# +# +# Clean-up. +drop database mysqltest; +# # End of 5.5 tests # diff --git a/mysql-test/r/information_schema_all_engines.result b/mysql-test/r/information_schema_all_engines.result index 013d480c8e1..9ea7c947100 100644 --- a/mysql-test/r/information_schema_all_engines.result +++ b/mysql-test/r/information_schema_all_engines.result @@ -54,11 +54,11 @@ INNODB_BUFFER_POOL_PAGES_BLOB INNODB_SYS_TABLES INNODB_SYS_FIELDS INNODB_SYS_COLUMNS -INNODB_TABLE_STATS INNODB_SYS_STATS INNODB_SYS_FOREIGN INNODB_SYS_INDEXES XTRADB_ADMIN_COMMAND +INNODB_TABLE_STATS SELECT t.table_name, c1.column_name FROM information_schema.tables t INNER JOIN @@ -127,11 +127,11 @@ INNODB_BUFFER_POOL_PAGES_BLOB space_id INNODB_SYS_TABLES SCHEMA INNODB_SYS_FIELDS INDEX_ID INNODB_SYS_COLUMNS TABLE_ID -INNODB_TABLE_STATS table_schema INNODB_SYS_STATS INDEX_ID INNODB_SYS_FOREIGN ID INNODB_SYS_INDEXES INDEX_ID XTRADB_ADMIN_COMMAND result_message +INNODB_TABLE_STATS table_schema SELECT t.table_name, c1.column_name FROM information_schema.tables t INNER JOIN @@ -200,11 +200,11 @@ INNODB_BUFFER_POOL_PAGES_BLOB space_id INNODB_SYS_TABLES SCHEMA INNODB_SYS_FIELDS INDEX_ID INNODB_SYS_COLUMNS TABLE_ID -INNODB_TABLE_STATS table_schema INNODB_SYS_STATS INDEX_ID INNODB_SYS_FOREIGN ID INNODB_SYS_INDEXES INDEX_ID XTRADB_ADMIN_COMMAND result_message +INNODB_TABLE_STATS table_schema select 1 as f1 from information_schema.tables where "CHARACTER_SETS"= (select cast(table_name as char) from information_schema.tables order by table_name limit 1) limit 1; @@ -340,11 +340,11 @@ Database: information_schema | INNODB_SYS_TABLES | | INNODB_SYS_FIELDS | | INNODB_SYS_COLUMNS | -| INNODB_TABLE_STATS | | INNODB_SYS_STATS | | INNODB_SYS_FOREIGN | | INNODB_SYS_INDEXES | | XTRADB_ADMIN_COMMAND | +| INNODB_TABLE_STATS | +---------------------------------------+ Database: INFORMATION_SCHEMA +---------------------------------------+ @@ -403,11 +403,11 @@ Database: INFORMATION_SCHEMA | INNODB_SYS_TABLES | | INNODB_SYS_FIELDS | | INNODB_SYS_COLUMNS | -| INNODB_TABLE_STATS | | INNODB_SYS_STATS | | INNODB_SYS_FOREIGN | | INNODB_SYS_INDEXES | | XTRADB_ADMIN_COMMAND | +| INNODB_TABLE_STATS | +---------------------------------------+ Wildcard: inf_rmation_schema +--------------------+ diff --git a/mysql-test/r/innodb_bug878769.result b/mysql-test/r/innodb_bug878769.result new file mode 100644 index 00000000000..db7ba3d2ee4 --- /dev/null +++ b/mysql-test/r/innodb_bug878769.result @@ -0,0 +1,57 @@ +drop table if exists t1,t2; +# +# Bug #878769: valgrind complains when using join cache +# to join an InnoDB table without primary key +# +CREATE TABLE t1 ( +col_int_key int(11), col_time_key time, col_varchar_key varchar(1), +KEY (col_int_key), KEY (col_varchar_key,col_int_key) +) ENGINE=InnoDB; +INSERT IGNORE INTO t1 VALUES +(7,'10:19:31','d'),(1,'14:40:36','r'),(7,'04:37:47','f'),(9,'19:34:06','y'), +(2,'00:00:00','m'),(4,'00:13:25','q'),(0,'03:47:16',NULL),(4,'01:41:48','d'), +(8,'00:00:00','g'),(NULL,'22:32:04','x'),(NULL,'16:44:14','f'), +(0,'17:38:37','p'),(NULL,'08:46:48','j'),(8,'14:11:27','c'); +CREATE TABLE t2 ( +col_int_nokey int(11), col_int_key int(11), +col_datetime_key datetime, col_datetime_nokey datetime, +col_varchar_key varchar(1), col_varchar_nokey varchar(1), +KEY (col_int_key), KEY (col_varchar_key,col_int_key) +); +INSERT IGNORE INTO t2 VALUES +(150,62,'2008-01-03 10:33:32','2008-01-03 10:33:32','v','v'), +(2,1,'2007-10-09 19:53:04','2007-10-09 19:53:04',NULL,NULL), +(5,0,'2001-11-08 21:02:12','2001-11-08 21:02:12','x','x'), +(3,7,'2003-04-01 00:00','2003-04-01 00:00','i','i'), +(1,7,'1900-01-01 00:00','1900-01-01 00:00:00','e','e'), +(NULL,7,'2005-04-04 01:21','2005-04-04 01:21','s','s'), +(2,1,'1900-01-01 00:00','1900-01-01 00:00','j','j'), +(8,0,'2004-04-28 21:44','2004-04-28 21:44','a','a'), +(6,8,'2001-04-18 00:00','2001-04-18 00:00:00','y','y'), +(8,1,'2008-12-18 19:39:55','2008-12-18 19:39:55',NULL,NULL), +(3,1,'2000-08-01 12:19:39','2000-08-01 12:19:39','r','r'), +(3,9,'2004-09-25 21:29:06','2004-09-25 21:29:06','v','v'); +set session optimizer_switch='mrr=on,mrr_sort_keys=on'; +set session join_cache_level=6; +EXPLAIN +SELECT t1.col_time_key, t1.col_varchar_key +FROM t2 STRAIGHT_JOIN t1 ON t1.col_int_key = t2.col_int_key +GROUP BY 1,2; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t2 index col_int_key col_int_key 5 NULL 12 Using where; Using index; Using temporary; Using filesort +1 SIMPLE t1 ref col_int_key col_int_key 5 test.t2.col_int_key 1 Using join buffer (flat, BKA join); Key-ordered Rowid-ordered scan +SELECT t1.col_time_key, t1.col_varchar_key +FROM t2 STRAIGHT_JOIN t1 ON t1.col_int_key = t2.col_int_key +GROUP BY 1,2; +col_time_key col_varchar_key +00:00:00 g +03:47:16 NULL +04:37:47 f +10:19:31 d +14:11:27 c +14:40:36 r +17:38:37 p +19:34:06 y +set session optimizer_switch=default; +set session join_cache_level=default; +DROP TABLE t1,t2; diff --git a/mysql-test/r/innodb_icp.result b/mysql-test/r/innodb_icp.result index 6df834168fa..b3b59bcdea6 100644 --- a/mysql-test/r/innodb_icp.result +++ b/mysql-test/r/innodb_icp.result @@ -83,6 +83,150 @@ c1 c2 c3 c4 DROP TABLE t1; # +# Bug#43617 - Innodb returns wrong results with timestamp's range value +# in IN clause +# (Note: Fixed by patch for BUG#42580) +# +CREATE TABLE t1( +c1 TIMESTAMP NOT NULL, +c2 TIMESTAMP NULL, +c3 DATE, +c4 DATETIME, +PRIMARY KEY(c1), +UNIQUE INDEX(c2) +); +INSERT INTO t1 VALUES +('0000-00-00 00:00:00','0000-00-00 00:00:00','2008-01-04','2008-01-05 00:00:00'), +('1971-01-01 00:00:01','1980-01-01 00:00:01','2009-01-01','2009-01-02 00:00:00'), +('1999-01-01 00:00:00','1999-01-01 00:00:00', NULL, NULL), +('2007-05-23 09:15:28','2007-05-23 09:15:28','2007-05-24','2007-05-24 09:15:28'), +('2007-05-27 00:00:00','2007-05-25 00:00:00','2007-05-26','2007-05-26 00:00:00'), +('2008-01-01 00:00:00', NULL, '2008-01-02','2008-01-03 00:00:00'), +('2009-01-29 11:11:27','2009-01-29 11:11:27','2009-01-29','2009-01-29 11:11:27'), +('2038-01-09 03:14:07','2038-01-09 03:14:07','2009-01-05','2009-01-06 00:00:00'); + +SELECT * +FROM t1 +WHERE c2 IN ('1971-01-01 00:00:01','2038-01-09 03:14:07') +ORDER BY c2; +c1 c2 c3 c4 +2038-01-09 03:14:07 2038-01-09 03:14:07 2009-01-05 2009-01-06 00:00:00 + +SELECT * +FROM t1 +WHERE c2 IN ('1971-01-01 00:00:01','2038-01-09 03:14:07') +ORDER BY c2 LIMIT 2; +c1 c2 c3 c4 +2038-01-09 03:14:07 2038-01-09 03:14:07 2009-01-05 2009-01-06 00:00:00 + +SELECT * +FROM t1 +WHERE c2 IN ('1971-01-01 00:00:01','2038-01-09 03:14:07') +ORDER BY c2 DESC; +c1 c2 c3 c4 +2038-01-09 03:14:07 2038-01-09 03:14:07 2009-01-05 2009-01-06 00:00:00 + +SELECT * +FROM t1 +WHERE c2 IN ('1971-01-01 00:00:01','2038-01-09 03:14:07') +ORDER BY c2 DESC LIMIT 2; +c1 c2 c3 c4 +2038-01-09 03:14:07 2038-01-09 03:14:07 2009-01-05 2009-01-06 00:00:00 + +DROP TABLE t1; +# +# BUG#43618: MyISAM&Maria returns wrong results with 'between' +# on timestamp +# +CREATE TABLE t1( +ts TIMESTAMP NOT NULL, +c char NULL, +PRIMARY KEY(ts) +); +INSERT INTO t1 VALUES +('1971-01-01','a'), +('2007-05-25','b'), +('2008-01-01','c'), +('2038-01-09','d'); + +# Execute select with invalid timestamp, desc ordering +SELECT * +FROM t1 +WHERE ts BETWEEN '0000-00-00' AND '2010-00-01 00:00:00' +ORDER BY ts DESC +LIMIT 2; +ts c +2008-01-01 00:00:00 c +2007-05-25 00:00:00 b + +# Should use index condition +EXPLAIN +SELECT * +FROM t1 +WHERE ts BETWEEN '0000-00-00' AND '2010-00-01 00:00:00' +ORDER BY ts DESC +LIMIT 2; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t1 range PRIMARY PRIMARY 4 NULL 4 Using index condition + +DROP TABLE t1; +# +# BUG#49906: Assertion failed - Field_varstring::val_str in field.cc +# (Note: Fixed by patch for LP BUG#625841) +# +CREATE TABLE t1 ( +f1 VARCHAR(1024), +f2 VARCHAR(10), +INDEX test_idx USING BTREE (f2,f1(5)) +); +INSERT INTO t1 VALUES ('a','c'), ('b','d'); +SELECT f1 +FROM t1 +WHERE f2 LIKE 'd' +ORDER BY f1; +f1 +b +DROP TABLE t1; +# +# Bug#52660 - "Perf. regr. using ICP for MyISAM on range queries on +# an index containing TEXT" +# +CREATE TABLE t1 (a INT); +INSERT INTO t1 VALUES (0),(1),(2),(3),(4),(5),(6),(7),(8),(9); +CREATE TABLE t2 (a INT); +INSERT INTO t2 SELECT A.a + 10*(B.a) FROM t1 A, t1 B; +CREATE TABLE t3 ( +c1 TINYTEXT NOT NULL, +i1 INT NOT NULL, +KEY (c1(6),i1) +); +INSERT INTO t3 SELECT CONCAT('c-',1000+t2.a,'=w'), 1 FROM t2; +EXPLAIN +SELECT c1 FROM t3 WHERE c1 >= 'c-1004=w' and c1 <= 'c-1006=w'; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t3 range c1 c1 8 NULL 3 Using where +SELECT c1 FROM t3 WHERE c1 >= 'c-1004=w' and c1 <= 'c-1006=w'; +c1 +c-1004=w +c-1005=w +c-1006=w +EXPLAIN +SELECT c1 FROM t3 WHERE c1 >= 'c-1004=w' and c1 <= 'c-1006=w' and i1 > 2; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t3 range c1 c1 12 NULL 2 Using index condition; Using where +SELECT c1 FROM t3 WHERE c1 >= 'c-1004=w' and c1 <= 'c-1006=w' and i1 > 2; +c1 +EXPLAIN +SELECT c1 FROM t3 WHERE c1 >= 'c-1004=w' and c1 <= 'c-1006=w' or i1 > 2; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t3 ALL c1 NULL NULL NULL 100 Using where +SELECT c1 FROM t3 WHERE c1 >= 'c-1004=w' and c1 <= 'c-1006=w' or i1 > 2; +c1 +c-1004=w +c-1005=w +c-1006=w +DROP TABLE t1, t2, t3; +# # Bug#40992 - InnoDB: Crash when engine_condition_pushdown is on # CREATE TABLE t ( @@ -203,6 +347,260 @@ COUNT(*) DROP PROCEDURE insert_data; DROP TABLE t1, t2, t3; # +# Bug#57372 "Multi-table updates and deletes fail when running with ICP +# against InnoDB" +# +CREATE TABLE t1 ( +a INT KEY, +b INT +); +CREATE TABLE t2 ( +a INT KEY, +b INT +); +INSERT INTO t1 VALUES (1, 101), (2, 102), (3, 103), (4, 104), (5, 105); +INSERT INTO t2 VALUES (1, 1), (2, 2), (3, 3), (4, 4), (5, 5); +UPDATE t1, t2 +SET t1.a = t1.a + 100, t2.b = t1.a + 10 +WHERE t1.a BETWEEN 2 AND 4 AND t2.a = t1.b - 100; +SELECT * FROM t1; +a b +1 101 +102 102 +103 103 +104 104 +5 105 +SELECT * FROM t2; +a b +1 1 +2 12 +3 13 +4 14 +5 5 +DROP TABLE t1, t2; +# +# Bug#52605 - "Adding LIMIT 1 clause to query with complex range +# predicate causes wrong results" +# +CREATE TABLE t1 ( +pk INT NOT NULL, +c1 INT, +PRIMARY KEY (pk), +KEY k1 (c1) +); +INSERT INTO t1 VALUES (1,NULL); +INSERT INTO t1 VALUES (2,6); +INSERT INTO t1 VALUES (3,NULL); +INSERT INTO t1 VALUES (4,6); +INSERT INTO t1 VALUES (5,NULL); +INSERT INTO t1 VALUES (6,NULL); +INSERT INTO t1 VALUES (7,9); +INSERT INTO t1 VALUES (8,0); +SELECT pk, c1 +FROM t1 +WHERE (pk BETWEEN 4 AND 5 OR pk < 2) AND c1 < 240 +ORDER BY c1 +LIMIT 1; +pk c1 +4 6 +EXPLAIN SELECT pk, c1 +FROM t1 +WHERE (pk BETWEEN 4 AND 5 OR pk < 2) AND c1 < 240 +ORDER BY c1 +LIMIT 1; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t1 range PRIMARY,k1 k1 5 NULL 3 Using where; Using index +DROP TABLE t1; +# +# Bug#59259 "Incorrect rows returned for a correlated subquery +# when ICP is on" +# +CREATE TABLE t1 (pk INTEGER PRIMARY KEY, i INTEGER NOT NULL) ENGINE=InnoDB; +INSERT INTO t1 VALUES (11,0); +INSERT INTO t1 VALUES (12,5); +INSERT INTO t1 VALUES (15,0); +CREATE TABLE t2 (pk INTEGER PRIMARY KEY, i INTEGER NOT NULL) ENGINE=InnoDB; +INSERT INTO t2 VALUES (11,1); +INSERT INTO t2 VALUES (12,2); +INSERT INTO t2 VALUES (15,4); +set @save_optimizer_switch= @@optimizer_switch; +set optimizer_switch='semijoin=off'; +EXPLAIN +SELECT * FROM t1 +WHERE pk IN (SELECT it.pk FROM t2 JOIN t2 AS it ON it.i=it.i WHERE it.pk-t1.i<10); +id select_type table type possible_keys key key_len ref rows Extra +1 PRIMARY t1 ALL NULL NULL NULL NULL 3 Using where +2 DEPENDENT SUBQUERY t2 index NULL PRIMARY 4 NULL 3 Using index +2 DEPENDENT SUBQUERY it eq_ref PRIMARY PRIMARY 4 func 1 Using index condition +SELECT * FROM t1 +WHERE pk IN (SELECT it.pk FROM t2 JOIN t2 AS it ON it.i=it.i WHERE it.pk-t1.i<10); +pk i +12 5 +set optimizer_switch=@save_optimizer_switch; +DROP TABLE t1, t2; +# +# Bug #58816 "Extra temporary duplicate rows in result set when +# switching ICP off" +# +set @save_optimizer_switch= @@optimizer_switch; +CREATE TABLE t1 ( +pk INT NOT NULL, +c1 INT NOT NULL, +PRIMARY KEY (pk) +); +INSERT INTO t1 VALUES (1,9),(2,7),(3,6),(4,3),(5,1); +EXPLAIN SELECT pk, c1 FROM t1 WHERE pk <> 3; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t1 range PRIMARY PRIMARY 4 NULL 4 Using index condition +SET SESSION optimizer_switch='index_condition_pushdown=off'; +SELECT pk, c1 FROM t1 WHERE pk <> 3; +pk c1 +1 9 +2 7 +4 3 +5 1 +DROP TABLE t1; +set optimizer_switch= @save_optimizer_switch; +# +# Bug#58837: ICP crash or valgrind error due to uninitialized +# value in innobase_index_cond +# +CREATE TABLE t1 ( +t1_int INT, +t1_time TIME +); +CREATE TABLE t2 ( +t2_int int PRIMARY KEY, +t2_int2 INT +); +INSERT INTO t2 VALUES (); +INSERT INTO t1 VALUES (); +SELECT * FROM t1 AS t1a +WHERE NOT EXISTS (SELECT * FROM t1 AS t1b +WHERE t1b.t1_int NOT IN +(SELECT t2.t2_int FROM t2 +WHERE t1b.t1_time LIKE t1b.t1_int +OR t1b.t1_time <> t2.t2_int2 +AND 6=7)); +t1_int t1_time +DROP TABLE t1,t2; +# +# Bug#59186: Wrong results of join when ICP is enabled +# (fixed by the patch for LP bug #694092) +# +CREATE TABLE t1 ( +pk INTEGER NOT NULL, +c1 VARCHAR(3) NOT NULL, +PRIMARY KEY (pk) +); +INSERT INTO t1 VALUES (1,'y'),(0,'or'); +CREATE TABLE t2 ( +pk INTEGER NOT NULL, +c1 VARCHAR(3) NOT NULL, +c2 VARCHAR(6) NOT NULL, +PRIMARY KEY (pk) +); +INSERT INTO t2 VALUES (6,'y','RPOYT'),(10,'m','JINQE'); +EXPLAIN +SELECT c2 FROM t1 JOIN t2 ON t1.c1 = t2.c1 +WHERE (t2.pk <= 4 AND t1.pk IN (2,1)) OR +(t1.pk > 1 AND t2.pk BETWEEN 6 AND 6); +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t1 range PRIMARY PRIMARY 4 NULL 1 Using index condition; Using where +1 SIMPLE t2 range PRIMARY PRIMARY 4 NULL 2 Using index condition; Using where; Using join buffer (flat, BNL join) +SELECT c2 FROM t1 JOIN t2 ON t1.c1 = t2.c1 +WHERE (t2.pk <= 4 AND t1.pk IN (2,1)) OR +(t1.pk > 1 AND t2.pk BETWEEN 6 AND 6); +c2 +DROP TABLE t1, t2; +# +# Bug#58838: "Wrong results with HAVING + LIMIT without GROUP BY when +# ICP is enabled". +# (Fixed by the patches for LP bugs #668644, #702322) +# +CREATE TABLE t1 ( +pk INT NOT NULL, +c1 INT, +PRIMARY KEY (pk), +KEY col_int_key (c1) +); +INSERT INTO t1 VALUES (1,37),(2,8),(3,-25),(4,NULL),(5,55); +SELECT pk FROM t1 WHERE c1 <> 1 HAVING pk = 3 ORDER BY pk LIMIT 0; +pk +SELECT pk FROM t1 WHERE c1 <> 1 HAVING pk = 3 ORDER BY pk LIMIT 1; +pk +3 +SELECT pk FROM t1 WHERE c1 <> 1 HAVING pk = 3 ORDER BY pk LIMIT 2; +pk +3 +SELECT pk FROM t1 WHERE c1 <> 1 HAVING pk = 3 ORDER BY pk LIMIT 5; +pk +3 +DROP TABLE t1; +# +# Bug#59483 "Crash on INSERT/REPLACE in +# rec_convert_dtuple_to_rec_comp with ICP on" +# +CREATE TABLE t1 ( +pk INTEGER AUTO_INCREMENT PRIMARY KEY, +i1 INTEGER, +c1 CHAR(6), +i2 INTEGER NOT NULL, +KEY (i2) +); +INSERT INTO t1 VALUES +(NULL, 4, 'that', 8), +(NULL, 1, 'she', 6), +(NULL, 6, 'tell', 2); +SELECT * FROM t1 WHERE i2 IN (3, 6) LIMIT 2 FOR UPDATE; +pk i1 c1 i2 +2 1 she 6 +INSERT INTO t1 (i2) VALUES (1); +DROP TABLE t1; +# +# Bug #11766678 - 59843: +# USING UNINITIALISED VALUE IN USES_INDEX_FIELDS_ONLY +# +CREATE TABLE t1 ( +col999 FLOAT NOT NULL, +COL1000 VARBINARY(179) NOT NULL, +col1003 DATE DEFAULT NULL, +KEY idx4267 (col1000, col1003) +); +INSERT INTO t1 VALUES (),(); +Warnings: +Warning 1364 Field 'col999' doesn't have a default value +Warning 1364 Field 'COL1000' doesn't have a default value +SELECT col999 FROM t1 WHERE col1000 = "3" AND col1003 <=> sysdate(); +col999 +DROP TABLE t1; +# +# BUG#12822678 - ICP WITH STRAIGHT_JOIN +# +CREATE TABLE t1 ( +i1 INTEGER NOT NULL, +d1 DOUBLE, +KEY k1 (d1) +); +INSERT INTO t1 VALUES (10,1), (17,NULL), (22,NULL); +CREATE TABLE t2 ( +pk INTEGER NOT NULL, +i1 INTEGER NOT NULL, +PRIMARY KEY (pk) +); +INSERT INTO t2 VALUES (4,1); +EXPLAIN +SELECT t1.d1, t2.pk, t2.i1 FROM t1 STRAIGHT_JOIN t2 ON t2.i1 +WHERE t2.pk <> t1.d1 AND t2.pk = 4; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t1 index NULL k1 9 NULL 3 Using index +1 SIMPLE t2 const PRIMARY PRIMARY 4 const 1 Using where +SELECT t1.d1, t2.pk, t2.i1 FROM t1 STRAIGHT_JOIN t2 ON t2.i1 +WHERE t2.pk <> t1.d1 AND t2.pk = 4; +d1 pk i1 +1 4 1 +DROP TABLE t1, t2; +# # BUG#778434 Wrong result with in_to_exists=on in maria-5.3-mwl89 # CREATE TABLE t1 ( f11 int) ; @@ -225,5 +623,83 @@ FROM t3 JOIN t4 ON t4.f11 = t3.f10 f11 f10 DROP TABLE t1,t2,t3,t4; set optimizer_switch= @tmp_778434; +# +# Bug#885168: ICP for one index + potential ORDER BY for another +# +CREATE TABLE t1 (a varchar(64), b varchar(10), INDEX(a), INDEX(b)) ; +INSERT INTO t1 VALUES +('Ohio','Iowa'), ('k','d'), ('bdkpj','mbdkpjdanp'), ('d','xdmbdkpjda'), +('fkxdmbdkpjdanpje','o'), ('f','Pennsylvan'), ('Virginia','ei'); +SET SESSION optimizer_switch='index_condition_pushdown=off'; +EXPLAIN +SELECT * FROM t1 +WHERE NOT(b = 'Texas') AND b BETWEEN 'wy' AND 'y' OR b = 'Pennsylvania' + ORDER BY a; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t1 range b b 13 NULL 2 Using where; Rowid-ordered scan; Using filesort +SELECT * FROM t1 +WHERE NOT(b = 'Texas') AND b BETWEEN 'wy' AND 'y' OR b = 'Pennsylvania' + ORDER BY a; +a b +d xdmbdkpjda +SET SESSION optimizer_switch='index_condition_pushdown=on'; +EXPLAIN +SELECT * FROM t1 +WHERE NOT(b = 'Texas') AND b BETWEEN 'wy' AND 'y' OR b = 'Pennsylvania' + ORDER BY a; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t1 range b b 13 NULL 2 Using index condition; Using where; Rowid-ordered scan; Using filesort +SELECT * FROM t1 +WHERE NOT(b = 'Texas') AND b BETWEEN 'wy' AND 'y' OR b = 'Pennsylvania' + ORDER BY a; +a b +d xdmbdkpjda +DROP TABLE t1; +# +# Bug#886145: join with ICP + ORDER BY +# +CREATE TABLE t1 (b int NOT NULL, c int, a varchar(1024), PRIMARY KEY (b)); +INSERT INTO t1 VALUES (1,4,'Ill'); +CREATE TABLE t2 (a varchar(1024), KEY (a(512))); +INSERT INTO t2 VALUES +('Ill'), ('eckqzsflbzaffti'), ('w'), ('she'), ('gxbwypqtjzwywwer'), ('w'); +SET SESSION optimizer_switch='index_condition_pushdown=off'; +EXPLAIN +SELECT t1.b, t1.c FROM t1, t2 WHERE t1.a = t2.a AND t1.b != 0 +HAVING t1.c != 5 ORDER BY t1.c; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t1 range PRIMARY PRIMARY 4 NULL 2 Using where; Using filesort +1 SIMPLE t2 ref a a 515 test.t1.a 1 Using where +SELECT t1.b, t1.c FROM t1, t2 WHERE t1.a = t2.a AND t1.b != 0 +HAVING t1.c != 5 ORDER BY t1.c; +b c +1 4 +SET SESSION optimizer_switch='index_condition_pushdown=on'; +EXPLAIN +SELECT t1.b, t1.c FROM t1, t2 WHERE t1.a = t2.a AND t1.b != 0 +HAVING t1.c != 5 ORDER BY t1.c; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t1 range PRIMARY PRIMARY 4 NULL 2 Using index condition; Using where; Using filesort +1 SIMPLE t2 ref a a 515 test.t1.a 1 Using where +SELECT t1.b, t1.c FROM t1, t2 WHERE t1.a = t2.a AND t1.b != 0 +HAVING t1.c != 5 ORDER BY t1.c; +b c +1 4 +DROP TABLE t1,t2; +# +# Bug#879871: InnoDB: possible ICP + GROUP BY primary index +# +CREATE TABLE t1 ( +a int NOT NULL, b int, c varchar(1), d varchar(1), +PRIMARY KEY (a), KEY c (c,b) +); +INSERT INTO t1 VALUES (10,8,'g','g'); +SET SESSION optimizer_switch='index_condition_pushdown=off'; +SELECT a FROM t1 WHERE c IS NULL AND d IS NOT NULL GROUP BY 1; +a +SET SESSION optimizer_switch='index_condition_pushdown=on'; +SELECT a FROM t1 WHERE c IS NULL AND d IS NOT NULL GROUP BY 1; +a +DROP TABLE t1; set optimizer_switch=@innodb_icp_tmp; set storage_engine= @save_storage_engine; diff --git a/mysql-test/r/join.result b/mysql-test/r/join.result index e95ed8c7cf2..0f7f2411c0c 100644 --- a/mysql-test/r/join.result +++ b/mysql-test/r/join.result @@ -1341,3 +1341,11 @@ WHERE t1.f1 IN (SELECT f1 FROM t1) AND t1.f1 = t2.f1 OR t1.f1 = 9; f1 f2 f1 f2 9 4 10 9 DROP TABLE t1,t2; +create table t1 (i time key); +insert into t1 values ('1:1:1'), ('2:2:2'); +create table t2 (i time); +insert into t2 values ('1:1:1'); +select t2.i from t1 left join t2 on t2.i = t1.i where t1.i = '1:1:1'; +i +01:01:01 +drop table t1,t2; diff --git a/mysql-test/r/join_cache.result b/mysql-test/r/join_cache.result index 0e616e259bc..1ef17b0763e 100644 --- a/mysql-test/r/join_cache.result +++ b/mysql-test/r/join_cache.result @@ -3037,12 +3037,12 @@ t1.metaid = t2.metaid AND t1.affiliateid = '2'; id select_type table type possible_keys key key_len ref rows Extra 1 SIMPLE t6 system PRIMARY NULL NULL NULL 1 1 SIMPLE t1 ref t1_affiliateid,t1_metaid t1_affiliateid 4 const 1 -1 SIMPLE t4 ref PRIMARY,t4_formatclassid,t4_formats_idx t4_formats_idx 1 const 1 Using index condition; Using where; Using join buffer (flat, BKA join); Key-ordered Rowid-ordered scan -1 SIMPLE t5 eq_ref PRIMARY,t5_formattypeid PRIMARY 4 test.t4.formatclassid 1 Using where; Using join buffer (incremental, BKA join); Key-ordered Rowid-ordered scan -1 SIMPLE t2 eq_ref PRIMARY PRIMARY 4 test.t1.metaid 1 Using join buffer (incremental, BKA join); Key-ordered Rowid-ordered scan +1 SIMPLE t2 eq_ref PRIMARY PRIMARY 4 test.t1.metaid 1 Using join buffer (flat, BKA join); Key-ordered Rowid-ordered scan 1 SIMPLE t7 ref PRIMARY PRIMARY 4 test.t1.metaid 1 Using index -1 SIMPLE t3 ref t3_metaid,t3_formatid,t3_metaidformatid t3_metaid 4 test.t1.metaid 2 Using where; Using join buffer (flat, BKA join); Key-ordered Rowid-ordered scan -1 SIMPLE t8 eq_ref PRIMARY PRIMARY 4 test.t7.artistid 1 Using join buffer (incremental, BKA join); Key-ordered Rowid-ordered scan +1 SIMPLE t8 eq_ref PRIMARY PRIMARY 4 test.t7.artistid 1 Using join buffer (flat, BKA join); Key-ordered Rowid-ordered scan +1 SIMPLE t3 ref t3_metaid,t3_formatid,t3_metaidformatid t3_metaidformatid 4 test.t1.metaid 1 Using index condition; Using join buffer (incremental, BKA join); Key-ordered Rowid-ordered scan +1 SIMPLE t4 eq_ref PRIMARY,t4_formatclassid,t4_formats_idx PRIMARY 4 test.t3.formatid 1 Using where; Using join buffer (incremental, BKA join); Key-ordered Rowid-ordered scan +1 SIMPLE t5 eq_ref PRIMARY,t5_formattypeid PRIMARY 4 test.t4.formatclassid 1 Using where; Using join buffer (incremental, BKA join); Key-ordered Rowid-ordered scan 1 SIMPLE t9 index PRIMARY,t9_subgenreid,t9_metaid PRIMARY 8 NULL 2 Using where; Using index; Using join buffer (incremental, BNL join) 1 SIMPLE t10 eq_ref PRIMARY,t10_genreid PRIMARY 4 test.t9.subgenreid 1 Using join buffer (incremental, BKA join); Key-ordered Rowid-ordered scan 1 SIMPLE t11 eq_ref PRIMARY PRIMARY 4 test.t10.genreid 1 Using join buffer (incremental, BKA join); Key-ordered Rowid-ordered scan @@ -3151,6 +3151,8 @@ CREATE TABLE t2 (a int, b int, INDEX idx(a)); INSERT INTO t1 VALUES (5,30), (3,20), (7,40), (2,10), (8,30), (1,10), (4,20); INSERT INTO t2 VALUES (7,10), (1,20), (2,20), (8,20), (8,10), (1,20); INSERT INTO t2 VALUES (1,10), (4,20), (3,20), (7,20), (7,10), (1,20); +INSERT INTO t2 VALUES (17,10), (11,20), (12,20), (18,20), (18,10), (11,20); +INSERT INTO t2 VALUES (11,10), (14,20), (13,20), (17,20), (17,10), (11,20); set join_buffer_size=32; Warnings: Warning 1292 Truncated incorrect join_buffer_size value: '32' @@ -3176,6 +3178,7 @@ CREATE TABLE t1 (a int NOT NULL); INSERT INTO t1 VALUES (2), (4), (3), (5), (1); CREATE TABLE t2 (a int NOT NULL, b int NOT NULL, INDEX i_a(a)); INSERT INTO t2 VALUES (4,10), (2,10), (2,30), (2,20), (4,20); +INSERT INTO t2 VALUES (14,10), (12,10), (15,30), (12,20), (14,20); EXPLAIN SELECT * FROM t1 LEFT JOIN t2 ON t1.a=t2.a WHERE t2.b IS NULL; id select_type table type possible_keys key key_len ref rows Extra @@ -3566,6 +3569,9 @@ create table t2 (id1 int, id2 int, index idx2 (id1)); insert into t2 values (20, 100), (30, 400), (20, 400), (30, 200), (10, 300), (10, 200), (40, 100), (40, 200), (30, 300), (10, 400), (20, 200), (20, 300); +insert into t2 values +(21, 10), (31, 400), (21, 400), (31, 200), (11, 300), (11, 200), (41, 100), +(41, 200), (31, 300), (11, 400), (21, 200), (21, 300); set join_cache_level=6; explain select t1.id1, sum(t2.id2) from t1 join t2 on t1.id1=t2.id1 @@ -3613,14 +3619,26 @@ insert into t2 values (30, 'bbb'), (10, 'b'), (70, 'bbbbbbb'), (60, 'bbbbbb'), (31, 'bbb'), (11, 'b'), (71, 'bbbbbbb'), (61, 'bbbbbb'), (32, 'bbb'), (12, 'b'), (72, 'bbbbbbb'), (62, 'bbbbbb'); +insert into t2 values +(130, 'bbb'), (110, 'b'), (170, 'bbbbbbb'), (160, 'bbbbbb'), +(131, 'bbb'), (111, 'b'), (171, 'bbbbbbb'), (161, 'bbbbbb'), +(132, 'bbb'), (112, 'b'), (172, 'bbbbbbb'), (162, 'bbbbbb'); insert into t3 values (4000, 'dddd'), (3000, 'ddd'), (1000, 'd'), (8000, 'dddddddd'), (4001, 'dddd'), (3001, 'ddd'), (1001, 'd'), (8001, 'dddddddd'), (4002, 'dddd'), (3002, 'ddd'), (1002, 'd'), (8002, 'dddddddd'); +insert into t3 values +(14000, 'dddd'), (13000, 'ddd'), (11000, 'd'), (18000, 'dddddddd'), +(14001, 'dddd'), (13001, 'ddd'), (11001, 'd'), (18001, 'dddddddd'), +(4002, 'dddd'), (3002, 'ddd'), (1002, 'd'), (8002, 'dddddddd'); insert into t4 values (200, 'cc'), (600, 'cccccc'), (300, 'ccc'), (500, 'ccccc'), (201, 'cc'), (601, 'cccccc'), (301, 'ccc'), (501, 'ccccc'), (202, 'cc'), (602, 'cccccc'), (302, 'ccc'), (502, 'ccccc'); +insert into t4 values +(1200, 'cc'), (1600, 'cccccc'), (1300, 'ccc'), (1500, 'ccccc'), +(1201, 'cc'), (1601, 'cccccc'), (1301, 'ccc'), (1501, 'ccccc'), +(1202, 'cc'), (1602, 'cccccc'), (1302, 'ccc'), (1502, 'ccccc'); analyze table t2,t3,t4; set join_cache_level=1; explain @@ -3968,7 +3986,9 @@ DROP TABLE t1,t2,t3,t4; CREATE TABLE t1 (b int); INSERT INTO t1 VALUES (NULL),(3); CREATE TABLE t2 (a int, b int, KEY (b)); -INSERT INTO t2 VALUES (100,NULL),(150,200); +INSERT INTO t2 VALUES +(100,NULL),(150,200),(50,150),(250,350),(180,210),(100,150), +(101,NULL),(151,200),(51,150),(251,350),(181,210),(101,150); set join_cache_level = 5; explain SELECT t2.a FROM t1 LEFT JOIN t2 ON t2.b = t1.b; id select_type table type possible_keys key key_len ref rows Extra @@ -4003,6 +4023,7 @@ CREATE TABLE t1 (b varchar(100)); INSERT INTO t1 VALUES (NULL),("some varchar"); CREATE TABLE t2 (a int, b varchar(100), KEY (b)); INSERT INTO t2 VALUES (100,NULL),(150,"varchar"),(200,NULL),(250,"long long varchar"); +INSERT INTO t2 VALUES (100,NULL),(150,"long varchar"),(200,"varchar"),(250,"long long long varchar"); set join_cache_level = 5; explain SELECT t2.a FROM t1 LEFT JOIN t2 ON t2.b = t1.b; id select_type table type possible_keys key key_len ref rows Extra @@ -4117,6 +4138,17 @@ INSERT INTO t3 VALUES (1,0,'2002-07-13','06:34:26','v','v'), (9,3,'2003-01-03','18:07:38','m','m'), (1,5,'2006-04-02','13:55:23','z','z'), (3,9,'2006-10-19','20:32:28','n','n'), (8,1,'2005-06-08','11:57:44','d','d'), (231,107,'2006-12-26','03:10:35','a','a'); +INSERT INTO t3 VALUES +(103,108,'2008-12-04','00:00:00','a','v'), (103,108,'2009-03-28','00:00:00','b','f'), +(103,105,'1900-01-01','00:55:47','c','v'), (102,108,'2009-10-02','00:00:00','d','s'), +(100,108,'1900-01-01','20:51:59','e','a'), (100,106,'2008-06-04','09:47:27','f','p'), +(108,107,'2009-01-13','21:58:29','g','z'), (105,102,'1900-01-01','22:45:53','h','a'), +(109,105,'2008-01-28','14:06:48','i','h'), (105,107,'2004-09-18','22:17:16','j','h'), +(104,102,'2006-10-14','14:59:37','k','v'), (102,109,'1900-01-01','23:37:40','l','v'), +(1033,1142,'2000-11-28','14:14:01','m','b'), (105,103,'2008-04-04','02:54:19','n','y'), +(100,100,'2002-07-13','06:34:26','o','v'), (109,103,'2003-01-03','18:07:38','p','m'), +(100,105,'2006-04-02','13:55:23','q','z'), (103,109,'2006-10-19','20:32:28','s','n'), +(108,100,'2005-06-08','11:57:44','t','d'), (1231,1107,'2006-12-26','03:10:35','v','a'); CREATE TABLE t1 SELECT * FROM t3; DELETE FROM t1 WHERE i > 8; CREATE TABLE t2 SELECT * FROM t3; @@ -4127,55 +4159,87 @@ WHERE t3.u <='a' AND t2.j < 5 AND t3.v = t2.u; id select_type table type possible_keys key key_len ref rows Extra 1 SIMPLE t1 ALL NULL NULL NULL NULL 16 1 SIMPLE t2 ALL NULL NULL NULL NULL 18 Using where; Using join buffer (flat, BNL join) -1 SIMPLE t3 hash_ALL idx #hash#idx 3 test.t2.u 20 Using where; Using join buffer (flat, BNLH join) +1 SIMPLE t3 hash_ALL idx #hash#idx 3 test.t2.u 40 Using where; Using join buffer (flat, BNLH join) SELECT t1.i, t1.d, t1.v, t2.i, t2.d, t2.t, t2.v FROM t1,t2,t3 WHERE t3.u <='a' AND t2.j < 5 AND t3.v = t2.u; i d v i d t v +0 2008-06-04 p 1 2002-07-13 06:34:26 v +0 2008-06-04 p 4 2006-10-14 14:59:37 v 0 2008-06-04 p 5 1900-01-01 22:45:53 a 0 2008-06-04 p 5 1900-01-01 22:45:53 a 0 2008-06-04 p 5 1900-01-01 22:45:53 a +1 1900-01-01 a 1 2002-07-13 06:34:26 v +1 1900-01-01 a 4 2006-10-14 14:59:37 v 1 1900-01-01 a 5 1900-01-01 22:45:53 a 1 1900-01-01 a 5 1900-01-01 22:45:53 a 1 1900-01-01 a 5 1900-01-01 22:45:53 a +1 2002-07-13 v 1 2002-07-13 06:34:26 v +1 2002-07-13 v 4 2006-10-14 14:59:37 v 1 2002-07-13 v 5 1900-01-01 22:45:53 a 1 2002-07-13 v 5 1900-01-01 22:45:53 a 1 2002-07-13 v 5 1900-01-01 22:45:53 a +1 2006-04-02 z 1 2002-07-13 06:34:26 v +1 2006-04-02 z 4 2006-10-14 14:59:37 v 1 2006-04-02 z 5 1900-01-01 22:45:53 a 1 2006-04-02 z 5 1900-01-01 22:45:53 a 1 2006-04-02 z 5 1900-01-01 22:45:53 a +2 1900-01-01 v 1 2002-07-13 06:34:26 v +2 1900-01-01 v 4 2006-10-14 14:59:37 v 2 1900-01-01 v 5 1900-01-01 22:45:53 a 2 1900-01-01 v 5 1900-01-01 22:45:53 a 2 1900-01-01 v 5 1900-01-01 22:45:53 a +2 2009-10-02 s 1 2002-07-13 06:34:26 v +2 2009-10-02 s 4 2006-10-14 14:59:37 v 2 2009-10-02 s 5 1900-01-01 22:45:53 a 2 2009-10-02 s 5 1900-01-01 22:45:53 a 2 2009-10-02 s 5 1900-01-01 22:45:53 a +3 1900-01-01 v 1 2002-07-13 06:34:26 v +3 1900-01-01 v 4 2006-10-14 14:59:37 v 3 1900-01-01 v 5 1900-01-01 22:45:53 a 3 1900-01-01 v 5 1900-01-01 22:45:53 a 3 1900-01-01 v 5 1900-01-01 22:45:53 a +3 2006-10-19 n 1 2002-07-13 06:34:26 v +3 2006-10-19 n 4 2006-10-14 14:59:37 v 3 2006-10-19 n 5 1900-01-01 22:45:53 a 3 2006-10-19 n 5 1900-01-01 22:45:53 a 3 2006-10-19 n 5 1900-01-01 22:45:53 a +3 2008-12-04 v 1 2002-07-13 06:34:26 v +3 2008-12-04 v 4 2006-10-14 14:59:37 v 3 2008-12-04 v 5 1900-01-01 22:45:53 a 3 2008-12-04 v 5 1900-01-01 22:45:53 a 3 2008-12-04 v 5 1900-01-01 22:45:53 a +3 2009-03-28 f 1 2002-07-13 06:34:26 v +3 2009-03-28 f 4 2006-10-14 14:59:37 v 3 2009-03-28 f 5 1900-01-01 22:45:53 a 3 2009-03-28 f 5 1900-01-01 22:45:53 a 3 2009-03-28 f 5 1900-01-01 22:45:53 a +4 2006-10-14 v 1 2002-07-13 06:34:26 v +4 2006-10-14 v 4 2006-10-14 14:59:37 v 4 2006-10-14 v 5 1900-01-01 22:45:53 a 4 2006-10-14 v 5 1900-01-01 22:45:53 a 4 2006-10-14 v 5 1900-01-01 22:45:53 a +5 1900-01-01 a 1 2002-07-13 06:34:26 v +5 1900-01-01 a 4 2006-10-14 14:59:37 v 5 1900-01-01 a 5 1900-01-01 22:45:53 a 5 1900-01-01 a 5 1900-01-01 22:45:53 a 5 1900-01-01 a 5 1900-01-01 22:45:53 a +5 2004-09-18 h 1 2002-07-13 06:34:26 v +5 2004-09-18 h 4 2006-10-14 14:59:37 v 5 2004-09-18 h 5 1900-01-01 22:45:53 a 5 2004-09-18 h 5 1900-01-01 22:45:53 a 5 2004-09-18 h 5 1900-01-01 22:45:53 a +5 2008-04-04 y 1 2002-07-13 06:34:26 v +5 2008-04-04 y 4 2006-10-14 14:59:37 v 5 2008-04-04 y 5 1900-01-01 22:45:53 a 5 2008-04-04 y 5 1900-01-01 22:45:53 a 5 2008-04-04 y 5 1900-01-01 22:45:53 a +8 2005-06-08 d 1 2002-07-13 06:34:26 v +8 2005-06-08 d 4 2006-10-14 14:59:37 v 8 2005-06-08 d 5 1900-01-01 22:45:53 a 8 2005-06-08 d 5 1900-01-01 22:45:53 a 8 2005-06-08 d 5 1900-01-01 22:45:53 a +8 2009-01-13 z 1 2002-07-13 06:34:26 v +8 2009-01-13 z 4 2006-10-14 14:59:37 v 8 2009-01-13 z 5 1900-01-01 22:45:53 a 8 2009-01-13 z 5 1900-01-01 22:45:53 a 8 2009-01-13 z 5 1900-01-01 22:45:53 a @@ -4193,7 +4257,15 @@ PRIMARY KEY (pk), INDEX idx1(i), INDEX idx2 (v,i) INSERT INTO t1 VALUES (10,8,'v'), (11,8,'f'), (12,5,'v'), (13,8,'s'), (14,8,'a'), (15,6,'p'), (16,7,'z'), (17,2,'a'), (18,5,'h'), (19,7,'h'), -(25,3,'m'), (26,5,'z'), (27,9,'n'), (28,1,'d'), (29,107,'a'); +(25,3,'m'), (26,5,'a'), (27,9,'n'), (28,1,'d'), (29,107,'a'); +INSERT INTO t1 VALUES +(110,8,'x'), (111,8,'y'), (112,5,'v'), (113,8,'z'), (114,8,'i'), +(115,6,'j'), (116,7,'t'), (117,2,'b'), (118,5,'j'), (119,7,'w'), +(125,3,'q'), (126,5,'o'), (127,9,'n'), (128,1,'e'), (129,107,'c'); +INSERT INTO t1 VALUES +(210,8,'b'), (211,8,'c'), (212,5,'d'), (213,8,'e'), (214,8,'g'), +(215,6,'f'), (216,7,'h'), (217,2,'i'), (218,5,'j'), (219,7,'k'), +(225,3,'l'), (226,5,'m'), (227,9,'n'), (228,1,'o'), (229,107,'p'); CREATE TABLE t2 ( pk int NOT NULL, i int NOT NULL, v varchar(1) NOT NULL, PRIMARY KEY (pk), INDEX idx1(i), INDEX idx2(v,i) @@ -4202,7 +4274,7 @@ INSERT INTO t2 VALUES (10,8,'v'), (11,8,'f'), (12,5,'v'), (13,8,'s'), (14,8,'a'), (15,6,'p'), (16,7,'z'), (17,2,'a'), (18,5,'h'), (19,7,'h'), (20,2,'v'), (21,9,'v'), (22,142,'b'), (23,3,'y'), (24,0,'v'), -(25,3,'m'), (26,5,'z'), (27,9,'n'), (28,1,'d'), (29,107,'a'); +(25,3,'m'), (26,5,'b'), (27,9,'n'), (28,1,'d'), (29,107,'a'); CREATE TABLE t3 ( pk int NOT NULL, i int NOT NULL, v varchar(1) NOT NULL, PRIMARY KEY (pk), INDEX idx1(i), INDEX idx2(v,i) @@ -4214,49 +4286,55 @@ INSERT INTO t3 VALUES (16,6,'e'), (17,3,'t'), (18,8,'j'), (19,5,'h'), (20,7,'w'); SET SESSION join_cache_level=1; EXPLAIN -SELECT t2.v FROM t1, t2, t3 WHERE t3.v <> t2.v AND t3.pk = t2.i AND t1.v = t3.v +SELECT t2.v FROM t1, t2, t3 +WHERE t3.v <> t2.v AND t3.pk = t2.i AND t1.v = t3.v AND t1.pk*2<100 GROUP BY t2.v ORDER BY t1.pk,t2.v; id select_type table type possible_keys key key_len ref rows Extra 1 SIMPLE t2 index idx1 idx2 7 NULL 20 Using index; Using temporary; Using filesort 1 SIMPLE t3 eq_ref PRIMARY,idx2 PRIMARY 4 test.t2.i 1 Using where -1 SIMPLE t1 ref idx2 idx2 3 test.t3.v 2 -SELECT t2.v FROM t1, t2, t3 WHERE t3.v <> t2.v AND t3.pk = t2.i AND t1.v = t3.v +1 SIMPLE t1 ref idx2 idx2 3 test.t3.v 5 Using where +SELECT t2.v FROM t1, t2, t3 +WHERE t3.v <> t2.v AND t3.pk = t2.i AND t1.v = t3.v AND t1.pk*2<100 GROUP BY t2.v ORDER BY t1.pk,t2.v; v +b h -z -p n v +p SET SESSION join_cache_level=6; EXPLAIN -SELECT t2.v FROM t1, t2, t3 WHERE t3.v <> t2.v AND t3.pk = t2.i AND t1.v = t3.v +SELECT t2.v FROM t1, t2, t3 +WHERE t3.v <> t2.v AND t3.pk = t2.i AND t1.v = t3.v AND t1.pk*2<100 GROUP BY t2.v ORDER BY t1.pk,t2.v; id select_type table type possible_keys key key_len ref rows Extra 1 SIMPLE t2 ALL idx1 NULL NULL NULL 20 Using temporary; Using filesort 1 SIMPLE t3 eq_ref PRIMARY,idx2 PRIMARY 4 test.t2.i 1 Using where; Using join buffer (flat, BKA join); Key-ordered Rowid-ordered scan -1 SIMPLE t1 ref idx2 idx2 3 test.t3.v 2 Using join buffer (incremental, BKA join); Key-ordered Rowid-ordered scan -SELECT t2.v FROM t1, t2, t3 WHERE t3.v <> t2.v AND t3.pk = t2.i AND t1.v = t3.v +1 SIMPLE t1 ref idx2 idx2 3 test.t3.v 5 Using where; Using join buffer (incremental, BKA join); Key-ordered Rowid-ordered scan +SELECT t2.v FROM t1, t2, t3 +WHERE t3.v <> t2.v AND t3.pk = t2.i AND t1.v = t3.v AND t1.pk*2<100 GROUP BY t2.v ORDER BY t1.pk,t2.v; v +b h -z n v p SET SESSION join_cache_level=4; EXPLAIN -SELECT t2.v FROM t1, t2, t3 WHERE t3.v <> t2.v AND t3.pk = t2.i AND t1.v = t3.v +SELECT t2.v FROM t1, t2, t3 +WHERE t3.v <> t2.v AND t3.pk = t2.i AND t1.v = t3.v AND t1.pk*2<100 GROUP BY t2.v ORDER BY t1.pk,t2.v; id select_type table type possible_keys key key_len ref rows Extra 1 SIMPLE t2 ALL idx1 NULL NULL NULL 20 Using temporary; Using filesort 1 SIMPLE t3 hash_ALL PRIMARY,idx2 #hash#PRIMARY 4 test.t2.i 20 Using where; Using join buffer (flat, BNLH join) -1 SIMPLE t1 hash_ALL idx2 #hash#idx2 3 test.t3.v 15 Using join buffer (incremental, BNLH join) -SELECT t2.v FROM t1, t2, t3 WHERE t3.v <> t2.v AND t3.pk = t2.i AND t1.v = t3.v +1 SIMPLE t1 hash_ALL idx2 #hash#idx2 3 test.t3.v 45 Using where; Using join buffer (incremental, BNLH join) +SELECT t2.v FROM t1, t2, t3 +WHERE t3.v <> t2.v AND t3.pk = t2.i AND t1.v = t3.v AND t1.pk*2<100 GROUP BY t2.v ORDER BY t1.pk,t2.v; v +b h -z n v p @@ -4323,13 +4401,18 @@ INSERT INTO t2 VALUES (1, 12, 102), (8, 81, 801), (7, 70, 700), (12, 120, 1200), (8, 82, 802), (1, 13, 103), (1, 14, 104), (3, 31, 301), (1, 15, 105), (8, 83, 803), (7, 71, 701); +INSERT INTO t2 VALUES +(108, 80, 800), (101, 10, 100), (101, 11, 101), (103, 30, 300), +(101, 12, 102), (108, 81, 801), (107, 70, 700), (1012, 120, 1200), +(108, 82, 802), (101, 13, 103), (101, 14, 104), (103, 31, 301), +(101, 15, 105), (108, 83, 803), (107, 71, 701); SET SESSION join_cache_level = 4; SET SESSION join_buffer_size = 256; EXPLAIN SELECT t1.a, t2.c FROM t1,t2 WHERE t1.a=t2.a AND t2.b=99; id select_type table type possible_keys key key_len ref rows Extra -1 SIMPLE t1 ALL NULL NULL NULL NULL 36 Using where -1 SIMPLE t2 hash_ALL idx #hash#idx 10 test.t1.a,const 15 Using join buffer (flat, BNLH join) +1 SIMPLE t1 ALL NULL NULL NULL NULL 36 +1 SIMPLE t2 ALL idx NULL NULL NULL 30 Using where; Using join buffer (flat, BNL join) SELECT t1.a, t2.c FROM t1,t2 WHERE t1.a=t2.a AND t2.b=99; a c SET SESSION join_cache_level = DEFAULT; @@ -4356,20 +4439,27 @@ INSERT INTO t2 VALUES ('abcdefjhjk',1015414784), ('or',4), ('now',0), ('abcdefjhjk',-32702464), ('abcdefjhjk',4), ('time',1078394880), ('f',4), ('m',-1845559296), ('ff', 5), ('abcdefjhjk',-1074397184); +INSERT INTO t2 VALUES +('dig',5), ('were',-1631322112), ('is',3), ('abcdefjhjl',3), +('abcdefjh',4), ('told',-824573952), ('tt',0),('vv',-1711013888), +('abcdefjhjj',1015414784), ('and',4), ('here',0), ('abcdefjhjm',-32702464), +('abcdefjhji',4), ('space',1078394880), ('fs',4), ('mn',-1845559296), +('fq', 5), ('abcdefjhjp',-1074397184); EXPLAIN SELECT t1.v,t2.i FROM t1,t2 WHERE t2.v = t1.v; id select_type table type possible_keys key key_len ref rows Extra 1 SIMPLE t1 ALL NULL NULL NULL NULL 7 Using where -1 SIMPLE t2 ref idx idx 13 test.t1.v 2 +1 SIMPLE t2 ref idx idx 13 test.t1.v 3 SELECT t1.v,t2.i FROM t1,t2 WHERE t2.v = t1.v; v i +abcdefjh 4 f 4 f 4 EXPLAIN SELECT t1.v,t2.i FROM t1,t2 WHERE t2.v = concat(t1.v, t1.v); id select_type table type possible_keys key key_len ref rows Extra 1 SIMPLE t1 ALL NULL NULL NULL NULL 7 -1 SIMPLE t2 ref idx idx 13 func 2 Using index condition +1 SIMPLE t2 ref idx idx 13 func 3 Using index condition SELECT t1.v,t2.i FROM t1,t2 WHERE t2.v = concat(t1.v, t1.v); v i f 5 @@ -4379,16 +4469,17 @@ EXPLAIN SELECT t1.v,t2.i FROM t1,t2 WHERE t2.v = t1.v; id select_type table type possible_keys key key_len ref rows Extra 1 SIMPLE t1 ALL NULL NULL NULL NULL 7 Using where -1 SIMPLE t2 hash_ALL idx #hash#idx 13 test.t1.v 18 Using join buffer (flat, BNLH join) +1 SIMPLE t2 hash_ALL idx #hash#idx 13 test.t1.v 36 Using join buffer (flat, BNLH join) SELECT t1.v,t2.i FROM t1,t2 WHERE t2.v = t1.v; v i f 4 f 4 +abcdefjh 4 EXPLAIN SELECT t1.v,t2.i FROM t1,t2 WHERE t2.v = concat(t1.v, t1.v); id select_type table type possible_keys key key_len ref rows Extra 1 SIMPLE t1 ALL NULL NULL NULL NULL 7 -1 SIMPLE t2 hash_ALL idx #hash#idx 13 func 18 Using where; Using join buffer (flat, BNLH join) +1 SIMPLE t2 hash_ALL idx #hash#idx 13 func 36 Using where; Using join buffer (flat, BNLH join) SELECT t1.v,t2.i FROM t1,t2 WHERE t2.v = concat(t1.v, t1.v); v i f 5 @@ -4419,6 +4510,13 @@ INSERT INTO t2 VALUES (11,6,'yes'), (12,NULL,'will'), (13,NULL,'o'), (14,NULL,'k'), (15,NULL,'she'), (16,-1450835968,'abcdefjhjkl'), (17,-975831040,'abcdefjhjkl'), (18,NULL,'z'), (19,-343932928,'t'); +INSERT INTO t2 VALUES +(101,6,'yes'), (102,NULL,'will'), (103,NULL,'o'), (104,NULL,'k'), (105,NULL,'she'), +(106,-1450835968,'abcdefjhjkl'), (107,-975831040,'abcdefjhjkl'), (108,NULL,'z'), +(100,-343932928,'t'), +(111,6,'yes'), (112,NULL,'will'), (113,NULL,'o'), (114,NULL,'k'), (115,NULL,'she'), +(116,-1450835968,'abcdefjhjkl'), (117,-975831040,'abcdefjhjkl'), (118,NULL,'z'), +(119,-343932928,'t'); CREATE TABLE t3 ( pk int NOT NULL PRIMARY KEY, i int, @@ -4434,6 +4532,15 @@ INSERT INTO t3 VALUES (26,NULL,'all'), (27,1443168256,'c'), (28,1427046400,'right'), (31,7,'abcdefjhjkl'), (32,6,'y'), (33,NULL,'to'), (34,7,'n'), (35,7,'look'), (36,NULL,'all'), (37,1443168256,'c'), (38,1427046400,'right'); +INSERT INTO t3 VALUES +(101,7,'abcdefjhjkl'),(102,6,'y'), (103,NULL,'to'),(104,7,'n'),(105,7,'look'), +(106,NULL,'all'), (107,1443168256,'c'), (108,1427046400,'right'), +(111,7,'abcdefjhjkl'), (112,6,'y'), (113,NULL,'to'), (114,7,'n'), (115,7,'look'), +(116,NULL,'all'), (117,1443168256,'c'), (118,1427046400,'right'), +(121,7,'abcdefjhjkl'), (122,6,'y'), (123,NULL,'to'), (124,7,'n'), (125,7,'look'), +(126,NULL,'all'), (127,1443168256,'c'), (128,1427046400,'right'), +(131,7,'abcdefjhjkl'), (132,6,'y'), (133,NULL,'to'), (134,7,'n'), (135,7,'look'), +(136,NULL,'all'), (137,1443168256,'c'), (138,1427046400,'right'); SET SESSION join_buffer_size = 256; SET SESSION join_cache_level = 4; EXPLAIN @@ -4441,8 +4548,8 @@ SELECT t3.i FROM t1,t2,t3 WHERE t1.v = t2.v AND t3.v = t1.v AND t2.i <> 0; id select_type table type possible_keys key key_len ref rows Extra 1 SIMPLE t1 index idx idx 13 NULL 7 Using where; Using index -1 SIMPLE t2 hash_ALL idx #hash#idx 1003 test.t1.v 18 Using where; Using join buffer (flat, BNLH join) -1 SIMPLE t3 hash_ALL idx #hash#idx 1002 func 32 Using where; Using join buffer (incremental, BNLH join) +1 SIMPLE t2 hash_ALL idx #hash#idx 1003 test.t1.v 36 Using where; Using join buffer (flat, BNLH join) +1 SIMPLE t3 hash_ALL idx #hash#idx 1002 func 64 Using where; Using join buffer (incremental, BNLH join) SELECT t3.i FROM t1,t2,t3 WHERE t1.v = t2.v AND t3.v = t1.v AND t2.i <> 0; i @@ -4467,19 +4574,28 @@ INSERT INTO t2 VALUES (10, 'a'), (20, 'c'), (30, 'aa'), (4, 'bb'), (11, 'a'), (21, 'c'), (31, 'aa'), (41, 'cc'), (12, 'a'), (22, 'c'), (32, 'bb'), (42, 'aa'); +INSERT INTO t2 VALUES +(110, 'a'), (120, 'c'), (130, 'aa'), (14, 'bb'), +(111, 'a'), (121, 'c'), (131, 'aa'), (141, 'cc'), +(112, 'a'), (122, 'c'), (132, 'bb'), (142, 'aa'); SELECT * FROM t1,t2 WHERE t2.a=t1.a; pk a pk a 2 aa 30 aa 2 aa 31 aa 2 aa 42 aa +2 aa 130 aa +2 aa 131 aa +2 aa 142 aa 3 bb 4 bb 3 bb 32 bb +3 bb 14 bb +3 bb 132 bb SET SESSION join_cache_level = 4; EXPLAIN SELECT * FROM t1,t2 WHERE t2.a=t1.a; id select_type table type possible_keys key key_len ref rows Extra 1 SIMPLE t1 ALL idx NULL NULL NULL 3 Using where -1 SIMPLE t2 hash_ALL idx #hash#idx 515 test.t1.a 12 Using join buffer (flat, BNLH join) +1 SIMPLE t2 hash_ALL idx #hash#idx 515 test.t1.a 24 Using join buffer (flat, BNLH join) SELECT * FROM t1,t2 WHERE t2.a=t1.a; pk a pk a 2 aa 30 aa @@ -4487,6 +4603,11 @@ pk a pk a 2 aa 31 aa 3 bb 32 bb 2 aa 42 aa +2 aa 130 aa +3 bb 14 bb +2 aa 131 aa +3 bb 132 bb +2 aa 142 aa SET SESSION join_cache_level = DEFAULT; DROP TABLE t1,t2; # @@ -4569,6 +4690,9 @@ CREATE TABLE t3 (pk int, a3 int, c3 int, d3 int) ; INSERT IGNORE INTO t3 VALUES (9,0,0,2), (1,0,0,7); CREATE TABLE t4 (pk int, a4 int, INDEX idx(a4)) ; INSERT IGNORE INTO t4 VALUES (2,NULL), (8,0); +INSERT IGNORE INTO t4 VALUES (12,10), (18,20); +INSERT IGNORE INTO t4 VALUES (22,11), (28,21); +INSERT IGNORE INTO t4 VALUES (32,12), (38,22); CREATE TABLE t5 (pk int, a5 int) ; INSERT IGNORE INTO t5 VALUES (2,0), (8,0); SET SESSION optimizer_switch = 'outer_join_with_cache=on'; @@ -4786,13 +4910,16 @@ INSERT INTO t1 VALUES INSERT INTO t2 VALUES (1,'Bbbb'), (2,'BBB'), (3,'bbbb'), (4,'AaA'), (5,'CC'), (6,'cC'), (7,'CCC'), (8,'AAA'), (9,'bBbB'), (10,'aaaa'), -(11,'a'), (12,'dd'), (13,'EE'), (14,'ee'), (15,'D'); +(11,'a'), (12,'dd'), (13,'EE'), (14,'ee'), (15,'D'), +(101,'Bbbb'), (102,'BBB'), (103,'bbbb'), (104,'AaA'), (105,'CC'), +(106,'cC'), (107,'CCC'), (108,'AAA'), (109,'bBbB'), (110,'aaaa'), +(111,'a'), (112,'dd'), (113,'EE'), (114,'ee'), (115,'D'); SET SESSION join_cache_level = 4; EXPLAIN SELECT * FROM t1,t2 WHERE t1.a=t2.a; id select_type table type possible_keys key key_len ref rows Extra 1 SIMPLE t1 ALL NULL NULL NULL NULL 5 Using where -1 SIMPLE t2 hash_ALL idx #hash#idx 35 test.t1.a 15 Using join buffer (flat, BNLH join) +1 SIMPLE t2 hash_ALL idx #hash#idx 35 test.t1.a 30 Using join buffer (flat, BNLH join) SELECT * FROM t1,t2 WHERE t1.a=t2.a; pk a pk a 20 BBBB 1 Bbbb @@ -4805,6 +4932,16 @@ pk a pk a 40 DD 12 dd 50 ee 13 EE 50 ee 14 ee +20 BBBB 101 Bbbb +20 BBBB 103 bbbb +10 AAA 104 AaA +30 Cc 105 CC +30 Cc 106 cC +10 AAA 108 AAA +20 BBBB 109 bBbB +40 DD 112 dd +50 ee 113 EE +50 ee 114 ee SET SESSION join_cache_level = DEFAULT; DROP TABLE t1,t2; # @@ -4834,7 +4971,7 @@ EXPLAIN SELECT * FROM t1,t2 WHERE t1.f1 = t2.f4 AND (t1.f3 = 1 AND t2.f3 = 4 OR t1.f3 = 2 AND t2.f3 = 6); id select_type table type possible_keys key key_len ref rows Extra -1 SIMPLE t1 range PRIMARY PRIMARY 4 NULL 2 Using index condition; Rowid-ordered scan +1 SIMPLE t1 range PRIMARY PRIMARY 4 NULL 2 Using index condition; Using where; Rowid-ordered scan 1 SIMPLE t2 range PRIMARY PRIMARY 4 NULL 2 Using index condition; Using where; Rowid-ordered scan; Using join buffer (flat, BNL join) SELECT * FROM t1,t2 WHERE t1.f1 = t2.f4 AND (t1.f3 = 1 AND t2.f3 = 4 OR t1.f3 = 2 AND t2.f3 = 6); @@ -4929,13 +5066,15 @@ CREATE TABLE t2 ( f1 varchar(10) , f2 int(11) , KEY (f1)); INSERT INTO t2 VALUES ('hgtofubn',1), ('GDOXZ',91), ('n',2), ('fggxgalh',88), ('hgtofu',1), ('GDO',101), ('n',3), ('fggxga',55), -('hgtofu',3), ('GDO',33), ('nn',3), ('fggxgarrr',77); +('hgtofu',3), ('GDO',33), ('nn',3), ('fggxgarrr',77), +('jgtofu',3), ('JDO',33), ('mn',3), ('jggxgarrr',77), +('igtofu',3), ('IDO',33), ('ln',3), ('iggxgarrr',77); SET SESSION join_cache_level=3; EXPLAIN SELECT * FROM t1,t2 WHERE t2.f1 = t1.f1; id select_type table type possible_keys key key_len ref rows Extra 1 SIMPLE t1 ALL f1 NULL NULL NULL 2 Using where -1 SIMPLE t2 hash_ALL f1 #hash#f1 13 test.t1.f1 12 Using join buffer (flat, BNLH join) +1 SIMPLE t2 hash_ALL f1 #hash#f1 13 test.t1.f1 20 Using join buffer (flat, BNLH join) SELECT * FROM t1,t2 WHERE t2.f1 = t1.f1; f1 f2 f1 f2 SET SESSION join_cache_level = DEFAULT; @@ -4948,17 +5087,20 @@ INSERT INTO t1 VALUES ('o'), ('u'); CREATE TABLE t2 (a int, v varchar(1), INDEX idx (v)) ; INSERT INTO t2 VALUES (8,NULL), (10,'b'), (5,'k'), (4,NULL), -(1,NULL), (11,'u'), (7,NULL), (2,'d'); +(1,NULL), (11,'u'), (7,NULL), (2,'d'), +(18,'u'), (11,'b'), (15,'k'), (12,'d'), +(18,'x'), (11,'y'), (15,'l'), (12,'e'); SET SESSION join_buffer_size = 256; SET SESSION join_cache_level = 4; EXPLAIN SELECT a FROM t1,t2 WHERE t2.v = t1.v ; id select_type table type possible_keys key key_len ref rows Extra 1 SIMPLE t1 ALL NULL NULL NULL NULL 2 Using where -1 SIMPLE t2 hash_ALL idx #hash#idx 4 test.t1.v 8 Using join buffer (flat, BNLH join) +1 SIMPLE t2 hash_ALL idx #hash#idx 4 test.t1.v 16 Using join buffer (flat, BNLH join) SELECT a FROM t1,t2 WHERE t2.v = t1.v ; a 11 +18 SET SESSION join_cache_level = 1; EXPLAIN SELECT a FROM t1,t2 WHERE t2.v = t1.v ; @@ -4968,6 +5110,7 @@ id select_type table type possible_keys key key_len ref rows Extra SELECT a FROM t1,t2 WHERE t2.v = t1.v ; a 11 +18 SET SESSION join_cache_level = DEFAULT; SET SESSION join_buffer_size = DEFAULT; DROP TABLE t1,t2; @@ -5006,4 +5149,37 @@ a 0 SET SESSION join_cache_level = DEFAULT; DROP TABLE t1, t2; +# +# Bug #887479: join_cache_level=3 + semijoin=on +# +CREATE TABLE t1 (a int, b int); +INSERT INTO t1 VALUES (3914,17), (3710,5), (3888,20); +CREATE TABLE t2 (c int, KEY (c)); +INSERT INTO t2 VALUES (27), (17), (33), (20), (3), (7), (18), (2); +SET @tmp887479_optimizer_switch=@@optimizer_switch; +SET SESSION optimizer_switch='semijoin=on'; +SET SESSION optimizer_switch='semijoin_with_cache=on'; +SET SESSION join_cache_level=1; +EXPLAIN +SELECT * FROM t1 WHERE (t1.b) IN (SELECT c FROM t2); +id select_type table type possible_keys key key_len ref rows Extra +1 PRIMARY t1 ALL NULL NULL NULL NULL 3 Using where +1 PRIMARY t2 ref c c 5 test.t1.b 2 Using index; Start temporary; End temporary +SELECT * FROM t1 WHERE (t1.b) IN (SELECT c FROM t2); +a b +3914 17 +3888 20 +SET SESSION join_cache_level=3; +EXPLAIN +SELECT * FROM t1 WHERE (t1.b) IN (SELECT c FROM t2); +id select_type table type possible_keys key key_len ref rows Extra +1 PRIMARY t1 ALL NULL NULL NULL NULL 3 Using where; Start temporary +1 PRIMARY t2 hash_index c #hash#c:c 5:5 test.t1.b 8 End temporary; Using join buffer (flat, BNLH join) +SELECT * FROM t1 WHERE (t1.b) IN (SELECT c FROM t2); +a b +3914 17 +3888 20 +SET SESSION join_cache_level = DEFAULT; +SET optimizer_switch=@tmp887479_optimizer_switch; +DROP TABLE t1,t2; set @@optimizer_switch=@save_optimizer_switch; diff --git a/mysql-test/r/join_nested.result b/mysql-test/r/join_nested.result index bdf650b97bc..234ac4a88d9 100644 --- a/mysql-test/r/join_nested.result +++ b/mysql-test/r/join_nested.result @@ -841,25 +841,26 @@ id select_type table type possible_keys key key_len ref rows filtered Extra 1 SIMPLE t4 ALL NULL NULL NULL NULL 2 100.00 Using where Warnings: Note 1003 select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b`,`test`.`t3`.`a` AS `a`,`test`.`t3`.`b` AS `b`,`test`.`t4`.`a` AS `a`,`test`.`t4`.`b` AS `b` from `test`.`t1` join `test`.`t2` left join (`test`.`t3` join `test`.`t4`) on(((`test`.`t3`.`a` = 1) and (`test`.`t4`.`b` = `test`.`t2`.`b`))) where (`test`.`t1`.`a` <= 2) +INSERT INTO t2 VALUES (-1,9,0), (-3,10,0), (-2,8,0), (-4,11,0), (-5,15,0); CREATE INDEX idx_b ON t2(b); EXPLAIN EXTENDED SELECT t2.a,t2.b,t3.a,t3.b,t4.a,t4.b FROM (t3,t4) LEFT JOIN (t1,t2) -ON t3.a=1 AND t3.b=t2.b AND t2.b=t4.b; +ON t3.a=1 AND t3.b=t2.b AND t2.b=t4.b AND t2.a>0; id select_type table type possible_keys key key_len ref rows filtered Extra 1 SIMPLE t3 ALL NULL NULL NULL NULL 2 100.00 1 SIMPLE t4 ALL NULL NULL NULL NULL 2 100.00 Using join buffer (flat, BNL join) 1 SIMPLE t2 ref idx_b idx_b 5 test.t3.b 2 100.00 Using where 1 SIMPLE t1 ALL NULL NULL NULL NULL 3 100.00 Warnings: -Note 1003 select `test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b`,`test`.`t3`.`a` AS `a`,`test`.`t3`.`b` AS `b`,`test`.`t4`.`a` AS `a`,`test`.`t4`.`b` AS `b` from `test`.`t3` join `test`.`t4` left join (`test`.`t1` join `test`.`t2`) on(((`test`.`t3`.`a` = 1) and (`test`.`t4`.`b` = `test`.`t3`.`b`) and (`test`.`t2`.`b` = `test`.`t3`.`b`) and (`test`.`t3`.`b` is not null))) where 1 +Note 1003 select `test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b`,`test`.`t3`.`a` AS `a`,`test`.`t3`.`b` AS `b`,`test`.`t4`.`a` AS `a`,`test`.`t4`.`b` AS `b` from `test`.`t3` join `test`.`t4` left join (`test`.`t1` join `test`.`t2`) on(((`test`.`t2`.`a` > 0) and (`test`.`t3`.`a` = 1) and (`test`.`t4`.`b` = `test`.`t3`.`b`) and (`test`.`t2`.`b` = `test`.`t3`.`b`) and (`test`.`t3`.`b` is not null))) where 1 SELECT t2.a,t2.b,t3.a,t3.b,t4.a,t4.b FROM (t3,t4) LEFT JOIN (t1,t2) -ON t3.a=1 AND t3.b=t2.b AND t2.b=t4.b; +ON t3.a=1 AND t3.b=t2.b AND t2.b=t4.b AND t2.a>0; a b a b a b 4 2 1 2 3 2 4 2 1 2 3 2 @@ -878,7 +879,7 @@ LEFT JOIN t2 LEFT JOIN (t3, t4) -ON t3.a=1 AND t2.b=t4.b, +ON t3.a=1 AND t2.b=t4.b AND t2.a>0, t5 LEFT JOIN ( @@ -907,16 +908,18 @@ t0.b=t1.b AND id select_type table type possible_keys key key_len ref rows filtered Extra 1 SIMPLE t0 ALL NULL NULL NULL NULL 3 100.00 Using where 1 SIMPLE t1 ALL NULL NULL NULL NULL 3 100.00 Using where; Using join buffer (flat, BNL join) -1 SIMPLE t2 ALL NULL NULL NULL NULL 3 100.00 Using where -1 SIMPLE t3 ALL NULL NULL NULL NULL 2 100.00 Using where -1 SIMPLE t4 ALL NULL NULL NULL NULL 2 100.00 Using where 1 SIMPLE t5 ALL NULL NULL NULL NULL 3 100.00 Using where 1 SIMPLE t7 ALL NULL NULL NULL NULL 2 100.00 Using where 1 SIMPLE t6 ALL NULL NULL NULL NULL 3 100.00 Using where 1 SIMPLE t8 ALL NULL NULL NULL NULL 2 100.00 Using where +1 SIMPLE t2 ALL NULL NULL NULL NULL 8 100.00 Using where +1 SIMPLE t4 ALL NULL NULL NULL NULL 2 100.00 Using where +1 SIMPLE t3 ALL NULL NULL NULL NULL 2 100.00 Using where 1 SIMPLE t9 ALL NULL NULL NULL NULL 3 100.00 Using where; Using join buffer (flat, BNL join) Warnings: -Note 1003 select `test`.`t0`.`a` AS `a`,`test`.`t0`.`b` AS `b`,`test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b`,`test`.`t3`.`a` AS `a`,`test`.`t3`.`b` AS `b`,`test`.`t4`.`a` AS `a`,`test`.`t4`.`b` AS `b`,`test`.`t5`.`a` AS `a`,`test`.`t5`.`b` AS `b`,`test`.`t6`.`a` AS `a`,`test`.`t6`.`b` AS `b`,`test`.`t7`.`a` AS `a`,`test`.`t7`.`b` AS `b`,`test`.`t8`.`a` AS `a`,`test`.`t8`.`b` AS `b`,`test`.`t9`.`a` AS `a`,`test`.`t9`.`b` AS `b` from `test`.`t0` join `test`.`t1` left join (`test`.`t2` left join (`test`.`t3` join `test`.`t4`) on(((`test`.`t3`.`a` = 1) and (`test`.`t4`.`b` = `test`.`t2`.`b`))) join `test`.`t5` left join (`test`.`t6` join `test`.`t7` left join `test`.`t8` on(((`test`.`t6`.`b` < 10) and ((`test`.`t7`.`b` = `test`.`t5`.`b`) and (`test`.`t8`.`b` = `test`.`t5`.`b`))))) on(((`test`.`t6`.`b` >= 2) and (`test`.`t7`.`b` = `test`.`t5`.`b`)))) on((((`test`.`t3`.`b` = 2) or isnull(`test`.`t3`.`c`)) and ((`test`.`t6`.`b` = 2) or isnull(`test`.`t6`.`c`)) and (((`test`.`t1`.`b` = `test`.`t0`.`b`) and (`test`.`t5`.`b` = `test`.`t0`.`b`)) or isnull(`test`.`t3`.`c`) or isnull(`test`.`t6`.`c`) or isnull(`test`.`t8`.`c`)) and (`test`.`t1`.`a` <> 2))) join `test`.`t9` where ((`test`.`t9`.`a` = 1) and (`test`.`t1`.`b` = `test`.`t0`.`b`) and (`test`.`t0`.`a` = 1) and ((`test`.`t2`.`a` >= 4) or isnull(`test`.`t2`.`c`)) and ((`test`.`t3`.`a` < 5) or isnull(`test`.`t3`.`c`)) and ((`test`.`t4`.`b` = `test`.`t3`.`b`) or isnull(`test`.`t3`.`c`) or isnull(`test`.`t4`.`c`)) and ((`test`.`t5`.`a` >= 2) or isnull(`test`.`t5`.`c`)) and ((`test`.`t6`.`a` >= 4) or isnull(`test`.`t6`.`c`)) and ((`test`.`t7`.`a` <= 2) or isnull(`test`.`t7`.`c`)) and ((`test`.`t8`.`a` < 1) or isnull(`test`.`t8`.`c`)) and ((`test`.`t9`.`b` = `test`.`t8`.`b`) or isnull(`test`.`t8`.`c`))) +Note 1003 select `test`.`t0`.`a` AS `a`,`test`.`t0`.`b` AS `b`,`test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b`,`test`.`t3`.`a` AS `a`,`test`.`t3`.`b` AS `b`,`test`.`t4`.`a` AS `a`,`test`.`t4`.`b` AS `b`,`test`.`t5`.`a` AS `a`,`test`.`t5`.`b` AS `b`,`test`.`t6`.`a` AS `a`,`test`.`t6`.`b` AS `b`,`test`.`t7`.`a` AS `a`,`test`.`t7`.`b` AS `b`,`test`.`t8`.`a` AS `a`,`test`.`t8`.`b` AS `b`,`test`.`t9`.`a` AS `a`,`test`.`t9`.`b` AS `b` from `test`.`t0` join `test`.`t1` left join (`test`.`t2` left join (`test`.`t3` join `test`.`t4`) on(((`test`.`t2`.`a` > 0) and (`test`.`t3`.`a` = 1) and (`test`.`t4`.`b` = `test`.`t2`.`b`))) join `test`.`t5` left join (`test`.`t6` join `test`.`t7` left join `test`.`t8` on(((`test`.`t6`.`b` < 10) and ((`test`.`t7`.`b` = `test`.`t5`.`b`) and (`test`.`t8`.`b` = `test`.`t5`.`b`))))) on(((`test`.`t6`.`b` >= 2) and (`test`.`t7`.`b` = `test`.`t5`.`b`)))) on((((`test`.`t3`.`b` = 2) or isnull(`test`.`t3`.`c`)) and ((`test`.`t6`.`b` = 2) or isnull(`test`.`t6`.`c`)) and (((`test`.`t1`.`b` = `test`.`t0`.`b`) and (`test`.`t5`.`b` = `test`.`t0`.`b`)) or isnull(`test`.`t3`.`c`) or isnull(`test`.`t6`.`c`) or isnull(`test`.`t8`.`c`)) and (`test`.`t1`.`a` <> 2))) join `test`.`t9` where ((`test`.`t9`.`a` = 1) and (`test`.`t1`.`b` = `test`.`t0`.`b`) and (`test`.`t0`.`a` = 1) and ((`test`.`t2`.`a` >= 4) or isnull(`test`.`t2`.`c`)) and ((`test`.`t3`.`a` < 5) or isnull(`test`.`t3`.`c`)) and ((`test`.`t3`.`b` = `test`.`t4`.`b`) or isnull(`test`.`t3`.`c`) or isnull(`test`.`t4`.`c`)) and ((`test`.`t5`.`a` >= 2) or isnull(`test`.`t5`.`c`)) and ((`test`.`t6`.`a` >= 4) or isnull(`test`.`t6`.`c`)) and ((`test`.`t7`.`a` <= 2) or isnull(`test`.`t7`.`c`)) and ((`test`.`t8`.`a` < 1) or isnull(`test`.`t8`.`c`)) and ((`test`.`t9`.`b` = `test`.`t8`.`b`) or isnull(`test`.`t8`.`c`))) +INSERT INTO t4 VALUES (-3,12,0), (-4,13,0), (-1,11,0), (-3,11,0), (-5,15,0); +INSERT INTO t5 VALUES (-3,11,0), (-2,12,0), (-3,13,0), (-4,12,0); CREATE INDEX idx_b ON t4(b); CREATE INDEX idx_b ON t5(b); EXPLAIN EXTENDED @@ -928,7 +931,7 @@ LEFT JOIN t2 LEFT JOIN (t3, t4) -ON t3.a=1 AND t2.b=t4.b, +ON t3.a=1 AND t2.b=t4.b AND t2.a>0 AND t4.a>0, t5 LEFT JOIN ( @@ -937,7 +940,7 @@ LEFT JOIN t8 ON t7.b=t8.b AND t6.b < 10 ) -ON t6.b >= 2 AND t5.b=t7.b +ON t6.b >= 2 AND t5.b=t7.b AND t5.a>0 ) ON (t3.b=2 OR t3.c IS NULL) AND (t6.b=2 OR t6.c IS NULL) AND (t1.b=t5.b OR t3.c IS NULL OR t6.c IS NULL or t8.c IS NULL) AND @@ -957,16 +960,17 @@ t0.b=t1.b AND id select_type table type possible_keys key key_len ref rows filtered Extra 1 SIMPLE t0 ALL NULL NULL NULL NULL 3 100.00 Using where 1 SIMPLE t1 ALL NULL NULL NULL NULL 3 100.00 Using where; Using join buffer (flat, BNL join) -1 SIMPLE t2 ALL NULL NULL NULL NULL 3 100.00 Using where +1 SIMPLE t9 ALL NULL NULL NULL NULL 3 100.00 Using where; Using join buffer (flat, BNL join) +1 SIMPLE t2 ALL NULL NULL NULL NULL 8 100.00 Using where 1 SIMPLE t3 ALL NULL NULL NULL NULL 2 100.00 Using where 1 SIMPLE t4 ref idx_b idx_b 5 test.t2.b 2 100.00 Using where -1 SIMPLE t5 ALL idx_b NULL NULL NULL 3 100.00 Using where +1 SIMPLE t5 ALL idx_b NULL NULL NULL 7 100.00 Using where 1 SIMPLE t7 ALL NULL NULL NULL NULL 2 100.00 Using where 1 SIMPLE t6 ALL NULL NULL NULL NULL 3 100.00 Using where 1 SIMPLE t8 ALL NULL NULL NULL NULL 2 100.00 Using where -1 SIMPLE t9 ALL NULL NULL NULL NULL 3 100.00 Using where; Using join buffer (flat, BNL join) Warnings: -Note 1003 select `test`.`t0`.`a` AS `a`,`test`.`t0`.`b` AS `b`,`test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b`,`test`.`t3`.`a` AS `a`,`test`.`t3`.`b` AS `b`,`test`.`t4`.`a` AS `a`,`test`.`t4`.`b` AS `b`,`test`.`t5`.`a` AS `a`,`test`.`t5`.`b` AS `b`,`test`.`t6`.`a` AS `a`,`test`.`t6`.`b` AS `b`,`test`.`t7`.`a` AS `a`,`test`.`t7`.`b` AS `b`,`test`.`t8`.`a` AS `a`,`test`.`t8`.`b` AS `b`,`test`.`t9`.`a` AS `a`,`test`.`t9`.`b` AS `b` from `test`.`t0` join `test`.`t1` left join (`test`.`t2` left join (`test`.`t3` join `test`.`t4`) on(((`test`.`t3`.`a` = 1) and (`test`.`t4`.`b` = `test`.`t2`.`b`) and (`test`.`t2`.`b` is not null))) join `test`.`t5` left join (`test`.`t6` join `test`.`t7` left join `test`.`t8` on(((`test`.`t6`.`b` < 10) and ((`test`.`t7`.`b` = `test`.`t5`.`b`) and (`test`.`t8`.`b` = `test`.`t5`.`b`))))) on(((`test`.`t6`.`b` >= 2) and (`test`.`t7`.`b` = `test`.`t5`.`b`)))) on((((`test`.`t3`.`b` = 2) or isnull(`test`.`t3`.`c`)) and ((`test`.`t6`.`b` = 2) or isnull(`test`.`t6`.`c`)) and (((`test`.`t1`.`b` = `test`.`t0`.`b`) and (`test`.`t5`.`b` = `test`.`t0`.`b`)) or isnull(`test`.`t3`.`c`) or isnull(`test`.`t6`.`c`) or isnull(`test`.`t8`.`c`)) and (`test`.`t1`.`a` <> 2))) join `test`.`t9` where ((`test`.`t9`.`a` = 1) and (`test`.`t1`.`b` = `test`.`t0`.`b`) and (`test`.`t0`.`a` = 1) and ((`test`.`t2`.`a` >= 4) or isnull(`test`.`t2`.`c`)) and ((`test`.`t3`.`a` < 5) or isnull(`test`.`t3`.`c`)) and ((`test`.`t4`.`b` = `test`.`t3`.`b`) or isnull(`test`.`t3`.`c`) or isnull(`test`.`t4`.`c`)) and ((`test`.`t5`.`a` >= 2) or isnull(`test`.`t5`.`c`)) and ((`test`.`t6`.`a` >= 4) or isnull(`test`.`t6`.`c`)) and ((`test`.`t7`.`a` <= 2) or isnull(`test`.`t7`.`c`)) and ((`test`.`t8`.`a` < 1) or isnull(`test`.`t8`.`c`)) and ((`test`.`t9`.`b` = `test`.`t8`.`b`) or isnull(`test`.`t8`.`c`))) +Note 1003 select `test`.`t0`.`a` AS `a`,`test`.`t0`.`b` AS `b`,`test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b`,`test`.`t3`.`a` AS `a`,`test`.`t3`.`b` AS `b`,`test`.`t4`.`a` AS `a`,`test`.`t4`.`b` AS `b`,`test`.`t5`.`a` AS `a`,`test`.`t5`.`b` AS `b`,`test`.`t6`.`a` AS `a`,`test`.`t6`.`b` AS `b`,`test`.`t7`.`a` AS `a`,`test`.`t7`.`b` AS `b`,`test`.`t8`.`a` AS `a`,`test`.`t8`.`b` AS `b`,`test`.`t9`.`a` AS `a`,`test`.`t9`.`b` AS `b` from `test`.`t0` join `test`.`t1` left join (`test`.`t2` left join (`test`.`t3` join `test`.`t4`) on(((`test`.`t2`.`a` > 0) and (`test`.`t4`.`a` > 0) and (`test`.`t3`.`a` = 1) and (`test`.`t4`.`b` = `test`.`t2`.`b`) and (`test`.`t2`.`b` is not null))) join `test`.`t5` left join (`test`.`t6` join `test`.`t7` left join `test`.`t8` on(((`test`.`t6`.`b` < 10) and ((`test`.`t7`.`b` = `test`.`t5`.`b`) and (`test`.`t8`.`b` = `test`.`t5`.`b`))))) on(((`test`.`t6`.`b` >= 2) and (`test`.`t5`.`a` > 0) and (`test`.`t7`.`b` = `test`.`t5`.`b`)))) on((((`test`.`t3`.`b` = 2) or isnull(`test`.`t3`.`c`)) and ((`test`.`t6`.`b` = 2) or isnull(`test`.`t6`.`c`)) and (((`test`.`t1`.`b` = `test`.`t0`.`b`) and (`test`.`t5`.`b` = `test`.`t0`.`b`)) or isnull(`test`.`t3`.`c`) or isnull(`test`.`t6`.`c`) or isnull(`test`.`t8`.`c`)) and (`test`.`t1`.`a` <> 2))) join `test`.`t9` where ((`test`.`t9`.`a` = 1) and (`test`.`t1`.`b` = `test`.`t0`.`b`) and (`test`.`t0`.`a` = 1) and ((`test`.`t2`.`a` >= 4) or isnull(`test`.`t2`.`c`)) and ((`test`.`t3`.`a` < 5) or isnull(`test`.`t3`.`c`)) and ((`test`.`t4`.`b` = `test`.`t3`.`b`) or isnull(`test`.`t3`.`c`) or isnull(`test`.`t4`.`c`)) and ((`test`.`t5`.`a` >= 2) or isnull(`test`.`t5`.`c`)) and ((`test`.`t6`.`a` >= 4) or isnull(`test`.`t6`.`c`)) and ((`test`.`t7`.`a` <= 2) or isnull(`test`.`t7`.`c`)) and ((`test`.`t8`.`a` < 1) or isnull(`test`.`t8`.`c`)) and ((`test`.`t8`.`b` = `test`.`t9`.`b`) or isnull(`test`.`t8`.`c`))) +INSERT INTO t8 VALUES (-3,12,0), (-1,14,0), (-5,15,0), (-1,11,0), (-4,13,0); CREATE INDEX idx_b ON t8(b); EXPLAIN EXTENDED SELECT t0.a,t0.b,t1.a,t1.b,t2.a,t2.b,t3.a,t3.b,t4.a,t4.b, @@ -977,16 +981,16 @@ LEFT JOIN t2 LEFT JOIN (t3, t4) -ON t3.a=1 AND t2.b=t4.b, +ON t3.a=1 AND t2.b=t4.b AND t2.a>0 AND t4.a>0, t5 LEFT JOIN ( (t6, t7) LEFT JOIN t8 -ON t7.b=t8.b AND t6.b < 10 +ON t7.b=t8.b AND t6.b < 10 AND t8.a>=0 ) -ON t6.b >= 2 AND t5.b=t7.b +ON t6.b >= 2 AND t5.b=t7.b AND t5.a>0 ) ON (t3.b=2 OR t3.c IS NULL) AND (t6.b=2 OR t6.c IS NULL) AND (t1.b=t5.b OR t3.c IS NULL OR t6.c IS NULL or t8.c IS NULL) AND @@ -1006,16 +1010,17 @@ t0.b=t1.b AND id select_type table type possible_keys key key_len ref rows filtered Extra 1 SIMPLE t0 ALL NULL NULL NULL NULL 3 100.00 Using where 1 SIMPLE t1 ALL NULL NULL NULL NULL 3 100.00 Using where; Using join buffer (flat, BNL join) -1 SIMPLE t2 ALL NULL NULL NULL NULL 3 100.00 Using where +1 SIMPLE t9 ALL NULL NULL NULL NULL 3 100.00 Using where; Using join buffer (flat, BNL join) +1 SIMPLE t2 ALL NULL NULL NULL NULL 8 100.00 Using where 1 SIMPLE t3 ALL NULL NULL NULL NULL 2 100.00 Using where 1 SIMPLE t4 ref idx_b idx_b 5 test.t2.b 2 100.00 Using where -1 SIMPLE t5 ALL idx_b NULL NULL NULL 3 100.00 Using where +1 SIMPLE t5 ALL idx_b NULL NULL NULL 7 100.00 Using where 1 SIMPLE t7 ALL NULL NULL NULL NULL 2 100.00 Using where 1 SIMPLE t6 ALL NULL NULL NULL NULL 3 100.00 Using where 1 SIMPLE t8 ref idx_b idx_b 5 test.t5.b 2 100.00 Using where -1 SIMPLE t9 ALL NULL NULL NULL NULL 3 100.00 Using where; Using join buffer (flat, BNL join) Warnings: -Note 1003 select `test`.`t0`.`a` AS `a`,`test`.`t0`.`b` AS `b`,`test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b`,`test`.`t3`.`a` AS `a`,`test`.`t3`.`b` AS `b`,`test`.`t4`.`a` AS `a`,`test`.`t4`.`b` AS `b`,`test`.`t5`.`a` AS `a`,`test`.`t5`.`b` AS `b`,`test`.`t6`.`a` AS `a`,`test`.`t6`.`b` AS `b`,`test`.`t7`.`a` AS `a`,`test`.`t7`.`b` AS `b`,`test`.`t8`.`a` AS `a`,`test`.`t8`.`b` AS `b`,`test`.`t9`.`a` AS `a`,`test`.`t9`.`b` AS `b` from `test`.`t0` join `test`.`t1` left join (`test`.`t2` left join (`test`.`t3` join `test`.`t4`) on(((`test`.`t3`.`a` = 1) and (`test`.`t4`.`b` = `test`.`t2`.`b`) and (`test`.`t2`.`b` is not null))) join `test`.`t5` left join (`test`.`t6` join `test`.`t7` left join `test`.`t8` on(((`test`.`t6`.`b` < 10) and (`test`.`t7`.`b` = `test`.`t5`.`b`) and (`test`.`t8`.`b` = `test`.`t5`.`b`) and (`test`.`t5`.`b` is not null)))) on(((`test`.`t6`.`b` >= 2) and (`test`.`t7`.`b` = `test`.`t5`.`b`)))) on((((`test`.`t3`.`b` = 2) or isnull(`test`.`t3`.`c`)) and ((`test`.`t6`.`b` = 2) or isnull(`test`.`t6`.`c`)) and (((`test`.`t1`.`b` = `test`.`t0`.`b`) and (`test`.`t5`.`b` = `test`.`t0`.`b`)) or isnull(`test`.`t3`.`c`) or isnull(`test`.`t6`.`c`) or isnull(`test`.`t8`.`c`)) and (`test`.`t1`.`a` <> 2))) join `test`.`t9` where ((`test`.`t9`.`a` = 1) and (`test`.`t1`.`b` = `test`.`t0`.`b`) and (`test`.`t0`.`a` = 1) and ((`test`.`t2`.`a` >= 4) or isnull(`test`.`t2`.`c`)) and ((`test`.`t3`.`a` < 5) or isnull(`test`.`t3`.`c`)) and ((`test`.`t4`.`b` = `test`.`t3`.`b`) or isnull(`test`.`t3`.`c`) or isnull(`test`.`t4`.`c`)) and ((`test`.`t5`.`a` >= 2) or isnull(`test`.`t5`.`c`)) and ((`test`.`t6`.`a` >= 4) or isnull(`test`.`t6`.`c`)) and ((`test`.`t7`.`a` <= 2) or isnull(`test`.`t7`.`c`)) and ((`test`.`t8`.`a` < 1) or isnull(`test`.`t8`.`c`)) and ((`test`.`t9`.`b` = `test`.`t8`.`b`) or isnull(`test`.`t8`.`c`))) +Note 1003 select `test`.`t0`.`a` AS `a`,`test`.`t0`.`b` AS `b`,`test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b`,`test`.`t3`.`a` AS `a`,`test`.`t3`.`b` AS `b`,`test`.`t4`.`a` AS `a`,`test`.`t4`.`b` AS `b`,`test`.`t5`.`a` AS `a`,`test`.`t5`.`b` AS `b`,`test`.`t6`.`a` AS `a`,`test`.`t6`.`b` AS `b`,`test`.`t7`.`a` AS `a`,`test`.`t7`.`b` AS `b`,`test`.`t8`.`a` AS `a`,`test`.`t8`.`b` AS `b`,`test`.`t9`.`a` AS `a`,`test`.`t9`.`b` AS `b` from `test`.`t0` join `test`.`t1` left join (`test`.`t2` left join (`test`.`t3` join `test`.`t4`) on(((`test`.`t2`.`a` > 0) and (`test`.`t4`.`a` > 0) and (`test`.`t3`.`a` = 1) and (`test`.`t4`.`b` = `test`.`t2`.`b`) and (`test`.`t2`.`b` is not null))) join `test`.`t5` left join (`test`.`t6` join `test`.`t7` left join `test`.`t8` on(((`test`.`t6`.`b` < 10) and (`test`.`t8`.`a` >= 0) and (`test`.`t7`.`b` = `test`.`t5`.`b`) and (`test`.`t8`.`b` = `test`.`t5`.`b`) and (`test`.`t5`.`b` is not null)))) on(((`test`.`t6`.`b` >= 2) and (`test`.`t5`.`a` > 0) and (`test`.`t7`.`b` = `test`.`t5`.`b`)))) on((((`test`.`t3`.`b` = 2) or isnull(`test`.`t3`.`c`)) and ((`test`.`t6`.`b` = 2) or isnull(`test`.`t6`.`c`)) and (((`test`.`t1`.`b` = `test`.`t0`.`b`) and (`test`.`t5`.`b` = `test`.`t0`.`b`)) or isnull(`test`.`t3`.`c`) or isnull(`test`.`t6`.`c`) or isnull(`test`.`t8`.`c`)) and (`test`.`t1`.`a` <> 2))) join `test`.`t9` where ((`test`.`t9`.`a` = 1) and (`test`.`t1`.`b` = `test`.`t0`.`b`) and (`test`.`t0`.`a` = 1) and ((`test`.`t2`.`a` >= 4) or isnull(`test`.`t2`.`c`)) and ((`test`.`t3`.`a` < 5) or isnull(`test`.`t3`.`c`)) and ((`test`.`t4`.`b` = `test`.`t3`.`b`) or isnull(`test`.`t3`.`c`) or isnull(`test`.`t4`.`c`)) and ((`test`.`t5`.`a` >= 2) or isnull(`test`.`t5`.`c`)) and ((`test`.`t6`.`a` >= 4) or isnull(`test`.`t6`.`c`)) and ((`test`.`t7`.`a` <= 2) or isnull(`test`.`t7`.`c`)) and ((`test`.`t8`.`a` < 1) or isnull(`test`.`t8`.`c`)) and ((`test`.`t8`.`b` = `test`.`t9`.`b`) or isnull(`test`.`t8`.`c`))) +INSERT INTO t1 VALUES (-1,133,0), (-2,12,0), (-3,11,0), (-5,15,0); CREATE INDEX idx_b ON t1(b); CREATE INDEX idx_a ON t0(a); EXPLAIN EXTENDED @@ -1040,7 +1045,7 @@ ON t6.b >= 2 AND t5.b=t7.b ) ON (t3.b=2 OR t3.c IS NULL) AND (t6.b=2 OR t6.c IS NULL) AND (t1.b=t5.b OR t3.c IS NULL OR t6.c IS NULL or t8.c IS NULL) AND -(t1.a != 2), +(t1.a != 2) AND t1.a>0, t9 WHERE t0.a=1 AND t0.b=t1.b AND @@ -1056,16 +1061,16 @@ t0.b=t1.b AND id select_type table type possible_keys key key_len ref rows filtered Extra 1 SIMPLE t0 ref idx_a idx_a 5 const 1 100.00 Using where 1 SIMPLE t1 ref idx_b idx_b 5 test.t0.b 2 100.00 -1 SIMPLE t2 ALL NULL NULL NULL NULL 3 100.00 Using where +1 SIMPLE t9 ALL NULL NULL NULL NULL 3 100.00 Using where; Using join buffer (flat, BNL join) +1 SIMPLE t2 ALL NULL NULL NULL NULL 8 100.00 Using where 1 SIMPLE t3 ALL NULL NULL NULL NULL 2 100.00 Using where 1 SIMPLE t4 ref idx_b idx_b 5 test.t2.b 2 100.00 Using where -1 SIMPLE t5 ALL idx_b NULL NULL NULL 3 100.00 Using where +1 SIMPLE t5 ALL idx_b NULL NULL NULL 7 100.00 Using where 1 SIMPLE t7 ALL NULL NULL NULL NULL 2 100.00 Using where 1 SIMPLE t6 ALL NULL NULL NULL NULL 3 100.00 Using where 1 SIMPLE t8 ref idx_b idx_b 5 test.t5.b 2 100.00 Using where -1 SIMPLE t9 ALL NULL NULL NULL NULL 3 100.00 Using where; Using join buffer (flat, BNL join) Warnings: -Note 1003 select `test`.`t0`.`a` AS `a`,`test`.`t0`.`b` AS `b`,`test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b`,`test`.`t3`.`a` AS `a`,`test`.`t3`.`b` AS `b`,`test`.`t4`.`a` AS `a`,`test`.`t4`.`b` AS `b`,`test`.`t5`.`a` AS `a`,`test`.`t5`.`b` AS `b`,`test`.`t6`.`a` AS `a`,`test`.`t6`.`b` AS `b`,`test`.`t7`.`a` AS `a`,`test`.`t7`.`b` AS `b`,`test`.`t8`.`a` AS `a`,`test`.`t8`.`b` AS `b`,`test`.`t9`.`a` AS `a`,`test`.`t9`.`b` AS `b` from `test`.`t0` join `test`.`t1` left join (`test`.`t2` left join (`test`.`t3` join `test`.`t4`) on(((`test`.`t3`.`a` = 1) and (`test`.`t4`.`b` = `test`.`t2`.`b`) and (`test`.`t2`.`b` is not null))) join `test`.`t5` left join (`test`.`t6` join `test`.`t7` left join `test`.`t8` on(((`test`.`t6`.`b` < 10) and (`test`.`t7`.`b` = `test`.`t5`.`b`) and (`test`.`t8`.`b` = `test`.`t5`.`b`) and (`test`.`t5`.`b` is not null)))) on(((`test`.`t6`.`b` >= 2) and (`test`.`t7`.`b` = `test`.`t5`.`b`)))) on((((`test`.`t3`.`b` = 2) or isnull(`test`.`t3`.`c`)) and ((`test`.`t6`.`b` = 2) or isnull(`test`.`t6`.`c`)) and (((`test`.`t1`.`b` = `test`.`t0`.`b`) and (`test`.`t5`.`b` = `test`.`t0`.`b`)) or isnull(`test`.`t3`.`c`) or isnull(`test`.`t6`.`c`) or isnull(`test`.`t8`.`c`)) and (`test`.`t1`.`a` <> 2))) join `test`.`t9` where ((`test`.`t9`.`a` = 1) and (`test`.`t1`.`b` = `test`.`t0`.`b`) and (`test`.`t0`.`a` = 1) and ((`test`.`t2`.`a` >= 4) or isnull(`test`.`t2`.`c`)) and ((`test`.`t3`.`a` < 5) or isnull(`test`.`t3`.`c`)) and ((`test`.`t4`.`b` = `test`.`t3`.`b`) or isnull(`test`.`t3`.`c`) or isnull(`test`.`t4`.`c`)) and ((`test`.`t5`.`a` >= 2) or isnull(`test`.`t5`.`c`)) and ((`test`.`t6`.`a` >= 4) or isnull(`test`.`t6`.`c`)) and ((`test`.`t7`.`a` <= 2) or isnull(`test`.`t7`.`c`)) and ((`test`.`t8`.`a` < 1) or isnull(`test`.`t8`.`c`)) and ((`test`.`t9`.`b` = `test`.`t8`.`b`) or isnull(`test`.`t8`.`c`))) +Note 1003 select `test`.`t0`.`a` AS `a`,`test`.`t0`.`b` AS `b`,`test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b`,`test`.`t3`.`a` AS `a`,`test`.`t3`.`b` AS `b`,`test`.`t4`.`a` AS `a`,`test`.`t4`.`b` AS `b`,`test`.`t5`.`a` AS `a`,`test`.`t5`.`b` AS `b`,`test`.`t6`.`a` AS `a`,`test`.`t6`.`b` AS `b`,`test`.`t7`.`a` AS `a`,`test`.`t7`.`b` AS `b`,`test`.`t8`.`a` AS `a`,`test`.`t8`.`b` AS `b`,`test`.`t9`.`a` AS `a`,`test`.`t9`.`b` AS `b` from `test`.`t0` join `test`.`t1` left join (`test`.`t2` left join (`test`.`t3` join `test`.`t4`) on(((`test`.`t3`.`a` = 1) and (`test`.`t4`.`b` = `test`.`t2`.`b`) and (`test`.`t2`.`b` is not null))) join `test`.`t5` left join (`test`.`t6` join `test`.`t7` left join `test`.`t8` on(((`test`.`t6`.`b` < 10) and (`test`.`t7`.`b` = `test`.`t5`.`b`) and (`test`.`t8`.`b` = `test`.`t5`.`b`) and (`test`.`t5`.`b` is not null)))) on(((`test`.`t6`.`b` >= 2) and (`test`.`t7`.`b` = `test`.`t5`.`b`)))) on((((`test`.`t3`.`b` = 2) or isnull(`test`.`t3`.`c`)) and ((`test`.`t6`.`b` = 2) or isnull(`test`.`t6`.`c`)) and (((`test`.`t1`.`b` = `test`.`t0`.`b`) and (`test`.`t5`.`b` = `test`.`t0`.`b`)) or isnull(`test`.`t3`.`c`) or isnull(`test`.`t6`.`c`) or isnull(`test`.`t8`.`c`)) and (`test`.`t1`.`a` <> 2) and (`test`.`t1`.`a` > 0))) join `test`.`t9` where ((`test`.`t9`.`a` = 1) and (`test`.`t1`.`b` = `test`.`t0`.`b`) and (`test`.`t0`.`a` = 1) and ((`test`.`t2`.`a` >= 4) or isnull(`test`.`t2`.`c`)) and ((`test`.`t3`.`a` < 5) or isnull(`test`.`t3`.`c`)) and ((`test`.`t4`.`b` = `test`.`t3`.`b`) or isnull(`test`.`t3`.`c`) or isnull(`test`.`t4`.`c`)) and ((`test`.`t5`.`a` >= 2) or isnull(`test`.`t5`.`c`)) and ((`test`.`t6`.`a` >= 4) or isnull(`test`.`t6`.`c`)) and ((`test`.`t7`.`a` <= 2) or isnull(`test`.`t7`.`c`)) and ((`test`.`t8`.`a` < 1) or isnull(`test`.`t8`.`c`)) and ((`test`.`t8`.`b` = `test`.`t9`.`b`) or isnull(`test`.`t8`.`c`))) SELECT t0.a,t0.b,t1.a,t1.b,t2.a,t2.b,t3.a,t3.b,t4.a,t4.b, t5.a,t5.b,t6.a,t6.b,t7.a,t7.b,t8.a,t8.b,t9.a,t9.b FROM t0,t1 @@ -1087,7 +1092,7 @@ ON t6.b >= 2 AND t5.b=t7.b ) ON (t3.b=2 OR t3.c IS NULL) AND (t6.b=2 OR t6.c IS NULL) AND (t1.b=t5.b OR t3.c IS NULL OR t6.c IS NULL or t8.c IS NULL) AND -(t1.a != 2), +(t1.a != 2) AND t1.a>0, t9 WHERE t0.a=1 AND t0.b=t1.b AND @@ -1124,6 +1129,11 @@ a b 3 3 4 2 5 3 +-1 9 +-3 10 +-2 8 +-4 11 +-5 15 SELECT t3.a,t3.b FROM t3; a b diff --git a/mysql-test/r/join_nested_jcl6.result b/mysql-test/r/join_nested_jcl6.result index d11955226ae..ff5a31b599b 100644 --- a/mysql-test/r/join_nested_jcl6.result +++ b/mysql-test/r/join_nested_jcl6.result @@ -850,25 +850,26 @@ id select_type table type possible_keys key key_len ref rows filtered Extra 1 SIMPLE t4 hash_ALL NULL #hash#$hj 5 test.t2.b 2 100.00 Using where; Using join buffer (incremental, BNLH join) Warnings: Note 1003 select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b`,`test`.`t3`.`a` AS `a`,`test`.`t3`.`b` AS `b`,`test`.`t4`.`a` AS `a`,`test`.`t4`.`b` AS `b` from `test`.`t1` join `test`.`t2` left join (`test`.`t3` join `test`.`t4`) on(((`test`.`t3`.`a` = 1) and (`test`.`t4`.`b` = `test`.`t2`.`b`) and (`test`.`t2`.`b` is not null))) where (`test`.`t1`.`a` <= 2) +INSERT INTO t2 VALUES (-1,9,0), (-3,10,0), (-2,8,0), (-4,11,0), (-5,15,0); CREATE INDEX idx_b ON t2(b); EXPLAIN EXTENDED SELECT t2.a,t2.b,t3.a,t3.b,t4.a,t4.b FROM (t3,t4) LEFT JOIN (t1,t2) -ON t3.a=1 AND t3.b=t2.b AND t2.b=t4.b; +ON t3.a=1 AND t3.b=t2.b AND t2.b=t4.b AND t2.a>0; id select_type table type possible_keys key key_len ref rows filtered Extra 1 SIMPLE t3 ALL NULL NULL NULL NULL 2 100.00 1 SIMPLE t4 ALL NULL NULL NULL NULL 2 100.00 Using join buffer (flat, BNL join) 1 SIMPLE t2 ref idx_b idx_b 5 test.t3.b 2 100.00 Using where; Using join buffer (incremental, BKA join); Key-ordered Rowid-ordered scan 1 SIMPLE t1 ALL NULL NULL NULL NULL 3 100.00 Using join buffer (incremental, BNL join) Warnings: -Note 1003 select `test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b`,`test`.`t3`.`a` AS `a`,`test`.`t3`.`b` AS `b`,`test`.`t4`.`a` AS `a`,`test`.`t4`.`b` AS `b` from `test`.`t3` join `test`.`t4` left join (`test`.`t1` join `test`.`t2`) on(((`test`.`t3`.`a` = 1) and (`test`.`t4`.`b` = `test`.`t3`.`b`) and (`test`.`t2`.`b` = `test`.`t3`.`b`) and (`test`.`t3`.`b` is not null))) where 1 +Note 1003 select `test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b`,`test`.`t3`.`a` AS `a`,`test`.`t3`.`b` AS `b`,`test`.`t4`.`a` AS `a`,`test`.`t4`.`b` AS `b` from `test`.`t3` join `test`.`t4` left join (`test`.`t1` join `test`.`t2`) on(((`test`.`t2`.`a` > 0) and (`test`.`t3`.`a` = 1) and (`test`.`t4`.`b` = `test`.`t3`.`b`) and (`test`.`t2`.`b` = `test`.`t3`.`b`) and (`test`.`t3`.`b` is not null))) where 1 SELECT t2.a,t2.b,t3.a,t3.b,t4.a,t4.b FROM (t3,t4) LEFT JOIN (t1,t2) -ON t3.a=1 AND t3.b=t2.b AND t2.b=t4.b; +ON t3.a=1 AND t3.b=t2.b AND t2.b=t4.b AND t2.a>0; a b a b a b 4 2 1 2 3 2 4 2 1 2 4 2 @@ -887,7 +888,7 @@ LEFT JOIN t2 LEFT JOIN (t3, t4) -ON t3.a=1 AND t2.b=t4.b, +ON t3.a=1 AND t2.b=t4.b AND t2.a>0, t5 LEFT JOIN ( @@ -916,16 +917,18 @@ t0.b=t1.b AND id select_type table type possible_keys key key_len ref rows filtered Extra 1 SIMPLE t0 ALL NULL NULL NULL NULL 3 100.00 Using where 1 SIMPLE t1 hash_ALL NULL #hash#$hj 5 test.t0.b 3 100.00 Using where; Using join buffer (flat, BNLH join) -1 SIMPLE t2 ALL NULL NULL NULL NULL 3 100.00 Using where; Using join buffer (incremental, BNL join) -1 SIMPLE t3 ALL NULL NULL NULL NULL 2 100.00 Using where; Using join buffer (incremental, BNL join) -1 SIMPLE t4 hash_ALL NULL #hash#$hj 5 test.t2.b 2 100.00 Using where; Using join buffer (incremental, BNLH join) 1 SIMPLE t5 ALL NULL NULL NULL NULL 3 100.00 Using where; Using join buffer (incremental, BNL join) 1 SIMPLE t7 hash_ALL NULL #hash#$hj 5 test.t5.b 2 100.00 Using where; Using join buffer (incremental, BNLH join) 1 SIMPLE t6 ALL NULL NULL NULL NULL 3 100.00 Using where; Using join buffer (incremental, BNL join) 1 SIMPLE t8 hash_ALL NULL #hash#$hj 5 test.t5.b 2 100.00 Using where; Using join buffer (incremental, BNLH join) +1 SIMPLE t2 ALL NULL NULL NULL NULL 8 100.00 Using where; Using join buffer (incremental, BNL join) +1 SIMPLE t4 hash_ALL NULL #hash#$hj 5 test.t2.b 2 100.00 Using where; Using join buffer (incremental, BNLH join) +1 SIMPLE t3 ALL NULL NULL NULL NULL 2 100.00 Using where; Using join buffer (incremental, BNL join) 1 SIMPLE t9 ALL NULL NULL NULL NULL 3 100.00 Using where; Using join buffer (incremental, BNL join) Warnings: -Note 1003 select `test`.`t0`.`a` AS `a`,`test`.`t0`.`b` AS `b`,`test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b`,`test`.`t3`.`a` AS `a`,`test`.`t3`.`b` AS `b`,`test`.`t4`.`a` AS `a`,`test`.`t4`.`b` AS `b`,`test`.`t5`.`a` AS `a`,`test`.`t5`.`b` AS `b`,`test`.`t6`.`a` AS `a`,`test`.`t6`.`b` AS `b`,`test`.`t7`.`a` AS `a`,`test`.`t7`.`b` AS `b`,`test`.`t8`.`a` AS `a`,`test`.`t8`.`b` AS `b`,`test`.`t9`.`a` AS `a`,`test`.`t9`.`b` AS `b` from `test`.`t0` join `test`.`t1` left join (`test`.`t2` left join (`test`.`t3` join `test`.`t4`) on(((`test`.`t3`.`a` = 1) and (`test`.`t4`.`b` = `test`.`t2`.`b`) and (`test`.`t2`.`b` is not null))) join `test`.`t5` left join (`test`.`t6` join `test`.`t7` left join `test`.`t8` on(((`test`.`t6`.`b` < 10) and (`test`.`t7`.`b` = `test`.`t5`.`b`) and (`test`.`t8`.`b` = `test`.`t5`.`b`) and (`test`.`t5`.`b` is not null)))) on(((`test`.`t6`.`b` >= 2) and (`test`.`t7`.`b` = `test`.`t5`.`b`) and (`test`.`t5`.`b` is not null)))) on((((`test`.`t3`.`b` = 2) or isnull(`test`.`t3`.`c`)) and ((`test`.`t6`.`b` = 2) or isnull(`test`.`t6`.`c`)) and (((`test`.`t1`.`b` = `test`.`t0`.`b`) and (`test`.`t5`.`b` = `test`.`t0`.`b`)) or isnull(`test`.`t3`.`c`) or isnull(`test`.`t6`.`c`) or isnull(`test`.`t8`.`c`)) and (`test`.`t1`.`a` <> 2))) join `test`.`t9` where ((`test`.`t9`.`a` = 1) and (`test`.`t1`.`b` = `test`.`t0`.`b`) and (`test`.`t0`.`a` = 1) and ((`test`.`t2`.`a` >= 4) or isnull(`test`.`t2`.`c`)) and ((`test`.`t3`.`a` < 5) or isnull(`test`.`t3`.`c`)) and ((`test`.`t4`.`b` = `test`.`t3`.`b`) or isnull(`test`.`t3`.`c`) or isnull(`test`.`t4`.`c`)) and ((`test`.`t5`.`a` >= 2) or isnull(`test`.`t5`.`c`)) and ((`test`.`t6`.`a` >= 4) or isnull(`test`.`t6`.`c`)) and ((`test`.`t7`.`a` <= 2) or isnull(`test`.`t7`.`c`)) and ((`test`.`t8`.`a` < 1) or isnull(`test`.`t8`.`c`)) and ((`test`.`t9`.`b` = `test`.`t8`.`b`) or isnull(`test`.`t8`.`c`))) +Note 1003 select `test`.`t0`.`a` AS `a`,`test`.`t0`.`b` AS `b`,`test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b`,`test`.`t3`.`a` AS `a`,`test`.`t3`.`b` AS `b`,`test`.`t4`.`a` AS `a`,`test`.`t4`.`b` AS `b`,`test`.`t5`.`a` AS `a`,`test`.`t5`.`b` AS `b`,`test`.`t6`.`a` AS `a`,`test`.`t6`.`b` AS `b`,`test`.`t7`.`a` AS `a`,`test`.`t7`.`b` AS `b`,`test`.`t8`.`a` AS `a`,`test`.`t8`.`b` AS `b`,`test`.`t9`.`a` AS `a`,`test`.`t9`.`b` AS `b` from `test`.`t0` join `test`.`t1` left join (`test`.`t2` left join (`test`.`t3` join `test`.`t4`) on(((`test`.`t2`.`a` > 0) and (`test`.`t3`.`a` = 1) and (`test`.`t4`.`b` = `test`.`t2`.`b`) and (`test`.`t2`.`b` is not null))) join `test`.`t5` left join (`test`.`t6` join `test`.`t7` left join `test`.`t8` on(((`test`.`t6`.`b` < 10) and (`test`.`t7`.`b` = `test`.`t5`.`b`) and (`test`.`t8`.`b` = `test`.`t5`.`b`) and (`test`.`t5`.`b` is not null)))) on(((`test`.`t6`.`b` >= 2) and (`test`.`t7`.`b` = `test`.`t5`.`b`) and (`test`.`t5`.`b` is not null)))) on((((`test`.`t3`.`b` = 2) or isnull(`test`.`t3`.`c`)) and ((`test`.`t6`.`b` = 2) or isnull(`test`.`t6`.`c`)) and (((`test`.`t1`.`b` = `test`.`t0`.`b`) and (`test`.`t5`.`b` = `test`.`t0`.`b`)) or isnull(`test`.`t3`.`c`) or isnull(`test`.`t6`.`c`) or isnull(`test`.`t8`.`c`)) and (`test`.`t1`.`a` <> 2))) join `test`.`t9` where ((`test`.`t9`.`a` = 1) and (`test`.`t1`.`b` = `test`.`t0`.`b`) and (`test`.`t0`.`a` = 1) and ((`test`.`t2`.`a` >= 4) or isnull(`test`.`t2`.`c`)) and ((`test`.`t3`.`a` < 5) or isnull(`test`.`t3`.`c`)) and ((`test`.`t3`.`b` = `test`.`t4`.`b`) or isnull(`test`.`t3`.`c`) or isnull(`test`.`t4`.`c`)) and ((`test`.`t5`.`a` >= 2) or isnull(`test`.`t5`.`c`)) and ((`test`.`t6`.`a` >= 4) or isnull(`test`.`t6`.`c`)) and ((`test`.`t7`.`a` <= 2) or isnull(`test`.`t7`.`c`)) and ((`test`.`t8`.`a` < 1) or isnull(`test`.`t8`.`c`)) and ((`test`.`t9`.`b` = `test`.`t8`.`b`) or isnull(`test`.`t8`.`c`))) +INSERT INTO t4 VALUES (-3,12,0), (-4,13,0), (-1,11,0), (-3,11,0), (-5,15,0); +INSERT INTO t5 VALUES (-3,11,0), (-2,12,0), (-3,13,0), (-4,12,0); CREATE INDEX idx_b ON t4(b); CREATE INDEX idx_b ON t5(b); EXPLAIN EXTENDED @@ -937,7 +940,7 @@ LEFT JOIN t2 LEFT JOIN (t3, t4) -ON t3.a=1 AND t2.b=t4.b, +ON t3.a=1 AND t2.b=t4.b AND t2.a>0 AND t4.a>0, t5 LEFT JOIN ( @@ -946,7 +949,7 @@ LEFT JOIN t8 ON t7.b=t8.b AND t6.b < 10 ) -ON t6.b >= 2 AND t5.b=t7.b +ON t6.b >= 2 AND t5.b=t7.b AND t5.a>0 ) ON (t3.b=2 OR t3.c IS NULL) AND (t6.b=2 OR t6.c IS NULL) AND (t1.b=t5.b OR t3.c IS NULL OR t6.c IS NULL or t8.c IS NULL) AND @@ -966,16 +969,17 @@ t0.b=t1.b AND id select_type table type possible_keys key key_len ref rows filtered Extra 1 SIMPLE t0 ALL NULL NULL NULL NULL 3 100.00 Using where 1 SIMPLE t1 hash_ALL NULL #hash#$hj 5 test.t0.b 3 100.00 Using where; Using join buffer (flat, BNLH join) -1 SIMPLE t2 ALL NULL NULL NULL NULL 3 100.00 Using where; Using join buffer (incremental, BNL join) +1 SIMPLE t9 ALL NULL NULL NULL NULL 3 100.00 Using where; Using join buffer (incremental, BNL join) +1 SIMPLE t2 ALL NULL NULL NULL NULL 8 100.00 Using where; Using join buffer (incremental, BNL join) 1 SIMPLE t3 ALL NULL NULL NULL NULL 2 100.00 Using where; Using join buffer (incremental, BNL join) 1 SIMPLE t4 ref idx_b idx_b 5 test.t2.b 2 100.00 Using where; Using join buffer (incremental, BKA join); Key-ordered Rowid-ordered scan -1 SIMPLE t5 ALL idx_b NULL NULL NULL 3 100.00 Using where; Using join buffer (incremental, BNL join) +1 SIMPLE t5 ALL idx_b NULL NULL NULL 7 100.00 Using where; Using join buffer (incremental, BNL join) 1 SIMPLE t7 hash_ALL NULL #hash#$hj 5 test.t5.b 2 100.00 Using where; Using join buffer (incremental, BNLH join) 1 SIMPLE t6 ALL NULL NULL NULL NULL 3 100.00 Using where; Using join buffer (incremental, BNL join) 1 SIMPLE t8 hash_ALL NULL #hash#$hj 5 test.t5.b 2 100.00 Using where; Using join buffer (incremental, BNLH join) -1 SIMPLE t9 ALL NULL NULL NULL NULL 3 100.00 Using where; Using join buffer (incremental, BNL join) Warnings: -Note 1003 select `test`.`t0`.`a` AS `a`,`test`.`t0`.`b` AS `b`,`test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b`,`test`.`t3`.`a` AS `a`,`test`.`t3`.`b` AS `b`,`test`.`t4`.`a` AS `a`,`test`.`t4`.`b` AS `b`,`test`.`t5`.`a` AS `a`,`test`.`t5`.`b` AS `b`,`test`.`t6`.`a` AS `a`,`test`.`t6`.`b` AS `b`,`test`.`t7`.`a` AS `a`,`test`.`t7`.`b` AS `b`,`test`.`t8`.`a` AS `a`,`test`.`t8`.`b` AS `b`,`test`.`t9`.`a` AS `a`,`test`.`t9`.`b` AS `b` from `test`.`t0` join `test`.`t1` left join (`test`.`t2` left join (`test`.`t3` join `test`.`t4`) on(((`test`.`t3`.`a` = 1) and (`test`.`t4`.`b` = `test`.`t2`.`b`) and (`test`.`t2`.`b` is not null))) join `test`.`t5` left join (`test`.`t6` join `test`.`t7` left join `test`.`t8` on(((`test`.`t6`.`b` < 10) and (`test`.`t7`.`b` = `test`.`t5`.`b`) and (`test`.`t8`.`b` = `test`.`t5`.`b`) and (`test`.`t5`.`b` is not null)))) on(((`test`.`t6`.`b` >= 2) and (`test`.`t7`.`b` = `test`.`t5`.`b`) and (`test`.`t5`.`b` is not null)))) on((((`test`.`t3`.`b` = 2) or isnull(`test`.`t3`.`c`)) and ((`test`.`t6`.`b` = 2) or isnull(`test`.`t6`.`c`)) and (((`test`.`t1`.`b` = `test`.`t0`.`b`) and (`test`.`t5`.`b` = `test`.`t0`.`b`)) or isnull(`test`.`t3`.`c`) or isnull(`test`.`t6`.`c`) or isnull(`test`.`t8`.`c`)) and (`test`.`t1`.`a` <> 2))) join `test`.`t9` where ((`test`.`t9`.`a` = 1) and (`test`.`t1`.`b` = `test`.`t0`.`b`) and (`test`.`t0`.`a` = 1) and ((`test`.`t2`.`a` >= 4) or isnull(`test`.`t2`.`c`)) and ((`test`.`t3`.`a` < 5) or isnull(`test`.`t3`.`c`)) and ((`test`.`t4`.`b` = `test`.`t3`.`b`) or isnull(`test`.`t3`.`c`) or isnull(`test`.`t4`.`c`)) and ((`test`.`t5`.`a` >= 2) or isnull(`test`.`t5`.`c`)) and ((`test`.`t6`.`a` >= 4) or isnull(`test`.`t6`.`c`)) and ((`test`.`t7`.`a` <= 2) or isnull(`test`.`t7`.`c`)) and ((`test`.`t8`.`a` < 1) or isnull(`test`.`t8`.`c`)) and ((`test`.`t9`.`b` = `test`.`t8`.`b`) or isnull(`test`.`t8`.`c`))) +Note 1003 select `test`.`t0`.`a` AS `a`,`test`.`t0`.`b` AS `b`,`test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b`,`test`.`t3`.`a` AS `a`,`test`.`t3`.`b` AS `b`,`test`.`t4`.`a` AS `a`,`test`.`t4`.`b` AS `b`,`test`.`t5`.`a` AS `a`,`test`.`t5`.`b` AS `b`,`test`.`t6`.`a` AS `a`,`test`.`t6`.`b` AS `b`,`test`.`t7`.`a` AS `a`,`test`.`t7`.`b` AS `b`,`test`.`t8`.`a` AS `a`,`test`.`t8`.`b` AS `b`,`test`.`t9`.`a` AS `a`,`test`.`t9`.`b` AS `b` from `test`.`t0` join `test`.`t1` left join (`test`.`t2` left join (`test`.`t3` join `test`.`t4`) on(((`test`.`t2`.`a` > 0) and (`test`.`t4`.`a` > 0) and (`test`.`t3`.`a` = 1) and (`test`.`t4`.`b` = `test`.`t2`.`b`) and (`test`.`t2`.`b` is not null))) join `test`.`t5` left join (`test`.`t6` join `test`.`t7` left join `test`.`t8` on(((`test`.`t6`.`b` < 10) and (`test`.`t7`.`b` = `test`.`t5`.`b`) and (`test`.`t8`.`b` = `test`.`t5`.`b`) and (`test`.`t5`.`b` is not null)))) on(((`test`.`t6`.`b` >= 2) and (`test`.`t5`.`a` > 0) and (`test`.`t7`.`b` = `test`.`t5`.`b`) and (`test`.`t5`.`b` is not null)))) on((((`test`.`t3`.`b` = 2) or isnull(`test`.`t3`.`c`)) and ((`test`.`t6`.`b` = 2) or isnull(`test`.`t6`.`c`)) and (((`test`.`t1`.`b` = `test`.`t0`.`b`) and (`test`.`t5`.`b` = `test`.`t0`.`b`)) or isnull(`test`.`t3`.`c`) or isnull(`test`.`t6`.`c`) or isnull(`test`.`t8`.`c`)) and (`test`.`t1`.`a` <> 2))) join `test`.`t9` where ((`test`.`t9`.`a` = 1) and (`test`.`t1`.`b` = `test`.`t0`.`b`) and (`test`.`t0`.`a` = 1) and ((`test`.`t2`.`a` >= 4) or isnull(`test`.`t2`.`c`)) and ((`test`.`t3`.`a` < 5) or isnull(`test`.`t3`.`c`)) and ((`test`.`t4`.`b` = `test`.`t3`.`b`) or isnull(`test`.`t3`.`c`) or isnull(`test`.`t4`.`c`)) and ((`test`.`t5`.`a` >= 2) or isnull(`test`.`t5`.`c`)) and ((`test`.`t6`.`a` >= 4) or isnull(`test`.`t6`.`c`)) and ((`test`.`t7`.`a` <= 2) or isnull(`test`.`t7`.`c`)) and ((`test`.`t8`.`a` < 1) or isnull(`test`.`t8`.`c`)) and ((`test`.`t8`.`b` = `test`.`t9`.`b`) or isnull(`test`.`t8`.`c`))) +INSERT INTO t8 VALUES (-3,12,0), (-1,14,0), (-5,15,0), (-1,11,0), (-4,13,0); CREATE INDEX idx_b ON t8(b); EXPLAIN EXTENDED SELECT t0.a,t0.b,t1.a,t1.b,t2.a,t2.b,t3.a,t3.b,t4.a,t4.b, @@ -986,16 +990,16 @@ LEFT JOIN t2 LEFT JOIN (t3, t4) -ON t3.a=1 AND t2.b=t4.b, +ON t3.a=1 AND t2.b=t4.b AND t2.a>0 AND t4.a>0, t5 LEFT JOIN ( (t6, t7) LEFT JOIN t8 -ON t7.b=t8.b AND t6.b < 10 +ON t7.b=t8.b AND t6.b < 10 AND t8.a>=0 ) -ON t6.b >= 2 AND t5.b=t7.b +ON t6.b >= 2 AND t5.b=t7.b AND t5.a>0 ) ON (t3.b=2 OR t3.c IS NULL) AND (t6.b=2 OR t6.c IS NULL) AND (t1.b=t5.b OR t3.c IS NULL OR t6.c IS NULL or t8.c IS NULL) AND @@ -1015,16 +1019,17 @@ t0.b=t1.b AND id select_type table type possible_keys key key_len ref rows filtered Extra 1 SIMPLE t0 ALL NULL NULL NULL NULL 3 100.00 Using where 1 SIMPLE t1 hash_ALL NULL #hash#$hj 5 test.t0.b 3 100.00 Using where; Using join buffer (flat, BNLH join) -1 SIMPLE t2 ALL NULL NULL NULL NULL 3 100.00 Using where; Using join buffer (incremental, BNL join) +1 SIMPLE t9 ALL NULL NULL NULL NULL 3 100.00 Using where; Using join buffer (incremental, BNL join) +1 SIMPLE t2 ALL NULL NULL NULL NULL 8 100.00 Using where; Using join buffer (incremental, BNL join) 1 SIMPLE t3 ALL NULL NULL NULL NULL 2 100.00 Using where; Using join buffer (incremental, BNL join) 1 SIMPLE t4 ref idx_b idx_b 5 test.t2.b 2 100.00 Using where; Using join buffer (incremental, BKA join); Key-ordered Rowid-ordered scan -1 SIMPLE t5 ALL idx_b NULL NULL NULL 3 100.00 Using where; Using join buffer (incremental, BNL join) -1 SIMPLE t7 hash_ALL NULL #hash#$hj 5 test.t5.b 2 100.00 Using where; Using join buffer (incremental, BNLH join) +1 SIMPLE t5 ALL idx_b NULL NULL NULL 7 100.00 Using where; Using join buffer (incremental, BNL join) 1 SIMPLE t6 ALL NULL NULL NULL NULL 3 100.00 Using where; Using join buffer (incremental, BNL join) +1 SIMPLE t7 hash_ALL NULL #hash#$hj 5 test.t5.b 2 100.00 Using where; Using join buffer (incremental, BNLH join) 1 SIMPLE t8 ref idx_b idx_b 5 test.t5.b 2 100.00 Using where; Using join buffer (incremental, BKA join); Key-ordered Rowid-ordered scan -1 SIMPLE t9 ALL NULL NULL NULL NULL 3 100.00 Using where; Using join buffer (incremental, BNL join) Warnings: -Note 1003 select `test`.`t0`.`a` AS `a`,`test`.`t0`.`b` AS `b`,`test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b`,`test`.`t3`.`a` AS `a`,`test`.`t3`.`b` AS `b`,`test`.`t4`.`a` AS `a`,`test`.`t4`.`b` AS `b`,`test`.`t5`.`a` AS `a`,`test`.`t5`.`b` AS `b`,`test`.`t6`.`a` AS `a`,`test`.`t6`.`b` AS `b`,`test`.`t7`.`a` AS `a`,`test`.`t7`.`b` AS `b`,`test`.`t8`.`a` AS `a`,`test`.`t8`.`b` AS `b`,`test`.`t9`.`a` AS `a`,`test`.`t9`.`b` AS `b` from `test`.`t0` join `test`.`t1` left join (`test`.`t2` left join (`test`.`t3` join `test`.`t4`) on(((`test`.`t3`.`a` = 1) and (`test`.`t4`.`b` = `test`.`t2`.`b`) and (`test`.`t2`.`b` is not null))) join `test`.`t5` left join (`test`.`t6` join `test`.`t7` left join `test`.`t8` on(((`test`.`t6`.`b` < 10) and (`test`.`t7`.`b` = `test`.`t5`.`b`) and (`test`.`t8`.`b` = `test`.`t5`.`b`) and (`test`.`t5`.`b` is not null)))) on(((`test`.`t6`.`b` >= 2) and (`test`.`t7`.`b` = `test`.`t5`.`b`) and (`test`.`t5`.`b` is not null)))) on((((`test`.`t3`.`b` = 2) or isnull(`test`.`t3`.`c`)) and ((`test`.`t6`.`b` = 2) or isnull(`test`.`t6`.`c`)) and (((`test`.`t1`.`b` = `test`.`t0`.`b`) and (`test`.`t5`.`b` = `test`.`t0`.`b`)) or isnull(`test`.`t3`.`c`) or isnull(`test`.`t6`.`c`) or isnull(`test`.`t8`.`c`)) and (`test`.`t1`.`a` <> 2))) join `test`.`t9` where ((`test`.`t9`.`a` = 1) and (`test`.`t1`.`b` = `test`.`t0`.`b`) and (`test`.`t0`.`a` = 1) and ((`test`.`t2`.`a` >= 4) or isnull(`test`.`t2`.`c`)) and ((`test`.`t3`.`a` < 5) or isnull(`test`.`t3`.`c`)) and ((`test`.`t4`.`b` = `test`.`t3`.`b`) or isnull(`test`.`t3`.`c`) or isnull(`test`.`t4`.`c`)) and ((`test`.`t5`.`a` >= 2) or isnull(`test`.`t5`.`c`)) and ((`test`.`t6`.`a` >= 4) or isnull(`test`.`t6`.`c`)) and ((`test`.`t7`.`a` <= 2) or isnull(`test`.`t7`.`c`)) and ((`test`.`t8`.`a` < 1) or isnull(`test`.`t8`.`c`)) and ((`test`.`t9`.`b` = `test`.`t8`.`b`) or isnull(`test`.`t8`.`c`))) +Note 1003 select `test`.`t0`.`a` AS `a`,`test`.`t0`.`b` AS `b`,`test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b`,`test`.`t3`.`a` AS `a`,`test`.`t3`.`b` AS `b`,`test`.`t4`.`a` AS `a`,`test`.`t4`.`b` AS `b`,`test`.`t5`.`a` AS `a`,`test`.`t5`.`b` AS `b`,`test`.`t6`.`a` AS `a`,`test`.`t6`.`b` AS `b`,`test`.`t7`.`a` AS `a`,`test`.`t7`.`b` AS `b`,`test`.`t8`.`a` AS `a`,`test`.`t8`.`b` AS `b`,`test`.`t9`.`a` AS `a`,`test`.`t9`.`b` AS `b` from `test`.`t0` join `test`.`t1` left join (`test`.`t2` left join (`test`.`t3` join `test`.`t4`) on(((`test`.`t2`.`a` > 0) and (`test`.`t4`.`a` > 0) and (`test`.`t3`.`a` = 1) and (`test`.`t4`.`b` = `test`.`t2`.`b`) and (`test`.`t2`.`b` is not null))) join `test`.`t5` left join (`test`.`t6` join `test`.`t7` left join `test`.`t8` on(((`test`.`t6`.`b` < 10) and (`test`.`t8`.`a` >= 0) and (`test`.`t7`.`b` = `test`.`t5`.`b`) and (`test`.`t8`.`b` = `test`.`t5`.`b`) and (`test`.`t5`.`b` is not null)))) on(((`test`.`t6`.`b` >= 2) and (`test`.`t5`.`a` > 0) and (`test`.`t7`.`b` = `test`.`t5`.`b`) and (`test`.`t5`.`b` is not null)))) on((((`test`.`t3`.`b` = 2) or isnull(`test`.`t3`.`c`)) and ((`test`.`t6`.`b` = 2) or isnull(`test`.`t6`.`c`)) and (((`test`.`t1`.`b` = `test`.`t0`.`b`) and (`test`.`t5`.`b` = `test`.`t0`.`b`)) or isnull(`test`.`t3`.`c`) or isnull(`test`.`t6`.`c`) or isnull(`test`.`t8`.`c`)) and (`test`.`t1`.`a` <> 2))) join `test`.`t9` where ((`test`.`t9`.`a` = 1) and (`test`.`t1`.`b` = `test`.`t0`.`b`) and (`test`.`t0`.`a` = 1) and ((`test`.`t2`.`a` >= 4) or isnull(`test`.`t2`.`c`)) and ((`test`.`t3`.`a` < 5) or isnull(`test`.`t3`.`c`)) and ((`test`.`t4`.`b` = `test`.`t3`.`b`) or isnull(`test`.`t3`.`c`) or isnull(`test`.`t4`.`c`)) and ((`test`.`t5`.`a` >= 2) or isnull(`test`.`t5`.`c`)) and ((`test`.`t6`.`a` >= 4) or isnull(`test`.`t6`.`c`)) and ((`test`.`t7`.`a` <= 2) or isnull(`test`.`t7`.`c`)) and ((`test`.`t8`.`a` < 1) or isnull(`test`.`t8`.`c`)) and ((`test`.`t8`.`b` = `test`.`t9`.`b`) or isnull(`test`.`t8`.`c`))) +INSERT INTO t1 VALUES (-1,133,0), (-2,12,0), (-3,11,0), (-5,15,0); CREATE INDEX idx_b ON t1(b); CREATE INDEX idx_a ON t0(a); EXPLAIN EXTENDED @@ -1049,7 +1054,7 @@ ON t6.b >= 2 AND t5.b=t7.b ) ON (t3.b=2 OR t3.c IS NULL) AND (t6.b=2 OR t6.c IS NULL) AND (t1.b=t5.b OR t3.c IS NULL OR t6.c IS NULL or t8.c IS NULL) AND -(t1.a != 2), +(t1.a != 2) AND t1.a>0, t9 WHERE t0.a=1 AND t0.b=t1.b AND @@ -1065,16 +1070,16 @@ t0.b=t1.b AND id select_type table type possible_keys key key_len ref rows filtered Extra 1 SIMPLE t0 ref idx_a idx_a 5 const 1 100.00 Using where 1 SIMPLE t1 ref idx_b idx_b 5 test.t0.b 2 100.00 Using join buffer (flat, BKA join); Key-ordered Rowid-ordered scan -1 SIMPLE t2 ALL NULL NULL NULL NULL 3 100.00 Using where; Using join buffer (incremental, BNL join) +1 SIMPLE t9 ALL NULL NULL NULL NULL 3 100.00 Using where; Using join buffer (incremental, BNL join) +1 SIMPLE t2 ALL NULL NULL NULL NULL 8 100.00 Using where; Using join buffer (incremental, BNL join) 1 SIMPLE t3 ALL NULL NULL NULL NULL 2 100.00 Using where; Using join buffer (incremental, BNL join) 1 SIMPLE t4 ref idx_b idx_b 5 test.t2.b 2 100.00 Using where; Using join buffer (incremental, BKA join); Key-ordered Rowid-ordered scan -1 SIMPLE t5 ALL idx_b NULL NULL NULL 3 100.00 Using where; Using join buffer (incremental, BNL join) +1 SIMPLE t5 ALL idx_b NULL NULL NULL 7 100.00 Using where; Using join buffer (incremental, BNL join) 1 SIMPLE t7 hash_ALL NULL #hash#$hj 5 test.t5.b 2 100.00 Using where; Using join buffer (incremental, BNLH join) 1 SIMPLE t6 ALL NULL NULL NULL NULL 3 100.00 Using where; Using join buffer (incremental, BNL join) 1 SIMPLE t8 ref idx_b idx_b 5 test.t7.b 2 100.00 Using where; Using join buffer (incremental, BKA join); Key-ordered Rowid-ordered scan -1 SIMPLE t9 ALL NULL NULL NULL NULL 3 100.00 Using where; Using join buffer (incremental, BNL join) Warnings: -Note 1003 select `test`.`t0`.`a` AS `a`,`test`.`t0`.`b` AS `b`,`test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b`,`test`.`t3`.`a` AS `a`,`test`.`t3`.`b` AS `b`,`test`.`t4`.`a` AS `a`,`test`.`t4`.`b` AS `b`,`test`.`t5`.`a` AS `a`,`test`.`t5`.`b` AS `b`,`test`.`t6`.`a` AS `a`,`test`.`t6`.`b` AS `b`,`test`.`t7`.`a` AS `a`,`test`.`t7`.`b` AS `b`,`test`.`t8`.`a` AS `a`,`test`.`t8`.`b` AS `b`,`test`.`t9`.`a` AS `a`,`test`.`t9`.`b` AS `b` from `test`.`t0` join `test`.`t1` left join (`test`.`t2` left join (`test`.`t3` join `test`.`t4`) on(((`test`.`t3`.`a` = 1) and (`test`.`t4`.`b` = `test`.`t2`.`b`) and (`test`.`t2`.`b` is not null))) join `test`.`t5` left join (`test`.`t6` join `test`.`t7` left join `test`.`t8` on(((`test`.`t6`.`b` < 10) and (`test`.`t7`.`b` = `test`.`t5`.`b`) and (`test`.`t8`.`b` = `test`.`t5`.`b`) and (`test`.`t7`.`b` is not null)))) on(((`test`.`t6`.`b` >= 2) and (`test`.`t7`.`b` = `test`.`t5`.`b`) and (`test`.`t5`.`b` is not null)))) on((((`test`.`t3`.`b` = 2) or isnull(`test`.`t3`.`c`)) and ((`test`.`t6`.`b` = 2) or isnull(`test`.`t6`.`c`)) and (((`test`.`t1`.`b` = `test`.`t0`.`b`) and (`test`.`t5`.`b` = `test`.`t0`.`b`)) or isnull(`test`.`t3`.`c`) or isnull(`test`.`t6`.`c`) or isnull(`test`.`t8`.`c`)) and (`test`.`t1`.`a` <> 2))) join `test`.`t9` where ((`test`.`t9`.`a` = 1) and (`test`.`t1`.`b` = `test`.`t0`.`b`) and (`test`.`t0`.`a` = 1) and ((`test`.`t2`.`a` >= 4) or isnull(`test`.`t2`.`c`)) and ((`test`.`t3`.`a` < 5) or isnull(`test`.`t3`.`c`)) and ((`test`.`t4`.`b` = `test`.`t3`.`b`) or isnull(`test`.`t3`.`c`) or isnull(`test`.`t4`.`c`)) and ((`test`.`t5`.`a` >= 2) or isnull(`test`.`t5`.`c`)) and ((`test`.`t6`.`a` >= 4) or isnull(`test`.`t6`.`c`)) and ((`test`.`t7`.`a` <= 2) or isnull(`test`.`t7`.`c`)) and ((`test`.`t8`.`a` < 1) or isnull(`test`.`t8`.`c`)) and ((`test`.`t9`.`b` = `test`.`t8`.`b`) or isnull(`test`.`t8`.`c`))) +Note 1003 select `test`.`t0`.`a` AS `a`,`test`.`t0`.`b` AS `b`,`test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b`,`test`.`t3`.`a` AS `a`,`test`.`t3`.`b` AS `b`,`test`.`t4`.`a` AS `a`,`test`.`t4`.`b` AS `b`,`test`.`t5`.`a` AS `a`,`test`.`t5`.`b` AS `b`,`test`.`t6`.`a` AS `a`,`test`.`t6`.`b` AS `b`,`test`.`t7`.`a` AS `a`,`test`.`t7`.`b` AS `b`,`test`.`t8`.`a` AS `a`,`test`.`t8`.`b` AS `b`,`test`.`t9`.`a` AS `a`,`test`.`t9`.`b` AS `b` from `test`.`t0` join `test`.`t1` left join (`test`.`t2` left join (`test`.`t3` join `test`.`t4`) on(((`test`.`t3`.`a` = 1) and (`test`.`t4`.`b` = `test`.`t2`.`b`) and (`test`.`t2`.`b` is not null))) join `test`.`t5` left join (`test`.`t6` join `test`.`t7` left join `test`.`t8` on(((`test`.`t6`.`b` < 10) and (`test`.`t7`.`b` = `test`.`t5`.`b`) and (`test`.`t8`.`b` = `test`.`t5`.`b`) and (`test`.`t7`.`b` is not null)))) on(((`test`.`t6`.`b` >= 2) and (`test`.`t7`.`b` = `test`.`t5`.`b`) and (`test`.`t5`.`b` is not null)))) on((((`test`.`t3`.`b` = 2) or isnull(`test`.`t3`.`c`)) and ((`test`.`t6`.`b` = 2) or isnull(`test`.`t6`.`c`)) and (((`test`.`t1`.`b` = `test`.`t0`.`b`) and (`test`.`t5`.`b` = `test`.`t0`.`b`)) or isnull(`test`.`t3`.`c`) or isnull(`test`.`t6`.`c`) or isnull(`test`.`t8`.`c`)) and (`test`.`t1`.`a` <> 2) and (`test`.`t1`.`a` > 0))) join `test`.`t9` where ((`test`.`t9`.`a` = 1) and (`test`.`t1`.`b` = `test`.`t0`.`b`) and (`test`.`t0`.`a` = 1) and ((`test`.`t2`.`a` >= 4) or isnull(`test`.`t2`.`c`)) and ((`test`.`t3`.`a` < 5) or isnull(`test`.`t3`.`c`)) and ((`test`.`t4`.`b` = `test`.`t3`.`b`) or isnull(`test`.`t3`.`c`) or isnull(`test`.`t4`.`c`)) and ((`test`.`t5`.`a` >= 2) or isnull(`test`.`t5`.`c`)) and ((`test`.`t6`.`a` >= 4) or isnull(`test`.`t6`.`c`)) and ((`test`.`t7`.`a` <= 2) or isnull(`test`.`t7`.`c`)) and ((`test`.`t8`.`a` < 1) or isnull(`test`.`t8`.`c`)) and ((`test`.`t8`.`b` = `test`.`t9`.`b`) or isnull(`test`.`t8`.`c`))) SELECT t0.a,t0.b,t1.a,t1.b,t2.a,t2.b,t3.a,t3.b,t4.a,t4.b, t5.a,t5.b,t6.a,t6.b,t7.a,t7.b,t8.a,t8.b,t9.a,t9.b FROM t0,t1 @@ -1096,7 +1101,7 @@ ON t6.b >= 2 AND t5.b=t7.b ) ON (t3.b=2 OR t3.c IS NULL) AND (t6.b=2 OR t6.c IS NULL) AND (t1.b=t5.b OR t3.c IS NULL OR t6.c IS NULL or t8.c IS NULL) AND -(t1.a != 2), +(t1.a != 2) AND t1.a>0, t9 WHERE t0.a=1 AND t0.b=t1.b AND @@ -1110,15 +1115,15 @@ t0.b=t1.b AND (t8.b=t9.b OR t8.c IS NULL) AND (t9.a=1); a b a b a b a b a b a b a b a b a b a b -1 2 3 2 4 2 1 2 3 2 2 2 6 2 2 2 0 2 1 2 1 2 3 2 4 2 1 2 4 2 2 2 6 2 2 2 0 2 1 2 +1 2 3 2 4 2 1 2 3 2 2 2 6 2 2 2 0 2 1 2 1 2 3 2 4 2 1 2 3 2 3 1 6 2 1 1 NULL NULL 1 1 -1 2 3 2 4 2 1 2 4 2 3 1 6 2 1 1 NULL NULL 1 1 1 2 3 2 4 2 1 2 3 2 3 1 6 2 1 1 NULL NULL 1 2 +1 2 3 2 4 2 1 2 4 2 3 1 6 2 1 1 NULL NULL 1 1 1 2 3 2 4 2 1 2 4 2 3 1 6 2 1 1 NULL NULL 1 2 1 2 3 2 4 2 1 2 3 2 3 3 NULL NULL NULL NULL NULL NULL 1 1 -1 2 3 2 4 2 1 2 4 2 3 3 NULL NULL NULL NULL NULL NULL 1 1 1 2 3 2 4 2 1 2 3 2 3 3 NULL NULL NULL NULL NULL NULL 1 2 +1 2 3 2 4 2 1 2 4 2 3 3 NULL NULL NULL NULL NULL NULL 1 1 1 2 3 2 4 2 1 2 4 2 3 3 NULL NULL NULL NULL NULL NULL 1 2 1 2 3 2 5 3 NULL NULL NULL NULL 2 2 6 2 2 2 0 2 1 2 1 2 3 2 5 3 NULL NULL NULL NULL 3 1 6 2 1 1 NULL NULL 1 1 @@ -1133,6 +1138,11 @@ a b 3 3 4 2 5 3 +-1 9 +-3 10 +-2 8 +-4 11 +-5 15 SELECT t3.a,t3.b FROM t3; a b @@ -1850,6 +1860,9 @@ INSERT INTO t5 VALUES (1,1,0), (2,2,0), (3,3,0); INSERT INTO t6 VALUES (1,2,0), (3,2,0), (6,1,0); INSERT INTO t7 VALUES (1,1,0), (2,2,0); INSERT INTO t8 VALUES (0,2,0), (1,2,0); +INSERT INTO t6 VALUES (-1,12,0), (-3,13,0), (-6,11,0), (-4,14,0); +INSERT INTO t7 VALUES (-1,11,0), (-2,12,0), (-3,13,0), (-4,14,0), (-5,15,0); +INSERT INTO t8 VALUES (-3,13,0), (-1,12,0), (-2,14,0), (-5,15,0), (-4,16,0); EXPLAIN SELECT t5.a,t5.b,t6.a,t6.b,t7.a,t7.b,t8.a,t8.b FROM t5 @@ -1858,14 +1871,14 @@ LEFT JOIN (t6, t7) LEFT JOIN t8 -ON t7.b=t8.b AND t6.b < 10 +ON t7.b=t8.b AND t6.b < 10 ) ON t6.b >= 2 AND t5.b=t7.b AND -(t8.a > 0 OR t8.c IS NULL); +(t8.a > 0 OR t8.c IS NULL) AND t6.a>0 AND t7.a>0; id select_type table type possible_keys key key_len ref rows Extra 1 SIMPLE t5 ALL NULL NULL NULL NULL 3 -1 SIMPLE t7 ref b_i b_i 5 test.t5.b 2 Using where; Using join buffer (flat, BKA join); Key-ordered Rowid-ordered scan -1 SIMPLE t6 ALL b_i NULL NULL NULL 3 Using where; Using join buffer (incremental, BNL join) +1 SIMPLE t7 ref PRIMARY,b_i b_i 5 test.t5.b 2 Using where; Using join buffer (flat, BKA join); Key-ordered Rowid-ordered scan +1 SIMPLE t6 ALL PRIMARY,b_i NULL NULL NULL 7 Using where; Using join buffer (incremental, BNL join) 1 SIMPLE t8 ref b_i b_i 5 test.t5.b 2 Using where; Using join buffer (incremental, BKA join); Key-ordered Rowid-ordered scan SELECT t5.a,t5.b,t6.a,t6.b,t7.a,t7.b,t8.a,t8.b FROM t5 @@ -1877,7 +1890,7 @@ t8 ON t7.b=t8.b AND t6.b < 10 ) ON t6.b >= 2 AND t5.b=t7.b AND -(t8.a > 0 OR t8.c IS NULL); +(t8.a > 0 OR t8.c IS NULL) AND t6.a>0 AND t7.a>0; a b a b a b a b 2 2 1 2 2 2 1 2 2 2 3 2 2 2 1 2 diff --git a/mysql-test/r/join_outer.result b/mysql-test/r/join_outer.result index 918ed1f21e6..49ea07c5dff 100644 --- a/mysql-test/r/join_outer.result +++ b/mysql-test/r/join_outer.result @@ -1685,7 +1685,7 @@ id select_type table type possible_keys key key_len ref rows filtered Extra 2 DEPENDENT SUBQUERY t4 eq_ref PRIMARY PRIMARY 4 test.t3.pk 1 100.00 Using where; Using index Warnings: Note 1276 Field or reference 'test.t2.pk' of SELECT #2 was resolved in SELECT #1 -Note 1003 select `test`.`t2`.`pk` AS `pk`,(select (`test`.`t3`.`pk` + if(isnull(`test`.`t4`.`pk`),0,`test`.`t4`.`pk`)) from `test`.`t3` left join `test`.`t4` on((`test`.`t4`.`pk` = `test`.`t3`.`pk`)) where (`test`.`t3`.`pk` = (`test`.`t2`.`pk` + 1000)) limit 1) AS `t` from `test`.`t1` join `test`.`t2` where ((`test`.`t2`.`pk` = (`test`.`t1`.`pk` + 1000)) and (`test`.`t1`.`pk` > 1000)) group by `test`.`t2`.`pk` +Note 1003 select `test`.`t2`.`pk` AS `pk`,<expr_cache><`test`.`t2`.`pk`>((select (`test`.`t3`.`pk` + if(isnull(`test`.`t4`.`pk`),0,`test`.`t4`.`pk`)) from `test`.`t3` left join `test`.`t4` on((`test`.`t4`.`pk` = `test`.`t3`.`pk`)) where (`test`.`t3`.`pk` = (`test`.`t2`.`pk` + 1000)) limit 1)) AS `t` from `test`.`t1` join `test`.`t2` where ((`test`.`t2`.`pk` = (`test`.`t1`.`pk` + 1000)) and (`test`.`t1`.`pk` > 1000)) group by `test`.`t2`.`pk` select t2.pk, (select t3.pk+if(isnull(t4.pk),0,t4.pk) from t3 left join t4 on t4.pk=t3.pk @@ -1725,6 +1725,8 @@ create table t2 like t1; insert into t2 select if(t1.a is null, 10, t1.a) from t1; create table t3 (a int, b int, index idx(a)); insert into t3 values (1, 100), (3, 301), (4, 402), (1, 102), (1, 101); +insert into t3 values (11, 100), (33, 301), (44, 402), (11, 102), (11, 101); +insert into t3 values (22, 100), (53, 301), (64, 402), (22, 102), (22, 101); analyze table t1,t2,t3; Table Op Msg_type Msg_text test.t1 analyze status OK @@ -1842,3 +1844,58 @@ FROM t1 LEFT JOIN t2 ON (t2.b) IN (SELECT c2 from t3) AND t2.a = 1; b NULL DROP TABLE t1,t2,t3; +# +# lp:825035 second execution of PS with outer join +# +CREATE TABLE t1 (a int); +INSERT INTO t1 VALUES (1),(2),(3),(4); +CREATE TABLE t2 (a int); +PREPARE stmt FROM +"SELECT * FROM t1 LEFT JOIN t2 ON t1.a = t2.a"; +EXECUTE stmt; +a a +1 NULL +2 NULL +3 NULL +4 NULL +EXECUTE stmt; +a a +1 NULL +2 NULL +3 NULL +4 NULL +DEALLOCATE PREPARE stmt; +DROP TABLE t1,t2; +# +# lp:838633 second execution of PS with outer join +# converted to inner join +# +CREATE TABLE t1 ( b int NOT NULL ) ; +INSERT INTO t1 VALUES (9),(10); +CREATE TABLE t2 ( b int NOT NULL, PRIMARY KEY (b)) ; +INSERT INTO t2 VALUES +(75),(76),(77),(78),(79),(80),(81),(82),(83),(84),(85),(86),(87),(88),(89), +(10), (90),(91),(92),(93),(94),(95),(96),(97),(98),(99),(100); +CREATE TABLE t3 ( a int, b int NOT NULL , PRIMARY KEY (b)) ; +INSERT INTO t3 VALUES +(0,6),(0,7),(0,8),(2,9),(0,10),(2,21),(0,22),(2,23),(2,24),(2,25); +SET SESSION join_cache_level=4; +EXPLAIN EXTENDED +SELECT * FROM (t2 LEFT JOIN t1 ON t1.b = t2.b) JOIN t3 ON t1.b = t3.b; +id select_type table type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 ALL NULL NULL NULL NULL 2 100.00 +1 SIMPLE t3 hash_ALL PRIMARY #hash#PRIMARY 4 test.t1.b 10 10.00 Using join buffer (flat, BNLH join) +1 SIMPLE t2 hash_index PRIMARY #hash#PRIMARY:PRIMARY 4:4 test.t1.b 27 3.70 Using join buffer (incremental, BNLH join) +Warnings: +Note 1003 select `test`.`t2`.`b` AS `b`,`test`.`t1`.`b` AS `b`,`test`.`t3`.`a` AS `a`,`test`.`t3`.`b` AS `b` from `test`.`t2` join `test`.`t1` join `test`.`t3` where ((`test`.`t3`.`b` = `test`.`t1`.`b`) and (`test`.`t2`.`b` = `test`.`t1`.`b`)) +PREPARE stmt FROM +'SELECT * FROM (t2 LEFT JOIN t1 ON t1.b = t2.b) JOIN t3 ON t1.b = t3.b'; +EXECUTE stmt; +b b a b +10 10 0 10 +EXECUTE stmt; +b b a b +10 10 0 10 +DEALLOCATE PREPARE stmt; +SET SESSION join_cache_level=default; +DROP TABLE t1,t2,t3; diff --git a/mysql-test/r/join_outer_jcl6.result b/mysql-test/r/join_outer_jcl6.result index 69f7052235b..4a53ff636cb 100644 --- a/mysql-test/r/join_outer_jcl6.result +++ b/mysql-test/r/join_outer_jcl6.result @@ -1694,7 +1694,7 @@ id select_type table type possible_keys key key_len ref rows filtered Extra 2 DEPENDENT SUBQUERY t4 eq_ref PRIMARY PRIMARY 4 test.t3.pk 1 100.00 Using where; Using index Warnings: Note 1276 Field or reference 'test.t2.pk' of SELECT #2 was resolved in SELECT #1 -Note 1003 select `test`.`t2`.`pk` AS `pk`,(select (`test`.`t3`.`pk` + if(isnull(`test`.`t4`.`pk`),0,`test`.`t4`.`pk`)) from `test`.`t3` left join `test`.`t4` on((`test`.`t4`.`pk` = `test`.`t3`.`pk`)) where (`test`.`t3`.`pk` = (`test`.`t2`.`pk` + 1000)) limit 1) AS `t` from `test`.`t1` join `test`.`t2` where ((`test`.`t2`.`pk` = (`test`.`t1`.`pk` + 1000)) and (`test`.`t1`.`pk` > 1000)) group by `test`.`t2`.`pk` +Note 1003 select `test`.`t2`.`pk` AS `pk`,<expr_cache><`test`.`t2`.`pk`>((select (`test`.`t3`.`pk` + if(isnull(`test`.`t4`.`pk`),0,`test`.`t4`.`pk`)) from `test`.`t3` left join `test`.`t4` on((`test`.`t4`.`pk` = `test`.`t3`.`pk`)) where (`test`.`t3`.`pk` = (`test`.`t2`.`pk` + 1000)) limit 1)) AS `t` from `test`.`t1` join `test`.`t2` where ((`test`.`t2`.`pk` = (`test`.`t1`.`pk` + 1000)) and (`test`.`t1`.`pk` > 1000)) group by `test`.`t2`.`pk` select t2.pk, (select t3.pk+if(isnull(t4.pk),0,t4.pk) from t3 left join t4 on t4.pk=t3.pk @@ -1734,6 +1734,8 @@ create table t2 like t1; insert into t2 select if(t1.a is null, 10, t1.a) from t1; create table t3 (a int, b int, index idx(a)); insert into t3 values (1, 100), (3, 301), (4, 402), (1, 102), (1, 101); +insert into t3 values (11, 100), (33, 301), (44, 402), (11, 102), (11, 101); +insert into t3 values (22, 100), (53, 301), (64, 402), (22, 102), (22, 101); analyze table t1,t2,t3; Table Op Msg_type Msg_text test.t1 analyze status OK @@ -1851,6 +1853,61 @@ FROM t1 LEFT JOIN t2 ON (t2.b) IN (SELECT c2 from t3) AND t2.a = 1; b NULL DROP TABLE t1,t2,t3; +# +# lp:825035 second execution of PS with outer join +# +CREATE TABLE t1 (a int); +INSERT INTO t1 VALUES (1),(2),(3),(4); +CREATE TABLE t2 (a int); +PREPARE stmt FROM +"SELECT * FROM t1 LEFT JOIN t2 ON t1.a = t2.a"; +EXECUTE stmt; +a a +1 NULL +2 NULL +3 NULL +4 NULL +EXECUTE stmt; +a a +1 NULL +2 NULL +3 NULL +4 NULL +DEALLOCATE PREPARE stmt; +DROP TABLE t1,t2; +# +# lp:838633 second execution of PS with outer join +# converted to inner join +# +CREATE TABLE t1 ( b int NOT NULL ) ; +INSERT INTO t1 VALUES (9),(10); +CREATE TABLE t2 ( b int NOT NULL, PRIMARY KEY (b)) ; +INSERT INTO t2 VALUES +(75),(76),(77),(78),(79),(80),(81),(82),(83),(84),(85),(86),(87),(88),(89), +(10), (90),(91),(92),(93),(94),(95),(96),(97),(98),(99),(100); +CREATE TABLE t3 ( a int, b int NOT NULL , PRIMARY KEY (b)) ; +INSERT INTO t3 VALUES +(0,6),(0,7),(0,8),(2,9),(0,10),(2,21),(0,22),(2,23),(2,24),(2,25); +SET SESSION join_cache_level=4; +EXPLAIN EXTENDED +SELECT * FROM (t2 LEFT JOIN t1 ON t1.b = t2.b) JOIN t3 ON t1.b = t3.b; +id select_type table type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 ALL NULL NULL NULL NULL 2 100.00 +1 SIMPLE t3 hash_ALL PRIMARY #hash#PRIMARY 4 test.t1.b 10 10.00 Using join buffer (flat, BNLH join) +1 SIMPLE t2 hash_index PRIMARY #hash#PRIMARY:PRIMARY 4:4 test.t1.b 27 3.70 Using join buffer (incremental, BNLH join) +Warnings: +Note 1003 select `test`.`t2`.`b` AS `b`,`test`.`t1`.`b` AS `b`,`test`.`t3`.`a` AS `a`,`test`.`t3`.`b` AS `b` from `test`.`t2` join `test`.`t1` join `test`.`t3` where ((`test`.`t3`.`b` = `test`.`t1`.`b`) and (`test`.`t2`.`b` = `test`.`t1`.`b`)) +PREPARE stmt FROM +'SELECT * FROM (t2 LEFT JOIN t1 ON t1.b = t2.b) JOIN t3 ON t1.b = t3.b'; +EXECUTE stmt; +b b a b +10 10 0 10 +EXECUTE stmt; +b b a b +10 10 0 10 +DEALLOCATE PREPARE stmt; +SET SESSION join_cache_level=default; +DROP TABLE t1,t2,t3; set join_cache_level=default; show variables like 'join_cache_level'; Variable_name Value diff --git a/mysql-test/r/kill.result b/mysql-test/r/kill.result index 699c1fc4463..36dd37611c4 100644 --- a/mysql-test/r/kill.result +++ b/mysql-test/r/kill.result @@ -161,7 +161,7 @@ SET DEBUG_SYNC = 'RESET'; # Connection: con1. SET DEBUG_SYNC= 'thread_end SIGNAL con1_end'; KILL @id; -ERROR 70100: Query execution was interrupted +ERROR 70100: Connection was killed SET DEBUG_SYNC= 'now WAIT_FOR con1_end'; # ER_SERVER_SHUTDOWN, CR_SERVER_GONE_ERROR, CR_SERVER_LOST, # depending on the timing of close of the connection socket @@ -275,5 +275,28 @@ unlock tables; # Switching to connection 'default' drop table t1; drop table t2; +# +# Test kill USER +# +grant ALL on test.* to test@localhost; +grant ALL on test.* to test2@localhost; +kill hard query user test2@nohost; +affected rows: 0 +kill soft query user test@localhost; +affected rows: 1 +kill hard query user test@localhost; +affected rows: 1 +kill soft connection user test2; +affected rows: 1 +kill hard connection user test@localhost; +affected rows: 1 +revoke all privileges on test.* from test@localhost; +revoke all privileges on test.* from test2@localhost; +drop user test@localhost; +drop user test2@localhost; +select 1; +Got one of the listed errors +select 1; +Got one of the listed errors SET DEBUG_SYNC = 'RESET'; DROP FUNCTION MY_KILL; diff --git a/mysql-test/r/maria_icp.result b/mysql-test/r/maria_icp.result index 81bf90f5439..255ec069eb0 100644 --- a/mysql-test/r/maria_icp.result +++ b/mysql-test/r/maria_icp.result @@ -83,6 +83,150 @@ c1 c2 c3 c4 DROP TABLE t1; # +# Bug#43617 - Innodb returns wrong results with timestamp's range value +# in IN clause +# (Note: Fixed by patch for BUG#42580) +# +CREATE TABLE t1( +c1 TIMESTAMP NOT NULL, +c2 TIMESTAMP NULL, +c3 DATE, +c4 DATETIME, +PRIMARY KEY(c1), +UNIQUE INDEX(c2) +); +INSERT INTO t1 VALUES +('0000-00-00 00:00:00','0000-00-00 00:00:00','2008-01-04','2008-01-05 00:00:00'), +('1971-01-01 00:00:01','1980-01-01 00:00:01','2009-01-01','2009-01-02 00:00:00'), +('1999-01-01 00:00:00','1999-01-01 00:00:00', NULL, NULL), +('2007-05-23 09:15:28','2007-05-23 09:15:28','2007-05-24','2007-05-24 09:15:28'), +('2007-05-27 00:00:00','2007-05-25 00:00:00','2007-05-26','2007-05-26 00:00:00'), +('2008-01-01 00:00:00', NULL, '2008-01-02','2008-01-03 00:00:00'), +('2009-01-29 11:11:27','2009-01-29 11:11:27','2009-01-29','2009-01-29 11:11:27'), +('2038-01-09 03:14:07','2038-01-09 03:14:07','2009-01-05','2009-01-06 00:00:00'); + +SELECT * +FROM t1 +WHERE c2 IN ('1971-01-01 00:00:01','2038-01-09 03:14:07') +ORDER BY c2; +c1 c2 c3 c4 +2038-01-09 03:14:07 2038-01-09 03:14:07 2009-01-05 2009-01-06 00:00:00 + +SELECT * +FROM t1 +WHERE c2 IN ('1971-01-01 00:00:01','2038-01-09 03:14:07') +ORDER BY c2 LIMIT 2; +c1 c2 c3 c4 +2038-01-09 03:14:07 2038-01-09 03:14:07 2009-01-05 2009-01-06 00:00:00 + +SELECT * +FROM t1 +WHERE c2 IN ('1971-01-01 00:00:01','2038-01-09 03:14:07') +ORDER BY c2 DESC; +c1 c2 c3 c4 +2038-01-09 03:14:07 2038-01-09 03:14:07 2009-01-05 2009-01-06 00:00:00 + +SELECT * +FROM t1 +WHERE c2 IN ('1971-01-01 00:00:01','2038-01-09 03:14:07') +ORDER BY c2 DESC LIMIT 2; +c1 c2 c3 c4 +2038-01-09 03:14:07 2038-01-09 03:14:07 2009-01-05 2009-01-06 00:00:00 + +DROP TABLE t1; +# +# BUG#43618: MyISAM&Maria returns wrong results with 'between' +# on timestamp +# +CREATE TABLE t1( +ts TIMESTAMP NOT NULL, +c char NULL, +PRIMARY KEY(ts) +); +INSERT INTO t1 VALUES +('1971-01-01','a'), +('2007-05-25','b'), +('2008-01-01','c'), +('2038-01-09','d'); + +# Execute select with invalid timestamp, desc ordering +SELECT * +FROM t1 +WHERE ts BETWEEN '0000-00-00' AND '2010-00-01 00:00:00' +ORDER BY ts DESC +LIMIT 2; +ts c +2008-01-01 00:00:00 c +2007-05-25 00:00:00 b + +# Should use index condition +EXPLAIN +SELECT * +FROM t1 +WHERE ts BETWEEN '0000-00-00' AND '2010-00-01 00:00:00' +ORDER BY ts DESC +LIMIT 2; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t1 range PRIMARY PRIMARY 4 NULL 4 Using index condition + +DROP TABLE t1; +# +# BUG#49906: Assertion failed - Field_varstring::val_str in field.cc +# (Note: Fixed by patch for LP BUG#625841) +# +CREATE TABLE t1 ( +f1 VARCHAR(1024), +f2 VARCHAR(10), +INDEX test_idx USING BTREE (f2,f1(5)) +); +INSERT INTO t1 VALUES ('a','c'), ('b','d'); +SELECT f1 +FROM t1 +WHERE f2 LIKE 'd' +ORDER BY f1; +f1 +b +DROP TABLE t1; +# +# Bug#52660 - "Perf. regr. using ICP for MyISAM on range queries on +# an index containing TEXT" +# +CREATE TABLE t1 (a INT); +INSERT INTO t1 VALUES (0),(1),(2),(3),(4),(5),(6),(7),(8),(9); +CREATE TABLE t2 (a INT); +INSERT INTO t2 SELECT A.a + 10*(B.a) FROM t1 A, t1 B; +CREATE TABLE t3 ( +c1 TINYTEXT NOT NULL, +i1 INT NOT NULL, +KEY (c1(6),i1) +); +INSERT INTO t3 SELECT CONCAT('c-',1000+t2.a,'=w'), 1 FROM t2; +EXPLAIN +SELECT c1 FROM t3 WHERE c1 >= 'c-1004=w' and c1 <= 'c-1006=w'; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t3 range c1 c1 8 NULL 3 Using where +SELECT c1 FROM t3 WHERE c1 >= 'c-1004=w' and c1 <= 'c-1006=w'; +c1 +c-1004=w +c-1005=w +c-1006=w +EXPLAIN +SELECT c1 FROM t3 WHERE c1 >= 'c-1004=w' and c1 <= 'c-1006=w' and i1 > 2; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t3 range c1 c1 12 NULL 2 Using index condition; Using where +SELECT c1 FROM t3 WHERE c1 >= 'c-1004=w' and c1 <= 'c-1006=w' and i1 > 2; +c1 +EXPLAIN +SELECT c1 FROM t3 WHERE c1 >= 'c-1004=w' and c1 <= 'c-1006=w' or i1 > 2; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t3 ALL c1 NULL NULL NULL 100 Using where +SELECT c1 FROM t3 WHERE c1 >= 'c-1004=w' and c1 <= 'c-1006=w' or i1 > 2; +c1 +c-1004=w +c-1005=w +c-1006=w +DROP TABLE t1, t2, t3; +# # Bug#40992 - InnoDB: Crash when engine_condition_pushdown is on # CREATE TABLE t ( @@ -203,6 +347,266 @@ COUNT(*) DROP PROCEDURE insert_data; DROP TABLE t1, t2, t3; # +# Bug#57372 "Multi-table updates and deletes fail when running with ICP +# against InnoDB" +# +CREATE TABLE t1 ( +a INT KEY, +b INT +); +CREATE TABLE t2 ( +a INT KEY, +b INT +); +INSERT INTO t1 VALUES (1, 101), (2, 102), (3, 103), (4, 104), (5, 105); +INSERT INTO t2 VALUES (1, 1), (2, 2), (3, 3), (4, 4), (5, 5); +UPDATE t1, t2 +SET t1.a = t1.a + 100, t2.b = t1.a + 10 +WHERE t1.a BETWEEN 2 AND 4 AND t2.a = t1.b - 100; +SELECT * FROM t1; +a b +1 101 +102 102 +103 103 +104 104 +5 105 +SELECT * FROM t2; +a b +1 1 +2 12 +3 13 +4 14 +5 5 +DROP TABLE t1, t2; +# +# Bug#52605 - "Adding LIMIT 1 clause to query with complex range +# predicate causes wrong results" +# +CREATE TABLE t1 ( +pk INT NOT NULL, +c1 INT, +PRIMARY KEY (pk), +KEY k1 (c1) +); +INSERT INTO t1 VALUES (1,NULL); +INSERT INTO t1 VALUES (2,6); +INSERT INTO t1 VALUES (3,NULL); +INSERT INTO t1 VALUES (4,6); +INSERT INTO t1 VALUES (5,NULL); +INSERT INTO t1 VALUES (6,NULL); +INSERT INTO t1 VALUES (7,9); +INSERT INTO t1 VALUES (8,0); +SELECT pk, c1 +FROM t1 +WHERE (pk BETWEEN 4 AND 5 OR pk < 2) AND c1 < 240 +ORDER BY c1 +LIMIT 1; +pk c1 +4 6 +EXPLAIN SELECT pk, c1 +FROM t1 +WHERE (pk BETWEEN 4 AND 5 OR pk < 2) AND c1 < 240 +ORDER BY c1 +LIMIT 1; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t1 range PRIMARY,k1 k1 5 NULL 4 Using where +DROP TABLE t1; +# +# Bug#59259 "Incorrect rows returned for a correlated subquery +# when ICP is on" +# +CREATE TABLE t1 (pk INTEGER PRIMARY KEY, i INTEGER NOT NULL) ENGINE=InnoDB; +Warnings: +Warning 1286 Unknown storage engine 'InnoDB' +Warning 1266 Using storage engine Aria for table 't1' +INSERT INTO t1 VALUES (11,0); +INSERT INTO t1 VALUES (12,5); +INSERT INTO t1 VALUES (15,0); +CREATE TABLE t2 (pk INTEGER PRIMARY KEY, i INTEGER NOT NULL) ENGINE=InnoDB; +Warnings: +Warning 1286 Unknown storage engine 'InnoDB' +Warning 1266 Using storage engine Aria for table 't2' +INSERT INTO t2 VALUES (11,1); +INSERT INTO t2 VALUES (12,2); +INSERT INTO t2 VALUES (15,4); +set @save_optimizer_switch= @@optimizer_switch; +set optimizer_switch='semijoin=off'; +EXPLAIN +SELECT * FROM t1 +WHERE pk IN (SELECT it.pk FROM t2 JOIN t2 AS it ON it.i=it.i WHERE it.pk-t1.i<10); +id select_type table type possible_keys key key_len ref rows Extra +1 PRIMARY t1 ALL NULL NULL NULL NULL 3 Using where +2 DEPENDENT SUBQUERY t2 index NULL PRIMARY 4 NULL 3 Using index +2 DEPENDENT SUBQUERY it eq_ref PRIMARY PRIMARY 4 func 1 Using index condition +SELECT * FROM t1 +WHERE pk IN (SELECT it.pk FROM t2 JOIN t2 AS it ON it.i=it.i WHERE it.pk-t1.i<10); +pk i +12 5 +set optimizer_switch=@save_optimizer_switch; +DROP TABLE t1, t2; +# +# Bug #58816 "Extra temporary duplicate rows in result set when +# switching ICP off" +# +set @save_optimizer_switch= @@optimizer_switch; +CREATE TABLE t1 ( +pk INT NOT NULL, +c1 INT NOT NULL, +PRIMARY KEY (pk) +); +INSERT INTO t1 VALUES (1,9),(2,7),(3,6),(4,3),(5,1); +EXPLAIN SELECT pk, c1 FROM t1 WHERE pk <> 3; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t1 ALL PRIMARY NULL NULL NULL 5 Using where +SET SESSION optimizer_switch='index_condition_pushdown=off'; +SELECT pk, c1 FROM t1 WHERE pk <> 3; +pk c1 +1 9 +2 7 +4 3 +5 1 +DROP TABLE t1; +set optimizer_switch= @save_optimizer_switch; +# +# Bug#58837: ICP crash or valgrind error due to uninitialized +# value in innobase_index_cond +# +CREATE TABLE t1 ( +t1_int INT, +t1_time TIME +); +CREATE TABLE t2 ( +t2_int int PRIMARY KEY, +t2_int2 INT +); +INSERT INTO t2 VALUES (); +INSERT INTO t1 VALUES (); +SELECT * FROM t1 AS t1a +WHERE NOT EXISTS (SELECT * FROM t1 AS t1b +WHERE t1b.t1_int NOT IN +(SELECT t2.t2_int FROM t2 +WHERE t1b.t1_time LIKE t1b.t1_int +OR t1b.t1_time <> t2.t2_int2 +AND 6=7)); +t1_int t1_time +DROP TABLE t1,t2; +# +# Bug#59186: Wrong results of join when ICP is enabled +# (fixed by the patch for LP bug #694092) +# +CREATE TABLE t1 ( +pk INTEGER NOT NULL, +c1 VARCHAR(3) NOT NULL, +PRIMARY KEY (pk) +); +INSERT INTO t1 VALUES (1,'y'),(0,'or'); +CREATE TABLE t2 ( +pk INTEGER NOT NULL, +c1 VARCHAR(3) NOT NULL, +c2 VARCHAR(6) NOT NULL, +PRIMARY KEY (pk) +); +INSERT INTO t2 VALUES (6,'y','RPOYT'),(10,'m','JINQE'); +EXPLAIN +SELECT c2 FROM t1 JOIN t2 ON t1.c1 = t2.c1 +WHERE (t2.pk <= 4 AND t1.pk IN (2,1)) OR +(t1.pk > 1 AND t2.pk BETWEEN 6 AND 6); +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t1 range PRIMARY PRIMARY 4 NULL 2 Using index condition; Using where; Rowid-ordered scan +1 SIMPLE t2 range PRIMARY PRIMARY 4 NULL 2 Using index condition; Using where; Rowid-ordered scan; Using join buffer (flat, BNL join) +SELECT c2 FROM t1 JOIN t2 ON t1.c1 = t2.c1 +WHERE (t2.pk <= 4 AND t1.pk IN (2,1)) OR +(t1.pk > 1 AND t2.pk BETWEEN 6 AND 6); +c2 +DROP TABLE t1, t2; +# +# Bug#58838: "Wrong results with HAVING + LIMIT without GROUP BY when +# ICP is enabled". +# (Fixed by the patches for LP bugs #668644, #702322) +# +CREATE TABLE t1 ( +pk INT NOT NULL, +c1 INT, +PRIMARY KEY (pk), +KEY col_int_key (c1) +); +INSERT INTO t1 VALUES (1,37),(2,8),(3,-25),(4,NULL),(5,55); +SELECT pk FROM t1 WHERE c1 <> 1 HAVING pk = 3 ORDER BY pk LIMIT 0; +pk +SELECT pk FROM t1 WHERE c1 <> 1 HAVING pk = 3 ORDER BY pk LIMIT 1; +pk +3 +SELECT pk FROM t1 WHERE c1 <> 1 HAVING pk = 3 ORDER BY pk LIMIT 2; +pk +3 +SELECT pk FROM t1 WHERE c1 <> 1 HAVING pk = 3 ORDER BY pk LIMIT 5; +pk +3 +DROP TABLE t1; +# +# Bug#59483 "Crash on INSERT/REPLACE in +# rec_convert_dtuple_to_rec_comp with ICP on" +# +CREATE TABLE t1 ( +pk INTEGER AUTO_INCREMENT PRIMARY KEY, +i1 INTEGER, +c1 CHAR(6), +i2 INTEGER NOT NULL, +KEY (i2) +); +INSERT INTO t1 VALUES +(NULL, 4, 'that', 8), +(NULL, 1, 'she', 6), +(NULL, 6, 'tell', 2); +SELECT * FROM t1 WHERE i2 IN (3, 6) LIMIT 2 FOR UPDATE; +pk i1 c1 i2 +2 1 she 6 +INSERT INTO t1 (i2) VALUES (1); +DROP TABLE t1; +# +# Bug #11766678 - 59843: +# USING UNINITIALISED VALUE IN USES_INDEX_FIELDS_ONLY +# +CREATE TABLE t1 ( +col999 FLOAT NOT NULL, +COL1000 VARBINARY(179) NOT NULL, +col1003 DATE DEFAULT NULL, +KEY idx4267 (col1000, col1003) +); +INSERT INTO t1 VALUES (),(); +Warnings: +Warning 1364 Field 'col999' doesn't have a default value +Warning 1364 Field 'COL1000' doesn't have a default value +SELECT col999 FROM t1 WHERE col1000 = "3" AND col1003 <=> sysdate(); +col999 +DROP TABLE t1; +# +# BUG#12822678 - ICP WITH STRAIGHT_JOIN +# +CREATE TABLE t1 ( +i1 INTEGER NOT NULL, +d1 DOUBLE, +KEY k1 (d1) +); +INSERT INTO t1 VALUES (10,1), (17,NULL), (22,NULL); +CREATE TABLE t2 ( +pk INTEGER NOT NULL, +i1 INTEGER NOT NULL, +PRIMARY KEY (pk) +); +INSERT INTO t2 VALUES (4,1); +EXPLAIN +SELECT t1.d1, t2.pk, t2.i1 FROM t1 STRAIGHT_JOIN t2 ON t2.i1 +WHERE t2.pk <> t1.d1 AND t2.pk = 4; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t1 index NULL k1 9 NULL 3 Using index +1 SIMPLE t2 const PRIMARY PRIMARY 4 const 1 Using where +SELECT t1.d1, t2.pk, t2.i1 FROM t1 STRAIGHT_JOIN t2 ON t2.i1 +WHERE t2.pk <> t1.d1 AND t2.pk = 4; +d1 pk i1 +1 4 1 +DROP TABLE t1, t2; +# # BUG#778434 Wrong result with in_to_exists=on in maria-5.3-mwl89 # CREATE TABLE t1 ( f11 int) ; @@ -225,5 +629,83 @@ FROM t3 JOIN t4 ON t4.f11 = t3.f10 f11 f10 DROP TABLE t1,t2,t3,t4; set optimizer_switch= @tmp_778434; +# +# Bug#885168: ICP for one index + potential ORDER BY for another +# +CREATE TABLE t1 (a varchar(64), b varchar(10), INDEX(a), INDEX(b)) ; +INSERT INTO t1 VALUES +('Ohio','Iowa'), ('k','d'), ('bdkpj','mbdkpjdanp'), ('d','xdmbdkpjda'), +('fkxdmbdkpjdanpje','o'), ('f','Pennsylvan'), ('Virginia','ei'); +SET SESSION optimizer_switch='index_condition_pushdown=off'; +EXPLAIN +SELECT * FROM t1 +WHERE NOT(b = 'Texas') AND b BETWEEN 'wy' AND 'y' OR b = 'Pennsylvania' + ORDER BY a; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t1 range b b 13 NULL 2 Using where; Rowid-ordered scan; Using filesort +SELECT * FROM t1 +WHERE NOT(b = 'Texas') AND b BETWEEN 'wy' AND 'y' OR b = 'Pennsylvania' + ORDER BY a; +a b +d xdmbdkpjda +SET SESSION optimizer_switch='index_condition_pushdown=on'; +EXPLAIN +SELECT * FROM t1 +WHERE NOT(b = 'Texas') AND b BETWEEN 'wy' AND 'y' OR b = 'Pennsylvania' + ORDER BY a; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t1 range b b 13 NULL 2 Using index condition; Using where; Rowid-ordered scan; Using filesort +SELECT * FROM t1 +WHERE NOT(b = 'Texas') AND b BETWEEN 'wy' AND 'y' OR b = 'Pennsylvania' + ORDER BY a; +a b +d xdmbdkpjda +DROP TABLE t1; +# +# Bug#886145: join with ICP + ORDER BY +# +CREATE TABLE t1 (b int NOT NULL, c int, a varchar(1024), PRIMARY KEY (b)); +INSERT INTO t1 VALUES (1,4,'Ill'); +CREATE TABLE t2 (a varchar(1024), KEY (a(512))); +INSERT INTO t2 VALUES +('Ill'), ('eckqzsflbzaffti'), ('w'), ('she'), ('gxbwypqtjzwywwer'), ('w'); +SET SESSION optimizer_switch='index_condition_pushdown=off'; +EXPLAIN +SELECT t1.b, t1.c FROM t1, t2 WHERE t1.a = t2.a AND t1.b != 0 +HAVING t1.c != 5 ORDER BY t1.c; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t1 system PRIMARY NULL NULL NULL 1 +1 SIMPLE t2 ref a a 515 const 1 Using where +SELECT t1.b, t1.c FROM t1, t2 WHERE t1.a = t2.a AND t1.b != 0 +HAVING t1.c != 5 ORDER BY t1.c; +b c +1 4 +SET SESSION optimizer_switch='index_condition_pushdown=on'; +EXPLAIN +SELECT t1.b, t1.c FROM t1, t2 WHERE t1.a = t2.a AND t1.b != 0 +HAVING t1.c != 5 ORDER BY t1.c; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t1 system PRIMARY NULL NULL NULL 1 +1 SIMPLE t2 ref a a 515 const 1 Using where +SELECT t1.b, t1.c FROM t1, t2 WHERE t1.a = t2.a AND t1.b != 0 +HAVING t1.c != 5 ORDER BY t1.c; +b c +1 4 +DROP TABLE t1,t2; +# +# Bug#879871: InnoDB: possible ICP + GROUP BY primary index +# +CREATE TABLE t1 ( +a int NOT NULL, b int, c varchar(1), d varchar(1), +PRIMARY KEY (a), KEY c (c,b) +); +INSERT INTO t1 VALUES (10,8,'g','g'); +SET SESSION optimizer_switch='index_condition_pushdown=off'; +SELECT a FROM t1 WHERE c IS NULL AND d IS NOT NULL GROUP BY 1; +a +SET SESSION optimizer_switch='index_condition_pushdown=on'; +SELECT a FROM t1 WHERE c IS NULL AND d IS NOT NULL GROUP BY 1; +a +DROP TABLE t1; set storage_engine= @save_storage_engine; set optimizer_switch=@maria_icp_tmp; diff --git a/mysql-test/r/maria_mrr.result b/mysql-test/r/maria_mrr.result index 52e8a916003..c94f16ea1fb 100644 --- a/mysql-test/r/maria_mrr.result +++ b/mysql-test/r/maria_mrr.result @@ -187,7 +187,7 @@ explain select * from t4 where a IS NULL and b IS NULL and (c IS NULL or c='no-such-row1' or c='no-such-row2'); id select_type table type possible_keys key key_len ref rows Extra -1 SIMPLE t4 range idx1 idx1 29 NULL 16 Using index condition; Rowid-ordered scan +1 SIMPLE t4 range idx1 idx1 29 NULL 16 Using index condition; Using where; Rowid-ordered scan select * from t4 where a IS NULL and b IS NULL and (c IS NULL or c='no-such-row1' or c='no-such-row2'); a b c filler @@ -209,7 +209,7 @@ NULL NULL NULL NULL-1 explain select * from t4 where (a ='b-1' or a='bb-1') and b IS NULL and (c='c-1' or c='cc-2'); id select_type table type possible_keys key key_len ref rows Extra -1 SIMPLE t4 range idx1 idx1 29 NULL 32 Using index condition; Rowid-ordered scan +1 SIMPLE t4 range idx1 idx1 29 NULL 32 Using index condition; Using where; Rowid-ordered scan select * from t4 where (a ='b-1' or a='bb-1') and b IS NULL and (c='c-1' or c='cc-2'); a b c filler b-1 NULL c-1 NULL-15 @@ -349,7 +349,9 @@ pk int NOT NULL, i int NOT NULL, v varchar(1) NOT NULL, PRIMARY KEY (pk), INDEX idx (v, i) ) ENGINE=ARIA; INSERT INTO t3 SELECT * FROM t1; -INSERT INTO t3 VALUES (88, 442, 'y'), (99, 445, 'w') ; +INSERT INTO t3 VALUES +(88, 442, 'y'), (99, 445, 'w'), (87, 442, 'z'), (98, 445, 'v'), (86, 442, 'x'), +(97, 445, 't'), (85, 442, 'b'), (96, 445, 'l'), (84, 442, 'a'), (95, 445, 'k'); SELECT COUNT(t1.v) FROM t1, t2 IGNORE INDEX (idx), t3 IGNORE INDEX (idx) WHERE t3.v = t2.v AND t3.i < t2.i AND t3.pk > 0 AND t2.pk > 0; COUNT(t1.v) @@ -360,7 +362,7 @@ WHERE t3.v = t2.v AND t3.i < t2.i AND t3.pk > 0 AND t2.pk > 0; id select_type table type possible_keys key key_len ref rows Extra 1 SIMPLE t1 index NULL idx 7 NULL 15 Using index 1 SIMPLE t2 ALL PRIMARY NULL NULL NULL 16 Using where; Using join buffer (flat, BNL join) -1 SIMPLE t3 ALL PRIMARY NULL NULL NULL 17 Using where; Using join buffer (flat, BNL join) +1 SIMPLE t3 ALL PRIMARY NULL NULL NULL 25 Using where; Using join buffer (flat, BNL join) SELECT COUNT(t1.v) FROM t1, t2, t3 WHERE t3.v = t2.v AND t3.i < t2.i AND t3.pk > 0 AND t2.pk > 0; COUNT(t1.v) @@ -386,11 +388,8 @@ PRIMARY KEY (pk), KEY col_varchar_1024_latin1_key (col_varchar_1024_latin1_key) ) ENGINE=Aria; INSERT INTO t1 VALUES -(1,'z'), -(2,'abcdefjhjkl'), -(3,'in'), -(4,'abcdefjhjkl'), -(6,'abcdefjhjkl'); +(1,'z'), (2,'abcdefjhjkl'), (3,'in'), (4,'abcdefjhjkl'), (6,'abcdefjhjkl'), +(11,'zx'), (12,'abcdefjhjm'), (13,'jn'), (14,'abcdefjhjp'), (16,'abcdefjhjr'); CREATE TABLE t2 ( col_varchar_10_latin1 varchar(10) DEFAULT NULL ) ENGINE=Aria; diff --git a/mysql-test/r/merge.result b/mysql-test/r/merge.result index 0e1a598bcab..622640a897c 100644 --- a/mysql-test/r/merge.result +++ b/mysql-test/r/merge.result @@ -904,7 +904,8 @@ SELECT * FROM tm1; ERROR HY000: Unable to open underlying table which is differently defined or of non-MyISAM type or doesn't exist CHECK TABLE tm1; Table Op Msg_type Msg_text -test.tm1 check Error Table 'test.t1' doesn't exist +test.tm1 check Error Table 'test.t1' is differently defined or of non-MyISAM type or doesn't exist +test.tm1 check Error Table 'test.t2' is differently defined or of non-MyISAM type or doesn't exist test.tm1 check Error Unable to open underlying table which is differently defined or of non-MyISAM type or doesn't exist test.tm1 check error Corrupt CREATE TABLE t1(a INT); @@ -912,7 +913,7 @@ SELECT * FROM tm1; ERROR HY000: Unable to open underlying table which is differently defined or of non-MyISAM type or doesn't exist CHECK TABLE tm1; Table Op Msg_type Msg_text -test.tm1 check Error Table 'test.t2' doesn't exist +test.tm1 check Error Table 'test.t2' is differently defined or of non-MyISAM type or doesn't exist test.tm1 check Error Unable to open underlying table which is differently defined or of non-MyISAM type or doesn't exist test.tm1 check error Corrupt CREATE TABLE t2(a BLOB); @@ -920,7 +921,7 @@ SELECT * FROM tm1; ERROR HY000: Unable to open underlying table which is differently defined or of non-MyISAM type or doesn't exist CHECK TABLE tm1; Table Op Msg_type Msg_text -test.tm1 check Warning Table 'test.t2' is differently defined or of non-MyISAM type or doesn't exist +test.tm1 check Error Table 'test.t2' is differently defined or of non-MyISAM type or doesn't exist test.tm1 check Error Unable to open underlying table which is differently defined or of non-MyISAM type or doesn't exist test.tm1 check error Corrupt ALTER TABLE t2 MODIFY a INT; @@ -3618,7 +3619,7 @@ test.t1 analyze Error Unable to open underlying table which is differently defin test.t1 analyze error Corrupt CHECK TABLE t1; Table Op Msg_type Msg_text -test.t1 check Error Table 'test.t_not_exists' doesn't exist +test.t1 check Error Table 'test.t_not_exists' is differently defined or of non-MyISAM type or doesn't exist test.t1 check Error Unable to open underlying table which is differently defined or of non-MyISAM type or doesn't exist test.t1 check error Corrupt CHECKSUM TABLE t1; @@ -3634,7 +3635,7 @@ test.t1 optimize Error Unable to open underlying table which is differently defi test.t1 optimize error Corrupt REPAIR TABLE t1; Table Op Msg_type Msg_text -test.t1 repair Error Table 'test.t_not_exists' doesn't exist +test.t1 repair Error Table 'test.t_not_exists' is differently defined or of non-MyISAM type or doesn't exist test.t1 repair Error Unable to open underlying table which is differently defined or of non-MyISAM type or doesn't exist test.t1 repair error Corrupt REPAIR TABLE t1 USE_FRM; @@ -3660,4 +3661,37 @@ ALTER TABLE t1 engine=myisam; ERROR HY000: Table 't1' was locked with a READ lock and can't be updated UNLOCK TABLES; DROP TABLE m1, t1; -End of 6.0 tests +# +# Test for bug #11754210 - "45777: CHECK TABLE DOESN'T SHOW ALL +# PROBLEMS FOR MERGE TABLE COMPLIANCE IN 5.1" +# +drop tables if exists t1, t2, t3, t4, m1; +create table t1(id int) engine=myisam; +create view t3 as select 1 as id; +create table t4(id int) engine=memory; +create table m1(id int) engine=merge union=(t1,t2,t3,t4); +select * from m1; +ERROR HY000: Unable to open underlying table which is differently defined or of non-MyISAM type or doesn't exist +# The below CHECK and REPAIR TABLE statements should +# report all problems with underlying tables: +# - absence of 't2', +# - missing base table for 't3', +# - wrong engine of 't4'. +check table m1; +Table Op Msg_type Msg_text +test.m1 check Error Table 'test.t2' is differently defined or of non-MyISAM type or doesn't exist +test.m1 check Error Table 'test.t3' is differently defined or of non-MyISAM type or doesn't exist +test.m1 check Error Table 'test.t4' is differently defined or of non-MyISAM type or doesn't exist +test.m1 check Error Unable to open underlying table which is differently defined or of non-MyISAM type or doesn't exist +test.m1 check error Corrupt +repair table m1; +Table Op Msg_type Msg_text +test.m1 repair Error Table 'test.t2' is differently defined or of non-MyISAM type or doesn't exist +test.m1 repair Error Table 'test.t3' is differently defined or of non-MyISAM type or doesn't exist +test.m1 repair Error Table 'test.t4' is differently defined or of non-MyISAM type or doesn't exist +test.m1 repair Error Unable to open underlying table which is differently defined or of non-MyISAM type or doesn't exist +test.m1 repair error Corrupt +# Clean-up. +drop tables m1, t1, t4; +drop view t3; +End of 5.5 tests diff --git a/mysql-test/r/mrr_icp_extra.result b/mysql-test/r/mrr_icp_extra.result index 9163267d356..5e49fb6e956 100644 --- a/mysql-test/r/mrr_icp_extra.result +++ b/mysql-test/r/mrr_icp_extra.result @@ -69,9 +69,10 @@ DROP TABLE t1,t2,t3; # create table t1(a int, b int, index(b)); insert into t1 values (2, 1), (1, 1), (4, NULL), (3, NULL), (6, 2), (5, 2); +insert into t1 values (2, 11), (1, 11), (4, 14), (3, 14), (6, 12), (5, 12); explain select * from t1 where b=1 or b is null order by a; id select_type table type possible_keys key key_len ref rows Extra -1 SIMPLE t1 ref_or_null b b 5 const 3 Using index condition; Using filesort +1 SIMPLE t1 ref_or_null b b 5 const 4 Using index condition; Using where; Using filesort select * from t1 where b=1 or b is null order by a; a b 1 1 @@ -80,7 +81,7 @@ a b 4 NULL explain select * from t1 where b=2 or b is null order by a; id select_type table type possible_keys key key_len ref rows Extra -1 SIMPLE t1 ref_or_null b b 5 const 4 Using index condition; Using filesort +1 SIMPLE t1 ref_or_null b b 5 const 3 Using index condition; Using where; Using filesort select * from t1 where b=2 or b is null order by a; a b 3 NULL @@ -104,7 +105,7 @@ id select_type table type possible_keys key key_len ref rows Extra 1 SIMPLE t1 range FieldKey FieldKey 38 NULL 4 Using index condition; Rowid-ordered scan; Using filesort EXPLAIN SELECT * FROM t1 IGNORE INDEX (FieldKey, LongField) WHERE FieldKey > '2' ORDER BY LongVal; id select_type table type possible_keys key key_len ref rows Extra -1 SIMPLE t1 range StringField StringField 38 NULL 4 Using where; Using filesort +1 SIMPLE t1 range StringField StringField 38 NULL 4 Using index condition; Using filesort SELECT * FROM t1 WHERE FieldKey > '2' ORDER BY LongVal; FieldKey LongVal StringVal 3 1 2 @@ -122,7 +123,7 @@ Table Op Msg_type Msg_text test.t1 optimize status OK explain select * from t1 force index (a) where a=0 or a=2; id select_type table type possible_keys key key_len ref rows Extra -1 SIMPLE t1 range a a 4 NULL 4 Using index condition; Rowid-ordered scan +1 SIMPLE t1 range a a 4 NULL 4 Using index condition; Using where; Rowid-ordered scan select * from t1 force index (a) where a=0 or a=2; a b c 0 NULL 0 diff --git a/mysql-test/r/myisam.result b/mysql-test/r/myisam.result index 9b096fe70d3..ad714fdb91b 100644 --- a/mysql-test/r/myisam.result +++ b/mysql-test/r/myisam.result @@ -329,7 +329,7 @@ ALTER TABLE t1 ADD INDEX t1 (a, b, c, d, e); ERROR 42000: Specified key was too long; max key length is 1000 bytes DROP TABLE t1; CREATE TABLE t1 (a int not null, b int, c int, key(b), key(c), key(a,b), key(c,a)); -INSERT into t1 values (0, null, 0), (0, null, 1), (0, null, 2), (0, null,3), (1,1,4); +INSERT into t1 values (0,null,0), (0,null,1), (0,null,2), (0,null,3), (1,1,4); create table t2 (a int not null, b int, c int, key(b), key(c), key(a)); INSERT into t2 values (1,1,1), (2,2,2); optimize table t1; @@ -355,10 +355,34 @@ explain select * from t1 force index(a),t2 force index(a) where t1.a=t2.a; id select_type table type possible_keys key key_len ref rows Extra 1 SIMPLE t2 ALL a NULL NULL NULL 2 1 SIMPLE t1 ref a a 4 test.t2.a 3 +INSERT into t1 values (2,4,5), (7,8,4), (8,3,1), (9,7,2), (5,5,9); +optimize table t1; +Table Op Msg_type Msg_text +test.t1 optimize status OK +show index from t1; +Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment +t1 1 b 1 b A 10 NULL NULL YES BTREE +t1 1 c 1 c A 10 NULL NULL YES BTREE +t1 1 a 1 a A 10 NULL NULL BTREE +t1 1 a 2 b A 10 NULL NULL YES BTREE +t1 1 c_2 1 c A 10 NULL NULL YES BTREE +t1 1 c_2 2 a A 10 NULL NULL BTREE explain select * from t1,t2 where t1.b=t2.b; id select_type table type possible_keys key key_len ref rows Extra 1 SIMPLE t2 ALL b NULL NULL NULL 2 Using where 1 SIMPLE t1 ref b b 5 test.t2.b 1 +delete from t1 where t1.a>1; +optimize table t1; +Table Op Msg_type Msg_text +test.t1 optimize status OK +show index from t1; +Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment +t1 1 b 1 b A 5 NULL NULL YES BTREE +t1 1 c 1 c A 5 NULL NULL YES BTREE +t1 1 a 1 a A 1 NULL NULL BTREE +t1 1 a 2 b A 5 NULL NULL YES BTREE +t1 1 c_2 1 c A 5 NULL NULL YES BTREE +t1 1 c_2 2 a A 5 NULL NULL BTREE explain select * from t1,t2 force index(c) where t1.a=t2.a; id select_type table type possible_keys key key_len ref rows Extra 1 SIMPLE t2 ALL NULL NULL NULL NULL 2 diff --git a/mysql-test/r/myisam_icp.result b/mysql-test/r/myisam_icp.result index d3e1114b39c..0426e1bdfba 100644 --- a/mysql-test/r/myisam_icp.result +++ b/mysql-test/r/myisam_icp.result @@ -1,3 +1,5 @@ +set @myisam_icp_tmp=@@optimizer_switch; +set optimizer_switch='mrr=on,mrr_sort_keys=on,index_condition_pushdown=on'; # # Bug#36981 - "innodb crash when selecting for update" # @@ -79,6 +81,150 @@ c1 c2 c3 c4 DROP TABLE t1; # +# Bug#43617 - Innodb returns wrong results with timestamp's range value +# in IN clause +# (Note: Fixed by patch for BUG#42580) +# +CREATE TABLE t1( +c1 TIMESTAMP NOT NULL, +c2 TIMESTAMP NULL, +c3 DATE, +c4 DATETIME, +PRIMARY KEY(c1), +UNIQUE INDEX(c2) +); +INSERT INTO t1 VALUES +('0000-00-00 00:00:00','0000-00-00 00:00:00','2008-01-04','2008-01-05 00:00:00'), +('1971-01-01 00:00:01','1980-01-01 00:00:01','2009-01-01','2009-01-02 00:00:00'), +('1999-01-01 00:00:00','1999-01-01 00:00:00', NULL, NULL), +('2007-05-23 09:15:28','2007-05-23 09:15:28','2007-05-24','2007-05-24 09:15:28'), +('2007-05-27 00:00:00','2007-05-25 00:00:00','2007-05-26','2007-05-26 00:00:00'), +('2008-01-01 00:00:00', NULL, '2008-01-02','2008-01-03 00:00:00'), +('2009-01-29 11:11:27','2009-01-29 11:11:27','2009-01-29','2009-01-29 11:11:27'), +('2038-01-09 03:14:07','2038-01-09 03:14:07','2009-01-05','2009-01-06 00:00:00'); + +SELECT * +FROM t1 +WHERE c2 IN ('1971-01-01 00:00:01','2038-01-09 03:14:07') +ORDER BY c2; +c1 c2 c3 c4 +2038-01-09 03:14:07 2038-01-09 03:14:07 2009-01-05 2009-01-06 00:00:00 + +SELECT * +FROM t1 +WHERE c2 IN ('1971-01-01 00:00:01','2038-01-09 03:14:07') +ORDER BY c2 LIMIT 2; +c1 c2 c3 c4 +2038-01-09 03:14:07 2038-01-09 03:14:07 2009-01-05 2009-01-06 00:00:00 + +SELECT * +FROM t1 +WHERE c2 IN ('1971-01-01 00:00:01','2038-01-09 03:14:07') +ORDER BY c2 DESC; +c1 c2 c3 c4 +2038-01-09 03:14:07 2038-01-09 03:14:07 2009-01-05 2009-01-06 00:00:00 + +SELECT * +FROM t1 +WHERE c2 IN ('1971-01-01 00:00:01','2038-01-09 03:14:07') +ORDER BY c2 DESC LIMIT 2; +c1 c2 c3 c4 +2038-01-09 03:14:07 2038-01-09 03:14:07 2009-01-05 2009-01-06 00:00:00 + +DROP TABLE t1; +# +# BUG#43618: MyISAM&Maria returns wrong results with 'between' +# on timestamp +# +CREATE TABLE t1( +ts TIMESTAMP NOT NULL, +c char NULL, +PRIMARY KEY(ts) +); +INSERT INTO t1 VALUES +('1971-01-01','a'), +('2007-05-25','b'), +('2008-01-01','c'), +('2038-01-09','d'); + +# Execute select with invalid timestamp, desc ordering +SELECT * +FROM t1 +WHERE ts BETWEEN '0000-00-00' AND '2010-00-01 00:00:00' +ORDER BY ts DESC +LIMIT 2; +ts c +2008-01-01 00:00:00 c +2007-05-25 00:00:00 b + +# Should use index condition +EXPLAIN +SELECT * +FROM t1 +WHERE ts BETWEEN '0000-00-00' AND '2010-00-01 00:00:00' +ORDER BY ts DESC +LIMIT 2; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t1 range PRIMARY PRIMARY 4 NULL 4 Using index condition + +DROP TABLE t1; +# +# BUG#49906: Assertion failed - Field_varstring::val_str in field.cc +# (Note: Fixed by patch for LP BUG#625841) +# +CREATE TABLE t1 ( +f1 VARCHAR(1024), +f2 VARCHAR(10), +INDEX test_idx USING BTREE (f2,f1(5)) +); +INSERT INTO t1 VALUES ('a','c'), ('b','d'); +SELECT f1 +FROM t1 +WHERE f2 LIKE 'd' +ORDER BY f1; +f1 +b +DROP TABLE t1; +# +# Bug#52660 - "Perf. regr. using ICP for MyISAM on range queries on +# an index containing TEXT" +# +CREATE TABLE t1 (a INT); +INSERT INTO t1 VALUES (0),(1),(2),(3),(4),(5),(6),(7),(8),(9); +CREATE TABLE t2 (a INT); +INSERT INTO t2 SELECT A.a + 10*(B.a) FROM t1 A, t1 B; +CREATE TABLE t3 ( +c1 TINYTEXT NOT NULL, +i1 INT NOT NULL, +KEY (c1(6),i1) +); +INSERT INTO t3 SELECT CONCAT('c-',1000+t2.a,'=w'), 1 FROM t2; +EXPLAIN +SELECT c1 FROM t3 WHERE c1 >= 'c-1004=w' and c1 <= 'c-1006=w'; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t3 range c1 c1 8 NULL 3 Using where +SELECT c1 FROM t3 WHERE c1 >= 'c-1004=w' and c1 <= 'c-1006=w'; +c1 +c-1004=w +c-1005=w +c-1006=w +EXPLAIN +SELECT c1 FROM t3 WHERE c1 >= 'c-1004=w' and c1 <= 'c-1006=w' and i1 > 2; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t3 range c1 c1 12 NULL 2 Using index condition; Using where +SELECT c1 FROM t3 WHERE c1 >= 'c-1004=w' and c1 <= 'c-1006=w' and i1 > 2; +c1 +EXPLAIN +SELECT c1 FROM t3 WHERE c1 >= 'c-1004=w' and c1 <= 'c-1006=w' or i1 > 2; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t3 ALL c1 NULL NULL NULL 100 Using where +SELECT c1 FROM t3 WHERE c1 >= 'c-1004=w' and c1 <= 'c-1006=w' or i1 > 2; +c1 +c-1004=w +c-1005=w +c-1006=w +DROP TABLE t1, t2, t3; +# # Bug#40992 - InnoDB: Crash when engine_condition_pushdown is on # CREATE TABLE t ( @@ -199,6 +345,266 @@ COUNT(*) DROP PROCEDURE insert_data; DROP TABLE t1, t2, t3; # +# Bug#57372 "Multi-table updates and deletes fail when running with ICP +# against InnoDB" +# +CREATE TABLE t1 ( +a INT KEY, +b INT +); +CREATE TABLE t2 ( +a INT KEY, +b INT +); +INSERT INTO t1 VALUES (1, 101), (2, 102), (3, 103), (4, 104), (5, 105); +INSERT INTO t2 VALUES (1, 1), (2, 2), (3, 3), (4, 4), (5, 5); +UPDATE t1, t2 +SET t1.a = t1.a + 100, t2.b = t1.a + 10 +WHERE t1.a BETWEEN 2 AND 4 AND t2.a = t1.b - 100; +SELECT * FROM t1; +a b +1 101 +102 102 +103 103 +104 104 +5 105 +SELECT * FROM t2; +a b +1 1 +2 12 +3 13 +4 14 +5 5 +DROP TABLE t1, t2; +# +# Bug#52605 - "Adding LIMIT 1 clause to query with complex range +# predicate causes wrong results" +# +CREATE TABLE t1 ( +pk INT NOT NULL, +c1 INT, +PRIMARY KEY (pk), +KEY k1 (c1) +); +INSERT INTO t1 VALUES (1,NULL); +INSERT INTO t1 VALUES (2,6); +INSERT INTO t1 VALUES (3,NULL); +INSERT INTO t1 VALUES (4,6); +INSERT INTO t1 VALUES (5,NULL); +INSERT INTO t1 VALUES (6,NULL); +INSERT INTO t1 VALUES (7,9); +INSERT INTO t1 VALUES (8,0); +SELECT pk, c1 +FROM t1 +WHERE (pk BETWEEN 4 AND 5 OR pk < 2) AND c1 < 240 +ORDER BY c1 +LIMIT 1; +pk c1 +4 6 +EXPLAIN SELECT pk, c1 +FROM t1 +WHERE (pk BETWEEN 4 AND 5 OR pk < 2) AND c1 < 240 +ORDER BY c1 +LIMIT 1; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t1 range PRIMARY,k1 k1 5 NULL 4 Using where +DROP TABLE t1; +# +# Bug#59259 "Incorrect rows returned for a correlated subquery +# when ICP is on" +# +CREATE TABLE t1 (pk INTEGER PRIMARY KEY, i INTEGER NOT NULL) ENGINE=InnoDB; +Warnings: +Warning 1286 Unknown storage engine 'InnoDB' +Warning 1266 Using storage engine MyISAM for table 't1' +INSERT INTO t1 VALUES (11,0); +INSERT INTO t1 VALUES (12,5); +INSERT INTO t1 VALUES (15,0); +CREATE TABLE t2 (pk INTEGER PRIMARY KEY, i INTEGER NOT NULL) ENGINE=InnoDB; +Warnings: +Warning 1286 Unknown storage engine 'InnoDB' +Warning 1266 Using storage engine MyISAM for table 't2' +INSERT INTO t2 VALUES (11,1); +INSERT INTO t2 VALUES (12,2); +INSERT INTO t2 VALUES (15,4); +set @save_optimizer_switch= @@optimizer_switch; +set optimizer_switch='semijoin=off'; +EXPLAIN +SELECT * FROM t1 +WHERE pk IN (SELECT it.pk FROM t2 JOIN t2 AS it ON it.i=it.i WHERE it.pk-t1.i<10); +id select_type table type possible_keys key key_len ref rows Extra +1 PRIMARY t1 ALL NULL NULL NULL NULL 3 Using where +2 DEPENDENT SUBQUERY t2 index NULL PRIMARY 4 NULL 3 Using index +2 DEPENDENT SUBQUERY it eq_ref PRIMARY PRIMARY 4 func 1 Using index condition +SELECT * FROM t1 +WHERE pk IN (SELECT it.pk FROM t2 JOIN t2 AS it ON it.i=it.i WHERE it.pk-t1.i<10); +pk i +12 5 +set optimizer_switch=@save_optimizer_switch; +DROP TABLE t1, t2; +# +# Bug #58816 "Extra temporary duplicate rows in result set when +# switching ICP off" +# +set @save_optimizer_switch= @@optimizer_switch; +CREATE TABLE t1 ( +pk INT NOT NULL, +c1 INT NOT NULL, +PRIMARY KEY (pk) +); +INSERT INTO t1 VALUES (1,9),(2,7),(3,6),(4,3),(5,1); +EXPLAIN SELECT pk, c1 FROM t1 WHERE pk <> 3; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t1 ALL PRIMARY NULL NULL NULL 5 Using where +SET SESSION optimizer_switch='index_condition_pushdown=off'; +SELECT pk, c1 FROM t1 WHERE pk <> 3; +pk c1 +1 9 +2 7 +4 3 +5 1 +DROP TABLE t1; +set optimizer_switch= @save_optimizer_switch; +# +# Bug#58837: ICP crash or valgrind error due to uninitialized +# value in innobase_index_cond +# +CREATE TABLE t1 ( +t1_int INT, +t1_time TIME +); +CREATE TABLE t2 ( +t2_int int PRIMARY KEY, +t2_int2 INT +); +INSERT INTO t2 VALUES (); +INSERT INTO t1 VALUES (); +SELECT * FROM t1 AS t1a +WHERE NOT EXISTS (SELECT * FROM t1 AS t1b +WHERE t1b.t1_int NOT IN +(SELECT t2.t2_int FROM t2 +WHERE t1b.t1_time LIKE t1b.t1_int +OR t1b.t1_time <> t2.t2_int2 +AND 6=7)); +t1_int t1_time +DROP TABLE t1,t2; +# +# Bug#59186: Wrong results of join when ICP is enabled +# (fixed by the patch for LP bug #694092) +# +CREATE TABLE t1 ( +pk INTEGER NOT NULL, +c1 VARCHAR(3) NOT NULL, +PRIMARY KEY (pk) +); +INSERT INTO t1 VALUES (1,'y'),(0,'or'); +CREATE TABLE t2 ( +pk INTEGER NOT NULL, +c1 VARCHAR(3) NOT NULL, +c2 VARCHAR(6) NOT NULL, +PRIMARY KEY (pk) +); +INSERT INTO t2 VALUES (6,'y','RPOYT'),(10,'m','JINQE'); +EXPLAIN +SELECT c2 FROM t1 JOIN t2 ON t1.c1 = t2.c1 +WHERE (t2.pk <= 4 AND t1.pk IN (2,1)) OR +(t1.pk > 1 AND t2.pk BETWEEN 6 AND 6); +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t1 range PRIMARY PRIMARY 4 NULL 2 Using index condition; Using where; Rowid-ordered scan +1 SIMPLE t2 range PRIMARY PRIMARY 4 NULL 2 Using index condition; Using where; Rowid-ordered scan; Using join buffer (flat, BNL join) +SELECT c2 FROM t1 JOIN t2 ON t1.c1 = t2.c1 +WHERE (t2.pk <= 4 AND t1.pk IN (2,1)) OR +(t1.pk > 1 AND t2.pk BETWEEN 6 AND 6); +c2 +DROP TABLE t1, t2; +# +# Bug#58838: "Wrong results with HAVING + LIMIT without GROUP BY when +# ICP is enabled". +# (Fixed by the patches for LP bugs #668644, #702322) +# +CREATE TABLE t1 ( +pk INT NOT NULL, +c1 INT, +PRIMARY KEY (pk), +KEY col_int_key (c1) +); +INSERT INTO t1 VALUES (1,37),(2,8),(3,-25),(4,NULL),(5,55); +SELECT pk FROM t1 WHERE c1 <> 1 HAVING pk = 3 ORDER BY pk LIMIT 0; +pk +SELECT pk FROM t1 WHERE c1 <> 1 HAVING pk = 3 ORDER BY pk LIMIT 1; +pk +3 +SELECT pk FROM t1 WHERE c1 <> 1 HAVING pk = 3 ORDER BY pk LIMIT 2; +pk +3 +SELECT pk FROM t1 WHERE c1 <> 1 HAVING pk = 3 ORDER BY pk LIMIT 5; +pk +3 +DROP TABLE t1; +# +# Bug#59483 "Crash on INSERT/REPLACE in +# rec_convert_dtuple_to_rec_comp with ICP on" +# +CREATE TABLE t1 ( +pk INTEGER AUTO_INCREMENT PRIMARY KEY, +i1 INTEGER, +c1 CHAR(6), +i2 INTEGER NOT NULL, +KEY (i2) +); +INSERT INTO t1 VALUES +(NULL, 4, 'that', 8), +(NULL, 1, 'she', 6), +(NULL, 6, 'tell', 2); +SELECT * FROM t1 WHERE i2 IN (3, 6) LIMIT 2 FOR UPDATE; +pk i1 c1 i2 +2 1 she 6 +INSERT INTO t1 (i2) VALUES (1); +DROP TABLE t1; +# +# Bug #11766678 - 59843: +# USING UNINITIALISED VALUE IN USES_INDEX_FIELDS_ONLY +# +CREATE TABLE t1 ( +col999 FLOAT NOT NULL, +COL1000 VARBINARY(179) NOT NULL, +col1003 DATE DEFAULT NULL, +KEY idx4267 (col1000, col1003) +); +INSERT INTO t1 VALUES (),(); +Warnings: +Warning 1364 Field 'col999' doesn't have a default value +Warning 1364 Field 'COL1000' doesn't have a default value +SELECT col999 FROM t1 WHERE col1000 = "3" AND col1003 <=> sysdate(); +col999 +DROP TABLE t1; +# +# BUG#12822678 - ICP WITH STRAIGHT_JOIN +# +CREATE TABLE t1 ( +i1 INTEGER NOT NULL, +d1 DOUBLE, +KEY k1 (d1) +); +INSERT INTO t1 VALUES (10,1), (17,NULL), (22,NULL); +CREATE TABLE t2 ( +pk INTEGER NOT NULL, +i1 INTEGER NOT NULL, +PRIMARY KEY (pk) +); +INSERT INTO t2 VALUES (4,1); +EXPLAIN +SELECT t1.d1, t2.pk, t2.i1 FROM t1 STRAIGHT_JOIN t2 ON t2.i1 +WHERE t2.pk <> t1.d1 AND t2.pk = 4; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t1 index NULL k1 9 NULL 3 Using index +1 SIMPLE t2 const PRIMARY PRIMARY 4 const 1 Using where +SELECT t1.d1, t2.pk, t2.i1 FROM t1 STRAIGHT_JOIN t2 ON t2.i1 +WHERE t2.pk <> t1.d1 AND t2.pk = 4; +d1 pk i1 +1 4 1 +DROP TABLE t1, t2; +# # BUG#778434 Wrong result with in_to_exists=on in maria-5.3-mwl89 # CREATE TABLE t1 ( f11 int) ; @@ -221,8 +627,84 @@ FROM t3 JOIN t4 ON t4.f11 = t3.f10 f11 f10 DROP TABLE t1,t2,t3,t4; set optimizer_switch= @tmp_778434; -set @myisam_icp_tmp=@@optimizer_switch; -set optimizer_switch='mrr=on,mrr_sort_keys=on,index_condition_pushdown=on'; +# +# Bug#885168: ICP for one index + potential ORDER BY for another +# +CREATE TABLE t1 (a varchar(64), b varchar(10), INDEX(a), INDEX(b)) ; +INSERT INTO t1 VALUES +('Ohio','Iowa'), ('k','d'), ('bdkpj','mbdkpjdanp'), ('d','xdmbdkpjda'), +('fkxdmbdkpjdanpje','o'), ('f','Pennsylvan'), ('Virginia','ei'); +SET SESSION optimizer_switch='index_condition_pushdown=off'; +EXPLAIN +SELECT * FROM t1 +WHERE NOT(b = 'Texas') AND b BETWEEN 'wy' AND 'y' OR b = 'Pennsylvania' + ORDER BY a; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t1 range b b 13 NULL 2 Using where; Rowid-ordered scan; Using filesort +SELECT * FROM t1 +WHERE NOT(b = 'Texas') AND b BETWEEN 'wy' AND 'y' OR b = 'Pennsylvania' + ORDER BY a; +a b +d xdmbdkpjda +SET SESSION optimizer_switch='index_condition_pushdown=on'; +EXPLAIN +SELECT * FROM t1 +WHERE NOT(b = 'Texas') AND b BETWEEN 'wy' AND 'y' OR b = 'Pennsylvania' + ORDER BY a; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t1 range b b 13 NULL 2 Using index condition; Using where; Rowid-ordered scan; Using filesort +SELECT * FROM t1 +WHERE NOT(b = 'Texas') AND b BETWEEN 'wy' AND 'y' OR b = 'Pennsylvania' + ORDER BY a; +a b +d xdmbdkpjda +DROP TABLE t1; +# +# Bug#886145: join with ICP + ORDER BY +# +CREATE TABLE t1 (b int NOT NULL, c int, a varchar(1024), PRIMARY KEY (b)); +INSERT INTO t1 VALUES (1,4,'Ill'); +CREATE TABLE t2 (a varchar(1024), KEY (a(512))); +INSERT INTO t2 VALUES +('Ill'), ('eckqzsflbzaffti'), ('w'), ('she'), ('gxbwypqtjzwywwer'), ('w'); +SET SESSION optimizer_switch='index_condition_pushdown=off'; +EXPLAIN +SELECT t1.b, t1.c FROM t1, t2 WHERE t1.a = t2.a AND t1.b != 0 +HAVING t1.c != 5 ORDER BY t1.c; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t1 system PRIMARY NULL NULL NULL 1 +1 SIMPLE t2 ref a a 515 const 1 Using where +SELECT t1.b, t1.c FROM t1, t2 WHERE t1.a = t2.a AND t1.b != 0 +HAVING t1.c != 5 ORDER BY t1.c; +b c +1 4 +SET SESSION optimizer_switch='index_condition_pushdown=on'; +EXPLAIN +SELECT t1.b, t1.c FROM t1, t2 WHERE t1.a = t2.a AND t1.b != 0 +HAVING t1.c != 5 ORDER BY t1.c; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t1 system PRIMARY NULL NULL NULL 1 +1 SIMPLE t2 ref a a 515 const 1 Using where +SELECT t1.b, t1.c FROM t1, t2 WHERE t1.a = t2.a AND t1.b != 0 +HAVING t1.c != 5 ORDER BY t1.c; +b c +1 4 +DROP TABLE t1,t2; +# +# Bug#879871: InnoDB: possible ICP + GROUP BY primary index +# +CREATE TABLE t1 ( +a int NOT NULL, b int, c varchar(1), d varchar(1), +PRIMARY KEY (a), KEY c (c,b) +); +INSERT INTO t1 VALUES (10,8,'g','g'); +SET SESSION optimizer_switch='index_condition_pushdown=off'; +SELECT a FROM t1 WHERE c IS NULL AND d IS NOT NULL GROUP BY 1; +a +SET SESSION optimizer_switch='index_condition_pushdown=on'; +SELECT a FROM t1 WHERE c IS NULL AND d IS NOT NULL GROUP BY 1; +a +DROP TABLE t1; drop table if exists t0, t1, t1i, t1m; # # BUG#826935 Assertion `!table || (!table->read_set || bitmap_is_set(table->read_set, field_index))' failed @@ -238,4 +720,61 @@ SELECT b FROM t1 WHERE a != 1 AND c IS NULL ORDER BY 1; b byluovkgwoukfxedyeffsedajyqkyhpaqqpozn DROP TABLE t1; +# +# Bug#870046: ICP for a GROUP BY query +# +CREATE TABLE t1 (a int, b varchar(1), c varchar(1), INDEX idx(b)); +INSERT INTO t1 VALUES (2,'x','x'), (5,'x','y'); +SET SESSION optimizer_switch='index_condition_pushdown=off'; +EXPLAIN +SELECT a, MIN(c) FROM t1 WHERE b = 'x' AND c > 'x' GROUP BY a; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t1 ref idx idx 4 const 1 Using where; Using temporary; Using filesort +SELECT a, MIN(c) FROM t1 WHERE b = 'x' AND c > 'x' GROUP BY a; +a MIN(c) +5 y +SET SESSION optimizer_switch='index_condition_pushdown=on'; +EXPLAIN +SELECT a, MIN(c) FROM t1 WHERE b = 'x' AND c > 'x' GROUP BY a; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t1 ref idx idx 4 const 1 Using index condition; Using where; Using temporary; Using filesort +SELECT a, MIN(c) FROM t1 WHERE b = 'x' AND c > 'x' GROUP BY a; +a MIN(c) +5 y +DROP TABLE t1; +# +# BUG#887026: Wrong result with ICP, outer join, subquery in maria-5.3-icp +# +CREATE TABLE t1 (c varchar(1)); +INSERT INTO t1 VALUES ('c'), ('c'); +CREATE TABLE t2 (c varchar(1), b int); +INSERT INTO t2 VALUES ('d', NULL),('d', NULL); +CREATE TABLE t3 (c varchar(1)); +INSERT INTO t3 VALUES ('c'); +INSERT INTO t3 VALUES ('c'); +CREATE TABLE t4 ( b int, c varchar(1), KEY (b)); +INSERT INTO t4 VALUES (7,'c'); +INSERT INTO t4 VALUES (7,'c'); +# Must be t1,t2,t3,t4, with t4 having Full-scan-on-NULL but not Using index condition +explain +SELECT * FROM t1 LEFT JOIN t2 ON t1.c=t2.b +WHERE +t2.b NOT IN (SELECT t4.b FROM t3 STRAIGHT_JOIN t4 WHERE t4.b <= 2 AND t4.c = t3.c); +id select_type table type possible_keys key key_len ref rows Extra +1 PRIMARY t1 ALL NULL NULL NULL NULL 2 +1 PRIMARY t2 ALL NULL NULL NULL NULL 2 Using where +2 DEPENDENT SUBQUERY t3 ALL NULL NULL NULL NULL 2 +2 DEPENDENT SUBQUERY t4 ref_or_null b b 5 func 2 Using where; Full scan on NULL key +SELECT * FROM t1 LEFT JOIN t2 ON t1.c=t2.b +WHERE +t2.b NOT IN (SELECT t4.b FROM t3 STRAIGHT_JOIN t4 WHERE t4.b <= 2 AND t4.c = t3.c); +c c b +c NULL NULL +c NULL NULL +Warnings: +Warning 1292 Truncated incorrect DOUBLE value: 'c' +Warning 1292 Truncated incorrect DOUBLE value: 'c' +Warning 1292 Truncated incorrect DOUBLE value: 'c' +Warning 1292 Truncated incorrect DOUBLE value: 'c' +DROP TABLE t1,t2,t3,t4; set optimizer_switch=@myisam_icp_tmp; diff --git a/mysql-test/r/myisam_mrr.result b/mysql-test/r/myisam_mrr.result index d3d6366456b..a85fb97fdbc 100644 --- a/mysql-test/r/myisam_mrr.result +++ b/mysql-test/r/myisam_mrr.result @@ -188,7 +188,7 @@ explain select * from t4 where a IS NULL and b IS NULL and (c IS NULL or c='no-such-row1' or c='no-such-row2'); id select_type table type possible_keys key key_len ref rows Extra -1 SIMPLE t4 range idx1 idx1 29 NULL 10 Using index condition; Rowid-ordered scan +1 SIMPLE t4 range idx1 idx1 29 NULL 10 Using index condition; Using where; Rowid-ordered scan select * from t4 where a IS NULL and b IS NULL and (c IS NULL or c='no-such-row1' or c='no-such-row2'); a b c filler @@ -210,7 +210,7 @@ NULL NULL NULL NULL-1 explain select * from t4 where (a ='b-1' or a='bb-1') and b IS NULL and (c='c-1' or c='cc-2'); id select_type table type possible_keys key key_len ref rows Extra -1 SIMPLE t4 range idx1 idx1 29 NULL 21 Using index condition; Rowid-ordered scan +1 SIMPLE t4 range idx1 idx1 29 NULL 21 Using index condition; Using where; Rowid-ordered scan select * from t4 where (a ='b-1' or a='bb-1') and b IS NULL and (c='c-1' or c='cc-2'); a b c filler b-1 NULL c-1 NULL-15 @@ -365,7 +365,7 @@ update t1 set b=repeat(char(65+a), 20) where a < 25; This must show range + using index condition: explain select * from t1 where a < 10 and b = repeat(char(65+a), 20); id select_type table type possible_keys key key_len ref rows Extra -1 SIMPLE t1 range a a 5 NULL 19 Using where +1 SIMPLE t1 range a a 5 NULL 19 Using index condition; Using where select * from t1 where a < 10 and b = repeat(char(65+a), 20); a b filler 0 AAAAAAAAAAAAAAAAAAAA filler @@ -488,6 +488,14 @@ INSERT INTO t1 VALUES (22,142,'b','b'),(23,3,'y','y'),(24,0,'v','v'), (25,3,'m','m'),(26,5,'z','z'),(27,9,'n','n'), (28,1,'d','d'),(29,107,'a','a'); +INSERT INTO t1 VALUES +(110,8,'v','v'),(111,8,'f','f'), (112,5,'v','v'), +(113,8,'s','s'),(114,8,'a','a'),(115,6,'p','p'), +(116,7,'z','z'),(117,2,'a','a'),(118,5,'h','h'), +(119,7,'h','h'),(120,2,'v','v'),(121,9,'v','v'), +(122,142,'b','b'),(123,3,'y','y'),(124,0,'v','v'), +(125,3,'m','m'),(126,5,'z','z'),(127,9,'n','n'), +(128,1,'d','d'),(129,107,'a','a'); SELECT COUNT(*) FROM t1 AS table2, t1 AS table3 @@ -496,7 +504,7 @@ table3.col_varchar_key = table2.col_varchar_key AND table3.col_varchar_key = table2.col_varchar_nokey AND table3.pk<>0; COUNT(*) -50 +200 EXPLAIN SELECT COUNT(*) FROM t1 AS table2, t1 AS table3 @@ -505,9 +513,48 @@ table3.col_varchar_key = table2.col_varchar_key AND table3.col_varchar_key = table2.col_varchar_nokey AND table3.pk<>0; id select_type table type possible_keys key key_len ref rows Extra -1 SIMPLE table2 ALL col_varchar_key NULL NULL NULL 20 Using where -1 SIMPLE table3 ref PRIMARY,col_varchar_key col_varchar_key 3 test.table2.col_varchar_key 3 Using where; Using join buffer (flat, BKA join); Key-ordered Rowid-ordered scan +1 SIMPLE table2 ALL col_varchar_key NULL NULL NULL 40 Using where +1 SIMPLE table3 ref PRIMARY,col_varchar_key col_varchar_key 3 test.table2.col_varchar_key 5 Using where; Using join buffer (flat, BKA join); Key-ordered Rowid-ordered scan set join_cache_level= @save_join_cache_level; set join_buffer_size= @save_join_buffer_size; -set optimizer_switch= @myisam_mrr_tmp; drop table t1; +# +# BUG#730133: Wrong result with jkl = 7, BKA, ICP in maria-5.3 + compound index +# +set @tmp_730133_jcl= @@join_cache_level; +set join_cache_level = 7; +set @tmp_730133_os= @@optimizer_switch; +set optimizer_switch= 'join_cache_hashed=off,join_cache_bka=on,index_condition_pushdown=on,optimize_join_buffer_size=on'; +CREATE TABLE t1 (f1 int, f2 int, f3 int, f4 int, f5 int, KEY (f4,f3)); +INSERT IGNORE INTO t1 VALUES ('2','9','5','0','0'),('4','7','0','0','0'), +('6','97','190','0','0'),('7','3','6','0','0'),('11','101','186','0','0'), +('14','194','226','0','0'),('15','148','133','0','0'), +('16','9','6','0','0'),('17','9','3','0','0'),('18','1','8','0','0'), +('19','1','5','0','0'),('20','5','7','0','0'); +explain +SELECT COUNT(alias2.f2) +FROM +t1 STRAIGHT_JOIN +t1 AS alias3 STRAIGHT_JOIN +t1 AS alias2 FORCE KEY (f4) +WHERE +alias2.f4=alias3.f5 AND +alias2.f3 > alias3.f1; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t1 index NULL f4 10 NULL 12 Using index +1 SIMPLE alias3 ALL NULL NULL NULL NULL 12 Using where; Using join buffer (flat, BNL join) +1 SIMPLE alias2 ref f4 f4 5 test.alias3.f5 2 Using index condition(BKA); Using join buffer (incremental, BKA join); Key-ordered Rowid-ordered scan +SELECT COUNT(alias2.f2) +FROM +t1 STRAIGHT_JOIN +t1 AS alias3 STRAIGHT_JOIN +t1 AS alias2 FORCE KEY (f4) +WHERE +alias2.f4=alias3.f5 AND +alias2.f3 > alias3.f1; +COUNT(alias2.f2) +768 +set @@join_cache_level= @tmp_730133_jcl; +set @@optimizer_switch= @tmp_730133_os; +drop table t1; +set optimizer_switch= @myisam_mrr_tmp; diff --git a/mysql-test/r/myisampack.result b/mysql-test/r/myisampack.result index 91700701139..56f61ccdf47 100644 --- a/mysql-test/r/myisampack.result +++ b/mysql-test/r/myisampack.result @@ -118,3 +118,35 @@ Aborted: file is not compressed DROP TABLE t1,t2,t3; DROP TABLE mysql_db1.t1; DROP DATABASE mysql_db1; +# +# BUG#11761180 - 53646: MYISAMPACK CORRUPTS TABLES WITH FULLTEXT INDEXES +# +CREATE TABLE t1(a CHAR(4), FULLTEXT(a)); +INSERT INTO t1 VALUES('aaaa'),('bbbb'),('cccc'); +FLUSH TABLE t1; +CHECK TABLE t1; +Table Op Msg_type Msg_text +test.t1 check status OK +SELECT * FROM t1 WHERE MATCH(a) AGAINST('aaaa' IN BOOLEAN MODE); +a +aaaa +SELECT * FROM t1 WHERE MATCH(a) AGAINST('aaaa'); +a +aaaa +DROP TABLE t1; +# Test table with key_reflength > rec_reflength +CREATE TABLE t1(a CHAR(30), FULLTEXT(a)); +# Populating a table, so it's index file exceeds 65K +# Populating a table, so index file has second level fulltext tree +FLUSH TABLE t1; +# Compressing table +# Fixing index (repair by sort) +CHECK TABLE t1; +Table Op Msg_type Msg_text +test.t1 check status OK +FLUSH TABLE t1; +# Fixing index (repair with keycache) +CHECK TABLE t1; +Table Op Msg_type Msg_text +test.t1 check status OK +DROP TABLE t1; diff --git a/mysql-test/r/mysql.result b/mysql-test/r/mysql.result index 9923ba03b3d..d43d891da2f 100644 --- a/mysql-test/r/mysql.result +++ b/mysql-test/r/mysql.result @@ -1,4 +1,4 @@ -drop table if exists t1; +drop table if exists t1,t2,t3; create table t1(a int); insert into t1 values(1); ERROR at line 9: DELIMITER must be followed by a 'delimiter' character or string @@ -137,6 +137,14 @@ drop table t1; 1 ERROR 1064 (42000) at line 3: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '' at line 1 ERROR at line 1: USE must be followed by a database name +1 +1 +2 +1 +1 +2 +1 +1 +2 +1 +1 +2 \ \\ '; diff --git a/mysql-test/r/mysql_plugin.result b/mysql-test/r/mysql_plugin.result new file mode 100644 index 00000000000..949f3748236 --- /dev/null +++ b/mysql-test/r/mysql_plugin.result @@ -0,0 +1,110 @@ +# +# Ensure the plugin isn't loaded. +# +SELECT * FROM mysql.plugin WHERE name = 'daemon_example' ORDER BY name; +name dl +# +# Enable the plugin... +# +# +# Ensure the plugin is now loaded. +# +SELECT * FROM mysql.plugin WHERE name = 'daemon_example' ORDER BY name; +name dl +daemon_example libdaemon_example.so +# +# Disable the plugin... +# +# +# Ensure the plugin isn't loaded. +# +SELECT * FROM mysql.plugin WHERE name = 'daemon_example' ORDER BY name; +name dl +# +# Attempt to load non-existant plugin +# +ERROR: Cannot read plugin config file NOT_THERE_AT_ALL. File does not exist. +# +# Attempt to use non-existant plugin.ini file +# +ERROR: Cannot read plugin config file daemon_example. File does not exist. +# +# Attempt to omit the plugin +# +ERROR: No plugin specified. +# +# Attempt to omit DISABLE|ENABLE +# +ERROR: missing operation. Please specify either '<plugin> ENABLE' or '<plugin> DISABLE'. +# +# Attempt to use bad paths - datadir +# +ERROR: Cannot access datadir at '/data_not_there/'. +# +# Attempt to use bad paths - basedir +# +ERROR: Cannot access basedir at '/basedir_not_there/'. +# +# Attempt to use bad paths - plugin_dir +# +ERROR: Cannot read plugin config file daemon_example. File does not exist. +# +# Attempt to use bad paths - mysqld +# +ERROR: Cannot access mysqld path '/mysqld_not_there/'. +# +# Attempt to use bad paths - my_print_defaults +# +ERROR: Cannot access my-print-defaults path '/my_print_defaults_not_there/'. +# +# Missing library +# +ERROR: The plugin library is missing or in a different location. +# +# Bad format for config file +# +ERROR: Cannot read plugin config file daemon_example. Bad format in plugin configuration file. +# +# Missing base_dir option +# +ERROR: Missing --basedir option. +# +# Missing data_dir option +# +ERROR: Missing --datadir option. +# +# Missing plugin_dir option +# +ERROR: Missing --plugin_dir option. +# +# Show the help. +# +mysql_plugin Ver V.V.VV Distrib XX.XX.XX +Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved. + +Enable or disable plugins. + +Usage: mysql_plugin [options] <plugin> ENABLE|DISABLE + +Options: + -?, --help Display this help and exit. + -b, --basedir=name The basedir for the server. + -d, --datadir=name The datadir for the server. + -p, --plugin-dir=name + The plugin dir for the server. + -i, --plugin-ini=name + Read plugin information from configuration file specified + instead of from <plugin-dir>/<plugin_name>.ini. + -n, --no-defaults Do not read values from configuration file. + -P, --print-defaults + Show default values from configuration file. + -m, --mysqld=name Path to mysqld executable. Example: /sbin/temp1/mysql/bin + -f, --my-print-defaults=name + Path to my_print_defaults executable. Example: + /source/temp11/extra + -v, --verbose More verbose output; you can use this multiple times to + get even more verbose output. + -V, --version Output version information and exit. + + +mysql_plugin Ver V.V.VV Distrib XX.XX.XX diff --git a/mysql-test/r/mysqld--help-notwin.result b/mysql-test/r/mysqld--help-notwin.result index b9bdee3211b..acdee8d8e89 100644 --- a/mysql-test/r/mysqld--help-notwin.result +++ b/mysql-test/r/mysqld--help-notwin.result @@ -32,7 +32,7 @@ The following options may be given as the first argument: --big-tables Allow big result sets by saving all temporary sets on file (Solves most 'table full' errors) --bind-address=name IP address to bind to. - --binlog-annotate-rows-events + --binlog-annotate-row-events Tells the master to annotate RBR events with the statement that caused these events --binlog-cache-size=# @@ -44,9 +44,6 @@ The following options may be given as the first argument: Type of BINLOG_CHECKSUM_ALG. Include checksum for log events in the binary log. Possible values are NONE and CRC32; default is NONE. - --binlog-dbug-fsync-sleep=# - Extra sleep (in microseconds) to add to binlog fsync(), - for debugging --binlog-direct-non-transactional-updates Causes updates to non-transactional engines using statement format to be written directly to binary log. @@ -335,7 +332,9 @@ The following options may be given as the first argument: when binary log is disabled). --log-tc-size=# Size of transaction coordinator log. -W, --log-warnings[=#] - Log some not critical warnings to the general log file + Log some not critical warnings to the general log + file.Value can be between 0 and 11. Higher values mean + more verbosity --long-query-time=# Log all queries that have taken more than long_query_time seconds to execute to file. The argument will be treated as a decimal value with microsecond precision @@ -609,7 +608,7 @@ The following options may be given as the first argument: transaction processed --relay-log-space-limit=# Maximum space to use for all relay logs - --replicate-annotate-rows-events + --replicate-annotate-row-events Tells the slave to write annotate rows events recieved from the master to its own binary log. Ignored if log_slave_updates is not set @@ -861,10 +860,9 @@ automatic-sp-privileges TRUE back-log 50 big-tables FALSE bind-address (No default value) -binlog-annotate-rows-events FALSE +binlog-annotate-row-events FALSE binlog-cache-size 32768 binlog-checksum NONE -binlog-dbug-fsync-sleep 0 binlog-direct-non-transactional-updates FALSE binlog-format STATEMENT binlog-optimize-thread-scheduling TRUE @@ -1002,7 +1000,7 @@ old-passwords FALSE old-style-user-limits FALSE optimizer-prune-level 1 optimizer-search-depth 62 -optimizer-switch index_merge=on,index_merge_union=on,index_merge_sort_union=on,index_merge_intersection=on,index_merge_sort_intersection=off,engine_condition_pushdown=off,index_condition_pushdown=off,derived_merge=off,derived_with_keys=off,firstmatch=off,loosescan=off,materialization=off,in_to_exists=on,semijoin=off,partial_match_rowid_merge=on,partial_match_table_scan=on,subquery_cache=off,mrr=off,mrr_cost_based=off,mrr_sort_keys=off,outer_join_with_cache=off,semijoin_with_cache=off,join_cache_incremental=on,join_cache_hashed=on,join_cache_bka=on,optimize_join_buffer_size=off,table_elimination=on +optimizer-switch index_merge=on,index_merge_union=on,index_merge_sort_union=on,index_merge_intersection=on,index_merge_sort_intersection=off,engine_condition_pushdown=off,index_condition_pushdown=off,derived_merge=off,derived_with_keys=off,firstmatch=on,loosescan=on,materialization=off,in_to_exists=on,semijoin=on,partial_match_rowid_merge=on,partial_match_table_scan=on,subquery_cache=on,mrr=off,mrr_cost_based=off,mrr_sort_keys=off,outer_join_with_cache=off,semijoin_with_cache=off,join_cache_incremental=on,join_cache_hashed=on,join_cache_bka=on,optimize_join_buffer_size=off,table_elimination=on performance-schema FALSE performance-schema-events-waits-history-long-size 10000 performance-schema-events-waits-history-size 10 @@ -1044,7 +1042,7 @@ relay-log-info-file relay-log.info relay-log-purge TRUE relay-log-recovery FALSE relay-log-space-limit 0 -replicate-annotate-rows-events FALSE +replicate-annotate-row-events FALSE replicate-same-server-id FALSE report-host (No default value) report-password (No default value) diff --git a/mysql-test/r/mysqltest.result b/mysql-test/r/mysqltest.result index 6af460db37a..f91ea83da4b 100644 --- a/mysql-test/r/mysqltest.result +++ b/mysql-test/r/mysqltest.result @@ -1,7 +1,6 @@ +-1 before test +<No error> before test SET GLOBAL max_connections = 1000; -select 0 as "before_use_test" ; -before_use_test -0 select otto from (select 1 as otto) as t1; otto 1 @@ -25,27 +24,32 @@ mysqltest: At line 1: query 'select friedrich from (select 1 as otto) as t1' fai select otto from (select 1 as otto) as t1; otto 1 + select 0 as "after_successful_stmt_errno" ; after_successful_stmt_errno 0 garbage ; ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'garbage' at line 1 +ER_PARSE_ERROR select 1064 as "after_wrong_syntax_errno" ; after_wrong_syntax_errno 1064 garbage ; ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'garbage' at line 1 +ER_PARSE_ERROR select 1064 as "after_let_var_equal_value" ; after_let_var_equal_value 1064 garbage ; ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'garbage' at line 1 set @my_var= 'abc' ; + select 0 as "after_set_var_equal_value" ; after_set_var_equal_value 0 garbage ; ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'garbage' at line 1 +ER_PARSE_ERROR select 1064 as "after_disable_warnings_command" ; after_disable_warnings_command 1064 @@ -53,6 +57,7 @@ drop table if exists t1 ; garbage ; ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'garbage' at line 1 drop table if exists t1 ; + select 0 as "after_disable_warnings" ; after_disable_warnings 0 @@ -60,6 +65,7 @@ garbage ; ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'garbage' at line 1 select 3 from t1 ; ERROR 42S02: Table 'test.t1' doesn't exist +ER_NO_SUCH_TABLE select 1146 as "after_minus_masked" ; after_minus_masked 1146 @@ -67,6 +73,7 @@ garbage ; ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'garbage' at line 1 select 3 from t1 ; ERROR 42S02: Table 'test.t1' doesn't exist +ER_NO_SUCH_TABLE select 1146 as "after_!_masked" ; after_!_masked 1146 @@ -79,6 +86,7 @@ garbage ; ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'garbage' at line 1 prepare stmt from "select 3 from t1" ; ERROR 42S02: Table 'test.t1' doesn't exist +ER_NO_SUCH_TABLE select 1146 as "after_failing_prepare" ; after_failing_prepare 1146 @@ -86,6 +94,7 @@ create table t1 ( f1 char(10)); garbage ; ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'garbage' at line 1 prepare stmt from "select 3 from t1" ; + select 0 as "after_successful_prepare" ; after_successful_prepare 0 @@ -93,6 +102,7 @@ garbage ; ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'garbage' at line 1 execute stmt; 3 + select 0 as "after_successful_execute" ; after_successful_execute 0 @@ -101,6 +111,7 @@ garbage ; ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'garbage' at line 1 execute stmt; ERROR 42S02: Table 'test.t1' doesn't exist +ER_NO_SUCH_TABLE select 1146 as "after_failing_execute" ; after_failing_execute 1146 @@ -108,12 +119,14 @@ garbage ; ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'garbage' at line 1 execute __stmt_; ERROR HY000: Unknown prepared statement handler (__stmt_) given to EXECUTE +ER_UNKNOWN_STMT_HANDLER select 1243 as "after_failing_execute" ; after_failing_execute 1243 garbage ; ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'garbage' at line 1 deallocate prepare stmt; + select 0 as "after_successful_deallocate" ; after_successful_deallocate 0 @@ -121,11 +134,13 @@ garbage ; ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'garbage' at line 1 deallocate prepare __stmt_; ERROR HY000: Unknown prepared statement handler (__stmt_) given to DEALLOCATE PREPARE +ER_UNKNOWN_STMT_HANDLER select 1243 as "after_failing_deallocate" ; after_failing_deallocate 1243 garbage ; ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'garbage' at line 1 +ER_PARSE_ERROR select 1064 as "after_--disable_abort_on_error" ; after_--disable_abort_on_error 1064 @@ -135,13 +150,19 @@ select 3 from t1 ; ERROR 42S02: Table 'test.t1' doesn't exist select 3 from t1 ; ERROR 42S02: Table 'test.t1' doesn't exist +ER_NO_SUCH_TABLE select 1146 as "after_!errno_masked_error" ; after_!errno_masked_error 1146 select 3 from t1; mysqltest: At line 1: query 'select 3 from t1' failed with wrong errno 1146: 'Table 'test.t1' doesn't exist', instead of 1000... +ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'garbage' at line 1 + is empty +ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'nonsense' at line 1 + is empty garbage ; ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'garbage' at line 1 +ER_PARSE_ERROR select 1064 as "after_--enable_abort_on_error" ; after_--enable_abort_on_error 1064 @@ -149,6 +170,28 @@ select 3 from t1 ; ERROR 42S02: Table 'test.t1' doesn't exist select 3 from t1; mysqltest: At line 1: query 'select 3 from t1' failed with wrong errno 1146: 'Table 'test.t1' doesn't exist', instead of 1064... +garbage; +ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'garbage' at line 1 +select 2; +select 3; +3 +3 +select 5; +ERROR 42S02: Table 'test.t1' doesn't exist +select 7; +7 +7 +mysqltest: At line 1: End of line junk detected: "OCNE" +connect con1,localhost,root,,; +select 5 from t1; +lower +case +name +abc +xyz + is empty + is empty +"Yes it's empty" hello hello ;;;;;;;; @@ -321,7 +364,7 @@ insert into t1 values ('$dollar'); $dollar `select 42` drop table t1; -mysqltest: At line 1: Error running query 'failing query': 1064 You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'failing query' at line 1 +mysqltest: At line 1: query 'let $var2= `failing query`' failed: 1064: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'failing query' at line 1 mysqltest: At line 1: Missing required argument 'filename' to command 'source' mysqltest: At line 1: Could not open './non_existingFile' for reading, errno: 2 mysqltest: In included file "MYSQLTEST_VARDIR/tmp/recursive.sql": @@ -859,7 +902,7 @@ mysqltest: At line 1: Could not find column 'column_not_exists' in the result of mysqltest: At line 1: Query 'SET @A = 1' didn't return a result set mysqltest: At line 1: Could not find column '1 AS B' in the result of 'SELECT 1 AS A' value= No such row -mysqltest: At line 1: Error running query 'SHOW COLNS FROM t1': 1064 You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'COLNS FROM t1' at line 1 +mysqltest: At line 1: query 'let $value= query_get_value(SHOW COLNS FROM t1, Field, 1)' failed: 1064: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'COLNS FROM t1' at line 1 Field Type Null Key Default Extra a int(11) YES -><- NULL diff --git a/mysql-test/r/optimizer_switch_eng_cond_pushdown1.result b/mysql-test/r/optimizer_switch_eng_cond_pushdown1.result deleted file mode 100644 index afb607e4877..00000000000 --- a/mysql-test/r/optimizer_switch_eng_cond_pushdown1.result +++ /dev/null @@ -1,5 +0,0 @@ -select @@session.engine_condition_pushdown, -@@global.engine_condition_pushdown, -@@session.optimizer_switch, @@global.optimizer_switch; -@@session.engine_condition_pushdown @@global.engine_condition_pushdown @@session.optimizer_switch @@global.optimizer_switch -1 1 index_merge=on,index_merge_union=on,index_merge_sort_union=on,index_merge_intersection=on,index_merge_sort_intersection=off,engine_condition_pushdown=on,index_condition_pushdown=off,derived_merge=off,derived_with_keys=off,firstmatch=off,loosescan=off,materialization=off,in_to_exists=on,semijoin=off,partial_match_rowid_merge=on,partial_match_table_scan=on,subquery_cache=off,mrr=off,mrr_cost_based=off,mrr_sort_keys=off,outer_join_with_cache=off,semijoin_with_cache=off,join_cache_incremental=on,join_cache_hashed=on,join_cache_bka=on,optimize_join_buffer_size=off,table_elimination=on index_merge=on,index_merge_union=on,index_merge_sort_union=on,index_merge_intersection=on,index_merge_sort_intersection=off,engine_condition_pushdown=on,index_condition_pushdown=off,derived_merge=off,derived_with_keys=off,firstmatch=off,loosescan=off,materialization=off,in_to_exists=on,semijoin=off,partial_match_rowid_merge=on,partial_match_table_scan=on,subquery_cache=off,mrr=off,mrr_cost_based=off,mrr_sort_keys=off,outer_join_with_cache=off,semijoin_with_cache=off,join_cache_incremental=on,join_cache_hashed=on,join_cache_bka=on,optimize_join_buffer_size=off,table_elimination=on diff --git a/mysql-test/r/optimizer_switch_eng_cond_pushdown2.result b/mysql-test/r/optimizer_switch_eng_cond_pushdown2.result deleted file mode 100644 index 813f8b47f6c..00000000000 --- a/mysql-test/r/optimizer_switch_eng_cond_pushdown2.result +++ /dev/null @@ -1,5 +0,0 @@ -select @@session.engine_condition_pushdown, -@@global.engine_condition_pushdown, -@@session.optimizer_switch, @@global.optimizer_switch; -@@session.engine_condition_pushdown @@global.engine_condition_pushdown @@session.optimizer_switch @@global.optimizer_switch -0 0 index_merge=on,index_merge_union=on,index_merge_sort_union=on,index_merge_intersection=on,index_merge_sort_intersection=off,engine_condition_pushdown=off,index_condition_pushdown=off,derived_merge=off,derived_with_keys=off,firstmatch=off,loosescan=off,materialization=off,in_to_exists=on,semijoin=off,partial_match_rowid_merge=on,partial_match_table_scan=on,subquery_cache=off,mrr=off,mrr_cost_based=off,mrr_sort_keys=off,outer_join_with_cache=off,semijoin_with_cache=off,join_cache_incremental=on,join_cache_hashed=on,join_cache_bka=on,optimize_join_buffer_size=off,table_elimination=on index_merge=on,index_merge_union=on,index_merge_sort_union=on,index_merge_intersection=on,index_merge_sort_intersection=off,engine_condition_pushdown=off,index_condition_pushdown=off,derived_merge=off,derived_with_keys=off,firstmatch=off,loosescan=off,materialization=off,in_to_exists=on,semijoin=off,partial_match_rowid_merge=on,partial_match_table_scan=on,subquery_cache=off,mrr=off,mrr_cost_based=off,mrr_sort_keys=off,outer_join_with_cache=off,semijoin_with_cache=off,join_cache_incremental=on,join_cache_hashed=on,join_cache_bka=on,optimize_join_buffer_size=off,table_elimination=on diff --git a/mysql-test/r/order_by.result b/mysql-test/r/order_by.result index cf5c9386790..824e6f55ae0 100644 --- a/mysql-test/r/order_by.result +++ b/mysql-test/r/order_by.result @@ -642,9 +642,10 @@ id drop table t1; create table t1(a int, b int, index(b)); insert into t1 values (2, 1), (1, 1), (4, NULL), (3, NULL), (6, 2), (5, 2); +insert into t1 values (12, 11), (11, 11), (14, 3), (13, 5), (16, 12), (15, 12); explain select * from t1 where b=1 or b is null order by a; id select_type table type possible_keys key key_len ref rows Extra -1 SIMPLE t1 ref_or_null b b 5 const 3 Using where; Using filesort +1 SIMPLE t1 ref_or_null b b 5 const 4 Using where; Using filesort select * from t1 where b=1 or b is null order by a; a b 1 1 @@ -653,7 +654,7 @@ a b 4 NULL explain select * from t1 where b=2 or b is null order by a; id select_type table type possible_keys key key_len ref rows Extra -1 SIMPLE t1 ref_or_null b b 5 const 4 Using where; Using filesort +1 SIMPLE t1 ref_or_null b b 5 const 3 Using where; Using filesort select * from t1 where b=2 or b is null order by a; a b 3 NULL @@ -1465,7 +1466,7 @@ INSERT INTO t1 VALUES (1, 10), (2, NULL); EXPLAIN SELECT 1 AS col FROM t1 WHERE a=2 AND (c=10 OR c IS NULL) ORDER BY c; id select_type table type possible_keys key key_len ref rows Extra -1 SIMPLE t1 ref_or_null a_c,a a_c 10 const,const 1 Using where +1 SIMPLE t1 ref_or_null a_c,a a_c 10 const,const 2 Using where; Using index; Using filesort # Must return 1 row SELECT 1 AS col FROM t1 WHERE a=2 AND (c=10 OR c IS NULL) ORDER BY c; col @@ -1718,6 +1719,13 @@ a 1 3 1 2 1 DROP TABLE t1; +# +# Bug#11765255 58201: +# VALGRIND/CRASH WHEN ORDERING BY MULTIPLE AGGREGATE FUNCTIONS +# +select 1 order by max(1) + min(1); +1 +1 End of 5.1 tests # # Bug #38745: MySQL 5.1 optimizer uses filesort for ORDER BY diff --git a/mysql-test/r/partition_innodb_plugin.result b/mysql-test/r/partition_innodb_plugin.result index aa0944e96b5..43838170501 100644 --- a/mysql-test/r/partition_innodb_plugin.result +++ b/mysql-test/r/partition_innodb_plugin.result @@ -2,7 +2,6 @@ call mtr.add_suppression("nnoDB: Error: table `test`.`t1` .* Partition.* InnoDB # # Bug#55091: Server crashes on ADD PARTITION after a failed attempt # -SET @old_innodb_file_format_max = @@global.innodb_file_format_max; SET @old_innodb_file_format = @@global.innodb_file_format; SET @old_innodb_file_per_table = @@global.innodb_file_per_table; SET @old_innodb_strict_mode = @@global.innodb_strict_mode; @@ -70,7 +69,6 @@ DROP TABLE t1; SET @@global.innodb_strict_mode = @old_innodb_strict_mode; SET @@global.innodb_file_format = @old_innodb_file_format; SET @@global.innodb_file_per_table = @old_innodb_file_per_table; -SET @@global.innodb_file_format_max = @old_innodb_file_format_max; SET NAMES utf8; CREATE TABLE `t``\""e` (a INT, PRIMARY KEY (a)) ENGINE=InnoDB diff --git a/mysql-test/r/partition_pruning.result b/mysql-test/r/partition_pruning.result index 3f49bf9cc9e..eb0849e2cad 100644 --- a/mysql-test/r/partition_pruning.result +++ b/mysql-test/r/partition_pruning.result @@ -2669,16 +2669,17 @@ drop table t1; create table t1 (a int not null, b int not null, key(a), key(b)) partition by hash(a) partitions 4; insert into t1 values (1,1),(2,2),(3,3),(4,4); +insert into t1 values (5,5),(6,6),(7,7),(8,8); explain partitions select * from t1 X, t1 Y where X.b = Y.b and (X.a=1 or X.a=2) and (Y.a=2 or Y.a=3); id select_type table partitions type possible_keys key key_len ref rows Extra -1 SIMPLE X p1,p2 ALL a,b NULL NULL NULL 2 Using where +1 SIMPLE X p1,p2 range a,b a 4 NULL 4 Using where 1 SIMPLE Y p2,p3 ref a,b b 4 test.X.b 2 Using where explain partitions select * from t1 X, t1 Y where X.a = Y.a and (X.a=1 or X.a=2); id select_type table partitions type possible_keys key key_len ref rows Extra -1 SIMPLE X p1,p2 ALL a NULL NULL NULL 2 Using where +1 SIMPLE X p1,p2 range a a 4 NULL 4 Using where 1 SIMPLE Y p1,p2 ref a a 4 test.X.a 2 drop table t1; create table t1 (a int) partition by hash(a) partitions 20; diff --git a/mysql-test/r/plugin_auth.result b/mysql-test/r/plugin_auth.result index 5a22e47107f..40e974f90eb 100644 --- a/mysql-test/r/plugin_auth.result +++ b/mysql-test/r/plugin_auth.result @@ -395,4 +395,39 @@ ORDER BY COLUMN_NAME; IS_NULLABLE COLUMN_NAME NO authentication_string NO plugin +# +# Bug # 11766641: 59792: BIN/MYSQL -UUNKNOWN -PUNKNOWN +# .-> USING PASSWORD: NO +# +# shoud contain "using password=yes" +ERROR 1045 (28000): Access denied for user 'unknown'@'localhost' (using password: YES) +# shoud contain "using password=no" +ERROR 1045 (28000): Access denied for user 'unknown'@'localhost' (using password: NO) +# +# Bug #12610784: SET PASSWORD INCORRECTLY KEEP AN OLD EMPTY PASSWORD +# +CREATE USER bug12610784@localhost; +SET PASSWORD FOR bug12610784@localhost = PASSWORD('secret'); +ERROR 28000: Access denied for user 'bug12610784'@'localhost' (using password: NO) +DROP USER bug12610784@localhost; +# +# Bug #12818542: PAM: ADDING PASSWORD FOR AN ACCOUNT DISABLES PAM +# AUTHENTICATION SETTINGS +# +CREATE USER bug12818542@localhost +IDENTIFIED WITH 'test_plugin_server' AS 'bug12818542_dest'; +CREATE USER bug12818542_dest@localhost +IDENTIFIED BY 'bug12818542_dest_passwd'; +GRANT PROXY ON bug12818542_dest@localhost TO bug12818542@localhost; +SELECT USER(),CURRENT_USER(); +USER() CURRENT_USER() +bug12818542@localhost bug12818542_dest@localhost +SET PASSWORD = PASSWORD('bruhaha'); +Warnings: +Note 1699 SET PASSWORD has no significance for users authenticating via plugins +SELECT USER(),CURRENT_USER(); +USER() CURRENT_USER() +bug12818542@localhost bug12818542_dest@localhost +DROP USER bug12818542@localhost; +DROP USER bug12818542_dest@localhost; End of 5.5 tests diff --git a/mysql-test/r/ps_ddl.result b/mysql-test/r/ps_ddl.result index 726579d1595..1b908e1046d 100644 --- a/mysql-test/r/ps_ddl.result +++ b/mysql-test/r/ps_ddl.result @@ -1568,12 +1568,12 @@ create view v_27690_1 as select A.a, A.b from t_27690_1 A, t_27690_1 B; execute stmt; a b a b 1 1 1 1 -1 1 2 2 2 2 1 1 -2 2 2 2 1 1 1 1 -1 1 2 2 2 2 1 1 +1 1 2 2 +2 2 2 2 +1 1 2 2 2 2 2 2 call p_verify_reprepare_count(1); SUCCESS @@ -1581,12 +1581,12 @@ SUCCESS execute stmt; a b a b 1 1 1 1 -1 1 2 2 2 2 1 1 -2 2 2 2 1 1 1 1 -1 1 2 2 2 2 1 1 +1 1 2 2 +2 2 2 2 +1 1 2 2 2 2 2 2 call p_verify_reprepare_count(0); SUCCESS diff --git a/mysql-test/r/range.result b/mysql-test/r/range.result index 62f73a712c8..1c6845ef07e 100644 --- a/mysql-test/r/range.result +++ b/mysql-test/r/range.result @@ -698,6 +698,18 @@ INSERT INTO t1 VALUES 'd8c4177d09f8b11f5.52725521'), ('d8c4177d24ccef970.14957924','d8c4177d09f8b11f5.52725521',10,11, 'd8c4177d09f8b11f5.52725521'); +INSERT INTO t1 VALUES +('d8c4177d09f8b11f5.52725522','oxrootid',1,40,'d8c4177d09f8b11f5.52725522'), +('d8c4177d151affab2.81582771','d8c4177d09f8b11f5.52725521',2,3, +'d8c4177d09f8b11f5.52725522'), +('d8c4177d206a333d2.74422678','d8c4177d09f8b11f5.52725521',4,5, +'d8c4177d09f8b11f5.52725522'), +('d8c4177d225791924.30714721','d8c4177d09f8b11f5.52725521',6,7, +'d8c4177d09f8b11f5.52725522'), +('d8c4177d2380fc201.39666694','d8c4177d09f8b11f5.52725521',8,9, +'d8c4177d09f8b11f5.52725522'), +('d8c4177d24ccef970.14957925','d8c4177d09f8b11f5.52725521',10,11, +'d8c4177d09f8b11f5.52725522'); EXPLAIN SELECT s.oxid FROM t1 v, t1 s WHERE s.oxrootid = 'd8c4177d09f8b11f5.52725521' AND @@ -705,7 +717,7 @@ v.oxrootid ='d8c4177d09f8b11f5.52725521' AND s.oxleft > v.oxleft AND s.oxleft < v.oxright; id select_type table type possible_keys key key_len ref rows Extra 1 SIMPLE v ref OXLEFT,OXRIGHT,OXROOTID OXROOTID 34 const 5 Using where -1 SIMPLE s ALL OXLEFT NULL NULL NULL 6 Range checked for each record (index map: 0x4) +1 SIMPLE s ALL OXLEFT NULL NULL NULL 12 Range checked for each record (index map: 0x4) SELECT s.oxid FROM t1 v, t1 s WHERE s.oxrootid = 'd8c4177d09f8b11f5.52725521' AND v.oxrootid ='d8c4177d09f8b11f5.52725521' AND diff --git a/mysql-test/r/range_mrr_icp.result b/mysql-test/r/range_mrr_icp.result index 3ddbc992c27..5966785c7c3 100644 --- a/mysql-test/r/range_mrr_icp.result +++ b/mysql-test/r/range_mrr_icp.result @@ -700,6 +700,18 @@ INSERT INTO t1 VALUES 'd8c4177d09f8b11f5.52725521'), ('d8c4177d24ccef970.14957924','d8c4177d09f8b11f5.52725521',10,11, 'd8c4177d09f8b11f5.52725521'); +INSERT INTO t1 VALUES +('d8c4177d09f8b11f5.52725522','oxrootid',1,40,'d8c4177d09f8b11f5.52725522'), +('d8c4177d151affab2.81582771','d8c4177d09f8b11f5.52725521',2,3, +'d8c4177d09f8b11f5.52725522'), +('d8c4177d206a333d2.74422678','d8c4177d09f8b11f5.52725521',4,5, +'d8c4177d09f8b11f5.52725522'), +('d8c4177d225791924.30714721','d8c4177d09f8b11f5.52725521',6,7, +'d8c4177d09f8b11f5.52725522'), +('d8c4177d2380fc201.39666694','d8c4177d09f8b11f5.52725521',8,9, +'d8c4177d09f8b11f5.52725522'), +('d8c4177d24ccef970.14957925','d8c4177d09f8b11f5.52725521',10,11, +'d8c4177d09f8b11f5.52725522'); EXPLAIN SELECT s.oxid FROM t1 v, t1 s WHERE s.oxrootid = 'd8c4177d09f8b11f5.52725521' AND @@ -707,7 +719,7 @@ v.oxrootid ='d8c4177d09f8b11f5.52725521' AND s.oxleft > v.oxleft AND s.oxleft < v.oxright; id select_type table type possible_keys key key_len ref rows Extra 1 SIMPLE v ref OXLEFT,OXRIGHT,OXROOTID OXROOTID 34 const 5 Using index condition -1 SIMPLE s ALL OXLEFT NULL NULL NULL 6 Range checked for each record (index map: 0x4) +1 SIMPLE s ALL OXLEFT NULL NULL NULL 12 Range checked for each record (index map: 0x4) SELECT s.oxid FROM t1 v, t1 s WHERE s.oxrootid = 'd8c4177d09f8b11f5.52725521' AND v.oxrootid ='d8c4177d09f8b11f5.52725521' AND @@ -915,7 +927,7 @@ id select_type table type possible_keys key key_len ref rows Extra 1 SIMPLE t1 range status status 23 NULL 10 Using index condition; Rowid-ordered scan EXPLAIN SELECT * FROM t1 WHERE status < 'A' OR status > 'B'; id select_type table type possible_keys key key_len ref rows Extra -1 SIMPLE t1 range status status 23 NULL 10 Using index condition; Rowid-ordered scan +1 SIMPLE t1 range status status 23 NULL 10 Using index condition; Using where; Rowid-ordered scan SELECT * FROM t1 WHERE status NOT BETWEEN 'A' AND 'B'; id status 53 C @@ -1019,13 +1031,13 @@ id select_type table type possible_keys key key_len ref rows Extra 1 SIMPLE t1 range a a 13 NULL # Using index condition; Rowid-ordered scan explain select * from t1 where a = 'a' or a='a '; id select_type table type possible_keys key key_len ref rows Extra -1 SIMPLE t1 range a a 13 NULL # Using index condition; Rowid-ordered scan +1 SIMPLE t1 range a a 13 NULL # Using index condition; Using where; Rowid-ordered scan explain select * from t2 where a between 'a' and 'a '; id select_type table type possible_keys key key_len ref rows Extra 1 SIMPLE t2 ref a a 13 const # Using index condition explain select * from t2 where a = 'a' or a='a '; id select_type table type possible_keys key key_len ref rows Extra -1 SIMPLE t2 ref a a 13 const # Using index condition +1 SIMPLE t2 ref a a 13 const # Using index condition; Using where update t1 set a='b' where a<>'a'; explain select * from t1 where a not between 'b' and 'b'; id select_type table type possible_keys key key_len ref rows Extra @@ -1783,7 +1795,7 @@ INSERT INTO t100(I,J) VALUES(8,26); EXPLAIN SELECT * FROM t100 WHERE I <> 6 OR (I <> 8 AND J = 5); id select_type table type possible_keys key key_len ref rows Extra -1 SIMPLE t100 range I I 10 NULL 4 Using index condition; Rowid-ordered scan +1 SIMPLE t100 range I I 10 NULL 4 Using index condition; Using where; Rowid-ordered scan SELECT * FROM t100 WHERE I <> 6 OR (I <> 8 AND J = 5); K I J diff --git a/mysql-test/r/range_vs_index_merge.result b/mysql-test/r/range_vs_index_merge.result index 08ede868ed6..f1838bc9aae 100644 --- a/mysql-test/r/range_vs_index_merge.result +++ b/mysql-test/r/range_vs_index_merge.result @@ -1377,4 +1377,41 @@ SELECT * FROM t1,t2,t3 WHERE (t2.f3 = 1 OR t3.f1=t2.f1) AND t3.f1 <> t2.f2 AND t3.f2 = t2.f4; f1 f1 f2 f3 f4 f1 f2 DROP TABLE t1,t2,t3; +CREATE TABLE t1 ( +a int, b int, c int, d int, +PRIMARY KEY(b), INDEX idx1(d), INDEX idx2(d,b,c) +); +INSERT INTO t1 VALUES +(0,58,7,7),(0,63,2,0),(0,64,186,8),(0,65,1,-2), (0,71,190,-3), +(0,72,321,-7),(0,73,0,3),(0,74,5,25),(0,75,5,3); +SET SESSION optimizer_switch='index_merge_sort_union=off'; +EXPLAIN +SELECT * FROM t1 +WHERE t1.b>7 AND t1.d>1 AND t1.d<>8 OR t1.d>=7 AND t1.d<8 OR t1.d>7; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t1 ALL PRIMARY,idx1,idx2 NULL NULL NULL 9 Using where +SELECT * FROM t1 +WHERE t1.b>7 AND t1.d>1 AND t1.d<>8 OR t1.d>=7 AND t1.d<8 OR t1.d>7; +a b c d +0 58 7 7 +0 64 186 8 +0 73 0 3 +0 74 5 25 +0 75 5 3 +SET SESSION optimizer_switch='index_merge_sort_union=on'; +EXPLAIN +SELECT * FROM t1 +WHERE t1.b>7 AND t1.d>1 AND t1.d<>8 OR t1.d>=7 AND t1.d<8 OR t1.d>7; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t1 ALL PRIMARY,idx1,idx2 NULL NULL NULL 9 Using where +SELECT * FROM t1 +WHERE t1.b>7 AND t1.d>1 AND t1.d<>8 OR t1.d>=7 AND t1.d<8 OR t1.d>7; +a b c d +0 58 7 7 +0 64 186 8 +0 73 0 3 +0 74 5 25 +0 75 5 3 +SET SESSION optimizer_switch=DEFAULT; +DROP TABLE t1; set session optimizer_switch='index_merge_sort_intersection=default'; diff --git a/mysql-test/r/range_vs_index_merge_innodb.result b/mysql-test/r/range_vs_index_merge_innodb.result index e74d187a416..71a4fcf9690 100644 --- a/mysql-test/r/range_vs_index_merge_innodb.result +++ b/mysql-test/r/range_vs_index_merge_innodb.result @@ -1378,5 +1378,42 @@ SELECT * FROM t1,t2,t3 WHERE (t2.f3 = 1 OR t3.f1=t2.f1) AND t3.f1 <> t2.f2 AND t3.f2 = t2.f4; f1 f1 f2 f3 f4 f1 f2 DROP TABLE t1,t2,t3; +CREATE TABLE t1 ( +a int, b int, c int, d int, +PRIMARY KEY(b), INDEX idx1(d), INDEX idx2(d,b,c) +); +INSERT INTO t1 VALUES +(0,58,7,7),(0,63,2,0),(0,64,186,8),(0,65,1,-2), (0,71,190,-3), +(0,72,321,-7),(0,73,0,3),(0,74,5,25),(0,75,5,3); +SET SESSION optimizer_switch='index_merge_sort_union=off'; +EXPLAIN +SELECT * FROM t1 +WHERE t1.b>7 AND t1.d>1 AND t1.d<>8 OR t1.d>=7 AND t1.d<8 OR t1.d>7; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t1 ALL PRIMARY,idx1,idx2 NULL NULL NULL 9 Using where +SELECT * FROM t1 +WHERE t1.b>7 AND t1.d>1 AND t1.d<>8 OR t1.d>=7 AND t1.d<8 OR t1.d>7; +a b c d +0 58 7 7 +0 64 186 8 +0 73 0 3 +0 74 5 25 +0 75 5 3 +SET SESSION optimizer_switch='index_merge_sort_union=on'; +EXPLAIN +SELECT * FROM t1 +WHERE t1.b>7 AND t1.d>1 AND t1.d<>8 OR t1.d>=7 AND t1.d<8 OR t1.d>7; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t1 ALL PRIMARY,idx1,idx2 NULL NULL NULL 9 Using where +SELECT * FROM t1 +WHERE t1.b>7 AND t1.d>1 AND t1.d<>8 OR t1.d>=7 AND t1.d<8 OR t1.d>7; +a b c d +0 58 7 7 +0 64 186 8 +0 73 0 3 +0 74 5 25 +0 75 5 3 +SET SESSION optimizer_switch=DEFAULT; +DROP TABLE t1; set session optimizer_switch='index_merge_sort_intersection=default'; SET SESSION STORAGE_ENGINE=DEFAULT; diff --git a/mysql-test/r/secure_file_priv_win.result b/mysql-test/r/secure_file_priv_win.result new file mode 100644 index 00000000000..d6636aad5d4 --- /dev/null +++ b/mysql-test/r/secure_file_priv_win.result @@ -0,0 +1,38 @@ +CREATE TABLE t1 (c1 longtext); +INSERT INTO t1 values ('a'); +SELECT * FROM t1 INTO OUTFILE 'MYSQL_TMP_DIR/B11764517.tmp'; +show global variables like 'secure_file_priv'; +Variable_name Value +secure_file_priv MYSQL_TMP_DIR/ +SELECT load_file('MYSQL_TMP_DIR\\B11764517.tmp') AS x; +x +a + +SELECT load_file('MYSQL_TMP_DIR/B11764517.tmp') AS x; +x +a + +SELECT load_file('MYSQL_TMP_DIR_UCASE/B11764517.tmp') AS x; +x +a + +SELECT load_file('MYSQL_TMP_DIR_LCASE/B11764517.tmp') AS x; +x +a + +SELECT load_file('MYSQL_TMP_DIR\\..a..\\..\\..\\B11764517.tmp') AS x; +x +NULL +LOAD DATA INFILE 'MYSQL_TMP_DIR\\B11764517.tmp' INTO TABLE t1; +LOAD DATA INFILE 'MYSQL_TMP_DIR/B11764517.tmp' INTO TABLE t1; +LOAD DATA INFILE 'MYSQL_TMP_DIR_UCASE/B11764517.tmp' INTO TABLE t1; +LOAD DATA INFILE 'MYSQL_TMP_DIR_LCASE/B11764517.tmp' INTO TABLE t1; +LOAD DATA INFILE "MYSQL_TMP_DIR\\..a..\\..\\..\\B11764517.tmp" into table t1; +ERROR HY000: The MySQL server is running with the --secure-file-priv option so it cannot execute this statement +SELECT * FROM t1 INTO OUTFILE 'MYSQL_TMP_DIR\\..a..\\..\\..\\B11764517-2.tmp'; +ERROR HY000: The MySQL server is running with the --secure-file-priv option so it cannot execute this statement +SELECT * FROM t1 INTO OUTFILE 'MYSQL_TMP_DIR\\B11764517-2.tmp'; +SELECT * FROM t1 INTO OUTFILE 'MYSQL_TMP_DIR/B11764517-3.tmp'; +SELECT * FROM t1 INTO OUTFILE 'MYSQL_TMP_DIR_UCASE/B11764517-4.tmp'; +SELECT * FROM t1 INTO OUTFILE 'MYSQL_TMP_DIR_LCASE/B11764517-5.tmp'; +DROP TABLE t1; diff --git a/mysql-test/r/select.result b/mysql-test/r/select.result index 2a187cb3d8c..5a20057995d 100644 --- a/mysql-test/r/select.result +++ b/mysql-test/r/select.result @@ -2394,6 +2394,7 @@ CREATE TABLE t1 ( a BLOB, INDEX (a(20)) ); CREATE TABLE t2 ( a BLOB, INDEX (a(20)) ); INSERT INTO t1 VALUES ('one'),('two'),('three'),('four'),('five'); INSERT INTO t2 VALUES ('one'),('two'),('three'),('four'),('five'); +INSERT INTO t2 VALUES ('one'),('two'),('three'),('four'),('five'); EXPLAIN SELECT * FROM t1 LEFT JOIN t2 USE INDEX (a) ON t1.a=t2.a; id select_type table type possible_keys key key_len ref rows Extra 1 SIMPLE t1 ALL NULL NULL NULL NULL 5 @@ -4786,7 +4787,7 @@ EXPLAIN EXTENDED SELECT * FROM t1 WHERE a > UNIX_TIMESTAMP('2009-03-10 00:00:00' id select_type table type possible_keys key key_len ref rows filtered Extra 1 SIMPLE t1 ALL NULL NULL NULL NULL 10 100.00 Using where Warnings: -Note 1003 select `test`.`t1`.`a` AS `a` from `test`.`t1` where (`test`.`t1`.`a` > 1236639600) +Note 1003 select `test`.`t1`.`a` AS `a` from `test`.`t1` where (`test`.`t1`.`a` > <cache>(unix_timestamp('2009-03-10 00:00:00'))) CREATE FUNCTION f1() RETURNS INT DETERMINISTIC BEGIN SET @cnt := @cnt + 1; diff --git a/mysql-test/r/select_jcl6.result b/mysql-test/r/select_jcl6.result index 0451f35dae6..22ad32c23f2 100644 --- a/mysql-test/r/select_jcl6.result +++ b/mysql-test/r/select_jcl6.result @@ -2403,6 +2403,7 @@ CREATE TABLE t1 ( a BLOB, INDEX (a(20)) ); CREATE TABLE t2 ( a BLOB, INDEX (a(20)) ); INSERT INTO t1 VALUES ('one'),('two'),('three'),('four'),('five'); INSERT INTO t2 VALUES ('one'),('two'),('three'),('four'),('five'); +INSERT INTO t2 VALUES ('one'),('two'),('three'),('four'),('five'); EXPLAIN SELECT * FROM t1 LEFT JOIN t2 USE INDEX (a) ON t1.a=t2.a; id select_type table type possible_keys key key_len ref rows Extra 1 SIMPLE t1 ALL NULL NULL NULL NULL 5 @@ -3427,7 +3428,7 @@ SELECT t2.sku, t2.sppr, t2.name, t1.sku, t1.pr FROM t2, t1 WHERE t2.sku=20 AND (t2.sku=t1.sku OR t2.sppr=t1.sku); id select_type table type possible_keys key key_len ref rows Extra 1 SIMPLE t2 const PRIMARY PRIMARY 4 const 1 -1 SIMPLE t1 range PRIMARY PRIMARY 4 NULL 2 Using index condition; Rowid-ordered scan +1 SIMPLE t1 range PRIMARY PRIMARY 4 NULL 2 Using index condition; Using where; Rowid-ordered scan DROP TABLE t1,t2; SET SQL_MODE='NO_UNSIGNED_SUBTRACTION'; CREATE TABLE t1 (i TINYINT UNSIGNED NOT NULL); @@ -4795,7 +4796,7 @@ EXPLAIN EXTENDED SELECT * FROM t1 WHERE a > UNIX_TIMESTAMP('2009-03-10 00:00:00' id select_type table type possible_keys key key_len ref rows filtered Extra 1 SIMPLE t1 ALL NULL NULL NULL NULL 10 100.00 Using where Warnings: -Note 1003 select `test`.`t1`.`a` AS `a` from `test`.`t1` where (`test`.`t1`.`a` > 1236639600) +Note 1003 select `test`.`t1`.`a` AS `a` from `test`.`t1` where (`test`.`t1`.`a` > <cache>(unix_timestamp('2009-03-10 00:00:00'))) CREATE FUNCTION f1() RETURNS INT DETERMINISTIC BEGIN SET @cnt := @cnt + 1; diff --git a/mysql-test/r/select_pkeycache.result b/mysql-test/r/select_pkeycache.result index 2a187cb3d8c..5a20057995d 100644 --- a/mysql-test/r/select_pkeycache.result +++ b/mysql-test/r/select_pkeycache.result @@ -2394,6 +2394,7 @@ CREATE TABLE t1 ( a BLOB, INDEX (a(20)) ); CREATE TABLE t2 ( a BLOB, INDEX (a(20)) ); INSERT INTO t1 VALUES ('one'),('two'),('three'),('four'),('five'); INSERT INTO t2 VALUES ('one'),('two'),('three'),('four'),('five'); +INSERT INTO t2 VALUES ('one'),('two'),('three'),('four'),('five'); EXPLAIN SELECT * FROM t1 LEFT JOIN t2 USE INDEX (a) ON t1.a=t2.a; id select_type table type possible_keys key key_len ref rows Extra 1 SIMPLE t1 ALL NULL NULL NULL NULL 5 @@ -4786,7 +4787,7 @@ EXPLAIN EXTENDED SELECT * FROM t1 WHERE a > UNIX_TIMESTAMP('2009-03-10 00:00:00' id select_type table type possible_keys key key_len ref rows filtered Extra 1 SIMPLE t1 ALL NULL NULL NULL NULL 10 100.00 Using where Warnings: -Note 1003 select `test`.`t1`.`a` AS `a` from `test`.`t1` where (`test`.`t1`.`a` > 1236639600) +Note 1003 select `test`.`t1`.`a` AS `a` from `test`.`t1` where (`test`.`t1`.`a` > <cache>(unix_timestamp('2009-03-10 00:00:00'))) CREATE FUNCTION f1() RETURNS INT DETERMINISTIC BEGIN SET @cnt := @cnt + 1; diff --git a/mysql-test/r/select_safe.result b/mysql-test/r/select_safe.result index 542c18dcec5..60364b8c4ec 100644 --- a/mysql-test/r/select_safe.result +++ b/mysql-test/r/select_safe.result @@ -30,7 +30,7 @@ ERROR HY000: You are using safe update mode and you tried to update a table with delete from t1 where a+0=1; ERROR HY000: You are using safe update mode and you tried to update a table without a WHERE that uses a KEY column select 1 from t1,t1 as t2,t1 as t3,t1 as t4,t1 as t5; -ERROR 42000: The SELECT would examine more than MAX_JOIN_SIZE rows; check your WHERE and use SET SQL_BIG_SELECTS=1 or SET SQL_MAX_JOIN_SIZE=# if the SELECT is okay +ERROR 42000: The SELECT would examine more than MAX_JOIN_SIZE rows; check your WHERE and use SET SQL_BIG_SELECTS=1 or SET MAX_JOIN_SIZE=# if the SELECT is okay update t1 set b="a" limit 1; update t1 set b="a" where b="b" limit 2; delete from t1 where b="test" limit 1; @@ -42,7 +42,7 @@ SELECT @@MAX_JOIN_SIZE, @@SQL_BIG_SELECTS; 2 0 insert into t1 values (null,"a"),(null,"a"),(null,"a"),(null,"a"),(null,"a"),(null,"a"),(null,"a"),(null,"a"),(null,"a"),(null,"a"); SELECT * from t1 order by a; -ERROR 42000: The SELECT would examine more than MAX_JOIN_SIZE rows; check your WHERE and use SET SQL_BIG_SELECTS=1 or SET SQL_MAX_JOIN_SIZE=# if the SELECT is okay +ERROR 42000: The SELECT would examine more than MAX_JOIN_SIZE rows; check your WHERE and use SET SQL_BIG_SELECTS=1 or SET MAX_JOIN_SIZE=# if the SELECT is okay SET SQL_BIG_SELECTS=1; SELECT * from t1 order by a; a b @@ -52,7 +52,7 @@ a b 5 a SET MAX_JOIN_SIZE=2; SELECT * from t1; -ERROR 42000: The SELECT would examine more than MAX_JOIN_SIZE rows; check your WHERE and use SET SQL_BIG_SELECTS=1 or SET SQL_MAX_JOIN_SIZE=# if the SELECT is okay +ERROR 42000: The SELECT would examine more than MAX_JOIN_SIZE rows; check your WHERE and use SET SQL_BIG_SELECTS=1 or SET MAX_JOIN_SIZE=# if the SELECT is okay SET MAX_JOIN_SIZE=DEFAULT; SELECT * from t1; a b @@ -64,14 +64,16 @@ analyze table t1; Table Op Msg_type Msg_text test.t1 analyze status OK insert into t1 values (null,"a"),(null,"a"),(null,"a"),(null,"a"),(null,"a"),(null,"a"),(null,"a"),(null,"a"),(null,"a"),(null,"a"); +insert into t1 values (null,"b"),(null,"b"),(null,"c"),(null,"c"),(null,"d"),(null,"d"),(null,"e"),(null,"e"),(null,"a"),(null,"e"); +insert into t1 values (null,"x"),(null,"x"),(null,"y"),(null,"y"),(null,"z"),(null,"z"),(null,"v"),(null,"v"),(null,"a"),(null,"v"); explain select STRAIGHT_JOIN * from t1,t1 as t2 where t1.b=t2.b; id select_type table type possible_keys key key_len ref rows Extra -1 SIMPLE t1 ALL b NULL NULL NULL 21 Using where +1 SIMPLE t1 ALL b NULL NULL NULL 41 Using where 1 SIMPLE t2 ref b b 21 test.t1.b 6 set MAX_SEEKS_FOR_KEY=1; explain select STRAIGHT_JOIN * from t1,t1 as t2 where t1.b=t2.b; id select_type table type possible_keys key key_len ref rows Extra -1 SIMPLE t1 ALL b NULL NULL NULL 21 Using where +1 SIMPLE t1 ALL b NULL NULL NULL 41 Using where 1 SIMPLE t2 ref b b 21 test.t1.b 6 SET MAX_SEEKS_FOR_KEY=DEFAULT; drop table t1; @@ -82,12 +84,12 @@ insert into t1 select * from t1; insert into t1 select * from t1; set local max_join_size=8; select * from (select * from t1) x; -ERROR 42000: The SELECT would examine more than MAX_JOIN_SIZE rows; check your WHERE and use SET SQL_BIG_SELECTS=1 or SET SQL_MAX_JOIN_SIZE=# if the SELECT is okay +ERROR 42000: The SELECT would examine more than MAX_JOIN_SIZE rows; check your WHERE and use SET SQL_BIG_SELECTS=1 or SET MAX_JOIN_SIZE=# if the SELECT is okay set local max_join_size=1; select * from (select a.a as aa, b.a as ba from t1 a, t1 b) x; -ERROR 42000: The SELECT would examine more than MAX_JOIN_SIZE rows; check your WHERE and use SET SQL_BIG_SELECTS=1 or SET SQL_MAX_JOIN_SIZE=# if the SELECT is okay +ERROR 42000: The SELECT would examine more than MAX_JOIN_SIZE rows; check your WHERE and use SET SQL_BIG_SELECTS=1 or SET MAX_JOIN_SIZE=# if the SELECT is okay set local max_join_size=1; select * from (select 1 union select 2 union select 3) x; -ERROR 42000: The SELECT would examine more than MAX_JOIN_SIZE rows; check your WHERE and use SET SQL_BIG_SELECTS=1 or SET SQL_MAX_JOIN_SIZE=# if the SELECT is okay +ERROR 42000: The SELECT would examine more than MAX_JOIN_SIZE rows; check your WHERE and use SET SQL_BIG_SELECTS=1 or SET MAX_JOIN_SIZE=# if the SELECT is okay drop table t1; SET SQL_SAFE_UPDATES=0,SQL_SELECT_LIMIT=DEFAULT, MAX_JOIN_SIZE=DEFAULT; diff --git a/mysql-test/r/show_check.result b/mysql-test/r/show_check.result index e2b92e443ee..b0a812c7b18 100644 --- a/mysql-test/r/show_check.result +++ b/mysql-test/r/show_check.result @@ -460,57 +460,57 @@ insert into t2 values (1),(2); insert into t3 values (1,1),(2,2); show table status; Name Engine Version Row_format Rows Avg_row_length Data_length Max_data_length Index_length Data_free Auto_increment Create_time Update_time Check_time Collation Checksum Create_options Comment -t1 MEMORY 10 Fixed 2 # # # # 0 NULL NULL NULL NULL latin1_swedish_ci NULL -t2 MEMORY 10 Fixed 2 # # # # 0 NULL NULL NULL NULL latin1_swedish_ci NULL -t3 MEMORY 10 Fixed 2 # # # # 0 NULL NULL NULL NULL latin1_swedish_ci NULL +t1 MEMORY 10 Fixed 2 # # # # 0 NULL # NULL NULL latin1_swedish_ci NULL +t2 MEMORY 10 Fixed 2 # # # # 0 NULL # NULL NULL latin1_swedish_ci NULL +t3 MEMORY 10 Fixed 2 # # # # 0 NULL # NULL NULL latin1_swedish_ci NULL insert into t1 values (3),(4); insert into t2 values (3),(4); insert into t3 values (3,3),(4,4); show table status; Name Engine Version Row_format Rows Avg_row_length Data_length Max_data_length Index_length Data_free Auto_increment Create_time Update_time Check_time Collation Checksum Create_options Comment -t1 MEMORY 10 Fixed 4 # # # # 0 NULL NULL NULL NULL latin1_swedish_ci NULL -t2 MEMORY 10 Fixed 4 # # # # 0 NULL NULL NULL NULL latin1_swedish_ci NULL -t3 MEMORY 10 Fixed 4 # # # # 0 NULL NULL NULL NULL latin1_swedish_ci NULL +t1 MEMORY 10 Fixed 4 # # # # 0 NULL # NULL NULL latin1_swedish_ci NULL +t2 MEMORY 10 Fixed 4 # # # # 0 NULL # NULL NULL latin1_swedish_ci NULL +t3 MEMORY 10 Fixed 4 # # # # 0 NULL # NULL NULL latin1_swedish_ci NULL insert into t1 values (5); insert into t2 values (5); insert into t3 values (5,5); show table status; Name Engine Version Row_format Rows Avg_row_length Data_length Max_data_length Index_length Data_free Auto_increment Create_time Update_time Check_time Collation Checksum Create_options Comment -t1 MEMORY 10 Fixed 5 # # # # 0 NULL NULL NULL NULL latin1_swedish_ci NULL -t2 MEMORY 10 Fixed 5 # # # # 0 NULL NULL NULL NULL latin1_swedish_ci NULL -t3 MEMORY 10 Fixed 5 # # # # 0 NULL NULL NULL NULL latin1_swedish_ci NULL +t1 MEMORY 10 Fixed 5 # # # # 0 NULL # NULL NULL latin1_swedish_ci NULL +t2 MEMORY 10 Fixed 5 # # # # 0 NULL # NULL NULL latin1_swedish_ci NULL +t3 MEMORY 10 Fixed 5 # # # # 0 NULL # NULL NULL latin1_swedish_ci NULL delete from t1 where a=3; delete from t2 where b=3; delete from t3 where a=3; show table status; Name Engine Version Row_format Rows Avg_row_length Data_length Max_data_length Index_length Data_free Auto_increment Create_time Update_time Check_time Collation Checksum Create_options Comment -t1 MEMORY 10 Fixed 4 # # # # # NULL NULL NULL NULL latin1_swedish_ci NULL -t2 MEMORY 10 Fixed 4 # # # # # NULL NULL NULL NULL latin1_swedish_ci NULL -t3 MEMORY 10 Fixed 4 # # # # # NULL NULL NULL NULL latin1_swedish_ci NULL +t1 MEMORY 10 Fixed 4 # # # # # NULL # NULL NULL latin1_swedish_ci NULL +t2 MEMORY 10 Fixed 4 # # # # # NULL # NULL NULL latin1_swedish_ci NULL +t3 MEMORY 10 Fixed 4 # # # # # NULL # NULL NULL latin1_swedish_ci NULL truncate table t1; truncate table t2; truncate table t3; show table status; Name Engine Version Row_format Rows Avg_row_length Data_length Max_data_length Index_length Data_free Auto_increment Create_time Update_time Check_time Collation Checksum Create_options Comment -t1 MEMORY 10 Fixed 0 # # # # 0 NULL NULL NULL NULL latin1_swedish_ci NULL -t2 MEMORY 10 Fixed 0 # # # # 0 NULL NULL NULL NULL latin1_swedish_ci NULL -t3 MEMORY 10 Fixed 0 # # # # 0 NULL NULL NULL NULL latin1_swedish_ci NULL +t1 MEMORY 10 Fixed 0 # # # # 0 NULL # NULL NULL latin1_swedish_ci NULL +t2 MEMORY 10 Fixed 0 # # # # 0 NULL # NULL NULL latin1_swedish_ci NULL +t3 MEMORY 10 Fixed 0 # # # # 0 NULL # NULL NULL latin1_swedish_ci NULL insert into t1 values (5); insert into t2 values (5); insert into t3 values (5,5); show table status; Name Engine Version Row_format Rows Avg_row_length Data_length Max_data_length Index_length Data_free Auto_increment Create_time Update_time Check_time Collation Checksum Create_options Comment -t1 MEMORY 10 Fixed 1 # # # # 0 NULL NULL NULL NULL latin1_swedish_ci NULL -t2 MEMORY 10 Fixed 1 # # # # 0 NULL NULL NULL NULL latin1_swedish_ci NULL -t3 MEMORY 10 Fixed 1 # # # # 0 NULL NULL NULL NULL latin1_swedish_ci NULL +t1 MEMORY 10 Fixed 1 # # # # 0 NULL # NULL NULL latin1_swedish_ci NULL +t2 MEMORY 10 Fixed 1 # # # # 0 NULL # NULL NULL latin1_swedish_ci NULL +t3 MEMORY 10 Fixed 1 # # # # 0 NULL # NULL NULL latin1_swedish_ci NULL delete from t1 where a=5; delete from t2 where b=5; delete from t3 where a=5; show table status; Name Engine Version Row_format Rows Avg_row_length Data_length Max_data_length Index_length Data_free Auto_increment Create_time Update_time Check_time Collation Checksum Create_options Comment -t1 MEMORY 10 Fixed 0 # # # # # NULL NULL NULL NULL latin1_swedish_ci NULL -t2 MEMORY 10 Fixed 0 # # # # # NULL NULL NULL NULL latin1_swedish_ci NULL -t3 MEMORY 10 Fixed 0 # # # # # NULL NULL NULL NULL latin1_swedish_ci NULL +t1 MEMORY 10 Fixed 0 # # # # # NULL # NULL NULL latin1_swedish_ci NULL +t2 MEMORY 10 Fixed 0 # # # # # NULL # NULL NULL latin1_swedish_ci NULL +t3 MEMORY 10 Fixed 0 # # # # # NULL # NULL NULL latin1_swedish_ci NULL drop table t1, t2, t3; create database mysqltest; show create database mysqltest; @@ -662,7 +662,7 @@ DROP TABLE t1; flush tables; SHOW TABLE STATUS like 't1'; Name Engine Version Row_format Rows Avg_row_length Data_length Max_data_length Index_length Data_free Auto_increment Create_time Update_time Check_time Collation Checksum Create_options Comment -t1 NULL NULL NULL NULL # # # # NULL NULL NULL NULL NULL NULL NULL NULL Incorrect information in file: './test/t1.frm' +t1 NULL NULL NULL NULL # # # # NULL NULL # NULL NULL NULL NULL NULL Incorrect information in file: './test/t1.frm' Warnings: Warning 1033 Incorrect information in file: './test/t1.frm' show create table t1; @@ -1334,7 +1334,7 @@ CREATE DATABASE `ä`; CREATE TABLE `ä`.`ä` (a int) ENGINE=Memory; SHOW TABLE STATUS FROM `ä` LIKE 'ä'; Name Engine Version Row_format Rows Avg_row_length Data_length Max_data_length Index_length Data_free Auto_increment Create_time Update_time Check_time Collation Checksum Create_options Comment -ä MEMORY 10 Fixed 0 # # # # 0 NULL NULL NULL NULL latin1_swedish_ci NULL +ä MEMORY 10 Fixed 0 # # # # 0 NULL # NULL NULL latin1_swedish_ci NULL DROP DATABASE `ä`; show columns from `#mysql50#????????`; Got one of the listed errors diff --git a/mysql-test/r/sp-error.result b/mysql-test/r/sp-error.result index 4e97429c48f..0da4ed34e89 100644 --- a/mysql-test/r/sp-error.result +++ b/mysql-test/r/sp-error.result @@ -1717,6 +1717,22 @@ ERROR HY000: View 'test.v1' references invalid table(s) or column(s) or function DROP PROCEDURE p1; DROP VIEW v1; DROP TABLE t1; +# +# Bug#12428824 - PARSER STACK OVERFLOW AND CRASH IN SP_ADD_USED_ROUTINE +# WITH OBSCURE QUERY +# +SELECT very_long_fn_name_1111111111111111111111111111111111111111111111111111111111111111111111111222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222225555555555555555555555555577777777777777777777777777777777777777777777777777777777777777777777777788888888999999999999999999999(); +ERROR 42000: Identifier name 'very_long_fn_name_1111111111111111111111111111111111111111111111111111111111111111111111111222222222' is too long +CALL very_long_pr_name_1111111111111111111111111111111111111111111111111111111111111111111111111222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222225555555555555555555555555577777777777777777777777777777777777777777777777777777777777777777777777788888888999999999999999999999(); +ERROR 42000: Identifier name 'very_long_pr_name_1111111111111111111111111111111111111111111111111111111111111111111111111222222222' is too long +SELECT very_long_db_name_1111111111111111111111111111111111111111111111111111111111111111111111111222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222225555555555555555555555555577777777777777777777777777777777777777777777777777777777777777777777777788888888999999999999999999999.simple_func(); +ERROR 42000: Incorrect database name 'very_long_db_name_1111111111111111111111111111111111111111111111111111111111111111111111111222222222' +CALL very_long_db_name_1111111111111111111111111111111111111111111111111111111111111111111111111222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222225555555555555555555555555577777777777777777777777777777777777777777777777777777777777777777777777788888888999999999999999999999.simple_proc(); +ERROR 42000: Incorrect database name 'very_long_db_name_1111111111111111111111111111111111111111111111111111111111111111111111111222222222' +SELECT db_name.very_long_fn_name_111111111111111111111111111111111111111111111111111111111111111111111111122222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222999999999999999999999(); +ERROR 42000: Identifier name 'very_long_fn_name_1111111111111111111111111111111111111111111111111111111111111111111111111222222222' is too long +CALL db_name.very_long_pr_name_111111111111111111111111111111111111111111111111111111111111111111111111122222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222999999999999999999999(); +ERROR 42000: Identifier name 'very_long_pr_name_1111111111111111111111111111111111111111111111111111111111111111111111111222222222' is too long End of 5.1 tests # # Bug#23032: Handlers declared in a SP do not handle warnings generated in sub-SP diff --git a/mysql-test/r/sp-security.result b/mysql-test/r/sp-security.result index c09579b13eb..88908b05f46 100644 --- a/mysql-test/r/sp-security.result +++ b/mysql-test/r/sp-security.result @@ -592,3 +592,28 @@ ERROR 42000: alter routine command denied to user 'bug57061_user'@'localhost' fo # Connection 'default'. drop user bug57061_user@localhost; drop database mysqltest_db; +# +# Bug#11882603 SELECT_ACL ON ANY COLUMN IN MYSQL.PROC ALLOWS TO SEE +# DEFINITION OF ANY ROUTINE. +# +DROP DATABASE IF EXISTS db1; +CREATE DATABASE db1; +CREATE PROCEDURE db1.p1() SELECT 1; +CREATE USER user2@localhost IDENTIFIED BY ''; +GRANT SELECT(db) ON mysql.proc TO user2@localhost; +# Connection con2 as user2 +# The statement below before disclosed info from body_utf8 column. +SHOW CREATE PROCEDURE db1.p1; +ERROR 42000: PROCEDURE p1 does not exist +# Check that SHOW works with SELECT grant on whole table +# Connection default +GRANT SELECT ON mysql.proc TO user2@localhost; +# Connection con2 +# This should work +SHOW CREATE PROCEDURE db1.p1; +Procedure sql_mode Create Procedure character_set_client collation_connection Database Collation +p1 CREATE DEFINER=`root`@`localhost` PROCEDURE `p1`() +SELECT 1 latin1 latin1_swedish_ci latin1_swedish_ci +# Connection default +DROP USER user2@localhost; +DROP DATABASE db1; diff --git a/mysql-test/r/sp.result b/mysql-test/r/sp.result index 0fcda087f0d..142c154bdac 100644 --- a/mysql-test/r/sp.result +++ b/mysql-test/r/sp.result @@ -7159,6 +7159,40 @@ init_connect SET @@GLOBAL.init_connect= @old_init_connect; DROP PROCEDURE p2; DROP PROCEDURE p5; +# +# Bug#11840395 (formerly known as bug#60347): +# The string "versiondata" seems +# to be 'leaking' into the schema name space +# +DROP DATABASE IF EXISTS mixedCaseDbName; +CREATE DATABASE mixedCaseDbName; +CREATE PROCEDURE mixedCaseDbName.tryMyProc() begin end| +CREATE FUNCTION mixedCaseDbName.tryMyFunc() returns text begin return 'IT WORKS'; end +| +call mixedCaseDbName.tryMyProc(); +select mixedCaseDbName.tryMyFunc(); +mixedCaseDbName.tryMyFunc() +IT WORKS +DROP DATABASE mixedCaseDbName; +# +# Bug#11766594 59736: SELECT DISTINCT.. INCORRECT RESULT WITH DETERMINISTIC FUNCTION IN WHERE C +# +CREATE TABLE t1 (a INT, b INT, KEY(b)); +CREATE TABLE t2 (c INT, d INT, KEY(c)); +INSERT INTO t1 VALUES (1,1),(1,1),(1,2); +INSERT INTO t2 VALUES (1,1),(1,2); +CREATE FUNCTION f1() RETURNS INT DETERMINISTIC +BEGIN +DECLARE a int; +-- SQL statement inside +SELECT 1 INTO a; +RETURN a; +END $ +SELECT COUNT(DISTINCT d) FROM t1, t2 WHERE a = c AND b = f1(); +COUNT(DISTINCT d) +2 +DROP FUNCTION f1; +DROP TABLE t1, t2; # ------------------------------------------------------------------ # -- End of 5.1 tests # ------------------------------------------------------------------ @@ -7498,4 +7532,76 @@ CALL p1(); DROP TABLE t1, t2, t3; DROP PROCEDURE p1; + +# -- +# -- Bug#12652769 - 61470: case operator in stored routine retains old +# -- value of input parameter +# --- +DROP TABLE IF EXISTS t1; +DROP PROCEDURE IF EXISTS p1; +CREATE TABLE t1 (s1 CHAR(5) CHARACTER SET utf8); +INSERT INTO t1 VALUES ('a'); +CREATE PROCEDURE p1(dt DATETIME, i INT) +BEGIN +SELECT +CASE +WHEN i = 1 THEN 2 +ELSE dt +END AS x1; +SELECT +CASE _latin1'a' + WHEN _utf8'a' THEN 'A' + END AS x2; +SELECT +CASE _utf8'a' + WHEN _latin1'a' THEN _utf8'A' + END AS x3; +SELECT +CASE s1 +WHEN _latin1'a' THEN _latin1'b' + ELSE _latin1'c' + END AS x4 +FROM t1; +END| + +CALL p1('2011-04-03 05:14:10', 1); +x1 +2 +x2 +A +x3 +A +x4 +b +CALL p1('2011-04-03 05:14:11', 2); +x1 +2011-04-03 05:14:11 +x2 +A +x3 +A +x4 +b +CALL p1('2011-04-03 05:14:12', 2); +x1 +2011-04-03 05:14:12 +x2 +A +x3 +A +x4 +b +CALL p1('2011-04-03 05:14:13', 2); +x1 +2011-04-03 05:14:13 +x2 +A +x3 +A +x4 +b + +DROP TABLE t1; +DROP PROCEDURE p1; + # End of 5.5 test diff --git a/mysql-test/r/sp_sync.result b/mysql-test/r/sp_sync.result index 174b3c60745..ba90b009ce4 100644 --- a/mysql-test/r/sp_sync.result +++ b/mysql-test/r/sp_sync.result @@ -1,4 +1,4 @@ -Tests of syncronization of stored procedure execution. +Tests of synchronization of stored procedure execution. SET DEBUG_SYNC= 'RESET'; # # Bug #30977 Concurrent statement using stored function and @@ -92,4 +92,16 @@ COUNT(f1(a)) DROP PROCEDURE p1; DROP FUNCTION f1; DROP TABLES t0, t1; -SET DEBUG_SYNC= 'RESET'; +# +# test for bug#11756013 +# +DROP SCHEMA IF EXISTS s1; +CREATE SCHEMA s1; +CREATE PROCEDURE s1.p1() BEGIN END; +SET DEBUG_SYNC='before_db_dir_check SIGNAL check_db WAIT_FOR dropped_schema'; +CALL s1.p1; +SET DEBUG_SYNC='now WAIT_FOR check_db'; +DROP SCHEMA s1; +SET DEBUG_SYNC='now SIGNAL dropped_schema'; +ERROR 42000: Unknown database 's1' +SET DEBUG_SYNC = 'RESET'; diff --git a/mysql-test/r/sp_trans.result b/mysql-test/r/sp_trans.result index 4163725a196..b91dc898f12 100644 --- a/mysql-test/r/sp_trans.result +++ b/mysql-test/r/sp_trans.result @@ -558,6 +558,52 @@ f1 bug13575(f1) 3 ccc drop function bug13575| drop table t3| +SELECT @@GLOBAL.storage_engine INTO @old_engine| +SET @@GLOBAL.storage_engine=InnoDB| +SET @@SESSION.storage_engine=InnoDB| +SHOW GLOBAL VARIABLES LIKE 'storage_engine'| +Variable_name Value +storage_engine InnoDB +SHOW SESSION VARIABLES LIKE 'storage_engine'| +Variable_name Value +storage_engine InnoDB +CREATE PROCEDURE bug11758414() +BEGIN +SET @@GLOBAL.storage_engine="MyISAM"; +SET @@SESSION.storage_engine="MyISAM"; +# show defaults at execution time / that setting them worked +SHOW GLOBAL VARIABLES LIKE 'storage_engine'; +SHOW SESSION VARIABLES LIKE 'storage_engine'; +CREATE TABLE t1 (id int); +CREATE TABLE t2 (id int) ENGINE=InnoDB; +# show we're heeding the default (at run-time, not parse-time!) + SHOW CREATE TABLE t1; + # show that we didn't break explicit override with ENGINE=... +SHOW CREATE TABLE t2; +END; +| +CALL bug11758414| +Variable_name Value +storage_engine MyISAM +Variable_name Value +storage_engine MyISAM +Table Create Table +t1 CREATE TABLE `t1` ( + `id` int(11) DEFAULT NULL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +Table Create Table +t2 CREATE TABLE `t2` ( + `id` int(11) DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=latin1 +SHOW GLOBAL VARIABLES LIKE 'storage_engine'| +Variable_name Value +storage_engine MyISAM +SHOW SESSION VARIABLES LIKE 'storage_engine'| +Variable_name Value +storage_engine MyISAM +DROP PROCEDURE bug11758414| +DROP TABLE t1, t2| +SET @@GLOBAL.storage_engine=@old_engine| # # End of 5.1 tests # diff --git a/mysql-test/r/subselect.result b/mysql-test/r/subselect.result index 713b0fcce2e..82b8e740cdc 100644 --- a/mysql-test/r/subselect.result +++ b/mysql-test/r/subselect.result @@ -2,7 +2,7 @@ drop table if exists t1,t2,t3,t4,t5,t6,t7,t8,t11,t12; drop view if exists v2; set @subselect_tmp=@@optimizer_switch; set @@optimizer_switch=ifnull(@optimizer_switch_for_subselect_test, -"semijoin=on,firstmatch=on,loosescan=on,partial_match_rowid_merge=off,partial_match_table_scan=off"); +"semijoin=on,firstmatch=on,loosescan=on,semijoin_with_cache=on,partial_match_rowid_merge=off,partial_match_table_scan=off"); set optimizer_switch='mrr=on,mrr_sort_keys=on,index_condition_pushdown=on'; select (select 2); (select 2) @@ -55,7 +55,7 @@ id select_type table type possible_keys key key_len ref rows filtered Extra Warnings: Note 1276 Field or reference 'b.a' of SELECT #3 was resolved in SELECT #1 Note 1276 Field or reference 'b.a' of SELECT #3 was resolved in SELECT #1 -Note 1003 select 1 AS `1` from dual having ((select 1) = 1) +Note 1003 select 1 AS `1` from dual having (<expr_cache><1>((select 1)) = 1) SELECT 1 FROM (SELECT 1 as a) as b HAVING (SELECT a)=1; 1 1 @@ -229,7 +229,7 @@ id select_type table type possible_keys key key_len ref rows filtered Extra 3 DEPENDENT SUBQUERY t3 ALL NULL NULL NULL NULL 3 100.00 Using where Warnings: Note 1276 Field or reference 'test.t4.a' of SELECT #3 was resolved in SELECT #1 -Note 1003 select `test`.`t4`.`b` AS `b`,(select avg((`test`.`t2`.`a` + (select min(`test`.`t3`.`a`) from `test`.`t3` where (`test`.`t3`.`a` >= `test`.`t4`.`a`)))) from `test`.`t2`) AS `(select avg(t2.a+(select min(t3.a) from t3 where t3.a >= t4.a)) from t2)` from `test`.`t4` +Note 1003 select `test`.`t4`.`b` AS `b`,<expr_cache><`test`.`t4`.`a`>((select avg((`test`.`t2`.`a` + (select min(`test`.`t3`.`a`) from `test`.`t3` where (`test`.`t3`.`a` >= `test`.`t4`.`a`)))) from `test`.`t2`)) AS `(select avg(t2.a+(select min(t3.a) from t3 where t3.a >= t4.a)) from t2)` from `test`.`t4` select * from t3 where exists (select * from t2 where t2.b=t3.a); a 7 @@ -275,7 +275,7 @@ id select_type table type possible_keys key key_len ref rows filtered Extra 1 PRIMARY t3 ALL NULL NULL NULL NULL 3 100.00 Using where 2 SUBQUERY t2 ALL NULL NULL NULL NULL 3 100.00 Warnings: -Note 1003 select `test`.`t3`.`a` AS `a` from `test`.`t3` where <nop>(<in_optimizer>(`test`.`t3`.`a`,((select min(`test`.`t2`.`b`) from `test`.`t2`) <= `test`.`t3`.`a`))) +Note 1003 select `test`.`t3`.`a` AS `a` from `test`.`t3` where <nop>(<in_optimizer>(`test`.`t3`.`a`,((select min(`test`.`t2`.`b`) from `test`.`t2`) <= <cache>(`test`.`t3`.`a`)))) select * from t3 where a >= all (select b from t2); a 7 @@ -319,7 +319,7 @@ NULL UNION RESULT <union2,3> ALL NULL NULL NULL NULL NULL NULL Warnings: Note 1276 Field or reference 'test.t2.a' of SELECT #2 was resolved in SELECT #1 Note 1276 Field or reference 'test.t2.a' of SELECT #3 was resolved in SELECT #1 -Note 1003 select (select 2 from dual where (2 = `test`.`t2`.`a`) union select `test`.`t5`.`a` from `test`.`t5` where (`test`.`t5`.`a` = `test`.`t2`.`a`)) AS `(select a from t1 where t1.a=t2.a union select a from t5 where t5.a=t2.a)`,`test`.`t2`.`a` AS `a` from `test`.`t2` +Note 1003 select <expr_cache><`test`.`t2`.`a`>((select 2 from dual where (2 = `test`.`t2`.`a`) union select `test`.`t5`.`a` from `test`.`t5` where (`test`.`t5`.`a` = `test`.`t2`.`a`))) AS `(select a from t1 where t1.a=t2.a union select a from t5 where t5.a=t2.a)`,`test`.`t2`.`a` AS `a` from `test`.`t2` select (select a from t1 where t1.a=t2.a union all select a from t5 where t5.a=t2.a), a from t2; ERROR 21000: Subquery returns more than 1 row create table t6 (patient_uq int, clinic_uq int, index i1 (clinic_uq)); @@ -337,7 +337,7 @@ id select_type table type possible_keys key key_len ref rows filtered Extra 2 DEPENDENT SUBQUERY t7 eq_ref PRIMARY PRIMARY 4 test.t6.clinic_uq 1 100.00 Using index Warnings: Note 1276 Field or reference 'test.t6.clinic_uq' of SELECT #2 was resolved in SELECT #1 -Note 1003 select `test`.`t6`.`patient_uq` AS `patient_uq`,`test`.`t6`.`clinic_uq` AS `clinic_uq` from `test`.`t6` where exists(select 1 from `test`.`t7` where (`test`.`t7`.`uq` = `test`.`t6`.`clinic_uq`)) +Note 1003 select `test`.`t6`.`patient_uq` AS `patient_uq`,`test`.`t6`.`clinic_uq` AS `clinic_uq` from `test`.`t6` where <expr_cache><`test`.`t6`.`clinic_uq`>(exists(select 1 from `test`.`t7` where (`test`.`t7`.`uq` = `test`.`t6`.`clinic_uq`))) select * from t1 where a= (select a from t2,t4 where t2.b=t4.b); ERROR 23000: Column 'a' in field list is ambiguous drop table t1,t2,t3; @@ -367,12 +367,12 @@ INSERT INTO t8 (pseudo,email) VALUES ('joce1','test1'); INSERT INTO t8 (pseudo,email) VALUES ('2joce1','2test1'); EXPLAIN EXTENDED SELECT pseudo,(SELECT email FROM t8 WHERE pseudo=(SELECT pseudo FROM t8 WHERE pseudo='joce')) FROM t8 WHERE pseudo=(SELECT pseudo FROM t8 WHERE pseudo='joce'); id select_type table type possible_keys key key_len ref rows filtered Extra -1 PRIMARY t8 const PRIMARY PRIMARY 37 const 1 100.00 Using index +1 PRIMARY t8 const PRIMARY PRIMARY 37 const 1 100.00 Using where; Using index 4 SUBQUERY t8 const PRIMARY PRIMARY 37 const 1 100.00 Using index -2 SUBQUERY t8 const PRIMARY PRIMARY 37 const 1 100.00 +2 SUBQUERY t8 const PRIMARY PRIMARY 37 const 1 100.00 Using where 3 SUBQUERY t8 const PRIMARY PRIMARY 37 const 1 100.00 Using index Warnings: -Note 1003 select 'joce' AS `pseudo`,(select 'test' from `test`.`t8` where ('joce' = (select 'joce' from `test`.`t8` where 1))) AS `(SELECT email FROM t8 WHERE pseudo=(SELECT pseudo FROM t8 WHERE pseudo='joce'))` from `test`.`t8` where ('joce' = (select 'joce' from `test`.`t8` where 1)) +Note 1003 select `test`.`t8`.`pseudo` AS `pseudo`,(select `test`.`t8`.`email` from `test`.`t8` where (`test`.`t8`.`pseudo` = (select 'joce' from `test`.`t8` where 1))) AS `(SELECT email FROM t8 WHERE pseudo=(SELECT pseudo FROM t8 WHERE pseudo='joce'))` from `test`.`t8` where (`test`.`t8`.`pseudo` = (select 'joce' from `test`.`t8` where 1)) SELECT pseudo FROM t8 WHERE pseudo=(SELECT pseudo,email FROM t8 WHERE pseudo='joce'); ERROR 21000: Operand should contain 1 column(s) @@ -543,18 +543,24 @@ SELECT numreponse, (SELECT numeropost FROM t1 HAVING numreponse=1) FROM (SELECT numreponse (SELECT numeropost FROM t1 HAVING numreponse=1) INSERT INTO t1 (numeropost,numreponse,pseudo) VALUES (1,1,'joce'),(1,2,'joce'),(1,3,'test'); EXPLAIN EXTENDED SELECT numreponse FROM t1 WHERE numeropost='1' AND numreponse=(SELECT 1 FROM t1 WHERE numeropost='1'); +id select_type table type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t1 const PRIMARY,numreponse PRIMARY 7 const,const 1 100.00 Using where; Using index +2 SUBQUERY t1 ref PRIMARY PRIMARY 3 const 2 100.00 Using index +Warnings: +Note 1003 select `test`.`t1`.`numreponse` AS `numreponse` from `test`.`t1` where ((`test`.`t1`.`numeropost` = '1') and (`test`.`t1`.`numreponse` = (select 1 from `test`.`t1` where (`test`.`t1`.`numeropost` = '1')))) +SELECT numreponse FROM t1 WHERE numeropost='1' AND numreponse=(SELECT 1 FROM t1 WHERE numeropost='1'); ERROR 21000: Subquery returns more than 1 row EXPLAIN EXTENDED SELECT MAX(numreponse) FROM t1 WHERE numeropost='1'; id select_type table type possible_keys key key_len ref rows filtered Extra 1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL Select tables optimized away Warnings: -Note 1003 select max(`test`.`t1`.`numreponse`) AS `MAX(numreponse)` from `test`.`t1` where multiple equal(1, `test`.`t1`.`numeropost`) +Note 1003 select max(`test`.`t1`.`numreponse`) AS `MAX(numreponse)` from `test`.`t1` where (`test`.`t1`.`numeropost` = '1') EXPLAIN EXTENDED SELECT numreponse FROM t1 WHERE numeropost='1' AND numreponse=(SELECT MAX(numreponse) FROM t1 WHERE numeropost='1'); id select_type table type possible_keys key key_len ref rows filtered Extra -1 PRIMARY t1 const PRIMARY,numreponse PRIMARY 7 const,const 1 100.00 Using index +1 PRIMARY t1 const PRIMARY,numreponse PRIMARY 7 const,const 1 100.00 Using where; Using index 2 SUBQUERY NULL NULL NULL NULL NULL NULL NULL NULL Select tables optimized away Warnings: -Note 1003 select 3 AS `numreponse` from `test`.`t1` where ((3 = (select max(`test`.`t1`.`numreponse`) from `test`.`t1` where multiple equal(1, `test`.`t1`.`numeropost`)))) +Note 1003 select `test`.`t1`.`numreponse` AS `numreponse` from `test`.`t1` where ((`test`.`t1`.`numeropost` = '1') and (`test`.`t1`.`numreponse` = (select max(`test`.`t1`.`numreponse`) from `test`.`t1` where (`test`.`t1`.`numeropost` = '1')))) drop table t1; CREATE TABLE t1 (a int(1)); INSERT INTO t1 VALUES (1); @@ -751,7 +757,7 @@ id select_type table type possible_keys key key_len ref rows filtered Extra 3 DEPENDENT UNION NULL NULL NULL NULL NULL NULL NULL NULL No tables used NULL UNION RESULT <union2,3> ALL NULL NULL NULL NULL NULL NULL Warnings: -Note 1003 select `test`.`t2`.`id` AS `id` from `test`.`t2` where <in_optimizer>(`test`.`t2`.`id`,<exists>(select 1 having (<cache>(`test`.`t2`.`id`) = <ref_null_helper>(1)) union select 3 having (<cache>(`test`.`t2`.`id`) = <ref_null_helper>(3)))) +Note 1003 select `test`.`t2`.`id` AS `id` from `test`.`t2` where <expr_cache><`test`.`t2`.`id`>(<in_optimizer>(`test`.`t2`.`id`,<exists>(select 1 having (<cache>(`test`.`t2`.`id`) = <ref_null_helper>(1)) union select 3 having (<cache>(`test`.`t2`.`id`) = <ref_null_helper>(3))))) SELECT * FROM t2 WHERE id IN (SELECT 5 UNION SELECT 3); id SELECT * FROM t2 WHERE id IN (SELECT 5 UNION SELECT 2); @@ -899,7 +905,7 @@ id select_type table type possible_keys key key_len ref rows filtered Extra 1 PRIMARY t1 index NULL PRIMARY 4 NULL 4 100.00 Using index 2 DEPENDENT SUBQUERY t2 index_subquery a a 5 func 2 100.00 Using index Warnings: -Note 1003 select `test`.`t1`.`a` AS `a`,<in_optimizer>(`test`.`t1`.`a`,<exists>(<index_lookup>(<cache>(`test`.`t1`.`a`) in t2 on a checking NULL having <is_not_null_test>(`test`.`t2`.`a`)))) AS `t1.a in (select t2.a from t2)` from `test`.`t1` +Note 1003 select `test`.`t1`.`a` AS `a`,<expr_cache><`test`.`t1`.`a`>(<in_optimizer>(`test`.`t1`.`a`,<exists>(<index_lookup>(<cache>(`test`.`t1`.`a`) in t2 on a checking NULL having <is_not_null_test>(`test`.`t2`.`a`))))) AS `t1.a in (select t2.a from t2)` from `test`.`t1` CREATE TABLE t3 (a int(11) default '0'); INSERT INTO t3 VALUES (1),(2),(3); SELECT t1.a, t1.a in (select t2.a from t2,t3 where t3.a=t2.a) FROM t1; @@ -914,8 +920,133 @@ id select_type table type possible_keys key key_len ref rows filtered Extra 2 DEPENDENT SUBQUERY t2 ref_or_null a a 5 func 2 100.00 Using where; Using index 2 DEPENDENT SUBQUERY t3 ALL NULL NULL NULL NULL 3 100.00 Using where; Using join buffer (flat, BNL join) Warnings: -Note 1003 select `test`.`t1`.`a` AS `a`,<in_optimizer>(`test`.`t1`.`a`,<exists>(select `test`.`t2`.`a` from `test`.`t2` join `test`.`t3` where ((`test`.`t3`.`a` = `test`.`t2`.`a`) and ((<cache>(`test`.`t1`.`a`) = `test`.`t2`.`a`) or isnull(`test`.`t2`.`a`))) having <is_not_null_test>(`test`.`t2`.`a`))) AS `t1.a in (select t2.a from t2,t3 where t3.a=t2.a)` from `test`.`t1` +Note 1003 select `test`.`t1`.`a` AS `a`,<expr_cache><`test`.`t1`.`a`>(<in_optimizer>(`test`.`t1`.`a`,<exists>(select `test`.`t2`.`a` from `test`.`t2` join `test`.`t3` where ((`test`.`t3`.`a` = `test`.`t2`.`a`) and ((<cache>(`test`.`t1`.`a`) = `test`.`t2`.`a`) or isnull(`test`.`t2`.`a`))) having <is_not_null_test>(`test`.`t2`.`a`)))) AS `t1.a in (select t2.a from t2,t3 where t3.a=t2.a)` from `test`.`t1` drop table t1,t2,t3; +# check correct NULL Processing for normal IN/ALL/ANY +# and 2 ways of max/min optimization +create table t1 (a int); +insert into t1 values (1), (100), (NULL), (1000); +create table t2 (a int not null); +# subselect returns empty set (for NULL and non-NULL left part) +select a, a in (select * from t2) from t1; +a a in (select * from t2) +1 0 +100 0 +NULL 0 +1000 0 +select a, a > any (select * from t2) from t1; +a a > any (select * from t2) +1 0 +100 0 +NULL 0 +1000 0 +select a, a > all (select * from t2) from t1; +a a > all (select * from t2) +1 1 +100 1 +NULL 1 +1000 1 +select a from t1 where a in (select * from t2); +a +select a from t1 where a > any (select * from t2); +a +select a from t1 where a > all (select * from t2); +a +1 +100 +NULL +1000 +select a from t1 where a in (select * from t2 group by a); +a +select a from t1 where a > any (select * from t2 group by a); +a +select a from t1 where a > all (select * from t2 group by a); +a +1 +100 +NULL +1000 +insert into t2 values (1),(200); +# sebselect returns non-empty set without NULLs +select a, a in (select * from t2) from t1; +a a in (select * from t2) +1 1 +100 0 +NULL NULL +1000 0 +select a, a > any (select * from t2) from t1; +a a > any (select * from t2) +1 0 +100 1 +NULL NULL +1000 1 +select a, a > all (select * from t2) from t1; +a a > all (select * from t2) +1 0 +100 0 +NULL NULL +1000 1 +select a from t1 where a in (select * from t2); +a +1 +select a from t1 where a > any (select * from t2); +a +100 +1000 +select a from t1 where a > all (select * from t2); +a +1000 +select a from t1 where a in (select * from t2 group by a); +a +1 +select a from t1 where a > any (select * from t2 group by a); +a +100 +1000 +select a from t1 where a > all (select * from t2 group by a); +a +1000 +drop table t2; +create table t2 (a int); +insert into t2 values (1),(NULL),(200); +# sebselect returns non-empty set with NULLs +select a, a in (select * from t2) from t1; +a a in (select * from t2) +1 1 +100 NULL +NULL NULL +1000 NULL +select a, a > any (select * from t2) from t1; +a a > any (select * from t2) +1 NULL +100 1 +NULL NULL +1000 1 +select a, a > all (select * from t2) from t1; +a a > all (select * from t2) +1 0 +100 0 +NULL NULL +1000 NULL +select a from t1 where a in (select * from t2); +a +1 +select a from t1 where a > any (select * from t2); +a +100 +1000 +select a from t1 where a > all (select * from t2); +a +select a from t1 where a in (select * from t2 group by a); +a +1 +select a from t1 where a > any (select * from t2 group by a); +a +100 +1000 +select a from t1 where a > all (select * from t2 group by a); +a +drop table t1, t2; create table t1 (a float); select 10.5 IN (SELECT * from t1 LIMIT 1); ERROR 42000: This version of MySQL doesn't yet support 'LIMIT & IN/ALL/ANY/SOME subquery' @@ -1475,27 +1606,27 @@ id select_type table type possible_keys key key_len ref rows filtered Extra 1 PRIMARY t1 index NULL s1 6 NULL 3 100.00 Using index 2 DEPENDENT SUBQUERY t2 index_subquery s1 s1 6 func 2 100.00 Using index; Full scan on NULL key Warnings: -Note 1003 select `test`.`t1`.`s1` AS `s1`,(not(<in_optimizer>(`test`.`t1`.`s1`,<exists>(<index_lookup>(<cache>(`test`.`t1`.`s1`) in t2 on s1 checking NULL having trigcond(<is_not_null_test>(`test`.`t2`.`s1`))))))) AS `s1 NOT IN (SELECT s1 FROM t2)` from `test`.`t1` +Note 1003 select `test`.`t1`.`s1` AS `s1`,(not(<expr_cache><`test`.`t1`.`s1`>(<in_optimizer>(`test`.`t1`.`s1`,<exists>(<index_lookup>(<cache>(`test`.`t1`.`s1`) in t2 on s1 checking NULL having trigcond(<is_not_null_test>(`test`.`t2`.`s1`)))))))) AS `s1 NOT IN (SELECT s1 FROM t2)` from `test`.`t1` explain extended select s1, s1 = ANY (SELECT s1 FROM t2) from t1; id select_type table type possible_keys key key_len ref rows filtered Extra 1 PRIMARY t1 index NULL s1 6 NULL 3 100.00 Using index 2 DEPENDENT SUBQUERY t2 index_subquery s1 s1 6 func 2 100.00 Using index; Full scan on NULL key Warnings: -Note 1003 select `test`.`t1`.`s1` AS `s1`,<in_optimizer>(`test`.`t1`.`s1`,<exists>(<index_lookup>(<cache>(`test`.`t1`.`s1`) in t2 on s1 checking NULL having trigcond(<is_not_null_test>(`test`.`t2`.`s1`))))) AS `s1 = ANY (SELECT s1 FROM t2)` from `test`.`t1` +Note 1003 select `test`.`t1`.`s1` AS `s1`,<expr_cache><`test`.`t1`.`s1`>(<in_optimizer>(`test`.`t1`.`s1`,<exists>(<index_lookup>(<cache>(`test`.`t1`.`s1`) in t2 on s1 checking NULL having trigcond(<is_not_null_test>(`test`.`t2`.`s1`)))))) AS `s1 = ANY (SELECT s1 FROM t2)` from `test`.`t1` explain extended select s1, s1 <> ALL (SELECT s1 FROM t2) from t1; id select_type table type possible_keys key key_len ref rows filtered Extra 1 PRIMARY t1 index NULL s1 6 NULL 3 100.00 Using index 2 DEPENDENT SUBQUERY t2 index_subquery s1 s1 6 func 2 100.00 Using index; Full scan on NULL key Warnings: -Note 1003 select `test`.`t1`.`s1` AS `s1`,(not(<in_optimizer>(`test`.`t1`.`s1`,<exists>(<index_lookup>(<cache>(`test`.`t1`.`s1`) in t2 on s1 checking NULL having trigcond(<is_not_null_test>(`test`.`t2`.`s1`))))))) AS `s1 <> ALL (SELECT s1 FROM t2)` from `test`.`t1` +Note 1003 select `test`.`t1`.`s1` AS `s1`,(not(<expr_cache><`test`.`t1`.`s1`>(<in_optimizer>(`test`.`t1`.`s1`,<exists>(<index_lookup>(<cache>(`test`.`t1`.`s1`) in t2 on s1 checking NULL having trigcond(<is_not_null_test>(`test`.`t2`.`s1`)))))))) AS `s1 <> ALL (SELECT s1 FROM t2)` from `test`.`t1` explain extended select s1, s1 NOT IN (SELECT s1 FROM t2 WHERE s1 < 'a2') from t1; id select_type table type possible_keys key key_len ref rows filtered Extra 1 PRIMARY t1 index NULL s1 6 NULL 3 100.00 Using index 2 DEPENDENT SUBQUERY t2 index_subquery s1 s1 6 func 2 100.00 Using index; Using where; Full scan on NULL key Warnings: -Note 1003 select `test`.`t1`.`s1` AS `s1`,(not(<in_optimizer>(`test`.`t1`.`s1`,<exists>(<index_lookup>(<cache>(`test`.`t1`.`s1`) in t2 on s1 checking NULL where (`test`.`t2`.`s1` < 'a2') having trigcond(<is_not_null_test>(`test`.`t2`.`s1`))))))) AS `s1 NOT IN (SELECT s1 FROM t2 WHERE s1 < 'a2')` from `test`.`t1` +Note 1003 select `test`.`t1`.`s1` AS `s1`,(not(<expr_cache><`test`.`t1`.`s1`>(<in_optimizer>(`test`.`t1`.`s1`,<exists>(<index_lookup>(<cache>(`test`.`t1`.`s1`) in t2 on s1 checking NULL where (`test`.`t2`.`s1` < 'a2') having trigcond(<is_not_null_test>(`test`.`t2`.`s1`)))))))) AS `s1 NOT IN (SELECT s1 FROM t2 WHERE s1 < 'a2')` from `test`.`t1` drop table t1,t2; -create table t2 (a int, b int); +create table t2 (a int, b int not null); create table t3 (a int); insert into t3 values (6),(7),(3); select * from t3 where a >= all (select b from t2); @@ -1508,7 +1639,7 @@ id select_type table type possible_keys key key_len ref rows filtered Extra 1 PRIMARY t3 ALL NULL NULL NULL NULL 3 100.00 Using where 2 SUBQUERY t2 system NULL NULL NULL NULL 0 0.00 const row not found Warnings: -Note 1003 select `test`.`t3`.`a` AS `a` from `test`.`t3` where <not>(<in_optimizer>(`test`.`t3`.`a`,((select max(NULL) from `test`.`t2`) > `test`.`t3`.`a`))) +Note 1003 select `test`.`t3`.`a` AS `a` from `test`.`t3` where <not>(<in_optimizer>(`test`.`t3`.`a`,((select max(NULL) from `test`.`t2`) > <cache>(`test`.`t3`.`a`)))) select * from t3 where a >= some (select b from t2); a explain extended select * from t3 where a >= some (select b from t2); @@ -1516,7 +1647,7 @@ id select_type table type possible_keys key key_len ref rows filtered Extra 1 PRIMARY t3 ALL NULL NULL NULL NULL 3 100.00 Using where 2 SUBQUERY t2 system NULL NULL NULL NULL 0 0.00 const row not found Warnings: -Note 1003 select `test`.`t3`.`a` AS `a` from `test`.`t3` where <nop>(<in_optimizer>(`test`.`t3`.`a`,((select min(NULL) from `test`.`t2`) <= `test`.`t3`.`a`))) +Note 1003 select `test`.`t3`.`a` AS `a` from `test`.`t3` where <nop>(<in_optimizer>(`test`.`t3`.`a`,((select min(NULL) from `test`.`t2`) <= <cache>(`test`.`t3`.`a`)))) select * from t3 where a >= all (select b from t2 group by 1); a 6 @@ -1527,7 +1658,7 @@ id select_type table type possible_keys key key_len ref rows filtered Extra 1 PRIMARY t3 ALL NULL NULL NULL NULL 3 100.00 Using where 2 SUBQUERY t2 system NULL NULL NULL NULL 0 0.00 const row not found Warnings: -Note 1003 select `test`.`t3`.`a` AS `a` from `test`.`t3` where <not>(<in_optimizer>(`test`.`t3`.`a`,(<max>(select NULL from `test`.`t2` group by 1) > `test`.`t3`.`a`))) +Note 1003 select `test`.`t3`.`a` AS `a` from `test`.`t3` where <not>(<in_optimizer>(`test`.`t3`.`a`,(<max>(select NULL from `test`.`t2` group by 1) > <cache>(`test`.`t3`.`a`)))) select * from t3 where a >= some (select b from t2 group by 1); a explain extended select * from t3 where a >= some (select b from t2 group by 1); @@ -1535,7 +1666,7 @@ id select_type table type possible_keys key key_len ref rows filtered Extra 1 PRIMARY t3 ALL NULL NULL NULL NULL 3 100.00 Using where 2 SUBQUERY t2 system NULL NULL NULL NULL 0 0.00 const row not found Warnings: -Note 1003 select `test`.`t3`.`a` AS `a` from `test`.`t3` where <nop>(<in_optimizer>(`test`.`t3`.`a`,(<min>(select NULL from `test`.`t2` group by 1) <= `test`.`t3`.`a`))) +Note 1003 select `test`.`t3`.`a` AS `a` from `test`.`t3` where <nop>(<in_optimizer>(`test`.`t3`.`a`,(<min>(select NULL from `test`.`t2` group by 1) <= <cache>(`test`.`t3`.`a`)))) select * from t3 where NULL >= any (select b from t2); a explain extended select * from t3 where NULL >= any (select b from t2); @@ -1578,7 +1709,7 @@ id select_type table type possible_keys key key_len ref rows filtered Extra 1 PRIMARY t3 ALL NULL NULL NULL NULL 3 100.00 Using where 2 SUBQUERY t2 ALL NULL NULL NULL NULL 4 100.00 Using temporary Warnings: -Note 1003 select `test`.`t3`.`a` AS `a` from `test`.`t3` where <not>(<in_optimizer>(`test`.`t3`.`a`,(<max>(select max(`test`.`t2`.`b`) from `test`.`t2` group by `test`.`t2`.`a`) >= `test`.`t3`.`a`))) +Note 1003 select `test`.`t3`.`a` AS `a` from `test`.`t3` where <not>(<in_optimizer>(`test`.`t3`.`a`,(<max>(select max(`test`.`t2`.`b`) from `test`.`t2` group by `test`.`t2`.`a`) >= <cache>(`test`.`t3`.`a`)))) drop table t2, t3; CREATE TABLE `t1` ( `id` mediumint(9) NOT NULL auto_increment, `taskid` bigint(20) NOT NULL default '0', `dbid` int(11) NOT NULL default '0', `create_date` datetime NOT NULL default '0000-00-00 00:00:00', `last_update` datetime NOT NULL default '0000-00-00 00:00:00', PRIMARY KEY (`id`)) ENGINE=MyISAM CHARSET=latin1 AUTO_INCREMENT=3 ; INSERT INTO `t1` (`id`, `taskid`, `dbid`, `create_date`,`last_update`) VALUES (1, 1, 15, '2003-09-29 10:31:36', '2003-09-29 10:31:36'), (2, 1, 21, now(), now()); @@ -1748,14 +1879,14 @@ id select_type table type possible_keys key key_len ref rows filtered Extra 1 PRIMARY t1 ALL NULL NULL NULL NULL 12 100.00 Using where 2 DEPENDENT SUBQUERY t1 unique_subquery PRIMARY PRIMARY 4 func 1 100.00 Using index; Using where Warnings: -Note 1003 select `test`.`t1`.`id` AS `id`,`test`.`t1`.`text` AS `text` from `test`.`t1` where (not(<in_optimizer>(`test`.`t1`.`id`,<exists>(<primary_index_lookup>(<cache>(`test`.`t1`.`id`) in t1 on PRIMARY where ((`test`.`t1`.`id` < 8) and (<cache>(`test`.`t1`.`id`) = `test`.`t1`.`id`))))))) +Note 1003 select `test`.`t1`.`id` AS `id`,`test`.`t1`.`text` AS `text` from `test`.`t1` where (not(<expr_cache><`test`.`t1`.`id`>(<in_optimizer>(`test`.`t1`.`id`,<exists>(<primary_index_lookup>(<cache>(`test`.`t1`.`id`) in t1 on PRIMARY where ((`test`.`t1`.`id` < 8) and (<cache>(`test`.`t1`.`id`) = `test`.`t1`.`id`)))))))) explain extended select * from t1 as tt where not exists (select id from t1 where id < 8 and (id = tt.id or id is null) having id is not null); id select_type table type possible_keys key key_len ref rows filtered Extra 1 PRIMARY tt ALL NULL NULL NULL NULL 12 100.00 Using where 2 DEPENDENT SUBQUERY t1 eq_ref PRIMARY PRIMARY 4 test.tt.id 1 100.00 Using where; Using index Warnings: Note 1276 Field or reference 'test.tt.id' of SELECT #2 was resolved in SELECT #1 -Note 1003 select `test`.`tt`.`id` AS `id`,`test`.`tt`.`text` AS `text` from `test`.`t1` `tt` where (not(exists(select `test`.`t1`.`id` from `test`.`t1` where ((`test`.`t1`.`id` < 8) and (`test`.`t1`.`id` = `test`.`tt`.`id`)) having (`test`.`t1`.`id` is not null)))) +Note 1003 select `test`.`tt`.`id` AS `id`,`test`.`tt`.`text` AS `text` from `test`.`t1` `tt` where (not(<expr_cache><`test`.`tt`.`id`>(exists(select `test`.`t1`.`id` from `test`.`t1` where ((`test`.`t1`.`id` < 8) and (`test`.`t1`.`id` = `test`.`tt`.`id`)) having (`test`.`t1`.`id` is not null))))) insert into t1 (id, text) values (1000, 'text1000'), (1001, 'text1001'); create table t2 (id int not null, text varchar(20) not null default '', primary key (id)); insert into t2 (id, text) values (1, 'text1'), (2, 'text2'), (3, 'text3'), (4, 'text4'), (5, 'text5'), (6, 'text6'), (7, 'text7'), (8, 'text8'), (9, 'text9'), (10, 'text10'), (11, 'text1'), (12, 'text2'), (13, 'text3'), (14, 'text4'), (15, 'text5'), (16, 'text6'), (17, 'text7'), (18, 'text8'), (19, 'text9'), (20, 'text10'),(21, 'text1'), (22, 'text2'), (23, 'text3'), (24, 'text4'), (25, 'text5'), (26, 'text6'), (27, 'text7'), (28, 'text8'), (29, 'text9'), (30, 'text10'), (31, 'text1'), (32, 'text2'), (33, 'text3'), (34, 'text4'), (35, 'text5'), (36, 'text6'), (37, 'text7'), (38, 'text8'), (39, 'text9'), (40, 'text10'), (41, 'text1'), (42, 'text2'), (43, 'text3'), (44, 'text4'), (45, 'text5'), (46, 'text6'), (47, 'text7'), (48, 'text8'), (49, 'text9'), (50, 'text10'); @@ -2291,7 +2422,7 @@ id select_type table type possible_keys key key_len ref rows filtered Extra 2 DEPENDENT SUBQUERY t1 ALL NULL NULL NULL NULL 2 100.00 Using where Warnings: Note 1276 Field or reference 'test.up.a' of SELECT #2 was resolved in SELECT #1 -Note 1003 select `test`.`up`.`a` AS `a`,`test`.`up`.`b` AS `b` from `test`.`t1` `up` where exists(select 1 from `test`.`t1` where (`test`.`t1`.`a` = `test`.`up`.`a`)) +Note 1003 select `test`.`up`.`a` AS `a`,`test`.`up`.`b` AS `b` from `test`.`t1` `up` where <expr_cache><`test`.`up`.`a`>(exists(select 1 from `test`.`t1` where (`test`.`t1`.`a` = `test`.`up`.`a`))) drop table t1; CREATE TABLE t1 (t1_a int); INSERT INTO t1 VALUES (1); @@ -2762,6 +2893,8 @@ select * from (select max(fld) from t1) as foo; max(fld) 1 drop table t1; +set @tmp11867_optimizer_switch=@@optimizer_switch; +set optimizer_switch='semijoin_with_cache=off'; CREATE TABLE t1 (one int, two int, flag char(1)); CREATE TABLE t2 (one int, two int, flag char(1)); INSERT INTO t1 VALUES(1,2,'Y'),(2,3,'Y'),(3,4,'Y'),(5,6,'N'),(7,8,'N'); @@ -2832,7 +2965,7 @@ id select_type table type possible_keys key key_len ref rows filtered Extra 1 PRIMARY t1 ALL NULL NULL NULL NULL 8 100.00 2 DEPENDENT SUBQUERY t2 ALL NULL NULL NULL NULL 9 100.00 Using where Warnings: -Note 1003 select `test`.`t1`.`one` AS `one`,`test`.`t1`.`two` AS `two`,<in_optimizer>((`test`.`t1`.`one`,`test`.`t1`.`two`),<exists>(select `test`.`t2`.`one`,`test`.`t2`.`two` from `test`.`t2` where ((`test`.`t2`.`flag` = '0') and trigcond(((<cache>(`test`.`t1`.`one`) = `test`.`t2`.`one`) or isnull(`test`.`t2`.`one`))) and trigcond(((<cache>(`test`.`t1`.`two`) = `test`.`t2`.`two`) or isnull(`test`.`t2`.`two`)))) having (trigcond(<is_not_null_test>(`test`.`t2`.`one`)) and trigcond(<is_not_null_test>(`test`.`t2`.`two`))))) AS `test` from `test`.`t1` +Note 1003 select `test`.`t1`.`one` AS `one`,`test`.`t1`.`two` AS `two`,<expr_cache><`test`.`t1`.`one`,`test`.`t1`.`two`>(<in_optimizer>((`test`.`t1`.`one`,`test`.`t1`.`two`),<exists>(select `test`.`t2`.`one`,`test`.`t2`.`two` from `test`.`t2` where ((`test`.`t2`.`flag` = '0') and trigcond(((<cache>(`test`.`t1`.`one`) = `test`.`t2`.`one`) or isnull(`test`.`t2`.`one`))) and trigcond(((<cache>(`test`.`t1`.`two`) = `test`.`t2`.`two`) or isnull(`test`.`t2`.`two`)))) having (trigcond(<is_not_null_test>(`test`.`t2`.`one`)) and trigcond(<is_not_null_test>(`test`.`t2`.`two`)))))) AS `test` from `test`.`t1` explain extended SELECT one,two from t1 where ROW(one,two) IN (SELECT one,two FROM t2 WHERE flag = 'N'); id select_type table type possible_keys key key_len ref rows filtered Extra 1 PRIMARY t1 ALL NULL NULL NULL NULL 8 100.00 @@ -2844,8 +2977,9 @@ id select_type table type possible_keys key key_len ref rows filtered Extra 1 PRIMARY t1 ALL NULL NULL NULL NULL 8 100.00 2 DEPENDENT SUBQUERY t2 ALL NULL NULL NULL NULL 9 100.00 Using where; Using temporary Warnings: -Note 1003 select `test`.`t1`.`one` AS `one`,`test`.`t1`.`two` AS `two`,<in_optimizer>((`test`.`t1`.`one`,`test`.`t1`.`two`),<exists>(select `test`.`t2`.`one`,`test`.`t2`.`two` from `test`.`t2` where (`test`.`t2`.`flag` = '0') group by `test`.`t2`.`one`,`test`.`t2`.`two` having (trigcond(((<cache>(`test`.`t1`.`one`) = `test`.`t2`.`one`) or isnull(`test`.`t2`.`one`))) and trigcond(((<cache>(`test`.`t1`.`two`) = `test`.`t2`.`two`) or isnull(`test`.`t2`.`two`))) and trigcond(<is_not_null_test>(`test`.`t2`.`one`)) and trigcond(<is_not_null_test>(`test`.`t2`.`two`))))) AS `test` from `test`.`t1` +Note 1003 select `test`.`t1`.`one` AS `one`,`test`.`t1`.`two` AS `two`,<expr_cache><`test`.`t1`.`one`,`test`.`t1`.`two`>(<in_optimizer>((`test`.`t1`.`one`,`test`.`t1`.`two`),<exists>(select `test`.`t2`.`one`,`test`.`t2`.`two` from `test`.`t2` where (`test`.`t2`.`flag` = '0') group by `test`.`t2`.`one`,`test`.`t2`.`two` having (trigcond(((<cache>(`test`.`t1`.`one`) = `test`.`t2`.`one`) or isnull(`test`.`t2`.`one`))) and trigcond(((<cache>(`test`.`t1`.`two`) = `test`.`t2`.`two`) or isnull(`test`.`t2`.`two`))) and trigcond(<is_not_null_test>(`test`.`t2`.`one`)) and trigcond(<is_not_null_test>(`test`.`t2`.`two`)))))) AS `test` from `test`.`t1` DROP TABLE t1,t2; +set optimizer_switch=@tmp11867_optimizer_switch; CREATE TABLE t1 (a char(5), b char(5)); INSERT INTO t1 VALUES (NULL,'aaa'), ('aaa','aaa'); SELECT * FROM t1 WHERE (a,b) IN (('aaa','aaa'), ('aaa','bbb')); @@ -4290,7 +4424,7 @@ id select_type table type possible_keys key key_len ref rows filtered Extra 2 DEPENDENT SUBQUERY t2 ALL NULL NULL NULL NULL 2 100.00 Using where Warnings: Note 1276 Field or reference 'test.t1.a' of SELECT #2 was resolved in SELECT #1 -Note 1003 select 2 AS `2` from `test`.`t1` where exists(select 1 from `test`.`t2` where (`test`.`t1`.`a` = `test`.`t2`.`a`)) +Note 1003 select 2 AS `2` from `test`.`t1` where <expr_cache><`test`.`t1`.`a`>(exists(select 1 from `test`.`t2` where (`test`.`t1`.`a` = `test`.`t2`.`a`))) EXPLAIN EXTENDED SELECT 2 FROM t1 WHERE EXISTS ((SELECT 1 FROM t2 WHERE t1.a=t2.a) UNION (SELECT 1 FROM t2 WHERE t1.a = t2.a)); @@ -4302,7 +4436,7 @@ NULL UNION RESULT <union2,3> ALL NULL NULL NULL NULL NULL NULL Warnings: Note 1276 Field or reference 'test.t1.a' of SELECT #2 was resolved in SELECT #1 Note 1276 Field or reference 'test.t1.a' of SELECT #3 was resolved in SELECT #1 -Note 1003 select 2 AS `2` from `test`.`t1` where exists((select 1 from `test`.`t2` where (`test`.`t1`.`a` = `test`.`t2`.`a`)) union (select 1 from `test`.`t2` where (`test`.`t1`.`a` = `test`.`t2`.`a`))) +Note 1003 select 2 AS `2` from `test`.`t1` where <expr_cache><`test`.`t1`.`a`>(exists((select 1 from `test`.`t2` where (`test`.`t1`.`a` = `test`.`t2`.`a`)) union (select 1 from `test`.`t2` where (`test`.`t1`.`a` = `test`.`t2`.`a`)))) DROP TABLE t1,t2; create table t0(a int); insert into t0 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9); @@ -4380,13 +4514,13 @@ id select_type table type possible_keys key key_len ref rows filtered Extra 1 PRIMARY t1 ALL NULL NULL NULL NULL 2 100.00 2 DEPENDENT SUBQUERY t1 ALL NULL NULL NULL NULL 2 100.00 Using temporary Warnings: -Note 1003 select 1 AS `1` from `test`.`t1` where <in_optimizer>(1,<exists>(select 1 from `test`.`t1` group by `test`.`t1`.`a` having (1 = <ref_null_helper>(1)))) +Note 1003 select 1 AS `1` from `test`.`t1` where <expr_cache><1>(<in_optimizer>(1,<exists>(select 1 from `test`.`t1` group by `test`.`t1`.`a` having (1 = <ref_null_helper>(1))))) EXPLAIN EXTENDED SELECT 1 FROM t1 WHERE 1 IN (SELECT 1 FROM t1 WHERE a > 3 GROUP BY a); id select_type table type possible_keys key key_len ref rows filtered Extra 1 PRIMARY t1 ALL NULL NULL NULL NULL 2 100.00 2 DEPENDENT SUBQUERY t1 ALL NULL NULL NULL NULL 2 100.00 Using where; Using temporary Warnings: -Note 1003 select 1 AS `1` from `test`.`t1` where <in_optimizer>(1,<exists>(select 1 from `test`.`t1` where (`test`.`t1`.`a` > 3) group by `test`.`t1`.`a` having (1 = <ref_null_helper>(1)))) +Note 1003 select 1 AS `1` from `test`.`t1` where <expr_cache><1>(<in_optimizer>(1,<exists>(select 1 from `test`.`t1` where (`test`.`t1`.`a` > 3) group by `test`.`t1`.`a` having (1 = <ref_null_helper>(1))))) DROP TABLE t1; # # Bug#45061: Incorrectly market field caused wrong result. @@ -5506,6 +5640,167 @@ SELECT 1 as foo FROM t1 WHERE a < SOME ); foo DROP TABLE t1; +CREATE TABLE t1 (a int(11), b varchar(1)); +INSERT INTO t1 VALUES (2,NULL),(5,'d'),(7,'g'); +SELECT a FROM t1 WHERE b < ANY ( SELECT b FROM t1 GROUP BY b ); +a +5 +SELECT a FROM t1 WHERE b < ANY ( SELECT b FROM t1 ); +a +5 +SELECT a FROM t1 WHERE b > ANY ( SELECT b FROM t1 GROUP BY b ); +a +7 +SELECT a FROM t1 WHERE b > ANY ( SELECT b FROM t1 ); +a +7 +SELECT a FROM t1 WHERE b <= ANY ( SELECT b FROM t1 GROUP BY b ); +a +5 +7 +SELECT a FROM t1 WHERE b <= ANY ( SELECT b FROM t1 ); +a +5 +7 +SELECT a FROM t1 WHERE b >= ANY ( SELECT b FROM t1 GROUP BY b ); +a +5 +7 +SELECT a FROM t1 WHERE b >= ANY ( SELECT b FROM t1 ); +a +5 +7 +SELECT a FROM t1 WHERE b = ANY ( SELECT b FROM t1 ); +a +5 +7 +SELECT a FROM t1 WHERE b = ANY ( SELECT b FROM t1 GROUP BY b ); +a +5 +7 +SELECT a FROM t1 WHERE b <> ANY ( SELECT b FROM t1 ); +a +5 +7 +SELECT a FROM t1 WHERE b <> ANY ( SELECT b FROM t1 GROUP BY b ); +a +5 +7 +SELECT a FROM t1 WHERE b < ALL ( SELECT b FROM t1 GROUP BY b ); +a +SELECT a FROM t1 WHERE b < ALL ( SELECT b FROM t1 ); +a +SELECT a FROM t1 WHERE b > ALL ( SELECT b FROM t1 GROUP BY b ); +a +SELECT a FROM t1 WHERE b > ALL ( SELECT b FROM t1 ); +a +SELECT a FROM t1 WHERE b <= ALL ( SELECT b FROM t1 GROUP BY b ); +a +SELECT a FROM t1 WHERE b <= ALL ( SELECT b FROM t1 ); +a +SELECT a FROM t1 WHERE b >= ALL ( SELECT b FROM t1 GROUP BY b ); +a +SELECT a FROM t1 WHERE b >= ALL ( SELECT b FROM t1 ); +a +SELECT a FROM t1 WHERE b = ALL ( SELECT b FROM t1 ); +a +SELECT a FROM t1 WHERE b = ALL ( SELECT b FROM t1 GROUP BY b ); +a +SELECT a FROM t1 WHERE b <> ALL ( SELECT b FROM t1 ); +a +SELECT a FROM t1 WHERE b <> ALL ( SELECT b FROM t1 GROUP BY b ); +a +delete from t1; +INSERT INTO t1 VALUES (2,NULL),(5,'d'),(7,'g'); +SELECT a FROM t1 WHERE b < ANY ( SELECT b FROM t1 GROUP BY b ); +a +5 +SELECT a FROM t1 WHERE b < ANY ( SELECT b FROM t1 ); +a +5 +SELECT a FROM t1 WHERE b > ANY ( SELECT b FROM t1 GROUP BY b ); +a +7 +SELECT a FROM t1 WHERE b > ANY ( SELECT b FROM t1 ); +a +7 +SELECT a FROM t1 WHERE b <= ANY ( SELECT b FROM t1 GROUP BY b ); +a +5 +7 +SELECT a FROM t1 WHERE b <= ANY ( SELECT b FROM t1 ); +a +5 +7 +SELECT a FROM t1 WHERE b >= ANY ( SELECT b FROM t1 GROUP BY b ); +a +5 +7 +SELECT a FROM t1 WHERE b >= ANY ( SELECT b FROM t1 ); +a +5 +7 +SELECT a FROM t1 WHERE b = ANY ( SELECT b FROM t1 ); +a +5 +7 +SELECT a FROM t1 WHERE b = ANY ( SELECT b FROM t1 GROUP BY b ); +a +5 +7 +SELECT a FROM t1 WHERE b <> ANY ( SELECT b FROM t1 ); +a +5 +7 +SELECT a FROM t1 WHERE b <> ANY ( SELECT b FROM t1 GROUP BY b ); +a +5 +7 +SELECT a FROM t1 WHERE b < ALL ( SELECT b FROM t1 GROUP BY b ); +a +SELECT a FROM t1 WHERE b < ALL ( SELECT b FROM t1 ); +a +SELECT a FROM t1 WHERE b > ALL ( SELECT b FROM t1 GROUP BY b ); +a +SELECT a FROM t1 WHERE b > ALL ( SELECT b FROM t1 ); +a +SELECT a FROM t1 WHERE b <= ALL ( SELECT b FROM t1 GROUP BY b ); +a +SELECT a FROM t1 WHERE b <= ALL ( SELECT b FROM t1 ); +a +SELECT a FROM t1 WHERE b >= ALL ( SELECT b FROM t1 GROUP BY b ); +a +SELECT a FROM t1 WHERE b >= ALL ( SELECT b FROM t1 ); +a +SELECT a FROM t1 WHERE b = ALL ( SELECT b FROM t1 ); +a +SELECT a FROM t1 WHERE b = ALL ( SELECT b FROM t1 GROUP BY b ); +a +SELECT a FROM t1 WHERE b <> ALL ( SELECT b FROM t1 ); +a +SELECT a FROM t1 WHERE b <> ALL ( SELECT b FROM t1 GROUP BY b ); +a +drop table t1; +# +# Fix of lp:780386 (NULL left part with empty ALL subquery). +# +CREATE TABLE t1 ( f11 int) ; +INSERT IGNORE INTO t1 VALUES (0),(0); +CREATE TABLE t2 ( f3 int, f10 int, KEY (f10,f3)) ; +INSERT IGNORE INTO t2 VALUES (NULL,NULL),(5,0); +DROP TABLE IF EXISTS t3; +Warnings: +Note 1051 Unknown table 't3' +CREATE TABLE t3 ( f3 int) ; +INSERT INTO t3 VALUES (0),(0); +SELECT a1.f3 AS r FROM t2 AS a1 , t1 WHERE a1.f3 < ALL ( SELECT f3 FROM t3 WHERE f3 = 1 ) ; +r +NULL +5 +NULL +5 +DROP TABLE t1, t2, t3; +End of 5.2 tests # # BUG#779885: Crash in eliminate_item_equal with materialization=on in # maria-5.3 @@ -5528,24 +5823,30 @@ ON t2.f10 = t3.f10 f1 DROP TABLE t1,t2,t3; # -# Fix of LP BUG#780386 (NULL left part with empty ALL subquery). +# BUG lp:813473: Wrong result with outer join + NOT IN subquery +# This bug is a duplicate of Bug#11764086 whose test case is added below # -CREATE TABLE t1 ( f11 int) ; -INSERT IGNORE INTO t1 VALUES (0),(0); -CREATE TABLE t2 ( f3 int, f10 int, KEY (f10,f3)) ; -INSERT IGNORE INTO t2 VALUES (NULL,NULL),(5,0); -DROP TABLE IF EXISTS t3; -Warnings: -Note 1051 Unknown table 't3' -CREATE TABLE t3 ( f3 int) ; -INSERT INTO t3 VALUES (0),(0); -SELECT a1.f3 AS r FROM t2 AS a1 , t1 WHERE a1.f3 < ALL ( SELECT f3 FROM t3 WHERE f3 = 1 ) ; -r -NULL -5 -NULL -5 -DROP TABLE t1, t2, t3; +CREATE TABLE t1 (c int) ; +INSERT INTO t1 VALUES (5),(6); +CREATE TABLE t2 (a int, b int) ; +INSERT INTO t2 VALUES (20,9),(20,9); +create table t3 (d int, e int); +insert into t3 values (2, 9), (3,10); +EXPLAIN +SELECT t2.b , t1.c +FROM t2 LEFT JOIN t1 ON t1.c < 3 +WHERE (t2.b , t1.c) NOT IN (SELECT * from t3); +id select_type table type possible_keys key key_len ref rows Extra +1 PRIMARY t2 ALL NULL NULL NULL NULL 2 +1 PRIMARY t1 ALL NULL NULL NULL NULL 2 Using where +2 DEPENDENT SUBQUERY t3 ALL NULL NULL NULL NULL 2 Using where +SELECT t2.b , t1.c +FROM t2 LEFT JOIN t1 ON t1.c < 3 +WHERE (t2.b, t1.c) NOT IN (SELECT * from t3); +b c +9 NULL +9 NULL +drop table t1, t2, t3; End of 5.3 tests End of 5.5 tests. # @@ -5664,4 +5965,55 @@ id select_type table type possible_keys key key_len ref rows Extra 1 PRIMARY table2 index NULL f1_key 4 NULL 10 Using where; Using index; Using join buffer (flat, BNL join) 2 DEPENDENT SUBQUERY t2 range f1_key f1_key 4 NULL 6 Range checked for each record (index map: 0x1); Using temporary DROP TABLE t1,t2; +# +# lp:826279: assertion failure with GROUP BY a result of subquery +# +CREATE TABLE t1 (a int); +INSERT INTO t1 VALUES (0), (0); +CREATE TABLE t2 (a int, b int, c int); +INSERT INTO t2 VALUES (10,7,0), (0,7,0); +CREATE TABLE t3 (a int, b int); +INSERT INTO t3 VALUES (10,7), (0,7); +SELECT SUM(DISTINCT b), +(SELECT t2.a FROM t1 JOIN t2 ON t2.c != 0 +WHERE t.a != 0 AND t2.a != 0) +FROM (SELECT * FROM t3) AS t +GROUP BY 2; +SUM(DISTINCT b) (SELECT t2.a FROM t1 JOIN t2 ON t2.c != 0 +WHERE t.a != 0 AND t2.a != 0) +7 NULL +SELECT SUM(DISTINCT b), +(SELECT t2.a FROM t1,t2 WHERE t.a != 0 or 1=2 LIMIT 1) +FROM (SELECT * FROM t3) AS t +GROUP BY 2; +SUM(DISTINCT b) (SELECT t2.a FROM t1,t2 WHERE t.a != 0 or 1=2 LIMIT 1) +7 NULL +7 10 +DROP TABLE t1,t2,t3; +# +# Bug#12329653 +# EXPLAIN, UNION, PREPARED STATEMENT, CRASH, SQL_FULL_GROUP_BY +# +CREATE TABLE t1(a1 int); +INSERT INTO t1 VALUES (1),(2); +SELECT @@session.sql_mode INTO @old_sql_mode; +SET SESSION sql_mode='ONLY_FULL_GROUP_BY'; +SELECT 1 FROM t1 WHERE 1 < SOME (SELECT a1 FROM t1); +1 +1 +1 +PREPARE stmt FROM +'SELECT 1 UNION ALL +SELECT 1 FROM t1 +ORDER BY +(SELECT 1 FROM t1 AS t1_0 + WHERE 1 < SOME (SELECT a1 FROM t1) +)' ; +EXECUTE stmt ; +ERROR 21000: Subquery returns more than 1 row +EXECUTE stmt ; +ERROR 21000: Subquery returns more than 1 row +SET SESSION sql_mode=@old_sql_mode; +DEALLOCATE PREPARE stmt; +DROP TABLE t1; set optimizer_switch=@subselect_tmp; diff --git a/mysql-test/r/subselect2.result b/mysql-test/r/subselect2.result index 67b9ef0a2e9..a7b6e40d9c9 100644 --- a/mysql-test/r/subselect2.result +++ b/mysql-test/r/subselect2.result @@ -125,14 +125,14 @@ DOCID DOCNAME DOCTYPEID FOLDERID AUTHOR CREATED TITLE SUBTITLE DOCABSTRACT PUBLI c373e9f5ad07993f3859444553544200 Last Discussion c373e9f5ad079174ff17444553544200 c373e9f5ad0796c0eca4444553544200 Goldilocks 2003-06-09 11:21:06 Title: Last Discussion NULL Setting new abstract and keeping doc checked out 2003-06-09 10:51:26 2003-06-09 10:51:26 NULL NULL NULL 03eea05112b845949f3fd03278b5fe43 2003-06-09 11:21:06 admin 0 NULL Discussion NULL NULL EXPLAIN SELECT t2.*, t4.DOCTYPENAME, t1.CONTENTSIZE,t1.MIMETYPE FROM t2 INNER JOIN t4 ON t2.DOCTYPEID = t4.DOCTYPEID LEFT OUTER JOIN t1 ON t2.DOCID = t1.DOCID WHERE t2.FOLDERID IN(SELECT t3.FOLDERID FROM t3 WHERE t3.PARENTID IN(SELECT t3.FOLDERID FROM t3 WHERE t3.PARENTID IN(SELECT t3.FOLDERID FROM t3 WHERE t3.PARENTID IN(SELECT t3.FOLDERID FROM t3 WHERE t3.PARENTID IN(SELECT t3.FOLDERID FROM t3 WHERE t3.PARENTID='2f6161e879db43c1a5b82c21ddc49089' AND t3.FOLDERNAME = 'Level1') AND t3.FOLDERNAME = 'Level2') AND t3.FOLDERNAME = 'Level3') AND t3.FOLDERNAME = 'CopiedFolder') AND t3.FOLDERNAME = 'Movie Reviews') AND t2.DOCNAME = 'Last Discussion'; id select_type table type possible_keys key key_len ref rows Extra -1 PRIMARY t3 ref PRIMARY,FFOLDERID_IDX,CMFLDRPARNT_IDX CMFLDRPARNT_IDX 35 const 6 Using index condition; Using where -1 PRIMARY t3 ref PRIMARY,FFOLDERID_IDX,CMFLDRPARNT_IDX CMFLDRPARNT_IDX 35 test.t3.FOLDERID 1 Using where -1 PRIMARY t3 ref PRIMARY,FFOLDERID_IDX,CMFLDRPARNT_IDX CMFLDRPARNT_IDX 35 test.t3.FOLDERID 1 Using where -1 PRIMARY t3 ref PRIMARY,FFOLDERID_IDX,CMFLDRPARNT_IDX CMFLDRPARNT_IDX 35 test.t3.FOLDERID 1 Using where -1 PRIMARY t3 ref PRIMARY,FFOLDERID_IDX,CMFLDRPARNT_IDX CMFLDRPARNT_IDX 35 test.t3.FOLDERID 1 Using where +1 PRIMARY t4 ALL PRIMARY NULL NULL NULL 10 1 PRIMARY t2 ALL DDOCTYPEID_IDX,DFOLDERID_IDX NULL NULL NULL 9 Using where; Using join buffer (flat, BNL join) 1 PRIMARY t1 eq_ref PRIMARY PRIMARY 34 test.t2.DOCID 1 -1 PRIMARY t4 eq_ref PRIMARY PRIMARY 34 test.t2.DOCTYPEID 1 +1 PRIMARY t3 eq_ref PRIMARY,FFOLDERID_IDX,CMFLDRPARNT_IDX PRIMARY 34 test.t2.FOLDERID 1 Using where +1 PRIMARY t3 eq_ref PRIMARY,FFOLDERID_IDX,CMFLDRPARNT_IDX PRIMARY 34 test.t3.PARENTID 1 Using where +1 PRIMARY t3 eq_ref PRIMARY,FFOLDERID_IDX,CMFLDRPARNT_IDX PRIMARY 34 test.t3.PARENTID 1 Using where +1 PRIMARY t3 eq_ref PRIMARY,FFOLDERID_IDX,CMFLDRPARNT_IDX PRIMARY 34 test.t3.PARENTID 1 Using where +1 PRIMARY t3 eq_ref PRIMARY,FFOLDERID_IDX,CMFLDRPARNT_IDX PRIMARY 34 test.t3.PARENTID 1 Using where drop table t1, t2, t3, t4; CREATE TABLE t1 (a int(10) , PRIMARY KEY (a)) Engine=InnoDB; INSERT INTO t1 VALUES (1),(2); diff --git a/mysql-test/r/subselect3.result b/mysql-test/r/subselect3.result index c96a25f05e4..501804a0006 100644 --- a/mysql-test/r/subselect3.result +++ b/mysql-test/r/subselect3.result @@ -1,6 +1,6 @@ drop table if exists t0, t1, t2, t3, t4, t5, t11, t12, t21, t22; set @subselect3_tmp= @@optimizer_switch; -set optimizer_switch='semijoin=on,firstmatch=on,loosescan=on'; +set optimizer_switch='semijoin=on,firstmatch=on,loosescan=on,semijoin_with_cache=on'; create table t1 (oref int, grp int, ie int) ; insert into t1 (oref, grp, ie) values (1, 1, 1), @@ -32,7 +32,7 @@ id select_type table type possible_keys key key_len ref rows filtered Extra 2 DEPENDENT SUBQUERY t1 ALL NULL NULL NULL NULL 6 100.00 Using where; Using temporary Warnings: Note 1276 Field or reference 'test.t2.oref' of SELECT #2 was resolved in SELECT #1 -Note 1003 select `test`.`t2`.`a` AS `a`,`test`.`t2`.`oref` AS `oref`,<in_optimizer>(`test`.`t2`.`a`,<exists>(select max(`test`.`t1`.`ie`) from `test`.`t1` where (`test`.`t1`.`oref` = `test`.`t2`.`oref`) group by `test`.`t1`.`grp` having trigcond((<cache>(`test`.`t2`.`a`) = <ref_null_helper>(max(`test`.`t1`.`ie`)))))) AS `Z` from `test`.`t2` +Note 1003 select `test`.`t2`.`a` AS `a`,`test`.`t2`.`oref` AS `oref`,<expr_cache><`test`.`t2`.`a`,`test`.`t2`.`oref`>(<in_optimizer>(`test`.`t2`.`a`,<exists>(select max(`test`.`t1`.`ie`) from `test`.`t1` where (`test`.`t1`.`oref` = `test`.`t2`.`oref`) group by `test`.`t1`.`grp` having trigcond((<cache>(`test`.`t2`.`a`) = <ref_null_helper>(max(`test`.`t1`.`ie`))))))) AS `Z` from `test`.`t2` explain extended select a, oref from t2 where a in (select max(ie) from t1 where oref=t2.oref group by grp); @@ -41,7 +41,7 @@ id select_type table type possible_keys key key_len ref rows filtered Extra 2 DEPENDENT SUBQUERY t1 ALL NULL NULL NULL NULL 6 100.00 Using where; Using temporary Warnings: Note 1276 Field or reference 'test.t2.oref' of SELECT #2 was resolved in SELECT #1 -Note 1003 select `test`.`t2`.`a` AS `a`,`test`.`t2`.`oref` AS `oref` from `test`.`t2` where <in_optimizer>(`test`.`t2`.`a`,<exists>(select max(`test`.`t1`.`ie`) from `test`.`t1` where (`test`.`t1`.`oref` = `test`.`t2`.`oref`) group by `test`.`t1`.`grp` having (<cache>(`test`.`t2`.`a`) = <ref_null_helper>(max(`test`.`t1`.`ie`))))) +Note 1003 select `test`.`t2`.`a` AS `a`,`test`.`t2`.`oref` AS `oref` from `test`.`t2` where <expr_cache><`test`.`t2`.`a`,`test`.`t2`.`oref`>(<in_optimizer>(`test`.`t2`.`a`,<exists>(select max(`test`.`t1`.`ie`) from `test`.`t1` where (`test`.`t1`.`oref` = `test`.`t2`.`oref`) group by `test`.`t1`.`grp` having (<cache>(`test`.`t2`.`a`) = <ref_null_helper>(max(`test`.`t1`.`ie`)))))) select a, oref, a in ( select max(ie) from t1 where oref=t2.oref group by grp union select max(ie) from t1 where oref=t2.oref group by grp @@ -72,7 +72,7 @@ id select_type table type possible_keys key key_len ref rows filtered Extra 1 PRIMARY t3 ALL NULL NULL NULL NULL 2 100.00 2 DEPENDENT SUBQUERY t1 ALL NULL NULL NULL NULL 6 100.00 Using where; Using temporary Warnings: -Note 1003 select <in_optimizer>(`test`.`t3`.`a`,<exists>(select max(`test`.`t1`.`ie`) from `test`.`t1` where (`test`.`t1`.`oref` = 4) group by `test`.`t1`.`grp` having trigcond((<cache>(`test`.`t3`.`a`) = <ref_null_helper>(max(`test`.`t1`.`ie`)))))) AS `a in (select max(ie) from t1 where oref=4 group by grp)` from `test`.`t3` +Note 1003 select <expr_cache><`test`.`t3`.`a`>(<in_optimizer>(`test`.`t3`.`a`,<exists>(select max(`test`.`t1`.`ie`) from `test`.`t1` where (`test`.`t1`.`oref` = 4) group by `test`.`t1`.`grp` having trigcond((<cache>(`test`.`t3`.`a`) = <ref_null_helper>(max(`test`.`t1`.`ie`))))))) AS `a in (select max(ie) from t1 where oref=4 group by grp)` from `test`.`t3` set @@optimizer_switch=@save_optimizer_switch; drop table t1, t2, t3; create table t1 (a int, oref int, key(a)); @@ -82,6 +82,7 @@ insert into t1 values (2, 3), (2, NULL), (3, NULL); +insert into t1 values (5, 7), (8, 9), (4, 1); create table t2 (a int, oref int); insert into t2 values (1, 1), (2,2), (NULL, 3), (NULL, 4); select oref, a, a in (select a from t1 where oref=t2.oref) Z from t2; @@ -97,14 +98,14 @@ id select_type table type possible_keys key key_len ref rows filtered Extra 2 DEPENDENT SUBQUERY t1 index_subquery a a 5 func 2 100.00 Using where; Full scan on NULL key Warnings: Note 1276 Field or reference 'test.t2.oref' of SELECT #2 was resolved in SELECT #1 -Note 1003 select `test`.`t2`.`oref` AS `oref`,`test`.`t2`.`a` AS `a`,<in_optimizer>(`test`.`t2`.`a`,<exists>(<index_lookup>(<cache>(`test`.`t2`.`a`) in t1 on a checking NULL where (`test`.`t1`.`oref` = `test`.`t2`.`oref`) having trigcond(<is_not_null_test>(`test`.`t1`.`a`))))) AS `Z` from `test`.`t2` +Note 1003 select `test`.`t2`.`oref` AS `oref`,`test`.`t2`.`a` AS `a`,<expr_cache><`test`.`t2`.`a`,`test`.`t2`.`oref`>(<in_optimizer>(`test`.`t2`.`a`,<exists>(<index_lookup>(<cache>(`test`.`t2`.`a`) in t1 on a checking NULL where (`test`.`t1`.`oref` = `test`.`t2`.`oref`) having trigcond(<is_not_null_test>(`test`.`t1`.`a`)))))) AS `Z` from `test`.`t2` flush status; select oref, a from t2 where a in (select a from t1 where oref=t2.oref); oref a 1 1 show status like '%Handler_read_rnd_next'; Variable_name Value -Handler_read_rnd_next 11 +Handler_read_rnd_next 14 delete from t2; insert into t2 values (NULL, 0),(NULL, 0), (NULL, 0), (NULL, 0); set optimizer_switch='subquery_cache=off'; @@ -123,7 +124,7 @@ Handler_read_last 0 Handler_read_next 0 Handler_read_prev 0 Handler_read_rnd 0 -Handler_read_rnd_next 35 +Handler_read_rnd_next 50 select 'No key lookups, seq reads: 29= 5 reads from t2 + 4 * 6 reads from t1.' Z; Z No key lookups, seq reads: 29= 5 reads from t2 + 4 * 6 reads from t1. @@ -165,7 +166,7 @@ id select_type table type possible_keys key key_len ref rows filtered Extra 2 DEPENDENT SUBQUERY t2 ref a a 5 test.t1.b 1 100.00 Using where Warnings: Note 1276 Field or reference 'test.t3.oref' of SELECT #2 was resolved in SELECT #1 -Note 1003 select `test`.`t3`.`a` AS `a`,`test`.`t3`.`oref` AS `oref`,<in_optimizer>(`test`.`t3`.`a`,<exists>(select `test`.`t1`.`a` from `test`.`t1` join `test`.`t2` where ((`test`.`t2`.`b` = `test`.`t3`.`oref`) and trigcond(((<cache>(`test`.`t3`.`a`) = `test`.`t1`.`a`) or isnull(`test`.`t1`.`a`))) and (`test`.`t2`.`a` = `test`.`t1`.`b`)) having trigcond(<is_not_null_test>(`test`.`t1`.`a`)))) AS `Z` from `test`.`t3` +Note 1003 select `test`.`t3`.`a` AS `a`,`test`.`t3`.`oref` AS `oref`,<expr_cache><`test`.`t3`.`a`,`test`.`t3`.`oref`>(<in_optimizer>(`test`.`t3`.`a`,<exists>(select `test`.`t1`.`a` from `test`.`t1` join `test`.`t2` where ((`test`.`t2`.`b` = `test`.`t3`.`oref`) and trigcond(((<cache>(`test`.`t3`.`a`) = `test`.`t1`.`a`) or isnull(`test`.`t1`.`a`))) and (`test`.`t2`.`a` = `test`.`t1`.`b`)) having trigcond(<is_not_null_test>(`test`.`t1`.`a`))))) AS `Z` from `test`.`t3` drop table t1, t2, t3; create table t1 (a int NOT NULL, b int NOT NULL, key(a)); insert into t1 values @@ -193,7 +194,7 @@ id select_type table type possible_keys key key_len ref rows filtered Extra 2 DEPENDENT SUBQUERY t2 ref a a 4 test.t1.b 1 100.00 Using where Warnings: Note 1276 Field or reference 'test.t3.oref' of SELECT #2 was resolved in SELECT #1 -Note 1003 select `test`.`t3`.`a` AS `a`,`test`.`t3`.`oref` AS `oref`,<in_optimizer>(`test`.`t3`.`a`,<exists>(select `test`.`t1`.`a` from `test`.`t1` join `test`.`t2` where ((`test`.`t2`.`b` = `test`.`t3`.`oref`) and trigcond((<cache>(`test`.`t3`.`a`) = `test`.`t1`.`a`)) and (`test`.`t2`.`a` = `test`.`t1`.`b`)))) AS `Z` from `test`.`t3` +Note 1003 select `test`.`t3`.`a` AS `a`,`test`.`t3`.`oref` AS `oref`,<expr_cache><`test`.`t3`.`a`,`test`.`t3`.`oref`>(<in_optimizer>(`test`.`t3`.`a`,<exists>(select `test`.`t1`.`a` from `test`.`t1` join `test`.`t2` where ((`test`.`t2`.`b` = `test`.`t3`.`oref`) and trigcond((<cache>(`test`.`t3`.`a`) = `test`.`t1`.`a`)) and (`test`.`t2`.`a` = `test`.`t1`.`b`))))) AS `Z` from `test`.`t3` drop table t1,t2,t3; create table t1 (oref int, grp int); insert into t1 (oref, grp) values @@ -217,7 +218,7 @@ id select_type table type possible_keys key key_len ref rows filtered Extra 2 DEPENDENT SUBQUERY t1 ALL NULL NULL NULL NULL 2 100.00 Using temporary Warnings: Note 1276 Field or reference 't2.oref' of SELECT #2 was resolved in SELECT #1 -Note 1003 select `test`.`t2`.`a` AS `a`,`test`.`t2`.`oref` AS `oref`,<in_optimizer>(`test`.`t2`.`a`,<exists>(select count(0) from `test`.`t1` group by `test`.`t1`.`grp` having ((`test`.`t1`.`grp` = `test`.`t2`.`oref`) and trigcond((<cache>(`test`.`t2`.`a`) = <ref_null_helper>(count(0))))))) AS `Z` from `test`.`t2` +Note 1003 select `test`.`t2`.`a` AS `a`,`test`.`t2`.`oref` AS `oref`,<expr_cache><`test`.`t2`.`a`,`test`.`t2`.`oref`>(<in_optimizer>(`test`.`t2`.`a`,<exists>(select count(0) from `test`.`t1` group by `test`.`t1`.`grp` having ((`test`.`t1`.`grp` = `test`.`t2`.`oref`) and trigcond((<cache>(`test`.`t2`.`a`) = <ref_null_helper>(count(0)))))))) AS `Z` from `test`.`t2` drop table t1, t2; create table t1 (a int, b int, primary key (a)); insert into t1 values (1,1), (3,1),(100,1); @@ -249,7 +250,7 @@ id select_type table type possible_keys key key_len ref rows filtered Extra 2 DEPENDENT SUBQUERY t1 index_subquery a a 5 func 2 100.00 Using where; Full scan on NULL key Warnings: Note 1276 Field or reference 'test.t2.oref' of SELECT #2 was resolved in SELECT #1 -Note 1003 select `test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b`,`test`.`t2`.`oref` AS `oref`,<in_optimizer>((`test`.`t2`.`a`,`test`.`t2`.`b`),<exists>(<index_lookup>(<cache>(`test`.`t2`.`a`) in t1 on a checking NULL where ((`test`.`t1`.`c` = `test`.`t2`.`oref`) and trigcond(((<cache>(`test`.`t2`.`a`) = `test`.`t1`.`a`) or isnull(`test`.`t1`.`a`))) and trigcond(((<cache>(`test`.`t2`.`b`) = `test`.`t1`.`b`) or isnull(`test`.`t1`.`b`)))) having (trigcond(<is_not_null_test>(`test`.`t1`.`a`)) and trigcond(<is_not_null_test>(`test`.`t1`.`b`)))))) AS `Z` from `test`.`t2` +Note 1003 select `test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b`,`test`.`t2`.`oref` AS `oref`,<expr_cache><`test`.`t2`.`a`,`test`.`t2`.`b`,`test`.`t2`.`oref`>(<in_optimizer>((`test`.`t2`.`a`,`test`.`t2`.`b`),<exists>(<index_lookup>(<cache>(`test`.`t2`.`a`) in t1 on a checking NULL where ((`test`.`t1`.`c` = `test`.`t2`.`oref`) and trigcond(((<cache>(`test`.`t2`.`a`) = `test`.`t1`.`a`) or isnull(`test`.`t1`.`a`))) and trigcond(((<cache>(`test`.`t2`.`b`) = `test`.`t1`.`b`) or isnull(`test`.`t1`.`b`)))) having (trigcond(<is_not_null_test>(`test`.`t1`.`a`)) and trigcond(<is_not_null_test>(`test`.`t1`.`b`))))))) AS `Z` from `test`.`t2` select a,b, oref, (a,b) in (select a,b from t1 where c=t2.oref) Z from t2; a b oref Z NULL 1 100 0 @@ -266,7 +267,7 @@ id select_type table type possible_keys key key_len ref rows filtered Extra 2 DEPENDENT SUBQUERY t4 ALL NULL NULL NULL NULL 100 100.00 Using where; Using join buffer (flat, BNL join) Warnings: Note 1276 Field or reference 'test.t2.oref' of SELECT #2 was resolved in SELECT #1 -Note 1003 select `test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b`,`test`.`t2`.`oref` AS `oref`,<in_optimizer>((`test`.`t2`.`a`,`test`.`t2`.`b`),<exists>(select `test`.`t1`.`a`,`test`.`t1`.`b` from `test`.`t1` join `test`.`t4` where ((`test`.`t1`.`c` = `test`.`t2`.`oref`) and trigcond(((<cache>(`test`.`t2`.`a`) = `test`.`t1`.`a`) or isnull(`test`.`t1`.`a`))) and trigcond(((<cache>(`test`.`t2`.`b`) = `test`.`t1`.`b`) or isnull(`test`.`t1`.`b`)))) having (trigcond(<is_not_null_test>(`test`.`t1`.`a`)) and trigcond(<is_not_null_test>(`test`.`t1`.`b`))))) AS `Z` from `test`.`t2` +Note 1003 select `test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b`,`test`.`t2`.`oref` AS `oref`,<expr_cache><`test`.`t2`.`a`,`test`.`t2`.`b`,`test`.`t2`.`oref`>(<in_optimizer>((`test`.`t2`.`a`,`test`.`t2`.`b`),<exists>(select `test`.`t1`.`a`,`test`.`t1`.`b` from `test`.`t1` join `test`.`t4` where ((`test`.`t1`.`c` = `test`.`t2`.`oref`) and trigcond(((<cache>(`test`.`t2`.`a`) = `test`.`t1`.`a`) or isnull(`test`.`t1`.`a`))) and trigcond(((<cache>(`test`.`t2`.`b`) = `test`.`t1`.`b`) or isnull(`test`.`t1`.`b`)))) having (trigcond(<is_not_null_test>(`test`.`t1`.`a`)) and trigcond(<is_not_null_test>(`test`.`t1`.`b`)))))) AS `Z` from `test`.`t2` select a,b, oref, (a,b) in (select a,b from t1,t4 where c=t2.oref) Z from t2; @@ -311,7 +312,7 @@ id select_type table type possible_keys key key_len ref rows filtered Extra 2 DEPENDENT SUBQUERY t1 index_subquery idx idx 5 func 4 100.00 Using where; Full scan on NULL key Warnings: Note 1276 Field or reference 'test.t2.oref' of SELECT #2 was resolved in SELECT #1 -Note 1003 select `test`.`t2`.`oref` AS `oref`,`test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b`,<in_optimizer>((`test`.`t2`.`a`,`test`.`t2`.`b`),<exists>(<index_lookup>(<cache>(`test`.`t2`.`a`) in t1 on idx checking NULL where ((`test`.`t1`.`oref` = `test`.`t2`.`oref`) and trigcond(((<cache>(`test`.`t2`.`a`) = `test`.`t1`.`ie1`) or isnull(`test`.`t1`.`ie1`))) and trigcond(((<cache>(`test`.`t2`.`b`) = `test`.`t1`.`ie2`) or isnull(`test`.`t1`.`ie2`)))) having (trigcond(<is_not_null_test>(`test`.`t1`.`ie1`)) and trigcond(<is_not_null_test>(`test`.`t1`.`ie2`)))))) AS `Z` from `test`.`t2` where ((`test`.`t2`.`b` = 10) and (`test`.`t2`.`a` = 10)) +Note 1003 select `test`.`t2`.`oref` AS `oref`,`test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b`,<expr_cache><`test`.`t2`.`a`,`test`.`t2`.`b`,`test`.`t2`.`oref`>(<in_optimizer>((`test`.`t2`.`a`,`test`.`t2`.`b`),<exists>(<index_lookup>(<cache>(`test`.`t2`.`a`) in t1 on idx checking NULL where ((`test`.`t1`.`oref` = `test`.`t2`.`oref`) and trigcond(((<cache>(`test`.`t2`.`a`) = `test`.`t1`.`ie1`) or isnull(`test`.`t1`.`ie1`))) and trigcond(((<cache>(`test`.`t2`.`b`) = `test`.`t1`.`ie2`) or isnull(`test`.`t1`.`ie2`)))) having (trigcond(<is_not_null_test>(`test`.`t1`.`ie1`)) and trigcond(<is_not_null_test>(`test`.`t1`.`ie2`))))))) AS `Z` from `test`.`t2` where ((`test`.`t2`.`b` = 10) and (`test`.`t2`.`a` = 10)) drop table t1, t2; create table t1 (oref char(4), grp int, ie int); insert into t1 (oref, grp, ie) values @@ -345,8 +346,8 @@ dd NULL 0 bb NULL NULL select oref, a from t2 where a in (select ie from t1 where oref=t2.oref); oref a -ff 2 aa 1 +ff 2 select oref, a from t2 where a not in (select ie from t1 where oref=t2.oref); oref a bb 2 @@ -523,8 +524,8 @@ aa 1 1 1 dd 1 NULL 0 select oref, a, b from t2 where (a,b) in (select ie1,ie2 from t1 where oref=t2.oref); oref a b -ff 2 2 aa 1 1 +ff 2 2 select oref, a, b from t2 where (a,b) not in (select ie1,ie2 from t1 where oref=t2.oref); oref a b bb 2 1 @@ -581,7 +582,7 @@ id select_type table type possible_keys key key_len ref rows filtered Extra 2 DEPENDENT SUBQUERY t1 index_subquery idx idx 5 func 4 100.00 Using where; Full scan on NULL key Warnings: Note 1276 Field or reference 'test.t2.oref' of SELECT #2 was resolved in SELECT #1 -Note 1003 select `test`.`t2`.`oref` AS `oref`,`test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b`,<in_optimizer>((`test`.`t2`.`a`,`test`.`t2`.`b`),<exists>(<index_lookup>(<cache>(`test`.`t2`.`a`) in t1 on idx checking NULL where ((`test`.`t1`.`oref` = `test`.`t2`.`oref`) and trigcond(((<cache>(`test`.`t2`.`a`) = `test`.`t1`.`ie1`) or isnull(`test`.`t1`.`ie1`))) and trigcond(((<cache>(`test`.`t2`.`b`) = `test`.`t1`.`ie2`) or isnull(`test`.`t1`.`ie2`)))) having (trigcond(<is_not_null_test>(`test`.`t1`.`ie1`)) and trigcond(<is_not_null_test>(`test`.`t1`.`ie2`)))))) AS `Z` from `test`.`t2` +Note 1003 select `test`.`t2`.`oref` AS `oref`,`test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b`,<expr_cache><`test`.`t2`.`a`,`test`.`t2`.`b`,`test`.`t2`.`oref`>(<in_optimizer>((`test`.`t2`.`a`,`test`.`t2`.`b`),<exists>(<index_lookup>(<cache>(`test`.`t2`.`a`) in t1 on idx checking NULL where ((`test`.`t1`.`oref` = `test`.`t2`.`oref`) and trigcond(((<cache>(`test`.`t2`.`a`) = `test`.`t1`.`ie1`) or isnull(`test`.`t1`.`ie1`))) and trigcond(((<cache>(`test`.`t2`.`b`) = `test`.`t1`.`ie2`) or isnull(`test`.`t1`.`ie2`)))) having (trigcond(<is_not_null_test>(`test`.`t1`.`ie1`)) and trigcond(<is_not_null_test>(`test`.`t1`.`ie2`))))))) AS `Z` from `test`.`t2` drop table t1,t2; create table t1 (oref char(4), grp int, ie int primary key); insert into t1 (oref, grp, ie) values @@ -712,7 +713,7 @@ id select_type table type possible_keys key key_len ref rows filtered Extra 1 PRIMARY t2 eq_ref PRIMARY PRIMARY 4 test.t1.a 1 100.00 Using index 2 DEPENDENT SUBQUERY t1 ALL NULL NULL NULL NULL 3 100.00 Using where Warnings: -Note 1003 select `test`.`t1`.`a` AS `a` from `test`.`t1` join `test`.`t2` where ((`test`.`t2`.`b` = `test`.`t1`.`a`) and (not(<in_optimizer>(`test`.`t1`.`a`,<exists>(select `test`.`t1`.`a` from `test`.`t1` where trigcond(((<cache>(`test`.`t2`.`b`) = `test`.`t1`.`a`) or isnull(`test`.`t1`.`a`))) having trigcond(<is_not_null_test>(`test`.`t1`.`a`))))))) +Note 1003 select `test`.`t1`.`a` AS `a` from `test`.`t1` join `test`.`t2` where ((`test`.`t2`.`b` = `test`.`t1`.`a`) and (not(<expr_cache><`test`.`t1`.`a`>(<in_optimizer>(`test`.`t1`.`a`,<exists>(select `test`.`t1`.`a` from `test`.`t1` where trigcond(((<cache>(`test`.`t2`.`b`) = `test`.`t1`.`a`) or isnull(`test`.`t1`.`a`))) having trigcond(<is_not_null_test>(`test`.`t1`.`a`)))))))) SELECT a FROM t1, t2 WHERE a=b AND (b NOT IN (SELECT a FROM t1)); a SELECT a FROM t1, t2 WHERE a=b AND (b NOT IN (SELECT a FROM t1 WHERE a > 4)); @@ -1114,7 +1115,7 @@ set @@optimizer_switch=@save_optimizer_switch; explain select * from (select a from t0) X where a in (select a from t1); id select_type table type possible_keys key key_len ref rows Extra 1 PRIMARY <derived2> ALL NULL NULL NULL NULL 11 -1 PRIMARY t1 ALL NULL NULL NULL NULL 20 Using where; FirstMatch(<derived2>) +1 PRIMARY t1 ALL NULL NULL NULL NULL 20 Using where; FirstMatch(<derived2>); Using join buffer (flat, BNL join) 2 DERIVED t0 ALL NULL NULL NULL NULL 11 drop table t0, t1; create table t0 (a int); @@ -1133,9 +1134,9 @@ insert into t4 select a from t3; explain select * from t3 where a in (select t1.kp1 from t1,t4 where kp1<20 and t4.pk=t1.c); id select_type table type possible_keys key key_len ref rows Extra -1 PRIMARY t3 ALL NULL NULL NULL NULL 100 Using where -1 PRIMARY t1 ref kp1 kp1 5 test.t3.a 1 Using where -1 PRIMARY t4 eq_ref PRIMARY PRIMARY 4 test.t1.c 1 Using index; FirstMatch(t3) +1 PRIMARY t1 range kp1 kp1 5 NULL 48 Using where; LooseScan +1 PRIMARY t4 eq_ref PRIMARY PRIMARY 4 test.t1.c 1 Using index; FirstMatch(t1) +1 PRIMARY t3 ALL NULL NULL NULL NULL 100 Using where; Using join buffer (flat, BNL join) drop table t1, t3, t4; create table t1 (a int) as select * from t0 where a < 5; set @save_max_heap_table_size=@@max_heap_table_size; @@ -1423,6 +1424,53 @@ CALL p1; ERROR 42S22: Unknown column 'f1' in 'where clause' DROP PROCEDURE p1; DROP TABLE t1, t2; +# +# fix of lp:824425 (prohibiting subqueries in row in +# left part of IN/ALL/ANY) +# +CREATE TABLE t1 ( a int) ; +INSERT INTO t1 VALUES (20),(30); +CREATE TABLE t2 (a int) ; +INSERT INTO t2 VALUES (3),(9); +CREATE TABLE t3 ( a int, b int) ; +INSERT INTO t3 VALUES (20,5),(30,6); +set @optimizer_switch_save=@@optimizer_switch; +SET SESSION optimizer_switch='semijoin=OFF,in_to_exists=OFF,materialization=ON,partial_match_rowid_merge=ON,partial_match_table_scan=OFF'; +SELECT * FROM t1 +WHERE ( +( SELECT a FROM t2 WHERE a = 9 ) +) NOT IN ( +SELECT b +FROM t3 +); +a +20 +30 +explain extended +SELECT * FROM t1 +WHERE ( +( SELECT a FROM t2 WHERE a = 9 ) +) NOT IN ( +SELECT b +FROM t3 +); +id select_type table type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t1 ALL NULL NULL NULL NULL 2 100.00 +3 SUBQUERY t3 ALL NULL NULL NULL NULL 2 100.00 +2 SUBQUERY t2 ALL NULL NULL NULL NULL 2 100.00 Using where +Warnings: +Note 1003 select `test`.`t1`.`a` AS `a` from `test`.`t1` where (not(<expr_cache><(select `test`.`t2`.`a` from `test`.`t2` where (`test`.`t2`.`a` = 9))>(<in_optimizer>((select `test`.`t2`.`a` from `test`.`t2` where (`test`.`t2`.`a` = 9)),(select `test`.`t2`.`a` from `test`.`t2` where (`test`.`t2`.`a` = 9)) in ( <materialize> (select `test`.`t3`.`b` from `test`.`t3` ), <primary_index_lookup>(9 in <temporary table> on distinct_key where ((9 = `<subquery3>`.`b`)))))))) +SELECT * FROM t1 +WHERE ( +( SELECT a FROM t2 WHERE a = 9 ), +( SELECT a FROM t2 WHERE a = 3 ) +) NOT IN ( +SELECT b , a +FROM t3 +); +ERROR 42000: This version of MySQL doesn't yet support 'SUBQUERY in ROW in left expression of IN/ALL/ANY' +set optimizer_switch=@optimizer_switch_save; +drop table t1,t2,t3; End of 5.3 tests # # BUG#48920: COUNT DISTINCT returns 1 for NULL values when in a subquery @@ -1471,7 +1519,7 @@ id select_type table type possible_keys key key_len ref rows filtered Extra 2 DEPENDENT SUBQUERY t1 ALL NULL NULL NULL NULL 3 100.00 Using where Warnings: Note 1276 Field or reference 'test.t2.v' of SELECT #2 was resolved in SELECT #1 -Note 1003 select `test`.`t2`.`i` AS `i`,`test`.`t2`.`v` AS `v`,(select count(distinct `test`.`t1`.`i`) from `test`.`t1` where (`test`.`t1`.`v` = `test`.`t2`.`v`)) AS `subsel` from `test`.`t2` +Note 1003 select `test`.`t2`.`i` AS `i`,`test`.`t2`.`v` AS `v`,<expr_cache><`test`.`t2`.`v`>((select count(distinct `test`.`t1`.`i`) from `test`.`t1` where (`test`.`t1`.`v` = `test`.`t2`.`v`))) AS `subsel` from `test`.`t2` DROP TABLE t1,t2; End of 5.6 tests set @@optimizer_switch=@subselect3_tmp; diff --git a/mysql-test/r/subselect3_jcl6.result b/mysql-test/r/subselect3_jcl6.result index ffd55264dc6..645e3a1d84e 100644 --- a/mysql-test/r/subselect3_jcl6.result +++ b/mysql-test/r/subselect3_jcl6.result @@ -9,7 +9,7 @@ Variable_name Value join_cache_level 6 drop table if exists t0, t1, t2, t3, t4, t5, t11, t12, t21, t22; set @subselect3_tmp= @@optimizer_switch; -set optimizer_switch='semijoin=on,firstmatch=on,loosescan=on'; +set optimizer_switch='semijoin=on,firstmatch=on,loosescan=on,semijoin_with_cache=on'; create table t1 (oref int, grp int, ie int) ; insert into t1 (oref, grp, ie) values (1, 1, 1), @@ -41,7 +41,7 @@ id select_type table type possible_keys key key_len ref rows filtered Extra 2 DEPENDENT SUBQUERY t1 ALL NULL NULL NULL NULL 6 100.00 Using where; Using temporary Warnings: Note 1276 Field or reference 'test.t2.oref' of SELECT #2 was resolved in SELECT #1 -Note 1003 select `test`.`t2`.`a` AS `a`,`test`.`t2`.`oref` AS `oref`,<in_optimizer>(`test`.`t2`.`a`,<exists>(select max(`test`.`t1`.`ie`) from `test`.`t1` where (`test`.`t1`.`oref` = `test`.`t2`.`oref`) group by `test`.`t1`.`grp` having trigcond((<cache>(`test`.`t2`.`a`) = <ref_null_helper>(max(`test`.`t1`.`ie`)))))) AS `Z` from `test`.`t2` +Note 1003 select `test`.`t2`.`a` AS `a`,`test`.`t2`.`oref` AS `oref`,<expr_cache><`test`.`t2`.`a`,`test`.`t2`.`oref`>(<in_optimizer>(`test`.`t2`.`a`,<exists>(select max(`test`.`t1`.`ie`) from `test`.`t1` where (`test`.`t1`.`oref` = `test`.`t2`.`oref`) group by `test`.`t1`.`grp` having trigcond((<cache>(`test`.`t2`.`a`) = <ref_null_helper>(max(`test`.`t1`.`ie`))))))) AS `Z` from `test`.`t2` explain extended select a, oref from t2 where a in (select max(ie) from t1 where oref=t2.oref group by grp); @@ -50,7 +50,7 @@ id select_type table type possible_keys key key_len ref rows filtered Extra 2 DEPENDENT SUBQUERY t1 ALL NULL NULL NULL NULL 6 100.00 Using where; Using temporary Warnings: Note 1276 Field or reference 'test.t2.oref' of SELECT #2 was resolved in SELECT #1 -Note 1003 select `test`.`t2`.`a` AS `a`,`test`.`t2`.`oref` AS `oref` from `test`.`t2` where <in_optimizer>(`test`.`t2`.`a`,<exists>(select max(`test`.`t1`.`ie`) from `test`.`t1` where (`test`.`t1`.`oref` = `test`.`t2`.`oref`) group by `test`.`t1`.`grp` having (<cache>(`test`.`t2`.`a`) = <ref_null_helper>(max(`test`.`t1`.`ie`))))) +Note 1003 select `test`.`t2`.`a` AS `a`,`test`.`t2`.`oref` AS `oref` from `test`.`t2` where <expr_cache><`test`.`t2`.`a`,`test`.`t2`.`oref`>(<in_optimizer>(`test`.`t2`.`a`,<exists>(select max(`test`.`t1`.`ie`) from `test`.`t1` where (`test`.`t1`.`oref` = `test`.`t2`.`oref`) group by `test`.`t1`.`grp` having (<cache>(`test`.`t2`.`a`) = <ref_null_helper>(max(`test`.`t1`.`ie`)))))) select a, oref, a in ( select max(ie) from t1 where oref=t2.oref group by grp union select max(ie) from t1 where oref=t2.oref group by grp @@ -81,7 +81,7 @@ id select_type table type possible_keys key key_len ref rows filtered Extra 1 PRIMARY t3 ALL NULL NULL NULL NULL 2 100.00 2 DEPENDENT SUBQUERY t1 ALL NULL NULL NULL NULL 6 100.00 Using where; Using temporary Warnings: -Note 1003 select <in_optimizer>(`test`.`t3`.`a`,<exists>(select max(`test`.`t1`.`ie`) from `test`.`t1` where (`test`.`t1`.`oref` = 4) group by `test`.`t1`.`grp` having trigcond((<cache>(`test`.`t3`.`a`) = <ref_null_helper>(max(`test`.`t1`.`ie`)))))) AS `a in (select max(ie) from t1 where oref=4 group by grp)` from `test`.`t3` +Note 1003 select <expr_cache><`test`.`t3`.`a`>(<in_optimizer>(`test`.`t3`.`a`,<exists>(select max(`test`.`t1`.`ie`) from `test`.`t1` where (`test`.`t1`.`oref` = 4) group by `test`.`t1`.`grp` having trigcond((<cache>(`test`.`t3`.`a`) = <ref_null_helper>(max(`test`.`t1`.`ie`))))))) AS `a in (select max(ie) from t1 where oref=4 group by grp)` from `test`.`t3` set @@optimizer_switch=@save_optimizer_switch; drop table t1, t2, t3; create table t1 (a int, oref int, key(a)); @@ -91,6 +91,7 @@ insert into t1 values (2, 3), (2, NULL), (3, NULL); +insert into t1 values (5, 7), (8, 9), (4, 1); create table t2 (a int, oref int); insert into t2 values (1, 1), (2,2), (NULL, 3), (NULL, 4); select oref, a, a in (select a from t1 where oref=t2.oref) Z from t2; @@ -106,14 +107,14 @@ id select_type table type possible_keys key key_len ref rows filtered Extra 2 DEPENDENT SUBQUERY t1 index_subquery a a 5 func 2 100.00 Using where; Full scan on NULL key Warnings: Note 1276 Field or reference 'test.t2.oref' of SELECT #2 was resolved in SELECT #1 -Note 1003 select `test`.`t2`.`oref` AS `oref`,`test`.`t2`.`a` AS `a`,<in_optimizer>(`test`.`t2`.`a`,<exists>(<index_lookup>(<cache>(`test`.`t2`.`a`) in t1 on a checking NULL where (`test`.`t1`.`oref` = `test`.`t2`.`oref`) having trigcond(<is_not_null_test>(`test`.`t1`.`a`))))) AS `Z` from `test`.`t2` +Note 1003 select `test`.`t2`.`oref` AS `oref`,`test`.`t2`.`a` AS `a`,<expr_cache><`test`.`t2`.`a`,`test`.`t2`.`oref`>(<in_optimizer>(`test`.`t2`.`a`,<exists>(<index_lookup>(<cache>(`test`.`t2`.`a`) in t1 on a checking NULL where (`test`.`t1`.`oref` = `test`.`t2`.`oref`) having trigcond(<is_not_null_test>(`test`.`t1`.`a`)))))) AS `Z` from `test`.`t2` flush status; select oref, a from t2 where a in (select a from t1 where oref=t2.oref); oref a 1 1 show status like '%Handler_read_rnd_next'; Variable_name Value -Handler_read_rnd_next 11 +Handler_read_rnd_next 14 delete from t2; insert into t2 values (NULL, 0),(NULL, 0), (NULL, 0), (NULL, 0); set optimizer_switch='subquery_cache=off'; @@ -132,7 +133,7 @@ Handler_read_last 0 Handler_read_next 0 Handler_read_prev 0 Handler_read_rnd 0 -Handler_read_rnd_next 35 +Handler_read_rnd_next 50 select 'No key lookups, seq reads: 29= 5 reads from t2 + 4 * 6 reads from t1.' Z; Z No key lookups, seq reads: 29= 5 reads from t2 + 4 * 6 reads from t1. @@ -174,7 +175,7 @@ id select_type table type possible_keys key key_len ref rows filtered Extra 2 DEPENDENT SUBQUERY t2 ref a a 5 test.t1.b 1 100.00 Using where; Using join buffer (flat, BKA join); Key-ordered Rowid-ordered scan Warnings: Note 1276 Field or reference 'test.t3.oref' of SELECT #2 was resolved in SELECT #1 -Note 1003 select `test`.`t3`.`a` AS `a`,`test`.`t3`.`oref` AS `oref`,<in_optimizer>(`test`.`t3`.`a`,<exists>(select `test`.`t1`.`a` from `test`.`t1` join `test`.`t2` where ((`test`.`t2`.`b` = `test`.`t3`.`oref`) and trigcond(((<cache>(`test`.`t3`.`a`) = `test`.`t1`.`a`) or isnull(`test`.`t1`.`a`))) and (`test`.`t2`.`a` = `test`.`t1`.`b`)) having trigcond(<is_not_null_test>(`test`.`t1`.`a`)))) AS `Z` from `test`.`t3` +Note 1003 select `test`.`t3`.`a` AS `a`,`test`.`t3`.`oref` AS `oref`,<expr_cache><`test`.`t3`.`a`,`test`.`t3`.`oref`>(<in_optimizer>(`test`.`t3`.`a`,<exists>(select `test`.`t1`.`a` from `test`.`t1` join `test`.`t2` where ((`test`.`t2`.`b` = `test`.`t3`.`oref`) and trigcond(((<cache>(`test`.`t3`.`a`) = `test`.`t1`.`a`) or isnull(`test`.`t1`.`a`))) and (`test`.`t2`.`a` = `test`.`t1`.`b`)) having trigcond(<is_not_null_test>(`test`.`t1`.`a`))))) AS `Z` from `test`.`t3` drop table t1, t2, t3; create table t1 (a int NOT NULL, b int NOT NULL, key(a)); insert into t1 values @@ -202,7 +203,7 @@ id select_type table type possible_keys key key_len ref rows filtered Extra 2 DEPENDENT SUBQUERY t2 ref a a 4 test.t1.b 1 100.00 Using where; Using join buffer (flat, BKA join); Key-ordered Rowid-ordered scan Warnings: Note 1276 Field or reference 'test.t3.oref' of SELECT #2 was resolved in SELECT #1 -Note 1003 select `test`.`t3`.`a` AS `a`,`test`.`t3`.`oref` AS `oref`,<in_optimizer>(`test`.`t3`.`a`,<exists>(select `test`.`t1`.`a` from `test`.`t1` join `test`.`t2` where ((`test`.`t2`.`b` = `test`.`t3`.`oref`) and trigcond((<cache>(`test`.`t3`.`a`) = `test`.`t1`.`a`)) and (`test`.`t2`.`a` = `test`.`t1`.`b`)))) AS `Z` from `test`.`t3` +Note 1003 select `test`.`t3`.`a` AS `a`,`test`.`t3`.`oref` AS `oref`,<expr_cache><`test`.`t3`.`a`,`test`.`t3`.`oref`>(<in_optimizer>(`test`.`t3`.`a`,<exists>(select `test`.`t1`.`a` from `test`.`t1` join `test`.`t2` where ((`test`.`t2`.`b` = `test`.`t3`.`oref`) and trigcond((<cache>(`test`.`t3`.`a`) = `test`.`t1`.`a`)) and (`test`.`t2`.`a` = `test`.`t1`.`b`))))) AS `Z` from `test`.`t3` drop table t1,t2,t3; create table t1 (oref int, grp int); insert into t1 (oref, grp) values @@ -226,7 +227,7 @@ id select_type table type possible_keys key key_len ref rows filtered Extra 2 DEPENDENT SUBQUERY t1 ALL NULL NULL NULL NULL 2 100.00 Using temporary Warnings: Note 1276 Field or reference 't2.oref' of SELECT #2 was resolved in SELECT #1 -Note 1003 select `test`.`t2`.`a` AS `a`,`test`.`t2`.`oref` AS `oref`,<in_optimizer>(`test`.`t2`.`a`,<exists>(select count(0) from `test`.`t1` group by `test`.`t1`.`grp` having ((`test`.`t1`.`grp` = `test`.`t2`.`oref`) and trigcond((<cache>(`test`.`t2`.`a`) = <ref_null_helper>(count(0))))))) AS `Z` from `test`.`t2` +Note 1003 select `test`.`t2`.`a` AS `a`,`test`.`t2`.`oref` AS `oref`,<expr_cache><`test`.`t2`.`a`,`test`.`t2`.`oref`>(<in_optimizer>(`test`.`t2`.`a`,<exists>(select count(0) from `test`.`t1` group by `test`.`t1`.`grp` having ((`test`.`t1`.`grp` = `test`.`t2`.`oref`) and trigcond((<cache>(`test`.`t2`.`a`) = <ref_null_helper>(count(0)))))))) AS `Z` from `test`.`t2` drop table t1, t2; create table t1 (a int, b int, primary key (a)); insert into t1 values (1,1), (3,1),(100,1); @@ -258,7 +259,7 @@ id select_type table type possible_keys key key_len ref rows filtered Extra 2 DEPENDENT SUBQUERY t1 index_subquery a a 5 func 2 100.00 Using where; Full scan on NULL key Warnings: Note 1276 Field or reference 'test.t2.oref' of SELECT #2 was resolved in SELECT #1 -Note 1003 select `test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b`,`test`.`t2`.`oref` AS `oref`,<in_optimizer>((`test`.`t2`.`a`,`test`.`t2`.`b`),<exists>(<index_lookup>(<cache>(`test`.`t2`.`a`) in t1 on a checking NULL where ((`test`.`t1`.`c` = `test`.`t2`.`oref`) and trigcond(((<cache>(`test`.`t2`.`a`) = `test`.`t1`.`a`) or isnull(`test`.`t1`.`a`))) and trigcond(((<cache>(`test`.`t2`.`b`) = `test`.`t1`.`b`) or isnull(`test`.`t1`.`b`)))) having (trigcond(<is_not_null_test>(`test`.`t1`.`a`)) and trigcond(<is_not_null_test>(`test`.`t1`.`b`)))))) AS `Z` from `test`.`t2` +Note 1003 select `test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b`,`test`.`t2`.`oref` AS `oref`,<expr_cache><`test`.`t2`.`a`,`test`.`t2`.`b`,`test`.`t2`.`oref`>(<in_optimizer>((`test`.`t2`.`a`,`test`.`t2`.`b`),<exists>(<index_lookup>(<cache>(`test`.`t2`.`a`) in t1 on a checking NULL where ((`test`.`t1`.`c` = `test`.`t2`.`oref`) and trigcond(((<cache>(`test`.`t2`.`a`) = `test`.`t1`.`a`) or isnull(`test`.`t1`.`a`))) and trigcond(((<cache>(`test`.`t2`.`b`) = `test`.`t1`.`b`) or isnull(`test`.`t1`.`b`)))) having (trigcond(<is_not_null_test>(`test`.`t1`.`a`)) and trigcond(<is_not_null_test>(`test`.`t1`.`b`))))))) AS `Z` from `test`.`t2` select a,b, oref, (a,b) in (select a,b from t1 where c=t2.oref) Z from t2; a b oref Z NULL 1 100 0 @@ -275,7 +276,7 @@ id select_type table type possible_keys key key_len ref rows filtered Extra 2 DEPENDENT SUBQUERY t4 ALL NULL NULL NULL NULL 100 100.00 Using where; Using join buffer (flat, BNL join) Warnings: Note 1276 Field or reference 'test.t2.oref' of SELECT #2 was resolved in SELECT #1 -Note 1003 select `test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b`,`test`.`t2`.`oref` AS `oref`,<in_optimizer>((`test`.`t2`.`a`,`test`.`t2`.`b`),<exists>(select `test`.`t1`.`a`,`test`.`t1`.`b` from `test`.`t1` join `test`.`t4` where ((`test`.`t1`.`c` = `test`.`t2`.`oref`) and trigcond(((<cache>(`test`.`t2`.`a`) = `test`.`t1`.`a`) or isnull(`test`.`t1`.`a`))) and trigcond(((<cache>(`test`.`t2`.`b`) = `test`.`t1`.`b`) or isnull(`test`.`t1`.`b`)))) having (trigcond(<is_not_null_test>(`test`.`t1`.`a`)) and trigcond(<is_not_null_test>(`test`.`t1`.`b`))))) AS `Z` from `test`.`t2` +Note 1003 select `test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b`,`test`.`t2`.`oref` AS `oref`,<expr_cache><`test`.`t2`.`a`,`test`.`t2`.`b`,`test`.`t2`.`oref`>(<in_optimizer>((`test`.`t2`.`a`,`test`.`t2`.`b`),<exists>(select `test`.`t1`.`a`,`test`.`t1`.`b` from `test`.`t1` join `test`.`t4` where ((`test`.`t1`.`c` = `test`.`t2`.`oref`) and trigcond(((<cache>(`test`.`t2`.`a`) = `test`.`t1`.`a`) or isnull(`test`.`t1`.`a`))) and trigcond(((<cache>(`test`.`t2`.`b`) = `test`.`t1`.`b`) or isnull(`test`.`t1`.`b`)))) having (trigcond(<is_not_null_test>(`test`.`t1`.`a`)) and trigcond(<is_not_null_test>(`test`.`t1`.`b`)))))) AS `Z` from `test`.`t2` select a,b, oref, (a,b) in (select a,b from t1,t4 where c=t2.oref) Z from t2; @@ -320,7 +321,7 @@ id select_type table type possible_keys key key_len ref rows filtered Extra 2 DEPENDENT SUBQUERY t1 index_subquery idx idx 5 func 4 100.00 Using where; Full scan on NULL key Warnings: Note 1276 Field or reference 'test.t2.oref' of SELECT #2 was resolved in SELECT #1 -Note 1003 select `test`.`t2`.`oref` AS `oref`,`test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b`,<in_optimizer>((`test`.`t2`.`a`,`test`.`t2`.`b`),<exists>(<index_lookup>(<cache>(`test`.`t2`.`a`) in t1 on idx checking NULL where ((`test`.`t1`.`oref` = `test`.`t2`.`oref`) and trigcond(((<cache>(`test`.`t2`.`a`) = `test`.`t1`.`ie1`) or isnull(`test`.`t1`.`ie1`))) and trigcond(((<cache>(`test`.`t2`.`b`) = `test`.`t1`.`ie2`) or isnull(`test`.`t1`.`ie2`)))) having (trigcond(<is_not_null_test>(`test`.`t1`.`ie1`)) and trigcond(<is_not_null_test>(`test`.`t1`.`ie2`)))))) AS `Z` from `test`.`t2` where ((`test`.`t2`.`b` = 10) and (`test`.`t2`.`a` = 10)) +Note 1003 select `test`.`t2`.`oref` AS `oref`,`test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b`,<expr_cache><`test`.`t2`.`a`,`test`.`t2`.`b`,`test`.`t2`.`oref`>(<in_optimizer>((`test`.`t2`.`a`,`test`.`t2`.`b`),<exists>(<index_lookup>(<cache>(`test`.`t2`.`a`) in t1 on idx checking NULL where ((`test`.`t1`.`oref` = `test`.`t2`.`oref`) and trigcond(((<cache>(`test`.`t2`.`a`) = `test`.`t1`.`ie1`) or isnull(`test`.`t1`.`ie1`))) and trigcond(((<cache>(`test`.`t2`.`b`) = `test`.`t1`.`ie2`) or isnull(`test`.`t1`.`ie2`)))) having (trigcond(<is_not_null_test>(`test`.`t1`.`ie1`)) and trigcond(<is_not_null_test>(`test`.`t1`.`ie2`))))))) AS `Z` from `test`.`t2` where ((`test`.`t2`.`b` = 10) and (`test`.`t2`.`a` = 10)) drop table t1, t2; create table t1 (oref char(4), grp int, ie int); insert into t1 (oref, grp, ie) values @@ -590,7 +591,7 @@ id select_type table type possible_keys key key_len ref rows filtered Extra 2 DEPENDENT SUBQUERY t1 index_subquery idx idx 5 func 4 100.00 Using where; Full scan on NULL key Warnings: Note 1276 Field or reference 'test.t2.oref' of SELECT #2 was resolved in SELECT #1 -Note 1003 select `test`.`t2`.`oref` AS `oref`,`test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b`,<in_optimizer>((`test`.`t2`.`a`,`test`.`t2`.`b`),<exists>(<index_lookup>(<cache>(`test`.`t2`.`a`) in t1 on idx checking NULL where ((`test`.`t1`.`oref` = `test`.`t2`.`oref`) and trigcond(((<cache>(`test`.`t2`.`a`) = `test`.`t1`.`ie1`) or isnull(`test`.`t1`.`ie1`))) and trigcond(((<cache>(`test`.`t2`.`b`) = `test`.`t1`.`ie2`) or isnull(`test`.`t1`.`ie2`)))) having (trigcond(<is_not_null_test>(`test`.`t1`.`ie1`)) and trigcond(<is_not_null_test>(`test`.`t1`.`ie2`)))))) AS `Z` from `test`.`t2` +Note 1003 select `test`.`t2`.`oref` AS `oref`,`test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b`,<expr_cache><`test`.`t2`.`a`,`test`.`t2`.`b`,`test`.`t2`.`oref`>(<in_optimizer>((`test`.`t2`.`a`,`test`.`t2`.`b`),<exists>(<index_lookup>(<cache>(`test`.`t2`.`a`) in t1 on idx checking NULL where ((`test`.`t1`.`oref` = `test`.`t2`.`oref`) and trigcond(((<cache>(`test`.`t2`.`a`) = `test`.`t1`.`ie1`) or isnull(`test`.`t1`.`ie1`))) and trigcond(((<cache>(`test`.`t2`.`b`) = `test`.`t1`.`ie2`) or isnull(`test`.`t1`.`ie2`)))) having (trigcond(<is_not_null_test>(`test`.`t1`.`ie1`)) and trigcond(<is_not_null_test>(`test`.`t1`.`ie2`))))))) AS `Z` from `test`.`t2` drop table t1,t2; create table t1 (oref char(4), grp int, ie int primary key); insert into t1 (oref, grp, ie) values @@ -721,7 +722,7 @@ id select_type table type possible_keys key key_len ref rows filtered Extra 1 PRIMARY t2 eq_ref PRIMARY PRIMARY 4 test.t1.a 1 100.00 Using index 2 DEPENDENT SUBQUERY t1 ALL NULL NULL NULL NULL 3 100.00 Using where Warnings: -Note 1003 select `test`.`t1`.`a` AS `a` from `test`.`t1` join `test`.`t2` where ((`test`.`t2`.`b` = `test`.`t1`.`a`) and (not(<in_optimizer>(`test`.`t1`.`a`,<exists>(select `test`.`t1`.`a` from `test`.`t1` where trigcond(((<cache>(`test`.`t2`.`b`) = `test`.`t1`.`a`) or isnull(`test`.`t1`.`a`))) having trigcond(<is_not_null_test>(`test`.`t1`.`a`))))))) +Note 1003 select `test`.`t1`.`a` AS `a` from `test`.`t1` join `test`.`t2` where ((`test`.`t2`.`b` = `test`.`t1`.`a`) and (not(<expr_cache><`test`.`t1`.`a`>(<in_optimizer>(`test`.`t1`.`a`,<exists>(select `test`.`t1`.`a` from `test`.`t1` where trigcond(((<cache>(`test`.`t2`.`b`) = `test`.`t1`.`a`) or isnull(`test`.`t1`.`a`))) having trigcond(<is_not_null_test>(`test`.`t1`.`a`)))))))) SELECT a FROM t1, t2 WHERE a=b AND (b NOT IN (SELECT a FROM t1)); a SELECT a FROM t1, t2 WHERE a=b AND (b NOT IN (SELECT a FROM t1 WHERE a > 4)); @@ -1142,9 +1143,9 @@ insert into t4 select a from t3; explain select * from t3 where a in (select t1.kp1 from t1,t4 where kp1<20 and t4.pk=t1.c); id select_type table type possible_keys key key_len ref rows Extra -1 PRIMARY t3 ALL NULL NULL NULL NULL 100 Using where -1 PRIMARY t1 ref kp1 kp1 5 test.t3.a 1 Using where -1 PRIMARY t4 eq_ref PRIMARY PRIMARY 4 test.t1.c 1 Using index; FirstMatch(t3) +1 PRIMARY t1 range kp1 kp1 5 NULL 48 Using index condition; Using where; Rowid-ordered scan; LooseScan +1 PRIMARY t4 eq_ref PRIMARY PRIMARY 4 test.t1.c 1 Using index; FirstMatch(t1) +1 PRIMARY t3 ALL NULL NULL NULL NULL 100 Using where; Using join buffer (flat, BNL join) drop table t1, t3, t4; create table t1 (a int) as select * from t0 where a < 5; set @save_max_heap_table_size=@@max_heap_table_size; @@ -1432,6 +1433,53 @@ CALL p1; ERROR 42S22: Unknown column 'f1' in 'where clause' DROP PROCEDURE p1; DROP TABLE t1, t2; +# +# fix of lp:824425 (prohibiting subqueries in row in +# left part of IN/ALL/ANY) +# +CREATE TABLE t1 ( a int) ; +INSERT INTO t1 VALUES (20),(30); +CREATE TABLE t2 (a int) ; +INSERT INTO t2 VALUES (3),(9); +CREATE TABLE t3 ( a int, b int) ; +INSERT INTO t3 VALUES (20,5),(30,6); +set @optimizer_switch_save=@@optimizer_switch; +SET SESSION optimizer_switch='semijoin=OFF,in_to_exists=OFF,materialization=ON,partial_match_rowid_merge=ON,partial_match_table_scan=OFF'; +SELECT * FROM t1 +WHERE ( +( SELECT a FROM t2 WHERE a = 9 ) +) NOT IN ( +SELECT b +FROM t3 +); +a +20 +30 +explain extended +SELECT * FROM t1 +WHERE ( +( SELECT a FROM t2 WHERE a = 9 ) +) NOT IN ( +SELECT b +FROM t3 +); +id select_type table type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t1 ALL NULL NULL NULL NULL 2 100.00 +3 SUBQUERY t3 ALL NULL NULL NULL NULL 2 100.00 +2 SUBQUERY t2 ALL NULL NULL NULL NULL 2 100.00 Using where +Warnings: +Note 1003 select `test`.`t1`.`a` AS `a` from `test`.`t1` where (not(<expr_cache><(select `test`.`t2`.`a` from `test`.`t2` where (`test`.`t2`.`a` = 9))>(<in_optimizer>((select `test`.`t2`.`a` from `test`.`t2` where (`test`.`t2`.`a` = 9)),(select `test`.`t2`.`a` from `test`.`t2` where (`test`.`t2`.`a` = 9)) in ( <materialize> (select `test`.`t3`.`b` from `test`.`t3` ), <primary_index_lookup>(9 in <temporary table> on distinct_key where ((9 = `<subquery3>`.`b`)))))))) +SELECT * FROM t1 +WHERE ( +( SELECT a FROM t2 WHERE a = 9 ), +( SELECT a FROM t2 WHERE a = 3 ) +) NOT IN ( +SELECT b , a +FROM t3 +); +ERROR 42000: This version of MySQL doesn't yet support 'SUBQUERY in ROW in left expression of IN/ALL/ANY' +set optimizer_switch=@optimizer_switch_save; +drop table t1,t2,t3; End of 5.3 tests # # BUG#48920: COUNT DISTINCT returns 1 for NULL values when in a subquery @@ -1480,7 +1528,7 @@ id select_type table type possible_keys key key_len ref rows filtered Extra 2 DEPENDENT SUBQUERY t1 ALL NULL NULL NULL NULL 3 100.00 Using where Warnings: Note 1276 Field or reference 'test.t2.v' of SELECT #2 was resolved in SELECT #1 -Note 1003 select `test`.`t2`.`i` AS `i`,`test`.`t2`.`v` AS `v`,(select count(distinct `test`.`t1`.`i`) from `test`.`t1` where (`test`.`t1`.`v` = `test`.`t2`.`v`)) AS `subsel` from `test`.`t2` +Note 1003 select `test`.`t2`.`i` AS `i`,`test`.`t2`.`v` AS `v`,<expr_cache><`test`.`t2`.`v`>((select count(distinct `test`.`t1`.`i`) from `test`.`t1` where (`test`.`t1`.`v` = `test`.`t2`.`v`))) AS `subsel` from `test`.`t2` DROP TABLE t1,t2; End of 5.6 tests set @@optimizer_switch=@subselect3_tmp; diff --git a/mysql-test/r/subselect4.result b/mysql-test/r/subselect4.result index 84317beba32..9c81a0f552d 100644 --- a/mysql-test/r/subselect4.result +++ b/mysql-test/r/subselect4.result @@ -2,6 +2,7 @@ drop table if exists t0,t1,t2,t3,t4,t5,t6; drop view if exists v1, v2; set @subselect4_tmp= @@optimizer_switch; set optimizer_switch='semijoin=on,firstmatch=on,loosescan=on'; +set optimizer_switch='semijoin_with_cache=on'; set optimizer_switch='mrr=on,mrr_sort_keys=on,index_condition_pushdown=on'; # # Bug #46791: Assertion failed:(table->key_read==0),function unknown @@ -225,7 +226,7 @@ id select_type table type possible_keys key key_len ref rows filtered Extra 2 DEPENDENT SUBQUERY NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables Warnings: Note 1276 Field or reference 'test.t1.c' of SELECT #2 was resolved in SELECT #1 -Note 1003 select (select 1 from `test`.`t2` where 0) AS `RESULT` from dual +Note 1003 select <expr_cache><>((select 1 from `test`.`t2` where 0)) AS `RESULT` from dual first equivalent variant SELECT (SELECT 1 FROM t2 WHERE d = IFNULL(c,NULL)) AS RESULT FROM t1 GROUP BY c ; RESULT @@ -236,7 +237,7 @@ id select_type table type possible_keys key key_len ref rows filtered Extra 2 DEPENDENT SUBQUERY NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables Warnings: Note 1276 Field or reference 'test.t1.c' of SELECT #2 was resolved in SELECT #1 -Note 1003 select (select 1 from `test`.`t2` where 0) AS `RESULT` from dual group by NULL +Note 1003 select <expr_cache><>((select 1 from `test`.`t2` where 0)) AS `RESULT` from dual group by NULL second equivalent variant SELECT (SELECT 1 FROM t2 WHERE d = c) AS RESULT FROM t1 GROUP BY c ; RESULT @@ -247,7 +248,7 @@ id select_type table type possible_keys key key_len ref rows filtered Extra 2 DEPENDENT SUBQUERY NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables Warnings: Note 1276 Field or reference 'test.t1.c' of SELECT #2 was resolved in SELECT #1 -Note 1003 select (select 1 from `test`.`t2` where 0) AS `RESULT` from dual group by NULL +Note 1003 select <expr_cache><>((select 1 from `test`.`t2` where 0)) AS `RESULT` from dual group by NULL DROP TABLE t1,t2; # # BUG#45928 "Differing query results depending on MRR and @@ -278,31 +279,6 @@ Warnings: Warning 1287 The syntax '@@engine_condition_pushdown' is deprecated and will be removed in MySQL 7.0. Please use '@@optimizer_switch' instead DROP TABLE t1; # -# BUG#45863 "Assertion failed: (fixed == 0), function fix_fields(), -# file item.cc, line 4448" -# -DROP TABLE IF EXISTS C, BB; -CREATE TABLE C ( -varchar_nokey varchar(1) NOT NULL -); -INSERT INTO C VALUES -('k'),('a'),(''),('u'),('e'),('v'),('i'), -('t'),('u'),('f'),('u'),('m'),('j'),('f'), -('v'),('j'),('g'),('e'),('h'),('z'); -CREATE TABLE BB ( -varchar_nokey varchar(1) NOT NULL -); -INSERT INTO BB VALUES ('i'),('t'); -SELECT varchar_nokey FROM C -WHERE (varchar_nokey, OUTR) IN (SELECT varchar_nokey -FROM BB); -ERROR 21000: Operand should contain 2 column(s) -SELECT varchar_nokey FROM C -WHERE (varchar_nokey, OUTR) IN (SELECT varchar_nokey, varchar_nokey -FROM BB); -ERROR 42S22: Unknown column 'OUTR' in 'IN/ALL/ANY subquery' -DROP TABLE C,BB; -# # During work with BUG#45863 I had problems with a query that was # optimized differently in regular and prepared mode. # Because there was a bug in one of the selected strategies, I became @@ -1234,7 +1210,8 @@ FROM t2 JOIN t1 ON t1.f3 WHERE ('v') IN (SELECT f4 FROM t2) GROUP BY f9; id select_type table type possible_keys key key_len ref rows Extra -1 PRIMARY NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables +1 PRIMARY t2 system NULL NULL NULL NULL 1 +1 PRIMARY t1 ALL NULL NULL NULL NULL 2 Using where 3 DEPENDENT SUBQUERY NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables 2 DEPENDENT SUBQUERY t1 ALL NULL NULL NULL NULL 2 SELECT COUNT(t2.f3), @@ -1250,7 +1227,8 @@ FROM t2 JOIN t1 ON t1.f3 WHERE ('v') IN (SELECT f4 FROM t2) ORDER BY f9; id select_type table type possible_keys key key_len ref rows Extra -1 PRIMARY NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables +1 PRIMARY t2 system NULL NULL NULL NULL 1 +1 PRIMARY t1 ALL NULL NULL NULL NULL 2 Using where 3 DEPENDENT SUBQUERY NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables 2 DEPENDENT SUBQUERY t1 ALL NULL NULL NULL NULL 2 SELECT COUNT(t2.f3), @@ -1894,7 +1872,9 @@ EXPLAIN SELECT t1.f4 FROM t1 JOIN ( t2 JOIN t3 ON t3.f3 = t2.f4 ) ON t3.f3 = t2.f3 WHERE t1.f4 IN ( SELECT f4 FROM t2 ) ; id select_type table type possible_keys key key_len ref rows Extra -1 PRIMARY NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables +1 PRIMARY t1 system NULL NULL NULL NULL 1 +1 PRIMARY t3 system NULL NULL NULL NULL 1 +1 PRIMARY t2 ALL NULL NULL NULL NULL 2 Using where 2 SUBQUERY t2 ALL NULL NULL NULL NULL 2 SELECT t1.f4 FROM t1 JOIN ( t2 JOIN t3 ON t3.f3 = t2.f4 ) ON t3.f3 = t2.f3 @@ -1905,7 +1885,9 @@ EXPLAIN SELECT t1.f4 FROM t1 JOIN ( t2 JOIN t3 ON t3.f3 = t2.f4 ) ON t3.f3 = t2.f3 WHERE t1.f4 IN ( SELECT f4 FROM t2 ) ; id select_type table type possible_keys key key_len ref rows Extra -1 PRIMARY NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables +1 PRIMARY t1 system NULL NULL NULL NULL 1 +1 PRIMARY t3 system NULL NULL NULL NULL 1 +1 PRIMARY t2 ALL NULL NULL NULL NULL 2 Using where 2 DEPENDENT SUBQUERY t2 ALL NULL NULL NULL NULL 2 Using where SELECT t1.f4 FROM t1 JOIN ( t2 JOIN t3 ON t3.f3 = t2.f4 ) ON t3.f3 = t2.f3 @@ -1943,4 +1925,71 @@ EXECUTE st2; f2 2 drop table t1, t2; +# +# LP BUG#825018: Crash in check_and_do_in_subquery_rewrites() with corrlated subquery in select list +# +CREATE TABLE t1 (a int, b int); +INSERT INTO t1 VALUES (10,1),(11,7); +CREATE TABLE t2 (a int); +INSERT INTO t2 VALUES (2),(3); +CREATE TABLE t3 (a int, b int); +INSERT INTO t3 VALUES (1,1); +CREATE PROCEDURE sp1 () LANGUAGE SQL +SELECT (SELECT t1.a +FROM t1 +WHERE t1.b = t3.b +AND t1.b IN ( SELECT a FROM t2 )) sq +FROM t3 +GROUP BY 1; +CALL sp1(); +sq +NULL +CALL sp1(); +sq +NULL +drop procedure sp1; +prepare st1 from " +SELECT (SELECT t1.a + FROM t1 + WHERE t1.b = t3.b + AND t1.b IN ( SELECT a FROM t2 )) sq +FROM t3 +GROUP BY 1"; +execute st1; +sq +NULL +execute st1; +sq +NULL +deallocate prepare st1; +drop table t1, t2, t3; +set optimizer_switch=@subselect4_tmp; +# +# LP BUG#833702 Wrong result with nested IN and singlerow subqueries and equality propagation +# +CREATE TABLE t2 (c int , a int, b int); +INSERT INTO t2 VALUES (10,7,0); +CREATE TABLE t3 (a int, b int) ; +INSERT INTO t3 VALUES (5,0),(7,0); +CREATE TABLE t4 (a int); +INSERT INTO t4 VALUES (2),(8); +set @@optimizer_switch='semijoin=off,in_to_exists=on,materialization=off,subquery_cache=off'; +SELECT * FROM t2 +WHERE t2.b IN (SELECT b FROM t3 WHERE t3.a = t2.a AND a < SOME (SELECT * FROM t4)) +OR ( t2.c > 242 ); +c a b +10 7 0 +EXPLAIN SELECT * FROM t2 +WHERE t2.b IN (SELECT t3.b FROM t3 WHERE t3.a < ANY (SELECT t4.a FROM t4) and t3.a = 7); +id select_type table type possible_keys key key_len ref rows Extra +1 PRIMARY t2 system NULL NULL NULL NULL 1 +2 DEPENDENT SUBQUERY t3 ALL NULL NULL NULL NULL 2 Using where +3 SUBQUERY t4 ALL NULL NULL NULL NULL 2 +SELECT * FROM t2 +WHERE t2.b IN (SELECT t3.b FROM t3 WHERE t3.a < ANY (SELECT t4.a FROM t4) and t3.a = 7); +c a b +10 7 0 +drop table t2, t3, t4; set optimizer_switch=@subselect4_tmp; +SET optimizer_switch= @@global.optimizer_switch; +set @@tmp_table_size= @@global.tmp_table_size; diff --git a/mysql-test/r/subselect_cache.result b/mysql-test/r/subselect_cache.result index e57010b026c..9b515ba8e52 100644 --- a/mysql-test/r/subselect_cache.result +++ b/mysql-test/r/subselect_cache.result @@ -1,4 +1,5 @@ drop table if exists t0,t1,t2,t3,t4,t5,t6,t7,t8,t9; +drop view if exists v1; set optimizer_switch='subquery_cache=on'; create table t1 (a int, b int); insert into t1 values (1,2),(3,4),(1,2),(3,4),(3,4),(4,5),(4,5),(5,6),(5,6),(4,5); @@ -3546,5 +3547,31 @@ f1 f2 f3 f3 7 0 0 0 7 0 0 0 drop tables t1, t2, t3; +# +# Test of LP BUG#872775 view with "outer references" bug +# +set @@optimizer_switch= default; +set optimizer_switch='subquery_cache=on'; +CREATE TABLE t1 (a int) ; +CREATE TABLE t2 (b int, c varchar(1) NOT NULL ) ; +INSERT INTO t2 VALUES (1,'x'),(2,'y'); +CREATE TABLE t3 (a int) ; +CREATE TABLE t4 ( pk int(11) NOT NULL , b int(11) NOT NULL ) ; +INSERT INTO t4 VALUES (26,9),(27,5),(28,0),(29,3); +CREATE OR REPLACE VIEW v1 AS +SELECT t2.b +FROM t1 +JOIN t2 +WHERE t2 .c > ( +SELECT t2.c FROM t3 +); +SELECT * FROM t4 WHERE b NOT IN ( SELECT * FROM v1 ); +pk b +26 9 +27 5 +28 0 +29 3 +drop view v1; +drop table t1,t2,t3,t4; # restore default set @@optimizer_switch= default; diff --git a/mysql-test/r/subselect_extra.result b/mysql-test/r/subselect_extra.result index 9d2ff08cdb0..bb2ae830c20 100644 --- a/mysql-test/r/subselect_extra.result +++ b/mysql-test/r/subselect_extra.result @@ -1,6 +1,8 @@ drop table if exists t1,t2,t3,t4; +drop view if exists v1,v2,v3; set @subselect_extra_tmp=@@optimizer_switch; -set optimizer_switch='semijoin=on,firstmatch=on,loosescan=on'; +set @@optimizer_switch=ifnull(@optimizer_switch_for_subselect_extra_test, +"semijoin=on,firstmatch=on,loosescan=on,semijoin_with_cache=on,partial_match_rowid_merge=off,partial_match_table_scan=off"); # From explain.test: # # Bug#37870: Usage of uninitialized value caused failed assertion. @@ -227,7 +229,7 @@ group by a1,a2,b; id select_type table type possible_keys key key_len ref rows Extra 1 PRIMARY t1 range NULL idx_t1_1 147 NULL 17 Using where; Using index for group-by 2 DEPENDENT SUBQUERY t2 index NULL idx_t2_1 163 NULL 164 Using where; Using index -2 DEPENDENT SUBQUERY t3 index NULL idx_t3_1 10 NULL 192 Using where; Using index; FirstMatch(t2) +2 DEPENDENT SUBQUERY t3 index NULL idx_t3_1 10 NULL 192 Using where; Using index; FirstMatch(t2); Using join buffer (flat, BNL join) select a1,a2,b,c,min(c), max(c) from t1 where exists ( select * from t2 where t2.c in (select c from t3 where t3.c > t1.b) and @@ -258,7 +260,7 @@ group by a1,a2,b; id select_type table type possible_keys key key_len ref rows Extra 1 PRIMARY t1 index NULL idx_t1_1 163 NULL 128 Using where; Using index 2 DEPENDENT SUBQUERY t2 index NULL idx_t2_1 163 NULL 164 Using where; Using index -2 DEPENDENT SUBQUERY t3 index NULL idx_t3_1 10 NULL 192 Using where; Using index; FirstMatch(t2) +2 DEPENDENT SUBQUERY t3 index NULL idx_t3_1 10 NULL 192 Using where; Using index; FirstMatch(t2); Using join buffer (flat, BNL join) select a1,a2,b,c,min(c), max(c) from t1 where exists ( select * from t2 where t2.c in (select c from t3 where t3.c > t1.c) and @@ -305,7 +307,7 @@ EXPLAIN SELECT 1 FROM t1 WHERE a IN (SELECT a FROM t1 USE INDEX (i2) IGNORE INDEX (i2)); id select_type table type possible_keys key key_len ref rows Extra 1 PRIMARY t1 index PRIMARY,i2 PRIMARY 4 NULL 144 Using index -1 PRIMARY t1 ALL NULL NULL NULL NULL 144 Using where; FirstMatch(t1) +1 PRIMARY t1 ALL NULL NULL NULL NULL 144 Using where; FirstMatch(t1); Using join buffer (flat, BNL join) CREATE TABLE t2 (a INT, b INT, KEY(a)); INSERT INTO t2 VALUES (1, 1), (2, 2), (3,3), (4,4); EXPLAIN SELECT a, SUM(b) FROM t2 GROUP BY a LIMIT 2; @@ -318,6 +320,159 @@ EXPLAIN SELECT 1 FROM t2 WHERE a IN (SELECT a FROM t1 USE INDEX (i2) IGNORE INDEX (i2)); id select_type table type possible_keys key key_len ref rows Extra 1 PRIMARY t2 index a a 5 NULL 4 Using index -1 PRIMARY t1 ALL NULL NULL NULL NULL 144 Using where; FirstMatch(t2) +1 PRIMARY t1 ALL NULL NULL NULL NULL 144 Using where; FirstMatch(t2); Using join buffer (flat, BNL join) DROP TABLE t1, t2; -set optimizer_switch= @subselect_extra_tmp; +# +# From derived_view.test +# +set @tmp_subselect_extra_derived=@@optimizer_switch; +set optimizer_switch='derived_merge=on,derived_with_keys=on'; +# +# LP bug #806504: right join over a view/derived table +# +CREATE TABLE t1 (a int, b int) ; +INSERT INTO t1 VALUES (0,0); +CREATE TABLE t2 (a int) ; +INSERT INTO t2 VALUES (0), (0); +CREATE VIEW v1 AS SELECT * FROM t1; +SELECT * FROM t2 RIGHT JOIN (SELECT * FROM t1) AS t ON t.a != 0 +WHERE t.a IN (SELECT b FROM t1); +a a b +NULL 0 0 +EXPLAIN EXTENDED +SELECT * FROM t2 RIGHT JOIN (SELECT * FROM t1) AS t ON t.a != 0 +WHERE t.a IN (SELECT b FROM t1); +id select_type table type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t1 system NULL NULL NULL NULL 1 100.00 +1 PRIMARY t1 system NULL NULL NULL NULL 1 100.00 +1 PRIMARY t2 ALL NULL NULL NULL NULL 2 100.00 Using where +Warnings: +Note 1003 select `test`.`t2`.`a` AS `a`,0 AS `a`,0 AS `b` from `test`.`t2` semi join (dual) where 1 +SELECT * FROM t2 RIGHT JOIN v1 AS t ON t.a != 0 +WHERE t.a IN (SELECT b FROM t1); +a a b +NULL 0 0 +EXPLAIN EXTENDED +SELECT * FROM t2 RIGHT JOIN v1 AS t ON t.a != 0 +WHERE t.a IN (SELECT b FROM t1); +id select_type table type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t1 system NULL NULL NULL NULL 1 100.00 +1 PRIMARY t1 system NULL NULL NULL NULL 1 100.00 +1 PRIMARY t2 ALL NULL NULL NULL NULL 2 100.00 Using where +Warnings: +Note 1003 select `test`.`t2`.`a` AS `a`,0 AS `a`,0 AS `b` from `test`.`t2` semi join (dual) where 1 +DROP VIEW v1; +DROP TABLE t1,t2; +# +# LP bug #793448: materialized view accessed by two-component key +# +CREATE TABLE t1 (a int, b int); +INSERT INTO t1 VALUES (9,3), (2,5); +CREATE TABLE t2 (a int, b int); +INSERT INTO t2 VALUES (9,3), (3,7), (9,1), (2,5), (2,4), (3,8); +CREATE TABLE t3 (a int, b int); +INSERT INTO t3 VALUES (10,3), (9,7), (9,1), (2,4); +CREATE VIEW v1(a,b) AS SELECT a, MAX(b) FROM t2 GROUP BY a; +CREATE VIEW v2(a,b) AS SELECT a,b FROM t2 UNION SELECT a,b FROM t3; +SELECT * FROM v1; +a b +2 5 +3 8 +9 3 +SELECT a FROM t1 WHERE (a,b) IN (SELECT * FROM v1); +a +9 +2 +EXPLAIN +SELECT a FROM t1 WHERE (a,b) IN (SELECT * FROM v1); +id select_type table type possible_keys key key_len ref rows Extra +1 PRIMARY t1 ALL NULL NULL NULL NULL 2 Using where +1 PRIMARY <derived3> ref key0 key0 10 test.t1.a,test.t1.b 2 FirstMatch(t1) +3 DERIVED t2 ALL NULL NULL NULL NULL 6 Using temporary; Using filesort +SELECT * FROM v2; +a b +9 3 +3 7 +9 1 +2 5 +2 4 +3 8 +10 3 +9 7 +SELECT a FROM t1 WHERE (a,b) IN (SELECT * FROM v2); +a +9 +2 +EXPLAIN +SELECT a FROM t1 WHERE (a,b) IN (SELECT * FROM v2); +id select_type table type possible_keys key key_len ref rows Extra +1 PRIMARY t1 ALL NULL NULL NULL NULL 2 Using where +1 PRIMARY <derived3> ref key0 key0 10 test.t1.a,test.t1.b 2 FirstMatch(t1) +3 DERIVED t2 ALL NULL NULL NULL NULL 6 +4 UNION t3 ALL NULL NULL NULL NULL 4 +NULL UNION RESULT <union3,4> ALL NULL NULL NULL NULL NULL +DROP VIEW v1,v2; +DROP TABLE t1,t2,t3; +# +# LP bug #874006: materialized view used in IN subquery +# +CREATE TABLE t3 (a int NOT NULL, b varchar(1), c varchar(1)); +INSERT INTO t3 VALUES (19,NULL,NULL), (20,'r','r'); +CREATE TABLE t1 (a int, b varchar(1) , c varchar(1)); +INSERT INTO t1 VALUES (1,NULL,NULL), (5,'r','r'), (7,'y','y'); +CREATE TABLE t2 (a int NOT NULL , b int, c varchar(1)); +INSERT INTO t2 VALUES (4,3,'r'); +CREATE ALGORITHM=TEMPTABLE VIEW v1 AS SELECT * FROM t1; +SET SESSION optimizer_switch='derived_with_keys=off'; +EXPLAIN +SELECT * FROM t3 +WHERE t3.b IN (SELECT v1.b FROM v1, t2 +WHERE t2.c = v1.c AND t2.c = v1.b AND v1.b = t3.c); +id select_type table type possible_keys key key_len ref rows Extra +1 PRIMARY t2 system NULL NULL NULL NULL 1 +1 PRIMARY t3 ALL NULL NULL NULL NULL 2 Using where +1 PRIMARY <derived3> ALL NULL NULL NULL NULL 3 Using where; Start temporary; End temporary +3 DERIVED t1 ALL NULL NULL NULL NULL 3 +SELECT * FROM t3 +WHERE t3.b IN (SELECT v1.b FROM v1, t2 +WHERE t2.c = v1.c AND t2.c = v1.b AND v1.b = t3.c); +a b c +20 r r +SET SESSION optimizer_switch='derived_with_keys=on'; +EXPLAIN +SELECT * FROM t3 +WHERE t3.b IN (SELECT v1.b FROM v1, t2 +WHERE t2.c = v1.c AND t2.c = v1.b AND v1.b = t3.c); +id select_type table type possible_keys key key_len ref rows Extra +1 PRIMARY t2 system NULL NULL NULL NULL 1 +1 PRIMARY <derived3> ref key1 key1 10 const,const 0 Start temporary +1 PRIMARY t3 ALL NULL NULL NULL NULL 2 Using where; End temporary; Using join buffer (flat, BNL join) +3 DERIVED t1 ALL NULL NULL NULL NULL 3 +SELECT * FROM t3 +WHERE t3.b IN (SELECT v1.b FROM v1, t2 +WHERE t2.c = v1.c AND t2.c = v1.b AND v1.b = t3.c); +a b c +20 r r +DROP VIEW v1; +DROP TABLE t1,t2,t3; +# +# LP bug #873263: materialized view used in correlated IN subquery +# +CREATE TABLE t1 (a int, b int) ; +INSERT INTO t1 VALUES (5,4), (9,8); +CREATE TABLE t2 (a int, b int) ; +INSERT INTO t2 VALUES (4,5), (5,1); +CREATE ALGORITHM=TEMPTABLE VIEW v2 AS SELECT * FROM t2; +SET SESSION optimizer_switch='derived_with_keys=on'; +EXPLAIN +SELECT * FROM t1 WHERE t1.b IN (SELECT v2.a FROM v2 WHERE v2.b = t1.a); +id select_type table type possible_keys key key_len ref rows Extra +1 PRIMARY t1 ALL NULL NULL NULL NULL 2 Using where +1 PRIMARY <derived3> ref key0 key0 10 test.t1.b,test.t1.a 2 FirstMatch(t1) +3 DERIVED t2 ALL NULL NULL NULL NULL 2 +SELECT * FROM t1 WHERE t1.b IN (SELECT v2.a FROM v2 WHERE v2.b = t1.a); +a b +5 4 +DROP VIEW v2; +DROP TABLE t1,t2; +set optimizer_switch= @tmp_subselect_extra_derived; diff --git a/mysql-test/r/subselect_extra_no_semijoin.result b/mysql-test/r/subselect_extra_no_semijoin.result new file mode 100644 index 00000000000..78d122cfcd4 --- /dev/null +++ b/mysql-test/r/subselect_extra_no_semijoin.result @@ -0,0 +1,484 @@ +set @subselect_extra_no_sj_tmp=@@optimizer_switch; +set @optimizer_switch_for_subselect_extra_test='semijoin=off,firstmatch=off,loosescan=off,semijoin_with_cache=off'; +drop table if exists t1,t2,t3,t4; +drop view if exists v1,v2,v3; +set @subselect_extra_tmp=@@optimizer_switch; +set @@optimizer_switch=ifnull(@optimizer_switch_for_subselect_extra_test, +"semijoin=on,firstmatch=on,loosescan=on,semijoin_with_cache=on,partial_match_rowid_merge=off,partial_match_table_scan=off"); +# From explain.test: +# +# Bug#37870: Usage of uninitialized value caused failed assertion. +# +create table t1 (dt datetime not null, t time not null); +create table t2 (dt datetime not null); +insert into t1 values ('2001-01-01 1:1:1', '1:1:1'), +('2001-01-01 1:1:1', '1:1:1'); +insert into t2 values ('2001-01-01 1:1:1'), ('2001-01-01 1:1:1'); +flush tables; +EXPLAIN SELECT OUTR.dt FROM t1 AS OUTR WHERE OUTR.dt IN (SELECT INNR.dt FROM t2 AS INNR WHERE OUTR.dt IS NULL ); +id select_type table type possible_keys key key_len ref rows Extra +1 PRIMARY OUTR ALL NULL NULL NULL NULL 2 Using where +2 DEPENDENT SUBQUERY INNR ALL NULL NULL NULL NULL 2 Using where +flush tables; +SELECT OUTR.dt FROM t1 AS OUTR WHERE OUTR.dt IN (SELECT INNR.dt FROM t2 AS INNR WHERE OUTR.dt IS NULL ); +dt +flush tables; +EXPLAIN SELECT OUTR.dt FROM t1 AS OUTR WHERE OUTR.dt IN ( SELECT INNR.dt FROM t2 AS INNR WHERE OUTR.t < '2005-11-13 7:41:31' ); +id select_type table type possible_keys key key_len ref rows Extra +1 PRIMARY OUTR ALL NULL NULL NULL NULL 2 Using where +2 DEPENDENT SUBQUERY INNR ALL NULL NULL NULL NULL 2 Using where +flush tables; +SELECT OUTR.dt FROM t1 AS OUTR WHERE OUTR.dt IN ( SELECT INNR.dt FROM t2 AS INNR WHERE OUTR.t < '2005-11-13 7:41:31' ); +dt +2001-01-01 01:01:01 +2001-01-01 01:01:01 +drop tables t1, t2; +# From type_datetime.test: +# +# Bug #32694: NOT NULL table field in a subquery produces invalid results +# +create table t1 (id int(10) not null, cur_date datetime not null); +create table t2 (id int(10) not null, cur_date date not null); +insert into t1 (id, cur_date) values (1, '2007-04-25 18:30:22'); +insert into t2 (id, cur_date) values (1, '2007-04-25'); +explain extended +select * from t1 +where id in (select id from t1 as x1 where (t1.cur_date is null)); +id select_type table type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t1 system NULL NULL NULL NULL 1 100.00 +2 DEPENDENT SUBQUERY NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1276 Field or reference 'test.t1.cur_date' of SELECT #2 was resolved in SELECT #1 +Note 1003 select 1 AS `id`,'2007-04-25 18:30:22' AS `cur_date` from dual where <expr_cache><1>(<in_optimizer>(1,<exists>(select `test`.`x1`.`id` from `test`.`t1` `x1` where 0))) +select * from t1 +where id in (select id from t1 as x1 where (t1.cur_date is null)); +id cur_date +explain extended +select * from t2 +where id in (select id from t2 as x1 where (t2.cur_date is null)); +id select_type table type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t2 system NULL NULL NULL NULL 1 100.00 +2 DEPENDENT SUBQUERY NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1276 Field or reference 'test.t2.cur_date' of SELECT #2 was resolved in SELECT #1 +Note 1003 select 1 AS `id`,'2007-04-25' AS `cur_date` from dual where <expr_cache><1>(<in_optimizer>(1,<exists>(select `test`.`x1`.`id` from `test`.`t2` `x1` where 0))) +select * from t2 +where id in (select id from t2 as x1 where (t2.cur_date is null)); +id cur_date +insert into t1 (id, cur_date) values (2, '2007-04-26 18:30:22'); +insert into t2 (id, cur_date) values (2, '2007-04-26'); +explain extended +select * from t1 +where id in (select id from t1 as x1 where (t1.cur_date is null)); +id select_type table type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t1 ALL NULL NULL NULL NULL 2 100.00 Using where +2 DEPENDENT SUBQUERY x1 ALL NULL NULL NULL NULL 2 100.00 Using where +Warnings: +Note 1276 Field or reference 'test.t1.cur_date' of SELECT #2 was resolved in SELECT #1 +Note 1003 select `test`.`t1`.`id` AS `id`,`test`.`t1`.`cur_date` AS `cur_date` from `test`.`t1` where <expr_cache><`test`.`t1`.`id`,`test`.`t1`.`cur_date`>(<in_optimizer>(`test`.`t1`.`id`,<exists>(select `test`.`x1`.`id` from `test`.`t1` `x1` where ((`test`.`t1`.`cur_date` = 0) and (<cache>(`test`.`t1`.`id`) = `test`.`x1`.`id`))))) +select * from t1 +where id in (select id from t1 as x1 where (t1.cur_date is null)); +id cur_date +explain extended +select * from t2 +where id in (select id from t2 as x1 where (t2.cur_date is null)); +id select_type table type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t2 ALL NULL NULL NULL NULL 2 100.00 Using where +2 DEPENDENT SUBQUERY x1 ALL NULL NULL NULL NULL 2 100.00 Using where +Warnings: +Note 1276 Field or reference 'test.t2.cur_date' of SELECT #2 was resolved in SELECT #1 +Note 1003 select `test`.`t2`.`id` AS `id`,`test`.`t2`.`cur_date` AS `cur_date` from `test`.`t2` where <expr_cache><`test`.`t2`.`id`,`test`.`t2`.`cur_date`>(<in_optimizer>(`test`.`t2`.`id`,<exists>(select `test`.`x1`.`id` from `test`.`t2` `x1` where ((`test`.`t2`.`cur_date` = 0) and (<cache>(`test`.`t2`.`id`) = `test`.`x1`.`id`))))) +select * from t2 +where id in (select id from t2 as x1 where (t2.cur_date is null)); +id cur_date +drop table t1,t2; +# +# From group_min_max.test +# +create table t1 ( +a1 char(64), a2 char(64), b char(16), c char(16) not null, d char(16), dummy char(64) default ' ' +); +insert into t1 (a1, a2, b, c, d) values +('a','a','a','a111','xy1'),('a','a','a','b111','xy2'),('a','a','a','c111','xy3'),('a','a','a','d111','xy4'), +('a','a','b','e112','xy1'),('a','a','b','f112','xy2'),('a','a','b','g112','xy3'),('a','a','b','h112','xy4'), +('a','b','a','i121','xy1'),('a','b','a','j121','xy2'),('a','b','a','k121','xy3'),('a','b','a','l121','xy4'), +('a','b','b','m122','xy1'),('a','b','b','n122','xy2'),('a','b','b','o122','xy3'),('a','b','b','p122','xy4'), +('b','a','a','a211','xy1'),('b','a','a','b211','xy2'),('b','a','a','c211','xy3'),('b','a','a','d211','xy4'), +('b','a','b','e212','xy1'),('b','a','b','f212','xy2'),('b','a','b','g212','xy3'),('b','a','b','h212','xy4'), +('b','b','a','i221','xy1'),('b','b','a','j221','xy2'),('b','b','a','k221','xy3'),('b','b','a','l221','xy4'), +('b','b','b','m222','xy1'),('b','b','b','n222','xy2'),('b','b','b','o222','xy3'),('b','b','b','p222','xy4'), +('c','a','a','a311','xy1'),('c','a','a','b311','xy2'),('c','a','a','c311','xy3'),('c','a','a','d311','xy4'), +('c','a','b','e312','xy1'),('c','a','b','f312','xy2'),('c','a','b','g312','xy3'),('c','a','b','h312','xy4'), +('c','b','a','i321','xy1'),('c','b','a','j321','xy2'),('c','b','a','k321','xy3'),('c','b','a','l321','xy4'), +('c','b','b','m322','xy1'),('c','b','b','n322','xy2'),('c','b','b','o322','xy3'),('c','b','b','p322','xy4'), +('d','a','a','a411','xy1'),('d','a','a','b411','xy2'),('d','a','a','c411','xy3'),('d','a','a','d411','xy4'), +('d','a','b','e412','xy1'),('d','a','b','f412','xy2'),('d','a','b','g412','xy3'),('d','a','b','h412','xy4'), +('d','b','a','i421','xy1'),('d','b','a','j421','xy2'),('d','b','a','k421','xy3'),('d','b','a','l421','xy4'), +('d','b','b','m422','xy1'),('d','b','b','n422','xy2'),('d','b','b','o422','xy3'),('d','b','b','p422','xy4'), +('a','a','a','a111','xy1'),('a','a','a','b111','xy2'),('a','a','a','c111','xy3'),('a','a','a','d111','xy4'), +('a','a','b','e112','xy1'),('a','a','b','f112','xy2'),('a','a','b','g112','xy3'),('a','a','b','h112','xy4'), +('a','b','a','i121','xy1'),('a','b','a','j121','xy2'),('a','b','a','k121','xy3'),('a','b','a','l121','xy4'), +('a','b','b','m122','xy1'),('a','b','b','n122','xy2'),('a','b','b','o122','xy3'),('a','b','b','p122','xy4'), +('b','a','a','a211','xy1'),('b','a','a','b211','xy2'),('b','a','a','c211','xy3'),('b','a','a','d211','xy4'), +('b','a','b','e212','xy1'),('b','a','b','f212','xy2'),('b','a','b','g212','xy3'),('b','a','b','h212','xy4'), +('b','b','a','i221','xy1'),('b','b','a','j221','xy2'),('b','b','a','k221','xy3'),('b','b','a','l221','xy4'), +('b','b','b','m222','xy1'),('b','b','b','n222','xy2'),('b','b','b','o222','xy3'),('b','b','b','p222','xy4'), +('c','a','a','a311','xy1'),('c','a','a','b311','xy2'),('c','a','a','c311','xy3'),('c','a','a','d311','xy4'), +('c','a','b','e312','xy1'),('c','a','b','f312','xy2'),('c','a','b','g312','xy3'),('c','a','b','h312','xy4'), +('c','b','a','i321','xy1'),('c','b','a','j321','xy2'),('c','b','a','k321','xy3'),('c','b','a','l321','xy4'), +('c','b','b','m322','xy1'),('c','b','b','n322','xy2'),('c','b','b','o322','xy3'),('c','b','b','p322','xy4'), +('d','a','a','a411','xy1'),('d','a','a','b411','xy2'),('d','a','a','c411','xy3'),('d','a','a','d411','xy4'), +('d','a','b','e412','xy1'),('d','a','b','f412','xy2'),('d','a','b','g412','xy3'),('d','a','b','h412','xy4'), +('d','b','a','i421','xy1'),('d','b','a','j421','xy2'),('d','b','a','k421','xy3'),('d','b','a','l421','xy4'), +('d','b','b','m422','xy1'),('d','b','b','n422','xy2'),('d','b','b','o422','xy3'),('d','b','b','p422','xy4'); +create index idx_t1_0 on t1 (a1); +create index idx_t1_1 on t1 (a1,a2,b,c); +create index idx_t1_2 on t1 (a1,a2,b); +analyze table t1; +Table Op Msg_type Msg_text +test.t1 analyze status Table is already up to date +create table t2 ( +a1 char(64), a2 char(64) not null, b char(16), c char(16), d char(16), dummy char(64) default ' ' +); +insert into t2 select * from t1; +insert into t2 (a1, a2, b, c, d) values +('a','a',NULL,'a777','xyz'),('a','a',NULL,'a888','xyz'),('a','a',NULL,'a999','xyz'), +('a','a','a',NULL,'xyz'), +('a','a','b',NULL,'xyz'), +('a','b','a',NULL,'xyz'), +('c','a',NULL,'c777','xyz'),('c','a',NULL,'c888','xyz'),('c','a',NULL,'c999','xyz'), +('d','b','b',NULL,'xyz'), +('e','a','a',NULL,'xyz'),('e','a','a',NULL,'xyz'),('e','a','a',NULL,'xyz'),('e','a','a',NULL,'xyz'), +('e','a','b',NULL,'xyz'),('e','a','b',NULL,'xyz'),('e','a','b',NULL,'xyz'),('e','a','b',NULL,'xyz'), +('a','a',NULL,'a777','xyz'),('a','a',NULL,'a888','xyz'),('a','a',NULL,'a999','xyz'), +('a','a','a',NULL,'xyz'), +('a','a','b',NULL,'xyz'), +('a','b','a',NULL,'xyz'), +('c','a',NULL,'c777','xyz'),('c','a',NULL,'c888','xyz'),('c','a',NULL,'c999','xyz'), +('d','b','b',NULL,'xyz'), +('e','a','a',NULL,'xyz'),('e','a','a',NULL,'xyz'),('e','a','a',NULL,'xyz'),('e','a','a',NULL,'xyz'), +('e','a','b',NULL,'xyz'),('e','a','b',NULL,'xyz'),('e','a','b',NULL,'xyz'),('e','a','b',NULL,'xyz'); +create index idx_t2_0 on t2 (a1); +create index idx_t2_1 on t2 (a1,a2,b,c); +create index idx_t2_2 on t2 (a1,a2,b); +analyze table t2; +Table Op Msg_type Msg_text +test.t2 analyze status Table is already up to date +create table t3 ( +a1 char(1), a2 char(1), b char(1), c char(4) not null, d char(3), dummy char(1) default ' ' +); +insert into t3 (a1, a2, b, c, d) values +('a','a','a','a111','xy1'),('a','a','a','b111','xy2'),('a','a','a','c111','xy3'),('a','a','a','d111','xy4'), +('a','a','b','e112','xy1'),('a','a','b','f112','xy2'),('a','a','b','g112','xy3'),('a','a','b','h112','xy4'), +('a','b','a','i121','xy1'),('a','b','a','j121','xy2'),('a','b','a','k121','xy3'),('a','b','a','l121','xy4'), +('a','b','b','m122','xy1'),('a','b','b','n122','xy2'),('a','b','b','o122','xy3'),('a','b','b','p122','xy4'), +('b','a','a','a211','xy1'),('b','a','a','b211','xy2'),('b','a','a','c211','xy3'),('b','a','a','d211','xy4'), +('b','a','b','e212','xy1'),('b','a','b','f212','xy2'),('b','a','b','g212','xy3'),('b','a','b','h212','xy4'), +('b','b','a','i221','xy1'),('b','b','a','j221','xy2'),('b','b','a','k221','xy3'),('b','b','a','l221','xy4'), +('b','b','b','m222','xy1'),('b','b','b','n222','xy2'),('b','b','b','o222','xy3'),('b','b','b','p222','xy4'), +('c','a','a','a311','xy1'),('c','a','a','b311','xy2'),('c','a','a','c311','xy3'),('c','a','a','d311','xy4'), +('c','a','b','e312','xy1'),('c','a','b','f312','xy2'),('c','a','b','g312','xy3'),('c','a','b','h312','xy4'), +('c','b','a','i321','xy1'),('c','b','a','j321','xy2'),('c','b','a','k321','xy3'),('c','b','a','l321','xy4'), +('c','b','b','m322','xy1'),('c','b','b','n322','xy2'),('c','b','b','o322','xy3'),('c','b','b','p322','xy4'); +insert into t3 (a1, a2, b, c, d) values +('a','a','a','a111','xy1'),('a','a','a','b111','xy2'),('a','a','a','c111','xy3'),('a','a','a','d111','xy4'), +('a','a','b','e112','xy1'),('a','a','b','f112','xy2'),('a','a','b','g112','xy3'),('a','a','b','h112','xy4'), +('a','b','a','i121','xy1'),('a','b','a','j121','xy2'),('a','b','a','k121','xy3'),('a','b','a','l121','xy4'), +('a','b','b','m122','xy1'),('a','b','b','n122','xy2'),('a','b','b','o122','xy3'),('a','b','b','p122','xy4'), +('b','a','a','a211','xy1'),('b','a','a','b211','xy2'),('b','a','a','c211','xy3'),('b','a','a','d211','xy4'), +('b','a','b','e212','xy1'),('b','a','b','f212','xy2'),('b','a','b','g212','xy3'),('b','a','b','h212','xy4'), +('b','b','a','i221','xy1'),('b','b','a','j221','xy2'),('b','b','a','k221','xy3'),('b','b','a','l221','xy4'), +('b','b','b','m222','xy1'),('b','b','b','n222','xy2'),('b','b','b','o222','xy3'),('b','b','b','p222','xy4'), +('c','a','a','a311','xy1'),('c','a','a','b311','xy2'),('c','a','a','c311','xy3'),('c','a','a','d311','xy4'), +('c','a','b','e312','xy1'),('c','a','b','f312','xy2'),('c','a','b','g312','xy3'),('c','a','b','h312','xy4'), +('c','b','a','i321','xy1'),('c','b','a','j321','xy2'),('c','b','a','k321','xy3'),('c','b','a','l321','xy4'), +('c','b','b','m322','xy1'),('c','b','b','n322','xy2'),('c','b','b','o322','xy3'),('c','b','b','p322','xy4'); +insert into t3 (a1, a2, b, c, d) values +('a','a','a','a111','xy1'),('a','a','a','b111','xy2'),('a','a','a','c111','xy3'),('a','a','a','d111','xy4'), +('a','a','b','e112','xy1'),('a','a','b','f112','xy2'),('a','a','b','g112','xy3'),('a','a','b','h112','xy4'), +('a','b','a','i121','xy1'),('a','b','a','j121','xy2'),('a','b','a','k121','xy3'),('a','b','a','l121','xy4'), +('a','b','b','m122','xy1'),('a','b','b','n122','xy2'),('a','b','b','o122','xy3'),('a','b','b','p122','xy4'), +('b','a','a','a211','xy1'),('b','a','a','b211','xy2'),('b','a','a','c211','xy3'),('b','a','a','d211','xy4'), +('b','a','b','e212','xy1'),('b','a','b','f212','xy2'),('b','a','b','g212','xy3'),('b','a','b','h212','xy4'), +('b','b','a','i221','xy1'),('b','b','a','j221','xy2'),('b','b','a','k221','xy3'),('b','b','a','l221','xy4'), +('b','b','b','m222','xy1'),('b','b','b','n222','xy2'),('b','b','b','o222','xy3'),('b','b','b','p222','xy4'), +('c','a','a','a311','xy1'),('c','a','a','b311','xy2'),('c','a','a','c311','xy3'),('c','a','a','d311','xy4'), +('c','a','b','e312','xy1'),('c','a','b','f312','xy2'),('c','a','b','g312','xy3'),('c','a','b','h312','xy4'), +('c','b','a','i321','xy1'),('c','b','a','j321','xy2'),('c','b','a','k321','xy3'),('c','b','a','l321','xy4'), +('c','b','b','m322','xy1'),('c','b','b','n322','xy2'),('c','b','b','o322','xy3'),('c','b','b','p322','xy4'); +insert into t3 (a1, a2, b, c, d) values +('a','a','a','a111','xy1'),('a','a','a','b111','xy2'),('a','a','a','c111','xy3'),('a','a','a','d111','xy4'), +('a','a','b','e112','xy1'),('a','a','b','f112','xy2'),('a','a','b','g112','xy3'),('a','a','b','h112','xy4'), +('a','b','a','i121','xy1'),('a','b','a','j121','xy2'),('a','b','a','k121','xy3'),('a','b','a','l121','xy4'), +('a','b','b','m122','xy1'),('a','b','b','n122','xy2'),('a','b','b','o122','xy3'),('a','b','b','p122','xy4'), +('b','a','a','a211','xy1'),('b','a','a','b211','xy2'),('b','a','a','c211','xy3'),('b','a','a','d211','xy4'), +('b','a','b','e212','xy1'),('b','a','b','f212','xy2'),('b','a','b','g212','xy3'),('b','a','b','h212','xy4'), +('b','b','a','i221','xy1'),('b','b','a','j221','xy2'),('b','b','a','k221','xy3'),('b','b','a','l221','xy4'), +('b','b','b','m222','xy1'),('b','b','b','n222','xy2'),('b','b','b','o222','xy3'),('b','b','b','p222','xy4'), +('c','a','a','a311','xy1'),('c','a','a','b311','xy2'),('c','a','a','c311','xy3'),('c','a','a','d311','xy4'), +('c','a','b','e312','xy1'),('c','a','b','f312','xy2'),('c','a','b','g312','xy3'),('c','a','b','h312','xy4'), +('c','b','a','i321','xy1'),('c','b','a','j321','xy2'),('c','b','a','k321','xy3'),('c','b','a','l321','xy4'), +('c','b','b','m322','xy1'),('c','b','b','n322','xy2'),('c','b','b','o322','xy3'),('c','b','b','p322','xy4'); +create index idx_t3_0 on t3 (a1); +create index idx_t3_1 on t3 (a1,a2,b,c); +create index idx_t3_2 on t3 (a1,a2,b); +analyze table t3; +Table Op Msg_type Msg_text +test.t3 analyze status Table is already up to date +explain select a1,a2,b,c,min(c), max(c) from t1 +where exists ( select * from t2 +where t2.c in (select c from t3 where t3.c > t1.b) and +t2.c > 'b1' ) +group by a1,a2,b; +id select_type table type possible_keys key key_len ref rows Extra +1 PRIMARY t1 range NULL idx_t1_1 147 NULL 17 Using where; Using index for group-by +2 DEPENDENT SUBQUERY t2 index NULL idx_t2_1 163 NULL 164 Using where; Using index +3 DEPENDENT SUBQUERY t3 index NULL idx_t3_1 10 NULL 192 Using where; Using index +select a1,a2,b,c,min(c), max(c) from t1 +where exists ( select * from t2 +where t2.c in (select c from t3 where t3.c > t1.b) and +t2.c > 'b1' ) +group by a1,a2,b; +a1 a2 b c min(c) max(c) +a a a d111 a111 d111 +a a b h112 e112 h112 +a b a l121 i121 l121 +a b b p122 m122 p122 +b a a d211 a211 d211 +b a b h212 e212 h212 +b b a l221 i221 l221 +b b b p222 m222 p222 +c a a d311 a311 d311 +c a b h312 e312 h312 +c b a l321 i321 l321 +c b b p322 m322 p322 +d a a d411 a411 d411 +d a b h412 e412 h412 +d b a l421 i421 l421 +d b b p422 m422 p422 +explain select a1,a2,b,c,min(c), max(c) from t1 +where exists ( select * from t2 +where t2.c in (select c from t3 where t3.c > t1.c) and +t2.c > 'b1' ) +group by a1,a2,b; +id select_type table type possible_keys key key_len ref rows Extra +1 PRIMARY t1 index NULL idx_t1_1 163 NULL 128 Using where; Using index +2 DEPENDENT SUBQUERY t2 index NULL idx_t2_1 163 NULL 164 Using where; Using index +3 DEPENDENT SUBQUERY t3 index NULL idx_t3_1 10 NULL 192 Using where; Using index +select a1,a2,b,c,min(c), max(c) from t1 +where exists ( select * from t2 +where t2.c in (select c from t3 where t3.c > t1.c) and +t2.c > 'b1' ) +group by a1,a2,b; +a1 a2 b c min(c) max(c) +a a a a111 a111 d111 +a a b e112 e112 h112 +a b a i121 i121 l121 +a b b m122 m122 p122 +b a a a211 a211 d211 +b a b e212 e212 h212 +b b a i221 i221 l221 +b b b m222 m222 p222 +c a a a311 a311 d311 +c a b e312 e312 h312 +c b a i321 i321 l321 +c b b m322 m322 o322 +d a a a411 a411 d411 +d a b e412 e412 h412 +d b a i421 i421 l421 +d b b m422 m422 o422 +drop table t1, t2, t3; +# +# From group_by.test +# +# Bug #21174: Index degrades sort performance and +# optimizer does not honor IGNORE INDEX. +# a.k.a WL3527. +# +CREATE TABLE t1 (a INT, b INT, +PRIMARY KEY (a), +KEY i2(a,b)); +INSERT INTO t1 VALUES (1,1),(2,2),(3,3),(4,4),(5,5),(6,6),(7,7),(8,8); +INSERT INTO t1 SELECT a + 8,b FROM t1; +INSERT INTO t1 SELECT a + 16,b FROM t1; +INSERT INTO t1 SELECT a + 32,b FROM t1; +INSERT INTO t1 SELECT a + 64,b FROM t1; +INSERT INTO t1 SELECT a + 128,b FROM t1 limit 16; +ANALYZE TABLE t1; +Table Op Msg_type Msg_text +test.t1 analyze status OK +EXPLAIN SELECT 1 FROM t1 WHERE a IN +(SELECT a FROM t1 USE INDEX (i2) IGNORE INDEX (i2)); +id select_type table type possible_keys key key_len ref rows Extra +1 PRIMARY t1 index NULL PRIMARY 4 NULL 144 Using where; Using index +2 DEPENDENT SUBQUERY t1 ALL NULL NULL NULL NULL 144 Using where +CREATE TABLE t2 (a INT, b INT, KEY(a)); +INSERT INTO t2 VALUES (1, 1), (2, 2), (3,3), (4,4); +EXPLAIN SELECT a, SUM(b) FROM t2 GROUP BY a LIMIT 2; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t2 index NULL a 5 NULL 2 +EXPLAIN SELECT a, SUM(b) FROM t2 IGNORE INDEX (a) GROUP BY a LIMIT 2; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t2 ALL NULL NULL NULL NULL 4 Using temporary; Using filesort +EXPLAIN SELECT 1 FROM t2 WHERE a IN +(SELECT a FROM t1 USE INDEX (i2) IGNORE INDEX (i2)); +id select_type table type possible_keys key key_len ref rows Extra +1 PRIMARY t2 index NULL a 5 NULL 4 Using where; Using index +2 DEPENDENT SUBQUERY t1 ALL NULL NULL NULL NULL 144 Using where +DROP TABLE t1, t2; +# +# From derived_view.test +# +set @tmp_subselect_extra_derived=@@optimizer_switch; +set optimizer_switch='derived_merge=on,derived_with_keys=on'; +# +# LP bug #806504: right join over a view/derived table +# +CREATE TABLE t1 (a int, b int) ; +INSERT INTO t1 VALUES (0,0); +CREATE TABLE t2 (a int) ; +INSERT INTO t2 VALUES (0), (0); +CREATE VIEW v1 AS SELECT * FROM t1; +SELECT * FROM t2 RIGHT JOIN (SELECT * FROM t1) AS t ON t.a != 0 +WHERE t.a IN (SELECT b FROM t1); +a a b +NULL 0 0 +EXPLAIN EXTENDED +SELECT * FROM t2 RIGHT JOIN (SELECT * FROM t1) AS t ON t.a != 0 +WHERE t.a IN (SELECT b FROM t1); +id select_type table type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t1 system NULL NULL NULL NULL 1 100.00 +1 PRIMARY t2 ALL NULL NULL NULL NULL 2 100.00 Using where +3 DEPENDENT SUBQUERY t1 system NULL NULL NULL NULL 1 100.00 +Warnings: +Note 1003 select `test`.`t2`.`a` AS `a`,0 AS `a`,0 AS `b` from `test`.`t2` where <expr_cache><0>(<in_optimizer>(0,<exists>(select 0 from dual where (<cache>(0) = 0)))) +SELECT * FROM t2 RIGHT JOIN v1 AS t ON t.a != 0 +WHERE t.a IN (SELECT b FROM t1); +a a b +NULL 0 0 +EXPLAIN EXTENDED +SELECT * FROM t2 RIGHT JOIN v1 AS t ON t.a != 0 +WHERE t.a IN (SELECT b FROM t1); +id select_type table type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t1 system NULL NULL NULL NULL 1 100.00 +1 PRIMARY t2 ALL NULL NULL NULL NULL 2 100.00 Using where +2 DEPENDENT SUBQUERY t1 system NULL NULL NULL NULL 1 100.00 +Warnings: +Note 1003 select `test`.`t2`.`a` AS `a`,0 AS `a`,0 AS `b` from `test`.`t2` where <expr_cache><0>(<in_optimizer>(0,<exists>(select 0 from dual where (<cache>(0) = 0)))) +DROP VIEW v1; +DROP TABLE t1,t2; +# +# LP bug #793448: materialized view accessed by two-component key +# +CREATE TABLE t1 (a int, b int); +INSERT INTO t1 VALUES (9,3), (2,5); +CREATE TABLE t2 (a int, b int); +INSERT INTO t2 VALUES (9,3), (3,7), (9,1), (2,5), (2,4), (3,8); +CREATE TABLE t3 (a int, b int); +INSERT INTO t3 VALUES (10,3), (9,7), (9,1), (2,4); +CREATE VIEW v1(a,b) AS SELECT a, MAX(b) FROM t2 GROUP BY a; +CREATE VIEW v2(a,b) AS SELECT a,b FROM t2 UNION SELECT a,b FROM t3; +SELECT * FROM v1; +a b +2 5 +3 8 +9 3 +SELECT a FROM t1 WHERE (a,b) IN (SELECT * FROM v1); +a +9 +2 +EXPLAIN +SELECT a FROM t1 WHERE (a,b) IN (SELECT * FROM v1); +id select_type table type possible_keys key key_len ref rows Extra +1 PRIMARY t1 ALL NULL NULL NULL NULL 2 Using where +2 DEPENDENT SUBQUERY <derived3> index_subquery key0 key0 10 func,func 2 Using where +3 DERIVED t2 ALL NULL NULL NULL NULL 6 Using temporary; Using filesort +SELECT * FROM v2; +a b +9 3 +3 7 +9 1 +2 5 +2 4 +3 8 +10 3 +9 7 +SELECT a FROM t1 WHERE (a,b) IN (SELECT * FROM v2); +a +9 +2 +EXPLAIN +SELECT a FROM t1 WHERE (a,b) IN (SELECT * FROM v2); +id select_type table type possible_keys key key_len ref rows Extra +1 PRIMARY t1 ALL NULL NULL NULL NULL 2 Using where +2 DEPENDENT SUBQUERY <derived3> index_subquery key0 key0 10 func,func 2 Using where +3 DERIVED t2 ALL NULL NULL NULL NULL 6 +4 UNION t3 ALL NULL NULL NULL NULL 4 +NULL UNION RESULT <union3,4> ALL NULL NULL NULL NULL NULL +DROP VIEW v1,v2; +DROP TABLE t1,t2,t3; +# +# LP bug #874006: materialized view used in IN subquery +# +CREATE TABLE t3 (a int NOT NULL, b varchar(1), c varchar(1)); +INSERT INTO t3 VALUES (19,NULL,NULL), (20,'r','r'); +CREATE TABLE t1 (a int, b varchar(1) , c varchar(1)); +INSERT INTO t1 VALUES (1,NULL,NULL), (5,'r','r'), (7,'y','y'); +CREATE TABLE t2 (a int NOT NULL , b int, c varchar(1)); +INSERT INTO t2 VALUES (4,3,'r'); +CREATE ALGORITHM=TEMPTABLE VIEW v1 AS SELECT * FROM t1; +SET SESSION optimizer_switch='derived_with_keys=off'; +EXPLAIN +SELECT * FROM t3 +WHERE t3.b IN (SELECT v1.b FROM v1, t2 +WHERE t2.c = v1.c AND t2.c = v1.b AND v1.b = t3.c); +id select_type table type possible_keys key key_len ref rows Extra +1 PRIMARY t3 ALL NULL NULL NULL NULL 2 Using where +2 DEPENDENT SUBQUERY t2 system NULL NULL NULL NULL 1 +2 DEPENDENT SUBQUERY <derived3> ALL NULL NULL NULL NULL 3 Using where +3 DERIVED t1 ALL NULL NULL NULL NULL 3 +SELECT * FROM t3 +WHERE t3.b IN (SELECT v1.b FROM v1, t2 +WHERE t2.c = v1.c AND t2.c = v1.b AND v1.b = t3.c); +a b c +20 r r +SET SESSION optimizer_switch='derived_with_keys=on'; +EXPLAIN +SELECT * FROM t3 +WHERE t3.b IN (SELECT v1.b FROM v1, t2 +WHERE t2.c = v1.c AND t2.c = v1.b AND v1.b = t3.c); +id select_type table type possible_keys key key_len ref rows Extra +1 PRIMARY t3 ALL NULL NULL NULL NULL 2 Using where +2 DEPENDENT SUBQUERY t2 system NULL NULL NULL NULL 1 +2 DEPENDENT SUBQUERY <derived3> ref key1 key1 10 const,const 0 Using where +3 DERIVED t1 ALL NULL NULL NULL NULL 3 +SELECT * FROM t3 +WHERE t3.b IN (SELECT v1.b FROM v1, t2 +WHERE t2.c = v1.c AND t2.c = v1.b AND v1.b = t3.c); +a b c +20 r r +DROP VIEW v1; +DROP TABLE t1,t2,t3; +# +# LP bug #873263: materialized view used in correlated IN subquery +# +CREATE TABLE t1 (a int, b int) ; +INSERT INTO t1 VALUES (5,4), (9,8); +CREATE TABLE t2 (a int, b int) ; +INSERT INTO t2 VALUES (4,5), (5,1); +CREATE ALGORITHM=TEMPTABLE VIEW v2 AS SELECT * FROM t2; +SET SESSION optimizer_switch='derived_with_keys=on'; +EXPLAIN +SELECT * FROM t1 WHERE t1.b IN (SELECT v2.a FROM v2 WHERE v2.b = t1.a); +id select_type table type possible_keys key key_len ref rows Extra +1 PRIMARY t1 ALL NULL NULL NULL NULL 2 Using where +2 DEPENDENT SUBQUERY <derived3> ref key0 key0 5 test.t1.a 2 Using where +3 DERIVED t2 ALL NULL NULL NULL NULL 2 +SELECT * FROM t1 WHERE t1.b IN (SELECT v2.a FROM v2 WHERE v2.b = t1.a); +a b +5 4 +DROP VIEW v2; +DROP TABLE t1,t2; +set optimizer_switch= @tmp_subselect_extra_derived; +set optimizer_switch= @subselect_extra_no_sj_tmp; +set @optimizer_switch_for_subselect_extra_test=null; diff --git a/mysql-test/r/subselect_innodb.result b/mysql-test/r/subselect_innodb.result index 68cfdff775b..b134e849bbe 100644 --- a/mysql-test/r/subselect_innodb.result +++ b/mysql-test/r/subselect_innodb.result @@ -258,4 +258,62 @@ a b Warnings: Warning 1292 Incorrect datetime value: '0' DROP TABLE t1; +# +# lp:827416 Crash in select_describe() on EXPLAIN with DISTINCT in nested subqueries +# +CREATE TABLE t3 ( b int) ENGINE=InnoDB; +CREATE TABLE t2 ( c int) ENGINE=InnoDB; +CREATE TABLE t1 ( a int NOT NULL , PRIMARY KEY (a)) ENGINE=InnoDB; +EXPLAIN SELECT * +FROM t1 +WHERE t1.a = ( +SELECT SUM( c ) +FROM t2 +WHERE (SELECT DISTINCT b FROM t3) > 0); +id select_type table type possible_keys key key_len ref rows Extra +1 PRIMARY t1 const PRIMARY PRIMARY 4 const 1 Using where; Using index +2 SUBQUERY t2 ALL NULL NULL NULL NULL 1 +3 SUBQUERY t3 ALL NULL NULL NULL NULL 1 Using temporary +SELECT * +FROM t1 +WHERE t1.a = ( +SELECT SUM( c ) +FROM t2 +WHERE (SELECT DISTINCT b FROM t3) > 0); +a +DROP TABLE t1, t2, t3; +# +# lp:858148 Fourth crash in select_describe() with nested subqueries +# +CREATE TABLE t1 ( f1 int(11)) ENGINE=InnoDB; +CREATE TABLE t2 ( f1 int(11), f2 int(11), PRIMARY KEY (f1)) ; +CREATE TABLE t3 ( f3 int(11)) ENGINE=InnoDB; +EXPLAIN +SELECT MAX( f1 ) FROM t2 +WHERE f2 >= ( +SELECT SUM( f1 ) +FROM t1 +WHERE EXISTS ( +SELECT f3 +FROM t3 +GROUP BY 1 +) +); +id select_type table type possible_keys key key_len ref rows Extra +1 PRIMARY NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables +2 SUBQUERY t1 ALL NULL NULL NULL NULL 1 +3 SUBQUERY t3 ALL NULL NULL NULL NULL 1 Using temporary; Using filesort +SELECT MAX( f1 ) FROM t2 +WHERE f2 >= ( +SELECT SUM( f1 ) +FROM t1 +WHERE EXISTS ( +SELECT f3 +FROM t3 +GROUP BY 1 +) +); +MAX( f1 ) +NULL +drop table t1, t2, t3; set optimizer_switch=@subselect_innodb_tmp; diff --git a/mysql-test/r/subselect_mat.result b/mysql-test/r/subselect_mat.result index f240c2ba492..d155a2cd3a8 100644 --- a/mysql-test/r/subselect_mat.result +++ b/mysql-test/r/subselect_mat.result @@ -1,9 +1,9 @@ set @subselect_mat_test_optimizer_switch_value='materialization=on,in_to_exists=off,semijoin=off'; set @subselect_sj_mat_tmp= @@optimizer_switch; -set optimizer_switch=ifnull(@subselect_mat_test_optimizer_switch_value, 'semijoin=on,firstmatch=on,loosescan=on'); +set optimizer_switch=ifnull(@subselect_mat_test_optimizer_switch_value, 'semijoin=on,firstmatch=on,loosescan=on,semijoin_with_cache=on'); set optimizer_switch='mrr=on,mrr_sort_keys=on,index_condition_pushdown=on'; set @optimizer_switch_local_default= @@optimizer_switch; -drop table if exists t1, t2, t3, t1i, t2i, t3i; +drop table if exists t1, t2, t3, t4, t5, t1i, t2i, t3i; drop table if exists columns; drop table if exists t1_16, t2_16, t3_16; drop view if exists v1, v2, v1m, v2m; @@ -48,7 +48,7 @@ id select_type table type possible_keys key key_len ref rows filtered Extra 1 PRIMARY t1 ALL NULL NULL NULL NULL 3 100.00 Using where 2 SUBQUERY t2 ALL NULL NULL NULL NULL 5 100.00 Using where Warnings: -Note 1003 select `test`.`t1`.`a1` AS `a1`,`test`.`t1`.`a2` AS `a2` from `test`.`t1` where <in_optimizer>(`test`.`t1`.`a1`,`test`.`t1`.`a1` in ( <materialize> (select `test`.`t2`.`b1` from `test`.`t2` where (`test`.`t2`.`b1` > '0') ), <primary_index_lookup>(`test`.`t1`.`a1` in <temporary table> on distinct_key where ((`test`.`t1`.`a1` = `<subquery2>`.`b1`))))) +Note 1003 select `test`.`t1`.`a1` AS `a1`,`test`.`t1`.`a2` AS `a2` from `test`.`t1` where <expr_cache><`test`.`t1`.`a1`>(<in_optimizer>(`test`.`t1`.`a1`,`test`.`t1`.`a1` in ( <materialize> (select `test`.`t2`.`b1` from `test`.`t2` where (`test`.`t2`.`b1` > '0') ), <primary_index_lookup>(`test`.`t1`.`a1` in <temporary table> on distinct_key where ((`test`.`t1`.`a1` = `<subquery2>`.`b1`)))))) select * from t1 where a1 in (select b1 from t2 where b1 > '0'); a1 a2 1 - 01 2 - 01 @@ -59,7 +59,7 @@ id select_type table type possible_keys key key_len ref rows filtered Extra 1 PRIMARY t1 ALL NULL NULL NULL NULL 3 100.00 Using where 2 SUBQUERY t2 ALL NULL NULL NULL NULL 5 100.00 Using where; Using temporary Warnings: -Note 1003 select `test`.`t1`.`a1` AS `a1`,`test`.`t1`.`a2` AS `a2` from `test`.`t1` where <in_optimizer>(`test`.`t1`.`a1`,`test`.`t1`.`a1` in ( <materialize> (select `test`.`t2`.`b1` from `test`.`t2` where (`test`.`t2`.`b1` > '0') group by `test`.`t2`.`b1` ), <primary_index_lookup>(`test`.`t1`.`a1` in <temporary table> on distinct_key where ((`test`.`t1`.`a1` = `<subquery2>`.`b1`))))) +Note 1003 select `test`.`t1`.`a1` AS `a1`,`test`.`t1`.`a2` AS `a2` from `test`.`t1` where <expr_cache><`test`.`t1`.`a1`>(<in_optimizer>(`test`.`t1`.`a1`,`test`.`t1`.`a1` in ( <materialize> (select `test`.`t2`.`b1` from `test`.`t2` where (`test`.`t2`.`b1` > '0') group by `test`.`t2`.`b1` ), <primary_index_lookup>(`test`.`t1`.`a1` in <temporary table> on distinct_key where ((`test`.`t1`.`a1` = `<subquery2>`.`b1`)))))) select * from t1 where a1 in (select b1 from t2 where b1 > '0' group by b1); a1 a2 1 - 01 2 - 01 @@ -70,7 +70,7 @@ id select_type table type possible_keys key key_len ref rows filtered Extra 1 PRIMARY t1 ALL NULL NULL NULL NULL 3 100.00 Using where 2 SUBQUERY t2 ALL NULL NULL NULL NULL 5 100.00 Using where; Using temporary Warnings: -Note 1003 select `test`.`t1`.`a1` AS `a1`,`test`.`t1`.`a2` AS `a2` from `test`.`t1` where <in_optimizer>((`test`.`t1`.`a1`,`test`.`t1`.`a2`),(`test`.`t1`.`a1`,`test`.`t1`.`a2`) in ( <materialize> (select `test`.`t2`.`b1`,`test`.`t2`.`b2` from `test`.`t2` where (`test`.`t2`.`b1` > '0') group by `test`.`t2`.`b1`,`test`.`t2`.`b2` ), <primary_index_lookup>(`test`.`t1`.`a1` in <temporary table> on distinct_key where ((`test`.`t1`.`a1` = `<subquery2>`.`b1`) and (`test`.`t1`.`a2` = `<subquery2>`.`b2`))))) +Note 1003 select `test`.`t1`.`a1` AS `a1`,`test`.`t1`.`a2` AS `a2` from `test`.`t1` where <expr_cache><`test`.`t1`.`a1`,`test`.`t1`.`a2`>(<in_optimizer>((`test`.`t1`.`a1`,`test`.`t1`.`a2`),(`test`.`t1`.`a1`,`test`.`t1`.`a2`) in ( <materialize> (select `test`.`t2`.`b1`,`test`.`t2`.`b2` from `test`.`t2` where (`test`.`t2`.`b1` > '0') group by `test`.`t2`.`b1`,`test`.`t2`.`b2` ), <primary_index_lookup>(`test`.`t1`.`a1` in <temporary table> on distinct_key where ((`test`.`t1`.`a1` = `<subquery2>`.`b1`) and (`test`.`t1`.`a2` = `<subquery2>`.`b2`)))))) select * from t1 where (a1, a2) in (select b1, b2 from t2 where b1 > '0' group by b1, b2); a1 a2 1 - 01 2 - 01 @@ -81,7 +81,7 @@ id select_type table type possible_keys key key_len ref rows filtered Extra 1 PRIMARY t1 ALL NULL NULL NULL NULL 3 100.00 Using where 2 SUBQUERY t2 ALL NULL NULL NULL NULL 5 100.00 Using where; Using temporary Warnings: -Note 1003 select `test`.`t1`.`a1` AS `a1`,`test`.`t1`.`a2` AS `a2` from `test`.`t1` where <in_optimizer>((`test`.`t1`.`a1`,`test`.`t1`.`a2`),(`test`.`t1`.`a1`,`test`.`t1`.`a2`) in ( <materialize> (select `test`.`t2`.`b1`,min(`test`.`t2`.`b2`) from `test`.`t2` where (`test`.`t2`.`b1` > '0') group by `test`.`t2`.`b1` ), <primary_index_lookup>(`test`.`t1`.`a1` in <temporary table> on distinct_key where ((`test`.`t1`.`a1` = `<subquery2>`.`b1`) and (`test`.`t1`.`a2` = `<subquery2>`.`min(b2)`))))) +Note 1003 select `test`.`t1`.`a1` AS `a1`,`test`.`t1`.`a2` AS `a2` from `test`.`t1` where <expr_cache><`test`.`t1`.`a1`,`test`.`t1`.`a2`>(<in_optimizer>((`test`.`t1`.`a1`,`test`.`t1`.`a2`),(`test`.`t1`.`a1`,`test`.`t1`.`a2`) in ( <materialize> (select `test`.`t2`.`b1`,min(`test`.`t2`.`b2`) from `test`.`t2` where (`test`.`t2`.`b1` > '0') group by `test`.`t2`.`b1` ), <primary_index_lookup>(`test`.`t1`.`a1` in <temporary table> on distinct_key where ((`test`.`t1`.`a1` = `<subquery2>`.`b1`) and (`test`.`t1`.`a2` = `<subquery2>`.`min(b2)`)))))) select * from t1 where (a1, a2) in (select b1, min(b2) from t2 where b1 > '0' group by b1); a1 a2 1 - 01 2 - 01 @@ -92,7 +92,7 @@ id select_type table type possible_keys key key_len ref rows filtered Extra 1 PRIMARY t1i index NULL _it1_idx # NULL 3 100.00 Using where; 2 SUBQUERY t2i index it2i1,it2i3 it2i1 # NULL 5 100.00 Using where; Warnings: -Note 1003 select `test`.`t1i`.`a1` AS `a1`,`test`.`t1i`.`a2` AS `a2` from `test`.`t1i` where <in_optimizer>(`test`.`t1i`.`a1`,`test`.`t1i`.`a1` in ( <materialize> (select `test`.`t2i`.`b1` from `test`.`t2i` where (`test`.`t2i`.`b1` > '0') ), <primary_index_lookup>(`test`.`t1i`.`a1` in <temporary table> on distinct_key where ((`test`.`t1i`.`a1` = `<subquery2>`.`b1`))))) +Note 1003 select `test`.`t1i`.`a1` AS `a1`,`test`.`t1i`.`a2` AS `a2` from `test`.`t1i` where <expr_cache><`test`.`t1i`.`a1`>(<in_optimizer>(`test`.`t1i`.`a1`,`test`.`t1i`.`a1` in ( <materialize> (select `test`.`t2i`.`b1` from `test`.`t2i` where (`test`.`t2i`.`b1` > '0') ), <primary_index_lookup>(`test`.`t1i`.`a1` in <temporary table> on distinct_key where ((`test`.`t1i`.`a1` = `<subquery2>`.`b1`)))))) select * from t1i where a1 in (select b1 from t2i where b1 > '0'); a1 a2 1 - 01 2 - 01 @@ -103,7 +103,7 @@ id select_type table type possible_keys key key_len ref rows filtered Extra 1 PRIMARY t1i index NULL # 18 # 3 100.00 # 2 SUBQUERY t2i range it2i1,it2i3 # 9 # 3 100.00 # Warnings: -Note 1003 select `test`.`t1i`.`a1` AS `a1`,`test`.`t1i`.`a2` AS `a2` from `test`.`t1i` where <in_optimizer>(`test`.`t1i`.`a1`,`test`.`t1i`.`a1` in ( <materialize> (select `test`.`t2i`.`b1` from `test`.`t2i` where (`test`.`t2i`.`b1` > '0') group by `test`.`t2i`.`b1` ), <primary_index_lookup>(`test`.`t1i`.`a1` in <temporary table> on distinct_key where ((`test`.`t1i`.`a1` = `<subquery2>`.`b1`))))) +Note 1003 select `test`.`t1i`.`a1` AS `a1`,`test`.`t1i`.`a2` AS `a2` from `test`.`t1i` where <expr_cache><`test`.`t1i`.`a1`>(<in_optimizer>(`test`.`t1i`.`a1`,`test`.`t1i`.`a1` in ( <materialize> (select `test`.`t2i`.`b1` from `test`.`t2i` where (`test`.`t2i`.`b1` > '0') group by `test`.`t2i`.`b1` ), <primary_index_lookup>(`test`.`t1i`.`a1` in <temporary table> on distinct_key where ((`test`.`t1i`.`a1` = `<subquery2>`.`b1`)))))) select * from t1i where a1 in (select b1 from t2i where b1 > '0' group by b1); a1 a2 1 - 01 2 - 01 @@ -114,7 +114,7 @@ id select_type table type possible_keys key key_len ref rows filtered Extra 1 PRIMARY t1i index NULL _it1_idx # NULL 3 100.00 Using where; 2 SUBQUERY t2i index it2i1,it2i3 it2i3 # NULL 5 100.00 Using where; Warnings: -Note 1003 select `test`.`t1i`.`a1` AS `a1`,`test`.`t1i`.`a2` AS `a2` from `test`.`t1i` where <in_optimizer>((`test`.`t1i`.`a1`,`test`.`t1i`.`a2`),(`test`.`t1i`.`a1`,`test`.`t1i`.`a2`) in ( <materialize> (select `test`.`t2i`.`b1`,`test`.`t2i`.`b2` from `test`.`t2i` where (`test`.`t2i`.`b1` > '0') ), <primary_index_lookup>(`test`.`t1i`.`a1` in <temporary table> on distinct_key where ((`test`.`t1i`.`a1` = `<subquery2>`.`b1`) and (`test`.`t1i`.`a2` = `<subquery2>`.`b2`))))) +Note 1003 select `test`.`t1i`.`a1` AS `a1`,`test`.`t1i`.`a2` AS `a2` from `test`.`t1i` where <expr_cache><`test`.`t1i`.`a1`,`test`.`t1i`.`a2`>(<in_optimizer>((`test`.`t1i`.`a1`,`test`.`t1i`.`a2`),(`test`.`t1i`.`a1`,`test`.`t1i`.`a2`) in ( <materialize> (select `test`.`t2i`.`b1`,`test`.`t2i`.`b2` from `test`.`t2i` where (`test`.`t2i`.`b1` > '0') ), <primary_index_lookup>(`test`.`t1i`.`a1` in <temporary table> on distinct_key where ((`test`.`t1i`.`a1` = `<subquery2>`.`b1`) and (`test`.`t1i`.`a2` = `<subquery2>`.`b2`)))))) select * from t1i where (a1, a2) in (select b1, b2 from t2i where b1 > '0'); a1 a2 1 - 01 2 - 01 @@ -125,7 +125,7 @@ id select_type table type possible_keys key key_len ref rows filtered Extra 1 PRIMARY t1i index NULL # # # 3 100.00 # 2 SUBQUERY t2i range it2i1,it2i3 # # # 3 100.00 # Warnings: -Note 1003 select `test`.`t1i`.`a1` AS `a1`,`test`.`t1i`.`a2` AS `a2` from `test`.`t1i` where <in_optimizer>((`test`.`t1i`.`a1`,`test`.`t1i`.`a2`),(`test`.`t1i`.`a1`,`test`.`t1i`.`a2`) in ( <materialize> (select `test`.`t2i`.`b1`,`test`.`t2i`.`b2` from `test`.`t2i` where (`test`.`t2i`.`b1` > '0') group by `test`.`t2i`.`b1`,`test`.`t2i`.`b2` ), <primary_index_lookup>(`test`.`t1i`.`a1` in <temporary table> on distinct_key where ((`test`.`t1i`.`a1` = `<subquery2>`.`b1`) and (`test`.`t1i`.`a2` = `<subquery2>`.`b2`))))) +Note 1003 select `test`.`t1i`.`a1` AS `a1`,`test`.`t1i`.`a2` AS `a2` from `test`.`t1i` where <expr_cache><`test`.`t1i`.`a1`,`test`.`t1i`.`a2`>(<in_optimizer>((`test`.`t1i`.`a1`,`test`.`t1i`.`a2`),(`test`.`t1i`.`a1`,`test`.`t1i`.`a2`) in ( <materialize> (select `test`.`t2i`.`b1`,`test`.`t2i`.`b2` from `test`.`t2i` where (`test`.`t2i`.`b1` > '0') group by `test`.`t2i`.`b1`,`test`.`t2i`.`b2` ), <primary_index_lookup>(`test`.`t1i`.`a1` in <temporary table> on distinct_key where ((`test`.`t1i`.`a1` = `<subquery2>`.`b1`) and (`test`.`t1i`.`a2` = `<subquery2>`.`b2`)))))) select * from t1i where (a1, a2) in (select b1, b2 from t2i where b1 > '0' group by b1, b2); a1 a2 1 - 01 2 - 01 @@ -136,7 +136,7 @@ id select_type table type possible_keys key key_len ref rows filtered Extra 1 PRIMARY t1i index NULL # # # 3 100.00 # 2 SUBQUERY t2i range it2i1,it2i3 # # # 3 100.00 # Warnings: -Note 1003 select `test`.`t1i`.`a1` AS `a1`,`test`.`t1i`.`a2` AS `a2` from `test`.`t1i` where <in_optimizer>((`test`.`t1i`.`a1`,`test`.`t1i`.`a2`),(`test`.`t1i`.`a1`,`test`.`t1i`.`a2`) in ( <materialize> (select `test`.`t2i`.`b1`,min(`test`.`t2i`.`b2`) from `test`.`t2i` where (`test`.`t2i`.`b1` > '0') group by `test`.`t2i`.`b1` ), <primary_index_lookup>(`test`.`t1i`.`a1` in <temporary table> on distinct_key where ((`test`.`t1i`.`a1` = `<subquery2>`.`b1`) and (`test`.`t1i`.`a2` = `<subquery2>`.`min(b2)`))))) +Note 1003 select `test`.`t1i`.`a1` AS `a1`,`test`.`t1i`.`a2` AS `a2` from `test`.`t1i` where <expr_cache><`test`.`t1i`.`a1`,`test`.`t1i`.`a2`>(<in_optimizer>((`test`.`t1i`.`a1`,`test`.`t1i`.`a2`),(`test`.`t1i`.`a1`,`test`.`t1i`.`a2`) in ( <materialize> (select `test`.`t2i`.`b1`,min(`test`.`t2i`.`b2`) from `test`.`t2i` where (`test`.`t2i`.`b1` > '0') group by `test`.`t2i`.`b1` ), <primary_index_lookup>(`test`.`t1i`.`a1` in <temporary table> on distinct_key where ((`test`.`t1i`.`a1` = `<subquery2>`.`b1`) and (`test`.`t1i`.`a2` = `<subquery2>`.`min(b2)`)))))) select * from t1i where (a1, a2) in (select b1, min(b2) from t2i where b1 > '0' group by b1); a1 a2 1 - 01 2 - 01 @@ -147,7 +147,7 @@ id select_type table type possible_keys key key_len ref rows filtered Extra 1 PRIMARY t1 ALL NULL NULL NULL NULL 3 100.00 Using where 2 SUBQUERY t2i range NULL it2i3 9 NULL 3 100.00 Using index for group-by Warnings: -Note 1003 select `test`.`t1`.`a1` AS `a1`,`test`.`t1`.`a2` AS `a2` from `test`.`t1` where <in_optimizer>((`test`.`t1`.`a1`,`test`.`t1`.`a2`),(`test`.`t1`.`a1`,`test`.`t1`.`a2`) in ( <materialize> (select `test`.`t2i`.`b1`,max(`test`.`t2i`.`b2`) from `test`.`t2i` group by `test`.`t2i`.`b1` ), <primary_index_lookup>(`test`.`t1`.`a1` in <temporary table> on distinct_key where ((`test`.`t1`.`a1` = `<subquery2>`.`b1`) and (`test`.`t1`.`a2` = `<subquery2>`.`max(b2)`))))) +Note 1003 select `test`.`t1`.`a1` AS `a1`,`test`.`t1`.`a2` AS `a2` from `test`.`t1` where <expr_cache><`test`.`t1`.`a1`,`test`.`t1`.`a2`>(<in_optimizer>((`test`.`t1`.`a1`,`test`.`t1`.`a2`),(`test`.`t1`.`a1`,`test`.`t1`.`a2`) in ( <materialize> (select `test`.`t2i`.`b1`,max(`test`.`t2i`.`b2`) from `test`.`t2i` group by `test`.`t2i`.`b1` ), <primary_index_lookup>(`test`.`t1`.`a1` in <temporary table> on distinct_key where ((`test`.`t1`.`a1` = `<subquery2>`.`b1`) and (`test`.`t1`.`a2` = `<subquery2>`.`max(b2)`)))))) select * from t1 where (a1, a2) in (select b1, max(b2) from t2i group by b1); a1 a2 1 - 01 2 - 01 @@ -176,7 +176,7 @@ id select_type table type possible_keys key key_len ref rows filtered Extra 1 PRIMARY t1 ALL NULL NULL NULL NULL 3 100.00 Using where 2 SUBQUERY t2i range it2i1,it2i3 it2i3 18 NULL 3 100.00 Using where; Using index for group-by Warnings: -Note 1003 select `test`.`t1`.`a1` AS `a1`,`test`.`t1`.`a2` AS `a2` from `test`.`t1` where <in_optimizer>((`test`.`t1`.`a1`,`test`.`t1`.`a2`),(`test`.`t1`.`a1`,`test`.`t1`.`a2`) in ( <materialize> (select `test`.`t2i`.`b1`,min(`test`.`t2i`.`b2`) from `test`.`t2i` where (`test`.`t2i`.`b1` > '0') group by `test`.`t2i`.`b1` ), <primary_index_lookup>(`test`.`t1`.`a1` in <temporary table> on distinct_key where ((`test`.`t1`.`a1` = `<subquery2>`.`b1`) and (`test`.`t1`.`a2` = `<subquery2>`.`min(b2)`))))) +Note 1003 select `test`.`t1`.`a1` AS `a1`,`test`.`t1`.`a2` AS `a2` from `test`.`t1` where <expr_cache><`test`.`t1`.`a1`,`test`.`t1`.`a2`>(<in_optimizer>((`test`.`t1`.`a1`,`test`.`t1`.`a2`),(`test`.`t1`.`a1`,`test`.`t1`.`a2`) in ( <materialize> (select `test`.`t2i`.`b1`,min(`test`.`t2i`.`b2`) from `test`.`t2i` where (`test`.`t2i`.`b1` > '0') group by `test`.`t2i`.`b1` ), <primary_index_lookup>(`test`.`t1`.`a1` in <temporary table> on distinct_key where ((`test`.`t1`.`a1` = `<subquery2>`.`b1`) and (`test`.`t1`.`a2` = `<subquery2>`.`min(b2)`)))))) select * from t1 where (a1, a2) in (select b1, min(b2) from t2i where b1 > '0' group by b1); a1 a2 1 - 01 2 - 01 @@ -223,7 +223,7 @@ id select_type table type possible_keys key key_len ref rows filtered Extra 1 PRIMARY t1 ALL NULL NULL NULL NULL 3 100.00 Using where 2 SUBQUERY t2 ALL NULL NULL NULL NULL 5 100.00 Warnings: -Note 1003 select `test`.`t1`.`a1` AS `a1`,`test`.`t1`.`a2` AS `a2` from `test`.`t1` where <in_optimizer>((`test`.`t1`.`a1`,`test`.`t1`.`a2`),(`test`.`t1`.`a1`,`test`.`t1`.`a2`) in ( <materialize> (select `test`.`t2`.`b1`,`test`.`t2`.`b2` from `test`.`t2` order by `test`.`t2`.`b1`,`test`.`t2`.`b2` ), <primary_index_lookup>(`test`.`t1`.`a1` in <temporary table> on distinct_key where ((`test`.`t1`.`a1` = `<subquery2>`.`b1`) and (`test`.`t1`.`a2` = `<subquery2>`.`b2`))))) +Note 1003 select `test`.`t1`.`a1` AS `a1`,`test`.`t1`.`a2` AS `a2` from `test`.`t1` where <expr_cache><`test`.`t1`.`a1`,`test`.`t1`.`a2`>(<in_optimizer>((`test`.`t1`.`a1`,`test`.`t1`.`a2`),(`test`.`t1`.`a1`,`test`.`t1`.`a2`) in ( <materialize> (select `test`.`t2`.`b1`,`test`.`t2`.`b2` from `test`.`t2` order by `test`.`t2`.`b1`,`test`.`t2`.`b2` ), <primary_index_lookup>(`test`.`t1`.`a1` in <temporary table> on distinct_key where ((`test`.`t1`.`a1` = `<subquery2>`.`b1`) and (`test`.`t1`.`a2` = `<subquery2>`.`b2`)))))) select * from t1 where (a1, a2) in (select b1, b2 from t2 order by b1, b2); a1 a2 1 - 01 2 - 01 @@ -234,7 +234,7 @@ id select_type table type possible_keys key key_len ref rows filtered Extra 1 PRIMARY t1i index NULL it1i3 18 NULL 3 100.00 Using where; Using index 2 SUBQUERY t2i index NULL it2i3 18 NULL 5 100.00 Using index Warnings: -Note 1003 select `test`.`t1i`.`a1` AS `a1`,`test`.`t1i`.`a2` AS `a2` from `test`.`t1i` where <in_optimizer>((`test`.`t1i`.`a1`,`test`.`t1i`.`a2`),(`test`.`t1i`.`a1`,`test`.`t1i`.`a2`) in ( <materialize> (select `test`.`t2i`.`b1`,`test`.`t2i`.`b2` from `test`.`t2i` order by `test`.`t2i`.`b1`,`test`.`t2i`.`b2` ), <primary_index_lookup>(`test`.`t1i`.`a1` in <temporary table> on distinct_key where ((`test`.`t1i`.`a1` = `<subquery2>`.`b1`) and (`test`.`t1i`.`a2` = `<subquery2>`.`b2`))))) +Note 1003 select `test`.`t1i`.`a1` AS `a1`,`test`.`t1i`.`a2` AS `a2` from `test`.`t1i` where <expr_cache><`test`.`t1i`.`a1`,`test`.`t1i`.`a2`>(<in_optimizer>((`test`.`t1i`.`a1`,`test`.`t1i`.`a2`),(`test`.`t1i`.`a1`,`test`.`t1i`.`a2`) in ( <materialize> (select `test`.`t2i`.`b1`,`test`.`t2i`.`b2` from `test`.`t2i` order by `test`.`t2i`.`b1`,`test`.`t2i`.`b2` ), <primary_index_lookup>(`test`.`t1i`.`a1` in <temporary table> on distinct_key where ((`test`.`t1i`.`a1` = `<subquery2>`.`b1`) and (`test`.`t1i`.`a2` = `<subquery2>`.`b2`)))))) select * from t1i where (a1, a2) in (select b1, b2 from t2i order by b1, b2); a1 a2 1 - 01 2 - 01 @@ -289,7 +289,7 @@ id select_type table type possible_keys key key_len ref rows filtered Extra 4 SUBQUERY t2i index it2i2 it2i3 18 NULL 5 100.00 Using where; Using index 2 SUBQUERY t2 ALL NULL NULL NULL NULL 5 100.00 Using where Warnings: -Note 1003 select `test`.`t1`.`a1` AS `a1`,`test`.`t1`.`a2` AS `a2` from `test`.`t1` where (<in_optimizer>((`test`.`t1`.`a1`,`test`.`t1`.`a2`),(`test`.`t1`.`a1`,`test`.`t1`.`a2`) in ( <materialize> (select `test`.`t2`.`b1`,`test`.`t2`.`b2` from `test`.`t2` where (`test`.`t2`.`b1` > '0') ), <primary_index_lookup>(`test`.`t1`.`a1` in <temporary table> on distinct_key where ((`test`.`t1`.`a1` = `<subquery2>`.`b1`) and (`test`.`t1`.`a2` = `<subquery2>`.`b2`))))) and <in_optimizer>((`test`.`t1`.`a1`,`test`.`t1`.`a2`),(`test`.`t1`.`a1`,`test`.`t1`.`a2`) in ( <materialize> (select `test`.`t3`.`c1`,`test`.`t3`.`c2` from `test`.`t3` where <in_optimizer>((`test`.`t3`.`c1`,`test`.`t3`.`c2`),(`test`.`t3`.`c1`,`test`.`t3`.`c2`) in ( <materialize> (select `test`.`t2i`.`b1`,`test`.`t2i`.`b2` from `test`.`t2i` where (`test`.`t2i`.`b2` > '0') ), <primary_index_lookup>(`test`.`t3`.`c1` in <temporary table> on distinct_key where ((`test`.`t3`.`c1` = `<subquery4>`.`b1`) and (`test`.`t3`.`c2` = `<subquery4>`.`b2`))))) ), <primary_index_lookup>(`test`.`t1`.`a1` in <temporary table> on distinct_key where ((`test`.`t1`.`a1` = `<subquery3>`.`c1`) and (`test`.`t1`.`a2` = `<subquery3>`.`c2`)))))) +Note 1003 select `test`.`t1`.`a1` AS `a1`,`test`.`t1`.`a2` AS `a2` from `test`.`t1` where (<expr_cache><`test`.`t1`.`a1`,`test`.`t1`.`a2`>(<in_optimizer>((`test`.`t1`.`a1`,`test`.`t1`.`a2`),(`test`.`t1`.`a1`,`test`.`t1`.`a2`) in ( <materialize> (select `test`.`t2`.`b1`,`test`.`t2`.`b2` from `test`.`t2` where (`test`.`t2`.`b1` > '0') ), <primary_index_lookup>(`test`.`t1`.`a1` in <temporary table> on distinct_key where ((`test`.`t1`.`a1` = `<subquery2>`.`b1`) and (`test`.`t1`.`a2` = `<subquery2>`.`b2`)))))) and <expr_cache><`test`.`t1`.`a1`,`test`.`t1`.`a2`>(<in_optimizer>((`test`.`t1`.`a1`,`test`.`t1`.`a2`),(`test`.`t1`.`a1`,`test`.`t1`.`a2`) in ( <materialize> (select `test`.`t3`.`c1`,`test`.`t3`.`c2` from `test`.`t3` where <expr_cache><`test`.`t3`.`c1`,`test`.`t3`.`c2`>(<in_optimizer>((`test`.`t3`.`c1`,`test`.`t3`.`c2`),(`test`.`t3`.`c1`,`test`.`t3`.`c2`) in ( <materialize> (select `test`.`t2i`.`b1`,`test`.`t2i`.`b2` from `test`.`t2i` where (`test`.`t2i`.`b2` > '0') ), <primary_index_lookup>(`test`.`t3`.`c1` in <temporary table> on distinct_key where ((`test`.`t3`.`c1` = `<subquery4>`.`b1`) and (`test`.`t3`.`c2` = `<subquery4>`.`b2`)))))) ), <primary_index_lookup>(`test`.`t1`.`a1` in <temporary table> on distinct_key where ((`test`.`t1`.`a1` = `<subquery3>`.`c1`) and (`test`.`t1`.`a2` = `<subquery3>`.`c2`))))))) select * from t1 where (a1, a2) in (select b1, b2 from t2 where b1 > '0') and (a1, a2) in (select c1, c2 from t3 @@ -308,7 +308,7 @@ id select_type table type possible_keys key key_len ref rows filtered Extra 4 SUBQUERY t2i index it2i2 # # # 5 100.00 # 2 SUBQUERY t2i index it2i1,it2i3 # # # 5 100.00 # Warnings: -Note 1003 select `test`.`t1i`.`a1` AS `a1`,`test`.`t1i`.`a2` AS `a2` from `test`.`t1i` where (<in_optimizer>((`test`.`t1i`.`a1`,`test`.`t1i`.`a2`),(`test`.`t1i`.`a1`,`test`.`t1i`.`a2`) in ( <materialize> (select `test`.`t2i`.`b1`,`test`.`t2i`.`b2` from `test`.`t2i` where (`test`.`t2i`.`b1` > '0') ), <primary_index_lookup>(`test`.`t1i`.`a1` in <temporary table> on distinct_key where ((`test`.`t1i`.`a1` = `<subquery2>`.`b1`) and (`test`.`t1i`.`a2` = `<subquery2>`.`b2`))))) and <in_optimizer>((`test`.`t1i`.`a1`,`test`.`t1i`.`a2`),(`test`.`t1i`.`a1`,`test`.`t1i`.`a2`) in ( <materialize> (select `test`.`t3i`.`c1`,`test`.`t3i`.`c2` from `test`.`t3i` where <in_optimizer>((`test`.`t3i`.`c1`,`test`.`t3i`.`c2`),(`test`.`t3i`.`c1`,`test`.`t3i`.`c2`) in ( <materialize> (select `test`.`t2i`.`b1`,`test`.`t2i`.`b2` from `test`.`t2i` where (`test`.`t2i`.`b2` > '0') ), <primary_index_lookup>(`test`.`t3i`.`c1` in <temporary table> on distinct_key where ((`test`.`t3i`.`c1` = `<subquery4>`.`b1`) and (`test`.`t3i`.`c2` = `<subquery4>`.`b2`))))) ), <primary_index_lookup>(`test`.`t1i`.`a1` in <temporary table> on distinct_key where ((`test`.`t1i`.`a1` = `<subquery3>`.`c1`) and (`test`.`t1i`.`a2` = `<subquery3>`.`c2`)))))) +Note 1003 select `test`.`t1i`.`a1` AS `a1`,`test`.`t1i`.`a2` AS `a2` from `test`.`t1i` where (<expr_cache><`test`.`t1i`.`a1`,`test`.`t1i`.`a2`>(<in_optimizer>((`test`.`t1i`.`a1`,`test`.`t1i`.`a2`),(`test`.`t1i`.`a1`,`test`.`t1i`.`a2`) in ( <materialize> (select `test`.`t2i`.`b1`,`test`.`t2i`.`b2` from `test`.`t2i` where (`test`.`t2i`.`b1` > '0') ), <primary_index_lookup>(`test`.`t1i`.`a1` in <temporary table> on distinct_key where ((`test`.`t1i`.`a1` = `<subquery2>`.`b1`) and (`test`.`t1i`.`a2` = `<subquery2>`.`b2`)))))) and <expr_cache><`test`.`t1i`.`a1`,`test`.`t1i`.`a2`>(<in_optimizer>((`test`.`t1i`.`a1`,`test`.`t1i`.`a2`),(`test`.`t1i`.`a1`,`test`.`t1i`.`a2`) in ( <materialize> (select `test`.`t3i`.`c1`,`test`.`t3i`.`c2` from `test`.`t3i` where <expr_cache><`test`.`t3i`.`c1`,`test`.`t3i`.`c2`>(<in_optimizer>((`test`.`t3i`.`c1`,`test`.`t3i`.`c2`),(`test`.`t3i`.`c1`,`test`.`t3i`.`c2`) in ( <materialize> (select `test`.`t2i`.`b1`,`test`.`t2i`.`b2` from `test`.`t2i` where (`test`.`t2i`.`b2` > '0') ), <primary_index_lookup>(`test`.`t3i`.`c1` in <temporary table> on distinct_key where ((`test`.`t3i`.`c1` = `<subquery4>`.`b1`) and (`test`.`t3i`.`c2` = `<subquery4>`.`b2`)))))) ), <primary_index_lookup>(`test`.`t1i`.`a1` in <temporary table> on distinct_key where ((`test`.`t1i`.`a1` = `<subquery3>`.`c1`) and (`test`.`t1i`.`a2` = `<subquery3>`.`c2`))))))) select * from t1i where (a1, a2) in (select b1, b2 from t2i where b1 > '0') and (a1, a2) in (select c1, c2 from t3i @@ -331,7 +331,7 @@ id select_type table type possible_keys key key_len ref rows filtered Extra 4 SUBQUERY t3 ALL NULL NULL NULL NULL 4 100.00 Using where 3 SUBQUERY t3 ALL NULL NULL NULL NULL 4 100.00 Using where Warnings: -Note 1003 select `test`.`t1`.`a1` AS `a1`,`test`.`t1`.`a2` AS `a2` from `test`.`t1` where (<in_optimizer>((`test`.`t1`.`a1`,`test`.`t1`.`a2`),(`test`.`t1`.`a1`,`test`.`t1`.`a2`) in ( <materialize> (select `test`.`t2`.`b1`,`test`.`t2`.`b2` from `test`.`t2` where (<in_optimizer>(`test`.`t2`.`b2`,`test`.`t2`.`b2` in ( <materialize> (select `test`.`t3`.`c2` from `test`.`t3` where (`test`.`t3`.`c2` like '%02') ), <primary_index_lookup>(`test`.`t2`.`b2` in <temporary table> on distinct_key where ((`test`.`t2`.`b2` = `<subquery3>`.`c2`))))) or <in_optimizer>(`test`.`t2`.`b2`,`test`.`t2`.`b2` in ( <materialize> (select `test`.`t3`.`c2` from `test`.`t3` where (`test`.`t3`.`c2` like '%03') ), <primary_index_lookup>(`test`.`t2`.`b2` in <temporary table> on distinct_key where ((`test`.`t2`.`b2` = `<subquery4>`.`c2`)))))) ), <primary_index_lookup>(`test`.`t1`.`a1` in <temporary table> on distinct_key where ((`test`.`t1`.`a1` = `<subquery2>`.`b1`) and (`test`.`t1`.`a2` = `<subquery2>`.`b2`))))) and <in_optimizer>((`test`.`t1`.`a1`,`test`.`t1`.`a2`),(`test`.`t1`.`a1`,`test`.`t1`.`a2`) in ( <materialize> (select `test`.`t3`.`c1`,`test`.`t3`.`c2` from `test`.`t3` where <in_optimizer>((`test`.`t3`.`c1`,`test`.`t3`.`c2`),(`test`.`t3`.`c1`,`test`.`t3`.`c2`) in ( <materialize> (select `test`.`t2i`.`b1`,`test`.`t2i`.`b2` from `test`.`t2i` where (`test`.`t2i`.`b2` > '0') ), <primary_index_lookup>(`test`.`t3`.`c1` in <temporary table> on distinct_key where ((`test`.`t3`.`c1` = `<subquery6>`.`b1`) and (`test`.`t3`.`c2` = `<subquery6>`.`b2`))))) ), <primary_index_lookup>(`test`.`t1`.`a1` in <temporary table> on distinct_key where ((`test`.`t1`.`a1` = `<subquery5>`.`c1`) and (`test`.`t1`.`a2` = `<subquery5>`.`c2`)))))) +Note 1003 select `test`.`t1`.`a1` AS `a1`,`test`.`t1`.`a2` AS `a2` from `test`.`t1` where (<expr_cache><`test`.`t1`.`a1`,`test`.`t1`.`a2`>(<in_optimizer>((`test`.`t1`.`a1`,`test`.`t1`.`a2`),(`test`.`t1`.`a1`,`test`.`t1`.`a2`) in ( <materialize> (select `test`.`t2`.`b1`,`test`.`t2`.`b2` from `test`.`t2` where (<expr_cache><`test`.`t2`.`b2`>(<in_optimizer>(`test`.`t2`.`b2`,`test`.`t2`.`b2` in ( <materialize> (select `test`.`t3`.`c2` from `test`.`t3` where (`test`.`t3`.`c2` like '%02') ), <primary_index_lookup>(`test`.`t2`.`b2` in <temporary table> on distinct_key where ((`test`.`t2`.`b2` = `<subquery3>`.`c2`)))))) or <expr_cache><`test`.`t2`.`b2`>(<in_optimizer>(`test`.`t2`.`b2`,`test`.`t2`.`b2` in ( <materialize> (select `test`.`t3`.`c2` from `test`.`t3` where (`test`.`t3`.`c2` like '%03') ), <primary_index_lookup>(`test`.`t2`.`b2` in <temporary table> on distinct_key where ((`test`.`t2`.`b2` = `<subquery4>`.`c2`))))))) ), <primary_index_lookup>(`test`.`t1`.`a1` in <temporary table> on distinct_key where ((`test`.`t1`.`a1` = `<subquery2>`.`b1`) and (`test`.`t1`.`a2` = `<subquery2>`.`b2`)))))) and <expr_cache><`test`.`t1`.`a1`,`test`.`t1`.`a2`>(<in_optimizer>((`test`.`t1`.`a1`,`test`.`t1`.`a2`),(`test`.`t1`.`a1`,`test`.`t1`.`a2`) in ( <materialize> (select `test`.`t3`.`c1`,`test`.`t3`.`c2` from `test`.`t3` where <expr_cache><`test`.`t3`.`c1`,`test`.`t3`.`c2`>(<in_optimizer>((`test`.`t3`.`c1`,`test`.`t3`.`c2`),(`test`.`t3`.`c1`,`test`.`t3`.`c2`) in ( <materialize> (select `test`.`t2i`.`b1`,`test`.`t2i`.`b2` from `test`.`t2i` where (`test`.`t2i`.`b2` > '0') ), <primary_index_lookup>(`test`.`t3`.`c1` in <temporary table> on distinct_key where ((`test`.`t3`.`c1` = `<subquery6>`.`b1`) and (`test`.`t3`.`c2` = `<subquery6>`.`b2`)))))) ), <primary_index_lookup>(`test`.`t1`.`a1` in <temporary table> on distinct_key where ((`test`.`t1`.`a1` = `<subquery5>`.`c1`) and (`test`.`t1`.`a2` = `<subquery5>`.`c2`))))))) select * from t1 where (a1, a2) in (select b1, b2 from t2 where b2 in (select c2 from t3 where c2 LIKE '%02') or @@ -356,7 +356,7 @@ id select_type table type possible_keys key key_len ref rows filtered Extra 3 DEPENDENT SUBQUERY t3a ALL NULL NULL NULL NULL 4 100.00 Using where Warnings: Note 1276 Field or reference 'test.t1.a1' of SELECT #3 was resolved in SELECT #1 -Note 1003 select `test`.`t1`.`a1` AS `a1`,`test`.`t1`.`a2` AS `a2` from `test`.`t1` where (<in_optimizer>((`test`.`t1`.`a1`,`test`.`t1`.`a2`),<exists>(select `test`.`t2`.`b1`,`test`.`t2`.`b2` from `test`.`t2` where ((<in_optimizer>(`test`.`t2`.`b2`,<exists>(select `test`.`t3a`.`c2` from `test`.`t3` `t3a` where ((`test`.`t3a`.`c1` = `test`.`t1`.`a1`) and (<cache>(`test`.`t2`.`b2`) = `test`.`t3a`.`c2`)))) or <in_optimizer>(`test`.`t2`.`b2`,`test`.`t2`.`b2` in ( <materialize> (select `test`.`t3b`.`c2` from `test`.`t3` `t3b` where (`test`.`t3b`.`c2` like '%03') ), <primary_index_lookup>(`test`.`t2`.`b2` in <temporary table> on distinct_key where ((`test`.`t2`.`b2` = `<subquery4>`.`c2`)))))) and (<cache>(`test`.`t1`.`a1`) = `test`.`t2`.`b1`) and (<cache>(`test`.`t1`.`a2`) = `test`.`t2`.`b2`)))) and <in_optimizer>((`test`.`t1`.`a1`,`test`.`t1`.`a2`),(`test`.`t1`.`a1`,`test`.`t1`.`a2`) in ( <materialize> (select `test`.`t3c`.`c1`,`test`.`t3c`.`c2` from `test`.`t3` `t3c` where <in_optimizer>((`test`.`t3c`.`c1`,`test`.`t3c`.`c2`),(`test`.`t3c`.`c1`,`test`.`t3c`.`c2`) in ( <materialize> (select `test`.`t2i`.`b1`,`test`.`t2i`.`b2` from `test`.`t2i` where (`test`.`t2i`.`b2` > '0') ), <primary_index_lookup>(`test`.`t3c`.`c1` in <temporary table> on distinct_key where ((`test`.`t3c`.`c1` = `<subquery6>`.`b1`) and (`test`.`t3c`.`c2` = `<subquery6>`.`b2`))))) ), <primary_index_lookup>(`test`.`t1`.`a1` in <temporary table> on distinct_key where ((`test`.`t1`.`a1` = `<subquery5>`.`c1`) and (`test`.`t1`.`a2` = `<subquery5>`.`c2`)))))) +Note 1003 select `test`.`t1`.`a1` AS `a1`,`test`.`t1`.`a2` AS `a2` from `test`.`t1` where (<expr_cache><`test`.`t1`.`a1`,`test`.`t1`.`a2`>(<in_optimizer>((`test`.`t1`.`a1`,`test`.`t1`.`a2`),<exists>(select `test`.`t2`.`b1`,`test`.`t2`.`b2` from `test`.`t2` where ((<expr_cache><`test`.`t2`.`b2`,`test`.`t1`.`a1`>(<in_optimizer>(`test`.`t2`.`b2`,<exists>(select `test`.`t3a`.`c2` from `test`.`t3` `t3a` where ((`test`.`t3a`.`c1` = `test`.`t1`.`a1`) and (<cache>(`test`.`t2`.`b2`) = `test`.`t3a`.`c2`))))) or <expr_cache><`test`.`t2`.`b2`>(<in_optimizer>(`test`.`t2`.`b2`,`test`.`t2`.`b2` in ( <materialize> (select `test`.`t3b`.`c2` from `test`.`t3` `t3b` where (`test`.`t3b`.`c2` like '%03') ), <primary_index_lookup>(`test`.`t2`.`b2` in <temporary table> on distinct_key where ((`test`.`t2`.`b2` = `<subquery4>`.`c2`))))))) and (<cache>(`test`.`t1`.`a1`) = `test`.`t2`.`b1`) and (<cache>(`test`.`t1`.`a2`) = `test`.`t2`.`b2`))))) and <expr_cache><`test`.`t1`.`a1`,`test`.`t1`.`a2`>(<in_optimizer>((`test`.`t1`.`a1`,`test`.`t1`.`a2`),(`test`.`t1`.`a1`,`test`.`t1`.`a2`) in ( <materialize> (select `test`.`t3c`.`c1`,`test`.`t3c`.`c2` from `test`.`t3` `t3c` where <expr_cache><`test`.`t3c`.`c1`,`test`.`t3c`.`c2`>(<in_optimizer>((`test`.`t3c`.`c1`,`test`.`t3c`.`c2`),(`test`.`t3c`.`c1`,`test`.`t3c`.`c2`) in ( <materialize> (select `test`.`t2i`.`b1`,`test`.`t2i`.`b2` from `test`.`t2i` where (`test`.`t2i`.`b2` > '0') ), <primary_index_lookup>(`test`.`t3c`.`c1` in <temporary table> on distinct_key where ((`test`.`t3c`.`c1` = `<subquery6>`.`b1`) and (`test`.`t3c`.`c2` = `<subquery6>`.`b2`)))))) ), <primary_index_lookup>(`test`.`t1`.`a1` in <temporary table> on distinct_key where ((`test`.`t1`.`a1` = `<subquery5>`.`c1`) and (`test`.`t1`.`a2` = `<subquery5>`.`c2`))))))) select * from t1 where (a1, a2) in (select b1, b2 from t2 where b2 in (select c2 from t3 t3a where c1 = a1) or @@ -392,7 +392,7 @@ id select_type table type possible_keys key key_len ref rows filtered Extra 8 SUBQUERY t2i index it2i1,it2i3 # # # 5 100.00 # NULL UNION RESULT <union1,7> ALL NULL # # # NULL NULL # Warnings: -Note 1003 (select `test`.`t1`.`a1` AS `a1`,`test`.`t1`.`a2` AS `a2` from `test`.`t1` where (<in_optimizer>((`test`.`t1`.`a1`,`test`.`t1`.`a2`),(`test`.`t1`.`a1`,`test`.`t1`.`a2`) in ( <materialize> (select `test`.`t2`.`b1`,`test`.`t2`.`b2` from `test`.`t2` where (<in_optimizer>(`test`.`t2`.`b2`,`test`.`t2`.`b2` in ( <materialize> (select `test`.`t3`.`c2` from `test`.`t3` where (`test`.`t3`.`c2` like '%02') ), <primary_index_lookup>(`test`.`t2`.`b2` in <temporary table> on distinct_key where ((`test`.`t2`.`b2` = `<subquery3>`.`c2`))))) or <in_optimizer>(`test`.`t2`.`b2`,`test`.`t2`.`b2` in ( <materialize> (select `test`.`t3`.`c2` from `test`.`t3` where (`test`.`t3`.`c2` like '%03') ), <primary_index_lookup>(`test`.`t2`.`b2` in <temporary table> on distinct_key where ((`test`.`t2`.`b2` = `<subquery4>`.`c2`)))))) group by `test`.`t2`.`b1`,`test`.`t2`.`b2` ), <primary_index_lookup>(`test`.`t1`.`a1` in <temporary table> on distinct_key where ((`test`.`t1`.`a1` = `<subquery2>`.`b1`) and (`test`.`t1`.`a2` = `<subquery2>`.`b2`))))) and <in_optimizer>((`test`.`t1`.`a1`,`test`.`t1`.`a2`),(`test`.`t1`.`a1`,`test`.`t1`.`a2`) in ( <materialize> (select `test`.`t3`.`c1`,`test`.`t3`.`c2` from `test`.`t3` where <in_optimizer>((`test`.`t3`.`c1`,`test`.`t3`.`c2`),(`test`.`t3`.`c1`,`test`.`t3`.`c2`) in ( <materialize> (select `test`.`t2i`.`b1`,`test`.`t2i`.`b2` from `test`.`t2i` where (`test`.`t2i`.`b2` > '0') ), <primary_index_lookup>(`test`.`t3`.`c1` in <temporary table> on distinct_key where ((`test`.`t3`.`c1` = `<subquery6>`.`b1`) and (`test`.`t3`.`c2` = `<subquery6>`.`b2`))))) ), <primary_index_lookup>(`test`.`t1`.`a1` in <temporary table> on distinct_key where ((`test`.`t1`.`a1` = `<subquery5>`.`c1`) and (`test`.`t1`.`a2` = `<subquery5>`.`c2`))))))) union (select `test`.`t1i`.`a1` AS `a1`,`test`.`t1i`.`a2` AS `a2` from `test`.`t1i` where (<in_optimizer>((`test`.`t1i`.`a1`,`test`.`t1i`.`a2`),(`test`.`t1i`.`a1`,`test`.`t1i`.`a2`) in ( <materialize> (select `test`.`t2i`.`b1`,`test`.`t2i`.`b2` from `test`.`t2i` where (`test`.`t2i`.`b1` > '0') ), <primary_index_lookup>(`test`.`t1i`.`a1` in <temporary table> on distinct_key where ((`test`.`t1i`.`a1` = `<subquery8>`.`b1`) and (`test`.`t1i`.`a2` = `<subquery8>`.`b2`))))) and <in_optimizer>((`test`.`t1i`.`a1`,`test`.`t1i`.`a2`),(`test`.`t1i`.`a1`,`test`.`t1i`.`a2`) in ( <materialize> (select `test`.`t3i`.`c1`,`test`.`t3i`.`c2` from `test`.`t3i` where <in_optimizer>((`test`.`t3i`.`c1`,`test`.`t3i`.`c2`),(`test`.`t3i`.`c1`,`test`.`t3i`.`c2`) in ( <materialize> (select `test`.`t2i`.`b1`,`test`.`t2i`.`b2` from `test`.`t2i` where (`test`.`t2i`.`b2` > '0') ), <primary_index_lookup>(`test`.`t3i`.`c1` in <temporary table> on distinct_key where ((`test`.`t3i`.`c1` = `<subquery10>`.`b1`) and (`test`.`t3i`.`c2` = `<subquery10>`.`b2`))))) ), <primary_index_lookup>(`test`.`t1i`.`a1` in <temporary table> on distinct_key where ((`test`.`t1i`.`a1` = `<subquery9>`.`c1`) and (`test`.`t1i`.`a2` = `<subquery9>`.`c2`))))))) +Note 1003 (select `test`.`t1`.`a1` AS `a1`,`test`.`t1`.`a2` AS `a2` from `test`.`t1` where (<expr_cache><`test`.`t1`.`a1`,`test`.`t1`.`a2`>(<in_optimizer>((`test`.`t1`.`a1`,`test`.`t1`.`a2`),(`test`.`t1`.`a1`,`test`.`t1`.`a2`) in ( <materialize> (select `test`.`t2`.`b1`,`test`.`t2`.`b2` from `test`.`t2` where (<expr_cache><`test`.`t2`.`b2`>(<in_optimizer>(`test`.`t2`.`b2`,`test`.`t2`.`b2` in ( <materialize> (select `test`.`t3`.`c2` from `test`.`t3` where (`test`.`t3`.`c2` like '%02') ), <primary_index_lookup>(`test`.`t2`.`b2` in <temporary table> on distinct_key where ((`test`.`t2`.`b2` = `<subquery3>`.`c2`)))))) or <expr_cache><`test`.`t2`.`b2`>(<in_optimizer>(`test`.`t2`.`b2`,`test`.`t2`.`b2` in ( <materialize> (select `test`.`t3`.`c2` from `test`.`t3` where (`test`.`t3`.`c2` like '%03') ), <primary_index_lookup>(`test`.`t2`.`b2` in <temporary table> on distinct_key where ((`test`.`t2`.`b2` = `<subquery4>`.`c2`))))))) group by `test`.`t2`.`b1`,`test`.`t2`.`b2` ), <primary_index_lookup>(`test`.`t1`.`a1` in <temporary table> on distinct_key where ((`test`.`t1`.`a1` = `<subquery2>`.`b1`) and (`test`.`t1`.`a2` = `<subquery2>`.`b2`)))))) and <expr_cache><`test`.`t1`.`a1`,`test`.`t1`.`a2`>(<in_optimizer>((`test`.`t1`.`a1`,`test`.`t1`.`a2`),(`test`.`t1`.`a1`,`test`.`t1`.`a2`) in ( <materialize> (select `test`.`t3`.`c1`,`test`.`t3`.`c2` from `test`.`t3` where <expr_cache><`test`.`t3`.`c1`,`test`.`t3`.`c2`>(<in_optimizer>((`test`.`t3`.`c1`,`test`.`t3`.`c2`),(`test`.`t3`.`c1`,`test`.`t3`.`c2`) in ( <materialize> (select `test`.`t2i`.`b1`,`test`.`t2i`.`b2` from `test`.`t2i` where (`test`.`t2i`.`b2` > '0') ), <primary_index_lookup>(`test`.`t3`.`c1` in <temporary table> on distinct_key where ((`test`.`t3`.`c1` = `<subquery6>`.`b1`) and (`test`.`t3`.`c2` = `<subquery6>`.`b2`)))))) ), <primary_index_lookup>(`test`.`t1`.`a1` in <temporary table> on distinct_key where ((`test`.`t1`.`a1` = `<subquery5>`.`c1`) and (`test`.`t1`.`a2` = `<subquery5>`.`c2`)))))))) union (select `test`.`t1i`.`a1` AS `a1`,`test`.`t1i`.`a2` AS `a2` from `test`.`t1i` where (<expr_cache><`test`.`t1i`.`a1`,`test`.`t1i`.`a2`>(<in_optimizer>((`test`.`t1i`.`a1`,`test`.`t1i`.`a2`),(`test`.`t1i`.`a1`,`test`.`t1i`.`a2`) in ( <materialize> (select `test`.`t2i`.`b1`,`test`.`t2i`.`b2` from `test`.`t2i` where (`test`.`t2i`.`b1` > '0') ), <primary_index_lookup>(`test`.`t1i`.`a1` in <temporary table> on distinct_key where ((`test`.`t1i`.`a1` = `<subquery8>`.`b1`) and (`test`.`t1i`.`a2` = `<subquery8>`.`b2`)))))) and <expr_cache><`test`.`t1i`.`a1`,`test`.`t1i`.`a2`>(<in_optimizer>((`test`.`t1i`.`a1`,`test`.`t1i`.`a2`),(`test`.`t1i`.`a1`,`test`.`t1i`.`a2`) in ( <materialize> (select `test`.`t3i`.`c1`,`test`.`t3i`.`c2` from `test`.`t3i` where <expr_cache><`test`.`t3i`.`c1`,`test`.`t3i`.`c2`>(<in_optimizer>((`test`.`t3i`.`c1`,`test`.`t3i`.`c2`),(`test`.`t3i`.`c1`,`test`.`t3i`.`c2`) in ( <materialize> (select `test`.`t2i`.`b1`,`test`.`t2i`.`b2` from `test`.`t2i` where (`test`.`t2i`.`b2` > '0') ), <primary_index_lookup>(`test`.`t3i`.`c1` in <temporary table> on distinct_key where ((`test`.`t3i`.`c1` = `<subquery10>`.`b1`) and (`test`.`t3i`.`c2` = `<subquery10>`.`b2`)))))) ), <primary_index_lookup>(`test`.`t1i`.`a1` in <temporary table> on distinct_key where ((`test`.`t1i`.`a1` = `<subquery9>`.`c1`) and (`test`.`t1i`.`a2` = `<subquery9>`.`c2`)))))))) (select * from t1 where (a1, a2) in (select b1, b2 from t2 where b2 in (select c2 from t3 where c2 LIKE '%02') or @@ -421,7 +421,7 @@ id select_type table type possible_keys key key_len ref rows filtered Extra 3 DEPENDENT UNION t2 ALL NULL NULL NULL NULL 5 100.00 Using where NULL UNION RESULT <union2,3> ALL NULL NULL NULL NULL NULL NULL Warnings: -Note 1003 select `test`.`t1`.`a1` AS `a1`,`test`.`t1`.`a2` AS `a2` from `test`.`t1` where (<in_optimizer>((`test`.`t1`.`a1`,`test`.`t1`.`a2`),<exists>(select `test`.`t1`.`a1`,`test`.`t1`.`a2` from `test`.`t1` where ((`test`.`t1`.`a1` > '0') and (<cache>(`test`.`t1`.`a1`) = `test`.`t1`.`a1`) and (<cache>(`test`.`t1`.`a2`) = `test`.`t1`.`a2`)) union select `test`.`t2`.`b1`,`test`.`t2`.`b2` from `test`.`t2` where ((`test`.`t2`.`b1` < '9') and (<cache>(`test`.`t1`.`a1`) = `test`.`t2`.`b1`) and (<cache>(`test`.`t1`.`a2`) = `test`.`t2`.`b2`)))) and <in_optimizer>((`test`.`t1`.`a1`,`test`.`t1`.`a2`),(`test`.`t1`.`a1`,`test`.`t1`.`a2`) in ( <materialize> (select `test`.`t3`.`c1`,`test`.`t3`.`c2` from `test`.`t3` where <in_optimizer>((`test`.`t3`.`c1`,`test`.`t3`.`c2`),(`test`.`t3`.`c1`,`test`.`t3`.`c2`) in ( <materialize> (select `test`.`t2i`.`b1`,`test`.`t2i`.`b2` from `test`.`t2i` where (`test`.`t2i`.`b2` > '0') ), <primary_index_lookup>(`test`.`t3`.`c1` in <temporary table> on distinct_key where ((`test`.`t3`.`c1` = `<subquery5>`.`b1`) and (`test`.`t3`.`c2` = `<subquery5>`.`b2`))))) ), <primary_index_lookup>(`test`.`t1`.`a1` in <temporary table> on distinct_key where ((`test`.`t1`.`a1` = `<subquery4>`.`c1`) and (`test`.`t1`.`a2` = `<subquery4>`.`c2`)))))) +Note 1003 select `test`.`t1`.`a1` AS `a1`,`test`.`t1`.`a2` AS `a2` from `test`.`t1` where (<expr_cache><`test`.`t1`.`a1`,`test`.`t1`.`a2`>(<in_optimizer>((`test`.`t1`.`a1`,`test`.`t1`.`a2`),<exists>(select `test`.`t1`.`a1`,`test`.`t1`.`a2` from `test`.`t1` where ((`test`.`t1`.`a1` > '0') and (<cache>(`test`.`t1`.`a1`) = `test`.`t1`.`a1`) and (<cache>(`test`.`t1`.`a2`) = `test`.`t1`.`a2`)) union select `test`.`t2`.`b1`,`test`.`t2`.`b2` from `test`.`t2` where ((`test`.`t2`.`b1` < '9') and (<cache>(`test`.`t1`.`a1`) = `test`.`t2`.`b1`) and (<cache>(`test`.`t1`.`a2`) = `test`.`t2`.`b2`))))) and <expr_cache><`test`.`t1`.`a1`,`test`.`t1`.`a2`>(<in_optimizer>((`test`.`t1`.`a1`,`test`.`t1`.`a2`),(`test`.`t1`.`a1`,`test`.`t1`.`a2`) in ( <materialize> (select `test`.`t3`.`c1`,`test`.`t3`.`c2` from `test`.`t3` where <expr_cache><`test`.`t3`.`c1`,`test`.`t3`.`c2`>(<in_optimizer>((`test`.`t3`.`c1`,`test`.`t3`.`c2`),(`test`.`t3`.`c1`,`test`.`t3`.`c2`) in ( <materialize> (select `test`.`t2i`.`b1`,`test`.`t2i`.`b2` from `test`.`t2i` where (`test`.`t2i`.`b2` > '0') ), <primary_index_lookup>(`test`.`t3`.`c1` in <temporary table> on distinct_key where ((`test`.`t3`.`c1` = `<subquery5>`.`b1`) and (`test`.`t3`.`c2` = `<subquery5>`.`b2`)))))) ), <primary_index_lookup>(`test`.`t1`.`a1` in <temporary table> on distinct_key where ((`test`.`t1`.`a1` = `<subquery4>`.`c1`) and (`test`.`t1`.`a2` = `<subquery4>`.`c2`))))))) select * from t1 where (a1, a2) in (select * from t1 where a1 > '0' UNION select * from t2 where b1 < '9') and (a1, a2) in (select c1, c2 from t3 @@ -444,7 +444,7 @@ id select_type table type possible_keys key key_len ref rows filtered Extra 3 DEPENDENT UNION t2 ALL NULL NULL NULL NULL 5 100.00 Using where NULL UNION RESULT <union2,3> ALL NULL NULL NULL NULL NULL NULL Warnings: -Note 1003 select `test`.`t1`.`a1` AS `a1`,`test`.`t1`.`a2` AS `a2`,`test`.`t3`.`c1` AS `c1`,`test`.`t3`.`c2` AS `c2` from `test`.`t1` join `test`.`t3` where ((`test`.`t3`.`c1` = `test`.`t1`.`a1`) and <in_optimizer>((`test`.`t1`.`a1`,`test`.`t1`.`a2`),<exists>(select `test`.`t1`.`a1`,`test`.`t1`.`a2` from `test`.`t1` where ((`test`.`t1`.`a1` > '0') and (<cache>(`test`.`t1`.`a1`) = `test`.`t1`.`a1`) and (<cache>(`test`.`t1`.`a2`) = `test`.`t1`.`a2`)) union select `test`.`t2`.`b1`,`test`.`t2`.`b2` from `test`.`t2` where ((`test`.`t2`.`b1` < '9') and (<cache>(`test`.`t1`.`a1`) = `test`.`t2`.`b1`) and (<cache>(`test`.`t1`.`a2`) = `test`.`t2`.`b2`)))) and <in_optimizer>((`test`.`t3`.`c1`,`test`.`t3`.`c2`),(`test`.`t3`.`c1`,`test`.`t3`.`c2`) in ( <materialize> (select `test`.`t3`.`c1`,`test`.`t3`.`c2` from `test`.`t3` where <in_optimizer>((`test`.`t3`.`c1`,`test`.`t3`.`c2`),(`test`.`t3`.`c1`,`test`.`t3`.`c2`) in ( <materialize> (select `test`.`t2i`.`b1`,`test`.`t2i`.`b2` from `test`.`t2i` where (`test`.`t2i`.`b2` > '0') ), <primary_index_lookup>(`test`.`t3`.`c1` in <temporary table> on distinct_key where ((`test`.`t3`.`c1` = `<subquery5>`.`b1`) and (`test`.`t3`.`c2` = `<subquery5>`.`b2`))))) ), <primary_index_lookup>(`test`.`t3`.`c1` in <temporary table> on distinct_key where ((`test`.`t3`.`c1` = `<subquery4>`.`c1`) and (`test`.`t3`.`c2` = `<subquery4>`.`c2`)))))) +Note 1003 select `test`.`t1`.`a1` AS `a1`,`test`.`t1`.`a2` AS `a2`,`test`.`t3`.`c1` AS `c1`,`test`.`t3`.`c2` AS `c2` from `test`.`t1` join `test`.`t3` where ((`test`.`t3`.`c1` = `test`.`t1`.`a1`) and <expr_cache><`test`.`t1`.`a1`,`test`.`t1`.`a2`>(<in_optimizer>((`test`.`t1`.`a1`,`test`.`t1`.`a2`),<exists>(select `test`.`t1`.`a1`,`test`.`t1`.`a2` from `test`.`t1` where ((`test`.`t1`.`a1` > '0') and (<cache>(`test`.`t1`.`a1`) = `test`.`t1`.`a1`) and (<cache>(`test`.`t1`.`a2`) = `test`.`t1`.`a2`)) union select `test`.`t2`.`b1`,`test`.`t2`.`b2` from `test`.`t2` where ((`test`.`t2`.`b1` < '9') and (<cache>(`test`.`t1`.`a1`) = `test`.`t2`.`b1`) and (<cache>(`test`.`t1`.`a2`) = `test`.`t2`.`b2`))))) and <expr_cache><`test`.`t3`.`c1`,`test`.`t3`.`c2`>(<in_optimizer>((`test`.`t3`.`c1`,`test`.`t3`.`c2`),(`test`.`t3`.`c1`,`test`.`t3`.`c2`) in ( <materialize> (select `test`.`t3`.`c1`,`test`.`t3`.`c2` from `test`.`t3` where <expr_cache><`test`.`t3`.`c1`,`test`.`t3`.`c2`>(<in_optimizer>((`test`.`t3`.`c1`,`test`.`t3`.`c2`),(`test`.`t3`.`c1`,`test`.`t3`.`c2`) in ( <materialize> (select `test`.`t2i`.`b1`,`test`.`t2i`.`b2` from `test`.`t2i` where (`test`.`t2i`.`b2` > '0') ), <primary_index_lookup>(`test`.`t3`.`c1` in <temporary table> on distinct_key where ((`test`.`t3`.`c1` = `<subquery5>`.`b1`) and (`test`.`t3`.`c2` = `<subquery5>`.`b2`)))))) ), <primary_index_lookup>(`test`.`t3`.`c1` in <temporary table> on distinct_key where ((`test`.`t3`.`c1` = `<subquery4>`.`c1`) and (`test`.`t3`.`c2` = `<subquery4>`.`c2`))))))) select * from t1, t3 where (a1, a2) in (select * from t1 where a1 > '0' UNION select * from t2 where b1 < '9') and (c1, c2) in (select c1, c2 from t3 @@ -466,7 +466,7 @@ id select_type table type possible_keys key key_len ref rows filtered Extra 3 DEPENDENT UNION t2 ALL NULL NULL NULL NULL 5 100.00 Using where NULL UNION RESULT <union2,3> ALL NULL NULL NULL NULL NULL NULL Warnings: -Note 1003 select `test`.`t3`.`c1` AS `c1`,`test`.`t3`.`c2` AS `c2` from `test`.`t3` where <in_optimizer>(`test`.`t3`.`c1`,<exists>(select `test`.`t1`.`a1` from `test`.`t1` where ((`test`.`t1`.`a1` > '0') and (<cache>(`test`.`t3`.`c1`) = `test`.`t1`.`a1`)) union select `test`.`t2`.`b1` from `test`.`t2` where ((`test`.`t2`.`b1` < '9') and (<cache>(`test`.`t3`.`c1`) = `test`.`t2`.`b1`)))) +Note 1003 select `test`.`t3`.`c1` AS `c1`,`test`.`t3`.`c2` AS `c2` from `test`.`t3` where <expr_cache><`test`.`t3`.`c1`>(<in_optimizer>(`test`.`t3`.`c1`,<exists>(select `test`.`t1`.`a1` from `test`.`t1` where ((`test`.`t1`.`a1` > '0') and (<cache>(`test`.`t3`.`c1`) = `test`.`t1`.`a1`)) union select `test`.`t2`.`b1` from `test`.`t2` where ((`test`.`t2`.`b1` < '9') and (<cache>(`test`.`t3`.`c1`) = `test`.`t2`.`b1`))))) select * from t3 where c1 in (select a1 from t1 where a1 > '0' UNION select b1 from t2 where b1 < '9'); c1 c2 @@ -490,14 +490,14 @@ id select_type table type possible_keys key key_len ref rows filtered Extra Warnings: Note 1276 Field or reference 'test.t1.a1' of SELECT #3 was resolved in SELECT #1 Note 1276 Field or reference 'test.t1.a2' of SELECT #6 was resolved in SELECT #1 -Note 1003 select `test`.`t1`.`a1` AS `a1`,`test`.`t1`.`a2` AS `a2` from `test`.`t1` where (<in_optimizer>((`test`.`t1`.`a1`,`test`.`t1`.`a2`),<exists>(select `test`.`t2`.`b1`,`test`.`t2`.`b2` from `test`.`t2` where ((<in_optimizer>(`test`.`t2`.`b2`,<exists>(select `test`.`t3a`.`c2` from `test`.`t3` `t3a` where ((`test`.`t3a`.`c1` = `test`.`t1`.`a1`) and (<cache>(`test`.`t2`.`b2`) = `test`.`t3a`.`c2`)))) or <in_optimizer>(`test`.`t2`.`b2`,`test`.`t2`.`b2` in ( <materialize> (select `test`.`t3b`.`c2` from `test`.`t3` `t3b` where (`test`.`t3b`.`c2` like '%03') ), <primary_index_lookup>(`test`.`t2`.`b2` in <temporary table> on distinct_key where ((`test`.`t2`.`b2` = `<subquery4>`.`c2`)))))) and (<cache>(`test`.`t1`.`a1`) = `test`.`t2`.`b1`) and (<cache>(`test`.`t1`.`a2`) = `test`.`t2`.`b2`)))) and <in_optimizer>((`test`.`t1`.`a1`,`test`.`t1`.`a2`),<exists>(select `test`.`t3c`.`c1`,`test`.`t3c`.`c2` from `test`.`t3` `t3c` where (<in_optimizer>((`test`.`t3c`.`c1`,`test`.`t3c`.`c2`),<exists>(<index_lookup>(<cache>(`test`.`t3c`.`c1`) in t2i on it2i3 where (((`test`.`t2i`.`b2` > '0') or (`test`.`t2i`.`b2` = `test`.`t1`.`a2`)) and (<cache>(`test`.`t3c`.`c1`) = `test`.`t2i`.`b1`) and (<cache>(`test`.`t3c`.`c2`) = `test`.`t2i`.`b2`))))) and (<cache>(`test`.`t1`.`a1`) = `test`.`t3c`.`c1`) and (<cache>(`test`.`t1`.`a2`) = `test`.`t3c`.`c2`))))) +Note 1003 select `test`.`t1`.`a1` AS `a1`,`test`.`t1`.`a2` AS `a2` from `test`.`t1` where (<expr_cache><`test`.`t1`.`a1`,`test`.`t1`.`a2`>(<in_optimizer>((`test`.`t1`.`a1`,`test`.`t1`.`a2`),<exists>(select `test`.`t2`.`b1`,`test`.`t2`.`b2` from `test`.`t2` where ((<expr_cache><`test`.`t2`.`b2`,`test`.`t1`.`a1`>(<in_optimizer>(`test`.`t2`.`b2`,<exists>(select `test`.`t3a`.`c2` from `test`.`t3` `t3a` where ((`test`.`t3a`.`c1` = `test`.`t1`.`a1`) and (<cache>(`test`.`t2`.`b2`) = `test`.`t3a`.`c2`))))) or <expr_cache><`test`.`t2`.`b2`>(<in_optimizer>(`test`.`t2`.`b2`,`test`.`t2`.`b2` in ( <materialize> (select `test`.`t3b`.`c2` from `test`.`t3` `t3b` where (`test`.`t3b`.`c2` like '%03') ), <primary_index_lookup>(`test`.`t2`.`b2` in <temporary table> on distinct_key where ((`test`.`t2`.`b2` = `<subquery4>`.`c2`))))))) and (<cache>(`test`.`t1`.`a1`) = `test`.`t2`.`b1`) and (<cache>(`test`.`t1`.`a2`) = `test`.`t2`.`b2`))))) and <expr_cache><`test`.`t1`.`a1`,`test`.`t1`.`a2`>(<in_optimizer>((`test`.`t1`.`a1`,`test`.`t1`.`a2`),<exists>(select `test`.`t3c`.`c1`,`test`.`t3c`.`c2` from `test`.`t3` `t3c` where (<expr_cache><`test`.`t3c`.`c1`,`test`.`t3c`.`c2`,`test`.`t1`.`a2`>(<in_optimizer>((`test`.`t3c`.`c1`,`test`.`t3c`.`c2`),<exists>(<index_lookup>(<cache>(`test`.`t3c`.`c1`) in t2i on it2i3 where (((`test`.`t2i`.`b2` > '0') or (`test`.`t2i`.`b2` = `test`.`t1`.`a2`)) and (<cache>(`test`.`t3c`.`c1`) = `test`.`t2i`.`b1`) and (<cache>(`test`.`t3c`.`c2`) = `test`.`t2i`.`b2`)))))) and (<cache>(`test`.`t1`.`a1`) = `test`.`t3c`.`c1`) and (<cache>(`test`.`t1`.`a2`) = `test`.`t3c`.`c2`)))))) explain extended select * from t1 where (a1, a2) in (select '1 - 01', '2 - 01'); id select_type table type possible_keys key key_len ref rows filtered Extra 1 PRIMARY t1 ALL NULL NULL NULL NULL 3 100.00 Using where 2 DEPENDENT SUBQUERY NULL NULL NULL NULL NULL NULL NULL NULL No tables used Warnings: -Note 1003 select `test`.`t1`.`a1` AS `a1`,`test`.`t1`.`a2` AS `a2` from `test`.`t1` where <in_optimizer>((`test`.`t1`.`a1`,`test`.`t1`.`a2`),<exists>(select '1 - 01','2 - 01' having (((<cache>(`test`.`t1`.`a1`) = '1 - 01') or isnull('1 - 01')) and ((<cache>(`test`.`t1`.`a2`) = '2 - 01') or isnull('2 - 01')) and <is_not_null_test>('1 - 01') and <is_not_null_test>('2 - 01')))) +Note 1003 select `test`.`t1`.`a1` AS `a1`,`test`.`t1`.`a2` AS `a2` from `test`.`t1` where <expr_cache><`test`.`t1`.`a1`,`test`.`t1`.`a2`>(<in_optimizer>((`test`.`t1`.`a1`,`test`.`t1`.`a2`),<exists>(select '1 - 01','2 - 01' having (((<cache>(`test`.`t1`.`a1`) = '1 - 01') or isnull('1 - 01')) and ((<cache>(`test`.`t1`.`a2`) = '2 - 01') or isnull('2 - 01')) and <is_not_null_test>('1 - 01') and <is_not_null_test>('2 - 01'))))) select * from t1 where (a1, a2) in (select '1 - 01', '2 - 01'); a1 a2 1 - 01 2 - 01 @@ -507,7 +507,7 @@ id select_type table type possible_keys key key_len ref rows filtered Extra 1 PRIMARY t1 ALL NULL NULL NULL NULL 3 100.00 Using where 2 DEPENDENT SUBQUERY NULL NULL NULL NULL NULL NULL NULL NULL No tables used Warnings: -Note 1003 select `test`.`t1`.`a1` AS `a1`,`test`.`t1`.`a2` AS `a2` from `test`.`t1` where <in_optimizer>((`test`.`t1`.`a1`,`test`.`t1`.`a2`),<exists>(select '1 - 01','2 - 01' having (((<cache>(`test`.`t1`.`a1`) = '1 - 01') or isnull('1 - 01')) and ((<cache>(`test`.`t1`.`a2`) = '2 - 01') or isnull('2 - 01')) and <is_not_null_test>('1 - 01') and <is_not_null_test>('2 - 01')))) +Note 1003 select `test`.`t1`.`a1` AS `a1`,`test`.`t1`.`a2` AS `a2` from `test`.`t1` where <expr_cache><`test`.`t1`.`a1`,`test`.`t1`.`a2`>(<in_optimizer>((`test`.`t1`.`a1`,`test`.`t1`.`a2`),<exists>(select '1 - 01','2 - 01' having (((<cache>(`test`.`t1`.`a1`) = '1 - 01') or isnull('1 - 01')) and ((<cache>(`test`.`t1`.`a2`) = '2 - 01') or isnull('2 - 01')) and <is_not_null_test>('1 - 01') and <is_not_null_test>('2 - 01'))))) select * from t1 where (a1, a2) in (select '1 - 01', '2 - 01' from dual); a1 a2 1 - 01 2 - 01 @@ -539,7 +539,7 @@ id select_type table type possible_keys key key_len ref rows filtered Extra 1 PRIMARY t1 ALL NULL NULL NULL NULL 3 100.00 Using temporary; Using filesort 2 DEPENDENT SUBQUERY columns unique_subquery PRIMARY PRIMARY 4 func 1 100.00 Using index; Using where; Full scan on NULL key Warnings: -Note 1003 select `test`.`t1`.`a1` AS `a1`,`test`.`t1`.`a2` AS `a2` from `test`.`t1` group by <in_optimizer>(`test`.`t1`.`a1`,<exists>(<primary_index_lookup>(<cache>(`test`.`t1`.`a1`) in columns on PRIMARY where trigcond((<cache>(`test`.`t1`.`a1`) = `test`.`columns`.`col`))))) +Note 1003 select `test`.`t1`.`a1` AS `a1`,`test`.`t1`.`a2` AS `a2` from `test`.`t1` group by <expr_cache><`test`.`t1`.`a1`>(<in_optimizer>(`test`.`t1`.`a1`,<exists>(<primary_index_lookup>(<cache>(`test`.`t1`.`a1`) in columns on PRIMARY where trigcond((<cache>(`test`.`t1`.`a1`) = `test`.`columns`.`col`)))))) select * from t1 group by (a1 in (select col from columns)); a1 a2 1 - 00 2 - 00 @@ -596,7 +596,7 @@ id select_type table type possible_keys key key_len ref rows filtered Extra 1 PRIMARY t1_16 ALL NULL NULL NULL NULL 3 100.00 Using where 2 DEPENDENT SUBQUERY t2_16 ALL NULL NULL NULL NULL 3 100.00 Using where Warnings: -Note 1003 select left(`test`.`t1_16`.`a1`,7) AS `left(a1,7)`,left(`test`.`t1_16`.`a2`,7) AS `left(a2,7)` from `test`.`t1_16` where <in_optimizer>(`test`.`t1_16`.`a1`,<exists>(select `test`.`t2_16`.`b1` from `test`.`t2_16` where ((`test`.`t2_16`.`b1` > '0') and (<cache>(`test`.`t1_16`.`a1`) = `test`.`t2_16`.`b1`)))) +Note 1003 select left(`test`.`t1_16`.`a1`,7) AS `left(a1,7)`,left(`test`.`t1_16`.`a2`,7) AS `left(a2,7)` from `test`.`t1_16` where <expr_cache><`test`.`t1_16`.`a1`>(<in_optimizer>(`test`.`t1_16`.`a1`,<exists>(select `test`.`t2_16`.`b1` from `test`.`t2_16` where ((`test`.`t2_16`.`b1` > '0') and (<cache>(`test`.`t1_16`.`a1`) = `test`.`t2_16`.`b1`))))) select left(a1,7), left(a2,7) from t1_16 where a1 in (select b1 from t2_16 where b1 > '0'); @@ -610,7 +610,7 @@ id select_type table type possible_keys key key_len ref rows filtered Extra 1 PRIMARY t1_16 ALL NULL NULL NULL NULL 3 100.00 Using where 2 DEPENDENT SUBQUERY t2_16 ALL NULL NULL NULL NULL 3 100.00 Using where Warnings: -Note 1003 select left(`test`.`t1_16`.`a1`,7) AS `left(a1,7)`,left(`test`.`t1_16`.`a2`,7) AS `left(a2,7)` from `test`.`t1_16` where <in_optimizer>((`test`.`t1_16`.`a1`,`test`.`t1_16`.`a2`),<exists>(select `test`.`t2_16`.`b1`,`test`.`t2_16`.`b2` from `test`.`t2_16` where ((`test`.`t2_16`.`b1` > '0') and (<cache>(`test`.`t1_16`.`a1`) = `test`.`t2_16`.`b1`) and (<cache>(`test`.`t1_16`.`a2`) = `test`.`t2_16`.`b2`)))) +Note 1003 select left(`test`.`t1_16`.`a1`,7) AS `left(a1,7)`,left(`test`.`t1_16`.`a2`,7) AS `left(a2,7)` from `test`.`t1_16` where <expr_cache><`test`.`t1_16`.`a1`,`test`.`t1_16`.`a2`>(<in_optimizer>((`test`.`t1_16`.`a1`,`test`.`t1_16`.`a2`),<exists>(select `test`.`t2_16`.`b1`,`test`.`t2_16`.`b2` from `test`.`t2_16` where ((`test`.`t2_16`.`b1` > '0') and (<cache>(`test`.`t1_16`.`a1`) = `test`.`t2_16`.`b1`) and (<cache>(`test`.`t1_16`.`a2`) = `test`.`t2_16`.`b2`))))) select left(a1,7), left(a2,7) from t1_16 where (a1,a2) in (select b1, b2 from t2_16 where b1 > '0'); @@ -624,7 +624,7 @@ id select_type table type possible_keys key key_len ref rows filtered Extra 1 PRIMARY t1_16 ALL NULL NULL NULL NULL 3 100.00 Using where 2 SUBQUERY t2_16 ALL NULL NULL NULL NULL 3 100.00 Using where Warnings: -Note 1003 select left(`test`.`t1_16`.`a1`,7) AS `left(a1,7)`,left(`test`.`t1_16`.`a2`,7) AS `left(a2,7)` from `test`.`t1_16` where <in_optimizer>(`test`.`t1_16`.`a1`,`test`.`t1_16`.`a1` in ( <materialize> (select substr(`test`.`t2_16`.`b1`,1,16) from `test`.`t2_16` where (`test`.`t2_16`.`b1` > '0') ), <primary_index_lookup>(`test`.`t1_16`.`a1` in <temporary table> on distinct_key where ((`test`.`t1_16`.`a1` = `<subquery2>`.`substring(b1,1,16)`))))) +Note 1003 select left(`test`.`t1_16`.`a1`,7) AS `left(a1,7)`,left(`test`.`t1_16`.`a2`,7) AS `left(a2,7)` from `test`.`t1_16` where <expr_cache><`test`.`t1_16`.`a1`>(<in_optimizer>(`test`.`t1_16`.`a1`,`test`.`t1_16`.`a1` in ( <materialize> (select substr(`test`.`t2_16`.`b1`,1,16) from `test`.`t2_16` where (`test`.`t2_16`.`b1` > '0') ), <primary_index_lookup>(`test`.`t1_16`.`a1` in <temporary table> on distinct_key where ((`test`.`t1_16`.`a1` = `<subquery2>`.`substring(b1,1,16)`)))))) select left(a1,7), left(a2,7) from t1_16 where a1 in (select substring(b1,1,16) from t2_16 where b1 > '0'); @@ -638,7 +638,7 @@ id select_type table type possible_keys key key_len ref rows filtered Extra 1 PRIMARY t1_16 ALL NULL NULL NULL NULL 3 100.00 Using where 2 DEPENDENT SUBQUERY t2_16 ALL NULL NULL NULL NULL 3 100.00 Using filesort Warnings: -Note 1003 select left(`test`.`t1_16`.`a1`,7) AS `left(a1,7)`,left(`test`.`t1_16`.`a2`,7) AS `left(a2,7)` from `test`.`t1_16` where <in_optimizer>(`test`.`t1_16`.`a1`,<exists>(select group_concat(`test`.`t2_16`.`b1` separator ',') from `test`.`t2_16` group by `test`.`t2_16`.`b2` having (<cache>(`test`.`t1_16`.`a1`) = <ref_null_helper>(group_concat(`test`.`t2_16`.`b1` separator ','))))) +Note 1003 select left(`test`.`t1_16`.`a1`,7) AS `left(a1,7)`,left(`test`.`t1_16`.`a2`,7) AS `left(a2,7)` from `test`.`t1_16` where <expr_cache><`test`.`t1_16`.`a1`>(<in_optimizer>(`test`.`t1_16`.`a1`,<exists>(select group_concat(`test`.`t2_16`.`b1` separator ',') from `test`.`t2_16` group by `test`.`t2_16`.`b2` having (<cache>(`test`.`t1_16`.`a1`) = <ref_null_helper>(group_concat(`test`.`t2_16`.`b1` separator ',')))))) select left(a1,7), left(a2,7) from t1_16 where a1 in (select group_concat(b1) from t2_16 group by b2); @@ -653,7 +653,7 @@ id select_type table type possible_keys key key_len ref rows filtered Extra 1 PRIMARY t1_16 ALL NULL NULL NULL NULL 3 100.00 Using where 2 SUBQUERY t2_16 ALL NULL NULL NULL NULL 3 100.00 Using filesort Warnings: -Note 1003 select left(`test`.`t1_16`.`a1`,7) AS `left(a1,7)`,left(`test`.`t1_16`.`a2`,7) AS `left(a2,7)` from `test`.`t1_16` where <in_optimizer>(`test`.`t1_16`.`a1`,`test`.`t1_16`.`a1` in ( <materialize> (select group_concat(`test`.`t2_16`.`b1` separator ',') from `test`.`t2_16` group by `test`.`t2_16`.`b2` ), <primary_index_lookup>(`test`.`t1_16`.`a1` in <temporary table> on distinct_key where ((`test`.`t1_16`.`a1` = `<subquery2>`.`group_concat(b1)`))))) +Note 1003 select left(`test`.`t1_16`.`a1`,7) AS `left(a1,7)`,left(`test`.`t1_16`.`a2`,7) AS `left(a2,7)` from `test`.`t1_16` where <expr_cache><`test`.`t1_16`.`a1`>(<in_optimizer>(`test`.`t1_16`.`a1`,`test`.`t1_16`.`a1` in ( <materialize> (select group_concat(`test`.`t2_16`.`b1` separator ',') from `test`.`t2_16` group by `test`.`t2_16`.`b2` ), <primary_index_lookup>(`test`.`t1_16`.`a1` in <temporary table> on distinct_key where ((`test`.`t1_16`.`a1` = `<subquery2>`.`group_concat(b1)`)))))) select left(a1,7), left(a2,7) from t1_16 where a1 in (select group_concat(b1) from t2_16 group by b2); @@ -675,7 +675,7 @@ id select_type table type possible_keys key key_len ref rows filtered Extra 3 DEPENDENT SUBQUERY t2 ALL NULL NULL NULL NULL 5 100.00 Using where; Using join buffer (flat, BNL join) 4 SUBQUERY t3 ALL NULL NULL NULL NULL 4 100.00 Using where Warnings: -Note 1003 select `test`.`t1`.`a1` AS `a1`,`test`.`t1`.`a2` AS `a2` from `test`.`t1` where <in_optimizer>(concat(`test`.`t1`.`a1`,'x'),<exists>(select left(`test`.`t1_16`.`a1`,8) from `test`.`t1_16` where (<in_optimizer>((`test`.`t1_16`.`a1`,`test`.`t1_16`.`a2`),<exists>(select `test`.`t2_16`.`b1`,`test`.`t2_16`.`b2` from `test`.`t2_16` join `test`.`t2` where ((`test`.`t2`.`b2` = substr(`test`.`t2_16`.`b2`,1,6)) and <in_optimizer>(`test`.`t2`.`b1`,`test`.`t2`.`b1` in ( <materialize> (select `test`.`t3`.`c1` from `test`.`t3` where (`test`.`t3`.`c2` > '0') ), <primary_index_lookup>(`test`.`t2`.`b1` in <temporary table> on distinct_key where ((`test`.`t2`.`b1` = `<subquery4>`.`c1`))))) and (<cache>(`test`.`t1_16`.`a1`) = `test`.`t2_16`.`b1`) and (<cache>(`test`.`t1_16`.`a2`) = `test`.`t2_16`.`b2`)))) and (<cache>(concat(`test`.`t1`.`a1`,'x')) = left(`test`.`t1_16`.`a1`,8))))) +Note 1003 select `test`.`t1`.`a1` AS `a1`,`test`.`t1`.`a2` AS `a2` from `test`.`t1` where <expr_cache><concat(`test`.`t1`.`a1`,'x')>(<in_optimizer>(concat(`test`.`t1`.`a1`,'x'),<exists>(select left(`test`.`t1_16`.`a1`,8) from `test`.`t1_16` where (<expr_cache><`test`.`t1_16`.`a1`,`test`.`t1_16`.`a2`>(<in_optimizer>((`test`.`t1_16`.`a1`,`test`.`t1_16`.`a2`),<exists>(select `test`.`t2_16`.`b1`,`test`.`t2_16`.`b2` from `test`.`t2_16` join `test`.`t2` where ((`test`.`t2`.`b2` = substr(`test`.`t2_16`.`b2`,1,6)) and <expr_cache><`test`.`t2`.`b1`>(<in_optimizer>(`test`.`t2`.`b1`,`test`.`t2`.`b1` in ( <materialize> (select `test`.`t3`.`c1` from `test`.`t3` where (`test`.`t3`.`c2` > '0') ), <primary_index_lookup>(`test`.`t2`.`b1` in <temporary table> on distinct_key where ((`test`.`t2`.`b1` = `<subquery4>`.`c1`)))))) and (<cache>(`test`.`t1_16`.`a1`) = `test`.`t2_16`.`b1`) and (<cache>(`test`.`t1_16`.`a2`) = `test`.`t2_16`.`b2`))))) and (<cache>(concat(`test`.`t1`.`a1`,'x')) = left(`test`.`t1_16`.`a1`,8)))))) drop table t1_16, t2_16, t3_16; set @blob_len = 512; set @suffix_len = @blob_len - @prefix_len; @@ -709,7 +709,7 @@ id select_type table type possible_keys key key_len ref rows filtered Extra 1 PRIMARY t1_512 ALL NULL NULL NULL NULL 3 100.00 Using where 2 DEPENDENT SUBQUERY t2_512 ALL NULL NULL NULL NULL 3 100.00 Using where Warnings: -Note 1003 select left(`test`.`t1_512`.`a1`,7) AS `left(a1,7)`,left(`test`.`t1_512`.`a2`,7) AS `left(a2,7)` from `test`.`t1_512` where <in_optimizer>(`test`.`t1_512`.`a1`,<exists>(select `test`.`t2_512`.`b1` from `test`.`t2_512` where ((`test`.`t2_512`.`b1` > '0') and (<cache>(`test`.`t1_512`.`a1`) = `test`.`t2_512`.`b1`)))) +Note 1003 select left(`test`.`t1_512`.`a1`,7) AS `left(a1,7)`,left(`test`.`t1_512`.`a2`,7) AS `left(a2,7)` from `test`.`t1_512` where <expr_cache><`test`.`t1_512`.`a1`>(<in_optimizer>(`test`.`t1_512`.`a1`,<exists>(select `test`.`t2_512`.`b1` from `test`.`t2_512` where ((`test`.`t2_512`.`b1` > '0') and (<cache>(`test`.`t1_512`.`a1`) = `test`.`t2_512`.`b1`))))) select left(a1,7), left(a2,7) from t1_512 where a1 in (select b1 from t2_512 where b1 > '0'); @@ -723,7 +723,7 @@ id select_type table type possible_keys key key_len ref rows filtered Extra 1 PRIMARY t1_512 ALL NULL NULL NULL NULL 3 100.00 Using where 2 DEPENDENT SUBQUERY t2_512 ALL NULL NULL NULL NULL 3 100.00 Using where Warnings: -Note 1003 select left(`test`.`t1_512`.`a1`,7) AS `left(a1,7)`,left(`test`.`t1_512`.`a2`,7) AS `left(a2,7)` from `test`.`t1_512` where <in_optimizer>((`test`.`t1_512`.`a1`,`test`.`t1_512`.`a2`),<exists>(select `test`.`t2_512`.`b1`,`test`.`t2_512`.`b2` from `test`.`t2_512` where ((`test`.`t2_512`.`b1` > '0') and (<cache>(`test`.`t1_512`.`a1`) = `test`.`t2_512`.`b1`) and (<cache>(`test`.`t1_512`.`a2`) = `test`.`t2_512`.`b2`)))) +Note 1003 select left(`test`.`t1_512`.`a1`,7) AS `left(a1,7)`,left(`test`.`t1_512`.`a2`,7) AS `left(a2,7)` from `test`.`t1_512` where <expr_cache><`test`.`t1_512`.`a1`,`test`.`t1_512`.`a2`>(<in_optimizer>((`test`.`t1_512`.`a1`,`test`.`t1_512`.`a2`),<exists>(select `test`.`t2_512`.`b1`,`test`.`t2_512`.`b2` from `test`.`t2_512` where ((`test`.`t2_512`.`b1` > '0') and (<cache>(`test`.`t1_512`.`a1`) = `test`.`t2_512`.`b1`) and (<cache>(`test`.`t1_512`.`a2`) = `test`.`t2_512`.`b2`))))) select left(a1,7), left(a2,7) from t1_512 where (a1,a2) in (select b1, b2 from t2_512 where b1 > '0'); @@ -737,7 +737,7 @@ id select_type table type possible_keys key key_len ref rows filtered Extra 1 PRIMARY t1_512 ALL NULL NULL NULL NULL 3 100.00 Using where 2 SUBQUERY t2_512 ALL NULL NULL NULL NULL 3 100.00 Using where Warnings: -Note 1003 select left(`test`.`t1_512`.`a1`,7) AS `left(a1,7)`,left(`test`.`t1_512`.`a2`,7) AS `left(a2,7)` from `test`.`t1_512` where <in_optimizer>(`test`.`t1_512`.`a1`,`test`.`t1_512`.`a1` in ( <materialize> (select substr(`test`.`t2_512`.`b1`,1,512) from `test`.`t2_512` where (`test`.`t2_512`.`b1` > '0') ), <primary_index_lookup>(`test`.`t1_512`.`a1` in <temporary table> on distinct_key where ((`test`.`t1_512`.`a1` = `<subquery2>`.`substring(b1,1,512)`))))) +Note 1003 select left(`test`.`t1_512`.`a1`,7) AS `left(a1,7)`,left(`test`.`t1_512`.`a2`,7) AS `left(a2,7)` from `test`.`t1_512` where <expr_cache><`test`.`t1_512`.`a1`>(<in_optimizer>(`test`.`t1_512`.`a1`,`test`.`t1_512`.`a1` in ( <materialize> (select substr(`test`.`t2_512`.`b1`,1,512) from `test`.`t2_512` where (`test`.`t2_512`.`b1` > '0') ), <primary_index_lookup>(`test`.`t1_512`.`a1` in <temporary table> on distinct_key where ((`test`.`t1_512`.`a1` = `<subquery2>`.`substring(b1,1,512)`)))))) select left(a1,7), left(a2,7) from t1_512 where a1 in (select substring(b1,1,512) from t2_512 where b1 > '0'); @@ -751,7 +751,7 @@ id select_type table type possible_keys key key_len ref rows filtered Extra 1 PRIMARY t1_512 ALL NULL NULL NULL NULL 3 100.00 Using where 2 SUBQUERY t2_512 ALL NULL NULL NULL NULL 3 100.00 Using filesort Warnings: -Note 1003 select left(`test`.`t1_512`.`a1`,7) AS `left(a1,7)`,left(`test`.`t1_512`.`a2`,7) AS `left(a2,7)` from `test`.`t1_512` where <in_optimizer>(`test`.`t1_512`.`a1`,`test`.`t1_512`.`a1` in ( <materialize> (select group_concat(`test`.`t2_512`.`b1` separator ',') from `test`.`t2_512` group by `test`.`t2_512`.`b2` ), <primary_index_lookup>(`test`.`t1_512`.`a1` in <temporary table> on distinct_key where ((`test`.`t1_512`.`a1` = `<subquery2>`.`group_concat(b1)`))))) +Note 1003 select left(`test`.`t1_512`.`a1`,7) AS `left(a1,7)`,left(`test`.`t1_512`.`a2`,7) AS `left(a2,7)` from `test`.`t1_512` where <expr_cache><`test`.`t1_512`.`a1`>(<in_optimizer>(`test`.`t1_512`.`a1`,`test`.`t1_512`.`a1` in ( <materialize> (select group_concat(`test`.`t2_512`.`b1` separator ',') from `test`.`t2_512` group by `test`.`t2_512`.`b2` ), <primary_index_lookup>(`test`.`t1_512`.`a1` in <temporary table> on distinct_key where ((`test`.`t1_512`.`a1` = `<subquery2>`.`group_concat(b1)`)))))) select left(a1,7), left(a2,7) from t1_512 where a1 in (select group_concat(b1) from t2_512 group by b2); @@ -764,7 +764,7 @@ id select_type table type possible_keys key key_len ref rows filtered Extra 1 PRIMARY t1_512 ALL NULL NULL NULL NULL 3 100.00 Using where 2 SUBQUERY t2_512 ALL NULL NULL NULL NULL 3 100.00 Using filesort Warnings: -Note 1003 select left(`test`.`t1_512`.`a1`,7) AS `left(a1,7)`,left(`test`.`t1_512`.`a2`,7) AS `left(a2,7)` from `test`.`t1_512` where <in_optimizer>(`test`.`t1_512`.`a1`,`test`.`t1_512`.`a1` in ( <materialize> (select group_concat(`test`.`t2_512`.`b1` separator ',') from `test`.`t2_512` group by `test`.`t2_512`.`b2` ), <primary_index_lookup>(`test`.`t1_512`.`a1` in <temporary table> on distinct_key where ((`test`.`t1_512`.`a1` = `<subquery2>`.`group_concat(b1)`))))) +Note 1003 select left(`test`.`t1_512`.`a1`,7) AS `left(a1,7)`,left(`test`.`t1_512`.`a2`,7) AS `left(a2,7)` from `test`.`t1_512` where <expr_cache><`test`.`t1_512`.`a1`>(<in_optimizer>(`test`.`t1_512`.`a1`,`test`.`t1_512`.`a1` in ( <materialize> (select group_concat(`test`.`t2_512`.`b1` separator ',') from `test`.`t2_512` group by `test`.`t2_512`.`b2` ), <primary_index_lookup>(`test`.`t1_512`.`a1` in <temporary table> on distinct_key where ((`test`.`t1_512`.`a1` = `<subquery2>`.`group_concat(b1)`)))))) select left(a1,7), left(a2,7) from t1_512 where a1 in (select group_concat(b1) from t2_512 group by b2); @@ -802,7 +802,7 @@ id select_type table type possible_keys key key_len ref rows filtered Extra 1 PRIMARY t1_1024 ALL NULL NULL NULL NULL 3 100.00 Using where 2 DEPENDENT SUBQUERY t2_1024 ALL NULL NULL NULL NULL 3 100.00 Using where Warnings: -Note 1003 select left(`test`.`t1_1024`.`a1`,7) AS `left(a1,7)`,left(`test`.`t1_1024`.`a2`,7) AS `left(a2,7)` from `test`.`t1_1024` where <in_optimizer>(`test`.`t1_1024`.`a1`,<exists>(select `test`.`t2_1024`.`b1` from `test`.`t2_1024` where ((`test`.`t2_1024`.`b1` > '0') and (<cache>(`test`.`t1_1024`.`a1`) = `test`.`t2_1024`.`b1`)))) +Note 1003 select left(`test`.`t1_1024`.`a1`,7) AS `left(a1,7)`,left(`test`.`t1_1024`.`a2`,7) AS `left(a2,7)` from `test`.`t1_1024` where <expr_cache><`test`.`t1_1024`.`a1`>(<in_optimizer>(`test`.`t1_1024`.`a1`,<exists>(select `test`.`t2_1024`.`b1` from `test`.`t2_1024` where ((`test`.`t2_1024`.`b1` > '0') and (<cache>(`test`.`t1_1024`.`a1`) = `test`.`t2_1024`.`b1`))))) select left(a1,7), left(a2,7) from t1_1024 where a1 in (select b1 from t2_1024 where b1 > '0'); @@ -816,7 +816,7 @@ id select_type table type possible_keys key key_len ref rows filtered Extra 1 PRIMARY t1_1024 ALL NULL NULL NULL NULL 3 100.00 Using where 2 DEPENDENT SUBQUERY t2_1024 ALL NULL NULL NULL NULL 3 100.00 Using where Warnings: -Note 1003 select left(`test`.`t1_1024`.`a1`,7) AS `left(a1,7)`,left(`test`.`t1_1024`.`a2`,7) AS `left(a2,7)` from `test`.`t1_1024` where <in_optimizer>((`test`.`t1_1024`.`a1`,`test`.`t1_1024`.`a2`),<exists>(select `test`.`t2_1024`.`b1`,`test`.`t2_1024`.`b2` from `test`.`t2_1024` where ((`test`.`t2_1024`.`b1` > '0') and (<cache>(`test`.`t1_1024`.`a1`) = `test`.`t2_1024`.`b1`) and (<cache>(`test`.`t1_1024`.`a2`) = `test`.`t2_1024`.`b2`)))) +Note 1003 select left(`test`.`t1_1024`.`a1`,7) AS `left(a1,7)`,left(`test`.`t1_1024`.`a2`,7) AS `left(a2,7)` from `test`.`t1_1024` where <expr_cache><`test`.`t1_1024`.`a1`,`test`.`t1_1024`.`a2`>(<in_optimizer>((`test`.`t1_1024`.`a1`,`test`.`t1_1024`.`a2`),<exists>(select `test`.`t2_1024`.`b1`,`test`.`t2_1024`.`b2` from `test`.`t2_1024` where ((`test`.`t2_1024`.`b1` > '0') and (<cache>(`test`.`t1_1024`.`a1`) = `test`.`t2_1024`.`b1`) and (<cache>(`test`.`t1_1024`.`a2`) = `test`.`t2_1024`.`b2`))))) select left(a1,7), left(a2,7) from t1_1024 where (a1,a2) in (select b1, b2 from t2_1024 where b1 > '0'); @@ -830,7 +830,7 @@ id select_type table type possible_keys key key_len ref rows filtered Extra 1 PRIMARY t1_1024 ALL NULL NULL NULL NULL 3 100.00 Using where 2 DEPENDENT SUBQUERY t2_1024 ALL NULL NULL NULL NULL 3 100.00 Using where Warnings: -Note 1003 select left(`test`.`t1_1024`.`a1`,7) AS `left(a1,7)`,left(`test`.`t1_1024`.`a2`,7) AS `left(a2,7)` from `test`.`t1_1024` where <in_optimizer>(`test`.`t1_1024`.`a1`,<exists>(select substr(`test`.`t2_1024`.`b1`,1,1024) from `test`.`t2_1024` where ((`test`.`t2_1024`.`b1` > '0') and (<cache>(`test`.`t1_1024`.`a1`) = substr(`test`.`t2_1024`.`b1`,1,1024))))) +Note 1003 select left(`test`.`t1_1024`.`a1`,7) AS `left(a1,7)`,left(`test`.`t1_1024`.`a2`,7) AS `left(a2,7)` from `test`.`t1_1024` where <expr_cache><`test`.`t1_1024`.`a1`>(<in_optimizer>(`test`.`t1_1024`.`a1`,<exists>(select substr(`test`.`t2_1024`.`b1`,1,1024) from `test`.`t2_1024` where ((`test`.`t2_1024`.`b1` > '0') and (<cache>(`test`.`t1_1024`.`a1`) = substr(`test`.`t2_1024`.`b1`,1,1024)))))) select left(a1,7), left(a2,7) from t1_1024 where a1 in (select substring(b1,1,1024) from t2_1024 where b1 > '0'); @@ -844,7 +844,7 @@ id select_type table type possible_keys key key_len ref rows filtered Extra 1 PRIMARY t1_1024 ALL NULL NULL NULL NULL 3 100.00 Using where 2 SUBQUERY t2_1024 ALL NULL NULL NULL NULL 3 100.00 Using filesort Warnings: -Note 1003 select left(`test`.`t1_1024`.`a1`,7) AS `left(a1,7)`,left(`test`.`t1_1024`.`a2`,7) AS `left(a2,7)` from `test`.`t1_1024` where <in_optimizer>(`test`.`t1_1024`.`a1`,`test`.`t1_1024`.`a1` in ( <materialize> (select group_concat(`test`.`t2_1024`.`b1` separator ',') from `test`.`t2_1024` group by `test`.`t2_1024`.`b2` ), <primary_index_lookup>(`test`.`t1_1024`.`a1` in <temporary table> on distinct_key where ((`test`.`t1_1024`.`a1` = `<subquery2>`.`group_concat(b1)`))))) +Note 1003 select left(`test`.`t1_1024`.`a1`,7) AS `left(a1,7)`,left(`test`.`t1_1024`.`a2`,7) AS `left(a2,7)` from `test`.`t1_1024` where <expr_cache><`test`.`t1_1024`.`a1`>(<in_optimizer>(`test`.`t1_1024`.`a1`,`test`.`t1_1024`.`a1` in ( <materialize> (select group_concat(`test`.`t2_1024`.`b1` separator ',') from `test`.`t2_1024` group by `test`.`t2_1024`.`b2` ), <primary_index_lookup>(`test`.`t1_1024`.`a1` in <temporary table> on distinct_key where ((`test`.`t1_1024`.`a1` = `<subquery2>`.`group_concat(b1)`)))))) select left(a1,7), left(a2,7) from t1_1024 where a1 in (select group_concat(b1) from t2_1024 group by b2); @@ -857,7 +857,7 @@ id select_type table type possible_keys key key_len ref rows filtered Extra 1 PRIMARY t1_1024 ALL NULL NULL NULL NULL 3 100.00 Using where 2 SUBQUERY t2_1024 ALL NULL NULL NULL NULL 3 100.00 Using filesort Warnings: -Note 1003 select left(`test`.`t1_1024`.`a1`,7) AS `left(a1,7)`,left(`test`.`t1_1024`.`a2`,7) AS `left(a2,7)` from `test`.`t1_1024` where <in_optimizer>(`test`.`t1_1024`.`a1`,`test`.`t1_1024`.`a1` in ( <materialize> (select group_concat(`test`.`t2_1024`.`b1` separator ',') from `test`.`t2_1024` group by `test`.`t2_1024`.`b2` ), <primary_index_lookup>(`test`.`t1_1024`.`a1` in <temporary table> on distinct_key where ((`test`.`t1_1024`.`a1` = `<subquery2>`.`group_concat(b1)`))))) +Note 1003 select left(`test`.`t1_1024`.`a1`,7) AS `left(a1,7)`,left(`test`.`t1_1024`.`a2`,7) AS `left(a2,7)` from `test`.`t1_1024` where <expr_cache><`test`.`t1_1024`.`a1`>(<in_optimizer>(`test`.`t1_1024`.`a1`,`test`.`t1_1024`.`a1` in ( <materialize> (select group_concat(`test`.`t2_1024`.`b1` separator ',') from `test`.`t2_1024` group by `test`.`t2_1024`.`b2` ), <primary_index_lookup>(`test`.`t1_1024`.`a1` in <temporary table> on distinct_key where ((`test`.`t1_1024`.`a1` = `<subquery2>`.`group_concat(b1)`)))))) select left(a1,7), left(a2,7) from t1_1024 where a1 in (select group_concat(b1) from t2_1024 group by b2); @@ -895,7 +895,7 @@ id select_type table type possible_keys key key_len ref rows filtered Extra 1 PRIMARY t1_1025 ALL NULL NULL NULL NULL 3 100.00 Using where 2 DEPENDENT SUBQUERY t2_1025 ALL NULL NULL NULL NULL 3 100.00 Using where Warnings: -Note 1003 select left(`test`.`t1_1025`.`a1`,7) AS `left(a1,7)`,left(`test`.`t1_1025`.`a2`,7) AS `left(a2,7)` from `test`.`t1_1025` where <in_optimizer>(`test`.`t1_1025`.`a1`,<exists>(select `test`.`t2_1025`.`b1` from `test`.`t2_1025` where ((`test`.`t2_1025`.`b1` > '0') and (<cache>(`test`.`t1_1025`.`a1`) = `test`.`t2_1025`.`b1`)))) +Note 1003 select left(`test`.`t1_1025`.`a1`,7) AS `left(a1,7)`,left(`test`.`t1_1025`.`a2`,7) AS `left(a2,7)` from `test`.`t1_1025` where <expr_cache><`test`.`t1_1025`.`a1`>(<in_optimizer>(`test`.`t1_1025`.`a1`,<exists>(select `test`.`t2_1025`.`b1` from `test`.`t2_1025` where ((`test`.`t2_1025`.`b1` > '0') and (<cache>(`test`.`t1_1025`.`a1`) = `test`.`t2_1025`.`b1`))))) select left(a1,7), left(a2,7) from t1_1025 where a1 in (select b1 from t2_1025 where b1 > '0'); @@ -909,7 +909,7 @@ id select_type table type possible_keys key key_len ref rows filtered Extra 1 PRIMARY t1_1025 ALL NULL NULL NULL NULL 3 100.00 Using where 2 DEPENDENT SUBQUERY t2_1025 ALL NULL NULL NULL NULL 3 100.00 Using where Warnings: -Note 1003 select left(`test`.`t1_1025`.`a1`,7) AS `left(a1,7)`,left(`test`.`t1_1025`.`a2`,7) AS `left(a2,7)` from `test`.`t1_1025` where <in_optimizer>((`test`.`t1_1025`.`a1`,`test`.`t1_1025`.`a2`),<exists>(select `test`.`t2_1025`.`b1`,`test`.`t2_1025`.`b2` from `test`.`t2_1025` where ((`test`.`t2_1025`.`b1` > '0') and (<cache>(`test`.`t1_1025`.`a1`) = `test`.`t2_1025`.`b1`) and (<cache>(`test`.`t1_1025`.`a2`) = `test`.`t2_1025`.`b2`)))) +Note 1003 select left(`test`.`t1_1025`.`a1`,7) AS `left(a1,7)`,left(`test`.`t1_1025`.`a2`,7) AS `left(a2,7)` from `test`.`t1_1025` where <expr_cache><`test`.`t1_1025`.`a1`,`test`.`t1_1025`.`a2`>(<in_optimizer>((`test`.`t1_1025`.`a1`,`test`.`t1_1025`.`a2`),<exists>(select `test`.`t2_1025`.`b1`,`test`.`t2_1025`.`b2` from `test`.`t2_1025` where ((`test`.`t2_1025`.`b1` > '0') and (<cache>(`test`.`t1_1025`.`a1`) = `test`.`t2_1025`.`b1`) and (<cache>(`test`.`t1_1025`.`a2`) = `test`.`t2_1025`.`b2`))))) select left(a1,7), left(a2,7) from t1_1025 where (a1,a2) in (select b1, b2 from t2_1025 where b1 > '0'); @@ -923,7 +923,7 @@ id select_type table type possible_keys key key_len ref rows filtered Extra 1 PRIMARY t1_1025 ALL NULL NULL NULL NULL 3 100.00 Using where 2 DEPENDENT SUBQUERY t2_1025 ALL NULL NULL NULL NULL 3 100.00 Using where Warnings: -Note 1003 select left(`test`.`t1_1025`.`a1`,7) AS `left(a1,7)`,left(`test`.`t1_1025`.`a2`,7) AS `left(a2,7)` from `test`.`t1_1025` where <in_optimizer>(`test`.`t1_1025`.`a1`,<exists>(select substr(`test`.`t2_1025`.`b1`,1,1025) from `test`.`t2_1025` where ((`test`.`t2_1025`.`b1` > '0') and (<cache>(`test`.`t1_1025`.`a1`) = substr(`test`.`t2_1025`.`b1`,1,1025))))) +Note 1003 select left(`test`.`t1_1025`.`a1`,7) AS `left(a1,7)`,left(`test`.`t1_1025`.`a2`,7) AS `left(a2,7)` from `test`.`t1_1025` where <expr_cache><`test`.`t1_1025`.`a1`>(<in_optimizer>(`test`.`t1_1025`.`a1`,<exists>(select substr(`test`.`t2_1025`.`b1`,1,1025) from `test`.`t2_1025` where ((`test`.`t2_1025`.`b1` > '0') and (<cache>(`test`.`t1_1025`.`a1`) = substr(`test`.`t2_1025`.`b1`,1,1025)))))) select left(a1,7), left(a2,7) from t1_1025 where a1 in (select substring(b1,1,1025) from t2_1025 where b1 > '0'); @@ -937,7 +937,7 @@ id select_type table type possible_keys key key_len ref rows filtered Extra 1 PRIMARY t1_1025 ALL NULL NULL NULL NULL 3 100.00 Using where 2 SUBQUERY t2_1025 ALL NULL NULL NULL NULL 3 100.00 Using filesort Warnings: -Note 1003 select left(`test`.`t1_1025`.`a1`,7) AS `left(a1,7)`,left(`test`.`t1_1025`.`a2`,7) AS `left(a2,7)` from `test`.`t1_1025` where <in_optimizer>(`test`.`t1_1025`.`a1`,`test`.`t1_1025`.`a1` in ( <materialize> (select group_concat(`test`.`t2_1025`.`b1` separator ',') from `test`.`t2_1025` group by `test`.`t2_1025`.`b2` ), <primary_index_lookup>(`test`.`t1_1025`.`a1` in <temporary table> on distinct_key where ((`test`.`t1_1025`.`a1` = `<subquery2>`.`group_concat(b1)`))))) +Note 1003 select left(`test`.`t1_1025`.`a1`,7) AS `left(a1,7)`,left(`test`.`t1_1025`.`a2`,7) AS `left(a2,7)` from `test`.`t1_1025` where <expr_cache><`test`.`t1_1025`.`a1`>(<in_optimizer>(`test`.`t1_1025`.`a1`,`test`.`t1_1025`.`a1` in ( <materialize> (select group_concat(`test`.`t2_1025`.`b1` separator ',') from `test`.`t2_1025` group by `test`.`t2_1025`.`b2` ), <primary_index_lookup>(`test`.`t1_1025`.`a1` in <temporary table> on distinct_key where ((`test`.`t1_1025`.`a1` = `<subquery2>`.`group_concat(b1)`)))))) select left(a1,7), left(a2,7) from t1_1025 where a1 in (select group_concat(b1) from t2_1025 group by b2); @@ -950,7 +950,7 @@ id select_type table type possible_keys key key_len ref rows filtered Extra 1 PRIMARY t1_1025 ALL NULL NULL NULL NULL 3 100.00 Using where 2 SUBQUERY t2_1025 ALL NULL NULL NULL NULL 3 100.00 Using filesort Warnings: -Note 1003 select left(`test`.`t1_1025`.`a1`,7) AS `left(a1,7)`,left(`test`.`t1_1025`.`a2`,7) AS `left(a2,7)` from `test`.`t1_1025` where <in_optimizer>(`test`.`t1_1025`.`a1`,`test`.`t1_1025`.`a1` in ( <materialize> (select group_concat(`test`.`t2_1025`.`b1` separator ',') from `test`.`t2_1025` group by `test`.`t2_1025`.`b2` ), <primary_index_lookup>(`test`.`t1_1025`.`a1` in <temporary table> on distinct_key where ((`test`.`t1_1025`.`a1` = `<subquery2>`.`group_concat(b1)`))))) +Note 1003 select left(`test`.`t1_1025`.`a1`,7) AS `left(a1,7)`,left(`test`.`t1_1025`.`a2`,7) AS `left(a2,7)` from `test`.`t1_1025` where <expr_cache><`test`.`t1_1025`.`a1`>(<in_optimizer>(`test`.`t1_1025`.`a1`,`test`.`t1_1025`.`a1` in ( <materialize> (select group_concat(`test`.`t2_1025`.`b1` separator ',') from `test`.`t2_1025` group by `test`.`t2_1025`.`b2` ), <primary_index_lookup>(`test`.`t1_1025`.`a1` in <temporary table> on distinct_key where ((`test`.`t1_1025`.`a1` = `<subquery2>`.`group_concat(b1)`)))))) select left(a1,7), left(a2,7) from t1_1025 where a1 in (select group_concat(b1) from t2_1025 group by b2); @@ -971,7 +971,7 @@ id select_type table type possible_keys key key_len ref rows filtered Extra 1 PRIMARY t1bit ALL NULL NULL NULL NULL 3 100.00 Using where 2 SUBQUERY t2bit ALL NULL NULL NULL NULL 3 100.00 Warnings: -Note 1003 select conv(`test`.`t1bit`.`a1`,10,2) AS `bin(a1)`,conv(`test`.`t1bit`.`a2`,10,2) AS `bin(a2)` from `test`.`t1bit` where <in_optimizer>((`test`.`t1bit`.`a1`,`test`.`t1bit`.`a2`),(`test`.`t1bit`.`a1`,`test`.`t1bit`.`a2`) in ( <materialize> (select `test`.`t2bit`.`b1`,`test`.`t2bit`.`b2` from `test`.`t2bit` ), <primary_index_lookup>(`test`.`t1bit`.`a1` in <temporary table> on distinct_key where ((`test`.`t1bit`.`a1` = `<subquery2>`.`b1`) and (`test`.`t1bit`.`a2` = `<subquery2>`.`b2`))))) +Note 1003 select conv(`test`.`t1bit`.`a1`,10,2) AS `bin(a1)`,conv(`test`.`t1bit`.`a2`,10,2) AS `bin(a2)` from `test`.`t1bit` where <expr_cache><`test`.`t1bit`.`a1`,`test`.`t1bit`.`a2`>(<in_optimizer>((`test`.`t1bit`.`a1`,`test`.`t1bit`.`a2`),(`test`.`t1bit`.`a1`,`test`.`t1bit`.`a2`) in ( <materialize> (select `test`.`t2bit`.`b1`,`test`.`t2bit`.`b2` from `test`.`t2bit` ), <primary_index_lookup>(`test`.`t1bit`.`a1` in <temporary table> on distinct_key where ((`test`.`t1bit`.`a1` = `<subquery2>`.`b1`) and (`test`.`t1bit`.`a2` = `<subquery2>`.`b2`)))))) select bin(a1), bin(a2) from t1bit where (a1, a2) in (select b1, b2 from t2bit); @@ -994,7 +994,7 @@ id select_type table type possible_keys key key_len ref rows filtered Extra 1 PRIMARY t1bb ALL NULL NULL NULL NULL 3 100.00 Using where 2 DEPENDENT SUBQUERY t2bb ALL NULL NULL NULL NULL 3 100.00 Using where Warnings: -Note 1003 select conv(`test`.`t1bb`.`a1`,10,2) AS `bin(a1)`,`test`.`t1bb`.`a2` AS `a2` from `test`.`t1bb` where <in_optimizer>((`test`.`t1bb`.`a1`,`test`.`t1bb`.`a2`),<exists>(select `test`.`t2bb`.`b1`,`test`.`t2bb`.`b2` from `test`.`t2bb` where ((<cache>(`test`.`t1bb`.`a1`) = `test`.`t2bb`.`b1`) and (<cache>(`test`.`t1bb`.`a2`) = `test`.`t2bb`.`b2`)))) +Note 1003 select conv(`test`.`t1bb`.`a1`,10,2) AS `bin(a1)`,`test`.`t1bb`.`a2` AS `a2` from `test`.`t1bb` where <expr_cache><`test`.`t1bb`.`a1`,`test`.`t1bb`.`a2`>(<in_optimizer>((`test`.`t1bb`.`a1`,`test`.`t1bb`.`a2`),<exists>(select `test`.`t2bb`.`b1`,`test`.`t2bb`.`b2` from `test`.`t2bb` where ((<cache>(`test`.`t1bb`.`a1`) = `test`.`t2bb`.`b1`) and (<cache>(`test`.`t1bb`.`a2`) = `test`.`t2bb`.`b2`))))) select bin(a1), a2 from t1bb where (a1, a2) in (select b1, b2 from t2bb); @@ -1042,7 +1042,7 @@ id select_type table type possible_keys key key_len ref rows filtered Extra 1 PRIMARY t1 ALL NULL NULL NULL NULL 7 100.00 Using where 2 SUBQUERY t2 ALL NULL NULL NULL NULL 6 100.00 Using where Warnings: -Note 1003 select `test`.`t1`.`a` AS `a` from `test`.`t1` where <in_optimizer>(`test`.`t1`.`a`,`test`.`t1`.`a` in ( <materialize> (select `test`.`t2`.`c` from `test`.`t2` where (`test`.`t2`.`d` >= 20) ), <primary_index_lookup>(`test`.`t1`.`a` in <temporary table> on distinct_key where ((`test`.`t1`.`a` = `<subquery2>`.`c`))))) +Note 1003 select `test`.`t1`.`a` AS `a` from `test`.`t1` where <expr_cache><`test`.`t1`.`a`>(<in_optimizer>(`test`.`t1`.`a`,`test`.`t1`.`a` in ( <materialize> (select `test`.`t2`.`c` from `test`.`t2` where (`test`.`t2`.`d` >= 20) ), <primary_index_lookup>(`test`.`t1`.`a` in <temporary table> on distinct_key where ((`test`.`t1`.`a` = `<subquery2>`.`c`)))))) select a from t1 where a in (select c from t2 where d >= 20); a 2 @@ -1056,7 +1056,7 @@ id select_type table type possible_keys key key_len ref rows filtered Extra 1 PRIMARY t1 index NULL it1a 4 NULL 7 100.00 Using where; Using index 2 SUBQUERY t2 ALL NULL NULL NULL NULL 6 100.00 Using where Warnings: -Note 1003 select `test`.`t1`.`a` AS `a` from `test`.`t1` where <in_optimizer>(`test`.`t1`.`a`,`test`.`t1`.`a` in ( <materialize> (select `test`.`t2`.`c` from `test`.`t2` where (`test`.`t2`.`d` >= 20) ), <primary_index_lookup>(`test`.`t1`.`a` in <temporary table> on distinct_key where ((`test`.`t1`.`a` = `<subquery2>`.`c`))))) +Note 1003 select `test`.`t1`.`a` AS `a` from `test`.`t1` where <expr_cache><`test`.`t1`.`a`>(<in_optimizer>(`test`.`t1`.`a`,`test`.`t1`.`a` in ( <materialize> (select `test`.`t2`.`c` from `test`.`t2` where (`test`.`t2`.`d` >= 20) ), <primary_index_lookup>(`test`.`t1`.`a` in <temporary table> on distinct_key where ((`test`.`t1`.`a` = `<subquery2>`.`c`)))))) select a from t1 where a in (select c from t2 where d >= 20); a 2 @@ -1070,7 +1070,7 @@ id select_type table type possible_keys key key_len ref rows filtered Extra 1 PRIMARY t1 index NULL it1a 4 NULL 7 100.00 Using where; Using index 2 SUBQUERY t2 ALL NULL NULL NULL NULL 7 100.00 Using where Warnings: -Note 1003 select `test`.`t1`.`a` AS `a` from `test`.`t1` where <in_optimizer>(`test`.`t1`.`a`,`test`.`t1`.`a` in ( <materialize> (select `test`.`t2`.`c` from `test`.`t2` where (`test`.`t2`.`d` >= 20) ), <primary_index_lookup>(`test`.`t1`.`a` in <temporary table> on distinct_key where ((`test`.`t1`.`a` = `<subquery2>`.`c`))))) +Note 1003 select `test`.`t1`.`a` AS `a` from `test`.`t1` where <expr_cache><`test`.`t1`.`a`>(<in_optimizer>(`test`.`t1`.`a`,`test`.`t1`.`a` in ( <materialize> (select `test`.`t2`.`c` from `test`.`t2` where (`test`.`t2`.`d` >= 20) ), <primary_index_lookup>(`test`.`t1`.`a` in <temporary table> on distinct_key where ((`test`.`t1`.`a` = `<subquery2>`.`c`)))))) select a from t1 where a in (select c from t2 where d >= 20); a 2 @@ -1083,7 +1083,7 @@ id select_type table type possible_keys key key_len ref rows filtered Extra 1 PRIMARY t1 index NULL it1a 4 NULL 7 100.00 Using index 2 SUBQUERY t2 ALL NULL NULL NULL NULL 7 100.00 Using where Warnings: -Note 1003 select `test`.`t1`.`a` AS `a` from `test`.`t1` group by `test`.`t1`.`a` having <in_optimizer>(`test`.`t1`.`a`,`test`.`t1`.`a` in ( <materialize> (select `test`.`t2`.`c` from `test`.`t2` where (`test`.`t2`.`d` >= 20) ), <primary_index_lookup>(`test`.`t1`.`a` in <temporary table> on distinct_key where ((`test`.`t1`.`a` = `<subquery2>`.`c`))))) +Note 1003 select `test`.`t1`.`a` AS `a` from `test`.`t1` group by `test`.`t1`.`a` having <expr_cache><`test`.`t1`.`a`>(<in_optimizer>(`test`.`t1`.`a`,`test`.`t1`.`a` in ( <materialize> (select `test`.`t2`.`c` from `test`.`t2` where (`test`.`t2`.`d` >= 20) ), <primary_index_lookup>(`test`.`t1`.`a` in <temporary table> on distinct_key where ((`test`.`t1`.`a` = `<subquery2>`.`c`)))))) select a from t1 group by a having a in (select c from t2 where d >= 20); a 2 @@ -1095,7 +1095,7 @@ id select_type table type possible_keys key key_len ref rows filtered Extra 1 PRIMARY t1 index NULL it1a 4 NULL 7 100.00 Using index 2 SUBQUERY t2 ALL NULL NULL NULL NULL 7 100.00 Using where Warnings: -Note 1003 select `test`.`t1`.`a` AS `a` from `test`.`t1` group by `test`.`t1`.`a` having <in_optimizer>(`test`.`t1`.`a`,`test`.`t1`.`a` in ( <materialize> (select `test`.`t2`.`c` from `test`.`t2` where (`test`.`t2`.`d` >= 20) ), <primary_index_lookup>(`test`.`t1`.`a` in <temporary table> on distinct_key where ((`test`.`t1`.`a` = `<subquery2>`.`c`))))) +Note 1003 select `test`.`t1`.`a` AS `a` from `test`.`t1` group by `test`.`t1`.`a` having <expr_cache><`test`.`t1`.`a`>(<in_optimizer>(`test`.`t1`.`a`,`test`.`t1`.`a` in ( <materialize> (select `test`.`t2`.`c` from `test`.`t2` where (`test`.`t2`.`d` >= 20) ), <primary_index_lookup>(`test`.`t1`.`a` in <temporary table> on distinct_key where ((`test`.`t1`.`a` = `<subquery2>`.`c`)))))) select a from t1 group by a having a in (select c from t2 where d >= 20); a 2 @@ -1109,7 +1109,7 @@ id select_type table type possible_keys key key_len ref rows filtered Extra 3 DEPENDENT SUBQUERY t3 ALL NULL NULL NULL NULL 4 100.00 Using where Warnings: Note 1276 Field or reference 'test.t1.b' of SELECT #3 was resolved in SELECT #1 -Note 1003 select `test`.`t1`.`a` AS `a` from `test`.`t1` group by `test`.`t1`.`a` having <in_optimizer>(`test`.`t1`.`a`,<exists>(select `test`.`t2`.`c` from `test`.`t2` where (<nop>(<in_optimizer>(`test`.`t2`.`d`,<exists>(select `test`.`t3`.`e` from `test`.`t3` where (max(`test`.`t1`.`b`) = `test`.`t3`.`e`) having (<cache>(`test`.`t2`.`d`) >= <ref_null_helper>(`test`.`t3`.`e`))))) and (<cache>(`test`.`t1`.`a`) = `test`.`t2`.`c`)))) +Note 1003 select `test`.`t1`.`a` AS `a` from `test`.`t1` group by `test`.`t1`.`a` having <expr_cache><`test`.`t1`.`a`,`test`.`t1`.`b`,max(`test`.`t1`.`b`),max(`test`.`t1`.`b`)>(<in_optimizer>(`test`.`t1`.`a`,<exists>(select `test`.`t2`.`c` from `test`.`t2` where (<nop>(<expr_cache><`test`.`t2`.`d`,`test`.`t1`.`b`,max(`test`.`t1`.`b`),max(`test`.`t1`.`b`)>(<in_optimizer>(`test`.`t2`.`d`,<exists>(select `test`.`t3`.`e` from `test`.`t3` where (max(`test`.`t1`.`b`) = `test`.`t3`.`e`) having (<cache>(`test`.`t2`.`d`) >= <ref_null_helper>(`test`.`t3`.`e`)))))) and (<cache>(`test`.`t1`.`a`) = `test`.`t2`.`c`))))) select a from t1 group by a having a in (select c from t2 where d >= some(select e from t3 where max(b)=e)); a @@ -1124,7 +1124,7 @@ id select_type table type possible_keys key key_len ref rows filtered Extra 3 DEPENDENT SUBQUERY t3 ALL NULL NULL NULL NULL 4 100.00 Using where Warnings: Note 1276 Field or reference 'test.t1.b' of SELECT #3 was resolved in SELECT #1 -Note 1003 select `test`.`t1`.`a` AS `a` from `test`.`t1` where <in_optimizer>(`test`.`t1`.`a`,<exists>(select `test`.`t2`.`c` from `test`.`t2` where (<nop>(<in_optimizer>(`test`.`t2`.`d`,<exists>(select `test`.`t3`.`e` from `test`.`t3` where ((`test`.`t1`.`b` = `test`.`t3`.`e`) and (<cache>(`test`.`t2`.`d`) >= `test`.`t3`.`e`))))) and (<cache>(`test`.`t1`.`a`) = `test`.`t2`.`c`)))) +Note 1003 select `test`.`t1`.`a` AS `a` from `test`.`t1` where <expr_cache><`test`.`t1`.`a`,`test`.`t1`.`b`>(<in_optimizer>(`test`.`t1`.`a`,<exists>(select `test`.`t2`.`c` from `test`.`t2` where (<nop>(<expr_cache><`test`.`t2`.`d`,`test`.`t1`.`b`>(<in_optimizer>(`test`.`t2`.`d`,<exists>(select `test`.`t3`.`e` from `test`.`t3` where ((`test`.`t1`.`b` = `test`.`t3`.`e`) and (<cache>(`test`.`t2`.`d`) >= `test`.`t3`.`e`)))))) and (<cache>(`test`.`t1`.`a`) = `test`.`t2`.`c`))))) select a from t1 where a in (select c from t2 where d >= some(select e from t3 where b=e)); a @@ -1235,7 +1235,8 @@ GROUP BY t3i ) ); id select_type table type possible_keys key key_len ref rows Extra -1 PRIMARY NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables +1 PRIMARY t1 system NULL NULL NULL NULL 1 +1 PRIMARY t4 ALL NULL NULL NULL NULL 2 Using where 2 SUBQUERY t2 ALL NULL NULL NULL NULL 2 Using where 3 SUBQUERY t3 ALL NULL NULL NULL NULL 2 Using temporary DROP TABLE t1,t2,t3,t4; @@ -1368,7 +1369,8 @@ INSERT INTO t2 VALUES (10,0),(11,0); explain SELECT * FROM t1 JOIN t2 USING (f1) WHERE t1.f1 IN (SELECT t1.pk FROM t1 ORDER BY t1.f1); id select_type table type possible_keys key key_len ref rows Extra -1 PRIMARY NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables +1 PRIMARY t1 system NULL NULL NULL NULL 1 +1 PRIMARY t2 ALL NULL NULL NULL NULL 2 Using where 2 SUBQUERY t1 system NULL NULL NULL NULL 1 SELECT * FROM t1 JOIN t2 USING (f1) WHERE t1.f1 IN (SELECT t1.pk FROM t1 ORDER BY t1.f1); @@ -1560,6 +1562,170 @@ select left(a1,7), left(a2,7) from t1_1024 where (a1,3) in (select substring(b1, left(a1,7) left(a2,7) 1 - 01x 2 - 01x drop table t1_1024, t2_1024; +# +# BUG##836491: Crash in Item_field::Item_field from add_ref_to_table_cond() with semijoin+materialization +# +CREATE TABLE t1 (c int, d varchar(1), KEY(d)) ; +INSERT INTO t1 VALUES (2,'x'),(2,'x'),(2,'j'),(2,'c'); +CREATE TABLE t2 (a int, d varchar(1)) ; +INSERT INTO t2 VALUES (1,'x'); +CREATE TABLE t3 (d varchar(1)) ; +INSERT INTO t3 VALUES ('x'),('x'),('j'),('c'); +SELECT t2.a, t1.c +FROM t1, t2 +WHERE t2.d IN ( SELECT d FROM t3 ) +AND t1.d = t2.d +GROUP BY 1 , 2; +a c +1 2 +drop table t1,t2,t3; +# +# BUG#836523: Crash in JOIN::get_partial_cost_and_fanout with semijoin+materialization +# +CREATE TABLE t1 (a varchar(1)); +INSERT INTO t1 VALUES ('a'),('a'); +CREATE TABLE t2 (a varchar(1)); +CREATE TABLE t3 (a int); +INSERT INTO t3 VALUES (1),(2); +CREATE TABLE t4 (a varchar(1)); +INSERT INTO t4 VALUES ('a'),('a'); +SELECT t1.a +FROM t1 +WHERE t1.a IN ( +SELECT t2.a +FROM t2, t3 +) +HAVING a IN ( +SELECT a +FROM t4 +); +a +DROP TABLE t1, t2, t3, t4; +# +# BUG#836507: Crash in setup_sj_materialization_part1() with semijoin+materialization +# +CREATE TABLE t1 (a int) ; +INSERT IGNORE INTO t1 VALUES (1),(1); +CREATE TABLE t2 (a int); +INSERT INTO t2 VALUES (1); +CREATE TABLE t3 (a int); +CREATE TABLE t4 (a int); +INSERT INTO t4 VALUES (2),(2); +CREATE TABLE t5 (a int); +INSERT INTO t5 VALUES (1); +SELECT * FROM t1 +WHERE (a) IN ( +SELECT t5.a +FROM ( +t2 +LEFT JOIN ( t3 , t4 ) +ON 1 = 1 +) +JOIN t5 +); +a +1 +1 +DROP TABLE t1,t2,t3,t4,t5; +# +# BUG#836532: Crash in Item_equal_fields_iterator::get_curr_field with semijoin+materialization +# +CREATE TABLE t2 (a int); +INSERT INTO t2 VALUES ('a'),('a'); +Warnings: +Warning 1366 Incorrect integer value: 'a' for column 'a' at row 1 +Warning 1366 Incorrect integer value: 'a' for column 'a' at row 2 +CREATE TABLE t4 (a varchar(1)); +INSERT INTO t4 VALUES ('m'),('o'); +CREATE TABLE t3 (a varchar(1) , b varchar(1) ) ; +INSERT INTO t3 VALUES ('b','b'); +CREATE TABLE t5 (a varchar(1), KEY (a)) ; +INSERT INTO t5 VALUES ('d'),('e'); +SELECT * +FROM t2 +WHERE t2.a = ALL ( +SELECT t4.a +FROM t4 +WHERE t4.a IN ( +SELECT t3.a +FROM t3 , t5 +WHERE ( t5.a = t3.b ) +) +); +a +0 +0 +DROP TABLE t2,t3,t4,t5; +# +# BUG#860300: Second crash with get_fanout_with_deps() with semijoin + materialization +# +set @tmp_860300=@@optimizer_switch; +set optimizer_switch='semijoin=on,materialization=on,loosescan=off,firstmatch=off'; +CREATE TABLE t1 (f2 int); +INSERT INTO t1 VALUES (9),(6); +CREATE TABLE t3 (f4 int); +CREATE TABLE t4 (f6 varchar(1)); +SELECT * +FROM t3 +WHERE 'h' IN (SELECT f6 +FROM t4 +WHERE 5 IN (SELECT f2 FROM t1) +GROUP BY t4.f6); +f4 +DROP TABLE t1,t3,t4; +set optimizer_switch=@tmp_860300; +# +# BUG#860535: Assertion `keypart_map' failed in mi_rkey with semijoin +# +set @tmp_860535=@@optimizer_switch; +set optimizer_switch='semijoin=on,materialization=on,loosescan=off,firstmatch=off'; +CREATE TABLE t1 (f3 int) ; +INSERT INTO t1 VALUES (1),(7); +CREATE TABLE t2 (f3 int , f5 varchar(1), KEY (f3)) ; +INSERT INTO t2 VALUES (7,'b'); +CREATE TABLE t3 (f3 int , f4 varchar(1) , KEY(f3), KEY (f4,f3)) ; +INSERT INTO t3 VALUES (1,'t'),(7,'g'); +CREATE TABLE t4 +SELECT f3 +FROM t1 WHERE ( f3 ) NOT IN ( +SELECT f3 +FROM t2 +WHERE f5 IN ( +SELECT f4 +FROM t3 +WHERE t3.f3 < 3 +) +); +SELECT * FROM t4; +f3 +1 +7 +DROP TABLE t1, t2, t3, t4; +set optimizer_switch=@tmp_860535; +# +# BUG#860553: Crash in create_ref_for_key with semijoin + materialization +# +CREATE TABLE t1 (f1 int) ; +CREATE TABLE t2 (f5 varchar(52) NOT NULL) ; +CREATE TABLE t3 (f1 varchar(3), f4 varchar(52) , KEY (f4), PRIMARY KEY (f1)); +CREATE TABLE t4 (f3 int, KEY (f3)); +INSERT INTO t4 VALUES (17),(20); +CREATE TABLE t5 (f2 int); +INSERT INTO t5 VALUES (0),(0); +SELECT * +FROM t1 +JOIN t2 +ON ( t2.f5 ) IN ( +SELECT t3.f4 +FROM t3 +WHERE ( 1 ) IN ( +SELECT t4.f3 +FROM t4 , t5 +) +); +f1 f5 +DROP TABLE t1, t2, t3, t4, t5; +# This must be at the end: set optimizer_switch=@subselect_sj_mat_tmp; set @subselect_mat_test_optimizer_switch_value=null; set @@optimizer_switch='materialization=on,in_to_exists=off,semijoin=off'; @@ -1797,7 +1963,7 @@ id select_type table type possible_keys key key_len ref rows filtered Extra 1 PRIMARY t1 index NULL b 5 NULL 2 100.00 Using index 2 SUBQUERY t2 ALL NULL NULL NULL NULL 2 100.00 Warnings: -Note 1003 select max(`test`.`t1`.`b`) AS `max_res` from `test`.`t1` where <in_optimizer>(9,9 in ( <materialize> (select `test`.`t2`.`a` from `test`.`t2` ), <primary_index_lookup>(9 in <temporary table> on distinct_key where ((9 = `<subquery2>`.`a`))))) +Note 1003 select max(`test`.`t1`.`b`) AS `max_res` from `test`.`t1` where <expr_cache><9>(<in_optimizer>(9,9 in ( <materialize> (select `test`.`t2`.`a` from `test`.`t2` ), <primary_index_lookup>(9 in <temporary table> on distinct_key where ((9 = `<subquery2>`.`a`)))))) set @@optimizer_switch='materialization=off,in_to_exists=on,semijoin=off'; SELECT MAX(t1.b) AS max_res FROM t1 WHERE (9) IN (SELECT a FROM t2); max_res @@ -1808,5 +1974,37 @@ id select_type table type possible_keys key key_len ref rows filtered Extra 1 PRIMARY t1 index NULL b 5 NULL 2 100.00 Using index 2 DEPENDENT SUBQUERY t2 ALL NULL NULL NULL NULL 2 100.00 Using where Warnings: -Note 1003 select max(`test`.`t1`.`b`) AS `max_res` from `test`.`t1` where <in_optimizer>(9,<exists>(select `test`.`t2`.`a` from `test`.`t2` where (9 = `test`.`t2`.`a`))) +Note 1003 select max(`test`.`t1`.`b`) AS `max_res` from `test`.`t1` where <expr_cache><9>(<in_optimizer>(9,<exists>(select `test`.`t2`.`a` from `test`.`t2` where (9 = `test`.`t2`.`a`)))) DROP TABLE t1,t2; +# +# LPBUG#825095: Wrong result with materialization and NOT IN with 2 expressions +# +CREATE TABLE t1 (a int,b int); +INSERT INTO t1 VALUES (4,4),(4,2); +CREATE TABLE t2 (b int, a int); +INSERT INTO t2 VALUES (4,3),(8,4); +set @@optimizer_switch='semijoin=off,in_to_exists=off,materialization=on,partial_match_rowid_merge=on,partial_match_table_scan=off'; +EXPLAIN SELECT * +FROM t1 +WHERE (a, b) NOT IN (SELECT a, b FROM t2); +id select_type table type possible_keys key key_len ref rows Extra +1 PRIMARY t1 ALL NULL NULL NULL NULL 2 Using where +2 SUBQUERY t2 ALL NULL NULL NULL NULL 2 +SELECT * +FROM t1 +WHERE (a, b) NOT IN (SELECT a, b FROM t2); +a b +4 4 +4 2 +EXPLAIN +SELECT a, b, (a, b) NOT IN (SELECT a, b FROM t2) as sq +FROM t1; +id select_type table type possible_keys key key_len ref rows Extra +1 PRIMARY t1 ALL NULL NULL NULL NULL 2 +2 SUBQUERY t2 ALL NULL NULL NULL NULL 2 +SELECT a, b, (a, b) NOT IN (SELECT a, b FROM t2) as sq +FROM t1; +a b sq +4 4 1 +4 2 1 +drop table t1, t2; diff --git a/mysql-test/r/subselect_mat_cost.result b/mysql-test/r/subselect_mat_cost.result index a642c498e53..5531c7e107f 100644 --- a/mysql-test/r/subselect_mat_cost.result +++ b/mysql-test/r/subselect_mat_cost.result @@ -1,5 +1,6 @@ set @subselect_mat_cost=@@optimizer_switch; set optimizer_switch='mrr=on,mrr_sort_keys=on,index_condition_pushdown=on'; +set long_query_time=0.1; TEST GROUP 1: Typical cases of in-to-exists and materialization subquery strategies ===================================================================== @@ -284,7 +285,7 @@ WHERE Code NOT IN (SELECT Country FROM CountryLanguage WHERE Language = 'English AND (CountryLanguage.Language = 'French' OR CountryLanguage.Language = 'Spanish') AND Code = Country; id select_type table type possible_keys key key_len ref rows Extra -1 PRIMARY CountryLanguage range PRIMARY,Language Language 30 NULL 45 Using index condition; Rowid-ordered scan +1 PRIMARY CountryLanguage range PRIMARY,Language Language 30 NULL 45 Using index condition; Using where; Rowid-ordered scan 1 PRIMARY Country eq_ref PRIMARY PRIMARY 3 world.CountryLanguage.Country 1 Using index condition 2 SUBQUERY CountryLanguage ref PRIMARY,Language Language 30 const 47 Using index condition SELECT Country.Name @@ -343,18 +344,20 @@ select count(*) from CountryLanguage where (Language, Country) NOT IN (SELECT City.Name, Country.Code -FROM City LEFT JOIN Country ON (Country = Code and City.Population < 10000)); +FROM City LEFT JOIN Country ON (Country = Code and City.Population < 10000)) +AND Language IN ('English','Spanish'); id select_type table type possible_keys key key_len ref rows Extra -1 PRIMARY CountryLanguage index NULL PRIMARY 33 NULL 984 Using where; Using index -2 DEPENDENT SUBQUERY City ref CityName CityName 35 func 2 Using index condition +1 PRIMARY CountryLanguage range Language Language 30 NULL 72 Using index condition; Using where; Rowid-ordered scan +2 DEPENDENT SUBQUERY City ref CityName CityName 35 func 2 Using index condition; Using where 2 DEPENDENT SUBQUERY Country eq_ref PRIMARY PRIMARY 3 world.City.Country 1 Using where; Using index select count(*) from CountryLanguage where (Language, Country) NOT IN (SELECT City.Name, Country.Code -FROM City LEFT JOIN Country ON (Country = Code and City.Population < 10000)); +FROM City LEFT JOIN Country ON (Country = Code and City.Population < 10000)) +AND Language IN ('English','Spanish'); count(*) -979 +88 Q2.3m: MATERIALIZATION with the PARTIAL_MATCH_MERGE strategy, because the HAVING clause prevents the use of the index on City(Name), and in practice reduces diff --git a/mysql-test/r/subselect_mat_cost_bugs.result b/mysql-test/r/subselect_mat_cost_bugs.result index 7988d93a389..2f5d799a44d 100644 --- a/mysql-test/r/subselect_mat_cost_bugs.result +++ b/mysql-test/r/subselect_mat_cost_bugs.result @@ -64,6 +64,12 @@ KEY c3 (c3,c2)); INSERT INTO t1 VALUES (10,7,8,'v','v'); INSERT INTO t1 VALUES (11,1,9,'r','r'); INSERT INTO t1 VALUES (12,5,9,'a','a'); +INSERT INTO t1 VALUES (13,7,18,'v','v'); +INSERT INTO t1 VALUES (14,1,19,'r','r'); +INSERT INTO t1 VALUES (15,5,29,'a','a'); +INSERT INTO t1 VALUES (17,7,38,'v','v'); +INSERT INTO t1 VALUES (18,1,39,'r','r'); +INSERT INTO t1 VALUES (19,5,49,'a','a'); create table t1a like t1; insert into t1a select * from t1; create table t1b like t1; @@ -88,13 +94,13 @@ FROM (t1b JOIN t2 ON t2.c3 = t1b.c4) LEFT JOIN t1a ON (t1a.c2 = t1b.pk AND 2) WHERE t1.pk) ; id select_type table type possible_keys key key_len ref rows filtered Extra -1 PRIMARY t1 ALL NULL NULL NULL NULL 3 100.00 Using where -2 DEPENDENT SUBQUERY t2 index c3 c3 9 NULL 2 100.00 Using index -2 DEPENDENT SUBQUERY t1b ALL NULL NULL NULL NULL 3 100.00 Using where; Using join buffer (flat, BNL join) -2 DEPENDENT SUBQUERY t1a ref c2 c2 5 test.t1b.pk 2 100.00 Using where +1 PRIMARY t1 ALL NULL NULL NULL NULL 9 100.00 Using where +2 DEPENDENT SUBQUERY t1b ALL NULL NULL NULL NULL 9 100.00 +2 DEPENDENT SUBQUERY t1a ref c2 c2 5 test.t1b.pk 1 100.00 Using where +2 DEPENDENT SUBQUERY t2 index c3 c3 9 NULL 2 100.00 Using where; Using index; Using join buffer (flat, BNL join) Warnings: Note 1276 Field or reference 'test.t1.pk' of SELECT #2 was resolved in SELECT #1 -Note 1003 select `test`.`t1`.`pk` AS `pk` from `test`.`t1` where <in_optimizer>(`test`.`t1`.`c1`,<exists>(select `test`.`t1a`.`c1` from `test`.`t1b` join `test`.`t2` left join `test`.`t1a` on((2 and (`test`.`t1a`.`c2` = `test`.`t1b`.`pk`))) where ((`test`.`t1`.`pk` <> 0) and (<cache>(`test`.`t1`.`c1`) = `test`.`t1a`.`c1`) and (`test`.`t1b`.`c4` = `test`.`t2`.`c3`)))) +Note 1003 select `test`.`t1`.`pk` AS `pk` from `test`.`t1` where <expr_cache><`test`.`t1`.`c1`,`test`.`t1`.`pk`>(<in_optimizer>(`test`.`t1`.`c1`,<exists>(select `test`.`t1a`.`c1` from `test`.`t1b` join `test`.`t2` left join `test`.`t1a` on((2 and (`test`.`t1a`.`c2` = `test`.`t1b`.`pk`))) where ((`test`.`t1`.`pk` <> 0) and (<cache>(`test`.`t1`.`c1`) = `test`.`t1a`.`c1`) and (`test`.`t2`.`c3` = `test`.`t1b`.`c4`))))) SELECT pk FROM t1 WHERE c1 IN @@ -327,4 +333,63 @@ SELECT * FROM t1 WHERE (f1) IN (SELECT f1 FROM t2) LIMIT 0; f1 +set @@optimizer_switch='default'; +drop table t1, t2; +# +# LP BUG#834492: Crash in fix_semijoin_strategies_for_picked_join_order +# with nested subqueries and LooseScan=ON +# +CREATE TABLE t3 (b int) ; +INSERT INTO t3 VALUES (0),(0); +CREATE TABLE t4 (a int, b int, c int, d int, PRIMARY KEY (a)) ; +INSERT INTO t4 VALUES (28,0,0,0),(29,3,0,0); +CREATE TABLE t5 (a int, b int, c int, d int, KEY (c,b)) ; +INSERT INTO t5 VALUES (28,0,0,0),(29,3,0,0); +SET @@optimizer_switch='semijoin=ON,loosescan=ON,firstmatch=OFF,materialization=OFF'; +EXPLAIN SELECT * +FROM t3 +WHERE t3.b > ALL ( +SELECT c +FROM t4 +WHERE t4.a >= t3.b +AND a = SOME (SELECT b FROM t5)); +id select_type table type possible_keys key key_len ref rows Extra +1 PRIMARY t3 ALL NULL NULL NULL NULL 2 Using where +2 DEPENDENT SUBQUERY t5 index c c 10 NULL 2 Using where; Using index; LooseScan +2 DEPENDENT SUBQUERY t4 eq_ref PRIMARY PRIMARY 4 test.t5.b 1 Using where +SELECT * +FROM t3 +WHERE t3.b > ALL ( +SELECT c +FROM t4 +WHERE t4.a >= t3.b +AND a = SOME (SELECT b FROM t5)); +b +0 +0 +set @@optimizer_switch='default'; +drop table t3, t4, t5; +# +# LP BUG#858038 The result of a query with NOT IN subquery depends on the state of the optimizer switch +# +create table t1 (c1 char(2) not null, c2 char(2)); +create table t2 (c3 char(2), c4 char(2)); +insert into t1 values ('a1', 'b1'); +insert into t1 values ('a2', 'b2'); +insert into t2 values ('x1', 'y1'); +insert into t2 values ('a2', null); +set @@optimizer_switch='in_to_exists=off,materialization=on,partial_match_rowid_merge=off,partial_match_table_scan=on'; +explain select * from t1 where c1 = 'a2' and (c1, c2) not in (select * from t2); +id select_type table type possible_keys key key_len ref rows Extra +1 PRIMARY t1 ALL NULL NULL NULL NULL 2 Using where +2 SUBQUERY t2 ALL NULL NULL NULL NULL 2 +select * from t1 where c1 = 'a2' and (c1, c2) not in (select * from t2); +c1 c2 +set @@optimizer_switch='in_to_exists=off,materialization=on,partial_match_rowid_merge=on,partial_match_table_scan=off'; +explain select * from t1 where c1 = 'a2' and (c1, c2) not in (select * from t2); +id select_type table type possible_keys key key_len ref rows Extra +1 PRIMARY t1 ALL NULL NULL NULL NULL 2 Using where +2 SUBQUERY t2 ALL NULL NULL NULL NULL 2 +select * from t1 where c1 = 'a2' and (c1, c2) not in (select * from t2); +c1 c2 drop table t1, t2; diff --git a/mysql-test/r/subselect_no_mat.result b/mysql-test/r/subselect_no_mat.result index cd805fb8e86..0bddfb5f477 100644 --- a/mysql-test/r/subselect_no_mat.result +++ b/mysql-test/r/subselect_no_mat.result @@ -7,7 +7,7 @@ drop table if exists t1,t2,t3,t4,t5,t6,t7,t8,t11,t12; drop view if exists v2; set @subselect_tmp=@@optimizer_switch; set @@optimizer_switch=ifnull(@optimizer_switch_for_subselect_test, -"semijoin=on,firstmatch=on,loosescan=on,partial_match_rowid_merge=off,partial_match_table_scan=off"); +"semijoin=on,firstmatch=on,loosescan=on,semijoin_with_cache=on,partial_match_rowid_merge=off,partial_match_table_scan=off"); set optimizer_switch='mrr=on,mrr_sort_keys=on,index_condition_pushdown=on'; select (select 2); (select 2) @@ -60,7 +60,7 @@ id select_type table type possible_keys key key_len ref rows filtered Extra Warnings: Note 1276 Field or reference 'b.a' of SELECT #3 was resolved in SELECT #1 Note 1276 Field or reference 'b.a' of SELECT #3 was resolved in SELECT #1 -Note 1003 select 1 AS `1` from dual having ((select 1) = 1) +Note 1003 select 1 AS `1` from dual having (<expr_cache><1>((select 1)) = 1) SELECT 1 FROM (SELECT 1 as a) as b HAVING (SELECT a)=1; 1 1 @@ -234,7 +234,7 @@ id select_type table type possible_keys key key_len ref rows filtered Extra 3 DEPENDENT SUBQUERY t3 ALL NULL NULL NULL NULL 3 100.00 Using where Warnings: Note 1276 Field or reference 'test.t4.a' of SELECT #3 was resolved in SELECT #1 -Note 1003 select `test`.`t4`.`b` AS `b`,(select avg((`test`.`t2`.`a` + (select min(`test`.`t3`.`a`) from `test`.`t3` where (`test`.`t3`.`a` >= `test`.`t4`.`a`)))) from `test`.`t2`) AS `(select avg(t2.a+(select min(t3.a) from t3 where t3.a >= t4.a)) from t2)` from `test`.`t4` +Note 1003 select `test`.`t4`.`b` AS `b`,<expr_cache><`test`.`t4`.`a`>((select avg((`test`.`t2`.`a` + (select min(`test`.`t3`.`a`) from `test`.`t3` where (`test`.`t3`.`a` >= `test`.`t4`.`a`)))) from `test`.`t2`)) AS `(select avg(t2.a+(select min(t3.a) from t3 where t3.a >= t4.a)) from t2)` from `test`.`t4` select * from t3 where exists (select * from t2 where t2.b=t3.a); a 7 @@ -280,7 +280,7 @@ id select_type table type possible_keys key key_len ref rows filtered Extra 1 PRIMARY t3 ALL NULL NULL NULL NULL 3 100.00 Using where 2 SUBQUERY t2 ALL NULL NULL NULL NULL 3 100.00 Warnings: -Note 1003 select `test`.`t3`.`a` AS `a` from `test`.`t3` where <nop>(<in_optimizer>(`test`.`t3`.`a`,((select min(`test`.`t2`.`b`) from `test`.`t2`) <= `test`.`t3`.`a`))) +Note 1003 select `test`.`t3`.`a` AS `a` from `test`.`t3` where <nop>(<in_optimizer>(`test`.`t3`.`a`,((select min(`test`.`t2`.`b`) from `test`.`t2`) <= <cache>(`test`.`t3`.`a`)))) select * from t3 where a >= all (select b from t2); a 7 @@ -324,7 +324,7 @@ NULL UNION RESULT <union2,3> ALL NULL NULL NULL NULL NULL NULL Warnings: Note 1276 Field or reference 'test.t2.a' of SELECT #2 was resolved in SELECT #1 Note 1276 Field or reference 'test.t2.a' of SELECT #3 was resolved in SELECT #1 -Note 1003 select (select 2 from dual where (2 = `test`.`t2`.`a`) union select `test`.`t5`.`a` from `test`.`t5` where (`test`.`t5`.`a` = `test`.`t2`.`a`)) AS `(select a from t1 where t1.a=t2.a union select a from t5 where t5.a=t2.a)`,`test`.`t2`.`a` AS `a` from `test`.`t2` +Note 1003 select <expr_cache><`test`.`t2`.`a`>((select 2 from dual where (2 = `test`.`t2`.`a`) union select `test`.`t5`.`a` from `test`.`t5` where (`test`.`t5`.`a` = `test`.`t2`.`a`))) AS `(select a from t1 where t1.a=t2.a union select a from t5 where t5.a=t2.a)`,`test`.`t2`.`a` AS `a` from `test`.`t2` select (select a from t1 where t1.a=t2.a union all select a from t5 where t5.a=t2.a), a from t2; ERROR 21000: Subquery returns more than 1 row create table t6 (patient_uq int, clinic_uq int, index i1 (clinic_uq)); @@ -342,7 +342,7 @@ id select_type table type possible_keys key key_len ref rows filtered Extra 2 DEPENDENT SUBQUERY t7 eq_ref PRIMARY PRIMARY 4 test.t6.clinic_uq 1 100.00 Using index Warnings: Note 1276 Field or reference 'test.t6.clinic_uq' of SELECT #2 was resolved in SELECT #1 -Note 1003 select `test`.`t6`.`patient_uq` AS `patient_uq`,`test`.`t6`.`clinic_uq` AS `clinic_uq` from `test`.`t6` where exists(select 1 from `test`.`t7` where (`test`.`t7`.`uq` = `test`.`t6`.`clinic_uq`)) +Note 1003 select `test`.`t6`.`patient_uq` AS `patient_uq`,`test`.`t6`.`clinic_uq` AS `clinic_uq` from `test`.`t6` where <expr_cache><`test`.`t6`.`clinic_uq`>(exists(select 1 from `test`.`t7` where (`test`.`t7`.`uq` = `test`.`t6`.`clinic_uq`))) select * from t1 where a= (select a from t2,t4 where t2.b=t4.b); ERROR 23000: Column 'a' in field list is ambiguous drop table t1,t2,t3; @@ -372,12 +372,12 @@ INSERT INTO t8 (pseudo,email) VALUES ('joce1','test1'); INSERT INTO t8 (pseudo,email) VALUES ('2joce1','2test1'); EXPLAIN EXTENDED SELECT pseudo,(SELECT email FROM t8 WHERE pseudo=(SELECT pseudo FROM t8 WHERE pseudo='joce')) FROM t8 WHERE pseudo=(SELECT pseudo FROM t8 WHERE pseudo='joce'); id select_type table type possible_keys key key_len ref rows filtered Extra -1 PRIMARY t8 const PRIMARY PRIMARY 37 const 1 100.00 Using index +1 PRIMARY t8 const PRIMARY PRIMARY 37 const 1 100.00 Using where; Using index 4 SUBQUERY t8 const PRIMARY PRIMARY 37 const 1 100.00 Using index -2 SUBQUERY t8 const PRIMARY PRIMARY 37 const 1 100.00 +2 SUBQUERY t8 const PRIMARY PRIMARY 37 const 1 100.00 Using where 3 SUBQUERY t8 const PRIMARY PRIMARY 37 const 1 100.00 Using index Warnings: -Note 1003 select 'joce' AS `pseudo`,(select 'test' from `test`.`t8` where ('joce' = (select 'joce' from `test`.`t8` where 1))) AS `(SELECT email FROM t8 WHERE pseudo=(SELECT pseudo FROM t8 WHERE pseudo='joce'))` from `test`.`t8` where ('joce' = (select 'joce' from `test`.`t8` where 1)) +Note 1003 select `test`.`t8`.`pseudo` AS `pseudo`,(select `test`.`t8`.`email` from `test`.`t8` where (`test`.`t8`.`pseudo` = (select 'joce' from `test`.`t8` where 1))) AS `(SELECT email FROM t8 WHERE pseudo=(SELECT pseudo FROM t8 WHERE pseudo='joce'))` from `test`.`t8` where (`test`.`t8`.`pseudo` = (select 'joce' from `test`.`t8` where 1)) SELECT pseudo FROM t8 WHERE pseudo=(SELECT pseudo,email FROM t8 WHERE pseudo='joce'); ERROR 21000: Operand should contain 1 column(s) @@ -548,18 +548,24 @@ SELECT numreponse, (SELECT numeropost FROM t1 HAVING numreponse=1) FROM (SELECT numreponse (SELECT numeropost FROM t1 HAVING numreponse=1) INSERT INTO t1 (numeropost,numreponse,pseudo) VALUES (1,1,'joce'),(1,2,'joce'),(1,3,'test'); EXPLAIN EXTENDED SELECT numreponse FROM t1 WHERE numeropost='1' AND numreponse=(SELECT 1 FROM t1 WHERE numeropost='1'); +id select_type table type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t1 const PRIMARY,numreponse PRIMARY 7 const,const 1 100.00 Using where; Using index +2 SUBQUERY t1 ref PRIMARY PRIMARY 3 const 2 100.00 Using index +Warnings: +Note 1003 select `test`.`t1`.`numreponse` AS `numreponse` from `test`.`t1` where ((`test`.`t1`.`numeropost` = '1') and (`test`.`t1`.`numreponse` = (select 1 from `test`.`t1` where (`test`.`t1`.`numeropost` = '1')))) +SELECT numreponse FROM t1 WHERE numeropost='1' AND numreponse=(SELECT 1 FROM t1 WHERE numeropost='1'); ERROR 21000: Subquery returns more than 1 row EXPLAIN EXTENDED SELECT MAX(numreponse) FROM t1 WHERE numeropost='1'; id select_type table type possible_keys key key_len ref rows filtered Extra 1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL Select tables optimized away Warnings: -Note 1003 select max(`test`.`t1`.`numreponse`) AS `MAX(numreponse)` from `test`.`t1` where multiple equal(1, `test`.`t1`.`numeropost`) +Note 1003 select max(`test`.`t1`.`numreponse`) AS `MAX(numreponse)` from `test`.`t1` where (`test`.`t1`.`numeropost` = '1') EXPLAIN EXTENDED SELECT numreponse FROM t1 WHERE numeropost='1' AND numreponse=(SELECT MAX(numreponse) FROM t1 WHERE numeropost='1'); id select_type table type possible_keys key key_len ref rows filtered Extra -1 PRIMARY t1 const PRIMARY,numreponse PRIMARY 7 const,const 1 100.00 Using index +1 PRIMARY t1 const PRIMARY,numreponse PRIMARY 7 const,const 1 100.00 Using where; Using index 2 SUBQUERY NULL NULL NULL NULL NULL NULL NULL NULL Select tables optimized away Warnings: -Note 1003 select 3 AS `numreponse` from `test`.`t1` where ((3 = (select max(`test`.`t1`.`numreponse`) from `test`.`t1` where multiple equal(1, `test`.`t1`.`numeropost`)))) +Note 1003 select `test`.`t1`.`numreponse` AS `numreponse` from `test`.`t1` where ((`test`.`t1`.`numeropost` = '1') and (`test`.`t1`.`numreponse` = (select max(`test`.`t1`.`numreponse`) from `test`.`t1` where (`test`.`t1`.`numeropost` = '1')))) drop table t1; CREATE TABLE t1 (a int(1)); INSERT INTO t1 VALUES (1); @@ -756,7 +762,7 @@ id select_type table type possible_keys key key_len ref rows filtered Extra 3 DEPENDENT UNION NULL NULL NULL NULL NULL NULL NULL NULL No tables used NULL UNION RESULT <union2,3> ALL NULL NULL NULL NULL NULL NULL Warnings: -Note 1003 select `test`.`t2`.`id` AS `id` from `test`.`t2` where <in_optimizer>(`test`.`t2`.`id`,<exists>(select 1 having (<cache>(`test`.`t2`.`id`) = <ref_null_helper>(1)) union select 3 having (<cache>(`test`.`t2`.`id`) = <ref_null_helper>(3)))) +Note 1003 select `test`.`t2`.`id` AS `id` from `test`.`t2` where <expr_cache><`test`.`t2`.`id`>(<in_optimizer>(`test`.`t2`.`id`,<exists>(select 1 having (<cache>(`test`.`t2`.`id`) = <ref_null_helper>(1)) union select 3 having (<cache>(`test`.`t2`.`id`) = <ref_null_helper>(3))))) SELECT * FROM t2 WHERE id IN (SELECT 5 UNION SELECT 3); id SELECT * FROM t2 WHERE id IN (SELECT 5 UNION SELECT 2); @@ -904,7 +910,7 @@ id select_type table type possible_keys key key_len ref rows filtered Extra 1 PRIMARY t1 index NULL PRIMARY 4 NULL 4 100.00 Using index 2 DEPENDENT SUBQUERY t2 index_subquery a a 5 func 2 100.00 Using index Warnings: -Note 1003 select `test`.`t1`.`a` AS `a`,<in_optimizer>(`test`.`t1`.`a`,<exists>(<index_lookup>(<cache>(`test`.`t1`.`a`) in t2 on a checking NULL having <is_not_null_test>(`test`.`t2`.`a`)))) AS `t1.a in (select t2.a from t2)` from `test`.`t1` +Note 1003 select `test`.`t1`.`a` AS `a`,<expr_cache><`test`.`t1`.`a`>(<in_optimizer>(`test`.`t1`.`a`,<exists>(<index_lookup>(<cache>(`test`.`t1`.`a`) in t2 on a checking NULL having <is_not_null_test>(`test`.`t2`.`a`))))) AS `t1.a in (select t2.a from t2)` from `test`.`t1` CREATE TABLE t3 (a int(11) default '0'); INSERT INTO t3 VALUES (1),(2),(3); SELECT t1.a, t1.a in (select t2.a from t2,t3 where t3.a=t2.a) FROM t1; @@ -919,8 +925,133 @@ id select_type table type possible_keys key key_len ref rows filtered Extra 2 DEPENDENT SUBQUERY t2 ref_or_null a a 5 func 2 100.00 Using where; Using index 2 DEPENDENT SUBQUERY t3 ALL NULL NULL NULL NULL 3 100.00 Using where; Using join buffer (flat, BNL join) Warnings: -Note 1003 select `test`.`t1`.`a` AS `a`,<in_optimizer>(`test`.`t1`.`a`,<exists>(select `test`.`t2`.`a` from `test`.`t2` join `test`.`t3` where ((`test`.`t3`.`a` = `test`.`t2`.`a`) and ((<cache>(`test`.`t1`.`a`) = `test`.`t2`.`a`) or isnull(`test`.`t2`.`a`))) having <is_not_null_test>(`test`.`t2`.`a`))) AS `t1.a in (select t2.a from t2,t3 where t3.a=t2.a)` from `test`.`t1` +Note 1003 select `test`.`t1`.`a` AS `a`,<expr_cache><`test`.`t1`.`a`>(<in_optimizer>(`test`.`t1`.`a`,<exists>(select `test`.`t2`.`a` from `test`.`t2` join `test`.`t3` where ((`test`.`t3`.`a` = `test`.`t2`.`a`) and ((<cache>(`test`.`t1`.`a`) = `test`.`t2`.`a`) or isnull(`test`.`t2`.`a`))) having <is_not_null_test>(`test`.`t2`.`a`)))) AS `t1.a in (select t2.a from t2,t3 where t3.a=t2.a)` from `test`.`t1` drop table t1,t2,t3; +# check correct NULL Processing for normal IN/ALL/ANY +# and 2 ways of max/min optimization +create table t1 (a int); +insert into t1 values (1), (100), (NULL), (1000); +create table t2 (a int not null); +# subselect returns empty set (for NULL and non-NULL left part) +select a, a in (select * from t2) from t1; +a a in (select * from t2) +1 0 +100 0 +NULL 0 +1000 0 +select a, a > any (select * from t2) from t1; +a a > any (select * from t2) +1 0 +100 0 +NULL 0 +1000 0 +select a, a > all (select * from t2) from t1; +a a > all (select * from t2) +1 1 +100 1 +NULL 1 +1000 1 +select a from t1 where a in (select * from t2); +a +select a from t1 where a > any (select * from t2); +a +select a from t1 where a > all (select * from t2); +a +1 +100 +NULL +1000 +select a from t1 where a in (select * from t2 group by a); +a +select a from t1 where a > any (select * from t2 group by a); +a +select a from t1 where a > all (select * from t2 group by a); +a +1 +100 +NULL +1000 +insert into t2 values (1),(200); +# sebselect returns non-empty set without NULLs +select a, a in (select * from t2) from t1; +a a in (select * from t2) +1 1 +100 0 +NULL NULL +1000 0 +select a, a > any (select * from t2) from t1; +a a > any (select * from t2) +1 0 +100 1 +NULL NULL +1000 1 +select a, a > all (select * from t2) from t1; +a a > all (select * from t2) +1 0 +100 0 +NULL NULL +1000 1 +select a from t1 where a in (select * from t2); +a +1 +select a from t1 where a > any (select * from t2); +a +100 +1000 +select a from t1 where a > all (select * from t2); +a +1000 +select a from t1 where a in (select * from t2 group by a); +a +1 +select a from t1 where a > any (select * from t2 group by a); +a +100 +1000 +select a from t1 where a > all (select * from t2 group by a); +a +1000 +drop table t2; +create table t2 (a int); +insert into t2 values (1),(NULL),(200); +# sebselect returns non-empty set with NULLs +select a, a in (select * from t2) from t1; +a a in (select * from t2) +1 1 +100 NULL +NULL NULL +1000 NULL +select a, a > any (select * from t2) from t1; +a a > any (select * from t2) +1 NULL +100 1 +NULL NULL +1000 1 +select a, a > all (select * from t2) from t1; +a a > all (select * from t2) +1 0 +100 0 +NULL NULL +1000 NULL +select a from t1 where a in (select * from t2); +a +1 +select a from t1 where a > any (select * from t2); +a +100 +1000 +select a from t1 where a > all (select * from t2); +a +select a from t1 where a in (select * from t2 group by a); +a +1 +select a from t1 where a > any (select * from t2 group by a); +a +100 +1000 +select a from t1 where a > all (select * from t2 group by a); +a +drop table t1, t2; create table t1 (a float); select 10.5 IN (SELECT * from t1 LIMIT 1); ERROR 42000: This version of MySQL doesn't yet support 'LIMIT & IN/ALL/ANY/SOME subquery' @@ -1480,27 +1611,27 @@ id select_type table type possible_keys key key_len ref rows filtered Extra 1 PRIMARY t1 index NULL s1 6 NULL 3 100.00 Using index 2 DEPENDENT SUBQUERY t2 index_subquery s1 s1 6 func 2 100.00 Using index; Full scan on NULL key Warnings: -Note 1003 select `test`.`t1`.`s1` AS `s1`,(not(<in_optimizer>(`test`.`t1`.`s1`,<exists>(<index_lookup>(<cache>(`test`.`t1`.`s1`) in t2 on s1 checking NULL having trigcond(<is_not_null_test>(`test`.`t2`.`s1`))))))) AS `s1 NOT IN (SELECT s1 FROM t2)` from `test`.`t1` +Note 1003 select `test`.`t1`.`s1` AS `s1`,(not(<expr_cache><`test`.`t1`.`s1`>(<in_optimizer>(`test`.`t1`.`s1`,<exists>(<index_lookup>(<cache>(`test`.`t1`.`s1`) in t2 on s1 checking NULL having trigcond(<is_not_null_test>(`test`.`t2`.`s1`)))))))) AS `s1 NOT IN (SELECT s1 FROM t2)` from `test`.`t1` explain extended select s1, s1 = ANY (SELECT s1 FROM t2) from t1; id select_type table type possible_keys key key_len ref rows filtered Extra 1 PRIMARY t1 index NULL s1 6 NULL 3 100.00 Using index 2 DEPENDENT SUBQUERY t2 index_subquery s1 s1 6 func 2 100.00 Using index; Full scan on NULL key Warnings: -Note 1003 select `test`.`t1`.`s1` AS `s1`,<in_optimizer>(`test`.`t1`.`s1`,<exists>(<index_lookup>(<cache>(`test`.`t1`.`s1`) in t2 on s1 checking NULL having trigcond(<is_not_null_test>(`test`.`t2`.`s1`))))) AS `s1 = ANY (SELECT s1 FROM t2)` from `test`.`t1` +Note 1003 select `test`.`t1`.`s1` AS `s1`,<expr_cache><`test`.`t1`.`s1`>(<in_optimizer>(`test`.`t1`.`s1`,<exists>(<index_lookup>(<cache>(`test`.`t1`.`s1`) in t2 on s1 checking NULL having trigcond(<is_not_null_test>(`test`.`t2`.`s1`)))))) AS `s1 = ANY (SELECT s1 FROM t2)` from `test`.`t1` explain extended select s1, s1 <> ALL (SELECT s1 FROM t2) from t1; id select_type table type possible_keys key key_len ref rows filtered Extra 1 PRIMARY t1 index NULL s1 6 NULL 3 100.00 Using index 2 DEPENDENT SUBQUERY t2 index_subquery s1 s1 6 func 2 100.00 Using index; Full scan on NULL key Warnings: -Note 1003 select `test`.`t1`.`s1` AS `s1`,(not(<in_optimizer>(`test`.`t1`.`s1`,<exists>(<index_lookup>(<cache>(`test`.`t1`.`s1`) in t2 on s1 checking NULL having trigcond(<is_not_null_test>(`test`.`t2`.`s1`))))))) AS `s1 <> ALL (SELECT s1 FROM t2)` from `test`.`t1` +Note 1003 select `test`.`t1`.`s1` AS `s1`,(not(<expr_cache><`test`.`t1`.`s1`>(<in_optimizer>(`test`.`t1`.`s1`,<exists>(<index_lookup>(<cache>(`test`.`t1`.`s1`) in t2 on s1 checking NULL having trigcond(<is_not_null_test>(`test`.`t2`.`s1`)))))))) AS `s1 <> ALL (SELECT s1 FROM t2)` from `test`.`t1` explain extended select s1, s1 NOT IN (SELECT s1 FROM t2 WHERE s1 < 'a2') from t1; id select_type table type possible_keys key key_len ref rows filtered Extra 1 PRIMARY t1 index NULL s1 6 NULL 3 100.00 Using index 2 DEPENDENT SUBQUERY t2 index_subquery s1 s1 6 func 2 100.00 Using index; Using where; Full scan on NULL key Warnings: -Note 1003 select `test`.`t1`.`s1` AS `s1`,(not(<in_optimizer>(`test`.`t1`.`s1`,<exists>(<index_lookup>(<cache>(`test`.`t1`.`s1`) in t2 on s1 checking NULL where (`test`.`t2`.`s1` < 'a2') having trigcond(<is_not_null_test>(`test`.`t2`.`s1`))))))) AS `s1 NOT IN (SELECT s1 FROM t2 WHERE s1 < 'a2')` from `test`.`t1` +Note 1003 select `test`.`t1`.`s1` AS `s1`,(not(<expr_cache><`test`.`t1`.`s1`>(<in_optimizer>(`test`.`t1`.`s1`,<exists>(<index_lookup>(<cache>(`test`.`t1`.`s1`) in t2 on s1 checking NULL where (`test`.`t2`.`s1` < 'a2') having trigcond(<is_not_null_test>(`test`.`t2`.`s1`)))))))) AS `s1 NOT IN (SELECT s1 FROM t2 WHERE s1 < 'a2')` from `test`.`t1` drop table t1,t2; -create table t2 (a int, b int); +create table t2 (a int, b int not null); create table t3 (a int); insert into t3 values (6),(7),(3); select * from t3 where a >= all (select b from t2); @@ -1513,7 +1644,7 @@ id select_type table type possible_keys key key_len ref rows filtered Extra 1 PRIMARY t3 ALL NULL NULL NULL NULL 3 100.00 Using where 2 SUBQUERY t2 system NULL NULL NULL NULL 0 0.00 const row not found Warnings: -Note 1003 select `test`.`t3`.`a` AS `a` from `test`.`t3` where <not>(<in_optimizer>(`test`.`t3`.`a`,((select max(NULL) from `test`.`t2`) > `test`.`t3`.`a`))) +Note 1003 select `test`.`t3`.`a` AS `a` from `test`.`t3` where <not>(<in_optimizer>(`test`.`t3`.`a`,((select max(NULL) from `test`.`t2`) > <cache>(`test`.`t3`.`a`)))) select * from t3 where a >= some (select b from t2); a explain extended select * from t3 where a >= some (select b from t2); @@ -1521,7 +1652,7 @@ id select_type table type possible_keys key key_len ref rows filtered Extra 1 PRIMARY t3 ALL NULL NULL NULL NULL 3 100.00 Using where 2 SUBQUERY t2 system NULL NULL NULL NULL 0 0.00 const row not found Warnings: -Note 1003 select `test`.`t3`.`a` AS `a` from `test`.`t3` where <nop>(<in_optimizer>(`test`.`t3`.`a`,((select min(NULL) from `test`.`t2`) <= `test`.`t3`.`a`))) +Note 1003 select `test`.`t3`.`a` AS `a` from `test`.`t3` where <nop>(<in_optimizer>(`test`.`t3`.`a`,((select min(NULL) from `test`.`t2`) <= <cache>(`test`.`t3`.`a`)))) select * from t3 where a >= all (select b from t2 group by 1); a 6 @@ -1532,7 +1663,7 @@ id select_type table type possible_keys key key_len ref rows filtered Extra 1 PRIMARY t3 ALL NULL NULL NULL NULL 3 100.00 Using where 2 SUBQUERY t2 system NULL NULL NULL NULL 0 0.00 const row not found Warnings: -Note 1003 select `test`.`t3`.`a` AS `a` from `test`.`t3` where <not>(<in_optimizer>(`test`.`t3`.`a`,(<max>(select NULL from `test`.`t2` group by 1) > `test`.`t3`.`a`))) +Note 1003 select `test`.`t3`.`a` AS `a` from `test`.`t3` where <not>(<in_optimizer>(`test`.`t3`.`a`,(<max>(select NULL from `test`.`t2` group by 1) > <cache>(`test`.`t3`.`a`)))) select * from t3 where a >= some (select b from t2 group by 1); a explain extended select * from t3 where a >= some (select b from t2 group by 1); @@ -1540,7 +1671,7 @@ id select_type table type possible_keys key key_len ref rows filtered Extra 1 PRIMARY t3 ALL NULL NULL NULL NULL 3 100.00 Using where 2 SUBQUERY t2 system NULL NULL NULL NULL 0 0.00 const row not found Warnings: -Note 1003 select `test`.`t3`.`a` AS `a` from `test`.`t3` where <nop>(<in_optimizer>(`test`.`t3`.`a`,(<min>(select NULL from `test`.`t2` group by 1) <= `test`.`t3`.`a`))) +Note 1003 select `test`.`t3`.`a` AS `a` from `test`.`t3` where <nop>(<in_optimizer>(`test`.`t3`.`a`,(<min>(select NULL from `test`.`t2` group by 1) <= <cache>(`test`.`t3`.`a`)))) select * from t3 where NULL >= any (select b from t2); a explain extended select * from t3 where NULL >= any (select b from t2); @@ -1583,7 +1714,7 @@ id select_type table type possible_keys key key_len ref rows filtered Extra 1 PRIMARY t3 ALL NULL NULL NULL NULL 3 100.00 Using where 2 SUBQUERY t2 ALL NULL NULL NULL NULL 4 100.00 Using temporary Warnings: -Note 1003 select `test`.`t3`.`a` AS `a` from `test`.`t3` where <not>(<in_optimizer>(`test`.`t3`.`a`,(<max>(select max(`test`.`t2`.`b`) from `test`.`t2` group by `test`.`t2`.`a`) >= `test`.`t3`.`a`))) +Note 1003 select `test`.`t3`.`a` AS `a` from `test`.`t3` where <not>(<in_optimizer>(`test`.`t3`.`a`,(<max>(select max(`test`.`t2`.`b`) from `test`.`t2` group by `test`.`t2`.`a`) >= <cache>(`test`.`t3`.`a`)))) drop table t2, t3; CREATE TABLE `t1` ( `id` mediumint(9) NOT NULL auto_increment, `taskid` bigint(20) NOT NULL default '0', `dbid` int(11) NOT NULL default '0', `create_date` datetime NOT NULL default '0000-00-00 00:00:00', `last_update` datetime NOT NULL default '0000-00-00 00:00:00', PRIMARY KEY (`id`)) ENGINE=MyISAM CHARSET=latin1 AUTO_INCREMENT=3 ; INSERT INTO `t1` (`id`, `taskid`, `dbid`, `create_date`,`last_update`) VALUES (1, 1, 15, '2003-09-29 10:31:36', '2003-09-29 10:31:36'), (2, 1, 21, now(), now()); @@ -1753,14 +1884,14 @@ id select_type table type possible_keys key key_len ref rows filtered Extra 1 PRIMARY t1 ALL NULL NULL NULL NULL 12 100.00 Using where 2 DEPENDENT SUBQUERY t1 unique_subquery PRIMARY PRIMARY 4 func 1 100.00 Using index; Using where Warnings: -Note 1003 select `test`.`t1`.`id` AS `id`,`test`.`t1`.`text` AS `text` from `test`.`t1` where (not(<in_optimizer>(`test`.`t1`.`id`,<exists>(<primary_index_lookup>(<cache>(`test`.`t1`.`id`) in t1 on PRIMARY where ((`test`.`t1`.`id` < 8) and (<cache>(`test`.`t1`.`id`) = `test`.`t1`.`id`))))))) +Note 1003 select `test`.`t1`.`id` AS `id`,`test`.`t1`.`text` AS `text` from `test`.`t1` where (not(<expr_cache><`test`.`t1`.`id`>(<in_optimizer>(`test`.`t1`.`id`,<exists>(<primary_index_lookup>(<cache>(`test`.`t1`.`id`) in t1 on PRIMARY where ((`test`.`t1`.`id` < 8) and (<cache>(`test`.`t1`.`id`) = `test`.`t1`.`id`)))))))) explain extended select * from t1 as tt where not exists (select id from t1 where id < 8 and (id = tt.id or id is null) having id is not null); id select_type table type possible_keys key key_len ref rows filtered Extra 1 PRIMARY tt ALL NULL NULL NULL NULL 12 100.00 Using where 2 DEPENDENT SUBQUERY t1 eq_ref PRIMARY PRIMARY 4 test.tt.id 1 100.00 Using where; Using index Warnings: Note 1276 Field or reference 'test.tt.id' of SELECT #2 was resolved in SELECT #1 -Note 1003 select `test`.`tt`.`id` AS `id`,`test`.`tt`.`text` AS `text` from `test`.`t1` `tt` where (not(exists(select `test`.`t1`.`id` from `test`.`t1` where ((`test`.`t1`.`id` < 8) and (`test`.`t1`.`id` = `test`.`tt`.`id`)) having (`test`.`t1`.`id` is not null)))) +Note 1003 select `test`.`tt`.`id` AS `id`,`test`.`tt`.`text` AS `text` from `test`.`t1` `tt` where (not(<expr_cache><`test`.`tt`.`id`>(exists(select `test`.`t1`.`id` from `test`.`t1` where ((`test`.`t1`.`id` < 8) and (`test`.`t1`.`id` = `test`.`tt`.`id`)) having (`test`.`t1`.`id` is not null))))) insert into t1 (id, text) values (1000, 'text1000'), (1001, 'text1001'); create table t2 (id int not null, text varchar(20) not null default '', primary key (id)); insert into t2 (id, text) values (1, 'text1'), (2, 'text2'), (3, 'text3'), (4, 'text4'), (5, 'text5'), (6, 'text6'), (7, 'text7'), (8, 'text8'), (9, 'text9'), (10, 'text10'), (11, 'text1'), (12, 'text2'), (13, 'text3'), (14, 'text4'), (15, 'text5'), (16, 'text6'), (17, 'text7'), (18, 'text8'), (19, 'text9'), (20, 'text10'),(21, 'text1'), (22, 'text2'), (23, 'text3'), (24, 'text4'), (25, 'text5'), (26, 'text6'), (27, 'text7'), (28, 'text8'), (29, 'text9'), (30, 'text10'), (31, 'text1'), (32, 'text2'), (33, 'text3'), (34, 'text4'), (35, 'text5'), (36, 'text6'), (37, 'text7'), (38, 'text8'), (39, 'text9'), (40, 'text10'), (41, 'text1'), (42, 'text2'), (43, 'text3'), (44, 'text4'), (45, 'text5'), (46, 'text6'), (47, 'text7'), (48, 'text8'), (49, 'text9'), (50, 'text10'); @@ -2296,7 +2427,7 @@ id select_type table type possible_keys key key_len ref rows filtered Extra 2 DEPENDENT SUBQUERY t1 ALL NULL NULL NULL NULL 2 100.00 Using where Warnings: Note 1276 Field or reference 'test.up.a' of SELECT #2 was resolved in SELECT #1 -Note 1003 select `test`.`up`.`a` AS `a`,`test`.`up`.`b` AS `b` from `test`.`t1` `up` where exists(select 1 from `test`.`t1` where (`test`.`t1`.`a` = `test`.`up`.`a`)) +Note 1003 select `test`.`up`.`a` AS `a`,`test`.`up`.`b` AS `b` from `test`.`t1` `up` where <expr_cache><`test`.`up`.`a`>(exists(select 1 from `test`.`t1` where (`test`.`t1`.`a` = `test`.`up`.`a`))) drop table t1; CREATE TABLE t1 (t1_a int); INSERT INTO t1 VALUES (1); @@ -2767,6 +2898,8 @@ select * from (select max(fld) from t1) as foo; max(fld) 1 drop table t1; +set @tmp11867_optimizer_switch=@@optimizer_switch; +set optimizer_switch='semijoin_with_cache=off'; CREATE TABLE t1 (one int, two int, flag char(1)); CREATE TABLE t2 (one int, two int, flag char(1)); INSERT INTO t1 VALUES(1,2,'Y'),(2,3,'Y'),(3,4,'Y'),(5,6,'N'),(7,8,'N'); @@ -2837,7 +2970,7 @@ id select_type table type possible_keys key key_len ref rows filtered Extra 1 PRIMARY t1 ALL NULL NULL NULL NULL 8 100.00 2 DEPENDENT SUBQUERY t2 ALL NULL NULL NULL NULL 9 100.00 Using where Warnings: -Note 1003 select `test`.`t1`.`one` AS `one`,`test`.`t1`.`two` AS `two`,<in_optimizer>((`test`.`t1`.`one`,`test`.`t1`.`two`),<exists>(select `test`.`t2`.`one`,`test`.`t2`.`two` from `test`.`t2` where ((`test`.`t2`.`flag` = '0') and trigcond(((<cache>(`test`.`t1`.`one`) = `test`.`t2`.`one`) or isnull(`test`.`t2`.`one`))) and trigcond(((<cache>(`test`.`t1`.`two`) = `test`.`t2`.`two`) or isnull(`test`.`t2`.`two`)))) having (trigcond(<is_not_null_test>(`test`.`t2`.`one`)) and trigcond(<is_not_null_test>(`test`.`t2`.`two`))))) AS `test` from `test`.`t1` +Note 1003 select `test`.`t1`.`one` AS `one`,`test`.`t1`.`two` AS `two`,<expr_cache><`test`.`t1`.`one`,`test`.`t1`.`two`>(<in_optimizer>((`test`.`t1`.`one`,`test`.`t1`.`two`),<exists>(select `test`.`t2`.`one`,`test`.`t2`.`two` from `test`.`t2` where ((`test`.`t2`.`flag` = '0') and trigcond(((<cache>(`test`.`t1`.`one`) = `test`.`t2`.`one`) or isnull(`test`.`t2`.`one`))) and trigcond(((<cache>(`test`.`t1`.`two`) = `test`.`t2`.`two`) or isnull(`test`.`t2`.`two`)))) having (trigcond(<is_not_null_test>(`test`.`t2`.`one`)) and trigcond(<is_not_null_test>(`test`.`t2`.`two`)))))) AS `test` from `test`.`t1` explain extended SELECT one,two from t1 where ROW(one,two) IN (SELECT one,two FROM t2 WHERE flag = 'N'); id select_type table type possible_keys key key_len ref rows filtered Extra 1 PRIMARY t1 ALL NULL NULL NULL NULL 8 100.00 @@ -2849,8 +2982,9 @@ id select_type table type possible_keys key key_len ref rows filtered Extra 1 PRIMARY t1 ALL NULL NULL NULL NULL 8 100.00 2 DEPENDENT SUBQUERY t2 ALL NULL NULL NULL NULL 9 100.00 Using where; Using temporary Warnings: -Note 1003 select `test`.`t1`.`one` AS `one`,`test`.`t1`.`two` AS `two`,<in_optimizer>((`test`.`t1`.`one`,`test`.`t1`.`two`),<exists>(select `test`.`t2`.`one`,`test`.`t2`.`two` from `test`.`t2` where (`test`.`t2`.`flag` = '0') group by `test`.`t2`.`one`,`test`.`t2`.`two` having (trigcond(((<cache>(`test`.`t1`.`one`) = `test`.`t2`.`one`) or isnull(`test`.`t2`.`one`))) and trigcond(((<cache>(`test`.`t1`.`two`) = `test`.`t2`.`two`) or isnull(`test`.`t2`.`two`))) and trigcond(<is_not_null_test>(`test`.`t2`.`one`)) and trigcond(<is_not_null_test>(`test`.`t2`.`two`))))) AS `test` from `test`.`t1` +Note 1003 select `test`.`t1`.`one` AS `one`,`test`.`t1`.`two` AS `two`,<expr_cache><`test`.`t1`.`one`,`test`.`t1`.`two`>(<in_optimizer>((`test`.`t1`.`one`,`test`.`t1`.`two`),<exists>(select `test`.`t2`.`one`,`test`.`t2`.`two` from `test`.`t2` where (`test`.`t2`.`flag` = '0') group by `test`.`t2`.`one`,`test`.`t2`.`two` having (trigcond(((<cache>(`test`.`t1`.`one`) = `test`.`t2`.`one`) or isnull(`test`.`t2`.`one`))) and trigcond(((<cache>(`test`.`t1`.`two`) = `test`.`t2`.`two`) or isnull(`test`.`t2`.`two`))) and trigcond(<is_not_null_test>(`test`.`t2`.`one`)) and trigcond(<is_not_null_test>(`test`.`t2`.`two`)))))) AS `test` from `test`.`t1` DROP TABLE t1,t2; +set optimizer_switch=@tmp11867_optimizer_switch; CREATE TABLE t1 (a char(5), b char(5)); INSERT INTO t1 VALUES (NULL,'aaa'), ('aaa','aaa'); SELECT * FROM t1 WHERE (a,b) IN (('aaa','aaa'), ('aaa','bbb')); @@ -4295,7 +4429,7 @@ id select_type table type possible_keys key key_len ref rows filtered Extra 2 DEPENDENT SUBQUERY t2 ALL NULL NULL NULL NULL 2 100.00 Using where Warnings: Note 1276 Field or reference 'test.t1.a' of SELECT #2 was resolved in SELECT #1 -Note 1003 select 2 AS `2` from `test`.`t1` where exists(select 1 from `test`.`t2` where (`test`.`t1`.`a` = `test`.`t2`.`a`)) +Note 1003 select 2 AS `2` from `test`.`t1` where <expr_cache><`test`.`t1`.`a`>(exists(select 1 from `test`.`t2` where (`test`.`t1`.`a` = `test`.`t2`.`a`))) EXPLAIN EXTENDED SELECT 2 FROM t1 WHERE EXISTS ((SELECT 1 FROM t2 WHERE t1.a=t2.a) UNION (SELECT 1 FROM t2 WHERE t1.a = t2.a)); @@ -4307,7 +4441,7 @@ NULL UNION RESULT <union2,3> ALL NULL NULL NULL NULL NULL NULL Warnings: Note 1276 Field or reference 'test.t1.a' of SELECT #2 was resolved in SELECT #1 Note 1276 Field or reference 'test.t1.a' of SELECT #3 was resolved in SELECT #1 -Note 1003 select 2 AS `2` from `test`.`t1` where exists((select 1 from `test`.`t2` where (`test`.`t1`.`a` = `test`.`t2`.`a`)) union (select 1 from `test`.`t2` where (`test`.`t1`.`a` = `test`.`t2`.`a`))) +Note 1003 select 2 AS `2` from `test`.`t1` where <expr_cache><`test`.`t1`.`a`>(exists((select 1 from `test`.`t2` where (`test`.`t1`.`a` = `test`.`t2`.`a`)) union (select 1 from `test`.`t2` where (`test`.`t1`.`a` = `test`.`t2`.`a`)))) DROP TABLE t1,t2; create table t0(a int); insert into t0 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9); @@ -4385,13 +4519,13 @@ id select_type table type possible_keys key key_len ref rows filtered Extra 1 PRIMARY t1 ALL NULL NULL NULL NULL 2 100.00 2 DEPENDENT SUBQUERY t1 ALL NULL NULL NULL NULL 2 100.00 Using temporary Warnings: -Note 1003 select 1 AS `1` from `test`.`t1` where <in_optimizer>(1,<exists>(select 1 from `test`.`t1` group by `test`.`t1`.`a` having (1 = <ref_null_helper>(1)))) +Note 1003 select 1 AS `1` from `test`.`t1` where <expr_cache><1>(<in_optimizer>(1,<exists>(select 1 from `test`.`t1` group by `test`.`t1`.`a` having (1 = <ref_null_helper>(1))))) EXPLAIN EXTENDED SELECT 1 FROM t1 WHERE 1 IN (SELECT 1 FROM t1 WHERE a > 3 GROUP BY a); id select_type table type possible_keys key key_len ref rows filtered Extra 1 PRIMARY t1 ALL NULL NULL NULL NULL 2 100.00 2 DEPENDENT SUBQUERY t1 ALL NULL NULL NULL NULL 2 100.00 Using where; Using temporary Warnings: -Note 1003 select 1 AS `1` from `test`.`t1` where <in_optimizer>(1,<exists>(select 1 from `test`.`t1` where (`test`.`t1`.`a` > 3) group by `test`.`t1`.`a` having (1 = <ref_null_helper>(1)))) +Note 1003 select 1 AS `1` from `test`.`t1` where <expr_cache><1>(<in_optimizer>(1,<exists>(select 1 from `test`.`t1` where (`test`.`t1`.`a` > 3) group by `test`.`t1`.`a` having (1 = <ref_null_helper>(1))))) DROP TABLE t1; # # Bug#45061: Incorrectly market field caused wrong result. @@ -5511,6 +5645,167 @@ SELECT 1 as foo FROM t1 WHERE a < SOME ); foo DROP TABLE t1; +CREATE TABLE t1 (a int(11), b varchar(1)); +INSERT INTO t1 VALUES (2,NULL),(5,'d'),(7,'g'); +SELECT a FROM t1 WHERE b < ANY ( SELECT b FROM t1 GROUP BY b ); +a +5 +SELECT a FROM t1 WHERE b < ANY ( SELECT b FROM t1 ); +a +5 +SELECT a FROM t1 WHERE b > ANY ( SELECT b FROM t1 GROUP BY b ); +a +7 +SELECT a FROM t1 WHERE b > ANY ( SELECT b FROM t1 ); +a +7 +SELECT a FROM t1 WHERE b <= ANY ( SELECT b FROM t1 GROUP BY b ); +a +5 +7 +SELECT a FROM t1 WHERE b <= ANY ( SELECT b FROM t1 ); +a +5 +7 +SELECT a FROM t1 WHERE b >= ANY ( SELECT b FROM t1 GROUP BY b ); +a +5 +7 +SELECT a FROM t1 WHERE b >= ANY ( SELECT b FROM t1 ); +a +5 +7 +SELECT a FROM t1 WHERE b = ANY ( SELECT b FROM t1 ); +a +5 +7 +SELECT a FROM t1 WHERE b = ANY ( SELECT b FROM t1 GROUP BY b ); +a +5 +7 +SELECT a FROM t1 WHERE b <> ANY ( SELECT b FROM t1 ); +a +5 +7 +SELECT a FROM t1 WHERE b <> ANY ( SELECT b FROM t1 GROUP BY b ); +a +5 +7 +SELECT a FROM t1 WHERE b < ALL ( SELECT b FROM t1 GROUP BY b ); +a +SELECT a FROM t1 WHERE b < ALL ( SELECT b FROM t1 ); +a +SELECT a FROM t1 WHERE b > ALL ( SELECT b FROM t1 GROUP BY b ); +a +SELECT a FROM t1 WHERE b > ALL ( SELECT b FROM t1 ); +a +SELECT a FROM t1 WHERE b <= ALL ( SELECT b FROM t1 GROUP BY b ); +a +SELECT a FROM t1 WHERE b <= ALL ( SELECT b FROM t1 ); +a +SELECT a FROM t1 WHERE b >= ALL ( SELECT b FROM t1 GROUP BY b ); +a +SELECT a FROM t1 WHERE b >= ALL ( SELECT b FROM t1 ); +a +SELECT a FROM t1 WHERE b = ALL ( SELECT b FROM t1 ); +a +SELECT a FROM t1 WHERE b = ALL ( SELECT b FROM t1 GROUP BY b ); +a +SELECT a FROM t1 WHERE b <> ALL ( SELECT b FROM t1 ); +a +SELECT a FROM t1 WHERE b <> ALL ( SELECT b FROM t1 GROUP BY b ); +a +delete from t1; +INSERT INTO t1 VALUES (2,NULL),(5,'d'),(7,'g'); +SELECT a FROM t1 WHERE b < ANY ( SELECT b FROM t1 GROUP BY b ); +a +5 +SELECT a FROM t1 WHERE b < ANY ( SELECT b FROM t1 ); +a +5 +SELECT a FROM t1 WHERE b > ANY ( SELECT b FROM t1 GROUP BY b ); +a +7 +SELECT a FROM t1 WHERE b > ANY ( SELECT b FROM t1 ); +a +7 +SELECT a FROM t1 WHERE b <= ANY ( SELECT b FROM t1 GROUP BY b ); +a +5 +7 +SELECT a FROM t1 WHERE b <= ANY ( SELECT b FROM t1 ); +a +5 +7 +SELECT a FROM t1 WHERE b >= ANY ( SELECT b FROM t1 GROUP BY b ); +a +5 +7 +SELECT a FROM t1 WHERE b >= ANY ( SELECT b FROM t1 ); +a +5 +7 +SELECT a FROM t1 WHERE b = ANY ( SELECT b FROM t1 ); +a +5 +7 +SELECT a FROM t1 WHERE b = ANY ( SELECT b FROM t1 GROUP BY b ); +a +5 +7 +SELECT a FROM t1 WHERE b <> ANY ( SELECT b FROM t1 ); +a +5 +7 +SELECT a FROM t1 WHERE b <> ANY ( SELECT b FROM t1 GROUP BY b ); +a +5 +7 +SELECT a FROM t1 WHERE b < ALL ( SELECT b FROM t1 GROUP BY b ); +a +SELECT a FROM t1 WHERE b < ALL ( SELECT b FROM t1 ); +a +SELECT a FROM t1 WHERE b > ALL ( SELECT b FROM t1 GROUP BY b ); +a +SELECT a FROM t1 WHERE b > ALL ( SELECT b FROM t1 ); +a +SELECT a FROM t1 WHERE b <= ALL ( SELECT b FROM t1 GROUP BY b ); +a +SELECT a FROM t1 WHERE b <= ALL ( SELECT b FROM t1 ); +a +SELECT a FROM t1 WHERE b >= ALL ( SELECT b FROM t1 GROUP BY b ); +a +SELECT a FROM t1 WHERE b >= ALL ( SELECT b FROM t1 ); +a +SELECT a FROM t1 WHERE b = ALL ( SELECT b FROM t1 ); +a +SELECT a FROM t1 WHERE b = ALL ( SELECT b FROM t1 GROUP BY b ); +a +SELECT a FROM t1 WHERE b <> ALL ( SELECT b FROM t1 ); +a +SELECT a FROM t1 WHERE b <> ALL ( SELECT b FROM t1 GROUP BY b ); +a +drop table t1; +# +# Fix of lp:780386 (NULL left part with empty ALL subquery). +# +CREATE TABLE t1 ( f11 int) ; +INSERT IGNORE INTO t1 VALUES (0),(0); +CREATE TABLE t2 ( f3 int, f10 int, KEY (f10,f3)) ; +INSERT IGNORE INTO t2 VALUES (NULL,NULL),(5,0); +DROP TABLE IF EXISTS t3; +Warnings: +Note 1051 Unknown table 't3' +CREATE TABLE t3 ( f3 int) ; +INSERT INTO t3 VALUES (0),(0); +SELECT a1.f3 AS r FROM t2 AS a1 , t1 WHERE a1.f3 < ALL ( SELECT f3 FROM t3 WHERE f3 = 1 ) ; +r +NULL +5 +NULL +5 +DROP TABLE t1, t2, t3; +End of 5.2 tests # # BUG#779885: Crash in eliminate_item_equal with materialization=on in # maria-5.3 @@ -5533,24 +5828,30 @@ ON t2.f10 = t3.f10 f1 DROP TABLE t1,t2,t3; # -# Fix of LP BUG#780386 (NULL left part with empty ALL subquery). +# BUG lp:813473: Wrong result with outer join + NOT IN subquery +# This bug is a duplicate of Bug#11764086 whose test case is added below # -CREATE TABLE t1 ( f11 int) ; -INSERT IGNORE INTO t1 VALUES (0),(0); -CREATE TABLE t2 ( f3 int, f10 int, KEY (f10,f3)) ; -INSERT IGNORE INTO t2 VALUES (NULL,NULL),(5,0); -DROP TABLE IF EXISTS t3; -Warnings: -Note 1051 Unknown table 't3' -CREATE TABLE t3 ( f3 int) ; -INSERT INTO t3 VALUES (0),(0); -SELECT a1.f3 AS r FROM t2 AS a1 , t1 WHERE a1.f3 < ALL ( SELECT f3 FROM t3 WHERE f3 = 1 ) ; -r -NULL -5 -NULL -5 -DROP TABLE t1, t2, t3; +CREATE TABLE t1 (c int) ; +INSERT INTO t1 VALUES (5),(6); +CREATE TABLE t2 (a int, b int) ; +INSERT INTO t2 VALUES (20,9),(20,9); +create table t3 (d int, e int); +insert into t3 values (2, 9), (3,10); +EXPLAIN +SELECT t2.b , t1.c +FROM t2 LEFT JOIN t1 ON t1.c < 3 +WHERE (t2.b , t1.c) NOT IN (SELECT * from t3); +id select_type table type possible_keys key key_len ref rows Extra +1 PRIMARY t2 ALL NULL NULL NULL NULL 2 +1 PRIMARY t1 ALL NULL NULL NULL NULL 2 Using where +2 DEPENDENT SUBQUERY t3 ALL NULL NULL NULL NULL 2 Using where +SELECT t2.b , t1.c +FROM t2 LEFT JOIN t1 ON t1.c < 3 +WHERE (t2.b, t1.c) NOT IN (SELECT * from t3); +b c +9 NULL +9 NULL +drop table t1, t2, t3; End of 5.3 tests End of 5.5 tests. # @@ -5669,6 +5970,57 @@ id select_type table type possible_keys key key_len ref rows Extra 1 PRIMARY table2 index NULL f1_key 4 NULL 10 Using where; Using index; Using join buffer (flat, BNL join) 2 DEPENDENT SUBQUERY t2 range f1_key f1_key 4 NULL 6 Range checked for each record (index map: 0x1); Using temporary DROP TABLE t1,t2; +# +# lp:826279: assertion failure with GROUP BY a result of subquery +# +CREATE TABLE t1 (a int); +INSERT INTO t1 VALUES (0), (0); +CREATE TABLE t2 (a int, b int, c int); +INSERT INTO t2 VALUES (10,7,0), (0,7,0); +CREATE TABLE t3 (a int, b int); +INSERT INTO t3 VALUES (10,7), (0,7); +SELECT SUM(DISTINCT b), +(SELECT t2.a FROM t1 JOIN t2 ON t2.c != 0 +WHERE t.a != 0 AND t2.a != 0) +FROM (SELECT * FROM t3) AS t +GROUP BY 2; +SUM(DISTINCT b) (SELECT t2.a FROM t1 JOIN t2 ON t2.c != 0 +WHERE t.a != 0 AND t2.a != 0) +7 NULL +SELECT SUM(DISTINCT b), +(SELECT t2.a FROM t1,t2 WHERE t.a != 0 or 1=2 LIMIT 1) +FROM (SELECT * FROM t3) AS t +GROUP BY 2; +SUM(DISTINCT b) (SELECT t2.a FROM t1,t2 WHERE t.a != 0 or 1=2 LIMIT 1) +7 NULL +7 10 +DROP TABLE t1,t2,t3; +# +# Bug#12329653 +# EXPLAIN, UNION, PREPARED STATEMENT, CRASH, SQL_FULL_GROUP_BY +# +CREATE TABLE t1(a1 int); +INSERT INTO t1 VALUES (1),(2); +SELECT @@session.sql_mode INTO @old_sql_mode; +SET SESSION sql_mode='ONLY_FULL_GROUP_BY'; +SELECT 1 FROM t1 WHERE 1 < SOME (SELECT a1 FROM t1); +1 +1 +1 +PREPARE stmt FROM +'SELECT 1 UNION ALL +SELECT 1 FROM t1 +ORDER BY +(SELECT 1 FROM t1 AS t1_0 + WHERE 1 < SOME (SELECT a1 FROM t1) +)' ; +EXECUTE stmt ; +ERROR 21000: Subquery returns more than 1 row +EXECUTE stmt ; +ERROR 21000: Subquery returns more than 1 row +SET SESSION sql_mode=@old_sql_mode; +DEALLOCATE PREPARE stmt; +DROP TABLE t1; set optimizer_switch=@subselect_tmp; set optimizer_switch=default; select @@optimizer_switch like '%materialization=on%'; diff --git a/mysql-test/r/subselect_no_opts.result b/mysql-test/r/subselect_no_opts.result index fa633f4b838..af0fc163f80 100644 --- a/mysql-test/r/subselect_no_opts.result +++ b/mysql-test/r/subselect_no_opts.result @@ -1,9 +1,9 @@ -set @optimizer_switch_for_subselect_test='materialization=off,semijoin=off,mrr=on,mrr_sort_keys=on,index_condition_pushdown=on'; +set @optimizer_switch_for_subselect_test='materialization=off,semijoin=off,subquery_cache=off,mrr=on,mrr_sort_keys=on,index_condition_pushdown=on'; drop table if exists t1,t2,t3,t4,t5,t6,t7,t8,t11,t12; drop view if exists v2; set @subselect_tmp=@@optimizer_switch; set @@optimizer_switch=ifnull(@optimizer_switch_for_subselect_test, -"semijoin=on,firstmatch=on,loosescan=on,partial_match_rowid_merge=off,partial_match_table_scan=off"); +"semijoin=on,firstmatch=on,loosescan=on,semijoin_with_cache=on,partial_match_rowid_merge=off,partial_match_table_scan=off"); set optimizer_switch='mrr=on,mrr_sort_keys=on,index_condition_pushdown=on'; select (select 2); (select 2) @@ -276,7 +276,7 @@ id select_type table type possible_keys key key_len ref rows filtered Extra 1 PRIMARY t3 ALL NULL NULL NULL NULL 3 100.00 Using where 2 SUBQUERY t2 ALL NULL NULL NULL NULL 3 100.00 Warnings: -Note 1003 select `test`.`t3`.`a` AS `a` from `test`.`t3` where <nop>(<in_optimizer>(`test`.`t3`.`a`,((select min(`test`.`t2`.`b`) from `test`.`t2`) <= `test`.`t3`.`a`))) +Note 1003 select `test`.`t3`.`a` AS `a` from `test`.`t3` where <nop>(<in_optimizer>(`test`.`t3`.`a`,((select min(`test`.`t2`.`b`) from `test`.`t2`) <= <cache>(`test`.`t3`.`a`)))) select * from t3 where a >= all (select b from t2); a 7 @@ -368,12 +368,12 @@ INSERT INTO t8 (pseudo,email) VALUES ('joce1','test1'); INSERT INTO t8 (pseudo,email) VALUES ('2joce1','2test1'); EXPLAIN EXTENDED SELECT pseudo,(SELECT email FROM t8 WHERE pseudo=(SELECT pseudo FROM t8 WHERE pseudo='joce')) FROM t8 WHERE pseudo=(SELECT pseudo FROM t8 WHERE pseudo='joce'); id select_type table type possible_keys key key_len ref rows filtered Extra -1 PRIMARY t8 const PRIMARY PRIMARY 37 const 1 100.00 Using index +1 PRIMARY t8 const PRIMARY PRIMARY 37 const 1 100.00 Using where; Using index 4 SUBQUERY t8 const PRIMARY PRIMARY 37 const 1 100.00 Using index -2 SUBQUERY t8 const PRIMARY PRIMARY 37 const 1 100.00 +2 SUBQUERY t8 const PRIMARY PRIMARY 37 const 1 100.00 Using where 3 SUBQUERY t8 const PRIMARY PRIMARY 37 const 1 100.00 Using index Warnings: -Note 1003 select 'joce' AS `pseudo`,(select 'test' from `test`.`t8` where ('joce' = (select 'joce' from `test`.`t8` where 1))) AS `(SELECT email FROM t8 WHERE pseudo=(SELECT pseudo FROM t8 WHERE pseudo='joce'))` from `test`.`t8` where ('joce' = (select 'joce' from `test`.`t8` where 1)) +Note 1003 select `test`.`t8`.`pseudo` AS `pseudo`,(select `test`.`t8`.`email` from `test`.`t8` where (`test`.`t8`.`pseudo` = (select 'joce' from `test`.`t8` where 1))) AS `(SELECT email FROM t8 WHERE pseudo=(SELECT pseudo FROM t8 WHERE pseudo='joce'))` from `test`.`t8` where (`test`.`t8`.`pseudo` = (select 'joce' from `test`.`t8` where 1)) SELECT pseudo FROM t8 WHERE pseudo=(SELECT pseudo,email FROM t8 WHERE pseudo='joce'); ERROR 21000: Operand should contain 1 column(s) @@ -544,18 +544,24 @@ SELECT numreponse, (SELECT numeropost FROM t1 HAVING numreponse=1) FROM (SELECT numreponse (SELECT numeropost FROM t1 HAVING numreponse=1) INSERT INTO t1 (numeropost,numreponse,pseudo) VALUES (1,1,'joce'),(1,2,'joce'),(1,3,'test'); EXPLAIN EXTENDED SELECT numreponse FROM t1 WHERE numeropost='1' AND numreponse=(SELECT 1 FROM t1 WHERE numeropost='1'); +id select_type table type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t1 const PRIMARY,numreponse PRIMARY 7 const,const 1 100.00 Using where; Using index +2 SUBQUERY t1 ref PRIMARY PRIMARY 3 const 2 100.00 Using index +Warnings: +Note 1003 select `test`.`t1`.`numreponse` AS `numreponse` from `test`.`t1` where ((`test`.`t1`.`numeropost` = '1') and (`test`.`t1`.`numreponse` = (select 1 from `test`.`t1` where (`test`.`t1`.`numeropost` = '1')))) +SELECT numreponse FROM t1 WHERE numeropost='1' AND numreponse=(SELECT 1 FROM t1 WHERE numeropost='1'); ERROR 21000: Subquery returns more than 1 row EXPLAIN EXTENDED SELECT MAX(numreponse) FROM t1 WHERE numeropost='1'; id select_type table type possible_keys key key_len ref rows filtered Extra 1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL Select tables optimized away Warnings: -Note 1003 select max(`test`.`t1`.`numreponse`) AS `MAX(numreponse)` from `test`.`t1` where multiple equal(1, `test`.`t1`.`numeropost`) +Note 1003 select max(`test`.`t1`.`numreponse`) AS `MAX(numreponse)` from `test`.`t1` where (`test`.`t1`.`numeropost` = '1') EXPLAIN EXTENDED SELECT numreponse FROM t1 WHERE numeropost='1' AND numreponse=(SELECT MAX(numreponse) FROM t1 WHERE numeropost='1'); id select_type table type possible_keys key key_len ref rows filtered Extra -1 PRIMARY t1 const PRIMARY,numreponse PRIMARY 7 const,const 1 100.00 Using index +1 PRIMARY t1 const PRIMARY,numreponse PRIMARY 7 const,const 1 100.00 Using where; Using index 2 SUBQUERY NULL NULL NULL NULL NULL NULL NULL NULL Select tables optimized away Warnings: -Note 1003 select 3 AS `numreponse` from `test`.`t1` where ((3 = (select max(`test`.`t1`.`numreponse`) from `test`.`t1` where multiple equal(1, `test`.`t1`.`numeropost`)))) +Note 1003 select `test`.`t1`.`numreponse` AS `numreponse` from `test`.`t1` where ((`test`.`t1`.`numeropost` = '1') and (`test`.`t1`.`numreponse` = (select max(`test`.`t1`.`numreponse`) from `test`.`t1` where (`test`.`t1`.`numeropost` = '1')))) drop table t1; CREATE TABLE t1 (a int(1)); INSERT INTO t1 VALUES (1); @@ -917,6 +923,131 @@ id select_type table type possible_keys key key_len ref rows filtered Extra Warnings: Note 1003 select `test`.`t1`.`a` AS `a`,<in_optimizer>(`test`.`t1`.`a`,<exists>(select `test`.`t2`.`a` from `test`.`t2` join `test`.`t3` where ((`test`.`t3`.`a` = `test`.`t2`.`a`) and ((<cache>(`test`.`t1`.`a`) = `test`.`t2`.`a`) or isnull(`test`.`t2`.`a`))) having <is_not_null_test>(`test`.`t2`.`a`))) AS `t1.a in (select t2.a from t2,t3 where t3.a=t2.a)` from `test`.`t1` drop table t1,t2,t3; +# check correct NULL Processing for normal IN/ALL/ANY +# and 2 ways of max/min optimization +create table t1 (a int); +insert into t1 values (1), (100), (NULL), (1000); +create table t2 (a int not null); +# subselect returns empty set (for NULL and non-NULL left part) +select a, a in (select * from t2) from t1; +a a in (select * from t2) +1 0 +100 0 +NULL 0 +1000 0 +select a, a > any (select * from t2) from t1; +a a > any (select * from t2) +1 0 +100 0 +NULL 0 +1000 0 +select a, a > all (select * from t2) from t1; +a a > all (select * from t2) +1 1 +100 1 +NULL 1 +1000 1 +select a from t1 where a in (select * from t2); +a +select a from t1 where a > any (select * from t2); +a +select a from t1 where a > all (select * from t2); +a +1 +100 +NULL +1000 +select a from t1 where a in (select * from t2 group by a); +a +select a from t1 where a > any (select * from t2 group by a); +a +select a from t1 where a > all (select * from t2 group by a); +a +1 +100 +NULL +1000 +insert into t2 values (1),(200); +# sebselect returns non-empty set without NULLs +select a, a in (select * from t2) from t1; +a a in (select * from t2) +1 1 +100 0 +NULL NULL +1000 0 +select a, a > any (select * from t2) from t1; +a a > any (select * from t2) +1 0 +100 1 +NULL NULL +1000 1 +select a, a > all (select * from t2) from t1; +a a > all (select * from t2) +1 0 +100 0 +NULL NULL +1000 1 +select a from t1 where a in (select * from t2); +a +1 +select a from t1 where a > any (select * from t2); +a +100 +1000 +select a from t1 where a > all (select * from t2); +a +1000 +select a from t1 where a in (select * from t2 group by a); +a +1 +select a from t1 where a > any (select * from t2 group by a); +a +100 +1000 +select a from t1 where a > all (select * from t2 group by a); +a +1000 +drop table t2; +create table t2 (a int); +insert into t2 values (1),(NULL),(200); +# sebselect returns non-empty set with NULLs +select a, a in (select * from t2) from t1; +a a in (select * from t2) +1 1 +100 NULL +NULL NULL +1000 NULL +select a, a > any (select * from t2) from t1; +a a > any (select * from t2) +1 NULL +100 1 +NULL NULL +1000 1 +select a, a > all (select * from t2) from t1; +a a > all (select * from t2) +1 0 +100 0 +NULL NULL +1000 NULL +select a from t1 where a in (select * from t2); +a +1 +select a from t1 where a > any (select * from t2); +a +100 +1000 +select a from t1 where a > all (select * from t2); +a +select a from t1 where a in (select * from t2 group by a); +a +1 +select a from t1 where a > any (select * from t2 group by a); +a +100 +1000 +select a from t1 where a > all (select * from t2 group by a); +a +drop table t1, t2; create table t1 (a float); select 10.5 IN (SELECT * from t1 LIMIT 1); ERROR 42000: This version of MySQL doesn't yet support 'LIMIT & IN/ALL/ANY/SOME subquery' @@ -1496,7 +1627,7 @@ id select_type table type possible_keys key key_len ref rows filtered Extra Warnings: Note 1003 select `test`.`t1`.`s1` AS `s1`,(not(<in_optimizer>(`test`.`t1`.`s1`,<exists>(<index_lookup>(<cache>(`test`.`t1`.`s1`) in t2 on s1 checking NULL where (`test`.`t2`.`s1` < 'a2') having trigcond(<is_not_null_test>(`test`.`t2`.`s1`))))))) AS `s1 NOT IN (SELECT s1 FROM t2 WHERE s1 < 'a2')` from `test`.`t1` drop table t1,t2; -create table t2 (a int, b int); +create table t2 (a int, b int not null); create table t3 (a int); insert into t3 values (6),(7),(3); select * from t3 where a >= all (select b from t2); @@ -1509,7 +1640,7 @@ id select_type table type possible_keys key key_len ref rows filtered Extra 1 PRIMARY t3 ALL NULL NULL NULL NULL 3 100.00 Using where 2 SUBQUERY t2 system NULL NULL NULL NULL 0 0.00 const row not found Warnings: -Note 1003 select `test`.`t3`.`a` AS `a` from `test`.`t3` where <not>(<in_optimizer>(`test`.`t3`.`a`,((select max(NULL) from `test`.`t2`) > `test`.`t3`.`a`))) +Note 1003 select `test`.`t3`.`a` AS `a` from `test`.`t3` where <not>(<in_optimizer>(`test`.`t3`.`a`,((select max(NULL) from `test`.`t2`) > <cache>(`test`.`t3`.`a`)))) select * from t3 where a >= some (select b from t2); a explain extended select * from t3 where a >= some (select b from t2); @@ -1517,7 +1648,7 @@ id select_type table type possible_keys key key_len ref rows filtered Extra 1 PRIMARY t3 ALL NULL NULL NULL NULL 3 100.00 Using where 2 SUBQUERY t2 system NULL NULL NULL NULL 0 0.00 const row not found Warnings: -Note 1003 select `test`.`t3`.`a` AS `a` from `test`.`t3` where <nop>(<in_optimizer>(`test`.`t3`.`a`,((select min(NULL) from `test`.`t2`) <= `test`.`t3`.`a`))) +Note 1003 select `test`.`t3`.`a` AS `a` from `test`.`t3` where <nop>(<in_optimizer>(`test`.`t3`.`a`,((select min(NULL) from `test`.`t2`) <= <cache>(`test`.`t3`.`a`)))) select * from t3 where a >= all (select b from t2 group by 1); a 6 @@ -1528,7 +1659,7 @@ id select_type table type possible_keys key key_len ref rows filtered Extra 1 PRIMARY t3 ALL NULL NULL NULL NULL 3 100.00 Using where 2 SUBQUERY t2 system NULL NULL NULL NULL 0 0.00 const row not found Warnings: -Note 1003 select `test`.`t3`.`a` AS `a` from `test`.`t3` where <not>(<in_optimizer>(`test`.`t3`.`a`,(<max>(select NULL from `test`.`t2` group by 1) > `test`.`t3`.`a`))) +Note 1003 select `test`.`t3`.`a` AS `a` from `test`.`t3` where <not>(<in_optimizer>(`test`.`t3`.`a`,(<max>(select NULL from `test`.`t2` group by 1) > <cache>(`test`.`t3`.`a`)))) select * from t3 where a >= some (select b from t2 group by 1); a explain extended select * from t3 where a >= some (select b from t2 group by 1); @@ -1536,7 +1667,7 @@ id select_type table type possible_keys key key_len ref rows filtered Extra 1 PRIMARY t3 ALL NULL NULL NULL NULL 3 100.00 Using where 2 SUBQUERY t2 system NULL NULL NULL NULL 0 0.00 const row not found Warnings: -Note 1003 select `test`.`t3`.`a` AS `a` from `test`.`t3` where <nop>(<in_optimizer>(`test`.`t3`.`a`,(<min>(select NULL from `test`.`t2` group by 1) <= `test`.`t3`.`a`))) +Note 1003 select `test`.`t3`.`a` AS `a` from `test`.`t3` where <nop>(<in_optimizer>(`test`.`t3`.`a`,(<min>(select NULL from `test`.`t2` group by 1) <= <cache>(`test`.`t3`.`a`)))) select * from t3 where NULL >= any (select b from t2); a explain extended select * from t3 where NULL >= any (select b from t2); @@ -1579,7 +1710,7 @@ id select_type table type possible_keys key key_len ref rows filtered Extra 1 PRIMARY t3 ALL NULL NULL NULL NULL 3 100.00 Using where 2 SUBQUERY t2 ALL NULL NULL NULL NULL 4 100.00 Using temporary Warnings: -Note 1003 select `test`.`t3`.`a` AS `a` from `test`.`t3` where <not>(<in_optimizer>(`test`.`t3`.`a`,(<max>(select max(`test`.`t2`.`b`) from `test`.`t2` group by `test`.`t2`.`a`) >= `test`.`t3`.`a`))) +Note 1003 select `test`.`t3`.`a` AS `a` from `test`.`t3` where <not>(<in_optimizer>(`test`.`t3`.`a`,(<max>(select max(`test`.`t2`.`b`) from `test`.`t2` group by `test`.`t2`.`a`) >= <cache>(`test`.`t3`.`a`)))) drop table t2, t3; CREATE TABLE `t1` ( `id` mediumint(9) NOT NULL auto_increment, `taskid` bigint(20) NOT NULL default '0', `dbid` int(11) NOT NULL default '0', `create_date` datetime NOT NULL default '0000-00-00 00:00:00', `last_update` datetime NOT NULL default '0000-00-00 00:00:00', PRIMARY KEY (`id`)) ENGINE=MyISAM CHARSET=latin1 AUTO_INCREMENT=3 ; INSERT INTO `t1` (`id`, `taskid`, `dbid`, `create_date`,`last_update`) VALUES (1, 1, 15, '2003-09-29 10:31:36', '2003-09-29 10:31:36'), (2, 1, 21, now(), now()); @@ -2763,6 +2894,8 @@ select * from (select max(fld) from t1) as foo; max(fld) 1 drop table t1; +set @tmp11867_optimizer_switch=@@optimizer_switch; +set optimizer_switch='semijoin_with_cache=off'; CREATE TABLE t1 (one int, two int, flag char(1)); CREATE TABLE t2 (one int, two int, flag char(1)); INSERT INTO t1 VALUES(1,2,'Y'),(2,3,'Y'),(3,4,'Y'),(5,6,'N'),(7,8,'N'); @@ -2847,6 +2980,7 @@ id select_type table type possible_keys key key_len ref rows filtered Extra Warnings: Note 1003 select `test`.`t1`.`one` AS `one`,`test`.`t1`.`two` AS `two`,<in_optimizer>((`test`.`t1`.`one`,`test`.`t1`.`two`),<exists>(select `test`.`t2`.`one`,`test`.`t2`.`two` from `test`.`t2` where (`test`.`t2`.`flag` = '0') group by `test`.`t2`.`one`,`test`.`t2`.`two` having (trigcond(((<cache>(`test`.`t1`.`one`) = `test`.`t2`.`one`) or isnull(`test`.`t2`.`one`))) and trigcond(((<cache>(`test`.`t1`.`two`) = `test`.`t2`.`two`) or isnull(`test`.`t2`.`two`))) and trigcond(<is_not_null_test>(`test`.`t2`.`one`)) and trigcond(<is_not_null_test>(`test`.`t2`.`two`))))) AS `test` from `test`.`t1` DROP TABLE t1,t2; +set optimizer_switch=@tmp11867_optimizer_switch; CREATE TABLE t1 (a char(5), b char(5)); INSERT INTO t1 VALUES (NULL,'aaa'), ('aaa','aaa'); SELECT * FROM t1 WHERE (a,b) IN (('aaa','aaa'), ('aaa','bbb')); @@ -5507,6 +5641,167 @@ SELECT 1 as foo FROM t1 WHERE a < SOME ); foo DROP TABLE t1; +CREATE TABLE t1 (a int(11), b varchar(1)); +INSERT INTO t1 VALUES (2,NULL),(5,'d'),(7,'g'); +SELECT a FROM t1 WHERE b < ANY ( SELECT b FROM t1 GROUP BY b ); +a +5 +SELECT a FROM t1 WHERE b < ANY ( SELECT b FROM t1 ); +a +5 +SELECT a FROM t1 WHERE b > ANY ( SELECT b FROM t1 GROUP BY b ); +a +7 +SELECT a FROM t1 WHERE b > ANY ( SELECT b FROM t1 ); +a +7 +SELECT a FROM t1 WHERE b <= ANY ( SELECT b FROM t1 GROUP BY b ); +a +5 +7 +SELECT a FROM t1 WHERE b <= ANY ( SELECT b FROM t1 ); +a +5 +7 +SELECT a FROM t1 WHERE b >= ANY ( SELECT b FROM t1 GROUP BY b ); +a +5 +7 +SELECT a FROM t1 WHERE b >= ANY ( SELECT b FROM t1 ); +a +5 +7 +SELECT a FROM t1 WHERE b = ANY ( SELECT b FROM t1 ); +a +5 +7 +SELECT a FROM t1 WHERE b = ANY ( SELECT b FROM t1 GROUP BY b ); +a +5 +7 +SELECT a FROM t1 WHERE b <> ANY ( SELECT b FROM t1 ); +a +5 +7 +SELECT a FROM t1 WHERE b <> ANY ( SELECT b FROM t1 GROUP BY b ); +a +5 +7 +SELECT a FROM t1 WHERE b < ALL ( SELECT b FROM t1 GROUP BY b ); +a +SELECT a FROM t1 WHERE b < ALL ( SELECT b FROM t1 ); +a +SELECT a FROM t1 WHERE b > ALL ( SELECT b FROM t1 GROUP BY b ); +a +SELECT a FROM t1 WHERE b > ALL ( SELECT b FROM t1 ); +a +SELECT a FROM t1 WHERE b <= ALL ( SELECT b FROM t1 GROUP BY b ); +a +SELECT a FROM t1 WHERE b <= ALL ( SELECT b FROM t1 ); +a +SELECT a FROM t1 WHERE b >= ALL ( SELECT b FROM t1 GROUP BY b ); +a +SELECT a FROM t1 WHERE b >= ALL ( SELECT b FROM t1 ); +a +SELECT a FROM t1 WHERE b = ALL ( SELECT b FROM t1 ); +a +SELECT a FROM t1 WHERE b = ALL ( SELECT b FROM t1 GROUP BY b ); +a +SELECT a FROM t1 WHERE b <> ALL ( SELECT b FROM t1 ); +a +SELECT a FROM t1 WHERE b <> ALL ( SELECT b FROM t1 GROUP BY b ); +a +delete from t1; +INSERT INTO t1 VALUES (2,NULL),(5,'d'),(7,'g'); +SELECT a FROM t1 WHERE b < ANY ( SELECT b FROM t1 GROUP BY b ); +a +5 +SELECT a FROM t1 WHERE b < ANY ( SELECT b FROM t1 ); +a +5 +SELECT a FROM t1 WHERE b > ANY ( SELECT b FROM t1 GROUP BY b ); +a +7 +SELECT a FROM t1 WHERE b > ANY ( SELECT b FROM t1 ); +a +7 +SELECT a FROM t1 WHERE b <= ANY ( SELECT b FROM t1 GROUP BY b ); +a +5 +7 +SELECT a FROM t1 WHERE b <= ANY ( SELECT b FROM t1 ); +a +5 +7 +SELECT a FROM t1 WHERE b >= ANY ( SELECT b FROM t1 GROUP BY b ); +a +5 +7 +SELECT a FROM t1 WHERE b >= ANY ( SELECT b FROM t1 ); +a +5 +7 +SELECT a FROM t1 WHERE b = ANY ( SELECT b FROM t1 ); +a +5 +7 +SELECT a FROM t1 WHERE b = ANY ( SELECT b FROM t1 GROUP BY b ); +a +5 +7 +SELECT a FROM t1 WHERE b <> ANY ( SELECT b FROM t1 ); +a +5 +7 +SELECT a FROM t1 WHERE b <> ANY ( SELECT b FROM t1 GROUP BY b ); +a +5 +7 +SELECT a FROM t1 WHERE b < ALL ( SELECT b FROM t1 GROUP BY b ); +a +SELECT a FROM t1 WHERE b < ALL ( SELECT b FROM t1 ); +a +SELECT a FROM t1 WHERE b > ALL ( SELECT b FROM t1 GROUP BY b ); +a +SELECT a FROM t1 WHERE b > ALL ( SELECT b FROM t1 ); +a +SELECT a FROM t1 WHERE b <= ALL ( SELECT b FROM t1 GROUP BY b ); +a +SELECT a FROM t1 WHERE b <= ALL ( SELECT b FROM t1 ); +a +SELECT a FROM t1 WHERE b >= ALL ( SELECT b FROM t1 GROUP BY b ); +a +SELECT a FROM t1 WHERE b >= ALL ( SELECT b FROM t1 ); +a +SELECT a FROM t1 WHERE b = ALL ( SELECT b FROM t1 ); +a +SELECT a FROM t1 WHERE b = ALL ( SELECT b FROM t1 GROUP BY b ); +a +SELECT a FROM t1 WHERE b <> ALL ( SELECT b FROM t1 ); +a +SELECT a FROM t1 WHERE b <> ALL ( SELECT b FROM t1 GROUP BY b ); +a +drop table t1; +# +# Fix of lp:780386 (NULL left part with empty ALL subquery). +# +CREATE TABLE t1 ( f11 int) ; +INSERT IGNORE INTO t1 VALUES (0),(0); +CREATE TABLE t2 ( f3 int, f10 int, KEY (f10,f3)) ; +INSERT IGNORE INTO t2 VALUES (NULL,NULL),(5,0); +DROP TABLE IF EXISTS t3; +Warnings: +Note 1051 Unknown table 't3' +CREATE TABLE t3 ( f3 int) ; +INSERT INTO t3 VALUES (0),(0); +SELECT a1.f3 AS r FROM t2 AS a1 , t1 WHERE a1.f3 < ALL ( SELECT f3 FROM t3 WHERE f3 = 1 ) ; +r +NULL +5 +NULL +5 +DROP TABLE t1, t2, t3; +End of 5.2 tests # # BUG#779885: Crash in eliminate_item_equal with materialization=on in # maria-5.3 @@ -5529,24 +5824,30 @@ ON t2.f10 = t3.f10 f1 DROP TABLE t1,t2,t3; # -# Fix of LP BUG#780386 (NULL left part with empty ALL subquery). +# BUG lp:813473: Wrong result with outer join + NOT IN subquery +# This bug is a duplicate of Bug#11764086 whose test case is added below # -CREATE TABLE t1 ( f11 int) ; -INSERT IGNORE INTO t1 VALUES (0),(0); -CREATE TABLE t2 ( f3 int, f10 int, KEY (f10,f3)) ; -INSERT IGNORE INTO t2 VALUES (NULL,NULL),(5,0); -DROP TABLE IF EXISTS t3; -Warnings: -Note 1051 Unknown table 't3' -CREATE TABLE t3 ( f3 int) ; -INSERT INTO t3 VALUES (0),(0); -SELECT a1.f3 AS r FROM t2 AS a1 , t1 WHERE a1.f3 < ALL ( SELECT f3 FROM t3 WHERE f3 = 1 ) ; -r -NULL -5 -NULL -5 -DROP TABLE t1, t2, t3; +CREATE TABLE t1 (c int) ; +INSERT INTO t1 VALUES (5),(6); +CREATE TABLE t2 (a int, b int) ; +INSERT INTO t2 VALUES (20,9),(20,9); +create table t3 (d int, e int); +insert into t3 values (2, 9), (3,10); +EXPLAIN +SELECT t2.b , t1.c +FROM t2 LEFT JOIN t1 ON t1.c < 3 +WHERE (t2.b , t1.c) NOT IN (SELECT * from t3); +id select_type table type possible_keys key key_len ref rows Extra +1 PRIMARY t2 ALL NULL NULL NULL NULL 2 +1 PRIMARY t1 ALL NULL NULL NULL NULL 2 Using where +2 DEPENDENT SUBQUERY t3 ALL NULL NULL NULL NULL 2 Using where +SELECT t2.b , t1.c +FROM t2 LEFT JOIN t1 ON t1.c < 3 +WHERE (t2.b, t1.c) NOT IN (SELECT * from t3); +b c +9 NULL +9 NULL +drop table t1, t2, t3; End of 5.3 tests End of 5.5 tests. # @@ -5665,5 +5966,56 @@ id select_type table type possible_keys key key_len ref rows Extra 1 PRIMARY table2 index NULL f1_key 4 NULL 10 Using where; Using index; Using join buffer (flat, BNL join) 2 DEPENDENT SUBQUERY t2 range f1_key f1_key 4 NULL 6 Range checked for each record (index map: 0x1); Using temporary DROP TABLE t1,t2; +# +# lp:826279: assertion failure with GROUP BY a result of subquery +# +CREATE TABLE t1 (a int); +INSERT INTO t1 VALUES (0), (0); +CREATE TABLE t2 (a int, b int, c int); +INSERT INTO t2 VALUES (10,7,0), (0,7,0); +CREATE TABLE t3 (a int, b int); +INSERT INTO t3 VALUES (10,7), (0,7); +SELECT SUM(DISTINCT b), +(SELECT t2.a FROM t1 JOIN t2 ON t2.c != 0 +WHERE t.a != 0 AND t2.a != 0) +FROM (SELECT * FROM t3) AS t +GROUP BY 2; +SUM(DISTINCT b) (SELECT t2.a FROM t1 JOIN t2 ON t2.c != 0 +WHERE t.a != 0 AND t2.a != 0) +7 NULL +SELECT SUM(DISTINCT b), +(SELECT t2.a FROM t1,t2 WHERE t.a != 0 or 1=2 LIMIT 1) +FROM (SELECT * FROM t3) AS t +GROUP BY 2; +SUM(DISTINCT b) (SELECT t2.a FROM t1,t2 WHERE t.a != 0 or 1=2 LIMIT 1) +7 NULL +7 10 +DROP TABLE t1,t2,t3; +# +# Bug#12329653 +# EXPLAIN, UNION, PREPARED STATEMENT, CRASH, SQL_FULL_GROUP_BY +# +CREATE TABLE t1(a1 int); +INSERT INTO t1 VALUES (1),(2); +SELECT @@session.sql_mode INTO @old_sql_mode; +SET SESSION sql_mode='ONLY_FULL_GROUP_BY'; +SELECT 1 FROM t1 WHERE 1 < SOME (SELECT a1 FROM t1); +1 +1 +1 +PREPARE stmt FROM +'SELECT 1 UNION ALL +SELECT 1 FROM t1 +ORDER BY +(SELECT 1 FROM t1 AS t1_0 + WHERE 1 < SOME (SELECT a1 FROM t1) +)' ; +EXECUTE stmt ; +ERROR 21000: Subquery returns more than 1 row +EXECUTE stmt ; +ERROR 21000: Subquery returns more than 1 row +SET SESSION sql_mode=@old_sql_mode; +DEALLOCATE PREPARE stmt; +DROP TABLE t1; set optimizer_switch=@subselect_tmp; set @optimizer_switch_for_subselect_test=null; diff --git a/mysql-test/r/subselect_scache.result b/mysql-test/r/subselect_no_scache.result index 8a6284acdd1..febb522254c 100644 --- a/mysql-test/r/subselect_scache.result +++ b/mysql-test/r/subselect_no_scache.result @@ -1,12 +1,12 @@ select @@optimizer_switch like '%subquery_cache=on%'; @@optimizer_switch like '%subquery_cache=on%' -0 -set optimizer_switch='subquery_cache=on'; +1 +set optimizer_switch='subquery_cache=off'; drop table if exists t1,t2,t3,t4,t5,t6,t7,t8,t11,t12; drop view if exists v2; set @subselect_tmp=@@optimizer_switch; set @@optimizer_switch=ifnull(@optimizer_switch_for_subselect_test, -"semijoin=on,firstmatch=on,loosescan=on,partial_match_rowid_merge=off,partial_match_table_scan=off"); +"semijoin=on,firstmatch=on,loosescan=on,semijoin_with_cache=on,partial_match_rowid_merge=off,partial_match_table_scan=off"); set optimizer_switch='mrr=on,mrr_sort_keys=on,index_condition_pushdown=on'; select (select 2); (select 2) @@ -59,7 +59,7 @@ id select_type table type possible_keys key key_len ref rows filtered Extra Warnings: Note 1276 Field or reference 'b.a' of SELECT #3 was resolved in SELECT #1 Note 1276 Field or reference 'b.a' of SELECT #3 was resolved in SELECT #1 -Note 1003 select 1 AS `1` from dual having (<expr_cache><1>((select 1)) = 1) +Note 1003 select 1 AS `1` from dual having ((select 1) = 1) SELECT 1 FROM (SELECT 1 as a) as b HAVING (SELECT a)=1; 1 1 @@ -233,7 +233,7 @@ id select_type table type possible_keys key key_len ref rows filtered Extra 3 DEPENDENT SUBQUERY t3 ALL NULL NULL NULL NULL 3 100.00 Using where Warnings: Note 1276 Field or reference 'test.t4.a' of SELECT #3 was resolved in SELECT #1 -Note 1003 select `test`.`t4`.`b` AS `b`,<expr_cache><`test`.`t4`.`a`>((select avg((`test`.`t2`.`a` + (select min(`test`.`t3`.`a`) from `test`.`t3` where (`test`.`t3`.`a` >= `test`.`t4`.`a`)))) from `test`.`t2`)) AS `(select avg(t2.a+(select min(t3.a) from t3 where t3.a >= t4.a)) from t2)` from `test`.`t4` +Note 1003 select `test`.`t4`.`b` AS `b`,(select avg((`test`.`t2`.`a` + (select min(`test`.`t3`.`a`) from `test`.`t3` where (`test`.`t3`.`a` >= `test`.`t4`.`a`)))) from `test`.`t2`) AS `(select avg(t2.a+(select min(t3.a) from t3 where t3.a >= t4.a)) from t2)` from `test`.`t4` select * from t3 where exists (select * from t2 where t2.b=t3.a); a 7 @@ -279,7 +279,7 @@ id select_type table type possible_keys key key_len ref rows filtered Extra 1 PRIMARY t3 ALL NULL NULL NULL NULL 3 100.00 Using where 2 SUBQUERY t2 ALL NULL NULL NULL NULL 3 100.00 Warnings: -Note 1003 select `test`.`t3`.`a` AS `a` from `test`.`t3` where <nop>(<in_optimizer>(`test`.`t3`.`a`,((select min(`test`.`t2`.`b`) from `test`.`t2`) <= `test`.`t3`.`a`))) +Note 1003 select `test`.`t3`.`a` AS `a` from `test`.`t3` where <nop>(<in_optimizer>(`test`.`t3`.`a`,((select min(`test`.`t2`.`b`) from `test`.`t2`) <= <cache>(`test`.`t3`.`a`)))) select * from t3 where a >= all (select b from t2); a 7 @@ -323,7 +323,7 @@ NULL UNION RESULT <union2,3> ALL NULL NULL NULL NULL NULL NULL Warnings: Note 1276 Field or reference 'test.t2.a' of SELECT #2 was resolved in SELECT #1 Note 1276 Field or reference 'test.t2.a' of SELECT #3 was resolved in SELECT #1 -Note 1003 select <expr_cache><`test`.`t2`.`a`>((select 2 from dual where (2 = `test`.`t2`.`a`) union select `test`.`t5`.`a` from `test`.`t5` where (`test`.`t5`.`a` = `test`.`t2`.`a`))) AS `(select a from t1 where t1.a=t2.a union select a from t5 where t5.a=t2.a)`,`test`.`t2`.`a` AS `a` from `test`.`t2` +Note 1003 select (select 2 from dual where (2 = `test`.`t2`.`a`) union select `test`.`t5`.`a` from `test`.`t5` where (`test`.`t5`.`a` = `test`.`t2`.`a`)) AS `(select a from t1 where t1.a=t2.a union select a from t5 where t5.a=t2.a)`,`test`.`t2`.`a` AS `a` from `test`.`t2` select (select a from t1 where t1.a=t2.a union all select a from t5 where t5.a=t2.a), a from t2; ERROR 21000: Subquery returns more than 1 row create table t6 (patient_uq int, clinic_uq int, index i1 (clinic_uq)); @@ -341,7 +341,7 @@ id select_type table type possible_keys key key_len ref rows filtered Extra 2 DEPENDENT SUBQUERY t7 eq_ref PRIMARY PRIMARY 4 test.t6.clinic_uq 1 100.00 Using index Warnings: Note 1276 Field or reference 'test.t6.clinic_uq' of SELECT #2 was resolved in SELECT #1 -Note 1003 select `test`.`t6`.`patient_uq` AS `patient_uq`,`test`.`t6`.`clinic_uq` AS `clinic_uq` from `test`.`t6` where <expr_cache><`test`.`t6`.`clinic_uq`>(exists(select 1 from `test`.`t7` where (`test`.`t7`.`uq` = `test`.`t6`.`clinic_uq`))) +Note 1003 select `test`.`t6`.`patient_uq` AS `patient_uq`,`test`.`t6`.`clinic_uq` AS `clinic_uq` from `test`.`t6` where exists(select 1 from `test`.`t7` where (`test`.`t7`.`uq` = `test`.`t6`.`clinic_uq`)) select * from t1 where a= (select a from t2,t4 where t2.b=t4.b); ERROR 23000: Column 'a' in field list is ambiguous drop table t1,t2,t3; @@ -371,12 +371,12 @@ INSERT INTO t8 (pseudo,email) VALUES ('joce1','test1'); INSERT INTO t8 (pseudo,email) VALUES ('2joce1','2test1'); EXPLAIN EXTENDED SELECT pseudo,(SELECT email FROM t8 WHERE pseudo=(SELECT pseudo FROM t8 WHERE pseudo='joce')) FROM t8 WHERE pseudo=(SELECT pseudo FROM t8 WHERE pseudo='joce'); id select_type table type possible_keys key key_len ref rows filtered Extra -1 PRIMARY t8 const PRIMARY PRIMARY 37 const 1 100.00 Using index +1 PRIMARY t8 const PRIMARY PRIMARY 37 const 1 100.00 Using where; Using index 4 SUBQUERY t8 const PRIMARY PRIMARY 37 const 1 100.00 Using index -2 SUBQUERY t8 const PRIMARY PRIMARY 37 const 1 100.00 +2 SUBQUERY t8 const PRIMARY PRIMARY 37 const 1 100.00 Using where 3 SUBQUERY t8 const PRIMARY PRIMARY 37 const 1 100.00 Using index Warnings: -Note 1003 select 'joce' AS `pseudo`,(select 'test' from `test`.`t8` where ('joce' = (select 'joce' from `test`.`t8` where 1))) AS `(SELECT email FROM t8 WHERE pseudo=(SELECT pseudo FROM t8 WHERE pseudo='joce'))` from `test`.`t8` where ('joce' = (select 'joce' from `test`.`t8` where 1)) +Note 1003 select `test`.`t8`.`pseudo` AS `pseudo`,(select `test`.`t8`.`email` from `test`.`t8` where (`test`.`t8`.`pseudo` = (select 'joce' from `test`.`t8` where 1))) AS `(SELECT email FROM t8 WHERE pseudo=(SELECT pseudo FROM t8 WHERE pseudo='joce'))` from `test`.`t8` where (`test`.`t8`.`pseudo` = (select 'joce' from `test`.`t8` where 1)) SELECT pseudo FROM t8 WHERE pseudo=(SELECT pseudo,email FROM t8 WHERE pseudo='joce'); ERROR 21000: Operand should contain 1 column(s) @@ -547,18 +547,24 @@ SELECT numreponse, (SELECT numeropost FROM t1 HAVING numreponse=1) FROM (SELECT numreponse (SELECT numeropost FROM t1 HAVING numreponse=1) INSERT INTO t1 (numeropost,numreponse,pseudo) VALUES (1,1,'joce'),(1,2,'joce'),(1,3,'test'); EXPLAIN EXTENDED SELECT numreponse FROM t1 WHERE numeropost='1' AND numreponse=(SELECT 1 FROM t1 WHERE numeropost='1'); +id select_type table type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t1 const PRIMARY,numreponse PRIMARY 7 const,const 1 100.00 Using where; Using index +2 SUBQUERY t1 ref PRIMARY PRIMARY 3 const 2 100.00 Using index +Warnings: +Note 1003 select `test`.`t1`.`numreponse` AS `numreponse` from `test`.`t1` where ((`test`.`t1`.`numeropost` = '1') and (`test`.`t1`.`numreponse` = (select 1 from `test`.`t1` where (`test`.`t1`.`numeropost` = '1')))) +SELECT numreponse FROM t1 WHERE numeropost='1' AND numreponse=(SELECT 1 FROM t1 WHERE numeropost='1'); ERROR 21000: Subquery returns more than 1 row EXPLAIN EXTENDED SELECT MAX(numreponse) FROM t1 WHERE numeropost='1'; id select_type table type possible_keys key key_len ref rows filtered Extra 1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL Select tables optimized away Warnings: -Note 1003 select max(`test`.`t1`.`numreponse`) AS `MAX(numreponse)` from `test`.`t1` where multiple equal(1, `test`.`t1`.`numeropost`) +Note 1003 select max(`test`.`t1`.`numreponse`) AS `MAX(numreponse)` from `test`.`t1` where (`test`.`t1`.`numeropost` = '1') EXPLAIN EXTENDED SELECT numreponse FROM t1 WHERE numeropost='1' AND numreponse=(SELECT MAX(numreponse) FROM t1 WHERE numeropost='1'); id select_type table type possible_keys key key_len ref rows filtered Extra -1 PRIMARY t1 const PRIMARY,numreponse PRIMARY 7 const,const 1 100.00 Using index +1 PRIMARY t1 const PRIMARY,numreponse PRIMARY 7 const,const 1 100.00 Using where; Using index 2 SUBQUERY NULL NULL NULL NULL NULL NULL NULL NULL Select tables optimized away Warnings: -Note 1003 select 3 AS `numreponse` from `test`.`t1` where ((3 = (select max(`test`.`t1`.`numreponse`) from `test`.`t1` where multiple equal(1, `test`.`t1`.`numeropost`)))) +Note 1003 select `test`.`t1`.`numreponse` AS `numreponse` from `test`.`t1` where ((`test`.`t1`.`numeropost` = '1') and (`test`.`t1`.`numreponse` = (select max(`test`.`t1`.`numreponse`) from `test`.`t1` where (`test`.`t1`.`numeropost` = '1')))) drop table t1; CREATE TABLE t1 (a int(1)); INSERT INTO t1 VALUES (1); @@ -755,7 +761,7 @@ id select_type table type possible_keys key key_len ref rows filtered Extra 3 DEPENDENT UNION NULL NULL NULL NULL NULL NULL NULL NULL No tables used NULL UNION RESULT <union2,3> ALL NULL NULL NULL NULL NULL NULL Warnings: -Note 1003 select `test`.`t2`.`id` AS `id` from `test`.`t2` where <expr_cache><`test`.`t2`.`id`>(<in_optimizer>(`test`.`t2`.`id`,<exists>(select 1 having (<cache>(`test`.`t2`.`id`) = <ref_null_helper>(1)) union select 3 having (<cache>(`test`.`t2`.`id`) = <ref_null_helper>(3))))) +Note 1003 select `test`.`t2`.`id` AS `id` from `test`.`t2` where <in_optimizer>(`test`.`t2`.`id`,<exists>(select 1 having (<cache>(`test`.`t2`.`id`) = <ref_null_helper>(1)) union select 3 having (<cache>(`test`.`t2`.`id`) = <ref_null_helper>(3)))) SELECT * FROM t2 WHERE id IN (SELECT 5 UNION SELECT 3); id SELECT * FROM t2 WHERE id IN (SELECT 5 UNION SELECT 2); @@ -903,7 +909,7 @@ id select_type table type possible_keys key key_len ref rows filtered Extra 1 PRIMARY t1 index NULL PRIMARY 4 NULL 4 100.00 Using index 2 DEPENDENT SUBQUERY t2 index_subquery a a 5 func 2 100.00 Using index Warnings: -Note 1003 select `test`.`t1`.`a` AS `a`,<expr_cache><`test`.`t1`.`a`>(<in_optimizer>(`test`.`t1`.`a`,<exists>(<index_lookup>(<cache>(`test`.`t1`.`a`) in t2 on a checking NULL having <is_not_null_test>(`test`.`t2`.`a`))))) AS `t1.a in (select t2.a from t2)` from `test`.`t1` +Note 1003 select `test`.`t1`.`a` AS `a`,<in_optimizer>(`test`.`t1`.`a`,<exists>(<index_lookup>(<cache>(`test`.`t1`.`a`) in t2 on a checking NULL having <is_not_null_test>(`test`.`t2`.`a`)))) AS `t1.a in (select t2.a from t2)` from `test`.`t1` CREATE TABLE t3 (a int(11) default '0'); INSERT INTO t3 VALUES (1),(2),(3); SELECT t1.a, t1.a in (select t2.a from t2,t3 where t3.a=t2.a) FROM t1; @@ -918,8 +924,133 @@ id select_type table type possible_keys key key_len ref rows filtered Extra 2 DEPENDENT SUBQUERY t2 ref_or_null a a 5 func 2 100.00 Using where; Using index 2 DEPENDENT SUBQUERY t3 ALL NULL NULL NULL NULL 3 100.00 Using where; Using join buffer (flat, BNL join) Warnings: -Note 1003 select `test`.`t1`.`a` AS `a`,<expr_cache><`test`.`t1`.`a`>(<in_optimizer>(`test`.`t1`.`a`,<exists>(select `test`.`t2`.`a` from `test`.`t2` join `test`.`t3` where ((`test`.`t3`.`a` = `test`.`t2`.`a`) and ((<cache>(`test`.`t1`.`a`) = `test`.`t2`.`a`) or isnull(`test`.`t2`.`a`))) having <is_not_null_test>(`test`.`t2`.`a`)))) AS `t1.a in (select t2.a from t2,t3 where t3.a=t2.a)` from `test`.`t1` +Note 1003 select `test`.`t1`.`a` AS `a`,<in_optimizer>(`test`.`t1`.`a`,<exists>(select `test`.`t2`.`a` from `test`.`t2` join `test`.`t3` where ((`test`.`t3`.`a` = `test`.`t2`.`a`) and ((<cache>(`test`.`t1`.`a`) = `test`.`t2`.`a`) or isnull(`test`.`t2`.`a`))) having <is_not_null_test>(`test`.`t2`.`a`))) AS `t1.a in (select t2.a from t2,t3 where t3.a=t2.a)` from `test`.`t1` drop table t1,t2,t3; +# check correct NULL Processing for normal IN/ALL/ANY +# and 2 ways of max/min optimization +create table t1 (a int); +insert into t1 values (1), (100), (NULL), (1000); +create table t2 (a int not null); +# subselect returns empty set (for NULL and non-NULL left part) +select a, a in (select * from t2) from t1; +a a in (select * from t2) +1 0 +100 0 +NULL 0 +1000 0 +select a, a > any (select * from t2) from t1; +a a > any (select * from t2) +1 0 +100 0 +NULL 0 +1000 0 +select a, a > all (select * from t2) from t1; +a a > all (select * from t2) +1 1 +100 1 +NULL 1 +1000 1 +select a from t1 where a in (select * from t2); +a +select a from t1 where a > any (select * from t2); +a +select a from t1 where a > all (select * from t2); +a +1 +100 +NULL +1000 +select a from t1 where a in (select * from t2 group by a); +a +select a from t1 where a > any (select * from t2 group by a); +a +select a from t1 where a > all (select * from t2 group by a); +a +1 +100 +NULL +1000 +insert into t2 values (1),(200); +# sebselect returns non-empty set without NULLs +select a, a in (select * from t2) from t1; +a a in (select * from t2) +1 1 +100 0 +NULL NULL +1000 0 +select a, a > any (select * from t2) from t1; +a a > any (select * from t2) +1 0 +100 1 +NULL NULL +1000 1 +select a, a > all (select * from t2) from t1; +a a > all (select * from t2) +1 0 +100 0 +NULL NULL +1000 1 +select a from t1 where a in (select * from t2); +a +1 +select a from t1 where a > any (select * from t2); +a +100 +1000 +select a from t1 where a > all (select * from t2); +a +1000 +select a from t1 where a in (select * from t2 group by a); +a +1 +select a from t1 where a > any (select * from t2 group by a); +a +100 +1000 +select a from t1 where a > all (select * from t2 group by a); +a +1000 +drop table t2; +create table t2 (a int); +insert into t2 values (1),(NULL),(200); +# sebselect returns non-empty set with NULLs +select a, a in (select * from t2) from t1; +a a in (select * from t2) +1 1 +100 NULL +NULL NULL +1000 NULL +select a, a > any (select * from t2) from t1; +a a > any (select * from t2) +1 NULL +100 1 +NULL NULL +1000 1 +select a, a > all (select * from t2) from t1; +a a > all (select * from t2) +1 0 +100 0 +NULL NULL +1000 NULL +select a from t1 where a in (select * from t2); +a +1 +select a from t1 where a > any (select * from t2); +a +100 +1000 +select a from t1 where a > all (select * from t2); +a +select a from t1 where a in (select * from t2 group by a); +a +1 +select a from t1 where a > any (select * from t2 group by a); +a +100 +1000 +select a from t1 where a > all (select * from t2 group by a); +a +drop table t1, t2; create table t1 (a float); select 10.5 IN (SELECT * from t1 LIMIT 1); ERROR 42000: This version of MySQL doesn't yet support 'LIMIT & IN/ALL/ANY/SOME subquery' @@ -1479,27 +1610,27 @@ id select_type table type possible_keys key key_len ref rows filtered Extra 1 PRIMARY t1 index NULL s1 6 NULL 3 100.00 Using index 2 DEPENDENT SUBQUERY t2 index_subquery s1 s1 6 func 2 100.00 Using index; Full scan on NULL key Warnings: -Note 1003 select `test`.`t1`.`s1` AS `s1`,(not(<expr_cache><`test`.`t1`.`s1`>(<in_optimizer>(`test`.`t1`.`s1`,<exists>(<index_lookup>(<cache>(`test`.`t1`.`s1`) in t2 on s1 checking NULL having trigcond(<is_not_null_test>(`test`.`t2`.`s1`)))))))) AS `s1 NOT IN (SELECT s1 FROM t2)` from `test`.`t1` +Note 1003 select `test`.`t1`.`s1` AS `s1`,(not(<in_optimizer>(`test`.`t1`.`s1`,<exists>(<index_lookup>(<cache>(`test`.`t1`.`s1`) in t2 on s1 checking NULL having trigcond(<is_not_null_test>(`test`.`t2`.`s1`))))))) AS `s1 NOT IN (SELECT s1 FROM t2)` from `test`.`t1` explain extended select s1, s1 = ANY (SELECT s1 FROM t2) from t1; id select_type table type possible_keys key key_len ref rows filtered Extra 1 PRIMARY t1 index NULL s1 6 NULL 3 100.00 Using index 2 DEPENDENT SUBQUERY t2 index_subquery s1 s1 6 func 2 100.00 Using index; Full scan on NULL key Warnings: -Note 1003 select `test`.`t1`.`s1` AS `s1`,<expr_cache><`test`.`t1`.`s1`>(<in_optimizer>(`test`.`t1`.`s1`,<exists>(<index_lookup>(<cache>(`test`.`t1`.`s1`) in t2 on s1 checking NULL having trigcond(<is_not_null_test>(`test`.`t2`.`s1`)))))) AS `s1 = ANY (SELECT s1 FROM t2)` from `test`.`t1` +Note 1003 select `test`.`t1`.`s1` AS `s1`,<in_optimizer>(`test`.`t1`.`s1`,<exists>(<index_lookup>(<cache>(`test`.`t1`.`s1`) in t2 on s1 checking NULL having trigcond(<is_not_null_test>(`test`.`t2`.`s1`))))) AS `s1 = ANY (SELECT s1 FROM t2)` from `test`.`t1` explain extended select s1, s1 <> ALL (SELECT s1 FROM t2) from t1; id select_type table type possible_keys key key_len ref rows filtered Extra 1 PRIMARY t1 index NULL s1 6 NULL 3 100.00 Using index 2 DEPENDENT SUBQUERY t2 index_subquery s1 s1 6 func 2 100.00 Using index; Full scan on NULL key Warnings: -Note 1003 select `test`.`t1`.`s1` AS `s1`,(not(<expr_cache><`test`.`t1`.`s1`>(<in_optimizer>(`test`.`t1`.`s1`,<exists>(<index_lookup>(<cache>(`test`.`t1`.`s1`) in t2 on s1 checking NULL having trigcond(<is_not_null_test>(`test`.`t2`.`s1`)))))))) AS `s1 <> ALL (SELECT s1 FROM t2)` from `test`.`t1` +Note 1003 select `test`.`t1`.`s1` AS `s1`,(not(<in_optimizer>(`test`.`t1`.`s1`,<exists>(<index_lookup>(<cache>(`test`.`t1`.`s1`) in t2 on s1 checking NULL having trigcond(<is_not_null_test>(`test`.`t2`.`s1`))))))) AS `s1 <> ALL (SELECT s1 FROM t2)` from `test`.`t1` explain extended select s1, s1 NOT IN (SELECT s1 FROM t2 WHERE s1 < 'a2') from t1; id select_type table type possible_keys key key_len ref rows filtered Extra 1 PRIMARY t1 index NULL s1 6 NULL 3 100.00 Using index 2 DEPENDENT SUBQUERY t2 index_subquery s1 s1 6 func 2 100.00 Using index; Using where; Full scan on NULL key Warnings: -Note 1003 select `test`.`t1`.`s1` AS `s1`,(not(<expr_cache><`test`.`t1`.`s1`>(<in_optimizer>(`test`.`t1`.`s1`,<exists>(<index_lookup>(<cache>(`test`.`t1`.`s1`) in t2 on s1 checking NULL where (`test`.`t2`.`s1` < 'a2') having trigcond(<is_not_null_test>(`test`.`t2`.`s1`)))))))) AS `s1 NOT IN (SELECT s1 FROM t2 WHERE s1 < 'a2')` from `test`.`t1` +Note 1003 select `test`.`t1`.`s1` AS `s1`,(not(<in_optimizer>(`test`.`t1`.`s1`,<exists>(<index_lookup>(<cache>(`test`.`t1`.`s1`) in t2 on s1 checking NULL where (`test`.`t2`.`s1` < 'a2') having trigcond(<is_not_null_test>(`test`.`t2`.`s1`))))))) AS `s1 NOT IN (SELECT s1 FROM t2 WHERE s1 < 'a2')` from `test`.`t1` drop table t1,t2; -create table t2 (a int, b int); +create table t2 (a int, b int not null); create table t3 (a int); insert into t3 values (6),(7),(3); select * from t3 where a >= all (select b from t2); @@ -1512,7 +1643,7 @@ id select_type table type possible_keys key key_len ref rows filtered Extra 1 PRIMARY t3 ALL NULL NULL NULL NULL 3 100.00 Using where 2 SUBQUERY t2 system NULL NULL NULL NULL 0 0.00 const row not found Warnings: -Note 1003 select `test`.`t3`.`a` AS `a` from `test`.`t3` where <not>(<in_optimizer>(`test`.`t3`.`a`,((select max(NULL) from `test`.`t2`) > `test`.`t3`.`a`))) +Note 1003 select `test`.`t3`.`a` AS `a` from `test`.`t3` where <not>(<in_optimizer>(`test`.`t3`.`a`,((select max(NULL) from `test`.`t2`) > <cache>(`test`.`t3`.`a`)))) select * from t3 where a >= some (select b from t2); a explain extended select * from t3 where a >= some (select b from t2); @@ -1520,7 +1651,7 @@ id select_type table type possible_keys key key_len ref rows filtered Extra 1 PRIMARY t3 ALL NULL NULL NULL NULL 3 100.00 Using where 2 SUBQUERY t2 system NULL NULL NULL NULL 0 0.00 const row not found Warnings: -Note 1003 select `test`.`t3`.`a` AS `a` from `test`.`t3` where <nop>(<in_optimizer>(`test`.`t3`.`a`,((select min(NULL) from `test`.`t2`) <= `test`.`t3`.`a`))) +Note 1003 select `test`.`t3`.`a` AS `a` from `test`.`t3` where <nop>(<in_optimizer>(`test`.`t3`.`a`,((select min(NULL) from `test`.`t2`) <= <cache>(`test`.`t3`.`a`)))) select * from t3 where a >= all (select b from t2 group by 1); a 6 @@ -1531,7 +1662,7 @@ id select_type table type possible_keys key key_len ref rows filtered Extra 1 PRIMARY t3 ALL NULL NULL NULL NULL 3 100.00 Using where 2 SUBQUERY t2 system NULL NULL NULL NULL 0 0.00 const row not found Warnings: -Note 1003 select `test`.`t3`.`a` AS `a` from `test`.`t3` where <not>(<in_optimizer>(`test`.`t3`.`a`,(<max>(select NULL from `test`.`t2` group by 1) > `test`.`t3`.`a`))) +Note 1003 select `test`.`t3`.`a` AS `a` from `test`.`t3` where <not>(<in_optimizer>(`test`.`t3`.`a`,(<max>(select NULL from `test`.`t2` group by 1) > <cache>(`test`.`t3`.`a`)))) select * from t3 where a >= some (select b from t2 group by 1); a explain extended select * from t3 where a >= some (select b from t2 group by 1); @@ -1539,7 +1670,7 @@ id select_type table type possible_keys key key_len ref rows filtered Extra 1 PRIMARY t3 ALL NULL NULL NULL NULL 3 100.00 Using where 2 SUBQUERY t2 system NULL NULL NULL NULL 0 0.00 const row not found Warnings: -Note 1003 select `test`.`t3`.`a` AS `a` from `test`.`t3` where <nop>(<in_optimizer>(`test`.`t3`.`a`,(<min>(select NULL from `test`.`t2` group by 1) <= `test`.`t3`.`a`))) +Note 1003 select `test`.`t3`.`a` AS `a` from `test`.`t3` where <nop>(<in_optimizer>(`test`.`t3`.`a`,(<min>(select NULL from `test`.`t2` group by 1) <= <cache>(`test`.`t3`.`a`)))) select * from t3 where NULL >= any (select b from t2); a explain extended select * from t3 where NULL >= any (select b from t2); @@ -1582,7 +1713,7 @@ id select_type table type possible_keys key key_len ref rows filtered Extra 1 PRIMARY t3 ALL NULL NULL NULL NULL 3 100.00 Using where 2 SUBQUERY t2 ALL NULL NULL NULL NULL 4 100.00 Using temporary Warnings: -Note 1003 select `test`.`t3`.`a` AS `a` from `test`.`t3` where <not>(<in_optimizer>(`test`.`t3`.`a`,(<max>(select max(`test`.`t2`.`b`) from `test`.`t2` group by `test`.`t2`.`a`) >= `test`.`t3`.`a`))) +Note 1003 select `test`.`t3`.`a` AS `a` from `test`.`t3` where <not>(<in_optimizer>(`test`.`t3`.`a`,(<max>(select max(`test`.`t2`.`b`) from `test`.`t2` group by `test`.`t2`.`a`) >= <cache>(`test`.`t3`.`a`)))) drop table t2, t3; CREATE TABLE `t1` ( `id` mediumint(9) NOT NULL auto_increment, `taskid` bigint(20) NOT NULL default '0', `dbid` int(11) NOT NULL default '0', `create_date` datetime NOT NULL default '0000-00-00 00:00:00', `last_update` datetime NOT NULL default '0000-00-00 00:00:00', PRIMARY KEY (`id`)) ENGINE=MyISAM CHARSET=latin1 AUTO_INCREMENT=3 ; INSERT INTO `t1` (`id`, `taskid`, `dbid`, `create_date`,`last_update`) VALUES (1, 1, 15, '2003-09-29 10:31:36', '2003-09-29 10:31:36'), (2, 1, 21, now(), now()); @@ -1752,14 +1883,14 @@ id select_type table type possible_keys key key_len ref rows filtered Extra 1 PRIMARY t1 ALL NULL NULL NULL NULL 12 100.00 Using where 2 DEPENDENT SUBQUERY t1 unique_subquery PRIMARY PRIMARY 4 func 1 100.00 Using index; Using where Warnings: -Note 1003 select `test`.`t1`.`id` AS `id`,`test`.`t1`.`text` AS `text` from `test`.`t1` where (not(<expr_cache><`test`.`t1`.`id`>(<in_optimizer>(`test`.`t1`.`id`,<exists>(<primary_index_lookup>(<cache>(`test`.`t1`.`id`) in t1 on PRIMARY where ((`test`.`t1`.`id` < 8) and (<cache>(`test`.`t1`.`id`) = `test`.`t1`.`id`)))))))) +Note 1003 select `test`.`t1`.`id` AS `id`,`test`.`t1`.`text` AS `text` from `test`.`t1` where (not(<in_optimizer>(`test`.`t1`.`id`,<exists>(<primary_index_lookup>(<cache>(`test`.`t1`.`id`) in t1 on PRIMARY where ((`test`.`t1`.`id` < 8) and (<cache>(`test`.`t1`.`id`) = `test`.`t1`.`id`))))))) explain extended select * from t1 as tt where not exists (select id from t1 where id < 8 and (id = tt.id or id is null) having id is not null); id select_type table type possible_keys key key_len ref rows filtered Extra 1 PRIMARY tt ALL NULL NULL NULL NULL 12 100.00 Using where 2 DEPENDENT SUBQUERY t1 eq_ref PRIMARY PRIMARY 4 test.tt.id 1 100.00 Using where; Using index Warnings: Note 1276 Field or reference 'test.tt.id' of SELECT #2 was resolved in SELECT #1 -Note 1003 select `test`.`tt`.`id` AS `id`,`test`.`tt`.`text` AS `text` from `test`.`t1` `tt` where (not(<expr_cache><`test`.`tt`.`id`>(exists(select `test`.`t1`.`id` from `test`.`t1` where ((`test`.`t1`.`id` < 8) and (`test`.`t1`.`id` = `test`.`tt`.`id`)) having (`test`.`t1`.`id` is not null))))) +Note 1003 select `test`.`tt`.`id` AS `id`,`test`.`tt`.`text` AS `text` from `test`.`t1` `tt` where (not(exists(select `test`.`t1`.`id` from `test`.`t1` where ((`test`.`t1`.`id` < 8) and (`test`.`t1`.`id` = `test`.`tt`.`id`)) having (`test`.`t1`.`id` is not null)))) insert into t1 (id, text) values (1000, 'text1000'), (1001, 'text1001'); create table t2 (id int not null, text varchar(20) not null default '', primary key (id)); insert into t2 (id, text) values (1, 'text1'), (2, 'text2'), (3, 'text3'), (4, 'text4'), (5, 'text5'), (6, 'text6'), (7, 'text7'), (8, 'text8'), (9, 'text9'), (10, 'text10'), (11, 'text1'), (12, 'text2'), (13, 'text3'), (14, 'text4'), (15, 'text5'), (16, 'text6'), (17, 'text7'), (18, 'text8'), (19, 'text9'), (20, 'text10'),(21, 'text1'), (22, 'text2'), (23, 'text3'), (24, 'text4'), (25, 'text5'), (26, 'text6'), (27, 'text7'), (28, 'text8'), (29, 'text9'), (30, 'text10'), (31, 'text1'), (32, 'text2'), (33, 'text3'), (34, 'text4'), (35, 'text5'), (36, 'text6'), (37, 'text7'), (38, 'text8'), (39, 'text9'), (40, 'text10'), (41, 'text1'), (42, 'text2'), (43, 'text3'), (44, 'text4'), (45, 'text5'), (46, 'text6'), (47, 'text7'), (48, 'text8'), (49, 'text9'), (50, 'text10'); @@ -2295,7 +2426,7 @@ id select_type table type possible_keys key key_len ref rows filtered Extra 2 DEPENDENT SUBQUERY t1 ALL NULL NULL NULL NULL 2 100.00 Using where Warnings: Note 1276 Field or reference 'test.up.a' of SELECT #2 was resolved in SELECT #1 -Note 1003 select `test`.`up`.`a` AS `a`,`test`.`up`.`b` AS `b` from `test`.`t1` `up` where <expr_cache><`test`.`up`.`a`>(exists(select 1 from `test`.`t1` where (`test`.`t1`.`a` = `test`.`up`.`a`))) +Note 1003 select `test`.`up`.`a` AS `a`,`test`.`up`.`b` AS `b` from `test`.`t1` `up` where exists(select 1 from `test`.`t1` where (`test`.`t1`.`a` = `test`.`up`.`a`)) drop table t1; CREATE TABLE t1 (t1_a int); INSERT INTO t1 VALUES (1); @@ -2766,6 +2897,8 @@ select * from (select max(fld) from t1) as foo; max(fld) 1 drop table t1; +set @tmp11867_optimizer_switch=@@optimizer_switch; +set optimizer_switch='semijoin_with_cache=off'; CREATE TABLE t1 (one int, two int, flag char(1)); CREATE TABLE t2 (one int, two int, flag char(1)); INSERT INTO t1 VALUES(1,2,'Y'),(2,3,'Y'),(3,4,'Y'),(5,6,'N'),(7,8,'N'); @@ -2836,7 +2969,7 @@ id select_type table type possible_keys key key_len ref rows filtered Extra 1 PRIMARY t1 ALL NULL NULL NULL NULL 8 100.00 2 DEPENDENT SUBQUERY t2 ALL NULL NULL NULL NULL 9 100.00 Using where Warnings: -Note 1003 select `test`.`t1`.`one` AS `one`,`test`.`t1`.`two` AS `two`,<expr_cache><`test`.`t1`.`one`,`test`.`t1`.`two`>(<in_optimizer>((`test`.`t1`.`one`,`test`.`t1`.`two`),<exists>(select `test`.`t2`.`one`,`test`.`t2`.`two` from `test`.`t2` where ((`test`.`t2`.`flag` = '0') and trigcond(((<cache>(`test`.`t1`.`one`) = `test`.`t2`.`one`) or isnull(`test`.`t2`.`one`))) and trigcond(((<cache>(`test`.`t1`.`two`) = `test`.`t2`.`two`) or isnull(`test`.`t2`.`two`)))) having (trigcond(<is_not_null_test>(`test`.`t2`.`one`)) and trigcond(<is_not_null_test>(`test`.`t2`.`two`)))))) AS `test` from `test`.`t1` +Note 1003 select `test`.`t1`.`one` AS `one`,`test`.`t1`.`two` AS `two`,<in_optimizer>((`test`.`t1`.`one`,`test`.`t1`.`two`),<exists>(select `test`.`t2`.`one`,`test`.`t2`.`two` from `test`.`t2` where ((`test`.`t2`.`flag` = '0') and trigcond(((<cache>(`test`.`t1`.`one`) = `test`.`t2`.`one`) or isnull(`test`.`t2`.`one`))) and trigcond(((<cache>(`test`.`t1`.`two`) = `test`.`t2`.`two`) or isnull(`test`.`t2`.`two`)))) having (trigcond(<is_not_null_test>(`test`.`t2`.`one`)) and trigcond(<is_not_null_test>(`test`.`t2`.`two`))))) AS `test` from `test`.`t1` explain extended SELECT one,two from t1 where ROW(one,two) IN (SELECT one,two FROM t2 WHERE flag = 'N'); id select_type table type possible_keys key key_len ref rows filtered Extra 1 PRIMARY t1 ALL NULL NULL NULL NULL 8 100.00 @@ -2848,8 +2981,9 @@ id select_type table type possible_keys key key_len ref rows filtered Extra 1 PRIMARY t1 ALL NULL NULL NULL NULL 8 100.00 2 DEPENDENT SUBQUERY t2 ALL NULL NULL NULL NULL 9 100.00 Using where; Using temporary Warnings: -Note 1003 select `test`.`t1`.`one` AS `one`,`test`.`t1`.`two` AS `two`,<expr_cache><`test`.`t1`.`one`,`test`.`t1`.`two`>(<in_optimizer>((`test`.`t1`.`one`,`test`.`t1`.`two`),<exists>(select `test`.`t2`.`one`,`test`.`t2`.`two` from `test`.`t2` where (`test`.`t2`.`flag` = '0') group by `test`.`t2`.`one`,`test`.`t2`.`two` having (trigcond(((<cache>(`test`.`t1`.`one`) = `test`.`t2`.`one`) or isnull(`test`.`t2`.`one`))) and trigcond(((<cache>(`test`.`t1`.`two`) = `test`.`t2`.`two`) or isnull(`test`.`t2`.`two`))) and trigcond(<is_not_null_test>(`test`.`t2`.`one`)) and trigcond(<is_not_null_test>(`test`.`t2`.`two`)))))) AS `test` from `test`.`t1` +Note 1003 select `test`.`t1`.`one` AS `one`,`test`.`t1`.`two` AS `two`,<in_optimizer>((`test`.`t1`.`one`,`test`.`t1`.`two`),<exists>(select `test`.`t2`.`one`,`test`.`t2`.`two` from `test`.`t2` where (`test`.`t2`.`flag` = '0') group by `test`.`t2`.`one`,`test`.`t2`.`two` having (trigcond(((<cache>(`test`.`t1`.`one`) = `test`.`t2`.`one`) or isnull(`test`.`t2`.`one`))) and trigcond(((<cache>(`test`.`t1`.`two`) = `test`.`t2`.`two`) or isnull(`test`.`t2`.`two`))) and trigcond(<is_not_null_test>(`test`.`t2`.`one`)) and trigcond(<is_not_null_test>(`test`.`t2`.`two`))))) AS `test` from `test`.`t1` DROP TABLE t1,t2; +set optimizer_switch=@tmp11867_optimizer_switch; CREATE TABLE t1 (a char(5), b char(5)); INSERT INTO t1 VALUES (NULL,'aaa'), ('aaa','aaa'); SELECT * FROM t1 WHERE (a,b) IN (('aaa','aaa'), ('aaa','bbb')); @@ -4294,7 +4428,7 @@ id select_type table type possible_keys key key_len ref rows filtered Extra 2 DEPENDENT SUBQUERY t2 ALL NULL NULL NULL NULL 2 100.00 Using where Warnings: Note 1276 Field or reference 'test.t1.a' of SELECT #2 was resolved in SELECT #1 -Note 1003 select 2 AS `2` from `test`.`t1` where <expr_cache><`test`.`t1`.`a`>(exists(select 1 from `test`.`t2` where (`test`.`t1`.`a` = `test`.`t2`.`a`))) +Note 1003 select 2 AS `2` from `test`.`t1` where exists(select 1 from `test`.`t2` where (`test`.`t1`.`a` = `test`.`t2`.`a`)) EXPLAIN EXTENDED SELECT 2 FROM t1 WHERE EXISTS ((SELECT 1 FROM t2 WHERE t1.a=t2.a) UNION (SELECT 1 FROM t2 WHERE t1.a = t2.a)); @@ -4306,7 +4440,7 @@ NULL UNION RESULT <union2,3> ALL NULL NULL NULL NULL NULL NULL Warnings: Note 1276 Field or reference 'test.t1.a' of SELECT #2 was resolved in SELECT #1 Note 1276 Field or reference 'test.t1.a' of SELECT #3 was resolved in SELECT #1 -Note 1003 select 2 AS `2` from `test`.`t1` where <expr_cache><`test`.`t1`.`a`>(exists((select 1 from `test`.`t2` where (`test`.`t1`.`a` = `test`.`t2`.`a`)) union (select 1 from `test`.`t2` where (`test`.`t1`.`a` = `test`.`t2`.`a`)))) +Note 1003 select 2 AS `2` from `test`.`t1` where exists((select 1 from `test`.`t2` where (`test`.`t1`.`a` = `test`.`t2`.`a`)) union (select 1 from `test`.`t2` where (`test`.`t1`.`a` = `test`.`t2`.`a`))) DROP TABLE t1,t2; create table t0(a int); insert into t0 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9); @@ -4384,13 +4518,13 @@ id select_type table type possible_keys key key_len ref rows filtered Extra 1 PRIMARY t1 ALL NULL NULL NULL NULL 2 100.00 2 DEPENDENT SUBQUERY t1 ALL NULL NULL NULL NULL 2 100.00 Using temporary Warnings: -Note 1003 select 1 AS `1` from `test`.`t1` where <expr_cache><1>(<in_optimizer>(1,<exists>(select 1 from `test`.`t1` group by `test`.`t1`.`a` having (1 = <ref_null_helper>(1))))) +Note 1003 select 1 AS `1` from `test`.`t1` where <in_optimizer>(1,<exists>(select 1 from `test`.`t1` group by `test`.`t1`.`a` having (1 = <ref_null_helper>(1)))) EXPLAIN EXTENDED SELECT 1 FROM t1 WHERE 1 IN (SELECT 1 FROM t1 WHERE a > 3 GROUP BY a); id select_type table type possible_keys key key_len ref rows filtered Extra 1 PRIMARY t1 ALL NULL NULL NULL NULL 2 100.00 2 DEPENDENT SUBQUERY t1 ALL NULL NULL NULL NULL 2 100.00 Using where; Using temporary Warnings: -Note 1003 select 1 AS `1` from `test`.`t1` where <expr_cache><1>(<in_optimizer>(1,<exists>(select 1 from `test`.`t1` where (`test`.`t1`.`a` > 3) group by `test`.`t1`.`a` having (1 = <ref_null_helper>(1))))) +Note 1003 select 1 AS `1` from `test`.`t1` where <in_optimizer>(1,<exists>(select 1 from `test`.`t1` where (`test`.`t1`.`a` > 3) group by `test`.`t1`.`a` having (1 = <ref_null_helper>(1)))) DROP TABLE t1; # # Bug#45061: Incorrectly market field caused wrong result. @@ -5510,6 +5644,167 @@ SELECT 1 as foo FROM t1 WHERE a < SOME ); foo DROP TABLE t1; +CREATE TABLE t1 (a int(11), b varchar(1)); +INSERT INTO t1 VALUES (2,NULL),(5,'d'),(7,'g'); +SELECT a FROM t1 WHERE b < ANY ( SELECT b FROM t1 GROUP BY b ); +a +5 +SELECT a FROM t1 WHERE b < ANY ( SELECT b FROM t1 ); +a +5 +SELECT a FROM t1 WHERE b > ANY ( SELECT b FROM t1 GROUP BY b ); +a +7 +SELECT a FROM t1 WHERE b > ANY ( SELECT b FROM t1 ); +a +7 +SELECT a FROM t1 WHERE b <= ANY ( SELECT b FROM t1 GROUP BY b ); +a +5 +7 +SELECT a FROM t1 WHERE b <= ANY ( SELECT b FROM t1 ); +a +5 +7 +SELECT a FROM t1 WHERE b >= ANY ( SELECT b FROM t1 GROUP BY b ); +a +5 +7 +SELECT a FROM t1 WHERE b >= ANY ( SELECT b FROM t1 ); +a +5 +7 +SELECT a FROM t1 WHERE b = ANY ( SELECT b FROM t1 ); +a +5 +7 +SELECT a FROM t1 WHERE b = ANY ( SELECT b FROM t1 GROUP BY b ); +a +5 +7 +SELECT a FROM t1 WHERE b <> ANY ( SELECT b FROM t1 ); +a +5 +7 +SELECT a FROM t1 WHERE b <> ANY ( SELECT b FROM t1 GROUP BY b ); +a +5 +7 +SELECT a FROM t1 WHERE b < ALL ( SELECT b FROM t1 GROUP BY b ); +a +SELECT a FROM t1 WHERE b < ALL ( SELECT b FROM t1 ); +a +SELECT a FROM t1 WHERE b > ALL ( SELECT b FROM t1 GROUP BY b ); +a +SELECT a FROM t1 WHERE b > ALL ( SELECT b FROM t1 ); +a +SELECT a FROM t1 WHERE b <= ALL ( SELECT b FROM t1 GROUP BY b ); +a +SELECT a FROM t1 WHERE b <= ALL ( SELECT b FROM t1 ); +a +SELECT a FROM t1 WHERE b >= ALL ( SELECT b FROM t1 GROUP BY b ); +a +SELECT a FROM t1 WHERE b >= ALL ( SELECT b FROM t1 ); +a +SELECT a FROM t1 WHERE b = ALL ( SELECT b FROM t1 ); +a +SELECT a FROM t1 WHERE b = ALL ( SELECT b FROM t1 GROUP BY b ); +a +SELECT a FROM t1 WHERE b <> ALL ( SELECT b FROM t1 ); +a +SELECT a FROM t1 WHERE b <> ALL ( SELECT b FROM t1 GROUP BY b ); +a +delete from t1; +INSERT INTO t1 VALUES (2,NULL),(5,'d'),(7,'g'); +SELECT a FROM t1 WHERE b < ANY ( SELECT b FROM t1 GROUP BY b ); +a +5 +SELECT a FROM t1 WHERE b < ANY ( SELECT b FROM t1 ); +a +5 +SELECT a FROM t1 WHERE b > ANY ( SELECT b FROM t1 GROUP BY b ); +a +7 +SELECT a FROM t1 WHERE b > ANY ( SELECT b FROM t1 ); +a +7 +SELECT a FROM t1 WHERE b <= ANY ( SELECT b FROM t1 GROUP BY b ); +a +5 +7 +SELECT a FROM t1 WHERE b <= ANY ( SELECT b FROM t1 ); +a +5 +7 +SELECT a FROM t1 WHERE b >= ANY ( SELECT b FROM t1 GROUP BY b ); +a +5 +7 +SELECT a FROM t1 WHERE b >= ANY ( SELECT b FROM t1 ); +a +5 +7 +SELECT a FROM t1 WHERE b = ANY ( SELECT b FROM t1 ); +a +5 +7 +SELECT a FROM t1 WHERE b = ANY ( SELECT b FROM t1 GROUP BY b ); +a +5 +7 +SELECT a FROM t1 WHERE b <> ANY ( SELECT b FROM t1 ); +a +5 +7 +SELECT a FROM t1 WHERE b <> ANY ( SELECT b FROM t1 GROUP BY b ); +a +5 +7 +SELECT a FROM t1 WHERE b < ALL ( SELECT b FROM t1 GROUP BY b ); +a +SELECT a FROM t1 WHERE b < ALL ( SELECT b FROM t1 ); +a +SELECT a FROM t1 WHERE b > ALL ( SELECT b FROM t1 GROUP BY b ); +a +SELECT a FROM t1 WHERE b > ALL ( SELECT b FROM t1 ); +a +SELECT a FROM t1 WHERE b <= ALL ( SELECT b FROM t1 GROUP BY b ); +a +SELECT a FROM t1 WHERE b <= ALL ( SELECT b FROM t1 ); +a +SELECT a FROM t1 WHERE b >= ALL ( SELECT b FROM t1 GROUP BY b ); +a +SELECT a FROM t1 WHERE b >= ALL ( SELECT b FROM t1 ); +a +SELECT a FROM t1 WHERE b = ALL ( SELECT b FROM t1 ); +a +SELECT a FROM t1 WHERE b = ALL ( SELECT b FROM t1 GROUP BY b ); +a +SELECT a FROM t1 WHERE b <> ALL ( SELECT b FROM t1 ); +a +SELECT a FROM t1 WHERE b <> ALL ( SELECT b FROM t1 GROUP BY b ); +a +drop table t1; +# +# Fix of lp:780386 (NULL left part with empty ALL subquery). +# +CREATE TABLE t1 ( f11 int) ; +INSERT IGNORE INTO t1 VALUES (0),(0); +CREATE TABLE t2 ( f3 int, f10 int, KEY (f10,f3)) ; +INSERT IGNORE INTO t2 VALUES (NULL,NULL),(5,0); +DROP TABLE IF EXISTS t3; +Warnings: +Note 1051 Unknown table 't3' +CREATE TABLE t3 ( f3 int) ; +INSERT INTO t3 VALUES (0),(0); +SELECT a1.f3 AS r FROM t2 AS a1 , t1 WHERE a1.f3 < ALL ( SELECT f3 FROM t3 WHERE f3 = 1 ) ; +r +NULL +5 +NULL +5 +DROP TABLE t1, t2, t3; +End of 5.2 tests # # BUG#779885: Crash in eliminate_item_equal with materialization=on in # maria-5.3 @@ -5532,24 +5827,30 @@ ON t2.f10 = t3.f10 f1 DROP TABLE t1,t2,t3; # -# Fix of LP BUG#780386 (NULL left part with empty ALL subquery). +# BUG lp:813473: Wrong result with outer join + NOT IN subquery +# This bug is a duplicate of Bug#11764086 whose test case is added below # -CREATE TABLE t1 ( f11 int) ; -INSERT IGNORE INTO t1 VALUES (0),(0); -CREATE TABLE t2 ( f3 int, f10 int, KEY (f10,f3)) ; -INSERT IGNORE INTO t2 VALUES (NULL,NULL),(5,0); -DROP TABLE IF EXISTS t3; -Warnings: -Note 1051 Unknown table 't3' -CREATE TABLE t3 ( f3 int) ; -INSERT INTO t3 VALUES (0),(0); -SELECT a1.f3 AS r FROM t2 AS a1 , t1 WHERE a1.f3 < ALL ( SELECT f3 FROM t3 WHERE f3 = 1 ) ; -r -NULL -5 -NULL -5 -DROP TABLE t1, t2, t3; +CREATE TABLE t1 (c int) ; +INSERT INTO t1 VALUES (5),(6); +CREATE TABLE t2 (a int, b int) ; +INSERT INTO t2 VALUES (20,9),(20,9); +create table t3 (d int, e int); +insert into t3 values (2, 9), (3,10); +EXPLAIN +SELECT t2.b , t1.c +FROM t2 LEFT JOIN t1 ON t1.c < 3 +WHERE (t2.b , t1.c) NOT IN (SELECT * from t3); +id select_type table type possible_keys key key_len ref rows Extra +1 PRIMARY t2 ALL NULL NULL NULL NULL 2 +1 PRIMARY t1 ALL NULL NULL NULL NULL 2 Using where +2 DEPENDENT SUBQUERY t3 ALL NULL NULL NULL NULL 2 Using where +SELECT t2.b , t1.c +FROM t2 LEFT JOIN t1 ON t1.c < 3 +WHERE (t2.b, t1.c) NOT IN (SELECT * from t3); +b c +9 NULL +9 NULL +drop table t1, t2, t3; End of 5.3 tests End of 5.5 tests. # @@ -5668,8 +5969,59 @@ id select_type table type possible_keys key key_len ref rows Extra 1 PRIMARY table2 index NULL f1_key 4 NULL 10 Using where; Using index; Using join buffer (flat, BNL join) 2 DEPENDENT SUBQUERY t2 range f1_key f1_key 4 NULL 6 Range checked for each record (index map: 0x1); Using temporary DROP TABLE t1,t2; +# +# lp:826279: assertion failure with GROUP BY a result of subquery +# +CREATE TABLE t1 (a int); +INSERT INTO t1 VALUES (0), (0); +CREATE TABLE t2 (a int, b int, c int); +INSERT INTO t2 VALUES (10,7,0), (0,7,0); +CREATE TABLE t3 (a int, b int); +INSERT INTO t3 VALUES (10,7), (0,7); +SELECT SUM(DISTINCT b), +(SELECT t2.a FROM t1 JOIN t2 ON t2.c != 0 +WHERE t.a != 0 AND t2.a != 0) +FROM (SELECT * FROM t3) AS t +GROUP BY 2; +SUM(DISTINCT b) (SELECT t2.a FROM t1 JOIN t2 ON t2.c != 0 +WHERE t.a != 0 AND t2.a != 0) +7 NULL +SELECT SUM(DISTINCT b), +(SELECT t2.a FROM t1,t2 WHERE t.a != 0 or 1=2 LIMIT 1) +FROM (SELECT * FROM t3) AS t +GROUP BY 2; +SUM(DISTINCT b) (SELECT t2.a FROM t1,t2 WHERE t.a != 0 or 1=2 LIMIT 1) +7 NULL +7 10 +DROP TABLE t1,t2,t3; +# +# Bug#12329653 +# EXPLAIN, UNION, PREPARED STATEMENT, CRASH, SQL_FULL_GROUP_BY +# +CREATE TABLE t1(a1 int); +INSERT INTO t1 VALUES (1),(2); +SELECT @@session.sql_mode INTO @old_sql_mode; +SET SESSION sql_mode='ONLY_FULL_GROUP_BY'; +SELECT 1 FROM t1 WHERE 1 < SOME (SELECT a1 FROM t1); +1 +1 +1 +PREPARE stmt FROM +'SELECT 1 UNION ALL +SELECT 1 FROM t1 +ORDER BY +(SELECT 1 FROM t1 AS t1_0 + WHERE 1 < SOME (SELECT a1 FROM t1) +)' ; +EXECUTE stmt ; +ERROR 21000: Subquery returns more than 1 row +EXECUTE stmt ; +ERROR 21000: Subquery returns more than 1 row +SET SESSION sql_mode=@old_sql_mode; +DEALLOCATE PREPARE stmt; +DROP TABLE t1; set optimizer_switch=@subselect_tmp; set optimizer_switch=default; select @@optimizer_switch like '%subquery_cache=on%'; @@optimizer_switch like '%subquery_cache=on%' -0 +1 diff --git a/mysql-test/r/subselect_no_semijoin.result b/mysql-test/r/subselect_no_semijoin.result index e1caa60bfc0..5130442b56d 100644 --- a/mysql-test/r/subselect_no_semijoin.result +++ b/mysql-test/r/subselect_no_semijoin.result @@ -3,7 +3,7 @@ drop table if exists t1,t2,t3,t4,t5,t6,t7,t8,t11,t12; drop view if exists v2; set @subselect_tmp=@@optimizer_switch; set @@optimizer_switch=ifnull(@optimizer_switch_for_subselect_test, -"semijoin=on,firstmatch=on,loosescan=on,partial_match_rowid_merge=off,partial_match_table_scan=off"); +"semijoin=on,firstmatch=on,loosescan=on,semijoin_with_cache=on,partial_match_rowid_merge=off,partial_match_table_scan=off"); set optimizer_switch='mrr=on,mrr_sort_keys=on,index_condition_pushdown=on'; select (select 2); (select 2) @@ -56,7 +56,7 @@ id select_type table type possible_keys key key_len ref rows filtered Extra Warnings: Note 1276 Field or reference 'b.a' of SELECT #3 was resolved in SELECT #1 Note 1276 Field or reference 'b.a' of SELECT #3 was resolved in SELECT #1 -Note 1003 select 1 AS `1` from dual having ((select 1) = 1) +Note 1003 select 1 AS `1` from dual having (<expr_cache><1>((select 1)) = 1) SELECT 1 FROM (SELECT 1 as a) as b HAVING (SELECT a)=1; 1 1 @@ -230,7 +230,7 @@ id select_type table type possible_keys key key_len ref rows filtered Extra 3 DEPENDENT SUBQUERY t3 ALL NULL NULL NULL NULL 3 100.00 Using where Warnings: Note 1276 Field or reference 'test.t4.a' of SELECT #3 was resolved in SELECT #1 -Note 1003 select `test`.`t4`.`b` AS `b`,(select avg((`test`.`t2`.`a` + (select min(`test`.`t3`.`a`) from `test`.`t3` where (`test`.`t3`.`a` >= `test`.`t4`.`a`)))) from `test`.`t2`) AS `(select avg(t2.a+(select min(t3.a) from t3 where t3.a >= t4.a)) from t2)` from `test`.`t4` +Note 1003 select `test`.`t4`.`b` AS `b`,<expr_cache><`test`.`t4`.`a`>((select avg((`test`.`t2`.`a` + (select min(`test`.`t3`.`a`) from `test`.`t3` where (`test`.`t3`.`a` >= `test`.`t4`.`a`)))) from `test`.`t2`)) AS `(select avg(t2.a+(select min(t3.a) from t3 where t3.a >= t4.a)) from t2)` from `test`.`t4` select * from t3 where exists (select * from t2 where t2.b=t3.a); a 7 @@ -276,7 +276,7 @@ id select_type table type possible_keys key key_len ref rows filtered Extra 1 PRIMARY t3 ALL NULL NULL NULL NULL 3 100.00 Using where 2 SUBQUERY t2 ALL NULL NULL NULL NULL 3 100.00 Warnings: -Note 1003 select `test`.`t3`.`a` AS `a` from `test`.`t3` where <nop>(<in_optimizer>(`test`.`t3`.`a`,((select min(`test`.`t2`.`b`) from `test`.`t2`) <= `test`.`t3`.`a`))) +Note 1003 select `test`.`t3`.`a` AS `a` from `test`.`t3` where <nop>(<in_optimizer>(`test`.`t3`.`a`,((select min(`test`.`t2`.`b`) from `test`.`t2`) <= <cache>(`test`.`t3`.`a`)))) select * from t3 where a >= all (select b from t2); a 7 @@ -320,7 +320,7 @@ NULL UNION RESULT <union2,3> ALL NULL NULL NULL NULL NULL NULL Warnings: Note 1276 Field or reference 'test.t2.a' of SELECT #2 was resolved in SELECT #1 Note 1276 Field or reference 'test.t2.a' of SELECT #3 was resolved in SELECT #1 -Note 1003 select (select 2 from dual where (2 = `test`.`t2`.`a`) union select `test`.`t5`.`a` from `test`.`t5` where (`test`.`t5`.`a` = `test`.`t2`.`a`)) AS `(select a from t1 where t1.a=t2.a union select a from t5 where t5.a=t2.a)`,`test`.`t2`.`a` AS `a` from `test`.`t2` +Note 1003 select <expr_cache><`test`.`t2`.`a`>((select 2 from dual where (2 = `test`.`t2`.`a`) union select `test`.`t5`.`a` from `test`.`t5` where (`test`.`t5`.`a` = `test`.`t2`.`a`))) AS `(select a from t1 where t1.a=t2.a union select a from t5 where t5.a=t2.a)`,`test`.`t2`.`a` AS `a` from `test`.`t2` select (select a from t1 where t1.a=t2.a union all select a from t5 where t5.a=t2.a), a from t2; ERROR 21000: Subquery returns more than 1 row create table t6 (patient_uq int, clinic_uq int, index i1 (clinic_uq)); @@ -338,7 +338,7 @@ id select_type table type possible_keys key key_len ref rows filtered Extra 2 DEPENDENT SUBQUERY t7 eq_ref PRIMARY PRIMARY 4 test.t6.clinic_uq 1 100.00 Using index Warnings: Note 1276 Field or reference 'test.t6.clinic_uq' of SELECT #2 was resolved in SELECT #1 -Note 1003 select `test`.`t6`.`patient_uq` AS `patient_uq`,`test`.`t6`.`clinic_uq` AS `clinic_uq` from `test`.`t6` where exists(select 1 from `test`.`t7` where (`test`.`t7`.`uq` = `test`.`t6`.`clinic_uq`)) +Note 1003 select `test`.`t6`.`patient_uq` AS `patient_uq`,`test`.`t6`.`clinic_uq` AS `clinic_uq` from `test`.`t6` where <expr_cache><`test`.`t6`.`clinic_uq`>(exists(select 1 from `test`.`t7` where (`test`.`t7`.`uq` = `test`.`t6`.`clinic_uq`))) select * from t1 where a= (select a from t2,t4 where t2.b=t4.b); ERROR 23000: Column 'a' in field list is ambiguous drop table t1,t2,t3; @@ -368,12 +368,12 @@ INSERT INTO t8 (pseudo,email) VALUES ('joce1','test1'); INSERT INTO t8 (pseudo,email) VALUES ('2joce1','2test1'); EXPLAIN EXTENDED SELECT pseudo,(SELECT email FROM t8 WHERE pseudo=(SELECT pseudo FROM t8 WHERE pseudo='joce')) FROM t8 WHERE pseudo=(SELECT pseudo FROM t8 WHERE pseudo='joce'); id select_type table type possible_keys key key_len ref rows filtered Extra -1 PRIMARY t8 const PRIMARY PRIMARY 37 const 1 100.00 Using index +1 PRIMARY t8 const PRIMARY PRIMARY 37 const 1 100.00 Using where; Using index 4 SUBQUERY t8 const PRIMARY PRIMARY 37 const 1 100.00 Using index -2 SUBQUERY t8 const PRIMARY PRIMARY 37 const 1 100.00 +2 SUBQUERY t8 const PRIMARY PRIMARY 37 const 1 100.00 Using where 3 SUBQUERY t8 const PRIMARY PRIMARY 37 const 1 100.00 Using index Warnings: -Note 1003 select 'joce' AS `pseudo`,(select 'test' from `test`.`t8` where ('joce' = (select 'joce' from `test`.`t8` where 1))) AS `(SELECT email FROM t8 WHERE pseudo=(SELECT pseudo FROM t8 WHERE pseudo='joce'))` from `test`.`t8` where ('joce' = (select 'joce' from `test`.`t8` where 1)) +Note 1003 select `test`.`t8`.`pseudo` AS `pseudo`,(select `test`.`t8`.`email` from `test`.`t8` where (`test`.`t8`.`pseudo` = (select 'joce' from `test`.`t8` where 1))) AS `(SELECT email FROM t8 WHERE pseudo=(SELECT pseudo FROM t8 WHERE pseudo='joce'))` from `test`.`t8` where (`test`.`t8`.`pseudo` = (select 'joce' from `test`.`t8` where 1)) SELECT pseudo FROM t8 WHERE pseudo=(SELECT pseudo,email FROM t8 WHERE pseudo='joce'); ERROR 21000: Operand should contain 1 column(s) @@ -544,18 +544,24 @@ SELECT numreponse, (SELECT numeropost FROM t1 HAVING numreponse=1) FROM (SELECT numreponse (SELECT numeropost FROM t1 HAVING numreponse=1) INSERT INTO t1 (numeropost,numreponse,pseudo) VALUES (1,1,'joce'),(1,2,'joce'),(1,3,'test'); EXPLAIN EXTENDED SELECT numreponse FROM t1 WHERE numeropost='1' AND numreponse=(SELECT 1 FROM t1 WHERE numeropost='1'); +id select_type table type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t1 const PRIMARY,numreponse PRIMARY 7 const,const 1 100.00 Using where; Using index +2 SUBQUERY t1 ref PRIMARY PRIMARY 3 const 2 100.00 Using index +Warnings: +Note 1003 select `test`.`t1`.`numreponse` AS `numreponse` from `test`.`t1` where ((`test`.`t1`.`numeropost` = '1') and (`test`.`t1`.`numreponse` = (select 1 from `test`.`t1` where (`test`.`t1`.`numeropost` = '1')))) +SELECT numreponse FROM t1 WHERE numeropost='1' AND numreponse=(SELECT 1 FROM t1 WHERE numeropost='1'); ERROR 21000: Subquery returns more than 1 row EXPLAIN EXTENDED SELECT MAX(numreponse) FROM t1 WHERE numeropost='1'; id select_type table type possible_keys key key_len ref rows filtered Extra 1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL Select tables optimized away Warnings: -Note 1003 select max(`test`.`t1`.`numreponse`) AS `MAX(numreponse)` from `test`.`t1` where multiple equal(1, `test`.`t1`.`numeropost`) +Note 1003 select max(`test`.`t1`.`numreponse`) AS `MAX(numreponse)` from `test`.`t1` where (`test`.`t1`.`numeropost` = '1') EXPLAIN EXTENDED SELECT numreponse FROM t1 WHERE numeropost='1' AND numreponse=(SELECT MAX(numreponse) FROM t1 WHERE numeropost='1'); id select_type table type possible_keys key key_len ref rows filtered Extra -1 PRIMARY t1 const PRIMARY,numreponse PRIMARY 7 const,const 1 100.00 Using index +1 PRIMARY t1 const PRIMARY,numreponse PRIMARY 7 const,const 1 100.00 Using where; Using index 2 SUBQUERY NULL NULL NULL NULL NULL NULL NULL NULL Select tables optimized away Warnings: -Note 1003 select 3 AS `numreponse` from `test`.`t1` where ((3 = (select max(`test`.`t1`.`numreponse`) from `test`.`t1` where multiple equal(1, `test`.`t1`.`numeropost`)))) +Note 1003 select `test`.`t1`.`numreponse` AS `numreponse` from `test`.`t1` where ((`test`.`t1`.`numeropost` = '1') and (`test`.`t1`.`numreponse` = (select max(`test`.`t1`.`numreponse`) from `test`.`t1` where (`test`.`t1`.`numeropost` = '1')))) drop table t1; CREATE TABLE t1 (a int(1)); INSERT INTO t1 VALUES (1); @@ -752,7 +758,7 @@ id select_type table type possible_keys key key_len ref rows filtered Extra 3 DEPENDENT UNION NULL NULL NULL NULL NULL NULL NULL NULL No tables used NULL UNION RESULT <union2,3> ALL NULL NULL NULL NULL NULL NULL Warnings: -Note 1003 select `test`.`t2`.`id` AS `id` from `test`.`t2` where <in_optimizer>(`test`.`t2`.`id`,<exists>(select 1 having (<cache>(`test`.`t2`.`id`) = <ref_null_helper>(1)) union select 3 having (<cache>(`test`.`t2`.`id`) = <ref_null_helper>(3)))) +Note 1003 select `test`.`t2`.`id` AS `id` from `test`.`t2` where <expr_cache><`test`.`t2`.`id`>(<in_optimizer>(`test`.`t2`.`id`,<exists>(select 1 having (<cache>(`test`.`t2`.`id`) = <ref_null_helper>(1)) union select 3 having (<cache>(`test`.`t2`.`id`) = <ref_null_helper>(3))))) SELECT * FROM t2 WHERE id IN (SELECT 5 UNION SELECT 3); id SELECT * FROM t2 WHERE id IN (SELECT 5 UNION SELECT 2); @@ -900,7 +906,7 @@ id select_type table type possible_keys key key_len ref rows filtered Extra 1 PRIMARY t1 index NULL PRIMARY 4 NULL 4 100.00 Using index 2 DEPENDENT SUBQUERY t2 index_subquery a a 5 func 2 100.00 Using index Warnings: -Note 1003 select `test`.`t1`.`a` AS `a`,<in_optimizer>(`test`.`t1`.`a`,<exists>(<index_lookup>(<cache>(`test`.`t1`.`a`) in t2 on a checking NULL having <is_not_null_test>(`test`.`t2`.`a`)))) AS `t1.a in (select t2.a from t2)` from `test`.`t1` +Note 1003 select `test`.`t1`.`a` AS `a`,<expr_cache><`test`.`t1`.`a`>(<in_optimizer>(`test`.`t1`.`a`,<exists>(<index_lookup>(<cache>(`test`.`t1`.`a`) in t2 on a checking NULL having <is_not_null_test>(`test`.`t2`.`a`))))) AS `t1.a in (select t2.a from t2)` from `test`.`t1` CREATE TABLE t3 (a int(11) default '0'); INSERT INTO t3 VALUES (1),(2),(3); SELECT t1.a, t1.a in (select t2.a from t2,t3 where t3.a=t2.a) FROM t1; @@ -915,8 +921,133 @@ id select_type table type possible_keys key key_len ref rows filtered Extra 2 DEPENDENT SUBQUERY t2 ref_or_null a a 5 func 2 100.00 Using where; Using index 2 DEPENDENT SUBQUERY t3 ALL NULL NULL NULL NULL 3 100.00 Using where; Using join buffer (flat, BNL join) Warnings: -Note 1003 select `test`.`t1`.`a` AS `a`,<in_optimizer>(`test`.`t1`.`a`,<exists>(select `test`.`t2`.`a` from `test`.`t2` join `test`.`t3` where ((`test`.`t3`.`a` = `test`.`t2`.`a`) and ((<cache>(`test`.`t1`.`a`) = `test`.`t2`.`a`) or isnull(`test`.`t2`.`a`))) having <is_not_null_test>(`test`.`t2`.`a`))) AS `t1.a in (select t2.a from t2,t3 where t3.a=t2.a)` from `test`.`t1` +Note 1003 select `test`.`t1`.`a` AS `a`,<expr_cache><`test`.`t1`.`a`>(<in_optimizer>(`test`.`t1`.`a`,<exists>(select `test`.`t2`.`a` from `test`.`t2` join `test`.`t3` where ((`test`.`t3`.`a` = `test`.`t2`.`a`) and ((<cache>(`test`.`t1`.`a`) = `test`.`t2`.`a`) or isnull(`test`.`t2`.`a`))) having <is_not_null_test>(`test`.`t2`.`a`)))) AS `t1.a in (select t2.a from t2,t3 where t3.a=t2.a)` from `test`.`t1` drop table t1,t2,t3; +# check correct NULL Processing for normal IN/ALL/ANY +# and 2 ways of max/min optimization +create table t1 (a int); +insert into t1 values (1), (100), (NULL), (1000); +create table t2 (a int not null); +# subselect returns empty set (for NULL and non-NULL left part) +select a, a in (select * from t2) from t1; +a a in (select * from t2) +1 0 +100 0 +NULL 0 +1000 0 +select a, a > any (select * from t2) from t1; +a a > any (select * from t2) +1 0 +100 0 +NULL 0 +1000 0 +select a, a > all (select * from t2) from t1; +a a > all (select * from t2) +1 1 +100 1 +NULL 1 +1000 1 +select a from t1 where a in (select * from t2); +a +select a from t1 where a > any (select * from t2); +a +select a from t1 where a > all (select * from t2); +a +1 +100 +NULL +1000 +select a from t1 where a in (select * from t2 group by a); +a +select a from t1 where a > any (select * from t2 group by a); +a +select a from t1 where a > all (select * from t2 group by a); +a +1 +100 +NULL +1000 +insert into t2 values (1),(200); +# sebselect returns non-empty set without NULLs +select a, a in (select * from t2) from t1; +a a in (select * from t2) +1 1 +100 0 +NULL NULL +1000 0 +select a, a > any (select * from t2) from t1; +a a > any (select * from t2) +1 0 +100 1 +NULL NULL +1000 1 +select a, a > all (select * from t2) from t1; +a a > all (select * from t2) +1 0 +100 0 +NULL NULL +1000 1 +select a from t1 where a in (select * from t2); +a +1 +select a from t1 where a > any (select * from t2); +a +100 +1000 +select a from t1 where a > all (select * from t2); +a +1000 +select a from t1 where a in (select * from t2 group by a); +a +1 +select a from t1 where a > any (select * from t2 group by a); +a +100 +1000 +select a from t1 where a > all (select * from t2 group by a); +a +1000 +drop table t2; +create table t2 (a int); +insert into t2 values (1),(NULL),(200); +# sebselect returns non-empty set with NULLs +select a, a in (select * from t2) from t1; +a a in (select * from t2) +1 1 +100 NULL +NULL NULL +1000 NULL +select a, a > any (select * from t2) from t1; +a a > any (select * from t2) +1 NULL +100 1 +NULL NULL +1000 1 +select a, a > all (select * from t2) from t1; +a a > all (select * from t2) +1 0 +100 0 +NULL NULL +1000 NULL +select a from t1 where a in (select * from t2); +a +1 +select a from t1 where a > any (select * from t2); +a +100 +1000 +select a from t1 where a > all (select * from t2); +a +select a from t1 where a in (select * from t2 group by a); +a +1 +select a from t1 where a > any (select * from t2 group by a); +a +100 +1000 +select a from t1 where a > all (select * from t2 group by a); +a +drop table t1, t2; create table t1 (a float); select 10.5 IN (SELECT * from t1 LIMIT 1); ERROR 42000: This version of MySQL doesn't yet support 'LIMIT & IN/ALL/ANY/SOME subquery' @@ -1305,7 +1436,7 @@ id select_type table type possible_keys key key_len ref rows filtered Extra 1 PRIMARY t2 index NULL PRIMARY 4 NULL 4 100.00 Using where; Using index 2 DEPENDENT SUBQUERY t1 unique_subquery PRIMARY PRIMARY 4 func 1 100.00 Using index Warnings: -Note 1003 select `test`.`t2`.`a` AS `a` from `test`.`t2` where <in_optimizer>(`test`.`t2`.`a`,<exists>(<primary_index_lookup>(<cache>(`test`.`t2`.`a`) in t1 on PRIMARY))) +Note 1003 select `test`.`t2`.`a` AS `a` from `test`.`t2` where <expr_cache><`test`.`t2`.`a`>(<in_optimizer>(`test`.`t2`.`a`,<exists>(<primary_index_lookup>(<cache>(`test`.`t2`.`a`) in t1 on PRIMARY)))) select * from t2 where t2.a in (select a from t1 where t1.b <> 30); a 2 @@ -1315,7 +1446,7 @@ id select_type table type possible_keys key key_len ref rows filtered Extra 1 PRIMARY t2 index NULL PRIMARY 4 NULL 4 100.00 Using where; Using index 2 DEPENDENT SUBQUERY t1 unique_subquery PRIMARY PRIMARY 4 func 1 100.00 Using where Warnings: -Note 1003 select `test`.`t2`.`a` AS `a` from `test`.`t2` where <in_optimizer>(`test`.`t2`.`a`,<exists>(<primary_index_lookup>(<cache>(`test`.`t2`.`a`) in t1 on PRIMARY where ((`test`.`t1`.`b` <> 30) and (<cache>(`test`.`t2`.`a`) = `test`.`t1`.`a`))))) +Note 1003 select `test`.`t2`.`a` AS `a` from `test`.`t2` where <expr_cache><`test`.`t2`.`a`>(<in_optimizer>(`test`.`t2`.`a`,<exists>(<primary_index_lookup>(<cache>(`test`.`t2`.`a`) in t1 on PRIMARY where ((`test`.`t1`.`b` <> 30) and (<cache>(`test`.`t2`.`a`) = `test`.`t1`.`a`)))))) select * from t2 where t2.a in (select t1.a from t1,t3 where t1.b=t3.a); a 2 @@ -1326,7 +1457,7 @@ id select_type table type possible_keys key key_len ref rows filtered Extra 2 DEPENDENT SUBQUERY t1 eq_ref PRIMARY PRIMARY 4 func 1 100.00 Using where 2 DEPENDENT SUBQUERY t3 eq_ref PRIMARY PRIMARY 4 test.t1.b 1 100.00 Using index Warnings: -Note 1003 select `test`.`t2`.`a` AS `a` from `test`.`t2` where <in_optimizer>(`test`.`t2`.`a`,<exists>(select `test`.`t1`.`a` from `test`.`t1` join `test`.`t3` where ((`test`.`t3`.`a` = `test`.`t1`.`b`) and (<cache>(`test`.`t2`.`a`) = `test`.`t1`.`a`)))) +Note 1003 select `test`.`t2`.`a` AS `a` from `test`.`t2` where <expr_cache><`test`.`t2`.`a`>(<in_optimizer>(`test`.`t2`.`a`,<exists>(select `test`.`t1`.`a` from `test`.`t1` join `test`.`t3` where ((`test`.`t3`.`a` = `test`.`t1`.`b`) and (<cache>(`test`.`t2`.`a`) = `test`.`t1`.`a`))))) drop table t1, t2, t3; create table t1 (a int, b int, index a (a,b)); create table t2 (a int, index a (a)); @@ -1348,7 +1479,7 @@ id select_type table type possible_keys key key_len ref rows filtered Extra 1 PRIMARY t2 index NULL a 5 NULL 4 100.00 Using where; Using index 2 DEPENDENT SUBQUERY t1 index_subquery a a 5 func 1001 100.00 Using index Warnings: -Note 1003 select `test`.`t2`.`a` AS `a` from `test`.`t2` where <in_optimizer>(`test`.`t2`.`a`,<exists>(<index_lookup>(<cache>(`test`.`t2`.`a`) in t1 on a))) +Note 1003 select `test`.`t2`.`a` AS `a` from `test`.`t2` where <expr_cache><`test`.`t2`.`a`>(<in_optimizer>(`test`.`t2`.`a`,<exists>(<index_lookup>(<cache>(`test`.`t2`.`a`) in t1 on a)))) select * from t2 where t2.a in (select a from t1 where t1.b <> 30); a 2 @@ -1358,7 +1489,7 @@ id select_type table type possible_keys key key_len ref rows filtered Extra 1 PRIMARY t2 index NULL a 5 NULL 4 100.00 Using where; Using index 2 DEPENDENT SUBQUERY t1 index_subquery a a 5 func 1001 100.00 Using index; Using where Warnings: -Note 1003 select `test`.`t2`.`a` AS `a` from `test`.`t2` where <in_optimizer>(`test`.`t2`.`a`,<exists>(<index_lookup>(<cache>(`test`.`t2`.`a`) in t1 on a where ((`test`.`t1`.`b` <> 30) and (<cache>(`test`.`t2`.`a`) = `test`.`t1`.`a`))))) +Note 1003 select `test`.`t2`.`a` AS `a` from `test`.`t2` where <expr_cache><`test`.`t2`.`a`>(<in_optimizer>(`test`.`t2`.`a`,<exists>(<index_lookup>(<cache>(`test`.`t2`.`a`) in t1 on a where ((`test`.`t1`.`b` <> 30) and (<cache>(`test`.`t2`.`a`) = `test`.`t1`.`a`)))))) select * from t2 where t2.a in (select t1.a from t1,t3 where t1.b=t3.a); a 2 @@ -1369,7 +1500,7 @@ id select_type table type possible_keys key key_len ref rows filtered Extra 2 DEPENDENT SUBQUERY t1 ref a a 5 func 1001 100.00 Using index 2 DEPENDENT SUBQUERY t3 index a a 5 NULL 3 100.00 Using where; Using index; Using join buffer (flat, BNL join) Warnings: -Note 1003 select `test`.`t2`.`a` AS `a` from `test`.`t2` where <in_optimizer>(`test`.`t2`.`a`,<exists>(select `test`.`t1`.`a` from `test`.`t1` join `test`.`t3` where ((`test`.`t3`.`a` = `test`.`t1`.`b`) and (<cache>(`test`.`t2`.`a`) = `test`.`t1`.`a`)))) +Note 1003 select `test`.`t2`.`a` AS `a` from `test`.`t2` where <expr_cache><`test`.`t2`.`a`>(<in_optimizer>(`test`.`t2`.`a`,<exists>(select `test`.`t1`.`a` from `test`.`t1` join `test`.`t3` where ((`test`.`t3`.`a` = `test`.`t1`.`b`) and (<cache>(`test`.`t2`.`a`) = `test`.`t1`.`a`))))) insert into t1 values (3,31); select * from t2 where t2.a in (select a from t1 where t1.b <> 30); a @@ -1385,7 +1516,7 @@ id select_type table type possible_keys key key_len ref rows filtered Extra 1 PRIMARY t2 index NULL a 5 NULL 4 100.00 Using where; Using index 2 DEPENDENT SUBQUERY t1 index_subquery a a 5 func 1001 100.00 Using index; Using where Warnings: -Note 1003 select `test`.`t2`.`a` AS `a` from `test`.`t2` where <in_optimizer>(`test`.`t2`.`a`,<exists>(<index_lookup>(<cache>(`test`.`t2`.`a`) in t1 on a where ((`test`.`t1`.`b` <> 30) and (<cache>(`test`.`t2`.`a`) = `test`.`t1`.`a`))))) +Note 1003 select `test`.`t2`.`a` AS `a` from `test`.`t2` where <expr_cache><`test`.`t2`.`a`>(<in_optimizer>(`test`.`t2`.`a`,<exists>(<index_lookup>(<cache>(`test`.`t2`.`a`) in t1 on a where ((`test`.`t1`.`b` <> 30) and (<cache>(`test`.`t2`.`a`) = `test`.`t1`.`a`)))))) drop table t0, t1, t2, t3; create table t1 (a int, b int); create table t2 (a int, b int); @@ -1476,27 +1607,27 @@ id select_type table type possible_keys key key_len ref rows filtered Extra 1 PRIMARY t1 index NULL s1 6 NULL 3 100.00 Using index 2 DEPENDENT SUBQUERY t2 index_subquery s1 s1 6 func 2 100.00 Using index; Full scan on NULL key Warnings: -Note 1003 select `test`.`t1`.`s1` AS `s1`,(not(<in_optimizer>(`test`.`t1`.`s1`,<exists>(<index_lookup>(<cache>(`test`.`t1`.`s1`) in t2 on s1 checking NULL having trigcond(<is_not_null_test>(`test`.`t2`.`s1`))))))) AS `s1 NOT IN (SELECT s1 FROM t2)` from `test`.`t1` +Note 1003 select `test`.`t1`.`s1` AS `s1`,(not(<expr_cache><`test`.`t1`.`s1`>(<in_optimizer>(`test`.`t1`.`s1`,<exists>(<index_lookup>(<cache>(`test`.`t1`.`s1`) in t2 on s1 checking NULL having trigcond(<is_not_null_test>(`test`.`t2`.`s1`)))))))) AS `s1 NOT IN (SELECT s1 FROM t2)` from `test`.`t1` explain extended select s1, s1 = ANY (SELECT s1 FROM t2) from t1; id select_type table type possible_keys key key_len ref rows filtered Extra 1 PRIMARY t1 index NULL s1 6 NULL 3 100.00 Using index 2 DEPENDENT SUBQUERY t2 index_subquery s1 s1 6 func 2 100.00 Using index; Full scan on NULL key Warnings: -Note 1003 select `test`.`t1`.`s1` AS `s1`,<in_optimizer>(`test`.`t1`.`s1`,<exists>(<index_lookup>(<cache>(`test`.`t1`.`s1`) in t2 on s1 checking NULL having trigcond(<is_not_null_test>(`test`.`t2`.`s1`))))) AS `s1 = ANY (SELECT s1 FROM t2)` from `test`.`t1` +Note 1003 select `test`.`t1`.`s1` AS `s1`,<expr_cache><`test`.`t1`.`s1`>(<in_optimizer>(`test`.`t1`.`s1`,<exists>(<index_lookup>(<cache>(`test`.`t1`.`s1`) in t2 on s1 checking NULL having trigcond(<is_not_null_test>(`test`.`t2`.`s1`)))))) AS `s1 = ANY (SELECT s1 FROM t2)` from `test`.`t1` explain extended select s1, s1 <> ALL (SELECT s1 FROM t2) from t1; id select_type table type possible_keys key key_len ref rows filtered Extra 1 PRIMARY t1 index NULL s1 6 NULL 3 100.00 Using index 2 DEPENDENT SUBQUERY t2 index_subquery s1 s1 6 func 2 100.00 Using index; Full scan on NULL key Warnings: -Note 1003 select `test`.`t1`.`s1` AS `s1`,(not(<in_optimizer>(`test`.`t1`.`s1`,<exists>(<index_lookup>(<cache>(`test`.`t1`.`s1`) in t2 on s1 checking NULL having trigcond(<is_not_null_test>(`test`.`t2`.`s1`))))))) AS `s1 <> ALL (SELECT s1 FROM t2)` from `test`.`t1` +Note 1003 select `test`.`t1`.`s1` AS `s1`,(not(<expr_cache><`test`.`t1`.`s1`>(<in_optimizer>(`test`.`t1`.`s1`,<exists>(<index_lookup>(<cache>(`test`.`t1`.`s1`) in t2 on s1 checking NULL having trigcond(<is_not_null_test>(`test`.`t2`.`s1`)))))))) AS `s1 <> ALL (SELECT s1 FROM t2)` from `test`.`t1` explain extended select s1, s1 NOT IN (SELECT s1 FROM t2 WHERE s1 < 'a2') from t1; id select_type table type possible_keys key key_len ref rows filtered Extra 1 PRIMARY t1 index NULL s1 6 NULL 3 100.00 Using index 2 DEPENDENT SUBQUERY t2 index_subquery s1 s1 6 func 2 100.00 Using index; Using where; Full scan on NULL key Warnings: -Note 1003 select `test`.`t1`.`s1` AS `s1`,(not(<in_optimizer>(`test`.`t1`.`s1`,<exists>(<index_lookup>(<cache>(`test`.`t1`.`s1`) in t2 on s1 checking NULL where (`test`.`t2`.`s1` < 'a2') having trigcond(<is_not_null_test>(`test`.`t2`.`s1`))))))) AS `s1 NOT IN (SELECT s1 FROM t2 WHERE s1 < 'a2')` from `test`.`t1` +Note 1003 select `test`.`t1`.`s1` AS `s1`,(not(<expr_cache><`test`.`t1`.`s1`>(<in_optimizer>(`test`.`t1`.`s1`,<exists>(<index_lookup>(<cache>(`test`.`t1`.`s1`) in t2 on s1 checking NULL where (`test`.`t2`.`s1` < 'a2') having trigcond(<is_not_null_test>(`test`.`t2`.`s1`)))))))) AS `s1 NOT IN (SELECT s1 FROM t2 WHERE s1 < 'a2')` from `test`.`t1` drop table t1,t2; -create table t2 (a int, b int); +create table t2 (a int, b int not null); create table t3 (a int); insert into t3 values (6),(7),(3); select * from t3 where a >= all (select b from t2); @@ -1509,7 +1640,7 @@ id select_type table type possible_keys key key_len ref rows filtered Extra 1 PRIMARY t3 ALL NULL NULL NULL NULL 3 100.00 Using where 2 SUBQUERY t2 system NULL NULL NULL NULL 0 0.00 const row not found Warnings: -Note 1003 select `test`.`t3`.`a` AS `a` from `test`.`t3` where <not>(<in_optimizer>(`test`.`t3`.`a`,((select max(NULL) from `test`.`t2`) > `test`.`t3`.`a`))) +Note 1003 select `test`.`t3`.`a` AS `a` from `test`.`t3` where <not>(<in_optimizer>(`test`.`t3`.`a`,((select max(NULL) from `test`.`t2`) > <cache>(`test`.`t3`.`a`)))) select * from t3 where a >= some (select b from t2); a explain extended select * from t3 where a >= some (select b from t2); @@ -1517,7 +1648,7 @@ id select_type table type possible_keys key key_len ref rows filtered Extra 1 PRIMARY t3 ALL NULL NULL NULL NULL 3 100.00 Using where 2 SUBQUERY t2 system NULL NULL NULL NULL 0 0.00 const row not found Warnings: -Note 1003 select `test`.`t3`.`a` AS `a` from `test`.`t3` where <nop>(<in_optimizer>(`test`.`t3`.`a`,((select min(NULL) from `test`.`t2`) <= `test`.`t3`.`a`))) +Note 1003 select `test`.`t3`.`a` AS `a` from `test`.`t3` where <nop>(<in_optimizer>(`test`.`t3`.`a`,((select min(NULL) from `test`.`t2`) <= <cache>(`test`.`t3`.`a`)))) select * from t3 where a >= all (select b from t2 group by 1); a 6 @@ -1528,7 +1659,7 @@ id select_type table type possible_keys key key_len ref rows filtered Extra 1 PRIMARY t3 ALL NULL NULL NULL NULL 3 100.00 Using where 2 SUBQUERY t2 system NULL NULL NULL NULL 0 0.00 const row not found Warnings: -Note 1003 select `test`.`t3`.`a` AS `a` from `test`.`t3` where <not>(<in_optimizer>(`test`.`t3`.`a`,(<max>(select NULL from `test`.`t2` group by 1) > `test`.`t3`.`a`))) +Note 1003 select `test`.`t3`.`a` AS `a` from `test`.`t3` where <not>(<in_optimizer>(`test`.`t3`.`a`,(<max>(select NULL from `test`.`t2` group by 1) > <cache>(`test`.`t3`.`a`)))) select * from t3 where a >= some (select b from t2 group by 1); a explain extended select * from t3 where a >= some (select b from t2 group by 1); @@ -1536,7 +1667,7 @@ id select_type table type possible_keys key key_len ref rows filtered Extra 1 PRIMARY t3 ALL NULL NULL NULL NULL 3 100.00 Using where 2 SUBQUERY t2 system NULL NULL NULL NULL 0 0.00 const row not found Warnings: -Note 1003 select `test`.`t3`.`a` AS `a` from `test`.`t3` where <nop>(<in_optimizer>(`test`.`t3`.`a`,(<min>(select NULL from `test`.`t2` group by 1) <= `test`.`t3`.`a`))) +Note 1003 select `test`.`t3`.`a` AS `a` from `test`.`t3` where <nop>(<in_optimizer>(`test`.`t3`.`a`,(<min>(select NULL from `test`.`t2` group by 1) <= <cache>(`test`.`t3`.`a`)))) select * from t3 where NULL >= any (select b from t2); a explain extended select * from t3 where NULL >= any (select b from t2); @@ -1579,7 +1710,7 @@ id select_type table type possible_keys key key_len ref rows filtered Extra 1 PRIMARY t3 ALL NULL NULL NULL NULL 3 100.00 Using where 2 SUBQUERY t2 ALL NULL NULL NULL NULL 4 100.00 Using temporary Warnings: -Note 1003 select `test`.`t3`.`a` AS `a` from `test`.`t3` where <not>(<in_optimizer>(`test`.`t3`.`a`,(<max>(select max(`test`.`t2`.`b`) from `test`.`t2` group by `test`.`t2`.`a`) >= `test`.`t3`.`a`))) +Note 1003 select `test`.`t3`.`a` AS `a` from `test`.`t3` where <not>(<in_optimizer>(`test`.`t3`.`a`,(<max>(select max(`test`.`t2`.`b`) from `test`.`t2` group by `test`.`t2`.`a`) >= <cache>(`test`.`t3`.`a`)))) drop table t2, t3; CREATE TABLE `t1` ( `id` mediumint(9) NOT NULL auto_increment, `taskid` bigint(20) NOT NULL default '0', `dbid` int(11) NOT NULL default '0', `create_date` datetime NOT NULL default '0000-00-00 00:00:00', `last_update` datetime NOT NULL default '0000-00-00 00:00:00', PRIMARY KEY (`id`)) ENGINE=MyISAM CHARSET=latin1 AUTO_INCREMENT=3 ; INSERT INTO `t1` (`id`, `taskid`, `dbid`, `create_date`,`last_update`) VALUES (1, 1, 15, '2003-09-29 10:31:36', '2003-09-29 10:31:36'), (2, 1, 21, now(), now()); @@ -1749,14 +1880,14 @@ id select_type table type possible_keys key key_len ref rows filtered Extra 1 PRIMARY t1 ALL NULL NULL NULL NULL 12 100.00 Using where 2 DEPENDENT SUBQUERY t1 unique_subquery PRIMARY PRIMARY 4 func 1 100.00 Using index; Using where Warnings: -Note 1003 select `test`.`t1`.`id` AS `id`,`test`.`t1`.`text` AS `text` from `test`.`t1` where (not(<in_optimizer>(`test`.`t1`.`id`,<exists>(<primary_index_lookup>(<cache>(`test`.`t1`.`id`) in t1 on PRIMARY where ((`test`.`t1`.`id` < 8) and (<cache>(`test`.`t1`.`id`) = `test`.`t1`.`id`))))))) +Note 1003 select `test`.`t1`.`id` AS `id`,`test`.`t1`.`text` AS `text` from `test`.`t1` where (not(<expr_cache><`test`.`t1`.`id`>(<in_optimizer>(`test`.`t1`.`id`,<exists>(<primary_index_lookup>(<cache>(`test`.`t1`.`id`) in t1 on PRIMARY where ((`test`.`t1`.`id` < 8) and (<cache>(`test`.`t1`.`id`) = `test`.`t1`.`id`)))))))) explain extended select * from t1 as tt where not exists (select id from t1 where id < 8 and (id = tt.id or id is null) having id is not null); id select_type table type possible_keys key key_len ref rows filtered Extra 1 PRIMARY tt ALL NULL NULL NULL NULL 12 100.00 Using where 2 DEPENDENT SUBQUERY t1 eq_ref PRIMARY PRIMARY 4 test.tt.id 1 100.00 Using where; Using index Warnings: Note 1276 Field or reference 'test.tt.id' of SELECT #2 was resolved in SELECT #1 -Note 1003 select `test`.`tt`.`id` AS `id`,`test`.`tt`.`text` AS `text` from `test`.`t1` `tt` where (not(exists(select `test`.`t1`.`id` from `test`.`t1` where ((`test`.`t1`.`id` < 8) and (`test`.`t1`.`id` = `test`.`tt`.`id`)) having (`test`.`t1`.`id` is not null)))) +Note 1003 select `test`.`tt`.`id` AS `id`,`test`.`tt`.`text` AS `text` from `test`.`t1` `tt` where (not(<expr_cache><`test`.`tt`.`id`>(exists(select `test`.`t1`.`id` from `test`.`t1` where ((`test`.`t1`.`id` < 8) and (`test`.`t1`.`id` = `test`.`tt`.`id`)) having (`test`.`t1`.`id` is not null))))) insert into t1 (id, text) values (1000, 'text1000'), (1001, 'text1001'); create table t2 (id int not null, text varchar(20) not null default '', primary key (id)); insert into t2 (id, text) values (1, 'text1'), (2, 'text2'), (3, 'text3'), (4, 'text4'), (5, 'text5'), (6, 'text6'), (7, 'text7'), (8, 'text8'), (9, 'text9'), (10, 'text10'), (11, 'text1'), (12, 'text2'), (13, 'text3'), (14, 'text4'), (15, 'text5'), (16, 'text6'), (17, 'text7'), (18, 'text8'), (19, 'text9'), (20, 'text10'),(21, 'text1'), (22, 'text2'), (23, 'text3'), (24, 'text4'), (25, 'text5'), (26, 'text6'), (27, 'text7'), (28, 'text8'), (29, 'text9'), (30, 'text10'), (31, 'text1'), (32, 'text2'), (33, 'text3'), (34, 'text4'), (35, 'text5'), (36, 'text6'), (37, 'text7'), (38, 'text8'), (39, 'text9'), (40, 'text10'), (41, 'text1'), (42, 'text2'), (43, 'text3'), (44, 'text4'), (45, 'text5'), (46, 'text6'), (47, 'text7'), (48, 'text8'), (49, 'text9'), (50, 'text10'); @@ -2292,7 +2423,7 @@ id select_type table type possible_keys key key_len ref rows filtered Extra 2 DEPENDENT SUBQUERY t1 ALL NULL NULL NULL NULL 2 100.00 Using where Warnings: Note 1276 Field or reference 'test.up.a' of SELECT #2 was resolved in SELECT #1 -Note 1003 select `test`.`up`.`a` AS `a`,`test`.`up`.`b` AS `b` from `test`.`t1` `up` where exists(select 1 from `test`.`t1` where (`test`.`t1`.`a` = `test`.`up`.`a`)) +Note 1003 select `test`.`up`.`a` AS `a`,`test`.`up`.`b` AS `b` from `test`.`t1` `up` where <expr_cache><`test`.`up`.`a`>(exists(select 1 from `test`.`t1` where (`test`.`t1`.`a` = `test`.`up`.`a`))) drop table t1; CREATE TABLE t1 (t1_a int); INSERT INTO t1 VALUES (1); @@ -2763,6 +2894,8 @@ select * from (select max(fld) from t1) as foo; max(fld) 1 drop table t1; +set @tmp11867_optimizer_switch=@@optimizer_switch; +set optimizer_switch='semijoin_with_cache=off'; CREATE TABLE t1 (one int, two int, flag char(1)); CREATE TABLE t2 (one int, two int, flag char(1)); INSERT INTO t1 VALUES(1,2,'Y'),(2,3,'Y'),(3,4,'Y'),(5,6,'N'),(7,8,'N'); @@ -2833,20 +2966,21 @@ id select_type table type possible_keys key key_len ref rows filtered Extra 1 PRIMARY t1 ALL NULL NULL NULL NULL 8 100.00 2 DEPENDENT SUBQUERY t2 ALL NULL NULL NULL NULL 9 100.00 Using where Warnings: -Note 1003 select `test`.`t1`.`one` AS `one`,`test`.`t1`.`two` AS `two`,<in_optimizer>((`test`.`t1`.`one`,`test`.`t1`.`two`),<exists>(select `test`.`t2`.`one`,`test`.`t2`.`two` from `test`.`t2` where ((`test`.`t2`.`flag` = '0') and trigcond(((<cache>(`test`.`t1`.`one`) = `test`.`t2`.`one`) or isnull(`test`.`t2`.`one`))) and trigcond(((<cache>(`test`.`t1`.`two`) = `test`.`t2`.`two`) or isnull(`test`.`t2`.`two`)))) having (trigcond(<is_not_null_test>(`test`.`t2`.`one`)) and trigcond(<is_not_null_test>(`test`.`t2`.`two`))))) AS `test` from `test`.`t1` +Note 1003 select `test`.`t1`.`one` AS `one`,`test`.`t1`.`two` AS `two`,<expr_cache><`test`.`t1`.`one`,`test`.`t1`.`two`>(<in_optimizer>((`test`.`t1`.`one`,`test`.`t1`.`two`),<exists>(select `test`.`t2`.`one`,`test`.`t2`.`two` from `test`.`t2` where ((`test`.`t2`.`flag` = '0') and trigcond(((<cache>(`test`.`t1`.`one`) = `test`.`t2`.`one`) or isnull(`test`.`t2`.`one`))) and trigcond(((<cache>(`test`.`t1`.`two`) = `test`.`t2`.`two`) or isnull(`test`.`t2`.`two`)))) having (trigcond(<is_not_null_test>(`test`.`t2`.`one`)) and trigcond(<is_not_null_test>(`test`.`t2`.`two`)))))) AS `test` from `test`.`t1` explain extended SELECT one,two from t1 where ROW(one,two) IN (SELECT one,two FROM t2 WHERE flag = 'N'); id select_type table type possible_keys key key_len ref rows filtered Extra 1 PRIMARY t1 ALL NULL NULL NULL NULL 8 100.00 Using where 2 DEPENDENT SUBQUERY t2 ALL NULL NULL NULL NULL 9 100.00 Using where Warnings: -Note 1003 select `test`.`t1`.`one` AS `one`,`test`.`t1`.`two` AS `two` from `test`.`t1` where <in_optimizer>((`test`.`t1`.`one`,`test`.`t1`.`two`),<exists>(select `test`.`t2`.`one`,`test`.`t2`.`two` from `test`.`t2` where ((`test`.`t2`.`flag` = 'N') and (<cache>(`test`.`t1`.`one`) = `test`.`t2`.`one`) and (<cache>(`test`.`t1`.`two`) = `test`.`t2`.`two`)))) +Note 1003 select `test`.`t1`.`one` AS `one`,`test`.`t1`.`two` AS `two` from `test`.`t1` where <expr_cache><`test`.`t1`.`one`,`test`.`t1`.`two`>(<in_optimizer>((`test`.`t1`.`one`,`test`.`t1`.`two`),<exists>(select `test`.`t2`.`one`,`test`.`t2`.`two` from `test`.`t2` where ((`test`.`t2`.`flag` = 'N') and (<cache>(`test`.`t1`.`one`) = `test`.`t2`.`one`) and (<cache>(`test`.`t1`.`two`) = `test`.`t2`.`two`))))) explain extended SELECT one,two,ROW(one,two) IN (SELECT one,two FROM t2 WHERE flag = '0' group by one,two) as 'test' from t1; id select_type table type possible_keys key key_len ref rows filtered Extra 1 PRIMARY t1 ALL NULL NULL NULL NULL 8 100.00 2 DEPENDENT SUBQUERY t2 ALL NULL NULL NULL NULL 9 100.00 Using where; Using temporary Warnings: -Note 1003 select `test`.`t1`.`one` AS `one`,`test`.`t1`.`two` AS `two`,<in_optimizer>((`test`.`t1`.`one`,`test`.`t1`.`two`),<exists>(select `test`.`t2`.`one`,`test`.`t2`.`two` from `test`.`t2` where (`test`.`t2`.`flag` = '0') group by `test`.`t2`.`one`,`test`.`t2`.`two` having (trigcond(((<cache>(`test`.`t1`.`one`) = `test`.`t2`.`one`) or isnull(`test`.`t2`.`one`))) and trigcond(((<cache>(`test`.`t1`.`two`) = `test`.`t2`.`two`) or isnull(`test`.`t2`.`two`))) and trigcond(<is_not_null_test>(`test`.`t2`.`one`)) and trigcond(<is_not_null_test>(`test`.`t2`.`two`))))) AS `test` from `test`.`t1` +Note 1003 select `test`.`t1`.`one` AS `one`,`test`.`t1`.`two` AS `two`,<expr_cache><`test`.`t1`.`one`,`test`.`t1`.`two`>(<in_optimizer>((`test`.`t1`.`one`,`test`.`t1`.`two`),<exists>(select `test`.`t2`.`one`,`test`.`t2`.`two` from `test`.`t2` where (`test`.`t2`.`flag` = '0') group by `test`.`t2`.`one`,`test`.`t2`.`two` having (trigcond(((<cache>(`test`.`t1`.`one`) = `test`.`t2`.`one`) or isnull(`test`.`t2`.`one`))) and trigcond(((<cache>(`test`.`t1`.`two`) = `test`.`t2`.`two`) or isnull(`test`.`t2`.`two`))) and trigcond(<is_not_null_test>(`test`.`t2`.`one`)) and trigcond(<is_not_null_test>(`test`.`t2`.`two`)))))) AS `test` from `test`.`t1` DROP TABLE t1,t2; +set optimizer_switch=@tmp11867_optimizer_switch; CREATE TABLE t1 (a char(5), b char(5)); INSERT INTO t1 VALUES (NULL,'aaa'), ('aaa','aaa'); SELECT * FROM t1 WHERE (a,b) IN (('aaa','aaa'), ('aaa','bbb')); @@ -4291,7 +4425,7 @@ id select_type table type possible_keys key key_len ref rows filtered Extra 2 DEPENDENT SUBQUERY t2 ALL NULL NULL NULL NULL 2 100.00 Using where Warnings: Note 1276 Field or reference 'test.t1.a' of SELECT #2 was resolved in SELECT #1 -Note 1003 select 2 AS `2` from `test`.`t1` where exists(select 1 from `test`.`t2` where (`test`.`t1`.`a` = `test`.`t2`.`a`)) +Note 1003 select 2 AS `2` from `test`.`t1` where <expr_cache><`test`.`t1`.`a`>(exists(select 1 from `test`.`t2` where (`test`.`t1`.`a` = `test`.`t2`.`a`))) EXPLAIN EXTENDED SELECT 2 FROM t1 WHERE EXISTS ((SELECT 1 FROM t2 WHERE t1.a=t2.a) UNION (SELECT 1 FROM t2 WHERE t1.a = t2.a)); @@ -4303,7 +4437,7 @@ NULL UNION RESULT <union2,3> ALL NULL NULL NULL NULL NULL NULL Warnings: Note 1276 Field or reference 'test.t1.a' of SELECT #2 was resolved in SELECT #1 Note 1276 Field or reference 'test.t1.a' of SELECT #3 was resolved in SELECT #1 -Note 1003 select 2 AS `2` from `test`.`t1` where exists((select 1 from `test`.`t2` where (`test`.`t1`.`a` = `test`.`t2`.`a`)) union (select 1 from `test`.`t2` where (`test`.`t1`.`a` = `test`.`t2`.`a`))) +Note 1003 select 2 AS `2` from `test`.`t1` where <expr_cache><`test`.`t1`.`a`>(exists((select 1 from `test`.`t2` where (`test`.`t1`.`a` = `test`.`t2`.`a`)) union (select 1 from `test`.`t2` where (`test`.`t1`.`a` = `test`.`t2`.`a`)))) DROP TABLE t1,t2; create table t0(a int); insert into t0 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9); @@ -4381,13 +4515,13 @@ id select_type table type possible_keys key key_len ref rows filtered Extra 1 PRIMARY t1 ALL NULL NULL NULL NULL 2 100.00 2 DEPENDENT SUBQUERY t1 ALL NULL NULL NULL NULL 2 100.00 Using temporary Warnings: -Note 1003 select 1 AS `1` from `test`.`t1` where <in_optimizer>(1,<exists>(select 1 from `test`.`t1` group by `test`.`t1`.`a` having (1 = <ref_null_helper>(1)))) +Note 1003 select 1 AS `1` from `test`.`t1` where <expr_cache><1>(<in_optimizer>(1,<exists>(select 1 from `test`.`t1` group by `test`.`t1`.`a` having (1 = <ref_null_helper>(1))))) EXPLAIN EXTENDED SELECT 1 FROM t1 WHERE 1 IN (SELECT 1 FROM t1 WHERE a > 3 GROUP BY a); id select_type table type possible_keys key key_len ref rows filtered Extra 1 PRIMARY t1 ALL NULL NULL NULL NULL 2 100.00 2 DEPENDENT SUBQUERY t1 ALL NULL NULL NULL NULL 2 100.00 Using where; Using temporary Warnings: -Note 1003 select 1 AS `1` from `test`.`t1` where <in_optimizer>(1,<exists>(select 1 from `test`.`t1` where (`test`.`t1`.`a` > 3) group by `test`.`t1`.`a` having (1 = <ref_null_helper>(1)))) +Note 1003 select 1 AS `1` from `test`.`t1` where <expr_cache><1>(<in_optimizer>(1,<exists>(select 1 from `test`.`t1` where (`test`.`t1`.`a` > 3) group by `test`.`t1`.`a` having (1 = <ref_null_helper>(1))))) DROP TABLE t1; # # Bug#45061: Incorrectly market field caused wrong result. @@ -5507,6 +5641,167 @@ SELECT 1 as foo FROM t1 WHERE a < SOME ); foo DROP TABLE t1; +CREATE TABLE t1 (a int(11), b varchar(1)); +INSERT INTO t1 VALUES (2,NULL),(5,'d'),(7,'g'); +SELECT a FROM t1 WHERE b < ANY ( SELECT b FROM t1 GROUP BY b ); +a +5 +SELECT a FROM t1 WHERE b < ANY ( SELECT b FROM t1 ); +a +5 +SELECT a FROM t1 WHERE b > ANY ( SELECT b FROM t1 GROUP BY b ); +a +7 +SELECT a FROM t1 WHERE b > ANY ( SELECT b FROM t1 ); +a +7 +SELECT a FROM t1 WHERE b <= ANY ( SELECT b FROM t1 GROUP BY b ); +a +5 +7 +SELECT a FROM t1 WHERE b <= ANY ( SELECT b FROM t1 ); +a +5 +7 +SELECT a FROM t1 WHERE b >= ANY ( SELECT b FROM t1 GROUP BY b ); +a +5 +7 +SELECT a FROM t1 WHERE b >= ANY ( SELECT b FROM t1 ); +a +5 +7 +SELECT a FROM t1 WHERE b = ANY ( SELECT b FROM t1 ); +a +5 +7 +SELECT a FROM t1 WHERE b = ANY ( SELECT b FROM t1 GROUP BY b ); +a +5 +7 +SELECT a FROM t1 WHERE b <> ANY ( SELECT b FROM t1 ); +a +5 +7 +SELECT a FROM t1 WHERE b <> ANY ( SELECT b FROM t1 GROUP BY b ); +a +5 +7 +SELECT a FROM t1 WHERE b < ALL ( SELECT b FROM t1 GROUP BY b ); +a +SELECT a FROM t1 WHERE b < ALL ( SELECT b FROM t1 ); +a +SELECT a FROM t1 WHERE b > ALL ( SELECT b FROM t1 GROUP BY b ); +a +SELECT a FROM t1 WHERE b > ALL ( SELECT b FROM t1 ); +a +SELECT a FROM t1 WHERE b <= ALL ( SELECT b FROM t1 GROUP BY b ); +a +SELECT a FROM t1 WHERE b <= ALL ( SELECT b FROM t1 ); +a +SELECT a FROM t1 WHERE b >= ALL ( SELECT b FROM t1 GROUP BY b ); +a +SELECT a FROM t1 WHERE b >= ALL ( SELECT b FROM t1 ); +a +SELECT a FROM t1 WHERE b = ALL ( SELECT b FROM t1 ); +a +SELECT a FROM t1 WHERE b = ALL ( SELECT b FROM t1 GROUP BY b ); +a +SELECT a FROM t1 WHERE b <> ALL ( SELECT b FROM t1 ); +a +SELECT a FROM t1 WHERE b <> ALL ( SELECT b FROM t1 GROUP BY b ); +a +delete from t1; +INSERT INTO t1 VALUES (2,NULL),(5,'d'),(7,'g'); +SELECT a FROM t1 WHERE b < ANY ( SELECT b FROM t1 GROUP BY b ); +a +5 +SELECT a FROM t1 WHERE b < ANY ( SELECT b FROM t1 ); +a +5 +SELECT a FROM t1 WHERE b > ANY ( SELECT b FROM t1 GROUP BY b ); +a +7 +SELECT a FROM t1 WHERE b > ANY ( SELECT b FROM t1 ); +a +7 +SELECT a FROM t1 WHERE b <= ANY ( SELECT b FROM t1 GROUP BY b ); +a +5 +7 +SELECT a FROM t1 WHERE b <= ANY ( SELECT b FROM t1 ); +a +5 +7 +SELECT a FROM t1 WHERE b >= ANY ( SELECT b FROM t1 GROUP BY b ); +a +5 +7 +SELECT a FROM t1 WHERE b >= ANY ( SELECT b FROM t1 ); +a +5 +7 +SELECT a FROM t1 WHERE b = ANY ( SELECT b FROM t1 ); +a +5 +7 +SELECT a FROM t1 WHERE b = ANY ( SELECT b FROM t1 GROUP BY b ); +a +5 +7 +SELECT a FROM t1 WHERE b <> ANY ( SELECT b FROM t1 ); +a +5 +7 +SELECT a FROM t1 WHERE b <> ANY ( SELECT b FROM t1 GROUP BY b ); +a +5 +7 +SELECT a FROM t1 WHERE b < ALL ( SELECT b FROM t1 GROUP BY b ); +a +SELECT a FROM t1 WHERE b < ALL ( SELECT b FROM t1 ); +a +SELECT a FROM t1 WHERE b > ALL ( SELECT b FROM t1 GROUP BY b ); +a +SELECT a FROM t1 WHERE b > ALL ( SELECT b FROM t1 ); +a +SELECT a FROM t1 WHERE b <= ALL ( SELECT b FROM t1 GROUP BY b ); +a +SELECT a FROM t1 WHERE b <= ALL ( SELECT b FROM t1 ); +a +SELECT a FROM t1 WHERE b >= ALL ( SELECT b FROM t1 GROUP BY b ); +a +SELECT a FROM t1 WHERE b >= ALL ( SELECT b FROM t1 ); +a +SELECT a FROM t1 WHERE b = ALL ( SELECT b FROM t1 ); +a +SELECT a FROM t1 WHERE b = ALL ( SELECT b FROM t1 GROUP BY b ); +a +SELECT a FROM t1 WHERE b <> ALL ( SELECT b FROM t1 ); +a +SELECT a FROM t1 WHERE b <> ALL ( SELECT b FROM t1 GROUP BY b ); +a +drop table t1; +# +# Fix of lp:780386 (NULL left part with empty ALL subquery). +# +CREATE TABLE t1 ( f11 int) ; +INSERT IGNORE INTO t1 VALUES (0),(0); +CREATE TABLE t2 ( f3 int, f10 int, KEY (f10,f3)) ; +INSERT IGNORE INTO t2 VALUES (NULL,NULL),(5,0); +DROP TABLE IF EXISTS t3; +Warnings: +Note 1051 Unknown table 't3' +CREATE TABLE t3 ( f3 int) ; +INSERT INTO t3 VALUES (0),(0); +SELECT a1.f3 AS r FROM t2 AS a1 , t1 WHERE a1.f3 < ALL ( SELECT f3 FROM t3 WHERE f3 = 1 ) ; +r +NULL +5 +NULL +5 +DROP TABLE t1, t2, t3; +End of 5.2 tests # # BUG#779885: Crash in eliminate_item_equal with materialization=on in # maria-5.3 @@ -5529,24 +5824,30 @@ ON t2.f10 = t3.f10 f1 DROP TABLE t1,t2,t3; # -# Fix of LP BUG#780386 (NULL left part with empty ALL subquery). +# BUG lp:813473: Wrong result with outer join + NOT IN subquery +# This bug is a duplicate of Bug#11764086 whose test case is added below # -CREATE TABLE t1 ( f11 int) ; -INSERT IGNORE INTO t1 VALUES (0),(0); -CREATE TABLE t2 ( f3 int, f10 int, KEY (f10,f3)) ; -INSERT IGNORE INTO t2 VALUES (NULL,NULL),(5,0); -DROP TABLE IF EXISTS t3; -Warnings: -Note 1051 Unknown table 't3' -CREATE TABLE t3 ( f3 int) ; -INSERT INTO t3 VALUES (0),(0); -SELECT a1.f3 AS r FROM t2 AS a1 , t1 WHERE a1.f3 < ALL ( SELECT f3 FROM t3 WHERE f3 = 1 ) ; -r -NULL -5 -NULL -5 -DROP TABLE t1, t2, t3; +CREATE TABLE t1 (c int) ; +INSERT INTO t1 VALUES (5),(6); +CREATE TABLE t2 (a int, b int) ; +INSERT INTO t2 VALUES (20,9),(20,9); +create table t3 (d int, e int); +insert into t3 values (2, 9), (3,10); +EXPLAIN +SELECT t2.b , t1.c +FROM t2 LEFT JOIN t1 ON t1.c < 3 +WHERE (t2.b , t1.c) NOT IN (SELECT * from t3); +id select_type table type possible_keys key key_len ref rows Extra +1 PRIMARY t2 ALL NULL NULL NULL NULL 2 +1 PRIMARY t1 ALL NULL NULL NULL NULL 2 Using where +2 DEPENDENT SUBQUERY t3 ALL NULL NULL NULL NULL 2 Using where +SELECT t2.b , t1.c +FROM t2 LEFT JOIN t1 ON t1.c < 3 +WHERE (t2.b, t1.c) NOT IN (SELECT * from t3); +b c +9 NULL +9 NULL +drop table t1, t2, t3; End of 5.3 tests End of 5.5 tests. # @@ -5665,5 +5966,56 @@ id select_type table type possible_keys key key_len ref rows Extra 1 PRIMARY table2 index NULL f1_key 4 NULL 10 Using where; Using index; Using join buffer (flat, BNL join) 2 DEPENDENT SUBQUERY t2 range f1_key f1_key 4 NULL 6 Range checked for each record (index map: 0x1); Using temporary DROP TABLE t1,t2; +# +# lp:826279: assertion failure with GROUP BY a result of subquery +# +CREATE TABLE t1 (a int); +INSERT INTO t1 VALUES (0), (0); +CREATE TABLE t2 (a int, b int, c int); +INSERT INTO t2 VALUES (10,7,0), (0,7,0); +CREATE TABLE t3 (a int, b int); +INSERT INTO t3 VALUES (10,7), (0,7); +SELECT SUM(DISTINCT b), +(SELECT t2.a FROM t1 JOIN t2 ON t2.c != 0 +WHERE t.a != 0 AND t2.a != 0) +FROM (SELECT * FROM t3) AS t +GROUP BY 2; +SUM(DISTINCT b) (SELECT t2.a FROM t1 JOIN t2 ON t2.c != 0 +WHERE t.a != 0 AND t2.a != 0) +7 NULL +SELECT SUM(DISTINCT b), +(SELECT t2.a FROM t1,t2 WHERE t.a != 0 or 1=2 LIMIT 1) +FROM (SELECT * FROM t3) AS t +GROUP BY 2; +SUM(DISTINCT b) (SELECT t2.a FROM t1,t2 WHERE t.a != 0 or 1=2 LIMIT 1) +7 NULL +7 10 +DROP TABLE t1,t2,t3; +# +# Bug#12329653 +# EXPLAIN, UNION, PREPARED STATEMENT, CRASH, SQL_FULL_GROUP_BY +# +CREATE TABLE t1(a1 int); +INSERT INTO t1 VALUES (1),(2); +SELECT @@session.sql_mode INTO @old_sql_mode; +SET SESSION sql_mode='ONLY_FULL_GROUP_BY'; +SELECT 1 FROM t1 WHERE 1 < SOME (SELECT a1 FROM t1); +1 +1 +1 +PREPARE stmt FROM +'SELECT 1 UNION ALL +SELECT 1 FROM t1 +ORDER BY +(SELECT 1 FROM t1 AS t1_0 + WHERE 1 < SOME (SELECT a1 FROM t1) +)' ; +EXECUTE stmt ; +ERROR 21000: Subquery returns more than 1 row +EXECUTE stmt ; +ERROR 21000: Subquery returns more than 1 row +SET SESSION sql_mode=@old_sql_mode; +DEALLOCATE PREPARE stmt; +DROP TABLE t1; set optimizer_switch=@subselect_tmp; set @optimizer_switch_for_subselect_test=null; diff --git a/mysql-test/r/subselect_nulls.result b/mysql-test/r/subselect_nulls.result index 1ae8c9f6237..584c184870d 100644 --- a/mysql-test/r/subselect_nulls.result +++ b/mysql-test/r/subselect_nulls.result @@ -1,5 +1,7 @@ drop table if exists x1; drop table if exists x2; +set @tmp_subselect_nulls=@@optimizer_switch; +set optimizer_switch='semijoin=off'; create table x1(k int primary key, d1 int, d2 int); create table x2(k int primary key, d1 int, d2 int); insert into x1 values @@ -110,5 +112,6 @@ where x1.d1=x2.d1 and x1.d2=x2.d2); k d1 d2 10 10 10 20 20 20 +set optimizer_switch= @tmp_subselect_nulls; drop table x1; drop table x2; diff --git a/mysql-test/r/subselect_partial_match.result b/mysql-test/r/subselect_partial_match.result index 85aa96df714..dddf5e2d8d6 100644 --- a/mysql-test/r/subselect_partial_match.result +++ b/mysql-test/r/subselect_partial_match.result @@ -3,11 +3,13 @@ set @save_optimizer_switch=@@optimizer_switch; Part 1: Feature tests. ------------------------------- Default for all tests. -set @@optimizer_switch="materialization=on,in_to_exists=off,semijoin=off,subquery_cache=off"; - +set @@optimizer_switch = "materialization=on,in_to_exists=off,semijoin=off,subquery_cache=off"; +set @test_default_opt_switch = @@optimizer_switch; +set @in_exists = "materialization=off,in_to_exists=on,semijoin=off,subquery_cache=off"; +------------------------------------------------------------------------- Schema requires partial matching, but data analysis discoveres there is no need. This is possible only if all outer columns are not NULL. - +------------------------------------------------------------------------- create table t1 (a1 char(8) not null, a2 char(8) not null); create table t2 (b1 char(8), b2 char(8)); insert into t1 values ('1 - 00', '2 - 00'); @@ -26,9 +28,9 @@ a1 a2 in_res 1 - 00 2 - 00 0 1 - 01 2 - 01 NULL drop table t1, t2; - +------------------------------------------------------------------------- NULLs in the outer columns, no NULLs in the suqbuery - +------------------------------------------------------------------------- create table t1 (a1 char(8), a2 char(8)); create table t2 (b1 char(8) not null, b2 char(8) not null); insert into t1 values (NULL , '2 - 00'); @@ -55,17 +57,532 @@ NULL 2 - 00 NULL 1 - 01 2 - 01 1 NULL NULL NULL drop table t1, t2; - +------------------------------------------------------------------------- +NULLs in the outer column, NULLs in the subquery, there is +no value match in any column, but there is a partial match +such that some of the matching NULLs are in the outer columns, +the other NULLs are in the inner columns. +------------------------------------------------------------------------- +create table t1 (a1 char(1), a2 char(1), a3 char(1)); +create table t2 (b1 char(1), b2 char(1), b3 char(1)); +insert into t1 values ('c', NULL, 'a'); +insert into t2 values (NULL, 'x', NULL); +insert into t2 values (NULL, 'y', NULL); +insert into t2 values ('o', 'z', 'p'); +set @@optimizer_switch='partial_match_rowid_merge=on,partial_match_table_scan=off'; +EXPLAIN +SELECT t1.*, (a1, a2, a3) IN (select * from t2) as in_res from t1; +id select_type table type possible_keys key key_len ref rows Extra +1 PRIMARY t1 system NULL NULL NULL NULL 1 +2 SUBQUERY t2 ALL NULL NULL NULL NULL 3 +SELECT t1.*, (a1, a2, a3) IN (select * from t2) as in_res from t1; +a1 a2 a3 in_res +c NULL a NULL +EXPLAIN +SELECT * from t1 where (a1, a2, a3) NOT IN (select * from t2); +id select_type table type possible_keys key key_len ref rows Extra +1 PRIMARY t1 system NULL NULL NULL NULL 1 +2 SUBQUERY t2 ALL NULL NULL NULL NULL 3 +SELECT * from t1 where (a1, a2, a3) NOT IN (select * from t2); +a1 a2 a3 +set @@optimizer_switch='partial_match_rowid_merge=off,partial_match_table_scan=on'; +EXPLAIN +SELECT t1.*, (a1, a2, a3) IN (select * from t2) as in_res from t1; +id select_type table type possible_keys key key_len ref rows Extra +1 PRIMARY t1 system NULL NULL NULL NULL 1 +2 SUBQUERY t2 ALL NULL NULL NULL NULL 3 +SELECT t1.*, (a1, a2, a3) IN (select * from t2) as in_res from t1; +a1 a2 a3 in_res +c NULL a NULL +EXPLAIN +SELECT * from t1 where (a1, a2, a3) NOT IN (select * from t2); +id select_type table type possible_keys key key_len ref rows Extra +1 PRIMARY t1 system NULL NULL NULL NULL 1 +2 SUBQUERY t2 ALL NULL NULL NULL NULL 3 +SELECT * from t1 where (a1, a2, a3) NOT IN (select * from t2); +a1 a2 a3 +set @@optimizer_switch=@in_exists; +EXPLAIN +SELECT t1.*, (a1, a2, a3) IN (select * from t2) as in_res from t1; +id select_type table type possible_keys key key_len ref rows Extra +1 PRIMARY t1 system NULL NULL NULL NULL 1 +2 DEPENDENT SUBQUERY t2 ALL NULL NULL NULL NULL 3 Using where +SELECT t1.*, (a1, a2, a3) IN (select * from t2) as in_res from t1; +a1 a2 a3 in_res +c NULL a NULL +EXPLAIN +SELECT * from t1 where (a1, a2, a3) NOT IN (select * from t2); +id select_type table type possible_keys key key_len ref rows Extra +1 PRIMARY t1 system NULL NULL NULL NULL 1 +2 DEPENDENT SUBQUERY t2 ALL NULL NULL NULL NULL 3 Using where +SELECT * from t1 where (a1, a2, a3) NOT IN (select * from t2); +a1 a2 a3 +set @@optimizer_switch = @test_default_opt_switch; +drop table t1, t2; +create table t1 (a1 char(1), a2 char(1) not null, a3 char(1)); +create table t2 (b1 char(1), b2 char(1), b3 char(1)); +insert into t1 values (NULL, 'y', NULL); +insert into t2 values ('v', 'x', NULL); +insert into t2 values (NULL, 'y', 'w'); +set @@optimizer_switch='partial_match_rowid_merge=on,partial_match_table_scan=off'; +EXPLAIN +SELECT t1.*, (a1, a2, a3) IN (select * from t2) as in_res from t1; +id select_type table type possible_keys key key_len ref rows Extra +1 PRIMARY t1 system NULL NULL NULL NULL 1 +2 SUBQUERY t2 ALL NULL NULL NULL NULL 2 +SELECT t1.*, (a1, a2, a3) IN (select * from t2) as in_res from t1; +a1 a2 a3 in_res +NULL y NULL NULL +EXPLAIN +SELECT * from t1 where (a1, a2, a3) NOT IN (select * from t2); +id select_type table type possible_keys key key_len ref rows Extra +1 PRIMARY t1 system NULL NULL NULL NULL 1 +2 SUBQUERY t2 ALL NULL NULL NULL NULL 2 +SELECT * from t1 where (a1, a2, a3) NOT IN (select * from t2); +a1 a2 a3 +set @@optimizer_switch='partial_match_rowid_merge=off,partial_match_table_scan=on'; +EXPLAIN +SELECT t1.*, (a1, a2, a3) IN (select * from t2) as in_res from t1; +id select_type table type possible_keys key key_len ref rows Extra +1 PRIMARY t1 system NULL NULL NULL NULL 1 +2 SUBQUERY t2 ALL NULL NULL NULL NULL 2 +SELECT t1.*, (a1, a2, a3) IN (select * from t2) as in_res from t1; +a1 a2 a3 in_res +NULL y NULL NULL +EXPLAIN +SELECT * from t1 where (a1, a2, a3) NOT IN (select * from t2); +id select_type table type possible_keys key key_len ref rows Extra +1 PRIMARY t1 system NULL NULL NULL NULL 1 +2 SUBQUERY t2 ALL NULL NULL NULL NULL 2 +SELECT * from t1 where (a1, a2, a3) NOT IN (select * from t2); +a1 a2 a3 +set @@optimizer_switch=@in_exists; +EXPLAIN +SELECT t1.*, (a1, a2, a3) IN (select * from t2) as in_res from t1; +id select_type table type possible_keys key key_len ref rows Extra +1 PRIMARY t1 system NULL NULL NULL NULL 1 +2 DEPENDENT SUBQUERY t2 ALL NULL NULL NULL NULL 2 Using where +SELECT t1.*, (a1, a2, a3) IN (select * from t2) as in_res from t1; +a1 a2 a3 in_res +NULL y NULL NULL +EXPLAIN +SELECT * from t1 where (a1, a2, a3) NOT IN (select * from t2); +id select_type table type possible_keys key key_len ref rows Extra +1 PRIMARY t1 system NULL NULL NULL NULL 1 +2 DEPENDENT SUBQUERY t2 ALL NULL NULL NULL NULL 2 Using where +SELECT * from t1 where (a1, a2, a3) NOT IN (select * from t2); +a1 a2 a3 +set @@optimizer_switch = @test_default_opt_switch; +drop table t1, t2; +------------------------------------------------------------------------- +There is only one column in the subquery to complement the NULLs in the +outer reference. It is a NULL column, so a match is guaranteed. +------------------------------------------------------------------------- +create table t1 (a1 char(1), a2 char(1), a3 char(1)); +create table t2 (b1 char(1), b2 char(1), b3 char(1)); +insert into t1 values (NULL, 'g', NULL); +insert into t2 values ('z', NULL, 'y'); +insert into t2 values (NULL, 'z', 'y'); +set @@optimizer_switch='partial_match_rowid_merge=on,partial_match_table_scan=off'; +EXPLAIN +SELECT t1.*, (a1, a2, a3) IN (select * from t2) as in_res from t1; +id select_type table type possible_keys key key_len ref rows Extra +1 PRIMARY t1 system NULL NULL NULL NULL 1 +2 SUBQUERY t2 ALL NULL NULL NULL NULL 2 +SELECT t1.*, (a1, a2, a3) IN (select * from t2) as in_res from t1; +a1 a2 a3 in_res +NULL g NULL NULL +EXPLAIN +SELECT * from t1 where (a1, a2, a3) NOT IN (select * from t2); +id select_type table type possible_keys key key_len ref rows Extra +1 PRIMARY t1 system NULL NULL NULL NULL 1 +2 SUBQUERY t2 ALL NULL NULL NULL NULL 2 +SELECT * from t1 where (a1, a2, a3) NOT IN (select * from t2); +a1 a2 a3 +set @@optimizer_switch='partial_match_rowid_merge=off,partial_match_table_scan=on'; +EXPLAIN +SELECT t1.*, (a1, a2, a3) IN (select * from t2) as in_res from t1; +id select_type table type possible_keys key key_len ref rows Extra +1 PRIMARY t1 system NULL NULL NULL NULL 1 +2 SUBQUERY t2 ALL NULL NULL NULL NULL 2 +SELECT t1.*, (a1, a2, a3) IN (select * from t2) as in_res from t1; +a1 a2 a3 in_res +NULL g NULL NULL +EXPLAIN +SELECT * from t1 where (a1, a2, a3) NOT IN (select * from t2); +id select_type table type possible_keys key key_len ref rows Extra +1 PRIMARY t1 system NULL NULL NULL NULL 1 +2 SUBQUERY t2 ALL NULL NULL NULL NULL 2 +SELECT * from t1 where (a1, a2, a3) NOT IN (select * from t2); +a1 a2 a3 +set @@optimizer_switch=@in_exists; +EXPLAIN +SELECT t1.*, (a1, a2, a3) IN (select * from t2) as in_res from t1; +id select_type table type possible_keys key key_len ref rows Extra +1 PRIMARY t1 system NULL NULL NULL NULL 1 +2 DEPENDENT SUBQUERY t2 ALL NULL NULL NULL NULL 2 Using where +SELECT t1.*, (a1, a2, a3) IN (select * from t2) as in_res from t1; +a1 a2 a3 in_res +NULL g NULL NULL +EXPLAIN +SELECT * from t1 where (a1, a2, a3) NOT IN (select * from t2); +id select_type table type possible_keys key key_len ref rows Extra +1 PRIMARY t1 system NULL NULL NULL NULL 1 +2 DEPENDENT SUBQUERY t2 ALL NULL NULL NULL NULL 2 Using where +SELECT * from t1 where (a1, a2, a3) NOT IN (select * from t2); +a1 a2 a3 +set @@optimizer_switch = @test_default_opt_switch; +drop table t1, t2; +------------------------------------------------------------------------- +The intersection of the NULL bitmaps is empty because the ranges +of NULL bits do not overlap. +------------------------------------------------------------------------- +create table t1 (a1 char(1), a2 char(1), a3 char(1)); +create table t2 (b1 char(1), b2 char(1), b3 char(1)); +insert into t1 values ('b', 'g', NULL); +insert into t2 values ('z', NULL, 'y'); +insert into t2 values (NULL, 'z', 'y'); +set @@optimizer_switch='partial_match_rowid_merge=on,partial_match_table_scan=off'; +EXPLAIN +SELECT t1.*, (a1, a2, a3) IN (select * from t2) as in_res from t1; +id select_type table type possible_keys key key_len ref rows Extra +1 PRIMARY t1 system NULL NULL NULL NULL 1 +2 SUBQUERY t2 ALL NULL NULL NULL NULL 2 +SELECT t1.*, (a1, a2, a3) IN (select * from t2) as in_res from t1; +a1 a2 a3 in_res +b g NULL 0 +EXPLAIN +SELECT * from t1 where (a1, a2, a3) NOT IN (select * from t2); +id select_type table type possible_keys key key_len ref rows Extra +1 PRIMARY t1 system NULL NULL NULL NULL 1 +2 SUBQUERY t2 ALL NULL NULL NULL NULL 2 +SELECT * from t1 where (a1, a2, a3) NOT IN (select * from t2); +a1 a2 a3 +b g NULL +set @@optimizer_switch='partial_match_rowid_merge=off,partial_match_table_scan=on'; +EXPLAIN +SELECT t1.*, (a1, a2, a3) IN (select * from t2) as in_res from t1; +id select_type table type possible_keys key key_len ref rows Extra +1 PRIMARY t1 system NULL NULL NULL NULL 1 +2 SUBQUERY t2 ALL NULL NULL NULL NULL 2 +SELECT t1.*, (a1, a2, a3) IN (select * from t2) as in_res from t1; +a1 a2 a3 in_res +b g NULL 0 +EXPLAIN +SELECT * from t1 where (a1, a2, a3) NOT IN (select * from t2); +id select_type table type possible_keys key key_len ref rows Extra +1 PRIMARY t1 system NULL NULL NULL NULL 1 +2 SUBQUERY t2 ALL NULL NULL NULL NULL 2 +SELECT * from t1 where (a1, a2, a3) NOT IN (select * from t2); +a1 a2 a3 +b g NULL +set @@optimizer_switch=@in_exists; +EXPLAIN +SELECT t1.*, (a1, a2, a3) IN (select * from t2) as in_res from t1; +id select_type table type possible_keys key key_len ref rows Extra +1 PRIMARY t1 system NULL NULL NULL NULL 1 +2 DEPENDENT SUBQUERY t2 ALL NULL NULL NULL NULL 2 Using where +SELECT t1.*, (a1, a2, a3) IN (select * from t2) as in_res from t1; +a1 a2 a3 in_res +b g NULL 0 +EXPLAIN +SELECT * from t1 where (a1, a2, a3) NOT IN (select * from t2); +id select_type table type possible_keys key key_len ref rows Extra +1 PRIMARY t1 system NULL NULL NULL NULL 1 +2 DEPENDENT SUBQUERY t2 ALL NULL NULL NULL NULL 2 Using where +SELECT * from t1 where (a1, a2, a3) NOT IN (select * from t2); +a1 a2 a3 +b g NULL +drop table t1, t2; +------------------------------------------------------------------------- +The intersection of the NULL bitmaps is non-empty, and there is a +non-NULL column. +------------------------------------------------------------------------- +create table t1 (a1 char(1), a2 char(1), a3 char(1) not null, a4 char(10)); +create table t2 (b1 char(1), b2 char(1), b3 char(1), b4 char(1)); +insert into t1 values ('a', 'g', 'x', NULL); +insert into t2 values ('z', NULL, 'y', 'x'); +insert into t2 values (NULL, NULL, 'x', 'y'); +insert into t2 values ('x', 'w', 'z', NULL); +set @@optimizer_switch='partial_match_rowid_merge=on,partial_match_table_scan=off'; +EXPLAIN +SELECT t1.*, (a1, a2, a3, a4) IN (select * from t2) as in_res from t1; +id select_type table type possible_keys key key_len ref rows Extra +1 PRIMARY t1 system NULL NULL NULL NULL 1 +2 DEPENDENT SUBQUERY t2 ALL NULL NULL NULL NULL 3 Using where +SELECT t1.*, (a1, a2, a3, a4) IN (select * from t2) as in_res from t1; +a1 a2 a3 a4 in_res +a g x NULL NULL +EXPLAIN +SELECT * from t1 where (a1, a2, a3, a4) NOT IN (select * from t2); +id select_type table type possible_keys key key_len ref rows Extra +1 PRIMARY t1 system NULL NULL NULL NULL 1 +2 DEPENDENT SUBQUERY t2 ALL NULL NULL NULL NULL 3 Using where +SELECT * from t1 where (a1, a2, a3, a4) NOT IN (select * from t2); +a1 a2 a3 a4 +set @@optimizer_switch='partial_match_rowid_merge=off,partial_match_table_scan=on'; +EXPLAIN +SELECT t1.*, (a1, a2, a3, a4) IN (select * from t2) as in_res from t1; +id select_type table type possible_keys key key_len ref rows Extra +1 PRIMARY t1 system NULL NULL NULL NULL 1 +2 DEPENDENT SUBQUERY t2 ALL NULL NULL NULL NULL 3 Using where +SELECT t1.*, (a1, a2, a3, a4) IN (select * from t2) as in_res from t1; +a1 a2 a3 a4 in_res +a g x NULL NULL +EXPLAIN +SELECT * from t1 where (a1, a2, a3, a4) NOT IN (select * from t2); +id select_type table type possible_keys key key_len ref rows Extra +1 PRIMARY t1 system NULL NULL NULL NULL 1 +2 DEPENDENT SUBQUERY t2 ALL NULL NULL NULL NULL 3 Using where +SELECT * from t1 where (a1, a2, a3, a4) NOT IN (select * from t2); +a1 a2 a3 a4 +set @@optimizer_switch=@in_exists; +EXPLAIN +SELECT t1.*, (a1, a2, a3, a4) IN (select * from t2) as in_res from t1; +id select_type table type possible_keys key key_len ref rows Extra +1 PRIMARY t1 system NULL NULL NULL NULL 1 +2 DEPENDENT SUBQUERY t2 ALL NULL NULL NULL NULL 3 Using where +SELECT t1.*, (a1, a2, a3, a4) IN (select * from t2) as in_res from t1; +a1 a2 a3 a4 in_res +a g x NULL NULL +EXPLAIN +SELECT * from t1 where (a1, a2, a3, a4) NOT IN (select * from t2); +id select_type table type possible_keys key key_len ref rows Extra +1 PRIMARY t1 system NULL NULL NULL NULL 1 +2 DEPENDENT SUBQUERY t2 ALL NULL NULL NULL NULL 3 Using where +SELECT * from t1 where (a1, a2, a3, a4) NOT IN (select * from t2); +a1 a2 a3 a4 +drop table t1, t2; +------------------------------------------------------------------------- +Value match in one row, but the NULL complement match in another. +The result must be false. +------------------------------------------------------------------------- +create table t1 (a1 char(2), a2 char(1), a3 char(1) not null, a4 char(10)); +create table t2 (b1 char(2), b2 char(1), b3 char(1), b4 char(1)); +insert into t1 values ('99', NULL, 'j', 'f'); +insert into t2 values ('01', NULL, 'y', NULL); +insert into t2 values ('02', NULL, 'x', 'y'); +insert into t2 values ('03', 'q', 'y', 'x'); +insert into t2 values (NULL, 'q', 'm', 'p'); +insert into t2 values ('m', 'z', 'j', NULL); +insert into t2 values (NULL, 'z', 'b', NULL); +insert into t2 values (NULL, 'z', 'a', NULL); +insert into t2 values ('34', 'q', 'y', 'x'); +set @@optimizer_switch='partial_match_rowid_merge=on,partial_match_table_scan=off'; +EXPLAIN +SELECT t1.*, (a1, a2, a3, a4) IN (select * from t2) as in_res from t1; +id select_type table type possible_keys key key_len ref rows Extra +1 PRIMARY t1 system NULL NULL NULL NULL 1 +2 DEPENDENT SUBQUERY t2 ALL NULL NULL NULL NULL 8 Using where +SELECT t1.*, (a1, a2, a3, a4) IN (select * from t2) as in_res from t1; +a1 a2 a3 a4 in_res +99 NULL j f 0 +EXPLAIN +SELECT * from t1 where (a1, a2, a3, a4) NOT IN (select * from t2); +id select_type table type possible_keys key key_len ref rows Extra +1 PRIMARY t1 system NULL NULL NULL NULL 1 +2 DEPENDENT SUBQUERY t2 ALL NULL NULL NULL NULL 8 Using where +SELECT * from t1 where (a1, a2, a3, a4) NOT IN (select * from t2); +a1 a2 a3 a4 +99 NULL j f +set @@optimizer_switch='partial_match_rowid_merge=off,partial_match_table_scan=on'; +EXPLAIN +SELECT t1.*, (a1, a2, a3, a4) IN (select * from t2) as in_res from t1; +id select_type table type possible_keys key key_len ref rows Extra +1 PRIMARY t1 system NULL NULL NULL NULL 1 +2 DEPENDENT SUBQUERY t2 ALL NULL NULL NULL NULL 8 Using where +SELECT t1.*, (a1, a2, a3, a4) IN (select * from t2) as in_res from t1; +a1 a2 a3 a4 in_res +99 NULL j f 0 +EXPLAIN +SELECT * from t1 where (a1, a2, a3, a4) NOT IN (select * from t2); +id select_type table type possible_keys key key_len ref rows Extra +1 PRIMARY t1 system NULL NULL NULL NULL 1 +2 DEPENDENT SUBQUERY t2 ALL NULL NULL NULL NULL 8 Using where +SELECT * from t1 where (a1, a2, a3, a4) NOT IN (select * from t2); +a1 a2 a3 a4 +99 NULL j f +set @@optimizer_switch=@in_exists; +EXPLAIN +SELECT t1.*, (a1, a2, a3, a4) IN (select * from t2) as in_res from t1; +id select_type table type possible_keys key key_len ref rows Extra +1 PRIMARY t1 system NULL NULL NULL NULL 1 +2 DEPENDENT SUBQUERY t2 ALL NULL NULL NULL NULL 8 Using where +SELECT t1.*, (a1, a2, a3, a4) IN (select * from t2) as in_res from t1; +a1 a2 a3 a4 in_res +99 NULL j f 0 +EXPLAIN +SELECT * from t1 where (a1, a2, a3, a4) NOT IN (select * from t2); +id select_type table type possible_keys key key_len ref rows Extra +1 PRIMARY t1 system NULL NULL NULL NULL 1 +2 DEPENDENT SUBQUERY t2 ALL NULL NULL NULL NULL 8 Using where +SELECT * from t1 where (a1, a2, a3, a4) NOT IN (select * from t2); +a1 a2 a3 a4 +99 NULL j f +drop table t1, t2; +------------------------------------------------------------------------- +Test the intersection of larger number of rows with NULL, such that +the number is at the boundary 32. This test is based on the implementation +of MY_BITMAP which uses 32 bit words, and the intersection operation works +by intersecting the bitmap word by word. +------------------------------------------------------------------------- +create table t1 (a1 char(2), a2 char(2), a3 char(1), a4 char(10)) ENGINE=MyISAM; +create table t2 (b1 char(2), b2 char(2), b3 char(1), b4 char(1)) ENGINE=MyISAM; +insert into t1 values (NULL, '98', NULL, 'b'); +insert into t1 values (NULL, '99', NULL, 'c'); +insert into t2 values ('00', 'rr', 'y', NULL); +insert into t2 values ('01', 'rr', 'y', NULL); +insert into t2 values ('02', NULL, 'x', 'y'); +insert into t2 values ('03', 'qq', 'y', 'x'); +insert into t2 values ('04', 'qq', 'm', 'p'); +insert into t2 values ('05', 'rr', 'y', NULL); +insert into t2 values ('06', NULL, 'x', 'y'); +insert into t2 values ('07', 'qq', 'y', 'x'); +insert into t2 values ('08', 'qq', 'm', 'q'); +insert into t2 values ('09', 'rr', 'y', NULL); +insert into t2 values ('10', NULL, 'x', 'y'); +insert into t2 values ('11', 'qq', 'y', 'x'); +insert into t2 values ('12', 'qq', 'm', 'k'); +insert into t2 values ('13', 'rr', 'y', NULL); +insert into t2 values ('14', NULL, 'x', 'y'); +insert into t2 values ('15', 'qq', 'y', 'x'); +insert into t2 values ('16', 'qq', 'm', 's'); +insert into t2 values ('17', 'rr', 'y', NULL); +insert into t2 values ('18', NULL, 'x', 'y'); +insert into t2 values ('19', 'qq', 'y', 'x'); +insert into t2 values ('20', 'qq', 'm', 't'); +insert into t2 values ('21', 'rr', 'y', NULL); +insert into t2 values ('22', NULL, 'x', 'y'); +insert into t2 values ('23', 'qq', 'y', 'x'); +insert into t2 values ('24', 'qq', 'm', 'u'); +insert into t2 values ('25', 'rr', 'y', NULL); +insert into t2 values ('26', NULL, 'x', 'y'); +insert into t2 values ('27', 'qq', 'y', 'x'); +insert into t2 values ('28', 'qq', 'm', 'y'); +insert into t2 values ('29', 'rr', 'y', NULL); +insert into t2 values ('30', NULL, 'x', 'z'); +insert into t2 values ('31', 'ss', 'h', NULL); +insert into t2 values ('32', 'vv', 'i', NULL); +the only partial matching row +insert into t2 values ('33', NULL, 'j', NULL); +insert into t2 values ('34', 'qq', 'y', 'x'); +set @@optimizer_switch='partial_match_rowid_merge=on,partial_match_table_scan=off'; +EXPLAIN +SELECT t1.*, (a1, a2, a3, a4) IN (select * from t2) as in_res from t1; +id select_type table type possible_keys key key_len ref rows Extra +1 PRIMARY t1 ALL NULL NULL NULL NULL 2 +2 DEPENDENT SUBQUERY t2 ALL NULL NULL NULL NULL 35 Using where +SELECT t1.*, (a1, a2, a3, a4) IN (select * from t2) as in_res from t1; +a1 a2 a3 a4 in_res +NULL 98 NULL b NULL +NULL 99 NULL c NULL +EXPLAIN +SELECT * from t1 where (a1, a2, a3, a4) NOT IN (select * from t2); +id select_type table type possible_keys key key_len ref rows Extra +1 PRIMARY t1 ALL NULL NULL NULL NULL 2 Using where +2 DEPENDENT SUBQUERY t2 ALL NULL NULL NULL NULL 35 Using where +SELECT * from t1 where (a1, a2, a3, a4) NOT IN (select * from t2); +a1 a2 a3 a4 +set @@optimizer_switch='partial_match_rowid_merge=off,partial_match_table_scan=on'; +EXPLAIN +SELECT t1.*, (a1, a2, a3, a4) IN (select * from t2) as in_res from t1; +id select_type table type possible_keys key key_len ref rows Extra +1 PRIMARY t1 ALL NULL NULL NULL NULL 2 +2 DEPENDENT SUBQUERY t2 ALL NULL NULL NULL NULL 35 Using where +SELECT t1.*, (a1, a2, a3, a4) IN (select * from t2) as in_res from t1; +a1 a2 a3 a4 in_res +NULL 98 NULL b NULL +NULL 99 NULL c NULL +EXPLAIN +SELECT * from t1 where (a1, a2, a3, a4) NOT IN (select * from t2); +id select_type table type possible_keys key key_len ref rows Extra +1 PRIMARY t1 ALL NULL NULL NULL NULL 2 Using where +2 DEPENDENT SUBQUERY t2 ALL NULL NULL NULL NULL 35 Using where +SELECT * from t1 where (a1, a2, a3, a4) NOT IN (select * from t2); +a1 a2 a3 a4 +set @@optimizer_switch=@in_exists; +EXPLAIN +SELECT t1.*, (a1, a2, a3, a4) IN (select * from t2) as in_res from t1; +id select_type table type possible_keys key key_len ref rows Extra +1 PRIMARY t1 ALL NULL NULL NULL NULL 2 +2 DEPENDENT SUBQUERY t2 ALL NULL NULL NULL NULL 35 Using where +SELECT t1.*, (a1, a2, a3, a4) IN (select * from t2) as in_res from t1; +a1 a2 a3 a4 in_res +NULL 98 NULL b NULL +NULL 99 NULL c NULL +EXPLAIN +SELECT * from t1 where (a1, a2, a3, a4) NOT IN (select * from t2); +id select_type table type possible_keys key key_len ref rows Extra +1 PRIMARY t1 ALL NULL NULL NULL NULL 2 Using where +2 DEPENDENT SUBQUERY t2 ALL NULL NULL NULL NULL 35 Using where +SELECT * from t1 where (a1, a2, a3, a4) NOT IN (select * from t2); +a1 a2 a3 a4 +change the mathcing row to be the last one in the first bitmap word +update t2 set b2 = 'zz' where b1 = 33; +update t2 set b2 = NULL where b1 = 31; +set @@optimizer_switch='partial_match_rowid_merge=on,partial_match_table_scan=off'; +EXPLAIN +SELECT t1.*, (a1, a2, a3, a4) IN (select * from t2) as in_res from t1; +id select_type table type possible_keys key key_len ref rows Extra +1 PRIMARY t1 ALL NULL NULL NULL NULL 2 +2 DEPENDENT SUBQUERY t2 ALL NULL NULL NULL NULL 35 Using where +SELECT t1.*, (a1, a2, a3, a4) IN (select * from t2) as in_res from t1; +a1 a2 a3 a4 in_res +NULL 98 NULL b NULL +NULL 99 NULL c NULL +EXPLAIN +SELECT * from t1 where (a1, a2, a3, a4) NOT IN (select * from t2); +id select_type table type possible_keys key key_len ref rows Extra +1 PRIMARY t1 ALL NULL NULL NULL NULL 2 Using where +2 DEPENDENT SUBQUERY t2 ALL NULL NULL NULL NULL 35 Using where +SELECT * from t1 where (a1, a2, a3, a4) NOT IN (select * from t2); +a1 a2 a3 a4 +set @@optimizer_switch='partial_match_rowid_merge=off,partial_match_table_scan=on'; +EXPLAIN +SELECT t1.*, (a1, a2, a3, a4) IN (select * from t2) as in_res from t1; +id select_type table type possible_keys key key_len ref rows Extra +1 PRIMARY t1 ALL NULL NULL NULL NULL 2 +2 DEPENDENT SUBQUERY t2 ALL NULL NULL NULL NULL 35 Using where +SELECT t1.*, (a1, a2, a3, a4) IN (select * from t2) as in_res from t1; +a1 a2 a3 a4 in_res +NULL 98 NULL b NULL +NULL 99 NULL c NULL +EXPLAIN +SELECT * from t1 where (a1, a2, a3, a4) NOT IN (select * from t2); +id select_type table type possible_keys key key_len ref rows Extra +1 PRIMARY t1 ALL NULL NULL NULL NULL 2 Using where +2 DEPENDENT SUBQUERY t2 ALL NULL NULL NULL NULL 35 Using where +SELECT * from t1 where (a1, a2, a3, a4) NOT IN (select * from t2); +a1 a2 a3 a4 +set @@optimizer_switch=@in_exists; +EXPLAIN +SELECT t1.*, (a1, a2, a3, a4) IN (select * from t2) as in_res from t1; +id select_type table type possible_keys key key_len ref rows Extra +1 PRIMARY t1 ALL NULL NULL NULL NULL 2 +2 DEPENDENT SUBQUERY t2 ALL NULL NULL NULL NULL 35 Using where +SELECT t1.*, (a1, a2, a3, a4) IN (select * from t2) as in_res from t1; +a1 a2 a3 a4 in_res +NULL 98 NULL b NULL +NULL 99 NULL c NULL +EXPLAIN +SELECT * from t1 where (a1, a2, a3, a4) NOT IN (select * from t2); +id select_type table type possible_keys key key_len ref rows Extra +1 PRIMARY t1 ALL NULL NULL NULL NULL 2 Using where +2 DEPENDENT SUBQUERY t2 ALL NULL NULL NULL NULL 35 Using where +SELECT * from t1 where (a1, a2, a3, a4) NOT IN (select * from t2); +a1 a2 a3 a4 +drop table t1, t2; +------------------------------------------------------------------------- All columns require partial matching (no non-null columns) - +------------------------------------------------------------------------- TODO - +------------------------------------------------------------------------- Both non-NULL columns and columns with NULLs - +------------------------------------------------------------------------- TODO - +------------------------------------------------------------------------- Covering NULL rows - +------------------------------------------------------------------------- create table t1 (a1 char(8), a2 char(8)); create table t2 (b1 char(8), b2 char(8)); insert into t1 values ('1 - 00', '2 - 00'); @@ -98,9 +615,9 @@ a1 a2 in_res 1 - 00 2 - 00 NULL 1 - 01 2 - 01 1 drop table t1, t2; - +------------------------------------------------------------------------- Covering NULL columns - +------------------------------------------------------------------------- this case affects only the rowid-merge algorithm set @@optimizer_switch="partial_match_rowid_merge=on,partial_match_table_scan=off"; create table t1 (a1 char(8) not null, a2 char(8), a3 char(8) not null); @@ -149,9 +666,9 @@ a1 a2 a3 in_res 1 - 00 2 - 00 3 - 00 NULL 1 - 01 2 - 01 3 - 01 0 drop table t1, t2; - +------------------------------------------------------------------------- Covering NULL row, and a NULL column - +------------------------------------------------------------------------- create table t1 (a1 char(8) not null, a2 char(8), a3 char(8)); create table t2 (b1 char(8), b2 char(8), b3 char(8)); insert into t1 values ('1 - 00', '2 - 00', '3 - 00'); @@ -174,9 +691,9 @@ a1 a2 a3 in_res 1 - 00 2 - 00 3 - 00 NULL 1 - 01 2 - 01 3 - 01 NULL drop table t1, t2; - +------------------------------------------------------------------------- Covering NULL row, and covering NULL columns - +------------------------------------------------------------------------- create table t1 (a1 char(8) not null, a2 char(8), a3 char(8)); create table t2 (b1 char(8), b2 char(8), b3 char(8)); insert into t1 values ('1 - 00', '2 - 00', '3 - 00'); @@ -198,6 +715,32 @@ a1 a2 a3 in_res 1 - 00 2 - 00 3 - 00 NULL 1 - 01 2 - 01 3 - 01 NULL drop table t1, t2; +------------------------------------------------------------------------- +Small buffer for the rowid_merge partial match algorithm that forces +reverting to table scan partial match. +------------------------------------------------------------------------- +set @save_rowid_merge_buff_size = @@rowid_merge_buff_size; +set @@rowid_merge_buff_size = 0; +create table t1 (a1 char(2), a2 char(2), a3 char(1), a4 char(10)); +create table t2 (b1 char(2), b2 char(2), b3 char(1), b4 char(1)); +insert into t1 values (NULL, '98', NULL, 'b'); +insert into t1 values (NULL, '99', NULL, 'c'); +insert into t2 values ('00', 'rr', 'y', NULL); +insert into t2 values ('01', 'rr', 'y', NULL); +insert into t2 values ('02', NULL, 'x', 'y'); +insert into t2 values ('03', 'qq', 'y', 'x'); +set @@optimizer_switch='partial_match_rowid_merge=on,partial_match_table_scan=off'; +EXPLAIN +SELECT t1.*, (a1, a2, a3, a4) IN (select * from t2) as in_res from t1; +id select_type table type possible_keys key key_len ref rows Extra +1 PRIMARY t1 ALL NULL NULL NULL NULL 2 +2 DEPENDENT SUBQUERY t2 ALL NULL NULL NULL NULL 4 Using where +SELECT t1.*, (a1, a2, a3, a4) IN (select * from t2) as in_res from t1; +a1 a2 a3 a4 in_res +NULL 98 NULL b 0 +NULL 99 NULL c 0 +drop table t1, t2; +set @@rowid_merge_buff_size = @save_rowid_merge_buff_size; ------------------------------- Part 2: Test cases for bugs. ------------------------------- @@ -348,4 +891,61 @@ c 0 0 drop table t1, t2; +# +# LP BUG#856152 Wrong result with NOT IN subquery and partial_match_rowid_merge +# +CREATE TABLE t1 ( f1 integer NOT NULL , f2 integer) ; +INSERT INTO t1 VALUES (3,3),(48,NULL),(49,1); +CREATE TABLE t2 ( f3 int) ; +INSERT INTO t2 VALUES (5); +set @@optimizer_switch='in_to_exists=off,materialization=on,partial_match_rowid_merge=on,partial_match_table_scan=off'; +EXPLAIN SELECT * FROM t2 WHERE ( 3 , 1 ) NOT IN ( SELECT f1 , f2 FROM t1 ); +id select_type table type possible_keys key key_len ref rows Extra +1 PRIMARY t2 system NULL NULL NULL NULL 1 +2 SUBQUERY t1 ALL NULL NULL NULL NULL 3 +SELECT * FROM t2 WHERE ( 3 , 1 ) NOT IN ( SELECT f1 , f2 FROM t1 ); +f3 +5 +set @@optimizer_switch='in_to_exists=on,materialization=off'; +EXPLAIN SELECT * FROM t2 WHERE ( 3 , 1 ) NOT IN ( SELECT f1 , f2 FROM t1 ); +id select_type table type possible_keys key key_len ref rows Extra +1 PRIMARY t2 system NULL NULL NULL NULL 1 +2 DEPENDENT SUBQUERY t1 ALL NULL NULL NULL NULL 3 Using where +SELECT * FROM t2 WHERE ( 3 , 1 ) NOT IN ( SELECT f1 , f2 FROM t1 ); +f3 +5 +drop table t1, t2; +# +# LP BUG#869036 Wrong result with in_to_exists=ON and NOT IN +# +create table outer_sq (f1 char(1), f2 char(1)); +insert into outer_sq values (NULL, 'c'), ('g', 'c'); +create table inner_sq (f3 char(1), f4 char(1)); +insert into inner_sq values(null, 'i'), ('v', null); +All three strategies below must produce the same result. +set @@optimizer_switch='in_to_exists=off,materialization=on,partial_match_rowid_merge=on,partial_match_table_scan=off'; +SELECT outer_sq.*, (f1, f2) IN (select * from inner_sq) from outer_sq; +f1 f2 (f1, f2) IN (select * from inner_sq) +NULL c NULL +g c 0 +SELECT * from outer_sq where (f1, f2) NOT IN (select * from inner_sq); +f1 f2 +g c +set @@optimizer_switch='in_to_exists=off,materialization=on,partial_match_rowid_merge=off,partial_match_table_scan=on'; +SELECT outer_sq.*, (f1, f2) IN (select * from inner_sq) from outer_sq; +f1 f2 (f1, f2) IN (select * from inner_sq) +NULL c NULL +g c 0 +SELECT * from outer_sq where (f1, f2) NOT IN (select * from inner_sq); +f1 f2 +g c +set @@optimizer_switch='in_to_exists=on,materialization=off'; +SELECT outer_sq.*, (f1, f2) IN (select * from inner_sq) from outer_sq; +f1 f2 (f1, f2) IN (select * from inner_sq) +NULL c NULL +g c 0 +SELECT * from outer_sq where (f1, f2) NOT IN (select * from inner_sq); +f1 f2 +g c +drop table outer_sq, inner_sq; set @@optimizer_switch=@save_optimizer_switch; diff --git a/mysql-test/r/subselect_sj.result b/mysql-test/r/subselect_sj.result index c1ed2a03973..42f8f3ca009 100644 --- a/mysql-test/r/subselect_sj.result +++ b/mysql-test/r/subselect_sj.result @@ -1,4 +1,4 @@ -drop table if exists t0, t1, t2, t3, t4, t10, t11, t12; +drop table if exists t0, t1, t2, t3, t4, t5, t10, t11, t12; drop view if exists v1, v2, v3, v4; drop procedure if exists p1; set @subselect_sj_tmp= @@optimizer_switch; @@ -726,7 +726,7 @@ FROM it1 LEFT JOIN it2 ON it2.datetime_key); id select_type table type possible_keys key key_len ref rows Extra 1 PRIMARY it1 index NULL int_key 4 NULL 2 Using index; Start temporary 1 PRIMARY ot1 ALL NULL NULL NULL NULL 20 Using join buffer (flat, BNL join) -1 PRIMARY it2 ALL int_key,datetime_key NULL NULL NULL 20 Using where; End temporary; Using join buffer (flat, BNL join) +1 PRIMARY it2 ALL int_key,datetime_key NULL NULL NULL 20 Using where; End temporary DROP TABLE ot1, it1, it2; # End of BUG#38075 # @@ -761,11 +761,11 @@ id select_type table type possible_keys key key_len ref rows filtered Extra 3 DEPENDENT SUBQUERY t3 ALL NULL NULL NULL NULL 4 100.00 Using where Warnings: Note 1276 Field or reference 'test.t1.b' of SELECT #3 was resolved in SELECT #1 -Note 1003 select `test`.`t1`.`a` AS `a` from `test`.`t1` semi join (`test`.`t2`) where ((`test`.`t1`.`a` = `test`.`t2`.`c`) and <nop>(<in_optimizer>(`test`.`t2`.`d`,<exists>(select `test`.`t3`.`e` from `test`.`t3` where ((`test`.`t1`.`b` = `test`.`t3`.`e`) and (<cache>(`test`.`t2`.`d`) >= `test`.`t3`.`e`)))))) +Note 1003 select `test`.`t1`.`a` AS `a` from `test`.`t1` semi join (`test`.`t2`) where ((`test`.`t1`.`a` = `test`.`t2`.`c`) and <nop>(<expr_cache><`test`.`t2`.`d`,`test`.`t1`.`b`>(<in_optimizer>(`test`.`t2`.`d`,<exists>(select `test`.`t3`.`e` from `test`.`t3` where ((`test`.`t1`.`b` = `test`.`t3`.`e`) and (<cache>(`test`.`t2`.`d`) >= `test`.`t3`.`e`))))))) show warnings; Level Code Message Note 1276 Field or reference 'test.t1.b' of SELECT #3 was resolved in SELECT #1 -Note 1003 select `test`.`t1`.`a` AS `a` from `test`.`t1` semi join (`test`.`t2`) where ((`test`.`t1`.`a` = `test`.`t2`.`c`) and <nop>(<in_optimizer>(`test`.`t2`.`d`,<exists>(select `test`.`t3`.`e` from `test`.`t3` where ((`test`.`t1`.`b` = `test`.`t3`.`e`) and (<cache>(`test`.`t2`.`d`) >= `test`.`t3`.`e`)))))) +Note 1003 select `test`.`t1`.`a` AS `a` from `test`.`t1` semi join (`test`.`t2`) where ((`test`.`t1`.`a` = `test`.`t2`.`c`) and <nop>(<expr_cache><`test`.`t2`.`d`,`test`.`t1`.`b`>(<in_optimizer>(`test`.`t2`.`d`,<exists>(select `test`.`t3`.`e` from `test`.`t3` where ((`test`.`t1`.`b` = `test`.`t3`.`e`) and (<cache>(`test`.`t2`.`d`) >= `test`.`t3`.`e`))))))) select a from t1 where a in (select c from t2 where d >= some(select e from t3 where b=e)); a @@ -1047,8 +1047,8 @@ AND t1.val IN (SELECT t3.val FROM t3 WHERE t3.val LIKE 'a%' OR t3.val LIKE 'e%'); id select_type table type possible_keys key key_len ref rows Extra 1 PRIMARY t1 ALL NULL NULL NULL NULL 5 Start temporary -1 PRIMARY t3 ALL NULL NULL NULL NULL 5 Using where; Using join buffer (flat, BNL join) -1 PRIMARY t2 ALL NULL NULL NULL NULL 6 Using where; End temporary; Using join buffer (flat, BNL join) +1 PRIMARY t3 ALL NULL NULL NULL NULL 5 Using where +1 PRIMARY t2 ALL NULL NULL NULL NULL 6 Using where; End temporary SELECT * FROM t1 WHERE t1.val IN (SELECT t2.val FROM t2 @@ -1238,7 +1238,7 @@ A.t1field IN (SELECT C.t2field FROM t2 C WHERE C.t2field IN (SELECT D.t2field FROM t2 D)); id select_type table type possible_keys key key_len ref rows Extra 1 PRIMARY A index PRIMARY PRIMARY 4 NULL 3 Using index; Start temporary -1 PRIMARY B index NULL PRIMARY 4 NULL 3 Using index; End temporary; Using join buffer (flat, BNL join) +1 PRIMARY B index NULL PRIMARY 4 NULL 3 Using index; End temporary 1 PRIMARY C eq_ref PRIMARY PRIMARY 4 test.A.t1field 1 Using index 1 PRIMARY D eq_ref PRIMARY PRIMARY 4 test.A.t1field 1 Using index SELECT * FROM t1 A @@ -1268,8 +1268,8 @@ where A.a = B.a and A.a in (select a from t2 C) and B.a in (select a from t2 D); id select_type table type possible_keys key key_len ref rows Extra 1 PRIMARY A ALL NULL NULL NULL NULL 3 Start temporary 1 PRIMARY B ALL NULL NULL NULL NULL 3 Using where; Using join buffer (flat, BNL join) -1 PRIMARY C ALL NULL NULL NULL NULL 3 Using where; Using join buffer (flat, BNL join) -1 PRIMARY D ALL NULL NULL NULL NULL 3 Using where; End temporary; Using join buffer (flat, BNL join) +1 PRIMARY C ALL NULL NULL NULL NULL 3 Using where +1 PRIMARY D ALL NULL NULL NULL NULL 3 Using where; End temporary drop table t1, t2; # # BUG#784441: Abort on semijoin with a view as the inner table @@ -1388,7 +1388,7 @@ insert into t3 values('three'),( 'four'); explain select * from t3 where t3.b in (select t2.b from t1 left join t2 on t1.a=t2.a); id select_type table type possible_keys key key_len ref rows Extra 1 PRIMARY t1 ALL NULL NULL NULL NULL 2 Start temporary -1 PRIMARY t2 ALL NULL NULL NULL NULL 2 Using where; Using join buffer (flat, BNL join) +1 PRIMARY t2 ALL NULL NULL NULL NULL 2 Using where 1 PRIMARY t3 ALL NULL NULL NULL NULL 8 Using where; End temporary; Using join buffer (flat, BNL join) select * from t3 where t3.b in (select t2.b from t1 left join t2 on t1.a=t2.a); b @@ -1442,7 +1442,7 @@ explain select * from t0 where a in (select t1.a from t1 left join t2 on t1.a=t2.a); id select_type table type possible_keys key key_len ref rows Extra 1 PRIMARY t0 ALL NULL NULL NULL NULL 2 Start temporary -1 PRIMARY t1 ALL NULL NULL NULL NULL 4 Using where; Using join buffer (flat, BNL join) +1 PRIMARY t1 ALL NULL NULL NULL NULL 4 Using where 1 PRIMARY t2 ALL NULL NULL NULL NULL 1 Using where; End temporary select * from t0 where a in (select t1.a from t1 left join t2 on t1.a=t2.a); a @@ -1501,7 +1501,7 @@ select * from t0 where a in (select t1.a from t1 left join (t3 join t2 on t3.b=t2.b) on t1.a=t3.a); id select_type table type possible_keys key key_len ref rows Extra 1 PRIMARY t0 ALL NULL NULL NULL NULL 2 Start temporary -1 PRIMARY t1 ALL NULL NULL NULL NULL 4 Using where; Using join buffer (flat, BNL join) +1 PRIMARY t1 ALL NULL NULL NULL NULL 4 Using where 1 PRIMARY t3 ALL NULL NULL NULL NULL 1 Using where 1 PRIMARY t2 ALL NULL NULL NULL NULL 1 Using where; End temporary select * from t0 @@ -1519,7 +1519,7 @@ select * from t0 where a in (select t1.a from t1 left join (t3 join t2 on t3.b=t2.b) on t1.a=t3.a); id select_type table type possible_keys key key_len ref rows Extra 1 PRIMARY t0 ALL NULL NULL NULL NULL 2 Start temporary -1 PRIMARY t1 ALL NULL NULL NULL NULL 4 Using where; Using join buffer (flat, BNL join) +1 PRIMARY t1 ALL NULL NULL NULL NULL 4 Using where 1 PRIMARY t2 ALL NULL NULL NULL NULL 1 1 PRIMARY t3 ALL NULL NULL NULL NULL 2 Using where; End temporary select * from t0 @@ -1674,8 +1674,6 @@ FROM t4 WHERE t4.f10 != t2.f11 ); f10 f10 f11 f10 -0 0 b 0 -0 0 b 0 0 0 a 0 0 0 a 0 0 0 b 0 @@ -1694,6 +1692,8 @@ f10 f10 f11 f10 0 0 b 0 0 0 a 0 0 0 a 0 +0 0 b 0 +0 0 b 0 drop table t1,t2,t3,t4; # # BUG#803457: Wrong result with semijoin + view + outer join in maria-5.3-subqueries-mwl90 @@ -1716,7 +1716,7 @@ id select_type table type possible_keys key key_len ref rows Extra 1 PRIMARY t1 ALL NULL NULL NULL NULL 3 Start temporary 1 PRIMARY t2 ALL NULL NULL NULL NULL 2 Using where 1 PRIMARY t3 ALL NULL NULL NULL NULL 5 Using where -1 PRIMARY t4 ALL NULL NULL NULL NULL 2 Using where; End temporary; Using join buffer (flat, BNL join) +1 PRIMARY t4 ALL NULL NULL NULL NULL 2 Using where; End temporary SELECT * FROM t1 NATURAL LEFT JOIN (t2, t3 ) WHERE IFNULL(t2.f3,'foo') IN (SELECT * FROM t4); f1 f2 f3 f3 2 0 0 0 @@ -1739,4 +1739,325 @@ c1 c2 2 7 5 6 DROP TABLE t1, t2, t3; +# +# BUG#834534: Assertion `0' failed in replace_where_subcondition with semijoin subquery in HAVING +# +CREATE TABLE t1 ( d int ); +INSERT INTO t1 VALUES (2),(2),(0),(2),(2); +CREATE TABLE t2 ( b int ); +INSERT INTO t2 VALUES (4),(3),(3); +CREATE TABLE t3 ( a int ); +SELECT * +FROM t3 +WHERE (t3.a) IN ( +SELECT t1.d +FROM t1 +HAVING ( 4 ) IN ( +SELECT t2.b +FROM t2 +) +); +a +drop table t1, t2,t3; +# +# BUG#834758: Wrong result with innner join, LooseScan, two-column IN() predicate +# +set @tmp835758=@@optimizer_switch; +set optimizer_switch='semijoin=on,loosescan=on,materialization=off,firstmatch=off'; +CREATE TABLE t1 (b int) ; +INSERT INTO t1 VALUES (1),(5); +CREATE TABLE t2 (a int, PRIMARY KEY (a)) ; +INSERT INTO t2 VALUES (6),(10); +CREATE TABLE t3 (a int, b int, KEY (b)) ; +INSERT INTO t3 VALUES (6,5),(6,2),(8,0),(9,1),(6,5); +# This used to incorrectly pick a join order of (t1, LooseScan(t3), t2): +explain +SELECT * FROM t1, t2 WHERE (t2.a , t1.b) IN (SELECT a, b FROM t3); +id select_type table type possible_keys key key_len ref rows Extra +1 PRIMARY t1 ALL NULL NULL NULL NULL 2 Start temporary +1 PRIMARY t2 index PRIMARY PRIMARY 4 NULL 2 Using index; Using join buffer (flat, BNL join) +1 PRIMARY t3 ALL b NULL NULL NULL 5 Using where; End temporary +SELECT * FROM t1, t2 WHERE (t2.a , t1.b) IN (SELECT a, b FROM t3); +b a +5 6 +DROP TABLE t1, t2, t3; +set @@optimizer_switch= @tmp835758; +# +# BUG#834739: Wrong result with 3-way inner join, LooseScan,multipart keys +# +set @tmp834739=@@optimizer_switch; +set optimizer_switch='semijoin=on,loosescan=on,materialization=off,firstmatch=off'; +CREATE TABLE t2 ( b int, c int, KEY (b)) ; +INSERT INTO t2 VALUES (1,0),(1,0),(9,0),(1,0),(5,0); +INSERT INTO t2 VALUES (2,0),(3,0),(8,0),(6,0),(5,0); +CREATE TABLE t3 ( a int); +INSERT INTO t3 VALUES (0),(0),(0),(0),(0),(0),(0),(0),(0),(0),(0),(0),(0),(0),(0); +CREATE TABLE t4 ( a int); +INSERT INTO t4 VALUES (0),(0),(0); +CREATE TABLE t5 ( b int, a int , KEY (a,b)) ; +INSERT INTO t5 VALUES (7,0),(9,0); +explain +SELECT * FROM t3 WHERE t3.a IN (SELECT t5.a FROM t2, t4, t5 WHERE t2.c = t5.a AND t2.b = t5.b); +id select_type table type possible_keys key key_len ref rows Extra +1 PRIMARY t5 index a a 10 NULL 2 Using where; Using index; LooseScan +1 PRIMARY t4 ALL NULL NULL NULL NULL 3 +1 PRIMARY t2 ref b b 5 test.t5.b 2 Using where; FirstMatch(t5) +1 PRIMARY t3 ALL NULL NULL NULL NULL 15 Using where; Using join buffer (flat, BNL join) +SELECT * FROM t3 WHERE t3.a IN (SELECT t5.a FROM t2, t4, t5 WHERE t2.c = t5.a AND t2.b = t5.b); +a +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +DROP TABLE t2, t3, t4, t5; +set @@optimizer_switch=@tmp834739; +# +# BUG#830993: Crash in end_read_record with derived table +# +set @tmp_830993=@@optimizer_switch; +set optimizer_switch='semijoin=on,loosescan=off,materialization=off,firstmatch=off'; +set @tmp_830993_jbs= @@join_buffer_size; +set join_buffer_size=160; +CREATE TABLE t1 ( +a int(11) NOT NULL AUTO_INCREMENT, +b int(11) DEFAULT NULL, +c int(11) DEFAULT NULL, +d time DEFAULT NULL, +e varchar(1) DEFAULT NULL, +f varchar(1) DEFAULT NULL, +PRIMARY KEY (a), +KEY c (c), +KEY d (d), +KEY e (e,c) +); +INSERT INTO t1 VALUES (10,NULL,8,'22:55:23','x','x'), +(11,8,7,'10:19:31','d','d'),(12,1,1,'14:40:36','r','r'), +(13,9,7,'04:37:47','f','f'),(14,4,9,'19:34:06','y','y'), +(15,3,NULL,'20:35:33','u','u'),(16,2,1,NULL,'m','m'), +(17,NULL,9,'14:43:37',NULL,NULL),(18,2,2,'02:23:09','o','o'), +(19,NULL,9,'01:22:45','w','w'),(20,6,2,'00:00:00','m','m'), +(21,7,4,'00:13:25','q','q'),(22,2,0,'03:47:16',NULL,NULL), +(23,5,4,'01:41:48','d','d'),(24,7,8,'00:00:00','g','g'), +(25,6,NULL,'22:32:04','x','x'),(26,6,NULL,'16:44:14','f','f'), +(27,2,0,'17:38:37','p','p'),(28,9,NULL,'08:46:48','j','j'), +(29,6,8,'14:11:27','c','c'); +CREATE TABLE t2 like t1; +INSERT INTO t2 VALUES (1,2,4,'22:34:09','v','v'), +(2,150,62,'14:26:02','v','v'),(3,NULL,7,'14:03:03','c','c'), +(4,2,1,'01:46:09',NULL,NULL),(5,5,0,'16:21:18','x','x'), +(6,3,7,'18:56:33','i','i'),(7,1,7,NULL,'e','e'), +(8,4,1,'09:29:08','p','p'),(9,NULL,7,'19:11:10','s','s'), +(10,2,1,'11:57:26','j','j'),(11,6,5,'00:39:46','z','z'), +(12,6,2,'03:28:15','c','c'),(13,8,0,'06:44:18','a','a'), +(14,2,1,'14:36:39','q','q'),(15,6,8,'18:42:45','y','y'), +(16,8,1,'02:57:29',NULL,NULL),(17,3,1,'16:46:13','r','r'), +(18,3,9,'19:39:02','v','v'),(19,9,1,NULL,NULL,NULL), +(20,6,5,'20:58:33','r','r'); +explain +SELECT +alias1.a, alias1.b, alias1.c, alias1.d, alias1.e, alias1.f, +alias2.a as a2_a, alias2.b as a2_b, alias2.c as a2_c, alias2.d as a2_d, +alias2.e as a2_e, alias2.f as a2_f, +t2.a as t2_a, t2.b as t2_b, t2.c as t2_c, t2.d as t2_d, t2.e as t2_e, t2.f as t2_f +FROM +(SELECT * FROM t2) AS alias1, +t1 AS alias2, +t2 +WHERE +alias1.c IN (SELECT SQ3_alias1.b +FROM t2 AS SQ3_alias1 STRAIGHT_JOIN t2 AS SQ3_alias2) +LIMIT 100; +id select_type table type possible_keys key key_len ref rows Extra +1 PRIMARY <derived2> ALL NULL NULL NULL NULL 20 Start temporary +1 PRIMARY alias2 ALL NULL NULL NULL NULL 20 Using join buffer (flat, BNL join) +1 PRIMARY t2 ALL NULL NULL NULL NULL 20 Using join buffer (flat, BNL join) +1 PRIMARY SQ3_alias1 ALL NULL NULL NULL NULL 20 Using where +1 PRIMARY SQ3_alias2 index NULL PRIMARY 4 NULL 20 Using index; End temporary +2 DERIVED t2 ALL NULL NULL NULL NULL 20 +create table t3 as +SELECT +alias1.a, alias1.b, alias1.c, alias1.d, alias1.e, alias1.f, +alias2.a as a2_a, alias2.b as a2_b, alias2.c as a2_c, alias2.d as a2_d, +alias2.e as a2_e, alias2.f as a2_f, +t2.a as t2_a, t2.b as t2_b, t2.c as t2_c, t2.d as t2_d, t2.e as t2_e, t2.f as t2_f +FROM +(SELECT * FROM t2) AS alias1, +t1 AS alias2, +t2 +WHERE +alias1.c IN (SELECT SQ3_alias1.b +FROM t2 AS SQ3_alias1 STRAIGHT_JOIN t2 AS SQ3_alias2) +LIMIT 100; +drop table t1,t2, t3; +set optimizer_switch=@tmp_830993; +set join_buffer_size= @tmp_830993_jbs; +# +# BUG##849717: Crash in Item_func::fix_fields on second execution of a prepared statement with semijoin +# +CREATE TABLE t1 (a int); +CREATE TABLE t2 (a int); +CREATE TABLE t3 (a int, b int) ; +PREPARE st1 FROM "SELECT * FROM t2 LEFT JOIN t1 ON t2.a != 0 AND ('j','r') IN ( SELECT b,a FROM t3)"; +EXECUTE st1; +a a +EXECUTE st1; +a a +DROP TABLE t1, t2, t3; +# +# BUG#849776: Wrong result with semijoin + "Impossible where" +# +CREATE TABLE t1 ( b varchar(1), a integer) ; +INSERT INTO t1 VALUES ('z',8); +CREATE TABLE t2 ( a integer, b varchar(1)) ; +CREATE TABLE t4 ( a integer, b varchar(1)) ; +CREATE TABLE t5 ( a integer) ; +INSERT INTO t5 VALUES (8); +select * from t5 where (a) in ( +SELECT t1.a +FROM t1 LEFT JOIN t2 ON t1.a = t2.a +WHERE t2.b NOT IN (SELECT t4.b FROM t4 WHERE t4.b < t1.b) +); +a +8 +DROP TABLE t1, t2, t4, t5; +# +# BUG#861147: Assertion `fixed == 1' failed in Item_func_eq::val_int() with semijoin + materialization + max_join_size +# +CREATE TABLE t1 ( f2 int) ; +CREATE TABLE t2 ( f1 int, f3 int, f4 varchar(3), f5 varchar(35)) ; +INSERT INTO t2 VALUES (4057,9,'USA','Visalia'),(3993,11,'USA','Waco'), +(3948,14,'USA','Warren'),(3813,57,'USA','Washington'), +(4010,11,'USA','Waterbury'),(4017,11,'USA','West Covina'), +(4004,11,'USA','West Valley City'),(4033,10,'USA','Westminster'), +(3842,34,'USA','Wichita'),(4018,10,'USA','Wichita Falls'), +(3899,19,'USA','Winston-Salem'),(3914,17,'USA','Worcester'), +(3888,20,'USA','Yonkers'); +CREATE TABLE t3 ( f3 int, f4 varchar(3)) ; +INSERT INTO t3 VALUES (86,'USA'); +CREATE TABLE t4 ( f3 int, f4 varchar(3), f5 varchar(52)) ; +INSERT INTO t4 VALUES (0,'RUS','Belorussian'),(0,'USA','Portuguese'); +CREATE TABLE t5 ( f2 int) ; +CREATE TABLE t6 ( f4 varchar(3)); +INSERT INTO t6 VALUES ('RUS'),('USA'); +set @tmp_mjs_861147= @@max_join_size; +SET max_join_size=10; +set @tmp_os_861147= @@optimizer_switch; +set @@optimizer_switch='semijoin=on,materialization=on'; +SELECT * +FROM t1 +WHERE ( 1 , 3 ) IN ( +SELECT t2.f1 , MAX( t3.f3 ) +FROM t2 +JOIN t3 +WHERE t3.f4 IN ( +SELECT t4.f5 +FROM t4 +STRAIGHT_JOIN t5 +WHERE t4.f4 < t2.f5 +) +) AND ( 'p' , 'k' ) IN ( +SELECT f4 , f4 FROM t6 +); +ERROR 42000: The SELECT would examine more than MAX_JOIN_SIZE rows; check your WHERE and use SET SQL_BIG_SELECTS=1 or SET MAX_JOIN_SIZE=# if the SELECT is okay +set max_join_size= @tmp_mjs_861147; +set optimizer_switch= @tmp_os_861147; +DROP TABLE t1,t2,t3,t4,t5,t6; +# +# BUG#877288: Wrong result with semijoin + materialization + multipart key +# +set @tmp_877288=@@optimizer_switch; +set optimizer_switch='semijoin=ON,materialization=ON'; +CREATE TABLE t1 ( a int) ; +INSERT INTO t1 VALUES (19),(19),(19),(20),(20),(20),(20),(20),(20); +CREATE TABLE t2 ( b int NOT NULL , c int NOT NULL , KEY (b,c)) ; +INSERT INTO t2 VALUES (14,1),(15,1),(16,1),(17,1),(18,1),(19,1),(20,1); +CREATE TABLE t3 ( a int, d int) ; +INSERT INTO t3 VALUES (19,1),(7,1),(3,1),(3,1),(20,1),(3,1),(16,1),(17,1),(9,1),(4,1),(6,1),(15,1),(17,1); +explain +SELECT * FROM t1 WHERE (a) IN (SELECT a FROM t2 JOIN t3 ON b = a); +id select_type table type possible_keys key key_len ref rows Extra +1 PRIMARY t1 ALL NULL NULL NULL NULL 9 +1 PRIMARY <subquery2> eq_ref distinct_key distinct_key 5 func 1 +2 SUBQUERY t3 ALL NULL NULL NULL NULL 13 Using where +2 SUBQUERY t2 ref b b 4 test.t3.a 1 Using index +SELECT * FROM t1 WHERE (a) IN (SELECT a FROM t2 JOIN t3 ON b = a); +a +19 +19 +19 +20 +20 +20 +20 +20 +20 +DROP TABLE t1,t2,t3; +set optimizer_switch=@tmp_877288; +# +# BUG#878753: Assertion '0' failed in replace_where_subcondition with derived_merge +# +set @tmp878753= @@optimizer_switch; +set optimizer_switch= 'semijoin=on,derived_merge=on'; +CREATE TABLE t1 (b int(11)) ; +CREATE TABLE t2 (c int, b int, d varchar(52) NOT NULL) ; +CREATE TABLE t3 (b int(11)) ; +PREPARE st1 FROM ' + SELECT * FROM t1 + JOIN ( + SELECT t2.* FROM t2 + WHERE t2.d <> "a" + AND t2.c IN ( + SELECT t3.b + FROM t3 + ) + ) AS alias2 + ON ( alias2.b = t1.b ); +'; +EXECUTE st1; +b c b d +DROP TABLE t1,t2,t3; +set optimizer_switch=@tmp878753; +# +# Bug #889750: semijoin=on + firstmatch=off + semijoin_with_cache=off +# +create table t1 (a int); +insert into t1 values (7), (1), (5), (3); +create table t2 (a int); +insert into t2 values (4), (1), (8), (3), (9), (2); +set @tmp_otimizer_switch= @@optimizer_switch; +set optimizer_switch='semijoin=on'; +set optimizer_switch='firstmatch=off'; +set optimizer_switch='semijoin_with_cache=on'; +explain +select * from t1 where t1.a in (select t2.a from t2); +id select_type table type possible_keys key key_len ref rows Extra +1 PRIMARY t1 ALL NULL NULL NULL NULL 4 Start temporary +1 PRIMARY t2 ALL NULL NULL NULL NULL 6 Using where; End temporary; Using join buffer (flat, BNL join) +select * from t1 where t1.a in (select t2.a from t2); +a +1 +3 +set optimizer_switch='semijoin_with_cache=off'; +explain +select * from t1 where t1.a in (select t2.a from t2); +id select_type table type possible_keys key key_len ref rows Extra +1 PRIMARY t1 ALL NULL NULL NULL NULL 4 Start temporary +1 PRIMARY t2 ALL NULL NULL NULL NULL 6 Using where; End temporary +select * from t1 where t1.a in (select t2.a from t2); +a +1 +3 +set optimizer_switch= @tmp_otimizer_switch; +drop table t1,t2; set optimizer_switch=@subselect_sj_tmp; diff --git a/mysql-test/r/subselect_sj2.result b/mysql-test/r/subselect_sj2.result index ce16f3b95ba..b410df3bab9 100644 --- a/mysql-test/r/subselect_sj2.result +++ b/mysql-test/r/subselect_sj2.result @@ -16,6 +16,7 @@ b int, key(b) ); insert into t2 select a, a/2 from t0; +insert into t2 select a+10, a+10/2 from t0; select * from t1; a b 1 1 @@ -33,6 +34,16 @@ a b 7 4 8 4 9 5 +10 5 +11 6 +12 7 +13 8 +14 9 +15 10 +16 11 +17 12 +18 13 +19 14 explain select * from t2 where b in (select a from t1); id select_type table type possible_keys key key_len ref rows Extra 1 PRIMARY t1 ALL NULL NULL NULL NULL 3 Using where; Start temporary @@ -51,6 +62,7 @@ pk1 char(200), pk2 char(200), pk3 char(200), primary key(pk1, pk2, pk3) ) engine=innodb; insert into t3 select a,a, a,a,a from t0; +insert into t3 select a,a, a+100,a+100,a+100 from t0; explain select * from t3 where b in (select a from t1); id select_type table type possible_keys key key_len ref rows Extra 1 PRIMARY t1 ALL NULL NULL NULL NULL 3 Using where; Start temporary @@ -58,6 +70,8 @@ id select_type table type possible_keys key key_len ref rows Extra select * from t3 where b in (select a from t1); a b pk1 pk2 pk3 1 1 1 1 1 +1 1 101 101 101 +2 2 102 102 102 2 2 2 2 2 set @save_max_heap_table_size= @@max_heap_table_size; set max_heap_table_size=16384; @@ -417,6 +431,7 @@ create table t0 (a int); insert into t0 values (0),(1),(2),(3),(4); create table t1 (a int, b int, key(a)); insert into t1 select a,a from t0; +insert into t1 select a+5,a from t0; create table t2 (a int, b int, primary key(a)); insert into t2 select * from t1; Table t2, unlike table t1, should be displayed as pulled out @@ -425,11 +440,11 @@ where t0.a in ( select t1.a from t1,t2 where t2.a=t0.a and t1.b=t2.b); id select_type table type possible_keys key key_len ref rows filtered Extra 1 PRIMARY t0 ALL NULL NULL NULL NULL 5 100.00 Using where -1 PRIMARY t1 ref a a 5 test.t0.a 1 100.00 Start temporary -1 PRIMARY t2 eq_ref PRIMARY PRIMARY 4 test.t0.a 1 100.00 Using where; End temporary +1 PRIMARY t2 eq_ref PRIMARY PRIMARY 4 test.t0.a 1 100.00 +1 PRIMARY t1 ref a a 5 test.t0.a 1 100.00 Using where; FirstMatch(t2) Warnings: Note 1276 Field or reference 'test.t0.a' of SELECT #2 was resolved in SELECT #1 -Note 1003 select `test`.`t0`.`a` AS `a` from `test`.`t2` semi join (`test`.`t1`) join `test`.`t0` where ((`test`.`t2`.`b` = `test`.`t1`.`b`) and (`test`.`t1`.`a` = `test`.`t0`.`a`) and (`test`.`t2`.`a` = `test`.`t0`.`a`)) +Note 1003 select `test`.`t0`.`a` AS `a` from `test`.`t2` semi join (`test`.`t1`) join `test`.`t0` where ((`test`.`t1`.`b` = `test`.`t2`.`b`) and (`test`.`t2`.`a` = `test`.`t0`.`a`) and (`test`.`t1`.`a` = `test`.`t0`.`a`)) update t1 set a=3, b=11 where a=4; update t2 set b=11 where a=3; select * from t0 where t0.a in @@ -744,4 +759,118 @@ LEFT JOIN t2 AS SQ4_alias3 ON SQ4_alias3.f10 GROUP BY field2; field2 drop table t1, t2, t3; +# +# BUG#849763: Wrong result with second execution of prepared statement with semijoin + view +# +CREATE TABLE t1 ( c varchar(1)) engine=innodb; +INSERT INTO t1 VALUES ('r'); +CREATE TABLE t2 ( a integer, b varchar(1), c varchar(1)) engine=innodb; +INSERT INTO t2 VALUES (1,'r','r'); +CREATE OR REPLACE VIEW v1 AS SELECT * FROM t1; +PREPARE st1 FROM 'SELECT * FROM t2 WHERE a = SOME (SELECT a FROM v1 WHERE v1.c = t2.c)'; +EXECUTE st1; +a b c +1 r r +EXECUTE st1; +a b c +1 r r +DROP VIEW v1; +DROP TABLE t1, t2; +# +# BUG#858732: Wrong result with semijoin + loosescan + comma join +# +CREATE TABLE t1 (f13 int(11) NOT NULL , PRIMARY KEY (f13)) ENGINE=InnoDB; +INSERT INTO t1 VALUES (16),(24); +CREATE TABLE t2 (f14 int(11) NOT NULL, f12 varchar(1) NOT NULL, KEY (f12,f14)) ENGINE=InnoDB; +INSERT INTO t2 VALUES (6,'y'); +CREATE TABLE t3 (f12 varchar(1) NOT NULL) ENGINE=InnoDB; +INSERT INTO t3 VALUES ('r'),('s'),('t'),('v'),('w'),('x'),('y'); +# The following must use LooseScan but not join buffering +explain +SELECT * FROM t3 +WHERE f12 IN (SELECT alias2.f12 FROM t1 AS alias1, t2 AS alias2, t1 WHERE alias1.f13 = 24); +id select_type table type possible_keys key key_len ref rows Extra +1 PRIMARY alias1 const PRIMARY PRIMARY 4 const 1 Using index +1 PRIMARY alias2 index f12 f12 7 NULL 1 Using index; LooseScan +1 PRIMARY t1 index NULL PRIMARY 4 NULL 2 Using index; FirstMatch(alias2) +1 PRIMARY t3 ALL NULL NULL NULL NULL 7 Using where; Using join buffer (flat, BNL join) +SELECT * FROM t3 +WHERE f12 IN (SELECT alias2.f12 FROM t1 AS alias1, t2 AS alias2, t1 WHERE alias1.f13 = 24); +f12 +y +DROP TABLE t1,t2,t3; +# +# BUG#869012: Wrong result with semijoin + materialization + AND in WHERE +# +CREATE TABLE t1 (f3 varchar(1) , f4 varchar(1) ) engine=InnoDB; +INSERT IGNORE INTO t1 VALUES ('x','x'),('x','x'); +CREATE TABLE t2 ( f4 varchar(1) ) ; +INSERT IGNORE INTO t2 VALUES ('g'); +CREATE TABLE t3 (f4 varchar(1) ) Engine=InnoDB; +INSERT IGNORE INTO t3 VALUES ('x'); +set @tmp_869012=@@optimizer_switch; +SET optimizer_switch='semijoin=on,materialization=on'; +SELECT * +FROM t1 , t2 +WHERE ( t1.f4 ) IN ( SELECT f4 FROM t3 ) +AND t2.f4 != t1.f3 ; +f3 f4 f4 +x x g +x x g +set optimizer_switch= @tmp_869012; +DROP TABLE t1,t2,t3; +# +# BUG#869001: Wrong result with semijoin + materialization + firstmatch + multipart key +# +set @tmp869001_jcl= @@join_cache_level; +set @tmp869001_os= @@optimizer_switch; +SET join_cache_level=0; +SET optimizer_switch='materialization=on,semijoin=on,firstmatch=on,loosescan=off'; +CREATE TABLE t1 ( f2 int, f3 varchar(1), KEY (f3,f2)) engine=innodb; +INSERT INTO t1 VALUES (8,'x'),(NULL,'x'),(8,'c'); +CREATE TABLE t2 ( f4 varchar(1)) engine=innodb; +INSERT INTO t2 VALUES ('x'); +CREATE TABLE t3 ( f1 int) engine=innodb; +INSERT INTO t3 VALUES (8),(6),(2),(9),(6); +CREATE TABLE t4 ( f3 varchar(1)) engine=innodb; +INSERT INTO t4 VALUES ('p'),('j'),('c'); +SELECT * +FROM t1 JOIN t2 ON (t2.f4 = t1.f3 ) +WHERE ( 8 ) IN ( +SELECT t3.f1 FROM t3 , t4 +); +f2 f3 f4 +NULL x x +8 x x +DROP TABLE t1, t2, t3, t4; +set join_cache_level= @tmp869001_jcl; +set optimizer_switch= @tmp869001_os; +# +# Bug #881318: join cache + duplicate elimination + left join +# with empty materialized derived inner table +# +CREATE TABLE t1 (b varchar(1)) ENGINE=InnoDB; +CREATE TABLE t2 (a varchar(1)) ENGINE=InnoDB; +INSERT INTO t2 VALUES ('a'); +CREATE TABLE t3 (a varchar(1), b varchar(1)) ENGINE=InnoDB; +INSERT INTO t3 VALUES ('c','c'); +CREATE TABLE t4 (b varchar(1)) ENGINE=InnoDB; +INSERT INTO t4 VALUES ('c'), ('b'); +CREATE ALGORITHM=TEMPTABLE VIEW v1 AS SELECT * FROM t1; +EXPLAIN +SELECT * FROM t3 LEFT JOIN (v1,t2) ON t3.a = t2.a +WHERE t3.b IN (SELECT b FROM t4); +id select_type table type possible_keys key key_len ref rows Extra +1 PRIMARY t3 ALL NULL NULL NULL NULL 1 Start temporary +1 PRIMARY t2 ALL NULL NULL NULL NULL 1 Using where +1 PRIMARY <derived3> ALL NULL NULL NULL NULL 2 +1 PRIMARY t4 ALL NULL NULL NULL NULL 2 Using where; End temporary +3 DERIVED t1 ALL NULL NULL NULL NULL 1 +SELECT * FROM t3 LEFT JOIN (v1,t2) ON t3.a = t2.a +WHERE t3.b IN (SELECT b FROM t4); +a b b a +c c NULL NULL +DROP VIEW v1; +DROP TABLE t1,t2,t3,t4; +# This must be the last in the file: set optimizer_switch=@subselect_sj2_tmp; diff --git a/mysql-test/r/subselect_sj2_jcl6.result b/mysql-test/r/subselect_sj2_jcl6.result index 4489b0dad25..f47fa06996e 100644 --- a/mysql-test/r/subselect_sj2_jcl6.result +++ b/mysql-test/r/subselect_sj2_jcl6.result @@ -25,6 +25,7 @@ b int, key(b) ); insert into t2 select a, a/2 from t0; +insert into t2 select a+10, a+10/2 from t0; select * from t1; a b 1 1 @@ -42,6 +43,16 @@ a b 7 4 8 4 9 5 +10 5 +11 6 +12 7 +13 8 +14 9 +15 10 +16 11 +17 12 +18 13 +19 14 explain select * from t2 where b in (select a from t1); id select_type table type possible_keys key key_len ref rows Extra 1 PRIMARY t1 ALL NULL NULL NULL NULL 3 Using where; Start temporary @@ -60,6 +71,7 @@ pk1 char(200), pk2 char(200), pk3 char(200), primary key(pk1, pk2, pk3) ) engine=innodb; insert into t3 select a,a, a,a,a from t0; +insert into t3 select a,a, a+100,a+100,a+100 from t0; explain select * from t3 where b in (select a from t1); id select_type table type possible_keys key key_len ref rows Extra 1 PRIMARY t1 ALL NULL NULL NULL NULL 3 Using where; Start temporary @@ -67,6 +79,8 @@ id select_type table type possible_keys key key_len ref rows Extra select * from t3 where b in (select a from t1); a b pk1 pk2 pk3 1 1 1 1 1 +1 1 101 101 101 +2 2 102 102 102 2 2 2 2 2 set @save_max_heap_table_size= @@max_heap_table_size; set max_heap_table_size=16384; @@ -426,6 +440,7 @@ create table t0 (a int); insert into t0 values (0),(1),(2),(3),(4); create table t1 (a int, b int, key(a)); insert into t1 select a,a from t0; +insert into t1 select a+5,a from t0; create table t2 (a int, b int, primary key(a)); insert into t2 select * from t1; Table t2, unlike table t1, should be displayed as pulled out @@ -433,12 +448,12 @@ explain extended select * from t0 where t0.a in ( select t1.a from t1,t2 where t2.a=t0.a and t1.b=t2.b); id select_type table type possible_keys key key_len ref rows filtered Extra -1 PRIMARY t0 ALL NULL NULL NULL NULL 5 100.00 Using where; Start temporary -1 PRIMARY t1 ref a a 5 test.t0.a 1 100.00 Using join buffer (flat, BKA join); Key-ordered Rowid-ordered scan -1 PRIMARY t2 eq_ref PRIMARY PRIMARY 4 test.t0.a 1 100.00 Using where; End temporary; Using join buffer (incremental, BKA join); Key-ordered Rowid-ordered scan +1 PRIMARY t0 ALL NULL NULL NULL NULL 5 100.00 Using where +1 PRIMARY t2 eq_ref PRIMARY PRIMARY 4 test.t0.a 1 100.00 Using join buffer (flat, BKA join); Key-ordered Rowid-ordered scan +1 PRIMARY t1 ref a a 5 test.t0.a 1 100.00 Using where; FirstMatch(t2); Using join buffer (incremental, BKA join); Key-ordered Rowid-ordered scan Warnings: Note 1276 Field or reference 'test.t0.a' of SELECT #2 was resolved in SELECT #1 -Note 1003 select `test`.`t0`.`a` AS `a` from `test`.`t2` semi join (`test`.`t1`) join `test`.`t0` where ((`test`.`t2`.`b` = `test`.`t1`.`b`) and (`test`.`t1`.`a` = `test`.`t0`.`a`) and (`test`.`t2`.`a` = `test`.`t0`.`a`)) +Note 1003 select `test`.`t0`.`a` AS `a` from `test`.`t2` semi join (`test`.`t1`) join `test`.`t0` where ((`test`.`t1`.`b` = `test`.`t2`.`b`) and (`test`.`t2`.`a` = `test`.`t0`.`a`) and (`test`.`t1`.`a` = `test`.`t0`.`a`)) update t1 set a=3, b=11 where a=4; update t2 set b=11 where a=3; # Not anymore: @@ -755,6 +770,120 @@ LEFT JOIN t2 AS SQ4_alias3 ON SQ4_alias3.f10 GROUP BY field2; field2 drop table t1, t2, t3; +# +# BUG#849763: Wrong result with second execution of prepared statement with semijoin + view +# +CREATE TABLE t1 ( c varchar(1)) engine=innodb; +INSERT INTO t1 VALUES ('r'); +CREATE TABLE t2 ( a integer, b varchar(1), c varchar(1)) engine=innodb; +INSERT INTO t2 VALUES (1,'r','r'); +CREATE OR REPLACE VIEW v1 AS SELECT * FROM t1; +PREPARE st1 FROM 'SELECT * FROM t2 WHERE a = SOME (SELECT a FROM v1 WHERE v1.c = t2.c)'; +EXECUTE st1; +a b c +1 r r +EXECUTE st1; +a b c +1 r r +DROP VIEW v1; +DROP TABLE t1, t2; +# +# BUG#858732: Wrong result with semijoin + loosescan + comma join +# +CREATE TABLE t1 (f13 int(11) NOT NULL , PRIMARY KEY (f13)) ENGINE=InnoDB; +INSERT INTO t1 VALUES (16),(24); +CREATE TABLE t2 (f14 int(11) NOT NULL, f12 varchar(1) NOT NULL, KEY (f12,f14)) ENGINE=InnoDB; +INSERT INTO t2 VALUES (6,'y'); +CREATE TABLE t3 (f12 varchar(1) NOT NULL) ENGINE=InnoDB; +INSERT INTO t3 VALUES ('r'),('s'),('t'),('v'),('w'),('x'),('y'); +# The following must use LooseScan but not join buffering +explain +SELECT * FROM t3 +WHERE f12 IN (SELECT alias2.f12 FROM t1 AS alias1, t2 AS alias2, t1 WHERE alias1.f13 = 24); +id select_type table type possible_keys key key_len ref rows Extra +1 PRIMARY alias1 const PRIMARY PRIMARY 4 const 1 Using index +1 PRIMARY alias2 index f12 f12 7 NULL 1 Using index; LooseScan +1 PRIMARY t1 index NULL PRIMARY 4 NULL 2 Using index; FirstMatch(alias2) +1 PRIMARY t3 ALL NULL NULL NULL NULL 7 Using where; Using join buffer (flat, BNL join) +SELECT * FROM t3 +WHERE f12 IN (SELECT alias2.f12 FROM t1 AS alias1, t2 AS alias2, t1 WHERE alias1.f13 = 24); +f12 +y +DROP TABLE t1,t2,t3; +# +# BUG#869012: Wrong result with semijoin + materialization + AND in WHERE +# +CREATE TABLE t1 (f3 varchar(1) , f4 varchar(1) ) engine=InnoDB; +INSERT IGNORE INTO t1 VALUES ('x','x'),('x','x'); +CREATE TABLE t2 ( f4 varchar(1) ) ; +INSERT IGNORE INTO t2 VALUES ('g'); +CREATE TABLE t3 (f4 varchar(1) ) Engine=InnoDB; +INSERT IGNORE INTO t3 VALUES ('x'); +set @tmp_869012=@@optimizer_switch; +SET optimizer_switch='semijoin=on,materialization=on'; +SELECT * +FROM t1 , t2 +WHERE ( t1.f4 ) IN ( SELECT f4 FROM t3 ) +AND t2.f4 != t1.f3 ; +f3 f4 f4 +x x g +x x g +set optimizer_switch= @tmp_869012; +DROP TABLE t1,t2,t3; +# +# BUG#869001: Wrong result with semijoin + materialization + firstmatch + multipart key +# +set @tmp869001_jcl= @@join_cache_level; +set @tmp869001_os= @@optimizer_switch; +SET join_cache_level=0; +SET optimizer_switch='materialization=on,semijoin=on,firstmatch=on,loosescan=off'; +CREATE TABLE t1 ( f2 int, f3 varchar(1), KEY (f3,f2)) engine=innodb; +INSERT INTO t1 VALUES (8,'x'),(NULL,'x'),(8,'c'); +CREATE TABLE t2 ( f4 varchar(1)) engine=innodb; +INSERT INTO t2 VALUES ('x'); +CREATE TABLE t3 ( f1 int) engine=innodb; +INSERT INTO t3 VALUES (8),(6),(2),(9),(6); +CREATE TABLE t4 ( f3 varchar(1)) engine=innodb; +INSERT INTO t4 VALUES ('p'),('j'),('c'); +SELECT * +FROM t1 JOIN t2 ON (t2.f4 = t1.f3 ) +WHERE ( 8 ) IN ( +SELECT t3.f1 FROM t3 , t4 +); +f2 f3 f4 +NULL x x +8 x x +DROP TABLE t1, t2, t3, t4; +set join_cache_level= @tmp869001_jcl; +set optimizer_switch= @tmp869001_os; +# +# Bug #881318: join cache + duplicate elimination + left join +# with empty materialized derived inner table +# +CREATE TABLE t1 (b varchar(1)) ENGINE=InnoDB; +CREATE TABLE t2 (a varchar(1)) ENGINE=InnoDB; +INSERT INTO t2 VALUES ('a'); +CREATE TABLE t3 (a varchar(1), b varchar(1)) ENGINE=InnoDB; +INSERT INTO t3 VALUES ('c','c'); +CREATE TABLE t4 (b varchar(1)) ENGINE=InnoDB; +INSERT INTO t4 VALUES ('c'), ('b'); +CREATE ALGORITHM=TEMPTABLE VIEW v1 AS SELECT * FROM t1; +EXPLAIN +SELECT * FROM t3 LEFT JOIN (v1,t2) ON t3.a = t2.a +WHERE t3.b IN (SELECT b FROM t4); +id select_type table type possible_keys key key_len ref rows Extra +1 PRIMARY t3 ALL NULL NULL NULL NULL 1 Using where; Start temporary +1 PRIMARY t2 hash_ALL NULL #hash#$hj 5 test.t3.a 1 Using where; Using join buffer (flat, BNLH join) +1 PRIMARY <derived3> ALL NULL NULL NULL NULL 2 Using join buffer (incremental, BNL join) +1 PRIMARY t4 hash_ALL NULL #hash#$hj 5 test.t3.b 2 Using where; End temporary; Using join buffer (incremental, BNLH join) +3 DERIVED t1 ALL NULL NULL NULL NULL 1 +SELECT * FROM t3 LEFT JOIN (v1,t2) ON t3.a = t2.a +WHERE t3.b IN (SELECT b FROM t4); +a b b a +c c NULL NULL +DROP VIEW v1; +DROP TABLE t1,t2,t3,t4; +# This must be the last in the file: set optimizer_switch=@subselect_sj2_tmp; set join_cache_level=default; show variables like 'join_cache_level'; diff --git a/mysql-test/r/subselect_sj2_mat.result b/mysql-test/r/subselect_sj2_mat.result index 8cd0101278c..a07f43dd288 100644 --- a/mysql-test/r/subselect_sj2_mat.result +++ b/mysql-test/r/subselect_sj2_mat.result @@ -18,6 +18,7 @@ b int, key(b) ); insert into t2 select a, a/2 from t0; +insert into t2 select a+10, a+10/2 from t0; select * from t1; a b 1 1 @@ -35,6 +36,16 @@ a b 7 4 8 4 9 5 +10 5 +11 6 +12 7 +13 8 +14 9 +15 10 +16 11 +17 12 +18 13 +19 14 explain select * from t2 where b in (select a from t1); id select_type table type possible_keys key key_len ref rows Extra 1 PRIMARY <subquery2> ALL distinct_key NULL NULL NULL 3 @@ -54,14 +65,17 @@ pk1 char(200), pk2 char(200), pk3 char(200), primary key(pk1, pk2, pk3) ) engine=innodb; insert into t3 select a,a, a,a,a from t0; +insert into t3 select a,a, a+100,a+100,a+100 from t0; explain select * from t3 where b in (select a from t1); id select_type table type possible_keys key key_len ref rows Extra -1 PRIMARY t3 ALL b NULL NULL NULL 10 +1 PRIMARY t3 ALL b NULL NULL NULL 20 1 PRIMARY <subquery2> eq_ref distinct_key distinct_key 5 func 1 2 SUBQUERY t1 ALL NULL NULL NULL NULL 3 select * from t3 where b in (select a from t1); a b pk1 pk2 pk3 1 1 1 1 1 +1 1 101 101 101 +2 2 102 102 102 2 2 2 2 2 set @save_max_heap_table_size= @@max_heap_table_size; set max_heap_table_size=16384; @@ -103,9 +117,8 @@ set join_buffer_size= @save_join_buffer_size; set max_heap_table_size= @save_max_heap_table_size; explain select * from t1 where a in (select b from t2); id select_type table type possible_keys key key_len ref rows Extra -1 PRIMARY t1 ALL NULL NULL NULL NULL 3 -1 PRIMARY <subquery2> eq_ref distinct_key distinct_key 5 func 1 -2 SUBQUERY t2 index b b 5 NULL 10 Using index +1 PRIMARY t1 ALL NULL NULL NULL NULL 3 Using where +1 PRIMARY t2 ref b b 5 test.t1.a 2 Using index; FirstMatch(t1) select * from t1; a b 1 1 @@ -275,7 +288,7 @@ from t0 where a in (select t2.a+t3.a from t1 left join (t2 join t3) on t2.a=t1.a and t3.a=t1.a); id select_type table type possible_keys key key_len ref rows Extra 1 PRIMARY t0 ALL NULL NULL NULL NULL 10 -1 PRIMARY <subquery2> eq_ref distinct_key distinct_key 9 func 1 +1 PRIMARY <subquery2> eq_ref distinct_key distinct_key 9 func 1 Using where 2 SUBQUERY t1 index a a 5 NULL 10 Using where; Using index 2 SUBQUERY t2 ref a a 5 test.t1.a 1 Using index 2 SUBQUERY t3 ref a a 5 test.t1.a 1 Using index @@ -429,6 +442,7 @@ create table t0 (a int); insert into t0 values (0),(1),(2),(3),(4); create table t1 (a int, b int, key(a)); insert into t1 select a,a from t0; +insert into t1 select a+5,a from t0; create table t2 (a int, b int, primary key(a)); insert into t2 select * from t1; Table t2, unlike table t1, should be displayed as pulled out @@ -437,11 +451,11 @@ where t0.a in ( select t1.a from t1,t2 where t2.a=t0.a and t1.b=t2.b); id select_type table type possible_keys key key_len ref rows filtered Extra 1 PRIMARY t0 ALL NULL NULL NULL NULL 5 100.00 Using where -1 PRIMARY t1 ref a a 5 test.t0.a 1 100.00 Start temporary -1 PRIMARY t2 eq_ref PRIMARY PRIMARY 4 test.t0.a 1 100.00 Using where; End temporary +1 PRIMARY t2 eq_ref PRIMARY PRIMARY 4 test.t0.a 1 100.00 +1 PRIMARY t1 ref a a 5 test.t0.a 1 100.00 Using where; FirstMatch(t2) Warnings: Note 1276 Field or reference 'test.t0.a' of SELECT #2 was resolved in SELECT #1 -Note 1003 select `test`.`t0`.`a` AS `a` from `test`.`t2` semi join (`test`.`t1`) join `test`.`t0` where ((`test`.`t2`.`b` = `test`.`t1`.`b`) and (`test`.`t1`.`a` = `test`.`t0`.`a`) and (`test`.`t2`.`a` = `test`.`t0`.`a`)) +Note 1003 select `test`.`t0`.`a` AS `a` from `test`.`t2` semi join (`test`.`t1`) join `test`.`t0` where ((`test`.`t1`.`b` = `test`.`t2`.`b`) and (`test`.`t2`.`a` = `test`.`t0`.`a`) and (`test`.`t1`.`a` = `test`.`t0`.`a`)) update t1 set a=3, b=11 where a=4; update t2 set b=11 where a=3; select * from t0 where t0.a in @@ -590,7 +604,7 @@ select * from t1 left join t2 on (t2.a= t1.a and t2.a in (select pk from t3)); id select_type table type possible_keys key key_len ref rows Extra 1 PRIMARY t1 ALL NULL NULL NULL NULL 3 1 PRIMARY t2 ALL NULL NULL NULL NULL 3 Using where -2 DEPENDENT SUBQUERY t3 unique_subquery PRIMARY PRIMARY 4 func 1 Using index +2 SUBQUERY t3 index PRIMARY PRIMARY 4 NULL 10 Using index drop table t0, t1, t2, t3; create table t1 (a int); insert into t1 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9); @@ -757,6 +771,121 @@ LEFT JOIN t2 AS SQ4_alias3 ON SQ4_alias3.f10 GROUP BY field2; field2 drop table t1, t2, t3; +# +# BUG#849763: Wrong result with second execution of prepared statement with semijoin + view +# +CREATE TABLE t1 ( c varchar(1)) engine=innodb; +INSERT INTO t1 VALUES ('r'); +CREATE TABLE t2 ( a integer, b varchar(1), c varchar(1)) engine=innodb; +INSERT INTO t2 VALUES (1,'r','r'); +CREATE OR REPLACE VIEW v1 AS SELECT * FROM t1; +PREPARE st1 FROM 'SELECT * FROM t2 WHERE a = SOME (SELECT a FROM v1 WHERE v1.c = t2.c)'; +EXECUTE st1; +a b c +1 r r +EXECUTE st1; +a b c +1 r r +DROP VIEW v1; +DROP TABLE t1, t2; +# +# BUG#858732: Wrong result with semijoin + loosescan + comma join +# +CREATE TABLE t1 (f13 int(11) NOT NULL , PRIMARY KEY (f13)) ENGINE=InnoDB; +INSERT INTO t1 VALUES (16),(24); +CREATE TABLE t2 (f14 int(11) NOT NULL, f12 varchar(1) NOT NULL, KEY (f12,f14)) ENGINE=InnoDB; +INSERT INTO t2 VALUES (6,'y'); +CREATE TABLE t3 (f12 varchar(1) NOT NULL) ENGINE=InnoDB; +INSERT INTO t3 VALUES ('r'),('s'),('t'),('v'),('w'),('x'),('y'); +# The following must use LooseScan but not join buffering +explain +SELECT * FROM t3 +WHERE f12 IN (SELECT alias2.f12 FROM t1 AS alias1, t2 AS alias2, t1 WHERE alias1.f13 = 24); +id select_type table type possible_keys key key_len ref rows Extra +1 PRIMARY alias1 const PRIMARY PRIMARY 4 const 1 Using index +1 PRIMARY alias2 index f12 f12 7 NULL 1 Using index; LooseScan +1 PRIMARY t1 index NULL PRIMARY 4 NULL 2 Using index; FirstMatch(alias2) +1 PRIMARY t3 ALL NULL NULL NULL NULL 7 Using where; Using join buffer (flat, BNL join) +SELECT * FROM t3 +WHERE f12 IN (SELECT alias2.f12 FROM t1 AS alias1, t2 AS alias2, t1 WHERE alias1.f13 = 24); +f12 +y +DROP TABLE t1,t2,t3; +# +# BUG#869012: Wrong result with semijoin + materialization + AND in WHERE +# +CREATE TABLE t1 (f3 varchar(1) , f4 varchar(1) ) engine=InnoDB; +INSERT IGNORE INTO t1 VALUES ('x','x'),('x','x'); +CREATE TABLE t2 ( f4 varchar(1) ) ; +INSERT IGNORE INTO t2 VALUES ('g'); +CREATE TABLE t3 (f4 varchar(1) ) Engine=InnoDB; +INSERT IGNORE INTO t3 VALUES ('x'); +set @tmp_869012=@@optimizer_switch; +SET optimizer_switch='semijoin=on,materialization=on'; +SELECT * +FROM t1 , t2 +WHERE ( t1.f4 ) IN ( SELECT f4 FROM t3 ) +AND t2.f4 != t1.f3 ; +f3 f4 f4 +x x g +x x g +set optimizer_switch= @tmp_869012; +DROP TABLE t1,t2,t3; +# +# BUG#869001: Wrong result with semijoin + materialization + firstmatch + multipart key +# +set @tmp869001_jcl= @@join_cache_level; +set @tmp869001_os= @@optimizer_switch; +SET join_cache_level=0; +SET optimizer_switch='materialization=on,semijoin=on,firstmatch=on,loosescan=off'; +CREATE TABLE t1 ( f2 int, f3 varchar(1), KEY (f3,f2)) engine=innodb; +INSERT INTO t1 VALUES (8,'x'),(NULL,'x'),(8,'c'); +CREATE TABLE t2 ( f4 varchar(1)) engine=innodb; +INSERT INTO t2 VALUES ('x'); +CREATE TABLE t3 ( f1 int) engine=innodb; +INSERT INTO t3 VALUES (8),(6),(2),(9),(6); +CREATE TABLE t4 ( f3 varchar(1)) engine=innodb; +INSERT INTO t4 VALUES ('p'),('j'),('c'); +SELECT * +FROM t1 JOIN t2 ON (t2.f4 = t1.f3 ) +WHERE ( 8 ) IN ( +SELECT t3.f1 FROM t3 , t4 +); +f2 f3 f4 +NULL x x +8 x x +DROP TABLE t1, t2, t3, t4; +set join_cache_level= @tmp869001_jcl; +set optimizer_switch= @tmp869001_os; +# +# Bug #881318: join cache + duplicate elimination + left join +# with empty materialized derived inner table +# +CREATE TABLE t1 (b varchar(1)) ENGINE=InnoDB; +CREATE TABLE t2 (a varchar(1)) ENGINE=InnoDB; +INSERT INTO t2 VALUES ('a'); +CREATE TABLE t3 (a varchar(1), b varchar(1)) ENGINE=InnoDB; +INSERT INTO t3 VALUES ('c','c'); +CREATE TABLE t4 (b varchar(1)) ENGINE=InnoDB; +INSERT INTO t4 VALUES ('c'), ('b'); +CREATE ALGORITHM=TEMPTABLE VIEW v1 AS SELECT * FROM t1; +EXPLAIN +SELECT * FROM t3 LEFT JOIN (v1,t2) ON t3.a = t2.a +WHERE t3.b IN (SELECT b FROM t4); +id select_type table type possible_keys key key_len ref rows Extra +1 PRIMARY t3 ALL NULL NULL NULL NULL 1 +1 PRIMARY t2 ALL NULL NULL NULL NULL 1 Using where +1 PRIMARY <derived3> ALL NULL NULL NULL NULL 2 +1 PRIMARY <subquery2> eq_ref distinct_key distinct_key 5 func 1 +2 SUBQUERY t4 ALL NULL NULL NULL NULL 2 +3 DERIVED t1 ALL NULL NULL NULL NULL 1 +SELECT * FROM t3 LEFT JOIN (v1,t2) ON t3.a = t2.a +WHERE t3.b IN (SELECT b FROM t4); +a b b a +c c NULL NULL +DROP VIEW v1; +DROP TABLE t1,t2,t3,t4; +# This must be the last in the file: set optimizer_switch=@subselect_sj2_tmp; set optimizer_switch=default; select @@optimizer_switch like '%materialization=on%'; diff --git a/mysql-test/r/subselect_sj_jcl6.result b/mysql-test/r/subselect_sj_jcl6.result index 10a1cb47cf1..17ed56092c3 100644 --- a/mysql-test/r/subselect_sj_jcl6.result +++ b/mysql-test/r/subselect_sj_jcl6.result @@ -9,7 +9,7 @@ set join_cache_level=6; show variables like 'join_cache_level'; Variable_name Value join_cache_level 6 -drop table if exists t0, t1, t2, t3, t4, t10, t11, t12; +drop table if exists t0, t1, t2, t3, t4, t5, t10, t11, t12; drop view if exists v1, v2, v3, v4; drop procedure if exists p1; set @subselect_sj_tmp= @@optimizer_switch; @@ -772,11 +772,11 @@ id select_type table type possible_keys key key_len ref rows filtered Extra 3 DEPENDENT SUBQUERY t3 ALL NULL NULL NULL NULL 4 100.00 Using where Warnings: Note 1276 Field or reference 'test.t1.b' of SELECT #3 was resolved in SELECT #1 -Note 1003 select `test`.`t1`.`a` AS `a` from `test`.`t1` semi join (`test`.`t2`) where ((`test`.`t1`.`a` = `test`.`t2`.`c`) and <nop>(<in_optimizer>(`test`.`t2`.`d`,<exists>(select `test`.`t3`.`e` from `test`.`t3` where ((`test`.`t1`.`b` = `test`.`t3`.`e`) and (<cache>(`test`.`t2`.`d`) >= `test`.`t3`.`e`)))))) +Note 1003 select `test`.`t1`.`a` AS `a` from `test`.`t1` semi join (`test`.`t2`) where ((`test`.`t1`.`a` = `test`.`t2`.`c`) and <nop>(<expr_cache><`test`.`t2`.`d`,`test`.`t1`.`b`>(<in_optimizer>(`test`.`t2`.`d`,<exists>(select `test`.`t3`.`e` from `test`.`t3` where ((`test`.`t1`.`b` = `test`.`t3`.`e`) and (<cache>(`test`.`t2`.`d`) >= `test`.`t3`.`e`))))))) show warnings; Level Code Message Note 1276 Field or reference 'test.t1.b' of SELECT #3 was resolved in SELECT #1 -Note 1003 select `test`.`t1`.`a` AS `a` from `test`.`t1` semi join (`test`.`t2`) where ((`test`.`t1`.`a` = `test`.`t2`.`c`) and <nop>(<in_optimizer>(`test`.`t2`.`d`,<exists>(select `test`.`t3`.`e` from `test`.`t3` where ((`test`.`t1`.`b` = `test`.`t3`.`e`) and (<cache>(`test`.`t2`.`d`) >= `test`.`t3`.`e`)))))) +Note 1003 select `test`.`t1`.`a` AS `a` from `test`.`t1` semi join (`test`.`t2`) where ((`test`.`t1`.`a` = `test`.`t2`.`c`) and <nop>(<expr_cache><`test`.`t2`.`d`,`test`.`t1`.`b`>(<in_optimizer>(`test`.`t2`.`d`,<exists>(select `test`.`t3`.`e` from `test`.`t3` where ((`test`.`t1`.`b` = `test`.`t3`.`e`) and (<cache>(`test`.`t2`.`d`) >= `test`.`t3`.`e`))))))) select a from t1 where a in (select c from t2 where d >= some(select e from t3 where b=e)); a @@ -1750,6 +1750,327 @@ c1 c2 2 7 5 6 DROP TABLE t1, t2, t3; +# +# BUG#834534: Assertion `0' failed in replace_where_subcondition with semijoin subquery in HAVING +# +CREATE TABLE t1 ( d int ); +INSERT INTO t1 VALUES (2),(2),(0),(2),(2); +CREATE TABLE t2 ( b int ); +INSERT INTO t2 VALUES (4),(3),(3); +CREATE TABLE t3 ( a int ); +SELECT * +FROM t3 +WHERE (t3.a) IN ( +SELECT t1.d +FROM t1 +HAVING ( 4 ) IN ( +SELECT t2.b +FROM t2 +) +); +a +drop table t1, t2,t3; +# +# BUG#834758: Wrong result with innner join, LooseScan, two-column IN() predicate +# +set @tmp835758=@@optimizer_switch; +set optimizer_switch='semijoin=on,loosescan=on,materialization=off,firstmatch=off'; +CREATE TABLE t1 (b int) ; +INSERT INTO t1 VALUES (1),(5); +CREATE TABLE t2 (a int, PRIMARY KEY (a)) ; +INSERT INTO t2 VALUES (6),(10); +CREATE TABLE t3 (a int, b int, KEY (b)) ; +INSERT INTO t3 VALUES (6,5),(6,2),(8,0),(9,1),(6,5); +# This used to incorrectly pick a join order of (t1, LooseScan(t3), t2): +explain +SELECT * FROM t1, t2 WHERE (t2.a , t1.b) IN (SELECT a, b FROM t3); +id select_type table type possible_keys key key_len ref rows Extra +1 PRIMARY t1 ALL NULL NULL NULL NULL 2 Start temporary +1 PRIMARY t2 index PRIMARY PRIMARY 4 NULL 2 Using index; Using join buffer (flat, BNL join) +1 PRIMARY t3 ALL b NULL NULL NULL 5 Using where; End temporary; Using join buffer (incremental, BNL join) +SELECT * FROM t1, t2 WHERE (t2.a , t1.b) IN (SELECT a, b FROM t3); +b a +5 6 +DROP TABLE t1, t2, t3; +set @@optimizer_switch= @tmp835758; +# +# BUG#834739: Wrong result with 3-way inner join, LooseScan,multipart keys +# +set @tmp834739=@@optimizer_switch; +set optimizer_switch='semijoin=on,loosescan=on,materialization=off,firstmatch=off'; +CREATE TABLE t2 ( b int, c int, KEY (b)) ; +INSERT INTO t2 VALUES (1,0),(1,0),(9,0),(1,0),(5,0); +INSERT INTO t2 VALUES (2,0),(3,0),(8,0),(6,0),(5,0); +CREATE TABLE t3 ( a int); +INSERT INTO t3 VALUES (0),(0),(0),(0),(0),(0),(0),(0),(0),(0),(0),(0),(0),(0),(0); +CREATE TABLE t4 ( a int); +INSERT INTO t4 VALUES (0),(0),(0); +CREATE TABLE t5 ( b int, a int , KEY (a,b)) ; +INSERT INTO t5 VALUES (7,0),(9,0); +explain +SELECT * FROM t3 WHERE t3.a IN (SELECT t5.a FROM t2, t4, t5 WHERE t2.c = t5.a AND t2.b = t5.b); +id select_type table type possible_keys key key_len ref rows Extra +1 PRIMARY t5 index a a 10 NULL 2 Using where; Using index; LooseScan +1 PRIMARY t4 ALL NULL NULL NULL NULL 3 +1 PRIMARY t2 ref b b 5 test.t5.b 2 Using where; FirstMatch(t5) +1 PRIMARY t3 ALL NULL NULL NULL NULL 15 Using where; Using join buffer (flat, BNL join) +SELECT * FROM t3 WHERE t3.a IN (SELECT t5.a FROM t2, t4, t5 WHERE t2.c = t5.a AND t2.b = t5.b); +a +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +DROP TABLE t2, t3, t4, t5; +set @@optimizer_switch=@tmp834739; +# +# BUG#830993: Crash in end_read_record with derived table +# +set @tmp_830993=@@optimizer_switch; +set optimizer_switch='semijoin=on,loosescan=off,materialization=off,firstmatch=off'; +set @tmp_830993_jbs= @@join_buffer_size; +set join_buffer_size=160; +CREATE TABLE t1 ( +a int(11) NOT NULL AUTO_INCREMENT, +b int(11) DEFAULT NULL, +c int(11) DEFAULT NULL, +d time DEFAULT NULL, +e varchar(1) DEFAULT NULL, +f varchar(1) DEFAULT NULL, +PRIMARY KEY (a), +KEY c (c), +KEY d (d), +KEY e (e,c) +); +INSERT INTO t1 VALUES (10,NULL,8,'22:55:23','x','x'), +(11,8,7,'10:19:31','d','d'),(12,1,1,'14:40:36','r','r'), +(13,9,7,'04:37:47','f','f'),(14,4,9,'19:34:06','y','y'), +(15,3,NULL,'20:35:33','u','u'),(16,2,1,NULL,'m','m'), +(17,NULL,9,'14:43:37',NULL,NULL),(18,2,2,'02:23:09','o','o'), +(19,NULL,9,'01:22:45','w','w'),(20,6,2,'00:00:00','m','m'), +(21,7,4,'00:13:25','q','q'),(22,2,0,'03:47:16',NULL,NULL), +(23,5,4,'01:41:48','d','d'),(24,7,8,'00:00:00','g','g'), +(25,6,NULL,'22:32:04','x','x'),(26,6,NULL,'16:44:14','f','f'), +(27,2,0,'17:38:37','p','p'),(28,9,NULL,'08:46:48','j','j'), +(29,6,8,'14:11:27','c','c'); +CREATE TABLE t2 like t1; +INSERT INTO t2 VALUES (1,2,4,'22:34:09','v','v'), +(2,150,62,'14:26:02','v','v'),(3,NULL,7,'14:03:03','c','c'), +(4,2,1,'01:46:09',NULL,NULL),(5,5,0,'16:21:18','x','x'), +(6,3,7,'18:56:33','i','i'),(7,1,7,NULL,'e','e'), +(8,4,1,'09:29:08','p','p'),(9,NULL,7,'19:11:10','s','s'), +(10,2,1,'11:57:26','j','j'),(11,6,5,'00:39:46','z','z'), +(12,6,2,'03:28:15','c','c'),(13,8,0,'06:44:18','a','a'), +(14,2,1,'14:36:39','q','q'),(15,6,8,'18:42:45','y','y'), +(16,8,1,'02:57:29',NULL,NULL),(17,3,1,'16:46:13','r','r'), +(18,3,9,'19:39:02','v','v'),(19,9,1,NULL,NULL,NULL), +(20,6,5,'20:58:33','r','r'); +explain +SELECT +alias1.a, alias1.b, alias1.c, alias1.d, alias1.e, alias1.f, +alias2.a as a2_a, alias2.b as a2_b, alias2.c as a2_c, alias2.d as a2_d, +alias2.e as a2_e, alias2.f as a2_f, +t2.a as t2_a, t2.b as t2_b, t2.c as t2_c, t2.d as t2_d, t2.e as t2_e, t2.f as t2_f +FROM +(SELECT * FROM t2) AS alias1, +t1 AS alias2, +t2 +WHERE +alias1.c IN (SELECT SQ3_alias1.b +FROM t2 AS SQ3_alias1 STRAIGHT_JOIN t2 AS SQ3_alias2) +LIMIT 100; +id select_type table type possible_keys key key_len ref rows Extra +1 PRIMARY <derived2> ALL NULL NULL NULL NULL 20 Start temporary +1 PRIMARY alias2 ALL NULL NULL NULL NULL 20 Using join buffer (flat, BNL join) +1 PRIMARY t2 ALL NULL NULL NULL NULL 20 Using join buffer (incremental, BNL join) +1 PRIMARY SQ3_alias1 ALL NULL NULL NULL NULL 20 Using where; Using join buffer (incremental, BNL join) +1 PRIMARY SQ3_alias2 index NULL PRIMARY 4 NULL 20 Using index; End temporary; Using join buffer (incremental, BNL join) +2 DERIVED t2 ALL NULL NULL NULL NULL 20 +create table t3 as +SELECT +alias1.a, alias1.b, alias1.c, alias1.d, alias1.e, alias1.f, +alias2.a as a2_a, alias2.b as a2_b, alias2.c as a2_c, alias2.d as a2_d, +alias2.e as a2_e, alias2.f as a2_f, +t2.a as t2_a, t2.b as t2_b, t2.c as t2_c, t2.d as t2_d, t2.e as t2_e, t2.f as t2_f +FROM +(SELECT * FROM t2) AS alias1, +t1 AS alias2, +t2 +WHERE +alias1.c IN (SELECT SQ3_alias1.b +FROM t2 AS SQ3_alias1 STRAIGHT_JOIN t2 AS SQ3_alias2) +LIMIT 100; +drop table t1,t2, t3; +set optimizer_switch=@tmp_830993; +set join_buffer_size= @tmp_830993_jbs; +# +# BUG##849717: Crash in Item_func::fix_fields on second execution of a prepared statement with semijoin +# +CREATE TABLE t1 (a int); +CREATE TABLE t2 (a int); +CREATE TABLE t3 (a int, b int) ; +PREPARE st1 FROM "SELECT * FROM t2 LEFT JOIN t1 ON t2.a != 0 AND ('j','r') IN ( SELECT b,a FROM t3)"; +EXECUTE st1; +a a +EXECUTE st1; +a a +DROP TABLE t1, t2, t3; +# +# BUG#849776: Wrong result with semijoin + "Impossible where" +# +CREATE TABLE t1 ( b varchar(1), a integer) ; +INSERT INTO t1 VALUES ('z',8); +CREATE TABLE t2 ( a integer, b varchar(1)) ; +CREATE TABLE t4 ( a integer, b varchar(1)) ; +CREATE TABLE t5 ( a integer) ; +INSERT INTO t5 VALUES (8); +select * from t5 where (a) in ( +SELECT t1.a +FROM t1 LEFT JOIN t2 ON t1.a = t2.a +WHERE t2.b NOT IN (SELECT t4.b FROM t4 WHERE t4.b < t1.b) +); +a +8 +DROP TABLE t1, t2, t4, t5; +# +# BUG#861147: Assertion `fixed == 1' failed in Item_func_eq::val_int() with semijoin + materialization + max_join_size +# +CREATE TABLE t1 ( f2 int) ; +CREATE TABLE t2 ( f1 int, f3 int, f4 varchar(3), f5 varchar(35)) ; +INSERT INTO t2 VALUES (4057,9,'USA','Visalia'),(3993,11,'USA','Waco'), +(3948,14,'USA','Warren'),(3813,57,'USA','Washington'), +(4010,11,'USA','Waterbury'),(4017,11,'USA','West Covina'), +(4004,11,'USA','West Valley City'),(4033,10,'USA','Westminster'), +(3842,34,'USA','Wichita'),(4018,10,'USA','Wichita Falls'), +(3899,19,'USA','Winston-Salem'),(3914,17,'USA','Worcester'), +(3888,20,'USA','Yonkers'); +CREATE TABLE t3 ( f3 int, f4 varchar(3)) ; +INSERT INTO t3 VALUES (86,'USA'); +CREATE TABLE t4 ( f3 int, f4 varchar(3), f5 varchar(52)) ; +INSERT INTO t4 VALUES (0,'RUS','Belorussian'),(0,'USA','Portuguese'); +CREATE TABLE t5 ( f2 int) ; +CREATE TABLE t6 ( f4 varchar(3)); +INSERT INTO t6 VALUES ('RUS'),('USA'); +set @tmp_mjs_861147= @@max_join_size; +SET max_join_size=10; +set @tmp_os_861147= @@optimizer_switch; +set @@optimizer_switch='semijoin=on,materialization=on'; +SELECT * +FROM t1 +WHERE ( 1 , 3 ) IN ( +SELECT t2.f1 , MAX( t3.f3 ) +FROM t2 +JOIN t3 +WHERE t3.f4 IN ( +SELECT t4.f5 +FROM t4 +STRAIGHT_JOIN t5 +WHERE t4.f4 < t2.f5 +) +) AND ( 'p' , 'k' ) IN ( +SELECT f4 , f4 FROM t6 +); +ERROR 42000: The SELECT would examine more than MAX_JOIN_SIZE rows; check your WHERE and use SET SQL_BIG_SELECTS=1 or SET MAX_JOIN_SIZE=# if the SELECT is okay +set max_join_size= @tmp_mjs_861147; +set optimizer_switch= @tmp_os_861147; +DROP TABLE t1,t2,t3,t4,t5,t6; +# +# BUG#877288: Wrong result with semijoin + materialization + multipart key +# +set @tmp_877288=@@optimizer_switch; +set optimizer_switch='semijoin=ON,materialization=ON'; +CREATE TABLE t1 ( a int) ; +INSERT INTO t1 VALUES (19),(19),(19),(20),(20),(20),(20),(20),(20); +CREATE TABLE t2 ( b int NOT NULL , c int NOT NULL , KEY (b,c)) ; +INSERT INTO t2 VALUES (14,1),(15,1),(16,1),(17,1),(18,1),(19,1),(20,1); +CREATE TABLE t3 ( a int, d int) ; +INSERT INTO t3 VALUES (19,1),(7,1),(3,1),(3,1),(20,1),(3,1),(16,1),(17,1),(9,1),(4,1),(6,1),(15,1),(17,1); +explain +SELECT * FROM t1 WHERE (a) IN (SELECT a FROM t2 JOIN t3 ON b = a); +id select_type table type possible_keys key key_len ref rows Extra +1 PRIMARY t1 ALL NULL NULL NULL NULL 9 +1 PRIMARY <subquery2> eq_ref distinct_key distinct_key 5 func 1 +2 SUBQUERY t3 ALL NULL NULL NULL NULL 13 Using where +2 SUBQUERY t2 ref b b 4 test.t3.a 1 Using index +SELECT * FROM t1 WHERE (a) IN (SELECT a FROM t2 JOIN t3 ON b = a); +a +19 +19 +19 +20 +20 +20 +20 +20 +20 +DROP TABLE t1,t2,t3; +set optimizer_switch=@tmp_877288; +# +# BUG#878753: Assertion '0' failed in replace_where_subcondition with derived_merge +# +set @tmp878753= @@optimizer_switch; +set optimizer_switch= 'semijoin=on,derived_merge=on'; +CREATE TABLE t1 (b int(11)) ; +CREATE TABLE t2 (c int, b int, d varchar(52) NOT NULL) ; +CREATE TABLE t3 (b int(11)) ; +PREPARE st1 FROM ' + SELECT * FROM t1 + JOIN ( + SELECT t2.* FROM t2 + WHERE t2.d <> "a" + AND t2.c IN ( + SELECT t3.b + FROM t3 + ) + ) AS alias2 + ON ( alias2.b = t1.b ); +'; +EXECUTE st1; +b c b d +DROP TABLE t1,t2,t3; +set optimizer_switch=@tmp878753; +# +# Bug #889750: semijoin=on + firstmatch=off + semijoin_with_cache=off +# +create table t1 (a int); +insert into t1 values (7), (1), (5), (3); +create table t2 (a int); +insert into t2 values (4), (1), (8), (3), (9), (2); +set @tmp_otimizer_switch= @@optimizer_switch; +set optimizer_switch='semijoin=on'; +set optimizer_switch='firstmatch=off'; +set optimizer_switch='semijoin_with_cache=on'; +explain +select * from t1 where t1.a in (select t2.a from t2); +id select_type table type possible_keys key key_len ref rows Extra +1 PRIMARY t1 ALL NULL NULL NULL NULL 4 Start temporary +1 PRIMARY t2 ALL NULL NULL NULL NULL 6 Using where; End temporary; Using join buffer (flat, BNL join) +select * from t1 where t1.a in (select t2.a from t2); +a +1 +3 +set optimizer_switch='semijoin_with_cache=off'; +explain +select * from t1 where t1.a in (select t2.a from t2); +id select_type table type possible_keys key key_len ref rows Extra +1 PRIMARY t1 ALL NULL NULL NULL NULL 4 Start temporary +1 PRIMARY t2 ALL NULL NULL NULL NULL 6 Using where; End temporary +select * from t1 where t1.a in (select t2.a from t2); +a +1 +3 +set optimizer_switch= @tmp_otimizer_switch; +drop table t1,t2; set optimizer_switch=@subselect_sj_tmp; # # BUG#49129: Wrong result with IN-subquery with join_cache_level=6 and firstmatch=off @@ -1758,6 +2079,8 @@ CREATE TABLE t0 (a INT); INSERT INTO t0 VALUES (0),(1),(2),(3),(4); CREATE TABLE t1 (a INT, b INT, KEY(a)); INSERT INTO t1 SELECT a, a from t0; +INSERT INTO t1 SELECT a+5, a from t0; +INSERT INTO t1 SELECT a+10, a from t0; CREATE TABLE t2 (a INT, b INT, PRIMARY KEY(a)); INSERT INTO t2 SELECT * FROM t1; UPDATE t1 SET a=3, b=11 WHERE a=4; diff --git a/mysql-test/r/subselect_sj_mat.result b/mysql-test/r/subselect_sj_mat.result index 97754415504..350d3fe62d7 100644 --- a/mysql-test/r/subselect_sj_mat.result +++ b/mysql-test/r/subselect_sj_mat.result @@ -1,8 +1,8 @@ set @subselect_sj_mat_tmp= @@optimizer_switch; -set optimizer_switch=ifnull(@subselect_mat_test_optimizer_switch_value, 'semijoin=on,firstmatch=on,loosescan=on'); +set optimizer_switch=ifnull(@subselect_mat_test_optimizer_switch_value, 'semijoin=on,firstmatch=on,loosescan=on,semijoin_with_cache=on'); set optimizer_switch='mrr=on,mrr_sort_keys=on,index_condition_pushdown=on'; set @optimizer_switch_local_default= @@optimizer_switch; -drop table if exists t1, t2, t3, t1i, t2i, t3i; +drop table if exists t1, t2, t3, t4, t5, t1i, t2i, t3i; drop table if exists columns; drop table if exists t1_16, t2_16, t3_16; drop view if exists v1, v2, v1m, v2m; @@ -349,7 +349,7 @@ id select_type table type possible_keys key key_len ref rows filtered Extra 4 SUBQUERY t3 ALL NULL NULL NULL NULL 4 100.00 Using where 3 SUBQUERY t3 ALL NULL NULL NULL NULL 4 100.00 Using where Warnings: -Note 1003 select `test`.`t1`.`a1` AS `a1`,`test`.`t1`.`a2` AS `a2` from `test`.`t1` semi join (`test`.`t2`) semi join (`test`.`t2i` join `test`.`t3`) where ((`test`.`t2i`.`b2` = `test`.`t3`.`c2`) and (`test`.`t2i`.`b1` = `test`.`t3`.`c1`) and (<in_optimizer>(`test`.`t2`.`b2`,`test`.`t2`.`b2` in ( <materialize> (select `test`.`t3`.`c2` from `test`.`t3` where (`test`.`t3`.`c2` like '%02') ), <primary_index_lookup>(`test`.`t2`.`b2` in <temporary table> on distinct_key where ((`test`.`t2`.`b2` = `<subquery3>`.`c2`))))) or <in_optimizer>(`test`.`t2`.`b2`,`test`.`t2`.`b2` in ( <materialize> (select `test`.`t3`.`c2` from `test`.`t3` where (`test`.`t3`.`c2` like '%03') ), <primary_index_lookup>(`test`.`t2`.`b2` in <temporary table> on distinct_key where ((`test`.`t2`.`b2` = `<subquery4>`.`c2`)))))) and (`test`.`t3`.`c2` > '0')) +Note 1003 select `test`.`t1`.`a1` AS `a1`,`test`.`t1`.`a2` AS `a2` from `test`.`t1` semi join (`test`.`t2`) semi join (`test`.`t2i` join `test`.`t3`) where ((`test`.`t2i`.`b2` = `test`.`t3`.`c2`) and (`test`.`t2i`.`b1` = `test`.`t3`.`c1`) and (<expr_cache><`test`.`t2`.`b2`>(<in_optimizer>(`test`.`t2`.`b2`,`test`.`t2`.`b2` in ( <materialize> (select `test`.`t3`.`c2` from `test`.`t3` where (`test`.`t3`.`c2` like '%02') ), <primary_index_lookup>(`test`.`t2`.`b2` in <temporary table> on distinct_key where ((`test`.`t2`.`b2` = `<subquery3>`.`c2`)))))) or <expr_cache><`test`.`t2`.`b2`>(<in_optimizer>(`test`.`t2`.`b2`,`test`.`t2`.`b2` in ( <materialize> (select `test`.`t3`.`c2` from `test`.`t3` where (`test`.`t3`.`c2` like '%03') ), <primary_index_lookup>(`test`.`t2`.`b2` in <temporary table> on distinct_key where ((`test`.`t2`.`b2` = `<subquery4>`.`c2`))))))) and (`test`.`t3`.`c2` > '0')) select * from t1 where (a1, a2) in (select b1, b2 from t2 where b2 in (select c2 from t3 where c2 LIKE '%02') or @@ -375,7 +375,7 @@ id select_type table type possible_keys key key_len ref rows filtered Extra 3 DEPENDENT SUBQUERY t3a ALL NULL NULL NULL NULL 4 100.00 Using where Warnings: Note 1276 Field or reference 'test.t1.a1' of SELECT #3 was resolved in SELECT #1 -Note 1003 select `test`.`t1`.`a1` AS `a1`,`test`.`t1`.`a2` AS `a2` from `test`.`t1` semi join (`test`.`t2`) semi join (`test`.`t2i` join `test`.`t3` `t3c`) where ((`test`.`t2`.`b2` = `test`.`t1`.`a2`) and (`test`.`t2i`.`b2` = `test`.`t3c`.`c2`) and (`test`.`t2`.`b1` = `test`.`t1`.`a1`) and (`test`.`t2i`.`b1` = `test`.`t3c`.`c1`) and (<in_optimizer>(`test`.`t2`.`b2`,<exists>(select `test`.`t3a`.`c2` from `test`.`t3` `t3a` where ((`test`.`t3a`.`c1` = `test`.`t1`.`a1`) and (<cache>(`test`.`t2`.`b2`) = `test`.`t3a`.`c2`)))) or <in_optimizer>(`test`.`t2`.`b2`,`test`.`t2`.`b2` in ( <materialize> (select `test`.`t3b`.`c2` from `test`.`t3` `t3b` where (`test`.`t3b`.`c2` like '%03') ), <primary_index_lookup>(`test`.`t2`.`b2` in <temporary table> on distinct_key where ((`test`.`t2`.`b2` = `<subquery4>`.`c2`)))))) and (`test`.`t3c`.`c2` > '0')) +Note 1003 select `test`.`t1`.`a1` AS `a1`,`test`.`t1`.`a2` AS `a2` from `test`.`t1` semi join (`test`.`t2`) semi join (`test`.`t2i` join `test`.`t3` `t3c`) where ((`test`.`t2`.`b2` = `test`.`t1`.`a2`) and (`test`.`t2i`.`b2` = `test`.`t3c`.`c2`) and (`test`.`t2`.`b1` = `test`.`t1`.`a1`) and (`test`.`t2i`.`b1` = `test`.`t3c`.`c1`) and (<expr_cache><`test`.`t2`.`b2`,`test`.`t1`.`a1`>(<in_optimizer>(`test`.`t2`.`b2`,<exists>(select `test`.`t3a`.`c2` from `test`.`t3` `t3a` where ((`test`.`t3a`.`c1` = `test`.`t1`.`a1`) and (<cache>(`test`.`t2`.`b2`) = `test`.`t3a`.`c2`))))) or <expr_cache><`test`.`t2`.`b2`>(<in_optimizer>(`test`.`t2`.`b2`,`test`.`t2`.`b2` in ( <materialize> (select `test`.`t3b`.`c2` from `test`.`t3` `t3b` where (`test`.`t3b`.`c2` like '%03') ), <primary_index_lookup>(`test`.`t2`.`b2` in <temporary table> on distinct_key where ((`test`.`t2`.`b2` = `<subquery4>`.`c2`))))))) and (`test`.`t3c`.`c2` > '0')) select * from t1 where (a1, a2) in (select b1, b2 from t2 where b2 in (select c2 from t3 t3a where c1 = a1) or @@ -414,7 +414,7 @@ id select_type table type possible_keys key key_len ref rows filtered Extra 9 SUBQUERY t3i index it3i1,it3i2,it3i3 # # # 4 75.00 # NULL UNION RESULT <union1,7> ALL NULL # # # NULL NULL # Warnings: -Note 1003 (select `test`.`t1`.`a1` AS `a1`,`test`.`t1`.`a2` AS `a2` from <materialize> (select `test`.`t2`.`b1`,`test`.`t2`.`b2` from `test`.`t2` where (<in_optimizer>(`test`.`t2`.`b2`,`test`.`t2`.`b2` in ( <materialize> (select `test`.`t3`.`c2` from `test`.`t3` where (`test`.`t3`.`c2` like '%02') ), <primary_index_lookup>(`test`.`t2`.`b2` in <temporary table> on distinct_key where ((`test`.`t2`.`b2` = `<subquery3>`.`c2`))))) or <in_optimizer>(`test`.`t2`.`b2`,`test`.`t2`.`b2` in ( <materialize> (select `test`.`t3`.`c2` from `test`.`t3` where (`test`.`t3`.`c2` like '%03') ), <primary_index_lookup>(`test`.`t2`.`b2` in <temporary table> on distinct_key where ((`test`.`t2`.`b2` = `<subquery4>`.`c2`)))))) group by `test`.`t2`.`b1`,`test`.`t2`.`b2`) semi join (`test`.`t2i` join `test`.`t3`) join `test`.`t1` where ((`test`.`t3`.`c2` = `<subquery2>`.`b2`) and (`test`.`t1`.`a2` = `<subquery2>`.`b2`) and (`test`.`t2i`.`b2` = `<subquery2>`.`b2`) and (`test`.`t3`.`c1` = `<subquery2>`.`b1`) and (`test`.`t1`.`a1` = `<subquery2>`.`b1`) and (`test`.`t2i`.`b1` = `<subquery2>`.`b1`) and (`<subquery2>`.`b2` > '0'))) union (select `test`.`t1i`.`a1` AS `a1`,`test`.`t1i`.`a2` AS `a2` from `test`.`t1i` semi join (`test`.`t2i`) semi join (`test`.`t2i` join `test`.`t3i`) where ((`test`.`t3i`.`c2` = `test`.`t2i`.`b2`) and (`test`.`t3i`.`c1` = `test`.`t2i`.`b1`) and (`test`.`t2i`.`b1` > '0') and (`test`.`t2i`.`b2` > '0'))) +Note 1003 (select `test`.`t1`.`a1` AS `a1`,`test`.`t1`.`a2` AS `a2` from <materialize> (select `test`.`t2`.`b1`,`test`.`t2`.`b2` from `test`.`t2` where (<expr_cache><`test`.`t2`.`b2`>(<in_optimizer>(`test`.`t2`.`b2`,`test`.`t2`.`b2` in ( <materialize> (select `test`.`t3`.`c2` from `test`.`t3` where (`test`.`t3`.`c2` like '%02') ), <primary_index_lookup>(`test`.`t2`.`b2` in <temporary table> on distinct_key where ((`test`.`t2`.`b2` = `<subquery3>`.`c2`)))))) or <expr_cache><`test`.`t2`.`b2`>(<in_optimizer>(`test`.`t2`.`b2`,`test`.`t2`.`b2` in ( <materialize> (select `test`.`t3`.`c2` from `test`.`t3` where (`test`.`t3`.`c2` like '%03') ), <primary_index_lookup>(`test`.`t2`.`b2` in <temporary table> on distinct_key where ((`test`.`t2`.`b2` = `<subquery4>`.`c2`))))))) group by `test`.`t2`.`b1`,`test`.`t2`.`b2`) semi join (`test`.`t2i` join `test`.`t3`) join `test`.`t1` where ((`test`.`t3`.`c2` = `<subquery2>`.`b2`) and (`test`.`t1`.`a2` = `<subquery2>`.`b2`) and (`test`.`t2i`.`b2` = `<subquery2>`.`b2`) and (`test`.`t3`.`c1` = `<subquery2>`.`b1`) and (`test`.`t1`.`a1` = `<subquery2>`.`b1`) and (`test`.`t2i`.`b1` = `<subquery2>`.`b1`) and (`<subquery2>`.`b2` > '0'))) union (select `test`.`t1i`.`a1` AS `a1`,`test`.`t1i`.`a2` AS `a2` from `test`.`t1i` semi join (`test`.`t2i`) semi join (`test`.`t2i` join `test`.`t3i`) where ((`test`.`t3i`.`c2` = `test`.`t2i`.`b2`) and (`test`.`t3i`.`c1` = `test`.`t2i`.`b1`) and (`test`.`t2i`.`b1` > '0') and (`test`.`t2i`.`b2` > '0'))) (select * from t1 where (a1, a2) in (select b1, b2 from t2 where b2 in (select c2 from t3 where c2 LIKE '%02') or @@ -444,7 +444,7 @@ id select_type table type possible_keys key key_len ref rows filtered Extra 3 DEPENDENT UNION t2 ALL NULL NULL NULL NULL 5 100.00 Using where NULL UNION RESULT <union2,3> ALL NULL NULL NULL NULL NULL NULL Warnings: -Note 1003 select `test`.`t1`.`a1` AS `a1`,`test`.`t1`.`a2` AS `a2` from `test`.`t1` semi join (`test`.`t2i` join `test`.`t3`) where ((`test`.`t2i`.`b2` = `test`.`t3`.`c2`) and (`test`.`t2i`.`b1` = `test`.`t3`.`c1`) and <in_optimizer>((`test`.`t1`.`a1`,`test`.`t1`.`a2`),<exists>(select `test`.`t1`.`a1`,`test`.`t1`.`a2` from `test`.`t1` where ((`test`.`t1`.`a1` > '0') and (<cache>(`test`.`t1`.`a1`) = `test`.`t1`.`a1`) and (<cache>(`test`.`t1`.`a2`) = `test`.`t1`.`a2`)) union select `test`.`t2`.`b1`,`test`.`t2`.`b2` from `test`.`t2` where ((`test`.`t2`.`b1` < '9') and (<cache>(`test`.`t1`.`a1`) = `test`.`t2`.`b1`) and (<cache>(`test`.`t1`.`a2`) = `test`.`t2`.`b2`)))) and (`test`.`t3`.`c2` > '0')) +Note 1003 select `test`.`t1`.`a1` AS `a1`,`test`.`t1`.`a2` AS `a2` from `test`.`t1` semi join (`test`.`t2i` join `test`.`t3`) where ((`test`.`t2i`.`b2` = `test`.`t3`.`c2`) and (`test`.`t2i`.`b1` = `test`.`t3`.`c1`) and <expr_cache><`test`.`t1`.`a1`,`test`.`t1`.`a2`>(<in_optimizer>((`test`.`t1`.`a1`,`test`.`t1`.`a2`),<exists>(select `test`.`t1`.`a1`,`test`.`t1`.`a2` from `test`.`t1` where ((`test`.`t1`.`a1` > '0') and (<cache>(`test`.`t1`.`a1`) = `test`.`t1`.`a1`) and (<cache>(`test`.`t1`.`a2`) = `test`.`t1`.`a2`)) union select `test`.`t2`.`b1`,`test`.`t2`.`b2` from `test`.`t2` where ((`test`.`t2`.`b1` < '9') and (<cache>(`test`.`t1`.`a1`) = `test`.`t2`.`b1`) and (<cache>(`test`.`t1`.`a2`) = `test`.`t2`.`b2`))))) and (`test`.`t3`.`c2` > '0')) select * from t1 where (a1, a2) in (select * from t1 where a1 > '0' UNION select * from t2 where b1 < '9') and (a1, a2) in (select c1, c2 from t3 @@ -468,7 +468,7 @@ id select_type table type possible_keys key key_len ref rows filtered Extra 3 DEPENDENT UNION t2 ALL NULL NULL NULL NULL 5 100.00 Using where NULL UNION RESULT <union2,3> ALL NULL NULL NULL NULL NULL NULL Warnings: -Note 1003 select `test`.`t1`.`a1` AS `a1`,`test`.`t1`.`a2` AS `a2`,`test`.`t3`.`c1` AS `c1`,`test`.`t3`.`c2` AS `c2` from `test`.`t1` semi join (`test`.`t2i` join `test`.`t3`) join `test`.`t3` where ((`test`.`t2i`.`b2` = `test`.`t3`.`c2`) and (`test`.`t3`.`c1` = `test`.`t1`.`a1`) and (`test`.`t2i`.`b1` = `test`.`t3`.`c1`) and <in_optimizer>((`test`.`t1`.`a1`,`test`.`t1`.`a2`),<exists>(select `test`.`t1`.`a1`,`test`.`t1`.`a2` from `test`.`t1` where ((`test`.`t1`.`a1` > '0') and (<cache>(`test`.`t1`.`a1`) = `test`.`t1`.`a1`) and (<cache>(`test`.`t1`.`a2`) = `test`.`t1`.`a2`)) union select `test`.`t2`.`b1`,`test`.`t2`.`b2` from `test`.`t2` where ((`test`.`t2`.`b1` < '9') and (<cache>(`test`.`t1`.`a1`) = `test`.`t2`.`b1`) and (<cache>(`test`.`t1`.`a2`) = `test`.`t2`.`b2`)))) and (`test`.`t3`.`c2` > '0')) +Note 1003 select `test`.`t1`.`a1` AS `a1`,`test`.`t1`.`a2` AS `a2`,`test`.`t3`.`c1` AS `c1`,`test`.`t3`.`c2` AS `c2` from `test`.`t1` semi join (`test`.`t2i` join `test`.`t3`) join `test`.`t3` where ((`test`.`t2i`.`b2` = `test`.`t3`.`c2`) and (`test`.`t3`.`c1` = `test`.`t1`.`a1`) and (`test`.`t2i`.`b1` = `test`.`t3`.`c1`) and <expr_cache><`test`.`t1`.`a1`,`test`.`t1`.`a2`>(<in_optimizer>((`test`.`t1`.`a1`,`test`.`t1`.`a2`),<exists>(select `test`.`t1`.`a1`,`test`.`t1`.`a2` from `test`.`t1` where ((`test`.`t1`.`a1` > '0') and (<cache>(`test`.`t1`.`a1`) = `test`.`t1`.`a1`) and (<cache>(`test`.`t1`.`a2`) = `test`.`t1`.`a2`)) union select `test`.`t2`.`b1`,`test`.`t2`.`b2` from `test`.`t2` where ((`test`.`t2`.`b1` < '9') and (<cache>(`test`.`t1`.`a1`) = `test`.`t2`.`b1`) and (<cache>(`test`.`t1`.`a2`) = `test`.`t2`.`b2`))))) and (`test`.`t3`.`c2` > '0')) select * from t1, t3 where (a1, a2) in (select * from t1 where a1 > '0' UNION select * from t2 where b1 < '9') and (c1, c2) in (select c1, c2 from t3 @@ -490,7 +490,7 @@ id select_type table type possible_keys key key_len ref rows filtered Extra 3 DEPENDENT UNION t2 ALL NULL NULL NULL NULL 5 100.00 Using where NULL UNION RESULT <union2,3> ALL NULL NULL NULL NULL NULL NULL Warnings: -Note 1003 select `test`.`t3`.`c1` AS `c1`,`test`.`t3`.`c2` AS `c2` from `test`.`t3` where <in_optimizer>(`test`.`t3`.`c1`,<exists>(select `test`.`t1`.`a1` from `test`.`t1` where ((`test`.`t1`.`a1` > '0') and (<cache>(`test`.`t3`.`c1`) = `test`.`t1`.`a1`)) union select `test`.`t2`.`b1` from `test`.`t2` where ((`test`.`t2`.`b1` < '9') and (<cache>(`test`.`t3`.`c1`) = `test`.`t2`.`b1`)))) +Note 1003 select `test`.`t3`.`c1` AS `c1`,`test`.`t3`.`c2` AS `c2` from `test`.`t3` where <expr_cache><`test`.`t3`.`c1`>(<in_optimizer>(`test`.`t3`.`c1`,<exists>(select `test`.`t1`.`a1` from `test`.`t1` where ((`test`.`t1`.`a1` > '0') and (<cache>(`test`.`t3`.`c1`) = `test`.`t1`.`a1`)) union select `test`.`t2`.`b1` from `test`.`t2` where ((`test`.`t2`.`b1` < '9') and (<cache>(`test`.`t3`.`c1`) = `test`.`t2`.`b1`))))) select * from t3 where c1 in (select a1 from t1 where a1 > '0' UNION select b1 from t2 where b1 < '9'); c1 c2 @@ -514,14 +514,14 @@ id select_type table type possible_keys key key_len ref rows filtered Extra Warnings: Note 1276 Field or reference 'test.t1.a1' of SELECT #3 was resolved in SELECT #1 Note 1276 Field or reference 'test.t1.a2' of SELECT #6 was resolved in SELECT #1 -Note 1003 select `test`.`t1`.`a1` AS `a1`,`test`.`t1`.`a2` AS `a2` from `test`.`t1` semi join (`test`.`t2`) semi join (`test`.`t2i` join `test`.`t3` `t3c`) where ((`test`.`t2i`.`b2` = `test`.`t1`.`a2`) and (`test`.`t2`.`b2` = `test`.`t1`.`a2`) and (`test`.`t3c`.`c2` = `test`.`t1`.`a2`) and (`test`.`t2i`.`b1` = `test`.`t1`.`a1`) and (`test`.`t2`.`b1` = `test`.`t1`.`a1`) and (`test`.`t3c`.`c1` = `test`.`t1`.`a1`) and (<in_optimizer>(`test`.`t2`.`b2`,<exists>(select `test`.`t3a`.`c2` from `test`.`t3` `t3a` where ((`test`.`t3a`.`c1` = `test`.`t1`.`a1`) and (<cache>(`test`.`t2`.`b2`) = `test`.`t3a`.`c2`)))) or <in_optimizer>(`test`.`t2`.`b2`,`test`.`t2`.`b2` in ( <materialize> (select `test`.`t3b`.`c2` from `test`.`t3` `t3b` where (`test`.`t3b`.`c2` like '%03') ), <primary_index_lookup>(`test`.`t2`.`b2` in <temporary table> on distinct_key where ((`test`.`t2`.`b2` = `<subquery4>`.`c2`))))))) +Note 1003 select `test`.`t1`.`a1` AS `a1`,`test`.`t1`.`a2` AS `a2` from `test`.`t1` semi join (`test`.`t2`) semi join (`test`.`t2i` join `test`.`t3` `t3c`) where ((`test`.`t2i`.`b2` = `test`.`t1`.`a2`) and (`test`.`t2`.`b2` = `test`.`t1`.`a2`) and (`test`.`t3c`.`c2` = `test`.`t1`.`a2`) and (`test`.`t2i`.`b1` = `test`.`t1`.`a1`) and (`test`.`t2`.`b1` = `test`.`t1`.`a1`) and (`test`.`t3c`.`c1` = `test`.`t1`.`a1`) and (<expr_cache><`test`.`t2`.`b2`,`test`.`t1`.`a1`>(<in_optimizer>(`test`.`t2`.`b2`,<exists>(select `test`.`t3a`.`c2` from `test`.`t3` `t3a` where ((`test`.`t3a`.`c1` = `test`.`t1`.`a1`) and (<cache>(`test`.`t2`.`b2`) = `test`.`t3a`.`c2`))))) or <expr_cache><`test`.`t2`.`b2`>(<in_optimizer>(`test`.`t2`.`b2`,`test`.`t2`.`b2` in ( <materialize> (select `test`.`t3b`.`c2` from `test`.`t3` `t3b` where (`test`.`t3b`.`c2` like '%03') ), <primary_index_lookup>(`test`.`t2`.`b2` in <temporary table> on distinct_key where ((`test`.`t2`.`b2` = `<subquery4>`.`c2`)))))))) explain extended select * from t1 where (a1, a2) in (select '1 - 01', '2 - 01'); id select_type table type possible_keys key key_len ref rows filtered Extra 1 PRIMARY t1 ALL NULL NULL NULL NULL 3 100.00 Using where 2 DEPENDENT SUBQUERY NULL NULL NULL NULL NULL NULL NULL NULL No tables used Warnings: -Note 1003 select `test`.`t1`.`a1` AS `a1`,`test`.`t1`.`a2` AS `a2` from `test`.`t1` where <in_optimizer>((`test`.`t1`.`a1`,`test`.`t1`.`a2`),<exists>(select '1 - 01','2 - 01' having (((<cache>(`test`.`t1`.`a1`) = '1 - 01') or isnull('1 - 01')) and ((<cache>(`test`.`t1`.`a2`) = '2 - 01') or isnull('2 - 01')) and <is_not_null_test>('1 - 01') and <is_not_null_test>('2 - 01')))) +Note 1003 select `test`.`t1`.`a1` AS `a1`,`test`.`t1`.`a2` AS `a2` from `test`.`t1` where <expr_cache><`test`.`t1`.`a1`,`test`.`t1`.`a2`>(<in_optimizer>((`test`.`t1`.`a1`,`test`.`t1`.`a2`),<exists>(select '1 - 01','2 - 01' having (((<cache>(`test`.`t1`.`a1`) = '1 - 01') or isnull('1 - 01')) and ((<cache>(`test`.`t1`.`a2`) = '2 - 01') or isnull('2 - 01')) and <is_not_null_test>('1 - 01') and <is_not_null_test>('2 - 01'))))) select * from t1 where (a1, a2) in (select '1 - 01', '2 - 01'); a1 a2 1 - 01 2 - 01 @@ -531,7 +531,7 @@ id select_type table type possible_keys key key_len ref rows filtered Extra 1 PRIMARY t1 ALL NULL NULL NULL NULL 3 100.00 Using where 2 DEPENDENT SUBQUERY NULL NULL NULL NULL NULL NULL NULL NULL No tables used Warnings: -Note 1003 select `test`.`t1`.`a1` AS `a1`,`test`.`t1`.`a2` AS `a2` from `test`.`t1` where <in_optimizer>((`test`.`t1`.`a1`,`test`.`t1`.`a2`),<exists>(select '1 - 01','2 - 01' having (((<cache>(`test`.`t1`.`a1`) = '1 - 01') or isnull('1 - 01')) and ((<cache>(`test`.`t1`.`a2`) = '2 - 01') or isnull('2 - 01')) and <is_not_null_test>('1 - 01') and <is_not_null_test>('2 - 01')))) +Note 1003 select `test`.`t1`.`a1` AS `a1`,`test`.`t1`.`a2` AS `a2` from `test`.`t1` where <expr_cache><`test`.`t1`.`a1`,`test`.`t1`.`a2`>(<in_optimizer>((`test`.`t1`.`a1`,`test`.`t1`.`a2`),<exists>(select '1 - 01','2 - 01' having (((<cache>(`test`.`t1`.`a1`) = '1 - 01') or isnull('1 - 01')) and ((<cache>(`test`.`t1`.`a2`) = '2 - 01') or isnull('2 - 01')) and <is_not_null_test>('1 - 01') and <is_not_null_test>('2 - 01'))))) select * from t1 where (a1, a2) in (select '1 - 01', '2 - 01' from dual); a1 a2 1 - 01 2 - 01 @@ -563,7 +563,7 @@ id select_type table type possible_keys key key_len ref rows filtered Extra 1 PRIMARY t1 ALL NULL NULL NULL NULL 3 100.00 Using temporary; Using filesort 2 DEPENDENT SUBQUERY columns unique_subquery PRIMARY PRIMARY 4 func 1 100.00 Using index; Using where; Full scan on NULL key Warnings: -Note 1003 select `test`.`t1`.`a1` AS `a1`,`test`.`t1`.`a2` AS `a2` from `test`.`t1` group by <in_optimizer>(`test`.`t1`.`a1`,<exists>(<primary_index_lookup>(<cache>(`test`.`t1`.`a1`) in columns on PRIMARY where trigcond((<cache>(`test`.`t1`.`a1`) = `test`.`columns`.`col`))))) +Note 1003 select `test`.`t1`.`a1` AS `a1`,`test`.`t1`.`a2` AS `a2` from `test`.`t1` group by <expr_cache><`test`.`t1`.`a1`>(<in_optimizer>(`test`.`t1`.`a1`,<exists>(<primary_index_lookup>(<cache>(`test`.`t1`.`a1`) in columns on PRIMARY where trigcond((<cache>(`test`.`t1`.`a1`) = `test`.`columns`.`col`)))))) select * from t1 group by (a1 in (select col from columns)); a1 a2 1 - 00 2 - 00 @@ -646,7 +646,7 @@ from t1_16 where a1 in (select substring(b1,1,16) from t2_16 where b1 > '0'); id select_type table type possible_keys key key_len ref rows filtered Extra 1 PRIMARY t1_16 ALL NULL NULL NULL NULL 3 100.00 -1 PRIMARY <subquery2> eq_ref distinct_key distinct_key 20 func 1 100.00 +1 PRIMARY <subquery2> eq_ref distinct_key distinct_key 20 func 1 100.00 Using where 2 SUBQUERY t2_16 ALL NULL NULL NULL NULL 3 100.00 Using where Warnings: Note 1003 select left(`test`.`t1_16`.`a1`,7) AS `left(a1,7)`,left(`test`.`t1_16`.`a2`,7) AS `left(a2,7)` from `test`.`t1_16` semi join (`test`.`t2_16`) where ((`test`.`t2_16`.`b1` > '0') and (`test`.`t1_16`.`a1` = substr(`test`.`t2_16`.`b1`,1,16))) @@ -663,7 +663,7 @@ id select_type table type possible_keys key key_len ref rows filtered Extra 1 PRIMARY t1_16 ALL NULL NULL NULL NULL 3 100.00 Using where 2 DEPENDENT SUBQUERY t2_16 ALL NULL NULL NULL NULL 3 100.00 Using filesort Warnings: -Note 1003 select left(`test`.`t1_16`.`a1`,7) AS `left(a1,7)`,left(`test`.`t1_16`.`a2`,7) AS `left(a2,7)` from `test`.`t1_16` where <in_optimizer>(`test`.`t1_16`.`a1`,<exists>(select group_concat(`test`.`t2_16`.`b1` separator ',') from `test`.`t2_16` group by `test`.`t2_16`.`b2` having (<cache>(`test`.`t1_16`.`a1`) = <ref_null_helper>(group_concat(`test`.`t2_16`.`b1` separator ','))))) +Note 1003 select left(`test`.`t1_16`.`a1`,7) AS `left(a1,7)`,left(`test`.`t1_16`.`a2`,7) AS `left(a2,7)` from `test`.`t1_16` where <expr_cache><`test`.`t1_16`.`a1`>(<in_optimizer>(`test`.`t1_16`.`a1`,<exists>(select group_concat(`test`.`t2_16`.`b1` separator ',') from `test`.`t2_16` group by `test`.`t2_16`.`b2` having (<cache>(`test`.`t1_16`.`a1`) = <ref_null_helper>(group_concat(`test`.`t2_16`.`b1` separator ',')))))) select left(a1,7), left(a2,7) from t1_16 where a1 in (select group_concat(b1) from t2_16 group by b2); @@ -761,7 +761,7 @@ from t1_512 where a1 in (select substring(b1,1,512) from t2_512 where b1 > '0'); id select_type table type possible_keys key key_len ref rows filtered Extra 1 PRIMARY t1_512 ALL NULL NULL NULL NULL 3 100.00 -1 PRIMARY <subquery2> eq_ref distinct_key distinct_key 517 func 1 100.00 +1 PRIMARY <subquery2> eq_ref distinct_key distinct_key 517 func 1 100.00 Using where 2 SUBQUERY t2_512 ALL NULL NULL NULL NULL 3 100.00 Using where Warnings: Note 1003 select left(`test`.`t1_512`.`a1`,7) AS `left(a1,7)`,left(`test`.`t1_512`.`a2`,7) AS `left(a2,7)` from `test`.`t1_512` semi join (`test`.`t2_512`) where ((`test`.`t2_512`.`b1` > '0') and (`test`.`t1_512`.`a1` = substr(`test`.`t2_512`.`b1`,1,512))) @@ -856,15 +856,16 @@ explain extended select left(a1,7), left(a2,7) from t1_1024 where a1 in (select substring(b1,1,1024) from t2_1024 where b1 > '0'); id select_type table type possible_keys key key_len ref rows filtered Extra -1 PRIMARY t1_1024 ALL NULL NULL NULL NULL 3 100.00 -1 PRIMARY <subquery2> eq_ref NULL distinct_key 13 func,func 1 100.00 -2 SUBQUERY t2_1024 ALL NULL NULL NULL NULL 3 100.00 Using where +1 PRIMARY t1_1024 ALL NULL NULL NULL NULL 3 100.00 Start temporary +1 PRIMARY t2_1024 ALL NULL NULL NULL NULL 3 100.00 Using where; End temporary; Using join buffer (flat, BNL join) Warnings: Note 1003 select left(`test`.`t1_1024`.`a1`,7) AS `left(a1,7)`,left(`test`.`t1_1024`.`a2`,7) AS `left(a2,7)` from `test`.`t1_1024` semi join (`test`.`t2_1024`) where ((`test`.`t2_1024`.`b1` > '0') and (`test`.`t1_1024`.`a1` = substr(`test`.`t2_1024`.`b1`,1,1024))) select left(a1,7), left(a2,7) from t1_1024 where a1 in (select substring(b1,1,1024) from t2_1024 where b1 > '0'); left(a1,7) left(a2,7) +1 - 01x 2 - 01x +1 - 02x 2 - 02x explain extended select left(a1,7), left(a2,7) from t1_1024 where a1 in (select group_concat(b1) from t2_1024 group by b2); @@ -950,15 +951,16 @@ explain extended select left(a1,7), left(a2,7) from t1_1025 where a1 in (select substring(b1,1,1025) from t2_1025 where b1 > '0'); id select_type table type possible_keys key key_len ref rows filtered Extra -1 PRIMARY t1_1025 ALL NULL NULL NULL NULL 3 100.00 -1 PRIMARY <subquery2> eq_ref NULL distinct_key 13 func,func 1 100.00 -2 SUBQUERY t2_1025 ALL NULL NULL NULL NULL 3 100.00 Using where +1 PRIMARY t1_1025 ALL NULL NULL NULL NULL 3 100.00 Start temporary +1 PRIMARY t2_1025 ALL NULL NULL NULL NULL 3 100.00 Using where; End temporary; Using join buffer (flat, BNL join) Warnings: Note 1003 select left(`test`.`t1_1025`.`a1`,7) AS `left(a1,7)`,left(`test`.`t1_1025`.`a2`,7) AS `left(a2,7)` from `test`.`t1_1025` semi join (`test`.`t2_1025`) where ((`test`.`t2_1025`.`b1` > '0') and (`test`.`t1_1025`.`a1` = substr(`test`.`t2_1025`.`b1`,1,1025))) select left(a1,7), left(a2,7) from t1_1025 where a1 in (select substring(b1,1,1025) from t2_1025 where b1 > '0'); left(a1,7) left(a2,7) +1 - 01x 2 - 01x +1 - 02x 2 - 02x explain extended select left(a1,7), left(a2,7) from t1_1025 where a1 in (select group_concat(b1) from t2_1025 group by b2); @@ -1118,7 +1120,7 @@ id select_type table type possible_keys key key_len ref rows filtered Extra 1 PRIMARY t1 index NULL it1a 4 NULL 7 100.00 Using index 2 SUBQUERY t2 ALL NULL NULL NULL NULL 7 100.00 Using where Warnings: -Note 1003 select `test`.`t1`.`a` AS `a` from `test`.`t1` group by `test`.`t1`.`a` having <in_optimizer>(`test`.`t1`.`a`,`test`.`t1`.`a` in ( <materialize> (select `test`.`t2`.`c` from `test`.`t2` where (`test`.`t2`.`d` >= 20) ), <primary_index_lookup>(`test`.`t1`.`a` in <temporary table> on distinct_key where ((`test`.`t1`.`a` = `<subquery2>`.`c`))))) +Note 1003 select `test`.`t1`.`a` AS `a` from `test`.`t1` group by `test`.`t1`.`a` having <expr_cache><`test`.`t1`.`a`>(<in_optimizer>(`test`.`t1`.`a`,`test`.`t1`.`a` in ( <materialize> (select `test`.`t2`.`c` from `test`.`t2` where (`test`.`t2`.`d` >= 20) ), <primary_index_lookup>(`test`.`t1`.`a` in <temporary table> on distinct_key where ((`test`.`t1`.`a` = `<subquery2>`.`c`)))))) select a from t1 group by a having a in (select c from t2 where d >= 20); a 2 @@ -1130,7 +1132,7 @@ id select_type table type possible_keys key key_len ref rows filtered Extra 1 PRIMARY t1 index NULL it1a 4 NULL 7 100.00 Using index 2 SUBQUERY t2 ALL NULL NULL NULL NULL 7 100.00 Using where Warnings: -Note 1003 select `test`.`t1`.`a` AS `a` from `test`.`t1` group by `test`.`t1`.`a` having <in_optimizer>(`test`.`t1`.`a`,`test`.`t1`.`a` in ( <materialize> (select `test`.`t2`.`c` from `test`.`t2` where (`test`.`t2`.`d` >= 20) ), <primary_index_lookup>(`test`.`t1`.`a` in <temporary table> on distinct_key where ((`test`.`t1`.`a` = `<subquery2>`.`c`))))) +Note 1003 select `test`.`t1`.`a` AS `a` from `test`.`t1` group by `test`.`t1`.`a` having <expr_cache><`test`.`t1`.`a`>(<in_optimizer>(`test`.`t1`.`a`,`test`.`t1`.`a` in ( <materialize> (select `test`.`t2`.`c` from `test`.`t2` where (`test`.`t2`.`d` >= 20) ), <primary_index_lookup>(`test`.`t1`.`a` in <temporary table> on distinct_key where ((`test`.`t1`.`a` = `<subquery2>`.`c`)))))) select a from t1 group by a having a in (select c from t2 where d >= 20); a 2 @@ -1144,7 +1146,7 @@ id select_type table type possible_keys key key_len ref rows filtered Extra 3 DEPENDENT SUBQUERY t3 ALL NULL NULL NULL NULL 4 100.00 Using where Warnings: Note 1276 Field or reference 'test.t1.b' of SELECT #3 was resolved in SELECT #1 -Note 1003 select `test`.`t1`.`a` AS `a` from `test`.`t1` group by `test`.`t1`.`a` having <in_optimizer>(`test`.`t1`.`a`,<exists>(select `test`.`t2`.`c` from `test`.`t2` where (<nop>(<in_optimizer>(`test`.`t2`.`d`,<exists>(select `test`.`t3`.`e` from `test`.`t3` where (max(`test`.`t1`.`b`) = `test`.`t3`.`e`) having (<cache>(`test`.`t2`.`d`) >= <ref_null_helper>(`test`.`t3`.`e`))))) and (<cache>(`test`.`t1`.`a`) = `test`.`t2`.`c`)))) +Note 1003 select `test`.`t1`.`a` AS `a` from `test`.`t1` group by `test`.`t1`.`a` having <expr_cache><`test`.`t1`.`a`,`test`.`t1`.`b`,max(`test`.`t1`.`b`),max(`test`.`t1`.`b`)>(<in_optimizer>(`test`.`t1`.`a`,<exists>(select `test`.`t2`.`c` from `test`.`t2` where (<nop>(<expr_cache><`test`.`t2`.`d`,`test`.`t1`.`b`,max(`test`.`t1`.`b`),max(`test`.`t1`.`b`)>(<in_optimizer>(`test`.`t2`.`d`,<exists>(select `test`.`t3`.`e` from `test`.`t3` where (max(`test`.`t1`.`b`) = `test`.`t3`.`e`) having (<cache>(`test`.`t2`.`d`) >= <ref_null_helper>(`test`.`t3`.`e`)))))) and (<cache>(`test`.`t1`.`a`) = `test`.`t2`.`c`))))) select a from t1 group by a having a in (select c from t2 where d >= some(select e from t3 where max(b)=e)); a @@ -1159,7 +1161,7 @@ id select_type table type possible_keys key key_len ref rows filtered Extra 3 DEPENDENT SUBQUERY t3 ALL NULL NULL NULL NULL 4 100.00 Using where Warnings: Note 1276 Field or reference 'test.t1.b' of SELECT #3 was resolved in SELECT #1 -Note 1003 select `test`.`t1`.`a` AS `a` from `test`.`t1` semi join (`test`.`t2`) where ((`test`.`t1`.`a` = `test`.`t2`.`c`) and <nop>(<in_optimizer>(`test`.`t2`.`d`,<exists>(select `test`.`t3`.`e` from `test`.`t3` where ((`test`.`t1`.`b` = `test`.`t3`.`e`) and (<cache>(`test`.`t2`.`d`) >= `test`.`t3`.`e`)))))) +Note 1003 select `test`.`t1`.`a` AS `a` from `test`.`t1` semi join (`test`.`t2`) where ((`test`.`t1`.`a` = `test`.`t2`.`c`) and <nop>(<expr_cache><`test`.`t2`.`d`,`test`.`t1`.`b`>(<in_optimizer>(`test`.`t2`.`d`,<exists>(select `test`.`t3`.`e` from `test`.`t3` where ((`test`.`t1`.`b` = `test`.`t3`.`e`) and (<cache>(`test`.`t2`.`d`) >= `test`.`t3`.`e`))))))) select a from t1 where a in (select c from t2 where d >= some(select e from t3 where b=e)); a @@ -1235,7 +1237,7 @@ insert into t1 values ('aa', 'aaaa'); explain select a,b from t1 where b in (select a from t1); id select_type table type possible_keys key key_len ref rows Extra 1 PRIMARY t1 ALL NULL NULL NULL NULL 2 -1 PRIMARY <subquery2> eq_ref distinct_key distinct_key 3 func 1 +1 PRIMARY <subquery2> eq_ref distinct_key distinct_key 3 func 1 Using where 2 SUBQUERY t1 ALL NULL NULL NULL NULL 2 select a,b from t1 where b in (select a from t1); a b @@ -1600,4 +1602,168 @@ select left(a1,7), left(a2,7) from t1_1024 where (a1,3) in (select substring(b1, left(a1,7) left(a2,7) 1 - 01x 2 - 01x drop table t1_1024, t2_1024; +# +# BUG##836491: Crash in Item_field::Item_field from add_ref_to_table_cond() with semijoin+materialization +# +CREATE TABLE t1 (c int, d varchar(1), KEY(d)) ; +INSERT INTO t1 VALUES (2,'x'),(2,'x'),(2,'j'),(2,'c'); +CREATE TABLE t2 (a int, d varchar(1)) ; +INSERT INTO t2 VALUES (1,'x'); +CREATE TABLE t3 (d varchar(1)) ; +INSERT INTO t3 VALUES ('x'),('x'),('j'),('c'); +SELECT t2.a, t1.c +FROM t1, t2 +WHERE t2.d IN ( SELECT d FROM t3 ) +AND t1.d = t2.d +GROUP BY 1 , 2; +a c +1 2 +drop table t1,t2,t3; +# +# BUG#836523: Crash in JOIN::get_partial_cost_and_fanout with semijoin+materialization +# +CREATE TABLE t1 (a varchar(1)); +INSERT INTO t1 VALUES ('a'),('a'); +CREATE TABLE t2 (a varchar(1)); +CREATE TABLE t3 (a int); +INSERT INTO t3 VALUES (1),(2); +CREATE TABLE t4 (a varchar(1)); +INSERT INTO t4 VALUES ('a'),('a'); +SELECT t1.a +FROM t1 +WHERE t1.a IN ( +SELECT t2.a +FROM t2, t3 +) +HAVING a IN ( +SELECT a +FROM t4 +); +a +DROP TABLE t1, t2, t3, t4; +# +# BUG#836507: Crash in setup_sj_materialization_part1() with semijoin+materialization +# +CREATE TABLE t1 (a int) ; +INSERT IGNORE INTO t1 VALUES (1),(1); +CREATE TABLE t2 (a int); +INSERT INTO t2 VALUES (1); +CREATE TABLE t3 (a int); +CREATE TABLE t4 (a int); +INSERT INTO t4 VALUES (2),(2); +CREATE TABLE t5 (a int); +INSERT INTO t5 VALUES (1); +SELECT * FROM t1 +WHERE (a) IN ( +SELECT t5.a +FROM ( +t2 +LEFT JOIN ( t3 , t4 ) +ON 1 = 1 +) +JOIN t5 +); +a +1 +1 +DROP TABLE t1,t2,t3,t4,t5; +# +# BUG#836532: Crash in Item_equal_fields_iterator::get_curr_field with semijoin+materialization +# +CREATE TABLE t2 (a int); +INSERT INTO t2 VALUES ('a'),('a'); +Warnings: +Warning 1366 Incorrect integer value: 'a' for column 'a' at row 1 +Warning 1366 Incorrect integer value: 'a' for column 'a' at row 2 +CREATE TABLE t4 (a varchar(1)); +INSERT INTO t4 VALUES ('m'),('o'); +CREATE TABLE t3 (a varchar(1) , b varchar(1) ) ; +INSERT INTO t3 VALUES ('b','b'); +CREATE TABLE t5 (a varchar(1), KEY (a)) ; +INSERT INTO t5 VALUES ('d'),('e'); +SELECT * +FROM t2 +WHERE t2.a = ALL ( +SELECT t4.a +FROM t4 +WHERE t4.a IN ( +SELECT t3.a +FROM t3 , t5 +WHERE ( t5.a = t3.b ) +) +); +a +0 +0 +DROP TABLE t2,t3,t4,t5; +# +# BUG#860300: Second crash with get_fanout_with_deps() with semijoin + materialization +# +set @tmp_860300=@@optimizer_switch; +set optimizer_switch='semijoin=on,materialization=on,loosescan=off,firstmatch=off'; +CREATE TABLE t1 (f2 int); +INSERT INTO t1 VALUES (9),(6); +CREATE TABLE t3 (f4 int); +CREATE TABLE t4 (f6 varchar(1)); +SELECT * +FROM t3 +WHERE 'h' IN (SELECT f6 +FROM t4 +WHERE 5 IN (SELECT f2 FROM t1) +GROUP BY t4.f6); +f4 +DROP TABLE t1,t3,t4; +set optimizer_switch=@tmp_860300; +# +# BUG#860535: Assertion `keypart_map' failed in mi_rkey with semijoin +# +set @tmp_860535=@@optimizer_switch; +set optimizer_switch='semijoin=on,materialization=on,loosescan=off,firstmatch=off'; +CREATE TABLE t1 (f3 int) ; +INSERT INTO t1 VALUES (1),(7); +CREATE TABLE t2 (f3 int , f5 varchar(1), KEY (f3)) ; +INSERT INTO t2 VALUES (7,'b'); +CREATE TABLE t3 (f3 int , f4 varchar(1) , KEY(f3), KEY (f4,f3)) ; +INSERT INTO t3 VALUES (1,'t'),(7,'g'); +CREATE TABLE t4 +SELECT f3 +FROM t1 WHERE ( f3 ) NOT IN ( +SELECT f3 +FROM t2 +WHERE f5 IN ( +SELECT f4 +FROM t3 +WHERE t3.f3 < 3 +) +); +SELECT * FROM t4; +f3 +1 +7 +DROP TABLE t1, t2, t3, t4; +set optimizer_switch=@tmp_860535; +# +# BUG#860553: Crash in create_ref_for_key with semijoin + materialization +# +CREATE TABLE t1 (f1 int) ; +CREATE TABLE t2 (f5 varchar(52) NOT NULL) ; +CREATE TABLE t3 (f1 varchar(3), f4 varchar(52) , KEY (f4), PRIMARY KEY (f1)); +CREATE TABLE t4 (f3 int, KEY (f3)); +INSERT INTO t4 VALUES (17),(20); +CREATE TABLE t5 (f2 int); +INSERT INTO t5 VALUES (0),(0); +SELECT * +FROM t1 +JOIN t2 +ON ( t2.f5 ) IN ( +SELECT t3.f4 +FROM t3 +WHERE ( 1 ) IN ( +SELECT t4.f3 +FROM t4 , t5 +) +); +f1 f5 +DROP TABLE t1, t2, t3, t4, t5; +# This must be at the end: set optimizer_switch=@subselect_sj_mat_tmp; diff --git a/mysql-test/r/system_mysql_db.result b/mysql-test/r/system_mysql_db.result index 033659ba5d7..d5409136ed4 100644 --- a/mysql-test/r/system_mysql_db.result +++ b/mysql-test/r/system_mysql_db.result @@ -119,7 +119,7 @@ user CREATE TABLE `user` ( `max_questions` int(11) unsigned NOT NULL DEFAULT '0', `max_updates` int(11) unsigned NOT NULL DEFAULT '0', `max_connections` int(11) unsigned NOT NULL DEFAULT '0', - `max_user_connections` int(11) unsigned NOT NULL DEFAULT '0', + `max_user_connections` int(11) NOT NULL DEFAULT '0', `plugin` char(64) CHARACTER SET latin1 NOT NULL DEFAULT '', `authentication_string` text COLLATE utf8_bin NOT NULL, PRIMARY KEY (`Host`,`User`) diff --git a/mysql-test/r/table_elim.result b/mysql-test/r/table_elim.result index 3ad02914ca8..892ac29d6d5 100644 --- a/mysql-test/r/table_elim.result +++ b/mysql-test/r/table_elim.result @@ -272,7 +272,8 @@ drop table t1, t2; create table t1 (a char(10) primary key); insert into t1 values ('foo'),('bar'); create table t2 (a char(10), unique key(a(2))); -insert into t2 values ('foo'),('bar'); +insert into t2 values +('foo'),('bar'),('boo'),('car'),('coo'),('par'),('doo'),('tar'); explain select t1.* from t1 left join t2 on t2.a=t1.a; id select_type table type possible_keys key key_len ref rows Extra 1 SIMPLE t1 index NULL PRIMARY 10 NULL 2 Using index @@ -566,3 +567,22 @@ id select_type table type possible_keys key key_len ref rows Extra # ^^ The above must not produce a QEP of t3,t5,t2,t4 # as that violates the "no interleaving of outer join nests" rule. DROP TABLE t1,t2,t3,t4,t5; +# +# BUG#884184: Wrong result with RIGHT JOIN + derived_merge +# +CREATE TABLE t1 (a int(11), b varchar(1)) ; +INSERT IGNORE INTO t1 VALUES (0,'g'); +CREATE TABLE t3 ( a varchar(1)) ; +INSERT IGNORE INTO t3 VALUES ('g'); +CREATE TABLE t2 ( a int(11) NOT NULL, PRIMARY KEY (a)) ; +create view v1 as SELECT t1.* FROM t1 LEFT JOIN t2 ON ( t1.a = t2.a ) WHERE t2.a <> 0; +SELECT alias1.* FROM t3 LEFT JOIN v1 as alias1 ON ( t3.a = alias1.b ); +a b +NULL NULL +EXPLAIN SELECT alias1.* FROM t3 LEFT JOIN v1 as alias1 ON ( t3.a = alias1.b ); +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t3 system NULL NULL NULL NULL 1 +1 SIMPLE t1 ALL NULL NULL NULL NULL 1 Using where +1 SIMPLE t2 eq_ref PRIMARY PRIMARY 4 test.t1.a 1 Using where; Using index +drop view v1; +DROP TABLE t1,t2,t3; diff --git a/mysql-test/r/trigger.result b/mysql-test/r/trigger.result index faea2e791d5..daddbe5ceca 100644 --- a/mysql-test/r/trigger.result +++ b/mysql-test/r/trigger.result @@ -2098,6 +2098,25 @@ b DROP DATABASE db1; USE test; End of 5.1 tests. +create table t1 (i int); +create table t2 (i int); +flush tables; +flush status; +CREATE DEFINER=`root`@`localhost` TRIGGER trg AFTER DELETE ON t1 FOR EACH ROW BEGIN DELETE FROM t2 WHERE t2.i = OLD.i; END // +insert into t1 values (1),(2); +insert into t2 values (1),(2); +delete from t1 where i=1; +show status like 'Opened_tables'; +Variable_name Value +Opened_tables 3 +select * from t1; +i +2 +select * from t2; +i +2 +drop table t1,t2; +End of 5.2 tests. # # Bug#34453 Can't change size of file (Errcode: 1224) # @@ -2181,7 +2200,6 @@ trigger_name # Clean-up. drop temporary table t1; drop table t1; - # # Bug #12362125: SP INOUT HANDLING IS BROKEN FOR TEXT TYPE. # diff --git a/mysql-test/r/type_datetime.result b/mysql-test/r/type_datetime.result index e04cd76d2ba..ff052101753 100644 --- a/mysql-test/r/type_datetime.result +++ b/mysql-test/r/type_datetime.result @@ -514,11 +514,10 @@ explain extended select * from t1 where id in (select id from t1 as x1 where (t1.cur_date is null)); id select_type table type possible_keys key key_len ref rows filtered Extra -1 PRIMARY t1 system NULL NULL NULL NULL 1 100.00 -2 DEPENDENT SUBQUERY NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +1 PRIMARY NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables Warnings: Note 1276 Field or reference 'test.t1.cur_date' of SELECT #2 was resolved in SELECT #1 -Note 1003 select 1 AS `id`,'2007-04-25 18:30:22' AS `cur_date` from dual where <in_optimizer>(1,<exists>(select `test`.`x1`.`id` from `test`.`t1` `x1` where 0)) +Note 1003 select 1 AS `id`,'2007-04-25 18:30:22' AS `cur_date` from (dual) where (('2007-04-25 18:30:22' = 0)) select * from t1 where id in (select id from t1 as x1 where (t1.cur_date is null)); id cur_date @@ -526,11 +525,10 @@ explain extended select * from t2 where id in (select id from t2 as x1 where (t2.cur_date is null)); id select_type table type possible_keys key key_len ref rows filtered Extra -1 PRIMARY t2 system NULL NULL NULL NULL 1 100.00 -2 DEPENDENT SUBQUERY NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +1 PRIMARY NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables Warnings: Note 1276 Field or reference 'test.t2.cur_date' of SELECT #2 was resolved in SELECT #1 -Note 1003 select 1 AS `id`,'2007-04-25' AS `cur_date` from dual where <in_optimizer>(1,<exists>(select `test`.`x1`.`id` from `test`.`t2` `x1` where 0)) +Note 1003 select 1 AS `id`,'2007-04-25' AS `cur_date` from (dual) where (('2007-04-25' = 0)) select * from t2 where id in (select id from t2 as x1 where (t2.cur_date is null)); id cur_date @@ -540,11 +538,11 @@ explain extended select * from t1 where id in (select id from t1 as x1 where (t1.cur_date is null)); id select_type table type possible_keys key key_len ref rows filtered Extra -1 PRIMARY t1 ALL NULL NULL NULL NULL 2 100.00 Using where -2 DEPENDENT SUBQUERY x1 ALL NULL NULL NULL NULL 2 100.00 Using where +1 PRIMARY t1 ALL NULL NULL NULL NULL 2 100.00 Using where; Start temporary +1 PRIMARY x1 ALL NULL NULL NULL NULL 2 100.00 Using where; End temporary Warnings: Note 1276 Field or reference 'test.t1.cur_date' of SELECT #2 was resolved in SELECT #1 -Note 1003 select `test`.`t1`.`id` AS `id`,`test`.`t1`.`cur_date` AS `cur_date` from `test`.`t1` where <in_optimizer>(`test`.`t1`.`id`,<exists>(select `test`.`x1`.`id` from `test`.`t1` `x1` where ((`test`.`t1`.`cur_date` = 0) and (<cache>(`test`.`t1`.`id`) = `test`.`x1`.`id`)))) +Note 1003 select `test`.`t1`.`id` AS `id`,`test`.`t1`.`cur_date` AS `cur_date` from `test`.`t1` semi join (`test`.`t1` `x1`) where ((`test`.`x1`.`id` = `test`.`t1`.`id`) and (`test`.`t1`.`cur_date` = 0)) select * from t1 where id in (select id from t1 as x1 where (t1.cur_date is null)); id cur_date @@ -552,11 +550,11 @@ explain extended select * from t2 where id in (select id from t2 as x1 where (t2.cur_date is null)); id select_type table type possible_keys key key_len ref rows filtered Extra -1 PRIMARY t2 ALL NULL NULL NULL NULL 2 100.00 Using where -2 DEPENDENT SUBQUERY x1 ALL NULL NULL NULL NULL 2 100.00 Using where +1 PRIMARY t2 ALL NULL NULL NULL NULL 2 100.00 Using where; Start temporary +1 PRIMARY x1 ALL NULL NULL NULL NULL 2 100.00 Using where; End temporary Warnings: Note 1276 Field or reference 'test.t2.cur_date' of SELECT #2 was resolved in SELECT #1 -Note 1003 select `test`.`t2`.`id` AS `id`,`test`.`t2`.`cur_date` AS `cur_date` from `test`.`t2` where <in_optimizer>(`test`.`t2`.`id`,<exists>(select `test`.`x1`.`id` from `test`.`t2` `x1` where ((`test`.`t2`.`cur_date` = 0) and (<cache>(`test`.`t2`.`id`) = `test`.`x1`.`id`)))) +Note 1003 select `test`.`t2`.`id` AS `id`,`test`.`t2`.`cur_date` AS `cur_date` from `test`.`t2` semi join (`test`.`t2` `x1`) where ((`test`.`x1`.`id` = `test`.`t2`.`id`) and (`test`.`t2`.`cur_date` = 0)) select * from t2 where id in (select id from t2 as x1 where (t2.cur_date is null)); id cur_date diff --git a/mysql-test/r/type_datetime_hires.result b/mysql-test/r/type_datetime_hires.result index ffbd5c42546..ba1fe4adedb 100644 --- a/mysql-test/r/type_datetime_hires.result +++ b/mysql-test/r/type_datetime_hires.result @@ -28,7 +28,7 @@ a DIV 1 0 20101211002003 20101211010203 -20101211030406 +20101211030405 20101211154711 select group_concat(distinct a) from t1; group_concat(distinct a) diff --git a/mysql-test/r/type_float.result b/mysql-test/r/type_float.result index 79fd21ebe20..f41c2e7688b 100644 --- a/mysql-test/r/type_float.result +++ b/mysql-test/r/type_float.result @@ -431,4 +431,19 @@ SELECT f1 FROM t1; f1 -1.79769313486231e308 DROP TABLE t1; +# +# Bug#12406055 BUFFER OVERFLOW OF VARIABLE 'BUFF' IN STRING::SET_REAL +# +# Ignoring output from misc. float operations +select format(-1.7976931348623157E+307,256) as foo; +select least(-1.1111111111111111111111111, +- group_concat(1.7976931348623157E+308)) as foo; +select concat((truncate((-1.7976931348623157E+307),(0x1e))), +(99999999999999999999999999999999999999999999999999999999999999999)) into @a; End of 5.0 tests +# +# Bug#12368853 FORMAT() CRASHES WITH LARGE NUMBERS AFTER TRUNCATE... +# +select format(truncate('1.7976931348623157E+308',-12),1,'fr_BE') as foo; +foo +0 diff --git a/mysql-test/r/type_newdecimal.result b/mysql-test/r/type_newdecimal.result index 38ce18e3dd6..047cfbe5342 100644 --- a/mysql-test/r/type_newdecimal.result +++ b/mysql-test/r/type_newdecimal.result @@ -1934,3 +1934,14 @@ f1 0.000000000000000000000000 DROP TABLE IF EXISTS t1; End of 5.1 tests +# +# BUG#12911710 - VALGRIND FAILURE IN +# ROW-DEBUG:PERFSCHEMA.SOCKET_SUMMARY_BY_INSTANCE_FUNC +# +CREATE TABLE t1(d1 DECIMAL(60,0) NOT NULL, +d2 DECIMAL(60,0) NOT NULL); +INSERT INTO t1 (d1, d2) VALUES(0.0, 0.0); +SELECT d1 * d2 FROM t1; +d1 * d2 +0 +DROP TABLE t1; diff --git a/mysql-test/r/type_time_hires.result b/mysql-test/r/type_time_hires.result index d54aebbd555..bf54434a04c 100644 --- a/mysql-test/r/type_time_hires.result +++ b/mysql-test/r/type_time_hires.result @@ -36,7 +36,7 @@ a DIV 1 0 2003 10203 -30406 +30405 154711 select group_concat(distinct a) from t1; group_concat(distinct a) diff --git a/mysql-test/r/type_timestamp_hires.result b/mysql-test/r/type_timestamp_hires.result index f5009cd2342..3f1e05f4870 100644 --- a/mysql-test/r/type_timestamp_hires.result +++ b/mysql-test/r/type_timestamp_hires.result @@ -28,7 +28,7 @@ a DIV 1 0 20101211002003 20101211010203 -20101211030406 +20101211030405 20101211154711 select group_concat(distinct a) from t1; group_concat(distinct a) diff --git a/mysql-test/r/union.result b/mysql-test/r/union.result index ddb706c2c7d..ae637467ad8 100644 --- a/mysql-test/r/union.result +++ b/mysql-test/r/union.result @@ -1659,6 +1659,63 @@ a 7 8 drop table t1; +# +# Bug#11765255 58201: +# VALGRIND/CRASH WHEN ORDERING BY MULTIPLE AGGREGATE FUNCTIONS +# +select 1 as foo +union +select 2 +union +select 3 +union +select 4 +order by max(42) + max(1) + max(1) + max(1) + max(1) + max(1) +; +foo +1 +prepare stmt1 from 'select 1 as foo +union +select 2 +union +select 3 +union +select 4 +order by max(42) + max(1) + max(1) + max(1) + max(1) + max(1) +'; +execute stmt1; +foo +1 +execute stmt1; +foo +1 +select 1 as foo +union +select 2 +union +select 3 +union +(select 4) +order by max(42) + max(1) + max(1) + max(1) + max(1) + max(1) +; +foo +1 +prepare stmt1 from 'select 1 as foo +union +select 2 +union +select 3 +union +(select 4) +order by max(42) + max(1) + max(1) + max(1) + max(1) + max(1) +'; +execute stmt1; +foo +1 +execute stmt1; +foo +1 +deallocate prepare stmt1; End of 5.1 tests # # Bug#57986 ORDER BY clause is not used after a UNION, diff --git a/mysql-test/r/user_limits.result b/mysql-test/r/user_limits.result index 80ec5517b16..688704f528a 100644 --- a/mysql-test/r/user_limits.result +++ b/mysql-test/r/user_limits.result @@ -1,3 +1,4 @@ +set @my_max_user_connections= @@global.max_user_connections; drop table if exists t1; create table t1 (i int); delete from mysql.user where user like 'mysqltest\_%'; @@ -12,9 +13,9 @@ i select * from t1; i select * from t1; -ERROR 42000: User 'mysqltest_1' has exceeded the 'max_questions' resource (current value: 2) +ERROR 42000: User 'mysqltest_1' has exceeded the 'max_queries_per_hour' resource (current value: 2) select * from t1; -ERROR 42000: User 'mysqltest_1' has exceeded the 'max_questions' resource (current value: 2) +ERROR 42000: User 'mysqltest_1' has exceeded the 'max_queries_per_hour' resource (current value: 2) drop user mysqltest_1@localhost; grant usage on *.* to mysqltest_1@localhost with max_updates_per_hour 2; flush user_resources; @@ -27,11 +28,11 @@ i delete from t1; delete from t1; delete from t1; -ERROR 42000: User 'mysqltest_1' has exceeded the 'max_updates' resource (current value: 2) +ERROR 42000: User 'mysqltest_1' has exceeded the 'max_updates_per_hour' resource (current value: 2) select * from t1; i delete from t1; -ERROR 42000: User 'mysqltest_1' has exceeded the 'max_updates' resource (current value: 2) +ERROR 42000: User 'mysqltest_1' has exceeded the 'max_updates_per_hour' resource (current value: 2) select * from t1; i drop user mysqltest_1@localhost; @@ -65,10 +66,20 @@ select * from t1; i connect(localhost,mysqltest_1,,test,MYSQL_PORT,MYSQL_SOCK); ERROR 42000: User 'mysqltest_1' has exceeded the 'max_user_connections' resource (current value: 3) +grant usage on *.* to mysqltest_1@localhost with max_user_connections -1; +show grants for mysqltest_1@localhost; +Grants for mysqltest_1@localhost +GRANT USAGE ON *.* TO 'mysqltest_1'@'localhost' WITH MAX_USER_CONNECTIONS -1 +flush user_resources; +show grants for mysqltest_1@localhost; +Grants for mysqltest_1@localhost +GRANT USAGE ON *.* TO 'mysqltest_1'@'localhost' WITH MAX_USER_CONNECTIONS -1 +connect(localhost,mysqltest_1,,test,MYSQL_PORT,MYSQL_SOCK); +ERROR 42000: User 'mysqltest_1' has exceeded the 'max_user_connections' resource (current value: -1) drop user mysqltest_1@localhost; select @@session.max_user_connections, @@global.max_user_connections; @@session.max_user_connections @@global.max_user_connections -0 0 +1000 1000 set session max_user_connections= 2; ERROR HY000: SESSION variable 'max_user_connections' is read-only. Use SET GLOBAL to assign the value set global max_user_connections= 2; @@ -92,5 +103,21 @@ select @@session.max_user_connections, @@global.max_user_connections; connect(localhost,mysqltest_1,,test,MYSQL_PORT,MYSQL_SOCK); ERROR 42000: User 'mysqltest_1' has exceeded the 'max_user_connections' resource (current value: 3) set global max_user_connections= 0; +grant usage on *.* to mysqltest_1@localhost with max_user_connections 0; +set global max_user_connections=-1; +show variables like "max_user_user_connections"; +Variable_name Value +select @@max_user_connections; +@@max_user_connections +-1 +select @@global.max_user_connections; +@@global.max_user_connections +-1 +connect(localhost,mysqltest_1,,test,MYSQL_PORT,MYSQL_SOCK); +ERROR 42000: User mysqltest_1 already has more than 'max_user_connections' active connections +set global max_user_connections=1; +connect(localhost,mysqltest_1,,test,MYSQL_PORT,MYSQL_SOCK); +ERROR 42000: User mysqltest_1 already has more than 'max_user_connections' active connections drop user mysqltest_1@localhost; drop table t1; +set global max_user_connections= @my_max_user_connections; diff --git a/mysql-test/r/variables.result b/mysql-test/r/variables.result index 68b0e04d89c..8cc51cc86ac 100644 --- a/mysql-test/r/variables.result +++ b/mysql-test/r/variables.result @@ -14,6 +14,7 @@ set @my_max_delayed_threads =@@global.max_delayed_threads; set @my_max_heap_table_size =@@global.max_heap_table_size; set @my_max_insert_delayed_threads=@@global.max_insert_delayed_threads; set @my_max_join_size =@@global.max_join_size; +set @my_max_user_connections =@@global.max_user_connections; set @my_myisam_data_pointer_size =@@global.myisam_data_pointer_size; set @my_myisam_max_sort_file_size =@@global.myisam_max_sort_file_size; set @my_net_buffer_length =@@global.net_buffer_length; @@ -27,6 +28,7 @@ set @my_thread_cache_size =@@global.thread_cache_size; set @my_max_allowed_packet =@@global.max_allowed_packet; set @my_delay_key_write =@@global.delay_key_write; set @my_join_buffer_size =@@global.join_buffer_size; +set @my_log_warnings =@@global.log_warnings; set @`test`=1; select @test, @`test`, @TEST, @`TEST`, @"teSt"; @test @`test` @TEST @`TEST` @"teSt" @@ -1047,7 +1049,7 @@ set global max_delayed_threads =@my_max_delayed_threads; set global max_heap_table_size =@my_max_heap_table_size; set global max_insert_delayed_threads=@my_max_insert_delayed_threads; set global max_join_size =@my_max_join_size; -set global max_user_connections =default; +set global max_user_connections =@my_max_user_connections; set global max_write_lock_count =default; set global myisam_data_pointer_size =@my_myisam_data_pointer_size; set global myisam_max_sort_file_size =@my_myisam_max_sort_file_size; @@ -1066,6 +1068,7 @@ set global thread_cache_size =@my_thread_cache_size; set global max_allowed_packet = default; set global delay_key_write =@my_delay_key_write; set global join_buffer_size =@my_join_buffer_size; +set global log_warnings =@my_log_warnings; show global variables where Variable_name='table_definition_cache'; Variable_name Value table_definition_cache # diff --git a/mysql-test/r/view.result b/mysql-test/r/view.result index e057a3d2630..f48d65c2dc0 100644 --- a/mysql-test/r/view.result +++ b/mysql-test/r/view.result @@ -4446,7 +4446,7 @@ id select_type table type possible_keys key key_len ref rows filtered Extra 2 DEPENDENT SUBQUERY t4 ALL NULL NULL NULL NULL 2 100.00 Using where Warnings: Note 1276 Field or reference 'test.t1.a' of SELECT #2 was resolved in SELECT #1 -Note 1003 select `test`.`t1`.`a` AS `a`,10 AS `a` from `test`.`t1` where (not(<in_optimizer>(10,<exists>(select NULL from `test`.`t4` where ((`test`.`t4`.`a` >= `test`.`t1`.`a`) and trigcond(((<cache>(10) = NULL) or <cache>(isnull(NULL))))) having trigcond(<is_not_null_test>(NULL)))))) +Note 1003 select `test`.`t1`.`a` AS `a`,10 AS `a` from `test`.`t1` where (not(<expr_cache><10,`test`.`t1`.`a`>(<in_optimizer>(10,<exists>(select NULL from `test`.`t4` where ((`test`.`t4`.`a` >= `test`.`t1`.`a`) and trigcond(((<cache>(10) = NULL) or <cache>(isnull(NULL))))) having trigcond(<is_not_null_test>(NULL))))))) SELECT * FROM t1, t2 WHERE t2.a NOT IN (SELECT t3.b FROM t3 RIGHT JOIN t4 ON (t4.a = t3.a) WHERE t4.a >= t1.a); @@ -4462,7 +4462,7 @@ id select_type table type possible_keys key key_len ref rows filtered Extra 2 DEPENDENT SUBQUERY t4 ALL NULL NULL NULL NULL 2 100.00 Using where Warnings: Note 1276 Field or reference 'v1.a' of SELECT #2 was resolved in SELECT #1 -Note 1003 select `test`.`t1`.`a` AS `a`,10 AS `a` from `test`.`t1` where (not(<in_optimizer>(10,<exists>(select NULL from `test`.`t4` where ((`test`.`t4`.`a` >= `test`.`t1`.`a`) and trigcond(((<cache>(10) = NULL) or <cache>(isnull(NULL))))) having trigcond(<is_not_null_test>(NULL)))))) +Note 1003 select `test`.`t1`.`a` AS `a`,10 AS `a` from `test`.`t1` where (not(<expr_cache><10,`test`.`t1`.`a`>(<in_optimizer>(10,<exists>(select NULL from `test`.`t4` where ((`test`.`t4`.`a` >= `test`.`t1`.`a`) and trigcond(((<cache>(10) = NULL) or <cache>(isnull(NULL))))) having trigcond(<is_not_null_test>(NULL))))))) SELECT * FROM v1, t2 WHERE t2.a NOT IN (SELECT t3.b FROM t3 RIGHT JOIN t4 ON (t4.a = t3.a) WHERE t4.a >= v1.a); @@ -4547,3 +4547,23 @@ UNLOCK TABLES; # Connection default DROP PROCEDURE p1; DROP TABLE t1; +# +# lp:833600 Wrong result with view + outer join + uncorrelated subquery (non-semijoin) +# +CREATE TABLE t1 ( a int, b int ); +INSERT INTO t1 VALUES (0,0),(0,0); +CREATE TABLE t2 ( a int, b int ); +INSERT IGNORE INTO t2 VALUES (1,0),(1,0); +CREATE TABLE t3 ( b int ); +INSERT IGNORE INTO t3 VALUES (0),(0); +CREATE OR REPLACE VIEW v2 AS SELECT * FROM t2; +SELECT * FROM t1 RIGHT JOIN v2 ON ( v2.a = t1.a ) WHERE v2.b IN ( SELECT b FROM t3 ) AND t1.b IS NULL ; +a b a b +NULL NULL 1 0 +NULL NULL 1 0 +SELECT * FROM t1 RIGHT JOIN v2 ON ( v2.a = t1.a ) WHERE v2.b IN ( SELECT b FROM t3 ) AND t1.b IS NULL ; +a b a b +NULL NULL 1 0 +NULL NULL 1 0 +DROP VIEW v2; +DROP TABLE t1, t2, t3; diff --git a/mysql-test/r/xml.result b/mysql-test/r/xml.result index 447f2d4e460..999178a0d52 100644 --- a/mysql-test/r/xml.result +++ b/mysql-test/r/xml.result @@ -1144,5 +1144,23 @@ SELECT UPDATEXML(CONVERT('' USING swe7), TRUNCATE('',1), 0); UPDATEXML(CONVERT('' USING swe7), TRUNCATE('',1), 0) NULL # +# Bug#12375190: UPDATEXML CRASHES ON SIMPLE INPUTS +# +SELECT UPDATEXML('','(a)/a',''); +UPDATEXML('','(a)/a','') + +SELECT UPDATEXML('<a><a>x</a></a>','(a)/a','<b />'); +UPDATEXML('<a><a>x</a></a>','(a)/a','<b />') +<a><b /></a> +SELECT UPDATEXML('<a><c><a>x</a></c></a>','(a)/a','<b />'); +UPDATEXML('<a><c><a>x</a></c></a>','(a)/a','<b />') +<a><c><a>x</a></c></a> +SELECT UPDATEXML('<a><c><a>x</a></c></a>','(a)//a','<b />'); +UPDATEXML('<a><c><a>x</a></c></a>','(a)//a','<b />') +<a><c><b /></c></a> +SELECT ExtractValue('<a><a>aa</a><b>bb</b></a>','(a)/a|(a)/b'); +ExtractValue('<a><a>aa</a><b>bb</b></a>','(a)/a|(a)/b') +aa bb +# # End of 5.5 tests # diff --git a/mysql-test/r/xtradb_mrr.result b/mysql-test/r/xtradb_mrr.result index 3f686f1abaf..785fa0174dd 100644 --- a/mysql-test/r/xtradb_mrr.result +++ b/mysql-test/r/xtradb_mrr.result @@ -186,7 +186,7 @@ explain select * from t4 where a IS NULL and b IS NULL and (c IS NULL or c='no-such-row1' or c='no-such-row2'); id select_type table type possible_keys key key_len ref rows Extra -1 SIMPLE t4 range idx1 idx1 29 NULL 16 Using index condition; Rowid-ordered scan +1 SIMPLE t4 range idx1 idx1 29 NULL 16 Using index condition; Using where; Rowid-ordered scan select * from t4 where a IS NULL and b IS NULL and (c IS NULL or c='no-such-row1' or c='no-such-row2'); a b c filler @@ -208,7 +208,7 @@ NULL NULL NULL NULL-1 explain select * from t4 where (a ='b-1' or a='bb-1') and b IS NULL and (c='c-1' or c='cc-2'); id select_type table type possible_keys key key_len ref rows Extra -1 SIMPLE t4 range idx1 idx1 29 NULL 32 Using index condition; Rowid-ordered scan +1 SIMPLE t4 range idx1 idx1 29 NULL 32 Using index condition; Using where; Rowid-ordered scan select * from t4 where (a ='b-1' or a='bb-1') and b IS NULL and (c='c-1' or c='cc-2'); a b c filler b-1 NULL c-1 NULL-15 @@ -871,6 +871,7 @@ JA USA DROP TABLE t1,t2; # # Testcase backport: Bug#43249 +# (Note: Fixed by patch for BUG#42580) # CREATE TABLE t1(c1 TIME NOT NULL, c2 TIME NULL, c3 DATE, PRIMARY KEY(c1), UNIQUE INDEX(c2)) engine=innodb; INSERT INTO t1 VALUES('8:29:45',NULL,'2009-02-01'); diff --git a/mysql-test/std_data/bug11747416_32228_binlog.000001 b/mysql-test/std_data/bug11747416_32228_binlog.000001 Binary files differnew file mode 100644 index 00000000000..2596b5b0237 --- /dev/null +++ b/mysql-test/std_data/bug11747416_32228_binlog.000001 diff --git a/mysql-test/std_data/bug57108.cnf b/mysql-test/std_data/bug57108.cnf deleted file mode 100644 index 5fd8c485cf0..00000000000 --- a/mysql-test/std_data/bug57108.cnf +++ /dev/null @@ -1,95 +0,0 @@ -[mysqld] -open-files-limit=1024 -character-set-server=latin1 -connect-timeout=4711 -log-bin-trust-function-creators=1 -key_buffer_size=1M -sort_buffer=256K -max_heap_table_size=1M -loose-innodb_data_file_path=ibdata1:10M:autoextend -loose-innodb_buffer_pool_size=8M -loose-innodb_write_io_threads=2 -loose-innodb_read_io_threads=2 -loose-innodb_log_buffer_size=1M -loose-innodb_log_file_size=5M -loose-innodb_additional_mem_pool_size=1M -loose-innodb_log_files_in_group=2 -slave-net-timeout=120 -log-bin=mysqld-bin -loose-enable-performance-schema -loose-performance-schema-max-mutex-instances=10000 -loose-performance-schema-max-rwlock-instances=10000 -loose-performance-schema-max-table-instances=500 -loose-performance-schema-max-table-handles=1000 -binlog-direct-non-transactional-updates - -[mysql] -default-character-set=latin1 - -[mysqlshow] -default-character-set=latin1 - -[mysqlimport] -default-character-set=latin1 - -[mysqlcheck] -default-character-set=latin1 - -[mysql_upgrade] -default-character-set=latin1 -tmpdir=/home/bzr/bugs/b57108-5.5-bugteam/mysql-test/var/tmp - -[mysqld.1] -#!run-master-sh -log-bin=master-bin -loose-enable-performance-schema -basedir=/home/bzr/bugs/b57108-5.5-bugteam -tmpdir=/home/bzr/bugs/b57108-5.5-bugteam/mysql-test/var/tmp/mysqld.1 -character-sets-dir=/home/bzr/bugs/b57108-5.5-bugteam/sql/share/charsets -lc-messages-dir=/home/bzr/bugs/b57108-5.5-bugteam/sql/share/ -datadir=/home/bzr/bugs/b57108-5.5-bugteam/mysql-test/var/mysqld.1/data -pid-file=/home/bzr/bugs/b57108-5.5-bugteam/mysql-test/var/run/mysqld.1.pid -#host=localhost -port=13000 -socket=/home/bzr/bugs/b57108-5.5-bugteam/mysql-test/var/tmp/mysqld.1.sock -#log-error=/home/bzr/bugs/b57108-5.5-bugteam/mysql-test/var/log/mysqld.1.err -general_log=1 -general_log_file=/home/bzr/bugs/b57108-5.5-bugteam/mysql-test/var/mysqld.1/mysqld.log -slow_query_log=1 -slow_query_log_file=/home/bzr/bugs/b57108-5.5-bugteam/mysql-test/var/mysqld.1/mysqld-slow.log -#user=root -#password= -server-id=1 -secure-file-priv=/home/bzr/bugs/b57108-5.5-bugteam/mysql-test/var -ssl-ca=/home/bzr/bugs/b57108-5.5-bugteam/mysql-test/std_data/cacert.pem -ssl-cert=/home/bzr/bugs/b57108-5.5-bugteam/mysql-test/std_data/server-cert.pem -ssl-key=/home/bzr/bugs/b57108-5.5-bugteam/mysql-test/std_data/server-key.pem - -[mysqlbinlog] -disable-force-if-open -character-sets-dir=/home/bzr/bugs/b57108-5.5-bugteam/sql/share/charsets - -[ENV] -MASTER_MYPORT=13000 -MASTER_MYSOCK=/home/bzr/bugs/b57108-5.5-bugteam/mysql-test/var/tmp/mysqld.1.sock - -[client] -password= -user=root -port=13000 -host=localhost -socket=/home/bzr/bugs/b57108-5.5-bugteam/mysql-test/var/tmp/mysqld.1.sock - -[mysqltest] -ssl-ca=/home/bzr/bugs/b57108-5.5-bugteam/mysql-test/std_data/cacert.pem -ssl-cert=/home/bzr/bugs/b57108-5.5-bugteam/mysql-test/std_data/client-cert.pem -ssl-key=/home/bzr/bugs/b57108-5.5-bugteam/mysql-test/std_data/client-key.pem -skip-ssl=1 - -[client.1] -password= -user=root -port=13000 -host=localhost -socket=/home/bzr/bugs/b57108-5.5-bugteam/mysql-test/var/tmp/mysqld.1.sock - diff --git a/mysql-test/std_data/latin1.xml b/mysql-test/std_data/latin1.xml index 458b1c34da1..5884416c30e 100644 --- a/mysql-test/std_data/latin1.xml +++ b/mysql-test/std_data/latin1.xml @@ -3,7 +3,8 @@ <charsets> <copyright> - Copyright (C) 2009 Sun Microsystems, Inc + Copyright (c) 2009 Sun Microsystems, Inc. + Use is subject to license terms. 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 @@ -16,7 +17,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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA </copyright> <charset name="latin1"> diff --git a/mysql-test/suite/binlog/r/binlog_row_annotate.result b/mysql-test/suite/binlog/r/binlog_row_annotate.result index 9442dd63efb..0c008661784 100644 --- a/mysql-test/suite/binlog/r/binlog_row_annotate.result +++ b/mysql-test/suite/binlog/r/binlog_row_annotate.result @@ -427,7 +427,7 @@ ROLLBACK /* added by mysqlbinlog */; /*!50003 SET COMPLETION_TYPE=@OLD_COMPLETION_TYPE*/; # ##################################################################################### -# mysqlbinlog --skip-annotate-rows-events +# mysqlbinlog --skip-annotate-row-events # No Annotates should appear in this output ##################################################################################### /*!40019 SET @@session.max_insert_delayed_threads=0*/; @@ -1013,7 +1013,7 @@ ROLLBACK /* added by mysqlbinlog */; /*!50003 SET COMPLETION_TYPE=@OLD_COMPLETION_TYPE*/; # ##################################################################################### -# mysqlbinlog --read-from-remote-server --skip-annotate-rows-events +# mysqlbinlog --read-from-remote-server --skip-annotate-row-events # No Annotates should appear in this output ##################################################################################### /*!40019 SET @@session.max_insert_delayed_threads=0*/; diff --git a/mysql-test/suite/binlog/r/binlog_stm_blackhole.result b/mysql-test/suite/binlog/r/binlog_stm_blackhole.result index 7e79186e7bc..e76f6b494f9 100644 --- a/mysql-test/suite/binlog/r/binlog_stm_blackhole.result +++ b/mysql-test/suite/binlog/r/binlog_stm_blackhole.result @@ -99,6 +99,8 @@ alter table t1 drop b; create table t3 like t1; insert into t1 select * from t3; replace into t1 select * from t3; +Warnings: +Note 1592 Unsafe statement written to the binary log using statement format since BINLOG_FORMAT = STATEMENT. REPLACE... SELECT is unsafe because the order in which rows are retrieved by the SELECT determines which (if any) rows are replaced. This order cannot be predicted and may differ on master and the slave. select * from t1; a select * from t2; diff --git a/mysql-test/suite/binlog/r/binlog_unsafe.result b/mysql-test/suite/binlog/r/binlog_unsafe.result index e8449f0cd11..17ad4c6e5b1 100644 --- a/mysql-test/suite/binlog/r/binlog_unsafe.result +++ b/mysql-test/suite/binlog/r/binlog_unsafe.result @@ -2352,6 +2352,7 @@ Note 1592 Unsafe statement written to the binary log using statement format sinc REPLACE INTO t1 SELECT * FROM t1 LIMIT 1; Warnings: Note 1592 Unsafe statement written to the binary log using statement format since BINLOG_FORMAT = STATEMENT. The statement is unsafe because it uses a LIMIT clause. This is unsafe because the set of rows included cannot be predicted. +Note 1592 Unsafe statement written to the binary log using statement format since BINLOG_FORMAT = STATEMENT. REPLACE... SELECT is unsafe because the order in which rows are retrieved by the SELECT determines which (if any) rows are replaced. This order cannot be predicted and may differ on master and the slave. UPDATE t1 SET a=1 LIMIT 1; Warnings: Note 1592 Unsafe statement written to the binary log using statement format since BINLOG_FORMAT = STATEMENT. The statement is unsafe because it uses a LIMIT clause. This is unsafe because the set of rows included cannot be predicted. @@ -2368,6 +2369,7 @@ END| CALL p1(); Warnings: Note 1592 Unsafe statement written to the binary log using statement format since BINLOG_FORMAT = STATEMENT. The statement is unsafe because it uses a LIMIT clause. This is unsafe because the set of rows included cannot be predicted. +Note 1592 Unsafe statement written to the binary log using statement format since BINLOG_FORMAT = STATEMENT. REPLACE... SELECT is unsafe because the order in which rows are retrieved by the SELECT determines which (if any) rows are replaced. This order cannot be predicted and may differ on master and the slave. DROP PROCEDURE p1; DROP TABLE t1; DROP TABLE IF EXISTS t1; @@ -2650,4 +2652,40 @@ a 13:46:40 1970-01-12 13:46:40 DROP TABLE t1; +CREATE TABLE filler_table (a INT, b INT); +INSERT INTO filler_table values (1,1),(1,2); +CREATE TABLE insert_table (a INT, b INT, PRIMARY KEY(a)); +CREATE TABLE replace_table (a INT, b INT, PRIMARY KEY(a)); +INSERT INTO replace_table values (1,1),(2,2); +CREATE TABLE update_table (a INT, b INT, PRIMARY KEY(a)); +INSERT INTO update_table values (1,1),(2,2); +INSERT IGNORE INTO insert_table SELECT * FROM filler_table; +Warnings: +Note 1592 Unsafe statement written to the binary log using statement format since BINLOG_FORMAT = STATEMENT. INSERT IGNORE... SELECT is unsafe because the order in which rows are retrieved by the SELECT determines which (if any) rows are ignored. This order cannot be predicted and may differ on master and the slave. +TRUNCATE TABLE insert_table; +INSERT INTO insert_table SELECT * FROM filler_table ON DUPLICATE KEY UPDATE a = 1; +Warnings: +Note 1592 Unsafe statement written to the binary log using statement format since BINLOG_FORMAT = STATEMENT. INSERT... SELECT... ON DUPLICATE KEY UPDATE is unsafe because the order in which rows are retrieved by the SELECT determines which (if any) rows are updated. This order cannot be predicted and may differ on master and the slave. +TRUNCATE TABLE insert_table; +REPLACE INTO replace_table SELECT * FROM filler_table; +Warnings: +Note 1592 Unsafe statement written to the binary log using statement format since BINLOG_FORMAT = STATEMENT. REPLACE... SELECT is unsafe because the order in which rows are retrieved by the SELECT determines which (if any) rows are replaced. This order cannot be predicted and may differ on master and the slave. +UPDATE IGNORE update_table SET a=2; +Warnings: +Note 1592 Unsafe statement written to the binary log using statement format since BINLOG_FORMAT = STATEMENT. UPDATE IGNORE is unsafe because the order in which rows are updated determines which (if any) rows are ignored. This order cannot be predicted and may differ on master and the slave. +CREATE TABLE create_ignore_test (a INT, b INT, PRIMARY KEY(b)) IGNORE SELECT * FROM filler_table; +Warnings: +Note 1592 Unsafe statement written to the binary log using statement format since BINLOG_FORMAT = STATEMENT. CREATE... IGNORE SELECT is unsafe because the order in which rows are retrieved by the SELECT determines which (if any) rows are ignored. This order cannot be predicted and may differ on master and the slave. +CREATE TABLE create_replace_test (a INT, b INT, PRIMARY KEY(b)) REPLACE SELECT * FROM filler_table; +Warnings: +Note 1592 Unsafe statement written to the binary log using statement format since BINLOG_FORMAT = STATEMENT. CREATE... REPLACE SELECT is unsafe because the order in which rows are retrieved by the SELECT determines which (if any) rows are replaced. This order cannot be predicted and may differ on master and the slave. +CREATE TEMPORARY TABLE temp1 (a INT, b INT, PRIMARY KEY(b)) REPLACE SELECT * FROM filler_table; +Warnings: +Note 1592 Unsafe statement written to the binary log using statement format since BINLOG_FORMAT = STATEMENT. CREATE... REPLACE SELECT is unsafe because the order in which rows are retrieved by the SELECT determines which (if any) rows are replaced. This order cannot be predicted and may differ on master and the slave. +DROP TABLE filler_table; +DROP TABLE insert_table; +DROP TABLE update_table; +DROP TABLE replace_table; +DROP TABLE create_ignore_test; +DROP TABLE create_replace_test; "End of tests" diff --git a/mysql-test/suite/binlog/t/binlog_row_annotate.test b/mysql-test/suite/binlog/t/binlog_row_annotate.test index c5db9ef2148..a0f72c9222c 100644 --- a/mysql-test/suite/binlog/t/binlog_row_annotate.test +++ b/mysql-test/suite/binlog/t/binlog_row_annotate.test @@ -1,11 +1,11 @@ ############################################################################### # WL47: Store in binlog text of statements that caused RBR events # new event: ANNOTATE_ROWS_EVENT -# new master option: --binlog-annotate-rows-events -# new mysqlbinlog option: --skip-annotate-rows-events +# new master option: --binlog-annotate-row-events +# new mysqlbinlog option: --skip-annotate-row-events # # Intended to test that: -# *** If the --binlog-annotate-rows-events option is switched on on master +# *** If the --binlog-annotate-row-events option is switched on on master # then Annotate_rows events: # - are generated; # - are genrated only once for "multi-table-maps" rbr queries; @@ -13,9 +13,9 @@ # - are generated when the corresponding queries are filtered away partialy # (e.g. in case of multi-delete). # *** Annotate_rows events are printed by mysqlbinlog started without -# --skip-annotate-rows-events options both in remote and local cases. +# --skip-annotate-row-events options both in remote and local cases. # *** Annotate_rows events are not printed by mysqlbinlog started with -# --skip-annotate-rows-events options both in remote and local cases. +# --skip-annotate-row-events options both in remote and local cases. ############################################################################### --source include/have_log_bin.inc @@ -54,11 +54,11 @@ CREATE TABLE xtest1.xt1(a int); CREATE DATABASE xtest2; CREATE TABLE xtest2.xt2(a int); -# By default SESSION binlog_annotate_rows_events = OFF +# By default SESSION binlog_annotate_row_events = OFF INSERT INTO test1.t1 VALUES (1), (2), (3); -SET SESSION binlog_annotate_rows_events = ON; +SET SESSION binlog_annotate_row_events = ON; INSERT INTO test2.t2 VALUES (1), (2), (3); INSERT INTO test3.t3 VALUES (1), (2), (3); @@ -133,13 +133,13 @@ let $MYSQLD_DATADIR= `select @@datadir`; --echo # --echo ##################################################################################### ---echo # mysqlbinlog --skip-annotate-rows-events +--echo # mysqlbinlog --skip-annotate-row-events --echo # No Annotates should appear in this output --echo ##################################################################################### let $MYSQLD_DATADIR= `select @@datadir`; --replace_regex /server id [0-9]*/server id #/ /server v [^ ]*/server v #.##.##/ /exec_time=[0-9]*/exec_time=#/ /thread_id=[0-9]*/thread_id=#/ /table id [0-9]*/table id #/ /mapped to number [0-9]*/mapped to number #/ /end_log_pos [0-9]*/end_log_pos #/ /# at [0-9]*/# at #/ ---exec $MYSQL_BINLOG --base64-output=decode-rows --skip-annotate-rows-events -v -v $MYSQLD_DATADIR/master-bin.000001 +--exec $MYSQL_BINLOG --base64-output=decode-rows --skip-annotate-row-events -v -v $MYSQLD_DATADIR/master-bin.000001 --echo # --echo ##################################################################################### @@ -169,13 +169,13 @@ let $MYSQLD_DATADIR= `select @@datadir`; --echo # --echo ##################################################################################### ---echo # mysqlbinlog --read-from-remote-server --skip-annotate-rows-events +--echo # mysqlbinlog --read-from-remote-server --skip-annotate-row-events --echo # No Annotates should appear in this output --echo ##################################################################################### let $MYSQLD_DATADIR= `select @@datadir`; --replace_regex /server id [0-9]*/server id #/ /server v [^ ]*/server v #.##.##/ /exec_time=[0-9]*/exec_time=#/ /thread_id=[0-9]*/thread_id=#/ /table id [0-9]*/table id #/ /mapped to number [0-9]*/mapped to number #/ /end_log_pos [0-9]*/end_log_pos #/ /# at [0-9]*/# at #/ ---exec $MYSQL_BINLOG --base64-output=decode-rows --skip-annotate-rows-events -v -v --read-from-remote-server --user=root --host=localhost --port=$MASTER_MYPORT master-bin.000001 +--exec $MYSQL_BINLOG --base64-output=decode-rows --skip-annotate-row-events -v -v --read-from-remote-server --user=root --host=localhost --port=$MASTER_MYPORT master-bin.000001 # Clean-up diff --git a/mysql-test/suite/binlog/t/binlog_unsafe.test b/mysql-test/suite/binlog/t/binlog_unsafe.test index 9fbdc9fc2c8..c64b9197b51 100644 --- a/mysql-test/suite/binlog/t/binlog_unsafe.test +++ b/mysql-test/suite/binlog/t/binlog_unsafe.test @@ -12,6 +12,11 @@ # - insert into two autoinc columns; # - statements using UDF's. # - statements reading from log tables in the mysql database. +# - INSERT ... SELECT ... ON DUPLICATE KEY UPDATE +# - REPLACE ... SELECT +# - CREATE TABLE [IGNORE/REPLACE] SELECT +# - INSERT IGNORE...SELECT +# - UPDATE IGNORE # # Note that statements that use stored functions, stored procedures, # triggers, views, or prepared statements that invoke unsafe @@ -79,6 +84,7 @@ # BUG#45785: LIMIT in SP does not cause RBL if binlog_format=MIXED # BUG#47995: Mark user functions as unsafe # BUG#49222: Mark RAND() unsafe +# BUG#11758262: MARK INSERT...SEL...ON DUP KEY UPD,REPLACE...SEL,CREATE...[IGN|REPL] SEL # # ==== Related test cases ==== # @@ -700,5 +706,47 @@ INSERT INTO t1 VALUES SELECT * FROM t1; DROP TABLE t1; +# +#BUG#11758262-50439: MARK INSERT...SEL...ON DUP KEY UPD,REPLACE.. +#The following statement may be unsafe when logged in statement format. +#INSERT IGNORE...SELECT +#INSERT ... SELECT ... ON DUPLICATE KEY UPDATE +#REPLACE ... SELECT +#UPDATE IGNORE +#CREATE TABLE... IGNORE SELECT +#CREATE TABLE... REPLACE SELECT + +#setup tables +CREATE TABLE filler_table (a INT, b INT); +INSERT INTO filler_table values (1,1),(1,2); +CREATE TABLE insert_table (a INT, b INT, PRIMARY KEY(a)); +CREATE TABLE replace_table (a INT, b INT, PRIMARY KEY(a)); +INSERT INTO replace_table values (1,1),(2,2); +CREATE TABLE update_table (a INT, b INT, PRIMARY KEY(a)); +INSERT INTO update_table values (1,1),(2,2); + +#INSERT IGNORE... SELECT +INSERT IGNORE INTO insert_table SELECT * FROM filler_table; +TRUNCATE TABLE insert_table; +#INSERT ... SELECT ... ON DUPLICATE KEY UPDATE +INSERT INTO insert_table SELECT * FROM filler_table ON DUPLICATE KEY UPDATE a = 1; +TRUNCATE TABLE insert_table; +#REPLACE...SELECT +REPLACE INTO replace_table SELECT * FROM filler_table; +#UPDATE IGNORE +UPDATE IGNORE update_table SET a=2; +#CREATE TABLE [IGNORE/REPLACE] SELECT +CREATE TABLE create_ignore_test (a INT, b INT, PRIMARY KEY(b)) IGNORE SELECT * FROM filler_table; +CREATE TABLE create_replace_test (a INT, b INT, PRIMARY KEY(b)) REPLACE SELECT * FROM filler_table; +#temporary tables should not throw the warning. +CREATE TEMPORARY TABLE temp1 (a INT, b INT, PRIMARY KEY(b)) REPLACE SELECT * FROM filler_table; + +###clean up +DROP TABLE filler_table; +DROP TABLE insert_table; +DROP TABLE update_table; +DROP TABLE replace_table; +DROP TABLE create_ignore_test; +DROP TABLE create_replace_test; --echo "End of tests" diff --git a/mysql-test/suite/federated/my.cnf b/mysql-test/suite/federated/my.cnf index 88344ae59ae..ec27e189179 100644 --- a/mysql-test/suite/federated/my.cnf +++ b/mysql-test/suite/federated/my.cnf @@ -3,7 +3,7 @@ !include include/default_client.cnf [mysqld.1] -log-bin= master-bin +#log-bin= master-bin [mysqld.2] diff --git a/mysql-test/suite/funcs_1/r/innodb_func_view.result b/mysql-test/suite/funcs_1/r/innodb_func_view.result index cea131523e8..29a2a2aa861 100644 --- a/mysql-test/suite/funcs_1/r/innodb_func_view.result +++ b/mysql-test/suite/funcs_1/r/innodb_func_view.result @@ -3716,8 +3716,8 @@ NULL 1.7976931348623e308 3 -00:00:01 -1 5 00:17:58 1758 25 Warnings: -Warning 1292 Incorrect datetime value: '-1.7976931348623e308' for column 'my_double' at row 2 -Warning 1292 Incorrect datetime value: '1.7976931348623e308' for column 'my_double' at row 3 +Warning 1292 Incorrect datetime value: '-1.7976931348623e308' for column 'my_double' at row 1 +Warning 1292 Incorrect datetime value: '1.7976931348623e308' for column 'my_double' at row 1 DROP VIEW v1; @@ -4068,10 +4068,10 @@ NULL 1.7976931348623e308 3 NULL -1 5 NULL 200506271758 19 Warnings: -Warning 1292 Incorrect datetime value: '-1.7976931348623e308' for column 'my_double' at row 2 -Warning 1292 Incorrect datetime value: '1.7976931348623e308' for column 'my_double' at row 3 -Warning 1292 Incorrect datetime value: '-1' for column 'my_double' at row 5 -Warning 1292 Incorrect datetime value: '200506271758' for column 'my_double' at row 19 +Warning 1292 Incorrect datetime value: '-1.7976931348623e308' for column 'my_double' at row 1 +Warning 1292 Incorrect datetime value: '1.7976931348623e308' for column 'my_double' at row 1 +Warning 1292 Incorrect datetime value: '-1' for column 'my_double' at row 1 +Warning 1292 Incorrect datetime value: '200506271758' for column 'my_double' at row 1 DROP VIEW v1; @@ -4429,9 +4429,9 @@ NULL 1.7976931348623e308 3 NULL -1 5 2005-06-27 20050627 13 Warnings: -Warning 1292 Incorrect datetime value: '-1.7976931348623e308' for column 'my_double' at row 2 -Warning 1292 Incorrect datetime value: '1.7976931348623e308' for column 'my_double' at row 3 -Warning 1292 Incorrect datetime value: '-1' for column 'my_double' at row 5 +Warning 1292 Incorrect datetime value: '-1.7976931348623e308' for column 'my_double' at row 1 +Warning 1292 Incorrect datetime value: '1.7976931348623e308' for column 'my_double' at row 1 +Warning 1292 Incorrect datetime value: '-1' for column 'my_double' at row 1 DROP VIEW v1; diff --git a/mysql-test/suite/funcs_1/r/is_columns_mysql.result b/mysql-test/suite/funcs_1/r/is_columns_mysql.result index 417228db52d..4eff12dab7b 100644 --- a/mysql-test/suite/funcs_1/r/is_columns_mysql.result +++ b/mysql-test/suite/funcs_1/r/is_columns_mysql.result @@ -205,7 +205,7 @@ def mysql user Lock_tables_priv 21 N NO enum 1 3 NULL NULL NULL utf8 utf8_genera def mysql user max_connections 39 0 NO int NULL NULL 10 0 NULL NULL NULL int(11) unsigned select,insert,update,references def mysql user max_questions 37 0 NO int NULL NULL 10 0 NULL NULL NULL int(11) unsigned select,insert,update,references def mysql user max_updates 38 0 NO int NULL NULL 10 0 NULL NULL NULL int(11) unsigned select,insert,update,references -def mysql user max_user_connections 40 0 NO int NULL NULL 10 0 NULL NULL NULL int(11) unsigned select,insert,update,references +def mysql user max_user_connections 40 0 NO int NULL NULL 10 0 NULL NULL NULL int(11) select,insert,update,references def mysql user Password 3 NO char 41 41 NULL NULL NULL latin1 latin1_bin char(41) select,insert,update,references def mysql user plugin 41 NO char 64 64 NULL NULL NULL latin1 latin1_swedish_ci char(64) select,insert,update,references def mysql user Process_priv 12 N NO enum 1 3 NULL NULL NULL utf8 utf8_general_ci enum('N','Y') select,insert,update,references @@ -515,6 +515,6 @@ NULL mysql time_zone_transition_type Is_DST tinyint NULL NULL NULL NULL tinyint( NULL mysql user max_questions int NULL NULL NULL NULL int(11) unsigned NULL mysql user max_updates int NULL NULL NULL NULL int(11) unsigned NULL mysql user max_connections int NULL NULL NULL NULL int(11) unsigned -NULL mysql user max_user_connections int NULL NULL NULL NULL int(11) unsigned +NULL mysql user max_user_connections int NULL NULL NULL NULL int(11) 1.0000 mysql user plugin char 64 64 latin1 latin1_swedish_ci char(64) 1.0000 mysql user authentication_string text 65535 65535 utf8 utf8_bin text diff --git a/mysql-test/suite/funcs_1/r/memory_func_view.result b/mysql-test/suite/funcs_1/r/memory_func_view.result index 23aba87e7bf..d8f26c81e58 100644 --- a/mysql-test/suite/funcs_1/r/memory_func_view.result +++ b/mysql-test/suite/funcs_1/r/memory_func_view.result @@ -3717,8 +3717,8 @@ NULL 1.7976931348623e308 3 -00:00:01 -1 5 00:17:58 1758 25 Warnings: -Warning 1292 Incorrect datetime value: '-1.7976931348623e308' for column 'my_double' at row 2 -Warning 1292 Incorrect datetime value: '1.7976931348623e308' for column 'my_double' at row 3 +Warning 1292 Incorrect datetime value: '-1.7976931348623e308' for column 'my_double' at row 1 +Warning 1292 Incorrect datetime value: '1.7976931348623e308' for column 'my_double' at row 1 DROP VIEW v1; @@ -4069,10 +4069,10 @@ NULL 1.7976931348623e308 3 NULL -1 5 NULL 200506271758 19 Warnings: -Warning 1292 Incorrect datetime value: '-1.7976931348623e308' for column 'my_double' at row 2 -Warning 1292 Incorrect datetime value: '1.7976931348623e308' for column 'my_double' at row 3 -Warning 1292 Incorrect datetime value: '-1' for column 'my_double' at row 5 -Warning 1292 Incorrect datetime value: '200506271758' for column 'my_double' at row 6 +Warning 1292 Incorrect datetime value: '-1.7976931348623e308' for column 'my_double' at row 1 +Warning 1292 Incorrect datetime value: '1.7976931348623e308' for column 'my_double' at row 1 +Warning 1292 Incorrect datetime value: '-1' for column 'my_double' at row 1 +Warning 1292 Incorrect datetime value: '200506271758' for column 'my_double' at row 1 DROP VIEW v1; @@ -4430,9 +4430,9 @@ NULL 1.7976931348623e308 3 NULL -1 5 2005-06-27 20050627 13 Warnings: -Warning 1292 Incorrect datetime value: '-1.7976931348623e308' for column 'my_double' at row 2 -Warning 1292 Incorrect datetime value: '1.7976931348623e308' for column 'my_double' at row 3 -Warning 1292 Incorrect datetime value: '-1' for column 'my_double' at row 5 +Warning 1292 Incorrect datetime value: '-1.7976931348623e308' for column 'my_double' at row 1 +Warning 1292 Incorrect datetime value: '1.7976931348623e308' for column 'my_double' at row 1 +Warning 1292 Incorrect datetime value: '-1' for column 'my_double' at row 1 DROP VIEW v1; diff --git a/mysql-test/suite/funcs_1/r/myisam_func_view.result b/mysql-test/suite/funcs_1/r/myisam_func_view.result index 23aba87e7bf..d8f26c81e58 100644 --- a/mysql-test/suite/funcs_1/r/myisam_func_view.result +++ b/mysql-test/suite/funcs_1/r/myisam_func_view.result @@ -3717,8 +3717,8 @@ NULL 1.7976931348623e308 3 -00:00:01 -1 5 00:17:58 1758 25 Warnings: -Warning 1292 Incorrect datetime value: '-1.7976931348623e308' for column 'my_double' at row 2 -Warning 1292 Incorrect datetime value: '1.7976931348623e308' for column 'my_double' at row 3 +Warning 1292 Incorrect datetime value: '-1.7976931348623e308' for column 'my_double' at row 1 +Warning 1292 Incorrect datetime value: '1.7976931348623e308' for column 'my_double' at row 1 DROP VIEW v1; @@ -4069,10 +4069,10 @@ NULL 1.7976931348623e308 3 NULL -1 5 NULL 200506271758 19 Warnings: -Warning 1292 Incorrect datetime value: '-1.7976931348623e308' for column 'my_double' at row 2 -Warning 1292 Incorrect datetime value: '1.7976931348623e308' for column 'my_double' at row 3 -Warning 1292 Incorrect datetime value: '-1' for column 'my_double' at row 5 -Warning 1292 Incorrect datetime value: '200506271758' for column 'my_double' at row 6 +Warning 1292 Incorrect datetime value: '-1.7976931348623e308' for column 'my_double' at row 1 +Warning 1292 Incorrect datetime value: '1.7976931348623e308' for column 'my_double' at row 1 +Warning 1292 Incorrect datetime value: '-1' for column 'my_double' at row 1 +Warning 1292 Incorrect datetime value: '200506271758' for column 'my_double' at row 1 DROP VIEW v1; @@ -4430,9 +4430,9 @@ NULL 1.7976931348623e308 3 NULL -1 5 2005-06-27 20050627 13 Warnings: -Warning 1292 Incorrect datetime value: '-1.7976931348623e308' for column 'my_double' at row 2 -Warning 1292 Incorrect datetime value: '1.7976931348623e308' for column 'my_double' at row 3 -Warning 1292 Incorrect datetime value: '-1' for column 'my_double' at row 5 +Warning 1292 Incorrect datetime value: '-1.7976931348623e308' for column 'my_double' at row 1 +Warning 1292 Incorrect datetime value: '1.7976931348623e308' for column 'my_double' at row 1 +Warning 1292 Incorrect datetime value: '-1' for column 'my_double' at row 1 DROP VIEW v1; diff --git a/mysql-test/suite/innodb/r/innodb-index.result b/mysql-test/suite/innodb/r/innodb-index.result index 7d7062c9161..a33099661aa 100644 --- a/mysql-test/suite/innodb/r/innodb-index.result +++ b/mysql-test/suite/innodb/r/innodb-index.result @@ -1,3 +1,121 @@ +set global innodb_file_per_table=on; +set global innodb_file_format='Barracuda'; +CREATE TABLE t1_purge ( +A INT, +B BLOB, C BLOB, D BLOB, E BLOB, +F BLOB, G BLOB, H BLOB, +PRIMARY KEY (B(767), C(767), D(767), E(767), A), +INDEX (A) +) ENGINE=InnoDB ROW_FORMAT=DYNAMIC; +INSERT INTO t1_purge VALUES (1, +REPEAT('b', 766), REPEAT('c', 766), REPEAT('d', 766), REPEAT('e', 766), +REPEAT('f', 766), REPEAT('g', 766), REPEAT('h', 766)); +CREATE TABLE t2_purge ( +A INT PRIMARY KEY, +B BLOB, C BLOB, D BLOB, E BLOB, +F BLOB, G BLOB, H BLOB, I BLOB, +J BLOB, K BLOB, L BLOB, +INDEX (B(767))) ENGINE=InnoDB ROW_FORMAT=DYNAMIC; +INSERT INTO t2_purge VALUES (1, +REPEAT('b', 766), REPEAT('c', 766), REPEAT('d', 766), REPEAT('e', 766), +REPEAT('f', 766), REPEAT('g', 766), REPEAT('h', 766), REPEAT('i', 766), +REPEAT('j', 766), REPEAT('k', 766), REPEAT('l', 766)); +CREATE TABLE t3_purge ( +A INT, +B VARCHAR(800), C VARCHAR(800), D VARCHAR(800), E VARCHAR(800), +F VARCHAR(800), G VARCHAR(800), H VARCHAR(800), +PRIMARY KEY (B(767), C(767), D(767), E(767), A), +INDEX (A) +) ENGINE=InnoDB ROW_FORMAT=DYNAMIC; +INSERT INTO t3_purge SELECT * FROM t1_purge; +CREATE TABLE t4_purge ( +A INT PRIMARY KEY, +B VARCHAR(800), C VARCHAR(800), D VARCHAR(800), E VARCHAR(800), +F VARCHAR(800), G VARCHAR(800), H VARCHAR(800), I VARCHAR(800), +J VARCHAR(800), K VARCHAR(800), L VARCHAR(800), +INDEX (B(767))) ENGINE=InnoDB ROW_FORMAT=DYNAMIC; +INSERT INTO t4_purge SELECT * FROM t2_purge; +DELETE FROM t1_purge; +DELETE FROM t2_purge; +DELETE FROM t3_purge; +DELETE FROM t4_purge; +SET @r=REPEAT('a',500); +CREATE TABLE t12637786(a INT, +v1 VARCHAR(500), v2 VARCHAR(500), v3 VARCHAR(500), +v4 VARCHAR(500), v5 VARCHAR(500), v6 VARCHAR(500), +v7 VARCHAR(500), v8 VARCHAR(500), v9 VARCHAR(500), +v10 VARCHAR(500), v11 VARCHAR(500), v12 VARCHAR(500), +v13 VARCHAR(500), v14 VARCHAR(500), v15 VARCHAR(500), +v16 VARCHAR(500), v17 VARCHAR(500), v18 VARCHAR(500) +) ENGINE=InnoDB ROW_FORMAT=DYNAMIC; +CREATE INDEX idx1 ON t12637786(a,v1); +INSERT INTO t12637786 VALUES(9,@r,@r,@r,@r,@r,@r,@r,@r,@r,@r,@r,@r,@r,@r,@r,@r,@r,@r); +UPDATE t12637786 SET a=1000; +DELETE FROM t12637786; +create table t12963823(a blob,b blob,c blob,d blob,e blob,f blob,g blob,h blob, +i blob,j blob,k blob,l blob,m blob,n blob,o blob,p blob) +engine=innodb row_format=dynamic; +SET @r = repeat('a', 767); +insert into t12963823 values (@r,@r,@r,@r, @r,@r,@r,@r, @r,@r,@r,@r, @r,@r,@r,@r); +create index ndx_a on t12963823 (a(500)); +create index ndx_b on t12963823 (b(500)); +create index ndx_c on t12963823 (c(500)); +create index ndx_d on t12963823 (d(500)); +create index ndx_e on t12963823 (e(500)); +create index ndx_f on t12963823 (f(500)); +create index ndx_k on t12963823 (k(500)); +create index ndx_l on t12963823 (l(500)); +SET @r = repeat('b', 500); +update t12963823 set a=@r,b=@r,c=@r,d=@r; +update t12963823 set e=@r,f=@r,g=@r,h=@r; +update t12963823 set i=@r,j=@r,k=@r,l=@r; +update t12963823 set m=@r,n=@r,o=@r,p=@r; +alter table t12963823 drop index ndx_a; +alter table t12963823 drop index ndx_b; +create index ndx_g on t12963823 (g(500)); +create index ndx_h on t12963823 (h(500)); +create index ndx_i on t12963823 (i(500)); +create index ndx_j on t12963823 (j(500)); +create index ndx_m on t12963823 (m(500)); +create index ndx_n on t12963823 (n(500)); +create index ndx_o on t12963823 (o(500)); +create index ndx_p on t12963823 (p(500)); +show create table t12963823; +Table Create Table +t12963823 CREATE TABLE `t12963823` ( + `a` blob, + `b` blob, + `c` blob, + `d` blob, + `e` blob, + `f` blob, + `g` blob, + `h` blob, + `i` blob, + `j` blob, + `k` blob, + `l` blob, + `m` blob, + `n` blob, + `o` blob, + `p` blob, + KEY `ndx_c` (`c`(500)), + KEY `ndx_d` (`d`(500)), + KEY `ndx_e` (`e`(500)), + KEY `ndx_f` (`f`(500)), + KEY `ndx_k` (`k`(500)), + KEY `ndx_l` (`l`(500)), + KEY `ndx_g` (`g`(500)), + KEY `ndx_h` (`h`(500)), + KEY `ndx_i` (`i`(500)), + KEY `ndx_j` (`j`(500)), + KEY `ndx_m` (`m`(500)), + KEY `ndx_n` (`n`(500)), + KEY `ndx_o` (`o`(500)), + KEY `ndx_p` (`p`(500)) +) ENGINE=InnoDB DEFAULT CHARSET=latin1 ROW_FORMAT=DYNAMIC +set global innodb_file_per_table=0; +set global innodb_file_format=Antelope; create table t1(a int not null, b int, c char(10) not null, d varchar(20)) engine = innodb; insert into t1 values (5,5,'oo','oo'),(4,4,'tr','tr'),(3,4,'ad','ad'),(2,3,'ak','ak'); commit; @@ -918,6 +1036,15 @@ ERROR HY000: Too big row alter table t1 row_format=compact; create index t1u on t1 (u(767)); drop table t1; +CREATE TABLE bug12547647( +a INT NOT NULL, b BLOB NOT NULL, c TEXT, +PRIMARY KEY (b(10), a), INDEX (c(767)), INDEX(b(767)) +) ENGINE=InnoDB ROW_FORMAT=DYNAMIC; +INSERT INTO bug12547647 VALUES (5,repeat('khdfo5AlOq',1900),repeat('g',7751)); +COMMIT; +UPDATE bug12547647 SET c = REPEAT('b',16928); +ERROR HY000: Undo log record is too big. +DROP TABLE bug12547647; set global innodb_file_per_table=0; set global innodb_file_format=Antelope; set global innodb_file_format_max=Antelope; @@ -1085,3 +1212,9 @@ t2 CREATE TABLE `t2` ( ) ENGINE=InnoDB DEFAULT CHARSET=latin1 DROP TABLE t2; DROP TABLE t1; +SELECT SLEEP(10); +SLEEP(10) +0 +DROP TABLE t1_purge, t2_purge, t3_purge, t4_purge; +DROP TABLE t12637786; +DROP TABLE t12963823; diff --git a/mysql-test/suite/innodb/r/innodb-zip.result b/mysql-test/suite/innodb/r/innodb-zip.result index a63ddff15ce..94f3bc71af1 100644 --- a/mysql-test/suite/innodb/r/innodb-zip.result +++ b/mysql-test/suite/innodb/r/innodb-zip.result @@ -63,42 +63,42 @@ row_format=compressed; create table t14(a int primary key) engine=innodb key_block_size=9; Warnings: Warning 1478 InnoDB: ignoring KEY_BLOCK_SIZE=9. -SELECT table_schema, table_name, row_format +SELECT table_schema, table_name, row_format, data_length, index_length FROM information_schema.tables WHERE engine='innodb'; -table_schema table_name row_format -test t0 Compact -test t00 Compact -test t1 Compact -test t10 Dynamic -test t11 Compressed -test t12 Compressed -test t13 Compressed -test t14 Compact -test t2 Redundant -test t3 Compact -test t4 Compact -test t5 Redundant -test t6 Redundant -test t7 Redundant -test t8 Compact -test t9 Compact +table_schema table_name row_format data_length index_length +test t0 Compact 16384 0 +test t00 Compact 16384 0 +test t1 Compact 16384 0 +test t10 Dynamic 16384 0 +test t11 Compressed 1024 0 +test t12 Compressed 1024 0 +test t13 Compressed 8192 0 +test t14 Compact 16384 0 +test t2 Redundant 16384 0 +test t3 Compact 16384 0 +test t4 Compact 16384 0 +test t5 Redundant 16384 0 +test t6 Redundant 16384 0 +test t7 Redundant 16384 0 +test t8 Compact 16384 0 +test t9 Compact 16384 0 drop table t0,t00,t2,t3,t4,t5,t6,t7,t8,t9,t10,t11,t12,t13,t14; alter table t1 key_block_size=0; alter table t1 row_format=dynamic; -SELECT table_schema, table_name, row_format +SELECT table_schema, table_name, row_format, data_length, index_length FROM information_schema.tables WHERE engine='innodb'; -table_schema table_name row_format -test t1 Dynamic +table_schema table_name row_format data_length index_length +test t1 Dynamic 16384 0 alter table t1 row_format=compact; -SELECT table_schema, table_name, row_format +SELECT table_schema, table_name, row_format, data_length, index_length FROM information_schema.tables WHERE engine='innodb'; -table_schema table_name row_format -test t1 Compact +table_schema table_name row_format data_length index_length +test t1 Compact 16384 0 alter table t1 row_format=redundant; -SELECT table_schema, table_name, row_format +SELECT table_schema, table_name, row_format, data_length, index_length FROM information_schema.tables WHERE engine='innodb'; -table_schema table_name row_format -test t1 Redundant +table_schema table_name row_format data_length index_length +test t1 Redundant 16384 0 drop table t1; create table t1(a int not null, b text, index(b(10))) engine=innodb key_block_size=1; @@ -115,11 +115,11 @@ rollback; select a,left(b,40) from t1 natural join t2; a left(b,40) 1 1abcdefghijklmnopqrstuvwxyzAAAAAAAAAAAAA -SELECT table_schema, table_name, row_format +SELECT table_schema, table_name, row_format, data_length, index_length FROM information_schema.tables WHERE engine='innodb'; -table_schema table_name row_format -test t1 Compressed -test t2 Compact +table_schema table_name row_format data_length index_length +test t1 Compressed 2048 1024 +test t2 Compact 16384 0 drop table t1,t2; SET SESSION innodb_strict_mode = off; CREATE TABLE t1( @@ -207,19 +207,19 @@ create table t8 (id int primary key) engine = innodb row_format = compressed; create table t9 (id int primary key) engine = innodb row_format = dynamic; create table t10(id int primary key) engine = innodb row_format = compact; create table t11(id int primary key) engine = innodb row_format = redundant; -SELECT table_schema, table_name, row_format +SELECT table_schema, table_name, row_format, data_length, index_length FROM information_schema.tables WHERE engine='innodb'; -table_schema table_name row_format -test t1 Compact -test t10 Compact -test t11 Redundant -test t3 Compressed -test t4 Compressed -test t5 Compressed -test t6 Compressed -test t7 Compressed -test t8 Compressed -test t9 Dynamic +table_schema table_name row_format data_length index_length +test t1 Compact 16384 0 +test t10 Compact 16384 0 +test t11 Redundant 16384 0 +test t3 Compressed 1024 0 +test t4 Compressed 2048 0 +test t5 Compressed 4096 0 +test t6 Compressed 8192 0 +test t7 Compressed 16384 0 +test t8 Compressed 8192 0 +test t9 Dynamic 16384 0 drop table t1, t3, t4, t5, t6, t7, t8, t9, t10, t11; create table t1 (id int primary key) engine = innodb key_block_size = 8 row_format = compressed; @@ -246,11 +246,11 @@ Warning 1478 InnoDB: cannot specify ROW_FORMAT = DYNAMIC with KEY_BLOCK_SIZE. Error 1005 Can't create table 'test.t4' (errno: 1478) create table t5 (id int primary key) engine = innodb key_block_size = 8 row_format = default; -SELECT table_schema, table_name, row_format +SELECT table_schema, table_name, row_format, data_length, index_length FROM information_schema.tables WHERE engine='innodb'; -table_schema table_name row_format -test t1 Compressed -test t5 Compressed +table_schema table_name row_format data_length index_length +test t1 Compressed 8192 0 +test t5 Compressed 8192 0 drop table t1, t5; create table t1 (id int primary key) engine = innodb key_block_size = 9 row_format = redundant; @@ -276,9 +276,9 @@ Level Code Message Warning 1478 InnoDB: invalid KEY_BLOCK_SIZE = 9. Valid values are [1, 2, 4, 8, 16] Warning 1478 InnoDB: cannot specify ROW_FORMAT = DYNAMIC with KEY_BLOCK_SIZE. Error 1005 Can't create table 'test.t2' (errno: 1478) -SELECT table_schema, table_name, row_format +SELECT table_schema, table_name, row_format, data_length, index_length FROM information_schema.tables WHERE engine='innodb'; -table_schema table_name row_format +table_schema table_name row_format data_length index_length set global innodb_file_per_table = off; create table t1 (id int primary key) engine = innodb key_block_size = 1; ERROR HY000: Can't create table 'test.t1' (errno: 1478) @@ -324,11 +324,11 @@ Warning 1478 InnoDB: ROW_FORMAT=DYNAMIC requires innodb_file_per_table. Error 1005 Can't create table 'test.t7' (errno: 1478) create table t8 (id int primary key) engine = innodb row_format = compact; create table t9 (id int primary key) engine = innodb row_format = redundant; -SELECT table_schema, table_name, row_format +SELECT table_schema, table_name, row_format, data_length, index_length FROM information_schema.tables WHERE engine='innodb'; -table_schema table_name row_format -test t8 Compact -test t9 Redundant +table_schema table_name row_format data_length index_length +test t8 Compact 16384 0 +test t9 Redundant 16384 0 drop table t8, t9; set global innodb_file_per_table = on; set global innodb_file_format = `0`; @@ -376,11 +376,11 @@ Warning 1478 InnoDB: ROW_FORMAT=DYNAMIC requires innodb_file_format > Antelope. Error 1005 Can't create table 'test.t7' (errno: 1478) create table t8 (id int primary key) engine = innodb row_format = compact; create table t9 (id int primary key) engine = innodb row_format = redundant; -SELECT table_schema, table_name, row_format +SELECT table_schema, table_name, row_format, data_length, index_length FROM information_schema.tables WHERE engine='innodb'; -table_schema table_name row_format -test t8 Compact -test t9 Redundant +table_schema table_name row_format data_length index_length +test t8 Compact 16384 0 +test t9 Redundant 16384 0 drop table t8, t9; set global innodb_file_per_table=0; set global innodb_file_format=Antelope; diff --git a/mysql-test/suite/innodb/r/innodb.result b/mysql-test/suite/innodb/r/innodb.result index 5f37ae6e2c6..efb47f65e6d 100644 --- a/mysql-test/suite/innodb/r/innodb.result +++ b/mysql-test/suite/innodb/r/innodb.result @@ -785,7 +785,7 @@ create table t1 (a int primary key,b int, c int, d int, e int, f int, g int, h insert into t1 values (1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1); explain select * from t1 where a > 0 and a < 50; id select_type table type possible_keys key key_len ref rows Extra -1 SIMPLE t1 range PRIMARY PRIMARY 4 NULL # Using where +1 SIMPLE t1 range PRIMARY PRIMARY 4 NULL # Using index condition drop table t1; create table t1 (id int NOT NULL,id2 int NOT NULL,id3 int NOT NULL,dummy1 char(30),primary key (id,id2),index index_id3 (id3)) engine=innodb; insert into t1 values (0,0,0,'ABCDEFGHIJ'),(2,2,2,'BCDEFGHIJK'),(1,1,1,'CDEFGHIJKL'); diff --git a/mysql-test/suite/innodb/r/innodb_bug52745.result b/mysql-test/suite/innodb/r/innodb_bug52745.result index d746fb427b5..74db8b0c20a 100644 --- a/mysql-test/suite/innodb/r/innodb_bug52745.result +++ b/mysql-test/suite/innodb/r/innodb_bug52745.result @@ -126,5 +126,4 @@ Warning 1265 Data truncated for column 'col79' at row 1 Warning 1264 Out of range value for column 'col84' at row 1 DROP TABLE bug52745; SET GLOBAL innodb_file_format=Antelope; -SET GLOBAL innodb_file_format_max=Antelope; SET GLOBAL innodb_file_per_table=0; diff --git a/mysql-test/suite/innodb/r/innodb_bug53591.result b/mysql-test/suite/innodb/r/innodb_bug53591.result index 9d296ffdb83..cf226464a4b 100644 --- a/mysql-test/suite/innodb/r/innodb_bug53591.result +++ b/mysql-test/suite/innodb/r/innodb_bug53591.result @@ -11,5 +11,4 @@ Error 139 Too big row Error 1118 Row size too large. The maximum row size for the used table type, not counting BLOBs, is 8126. You have to change some columns to TEXT or BLOBs DROP TABLE bug53591; SET GLOBAL innodb_file_format=Antelope; -SET GLOBAL innodb_file_format_max=Antelope; SET GLOBAL innodb_file_per_table=0; diff --git a/mysql-test/suite/innodb/r/innodb_bug59733.result b/mysql-test/suite/innodb/r/innodb_bug59733.result new file mode 100644 index 00000000000..c962cdfd677 --- /dev/null +++ b/mysql-test/suite/innodb/r/innodb_bug59733.result @@ -0,0 +1,18 @@ +CREATE TABLE bug59733(a INT AUTO_INCREMENT PRIMARY KEY,b CHAR(1))ENGINE=InnoDB; +INSERT INTO bug59733 VALUES(0,'x'); +INSERT INTO bug59733 SELECT 0,b FROM bug59733; +INSERT INTO bug59733 SELECT 0,b FROM bug59733; +INSERT INTO bug59733 SELECT 0,b FROM bug59733; +INSERT INTO bug59733 SELECT 0,b FROM bug59733; +INSERT INTO bug59733 SELECT 0,b FROM bug59733; +INSERT INTO bug59733 SELECT 0,b FROM bug59733; +INSERT INTO bug59733 SELECT 0,b FROM bug59733; +INSERT INTO bug59733 SELECT 0,b FROM bug59733; +INSERT INTO bug59733 SELECT 0,b FROM bug59733; +INSERT INTO bug59733 SELECT 0,b FROM bug59733; +INSERT INTO bug59733 SELECT 0,b FROM bug59733; +CREATE INDEX b ON bug59733 (b); +DELETE FROM bug59733 WHERE (a%100)=0; +DROP INDEX b ON bug59733; +CREATE INDEX b ON bug59733 (b); +DROP TABLE bug59733; diff --git a/mysql-test/suite/innodb/r/innodb_corrupt_bit.result b/mysql-test/suite/innodb/r/innodb_corrupt_bit.result new file mode 100644 index 00000000000..c88e1ed2504 --- /dev/null +++ b/mysql-test/suite/innodb/r/innodb_corrupt_bit.result @@ -0,0 +1,81 @@ +set names utf8; +CREATE TABLE corrupt_bit_test_Ä( +a INT AUTO_INCREMENT PRIMARY KEY, +b CHAR(100), +c INT, +z INT, +INDEX(b)) +ENGINE=InnoDB; +INSERT INTO corrupt_bit_test_Ä VALUES(0,'x',1, 1); +CREATE UNIQUE INDEX idxÄ ON corrupt_bit_test_Ä(c, b); +CREATE UNIQUE INDEX idxÄ“ ON corrupt_bit_test_Ä(z, b); +SELECT * FROM corrupt_bit_test_Ä; +a b c z +1 x 1 1 +select @@unique_checks; +@@unique_checks +0 +select @@innodb_change_buffering_debug; +@@innodb_change_buffering_debug +1 +INSERT INTO corrupt_bit_test_Ä SELECT 0,b,c+1,z+1 FROM corrupt_bit_test_Ä; +INSERT INTO corrupt_bit_test_Ä SELECT 0,b,c+10,z+10 FROM corrupt_bit_test_Ä; +INSERT INTO corrupt_bit_test_Ä SELECT 0,b,c+20,z+20 FROM corrupt_bit_test_Ä; +INSERT INTO corrupt_bit_test_Ä SELECT 0,b,c+50,z+50 FROM corrupt_bit_test_Ä; +INSERT INTO corrupt_bit_test_Ä SELECT 0,b,c+100,z+100 FROM corrupt_bit_test_Ä; +INSERT INTO corrupt_bit_test_Ä SELECT 0,b,c+200,z+200 FROM corrupt_bit_test_Ä; +INSERT INTO corrupt_bit_test_Ä SELECT 0,b,c+400,z+400 FROM corrupt_bit_test_Ä; +INSERT INTO corrupt_bit_test_Ä SELECT 0,b,c+800,z+800 FROM corrupt_bit_test_Ä; +INSERT INTO corrupt_bit_test_Ä SELECT 0,b,c+1600,z+1600 FROM corrupt_bit_test_Ä; +INSERT INTO corrupt_bit_test_Ä SELECT 0,b,c+4000,z+4000 FROM corrupt_bit_test_Ä; +select count(*) from corrupt_bit_test_Ä; +count(*) +1024 +CREATE INDEX idx3 ON corrupt_bit_test_Ä(b, c); +INSERT INTO corrupt_bit_test_Ä VALUES(13000,'x',1,1); +CREATE INDEX idx4 ON corrupt_bit_test_Ä(b, z); +check table corrupt_bit_test_Ä; +Table Op Msg_type Msg_text +test.corrupt_bit_test_Ä check Warning InnoDB: The B-tree of index "idxÄ" is corrupted. +test.corrupt_bit_test_Ä check Warning InnoDB: The B-tree of index "idxÄ“" is corrupted. +test.corrupt_bit_test_Ä check error Corrupt +select c from corrupt_bit_test_Ä; +ERROR HY000: Incorrect key file for table 'corrupt_bit_test_Ä'; try to repair it +select z from corrupt_bit_test_Ä; +ERROR HY000: Incorrect key file for table 'corrupt_bit_test_Ä'; try to repair it +show warnings; +Level Code Message +Warning 179 InnoDB: Index "idxÄ“" for table "test"."corrupt_bit_test_Ä" is marked as corrupted +Error 1034 Incorrect key file for table 'corrupt_bit_test_Ä'; try to repair it +insert into corrupt_bit_test_Ä values (10001, "a", 20001, 20001); +select * from corrupt_bit_test_Ä use index(primary) where a = 10001; +a b c z +10001 a 20001 20001 +begin; +insert into corrupt_bit_test_Ä values (10002, "a", 20002, 20002); +delete from corrupt_bit_test_Ä where a = 10001; +insert into corrupt_bit_test_Ä values (10001, "a", 20001, 20001); +rollback; +drop index idxÄ on corrupt_bit_test_Ä; +check table corrupt_bit_test_Ä; +Table Op Msg_type Msg_text +test.corrupt_bit_test_Ä check Warning InnoDB: Index "idxÄ“" is marked as corrupted +test.corrupt_bit_test_Ä check error Corrupt +set names utf8; +select z from corrupt_bit_test_Ä; +ERROR HY000: Incorrect key file for table 'corrupt_bit_test_Ä'; try to repair it +drop index idxÄ“ on corrupt_bit_test_Ä; +select z from corrupt_bit_test_Ä limit 10; +z +20001 +1 +1 +2 +11 +12 +21 +22 +31 +32 +drop table corrupt_bit_test_Ä; +SET GLOBAL innodb_change_buffering_debug = 0; diff --git a/mysql-test/suite/innodb/r/innodb_file_format.result b/mysql-test/suite/innodb/r/innodb_file_format.result index 70cfc9e4f47..82b4c6fab60 100644 --- a/mysql-test/suite/innodb/r/innodb_file_format.result +++ b/mysql-test/suite/innodb/r/innodb_file_format.result @@ -47,4 +47,3 @@ set global innodb_file_format_max=antelope; set global innodb_file_format_check=off; ERROR HY000: Variable 'innodb_file_format_check' is a read only variable SET GLOBAL innodb_file_format=Antelope; -SET GLOBAL innodb_file_format_max=Antelope; diff --git a/mysql-test/suite/innodb/r/innodb_index_large_prefix.result b/mysql-test/suite/innodb/r/innodb_index_large_prefix.result index b8f8fcfc749..f966574506a 100644 --- a/mysql-test/suite/innodb/r/innodb_index_large_prefix.result +++ b/mysql-test/suite/innodb/r/innodb_index_large_prefix.result @@ -181,5 +181,4 @@ create index idx2 on worklog5743(a(767)); drop table worklog5743; SET GLOBAL innodb_file_format=Antelope; SET GLOBAL innodb_file_per_table=0; -SET GLOBAL innodb_file_format_max=Antelope; SET GLOBAL innodb_large_prefix=0; diff --git a/mysql-test/suite/innodb/r/innodb_prefix_index_liftedlimit.result b/mysql-test/suite/innodb/r/innodb_prefix_index_liftedlimit.result index 73d75241a10..3ab3b28d6b5 100644 --- a/mysql-test/suite/innodb/r/innodb_prefix_index_liftedlimit.result +++ b/mysql-test/suite/innodb/r/innodb_prefix_index_liftedlimit.result @@ -1350,5 +1350,4 @@ Warning 1071 Specified key was too long; max key length is 767 bytes DROP TABLE worklog5743; SET GLOBAL innodb_file_format=Antelope; SET GLOBAL innodb_file_per_table=0; -SET GLOBAL innodb_file_format_max=Antelope; SET GLOBAL innodb_large_prefix=0; diff --git a/mysql-test/suite/innodb/r/innodb_prefix_index_restart_server.result b/mysql-test/suite/innodb/r/innodb_prefix_index_restart_server.result index 09756954b92..abd4c243912 100644 --- a/mysql-test/suite/innodb/r/innodb_prefix_index_restart_server.result +++ b/mysql-test/suite/innodb/r/innodb_prefix_index_restart_server.result @@ -87,5 +87,4 @@ col_1_text = REPEAT("a", 3500) col_2_text = REPEAT("o", 3500) DROP TABLE worklog5743; SET GLOBAL innodb_file_format=Antelope; SET GLOBAL innodb_file_per_table=0; -SET GLOBAL innodb_file_format_max=Antelope; SET GLOBAL innodb_large_prefix=0; diff --git a/mysql-test/suite/innodb/t/disabled.def b/mysql-test/suite/innodb/t/disabled.def index 8cae44a3607..2080a009fb6 100644 --- a/mysql-test/suite/innodb/t/disabled.def +++ b/mysql-test/suite/innodb/t/disabled.def @@ -10,3 +10,5 @@ # ############################################################################## +innodb-index : the fix is not in XtraDB yet +innodb_corrupt_bit : the fix is not in XtraDB yet diff --git a/mysql-test/suite/innodb/t/innodb-autoinc-44030.test b/mysql-test/suite/innodb/t/innodb-autoinc-44030.test index 6bcc901a878..7c9b7017464 100644 --- a/mysql-test/suite/innodb/t/innodb-autoinc-44030.test +++ b/mysql-test/suite/innodb/t/innodb-autoinc-44030.test @@ -1,8 +1,6 @@ # embedded server ignores 'delayed', so skip this -- source include/not_embedded.inc -let $innodb_file_format_max_orig=`select @@innodb_file_format_max`; - --disable_warnings drop table if exists t1; --enable_warnings @@ -33,10 +31,3 @@ SHOW CREATE TABLE t1; INSERT INTO t1 VALUES(null); SELECT * FROM t1; DROP TABLE t1; - -# -# restore environment to the state it was before this test execution -# - --- disable_query_log -eval SET GLOBAL innodb_file_format_max=$innodb_file_format_max_orig; diff --git a/mysql-test/suite/innodb/t/innodb-autoinc.test b/mysql-test/suite/innodb/t/innodb-autoinc.test index 4ca761b45ce..87ca1425630 100644 --- a/mysql-test/suite/innodb/t/innodb-autoinc.test +++ b/mysql-test/suite/innodb/t/innodb-autoinc.test @@ -1,8 +1,6 @@ # embedded server ignores 'delayed', so skip this -- source include/not_embedded.inc -let $innodb_file_format_max_orig=`select @@innodb_file_format_max`; - --disable_warnings drop table if exists t1; --enable_warnings @@ -638,9 +636,3 @@ INSERT INTO t1 VALUES (18446744073709551615); -- source include/restart_mysqld.inc SHOW CREATE TABLE t1; DROP TABLE t1; -# -# restore environment to the state it was before this test execution -# - --- disable_query_log -eval SET GLOBAL innodb_file_format_max=$innodb_file_format_max_orig; diff --git a/mysql-test/suite/innodb/t/innodb-create-options.test b/mysql-test/suite/innodb/t/innodb-create-options.test index 367a2f87dec..83155897349 100644 --- a/mysql-test/suite/innodb/t/innodb-create-options.test +++ b/mysql-test/suite/innodb/t/innodb-create-options.test @@ -60,7 +60,6 @@ SET storage_engine=InnoDB; --disable_query_log # These values can change during the test LET $innodb_file_format_orig=`select @@innodb_file_format`; -LET $innodb_file_format_max_orig=`select @@innodb_file_format_max`; LET $innodb_file_per_table_orig=`select @@innodb_file_per_table`; LET $innodb_strict_mode_orig=`select @@session.innodb_strict_mode`; --enable_query_log @@ -567,7 +566,6 @@ DROP TABLE IF EXISTS t1; --disable_query_log EVAL SET GLOBAL innodb_file_format=$innodb_file_format_orig; -EVAL SET GLOBAL innodb_file_format_max=$innodb_file_format_max_orig; EVAL SET GLOBAL innodb_file_per_table=$innodb_file_per_table_orig; EVAL SET SESSION innodb_strict_mode=$innodb_strict_mode_orig; --enable_query_log diff --git a/mysql-test/suite/innodb/t/innodb-index.test b/mysql-test/suite/innodb/t/innodb-index.test index 86189f1426d..2402c74fe53 100644 --- a/mysql-test/suite/innodb/t/innodb-index.test +++ b/mysql-test/suite/innodb/t/innodb-index.test @@ -1,7 +1,126 @@ let $MYSQLD_DATADIR= `select @@datadir`; -let $innodb_file_format_max_orig=`select @@innodb_file_format_max`; +let $per_table=`select @@innodb_file_per_table`; +let $format=`select @@innodb_file_format`; +set global innodb_file_per_table=on; +set global innodb_file_format='Barracuda'; + +# Bug #12429576 - Test an assertion failure on purge. +CREATE TABLE t1_purge ( +A INT, +B BLOB, C BLOB, D BLOB, E BLOB, +F BLOB, G BLOB, H BLOB, +PRIMARY KEY (B(767), C(767), D(767), E(767), A), +INDEX (A) +) ENGINE=InnoDB ROW_FORMAT=DYNAMIC; + +INSERT INTO t1_purge VALUES (1, +REPEAT('b', 766), REPEAT('c', 766), REPEAT('d', 766), REPEAT('e', 766), +REPEAT('f', 766), REPEAT('g', 766), REPEAT('h', 766)); + +CREATE TABLE t2_purge ( +A INT PRIMARY KEY, +B BLOB, C BLOB, D BLOB, E BLOB, +F BLOB, G BLOB, H BLOB, I BLOB, +J BLOB, K BLOB, L BLOB, +INDEX (B(767))) ENGINE=InnoDB ROW_FORMAT=DYNAMIC; + +INSERT INTO t2_purge VALUES (1, +REPEAT('b', 766), REPEAT('c', 766), REPEAT('d', 766), REPEAT('e', 766), +REPEAT('f', 766), REPEAT('g', 766), REPEAT('h', 766), REPEAT('i', 766), +REPEAT('j', 766), REPEAT('k', 766), REPEAT('l', 766)); + +CREATE TABLE t3_purge ( +A INT, +B VARCHAR(800), C VARCHAR(800), D VARCHAR(800), E VARCHAR(800), +F VARCHAR(800), G VARCHAR(800), H VARCHAR(800), +PRIMARY KEY (B(767), C(767), D(767), E(767), A), +INDEX (A) +) ENGINE=InnoDB ROW_FORMAT=DYNAMIC; + +INSERT INTO t3_purge SELECT * FROM t1_purge; + +CREATE TABLE t4_purge ( +A INT PRIMARY KEY, +B VARCHAR(800), C VARCHAR(800), D VARCHAR(800), E VARCHAR(800), +F VARCHAR(800), G VARCHAR(800), H VARCHAR(800), I VARCHAR(800), +J VARCHAR(800), K VARCHAR(800), L VARCHAR(800), +INDEX (B(767))) ENGINE=InnoDB ROW_FORMAT=DYNAMIC; + +INSERT INTO t4_purge SELECT * FROM t2_purge; + +# This would trigger the failure (Bug #12429576) +# if purge gets a chance to run before DROP TABLE t1_purge, .... +DELETE FROM t1_purge; +DELETE FROM t2_purge; +DELETE FROM t3_purge; +DELETE FROM t4_purge; +# Instead of doing a --sleep 10, wait until the rest of the tests in +# this file complete before dropping the tables. By then, the purge thread +# will have delt with the updates above. + +# Bug#12637786 - Bad assert by purge thread for records with external data +# used in secondary indexes. +SET @r=REPEAT('a',500); +CREATE TABLE t12637786(a INT, + v1 VARCHAR(500), v2 VARCHAR(500), v3 VARCHAR(500), + v4 VARCHAR(500), v5 VARCHAR(500), v6 VARCHAR(500), + v7 VARCHAR(500), v8 VARCHAR(500), v9 VARCHAR(500), + v10 VARCHAR(500), v11 VARCHAR(500), v12 VARCHAR(500), + v13 VARCHAR(500), v14 VARCHAR(500), v15 VARCHAR(500), + v16 VARCHAR(500), v17 VARCHAR(500), v18 VARCHAR(500) +) ENGINE=InnoDB ROW_FORMAT=DYNAMIC; +CREATE INDEX idx1 ON t12637786(a,v1); +INSERT INTO t12637786 VALUES(9,@r,@r,@r,@r,@r,@r,@r,@r,@r,@r,@r,@r,@r,@r,@r,@r,@r,@r); +UPDATE t12637786 SET a=1000; +DELETE FROM t12637786; +# We need to activate the purge thread at this point to make sure it does not +# assert and is able to clean up the old versions of secondary index entries. +# But instead of doing a --sleep 10, wait until the rest of the tests in +# this file complete before dropping the table. By then, the purge thread +# will have delt with the updates above. + +# Bug#12963823 - Test that the purge thread does not crash when +# the number of indexes has changed since the UNDO record was logged. +create table t12963823(a blob,b blob,c blob,d blob,e blob,f blob,g blob,h blob, + i blob,j blob,k blob,l blob,m blob,n blob,o blob,p blob) + engine=innodb row_format=dynamic; +SET @r = repeat('a', 767); +insert into t12963823 values (@r,@r,@r,@r, @r,@r,@r,@r, @r,@r,@r,@r, @r,@r,@r,@r); +create index ndx_a on t12963823 (a(500)); +create index ndx_b on t12963823 (b(500)); +create index ndx_c on t12963823 (c(500)); +create index ndx_d on t12963823 (d(500)); +create index ndx_e on t12963823 (e(500)); +create index ndx_f on t12963823 (f(500)); +create index ndx_k on t12963823 (k(500)); +create index ndx_l on t12963823 (l(500)); + +SET @r = repeat('b', 500); +update t12963823 set a=@r,b=@r,c=@r,d=@r; +update t12963823 set e=@r,f=@r,g=@r,h=@r; +update t12963823 set i=@r,j=@r,k=@r,l=@r; +update t12963823 set m=@r,n=@r,o=@r,p=@r; +alter table t12963823 drop index ndx_a; +alter table t12963823 drop index ndx_b; +create index ndx_g on t12963823 (g(500)); +create index ndx_h on t12963823 (h(500)); +create index ndx_i on t12963823 (i(500)); +create index ndx_j on t12963823 (j(500)); +create index ndx_m on t12963823 (m(500)); +create index ndx_n on t12963823 (n(500)); +create index ndx_o on t12963823 (o(500)); +create index ndx_p on t12963823 (p(500)); +show create table t12963823; +# We need to activate the purge thread at this point to see if it crashes +# but instead of doing a --sleep 10, wait until the rest of the tests in +# this file complete before dropping the table. By then, the purge thread +# will have delt with the updates above. + + +eval set global innodb_file_per_table=$per_table; +eval set global innodb_file_format=$format; create table t1(a int not null, b int, c char(10) not null, d varchar(20)) engine = innodb; insert into t1 values (5,5,'oo','oo'),(4,4,'tr','tr'),(3,4,'ad','ad'),(2,3,'ak','ak'); @@ -356,8 +475,6 @@ explain select * from t1 where b like 'adfd%'; # end disabled45225_1 drop table t1; -let $per_table=`select @@innodb_file_per_table`; -let $format=`select @@innodb_file_format`; set global innodb_file_per_table=on; set global innodb_file_format='Barracuda'; # Test creating a table that could lead to undo log overflow. @@ -400,6 +517,20 @@ alter table t1 row_format=compact; create index t1u on t1 (u(767)); drop table t1; + +# Bug#12547647 UPDATE LOGGING COULD EXCEED LOG PAGE SIZE +CREATE TABLE bug12547647( +a INT NOT NULL, b BLOB NOT NULL, c TEXT, +PRIMARY KEY (b(10), a), INDEX (c(767)), INDEX(b(767)) +) ENGINE=InnoDB ROW_FORMAT=DYNAMIC; + +INSERT INTO bug12547647 VALUES (5,repeat('khdfo5AlOq',1900),repeat('g',7751)); +COMMIT; +# The following used to cause infinite undo log allocation. +--error ER_UNDO_RECORD_TOO_BIG +UPDATE bug12547647 SET c = REPEAT('b',16928); +DROP TABLE bug12547647; + eval set global innodb_file_per_table=$per_table; eval set global innodb_file_format=$format; eval set global innodb_file_format_max=$format; @@ -543,10 +674,8 @@ DROP TABLE t1; # #DROP TABLE t1; # end disabled45225_2 - -# -# restore environment to the state it was before this test execution -# - --- disable_query_log -eval SET GLOBAL innodb_file_format_max=$innodb_file_format_max_orig; +#this delay is needed because 45225_2 is disabled, to allow the purge to run +SELECT SLEEP(10); +DROP TABLE t1_purge, t2_purge, t3_purge, t4_purge; +DROP TABLE t12637786; +DROP TABLE t12963823; diff --git a/mysql-test/suite/innodb/t/innodb-zip.test b/mysql-test/suite/innodb/t/innodb-zip.test index e28b0862166..6561feffdd4 100644 --- a/mysql-test/suite/innodb/t/innodb-zip.test +++ b/mysql-test/suite/innodb/t/innodb-zip.test @@ -1,7 +1,6 @@ let $per_table=`select @@innodb_file_per_table`; let $format=`select @@innodb_file_format`; -let $innodb_file_format_max_orig=`select @@innodb_file_format_max`; let $innodb_strict_mode_orig=`select @@session.innodb_strict_mode`; set session innodb_strict_mode=0; @@ -38,19 +37,19 @@ create table t13(a int primary key) engine=innodb row_format=compressed; create table t14(a int primary key) engine=innodb key_block_size=9; -SELECT table_schema, table_name, row_format +SELECT table_schema, table_name, row_format, data_length, index_length FROM information_schema.tables WHERE engine='innodb'; drop table t0,t00,t2,t3,t4,t5,t6,t7,t8,t9,t10,t11,t12,t13,t14; alter table t1 key_block_size=0; alter table t1 row_format=dynamic; -SELECT table_schema, table_name, row_format +SELECT table_schema, table_name, row_format, data_length, index_length FROM information_schema.tables WHERE engine='innodb'; alter table t1 row_format=compact; -SELECT table_schema, table_name, row_format +SELECT table_schema, table_name, row_format, data_length, index_length FROM information_schema.tables WHERE engine='innodb'; alter table t1 row_format=redundant; -SELECT table_schema, table_name, row_format +SELECT table_schema, table_name, row_format, data_length, index_length FROM information_schema.tables WHERE engine='innodb'; drop table t1; @@ -83,7 +82,7 @@ connection default; disconnect a; disconnect b; -SELECT table_schema, table_name, row_format +SELECT table_schema, table_name, row_format, data_length, index_length FROM information_schema.tables WHERE engine='innodb'; drop table t1,t2; @@ -194,7 +193,7 @@ create table t9 (id int primary key) engine = innodb row_format = dynamic; create table t10(id int primary key) engine = innodb row_format = compact; create table t11(id int primary key) engine = innodb row_format = redundant; -SELECT table_schema, table_name, row_format +SELECT table_schema, table_name, row_format, data_length, index_length FROM information_schema.tables WHERE engine='innodb'; drop table t1, t3, t4, t5, t6, t7, t8, t9, t10, t11; @@ -220,7 +219,7 @@ show warnings; create table t5 (id int primary key) engine = innodb key_block_size = 8 row_format = default; -SELECT table_schema, table_name, row_format +SELECT table_schema, table_name, row_format, data_length, index_length FROM information_schema.tables WHERE engine='innodb'; drop table t1, t5; @@ -240,7 +239,7 @@ create table t2 (id int primary key) engine = innodb key_block_size = 9 row_format = dynamic; show warnings; -SELECT table_schema, table_name, row_format +SELECT table_schema, table_name, row_format, data_length, index_length FROM information_schema.tables WHERE engine='innodb'; #test valid values with innodb_file_per_table unset @@ -270,7 +269,7 @@ show warnings; create table t8 (id int primary key) engine = innodb row_format = compact; create table t9 (id int primary key) engine = innodb row_format = redundant; -SELECT table_schema, table_name, row_format +SELECT table_schema, table_name, row_format, data_length, index_length FROM information_schema.tables WHERE engine='innodb'; drop table t8, t9; @@ -302,7 +301,7 @@ show warnings; create table t8 (id int primary key) engine = innodb row_format = compact; create table t9 (id int primary key) engine = innodb row_format = redundant; -SELECT table_schema, table_name, row_format +SELECT table_schema, table_name, row_format, data_length, index_length FROM information_schema.tables WHERE engine='innodb'; drop table t8, t9; @@ -339,5 +338,4 @@ drop table normal_table, zip_table; -- disable_query_log eval set global innodb_file_format=$format; eval set global innodb_file_per_table=$per_table; -eval set global innodb_file_format_max=$innodb_file_format_max_orig; eval set session innodb_strict_mode=$innodb_strict_mode_orig; diff --git a/mysql-test/suite/innodb/t/innodb.test b/mysql-test/suite/innodb/t/innodb.test index b8b507112b7..44cd2bd9573 100644 --- a/mysql-test/suite/innodb/t/innodb.test +++ b/mysql-test/suite/innodb/t/innodb.test @@ -532,6 +532,7 @@ DROP TABLE t1; create table t1 (a int primary key,b int, c int, d int, e int, f int, g int, h int, i int, j int, k int, l int, m int, n int, o int, p int, q int, r int, s int, t int, u int, v int, w int, x int, y int, z int, a1 int, a2 int, a3 int, a4 int, a5 int, a6 int, a7 int, a8 int, a9 int, b1 int, b2 int, b3 int, b4 int, b5 int, b6 int) engine = innodb; insert into t1 values (1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1); --replace_column 9 # +--replace_result "Using where" "Using index condition" explain select * from t1 where a > 0 and a < 50; drop table t1; diff --git a/mysql-test/suite/innodb/t/innodb_bug36172.test b/mysql-test/suite/innodb/t/innodb_bug36172.test index 9269d54032d..30be4873df0 100644 --- a/mysql-test/suite/innodb/t/innodb_bug36172.test +++ b/mysql-test/suite/innodb/t/innodb_bug36172.test @@ -14,7 +14,6 @@ SET storage_engine=InnoDB; -- disable_result_log let $file_format=`select @@innodb_file_format`; -let $file_format_max=`select @@innodb_file_format_max`; let $file_per_table=`select @@innodb_file_per_table`; SET GLOBAL innodb_file_format='Barracuda'; SET GLOBAL innodb_file_per_table=on; @@ -27,5 +26,4 @@ INSERT IGNORE INTO `table0` SET `col19` = '19940127002709', `col20` = 2383927.90 CHECK TABLE table0 EXTENDED; DROP TABLE table0; EVAL SET GLOBAL innodb_file_format=$file_format; -EVAL SET GLOBAL innodb_file_format_max=$file_format_max; EVAL SET GLOBAL innodb_file_per_table=$file_per_table; diff --git a/mysql-test/suite/innodb/t/innodb_bug47167-master.opt b/mysql-test/suite/innodb/t/innodb_bug47167-master.opt new file mode 100644 index 00000000000..cef79bc8585 --- /dev/null +++ b/mysql-test/suite/innodb/t/innodb_bug47167-master.opt @@ -0,0 +1 @@ +--force-restart diff --git a/mysql-test/suite/innodb/t/innodb_bug52745.test b/mysql-test/suite/innodb/t/innodb_bug52745.test index 25adf5c064a..252de1e2794 100644 --- a/mysql-test/suite/innodb/t/innodb_bug52745.test +++ b/mysql-test/suite/innodb/t/innodb_bug52745.test @@ -1,6 +1,5 @@ let $file_format=`select @@innodb_file_format`; -let $file_format_max=`select @@innodb_file_format_max`; let $file_per_table=`select @@innodb_file_per_table`; SET GLOBAL innodb_file_format='Barracuda'; SET GLOBAL innodb_file_per_table=on; @@ -104,5 +103,4 @@ SHOW WARNINGS; DROP TABLE bug52745; EVAL SET GLOBAL innodb_file_format=$file_format; -EVAL SET GLOBAL innodb_file_format_max=$file_format_max; EVAL SET GLOBAL innodb_file_per_table=$file_per_table; diff --git a/mysql-test/suite/innodb/t/innodb_bug53591.test b/mysql-test/suite/innodb/t/innodb_bug53591.test index cac39c10d30..3261779a825 100644 --- a/mysql-test/suite/innodb/t/innodb_bug53591.test +++ b/mysql-test/suite/innodb/t/innodb_bug53591.test @@ -1,6 +1,5 @@ let $file_format=`select @@innodb_file_format`; -let $file_format_max=`select @@innodb_file_format_max`; let $file_per_table=`select @@innodb_file_per_table`; SET GLOBAL innodb_file_format='Barracuda'; @@ -17,5 +16,4 @@ SHOW WARNINGS; DROP TABLE bug53591; EVAL SET GLOBAL innodb_file_format=$file_format; -EVAL SET GLOBAL innodb_file_format_max=$file_format_max; EVAL SET GLOBAL innodb_file_per_table=$file_per_table; diff --git a/mysql-test/suite/innodb/t/innodb_bug56680.test b/mysql-test/suite/innodb/t/innodb_bug56680.test index 19ab5cfff21..1fcf55add60 100644 --- a/mysql-test/suite/innodb/t/innodb_bug56680.test +++ b/mysql-test/suite/innodb/t/innodb_bug56680.test @@ -5,7 +5,6 @@ SET @tx_isolation_orig = @@tx_isolation; SET @innodb_file_per_table_orig = @@innodb_file_per_table; SET @innodb_file_format_orig = @@innodb_file_format; -SET @innodb_file_format_max_orig = @@innodb_file_format_max; # The flag innodb_change_buffering_debug is only available in debug builds. # It instructs InnoDB to try to evict pages from the buffer pool when # change buffering is possible, so that the change buffer will be used @@ -135,6 +134,5 @@ DROP TABLE bug56680; SET GLOBAL tx_isolation = @tx_isolation_orig; SET GLOBAL innodb_file_per_table = @innodb_file_per_table_orig; SET GLOBAL innodb_file_format = @innodb_file_format_orig; -SET GLOBAL innodb_file_format_max = @innodb_file_format_max_orig; -- error 0, ER_UNKNOWN_SYSTEM_VARIABLE SET GLOBAL innodb_change_buffering_debug = @innodb_change_buffering_debug_orig; diff --git a/mysql-test/suite/innodb/t/innodb_bug59733.test b/mysql-test/suite/innodb/t/innodb_bug59733.test new file mode 100644 index 00000000000..0b1bff51932 --- /dev/null +++ b/mysql-test/suite/innodb/t/innodb_bug59733.test @@ -0,0 +1,53 @@ +# +# Bug #59733 Possible deadlock when buffered changes are to be discarded +# in buf_page_create +# +-- source include/have_innodb.inc + +-- disable_query_log +# The flag innodb_change_buffering_debug is only available in debug builds. +# It instructs InnoDB to try to evict pages from the buffer pool when +# change buffering is possible, so that the change buffer will be used +# whenever possible. +-- error 0,ER_UNKNOWN_SYSTEM_VARIABLE +SET @innodb_change_buffering_debug_orig = @@innodb_change_buffering_debug; +-- error 0,ER_UNKNOWN_SYSTEM_VARIABLE +SET GLOBAL innodb_change_buffering_debug = 1; +-- enable_query_log + +CREATE TABLE bug59733(a INT AUTO_INCREMENT PRIMARY KEY,b CHAR(1))ENGINE=InnoDB; + +# Create enough rows for the table, so that the insert buffer will be +# used. There must be multiple index pages, because changes to the +# root page are never buffered. + +INSERT INTO bug59733 VALUES(0,'x'); +INSERT INTO bug59733 SELECT 0,b FROM bug59733; +INSERT INTO bug59733 SELECT 0,b FROM bug59733; +INSERT INTO bug59733 SELECT 0,b FROM bug59733; +INSERT INTO bug59733 SELECT 0,b FROM bug59733; +INSERT INTO bug59733 SELECT 0,b FROM bug59733; +INSERT INTO bug59733 SELECT 0,b FROM bug59733; +INSERT INTO bug59733 SELECT 0,b FROM bug59733; +INSERT INTO bug59733 SELECT 0,b FROM bug59733; +INSERT INTO bug59733 SELECT 0,b FROM bug59733; +INSERT INTO bug59733 SELECT 0,b FROM bug59733; +INSERT INTO bug59733 SELECT 0,b FROM bug59733; + +# Create the secondary index for which changes will be buffered. +CREATE INDEX b ON bug59733 (b); + +# This should be buffered, if innodb_change_buffering_debug = 1 is in effect. +DELETE FROM bug59733 WHERE (a%100)=0; + +# Drop the index in order to get free pages with orphaned buffered changes. +DROP INDEX b ON bug59733; + +# Create the index and attempt to reuse pages for which buffered changes exist. +CREATE INDEX b ON bug59733 (b); + +DROP TABLE bug59733; + +-- disable_query_log +-- error 0, ER_UNKNOWN_SYSTEM_VARIABLE +SET GLOBAL innodb_change_buffering_debug = @innodb_change_buffering_debug_orig; diff --git a/mysql-test/suite/innodb/t/innodb_corrupt_bit.test b/mysql-test/suite/innodb/t/innodb_corrupt_bit.test new file mode 100644 index 00000000000..34991362f98 --- /dev/null +++ b/mysql-test/suite/innodb/t/innodb_corrupt_bit.test @@ -0,0 +1,120 @@ +# +# Test for persistent corrupt bit for corrupted index and table +# +-- source include/have_innodb.inc + +# This test needs debug server +--source include/have_debug.inc + +-- disable_query_log +# This test setup is extracted from bug56680.test: +# The flag innodb_change_buffering_debug is only available in debug builds. +# It instructs InnoDB to try to evict pages from the buffer pool when +# change buffering is possible, so that the change buffer will be used +# whenever possible. +-- error 0,ER_UNKNOWN_SYSTEM_VARIABLE +SET @innodb_change_buffering_debug_orig = @@innodb_change_buffering_debug; +-- error 0,ER_UNKNOWN_SYSTEM_VARIABLE +SET GLOBAL innodb_change_buffering_debug = 1; + +# Turn off Unique Check to create corrupted index with dup key +SET UNIQUE_CHECKS=0; + +-- enable_query_log + +set names utf8; + +CREATE TABLE corrupt_bit_test_Ä( + a INT AUTO_INCREMENT PRIMARY KEY, + b CHAR(100), + c INT, + z INT, + INDEX(b)) +ENGINE=InnoDB; + +INSERT INTO corrupt_bit_test_Ä VALUES(0,'x',1, 1); + +# This is the first unique index we intend to corrupt +CREATE UNIQUE INDEX idxÄ ON corrupt_bit_test_Ä(c, b); + +# This is the second unique index we intend to corrupt +CREATE UNIQUE INDEX idxÄ“ ON corrupt_bit_test_Ä(z, b); + +SELECT * FROM corrupt_bit_test_Ä; + +select @@unique_checks; +select @@innodb_change_buffering_debug; + +# Create enough rows for the table, so that the insert buffer will be +# used for modifying the secondary index page. There must be multiple +# index pages, because changes to the root page are never buffered. + +INSERT INTO corrupt_bit_test_Ä SELECT 0,b,c+1,z+1 FROM corrupt_bit_test_Ä; +INSERT INTO corrupt_bit_test_Ä SELECT 0,b,c+10,z+10 FROM corrupt_bit_test_Ä; +INSERT INTO corrupt_bit_test_Ä SELECT 0,b,c+20,z+20 FROM corrupt_bit_test_Ä; +INSERT INTO corrupt_bit_test_Ä SELECT 0,b,c+50,z+50 FROM corrupt_bit_test_Ä; +INSERT INTO corrupt_bit_test_Ä SELECT 0,b,c+100,z+100 FROM corrupt_bit_test_Ä; +INSERT INTO corrupt_bit_test_Ä SELECT 0,b,c+200,z+200 FROM corrupt_bit_test_Ä; +INSERT INTO corrupt_bit_test_Ä SELECT 0,b,c+400,z+400 FROM corrupt_bit_test_Ä; +INSERT INTO corrupt_bit_test_Ä SELECT 0,b,c+800,z+800 FROM corrupt_bit_test_Ä; +INSERT INTO corrupt_bit_test_Ä SELECT 0,b,c+1600,z+1600 FROM corrupt_bit_test_Ä; +INSERT INTO corrupt_bit_test_Ä SELECT 0,b,c+4000,z+4000 FROM corrupt_bit_test_Ä; + +select count(*) from corrupt_bit_test_Ä; + +CREATE INDEX idx3 ON corrupt_bit_test_Ä(b, c); + +# Create a dup key error on index "idxÄ“" and "idxÄ" by inserting a dup value +INSERT INTO corrupt_bit_test_Ä VALUES(13000,'x',1,1); + +# creating an index should succeed even if other secondary indexes are corrupted +CREATE INDEX idx4 ON corrupt_bit_test_Ä(b, z); + +# Check table will find the unique indexes corrupted +# with dup key +check table corrupt_bit_test_Ä; + +# This selection intend to use the corrupted index. Expect to fail +-- error ER_NOT_KEYFILE +select c from corrupt_bit_test_Ä; + +-- error ER_NOT_KEYFILE +select z from corrupt_bit_test_Ä; + +show warnings; + +# Since corrupted index is a secondary index, we only disable such +# index and allow other DML to proceed +insert into corrupt_bit_test_Ä values (10001, "a", 20001, 20001); + +# This does not use the corrupted index, expect to succeed +select * from corrupt_bit_test_Ä use index(primary) where a = 10001; + +# Some more DMLs +begin; +insert into corrupt_bit_test_Ä values (10002, "a", 20002, 20002); +delete from corrupt_bit_test_Ä where a = 10001; +insert into corrupt_bit_test_Ä values (10001, "a", 20001, 20001); +rollback; + +# Drop one corrupted index before reboot +drop index idxÄ on corrupt_bit_test_Ä; + +check table corrupt_bit_test_Ä; + +set names utf8; + +-- error ER_NOT_KEYFILE +select z from corrupt_bit_test_Ä; + +# Drop the corrupted index +drop index idxÄ“ on corrupt_bit_test_Ä; + +# Now select back to normal +select z from corrupt_bit_test_Ä limit 10; + +# Drop table +drop table corrupt_bit_test_Ä; + +-- error 0, ER_UNKNOWN_SYSTEM_VARIABLE +SET GLOBAL innodb_change_buffering_debug = 0; diff --git a/mysql-test/suite/innodb/t/innodb_file_format-master.opt b/mysql-test/suite/innodb/t/innodb_file_format-master.opt new file mode 100644 index 00000000000..cef79bc8585 --- /dev/null +++ b/mysql-test/suite/innodb/t/innodb_file_format-master.opt @@ -0,0 +1 @@ +--force-restart diff --git a/mysql-test/suite/innodb/t/innodb_file_format.test b/mysql-test/suite/innodb/t/innodb_file_format.test index 5c80ef89ba4..115d8323050 100644 --- a/mysql-test/suite/innodb/t/innodb_file_format.test +++ b/mysql-test/suite/innodb/t/innodb_file_format.test @@ -1,7 +1,6 @@ -- source include/not_embedded.inc let $innodb_file_format_orig=`select @@innodb_file_format`; -let $innodb_file_format_max_orig=`select @@innodb_file_format_max`; select @@innodb_file_format; select @@innodb_file_format_check; @@ -38,4 +37,3 @@ set global innodb_file_format_max=antelope; set global innodb_file_format_check=off; eval SET GLOBAL innodb_file_format=$innodb_file_format_orig; -eval SET GLOBAL innodb_file_format_max=$innodb_file_format_max_orig; diff --git a/mysql-test/suite/innodb/t/innodb_index_large_prefix.test b/mysql-test/suite/innodb/t/innodb_index_large_prefix.test index b43ff033903..2ae0237488c 100644 --- a/mysql-test/suite/innodb/t/innodb_index_large_prefix.test +++ b/mysql-test/suite/innodb/t/innodb_index_large_prefix.test @@ -2,7 +2,6 @@ let $innodb_file_format_orig=`select @@innodb_file_format`; let $innodb_file_per_table_orig=`select @@innodb_file_per_table`; -let $innodb_file_format_max_orig=`select @@innodb_file_format_max`; let $innodb_large_prefix_orig=`select @@innodb_large_prefix`; set global innodb_file_format="Barracuda"; @@ -265,5 +264,4 @@ drop table worklog5743; eval SET GLOBAL innodb_file_format=$innodb_file_format_orig; eval SET GLOBAL innodb_file_per_table=$innodb_file_per_table_orig; -eval SET GLOBAL innodb_file_format_max=$innodb_file_format_max_orig; eval SET GLOBAL innodb_large_prefix=$innodb_large_prefix_orig; diff --git a/mysql-test/suite/innodb/t/innodb_prefix_index_liftedlimit.test b/mysql-test/suite/innodb/t/innodb_prefix_index_liftedlimit.test index 2ec048a0614..c702b59e81f 100644 --- a/mysql-test/suite/innodb/t/innodb_prefix_index_liftedlimit.test +++ b/mysql-test/suite/innodb/t/innodb_prefix_index_liftedlimit.test @@ -17,7 +17,6 @@ # Save innodb variables let $innodb_file_format_orig=`select @@innodb_file_format`; let $innodb_file_per_table_orig=`select @@innodb_file_per_table`; -let $innodb_file_format_max_orig=`select @@innodb_file_format_max`; let $innodb_large_prefix_orig=`select @@innodb_large_prefix`; # Set Innodb file format as feature works for Barracuda file format @@ -1334,5 +1333,4 @@ DROP TABLE worklog5743; eval SET GLOBAL innodb_file_format=$innodb_file_format_orig; eval SET GLOBAL innodb_file_per_table=$innodb_file_per_table_orig; -eval SET GLOBAL innodb_file_format_max=$innodb_file_format_max_orig; eval SET GLOBAL innodb_large_prefix=$innodb_large_prefix_orig; diff --git a/mysql-test/suite/innodb/t/innodb_prefix_index_restart_server.test b/mysql-test/suite/innodb/t/innodb_prefix_index_restart_server.test index eb9f3e454a2..1f54a9b253d 100644 --- a/mysql-test/suite/innodb/t/innodb_prefix_index_restart_server.test +++ b/mysql-test/suite/innodb/t/innodb_prefix_index_restart_server.test @@ -17,7 +17,6 @@ # Save innodb variables let $innodb_file_format_orig=`select @@innodb_file_format`; let $innodb_file_per_table_orig=`select @@innodb_file_per_table`; -let $innodb_file_format_max_orig=`select @@innodb_file_format_max`; let $innodb_large_prefix_orig=`select @@innodb_large_prefix`; # Set Innodb file format as feature works for Barracuda file format @@ -121,6 +120,5 @@ DROP TABLE worklog5743; eval SET GLOBAL innodb_file_format=$innodb_file_format_orig; eval SET GLOBAL innodb_file_per_table=$innodb_file_per_table_orig; -eval SET GLOBAL innodb_file_format_max=$innodb_file_format_max_orig; eval SET GLOBAL innodb_large_prefix=$innodb_large_prefix_orig; diff --git a/mysql-test/suite/maria/r/maria.result b/mysql-test/suite/maria/r/maria.result index 7baf561eea3..320c081382f 100644 --- a/mysql-test/suite/maria/r/maria.result +++ b/mysql-test/suite/maria/r/maria.result @@ -361,7 +361,8 @@ ALTER TABLE t1 ADD INDEX t1 (a, b, c, d, e); ERROR 42000: Specified key was too long; max key length is 1208 bytes DROP TABLE t1; CREATE TABLE t1 (a int not null, b int, c int, key(b), key(c), key(a,b), key(c,a)); -INSERT into t1 values (0, null, 0), (0, null, 1), (0, null, 2), (0, null,3), (1,1,4); +INSERT into t1 values (0,null,0), (0,null,1), (0,null,2), (0,null,3), (1,1,4); +INSERT into t1 values (2,4,5), (7,8,4), (8,3,1), (9,7,2), (5,5,9); create table t2 (a int not null, b int, c int, key(b), key(c), key(a)); INSERT into t2 values (1,1,1), (2,2,2); optimize table t1; @@ -372,24 +373,24 @@ Table Op Msg_type Msg_text test.t1 check status OK show index from t1; Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment -t1 1 b 1 b A 5 NULL NULL YES BTREE -t1 1 c 1 c A 5 NULL NULL YES BTREE -t1 1 a 1 a A 1 NULL NULL BTREE -t1 1 a 2 b A 5 NULL NULL YES BTREE -t1 1 c_2 1 c A 5 NULL NULL YES BTREE -t1 1 c_2 2 a A 5 NULL NULL BTREE +t1 1 b 1 b A 10 NULL NULL YES BTREE +t1 1 c 1 c A 10 NULL NULL YES BTREE +t1 1 a 1 a A 10 NULL NULL BTREE +t1 1 a 2 b A 10 NULL NULL YES BTREE +t1 1 c_2 1 c A 10 NULL NULL YES BTREE +t1 1 c_2 2 a A 10 NULL NULL BTREE explain select * from t1,t2 where t1.a=t2.a; id select_type table type possible_keys key key_len ref rows Extra 1 SIMPLE t2 ALL a NULL NULL NULL 2 -1 SIMPLE t1 ref a a 4 test.t2.a 3 +1 SIMPLE t1 ref a a 4 test.t2.a 1 explain select * from t1,t2 force index(a) where t1.a=t2.a; id select_type table type possible_keys key key_len ref rows Extra 1 SIMPLE t2 ALL a NULL NULL NULL 2 -1 SIMPLE t1 ref a a 4 test.t2.a 3 +1 SIMPLE t1 ref a a 4 test.t2.a 1 explain select * from t1 force index(a),t2 force index(a) where t1.a=t2.a; id select_type table type possible_keys key key_len ref rows Extra 1 SIMPLE t2 ALL a NULL NULL NULL 2 -1 SIMPLE t1 ref a a 4 test.t2.a 3 +1 SIMPLE t1 ref a a 4 test.t2.a 1 explain select * from t1,t2 where t1.b=t2.b; id select_type table type possible_keys key key_len ref rows Extra 1 SIMPLE t2 ALL b NULL NULL NULL 2 Using where @@ -397,19 +398,19 @@ id select_type table type possible_keys key key_len ref rows Extra explain select * from t1,t2 force index(c) where t1.a=t2.a; id select_type table type possible_keys key key_len ref rows Extra 1 SIMPLE t2 ALL NULL NULL NULL NULL 2 -1 SIMPLE t1 ref a a 4 test.t2.a 3 +1 SIMPLE t1 ref a a 4 test.t2.a 1 explain select * from t1 where a=0 or a=2; id select_type table type possible_keys key key_len ref rows Extra -1 SIMPLE t1 range a a 4 NULL 4 Using where +1 SIMPLE t1 range a a 4 NULL 5 Using where explain select * from t1 force index (a) where a=0 or a=2; id select_type table type possible_keys key key_len ref rows Extra -1 SIMPLE t1 range a a 4 NULL 4 Using where +1 SIMPLE t1 range a a 4 NULL 5 Using where explain select * from t1 where c=1; id select_type table type possible_keys key key_len ref rows Extra -1 SIMPLE t1 ref c,c_2 c 5 const 1 +1 SIMPLE t1 ref c,c_2 c 5 const 2 explain select * from t1 use index() where c=1; id select_type table type possible_keys key key_len ref rows Extra -1 SIMPLE t1 ALL NULL NULL NULL NULL 5 Using where +1 SIMPLE t1 ALL NULL NULL NULL NULL 10 Using where drop table t1,t2; create table t1 (a int not null auto_increment primary key, b varchar(255)); insert into t1 (b) values (repeat('a',100)),(repeat('b',100)),(repeat('c',100)); diff --git a/mysql-test/suite/maria/r/maria3.result b/mysql-test/suite/maria/r/maria3.result index fce5fa61034..21de234dad6 100644 --- a/mysql-test/suite/maria/r/maria3.result +++ b/mysql-test/suite/maria/r/maria3.result @@ -304,6 +304,7 @@ select lower(variable_name) as Variable_name, Variable_value as Value from infor Variable_name Value aria_block_size 8192 aria_checkpoint_interval 30 +aria_checkpoint_log_activity 1048576 aria_force_start_after_recovery_failures 0 aria_group_commit none aria_group_commit_interval 0 diff --git a/mysql-test/suite/maria/t/maria.test b/mysql-test/suite/maria/t/maria.test index 9d04e564e56..b371394b2b3 100644 --- a/mysql-test/suite/maria/t/maria.test +++ b/mysql-test/suite/maria/t/maria.test @@ -386,7 +386,8 @@ DROP TABLE t1; # CREATE TABLE t1 (a int not null, b int, c int, key(b), key(c), key(a,b), key(c,a)); -INSERT into t1 values (0, null, 0), (0, null, 1), (0, null, 2), (0, null,3), (1,1,4); +INSERT into t1 values (0,null,0), (0,null,1), (0,null,2), (0,null,3), (1,1,4); +INSERT into t1 values (2,4,5), (7,8,4), (8,3,1), (9,7,2), (5,5,9); create table t2 (a int not null, b int, c int, key(b), key(c), key(a)); INSERT into t2 values (1,1,1), (2,2,2); optimize table t1; diff --git a/mysql-test/suite/optimizer_unfixed_bugs/r/bug45219.result b/mysql-test/suite/optimizer_unfixed_bugs/r/bug45219.result index e3cee8cd055..1335120b6b0 100644 --- a/mysql-test/suite/optimizer_unfixed_bugs/r/bug45219.result +++ b/mysql-test/suite/optimizer_unfixed_bugs/r/bug45219.result @@ -56,27 +56,6 @@ WHERE ( `int_nokey` , `pk` ) IN ( SELECT INNR .`pk` , INNR .`pk` FROM CC LEFT JOIN BB INNR ON INNR .`varchar_key` ) AND `pk` = 9 ; datetime_key -Warnings: -Warning 1292 Truncated incorrect DOUBLE value: 'i' -Warning 1292 Truncated incorrect DOUBLE value: 'i' -Warning 1292 Truncated incorrect DOUBLE value: 'i' -Warning 1292 Truncated incorrect DOUBLE value: 'i' -Warning 1292 Truncated incorrect DOUBLE value: 'i' -Warning 1292 Truncated incorrect DOUBLE value: 'i' -Warning 1292 Truncated incorrect DOUBLE value: 'i' -Warning 1292 Truncated incorrect DOUBLE value: 'i' -Warning 1292 Truncated incorrect DOUBLE value: 'i' -Warning 1292 Truncated incorrect DOUBLE value: 'i' -Warning 1292 Truncated incorrect DOUBLE value: 'i' -Warning 1292 Truncated incorrect DOUBLE value: 'i' -Warning 1292 Truncated incorrect DOUBLE value: 'i' -Warning 1292 Truncated incorrect DOUBLE value: 'i' -Warning 1292 Truncated incorrect DOUBLE value: 'i' -Warning 1292 Truncated incorrect DOUBLE value: 'i' -Warning 1292 Truncated incorrect DOUBLE value: 'i' -Warning 1292 Truncated incorrect DOUBLE value: 'i' -Warning 1292 Truncated incorrect DOUBLE value: 'i' -Warning 1292 Truncated incorrect DOUBLE value: 'i' DROP TABLE CC, C, BB; DROP TABLE IF EXISTS CC, C, BB; CREATE TABLE `CC` ( diff --git a/mysql-test/suite/optimizer_unfixed_bugs/r/bug45221.result b/mysql-test/suite/optimizer_unfixed_bugs/r/bug45221.result index 060955d84a4..657f1f57b2d 100644 --- a/mysql-test/suite/optimizer_unfixed_bugs/r/bug45221.result +++ b/mysql-test/suite/optimizer_unfixed_bugs/r/bug45221.result @@ -25,10 +25,10 @@ SELECT `int_key` FROM CC WHERE `date_nokey` < `datetime_nokey` XOR OUTR .`date_nokey` ) ; pk +9 2 5 6 -9 SELECT `pk` FROM C WHERE `pk` IN ( @@ -36,11 +36,11 @@ SELECT `int_key` FROM CC WHERE `date_nokey` < `datetime_nokey` XOR '2009-11-25' ) ; pk +9 2 -4 5 6 -9 +4 Warnings: Warning 1292 Truncated incorrect INTEGER value: '2009-11-25' Warning 1292 Truncated incorrect INTEGER value: '2009-11-25' @@ -52,6 +52,12 @@ Warning 1292 Truncated incorrect INTEGER value: '2009-11-25' Warning 1292 Truncated incorrect INTEGER value: '2009-11-25' Warning 1292 Truncated incorrect INTEGER value: '2009-11-25' Warning 1292 Truncated incorrect INTEGER value: '2009-11-25' +Warning 1292 Truncated incorrect INTEGER value: '2009-11-25' +Warning 1292 Truncated incorrect INTEGER value: '2009-11-25' +Warning 1292 Truncated incorrect INTEGER value: '2009-11-25' +Warning 1292 Truncated incorrect INTEGER value: '2009-11-25' +Warning 1292 Truncated incorrect INTEGER value: '2009-11-25' +Warning 1292 Truncated incorrect INTEGER value: '2009-11-25' DROP TABLE CC; DROP TABLE C; CREATE TABLE `CC` ( diff --git a/mysql-test/suite/parts/r/partition_repair_myisam.result b/mysql-test/suite/parts/r/partition_repair_myisam.result index 4b6d4dc6ec0..a9d7ce8aeb4 100644 --- a/mysql-test/suite/parts/r/partition_repair_myisam.result +++ b/mysql-test/suite/parts/r/partition_repair_myisam.result @@ -264,6 +264,7 @@ Table Op Msg_type Msg_text test.t1_will_crash analyze status OK OPTIMIZE TABLE t1_will_crash; Table Op Msg_type Msg_text +test.t1_will_crash optimize info Found row block followed by deleted block test.t1_will_crash optimize warning Number of rows changed from 8 to 7 test.t1_will_crash optimize status OK CHECK TABLE t1_will_crash; diff --git a/mysql-test/suite/pbxt/r/derived.result b/mysql-test/suite/pbxt/r/derived.result index 565a3bd1a58..9294b658595 100644 --- a/mysql-test/suite/pbxt/r/derived.result +++ b/mysql-test/suite/pbxt/r/derived.result @@ -190,13 +190,13 @@ pla_id test explain SELECT STRAIGHT_JOIN d.pla_id, m2.mat_id FROM t1 m2 INNER JOIN (SELECT mp.pla_id, MIN(m1.matintnum) AS matintnum FROM t2 mp INNER JOIN t1 m1 ON mp.mat_id=m1.mat_id GROUP BY mp.pla_id) d ON d.matintnum=m2.matintnum; id select_type table type possible_keys key key_len ref rows Extra 1 PRIMARY m2 ALL NULL NULL NULL NULL 9 -1 PRIMARY <derived2> ALL NULL $hj 7 test.m2.matintnum 9 Using where +1 PRIMARY <derived2> ALL NULL NULL NULL NULL 9 Using where 2 DERIVED mp ALL NULL NULL NULL NULL 9 Using temporary; Using filesort 2 DERIVED m1 eq_ref PRIMARY PRIMARY 3 test.mp.mat_id 1 explain SELECT STRAIGHT_JOIN d.pla_id, m2.test FROM t1 m2 INNER JOIN (SELECT mp.pla_id, MIN(m1.matintnum) AS matintnum FROM t2 mp INNER JOIN t1 m1 ON mp.mat_id=m1.mat_id GROUP BY mp.pla_id) d ON d.matintnum=m2.matintnum; id select_type table type possible_keys key key_len ref rows Extra 1 PRIMARY m2 ALL NULL NULL NULL NULL 9 -1 PRIMARY <derived2> ALL NULL $hj 7 test.m2.matintnum 9 Using where +1 PRIMARY <derived2> ALL NULL NULL NULL NULL 9 Using where 2 DERIVED mp ALL NULL NULL NULL NULL 9 Using temporary; Using filesort 2 DERIVED m1 eq_ref PRIMARY PRIMARY 3 test.mp.mat_id 1 drop table t1,t2; diff --git a/mysql-test/suite/pbxt/r/func_in.result b/mysql-test/suite/pbxt/r/func_in.result index b6b9e8be16e..167f75240a7 100644 --- a/mysql-test/suite/pbxt/r/func_in.result +++ b/mysql-test/suite/pbxt/r/func_in.result @@ -419,9 +419,15 @@ id select_type table type possible_keys key key_len ref rows Extra select f2 from t2 where f2 in ('a','b'); f2 0 +Warnings: +Warning 1292 Truncated incorrect DOUBLE value: 'a' +Warning 1292 Truncated incorrect DOUBLE value: 'b' explain select f2 from t2 where f2 in ('a','b'); id select_type table type possible_keys key key_len ref rows Extra 1 SIMPLE t2 index t2f2 t2f2 5 NULL 3 Using where; Using index +Warnings: +Warning 1292 Truncated incorrect DOUBLE value: 'a' +Warning 1292 Truncated incorrect DOUBLE value: 'b' select f2 from t2 where f2 in (1,'b'); f2 0 diff --git a/mysql-test/suite/pbxt/r/group_by.result b/mysql-test/suite/pbxt/r/group_by.result index c2f31b2165b..b33c9ac87c2 100644 --- a/mysql-test/suite/pbxt/r/group_by.result +++ b/mysql-test/suite/pbxt/r/group_by.result @@ -1171,8 +1171,8 @@ id select_type table type possible_keys key key_len ref rows Extra EXPLAIN SELECT 1 FROM t1 WHERE a IN (SELECT a FROM t1 USE INDEX (i2) IGNORE INDEX (i2)); id select_type table type possible_keys key key_len ref rows Extra -1 PRIMARY t1 index NULL PRIMARY 4 NULL 144 Using where; Using index -2 DEPENDENT SUBQUERY t1 ALL NULL NULL NULL NULL 144 Using where +1 PRIMARY t1 index PRIMARY,i2 PRIMARY 4 NULL 144 Using index +1 PRIMARY t1 ALL NULL NULL NULL NULL 144 Using where; FirstMatch(t1) CREATE TABLE t2 (a INT, b INT, KEY(a)); INSERT INTO t2 VALUES (1, 1), (2, 2), (3,3), (4,4); EXPLAIN SELECT a, SUM(b) FROM t2 GROUP BY a LIMIT 2; @@ -1184,6 +1184,6 @@ id select_type table type possible_keys key key_len ref rows Extra EXPLAIN SELECT 1 FROM t2 WHERE a IN (SELECT a FROM t1 USE INDEX (i2) IGNORE INDEX (i2)); id select_type table type possible_keys key key_len ref rows Extra -1 PRIMARY t2 index NULL a 5 NULL 4 Using where; Using index -2 DEPENDENT SUBQUERY t1 ALL NULL NULL NULL NULL 144 Using where +1 PRIMARY t2 index a a 5 NULL 4 Using index +1 PRIMARY t1 ALL NULL NULL NULL NULL 144 Using where; FirstMatch(t2) DROP TABLE t1, t2; diff --git a/mysql-test/suite/pbxt/r/having.result b/mysql-test/suite/pbxt/r/having.result index d76cd81022b..fede184f9f7 100644 --- a/mysql-test/suite/pbxt/r/having.result +++ b/mysql-test/suite/pbxt/r/having.result @@ -400,7 +400,7 @@ select f1 from t1 group by f1 having max(f1)=f1; f1 set session sql_mode='ONLY_FULL_GROUP_BY'; select f1 from t1 having max(f1)=f1; -ERROR 42000: non-grouping field 'f1' is used in HAVING clause +ERROR 42000: Non-grouping field 'f1' is used in HAVING clause select f1 from t1 group by f1 having max(f1)=f1; f1 set session sql_mode=''; diff --git a/mysql-test/suite/pbxt/r/heap.result b/mysql-test/suite/pbxt/r/heap.result index 17088ee01a6..0404e8b98f9 100644 --- a/mysql-test/suite/pbxt/r/heap.result +++ b/mysql-test/suite/pbxt/r/heap.result @@ -715,8 +715,8 @@ create table t1 (c char(10)) engine=memory; create table t2 (c varchar(10)) engine=memory; show table status like 't_'; Name Engine Version Row_format Rows Avg_row_length Data_length Max_data_length Index_length Data_free Auto_increment Create_time Update_time Check_time Collation Checksum Create_options Comment -t1 MEMORY 10 Fixed 0 11 0 # 0 0 NULL NULL NULL NULL latin1_swedish_ci NULL -t2 MEMORY 10 Fixed 0 12 0 # 0 0 NULL NULL NULL NULL latin1_swedish_ci NULL +t1 MEMORY 10 Fixed 0 11 0 # 0 0 NULL # NULL NULL latin1_swedish_ci NULL +t2 MEMORY 10 Fixed 0 12 0 # 0 0 NULL # NULL NULL latin1_swedish_ci NULL drop table t1, t2; CREATE TABLE t1(a VARCHAR(1), b VARCHAR(2), c VARCHAR(256), KEY(a), KEY(b), KEY(c)) ENGINE=MEMORY; diff --git a/mysql-test/suite/pbxt/r/join_nested.result b/mysql-test/suite/pbxt/r/join_nested.result index b4edf18f2f5..1a195cb13a8 100644 --- a/mysql-test/suite/pbxt/r/join_nested.result +++ b/mysql-test/suite/pbxt/r/join_nested.result @@ -1017,6 +1017,7 @@ id select_type table type possible_keys key key_len ref rows Extra ATTENTION: the above EXPLAIN has several competing QEPs with identical . costs. To combat the plan change it uses --sorted_result and . and --replace tricks +INSERT INTO t1 VALUES (-1,133,0), (-2,12,0), (-3,11,0), (-5,15,0); CREATE INDEX idx_b ON t1(b); CREATE INDEX idx_a ON t0(a); EXPLAIN @@ -1041,7 +1042,7 @@ ON t6.b >= 2 AND t5.b=t7.b ) ON (t3.b=2 OR t3.c IS NULL) AND (t6.b=2 OR t6.c IS NULL) AND (t1.b=t5.b OR t3.c IS NULL OR t6.c IS NULL or t8.c IS NULL) AND -(t1.a != 2), +(t1.a != 2) AND t1.a>0, t9 WHERE t0.a=1 AND t0.b=t1.b AND @@ -1089,7 +1090,7 @@ ON t6.b >= 2 AND t5.b=t7.b ) ON (t3.b=2 OR t3.c IS NULL) AND (t6.b=2 OR t6.c IS NULL) AND (t1.b=t5.b OR t3.c IS NULL OR t6.c IS NULL or t8.c IS NULL) AND -(t1.a != 2), +(t1.a != 2) AND t1.a>0, t9 WHERE t0.a=1 AND t0.b=t1.b AND diff --git a/mysql-test/suite/pbxt/r/key_diff.result b/mysql-test/suite/pbxt/r/key_diff.result index 33bedfcc39e..99bc7e7f8ad 100644 --- a/mysql-test/suite/pbxt/r/key_diff.result +++ b/mysql-test/suite/pbxt/r/key_diff.result @@ -6,7 +6,12 @@ KEY (a), KEY (b) ); INSERT INTO t1 VALUES ('A','B'),('b','A'),('C','c'),('D','E'),('a','a'); -select * from t1,t1 as t2; +INSERT INTO t1 VALUES +('AA','BB'),('bb','AA'),('CC','cc'),('DD','EE'),('aa','aa'); +INSERT INTO t1 VALUES +('AAA','BBB'),('bbb','AAA'),('CCC','ccc'),('DDD','EEE'),('aaa','aaa'); +select * from t1,t1 as t2 +where length(t1.A)=1 and length(t2.B)=1 ; a b a b A B A B b A A B @@ -33,11 +38,14 @@ b A a a C c a a D E a a a a a a -explain select t1.*,t2.* from t1,t1 as t2 where t1.A=t2.B; +explain select t1.*,t2.* from t1,t1 as t2 +where t1.A=t2.B and length(t1.A)=1 and length(t2.B)=1; id select_type table type possible_keys key key_len ref rows Extra -1 SIMPLE t1 ALL a NULL NULL NULL 5 +1 SIMPLE t1 ALL a NULL NULL NULL 15 Using where 1 SIMPLE t2 ref b b 4 test.t1.a 1 Using where -select t1.*,t2.* from t1,t1 as t2 where t1.A=t2.B order by binary t1.a,t2.a; +select t1.*,t2.* from t1,t1 as t2 +where t1.A=t2.B and length(t1.A)=1 and length(t2.B)=1 +order by binary t1.a,t2.a; a b a b A B a a A B b A diff --git a/mysql-test/suite/pbxt/r/limit.result b/mysql-test/suite/pbxt/r/limit.result index 9bbf54fcfe9..dd53cb7deec 100644 --- a/mysql-test/suite/pbxt/r/limit.result +++ b/mysql-test/suite/pbxt/r/limit.result @@ -23,7 +23,7 @@ a b 2 2 3 2 4 4 -delete from t1 where b=2 limit 1; +delete from t1 where b=2 order by a limit 1; select * from t1 order by a; a b 0 0 diff --git a/mysql-test/suite/pbxt/r/mysqlshow.result b/mysql-test/suite/pbxt/r/mysqlshow.result index 96e45e84b77..a8bd5904600 100644 --- a/mysql-test/suite/pbxt/r/mysqlshow.result +++ b/mysql-test/suite/pbxt/r/mysqlshow.result @@ -132,11 +132,11 @@ Database: information_schema | INNODB_SYS_TABLES | | INNODB_SYS_FIELDS | | INNODB_SYS_COLUMNS | -| INNODB_TABLE_STATS | | INNODB_SYS_STATS | | INNODB_SYS_FOREIGN | | INNODB_SYS_INDEXES | | XTRADB_ADMIN_COMMAND | +| INNODB_TABLE_STATS | +---------------------------------------+ Database: INFORMATION_SCHEMA +---------------------------------------+ @@ -195,11 +195,11 @@ Database: INFORMATION_SCHEMA | INNODB_SYS_TABLES | | INNODB_SYS_FIELDS | | INNODB_SYS_COLUMNS | -| INNODB_TABLE_STATS | | INNODB_SYS_STATS | | INNODB_SYS_FOREIGN | | INNODB_SYS_INDEXES | | XTRADB_ADMIN_COMMAND | +| INNODB_TABLE_STATS | +---------------------------------------+ Wildcard: inf_rmation_schema +--------------------+ diff --git a/mysql-test/suite/pbxt/r/select_safe.result b/mysql-test/suite/pbxt/r/select_safe.result index 27e4154fe71..801c8fa67a3 100644 --- a/mysql-test/suite/pbxt/r/select_safe.result +++ b/mysql-test/suite/pbxt/r/select_safe.result @@ -37,7 +37,7 @@ ERROR HY000: You are using safe update mode and you tried to update a table with delete from t1 where a+0=1; ERROR HY000: You are using safe update mode and you tried to update a table without a WHERE that uses a KEY column select 1 from t1,t1 as t2,t1 as t3,t1 as t4,t1 as t5; -ERROR 42000: The SELECT would examine more than MAX_JOIN_SIZE rows; check your WHERE and use SET SQL_BIG_SELECTS=1 or SET SQL_MAX_JOIN_SIZE=# if the SELECT is okay +ERROR 42000: The SELECT would examine more than MAX_JOIN_SIZE rows; check your WHERE and use SET SQL_BIG_SELECTS=1 or SET MAX_JOIN_SIZE=# if the SELECT is okay update t1 set b="a" order by a limit 1; update t1 set b="a" where b="b" order by a limit 2; delete from t1 where b="test" order by a limit 1; @@ -49,7 +49,7 @@ SELECT @@MAX_JOIN_SIZE, @@SQL_BIG_SELECTS; 2 0 insert into t1 values (null,"a"),(null,"a"),(null,"a"),(null,"a"),(null,"a"),(null,"a"),(null,"a"),(null,"a"),(null,"a"),(null,"a"); SELECT * from t1 order by a; -ERROR 42000: The SELECT would examine more than MAX_JOIN_SIZE rows; check your WHERE and use SET SQL_BIG_SELECTS=1 or SET SQL_MAX_JOIN_SIZE=# if the SELECT is okay +ERROR 42000: The SELECT would examine more than MAX_JOIN_SIZE rows; check your WHERE and use SET SQL_BIG_SELECTS=1 or SET MAX_JOIN_SIZE=# if the SELECT is okay SET SQL_BIG_SELECTS=1; SELECT * from t1 order by a; a b @@ -59,7 +59,7 @@ a b 5 a SET MAX_JOIN_SIZE=2; SELECT * from t1; -ERROR 42000: The SELECT would examine more than MAX_JOIN_SIZE rows; check your WHERE and use SET SQL_BIG_SELECTS=1 or SET SQL_MAX_JOIN_SIZE=# if the SELECT is okay +ERROR 42000: The SELECT would examine more than MAX_JOIN_SIZE rows; check your WHERE and use SET SQL_BIG_SELECTS=1 or SET MAX_JOIN_SIZE=# if the SELECT is okay SET MAX_JOIN_SIZE=DEFAULT; SELECT * from t1; a b @@ -89,13 +89,13 @@ insert into t1 select * from t1; insert into t1 select * from t1; set local max_join_size=8; select * from (select * from t1) x; -ERROR 42000: The SELECT would examine more than MAX_JOIN_SIZE rows; check your WHERE and use SET SQL_BIG_SELECTS=1 or SET SQL_MAX_JOIN_SIZE=# if the SELECT is okay +ERROR 42000: The SELECT would examine more than MAX_JOIN_SIZE rows; check your WHERE and use SET SQL_BIG_SELECTS=1 or SET MAX_JOIN_SIZE=# if the SELECT is okay set local max_join_size=1; select * from (select a.a as aa, b.a as ba from t1 a, t1 b) x; -ERROR 42000: The SELECT would examine more than MAX_JOIN_SIZE rows; check your WHERE and use SET SQL_BIG_SELECTS=1 or SET SQL_MAX_JOIN_SIZE=# if the SELECT is okay +ERROR 42000: The SELECT would examine more than MAX_JOIN_SIZE rows; check your WHERE and use SET SQL_BIG_SELECTS=1 or SET MAX_JOIN_SIZE=# if the SELECT is okay set local max_join_size=1; select * from (select 1 union select 2 union select 3) x; -ERROR 42000: The SELECT would examine more than MAX_JOIN_SIZE rows; check your WHERE and use SET SQL_BIG_SELECTS=1 or SET SQL_MAX_JOIN_SIZE=# if the SELECT is okay +ERROR 42000: The SELECT would examine more than MAX_JOIN_SIZE rows; check your WHERE and use SET SQL_BIG_SELECTS=1 or SET MAX_JOIN_SIZE=# if the SELECT is okay drop table t1; SET SQL_SAFE_UPDATES=0,SQL_SELECT_LIMIT=DEFAULT, SQL_MAX_JOIN_SIZE=DEFAULT; Warnings: diff --git a/mysql-test/suite/pbxt/r/subselect.result b/mysql-test/suite/pbxt/r/subselect.result index f8f75a6f543..c012c2d1c29 100644 --- a/mysql-test/suite/pbxt/r/subselect.result +++ b/mysql-test/suite/pbxt/r/subselect.result @@ -50,7 +50,7 @@ id select_type table type possible_keys key key_len ref rows filtered Extra Warnings: Note 1276 Field or reference 'b.a' of SELECT #3 was resolved in SELECT #1 Note 1276 Field or reference 'b.a' of SELECT #3 was resolved in SELECT #1 -Note 1003 select 1 AS `1` from dual having ((select 1) = 1) +Note 1003 select 1 AS `1` from dual having (<expr_cache><1>((select 1)) = 1) SELECT 1 FROM (SELECT 1 as a) as b HAVING (SELECT a)=1; 1 1 @@ -224,7 +224,7 @@ id select_type table type possible_keys key key_len ref rows filtered Extra 3 DEPENDENT SUBQUERY t3 ALL NULL NULL NULL NULL 3 100.00 Using where Warnings: Note 1276 Field or reference 'test.t4.a' of SELECT #3 was resolved in SELECT #1 -Note 1003 select `test`.`t4`.`b` AS `b`,(select avg((`test`.`t2`.`a` + (select min(`test`.`t3`.`a`) from `test`.`t3` where (`test`.`t3`.`a` >= `test`.`t4`.`a`)))) from `test`.`t2`) AS `(select avg(t2.a+(select min(t3.a) from t3 where t3.a >= t4.a)) from t2)` from `test`.`t4` +Note 1003 select `test`.`t4`.`b` AS `b`,<expr_cache><`test`.`t4`.`a`>((select avg((`test`.`t2`.`a` + (select min(`test`.`t3`.`a`) from `test`.`t3` where (`test`.`t3`.`a` >= `test`.`t4`.`a`)))) from `test`.`t2`)) AS `(select avg(t2.a+(select min(t3.a) from t3 where t3.a >= t4.a)) from t2)` from `test`.`t4` select * from t3 where exists (select * from t2 where t2.b=t3.a); a 7 @@ -270,7 +270,7 @@ id select_type table type possible_keys key key_len ref rows filtered Extra 1 PRIMARY t3 ALL NULL NULL NULL NULL 3 100.00 Using where 2 SUBQUERY t2 ALL NULL NULL NULL NULL 3 100.00 Warnings: -Note 1003 select `test`.`t3`.`a` AS `a` from `test`.`t3` where <nop>(<in_optimizer>(`test`.`t3`.`a`,((select min(`test`.`t2`.`b`) from `test`.`t2`) <= `test`.`t3`.`a`))) +Note 1003 select `test`.`t3`.`a` AS `a` from `test`.`t3` where <nop>(<in_optimizer>(`test`.`t3`.`a`,((select min(`test`.`t2`.`b`) from `test`.`t2`) <= <cache>(`test`.`t3`.`a`)))) select * from t3 where a >= all (select b from t2); a 7 @@ -314,7 +314,7 @@ NULL UNION RESULT <union2,3> ALL NULL NULL NULL NULL # NULL Warnings: Note 1276 Field or reference 'test.t2.a' of SELECT #2 was resolved in SELECT #1 Note 1276 Field or reference 'test.t2.a' of SELECT #3 was resolved in SELECT #1 -Note 1003 select (select `test`.`t1`.`a` from `test`.`t1` where (`test`.`t1`.`a` = `test`.`t2`.`a`) union select `test`.`t5`.`a` from `test`.`t5` where (`test`.`t5`.`a` = `test`.`t2`.`a`)) AS `(select a from t1 where t1.a=t2.a union select a from t5 where t5.a=t2.a)`,`test`.`t2`.`a` AS `a` from `test`.`t2` +Note 1003 select <expr_cache><`test`.`t2`.`a`>((select `test`.`t1`.`a` from `test`.`t1` where (`test`.`t1`.`a` = `test`.`t2`.`a`) union select `test`.`t5`.`a` from `test`.`t5` where (`test`.`t5`.`a` = `test`.`t2`.`a`))) AS `(select a from t1 where t1.a=t2.a union select a from t5 where t5.a=t2.a)`,`test`.`t2`.`a` AS `a` from `test`.`t2` select (select a from t1 where t1.a=t2.a union all select a from t5 where t5.a=t2.a), a from t2; ERROR 21000: Subquery returns more than 1 row create table t6 (patient_uq int, clinic_uq int, index i1 (clinic_uq)); @@ -332,7 +332,7 @@ id select_type table type possible_keys key key_len ref rows filtered Extra 2 DEPENDENT SUBQUERY t7 eq_ref PRIMARY PRIMARY 4 test.t6.clinic_uq 1 100.00 Using index Warnings: Note 1276 Field or reference 'test.t6.clinic_uq' of SELECT #2 was resolved in SELECT #1 -Note 1003 select `test`.`t6`.`patient_uq` AS `patient_uq`,`test`.`t6`.`clinic_uq` AS `clinic_uq` from `test`.`t6` where exists(select 1 from `test`.`t7` where (`test`.`t7`.`uq` = `test`.`t6`.`clinic_uq`)) +Note 1003 select `test`.`t6`.`patient_uq` AS `patient_uq`,`test`.`t6`.`clinic_uq` AS `clinic_uq` from `test`.`t6` where <expr_cache><`test`.`t6`.`clinic_uq`>(exists(select 1 from `test`.`t7` where (`test`.`t7`.`uq` = `test`.`t6`.`clinic_uq`))) select * from t1 where a= (select a from t2,t4 where t2.b=t4.b); ERROR 23000: Column 'a' in field list is ambiguous drop table t1,t2,t3; @@ -362,12 +362,12 @@ INSERT INTO t8 (pseudo,email) VALUES ('joce1','test1'); INSERT INTO t8 (pseudo,email) VALUES ('2joce1','2test1'); EXPLAIN EXTENDED SELECT pseudo,(SELECT email FROM t8 WHERE pseudo=(SELECT pseudo FROM t8 WHERE pseudo='joce')) FROM t8 WHERE pseudo=(SELECT pseudo FROM t8 WHERE pseudo='joce'); id select_type table type possible_keys key key_len ref rows filtered Extra -1 PRIMARY t8 const PRIMARY PRIMARY 37 const 1 100.00 Using index +1 PRIMARY t8 const PRIMARY PRIMARY 37 const 1 100.00 Using where; Using index 4 SUBQUERY t8 const PRIMARY PRIMARY 37 const 1 100.00 Using index -2 SUBQUERY t8 const PRIMARY PRIMARY 37 const 1 100.00 +2 SUBQUERY t8 const PRIMARY PRIMARY 37 const 1 100.00 Using where 3 SUBQUERY t8 const PRIMARY PRIMARY 37 const 1 100.00 Using index Warnings: -Note 1003 select 'joce' AS `pseudo`,(select 'test' from `test`.`t8` where ('joce' = (select 'joce' from `test`.`t8` where 1))) AS `(SELECT email FROM t8 WHERE pseudo=(SELECT pseudo FROM t8 WHERE pseudo='joce'))` from `test`.`t8` where ('joce' = (select 'joce' from `test`.`t8` where 1)) +Note 1003 select `test`.`t8`.`pseudo` AS `pseudo`,(select `test`.`t8`.`email` from `test`.`t8` where (`test`.`t8`.`pseudo` = (select 'joce' from `test`.`t8` where 1))) AS `(SELECT email FROM t8 WHERE pseudo=(SELECT pseudo FROM t8 WHERE pseudo='joce'))` from `test`.`t8` where (`test`.`t8`.`pseudo` = (select 'joce' from `test`.`t8` where 1)) SELECT pseudo FROM t8 WHERE pseudo=(SELECT pseudo,email FROM t8 WHERE pseudo='joce'); ERROR 21000: Operand should contain 1 column(s) @@ -535,18 +535,24 @@ SELECT numreponse, (SELECT numeropost FROM t1 HAVING numreponse=1) FROM (SELECT numreponse (SELECT numeropost FROM t1 HAVING numreponse=1) INSERT INTO t1 (numeropost,numreponse,pseudo) VALUES (1,1,'joce'),(1,2,'joce'),(1,3,'test'); EXPLAIN EXTENDED SELECT numreponse FROM t1 WHERE numeropost='1' AND numreponse=(SELECT 1 FROM t1 WHERE numeropost='1'); +id select_type table type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t1 const PRIMARY,numreponse PRIMARY 7 const,const 1 100.00 Using where; Using index +2 SUBQUERY t1 ref PRIMARY PRIMARY 3 const 2 100.00 Using index +Warnings: +Note 1003 select `test`.`t1`.`numreponse` AS `numreponse` from `test`.`t1` where ((`test`.`t1`.`numeropost` = '1') and (`test`.`t1`.`numreponse` = (select 1 from `test`.`t1` where (`test`.`t1`.`numeropost` = '1')))) +SELECT numreponse FROM t1 WHERE numeropost='1' AND numreponse=(SELECT 1 FROM t1 WHERE numeropost='1'); ERROR 21000: Subquery returns more than 1 row EXPLAIN EXTENDED SELECT MAX(numreponse) FROM t1 WHERE numeropost='1'; id select_type table type possible_keys key key_len ref rows filtered Extra 1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL Select tables optimized away Warnings: -Note 1003 select max(`test`.`t1`.`numreponse`) AS `MAX(numreponse)` from `test`.`t1` where multiple equal(1, `test`.`t1`.`numeropost`) +Note 1003 select max(`test`.`t1`.`numreponse`) AS `MAX(numreponse)` from `test`.`t1` where (`test`.`t1`.`numeropost` = '1') EXPLAIN EXTENDED SELECT numreponse FROM t1 WHERE numeropost='1' AND numreponse=(SELECT MAX(numreponse) FROM t1 WHERE numeropost='1'); id select_type table type possible_keys key key_len ref rows filtered Extra -1 PRIMARY t1 const PRIMARY,numreponse PRIMARY 7 const,const 1 100.00 Using index +1 PRIMARY t1 const PRIMARY,numreponse PRIMARY 7 const,const 1 100.00 Using where; Using index 2 SUBQUERY NULL NULL NULL NULL NULL NULL NULL NULL Select tables optimized away Warnings: -Note 1003 select 3 AS `numreponse` from `test`.`t1` where ((3 = (select max(`test`.`t1`.`numreponse`) from `test`.`t1` where multiple equal(1, `test`.`t1`.`numeropost`)))) +Note 1003 select `test`.`t1`.`numreponse` AS `numreponse` from `test`.`t1` where ((`test`.`t1`.`numeropost` = '1') and (`test`.`t1`.`numreponse` = (select max(`test`.`t1`.`numreponse`) from `test`.`t1` where (`test`.`t1`.`numeropost` = '1')))) drop table t1; CREATE TABLE t1 (a int(1)); INSERT INTO t1 VALUES (1); @@ -743,7 +749,7 @@ id select_type table type possible_keys key key_len ref rows filtered Extra 3 DEPENDENT UNION NULL NULL NULL NULL NULL NULL NULL NULL No tables used NULL UNION RESULT <union2,3> ALL NULL NULL NULL NULL NULL NULL Warnings: -Note 1003 select `test`.`t2`.`id` AS `id` from `test`.`t2` where <in_optimizer>(`test`.`t2`.`id`,<exists>(select 1 having (<cache>(`test`.`t2`.`id`) = <ref_null_helper>(1)) union select 3 having (<cache>(`test`.`t2`.`id`) = <ref_null_helper>(3)))) +Note 1003 select `test`.`t2`.`id` AS `id` from `test`.`t2` where <expr_cache><`test`.`t2`.`id`>(<in_optimizer>(`test`.`t2`.`id`,<exists>(select 1 having (<cache>(`test`.`t2`.`id`) = <ref_null_helper>(1)) union select 3 having (<cache>(`test`.`t2`.`id`) = <ref_null_helper>(3))))) SELECT * FROM t2 WHERE id IN (SELECT 5 UNION SELECT 3); id SELECT * FROM t2 WHERE id IN (SELECT 5 UNION SELECT 2); @@ -893,7 +899,7 @@ id select_type table type possible_keys key key_len ref rows filtered Extra 1 PRIMARY t1 index NULL PRIMARY 4 NULL 4 100.00 Using index 2 DEPENDENT SUBQUERY t2 index_subquery a a 5 func 2 100.00 Using index Warnings: -Note 1003 select `test`.`t1`.`a` AS `a`,<in_optimizer>(`test`.`t1`.`a`,<exists>(<index_lookup>(<cache>(`test`.`t1`.`a`) in t2 on a checking NULL having <is_not_null_test>(`test`.`t2`.`a`)))) AS `t1.a in (select t2.a from t2)` from `test`.`t1` +Note 1003 select `test`.`t1`.`a` AS `a`,<expr_cache><`test`.`t1`.`a`>(<in_optimizer>(`test`.`t1`.`a`,<exists>(<index_lookup>(<cache>(`test`.`t1`.`a`) in t2 on a checking NULL having <is_not_null_test>(`test`.`t2`.`a`))))) AS `t1.a in (select t2.a from t2)` from `test`.`t1` CREATE TABLE t3 (a int(11) default '0'); INSERT INTO t3 VALUES (1),(2),(3); SELECT t1.a, t1.a in (select t2.a from t2,t3 where t3.a=t2.a) FROM t1; @@ -908,7 +914,7 @@ id select_type table type possible_keys key key_len ref rows filtered Extra 2 DEPENDENT SUBQUERY t2 ref_or_null a a 5 func 2 100.00 Using where; Using index 2 DEPENDENT SUBQUERY t3 ALL NULL NULL NULL NULL 3 100.00 Using where; Using join buffer (flat, BNL join) Warnings: -Note 1003 select `test`.`t1`.`a` AS `a`,<in_optimizer>(`test`.`t1`.`a`,<exists>(select `test`.`t2`.`a` from `test`.`t2` join `test`.`t3` where ((`test`.`t3`.`a` = `test`.`t2`.`a`) and ((<cache>(`test`.`t1`.`a`) = `test`.`t2`.`a`) or isnull(`test`.`t2`.`a`))) having <is_not_null_test>(`test`.`t2`.`a`))) AS `t1.a in (select t2.a from t2,t3 where t3.a=t2.a)` from `test`.`t1` +Note 1003 select `test`.`t1`.`a` AS `a`,<expr_cache><`test`.`t1`.`a`>(<in_optimizer>(`test`.`t1`.`a`,<exists>(select `test`.`t2`.`a` from `test`.`t2` join `test`.`t3` where ((`test`.`t3`.`a` = `test`.`t2`.`a`) and ((<cache>(`test`.`t1`.`a`) = `test`.`t2`.`a`) or isnull(`test`.`t2`.`a`))) having <is_not_null_test>(`test`.`t2`.`a`)))) AS `t1.a in (select t2.a from t2,t3 where t3.a=t2.a)` from `test`.`t1` drop table t1,t2,t3; create table t1 (a float); select 10.5 IN (SELECT * from t1 LIMIT 1); @@ -1295,31 +1301,31 @@ a 4 explain extended select * from t2 where t2.a in (select a from t1); id select_type table type possible_keys key key_len ref rows filtered Extra -1 PRIMARY t2 index NULL PRIMARY 4 NULL 4 100.00 Using where; Using index -2 DEPENDENT SUBQUERY t1 unique_subquery PRIMARY PRIMARY 4 func 1 100.00 Using index +1 PRIMARY t2 index PRIMARY PRIMARY 4 NULL 4 100.00 Using index +1 PRIMARY t1 index PRIMARY PRIMARY 4 NULL 4 75.00 Using where; Using index; Using join buffer (flat, BNL join) Warnings: -Note 1003 select `test`.`t2`.`a` AS `a` from `test`.`t2` where <in_optimizer>(`test`.`t2`.`a`,<exists>(<primary_index_lookup>(<cache>(`test`.`t2`.`a`) in t1 on PRIMARY))) +Note 1003 select `test`.`t2`.`a` AS `a` from `test`.`t1` join `test`.`t2` where (`test`.`t1`.`a` = `test`.`t2`.`a`) select * from t2 where t2.a in (select a from t1 where t1.b <> 30); a 2 4 explain extended select * from t2 where t2.a in (select a from t1 where t1.b <> 30); id select_type table type possible_keys key key_len ref rows filtered Extra -1 PRIMARY t2 index NULL PRIMARY 4 NULL 4 100.00 Using where; Using index -2 DEPENDENT SUBQUERY t1 unique_subquery PRIMARY PRIMARY 4 func 1 100.00 Using where +1 PRIMARY t2 index PRIMARY PRIMARY 4 NULL 4 100.00 Using index +1 PRIMARY t1 ALL PRIMARY NULL NULL NULL 4 75.00 Using where; Using join buffer (flat, BNL join) Warnings: -Note 1003 select `test`.`t2`.`a` AS `a` from `test`.`t2` where <in_optimizer>(`test`.`t2`.`a`,<exists>(<primary_index_lookup>(<cache>(`test`.`t2`.`a`) in t1 on PRIMARY where ((`test`.`t1`.`b` <> 30) and (<cache>(`test`.`t2`.`a`) = `test`.`t1`.`a`))))) +Note 1003 select `test`.`t2`.`a` AS `a` from `test`.`t1` join `test`.`t2` where ((`test`.`t1`.`a` = `test`.`t2`.`a`) and (`test`.`t1`.`b` <> 30)) select * from t2 where t2.a in (select t1.a from t1,t3 where t1.b=t3.a); a 2 3 explain extended select * from t2 where t2.a in (select t1.a from t1,t3 where t1.b=t3.a); id select_type table type possible_keys key key_len ref rows filtered Extra -1 PRIMARY t2 index NULL PRIMARY 4 NULL 4 100.00 Using where; Using index -2 DEPENDENT SUBQUERY t1 eq_ref PRIMARY PRIMARY 4 func 1 100.00 Using where -2 DEPENDENT SUBQUERY t3 eq_ref PRIMARY PRIMARY 4 test.t1.b 1 100.00 Using index +1 PRIMARY t2 index PRIMARY PRIMARY 4 NULL 4 100.00 Using index +1 PRIMARY t1 ALL PRIMARY NULL NULL NULL 4 75.00 Using where; Using join buffer (flat, BNL join) +1 PRIMARY t3 eq_ref PRIMARY PRIMARY 4 test.t1.b 1 100.00 Using index Warnings: -Note 1003 select `test`.`t2`.`a` AS `a` from `test`.`t2` where <in_optimizer>(`test`.`t2`.`a`,<exists>(select `test`.`t1`.`a` from `test`.`t1` join `test`.`t3` where ((`test`.`t3`.`a` = `test`.`t1`.`b`) and (<cache>(`test`.`t2`.`a`) = `test`.`t1`.`a`)))) +Note 1003 select `test`.`t2`.`a` AS `a` from `test`.`t1` join `test`.`t3` join `test`.`t2` where ((`test`.`t1`.`a` = `test`.`t2`.`a`) and (`test`.`t3`.`a` = `test`.`t1`.`b`)) drop table t1, t2, t3; create table t1 (a int, b int, index a (a,b)); create table t2 (a int, index a (a)); @@ -1334,31 +1340,31 @@ a 4 explain extended select * from t2 where t2.a in (select a from t1); id select_type table type possible_keys key key_len ref rows filtered Extra -1 PRIMARY t2 index NULL a 5 NULL 4 100.00 Using where; Using index -2 DEPENDENT SUBQUERY t1 index_subquery a a 5 func 1 100.00 Using index +1 PRIMARY t2 index a a 5 NULL 4 100.00 Using where; Using index +1 PRIMARY t1 ref a a 5 test.t2.a 1 100.00 Using index; FirstMatch(t2) Warnings: -Note 1003 select `test`.`t2`.`a` AS `a` from `test`.`t2` where <in_optimizer>(`test`.`t2`.`a`,<exists>(<index_lookup>(<cache>(`test`.`t2`.`a`) in t1 on a))) +Note 1003 select `test`.`t2`.`a` AS `a` from `test`.`t2` semi join (`test`.`t1`) where (`test`.`t1`.`a` = `test`.`t2`.`a`) select * from t2 where t2.a in (select a from t1 where t1.b <> 30); a 2 4 explain extended select * from t2 where t2.a in (select a from t1 where t1.b <> 30); id select_type table type possible_keys key key_len ref rows filtered Extra -1 PRIMARY t2 index NULL a 5 NULL 4 100.00 Using where; Using index -2 DEPENDENT SUBQUERY t1 index_subquery a a 5 func 1 100.00 Using index; Using where +1 PRIMARY t2 index a a 5 NULL 4 100.00 Using where; Using index +1 PRIMARY t1 ref a a 5 test.t2.a 1 100.00 Using where; Using index; FirstMatch(t2) Warnings: -Note 1003 select `test`.`t2`.`a` AS `a` from `test`.`t2` where <in_optimizer>(`test`.`t2`.`a`,<exists>(<index_lookup>(<cache>(`test`.`t2`.`a`) in t1 on a where ((`test`.`t1`.`b` <> 30) and (<cache>(`test`.`t2`.`a`) = `test`.`t1`.`a`))))) +Note 1003 select `test`.`t2`.`a` AS `a` from `test`.`t2` semi join (`test`.`t1`) where ((`test`.`t1`.`a` = `test`.`t2`.`a`) and (`test`.`t1`.`b` <> 30)) select * from t2 where t2.a in (select t1.a from t1,t3 where t1.b=t3.a); a 2 3 explain extended select * from t2 where t2.a in (select t1.a from t1,t3 where t1.b=t3.a); id select_type table type possible_keys key key_len ref rows filtered Extra -1 PRIMARY t2 index NULL a 5 NULL 4 100.00 Using where; Using index -2 DEPENDENT SUBQUERY t1 ref a a 5 func 1 100.00 Using where; Using index -2 DEPENDENT SUBQUERY t3 ref a a 5 test.t1.b 1 100.00 Using index +1 PRIMARY t2 index a a 5 NULL 4 100.00 Using where; Using index; Start temporary +1 PRIMARY t1 ref a a 5 test.t2.a 1 100.00 Using index +1 PRIMARY t3 index a a 5 NULL 3 100.00 Using where; Using index; End temporary Warnings: -Note 1003 select `test`.`t2`.`a` AS `a` from `test`.`t2` where <in_optimizer>(`test`.`t2`.`a`,<exists>(select `test`.`t1`.`a` from `test`.`t1` join `test`.`t3` where ((`test`.`t3`.`a` = `test`.`t1`.`b`) and (<cache>(`test`.`t2`.`a`) = `test`.`t1`.`a`)))) +Note 1003 select `test`.`t2`.`a` AS `a` from `test`.`t2` semi join (`test`.`t1` join `test`.`t3`) where ((`test`.`t1`.`a` = `test`.`t2`.`a`) and (`test`.`t3`.`a` = `test`.`t1`.`b`)) insert into t1 values (3,31); select * from t2 where t2.a in (select a from t1 where t1.b <> 30); a @@ -1371,10 +1377,10 @@ a 4 explain extended select * from t2 where t2.a in (select a from t1 where t1.b <> 30); id select_type table type possible_keys key key_len ref rows filtered Extra -1 PRIMARY t2 index NULL a 5 NULL 4 100.00 Using where; Using index -2 DEPENDENT SUBQUERY t1 index_subquery a a 5 func 1 100.00 Using index; Using where +1 PRIMARY t2 index a a 5 NULL 4 100.00 Using where; Using index +1 PRIMARY t1 ref a a 5 test.t2.a 1 100.00 Using where; Using index; FirstMatch(t2) Warnings: -Note 1003 select `test`.`t2`.`a` AS `a` from `test`.`t2` where <in_optimizer>(`test`.`t2`.`a`,<exists>(<index_lookup>(<cache>(`test`.`t2`.`a`) in t1 on a where ((`test`.`t1`.`b` <> 30) and (<cache>(`test`.`t2`.`a`) = `test`.`t1`.`a`))))) +Note 1003 select `test`.`t2`.`a` AS `a` from `test`.`t2` semi join (`test`.`t1`) where ((`test`.`t1`.`a` = `test`.`t2`.`a`) and (`test`.`t1`.`b` <> 30)) drop table t1, t2, t3; create table t1 (a int, b int); create table t2 (a int, b int); @@ -1465,27 +1471,27 @@ id select_type table type possible_keys key key_len ref rows filtered Extra 1 PRIMARY t1 index NULL s1 6 NULL 3 100.00 Using index 2 DEPENDENT SUBQUERY t2 index_subquery s1 s1 6 func 2 100.00 Using index; Full scan on NULL key Warnings: -Note 1003 select `test`.`t1`.`s1` AS `s1`,(not(<in_optimizer>(`test`.`t1`.`s1`,<exists>(<index_lookup>(<cache>(`test`.`t1`.`s1`) in t2 on s1 checking NULL having trigcond(<is_not_null_test>(`test`.`t2`.`s1`))))))) AS `s1 NOT IN (SELECT s1 FROM t2)` from `test`.`t1` +Note 1003 select `test`.`t1`.`s1` AS `s1`,(not(<expr_cache><`test`.`t1`.`s1`>(<in_optimizer>(`test`.`t1`.`s1`,<exists>(<index_lookup>(<cache>(`test`.`t1`.`s1`) in t2 on s1 checking NULL having trigcond(<is_not_null_test>(`test`.`t2`.`s1`)))))))) AS `s1 NOT IN (SELECT s1 FROM t2)` from `test`.`t1` explain extended select s1, s1 = ANY (SELECT s1 FROM t2) from t1; id select_type table type possible_keys key key_len ref rows filtered Extra 1 PRIMARY t1 index NULL s1 6 NULL 3 100.00 Using index 2 DEPENDENT SUBQUERY t2 index_subquery s1 s1 6 func 2 100.00 Using index; Full scan on NULL key Warnings: -Note 1003 select `test`.`t1`.`s1` AS `s1`,<in_optimizer>(`test`.`t1`.`s1`,<exists>(<index_lookup>(<cache>(`test`.`t1`.`s1`) in t2 on s1 checking NULL having trigcond(<is_not_null_test>(`test`.`t2`.`s1`))))) AS `s1 = ANY (SELECT s1 FROM t2)` from `test`.`t1` +Note 1003 select `test`.`t1`.`s1` AS `s1`,<expr_cache><`test`.`t1`.`s1`>(<in_optimizer>(`test`.`t1`.`s1`,<exists>(<index_lookup>(<cache>(`test`.`t1`.`s1`) in t2 on s1 checking NULL having trigcond(<is_not_null_test>(`test`.`t2`.`s1`)))))) AS `s1 = ANY (SELECT s1 FROM t2)` from `test`.`t1` explain extended select s1, s1 <> ALL (SELECT s1 FROM t2) from t1; id select_type table type possible_keys key key_len ref rows filtered Extra 1 PRIMARY t1 index NULL s1 6 NULL 3 100.00 Using index 2 DEPENDENT SUBQUERY t2 index_subquery s1 s1 6 func 2 100.00 Using index; Full scan on NULL key Warnings: -Note 1003 select `test`.`t1`.`s1` AS `s1`,(not(<in_optimizer>(`test`.`t1`.`s1`,<exists>(<index_lookup>(<cache>(`test`.`t1`.`s1`) in t2 on s1 checking NULL having trigcond(<is_not_null_test>(`test`.`t2`.`s1`))))))) AS `s1 <> ALL (SELECT s1 FROM t2)` from `test`.`t1` +Note 1003 select `test`.`t1`.`s1` AS `s1`,(not(<expr_cache><`test`.`t1`.`s1`>(<in_optimizer>(`test`.`t1`.`s1`,<exists>(<index_lookup>(<cache>(`test`.`t1`.`s1`) in t2 on s1 checking NULL having trigcond(<is_not_null_test>(`test`.`t2`.`s1`)))))))) AS `s1 <> ALL (SELECT s1 FROM t2)` from `test`.`t1` explain extended select s1, s1 NOT IN (SELECT s1 FROM t2 WHERE s1 < 'a2') from t1; id select_type table type possible_keys key key_len ref rows filtered Extra 1 PRIMARY t1 index NULL s1 6 NULL 3 100.00 Using index 2 DEPENDENT SUBQUERY t2 index_subquery s1 s1 6 func 2 100.00 Using index; Using where; Full scan on NULL key Warnings: -Note 1003 select `test`.`t1`.`s1` AS `s1`,(not(<in_optimizer>(`test`.`t1`.`s1`,<exists>(<index_lookup>(<cache>(`test`.`t1`.`s1`) in t2 on s1 checking NULL where (`test`.`t2`.`s1` < 'a2') having trigcond(<is_not_null_test>(`test`.`t2`.`s1`))))))) AS `s1 NOT IN (SELECT s1 FROM t2 WHERE s1 < 'a2')` from `test`.`t1` +Note 1003 select `test`.`t1`.`s1` AS `s1`,(not(<expr_cache><`test`.`t1`.`s1`>(<in_optimizer>(`test`.`t1`.`s1`,<exists>(<index_lookup>(<cache>(`test`.`t1`.`s1`) in t2 on s1 checking NULL where (`test`.`t2`.`s1` < 'a2') having trigcond(<is_not_null_test>(`test`.`t2`.`s1`)))))))) AS `s1 NOT IN (SELECT s1 FROM t2 WHERE s1 < 'a2')` from `test`.`t1` drop table t1,t2; -create table t2 (a int, b int); +create table t2 (a int, b int not null); create table t3 (a int); insert into t3 values (6),(7),(3); select * from t3 where a >= all (select b from t2); @@ -1498,7 +1504,7 @@ id select_type table type possible_keys key key_len ref rows filtered Extra 1 PRIMARY t3 ALL NULL NULL NULL NULL 3 100.00 Using where 2 SUBQUERY t2 ALL NULL NULL NULL NULL 0 0.00 Warnings: -Note 1003 select `test`.`t3`.`a` AS `a` from `test`.`t3` where <not>(<in_optimizer>(`test`.`t3`.`a`,((select max(`test`.`t2`.`b`) from `test`.`t2`) > `test`.`t3`.`a`))) +Note 1003 select `test`.`t3`.`a` AS `a` from `test`.`t3` where <not>(<in_optimizer>(`test`.`t3`.`a`,((select max(`test`.`t2`.`b`) from `test`.`t2`) > <cache>(`test`.`t3`.`a`)))) select * from t3 where a >= some (select b from t2); a explain extended select * from t3 where a >= some (select b from t2); @@ -1506,7 +1512,7 @@ id select_type table type possible_keys key key_len ref rows filtered Extra 1 PRIMARY t3 ALL NULL NULL NULL NULL 3 100.00 Using where 2 SUBQUERY t2 ALL NULL NULL NULL NULL 0 0.00 Warnings: -Note 1003 select `test`.`t3`.`a` AS `a` from `test`.`t3` where <nop>(<in_optimizer>(`test`.`t3`.`a`,((select min(`test`.`t2`.`b`) from `test`.`t2`) <= `test`.`t3`.`a`))) +Note 1003 select `test`.`t3`.`a` AS `a` from `test`.`t3` where <nop>(<in_optimizer>(`test`.`t3`.`a`,((select min(`test`.`t2`.`b`) from `test`.`t2`) <= <cache>(`test`.`t3`.`a`)))) select * from t3 where a >= all (select b from t2 group by 1); a 6 @@ -1517,7 +1523,7 @@ id select_type table type possible_keys key key_len ref rows filtered Extra 1 PRIMARY t3 ALL NULL NULL NULL NULL 3 100.00 Using where 2 SUBQUERY t2 ALL NULL NULL NULL NULL 0 0.00 Using temporary Warnings: -Note 1003 select `test`.`t3`.`a` AS `a` from `test`.`t3` where <not>(<in_optimizer>(`test`.`t3`.`a`,(<max>(select `test`.`t2`.`b` from `test`.`t2` group by 1) > `test`.`t3`.`a`))) +Note 1003 select `test`.`t3`.`a` AS `a` from `test`.`t3` where <not>(<in_optimizer>(`test`.`t3`.`a`,(<max>(select `test`.`t2`.`b` from `test`.`t2` group by 1) > <cache>(`test`.`t3`.`a`)))) select * from t3 where a >= some (select b from t2 group by 1); a explain extended select * from t3 where a >= some (select b from t2 group by 1); @@ -1525,7 +1531,7 @@ id select_type table type possible_keys key key_len ref rows filtered Extra 1 PRIMARY t3 ALL NULL NULL NULL NULL 3 100.00 Using where 2 SUBQUERY t2 ALL NULL NULL NULL NULL 0 0.00 Using temporary Warnings: -Note 1003 select `test`.`t3`.`a` AS `a` from `test`.`t3` where <nop>(<in_optimizer>(`test`.`t3`.`a`,(<min>(select `test`.`t2`.`b` from `test`.`t2` group by 1) <= `test`.`t3`.`a`))) +Note 1003 select `test`.`t3`.`a` AS `a` from `test`.`t3` where <nop>(<in_optimizer>(`test`.`t3`.`a`,(<min>(select `test`.`t2`.`b` from `test`.`t2` group by 1) <= <cache>(`test`.`t3`.`a`)))) select * from t3 where NULL >= any (select b from t2); a explain extended select * from t3 where NULL >= any (select b from t2); @@ -1568,7 +1574,7 @@ id select_type table type possible_keys key key_len ref rows filtered Extra 1 PRIMARY t3 ALL NULL NULL NULL NULL 3 100.00 Using where 2 SUBQUERY t2 ALL NULL NULL NULL NULL 4 100.00 Using temporary Warnings: -Note 1003 select `test`.`t3`.`a` AS `a` from `test`.`t3` where <not>(<in_optimizer>(`test`.`t3`.`a`,(<max>(select max(`test`.`t2`.`b`) from `test`.`t2` group by `test`.`t2`.`a`) >= `test`.`t3`.`a`))) +Note 1003 select `test`.`t3`.`a` AS `a` from `test`.`t3` where <not>(<in_optimizer>(`test`.`t3`.`a`,(<max>(select max(`test`.`t2`.`b`) from `test`.`t2` group by `test`.`t2`.`a`) >= <cache>(`test`.`t3`.`a`)))) drop table t2, t3; CREATE TABLE `t1` ( `id` mediumint(9) NOT NULL auto_increment, `taskid` bigint(20) NOT NULL default '0', `dbid` int(11) NOT NULL default '0', `create_date` datetime NOT NULL default '0000-00-00 00:00:00', `last_update` datetime NOT NULL default '0000-00-00 00:00:00', PRIMARY KEY (`id`)) ENGINE=MyISAM CHARSET=latin1 AUTO_INCREMENT=3 ; INSERT INTO `t1` (`id`, `taskid`, `dbid`, `create_date`,`last_update`) VALUES (1, 1, 15, '2003-09-29 10:31:36', '2003-09-29 10:31:36'), (2, 1, 21, now(), now()); @@ -1738,14 +1744,14 @@ id select_type table type possible_keys key key_len ref rows filtered Extra 1 PRIMARY t1 ALL NULL NULL NULL NULL 12 100.00 Using where 2 DEPENDENT SUBQUERY t1 unique_subquery PRIMARY PRIMARY 4 func 1 100.00 Using index; Using where Warnings: -Note 1003 select `test`.`t1`.`id` AS `id`,`test`.`t1`.`text` AS `text` from `test`.`t1` where (not(<in_optimizer>(`test`.`t1`.`id`,<exists>(<primary_index_lookup>(<cache>(`test`.`t1`.`id`) in t1 on PRIMARY where ((`test`.`t1`.`id` < 8) and (<cache>(`test`.`t1`.`id`) = `test`.`t1`.`id`))))))) +Note 1003 select `test`.`t1`.`id` AS `id`,`test`.`t1`.`text` AS `text` from `test`.`t1` where (not(<expr_cache><`test`.`t1`.`id`>(<in_optimizer>(`test`.`t1`.`id`,<exists>(<primary_index_lookup>(<cache>(`test`.`t1`.`id`) in t1 on PRIMARY where ((`test`.`t1`.`id` < 8) and (<cache>(`test`.`t1`.`id`) = `test`.`t1`.`id`)))))))) explain extended select * from t1 as tt where not exists (select id from t1 where id < 8 and (id = tt.id or id is null) having id is not null); id select_type table type possible_keys key key_len ref rows filtered Extra 1 PRIMARY tt ALL NULL NULL NULL NULL 12 100.00 Using where 2 DEPENDENT SUBQUERY t1 eq_ref PRIMARY PRIMARY 4 test.tt.id 1 100.00 Using where; Using index Warnings: Note 1276 Field or reference 'test.tt.id' of SELECT #2 was resolved in SELECT #1 -Note 1003 select `test`.`tt`.`id` AS `id`,`test`.`tt`.`text` AS `text` from `test`.`t1` `tt` where (not(exists(select `test`.`t1`.`id` from `test`.`t1` where ((`test`.`t1`.`id` < 8) and (`test`.`t1`.`id` = `test`.`tt`.`id`)) having (`test`.`t1`.`id` is not null)))) +Note 1003 select `test`.`tt`.`id` AS `id`,`test`.`tt`.`text` AS `text` from `test`.`t1` `tt` where (not(<expr_cache><`test`.`tt`.`id`>(exists(select `test`.`t1`.`id` from `test`.`t1` where ((`test`.`t1`.`id` < 8) and (`test`.`t1`.`id` = `test`.`tt`.`id`)) having (`test`.`t1`.`id` is not null))))) insert into t1 (id, text) values (1000, 'text1000'), (1001, 'text1001'); create table t2 (id int not null, text varchar(20) not null default '', primary key (id)); insert into t2 (id, text) values (1, 'text1'), (2, 'text2'), (3, 'text3'), (4, 'text4'), (5, 'text5'), (6, 'text6'), (7, 'text7'), (8, 'text8'), (9, 'text9'), (10, 'text10'), (11, 'text1'), (12, 'text2'), (13, 'text3'), (14, 'text4'), (15, 'text5'), (16, 'text6'), (17, 'text7'), (18, 'text8'), (19, 'text9'), (20, 'text10'),(21, 'text1'), (22, 'text2'), (23, 'text3'), (24, 'text4'), (25, 'text5'), (26, 'text6'), (27, 'text7'), (28, 'text8'), (29, 'text9'), (30, 'text10'), (31, 'text1'), (32, 'text2'), (33, 'text3'), (34, 'text4'), (35, 'text5'), (36, 'text6'), (37, 'text7'), (38, 'text8'), (39, 'text9'), (40, 'text10'), (41, 'text1'), (42, 'text2'), (43, 'text3'), (44, 'text4'), (45, 'text5'), (46, 'text6'), (47, 'text7'), (48, 'text8'), (49, 'text9'), (50, 'text10'); @@ -2282,7 +2288,7 @@ id select_type table type possible_keys key key_len ref rows filtered Extra 2 DEPENDENT SUBQUERY t1 ALL NULL NULL NULL NULL 2 100.00 Using where Warnings: Note 1276 Field or reference 'test.up.a' of SELECT #2 was resolved in SELECT #1 -Note 1003 select `test`.`up`.`a` AS `a`,`test`.`up`.`b` AS `b` from `test`.`t1` `up` where exists(select 1 from `test`.`t1` where (`test`.`t1`.`a` = `test`.`up`.`a`)) +Note 1003 select `test`.`up`.`a` AS `a`,`test`.`up`.`b` AS `b` from `test`.`t1` `up` where <expr_cache><`test`.`up`.`a`>(exists(select 1 from `test`.`t1` where (`test`.`t1`.`a` = `test`.`up`.`a`))) drop table t1; CREATE TABLE t1 (t1_a int); INSERT INTO t1 VALUES (1); @@ -2825,19 +2831,19 @@ id select_type table type possible_keys key key_len ref rows filtered Extra 1 PRIMARY t1 ALL NULL NULL NULL NULL 8 100.00 2 DEPENDENT SUBQUERY t2 ALL NULL NULL NULL NULL 9 100.00 Using where Warnings: -Note 1003 select `test`.`t1`.`one` AS `one`,`test`.`t1`.`two` AS `two`,<in_optimizer>((`test`.`t1`.`one`,`test`.`t1`.`two`),<exists>(select `test`.`t2`.`one`,`test`.`t2`.`two` from `test`.`t2` where ((`test`.`t2`.`flag` = '0') and trigcond(((<cache>(`test`.`t1`.`one`) = `test`.`t2`.`one`) or isnull(`test`.`t2`.`one`))) and trigcond(((<cache>(`test`.`t1`.`two`) = `test`.`t2`.`two`) or isnull(`test`.`t2`.`two`)))) having (trigcond(<is_not_null_test>(`test`.`t2`.`one`)) and trigcond(<is_not_null_test>(`test`.`t2`.`two`))))) AS `test` from `test`.`t1` +Note 1003 select `test`.`t1`.`one` AS `one`,`test`.`t1`.`two` AS `two`,<expr_cache><`test`.`t1`.`one`,`test`.`t1`.`two`>(<in_optimizer>((`test`.`t1`.`one`,`test`.`t1`.`two`),<exists>(select `test`.`t2`.`one`,`test`.`t2`.`two` from `test`.`t2` where ((`test`.`t2`.`flag` = '0') and trigcond(((<cache>(`test`.`t1`.`one`) = `test`.`t2`.`one`) or isnull(`test`.`t2`.`one`))) and trigcond(((<cache>(`test`.`t1`.`two`) = `test`.`t2`.`two`) or isnull(`test`.`t2`.`two`)))) having (trigcond(<is_not_null_test>(`test`.`t2`.`one`)) and trigcond(<is_not_null_test>(`test`.`t2`.`two`)))))) AS `test` from `test`.`t1` explain extended SELECT one,two from t1 where ROW(one,two) IN (SELECT one,two FROM t2 WHERE flag = 'N'); id select_type table type possible_keys key key_len ref rows filtered Extra -1 PRIMARY t1 ALL NULL NULL NULL NULL 8 100.00 Using where -2 DEPENDENT SUBQUERY t2 ALL NULL NULL NULL NULL 9 100.00 Using where +1 PRIMARY t1 ALL NULL NULL NULL NULL 8 100.00 +1 PRIMARY t2 ALL NULL NULL NULL NULL 9 100.00 Using where; FirstMatch(t1) Warnings: -Note 1003 select `test`.`t1`.`one` AS `one`,`test`.`t1`.`two` AS `two` from `test`.`t1` where <in_optimizer>((`test`.`t1`.`one`,`test`.`t1`.`two`),<exists>(select `test`.`t2`.`one`,`test`.`t2`.`two` from `test`.`t2` where ((`test`.`t2`.`flag` = 'N') and (<cache>(`test`.`t1`.`one`) = `test`.`t2`.`one`) and (<cache>(`test`.`t1`.`two`) = `test`.`t2`.`two`)))) +Note 1003 select `test`.`t1`.`one` AS `one`,`test`.`t1`.`two` AS `two` from `test`.`t1` semi join (`test`.`t2`) where ((`test`.`t2`.`two` = `test`.`t1`.`two`) and (`test`.`t2`.`one` = `test`.`t1`.`one`) and (`test`.`t2`.`flag` = 'N')) explain extended SELECT one,two,ROW(one,two) IN (SELECT one,two FROM t2 WHERE flag = '0' group by one,two) as 'test' from t1; id select_type table type possible_keys key key_len ref rows filtered Extra 1 PRIMARY t1 ALL NULL NULL NULL NULL 8 100.00 2 DEPENDENT SUBQUERY t2 ALL NULL NULL NULL NULL 9 100.00 Using where; Using temporary Warnings: -Note 1003 select `test`.`t1`.`one` AS `one`,`test`.`t1`.`two` AS `two`,<in_optimizer>((`test`.`t1`.`one`,`test`.`t1`.`two`),<exists>(select `test`.`t2`.`one`,`test`.`t2`.`two` from `test`.`t2` where (`test`.`t2`.`flag` = '0') group by `test`.`t2`.`one`,`test`.`t2`.`two` having (trigcond(((<cache>(`test`.`t1`.`one`) = `test`.`t2`.`one`) or isnull(`test`.`t2`.`one`))) and trigcond(((<cache>(`test`.`t1`.`two`) = `test`.`t2`.`two`) or isnull(`test`.`t2`.`two`))) and trigcond(<is_not_null_test>(`test`.`t2`.`one`)) and trigcond(<is_not_null_test>(`test`.`t2`.`two`))))) AS `test` from `test`.`t1` +Note 1003 select `test`.`t1`.`one` AS `one`,`test`.`t1`.`two` AS `two`,<expr_cache><`test`.`t1`.`one`,`test`.`t1`.`two`>(<in_optimizer>((`test`.`t1`.`one`,`test`.`t1`.`two`),<exists>(select `test`.`t2`.`one`,`test`.`t2`.`two` from `test`.`t2` where (`test`.`t2`.`flag` = '0') group by `test`.`t2`.`one`,`test`.`t2`.`two` having (trigcond(((<cache>(`test`.`t1`.`one`) = `test`.`t2`.`one`) or isnull(`test`.`t2`.`one`))) and trigcond(((<cache>(`test`.`t1`.`two`) = `test`.`t2`.`two`) or isnull(`test`.`t2`.`two`))) and trigcond(<is_not_null_test>(`test`.`t2`.`one`)) and trigcond(<is_not_null_test>(`test`.`t2`.`two`)))))) AS `test` from `test`.`t1` DROP TABLE t1,t2; set @@optimizer_switch=@save_optimizer_switch; CREATE TABLE t1 (a char(5), b char(5)); @@ -4220,8 +4226,8 @@ CREATE INDEX I1 ON t1 (a); CREATE INDEX I2 ON t1 (b); EXPLAIN SELECT a,b FROM t1 WHERE b IN (SELECT a FROM t1); id select_type table type possible_keys key key_len ref rows Extra -1 PRIMARY t1 ALL NULL NULL NULL NULL 2 Using where -2 DEPENDENT SUBQUERY t1 index_subquery I1 I1 2 func 1 Using index; Using where +1 PRIMARY t1 ALL I2 NULL NULL NULL 2 Using where +1 PRIMARY t1 ref I1 I1 2 test.t1.b 1 Using where; Using index; FirstMatch(t1) SELECT a,b FROM t1 WHERE b IN (SELECT a FROM t1); a b CREATE TABLE t2 (a VARCHAR(1), b VARCHAR(10)); @@ -4230,15 +4236,15 @@ CREATE INDEX I1 ON t2 (a); CREATE INDEX I2 ON t2 (b); EXPLAIN SELECT a,b FROM t2 WHERE b IN (SELECT a FROM t2); id select_type table type possible_keys key key_len ref rows Extra -1 PRIMARY t2 ALL NULL NULL NULL NULL 2 Using where -2 DEPENDENT SUBQUERY t2 index_subquery I1 I1 4 func 1 Using index; Using where +1 PRIMARY t2 ALL I2 NULL NULL NULL 2 Using where +1 PRIMARY t2 ref I1 I1 4 test.t2.b 1 Using where; Using index; FirstMatch(t2) SELECT a,b FROM t2 WHERE b IN (SELECT a FROM t2); a b EXPLAIN SELECT a,b FROM t1 WHERE b IN (SELECT a FROM t1 WHERE LENGTH(a)<500); id select_type table type possible_keys key key_len ref rows Extra -1 PRIMARY t1 ALL NULL NULL NULL NULL 2 Using where -2 DEPENDENT SUBQUERY t1 index_subquery I1 I1 2 func 1 Using index; Using where +1 PRIMARY t1 ALL I2 NULL NULL NULL 2 Using where +1 PRIMARY t1 ref I1 I1 2 test.t1.b 1 Using where; Using index; FirstMatch(t1) SELECT a,b FROM t1 WHERE b IN (SELECT a FROM t1 WHERE LENGTH(a)<500); a b DROP TABLE t1,t2; @@ -4282,7 +4288,7 @@ id select_type table type possible_keys key key_len ref rows filtered Extra 2 DEPENDENT SUBQUERY t2 ALL NULL NULL NULL NULL 2 100.00 Using where Warnings: Note 1276 Field or reference 'test.t1.a' of SELECT #2 was resolved in SELECT #1 -Note 1003 select 2 AS `2` from `test`.`t1` where exists(select 1 from `test`.`t2` where (`test`.`t1`.`a` = `test`.`t2`.`a`)) +Note 1003 select 2 AS `2` from `test`.`t1` where <expr_cache><`test`.`t1`.`a`>(exists(select 1 from `test`.`t2` where (`test`.`t1`.`a` = `test`.`t2`.`a`))) EXPLAIN EXTENDED SELECT 2 FROM t1 WHERE EXISTS ((SELECT 1 FROM t2 WHERE t1.a=t2.a) UNION (SELECT 1 FROM t2 WHERE t1.a = t2.a)); @@ -4294,7 +4300,7 @@ NULL UNION RESULT <union2,3> ALL NULL NULL NULL NULL NULL NULL Warnings: Note 1276 Field or reference 'test.t1.a' of SELECT #2 was resolved in SELECT #1 Note 1276 Field or reference 'test.t1.a' of SELECT #3 was resolved in SELECT #1 -Note 1003 select 2 AS `2` from `test`.`t1` where exists((select 1 from `test`.`t2` where (`test`.`t1`.`a` = `test`.`t2`.`a`)) union (select 1 from `test`.`t2` where (`test`.`t1`.`a` = `test`.`t2`.`a`))) +Note 1003 select 2 AS `2` from `test`.`t1` where <expr_cache><`test`.`t1`.`a`>(exists((select 1 from `test`.`t2` where (`test`.`t1`.`a` = `test`.`t2`.`a`)) union (select 1 from `test`.`t2` where (`test`.`t1`.`a` = `test`.`t2`.`a`)))) DROP TABLE t1,t2; create table t1(f11 int, f12 int); create table t2(f21 int unsigned not null, f22 int, f23 varchar(10)); diff --git a/mysql-test/suite/pbxt/t/heap.test b/mysql-test/suite/pbxt/t/heap.test index 2d863827b2b..452bcb754d3 100644 --- a/mysql-test/suite/pbxt/t/heap.test +++ b/mysql-test/suite/pbxt/t/heap.test @@ -454,7 +454,7 @@ drop table t1; # create table t1 (c char(10)) engine=memory; create table t2 (c varchar(10)) engine=memory; ---replace_column 8 # +--replace_column 8 # 12 # show table status like 't_'; drop table t1, t2; diff --git a/mysql-test/suite/pbxt/t/join_nested.test b/mysql-test/suite/pbxt/t/join_nested.test index 3b72dc1e293..98ffcbc9a8a 100644 --- a/mysql-test/suite/pbxt/t/join_nested.test +++ b/mysql-test/suite/pbxt/t/join_nested.test @@ -587,6 +587,7 @@ SELECT t0.a,t0.b,t1.a,t1.b,t2.a,t2.b,t3.a,t3.b,t4.a,t4.b, --echo . costs. To combat the plan change it uses --sorted_result and --echo . and --replace tricks +INSERT INTO t1 VALUES (-1,133,0), (-2,12,0), (-3,11,0), (-5,15,0); CREATE INDEX idx_b ON t1(b); CREATE INDEX idx_a ON t0(a); @@ -614,7 +615,7 @@ SELECT t0.a,t0.b,t1.a,t1.b,t2.a,t2.b,t3.a,t3.b,t4.a,t4.b, ) ON (t3.b=2 OR t3.c IS NULL) AND (t6.b=2 OR t6.c IS NULL) AND (t1.b=t5.b OR t3.c IS NULL OR t6.c IS NULL or t8.c IS NULL) AND - (t1.a != 2), + (t1.a != 2) AND t1.a>0, t9 WHERE t0.a=1 AND t0.b=t1.b AND @@ -653,7 +654,7 @@ SELECT t0.a,t0.b,t1.a,t1.b,t2.a,t2.b,t3.a,t3.b,t4.a,t4.b, ) ON (t3.b=2 OR t3.c IS NULL) AND (t6.b=2 OR t6.c IS NULL) AND (t1.b=t5.b OR t3.c IS NULL OR t6.c IS NULL or t8.c IS NULL) AND - (t1.a != 2), + (t1.a != 2) AND t1.a>0, t9 WHERE t0.a=1 AND t0.b=t1.b AND diff --git a/mysql-test/suite/pbxt/t/key_diff.test b/mysql-test/suite/pbxt/t/key_diff.test index 5e9d7bac9cc..fc93c7418ab 100644 --- a/mysql-test/suite/pbxt/t/key_diff.test +++ b/mysql-test/suite/pbxt/t/key_diff.test @@ -13,11 +13,19 @@ CREATE TABLE t1 ( ); INSERT INTO t1 VALUES ('A','B'),('b','A'),('C','c'),('D','E'),('a','a'); +INSERT INTO t1 VALUES + ('AA','BB'),('bb','AA'),('CC','cc'),('DD','EE'),('aa','aa'); +INSERT INTO t1 VALUES + ('AAA','BBB'),('bbb','AAA'),('CCC','ccc'),('DDD','EEE'),('aaa','aaa'); -select * from t1,t1 as t2; -explain select t1.*,t2.* from t1,t1 as t2 where t1.A=t2.B; +select * from t1,t1 as t2 + where length(t1.A)=1 and length(t2.B)=1 ; +explain select t1.*,t2.* from t1,t1 as t2 + where t1.A=t2.B and length(t1.A)=1 and length(t2.B)=1; #select t1.*,t2.* from t1,t1 as t2 where t1.A=t2.B; -select t1.*,t2.* from t1,t1 as t2 where t1.A=t2.B order by binary t1.a,t2.a; +select t1.*,t2.* from t1,t1 as t2 + where t1.A=t2.B and length(t1.A)=1 and length(t2.B)=1 +order by binary t1.a,t2.a; select * from t1 where a='a'; drop table t1; diff --git a/mysql-test/suite/pbxt/t/limit.test b/mysql-test/suite/pbxt/t/limit.test index 0844af8705d..a65d5060e4d 100644 --- a/mysql-test/suite/pbxt/t/limit.test +++ b/mysql-test/suite/pbxt/t/limit.test @@ -15,7 +15,7 @@ update t1 set b=2 where b=1 limit 2; select * from t1 order by a; # PBXT: required for consistent result update t1 set b=4 where b=1; select * from t1 order by a; # PBXT: required for consistent result -delete from t1 where b=2 limit 1; +delete from t1 where b=2 order by a limit 1; select * from t1 order by a; # PBXT: required for consistent result delete from t1 limit 1; select * from t1 order by a; # PBXT: required for consistent result diff --git a/mysql-test/suite/pbxt/t/mysqlshow.test b/mysql-test/suite/pbxt/t/mysqlshow.test index 41505cc0b10..b54eeaeab34 100644 --- a/mysql-test/suite/pbxt/t/mysqlshow.test +++ b/mysql-test/suite/pbxt/t/mysqlshow.test @@ -30,7 +30,9 @@ DROP TABLE t1, t2; # # Bug #19147: mysqlshow INFORMATION_SCHEMA does not work # +--sorted_result --exec $MYSQL_SHOW information_schema +--sorted_result --exec $MYSQL_SHOW INFORMATION_SCHEMA --exec $MYSQL_SHOW inf_rmation_schema diff --git a/mysql-test/suite/pbxt/t/subselect.test b/mysql-test/suite/pbxt/t/subselect.test index 891e23d923e..651f47fcee1 100644 --- a/mysql-test/suite/pbxt/t/subselect.test +++ b/mysql-test/suite/pbxt/t/subselect.test @@ -278,8 +278,9 @@ SELECT (SELECT numeropost FROM t1 HAVING numreponse=a),numreponse FROM (SELECT * SELECT numreponse, (SELECT numeropost FROM t1 HAVING numreponse=a) FROM (SELECT * FROM t1) as a; SELECT numreponse, (SELECT numeropost FROM t1 HAVING numreponse=1) FROM (SELECT * FROM t1) as a; INSERT INTO t1 (numeropost,numreponse,pseudo) VALUES (1,1,'joce'),(1,2,'joce'),(1,3,'test'); --- error 1242 EXPLAIN EXTENDED SELECT numreponse FROM t1 WHERE numeropost='1' AND numreponse=(SELECT 1 FROM t1 WHERE numeropost='1'); +-- error 1242 +SELECT numreponse FROM t1 WHERE numeropost='1' AND numreponse=(SELECT 1 FROM t1 WHERE numeropost='1'); EXPLAIN EXTENDED SELECT MAX(numreponse) FROM t1 WHERE numeropost='1'; EXPLAIN EXTENDED SELECT numreponse FROM t1 WHERE numeropost='1' AND numreponse=(SELECT MAX(numreponse) FROM t1 WHERE numeropost='1'); drop table t1; @@ -928,7 +929,7 @@ drop table t1,t2; # # correct ALL optimisation # -create table t2 (a int, b int); +create table t2 (a int, b int not null); create table t3 (a int); insert into t3 values (6),(7),(3); select * from t3 where a >= all (select b from t2); diff --git a/mysql-test/suite/percona/disabled.def b/mysql-test/suite/percona/disabled.def index 1dafa2e2daa..b0dc0a2a84d 100644 --- a/mysql-test/suite/percona/disabled.def +++ b/mysql-test/suite/percona/disabled.def @@ -15,7 +15,8 @@ percona_sql_no_fcache: Feature not merged into MariaDB percona_status_wait_query_cache_mutex: Feature not merged into MariaDB percona_slave_innodb_stats: Feature not merged into MariaDB percona_query_response_time-replication: Feature not merged into MariaDB -percona_server_variables: Feature not merged into MariaDB +percona_server_variables_debug: Feature not merged into MariaDB +percona_server_variables_release: Feature not merged into MariaDB percona_slow_query_log-log_slow_verbosity: InnoDB filtering information not fully merged into MariaDB percona_innodb_buffer_pool_shm: Requires big shmmax not default on many systems percona_log_warnings_suppress: Feature not merged into MariaDB diff --git a/mysql-test/suite/percona/percona_server_variables_release.test b/mysql-test/suite/percona/percona_server_variables_release.test index f61446aeb02..b145843ab22 100644 --- a/mysql-test/suite/percona/percona_server_variables_release.test +++ b/mysql-test/suite/percona/percona_server_variables_release.test @@ -1,2 +1,2 @@ --source include/have_nodebug.inc ---source include/percona_server_variables.inc +--source percona_server_variables.inc diff --git a/mysql-test/suite/perfschema/include/cleanup_helper.inc b/mysql-test/suite/perfschema/include/cleanup_helper.inc index b7e37849f78..7ea97ba6e92 100644 --- a/mysql-test/suite/perfschema/include/cleanup_helper.inc +++ b/mysql-test/suite/perfschema/include/cleanup_helper.inc @@ -1,25 +1,32 @@ -# Copyright (C) 2009 Sun Microsystems, Inc +# Copyright (c) 2009, 2011, Oracle and/or its affiliates. All rights reserved. # -# 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 -# the Free Software Foundation; version 2 of the License. +# 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 the Free Software Foundation; version 2 of +# the License. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA # Tests for PERFORMANCE_SCHEMA update performance_schema.setup_instruments set enabled='YES'; +connection con1; disconnect con1; +--source include/wait_until_disconnected.inc +connection con2; disconnect con2; +--source include/wait_until_disconnected.inc +connection con3; disconnect con3; +--source include/wait_until_disconnected.inc connection default; diff --git a/mysql-test/suite/perfschema/include/privilege.inc b/mysql-test/suite/perfschema/include/privilege.inc index f29ef65f519..0de948d369b 100644 --- a/mysql-test/suite/perfschema/include/privilege.inc +++ b/mysql-test/suite/perfschema/include/privilege.inc @@ -1,4 +1,4 @@ -# Copyright (C) 2009 Sun Microsystems, Inc +# Copyright (c) 2009, 2010, Oracle and/or its affiliates. All rights reserved. # # 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 @@ -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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA # Tests for PERFORMANCE_SCHEMA diff --git a/mysql-test/suite/perfschema/include/start_server_common.inc b/mysql-test/suite/perfschema/include/start_server_common.inc index f6e549ea44e..e48bbba4d40 100644 --- a/mysql-test/suite/perfschema/include/start_server_common.inc +++ b/mysql-test/suite/perfschema/include/start_server_common.inc @@ -1,4 +1,4 @@ -# Copyright (C) 2008-2009 Sun Microsystems, Inc +# Copyright (c) 2008, 2010, Oracle and/or its affiliates. All rights reserved. # # 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 @@ -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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA # Tests for PERFORMANCE_SCHEMA diff --git a/mysql-test/suite/perfschema/include/upgrade_check.inc b/mysql-test/suite/perfschema/include/upgrade_check.inc index 3620e80002f..d8dc750bd39 100644 --- a/mysql-test/suite/perfschema/include/upgrade_check.inc +++ b/mysql-test/suite/perfschema/include/upgrade_check.inc @@ -1,4 +1,4 @@ -# Copyright (C) 2010 Oracle and/or its affiliates. All rights reserved. +# Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved. # # 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 @@ -11,14 +11,16 @@ # # 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA # Routine to be called by pfs_upgrade.test # $out_file and $err_file must be set within pfs_upgrade.test. # +--source include/count_sessions.inc --error 1 --exec $MYSQL_UPGRADE --skip-verbose --force > $out_file 2> $err_file +--source include/wait_until_count_sessions.inc # Verify that mysql_upgrade complained about the performance_schema --cat_file $err_file diff --git a/mysql-test/suite/perfschema/r/all_instances.result b/mysql-test/suite/perfschema/r/all_instances.result index 93386be7fa9..756b5207714 100644 --- a/mysql-test/suite/perfschema/r/all_instances.result +++ b/mysql-test/suite/perfschema/r/all_instances.result @@ -1,5 +1,5 @@ use performance_schema; -select name from mutex_instances group by name; +select name from mutex_instances where name not rlike '/(DEBUG_SYNC::mutex)$' group by name; name wait/synch/mutex/archive/archive_mutex wait/synch/mutex/aria/LOCK_trn_list @@ -32,7 +32,6 @@ wait/synch/mutex/mysys/THR_LOCK_open wait/synch/mutex/mysys/THR_LOCK_threads wait/synch/mutex/mysys/TMPDIR_mutex wait/synch/mutex/sql/Cversion_lock -wait/synch/mutex/sql/DEBUG_SYNC::mutex wait/synch/mutex/sql/Event_scheduler::LOCK_scheduler_state wait/synch/mutex/sql/hash_filo::lock wait/synch/mutex/sql/LOCK_active_mi @@ -100,7 +99,7 @@ wait/synch/rwlock/sql/MDL_context::LOCK_waiting_for wait/synch/rwlock/sql/MDL_lock::rwlock wait/synch/rwlock/sql/THR_LOCK_servers wait/synch/rwlock/sql/THR_LOCK_udf -select name from cond_instances group by name; +select name from cond_instances where name not rlike '/(DEBUG_SYNC::cond)$' group by name; name wait/synch/cond/aria/SERVICE_THREAD_CONTROL::COND_control wait/synch/cond/aria/TRANSLOG_BUFFER::prev_sent_to_disk_cond @@ -117,7 +116,6 @@ wait/synch/cond/sql/COND_rpl_status wait/synch/cond/sql/COND_server_started wait/synch/cond/sql/COND_thread_cache wait/synch/cond/sql/COND_thread_count -wait/synch/cond/sql/DEBUG_SYNC::cond wait/synch/cond/sql/Event_scheduler::COND_state wait/synch/cond/sql/Master_info::data_cond wait/synch/cond/sql/Master_info::start_cond diff --git a/mysql-test/suite/perfschema/r/pfs_upgrade.result b/mysql-test/suite/perfschema/r/pfs_upgrade.result index b2e415637d9..a7c47d8d64a 100644 --- a/mysql-test/suite/perfschema/r/pfs_upgrade.result +++ b/mysql-test/suite/perfschema/r/pfs_upgrade.result @@ -25,7 +25,7 @@ ERROR 1050 (42S01) at line 427: Table 'setup_consumers' already exists ERROR 1050 (42S01) at line 444: Table 'setup_instruments' already exists ERROR 1050 (42S01) at line 460: Table 'setup_timers' already exists ERROR 1050 (42S01) at line 477: Table 'threads' already exists -ERROR 1644 (HY000) at line 1122: Unexpected content found in the performance_schema database. +ERROR 1644 (HY000) at line 1125: Unexpected content found in the performance_schema database. FATAL ERROR: Upgrade failed show tables like "user_table"; Tables_in_performance_schema (user_table) @@ -55,7 +55,7 @@ ERROR 1050 (42S01) at line 427: Table 'setup_consumers' already exists ERROR 1050 (42S01) at line 444: Table 'setup_instruments' already exists ERROR 1050 (42S01) at line 460: Table 'setup_timers' already exists ERROR 1050 (42S01) at line 477: Table 'threads' already exists -ERROR 1644 (HY000) at line 1122: Unexpected content found in the performance_schema database. +ERROR 1644 (HY000) at line 1125: Unexpected content found in the performance_schema database. FATAL ERROR: Upgrade failed show tables like "user_view"; Tables_in_performance_schema (user_view) @@ -83,7 +83,7 @@ ERROR 1050 (42S01) at line 427: Table 'setup_consumers' already exists ERROR 1050 (42S01) at line 444: Table 'setup_instruments' already exists ERROR 1050 (42S01) at line 460: Table 'setup_timers' already exists ERROR 1050 (42S01) at line 477: Table 'threads' already exists -ERROR 1644 (HY000) at line 1122: Unexpected content found in the performance_schema database. +ERROR 1644 (HY000) at line 1125: Unexpected content found in the performance_schema database. FATAL ERROR: Upgrade failed select name from mysql.proc where db='performance_schema'; name @@ -111,7 +111,7 @@ ERROR 1050 (42S01) at line 427: Table 'setup_consumers' already exists ERROR 1050 (42S01) at line 444: Table 'setup_instruments' already exists ERROR 1050 (42S01) at line 460: Table 'setup_timers' already exists ERROR 1050 (42S01) at line 477: Table 'threads' already exists -ERROR 1644 (HY000) at line 1122: Unexpected content found in the performance_schema database. +ERROR 1644 (HY000) at line 1125: Unexpected content found in the performance_schema database. FATAL ERROR: Upgrade failed select name from mysql.proc where db='performance_schema'; name @@ -139,7 +139,7 @@ ERROR 1050 (42S01) at line 427: Table 'setup_consumers' already exists ERROR 1050 (42S01) at line 444: Table 'setup_instruments' already exists ERROR 1050 (42S01) at line 460: Table 'setup_timers' already exists ERROR 1050 (42S01) at line 477: Table 'threads' already exists -ERROR 1644 (HY000) at line 1122: Unexpected content found in the performance_schema database. +ERROR 1644 (HY000) at line 1125: Unexpected content found in the performance_schema database. FATAL ERROR: Upgrade failed select name from mysql.event where db='performance_schema'; name diff --git a/mysql-test/suite/perfschema/r/relaylog.result b/mysql-test/suite/perfschema/r/relaylog.result index fa5c386acbc..a1d10265f4d 100644 --- a/mysql-test/suite/perfschema/r/relaylog.result +++ b/mysql-test/suite/perfschema/r/relaylog.result @@ -52,11 +52,12 @@ select EVENT_NAME, if (count_star > 0, "MANY", "NONE") as COUNT_STAR from performance_schema.events_waits_summary_global_by_event_name -where event_name like "%MYSQL_BIN_LOG%" order by event_name; +where event_name like "%MYSQL_BIN_LOG%" + and event_name not like "%MYSQL_BIN_LOG::update_cond" + order by event_name; EVENT_NAME COUNT_STAR wait/synch/cond/sql/MYSQL_BIN_LOG::COND_prep_xids NONE wait/synch/cond/sql/MYSQL_BIN_LOG::COND_queue_busy NONE -wait/synch/cond/sql/MYSQL_BIN_LOG::update_cond MANY wait/synch/mutex/sql/MYSQL_BIN_LOG::LOCK_index MANY wait/synch/mutex/sql/MYSQL_BIN_LOG::LOCK_prep_xids NONE "Expect no slave relay log" @@ -69,10 +70,11 @@ EVENT_NAME COUNT_READ COUNT_WRITE SUM_NUMBER_OF_BYTES_READ SUM_NUMBER_OF_BYTES_W wait/io/file/sql/relaylog 0 0 0 0 wait/io/file/sql/relaylog_index 0 0 0 0 select * from performance_schema.events_waits_summary_global_by_event_name -where event_name like "%MYSQL_RELAY_LOG%" order by event_name; +where event_name like "%MYSQL_RELAY_LOG%" + and event_name not like "%MYSQL_RELAY_LOG::update_cond" + order by event_name; EVENT_NAME COUNT_STAR SUM_TIMER_WAIT MIN_TIMER_WAIT AVG_TIMER_WAIT MAX_TIMER_WAIT wait/synch/cond/sql/MYSQL_RELAY_LOG::COND_queue_busy 0 0 0 0 0 -wait/synch/cond/sql/MYSQL_RELAY_LOG::update_cond 0 0 0 0 0 wait/synch/mutex/sql/MYSQL_RELAY_LOG::LOCK_index 0 0 0 0 0 "============ Performance schema on slave ============" select * from performance_schema.file_summary_by_instance @@ -125,11 +127,12 @@ select EVENT_NAME, if (count_star > 0, "MANY", "NONE") as COUNT_STAR from performance_schema.events_waits_summary_global_by_event_name -where event_name like "%MYSQL_BIN_LOG%" order by event_name; +where event_name like "%MYSQL_BIN_LOG%" + and event_name not like "%MYSQL_BIN_LOG::update_cond" + order by event_name; EVENT_NAME COUNT_STAR wait/synch/cond/sql/MYSQL_BIN_LOG::COND_prep_xids NONE wait/synch/cond/sql/MYSQL_BIN_LOG::COND_queue_busy NONE -wait/synch/cond/sql/MYSQL_BIN_LOG::update_cond NONE wait/synch/mutex/sql/MYSQL_BIN_LOG::LOCK_index MANY wait/synch/mutex/sql/MYSQL_BIN_LOG::LOCK_prep_xids NONE "Expect a slave relay log" @@ -165,9 +168,10 @@ select EVENT_NAME, if (count_star > 0, "MANY", "NONE") as COUNT_STAR from performance_schema.events_waits_summary_global_by_event_name -where event_name like "%MYSQL_RELAY_LOG%" order by event_name; +where event_name like "%MYSQL_RELAY_LOG%" + and event_name not like "%MYSQL_RELAY_LOG::update_cond" + order by event_name; EVENT_NAME COUNT_STAR wait/synch/cond/sql/MYSQL_RELAY_LOG::COND_queue_busy NONE -wait/synch/cond/sql/MYSQL_RELAY_LOG::update_cond MANY wait/synch/mutex/sql/MYSQL_RELAY_LOG::LOCK_index MANY include/stop_slave.inc diff --git a/mysql-test/suite/perfschema/r/selects.result b/mysql-test/suite/perfschema/r/selects.result index a3d0931cf4c..4c59cc3338e 100644 --- a/mysql-test/suite/perfschema/r/selects.result +++ b/mysql-test/suite/perfschema/r/selects.result @@ -62,6 +62,7 @@ SELECT EVENT_ID FROM performance_schema.events_waits_current WHERE 1 = 2; CREATE EVENT t_ps_event ON SCHEDULE AT CURRENT_TIMESTAMP + INTERVAL 1 SECOND +ON COMPLETION PRESERVE DO INSERT INTO t_event SELECT DISTINCT EVENT_ID FROM performance_schema.events_waits_current @@ -106,5 +107,6 @@ EVENT_ID [EVENT_ID] DROP PROCEDURE t_ps_proc; DROP FUNCTION t_ps_func; +DROP EVENT t_ps_event; DROP TABLE t1; DROP TABLE t_event; diff --git a/mysql-test/suite/perfschema/t/all_instances.test b/mysql-test/suite/perfschema/t/all_instances.test index 801056d9d1c..76262e78255 100644 --- a/mysql-test/suite/perfschema/t/all_instances.test +++ b/mysql-test/suite/perfschema/t/all_instances.test @@ -16,8 +16,8 @@ use performance_schema; # "where" filters out instances that can be conditionally compiled out # -select name from mutex_instances group by name; +select name from mutex_instances where name not rlike '/(DEBUG_SYNC::mutex)$' group by name; select name from rwlock_instances group by name; -select name from cond_instances group by name; +select name from cond_instances where name not rlike '/(DEBUG_SYNC::cond)$' group by name; select event_name from file_instances group by event_name; select name from threads group by name; diff --git a/mysql-test/suite/perfschema/t/cnf_option.cnf b/mysql-test/suite/perfschema/t/cnf_option.cnf index 2892908fbb6..2be42791fb6 100644 --- a/mysql-test/suite/perfschema/t/cnf_option.cnf +++ b/mysql-test/suite/perfschema/t/cnf_option.cnf @@ -1,4 +1,4 @@ -# Copyright (C) 2009 Sun Microsystems, Inc +# Copyright (c) 2009, 2010 Sun Microsystems, Inc. # # 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 @@ -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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA # Tests for PERFORMANCE_SCHEMA # Check server start options, read from a .cnf file diff --git a/mysql-test/suite/perfschema/t/disabled.def b/mysql-test/suite/perfschema/t/disabled.def index 56bcf811ff6..c9f3b9a97e0 100644 --- a/mysql-test/suite/perfschema/t/disabled.def +++ b/mysql-test/suite/perfschema/t/disabled.def @@ -1,4 +1,4 @@ -# Copyright (C) 2009 Sun Microsystems, Inc +# Copyright (c) 2009, 2010 Sun Microsystems, Inc. # # 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 @@ -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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA ############################################################################## # diff --git a/mysql-test/suite/perfschema/t/relaylog.test b/mysql-test/suite/perfschema/t/relaylog.test index 68ba57dd502..e2798e9b707 100644 --- a/mysql-test/suite/perfschema/t/relaylog.test +++ b/mysql-test/suite/perfschema/t/relaylog.test @@ -41,6 +41,8 @@ drop table test.t1; # To ensure robustness: # - log file rotation is limited to file .000001 and .000002 # - statistics are normalized to "NONE" or "MANY" +# - statistics on ::update_cond conditions are not collected, +# since this is too much dependent on execution. # connection master; @@ -84,7 +86,9 @@ select EVENT_NAME, if (count_star > 0, "MANY", "NONE") as COUNT_STAR from performance_schema.events_waits_summary_global_by_event_name - where event_name like "%MYSQL_BIN_LOG%" order by event_name; + where event_name like "%MYSQL_BIN_LOG%" + and event_name not like "%MYSQL_BIN_LOG::update_cond" + order by event_name; -- echo "Expect no slave relay log" @@ -95,7 +99,9 @@ select * from performance_schema.file_summary_by_event_name where event_name like "%relaylog%" order by event_name; select * from performance_schema.events_waits_summary_global_by_event_name - where event_name like "%MYSQL_RELAY_LOG%" order by event_name; + where event_name like "%MYSQL_RELAY_LOG%" + and event_name not like "%MYSQL_RELAY_LOG::update_cond" + order by event_name; sync_slave_with_master; -- echo "============ Performance schema on slave ============" @@ -142,7 +148,9 @@ select EVENT_NAME, if (count_star > 0, "MANY", "NONE") as COUNT_STAR from performance_schema.events_waits_summary_global_by_event_name - where event_name like "%MYSQL_BIN_LOG%" order by event_name; + where event_name like "%MYSQL_BIN_LOG%" + and event_name not like "%MYSQL_BIN_LOG::update_cond" + order by event_name; -- echo "Expect a slave relay log" @@ -173,7 +181,9 @@ select EVENT_NAME, if (count_star > 0, "MANY", "NONE") as COUNT_STAR from performance_schema.events_waits_summary_global_by_event_name - where event_name like "%MYSQL_RELAY_LOG%" order by event_name; + where event_name like "%MYSQL_RELAY_LOG%" + and event_name not like "%MYSQL_RELAY_LOG::update_cond" + order by event_name; --source include/stop_slave.inc diff --git a/mysql-test/suite/perfschema/t/selects.test b/mysql-test/suite/perfschema/t/selects.test index e8fd0827c53..e4541d6c6fc 100644 --- a/mysql-test/suite/perfschema/t/selects.test +++ b/mysql-test/suite/perfschema/t/selects.test @@ -1,4 +1,4 @@ -# Copyright (c) 2008, 2010, Oracle and/or its affiliates. All rights reserved. +# Copyright (c) 2008, 2011, Oracle and/or its affiliates. All rights reserved. # # 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 @@ -97,6 +97,7 @@ SELECT EVENT_ID FROM performance_schema.events_waits_current WHERE 1 = 2; CREATE EVENT t_ps_event ON SCHEDULE AT CURRENT_TIMESTAMP + INTERVAL 1 SECOND +ON COMPLETION PRESERVE DO INSERT INTO t_event SELECT DISTINCT EVENT_ID FROM performance_schema.events_waits_current @@ -168,7 +169,7 @@ delimiter ;| SELECT t_ps_func(connection_id()) = @p_id; # We might reach this point too early which means the event scheduler has not -# execute our "t_ps_event". Therefore we poll till the record was inserted +# executed our "t_ps_event". Therefore we poll till the record was inserted # and run our test statement afterwards. let $wait_timeout= 20; let $wait_condition= SELECT COUNT(*) = 1 FROM t_event; @@ -179,5 +180,6 @@ SELECT * FROM t_event; # Clean up DROP PROCEDURE t_ps_proc; DROP FUNCTION t_ps_func; +DROP EVENT t_ps_event; DROP TABLE t1; DROP TABLE t_event; diff --git a/mysql-test/suite/perfschema_stress/README b/mysql-test/suite/perfschema_stress/README index 53f6f1daf35..d28287f9735 100644 --- a/mysql-test/suite/perfschema_stress/README +++ b/mysql-test/suite/perfschema_stress/README @@ -1,4 +1,4 @@ -# Copyright (C) 2009 Sun Microsystems, Inc +# Copyright (c) 2009, 2010 Sun Microsystems, Inc. # # 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 @@ -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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA WL#4818 - Stress testing of PERFORMANCE_SCHEMA diff --git a/mysql-test/suite/perfschema_stress/include/settings.inc b/mysql-test/suite/perfschema_stress/include/settings.inc index fb886a86df2..224cb54a8aa 100644 --- a/mysql-test/suite/perfschema_stress/include/settings.inc +++ b/mysql-test/suite/perfschema_stress/include/settings.inc @@ -1,4 +1,4 @@ -# Copyright (C) 2009 Sun Microsystems, Inc +# Copyright (c) 2009, 2010 Sun Microsystems, Inc. # # 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 @@ -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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA let $num_stress_rows= 5000; let $default_engine_type= myisam; diff --git a/mysql-test/suite/rpl/r/rpl_cant_read_event_incident.result b/mysql-test/suite/rpl/r/rpl_cant_read_event_incident.result new file mode 100644 index 00000000000..1bee6f2ec1a --- /dev/null +++ b/mysql-test/suite/rpl/r/rpl_cant_read_event_incident.result @@ -0,0 +1,19 @@ +include/master-slave.inc +[connection master] +call mtr.add_suppression("Error in Log_event::read_log_event()"); +include/rpl_stop_server.inc [server_number=1] +include/rpl_start_server.inc [server_number=1] +show binlog events; +ERROR HY000: Error when executing command SHOW BINLOG EVENTS: Wrong offset or I/O error +call mtr.add_suppression("Slave I/O: Got fatal error 1236 from master when reading data from binary log"); +stop slave; +reset slave; +start slave; +include/wait_for_slave_param.inc [Last_IO_Errno] +Last_IO_Errno = '1236' +Last_IO_Error = 'Got fatal error 1236 from master when reading data from binary log: 'binlog truncated in the middle of event; consider out of disk space on master; the last event was read from 'master-bin.000001' at 316, the last byte read was read from 'master-bin.000001' at 335.'' +reset master; +stop slave; +reset slave; +drop table t; +End of the tests diff --git a/mysql-test/suite/rpl/r/rpl_checksum.result b/mysql-test/suite/rpl/r/rpl_checksum.result index 7b483c7a9e9..b6b1210f05f 100644 --- a/mysql-test/suite/rpl/r/rpl_checksum.result +++ b/mysql-test/suite/rpl/r/rpl_checksum.result @@ -71,7 +71,7 @@ insert into t1 values (1) /* will not be applied on slave due to simulation */; set @@global.debug='d,simulate_slave_unaware_checksum'; start slave; include/wait_for_slave_io_error.inc [errno=1236] -Last_IO_Error = 'Got fatal error 1236 from master when reading data from binary log: 'Slave can not handle replication events with the checksum that master is configured to log'' +Last_IO_Error = 'Got fatal error 1236 from master when reading data from binary log: 'Slave can not handle replication events with the checksum that master is configured to log; the last event was read from 'master-bin.000010' at 245, the last byte read was read from 'master-bin.000010' at 245.'' select count(*) as zero from t1; zero 0 diff --git a/mysql-test/suite/rpl/r/rpl_insert_duplicate.result b/mysql-test/suite/rpl/r/rpl_insert_duplicate.result deleted file mode 100644 index 61ebbaaa5a9..00000000000 --- a/mysql-test/suite/rpl/r/rpl_insert_duplicate.result +++ /dev/null @@ -1,29 +0,0 @@ -include/master-slave.inc -[connection master] -CREATE TABLE t1 ( -a INT UNSIGNED NOT NULL PRIMARY KEY -) ENGINE=innodb; -CREATE TABLE t2 ( -a INT UNSIGNED -) ENGINE=innodb; -INSERT INTO t1 VALUES (1); -INSERT INTO t2 VALUES (1); -INSERT INTO t1 SELECT t2.a FROM t2 ORDER BY t2.a ON DUPLICATE KEY UPDATE t1.a= t1.a; -include/assert.inc [Sum of elements in t1 should be 1.] -include/assert.inc [In SBR or MIXED modes, the event in the binlog should be the same that was executed. In RBR mode, binlog position should stay unchanged.] -include/diff_tables.inc [master:test.t1 , slave:test.t1] -drop table t1, t2; -CREATE TABLE t1 ( -a INT UNSIGNED NOT NULL PRIMARY KEY -) ENGINE=myisam; -CREATE TABLE t2 ( -a INT UNSIGNED -) ENGINE=myisam; -INSERT INTO t1 VALUES (1); -INSERT INTO t2 VALUES (1); -INSERT INTO t1 SELECT t2.a FROM t2 ORDER BY t2.a ON DUPLICATE KEY UPDATE t1.a= t1.a; -include/assert.inc [Sum of elements in t1 should be 1.] -include/assert.inc [In SBR or MIXED modes, the event in the binlog should be the same that was executed. In RBR mode, binlog position should stay unchanged.] -include/diff_tables.inc [master:test.t1 , slave:test.t1] -drop table t1, t2; -include/rpl_end.inc diff --git a/mysql-test/suite/rpl/r/rpl_insert_ignore.result b/mysql-test/suite/rpl/r/rpl_insert_ignore.result index 04b64359126..1598b3c059f 100644 --- a/mysql-test/suite/rpl/r/rpl_insert_ignore.result +++ b/mysql-test/suite/rpl/r/rpl_insert_ignore.result @@ -26,6 +26,19 @@ include/diff_tables.inc [master:test.t1 , slave:test.t1] INSERT IGNORE INTO t1 SELECT NULL, t2.b FROM t2 ORDER BY t2.a; include/assert.inc [Count of elements in t1 should be 6.] include/assert.inc [In SBR or MIXED modes, the event in the binlog should be the same that was executed. In RBR mode, binlog position should stay unchanged.] +DROP TABLE t1; +DROP TABLE t2; +CREATE TABLE t1 ( +a INT UNSIGNED NOT NULL PRIMARY KEY +) ENGINE=innodb; +CREATE TABLE t2 ( +a INT UNSIGNED +) ENGINE=innodb; +INSERT INTO t1 VALUES (1); +INSERT INTO t2 VALUES (1); +INSERT INTO t1 SELECT t2.a FROM t2 ORDER BY t2.a ON DUPLICATE KEY UPDATE t1.a= t1.a; +include/assert.inc [Sum of elements in t1 should be 1.] +include/assert.inc [In SBR or MIXED modes, the event in the binlog should be the same that was executed. In RBR mode, binlog position should stay unchanged.] drop table t1, t2; CREATE TABLE t1 ( a int unsigned not null auto_increment primary key, @@ -52,5 +65,18 @@ include/diff_tables.inc [master:test.t1 , slave:test.t1] INSERT IGNORE INTO t1 SELECT NULL, t2.b FROM t2 ORDER BY t2.a; include/assert.inc [Count of elements in t1 should be 6.] include/assert.inc [In SBR or MIXED modes, the event in the binlog should be the same that was executed. In RBR mode, binlog position should stay unchanged.] +DROP TABLE t1; +DROP TABLE t2; +CREATE TABLE t1 ( +a INT UNSIGNED NOT NULL PRIMARY KEY +) ENGINE=myisam; +CREATE TABLE t2 ( +a INT UNSIGNED +) ENGINE=myisam; +INSERT INTO t1 VALUES (1); +INSERT INTO t2 VALUES (1); +INSERT INTO t1 SELECT t2.a FROM t2 ORDER BY t2.a ON DUPLICATE KEY UPDATE t1.a= t1.a; +include/assert.inc [Sum of elements in t1 should be 1.] +include/assert.inc [In SBR or MIXED modes, the event in the binlog should be the same that was executed. In RBR mode, binlog position should stay unchanged.] drop table t1, t2; include/rpl_end.inc diff --git a/mysql-test/suite/rpl/r/rpl_insert_select.result b/mysql-test/suite/rpl/r/rpl_insert_select.result deleted file mode 100644 index d98ae2538fa..00000000000 --- a/mysql-test/suite/rpl/r/rpl_insert_select.result +++ /dev/null @@ -1,14 +0,0 @@ -include/master-slave.inc -[connection master] -create table t1 (n int not null primary key); -insert into t1 values (1); -create table t2 (n int); -insert into t2 values (1); -insert ignore into t1 select * from t2; -insert into t1 values (2); -select * from t1; -n -1 -2 -drop table t1,t2; -include/rpl_end.inc diff --git a/mysql-test/suite/rpl/r/rpl_known_bugs_detection.result b/mysql-test/suite/rpl/r/rpl_known_bugs_detection.result index 43f5c082dea..7857ba95209 100644 --- a/mysql-test/suite/rpl/r/rpl_known_bugs_detection.result +++ b/mysql-test/suite/rpl/r/rpl_known_bugs_detection.result @@ -1,3 +1,4 @@ +call mtr.add_suppression("Unsafe statement written to the binary log using statement format"); include/master-slave.inc [connection master] CREATE TABLE t1 (a INT NOT NULL PRIMARY KEY AUTO_INCREMENT, b INT, @@ -42,12 +43,16 @@ SELECT t2.field_a, t2.field_b, t2.field_c FROM t2 ON DUPLICATE KEY UPDATE t1.field_3 = t2.field_c; +Warnings: +Note 1592 Unsafe statement written to the binary log using statement format since BINLOG_FORMAT = STATEMENT. INSERT... SELECT... ON DUPLICATE KEY UPDATE is unsafe because the order in which rows are retrieved by the SELECT determines which (if any) rows are updated. This order cannot be predicted and may differ on master and the slave. INSERT INTO t2 (field_a, field_b, field_c) VALUES (6, 'f', '6f'); INSERT INTO t1 (field_1, field_2, field_3) SELECT t2.field_a, t2.field_b, t2.field_c FROM t2 ON DUPLICATE KEY UPDATE t1.field_3 = t2.field_c; +Warnings: +Note 1592 Unsafe statement written to the binary log using statement format since BINLOG_FORMAT = STATEMENT. INSERT... SELECT... ON DUPLICATE KEY UPDATE is unsafe because the order in which rows are retrieved by the SELECT determines which (if any) rows are updated. This order cannot be predicted and may differ on master and the slave. SELECT * FROM t1; id field_1 field_2 field_3 1 1 a 1a diff --git a/mysql-test/suite/rpl/r/rpl_log_pos.result b/mysql-test/suite/rpl/r/rpl_log_pos.result index 58d0e202110..29b11f4b950 100644 --- a/mysql-test/suite/rpl/r/rpl_log_pos.result +++ b/mysql-test/suite/rpl/r/rpl_log_pos.result @@ -11,7 +11,7 @@ include/stop_slave.inc change master to master_log_pos=MASTER_LOG_POS; start slave; include/wait_for_slave_io_error.inc [errno=1236] -Last_IO_Error = 'Got fatal error 1236 from master when reading data from binary log: 'log event entry exceeded max_allowed_packet; Increase max_allowed_packet on master'' +Last_IO_Error = 'Got fatal error 1236 from master when reading data from binary log: 'log event entry exceeded max_allowed_packet; Increase max_allowed_packet on master; the last event was read from 'master-bin.000001' at 247, the last byte read was read from 'master-bin.000001' at 266.'' include/stop_slave_sql.inc show master status; File Position Binlog_Do_DB Binlog_Ignore_DB diff --git a/mysql-test/suite/rpl/r/rpl_manual_change_index_file.result b/mysql-test/suite/rpl/r/rpl_manual_change_index_file.result index 23238d9c97b..a1874ed1595 100644 --- a/mysql-test/suite/rpl/r/rpl_manual_change_index_file.result +++ b/mysql-test/suite/rpl/r/rpl_manual_change_index_file.result @@ -5,7 +5,7 @@ CREATE TABLE t1(c1 INT); FLUSH LOGS; call mtr.add_suppression('Got fatal error 1236 from master when reading data from binary log: .*could not find next log'); include/wait_for_slave_io_error.inc [errno=1236] -Last_IO_Error = 'Got fatal error 1236 from master when reading data from binary log: 'could not find next log'' +Last_IO_Error = 'Got fatal error 1236 from master when reading data from binary log: 'could not find next log; the last event was read from 'master-bin.000002' at 375, the last byte read was read from 'master-bin.000002' at 375.'' CREATE TABLE t2(c1 INT); FLUSH LOGS; CREATE TABLE t3(c1 INT); diff --git a/mysql-test/suite/rpl/r/rpl_packet.result b/mysql-test/suite/rpl/r/rpl_packet.result index 6190f458367..be2f551f9c2 100644 --- a/mysql-test/suite/rpl/r/rpl_packet.result +++ b/mysql-test/suite/rpl/r/rpl_packet.result @@ -37,7 +37,7 @@ DROP TABLE t1; CREATE TABLE t1 (f1 int PRIMARY KEY, f2 LONGTEXT, f3 LONGTEXT) ENGINE=MyISAM; INSERT INTO t1(f1, f2, f3) VALUES(1, REPEAT('a', @@global.max_allowed_packet), REPEAT('b', @@global.max_allowed_packet)); include/wait_for_slave_io_error.inc [errno=1236] -Last_IO_Error = 'Got fatal error 1236 from master when reading data from binary log: 'log event entry exceeded max_allowed_packet; Increase max_allowed_packet on master'' +Last_IO_Error = 'Got fatal error 1236 from master when reading data from binary log: 'log event entry exceeded max_allowed_packet; Increase max_allowed_packet on master; the last event was read from 'master-bin.000001' at 601, the last byte read was read from 'master-bin.000001' at 620.'' STOP SLAVE; RESET SLAVE; RESET MASTER; diff --git a/mysql-test/suite/rpl/r/rpl_row_annotate_do.result b/mysql-test/suite/rpl/r/rpl_row_annotate_do.result index 0ece93e7aa5..a7dc2a569a1 100644 --- a/mysql-test/suite/rpl/r/rpl_row_annotate_do.result +++ b/mysql-test/suite/rpl/r/rpl_row_annotate_do.result @@ -127,7 +127,7 @@ slave-bin.000001 # Rotate 2 # slave-bin.000002;pos=4 ######################################################################## # INSERTs DELAYED ON MASTERs ######################################################################## -SET SESSION binlog_annotate_rows_events = ON; +SET SESSION binlog_annotate_row_events = ON; INSERT DELAYED INTO test1.t4 VALUES (1,1); FLUSH TABLES; SELECT * FROM test1.t4 ORDER BY a; diff --git a/mysql-test/suite/rpl/r/rpl_row_annotate_dont.result b/mysql-test/suite/rpl/r/rpl_row_annotate_dont.result index 8463256d5db..2a3b5b1870e 100644 --- a/mysql-test/suite/rpl/r/rpl_row_annotate_dont.result +++ b/mysql-test/suite/rpl/r/rpl_row_annotate_dont.result @@ -109,7 +109,7 @@ slave-bin.000001 # Rotate 2 # slave-bin.000002;pos=4 ######################################################################## # INSERTs DELAYED ON MASTERs ######################################################################## -SET SESSION binlog_annotate_rows_events = ON; +SET SESSION binlog_annotate_row_events = ON; INSERT DELAYED INTO test1.t4 VALUES (1,1); FLUSH TABLES; SELECT * FROM test1.t4 ORDER BY a; diff --git a/mysql-test/suite/rpl/r/rpl_row_corruption.result b/mysql-test/suite/rpl/r/rpl_row_corruption.result new file mode 100644 index 00000000000..7fd47a20f03 --- /dev/null +++ b/mysql-test/suite/rpl/r/rpl_row_corruption.result @@ -0,0 +1,49 @@ +include/master-slave.inc +[connection master] +CREATE TABLE t1_11753004 (c1 INT); +CREATE TABLE t2_11753004 (c1 INT); +INSERT INTO t1_11753004 VALUES (1); +INSERT INTO t2_11753004 VALUES (2); +call mtr.add_suppression(".*Found table map event mapping table id 0 which was already mapped but with different settings.*"); +include/stop_slave.inc +SET @save_debug= @@global.debug; +SET GLOBAL debug="+d,inject_tblmap_same_id_maps_diff_table"; +include/start_slave.inc +UPDATE t1_11753004, t2_11753004 SET t1_11753004.c1=3, t2_11753004.c1=4 WHERE t1_11753004.c1=1 OR t2_11753004.c1=2; +include/wait_for_slave_sql_error.inc [errno=1593 ] +include/stop_slave.inc +SET GLOBAL debug="-d,inject_tblmap_same_id_maps_diff_table"; +include/start_slave.inc +include/rpl_reset.inc +DROP TABLE t1_11753004, t2_11753004; +include/stop_slave.inc +SET GLOBAL debug="+d,inject_tblmap_same_id_maps_diff_table"; +include/start_slave.inc +include/rpl_reset.inc +CREATE TABLE t1_11753004 (c1 INT); +CREATE TABLE t2_11753004_ign (c1 INT); +INSERT INTO t1_11753004 VALUES (1); +INSERT INTO t2_11753004_ign VALUES (2); +UPDATE t1_11753004, t2_11753004_ign SET t1_11753004.c1=3, t2_11753004_ign.c1=4 WHERE t1_11753004.c1=1 OR t2_11753004_ign.c1=2; +CREATE TABLE t1 (c1 INT); +CREATE TABLE t2 (c1 INT); +INSERT INTO t1 VALUES (1); +INSERT INTO t2 VALUES (1); +BINLOG ' +SOgWTg8BAAAAbgAAAHIAAAAAAAQANS42LjMtbTUtZGVidWctbG9nAAAAAAAAAAAAAAAAAAAAAAAA +AAAAAAAAAAAAAAAAAABI6BZOEzgNAAgAEgAEBAQEEgAAVgAEGggAAAAICAgCAAAAAAVAYI8= +'/*!*/; +SET GLOBAL debug="+d,inject_tblmap_same_id_maps_diff_table"; +BINLOG ' +SOgWThMBAAAAKQAAAAYDAAAAAEIAAAAAAAEABHRlc3QAAnQxAAEDAAE= +SOgWThMBAAAAKQAAAC8DAAAAAEMAAAAAAAEABHRlc3QAAnQyAAEDAAE= +SOgWThgBAAAAKAAAAFcDAAAAAEIAAAAAAAAAAf///gEAAAD+AwAAAA== +SOgWThgBAAAAKAAAAH8DAAAAAEMAAAAAAAEAAf///gEAAAD+BAAAAA== +'/*!*/; +ERROR HY000: Fatal error: Found table map event mapping table id 0 which was already mapped but with different settings. +DROP TABLE t1,t2; +SET GLOBAL debug="-d,inject_tblmap_same_id_maps_diff_table"; +DROP TABLE t1_11753004; +DROP TABLE t2_11753004_ign; +SET GLOBAL debug= @save_debug; +include/rpl_end.inc diff --git a/mysql-test/suite/rpl/r/rpl_row_reset_slave.result b/mysql-test/suite/rpl/r/rpl_row_reset_slave.result index 7dc94bab481..41fe0b1a9f3 100644 --- a/mysql-test/suite/rpl/r/rpl_row_reset_slave.result +++ b/mysql-test/suite/rpl/r/rpl_row_reset_slave.result @@ -41,4 +41,12 @@ include/stop_slave_sql.inc reset slave; include/check_slave_no_error.inc change master to master_user='root'; +reset slave; +include/start_slave.inc +include/stop_slave.inc +reset slave all; +start slave; +ERROR HY000: The server is not configured as slave; fix in config file or with CHANGE MASTER TO +CHANGE MASTER TO MASTER_HOST= 'MASTER_HOST', MASTER_USER= 'MASTER_USER', MASTER_PORT= MASTER_PORT; +include/start_slave.inc include/rpl_end.inc diff --git a/mysql-test/suite/rpl/r/rpl_stm_000001.result b/mysql-test/suite/rpl/r/rpl_stm_000001.result index eb421d1adc4..80a3240021a 100644 --- a/mysql-test/suite/rpl/r/rpl_stm_000001.result +++ b/mysql-test/suite/rpl/r/rpl_stm_000001.result @@ -49,7 +49,7 @@ select (@id := id) - id from t2; kill @id; drop table t2; Got one of the listed errors -include/wait_for_slave_sql_error_and_skip.inc [errno=1053] +include/wait_for_slave_sql_error_and_skip.inc [errno=1927] select count(*) from t1; count(*) 5000 diff --git a/mysql-test/suite/rpl/r/rpl_stm_reset_slave.result b/mysql-test/suite/rpl/r/rpl_stm_reset_slave.result index aa8bc63a432..b1473c937a1 100644 --- a/mysql-test/suite/rpl/r/rpl_stm_reset_slave.result +++ b/mysql-test/suite/rpl/r/rpl_stm_reset_slave.result @@ -41,4 +41,12 @@ include/stop_slave_sql.inc reset slave; include/check_slave_no_error.inc change master to master_user='root'; +reset slave; +include/start_slave.inc +include/stop_slave.inc +reset slave all; +start slave; +ERROR HY000: The server is not configured as slave; fix in config file or with CHANGE MASTER TO +CHANGE MASTER TO MASTER_HOST= 'MASTER_HOST', MASTER_USER= 'MASTER_USER', MASTER_PORT= MASTER_PORT; +include/start_slave.inc include/rpl_end.inc diff --git a/mysql-test/suite/rpl/t/rpl_cant_read_event_incident.test b/mysql-test/suite/rpl/t/rpl_cant_read_event_incident.test new file mode 100644 index 00000000000..71445be55e6 --- /dev/null +++ b/mysql-test/suite/rpl/t/rpl_cant_read_event_incident.test @@ -0,0 +1,64 @@ +# +# Bug#11747416 : 32228 A disk full makes binary log corrupt. +# +# +# The test demonstrates reading from binlog error propagation to slave +# and reporting there. +# Conditions for the bug include a crash at time of the last event to +# the binlog was written partly. With the fixes the event is not sent out +# any longer, but rather the dump thread sends out a sound error message. +# +# Crash is not simulated. A binlog with partly written event in its end is installed +# and replication is started from it. +# + +--source include/master-slave.inc +--source include/have_binlog_format_mixed.inc + +call mtr.add_suppression("Error in Log_event::read_log_event()"); + +--connection master +--let $datadir= `SELECT @@datadir` + +--let $rpl_server_number= 1 +--source include/rpl_stop_server.inc + +--remove_file $datadir/master-bin.000001 +--copy_file $MYSQL_TEST_DIR/std_data/bug11747416_32228_binlog.000001 $datadir/master-bin.000001 + +--let $rpl_server_number= 1 +--source include/rpl_start_server.inc + +--source include/wait_until_connected_again.inc + +# evidence of the partial binlog +--error ER_ERROR_WHEN_EXECUTING_COMMAND +show binlog events; + +--connection slave +call mtr.add_suppression("Slave I/O: Got fatal error 1236 from master when reading data from binary log"); +stop slave; +reset slave; +start slave; + +# ER_MASTER_FATAL_ERROR_READING_BINLOG 1236 +--let $slave_param=Last_IO_Errno +--let $slave_param_value=1236 +--source include/wait_for_slave_param.inc + +--let $status_items= Last_IO_Errno, Last_IO_Error +--source include/show_slave_status.inc + +# +# Cleanup +# + +--connection master +reset master; + +--connection slave +stop slave; +reset slave; +drop table t; # table was created from binlog. it does not exist on master. + +--echo End of the tests diff --git a/mysql-test/suite/rpl/t/rpl_insert_duplicate.test b/mysql-test/suite/rpl/t/rpl_insert_duplicate.test deleted file mode 100644 index 7dd38a696ae..00000000000 --- a/mysql-test/suite/rpl/t/rpl_insert_duplicate.test +++ /dev/null @@ -1,14 +0,0 @@ -######################################### -# Wrapper for rpl_insert_duplicate.test # -######################################### --- source include/master-slave.inc --- source include/have_innodb.inc -#-- source include/have_binlog_format_mixed_or_statement.inc - -let $engine_type=innodb; --- source extra/rpl_tests/rpl_insert_duplicate.test - -let $engine_type=myisam; --- source extra/rpl_tests/rpl_insert_duplicate.test - ---source include/rpl_end.inc diff --git a/mysql-test/suite/rpl/t/rpl_insert_select.test b/mysql-test/suite/rpl/t/rpl_insert_select.test deleted file mode 100644 index 23bc7ecd167..00000000000 --- a/mysql-test/suite/rpl/t/rpl_insert_select.test +++ /dev/null @@ -1,20 +0,0 @@ -# Testcase for BUG#10456 - INSERT INTO ... SELECT violating a primary key -# breaks replication - --- source include/master-slave.inc -connection master; - -create table t1 (n int not null primary key); -insert into t1 values (1); -create table t2 (n int); -insert into t2 values (1); -insert ignore into t1 select * from t2; -insert into t1 values (2); -sync_slave_with_master; -connection slave; -select * from t1; - -connection master; -drop table t1,t2; -sync_slave_with_master; ---source include/rpl_end.inc diff --git a/mysql-test/suite/rpl/t/rpl_known_bugs_detection.test b/mysql-test/suite/rpl/t/rpl_known_bugs_detection.test index db182d477a1..87c492e7f22 100644 --- a/mysql-test/suite/rpl/t/rpl_known_bugs_detection.test +++ b/mysql-test/suite/rpl/t/rpl_known_bugs_detection.test @@ -3,14 +3,15 @@ # (assuming the bug is fixed in the slave, slave cannot of course # imitate the bug, so it has to stop). +call mtr.add_suppression("Unsafe statement written to the binary log using statement format"); + source include/have_debug.inc; # because of pretend_version_50034_in_binlog the test can't run with checksum source include/have_binlog_checksum_off.inc; source include/master-slave.inc; # Currently only statement-based-specific bugs are here --- source include/have_binlog_format_mixed_or_statement.inc - +-- source include/have_binlog_format_statement.inc # # This is to test that slave properly detects if diff --git a/mysql-test/suite/rpl/t/rpl_row_annotate_do-slave.opt b/mysql-test/suite/rpl/t/rpl_row_annotate_do-slave.opt index aa3af621897..18de9bd1e33 100644 --- a/mysql-test/suite/rpl/t/rpl_row_annotate_do-slave.opt +++ b/mysql-test/suite/rpl/t/rpl_row_annotate_do-slave.opt @@ -1 +1 @@ ---log-slave-updates --replicate-annotate-rows-events --replicate-ignore-table=test1.xt1 --replicate-ignore-table=test1.xt2
\ No newline at end of file +--log-slave-updates --replicate-annotate-row-events --replicate-ignore-table=test1.xt1 --replicate-ignore-table=test1.xt2 diff --git a/mysql-test/suite/rpl/t/rpl_row_annotate_do.test b/mysql-test/suite/rpl/t/rpl_row_annotate_do.test index b61ce0ab6d8..4114f90b90b 100644 --- a/mysql-test/suite/rpl/t/rpl_row_annotate_do.test +++ b/mysql-test/suite/rpl/t/rpl_row_annotate_do.test @@ -1,7 +1,7 @@ ############################################################################### # WL47: Store in binlog text of statements that caused RBR events # Wrapper for extra/rpl/rpl_row_annotate.test. -# Intended to test that if the --replicate-annotate-rows-events option +# Intended to test that if the --replicate-annotate-row-events option # is switched on on slave then Annotate_events: # - are reproduced on slave # - are reproduced only once for "multi-table-maps" rbr queries diff --git a/mysql-test/suite/rpl/t/rpl_row_annotate_dont.test b/mysql-test/suite/rpl/t/rpl_row_annotate_dont.test index 56765c591aa..ef746e76b4d 100644 --- a/mysql-test/suite/rpl/t/rpl_row_annotate_dont.test +++ b/mysql-test/suite/rpl/t/rpl_row_annotate_dont.test @@ -1,7 +1,7 @@ ############################################################################### # WL47: Store in binlog text of statements that caused RBR events # Wrapper for extra/rpl/rpl_row_annotate.test. -# Intended to test that if the --replicate-annotate-rows-events option +# Intended to test that if the --replicate-annotate-row-events option # is switched off on slave then Annotate_events are not reproduced. ############################################################################### diff --git a/mysql-test/suite/rpl/t/rpl_row_corruption-slave.opt b/mysql-test/suite/rpl/t/rpl_row_corruption-slave.opt new file mode 100644 index 00000000000..da199510eb3 --- /dev/null +++ b/mysql-test/suite/rpl/t/rpl_row_corruption-slave.opt @@ -0,0 +1 @@ +--replicate-ignore-table=test.t2_11753004_ign diff --git a/mysql-test/suite/rpl/t/rpl_row_corruption.test b/mysql-test/suite/rpl/t/rpl_row_corruption.test new file mode 100644 index 00000000000..a7650c615a3 --- /dev/null +++ b/mysql-test/suite/rpl/t/rpl_row_corruption.test @@ -0,0 +1,115 @@ +# +--source include/master-slave.inc +--source include/have_debug.inc +--source include/have_binlog_format_row.inc + +# BUG#11753004: 44360: REPLICATION FAILED + +## assert that we get an error when checking the +## identifiers at the slave (instead of a crash or +## different table being updated) + +--let $t1= t1_11753004 +--let $t2= t2_11753004 +--let $t2_ign= t2_11753004_ign + +## test #1: assert that we get an error raised when multiple +## tables in the same RBR statement are mapped with the +## same identifier + +--eval CREATE TABLE $t1 (c1 INT) +--eval CREATE TABLE $t2 (c1 INT) +--eval INSERT INTO $t1 VALUES (1) +--eval INSERT INTO $t2 VALUES (2) + +--sync_slave_with_master +call mtr.add_suppression(".*Found table map event mapping table id 0 which was already mapped but with different settings.*"); + +# stop the slave and inject corruption +--source include/stop_slave.inc +SET @save_debug= @@global.debug; +SET GLOBAL debug="+d,inject_tblmap_same_id_maps_diff_table"; +--source include/start_slave.inc +--connection master +# both tables get mapped to 0 (in a way, simulating scenario +# originated by BUG#56226) +--eval UPDATE $t1, $t2 SET $t1.c1=3, $t2.c1=4 WHERE $t1.c1=1 OR $t2.c1=2 +--connection slave + +# wait for error 1593 (ER_SLAVE_FATAL_ERROR) +--let $slave_sql_errno=1593 +--source include/wait_for_slave_sql_error.inc +--source include/stop_slave.inc + +# clean up +SET GLOBAL debug="-d,inject_tblmap_same_id_maps_diff_table"; +--source include/start_slave.inc +--connection master +--source include/rpl_reset.inc +--eval DROP TABLE $t1, $t2 +--sync_slave_with_master + +## test #2: assert that ignored tables that may have been mapped +## with the same identifier are skipped, thus no error +## is raised. + +--connection slave +--source include/stop_slave.inc +SET GLOBAL debug="+d,inject_tblmap_same_id_maps_diff_table"; +--source include/start_slave.inc +--source include/rpl_reset.inc +--connection master +--eval CREATE TABLE $t1 (c1 INT) +--eval CREATE TABLE $t2_ign (c1 INT) +--eval INSERT INTO $t1 VALUES (1) +--eval INSERT INTO $t2_ign VALUES (2) +--eval UPDATE $t1, $t2_ign SET $t1.c1=3, $t2_ign.c1=4 WHERE $t1.c1=1 OR $t2_ign.c1=2 + +# must not raise error as second table is filtered +--sync_slave_with_master + + +## test #3: check that BINLOG statements will also raise an +## error if containing table map events mapping different +## tables to same table identifier. + +CREATE TABLE t1 (c1 INT); +CREATE TABLE t2 (c1 INT); + +INSERT INTO t1 VALUES (1); +INSERT INTO t2 VALUES (1); + +# FD event +BINLOG ' +SOgWTg8BAAAAbgAAAHIAAAAAAAQANS42LjMtbTUtZGVidWctbG9nAAAAAAAAAAAAAAAAAAAAAAAA +AAAAAAAAAAAAAAAAAABI6BZOEzgNAAgAEgAEBAQEEgAAVgAEGggAAAAICAgCAAAAAAVAYI8= +'/*!*/; + +#110708 12:21:44 server id 1 end_log_pos 774 Table_map: `test`.`t1` mapped to number 66 +# at 774 +#110708 12:21:44 server id 1 end_log_pos 815 Table_map: `test`.`t2` mapped to number 67 +# at 815 +#110708 12:21:44 server id 1 end_log_pos 855 Update_rows: table id 66 +# at 855 +#110708 12:21:44 server id 1 end_log_pos 895 Update_rows: table id 67 flags: STMT_END_F +SET GLOBAL debug="+d,inject_tblmap_same_id_maps_diff_table"; +--error ER_SLAVE_FATAL_ERROR +BINLOG ' +SOgWThMBAAAAKQAAAAYDAAAAAEIAAAAAAAEABHRlc3QAAnQxAAEDAAE= +SOgWThMBAAAAKQAAAC8DAAAAAEMAAAAAAAEABHRlc3QAAnQyAAEDAAE= +SOgWThgBAAAAKAAAAFcDAAAAAEIAAAAAAAAAAf///gEAAAD+AwAAAA== +SOgWThgBAAAAKAAAAH8DAAAAAEMAAAAAAAEAAf///gEAAAD+BAAAAA== +'/*!*/; + + +# clean up +DROP TABLE t1,t2; +--connection slave +SET GLOBAL debug="-d,inject_tblmap_same_id_maps_diff_table"; +--connection master +--eval DROP TABLE $t1 +--eval DROP TABLE $t2_ign +--sync_slave_with_master +SET GLOBAL debug= @save_debug; + +--source include/rpl_end.inc diff --git a/mysql-test/suite/rpl/t/rpl_stm_000001.test b/mysql-test/suite/rpl/t/rpl_stm_000001.test index 268a10ad1fa..16f89123d75 100644 --- a/mysql-test/suite/rpl/t/rpl_stm_000001.test +++ b/mysql-test/suite/rpl/t/rpl_stm_000001.test @@ -96,14 +96,15 @@ drop table t2; connection master; # The get_lock function causes warning for unsafe statement. --disable_warnings ---error 1317,2013 +# 2013 = CR_SERVER_LOST +--error ER_QUERY_INTERRUPTED,ER_CONNECTION_KILLED,2013 reap; --enable_warnings connection slave; # The SQL slave thread should now have stopped because the query was killed on # the master (so it has a non-zero error code in the binlog). -# 1053 = ER_SERVER_SHUTDOWN ---let $slave_sql_errno= 1053 +# 1927 = ER_CONNECTION_KILLED +--let $slave_sql_errno= 1927 --source include/wait_for_slave_sql_error_and_skip.inc select count(*) from t1; diff --git a/mysql-test/suite/stress/t/wrapper.test b/mysql-test/suite/stress/t/wrapper.test new file mode 100644 index 00000000000..4d2dd808a4c --- /dev/null +++ b/mysql-test/suite/stress/t/wrapper.test @@ -0,0 +1,29 @@ +# +# This is a wrapper "pseudo" test for mtr --stress execution. +# It should not be run directly (will be skipped) +# Do not create a result file! +# + +if (!$MST_OPTIONS) { + skip Only to be run with mtr --stress; +} + +# echo Running MST with options $MST_OPTIONS; + +perl; + my ($mtest)= split " ", $ENV{MYSQL_TEST}; + open(FILE, ">", "$ENV{MYSQL_TMP_DIR}/mtest.inc") or die; + print FILE "let \$MYSQLTEST_BIN= $mtest;\n"; + close FILE; +EOF + +--source $MYSQL_TMP_DIR/mtest.inc +--remove_file $MYSQL_TMP_DIR/mtest.inc + +exec perl mysql-stress-test.pl --mysqltest=$MYSQLTEST_BIN + --server-port=$MASTER_MYPORT --server-socket=$MASTER_MYSOCK + --server-user=root --cleanup + --server-logs-dir=$MYSQLTEST_VARDIR/log + --stress-basedir=$MYSQLTEST_VARDIR + $MST_OPTIONS +; diff --git a/mysql-test/suite/sys_vars/r/aria_checkpoint_log_activity_basic.result b/mysql-test/suite/sys_vars/r/aria_checkpoint_log_activity_basic.result new file mode 100644 index 00000000000..8a0247471ff --- /dev/null +++ b/mysql-test/suite/sys_vars/r/aria_checkpoint_log_activity_basic.result @@ -0,0 +1,43 @@ +SET @start_global_value = @@global.aria_checkpoint_log_activity; +select @@global.aria_checkpoint_log_activity; +@@global.aria_checkpoint_log_activity +1048576 +select @@session.aria_checkpoint_log_activity; +ERROR HY000: Variable 'aria_checkpoint_log_activity' is a GLOBAL variable +show global variables like 'aria_checkpoint_log_activity'; +Variable_name Value +aria_checkpoint_log_activity 1048576 +show session variables like 'aria_checkpoint_log_activity'; +Variable_name Value +aria_checkpoint_log_activity 1048576 +select * from information_schema.global_variables where variable_name='aria_checkpoint_log_activity'; +VARIABLE_NAME VARIABLE_VALUE +ARIA_CHECKPOINT_LOG_ACTIVITY 1048576 +select * from information_schema.session_variables where variable_name='aria_checkpoint_log_activity'; +VARIABLE_NAME VARIABLE_VALUE +ARIA_CHECKPOINT_LOG_ACTIVITY 1048576 +set global aria_checkpoint_log_activity=1; +select @@global.aria_checkpoint_log_activity; +@@global.aria_checkpoint_log_activity +1 +set session aria_checkpoint_log_activity=1; +ERROR HY000: Variable 'aria_checkpoint_log_activity' is a GLOBAL variable and should be set with SET GLOBAL +set global aria_checkpoint_log_activity=1.1; +ERROR 42000: Incorrect argument type to variable 'aria_checkpoint_log_activity' +set global aria_checkpoint_log_activity=1e1; +ERROR 42000: Incorrect argument type to variable 'aria_checkpoint_log_activity' +set global aria_checkpoint_log_activity="foo"; +ERROR 42000: Incorrect argument type to variable 'aria_checkpoint_log_activity' +set global aria_checkpoint_log_activity=0; +select @@global.aria_checkpoint_log_activity; +@@global.aria_checkpoint_log_activity +0 +set global aria_checkpoint_log_activity=cast(-1 as unsigned int); +Warnings: +Warning 1105 Cast to unsigned converted negative integer to it's positive complement +Warning 1105 Cast to unsigned converted negative integer to it's positive complement +Warning 1292 Truncated incorrect aria_checkpoint_log_activity value: '18446744073709551615' +select @@global.aria_checkpoint_log_activity; +@@global.aria_checkpoint_log_activity +4294967295 +SET @@global.aria_checkpoint_log_activity = @start_global_value; diff --git a/mysql-test/suite/sys_vars/r/binlog_annotate_row_events_basic.result b/mysql-test/suite/sys_vars/r/binlog_annotate_row_events_basic.result new file mode 100644 index 00000000000..6fef4fc1d32 --- /dev/null +++ b/mysql-test/suite/sys_vars/r/binlog_annotate_row_events_basic.result @@ -0,0 +1,50 @@ +SET @start_global_value = @@global.binlog_annotate_row_events; +select @@global.binlog_annotate_row_events; +@@global.binlog_annotate_row_events +0 +select @@session.binlog_annotate_row_events; +@@session.binlog_annotate_row_events +0 +show global variables like 'binlog_annotate_row_events'; +Variable_name Value +binlog_annotate_row_events OFF +show session variables like 'binlog_annotate_row_events'; +Variable_name Value +binlog_annotate_row_events OFF +select * from information_schema.global_variables where variable_name='binlog_annotate_row_events'; +VARIABLE_NAME VARIABLE_VALUE +BINLOG_ANNOTATE_ROW_EVENTS OFF +select * from information_schema.session_variables where variable_name='binlog_annotate_row_events'; +VARIABLE_NAME VARIABLE_VALUE +BINLOG_ANNOTATE_ROW_EVENTS OFF +set global binlog_annotate_row_events=ON; +select @@global.binlog_annotate_row_events; +@@global.binlog_annotate_row_events +1 +set global binlog_annotate_row_events=OFF; +select @@global.binlog_annotate_row_events; +@@global.binlog_annotate_row_events +0 +set global binlog_annotate_row_events=1; +select @@global.binlog_annotate_row_events; +@@global.binlog_annotate_row_events +1 +set session binlog_annotate_row_events=ON; +select @@session.binlog_annotate_row_events; +@@session.binlog_annotate_row_events +1 +set session binlog_annotate_row_events=OFF; +select @@session.binlog_annotate_row_events; +@@session.binlog_annotate_row_events +0 +set session binlog_annotate_row_events=1; +select @@session.binlog_annotate_row_events; +@@session.binlog_annotate_row_events +1 +set global binlog_annotate_row_events=1.1; +ERROR 42000: Incorrect argument type to variable 'binlog_annotate_row_events' +set session binlog_annotate_row_events=1e1; +ERROR 42000: Incorrect argument type to variable 'binlog_annotate_row_events' +set session binlog_annotate_row_events="foo"; +ERROR 42000: Variable 'binlog_annotate_row_events' can't be set to the value of 'foo' +SET @@global.binlog_annotate_row_events = @start_global_value; diff --git a/mysql-test/suite/sys_vars/r/binlog_annotate_rows_events_basic.result b/mysql-test/suite/sys_vars/r/binlog_annotate_rows_events_basic.result deleted file mode 100644 index af6b27972e5..00000000000 --- a/mysql-test/suite/sys_vars/r/binlog_annotate_rows_events_basic.result +++ /dev/null @@ -1,50 +0,0 @@ -SET @start_global_value = @@global.binlog_annotate_rows_events; -select @@global.binlog_annotate_rows_events; -@@global.binlog_annotate_rows_events -0 -select @@session.binlog_annotate_rows_events; -@@session.binlog_annotate_rows_events -0 -show global variables like 'binlog_annotate_rows_events'; -Variable_name Value -binlog_annotate_rows_events OFF -show session variables like 'binlog_annotate_rows_events'; -Variable_name Value -binlog_annotate_rows_events OFF -select * from information_schema.global_variables where variable_name='binlog_annotate_rows_events'; -VARIABLE_NAME VARIABLE_VALUE -BINLOG_ANNOTATE_ROWS_EVENTS OFF -select * from information_schema.session_variables where variable_name='binlog_annotate_rows_events'; -VARIABLE_NAME VARIABLE_VALUE -BINLOG_ANNOTATE_ROWS_EVENTS OFF -set global binlog_annotate_rows_events=ON; -select @@global.binlog_annotate_rows_events; -@@global.binlog_annotate_rows_events -1 -set global binlog_annotate_rows_events=OFF; -select @@global.binlog_annotate_rows_events; -@@global.binlog_annotate_rows_events -0 -set global binlog_annotate_rows_events=1; -select @@global.binlog_annotate_rows_events; -@@global.binlog_annotate_rows_events -1 -set session binlog_annotate_rows_events=ON; -select @@session.binlog_annotate_rows_events; -@@session.binlog_annotate_rows_events -1 -set session binlog_annotate_rows_events=OFF; -select @@session.binlog_annotate_rows_events; -@@session.binlog_annotate_rows_events -0 -set session binlog_annotate_rows_events=1; -select @@session.binlog_annotate_rows_events; -@@session.binlog_annotate_rows_events -1 -set global binlog_annotate_rows_events=1.1; -ERROR 42000: Incorrect argument type to variable 'binlog_annotate_rows_events' -set session binlog_annotate_rows_events=1e1; -ERROR 42000: Incorrect argument type to variable 'binlog_annotate_rows_events' -set session binlog_annotate_rows_events="foo"; -ERROR 42000: Variable 'binlog_annotate_rows_events' can't be set to the value of 'foo' -SET @@global.binlog_annotate_rows_events = @start_global_value; diff --git a/mysql-test/suite/sys_vars/r/debug_binlog_fsync_sleep_basic.result b/mysql-test/suite/sys_vars/r/debug_binlog_fsync_sleep_basic.result new file mode 100644 index 00000000000..adf2b4c39b9 --- /dev/null +++ b/mysql-test/suite/sys_vars/r/debug_binlog_fsync_sleep_basic.result @@ -0,0 +1,41 @@ +SET @start_global_value = @@global.debug_binlog_fsync_sleep; +select @@global.debug_binlog_fsync_sleep; +@@global.debug_binlog_fsync_sleep +0 +select @@session.debug_binlog_fsync_sleep; +ERROR HY000: Variable 'debug_binlog_fsync_sleep' is a GLOBAL variable +show global variables like 'debug_binlog_fsync_sleep'; +Variable_name Value +debug_binlog_fsync_sleep 0 +show session variables like 'debug_binlog_fsync_sleep'; +Variable_name Value +debug_binlog_fsync_sleep 0 +select * from information_schema.global_variables where variable_name='debug_binlog_fsync_sleep'; +VARIABLE_NAME VARIABLE_VALUE +DEBUG_BINLOG_FSYNC_SLEEP 0 +select * from information_schema.session_variables where variable_name='debug_binlog_fsync_sleep'; +VARIABLE_NAME VARIABLE_VALUE +DEBUG_BINLOG_FSYNC_SLEEP 0 +set global debug_binlog_fsync_sleep=20; +select @@global.debug_binlog_fsync_sleep; +@@global.debug_binlog_fsync_sleep +20 +set session debug_binlog_fsync_sleep=1; +ERROR HY000: Variable 'debug_binlog_fsync_sleep' is a GLOBAL variable and should be set with SET GLOBAL +set global debug_binlog_fsync_sleep=1.1; +ERROR 42000: Incorrect argument type to variable 'debug_binlog_fsync_sleep' +set global debug_binlog_fsync_sleep=1e1; +ERROR 42000: Incorrect argument type to variable 'debug_binlog_fsync_sleep' +set global debug_binlog_fsync_sleep="foo"; +ERROR 42000: Incorrect argument type to variable 'debug_binlog_fsync_sleep' +set global debug_binlog_fsync_sleep=0; +select @@global.debug_binlog_fsync_sleep; +@@global.debug_binlog_fsync_sleep +0 +set global debug_binlog_fsync_sleep=cast(-1 as unsigned int); +Warnings: +Warning 1105 Cast to unsigned converted negative integer to it's positive complement +select @@global.debug_binlog_fsync_sleep; +@@global.debug_binlog_fsync_sleep +18446744073709551615 +SET @@global.debug_binlog_fsync_sleep = @start_global_value; diff --git a/mysql-test/suite/sys_vars/r/engine_condition_pushdown_basic.result b/mysql-test/suite/sys_vars/r/engine_condition_pushdown_basic.result index 36dc9b6399e..0922113f8b6 100644 --- a/mysql-test/suite/sys_vars/r/engine_condition_pushdown_basic.result +++ b/mysql-test/suite/sys_vars/r/engine_condition_pushdown_basic.result @@ -9,7 +9,7 @@ SELECT @global_start_value; select @old_session_opt_switch:=@@session.optimizer_switch, @old_global_opt_switch:=@@global.optimizer_switch; @old_session_opt_switch:=@@session.optimizer_switch @old_global_opt_switch:=@@global.optimizer_switch -index_merge=on,index_merge_union=on,index_merge_sort_union=on,index_merge_intersection=on,index_merge_sort_intersection=off,engine_condition_pushdown=off,index_condition_pushdown=off,derived_merge=off,derived_with_keys=off,firstmatch=off,loosescan=off,materialization=off,in_to_exists=on,semijoin=off,partial_match_rowid_merge=on,partial_match_table_scan=on,subquery_cache=off,mrr=off,mrr_cost_based=off,mrr_sort_keys=off,outer_join_with_cache=off,semijoin_with_cache=off,join_cache_incremental=on,join_cache_hashed=on,join_cache_bka=on,optimize_join_buffer_size=off,table_elimination=on index_merge=on,index_merge_union=on,index_merge_sort_union=on,index_merge_intersection=on,index_merge_sort_intersection=off,engine_condition_pushdown=off,index_condition_pushdown=off,derived_merge=off,derived_with_keys=off,firstmatch=off,loosescan=off,materialization=off,in_to_exists=on,semijoin=off,partial_match_rowid_merge=on,partial_match_table_scan=on,subquery_cache=off,mrr=off,mrr_cost_based=off,mrr_sort_keys=off,outer_join_with_cache=off,semijoin_with_cache=off,join_cache_incremental=on,join_cache_hashed=on,join_cache_bka=on,optimize_join_buffer_size=off,table_elimination=on +index_merge=on,index_merge_union=on,index_merge_sort_union=on,index_merge_intersection=on,index_merge_sort_intersection=off,engine_condition_pushdown=off,index_condition_pushdown=off,derived_merge=off,derived_with_keys=off,firstmatch=on,loosescan=on,materialization=off,in_to_exists=on,semijoin=on,partial_match_rowid_merge=on,partial_match_table_scan=on,subquery_cache=on,mrr=off,mrr_cost_based=off,mrr_sort_keys=off,outer_join_with_cache=off,semijoin_with_cache=off,join_cache_incremental=on,join_cache_hashed=on,join_cache_bka=on,optimize_join_buffer_size=off,table_elimination=on index_merge=on,index_merge_union=on,index_merge_sort_union=on,index_merge_intersection=on,index_merge_sort_intersection=off,engine_condition_pushdown=off,index_condition_pushdown=off,derived_merge=off,derived_with_keys=off,firstmatch=on,loosescan=on,materialization=off,in_to_exists=on,semijoin=on,partial_match_rowid_merge=on,partial_match_table_scan=on,subquery_cache=on,mrr=off,mrr_cost_based=off,mrr_sort_keys=off,outer_join_with_cache=off,semijoin_with_cache=off,join_cache_incremental=on,join_cache_hashed=on,join_cache_bka=on,optimize_join_buffer_size=off,table_elimination=on '#--------------------FN_DYNVARS_028_01------------------------#' SET @@session.engine_condition_pushdown = 0; Warnings: @@ -212,7 +212,7 @@ select @@session.engine_condition_pushdown, @@global.engine_condition_pushdown, @@session.optimizer_switch, @@global.optimizer_switch; @@session.engine_condition_pushdown @@global.engine_condition_pushdown @@session.optimizer_switch @@global.optimizer_switch -0 0 index_merge=on,index_merge_union=on,index_merge_sort_union=on,index_merge_intersection=on,index_merge_sort_intersection=off,engine_condition_pushdown=off,index_condition_pushdown=off,derived_merge=off,derived_with_keys=off,firstmatch=off,loosescan=off,materialization=off,in_to_exists=on,semijoin=off,partial_match_rowid_merge=on,partial_match_table_scan=on,subquery_cache=off,mrr=off,mrr_cost_based=off,mrr_sort_keys=off,outer_join_with_cache=off,semijoin_with_cache=off,join_cache_incremental=on,join_cache_hashed=on,join_cache_bka=on,optimize_join_buffer_size=off,table_elimination=on index_merge=on,index_merge_union=on,index_merge_sort_union=on,index_merge_intersection=on,index_merge_sort_intersection=off,engine_condition_pushdown=off,index_condition_pushdown=off,derived_merge=off,derived_with_keys=off,firstmatch=off,loosescan=off,materialization=off,in_to_exists=on,semijoin=off,partial_match_rowid_merge=on,partial_match_table_scan=on,subquery_cache=off,mrr=off,mrr_cost_based=off,mrr_sort_keys=off,outer_join_with_cache=off,semijoin_with_cache=off,join_cache_incremental=on,join_cache_hashed=on,join_cache_bka=on,optimize_join_buffer_size=off,table_elimination=on +0 0 index_merge=on,index_merge_union=on,index_merge_sort_union=on,index_merge_intersection=on,index_merge_sort_intersection=off,engine_condition_pushdown=off,index_condition_pushdown=off,derived_merge=off,derived_with_keys=off,firstmatch=on,loosescan=on,materialization=off,in_to_exists=on,semijoin=on,partial_match_rowid_merge=on,partial_match_table_scan=on,subquery_cache=on,mrr=off,mrr_cost_based=off,mrr_sort_keys=off,outer_join_with_cache=off,semijoin_with_cache=off,join_cache_incremental=on,join_cache_hashed=on,join_cache_bka=on,optimize_join_buffer_size=off,table_elimination=on index_merge=on,index_merge_union=on,index_merge_sort_union=on,index_merge_intersection=on,index_merge_sort_intersection=off,engine_condition_pushdown=off,index_condition_pushdown=off,derived_merge=off,derived_with_keys=off,firstmatch=on,loosescan=on,materialization=off,in_to_exists=on,semijoin=on,partial_match_rowid_merge=on,partial_match_table_scan=on,subquery_cache=on,mrr=off,mrr_cost_based=off,mrr_sort_keys=off,outer_join_with_cache=off,semijoin_with_cache=off,join_cache_incremental=on,join_cache_hashed=on,join_cache_bka=on,optimize_join_buffer_size=off,table_elimination=on set @@session.engine_condition_pushdown = TRUE; Warnings: Warning 1287 The syntax '@@engine_condition_pushdown' is deprecated and will be removed in MySQL 7.0. Please use '@@optimizer_switch' instead @@ -220,7 +220,7 @@ select @@session.engine_condition_pushdown, @@global.engine_condition_pushdown, @@session.optimizer_switch, @@global.optimizer_switch; @@session.engine_condition_pushdown @@global.engine_condition_pushdown @@session.optimizer_switch @@global.optimizer_switch -1 0 index_merge=on,index_merge_union=on,index_merge_sort_union=on,index_merge_intersection=on,index_merge_sort_intersection=off,engine_condition_pushdown=on,index_condition_pushdown=off,derived_merge=off,derived_with_keys=off,firstmatch=off,loosescan=off,materialization=off,in_to_exists=on,semijoin=off,partial_match_rowid_merge=on,partial_match_table_scan=on,subquery_cache=off,mrr=off,mrr_cost_based=off,mrr_sort_keys=off,outer_join_with_cache=off,semijoin_with_cache=off,join_cache_incremental=on,join_cache_hashed=on,join_cache_bka=on,optimize_join_buffer_size=off,table_elimination=on index_merge=on,index_merge_union=on,index_merge_sort_union=on,index_merge_intersection=on,index_merge_sort_intersection=off,engine_condition_pushdown=off,index_condition_pushdown=off,derived_merge=off,derived_with_keys=off,firstmatch=off,loosescan=off,materialization=off,in_to_exists=on,semijoin=off,partial_match_rowid_merge=on,partial_match_table_scan=on,subquery_cache=off,mrr=off,mrr_cost_based=off,mrr_sort_keys=off,outer_join_with_cache=off,semijoin_with_cache=off,join_cache_incremental=on,join_cache_hashed=on,join_cache_bka=on,optimize_join_buffer_size=off,table_elimination=on +1 0 index_merge=on,index_merge_union=on,index_merge_sort_union=on,index_merge_intersection=on,index_merge_sort_intersection=off,engine_condition_pushdown=on,index_condition_pushdown=off,derived_merge=off,derived_with_keys=off,firstmatch=on,loosescan=on,materialization=off,in_to_exists=on,semijoin=on,partial_match_rowid_merge=on,partial_match_table_scan=on,subquery_cache=on,mrr=off,mrr_cost_based=off,mrr_sort_keys=off,outer_join_with_cache=off,semijoin_with_cache=off,join_cache_incremental=on,join_cache_hashed=on,join_cache_bka=on,optimize_join_buffer_size=off,table_elimination=on index_merge=on,index_merge_union=on,index_merge_sort_union=on,index_merge_intersection=on,index_merge_sort_intersection=off,engine_condition_pushdown=off,index_condition_pushdown=off,derived_merge=off,derived_with_keys=off,firstmatch=on,loosescan=on,materialization=off,in_to_exists=on,semijoin=on,partial_match_rowid_merge=on,partial_match_table_scan=on,subquery_cache=on,mrr=off,mrr_cost_based=off,mrr_sort_keys=off,outer_join_with_cache=off,semijoin_with_cache=off,join_cache_incremental=on,join_cache_hashed=on,join_cache_bka=on,optimize_join_buffer_size=off,table_elimination=on set @@session.engine_condition_pushdown = FALSE; Warnings: Warning 1287 The syntax '@@engine_condition_pushdown' is deprecated and will be removed in MySQL 7.0. Please use '@@optimizer_switch' instead @@ -228,7 +228,7 @@ select @@session.engine_condition_pushdown, @@global.engine_condition_pushdown, @@session.optimizer_switch, @@global.optimizer_switch; @@session.engine_condition_pushdown @@global.engine_condition_pushdown @@session.optimizer_switch @@global.optimizer_switch -0 0 index_merge=on,index_merge_union=on,index_merge_sort_union=on,index_merge_intersection=on,index_merge_sort_intersection=off,engine_condition_pushdown=off,index_condition_pushdown=off,derived_merge=off,derived_with_keys=off,firstmatch=off,loosescan=off,materialization=off,in_to_exists=on,semijoin=off,partial_match_rowid_merge=on,partial_match_table_scan=on,subquery_cache=off,mrr=off,mrr_cost_based=off,mrr_sort_keys=off,outer_join_with_cache=off,semijoin_with_cache=off,join_cache_incremental=on,join_cache_hashed=on,join_cache_bka=on,optimize_join_buffer_size=off,table_elimination=on index_merge=on,index_merge_union=on,index_merge_sort_union=on,index_merge_intersection=on,index_merge_sort_intersection=off,engine_condition_pushdown=off,index_condition_pushdown=off,derived_merge=off,derived_with_keys=off,firstmatch=off,loosescan=off,materialization=off,in_to_exists=on,semijoin=off,partial_match_rowid_merge=on,partial_match_table_scan=on,subquery_cache=off,mrr=off,mrr_cost_based=off,mrr_sort_keys=off,outer_join_with_cache=off,semijoin_with_cache=off,join_cache_incremental=on,join_cache_hashed=on,join_cache_bka=on,optimize_join_buffer_size=off,table_elimination=on +0 0 index_merge=on,index_merge_union=on,index_merge_sort_union=on,index_merge_intersection=on,index_merge_sort_intersection=off,engine_condition_pushdown=off,index_condition_pushdown=off,derived_merge=off,derived_with_keys=off,firstmatch=on,loosescan=on,materialization=off,in_to_exists=on,semijoin=on,partial_match_rowid_merge=on,partial_match_table_scan=on,subquery_cache=on,mrr=off,mrr_cost_based=off,mrr_sort_keys=off,outer_join_with_cache=off,semijoin_with_cache=off,join_cache_incremental=on,join_cache_hashed=on,join_cache_bka=on,optimize_join_buffer_size=off,table_elimination=on index_merge=on,index_merge_union=on,index_merge_sort_union=on,index_merge_intersection=on,index_merge_sort_intersection=off,engine_condition_pushdown=off,index_condition_pushdown=off,derived_merge=off,derived_with_keys=off,firstmatch=on,loosescan=on,materialization=off,in_to_exists=on,semijoin=on,partial_match_rowid_merge=on,partial_match_table_scan=on,subquery_cache=on,mrr=off,mrr_cost_based=off,mrr_sort_keys=off,outer_join_with_cache=off,semijoin_with_cache=off,join_cache_incremental=on,join_cache_hashed=on,join_cache_bka=on,optimize_join_buffer_size=off,table_elimination=on set @@global.engine_condition_pushdown = TRUE; Warnings: Warning 1287 The syntax '@@engine_condition_pushdown' is deprecated and will be removed in MySQL 7.0. Please use '@@optimizer_switch' instead @@ -236,7 +236,7 @@ select @@session.engine_condition_pushdown, @@global.engine_condition_pushdown, @@session.optimizer_switch, @@global.optimizer_switch; @@session.engine_condition_pushdown @@global.engine_condition_pushdown @@session.optimizer_switch @@global.optimizer_switch -0 1 index_merge=on,index_merge_union=on,index_merge_sort_union=on,index_merge_intersection=on,index_merge_sort_intersection=off,engine_condition_pushdown=off,index_condition_pushdown=off,derived_merge=off,derived_with_keys=off,firstmatch=off,loosescan=off,materialization=off,in_to_exists=on,semijoin=off,partial_match_rowid_merge=on,partial_match_table_scan=on,subquery_cache=off,mrr=off,mrr_cost_based=off,mrr_sort_keys=off,outer_join_with_cache=off,semijoin_with_cache=off,join_cache_incremental=on,join_cache_hashed=on,join_cache_bka=on,optimize_join_buffer_size=off,table_elimination=on index_merge=on,index_merge_union=on,index_merge_sort_union=on,index_merge_intersection=on,index_merge_sort_intersection=off,engine_condition_pushdown=on,index_condition_pushdown=off,derived_merge=off,derived_with_keys=off,firstmatch=off,loosescan=off,materialization=off,in_to_exists=on,semijoin=off,partial_match_rowid_merge=on,partial_match_table_scan=on,subquery_cache=off,mrr=off,mrr_cost_based=off,mrr_sort_keys=off,outer_join_with_cache=off,semijoin_with_cache=off,join_cache_incremental=on,join_cache_hashed=on,join_cache_bka=on,optimize_join_buffer_size=off,table_elimination=on +0 1 index_merge=on,index_merge_union=on,index_merge_sort_union=on,index_merge_intersection=on,index_merge_sort_intersection=off,engine_condition_pushdown=off,index_condition_pushdown=off,derived_merge=off,derived_with_keys=off,firstmatch=on,loosescan=on,materialization=off,in_to_exists=on,semijoin=on,partial_match_rowid_merge=on,partial_match_table_scan=on,subquery_cache=on,mrr=off,mrr_cost_based=off,mrr_sort_keys=off,outer_join_with_cache=off,semijoin_with_cache=off,join_cache_incremental=on,join_cache_hashed=on,join_cache_bka=on,optimize_join_buffer_size=off,table_elimination=on index_merge=on,index_merge_union=on,index_merge_sort_union=on,index_merge_intersection=on,index_merge_sort_intersection=off,engine_condition_pushdown=on,index_condition_pushdown=off,derived_merge=off,derived_with_keys=off,firstmatch=on,loosescan=on,materialization=off,in_to_exists=on,semijoin=on,partial_match_rowid_merge=on,partial_match_table_scan=on,subquery_cache=on,mrr=off,mrr_cost_based=off,mrr_sort_keys=off,outer_join_with_cache=off,semijoin_with_cache=off,join_cache_incremental=on,join_cache_hashed=on,join_cache_bka=on,optimize_join_buffer_size=off,table_elimination=on set @@global.engine_condition_pushdown = FALSE; Warnings: Warning 1287 The syntax '@@engine_condition_pushdown' is deprecated and will be removed in MySQL 7.0. Please use '@@optimizer_switch' instead @@ -244,31 +244,31 @@ select @@session.engine_condition_pushdown, @@global.engine_condition_pushdown, @@session.optimizer_switch, @@global.optimizer_switch; @@session.engine_condition_pushdown @@global.engine_condition_pushdown @@session.optimizer_switch @@global.optimizer_switch -0 0 index_merge=on,index_merge_union=on,index_merge_sort_union=on,index_merge_intersection=on,index_merge_sort_intersection=off,engine_condition_pushdown=off,index_condition_pushdown=off,derived_merge=off,derived_with_keys=off,firstmatch=off,loosescan=off,materialization=off,in_to_exists=on,semijoin=off,partial_match_rowid_merge=on,partial_match_table_scan=on,subquery_cache=off,mrr=off,mrr_cost_based=off,mrr_sort_keys=off,outer_join_with_cache=off,semijoin_with_cache=off,join_cache_incremental=on,join_cache_hashed=on,join_cache_bka=on,optimize_join_buffer_size=off,table_elimination=on index_merge=on,index_merge_union=on,index_merge_sort_union=on,index_merge_intersection=on,index_merge_sort_intersection=off,engine_condition_pushdown=off,index_condition_pushdown=off,derived_merge=off,derived_with_keys=off,firstmatch=off,loosescan=off,materialization=off,in_to_exists=on,semijoin=off,partial_match_rowid_merge=on,partial_match_table_scan=on,subquery_cache=off,mrr=off,mrr_cost_based=off,mrr_sort_keys=off,outer_join_with_cache=off,semijoin_with_cache=off,join_cache_incremental=on,join_cache_hashed=on,join_cache_bka=on,optimize_join_buffer_size=off,table_elimination=on +0 0 index_merge=on,index_merge_union=on,index_merge_sort_union=on,index_merge_intersection=on,index_merge_sort_intersection=off,engine_condition_pushdown=off,index_condition_pushdown=off,derived_merge=off,derived_with_keys=off,firstmatch=on,loosescan=on,materialization=off,in_to_exists=on,semijoin=on,partial_match_rowid_merge=on,partial_match_table_scan=on,subquery_cache=on,mrr=off,mrr_cost_based=off,mrr_sort_keys=off,outer_join_with_cache=off,semijoin_with_cache=off,join_cache_incremental=on,join_cache_hashed=on,join_cache_bka=on,optimize_join_buffer_size=off,table_elimination=on index_merge=on,index_merge_union=on,index_merge_sort_union=on,index_merge_intersection=on,index_merge_sort_intersection=off,engine_condition_pushdown=off,index_condition_pushdown=off,derived_merge=off,derived_with_keys=off,firstmatch=on,loosescan=on,materialization=off,in_to_exists=on,semijoin=on,partial_match_rowid_merge=on,partial_match_table_scan=on,subquery_cache=on,mrr=off,mrr_cost_based=off,mrr_sort_keys=off,outer_join_with_cache=off,semijoin_with_cache=off,join_cache_incremental=on,join_cache_hashed=on,join_cache_bka=on,optimize_join_buffer_size=off,table_elimination=on set @@session.optimizer_switch = "engine_condition_pushdown=on"; select @@session.engine_condition_pushdown, @@global.engine_condition_pushdown, @@session.optimizer_switch, @@global.optimizer_switch; @@session.engine_condition_pushdown @@global.engine_condition_pushdown @@session.optimizer_switch @@global.optimizer_switch -1 0 index_merge=on,index_merge_union=on,index_merge_sort_union=on,index_merge_intersection=on,index_merge_sort_intersection=off,engine_condition_pushdown=on,index_condition_pushdown=off,derived_merge=off,derived_with_keys=off,firstmatch=off,loosescan=off,materialization=off,in_to_exists=on,semijoin=off,partial_match_rowid_merge=on,partial_match_table_scan=on,subquery_cache=off,mrr=off,mrr_cost_based=off,mrr_sort_keys=off,outer_join_with_cache=off,semijoin_with_cache=off,join_cache_incremental=on,join_cache_hashed=on,join_cache_bka=on,optimize_join_buffer_size=off,table_elimination=on index_merge=on,index_merge_union=on,index_merge_sort_union=on,index_merge_intersection=on,index_merge_sort_intersection=off,engine_condition_pushdown=off,index_condition_pushdown=off,derived_merge=off,derived_with_keys=off,firstmatch=off,loosescan=off,materialization=off,in_to_exists=on,semijoin=off,partial_match_rowid_merge=on,partial_match_table_scan=on,subquery_cache=off,mrr=off,mrr_cost_based=off,mrr_sort_keys=off,outer_join_with_cache=off,semijoin_with_cache=off,join_cache_incremental=on,join_cache_hashed=on,join_cache_bka=on,optimize_join_buffer_size=off,table_elimination=on +1 0 index_merge=on,index_merge_union=on,index_merge_sort_union=on,index_merge_intersection=on,index_merge_sort_intersection=off,engine_condition_pushdown=on,index_condition_pushdown=off,derived_merge=off,derived_with_keys=off,firstmatch=on,loosescan=on,materialization=off,in_to_exists=on,semijoin=on,partial_match_rowid_merge=on,partial_match_table_scan=on,subquery_cache=on,mrr=off,mrr_cost_based=off,mrr_sort_keys=off,outer_join_with_cache=off,semijoin_with_cache=off,join_cache_incremental=on,join_cache_hashed=on,join_cache_bka=on,optimize_join_buffer_size=off,table_elimination=on index_merge=on,index_merge_union=on,index_merge_sort_union=on,index_merge_intersection=on,index_merge_sort_intersection=off,engine_condition_pushdown=off,index_condition_pushdown=off,derived_merge=off,derived_with_keys=off,firstmatch=on,loosescan=on,materialization=off,in_to_exists=on,semijoin=on,partial_match_rowid_merge=on,partial_match_table_scan=on,subquery_cache=on,mrr=off,mrr_cost_based=off,mrr_sort_keys=off,outer_join_with_cache=off,semijoin_with_cache=off,join_cache_incremental=on,join_cache_hashed=on,join_cache_bka=on,optimize_join_buffer_size=off,table_elimination=on set @@session.optimizer_switch = "engine_condition_pushdown=off"; select @@session.engine_condition_pushdown, @@global.engine_condition_pushdown, @@session.optimizer_switch, @@global.optimizer_switch; @@session.engine_condition_pushdown @@global.engine_condition_pushdown @@session.optimizer_switch @@global.optimizer_switch -0 0 index_merge=on,index_merge_union=on,index_merge_sort_union=on,index_merge_intersection=on,index_merge_sort_intersection=off,engine_condition_pushdown=off,index_condition_pushdown=off,derived_merge=off,derived_with_keys=off,firstmatch=off,loosescan=off,materialization=off,in_to_exists=on,semijoin=off,partial_match_rowid_merge=on,partial_match_table_scan=on,subquery_cache=off,mrr=off,mrr_cost_based=off,mrr_sort_keys=off,outer_join_with_cache=off,semijoin_with_cache=off,join_cache_incremental=on,join_cache_hashed=on,join_cache_bka=on,optimize_join_buffer_size=off,table_elimination=on index_merge=on,index_merge_union=on,index_merge_sort_union=on,index_merge_intersection=on,index_merge_sort_intersection=off,engine_condition_pushdown=off,index_condition_pushdown=off,derived_merge=off,derived_with_keys=off,firstmatch=off,loosescan=off,materialization=off,in_to_exists=on,semijoin=off,partial_match_rowid_merge=on,partial_match_table_scan=on,subquery_cache=off,mrr=off,mrr_cost_based=off,mrr_sort_keys=off,outer_join_with_cache=off,semijoin_with_cache=off,join_cache_incremental=on,join_cache_hashed=on,join_cache_bka=on,optimize_join_buffer_size=off,table_elimination=on +0 0 index_merge=on,index_merge_union=on,index_merge_sort_union=on,index_merge_intersection=on,index_merge_sort_intersection=off,engine_condition_pushdown=off,index_condition_pushdown=off,derived_merge=off,derived_with_keys=off,firstmatch=on,loosescan=on,materialization=off,in_to_exists=on,semijoin=on,partial_match_rowid_merge=on,partial_match_table_scan=on,subquery_cache=on,mrr=off,mrr_cost_based=off,mrr_sort_keys=off,outer_join_with_cache=off,semijoin_with_cache=off,join_cache_incremental=on,join_cache_hashed=on,join_cache_bka=on,optimize_join_buffer_size=off,table_elimination=on index_merge=on,index_merge_union=on,index_merge_sort_union=on,index_merge_intersection=on,index_merge_sort_intersection=off,engine_condition_pushdown=off,index_condition_pushdown=off,derived_merge=off,derived_with_keys=off,firstmatch=on,loosescan=on,materialization=off,in_to_exists=on,semijoin=on,partial_match_rowid_merge=on,partial_match_table_scan=on,subquery_cache=on,mrr=off,mrr_cost_based=off,mrr_sort_keys=off,outer_join_with_cache=off,semijoin_with_cache=off,join_cache_incremental=on,join_cache_hashed=on,join_cache_bka=on,optimize_join_buffer_size=off,table_elimination=on set @@global.optimizer_switch = "engine_condition_pushdown=on"; select @@session.engine_condition_pushdown, @@global.engine_condition_pushdown, @@session.optimizer_switch, @@global.optimizer_switch; @@session.engine_condition_pushdown @@global.engine_condition_pushdown @@session.optimizer_switch @@global.optimizer_switch -0 1 index_merge=on,index_merge_union=on,index_merge_sort_union=on,index_merge_intersection=on,index_merge_sort_intersection=off,engine_condition_pushdown=off,index_condition_pushdown=off,derived_merge=off,derived_with_keys=off,firstmatch=off,loosescan=off,materialization=off,in_to_exists=on,semijoin=off,partial_match_rowid_merge=on,partial_match_table_scan=on,subquery_cache=off,mrr=off,mrr_cost_based=off,mrr_sort_keys=off,outer_join_with_cache=off,semijoin_with_cache=off,join_cache_incremental=on,join_cache_hashed=on,join_cache_bka=on,optimize_join_buffer_size=off,table_elimination=on index_merge=on,index_merge_union=on,index_merge_sort_union=on,index_merge_intersection=on,index_merge_sort_intersection=off,engine_condition_pushdown=on,index_condition_pushdown=off,derived_merge=off,derived_with_keys=off,firstmatch=off,loosescan=off,materialization=off,in_to_exists=on,semijoin=off,partial_match_rowid_merge=on,partial_match_table_scan=on,subquery_cache=off,mrr=off,mrr_cost_based=off,mrr_sort_keys=off,outer_join_with_cache=off,semijoin_with_cache=off,join_cache_incremental=on,join_cache_hashed=on,join_cache_bka=on,optimize_join_buffer_size=off,table_elimination=on +0 1 index_merge=on,index_merge_union=on,index_merge_sort_union=on,index_merge_intersection=on,index_merge_sort_intersection=off,engine_condition_pushdown=off,index_condition_pushdown=off,derived_merge=off,derived_with_keys=off,firstmatch=on,loosescan=on,materialization=off,in_to_exists=on,semijoin=on,partial_match_rowid_merge=on,partial_match_table_scan=on,subquery_cache=on,mrr=off,mrr_cost_based=off,mrr_sort_keys=off,outer_join_with_cache=off,semijoin_with_cache=off,join_cache_incremental=on,join_cache_hashed=on,join_cache_bka=on,optimize_join_buffer_size=off,table_elimination=on index_merge=on,index_merge_union=on,index_merge_sort_union=on,index_merge_intersection=on,index_merge_sort_intersection=off,engine_condition_pushdown=on,index_condition_pushdown=off,derived_merge=off,derived_with_keys=off,firstmatch=on,loosescan=on,materialization=off,in_to_exists=on,semijoin=on,partial_match_rowid_merge=on,partial_match_table_scan=on,subquery_cache=on,mrr=off,mrr_cost_based=off,mrr_sort_keys=off,outer_join_with_cache=off,semijoin_with_cache=off,join_cache_incremental=on,join_cache_hashed=on,join_cache_bka=on,optimize_join_buffer_size=off,table_elimination=on set @@global.optimizer_switch = "engine_condition_pushdown=off"; select @@session.engine_condition_pushdown, @@global.engine_condition_pushdown, @@session.optimizer_switch, @@global.optimizer_switch; @@session.engine_condition_pushdown @@global.engine_condition_pushdown @@session.optimizer_switch @@global.optimizer_switch -0 0 index_merge=on,index_merge_union=on,index_merge_sort_union=on,index_merge_intersection=on,index_merge_sort_intersection=off,engine_condition_pushdown=off,index_condition_pushdown=off,derived_merge=off,derived_with_keys=off,firstmatch=off,loosescan=off,materialization=off,in_to_exists=on,semijoin=off,partial_match_rowid_merge=on,partial_match_table_scan=on,subquery_cache=off,mrr=off,mrr_cost_based=off,mrr_sort_keys=off,outer_join_with_cache=off,semijoin_with_cache=off,join_cache_incremental=on,join_cache_hashed=on,join_cache_bka=on,optimize_join_buffer_size=off,table_elimination=on index_merge=on,index_merge_union=on,index_merge_sort_union=on,index_merge_intersection=on,index_merge_sort_intersection=off,engine_condition_pushdown=off,index_condition_pushdown=off,derived_merge=off,derived_with_keys=off,firstmatch=off,loosescan=off,materialization=off,in_to_exists=on,semijoin=off,partial_match_rowid_merge=on,partial_match_table_scan=on,subquery_cache=off,mrr=off,mrr_cost_based=off,mrr_sort_keys=off,outer_join_with_cache=off,semijoin_with_cache=off,join_cache_incremental=on,join_cache_hashed=on,join_cache_bka=on,optimize_join_buffer_size=off,table_elimination=on +0 0 index_merge=on,index_merge_union=on,index_merge_sort_union=on,index_merge_intersection=on,index_merge_sort_intersection=off,engine_condition_pushdown=off,index_condition_pushdown=off,derived_merge=off,derived_with_keys=off,firstmatch=on,loosescan=on,materialization=off,in_to_exists=on,semijoin=on,partial_match_rowid_merge=on,partial_match_table_scan=on,subquery_cache=on,mrr=off,mrr_cost_based=off,mrr_sort_keys=off,outer_join_with_cache=off,semijoin_with_cache=off,join_cache_incremental=on,join_cache_hashed=on,join_cache_bka=on,optimize_join_buffer_size=off,table_elimination=on index_merge=on,index_merge_union=on,index_merge_sort_union=on,index_merge_intersection=on,index_merge_sort_intersection=off,engine_condition_pushdown=off,index_condition_pushdown=off,derived_merge=off,derived_with_keys=off,firstmatch=on,loosescan=on,materialization=off,in_to_exists=on,semijoin=on,partial_match_rowid_merge=on,partial_match_table_scan=on,subquery_cache=on,mrr=off,mrr_cost_based=off,mrr_sort_keys=off,outer_join_with_cache=off,semijoin_with_cache=off,join_cache_incremental=on,join_cache_hashed=on,join_cache_bka=on,optimize_join_buffer_size=off,table_elimination=on SET @@session.engine_condition_pushdown = @session_start_value; Warnings: Warning 1287 The syntax '@@engine_condition_pushdown' is deprecated and will be removed in MySQL 7.0. Please use '@@optimizer_switch' instead @@ -287,4 +287,4 @@ select @@session.engine_condition_pushdown, @@global.engine_condition_pushdown, @@session.optimizer_switch, @@global.optimizer_switch; @@session.engine_condition_pushdown @@global.engine_condition_pushdown @@session.optimizer_switch @@global.optimizer_switch -0 0 index_merge=on,index_merge_union=on,index_merge_sort_union=on,index_merge_intersection=on,index_merge_sort_intersection=off,engine_condition_pushdown=off,index_condition_pushdown=off,derived_merge=off,derived_with_keys=off,firstmatch=off,loosescan=off,materialization=off,in_to_exists=on,semijoin=off,partial_match_rowid_merge=on,partial_match_table_scan=on,subquery_cache=off,mrr=off,mrr_cost_based=off,mrr_sort_keys=off,outer_join_with_cache=off,semijoin_with_cache=off,join_cache_incremental=on,join_cache_hashed=on,join_cache_bka=on,optimize_join_buffer_size=off,table_elimination=on index_merge=on,index_merge_union=on,index_merge_sort_union=on,index_merge_intersection=on,index_merge_sort_intersection=off,engine_condition_pushdown=off,index_condition_pushdown=off,derived_merge=off,derived_with_keys=off,firstmatch=off,loosescan=off,materialization=off,in_to_exists=on,semijoin=off,partial_match_rowid_merge=on,partial_match_table_scan=on,subquery_cache=off,mrr=off,mrr_cost_based=off,mrr_sort_keys=off,outer_join_with_cache=off,semijoin_with_cache=off,join_cache_incremental=on,join_cache_hashed=on,join_cache_bka=on,optimize_join_buffer_size=off,table_elimination=on +0 0 index_merge=on,index_merge_union=on,index_merge_sort_union=on,index_merge_intersection=on,index_merge_sort_intersection=off,engine_condition_pushdown=off,index_condition_pushdown=off,derived_merge=off,derived_with_keys=off,firstmatch=on,loosescan=on,materialization=off,in_to_exists=on,semijoin=on,partial_match_rowid_merge=on,partial_match_table_scan=on,subquery_cache=on,mrr=off,mrr_cost_based=off,mrr_sort_keys=off,outer_join_with_cache=off,semijoin_with_cache=off,join_cache_incremental=on,join_cache_hashed=on,join_cache_bka=on,optimize_join_buffer_size=off,table_elimination=on index_merge=on,index_merge_union=on,index_merge_sort_union=on,index_merge_intersection=on,index_merge_sort_intersection=off,engine_condition_pushdown=off,index_condition_pushdown=off,derived_merge=off,derived_with_keys=off,firstmatch=on,loosescan=on,materialization=off,in_to_exists=on,semijoin=on,partial_match_rowid_merge=on,partial_match_table_scan=on,subquery_cache=on,mrr=off,mrr_cost_based=off,mrr_sort_keys=off,outer_join_with_cache=off,semijoin_with_cache=off,join_cache_incremental=on,join_cache_hashed=on,join_cache_bka=on,optimize_join_buffer_size=off,table_elimination=on diff --git a/mysql-test/suite/sys_vars/r/innodb_file_format_check_basic.result b/mysql-test/suite/sys_vars/r/innodb_file_format_check_basic.result index c59e1b802f4..9167585f1d6 100644 --- a/mysql-test/suite/sys_vars/r/innodb_file_format_check_basic.result +++ b/mysql-test/suite/sys_vars/r/innodb_file_format_check_basic.result @@ -1,59 +1,80 @@ -SET @start_global_value = @@global.innodb_file_format_max; +SET @start_global_value = @@global.innodb_file_format_check; SELECT @start_global_value; @start_global_value -Antelope -Valid values are 'Antelope' and 'Barracuda' -select @@global.innodb_file_format_max in ('Antelope', 'Barracuda'); -@@global.innodb_file_format_max in ('Antelope', 'Barracuda') -1 -select @@global.innodb_file_format_max; -@@global.innodb_file_format_max -Antelope -select @@session.innodb_file_format_max; -ERROR HY000: Variable 'innodb_file_format_max' is a GLOBAL variable -show global variables like 'innodb_file_format_max'; +1 +Valid values are 'ON' and 'OFF' +SELECT @@global.innodb_file_format_check in (0, 1); +@@global.innodb_file_format_check in (0, 1) +1 +SELECT @@global.innodb_file_format_check; +@@global.innodb_file_format_check +1 +SELECT @@session.innodb_file_format_check; +ERROR HY000: Variable 'innodb_file_format_check' is a GLOBAL variable +SHOW global variables LIKE 'innodb_file_format_check'; Variable_name Value -innodb_file_format_max Antelope -show session variables like 'innodb_file_format_max'; +innodb_file_format_check ON +SHOW session variables LIKE 'innodb_file_format_check'; Variable_name Value -innodb_file_format_max Antelope -select * from information_schema.global_variables where variable_name='innodb_file_format_max'; -VARIABLE_NAME VARIABLE_VALUE -INNODB_FILE_FORMAT_MAX Antelope -select * from information_schema.session_variables where variable_name='innodb_file_format_max'; -VARIABLE_NAME VARIABLE_VALUE -INNODB_FILE_FORMAT_MAX Antelope -set global innodb_file_format_max='Antelope'; -select @@global.innodb_file_format_max; -@@global.innodb_file_format_max -Antelope -select * from information_schema.global_variables where variable_name='innodb_file_format_max'; -VARIABLE_NAME VARIABLE_VALUE -INNODB_FILE_FORMAT_MAX Antelope -select * from information_schema.session_variables where variable_name='innodb_file_format_max'; -VARIABLE_NAME VARIABLE_VALUE -INNODB_FILE_FORMAT_MAX Antelope -set @@global.innodb_file_format_max='Barracuda'; -select @@global.innodb_file_format_max; -@@global.innodb_file_format_max -Barracuda -select * from information_schema.global_variables where variable_name='innodb_file_format_max'; +innodb_file_format_check ON +SELECT * FROM information_schema.global_variables +WHERE variable_name='innodb_file_format_check'; VARIABLE_NAME VARIABLE_VALUE -INNODB_FILE_FORMAT_MAX Barracuda -select * from information_schema.session_variables where variable_name='innodb_file_format_max'; +INNODB_FILE_FORMAT_CHECK ON +SELECT * FROM information_schema.session_variables +WHERE variable_name='innodb_file_format_check'; VARIABLE_NAME VARIABLE_VALUE -INNODB_FILE_FORMAT_MAX Barracuda -set session innodb_file_format_max='Salmon'; -ERROR HY000: Variable 'innodb_file_format_max' is a GLOBAL variable and should be set with SET GLOBAL -set @@session.innodb_file_format_max='Salmon'; -ERROR HY000: Variable 'innodb_file_format_max' is a GLOBAL variable and should be set with SET GLOBAL -set global innodb_file_format_max=1.1; -ERROR 42000: Incorrect argument type to variable 'innodb_file_format_max' -set global innodb_file_format_max=1e1; -ERROR 42000: Incorrect argument type to variable 'innodb_file_format_max' -set global innodb_file_format_max='Salmon'; -ERROR 42000: Variable 'innodb_file_format_max' can't be set to the value of 'Salmon' -SET @@global.innodb_file_format_max = @start_global_value; -SELECT @@global.innodb_file_format_max; -@@global.innodb_file_format_max -Antelope +INNODB_FILE_FORMAT_CHECK ON +SET @@global.innodb_file_format_check='Off'; +ERROR HY000: Variable 'innodb_file_format_check' is a read only variable +Expected error 'Read only variable' +SET @@global.innodb_file_format_check=1; +ERROR HY000: Variable 'innodb_file_format_check' is a read only variable +Expected error 'Read only variable' +SET @@global.innodb_file_format_check=0; +ERROR HY000: Variable 'innodb_file_format_check' is a read only variable +Expected error 'Read only variable' +SET @@global.innodb_file_format_check='On'; +ERROR HY000: Variable 'innodb_file_format_check' is a read only variable +Expected error 'Read only variable' +SET session innodb_large_prefix='OFF'; +ERROR HY000: Variable 'innodb_large_prefix' is a GLOBAL variable and should be set with SET GLOBAL +SET @@session.innodb_stats_on_metadata='ON'; +ERROR HY000: Variable 'innodb_stats_on_metadata' is a GLOBAL variable and should be set with SET GLOBAL +SELECT IF(@@GLOBAL.innodb_file_format_check, "ON", "OFF") = VARIABLE_VALUE +FROM INFORMATION_SCHEMA.GLOBAL_VARIABLES +WHERE VARIABLE_NAME='innodb_file_format_check'; +IF(@@GLOBAL.innodb_file_format_check, "ON", "OFF") = VARIABLE_VALUE +1 +1 Expected +SELECT COUNT(@@GLOBAL.innodb_file_format_check); +COUNT(@@GLOBAL.innodb_file_format_check) +1 +1 Expected +SELECT COUNT(VARIABLE_VALUE) +FROM INFORMATION_SCHEMA.GLOBAL_VARIABLES +WHERE VARIABLE_NAME='innodb_file_format_check'; +COUNT(VARIABLE_VALUE) +1 +1 Expected +SELECT @@innodb_file_format_check = @@GLOBAL.innodb_file_format_check; +@@innodb_file_format_check = @@GLOBAL.innodb_file_format_check +1 +1 Expected +SELECT COUNT(@@innodb_file_format_check); +COUNT(@@innodb_file_format_check) +1 +1 Expected +SELECT COUNT(@@local.innodb_file_format_check); +ERROR HY000: Variable 'innodb_file_format_check' is a GLOBAL variable +Expected error 'Variable is a GLOBAL variable' +SELECT COUNT(@@SESSION.innodb_file_format_check); +ERROR HY000: Variable 'innodb_file_format_check' is a GLOBAL variable +Expected error 'Variable is a GLOBAL variable' +SELECT COUNT(@@GLOBAL.innodb_file_format_check); +COUNT(@@GLOBAL.innodb_file_format_check) +1 +1 Expected +SELECT innodb_file_format_check = @@SESSION.innodb_file_format_check; +ERROR 42S22: Unknown column 'innodb_file_format_check' in 'field list' +Expected error 'Readonly variable' diff --git a/mysql-test/suite/sys_vars/r/innodb_file_format_max_basic.result b/mysql-test/suite/sys_vars/r/innodb_file_format_max_basic.result index d9d067c2cf9..32b2262c091 100644 --- a/mysql-test/suite/sys_vars/r/innodb_file_format_max_basic.result +++ b/mysql-test/suite/sys_vars/r/innodb_file_format_max_basic.result @@ -1 +1,65 @@ -XtraDB extension +SET @start_global_value = @@global.innodb_file_format_max; +SELECT @start_global_value; +@start_global_value +Antelope +Valid values are 'Antelope' and 'Barracuda' +SELECT @@global.innodb_file_format_max in ('Antelope', 'Barracuda'); +@@global.innodb_file_format_max in ('Antelope', 'Barracuda') +1 +SELECT @@global.innodb_file_format_max; +@@global.innodb_file_format_max +Antelope +SELECT @@session.innodb_file_format_max; +ERROR HY000: Variable 'innodb_file_format_max' is a GLOBAL variable +SHOW global variables LIKE 'innodb_file_format_max'; +Variable_name Value +innodb_file_format_max Antelope +SHOW session variables LIKE 'innodb_file_format_max'; +Variable_name Value +innodb_file_format_max Antelope +SELECT * FROM information_schema.global_variables +WHERE variable_name='innodb_file_format_max'; +VARIABLE_NAME VARIABLE_VALUE +INNODB_FILE_FORMAT_MAX Antelope +SELECT * FROM information_schema.session_variables +WHERE variable_name='innodb_file_format_max'; +VARIABLE_NAME VARIABLE_VALUE +INNODB_FILE_FORMAT_MAX Antelope +SET global innodb_file_format_max='Antelope'; +SELECT @@global.innodb_file_format_max; +@@global.innodb_file_format_max +Antelope +SELECT * FROM information_schema.global_variables +WHERE variable_name='innodb_file_format_max'; +VARIABLE_NAME VARIABLE_VALUE +INNODB_FILE_FORMAT_MAX Antelope +SELECT * FROM information_schema.session_variables +WHERE variable_name='innodb_file_format_max'; +VARIABLE_NAME VARIABLE_VALUE +INNODB_FILE_FORMAT_MAX Antelope +SET @@global.innodb_file_format_max='Barracuda'; +SELECT @@global.innodb_file_format_max; +@@global.innodb_file_format_max +Barracuda +SELECT * FROM information_schema.global_variables +WHERE variable_name='innodb_file_format_max'; +VARIABLE_NAME VARIABLE_VALUE +INNODB_FILE_FORMAT_MAX Barracuda +SELECT * FROM information_schema.session_variables +WHERE variable_name='innodb_file_format_max'; +VARIABLE_NAME VARIABLE_VALUE +INNODB_FILE_FORMAT_MAX Barracuda +SET session innodb_file_format_max='Salmon'; +ERROR HY000: Variable 'innodb_file_format_max' is a GLOBAL variable and should be set with SET GLOBAL +SET @@session.innodb_file_format_max='Salmon'; +ERROR HY000: Variable 'innodb_file_format_max' is a GLOBAL variable and should be set with SET GLOBAL +SET global innodb_file_format_max=1.1; +ERROR 42000: Incorrect argument type to variable 'innodb_file_format_max' +SET global innodb_file_format_max=1e1; +ERROR 42000: Incorrect argument type to variable 'innodb_file_format_max' +SET global innodb_file_format_max='Salmon'; +ERROR 42000: Variable 'innodb_file_format_max' can't be set to the value of 'Salmon' +SET @@global.innodb_file_format_max = @start_global_value; +SELECT @@global.innodb_file_format_max; +@@global.innodb_file_format_max +Antelope diff --git a/mysql-test/suite/sys_vars/r/innodb_file_per_table_basic.result b/mysql-test/suite/sys_vars/r/innodb_file_per_table_basic.result index 163eb31f686..ecf11351cd9 100644 --- a/mysql-test/suite/sys_vars/r/innodb_file_per_table_basic.result +++ b/mysql-test/suite/sys_vars/r/innodb_file_per_table_basic.result @@ -1,13 +1,29 @@ +SET @start_global_value = @@global.innodb_file_per_table; +SELECT @start_global_value; +@start_global_value +0 '#---------------------BS_STVARS_028_01----------------------#' SELECT COUNT(@@GLOBAL.innodb_file_per_table); COUNT(@@GLOBAL.innodb_file_per_table) 1 1 Expected '#---------------------BS_STVARS_028_02----------------------#' -SELECT COUNT(@@GLOBAL.innodb_file_per_table); -COUNT(@@GLOBAL.innodb_file_per_table) +SET @@global.innodb_file_per_table = 0; +SELECT @@global.innodb_file_per_table; +@@global.innodb_file_per_table +0 +SET @@global.innodb_file_per_table ='On' ; +SELECT @@global.innodb_file_per_table; +@@global.innodb_file_per_table +1 +SET @@global.innodb_file_per_table ='Off' ; +SELECT @@global.innodb_file_per_table; +@@global.innodb_file_per_table +0 +SET @@global.innodb_file_per_table = 1; +SELECT @@global.innodb_file_per_table; +@@global.innodb_file_per_table 1 -1 Expected '#---------------------BS_STVARS_028_03----------------------#' SELECT IF(@@GLOBAL.innodb_file_per_table,'ON','OFF') = VARIABLE_VALUE FROM INFORMATION_SCHEMA.GLOBAL_VARIABLES @@ -47,4 +63,7 @@ COUNT(@@GLOBAL.innodb_file_per_table) 1 Expected SELECT innodb_file_per_table = @@SESSION.innodb_file_per_table; ERROR 42S22: Unknown column 'innodb_file_per_table' in 'field list' -Expected error 'Readonly variable' +SET @@global.innodb_file_per_table = @start_global_value; +SELECT @@global.innodb_file_per_table; +@@global.innodb_file_per_table +0 diff --git a/mysql-test/suite/sys_vars/r/innodb_force_load_corrupted_basic.result b/mysql-test/suite/sys_vars/r/innodb_force_load_corrupted_basic.result new file mode 100644 index 00000000000..bc9b7019eb8 --- /dev/null +++ b/mysql-test/suite/sys_vars/r/innodb_force_load_corrupted_basic.result @@ -0,0 +1,53 @@ +'#---------------------BS_STVARS_031_01----------------------#' +SELECT COUNT(@@GLOBAL.innodb_force_load_corrupted); +COUNT(@@GLOBAL.innodb_force_load_corrupted) +1 +1 Expected +'#---------------------BS_STVARS_031_02----------------------#' +SET @@GLOBAL.innodb_force_load_corrupted=1; +ERROR HY000: Variable 'innodb_force_load_corrupted' is a read only variable +Expected error 'Read only variable' +SELECT COUNT(@@GLOBAL.innodb_force_load_corrupted); +COUNT(@@GLOBAL.innodb_force_load_corrupted) +1 +1 Expected +'#---------------------BS_STVARS_031_03----------------------#' +SELECT IF(@@GLOBAL.innodb_force_load_corrupted, "ON", "OFF") = VARIABLE_VALUE +FROM INFORMATION_SCHEMA.GLOBAL_VARIABLES +WHERE VARIABLE_NAME='innodb_force_load_corrupted'; +IF(@@GLOBAL.innodb_force_load_corrupted, "ON", "OFF") = VARIABLE_VALUE +1 +1 Expected +SELECT COUNT(@@GLOBAL.innodb_force_load_corrupted); +COUNT(@@GLOBAL.innodb_force_load_corrupted) +1 +1 Expected +SELECT COUNT(VARIABLE_VALUE) +FROM INFORMATION_SCHEMA.GLOBAL_VARIABLES +WHERE VARIABLE_NAME='innodb_force_load_corrupted'; +COUNT(VARIABLE_VALUE) +1 +1 Expected +'#---------------------BS_STVARS_031_04----------------------#' +SELECT @@innodb_force_load_corrupted = @@GLOBAL.innodb_force_load_corrupted; +@@innodb_force_load_corrupted = @@GLOBAL.innodb_force_load_corrupted +1 +1 Expected +'#---------------------BS_STVARS_031_05----------------------#' +SELECT COUNT(@@innodb_force_load_corrupted); +COUNT(@@innodb_force_load_corrupted) +1 +1 Expected +SELECT COUNT(@@local.innodb_force_load_corrupted); +ERROR HY000: Variable 'innodb_force_load_corrupted' is a GLOBAL variable +Expected error 'Variable is a GLOBAL variable' +SELECT COUNT(@@SESSION.innodb_force_load_corrupted); +ERROR HY000: Variable 'innodb_force_load_corrupted' is a GLOBAL variable +Expected error 'Variable is a GLOBAL variable' +SELECT COUNT(@@GLOBAL.innodb_force_load_corrupted); +COUNT(@@GLOBAL.innodb_force_load_corrupted) +1 +1 Expected +SELECT innodb_force_load_corrupted = @@SESSION.innodb_force_load_corrupted; +ERROR 42S22: Unknown column 'innodb_force_load_corrupted' in 'field list' +Expected error 'Readonly variable' diff --git a/mysql-test/suite/sys_vars/r/innodb_large_prefix_basic.result b/mysql-test/suite/sys_vars/r/innodb_large_prefix_basic.result index d9d067c2cf9..adb56b347cd 100644 --- a/mysql-test/suite/sys_vars/r/innodb_large_prefix_basic.result +++ b/mysql-test/suite/sys_vars/r/innodb_large_prefix_basic.result @@ -1 +1,92 @@ -XtraDB extension +SET @start_global_value = @@global.innodb_large_prefix; +SELECT @start_global_value; +@start_global_value +0 +Valid values are 'ON' and 'OFF' +select @@global.innodb_large_prefix in (0, 1); +@@global.innodb_large_prefix in (0, 1) +1 +select @@global.innodb_large_prefix; +@@global.innodb_large_prefix +0 +select @@session.innodb_large_prefix; +ERROR HY000: Variable 'innodb_large_prefix' is a GLOBAL variable +show global variables like 'innodb_large_prefix'; +Variable_name Value +innodb_large_prefix OFF +show session variables like 'innodb_large_prefix'; +Variable_name Value +innodb_large_prefix OFF +select * from information_schema.global_variables where variable_name='innodb_large_prefix'; +VARIABLE_NAME VARIABLE_VALUE +INNODB_LARGE_PREFIX OFF +select * from information_schema.session_variables where variable_name='innodb_large_prefix'; +VARIABLE_NAME VARIABLE_VALUE +INNODB_LARGE_PREFIX OFF +set global innodb_large_prefix='OFF'; +select @@global.innodb_large_prefix; +@@global.innodb_large_prefix +0 +select * from information_schema.global_variables where variable_name='innodb_large_prefix'; +VARIABLE_NAME VARIABLE_VALUE +INNODB_LARGE_PREFIX OFF +select * from information_schema.session_variables where variable_name='innodb_large_prefix'; +VARIABLE_NAME VARIABLE_VALUE +INNODB_LARGE_PREFIX OFF +set @@global.innodb_large_prefix=1; +select @@global.innodb_large_prefix; +@@global.innodb_large_prefix +1 +select * from information_schema.global_variables where variable_name='innodb_large_prefix'; +VARIABLE_NAME VARIABLE_VALUE +INNODB_LARGE_PREFIX ON +select * from information_schema.session_variables where variable_name='innodb_large_prefix'; +VARIABLE_NAME VARIABLE_VALUE +INNODB_LARGE_PREFIX ON +set global innodb_large_prefix=0; +select @@global.innodb_large_prefix; +@@global.innodb_large_prefix +0 +select * from information_schema.global_variables where variable_name='innodb_large_prefix'; +VARIABLE_NAME VARIABLE_VALUE +INNODB_LARGE_PREFIX OFF +select * from information_schema.session_variables where variable_name='innodb_large_prefix'; +VARIABLE_NAME VARIABLE_VALUE +INNODB_LARGE_PREFIX OFF +set @@global.innodb_large_prefix='ON'; +select @@global.innodb_large_prefix; +@@global.innodb_large_prefix +1 +select * from information_schema.global_variables where variable_name='innodb_large_prefix'; +VARIABLE_NAME VARIABLE_VALUE +INNODB_LARGE_PREFIX ON +select * from information_schema.session_variables where variable_name='innodb_large_prefix'; +VARIABLE_NAME VARIABLE_VALUE +INNODB_LARGE_PREFIX ON +set session innodb_large_prefix='OFF'; +ERROR HY000: Variable 'innodb_large_prefix' is a GLOBAL variable and should be set with SET GLOBAL +set @@session.innodb_large_prefix='ON'; +ERROR HY000: Variable 'innodb_large_prefix' is a GLOBAL variable and should be set with SET GLOBAL +set global innodb_large_prefix=1.1; +ERROR 42000: Incorrect argument type to variable 'innodb_large_prefix' +set global innodb_large_prefix=1e1; +ERROR 42000: Incorrect argument type to variable 'innodb_large_prefix' +set global innodb_large_prefix=2; +ERROR 42000: Variable 'innodb_large_prefix' can't be set to the value of '2' +NOTE: The following should fail with ER_WRONG_VALUE_FOR_VAR (BUG#50643) +set global innodb_large_prefix=-3; +select @@global.innodb_large_prefix; +@@global.innodb_large_prefix +1 +select * from information_schema.global_variables where variable_name='innodb_large_prefix'; +VARIABLE_NAME VARIABLE_VALUE +INNODB_LARGE_PREFIX ON +select * from information_schema.session_variables where variable_name='innodb_large_prefix'; +VARIABLE_NAME VARIABLE_VALUE +INNODB_LARGE_PREFIX ON +set global innodb_large_prefix='AUTO'; +ERROR 42000: Variable 'innodb_large_prefix' can't be set to the value of 'AUTO' +SET @@global.innodb_large_prefix = @start_global_value; +SELECT @@global.innodb_large_prefix; +@@global.innodb_large_prefix +0 diff --git a/mysql-test/suite/sys_vars/r/innodb_lock_wait_timeout_basic.result b/mysql-test/suite/sys_vars/r/innodb_lock_wait_timeout_basic.result index 89960e5860f..1dcc2d554ce 100644 --- a/mysql-test/suite/sys_vars/r/innodb_lock_wait_timeout_basic.result +++ b/mysql-test/suite/sys_vars/r/innodb_lock_wait_timeout_basic.result @@ -1,13 +1,21 @@ +SET @start_global_value=@@global.innodb_lock_wait_timeout; +SELECT @start_global_value; +@start_global_value +50 '#---------------------BS_STVARS_032_01----------------------#' SELECT COUNT(@@GLOBAL.innodb_lock_wait_timeout); COUNT(@@GLOBAL.innodb_lock_wait_timeout) 1 1 Expected '#---------------------BS_STVARS_032_02----------------------#' -SELECT COUNT(@@GLOBAL.innodb_lock_wait_timeout); -COUNT(@@GLOBAL.innodb_lock_wait_timeout) -1 -1 Expected +SET global innodb_lock_wait_timeout=60; +SELECT @@global.innodb_lock_wait_timeout; +@@global.innodb_lock_wait_timeout +60 +SET session innodb_lock_wait_timeout=60; +SELECT @@session.innodb_lock_wait_timeout; +@@session.innodb_lock_wait_timeout +60 '#---------------------BS_STVARS_032_03----------------------#' SELECT @@GLOBAL.innodb_lock_wait_timeout = VARIABLE_VALUE FROM INFORMATION_SCHEMA.GLOBAL_VARIABLES @@ -47,4 +55,7 @@ COUNT(@@GLOBAL.innodb_lock_wait_timeout) 1 Expected SELECT innodb_lock_wait_timeout = @@SESSION.innodb_lock_wait_timeout; ERROR 42S22: Unknown column 'innodb_lock_wait_timeout' in 'field list' -Expected error 'Readonly variable' +SET @@global.innodb_lock_wait_timeout = @start_global_value; +SELECT @@global.innodb_lock_wait_timeout; +@@global.innodb_lock_wait_timeout +50 diff --git a/mysql-test/suite/sys_vars/r/innodb_random_read_ahead_basic.result b/mysql-test/suite/sys_vars/r/innodb_random_read_ahead_basic.result new file mode 100644 index 00000000000..d627aa92ba7 --- /dev/null +++ b/mysql-test/suite/sys_vars/r/innodb_random_read_ahead_basic.result @@ -0,0 +1,92 @@ +SET @start_global_value = @@global.innodb_random_read_ahead; +SELECT @start_global_value; +@start_global_value +0 +Valid values are 'ON' and 'OFF' +select @@global.innodb_random_read_ahead in (0, 1); +@@global.innodb_random_read_ahead in (0, 1) +1 +select @@global.innodb_random_read_ahead; +@@global.innodb_random_read_ahead +0 +select @@session.innodb_random_read_ahead; +ERROR HY000: Variable 'innodb_random_read_ahead' is a GLOBAL variable +show global variables like 'innodb_random_read_ahead'; +Variable_name Value +innodb_random_read_ahead OFF +show session variables like 'innodb_random_read_ahead'; +Variable_name Value +innodb_random_read_ahead OFF +select * from information_schema.global_variables where variable_name='innodb_random_read_ahead'; +VARIABLE_NAME VARIABLE_VALUE +INNODB_RANDOM_READ_AHEAD OFF +select * from information_schema.session_variables where variable_name='innodb_random_read_ahead'; +VARIABLE_NAME VARIABLE_VALUE +INNODB_RANDOM_READ_AHEAD OFF +set global innodb_random_read_ahead='ON'; +select @@global.innodb_random_read_ahead; +@@global.innodb_random_read_ahead +1 +select * from information_schema.global_variables where variable_name='innodb_random_read_ahead'; +VARIABLE_NAME VARIABLE_VALUE +INNODB_RANDOM_READ_AHEAD ON +select * from information_schema.session_variables where variable_name='innodb_random_read_ahead'; +VARIABLE_NAME VARIABLE_VALUE +INNODB_RANDOM_READ_AHEAD ON +set @@global.innodb_random_read_ahead=0; +select @@global.innodb_random_read_ahead; +@@global.innodb_random_read_ahead +0 +select * from information_schema.global_variables where variable_name='innodb_random_read_ahead'; +VARIABLE_NAME VARIABLE_VALUE +INNODB_RANDOM_READ_AHEAD OFF +select * from information_schema.session_variables where variable_name='innodb_random_read_ahead'; +VARIABLE_NAME VARIABLE_VALUE +INNODB_RANDOM_READ_AHEAD OFF +set global innodb_random_read_ahead=1; +select @@global.innodb_random_read_ahead; +@@global.innodb_random_read_ahead +1 +select * from information_schema.global_variables where variable_name='innodb_random_read_ahead'; +VARIABLE_NAME VARIABLE_VALUE +INNODB_RANDOM_READ_AHEAD ON +select * from information_schema.session_variables where variable_name='innodb_random_read_ahead'; +VARIABLE_NAME VARIABLE_VALUE +INNODB_RANDOM_READ_AHEAD ON +set @@global.innodb_random_read_ahead='OFF'; +select @@global.innodb_random_read_ahead; +@@global.innodb_random_read_ahead +0 +select * from information_schema.global_variables where variable_name='innodb_random_read_ahead'; +VARIABLE_NAME VARIABLE_VALUE +INNODB_RANDOM_READ_AHEAD OFF +select * from information_schema.session_variables where variable_name='innodb_random_read_ahead'; +VARIABLE_NAME VARIABLE_VALUE +INNODB_RANDOM_READ_AHEAD OFF +set session innodb_random_read_ahead='OFF'; +ERROR HY000: Variable 'innodb_random_read_ahead' is a GLOBAL variable and should be set with SET GLOBAL +set @@session.innodb_random_read_ahead='ON'; +ERROR HY000: Variable 'innodb_random_read_ahead' is a GLOBAL variable and should be set with SET GLOBAL +set global innodb_random_read_ahead=1.1; +ERROR 42000: Incorrect argument type to variable 'innodb_random_read_ahead' +set global innodb_random_read_ahead=1e1; +ERROR 42000: Incorrect argument type to variable 'innodb_random_read_ahead' +set global innodb_random_read_ahead=2; +ERROR 42000: Variable 'innodb_random_read_ahead' can't be set to the value of '2' +NOTE: The following should fail with ER_WRONG_VALUE_FOR_VAR (BUG#50643) +set global innodb_random_read_ahead=-3; +select @@global.innodb_random_read_ahead; +@@global.innodb_random_read_ahead +1 +select * from information_schema.global_variables where variable_name='innodb_random_read_ahead'; +VARIABLE_NAME VARIABLE_VALUE +INNODB_RANDOM_READ_AHEAD ON +select * from information_schema.session_variables where variable_name='innodb_random_read_ahead'; +VARIABLE_NAME VARIABLE_VALUE +INNODB_RANDOM_READ_AHEAD ON +set global innodb_random_read_ahead='AUTO'; +ERROR 42000: Variable 'innodb_random_read_ahead' can't be set to the value of 'AUTO' +SET @@global.innodb_random_read_ahead = @start_global_value; +SELECT @@global.innodb_random_read_ahead; +@@global.innodb_random_read_ahead +0 diff --git a/mysql-test/suite/sys_vars/r/innodb_rollback_segments_basic.result b/mysql-test/suite/sys_vars/r/innodb_rollback_segments_basic.result index d9d067c2cf9..a8d392eee38 100644 --- a/mysql-test/suite/sys_vars/r/innodb_rollback_segments_basic.result +++ b/mysql-test/suite/sys_vars/r/innodb_rollback_segments_basic.result @@ -1 +1,64 @@ -XtraDB extension +SET @start_global_value = @@global.innodb_rollback_segments; +SELECT @start_global_value; +@start_global_value +128 +Valid values are zero or above +SELECT @@global.innodb_rollback_segments >=0; +@@global.innodb_rollback_segments >=0 +1 +SELECT @@global.innodb_rollback_segments <=128; +@@global.innodb_rollback_segments <=128 +1 +SELECT @@global.innodb_rollback_segments; +@@global.innodb_rollback_segments +128 +SELECT @@session.innodb_rollback_segments; +ERROR HY000: Variable 'innodb_rollback_segments' is a GLOBAL variable +SHOW global variables LIKE 'innodb_rollback_segments'; +Variable_name Value +innodb_rollback_segments 128 +SHOW session variables LIKE 'innodb_rollback_segments'; +Variable_name Value +innodb_rollback_segments 128 +SELECT * FROM information_schema.global_variables +WHERE variable_name='innodb_rollback_segments'; +VARIABLE_NAME VARIABLE_VALUE +INNODB_ROLLBACK_SEGMENTS 128 +SELECT * FROM information_schema.session_variables +WHERE variable_name='innodb_rollback_segments'; +VARIABLE_NAME VARIABLE_VALUE +INNODB_ROLLBACK_SEGMENTS 128 +SET global innodb_rollback_segments=100; +SELECT @@global.innodb_rollback_segments; +@@global.innodb_rollback_segments +100 +SELECT * FROM information_schema.global_variables +WHERE variable_name='innodb_rollback_segments'; +VARIABLE_NAME VARIABLE_VALUE +INNODB_ROLLBACK_SEGMENTS 100 +SELECT * FROM information_schema.session_variables +WHERE variable_name='innodb_rollback_segments'; +VARIABLE_NAME VARIABLE_VALUE +INNODB_ROLLBACK_SEGMENTS 100 +SET session innodb_rollback_segments=1; +ERROR HY000: Variable 'innodb_rollback_segments' is a GLOBAL variable and should be set with SET GLOBAL +SET global innodb_rollback_segments=1.1; +ERROR 42000: Incorrect argument type to variable 'innodb_rollback_segments' +SET global innodb_rollback_segments=1e1; +ERROR 42000: Incorrect argument type to variable 'innodb_rollback_segments' +SET global innodb_rollback_segments="foo"; +ERROR 42000: Incorrect argument type to variable 'innodb_rollback_segments' +SET global innodb_rollback_segments=-7; +Warnings: +Warning 1292 Truncated incorrect innodb_rollback_segments value: '-7' +SELECT @@global.innodb_rollback_segments; +@@global.innodb_rollback_segments +1 +SELECT * FROM information_schema.global_variables +WHERE variable_name='innodb_rollback_segments'; +VARIABLE_NAME VARIABLE_VALUE +INNODB_ROLLBACK_SEGMENTS 1 +SET @@global.innodb_rollback_segments = @start_global_value; +SELECT @@global.innodb_rollback_segments; +@@global.innodb_rollback_segments +128 diff --git a/mysql-test/suite/sys_vars/r/innodb_stats_method_basic.result b/mysql-test/suite/sys_vars/r/innodb_stats_method_basic.result index d9d067c2cf9..6599ca9edb6 100644 --- a/mysql-test/suite/sys_vars/r/innodb_stats_method_basic.result +++ b/mysql-test/suite/sys_vars/r/innodb_stats_method_basic.result @@ -1 +1,83 @@ -XtraDB extension +SET @start_global_value = @@global.innodb_stats_method; +SELECT @start_global_value; +@start_global_value +nulls_equal +Valid values are 'nulls_equal', 'nulls_unequal', 'nulls_ignored' +SELECT @@global.innodb_stats_method in ('nulls_equal', 'nulls_unequal', +'nulls_ignored'); +@@global.innodb_stats_method in ('nulls_equal', 'nulls_unequal', +'nulls_ignored') +1 +SELECT @@global.innodb_stats_method; +@@global.innodb_stats_method +nulls_equal +SELECT @@session.innodb_stats_method; +ERROR HY000: Variable 'innodb_stats_method' is a GLOBAL variable +SHOW global variables LIKE 'innodb_stats_method'; +Variable_name Value +innodb_stats_method nulls_equal +SHOW session variables LIKE 'innodb_stats_method'; +Variable_name Value +innodb_stats_method nulls_equal +SELECT * FROM information_schema.global_variables +WHERE variable_name='innodb_stats_method'; +VARIABLE_NAME VARIABLE_VALUE +INNODB_STATS_METHOD nulls_equal +SELECT * FROM information_schema.session_variables +WHERE variable_name='innodb_stats_method'; +VARIABLE_NAME VARIABLE_VALUE +INNODB_STATS_METHOD nulls_equal +SET global innodb_stats_method='nulls_equal'; +SELECT @@global.innodb_stats_method; +@@global.innodb_stats_method +nulls_equal +SELECT * FROM information_schema.global_variables +WHERE variable_name='innodb_stats_method'; +VARIABLE_NAME VARIABLE_VALUE +INNODB_STATS_METHOD nulls_equal +SELECT * FROM information_schema.session_variables +WHERE variable_name='innodb_stats_method'; +VARIABLE_NAME VARIABLE_VALUE +INNODB_STATS_METHOD nulls_equal +SET @@global.innodb_stats_method='nulls_unequal'; +SELECT @@global.innodb_stats_method; +@@global.innodb_stats_method +nulls_unequal +SELECT * FROM information_schema.global_variables +WHERE variable_name='innodb_stats_method'; +VARIABLE_NAME VARIABLE_VALUE +INNODB_STATS_METHOD nulls_unequal +SELECT * FROM information_schema.session_variables +WHERE variable_name='innodb_stats_method'; +VARIABLE_NAME VARIABLE_VALUE +INNODB_STATS_METHOD nulls_unequal +SET global innodb_stats_method=2; +SELECT @@global.innodb_stats_method; +@@global.innodb_stats_method +nulls_ignored +SELECT * FROM information_schema.global_variables +WHERE variable_name='innodb_stats_method'; +VARIABLE_NAME VARIABLE_VALUE +INNODB_STATS_METHOD nulls_ignored +SELECT * FROM information_schema.session_variables +WHERE variable_name='innodb_stats_method'; +VARIABLE_NAME VARIABLE_VALUE +INNODB_STATS_METHOD nulls_ignored +SET session innodb_stats_method='nulls_equal'; +ERROR HY000: Variable 'innodb_stats_method' is a GLOBAL variable and should be set with SET GLOBAL +SET @@session.innodb_stats_method='nulls_ignored'; +ERROR HY000: Variable 'innodb_stats_method' is a GLOBAL variable and should be set with SET GLOBAL +SET global innodb_stats_method=1.1; +ERROR 42000: Incorrect argument type to variable 'innodb_stats_method' +SET global innodb_stats_method=4; +ERROR 42000: Variable 'innodb_stats_method' can't be set to the value of '4' +SET global innodb_stats_method=-2; +ERROR 42000: Variable 'innodb_stats_method' can't be set to the value of '-2' +SET global innodb_stats_method=1e1; +ERROR 42000: Incorrect argument type to variable 'innodb_stats_method' +SET global innodb_stats_method='some'; +ERROR 42000: Variable 'innodb_stats_method' can't be set to the value of 'some' +SET @@global.innodb_stats_method = @start_global_value; +SELECT @@global.innodb_stats_method; +@@global.innodb_stats_method +nulls_equal diff --git a/mysql-test/suite/sys_vars/r/max_join_size_func.result b/mysql-test/suite/sys_vars/r/max_join_size_func.result index bf535579433..0bf4f507b0c 100644 --- a/mysql-test/suite/sys_vars/r/max_join_size_func.result +++ b/mysql-test/suite/sys_vars/r/max_join_size_func.result @@ -41,7 +41,7 @@ id name id name SET @@session.max_join_size=8; ## Since total joins are more than max_join_size value so error will occur ## SELECT * FROM t1 INNER JOIN t2 ON t1.id = t2.id; -ERROR 42000: The SELECT would examine more than MAX_JOIN_SIZE rows; check your WHERE and use SET SQL_BIG_SELECTS=1 or SET SQL_MAX_JOIN_SIZE=# if the SELECT is okay +ERROR 42000: The SELECT would examine more than MAX_JOIN_SIZE rows; check your WHERE and use SET SQL_BIG_SELECTS=1 or SET MAX_JOIN_SIZE=# if the SELECT is okay '#--------------------FN_DYNVARS_079_03-------------------------#' ## Setting global value of variable ## SET @@global.max_join_size=8; @@ -52,7 +52,7 @@ SELECT @@global.max_join_size; 8 ## Since total joins are more than max_join_size value so error will occur ## SELECT * FROM t1 INNER JOIN t2 ON t1.id = t2.id; -ERROR 42000: The SELECT would examine more than MAX_JOIN_SIZE rows; check your WHERE and use SET SQL_BIG_SELECTS=1 or SET SQL_MAX_JOIN_SIZE=# if the SELECT is okay +ERROR 42000: The SELECT would examine more than MAX_JOIN_SIZE rows; check your WHERE and use SET SQL_BIG_SELECTS=1 or SET MAX_JOIN_SIZE=# if the SELECT is okay ## Dropping both the tables ## Drop table t1, t2; ## Restoring values ## diff --git a/mysql-test/suite/sys_vars/r/max_user_connections-2.result b/mysql-test/suite/sys_vars/r/max_user_connections-2.result new file mode 100644 index 00000000000..d9daec5c089 --- /dev/null +++ b/mysql-test/suite/sys_vars/r/max_user_connections-2.result @@ -0,0 +1,2 @@ +set global max_user_connections=100; +ERROR HY000: The MySQL server is running with the --max-user-connections=0 option so it cannot execute this statement diff --git a/mysql-test/suite/sys_vars/r/max_user_connections_basic.result b/mysql-test/suite/sys_vars/r/max_user_connections_basic.result index cc43b631085..c31498c1a66 100644 --- a/mysql-test/suite/sys_vars/r/max_user_connections_basic.result +++ b/mysql-test/suite/sys_vars/r/max_user_connections_basic.result @@ -1,11 +1,11 @@ SET @start_global_value = @@global.max_user_connections; SELECT @start_global_value; @start_global_value -0 +10 SET @start_session_value = @@session.max_user_connections; SELECT @start_session_value; @start_session_value -0 +10 '#--------------------FN_DYNVARS_087_01-------------------------#' SET @@global.max_user_connections = 1000; SET @@global.max_user_connections = DEFAULT; @@ -37,49 +37,47 @@ SET @@global.max_user_connections = 65536; SELECT @@global.max_user_connections; @@global.max_user_connections 65536 -SET @@global.max_user_connections = 4294967295; +SET @@global.max_user_connections = 2147483647; SELECT @@global.max_user_connections; @@global.max_user_connections -4294967295 -SET @@global.max_user_connections = 4294967294; +2147483647 +SET @@global.max_user_connections = 2147483646; SELECT @@global.max_user_connections; @@global.max_user_connections -4294967294 +2147483646 '#------------------FN_DYNVARS_087_05-----------------------#' SET @@global.max_user_connections = -1024; Warnings: Warning 1292 Truncated incorrect max_user_connections value: '-1024' SELECT @@global.max_user_connections; @@global.max_user_connections -0 +-1 SET @@global.max_user_connections = 4294967296; Warnings: Warning 1292 Truncated incorrect max_user_connections value: '4294967296' SELECT @@global.max_user_connections; @@global.max_user_connections -4294967295 +2147483647 SET @@global.max_user_connections = -1; -Warnings: -Warning 1292 Truncated incorrect max_user_connections value: '-1' SELECT @@global.max_user_connections; @@global.max_user_connections -0 +-1 SET @@global.max_user_connections = 429496729500; Warnings: Warning 1292 Truncated incorrect max_user_connections value: '429496729500' SELECT @@global.max_user_connections; @@global.max_user_connections -4294967295 +2147483647 SET @@global.max_user_connections = 65530.34; ERROR 42000: Incorrect argument type to variable 'max_user_connections' SELECT @@global.max_user_connections; @@global.max_user_connections -4294967295 +2147483647 SET @@global.max_user_connections = test; ERROR 42000: Incorrect argument type to variable 'max_user_connections' SELECT @@global.max_user_connections; @@global.max_user_connections -4294967295 +2147483647 '#------------------FN_DYNVARS_087_06-----------------------#' SELECT @@global.max_user_connections = VARIABLE_VALUE FROM INFORMATION_SCHEMA.GLOBAL_VARIABLES @@ -114,4 +112,4 @@ ERROR 42S22: Unknown column 'max_user_connections' in 'field list' SET @@global.max_user_connections = @start_global_value; SELECT @@global.max_user_connections; @@global.max_user_connections -0 +10 diff --git a/mysql-test/suite/sys_vars/r/max_user_connections_func.result b/mysql-test/suite/sys_vars/r/max_user_connections_func.result index 2ff2ac82ce7..04999a0a43f 100644 --- a/mysql-test/suite/sys_vars/r/max_user_connections_func.result +++ b/mysql-test/suite/sys_vars/r/max_user_connections_func.result @@ -2,18 +2,20 @@ SET @default_max_user_connections = @@global.max_user_connections; Set Global max_user_connections=2; +GRANT USAGE on *.* TO test@localhost; '#--------------------FN_DYNVARS_114_01-------------------------#' -** Connecting conn1 using username 'root' ** -** Connecting conn2 using username 'root' ** -** Connecting conn3 using username 'root' ** -ERROR 42000: User root already has more than 'max_user_connections' active connections +** Connecting conn1 using username 'test' ** +** Connecting conn2 using username 'test' ** +** Connecting conn3 using username 'test' ** +ERROR 42000: User test already has more than 'max_user_connections' active connections Expected error "too many connections" ** Disconnecting conn1 ** ** Poll till disconnected conn1 disappears from processlist '#--------------------FN_DYNVARS_114_02-------------------------#' Set Global max_user_connections=3; -** Connecting conn5 using username 'root' ** -** Connecting conn6 using username 'root' ** +** Connecting conn5 using username 'test' ** +** Connecting conn6 using username 'test' ** ** Connection default ** ** Disconnecting conn5, conn6 ** +drop user test@localhost; SET @@global.max_user_connections = @default_max_user_connections; diff --git a/mysql-test/suite/sys_vars/r/optimizer_switch_basic.result b/mysql-test/suite/sys_vars/r/optimizer_switch_basic.result index a56bcc77886..1fa39374f9c 100644 --- a/mysql-test/suite/sys_vars/r/optimizer_switch_basic.result +++ b/mysql-test/suite/sys_vars/r/optimizer_switch_basic.result @@ -1,25 +1,25 @@ SET @start_global_value = @@global.optimizer_switch; SELECT @start_global_value; @start_global_value -index_merge=on,index_merge_union=on,index_merge_sort_union=on,index_merge_intersection=on,index_merge_sort_intersection=off,engine_condition_pushdown=off,index_condition_pushdown=off,derived_merge=off,derived_with_keys=off,firstmatch=off,loosescan=off,materialization=off,in_to_exists=on,semijoin=off,partial_match_rowid_merge=on,partial_match_table_scan=on,subquery_cache=off,mrr=off,mrr_cost_based=off,mrr_sort_keys=off,outer_join_with_cache=off,semijoin_with_cache=off,join_cache_incremental=on,join_cache_hashed=on,join_cache_bka=on,optimize_join_buffer_size=off,table_elimination=on +index_merge=on,index_merge_union=on,index_merge_sort_union=on,index_merge_intersection=on,index_merge_sort_intersection=off,engine_condition_pushdown=off,index_condition_pushdown=off,derived_merge=off,derived_with_keys=off,firstmatch=on,loosescan=on,materialization=off,in_to_exists=on,semijoin=on,partial_match_rowid_merge=on,partial_match_table_scan=on,subquery_cache=on,mrr=off,mrr_cost_based=off,mrr_sort_keys=off,outer_join_with_cache=off,semijoin_with_cache=off,join_cache_incremental=on,join_cache_hashed=on,join_cache_bka=on,optimize_join_buffer_size=off,table_elimination=on select @@global.optimizer_switch; @@global.optimizer_switch -index_merge=on,index_merge_union=on,index_merge_sort_union=on,index_merge_intersection=on,index_merge_sort_intersection=off,engine_condition_pushdown=off,index_condition_pushdown=off,derived_merge=off,derived_with_keys=off,firstmatch=off,loosescan=off,materialization=off,in_to_exists=on,semijoin=off,partial_match_rowid_merge=on,partial_match_table_scan=on,subquery_cache=off,mrr=off,mrr_cost_based=off,mrr_sort_keys=off,outer_join_with_cache=off,semijoin_with_cache=off,join_cache_incremental=on,join_cache_hashed=on,join_cache_bka=on,optimize_join_buffer_size=off,table_elimination=on +index_merge=on,index_merge_union=on,index_merge_sort_union=on,index_merge_intersection=on,index_merge_sort_intersection=off,engine_condition_pushdown=off,index_condition_pushdown=off,derived_merge=off,derived_with_keys=off,firstmatch=on,loosescan=on,materialization=off,in_to_exists=on,semijoin=on,partial_match_rowid_merge=on,partial_match_table_scan=on,subquery_cache=on,mrr=off,mrr_cost_based=off,mrr_sort_keys=off,outer_join_with_cache=off,semijoin_with_cache=off,join_cache_incremental=on,join_cache_hashed=on,join_cache_bka=on,optimize_join_buffer_size=off,table_elimination=on select @@session.optimizer_switch; @@session.optimizer_switch -index_merge=on,index_merge_union=on,index_merge_sort_union=on,index_merge_intersection=on,index_merge_sort_intersection=off,engine_condition_pushdown=off,index_condition_pushdown=off,derived_merge=off,derived_with_keys=off,firstmatch=off,loosescan=off,materialization=off,in_to_exists=on,semijoin=off,partial_match_rowid_merge=on,partial_match_table_scan=on,subquery_cache=off,mrr=off,mrr_cost_based=off,mrr_sort_keys=off,outer_join_with_cache=off,semijoin_with_cache=off,join_cache_incremental=on,join_cache_hashed=on,join_cache_bka=on,optimize_join_buffer_size=off,table_elimination=on +index_merge=on,index_merge_union=on,index_merge_sort_union=on,index_merge_intersection=on,index_merge_sort_intersection=off,engine_condition_pushdown=off,index_condition_pushdown=off,derived_merge=off,derived_with_keys=off,firstmatch=on,loosescan=on,materialization=off,in_to_exists=on,semijoin=on,partial_match_rowid_merge=on,partial_match_table_scan=on,subquery_cache=on,mrr=off,mrr_cost_based=off,mrr_sort_keys=off,outer_join_with_cache=off,semijoin_with_cache=off,join_cache_incremental=on,join_cache_hashed=on,join_cache_bka=on,optimize_join_buffer_size=off,table_elimination=on show global variables like 'optimizer_switch'; Variable_name Value -optimizer_switch index_merge=on,index_merge_union=on,index_merge_sort_union=on,index_merge_intersection=on,index_merge_sort_intersection=off,engine_condition_pushdown=off,index_condition_pushdown=off,derived_merge=off,derived_with_keys=off,firstmatch=off,loosescan=off,materialization=off,in_to_exists=on,semijoin=off,partial_match_rowid_merge=on,partial_match_table_scan=on,subquery_cache=off,mrr=off,mrr_cost_based=off,mrr_sort_keys=off,outer_join_with_cache=off,semijoin_with_cache=off,join_cache_incremental=on,join_cache_hashed=on,join_cache_bka=on,optimize_join_buffer_size=off,table_elimination=on +optimizer_switch index_merge=on,index_merge_union=on,index_merge_sort_union=on,index_merge_intersection=on,index_merge_sort_intersection=off,engine_condition_pushdown=off,index_condition_pushdown=off,derived_merge=off,derived_with_keys=off,firstmatch=on,loosescan=on,materialization=off,in_to_exists=on,semijoin=on,partial_match_rowid_merge=on,partial_match_table_scan=on,subquery_cache=on,mrr=off,mrr_cost_based=off,mrr_sort_keys=off,outer_join_with_cache=off,semijoin_with_cache=off,join_cache_incremental=on,join_cache_hashed=on,join_cache_bka=on,optimize_join_buffer_size=off,table_elimination=on show session variables like 'optimizer_switch'; Variable_name Value -optimizer_switch index_merge=on,index_merge_union=on,index_merge_sort_union=on,index_merge_intersection=on,index_merge_sort_intersection=off,engine_condition_pushdown=off,index_condition_pushdown=off,derived_merge=off,derived_with_keys=off,firstmatch=off,loosescan=off,materialization=off,in_to_exists=on,semijoin=off,partial_match_rowid_merge=on,partial_match_table_scan=on,subquery_cache=off,mrr=off,mrr_cost_based=off,mrr_sort_keys=off,outer_join_with_cache=off,semijoin_with_cache=off,join_cache_incremental=on,join_cache_hashed=on,join_cache_bka=on,optimize_join_buffer_size=off,table_elimination=on +optimizer_switch index_merge=on,index_merge_union=on,index_merge_sort_union=on,index_merge_intersection=on,index_merge_sort_intersection=off,engine_condition_pushdown=off,index_condition_pushdown=off,derived_merge=off,derived_with_keys=off,firstmatch=on,loosescan=on,materialization=off,in_to_exists=on,semijoin=on,partial_match_rowid_merge=on,partial_match_table_scan=on,subquery_cache=on,mrr=off,mrr_cost_based=off,mrr_sort_keys=off,outer_join_with_cache=off,semijoin_with_cache=off,join_cache_incremental=on,join_cache_hashed=on,join_cache_bka=on,optimize_join_buffer_size=off,table_elimination=on select * from information_schema.global_variables where variable_name='optimizer_switch'; VARIABLE_NAME VARIABLE_VALUE -OPTIMIZER_SWITCH index_merge=on,index_merge_union=on,index_merge_sort_union=on,index_merge_intersection=on,index_merge_sort_intersection=off,engine_condition_pushdown=off,index_condition_pushdown=off,derived_merge=off,derived_with_keys=off,firstmatch=off,loosescan=off,materialization=off,in_to_exists=on,semijoin=off,partial_match_rowid_merge=on,partial_match_table_scan=on,subquery_cache=off,mrr=off,mrr_cost_based=off,mrr_sort_keys=off,outer_join_with_cache=off,semijoin_with_cache=off,join_cache_incremental=on,join_cache_hashed=on,join_cache_bka=on,optimize_join_buffer_size=off,table_elimination=on +OPTIMIZER_SWITCH index_merge=on,index_merge_union=on,index_merge_sort_union=on,index_merge_intersection=on,index_merge_sort_intersection=off,engine_condition_pushdown=off,index_condition_pushdown=off,derived_merge=off,derived_with_keys=off,firstmatch=on,loosescan=on,materialization=off,in_to_exists=on,semijoin=on,partial_match_rowid_merge=on,partial_match_table_scan=on,subquery_cache=on,mrr=off,mrr_cost_based=off,mrr_sort_keys=off,outer_join_with_cache=off,semijoin_with_cache=off,join_cache_incremental=on,join_cache_hashed=on,join_cache_bka=on,optimize_join_buffer_size=off,table_elimination=on select * from information_schema.session_variables where variable_name='optimizer_switch'; VARIABLE_NAME VARIABLE_VALUE -OPTIMIZER_SWITCH index_merge=on,index_merge_union=on,index_merge_sort_union=on,index_merge_intersection=on,index_merge_sort_intersection=off,engine_condition_pushdown=off,index_condition_pushdown=off,derived_merge=off,derived_with_keys=off,firstmatch=off,loosescan=off,materialization=off,in_to_exists=on,semijoin=off,partial_match_rowid_merge=on,partial_match_table_scan=on,subquery_cache=off,mrr=off,mrr_cost_based=off,mrr_sort_keys=off,outer_join_with_cache=off,semijoin_with_cache=off,join_cache_incremental=on,join_cache_hashed=on,join_cache_bka=on,optimize_join_buffer_size=off,table_elimination=on +OPTIMIZER_SWITCH index_merge=on,index_merge_union=on,index_merge_sort_union=on,index_merge_intersection=on,index_merge_sort_intersection=off,engine_condition_pushdown=off,index_condition_pushdown=off,derived_merge=off,derived_with_keys=off,firstmatch=on,loosescan=on,materialization=off,in_to_exists=on,semijoin=on,partial_match_rowid_merge=on,partial_match_table_scan=on,subquery_cache=on,mrr=off,mrr_cost_based=off,mrr_sort_keys=off,outer_join_with_cache=off,semijoin_with_cache=off,join_cache_incremental=on,join_cache_hashed=on,join_cache_bka=on,optimize_join_buffer_size=off,table_elimination=on set global optimizer_switch=10; set session optimizer_switch=5; select @@global.optimizer_switch; @@ -63,4 +63,4 @@ ERROR 42000: Variable 'optimizer_switch' can't be set to the value of 'foobar' SET @@global.optimizer_switch = @start_global_value; SELECT @@global.optimizer_switch; @@global.optimizer_switch -index_merge=on,index_merge_union=on,index_merge_sort_union=on,index_merge_intersection=on,index_merge_sort_intersection=off,engine_condition_pushdown=off,index_condition_pushdown=off,derived_merge=off,derived_with_keys=off,firstmatch=off,loosescan=off,materialization=off,in_to_exists=on,semijoin=off,partial_match_rowid_merge=on,partial_match_table_scan=on,subquery_cache=off,mrr=off,mrr_cost_based=off,mrr_sort_keys=off,outer_join_with_cache=off,semijoin_with_cache=off,join_cache_incremental=on,join_cache_hashed=on,join_cache_bka=on,optimize_join_buffer_size=off,table_elimination=on +index_merge=on,index_merge_union=on,index_merge_sort_union=on,index_merge_intersection=on,index_merge_sort_intersection=off,engine_condition_pushdown=off,index_condition_pushdown=off,derived_merge=off,derived_with_keys=off,firstmatch=on,loosescan=on,materialization=off,in_to_exists=on,semijoin=on,partial_match_rowid_merge=on,partial_match_table_scan=on,subquery_cache=on,mrr=off,mrr_cost_based=off,mrr_sort_keys=off,outer_join_with_cache=off,semijoin_with_cache=off,join_cache_incremental=on,join_cache_hashed=on,join_cache_bka=on,optimize_join_buffer_size=off,table_elimination=on diff --git a/mysql-test/suite/sys_vars/r/optimizer_switch_eng_cond_pushdown1.result b/mysql-test/suite/sys_vars/r/optimizer_switch_eng_cond_pushdown1.result new file mode 100644 index 00000000000..ad618c1727f --- /dev/null +++ b/mysql-test/suite/sys_vars/r/optimizer_switch_eng_cond_pushdown1.result @@ -0,0 +1,5 @@ +select @@session.engine_condition_pushdown, +@@global.engine_condition_pushdown, +@@session.optimizer_switch, @@global.optimizer_switch; +@@session.engine_condition_pushdown @@global.engine_condition_pushdown @@session.optimizer_switch @@global.optimizer_switch +1 1 index_merge=on,index_merge_union=on,index_merge_sort_union=on,index_merge_intersection=on,index_merge_sort_intersection=off,engine_condition_pushdown=on,index_condition_pushdown=off,derived_merge=off,derived_with_keys=off,firstmatch=on,loosescan=on,materialization=off,in_to_exists=on,semijoin=on,partial_match_rowid_merge=on,partial_match_table_scan=on,subquery_cache=on,mrr=off,mrr_cost_based=off,mrr_sort_keys=off,outer_join_with_cache=off,semijoin_with_cache=off,join_cache_incremental=on,join_cache_hashed=on,join_cache_bka=on,optimize_join_buffer_size=off,table_elimination=on index_merge=on,index_merge_union=on,index_merge_sort_union=on,index_merge_intersection=on,index_merge_sort_intersection=off,engine_condition_pushdown=on,index_condition_pushdown=off,derived_merge=off,derived_with_keys=off,firstmatch=on,loosescan=on,materialization=off,in_to_exists=on,semijoin=on,partial_match_rowid_merge=on,partial_match_table_scan=on,subquery_cache=on,mrr=off,mrr_cost_based=off,mrr_sort_keys=off,outer_join_with_cache=off,semijoin_with_cache=off,join_cache_incremental=on,join_cache_hashed=on,join_cache_bka=on,optimize_join_buffer_size=off,table_elimination=on diff --git a/mysql-test/suite/sys_vars/r/optimizer_switch_eng_cond_pushdown2.result b/mysql-test/suite/sys_vars/r/optimizer_switch_eng_cond_pushdown2.result new file mode 100644 index 00000000000..daed5b2919c --- /dev/null +++ b/mysql-test/suite/sys_vars/r/optimizer_switch_eng_cond_pushdown2.result @@ -0,0 +1,5 @@ +select @@session.engine_condition_pushdown, +@@global.engine_condition_pushdown, +@@session.optimizer_switch, @@global.optimizer_switch; +@@session.engine_condition_pushdown @@global.engine_condition_pushdown @@session.optimizer_switch @@global.optimizer_switch +0 0 index_merge=on,index_merge_union=on,index_merge_sort_union=on,index_merge_intersection=on,index_merge_sort_intersection=off,engine_condition_pushdown=off,index_condition_pushdown=off,derived_merge=off,derived_with_keys=off,firstmatch=on,loosescan=on,materialization=off,in_to_exists=on,semijoin=on,partial_match_rowid_merge=on,partial_match_table_scan=on,subquery_cache=on,mrr=off,mrr_cost_based=off,mrr_sort_keys=off,outer_join_with_cache=off,semijoin_with_cache=off,join_cache_incremental=on,join_cache_hashed=on,join_cache_bka=on,optimize_join_buffer_size=off,table_elimination=on index_merge=on,index_merge_union=on,index_merge_sort_union=on,index_merge_intersection=on,index_merge_sort_intersection=off,engine_condition_pushdown=off,index_condition_pushdown=off,derived_merge=off,derived_with_keys=off,firstmatch=on,loosescan=on,materialization=off,in_to_exists=on,semijoin=on,partial_match_rowid_merge=on,partial_match_table_scan=on,subquery_cache=on,mrr=off,mrr_cost_based=off,mrr_sort_keys=off,outer_join_with_cache=off,semijoin_with_cache=off,join_cache_incremental=on,join_cache_hashed=on,join_cache_bka=on,optimize_join_buffer_size=off,table_elimination=on diff --git a/mysql-test/suite/sys_vars/r/plugin_dir_basic.result b/mysql-test/suite/sys_vars/r/plugin_dir_basic.result index c18f4cd2a1d..a5f36de73fa 100644 --- a/mysql-test/suite/sys_vars/r/plugin_dir_basic.result +++ b/mysql-test/suite/sys_vars/r/plugin_dir_basic.result @@ -1,20 +1,20 @@ select @@global.plugin_dir; @@global.plugin_dir -MYSQL_LIBDIR/plugins +MYSQL_TMP_DIR select @@session.plugin_dir; ERROR HY000: Variable 'plugin_dir' is a GLOBAL variable show global variables like 'plugin_dir'; Variable_name Value -plugin_dir MYSQL_LIBDIR/plugins +plugin_dir MYSQL_TMP_DIR show session variables like 'plugin_dir'; Variable_name Value -plugin_dir MYSQL_LIBDIR/plugins +plugin_dir MYSQL_TMP_DIR select * from information_schema.global_variables where variable_name='plugin_dir'; VARIABLE_NAME VARIABLE_VALUE -PLUGIN_DIR MYSQL_LIBDIR/plugins +PLUGIN_DIR MYSQL_TMP_DIR select * from information_schema.session_variables where variable_name='plugin_dir'; VARIABLE_NAME VARIABLE_VALUE -PLUGIN_DIR MYSQL_LIBDIR/plugins +PLUGIN_DIR MYSQL_TMP_DIR set global plugin_dir=1; ERROR HY000: Variable 'plugin_dir' is a read only variable set session plugin_dir=1; diff --git a/mysql-test/suite/sys_vars/r/replicate_annotate_row_events_basic.result b/mysql-test/suite/sys_vars/r/replicate_annotate_row_events_basic.result new file mode 100644 index 00000000000..802c92268d6 --- /dev/null +++ b/mysql-test/suite/sys_vars/r/replicate_annotate_row_events_basic.result @@ -0,0 +1,21 @@ +select @@global.replicate_annotate_row_events; +@@global.replicate_annotate_row_events +0 +select @@session.replicate_annotate_row_events; +ERROR HY000: Variable 'replicate_annotate_row_events' is a GLOBAL variable +show global variables like 'replicate_annotate_row_events'; +Variable_name Value +replicate_annotate_row_events OFF +show session variables like 'replicate_annotate_row_events'; +Variable_name Value +replicate_annotate_row_events OFF +select * from information_schema.global_variables where variable_name='replicate_annotate_row_events'; +VARIABLE_NAME VARIABLE_VALUE +REPLICATE_ANNOTATE_ROW_EVENTS OFF +select * from information_schema.session_variables where variable_name='replicate_annotate_row_events'; +VARIABLE_NAME VARIABLE_VALUE +REPLICATE_ANNOTATE_ROW_EVENTS OFF +set global replicate_annotate_row_events=1; +ERROR HY000: Variable 'replicate_annotate_row_events' is a read only variable +set session replicate_annotate_row_events=1; +ERROR HY000: Variable 'replicate_annotate_row_events' is a read only variable diff --git a/mysql-test/suite/sys_vars/r/replicate_annotate_rows_events_basic.result b/mysql-test/suite/sys_vars/r/replicate_annotate_rows_events_basic.result deleted file mode 100644 index ef0d29fad07..00000000000 --- a/mysql-test/suite/sys_vars/r/replicate_annotate_rows_events_basic.result +++ /dev/null @@ -1,21 +0,0 @@ -select @@global.replicate_annotate_rows_events; -@@global.replicate_annotate_rows_events -0 -select @@session.replicate_annotate_rows_events; -ERROR HY000: Variable 'replicate_annotate_rows_events' is a GLOBAL variable -show global variables like 'replicate_annotate_rows_events'; -Variable_name Value -replicate_annotate_rows_events OFF -show session variables like 'replicate_annotate_rows_events'; -Variable_name Value -replicate_annotate_rows_events OFF -select * from information_schema.global_variables where variable_name='replicate_annotate_rows_events'; -VARIABLE_NAME VARIABLE_VALUE -REPLICATE_ANNOTATE_ROWS_EVENTS OFF -select * from information_schema.session_variables where variable_name='replicate_annotate_rows_events'; -VARIABLE_NAME VARIABLE_VALUE -REPLICATE_ANNOTATE_ROWS_EVENTS OFF -set global replicate_annotate_rows_events=1; -ERROR HY000: Variable 'replicate_annotate_rows_events' is a read only variable -set session replicate_annotate_rows_events=1; -ERROR HY000: Variable 'replicate_annotate_rows_events' is a read only variable diff --git a/mysql-test/suite/sys_vars/r/sql_big_selects_func.result b/mysql-test/suite/sys_vars/r/sql_big_selects_func.result index 72631dbb1d5..ceac0ce539d 100644 --- a/mysql-test/suite/sys_vars/r/sql_big_selects_func.result +++ b/mysql-test/suite/sys_vars/r/sql_big_selects_func.result @@ -21,7 +21,7 @@ INSERT INTO t2 VALUES('aa4','bb'); '#--------------------FN_DYNVARS_154_01-------------------------#' Expected error "Too big select" SELECT * FROM t1 INNER JOIN t2 ON t1.a = t2.a; -ERROR 42000: The SELECT would examine more than MAX_JOIN_SIZE rows; check your WHERE and use SET SQL_BIG_SELECTS=1 or SET SQL_MAX_JOIN_SIZE=# if the SELECT is okay +ERROR 42000: The SELECT would examine more than MAX_JOIN_SIZE rows; check your WHERE and use SET SQL_BIG_SELECTS=1 or SET MAX_JOIN_SIZE=# if the SELECT is okay Expected error The SELECT would examine more than MAX_JOIN_SIZE rows. '#--------------------FN_DYNVARS_154_02-------------------------#' SET SESSION SQL_BIG_SELECTS = 1; diff --git a/mysql-test/suite/sys_vars/r/sql_max_join_size_func.result b/mysql-test/suite/sys_vars/r/sql_max_join_size_func.result index 0dc85925c6b..377c2c9c4ca 100644 --- a/mysql-test/suite/sys_vars/r/sql_max_join_size_func.result +++ b/mysql-test/suite/sys_vars/r/sql_max_join_size_func.result @@ -19,7 +19,7 @@ SET SESSION sql_max_join_size=9; Warnings: Warning 1287 The syntax '@@sql_max_join_size' is deprecated and will be removed in MySQL 7.0. Please use '@@max_join_size' instead SELECT * FROM t1 INNER JOIN t2 ON t1.a = t2.a; -ERROR 42000: The SELECT would examine more than MAX_JOIN_SIZE rows; check your WHERE and use SET SQL_BIG_SELECTS=1 or SET SQL_MAX_JOIN_SIZE=# if the SELECT is okay +ERROR 42000: The SELECT would examine more than MAX_JOIN_SIZE rows; check your WHERE and use SET SQL_BIG_SELECTS=1 or SET MAX_JOIN_SIZE=# if the SELECT is okay Expected error The SELECT would examine more than MAX_JOIN_SIZE rows. '#--------------------FN_DYNVARS_161_02-------------------------#' SET SESSION SQL_BIG_SELECTS = 1; diff --git a/mysql-test/suite/sys_vars/t/aria_checkpoint_log_activity_basic.test b/mysql-test/suite/sys_vars/t/aria_checkpoint_log_activity_basic.test new file mode 100644 index 00000000000..9fa5e5e2e2f --- /dev/null +++ b/mysql-test/suite/sys_vars/t/aria_checkpoint_log_activity_basic.test @@ -0,0 +1,43 @@ +# ulong global +--source include/have_maria.inc + +SET @start_global_value = @@global.aria_checkpoint_log_activity; + +# +# exists as global only +# +select @@global.aria_checkpoint_log_activity; +--error ER_INCORRECT_GLOBAL_LOCAL_VAR +select @@session.aria_checkpoint_log_activity; +show global variables like 'aria_checkpoint_log_activity'; +show session variables like 'aria_checkpoint_log_activity'; +select * from information_schema.global_variables where variable_name='aria_checkpoint_log_activity'; +select * from information_schema.session_variables where variable_name='aria_checkpoint_log_activity'; + +# +# show that it's writable +# +set global aria_checkpoint_log_activity=1; +select @@global.aria_checkpoint_log_activity; +--error ER_GLOBAL_VARIABLE +set session aria_checkpoint_log_activity=1; + +# +# incorrect types +# +--error ER_WRONG_TYPE_FOR_VAR +set global aria_checkpoint_log_activity=1.1; +--error ER_WRONG_TYPE_FOR_VAR +set global aria_checkpoint_log_activity=1e1; +--error ER_WRONG_TYPE_FOR_VAR +set global aria_checkpoint_log_activity="foo"; + +# +# min/max values +# +set global aria_checkpoint_log_activity=0; +select @@global.aria_checkpoint_log_activity; +set global aria_checkpoint_log_activity=cast(-1 as unsigned int); +select @@global.aria_checkpoint_log_activity; + +SET @@global.aria_checkpoint_log_activity = @start_global_value; diff --git a/mysql-test/suite/sys_vars/t/binlog_annotate_row_events_basic.test b/mysql-test/suite/sys_vars/t/binlog_annotate_row_events_basic.test new file mode 100644 index 00000000000..9dd3545e1ec --- /dev/null +++ b/mysql-test/suite/sys_vars/t/binlog_annotate_row_events_basic.test @@ -0,0 +1,39 @@ +# bool session + +SET @start_global_value = @@global.binlog_annotate_row_events; + +select @@global.binlog_annotate_row_events; +select @@session.binlog_annotate_row_events; +show global variables like 'binlog_annotate_row_events'; +show session variables like 'binlog_annotate_row_events'; +select * from information_schema.global_variables where variable_name='binlog_annotate_row_events'; +select * from information_schema.session_variables where variable_name='binlog_annotate_row_events'; + +# +# show that it's writable +# +set global binlog_annotate_row_events=ON; +select @@global.binlog_annotate_row_events; +set global binlog_annotate_row_events=OFF; +select @@global.binlog_annotate_row_events; +set global binlog_annotate_row_events=1; +select @@global.binlog_annotate_row_events; + +set session binlog_annotate_row_events=ON; +select @@session.binlog_annotate_row_events; +set session binlog_annotate_row_events=OFF; +select @@session.binlog_annotate_row_events; +set session binlog_annotate_row_events=1; +select @@session.binlog_annotate_row_events; +# +# incorrect types +# +--error ER_WRONG_TYPE_FOR_VAR +set global binlog_annotate_row_events=1.1; +--error ER_WRONG_TYPE_FOR_VAR +set session binlog_annotate_row_events=1e1; +--error ER_WRONG_VALUE_FOR_VAR +set session binlog_annotate_row_events="foo"; + +SET @@global.binlog_annotate_row_events = @start_global_value; + diff --git a/mysql-test/suite/sys_vars/t/binlog_annotate_rows_events_basic.test b/mysql-test/suite/sys_vars/t/binlog_annotate_rows_events_basic.test deleted file mode 100644 index 89bdb0986e5..00000000000 --- a/mysql-test/suite/sys_vars/t/binlog_annotate_rows_events_basic.test +++ /dev/null @@ -1,39 +0,0 @@ -# bool session - -SET @start_global_value = @@global.binlog_annotate_rows_events; - -select @@global.binlog_annotate_rows_events; -select @@session.binlog_annotate_rows_events; -show global variables like 'binlog_annotate_rows_events'; -show session variables like 'binlog_annotate_rows_events'; -select * from information_schema.global_variables where variable_name='binlog_annotate_rows_events'; -select * from information_schema.session_variables where variable_name='binlog_annotate_rows_events'; - -# -# show that it's writable -# -set global binlog_annotate_rows_events=ON; -select @@global.binlog_annotate_rows_events; -set global binlog_annotate_rows_events=OFF; -select @@global.binlog_annotate_rows_events; -set global binlog_annotate_rows_events=1; -select @@global.binlog_annotate_rows_events; - -set session binlog_annotate_rows_events=ON; -select @@session.binlog_annotate_rows_events; -set session binlog_annotate_rows_events=OFF; -select @@session.binlog_annotate_rows_events; -set session binlog_annotate_rows_events=1; -select @@session.binlog_annotate_rows_events; -# -# incorrect types -# ---error ER_WRONG_TYPE_FOR_VAR -set global binlog_annotate_rows_events=1.1; ---error ER_WRONG_TYPE_FOR_VAR -set session binlog_annotate_rows_events=1e1; ---error ER_WRONG_VALUE_FOR_VAR -set session binlog_annotate_rows_events="foo"; - -SET @@global.binlog_annotate_rows_events = @start_global_value; - diff --git a/mysql-test/suite/sys_vars/t/binlog_dbug_fsync_sleep_basic.test b/mysql-test/suite/sys_vars/t/binlog_dbug_fsync_sleep_basic.test deleted file mode 100644 index f4e1161aa07..00000000000 --- a/mysql-test/suite/sys_vars/t/binlog_dbug_fsync_sleep_basic.test +++ /dev/null @@ -1,46 +0,0 @@ -# ulong global - -SET @start_global_value = @@global.binlog_dbug_fsync_sleep; - -# -# exists as global only -# -select @@global.binlog_dbug_fsync_sleep; ---error ER_INCORRECT_GLOBAL_LOCAL_VAR -select @@session.binlog_dbug_fsync_sleep; -show global variables like 'binlog_dbug_fsync_sleep'; -show session variables like 'binlog_dbug_fsync_sleep'; -select * from information_schema.global_variables where variable_name='binlog_dbug_fsync_sleep'; -select * from information_schema.session_variables where variable_name='binlog_dbug_fsync_sleep'; - -# -# show that it's writable -# -set global binlog_dbug_fsync_sleep=200; -select @@global.binlog_dbug_fsync_sleep; ---error ER_GLOBAL_VARIABLE -set session binlog_dbug_fsync_sleep=1; - -# -# incorrect types -# ---error ER_WRONG_TYPE_FOR_VAR -set global binlog_dbug_fsync_sleep=1.1; ---error ER_WRONG_TYPE_FOR_VAR -set global binlog_dbug_fsync_sleep=1e1; ---error ER_WRONG_TYPE_FOR_VAR -set global binlog_dbug_fsync_sleep="foo"; - -# -# min/max values, block size -# -set global binlog_dbug_fsync_sleep=1; -select @@global.binlog_dbug_fsync_sleep; -set global binlog_dbug_fsync_sleep=@@global.binlog_dbug_fsync_sleep + 100 - 1; -select @@global.binlog_dbug_fsync_sleep; -set global binlog_dbug_fsync_sleep=@@global.binlog_dbug_fsync_sleep + 100; -select @@global.binlog_dbug_fsync_sleep; -set global binlog_dbug_fsync_sleep=cast(-1 as unsigned int); -select @@global.binlog_dbug_fsync_sleep; - -SET @@global.binlog_dbug_fsync_sleep = @start_global_value; diff --git a/mysql-test/suite/sys_vars/t/debug_binlog_fsync_sleep_basic.test b/mysql-test/suite/sys_vars/t/debug_binlog_fsync_sleep_basic.test new file mode 100644 index 00000000000..73f61c45623 --- /dev/null +++ b/mysql-test/suite/sys_vars/t/debug_binlog_fsync_sleep_basic.test @@ -0,0 +1,42 @@ +# ulong global + +SET @start_global_value = @@global.debug_binlog_fsync_sleep; + +# +# exists as global only +# +select @@global.debug_binlog_fsync_sleep; +--error ER_INCORRECT_GLOBAL_LOCAL_VAR +select @@session.debug_binlog_fsync_sleep; +show global variables like 'debug_binlog_fsync_sleep'; +show session variables like 'debug_binlog_fsync_sleep'; +select * from information_schema.global_variables where variable_name='debug_binlog_fsync_sleep'; +select * from information_schema.session_variables where variable_name='debug_binlog_fsync_sleep'; + +# +# show that it's writable +# +set global debug_binlog_fsync_sleep=20; +select @@global.debug_binlog_fsync_sleep; +--error ER_GLOBAL_VARIABLE +set session debug_binlog_fsync_sleep=1; + +# +# incorrect types +# +--error ER_WRONG_TYPE_FOR_VAR +set global debug_binlog_fsync_sleep=1.1; +--error ER_WRONG_TYPE_FOR_VAR +set global debug_binlog_fsync_sleep=1e1; +--error ER_WRONG_TYPE_FOR_VAR +set global debug_binlog_fsync_sleep="foo"; + +# +# min/max values, block size +# +set global debug_binlog_fsync_sleep=0; +select @@global.debug_binlog_fsync_sleep; +set global debug_binlog_fsync_sleep=cast(-1 as unsigned int); +select @@global.debug_binlog_fsync_sleep; + +SET @@global.debug_binlog_fsync_sleep = @start_global_value; diff --git a/mysql-test/suite/sys_vars/t/debug_crc_break_basic.test b/mysql-test/suite/sys_vars/t/debug_crc_break_basic.test index f7d17a8e5ad..6e37a47c5b8 100644 --- a/mysql-test/suite/sys_vars/t/debug_crc_break_basic.test +++ b/mysql-test/suite/sys_vars/t/debug_crc_break_basic.test @@ -1,3 +1,4 @@ +--source include/have_debug.inc # ulong global SET @start_global_value = @@global.debug_crc_break; diff --git a/mysql-test/suite/sys_vars/t/disabled.def b/mysql-test/suite/sys_vars/t/disabled.def index 888298bbb09..133754ed6ce 100644 --- a/mysql-test/suite/sys_vars/t/disabled.def +++ b/mysql-test/suite/sys_vars/t/disabled.def @@ -9,3 +9,6 @@ # Do not use any TAB characters for whitespace. # ############################################################################## + +innodb_force_load_corrupted_basic : not in XtraDB (yet?) +innodb_random_read_ahead_basic : not in XtraDB (yet?) diff --git a/mysql-test/suite/sys_vars/t/innodb_autoinc_lock_mode_basic.test b/mysql-test/suite/sys_vars/t/innodb_autoinc_lock_mode_basic.test index 5b6fa943bbe..e07234a9152 100644 --- a/mysql-test/suite/sys_vars/t/innodb_autoinc_lock_mode_basic.test +++ b/mysql-test/suite/sys_vars/t/innodb_autoinc_lock_mode_basic.test @@ -1,8 +1,7 @@ ################# mysql-test\t\innodb_autoinc_lock_mode_basic.test ############ # # # Variable Name: innodb_autoinc_lock_mode # -# Scope: GLOBAL # -# Access Type: Dynamic # +# Access Type: Static # # Data Type: Numeric # # Default Value: 1 # # Range: 0,1,2 # diff --git a/mysql-test/suite/sys_vars/t/innodb_fast_shutdown_basic.test b/mysql-test/suite/sys_vars/t/innodb_fast_shutdown_basic.test index 636309a3088..e1b62046313 100644 --- a/mysql-test/suite/sys_vars/t/innodb_fast_shutdown_basic.test +++ b/mysql-test/suite/sys_vars/t/innodb_fast_shutdown_basic.test @@ -3,9 +3,9 @@ # Variable Name: innodb_fast_shutdown # # Scope: GLOBAL # # Access Type: Dynamic # -# Data Type: boolean # +# Data Type: numeric # # Default Value: 1 # -# Valid Values: 0,1 # +# Valid Values: 0,1,2 # # # # # # Creation Date: 2008-02-20 # diff --git a/mysql-test/suite/sys_vars/t/innodb_file_format_check_basic.test b/mysql-test/suite/sys_vars/t/innodb_file_format_check_basic.test index cbf25af2442..f9f61b9380c 100644 --- a/mysql-test/suite/sys_vars/t/innodb_file_format_check_basic.test +++ b/mysql-test/suite/sys_vars/t/innodb_file_format_check_basic.test @@ -1,55 +1,95 @@ - - -# 2010-01-25 - Added # +# 2011-08-02 - Added +# + --source include/not_embedded.inc --source include/have_innodb.inc -SET @start_global_value = @@global.innodb_file_format_max; +SET @start_global_value = @@global.innodb_file_format_check; SELECT @start_global_value; # # exists as global only # ---echo Valid values are 'Antelope' and 'Barracuda' -select @@global.innodb_file_format_max in ('Antelope', 'Barracuda'); -select @@global.innodb_file_format_max; +--echo Valid values are 'ON' and 'OFF' +SELECT @@global.innodb_file_format_check in (0, 1); +SELECT @@global.innodb_file_format_check; + +--error ER_INCORRECT_GLOBAL_LOCAL_VAR +SELECT @@session.innodb_file_format_check; +SHOW global variables LIKE 'innodb_file_format_check'; +SHOW session variables LIKE 'innodb_file_format_check'; +SELECT * FROM information_schema.global_variables +WHERE variable_name='innodb_file_format_check'; +SELECT * FROM information_schema.session_variables +WHERE variable_name='innodb_file_format_check'; + +# +# show that it's read only +# + +--error ER_INCORRECT_GLOBAL_LOCAL_VAR +SET @@global.innodb_file_format_check='Off'; +--echo Expected error 'Read only variable' + +--error ER_INCORRECT_GLOBAL_LOCAL_VAR +SET @@global.innodb_file_format_check=1; +--echo Expected error 'Read only variable' + --error ER_INCORRECT_GLOBAL_LOCAL_VAR -select @@session.innodb_file_format_max; -show global variables like 'innodb_file_format_max'; -show session variables like 'innodb_file_format_max'; -select * from information_schema.global_variables where variable_name='innodb_file_format_max'; -select * from information_schema.session_variables where variable_name='innodb_file_format_max'; - -# -# show that it's writable -# -set global innodb_file_format_max='Antelope'; -select @@global.innodb_file_format_max; -select * from information_schema.global_variables where variable_name='innodb_file_format_max'; -select * from information_schema.session_variables where variable_name='innodb_file_format_max'; -set @@global.innodb_file_format_max='Barracuda'; -select @@global.innodb_file_format_max; -select * from information_schema.global_variables where variable_name='innodb_file_format_max'; -select * from information_schema.session_variables where variable_name='innodb_file_format_max'; +SET @@global.innodb_file_format_check=0; +--echo Expected error 'Read only variable' + +--error ER_INCORRECT_GLOBAL_LOCAL_VAR +SET @@global.innodb_file_format_check='On'; +--echo Expected error 'Read only variable' + --error ER_GLOBAL_VARIABLE -set session innodb_file_format_max='Salmon'; +SET session innodb_large_prefix='OFF'; --error ER_GLOBAL_VARIABLE -set @@session.innodb_file_format_max='Salmon'; +SET @@session.innodb_stats_on_metadata='ON'; # -# incorrect types +# Check if the value in GLOBAL Table matches value in variable # ---error ER_WRONG_TYPE_FOR_VAR -set global innodb_file_format_max=1.1; ---error ER_WRONG_TYPE_FOR_VAR -set global innodb_file_format_max=1e1; ---error ER_WRONG_VALUE_FOR_VAR -set global innodb_file_format_max='Salmon'; + +SELECT IF(@@GLOBAL.innodb_file_format_check, "ON", "OFF") = VARIABLE_VALUE +FROM INFORMATION_SCHEMA.GLOBAL_VARIABLES +WHERE VARIABLE_NAME='innodb_file_format_check'; +--echo 1 Expected + +SELECT COUNT(@@GLOBAL.innodb_file_format_check); +--echo 1 Expected + +SELECT COUNT(VARIABLE_VALUE) +FROM INFORMATION_SCHEMA.GLOBAL_VARIABLES +WHERE VARIABLE_NAME='innodb_file_format_check'; +--echo 1 Expected # -# Cleanup +# Check if accessing variable with and without GLOBAL point to same variable # +SELECT @@innodb_file_format_check = @@GLOBAL.innodb_file_format_check; +--echo 1 Expected + +# +# Check if innodb_doublewrite can be accessed with and without @@ sign +# + +SELECT COUNT(@@innodb_file_format_check); +--echo 1 Expected + +--Error ER_INCORRECT_GLOBAL_LOCAL_VAR +SELECT COUNT(@@local.innodb_file_format_check); +--echo Expected error 'Variable is a GLOBAL variable' + +--Error ER_INCORRECT_GLOBAL_LOCAL_VAR +SELECT COUNT(@@SESSION.innodb_file_format_check); +--echo Expected error 'Variable is a GLOBAL variable' + +SELECT COUNT(@@GLOBAL.innodb_file_format_check); +--echo 1 Expected -SET @@global.innodb_file_format_max = @start_global_value; -SELECT @@global.innodb_file_format_max; +--Error ER_BAD_FIELD_ERROR +SELECT innodb_file_format_check = @@SESSION.innodb_file_format_check; +--echo Expected error 'Readonly variable' diff --git a/mysql-test/suite/sys_vars/t/innodb_file_format_max_basic-master.opt b/mysql-test/suite/sys_vars/t/innodb_file_format_max_basic-master.opt new file mode 100644 index 00000000000..cef79bc8585 --- /dev/null +++ b/mysql-test/suite/sys_vars/t/innodb_file_format_max_basic-master.opt @@ -0,0 +1 @@ +--force-restart diff --git a/mysql-test/suite/sys_vars/t/innodb_file_format_max_basic.test b/mysql-test/suite/sys_vars/t/innodb_file_format_max_basic.test index 00aa476e8d2..c2cb4cb47bb 100644 --- a/mysql-test/suite/sys_vars/t/innodb_file_format_max_basic.test +++ b/mysql-test/suite/sys_vars/t/innodb_file_format_max_basic.test @@ -1 +1,60 @@ ---echo XtraDB extension +# +# 2011-08-02 - Added +# +--source include/not_embedded.inc +--source include/have_innodb.inc + +SET @start_global_value = @@global.innodb_file_format_max; +SELECT @start_global_value; + +# +# exists as global only +# +--echo Valid values are 'Antelope' and 'Barracuda' +SELECT @@global.innodb_file_format_max in ('Antelope', 'Barracuda'); +SELECT @@global.innodb_file_format_max; +--error ER_INCORRECT_GLOBAL_LOCAL_VAR +SELECT @@session.innodb_file_format_max; +SHOW global variables LIKE 'innodb_file_format_max'; +SHOW session variables LIKE 'innodb_file_format_max'; +SELECT * FROM information_schema.global_variables +WHERE variable_name='innodb_file_format_max'; +SELECT * FROM information_schema.session_variables +WHERE variable_name='innodb_file_format_max'; + +# +# show that it's writable +# +SET global innodb_file_format_max='Antelope'; +SELECT @@global.innodb_file_format_max; +SELECT * FROM information_schema.global_variables +WHERE variable_name='innodb_file_format_max'; +SELECT * FROM information_schema.session_variables +WHERE variable_name='innodb_file_format_max'; +SET @@global.innodb_file_format_max='Barracuda'; +SELECT @@global.innodb_file_format_max; +SELECT * FROM information_schema.global_variables +WHERE variable_name='innodb_file_format_max'; +SELECT * FROM information_schema.session_variables +WHERE variable_name='innodb_file_format_max'; +--error ER_GLOBAL_VARIABLE +SET session innodb_file_format_max='Salmon'; +--error ER_GLOBAL_VARIABLE +SET @@session.innodb_file_format_max='Salmon'; + +# +# incorrect types +# +--error ER_WRONG_TYPE_FOR_VAR +SET global innodb_file_format_max=1.1; +--error ER_WRONG_TYPE_FOR_VAR +SET global innodb_file_format_max=1e1; +--error ER_WRONG_VALUE_FOR_VAR +SET global innodb_file_format_max='Salmon'; + +# +# Cleanup +# + +SET @@global.innodb_file_format_max = @start_global_value; +SELECT @@global.innodb_file_format_max; diff --git a/mysql-test/suite/sys_vars/t/innodb_file_per_table_basic.test b/mysql-test/suite/sys_vars/t/innodb_file_per_table_basic.test index 76a50df8879..1478d6df2e9 100644 --- a/mysql-test/suite/sys_vars/t/innodb_file_per_table_basic.test +++ b/mysql-test/suite/sys_vars/t/innodb_file_per_table_basic.test @@ -4,7 +4,7 @@ # # # Variable Name: innodb_file_per_table # # Scope: Global # -# Access Type: Static # +# Access Type: Dynamic # # Data Type: boolean # # # # # @@ -24,6 +24,10 @@ --source include/have_innodb.inc +SET @start_global_value = @@global.innodb_file_per_table; +SELECT @start_global_value; + + --echo '#---------------------BS_STVARS_028_01----------------------#' #################################################################### # Displaying default value # @@ -37,11 +41,17 @@ SELECT COUNT(@@GLOBAL.innodb_file_per_table); # Check if Value can set # #################################################################### -SELECT COUNT(@@GLOBAL.innodb_file_per_table); ---echo 1 Expected +SET @@global.innodb_file_per_table = 0; +SELECT @@global.innodb_file_per_table; +SET @@global.innodb_file_per_table ='On' ; +SELECT @@global.innodb_file_per_table; +SET @@global.innodb_file_per_table ='Off' ; +SELECT @@global.innodb_file_per_table; +SET @@global.innodb_file_per_table = 1; +SELECT @@global.innodb_file_per_table; --echo '#---------------------BS_STVARS_028_03----------------------#' ################################################################# @@ -93,6 +103,10 @@ SELECT COUNT(@@GLOBAL.innodb_file_per_table); --Error ER_BAD_FIELD_ERROR SELECT innodb_file_per_table = @@SESSION.innodb_file_per_table; ---echo Expected error 'Readonly variable' +# +# Cleanup +# +SET @@global.innodb_file_per_table = @start_global_value; +SELECT @@global.innodb_file_per_table; diff --git a/mysql-test/suite/sys_vars/t/innodb_force_load_corrupted_basic.test b/mysql-test/suite/sys_vars/t/innodb_force_load_corrupted_basic.test new file mode 100644 index 00000000000..1726b320f47 --- /dev/null +++ b/mysql-test/suite/sys_vars/t/innodb_force_load_corrupted_basic.test @@ -0,0 +1,102 @@ + + +################## mysql-test\t\innodb_force_load_corrupted_basic.test ##### +# # +# Variable Name: innodb_force_load_corrupted # +# Scope: Global # +# Access Type: Static # +# Data Type: boolean # +# # +# # +# Creation Date: 2008-02-07 # +# Author : Sharique Abdullah # +# # +# # +# Description:Test Cases of Dynamic System Variable innodb_force_load_corrupted# +# that checks the behavior of this variable in the following ways # +# * Value Check # +# * Scope Check # +# # +# Reference: http://dev.mysql.com/doc/refman/5.1/en/ # +# server-system-variables.html # +# # +############################################################################### + +--source include/have_innodb.inc + +--echo '#---------------------BS_STVARS_031_01----------------------#' +#################################################################### +# Displaying default value # +#################################################################### +SELECT COUNT(@@GLOBAL.innodb_force_load_corrupted); +--echo 1 Expected + + +--echo '#---------------------BS_STVARS_031_02----------------------#' +#################################################################### +# Check if Value can set # +#################################################################### + +--error ER_INCORRECT_GLOBAL_LOCAL_VAR +SET @@GLOBAL.innodb_force_load_corrupted=1; +--echo Expected error 'Read only variable' + +SELECT COUNT(@@GLOBAL.innodb_force_load_corrupted); +--echo 1 Expected + + + + +--echo '#---------------------BS_STVARS_031_03----------------------#' +################################################################# +# Check if the value in GLOBAL Table matches value in variable # +################################################################# + +SELECT IF(@@GLOBAL.innodb_force_load_corrupted, "ON", "OFF") = VARIABLE_VALUE +FROM INFORMATION_SCHEMA.GLOBAL_VARIABLES +WHERE VARIABLE_NAME='innodb_force_load_corrupted'; +--echo 1 Expected + +SELECT COUNT(@@GLOBAL.innodb_force_load_corrupted); +--echo 1 Expected + +SELECT COUNT(VARIABLE_VALUE) +FROM INFORMATION_SCHEMA.GLOBAL_VARIABLES +WHERE VARIABLE_NAME='innodb_force_load_corrupted'; +--echo 1 Expected + + + +--echo '#---------------------BS_STVARS_031_04----------------------#' +################################################################################ +# Check if accessing variable with and without GLOBAL point to same variable # +################################################################################ +SELECT @@innodb_force_load_corrupted = @@GLOBAL.innodb_force_load_corrupted; +--echo 1 Expected + + + +--echo '#---------------------BS_STVARS_031_05----------------------#' +################################################################################ +# Check if innodb_force_load_corrupted can be accessed with and without @@ sign # +################################################################################ + +SELECT COUNT(@@innodb_force_load_corrupted); +--echo 1 Expected + +--Error ER_INCORRECT_GLOBAL_LOCAL_VAR +SELECT COUNT(@@local.innodb_force_load_corrupted); +--echo Expected error 'Variable is a GLOBAL variable' + +--Error ER_INCORRECT_GLOBAL_LOCAL_VAR +SELECT COUNT(@@SESSION.innodb_force_load_corrupted); +--echo Expected error 'Variable is a GLOBAL variable' + +SELECT COUNT(@@GLOBAL.innodb_force_load_corrupted); +--echo 1 Expected + +--Error ER_BAD_FIELD_ERROR +SELECT innodb_force_load_corrupted = @@SESSION.innodb_force_load_corrupted; +--echo Expected error 'Readonly variable' + + diff --git a/mysql-test/suite/sys_vars/t/innodb_io_capacity_basic.test b/mysql-test/suite/sys_vars/t/innodb_io_capacity_basic.test index 3f00b50cf08..0ced5800d4b 100644 --- a/mysql-test/suite/sys_vars/t/innodb_io_capacity_basic.test +++ b/mysql-test/suite/sys_vars/t/innodb_io_capacity_basic.test @@ -54,5 +54,9 @@ select * from information_schema.global_variables where variable_name='innodb_io set global innodb_io_capacity=100; select @@global.innodb_io_capacity; +# +# cleanup +# + SET @@global.innodb_io_capacity = @start_global_value; SELECT @@global.innodb_io_capacity; diff --git a/mysql-test/suite/sys_vars/t/innodb_large_prefix_basic.test b/mysql-test/suite/sys_vars/t/innodb_large_prefix_basic.test index 00aa476e8d2..582e9ffbee8 100644 --- a/mysql-test/suite/sys_vars/t/innodb_large_prefix_basic.test +++ b/mysql-test/suite/sys_vars/t/innodb_large_prefix_basic.test @@ -1 +1,70 @@ ---echo XtraDB extension + + +# 2010-01-25 - Added +# + +--source include/have_innodb.inc + +SET @start_global_value = @@global.innodb_large_prefix; +SELECT @start_global_value; + +# +# exists as global only +# +--echo Valid values are 'ON' and 'OFF' +select @@global.innodb_large_prefix in (0, 1); +select @@global.innodb_large_prefix; +--error ER_INCORRECT_GLOBAL_LOCAL_VAR +select @@session.innodb_large_prefix; +show global variables like 'innodb_large_prefix'; +show session variables like 'innodb_large_prefix'; +select * from information_schema.global_variables where variable_name='innodb_large_prefix'; +select * from information_schema.session_variables where variable_name='innodb_large_prefix'; + +# +# show that it's writable +# +set global innodb_large_prefix='OFF'; +select @@global.innodb_large_prefix; +select * from information_schema.global_variables where variable_name='innodb_large_prefix'; +select * from information_schema.session_variables where variable_name='innodb_large_prefix'; +set @@global.innodb_large_prefix=1; +select @@global.innodb_large_prefix; +select * from information_schema.global_variables where variable_name='innodb_large_prefix'; +select * from information_schema.session_variables where variable_name='innodb_large_prefix'; +set global innodb_large_prefix=0; +select @@global.innodb_large_prefix; +select * from information_schema.global_variables where variable_name='innodb_large_prefix'; +select * from information_schema.session_variables where variable_name='innodb_large_prefix'; +set @@global.innodb_large_prefix='ON'; +select @@global.innodb_large_prefix; +select * from information_schema.global_variables where variable_name='innodb_large_prefix'; +select * from information_schema.session_variables where variable_name='innodb_large_prefix'; +--error ER_GLOBAL_VARIABLE +set session innodb_large_prefix='OFF'; +--error ER_GLOBAL_VARIABLE +set @@session.innodb_large_prefix='ON'; + +# +# incorrect types +# +--error ER_WRONG_TYPE_FOR_VAR +set global innodb_large_prefix=1.1; +--error ER_WRONG_TYPE_FOR_VAR +set global innodb_large_prefix=1e1; +--error ER_WRONG_VALUE_FOR_VAR +set global innodb_large_prefix=2; +--echo NOTE: The following should fail with ER_WRONG_VALUE_FOR_VAR (BUG#50643) +set global innodb_large_prefix=-3; +select @@global.innodb_large_prefix; +select * from information_schema.global_variables where variable_name='innodb_large_prefix'; +select * from information_schema.session_variables where variable_name='innodb_large_prefix'; +--error ER_WRONG_VALUE_FOR_VAR +set global innodb_large_prefix='AUTO'; + +# +# Cleanup +# + +SET @@global.innodb_large_prefix = @start_global_value; +SELECT @@global.innodb_large_prefix; diff --git a/mysql-test/suite/sys_vars/t/innodb_lock_wait_timeout_basic.test b/mysql-test/suite/sys_vars/t/innodb_lock_wait_timeout_basic.test index 8cfd23fd6e7..f80b8e48736 100644 --- a/mysql-test/suite/sys_vars/t/innodb_lock_wait_timeout_basic.test +++ b/mysql-test/suite/sys_vars/t/innodb_lock_wait_timeout_basic.test @@ -3,13 +3,13 @@ ################## mysql-test\t\innodb_lock_wait_timeout_basic.test ########### # # # Variable Name: innodb_lock_wait_timeout # -# Scope: Global # -# Access Type: Static # +# Scope: Global , Session # +# Access Type: Dynamic # # Data Type: numeric # # # # # # Creation Date: 2008-02-07 # -# Author : Sharique Abdullah # +# Author : Sharique Abdullah # # # # # # Description:Test Cases of Dynamic System Variable innodb_lock_wait_timeout # @@ -24,6 +24,9 @@ --source include/have_innodb.inc +SET @start_global_value=@@global.innodb_lock_wait_timeout; +SELECT @start_global_value; + --echo '#---------------------BS_STVARS_032_01----------------------#' #################################################################### # Displaying default value # @@ -37,11 +40,10 @@ SELECT COUNT(@@GLOBAL.innodb_lock_wait_timeout); # Check if Value can set # #################################################################### -SELECT COUNT(@@GLOBAL.innodb_lock_wait_timeout); ---echo 1 Expected - - - +SET global innodb_lock_wait_timeout=60; +SELECT @@global.innodb_lock_wait_timeout; +SET session innodb_lock_wait_timeout=60; +SELECT @@session.innodb_lock_wait_timeout; --echo '#---------------------BS_STVARS_032_03----------------------#' ################################################################# @@ -89,6 +91,10 @@ SELECT COUNT(@@GLOBAL.innodb_lock_wait_timeout); --Error ER_BAD_FIELD_ERROR SELECT innodb_lock_wait_timeout = @@SESSION.innodb_lock_wait_timeout; ---echo Expected error 'Readonly variable' +# +# Cleanup +# +SET @@global.innodb_lock_wait_timeout = @start_global_value; +SELECT @@global.innodb_lock_wait_timeout; diff --git a/mysql-test/suite/sys_vars/t/innodb_max_dirty_pages_pct_basic.test b/mysql-test/suite/sys_vars/t/innodb_max_dirty_pages_pct_basic.test index 38c3acd92a2..7e70ed11351 100644 --- a/mysql-test/suite/sys_vars/t/innodb_max_dirty_pages_pct_basic.test +++ b/mysql-test/suite/sys_vars/t/innodb_max_dirty_pages_pct_basic.test @@ -4,8 +4,8 @@ # Scope: GLOBAL # # Access Type: Dynamic # # Data Type: Numeric # -# Default Value: 90 # -# Range: 0-1000 # +# Default Value: 75 # +# Range: 0-99 # # # # # # Creation Date: 2008-02-07 # diff --git a/mysql-test/suite/sys_vars/t/innodb_random_read_ahead_basic.test b/mysql-test/suite/sys_vars/t/innodb_random_read_ahead_basic.test new file mode 100644 index 00000000000..f78223bad02 --- /dev/null +++ b/mysql-test/suite/sys_vars/t/innodb_random_read_ahead_basic.test @@ -0,0 +1,70 @@ + + +# 2010-01-25 - Added +# + +--source include/have_innodb.inc + +SET @start_global_value = @@global.innodb_random_read_ahead; +SELECT @start_global_value; + +# +# exists as global only +# +--echo Valid values are 'ON' and 'OFF' +select @@global.innodb_random_read_ahead in (0, 1); +select @@global.innodb_random_read_ahead; +--error ER_INCORRECT_GLOBAL_LOCAL_VAR +select @@session.innodb_random_read_ahead; +show global variables like 'innodb_random_read_ahead'; +show session variables like 'innodb_random_read_ahead'; +select * from information_schema.global_variables where variable_name='innodb_random_read_ahead'; +select * from information_schema.session_variables where variable_name='innodb_random_read_ahead'; + +# +# show that it's writable +# +set global innodb_random_read_ahead='ON'; +select @@global.innodb_random_read_ahead; +select * from information_schema.global_variables where variable_name='innodb_random_read_ahead'; +select * from information_schema.session_variables where variable_name='innodb_random_read_ahead'; +set @@global.innodb_random_read_ahead=0; +select @@global.innodb_random_read_ahead; +select * from information_schema.global_variables where variable_name='innodb_random_read_ahead'; +select * from information_schema.session_variables where variable_name='innodb_random_read_ahead'; +set global innodb_random_read_ahead=1; +select @@global.innodb_random_read_ahead; +select * from information_schema.global_variables where variable_name='innodb_random_read_ahead'; +select * from information_schema.session_variables where variable_name='innodb_random_read_ahead'; +set @@global.innodb_random_read_ahead='OFF'; +select @@global.innodb_random_read_ahead; +select * from information_schema.global_variables where variable_name='innodb_random_read_ahead'; +select * from information_schema.session_variables where variable_name='innodb_random_read_ahead'; +--error ER_GLOBAL_VARIABLE +set session innodb_random_read_ahead='OFF'; +--error ER_GLOBAL_VARIABLE +set @@session.innodb_random_read_ahead='ON'; + +# +# incorrect types +# +--error ER_WRONG_TYPE_FOR_VAR +set global innodb_random_read_ahead=1.1; +--error ER_WRONG_TYPE_FOR_VAR +set global innodb_random_read_ahead=1e1; +--error ER_WRONG_VALUE_FOR_VAR +set global innodb_random_read_ahead=2; +--echo NOTE: The following should fail with ER_WRONG_VALUE_FOR_VAR (BUG#50643) +set global innodb_random_read_ahead=-3; +select @@global.innodb_random_read_ahead; +select * from information_schema.global_variables where variable_name='innodb_random_read_ahead'; +select * from information_schema.session_variables where variable_name='innodb_random_read_ahead'; +--error ER_WRONG_VALUE_FOR_VAR +set global innodb_random_read_ahead='AUTO'; + +# +# Cleanup +# + +SET @@global.innodb_random_read_ahead = @start_global_value; +SELECT @@global.innodb_random_read_ahead; diff --git a/mysql-test/suite/sys_vars/t/innodb_rollback_segments_basic.test b/mysql-test/suite/sys_vars/t/innodb_rollback_segments_basic.test index 00aa476e8d2..9f0b70a528f 100644 --- a/mysql-test/suite/sys_vars/t/innodb_rollback_segments_basic.test +++ b/mysql-test/suite/sys_vars/t/innodb_rollback_segments_basic.test @@ -1 +1,58 @@ ---echo XtraDB extension +# +# 2011-08-01 Added +# + +--source include/have_innodb.inc + +SET @start_global_value = @@global.innodb_rollback_segments; +SELECT @start_global_value; + +# +# exists as global only +# +--echo Valid values are zero or above +SELECT @@global.innodb_rollback_segments >=0; +SELECT @@global.innodb_rollback_segments <=128; +SELECT @@global.innodb_rollback_segments; + +--error ER_INCORRECT_GLOBAL_LOCAL_VAR +SELECT @@session.innodb_rollback_segments; +SHOW global variables LIKE 'innodb_rollback_segments'; +SHOW session variables LIKE 'innodb_rollback_segments'; +SELECT * FROM information_schema.global_variables +WHERE variable_name='innodb_rollback_segments'; +SELECT * FROM information_schema.session_variables +WHERE variable_name='innodb_rollback_segments'; + +# +# show that it's writable +# +SET global innodb_rollback_segments=100; +SELECT @@global.innodb_rollback_segments; +SELECT * FROM information_schema.global_variables +WHERE variable_name='innodb_rollback_segments'; +SELECT * FROM information_schema.session_variables +WHERE variable_name='innodb_rollback_segments'; +--error ER_GLOBAL_VARIABLE +SET session innodb_rollback_segments=1; + +# +# incorrect types +# +--error ER_WRONG_TYPE_FOR_VAR +SET global innodb_rollback_segments=1.1; +--error ER_WRONG_TYPE_FOR_VAR +SET global innodb_rollback_segments=1e1; +--error ER_WRONG_TYPE_FOR_VAR +SET global innodb_rollback_segments="foo"; +SET global innodb_rollback_segments=-7; +SELECT @@global.innodb_rollback_segments; +SELECT * FROM information_schema.global_variables +WHERE variable_name='innodb_rollback_segments'; + +# +# cleanup +# + +SET @@global.innodb_rollback_segments = @start_global_value; +SELECT @@global.innodb_rollback_segments; diff --git a/mysql-test/suite/sys_vars/t/innodb_stats_method_basic.test b/mysql-test/suite/sys_vars/t/innodb_stats_method_basic.test index 00aa476e8d2..f01574c3683 100644 --- a/mysql-test/suite/sys_vars/t/innodb_stats_method_basic.test +++ b/mysql-test/suite/sys_vars/t/innodb_stats_method_basic.test @@ -1 +1,72 @@ ---echo XtraDB extension +# +# 2011-08-05 - Added +# + +--source include/have_innodb.inc + +SET @start_global_value = @@global.innodb_stats_method; +SELECT @start_global_value; + +# +# exists as global only +# +--echo Valid values are 'nulls_equal', 'nulls_unequal', 'nulls_ignored' +SELECT @@global.innodb_stats_method in ('nulls_equal', 'nulls_unequal', +'nulls_ignored'); +SELECT @@global.innodb_stats_method; +--error ER_INCORRECT_GLOBAL_LOCAL_VAR +SELECT @@session.innodb_stats_method; +SHOW global variables LIKE 'innodb_stats_method'; +SHOW session variables LIKE 'innodb_stats_method'; +SELECT * FROM information_schema.global_variables +WHERE variable_name='innodb_stats_method'; +SELECT * FROM information_schema.session_variables +WHERE variable_name='innodb_stats_method'; + +# +# show that it's writable +# +SET global innodb_stats_method='nulls_equal'; +SELECT @@global.innodb_stats_method; +SELECT * FROM information_schema.global_variables +WHERE variable_name='innodb_stats_method'; +SELECT * FROM information_schema.session_variables +WHERE variable_name='innodb_stats_method'; +SET @@global.innodb_stats_method='nulls_unequal'; +SELECT @@global.innodb_stats_method; +SELECT * FROM information_schema.global_variables +WHERE variable_name='innodb_stats_method'; +SELECT * FROM information_schema.session_variables +WHERE variable_name='innodb_stats_method'; +SET global innodb_stats_method=2; +SELECT @@global.innodb_stats_method; +SELECT * FROM information_schema.global_variables +WHERE variable_name='innodb_stats_method'; +SELECT * FROM information_schema.session_variables +WHERE variable_name='innodb_stats_method'; + +--error ER_GLOBAL_VARIABLE +SET session innodb_stats_method='nulls_equal'; +--error ER_GLOBAL_VARIABLE +SET @@session.innodb_stats_method='nulls_ignored'; + +# +# incorrect types +# +--error ER_WRONG_TYPE_FOR_VAR +SET global innodb_stats_method=1.1; +--error ER_WRONG_VALUE_FOR_VAR +SET global innodb_stats_method=4; +--error ER_WRONG_VALUE_FOR_VAR +SET global innodb_stats_method=-2; +--error ER_WRONG_TYPE_FOR_VAR +SET global innodb_stats_method=1e1; +--error ER_WRONG_VALUE_FOR_VAR +SET global innodb_stats_method='some'; + +# +# Cleanup +# + +SET @@global.innodb_stats_method = @start_global_value; +SELECT @@global.innodb_stats_method; diff --git a/mysql-test/suite/sys_vars/t/max_user_connections-2.test b/mysql-test/suite/sys_vars/t/max_user_connections-2.test new file mode 100644 index 00000000000..a376c78a09b --- /dev/null +++ b/mysql-test/suite/sys_vars/t/max_user_connections-2.test @@ -0,0 +1,11 @@ +# +# Test behavior of various per-account limits (aka quotas) +# +--source include/not_embedded.inc + +# +# We will get an error as it was set to 0 at startup +# +--error ER_OPTION_PREVENTS_STATEMENT +set global max_user_connections=100; + diff --git a/mysql-test/suite/sys_vars/t/max_user_connections_basic-master.opt b/mysql-test/suite/sys_vars/t/max_user_connections_basic-master.opt new file mode 100644 index 00000000000..f507cd0406c --- /dev/null +++ b/mysql-test/suite/sys_vars/t/max_user_connections_basic-master.opt @@ -0,0 +1 @@ +--max-user-connections=10 diff --git a/mysql-test/suite/sys_vars/t/max_user_connections_basic.test b/mysql-test/suite/sys_vars/t/max_user_connections_basic.test index 1adcc012bc4..8c9d031030f 100644 --- a/mysql-test/suite/sys_vars/t/max_user_connections_basic.test +++ b/mysql-test/suite/sys_vars/t/max_user_connections_basic.test @@ -77,9 +77,9 @@ SET @@global.max_user_connections = 2; SELECT @@global.max_user_connections; SET @@global.max_user_connections = 65536; SELECT @@global.max_user_connections; -SET @@global.max_user_connections = 4294967295; +SET @@global.max_user_connections = 2147483647; SELECT @@global.max_user_connections; -SET @@global.max_user_connections = 4294967294; +SET @@global.max_user_connections = 2147483646; SELECT @@global.max_user_connections; diff --git a/mysql-test/suite/sys_vars/t/max_user_connections_func-master.opt b/mysql-test/suite/sys_vars/t/max_user_connections_func-master.opt new file mode 100644 index 00000000000..f507cd0406c --- /dev/null +++ b/mysql-test/suite/sys_vars/t/max_user_connections_func-master.opt @@ -0,0 +1 @@ +--max-user-connections=10 diff --git a/mysql-test/suite/sys_vars/t/max_user_connections_func.test b/mysql-test/suite/sys_vars/t/max_user_connections_func.test index 841a630c5ce..74707c9b296 100644 --- a/mysql-test/suite/sys_vars/t/max_user_connections_func.test +++ b/mysql-test/suite/sys_vars/t/max_user_connections_func.test @@ -39,21 +39,23 @@ SET @default_max_user_connections = @@global.max_user_connections; Set Global max_user_connections=2; +GRANT USAGE on *.* TO test@localhost; + --echo '#--------------------FN_DYNVARS_114_01-------------------------#' ######################################## #Should not make more then 2 connection# ######################################## ---echo ** Connecting conn1 using username 'root' ** -CONNECT (conn1,localhost,root,,); +--echo ** Connecting conn1 using username 'test' ** +CONNECT (conn1,localhost,test,,); ---echo ** Connecting conn2 using username 'root' ** -CONNECT (conn2,localhost,root,,); +--echo ** Connecting conn2 using username 'test' ** +CONNECT (conn2,localhost,test,,); ---echo ** Connecting conn3 using username 'root' ** +--echo ** Connecting conn3 using username 'test' ** --disable_query_log --Error ER_TOO_MANY_USER_CONNECTIONS -CONNECT (conn3,localhost,root,,); +CONNECT (conn3,localhost,test,,); --enable_query_log --echo Expected error "too many connections" @@ -62,7 +64,7 @@ DISCONNECT conn1; --echo ** Poll till disconnected conn1 disappears from processlist let $wait_condition= SELECT count(id) <= 2 - FROM information_schema.processlist WHERE user = 'root'; + FROM information_schema.processlist WHERE user = 'test'; --source include/wait_condition.inc --echo '#--------------------FN_DYNVARS_114_02-------------------------#' @@ -70,11 +72,12 @@ let $wait_condition= SELECT count(id) <= 2 #Set value to 3 and see if 3 connections can be made# ##################################################### +connection default; Set Global max_user_connections=3; ---echo ** Connecting conn5 using username 'root' ** -CONNECT (conn5,localhost,root,,); ---echo ** Connecting conn6 using username 'root' ** -CONNECT (conn6,localhost,root,,); +--echo ** Connecting conn5 using username 'test' ** +CONNECT (conn5,localhost,test,,); +--echo ** Connecting conn6 using username 'test' ** +CONNECT (conn6,localhost,test,,); # # Cleanup @@ -88,5 +91,7 @@ DISCONNECT conn2; DISCONNECT conn5; DISCONNECT conn6; +drop user test@localhost; + SET @@global.max_user_connections = @default_max_user_connections; diff --git a/mysql-test/t/optimizer_switch_eng_cond_pushdown1-master.opt b/mysql-test/suite/sys_vars/t/optimizer_switch_eng_cond_pushdown1-master.opt index 89aa07976ac..89aa07976ac 100644 --- a/mysql-test/t/optimizer_switch_eng_cond_pushdown1-master.opt +++ b/mysql-test/suite/sys_vars/t/optimizer_switch_eng_cond_pushdown1-master.opt diff --git a/mysql-test/t/optimizer_switch_eng_cond_pushdown1.test b/mysql-test/suite/sys_vars/t/optimizer_switch_eng_cond_pushdown1.test index 187aa145408..187aa145408 100644 --- a/mysql-test/t/optimizer_switch_eng_cond_pushdown1.test +++ b/mysql-test/suite/sys_vars/t/optimizer_switch_eng_cond_pushdown1.test diff --git a/mysql-test/t/optimizer_switch_eng_cond_pushdown2-master.opt b/mysql-test/suite/sys_vars/t/optimizer_switch_eng_cond_pushdown2-master.opt index f48ab5b963b..f48ab5b963b 100644 --- a/mysql-test/t/optimizer_switch_eng_cond_pushdown2-master.opt +++ b/mysql-test/suite/sys_vars/t/optimizer_switch_eng_cond_pushdown2-master.opt diff --git a/mysql-test/t/optimizer_switch_eng_cond_pushdown2.test b/mysql-test/suite/sys_vars/t/optimizer_switch_eng_cond_pushdown2.test index 187aa145408..187aa145408 100644 --- a/mysql-test/t/optimizer_switch_eng_cond_pushdown2.test +++ b/mysql-test/suite/sys_vars/t/optimizer_switch_eng_cond_pushdown2.test diff --git a/mysql-test/suite/sys_vars/t/plugin_dir_basic-master.opt b/mysql-test/suite/sys_vars/t/plugin_dir_basic-master.opt new file mode 100644 index 00000000000..69a9f0def2a --- /dev/null +++ b/mysql-test/suite/sys_vars/t/plugin_dir_basic-master.opt @@ -0,0 +1 @@ +--plugin-dir=$MYSQL_TMP_DIR diff --git a/mysql-test/suite/sys_vars/t/plugin_dir_basic.test b/mysql-test/suite/sys_vars/t/plugin_dir_basic.test index 8bb231c2c5e..59889f7ecb2 100644 --- a/mysql-test/suite/sys_vars/t/plugin_dir_basic.test +++ b/mysql-test/suite/sys_vars/t/plugin_dir_basic.test @@ -3,22 +3,20 @@ # # -# on windows it's <basedir>/lib/plugin -# on unix it's <basedir>/lib/mysql/plugin -# unless mtr sets it to $MYSQL_TEST_DIR/var/plugins +# Don't rely on being able to guess the correct default. +# -master.opt file for this test sets plugin_dir to a known directory # -let plugindir=$MYSQLTEST_VARDIR; ---replace_result $plugindir MYSQL_LIBDIR $MYSQL_LIBDIR MYSQL_LIBDIR /mysql/ / +--replace_result $MYSQL_TMP_DIR MYSQL_TMP_DIR /mysql/ / select @@global.plugin_dir; --error ER_INCORRECT_GLOBAL_LOCAL_VAR select @@session.plugin_dir; ---replace_result $plugindir MYSQL_LIBDIR $MYSQL_LIBDIR MYSQL_LIBDIR /mysql/ / +--replace_result $MYSQL_TMP_DIR MYSQL_TMP_DIR /mysql/ / show global variables like 'plugin_dir'; ---replace_result $plugindir MYSQL_LIBDIR $MYSQL_LIBDIR MYSQL_LIBDIR /mysql/ / +--replace_result $MYSQL_TMP_DIR MYSQL_TMP_DIR /mysql/ / show session variables like 'plugin_dir'; ---replace_result $plugindir MYSQL_LIBDIR $MYSQL_LIBDIR MYSQL_LIBDIR /mysql/ / +--replace_result $MYSQL_TMP_DIR MYSQL_TMP_DIR /mysql/ / select * from information_schema.global_variables where variable_name='plugin_dir'; ---replace_result $plugindir MYSQL_LIBDIR $MYSQL_LIBDIR MYSQL_LIBDIR /mysql/ / +--replace_result $MYSQL_TMP_DIR MYSQL_TMP_DIR /mysql/ / select * from information_schema.session_variables where variable_name='plugin_dir'; # diff --git a/mysql-test/suite/sys_vars/t/replicate_annotate_row_events_basic.test b/mysql-test/suite/sys_vars/t/replicate_annotate_row_events_basic.test new file mode 100644 index 00000000000..f4d7221f1b8 --- /dev/null +++ b/mysql-test/suite/sys_vars/t/replicate_annotate_row_events_basic.test @@ -0,0 +1,23 @@ +# bool readonly + +--source include/not_embedded.inc + +# +# show values; +# +select @@global.replicate_annotate_row_events; +--error ER_INCORRECT_GLOBAL_LOCAL_VAR +select @@session.replicate_annotate_row_events; +show global variables like 'replicate_annotate_row_events'; +show session variables like 'replicate_annotate_row_events'; +select * from information_schema.global_variables where variable_name='replicate_annotate_row_events'; +select * from information_schema.session_variables where variable_name='replicate_annotate_row_events'; + +# +# show that it's read-only +# +--error ER_INCORRECT_GLOBAL_LOCAL_VAR +set global replicate_annotate_row_events=1; +--error ER_INCORRECT_GLOBAL_LOCAL_VAR +set session replicate_annotate_row_events=1; + diff --git a/mysql-test/suite/sys_vars/t/replicate_annotate_rows_events_basic.test b/mysql-test/suite/sys_vars/t/replicate_annotate_rows_events_basic.test deleted file mode 100644 index b519859e971..00000000000 --- a/mysql-test/suite/sys_vars/t/replicate_annotate_rows_events_basic.test +++ /dev/null @@ -1,23 +0,0 @@ -# bool readonly - ---source include/not_embedded.inc - -# -# show values; -# -select @@global.replicate_annotate_rows_events; ---error ER_INCORRECT_GLOBAL_LOCAL_VAR -select @@session.replicate_annotate_rows_events; -show global variables like 'replicate_annotate_rows_events'; -show session variables like 'replicate_annotate_rows_events'; -select * from information_schema.global_variables where variable_name='replicate_annotate_rows_events'; -select * from information_schema.session_variables where variable_name='replicate_annotate_rows_events'; - -# -# show that it's read-only -# ---error ER_INCORRECT_GLOBAL_LOCAL_VAR -set global replicate_annotate_rows_events=1; ---error ER_INCORRECT_GLOBAL_LOCAL_VAR -set session replicate_annotate_rows_events=1; - diff --git a/mysql-test/suite/vcol/r/vcol_misc.result b/mysql-test/suite/vcol/r/vcol_misc.result index 58bd048ec85..693ea0d9174 100644 --- a/mysql-test/suite/vcol/r/vcol_misc.result +++ b/mysql-test/suite/vcol/r/vcol_misc.result @@ -139,6 +139,9 @@ create table t2 (c int, d int, v int as (d+1), index idx(c)); insert into t2(c,d) values (20, 100), (20, 300), (30, 100), (30, 200), (40, 500), (70, 100), (40, 300), (60, 100), (40, 100), (70, 100); +insert into t2(c,d) values +(120, 100), (150, 300), (130, 100), (130, 200), (140, 500), +(170, 100), (180, 300), (160, 100), (40, 100), (170, 100); set join_cache_level=6; explain select * from t1,t2 where t1.b=t2.c and d <= 100; diff --git a/mysql-test/suite/vcol/r/vcol_select_innodb.result b/mysql-test/suite/vcol/r/vcol_select_innodb.result index dfae286e984..6dafda87647 100644 --- a/mysql-test/suite/vcol/r/vcol_select_innodb.result +++ b/mysql-test/suite/vcol/r/vcol_select_innodb.result @@ -63,8 +63,8 @@ a b c 3 -3 -3 explain select * from t1 where b in (select c from t3); id select_type table type possible_keys key key_len ref rows Extra -1 PRIMARY t1 ALL NULL NULL NULL NULL 5 Using where -2 DEPENDENT SUBQUERY t3 index_subquery c c 5 func 1 Using index +1 PRIMARY t3 index c c 5 NULL 3 Using index +1 PRIMARY t1 ALL NULL NULL NULL NULL 5 Using where; Using join buffer (flat, BNL join) # select_type=PRIMARY, type=range,ref select * from t1 where c in (select c from t3 where c between -2 and -1); a b c @@ -73,8 +73,8 @@ a b c 1 -1 -1 explain select * from t1 where c in (select c from t3 where c between -2 and -1); id select_type table type possible_keys key key_len ref rows Extra -1 PRIMARY t1 ALL NULL NULL NULL NULL 5 Using where -2 DEPENDENT SUBQUERY t3 index_subquery c c 5 func 1 Using index; Using where +1 PRIMARY t3 index c c 5 NULL 3 Using where; Using index +1 PRIMARY t1 ALL c NULL NULL NULL 5 Using where; Using join buffer (flat, BNL join) # select_type=UNION, type=system # select_type=UNION RESULT, type=<union1,2> select * from t1 union select * from t2; diff --git a/mysql-test/suite/vcol/r/vcol_select_myisam.result b/mysql-test/suite/vcol/r/vcol_select_myisam.result index 24af9cd4256..4d74d791841 100644 --- a/mysql-test/suite/vcol/r/vcol_select_myisam.result +++ b/mysql-test/suite/vcol/r/vcol_select_myisam.result @@ -63,8 +63,8 @@ a b c 3 -3 -3 explain select * from t1 where b in (select c from t3); id select_type table type possible_keys key key_len ref rows Extra -1 PRIMARY t1 ALL NULL NULL NULL NULL 5 Using where -2 DEPENDENT SUBQUERY t3 index_subquery c c 5 func 2 Using index +1 PRIMARY t3 index c c 5 NULL 3 Using index +1 PRIMARY t1 ALL NULL NULL NULL NULL 5 Using where; Using join buffer (flat, BNL join) # select_type=PRIMARY, type=range,ref select * from t1 where c in (select c from t3 where c between -2 and -1); a b c @@ -73,8 +73,8 @@ a b c 1 -1 -1 explain select * from t1 where c in (select c from t3 where c between -2 and -1); id select_type table type possible_keys key key_len ref rows Extra -1 PRIMARY t1 ALL NULL NULL NULL NULL 5 Using where -2 DEPENDENT SUBQUERY t3 index_subquery c c 5 func 2 Using index; Using where +1 PRIMARY t3 index c c 5 NULL 3 Using where; Using index +1 PRIMARY t1 ref c c 5 test.t3.c 2 # select_type=UNION, type=system # select_type=UNION RESULT, type=<union1,2> select * from t1 union select * from t2; diff --git a/mysql-test/suite/vcol/t/vcol_misc.test b/mysql-test/suite/vcol/t/vcol_misc.test index a0616d187da..f87cb5fbec8 100644 --- a/mysql-test/suite/vcol/t/vcol_misc.test +++ b/mysql-test/suite/vcol/t/vcol_misc.test @@ -151,6 +151,9 @@ create table t2 (c int, d int, v int as (d+1), index idx(c)); insert into t2(c,d) values (20, 100), (20, 300), (30, 100), (30, 200), (40, 500), (70, 100), (40, 300), (60, 100), (40, 100), (70, 100); +insert into t2(c,d) values + (120, 100), (150, 300), (130, 100), (130, 200), (140, 500), + (170, 100), (180, 300), (160, 100), (40, 100), (170, 100); set join_cache_level=6; explain diff --git a/mysql-test/t/alter_table.test b/mysql-test/t/alter_table.test index 15b037a0294..1edee9abf1e 100644 --- a/mysql-test/t/alter_table.test +++ b/mysql-test/t/alter_table.test @@ -1100,6 +1100,33 @@ ALTER TABLE t1 DROP COLUMN a, ADD COLUMN c TEXT FIRST; DROP TABLE t1; +--echo # +--echo # Test for bug #12652385 - "61493: REORDERING COLUMNS TO POSITION +--echo # FIRST CAN CAUSE DATA TO BE CORRUPTED". +--echo # +--disable_warnings +drop table if exists t1; +--enable_warnings +--echo # Use MyISAM engine as the fact that InnoDB doesn't support +--echo # in-place ALTER TABLE in cases when columns are being renamed +--echo # hides some bugs. +create table t1 (i int, j int) engine=myisam; +insert into t1 value (1, 2); +--echo # First, test for original problem described in the bug report. +select * from t1; +--echo # Change of column order by the below ALTER TABLE statement should +--echo # affect both column names and column contents. +alter table t1 modify column j int first; +select * from t1; +--echo # Now test for similar problem with the same root. +--echo # The below ALTER TABLE should change not only the name but +--echo # also the value for the last column of the table. +alter table t1 drop column i, add column k int default 0; +select * from t1; +--echo # Clean-up. +drop table t1; + + --echo End of 5.1 tests # diff --git a/mysql-test/t/auth_rpl-master.opt b/mysql-test/t/auth_rpl-master.opt new file mode 100644 index 00000000000..3536d102387 --- /dev/null +++ b/mysql-test/t/auth_rpl-master.opt @@ -0,0 +1,2 @@ +$PLUGIN_AUTH_OPT +$PLUGIN_AUTH_LOAD diff --git a/mysql-test/t/auth_rpl-slave.opt b/mysql-test/t/auth_rpl-slave.opt new file mode 100644 index 00000000000..3f4af6e59bb --- /dev/null +++ b/mysql-test/t/auth_rpl-slave.opt @@ -0,0 +1,4 @@ +--master-retry-count=1 +$PLUGIN_AUTH_OPT +$PLUGIN_AUTH_LOAD + diff --git a/mysql-test/t/auth_rpl.test b/mysql-test/t/auth_rpl.test new file mode 100644 index 00000000000..c413a84b53c --- /dev/null +++ b/mysql-test/t/auth_rpl.test @@ -0,0 +1,66 @@ +--source include/have_plugin_auth.inc
+--source include/not_embedded.inc
+--source include/master-slave.inc
+
+#
+# Check that replication slave can connect to master using an account
+# which authenticates with an external authentication plugin (bug#12897501).
+
+#
+# First stop the slave to guarantee that nothing is replicated.
+#
+--connection slave
+--echo [connection slave]
+--source include/stop_slave.inc
+#
+# Create an replication account on the master.
+#
+--connection master
+--echo [connection master]
+CREATE USER 'plug_user' IDENTIFIED WITH 'test_plugin_server' AS 'plug_user';
+GRANT REPLICATION SLAVE ON *.* TO plug_user;
+FLUSH PRIVILEGES;
+
+#
+# Now go to slave and change the replication user.
+#
+--connection slave
+--echo [connection slave]
+--let $master_user= query_get_value(SHOW SLAVE STATUS, Master_User, 1)
+CHANGE MASTER TO
+ MASTER_USER= 'plug_user',
+ MASTER_PASSWORD= 'plug_user';
+
+#
+# Start slave with new replication account - this should trigger connection
+# to the master server.
+#
+--source include/start_slave.inc
+
+# Replicate all statements executed on master, in this case,
+# (creation of the plug_user account).
+#
+--connection master
+--sync_slave_with_master
+--echo # Slave in-sync with master now.
+
+SELECT user, plugin, authentication_string FROM mysql.user WHERE user LIKE 'plug_user';
+
+#
+# Now we can stop the slave and clean up.
+#
+# Note: it is important that slave is stopped at this
+# moment - otherwise master's cleanup statements
+# would be replicated on slave!
+#
+--echo # Cleanup (on slave).
+--source include/stop_slave.inc
+eval CHANGE MASTER TO MASTER_USER='$master_user';
+DROP USER 'plug_user';
+
+--echo # Cleanup (on master).
+--connection master
+DROP USER 'plug_user';
+
+--let $rpl_only_running_threads= 1
+--source include/rpl_end.inc
diff --git a/mysql-test/t/case.test b/mysql-test/t/case.test index e1c807fe32b..9d6cc7d375a 100644 --- a/mysql-test/t/case.test +++ b/mysql-test/t/case.test @@ -173,3 +173,12 @@ select t1.a, (case t1.a when 0 then 0 else t1.b end) d from t1 drop table t1, t2; --echo End of 5.0 tests + +# +# lp:839387 Assertion `(Item_result)i != TIME_RESULT' failed with CASE + datetime +# + +create table t1 (f1 time); +insert t1 values ('00:00:00'),('00:01:00'); +select case t1.f1 when '00:00:00' then 1 end from t1; +drop table t1; diff --git a/mysql-test/t/cast.test b/mysql-test/t/cast.test index 522007f6079..f5e2bc9ea57 100644 --- a/mysql-test/t/cast.test +++ b/mysql-test/t/cast.test @@ -37,7 +37,7 @@ select cast("2011-02-03 10:11:12.123456" as datetime(0)); select cast("2011-02-03 10:11:12.123456" as datetime(5)); select cast("2011-02-03 10:11:12.123456" as datetime(6)); select cast("2011-02-03 10:11:12" as datetime(6)); -select cast(cast(20010203101112.1 as double) as datetime(1)); +select cast(cast(20010203101112.5 as double) as datetime(1)); select cast(cast(010203101112.12 as double) as datetime(2)); select cast(cast(20010203101112.121314 as decimal(32,6)) as datetime(6)); select cast(20010203101112.121314 as datetime(6)); @@ -419,3 +419,8 @@ insert into t1 values ('11:22:33','2011-12-13','2011-12-13 11:22:33'); select cast(f1 as unsigned), cast(f2 as unsigned), cast(f3 as unsigned) from t1; drop table t1; +# +# CAST(... AS DATE) and invalid dates +# +SELECT CAST(TIME('10:20:30') AS DATE) + INTERVAL 1 DAY; + diff --git a/mysql-test/t/comments.test b/mysql-test/t/comments.test index 3a18a8bd483..08c74c99d0c 100644 --- a/mysql-test/t/comments.test +++ b/mysql-test/t/comments.test @@ -21,6 +21,17 @@ select 1 # The rest of the row will be ignored # End of 4.1 tests # +# Testing of MariaDB executable comments +# + +select 1 /*M! +1 */; +select 1 /*M!50000 +1 */; +select 1 /*M!50300 +1 */; +select 2 /*M!99999 +1 */; +--error ER_PARSE_ERROR +select 2 /*M!0000 +1 */; + +# # Bug#25411 (trigger code truncated) # diff --git a/mysql-test/t/ctype_errors.test b/mysql-test/t/ctype_errors.test index 3c73fdae264..681223dae64 100644 --- a/mysql-test/t/ctype_errors.test +++ b/mysql-test/t/ctype_errors.test @@ -44,4 +44,19 @@ USE nonexistant; disconnect con1; connection default; ---echo End of 5.4 tests +--echo # +--echo # Bug#12736295: Buffer overflow for variable converted_err +--echo # with non-latin1 server error message +--echo # + +connect (con1,localhost,root,,test); +--echo # Connection con1 +SET lc_messages=ru_RU; +SET NAMES latin1; +--error ER_PARSE_ERROR +--query SELECT '01234567890123456789012345678901234\' +disconnect con1; +--echo # Connection default +connection default; + +--echo End of 5.5 tests diff --git a/mysql-test/t/ctype_utf16.test b/mysql-test/t/ctype_utf16.test index c748e7148bf..d47dc335d5b 100644 --- a/mysql-test/t/ctype_utf16.test +++ b/mysql-test/t/ctype_utf16.test @@ -757,6 +757,13 @@ INSERT INTO t1 VALUES ('a'); SELECT CASE s1 WHEN 'a' THEN 'b' ELSE 'c' END FROM t1; DROP TABLE t1; +--echo # +--echo # Bug#12340997 +--echo # DATE_ADD/DATE_SUB WITH INTERVAL CRASHES IN GET_INTERVAL_VALUE() +--echo # + +SELECT space(date_add(101, INTERVAL CHAR('1' USING utf16) hour_second)); + # ## TODO: add tests for all engines # diff --git a/mysql-test/t/ctype_utf32_uca.test b/mysql-test/t/ctype_utf32_uca.test index a62ffbf95c7..1d79fbe1616 100644 --- a/mysql-test/t/ctype_utf32_uca.test +++ b/mysql-test/t/ctype_utf32_uca.test @@ -293,6 +293,27 @@ SET collation_connection=utf32_czech_ci; --source include/ctype_czech.inc --source include/ctype_like_ignorable.inc +--echo # +--echo # Bug #12319710 : INVALID MEMORY READ AND/OR CRASH IN +--echo # MY_UCA_CHARCMP WITH UTF32 +--echo # + +SET collation_connection=utf32_unicode_ci; +CREATE TABLE t1 (a TEXT CHARACTER SET utf32 COLLATE utf32_turkish_ci NOT NULL); +INSERT INTO t1 VALUES ('a'), ('b'); +CREATE TABLE t2 (b VARBINARY(5) NOT NULL); + +--echo #insert chars outside of BMP +INSERT INTO t2 VALUEs (0x082837),(0x082837); + +--echo #test for read-out-of-bounds with non-BMP chars as a LIKE pattern +SELECT * FROM t1,t2 WHERE a LIKE b; + +--echo #test the original statement +SELECT 1 FROM t1 AS t1_0 NATURAL LEFT OUTER JOIN t2 AS t2_0 +RIGHT JOIN t1 AS t1_1 ON t1_0.a LIKE t2_0.b; + +DROP TABLE t1,t2; --echo # --echo # End of 5.5 tests diff --git a/mysql-test/t/derived_view.test b/mysql-test/t/derived_view.test index 72719ec9786..c1a9435ef6c 100644 --- a/mysql-test/t/derived_view.test +++ b/mysql-test/t/derived_view.test @@ -363,7 +363,9 @@ CREATE TABLE t2 (a varchar(1) , KEY (a)) ; INSERT INTO t2 VALUES ('c'), (NULL), ('r'); CREATE TABLE t3 (a varchar(1), b varchar(1)); -INSERT INTO t3 VALUES ('e', 'c'), ('c', 'c'), ('c', 'r'); +INSERT INTO t3 VALUES + ('e', 'c'), ('c', 'c'), ('c', 'r'), ('g', 'a'), ('b', 'x'), ('b', 'y'), + ('h', 'w'), ('d', 'z'), ('k', 'v'), ('j', 's'), ('m', 'p'), ('l', 'q'); CREATE VIEW v1 AS SELECT a, MIN(b) AS b FROM t3 GROUP BY a; @@ -599,7 +601,10 @@ INSERT INTO t1 VALUES (0); CREATE TABLE t2 (a varchar(32), b int, KEY (a)) ; INSERT INTO t2 VALUES ('j',28), ('c',29), ('i',26), ('c',29), ('k',27), - ('j',28), ('c',29), ('i',25), ('d',26), ('k',27); + ('j',28), ('c',29), ('i',25), ('d',26), ('k',27), + ('n',28), ('d',29), ('m',26), ('e',29), ('p',27), + ('w',28), ('x',29), ('y',25), ('z',26), ('s',27); + CREATE TABLE t3 (a varchar(32)); INSERT INTO t3 VALUES ('j'), ('c'); @@ -783,5 +788,478 @@ WHERE EXISTS (SELECT t2.a FROM t3 RIGHT JOIN t2 ON (t3.a = t2.a) DROP TABLE t1,t2,t3; +--echo # +--echo # LP bug #824463: nested outer join using a merged view +--echo # as an inner table +--echo # + +CREATE TABLE t1 (b int, a int) ; + +CREATE TABLE t2 (a int) ; +INSERT INTO t2 VALUES (5), (6); + +CREATE TABLE t3 (a int , c int) ; +INSERT INTO t3 VALUES (22,1), (23,-1); + +CREATE TABLE t4 (a int); + +CREATE TABLE t5 (d int) ; +INSERT INTO t5 VALUES (0), (7), (3), (5); + +CREATE VIEW v2 AS SELECT * FROM t2; +CREATE VIEW v3 AS SELECT * FROM t3; + +EXPLAIN EXTENDED +SELECT STRAIGHT_JOIN * + FROM ( t2 AS s2 + JOIN + ( t3 AS s3 + LEFT JOIN + ( t4 LEFT JOIN t3 ON t4.a != 0 ) + ON s3.a != 0) + ON s2.a != 0) + JOIN t5 ON s3.c != 0 AND t5.d = 0; +SELECT STRAIGHT_JOIN * + FROM ( t2 AS s2 + JOIN + ( t3 AS s3 + LEFT JOIN + ( t4 LEFT JOIN t3 ON t4.a != 0 ) + ON s3.a != 0) + ON s2.a != 0) + JOIN t5 ON s3.c != 0 AND t5.d = 0; + +EXPLAIN EXTENDED +SELECT STRAIGHT_JOIN * + FROM t2 AS s2 , t5, + (t3 LEFT JOIN (t4 LEFT JOIN t3 AS s3 ON t4.a != 0) ON t3.a != 0) + WHERE s2.a != 0 AND t3.c != 0 AND t5.d = 0; +SELECT STRAIGHT_JOIN * + FROM t2 AS s2 , t5, + (t3 LEFT JOIN (t4 LEFT JOIN t3 AS s3 ON t4.a != 0) ON t3.a != 0) + WHERE s2.a != 0 AND t3.c != 0 AND t5.d = 0; + +EXPLAIN EXTENDED +SELECT STRAIGHT_JOIN * + FROM v2 AS s2 , t5, + (t3 LEFT JOIN (t4 LEFT JOIN v3 AS s3 ON t4.a != 0) ON t3.a != 0) + WHERE s2.a != 0 AND t3.c != 0 AND t5.d = 0; +SELECT STRAIGHT_JOIN * + FROM v2 AS s2 , t5, + (t3 LEFT JOIN (t4 LEFT JOIN v3 AS s3 ON t4.a != 0) ON t3.a != 0) + WHERE s2.a != 0 AND t3.c != 0 AND t5.d = 0; + +SELECT STRAIGHT_JOIN * + FROM ( ( t2 AS s2 + LEFT JOIN + ( t3 AS s3 + LEFT JOIN + ( t4 AS s4 JOIN t3 ON s4.a != 0) + ON s3.a != 0 ) + ON s2.a != 0) + LEFT JOIN + t1 AS s1 + ON s1.a != 0) + JOIN t5 ON s3.c != 0; +SELECT STRAIGHT_JOIN * + FROM ( ( v2 AS s2 + LEFT JOIN + ( v3 AS s3 + LEFT JOIN + ( t4 AS s4 JOIN v3 ON s4.a != 0) + ON s3.a != 0 ) + ON s2.a != 0) + LEFT JOIN + t1 AS s1 + ON s1.a != 0) + JOIN t5 ON s3.c != 0; + +DROP VIEW v2,v3; +DROP TABLE t1,t2,t3,t4,t5; + +--echo # +--echo # LP bug #872735: derived used in a NOT IN subquery +--echo # + +CREATE TABLE t1 (b int NOT NULL); +INSERT INTO t1 VALUES (9), (7); + +CREATE TABLE t2 (a int NOT NULL) ; +INSERT INTO t2 VALUES (1), (2); + +CREATE TABLE t3 ( + a int NOT NULL , c int NOT NULL, d varchar(1) NOT NULL, + KEY (c,a) , PRIMARY KEY (a) +); +INSERT INTO t3 VALUES + (14,4,'a'), (15,7,'b'), (16,4,'c'), (17,1,'d'), (18,9,'e'), + (19,4,'f'), (20,8,'g'); + +SET SESSION optimizer_switch='derived_merge=on,subquery_cache=off'; + +--echo # The following two EXPLAINs must return the same execution plan +EXPLAIN +SELECT * FROM t1 , t2 + WHERE (t2.a ,t1.b) NOT IN (SELECT DISTINCT c,a FROM t3 t); +EXPLAIN +SELECT * FROM t1 , t2 + WHERE (t2.a ,t1.b) NOT IN (SELECT DISTINCT c,a FROM (SELECT * FROM t3) t); + +SELECT * FROM t1 , t2 + WHERE (t2.a ,t1.b) NOT IN (SELECT DISTINCT c,a FROM (SELECT * FROM t3) t); + +DROP TABLE t1,t2,t3; + +--echo # +--echo # LP bug #874006: materialized view used in IN subquery +--echo # + +CREATE TABLE t3 (a int NOT NULL, b varchar(1), c varchar(1)); +INSERT INTO t3 VALUES (19,NULL,NULL), (20,'r','r'); + +CREATE TABLE t1 (a int, b varchar(1) , c varchar(1)); +INSERT INTO t1 VALUES (1,NULL,NULL), (5,'r','r'), (7,'y','y'); + +CREATE TABLE t2 (a int NOT NULL , b int, c varchar(1)); +INSERT INTO t2 VALUES (4,3,'r'); + +CREATE ALGORITHM=TEMPTABLE VIEW v1 AS SELECT * FROM t1; + +SET SESSION optimizer_switch='derived_with_keys=off'; +EXPLAIN +SELECT * FROM t3 + WHERE t3.b IN (SELECT v1.b FROM v1, t2 + WHERE t2.c = v1.c AND t2.c = v1.b AND v1.b = t3.c); +SELECT * FROM t3 + WHERE t3.b IN (SELECT v1.b FROM v1, t2 + WHERE t2.c = v1.c AND t2.c = v1.b AND v1.b = t3.c); + +SET SESSION optimizer_switch='derived_with_keys=on'; +EXPLAIN +SELECT * FROM t3 + WHERE t3.b IN (SELECT v1.b FROM v1, t2 + WHERE t2.c = v1.c AND t2.c = v1.b AND v1.b = t3.c); +SELECT * FROM t3 + WHERE t3.b IN (SELECT v1.b FROM v1, t2 + WHERE t2.c = v1.c AND t2.c = v1.b AND v1.b = t3.c); + +DROP VIEW v1; +DROP TABLE t1,t2,t3; + +--echo # +--echo # LP bug #873263: materialized view used in correlated IN subquery +--echo # + +CREATE TABLE t1 (a int, b int) ; +INSERT INTO t1 VALUES (5,4), (9,8); + +CREATE TABLE t2 (a int, b int) ; +INSERT INTO t2 VALUES (4,5), (5,1); + +CREATE ALGORITHM=TEMPTABLE VIEW v2 AS SELECT * FROM t2; + +SET SESSION optimizer_switch='derived_with_keys=on'; +EXPLAIN +SELECT * FROM t1 WHERE t1.b IN (SELECT v2.a FROM v2 WHERE v2.b = t1.a); +SELECT * FROM t1 WHERE t1.b IN (SELECT v2.a FROM v2 WHERE v2.b = t1.a); + +DROP VIEW v2; +DROP TABLE t1,t2; + +--echo # +--echo # LP bug #877316: query over a view with correlated subquery in WHERE +--echo # + +CREATE TABLE t1 (a int, b int, PRIMARY KEY (a)) ; +INSERT INTO t1 VALUES (18,2), (19,9); + +CREATE TABLE t2 (a int, b int) ; +INSERT INTO t2 VALUES (10,8), (5,10); + +CREATE VIEW v1 AS SELECT * FROM t1; + +SELECT t1.a FROM t1 + WHERE EXISTS (SELECT t2.a FROM t2 WHERE t2.b < t1.b); +EXPLAIN +SELECT t1.a FROM t1 + WHERE EXISTS (SELECT t2.a FROM t2 WHERE t2.b < t1.b); + +SELECT v1.a FROM v1 + WHERE EXISTS (SELECT t2.a FROM t2 WHERE t2.b < v1.b); +EXPLAIN +SELECT v1.a FROM v1 + WHERE EXISTS (SELECT t2.a FROM t2 WHERE t2.b < v1.b); + +DROP VIEW v1; +DROP TABLE t1,t2; + +--echo # +--echo # LP bug #878199: join of two materialized views +--echo # + +CREATE TABLE t1 (a int, b varchar(1)) ; +INSERT INTO t1 VALUES (7,'c'), (3,'h'), (7,'c'); + +CREATE TABLE t2 (b varchar(1)) ; +INSERT INTO t2 VALUES ('p'), ('c'), ('j'), ('c'), ('p'); + +CREATE VIEW v1 AS SELECT * FROM t1 GROUP BY a,b; + +CREATE VIEW v2 AS SELECT * FROM t2 GROUP BY b; + +SET SESSION optimizer_switch = 'derived_with_keys=on'; + +SELECT v1.a FROM v1,v2 WHERE v2.b = v1.b ORDER BY 1; +EXPLAIN +SELECT v1.a FROM v1,v2 WHERE v2.b = v1.b ORDER BY 1; + +DROP VIEW v1,v2; +DROP TABLE t1,t2; + + +--echo # +--echo # Bug #743378: join over merged view employing BNL +--echo # + +CREATE TABLE t1 ( d varchar(1) NOT NULL) ; +INSERT INTO t1 VALUES ('j'),('v'),('c'); + +CREATE TABLE t2 (h time NOT NULL, d varchar(1) NOT NULL) ; +INSERT INTO t2 VALUES ('05:03:03','w'),('02:59:24','d'),('00:01:58','e'); + +CREATE TABLE t3 ( + b int NOT NULL, e varchar(1) NOT NULL, d varchar(1) NOT NULL, KEY (e,b) +); +INSERT INTO t3 VALUES (4,'x','x'),(9,'w','w'),(4,'d','d'),(8,'e','e'); + +CREATE TABLE t4 (i int NOT NULL, m varchar(1) NOT NULL) ; +INSERT INTO t4 VALUES (8,'m'),(9,'d'),(2,'s'),(4,'r'),(8,'m'); + +CREATE TABLE t5 ( + a int NOT NULL, c int NOT NULL, b int NOT NULL, f date NOT NULL, + g date NOT NULL, h time NOT NULL, j time NOT NULL, k datetime NOT NULL +); + +INSERT INTO t5 VALUES + (1,4,0,'0000-00-00','0000-00-00','21:22:34','21:22:34','2002-02-13 17:30'), + (2,6,8,'2004-09-18','2004-09-18','10:50:38','10:50:38','2008-09-27 00:34'); + +CREATE VIEW v3 AS SELECT t3.*, t4.i FROM t3, t4, t5; + +SET SESSION join_cache_level = 1; +SET SESSION join_buffer_size = 512; + +EXPLAIN +SELECT t2.d FROM t1,t2,v3 WHERE v3.e = t2.d AND v3.i < 3; +SELECT t2.d FROM t1,t2,v3 WHERE v3.e = t2.d AND v3.i < 3; + +SET SESSION join_cache_level = DEFAULT; +SET SESSION join_buffer_size = DEFAULT; + +DROP VIEW v3; +DROP TABLE t1,t2,t3,t4,t5; + +--echo # +--echo # Bug #879882: right join within mergeable derived table +--echo # + +CREATE TABLE t1 (a varchar(1)); +INSERT INTO t1 VALUES ('c'), ('a'); + +CREATE TABLE t2 (a int, b int, c varchar(1)); +INSERT INTO t2 VALUES (29,8,'c'), (39,7,'b'); + +CREATE TABLE t3 (b int); + +EXPLAIN EXTENDED +SELECT t.b, t.c, t1.a +FROM t1, (SELECT t2.b, t2.c FROM t3 RIGHT JOIN t2 ON t2.a = t3.b) AS t + WHERE t.b AND t.c = t1.a; +SELECT t.b, t.c, t1.a +FROM t1, (SELECT t2.b, t2.c FROM t3 RIGHT JOIN t2 ON t2.a = t3.b) AS t + WHERE t.b AND t.c = t1.a; + +EXPLAIN EXTENDED +SELECT t.b, t.c, t1.a +FROM t1, (SELECT t2.b, t2.c FROM t3 RIGHT JOIN t2 ON t2.a = t3.b) AS t + WHERE t.b <> 0 AND t.c = t1.a; +SELECT t.b, t.c, t1.a +FROM t1, (SELECT t2.b, t2.c FROM t3 RIGHT JOIN t2 ON t2.a = t3.b) AS t + WHERE t.b <> 0 AND t.c = t1.a; + +INSERT INTO t3 VALUES (100), (200); + +EXPLAIN EXTENDED +SELECT t.b, t.c, t1.a +FROM t1, (SELECT t2.b, t2.c FROM t3 RIGHT JOIN t2 ON t2.a = t3.b) AS t + WHERE t.b AND t.c = t1.a; +SELECT t.b, t.c, t1.a +FROM t1, (SELECT t2.b, t2.c FROM t3 RIGHT JOIN t2 ON t2.a = t3.b) AS t + WHERE t.b AND t.c = t1.a; + +EXPLAIN EXTENDED +SELECT t.b, t.c, t1.a +FROM t1, (SELECT t2.b, t2.c FROM t3 RIGHT JOIN t2 ON t2.a = t3.b) AS t + WHERE t.b <> 0 AND t.c = t1.a; +SELECT t.b, t.c, t1.a +FROM t1, (SELECT t2.b, t2.c FROM t3 RIGHT JOIN t2 ON t2.a = t3.b) AS t + WHERE t.b <> 0 AND t.c = t1.a; + +DROP TABLE t1,t2,t3; + +--echo # +--echo # Bug #880724: materialized const view as inner table of outer join +--echo # + +CREATE TABLE t1 (a int, b varchar(1)); +INSERT INTO t1 VALUES (9,NULL), (6,'r'), (7,'c'); + +CREATE TABLE t2 (a int); +INSERT INTO t2 VALUES (6); + +CREATE ALGORITHM=TEMPTABLE VIEW v2 AS SELECT * FROM t2; + +SET SESSION optimizer_switch = 'derived_with_keys=on'; +SET SESSION join_cache_level = 4; + +EXPLAIN +SELECT t1.b,v2.a FROM t1 LEFT JOIN v2 ON v2.a = t1.a; +SELECT t1.b,v2.a FROM t1 LEFT JOIN v2 ON v2.a = t1.a; + +CREATE TABLE t3 (a int, b varchar(1)); +INSERT INTO t3 VALUES (8,'x'), (5,'r'), (9,'y'); + +EXPLAIN +SELECT * FROM t3 + WHERE t3.b <> ANY (SELECT t1.b FROM t1 LEFT JOIN v2 ON v2.a = t1.a); +SELECT * FROM t3 + WHERE t3.b <> ANY (SELECT t1.b FROM t1 LEFT JOIN v2 ON v2.a = t1.a); + +SET SESSION join_cache_level = default; + +DROP VIEW v2; +DROP TABLE t1,t2,t3; + +--echo # +--echo # Bug #881449: OUTER JOIN usin a merged view within IN subquery +--echo # + +CREATE TABLE t1 (a varchar(1)) ; +INSERT INTO t1 VALUES ('y'), ('x'); + +CREATE TABLE t2 (a int, PRIMARY KEY (a)) ; +INSERT INTO t2 VALUES (1), (2); + +CREATE TABLE t3 (a int, b varchar(1)) ; +INSERT INTO t3 VALUES (1,'x'); + +CREATE VIEW v3 AS SELECT * FROM t3; + +SET SESSION optimizer_switch='semijoin=on'; + +EXPLAIN +SELECT * FROM t1 WHERE a IN (SELECT v3.b FROM t2 RIGHT JOIN v3 ON v3.a = t2.a); +SELECT * FROM t1 WHERE a IN (SELECT v3.b FROM t2 RIGHT JOIN v3 ON v3.a = t2.a); + +set optimizer_switch= @save_optimizer_switch; + +DROP VIEW v3; +DROP TABLE t1,t2,t3; + +--echo # +--echo # Bug #874035: view as an inner table of a materialized derived +--echo # + +CREATE TABLE t2 (a int NOT NULL); +INSERT INTO t2 VALUES (7), (4); + +CREATE TABLE t1 (b int NOT NULL); +INSERT INTO t1 VALUES (5), (7); +CREATE ALGORITHM=MERGE VIEW v1 AS SELECT * FROM t1; + +SET SESSION optimizer_switch='derived_merge=off'; + +PREPARE st1 FROM +'SELECT * FROM (SELECT * FROM t2 LEFT JOIN v1 ON t2.a = v1.b) AS t'; +EXECUTE st1; +EXECUTE st1; +DEALLOCATE PREPARE st1; + +DROP VIEW v1; +DROP TABLE t1,t2; + +SET SESSION optimizer_switch='derived_merge=on'; + +--echo # +--echo # LP bug #879939: assertion in ha_maria::enable_indexes +--echo # with derived_with_keys=on +--echo # + +CREATE TABLE t2 (a varchar(3)); +INSERT INTO t2 VALUES ('USA'), ('USA'), ('USA'), ('USA'), ('USA'); + +CREATE TABLE t1 (a varchar(3), b varchar(35)); +INSERT INTO t1 VALUES + ('USA','Lansing'), ('USA','Laredo'), ('USA','Las Vegas'), + ('USA','Lexington-Fayett'), ('USA','Lincoln'), ('USA','Little Rock'), + ('USA','Livonia'), ('USA','Long Beach'), ('USA','Los Angeles'), + ('USA','Louisville'), ('USA','Lowell'), ('USA','Lubbock'), + ('USA','Macon'), ('USA','Madison'), ('USA','Manchester'), + ('USA','McAllen'), ('USA','Memphis'), ('USA','Mesa'), + ('USA','Mesquite'), ('USA','Metairie'), ('USA','Miami'); + +CREATE TABLE t3 (a varchar(35)); +INSERT INTO t3 VALUES ('Miami'); + +SET optimizer_switch = 'derived_with_keys=on'; +SET @@tmp_table_size=1024*4; +explain SELECT * FROM (SELECT t1.* FROM t1, t2) AS t JOIN t3 ON t3.a = t.b; +SELECT * FROM (SELECT t1.* FROM t1, t2) AS t JOIN t3 ON t3.a = t.b; +SET @@tmp_table_size=1024*1024*16; +SELECT * FROM (SELECT t1.* FROM t1, t2) AS t JOIN t3 ON t3.a = t.b; +SET @@tmp_table_size=default; + +drop table t1,t2,t3; + +--echo # +--echo # BUG#882994: Crash in QUICK_RANGE_SELECT::reset with derived_with_keys +--echo # +CREATE TABLE t2 ( + pk varchar(33), + col_varchar_key varchar(3) NOT NULL, + col_varchar_nokey varchar(52) NOT NULL); + +INSERT INTO t2 VALUES ('NICSpanish','NIC','Spanish'), + ('NERHausa','NER','Hausa'),('NGAJoruba','NGA','Joruba'), + ('NIUNiue','NIU','Niue'),('NFKEnglish','NFK','English'), + ('NORNorwegian','NOR','Norwegian'),('CIVAkan','CIV','Akan'), + ('OMNArabic','OMN','Arabic'),('PAKPunjabi','PAK','Punjabi'), + ('PLWPalau','PLW','Palau'),('PANSpanish','PAN','Spanish'), + ('PNGPapuan Langua','PNG','Papuan Languages'), ('PRYSpanish','PRY','Spanish'), + ('PERSpanish','PER','Spanish'), ('PCNPitcairnese','PCN','Pitcairnese'), + ('MNPPhilippene La','MNP','Philippene Langu'),('PRTPortuguese','PRT','Portuguese'), + ('PRISpanish','PRI','Spanish'),('POLPolish','POL','Polish'),('GNQFang','GNQ','Fang'); + +CREATE TABLE t1 ( col_varchar_nokey varchar(52) NOT NULL ) ; +INSERT INTO t1 VALUES ('Chinese'),('English'),('French'),('German'), + ('Italian'),('Japanese'),('Korean'),('Polish'),('Portuguese'),('Spanish'), + ('Tagalog'),('Vietnamese'); +CREATE TABLE t3 ( col_varchar_key varchar(52)) ; +INSERT INTO t3 VALUES ('United States'); + +set @tmp_882994= @@max_heap_table_size; +--disable_warnings +set max_heap_table_size=1; +--enable_warnings + +SELECT * +FROM t3 JOIN +( SELECT t2.* FROM t1, t2 ) AS alias2 +ON ( alias2.col_varchar_nokey = t3.col_varchar_key ) +ORDER BY CONCAT(alias2.col_varchar_nokey); + +set max_heap_table_size= @tmp_882994; +drop table t1,t2,t3; + # The following command must be the last one the file set optimizer_switch=@exit_optimizer_switch; diff --git a/mysql-test/t/disabled.def b/mysql-test/t/disabled.def index 45b785e6a80..ce9f57b130f 100644 --- a/mysql-test/t/disabled.def +++ b/mysql-test/t/disabled.def @@ -9,6 +9,7 @@ # Do not use any TAB characters for whitespace. # ############################################################################## +tablespace : disabled in MariaDB (no TABLESPACE table attribute) events_time_zone : Test is not predictable as it depends on precise timing. lowercase_table3 : Bug#11762269 2010-06-30 alik main.lowercase_table3 on Mac OSX read_many_rows_innodb : Bug#11748886 2010-11-15 mattiasj report already exists @@ -17,5 +18,4 @@ alter_table-big : Bug#11748731 2010-11-15 mattiasj was not tested create-big : Bug#11748731 2010-11-15 mattiasj was not tested archive-big : Bug#11817185 2011-03-10 Anitha Disabled since this leads to timeout on Solaris Sparc log_tables-big : Bug#11756699 2010-11-15 mattiasj report already exists -mysql_embedded : Bug#12561297 2011-06-15 New test failing on all platforms -tablespace : disabled in MariaDB (no TABLESPACE table attribute) +mysql_embedded : Bug#12561297 2011-05-14 Anitha Dependent on PB2 changes - eventum#41836 diff --git a/mysql-test/t/error_simulation.test b/mysql-test/t/error_simulation.test index f6edacfaa29..a60eccad3d8 100644 --- a/mysql-test/t/error_simulation.test +++ b/mysql-test/t/error_simulation.test @@ -89,6 +89,7 @@ SET SESSION debug = DEFAULT; DROP TABLE t1, t2; + --echo # --echo # End of 5.1 tests --echo # diff --git a/mysql-test/t/execution_constants.test b/mysql-test/t/execution_constants.test index 92b1deb9921..285197cd1f4 100644 --- a/mysql-test/t/execution_constants.test +++ b/mysql-test/t/execution_constants.test @@ -38,7 +38,7 @@ while ($i) { # If we SEGV because the min stack size is exceeded, this would return error # 2013 . - error 0,1436 // + error 0,ER_STACK_OVERRUN_NEED_MORE // eval $query_head 0 $query_tail// if ($mysql_errno) @@ -48,10 +48,10 @@ while ($i) # limit, we still have enough space reserved to report an error. let $i = 1// - # Check that mysql_errno is 1436 - if ($mysql_errno != 1436) + # Check that mysql_errname is ER_STACK_OVERRUN_NEED_MORE + if ($mysql_errname != ER_STACK_OVERRUN_NEED_MORE) { - die Wrong error triggered, expected 1436 but got $mysql_errno// + die Wrong error triggered, expected ER_STACK_OVERRUN_NEED_MORE but got $mysql_errname// } } @@ -76,7 +76,7 @@ while ($i) enable_result_log// enable_query_log// -echo Assertion: mysql_errno 1436 == $mysql_errno// +echo Assertion: mysql_errname ER_STACK_OVERRUN_NEED_MORE == $mysql_errname// delimiter ;// DROP TABLE `t_bug21476`; diff --git a/mysql-test/t/explain.test b/mysql-test/t/explain.test index 2fb0fb8fac7..ece2e968b83 100644 --- a/mysql-test/t/explain.test +++ b/mysql-test/t/explain.test @@ -152,19 +152,17 @@ DROP TABLE t1; --echo # explain extended crash with subquery and ONLY_FULL_GROUP_BY sql_mode --echo # -CREATE TABLE t1 (f1 INT); +CREATE TABLE t1 (f1 INT not null); SELECT @@session.sql_mode INTO @old_sql_mode; SET SESSION sql_mode='ONLY_FULL_GROUP_BY'; -# EXPLAIN EXTENDED (with subselect). used to crash. should give NOTICE. -# Before moving max/min optimization to optimize phase this statement -# generated error, but as far as original query do not contain aggregate -# function user should not see error -# --error ER_MIX_OF_GROUP_FUNC_AND_FIELDS +# EXPLAIN EXTENDED (with subselect). used to crash. +# This is actually a valid query for this sql_mode, +# but it was transformed in such a way that it failed, see +# Bug#12329653 - EXPLAIN, UNION, PREPARED STATEMENT, CRASH, SQL_FULL_GROUP_BY EXPLAIN EXTENDED SELECT 1 FROM t1 WHERE f1 > ALL( SELECT t.f1 FROM t1,t1 AS t ); -SHOW WARNINGS; SET SESSION sql_mode=@old_sql_mode; diff --git a/mysql-test/t/feedback_plugin_install.opt b/mysql-test/t/feedback_plugin_install.opt new file mode 100644 index 00000000000..a711ae94e69 --- /dev/null +++ b/mysql-test/t/feedback_plugin_install.opt @@ -0,0 +1 @@ +--loose-feedback diff --git a/mysql-test/t/feedback_plugin_install.test b/mysql-test/t/feedback_plugin_install.test new file mode 100644 index 00000000000..81343c436c3 --- /dev/null +++ b/mysql-test/t/feedback_plugin_install.test @@ -0,0 +1,15 @@ +--source include/not_embedded.inc + +if (`select length('$FEEDBACK_SO') = 0`) { + skip No feedback plugin; +} + +--replace_regex /\.dll/.so/ +eval install plugin feedback soname '$FEEDBACK_SO'; +select plugin_status from information_schema.plugins where plugin_name='feedback'; +--replace_result https http +--sorted_result +select * from information_schema.feedback where variable_name like 'feed%' + and variable_name not like '%_uid'; +uninstall plugin feedback; + diff --git a/mysql-test/t/feedback_plugin_load.opt b/mysql-test/t/feedback_plugin_load.opt new file mode 100644 index 00000000000..5fbb2f83954 --- /dev/null +++ b/mysql-test/t/feedback_plugin_load.opt @@ -0,0 +1,2 @@ +--loose-feedback +--plugin-load=$FEEDBACK_SO diff --git a/mysql-test/t/feedback_plugin_load.test b/mysql-test/t/feedback_plugin_load.test new file mode 100644 index 00000000000..5ad301667b4 --- /dev/null +++ b/mysql-test/t/feedback_plugin_load.test @@ -0,0 +1,10 @@ +if (`select count(*) = 0 from information_schema.plugins where plugin_name = 'feedback' and plugin_status='active'`) +{ + --skip Feedback plugin is not active +} + +select plugin_status from information_schema.plugins where plugin_name='feedback'; +--replace_result https http +--sorted_result +select * from information_schema.feedback where variable_name like 'feed%' + and variable_name not like '%_uid'; diff --git a/mysql-test/t/feedback_plugin_send.test b/mysql-test/t/feedback_plugin_send.test new file mode 100644 index 00000000000..14765ee9543 --- /dev/null +++ b/mysql-test/t/feedback_plugin_send.test @@ -0,0 +1,23 @@ +source t/feedback_plugin_load.test; + +if (!$MTR_FEEDBACK_PLUGIN) { + skip MTR_FEEDBACK_PLUGIN is not set; +} + +# +# Yep. The plugin waits 5 minutes before sending anything, +# and there's no way to force it to send anything sooner. +# Let's wait, and hope that mtr is started with --parallel and +# is doing some work in other workers. +# +sleep 310; +source include/restart_mysqld.inc; + +replace_result https http; +perl; + $log_error= $ENV{'MYSQLTEST_VARDIR'} . '/log/mysqld.1.err'; + open(LOG, '<', $log_error) or die "open(< $log_error): $!"; + /feedback plugin:.*/ && print "$&\n" while $_=<LOG>; + close LOG; +EOF + diff --git a/mysql-test/t/flush.test b/mysql-test/t/flush.test index de23cf02c38..037e2fcaa73 100644 --- a/mysql-test/t/flush.test +++ b/mysql-test/t/flush.test @@ -668,3 +668,36 @@ ALTER TABLE t1 COMMENT 'test'; UNLOCK TABLES; DROP TABLE t1; + + +--echo # +--echo # Test for bug #12641342 - "61401: UPDATE PERFORMANCE DEGRADES +--echo # GRADUALLY IF A TRIGGER EXISTS". +--echo # +--echo # One of side-effects of this bug was that a transaction which +--echo # involved DML statements requiring prelocking blocked concurrent +--echo # FLUSH TABLES WITH READ LOCK for the whole its duration, while +--echo # correct behavior in this case is to block FTWRL only for duration +--echo # of individual DML statements. +--disable_warnings +DROP TABLE IF EXISTS t1; +--enable_warnings +CREATE TABLE t1 (id INT PRIMARY KEY, value INT); +INSERT INTO t1 VALUES (1, 1); +CREATE TRIGGER t1_au AFTER UPDATE ON t1 FOR EACH ROW SET @var = "a"; +BEGIN; +UPDATE t1 SET value= value + 1 WHERE id = 1; + +--echo # Switching to connection 'con1'. +connect(con1, localhost, root); +--echo # The below FLUSH TABLES WITH READ LOCK should succeed and +--echo # should not be blocked by the transaction in default connection. +FLUSH TABLES WITH READ LOCK; +UNLOCK TABLES; +disconnect con1; +--source include/wait_until_disconnected.inc + +--echo # Switching to connection 'default'. +connection default; +COMMIT; +DROP TABLE t1; diff --git a/mysql-test/t/fulltext.test b/mysql-test/t/fulltext.test index e49970047a2..b4b09413896 100644 --- a/mysql-test/t/fulltext.test +++ b/mysql-test/t/fulltext.test @@ -437,6 +437,8 @@ show warnings; CREATE TABLE t1 (a VARCHAR(255), b INT, FULLTEXT(a), KEY(b)); INSERT INTO t1 VALUES('test', 1),('test', 1),('test', 1),('test', 1), ('test', 1),('test', 2),('test', 3),('test', 4); +INSERT INTO t1 VALUES('test', 5),('test', 6),('test', 7),('test', 8), + ('test', 5),('test', 6),('test', 7),('test', 8); EXPLAIN SELECT * FROM t1 WHERE MATCH(a) AGAINST('test' IN BOOLEAN MODE) AND b=1; diff --git a/mysql-test/t/fulltext_plugin.test b/mysql-test/t/fulltext_plugin.test index 5f09992d464..0e2f53d5b15 100644 --- a/mysql-test/t/fulltext_plugin.test +++ b/mysql-test/t/fulltext_plugin.test @@ -3,7 +3,7 @@ # # BUG#39746 - Debug flag breaks struct definition (server crash) # ---replace_regex /\.dll/.so/ +--replace_result .dll .so eval INSTALL PLUGIN simple_parser SONAME '$MYPLUGLIB_SO'; CREATE TABLE t1(a TEXT, b TEXT, FULLTEXT(a) WITH PARSER simple_parser); ALTER TABLE t1 ADD FULLTEXT(b) WITH PARSER simple_parser; diff --git a/mysql-test/t/func_group.test b/mysql-test/t/func_group.test index 77b2fd67ffa..a18ce6b5c51 100644 --- a/mysql-test/t/func_group.test +++ b/mysql-test/t/func_group.test @@ -1139,6 +1139,13 @@ INSERT INTO t1 VALUES (0000),(2001); --disable_metadata DROP TABLE t1; +--echo # +--echo # LP BUG#813418 - incorrect optimisation of max/min by index for +--echo # negated BETWEEN +CREATE TABLE t1 (a int, KEY (a)); +INSERT INTO t1 VALUES (1),(2),(3),(4),(5),(6),(7),(8),(9),(10); +SELECT MAX(a) FROM t1 WHERE a NOT BETWEEN 3 AND 9; +drop table t1; --echo # --echo End of 5.1 tests diff --git a/mysql-test/t/func_in.test b/mysql-test/t/func_in.test index 08469b37967..febec62f037 100644 --- a/mysql-test/t/func_in.test +++ b/mysql-test/t/func_in.test @@ -563,3 +563,23 @@ SELECT 1 IN (YEAR(FROM_UNIXTIME(NULL)) ,1); --echo # --echo End of 5.1 tests + +# +# lp:817966 int_column IN (string_constant) +# +# rather illogically, when BIGINT field is compared to a string, +# the string is converted to an integer, not to a double. +# When some other integer field (not BIGINT) is compared to a string, +# or when the BIGINT is not a field, but an expression, both +# operands are compared as doubles. The latter behavior is correct, +# according to the manual. +# +create table t1 (a bigint, b int); +insert t1 values (1,1),(2,2),(3,3); +select * from t1 where a in ('2.1'); +select * from t1 where b in ('2.1'); +select * from t1 where a='2.1'; +select * from t1 where b='2.1'; +select * from t1 where IF(1,a,a)='2.1'; +drop table t1; + diff --git a/mysql-test/t/func_math.test b/mysql-test/t/func_math.test index 0d59f98a313..a1df990fa8e 100644 --- a/mysql-test/t/func_math.test +++ b/mysql-test/t/func_math.test @@ -536,3 +536,25 @@ SELECT 1 div null; --echo # Bug #11792200 - DIVIDING LARGE NUMBERS CAUSES STACK CORRUPTIONS --echo # select (1.175494351E-37 div 1.7976931348623157E+308); + +--echo # +--echo # Bug#12537160 ASSERTION FAILED: +--echo # STOP0 <= &TO->BUF[TO->LEN] WITH LARGE NUMBER. +--echo # + +let $nine_81= +999999999999999999999999999999999999999999999999999999999999999999999999999999999; + +eval select $nine_81 % 0.1 as foo; +eval select $nine_81 % 0.0 as foo; + +--echo # +--echo # Bug#12711164 - 61676: +--echo # RESULT OF DIV WITH DECIMAL AND INTEGER DOES NOT MAKE SENSE +--echo # + +select 5 div 2; +select 5.0 div 2.0; +select 5.0 div 2; +select 5 div 2.0; +select 5.9 div 2, 1.23456789e3 DIV 2, 1.23456789e9 DIV 2, 1.23456789e19 DIV 2; diff --git a/mysql-test/t/func_str.test b/mysql-test/t/func_str.test index 9a9a8110a74..bb22366a98d 100644 --- a/mysql-test/t/func_str.test +++ b/mysql-test/t/func_str.test @@ -1437,5 +1437,24 @@ SELECT * FROM t1; DROP TABLE t1; --echo # +--echo # Bug#12985030 SIMPLE QUERY WITH DECIMAL NUMBERS LEAKS MEMORY +--echo # + +SELECT (rpad(1.0,2048,1)) IS NOT FALSE; +SELECT ((+0) IN +((0b111111111111111111111111111111111111111111111111111),(rpad(1.0,2048,1)), +(32767.1))); +SELECT ((rpad(1.0,2048,1)) = ('4(') ^ (0.1)); + +--error 1690 +SELECT +pow((rpad(10.0,2048,1)),(b'1111111111111111111111111111111111111111111')); +SELECT ((rpad(1.0,2048,1)) + (0) ^ ('../')); +SELECT stddev_samp(rpad(1.0,2048,1)); +SELECT ((127.1) not in ((rpad(1.0,2048,1)),(''),(-1.1))); +SELECT ((0xf3) * (rpad(1.0,2048,1)) << (0xcc)); + + +--echo # --echo # End of 5.5 tests --echo # diff --git a/mysql-test/t/func_time.test b/mysql-test/t/func_time.test index cdac95523e5..7d0e5ae819a 100644 --- a/mysql-test/t/func_time.test +++ b/mysql-test/t/func_time.test @@ -18,6 +18,8 @@ select sec_to_time(9001),sec_to_time(9001)+0,time_to_sec("15:12:22"), select sec_to_time(9001.1), time_to_sec('15:12:22.123456'), time_to_sec(15.5566778899); select sec_to_time(time_to_sec('-838:59:59')); select sec_to_time('9001.1'), sec_to_time('1234567890123.123'); +select sec_to_time(-9001.1), sec_to_time(-9001.1) / 1, + sec_to_time(-9001.1) / 1e0, sec_to_time(-9001) div 1; --replace_result e+042 e+42 select sec_to_time(90011e-1), sec_to_time(1234567890123e30); select sec_to_time(1234567890123), sec_to_time('99999999999999999999999999999'); @@ -919,6 +921,12 @@ SELECT DATE_FORMAT('0000-00-11', '%w'); SELECT MAKEDATE(11111111,1); SELECT WEEK(DATE_ADD(FROM_DAYS(1),INTERVAL 1 MONTH), 1); +--echo # +--echo # Bug#12584302 AFTER FIX FOR #12403504: ASSERTION FAILED: DELSUM+(INT) Y/4-TEMP > 0, +--echo # + +DO WEEK((DATE_ADD((CAST(0 AS DATE)), INTERVAL 1 YEAR_MONTH)), 5); + --echo End of 5.1 tests --echo # diff --git a/mysql-test/t/gis.test b/mysql-test/t/gis.test index 2a800140d1f..104afddeee5 100644 --- a/mysql-test/t/gis.test +++ b/mysql-test/t/gis.test @@ -820,5 +820,23 @@ CREATE TABLE t3 ( # cleanup DROP TABLE t0, t1, t2; +--echo # +--echo # Bug#11908153: CRASH AND/OR VALGRIND ERRORS IN FIELD_BLOB::GET_KEY_IMAGE +--echo # + +CREATE TABLE g1 +(a geometry NOT NULL, UNIQUE KEY i (a(151))) engine=myisam; + +INSERT INTO g1 VALUES (geomfromtext('point(1 1)')); +INSERT INTO g1 VALUES (geomfromtext('point(1 2)')); + +FLUSH TABLES; + +SELECT 1 FROM g1 +FORCE INDEX(i) WHERE a = date_sub(now(), interval 2808.4 year_month) +; + +DROP TABLE g1; + --echo End of 5.5 tests diff --git a/mysql-test/t/group_by.test b/mysql-test/t/group_by.test index f739870ca07..30f5657ffdf 100644 --- a/mysql-test/t/group_by.test +++ b/mysql-test/t/group_by.test @@ -1297,6 +1297,20 @@ FROM t1 GROUP BY a; DROP TABLE t1; +--echo # +--echo # Bug#11765254 (58200): Assertion failed: param.sort_length when grouping +--echo # by functions +--echo # + +SET SQL_BIG_TABLES=1; +CREATE TABLE t1(a INT); +INSERT INTO t1 VALUES (0),(0); +SELECT 1 FROM t1 GROUP BY IF(`a`,'',''); +SELECT 1 FROM t1 GROUP BY TRIM(LEADING RAND() FROM ''); +SELECT 1 FROM t1 GROUP BY SUBSTRING('',SLEEP(0),''); +SELECT 1 FROM t1 GROUP BY SUBSTRING(SYSDATE() FROM 'K' FOR 'jxW<'); +DROP TABLE t1; +SET SQL_BIG_TABLES=0; --echo # End of 5.1 tests @@ -1322,3 +1336,20 @@ SELECT f1,MIN(f2),MAX(f2) FROM t1 GROUP BY 1; DROP TABLE t1; --echo #End of test#49771 +--echo # +--echo # lp:872702: Crash in add_ref_to_table_cond() when grouping by a PK +--echo # +CREATE TABLE t1 (a int, PRIMARY KEY (a)) ; +INSERT INTO t1 VALUES (14),(15),(16),(17),(18),(19),(20); + +CREATE TABLE t2 (a int) ; + +SELECT a +FROM t1 +WHERE a = ( + SELECT t2.a + FROM t2 +) OR t1.a = 73 +GROUP BY 1; +DROP TABLE t1, t2; + diff --git a/mysql-test/t/heap.test b/mysql-test/t/heap.test index e5700eaeeb8..7d56425799a 100644 --- a/mysql-test/t/heap.test +++ b/mysql-test/t/heap.test @@ -459,7 +459,7 @@ drop table t1; # create table t1 (c char(10)) engine=memory; create table t2 (c varchar(10)) engine=memory; ---replace_column 8 # +--replace_column 8 # 12 # show table status like 't_'; drop table t1, t2; diff --git a/mysql-test/t/implicit_commit.test b/mysql-test/t/implicit_commit.test index b10788bd891..59f8dc3a44c 100644 --- a/mysql-test/t/implicit_commit.test +++ b/mysql-test/t/implicit_commit.test @@ -1,5 +1,6 @@ source include/have_innodb.inc; source include/not_embedded.inc; +source include/have_profiling.inc; SET GLOBAL EVENT_SCHEDULER = OFF; SET BINLOG_FORMAT = STATEMENT; diff --git a/mysql-test/t/index_merge_myisam.test b/mysql-test/t/index_merge_myisam.test index 5431c6dba2b..614c6595d61 100644 --- a/mysql-test/t/index_merge_myisam.test +++ b/mysql-test/t/index_merge_myisam.test @@ -125,5 +125,29 @@ set optimizer_switch=default; drop table t0, t1; + +--echo # +--echo # BUG#834514 Assertion `!table || (!table->read_set || bitmap_is_set(...' with aggregates +--echo # +CREATE TABLE t1 ( a int , b int, c int, KEY (b), PRIMARY KEY (a)) ; +INSERT INTO t1 VALUES (1,4,0),(5,0,0),(6,7,0),(7,7,0),(8,1,0),(9,7,0),(10,1,0); + +CREATE TABLE t2 ( b int, c int, KEY (c,b)) ; +INSERT INTO t2 VALUES (7,0),(1,0),(7,0),(1,0); + +CREATE TABLE t3 ( a int ) ; + +SELECT COUNT(DISTINCT t2.b), CONCAT(t1.c) +FROM t1, t2 +WHERE (t2.c = t1.c) +AND ( + t1.b IN ( 4 ) + OR t1.a = 137 + AND EXISTS ( SELECT a FROM t3 ) +) +GROUP BY 2; + +DROP TABLE t1,t2,t3; + set optimizer_switch= @optimizer_switch_save; diff --git a/mysql-test/t/information_schema.test b/mysql-test/t/information_schema.test index 4a43969a057..5b5e2137d0e 100644 --- a/mysql-test/t/information_schema.test +++ b/mysql-test/t/information_schema.test @@ -1540,8 +1540,6 @@ DROP TABLE t1, information_schema.tables; LOCK TABLES t1 READ, information_schema.tables READ; DROP TABLE t1; -# Wait till all disconnects are completed ---source include/wait_until_count_sessions.inc # # Bug #43834 Assertion in Natural_join_column::db_name() on an I_S query @@ -1606,5 +1604,185 @@ drop view v1; --echo # +--echo # Test for bug #12828477 - "MDL SUBSYSTEM CREATES BIG OVERHEAD FOR +--echo # CERTAIN QUERIES TO INFORMATION_SCHEMA". +--echo # +--echo # Check that metadata locks which are acquired during the process +--echo # of opening tables/.FRMs/.TRG files while filling I_S table are +--echo # not kept to the end of statement. Keeping the locks has caused +--echo # performance problems in cases when big number of tables (.FRMs +--echo # or .TRG files) were scanned as cost of new lock acquisition has +--echo # increased linearly. +--disable_warnings +drop database if exists mysqltest; +--enable_warnings +create database mysqltest; +use mysqltest; +create table t0 (i int); +create table t1 (j int); +create table t2 (k int); + +--echo # +--echo # Test that we don't keep locks in case when we to fill +--echo # I_S table we perform full-blown table open. +--echo # + +--echo # Acquire lock on 't2' so upcoming RENAME is +--echo # blocked. +lock tables t2 read; + +--echo # +--echo # Switching to connection 'con12828477_1'. +--echo # +connect (con12828477_1, localhost, root,,mysqltest); +--echo # The below RENAME should wait on 't2' while +--echo # keeping X lock on 't1'. +--send rename table t1 to t3, t2 to t1, t3 to t2 + +--echo # +--echo # Switching to connection 'con12828477_2'. +--echo # +connect (con12828477_2, localhost, root,,mysqltest); +--echo # Wait while the above RENAME is blocked. +let $wait_condition= + select count(*) = 1 from information_schema.processlist + where state = "Waiting for table metadata lock" and + info = "rename table t1 to t3, t2 to t1, t3 to t2"; +--source include/wait_condition.inc + +--echo # Issue query to I_S which will open 't0' and get +--echo # blocked on 't1' because of RENAME. +--send select table_name, auto_increment from information_schema.tables where table_schema='mysqltest' + +--echo # +--echo # Switching to connection 'con12828477_3'. +--echo # +connect (con12828477_3, localhost, root,,mysqltest); +--echo # Wait while the above SELECT is blocked. +let $wait_condition= + select count(*) = 1 from information_schema.processlist + where state = "Waiting for table metadata lock" and + info = "select table_name, auto_increment from information_schema.tables where table_schema='mysqltest'"; +--source include/wait_condition.inc + +--echo # +--echo # Check that it holds no lock on 't0' so it can be renamed. +rename table t0 to t4; + +--echo # +--echo # Switching to connection 'default'. +--echo # +connection default; +--echo # +--echo # Unblock the first RENAME. +unlock tables; + +--echo # +--echo # Switching to connection 'con12828477_1'. +--echo # +connection con12828477_1; +--echo # Reap the first RENAME +--reap + +--echo # +--echo # Switching to connection 'con12828477_2'. +--echo # +connection con12828477_2; +--echo # Reap SELECT to I_S. +--reap + +--echo # +--echo # Switching to connection 'default'. +--echo # +connection default; + +--echo # +--echo # Now test that we don't keep locks in case when we to fill +--echo # I_S table we read .FRM or .TRG file only (this was the case +--echo # for which problem existed). +--echo # + +rename table t4 to t0; +--echo # Acquire lock on 't2' so upcoming RENAME is +--echo # blocked. +lock tables t2 read; + +--echo # +--echo # Switching to connection 'con12828477_1'. +--echo # +connection con12828477_1; +--echo # The below RENAME should wait on 't2' while +--echo # keeping X lock on 't1'. +--send rename table t1 to t3, t2 to t1, t3 to t2 + +--echo # +--echo # Switching to connection 'con12828477_2'. +--echo # +connection con12828477_2; +--echo # Wait while the above RENAME is blocked. +let $wait_condition= + select count(*) = 1 from information_schema.processlist + where state = "Waiting for table metadata lock" and + info = "rename table t1 to t3, t2 to t1, t3 to t2"; +--source include/wait_condition.inc + +--echo # Issue query to I_S which will open 't0' and get +--echo # blocked on 't1' because of RENAME. +--send select event_object_table, trigger_name from information_schema.triggers where event_object_schema='mysqltest' + +--echo # +--echo # Switching to connection 'con12828477_3'. +--echo # +connection con12828477_3; +--echo # Wait while the above SELECT is blocked. +let $wait_condition= + select count(*) = 1 from information_schema.processlist + where state = "Waiting for table metadata lock" and + info = "select event_object_table, trigger_name from information_schema.triggers where event_object_schema='mysqltest'"; +--source include/wait_condition.inc + +--echo # +--echo # Check that it holds no lock on 't0' so it can be renamed. +rename table t0 to t4; + +--echo # +--echo # Switching to connection 'default'. +--echo # +connection default; +--echo # +--echo # Unblock the first RENAME. +unlock tables; + +--echo # +--echo # Switching to connection 'con12828477_1'. +--echo # +connection con12828477_1; +--echo # Reap the first RENAME +--reap + +--echo # +--echo # Switching to connection 'con12828477_2'. +--echo # +connection con12828477_2; +--echo # Reap SELECT to I_S. +--reap + +--echo # +--echo # Switching to connection 'default'. +--echo # +connection default; +disconnect con12828477_1; +disconnect con12828477_2; +disconnect con12828477_3; + +--echo # +--echo # Clean-up. +drop database mysqltest; + + +--echo # --echo # End of 5.5 tests --echo # + +# Wait till all disconnects are completed +--source include/wait_until_count_sessions.inc diff --git a/mysql-test/t/innodb_bug878769.test b/mysql-test/t/innodb_bug878769.test new file mode 100644 index 00000000000..157c7827dde --- /dev/null +++ b/mysql-test/t/innodb_bug878769.test @@ -0,0 +1,56 @@ +--source include/have_innodb.inc + +--disable_warnings +drop table if exists t1,t2; +--enable_warnings + +--echo # +--echo # Bug #878769: valgrind complains when using join cache +--echo # to join an InnoDB table without primary key +--echo # + +CREATE TABLE t1 ( + col_int_key int(11), col_time_key time, col_varchar_key varchar(1), + KEY (col_int_key), KEY (col_varchar_key,col_int_key) +) ENGINE=InnoDB; +INSERT IGNORE INTO t1 VALUES + (7,'10:19:31','d'),(1,'14:40:36','r'),(7,'04:37:47','f'),(9,'19:34:06','y'), + (2,'00:00:00','m'),(4,'00:13:25','q'),(0,'03:47:16',NULL),(4,'01:41:48','d'), + (8,'00:00:00','g'),(NULL,'22:32:04','x'),(NULL,'16:44:14','f'), + (0,'17:38:37','p'),(NULL,'08:46:48','j'),(8,'14:11:27','c'); + +CREATE TABLE t2 ( + col_int_nokey int(11), col_int_key int(11), + col_datetime_key datetime, col_datetime_nokey datetime, + col_varchar_key varchar(1), col_varchar_nokey varchar(1), + KEY (col_int_key), KEY (col_varchar_key,col_int_key) +); +INSERT IGNORE INTO t2 VALUES + (150,62,'2008-01-03 10:33:32','2008-01-03 10:33:32','v','v'), + (2,1,'2007-10-09 19:53:04','2007-10-09 19:53:04',NULL,NULL), + (5,0,'2001-11-08 21:02:12','2001-11-08 21:02:12','x','x'), + (3,7,'2003-04-01 00:00','2003-04-01 00:00','i','i'), + (1,7,'1900-01-01 00:00','1900-01-01 00:00:00','e','e'), + (NULL,7,'2005-04-04 01:21','2005-04-04 01:21','s','s'), + (2,1,'1900-01-01 00:00','1900-01-01 00:00','j','j'), + (8,0,'2004-04-28 21:44','2004-04-28 21:44','a','a'), + (6,8,'2001-04-18 00:00','2001-04-18 00:00:00','y','y'), + (8,1,'2008-12-18 19:39:55','2008-12-18 19:39:55',NULL,NULL), + (3,1,'2000-08-01 12:19:39','2000-08-01 12:19:39','r','r'), + (3,9,'2004-09-25 21:29:06','2004-09-25 21:29:06','v','v'); + +set session optimizer_switch='mrr=on,mrr_sort_keys=on'; +set session join_cache_level=6; + +EXPLAIN +SELECT t1.col_time_key, t1.col_varchar_key + FROM t2 STRAIGHT_JOIN t1 ON t1.col_int_key = t2.col_int_key +GROUP BY 1,2; +SELECT t1.col_time_key, t1.col_varchar_key + FROM t2 STRAIGHT_JOIN t1 ON t1.col_int_key = t2.col_int_key +GROUP BY 1,2; + +set session optimizer_switch=default; +set session join_cache_level=default; + +DROP TABLE t1,t2; diff --git a/mysql-test/t/join.test b/mysql-test/t/join.test index c4f2b6cb61f..82e67904e9f 100644 --- a/mysql-test/t/join.test +++ b/mysql-test/t/join.test @@ -1015,3 +1015,13 @@ SELECT STRAIGHT_JOIN * FROM t1 JOIN t2 ON t2.f2 = t1.f1 DROP TABLE t1,t2; +# +# Item_equal used cmp_item::get_comparator() incorrectly +# +create table t1 (i time key); +insert into t1 values ('1:1:1'), ('2:2:2'); +create table t2 (i time); +insert into t2 values ('1:1:1'); +select t2.i from t1 left join t2 on t2.i = t1.i where t1.i = '1:1:1'; +drop table t1,t2; + diff --git a/mysql-test/t/join_cache.test b/mysql-test/t/join_cache.test index ca0d10c3ee1..caf5af57df7 100644 --- a/mysql-test/t/join_cache.test +++ b/mysql-test/t/join_cache.test @@ -1220,7 +1220,9 @@ CREATE TABLE t2 (a int, b int, INDEX idx(a)); INSERT INTO t1 VALUES (5,30), (3,20), (7,40), (2,10), (8,30), (1,10), (4,20); INSERT INTO t2 VALUES (7,10), (1,20), (2,20), (8,20), (8,10), (1,20); INSERT INTO t2 VALUES (1,10), (4,20), (3,20), (7,20), (7,10), (1,20); - +INSERT INTO t2 VALUES (17,10), (11,20), (12,20), (18,20), (18,10), (11,20); +INSERT INTO t2 VALUES (11,10), (14,20), (13,20), (17,20), (17,10), (11,20); + set join_buffer_size=32; set join_cache_level=8; @@ -1241,6 +1243,7 @@ CREATE TABLE t1 (a int NOT NULL); INSERT INTO t1 VALUES (2), (4), (3), (5), (1); CREATE TABLE t2 (a int NOT NULL, b int NOT NULL, INDEX i_a(a)); INSERT INTO t2 VALUES (4,10), (2,10), (2,30), (2,20), (4,20); +INSERT INTO t2 VALUES (14,10), (12,10), (15,30), (12,20), (14,20); EXPLAIN SELECT * FROM t1 LEFT JOIN t2 ON t1.a=t2.a WHERE t2.b IS NULL; @@ -1564,6 +1567,9 @@ create table t2 (id1 int, id2 int, index idx2 (id1)); insert into t2 values (20, 100), (30, 400), (20, 400), (30, 200), (10, 300), (10, 200), (40, 100), (40, 200), (30, 300), (10, 400), (20, 200), (20, 300); +insert into t2 values + (21, 10), (31, 400), (21, 400), (31, 200), (11, 300), (11, 200), (41, 100), + (41, 200), (31, 300), (11, 400), (21, 200), (21, 300); set join_cache_level=6; @@ -1602,14 +1608,26 @@ insert into t2 values (30, 'bbb'), (10, 'b'), (70, 'bbbbbbb'), (60, 'bbbbbb'), (31, 'bbb'), (11, 'b'), (71, 'bbbbbbb'), (61, 'bbbbbb'), (32, 'bbb'), (12, 'b'), (72, 'bbbbbbb'), (62, 'bbbbbb'); +insert into t2 values + (130, 'bbb'), (110, 'b'), (170, 'bbbbbbb'), (160, 'bbbbbb'), + (131, 'bbb'), (111, 'b'), (171, 'bbbbbbb'), (161, 'bbbbbb'), + (132, 'bbb'), (112, 'b'), (172, 'bbbbbbb'), (162, 'bbbbbb'); insert into t3 values (4000, 'dddd'), (3000, 'ddd'), (1000, 'd'), (8000, 'dddddddd'), (4001, 'dddd'), (3001, 'ddd'), (1001, 'd'), (8001, 'dddddddd'), (4002, 'dddd'), (3002, 'ddd'), (1002, 'd'), (8002, 'dddddddd'); +insert into t3 values + (14000, 'dddd'), (13000, 'ddd'), (11000, 'd'), (18000, 'dddddddd'), + (14001, 'dddd'), (13001, 'ddd'), (11001, 'd'), (18001, 'dddddddd'), + (4002, 'dddd'), (3002, 'ddd'), (1002, 'd'), (8002, 'dddddddd'); insert into t4 values (200, 'cc'), (600, 'cccccc'), (300, 'ccc'), (500, 'ccccc'), (201, 'cc'), (601, 'cccccc'), (301, 'ccc'), (501, 'ccccc'), (202, 'cc'), (602, 'cccccc'), (302, 'ccc'), (502, 'ccccc'); +insert into t4 values + (1200, 'cc'), (1600, 'cccccc'), (1300, 'ccc'), (1500, 'ccccc'), + (1201, 'cc'), (1601, 'cccccc'), (1301, 'ccc'), (1501, 'ccccc'), + (1202, 'cc'), (1602, 'cccccc'), (1302, 'ccc'), (1502, 'ccccc'); --disable_result_log --disable_warnings @@ -2264,7 +2282,9 @@ CREATE TABLE t1 (b int); INSERT INTO t1 VALUES (NULL),(3); CREATE TABLE t2 (a int, b int, KEY (b)); -INSERT INTO t2 VALUES (100,NULL),(150,200); +INSERT INTO t2 VALUES + (100,NULL),(150,200),(50,150),(250,350),(180,210),(100,150), + (101,NULL),(151,200),(51,150),(251,350),(181,210),(101,150); set join_cache_level = 5; explain SELECT t2.a FROM t1 LEFT JOIN t2 ON t2.b = t1.b; @@ -2292,6 +2312,7 @@ INSERT INTO t1 VALUES (NULL),("some varchar"); CREATE TABLE t2 (a int, b varchar(100), KEY (b)); INSERT INTO t2 VALUES (100,NULL),(150,"varchar"),(200,NULL),(250,"long long varchar"); +INSERT INTO t2 VALUES (100,NULL),(150,"long varchar"),(200,"varchar"),(250,"long long long varchar"); set join_cache_level = 5; explain SELECT t2.a FROM t1 LEFT JOIN t2 ON t2.b = t1.b; @@ -2393,6 +2414,17 @@ INSERT INTO t3 VALUES (1,0,'2002-07-13','06:34:26','v','v'), (9,3,'2003-01-03','18:07:38','m','m'), (1,5,'2006-04-02','13:55:23','z','z'), (3,9,'2006-10-19','20:32:28','n','n'), (8,1,'2005-06-08','11:57:44','d','d'), (231,107,'2006-12-26','03:10:35','a','a'); +INSERT INTO t3 VALUES + (103,108,'2008-12-04','00:00:00','a','v'), (103,108,'2009-03-28','00:00:00','b','f'), + (103,105,'1900-01-01','00:55:47','c','v'), (102,108,'2009-10-02','00:00:00','d','s'), + (100,108,'1900-01-01','20:51:59','e','a'), (100,106,'2008-06-04','09:47:27','f','p'), + (108,107,'2009-01-13','21:58:29','g','z'), (105,102,'1900-01-01','22:45:53','h','a'), + (109,105,'2008-01-28','14:06:48','i','h'), (105,107,'2004-09-18','22:17:16','j','h'), + (104,102,'2006-10-14','14:59:37','k','v'), (102,109,'1900-01-01','23:37:40','l','v'), + (1033,1142,'2000-11-28','14:14:01','m','b'), (105,103,'2008-04-04','02:54:19','n','y'), + (100,100,'2002-07-13','06:34:26','o','v'), (109,103,'2003-01-03','18:07:38','p','m'), + (100,105,'2006-04-02','13:55:23','q','z'), (103,109,'2006-10-19','20:32:28','s','n'), + (108,100,'2005-06-08','11:57:44','t','d'), (1231,1107,'2006-12-26','03:10:35','v','a'); CREATE TABLE t1 SELECT * FROM t3; DELETE FROM t1 WHERE i > 8; @@ -2425,7 +2457,15 @@ CREATE TABLE t1 ( INSERT INTO t1 VALUES (10,8,'v'), (11,8,'f'), (12,5,'v'), (13,8,'s'), (14,8,'a'), (15,6,'p'), (16,7,'z'), (17,2,'a'), (18,5,'h'), (19,7,'h'), - (25,3,'m'), (26,5,'z'), (27,9,'n'), (28,1,'d'), (29,107,'a'); + (25,3,'m'), (26,5,'a'), (27,9,'n'), (28,1,'d'), (29,107,'a'); +INSERT INTO t1 VALUES + (110,8,'x'), (111,8,'y'), (112,5,'v'), (113,8,'z'), (114,8,'i'), + (115,6,'j'), (116,7,'t'), (117,2,'b'), (118,5,'j'), (119,7,'w'), + (125,3,'q'), (126,5,'o'), (127,9,'n'), (128,1,'e'), (129,107,'c'); +INSERT INTO t1 VALUES + (210,8,'b'), (211,8,'c'), (212,5,'d'), (213,8,'e'), (214,8,'g'), + (215,6,'f'), (216,7,'h'), (217,2,'i'), (218,5,'j'), (219,7,'k'), + (225,3,'l'), (226,5,'m'), (227,9,'n'), (228,1,'o'), (229,107,'p'); CREATE TABLE t2 ( pk int NOT NULL, i int NOT NULL, v varchar(1) NOT NULL, @@ -2435,7 +2475,7 @@ INSERT INTO t2 VALUES (10,8,'v'), (11,8,'f'), (12,5,'v'), (13,8,'s'), (14,8,'a'), (15,6,'p'), (16,7,'z'), (17,2,'a'), (18,5,'h'), (19,7,'h'), (20,2,'v'), (21,9,'v'), (22,142,'b'), (23,3,'y'), (24,0,'v'), - (25,3,'m'), (26,5,'z'), (27,9,'n'), (28,1,'d'), (29,107,'a'); + (25,3,'m'), (26,5,'b'), (27,9,'n'), (28,1,'d'), (29,107,'a'); CREATE TABLE t3 ( pk int NOT NULL, i int NOT NULL, v varchar(1) NOT NULL, @@ -2449,23 +2489,29 @@ INSERT INTO t3 VALUES SET SESSION join_cache_level=1; EXPLAIN -SELECT t2.v FROM t1, t2, t3 WHERE t3.v <> t2.v AND t3.pk = t2.i AND t1.v = t3.v +SELECT t2.v FROM t1, t2, t3 +WHERE t3.v <> t2.v AND t3.pk = t2.i AND t1.v = t3.v AND t1.pk*2<100 GROUP BY t2.v ORDER BY t1.pk,t2.v; -SELECT t2.v FROM t1, t2, t3 WHERE t3.v <> t2.v AND t3.pk = t2.i AND t1.v = t3.v +SELECT t2.v FROM t1, t2, t3 +WHERE t3.v <> t2.v AND t3.pk = t2.i AND t1.v = t3.v AND t1.pk*2<100 GROUP BY t2.v ORDER BY t1.pk,t2.v; SET SESSION join_cache_level=6; EXPLAIN -SELECT t2.v FROM t1, t2, t3 WHERE t3.v <> t2.v AND t3.pk = t2.i AND t1.v = t3.v +SELECT t2.v FROM t1, t2, t3 +WHERE t3.v <> t2.v AND t3.pk = t2.i AND t1.v = t3.v AND t1.pk*2<100 GROUP BY t2.v ORDER BY t1.pk,t2.v; -SELECT t2.v FROM t1, t2, t3 WHERE t3.v <> t2.v AND t3.pk = t2.i AND t1.v = t3.v +SELECT t2.v FROM t1, t2, t3 +WHERE t3.v <> t2.v AND t3.pk = t2.i AND t1.v = t3.v AND t1.pk*2<100 GROUP BY t2.v ORDER BY t1.pk,t2.v; SET SESSION join_cache_level=4; EXPLAIN -SELECT t2.v FROM t1, t2, t3 WHERE t3.v <> t2.v AND t3.pk = t2.i AND t1.v = t3.v +SELECT t2.v FROM t1, t2, t3 +WHERE t3.v <> t2.v AND t3.pk = t2.i AND t1.v = t3.v AND t1.pk*2<100 GROUP BY t2.v ORDER BY t1.pk,t2.v; -SELECT t2.v FROM t1, t2, t3 WHERE t3.v <> t2.v AND t3.pk = t2.i AND t1.v = t3.v +SELECT t2.v FROM t1, t2, t3 +WHERE t3.v <> t2.v AND t3.pk = t2.i AND t1.v = t3.v AND t1.pk*2<100 GROUP BY t2.v ORDER BY t1.pk,t2.v; DROP TABLE t1,t2,t3; @@ -2531,6 +2577,11 @@ INSERT INTO t2 VALUES (1, 12, 102), (8, 81, 801), (7, 70, 700), (12, 120, 1200), (8, 82, 802), (1, 13, 103), (1, 14, 104), (3, 31, 301), (1, 15, 105), (8, 83, 803), (7, 71, 701); +INSERT INTO t2 VALUES + (108, 80, 800), (101, 10, 100), (101, 11, 101), (103, 30, 300), + (101, 12, 102), (108, 81, 801), (107, 70, 700), (1012, 120, 1200), + (108, 82, 802), (101, 13, 103), (101, 14, 104), (103, 31, 301), + (101, 15, 105), (108, 83, 803), (107, 71, 701); SET SESSION join_cache_level = 4; SET SESSION join_buffer_size = 256; @@ -2567,6 +2618,12 @@ INSERT INTO t2 VALUES ('abcdefjhjk',1015414784), ('or',4), ('now',0), ('abcdefjhjk',-32702464), ('abcdefjhjk',4), ('time',1078394880), ('f',4), ('m',-1845559296), ('ff', 5), ('abcdefjhjk',-1074397184); +INSERT INTO t2 VALUES + ('dig',5), ('were',-1631322112), ('is',3), ('abcdefjhjl',3), + ('abcdefjh',4), ('told',-824573952), ('tt',0),('vv',-1711013888), + ('abcdefjhjj',1015414784), ('and',4), ('here',0), ('abcdefjhjm',-32702464), + ('abcdefjhji',4), ('space',1078394880), ('fs',4), ('mn',-1845559296), + ('fq', 5), ('abcdefjhjp',-1074397184); EXPLAIN SELECT t1.v,t2.i FROM t1,t2 WHERE t2.v = t1.v; @@ -2614,6 +2671,13 @@ INSERT INTO t2 VALUES (11,6,'yes'), (12,NULL,'will'), (13,NULL,'o'), (14,NULL,'k'), (15,NULL,'she'), (16,-1450835968,'abcdefjhjkl'), (17,-975831040,'abcdefjhjkl'), (18,NULL,'z'), (19,-343932928,'t'); +INSERT INTO t2 VALUES + (101,6,'yes'), (102,NULL,'will'), (103,NULL,'o'), (104,NULL,'k'), (105,NULL,'she'), + (106,-1450835968,'abcdefjhjkl'), (107,-975831040,'abcdefjhjkl'), (108,NULL,'z'), + (100,-343932928,'t'), + (111,6,'yes'), (112,NULL,'will'), (113,NULL,'o'), (114,NULL,'k'), (115,NULL,'she'), + (116,-1450835968,'abcdefjhjkl'), (117,-975831040,'abcdefjhjkl'), (118,NULL,'z'), + (119,-343932928,'t'); CREATE TABLE t3 ( pk int NOT NULL PRIMARY KEY, @@ -2630,6 +2694,15 @@ INSERT INTO t3 VALUES (26,NULL,'all'), (27,1443168256,'c'), (28,1427046400,'right'), (31,7,'abcdefjhjkl'), (32,6,'y'), (33,NULL,'to'), (34,7,'n'), (35,7,'look'), (36,NULL,'all'), (37,1443168256,'c'), (38,1427046400,'right'); +INSERT INTO t3 VALUES +(101,7,'abcdefjhjkl'),(102,6,'y'), (103,NULL,'to'),(104,7,'n'),(105,7,'look'), +(106,NULL,'all'), (107,1443168256,'c'), (108,1427046400,'right'), +(111,7,'abcdefjhjkl'), (112,6,'y'), (113,NULL,'to'), (114,7,'n'), (115,7,'look'), +(116,NULL,'all'), (117,1443168256,'c'), (118,1427046400,'right'), +(121,7,'abcdefjhjkl'), (122,6,'y'), (123,NULL,'to'), (124,7,'n'), (125,7,'look'), +(126,NULL,'all'), (127,1443168256,'c'), (128,1427046400,'right'), +(131,7,'abcdefjhjkl'), (132,6,'y'), (133,NULL,'to'), (134,7,'n'), (135,7,'look'), +(136,NULL,'all'), (137,1443168256,'c'), (138,1427046400,'right'); SET SESSION join_buffer_size = 256; @@ -2665,6 +2738,10 @@ INSERT INTO t2 VALUES (10, 'a'), (20, 'c'), (30, 'aa'), (4, 'bb'), (11, 'a'), (21, 'c'), (31, 'aa'), (41, 'cc'), (12, 'a'), (22, 'c'), (32, 'bb'), (42, 'aa'); +INSERT INTO t2 VALUES + (110, 'a'), (120, 'c'), (130, 'aa'), (14, 'bb'), + (111, 'a'), (121, 'c'), (131, 'aa'), (141, 'cc'), + (112, 'a'), (122, 'c'), (132, 'bb'), (142, 'aa'); SELECT * FROM t1,t2 WHERE t2.a=t1.a; @@ -2766,6 +2843,9 @@ INSERT IGNORE INTO t3 VALUES (9,0,0,2), (1,0,0,7); CREATE TABLE t4 (pk int, a4 int, INDEX idx(a4)) ; INSERT IGNORE INTO t4 VALUES (2,NULL), (8,0); +INSERT IGNORE INTO t4 VALUES (12,10), (18,20); +INSERT IGNORE INTO t4 VALUES (22,11), (28,21); +INSERT IGNORE INTO t4 VALUES (32,12), (38,22); CREATE TABLE t5 (pk int, a5 int) ; INSERT IGNORE INTO t5 VALUES (2,0), (8,0); @@ -2941,7 +3021,10 @@ INSERT INTO t1 VALUES INSERT INTO t2 VALUES (1,'Bbbb'), (2,'BBB'), (3,'bbbb'), (4,'AaA'), (5,'CC'), (6,'cC'), (7,'CCC'), (8,'AAA'), (9,'bBbB'), (10,'aaaa'), - (11,'a'), (12,'dd'), (13,'EE'), (14,'ee'), (15,'D'); + (11,'a'), (12,'dd'), (13,'EE'), (14,'ee'), (15,'D'), + (101,'Bbbb'), (102,'BBB'), (103,'bbbb'), (104,'AaA'), (105,'CC'), + (106,'cC'), (107,'CCC'), (108,'AAA'), (109,'bBbB'), (110,'aaaa'), + (111,'a'), (112,'dd'), (113,'EE'), (114,'ee'), (115,'D'); SET SESSION join_cache_level = 4; @@ -3063,7 +3146,10 @@ CREATE TABLE t2 ( f1 varchar(10) , f2 int(11) , KEY (f1)); INSERT INTO t2 VALUES ('hgtofubn',1), ('GDOXZ',91), ('n',2), ('fggxgalh',88), ('hgtofu',1), ('GDO',101), ('n',3), ('fggxga',55), - ('hgtofu',3), ('GDO',33), ('nn',3), ('fggxgarrr',77); + ('hgtofu',3), ('GDO',33), ('nn',3), ('fggxgarrr',77), + ('jgtofu',3), ('JDO',33), ('mn',3), ('jggxgarrr',77), + ('igtofu',3), ('IDO',33), ('ln',3), ('iggxgarrr',77); + SET SESSION join_cache_level=3; @@ -3085,7 +3171,9 @@ INSERT INTO t1 VALUES ('o'), ('u'); CREATE TABLE t2 (a int, v varchar(1), INDEX idx (v)) ; INSERT INTO t2 VALUES (8,NULL), (10,'b'), (5,'k'), (4,NULL), - (1,NULL), (11,'u'), (7,NULL), (2,'d'); + (1,NULL), (11,'u'), (7,NULL), (2,'d'), + (18,'u'), (11,'b'), (15,'k'), (12,'d'), + (18,'x'), (11,'y'), (15,'l'), (12,'e'); SET SESSION join_buffer_size = 256; @@ -3137,5 +3225,34 @@ SET SESSION join_cache_level = DEFAULT; DROP TABLE t1, t2; +--echo # +--echo # Bug #887479: join_cache_level=3 + semijoin=on +--echo # + +CREATE TABLE t1 (a int, b int); +INSERT INTO t1 VALUES (3914,17), (3710,5), (3888,20); + +CREATE TABLE t2 (c int, KEY (c)); +INSERT INTO t2 VALUES (27), (17), (33), (20), (3), (7), (18), (2); + +SET @tmp887479_optimizer_switch=@@optimizer_switch; +SET SESSION optimizer_switch='semijoin=on'; +SET SESSION optimizer_switch='semijoin_with_cache=on'; + +SET SESSION join_cache_level=1; +EXPLAIN +SELECT * FROM t1 WHERE (t1.b) IN (SELECT c FROM t2); +SELECT * FROM t1 WHERE (t1.b) IN (SELECT c FROM t2); + +SET SESSION join_cache_level=3; +EXPLAIN +SELECT * FROM t1 WHERE (t1.b) IN (SELECT c FROM t2); +SELECT * FROM t1 WHERE (t1.b) IN (SELECT c FROM t2); + +SET SESSION join_cache_level = DEFAULT; +SET optimizer_switch=@tmp887479_optimizer_switch; + +DROP TABLE t1,t2; + # this must be the last command in the file set @@optimizer_switch=@save_optimizer_switch; diff --git a/mysql-test/t/join_nested.test b/mysql-test/t/join_nested.test index deda56eb8ee..b617331de38 100644 --- a/mysql-test/t/join_nested.test +++ b/mysql-test/t/join_nested.test @@ -454,6 +454,7 @@ SELECT t1.a,t1.b,t2.a,t2.b,t3.a,t3.b,t4.a,t4.b ON t3.a=1 AND t2.b=t4.b WHERE t1.a <= 2; +INSERT INTO t2 VALUES (-1,9,0), (-3,10,0), (-2,8,0), (-4,11,0), (-5,15,0); CREATE INDEX idx_b ON t2(b); EXPLAIN EXTENDED @@ -461,12 +462,12 @@ SELECT t2.a,t2.b,t3.a,t3.b,t4.a,t4.b FROM (t3,t4) LEFT JOIN (t1,t2) - ON t3.a=1 AND t3.b=t2.b AND t2.b=t4.b; + ON t3.a=1 AND t3.b=t2.b AND t2.b=t4.b AND t2.a>0; SELECT t2.a,t2.b,t3.a,t3.b,t4.a,t4.b FROM (t3,t4) LEFT JOIN (t1,t2) - ON t3.a=1 AND t3.b=t2.b AND t2.b=t4.b; + ON t3.a=1 AND t3.b=t2.b AND t2.b=t4.b AND t2.a>0; EXPLAIN EXTENDED SELECT t0.a,t0.b,t1.a,t1.b,t2.a,t2.b,t3.a,t3.b,t4.a,t4.b, @@ -477,7 +478,7 @@ SELECT t0.a,t0.b,t1.a,t1.b,t2.a,t2.b,t3.a,t3.b,t4.a,t4.b, t2 LEFT JOIN (t3, t4) - ON t3.a=1 AND t2.b=t4.b, + ON t3.a=1 AND t2.b=t4.b AND t2.a>0, t5 LEFT JOIN ( @@ -504,6 +505,8 @@ SELECT t0.a,t0.b,t1.a,t1.b,t2.a,t2.b,t3.a,t3.b,t4.a,t4.b, (t8.b=t9.b OR t8.c IS NULL) AND (t9.a=1); +INSERT INTO t4 VALUES (-3,12,0), (-4,13,0), (-1,11,0), (-3,11,0), (-5,15,0); +INSERT INTO t5 VALUES (-3,11,0), (-2,12,0), (-3,13,0), (-4,12,0); CREATE INDEX idx_b ON t4(b); CREATE INDEX idx_b ON t5(b); @@ -516,7 +519,7 @@ SELECT t0.a,t0.b,t1.a,t1.b,t2.a,t2.b,t3.a,t3.b,t4.a,t4.b, t2 LEFT JOIN (t3, t4) - ON t3.a=1 AND t2.b=t4.b, + ON t3.a=1 AND t2.b=t4.b AND t2.a>0 AND t4.a>0, t5 LEFT JOIN ( @@ -525,7 +528,7 @@ SELECT t0.a,t0.b,t1.a,t1.b,t2.a,t2.b,t3.a,t3.b,t4.a,t4.b, t8 ON t7.b=t8.b AND t6.b < 10 ) - ON t6.b >= 2 AND t5.b=t7.b + ON t6.b >= 2 AND t5.b=t7.b AND t5.a>0 ) ON (t3.b=2 OR t3.c IS NULL) AND (t6.b=2 OR t6.c IS NULL) AND (t1.b=t5.b OR t3.c IS NULL OR t6.c IS NULL or t8.c IS NULL) AND @@ -543,6 +546,7 @@ SELECT t0.a,t0.b,t1.a,t1.b,t2.a,t2.b,t3.a,t3.b,t4.a,t4.b, (t8.b=t9.b OR t8.c IS NULL) AND (t9.a=1); +INSERT INTO t8 VALUES (-3,12,0), (-1,14,0), (-5,15,0), (-1,11,0), (-4,13,0); CREATE INDEX idx_b ON t8(b); EXPLAIN EXTENDED @@ -554,16 +558,16 @@ SELECT t0.a,t0.b,t1.a,t1.b,t2.a,t2.b,t3.a,t3.b,t4.a,t4.b, t2 LEFT JOIN (t3, t4) - ON t3.a=1 AND t2.b=t4.b, + ON t3.a=1 AND t2.b=t4.b AND t2.a>0 AND t4.a>0, t5 LEFT JOIN ( (t6, t7) LEFT JOIN t8 - ON t7.b=t8.b AND t6.b < 10 + ON t7.b=t8.b AND t6.b < 10 AND t8.a>=0 ) - ON t6.b >= 2 AND t5.b=t7.b + ON t6.b >= 2 AND t5.b=t7.b AND t5.a>0 ) ON (t3.b=2 OR t3.c IS NULL) AND (t6.b=2 OR t6.c IS NULL) AND (t1.b=t5.b OR t3.c IS NULL OR t6.c IS NULL or t8.c IS NULL) AND @@ -581,6 +585,7 @@ SELECT t0.a,t0.b,t1.a,t1.b,t2.a,t2.b,t3.a,t3.b,t4.a,t4.b, (t8.b=t9.b OR t8.c IS NULL) AND (t9.a=1); +INSERT INTO t1 VALUES (-1,133,0), (-2,12,0), (-3,11,0), (-5,15,0); CREATE INDEX idx_b ON t1(b); CREATE INDEX idx_a ON t0(a); @@ -606,7 +611,7 @@ SELECT t0.a,t0.b,t1.a,t1.b,t2.a,t2.b,t3.a,t3.b,t4.a,t4.b, ) ON (t3.b=2 OR t3.c IS NULL) AND (t6.b=2 OR t6.c IS NULL) AND (t1.b=t5.b OR t3.c IS NULL OR t6.c IS NULL or t8.c IS NULL) AND - (t1.a != 2), + (t1.a != 2) AND t1.a>0, t9 WHERE t0.a=1 AND t0.b=t1.b AND @@ -641,7 +646,7 @@ SELECT t0.a,t0.b,t1.a,t1.b,t2.a,t2.b,t3.a,t3.b,t4.a,t4.b, ) ON (t3.b=2 OR t3.c IS NULL) AND (t6.b=2 OR t6.c IS NULL) AND (t1.b=t5.b OR t3.c IS NULL OR t6.c IS NULL or t8.c IS NULL) AND - (t1.a != 2), + (t1.a != 2) AND t1.a>0, t9 WHERE t0.a=1 AND t0.b=t1.b AND diff --git a/mysql-test/t/join_nested_jcl6.test b/mysql-test/t/join_nested_jcl6.test index 6b04d8d58b5..809755b1fbf 100644 --- a/mysql-test/t/join_nested_jcl6.test +++ b/mysql-test/t/join_nested_jcl6.test @@ -26,6 +26,9 @@ INSERT INTO t5 VALUES (1,1,0), (2,2,0), (3,3,0); INSERT INTO t6 VALUES (1,2,0), (3,2,0), (6,1,0); INSERT INTO t7 VALUES (1,1,0), (2,2,0); INSERT INTO t8 VALUES (0,2,0), (1,2,0); +INSERT INTO t6 VALUES (-1,12,0), (-3,13,0), (-6,11,0), (-4,14,0); +INSERT INTO t7 VALUES (-1,11,0), (-2,12,0), (-3,13,0), (-4,14,0), (-5,15,0); +INSERT INTO t8 VALUES (-3,13,0), (-1,12,0), (-2,14,0), (-5,15,0), (-4,16,0); EXPLAIN SELECT t5.a,t5.b,t6.a,t6.b,t7.a,t7.b,t8.a,t8.b @@ -35,10 +38,10 @@ SELECT t5.a,t5.b,t6.a,t6.b,t7.a,t7.b,t8.a,t8.b (t6, t7) LEFT JOIN t8 - ON t7.b=t8.b AND t6.b < 10 + ON t7.b=t8.b AND t6.b < 10 ) ON t6.b >= 2 AND t5.b=t7.b AND - (t8.a > 0 OR t8.c IS NULL); + (t8.a > 0 OR t8.c IS NULL) AND t6.a>0 AND t7.a>0; SELECT t5.a,t5.b,t6.a,t6.b,t7.a,t7.b,t8.a,t8.b FROM t5 @@ -50,7 +53,7 @@ SELECT t5.a,t5.b,t6.a,t6.b,t7.a,t7.b,t8.a,t8.b ON t7.b=t8.b AND t6.b < 10 ) ON t6.b >= 2 AND t5.b=t7.b AND - (t8.a > 0 OR t8.c IS NULL); + (t8.a > 0 OR t8.c IS NULL) AND t6.a>0 AND t7.a>0; DELETE FROM t5; DELETE FROM t6; diff --git a/mysql-test/t/join_outer.test b/mysql-test/t/join_outer.test index f98dbcdf7ac..059606d9f86 100644 --- a/mysql-test/t/join_outer.test +++ b/mysql-test/t/join_outer.test @@ -1329,6 +1329,8 @@ insert into t2 select if(t1.a is null, 10, t1.a) from t1; create table t3 (a int, b int, index idx(a)); insert into t3 values (1, 100), (3, 301), (4, 402), (1, 102), (1, 101); +insert into t3 values (11, 100), (33, 301), (44, 402), (11, 102), (11, 101); +insert into t3 values (22, 100), (53, 301), (64, 402), (22, 102), (22, 101); analyze table t1,t2,t3; @@ -1419,3 +1421,56 @@ SELECT t2.b FROM t1 LEFT JOIN t2 ON (t2.b) IN (SELECT c2 from t3) AND t2.a = 1; DROP TABLE t1,t2,t3; + +--echo # +--echo # lp:825035 second execution of PS with outer join +--echo # + +CREATE TABLE t1 (a int); +INSERT INTO t1 VALUES (1),(2),(3),(4); + +CREATE TABLE t2 (a int); + +PREPARE stmt FROM +"SELECT * FROM t1 LEFT JOIN t2 ON t1.a = t2.a"; + +EXECUTE stmt; +EXECUTE stmt; + +DEALLOCATE PREPARE stmt; + +DROP TABLE t1,t2; + +--echo # +--echo # lp:838633 second execution of PS with outer join +--echo # converted to inner join +--echo # + +CREATE TABLE t1 ( b int NOT NULL ) ; +INSERT INTO t1 VALUES (9),(10); + +CREATE TABLE t2 ( b int NOT NULL, PRIMARY KEY (b)) ; +INSERT INTO t2 VALUES + (75),(76),(77),(78),(79),(80),(81),(82),(83),(84),(85),(86),(87),(88),(89), + (10), (90),(91),(92),(93),(94),(95),(96),(97),(98),(99),(100); + +CREATE TABLE t3 ( a int, b int NOT NULL , PRIMARY KEY (b)) ; +INSERT INTO t3 VALUES + (0,6),(0,7),(0,8),(2,9),(0,10),(2,21),(0,22),(2,23),(2,24),(2,25); + +SET SESSION join_cache_level=4; + +EXPLAIN EXTENDED +SELECT * FROM (t2 LEFT JOIN t1 ON t1.b = t2.b) JOIN t3 ON t1.b = t3.b; + +PREPARE stmt FROM +'SELECT * FROM (t2 LEFT JOIN t1 ON t1.b = t2.b) JOIN t3 ON t1.b = t3.b'; + +EXECUTE stmt; +EXECUTE stmt; + +DEALLOCATE PREPARE stmt; + +SET SESSION join_cache_level=default; + +DROP TABLE t1,t2,t3; diff --git a/mysql-test/t/kill.test b/mysql-test/t/kill.test index 4aa765caa8c..7c6c37ecfc6 100644 --- a/mysql-test/t/kill.test +++ b/mysql-test/t/kill.test @@ -349,7 +349,7 @@ SET DEBUG_SYNC = 'RESET'; let $ID= `SELECT @id := CONNECTION_ID()`; SET DEBUG_SYNC= 'thread_end SIGNAL con1_end'; --disable_reconnect ---error ER_QUERY_INTERRUPTED +--error ER_CONNECTION_KILLED KILL @id; connection con2; @@ -604,5 +604,33 @@ drop table t2; ########################################################################### +--echo # +--echo # Test kill USER +--echo # +grant ALL on test.* to test@localhost; +grant ALL on test.* to test2@localhost; +connect (con3, localhost, test,,); +connect (con4, localhost, test2,,); +connection default; +--enable_info +kill hard query user test2@nohost; +kill soft query user test@localhost; +kill hard query user test@localhost; +kill soft connection user test2; +kill hard connection user test@localhost; +--disable_info +revoke all privileges on test.* from test@localhost; +revoke all privileges on test.* from test2@localhost; +drop user test@localhost; +drop user test2@localhost; + +connection con3; +--error 2013,2006 +select 1; +connection con4; +--error 2013,2006 +select 1; +connection default; + SET DEBUG_SYNC = 'RESET'; DROP FUNCTION MY_KILL; diff --git a/mysql-test/t/maria_mrr.test b/mysql-test/t/maria_mrr.test index 9d26a01d5e0..d67572033c8 100644 --- a/mysql-test/t/maria_mrr.test +++ b/mysql-test/t/maria_mrr.test @@ -74,7 +74,9 @@ CREATE TABLE t3( PRIMARY KEY (pk), INDEX idx (v, i) ) ENGINE=ARIA; INSERT INTO t3 SELECT * FROM t1; -INSERT INTO t3 VALUES (88, 442, 'y'), (99, 445, 'w') ; +INSERT INTO t3 VALUES + (88, 442, 'y'), (99, 445, 'w'), (87, 442, 'z'), (98, 445, 'v'), (86, 442, 'x'), + (97, 445, 't'), (85, 442, 'b'), (96, 445, 'l'), (84, 442, 'a'), (95, 445, 'k'); SELECT COUNT(t1.v) FROM t1, t2 IGNORE INDEX (idx), t3 IGNORE INDEX (idx) WHERE t3.v = t2.v AND t3.i < t2.i AND t3.pk > 0 AND t2.pk > 0; @@ -105,11 +107,8 @@ CREATE TABLE t1 ( ) ENGINE=Aria; INSERT INTO t1 VALUES -(1,'z'), -(2,'abcdefjhjkl'), -(3,'in'), -(4,'abcdefjhjkl'), -(6,'abcdefjhjkl'); + (1,'z'), (2,'abcdefjhjkl'), (3,'in'), (4,'abcdefjhjkl'), (6,'abcdefjhjkl'), + (11,'zx'), (12,'abcdefjhjm'), (13,'jn'), (14,'abcdefjhjp'), (16,'abcdefjhjr'); CREATE TABLE t2 ( col_varchar_10_latin1 varchar(10) DEFAULT NULL diff --git a/mysql-test/t/merge.test b/mysql-test/t/merge.test index ca2f5ebb4d7..4066fcb264b 100644 --- a/mysql-test/t/merge.test +++ b/mysql-test/t/merge.test @@ -2809,7 +2809,32 @@ UNLOCK TABLES; DROP TABLE m1, t1; ---echo End of 6.0 tests +--echo # +--echo # Test for bug #11754210 - "45777: CHECK TABLE DOESN'T SHOW ALL +--echo # PROBLEMS FOR MERGE TABLE COMPLIANCE IN 5.1" +--echo # +--disable_warnings +drop tables if exists t1, t2, t3, t4, m1; +--enable_warnings +create table t1(id int) engine=myisam; +create view t3 as select 1 as id; +create table t4(id int) engine=memory; +create table m1(id int) engine=merge union=(t1,t2,t3,t4); +--error ER_WRONG_MRG_TABLE +select * from m1; +--echo # The below CHECK and REPAIR TABLE statements should +--echo # report all problems with underlying tables: +--echo # - absence of 't2', +--echo # - missing base table for 't3', +--echo # - wrong engine of 't4'. +check table m1; +repair table m1; +--echo # Clean-up. +drop tables m1, t1, t4; +drop view t3; + + +--echo End of 5.5 tests --disable_result_log --disable_query_log diff --git a/mysql-test/t/mrr_icp_extra.test b/mysql-test/t/mrr_icp_extra.test index 2d0fd527dcf..f1b21154449 100644 --- a/mysql-test/t/mrr_icp_extra.test +++ b/mysql-test/t/mrr_icp_extra.test @@ -57,6 +57,7 @@ DROP TABLE t1,t2,t3; --echo # create table t1(a int, b int, index(b)); insert into t1 values (2, 1), (1, 1), (4, NULL), (3, NULL), (6, 2), (5, 2); +insert into t1 values (2, 11), (1, 11), (4, 14), (3, 14), (6, 12), (5, 12); explain select * from t1 where b=1 or b is null order by a; select * from t1 where b=1 or b is null order by a; explain select * from t1 where b=2 or b is null order by a; diff --git a/mysql-test/t/myisam.test b/mysql-test/t/myisam.test index cab06a03498..fa82be90427 100644 --- a/mysql-test/t/myisam.test +++ b/mysql-test/t/myisam.test @@ -350,7 +350,7 @@ DROP TABLE t1; # CREATE TABLE t1 (a int not null, b int, c int, key(b), key(c), key(a,b), key(c,a)); -INSERT into t1 values (0, null, 0), (0, null, 1), (0, null, 2), (0, null,3), (1,1,4); +INSERT into t1 values (0,null,0), (0,null,1), (0,null,2), (0,null,3), (1,1,4); create table t2 (a int not null, b int, c int, key(b), key(c), key(a)); INSERT into t2 values (1,1,1), (2,2,2); optimize table t1; @@ -358,7 +358,13 @@ show index from t1; explain select * from t1,t2 where t1.a=t2.a; explain select * from t1,t2 force index(a) where t1.a=t2.a; explain select * from t1 force index(a),t2 force index(a) where t1.a=t2.a; +INSERT into t1 values (2,4,5), (7,8,4), (8,3,1), (9,7,2), (5,5,9); +optimize table t1; +show index from t1; explain select * from t1,t2 where t1.b=t2.b; +delete from t1 where t1.a>1; +optimize table t1; +show index from t1; explain select * from t1,t2 force index(c) where t1.a=t2.a; explain select * from t1 where a=0 or a=2; explain select * from t1 force index (a) where a=0 or a=2; diff --git a/mysql-test/t/myisam_icp.test b/mysql-test/t/myisam_icp.test index 66ffbfa3821..bbff6c30e56 100644 --- a/mysql-test/t/myisam_icp.test +++ b/mysql-test/t/myisam_icp.test @@ -2,11 +2,11 @@ # ICP/MyISAM tests (Index Condition Pushdown) # ---source include/icp_tests.inc - set @myisam_icp_tmp=@@optimizer_switch; set optimizer_switch='mrr=on,mrr_sort_keys=on,index_condition_pushdown=on'; +--source include/icp_tests.inc + --disable_warnings drop table if exists t0, t1, t1i, t1m; --enable_warnings @@ -209,4 +209,52 @@ INSERT INTO t1 VALUES SELECT b FROM t1 WHERE a != 1 AND c IS NULL ORDER BY 1; DROP TABLE t1; +--echo # +--echo # Bug#870046: ICP for a GROUP BY query +--echo # + +CREATE TABLE t1 (a int, b varchar(1), c varchar(1), INDEX idx(b)); +INSERT INTO t1 VALUES (2,'x','x'), (5,'x','y'); + +SET SESSION optimizer_switch='index_condition_pushdown=off'; +EXPLAIN +SELECT a, MIN(c) FROM t1 WHERE b = 'x' AND c > 'x' GROUP BY a; +SELECT a, MIN(c) FROM t1 WHERE b = 'x' AND c > 'x' GROUP BY a; +SET SESSION optimizer_switch='index_condition_pushdown=on'; +EXPLAIN +SELECT a, MIN(c) FROM t1 WHERE b = 'x' AND c > 'x' GROUP BY a; +SELECT a, MIN(c) FROM t1 WHERE b = 'x' AND c > 'x' GROUP BY a; + +DROP TABLE t1; + +--echo # +--echo # BUG#887026: Wrong result with ICP, outer join, subquery in maria-5.3-icp +--echo # + +CREATE TABLE t1 (c varchar(1)); +INSERT INTO t1 VALUES ('c'), ('c'); + +CREATE TABLE t2 (c varchar(1), b int); +INSERT INTO t2 VALUES ('d', NULL),('d', NULL); + +CREATE TABLE t3 (c varchar(1)); +INSERT INTO t3 VALUES ('c'); +INSERT INTO t3 VALUES ('c'); + +CREATE TABLE t4 ( b int, c varchar(1), KEY (b)); +INSERT INTO t4 VALUES (7,'c'); +INSERT INTO t4 VALUES (7,'c'); + +--echo # Must be t1,t2,t3,t4, with t4 having Full-scan-on-NULL but not Using index condition +explain +SELECT * FROM t1 LEFT JOIN t2 ON t1.c=t2.b +WHERE + t2.b NOT IN (SELECT t4.b FROM t3 STRAIGHT_JOIN t4 WHERE t4.b <= 2 AND t4.c = t3.c); + +SELECT * FROM t1 LEFT JOIN t2 ON t1.c=t2.b +WHERE + t2.b NOT IN (SELECT t4.b FROM t3 STRAIGHT_JOIN t4 WHERE t4.b <= 2 AND t4.c = t3.c); + +DROP TABLE t1,t2,t3,t4; + set optimizer_switch=@myisam_icp_tmp; diff --git a/mysql-test/t/myisam_mrr.test b/mysql-test/t/myisam_mrr.test index 9c4c7be4fa2..1e070ec9a34 100644 --- a/mysql-test/t/myisam_mrr.test +++ b/mysql-test/t/myisam_mrr.test @@ -199,6 +199,14 @@ INSERT INTO t1 VALUES (22,142,'b','b'),(23,3,'y','y'),(24,0,'v','v'), (25,3,'m','m'),(26,5,'z','z'),(27,9,'n','n'), (28,1,'d','d'),(29,107,'a','a'); +INSERT INTO t1 VALUES + (110,8,'v','v'),(111,8,'f','f'), (112,5,'v','v'), + (113,8,'s','s'),(114,8,'a','a'),(115,6,'p','p'), + (116,7,'z','z'),(117,2,'a','a'),(118,5,'h','h'), + (119,7,'h','h'),(120,2,'v','v'),(121,9,'v','v'), + (122,142,'b','b'),(123,3,'y','y'),(124,0,'v','v'), + (125,3,'m','m'),(126,5,'z','z'),(127,9,'n','n'), + (128,1,'d','d'),(129,107,'a','a'); SELECT COUNT(*) FROM @@ -218,6 +226,47 @@ where set join_cache_level= @save_join_cache_level; set join_buffer_size= @save_join_buffer_size; -set optimizer_switch= @myisam_mrr_tmp; drop table t1; + +--echo # +--echo # BUG#730133: Wrong result with jkl = 7, BKA, ICP in maria-5.3 + compound index +--echo # +set @tmp_730133_jcl= @@join_cache_level; +set join_cache_level = 7; + +set @tmp_730133_os= @@optimizer_switch; +set optimizer_switch= 'join_cache_hashed=off,join_cache_bka=on,index_condition_pushdown=on,optimize_join_buffer_size=on'; + +CREATE TABLE t1 (f1 int, f2 int, f3 int, f4 int, f5 int, KEY (f4,f3)); +INSERT IGNORE INTO t1 VALUES ('2','9','5','0','0'),('4','7','0','0','0'), + ('6','97','190','0','0'),('7','3','6','0','0'),('11','101','186','0','0'), + ('14','194','226','0','0'),('15','148','133','0','0'), + ('16','9','6','0','0'),('17','9','3','0','0'),('18','1','8','0','0'), + ('19','1','5','0','0'),('20','5','7','0','0'); + +explain +SELECT COUNT(alias2.f2) +FROM + t1 STRAIGHT_JOIN + t1 AS alias3 STRAIGHT_JOIN + t1 AS alias2 FORCE KEY (f4) +WHERE + alias2.f4=alias3.f5 AND + alias2.f3 > alias3.f1; + +SELECT COUNT(alias2.f2) +FROM + t1 STRAIGHT_JOIN + t1 AS alias3 STRAIGHT_JOIN + t1 AS alias2 FORCE KEY (f4) +WHERE + alias2.f4=alias3.f5 AND + alias2.f3 > alias3.f1; + +set @@join_cache_level= @tmp_730133_jcl; +set @@optimizer_switch= @tmp_730133_os; +drop table t1; + +## This must be last line in the file: +set optimizer_switch= @myisam_mrr_tmp; diff --git a/mysql-test/t/myisampack.test b/mysql-test/t/myisampack.test index 190ee8d8fd2..afa417822e6 100644 --- a/mysql-test/t/myisampack.test +++ b/mysql-test/t/myisampack.test @@ -223,3 +223,47 @@ DROP TABLE t1,t2,t3; DROP TABLE mysql_db1.t1; DROP DATABASE mysql_db1; +--echo # +--echo # BUG#11761180 - 53646: MYISAMPACK CORRUPTS TABLES WITH FULLTEXT INDEXES +--echo # +CREATE TABLE t1(a CHAR(4), FULLTEXT(a)); +INSERT INTO t1 VALUES('aaaa'),('bbbb'),('cccc'); +FLUSH TABLE t1; +--exec $MYISAMPACK -sf $MYSQLD_DATADIR/test/t1 +--exec $MYISAMCHK -srq $MYSQLD_DATADIR/test/t1 +CHECK TABLE t1; +SELECT * FROM t1 WHERE MATCH(a) AGAINST('aaaa' IN BOOLEAN MODE); +SELECT * FROM t1 WHERE MATCH(a) AGAINST('aaaa'); +DROP TABLE t1; + +--echo # Test table with key_reflength > rec_reflength +CREATE TABLE t1(a CHAR(30), FULLTEXT(a)); +--disable_query_log +--echo # Populating a table, so it's index file exceeds 65K +let $1=1700; +while ($1) +{ + eval INSERT INTO t1 VALUES('$1aaaaaaaaaaaaaaaaaaaaaaaaaa'); + dec $1; +} + +--echo # Populating a table, so index file has second level fulltext tree +let $1=60; +while ($1) +{ + eval INSERT INTO t1 VALUES('aaaa'),('aaaa'),('aaaa'),('aaaa'),('aaaa'); + dec $1; +} +--enable_query_log + +FLUSH TABLE t1; +--echo # Compressing table +--exec $MYISAMPACK -sf $MYSQLD_DATADIR/test/t1 +--echo # Fixing index (repair by sort) +--exec $MYISAMCHK -srnq $MYSQLD_DATADIR/test/t1 +CHECK TABLE t1; +FLUSH TABLE t1; +--echo # Fixing index (repair with keycache) +--exec $MYISAMCHK -soq $MYSQLD_DATADIR/test/t1 +CHECK TABLE t1; +DROP TABLE t1; diff --git a/mysql-test/t/mysql.test b/mysql-test/t/mysql.test index 52d9b52b26e..069cf37c3e6 100644 --- a/mysql-test/t/mysql.test +++ b/mysql-test/t/mysql.test @@ -6,7 +6,7 @@ # --disable_warnings -drop table if exists t1; +drop table if exists t1,t2,t3; --enable_warnings # @@ -124,6 +124,13 @@ drop table t1; --exec echo "use" > $file --exec $MYSQL < $file 2>&1 +# Test exceutable comments +--exec echo "SELECT 1 /*! +1 */;" > $file +--exec echo "SELECT 1 /*M! +1 */;" >> $file +--exec echo "SELECT 1 /*!00000 +1 */;" >> $file +--exec echo "SELECT 1 /*M!00000 +1 */" >> $file +--exec $MYSQL < $file 2>&1 + --remove_file $file # diff --git a/mysql-test/t/mysql_embedded.test b/mysql-test/t/mysql_embedded.test index b4c8c6be05f..30959b83017 100644 --- a/mysql-test/t/mysql_embedded.test +++ b/mysql-test/t/mysql_embedded.test @@ -3,4 +3,10 @@ --echo # --source include/is_embedded.inc ---exec $MYSQL_TEST_DIR/../libmysqld/examples/mysql_embedded -e 'select 1' + +# Test case require mysql_embedded to be present +if(!$MYSQL_EMBEDDED) +{ + --skip Test requires mysql_embedded executable +} +--exec $MYSQL_EMBEDDED -e 'select 1' diff --git a/mysql-test/t/mysql_plugin-master.opt b/mysql-test/t/mysql_plugin-master.opt new file mode 100644 index 00000000000..061ca907902 --- /dev/null +++ b/mysql-test/t/mysql_plugin-master.opt @@ -0,0 +1 @@ +--plugin-dir=$DAEMONEXAMPLE_DIR diff --git a/mysql-test/t/mysql_plugin.test b/mysql-test/t/mysql_plugin.test new file mode 100644 index 00000000000..b7fbe377e31 --- /dev/null +++ b/mysql-test/t/mysql_plugin.test @@ -0,0 +1,318 @@ +# +# Test mysql_plugin tool +# +# This test contains test cases for testing the mysql_plugin client with +# the daemon_example plugin. Test cases include tests for: +# +# - successful enable/disable +# - incorrect paths +# - missing paths/options +# +# Implementation Notes +# +# The mysql_plugin tool now accepts --mysqld the path to mysqld server. The +# mysqld path is extracted from MYSQLD_BOOTSTRAP_CMD line. We also extract +# the path of MYSQLD_BASEDIR (where mysql exists) and use it for the errmsg +# file. The directories differ between Windows and Unix but the Perl script +# included below will pick as per platform. +# +# The test is also designed to issue the --skip directive if the location of +# the mysqld, my_print_defaults, or daemon_example.ini files cannot be found. +# + +--source include/not_embedded.inc + +# Add the datadir, basedir, plugin_dir to the bootstrap command +let $MYSQLD_DATADIR= `select @@datadir`; +let $MYSQL_BASEDIR= `select @@basedir`; +let $MYSQL_ERRMSG_BASEDIR=`select @@lc_messages_dir`; +let $PLUGIN_DIR=`select @@plugin_dir`; + +--disable_abort_on_error + +# Perl script to extract the location of the basedir from environment +# variables. This is needed to ensure the test will run on the PB machines +# designed to test release as well as debug builds. It also checks for the +# location of the my_print_defaults and daemon_example.ini files. + +perl; +use File::Basename; + my ($mysqld)= split " ", $ENV{MYSQLD_BOOTSTRAP_CMD}; + my $mysqld_basedir=dirname($mysqld); + my $my_print_defaults= $ENV{MYSQL_MY_PRINT_DEFAULTS}; + my $my_print_defaults_basedir=dirname($my_print_defaults); + my $daemonexample_ini= "$ENV{DAEMONEXAMPLE_DIR}/daemon_example.ini"; + my $plugindir_ini= "$ENV{PLUGIN_DIR}/daemon_example.ini"; + my $notfound= ""; + open(FILE, ">", "$ENV{MYSQL_TMP_DIR}/mysqld.inc") or die; + print FILE "let \$MYSQLD_BASEDIR= $mysqld_basedir;\n"; + print FILE "let \$MYSQL_MY_PRINT_DEFAULTS_BASEDIR= $my_print_defaults_basedir;\n"; + if ((!-e $daemonexample_ini) || (!-r $daemonexample_ini)) + { + print FILE "let \$DAEMONEXAMPLE_DIR= $not_found;\n"; + } + if ((!-e $plugindir_ini) || (!-r $plugindir_ini)) + { + print FILE "let \$PLUGIN_DIR= $not_found;\n"; + } + close FILE; +EOF + + +source $MYSQL_TMP_DIR/mysqld.inc; +remove_file $MYSQL_TMP_DIR/mysqld.inc; + +# The mysql_plugin tool expects a directory structure like in the installed +# mysql version, so errmsg.sys will be copied to "basedir/share", we create +# and remove this structure. + +--mkdir $MYSQLD_BASEDIR/share +--mkdir $MYSQLD_BASEDIR/share/mysql +--copy_file $MYSQL_ERRMSG_BASEDIR/english/errmsg.sys $MYSQLD_BASEDIR/share/errmsg.sys +--copy_file $MYSQL_ERRMSG_BASEDIR/english/errmsg.sys $MYSQLD_BASEDIR/share/mysql/errmsg.sys + +# The mysql_plugin tool now accepts --my-print-defaults which points to the +# executable my_print_defaults.exe we can get this path from the variable +# $MYSQL_MY_PRINT_DEFAULTS. + +# Check for my_print_defaults location. Skip if not found. +if ($MYSQL_MY_PRINT_DEFAULTS_BASEDIR == '') +{ + --skip Test requires known location of my_print_defaults executable. +} + +# Check for mysqld location. Skip if not found. +if ($MYSQLD == '') +{ + --skip Test requires known location of mysqld executable. +} + +# Check for daemon_example.ini location. Skip if not found in either +# the plugin_dir path or the daemon_example_dir path. +if ($PLUGIN_DIR == '') +{ + if ($DAEMONEXAMPLE_DIR == '') + { + --skip Test requires known location of daemon_example.ini file. + } + let $PLUGIN_DIR = $DAEMONEXAMPLE_DIR; +} + +# Build client command for reuse. + +let $MYSQL_PLUGIN_CMD= $MYSQL_PLUGIN --datadir=$MYSQLD_DATADIR --basedir=$MYSQLD_BASEDIR --plugin-dir=$PLUGIN_DIR --mysqld=$MYSQLD_BASEDIR --my-print-defaults=$MYSQL_MY_PRINT_DEFAULTS_BASEDIR; + +--echo # +--echo # Ensure the plugin isn't loaded. +--echo # +SELECT * FROM mysql.plugin WHERE name = 'daemon_example' ORDER BY name; + +--echo # +--echo # Enable the plugin... +--echo # +let $expect_file= $MYSQLTEST_VARDIR/tmp/mysqld.1.expect; +# MTR will remove this file later, but this might be too late. +--error 0,1 +--remove_file $expect_file +--write_file $expect_file +wait +EOF +--shutdown_server 10 +--source include/wait_until_disconnected.inc + +# +# Enable the plugin +# +--exec $MYSQL_PLUGIN_CMD ENABLE daemon_example + +# +# Ensure enabling an enabled plugin doesn't fail +--exec $MYSQL_PLUGIN_CMD ENABLE daemon_example + +# +# Restart the server +# +--append_file $expect_file +restart +EOF +--enable_reconnect +--source include/wait_until_connected_again.inc + +--echo # +--echo # Ensure the plugin is now loaded. +--echo # +--replace_regex /\.dll/.so/ +SELECT * FROM mysql.plugin WHERE name = 'daemon_example' ORDER BY name; + +--echo # +--echo # Disable the plugin... +--echo # +# MTR will remove this file later, but this might be too late. +--error 0,1 +--remove_file $expect_file +--write_file $expect_file +wait +EOF +--shutdown_server 10 +--source include/wait_until_disconnected.inc + +# +# Disable the plugin +# +--exec $MYSQL_PLUGIN_CMD DISABLE daemon_example + +# +# Restart the server +# +--append_file $expect_file +restart +EOF +--enable_reconnect +--source include/wait_until_connected_again.inc + +--echo # +--echo # Ensure the plugin isn't loaded. +--echo # +SELECT * FROM mysql.plugin WHERE name = 'daemon_example' ORDER BY name; + +# +# Stop the server for error conditions +# +let $expect_file= $MYSQLTEST_VARDIR/tmp/mysqld.1.expect; +# MTR will remove this file later, but this might be too late. +--error 0,1 +--remove_file $expect_file +--write_file $expect_file +wait +EOF +--shutdown_server 10 +--source include/wait_until_disconnected.inc + +--echo # +--echo # Attempt to load non-existant plugin +--echo # +--error 1,2,256 +--exec $MYSQL_PLUGIN_CMD DISABLE NOT_THERE_AT_ALL 2>&1 + +--echo # +--echo # Attempt to use non-existant plugin.ini file +--echo # +--error 1,2,7,256 +--exec $MYSQL_PLUGIN_CMD DISABLE daemon_example --plugin-ini=/NOT/THERE/pi.ini 2>&1 + +--echo # +--echo # Attempt to omit the plugin +--echo # +--error 1,2,256 +--exec $MYSQL_PLUGIN_CMD DISABLE 2>&1 + +--echo # +--echo # Attempt to omit DISABLE|ENABLE +--echo # +--error 1,2,256 +--exec $MYSQL_PLUGIN_CMD daemon_example 2>&1 + +--echo # +--echo # Attempt to use bad paths - datadir +--echo # +let $MYSQL_PLUGIN_CMD= $MYSQL_PLUGIN -n --datadir=/data_not_there/ --basedir=$MYSQL_BASEDIR --plugin-dir=$PLUGIN_DIR --mysqld=$MYSQLD_BASEDIR --my-print-defaults=$MYSQL_MY_PRINT_DEFAULTS_BASEDIR; +--error 1,2,256 +--exec $MYSQL_PLUGIN_CMD DISABLE daemon_example 2>&1 + +--echo # +--echo # Attempt to use bad paths - basedir +--echo # +let $MYSQL_PLUGIN_CMD= $MYSQL_PLUGIN -n --datadir=$MYSQLD_DATADIR --basedir=/basedir_not_there/ --plugin-dir=$PLUGIN_DIR --mysqld=$MYSQLD_BASEDIR --my-print-defaults=$MYSQL_MY_PRINT_DEFAULTS_BASEDIR; +replace_result "/basedir_not_there//" "/basedir_not_there/"; +--error 1,2,256 +--exec $MYSQL_PLUGIN_CMD DISABLE daemon_example 2>&1 + +--echo # +--echo # Attempt to use bad paths - plugin_dir +--echo # +let $MYSQL_PLUGIN_CMD= $MYSQL_PLUGIN -n --datadir=$MYSQLD_DATADIR --basedir=$MYSQL_BASEDIR --plugin-dir=/plugin_not_there/ --mysqld=$MYSQLD_BASEDIR --my-print-defaults=$MYSQL_MY_PRINT_DEFAULTS_BASEDIR; +--error 1,2,256 +--exec $MYSQL_PLUGIN_CMD DISABLE daemon_example 2>&1 + +--echo # +--echo # Attempt to use bad paths - mysqld +--echo # +let $MYSQL_PLUGIN_CMD= $MYSQL_PLUGIN -n --datadir=$MYSQLD_DATADIR --basedir=$MYSQL_BASEDIR --plugin-dir=$PLUGIN_DIR --mysqld=/mysqld_not_there/ --my-print-defaults=$MYSQL_MY_PRINT_DEFAULTS_BASEDIR; +--error 1,2,256 +--exec $MYSQL_PLUGIN_CMD DISABLE daemon_example 2>&1 + +--echo # +--echo # Attempt to use bad paths - my_print_defaults +--echo # +let $MYSQL_PLUGIN_CMD= $MYSQL_PLUGIN -n --datadir=$MYSQLD_DATADIR --basedir=$MYSQL_BASEDIR --plugin-dir=$PLUGIN_DIR --mysqld=$MYSQLD_BASEDIR --my-print-defaults=/my_print_defaults_not_there/; +--error 1,2,256 +--exec $MYSQL_PLUGIN_CMD DISABLE daemon_example 2>&1 + + +--echo # +--echo # Missing library +--echo # +let $MYSQL_PLUGIN_CMD= $MYSQL_PLUGIN -n --datadir=$MYSQLD_DATADIR --basedir=$MYSQL_BASEDIR --plugin-dir=$PLUGIN_DIR --plugin-ini=$MYSQL_TEST_DIR/include/daemon_example_bad_soname.ini --mysqld=$MYSQLD_BASEDIR --my-print-defaults=$MYSQL_MY_PRINT_DEFAULTS_BASEDIR; +--error 1,2,256 +--exec $MYSQL_PLUGIN_CMD DISABLE daemon_example 2>&1 + +--echo # +--echo # Bad format for config file +--echo # +let $MYSQL_PLUGIN_CMD= $MYSQL_PLUGIN -n --datadir=$MYSQLD_DATADIR --basedir=$MYSQL_BASEDIR --plugin-dir=$PLUGIN_DIR --plugin-ini=$MYSQL_TEST_DIR/include/daemon_example_bad_format.ini --mysqld=$MYSQLD_BASEDIR --my-print-defaults=$MYSQL_MY_PRINT_DEFAULTS_BASEDIR; +--error 1,2,256 +--exec $MYSQL_PLUGIN_CMD DISABLE daemon_example 2>&1 + +--echo # +--echo # Missing base_dir option +--echo # +let $MYSQL_PLUGIN_CMD= $MYSQL_PLUGIN -n --datadir=$MYSQLD_DATADIR --plugin-dir=$PLUGIN_DIR --mysqld=$MYSQLD_BASEDIR --my-print-defaults=$MYSQL_MY_PRINT_DEFAULTS_BASEDIR; +--error 1,2,139,256 +--exec $MYSQL_PLUGIN_CMD DISABLE daemon_example 2>&1 + +--echo # +--echo # Missing data_dir option +--echo # +let $MYSQL_PLUGIN_CMD= $MYSQL_PLUGIN -n --basedir=$MYSQL_BASEDIR --plugin-dir=$PLUGIN_DIR --mysqld=$MYSQLD_BASEDIR --my-print-defaults=$MYSQL_MY_PRINT_DEFAULTS_BASEDIR; +--error 1,2,139,256 +--exec $MYSQL_PLUGIN_CMD DISABLE daemon_example 2>&1 + +--echo # +--echo # Missing plugin_dir option +--echo # +let $MYSQL_PLUGIN_CMD= $MYSQL_PLUGIN -n --datadir=$MYSQL_DATADIR --basedir=$MYSQL_BASEDIR --mysqld=$MYSQLD_BASEDIR --my-print-defaults=$MYSQL_MY_PRINT_DEFAULTS_BASEDIR; +--error 1,2,139,256 +--exec $MYSQL_PLUGIN_CMD DISABLE daemon_example 2>&1 + +--echo # +--echo # Show the help. +--echo # +replace_result $MYSQL_PLUGIN mysql_plugin; +--replace_regex /Ver [0-9.]+ Distrib [0-9.]+/Ver V.V.VV Distrib XX.XX.XX/ /XX-m[0-9]+/XX/ +--exec $MYSQL_PLUGIN --help + +replace_result $MYSQL_PLUGIN mysql_plugin; +--replace_regex /Ver [0-9.]+ Distrib [0-9.]+/Ver V.V.VV Distrib XX.XX.XX/ /XX-m[0-9]+/XX/ +--exec $MYSQL_PLUGIN --version + +# +# Restart the server +# +--append_file $expect_file +restart +EOF +--enable_reconnect +--source include/wait_until_connected_again.inc + +# +# Cleanup +# MTR will remove this file later, but this might be too late. +--error 0,1 +--remove_file $expect_file + +# Cleanup the share folder in the binary path. +--remove_file $MYSQLD_BASEDIR/share/errmsg.sys +--rmdir $MYSQLD_BASEDIR/share/mysql +--rmdir $MYSQLD_BASEDIR/share + +--enable_abort_on_error diff --git a/mysql-test/t/mysqld--defaults-file.test b/mysql-test/t/mysqld--defaults-file.test index 065436c38aa..3bfe0aa891f 100644 --- a/mysql-test/t/mysqld--defaults-file.test +++ b/mysql-test/t/mysqld--defaults-file.test @@ -5,21 +5,6 @@ source include/not_embedded.inc; source include/not_windows.inc; -# We need to use a plain "mysqld" without any other options to trigger -# the bug. In particular, it seems that passing --bootstrap does not -# trigger the bug. To do that, we extract the "command name" from the -# MYSQLD_BOOTSTRAP_CMD variable and store that in a file, which we -# then load into the test case. - -perl; - my ($mysqld)= split " ", $ENV{MYSQLD_BOOTSTRAP_CMD}; - open(FILE, ">", "$ENV{MYSQL_TMP_DIR}/mysqld.inc") or die; - print FILE "let \$MYSQLD= $mysqld;\n"; - close FILE; -EOF - -source $MYSQL_TMP_DIR/mysqld.inc; - # All these tests refer to configuration files that do not exist --error 1 @@ -44,4 +29,3 @@ exec $MYSQLD --defaults-file=with.ext --print-defaults 2>&1; --error 1 exec $MYSQLD --defaults-file=no_extension --print-defaults 2>&1; -remove_file $MYSQL_TMP_DIR/mysqld.inc; diff --git a/mysql-test/t/mysqltest.test b/mysql-test/t/mysqltest.test index 6f12c6d4d11..ab55fd30bf5 100644 --- a/mysql-test/t/mysqltest.test +++ b/mysql-test/t/mysqltest.test @@ -1,3 +1,14 @@ +# ---------------------------------------------------------------------------- +# $mysql_errno contains the return code of the last command +# sent to the server. +# ---------------------------------------------------------------------------- +# get $mysql_errno before the first statement +# $mysql_errno should be -1 +# get $mysql_errname as well + +echo $mysql_errno before test; +echo $mysql_errname before test; + -- source include/have_log_bin.inc # This test should work in embedded server after mysqltest is fixed @@ -42,15 +53,6 @@ SET GLOBAL max_connections = 1000; # ============================================================================ # ---------------------------------------------------------------------------- -# $mysql_errno contains the return code of the last command -# sent to the server. -# ---------------------------------------------------------------------------- -# get $mysql_errno before the first statement -# $mysql_errno should be -1 -eval select $mysql_errno as "before_use_test" ; - - -# ---------------------------------------------------------------------------- # Positive case(statement) # ---------------------------------------------------------------------------- @@ -142,6 +144,7 @@ select friedrich from (select 1 as otto) as t1; # check mysql_errno = 0 after successful statement # ---------------------------------------------------------------------------- select otto from (select 1 as otto) as t1; +echo $mysql_errname; eval select $mysql_errno as "after_successful_stmt_errno" ; #---------------------------------------------------------------------------- @@ -150,6 +153,7 @@ eval select $mysql_errno as "after_successful_stmt_errno" ; --error ER_PARSE_ERROR garbage ; +echo $mysql_errname; eval select $mysql_errno as "after_wrong_syntax_errno" ; # ---------------------------------------------------------------------------- @@ -159,6 +163,7 @@ eval select $mysql_errno as "after_wrong_syntax_errno" ; garbage ; let $my_var= 'abc' ; +echo $mysql_errname; eval select $mysql_errno as "after_let_var_equal_value" ; # ---------------------------------------------------------------------------- @@ -168,6 +173,7 @@ eval select $mysql_errno as "after_let_var_equal_value" ; garbage ; set @my_var= 'abc' ; +echo $mysql_errname; eval select $mysql_errno as "after_set_var_equal_value" ; # ---------------------------------------------------------------------------- @@ -178,6 +184,7 @@ eval select $mysql_errno as "after_set_var_equal_value" ; garbage ; --disable_warnings +echo $mysql_errname; eval select $mysql_errno as "after_disable_warnings_command" ; # ---------------------------------------------------------------------------- @@ -190,6 +197,7 @@ drop table if exists t1 ; garbage ; drop table if exists t1 ; +echo $mysql_errname; eval select $mysql_errno as "after_disable_warnings" ; --enable_warnings @@ -202,6 +210,7 @@ garbage ; --error ER_NO_SUCH_TABLE select 3 from t1 ; +echo $mysql_errname; eval select $mysql_errno as "after_minus_masked" ; --error ER_PARSE_ERROR @@ -209,6 +218,7 @@ garbage ; --error ER_NO_SUCH_TABLE select 3 from t1 ; +echo $mysql_errname; eval select $mysql_errno as "after_!_masked" ; # ---------------------------------------------------------------------------- @@ -230,6 +240,7 @@ garbage ; --error ER_NO_SUCH_TABLE prepare stmt from "select 3 from t1" ; +echo $mysql_errname; eval select $mysql_errno as "after_failing_prepare" ; create table t1 ( f1 char(10)); @@ -238,6 +249,7 @@ create table t1 ( f1 char(10)); garbage ; prepare stmt from "select 3 from t1" ; +echo $mysql_errname; eval select $mysql_errno as "after_successful_prepare" ; # successful execute @@ -245,6 +257,7 @@ eval select $mysql_errno as "after_successful_prepare" ; garbage ; execute stmt; +echo $mysql_errname; eval select $mysql_errno as "after_successful_execute" ; # failing execute (table has been dropped) @@ -255,6 +268,7 @@ garbage ; --error ER_NO_SUCH_TABLE execute stmt; +echo $mysql_errname; eval select $mysql_errno as "after_failing_execute" ; # failing execute (unknown statement) @@ -264,6 +278,7 @@ garbage ; --error ER_UNKNOWN_STMT_HANDLER execute __stmt_; +echo $mysql_errname; eval select $mysql_errno as "after_failing_execute" ; # successful deallocate @@ -271,6 +286,7 @@ eval select $mysql_errno as "after_failing_execute" ; garbage ; deallocate prepare stmt; +echo $mysql_errname; eval select $mysql_errno as "after_successful_deallocate" ; # failing deallocate ( statement handle does not exist ) @@ -280,6 +296,7 @@ garbage ; --error ER_UNKNOWN_STMT_HANDLER deallocate prepare __stmt_; +echo $mysql_errname; eval select $mysql_errno as "after_failing_deallocate" ; @@ -307,6 +324,7 @@ eval select $mysql_errno as "after_failing_deallocate" ; garbage ; --disable_abort_on_error +echo $mysql_errname; eval select $mysql_errno as "after_--disable_abort_on_error" ; # ---------------------------------------------------------------------------- @@ -324,6 +342,7 @@ select 3 from t1 ; --error ER_NO_SUCH_TABLE select 3 from t1 ; +echo $mysql_errname; eval select $mysql_errno as "after_!errno_masked_error" ; # expected error <> response # --error 1000 @@ -343,12 +362,21 @@ eval select $mysql_errno as "after_!errno_masked_error" ; EOF # ---------------------------------------------------------------------------- +# Check backtick and query_get_value, result should be empty +# ---------------------------------------------------------------------------- +let $empty= `garbage`; +echo $empty is empty; +let $empty= query_get_value(nonsense, blabla, 1); +echo $empty is empty; + +# ---------------------------------------------------------------------------- # Switch the abort on error on and check the effect on $mysql_errno # ---------------------------------------------------------------------------- --error ER_PARSE_ERROR garbage ; --enable_abort_on_error +echo $mysql_errname; eval select $mysql_errno as "after_--enable_abort_on_error" ; # ---------------------------------------------------------------------------- @@ -371,6 +399,71 @@ select 3 from t1 ; --error 1 --exec echo "disable_abort_on_error; enable_abort_on_error; error 1064; select 3 from t1; select 3 from t1;" | $MYSQL_TEST 2>&1 +# ---------------------------------------------------------------------------- +# Test --enable and --disable with ONCE +# ---------------------------------------------------------------------------- + +--disable_abort_on_error ONCE +garbage; +--disable_abort_on_error ONCE +--remove_file DoesNotExist + +--disable_result_log +select 2; +--enable_result_log ONCE +select 3; +select 5; +--enable_result_log + +# ---------------------------------------------------------------------------- +# Test cumulative ONCE +# ---------------------------------------------------------------------------- + +--disable_abort_on_error ONCE +--disable_query_log ONCE +select 3 from t1; +select 7; + +--error 1 +--exec echo "--disable_info OCNE" | $MYSQL_TEST 2>&1 + +--enable_connect_log ONCE +connect (con1,localhost,root,,); +connection default; +disconnect con1; + +# ---------------------------------------------------------------------------- +# Test ONCE can be combined with --error or modifiers like lowercase +# ---------------------------------------------------------------------------- + +--disable_result_log ONCE +--error ER_NO_SUCH_TABLE +select 5 from t1; + +--disable_query_log ONCE +--lowercase_result +select "CASE" as "LOWER"; + +--sorted_result +--disable_query_log ONCE +select "xyz" as name union select "abc" as name order by name desc; + +# ---------------------------------------------------------------------------- +# Test --error with backtick operator or query_get_value +# ---------------------------------------------------------------------------- + +--error 0,ER_NO_SUCH_TABLE +let $empty= `SELECT foo from bar`; +echo $empty is empty; + +--error 0,ER_BAD_FIELD_ERROR +let $empty= query_get_value(SELECT bar as foo, baz, 1); +echo $empty is empty; + +--error 0,ER_NO_SUCH_TABLE +if (!`SELECT foo from bar`) { + echo "Yes it's empty"; +} # ---------------------------------------------------------------------------- # Test comments @@ -940,10 +1033,9 @@ while ($outer) --source $MYSQLTEST_VARDIR/tmp/sourced.inc --error ER_NO_SUCH_TABLE SELECT * from nowhere; - --disable_abort_on_error + --disable_abort_on_error ONCE # Statement giving a different error, to make sure we don't mask it SELECT * FROM nowhere else; - --enable_abort_on_error } dec $outer; inc $ifval; @@ -1092,9 +1184,8 @@ system echo "hej" > /dev/null; --error 1 --exec echo "system $NONEXISTSINFVAREABLI;" | $MYSQL_TEST 2>&1 ---disable_abort_on_error +--disable_abort_on_error ONCE system NonExistsinfComamdn 2> /dev/null; ---enable_abort_on_error # ---------------------------------------------------------------------------- @@ -2513,10 +2604,9 @@ INSERT INTO t1 SELECT f1 - 64 FROM t1; INSERT INTO t1 SELECT f1 - 128 FROM t1; INSERT INTO t1 SELECT f1 - 256 FROM t1; INSERT INTO t1 SELECT f1 - 512 FROM t1; ---disable_result_log +--disable_result_log ONCE --sorted_result SELECT * FROM t1; ---enable_result_log DROP TABLE t1; # ---------------------------------------------------------------------------- @@ -2564,11 +2654,9 @@ SELECT 0 as "WILL NOT lower case ÄËÐ"; --exec $MYSQL_TEST --help 2>&1 > /dev/null --exec $MYSQL_TEST --version 2>&1 > /dev/null --enable_query_log ---disable_abort_on_error +--disable_abort_on_error ONCE --error 1 --exec $MYSQL_TEST a b c 2>&1 > /dev/null ---enable_abort_on_error ---enable_query_log # ---------------------------------------------------------------------------- # test for query_get_value diff --git a/mysql-test/t/order_by.test b/mysql-test/t/order_by.test index d820f1c03bd..d514ae88afd 100644 --- a/mysql-test/t/order_by.test +++ b/mysql-test/t/order_by.test @@ -440,6 +440,7 @@ drop table t1; create table t1(a int, b int, index(b)); insert into t1 values (2, 1), (1, 1), (4, NULL), (3, NULL), (6, 2), (5, 2); +insert into t1 values (12, 11), (11, 11), (14, 3), (13, 5), (16, 12), (15, 12); explain select * from t1 where b=1 or b is null order by a; select * from t1 where b=1 or b is null order by a; explain select * from t1 where b=2 or b is null order by a; @@ -1547,6 +1548,13 @@ SELECT DISTINCT a,1 FROM t1 WHERE a <> 1 ORDER BY a DESC; DROP TABLE t1; +--echo # +--echo # Bug#11765255 58201: +--echo # VALGRIND/CRASH WHEN ORDERING BY MULTIPLE AGGREGATE FUNCTIONS +--echo # + +select 1 order by max(1) + min(1); + --echo End of 5.1 tests diff --git a/mysql-test/t/partition_innodb_plugin.test b/mysql-test/t/partition_innodb_plugin.test index e8b73687177..6ff90f37687 100644 --- a/mysql-test/t/partition_innodb_plugin.test +++ b/mysql-test/t/partition_innodb_plugin.test @@ -7,7 +7,6 @@ call mtr.add_suppression("nnoDB: Error: table `test`.`t1` .* Partition.* InnoDB --echo # --echo # Bug#55091: Server crashes on ADD PARTITION after a failed attempt --echo # -SET @old_innodb_file_format_max = @@global.innodb_file_format_max; SET @old_innodb_file_format = @@global.innodb_file_format; SET @old_innodb_file_per_table = @@global.innodb_file_per_table; SET @old_innodb_strict_mode = @@global.innodb_strict_mode; @@ -66,7 +65,6 @@ DROP TABLE t1; SET @@global.innodb_strict_mode = @old_innodb_strict_mode; SET @@global.innodb_file_format = @old_innodb_file_format; SET @@global.innodb_file_per_table = @old_innodb_file_per_table; -SET @@global.innodb_file_format_max = @old_innodb_file_format_max; # # Bug#32430 - show engine innodb status causes errors diff --git a/mysql-test/t/partition_pruning.test b/mysql-test/t/partition_pruning.test index f2ca16b9259..da41b8e9428 100644 --- a/mysql-test/t/partition_pruning.test +++ b/mysql-test/t/partition_pruning.test @@ -892,6 +892,7 @@ drop table t1; create table t1 (a int not null, b int not null, key(a), key(b)) partition by hash(a) partitions 4; insert into t1 values (1,1),(2,2),(3,3),(4,4); +insert into t1 values (5,5),(6,6),(7,7),(8,8); explain partitions select * from t1 X, t1 Y diff --git a/mysql-test/t/plugin_auth.test b/mysql-test/t/plugin_auth.test index 16c96fa0c21..e1de1cc8153 100644 --- a/mysql-test/t/plugin_auth.test +++ b/mysql-test/t/plugin_auth.test @@ -507,4 +507,63 @@ SELECT IS_NULLABLE, COLUMN_NAME FROM INFORMATION_SCHEMA.COLUMNS ORDER BY COLUMN_NAME; +--echo # +--echo # Bug # 11766641: 59792: BIN/MYSQL -UUNKNOWN -PUNKNOWN +--echo # .-> USING PASSWORD: NO +--echo # + +--echo # shoud contain "using password=yes" +--error 1 +--exec $MYSQL -uunknown -punknown 2>&1 + +--echo # shoud contain "using password=no" +--error 1 +--exec $MYSQL -uunknown 2>&1 + +--echo # +--echo # Bug #12610784: SET PASSWORD INCORRECTLY KEEP AN OLD EMPTY PASSWORD +--echo # + +CREATE USER bug12610784@localhost; +SET PASSWORD FOR bug12610784@localhost = PASSWORD('secret'); +--disable_query_log +--error ER_ACCESS_DENIED_ERROR +connect(b12610784,localhost,bug12610784,,test); +--enable_query_log +connect(b12610784,localhost,bug12610784,secret,test); +connection default; +disconnect b12610784; +DROP USER bug12610784@localhost; + + +--echo # +--echo # Bug #12818542: PAM: ADDING PASSWORD FOR AN ACCOUNT DISABLES PAM +--echo # AUTHENTICATION SETTINGS +--echo # + +CREATE USER bug12818542@localhost + IDENTIFIED WITH 'test_plugin_server' AS 'bug12818542_dest'; +CREATE USER bug12818542_dest@localhost + IDENTIFIED BY 'bug12818542_dest_passwd'; +GRANT PROXY ON bug12818542_dest@localhost TO bug12818542@localhost; + +connect(bug12818542_con,localhost,bug12818542,bug12818542_dest); +connection bug12818542_con; +SELECT USER(),CURRENT_USER(); + +SET PASSWORD = PASSWORD('bruhaha'); + +connection default; +disconnect bug12818542_con; + +connect(bug12818542_con2,localhost,bug12818542,bug12818542_dest); +connection bug12818542_con2; +SELECT USER(),CURRENT_USER(); + +connection default; +disconnect bug12818542_con2; + +DROP USER bug12818542@localhost; +DROP USER bug12818542_dest@localhost; + --echo End of 5.5 tests diff --git a/mysql-test/t/range.test b/mysql-test/t/range.test index 0a34bac32ba..746d6bad896 100644 --- a/mysql-test/t/range.test +++ b/mysql-test/t/range.test @@ -554,6 +554,18 @@ INSERT INTO t1 VALUES 'd8c4177d09f8b11f5.52725521'), ('d8c4177d24ccef970.14957924','d8c4177d09f8b11f5.52725521',10,11, 'd8c4177d09f8b11f5.52725521'); +INSERT INTO t1 VALUES +('d8c4177d09f8b11f5.52725522','oxrootid',1,40,'d8c4177d09f8b11f5.52725522'), +('d8c4177d151affab2.81582771','d8c4177d09f8b11f5.52725521',2,3, + 'd8c4177d09f8b11f5.52725522'), +('d8c4177d206a333d2.74422678','d8c4177d09f8b11f5.52725521',4,5, + 'd8c4177d09f8b11f5.52725522'), +('d8c4177d225791924.30714721','d8c4177d09f8b11f5.52725521',6,7, + 'd8c4177d09f8b11f5.52725522'), +('d8c4177d2380fc201.39666694','d8c4177d09f8b11f5.52725521',8,9, + 'd8c4177d09f8b11f5.52725522'), +('d8c4177d24ccef970.14957925','d8c4177d09f8b11f5.52725521',10,11, + 'd8c4177d09f8b11f5.52725522'); EXPLAIN SELECT s.oxid FROM t1 v, t1 s diff --git a/mysql-test/t/range_vs_index_merge.test b/mysql-test/t/range_vs_index_merge.test index 1f7065dcb0a..2ffa2d8eb49 100755 --- a/mysql-test/t/range_vs_index_merge.test +++ b/mysql-test/t/range_vs_index_merge.test @@ -1029,5 +1029,34 @@ SELECT * FROM t1,t2,t3 DROP TABLE t1,t2,t3; +# +# LP bug #823301: index merge union with prossible index scan +# +# + +CREATE TABLE t1 ( + a int, b int, c int, d int, + PRIMARY KEY(b), INDEX idx1(d), INDEX idx2(d,b,c) +); +INSERT INTO t1 VALUES + (0,58,7,7),(0,63,2,0),(0,64,186,8),(0,65,1,-2), (0,71,190,-3), + (0,72,321,-7),(0,73,0,3),(0,74,5,25),(0,75,5,3); + +SET SESSION optimizer_switch='index_merge_sort_union=off'; +EXPLAIN +SELECT * FROM t1 + WHERE t1.b>7 AND t1.d>1 AND t1.d<>8 OR t1.d>=7 AND t1.d<8 OR t1.d>7; +SELECT * FROM t1 + WHERE t1.b>7 AND t1.d>1 AND t1.d<>8 OR t1.d>=7 AND t1.d<8 OR t1.d>7; +SET SESSION optimizer_switch='index_merge_sort_union=on'; +EXPLAIN +SELECT * FROM t1 + WHERE t1.b>7 AND t1.d>1 AND t1.d<>8 OR t1.d>=7 AND t1.d<8 OR t1.d>7; +SELECT * FROM t1 + WHERE t1.b>7 AND t1.d>1 AND t1.d<>8 OR t1.d>=7 AND t1.d<8 OR t1.d>7; +SET SESSION optimizer_switch=DEFAULT; + +DROP TABLE t1; + #the following command must be the last one in the file set session optimizer_switch='index_merge_sort_intersection=default'; diff --git a/mysql-test/t/secure_file_priv_win-master.opt b/mysql-test/t/secure_file_priv_win-master.opt new file mode 100644 index 00000000000..e9a43a5584d --- /dev/null +++ b/mysql-test/t/secure_file_priv_win-master.opt @@ -0,0 +1 @@ +--secure_file_priv=$MYSQL_TMP_DIR diff --git a/mysql-test/t/secure_file_priv_win.test b/mysql-test/t/secure_file_priv_win.test new file mode 100644 index 00000000000..a12510974ce --- /dev/null +++ b/mysql-test/t/secure_file_priv_win.test @@ -0,0 +1,79 @@ +# +# Bug58747 breaks secure_file_priv+not secure yet+still accesses other folders +# + +# we do the windows specific relative directory testing + +--source include/windows.inc + +CREATE TABLE t1 (c1 longtext); +INSERT INTO t1 values ('a'); + +LET $MYSQL_TMP_DIR_UCASE= `SELECT upper('$MYSQL_TMP_DIR')`; +LET $MYSQL_TMP_DIR_LCASE= `SELECT lower('$MYSQL_TMP_DIR')`; + +#create the file +--replace_result $MYSQL_TMP_DIR MYSQL_TMP_DIR +eval SELECT * FROM t1 INTO OUTFILE '$MYSQL_TMP_DIR/B11764517.tmp'; + +--replace_result $MYSQL_TMP_DIR MYSQL_TMP_DIR +show global variables like 'secure_file_priv'; + +--replace_result $MYSQL_TMP_DIR MYSQL_TMP_DIR +eval SELECT load_file('$MYSQL_TMP_DIR\\\\B11764517.tmp') AS x; + +--replace_result $MYSQL_TMP_DIR MYSQL_TMP_DIR +eval SELECT load_file('$MYSQL_TMP_DIR/B11764517.tmp') AS x; + +--replace_result $MYSQL_TMP_DIR_UCASE MYSQL_TMP_DIR_UCASE +eval SELECT load_file('$MYSQL_TMP_DIR_UCASE/B11764517.tmp') AS x; + +--replace_result $MYSQL_TMP_DIR_LCASE MYSQL_TMP_DIR_LCASE +eval SELECT load_file('$MYSQL_TMP_DIR_LCASE/B11764517.tmp') AS x; + +--replace_result $MYSQL_TMP_DIR MYSQL_TMP_DIR +eval SELECT load_file('$MYSQL_TMP_DIR\\\\..a..\\\\..\\\\..\\\\B11764517.tmp') AS x; + +--replace_result $MYSQL_TMP_DIR MYSQL_TMP_DIR +eval LOAD DATA INFILE '$MYSQL_TMP_DIR\\\\B11764517.tmp' INTO TABLE t1; + +--replace_result $MYSQL_TMP_DIR MYSQL_TMP_DIR +eval LOAD DATA INFILE '$MYSQL_TMP_DIR/B11764517.tmp' INTO TABLE t1; + +--replace_result $MYSQL_TMP_DIR_UCASE MYSQL_TMP_DIR_UCASE +eval LOAD DATA INFILE '$MYSQL_TMP_DIR_UCASE/B11764517.tmp' INTO TABLE t1; + +--replace_result $MYSQL_TMP_DIR_LCASE MYSQL_TMP_DIR_LCASE +eval LOAD DATA INFILE '$MYSQL_TMP_DIR_LCASE/B11764517.tmp' INTO TABLE t1; + +--replace_result $MYSQL_TMP_DIR MYSQL_TMP_DIR +--error ER_OPTION_PREVENTS_STATEMENT +eval LOAD DATA INFILE "$MYSQL_TMP_DIR\\\\..a..\\\\..\\\\..\\\\B11764517.tmp" into table t1; + +--replace_result $MYSQL_TMP_DIR MYSQL_TMP_DIR +--error ER_OPTION_PREVENTS_STATEMENT +eval SELECT * FROM t1 INTO OUTFILE '$MYSQL_TMP_DIR\\\\..a..\\\\..\\\\..\\\\B11764517-2.tmp'; + +--replace_result $MYSQL_TMP_DIR MYSQL_TMP_DIR +eval SELECT * FROM t1 INTO OUTFILE '$MYSQL_TMP_DIR\\\\B11764517-2.tmp'; + +--replace_result $MYSQL_TMP_DIR MYSQL_TMP_DIR +eval SELECT * FROM t1 INTO OUTFILE '$MYSQL_TMP_DIR/B11764517-3.tmp'; + +--replace_result $MYSQL_TMP_DIR_UCASE MYSQL_TMP_DIR_UCASE +eval SELECT * FROM t1 INTO OUTFILE '$MYSQL_TMP_DIR_UCASE/B11764517-4.tmp'; + +--replace_result $MYSQL_TMP_DIR_LCASE MYSQL_TMP_DIR_LCASE +eval SELECT * FROM t1 INTO OUTFILE '$MYSQL_TMP_DIR_LCASE/B11764517-5.tmp'; + +--error 0,1 +--remove_file $MYSQL_TMP_DIR/B11764517.tmp; +--error 0,1 +--remove_file $MYSQL_TMP_DIR/B11764517-2.tmp; +--error 0,1 +--remove_file $MYSQL_TMP_DIR/B11764517-3.tmp; +--error 0,1 +--remove_file $MYSQL_TMP_DIR/B11764517-4.tmp; +--error 0,1 +--remove_file $MYSQL_TMP_DIR/B11764517-5.tmp; +DROP TABLE t1; diff --git a/mysql-test/t/select.test b/mysql-test/t/select.test index e9ae69826e5..3781f7a5d43 100644 --- a/mysql-test/t/select.test +++ b/mysql-test/t/select.test @@ -1966,6 +1966,7 @@ CREATE TABLE t2 ( a BLOB, INDEX (a(20)) ); INSERT INTO t1 VALUES ('one'),('two'),('three'),('four'),('five'); INSERT INTO t2 VALUES ('one'),('two'),('three'),('four'),('five'); +INSERT INTO t2 VALUES ('one'),('two'),('three'),('four'),('five'); EXPLAIN SELECT * FROM t1 LEFT JOIN t2 USE INDEX (a) ON t1.a=t2.a; EXPLAIN SELECT * FROM t1 LEFT JOIN t2 FORCE INDEX (a) ON t1.a=t2.a; diff --git a/mysql-test/t/select_safe.test b/mysql-test/t/select_safe.test index cca736d4c1d..c76e337cd10 100644 --- a/mysql-test/t/select_safe.test +++ b/mysql-test/t/select_safe.test @@ -58,6 +58,8 @@ SELECT * from t1; # analyze table t1; insert into t1 values (null,"a"),(null,"a"),(null,"a"),(null,"a"),(null,"a"),(null,"a"),(null,"a"),(null,"a"),(null,"a"),(null,"a"); +insert into t1 values (null,"b"),(null,"b"),(null,"c"),(null,"c"),(null,"d"),(null,"d"),(null,"e"),(null,"e"),(null,"a"),(null,"e"); +insert into t1 values (null,"x"),(null,"x"),(null,"y"),(null,"y"),(null,"z"),(null,"z"),(null,"v"),(null,"v"),(null,"a"),(null,"v"); explain select STRAIGHT_JOIN * from t1,t1 as t2 where t1.b=t2.b; set MAX_SEEKS_FOR_KEY=1; explain select STRAIGHT_JOIN * from t1,t1 as t2 where t1.b=t2.b; diff --git a/mysql-test/t/show_check.test b/mysql-test/t/show_check.test index bc5ac8ac63f..e78724d16da 100644 --- a/mysql-test/t/show_check.test +++ b/mysql-test/t/show_check.test @@ -295,37 +295,37 @@ CREATE TABLE t3 ( insert into t1 values (1),(2); insert into t2 values (1),(2); insert into t3 values (1,1),(2,2); ---replace_column 6 # 7 # 8 # 9 # +--replace_column 6 # 7 # 8 # 9 # 12 # show table status; insert into t1 values (3),(4); insert into t2 values (3),(4); insert into t3 values (3,3),(4,4); ---replace_column 6 # 7 # 8 # 9 # +--replace_column 6 # 7 # 8 # 9 # 12 # show table status; insert into t1 values (5); insert into t2 values (5); insert into t3 values (5,5); ---replace_column 6 # 7 # 8 # 9 # +--replace_column 6 # 7 # 8 # 9 # 12 # show table status; delete from t1 where a=3; delete from t2 where b=3; delete from t3 where a=3; ---replace_column 6 # 7 # 8 # 9 # 10 # +--replace_column 6 # 7 # 8 # 9 # 10 # 12 # show table status; truncate table t1; truncate table t2; truncate table t3; ---replace_column 6 # 7 # 8 # 9 # +--replace_column 6 # 7 # 8 # 9 # 12 # show table status; insert into t1 values (5); insert into t2 values (5); insert into t3 values (5,5); ---replace_column 6 # 7 # 8 # 9 # +--replace_column 6 # 7 # 8 # 9 # 12 # show table status; delete from t1 where a=5; delete from t2 where b=5; delete from t3 where a=5; ---replace_column 6 # 7 # 8 # 9 # 10 # +--replace_column 6 # 7 # 8 # 9 # 10 # 12 # show table status; drop table t1, t2, t3; @@ -443,7 +443,7 @@ flush tables; # Create a junk frm file on disk let $MYSQLD_DATADIR= `select @@datadir`; system echo "this is a junk file for test" >> $MYSQLD_DATADIR/test/t1.frm ; ---replace_column 6 # 7 # 8 # 9 # +--replace_column 6 # 7 # 8 # 9 # 12 # SHOW TABLE STATUS like 't1'; --error ER_NOT_FORM_FILE show create table t1; @@ -1073,7 +1073,7 @@ set names latin1; SET NAMES latin1; CREATE DATABASE `ä`; CREATE TABLE `ä`.`ä` (a int) ENGINE=Memory; ---replace_column 6 # 7 # 8 # 9 # +--replace_column 6 # 7 # 8 # 9 # 12 # SHOW TABLE STATUS FROM `ä` LIKE 'ä'; DROP DATABASE `ä`; diff --git a/mysql-test/t/sp-error.test b/mysql-test/t/sp-error.test index 6175fc53adf..063b30c01cb 100644 --- a/mysql-test/t/sp-error.test +++ b/mysql-test/t/sp-error.test @@ -2541,6 +2541,28 @@ DROP PROCEDURE p1; DROP VIEW v1; DROP TABLE t1; +--echo # +--echo # Bug#12428824 - PARSER STACK OVERFLOW AND CRASH IN SP_ADD_USED_ROUTINE +--echo # WITH OBSCURE QUERY +--echo # + +--error ER_TOO_LONG_IDENT +SELECT very_long_fn_name_1111111111111111111111111111111111111111111111111111111111111111111111111222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222225555555555555555555555555577777777777777777777777777777777777777777777777777777777777777777777777788888888999999999999999999999(); + +--error ER_TOO_LONG_IDENT +CALL very_long_pr_name_1111111111111111111111111111111111111111111111111111111111111111111111111222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222225555555555555555555555555577777777777777777777777777777777777777777777777777777777777777777777777788888888999999999999999999999(); + +--error ER_WRONG_DB_NAME +SELECT very_long_db_name_1111111111111111111111111111111111111111111111111111111111111111111111111222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222225555555555555555555555555577777777777777777777777777777777777777777777777777777777777777777777777788888888999999999999999999999.simple_func(); + +--error ER_WRONG_DB_NAME +CALL very_long_db_name_1111111111111111111111111111111111111111111111111111111111111111111111111222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222225555555555555555555555555577777777777777777777777777777777777777777777777777777777777777777777777788888888999999999999999999999.simple_proc(); + +--error ER_TOO_LONG_IDENT +SELECT db_name.very_long_fn_name_111111111111111111111111111111111111111111111111111111111111111111111111122222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222999999999999999999999(); + +--error ER_TOO_LONG_IDENT +CALL db_name.very_long_pr_name_111111111111111111111111111111111111111111111111111111111111111111111111122222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222999999999999999999999(); --echo End of 5.1 tests --echo # diff --git a/mysql-test/t/sp-security.test b/mysql-test/t/sp-security.test index d7ea829bf50..ca4e6b04f13 100644 --- a/mysql-test/t/sp-security.test +++ b/mysql-test/t/sp-security.test @@ -959,6 +959,43 @@ drop user bug57061_user@localhost; drop database mysqltest_db; +--echo # +--echo # Bug#11882603 SELECT_ACL ON ANY COLUMN IN MYSQL.PROC ALLOWS TO SEE +--echo # DEFINITION OF ANY ROUTINE. +--echo # + +--disable_warnings +DROP DATABASE IF EXISTS db1; +--enable_warnings + +CREATE DATABASE db1; +CREATE PROCEDURE db1.p1() SELECT 1; +CREATE USER user2@localhost IDENTIFIED BY ''; +GRANT SELECT(db) ON mysql.proc TO user2@localhost; + +--echo # Connection con2 as user2 +connect (con2, localhost, user2); +--echo # The statement below before disclosed info from body_utf8 column. +--error ER_SP_DOES_NOT_EXIST +SHOW CREATE PROCEDURE db1.p1; + +--echo # Check that SHOW works with SELECT grant on whole table +--echo # Connection default +connection default; +GRANT SELECT ON mysql.proc TO user2@localhost; + +--echo # Connection con2 +connection con2; +--echo # This should work +SHOW CREATE PROCEDURE db1.p1; + +--echo # Connection default +connection default; +disconnect con2; +DROP USER user2@localhost; +DROP DATABASE db1; + + # Wait till all disconnects are completed --source include/wait_until_count_sessions.inc diff --git a/mysql-test/t/sp.test b/mysql-test/t/sp.test index 2b83e9a10dc..acbf75d9f01 100644 --- a/mysql-test/t/sp.test +++ b/mysql-test/t/sp.test @@ -8385,6 +8385,53 @@ SET @@GLOBAL.init_connect= @old_init_connect; DROP PROCEDURE p2; DROP PROCEDURE p5; + +--echo # +--echo # Bug#11840395 (formerly known as bug#60347): +--echo # The string "versiondata" seems +--echo # to be 'leaking' into the schema name space +--echo # +--disable_warnings +DROP DATABASE IF EXISTS mixedCaseDbName; +--enable_warnings +CREATE DATABASE mixedCaseDbName; +DELIMITER |; +CREATE PROCEDURE mixedCaseDbName.tryMyProc() begin end| +CREATE FUNCTION mixedCaseDbName.tryMyFunc() returns text begin return 'IT WORKS'; end +| +DELIMITER ;| +call mixedCaseDbName.tryMyProc(); +select mixedCaseDbName.tryMyFunc(); +DROP DATABASE mixedCaseDbName; + + +--echo # +--echo # Bug#11766594 59736: SELECT DISTINCT.. INCORRECT RESULT WITH DETERMINISTIC FUNCTION IN WHERE C +--echo # + +CREATE TABLE t1 (a INT, b INT, KEY(b)); +CREATE TABLE t2 (c INT, d INT, KEY(c)); +INSERT INTO t1 VALUES (1,1),(1,1),(1,2); +INSERT INTO t2 VALUES (1,1),(1,2); + +DELIMITER $; + +CREATE FUNCTION f1() RETURNS INT DETERMINISTIC +BEGIN + DECLARE a int; + -- SQL statement inside + SELECT 1 INTO a; + RETURN a; +END $ + +DELIMITER ;$ + +SELECT COUNT(DISTINCT d) FROM t1, t2 WHERE a = c AND b = f1(); + +DROP FUNCTION f1; +DROP TABLE t1, t2; + + --echo # ------------------------------------------------------------------ --echo # -- End of 5.1 tests --echo # ------------------------------------------------------------------ @@ -8787,4 +8834,60 @@ DROP TABLE t1, t2, t3; DROP PROCEDURE p1; --echo + +--echo +--echo # -- +--echo # -- Bug#12652769 - 61470: case operator in stored routine retains old +--echo # -- value of input parameter +--echo # --- + +--disable_warnings +DROP TABLE IF EXISTS t1; +DROP PROCEDURE IF EXISTS p1; +--enable_warnings + +CREATE TABLE t1 (s1 CHAR(5) CHARACTER SET utf8); +INSERT INTO t1 VALUES ('a'); + +delimiter |; + +CREATE PROCEDURE p1(dt DATETIME, i INT) +BEGIN + SELECT + CASE + WHEN i = 1 THEN 2 + ELSE dt + END AS x1; + + SELECT + CASE _latin1'a' + WHEN _utf8'a' THEN 'A' + END AS x2; + + SELECT + CASE _utf8'a' + WHEN _latin1'a' THEN _utf8'A' + END AS x3; + + SELECT + CASE s1 + WHEN _latin1'a' THEN _latin1'b' + ELSE _latin1'c' + END AS x4 + FROM t1; +END| + +delimiter ;| + +--echo +CALL p1('2011-04-03 05:14:10', 1); +CALL p1('2011-04-03 05:14:11', 2); +CALL p1('2011-04-03 05:14:12', 2); +CALL p1('2011-04-03 05:14:13', 2); + +--echo +DROP TABLE t1; +DROP PROCEDURE p1; +--echo + --echo # End of 5.5 test diff --git a/mysql-test/t/sp_sync.test b/mysql-test/t/sp_sync.test index 368a09eac8c..589832bb570 100644 --- a/mysql-test/t/sp_sync.test +++ b/mysql-test/t/sp_sync.test @@ -1,7 +1,7 @@ # This test should work in embedded server after mysqltest is fixed -- source include/not_embedded.inc ---echo Tests of syncronization of stored procedure execution. +--echo Tests of synchronization of stored procedure execution. --source include/have_debug_sync.inc @@ -149,9 +149,34 @@ disconnect con2; DROP PROCEDURE p1; DROP FUNCTION f1; DROP TABLES t0, t1; -SET DEBUG_SYNC= 'RESET'; +--echo # +--echo # test for bug#11756013 +--echo # +--disable_warnings +DROP SCHEMA IF EXISTS s1; +--enable_warnings +CREATE SCHEMA s1; +CREATE PROCEDURE s1.p1() BEGIN END; + +connect (con3, localhost, root); +SET DEBUG_SYNC='before_db_dir_check SIGNAL check_db WAIT_FOR dropped_schema'; +--send CALL s1.p1 + +connection default; +SET DEBUG_SYNC='now WAIT_FOR check_db'; +DROP SCHEMA s1; +SET DEBUG_SYNC='now SIGNAL dropped_schema'; + +connection con3; +--error ER_BAD_DB_ERROR +--reap +connection default; +disconnect con3; + +SET DEBUG_SYNC = 'RESET'; + # Check that all connections opened by test cases in this file are really # gone so execution of other tests won't be affected by their presence. --source include/wait_until_count_sessions.inc diff --git a/mysql-test/t/sp_trans.test b/mysql-test/t/sp_trans.test index c114d397e43..39ac086071b 100644 --- a/mysql-test/t/sp_trans.test +++ b/mysql-test/t/sp_trans.test @@ -598,6 +598,39 @@ select distinct f1, bug13575(f1) from t3 order by f1| drop function bug13575| drop table t3| +# +# BUG#11758414: Default storage_engine not honored when set +# from within a stored procedure +# +SELECT @@GLOBAL.storage_engine INTO @old_engine| +SET @@GLOBAL.storage_engine=InnoDB| +SET @@SESSION.storage_engine=InnoDB| +# show defaults at define-time +SHOW GLOBAL VARIABLES LIKE 'storage_engine'| +SHOW SESSION VARIABLES LIKE 'storage_engine'| +CREATE PROCEDURE bug11758414() +BEGIN + SET @@GLOBAL.storage_engine="MyISAM"; + SET @@SESSION.storage_engine="MyISAM"; + # show defaults at execution time / that setting them worked + SHOW GLOBAL VARIABLES LIKE 'storage_engine'; + SHOW SESSION VARIABLES LIKE 'storage_engine'; + CREATE TABLE t1 (id int); + CREATE TABLE t2 (id int) ENGINE=InnoDB; + # show we're heeding the default (at run-time, not parse-time!) + SHOW CREATE TABLE t1; + # show that we didn't break explicit override with ENGINE=... + SHOW CREATE TABLE t2; +END; +| +CALL bug11758414| +# show that changing defaults within SP stuck +SHOW GLOBAL VARIABLES LIKE 'storage_engine'| +SHOW SESSION VARIABLES LIKE 'storage_engine'| +DROP PROCEDURE bug11758414| +DROP TABLE t1, t2| +SET @@GLOBAL.storage_engine=@old_engine| + --echo # --echo # End of 5.1 tests --echo # diff --git a/mysql-test/t/subselect.test b/mysql-test/t/subselect.test index 7444af790e5..6369e4edbeb 100644 --- a/mysql-test/t/subselect.test +++ b/mysql-test/t/subselect.test @@ -14,7 +14,7 @@ drop view if exists v2; set @subselect_tmp=@@optimizer_switch; set @@optimizer_switch=ifnull(@optimizer_switch_for_subselect_test, - "semijoin=on,firstmatch=on,loosescan=on,partial_match_rowid_merge=off,partial_match_table_scan=off"); + "semijoin=on,firstmatch=on,loosescan=on,semijoin_with_cache=on,partial_match_rowid_merge=off,partial_match_table_scan=off"); set optimizer_switch='mrr=on,mrr_sort_keys=on,index_condition_pushdown=on'; select (select 2); @@ -292,8 +292,9 @@ SELECT (SELECT numeropost FROM t1 HAVING numreponse=a),numreponse FROM (SELECT * SELECT numreponse, (SELECT numeropost FROM t1 HAVING numreponse=a) FROM (SELECT * FROM t1) as a; SELECT numreponse, (SELECT numeropost FROM t1 HAVING numreponse=1) FROM (SELECT * FROM t1) as a; INSERT INTO t1 (numeropost,numreponse,pseudo) VALUES (1,1,'joce'),(1,2,'joce'),(1,3,'test'); --- error ER_SUBQUERY_NO_1_ROW EXPLAIN EXTENDED SELECT numreponse FROM t1 WHERE numeropost='1' AND numreponse=(SELECT 1 FROM t1 WHERE numeropost='1'); +-- error ER_SUBQUERY_NO_1_ROW +SELECT numreponse FROM t1 WHERE numeropost='1' AND numreponse=(SELECT 1 FROM t1 WHERE numeropost='1'); EXPLAIN EXTENDED SELECT MAX(numreponse) FROM t1 WHERE numeropost='1'; EXPLAIN EXTENDED SELECT numreponse FROM t1 WHERE numeropost='1' AND numreponse=(SELECT MAX(numreponse) FROM t1 WHERE numeropost='1'); drop table t1; @@ -503,6 +504,54 @@ SELECT t1.a, t1.a in (select t2.a from t2,t3 where t3.a=t2.a) FROM t1; explain extended SELECT t1.a, t1.a in (select t2.a from t2,t3 where t3.a=t2.a) FROM t1; drop table t1,t2,t3; +--echo # check correct NULL Processing for normal IN/ALL/ANY +--echo # and 2 ways of max/min optimization +create table t1 (a int); +insert into t1 values (1), (100), (NULL), (1000); +create table t2 (a int not null); + +--echo # subselect returns empty set (for NULL and non-NULL left part) +select a, a in (select * from t2) from t1; +select a, a > any (select * from t2) from t1; +select a, a > all (select * from t2) from t1; +select a from t1 where a in (select * from t2); +select a from t1 where a > any (select * from t2); +select a from t1 where a > all (select * from t2); +select a from t1 where a in (select * from t2 group by a); +select a from t1 where a > any (select * from t2 group by a); +select a from t1 where a > all (select * from t2 group by a); + +insert into t2 values (1),(200); + +--echo # sebselect returns non-empty set without NULLs +select a, a in (select * from t2) from t1; +select a, a > any (select * from t2) from t1; +select a, a > all (select * from t2) from t1; +select a from t1 where a in (select * from t2); +select a from t1 where a > any (select * from t2); +select a from t1 where a > all (select * from t2); +select a from t1 where a in (select * from t2 group by a); +select a from t1 where a > any (select * from t2 group by a); +select a from t1 where a > all (select * from t2 group by a); + +drop table t2; +create table t2 (a int); +insert into t2 values (1),(NULL),(200); + +--echo # sebselect returns non-empty set with NULLs +select a, a in (select * from t2) from t1; +select a, a > any (select * from t2) from t1; +select a, a > all (select * from t2) from t1; +select a from t1 where a in (select * from t2); +select a from t1 where a > any (select * from t2); +select a from t1 where a > all (select * from t2); +select a from t1 where a in (select * from t2 group by a); +select a from t1 where a > any (select * from t2 group by a); +select a from t1 where a > all (select * from t2 group by a); + + +drop table t1, t2; + #LIMIT is not supported now create table t1 (a float); -- error ER_NOT_SUPPORTED_YET @@ -934,7 +983,7 @@ drop table t1,t2; # # correct ALL optimisation # -create table t2 (a int, b int); +create table t2 (a int, b int not null); create table t3 (a int); insert into t3 values (6),(7),(3); select * from t3 where a >= all (select b from t2); @@ -1817,6 +1866,9 @@ drop table t1; # Bug#11867 queries with ROW(,elems>) IN (SELECT DISTINCT <cols> FROM ...) # +set @tmp11867_optimizer_switch=@@optimizer_switch; +set optimizer_switch='semijoin_with_cache=off'; + CREATE TABLE t1 (one int, two int, flag char(1)); CREATE TABLE t2 (one int, two int, flag char(1)); INSERT INTO t1 VALUES(1,2,'Y'),(2,3,'Y'),(3,4,'Y'),(5,6,'N'),(7,8,'N'); @@ -1844,6 +1896,7 @@ explain extended SELECT one,two from t1 where ROW(one,two) IN (SELECT one,two FR explain extended SELECT one,two,ROW(one,two) IN (SELECT one,two FROM t2 WHERE flag = '0' group by one,two) as 'test' from t1; DROP TABLE t1,t2; +set optimizer_switch=@tmp11867_optimizer_switch; # # Bug#12392 where cond with IN predicate for rows and NULL values in table @@ -3433,6 +3486,39 @@ ORDER BY outr.pk; DROP TABLE t1,t2; +#--echo # +#--echo # Bug#12329653 +#--echo # EXPLAIN, UNION, PREPARED STATEMENT, CRASH, SQL_FULL_GROUP_BY +#--echo # +# +#CREATE TABLE t1(a1 int); +#INSERT INTO t1 VALUES (1),(2); +# +#SELECT @@session.sql_mode INTO @old_sql_mode; +#SET SESSION sql_mode='ONLY_FULL_GROUP_BY'; +# +### First a simpler query, illustrating the transformation +### '1 < some (...)' => '1 < max(...)' +#SELECT 1 FROM t1 WHERE 1 < SOME (SELECT a1 FROM t1); +# +### The query which made the server crash. +#PREPARE stmt FROM +#'SELECT 1 UNION ALL +#SELECT 1 FROM t1 +#ORDER BY +#(SELECT 1 FROM t1 AS t1_0 +# WHERE 1 < SOME (SELECT a1 FROM t1) +#)' ; +# +#--error ER_SUBQUERY_NO_1_ROW +#EXECUTE stmt ; +#--error ER_SUBQUERY_NO_1_ROW +#EXECUTE stmt ; +# +#SET SESSION sql_mode=@old_sql_mode; +# +#DEALLOCATE PREPARE stmt; +#DROP TABLE t1; --echo End of 5.0 tests. @@ -4689,6 +4775,87 @@ SELECT 1 as foo FROM t1 WHERE a < SOME DROP TABLE t1; +# +# LP BUG#823169 NULLs with ALL/ANY and maxmin optimization +# +CREATE TABLE t1 (a int(11), b varchar(1)); +INSERT INTO t1 VALUES (2,NULL),(5,'d'),(7,'g'); + +SELECT a FROM t1 WHERE b < ANY ( SELECT b FROM t1 GROUP BY b ); +SELECT a FROM t1 WHERE b < ANY ( SELECT b FROM t1 ); +SELECT a FROM t1 WHERE b > ANY ( SELECT b FROM t1 GROUP BY b ); +SELECT a FROM t1 WHERE b > ANY ( SELECT b FROM t1 ); +SELECT a FROM t1 WHERE b <= ANY ( SELECT b FROM t1 GROUP BY b ); +SELECT a FROM t1 WHERE b <= ANY ( SELECT b FROM t1 ); +SELECT a FROM t1 WHERE b >= ANY ( SELECT b FROM t1 GROUP BY b ); +SELECT a FROM t1 WHERE b >= ANY ( SELECT b FROM t1 ); +SELECT a FROM t1 WHERE b = ANY ( SELECT b FROM t1 ); +SELECT a FROM t1 WHERE b = ANY ( SELECT b FROM t1 GROUP BY b ); +SELECT a FROM t1 WHERE b <> ANY ( SELECT b FROM t1 ); +SELECT a FROM t1 WHERE b <> ANY ( SELECT b FROM t1 GROUP BY b ); + +SELECT a FROM t1 WHERE b < ALL ( SELECT b FROM t1 GROUP BY b ); +SELECT a FROM t1 WHERE b < ALL ( SELECT b FROM t1 ); +SELECT a FROM t1 WHERE b > ALL ( SELECT b FROM t1 GROUP BY b ); +SELECT a FROM t1 WHERE b > ALL ( SELECT b FROM t1 ); +SELECT a FROM t1 WHERE b <= ALL ( SELECT b FROM t1 GROUP BY b ); +SELECT a FROM t1 WHERE b <= ALL ( SELECT b FROM t1 ); +SELECT a FROM t1 WHERE b >= ALL ( SELECT b FROM t1 GROUP BY b ); +SELECT a FROM t1 WHERE b >= ALL ( SELECT b FROM t1 ); +SELECT a FROM t1 WHERE b = ALL ( SELECT b FROM t1 ); +SELECT a FROM t1 WHERE b = ALL ( SELECT b FROM t1 GROUP BY b ); +SELECT a FROM t1 WHERE b <> ALL ( SELECT b FROM t1 ); +SELECT a FROM t1 WHERE b <> ALL ( SELECT b FROM t1 GROUP BY b ); + +delete from t1; +INSERT INTO t1 VALUES (2,NULL),(5,'d'),(7,'g'); + +SELECT a FROM t1 WHERE b < ANY ( SELECT b FROM t1 GROUP BY b ); +SELECT a FROM t1 WHERE b < ANY ( SELECT b FROM t1 ); +SELECT a FROM t1 WHERE b > ANY ( SELECT b FROM t1 GROUP BY b ); +SELECT a FROM t1 WHERE b > ANY ( SELECT b FROM t1 ); +SELECT a FROM t1 WHERE b <= ANY ( SELECT b FROM t1 GROUP BY b ); +SELECT a FROM t1 WHERE b <= ANY ( SELECT b FROM t1 ); +SELECT a FROM t1 WHERE b >= ANY ( SELECT b FROM t1 GROUP BY b ); +SELECT a FROM t1 WHERE b >= ANY ( SELECT b FROM t1 ); +SELECT a FROM t1 WHERE b = ANY ( SELECT b FROM t1 ); +SELECT a FROM t1 WHERE b = ANY ( SELECT b FROM t1 GROUP BY b ); +SELECT a FROM t1 WHERE b <> ANY ( SELECT b FROM t1 ); +SELECT a FROM t1 WHERE b <> ANY ( SELECT b FROM t1 GROUP BY b ); + +SELECT a FROM t1 WHERE b < ALL ( SELECT b FROM t1 GROUP BY b ); +SELECT a FROM t1 WHERE b < ALL ( SELECT b FROM t1 ); +SELECT a FROM t1 WHERE b > ALL ( SELECT b FROM t1 GROUP BY b ); +SELECT a FROM t1 WHERE b > ALL ( SELECT b FROM t1 ); +SELECT a FROM t1 WHERE b <= ALL ( SELECT b FROM t1 GROUP BY b ); +SELECT a FROM t1 WHERE b <= ALL ( SELECT b FROM t1 ); +SELECT a FROM t1 WHERE b >= ALL ( SELECT b FROM t1 GROUP BY b ); +SELECT a FROM t1 WHERE b >= ALL ( SELECT b FROM t1 ); +SELECT a FROM t1 WHERE b = ALL ( SELECT b FROM t1 ); +SELECT a FROM t1 WHERE b = ALL ( SELECT b FROM t1 GROUP BY b ); +SELECT a FROM t1 WHERE b <> ALL ( SELECT b FROM t1 ); +SELECT a FROM t1 WHERE b <> ALL ( SELECT b FROM t1 GROUP BY b ); + +drop table t1; + +--echo # +--echo # Fix of lp:780386 (NULL left part with empty ALL subquery). +--echo # +CREATE TABLE t1 ( f11 int) ; +INSERT IGNORE INTO t1 VALUES (0),(0); + +CREATE TABLE t2 ( f3 int, f10 int, KEY (f10,f3)) ; +INSERT IGNORE INTO t2 VALUES (NULL,NULL),(5,0); + +DROP TABLE IF EXISTS t3; +CREATE TABLE t3 ( f3 int) ; +INSERT INTO t3 VALUES (0),(0); + +SELECT a1.f3 AS r FROM t2 AS a1 , t1 WHERE a1.f3 < ALL ( SELECT f3 FROM t3 WHERE f3 = 1 ) ; +DROP TABLE t1, t2, t3; + +--echo End of 5.2 tests + --echo # --echo # BUG#779885: Crash in eliminate_item_equal with materialization=on in --echo # maria-5.3 @@ -4715,20 +4882,29 @@ WHERE DROP TABLE t1,t2,t3; --echo # ---echo # Fix of LP BUG#780386 (NULL left part with empty ALL subquery). +--echo # BUG lp:813473: Wrong result with outer join + NOT IN subquery +--echo # This bug is a duplicate of Bug#11764086 whose test case is added below --echo # -CREATE TABLE t1 ( f11 int) ; -INSERT IGNORE INTO t1 VALUES (0),(0); -CREATE TABLE t2 ( f3 int, f10 int, KEY (f10,f3)) ; -INSERT IGNORE INTO t2 VALUES (NULL,NULL),(5,0); +CREATE TABLE t1 (c int) ; +INSERT INTO t1 VALUES (5),(6); -DROP TABLE IF EXISTS t3; -CREATE TABLE t3 ( f3 int) ; -INSERT INTO t3 VALUES (0),(0); +CREATE TABLE t2 (a int, b int) ; +INSERT INTO t2 VALUES (20,9),(20,9); -SELECT a1.f3 AS r FROM t2 AS a1 , t1 WHERE a1.f3 < ALL ( SELECT f3 FROM t3 WHERE f3 = 1 ) ; -DROP TABLE t1, t2, t3; +create table t3 (d int, e int); +insert into t3 values (2, 9), (3,10); + +EXPLAIN +SELECT t2.b , t1.c +FROM t2 LEFT JOIN t1 ON t1.c < 3 +WHERE (t2.b , t1.c) NOT IN (SELECT * from t3); + +SELECT t2.b , t1.c +FROM t2 LEFT JOIN t1 ON t1.c < 3 +WHERE (t2.b, t1.c) NOT IN (SELECT * from t3); + +drop table t1, t2, t3; --echo End of 5.3 tests @@ -4827,4 +5003,64 @@ eval explain $query; DROP TABLE t1,t2; +--echo # +--echo # lp:826279: assertion failure with GROUP BY a result of subquery +--echo # + +CREATE TABLE t1 (a int); +INSERT INTO t1 VALUES (0), (0); + +CREATE TABLE t2 (a int, b int, c int); +INSERT INTO t2 VALUES (10,7,0), (0,7,0); + +CREATE TABLE t3 (a int, b int); +INSERT INTO t3 VALUES (10,7), (0,7); + +SELECT SUM(DISTINCT b), + (SELECT t2.a FROM t1 JOIN t2 ON t2.c != 0 + WHERE t.a != 0 AND t2.a != 0) + FROM (SELECT * FROM t3) AS t +GROUP BY 2; + +SELECT SUM(DISTINCT b), + (SELECT t2.a FROM t1,t2 WHERE t.a != 0 or 1=2 LIMIT 1) + FROM (SELECT * FROM t3) AS t +GROUP BY 2; + +DROP TABLE t1,t2,t3; + +--echo # +--echo # Bug#12329653 +--echo # EXPLAIN, UNION, PREPARED STATEMENT, CRASH, SQL_FULL_GROUP_BY +--echo # + +CREATE TABLE t1(a1 int); +INSERT INTO t1 VALUES (1),(2); + +SELECT @@session.sql_mode INTO @old_sql_mode; +SET SESSION sql_mode='ONLY_FULL_GROUP_BY'; + +## First a simpler query, illustrating the transformation +## '1 < some (...)' => '1 < max(...)' +SELECT 1 FROM t1 WHERE 1 < SOME (SELECT a1 FROM t1); + +## The query which made the server crash. +PREPARE stmt FROM +'SELECT 1 UNION ALL +SELECT 1 FROM t1 +ORDER BY +(SELECT 1 FROM t1 AS t1_0 + WHERE 1 < SOME (SELECT a1 FROM t1) +)' ; + +--error ER_SUBQUERY_NO_1_ROW +EXECUTE stmt ; +--error ER_SUBQUERY_NO_1_ROW +EXECUTE stmt ; + +SET SESSION sql_mode=@old_sql_mode; + +DEALLOCATE PREPARE stmt; +DROP TABLE t1; + set optimizer_switch=@subselect_tmp; diff --git a/mysql-test/t/subselect3.test b/mysql-test/t/subselect3.test index 1e92a147bcd..13c4b532c74 100644 --- a/mysql-test/t/subselect3.test +++ b/mysql-test/t/subselect3.test @@ -3,7 +3,7 @@ drop table if exists t0, t1, t2, t3, t4, t5, t11, t12, t21, t22; --enable_warnings set @subselect3_tmp= @@optimizer_switch; -set optimizer_switch='semijoin=on,firstmatch=on,loosescan=on'; +set optimizer_switch='semijoin=on,firstmatch=on,loosescan=on,semijoin_with_cache=on'; # # 1. Subquery with GROUP/HAVING @@ -81,6 +81,7 @@ insert into t1 values (2, 3), (2, NULL), (3, NULL); +insert into t1 values (5, 7), (8, 9), (4, 1); create table t2 (a int, oref int); insert into t2 values (1, 1), (2,2), (NULL, 3), (NULL, 4); @@ -1186,6 +1187,52 @@ CALL p1; DROP PROCEDURE p1; DROP TABLE t1, t2; +--echo # +--echo # fix of lp:824425 (prohibiting subqueries in row in +--echo # left part of IN/ALL/ANY) +--echo # + +CREATE TABLE t1 ( a int) ; +INSERT INTO t1 VALUES (20),(30); + +CREATE TABLE t2 (a int) ; +INSERT INTO t2 VALUES (3),(9); + +CREATE TABLE t3 ( a int, b int) ; +INSERT INTO t3 VALUES (20,5),(30,6); + +set @optimizer_switch_save=@@optimizer_switch; +SET SESSION optimizer_switch='semijoin=OFF,in_to_exists=OFF,materialization=ON,partial_match_rowid_merge=ON,partial_match_table_scan=OFF'; + +SELECT * FROM t1 +WHERE ( + ( SELECT a FROM t2 WHERE a = 9 ) +) NOT IN ( + SELECT b + FROM t3 +); +explain extended +SELECT * FROM t1 +WHERE ( + ( SELECT a FROM t2 WHERE a = 9 ) +) NOT IN ( + SELECT b + FROM t3 +); + +--error ER_NOT_SUPPORTED_YET +SELECT * FROM t1 +WHERE ( + ( SELECT a FROM t2 WHERE a = 9 ), + ( SELECT a FROM t2 WHERE a = 3 ) +) NOT IN ( + SELECT b , a + FROM t3 +); +set optimizer_switch=@optimizer_switch_save; + +drop table t1,t2,t3; + --echo End of 5.3 tests --echo # diff --git a/mysql-test/t/subselect4.test b/mysql-test/t/subselect4.test index b31ba9b8f89..41ca1762fef 100644 --- a/mysql-test/t/subselect4.test +++ b/mysql-test/t/subselect4.test @@ -7,6 +7,7 @@ drop view if exists v1, v2; set @subselect4_tmp= @@optimizer_switch; set optimizer_switch='semijoin=on,firstmatch=on,loosescan=on'; +set optimizer_switch='semijoin_with_cache=on'; set optimizer_switch='mrr=on,mrr_sort_keys=on,index_condition_pushdown=on'; --echo # @@ -239,35 +240,6 @@ set @@session.optimizer_switch = @old_optimizer_switch, DROP TABLE t1; --echo # ---echo # BUG#45863 "Assertion failed: (fixed == 0), function fix_fields(), ---echo # file item.cc, line 4448" ---echo # ---disable_warnings -DROP TABLE IF EXISTS C, BB; ---enable_warnings - -CREATE TABLE C ( - varchar_nokey varchar(1) NOT NULL -); -INSERT INTO C VALUES - ('k'),('a'),(''),('u'),('e'),('v'),('i'), - ('t'),('u'),('f'),('u'),('m'),('j'),('f'), - ('v'),('j'),('g'),('e'),('h'),('z'); -CREATE TABLE BB ( - varchar_nokey varchar(1) NOT NULL -); -INSERT INTO BB VALUES ('i'),('t'); --- error ER_OPERAND_COLUMNS -SELECT varchar_nokey FROM C -WHERE (varchar_nokey, OUTR) IN (SELECT varchar_nokey - FROM BB); --- error ER_BAD_FIELD_ERROR -SELECT varchar_nokey FROM C -WHERE (varchar_nokey, OUTR) IN (SELECT varchar_nokey, varchar_nokey - FROM BB); -DROP TABLE C,BB; - ---echo # --echo # During work with BUG#45863 I had problems with a query that was --echo # optimized differently in regular and prepared mode. --echo # Because there was a bug in one of the selected strategies, I became @@ -1591,5 +1563,72 @@ EXECUTE st2; drop table t1, t2; +--echo # +--echo # LP BUG#825018: Crash in check_and_do_in_subquery_rewrites() with corrlated subquery in select list +--echo # + +CREATE TABLE t1 (a int, b int); +INSERT INTO t1 VALUES (10,1),(11,7); + +CREATE TABLE t2 (a int); +INSERT INTO t2 VALUES (2),(3); + +CREATE TABLE t3 (a int, b int); +INSERT INTO t3 VALUES (1,1); + +CREATE PROCEDURE sp1 () LANGUAGE SQL +SELECT (SELECT t1.a + FROM t1 + WHERE t1.b = t3.b + AND t1.b IN ( SELECT a FROM t2 )) sq +FROM t3 +GROUP BY 1; +CALL sp1(); +CALL sp1(); +drop procedure sp1; + +prepare st1 from " +SELECT (SELECT t1.a + FROM t1 + WHERE t1.b = t3.b + AND t1.b IN ( SELECT a FROM t2 )) sq +FROM t3 +GROUP BY 1"; +execute st1; +execute st1; +deallocate prepare st1; + +drop table t1, t2, t3; set optimizer_switch=@subselect4_tmp; + +--echo # +--echo # LP BUG#833702 Wrong result with nested IN and singlerow subqueries and equality propagation +--echo # + +CREATE TABLE t2 (c int , a int, b int); +INSERT INTO t2 VALUES (10,7,0); + +CREATE TABLE t3 (a int, b int) ; +INSERT INTO t3 VALUES (5,0),(7,0); + +CREATE TABLE t4 (a int); +INSERT INTO t4 VALUES (2),(8); + +set @@optimizer_switch='semijoin=off,in_to_exists=on,materialization=off,subquery_cache=off'; + +SELECT * FROM t2 +WHERE t2.b IN (SELECT b FROM t3 WHERE t3.a = t2.a AND a < SOME (SELECT * FROM t4)) + OR ( t2.c > 242 ); + +EXPLAIN SELECT * FROM t2 +WHERE t2.b IN (SELECT t3.b FROM t3 WHERE t3.a < ANY (SELECT t4.a FROM t4) and t3.a = 7); +SELECT * FROM t2 +WHERE t2.b IN (SELECT t3.b FROM t3 WHERE t3.a < ANY (SELECT t4.a FROM t4) and t3.a = 7); + +drop table t2, t3, t4; + +set optimizer_switch=@subselect4_tmp; + +SET optimizer_switch= @@global.optimizer_switch; +set @@tmp_table_size= @@global.tmp_table_size; diff --git a/mysql-test/t/subselect_cache.test b/mysql-test/t/subselect_cache.test index e4671cf7b2a..d06bf06756a 100644 --- a/mysql-test/t/subselect_cache.test +++ b/mysql-test/t/subselect_cache.test @@ -1,6 +1,8 @@ --disable_warnings drop table if exists t0,t1,t2,t3,t4,t5,t6,t7,t8,t9; +drop view if exists v1; --enable_warnings + set optimizer_switch='subquery_cache=on'; create table t1 (a int, b int); @@ -1666,5 +1668,33 @@ FROM t1 WHERE t2.f1 OR t2.f3 ); drop tables t1, t2, t3; +--echo # +--echo # Test of LP BUG#872775 view with "outer references" bug +--echo # +set @@optimizer_switch= default; +set optimizer_switch='subquery_cache=on'; +CREATE TABLE t1 (a int) ; + +CREATE TABLE t2 (b int, c varchar(1) NOT NULL ) ; +INSERT INTO t2 VALUES (1,'x'),(2,'y'); + +CREATE TABLE t3 (a int) ; + +CREATE TABLE t4 ( pk int(11) NOT NULL , b int(11) NOT NULL ) ; +INSERT INTO t4 VALUES (26,9),(27,5),(28,0),(29,3); + +CREATE OR REPLACE VIEW v1 AS +SELECT t2.b +FROM t1 +JOIN t2 +WHERE t2 .c > ( + SELECT t2.c FROM t3 + ); + +SELECT * FROM t4 WHERE b NOT IN ( SELECT * FROM v1 ); + +drop view v1; +drop table t1,t2,t3,t4; + --echo # restore default set @@optimizer_switch= default; diff --git a/mysql-test/t/subselect_extra.test b/mysql-test/t/subselect_extra.test index 466f254e6ad..b76f3f70516 100644 --- a/mysql-test/t/subselect_extra.test +++ b/mysql-test/t/subselect_extra.test @@ -9,11 +9,12 @@ --disable_warnings drop table if exists t1,t2,t3,t4; +drop view if exists v1,v2,v3; --enable_warnings set @subselect_extra_tmp=@@optimizer_switch; -set optimizer_switch='semijoin=on,firstmatch=on,loosescan=on'; - +set @@optimizer_switch=ifnull(@optimizer_switch_for_subselect_extra_test, + "semijoin=on,firstmatch=on,loosescan=on,semijoin_with_cache=on,partial_match_rowid_merge=off,partial_match_table_scan=off"); --echo # From explain.test: --echo # @@ -273,6 +274,122 @@ EXPLAIN SELECT 1 FROM t2 WHERE a IN (SELECT a FROM t1 USE INDEX (i2) IGNORE INDEX (i2)); DROP TABLE t1, t2; +--echo # +--echo # From derived_view.test +--echo # +set @tmp_subselect_extra_derived=@@optimizer_switch; +set optimizer_switch='derived_merge=on,derived_with_keys=on'; + +--echo # +--echo # LP bug #806504: right join over a view/derived table +--echo # + +CREATE TABLE t1 (a int, b int) ; +INSERT INTO t1 VALUES (0,0); + +CREATE TABLE t2 (a int) ; +INSERT INTO t2 VALUES (0), (0); + +CREATE VIEW v1 AS SELECT * FROM t1; + +SELECT * FROM t2 RIGHT JOIN (SELECT * FROM t1) AS t ON t.a != 0 + WHERE t.a IN (SELECT b FROM t1); +EXPLAIN EXTENDED +SELECT * FROM t2 RIGHT JOIN (SELECT * FROM t1) AS t ON t.a != 0 + WHERE t.a IN (SELECT b FROM t1); + +SELECT * FROM t2 RIGHT JOIN v1 AS t ON t.a != 0 + WHERE t.a IN (SELECT b FROM t1); +EXPLAIN EXTENDED +SELECT * FROM t2 RIGHT JOIN v1 AS t ON t.a != 0 + WHERE t.a IN (SELECT b FROM t1); + +DROP VIEW v1; +DROP TABLE t1,t2; + +--echo # +--echo # LP bug #793448: materialized view accessed by two-component key +--echo # + +CREATE TABLE t1 (a int, b int); +INSERT INTO t1 VALUES (9,3), (2,5); + +CREATE TABLE t2 (a int, b int); +INSERT INTO t2 VALUES (9,3), (3,7), (9,1), (2,5), (2,4), (3,8); + +CREATE TABLE t3 (a int, b int); +INSERT INTO t3 VALUES (10,3), (9,7), (9,1), (2,4); + +CREATE VIEW v1(a,b) AS SELECT a, MAX(b) FROM t2 GROUP BY a; +CREATE VIEW v2(a,b) AS SELECT a,b FROM t2 UNION SELECT a,b FROM t3; + +SELECT * FROM v1; +SELECT a FROM t1 WHERE (a,b) IN (SELECT * FROM v1); +EXPLAIN +SELECT a FROM t1 WHERE (a,b) IN (SELECT * FROM v1); + +SELECT * FROM v2; +SELECT a FROM t1 WHERE (a,b) IN (SELECT * FROM v2); +EXPLAIN +SELECT a FROM t1 WHERE (a,b) IN (SELECT * FROM v2); + +DROP VIEW v1,v2; +DROP TABLE t1,t2,t3; + +--echo # +--echo # LP bug #874006: materialized view used in IN subquery +--echo # + +CREATE TABLE t3 (a int NOT NULL, b varchar(1), c varchar(1)); +INSERT INTO t3 VALUES (19,NULL,NULL), (20,'r','r'); + +CREATE TABLE t1 (a int, b varchar(1) , c varchar(1)); +INSERT INTO t1 VALUES (1,NULL,NULL), (5,'r','r'), (7,'y','y'); + +CREATE TABLE t2 (a int NOT NULL , b int, c varchar(1)); +INSERT INTO t2 VALUES (4,3,'r'); + +CREATE ALGORITHM=TEMPTABLE VIEW v1 AS SELECT * FROM t1; + +SET SESSION optimizer_switch='derived_with_keys=off'; +EXPLAIN +SELECT * FROM t3 + WHERE t3.b IN (SELECT v1.b FROM v1, t2 + WHERE t2.c = v1.c AND t2.c = v1.b AND v1.b = t3.c); +SELECT * FROM t3 + WHERE t3.b IN (SELECT v1.b FROM v1, t2 + WHERE t2.c = v1.c AND t2.c = v1.b AND v1.b = t3.c); + +SET SESSION optimizer_switch='derived_with_keys=on'; +EXPLAIN +SELECT * FROM t3 + WHERE t3.b IN (SELECT v1.b FROM v1, t2 + WHERE t2.c = v1.c AND t2.c = v1.b AND v1.b = t3.c); +SELECT * FROM t3 + WHERE t3.b IN (SELECT v1.b FROM v1, t2 + WHERE t2.c = v1.c AND t2.c = v1.b AND v1.b = t3.c); + +DROP VIEW v1; +DROP TABLE t1,t2,t3; + +--echo # +--echo # LP bug #873263: materialized view used in correlated IN subquery +--echo # + +CREATE TABLE t1 (a int, b int) ; +INSERT INTO t1 VALUES (5,4), (9,8); + +CREATE TABLE t2 (a int, b int) ; +INSERT INTO t2 VALUES (4,5), (5,1); + +CREATE ALGORITHM=TEMPTABLE VIEW v2 AS SELECT * FROM t2; + +SET SESSION optimizer_switch='derived_with_keys=on'; +EXPLAIN +SELECT * FROM t1 WHERE t1.b IN (SELECT v2.a FROM v2 WHERE v2.b = t1.a); +SELECT * FROM t1 WHERE t1.b IN (SELECT v2.a FROM v2 WHERE v2.b = t1.a); -set optimizer_switch= @subselect_extra_tmp; +DROP VIEW v2; +DROP TABLE t1,t2; +set optimizer_switch= @tmp_subselect_extra_derived; diff --git a/mysql-test/t/subselect_extra_no_semijoin.test b/mysql-test/t/subselect_extra_no_semijoin.test new file mode 100644 index 00000000000..8aba3dde72b --- /dev/null +++ b/mysql-test/t/subselect_extra_no_semijoin.test @@ -0,0 +1,9 @@ +set @subselect_extra_no_sj_tmp=@@optimizer_switch; + +set @optimizer_switch_for_subselect_extra_test='semijoin=off,firstmatch=off,loosescan=off,semijoin_with_cache=off'; + +--source t/subselect_extra.test + +set optimizer_switch= @subselect_extra_no_sj_tmp; + +set @optimizer_switch_for_subselect_extra_test=null;
\ No newline at end of file diff --git a/mysql-test/t/subselect_innodb.test b/mysql-test/t/subselect_innodb.test index 3e2914eaef4..27ec36854f4 100644 --- a/mysql-test/t/subselect_innodb.test +++ b/mysql-test/t/subselect_innodb.test @@ -1,5 +1,7 @@ -- source include/have_innodb.inc +# Note: the tests uses only non-semijoin subqueries so semi-join switch +# settings are not relevant. set @subselect_innodb_tmp=@@optimizer_switch; set optimizer_switch='mrr=on,mrr_sort_keys=on,index_condition_pushdown=on'; --disable_warnings @@ -250,5 +252,61 @@ INSERT INTO t1 VALUES ('2011-05-13', 0); SELECT * FROM t1 WHERE b < (SELECT CAST(a as date) FROM t1 GROUP BY a); DROP TABLE t1; -# Cleanups +--echo # +--echo # lp:827416 Crash in select_describe() on EXPLAIN with DISTINCT in nested subqueries +--echo # + +CREATE TABLE t3 ( b int) ENGINE=InnoDB; +CREATE TABLE t2 ( c int) ENGINE=InnoDB; +CREATE TABLE t1 ( a int NOT NULL , PRIMARY KEY (a)) ENGINE=InnoDB; + +EXPLAIN SELECT * +FROM t1 +WHERE t1.a = ( + SELECT SUM( c ) + FROM t2 + WHERE (SELECT DISTINCT b FROM t3) > 0); +SELECT * +FROM t1 +WHERE t1.a = ( + SELECT SUM( c ) + FROM t2 + WHERE (SELECT DISTINCT b FROM t3) > 0); + +DROP TABLE t1, t2, t3; + + +--echo # +--echo # lp:858148 Fourth crash in select_describe() with nested subqueries +--echo # + +CREATE TABLE t1 ( f1 int(11)) ENGINE=InnoDB; +CREATE TABLE t2 ( f1 int(11), f2 int(11), PRIMARY KEY (f1)) ; +CREATE TABLE t3 ( f3 int(11)) ENGINE=InnoDB; + +EXPLAIN +SELECT MAX( f1 ) FROM t2 +WHERE f2 >= ( + SELECT SUM( f1 ) + FROM t1 + WHERE EXISTS ( + SELECT f3 + FROM t3 + GROUP BY 1 + ) +); + +SELECT MAX( f1 ) FROM t2 +WHERE f2 >= ( + SELECT SUM( f1 ) + FROM t1 + WHERE EXISTS ( + SELECT f3 + FROM t3 + GROUP BY 1 + ) +); + +drop table t1, t2, t3; + set optimizer_switch=@subselect_innodb_tmp; diff --git a/mysql-test/t/subselect_mat.test b/mysql-test/t/subselect_mat.test index a70fb4783c5..09c6b3e1747 100644 --- a/mysql-test/t/subselect_mat.test +++ b/mysql-test/t/subselect_mat.test @@ -226,3 +226,31 @@ SELECT MAX(t1.b) AS max_res FROM t1 WHERE (9) IN (SELECT a FROM t2); DROP TABLE t1,t2; +--echo # +--echo # LPBUG#825095: Wrong result with materialization and NOT IN with 2 expressions +--echo # + +CREATE TABLE t1 (a int,b int); +INSERT INTO t1 VALUES (4,4),(4,2); + +CREATE TABLE t2 (b int, a int); +INSERT INTO t2 VALUES (4,3),(8,4); + +set @@optimizer_switch='semijoin=off,in_to_exists=off,materialization=on,partial_match_rowid_merge=on,partial_match_table_scan=off'; + +EXPLAIN SELECT * +FROM t1 +WHERE (a, b) NOT IN (SELECT a, b FROM t2); + +SELECT * +FROM t1 +WHERE (a, b) NOT IN (SELECT a, b FROM t2); + +EXPLAIN +SELECT a, b, (a, b) NOT IN (SELECT a, b FROM t2) as sq +FROM t1; + +SELECT a, b, (a, b) NOT IN (SELECT a, b FROM t2) as sq +FROM t1; + +drop table t1, t2; diff --git a/mysql-test/t/subselect_mat_cost-master.opt b/mysql-test/t/subselect_mat_cost-master.opt new file mode 100644 index 00000000000..dc7ac6cc205 --- /dev/null +++ b/mysql-test/t/subselect_mat_cost-master.opt @@ -0,0 +1 @@ +--log-output=TABLE,FILE --log --log-slow-queries --slow-query-log=1 diff --git a/mysql-test/t/subselect_mat_cost.test b/mysql-test/t/subselect_mat_cost.test index 8a0d1ac702d..5a1fb550ca4 100644 --- a/mysql-test/t/subselect_mat_cost.test +++ b/mysql-test/t/subselect_mat_cost.test @@ -15,6 +15,11 @@ set @subselect_mat_cost=@@optimizer_switch; set optimizer_switch='mrr=on,mrr_sort_keys=on,index_condition_pushdown=on'; +# +# Test logging to slow log (there was some errors in the log files about +# the slow log when running under valgrind, so better to get this tested) +# +set long_query_time=0.1; -- echo TEST GROUP 1: @@ -222,13 +227,15 @@ select count(*) from CountryLanguage where (Language, Country) NOT IN (SELECT City.Name, Country.Code - FROM City LEFT JOIN Country ON (Country = Code and City.Population < 10000)); + FROM City LEFT JOIN Country ON (Country = Code and City.Population < 10000)) + AND Language IN ('English','Spanish'); select count(*) from CountryLanguage where (Language, Country) NOT IN (SELECT City.Name, Country.Code - FROM City LEFT JOIN Country ON (Country = Code and City.Population < 10000)); + FROM City LEFT JOIN Country ON (Country = Code and City.Population < 10000)) + AND Language IN ('English','Spanish'); -- echo Q2.3m: -- echo MATERIALIZATION with the PARTIAL_MATCH_MERGE strategy, because the HAVING diff --git a/mysql-test/t/subselect_mat_cost_bugs.test b/mysql-test/t/subselect_mat_cost_bugs.test index 37c7b617760..2e5dd71f9af 100644 --- a/mysql-test/t/subselect_mat_cost_bugs.test +++ b/mysql-test/t/subselect_mat_cost_bugs.test @@ -89,6 +89,12 @@ CREATE TABLE t1 ( INSERT INTO t1 VALUES (10,7,8,'v','v'); INSERT INTO t1 VALUES (11,1,9,'r','r'); INSERT INTO t1 VALUES (12,5,9,'a','a'); +INSERT INTO t1 VALUES (13,7,18,'v','v'); +INSERT INTO t1 VALUES (14,1,19,'r','r'); +INSERT INTO t1 VALUES (15,5,29,'a','a'); +INSERT INTO t1 VALUES (17,7,38,'v','v'); +INSERT INTO t1 VALUES (18,1,39,'r','r'); +INSERT INTO t1 VALUES (19,5,49,'a','a'); create table t1a like t1; insert into t1a select * from t1; @@ -348,4 +354,63 @@ SELECT * FROM t1 WHERE (f1) IN (SELECT f1 FROM t2) LIMIT 0; +set @@optimizer_switch='default'; +drop table t1, t2; + +--echo # +--echo # LP BUG#834492: Crash in fix_semijoin_strategies_for_picked_join_order +--echo # with nested subqueries and LooseScan=ON +--echo # + +CREATE TABLE t3 (b int) ; +INSERT INTO t3 VALUES (0),(0); + +CREATE TABLE t4 (a int, b int, c int, d int, PRIMARY KEY (a)) ; +INSERT INTO t4 VALUES (28,0,0,0),(29,3,0,0); + +CREATE TABLE t5 (a int, b int, c int, d int, KEY (c,b)) ; +INSERT INTO t5 VALUES (28,0,0,0),(29,3,0,0); + +SET @@optimizer_switch='semijoin=ON,loosescan=ON,firstmatch=OFF,materialization=OFF'; + +EXPLAIN SELECT * +FROM t3 +WHERE t3.b > ALL ( + SELECT c + FROM t4 + WHERE t4.a >= t3.b + AND a = SOME (SELECT b FROM t5)); + +SELECT * +FROM t3 +WHERE t3.b > ALL ( + SELECT c + FROM t4 + WHERE t4.a >= t3.b + AND a = SOME (SELECT b FROM t5)); + +set @@optimizer_switch='default'; +drop table t3, t4, t5; + +--echo # +--echo # LP BUG#858038 The result of a query with NOT IN subquery depends on the state of the optimizer switch +--echo # + +create table t1 (c1 char(2) not null, c2 char(2)); +create table t2 (c3 char(2), c4 char(2)); + +insert into t1 values ('a1', 'b1'); +insert into t1 values ('a2', 'b2'); + +insert into t2 values ('x1', 'y1'); +insert into t2 values ('a2', null); + +set @@optimizer_switch='in_to_exists=off,materialization=on,partial_match_rowid_merge=off,partial_match_table_scan=on'; +explain select * from t1 where c1 = 'a2' and (c1, c2) not in (select * from t2); +select * from t1 where c1 = 'a2' and (c1, c2) not in (select * from t2); + +set @@optimizer_switch='in_to_exists=off,materialization=on,partial_match_rowid_merge=on,partial_match_table_scan=off'; +explain select * from t1 where c1 = 'a2' and (c1, c2) not in (select * from t2); +select * from t1 where c1 = 'a2' and (c1, c2) not in (select * from t2); + drop table t1, t2; diff --git a/mysql-test/t/subselect_no_opts.test b/mysql-test/t/subselect_no_opts.test index 005b2f041fa..724cbab6310 100644 --- a/mysql-test/t/subselect_no_opts.test +++ b/mysql-test/t/subselect_no_opts.test @@ -3,7 +3,7 @@ # (test in-to-exists) -set @optimizer_switch_for_subselect_test='materialization=off,semijoin=off,mrr=on,mrr_sort_keys=on,index_condition_pushdown=on'; +set @optimizer_switch_for_subselect_test='materialization=off,semijoin=off,subquery_cache=off,mrr=on,mrr_sort_keys=on,index_condition_pushdown=on'; --source t/subselect.test set @optimizer_switch_for_subselect_test=null; diff --git a/mysql-test/t/subselect_scache.test b/mysql-test/t/subselect_no_scache.test index 0032b148643..fe8ff749a59 100644 --- a/mysql-test/t/subselect_scache.test +++ b/mysql-test/t/subselect_no_scache.test @@ -2,7 +2,7 @@ # Run subselect.test without semi-join optimization (test materialize) # select @@optimizer_switch like '%subquery_cache=on%'; -set optimizer_switch='subquery_cache=on'; +set optimizer_switch='subquery_cache=off'; --source t/subselect.test diff --git a/mysql-test/t/subselect_nulls.test b/mysql-test/t/subselect_nulls.test index 6de7820872c..4b08e773b17 100644 --- a/mysql-test/t/subselect_nulls.test +++ b/mysql-test/t/subselect_nulls.test @@ -5,6 +5,9 @@ drop table if exists x1; drop table if exists x2; --enable_warnings +set @tmp_subselect_nulls=@@optimizer_switch; +set optimizer_switch='semijoin=off'; + create table x1(k int primary key, d1 int, d2 int); create table x2(k int primary key, d1 int, d2 int); @@ -90,5 +93,7 @@ where exists (select * from x2 where x1.d1=x2.d1 and x1.d2=x2.d2); +set optimizer_switch= @tmp_subselect_nulls; + drop table x1; drop table x2; diff --git a/mysql-test/t/subselect_partial_match.test b/mysql-test/t/subselect_partial_match.test index 8d1fbd9b8d7..be78360c76b 100644 --- a/mysql-test/t/subselect_partial_match.test +++ b/mysql-test/t/subselect_partial_match.test @@ -10,12 +10,14 @@ set @save_optimizer_switch=@@optimizer_switch; --echo ------------------------------- --echo Default for all tests. -set @@optimizer_switch="materialization=on,in_to_exists=off,semijoin=off,subquery_cache=off"; +set @@optimizer_switch = "materialization=on,in_to_exists=off,semijoin=off,subquery_cache=off"; +set @test_default_opt_switch = @@optimizer_switch; +set @in_exists = "materialization=off,in_to_exists=on,semijoin=off,subquery_cache=off"; ---echo +--echo ------------------------------------------------------------------------- --echo Schema requires partial matching, but data analysis discoveres there is --echo no need. This is possible only if all outer columns are not NULL. ---echo +--echo ------------------------------------------------------------------------- create table t1 (a1 char(8) not null, a2 char(8) not null); create table t2 (b1 char(8), b2 char(8)); @@ -36,9 +38,9 @@ select a1, a2, (a1, a2) not in (select * from t2) as in_res from t1; drop table t1, t2; ---echo +--echo ------------------------------------------------------------------------- --echo NULLs in the outer columns, no NULLs in the suqbuery ---echo +--echo ------------------------------------------------------------------------- create table t1 (a1 char(8), a2 char(8)); create table t2 (b1 char(8) not null, b2 char(8) not null); @@ -63,21 +65,366 @@ select a1, a2, (a1, a2) in (select * from t2) as in_res from t1; drop table t1, t2; ---echo +--echo ------------------------------------------------------------------------- +--echo NULLs in the outer column, NULLs in the subquery, there is +--echo no value match in any column, but there is a partial match +--echo such that some of the matching NULLs are in the outer columns, +--echo the other NULLs are in the inner columns. +--echo ------------------------------------------------------------------------- + +create table t1 (a1 char(1), a2 char(1), a3 char(1)); +create table t2 (b1 char(1), b2 char(1), b3 char(1)); + +insert into t1 values ('c', NULL, 'a'); +insert into t2 values (NULL, 'x', NULL); +insert into t2 values (NULL, 'y', NULL); +insert into t2 values ('o', 'z', 'p'); + +set @@optimizer_switch='partial_match_rowid_merge=on,partial_match_table_scan=off'; +EXPLAIN +SELECT t1.*, (a1, a2, a3) IN (select * from t2) as in_res from t1; +SELECT t1.*, (a1, a2, a3) IN (select * from t2) as in_res from t1; +EXPLAIN +SELECT * from t1 where (a1, a2, a3) NOT IN (select * from t2); +SELECT * from t1 where (a1, a2, a3) NOT IN (select * from t2); + +set @@optimizer_switch='partial_match_rowid_merge=off,partial_match_table_scan=on'; +EXPLAIN +SELECT t1.*, (a1, a2, a3) IN (select * from t2) as in_res from t1; +SELECT t1.*, (a1, a2, a3) IN (select * from t2) as in_res from t1; +EXPLAIN +SELECT * from t1 where (a1, a2, a3) NOT IN (select * from t2); +SELECT * from t1 where (a1, a2, a3) NOT IN (select * from t2); + +set @@optimizer_switch=@in_exists; +EXPLAIN +SELECT t1.*, (a1, a2, a3) IN (select * from t2) as in_res from t1; +SELECT t1.*, (a1, a2, a3) IN (select * from t2) as in_res from t1; +EXPLAIN +SELECT * from t1 where (a1, a2, a3) NOT IN (select * from t2); +SELECT * from t1 where (a1, a2, a3) NOT IN (select * from t2); + +set @@optimizer_switch = @test_default_opt_switch; + +drop table t1, t2; + +create table t1 (a1 char(1), a2 char(1) not null, a3 char(1)); +create table t2 (b1 char(1), b2 char(1), b3 char(1)); + +insert into t1 values (NULL, 'y', NULL); +insert into t2 values ('v', 'x', NULL); +insert into t2 values (NULL, 'y', 'w'); + +set @@optimizer_switch='partial_match_rowid_merge=on,partial_match_table_scan=off'; +EXPLAIN +SELECT t1.*, (a1, a2, a3) IN (select * from t2) as in_res from t1; +SELECT t1.*, (a1, a2, a3) IN (select * from t2) as in_res from t1; +EXPLAIN +SELECT * from t1 where (a1, a2, a3) NOT IN (select * from t2); +SELECT * from t1 where (a1, a2, a3) NOT IN (select * from t2); + +set @@optimizer_switch='partial_match_rowid_merge=off,partial_match_table_scan=on'; +EXPLAIN +SELECT t1.*, (a1, a2, a3) IN (select * from t2) as in_res from t1; +SELECT t1.*, (a1, a2, a3) IN (select * from t2) as in_res from t1; +EXPLAIN +SELECT * from t1 where (a1, a2, a3) NOT IN (select * from t2); +SELECT * from t1 where (a1, a2, a3) NOT IN (select * from t2); + +set @@optimizer_switch=@in_exists; +EXPLAIN +SELECT t1.*, (a1, a2, a3) IN (select * from t2) as in_res from t1; +SELECT t1.*, (a1, a2, a3) IN (select * from t2) as in_res from t1; +EXPLAIN +SELECT * from t1 where (a1, a2, a3) NOT IN (select * from t2); +SELECT * from t1 where (a1, a2, a3) NOT IN (select * from t2); + +set @@optimizer_switch = @test_default_opt_switch; + +drop table t1, t2; + +--echo ------------------------------------------------------------------------- +--echo There is only one column in the subquery to complement the NULLs in the +--echo outer reference. It is a NULL column, so a match is guaranteed. +--echo ------------------------------------------------------------------------- + +create table t1 (a1 char(1), a2 char(1), a3 char(1)); +create table t2 (b1 char(1), b2 char(1), b3 char(1)); + +insert into t1 values (NULL, 'g', NULL); +insert into t2 values ('z', NULL, 'y'); +insert into t2 values (NULL, 'z', 'y'); + +set @@optimizer_switch='partial_match_rowid_merge=on,partial_match_table_scan=off'; +EXPLAIN +SELECT t1.*, (a1, a2, a3) IN (select * from t2) as in_res from t1; +SELECT t1.*, (a1, a2, a3) IN (select * from t2) as in_res from t1; +EXPLAIN +SELECT * from t1 where (a1, a2, a3) NOT IN (select * from t2); +SELECT * from t1 where (a1, a2, a3) NOT IN (select * from t2); + +set @@optimizer_switch='partial_match_rowid_merge=off,partial_match_table_scan=on'; +EXPLAIN +SELECT t1.*, (a1, a2, a3) IN (select * from t2) as in_res from t1; +SELECT t1.*, (a1, a2, a3) IN (select * from t2) as in_res from t1; +EXPLAIN +SELECT * from t1 where (a1, a2, a3) NOT IN (select * from t2); +SELECT * from t1 where (a1, a2, a3) NOT IN (select * from t2); + +set @@optimizer_switch=@in_exists; +EXPLAIN +SELECT t1.*, (a1, a2, a3) IN (select * from t2) as in_res from t1; +SELECT t1.*, (a1, a2, a3) IN (select * from t2) as in_res from t1; +EXPLAIN +SELECT * from t1 where (a1, a2, a3) NOT IN (select * from t2); +SELECT * from t1 where (a1, a2, a3) NOT IN (select * from t2); + +set @@optimizer_switch = @test_default_opt_switch; + +drop table t1, t2; + +--echo ------------------------------------------------------------------------- +--echo The intersection of the NULL bitmaps is empty because the ranges +--echo of NULL bits do not overlap. +--echo ------------------------------------------------------------------------- + +create table t1 (a1 char(1), a2 char(1), a3 char(1)); +create table t2 (b1 char(1), b2 char(1), b3 char(1)); + +insert into t1 values ('b', 'g', NULL); +insert into t2 values ('z', NULL, 'y'); +insert into t2 values (NULL, 'z', 'y'); + +set @@optimizer_switch='partial_match_rowid_merge=on,partial_match_table_scan=off'; +EXPLAIN +SELECT t1.*, (a1, a2, a3) IN (select * from t2) as in_res from t1; +SELECT t1.*, (a1, a2, a3) IN (select * from t2) as in_res from t1; +EXPLAIN +SELECT * from t1 where (a1, a2, a3) NOT IN (select * from t2); +SELECT * from t1 where (a1, a2, a3) NOT IN (select * from t2); + +set @@optimizer_switch='partial_match_rowid_merge=off,partial_match_table_scan=on'; +EXPLAIN +SELECT t1.*, (a1, a2, a3) IN (select * from t2) as in_res from t1; +SELECT t1.*, (a1, a2, a3) IN (select * from t2) as in_res from t1; +EXPLAIN +SELECT * from t1 where (a1, a2, a3) NOT IN (select * from t2); +SELECT * from t1 where (a1, a2, a3) NOT IN (select * from t2); + +set @@optimizer_switch=@in_exists; +EXPLAIN +SELECT t1.*, (a1, a2, a3) IN (select * from t2) as in_res from t1; +SELECT t1.*, (a1, a2, a3) IN (select * from t2) as in_res from t1; +EXPLAIN +SELECT * from t1 where (a1, a2, a3) NOT IN (select * from t2); +SELECT * from t1 where (a1, a2, a3) NOT IN (select * from t2); + +drop table t1, t2; + +--echo ------------------------------------------------------------------------- +--echo The intersection of the NULL bitmaps is non-empty, and there is a +--echo non-NULL column. +--echo ------------------------------------------------------------------------- + +create table t1 (a1 char(1), a2 char(1), a3 char(1) not null, a4 char(10)); +create table t2 (b1 char(1), b2 char(1), b3 char(1), b4 char(1)); + +insert into t1 values ('a', 'g', 'x', NULL); +insert into t2 values ('z', NULL, 'y', 'x'); +insert into t2 values (NULL, NULL, 'x', 'y'); +insert into t2 values ('x', 'w', 'z', NULL); + +set @@optimizer_switch='partial_match_rowid_merge=on,partial_match_table_scan=off'; +EXPLAIN +SELECT t1.*, (a1, a2, a3, a4) IN (select * from t2) as in_res from t1; +SELECT t1.*, (a1, a2, a3, a4) IN (select * from t2) as in_res from t1; +EXPLAIN +SELECT * from t1 where (a1, a2, a3, a4) NOT IN (select * from t2); +SELECT * from t1 where (a1, a2, a3, a4) NOT IN (select * from t2); + +set @@optimizer_switch='partial_match_rowid_merge=off,partial_match_table_scan=on'; +EXPLAIN +SELECT t1.*, (a1, a2, a3, a4) IN (select * from t2) as in_res from t1; +SELECT t1.*, (a1, a2, a3, a4) IN (select * from t2) as in_res from t1; +EXPLAIN +SELECT * from t1 where (a1, a2, a3, a4) NOT IN (select * from t2); +SELECT * from t1 where (a1, a2, a3, a4) NOT IN (select * from t2); + +set @@optimizer_switch=@in_exists; +EXPLAIN +SELECT t1.*, (a1, a2, a3, a4) IN (select * from t2) as in_res from t1; +SELECT t1.*, (a1, a2, a3, a4) IN (select * from t2) as in_res from t1; +EXPLAIN +SELECT * from t1 where (a1, a2, a3, a4) NOT IN (select * from t2); +SELECT * from t1 where (a1, a2, a3, a4) NOT IN (select * from t2); + +drop table t1, t2; + +--echo ------------------------------------------------------------------------- +--echo Value match in one row, but the NULL complement match in another. +--echo The result must be false. +--echo ------------------------------------------------------------------------- + +create table t1 (a1 char(2), a2 char(1), a3 char(1) not null, a4 char(10)); +create table t2 (b1 char(2), b2 char(1), b3 char(1), b4 char(1)); + +insert into t1 values ('99', NULL, 'j', 'f'); + +insert into t2 values ('01', NULL, 'y', NULL); +insert into t2 values ('02', NULL, 'x', 'y'); +insert into t2 values ('03', 'q', 'y', 'x'); +insert into t2 values (NULL, 'q', 'm', 'p'); +insert into t2 values ('m', 'z', 'j', NULL); +insert into t2 values (NULL, 'z', 'b', NULL); +insert into t2 values (NULL, 'z', 'a', NULL); +insert into t2 values ('34', 'q', 'y', 'x'); + +set @@optimizer_switch='partial_match_rowid_merge=on,partial_match_table_scan=off'; +EXPLAIN +SELECT t1.*, (a1, a2, a3, a4) IN (select * from t2) as in_res from t1; +SELECT t1.*, (a1, a2, a3, a4) IN (select * from t2) as in_res from t1; +EXPLAIN +SELECT * from t1 where (a1, a2, a3, a4) NOT IN (select * from t2); +SELECT * from t1 where (a1, a2, a3, a4) NOT IN (select * from t2); + +set @@optimizer_switch='partial_match_rowid_merge=off,partial_match_table_scan=on'; +EXPLAIN +SELECT t1.*, (a1, a2, a3, a4) IN (select * from t2) as in_res from t1; +SELECT t1.*, (a1, a2, a3, a4) IN (select * from t2) as in_res from t1; +EXPLAIN +SELECT * from t1 where (a1, a2, a3, a4) NOT IN (select * from t2); +SELECT * from t1 where (a1, a2, a3, a4) NOT IN (select * from t2); + +set @@optimizer_switch=@in_exists; +EXPLAIN +SELECT t1.*, (a1, a2, a3, a4) IN (select * from t2) as in_res from t1; +SELECT t1.*, (a1, a2, a3, a4) IN (select * from t2) as in_res from t1; +EXPLAIN +SELECT * from t1 where (a1, a2, a3, a4) NOT IN (select * from t2); +SELECT * from t1 where (a1, a2, a3, a4) NOT IN (select * from t2); + +drop table t1, t2; + +--echo ------------------------------------------------------------------------- +--echo Test the intersection of larger number of rows with NULL, such that +--echo the number is at the boundary 32. This test is based on the implementation +--echo of MY_BITMAP which uses 32 bit words, and the intersection operation works +--echo by intersecting the bitmap word by word. +--echo ------------------------------------------------------------------------- + +create table t1 (a1 char(2), a2 char(2), a3 char(1), a4 char(10)) ENGINE=MyISAM; +create table t2 (b1 char(2), b2 char(2), b3 char(1), b4 char(1)) ENGINE=MyISAM; + +insert into t1 values (NULL, '98', NULL, 'b'); +insert into t1 values (NULL, '99', NULL, 'c'); + +insert into t2 values ('00', 'rr', 'y', NULL); +insert into t2 values ('01', 'rr', 'y', NULL); +insert into t2 values ('02', NULL, 'x', 'y'); +insert into t2 values ('03', 'qq', 'y', 'x'); +insert into t2 values ('04', 'qq', 'm', 'p'); +insert into t2 values ('05', 'rr', 'y', NULL); +insert into t2 values ('06', NULL, 'x', 'y'); +insert into t2 values ('07', 'qq', 'y', 'x'); +insert into t2 values ('08', 'qq', 'm', 'q'); +insert into t2 values ('09', 'rr', 'y', NULL); +insert into t2 values ('10', NULL, 'x', 'y'); +insert into t2 values ('11', 'qq', 'y', 'x'); +insert into t2 values ('12', 'qq', 'm', 'k'); +insert into t2 values ('13', 'rr', 'y', NULL); +insert into t2 values ('14', NULL, 'x', 'y'); +insert into t2 values ('15', 'qq', 'y', 'x'); +insert into t2 values ('16', 'qq', 'm', 's'); +insert into t2 values ('17', 'rr', 'y', NULL); +insert into t2 values ('18', NULL, 'x', 'y'); +insert into t2 values ('19', 'qq', 'y', 'x'); +insert into t2 values ('20', 'qq', 'm', 't'); +insert into t2 values ('21', 'rr', 'y', NULL); +insert into t2 values ('22', NULL, 'x', 'y'); +insert into t2 values ('23', 'qq', 'y', 'x'); +insert into t2 values ('24', 'qq', 'm', 'u'); +insert into t2 values ('25', 'rr', 'y', NULL); +insert into t2 values ('26', NULL, 'x', 'y'); +insert into t2 values ('27', 'qq', 'y', 'x'); +insert into t2 values ('28', 'qq', 'm', 'y'); +insert into t2 values ('29', 'rr', 'y', NULL); +insert into t2 values ('30', NULL, 'x', 'z'); +insert into t2 values ('31', 'ss', 'h', NULL); +insert into t2 values ('32', 'vv', 'i', NULL); +--echo the only partial matching row +insert into t2 values ('33', NULL, 'j', NULL); +insert into t2 values ('34', 'qq', 'y', 'x'); + +set @@optimizer_switch='partial_match_rowid_merge=on,partial_match_table_scan=off'; +EXPLAIN +SELECT t1.*, (a1, a2, a3, a4) IN (select * from t2) as in_res from t1; +SELECT t1.*, (a1, a2, a3, a4) IN (select * from t2) as in_res from t1; +EXPLAIN +SELECT * from t1 where (a1, a2, a3, a4) NOT IN (select * from t2); +SELECT * from t1 where (a1, a2, a3, a4) NOT IN (select * from t2); + +set @@optimizer_switch='partial_match_rowid_merge=off,partial_match_table_scan=on'; +EXPLAIN +SELECT t1.*, (a1, a2, a3, a4) IN (select * from t2) as in_res from t1; +SELECT t1.*, (a1, a2, a3, a4) IN (select * from t2) as in_res from t1; +EXPLAIN +SELECT * from t1 where (a1, a2, a3, a4) NOT IN (select * from t2); +SELECT * from t1 where (a1, a2, a3, a4) NOT IN (select * from t2); + +set @@optimizer_switch=@in_exists; +EXPLAIN +SELECT t1.*, (a1, a2, a3, a4) IN (select * from t2) as in_res from t1; +SELECT t1.*, (a1, a2, a3, a4) IN (select * from t2) as in_res from t1; +EXPLAIN +SELECT * from t1 where (a1, a2, a3, a4) NOT IN (select * from t2); +SELECT * from t1 where (a1, a2, a3, a4) NOT IN (select * from t2); + +--echo change the mathcing row to be the last one in the first bitmap word +update t2 set b2 = 'zz' where b1 = 33; +update t2 set b2 = NULL where b1 = 31; + +set @@optimizer_switch='partial_match_rowid_merge=on,partial_match_table_scan=off'; +EXPLAIN +SELECT t1.*, (a1, a2, a3, a4) IN (select * from t2) as in_res from t1; +SELECT t1.*, (a1, a2, a3, a4) IN (select * from t2) as in_res from t1; +EXPLAIN +SELECT * from t1 where (a1, a2, a3, a4) NOT IN (select * from t2); +SELECT * from t1 where (a1, a2, a3, a4) NOT IN (select * from t2); + +set @@optimizer_switch='partial_match_rowid_merge=off,partial_match_table_scan=on'; +EXPLAIN +SELECT t1.*, (a1, a2, a3, a4) IN (select * from t2) as in_res from t1; +SELECT t1.*, (a1, a2, a3, a4) IN (select * from t2) as in_res from t1; +EXPLAIN +SELECT * from t1 where (a1, a2, a3, a4) NOT IN (select * from t2); +SELECT * from t1 where (a1, a2, a3, a4) NOT IN (select * from t2); + +set @@optimizer_switch=@in_exists; +EXPLAIN +SELECT t1.*, (a1, a2, a3, a4) IN (select * from t2) as in_res from t1; +SELECT t1.*, (a1, a2, a3, a4) IN (select * from t2) as in_res from t1; +EXPLAIN +SELECT * from t1 where (a1, a2, a3, a4) NOT IN (select * from t2); +SELECT * from t1 where (a1, a2, a3, a4) NOT IN (select * from t2); + +drop table t1, t2; + + +--echo ------------------------------------------------------------------------- --echo All columns require partial matching (no non-null columns) ---echo +--echo ------------------------------------------------------------------------- --echo TODO ---echo +--echo ------------------------------------------------------------------------- --echo Both non-NULL columns and columns with NULLs ---echo +--echo ------------------------------------------------------------------------- --echo TODO ---echo +--echo ------------------------------------------------------------------------- --echo Covering NULL rows ---echo +--echo ------------------------------------------------------------------------- create table t1 (a1 char(8), a2 char(8)); create table t2 (b1 char(8), b2 char(8)); @@ -110,9 +457,9 @@ select a1, a2, (a1, a2) in (select * from t2) as in_res from t1; drop table t1, t2; ---echo +--echo ------------------------------------------------------------------------- --echo Covering NULL columns ---echo +--echo ------------------------------------------------------------------------- --echo this case affects only the rowid-merge algorithm set @@optimizer_switch="partial_match_rowid_merge=on,partial_match_table_scan=off"; @@ -161,9 +508,9 @@ select *, (a1, a2, a3) in (select * from t2) as in_res from t1; drop table t1, t2; ---echo +--echo ------------------------------------------------------------------------- --echo Covering NULL row, and a NULL column ---echo +--echo ------------------------------------------------------------------------- create table t1 (a1 char(8) not null, a2 char(8), a3 char(8)); create table t2 (b1 char(8), b2 char(8), b3 char(8)); @@ -188,9 +535,9 @@ select *, (a1, a2, a3) in (select * from t2) as in_res from t1; drop table t1, t2; ---echo +--echo ------------------------------------------------------------------------- --echo Covering NULL row, and covering NULL columns ---echo +--echo ------------------------------------------------------------------------- create table t1 (a1 char(8) not null, a2 char(8), a3 char(8)); create table t2 (b1 char(8), b2 char(8), b3 char(8)); @@ -213,6 +560,34 @@ select *, (a1, a2, a3) in (select * from t2) as in_res from t1; drop table t1, t2; +--echo ------------------------------------------------------------------------- +--echo Small buffer for the rowid_merge partial match algorithm that forces +--echo reverting to table scan partial match. +--echo ------------------------------------------------------------------------- + +set @save_rowid_merge_buff_size = @@rowid_merge_buff_size; +set @@rowid_merge_buff_size = 0; + +create table t1 (a1 char(2), a2 char(2), a3 char(1), a4 char(10)); +create table t2 (b1 char(2), b2 char(2), b3 char(1), b4 char(1)); + +insert into t1 values (NULL, '98', NULL, 'b'); +insert into t1 values (NULL, '99', NULL, 'c'); + +insert into t2 values ('00', 'rr', 'y', NULL); +insert into t2 values ('01', 'rr', 'y', NULL); +insert into t2 values ('02', NULL, 'x', 'y'); +insert into t2 values ('03', 'qq', 'y', 'x'); + +set @@optimizer_switch='partial_match_rowid_merge=on,partial_match_table_scan=off'; +EXPLAIN +SELECT t1.*, (a1, a2, a3, a4) IN (select * from t2) as in_res from t1; +SELECT t1.*, (a1, a2, a3, a4) IN (select * from t2) as in_res from t1; + +drop table t1, t2; + +set @@rowid_merge_buff_size = @save_rowid_merge_buff_size; + --echo ------------------------------- --echo Part 2: Test cases for bugs. @@ -354,4 +729,50 @@ SELECT * FROM t1 WHERE (6, 4 ) NOT IN (SELECT a, b FROM t2); drop table t1, t2; +--echo # +--echo # LP BUG#856152 Wrong result with NOT IN subquery and partial_match_rowid_merge +--echo # + +CREATE TABLE t1 ( f1 integer NOT NULL , f2 integer) ; +INSERT INTO t1 VALUES (3,3),(48,NULL),(49,1); + +CREATE TABLE t2 ( f3 int) ; +INSERT INTO t2 VALUES (5); + +set @@optimizer_switch='in_to_exists=off,materialization=on,partial_match_rowid_merge=on,partial_match_table_scan=off'; +EXPLAIN SELECT * FROM t2 WHERE ( 3 , 1 ) NOT IN ( SELECT f1 , f2 FROM t1 ); +SELECT * FROM t2 WHERE ( 3 , 1 ) NOT IN ( SELECT f1 , f2 FROM t1 ); + +set @@optimizer_switch='in_to_exists=on,materialization=off'; +EXPLAIN SELECT * FROM t2 WHERE ( 3 , 1 ) NOT IN ( SELECT f1 , f2 FROM t1 ); +SELECT * FROM t2 WHERE ( 3 , 1 ) NOT IN ( SELECT f1 , f2 FROM t1 ); + +drop table t1, t2; + +--echo # +--echo # LP BUG#869036 Wrong result with in_to_exists=ON and NOT IN +--echo # + +create table outer_sq (f1 char(1), f2 char(1)); +insert into outer_sq values (NULL, 'c'), ('g', 'c'); + +create table inner_sq (f3 char(1), f4 char(1)); +insert into inner_sq values(null, 'i'), ('v', null); + +--echo All three strategies below must produce the same result. + +set @@optimizer_switch='in_to_exists=off,materialization=on,partial_match_rowid_merge=on,partial_match_table_scan=off'; +SELECT outer_sq.*, (f1, f2) IN (select * from inner_sq) from outer_sq; +SELECT * from outer_sq where (f1, f2) NOT IN (select * from inner_sq); + +set @@optimizer_switch='in_to_exists=off,materialization=on,partial_match_rowid_merge=off,partial_match_table_scan=on'; +SELECT outer_sq.*, (f1, f2) IN (select * from inner_sq) from outer_sq; +SELECT * from outer_sq where (f1, f2) NOT IN (select * from inner_sq); + +set @@optimizer_switch='in_to_exists=on,materialization=off'; +SELECT outer_sq.*, (f1, f2) IN (select * from inner_sq) from outer_sq; +SELECT * from outer_sq where (f1, f2) NOT IN (select * from inner_sq); + +drop table outer_sq, inner_sq; + set @@optimizer_switch=@save_optimizer_switch; diff --git a/mysql-test/t/subselect_sj.test b/mysql-test/t/subselect_sj.test index 66c7b1bc549..740289ffcc8 100644 --- a/mysql-test/t/subselect_sj.test +++ b/mysql-test/t/subselect_sj.test @@ -2,7 +2,7 @@ # Nested Loops semi-join subquery evaluation tests # --disable_warnings -drop table if exists t0, t1, t2, t3, t4, t10, t11, t12; +drop table if exists t0, t1, t2, t3, t4, t5, t10, t11, t12; drop view if exists v1, v2, v3, v4; drop procedure if exists p1; --enable_warnings @@ -776,6 +776,7 @@ eval EXPLAIN EXTENDED $query; eval $query; DROP TABLE t1, t2; + --echo # End of Bug#48213 --echo # @@ -1571,5 +1572,313 @@ SELECT * FROM t1 WHERE c1 IN ( SELECT t3.c1 FROM t3 LEFT JOIN t2 ON t2 .c1 = t3 DROP TABLE t1, t2, t3; +--echo # +--echo # BUG#834534: Assertion `0' failed in replace_where_subcondition with semijoin subquery in HAVING +--echo # +CREATE TABLE t1 ( d int ); +INSERT INTO t1 VALUES (2),(2),(0),(2),(2); + +CREATE TABLE t2 ( b int ); +INSERT INTO t2 VALUES (4),(3),(3); + +CREATE TABLE t3 ( a int ); + +SELECT * +FROM t3 +WHERE (t3.a) IN ( + SELECT t1.d + FROM t1 + HAVING ( 4 ) IN ( + SELECT t2.b + FROM t2 + ) +); +drop table t1, t2,t3; + +--echo # +--echo # BUG#834758: Wrong result with innner join, LooseScan, two-column IN() predicate +--echo # + +set @tmp835758=@@optimizer_switch; +set optimizer_switch='semijoin=on,loosescan=on,materialization=off,firstmatch=off'; + +CREATE TABLE t1 (b int) ; +INSERT INTO t1 VALUES (1),(5); + +CREATE TABLE t2 (a int, PRIMARY KEY (a)) ; +INSERT INTO t2 VALUES (6),(10); + +CREATE TABLE t3 (a int, b int, KEY (b)) ; +INSERT INTO t3 VALUES (6,5),(6,2),(8,0),(9,1),(6,5); + +--echo # This used to incorrectly pick a join order of (t1, LooseScan(t3), t2): +explain +SELECT * FROM t1, t2 WHERE (t2.a , t1.b) IN (SELECT a, b FROM t3); +SELECT * FROM t1, t2 WHERE (t2.a , t1.b) IN (SELECT a, b FROM t3); + +DROP TABLE t1, t2, t3; +set @@optimizer_switch= @tmp835758; + +--echo # +--echo # BUG#834739: Wrong result with 3-way inner join, LooseScan,multipart keys +--echo # +set @tmp834739=@@optimizer_switch; +set optimizer_switch='semijoin=on,loosescan=on,materialization=off,firstmatch=off'; +CREATE TABLE t2 ( b int, c int, KEY (b)) ; +INSERT INTO t2 VALUES (1,0),(1,0),(9,0),(1,0),(5,0); +INSERT INTO t2 VALUES (2,0),(3,0),(8,0),(6,0),(5,0); + +CREATE TABLE t3 ( a int); +INSERT INTO t3 VALUES (0),(0),(0),(0),(0),(0),(0),(0),(0),(0),(0),(0),(0),(0),(0); + +CREATE TABLE t4 ( a int); +INSERT INTO t4 VALUES (0),(0),(0); + +CREATE TABLE t5 ( b int, a int , KEY (a,b)) ; +INSERT INTO t5 VALUES (7,0),(9,0); + +explain +SELECT * FROM t3 WHERE t3.a IN (SELECT t5.a FROM t2, t4, t5 WHERE t2.c = t5.a AND t2.b = t5.b); +SELECT * FROM t3 WHERE t3.a IN (SELECT t5.a FROM t2, t4, t5 WHERE t2.c = t5.a AND t2.b = t5.b); + +DROP TABLE t2, t3, t4, t5; +set @@optimizer_switch=@tmp834739; + +--echo # +--echo # BUG#830993: Crash in end_read_record with derived table +--echo # +set @tmp_830993=@@optimizer_switch; +set optimizer_switch='semijoin=on,loosescan=off,materialization=off,firstmatch=off'; +set @tmp_830993_jbs= @@join_buffer_size; +--disable_warnings +set join_buffer_size=160; +--enable_warnings +CREATE TABLE t1 ( + a int(11) NOT NULL AUTO_INCREMENT, + b int(11) DEFAULT NULL, + c int(11) DEFAULT NULL, + d time DEFAULT NULL, + e varchar(1) DEFAULT NULL, + f varchar(1) DEFAULT NULL, + PRIMARY KEY (a), + KEY c (c), + KEY d (d), + KEY e (e,c) +); +INSERT INTO t1 VALUES (10,NULL,8,'22:55:23','x','x'), + (11,8,7,'10:19:31','d','d'),(12,1,1,'14:40:36','r','r'), + (13,9,7,'04:37:47','f','f'),(14,4,9,'19:34:06','y','y'), + (15,3,NULL,'20:35:33','u','u'),(16,2,1,NULL,'m','m'), + (17,NULL,9,'14:43:37',NULL,NULL),(18,2,2,'02:23:09','o','o'), + (19,NULL,9,'01:22:45','w','w'),(20,6,2,'00:00:00','m','m'), + (21,7,4,'00:13:25','q','q'),(22,2,0,'03:47:16',NULL,NULL), + (23,5,4,'01:41:48','d','d'),(24,7,8,'00:00:00','g','g'), + (25,6,NULL,'22:32:04','x','x'),(26,6,NULL,'16:44:14','f','f'), + (27,2,0,'17:38:37','p','p'),(28,9,NULL,'08:46:48','j','j'), + (29,6,8,'14:11:27','c','c'); + +CREATE TABLE t2 like t1; +INSERT INTO t2 VALUES (1,2,4,'22:34:09','v','v'), + (2,150,62,'14:26:02','v','v'),(3,NULL,7,'14:03:03','c','c'), + (4,2,1,'01:46:09',NULL,NULL),(5,5,0,'16:21:18','x','x'), + (6,3,7,'18:56:33','i','i'),(7,1,7,NULL,'e','e'), + (8,4,1,'09:29:08','p','p'),(9,NULL,7,'19:11:10','s','s'), + (10,2,1,'11:57:26','j','j'),(11,6,5,'00:39:46','z','z'), + (12,6,2,'03:28:15','c','c'),(13,8,0,'06:44:18','a','a'), + (14,2,1,'14:36:39','q','q'),(15,6,8,'18:42:45','y','y'), + (16,8,1,'02:57:29',NULL,NULL),(17,3,1,'16:46:13','r','r'), + (18,3,9,'19:39:02','v','v'),(19,9,1,NULL,NULL,NULL), + (20,6,5,'20:58:33','r','r'); + +explain +SELECT + alias1.a, alias1.b, alias1.c, alias1.d, alias1.e, alias1.f, + alias2.a as a2_a, alias2.b as a2_b, alias2.c as a2_c, alias2.d as a2_d, + alias2.e as a2_e, alias2.f as a2_f, + t2.a as t2_a, t2.b as t2_b, t2.c as t2_c, t2.d as t2_d, t2.e as t2_e, t2.f as t2_f +FROM + (SELECT * FROM t2) AS alias1, + t1 AS alias2, + t2 +WHERE + alias1.c IN (SELECT SQ3_alias1.b + FROM t2 AS SQ3_alias1 STRAIGHT_JOIN t2 AS SQ3_alias2) +LIMIT 100; + +create table t3 as +SELECT + alias1.a, alias1.b, alias1.c, alias1.d, alias1.e, alias1.f, + alias2.a as a2_a, alias2.b as a2_b, alias2.c as a2_c, alias2.d as a2_d, + alias2.e as a2_e, alias2.f as a2_f, + t2.a as t2_a, t2.b as t2_b, t2.c as t2_c, t2.d as t2_d, t2.e as t2_e, t2.f as t2_f +FROM + (SELECT * FROM t2) AS alias1, + t1 AS alias2, + t2 +WHERE + alias1.c IN (SELECT SQ3_alias1.b + FROM t2 AS SQ3_alias1 STRAIGHT_JOIN t2 AS SQ3_alias2) +LIMIT 100; + +drop table t1,t2, t3; +set optimizer_switch=@tmp_830993; +set join_buffer_size= @tmp_830993_jbs; + +--echo # +--echo # BUG##849717: Crash in Item_func::fix_fields on second execution of a prepared statement with semijoin +--echo # +CREATE TABLE t1 (a int); +CREATE TABLE t2 (a int); +CREATE TABLE t3 (a int, b int) ; + +PREPARE st1 FROM "SELECT * FROM t2 LEFT JOIN t1 ON t2.a != 0 AND ('j','r') IN ( SELECT b,a FROM t3)"; +EXECUTE st1; +EXECUTE st1; + +DROP TABLE t1, t2, t3; + +--echo # +--echo # BUG#849776: Wrong result with semijoin + "Impossible where" +--echo # +CREATE TABLE t1 ( b varchar(1), a integer) ; +INSERT INTO t1 VALUES ('z',8); + +CREATE TABLE t2 ( a integer, b varchar(1)) ; + +CREATE TABLE t4 ( a integer, b varchar(1)) ; + +CREATE TABLE t5 ( a integer) ; +INSERT INTO t5 VALUES (8); + +select * from t5 where (a) in ( + SELECT t1.a + FROM t1 LEFT JOIN t2 ON t1.a = t2.a + WHERE t2.b NOT IN (SELECT t4.b FROM t4 WHERE t4.b < t1.b) +); + +DROP TABLE t1, t2, t4, t5; + +--echo # +--echo # BUG#861147: Assertion `fixed == 1' failed in Item_func_eq::val_int() with semijoin + materialization + max_join_size +--echo # +CREATE TABLE t1 ( f2 int) ; +CREATE TABLE t2 ( f1 int, f3 int, f4 varchar(3), f5 varchar(35)) ; +INSERT INTO t2 VALUES (4057,9,'USA','Visalia'),(3993,11,'USA','Waco'), + (3948,14,'USA','Warren'),(3813,57,'USA','Washington'), + (4010,11,'USA','Waterbury'),(4017,11,'USA','West Covina'), + (4004,11,'USA','West Valley City'),(4033,10,'USA','Westminster'), + (3842,34,'USA','Wichita'),(4018,10,'USA','Wichita Falls'), + (3899,19,'USA','Winston-Salem'),(3914,17,'USA','Worcester'), + (3888,20,'USA','Yonkers'); + +CREATE TABLE t3 ( f3 int, f4 varchar(3)) ; +INSERT INTO t3 VALUES (86,'USA'); + +CREATE TABLE t4 ( f3 int, f4 varchar(3), f5 varchar(52)) ; +INSERT INTO t4 VALUES (0,'RUS','Belorussian'),(0,'USA','Portuguese'); + +CREATE TABLE t5 ( f2 int) ; + +CREATE TABLE t6 ( f4 varchar(3)); +INSERT INTO t6 VALUES ('RUS'),('USA'); + +set @tmp_mjs_861147= @@max_join_size; +SET max_join_size=10; +set @tmp_os_861147= @@optimizer_switch; +set @@optimizer_switch='semijoin=on,materialization=on'; + +--error ER_TOO_BIG_SELECT +SELECT * +FROM t1 +WHERE ( 1 , 3 ) IN ( + SELECT t2.f1 , MAX( t3.f3 ) + FROM t2 + JOIN t3 + WHERE t3.f4 IN ( + SELECT t4.f5 + FROM t4 + STRAIGHT_JOIN t5 + WHERE t4.f4 < t2.f5 + ) +) AND ( 'p' , 'k' ) IN ( + SELECT f4 , f4 FROM t6 +); +set max_join_size= @tmp_mjs_861147; +set optimizer_switch= @tmp_os_861147; + +DROP TABLE t1,t2,t3,t4,t5,t6; + +--echo # +--echo # BUG#877288: Wrong result with semijoin + materialization + multipart key +--echo # +set @tmp_877288=@@optimizer_switch; +set optimizer_switch='semijoin=ON,materialization=ON'; +CREATE TABLE t1 ( a int) ; +INSERT INTO t1 VALUES (19),(19),(19),(20),(20),(20),(20),(20),(20); + +CREATE TABLE t2 ( b int NOT NULL , c int NOT NULL , KEY (b,c)) ; +INSERT INTO t2 VALUES (14,1),(15,1),(16,1),(17,1),(18,1),(19,1),(20,1); + +CREATE TABLE t3 ( a int, d int) ; +INSERT INTO t3 VALUES (19,1),(7,1),(3,1),(3,1),(20,1),(3,1),(16,1),(17,1),(9,1),(4,1),(6,1),(15,1),(17,1); + +explain +SELECT * FROM t1 WHERE (a) IN (SELECT a FROM t2 JOIN t3 ON b = a); +SELECT * FROM t1 WHERE (a) IN (SELECT a FROM t2 JOIN t3 ON b = a); +DROP TABLE t1,t2,t3; +set optimizer_switch=@tmp_877288; + +--echo # +--echo # BUG#878753: Assertion '0' failed in replace_where_subcondition with derived_merge +--echo # +set @tmp878753= @@optimizer_switch; +set optimizer_switch= 'semijoin=on,derived_merge=on'; +CREATE TABLE t1 (b int(11)) ; +CREATE TABLE t2 (c int, b int, d varchar(52) NOT NULL) ; +CREATE TABLE t3 (b int(11)) ; + +PREPARE st1 FROM ' + SELECT * FROM t1 + JOIN ( + SELECT t2.* FROM t2 + WHERE t2.d <> "a" + AND t2.c IN ( + SELECT t3.b + FROM t3 + ) + ) AS alias2 + ON ( alias2.b = t1.b ); +'; +EXECUTE st1; +DROP TABLE t1,t2,t3; +set optimizer_switch=@tmp878753; + +--echo # +--echo # Bug #889750: semijoin=on + firstmatch=off + semijoin_with_cache=off +--echo # + +create table t1 (a int); +insert into t1 values (7), (1), (5), (3); +create table t2 (a int); +insert into t2 values (4), (1), (8), (3), (9), (2); + +set @tmp_otimizer_switch= @@optimizer_switch; +set optimizer_switch='semijoin=on'; +set optimizer_switch='firstmatch=off'; + +set optimizer_switch='semijoin_with_cache=on'; +explain +select * from t1 where t1.a in (select t2.a from t2); +select * from t1 where t1.a in (select t2.a from t2); + +set optimizer_switch='semijoin_with_cache=off'; +explain +select * from t1 where t1.a in (select t2.a from t2); +select * from t1 where t1.a in (select t2.a from t2); + +set optimizer_switch= @tmp_otimizer_switch; + +drop table t1,t2; + # The following command must be the last one the file set optimizer_switch=@subselect_sj_tmp; diff --git a/mysql-test/t/subselect_sj2.test b/mysql-test/t/subselect_sj2.test index 7972ff50450..0fd8cab1a04 100644 --- a/mysql-test/t/subselect_sj2.test +++ b/mysql-test/t/subselect_sj2.test @@ -28,6 +28,7 @@ create table t2 ( key(b) ); insert into t2 select a, a/2 from t0; +insert into t2 select a+10, a+10/2 from t0; select * from t1; select * from t2; @@ -43,6 +44,8 @@ create table t3 ( primary key(pk1, pk2, pk3) ) engine=innodb; insert into t3 select a,a, a,a,a from t0; +insert into t3 select a,a, a+100,a+100,a+100 from t0; + explain select * from t3 where b in (select a from t1); select * from t3 where b in (select a from t1); @@ -578,6 +581,7 @@ insert into t0 values (0),(1),(2),(3),(4); create table t1 (a int, b int, key(a)); insert into t1 select a,a from t0; +insert into t1 select a+5,a from t0; create table t2 (a int, b int, primary key(a)); insert into t2 select * from t1; @@ -947,4 +951,123 @@ WHERE alias2.f11 IN ( GROUP BY field2; drop table t1, t2, t3; +--echo # +--echo # BUG#849763: Wrong result with second execution of prepared statement with semijoin + view +--echo # +CREATE TABLE t1 ( c varchar(1)) engine=innodb; +INSERT INTO t1 VALUES ('r'); + +CREATE TABLE t2 ( a integer, b varchar(1), c varchar(1)) engine=innodb; +INSERT INTO t2 VALUES (1,'r','r'); + +CREATE OR REPLACE VIEW v1 AS SELECT * FROM t1; + +PREPARE st1 FROM 'SELECT * FROM t2 WHERE a = SOME (SELECT a FROM v1 WHERE v1.c = t2.c)'; +EXECUTE st1; +EXECUTE st1; + +DROP VIEW v1; +DROP TABLE t1, t2; + +--echo # +--echo # BUG#858732: Wrong result with semijoin + loosescan + comma join +--echo # +CREATE TABLE t1 (f13 int(11) NOT NULL , PRIMARY KEY (f13)) ENGINE=InnoDB; +INSERT INTO t1 VALUES (16),(24); + +CREATE TABLE t2 (f14 int(11) NOT NULL, f12 varchar(1) NOT NULL, KEY (f12,f14)) ENGINE=InnoDB; +INSERT INTO t2 VALUES (6,'y'); + +CREATE TABLE t3 (f12 varchar(1) NOT NULL) ENGINE=InnoDB; +INSERT INTO t3 VALUES ('r'),('s'),('t'),('v'),('w'),('x'),('y'); + +--echo # The following must use LooseScan but not join buffering +explain +SELECT * FROM t3 +WHERE f12 IN (SELECT alias2.f12 FROM t1 AS alias1, t2 AS alias2, t1 WHERE alias1.f13 = 24); + +SELECT * FROM t3 +WHERE f12 IN (SELECT alias2.f12 FROM t1 AS alias1, t2 AS alias2, t1 WHERE alias1.f13 = 24); + +DROP TABLE t1,t2,t3; + +--echo # +--echo # BUG#869012: Wrong result with semijoin + materialization + AND in WHERE +--echo # +CREATE TABLE t1 (f3 varchar(1) , f4 varchar(1) ) engine=InnoDB; +INSERT IGNORE INTO t1 VALUES ('x','x'),('x','x'); +CREATE TABLE t2 ( f4 varchar(1) ) ; +INSERT IGNORE INTO t2 VALUES ('g'); +CREATE TABLE t3 (f4 varchar(1) ) Engine=InnoDB; +INSERT IGNORE INTO t3 VALUES ('x'); + +set @tmp_869012=@@optimizer_switch; +SET optimizer_switch='semijoin=on,materialization=on'; +SELECT * +FROM t1 , t2 +WHERE ( t1.f4 ) IN ( SELECT f4 FROM t3 ) +AND t2.f4 != t1.f3 ; +set optimizer_switch= @tmp_869012; + +DROP TABLE t1,t2,t3; + + +--echo # +--echo # BUG#869001: Wrong result with semijoin + materialization + firstmatch + multipart key +--echo # +set @tmp869001_jcl= @@join_cache_level; +set @tmp869001_os= @@optimizer_switch; +SET join_cache_level=0; +SET optimizer_switch='materialization=on,semijoin=on,firstmatch=on,loosescan=off'; + +CREATE TABLE t1 ( f2 int, f3 varchar(1), KEY (f3,f2)) engine=innodb; +INSERT INTO t1 VALUES (8,'x'),(NULL,'x'),(8,'c'); + +CREATE TABLE t2 ( f4 varchar(1)) engine=innodb; +INSERT INTO t2 VALUES ('x'); + +CREATE TABLE t3 ( f1 int) engine=innodb; +INSERT INTO t3 VALUES (8),(6),(2),(9),(6); + +CREATE TABLE t4 ( f3 varchar(1)) engine=innodb; +INSERT INTO t4 VALUES ('p'),('j'),('c'); + +SELECT * +FROM t1 JOIN t2 ON (t2.f4 = t1.f3 ) +WHERE ( 8 ) IN ( + SELECT t3.f1 FROM t3 , t4 +); + +DROP TABLE t1, t2, t3, t4; +set join_cache_level= @tmp869001_jcl; +set optimizer_switch= @tmp869001_os; + +--echo # +--echo # Bug #881318: join cache + duplicate elimination + left join +--echo # with empty materialized derived inner table +--echo # + +CREATE TABLE t1 (b varchar(1)) ENGINE=InnoDB; + +CREATE TABLE t2 (a varchar(1)) ENGINE=InnoDB; +INSERT INTO t2 VALUES ('a'); + +CREATE TABLE t3 (a varchar(1), b varchar(1)) ENGINE=InnoDB; +INSERT INTO t3 VALUES ('c','c'); + +CREATE TABLE t4 (b varchar(1)) ENGINE=InnoDB; +INSERT INTO t4 VALUES ('c'), ('b'); + +CREATE ALGORITHM=TEMPTABLE VIEW v1 AS SELECT * FROM t1; + +EXPLAIN +SELECT * FROM t3 LEFT JOIN (v1,t2) ON t3.a = t2.a + WHERE t3.b IN (SELECT b FROM t4); +SELECT * FROM t3 LEFT JOIN (v1,t2) ON t3.a = t2.a + WHERE t3.b IN (SELECT b FROM t4); + +DROP VIEW v1; +DROP TABLE t1,t2,t3,t4; + +--echo # This must be the last in the file: set optimizer_switch=@subselect_sj2_tmp; diff --git a/mysql-test/t/subselect_sj_jcl6.test b/mysql-test/t/subselect_sj_jcl6.test index 44ee52686b3..e475adbf9a8 100644 --- a/mysql-test/t/subselect_sj_jcl6.test +++ b/mysql-test/t/subselect_sj_jcl6.test @@ -22,6 +22,8 @@ CREATE TABLE t0 (a INT); INSERT INTO t0 VALUES (0),(1),(2),(3),(4); CREATE TABLE t1 (a INT, b INT, KEY(a)); INSERT INTO t1 SELECT a, a from t0; +INSERT INTO t1 SELECT a+5, a from t0; +INSERT INTO t1 SELECT a+10, a from t0; CREATE TABLE t2 (a INT, b INT, PRIMARY KEY(a)); INSERT INTO t2 SELECT * FROM t1; UPDATE t1 SET a=3, b=11 WHERE a=4; diff --git a/mysql-test/t/subselect_sj_mat.test b/mysql-test/t/subselect_sj_mat.test index 0ea1c3873eb..a72128bf5ed 100644 --- a/mysql-test/t/subselect_sj_mat.test +++ b/mysql-test/t/subselect_sj_mat.test @@ -4,12 +4,12 @@ # set @subselect_sj_mat_tmp= @@optimizer_switch; -set optimizer_switch=ifnull(@subselect_mat_test_optimizer_switch_value, 'semijoin=on,firstmatch=on,loosescan=on'); +set optimizer_switch=ifnull(@subselect_mat_test_optimizer_switch_value, 'semijoin=on,firstmatch=on,loosescan=on,semijoin_with_cache=on'); set optimizer_switch='mrr=on,mrr_sort_keys=on,index_condition_pushdown=on'; set @optimizer_switch_local_default= @@optimizer_switch; --disable_warnings -drop table if exists t1, t2, t3, t1i, t2i, t3i; +drop table if exists t1, t2, t3, t4, t5, t1i, t2i, t3i; drop table if exists columns; drop table if exists t1_16, t2_16, t3_16; drop view if exists v1, v2, v1m, v2m; @@ -1242,5 +1242,190 @@ select left(a1,7), left(a2,7) from t1_1024 where (a1,3) in (select substring(b1, drop table t1_1024, t2_1024; +--echo # +--echo # BUG##836491: Crash in Item_field::Item_field from add_ref_to_table_cond() with semijoin+materialization +--echo # + +CREATE TABLE t1 (c int, d varchar(1), KEY(d)) ; +INSERT INTO t1 VALUES (2,'x'),(2,'x'),(2,'j'),(2,'c'); + +CREATE TABLE t2 (a int, d varchar(1)) ; +INSERT INTO t2 VALUES (1,'x'); + +CREATE TABLE t3 (d varchar(1)) ; +INSERT INTO t3 VALUES ('x'),('x'),('j'),('c'); + +SELECT t2.a, t1.c +FROM t1, t2 +WHERE t2.d IN ( SELECT d FROM t3 ) +AND t1.d = t2.d +GROUP BY 1 , 2; + +drop table t1,t2,t3; + +--echo # +--echo # BUG#836523: Crash in JOIN::get_partial_cost_and_fanout with semijoin+materialization +--echo # +CREATE TABLE t1 (a varchar(1)); +INSERT INTO t1 VALUES ('a'),('a'); + +CREATE TABLE t2 (a varchar(1)); + +CREATE TABLE t3 (a int); +INSERT INTO t3 VALUES (1),(2); + +CREATE TABLE t4 (a varchar(1)); +INSERT INTO t4 VALUES ('a'),('a'); + +SELECT t1.a +FROM t1 +WHERE t1.a IN ( + SELECT t2.a + FROM t2, t3 +) +HAVING a IN ( + SELECT a + FROM t4 +); +DROP TABLE t1, t2, t3, t4; + +--echo # +--echo # BUG#836507: Crash in setup_sj_materialization_part1() with semijoin+materialization +--echo # +CREATE TABLE t1 (a int) ; +INSERT IGNORE INTO t1 VALUES (1),(1); + +CREATE TABLE t2 (a int); +INSERT INTO t2 VALUES (1); + +CREATE TABLE t3 (a int); + +CREATE TABLE t4 (a int); +INSERT INTO t4 VALUES (2),(2); + +CREATE TABLE t5 (a int); +INSERT INTO t5 VALUES (1); + +SELECT * FROM t1 +WHERE (a) IN ( + SELECT t5.a + FROM ( + t2 + LEFT JOIN ( t3 , t4 ) + ON 1 = 1 + ) + JOIN t5 +); + +DROP TABLE t1,t2,t3,t4,t5; + +--echo # +--echo # BUG#836532: Crash in Item_equal_fields_iterator::get_curr_field with semijoin+materialization +--echo # + +CREATE TABLE t2 (a int); +INSERT INTO t2 VALUES ('a'),('a'); + +CREATE TABLE t4 (a varchar(1)); +INSERT INTO t4 VALUES ('m'),('o'); + +CREATE TABLE t3 (a varchar(1) , b varchar(1) ) ; +INSERT INTO t3 VALUES ('b','b'); + +CREATE TABLE t5 (a varchar(1), KEY (a)) ; +INSERT INTO t5 VALUES ('d'),('e'); + +SELECT * +FROM t2 +WHERE t2.a = ALL ( + SELECT t4.a + FROM t4 + WHERE t4.a IN ( + SELECT t3.a + FROM t3 , t5 + WHERE ( t5.a = t3.b ) + ) +); + +DROP TABLE t2,t3,t4,t5; + +--echo # +--echo # BUG#860300: Second crash with get_fanout_with_deps() with semijoin + materialization +--echo # +set @tmp_860300=@@optimizer_switch; +set optimizer_switch='semijoin=on,materialization=on,loosescan=off,firstmatch=off'; +CREATE TABLE t1 (f2 int); +INSERT INTO t1 VALUES (9),(6); +CREATE TABLE t3 (f4 int); +CREATE TABLE t4 (f6 varchar(1)); + +SELECT * +FROM t3 +WHERE 'h' IN (SELECT f6 + FROM t4 + WHERE 5 IN (SELECT f2 FROM t1) + GROUP BY t4.f6); +DROP TABLE t1,t3,t4; +set optimizer_switch=@tmp_860300; + +--echo # +--echo # BUG#860535: Assertion `keypart_map' failed in mi_rkey with semijoin +--echo # +set @tmp_860535=@@optimizer_switch; +set optimizer_switch='semijoin=on,materialization=on,loosescan=off,firstmatch=off'; +CREATE TABLE t1 (f3 int) ; +INSERT INTO t1 VALUES (1),(7); + +CREATE TABLE t2 (f3 int , f5 varchar(1), KEY (f3)) ; +INSERT INTO t2 VALUES (7,'b'); + +CREATE TABLE t3 (f3 int , f4 varchar(1) , KEY(f3), KEY (f4,f3)) ; +INSERT INTO t3 VALUES (1,'t'),(7,'g'); + +CREATE TABLE t4 +SELECT f3 +FROM t1 WHERE ( f3 ) NOT IN ( + SELECT f3 + FROM t2 + WHERE f5 IN ( + SELECT f4 + FROM t3 + WHERE t3.f3 < 3 + ) +); +SELECT * FROM t4; +DROP TABLE t1, t2, t3, t4; +set optimizer_switch=@tmp_860535; + +--echo # +--echo # BUG#860553: Crash in create_ref_for_key with semijoin + materialization +--echo # +CREATE TABLE t1 (f1 int) ; +CREATE TABLE t2 (f5 varchar(52) NOT NULL) ; + +CREATE TABLE t3 (f1 varchar(3), f4 varchar(52) , KEY (f4), PRIMARY KEY (f1)); + +CREATE TABLE t4 (f3 int, KEY (f3)); +INSERT INTO t4 VALUES (17),(20); + +CREATE TABLE t5 (f2 int); +INSERT INTO t5 VALUES (0),(0); + +SELECT * +FROM t1 +JOIN t2 +ON ( t2.f5 ) IN ( + SELECT t3.f4 + FROM t3 + WHERE ( 1 ) IN ( + SELECT t4.f3 + FROM t4 , t5 + ) +); + +DROP TABLE t1, t2, t3, t4, t5; + + +--echo # This must be at the end: set optimizer_switch=@subselect_sj_mat_tmp; diff --git a/mysql-test/t/table_elim.test b/mysql-test/t/table_elim.test index 5576362b396..3b584ce2b38 100644 --- a/mysql-test/t/table_elim.test +++ b/mysql-test/t/table_elim.test @@ -223,7 +223,8 @@ create table t1 (a char(10) primary key); insert into t1 values ('foo'),('bar'); create table t2 (a char(10), unique key(a(2))); -insert into t2 values ('foo'),('bar'); +insert into t2 values + ('foo'),('bar'),('boo'),('car'),('coo'),('par'),('doo'),('tar'); explain select t1.* from t1 left join t2 on t2.a=t1.a; @@ -499,3 +500,21 @@ WHERE t3.f2 ; DROP TABLE t1,t2,t3,t4,t5; +--echo # +--echo # BUG#884184: Wrong result with RIGHT JOIN + derived_merge +--echo # +CREATE TABLE t1 (a int(11), b varchar(1)) ; +INSERT IGNORE INTO t1 VALUES (0,'g'); + +CREATE TABLE t3 ( a varchar(1)) ; +INSERT IGNORE INTO t3 VALUES ('g'); + +CREATE TABLE t2 ( a int(11) NOT NULL, PRIMARY KEY (a)) ; +create view v1 as SELECT t1.* FROM t1 LEFT JOIN t2 ON ( t1.a = t2.a ) WHERE t2.a <> 0; + +SELECT alias1.* FROM t3 LEFT JOIN v1 as alias1 ON ( t3.a = alias1.b ); +EXPLAIN SELECT alias1.* FROM t3 LEFT JOIN v1 as alias1 ON ( t3.a = alias1.b ); + +drop view v1; +DROP TABLE t1,t2,t3; + diff --git a/mysql-test/t/table_elim_debug.test b/mysql-test/t/table_elim_debug.test index 9f793169e4f..6400f798195 100644 --- a/mysql-test/t/table_elim_debug.test +++ b/mysql-test/t/table_elim_debug.test @@ -1,7 +1,8 @@ # # Table elimination (MWL#17) tests that need debug build # ---source include/have_debug.inc +# In MariaDB 5.3, one can switch table_elimination on/off without debug, too: +## --source include/have_debug.inc --disable_warnings drop table if exists t1, t2; diff --git a/mysql-test/t/trigger.test b/mysql-test/t/trigger.test index 85cf01a607f..1bd637f477c 100644 --- a/mysql-test/t/trigger.test +++ b/mysql-test/t/trigger.test @@ -2406,6 +2406,29 @@ USE test; --echo End of 5.1 tests. +# +# Test that using a trigger will not open mysql.proc +# +create table t1 (i int); +create table t2 (i int); +flush tables; +flush status; +delimiter //; +CREATE DEFINER=`root`@`localhost` TRIGGER trg AFTER DELETE ON t1 FOR EACH ROW BEGIN DELETE FROM t2 WHERE t2.i = OLD.i; END // +delimiter ;// +insert into t1 values (1),(2); +insert into t2 values (1),(2); +delete from t1 where i=1; +# +# If mysql.proc would be used we would have 4 here. 3 is the correct number. +# (CREATE TRIGGER will open t1 and then flush it) +# +show status like 'Opened_tables'; +select * from t1; +select * from t2; +drop table t1,t2; + +--echo End of 5.2 tests. --echo # --echo # Bug#34453 Can't change size of file (Errcode: 1224) @@ -2521,8 +2544,6 @@ select trigger_name from information_schema.triggers drop temporary table t1; drop table t1; - ---echo --echo # --echo # Bug #12362125: SP INOUT HANDLING IS BROKEN FOR TEXT TYPE. --echo # diff --git a/mysql-test/t/type_float.test b/mysql-test/t/type_float.test index 45cf80aab5c..b33c51566a0 100644 --- a/mysql-test/t/type_float.test +++ b/mysql-test/t/type_float.test @@ -307,4 +307,27 @@ INSERT INTO t1 VALUES(-1.79769313486231e+308); SELECT f1 FROM t1; DROP TABLE t1; +--echo # +--echo # Bug#12406055 BUFFER OVERFLOW OF VARIABLE 'BUFF' IN STRING::SET_REAL +--echo # + +--echo # Ignoring output from misc. float operations +--disable_result_log + +let $nine_65= +99999999999999999999999999999999999999999999999999999999999999999; + +select format(-1.7976931348623157E+307,256) as foo; +select least(-1.1111111111111111111111111, + - group_concat(1.7976931348623157E+308)) as foo; +eval select concat((truncate((-1.7976931348623157E+307),(0x1e))), + ($nine_65)) into @a; +--enable_result_log + --echo End of 5.0 tests + +--echo # +--echo # Bug#12368853 FORMAT() CRASHES WITH LARGE NUMBERS AFTER TRUNCATE... +--echo # + +select format(truncate('1.7976931348623157E+308',-12),1,'fr_BE') as foo; diff --git a/mysql-test/t/type_newdecimal.test b/mysql-test/t/type_newdecimal.test index f1eeabbd924..4f4b1962cc3 100644 --- a/mysql-test/t/type_newdecimal.test +++ b/mysql-test/t/type_newdecimal.test @@ -1535,3 +1535,17 @@ DROP TABLE IF EXISTS t1; --echo End of 5.1 tests + +--echo # +--echo # BUG#12911710 - VALGRIND FAILURE IN +--echo # ROW-DEBUG:PERFSCHEMA.SOCKET_SUMMARY_BY_INSTANCE_FUNC +--echo # + +CREATE TABLE t1(d1 DECIMAL(60,0) NOT NULL, + d2 DECIMAL(60,0) NOT NULL); + +INSERT INTO t1 (d1, d2) VALUES(0.0, 0.0); +SELECT d1 * d2 FROM t1; + +DROP TABLE t1; + diff --git a/mysql-test/t/union.test b/mysql-test/t/union.test index db7f8397c7b..c9bc3f5e1aa 100644 --- a/mysql-test/t/union.test +++ b/mysql-test/t/union.test @@ -1124,6 +1124,47 @@ insert into t1 values (10),(10),(10),(2),(3),(4),(5),(6),(7),(8),(9),(1),(10); select a from t1 where false UNION select a from t1 limit 8; drop table t1; +--echo # +--echo # Bug#11765255 58201: +--echo # VALGRIND/CRASH WHEN ORDERING BY MULTIPLE AGGREGATE FUNCTIONS +--echo # + +let $my_stmt= +select 1 as foo +union +select 2 +union +select 3 +union +select 4 +order by max(42) + max(1) + max(1) + max(1) + max(1) + max(1) +; + +eval $my_stmt; + +eval prepare stmt1 from '$my_stmt'; +execute stmt1; +execute stmt1; + +let $my_stmt= +select 1 as foo +union +select 2 +union +select 3 +union +(select 4) +order by max(42) + max(1) + max(1) + max(1) + max(1) + max(1) +; + +eval $my_stmt; + +eval prepare stmt1 from '$my_stmt'; +execute stmt1; +execute stmt1; + +deallocate prepare stmt1; + --echo End of 5.1 tests --echo # diff --git a/mysql-test/t/user_limits-master.opt b/mysql-test/t/user_limits-master.opt new file mode 100644 index 00000000000..107b2e4a27f --- /dev/null +++ b/mysql-test/t/user_limits-master.opt @@ -0,0 +1 @@ +--max-user-connections=1000 diff --git a/mysql-test/t/user_limits.test b/mysql-test/t/user_limits.test index 1bf3f9a3103..7c249f61686 100644 --- a/mysql-test/t/user_limits.test +++ b/mysql-test/t/user_limits.test @@ -8,6 +8,8 @@ # Save the initial number of concurrent sessions --source include/count_sessions.inc +set @my_max_user_connections= @@global.max_user_connections; + # Prepare play-ground --disable_warnings drop table if exists t1; @@ -120,8 +122,18 @@ select * from t1; --replace_result $MASTER_MYPORT MYSQL_PORT $MASTER_MYSOCK MYSQL_SOCK --error ER_USER_LIMIT_REACHED connect (muc5, localhost, mysqltest_1,,); -# Clean up + connection default; +# Test with negative max_user_connections +grant usage on *.* to mysqltest_1@localhost with max_user_connections -1; +show grants for mysqltest_1@localhost; +flush user_resources; +show grants for mysqltest_1@localhost; +--replace_result $MASTER_MYPORT MYSQL_PORT $MASTER_MYSOCK MYSQL_SOCK +--error ER_USER_LIMIT_REACHED +connect (muc5, localhost, mysqltest_1,,); + +# Clean up disconnect muc2; disconnect muc3; disconnect muc4; @@ -165,12 +177,37 @@ disconnect muca1; disconnect muca2; disconnect muca3; set global max_user_connections= 0; -drop user mysqltest_1@localhost; --enable_ps_protocol +# +# Test setting negative values of max_user_connections +# +grant usage on *.* to mysqltest_1@localhost with max_user_connections 0; +set global max_user_connections=-1; +show variables like "max_user_user_connections"; +select @@max_user_connections; +select @@global.max_user_connections; +# Check that we can't connect anymore except as root +--replace_result $MASTER_MYPORT MYSQL_PORT $MASTER_MYSOCK MYSQL_SOCK +--error ER_TOO_MANY_USER_CONNECTIONS +connect (muca2, localhost, mysqltest_1,,); +connect (muca2, localhost, root,,); +disconnect muca2; +connection default; +set global max_user_connections=1; +# Check that we can connect one time, not two +connect (muca2, localhost, mysqltest_1,,); +--replace_result $MASTER_MYPORT MYSQL_PORT $MASTER_MYSOCK MYSQL_SOCK +--error ER_TOO_MANY_USER_CONNECTIONS +connect (muca3, localhost, mysqltest_1,,); +disconnect muca2; +connection default; +drop user mysqltest_1@localhost; + # Final cleanup drop table t1; # Wait till all disconnects are completed --source include/wait_until_count_sessions.inc +set global max_user_connections= @my_max_user_connections; diff --git a/mysql-test/t/variables-master.opt b/mysql-test/t/variables-master.opt new file mode 100644 index 00000000000..e4b213a0323 --- /dev/null +++ b/mysql-test/t/variables-master.opt @@ -0,0 +1 @@ +--max-user-connections=1 diff --git a/mysql-test/t/variables.test b/mysql-test/t/variables.test index 3f7c4541a43..e9b428ff26c 100644 --- a/mysql-test/t/variables.test +++ b/mysql-test/t/variables.test @@ -23,6 +23,7 @@ set @my_max_delayed_threads =@@global.max_delayed_threads; set @my_max_heap_table_size =@@global.max_heap_table_size; set @my_max_insert_delayed_threads=@@global.max_insert_delayed_threads; set @my_max_join_size =@@global.max_join_size; +set @my_max_user_connections =@@global.max_user_connections; set @my_myisam_data_pointer_size =@@global.myisam_data_pointer_size; set @my_myisam_max_sort_file_size =@@global.myisam_max_sort_file_size; set @my_net_buffer_length =@@global.net_buffer_length; @@ -36,6 +37,7 @@ set @my_thread_cache_size =@@global.thread_cache_size; set @my_max_allowed_packet =@@global.max_allowed_packet; set @my_delay_key_write =@@global.delay_key_write; set @my_join_buffer_size =@@global.join_buffer_size; +set @my_log_warnings =@@global.log_warnings; # case insensitivity tests (new in 5.0) set @`test`=1; select @test, @`test`, @TEST, @`TEST`, @"teSt"; @@ -817,7 +819,7 @@ set global max_delayed_threads =@my_max_delayed_threads; set global max_heap_table_size =@my_max_heap_table_size; set global max_insert_delayed_threads=@my_max_insert_delayed_threads; set global max_join_size =@my_max_join_size; -set global max_user_connections =default; +set global max_user_connections =@my_max_user_connections; set global max_write_lock_count =default; set global myisam_data_pointer_size =@my_myisam_data_pointer_size; set global myisam_max_sort_file_size =@my_myisam_max_sort_file_size; @@ -832,6 +834,7 @@ set global thread_cache_size =@my_thread_cache_size; set global max_allowed_packet = default; set global delay_key_write =@my_delay_key_write; set global join_buffer_size =@my_join_buffer_size; +set global log_warnings =@my_log_warnings; # # Bug#28580 Repeatation of status variables diff --git a/mysql-test/t/view.test b/mysql-test/t/view.test index f464239b81e..df47526ef21 100644 --- a/mysql-test/t/view.test +++ b/mysql-test/t/view.test @@ -4465,7 +4465,27 @@ DROP TABLE t1; disconnect con2; disconnect con3; - # Check that all connections opened by test cases in this file are really # gone so execution of other tests won't be affected by their presence. --source include/wait_until_count_sessions.inc + +--echo # +--echo # lp:833600 Wrong result with view + outer join + uncorrelated subquery (non-semijoin) +--echo # + +CREATE TABLE t1 ( a int, b int ); +INSERT INTO t1 VALUES (0,0),(0,0); + +CREATE TABLE t2 ( a int, b int ); +INSERT IGNORE INTO t2 VALUES (1,0),(1,0); + +CREATE TABLE t3 ( b int ); +INSERT IGNORE INTO t3 VALUES (0),(0); + +CREATE OR REPLACE VIEW v2 AS SELECT * FROM t2; +SELECT * FROM t1 RIGHT JOIN v2 ON ( v2.a = t1.a ) WHERE v2.b IN ( SELECT b FROM t3 ) AND t1.b IS NULL ; + +SELECT * FROM t1 RIGHT JOIN v2 ON ( v2.a = t1.a ) WHERE v2.b IN ( SELECT b FROM t3 ) AND t1.b IS NULL ; + +DROP VIEW v2; +DROP TABLE t1, t2, t3; diff --git a/mysql-test/t/xml.test b/mysql-test/t/xml.test index 89c0b8992b1..b36bd2067cc 100644 --- a/mysql-test/t/xml.test +++ b/mysql-test/t/xml.test @@ -665,5 +665,14 @@ SET NAMES latin1; SELECT UPDATEXML(CONVERT('' USING swe7), TRUNCATE('',1), 0); --echo # +--echo # Bug#12375190: UPDATEXML CRASHES ON SIMPLE INPUTS +--echo # +SELECT UPDATEXML('','(a)/a',''); +SELECT UPDATEXML('<a><a>x</a></a>','(a)/a','<b />'); +SELECT UPDATEXML('<a><c><a>x</a></c></a>','(a)/a','<b />'); +SELECT UPDATEXML('<a><c><a>x</a></c></a>','(a)//a','<b />'); +SELECT ExtractValue('<a><a>aa</a><b>bb</b></a>','(a)/a|(a)/b'); + +--echo # --echo # End of 5.5 tests --echo # diff --git a/mysql-test/t/xtradb_mrr.test b/mysql-test/t/xtradb_mrr.test index 0653f9859c3..37a0159babd 100644 --- a/mysql-test/t/xtradb_mrr.test +++ b/mysql-test/t/xtradb_mrr.test @@ -420,6 +420,7 @@ DROP TABLE t1,t2; --echo # --echo # Testcase backport: Bug#43249 +--echo # (Note: Fixed by patch for BUG#42580) --echo # CREATE TABLE t1(c1 TIME NOT NULL, c2 TIME NULL, c3 DATE, PRIMARY KEY(c1), UNIQUE INDEX(c2)) engine=innodb; INSERT INTO t1 VALUES('8:29:45',NULL,'2009-02-01'); diff --git a/mysql-test/valgrind.supp b/mysql-test/valgrind.supp index 34f164bc731..5174b04c054 100644 --- a/mysql-test/valgrind.supp +++ b/mysql-test/valgrind.supp @@ -414,6 +414,15 @@ } { + dlsym memory loss from udf_free on SuSE 11.1 x64 variant 2 + Memcheck:Leak + fun:calloc + obj:/lib*/ld-*.so + fun:dlclose + fun:udf_free +} + +{ dlclose memory loss from plugin variant 1 Memcheck:Leak fun:calloc @@ -1203,3 +1212,46 @@ fun:buf_buddy_free_low fun:buf_buddy_free } + +# Note the wildcard in the (mangled) function signatures of +# write_keys() and find_all_keys(). +# They both return ha_rows, which is platform dependent. +# +# The '...' wildcards are for 'fun:inline_mysql_file_write' which *may* +# be inlined. +{ + Bug#12856915 VALGRIND FAILURE IN FILESORT/CREATE_SORT_INDEX / one + Memcheck:Param + write(buf) + obj:*/libpthread*.so + fun:my_write + ... + fun:my_b_flush_io_cache + fun:_my_b_write + fun:_Z*10write_keysP13st_sort_paramPPhjP11st_io_cacheS4_ + fun:_Z*13find_all_keysP13st_sort_paramP10SQL_SELECTPPhP11st_io_cacheS6_S6_ + fun:_Z8filesortP3THDP5TABLEP13st_sort_fieldjP10SQL_SELECTybPy +} + +{ + Bug#12856915 VALGRIND FAILURE IN FILESORT/CREATE_SORT_INDEX / two + Memcheck:Param + write(buf) + obj:*/libpthread*.so + fun:my_write + ... + fun:my_b_flush_io_cache + fun:_Z15merge_many_buffP13st_sort_paramPhP10st_buffpekPjP11st_io_cache + fun:_Z8filesortP3THDP5TABLEP13st_sort_fieldjP10SQL_SELECTybPy +} + +{ + Bug#12856915 VALGRIND FAILURE IN FILESORT/CREATE_SORT_INDEX / three + Memcheck:Param + write(buf) + obj:*/libpthread*.so + fun:my_write + ... + fun:my_b_flush_io_cache + fun:_Z8filesortP3THDP5TABLEP13st_sort_fieldjP10SQL_SELECTybPy +} diff --git a/mysys/CMakeLists.txt b/mysys/CMakeLists.txt index c1b9efea0e2..5837764a171 100644 --- a/mysys/CMakeLists.txt +++ b/mysys/CMakeLists.txt @@ -1,4 +1,4 @@ -# Copyright (c) 2006, 2010, Oracle and/or its affiliates. All rights reserved. +# Copyright (c) 2006, 2011, Oracle and/or its affiliates. All rights reserved. # # 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/mysys/array.c b/mysys/array.c index d5a4a6fa284..c969da83586 100644 --- a/mysys/array.c +++ b/mysys/array.c @@ -1,4 +1,4 @@ -/* Copyright (C) 2000 MySQL AB +/* Copyright (c) 2000, 2010, Oracle and/or its affiliates. All rights reserved. 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 @@ -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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ /* Handling of arrays that can grow dynamicly. */ diff --git a/mysys/base64.c b/mysys/base64.c index ab66715c929..b48bcb85e03 100644 --- a/mysys/base64.c +++ b/mysys/base64.c @@ -1,4 +1,5 @@ -/* Copyright (C) 2003 MySQL AB +/* Copyright (c) 2003-2008 MySQL AB, 2009 Sun Microsystems, Inc. + Use is subject to license terms. 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 @@ -11,7 +12,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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ #include <my_global.h> #include <m_string.h> /* strchr() */ diff --git a/mysys/charset-def.c b/mysys/charset-def.c index 703cd8568e0..11416f11c06 100644 --- a/mysys/charset-def.c +++ b/mysys/charset-def.c @@ -1,4 +1,5 @@ -/* Copyright (C) 2000 MySQL AB +/* Copyright (c) 2000, 2003-2007 MySQL AB, 2009, 2010 Sun Microsystems, Inc. + Use is subject to license terms. 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 @@ -11,7 +12,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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ #include "mysys_priv.h" diff --git a/mysys/charset.c b/mysys/charset.c index 98b87ba9feb..e3c5c945500 100644 --- a/mysys/charset.c +++ b/mysys/charset.c @@ -1,4 +1,4 @@ -/* Copyright (C) 2000 MySQL AB, 2008-2009 Sun Microsystems, Inc +/* Copyright (c) 2000, 2011, Oracle and/or its affiliates. All rights reserved. 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 @@ -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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ #include "mysys_priv.h" #include "mysys_err.h" diff --git a/mysys/checksum.c b/mysys/checksum.c index c8d3c1a038d..7bc52c6a178 100644 --- a/mysys/checksum.c +++ b/mysys/checksum.c @@ -1,4 +1,4 @@ -/* Copyright (C) 2000 MySQL AB +/* Copyright (c) 2000, 2010, Oracle and/or its affiliates. All rights reserved. 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 @@ -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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ #include <my_global.h> diff --git a/mysys/errors.c b/mysys/errors.c index 2a9b3e770d2..fe0122c2e94 100644 --- a/mysys/errors.c +++ b/mysys/errors.c @@ -1,4 +1,4 @@ -/* Copyright (C) 2000 MySQL AB +/* Copyright (c) 2000, 2010, Oracle and/or its affiliates. All rights reserved. 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 @@ -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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ #include "mysys_priv.h" #include "mysys_err.h" diff --git a/mysys/hash.c b/mysys/hash.c index 38914d5f350..b93f6b666d6 100644 --- a/mysys/hash.c +++ b/mysys/hash.c @@ -1,4 +1,4 @@ -/* Copyright 2000-2008 MySQL AB, 2008 Sun Microsystems, Inc. +/* Copyright (c) 2000, 2010, Oracle and/or its affiliates. All rights reserved. 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 @@ -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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ /* The hash functions used for saveing keys */ /* One of key_length or key_length_offset must be given */ diff --git a/mysys/lf_alloc-pin.c b/mysys/lf_alloc-pin.c index ab88828d2f6..5eda20c3236 100644 --- a/mysys/lf_alloc-pin.c +++ b/mysys/lf_alloc-pin.c @@ -1,5 +1,5 @@ /* QQ: TODO multi-pinbox */ -/* Copyright (C) 2006-2008 MySQL AB, 2008-2009 Sun Microsystems, Inc. +/* Copyright (c) 2006, 2011, Oracle and/or its affiliates. All rights reserved. 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 @@ -12,7 +12,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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ /* wait-free concurrent allocator based on pinning addresses diff --git a/mysys/lf_dynarray.c b/mysys/lf_dynarray.c index 0941c8762bb..3d072fd063e 100644 --- a/mysys/lf_dynarray.c +++ b/mysys/lf_dynarray.c @@ -1,4 +1,4 @@ -/* Copyright (C) 2006 MySQL AB +/* Copyright (c) 2006, 2010, Oracle and/or its affiliates. All rights reserved. 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 @@ -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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ /* Analog of DYNAMIC_ARRAY that never reallocs diff --git a/mysys/lf_hash.c b/mysys/lf_hash.c index 2c89f5ca7ca..28e97192f18 100644 --- a/mysys/lf_hash.c +++ b/mysys/lf_hash.c @@ -1,4 +1,4 @@ -/* Copyright (C) 2006-2008 MySQL AB, 2008-2009 Sun Microsystems, Inc. +/* Copyright (c) 2006, 2010, Oracle and/or its affiliates. All rights reserved. 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 @@ -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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ /* extensible hash diff --git a/mysys/list.c b/mysys/list.c index e68fbf519d1..fb46120db04 100644 --- a/mysys/list.c +++ b/mysys/list.c @@ -1,4 +1,4 @@ -/* Copyright (C) 2000 MySQL AB +/* Copyright (c) 2000, 2010, Oracle and/or its affiliates. All rights reserved. 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 @@ -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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ /* Code for handling dubble-linked lists in C diff --git a/mysys/ma_dyncol.c b/mysys/ma_dyncol.c index 0901fe6bea1..c717f69c3e5 100644 --- a/mysys/ma_dyncol.c +++ b/mysys/ma_dyncol.c @@ -238,7 +238,7 @@ dynamic_column_uint_read(DYNAMIC_COLUMN_VALUE *store_it_here, for (i= 0; i < length; i++) value+= ((ulonglong)data[i]) << (i*8); - store_it_here->ulong_value= value; + store_it_here->x.ulong_value= value; return ER_DYNCOL_OK; } @@ -297,12 +297,12 @@ dynamic_column_sint_read(DYNAMIC_COLUMN_VALUE *store_it_here, { ulonglong val; dynamic_column_uint_read(store_it_here, data, length); - val= store_it_here->ulong_value; + val= store_it_here->x.ulong_value; if (val & 1) val= (val >> 1) ^ ULL(0xffffffffffffffff); else val>>= 1; - store_it_here->long_value= (longlong) val; + store_it_here->x.long_value= (longlong) val; return ER_DYNCOL_OK; } @@ -324,30 +324,30 @@ dynamic_column_value_len(DYNAMIC_COLUMN_VALUE *value) case DYN_COL_NULL: return 0; case DYN_COL_INT: - return dynamic_column_sint_bytes(value->long_value); + return dynamic_column_sint_bytes(value->x.long_value); case DYN_COL_UINT: - return dynamic_column_uint_bytes(value->ulong_value); + return dynamic_column_uint_bytes(value->x.ulong_value); case DYN_COL_DOUBLE: return 8; case DYN_COL_STRING: - return (dynamic_column_var_uint_bytes(value->charset->number) + - value->string_value.length); + return (dynamic_column_var_uint_bytes(value->x.string.charset->number) + + value->x.string.value.length); case DYN_COL_DECIMAL: { - int precision= value->decimal_value.intg + value->decimal_value.frac; - int scale= value->decimal_value.frac; + int precision= value->x.decimal.value.intg + value->x.decimal.value.frac; + int scale= value->x.decimal.value.frac; - if (precision == 0 || decimal_is_zero(&value->decimal_value)) + if (precision == 0 || decimal_is_zero(&value->x.decimal.value)) { /* This is here to simplify dynamic_column_decimal_store() */ - value->decimal_value.intg= value->decimal_value.frac= 0; + value->x.decimal.value.intg= value->x.decimal.value.frac= 0; return 0; } /* Check if legal decimal; This is needed to not get an assert in decimal_bin_size(). However this should be impossible as all decimals entered here should be valid and we have the special check - above to handle the unlikely but possible case that decimal_value.intg + above to handle the unlikely but possible case that decimal.value.intg and decimal.frac is 0. */ if (scale < 0 || precision <= 0) @@ -355,8 +355,8 @@ dynamic_column_value_len(DYNAMIC_COLUMN_VALUE *value) DBUG_ASSERT(0); /* Impossible */ return (size_t) ~0; } - return (dynamic_column_var_uint_bytes(value->decimal_value.intg) + - dynamic_column_var_uint_bytes(value->decimal_value.frac) + + return (dynamic_column_var_uint_bytes(value->x.decimal.value.intg) + + dynamic_column_var_uint_bytes(value->x.decimal.value.frac) + decimal_bin_size(precision, scale)); } case DYN_COL_DATETIME: @@ -410,7 +410,7 @@ dynamic_column_double_read(DYNAMIC_COLUMN_VALUE *store_it_here, { if (length != 8) return ER_DYNCOL_FORMAT; - float8get(store_it_here->double_value, data); + float8get(store_it_here->x.double_value, data); return ER_DYNCOL_OK; } @@ -455,12 +455,12 @@ dynamic_column_string_read(DYNAMIC_COLUMN_VALUE *store_it_here, uint charset_nr= (uint)dynamic_column_var_uint_get(data, length, &len); if (len == 0) /* Wrong packed number */ return ER_DYNCOL_FORMAT; - store_it_here->charset= get_charset(charset_nr, MYF(MY_WME)); - if (store_it_here->charset == NULL) + store_it_here->x.string.charset= get_charset(charset_nr, MYF(MY_WME)); + if (store_it_here->x.string.charset == NULL) return ER_DYNCOL_UNKNOWN_CHARSET; data+= len; - store_it_here->string_value.length= (length-= len); - store_it_here->string_value.str= (char*) data; + store_it_here->x.string.value.length= (length-= len); + store_it_here->x.string.value.str= (char*) data; return ER_DYNCOL_OK; } @@ -508,11 +508,11 @@ dynamic_column_decimal_store(DYNAMIC_COLUMN *str, void dynamic_column_prepare_decimal(DYNAMIC_COLUMN_VALUE *value) { - value->decimal_value.buf= value->decimal_buffer; - value->decimal_value.len= DECIMAL_BUFF_LENGTH; + value->x.decimal.value.buf= value->x.decimal.buffer; + value->x.decimal.value.len= DECIMAL_BUFF_LENGTH; /* just to be safe */ value->type= DYN_COL_DECIMAL; - decimal_make_zero(&value->decimal_value); + decimal_make_zero(&value->x.decimal.value); } @@ -553,7 +553,7 @@ dynamic_column_decimal_read(DYNAMIC_COLUMN_VALUE *store_it_here, (int) (length - intg_len - frac_len)) return ER_DYNCOL_FORMAT; - if (bin2decimal(data, &store_it_here->decimal_value, precision, scale) != + if (bin2decimal(data, &store_it_here->x.decimal.value, precision, scale) != E_DEC_OK) return ER_DYNCOL_FORMAT; return ER_DYNCOL_OK; @@ -607,14 +607,14 @@ dynamic_column_date_time_read(DYNAMIC_COLUMN_VALUE *store_it_here, */ if (length != 9) goto err; - store_it_here->time_value.time_type= MYSQL_TIMESTAMP_DATETIME; + store_it_here->x.time_value.time_type= MYSQL_TIMESTAMP_DATETIME; if ((rc= dynamic_column_date_read_internal(store_it_here, data, 3)) || (rc= dynamic_column_time_read_internal(store_it_here, data + 3, 6))) goto err; return ER_DYNCOL_OK; err: - store_it_here->time_value.time_type= MYSQL_TIMESTAMP_ERROR; + store_it_here->x.time_value.time_type= MYSQL_TIMESTAMP_ERROR; return rc; } @@ -682,9 +682,9 @@ static enum enum_dyncol_func_result dynamic_column_time_read(DYNAMIC_COLUMN_VALUE *store_it_here, uchar *data, size_t length) { - store_it_here->time_value.year= store_it_here->time_value.month= - store_it_here->time_value.day= 0; - store_it_here->time_value.time_type= MYSQL_TIMESTAMP_TIME; + store_it_here->x.time_value.year= store_it_here->x.time_value.month= + store_it_here->x.time_value.day= 0; + store_it_here->x.time_value.time_type= MYSQL_TIMESTAMP_TIME; return dynamic_column_time_read_internal(store_it_here, data, length); } @@ -709,23 +709,23 @@ dynamic_column_time_read_internal(DYNAMIC_COLUMN_VALUE *store_it_here, 1123456789012345612345612345678901234567890 <123456><123456><123456><123456><123456><123456> */ - store_it_here->time_value.second_part= (data[0] | + store_it_here->x.time_value.second_part= (data[0] | (data[1] << 8) | ((data[2] & 0xf) << 16)); - store_it_here->time_value.second= ((data[2] >> 4) | + store_it_here->x.time_value.second= ((data[2] >> 4) | ((data[3] & 0x3) << 4)); - store_it_here->time_value.minute= (data[3] >> 2); - store_it_here->time_value.hour= (((((uint)data[5]) & 0x3 ) << 8) | data[4]); - store_it_here->time_value.neg= ((data[5] & 0x4) ? 1 : 0); - if (store_it_here->time_value.second > 59 || - store_it_here->time_value.minute > 59 || - store_it_here->time_value.hour > 838 || - store_it_here->time_value.second_part > 999999) + store_it_here->x.time_value.minute= (data[3] >> 2); + store_it_here->x.time_value.hour= (((((uint)data[5]) & 0x3 ) << 8) | data[4]); + store_it_here->x.time_value.neg= ((data[5] & 0x4) ? 1 : 0); + if (store_it_here->x.time_value.second > 59 || + store_it_here->x.time_value.minute > 59 || + store_it_here->x.time_value.hour > 838 || + store_it_here->x.time_value.second_part > 999999) goto err; return ER_DYNCOL_OK; err: - store_it_here->time_value.time_type= MYSQL_TIMESTAMP_ERROR; + store_it_here->x.time_value.time_type= MYSQL_TIMESTAMP_ERROR; return ER_DYNCOL_FORMAT; } @@ -783,12 +783,12 @@ static enum enum_dyncol_func_result dynamic_column_date_read(DYNAMIC_COLUMN_VALUE *store_it_here, uchar *data, size_t length) { - store_it_here->time_value.neg= 0; - store_it_here->time_value.second_part= 0; - store_it_here->time_value.hour= 0; - store_it_here->time_value.minute= 0; - store_it_here->time_value.second= 0; - store_it_here->time_value.time_type= MYSQL_TIMESTAMP_DATE; + store_it_here->x.time_value.neg= 0; + store_it_here->x.time_value.second_part= 0; + store_it_here->x.time_value.hour= 0; + store_it_here->x.time_value.minute= 0; + store_it_here->x.time_value.second= 0; + store_it_here->x.time_value.time_type= MYSQL_TIMESTAMP_DATE; return dynamic_column_date_read_internal(store_it_here, data, length); } @@ -814,19 +814,19 @@ dynamic_column_date_read_internal(DYNAMIC_COLUMN_VALUE *store_it_here, 12345678901234123412345 <123456><123456><123456> */ - store_it_here->time_value.day= (data[0] & 0x1f); - store_it_here->time_value.month= (((data[1] & 0x1) << 3) | + store_it_here->x.time_value.day= (data[0] & 0x1f); + store_it_here->x.time_value.month= (((data[1] & 0x1) << 3) | (data[0] >> 5)); - store_it_here->time_value.year= ((((uint)data[2]) << 7) | + store_it_here->x.time_value.year= ((((uint)data[2]) << 7) | (data[1] >> 1)); - if (store_it_here->time_value.day > 31 || - store_it_here->time_value.month > 12 || - store_it_here->time_value.year > 9999) + if (store_it_here->x.time_value.day > 31 || + store_it_here->x.time_value.month > 12 || + store_it_here->x.time_value.year > 9999) goto err; return ER_DYNCOL_OK; err: - store_it_here->time_value.time_type= MYSQL_TIMESTAMP_ERROR; + store_it_here->x.time_value.time_type= MYSQL_TIMESTAMP_ERROR; return ER_DYNCOL_FORMAT; } @@ -845,25 +845,25 @@ data_store(DYNAMIC_COLUMN *str, DYNAMIC_COLUMN_VALUE *value) { switch (value->type) { case DYN_COL_INT: - return dynamic_column_sint_store(str, value->long_value); + return dynamic_column_sint_store(str, value->x.long_value); case DYN_COL_UINT: - return dynamic_column_uint_store(str, value->ulong_value); + return dynamic_column_uint_store(str, value->x.ulong_value); case DYN_COL_DOUBLE: - return dynamic_column_double_store(str, value->double_value); + return dynamic_column_double_store(str, value->x.double_value); case DYN_COL_STRING: - return dynamic_column_string_store(str, &value->string_value, - value->charset); + return dynamic_column_string_store(str, &value->x.string.value, + value->x.string.charset); case DYN_COL_DECIMAL: - return dynamic_column_decimal_store(str, &value->decimal_value); + return dynamic_column_decimal_store(str, &value->x.decimal.value); case DYN_COL_DATETIME: /* date+time in bits: 14 + 4 + 5 + 5 + 6 + 6 40bits = 5 bytes */ - return dynamic_column_date_time_store(str, &value->time_value); + return dynamic_column_date_time_store(str, &value->x.time_value); case DYN_COL_DATE: /* date in dits: 14 + 4 + 5 = 23bits ~= 3bytes*/ - return dynamic_column_date_store(str, &value->time_value); + return dynamic_column_date_store(str, &value->x.time_value); case DYN_COL_TIME: /* time in bits: 5 + 6 + 6 = 17bits ~= 3bytes*/ - return dynamic_column_time_store(str, &value->time_value); + return dynamic_column_time_store(str, &value->x.time_value); case DYN_COL_NULL: break; /* Impossible */ } @@ -1741,11 +1741,10 @@ dynamic_column_update_many(DYNAMIC_COLUMN *str, uint i, j, k; uint new_column_count, column_count, not_null; enum enum_dyncol_func_result rc; - int header_delta, header_delta_sign, data_delta_sign; + int header_delta; size_t offset_size, entry_size, header_size, data_size; size_t new_offset_size, new_entry_size, new_header_size, new_data_size; size_t max_offset; - my_bool copy; if (add_column_count == 0) return ER_DYNCOL_OK; @@ -1876,7 +1875,7 @@ dynamic_column_update_many(DYNAMIC_COLUMN *str, if (plan[i].val->type == DYN_COL_NULL) { - plan[i].act= PLAN_NOP; /* Mark entry to be skiped */ + plan[i].act= PLAN_NOP; /* Mark entry to be skiped */ } else { @@ -1913,17 +1912,17 @@ dynamic_column_update_many(DYNAMIC_COLUMN *str, goto end; } +#ifdef NOT_IMPLEMENTED /* if (new_offset_size != offset_size) then we have to rewrite header */ header_delta_sign= new_offset_size - offset_size; data_delta_sign= 0; - copy= FALSE; for (i= 0; i < add_column_count; i++) { /* This is the check for increasing/decreasing */ DELTA_CHECK(header_delta_sign, plan[i].hdelta, copy); DELTA_CHECK(data_delta_sign, plan[i].ddelta, copy); } - +#endif calc_param(&new_entry_size, &new_header_size, new_offset_size, new_column_count); diff --git a/mysys/mf_cache.c b/mysys/mf_cache.c index 691532c0d80..545084ea97f 100644 --- a/mysys/mf_cache.c +++ b/mysys/mf_cache.c @@ -1,4 +1,4 @@ -/* Copyright (C) 2000 MySQL AB +/* Copyright (c) 2000, 2010, Oracle and/or its affiliates. All rights reserved. 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 @@ -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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ /* Open a temporary file and cache it with io_cache. Delete it on close */ diff --git a/mysys/mf_dirname.c b/mysys/mf_dirname.c index 5a9440483e4..569293f5401 100644 --- a/mysys/mf_dirname.c +++ b/mysys/mf_dirname.c @@ -1,4 +1,4 @@ -/* Copyright (C) 2000 MySQL AB +/* Copyright (c) 2000, 2010, Oracle and/or its affiliates. All rights reserved. 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 @@ -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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ #include "mysys_priv.h" #include <m_string.h> diff --git a/mysys/mf_fn_ext.c b/mysys/mf_fn_ext.c index c872f2993c4..47fc67cabbd 100644 --- a/mysys/mf_fn_ext.c +++ b/mysys/mf_fn_ext.c @@ -1,4 +1,4 @@ -/* Copyright (C) 2000 MySQL AB +/* Copyright (c) 2000, 2010, Oracle and/or its affiliates. All rights reserved. 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 @@ -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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ #include "mysys_priv.h" diff --git a/mysys/mf_format.c b/mysys/mf_format.c index 74f114a966f..2b2356c08df 100644 --- a/mysys/mf_format.c +++ b/mysys/mf_format.c @@ -1,4 +1,4 @@ -/* Copyright (C) 2000 MySQL AB +/* Copyright (c) 2000, 2011, Oracle and/or its affiliates. All rights reserved. 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 @@ -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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ #include "mysys_priv.h" #include <m_string.h> diff --git a/mysys/mf_getdate.c b/mysys/mf_getdate.c index 70278e64003..ed8544a23fe 100644 --- a/mysys/mf_getdate.c +++ b/mysys/mf_getdate.c @@ -1,4 +1,5 @@ -/* Copyright (C) 2000 MySQL AB +/* Copyright (c) 2000, 2004-2007 MySQL AB, 2009 Sun Microsystems, Inc. + Use is subject to license terms. 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 @@ -11,7 +12,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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ /* Get date in a printable form: yyyy-mm-dd hh:mm:ss */ diff --git a/mysys/mf_iocache.c b/mysys/mf_iocache.c index cde11f3cae5..c84a41bbec9 100644 --- a/mysys/mf_iocache.c +++ b/mysys/mf_iocache.c @@ -1,4 +1,4 @@ -/* Copyright (C) 2000 MySQL AB, 2008-2009 Sun Microsystems, Inc +/* Copyright (c) 2000, 2011, Oracle and/or its affiliates. All rights reserved. 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 @@ -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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ /* Cashing of files with only does (sequential) read or writes of fixed- @@ -168,11 +168,9 @@ int init_io_cache(IO_CACHE *info, File file, size_t cachesize, if ((pos == (my_off_t) -1) && (my_errno == ESPIPE)) { /* - This kind of object doesn't support seek() or tell(). Don't set a - flag that will make us again try to seek() later and fail. - */ - info->seek_not_done= 0; - /* + This kind of object doesn't support seek() or tell(). Don't set a + seek_not_done that will make us again try to seek() later and fail. + Additionally, if we're supposed to start somewhere other than the the beginning of whatever this file is, then somebody made a bad assumption. @@ -1755,7 +1753,7 @@ int my_b_flush_io_cache(IO_CACHE *info, */ if (!append_cache && info->seek_not_done) { /* File touched, do seek */ - if (mysql_file_seek(info->file, pos_in_file, MY_SEEK_SET, MYF(0)) == + if (mysql_file_seek(info->file, pos_in_file, MY_SEEK_SET, MYF(info->myflags & MY_WME)) == MY_FILEPOS_ERROR) { UNLOCK_APPEND_BUFFER; diff --git a/mysys/mf_iocache2.c b/mysys/mf_iocache2.c index 85631e9741b..3c23d0737e7 100644 --- a/mysys/mf_iocache2.c +++ b/mysys/mf_iocache2.c @@ -1,4 +1,4 @@ -/* Copyright (C) 2000 MySQL AB, 2008-2009 Sun Microsystems, Inc +/* Copyright (c) 2000, 2011, Oracle and/or its affiliates. All rights reserved. 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 @@ -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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ /* More functions to be used with IO_CACHE files diff --git a/mysys/mf_keycache.c b/mysys/mf_keycache.c index 80111b3245d..4321a3aa072 100644 --- a/mysys/mf_keycache.c +++ b/mysys/mf_keycache.c @@ -1,4 +1,4 @@ -/* Copyright (C) 2000 MySQL AB, 2008-2009 Sun Microsystems, Inc +/* Copyright (c) 2000, 2011, Oracle and/or its affiliates. All rights reserved. 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 @@ -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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ diff --git a/mysys/mf_keycaches.c b/mysys/mf_keycaches.c index 9ea5678da9a..7dbfc26a365 100644 --- a/mysys/mf_keycaches.c +++ b/mysys/mf_keycaches.c @@ -1,4 +1,5 @@ -/* Copyright (C) 2003-2007 MySQL AB +/* Copyright (c) 2003, 2011, Oracle and/or its affiliates. + Copyright (c) 2010, 2011, Monty Program Ab 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 @@ -11,7 +12,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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ /* Handling of multiple key caches diff --git a/mysys/mf_loadpath.c b/mysys/mf_loadpath.c index 510c72ffa38..0b24731f2a7 100644 --- a/mysys/mf_loadpath.c +++ b/mysys/mf_loadpath.c @@ -1,4 +1,4 @@ -/* Copyright (C) 2000 MySQL AB +/* Copyright (c) 2000, 2010, Oracle and/or its affiliates. All rights reserved. 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 @@ -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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ #include "mysys_priv.h" #include <m_string.h> diff --git a/mysys/mf_pack.c b/mysys/mf_pack.c index 790936461a4..18c9a38f0db 100644 --- a/mysys/mf_pack.c +++ b/mysys/mf_pack.c @@ -1,4 +1,4 @@ -/* Copyright (c) 2000, 2010, Oracle and/or its affiliates. All rights reserved. +/* Copyright (c) 2000, 2011, Oracle and/or its affiliates. All rights reserved. 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/mysys/mf_path.c b/mysys/mf_path.c index 92cb62e6827..725cf278f6f 100644 --- a/mysys/mf_path.c +++ b/mysys/mf_path.c @@ -1,4 +1,4 @@ -/* Copyright (C) 2000 MySQL AB +/* Copyright (c) 2000, 2010, Oracle and/or its affiliates. All rights reserved. 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 @@ -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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ #include "mysys_priv.h" #include <m_string.h> diff --git a/mysys/mf_sort.c b/mysys/mf_sort.c index a3e7465ead0..9ef02787716 100644 --- a/mysys/mf_sort.c +++ b/mysys/mf_sort.c @@ -1,4 +1,4 @@ -/* Copyright (C) 2000 MySQL AB +/* Copyright (c) 2000, 2010, Oracle and/or its affiliates. All rights reserved. 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 @@ -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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ /* Sort of string pointers in string-order with radix or qsort */ diff --git a/mysys/mf_tempdir.c b/mysys/mf_tempdir.c index c84987cfc96..eceb90bb619 100644 --- a/mysys/mf_tempdir.c +++ b/mysys/mf_tempdir.c @@ -1,4 +1,4 @@ -/* Copyright (C) 2000 MySQL AB, 2008-2009 Sun Microsystems, Inc +/* Copyright (c) 2000, 2010, Oracle and/or its affiliates. All rights reserved. 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 @@ -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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ #include "mysys_priv.h" #include <m_string.h> diff --git a/mysys/mf_tempfile.c b/mysys/mf_tempfile.c index e85124fb4c3..15482075c39 100644 --- a/mysys/mf_tempfile.c +++ b/mysys/mf_tempfile.c @@ -1,4 +1,4 @@ -/* Copyright (C) 2000 MySQL AB +/* Copyright (c) 2000, 2010, Oracle and/or its affiliates. All rights reserved. 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 @@ -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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ #include "mysys_priv.h" #include <m_string.h> diff --git a/mysys/mf_unixpath.c b/mysys/mf_unixpath.c index ee81aae4584..6777c27bc96 100644 --- a/mysys/mf_unixpath.c +++ b/mysys/mf_unixpath.c @@ -1,4 +1,4 @@ -/* Copyright (C) 2000 MySQL AB +/* Copyright (c) 2000, 2010, Oracle and/or its affiliates. All rights reserved. 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 @@ -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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ #include "mysys_priv.h" #include <m_string.h> diff --git a/mysys/my_alloc.c b/mysys/my_alloc.c index 923e00d2182..f2bd029e522 100644 --- a/mysys/my_alloc.c +++ b/mysys/my_alloc.c @@ -1,4 +1,4 @@ -/* Copyright (C) 2000 MySQL AB +/* Copyright (c) 2000, 2010, Oracle and/or its affiliates. All rights reserved. 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 @@ -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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ /* Routines to handle mallocing of results which will be freed the same time */ diff --git a/mysys/my_atomic.c b/mysys/my_atomic.c index 7cbe15cfb74..26348b518ae 100644 --- a/mysys/my_atomic.c +++ b/mysys/my_atomic.c @@ -1,4 +1,4 @@ -/* Copyright (C) 2006 MySQL AB, 2008-2009 Sun Microsystems, Inc +/* Copyright (c) 2006, 2010, Oracle and/or its affiliates. All rights reserved. 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 @@ -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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ #include <my_global.h> #include <my_sys.h> diff --git a/mysys/my_bit.c b/mysys/my_bit.c index f072f243765..d36f52bb3c0 100644 --- a/mysys/my_bit.c +++ b/mysys/my_bit.c @@ -1,4 +1,4 @@ -/* Copyright (C) 2000 MySQL AB +/* Copyright (c) 2000, 2010, Oracle and/or its affiliates. All rights reserved. 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 @@ -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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ #include <my_global.h> diff --git a/mysys/my_bitmap.c b/mysys/my_bitmap.c index 8f86e5832f6..8328efea8ac 100644 --- a/mysys/my_bitmap.c +++ b/mysys/my_bitmap.c @@ -1,6 +1,6 @@ -/* Copyright (C) 2000 MySQL AB - Copyright (c) 2000, 2011, Oracle and/or its affiliates. - Copyright (C) 2009- 2011 Monty Program Ab +/* + Copyright (c) 2001, 2011, Oracle and/or its affiliates. + Copyright (C) 2009, 2011, Monty Program Ab 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 @@ -96,6 +96,44 @@ void create_last_word_mask(MY_BITMAP *map) } +static inline my_bitmap_map last_word_mask(uint bit) +{ + my_bitmap_map last_word_mask; + uint n_bits= bit + 1; + unsigned char const mask= invers_last_byte_mask(n_bits); + + /* + The first bytes are to be set to zero since they represent real bits + in the bitvector. The last bytes are set to 0xFF since they represent + bytes not used by the bitvector. Finally the last byte contains bits + as set by the mask above. + */ + unsigned char *ptr= (unsigned char*)&last_word_mask; + + switch ((n_bits + 7)/8 & 3) { + case 1: + last_word_mask= ~0U; + ptr[0]= mask; + break; + case 2: + last_word_mask= ~0U; + ptr[0]= 0; + ptr[1]= mask; + break; + case 3: + last_word_mask= 0U; + ptr[2]= mask; + ptr[3]= 0xFFU; + break; + case 0: + last_word_mask= 0U; + ptr[3]= mask; + break; + } + return last_word_mask; +} + + static inline void bitmap_lock(MY_BITMAP *map __attribute__((unused))) { if (map->mutex) @@ -380,6 +418,58 @@ void bitmap_intersect(MY_BITMAP *map, const MY_BITMAP *map2) } } + +/* + Check if there is some bit index between start_bit and end_bit, such that + this is bit is set for all bitmaps in bitmap_list. + + SYNOPSIS + bitmap_exists_intersection() + bitmpap_array [in] a set of MY_BITMAPs + bitmap_count [in] number of elements in bitmpap_array + start_bit [in] beginning (inclusive) of the range of bits to search + end_bit [in] end (inclusive) of the range of bits to search, must be + no bigger than the bits of the shortest bitmap. + + NOTES + This function assumes that for at least one of the bitmaps in bitmap_array all + bits outside the range [start_bit, end_bit] are 0. As a result is not + necessary to take care of the bits outside the range [start_bit, end_bit]. + + RETURN + TRUE if an intersecion exists + FALSE no intersection +*/ + +my_bool bitmap_exists_intersection(const MY_BITMAP **bitmap_array, + uint bitmap_count, + uint start_bit, uint end_bit) +{ + uint i, j, start_idx, end_idx; + my_bitmap_map cur_res; + + DBUG_ASSERT(bitmap_count && end_bit >= start_bit); + for (j= 0; j < bitmap_count; j++) + DBUG_ASSERT(end_bit < bitmap_array[j]->n_bits); + + start_idx= start_bit/8/sizeof(my_bitmap_map); + end_idx= end_bit/8/sizeof(my_bitmap_map); + + for (i= start_idx; i < end_idx; i++) + { + cur_res= ~0; + for (j= 0; cur_res && j < bitmap_count; j++) + cur_res &= bitmap_array[j]->bitmap[i]; + if (cur_res) + return TRUE; + } + cur_res= ~last_word_mask(end_bit); + for (j= 0; cur_res && j < bitmap_count; j++) + cur_res &= bitmap_array[j]->bitmap[end_idx]; + return cur_res != 0; +} + + /* True if union of bitmaps have all bits set */ my_bool bitmap_union_is_set_all(const MY_BITMAP *map1, const MY_BITMAP *map2) diff --git a/mysys/my_chsize.c b/mysys/my_chsize.c index b9013811b34..97ecd881af1 100644 --- a/mysys/my_chsize.c +++ b/mysys/my_chsize.c @@ -1,4 +1,5 @@ -/* Copyright (C) 2000 MySQL AB +/* Copyright (c) 2000-2007 MySQL AB, 2009 Sun Microsystems, Inc. + Use is subject to license terms. 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 @@ -11,7 +12,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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ #include "mysys_priv.h" #include "mysys_err.h" diff --git a/mysys/my_compress.c b/mysys/my_compress.c index 98f96f6b2b6..ea56900db05 100644 --- a/mysys/my_compress.c +++ b/mysys/my_compress.c @@ -1,4 +1,4 @@ -/* Copyright (C) 2000 MySQL AB +/* Copyright (c) 2000, 2010, Oracle and/or its affiliates. All rights reserved. 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 @@ -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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ /* Written by Sinisa Milivojevic <sinisa@mysql.com> */ diff --git a/mysys/my_copy.c b/mysys/my_copy.c index c2f4f53a780..802913b141f 100644 --- a/mysys/my_copy.c +++ b/mysys/my_copy.c @@ -1,4 +1,4 @@ -/* Copyright (C) 2000 MySQL AB +/* Copyright (c) 2000, 2010, Oracle and/or its affiliates. All rights reserved. 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 @@ -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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ #include "mysys_priv.h" #include "mysys_err.h" diff --git a/mysys/my_create.c b/mysys/my_create.c index 49529f9b7b5..2e4e8eb1af2 100644 --- a/mysys/my_create.c +++ b/mysys/my_create.c @@ -1,4 +1,5 @@ -/* Copyright (C) 2000 MySQL AB +/* Copyright (c) 2000, 2001, 2005-2008 MySQL AB, 2009 Sun Microsystems, Inc. + Use is subject to license terms. 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 @@ -11,7 +12,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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ #include "mysys_priv.h" #include <my_dir.h> diff --git a/mysys/my_delete.c b/mysys/my_delete.c index 4a23fedb5ab..cf9573f592b 100644 --- a/mysys/my_delete.c +++ b/mysys/my_delete.c @@ -1,4 +1,4 @@ -/* Copyright (C) 2000 MySQL AB +/* Copyright (c) 2000, 2010, Oracle and/or its affiliates. All rights reserved. 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 @@ -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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ #include "mysys_priv.h" #include "mysys_err.h" diff --git a/mysys/my_error.c b/mysys/my_error.c index 48b907d48cb..3302add688b 100644 --- a/mysys/my_error.c +++ b/mysys/my_error.c @@ -1,4 +1,4 @@ -/* Copyright (C) 2000 MySQL AB +/* Copyright (c) 2000, 2010, Oracle and/or its affiliates. All rights reserved. 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 @@ -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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ #include "mysys_priv.h" #include "mysys_err.h" diff --git a/mysys/my_file.c b/mysys/my_file.c index a6a4244a772..bb81fd5f06b 100644 --- a/mysys/my_file.c +++ b/mysys/my_file.c @@ -1,4 +1,4 @@ -/* Copyright (C) 2000 MySQL AB +/* Copyright (c) 2000, 2010, Oracle and/or its affiliates. All rights reserved. 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 @@ -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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ #include "mysys_priv.h" #include "my_static.h" diff --git a/mysys/my_fstream.c b/mysys/my_fstream.c index 83cb0d261c0..e758609741b 100644 --- a/mysys/my_fstream.c +++ b/mysys/my_fstream.c @@ -1,4 +1,4 @@ -/* Copyright (C) 2000 MySQL AB +/* Copyright (c) 2000, 2011, Oracle and/or its affiliates. All rights reserved. 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 @@ -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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ /* USE_MY_STREAM isn't set because we can't thrust my_fclose! */ diff --git a/mysys/my_gethwaddr.c b/mysys/my_gethwaddr.c index ab44bac43d3..4360daca6f8 100644 --- a/mysys/my_gethwaddr.c +++ b/mysys/my_gethwaddr.c @@ -1,4 +1,5 @@ -/* Copyright (C) 2004 MySQL AB +/* Copyright (c) 2004, 2010, Oracle and/or its affiliates. + Copyright (c) 2011, Monty Program Ab 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 @@ -11,7 +12,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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ /* get hardware address for an interface */ /* if there are many available, any non-zero one can be used */ @@ -21,8 +22,17 @@ #ifndef MAIN -#ifdef __FreeBSD__ +static my_bool memcpy_and_test(uchar *to, uchar *from, uint len) +{ + uint i, res= 1; + + for (i= 0; i < len; i++) + if ((*to++= *from++)) + res= 0; + return res; +} +#if defined(__APPLE__) || defined(__FreeBSD__) #include <net/ethernet.h> #include <sys/sysctl.h> #include <net/route.h> @@ -32,11 +42,10 @@ my_bool my_gethwaddr(uchar *to) { size_t len; - char *buf, *next, *end; + uchar *buf, *next, *end, *addr; struct if_msghdr *ifm; struct sockaddr_dl *sdl; - int res=1, mib[6]={CTL_NET, AF_ROUTE, 0, AF_LINK, NET_RT_IFLIST, 0}; - char zero_array[ETHER_ADDR_LEN] = {0}; + int res= 1, mib[6]= {CTL_NET, AF_ROUTE, 0, AF_LINK, NET_RT_IFLIST, 0}; if (sysctl(mib, 6, NULL, &len, NULL, 0) == -1) goto err; @@ -52,9 +61,9 @@ my_bool my_gethwaddr(uchar *to) ifm = (struct if_msghdr *)next; if (ifm->ifm_type == RTM_IFINFO) { - sdl= (struct sockaddr_dl *)(ifm + 1); - memcpy(to, LLADDR(sdl), ETHER_ADDR_LEN); - res= memcmp(to, zero_array, ETHER_ADDR_LEN) ? 0 : 1; + sdl = (struct sockaddr_dl *)(ifm + 1); + addr= (uchar *)LLADDR(sdl); + res= memcpy_and_test(to, addr, ETHER_ADDR_LEN); } } @@ -62,140 +71,97 @@ err: return res; } -#elif __linux__ - +#elif defined(__linux__) || defined(__sun__) #include <net/if.h> #include <sys/ioctl.h> -#include <net/ethernet.h> +#include <net/if_arp.h> +#ifdef HAVE_SYS_SOCKIO_H +#include <sys/sockio.h> +#endif + +#define ETHER_ADDR_LEN 6 my_bool my_gethwaddr(uchar *to) { int fd, res= 1; - struct ifreq ifr; - char zero_array[ETHER_ADDR_LEN] = {0}; + struct ifreq ifr[32]; + struct ifconf ifc; + + ifc.ifc_req= ifr; + ifc.ifc_len= sizeof(ifr); fd = socket(AF_INET, SOCK_DGRAM, 0); if (fd < 0) goto err; - bzero(&ifr, sizeof(ifr)); - strnmov(ifr.ifr_name, "eth0", sizeof(ifr.ifr_name) - 1); - - do + if (ioctl(fd, SIOCGIFCONF, (char*)&ifc) >= 0) { - if (ioctl(fd, SIOCGIFHWADDR, &ifr) >= 0) + uint i; + for (i= 0; res && i < ifc.ifc_len / sizeof(ifr[0]); i++) { - memcpy(to, &ifr.ifr_hwaddr.sa_data, ETHER_ADDR_LEN); - res= memcmp(to, zero_array, ETHER_ADDR_LEN) ? 0 : 1; +#ifdef SIOCGIFHWADDR + if (ioctl(fd, SIOCGIFHWADDR, &ifr[i]) >= 0) + res= memcpy_and_test(to, (uchar *)&ifr[i].ifr_hwaddr.sa_data, + ETHER_ADDR_LEN); +#else + /* + A bug in OpenSolaris prevents non-root from getting a mac address: + http://bugs.opensolaris.org/bugdatabase/view_bug.do?bug_id=4720634 + + Thus, we'll use an alternative method and extract the address from the + arp table. + */ + struct arpreq arpr; + arpr.arp_pa= ifr[i].ifr_addr; + + if (ioctl(fd, SIOCGARP, (char*)&arpr) >= 0) + res= memcpy_and_test(to, (uchar *)&arpr.arp_ha.sa_data, + ETHER_ADDR_LEN); +#endif } - } while (res && (errno == 0 || errno == ENODEV) && ifr.ifr_name[3]++ < '6'); + } close(fd); err: return res; } -#elif defined(__WIN__) - -/* - Workaround for BUG#32082 (Definition of VOID in my_global.h conflicts with - windows headers) -*/ -#ifdef VOID -#undef VOID -#define VOID void -#endif - +#elif defined(_WIN32) +#include <winsock2.h> #include <iphlpapi.h> -/* - The following typedef is for dynamically loading iphlpapi.dll / - GetAdaptersAddresses. Dynamic loading is used because - GetAdaptersAddresses is not available on Windows 2000 which MySQL - still supports. Static linking would cause an unresolved export. -*/ -typedef DWORD (WINAPI *pfnGetAdaptersAddresses)(IN ULONG Family, - IN DWORD Flags,IN PVOID Reserved, - OUT PIP_ADAPTER_ADDRESSES pAdapterAddresses, - IN OUT PULONG pOutBufLen); +#define ETHER_ADDR_LEN 6 -/* - my_gethwaddr - Windows version +my_bool my_gethwaddr(uchar *to) +{ + my_bool res= 1; - @brief Retrieve MAC address from network hardware + IP_ADAPTER_INFO *info= NULL; + ULONG info_len= 0; - @param[out] to MAC address exactly six bytes + if (GetAdaptersInfo(info, &info_len) != ERROR_BUFFER_OVERFLOW) + goto err; - @return Operation status - @retval 0 OK - @retval <>0 FAILED -*/ -my_bool my_gethwaddr(uchar *to) -{ - PIP_ADAPTER_ADDRESSES pAdapterAddresses; - PIP_ADAPTER_ADDRESSES pCurrAddresses; - IP_ADAPTER_ADDRESSES adapterAddresses; - ULONG address_len; - my_bool return_val= 1; - static pfnGetAdaptersAddresses fnGetAdaptersAddresses= - (pfnGetAdaptersAddresses)-1; - - if(fnGetAdaptersAddresses == (pfnGetAdaptersAddresses)-1) - { - /* Get the function from the DLL */ - fnGetAdaptersAddresses= (pfnGetAdaptersAddresses) - GetProcAddress(LoadLibrary("iphlpapi.dll"), - "GetAdaptersAddresses"); - } - if (!fnGetAdaptersAddresses) - return 1; /* failed to get function */ - address_len= sizeof (IP_ADAPTER_ADDRESSES); + info= alloca(info_len); - /* Get the required size for the address data. */ - if (fnGetAdaptersAddresses(AF_UNSPEC, 0, 0, &adapterAddresses, &address_len) - == ERROR_BUFFER_OVERFLOW) - { - pAdapterAddresses= my_malloc(address_len, 0); - if (!pAdapterAddresses) - return 1; /* error, alloc failed */ - } - else - pAdapterAddresses= &adapterAddresses; /* one is enough don't alloc */ + if (GetAdaptersInfo(info, &info_len) != NO_ERROR) + goto err; - /* Get the hardware info. */ - if (fnGetAdaptersAddresses(AF_UNSPEC, 0, 0, pAdapterAddresses, &address_len) - == NO_ERROR) + while (info && res) { - pCurrAddresses= pAdapterAddresses; - - while (pCurrAddresses) + if (info->Type == MIB_IF_TYPE_ETHERNET && + info->AddressLength == ETHER_ADDR_LEN) { - /* Look for ethernet cards. */ - if (pCurrAddresses->IfType == IF_TYPE_ETHERNET_CSMACD) - { - /* check for a good address */ - if (pCurrAddresses->PhysicalAddressLength < 6) - continue; /* bad address */ - - /* save 6 bytes of the address in the 'to' parameter */ - memcpy(to, pCurrAddresses->PhysicalAddress, 6); - - /* Network card found, we're done. */ - return_val= 0; - break; - } - pCurrAddresses= pCurrAddresses->Next; + res= memcpy_and_test(to, info->Address, ETHER_ADDR_LEN); } + info = info->Next; } - /* Clean up memory allocation. */ - if (pAdapterAddresses != &adapterAddresses) - my_free(pAdapterAddresses); - - return return_val; +err: + return res; } -#else /* __FreeBSD__ || __linux__ || __WIN__ */ +#else /* unsupported system */ /* just fail */ my_bool my_gethwaddr(uchar *to __attribute__((unused))) { @@ -214,7 +180,7 @@ int main(int argc __attribute__((unused)),char **argv) printf("my_gethwaddr failed with errno %d\n", errno); exit(1); } - for (i=0; i < sizeof(mac); i++) + for (i= 0; i < sizeof(mac); i++) { if (i) printf(":"); printf("%02x", mac[i]); diff --git a/mysys/my_getncpus.c b/mysys/my_getncpus.c index a7631e15966..a17d8812e04 100644 --- a/mysys/my_getncpus.c +++ b/mysys/my_getncpus.c @@ -1,4 +1,4 @@ -/* Copyright (C) 2006 MySQL AB, 2008-2009 Sun Microsystems, Inc +/* Copyright (c) 2006, 2010, Oracle and/or its affiliates. All rights reserved. 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 @@ -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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ /* get the number of (online) CPUs */ diff --git a/mysys/my_getopt.c b/mysys/my_getopt.c index d9e34cbece6..ea09370280e 100644 --- a/mysys/my_getopt.c +++ b/mysys/my_getopt.c @@ -395,10 +395,12 @@ int handle_options(int *argc, char ***argv, */ (*argc)--; if (!optend || *optend == '1' || - !my_strcasecmp(&my_charset_latin1, optend, "true")) + !my_strcasecmp(&my_charset_latin1, optend, "true") || + !my_strcasecmp(&my_charset_latin1, optend, "on")) *((my_bool*) value)= (my_bool) 1; else if (*optend == '0' || - !my_strcasecmp(&my_charset_latin1, optend, "false")) + !my_strcasecmp(&my_charset_latin1, optend, "false") || + !my_strcasecmp(&my_charset_latin1, optend, "off")) *((my_bool*) value)= (my_bool) 0; else { diff --git a/mysys/my_getwd.c b/mysys/my_getwd.c index ace14c8a3c9..3552081b85f 100644 --- a/mysys/my_getwd.c +++ b/mysys/my_getwd.c @@ -1,4 +1,4 @@ -/* Copyright (C) 2000 MySQL AB +/* Copyright (c) 2000, 2010, Oracle and/or its affiliates. All rights reserved. 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 @@ -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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ /* my_setwd() and my_getwd() works with intern_filenames !! */ diff --git a/mysys/my_handler_errors.h b/mysys/my_handler_errors.h index 8f2a8b750bd..42839fd31f5 100644 --- a/mysys/my_handler_errors.h +++ b/mysys/my_handler_errors.h @@ -1,6 +1,21 @@ #ifndef MYSYS_MY_HANDLER_ERRORS_INCLUDED #define MYSYS_MY_HANDLER_ERRORS_INCLUDED +/* Copyright (c) 2008, 2011, Oracle and/or its affiliates. All rights reserved. + + 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 + the Free Software Foundation; version 2 of the License. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + 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 02110-1301 USA */ + /* Errors a handler can give you */ @@ -66,6 +81,8 @@ static const char *handler_error_messages[]= "Read page with wrong checksum", "Too many active concurrent transactions", "Index column length exceeds limit", + "Index corrupted", + "Undo record too big", "Row is not visible by the current transaction", "Operation was interrupted by end user (probably kill command?)", "Disk full" diff --git a/mysys/my_init.c b/mysys/my_init.c index 580e29c381a..e366268936b 100644 --- a/mysys/my_init.c +++ b/mysys/my_init.c @@ -1,4 +1,4 @@ -/* Copyright (c) 2000, 2011 Oracle and/or its affiliates. All rights reserved. +/* Copyright (c) 2000, 2011, Oracle and/or its affiliates. All rights reserved. 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 @@ -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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ #include "mysys_priv.h" #include "my_static.h" @@ -75,6 +75,7 @@ my_bool my_init(void) mysys_usage_id++; my_umask= 0660; /* Default umask for new files */ my_umask_dir= 0700; /* Default umask for new directories */ + my_global_flags= 0; /* Default creation of new files */ if ((str= getenv("UMASK")) != 0) @@ -99,10 +100,6 @@ my_bool my_init(void) if (my_thread_global_init()) return 1; -#if defined(HAVE_PTHREAD_INIT) - pthread_init(); /* Must be called before DBUG_ENTER */ -#endif - /* $HOME is needed early to parse configuration files located in ~/ */ if ((home_dir= getenv("HOME")) != 0) home_dir= intern_filename(home_dir_buff, home_dir); diff --git a/mysys/my_largepage.c b/mysys/my_largepage.c index 9f5ab01a2b7..59f815a9d87 100644 --- a/mysys/my_largepage.c +++ b/mysys/my_largepage.c @@ -1,4 +1,4 @@ -/* Copyright (C) 2004 MySQL AB, 2008-2009 Sun Microsystems, Inc +/* Copyright (c) 2004, 2010, Oracle and/or its affiliates. All rights reserved. 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 @@ -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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ #include "mysys_priv.h" diff --git a/mysys/my_lib.c b/mysys/my_lib.c index 06f9521a664..b42a3d55d93 100644 --- a/mysys/my_lib.c +++ b/mysys/my_lib.c @@ -1,4 +1,4 @@ -/* Copyright (C) 2000 MySQL AB, 2008-2009 Sun Microsystems, Inc +/* Copyright (c) 2000, 2011, Oracle and/or its affiliates. All rights reserved. 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 @@ -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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ /* TODO: check for overun of memory for names. */ diff --git a/mysys/my_lock.c b/mysys/my_lock.c index 96abded4cc3..c9e599904fa 100644 --- a/mysys/my_lock.c +++ b/mysys/my_lock.c @@ -1,4 +1,4 @@ -/* Copyright (C) 2000-2003 MySQL AB, 2008-2009 Sun Microsystems, Inc +/* Copyright (c) 2000, 2010, Oracle and/or its affiliates. All rights reserved. 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 @@ -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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ #include "mysys_priv.h" #include "mysys_err.h" diff --git a/mysys/my_lockmem.c b/mysys/my_lockmem.c index a37db6b2089..8f06192d9f8 100644 --- a/mysys/my_lockmem.c +++ b/mysys/my_lockmem.c @@ -1,4 +1,4 @@ -/* Copyright (C) 2000 MySQL AB, 2008-2009 Sun Microsystems, Inc +/* Copyright (c) 2000, 2010, Oracle and/or its affiliates. All rights reserved. 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 @@ -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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ /* Alloc a block of locked memory */ diff --git a/mysys/my_malloc.c b/mysys/my_malloc.c index 2555c052fc3..24bccf37ece 100644 --- a/mysys/my_malloc.c +++ b/mysys/my_malloc.c @@ -30,6 +30,8 @@ void *my_malloc(size_t size, myf my_flags) void* point; DBUG_ENTER("my_malloc"); DBUG_PRINT("my",("size: %lu my_flags: %d", (ulong) size, my_flags)); + if (!(my_flags & (MY_WME | MY_FAE))) + my_flags|= my_global_flags; /* Safety */ if (!size) @@ -48,7 +50,9 @@ void *my_malloc(size_t size, myf my_flags) if (my_flags & MY_FAE) error_handler_hook=fatal_error_handler_hook; if (my_flags & (MY_FAE+MY_WME)) - my_error(EE_OUTOFMEMORY, MYF(ME_BELL+ME_WAITTANG+ME_NOREFRESH),size); + my_error(EE_OUTOFMEMORY, + MYF(ME_BELL | ME_WAITTANG | ME_NOREFRESH | (my_flags & ME_JUST_INFO)), + size); DBUG_EXECUTE_IF("simulate_out_of_memory", DBUG_SET("-d,simulate_out_of_memory");); if (my_flags & MY_FAE) diff --git a/mysys/my_mess.c b/mysys/my_mess.c index 513afe39054..8ee816b385a 100644 --- a/mysys/my_mess.c +++ b/mysys/my_mess.c @@ -1,4 +1,4 @@ -/* Copyright (C) 2000 MySQL AB +/* Copyright (c) 2000, 2010, Oracle and/or its affiliates. All rights reserved. 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 @@ -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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ #include "mysys_priv.h" diff --git a/mysys/my_mmap.c b/mysys/my_mmap.c index 82ee1562bc2..acd4862eaca 100644 --- a/mysys/my_mmap.c +++ b/mysys/my_mmap.c @@ -1,4 +1,4 @@ -/* Copyright (C) 2000-2003 MySQL AB +/* Copyright (c) 2000, 2010, Oracle and/or its affiliates. All rights reserved. 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 @@ -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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ #include "mysys_priv.h" diff --git a/mysys/my_new.cc b/mysys/my_new.cc index 7da54ffac87..377d9be22a8 100644 --- a/mysys/my_new.cc +++ b/mysys/my_new.cc @@ -1,4 +1,5 @@ -/* Copyright (C) 2000 MySQL AB +/* Copyright (c) 2000, 2001, 2003-2006 MySQL AB, 2009 Sun Microsystems, Inc. + Use is subject to license terms. 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 @@ -11,7 +12,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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ /* This is a replacement of new/delete operators to be used when compiling diff --git a/mysys/my_once.c b/mysys/my_once.c index 32d07802028..7df9b0a1981 100644 --- a/mysys/my_once.c +++ b/mysys/my_once.c @@ -1,4 +1,4 @@ -/* Copyright (C) 2000 MySQL AB +/* Copyright (c) 2000, 2010, Oracle and/or its affiliates. All rights reserved. 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 @@ -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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ /* Not MT-SAFE */ diff --git a/mysys/my_open.c b/mysys/my_open.c index bac0be46766..645d6709358 100644 --- a/mysys/my_open.c +++ b/mysys/my_open.c @@ -1,4 +1,4 @@ -/* Copyright (C) 2000 MySQL AB, 2008-2009 Sun Microsystems, Inc +/* Copyright (c) 2000, 2011, Oracle and/or its affiliates. All rights reserved. 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 @@ -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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ #include "mysys_priv.h" #include "mysys_err.h" @@ -41,6 +41,8 @@ File my_open(const char *FileName, int Flags, myf MyFlags) DBUG_ENTER("my_open"); DBUG_PRINT("my",("Name: '%s' Flags: %d MyFlags: %d", FileName, Flags, MyFlags)); + if (!(MyFlags & (MY_WME | MY_FAE | MY_FFNF))) + MyFlags|= my_global_flags; #if defined(_WIN32) fd= my_win_open(FileName, Flags); #elif !defined(NO_OPEN_3) @@ -70,6 +72,8 @@ int my_close(File fd, myf MyFlags) int err; DBUG_ENTER("my_close"); DBUG_PRINT("my",("fd: %d MyFlags: %d",fd, MyFlags)); + if (!(MyFlags & (MY_WME | MY_FAE))) + MyFlags|= my_global_flags; mysql_mutex_lock(&THR_LOCK_open); #ifndef _WIN32 @@ -85,7 +89,8 @@ int my_close(File fd, myf MyFlags) DBUG_PRINT("error",("Got error %d on close",err)); my_errno=errno; if (MyFlags & (MY_FAE | MY_WME)) - my_error(EE_BADCLOSE, MYF(ME_BELL+ME_WAITTANG),my_filename(fd),errno); + my_error(EE_BADCLOSE, MYF(ME_BELL | ME_WAITTANG | (MyFlags & (ME_JUST_INFO | ME_NOREFRESH))), + my_filename(fd),errno); } if ((uint) fd < my_file_limit && my_file_info[fd].type != UNOPEN) { @@ -151,8 +156,8 @@ File my_register_filename(File fd, const char *FileName, enum file_type { if (my_errno == EMFILE) error_message_number= EE_OUT_OF_FILERESOURCES; - DBUG_PRINT("error",("print err: %d",error_message_number)); - my_error(error_message_number, MYF(ME_BELL+ME_WAITTANG), + my_error(error_message_number, + MYF(ME_BELL | ME_WAITTANG | (MyFlags & (ME_JUST_INFO | ME_NOREFRESH))), FileName, my_errno); } DBUG_RETURN(-1); diff --git a/mysys/my_pread.c b/mysys/my_pread.c index 9d513a08418..51b4c5f5599 100644 --- a/mysys/my_pread.c +++ b/mysys/my_pread.c @@ -1,4 +1,5 @@ -/* Copyright (C) 2000 MySQL AB +/* Copyright (c) 2000, 2011, Oracle and/or its affiliates. + Copyright (c) 2011, Monty Program Ab 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 @@ -11,7 +12,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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ #include "mysys_priv.h" #include "mysys_err.h" @@ -50,8 +51,13 @@ size_t my_pread(File Filedes, uchar *Buffer, size_t Count, my_off_t offset, int error= 0; DBUG_ENTER("my_pread"); + DBUG_PRINT("my",("fd: %d Seek: %llu Buffer: %p Count: %lu MyFlags: %d", Filedes, (ulonglong)offset, Buffer, (ulong)Count, MyFlags)); + + if (!(MyFlags & (MY_WME | MY_FAE | MY_FNABP))) + MyFlags|= my_global_flags; + for (;;) { errno= 0; /* Linux, Windows don't reset this on EOF/success */ @@ -78,11 +84,13 @@ size_t my_pread(File Filedes, uchar *Buffer, size_t Count, my_off_t offset, } if (MyFlags & (MY_WME | MY_FAE | MY_FNABP)) { - if (readbytes == (size_t) -1) - my_error(EE_READ, MYF(ME_BELL+ME_WAITTANG), - my_filename(Filedes),my_errno); - else if (MyFlags & (MY_NABP | MY_FNABP)) - my_error(EE_EOFERR, MYF(ME_BELL+ME_WAITTANG), + if (readbytes == (size_t) -1) + my_error(EE_READ, + MYF(ME_BELL | ME_WAITTANG | (MyFlags & (ME_JUST_INFO | ME_NOREFRESH))), + my_filename(Filedes),my_errno); + else if (MyFlags & (MY_NABP | MY_FNABP)) + my_error(EE_EOFERR, + MYF(ME_BELL | ME_WAITTANG | (MyFlags & (ME_JUST_INFO | ME_NOREFRESH))), my_filename(Filedes),my_errno); } if (readbytes == (size_t) -1 || (MyFlags & (MY_FNABP | MY_NABP))) @@ -126,6 +134,8 @@ size_t my_pwrite(int Filedes, const uchar *Buffer, size_t Count, Filedes, (ulonglong)offset, Buffer, (ulong)Count, MyFlags)); errors= 0; written= 0; + if (!(MyFlags & (MY_WME | MY_FAE | MY_FNABP))) + MyFlags|= my_global_flags; for (;;) { @@ -158,20 +168,19 @@ size_t my_pwrite(int Filedes, const uchar *Buffer, size_t Count, if ((writtenbytes && writtenbytes != (size_t) -1) || my_errno == EINTR) continue; /* Retry */ #endif + + /* Don't give a warning if it's ok that we only write part of the data */ if (MyFlags & (MY_NABP | MY_FNABP)) { if (MyFlags & (MY_WME | MY_FAE | MY_FNABP)) - { - my_error(EE_WRITE, MYF(ME_BELL | ME_WAITTANG), + my_error(EE_WRITE, MYF(ME_BELL | ME_WAITTANG | (MyFlags & (ME_JUST_INFO | ME_NOREFRESH))), my_filename(Filedes),my_errno); - } - DBUG_RETURN(MY_FILE_ERROR); /* Error on read */ + DBUG_RETURN(MY_FILE_ERROR); /* Error on write */ } - else - break; /* Return bytes written */ + break; /* Return bytes written */ } DBUG_EXECUTE_IF("check", my_seek(Filedes, -1, SEEK_SET, MYF(0));); if (MyFlags & (MY_NABP | MY_FNABP)) - DBUG_RETURN(0); /* Want only errors */ - DBUG_RETURN(writtenbytes+written); /* purecov: inspected */ + DBUG_RETURN(0); /* Want only errors */ + DBUG_RETURN(writtenbytes+written); /* purecov: inspected */ } /* my_pwrite */ diff --git a/mysys/my_pthread.c b/mysys/my_pthread.c index f0b3b1e8aef..d29cbcc5048 100644 --- a/mysys/my_pthread.c +++ b/mysys/my_pthread.c @@ -1,4 +1,4 @@ -/* Copyright (C) 2000-2003 MySQL AB, 2008-2009 Sun Microsystems, Inc +/* Copyright (c) 2000, 2011, Oracle and/or its affiliates. All rights reserved. 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 @@ -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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ /* Functions to get threads more portable */ diff --git a/mysys/my_quick.c b/mysys/my_quick.c index b93e7e17224..2d5e9fb95ca 100644 --- a/mysys/my_quick.c +++ b/mysys/my_quick.c @@ -1,4 +1,5 @@ -/* Copyright (C) 2000 MySQL AB +/* Copyright (c) 2000, 2006, 2007 MySQL AB, 2009 Sun Microsystems, Inc. + Use is subject to license terms. 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 @@ -11,7 +12,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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ /* Quicker interface to read & write. Used with my_nosys.h */ diff --git a/mysys/my_rdtsc.c b/mysys/my_rdtsc.c index 2afe3ec31dd..028c7f810d4 100644 --- a/mysys/my_rdtsc.c +++ b/mysys/my_rdtsc.c @@ -1,4 +1,4 @@ -/* Copyright (C) 2008-2010 Sun Microsystems, Inc +/* Copyright (c) 2008, 2010, Oracle and/or its affiliates. All rights reserved. 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 @@ -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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ /* rdtsc3 -- multi-platform timer code diff --git a/mysys/my_read.c b/mysys/my_read.c index dbe9006a1d3..0afbf3773f3 100644 --- a/mysys/my_read.c +++ b/mysys/my_read.c @@ -1,4 +1,4 @@ -/* Copyright (C) 2000 MySQL AB +/* Copyright (c) 2000, 2011, Oracle and/or its affiliates. All rights reserved. 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 @@ -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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ #include "mysys_priv.h" #include "mysys_err.h" @@ -40,6 +40,8 @@ size_t my_read(File Filedes, uchar *Buffer, size_t Count, myf MyFlags) DBUG_PRINT("my",("fd: %d Buffer: %p Count: %lu MyFlags: %d", Filedes, Buffer, (ulong) Count, MyFlags)); save_count= Count; + if (!(MyFlags & (MY_WME | MY_FAE | MY_FNABP))) + MyFlags|= my_global_flags; for (;;) { @@ -70,10 +72,12 @@ size_t my_read(File Filedes, uchar *Buffer, size_t Count, myf MyFlags) if (MyFlags & (MY_WME | MY_FAE | MY_FNABP)) { if (readbytes == (size_t) -1) - my_error(EE_READ, MYF(ME_BELL+ME_WAITTANG), + my_error(EE_READ, + MYF(ME_BELL | ME_WAITTANG | (MyFlags & (ME_JUST_INFO | ME_NOREFRESH))), my_filename(Filedes),my_errno); else if (MyFlags & (MY_NABP | MY_FNABP)) - my_error(EE_EOFERR, MYF(ME_BELL+ME_WAITTANG), + my_error(EE_EOFERR, + MYF(ME_BELL | ME_WAITTANG | (MyFlags & (ME_JUST_INFO | ME_NOREFRESH))), my_filename(Filedes),my_errno); } if (readbytes == (size_t) -1 || diff --git a/mysys/my_redel.c b/mysys/my_redel.c index 1b200568a47..7f4e95f4f74 100644 --- a/mysys/my_redel.c +++ b/mysys/my_redel.c @@ -1,4 +1,4 @@ -/* Copyright (C) 2000 MySQL AB +/* Copyright (c) 2000, 2010, Oracle and/or its affiliates. All rights reserved. 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 @@ -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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ #include "mysys_priv.h" #include "mysys_err.h" diff --git a/mysys/my_rename.c b/mysys/my_rename.c index 1a4e7b2b409..6704d7c87d0 100644 --- a/mysys/my_rename.c +++ b/mysys/my_rename.c @@ -1,4 +1,4 @@ -/* Copyright (C) 2000 MySQL AB +/* Copyright (c) 2000, 2010, Oracle and/or its affiliates. All rights reserved. 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 @@ -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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ #include "mysys_priv.h" #include <my_dir.h> diff --git a/mysys/my_seek.c b/mysys/my_seek.c index efe0416c49a..505aec0a3c0 100644 --- a/mysys/my_seek.c +++ b/mysys/my_seek.c @@ -1,4 +1,4 @@ -/* Copyright (C) 2000 MySQL AB +/* Copyright (c) 2000, 2010, Oracle and/or its affiliates. All rights reserved. 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 @@ -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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ #include "mysys_priv.h" #include "mysys_err.h" diff --git a/mysys/my_sleep.c b/mysys/my_sleep.c index 5a18a2854d6..77eb466aee8 100644 --- a/mysys/my_sleep.c +++ b/mysys/my_sleep.c @@ -1,4 +1,4 @@ -/* Copyright (C) 2000 MySQL AB +/* Copyright (c) 2000, 2010, Oracle and/or its affiliates. All rights reserved. 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 @@ -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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ /* Wait a given number of microseconds */ diff --git a/mysys/my_static.c b/mysys/my_static.c index 60e23e8dfa9..5b088704acc 100644 --- a/mysys/my_static.c +++ b/mysys/my_static.c @@ -1,4 +1,4 @@ -/* Copyright (C) 2000-2008 MySQL AB, 2008-2009 Sun Microsystems, Inc. +/* Copyright (c) 2000, 2011, Oracle and/or its affiliates. All rights reserved. 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 @@ -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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ /* Static variables for mysys library. All definied here for easy making of @@ -33,6 +33,8 @@ ulong my_stream_opened=0,my_file_opened=0, my_tmp_file_created=0; ulong my_file_total_opened= 0; int my_umask=0664, my_umask_dir=0777; +myf my_global_flags= 0; +my_bool my_assert_on_error= 0; struct st_my_file_info my_file_info_default[MY_NFILE]; uint my_file_limit= MY_NFILE; struct st_my_file_info *my_file_info= my_file_info_default; diff --git a/mysys/my_static.h b/mysys/my_static.h index 0f1cd34a04e..a44a4b26c3d 100644 --- a/mysys/my_static.h +++ b/mysys/my_static.h @@ -1,7 +1,7 @@ #ifndef MYSYS_MY_STATIC_INCLUDED #define MYSYS_MY_STATIC_INCLUDED -/* Copyright (C) 2000 MySQL AB +/* Copyright (c) 2000, 2010, Oracle and/or its affiliates. All rights reserved. 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 @@ -14,7 +14,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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ /* Static variables for mysys library. All definied here for easy making of diff --git a/mysys/my_symlink.c b/mysys/my_symlink.c index b001354275d..7fe7a92f54e 100644 --- a/mysys/my_symlink.c +++ b/mysys/my_symlink.c @@ -1,4 +1,4 @@ -/* Copyright (C) 2000 MySQL AB +/* Copyright (c) 2001, 2010, Oracle and/or its affiliates. All rights reserved. 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 @@ -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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ #include "mysys_priv.h" #include "mysys_err.h" @@ -147,22 +147,23 @@ int my_realpath(char *to, const char *filename, myf MyFlags) result= -1; } DBUG_RETURN(result); -#else -#ifdef _WIN32 +#elif defined(_WIN32) int ret= GetFullPathName(filename,FN_REFLEN, to, NULL); if (ret == 0 || ret > FN_REFLEN) { - if (ret > FN_REFLEN) - my_errno= ENAMETOOLONG; - else - my_errno= EACCES; + my_errno= (ret > FN_REFLEN) ? ENAMETOOLONG : GetLastError(); if (MyFlags & MY_WME) my_error(EE_REALPATH, MYF(0), filename, my_errno); + /* + GetFullPathName didn't work : use my_load_path() which is a poor + substitute original name but will at least be able to resolve + paths that starts with '.'. + */ + my_load_path(to, filename, NullS); return -1; } #else my_load_path(to, filename, NullS); #endif return 0; -#endif } diff --git a/mysys/my_sync.c b/mysys/my_sync.c index 4d187631786..a18f82bcf64 100644 --- a/mysys/my_sync.c +++ b/mysys/my_sync.c @@ -1,4 +1,4 @@ -/* Copyright (C) 2003 MySQL AB +/* Copyright (c) 2003, 2011, Oracle and/or its affiliates. All rights reserved. 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 @@ -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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ #include "mysys_priv.h" #include "mysys_err.h" diff --git a/mysys/my_thr_init.c b/mysys/my_thr_init.c index 121392be8c3..ee9bc91e910 100644 --- a/mysys/my_thr_init.c +++ b/mysys/my_thr_init.c @@ -1,4 +1,4 @@ -/* Copyright (c) 2000, 2011 Oracle and/or its affiliates. All rights reserved. +/* Copyright (c) 2000, 2011, Oracle and/or its affiliates. All rights reserved. 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 @@ -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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ /* Functions to handle initializating and allocationg of all mysys & debug diff --git a/mysys/my_timer_cycles.il b/mysys/my_timer_cycles.il index 2f3f776530b..e655cad2a2e 100644 --- a/mysys/my_timer_cycles.il +++ b/mysys/my_timer_cycles.il @@ -1,4 +1,5 @@ -/* Copyright (C) 2008 Sun Microsystems, Inc +/* Copyright (c) 2008 MySQL AB, 2009 Sun Microsystems, Inc. + Use is subject to license terms. 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 @@ -11,7 +12,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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ /* Sun Studio SPARC inline templates for cycle timer */ /* Sun Studio i386 and x86_64 inline templates for cycle timer */ diff --git a/mysys/my_wincond.c b/mysys/my_wincond.c index bed64230aea..f88e33e17f3 100644 --- a/mysys/my_wincond.c +++ b/mysys/my_wincond.c @@ -1,4 +1,4 @@ -/* Copyright (C) 2000 MySQL AB +/* Copyright (c) 2000, 2010, Oracle and/or its affiliates. All rights reserved. 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 @@ -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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ /***************************************************************************** ** The following is a simple implementation of posix conditions diff --git a/mysys/my_windac.c b/mysys/my_windac.c index 0c924188623..51fe22e8f59 100644 --- a/mysys/my_windac.c +++ b/mysys/my_windac.c @@ -1,4 +1,4 @@ -/* Copyright (C) 2000-2005 MySQL AB +/* Copyright (c) 2000, 2010, Oracle and/or its affiliates. All rights reserved. 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 @@ -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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ #include "mysys_priv.h" #include "m_string.h" diff --git a/mysys/my_winerr.c b/mysys/my_winerr.c index 534078b6737..15f52dd7f37 100644 --- a/mysys/my_winerr.c +++ b/mysys/my_winerr.c @@ -1,4 +1,5 @@ -/* Copyright (C) 2008 MySQL AB +/* Copyright (c) 2008 MySQL AB, 2009 Sun Microsystems, Inc. + Use is subject to license terms. 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 @@ -11,7 +12,7 @@ GNU General Public License for more details. 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ +Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ /* Convert Windows API error (GetLastError() to Posix equivalent (errno) diff --git a/mysys/my_winfile.c b/mysys/my_winfile.c index 4d80d774dad..ad87bf718d2 100644 --- a/mysys/my_winfile.c +++ b/mysys/my_winfile.c @@ -1,4 +1,4 @@ -/* Copyright (C) 2008 MySQL AB, 2008-2009 Sun Microsystems, Inc +/* Copyright (c) 2008, 2010, Oracle and/or its affiliates. All rights reserved. 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 @@ -11,7 +11,7 @@ GNU General Public License for more details. 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ +Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ /* The purpose of this file is to provide implementation of file IO routines on diff --git a/mysys/my_winthread.c b/mysys/my_winthread.c index 54b8463fe0b..d9f5149e6c9 100644 --- a/mysys/my_winthread.c +++ b/mysys/my_winthread.c @@ -1,4 +1,4 @@ -/* Copyright (C) 2000 MySQL AB, 2008-2009 Sun Microsystems, Inc +/* Copyright (c) 2000, 2010, Oracle and/or its affiliates. All rights reserved. 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 @@ -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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ /***************************************************************************** ** Simulation of posix threads calls for Windows diff --git a/mysys/my_write.c b/mysys/my_write.c index 46b0d749944..dc04b60f613 100644 --- a/mysys/my_write.c +++ b/mysys/my_write.c @@ -1,4 +1,4 @@ -/* Copyright (C) 2000 MySQL AB +/* Copyright (c) 2000, 2011, Oracle and/or its affiliates. All rights reserved. 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 @@ -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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ #include "mysys_priv.h" #include "mysys_err.h" @@ -28,6 +28,8 @@ size_t my_write(File Filedes, const uchar *Buffer, size_t Count, myf MyFlags) DBUG_PRINT("my",("fd: %d Buffer: %p Count: %lu MyFlags: %d", Filedes, Buffer, (ulong) Count, MyFlags)); errors= 0; written= 0; + if (!(MyFlags & (MY_WME | MY_FAE | MY_FNABP))) + MyFlags|= my_global_flags; /* The behavior of write(fd, buf, 0) is not portable */ if (unlikely(!Count)) @@ -87,19 +89,20 @@ size_t my_write(File Filedes, const uchar *Buffer, size_t Count, myf MyFlags) else continue; /* Retry */ #endif + + /* Don't give a warning if it's ok that we only write part of the data */ if (MyFlags & (MY_NABP | MY_FNABP)) { if (MyFlags & (MY_WME | MY_FAE | MY_FNABP)) { - my_error(EE_WRITE, MYF(ME_BELL+ME_WAITTANG), + my_error(EE_WRITE, MYF(ME_BELL | ME_WAITTANG | (MyFlags & (ME_JUST_INFO | ME_NOREFRESH))), my_filename(Filedes),my_errno); } DBUG_RETURN(MY_FILE_ERROR); /* Error on read */ } - else - break; /* Return bytes written */ + break; /* Return bytes written */ } if (MyFlags & (MY_NABP | MY_FNABP)) - DBUG_RETURN(0); /* Want only errors */ + DBUG_RETURN(0); /* Want only errors */ DBUG_RETURN(writtenbytes+written); } /* my_write */ diff --git a/mysys/mysys_priv.h b/mysys/mysys_priv.h index 2f669878f49..2c0c8bf82f8 100644 --- a/mysys/mysys_priv.h +++ b/mysys/mysys_priv.h @@ -1,4 +1,4 @@ -/* Copyright (C) 2000 MySQL AB, 2008-2009 Sun Microsystems, Inc +/* Copyright (c) 2000, 2011, Oracle and/or its affiliates. All rights reserved. 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 @@ -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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ #include <my_global.h> #include <my_sys.h> diff --git a/mysys/ptr_cmp.c b/mysys/ptr_cmp.c index dcafe13291d..6f9ab13c82b 100644 --- a/mysys/ptr_cmp.c +++ b/mysys/ptr_cmp.c @@ -1,4 +1,4 @@ -/* Copyright (C) 2000 MySQL AB +/* Copyright (c) 2000, 2010, Oracle and/or its affiliates. All rights reserved. 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 @@ -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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ /* get_ptr_compare(len) returns a pointer to a optimal byte-compare function diff --git a/mysys/rijndael.c b/mysys/rijndael.c index 2d622efad82..e893a886726 100644 --- a/mysys/rijndael.c +++ b/mysys/rijndael.c @@ -1,4 +1,4 @@ -/* Copyright (C) 2002, 2004 MySQL AB +/* Copyright (c) 2002, 2010, Oracle and/or its affiliates. All rights reserved. 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 @@ -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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ /* diff --git a/mysys/stacktrace.c b/mysys/stacktrace.c index c2e930d76e2..d0897fabb52 100644 --- a/mysys/stacktrace.c +++ b/mysys/stacktrace.c @@ -1,4 +1,4 @@ -/* Copyright (C) 2000 MySQL AB +/* Copyright (c) 2001, 2011, Oracle and/or its affiliates. All rights reserved. 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 @@ -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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ #include <my_global.h> #include <my_stacktrace.h> diff --git a/mysys/string.c b/mysys/string.c index fa669ceda3a..d9791341c60 100644 --- a/mysys/string.c +++ b/mysys/string.c @@ -1,4 +1,4 @@ -/* Copyright (C) 2000 MySQL AB +/* Copyright (c) 2000, 2010, Oracle and/or its affiliates. All rights reserved. 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 @@ -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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ /* Code for handling strings with can grow dynamicly. diff --git a/mysys/test_charset.c b/mysys/test_charset.c index 39df1b02d7b..49e25b8d5cd 100644 --- a/mysys/test_charset.c +++ b/mysys/test_charset.c @@ -1,4 +1,4 @@ -/* Copyright (C) 2000 MySQL AB +/* Copyright (c) 2000, 2010, Oracle and/or its affiliates. All rights reserved. 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 @@ -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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ #include <my_global.h> #include <m_ctype.h> diff --git a/mysys/testhash.c b/mysys/testhash.c index 376303f29be..ffdaaece770 100644 --- a/mysys/testhash.c +++ b/mysys/testhash.c @@ -1,4 +1,4 @@ -/* Copyright (C) 2000 MySQL AB +/* Copyright (c) 2000, 2010, Oracle and/or its affiliates. All rights reserved. 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 @@ -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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ /* Test of hash library: big test */ diff --git a/mysys/thr_alarm.c b/mysys/thr_alarm.c index f902057a71b..adce7407239 100644 --- a/mysys/thr_alarm.c +++ b/mysys/thr_alarm.c @@ -1,4 +1,4 @@ -/* Copyright (C) 2000 MySQL AB, 2008-2009 Sun Microsystems, Inc +/* Copyright (c) 2000, 2011, Oracle and/or its affiliates. All rights reserved. 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 @@ -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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ /* To avoid problems with alarms in debug code, we disable DBUG here */ #define FORCE_DBUG_OFF diff --git a/mysys/thr_lock.c b/mysys/thr_lock.c index b2e51cde260..61f18d9dddf 100644 --- a/mysys/thr_lock.c +++ b/mysys/thr_lock.c @@ -1,4 +1,4 @@ -/* Copyright (C) 2000 MySQL AB, 2008-2009 Sun Microsystems, Inc +/* Copyright (c) 2000, 2011, Oracle and/or its affiliates. All rights reserved. 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 @@ -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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ /* Read and write locks for Posix threads. All tread must acquire diff --git a/mysys/thr_mutex.c b/mysys/thr_mutex.c index 83395adaf61..d268fb618d5 100644 --- a/mysys/thr_mutex.c +++ b/mysys/thr_mutex.c @@ -1,4 +1,5 @@ -/* Copyright (C) 2000-2008 MySQL AB, 2008-2009 Sun Microsystems, Inc +/* Copyright (c) 2000, 2011, Oracle and/or its affiliates. + Copyright (c) 2010, 2011, Monty Program Ab 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 @@ -11,7 +12,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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ /* This makes a wrapper for mutex handling to make it easier to debug mutex */ @@ -835,6 +836,7 @@ static void print_deadlock_warning(safe_mutex_t *new_mutex, mutex_root->file, mutex_root->line)); } fflush(stderr); + DBUG_ASSERT(my_assert_on_error == 0); DBUG_VOID_RETURN; } diff --git a/mysys/thr_rwlock.c b/mysys/thr_rwlock.c index a6eb16a4b1b..17fafecd8fd 100644 --- a/mysys/thr_rwlock.c +++ b/mysys/thr_rwlock.c @@ -1,4 +1,4 @@ -/* Copyright (C) 2000 MySQL AB +/* Copyright (c) 2000, 2011, Oracle and/or its affiliates. All rights reserved. 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 @@ -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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ /* Synchronization - readers / writer thread locks */ diff --git a/mysys/tree.c b/mysys/tree.c index 03c4ac5b36b..85770194f25 100644 --- a/mysys/tree.c +++ b/mysys/tree.c @@ -1,4 +1,4 @@ -/* Copyright (C) 2000 MySQL AB +/* Copyright (c) 2000, 2010, Oracle and/or its affiliates. All rights reserved. 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 @@ -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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ /* Code for handling red-black (balanced) binary trees. diff --git a/packaging/WiX/CMakeLists.txt b/packaging/WiX/CMakeLists.txt index 4048273fc03..a5970703720 100644 --- a/packaging/WiX/CMakeLists.txt +++ b/packaging/WiX/CMakeLists.txt @@ -1,4 +1,4 @@ -# Copyright 2010, Oracle and/or its affiliates. All rights reserved. +# Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved. # # 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/packaging/WiX/CPackWixConfig.cmake b/packaging/WiX/CPackWixConfig.cmake index f49406b5787..9ebb2398a2b 100644 --- a/packaging/WiX/CPackWixConfig.cmake +++ b/packaging/WiX/CPackWixConfig.cmake @@ -1,3 +1,17 @@ +# Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.
+#
+# 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
+# the Free Software Foundation; version 2 of the License.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# 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 02110-1301 USA
IF(ESSENTIALS)
SET(CPACK_COMPONENTS_USED "Server;Client;DataFiles")
diff --git a/packaging/WiX/ca/CMakeLists.txt b/packaging/WiX/ca/CMakeLists.txt index 6872dc99d94..81622a1d158 100644 --- a/packaging/WiX/ca/CMakeLists.txt +++ b/packaging/WiX/ca/CMakeLists.txt @@ -1,4 +1,4 @@ -# Copyright 2010, Oracle and/or its affiliates. All rights reserved. +# Copyright (c) 2010, 2011, Oracle and/or its affiliates. All rights reserved. # # 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/packaging/WiX/ca/CustomAction.cpp b/packaging/WiX/ca/CustomAction.cpp index 806535bc79a..444e003c3f2 100644 --- a/packaging/WiX/ca/CustomAction.cpp +++ b/packaging/WiX/ca/CustomAction.cpp @@ -1,4 +1,4 @@ -/* Copyright 2010, Oracle and/or its affiliates. All rights reserved. +/* Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved. 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 @@ -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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ #ifndef UNICODE #define UNICODE diff --git a/packaging/WiX/create_msi.cmake.in b/packaging/WiX/create_msi.cmake.in index dd2e9fd9d85..8de271fc1cf 100644 --- a/packaging/WiX/create_msi.cmake.in +++ b/packaging/WiX/create_msi.cmake.in @@ -1,3 +1,18 @@ +# Copyright (c) 2010, 2011, Oracle and/or its affiliates. All rights reserved.
+#
+# 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
+# the Free Software Foundation; version 2 of the License.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# 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 02110-1301 USA
+
SET(CMAKE_BINARY_DIR "@CMAKE_BINARY_DIR@")
SET(CMAKE_CURRENT_SOURCE_DIR "@CMAKE_CURRENT_SOURCE_DIR@")
SET(CANDLE_EXECUTABLE "@CANDLE_EXECUTABLE@")
diff --git a/packaging/WiX/custom_ui.wxs b/packaging/WiX/custom_ui.wxs index 1dc1ef28e4f..a77612c4e50 100644 --- a/packaging/WiX/custom_ui.wxs +++ b/packaging/WiX/custom_ui.wxs @@ -1,5 +1,23 @@ <Include xmlns="http://schemas.microsoft.com/wix/2006/wi"
xmlns:util="http://schemas.microsoft.com/wix/UtilExtension">
+
+<!--
+ Copyright (c) 2010, 2011, Oracle and/or its affiliates. All rights reserved.
+
+ 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
+ the Free Software Foundation; version 2 of the License.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ 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 02110-1301 USA
+-->
+
<UI Id="WixUI_Mondo_Custom">
<Dialog Id="CustomWelcomeDlg" Width="370" Height="270" Title="[ProductName] Setup" NoMinimize="yes">
<Control Id="Cancel" Type="PushButton" X="304" Y="243" Width="56" Height="17" Cancel="yes" Text="!(loc.WixUICancel)">
diff --git a/packaging/WiX/extra.wxs.in b/packaging/WiX/extra.wxs.in index fe2e73c3340..91bf3f64b8e 100644 --- a/packaging/WiX/extra.wxs.in +++ b/packaging/WiX/extra.wxs.in @@ -1,6 +1,23 @@ <Include xmlns="http://schemas.microsoft.com/wix/2006/wi"
xmlns:util="http://schemas.microsoft.com/wix/UtilExtension">
+<!--
+ Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.
+
+ 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
+ the Free Software Foundation; version 2 of the License.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ 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 02110-1301 USA
+-->
+
<!-- Datafiles that installation will copy to CommonAppData (initial database)
They are declared Permanent and NeverOverwrite since it is user data -->
<DirectoryRef Id='TARGETDIR'>
diff --git a/packaging/WiX/mysql_server.wxs.in b/packaging/WiX/mysql_server.wxs.in index 43a30538384..370830d82db 100644 --- a/packaging/WiX/mysql_server.wxs.in +++ b/packaging/WiX/mysql_server.wxs.in @@ -1,5 +1,23 @@ <Wix xmlns="http://schemas.microsoft.com/wix/2006/wi"
xmlns:util="http://schemas.microsoft.com/wix/UtilExtension">
+
+<!--
+ Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.
+
+ 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
+ the Free Software Foundation; version 2 of the License.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ 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 02110-1301 USA
+-->
+
<Product
Id="*"
UpgradeCode="49EB7A6A-1CEF-4A1E-9E89-B9A4993963E3"
diff --git a/plugin/audit_null/audit_null.c b/plugin/audit_null/audit_null.c index 161bd1cea70..469e5ae494c 100644 --- a/plugin/audit_null/audit_null.c +++ b/plugin/audit_null/audit_null.c @@ -1,12 +1,13 @@ -/* Copyright (C) 2006-2007 MySQL AB +/* Copyright (c) 2006, 2011, Oracle and/or its affiliates. All rights reserved. - 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 - the Free Software Foundation; version 2 of the License. + 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 the Free Software Foundation; version 2 of + the License. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License @@ -153,7 +154,8 @@ mysql_declare_plugin(audit_null) 0x0002, /* version */ simple_status, /* status variables */ NULL, /* system variables */ - NULL + NULL, + 0, } mysql_declare_plugin_end; diff --git a/plugin/auth_examples/dialog_examples.c b/plugin/auth_examples/dialog_examples.c index 0d8897042c9..9c4728b7886 100644 --- a/plugin/auth_examples/dialog_examples.c +++ b/plugin/auth_examples/dialog_examples.c @@ -134,7 +134,8 @@ mysql_declare_plugin(dialog) 0x0100, NULL, NULL, - NULL + NULL, + 0, }, { MYSQL_AUTHENTICATION_PLUGIN, @@ -148,7 +149,8 @@ mysql_declare_plugin(dialog) 0x0100, NULL, NULL, - NULL + NULL, + 0, } mysql_declare_plugin_end; diff --git a/plugin/auth_examples/qa_auth_interface.c b/plugin/auth_examples/qa_auth_interface.c index a768995fbfd..303978f7b1f 100644 --- a/plugin/auth_examples/qa_auth_interface.c +++ b/plugin/auth_examples/qa_auth_interface.c @@ -152,7 +152,8 @@ mysql_declare_plugin(test_plugin) 0x0100, NULL, NULL, - NULL + NULL, + 0, } mysql_declare_plugin_end; diff --git a/plugin/auth_examples/qa_auth_server.c b/plugin/auth_examples/qa_auth_server.c index 31cc4f08616..a6a06cfa289 100644 --- a/plugin/auth_examples/qa_auth_server.c +++ b/plugin/auth_examples/qa_auth_server.c @@ -72,6 +72,7 @@ mysql_declare_plugin(test_plugin) 0x0100, NULL, NULL, - NULL + NULL, + 0, } mysql_declare_plugin_end; diff --git a/plugin/auth_examples/test_plugin.c b/plugin/auth_examples/test_plugin.c index da9ab51bb58..2b20a8cb56c 100644 --- a/plugin/auth_examples/test_plugin.c +++ b/plugin/auth_examples/test_plugin.c @@ -1,4 +1,4 @@ -/* Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved. +/* Copyright (c) 2010, 2011, Oracle and/or its affiliates. All rights reserved. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as @@ -115,7 +115,8 @@ mysql_declare_plugin(test_plugin) 0x0100, NULL, NULL, - NULL + NULL, + 0, }, { MYSQL_AUTHENTICATION_PLUGIN, @@ -129,7 +130,8 @@ mysql_declare_plugin(test_plugin) 0x0100, NULL, NULL, - NULL + NULL, + 0, } mysql_declare_plugin_end; diff --git a/plugin/auth_socket/auth_socket.c b/plugin/auth_socket/auth_socket.c index 2aa4a0794ea..dbc8513e5dd 100644 --- a/plugin/auth_socket/auth_socket.c +++ b/plugin/auth_socket/auth_socket.c @@ -1,5 +1,5 @@ /* Copyright (C) 2010 Sergei Golubchik and Monty Program Ab - Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved. + Copyright (c) 2010, 2011, Oracle and/or its affiliates. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as @@ -98,7 +98,8 @@ mysql_declare_plugin(socket_auth) 0x0100, NULL, NULL, - NULL + NULL, + 0, } mysql_declare_plugin_end; maria_declare_plugin(socket_auth) diff --git a/plugin/daemon_example/CMakeLists.txt b/plugin/daemon_example/CMakeLists.txt index 60aa00687ba..1623c3025d7 100644 --- a/plugin/daemon_example/CMakeLists.txt +++ b/plugin/daemon_example/CMakeLists.txt @@ -15,3 +15,5 @@ MYSQL_ADD_PLUGIN(daemon_example daemon_example.cc MODULE_ONLY MODULE_OUTPUT_NAME "libdaemon_example") + +INSTALL(FILES daemon_example.ini DESTINATION ${INSTALL_PLUGINDIR}) diff --git a/plugin/daemon_example/daemon_example.cc b/plugin/daemon_example/daemon_example.cc index 79b58d27414..ab374a4fb3f 100644 --- a/plugin/daemon_example/daemon_example.cc +++ b/plugin/daemon_example/daemon_example.cc @@ -1,4 +1,4 @@ -/* Copyright (C) 2006 MySQL AB +/* Copyright (c) 2006, 2010, Oracle and/or its affiliates. All rights reserved. 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 @@ -201,7 +201,8 @@ mysql_declare_plugin(daemon_example) 0x0100 /* 1.0 */, NULL, /* status variables */ NULL, /* system variables */ - NULL /* config options */ + NULL, /* config options */ + 0, /* flags */ } mysql_declare_plugin_end; maria_declare_plugin(daemon_example) diff --git a/plugin/daemon_example/daemon_example.ini b/plugin/daemon_example/daemon_example.ini new file mode 100644 index 00000000000..7c6d4d1456e --- /dev/null +++ b/plugin/daemon_example/daemon_example.ini @@ -0,0 +1,9 @@ +# +# Plugin configuration file. Place the following on a separate line: +# +# library binary file name (without .so or .dll) +# component_name +# [component_name] - additional components in plugin +# +libdaemon_example +daemon_example diff --git a/plugin/feedback/CMakeLists.txt b/plugin/feedback/CMakeLists.txt new file mode 100644 index 00000000000..7407cc65637 --- /dev/null +++ b/plugin/feedback/CMakeLists.txt @@ -0,0 +1,18 @@ +INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR}/sql ${CMAKE_SOURCE_DIR}/regex + ${CMAKE_SOURCE_DIR}/extra/yassl/include) + +SET(FEEDBACK_SOURCES feedback.cc sender_thread.cc + url_base.cc url_http.cc utils.cc) + +INCLUDE (CheckIncludeFiles) +CHECK_INCLUDE_FILES (netdb.h HAVE_NETDB_H) +IF(HAVE_NETDB_H) + ADD_DEFINITIONS(-DHAVE_NETDB_H) +ENDIF(HAVE_NETDB_H) + +IF(WIN32) + #SET(FEEDBACK_LIBS Ws2_32) + MYSQL_ADD_PLUGIN(FEEDBACK ${FEEDBACK_SOURCES} STATIC_ONLY) +ELSE(WIN32) + MYSQL_ADD_PLUGIN(FEEDBACK ${FEEDBACK_SOURCES}) +ENDIF(WIN32) diff --git a/plugin/feedback/Makefile.am b/plugin/feedback/Makefile.am new file mode 100644 index 00000000000..7d2a61d593f --- /dev/null +++ b/plugin/feedback/Makefile.am @@ -0,0 +1,18 @@ +pkgplugindir = $(pkglibdir)/plugin +INCLUDES = -I$(top_srcdir)/include -I$(top_builddir)/include \ + -I$(top_srcdir)/regex -I$(top_srcdir)/sql + +EXTRA_LTLIBRARIES = feedback.la libfeedback.la +pkgplugin_LTLIBRARIES = @plugin_feedback_shared_target@ +feedback_la_LDFLAGS = -module -rpath $(pkgplugindir) -L$(top_builddir)/libservices -lmysqlservices +feedback_la_CXXFLAGS = -shared -DMYSQL_DYNAMIC_PLUGIN +feedback_la_SOURCES = feedback.cc utils.cc url_base.cc url_http.cc \ + sender_thread.cc + +noinst_LTLIBRARIES = @plugin_feedback_static_target@ +libfeedback_la_SOURCES= feedback.cc utils.cc url_base.cc url_http.cc \ + sender_thread.cc + +noinst_HEADERS = feedback.h +EXTRA_DIST = CMakeLists.txt plug.in + diff --git a/plugin/feedback/feedback.cc b/plugin/feedback/feedback.cc new file mode 100644 index 00000000000..975aaef7d38 --- /dev/null +++ b/plugin/feedback/feedback.cc @@ -0,0 +1,393 @@ +/* Copyright (C) 2010 Sergei Golubchik and Monty Program Ab + + 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 + the Free Software Foundation; version 2 of the License. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ + +#include "feedback.h" + +/* MySQL functions/variables not declared in mysql_priv.h */ +int fill_variables(THD *thd, TABLE_LIST *tables, COND *cond); +int fill_status(THD *thd, TABLE_LIST *tables, COND *cond); +extern ST_SCHEMA_TABLE schema_tables[]; + +namespace feedback { + +char server_uid_buf[SERVER_UID_SIZE+1]; ///< server uid will be written here + +/* backing store for system variables */ +static char *server_uid= server_uid_buf, *url; +char *user_info; +ulong send_timeout, send_retry_wait; + +/** + these three are used to communicate the shutdown signal to the + background thread +*/ +mysql_mutex_t sleep_mutex; +mysql_cond_t sleep_condition; +volatile bool shutdown_plugin; +static pthread_t sender_thread; + +static PSI_mutex_key key_sleep_mutex; +static PSI_mutex_info mutex_list[]= +{{ &key_sleep_mutex, "sleep_mutex", PSI_FLAG_GLOBAL}}; + +static PSI_cond_key key_sleep_cond; +static PSI_cond_info cond_list[]= +{{ &key_sleep_cond, "sleep_condition", PSI_FLAG_GLOBAL}}; + +static PSI_thread_key key_sender_thread; +static PSI_thread_info thread_list[] = +{{&key_sender_thread, "sender_thread", 0}}; + +Url **urls; ///< list of urls to send the report to +uint url_count; + +ST_SCHEMA_TABLE *i_s_feedback; ///< table descriptor for our I_S table + +/* + the column names *must* match column names in GLOBAL_VARIABLES and + GLOBAL_STATUS tables otherwise condition pushdown below will not work +*/ +static ST_FIELD_INFO feedback_fields[] = +{ + {"VARIABLE_NAME", 255, MYSQL_TYPE_STRING, 0, 0, 0, 0}, + {"VARIABLE_VALUE", 1024, MYSQL_TYPE_STRING, 0, 0, 0, 0}, + {0, 0, MYSQL_TYPE_NULL, 0, 0, 0, 0} +}; + +static COND * const OOM= (COND*)1; + +/** + Generate the COND tree for the condition pushdown + + This function takes a list of strings and generates an Item tree + corresponding to the following expression: + + field LIKE str1 OR field LIKE str2 OR field LIKE str3 OR ... + + where 'field' is the first field in the table - VARIABLE_NAME field - + and str1, str2... are strings from the list. + + This condition is used to filter the selected rows, emulating + + SELECT * FROM INFORMATION_SCHEMA.GLOBAL_VARIABLES WHERE ... +*/ +static COND* make_cond(THD *thd, TABLE_LIST *tables, LEX_STRING *filter) +{ + Item_cond_or *res= NULL; + Name_resolution_context nrc; + const char *db= tables->db, *table= tables->alias, + *field= tables->table->field[0]->field_name; + CHARSET_INFO *cs= &my_charset_latin1; + + if (!filter->str) + return 0; + + nrc.init(); + nrc.resolve_in_table_list_only(tables); + + res= new Item_cond_or(); + if (!res) + return OOM; + + for (; filter->str; filter++) + { + Item_field *fld= new Item_field(&nrc, db, table, field); + Item_string *pattern= new Item_string(filter->str, filter->length, cs); + Item_string *escape= new Item_string("\\", 1, cs); + + if (!fld || !pattern || !escape) + return OOM; + + Item_func_like *like= new Item_func_like(fld, pattern, escape, 0); + + if (!like) + return OOM; + + res->add(like); + } + + if (res->fix_fields(thd, (Item**)&res)) + return OOM; + + return res; +} + +/** + System variables that we want to see in the feedback report +*/ +static LEX_STRING vars_filter[]= { + {C_STRING_WITH_LEN("auto\\_increment%")}, + {C_STRING_WITH_LEN("binlog\\_format")}, + {C_STRING_WITH_LEN("character\\_set\\_%")}, + {C_STRING_WITH_LEN("collation%")}, + {C_STRING_WITH_LEN("engine\\_condition\\_pushdown")}, + {C_STRING_WITH_LEN("event\\_scheduler")}, + {C_STRING_WITH_LEN("feedback\\_%")}, + {C_STRING_WITH_LEN("ft\\_m%")}, + {C_STRING_WITH_LEN("have\\_%")}, + {C_STRING_WITH_LEN("%\\_size")}, + {C_STRING_WITH_LEN("%\\_length%")}, + {C_STRING_WITH_LEN("%\\_timeout")}, + {C_STRING_WITH_LEN("large\\_%")}, + {C_STRING_WITH_LEN("lc_time_names")}, + {C_STRING_WITH_LEN("log")}, + {C_STRING_WITH_LEN("log_bin")}, + {C_STRING_WITH_LEN("log_output")}, + {C_STRING_WITH_LEN("log_slow_queries")}, + {C_STRING_WITH_LEN("log_slow_time")}, + {C_STRING_WITH_LEN("lower_case%")}, + {C_STRING_WITH_LEN("max_allowed_packet")}, + {C_STRING_WITH_LEN("max_connections")}, + {C_STRING_WITH_LEN("max_prepared_stmt_count")}, + {C_STRING_WITH_LEN("max_sp_recursion_depth")}, + {C_STRING_WITH_LEN("max_user_connections")}, + {C_STRING_WITH_LEN("max_write_lock_count")}, + {C_STRING_WITH_LEN("myisam_recover_options")}, + {C_STRING_WITH_LEN("myisam_repair_threads")}, + {C_STRING_WITH_LEN("myisam_stats_method")}, + {C_STRING_WITH_LEN("myisam_use_mmap")}, + {C_STRING_WITH_LEN("net\\_%")}, + {C_STRING_WITH_LEN("new")}, + {C_STRING_WITH_LEN("old%")}, + {C_STRING_WITH_LEN("optimizer%")}, + {C_STRING_WITH_LEN("profiling")}, + {C_STRING_WITH_LEN("query_cache%")}, + {C_STRING_WITH_LEN("secure_auth")}, + {C_STRING_WITH_LEN("slow_launch_time")}, + {C_STRING_WITH_LEN("sql%")}, + {C_STRING_WITH_LEN("storage_engine")}, + {C_STRING_WITH_LEN("sync_binlog")}, + {C_STRING_WITH_LEN("table_definition_cache")}, + {C_STRING_WITH_LEN("table_open_cache")}, + {C_STRING_WITH_LEN("thread_handling")}, + {C_STRING_WITH_LEN("time_zone")}, + {C_STRING_WITH_LEN("timed_mutexes")}, + {C_STRING_WITH_LEN("version%")}, + {0, 0} +}; + +/** + Status variables that we want to see in the feedback report + + (empty list = no WHERE condition) +*/ +static LEX_STRING status_filter[]= {{0, 0}}; + +/** + Fill our I_S table with data + + This function works by invoking fill_variables() and + fill_status() of the corresponding I_S tables - to have + their data UNION-ed in the same target table. + After that it invokes our own fill_* functions + from the utils.cc - to get the data that aren't available in the + I_S.GLOBAL_VARIABLES and I_S.GLOBAL_STATUS. +*/ +int fill_feedback(THD *thd, TABLE_LIST *tables, COND *unused) +{ + int res; + COND *cond; + + tables->schema_table= schema_tables + SCH_GLOBAL_VARIABLES; + cond= make_cond(thd, tables, vars_filter); + res= (cond == OOM) ? 1 : fill_variables(thd, tables, cond); + + tables->schema_table= schema_tables + SCH_GLOBAL_STATUS; + if (!res) + { + cond= make_cond(thd, tables, status_filter); + res= (cond == OOM) ? 1 : fill_status(thd, tables, cond); + } + + tables->schema_table= i_s_feedback; + res= res || fill_plugin_version(thd, tables) + || fill_misc_data(thd, tables) + || fill_linux_info(thd, tables); + + return res; +} + +/** + plugin initialization function +*/ +static int init(void *p) +{ + i_s_feedback= (ST_SCHEMA_TABLE*) p; + /* initialize the I_S descriptor structure */ + i_s_feedback->fields_info= feedback_fields; ///< field descriptor + i_s_feedback->fill_table= fill_feedback; ///< how to fill the I_S table + i_s_feedback->idx_field1 = 0; ///< virtual index on the 1st col + +#define PSI_register(X) \ + PSI_server->register_ ## X("feedback", X ## _list, array_elements(X ## _list)) + + PSI_register(mutex); + PSI_register(cond); + PSI_register(thread); + + if (calculate_server_uid(server_uid_buf)) + return 1; + + prepare_linux_info(); + + url_count= 0; + if (*url) + { + // now we split url on spaces and store them in Url objects + int slot; + char *s, *e; + + for (s= url, url_count= 1; *s; s++) + if (*s == ' ') + url_count++; + + urls= (Url **)my_malloc(url_count*sizeof(Url*), MYF(MY_WME)); + if (!urls) + return 1; + + for (s= url, e = url+1, slot= 0; e[-1]; e++) + if (*e == 0 || *e == ' ') + { + if (e > s && (urls[slot]= Url::create(s, e - s))) + slot++; + else + { + if (e > s) + sql_print_error("feedback plugin: invalid url '%.*s'", (int)(e-s), s); + url_count--; + } + s= e + 1; + } + + // create a background thread to handle urls, if any + if (url_count) + { + mysql_mutex_init(0, &sleep_mutex, 0); + mysql_cond_init(0, &sleep_condition, 0); + shutdown_plugin= false; + + pthread_attr_t attr; + pthread_attr_init(&attr); + pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_JOINABLE); + if (pthread_create(&sender_thread, &attr, background_thread, 0) != 0) + { + sql_print_error("feedback plugin: failed to start a background thread"); + return 1; + } + } + else + my_free(urls); + } + + return 0; +} + +/** + plugin deinitialization function +*/ +static int free(void *p) +{ + if (url_count) + { + mysql_mutex_lock(&sleep_mutex); + shutdown_plugin= true; + mysql_cond_signal(&sleep_condition); + mysql_mutex_unlock(&sleep_mutex); + pthread_join(sender_thread, NULL); + + mysql_mutex_destroy(&sleep_mutex); + mysql_cond_destroy(&sleep_condition); + + for (uint i= 0; i < url_count; i++) + delete urls[i]; + my_free(urls); + } + return 0; +} + +#ifdef HAVE_OPENSSL +#define DEFAULT_PROTO "https://" +#else +#define DEFAULT_PROTO "http://" +#endif + +static MYSQL_SYSVAR_STR(server_uid, server_uid, + PLUGIN_VAR_READONLY | PLUGIN_VAR_NOCMDOPT, + "Automatically calculated server unique id hash.", NULL, NULL, 0); +static MYSQL_SYSVAR_STR(user_info, user_info, + PLUGIN_VAR_READONLY | PLUGIN_VAR_RQCMDARG, + "User specified string that will be included in the feedback report.", + NULL, NULL, ""); +static MYSQL_SYSVAR_STR(url, url, PLUGIN_VAR_READONLY | PLUGIN_VAR_RQCMDARG, + "Space separated URLs to send the feedback report to.", NULL, NULL, + DEFAULT_PROTO "mariadb.org/feedback_plugin/post"); +static MYSQL_SYSVAR_ULONG(send_timeout, send_timeout, PLUGIN_VAR_RQCMDARG, + "Timeout (in seconds) for the sending the report.", + NULL, NULL, 60, 1, 60*60*24, 1); +static MYSQL_SYSVAR_ULONG(send_retry_wait, send_retry_wait, PLUGIN_VAR_RQCMDARG, + "Wait this many seconds before retrying a failed send.", + NULL, NULL, 60, 1, 60*60*24, 1); + +static struct st_mysql_sys_var* settings[] = { + MYSQL_SYSVAR(server_uid), + MYSQL_SYSVAR(user_info), + MYSQL_SYSVAR(url), + MYSQL_SYSVAR(send_timeout), + MYSQL_SYSVAR(send_retry_wait), + NULL +}; + + +static struct st_mysql_information_schema feedback = +{ MYSQL_INFORMATION_SCHEMA_INTERFACE_VERSION }; + +} // namespace feedback + +mysql_declare_plugin(feedback) +{ + MYSQL_INFORMATION_SCHEMA_PLUGIN, + &feedback::feedback, + "FEEDBACK", + "Sergei Golubchik", + "MariaDB User Feedback Plugin", + PLUGIN_LICENSE_GPL, + feedback::init, + feedback::free, + 0x0101, + NULL, + feedback::settings, + NULL, + 0 +} +mysql_declare_plugin_end; +#ifdef MARIA_PLUGIN_INTERFACE_VERSION +maria_declare_plugin(feedback) +{ + MYSQL_INFORMATION_SCHEMA_PLUGIN, + &feedback::feedback, + "FEEDBACK", + "Sergei Golubchik", + "MariaDB User Feedback Plugin", + PLUGIN_LICENSE_GPL, + feedback::init, + feedback::free, + 0x0101, + NULL, + feedback::settings, + "1.1", + MariaDB_PLUGIN_MATURITY_BETA +} +maria_declare_plugin_end; +#endif diff --git a/plugin/feedback/feedback.h b/plugin/feedback/feedback.h new file mode 100644 index 00000000000..74fb806fac2 --- /dev/null +++ b/plugin/feedback/feedback.h @@ -0,0 +1,67 @@ +/* Copyright (C) 2010 Sergei Golubchik and Monty Program Ab + + 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 + the Free Software Foundation; version 2 of the License. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ + +#define MYSQL_SERVER +#include <sql_class.h> + +namespace feedback { + +int fill_feedback(THD *thd, TABLE_LIST *tables, COND *cond); +int fill_plugin_version(THD *thd, TABLE_LIST *tables); +int fill_misc_data(THD *thd, TABLE_LIST *tables); +int fill_linux_info(THD *thd, TABLE_LIST *tables); + +static const int SERVER_UID_SIZE= 29; +extern char server_uid_buf[SERVER_UID_SIZE+1], *user_info; +int calculate_server_uid(char *); +int prepare_linux_info(); + +extern ST_SCHEMA_TABLE *i_s_feedback; + +extern ulong send_timeout, send_retry_wait; + +pthread_handler_t background_thread(void *arg); + +/** + The class for storing urls to send report data to. + + Constructors are private, the object should be created with create() method. + send() method does the actual sending. +*/ +class Url { + protected: + Url(LEX_STRING &url_arg) : full_url(url_arg) {} + const LEX_STRING full_url; + + public: + virtual ~Url() { my_free(full_url.str); } + + const char *url() { return full_url.str; } + size_t url_length() { return full_url.length; } + virtual int send(const char* data, size_t data_length) = 0; + + static Url* create(const char *url, size_t url_length); +}; + +extern Url **urls; +extern uint url_count; + +/* these are used to communicate with the background thread */ +extern mysql_mutex_t sleep_mutex; +extern mysql_cond_t sleep_condition; +extern volatile bool shutdown_plugin; + +} // namespace feedback + diff --git a/plugin/feedback/plug.in b/plugin/feedback/plug.in new file mode 100644 index 00000000000..88a4448321d --- /dev/null +++ b/plugin/feedback/plug.in @@ -0,0 +1,28 @@ +MYSQL_PLUGIN(feedback,[MariaDB User Feedback Plugin], + [MariaDB User Feedback Plugin]) + +dnl Although it's not exactly obvious, top-level CMakeLists.txt parses plug.in +dnl files, in particular looking for what the library name should be. It uses +dnl regexp that matches MYSQL_PLUGIN_DYNAMIC or MYSQL_PLUGIN_STATIC, followed +dnl by an open parenthesys, and the plugin name. Having engine name enclosed in +dnl square brackets below causes this regexp to fail and as a result feedback +dnl plugin will not be considered for dynamic builds on Windows. +dnl Unfortunately, feedback cannot be built dynamically on Windows, because it +dnl needs to access server internals that aren't designed for plugin use and +dnl aren't marked with MYSQL_PLUGIN_IMPORT. +MYSQL_PLUGIN_DYNAMIC([feedback], [feedback.la]) +ifelse(index(AC_PACKAGE_NAME, [MariaDB]), -1, [], [ + +dnl MariaDB and MySQL define static plugins differently. +dnl I only support MariaDB here, for now. +MYSQL_PLUGIN_STATIC(feedback, [libfeedback.la]) + +]) + +dnl MariaDB before 5.5 needs this define: +MYSQL_PLUGIN_DEFINE(feedback, [WITH_FEEDBACK_PLUGIN]) + +MYSQL_PLUGIN_ACTIONS(feedback, [ + AC_CHECK_HEADERS([netdb.h sys/utsname.h]) +]) + diff --git a/plugin/feedback/sender_thread.cc b/plugin/feedback/sender_thread.cc new file mode 100644 index 00000000000..4ab45998484 --- /dev/null +++ b/plugin/feedback/sender_thread.cc @@ -0,0 +1,305 @@ +/* Copyright (C) 2010 Sergei Golubchik and Monty Program Ab + + 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 + the Free Software Foundation; version 2 of the License. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ + +#include "feedback.h" +#include <sql_acl.h> +#include <sql_parse.h> +#include <time.h> + +namespace feedback { + +static THD *thd= 0; ///< background thread thd +static my_thread_id thd_thread_id; ///< its thread_id + +static size_t needed_size= 20480; + +static const time_t startup_interval= 60*5; ///< in seconds (5 minutes) +static const time_t first_interval= 60*60*24; ///< in seconds (one day) +static const time_t interval= 60*60*24*7; ///< in seconds (one week) + +/** + reads the rows from a table and puts them, concatenated, in a String + + @note + 1. only supports two column tables - no less, no more. + 2. it emulates mysql -e "select * from..." and thus it separates + columns with \t and starts the output with column names. +*/ +static int table_to_string(TABLE *table, String *result) +{ + bool res; + char buff1[MAX_FIELD_WIDTH], buff2[MAX_FIELD_WIDTH]; + String str1(buff1, sizeof(buff1), system_charset_info); + String str2(buff2, sizeof(buff2), system_charset_info); + + res= table->file->ha_rnd_init(1); + + dbug_tmp_use_all_columns(table, table->read_set); + + while(!res && !table->file->ha_rnd_next(table->record[0])) + { + table->field[0]->val_str(&str1); + table->field[1]->val_str(&str2); + if (result->reserve(str1.length() + str2.length() + 3)) + res= 1; + else + { + result->qs_append(str1.ptr(), str1.length()); + result->qs_append('\t'); + result->qs_append(str2.ptr(), str2.length()); + result->qs_append('\n'); + } + } + + res = res || result->append('\n'); + + /* + Note, "|=" and not "||" - because we want to call ha_rnd_end() + even if res is already 1. + */ + res |= table->file->ha_rnd_end(); + + return res; +} + +/** + Initialize the THD and TABLE_LIST + + The structures must be sufficiently initialized for create_tmp_table() + and fill_feedback() to work. +*/ +static int prepare_for_fill(TABLE_LIST *tables) +{ + /* + Add our thd to the list, for it to be visible in SHOW PROCESSLIST. + But don't generate thread_id every time - use the saved value + (every increment of global thread_id counts as a new connection + in SHOW STATUS and we want to avoid skewing the statistics) + */ + thd->thread_id= thd->variables.pseudo_thread_id= thd_thread_id; + mysql_mutex_lock(&LOCK_thread_count); + thread_count++; + threads.append(thd); + mysql_mutex_unlock(&LOCK_thread_count); + thd->thread_stack= (char*) &tables; + if (thd->store_globals()) + return 1; + + thd->mysys_var->current_cond= &sleep_condition; + thd->mysys_var->current_mutex= &sleep_mutex; + thd->proc_info="feedback"; + thd->command=COM_SLEEP; + thd->system_thread= SYSTEM_THREAD_EVENT_WORKER; // whatever + thd->set_time(); + thd->init_for_queries(); + thd->real_id= pthread_self(); + thd->db= NULL; + thd->db_length= 0; + thd->security_ctx->host_or_ip= ""; + thd->security_ctx->db_access= DB_ACLS; + thd->security_ctx->master_access= ~NO_ACCESS; + bzero((char*) &thd->net, sizeof(thd->net)); + lex_start(thd); + mysql_init_select(thd->lex); + + tables->init_one_table(INFORMATION_SCHEMA_NAME.str, + INFORMATION_SCHEMA_NAME.length, + i_s_feedback->table_name, + strlen(i_s_feedback->table_name), + 0, TL_READ); + tables->schema_table= i_s_feedback; + tables->table= i_s_feedback->create_table(thd, tables); + if (!tables->table) + return 1; + + tables->table->pos_in_table_list= tables; + + return 0; +} + +/** + Try to detect if this thread is going down + + which can happen for different reasons: + * plugin is being unloaded + * mysqld server is being shut down + * the thread is being killed + +*/ +static bool going_down() +{ + return shutdown_plugin || shutdown_in_progress || (thd && thd->killed); +} + +/** + just like sleep, but waits on a condition and checks "plugin shutdown" status +*/ +static int slept_ok(time_t sec) +{ + struct timespec abstime; + int ret= 0; + + set_timespec(abstime, sec); + + mysql_mutex_lock(&sleep_mutex); + while (!going_down() && ret != ETIMEDOUT) + ret= mysql_cond_timedwait(&sleep_condition, &sleep_mutex, &abstime); + mysql_mutex_unlock(&sleep_mutex); + + return !going_down(); +} + +/** + create a feedback report and send it to all specified urls + + If "when" argument is not null, only it and the server uid are sent. + Otherwise a full report is generated. +*/ +static void send_report(const char *when) +{ + TABLE_LIST tables; + String str; + int i, last_todo; + Url **todo= (Url**)alloca(url_count*sizeof(Url*)); + + str.alloc(needed_size); // preallocate it to avoid many small mallocs + + /* + on startup and shutdown the server may not be completely + initialized, and full report won't work. + We send a short status notice only. + */ + if (when) + { + str.length(0); + str.append(STRING_WITH_LEN("FEEDBACK_SERVER_UID")); + str.append('\t'); + str.append(server_uid_buf); + str.append('\n'); + str.append(STRING_WITH_LEN("FEEDBACK_WHEN")); + str.append('\t'); + str.append(when); + str.append('\n'); + str.append(STRING_WITH_LEN("FEEDBACK_USER_INFO")); + str.append('\t'); + str.append(user_info); + str.append('\n'); + str.append('\n'); + } + else + { + /* + otherwise, prepare the THD and TABLE_LIST, + create and fill the temporary table with data just like + SELECT * FROM IFROEMATION_SCHEMA.feedback is doing, + read and concatenate table data into a String. + */ + if (!(thd= new THD())) + return; + + if (prepare_for_fill(&tables)) + goto ret; + + if (fill_feedback(thd, &tables, NULL)) + goto ret; + + if (table_to_string(tables.table, &str)) + goto ret; + + needed_size= (size_t)(str.length() * 1.1); + + free_tmp_table(thd, tables.table); + tables.table= 0; + } + + /* + Try to send the report on every url from the list, remove url on success, + keep failed in the list. Repeat until the list is empty. + */ + memcpy(todo, urls, url_count*sizeof(Url*)); + last_todo= url_count - 1; + do + { + for (i= 0; i <= last_todo;) + { + Url *url= todo[i]; + + if (thd) // for nicer SHOW PROCESSLIST + thd->set_query(const_cast<char*>(url->url()), url->url_length()); + + if (url->send(str.ptr(), str.length())) + i++; + else + todo[i]= todo[last_todo--]; + } + if (last_todo < 0) + break; + } while (slept_ok(send_retry_wait)); // wait a little bit before retrying + +ret: + if (thd) + { + if (tables.table) + free_tmp_table(thd, tables.table); + /* + clean up, free the thd. + reset all thread local status variables to minimize + the effect of the background thread on SHOW STATUS. + */ + mysql_mutex_lock(&LOCK_thread_count); + bzero(&thd->status_var, sizeof(thd->status_var)); + thread_count--; + thd->killed= KILL_CONNECTION; + mysql_cond_broadcast(&COND_thread_count); + mysql_mutex_unlock(&LOCK_thread_count); + delete thd; + thd= 0; + } +} + +/** + background sending thread +*/ +pthread_handler_t background_thread(void *arg __attribute__((unused))) +{ + if (my_thread_init()) + return 0; + + mysql_mutex_lock(&LOCK_thread_count); + thd_thread_id= thread_id++; + mysql_mutex_unlock(&LOCK_thread_count); + + if (slept_ok(startup_interval)) + { + send_report("startup"); + + if (slept_ok(first_interval)) + { + send_report(NULL); + + while(slept_ok(interval)) + send_report(NULL); + } + + send_report("shutdown"); + } + + my_thread_end(); + pthread_exit(0); + return 0; +} + +} // namespace feedback + diff --git a/plugin/feedback/url_base.cc b/plugin/feedback/url_base.cc new file mode 100644 index 00000000000..e7d038f02e2 --- /dev/null +++ b/plugin/feedback/url_base.cc @@ -0,0 +1,51 @@ +/* Copyright (C) 2010 Sergei Golubchik and Monty Program Ab + + 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 + the Free Software Foundation; version 2 of the License. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ + +#include "feedback.h" + +namespace feedback { + +Url* http_create(const char *url, size_t url_length); + +/** + creates an Url object out of an url, if possible. + + This is done by invoking corresponding creator functions + of the derived classes, until the first not NULL result. +*/ +Url* Url::create(const char *url, size_t url_length) +{ + url= my_strndup(url, url_length, MYF(MY_WME)); + + if (!url) + return NULL; + + Url *self= http_create(url, url_length); + + /* + here we can add + + if (!self) self= smtp_create(url, url_length); + if (!self) self= tftp_create(url, url_length); + etc + */ + + if (!self) + my_free(const_cast<char*>(url)); + + return self; +} + +} // namespace feedback diff --git a/plugin/feedback/url_http.cc b/plugin/feedback/url_http.cc new file mode 100644 index 00000000000..a9d4c5bbbaf --- /dev/null +++ b/plugin/feedback/url_http.cc @@ -0,0 +1,307 @@ +/* Copyright (C) 2010 Sergei Golubchik and Monty Program Ab + + 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 + the Free Software Foundation; version 2 of the License. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ + +#include "feedback.h" + +#ifdef HAVE_NETDB_H +#include <netdb.h> +#endif + +#ifdef _WIN32 +#include <ws2tcpip.h> +#define addrinfo ADDRINFOA +#endif + +namespace feedback { + +static const uint FOR_READING= 0; +static const uint FOR_WRITING= 1; + +#ifdef MARIADB_BASE_VERSION +#define ssl_connect(A,B,C,D) sslconnect(A,B,C,D) +#else +#define ssl_connect(A,B,C,D) sslconnect(A,B,C) +#endif + +/** + implementation of the Url class that sends the data via HTTP POST request. + + Both http:// and https:// protocols are supported. +*/ +class Url_http: public Url { + protected: + const LEX_STRING host, port, path; + bool ssl; + + Url_http(LEX_STRING &url_arg, LEX_STRING &host_arg, + LEX_STRING &port_arg, LEX_STRING &path_arg, bool ssl_arg) : + Url(url_arg), host(host_arg), port(port_arg), path(path_arg), ssl(ssl_arg) + {} + ~Url_http() + { + my_free(host.str); + my_free(port.str); + my_free(path.str); + } + + public: + int send(const char* data, size_t data_length); + + friend Url* http_create(const char *url, size_t url_length); +}; + +/** + create a Url_http object out of the url, if possible. + + @note + Arbitrary limitations here. + + The url must be http[s]://hostname[:port]/path + No username:password@ or ?script=parameters are supported. + + But it's ok. This is not a generic purpose www browser - it only needs to be + good enough to POST the data to mariadb.org. +*/ +Url* http_create(const char *url, size_t url_length) +{ + const char *s; + LEX_STRING full_url= {const_cast<char*>(url), url_length}; + LEX_STRING host, port, path; + bool ssl= false; + + if (is_prefix(url, "http://")) + s= url + 7; +#ifdef HAVE_OPENSSL + else if (is_prefix(url, "https://")) + { + ssl= true; + s= url + 8; + } +#endif + else + return NULL; + + for (url= s; *s && *s != ':' && *s != '/'; s++) /* no-op */; + host.str= const_cast<char*>(url); + host.length= s-url; + + if (*s == ':') + { + for (url= ++s; *s && *s >= '0' && *s <= '9'; s++) /* no-op */; + port.str= const_cast<char*>(url); + port.length= s-url; + } + else + { + if (ssl) + { + port.str= const_cast<char*>("443"); + port.length=3; + } + else + { + port.str= const_cast<char*>("80"); + port.length=2; + } + } + + if (*s == 0) + { + path.str= const_cast<char*>("/"); + path.length= 1; + } + else + { + path.str= const_cast<char*>(s); + path.length= strlen(s); + } + if (!host.length || !port.length || path.str[0] != '/') + return NULL; + + host.str= my_strndup(host.str, host.length, MYF(MY_WME)); + port.str= my_strndup(port.str, port.length, MYF(MY_WME)); + path.str= my_strndup(path.str, path.length, MYF(MY_WME)); + + if (!host.str || !port.str || !path.str) + { + my_free(host.str); + my_free(port.str); + my_free(path.str); + return NULL; + } + + return new Url_http(full_url, host, port, path, ssl); +} + +/* do the vio_write and check that all data were sent ok */ +#define write_check(VIO, DATA, LEN) \ + (vio_write((VIO), (uchar*)(DATA), (LEN)) != (LEN)) + +int Url_http::send(const char* data, size_t data_length) +{ + my_socket fd= INVALID_SOCKET; + char buf[1024]; + uint len= 0; + + addrinfo *addrs, *addr, filter= {0, AF_UNSPEC, SOCK_STREAM, 6, 0, 0, 0, 0}; + int res= getaddrinfo(host.str, port.str, &filter, &addrs); + + if (res) + { + sql_print_error("feedback plugin: getaddrinfo() failed for url '%s': %s", + full_url.str, gai_strerror(res)); + return 1; + } + + for (addr= addrs; addr != NULL; addr= addr->ai_next) + { + fd= socket(addr->ai_family, addr->ai_socktype, addr->ai_protocol); + if (fd == INVALID_SOCKET) + continue; + + if (connect(fd, addr->ai_addr, addr->ai_addrlen) == 0) + break; + + closesocket(fd); + } + + freeaddrinfo(addrs); + + if (fd == INVALID_SOCKET) + { + sql_print_error("feedback plugin: could not connect for url '%s'", + full_url.str); + return 1; + } + + Vio *vio= vio_new(fd, VIO_TYPE_TCPIP, 0); + if (!vio) + { + sql_print_error("feedback plugin: vio_new failed for url '%s'", + full_url.str); + closesocket(fd); + return 1; + } + +#ifdef HAVE_OPENSSL + struct st_VioSSLFd *UNINIT_VAR(ssl_fd); + if (ssl) + { + buf[0]= 0; + if (!(ssl_fd= new_VioSSLConnectorFd(0, 0, 0, 0, 0)) || + ssl_connect(ssl_fd, vio, send_timeout, buf)) + { + sql_print_error("feedback plugin: ssl failed for url '%s' %s", + full_url.str, buf); + if (ssl_fd) + free_vio_ssl_acceptor_fd(ssl_fd); + closesocket(fd); + vio_delete(vio); + return 1; + } + } +#endif + + static const LEX_STRING boundary= + { C_STRING_WITH_LEN("----------------------------ba4f3696b39f") }; + static const LEX_STRING header= + { C_STRING_WITH_LEN("\r\n" + "Content-Disposition: form-data; name=\"data\"; filename=\"-\"\r\n" + "Content-Type: application/octet-stream\r\n\r\n") + }; + + len= my_snprintf(buf, sizeof(buf), + "POST %s HTTP/1.0\r\n" + "User-Agent: MariaDB User Feedback Plugin\r\n" + "Host: %s:%s\r\n" + "Accept: */*\r\n" + "Content-Length: %u\r\n" + "Content-Type: multipart/form-data; boundary=%s\r\n" + "\r\n", + path.str, host.str, port.str, + (uint)(2*boundary.length + header.length + data_length + 4), + boundary.str + 2); + + vio_timeout(vio, FOR_READING, send_timeout); + vio_timeout(vio, FOR_WRITING, send_timeout); + res = write_check(vio, buf, len) + || write_check(vio, boundary.str, boundary.length) + || write_check(vio, header.str, header.length) + || write_check(vio, data, data_length) + || write_check(vio, boundary.str, boundary.length) + || write_check(vio, "--\r\n", 4); + + if (res) + sql_print_error("feedback plugin: failed to send report to '%s'", + full_url.str); + else + { + sql_print_information("feedback plugin: report to '%s' was sent", + full_url.str); + + /* + if the data were send successfully, read the reply. + Extract the first string between <h1>...</h1> tags + and put it as a server reply into the error log. + */ + for (;;) + { + size_t i= vio_read(vio, (uchar*)buf + len, sizeof(buf) - len - 1); + if ((int)i <= 0) + break; + len+= i; + } + if (len && len < sizeof(buf)) + { + char *from; + + buf[len+1]= 0; // safety + + if ((from= strstr(buf, "<h1>"))) + { + from+= 4; + char *to= strstr(from, "</h1>"); + if (to) + *to= 0; + else + from= NULL; + } + if (from) + sql_print_information("feedback plugin: server replied '%s'", from); + else + sql_print_warning("feedback plugin: failed to parse server reply"); + } + else + { + res= 1; + sql_print_error("feedback plugin: failed to read server reply"); + } + } + + vio_delete(vio); + +#ifdef HAVE_OPENSSL + if (ssl) + { + SSL_CTX_free(ssl_fd->ssl_context); + my_free(ssl_fd, MYF(0)); + } +#endif + + return res; +} + +} // namespace feedback + diff --git a/plugin/feedback/utils.cc b/plugin/feedback/utils.cc new file mode 100644 index 00000000000..48bbd72d530 --- /dev/null +++ b/plugin/feedback/utils.cc @@ -0,0 +1,393 @@ +/* Copyright (C) 2010 Sergei Golubchik and Monty Program Ab + + 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 + the Free Software Foundation; version 2 of the License. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ + +#include "feedback.h" + +#ifdef HAVE_UNISTD_H +#include <unistd.h> +#endif + +#include <base64.h> +#include <sha1.h> + +#if defined (_WIN32) +#define HAVE_SYS_UTSNAME_H + +#ifndef VER_SUITE_WH_SERVER +#define VER_SUITE_WH_SERVER 0x00008000 +#endif + +struct utsname { + char sysname[16]; // Name of this implementation of the operating system. + char nodename[16]; // Name of this node within the communications + // network to which this node is attached, if any. + char release[16]; // Current release level of this implementation. + char version[256]; // Current version level of this release. + char machine[16]; // Name of the hardware type on which the system is running. +}; + +/* Get commonly used name for Windows version */ +static const char *get_os_version_name(OSVERSIONINFOEX *ver) +{ + DWORD major = ver->dwMajorVersion; + DWORD minor = ver->dwMinorVersion; + + if (major == 6 && minor == 1) + { + return (ver->wProductType == VER_NT_WORKSTATION)? + "Windows 7":"Windows Server 2008 R2"; + } + if (major == 6 && minor == 0) + { + return (ver->wProductType == VER_NT_WORKSTATION)? + "Windows Vista":"Windows Server 2008"; + } + if (major == 5 && minor == 2) + { + if (GetSystemMetrics(SM_SERVERR2) != 0) + return "Windows Server 2003 R2"; + if (ver->wSuiteMask & VER_SUITE_WH_SERVER) + return "Windows Home Server"; + SYSTEM_INFO sysinfo; + GetSystemInfo(&sysinfo); + if (ver->wProductType == VER_NT_WORKSTATION && + sysinfo.wProcessorArchitecture==PROCESSOR_ARCHITECTURE_AMD64) + return "Windows XP Professional x64 Edition"; + + return "Windows Server 2003"; + } + if (major == 5 && minor == 1) + return "Windows XP"; + if (major == 5 && minor == 0) + return "Windows 2000"; + + return ""; +} + + +static int uname(struct utsname *buf) +{ + OSVERSIONINFOEX ver; + ver.dwOSVersionInfoSize = (DWORD)sizeof(ver); + if (!GetVersionEx((OSVERSIONINFO *)&ver)) + return -1; + + buf->nodename[0]= 0; + strcpy(buf->sysname, "Windows"); + sprintf(buf->release, "%d.%d", ver.dwMajorVersion, ver.dwMinorVersion); + + const char *version_str= get_os_version_name(&ver); + if(version_str && version_str[0]) + sprintf(buf->version, "%s %s",version_str, ver.szCSDVersion); + else + sprintf(buf->version, "%s", ver.szCSDVersion); + +#ifdef _WIN64 + strcpy(buf->machine, "x64"); +#else + BOOL isX64; + if (IsWow64Process(GetCurrentProcess(), &isX64) && isX64) + strcpy(buf->machine, "x64"); + else + strcpy(buf->machine,"x86"); +#endif + return 0; +} + +#elif defined(HAVE_SYS_UTSNAME_H) +#include <sys/utsname.h> +#endif + +#ifdef HAVE_SYS_UTSNAME_H +static bool have_ubuf= false; +static struct utsname ubuf; +#endif + +#ifdef TARGET_OS_LINUX +#include <glob.h> +static bool have_distribution= false; +static char distribution[256]; + +static const char *masks[]= { + "/etc/*-version", "/etc/*-release", + "/etc/*_version", "/etc/*_release" +}; +#endif + +bool schema_table_store_record(THD *thd, TABLE *table); + +namespace feedback { + +/* + convenience macros for inserting rows into I_S table. +*/ +#define INSERT2(NAME,LEN,VALUE) \ + do { \ + table->field[0]->store(NAME, LEN, system_charset_info); \ + table->field[1]->store VALUE; \ + if (schema_table_store_record(thd, table)) \ + return 1; \ + } while (0) + +#define INSERT1(NAME,VALUE) \ + do { \ + table->field[0]->store(NAME, sizeof(NAME)-1, system_charset_info); \ + table->field[1]->store VALUE; \ + if (schema_table_store_record(thd, table)) \ + return 1; \ + } while (0) + +static const bool UNSIGNED= true; ///< used below when inserting integers + +/** + callback for fill_plugin_version() - insert a plugin name and its version +*/ +static my_bool show_plugins(THD *thd, plugin_ref plugin, void *arg) +{ + TABLE *table= (TABLE*) arg; + char version[20]; + size_t version_len; + + version_len= my_snprintf(version, sizeof(version), "%d.%d", + (plugin_decl(plugin)->version) >> 8, + (plugin_decl(plugin)->version) & 0xff); + + INSERT2(plugin_name(plugin)->str, plugin_name(plugin)->length, + (version, version_len, system_charset_info)); + + return 0; +} + +/** + inserts all plugins and their versions into I_S.FEEDBACK +*/ +int fill_plugin_version(THD *thd, TABLE_LIST *tables) +{ + return plugin_foreach_with_mask(thd, show_plugins, MYSQL_ANY_PLUGIN, + ~PLUGIN_IS_FREED, tables->table); +} + +#if defined(_SC_PAGE_SIZE) && !defined(_SC_PAGESIZE) +#define _SC_PAGESIZE _SC_PAGE_SIZE +#endif + +/** + return the amount of physical memory +*/ +static ulonglong my_getphysmem() +{ +#ifdef _WIN32 + MEMORYSTATUSEX memstatus; + memstatus.dwLength= sizeof(memstatus); + GlobalMemoryStatusEx(&memstatus); + return memstatus.ullTotalPhys; +#else + ulonglong pages= 0; + +#ifdef _SC_PHYS_PAGES + pages= sysconf(_SC_PHYS_PAGES); +#endif + +#ifdef _SC_PAGESIZE + return pages * sysconf(_SC_PAGESIZE); +#else + return pages * my_getpagesize(); +#endif +#endif +} + +/* get the number of (online) CPUs */ +int my_getncpus() +{ +#ifdef _SC_NPROCESSORS_ONLN + return sysconf(_SC_NPROCESSORS_ONLN); +#elif defined(__WIN__) + SYSTEM_INFO sysinfo; + GetSystemInfo(&sysinfo); + return sysinfo.dwNumberOfProcessors; +#else + return 0; +#endif +} + +/** + Find the version of the kernel and the linux distribution +*/ +int prepare_linux_info() +{ +#ifdef HAVE_SYS_UTSNAME_H + have_ubuf= (uname(&ubuf) != -1); +#endif + +#ifdef TARGET_OS_LINUX + /* + let's try to find what linux distribution it is + we read *[-_]{release,version} file in /etc. + + Either it will be /etc/lsb-release, such as + + ==> /etc/lsb-release <== + DISTRIB_ID=Ubuntu + DISTRIB_RELEASE=8.04 + DISTRIB_CODENAME=hardy + DISTRIB_DESCRIPTION="Ubuntu 8.04.4 LTS" + + Or a one-liner with the description (/etc/SuSE-release has more + than one line, but the description is the first, so it can be + treated as a one-liner). + + We'll read lsb-release first, and if it's not found will search + for other files (*-version *-release *_version *_release) +*/ + int fd; + have_distribution= false; + if ((fd= my_open("/etc/lsb-release", O_RDONLY, MYF(0))) != -1) + { + /* Cool, LSB-compliant distribution! */ + size_t len= my_read(fd, (uchar*)distribution, sizeof(distribution)-1, MYF(0)); + my_close(fd, MYF(0)); + if (len != (size_t)-1) + { + distribution[len]= 0; // safety + char *found= strstr(distribution, "DISTRIB_DESCRIPTION="); + if (found) + { + have_distribution= true; + char *end= strstr(found, "\n"); + if (end == NULL) + end= distribution + len; + found+= 20; + + if (*found == '"' && end[-1] == '"') + { + found++; + end--; + } + *end= 0; + + char *to= strmov(distribution, "lsb: "); + memmove(to, found, end - found + 1); + } + } + } + + /* if not an LSB-compliant distribution */ + for (uint i= 0; !have_distribution && i < array_elements(masks); i++) + { + glob_t found; + if (glob(masks[i], GLOB_NOSORT, NULL, &found) == 0) + { + int fd; + if ((fd= my_open(found.gl_pathv[0], O_RDONLY, MYF(0))) != -1) + { + /* + +5 and -8 below cut the file name part out of the + full pathname that corresponds to the mask as above. + */ + char *to= strmov(distribution, found.gl_pathv[0] + 5) - 8; + *to++= ':'; + *to++= ' '; + + size_t to_len= distribution + sizeof(distribution) - 1 - to; + size_t len= my_read(fd, (uchar*)to, to_len, MYF(0)); + my_close(fd, MYF(0)); + if (len != (size_t)-1) + { + to[len]= 0; // safety + char *end= strstr(to, "\n"); + if (end) + *end= 0; + have_distribution= true; + } + } + } + globfree(&found); + } +#endif + return 0; +} + +/** + Add the linux distribution and the kernel version +*/ +int fill_linux_info(THD *thd, TABLE_LIST *tables) +{ + TABLE *table= tables->table; + CHARSET_INFO *cs= system_charset_info; + +#ifdef HAVE_SYS_UTSNAME_H + if (have_ubuf) + { + INSERT1("Uname_sysname", (ubuf.sysname, strlen(ubuf.sysname), cs)); + INSERT1("Uname_release", (ubuf.release, strlen(ubuf.release), cs)); + INSERT1("Uname_version", (ubuf.version, strlen(ubuf.version), cs)); + INSERT1("Uname_machine", (ubuf.machine, strlen(ubuf.machine), cs)); + } +#endif + +#ifdef TARGET_OS_LINUX + if (have_distribution) + INSERT1("Uname_distribution", (distribution, strlen(distribution), cs)); +#endif + + return 0; +} + +/** + Adds varios bits of information to the I_S.FEEDBACK +*/ +int fill_misc_data(THD *thd, TABLE_LIST *tables) +{ + TABLE *table= tables->table; + +#ifdef MY_ATOMIC_OK + INSERT1("Cpu_count", (my_getncpus(), UNSIGNED)); +#endif + INSERT1("Mem_total", (my_getphysmem(), UNSIGNED)); + INSERT1("Now", (thd->query_start(), UNSIGNED)); + + return 0; +} + +/** + calculates the server unique identifier + + UID is a base64 encoded SHA1 hash of the MAC address of one of + the interfaces, and the tcp port that the server is listening on +*/ +int calculate_server_uid(char *dest) +{ + uchar rawbuf[2 + 6]; + uchar shabuf[SHA1_HASH_SIZE]; + SHA1_CONTEXT ctx; + + int2store(rawbuf, mysqld_port); + if (my_gethwaddr(rawbuf + 2)) + { + sql_print_error("feedback plugin: failed to retrieve the MAC address"); + return 1; + } + + mysql_sha1_reset(&ctx); + mysql_sha1_input(&ctx, rawbuf, sizeof(rawbuf)); + mysql_sha1_result(&ctx, shabuf); + + assert(base64_needed_encoded_length(sizeof(shabuf)) <= SERVER_UID_SIZE); + base64_encode(shabuf, sizeof(shabuf), dest); + + return 0; +} + +} // namespace feedback diff --git a/plugin/fulltext/plugin_example.c b/plugin/fulltext/plugin_example.c index 13715094850..b58f3e9eda5 100644 --- a/plugin/fulltext/plugin_example.c +++ b/plugin/fulltext/plugin_example.c @@ -1,4 +1,4 @@ -/* Copyright (c) 2006, 2011, Oracle and/or its affiliates. All rights reserved. +/* Copyright (c) 2005, 2011, Oracle and/or its affiliates. All rights reserved. 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 @@ -267,7 +267,8 @@ mysql_declare_plugin(ftexample) 0x0001, /* version */ simple_status, /* status variables */ simple_system_variables, /* system variables */ - NULL + NULL, + 0, } mysql_declare_plugin_end; diff --git a/plugin/handler_socket/handlersocket/database.cpp b/plugin/handler_socket/handlersocket/database.cpp index f63f011d9b1..311eec55fa8 100644 --- a/plugin/handler_socket/handlersocket/database.cpp +++ b/plugin/handler_socket/handlersocket/database.cpp @@ -246,11 +246,11 @@ wait_server_to_start(THD *thd, volatile int& shutdown_flag) &abstime); pthread_mutex_unlock(&LOCK_server_started); pthread_mutex_lock(&thd->mysys_var->mutex); - THD::killed_state st = thd->killed; + killed_state st = thd->killed; pthread_mutex_unlock(&thd->mysys_var->mutex); DBG_SHUT(fprintf(stderr, "HNDSOCK wsts kst %d\n", (int)st)); pthread_mutex_lock(&LOCK_server_started); - if (st != THD::NOT_KILLED) { + if (st != NOT_KILLED) { DBG_SHUT(fprintf(stderr, "HNDSOCK wsts kst %d break\n", (int)st)); r = -1; break; @@ -357,11 +357,11 @@ bool dbcontext::check_alive() { pthread_mutex_lock(&thd->mysys_var->mutex); - THD::killed_state st = thd->killed; + killed_state st = thd->killed; pthread_mutex_unlock(&thd->mysys_var->mutex); DBG_SHUT(fprintf(stderr, "chk HNDSOCK kst %p %p %d %zu\n", thd, &thd->killed, (int)st, sizeof(*thd))); - if (st != THD::NOT_KILLED) { + if (st != NOT_KILLED) { DBG_SHUT(fprintf(stderr, "chk HNDSOCK kst %d break\n", (int)st)); return false; } diff --git a/plugin/handler_socket/handlersocket/hstcpsvr_worker.cpp b/plugin/handler_socket/handlersocket/hstcpsvr_worker.cpp index fa42f2b0914..85887d1d55c 100644 --- a/plugin/handler_socket/handlersocket/hstcpsvr_worker.cpp +++ b/plugin/handler_socket/handlersocket/hstcpsvr_worker.cpp @@ -63,7 +63,7 @@ struct hstcpsvr_conn : public dbcallback_i { public: auto_file fd; sockaddr_storage addr; - socklen_t addr_len; + size_socket addr_len; dbconnstate cstate; std::string err; size_t readsize; diff --git a/plugin/handler_socket/libhsclient/auto_addrinfo.hpp b/plugin/handler_socket/libhsclient/auto_addrinfo.hpp index c3ab64e8127..f0c07060be1 100644 --- a/plugin/handler_socket/libhsclient/auto_addrinfo.hpp +++ b/plugin/handler_socket/libhsclient/auto_addrinfo.hpp @@ -9,12 +9,15 @@ #ifndef DENA_AUTO_ADDRINFO_HPP #define DENA_AUTO_ADDRINFO_HPP +#include <my_config.h> #include <sys/types.h> #include <sys/socket.h> #include <netdb.h> #include "util.hpp" +typedef SOCKET_SIZE_TYPE size_socket; + namespace dena { struct auto_addrinfo : private noncopyable { diff --git a/plugin/handler_socket/libhsclient/socket.cpp b/plugin/handler_socket/libhsclient/socket.cpp index 5d84a7c4adf..0c4816589fa 100644 --- a/plugin/handler_socket/libhsclient/socket.cpp +++ b/plugin/handler_socket/libhsclient/socket.cpp @@ -172,7 +172,7 @@ socket_bind(auto_file& fd, const socket_args& args, std::string& err_r) int socket_accept(int listen_fd, auto_file& fd, const socket_args& args, - sockaddr_storage& addr_r, socklen_t& addrlen_r, std::string& err_r) + sockaddr_storage& addr_r, size_socket& addrlen_r, std::string& err_r) { fd.reset(accept(listen_fd, reinterpret_cast<sockaddr *>(&addr_r), &addrlen_r)); diff --git a/plugin/handler_socket/libhsclient/socket.hpp b/plugin/handler_socket/libhsclient/socket.hpp index 3da6020e843..c6e638c9c01 100644 --- a/plugin/handler_socket/libhsclient/socket.hpp +++ b/plugin/handler_socket/libhsclient/socket.hpp @@ -19,7 +19,7 @@ namespace dena { struct socket_args { sockaddr_storage addr; - socklen_t addrlen; + size_socket addrlen; int family; int socktype; int protocol; @@ -43,7 +43,7 @@ void ignore_sigpipe(); int socket_bind(auto_file& fd, const socket_args& args, std::string& err_r); int socket_connect(auto_file& fd, const socket_args& args, std::string& err_r); int socket_accept(int listen_fd, auto_file& fd, const socket_args& args, - sockaddr_storage& addr_r, socklen_t& addrlen_r, std::string& err_r); + sockaddr_storage& addr_r, size_socket& addrlen_r, std::string& err_r); }; diff --git a/plugin/handler_socket/perl-Net-HandlerSocket/HandlerSocket.xs b/plugin/handler_socket/perl-Net-HandlerSocket/HandlerSocket.xs index 39f11e2780e..8e8d2520337 100644 --- a/plugin/handler_socket/perl-Net-HandlerSocket/HandlerSocket.xs +++ b/plugin/handler_socket/perl-Net-HandlerSocket/HandlerSocket.xs @@ -12,6 +12,11 @@ #include "ppport.h" +/* + below we'll include (indirectly) my_global.h, which defines + VERSION too. Undefine our VERSION here. +*/ +#undef VERSION #include "hstcpcli.hpp" #define DBG(x) diff --git a/plugin/handler_socket/perl-Net-HandlerSocket/Makefile.PL b/plugin/handler_socket/perl-Net-HandlerSocket/Makefile.PL.in index 50c329db4b6..1a9b1444fb8 100644 --- a/plugin/handler_socket/perl-Net-HandlerSocket/Makefile.PL +++ b/plugin/handler_socket/perl-Net-HandlerSocket/Makefile.PL.in @@ -11,8 +11,8 @@ WriteMakefile( AUTHOR => 'higuchi dot akira at dena dot jp>') : ()), CC => 'g++ -fPIC', LD => 'g++ -fPIC', - LIBS => ['-L../libhsclient -L../libhsclient/.libs -lhsclient'], + LIBS => ['-L@builddir@/../libhsclient -L@builddir@/../libhsclient/.libs -lhsclient'], DEFINE => '', - INC => '-I. -I../libhsclient', + INC => '-I. -I../libhsclient -I@builddir@/../libhsclient -I@top_builddir@/include', OPTIMIZE => '-g -O3 -Wall -Wno-unused', ); diff --git a/plugin/handler_socket/perl-Net-HandlerSocket/Makefile.PL.installed b/plugin/handler_socket/perl-Net-HandlerSocket/Makefile.PL.installed index 1b7649498d2..0d01bceb819 100644 --- a/plugin/handler_socket/perl-Net-HandlerSocket/Makefile.PL.installed +++ b/plugin/handler_socket/perl-Net-HandlerSocket/Makefile.PL.installed @@ -13,7 +13,7 @@ WriteMakefile( LD => 'g++ -fPIC', LIBS => ['-lhsclient'], # e.g., '-lm' DEFINE => '', # e.g., '-DHAVE_SOMETHING' - INC => '-I. -I/usr/include/handlersocket', + INC => '-I. -I/usr/include/handlersocket -I/usr/include/mysql', OPTIMIZE => '-g -O3 -Wall -Wno-unused', # Un-comment this if you add C files to link with later: # OBJECT => '$(O_FILES)', # link all the C files too diff --git a/plugin/handler_socket/plug.in b/plugin/handler_socket/plug.in index 0a6c36ba39f..fd351dec98d 100644 --- a/plugin/handler_socket/plug.in +++ b/plugin/handler_socket/plug.in @@ -16,4 +16,5 @@ MYSQL_PLUGIN_ACTIONS(handlersocket, AC_SUBST(MYSQL_LIB) AC_SUBST(PLUGIN_DIR) AC_SUBST(HANDLERSOCKET_SUBDIRS) + AC_CONFIG_FILES(plugin/handler_socket/perl-Net-HandlerSocket/Makefile.PL) ]) diff --git a/plugin/semisync/semisync_master.cc b/plugin/semisync/semisync_master.cc index 2e9e89cdef7..7504697a21f 100644 --- a/plugin/semisync/semisync_master.cc +++ b/plugin/semisync/semisync_master.cc @@ -1,5 +1,6 @@ /* Copyright (C) 2007 Google Inc. - Copyright (C) 2008 MySQL AB, 2008-2009 Sun Microsystems, Inc + Copyright (c) 2008 MySQL AB, 2008-2009 Sun Microsystems, Inc. + Use is subject to license terms. 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 @@ -307,18 +308,18 @@ int ActiveTranx::clear_active_tranx_nodes(const char *log_file_name, * The most important functions during semi-syn replication listed: * * Master: - * . reportReplyBinlog(): called by the binlog dump thread when it receives - * the slave's status information. - * . updateSyncHeader(): based on transaction waiting information, decide - * whether to request the slave to reply. - * . writeTraxInBinlog(): called by the transaction thread when it finishes - * writing all transaction events in binlog. - * . commitTrx(): transaction thread wait for the slave reply. + * . reportReplyBinlog(): called by the binlog dump thread when it receives + * the slave's status information. + * . updateSyncHeader(): based on transaction waiting information, decide + * whether to request the slave to reply. + * . writeTranxInBinlog(): called by the transaction thread when it finishes + * writing all transaction events in binlog. + * . commitTrx(): transaction thread wait for the slave reply. * * Slave: * . slaveReadSyncHeader(): read the semi-sync header from the master, get the - * sync status and get the payload for events. - * . slaveReply(): reply to the master about the replication progress. + * sync status and get the payload for events. + * . slaveReply(): reply to the master about the replication progress. * ******************************************************************************/ diff --git a/plugin/semisync/semisync_master.h b/plugin/semisync/semisync_master.h index dfadf85f271..841c24197fc 100644 --- a/plugin/semisync/semisync_master.h +++ b/plugin/semisync/semisync_master.h @@ -1,6 +1,6 @@ /* Copyright (C) 2007 Google Inc. - Copyright (C) 2008 MySQL AB - Copyright (C) 2009 Sun Microsystems, Inc + Copyright (c) 2008 MySQL AB, 2009 Sun Microsystems, Inc. + Use is subject to license terms. 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/plugin/semisync/semisync_master_plugin.cc b/plugin/semisync/semisync_master_plugin.cc index a55ba184a17..9a325018242 100644 --- a/plugin/semisync/semisync_master_plugin.cc +++ b/plugin/semisync/semisync_master_plugin.cc @@ -1,5 +1,6 @@ /* Copyright (C) 2007 Google Inc. - Copyright (C) 2008 MySQL AB, 2008-2009 Sun Microsystems, Inc + Copyright (c) 2008 MySQL AB, 2008-2009 Sun Microsystems, Inc. + Use is subject to license terms. 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 @@ -428,6 +429,7 @@ mysql_declare_plugin(semi_sync_master) 0x0100 /* 1.0 */, semi_sync_master_status_vars, /* status variables */ semi_sync_master_system_vars, /* system variables */ - NULL /* config options */ + NULL, /* config options */ + 0, /* flags */ } mysql_declare_plugin_end; diff --git a/plugin/semisync/semisync_slave.cc b/plugin/semisync/semisync_slave.cc index 109577fb688..5f98472d5d7 100644 --- a/plugin/semisync/semisync_slave.cc +++ b/plugin/semisync/semisync_slave.cc @@ -1,4 +1,5 @@ -/* Copyright (C) 2008 MySQL AB +/* Copyright (c) 2008 MySQL AB, 2009 Sun Microsystems, Inc. + Use is subject to license terms. 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/plugin/semisync/semisync_slave.h b/plugin/semisync/semisync_slave.h index 19ea43e2653..1bf8cf31972 100644 --- a/plugin/semisync/semisync_slave.h +++ b/plugin/semisync/semisync_slave.h @@ -1,4 +1,5 @@ -/* Copyright (C) 2006 MySQL AB +/* Copyright (c) 2006 MySQL AB, 2009 Sun Microsystems, Inc. + Use is subject to license terms. 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/plugin/semisync/semisync_slave_plugin.cc b/plugin/semisync/semisync_slave_plugin.cc index cfb04bdd276..d5472b9cc83 100644 --- a/plugin/semisync/semisync_slave_plugin.cc +++ b/plugin/semisync/semisync_slave_plugin.cc @@ -225,6 +225,7 @@ mysql_declare_plugin(semi_sync_slave) 0x0100 /* 1.0 */, semi_sync_slave_status_vars, /* status variables */ semi_sync_slave_system_vars, /* system variables */ - NULL /* config options */ + NULL, /* config options */ + 0, /* flags */ } mysql_declare_plugin_end; diff --git a/plugin/win_auth_client/common.cc b/plugin/win_auth_client/common.cc index 1d1f2938969..9544e7734f5 100644 --- a/plugin/win_auth_client/common.cc +++ b/plugin/win_auth_client/common.cc @@ -22,6 +22,24 @@ template <> void error_log_print<error_log_level::INFO>(const char *fmt, ...); template <> void error_log_print<error_log_level::WARNING>(const char *fmt, ...); template <> void error_log_print<error_log_level::ERROR>(const char *fmt, ...); +/** + Option indicating desired level of logging. Values: + + 0 - no logging + 1 - log only error messages + 2 - additionally log warnings + 3 - additionally log info notes + 4 - also log debug messages + + Value of this option should be taken into account in the + implementation of error_log_vprint() function (see + log_client.cc). + + Note: No error or debug messages are logged in production code + (see logging macros in common.h). +*/ +int opt_auth_win_log_level= 2; + /** Connection class **************************************************/ diff --git a/plugin/win_auth_client/common.h b/plugin/win_auth_client/common.h index ff0f7153664..7f7aa1d2dff 100644 --- a/plugin/win_auth_client/common.h +++ b/plugin/win_auth_client/common.h @@ -41,13 +41,15 @@ struct error_log_level typedef enum {INFO, WARNING, ERROR} type; }; +extern "C" int opt_auth_win_log_level; +unsigned int get_log_level(void); +void set_log_level(unsigned int); + /* If DEBUG_ERROR_LOG is defined then error logging happens only in debug-copiled code. Otherwise ERROR_LOG() expands to - error_log_print() even in production code. Note that in client - plugin, error_log_print() will print nothing if opt_auth_win_clinet_log - is 0. + error_log_print() even in production code. Note: Macro ERROR_LOG() can use printf-like format string like this: @@ -57,8 +59,6 @@ struct error_log_level to fprintf() (see error_log_vprint() function). */ -extern "C" int opt_auth_win_client_log; - #if defined(DEBUG_ERROR_LOG) && defined(DBUG_OFF) #define ERROR_LOG(Level, Msg) do {} while (0) #else @@ -67,7 +67,7 @@ extern "C" int opt_auth_win_client_log; void error_log_vprint(error_log_level::type level, - const char *fmt, va_list args); + const char *fmt, va_list args); template <error_log_level::type Level> void error_log_print(const char *fmt, ...) @@ -96,7 +96,7 @@ const char* get_last_error_message(Error_message_buf); #define DBUG_PRINT_DO(Keyword, Msg) \ do { \ - if (2 > opt_auth_win_client_log) break; \ + if (4 > get_log_level()) break; \ fprintf(stderr, "winauth: %s: ", Keyword); \ debug_msg Msg; \ } while (0) diff --git a/plugin/win_auth_client/handshake_client.cc b/plugin/win_auth_client/handshake_client.cc index 7e89fc92ae7..02e5483da29 100644 --- a/plugin/win_auth_client/handshake_client.cc +++ b/plugin/win_auth_client/handshake_client.cc @@ -161,6 +161,21 @@ int Handshake_client::write_packet(Blob &data) keep all the data. */ unsigned block_count= data.len()/512 + ((data.len() % 512) ? 1 : 0); + +#if !defined(DBUG_OFF) && defined(WINAUTH_USE_DBUG_LIB) + + /* + For testing purposes, use wrong block count to see how server + handles this. + */ + DBUG_EXECUTE_IF("winauth_first_packet_test",{ + block_count= data.len() == 601 ? 0 : + data.len() == 602 ? 1 : + block_count; + }); + +#endif + DBUG_ASSERT(block_count < (unsigned)0x100); saved_byte= data[254]; data[254] = block_count; @@ -323,13 +338,13 @@ int win_auth_handshake_client(MYSQL_PLUGIN_VIO *vio, MYSQL *mysql) int opt_val= opt ? atoi(opt) : 0; if (opt && !opt_val) { - if (!strncasecmp("on", opt, 2)) opt_val= 1; - if (!strncasecmp("yes", opt, 3)) opt_val= 1; - if (!strncasecmp("true", opt, 4)) opt_val= 1; - if (!strncasecmp("debug", opt, 5)) opt_val= 2; - if (!strncasecmp("dbug", opt, 4)) opt_val= 2; + if (!strncasecmp("on", opt, 2)) opt_val= 2; + if (!strncasecmp("yes", opt, 3)) opt_val= 2; + if (!strncasecmp("true", opt, 4)) opt_val= 2; + if (!strncasecmp("debug", opt, 5)) opt_val= 4; + if (!strncasecmp("dbug", opt, 4)) opt_val= 4; } - opt_auth_win_client_log= opt_val; + set_log_level(opt_val); } ERROR_LOG(INFO, ("Authentication handshake for account %s", mysql->user)); diff --git a/plugin/win_auth_client/log_client.cc b/plugin/win_auth_client/log_client.cc index df4ce4f9c2a..8a49c4220bb 100644 --- a/plugin/win_auth_client/log_client.cc +++ b/plugin/win_auth_client/log_client.cc @@ -16,36 +16,32 @@ #include <my_global.h> #include "common.h" -/** - This option is set in win_auth_handshake_client() function - in handshake_client.cc. - - Values: - 0 - no logging - 1 - log error/warning/info messages - 2 - also log debug messages - - Note: No error or debug messages are logged in production code - (see logging macros in common.h). -*/ -int opt_auth_win_client_log= 0; - // Client-side logging function void error_log_vprint(error_log_level::type level, const char *fmt, va_list args) { - if (0 == opt_auth_win_client_log) - return; - const char *level_string= ""; + int log_level= get_log_level(); switch (level) { - case error_log_level::INFO: level_string= "Note"; break; - case error_log_level::WARNING: level_string= "Warning"; break; - case error_log_level::ERROR: level_string= "ERROR"; break; + case error_log_level::INFO: + if (3 > log_level) + return; + level_string= "Note"; + break; + case error_log_level::WARNING: + if (2 > log_level) + return; + level_string= "Warning"; + break; + case error_log_level::ERROR: + if (1 > log_level) + return; + level_string= "ERROR"; + break; } fprintf(stderr, "Windows Authentication Plugin %s: ", level_string); @@ -53,3 +49,17 @@ void error_log_vprint(error_log_level::type level, fputc('\n', stderr); fflush(stderr); } + + +// Trivial implementation of log-level setting storage. + +void set_log_level(unsigned int level) +{ + opt_auth_win_log_level= level; +} + + +unsigned int get_log_level(void) +{ + return opt_auth_win_log_level; +} diff --git a/scripts/CMakeLists.txt b/scripts/CMakeLists.txt index 56b7f779bb0..424d92e31e1 100644 --- a/scripts/CMakeLists.txt +++ b/scripts/CMakeLists.txt @@ -1,4 +1,4 @@ -# Copyright (c) 2006, 2010, Oracle and/or its affiliates. All rights reserved. +# Copyright (c) 2006, 2011, Oracle and/or its affiliates. All rights reserved. # # 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 @@ -65,7 +65,7 @@ ADD_CUSTOM_TARGET(GenFixPrivs IF(UNIX) FILE(WRITE ${CMAKE_CURRENT_BINARY_DIR}/make_binary_distribution - "cd ${CMAKE_BINARY_DIR} && '${CMAKE_CPACK_COMMAND}' -G TGZ --config CPackConfig.cmake" ) + "cd ${CMAKE_BINARY_DIR} && '${CMAKE_CPACK_COMMAND}' -G TGZ --config CPackConfig.cmake\n" ) EXECUTE_PROCESS( COMMAND chmod +x ${CMAKE_CURRENT_BINARY_DIR}/make_binary_distribution ) @@ -104,11 +104,11 @@ IF(UNIX) # FIND_PROC and CHECK_PID are used by mysqld_safe IF(CMAKE_SYSTEM_NAME MATCHES "Linux") SET (FIND_PROC - "ps wwwp $PID | grep -v \" grep\" | grep -v mysqld_safe | grep -- \"$MYSQLD\" > /dev/null") + "ps wwwp $PID | grep -v mysqld_safe | grep -- $MYSQLD > /dev/null") ENDIF() IF(NOT FIND_PROC AND CMAKE_SYSTEM_NAME MATCHES "SunOS") SET (FIND_PROC - "ps -p $PID | grep -v \" grep\" | grep -v mysqld_safe | grep -- \"$MYSQLD\" > /dev/null") + "ps -p $PID | grep -v mysqld_safe | grep -- $MYSQLD > /dev/null") ENDIF() IF(NOT FIND_PROC) @@ -116,7 +116,7 @@ IF(NOT FIND_PROC) EXECUTE_PROCESS(COMMAND ps -uaxww OUTPUT_QUIET ERROR_QUIET RESULT_VARIABLE result) IF(result MATCHES 0) SET( FIND_PROC - "ps -uaxww | grep -v \" grep\" | grep -v mysqld_safe | grep -- \"$MYSQLD\" | grep \" $PID \" > /dev/null") + "ps -uaxww | grep -v mysqld_safe | grep -- $MYSQLD | grep $PID > /dev/null") ENDIF() ENDIF() @@ -124,7 +124,7 @@ IF(NOT FIND_PROC) # SysV style EXECUTE_PROCESS(COMMAND ps -ef OUTPUT_QUIET ERROR_QUIET RESULT_VARIABLE result) IF(result MATCHES 0) - SET( FIND_PROC "ps -ef | grep -v \" grep\" | grep -v mysqld_safe | grep -- \"$MYSQLD\" | grep \" $PID \" > /dev/null") + SET( FIND_PROC "ps -ef | grep -v mysqld_safe | grep -- $MYSQLD | grep $PID > /dev/null") ENDIF() ENDIF() diff --git a/scripts/dheadgen.pl b/scripts/dheadgen.pl index 374b232a04e..c42bd49b32e 100755 --- a/scripts/dheadgen.pl +++ b/scripts/dheadgen.pl @@ -1,7 +1,7 @@ #!/usr/bin/perl -w # -# Copyright 2007 Sun Microsystems, Inc. All rights reserved. +# Copyright (c) 2008, 2009 Sun Microsystems, Inc. # Use is subject to license terms. # diff --git a/scripts/make_binary_distribution.sh b/scripts/make_binary_distribution.sh index 95de41d517b..7c9126f0d71 100644 --- a/scripts/make_binary_distribution.sh +++ b/scripts/make_binary_distribution.sh @@ -167,6 +167,7 @@ echo "PLATFORM NAME: $PLATFORM" VERSION_NAME=@VERSION@ case $VERSION_NAME in *-ndb-* ) VERSION_NAME=`echo $VERSION_NAME | sed -e 's/[.0-9]*-ndb-//'` ;; + *-MariaDB-* ) VERSION_NAME=`echo $VERSION_NAME | sed -e 's/-MariaDB//'` ;; esac if [ x"$SHORT_PRODUCT_TAG" != x"" ] ; then NEW_NAME=mariadb-$SHORT_PRODUCT_TAG-$VERSION_NAME-$PLATFORM$SUFFIX diff --git a/scripts/mysql_config.pl.in b/scripts/mysql_config.pl.in index fb48979eb7b..acf33699b05 100644 --- a/scripts/mysql_config.pl.in +++ b/scripts/mysql_config.pl.in @@ -1,7 +1,7 @@ #!/usr/bin/perl # -*- cperl -*- # -# Copyright (C) 2007 MySQL AB +# Copyright (c) 2007, 2010, Oracle and/or its affiliates. All rights reserved. # # 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 @@ -14,7 +14,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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA ############################################################################## # diff --git a/scripts/mysql_config.sh b/scripts/mysql_config.sh index 6463b3bf099..c05b311cc7b 100644 --- a/scripts/mysql_config.sh +++ b/scripts/mysql_config.sh @@ -1,5 +1,5 @@ #!/bin/sh -# Copyright (C) 2000-2006 MySQL AB +# Copyright (c) 2000, 2010, Oracle and/or its affiliates. All rights reserved. # # 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 @@ -12,7 +12,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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA # This script reports various configuration settings that may be needed # when using the MySQL client library. diff --git a/scripts/mysql_convert_table_format.sh b/scripts/mysql_convert_table_format.sh index 7983982913c..5f3e093d2b9 100644 --- a/scripts/mysql_convert_table_format.sh +++ b/scripts/mysql_convert_table_format.sh @@ -1,5 +1,6 @@ #!/usr/bin/perl -# Copyright (C) 2000-2002 MySQL AB +# Copyright (c) 2000-2002, 2006, 2007 MySQL AB, 2009 Sun Microsystems, Inc. +# Use is subject to license terms. # # 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/scripts/mysql_find_rows.sh b/scripts/mysql_find_rows.sh index 967a8196ebd..48c4915ae00 100644 --- a/scripts/mysql_find_rows.sh +++ b/scripts/mysql_find_rows.sh @@ -1,5 +1,6 @@ #!/usr/bin/perl -# Copyright (C) 2000, 2004 MySQL AB +# Copyright (c) 2000, 2004, 2006 MySQL AB, 2009 Sun Microsystems, Inc. +# Use is subject to license terms. # # 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/scripts/mysql_fix_extensions.sh b/scripts/mysql_fix_extensions.sh index 74a47fdf4a1..2a50bfe22bb 100644 --- a/scripts/mysql_fix_extensions.sh +++ b/scripts/mysql_fix_extensions.sh @@ -1,6 +1,7 @@ #!/usr/bin/perl -# Copyright (C) 2001 MySQL AB, 2009 Sun Microsystems, Inc. +# Copyright (c) 2001 MySQL AB, 2009 Sun Microsystems, Inc. +# Use is subject to license terms. # # This program is free software; you can redistribute it and/or # modify it under the terms of the GNU Library General Public @@ -14,8 +15,8 @@ # # You should have received a copy of the GNU Library General Public # License along with this library; if not, write to the Free -# Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, -# MA 02111-1307, USA +# Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, +# MA 02110-1301, USA # This is a utility for MySQL. It is not needed by any standard part # of MySQL. diff --git a/scripts/mysql_install_db.pl.in b/scripts/mysql_install_db.pl.in index 2119a1b650a..83756d686d2 100644 --- a/scripts/mysql_install_db.pl.in +++ b/scripts/mysql_install_db.pl.in @@ -61,10 +61,15 @@ Usage: $0 [OPTIONS] --cross-bootstrap For internal use. Used when building the MySQL system tables on a different host than the target. --datadir=path The path to the MySQL data directory. + --defaults-extra-file=name + Read this file after the global files are read. + --defaults-file=name Only read default options from the given file name. --force Causes mysql_install_db to run even if DNS does not work. In that case, grant table entries that normally use hostnames will use IP addresses. + --help Display this help and exit. --ldata=path The path to the MySQL data directory. Same as --datadir. + --no-defaults Don't read default options from any option file. --rpm For internal use. This option is used by RPM files during the MySQL installation process. --skip-name-resolve Use IP addresses rather than hostnames when creating diff --git a/scripts/mysql_install_db.sh b/scripts/mysql_install_db.sh index 5b21de31f6d..0454654ad1d 100644 --- a/scripts/mysql_install_db.sh +++ b/scripts/mysql_install_db.sh @@ -1,5 +1,7 @@ #!/bin/sh +# Copyright (c) 2000-2008 MySQL AB, 2009, 2010 Sun Microsystems, Inc. # Copyright (C) 2002-2003 MySQL AB & Monty Program Ab +# Use is subject to license terms. # # 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 @@ -45,12 +47,16 @@ Usage: $0 [OPTIONS] --cross-bootstrap For internal use. Used when building the MariaDB system tables on a different host than the target. --datadir=path The path to the MariaDB data directory. + --defaults-extra-file=name + Read this file after the global files are read. + --defaults-file=name Only read default options from the given file name. --force Causes mysql_install_db to run even if DNS does not work. In that case, grant table entries that normally use hostnames will use IP addresses. + --help Display this help and exit. --ldata=path The path to the MariaDB data directory. Same as --datadir. - --no-defaults Don't read any configuration files (my.cnf). + --no-defaults Don't read default options from any option file. --defaults-file=path Read only this configuration file. --rpm For internal use. This option is used by RPM files during the MariaDB installation process. diff --git a/scripts/mysql_secure_installation.pl.in b/scripts/mysql_secure_installation.pl.in index 0cd99267cdb..543b8d1b1c0 100755 --- a/scripts/mysql_secure_installation.pl.in +++ b/scripts/mysql_secure_installation.pl.in @@ -1,7 +1,7 @@ #!/usr/bin/perl # -*- cperl -*- # -# Copyright (C) 2002 MySQL AB and Jeremy Cole +# Copyright (c) 2007, 2010, Oracle and/or its affiliates. All rights reserved. # # 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 @@ -14,7 +14,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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA use Fcntl; use File::Spec; diff --git a/scripts/mysql_secure_installation.sh b/scripts/mysql_secure_installation.sh index d59f1ac8565..d5ace68ea76 100644 --- a/scripts/mysql_secure_installation.sh +++ b/scripts/mysql_secure_installation.sh @@ -1,6 +1,6 @@ #!/bin/sh -# Copyright (C) 2002 MySQL AB and Jeremy Cole +# Copyright (c) 2002, 2010, Oracle and/or its affiliates. All rights reserved. # # 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 @@ -13,7 +13,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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA config=".my.cnf.$$" command=".mysql.$$" diff --git a/scripts/mysql_setpermission.sh b/scripts/mysql_setpermission.sh index 433f30dfabb..f23011a5ae6 100644 --- a/scripts/mysql_setpermission.sh +++ b/scripts/mysql_setpermission.sh @@ -1,7 +1,8 @@ #!/usr/bin/perl ## Emacs, this is -*- perl -*- mode? :-) -# Copyright (C) 2000, 2007 MySQL AB, 2009 Sun Microsystems, Inc. +# Copyright (c) 2000, 2007 MySQL AB, 2009 Sun Microsystems, Inc. +# Use is subject to license terms. # # This program is free software; you can redistribute it and/or # modify it under the terms of the GNU Library General Public @@ -15,8 +16,8 @@ # # You should have received a copy of the GNU Library General Public # License along with this library; if not, write to the Free -# Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, -# MA 02111-1307, USA +# Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, +# MA 02110-1301, USA ## ## Permission setter for MySQL diff --git a/scripts/mysql_system_tables.sql b/scripts/mysql_system_tables.sql index e1ac071fd3b..c8e0aa7b435 100644 --- a/scripts/mysql_system_tables.sql +++ b/scripts/mysql_system_tables.sql @@ -1,4 +1,4 @@ --- Copyright (C) 2008, 2010 Oracle and/or its affiliates. +-- Copyright (C) 2008, 2011 Oracle and/or its affiliates. -- Copyright (C) 2010, 2011 Monty Program Ab -- -- This program is free software; you can redistribute it and/or modify @@ -28,7 +28,7 @@ set @had_db_table= @@warning_count != 0; CREATE TABLE IF NOT EXISTS host ( Host char(60) binary DEFAULT '' NOT NULL, Db char(64) binary DEFAULT '' NOT NULL, Select_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL, Insert_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL, Update_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL, Delete_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL, Create_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL, Drop_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL, Grant_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL, References_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL, Index_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL, Alter_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL, Create_tmp_table_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL, Lock_tables_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL, Create_view_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL, Show_view_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL, Create_routine_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL, Alter_routine_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL, Execute_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL, Trigger_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL, PRIMARY KEY Host (Host,Db) ) engine=MyISAM CHARACTER SET utf8 COLLATE utf8_bin comment='Host privileges; Merged with database privileges'; -CREATE TABLE IF NOT EXISTS user ( Host char(60) binary DEFAULT '' NOT NULL, User char(16) binary DEFAULT '' NOT NULL, Password char(41) character set latin1 collate latin1_bin DEFAULT '' NOT NULL, Select_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL, Insert_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL, Update_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL, Delete_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL, Create_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL, Drop_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL, Reload_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL, Shutdown_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL, Process_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL, File_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL, Grant_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL, References_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL, Index_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL, Alter_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL, Show_db_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL, Super_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL, Create_tmp_table_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL, Lock_tables_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL, Execute_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL, Repl_slave_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL, Repl_client_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL, Create_view_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL, Show_view_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL, Create_routine_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL, Alter_routine_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL, Create_user_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL, Event_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL, Trigger_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL, Create_tablespace_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL, ssl_type enum('','ANY','X509', 'SPECIFIED') COLLATE utf8_general_ci DEFAULT '' NOT NULL, ssl_cipher BLOB NOT NULL, x509_issuer BLOB NOT NULL, x509_subject BLOB NOT NULL, max_questions int(11) unsigned DEFAULT 0 NOT NULL, max_updates int(11) unsigned DEFAULT 0 NOT NULL, max_connections int(11) unsigned DEFAULT 0 NOT NULL, max_user_connections int(11) unsigned DEFAULT 0 NOT NULL, plugin char(64) CHARACTER SET latin1 DEFAULT '' NOT NULL, authentication_string TEXT NOT NULL, PRIMARY KEY Host (Host,User) ) engine=MyISAM CHARACTER SET utf8 COLLATE utf8_bin comment='Users and global privileges'; +CREATE TABLE IF NOT EXISTS user ( Host char(60) binary DEFAULT '' NOT NULL, User char(16) binary DEFAULT '' NOT NULL, Password char(41) character set latin1 collate latin1_bin DEFAULT '' NOT NULL, Select_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL, Insert_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL, Update_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL, Delete_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL, Create_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL, Drop_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL, Reload_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL, Shutdown_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL, Process_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL, File_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL, Grant_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL, References_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL, Index_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL, Alter_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL, Show_db_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL, Super_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL, Create_tmp_table_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL, Lock_tables_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL, Execute_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL, Repl_slave_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL, Repl_client_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL, Create_view_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL, Show_view_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL, Create_routine_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL, Alter_routine_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL, Create_user_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL, Event_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL, Trigger_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL, Create_tablespace_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL, ssl_type enum('','ANY','X509', 'SPECIFIED') COLLATE utf8_general_ci DEFAULT '' NOT NULL, ssl_cipher BLOB NOT NULL, x509_issuer BLOB NOT NULL, x509_subject BLOB NOT NULL, max_questions int(11) unsigned DEFAULT 0 NOT NULL, max_updates int(11) unsigned DEFAULT 0 NOT NULL, max_connections int(11) unsigned DEFAULT 0 NOT NULL, max_user_connections int(11) DEFAULT 0 NOT NULL, plugin char(64) CHARACTER SET latin1 DEFAULT '' NOT NULL, authentication_string TEXT NOT NULL, PRIMARY KEY Host (Host,User) ) engine=MyISAM CHARACTER SET utf8 COLLATE utf8_bin comment='Users and global privileges'; -- Remember for later if user table already existed set @had_user_table= @@warning_count != 0; diff --git a/scripts/mysql_system_tables_data.sql b/scripts/mysql_system_tables_data.sql index 0d6127d2173..a3b6f6cbfef 100644 --- a/scripts/mysql_system_tables_data.sql +++ b/scripts/mysql_system_tables_data.sql @@ -1,4 +1,4 @@ --- Copyright (C) 2007, 2008 MySQL AB +-- Copyright (c) 2007, 2010, Oracle and/or its affiliates. All rights reserved. -- -- 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 @@ -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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +-- Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA -- -- The inital data for system tables of MySQL Server diff --git a/scripts/mysql_system_tables_fix.sql b/scripts/mysql_system_tables_fix.sql index 1ad06b6013d..cc697092e6e 100644 --- a/scripts/mysql_system_tables_fix.sql +++ b/scripts/mysql_system_tables_fix.sql @@ -1,4 +1,4 @@ --- Copyright (C) 2003, 2010 Oracle and/or its affiliates. +-- Copyright (C) 2003, 2011 Oracle and/or its affiliates. -- Copyright (C) 2010, 2011 Monty Program Ab -- -- This program is free software; you can redistribute it and/or modify @@ -343,8 +343,11 @@ UPDATE host SET Create_routine_priv=Create_priv, Alter_routine_priv=Alter_priv, # # Add max_user_connections resource limit +# this is signed in MariaDB so that if one sets it's to -1 then the user +# can't connect anymore. # -ALTER TABLE user ADD max_user_connections int(11) unsigned DEFAULT '0' NOT NULL AFTER max_connections; +ALTER TABLE user ADD max_user_connections int(11) DEFAULT '0' NOT NULL AFTER max_connections; +ALTER TABLE user MODIFY max_user_connections int(11) DEFAULT '0' NOT NULL AFTER max_connections; # # user.Create_user_priv diff --git a/scripts/mysql_zap.sh b/scripts/mysql_zap.sh index f78212e2578..a9c3e7a7f5a 100644 --- a/scripts/mysql_zap.sh +++ b/scripts/mysql_zap.sh @@ -1,5 +1,6 @@ #!/usr/bin/perl -# Copyright (C) 2000-2002, 2004 MySQL AB +# Copyright (c) 2000-2002, 2004, 2006 MySQL AB, 2009 Sun Microsystems, Inc. +# Use is subject to license terms. # # 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/scripts/mysqlaccess.sh b/scripts/mysqlaccess.sh index 4e208e6c16e..bab0dbf5b87 100644 --- a/scripts/mysqlaccess.sh +++ b/scripts/mysqlaccess.sh @@ -1,6 +1,7 @@ #!/usr/bin/perl -# Copyright (C) 2000, 2007 MySQL AB, 2009 Sun Microsystems, Inc. +# Copyright (c) 2000, 2007 MySQL AB, 2009 Sun Microsystems, Inc. +# Use is subject to license terms. # # This program is free software; you can redistribute it and/or # modify it under the terms of the GNU Library General Public @@ -14,8 +15,8 @@ # # You should have received a copy of the GNU Library General Public # License along with this library; if not, write to the Free -# Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, -# MA 02111-1307, USA +# Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, +# MA 02110-1301, USA # **************************** package MySQLaccess; diff --git a/scripts/mysqld_multi.sh b/scripts/mysqld_multi.sh index 6b421034447..9d2571b201f 100644 --- a/scripts/mysqld_multi.sh +++ b/scripts/mysqld_multi.sh @@ -1,5 +1,22 @@ #!/usr/bin/perl +# Copyright (c) 2000, 2010, Oracle and/or its affiliates. All rights reserved. +# +# This program is free software; you can redistribute it and/or +# modify it under the terms of the GNU Library General Public +# License as published by the Free Software Foundation; version 2 +# of the License. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# Library General Public License for more details. +# +# You should have received a copy of the GNU Library General Public +# License along with this library; if not, write to the Free +# Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, +# MA 02110-1301, USA + use Getopt::Long; use POSIX qw(strftime getcwd); diff --git a/scripts/mysqldumpslow.sh b/scripts/mysqldumpslow.sh index de565678f9b..0de4fe159f0 100644 --- a/scripts/mysqldumpslow.sh +++ b/scripts/mysqldumpslow.sh @@ -1,4 +1,23 @@ #!/usr/bin/perl + +# Copyright (c) 2000-2002, 2005-2008 MySQL AB, 2008, 2009 Sun Microsystems, Inc. +# Use is subject to license terms. +# +# This program is free software; you can redistribute it and/or +# modify it under the terms of the GNU Library General Public +# License as published by the Free Software Foundation; version 2 +# of the License. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# Library General Public License for more details. +# +# You should have received a copy of the GNU Library General Public +# License along with this library; if not, write to the Free +# Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, +# MA 02110-1301, USA + # mysqldumpslow - parse and summarize the MySQL slow query log # Original version by Tim Bunce, sometime in 2000. diff --git a/scripts/mysqlhotcopy.sh b/scripts/mysqlhotcopy.sh index d605f6ef02d..b7fb73cf1dd 100644 --- a/scripts/mysqlhotcopy.sh +++ b/scripts/mysqlhotcopy.sh @@ -1,5 +1,22 @@ #!/usr/bin/perl +# Copyright (c) 2000, 2010, Oracle and/or its affiliates. All rights reserved. +# +# This program is free software; you can redistribute it and/or +# modify it under the terms of the GNU Library General Public +# License as published by the Free Software Foundation; version 2 +# of the License. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# Library General Public License for more details. +# +# You should have received a copy of the GNU Library General Public +# License along with this library; if not, write to the Free +# Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, +# MA 02110-1301, USA + use strict; use Getopt::Long; use Data::Dumper; diff --git a/sql-bench/as3ap.sh b/sql-bench/as3ap.sh index 1c672377fd3..52e790cafeb 100644 --- a/sql-bench/as3ap.sh +++ b/sql-bench/as3ap.sh @@ -1,5 +1,6 @@ #!/usr/bin/perl -# Copyright (C) 2001, 2003 MySQL AB +# Copyright (c) 2001, 2003, 2006 MySQL AB, 2009 Sun Microsystems, Inc. +# Use is subject to license terms. # # This library is free software; you can redistribute it and/or # modify it under the terms of the GNU Library General Public @@ -13,8 +14,8 @@ # # You should have received a copy of the GNU Library General Public # License along with this library; if not, write to the Free -# Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, -# MA 02111-1307, USA +# Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, +# MA 02110-1301, USA # # AS3AP single-user benchmark. # diff --git a/sql-bench/bench-count-distinct.sh b/sql-bench/bench-count-distinct.sh index 5cc9fb555af..923af98648a 100644 --- a/sql-bench/bench-count-distinct.sh +++ b/sql-bench/bench-count-distinct.sh @@ -1,5 +1,6 @@ #!/usr/bin/perl -# Copyright (C) 2001, 2003 MySQL AB +# Copyright (c) 2001, 2003, 2006 MySQL AB, 2009 Sun Microsystems, Inc. +# Use is subject to license terms. # # This library is free software; you can redistribute it and/or # modify it under the terms of the GNU Library General Public @@ -13,8 +14,8 @@ # # You should have received a copy of the GNU Library General Public # License along with this library; if not, write to the Free -# Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, -# MA 02111-1307, USA +# Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, +# MA 02110-1301, USA # # Test of selecting on keys that consist of many parts # diff --git a/sql-bench/bench-init.pl.sh b/sql-bench/bench-init.pl.sh index f1d4bd9edec..a46bb2d7a49 100644 --- a/sql-bench/bench-init.pl.sh +++ b/sql-bench/bench-init.pl.sh @@ -1,5 +1,6 @@ #!/usr/bin/perl -# Copyright (C) 2000-2003, 2005 MySQL AB +# Copyright (c) 2000-2003, 2005-2007 MySQL AB, 2009 Sun Microsystems, Inc. +# Use is subject to license terms. # # This library is free software; you can redistribute it and/or # modify it under the terms of the GNU Library General Public @@ -13,8 +14,8 @@ # # You should have received a copy of the GNU Library General Public # License along with this library; if not, write to the Free -# Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, -# MA 02111-1307, USA +# Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, +# MA 02110-1301, USA # ########################################################## # this is the base file every test is using .... diff --git a/sql-bench/compare-results.sh b/sql-bench/compare-results.sh index fe3563bd0b9..91d29685ee3 100644 --- a/sql-bench/compare-results.sh +++ b/sql-bench/compare-results.sh @@ -1,5 +1,6 @@ #!/usr/bin/perl -# Copyright (C) 2000-2001, 2003 MySQL AB +# Copyright (c) 2000, 2001, 2006 MySQL AB, 2009 Sun Microsystems, Inc. +# Use is subject to license terms. # # This library is free software; you can redistribute it and/or # modify it under the terms of the GNU Library General Public @@ -13,8 +14,8 @@ # # You should have received a copy of the GNU Library General Public # License along with this library; if not, write to the Free -# Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, -# MA 02111-1307, USA +# Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, +# MA 02110-1301, USA # # a little program to generate a table of results # just read all the RUN-*.log files and format them nicely diff --git a/sql-bench/copy-db.sh b/sql-bench/copy-db.sh index e0c290d2453..082db2203aa 100644 --- a/sql-bench/copy-db.sh +++ b/sql-bench/copy-db.sh @@ -1,5 +1,6 @@ #!/usr/bin/perl -# Copyright (C) 2000, 2003 MySQL AB +# Copyright (c) 2000, 2003, 2006 MySQL AB, 2009 Sun Microsystems, Inc. +# Use is subject to license terms. # # This library is free software; you can redistribute it and/or # modify it under the terms of the GNU Library General Public @@ -13,8 +14,8 @@ # # You should have received a copy of the GNU Library General Public # License along with this library; if not, write to the Free -# Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, -# MA 02111-1307, USA +# Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, +# MA 02110-1301, USA # # start initialition # diff --git a/sql-bench/crash-me.sh b/sql-bench/crash-me.sh index cc8659513c2..4391a2afb40 100644 --- a/sql-bench/crash-me.sh +++ b/sql-bench/crash-me.sh @@ -1,6 +1,7 @@ #!/usr/bin/perl # -*- perl -*- -# Copyright (C) 2000-2006 MySQL AB +# Copyright (c) 2000-2006 MySQL AB, 2009 Sun Microsystems, Inc. +# Use is subject to license terms. # # This library is free software; you can redistribute it and/or # modify it under the terms of the GNU Library General Public @@ -14,8 +15,8 @@ # # You should have received a copy of the GNU Library General Public # License along with this library; if not, write to the Free -# Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, -# MA 02111-1307, USA +# Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, +# MA 02110-1301, USA # Written by Monty for the TCX/Monty Program/Detron benchmark suite. # Empress and PostgreSQL patches by Luuk de Boer @@ -39,7 +40,7 @@ # as such, and clarify ones such as "mediumint" with comments such as # "3-byte int" or "same as xxx". -$version="1.61"; +$version="1.62"; use Cwd; use DBI; @@ -619,6 +620,8 @@ check_reserved_words($dbh); "numeric(9,2)","decimal(6,2)","dec(6,2)", "bit", "bit(2)","bit varying(2)","float","float(8)","real", "double precision", "date","time","timestamp", + "time(6)", "timestamp(6)", + "datetime", "datetime(6)", "interval year", "interval year to month", "interval month", "interval day", "interval day to hour", "interval day to minute", @@ -632,8 +635,7 @@ check_reserved_words($dbh); "national char varying(20)","nchar varying(20)", "national character varying(20)", "timestamp with time zone"); -@odbc_types=("binary(1)","varbinary(1)","tinyint","bigint", - "datetime"); +@odbc_types=("binary(1)","varbinary(1)","tinyint","bigint"); @extra_types=("blob","byte","long varbinary","image","text","text(10)", "mediumtext", "long varchar(1)", "varchar2(257)", @@ -663,7 +665,7 @@ check_reserved_words($dbh); foreach $types (@types) { print "\nSupported $types->[0] types\n"; - $tmp=@$types->[1]; + $tmp= $types->[1]; foreach $use_type (@$tmp) { $type=$use_type; @@ -746,10 +748,14 @@ if (($limits{'type_extra_float(2_arg)'} eq "yes" || $result="exact"; } $prompt="Storage of float values"; - print "$prompt: $result\n"; save_config_data("storage_of_float", $result, $prompt); } +if (defined($limits{'storage_of_float'})) +{ + print "Storage of float values: $limits{'storage_of_float'}\n"; +} + try_and_report("Type for row id", "rowid", ["rowid", "create table crash_q (a rowid)", @@ -1061,7 +1067,7 @@ try_and_report("Automatic row id", "automatic_rowid", foreach $types (@types) { print "\nSupported $types->[0] functions\n"; - $tmp=@$types->[1]; + $tmp= $types->[1]; foreach $type (@$tmp) { if (defined($limits{"func_$types->[0]_$type->[1]"})) @@ -1136,7 +1142,7 @@ if ($limits{'functions'} eq 'yes') foreach $types (@group_types) { print "\nSupported $types->[0] group functions\n"; - $tmp=@$types->[1]; + $tmp= $types->[1]; foreach $type (@$tmp) { check_and_report("Group function $type->[0]", @@ -3132,8 +3138,11 @@ $0 takes the following options: Wait this long before restarting server. --verbose ---noverbose Log into the result file queries performed for determination parameter value + This causes rows starting with ' ###' to be logged into the .cnf file + +--noverbose + Don't log '###' quries to the .cnf file. EOF exit(0); @@ -4349,7 +4358,7 @@ sub save_config_data my $last_line_was_empty=0; foreach $line (split /\n/, $log{$key}) { - print CONFIG_FILE " ###$line\n" + print CONFIG_FILE "$log_prefix$line\n" unless ( ($last_line_was_empty eq 1) && ($line =~ /^\s+$/) ); $last_line_was_empty= ($line =~ /^\s+$/)?1:0; @@ -4369,7 +4378,7 @@ sub add_log { my $key = shift; my $line = shift; - $log{$key} .= $line . "\n" if ($opt_verbose);; + $log{$key} .= $line . "\n" if ($opt_verbose); } sub save_all_config_data @@ -4391,14 +4400,17 @@ sub save_all_config_data $tmp="$key=$limits{$key}"; print CONFIG_FILE $tmp . ("\t" x (int((32-min(length($tmp),32)+7)/8)+1)) . "# $prompts{$key}\n"; - my $line; - my $last_line_was_empty=0; - foreach $line (split /\n/, $log{$key}) - { - print CONFIG_FILE " ###$line\n" unless - ( ($last_line_was_empty eq 1) && ($line =~ /^\s*$/)); + if ($opt_verbose) + { + my $line; + my $last_line_was_empty=0; + foreach $line (split /\n/, $log{$key}) + { + print CONFIG_FILE "$log_prefix$line\n" unless + ( ($last_line_was_empty eq 1) && ($line =~ /^\s*$/)); $last_line_was_empty= ($line =~ /^\s*$/)?1:0; - }; + } + } } close CONFIG_FILE; } diff --git a/sql-bench/limits/mysql.cfg b/sql-bench/limits/mysql.cfg index 76565cb16ff..1194898481d 100644 --- a/sql-bench/limits/mysql.cfg +++ b/sql-bench/limits/mysql.cfg @@ -1,4 +1,4 @@ -#This file is automaticly generated by crash-me 1.61 +#This file is automaticly generated by crash-me 1.62 NEG=yes # update of column= -column Need_cast_for_null=no # Need to cast NULL for arithmetic @@ -31,7 +31,7 @@ comment_--=yes # -- as comment (ANSI) comment_/**/=yes # /* */ as comment comment_//=no # // as comment compute=no # Compute -connections=101 # Simultaneous connections (installation default) +connections=152 # Simultaneous connections (installation default) constraint_check=syntax only # Column constraints constraint_check_named=syntax only # Named constraints constraint_check_table=syntax only # Table constraints @@ -387,17 +387,17 @@ max_char_size=255 # max char() size max_column_name=64 # column name length max_columns=2599 # Columns in table max_conditions=85660 # OR and AND in WHERE -max_expressions=580 # simple expressions +max_expressions=571 # simple expressions max_index=+64 # max index max_index_length=1000 # index length max_index_name=64 # index name length max_index_part_length=255 # max index part length -max_index_parts=16 # index parts +max_index_parts=32 # index parts max_index_varchar_part_length=1000 # index varchar part length max_row_length=65534 # max table row length (without blobs) max_row_length_with_null=65502 # table row length with nulls (without blobs) max_select_alias_name=+512 # select alias name length -max_stack_expression=580 # stacked expressions +max_stack_expression=571 # stacked expressions max_table_alias_name=+512 # table alias name length max_table_name=64 # table name length max_text_size=1048543 # max text or blob size @@ -422,7 +422,7 @@ null_in_unique=yes # null in unique index null_num_expr=yes # Is 1+NULL = NULL nulls_in_unique=yes # null combination in unique index odbc_left_outer_join=yes # left outer join odbc style -operating_system=Linux 2.6.8-my i686 # crash-me tested on +operating_system=Linux 2.6.37.6-0.7-desktop x86_64 # crash-me tested on order_by=yes # Order by order_by_alias=yes # Order by alias order_by_function=yes # Order by function @@ -433,7 +433,7 @@ position_of_null_desc=last # Where is null values in sorted recordset (DESC) primary_key_in_create=yes # primary key in create table psm_functions=no # PSM functions (ANSI SQL) psm_modules=no # PSM modules (ANSI SQL) -psm_procedures=no # PSM procedures (ANSI SQL) +psm_procedures=yes # PSM procedures (ANSI SQL) psm_trigger=no # Triggers (ANSI SQL) query_size=1048574 # query size quote_ident_with_"=error # " as identifier quote (ANSI SQL) @@ -485,7 +485,7 @@ reserved_word_ansi-92/99_column=yes # Keyword COLUMN reserved_word_ansi-92/99_commit=no # Keyword COMMIT reserved_word_ansi-92/99_completion=no # Keyword COMPLETION reserved_word_ansi-92/99_connect=no # Keyword CONNECT -reserved_word_ansi-92/99_connection=yes # Keyword CONNECTION +reserved_word_ansi-92/99_connection=no # Keyword CONNECTION reserved_word_ansi-92/99_constraint=yes # Keyword CONSTRAINT reserved_word_ansi-92/99_constraints=no # Keyword CONSTRAINTS reserved_word_ansi-92/99_continue=yes # Keyword CONTINUE @@ -546,7 +546,7 @@ reserved_word_ansi-92/99_general=no # Keyword GENERAL reserved_word_ansi-92/99_get=no # Keyword GET reserved_word_ansi-92/99_global=no # Keyword GLOBAL reserved_word_ansi-92/99_go=no # Keyword GO -reserved_word_ansi-92/99_goto=yes # Keyword GOTO +reserved_word_ansi-92/99_goto=no # Keyword GOTO reserved_word_ansi-92/99_grant=yes # Keyword GRANT reserved_word_ansi-92/99_group=yes # Keyword GROUP reserved_word_ansi-92/99_having=yes # Keyword HAVING @@ -933,7 +933,7 @@ reserved_word_extra_setuser=no # Keyword SETUSER reserved_word_extra_share=no # Keyword SHARE reserved_word_extra_show=yes # Keyword SHOW reserved_word_extra_shutdown=no # Keyword SHUTDOWN -reserved_word_extra_soname=yes # Keyword SONAME +reserved_word_extra_soname=no # Keyword SONAME reserved_word_extra_spatial=yes # Keyword SPATIAL reserved_word_extra_sql_big_result=yes # Keyword SQL_BIG_RESULT reserved_word_extra_sql_calc_found_rows=yes # Keyword SQL_CALC_FOUND_ROWS @@ -983,7 +983,7 @@ select_limit3=yes # SELECT with LIMIT # OFFSET # select_string_size=1048565 # constant string size in SELECT select_table_update=yes # Update with sub select select_without_from=yes # SELECT without FROM -server_version=MySQL 5.0.7 beta valgrind max debug/ # server version +server_version=MySQL 5.3.1 MariaDB beta valgrind max debug # server version simple_joins=yes # ANSI SQL simple joins sorted_group_by=yes # Group by always sorted storage_of_float=round # Storage of float values @@ -1063,7 +1063,6 @@ type_extra_varchar2(1_arg)=no # Type varchar2(1 arg) type_extra_year=yes # Type year type_odbc_bigint=yes # Type bigint type_odbc_binary(1_arg)=yes # Type binary(1 arg) -type_odbc_datetime=yes # Type datetime type_odbc_tinyint=yes # Type tinyint type_odbc_varbinary(1_arg)=yes # Type varbinary(1 arg) type_sql_bit=yes # Type bit @@ -1075,6 +1074,8 @@ type_sql_char_varying(1_arg)=yes # Type char varying(1 arg) type_sql_character(1_arg)=yes # Type character(1 arg) type_sql_character_varying(1_arg)=yes # Type character varying(1 arg) type_sql_date=yes # Type date +type_sql_datetime=yes # Type datetime +type_sql_datetime(1_arg)=yes # Type datetime(1 arg) type_sql_dec(2_arg)=yes # Type dec(2 arg) type_sql_decimal(2_arg)=yes # Type decimal(2 arg) type_sql_double_precision=yes # Type double precision @@ -1104,7 +1105,9 @@ type_sql_numeric(2_arg)=yes # Type numeric(2 arg) type_sql_real=yes # Type real type_sql_smallint=yes # Type smallint type_sql_time=yes # Type time +type_sql_time(1_arg)=yes # Type time(1 arg) type_sql_timestamp=yes # Type timestamp +type_sql_timestamp(1_arg)=yes # Type timestamp(1 arg) type_sql_timestamp_with_time_zone=no # Type timestamp with time zone type_sql_varchar(1_arg)=yes # Type varchar(1 arg) union=yes # union diff --git a/sql-bench/run-all-tests.sh b/sql-bench/run-all-tests.sh index a4b03428d94..4e4b372b759 100644 --- a/sql-bench/run-all-tests.sh +++ b/sql-bench/run-all-tests.sh @@ -1,5 +1,6 @@ #!/usr/bin/perl -# Copyright (C) 2000-2001, 2003 MySQL AB +# Copyright (c) 2000, 2001, 2003, 2006, 2007 MySQL AB, 2009 Sun Microsystems, Inc. +# Use is subject to license terms. # # This library is free software; you can redistribute it and/or # modify it under the terms of the GNU Library General Public @@ -13,8 +14,8 @@ # # You should have received a copy of the GNU Library General Public # License along with this library; if not, write to the Free -# Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, -# MA 02111-1307, USA +# Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, +# MA 02110-1301, USA # # This program runs all test that starts with 'test-' and sums # the results that the program prints. diff --git a/sql-bench/server-cfg.sh b/sql-bench/server-cfg.sh index de92fd80a40..8b7cdfdb103 100644 --- a/sql-bench/server-cfg.sh +++ b/sql-bench/server-cfg.sh @@ -1,6 +1,7 @@ #!/usr/bin/perl # -*- perl -*- -# Copyright (C) 2000-2006 MySQL AB +# Copyright (c) 2000-2006 MySQL AB, 2009 Sun Microsystems, Inc. +# Use is subject to license terms. # # This library is free software; you can redistribute it and/or # modify it under the terms of the GNU Library General Public @@ -14,8 +15,8 @@ # # You should have received a copy of the GNU Library General Public # License along with this library; if not, write to the Free -# Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, -# MA 02111-1307, USA +# Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, +# MA 02110-1301, USA # # The configuration file for the DBI/DBD tests on different databases .... # You will need the DBD module for the database you are running. diff --git a/sql-bench/test-ATIS.sh b/sql-bench/test-ATIS.sh index ee697d4f319..ca1132435ff 100644 --- a/sql-bench/test-ATIS.sh +++ b/sql-bench/test-ATIS.sh @@ -1,5 +1,6 @@ #!/usr/bin/perl -# Copyright (C) 2000-2001, 2003 MySQL AB +# Copyright (c) 2000, 2001, 2003, 2006 MySQL AB, 2009 Sun Microsystems, Inc. +# Use is subject to license terms. # # This library is free software; you can redistribute it and/or # modify it under the terms of the GNU Library General Public @@ -13,8 +14,8 @@ # # You should have received a copy of the GNU Library General Public # License along with this library; if not, write to the Free -# Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, -# MA 02111-1307, USA +# Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, +# MA 02110-1301, USA # # Test of creating the ATIS database and doing many different selects on it # diff --git a/sql-bench/test-alter-table.sh b/sql-bench/test-alter-table.sh index 03d40a01276..6dc5ce35841 100644 --- a/sql-bench/test-alter-table.sh +++ b/sql-bench/test-alter-table.sh @@ -1,5 +1,6 @@ #!/usr/bin/perl -# Copyright (C) 2000-2001, 2003 MySQL AB +# Copyright (c) 2000, 2001, 2003, 2006 MySQL AB, 2009 Sun Microsystems, Inc. +# Use is subject to license terms. # # This library is free software; you can redistribute it and/or # modify it under the terms of the GNU Library General Public @@ -13,8 +14,8 @@ # # You should have received a copy of the GNU Library General Public # License along with this library; if not, write to the Free -# Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, -# MA 02111-1307, USA +# Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, +# MA 02110-1301, USA # # Test of alter table # diff --git a/sql-bench/test-big-tables.sh b/sql-bench/test-big-tables.sh index de2b0830bd3..68b4afaa429 100644 --- a/sql-bench/test-big-tables.sh +++ b/sql-bench/test-big-tables.sh @@ -1,5 +1,6 @@ #!/usr/bin/perl -# Copyright (C) 2000-2001, 2003 MySQL AB +# Copyright (c) 2000, 2001, 2003, 2006 MySQL AB, 2009 Sun Microsystems, Inc. +# Use is subject to license terms. # # This library is free software; you can redistribute it and/or # modify it under the terms of the GNU Library General Public @@ -13,8 +14,8 @@ # # You should have received a copy of the GNU Library General Public # License along with this library; if not, write to the Free -# Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, -# MA 02111-1307, USA +# Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, +# MA 02110-1301, USA # # Test of extreme tables. # diff --git a/sql-bench/test-connect.sh b/sql-bench/test-connect.sh index d2b8530ed0d..50024e7e055 100644 --- a/sql-bench/test-connect.sh +++ b/sql-bench/test-connect.sh @@ -1,5 +1,6 @@ #!/usr/bin/perl -# Copyright (C) 2000-2001, 2003 MySQL AB +# Copyright (c) 2000, 2001, 2003, 2006 MySQL AB, 2009 Sun Microsystems, Inc. +# Use is subject to license terms. # # This library is free software; you can redistribute it and/or # modify it under the terms of the GNU Library General Public @@ -13,8 +14,8 @@ # # You should have received a copy of the GNU Library General Public # License along with this library; if not, write to the Free -# Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, -# MA 02111-1307, USA +# Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, +# MA 02110-1301, USA # # This test is for testing the speed of connections and sending # data to the client. diff --git a/sql-bench/test-create.sh b/sql-bench/test-create.sh index e2a51f96fff..235cacd86ec 100644 --- a/sql-bench/test-create.sh +++ b/sql-bench/test-create.sh @@ -1,5 +1,6 @@ #!/usr/bin/perl -# Copyright (C) 2000-2003 MySQL AB +# Copyright (c) 2000-2003, 2006 MySQL AB, 2009 Sun Microsystems, Inc. +# Use is subject to license terms. # # This library is free software; you can redistribute it and/or # modify it under the terms of the GNU Library General Public @@ -13,8 +14,8 @@ # # You should have received a copy of the GNU Library General Public # License along with this library; if not, write to the Free -# Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, -# MA 02111-1307, USA +# Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, +# MA 02110-1301, USA # # This test is for testing how long it takes to create tables, # make a count(*) from them and finally drop the tables. These diff --git a/sql-bench/test-insert.sh b/sql-bench/test-insert.sh index 387cb48e494..e264c7d529f 100644 --- a/sql-bench/test-insert.sh +++ b/sql-bench/test-insert.sh @@ -1,5 +1,6 @@ #!/usr/bin/perl -# Copyright (C) 2000-2003 MySQL AB +# Copyright (c) 2000-2003, 2006, 2007 MySQL AB, 2009 Sun Microsystems, Inc. +# Use is subject to license terms. # # This library is free software; you can redistribute it and/or # modify it under the terms of the GNU Library General Public @@ -13,8 +14,8 @@ # # You should have received a copy of the GNU Library General Public # License along with this library; if not, write to the Free -# Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, -# MA 02111-1307, USA +# Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, +# MA 02110-1301, USA # # Test of creating a simple table and inserting $record_count records in it, # $opt_loop_count rows in order, $opt_loop_count rows in reverse order and diff --git a/sql-bench/test-select.sh b/sql-bench/test-select.sh index a3162b29dc3..1752c05079b 100644 --- a/sql-bench/test-select.sh +++ b/sql-bench/test-select.sh @@ -1,5 +1,6 @@ #!/usr/bin/perl -# Copyright (C) 2000-2001, 2003 MySQL AB +# Copyright (c) 2000, 2001, 2003, 2006 MySQL AB, 2009 Sun Microsystems, Inc. +# Use is subject to license terms. # # This library is free software; you can redistribute it and/or # modify it under the terms of the GNU Library General Public @@ -13,8 +14,8 @@ # # You should have received a copy of the GNU Library General Public # License along with this library; if not, write to the Free -# Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, -# MA 02111-1307, USA +# Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, +# MA 02110-1301, USA # # Test of selecting on keys that consist of many parts # diff --git a/sql-bench/test-transactions.sh b/sql-bench/test-transactions.sh index f6de5641cbd..b0aee8c6d38 100644 --- a/sql-bench/test-transactions.sh +++ b/sql-bench/test-transactions.sh @@ -1,5 +1,6 @@ #!/usr/bin/perl -# Copyright (C) 2001, 2003 MySQL AB +# Copyright (c) 2001, 2003, 2006 MySQL AB, 2009 Sun Microsystems, Inc. +# Use is subject to license terms. # # This library is free software; you can redistribute it and/or # modify it under the terms of the GNU Library General Public @@ -13,8 +14,8 @@ # # You should have received a copy of the GNU Library General Public # License along with this library; if not, write to the Free -# Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, -# MA 02111-1307, USA +# Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, +# MA 02110-1301, USA # # Test of transactions performance. # diff --git a/sql-bench/test-wisconsin.sh b/sql-bench/test-wisconsin.sh index 0dbd88dd62d..4fb3bc65f35 100644 --- a/sql-bench/test-wisconsin.sh +++ b/sql-bench/test-wisconsin.sh @@ -1,5 +1,6 @@ #!/usr/bin/perl -# Copyright (C) 2000-2001, 2003 MySQL AB +# Copyright (c) 2000, 2001, 2003, 2006 MySQL AB, 2009 Sun Microsystems, Inc. +# Use is subject to license terms. # # This library is free software; you can redistribute it and/or # modify it under the terms of the GNU Library General Public @@ -13,8 +14,8 @@ # # You should have received a copy of the GNU Library General Public # License along with this library; if not, write to the Free -# Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, -# MA 02111-1307, USA +# Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, +# MA 02110-1301, USA # use Cwd; diff --git a/sql-common/client.c b/sql-common/client.c index 6db20153eaa..638dab9afc4 100644 --- a/sql-common/client.c +++ b/sql-common/client.c @@ -1,4 +1,4 @@ -/* Copyright (c) 2000, 2011, Oracle and/or its affiliates. All rights reserved. +/* Copyright (c) 2003, 2011, Oracle and/or its affiliates. All rights reserved. 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-common/client_plugin.c b/sql-common/client_plugin.c index add5c60c056..f31ddb22a6a 100644 --- a/sql-common/client_plugin.c +++ b/sql-common/client_plugin.c @@ -1,5 +1,5 @@ /* Copyright (C) 2010 Sergei Golubchik and Monty Program Ab - Copyright (C) 2010 Sun Microsystems, Inc. + Copyright (c) 2010, 2011, Oracle and/or its affiliates. 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 @@ -12,7 +12,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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ /** @file diff --git a/sql-common/my_time.c b/sql-common/my_time.c index 8e05e33e940..83271aa91a0 100644 --- a/sql-common/my_time.c +++ b/sql-common/my_time.c @@ -1,4 +1,4 @@ -/* Copyright (C) 2004-2006 MySQL AB +/* Copyright (c) 2004, 2011, Oracle and/or its affiliates. All rights reserved. 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 @@ -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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ #include <my_time.h> #include <m_string.h> @@ -343,7 +343,7 @@ str_to_datetime(const char *str, uint length, MYSQL_TIME *l_time, { if (str[0] == 'p' || str[0] == 'P') add_hours= 12; - else if (str[0] != 'a' || str[0] != 'A') + else if (str[0] != 'a' && str[0] != 'A') continue; /* Not AM/PM */ str+= 2; /* Skip AM/PM */ /* Skip space after AM/PM */ diff --git a/sql-common/my_user.c b/sql-common/my_user.c index 0b72e002977..8d717ea7131 100644 --- a/sql-common/my_user.c +++ b/sql-common/my_user.c @@ -1,4 +1,5 @@ -/* Copyright (C) 2005 MySQL AB +/* Copyright (c) 2006-2008 MySQL AB, 2009 Sun Microsystems, Inc. + Use is subject to license terms. 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 @@ -11,7 +12,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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ #include <my_user.h> #include <m_string.h> diff --git a/sql/CMakeLists.txt b/sql/CMakeLists.txt index 93023ae6158..6d7b73ffcee 100644 --- a/sql/CMakeLists.txt +++ b/sql/CMakeLists.txt @@ -1,4 +1,4 @@ -# Copyright (c) 2006, 2010, Oracle and/or its affiliates. All rights reserved. +# Copyright (c) 2006, 2011, Oracle and/or its affiliates. All rights reserved. # # 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 @@ -107,6 +107,14 @@ ENDIF() MYSQL_ADD_EXECUTABLE(mysqld ${MYSQLD_SOURCE} DESTINATION ${INSTALL_SBINDIR} COMPONENT Server) +IF(APPLE) + # Add CoreServices framework since some dloadable plugins may need it + FIND_LIBRARY(CORESERVICES NAMES CoreServices) + IF(CORESERVICES) + TARGET_LINK_LIBRARIES(mysqld ${CORESERVICES}) + ENDIF() +ENDIF() + IF(NOT WITHOUT_DYNAMIC_PLUGINS) SET_TARGET_PROPERTIES(mysqld PROPERTIES ENABLE_EXPORTS TRUE) GET_TARGET_PROPERTY(mysqld_link_flags mysqld LINK_FLAGS) diff --git a/sql/authors.h b/sql/authors.h index 40fcd4c47f8..018c8fabc31 100644 --- a/sql/authors.h +++ b/sql/authors.h @@ -1,7 +1,7 @@ #ifndef AUTHORS_INCLUDED #define AUTHORS_INCLUDED -/* Copyright (C) 2005-2006 MySQL AB +/* Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved. 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/client_settings.h b/sql/client_settings.h index 0a61c12b64a..54cb72f9412 100644 --- a/sql/client_settings.h +++ b/sql/client_settings.h @@ -1,4 +1,4 @@ -/* Copyright (C) 2003 MySQL AB +/* Copyright (c) 2003, 2011, Oracle and/or its affiliates. All rights reserved. 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 @@ -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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ #ifndef CLIENT_SETTINGS_INCLUDED @@ -23,9 +23,18 @@ #include <thr_alarm.h> #include <sql_common.h> -#define CLIENT_CAPABILITIES (CLIENT_LONG_PASSWORD | CLIENT_LONG_FLAG | \ - CLIENT_SECURE_CONNECTION | CLIENT_TRANSACTIONS | \ - CLIENT_PROTOCOL_41 | CLIENT_SECURE_CONNECTION) +/* + Note: CLIENT_CAPABILITIES is also defined in libmysql/client_settings.h. + When adding capabilities here, consider if they should be also added to + the libmysql version. +*/ +#define CLIENT_CAPABILITIES (CLIENT_LONG_PASSWORD | \ + CLIENT_LONG_FLAG | \ + CLIENT_SECURE_CONNECTION | \ + CLIENT_TRANSACTIONS | \ + CLIENT_PROTOCOL_41 | \ + CLIENT_SECURE_CONNECTION | \ + CLIENT_PLUGIN_AUTH) #define read_user_name(A) {} #undef _CUSTOMCONFIG_ diff --git a/sql/contributors.h b/sql/contributors.h index 6cf8bb88e3b..b1ba2c20997 100644 --- a/sql/contributors.h +++ b/sql/contributors.h @@ -1,7 +1,8 @@ #ifndef CONTRIBUTORS_INCLUDED #define CONTRIBUTORS_INCLUDED -/* Copyright (C) 2006 MySQL AB +/* Copyright (c) 2006 MySQL AB, 2009 Sun Microsystems, Inc. + Use is subject to license terms. 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/debug_sync.cc b/sql/debug_sync.cc index 7e5db3b499d..2f356122687 100644 --- a/sql/debug_sync.cc +++ b/sql/debug_sync.cc @@ -1,4 +1,4 @@ -/* Copyright (C) 2008 MySQL AB, 2008 - 2009 Sun Microsystems, Inc. +/* Copyright (c) 2009, 2011, Oracle and/or its affiliates. All rights reserved. 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 @@ -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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ /** == Debug Sync Facility == @@ -1123,7 +1123,7 @@ static bool debug_sync_set_action(THD *thd, st_debug_sync_action *action) point decremented it to 0. In this case the following happened: - an error message was reported with my_error() and - - the statement was killed with thd->killed= THD::KILL_QUERY. + - the statement was killed with thd->killed= KILL_QUERY. If a statement reports an error, it must not call send_ok(). The calling functions will not call send_ok(), if we return TRUE @@ -1738,7 +1738,7 @@ static void debug_sync_execute(THD *thd, st_debug_sync_action *action) if (action->wait_for.length()) { mysql_mutex_t *old_mutex; - mysql_cond_t *old_cond; + mysql_cond_t *UNINIT_VAR(old_cond); int error= 0; struct timespec abstime; @@ -1838,7 +1838,7 @@ static void debug_sync_execute(THD *thd, st_debug_sync_action *action) { if (!--action->hit_limit) { - thd->killed= THD::KILL_QUERY; + thd->killed= KILL_QUERY; my_error(ER_DEBUG_SYNC_HIT_LIMIT, MYF(0)); } DBUG_PRINT("debug_sync_exec", ("hit_limit: %lu at: '%s'", diff --git a/sql/debug_sync.h b/sql/debug_sync.h index ba3739e8ad5..930e6c35be9 100644 --- a/sql/debug_sync.h +++ b/sql/debug_sync.h @@ -1,7 +1,7 @@ #ifndef DEBUG_SYNC_INCLUDED #define DEBUG_SYNC_INCLUDED -/* Copyright (C) 2008 Sun Microsystems, Inc. +/* Copyright (c) 2009, 2011, Oracle and/or its affiliates. All rights reserved. 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 @@ -14,7 +14,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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ /** @file diff --git a/sql/derror.h b/sql/derror.h index cb8ae91acbc..b2f6331e048 100644 --- a/sql/derror.h +++ b/sql/derror.h @@ -1,4 +1,4 @@ -/* Copyright 2006-2008 MySQL AB, 2008-2009 Sun Microsystems, Inc. +/* Copyright (c) 2006, 2010, Oracle and/or its affiliates. All rights reserved. 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/des_key_file.cc b/sql/des_key_file.cc index d2bf2ebdaa7..b6b6f4536bc 100644 --- a/sql/des_key_file.cc +++ b/sql/des_key_file.cc @@ -1,4 +1,4 @@ -/* Copyright (C) 2001-2003, 2005 MySQL AB, 2008-2009 Sun Microsystems, Inc +/* Copyright (c) 2001, 2010, Oracle and/or its affiliates. All rights reserved. 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 @@ -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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ #include "my_global.h" // HAVE_* #include "sql_priv.h" diff --git a/sql/des_key_file.h b/sql/des_key_file.h index d817ff93949..024a1715d47 100644 --- a/sql/des_key_file.h +++ b/sql/des_key_file.h @@ -1,4 +1,4 @@ -/* Copyright 2006-2008 MySQL AB, 2008-2009 Sun Microsystems, Inc. +/* Copyright (c) 2006, 2010, Oracle and/or its affiliates. All rights reserved. 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/discover.cc b/sql/discover.cc index b129747503e..b9dba92a780 100644 --- a/sql/discover.cc +++ b/sql/discover.cc @@ -1,4 +1,4 @@ -/* Copyright (C) 2004 MySQL AB, 2008-2009 Sun Microsystems, Inc +/* Copyright (c) 2004, 2010, Oracle and/or its affiliates. All rights reserved. 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 @@ -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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ /** diff --git a/sql/discover.h b/sql/discover.h index 54fb78ddd2f..a663e44128d 100644 --- a/sql/discover.h +++ b/sql/discover.h @@ -1,4 +1,4 @@ -/* Copyright 2006-2008 MySQL AB, 2008-2009 Sun Microsystems, Inc. +/* Copyright (c) 2006, 2010, Oracle and/or its affiliates. All rights reserved. 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/event_data_objects.cc b/sql/event_data_objects.cc index fc9ab35ac8a..eabe215bc3a 100644 --- a/sql/event_data_objects.cc +++ b/sql/event_data_objects.cc @@ -1,4 +1,4 @@ -/* Copyright (C) 2004-2006 MySQL AB, 2008-2009 Sun Microsystems, Inc +/* Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved. 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 @@ -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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ #define MYSQL_LEX 1 #include "my_global.h" /* NO_EMBEDDED_ACCESS_CHECKS */ diff --git a/sql/event_data_objects.h b/sql/event_data_objects.h index 2c693e5ec43..2483c564dff 100644 --- a/sql/event_data_objects.h +++ b/sql/event_data_objects.h @@ -1,6 +1,6 @@ #ifndef _EVENT_DATA_OBJECTS_H_ #define _EVENT_DATA_OBJECTS_H_ -/* Copyright (C) 2004-2006 MySQL AB +/* Copyright (c) 2004, 2010, Oracle and/or its affiliates. All rights reserved. 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 @@ -13,7 +13,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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ /** @addtogroup Event_Scheduler diff --git a/sql/event_db_repository.cc b/sql/event_db_repository.cc index 807b5cf603e..8099d87b580 100644 --- a/sql/event_db_repository.cc +++ b/sql/event_db_repository.cc @@ -1,4 +1,5 @@ -/* Copyright 2004-2008 MySQL AB, 2008 Sun Microsystems, Inc. +/* + Copyright (c) 2006, 2011, Oracle and/or its affiliates. All rights reserved. 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 @@ -11,7 +12,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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ #include "sql_priv.h" #include "unireg.h" diff --git a/sql/event_db_repository.h b/sql/event_db_repository.h index 162ec5d1243..bb708b2b520 100644 --- a/sql/event_db_repository.h +++ b/sql/event_db_repository.h @@ -1,6 +1,8 @@ #ifndef _EVENT_DB_REPOSITORY_H_ #define _EVENT_DB_REPOSITORY_H_ -/* Copyright (C) 2004-2006 MySQL AB + +/* + Copyright (c) 2006, 2011, Oracle and/or its affiliates. All rights reserved. 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 @@ -13,7 +15,8 @@ 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +*/ /** @addtogroup Event_Scheduler diff --git a/sql/event_parse_data.cc b/sql/event_parse_data.cc index 8bffe47f30f..b53e366e27c 100644 --- a/sql/event_parse_data.cc +++ b/sql/event_parse_data.cc @@ -1,4 +1,5 @@ -/* Copyright 2000-2008 MySQL AB, 2008 Sun Microsystems, Inc. +/* + Copyright (c) 2008, 2011, Oracle and/or its affiliates. All rights reserved. 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 @@ -11,7 +12,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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ #include "sql_priv.h" #include "unireg.h" diff --git a/sql/event_parse_data.h b/sql/event_parse_data.h index 85c620760cb..1ea22edf488 100644 --- a/sql/event_parse_data.h +++ b/sql/event_parse_data.h @@ -1,4 +1,5 @@ -/* Copyright 2000-2008 MySQL AB, 2008 Sun Microsystems, Inc. +/* + Copyright (c) 2008, 2011, Oracle and/or its affiliates. All rights reserved. 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 @@ -11,7 +12,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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ #ifndef _EVENT_PARSE_DATA_H_ #define _EVENT_PARSE_DATA_H_ diff --git a/sql/event_queue.cc b/sql/event_queue.cc index c92c3a835ba..40fddff094c 100644 --- a/sql/event_queue.cc +++ b/sql/event_queue.cc @@ -1,4 +1,4 @@ -/* Copyright (C) 2004-2006 MySQL AB, 2008-2009 Sun Microsystems, Inc +/* Copyright (c) 2004, 2010, Oracle and/or its affiliates. All rights reserved. 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 @@ -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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ #include "sql_priv.h" #include "unireg.h" diff --git a/sql/event_queue.h b/sql/event_queue.h index 5e489ddaa37..affa306b259 100644 --- a/sql/event_queue.h +++ b/sql/event_queue.h @@ -1,6 +1,6 @@ #ifndef _EVENT_QUEUE_H_ #define _EVENT_QUEUE_H_ -/* Copyright (C) 2004-2006 MySQL AB, 2008-2009 Sun Microsystems, Inc +/* Copyright (c) 2004, 2010, Oracle and/or its affiliates. All rights reserved. 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 @@ -13,7 +13,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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ /** diff --git a/sql/event_scheduler.cc b/sql/event_scheduler.cc index ab6f0cdccaa..55a3f6b36c4 100644 --- a/sql/event_scheduler.cc +++ b/sql/event_scheduler.cc @@ -1,4 +1,4 @@ -/* Copyright (C) 2004, 2010 Oracle and/or its affiliates. All rights reserved. +/* Copyright (c) 2006, 2010, Oracle and/or its affiliates. All rights reserved. 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 @@ -659,7 +659,7 @@ Event_scheduler::stop() sql_print_information("Event Scheduler: Killing the scheduler thread, " "thread id %lu", scheduler_thd->thread_id); - scheduler_thd->awake(THD::KILL_CONNECTION); + scheduler_thd->awake(KILL_CONNECTION); mysql_mutex_unlock(&scheduler_thd->LOCK_thd_data); /* thd could be 0x0, when shutting down */ diff --git a/sql/event_scheduler.h b/sql/event_scheduler.h index ecd7031f546..aca4b74dd95 100644 --- a/sql/event_scheduler.h +++ b/sql/event_scheduler.h @@ -1,6 +1,6 @@ #ifndef _EVENT_SCHEDULER_H_ #define _EVENT_SCHEDULER_H_ -/* Copyright (C) 2004-2006 MySQL AB, 2008-2009 Sun Microsystems, Inc +/* Copyright (c) 2004, 2010, Oracle and/or its affiliates. All rights reserved. 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 @@ -13,7 +13,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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ /** @addtogroup Event_Scheduler diff --git a/sql/events.cc b/sql/events.cc index 631092f68e7..00299463dba 100644 --- a/sql/events.cc +++ b/sql/events.cc @@ -1,4 +1,5 @@ -/* Copyright (c) 2004, 2011, Oracle and/or its affiliates. All rights reserved. +/* + Copyright (c) 2005, 2011, Oracle and/or its affiliates. All rights reserved. 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/field.cc b/sql/field.cc index bdbf48751bb..42d71477372 100644 --- a/sql/field.cc +++ b/sql/field.cc @@ -1,5 +1,7 @@ -/* Copyright (c) 2000, 2011, Oracle and/or its affiliates. +/* + Copyright (c) 2000, 2011, Oracle and/or its affiliates. Copyright (c) 2009-2011 Monty Program Ab + 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 the Free Software Foundation; version 2 of the License. @@ -11,7 +13,8 @@ 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 02110-1301 USA */ + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +*/ /** @file diff --git a/sql/field.h b/sql/field.h index f685bac11ad..84d60012a85 100644 --- a/sql/field.h +++ b/sql/field.h @@ -1,6 +1,6 @@ #ifndef FIELD_INCLUDED #define FIELD_INCLUDED -/* Copyright (c) 2000, 2010 Oracle and/or its affiliates. +/* Copyright (c) 2000, 2011 Oracle and/or its affiliates. Copyright (c) 2009-2011 Monty Program Ab This program is free software; you can redistribute it and/or modify @@ -1943,7 +1943,13 @@ public: int store(longlong nr, bool unsigned_val); int store_decimal(const my_decimal *); uint size_of() const { return sizeof(*this); } - int reset(void) { return !maybe_null() || Field_blob::reset(); } + + /** + Non-nullable GEOMETRY types cannot have defaults, + but the underlying blob must still be reset. + */ + int reset(void) { return Field_blob::reset() || !maybe_null(); } + geometry_type get_geometry_type() { return geom_type; }; }; #endif /*HAVE_SPATIAL*/ diff --git a/sql/field_conv.cc b/sql/field_conv.cc index a0f6a159c05..8808d73f622 100644 --- a/sql/field_conv.cc +++ b/sql/field_conv.cc @@ -1,4 +1,4 @@ -/* Copyright (C) 2000-2003 MySQL AB +/* Copyright (c) 2000, 2011, Oracle and/or its affiliates. All rights reserved. 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 @@ -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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ /** @@ -178,7 +178,10 @@ set_field_to_null_with_conversions(Field *field, bool no_conversions) ((Field_timestamp*) field)->set_time(); return 0; // Ok to set time to NULL } + + // Note: we ignore any potential failure of reset() here. field->reset(); + if (field == field->table->next_number_field) { field->table->auto_increment_field_not_null= FALSE; diff --git a/sql/filesort.cc b/sql/filesort.cc index 13b5d0e2bd5..a9db198e9d3 100644 --- a/sql/filesort.cc +++ b/sql/filesort.cc @@ -145,8 +145,6 @@ ha_rows filesort(THD *thd, TABLE *table, SORT_FIELD *sortorder, uint s_length, error= 1; bzero((char*) ¶m,sizeof(param)); param.sort_length= sortlength(thd, sortorder, s_length, &multi_byte_charset); - /* filesort cannot handle zero-length records. */ - DBUG_ASSERT(param.sort_length); param.ref_length= table->file->ref_length; if (!(table->file->ha_table_flags() & HA_FAST_KEY_READ) && !table->fulltext_searched && !sort_positions) @@ -258,6 +256,10 @@ ha_rows filesort(THD *thd, TABLE *table, SORT_FIELD *sortorder, uint s_length, else { thd->query_plan_flags|= QPLAN_FILESORT_DISK; + + /* filesort cannot handle zero-length records during merge. */ + DBUG_ASSERT(param.sort_length != 0); + if (table_sort.buffpek && table_sort.buffpek_len < maxbuffer) { my_free(table_sort.buffpek); @@ -524,7 +526,7 @@ static ha_rows find_all_keys(SORTPARAM *param, SQL_SELECT *select, my_off_t record; TABLE *sort_form; THD *thd= current_thd; - volatile THD::killed_state *killed= &thd->killed; + volatile killed_state *killed= &thd->killed; handler *file; MY_BITMAP *save_read_set, *save_write_set, *save_vcol_set; DBUG_ENTER("find_all_keys"); @@ -564,12 +566,11 @@ static ha_rows find_all_keys(SORTPARAM *param, SQL_SELECT *select, /* Temporary set for register_used_fields and register_field_in_read_map */ sort_form->read_set= &sort_form->tmp_set; register_used_fields(param); - if (select && select->cond) - select->cond->walk(&Item::register_field_in_read_map, 1, - (uchar*) sort_form); - if (select && select->pre_idx_push_select_cond) - select->pre_idx_push_select_cond->walk(&Item::register_field_in_read_map, - 1, (uchar*) sort_form); + Item *sort_cond= !select ? + 0 : !select->pre_idx_push_select_cond ? + select->cond : select->pre_idx_push_select_cond; + if (sort_cond) + sort_cond->walk(&Item::register_field_in_read_map, 1, (uchar*) sort_form); sort_form->column_bitmaps_set(&sort_form->tmp_set, &sort_form->tmp_set, &sort_form->tmp_set); @@ -642,15 +643,21 @@ static ha_rows find_all_keys(SORTPARAM *param, SQL_SELECT *select, SQL_SELECT::skip_record evaluates this condition. it may include a correlated subquery predicate, such that some field in the subquery refers to 'sort_form'. + + PSergey-todo: discuss the above with Timour. */ + MY_BITMAP *tmp_read_set= sort_form->read_set; + MY_BITMAP *tmp_write_set= sort_form->write_set; + MY_BITMAP *tmp_vcol_set= sort_form->vcol_set; + if (select->cond->with_subselect) sort_form->column_bitmaps_set(save_read_set, save_write_set, save_vcol_set); write_record= (select->skip_record(thd) > 0); if (select->cond->with_subselect) - sort_form->column_bitmaps_set(&sort_form->tmp_set, - &sort_form->tmp_set, - &sort_form->tmp_set); + sort_form->column_bitmaps_set(tmp_read_set, + tmp_write_set, + tmp_vcol_set); } else write_record= true; @@ -999,21 +1006,10 @@ static void make_sortkey(register SORTPARAM *param, if (addonf->null_bit && field->is_null()) { nulls[addonf->null_offset]|= addonf->null_bit; -#ifdef HAVE_valgrind - bzero(to, addonf->length); -#endif } else { -#ifdef HAVE_valgrind - uchar *end= field->pack(to, field->ptr); - uint length= (uint) ((to + addonf->length) - end); - DBUG_ASSERT((int) length >= 0); - if (length) - bzero(end, length); -#else (void) field->pack(to, field->ptr); -#endif } to+= addonf->length; } @@ -1252,9 +1248,9 @@ int merge_buffers(SORTPARAM *param, IO_CACHE *from_file, void *first_cmp_arg; element_count dupl_count= 0; uchar *src; - THD::killed_state not_killable; + killed_state not_killable; uchar *unique_buff= param->unique_buff; - volatile THD::killed_state *killed= ¤t_thd->killed; + volatile killed_state *killed= ¤t_thd->killed; DBUG_ENTER("merge_buffers"); status_var_increment(current_thd->status_var.filesort_merge_passes); @@ -1262,7 +1258,7 @@ int merge_buffers(SORTPARAM *param, IO_CACHE *from_file, if (param->not_killable) { killed= ¬_killable; - not_killable= THD::NOT_KILLED; + not_killable= NOT_KILLED; } error=0; diff --git a/sql/filesort.h b/sql/filesort.h index a4056415d32..8ee8999d055 100644 --- a/sql/filesort.h +++ b/sql/filesort.h @@ -1,4 +1,4 @@ -/* Copyright 2006-2008 MySQL AB, 2008-2009 Sun Microsystems, Inc. +/* Copyright (c) 2006, 2010, Oracle and/or its affiliates. All rights reserved. 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/frm_crypt.cc b/sql/frm_crypt.cc index 821e61c5247..5612908aea5 100644 --- a/sql/frm_crypt.cc +++ b/sql/frm_crypt.cc @@ -1,4 +1,4 @@ -/* Copyright (C) 2000 MySQL AB +/* Copyright (c) 2000, 2010, Oracle and/or its affiliates. All rights reserved. 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 @@ -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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ /* diff --git a/sql/frm_crypt.h b/sql/frm_crypt.h index e119dceae35..0605644b3e0 100644 --- a/sql/frm_crypt.h +++ b/sql/frm_crypt.h @@ -1,4 +1,4 @@ -/* Copyright 2006-2008 MySQL AB, 2008-2009 Sun Microsystems, Inc. +/* Copyright (c) 2006, 2010, Oracle and/or its affiliates. All rights reserved. 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/gen_lex_hash.cc b/sql/gen_lex_hash.cc index d442d029ba0..e2ced8c8326 100644 --- a/sql/gen_lex_hash.cc +++ b/sql/gen_lex_hash.cc @@ -1,4 +1,5 @@ -/* Copyright (C) 2000-2007 MySQL AB, 2009 Sun Microsystems, Inc. +/* + Copyright (c) 2000, 2011, Oracle and/or its affiliates. All rights reserved. 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 @@ -11,7 +12,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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ /** @file @@ -84,6 +85,8 @@ So, we can read full search-structure as 32-bit word #include <stdio.h> #include <string.h> +#include <welcome_copyright_notice.h> /* ORACLE_WELCOME_COPYRIGHT_NOTICE */ + struct hash_lex_struct { int first_char; @@ -374,24 +377,9 @@ int main(int argc,char **argv) /* Broken up to indicate that it's not advice to you, gentle reader. */ printf("/*\n\n Do " "not " "edit " "this " "file " "directly!\n\n*/\n"); - printf("\ -/* Copyright (C) 2000-2008 MySQL AB, 2008 Sun Microsystems, Inc.\n\ -\n\ - This program is free software; you can redistribute it and/or modify\n\ - it under the terms of the GNU General Public License as published by\n\ - the Free Software Foundation; version 2 of the License.\n\ -\n\ - This program is distributed in the hope that it will be useful,\n\ - but WITHOUT ANY WARRANTY; without even the implied warranty of\n\ - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n\ - GNU General Public License for more details.\n\ -\n\ - You should have received a copy of the GNU General Public License\n\ - along with this program; see the file COPYING. If not, write to the\n\ - Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston\n\ - MA 02110-1301 USA. */\n\ -\n\ -"); + puts("/*"); + puts(ORACLE_WELCOME_COPYRIGHT_NOTICE("2000, 2011")); + puts("*/"); /* Broken up to indicate that it's not advice to you, gentle reader. */ printf("/* Do " "not " "edit " "this " "file! This is generated by " diff --git a/sql/gstream.cc b/sql/gstream.cc index fcb9a91ac50..61263380411 100644 --- a/sql/gstream.cc +++ b/sql/gstream.cc @@ -1,4 +1,4 @@ -/* Copyright (C) 2004 MySQL AB +/* Copyright (c) 2002, 2010, Oracle and/or its affiliates. All rights reserved. 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 @@ -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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ /* Functions to read and parse geometrical data. diff --git a/sql/gstream.h b/sql/gstream.h index 7c079c7bdb3..533fafa28f3 100644 --- a/sql/gstream.h +++ b/sql/gstream.h @@ -1,7 +1,7 @@ #ifndef GSTREAM_INCLUDED #define GSTREAM_INCLUDED -/* Copyright (C) 2000-2004 MySQL AB +/* Copyright (c) 2000, 2010, Oracle and/or its affiliates. All rights reserved. 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 @@ -14,7 +14,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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ #include "my_global.h" /* NULL, NullS */ diff --git a/sql/ha_ndbcluster.cc b/sql/ha_ndbcluster.cc index 773b6155c68..7a62efb1917 100644 --- a/sql/ha_ndbcluster.cc +++ b/sql/ha_ndbcluster.cc @@ -1,4 +1,4 @@ -/* Copyright (c) 2000, 2011, Oracle and/or its affiliates. All rights reserved. +/* Copyright (c) 2004, 2011, Oracle and/or its affiliates. All rights reserved. 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 @@ -11026,7 +11026,8 @@ mysql_declare_plugin(ndbcluster) 0x0100 /* 1.0 */, ndb_status_variables_export,/* status variables */ system_variables, /* system variables */ - NULL /* config options */ + NULL, /* config options */ + 0, /* flags */ } mysql_declare_plugin_end; maria_declare_plugin(ndbcluster) diff --git a/sql/ha_ndbcluster.h b/sql/ha_ndbcluster.h index 83205084209..f3c9553f524 100644 --- a/sql/ha_ndbcluster.h +++ b/sql/ha_ndbcluster.h @@ -1,7 +1,8 @@ #ifndef HA_NDBCLUSTER_INCLUDED #define HA_NDBCLUSTER_INCLUDED -/* Copyright (C) 2000-2003 MySQL AB, 2008-2009 Sun Microsystems, Inc +/* Copyright (c) 2000-2003 MySQL AB, 2008-2009 Sun Microsystems, Inc. + Use is subject to license terms. 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 @@ -14,7 +15,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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ /* This file defines the NDB Cluster handler: the interface between MySQL and diff --git a/sql/ha_ndbcluster_binlog.cc b/sql/ha_ndbcluster_binlog.cc index c4b71bf32cf..3d140b92977 100644 --- a/sql/ha_ndbcluster_binlog.cc +++ b/sql/ha_ndbcluster_binlog.cc @@ -1,4 +1,5 @@ -/* Copyright (c) 2000, 2011, Oracle and/or its affiliates. All rights reserved. +/* + Copyright (c) 2006, 2011, Oracle and/or its affiliates. All rights reserved. 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 @@ -11,7 +12,8 @@ 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 02110-1301 USA */ + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +*/ #include "sql_priv.h" #include "unireg.h" // REQUIRED: for other includes @@ -1868,7 +1870,7 @@ static void ndb_binlog_query(THD *thd, Cluster_schema *schema) else thd->server_id= schema->any_value; thd->db= schema->db; - int errcode = query_error_code(thd, thd->killed == THD::NOT_KILLED); + int errcode = query_error_code(thd, thd->killed == NOT_KILLED); thd->binlog_query(THD::STMT_QUERY_TYPE, schema->query, schema->query_length, FALSE, TRUE, schema->name[0] == 0 || thd->db[0] == 0, diff --git a/sql/ha_ndbcluster_binlog.h b/sql/ha_ndbcluster_binlog.h index 5dbcf0fa43f..1cc20c954cb 100644 --- a/sql/ha_ndbcluster_binlog.h +++ b/sql/ha_ndbcluster_binlog.h @@ -1,7 +1,8 @@ #ifndef HA_NDBCLUSTER_BINLOG_INCLUDED #define HA_NDBCLUSTER_BINLOG_INCLUDED -/* Copyright (C) 2000-2003 MySQL AB, 2008-2009 Sun Microsystems, Inc +/* Copyright (c) 2000-2003 MySQL AB, 2008-2009 Sun Microsystems, Inc. + Use is subject to license terms. 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 @@ -14,7 +15,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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ #include "sql_class.h" /* THD */ diff --git a/sql/ha_partition.cc b/sql/ha_partition.cc index eefc24c3103..b4dc3f79e0c 100644 --- a/sql/ha_partition.cc +++ b/sql/ha_partition.cc @@ -1,4 +1,5 @@ -/* Copyright (c) 2005, 2011, Oracle and/or its affiliates. All rights reserved. +/* + Copyright (c) 2005, 2011, Oracle and/or its affiliates. All rights reserved. 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 @@ -11,7 +12,8 @@ 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 02110-1301 USA */ + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +*/ /* This handler was developed by Mikael Ronstrom for version 5.1 of MySQL. @@ -7220,7 +7222,8 @@ mysql_declare_plugin(partition) 0x0100, /* 1.0 */ NULL, /* status variables */ NULL, /* system variables */ - NULL /* config options */ + NULL, /* config options */ + 0, /* flags */ } mysql_declare_plugin_end; maria_declare_plugin(partition) diff --git a/sql/ha_partition.h b/sql/ha_partition.h index 45ac8168513..46a8924c883 100644 --- a/sql/ha_partition.h +++ b/sql/ha_partition.h @@ -1,7 +1,8 @@ #ifndef HA_PARTITION_INCLUDED #define HA_PARTITION_INCLUDED -/* Copyright 2005-2008 MySQL AB, 2008-2009 Sun Microsystems, Inc. +/* + Copyright (c) 2005, 2011, Oracle and/or its affiliates. All rights reserved. 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 @@ -14,7 +15,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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ #ifdef __GNUC__ #pragma interface /* gcc class implementation */ diff --git a/sql/handler.cc b/sql/handler.cc index 7fc5aea48fa..1d0f676493d 100644 --- a/sql/handler.cc +++ b/sql/handler.cc @@ -362,6 +362,7 @@ int ha_init_errors(void) SETMSG(HA_ERR_AUTOINC_ERANGE, ER_DEFAULT(ER_WARN_DATA_OUT_OF_RANGE)); SETMSG(HA_ERR_TOO_MANY_CONCURRENT_TRXS, ER_DEFAULT(ER_TOO_MANY_CONCURRENT_TRXS)); SETMSG(HA_ERR_INDEX_COL_TOO_LONG, ER_DEFAULT(ER_INDEX_COLUMN_TOO_LONG)); + SETMSG(HA_ERR_INDEX_CORRUPT, ER_DEFAULT(ER_INDEX_CORRUPT)); SETMSG(HA_ERR_DISK_FULL, ER_DEFAULT(ER_DISK_FULL)); /* Register the error messages for use with my_error(). */ @@ -1477,9 +1478,13 @@ int ha_rollback_trans(THD *thd, bool all) slave SQL thread, it would not stop the thread but just be printed in the error log; but we don't want users to wonder why they have this message in the error log, so we don't send it. + + We don't have to test for thd->killed == KILL_SYSTEM_THREAD as + it doesn't matter if a warning is pushed to a system thread or not: + No one will see it... */ if (is_real_trans && thd->transaction.all.modified_non_trans_table && - !thd->slave_thread && thd->killed != THD::KILL_CONNECTION) + !thd->slave_thread && thd->killed < KILL_CONNECTION) push_warning(thd, MYSQL_ERROR::WARN_LEVEL_WARN, ER_WARNING_NOT_COMPLETE_ROLLBACK, ER(ER_WARNING_NOT_COMPLETE_ROLLBACK)); @@ -2608,7 +2613,7 @@ int handler::update_auto_increment() /* first test if the query was aborted due to strict mode constraints */ - if (thd->killed == THD::KILL_BAD_DATA) + if (killed_mask_hard(thd->killed) == KILL_BAD_DATA) DBUG_RETURN(HA_ERR_AUTOINC_ERANGE); /* @@ -3010,6 +3015,12 @@ void handler::print_error(int error, myf errflag) case HA_ERR_INDEX_COL_TOO_LONG: textno= ER_INDEX_COLUMN_TOO_LONG; break; + case HA_ERR_INDEX_CORRUPT: + textno= ER_INDEX_CORRUPT; + break; + case HA_ERR_UNDO_REC_TOO_BIG: + textno= ER_UNDO_RECORD_TOO_BIG; + break; default: { /* The error was "unknown" to this function. @@ -4772,7 +4783,7 @@ static bool check_table_binlog_row_based(THD *thd, TABLE *table) /** @brief Write table maps for all (manually or automatically) locked tables - to the binary log. Also, if binlog_annotate_rows_events is ON, + to the binary log. Also, if binlog_annotate_row_events is ON, write Annotate_rows event before the first table map. SYNOPSIS @@ -4805,7 +4816,7 @@ static int write_locked_table_maps(THD *thd) MYSQL_LOCK *locks[2]; locks[0]= thd->extra_lock; locks[1]= thd->lock; - my_bool with_annotate= thd->variables.binlog_annotate_rows_events && + my_bool with_annotate= thd->variables.binlog_annotate_row_events && thd->query() && thd->query_length(); for (uint i= 0 ; i < sizeof(locks)/sizeof(*locks) ; ++i ) @@ -4989,6 +5000,9 @@ int handler::ha_reset() /* reset the bitmaps to point to defaults */ table->default_column_bitmaps(); pushed_cond= NULL; + /* Reset information about pushed engine conditions */ + cancel_pushed_idx_cond(); + /* Reset information about pushed index conditions */ DBUG_RETURN(reset()); } diff --git a/sql/handler.h b/sql/handler.h index b27c897364b..fc38794a410 100644 --- a/sql/handler.h +++ b/sql/handler.h @@ -1,6 +1,7 @@ #ifndef HANDLER_INCLUDED #define HANDLER_INCLUDED -/* Copyright (c) 2000, 2011, Oracle and/or its affiliates. +/* + Copyright (c) 2000, 2011, Oracle and/or its affiliates. Copyright (c) 2009-2011 Monty Program Ab This program is free software; you can redistribute it and/or @@ -15,8 +16,8 @@ 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 - 02110-1301 USA */ + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +*/ /* Definitions for parameters to do with handler-routines */ @@ -1787,7 +1788,7 @@ public: handler(handlerton *ht_arg, TABLE_SHARE *share_arg) :table_share(share_arg), table(0), estimation_rows_to_insert(0), ht(ht_arg), - ref(0), key_used_on_scan(MAX_KEY), active_index(MAX_KEY), + ref(0), end_range(NULL), key_used_on_scan(MAX_KEY), active_index(MAX_KEY), in_range_check_pushed_down(FALSE), ref_length(sizeof(my_off_t)), ft_handler(0), inited(NONE), @@ -1844,6 +1845,7 @@ public: DBUG_ENTER("ha_rnd_init"); DBUG_ASSERT(inited==NONE || (inited==RND && scan)); inited= (result= rnd_init(scan)) ? NONE: RND; + end_range= NULL; DBUG_RETURN(result); } int ha_rnd_end() @@ -1851,6 +1853,7 @@ public: DBUG_ENTER("ha_rnd_end"); DBUG_ASSERT(inited==RND); inited=NONE; + end_range= NULL; DBUG_RETURN(rnd_end()); } int ha_rnd_init_with_error(bool scan) __attribute__ ((warn_unused_result)); @@ -2566,6 +2569,13 @@ public: */ virtual void cond_pop() { return; }; virtual Item *idx_cond_push(uint keyno, Item* idx_cond) { return idx_cond; } + /** Reset information about pushed index conditions */ + virtual void cancel_pushed_idx_cond() + { + pushed_idx_cond= NULL; + pushed_idx_cond_keyno= MAX_KEY; + in_range_check_pushed_down= false; + } virtual bool check_if_incompatible_data(HA_CREATE_INFO *create_info, uint table_changes) { return COMPATIBLE_DATA_NO; } diff --git a/sql/hash_filo.cc b/sql/hash_filo.cc index 9d6e4363efc..7c275ffc617 100644 --- a/sql/hash_filo.cc +++ b/sql/hash_filo.cc @@ -1,4 +1,4 @@ -/* Copyright (C) 2000-2001, 2005 MySQL AB +/* Copyright (c) 2000, 2010, Oracle and/or its affiliates. All rights reserved. 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 @@ -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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ /* diff --git a/sql/hash_filo.h b/sql/hash_filo.h index 8301f5c8c3b..dab54928a55 100644 --- a/sql/hash_filo.h +++ b/sql/hash_filo.h @@ -1,4 +1,4 @@ -/* Copyright (C) 2000-2003, 2005 MySQL AB, 2008-2009 Sun Microsystems, Inc +/* Copyright (c) 2000, 2010, Oracle and/or its affiliates. All rights reserved. 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 @@ -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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ /* diff --git a/sql/hostname.h b/sql/hostname.h index 03611bb5813..6e9535c2947 100644 --- a/sql/hostname.h +++ b/sql/hostname.h @@ -1,4 +1,4 @@ -/* Copyright 2006-2008 MySQL AB, 2008-2009 Sun Microsystems, Inc. +/* Copyright (c) 2006, 2010, Oracle and/or its affiliates. All rights reserved. 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/init.cc b/sql/init.cc index e43b12787ab..86915b7aa01 100644 --- a/sql/init.cc +++ b/sql/init.cc @@ -1,4 +1,4 @@ -/* Copyright (C) 2000-2005 MySQL AB +/* Copyright (c) 2000, 2010, Oracle and/or its affiliates. All rights reserved. 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 @@ -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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ /** diff --git a/sql/init.h b/sql/init.h index 2c160879223..88cd8e6e178 100644 --- a/sql/init.h +++ b/sql/init.h @@ -1,4 +1,4 @@ -/* Copyright 2006-2008 MySQL AB, 2008-2009 Sun Microsystems, Inc. +/* Copyright (c) 2006, 2010, Oracle and/or its affiliates. All rights reserved. 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/item.cc b/sql/item.cc index f443ca7ec18..028cc8c8e30 100644 --- a/sql/item.cc +++ b/sql/item.cc @@ -1,4 +1,5 @@ -/* Copyright (c) 2000, 2010 Oracle and/or its affiliates. All rights reserved. +/* + Copyright (c) 2000, 2011, Oracle and/or its affiliates. All rights reserved. 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 @@ -11,7 +12,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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ #ifdef USE_PRAGMA_IMPLEMENTATION @@ -805,7 +806,9 @@ bool Item_ident::remove_dependence_processor(uchar * arg) bool Item_ident::collect_outer_ref_processor(uchar *param) { Collect_deps_prm *prm= (Collect_deps_prm *)param; - if (depended_from && depended_from->nest_level < prm->nest_level) + if (depended_from && + depended_from->nest_level_base == prm->nest_level_base && + depended_from->nest_level < prm->nest_level) prm->parameters->add_unique(this, &cmp_items); return FALSE; } @@ -2342,6 +2345,11 @@ bool Item_field::enumerate_field_refs_processor(uchar *arg) return FALSE; } +bool Item_field::update_table_bitmaps_processor(uchar *arg) +{ + update_table_bitmaps(); + return FALSE; +} const char *Item_ident::full_name() const { @@ -5010,6 +5018,7 @@ bool Item_field::fix_fields(THD *thd, Item **reference) if (!outer_fixed && cached_table && cached_table->select_lex && context->select_lex && cached_table->select_lex != context->select_lex && + !context->select_lex->is_merged_child_of(cached_table->select_lex) && is_outer_table(cached_table, context->select_lex)) { int ret; @@ -5109,14 +5118,14 @@ mark_non_agg_field: SELECT_LEX *select_lex= cached_table ? cached_table->select_lex : context->select_lex; if (!thd->lex->in_sum_func) - select_lex->full_group_by_flag|= NON_AGG_FIELD_USED; + select_lex->set_non_agg_field_used(true); else { if (outer_fixed) thd->lex->in_sum_func->outer_fields.push_back(this); else if (thd->lex->in_sum_func->nest_level != thd->lex->current_select->nest_level) - select_lex->full_group_by_flag|= NON_AGG_FIELD_USED; + select_lex->set_non_agg_field_used(true); } } return FALSE; @@ -5543,6 +5552,10 @@ Field *Item::make_string_field(TABLE *table) { Field *field; DBUG_ASSERT(collation.collation); + /* + Note: the following check is repeated in + subquery_types_allow_materialization(): + */ if (max_length/collation.collation->mbmaxlen > CONVERT_IF_BIGGER_TO_BLOB) field= new Field_blob(max_length, maybe_null, name, collation.collation, TRUE); @@ -6344,7 +6357,7 @@ bool Item::send(Protocol *protocol, String *buffer) case MYSQL_TYPE_TIMESTAMP: { MYSQL_TIME tm; - get_date(&tm, TIME_FUZZY_DATE); + get_date(&tm, TIME_FUZZY_DATE | sql_mode_for_dates()); if (!null_value) { if (f_type == MYSQL_TYPE_DATE) @@ -7745,7 +7758,11 @@ bool Item_direct_view_ref::fix_fields(THD *thd, Item **reference) ((*ref)->fix_fields(thd, ref))) return TRUE; - return Item_direct_ref::fix_fields(thd, reference); + if (Item_direct_ref::fix_fields(thd, reference)) + return TRUE; + if (view->table && view->table->maybe_null) + maybe_null= TRUE; + return FALSE; } /* @@ -9520,6 +9537,12 @@ table_map Item_direct_view_ref::used_tables() const (view->merged ? (*ref)->used_tables() : view->table->map); } +table_map Item_direct_view_ref::not_null_tables() const +{ + return get_depended_from() ? + 0 : + (view->merged ? (*ref)->not_null_tables() : view->table->map); +} /* we add RAND_TABLE_BIT to prevent moving this item from HAVING to WHERE @@ -9532,7 +9555,22 @@ table_map Item_ref_null_helper::used_tables() const } +/* Debugger help function */ +static char dbug_item_print_buf[256]; +const char *dbug_print_item(Item *item) +{ + char *buf= dbug_item_print_buf; + String str(buf, sizeof(dbug_item_print_buf), &my_charset_bin); + str.length(0); + if (!item) + return "(Item*)NULL"; + item->print(&str ,QT_ORDINARY); + if (str.c_ptr() == buf) + return buf; + else + return "Couldn't fit into buffer"; +} /***************************************************************************** ** Instantiate templates *****************************************************************************/ diff --git a/sql/item.h b/sql/item.h index c3bdc5042c8..9186ba084db 100644 --- a/sql/item.h +++ b/sql/item.h @@ -541,6 +541,7 @@ typedef void (*Cond_traverser) (const Item *item, void *arg); class Item_equal; class COND_EQUAL; +class st_select_lex_unit; class Item { Item(const Item &); /* Prevent use of these */ @@ -1144,9 +1145,11 @@ public: virtual bool mark_as_eliminated_processor(uchar *arg) { return 0; } virtual bool eliminate_subselect_processor(uchar *arg) { return 0; } virtual bool set_fake_select_as_master_processor(uchar *arg) { return 0; } + virtual bool update_table_bitmaps_processor(uchar *arg) { return 0; } virtual bool view_used_tables_processor(uchar *arg) { return 0; } virtual bool eval_not_null_tables(uchar *opt_arg) { return 0; } virtual bool clear_sum_processor(uchar *opt_arg) { return 0; } + virtual bool is_subquery_processor (uchar *opt_arg) { return 0; } /* To call bool function for all arguments */ struct bool_func_call_args @@ -1288,8 +1291,10 @@ public: } struct Collect_deps_prm { - int nest_level; List<Item> *parameters; + /* unit from which we count nest_level */ + st_select_lex_unit *nest_level_base; + int nest_level; }; /** Collect outer references @@ -1461,6 +1466,8 @@ public: be defined for Item_func. */ virtual void get_cache_parameters(List<Item> ¶meters) { }; + + virtual void mark_as_condition_AND_part(TABLE_LIST *embedding) {}; }; @@ -2022,6 +2029,20 @@ public: bool get_date_result(MYSQL_TIME *ltime,ulonglong fuzzydate); bool is_null() { return field->is_null(); } void update_null_value(); + void update_table_bitmaps() + { + if (field && field->table) + { + TABLE *tab= field->table; + tab->covering_keys.intersect(field->part_of_key); + tab->merge_keys.merge(field->part_of_key); + if (tab->read_set) + bitmap_fast_test_and_set(tab->read_set, field->field_index); + if (field->vcol_info) + tab->mark_virtual_col(field); + } + } + void update_used_tables() { update_table_bitmaps(); } Item *get_tmp_table_item(THD *thd); bool collect_item_field_processor(uchar * arg); bool add_field_to_set_processor(uchar * arg); @@ -2033,6 +2054,7 @@ public: bool vcol_in_partition_func_processor(uchar *bool_arg); bool check_vcol_func_processor(uchar *arg) { return FALSE;} bool enumerate_field_refs_processor(uchar *arg); + bool update_table_bitmaps_processor(uchar *arg); void cleanup(); Item_equal *get_item_equal() { return item_equal; } void set_item_equal(Item_equal *item_eq) { item_equal= item_eq; } @@ -3153,6 +3175,7 @@ public: Item *equal_fields_propagator(uchar *arg); Item *replace_equal_field(uchar *arg); table_map used_tables() const; + table_map not_null_tables() const; bool walk(Item_processor processor, bool walk_subquery, uchar *arg) { return (*ref)->walk(processor, walk_subquery, arg) || @@ -3848,6 +3871,20 @@ public: { return test(example && example->basic_const_item());} virtual void clear() { null_value= TRUE; value_cached= FALSE; } bool is_null() { return null_value; } + virtual bool is_expensive() + { + DBUG_ASSERT(example); + if (value_cached) + return false; + return example->is_expensive(); + } + bool is_expensive_processor(uchar *arg) + { + DBUG_ASSERT(example); + if (value_cached) + return false; + return example->is_expensive_processor(arg); + } }; diff --git a/sql/item_buff.cc b/sql/item_buff.cc index 8c4224404d0..e72c63daf7d 100644 --- a/sql/item_buff.cc +++ b/sql/item_buff.cc @@ -1,4 +1,4 @@ -/* Copyright (C) 2000-2006 MySQL AB +/* Copyright (c) 2000, 2010, Oracle and/or its affiliates. All rights reserved. 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 @@ -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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ /** diff --git a/sql/item_cmpfunc.cc b/sql/item_cmpfunc.cc index aa11a2ae8eb..14c8c9b9138 100644 --- a/sql/item_cmpfunc.cc +++ b/sql/item_cmpfunc.cc @@ -33,8 +33,6 @@ #include "sql_time.h" // make_truncated_value_warning #include "sql_base.h" // dynamic_column_error_message -static bool convert_const_to_int(THD *, Item_field *, Item **); - static Item_result item_store_type(Item_result a, Item *item, my_bool unsigned_flag) { @@ -519,7 +517,6 @@ static bool convert_const_to_int(THD *thd, Item_field *field_item, void Item_bool_func2::fix_length_and_dec() { max_length= 1; // Function returns 0 or 1 - THD *thd; /* As some compare functions are generated after sql_yacc, @@ -551,14 +548,14 @@ void Item_bool_func2::fix_length_and_dec() /* Make a special case of compare with fields to get nicer comparisons - of numbers with constant string. + of bigint numbers with constant string. This directly contradicts the manual (number and a string should be compared as doubles), but seems to provide more "intuitive" behavior in some cases (but less intuitive in others). But disable conversion in case of LIKE function. */ - thd= current_thd; + THD *thd= current_thd; if (functype() != LIKE_FUNC && !thd->lex->is_ps_or_view_context_analysis()) { int field; @@ -566,7 +563,8 @@ void Item_bool_func2::fix_length_and_dec() args[field= 1]->real_item()->type() == FIELD_ITEM) { Item_field *field_item= (Item_field*) (args[field]->real_item()); - if (field_item->cmp_type() == INT_RESULT && + if ((field_item->field_type() == MYSQL_TYPE_LONGLONG || + field_item->field_type() == MYSQL_TYPE_YEAR) && convert_const_to_int(thd, field_item, &args[!field])) args[0]->cmp_context= args[1]->cmp_context= INT_RESULT; } @@ -1401,6 +1399,16 @@ bool Item_in_optimizer::is_top_level_item() } +void Item_in_optimizer::fix_after_pullout(st_select_lex *new_parent, Item **ref) +{ + /* This will re-calculate attributes of our Item_in_subselect: */ + Item_bool_func::fix_after_pullout(new_parent, ref); + + /* Then, re-calculate not_null_tables_cache: */ + eval_not_null_tables(NULL); +} + + bool Item_in_optimizer::eval_not_null_tables(uchar *opt_arg) { not_null_tables_cache= 0; @@ -1424,6 +1432,7 @@ bool Item_in_optimizer::fix_left(THD *thd, Item **ref) cache->setup(args[0]); if (cache->cols() == 1) { + DBUG_ASSERT(args[0]->type() != ROW_ITEM); /* Note: there can be cases when used_tables()==0 && !const_item(). See Item_sum::update_used_tables for details. @@ -1438,6 +1447,14 @@ bool Item_in_optimizer::fix_left(THD *thd, Item **ref) uint n= cache->cols(); for (uint i= 0; i < n; i++) { + /* Check that the expression (part of row) do not contain a subquery */ + if (args[0]->element_index(i)->walk(&Item::is_subquery_processor, + FALSE, NULL)) + { + my_error(ER_NOT_SUPPORTED_YET, MYF(0), + "SUBQUERY in ROW in left expression of IN/ALL/ANY"); + return 1; + } Item *element=args[0]->element_index(i); if (element->used_tables() || !element->const_item()) ((Item_cache *)cache->element_index(i))->set_used_tables(OUTER_REF_TABLE_BIT); @@ -1784,7 +1801,7 @@ Item *Item_in_optimizer::transform(Item_transformer transformer, uchar *argument if (!new_item) return 0; if (args[1] != new_item) - current_thd->change_item_tree(args, new_item); + current_thd->change_item_tree(args + 1, new_item); } else { @@ -2135,6 +2152,14 @@ bool Item_func_between::eval_not_null_tables(uchar *opt_arg) } +void Item_func_between::fix_after_pullout(st_select_lex *new_parent, Item **ref) +{ + /* This will re-calculate attributes of the arguments */ + Item_func_opt_neg::fix_after_pullout(new_parent, ref); + /* Then, re-calculate not_null_tables_cache according to our special rules */ + eval_not_null_tables(NULL); +} + void Item_func_between::fix_length_and_dec() { THD *thd= current_thd; @@ -2169,7 +2194,8 @@ void Item_func_between::fix_length_and_dec() !thd->lex->is_ps_or_view_context_analysis()) { Item_field *field_item= (Item_field*) (args[0]->real_item()); - if (field_item->cmp_type() == INT_RESULT) + if (field_item->field_type() == MYSQL_TYPE_LONGLONG || + field_item->field_type() == MYSQL_TYPE_YEAR) { /* The following can't be recoded with || as convert_const_to_int @@ -2519,6 +2545,15 @@ Item_func_if::eval_not_null_tables(uchar *opt_arg) } +void Item_func_if::fix_after_pullout(st_select_lex *new_parent, Item **ref) +{ + /* This will re-calculate attributes of the arguments */ + Item_func::fix_after_pullout(new_parent, ref); + /* Then, re-calculate not_null_tables_cache according to our special rules */ + eval_not_null_tables(NULL); +} + + void Item_func_if::fix_length_and_dec() { @@ -2771,7 +2806,7 @@ Item *Item_func_case::find_item(String *str) { if (args[i]->real_item()->type() == NULL_ITEM) continue; - cmp_type= item_cmp_type(left_result_type, args[i]->result_type()); + cmp_type= item_cmp_type(left_result_type, args[i]->cmp_type()); DBUG_ASSERT(cmp_type != ROW_RESULT); DBUG_ASSERT(cmp_items[(uint)cmp_type]); if (!(value_added_map & (1<<(uint)cmp_type))) @@ -2901,11 +2936,35 @@ void Item_func_case::agg_num_lengths(Item *arg) } +/** + Check if (*place) and new_value points to different Items and call + THD::change_item_tree() if needed. + + This function is a workaround for implementation deficiency in + Item_func_case. The problem there is that the 'args' attribute contains + Items from different expressions. + + The function must not be used elsewhere and will be remove eventually. +*/ + +static void change_item_tree_if_needed(THD *thd, + Item **place, + Item *new_value) +{ + if (*place == new_value) + return; + + thd->change_item_tree(place, new_value); +} + + void Item_func_case::fix_length_and_dec() { Item **agg; uint nagg; uint found_types= 0; + THD *thd= current_thd; + if (!(agg= (Item**) sql_alloc(sizeof(Item*)*(ncases+1)))) return; @@ -2930,9 +2989,10 @@ void Item_func_case::fix_length_and_dec() Some of the items might have been changed to Item_func_conv_charset. */ for (nagg= 0 ; nagg < ncases / 2 ; nagg++) - args[nagg * 2 + 1]= agg[nagg]; + change_item_tree_if_needed(thd, &args[nagg * 2 + 1], agg[nagg]); + if (else_expr_num != -1) - args[else_expr_num]= agg[nagg++]; + change_item_tree_if_needed(thd, &args[else_expr_num], agg[nagg++]); } else collation.set_numeric(); @@ -2946,7 +3006,7 @@ void Item_func_case::fix_length_and_dec() { uint i; agg[0]= args[first_expr_num]; - left_result_type= agg[0]->result_type(); + left_result_type= agg[0]->cmp_type(); /* As the first expression and WHEN expressions @@ -2992,19 +3052,24 @@ void Item_func_case::fix_length_and_dec() arrray, because some of the items might have been changed to converters (e.g. Item_func_conv_charset, or Item_string for constants). */ - args[first_expr_num]= agg[0]; + change_item_tree_if_needed(thd, &args[first_expr_num], agg[0]); + for (nagg= 0; nagg < ncases / 2; nagg++) - args[nagg * 2]= agg[nagg + 1]; + change_item_tree_if_needed(thd, &args[nagg * 2], agg[nagg + 1]); } + Item *date_arg= 0; for (i= 0; i <= (uint)TIME_RESULT; i++) { if (found_types & (1 << i) && !cmp_items[i]) { DBUG_ASSERT((Item_result)i != ROW_RESULT); - DBUG_ASSERT((Item_result)i != TIME_RESULT); + + if ((Item_result)i == TIME_RESULT) + date_arg= find_date_time_item(args, arg_count, 0); + if (!(cmp_items[i]= - cmp_item::get_comparator((Item_result)i, 0, + cmp_item::get_comparator((Item_result)i, date_arg, cmp_collation.collation))) return; } @@ -3598,10 +3663,13 @@ void cmp_item_row::store_value(Item *item) for (uint i=0; i < n; i++) { if (!comparators[i]) + { + DBUG_ASSERT(item->element_index(i)->cmp_type() != TIME_RESULT); if (!(comparators[i]= cmp_item::get_comparator(item->element_index(i)->result_type(), 0, item->element_index(i)->collation.collation))) break; // new failed + } comparators[i]->store_value(item->element_index(i)); item->null_value|= item->element_index(i)->null_value; } @@ -3804,6 +3872,14 @@ Item_func_in::eval_not_null_tables(uchar *opt_arg) } +void Item_func_in::fix_after_pullout(st_select_lex *new_parent, Item **ref) +{ + /* This will re-calculate attributes of the arguments */ + Item_func_opt_neg::fix_after_pullout(new_parent, ref); + /* Then, re-calculate not_null_tables_cache according to our special rules */ + eval_not_null_tables(NULL); +} + static int srtcmp_in(CHARSET_INFO *cs, const String *x,const String *y) { return cs->coll->strnncollsp(cs, @@ -3902,7 +3978,8 @@ void Item_func_in::fix_length_and_dec() !thd->lex->is_view_context_analysis() && cmp_type != INT_RESULT) { Item_field *field_item= (Item_field*) (args[0]->real_item()); - if (field_item->cmp_type() == INT_RESULT) + if (field_item->field_type() == MYSQL_TYPE_LONGLONG || + field_item->field_type() == MYSQL_TYPE_YEAR) { bool all_converted= TRUE; for (arg=args+1, arg_end=args+arg_count; arg != arg_end ; arg++) @@ -4125,13 +4202,10 @@ Item_cond::fix_fields(THD *thd, Item **ref) DBUG_ASSERT(fixed == 0); List_iterator<Item> li(list); Item *item; - TABLE_LIST *save_emb_on_expr_nest= thd->thd_marker.emb_on_expr_nest; uchar buff[sizeof(char*)]; // Max local vars in function not_null_tables_cache= used_tables_cache= 0; const_item_cache= 1; - if (functype() != COND_AND_FUNC) - thd->thd_marker.emb_on_expr_nest= NULL; /* and_table_cache is the value that Item_cond_or() returns for not_null_tables() @@ -4191,7 +4265,6 @@ Item_cond::fix_fields(THD *thd, Item **ref) maybe_null=1; } thd->lex->current_select->cond_count+= list.elements; - thd->thd_marker.emb_on_expr_nest= save_emb_on_expr_nest; fix_length_and_dec(); fixed= 1; return FALSE; @@ -4203,6 +4276,7 @@ Item_cond::eval_not_null_tables(uchar *opt_arg) { Item *item; List_iterator<Item> li(list); + not_null_tables_cache= (table_map) 0; and_tables_cache= ~(table_map) 0; while ((item=li++)) { @@ -4461,6 +4535,17 @@ void Item_cond::neg_arguments(THD *thd) } +void Item_cond_and::mark_as_condition_AND_part(TABLE_LIST *embedding) +{ + List_iterator<Item> li(list); + Item *item; + while ((item=li++)) + { + item->mark_as_condition_AND_part(embedding); + } +} + + /** Evaluation of AND(expr, expr, expr ...). @@ -5714,7 +5799,7 @@ longlong Item_equal::val_int() void Item_equal::fix_length_and_dec() { Item *item= get_first(NULL); - eval_item= cmp_item::get_comparator(item->result_type(), 0, + eval_item= cmp_item::get_comparator(item->cmp_type(), item, item->collation.collation); } @@ -5817,7 +5902,6 @@ Item* Item_equal::get_first(Item *field_item) { Item_equal_fields_iterator it(*this); Item *item; - JOIN_TAB *field_tab; if (!field_item) return (it++); Field *field= ((Item_field *) (field_item->real_item()))->field; @@ -5842,8 +5926,6 @@ Item* Item_equal::get_first(Item *field_item) in presense of SJM nests. */ - field_tab= field->table->reginfo.join_tab; - TABLE_LIST *emb_nest= field->table->pos_in_table_list->embedding; if (emb_nest && emb_nest->sj_mat_info && emb_nest->sj_mat_info->is_used) diff --git a/sql/item_cmpfunc.h b/sql/item_cmpfunc.h index ef12364ae68..1aa48034566 100644 --- a/sql/item_cmpfunc.h +++ b/sql/item_cmpfunc.h @@ -267,6 +267,7 @@ public: virtual void get_cache_parameters(List<Item> ¶meters); bool is_top_level_item(); bool eval_not_null_tables(uchar *opt_arg); + void fix_after_pullout(st_select_lex *new_parent, Item **ref); }; class Comp_creator @@ -679,6 +680,7 @@ public: CHARSET_INFO *compare_collation() { return cmp_collation.collation; } uint decimal_precision() const { return 1; } bool eval_not_null_tables(uchar *opt_arg); + void fix_after_pullout(st_select_lex *new_parent, Item **ref); }; @@ -785,6 +787,7 @@ public: uint decimal_precision() const; const char *func_name() const { return "if"; } bool eval_not_null_tables(uchar *opt_arg); + void fix_after_pullout(st_select_lex *new_parent, Item **ref); }; @@ -1323,6 +1326,7 @@ public: bool is_bool_func() { return 1; } CHARSET_INFO *compare_collation() { return cmp_collation.collation; } bool eval_not_null_tables(uchar *opt_arg); + void fix_after_pullout(st_select_lex *new_parent, Item **ref); }; class cmp_item_row :public cmp_item @@ -1807,6 +1811,7 @@ public: return item; } Item *neg_transformer(THD *thd); + void mark_as_condition_AND_part(TABLE_LIST *embedding); }; inline bool is_cond_and(Item *item) diff --git a/sql/item_create.cc b/sql/item_create.cc index afa78946fb8..315ca857f6f 100644 --- a/sql/item_create.cc +++ b/sql/item_create.cc @@ -1,4 +1,5 @@ -/* Copyright (c) 2000, 2010 Oracle and/or its affiliates. +/* + Copyright (c) 2000, 2011, Oracle and/or its affiliates. Copyright (c) 2011 Monty Program Ab This program is free software; you can redistribute it and/or modify diff --git a/sql/item_create.h b/sql/item_create.h index 457879a618f..a8a8b9d97dd 100644 --- a/sql/item_create.h +++ b/sql/item_create.h @@ -1,4 +1,5 @@ -/* Copyright (c) 2000, 2010 Oracle and/or its affiliates. +/* Copyright (c) 2000, 2010, Oracle and/or its affiliates. + Copyright (c) 2010, 2011, Monty Program Ab 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 @@ -11,7 +12,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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ /* Functions to create an item. Used by sql/sql_yacc.yy */ diff --git a/sql/item_func.cc b/sql/item_func.cc index c9d3a506c94..251ecd00242 100644 --- a/sql/item_func.cc +++ b/sql/item_func.cc @@ -177,9 +177,7 @@ Item_func::fix_fields(THD *thd, Item **ref) { DBUG_ASSERT(fixed == 0); Item **arg,**arg_end; - TABLE_LIST *save_emb_on_expr_nest= thd->thd_marker.emb_on_expr_nest; uchar buff[STACK_BUFF_ALLOC]; // Max argument in function - thd->thd_marker.emb_on_expr_nest= NULL; used_tables_cache= not_null_tables_cache= 0; const_item_cache=1; @@ -233,7 +231,6 @@ Item_func::fix_fields(THD *thd, Item **ref) if (thd->is_error()) // An error inside fix_length_and_dec occured return TRUE; fixed= 1; - thd->thd_marker.emb_on_expr_nest= save_emb_on_expr_nest; return FALSE; } @@ -1752,8 +1749,13 @@ longlong Item_func_int_div::val_int() return 0; } + my_decimal truncated; + const bool do_truncate= true; + if (my_decimal_round(E_DEC_FATAL_ERROR, &tmp, 0, do_truncate, &truncated)) + DBUG_ASSERT(false); + longlong res; - if (my_decimal2int(E_DEC_FATAL_ERROR, &tmp, unsigned_flag, &res) & + if (my_decimal2int(E_DEC_FATAL_ERROR, &truncated, unsigned_flag, &res) & E_DEC_OVERFLOW) raise_integer_overflow(); return res; @@ -5152,8 +5154,9 @@ longlong Item_func_get_user_var::val_int() */ -int get_var_with_binlog(THD *thd, enum_sql_command sql_command, - LEX_STRING &name, user_var_entry **out_entry) +static int +get_var_with_binlog(THD *thd, enum_sql_command sql_command, + LEX_STRING &name, user_var_entry **out_entry) { BINLOG_USER_VAR_EVENT *user_var_event; user_var_entry *var_entry; @@ -5283,7 +5286,7 @@ void Item_func_get_user_var::fix_length_and_dec() 'var_entry' is NULL only if there occured an error during the call to get_var_with_binlog. */ - if (var_entry) + if (!error && var_entry) { m_cached_result_type= var_entry->type; unsigned_flag= var_entry->unsigned_flag; @@ -5488,16 +5491,15 @@ void Item_func_get_system_var::fix_length_and_dec() switch (var->show_type()) { - case SHOW_LONG: - case SHOW_INT: case SHOW_HA_ROWS: + case SHOW_UINT: + case SHOW_ULONG: + case SHOW_ULONGLONG: unsigned_flag= TRUE; - collation.set_numeric(); - fix_char_length(MY_INT64_NUM_DECIMAL_DIGITS); - decimals=0; - break; - case SHOW_LONGLONG: - unsigned_flag= TRUE; + /* fall through */ + case SHOW_SINT: + case SHOW_SLONG: + case SHOW_SLONGLONG: collation.set_numeric(); fix_char_length(MY_INT64_NUM_DECIMAL_DIGITS); decimals=0; @@ -5532,13 +5534,11 @@ void Item_func_get_system_var::fix_length_and_dec() break; case SHOW_BOOL: case SHOW_MY_BOOL: - unsigned_flag= FALSE; collation.set_numeric(); fix_char_length(1); decimals=0; break; case SHOW_DOUBLE: - unsigned_flag= FALSE; decimals= 6; collation.set_numeric(); fix_char_length(DBL_DIG + 6); @@ -5562,9 +5562,12 @@ enum Item_result Item_func_get_system_var::result_type() const { case SHOW_BOOL: case SHOW_MY_BOOL: - case SHOW_INT: - case SHOW_LONG: - case SHOW_LONGLONG: + case SHOW_SINT: + case SHOW_SLONG: + case SHOW_SLONGLONG: + case SHOW_UINT: + case SHOW_ULONG: + case SHOW_ULONGLONG: case SHOW_HA_ROWS: return INT_RESULT; case SHOW_CHAR: @@ -5586,9 +5589,12 @@ enum_field_types Item_func_get_system_var::field_type() const { case SHOW_BOOL: case SHOW_MY_BOOL: - case SHOW_INT: - case SHOW_LONG: - case SHOW_LONGLONG: + case SHOW_SINT: + case SHOW_SLONG: + case SHOW_SLONGLONG: + case SHOW_UINT: + case SHOW_ULONG: + case SHOW_ULONGLONG: case SHOW_HA_ROWS: return MYSQL_TYPE_LONGLONG; case SHOW_CHAR: @@ -5657,9 +5663,12 @@ longlong Item_func_get_system_var::val_int() switch (var->show_type()) { - case SHOW_INT: get_sys_var_safe (uint); - case SHOW_LONG: get_sys_var_safe (ulong); - case SHOW_LONGLONG: get_sys_var_safe (ulonglong); + case SHOW_SINT: get_sys_var_safe (int); + case SHOW_SLONG: get_sys_var_safe (long); + case SHOW_SLONGLONG:get_sys_var_safe (longlong); + case SHOW_UINT: get_sys_var_safe (uint); + case SHOW_ULONG: get_sys_var_safe (ulong); + case SHOW_ULONGLONG:get_sys_var_safe (ulonglong); case SHOW_HA_ROWS: get_sys_var_safe (ha_rows); case SHOW_BOOL: get_sys_var_safe (bool); case SHOW_MY_BOOL: get_sys_var_safe (my_bool); @@ -5760,9 +5769,12 @@ String* Item_func_get_system_var::val_str(String* str) break; } - case SHOW_INT: - case SHOW_LONG: - case SHOW_LONGLONG: + case SHOW_SINT: + case SHOW_SLONG: + case SHOW_SLONGLONG: + case SHOW_UINT: + case SHOW_ULONG: + case SHOW_ULONGLONG: case SHOW_HA_ROWS: case SHOW_BOOL: case SHOW_MY_BOOL: @@ -5852,9 +5864,12 @@ double Item_func_get_system_var::val_real() cache_present|= GET_SYS_VAR_CACHE_DOUBLE; return cached_dval; } - case SHOW_INT: - case SHOW_LONG: - case SHOW_LONGLONG: + case SHOW_SINT: + case SHOW_SLONG: + case SHOW_SLONGLONG: + case SHOW_UINT: + case SHOW_ULONG: + case SHOW_ULONGLONG: case SHOW_HA_ROWS: case SHOW_BOOL: case SHOW_MY_BOOL: diff --git a/sql/item_geofunc.cc b/sql/item_geofunc.cc index d734b55a970..621ddcb1a30 100644 --- a/sql/item_geofunc.cc +++ b/sql/item_geofunc.cc @@ -1,4 +1,4 @@ -/* Copyright (C) 2003-2006 MySQL AB +/* Copyright (c) 2003, 2010, Oracle and/or its affiliates. All rights reserved. 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 @@ -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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ /** diff --git a/sql/item_row.cc b/sql/item_row.cc index eb446768423..ccd7a37e9b7 100644 --- a/sql/item_row.cc +++ b/sql/item_row.cc @@ -1,4 +1,4 @@ -/* Copyright (C) 2000 MySQL AB +/* Copyright (c) 2002, 2011, Oracle and/or its affiliates. All rights reserved. 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 @@ -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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ #include "sql_priv.h" /* @@ -156,11 +156,13 @@ void Item_row::fix_after_pullout(st_select_lex *new_parent, Item **ref) { used_tables_cache= 0; const_item_cache= 1; + not_null_tables_cache= 0; for (uint i= 0; i < arg_count; i++) { items[i]->fix_after_pullout(new_parent, &items[i]); used_tables_cache|= items[i]->used_tables(); const_item_cache&= items[i]->const_item(); + not_null_tables_cache|= items[i]->not_null_tables(); } } diff --git a/sql/item_row.h b/sql/item_row.h index 2141213b194..1d34ecfc310 100644 --- a/sql/item_row.h +++ b/sql/item_row.h @@ -1,7 +1,7 @@ #ifndef ITEM_ROW_INCLUDED #define ITEM_ROW_INCLUDED -/* Copyright (C) 2000 MySQL AB +/* Copyright (c) 2002, 2010, Oracle and/or its affiliates. All rights reserved. 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 @@ -14,7 +14,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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ class Item_row: public Item { diff --git a/sql/item_strfunc.cc b/sql/item_strfunc.cc index 27b4a46ce34..f570c309d79 100644 --- a/sql/item_strfunc.cc +++ b/sql/item_strfunc.cc @@ -1,4 +1,5 @@ -/* Copyright (c) 2000, 2011, Oracle and/or its affiliates. All rights reserved. +/* + Copyright (c) 2000, 2011, Oracle and/or its affiliates. All rights reserved. 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 @@ -11,7 +12,8 @@ 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 02110-1301 USA */ + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +*/ /** @file @@ -2317,7 +2319,7 @@ String *Item_func_format::val_str_ascii(String *str) return 0; /* purecov: inspected */ nr= my_double_round(nr, (longlong) dec, FALSE, FALSE); str->set_real(nr, dec, &my_charset_numeric); - if (isnan(nr)) + if (isnan(nr) || my_isinf(nr)) return str; str_length=str->length(); } @@ -2373,6 +2375,7 @@ String *Item_func_format::val_str_ascii(String *str) For short values without thousands (<1000) replace decimal point to localized value. */ + DBUG_ASSERT(dec_length <= str_length); ((char*) str->ptr())[str_length - dec_length]= lc->decimal_point; } return str; @@ -3844,40 +3847,40 @@ void Item_func_dyncol_create::prepare_arguments() DBUG_ASSERT(args[valpos]->field_type() == MYSQL_TYPE_NULL); break; case DYN_COL_INT: - vals[i].long_value= args[valpos]->val_int(); + vals[i].x.long_value= args[valpos]->val_int(); break; case DYN_COL_UINT: - vals[i].ulong_value= args[valpos]->val_int(); + vals[i].x.ulong_value= args[valpos]->val_int(); break; case DYN_COL_DOUBLE: - vals[i].double_value= args[valpos]->val_real(); + vals[i].x.double_value= args[valpos]->val_real(); break; case DYN_COL_STRING: res= args[valpos]->val_str(&tmp); if (res && - (vals[i].string_value.str= my_strndup(res->ptr(), res->length(), + (vals[i].x.string.value.str= my_strndup(res->ptr(), res->length(), MYF(MY_WME)))) { - vals[i].string_value.length= res->length(); - vals[i].charset= res->charset(); + vals[i].x.string.value.length= res->length(); + vals[i].x.string.charset= res->charset(); } else { args[valpos]->null_value= 1; // In case of out of memory - vals[i].string_value.str= NULL; - vals[i].string_value.length= 0; // just to be safe + vals[i].x.string.value.str= NULL; + vals[i].x.string.value.length= 0; // just to be safe } break; case DYN_COL_DECIMAL: if ((dres= args[valpos]->val_decimal(&dtmp))) { dynamic_column_prepare_decimal(&vals[i]); - DBUG_ASSERT(vals[i].decimal_value.len == dres->len); - vals[i].decimal_value.intg= dres->intg; - vals[i].decimal_value.frac= dres->frac; - vals[i].decimal_value.sign= dres->sign(); - memcpy(vals[i].decimal_buffer, dres->buf, - sizeof(vals[i].decimal_buffer)); + DBUG_ASSERT(vals[i].x.decimal.value.len == dres->len); + vals[i].x.decimal.value.intg= dres->intg; + vals[i].x.decimal.value.frac= dres->frac; + vals[i].x.decimal.value.sign= dres->sign(); + memcpy(vals[i].x.decimal.buffer, dres->buf, + sizeof(vals[i].x.decimal.buffer)); } else { @@ -3886,13 +3889,13 @@ void Item_func_dyncol_create::prepare_arguments() } break; case DYN_COL_DATETIME: - args[valpos]->get_date(&vals[i].time_value, TIME_FUZZY_DATE); + args[valpos]->get_date(&vals[i].x.time_value, TIME_FUZZY_DATE); break; case DYN_COL_DATE: - args[valpos]->get_date(&vals[i].time_value, TIME_FUZZY_DATE); + args[valpos]->get_date(&vals[i].x.time_value, TIME_FUZZY_DATE); break; case DYN_COL_TIME: - args[valpos]->get_time(&vals[i].time_value); + args[valpos]->get_time(&vals[i].x.time_value); break; default: DBUG_ASSERT(0); @@ -3901,7 +3904,7 @@ void Item_func_dyncol_create::prepare_arguments() if (vals[i].type != DYN_COL_NULL && args[valpos]->null_value) { if (vals[i].type == DYN_COL_STRING) - my_free(vals[i].string_value.str); + my_free(vals[i].x.string.value.str); vals[i].type= DYN_COL_NULL; } } @@ -3915,7 +3918,7 @@ void Item_func_dyncol_create::cleanup_arguments() for (i= 0; i < column_count; i++) { if (vals[i].type == DYN_COL_STRING) - my_free(vals[i].string_value.str); + my_free(vals[i].x.string.value.str); } } @@ -4132,19 +4135,19 @@ String *Item_dyncol_get::val_str(String *str_result) goto null; case DYN_COL_INT: case DYN_COL_UINT: - str_result->set_int(val.long_value, test(val.type == DYN_COL_UINT), + str_result->set_int(val.x.long_value, test(val.type == DYN_COL_UINT), &my_charset_latin1); break; case DYN_COL_DOUBLE: - str_result->set_real(val.double_value, NOT_FIXED_DEC, &my_charset_latin1); + str_result->set_real(val.x.double_value, NOT_FIXED_DEC, &my_charset_latin1); break; case DYN_COL_STRING: - if ((char*) tmp.ptr() <= val.string_value.str && - (char*) tmp.ptr() + tmp.length() >= val.string_value.str) + if ((char*) tmp.ptr() <= val.x.string.value.str && + (char*) tmp.ptr() + tmp.length() >= val.x.string.value.str) { /* value is allocated in tmp buffer; We have to make a copy */ - str_result->copy(val.string_value.str, val.string_value.length, - val.charset); + str_result->copy(val.x.string.value.str, val.x.string.value.length, + val.x.string.charset); } else { @@ -4153,24 +4156,24 @@ String *Item_dyncol_get::val_str(String *str_result) into a field or in a buffer for another item and this buffer is not going to be deleted during expression evaluation */ - str_result->set(val.string_value.str, val.string_value.length, - val.charset); + str_result->set(val.x.string.value.str, val.x.string.value.length, + val.x.string.charset); } break; case DYN_COL_DECIMAL: { int res; int length= - my_decimal_string_length((const my_decimal*)&val.decimal_value); + my_decimal_string_length((const my_decimal*)&val.x.decimal.value); if (str_result->alloc(length)) goto null; - if ((res= decimal2string(&val.decimal_value, (char*) str_result->ptr(), + if ((res= decimal2string(&val.x.decimal.value, (char*) str_result->ptr(), &length, 0, 0, ' ')) != E_DEC_OK) { char buff[40]; int len= sizeof(buff); DBUG_ASSERT(length < (int)sizeof(buff)); - decimal2string(&val.decimal_value, buff, &len, 0, 0, ' '); + decimal2string(&val.x.decimal.value, buff, &len, 0, 0, ' '); decimal_operation_results(res, buff, "CHAR"); } str_result->set_charset(&my_charset_latin1); @@ -4188,7 +4191,7 @@ String *Item_dyncol_get::val_str(String *str_result) asked to return the time argument as a string. */ if (str_result->alloc(MAX_DATE_STRING_REP_LENGTH) || - !(length= my_TIME_to_str(&val.time_value, (char*) str_result->ptr(), + !(length= my_TIME_to_str(&val.x.time_value, (char*) str_result->ptr(), AUTO_SEC_PART_DIGITS))) goto null; str_result->set_charset(&my_charset_latin1); @@ -4218,20 +4221,20 @@ longlong Item_dyncol_get::val_int() goto null; case DYN_COL_UINT: unsigned_flag= 1; // Make it possible for caller to detect sign - return val.long_value; + return val.x.long_value; case DYN_COL_INT: unsigned_flag= 0; // Make it possible for caller to detect sign - return val.long_value; + return val.x.long_value; case DYN_COL_DOUBLE: { bool error; longlong num; - num= double_to_longlong(val.double_value, unsigned_flag, &error); + num= double_to_longlong(val.x.double_value, unsigned_flag, &error); if (error) { char buff[30]; - sprintf(buff, "%lg", val.double_value); + sprintf(buff, "%lg", val.x.double_value); push_warning_printf(current_thd, MYSQL_ERROR::WARN_LEVEL_WARN, ER_DATA_OVERFLOW, ER(ER_DATA_OVERFLOW), @@ -4244,14 +4247,14 @@ longlong Item_dyncol_get::val_int() { int error; longlong num; - char *end= val.string_value.str + val.string_value.length, *org_end= end; + char *end= val.x.string.value.str + val.x.string.value.length, *org_end= end; - num= my_strtoll10(val.string_value.str, &end, &error); + num= my_strtoll10(val.x.string.value.str, &end, &error); if (end != org_end || error > 0) { char buff[80]; - strmake(buff, val.string_value.str, min(sizeof(buff)-1, - val.string_value.length)); + strmake(buff, val.x.string.value.str, min(sizeof(buff)-1, + val.x.string.value.length)); push_warning_printf(current_thd, MYSQL_ERROR::WARN_LEVEL_WARN, ER_BAD_DATA, ER(ER_BAD_DATA), @@ -4264,18 +4267,18 @@ longlong Item_dyncol_get::val_int() case DYN_COL_DECIMAL: { longlong num; - my_decimal2int(E_DEC_FATAL_ERROR, &val.decimal_value, unsigned_flag, + my_decimal2int(E_DEC_FATAL_ERROR, &val.x.decimal.value, unsigned_flag, &num); return num; } case DYN_COL_DATETIME: case DYN_COL_DATE: case DYN_COL_TIME: - unsigned_flag= !val.time_value.neg; + unsigned_flag= !val.x.time_value.neg; if (unsigned_flag) - return TIME_to_ulonglong(&val.time_value); + return TIME_to_ulonglong(&val.x.time_value); else - return -(longlong)TIME_to_ulonglong(&val.time_value); + return -(longlong)TIME_to_ulonglong(&val.x.time_value); } null: @@ -4297,24 +4300,24 @@ double Item_dyncol_get::val_real() case DYN_COL_NULL: goto null; case DYN_COL_UINT: - return ulonglong2double(val.ulong_value); + return ulonglong2double(val.x.ulong_value); case DYN_COL_INT: - return (double) val.long_value; + return (double) val.x.long_value; case DYN_COL_DOUBLE: - return (double) val.double_value; + return (double) val.x.double_value; case DYN_COL_STRING: { int error; char *end; - double res= my_strntod(val.charset, (char*) val.string_value.str, - val.string_value.length, &end, &error); + double res= my_strntod(val.x.string.charset, (char*) val.x.string.value.str, + val.x.string.value.length, &end, &error); - if (end != (char*) val.string_value.str + val.string_value.length || + if (end != (char*) val.x.string.value.str + val.x.string.value.length || error) { char buff[80]; - strmake(buff, val.string_value.str, min(sizeof(buff)-1, - val.string_value.length)); + strmake(buff, val.x.string.value.str, min(sizeof(buff)-1, + val.x.string.value.length)); push_warning_printf(current_thd, MYSQL_ERROR::WARN_LEVEL_WARN, ER_BAD_DATA, ER(ER_BAD_DATA), @@ -4326,13 +4329,13 @@ double Item_dyncol_get::val_real() { double res; /* This will always succeed */ - decimal2double(&val.decimal_value, &res); + decimal2double(&val.x.decimal.value, &res); return res; } case DYN_COL_DATETIME: case DYN_COL_DATE: case DYN_COL_TIME: - return TIME_to_double(&val.time_value); + return TIME_to_double(&val.x.time_value); } null: @@ -4354,22 +4357,22 @@ my_decimal *Item_dyncol_get::val_decimal(my_decimal *decimal_value) case DYN_COL_NULL: goto null; case DYN_COL_UINT: - int2my_decimal(E_DEC_FATAL_ERROR, val.long_value, TRUE, decimal_value); + int2my_decimal(E_DEC_FATAL_ERROR, val.x.long_value, TRUE, decimal_value); break; case DYN_COL_INT: - int2my_decimal(E_DEC_FATAL_ERROR, val.long_value, FALSE, decimal_value); + int2my_decimal(E_DEC_FATAL_ERROR, val.x.long_value, FALSE, decimal_value); break; case DYN_COL_DOUBLE: - double2my_decimal(E_DEC_FATAL_ERROR, val.double_value, decimal_value); + double2my_decimal(E_DEC_FATAL_ERROR, val.x.double_value, decimal_value); break; case DYN_COL_STRING: { int rc; - rc= str2my_decimal(0, val.string_value.str, val.string_value.length, - val.charset, decimal_value); + rc= str2my_decimal(0, val.x.string.value.str, val.x.string.value.length, + val.x.string.charset, decimal_value); char buff[80]; - strmake(buff, val.string_value.str, min(sizeof(buff)-1, - val.string_value.length)); + strmake(buff, val.x.string.value.str, min(sizeof(buff)-1, + val.x.string.value.length)); if (rc != E_DEC_OK) { push_warning_printf(current_thd, MYSQL_ERROR::WARN_LEVEL_WARN, @@ -4380,14 +4383,14 @@ my_decimal *Item_dyncol_get::val_decimal(my_decimal *decimal_value) break; } case DYN_COL_DECIMAL: - decimal2my_decimal(&val.decimal_value, decimal_value); + decimal2my_decimal(&val.x.decimal.value, decimal_value); break; case DYN_COL_DATETIME: case DYN_COL_DATE: case DYN_COL_TIME: - decimal_value= seconds2my_decimal(val.time_value.neg, - TIME_to_ulonglong(&val.time_value), - val.time_value.second_part, + decimal_value= seconds2my_decimal(val.x.time_value.neg, + TIME_to_ulonglong(&val.x.time_value), + val.x.time_value.second_part, decimal_value); break; } @@ -4416,37 +4419,37 @@ bool Item_dyncol_get::get_date(MYSQL_TIME *ltime, ulonglong fuzzy_date) signed_value= 1; // For error message /* fall_trough */ case DYN_COL_UINT: - if (signed_value || val.ulong_value <= LONGLONG_MAX) + if (signed_value || val.x.ulong_value <= LONGLONG_MAX) { - if (int_to_datetime_with_warn(val.ulong_value, ltime, fuzzy_date, + if (int_to_datetime_with_warn(val.x.ulong_value, ltime, fuzzy_date, 0 /* TODO */)) goto null; return 0; } /* let double_to_datetime_with_warn() issue the warning message */ - val.double_value= static_cast<double>(ULONGLONG_MAX); + val.x.double_value= static_cast<double>(ULONGLONG_MAX); /* fall_trough */ case DYN_COL_DOUBLE: - if (double_to_datetime_with_warn(val.double_value, ltime, fuzzy_date, + if (double_to_datetime_with_warn(val.x.double_value, ltime, fuzzy_date, 0 /* TODO */)) goto null; return 0; case DYN_COL_DECIMAL: - if (decimal_to_datetime_with_warn((my_decimal*)&val.decimal_value, ltime, + if (decimal_to_datetime_with_warn((my_decimal*)&val.x.decimal.value, ltime, fuzzy_date, 0 /* TODO */)) goto null; return 0; case DYN_COL_STRING: if (str_to_datetime_with_warn(&my_charset_numeric, - val.string_value.str, - val.string_value.length, + val.x.string.value.str, + val.x.string.value.length, ltime, fuzzy_date) <= MYSQL_TIMESTAMP_ERROR) goto null; return 0; case DYN_COL_DATETIME: case DYN_COL_DATE: case DYN_COL_TIME: - *ltime= val.time_value; + *ltime= val.x.time_value; return 0; } diff --git a/sql/item_subselect.cc b/sql/item_subselect.cc index 554052640da..f25722ab30b 100644 --- a/sql/item_subselect.cc +++ b/sql/item_subselect.cc @@ -1,4 +1,5 @@ -/* Copyright (c) 2002, 2010, Oracle and/or its affiliates. +/* Copyright (c) 2002, 2011, Oracle and/or its affiliates. + Copyright (c) 2010, 2011, Monty Program Ab 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 @@ -11,7 +12,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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ /** @file @@ -38,6 +39,7 @@ #include "set_var.h" #include "sql_select.h" #include "sql_parse.h" // check_stack_overrun +#include "sql_test.h" double get_post_group_estimate(JOIN* join, double join_op_rows); @@ -166,9 +168,11 @@ void Item_in_subselect::cleanup() delete left_expr_cache; left_expr_cache= NULL; } + /* + TODO: This breaks the commented assert in add_strategy(). + in_strategy&= ~SUBS_STRATEGY_CHOSEN; + */ first_execution= TRUE; - if (in_strategy & SUBS_MATERIALIZATION) - in_strategy= 0; pushed_cond_guards= NULL; Item_subselect::cleanup(); DBUG_VOID_RETURN; @@ -184,10 +188,9 @@ void Item_allany_subselect::cleanup() */ for (SELECT_LEX *sl= unit->first_select(); sl; sl= sl->next_select()) - if (in_strategy & SUBS_MAXMIN_INJECTED) + if (test_strategy(SUBS_MAXMIN_INJECTED)) sl->with_sum_func= false; Item_in_subselect::cleanup(); - } @@ -237,7 +240,7 @@ bool Item_subselect::fix_fields(THD *thd_param, Item **ref) if (check_stack_overrun(thd, STACK_MIN_SIZE, (uchar*)&res)) return TRUE; - + if (!(res= engine->prepare())) { // all transformation is done (used by prepared statements) @@ -500,6 +503,7 @@ void Item_subselect::recalc_used_tables(st_select_lex *new_parent, upper->item->walk(&Item::enumerate_field_refs_processor, FALSE, (uchar*)&fixer); used_tables_cache |= fixer.used_tables; + upper->item->walk(&Item::update_table_bitmaps_processor, FALSE, NULL); /* if (after_pullout) upper->item->fix_after_pullout(new_parent, &(upper->item)); @@ -522,6 +526,20 @@ void Item_subselect::recalc_used_tables(st_select_lex *new_parent, bool Item_subselect::walk(Item_processor processor, bool walk_subquery, uchar *argument) { + if (!(unit->uncacheable & ~UNCACHEABLE_DEPENDENT) && engine->is_executed() && + !unit->describe) + { + /* + The subquery has already been executed (for real, it wasn't EXPLAIN's + fake execution) so it should not matter what it has inside. + + The actual reason for not walking inside is that parts of the subquery + (e.g. JTBM join nests and their IN-equality conditions may have been + invalidated by irreversible cleanups (those happen after an uncorrelated + subquery has been executed). + */ + return (this->*processor)(argument); + } if (walk_subquery) { @@ -594,7 +612,9 @@ bool Item_subselect::exec() void Item_subselect::get_cache_parameters(List<Item> ¶meters) { - Collect_deps_prm prm= { unit->first_select()->nest_level, ¶meters }; + Collect_deps_prm prm= {¶meters, + unit->first_select()->nest_level_base, + unit->first_select()->nest_level}; walk(&Item::collect_outer_ref_processor, TRUE, (uchar*)&prm); } @@ -715,7 +735,7 @@ bool Item_in_subselect::exec() - on a cost-based basis, that takes into account the cost of a cache lookup, the cache hit rate, and the savings per cache hit. */ - if (!left_expr_cache && (in_strategy & SUBS_MATERIALIZATION)) + if (!left_expr_cache && (test_strategy(SUBS_MATERIALIZATION))) init_left_expr_cache(); /* @@ -832,7 +852,10 @@ Item_maxmin_subselect::Item_maxmin_subselect(THD *thd_param, { DBUG_ENTER("Item_maxmin_subselect::Item_maxmin_subselect"); max= max_arg; - init(select_lex, new select_max_min_finder_subselect(this, max_arg)); + init(select_lex, + new select_max_min_finder_subselect(this, max_arg, + parent->substype() == + Item_subselect::ALL_SUBS)); max_columns= 1; maybe_null= 1; max_columns= 1; @@ -1175,8 +1198,9 @@ bool Item_in_subselect::test_limit(st_select_lex_unit *unit_arg) Item_in_subselect::Item_in_subselect(Item * left_exp, st_select_lex *select_lex): - Item_exists_subselect(), left_expr_cache(0), first_execution(TRUE), - optimizer(0), pushed_cond_guards(NULL), in_strategy(0), + Item_exists_subselect(), + left_expr_cache(0), first_execution(TRUE), in_strategy(SUBS_NOT_TRANSFORMED), + optimizer(0), pushed_cond_guards(NULL), emb_on_expr_nest(NULL), is_jtbm_merged(FALSE), is_flattenable_semijoin(FALSE), is_registered_semijoin(FALSE), upper_item(0) @@ -1597,7 +1621,7 @@ Item_in_subselect::single_value_transformer(JOIN *join) bool Item_allany_subselect::transform_into_max_min(JOIN *join) { DBUG_ENTER("Item_allany_subselect::transform_into_max_min"); - if (!(in_strategy & (SUBS_MAXMIN_INJECTED | SUBS_MAXMIN_ENGINE))) + if (!test_strategy(SUBS_MAXMIN_INJECTED | SUBS_MAXMIN_ENGINE)) DBUG_RETURN(false); Item **place= optimizer->arguments() + 1; THD *thd= join->thd; @@ -1608,11 +1632,20 @@ bool Item_allany_subselect::transform_into_max_min(JOIN *join) */ DBUG_ASSERT(!substitution); - if (!select_lex->group_list.elements && - !select_lex->having && - !select_lex->with_sum_func && - !(select_lex->next_select()) && - select_lex->table_list.elements) + /* + Check if optimization with aggregate min/max possible + 1 There is no aggregate in the subquery + 2 It is not UNION + 3 There is tables + 4 It is not ALL subquery with possible NULLs in the SELECT list + */ + if (!select_lex->group_list.elements && /*1*/ + !select_lex->having && /*1*/ + !select_lex->with_sum_func && /*1*/ + !(select_lex->next_select()) && /*2*/ + select_lex->table_list.elements && /*3*/ + (!select_lex->ref_pointer_array[0]->maybe_null || /*4*/ + substype() != Item_subselect::ALL_SUBS)) /*4*/ { Item_sum_hybrid *item; nesting_map save_allow_sum_func; @@ -1662,7 +1695,7 @@ bool Item_allany_subselect::transform_into_max_min(JOIN *join) Remove other strategies if any (we already changed the query and can't apply other strategy). */ - in_strategy= SUBS_MAXMIN_INJECTED; + set_strategy(SUBS_MAXMIN_INJECTED); } else { @@ -1674,13 +1707,13 @@ bool Item_allany_subselect::transform_into_max_min(JOIN *join) Remove other strategies if any (we already changed the query and can't apply other strategy). */ - in_strategy= SUBS_MAXMIN_ENGINE; + set_strategy(SUBS_MAXMIN_ENGINE); } /* The swap is needed for expressions of type 'f1 < ALL ( SELECT ....)' where we want to evaluate the sub query even if f1 would be null. */ - subs= func->create_swap(left_expr, subs); + subs= func->create_swap(*(optimizer->get_cache()), subs); thd->change_item_tree(place, subs); if (subs->fix_fields(thd, &subs)) DBUG_RETURN(true); @@ -2261,7 +2294,12 @@ bool Item_in_subselect::inject_in_to_exists_cond(JOIN *join_arg) { /* The argument list of the top-level AND may change after fix fields. */ and_args= ((Item_cond*) join_arg->conds)->argument_list(); - and_args->concat((List<Item> *) &join_arg->cond_equal->current_level); + List_iterator<Item_equal> li(join_arg->cond_equal->current_level); + Item_equal *elem; + while ((elem= li++)) + { + and_args->push_back(elem); + } } } @@ -2389,7 +2427,7 @@ err: void Item_in_subselect::print(String *str, enum_query_type query_type) { - if (in_strategy & SUBS_IN_TO_EXISTS) + if (test_strategy(SUBS_IN_TO_EXISTS)) str->append(STRING_WITH_LEN("<exists>")); else { @@ -2405,7 +2443,7 @@ bool Item_in_subselect::fix_fields(THD *thd_arg, Item **ref) uint outer_cols_num; List<Item> *inner_cols; - if (in_strategy & SUBS_SEMI_JOIN) + if (test_strategy(SUBS_SEMI_JOIN)) return !( (*ref)= new Item_int(1)); /* @@ -2459,7 +2497,6 @@ bool Item_in_subselect::fix_fields(THD *thd_arg, Item **ref) return TRUE; if (Item_subselect::fix_fields(thd_arg, ref)) return TRUE; - fixed= TRUE; return FALSE; } @@ -2469,6 +2506,7 @@ void Item_in_subselect::fix_after_pullout(st_select_lex *new_parent, Item **ref) { left_expr->fix_after_pullout(new_parent, &left_expr); Item_subselect::fix_after_pullout(new_parent, ref); + used_tables_cache |= left_expr->used_tables(); } void Item_in_subselect::update_used_tables() @@ -2581,8 +2619,7 @@ Item_allany_subselect::select_transformer(JOIN *join) { DBUG_ENTER("Item_allany_subselect::select_transformer"); DBUG_ASSERT((in_strategy & ~(SUBS_MAXMIN_INJECTED | SUBS_MAXMIN_ENGINE | - SUBS_IN_TO_EXISTS)) == 0); - in_strategy|= SUBS_IN_TO_EXISTS; + SUBS_IN_TO_EXISTS | SUBS_STRATEGY_CHOSEN)) == 0); if (upper_item) upper_item->show= 1; DBUG_RETURN(select_in_like_transformer(join)); @@ -2591,7 +2628,7 @@ Item_allany_subselect::select_transformer(JOIN *join) void Item_allany_subselect::print(String *str, enum_query_type query_type) { - if (in_strategy & SUBS_IN_TO_EXISTS) + if (test_strategy(SUBS_IN_TO_EXISTS)) str->append(STRING_WITH_LEN("<exists>")); else { @@ -2617,7 +2654,8 @@ subselect_single_select_engine(THD *thd_arg, st_select_lex *select, select_result_interceptor *result_arg, Item_subselect *item_arg) :subselect_engine(thd_arg, item_arg, result_arg), - prepared(0), executed(0), select_lex(select), join(0) + prepared(0), executed(0), optimize_error(0), + select_lex(select), join(0) { select_lex->master_unit()->item= item_arg; } @@ -2630,7 +2668,7 @@ int subselect_single_select_engine::get_identifier() void subselect_single_select_engine::cleanup() { DBUG_ENTER("subselect_single_select_engine::cleanup"); - prepared= executed= 0; + prepared= executed= optimize_error= 0; join= 0; result->cleanup(); select_lex->uncacheable&= ~UNCACHEABLE_DEPENDENT_INJECTED; @@ -2861,6 +2899,10 @@ int join_read_next_same_or_null(READ_RECORD *info); int subselect_single_select_engine::exec() { DBUG_ENTER("subselect_single_select_engine::exec"); + + if (optimize_error) + DBUG_RETURN(1); + char const *save_where= thd->where; SELECT_LEX *save_select= thd->lex->current_select; thd->lex->current_select= select_lex; @@ -2872,7 +2914,7 @@ int subselect_single_select_engine::exec() if (join->optimize()) { thd->where= save_where; - executed= 1; + optimize_error= 1; thd->lex->current_select= save_select; DBUG_RETURN(join->error ? join->error : 1); } @@ -2972,7 +3014,7 @@ int subselect_single_select_engine::exec() executed= 1; thd->where= save_where; thd->lex->current_select= save_select; - DBUG_RETURN(join->error||thd->is_fatal_error); + DBUG_RETURN(join->error || thd->is_fatal_error || thd->is_error()); } thd->where= save_where; thd->lex->current_select= save_select; @@ -3910,6 +3952,8 @@ subselect_hash_sj_engine::get_strategy_using_data() } if (result_sink->get_null_count_of_col(i) == tmp_table->file->stats.records) ++count_null_only_columns; + if (result_sink->get_null_count_of_col(i)) + ++count_columns_with_nulls; } /* If no column contains NULLs use regular hash index lookups. */ @@ -4388,7 +4432,13 @@ double get_fanout_with_deps(JOIN *join, table_map tset) for (JOIN_TAB *tab= first_top_level_tab(join, WITHOUT_CONST_TABLES); tab; tab= next_top_level_tab(join, tab)) { - if ((tab->table->map & checked_deps) && !tab->emb_sj_nest && + /* + Ignore SJM nests. They have tab->table==NULL. There is no point to walk + inside them, because GROUP BY clause cannot refer to tables from within + subquery. + */ + if (!tab->is_sjm_nest() && (tab->table->map & checked_deps) && + !tab->emb_sj_nest && tab->records_read != 0) { fanout *= rows2double(tab->records_read); @@ -4578,7 +4628,8 @@ int subselect_hash_sj_engine::exec() /* The subquery should be optimized, and materialized only once. */ DBUG_ASSERT(materialize_join->optimized && !is_materialized); materialize_join->exec(); - if ((res= test(materialize_join->error || thd->is_fatal_error))) + if ((res= test(materialize_join->error || thd->is_fatal_error || + thd->is_error()))) goto err; /* @@ -4674,6 +4725,7 @@ int subselect_hash_sj_engine::exec() count_pm_keys, has_covering_null_row, has_covering_null_columns, + count_columns_with_nulls, item, result, semi_join_conds->argument_list()); if (!pm_engine || @@ -4699,7 +4751,8 @@ int subselect_hash_sj_engine::exec() item, result, semi_join_conds->argument_list(), has_covering_null_row, - has_covering_null_columns))) + has_covering_null_columns, + count_columns_with_nulls))) { /* This is an irrecoverable error. */ res= 1; @@ -4818,14 +4871,14 @@ bool Ordered_key::init(MY_BITMAP *columns_to_index) Item_func_lt *fn_less_than; key_column_count= bitmap_bits_set(columns_to_index); - - // TIMOUR: check for mem allocation err, revert to scan - key_columns= (Item_field**) thd->alloc(key_column_count * sizeof(Item_field*)); compare_pred= (Item_func_lt**) thd->alloc(key_column_count * sizeof(Item_func_lt*)); + if (!key_columns || !compare_pred) + return TRUE; /* Revert to table scan partial match. */ + for (uint i= 0; i < columns_to_index->n_bits; i++) { if (!bitmap_is_set(columns_to_index, i)) @@ -5136,43 +5189,48 @@ subselect_partial_match_engine::subselect_partial_match_engine( select_result_interceptor *result_arg, List<Item> *equi_join_conds_arg, bool has_covering_null_row_arg, - bool has_covering_null_columns_arg) + bool has_covering_null_columns_arg, + uint count_columns_with_nulls_arg) :subselect_engine(thd_arg, item_arg, result_arg), tmp_table(tmp_table_arg), lookup_engine(engine_arg), equi_join_conds(equi_join_conds_arg), has_covering_null_row(has_covering_null_row_arg), - has_covering_null_columns(has_covering_null_columns_arg) + has_covering_null_columns(has_covering_null_columns_arg), + count_columns_with_nulls(count_columns_with_nulls_arg) {} int subselect_partial_match_engine::exec() { Item_in_subselect *item_in= (Item_in_subselect *) item; - int res; + int copy_res, lookup_res; /* Try to find a matching row by index lookup. */ - res= lookup_engine->copy_ref_key_simple(); - if (res == -1) + copy_res= lookup_engine->copy_ref_key_simple(); + if (copy_res == -1) { /* The result is FALSE based on the outer reference. */ item_in->value= 0; item_in->null_value= 0; return 0; } - else if (res == 0) + else if (copy_res == 0) { /* Search for a complete match. */ - if ((res= lookup_engine->index_lookup())) + if ((lookup_res= lookup_engine->index_lookup())) { /* An error occured during lookup(). */ item_in->value= 0; item_in->null_value= 0; - return res; + return lookup_res; } - else if (item_in->value) + else if (item_in->value || !count_columns_with_nulls) { /* A complete match was found, the result of IN is TRUE. + If no match was found, and there are no NULLs in the materialized + subquery, then the result is guaranteed to be false because this + branch is executed when the outer reference has no NULLs as well. Notice: (this->item == lookup_engine->item) */ return 0; @@ -5280,10 +5338,13 @@ subselect_rowid_merge_engine::init(MY_BITMAP *non_null_key_parts, merge_keys_count == 1 && non_null_key_parts)); /* Allocate buffers to hold the merged keys and the mapping between rowids and - row numbers. + row numbers. All small buffers are allocated in the runtime memroot. Big + buffers are allocated from the OS via malloc. */ if (!(merge_keys= (Ordered_key**) thd->alloc(merge_keys_count * sizeof(Ordered_key*))) || + !(null_bitmaps= (MY_BITMAP**) thd->alloc(merge_keys_count * + sizeof(MY_BITMAP*))) || !(row_num_to_rowid= (uchar*) my_malloc((size_t)(row_count * rowid_length), MYF(MY_WME)))) return TRUE; @@ -5501,6 +5562,56 @@ bool subselect_rowid_merge_engine::test_null_row(rownum_t row_num) } +/** + Test if a subset of NULL-able columns contains a row of NULLs. +*/ + +bool subselect_rowid_merge_engine:: +exists_complementing_null_row(MY_BITMAP *keys_to_complement) +{ + rownum_t highest_min_row= 0; + rownum_t lowest_max_row= UINT_MAX; + uint count_null_keys, i, j; + Ordered_key *cur_key; + + count_null_keys= keys_to_complement->n_bits - + bitmap_bits_set(keys_to_complement); + if (count_null_keys == 1) + { + /* + The caller guarantees that the complement to keys_to_complement + contains only columns with NULLs. Therefore if there is only one column, + it is guaranteed to contain NULLs. + */ + return TRUE; + } + + for (i= (non_null_key ? 1 : 0), j= 0; i < merge_keys_count; i++) + { + cur_key= merge_keys[i]; + if (bitmap_is_set(keys_to_complement, cur_key->get_keyid())) + continue; + DBUG_ASSERT(cur_key->get_null_count()); + if (cur_key->get_min_null_row() > highest_min_row) + highest_min_row= cur_key->get_min_null_row(); + if (cur_key->get_max_null_row() < lowest_max_row) + lowest_max_row= cur_key->get_max_null_row(); + null_bitmaps[j++]= cur_key->get_null_key(); + } + DBUG_ASSERT(count_null_keys == j); + + if (lowest_max_row < highest_min_row) + { + /* The intersection of NULL rows is empty. */ + return FALSE; + } + + return bitmap_exists_intersection((const MY_BITMAP**) null_bitmaps, + count_null_keys, + highest_min_row, lowest_max_row); +} + + /* @retval TRUE there is a partial match (UNKNOWN) @retval FALSE there is no match at all (FALSE) @@ -5513,6 +5624,8 @@ bool subselect_rowid_merge_engine::partial_match() Ordered_key *cur_key; rownum_t cur_row_num; uint count_nulls_in_search_key= 0; + uint max_null_in_any_row= + ((select_materialize_with_stats *) result)->get_max_nulls_in_row(); bool res= FALSE; /* If there is a non-NULL key, it must be the first key in the keys array. */ @@ -5564,22 +5677,53 @@ bool subselect_rowid_merge_engine::partial_match() /* If the outer reference consists of only NULLs, or if it has NULLs in all - nullable columns, the result is UNKNOWN. + nullable columns (above we guarantee there is a match for the non-null + coumns), the result is UNKNOWN. */ - if (count_nulls_in_search_key == - ((Item_in_subselect *) item)->left_expr->cols() - - (non_null_key ? non_null_key->get_column_count() : 0)) + if (count_nulls_in_search_key == merge_keys_count - test(non_null_key)) { res= TRUE; goto end; } /* + If the outer row has NULLs in some columns, and + there is no match for any of the remaining columns, and + there is a subquery row with NULLs in all unmatched columns, + then there is a partial match, otherwise the result is FALSE. + */ + if (count_nulls_in_search_key && !pq.elements) + { + DBUG_ASSERT(!non_null_key); + /* + Check if the intersection of all NULL bitmaps of all keys that + are not in matching_outer_cols is non-empty. + */ + res= exists_complementing_null_row(&matching_outer_cols); + goto end; + } + + /* If there is no NULL (sub)row that covers all NULL columns, and there is no - single match for any of the NULL columns, the result is FALSE. + match for any of the NULL columns, the result is FALSE. Notice that if there + is a non-null key, and there is only one matching key, the non-null key is + the matching key. This is so, because this method returns FALSE if the + non-null key doesn't have a match. */ - if (pq.elements - test(non_null_key) == 0) + if (!count_nulls_in_search_key && + (!pq.elements || + (pq.elements == 1 && non_null_key && + max_null_in_any_row < merge_keys_count-1))) { + if (!pq.elements) + { + DBUG_ASSERT(!non_null_key); + /* + The case of a covering null row is handled by + subselect_partial_match_engine::exec() + */ + DBUG_ASSERT(max_null_in_any_row != tmp_table->s->fields); + } res= FALSE; goto end; } @@ -5623,6 +5767,7 @@ bool subselect_rowid_merge_engine::partial_match() { min_key= cur_key; min_row_num= cur_row_num; + bitmap_clear_all(&matching_keys); bitmap_set_bit(&matching_keys, min_key->get_keyid()); bitmap_union(&matching_keys, &matching_outer_cols); } @@ -5643,6 +5788,8 @@ bool subselect_rowid_merge_engine::partial_match() DBUG_ASSERT(FALSE); end: + if (!has_covering_null_columns) + bitmap_clear_all(&matching_keys); queue_remove_all(&pq); tmp_table->file->ha_rnd_end(); return res; @@ -5656,11 +5803,13 @@ subselect_table_scan_engine::subselect_table_scan_engine( select_result_interceptor *result_arg, List<Item> *equi_join_conds_arg, bool has_covering_null_row_arg, - bool has_covering_null_columns_arg) + bool has_covering_null_columns_arg, + uint count_columns_with_nulls_arg) :subselect_partial_match_engine(thd_arg, engine_arg, tmp_table_arg, item_arg, result_arg, equi_join_conds_arg, has_covering_null_row_arg, - has_covering_null_columns_arg) + has_covering_null_columns_arg, + count_columns_with_nulls_arg) {} diff --git a/sql/item_subselect.h b/sql/item_subselect.h index de3279aeeef..6007812fa7d 100644 --- a/sql/item_subselect.h +++ b/sql/item_subselect.h @@ -1,7 +1,7 @@ #ifndef ITEM_SUBSELECT_INCLUDED #define ITEM_SUBSELECT_INCLUDED -/* Copyright (C) 2000 MySQL AB +/* Copyright (c) 2002, 2011, Oracle and/or its affiliates. All rights reserved. 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 @@ -14,7 +14,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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ /* subselect Item */ @@ -240,6 +240,7 @@ public: const char *func_name() const { DBUG_ASSERT(0); return "subselect"; } virtual bool expr_cache_is_needed(THD *); virtual void get_cache_parameters(List<Item> ¶meters); + virtual bool is_subquery_processor (uchar *opt_arg) { return 1; } friend class select_result_interceptor; friend class Item_in_optimizer; @@ -367,17 +368,19 @@ TABLE_LIST * const NO_JOIN_NEST=(TABLE_LIST*)0x1; based on user-set optimizer switches, semantic analysis and cost comparison. */ #define SUBS_NOT_TRANSFORMED 0 /* No execution method was chosen for this IN. */ -#define SUBS_SEMI_JOIN 1 /* IN was converted to semi-join. */ -#define SUBS_IN_TO_EXISTS 2 /* IN was converted to correlated EXISTS. */ -#define SUBS_MATERIALIZATION 4 /* Execute IN via subquery materialization. */ +/* The Final decision about the strategy is made. */ +#define SUBS_STRATEGY_CHOSEN 1 +#define SUBS_SEMI_JOIN 2 /* IN was converted to semi-join. */ +#define SUBS_IN_TO_EXISTS 4 /* IN was converted to correlated EXISTS. */ +#define SUBS_MATERIALIZATION 8 /* Execute IN via subquery materialization. */ /* Partial matching substrategies of MATERIALIZATION. */ -#define SUBS_PARTIAL_MATCH_ROWID_MERGE 8 -#define SUBS_PARTIAL_MATCH_TABLE_SCAN 16 +#define SUBS_PARTIAL_MATCH_ROWID_MERGE 16 +#define SUBS_PARTIAL_MATCH_TABLE_SCAN 32 /* ALL/ANY will be transformed with max/min optimization */ /* The subquery has not aggregates, transform it into a MAX/MIN query. */ -#define SUBS_MAXMIN_INJECTED 32 +#define SUBS_MAXMIN_INJECTED 64 /* The subquery has aggregates, use a special max/min subselect engine. */ -#define SUBS_MAXMIN_ENGINE 64 +#define SUBS_MAXMIN_ENGINE 128 /** @@ -412,6 +415,8 @@ protected: Item *expr; bool was_null; bool abort_on_null; + /* A bitmap of possible execution strategies for an IN predicate. */ + uchar in_strategy; public: Item_in_optimizer *optimizer; protected: @@ -442,7 +447,6 @@ public: join nest pointer - the predicate is an AND-part of ON expression of a join nest NULL - for all other locations - See also THD::emb_on_expr_nest. */ TABLE_LIST *emb_on_expr_nest; /* @@ -457,11 +461,7 @@ public: */ bool sjm_scan_allowed; double jtbm_read_time; - double jtbm_record_count; - - /* A bitmap of possible execution strategies for an IN predicate. */ - uchar in_strategy; - + double jtbm_record_count; bool is_jtbm_merged; /* @@ -473,7 +473,7 @@ public: TRUE<=>registered in the list of semijoins in outer select */ bool is_registered_semijoin; - + /* Used to determine how this subselect item is represented in the item tree, in case there is a need to locate it there and replace with something else. @@ -502,8 +502,8 @@ public: Item_in_subselect(Item * left_expr, st_select_lex *select_lex); Item_in_subselect() :Item_exists_subselect(), left_expr_cache(0), first_execution(TRUE), - abort_on_null(0), optimizer(0), - pushed_cond_guards(NULL), func(NULL), in_strategy(SUBS_NOT_TRANSFORMED), + abort_on_null(0), in_strategy(SUBS_NOT_TRANSFORMED), optimizer(0), + pushed_cond_guards(NULL), func(NULL), emb_on_expr_nest(NULL), is_jtbm_merged(FALSE), upper_item(0) {} @@ -547,6 +547,70 @@ public: user. */ int get_identifier(); + + void mark_as_condition_AND_part(TABLE_LIST *embedding) + { + emb_on_expr_nest= embedding; + } + + bool test_strategy(uchar strategy) + { return test(in_strategy & strategy); } + + /** + Test that the IN strategy was chosen for execution. This is so + when the CHOSEN flag is ON, and there is no other strategy. + */ + bool test_set_strategy(uchar strategy) + { + DBUG_ASSERT(strategy == SUBS_SEMI_JOIN || + strategy == SUBS_IN_TO_EXISTS || + strategy == SUBS_MATERIALIZATION || + strategy == SUBS_PARTIAL_MATCH_ROWID_MERGE || + strategy == SUBS_PARTIAL_MATCH_TABLE_SCAN || + strategy == SUBS_MAXMIN_INJECTED || + strategy == SUBS_MAXMIN_ENGINE); + return ((in_strategy & SUBS_STRATEGY_CHOSEN) && + (in_strategy & ~SUBS_STRATEGY_CHOSEN) == strategy); + } + + bool is_set_strategy() + { return test(in_strategy & SUBS_STRATEGY_CHOSEN); } + + bool has_strategy() + { return in_strategy != SUBS_NOT_TRANSFORMED; } + + void add_strategy (uchar strategy) + { + DBUG_ASSERT(strategy != SUBS_NOT_TRANSFORMED); + DBUG_ASSERT(!(strategy & SUBS_STRATEGY_CHOSEN)); + /* + TODO: PS re-execution breaks this condition, because + check_and_do_in_subquery_rewrites() is called for each reexecution + and re-adds the same strategies. + DBUG_ASSERT(!(in_strategy & SUBS_STRATEGY_CHOSEN)); + */ + in_strategy|= strategy; + } + + void reset_strategy(uchar strategy) + { + DBUG_ASSERT(strategy != SUBS_NOT_TRANSFORMED); + in_strategy= strategy; + } + + void set_strategy(uchar strategy) + { + /* Check that only one strategy is set for execution. */ + DBUG_ASSERT(strategy == SUBS_SEMI_JOIN || + strategy == SUBS_IN_TO_EXISTS || + strategy == SUBS_MATERIALIZATION || + strategy == SUBS_PARTIAL_MATCH_ROWID_MERGE || + strategy == SUBS_PARTIAL_MATCH_TABLE_SCAN || + strategy == SUBS_MAXMIN_INJECTED || + strategy == SUBS_MAXMIN_ENGINE); + in_strategy= (SUBS_STRATEGY_CHOSEN | strategy); + } + friend class Item_ref_null_helper; friend class Item_is_not_null_test; friend class Item_in_optimizer; @@ -663,6 +727,7 @@ class subselect_single_select_engine: public subselect_engine { bool prepared; /* simple subselect is prepared */ bool executed; /* simple subselect is executed */ + bool optimize_error; ///< simple subselect optimization failed st_select_lex *select_lex; /* corresponding select_lex */ JOIN * join; /* corresponding JOIN structure */ public: @@ -892,7 +957,7 @@ public: tmp_table(NULL), is_materialized(FALSE), materialize_engine(old_engine), materialize_join(NULL), semi_join_conds(NULL), lookup_engine(NULL), count_partial_match_columns(0), count_null_only_columns(0), - strategy(UNDEFINED) + count_columns_with_nulls(0), strategy(UNDEFINED) {} ~subselect_hash_sj_engine(); @@ -930,6 +995,7 @@ protected: MY_BITMAP partial_match_key_parts; uint count_partial_match_columns; uint count_null_only_columns; + uint count_columns_with_nulls; /* Possible execution strategies that can be used to compute hash semi-join.*/ enum exec_strategy { UNDEFINED, @@ -956,7 +1022,7 @@ protected: /* - Distinguish the type od (0-based) row numbers from the type of the index into + Distinguish the type of (0-based) row numbers from the type of the index into an array of row numbers. */ typedef ha_rows rownum_t; @@ -1032,9 +1098,9 @@ protected: /* Count of NULLs per column. */ ha_rows null_count; /* The row number that contains the first NULL in a column. */ - ha_rows min_null_row; + rownum_t min_null_row; /* The row number that contains the last NULL in a column. */ - ha_rows max_null_row; + rownum_t max_null_row; protected: bool alloc_keys_buffers(); @@ -1067,6 +1133,10 @@ public: DBUG_ASSERT(i < key_column_count); return key_columns[i]->field->field_index; } + rownum_t get_min_null_row() { return min_null_row; } + rownum_t get_max_null_row() { return max_null_row; } + MY_BITMAP * get_null_key() { return &null_key; } + ha_rows get_null_count() { return null_count; } /* Get the search key element that corresponds to the i-th key part of this index. @@ -1167,6 +1237,7 @@ protected: guaranteed partial match. */ bool has_covering_null_columns; + uint count_columns_with_nulls; protected: virtual bool partial_match()= 0; @@ -1177,7 +1248,8 @@ public: select_result_interceptor *result_arg, List<Item> *equi_join_conds_arg, bool has_covering_null_row_arg, - bool has_covering_null_columns_arg); + bool has_covering_null_columns_arg, + uint count_columns_with_nulls_arg); int prepare() { return 0; } int exec(); void fix_length_and_dec(Item_cache**) {} @@ -1235,6 +1307,8 @@ protected: Ordered_key **merge_keys; /* The number of elements in merge_keys. */ uint merge_keys_count; + /* The NULL bitmaps of merge keys.*/ + MY_BITMAP **null_bitmaps; /* An index on all non-NULL columns of 'tmp_table'. The index has the logical form: <[v_i1 | ... | v_ik], rownum>. It allows to find the row @@ -1260,6 +1334,7 @@ protected: static int cmp_keys_by_cur_rownum(void *arg, uchar *k1, uchar *k2); bool test_null_row(rownum_t row_num); + bool exists_complementing_null_row(MY_BITMAP *keys_to_complement); bool partial_match(); public: subselect_rowid_merge_engine(THD *thd_arg, @@ -1267,13 +1342,15 @@ public: TABLE *tmp_table_arg, uint merge_keys_count_arg, bool has_covering_null_row_arg, bool has_covering_null_columns_arg, + uint count_columns_with_nulls_arg, Item_subselect *item_arg, select_result_interceptor *result_arg, List<Item> *equi_join_conds_arg) :subselect_partial_match_engine(thd_arg, engine_arg, tmp_table_arg, item_arg, result_arg, equi_join_conds_arg, has_covering_null_row_arg, - has_covering_null_columns_arg), + has_covering_null_columns_arg, + count_columns_with_nulls_arg), merge_keys_count(merge_keys_count_arg), non_null_key(NULL) {} ~subselect_rowid_merge_engine(); @@ -1294,7 +1371,8 @@ public: select_result_interceptor *result_arg, List<Item> *equi_join_conds_arg, bool has_covering_null_row_arg, - bool has_covering_null_columns_arg); + bool has_covering_null_columns_arg, + uint count_columns_with_nulls_arg); void cleanup(); virtual enum_engine_type engine_type() { return TABLE_SCAN_ENGINE; } }; diff --git a/sql/item_sum.cc b/sql/item_sum.cc index 0b8ae2d1d54..9bf786dbbd4 100644 --- a/sql/item_sum.cc +++ b/sql/item_sum.cc @@ -1,4 +1,5 @@ -/* Copyright (c) 2000, 2010, Oracle and/or its affiliates. +/* Copyright (c) 2000, 2011, Oracle and/or its affiliates. + Copyright (c) 2010, 2011, Monty Program Ab 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 @@ -11,7 +12,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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ /** @@ -259,10 +260,10 @@ bool Item_sum::check_sum_func(THD *thd, Item **ref) in_sum_func->outer_fields.push_back(field); } else - sel->full_group_by_flag|= NON_AGG_FIELD_USED; + sel->set_non_agg_field_used(true); } if (sel->nest_level > aggr_level && - (sel->full_group_by_flag & SUM_FUNC_USED) && + (sel->agg_func_used()) && !sel->group_list.elements) { my_message(ER_MIX_OF_GROUP_FUNC_AND_FIELDS, @@ -271,7 +272,7 @@ bool Item_sum::check_sum_func(THD *thd, Item **ref) } } } - aggr_sel->full_group_by_flag|= SUM_FUNC_USED; + aggr_sel->set_agg_func_used(true); update_used_tables(); thd->lex->in_sum_func= in_sum_func; return FALSE; @@ -371,7 +372,9 @@ bool Item_sum::collect_outer_ref_processor(uchar *param) { Collect_deps_prm *prm= (Collect_deps_prm *)param; SELECT_LEX *ds; - if ((ds= depended_from()) && ds->nest_level < prm->nest_level) + if ((ds= depended_from()) && + ds->nest_level_base == prm->nest_level_base && + ds->nest_level < prm->nest_level) prm->parameters->add_unique(this, &cmp_items); return FALSE; } diff --git a/sql/item_sum.h b/sql/item_sum.h index cd5ce3df9fc..c7a222bcd84 100644 --- a/sql/item_sum.h +++ b/sql/item_sum.h @@ -1,6 +1,7 @@ #ifndef ITEM_SUM_INCLUDED #define ITEM_SUM_INCLUDED -/* Copyright (c) 2000, 2010 Oracle and/or its affiliates. All rights reserved. +/* Copyright (c) 2000, 2011 Oracle and/or its affiliates. + Copyright (c) 2010, 2011 Monty Program Ab 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 @@ -13,7 +14,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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ /* classes for sum functions */ diff --git a/sql/item_timefunc.cc b/sql/item_timefunc.cc index 79e792281d3..0d21d619421 100644 --- a/sql/item_timefunc.cc +++ b/sql/item_timefunc.cc @@ -1,4 +1,5 @@ -/* Copyright (C) 2000-2003 MySQL AB +/* + Copyright (c) 2000, 2011, Oracle and/or its affiliates. Copyright (c) 2009-2011, Monty Program Ab This program is free software; you can redistribute it and/or modify @@ -12,7 +13,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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ /** @@ -1320,7 +1321,7 @@ bool get_interval_value(Item *args,interval_type int_type, INTERVAL *interval) else { String *res; - if (!(res=args->val_str(&str_value))) + if (!(res= args->val_str_ascii(&str_value))) return (1); /* record negative intervalls in interval->neg */ @@ -1485,7 +1486,8 @@ longlong Item_temporal_func::val_int() MYSQL_TIME ltime; if (get_date(<ime, TIME_FUZZY_DATE | sql_mode)) return 0; - return (longlong)TIME_to_ulonglong(<ime); + longlong v= TIME_to_ulonglong(<ime); + return ltime.neg ? -v : v; } @@ -2567,7 +2569,6 @@ bool Item_func_add_time::get_date(MYSQL_TIME *ltime, ulonglong fuzzy_date) long days, microseconds; longlong seconds; int l_sign= sign, was_cut= 0; - uint dec= decimals; if (is_date) // TIMESTAMP function { @@ -2609,10 +2610,6 @@ bool Item_func_add_time::get_date(MYSQL_TIME *ltime, ulonglong fuzzy_date) ltime->time_type= is_time ? MYSQL_TIMESTAMP_TIME : MYSQL_TIMESTAMP_DATETIME; - if (cached_field_type == MYSQL_TYPE_STRING && - (l_time1.second_part || l_time2.second_part)) - dec= TIME_SECOND_PART_DIGITS; - if (!is_time) { get_date_from_daynr(days,<ime->year,<ime->month,<ime->day); diff --git a/sql/item_xmlfunc.cc b/sql/item_xmlfunc.cc index 183c07c1781..b93a83c05a9 100644 --- a/sql/item_xmlfunc.cc +++ b/sql/item_xmlfunc.cc @@ -1,4 +1,4 @@ -/* Copyright (C) 2005-2006 MySQL AB +/* Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved. 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 @@ -1982,6 +1982,9 @@ static int my_xpath_parse_UnionExpr(MY_XPATH *xpath) static int my_xpath_parse_FilterExpr_opt_slashes_RelativeLocationPath(MY_XPATH *xpath) { + Item *context= xpath->context; + int rc; + if (!my_xpath_parse_FilterExpr(xpath)) return 0; @@ -1995,8 +1998,22 @@ my_xpath_parse_FilterExpr_opt_slashes_RelativeLocationPath(MY_XPATH *xpath) return 0; } - my_xpath_parse_term(xpath, MY_XPATH_LEX_SLASH); - return my_xpath_parse_RelativeLocationPath(xpath); + /* + The context for the next relative path is the nodeset + returned by FilterExpr + */ + xpath->context= xpath->item; + + /* treat double slash (//) as /descendant-or-self::node()/ */ + if (my_xpath_parse_term(xpath, MY_XPATH_LEX_SLASH)) + xpath->context= new Item_nodeset_func_descendantbyname(xpath->context, + "*", 1, xpath->pxml, 1); + rc= my_xpath_parse_RelativeLocationPath(xpath); + + /* push back the context and restore the item */ + xpath->item= xpath->context; + xpath->context= context; + return rc; } static int my_xpath_parse_PathExpr(MY_XPATH *xpath) { diff --git a/sql/item_xmlfunc.h b/sql/item_xmlfunc.h index 38dd0a5e1d1..800cf6ed760 100644 --- a/sql/item_xmlfunc.h +++ b/sql/item_xmlfunc.h @@ -1,7 +1,8 @@ #ifndef ITEM_XMLFUNC_INCLUDED #define ITEM_XMLFUNC_INCLUDED -/* Copyright (C) 2000-2005 MySQL AB +/* Copyright (c) 2000-2007 MySQL AB, 2009 Sun Microsystems, Inc. + Use is subject to license terms. 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 @@ -14,7 +15,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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ /* This file defines all XML functions */ diff --git a/sql/key.cc b/sql/key.cc index 02ef37ec1e5..dd7818119c8 100644 --- a/sql/key.cc +++ b/sql/key.cc @@ -1,4 +1,4 @@ -/* Copyright (C) 2000-2006 MySQL AB +/* Copyright (c) 2000, 2010, Oracle and/or its affiliates. All rights reserved. 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 @@ -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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ /* Functions to handle keys and fields in forms */ diff --git a/sql/key.h b/sql/key.h index 93f2c07e17a..8bf6f88fa04 100644 --- a/sql/key.h +++ b/sql/key.h @@ -1,4 +1,4 @@ -/* Copyright 2006-2008 MySQL AB, 2008-2009 Sun Microsystems, Inc. +/* Copyright (c) 2006, 2010, Oracle and/or its affiliates. All rights reserved. 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/keycaches.cc b/sql/keycaches.cc index 984b5a6768b..26a39808c56 100644 --- a/sql/keycaches.cc +++ b/sql/keycaches.cc @@ -1,4 +1,4 @@ -/* Copyright (C) 2002-2006 MySQL AB, 2009 Sun Microsystems, Inc. +/* Copyright (c) 2002, 2010, Oracle and/or its affiliates. All rights reserved. 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 @@ -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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ #include "keycaches.h" diff --git a/sql/keycaches.h b/sql/keycaches.h index 52bd163a0be..04d3f6145e7 100644 --- a/sql/keycaches.h +++ b/sql/keycaches.h @@ -1,7 +1,7 @@ #ifndef KEYCACHES_INCLUDED #define KEYCACHES_INCLUDED -/* Copyright (C) 2002-2006 MySQL AB, 2009 Sun Microsystems, Inc. +/* Copyright (c) 2002, 2010, Oracle and/or its affiliates. All rights reserved. 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 @@ -14,7 +14,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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ #include "sql_list.h" #include <keycache.h> diff --git a/sql/lex.h b/sql/lex.h index 37d0f0cc015..bb8f5825879 100644 --- a/sql/lex.h +++ b/sql/lex.h @@ -1,7 +1,7 @@ #ifndef LEX_INCLUDED #define LEX_INCLUDED -/* Copyright (C) 2000-2002 MySQL AB +/* Copyright (c) 2000, 2010, Oracle and/or its affiliates. All rights reserved. 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 @@ -14,7 +14,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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ /* This file includes all reserved words and functions */ @@ -249,6 +249,7 @@ static SYMBOL symbols[] = { { "GRANTS", SYM(GRANTS)}, { "GROUP", SYM(GROUP_SYM)}, { "HANDLER", SYM(HANDLER_SYM)}, + { "HARD", SYM(HARD_SYM)}, { "HASH", SYM(HASH_SYM)}, { "HAVING", SYM(HAVING)}, { "HELP", SYM(HELP_SYM)}, @@ -515,6 +516,7 @@ static SYMBOL symbols[] = { { "SNAPSHOT", SYM(SNAPSHOT_SYM)}, { "SMALLINT", SYM(SMALLINT)}, { "SOCKET", SYM(SOCKET_SYM)}, + { "SOFT", SYM(SOFT_SYM)}, { "SOME", SYM(ANY_SYM)}, { "SONAME", SYM(SONAME_SYM)}, { "SOUNDS", SYM(SOUNDS_SYM)}, diff --git a/sql/lock.cc b/sql/lock.cc index 8b010968f5f..631e5018cf3 100644 --- a/sql/lock.cc +++ b/sql/lock.cc @@ -1,4 +1,4 @@ -/* Copyright 2000-2008 MySQL AB, 2008-2009 Sun Microsystems, Inc. +/* Copyright (c) 2000, 2011, Oracle and/or its affiliates. All rights reserved. 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 @@ -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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ /** diff --git a/sql/lock.h b/sql/lock.h index 442881c5b9b..a4833cdc38e 100644 --- a/sql/lock.h +++ b/sql/lock.h @@ -1,3 +1,18 @@ +/* Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved. + + 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 + the Free Software Foundation; version 2 of the License. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + 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 02110-1301 USA */ + #ifndef LOCK_INCLUDED #define LOCK_INCLUDED diff --git a/sql/log.cc b/sql/log.cc index 8939e69bb54..a7698fd3ae6 100644 --- a/sql/log.cc +++ b/sql/log.cc @@ -81,7 +81,7 @@ static LEX_STRING const write_error_msg= static my_bool opt_optimize_thread_scheduling= TRUE; ulong binlog_checksum_options; #ifndef DBUG_OFF -static ulong opt_binlog_dbug_fsync_sleep= 0; +ulong opt_binlog_dbug_fsync_sleep= 0; #endif mysql_mutex_t LOCK_prepare_ordered; @@ -1256,17 +1256,6 @@ bool LOGGER::slow_log_print(THD *thd, const char *query, uint query_length, query_length= command_name[thd->command].length; } - if (!query_length) - { - /* - Not a real query; Reset counts for slow query logging - (QQ: Wonder if this is really needed) - */ - thd->sent_row_count= thd->examined_row_count= 0; - thd->query_plan_flags= QPLAN_INIT; - thd->query_plan_fsort_passes= 0; - } - for (current_handler= slow_log_handler_list; *current_handler ;) error= (*current_handler++)->log_slow(thd, current_time, user_host_buff, user_host_len, @@ -2088,7 +2077,7 @@ static int binlog_savepoint_set(handlerton *hton, THD *thd, void *sv) log_query.append(thd->lex->ident.str, thd->lex->ident.length) || log_query.append("`")) DBUG_RETURN(1); - int errcode= query_error_code(thd, thd->killed == THD::NOT_KILLED); + int errcode= query_error_code(thd, thd->killed == NOT_KILLED); Query_log_event qinfo(thd, log_query.ptr(), log_query.length(), TRUE, FALSE, TRUE, errcode); DBUG_RETURN(mysql_bin_log.write(&qinfo)); @@ -2112,7 +2101,7 @@ static int binlog_savepoint_rollback(handlerton *hton, THD *thd, void *sv) log_query.append(thd->lex->ident.str, thd->lex->ident.length) || log_query.append("`")) DBUG_RETURN(1); - int errcode= query_error_code(thd, thd->killed == THD::NOT_KILLED); + int errcode= query_error_code(thd, thd->killed == NOT_KILLED); Query_log_event qinfo(thd, log_query.ptr(), log_query.length(), TRUE, FALSE, TRUE, errcode); DBUG_RETURN(mysql_bin_log.write(&qinfo)); @@ -5614,7 +5603,7 @@ int query_error_code(THD *thd, bool not_killed) { int error; - if (not_killed || (thd->killed == THD::KILL_BAD_DATA)) + if (not_killed || (killed_mask_hard(thd->killed) == KILL_BAD_DATA)) { error= thd->is_error() ? thd->stmt_da->sql_errno() : 0; @@ -5623,7 +5612,8 @@ int query_error_code(THD *thd, bool not_killed) is not set to these errors when specified not_killed by the caller. */ - if (error == ER_SERVER_SHUTDOWN || error == ER_QUERY_INTERRUPTED) + if (error == ER_SERVER_SHUTDOWN || error == ER_QUERY_INTERRUPTED || + error == ER_NEW_ABORTING_CONNECTION || error == ER_CONNECTION_KILLED) error= 0; } else @@ -7569,27 +7559,10 @@ static MYSQL_SYSVAR_ENUM( BINLOG_CHECKSUM_ALG_OFF, &binlog_checksum_typelib); -#ifndef DBUG_OFF -static MYSQL_SYSVAR_ULONG( - dbug_fsync_sleep, - opt_binlog_dbug_fsync_sleep, - PLUGIN_VAR_RQCMDARG, - "Extra sleep (in microseconds) to add to binlog fsync(), for debugging", - NULL, - NULL, - 0, - 0, - ULONG_MAX, - 0); -#endif - static struct st_mysql_sys_var *binlog_sys_vars[]= { MYSQL_SYSVAR(optimize_thread_scheduling), MYSQL_SYSVAR(checksum), -#ifndef DBUG_OFF - MYSQL_SYSVAR(dbug_fsync_sleep), -#endif NULL }; @@ -7643,22 +7616,6 @@ TC_LOG_BINLOG::set_status_variables(THD *thd) struct st_mysql_storage_engine binlog_storage_engine= { MYSQL_HANDLERTON_INTERFACE_VERSION }; -mysql_declare_plugin(binlog) -{ - MYSQL_STORAGE_ENGINE_PLUGIN, - &binlog_storage_engine, - "binlog", - "MySQL AB", - "This is a pseudo storage engine to represent the binlog in a transaction", - PLUGIN_LICENSE_GPL, - binlog_init, /* Plugin Init */ - NULL, /* Plugin Deinit */ - 0x0100 /* 1.0 */, - binlog_status_vars_top, /* status variables */ - binlog_sys_vars, /* system variables */ - NULL /* config options */ -} -mysql_declare_plugin_end; maria_declare_plugin(binlog) { MYSQL_STORAGE_ENGINE_PLUGIN, diff --git a/sql/log_event.cc b/sql/log_event.cc index c9e92cc264b..dddd24bc299 100644 --- a/sql/log_event.cc +++ b/sql/log_event.cc @@ -1,4 +1,5 @@ -/* Copyright 2000-2008 MySQL AB, 2008-2009 Sun Microsystems, Inc. +/* + Copyright (c) 2000, 2011, Oracle and/or its affiliates. All rights reserved. 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 @@ -11,7 +12,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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ #ifdef MYSQL_CLIENT @@ -113,6 +114,11 @@ static int rows_event_stmt_cleanup(Relay_log_info const *rli, THD* thd); static const char *HA_ERR(int i) { + /* + This function should only be called in case of an error + was detected + */ + DBUG_ASSERT(i != 0); switch (i) { case HA_ERR_KEY_NOT_FOUND: return "HA_ERR_KEY_NOT_FOUND"; case HA_ERR_FOUND_DUPP_KEY: return "HA_ERR_FOUND_DUPP_KEY"; @@ -165,7 +171,7 @@ static const char *HA_ERR(int i) case HA_ERR_CORRUPT_EVENT: return "HA_ERR_CORRUPT_EVENT"; case HA_ERR_ROWS_EVENT_APPLY : return "HA_ERR_ROWS_EVENT_APPLY"; } - return 0; + return "No Error!"; } /** @@ -186,7 +192,7 @@ static void inline slave_rows_error_report(enum loglevel level, int ha_error, TABLE *table, const char * type, const char *log_name, ulong pos) { - const char *handler_error= HA_ERR(ha_error); + const char *handler_error= (ha_error ? HA_ERR(ha_error) : NULL); char buff[MAX_SLAVE_ERRMSG], *slider; const char *buff_end= buff + sizeof(buff); uint len; @@ -451,6 +457,7 @@ inline bool unexpected_error_code(int unexpected_error) case ER_NET_READ_ERROR: case ER_NET_ERROR_ON_WRITE: case ER_QUERY_INTERRUPTED: + case ER_CONNECTION_KILLED: case ER_SERVER_SHUTDOWN: case ER_NEW_ABORTING_CONNECTION: return(TRUE); @@ -3787,7 +3794,7 @@ Default database: '%s'. Query: '%s'", { DBUG_PRINT("info",("error ignored")); clear_all_errors(thd, const_cast<Relay_log_info*>(rli)); - thd->killed= THD::NOT_KILLED; + thd->killed= NOT_KILLED; } /* Other cases: mostly we expected no error and get one. @@ -8236,7 +8243,8 @@ int Rows_log_event::do_apply_event(Relay_log_info const *rli) error= do_exec_row(rli); - DBUG_PRINT("info", ("error: %s", HA_ERR(error))); + if (error) + DBUG_PRINT("info", ("error: %s", HA_ERR(error))); DBUG_ASSERT(error != HA_ERR_RECORD_DELETED); table->in_use = old_thd; @@ -9101,6 +9109,97 @@ int Table_map_log_event::rewrite_db(const char* new_db, size_t new_len, */ #if !defined(MYSQL_CLIENT) && defined(HAVE_REPLICATION) + +enum enum_tbl_map_status +{ + /* no duplicate identifier found */ + OK_TO_PROCESS= 0, + + /* this table map must be filtered out */ + FILTERED_OUT= 1, + + /* identifier mapping table with different properties */ + SAME_ID_MAPPING_DIFFERENT_TABLE= 2, + + /* a duplicate identifier was found mapping the same table */ + SAME_ID_MAPPING_SAME_TABLE= 3 +}; + +/* + Checks if this table map event should be processed or not. First + it checks the filtering rules, and then looks for duplicate identifiers + in the existing list of rli->tables_to_lock. + + It checks that there hasn't been any corruption by verifying that there + are no duplicate entries with different properties. + + In some cases, some binary logs could get corrupted, showing several + tables mapped to the same table_id, 0 (see: BUG#56226). Thus we do this + early sanity check for such cases and avoid that the server crashes + later. + + In some corner cases, the master logs duplicate table map events, i.e., + same id, same database name, same table name (see: BUG#37137). This is + different from the above as it's the same table that is mapped again + to the same identifier. Thus we cannot just check for same ids and + assume that the event is corrupted we need to check every property. + + NOTE: in the event that BUG#37137 ever gets fixed, this extra check + will still be valid because we would need to support old binary + logs anyway. + + @param rli The relay log info reference. + @param table_list A list element containing the table to check against. + @return OK_TO_PROCESS + if there was no identifier already in rli->tables_to_lock + + FILTERED_OUT + if the event is filtered according to the filtering rules + + SAME_ID_MAPPING_DIFFERENT_TABLE + if the same identifier already maps a different table in + rli->tables_to_lock + + SAME_ID_MAPPING_SAME_TABLE + if the same identifier already maps the same table in + rli->tables_to_lock. +*/ +static enum_tbl_map_status +check_table_map(Relay_log_info const *rli, RPL_TABLE_LIST *table_list) +{ + DBUG_ENTER("check_table_map"); + enum_tbl_map_status res= OK_TO_PROCESS; + + if (rli->sql_thd->slave_thread /* filtering is for slave only */ && + (!rpl_filter->db_ok(table_list->db) || + (rpl_filter->is_on() && !rpl_filter->tables_ok("", table_list)))) + res= FILTERED_OUT; + else + { + for(RPL_TABLE_LIST *ptr= static_cast<RPL_TABLE_LIST*>(rli->tables_to_lock); + ptr; + ptr= static_cast<RPL_TABLE_LIST*>(ptr->next_local)) + { + if (ptr->table_id == table_list->table_id) + { + + if (strcmp(ptr->db, table_list->db) || + strcmp(ptr->alias, table_list->table_name) || + ptr->lock_type != TL_WRITE) // the ::do_apply_event always sets TL_WRITE + res= SAME_ID_MAPPING_DIFFERENT_TABLE; + else + res= SAME_ID_MAPPING_SAME_TABLE; + + break; + } + } + } + + DBUG_PRINT("debug", ("check of table map ended up with: %u", res)); + + DBUG_RETURN(res); +} + int Table_map_log_event::do_apply_event(Relay_log_info const *rli) { RPL_TABLE_LIST *table_list; @@ -9127,18 +9226,11 @@ int Table_map_log_event::do_apply_event(Relay_log_info const *rli) tname_mem, strlen(tname_mem), tname_mem, TL_WRITE); - table_list->table_id= m_table_id; + table_list->table_id= DBUG_EVALUATE_IF("inject_tblmap_same_id_maps_diff_table", 0, m_table_id); table_list->updating= 1; - - int error= 0; - - if (rli->sql_thd->slave_thread /* filtering is for slave only */ && - (!rpl_filter->db_ok(table_list->db) || - (rpl_filter->is_on() && !rpl_filter->tables_ok("", table_list)))) - { - my_free(memory); - } - else + DBUG_PRINT("debug", ("table: %s is mapped to %u", table_list->table_name, table_list->table_id)); + enum_tbl_map_status tblmap_status= check_table_map(rli, table_list); + if (tblmap_status == OK_TO_PROCESS) { DBUG_ASSERT(thd->lex->query_tables != table_list); @@ -9168,8 +9260,48 @@ int Table_map_log_event::do_apply_event(Relay_log_info const *rli) const_cast<Relay_log_info*>(rli)->tables_to_lock_count++; /* 'memory' is freed in clear_tables_to_lock */ } + else // FILTERED_OUT, SAME_ID_MAPPING_* + { + /* + If mapped already but with different properties, we raise an + error. + If mapped already but with same properties we skip the event. + If filtered out we skip the event. - DBUG_RETURN(error); + In all three cases, we need to free the memory previously + allocated. + */ + if (tblmap_status == SAME_ID_MAPPING_DIFFERENT_TABLE) + { + /* + Something bad has happened. We need to stop the slave as strange things + could happen if we proceed: slave crash, wrong table being updated, ... + As a consequence we push an error in this case. + */ + + char buf[256]; + + my_snprintf(buf, sizeof(buf), + "Found table map event mapping table id %u which " + "was already mapped but with different settings.", + table_list->table_id); + + if (thd->slave_thread) + rli->report(ERROR_LEVEL, ER_SLAVE_FATAL_ERROR, + ER(ER_SLAVE_FATAL_ERROR), buf); + else + /* + For the cases in which a 'BINLOG' statement is set to + execute in a user session + */ + my_printf_error(ER_SLAVE_FATAL_ERROR, ER(ER_SLAVE_FATAL_ERROR), + MYF(0), buf); + } + + my_free(memory); + } + + DBUG_RETURN(tblmap_status == SAME_ID_MAPPING_DIFFERENT_TABLE); } Log_event::enum_skip_reason @@ -10187,7 +10319,8 @@ int Rows_log_event::find_row(const Relay_log_info *rli) restart_rnd_next: error= table->file->ha_rnd_next(table->record[0]); - DBUG_PRINT("info", ("error: %s", HA_ERR(error))); + if (error) + DBUG_PRINT("info", ("error: %s", HA_ERR(error))); switch (error) { case 0: diff --git a/sql/log_event.h b/sql/log_event.h index be83995f331..c9810cbb140 100644 --- a/sql/log_event.h +++ b/sql/log_event.h @@ -1,4 +1,4 @@ -/* Copyright (C) 2000-2006 MySQL AB, 2008-2009 Sun Microsystems, Inc +/* Copyright (c) 2000, 2010, Oracle and/or its affiliates. All rights reserved. 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 @@ -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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ /** @addtogroup Replication @@ -3145,7 +3145,7 @@ char *str_to_hex(char *to, const char *from, uint len); /** @class Annotate_rows_log_event - In row-based mode, if binlog_annotate_rows_events = ON, each group of + In row-based mode, if binlog_annotate_row_events = ON, each group of Table_map_log_events is preceded by an Annotate_rows_log_event which contains the query which caused the subsequent rows operations. diff --git a/sql/log_event_old.cc b/sql/log_event_old.cc index c6efa91f375..a52c584726a 100644 --- a/sql/log_event_old.cc +++ b/sql/log_event_old.cc @@ -1,3 +1,17 @@ +/* Copyright (c) 2007, 2010, Oracle and/or its affiliates. All rights reserved. + + 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 + the Free Software Foundation; version 2 of the License. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + 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 02110-1301 USA */ #include "sql_priv.h" #ifndef MYSQL_CLIENT diff --git a/sql/main.cc b/sql/main.cc index 249a2a883fe..10141c132a6 100644 --- a/sql/main.cc +++ b/sql/main.cc @@ -1,4 +1,5 @@ -/* Copyright (C) 2009 Sun Microsystems, Inc. +/* Copyright (c) 2009 Sun Microsystems, Inc. + Use is subject to license terms. 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 @@ -11,7 +12,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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ /* main() for mysqld. diff --git a/sql/mdl.cc b/sql/mdl.cc index 45f0c02338e..d29f6a112d4 100644 --- a/sql/mdl.cc +++ b/sql/mdl.cc @@ -1,4 +1,4 @@ -/* Copyright (C) 2007-2008 MySQL AB +/* Copyright (c) 2007, 2011, Oracle and/or its affiliates. All rights reserved. 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 @@ -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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ #include "mdl.h" diff --git a/sql/mdl.h b/sql/mdl.h index 2fa89ea2f55..3a0ac0037aa 100644 --- a/sql/mdl.h +++ b/sql/mdl.h @@ -1,6 +1,6 @@ #ifndef MDL_H #define MDL_H -/* Copyright (C) 2007-2008 MySQL AB +/* Copyright (c) 2009, 2011, Oracle and/or its affiliates. All rights reserved. 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 @@ -13,7 +13,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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ #if defined(__IBMC__) || defined(__IBMCPP__) /* Further down, "next_in_lock" and "next_in_context" have the same type, @@ -153,11 +153,24 @@ enum enum_mdl_type { /** Duration of metadata lock. */ -enum enum_mdl_duration { MDL_STATEMENT= 0, - MDL_TRANSACTION, - MDL_EXPLICIT, - /* This should be the last ! */ - MDL_DURATION_END }; +enum enum_mdl_duration { + /** + Locks with statement duration are automatically released at the end + of statement or transaction. + */ + MDL_STATEMENT= 0, + /** + Locks with transaction duration are automatically released at the end + of transaction. + */ + MDL_TRANSACTION, + /** + Locks with explicit duration survive the end of statement and transaction. + They have to be released explicitly by calling MDL_context::release_lock(). + */ + MDL_EXPLICIT, + /* This should be the last ! */ + MDL_DURATION_END }; /** Maximal length of key for metadata locking subsystem. */ diff --git a/sql/message.h b/sql/message.h index 102d38091e7..8ef0032e423 100644 --- a/sql/message.h +++ b/sql/message.h @@ -1,6 +1,7 @@ #ifndef MESSAGE_INCLUDED
#define MESSAGE_INCLUDED
-/* Copyright 2008 Sun Microsystems, Inc.
+/* Copyright (c) 2008, 2009 Sun Microsystems, Inc.
+ Use is subject to license terms.
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
@@ -13,7 +14,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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
+ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */
/*
To change or add messages mysqld writes to the Windows error log, run
diff --git a/sql/mf_iocache.cc b/sql/mf_iocache.cc index af0cb660713..d8848c1ee35 100644 --- a/sql/mf_iocache.cc +++ b/sql/mf_iocache.cc @@ -1,4 +1,4 @@ -/* Copyright (C) 2000-2004 MySQL AB +/* Copyright (c) 2000, 2010, Oracle and/or its affiliates. All rights reserved. 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 @@ -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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ /** @file diff --git a/sql/multi_range_read.cc b/sql/multi_range_read.cc index 130ab676e7b..d8dc45d38c7 100644 --- a/sql/multi_range_read.cc +++ b/sql/multi_range_read.cc @@ -440,10 +440,10 @@ void Mrr_ordered_index_reader::interrupt_read() { DBUG_ASSERT(support_scan_interruptions); TABLE *table= file->get_table(); + KEY *used_index= &table->key_info[file->active_index]; /* Save the current key value */ key_copy(saved_key_tuple, table->record[0], - &table->key_info[file->active_index], - keypar.key_tuple_length); + used_index, used_index->key_length); if (saved_primary_key) { @@ -468,9 +468,9 @@ void Mrr_ordered_index_reader::position() void Mrr_ordered_index_reader::resume_read() { TABLE *table= file->get_table(); + KEY *used_index= &table->key_info[file->active_index]; key_restore(table->record[0], saved_key_tuple, - &table->key_info[file->active_index], - keypar.key_tuple_length); + used_index, used_index->key_length); if (saved_primary_key) { key_restore(table->record[0], saved_primary_key, @@ -547,7 +547,7 @@ int Mrr_ordered_index_reader::init(handler *h_arg, RANGE_SEQ_IF *seq_funcs, mrr_funcs= *seq_funcs; source_exhausted= FALSE; if (support_scan_interruptions) - bzero(saved_key_tuple, keypar.key_tuple_length); + bzero(saved_key_tuple, key_info->key_length); have_saved_rowid= FALSE; return 0; } @@ -864,12 +864,14 @@ int DsMrr_impl::dsmrr_init(handler *h_arg, RANGE_SEQ_IF *seq_funcs, if (h_idx->primary_key_is_clustered()) { uint pk= h_idx->get_table()->s->primary_key; - saved_pk_length= h_idx->get_table()->key_info[pk].key_length; + if (pk != MAX_KEY) + saved_pk_length= h_idx->get_table()->key_info[pk].key_length; } - + + KEY *used_index= &h_idx->get_table()->key_info[h_idx->active_index]; if (reader_factory.ordered_index_reader. set_interruption_temp_buffer(primary_file->ref_length, - keypar.key_tuple_length, + used_index->key_length, saved_pk_length, &full_buf, full_buf_end)) goto use_default_impl; @@ -1651,7 +1653,8 @@ bool DsMrr_impl::get_disk_sweep_mrr_cost(uint keynr, ha_rows rows, uint flags, uint *buffer_size, COST_VECT *cost) { ulong max_buff_entries, elem_size; - ha_rows rows_in_full_step, rows_in_last_step; + ha_rows rows_in_full_step; + ha_rows rows_in_last_step; uint n_full_steps; double index_read_cost; @@ -1676,7 +1679,7 @@ bool DsMrr_impl::get_disk_sweep_mrr_cost(uint keynr, ha_rows rows, uint flags, /* Adjust buffer size if we expect to use only part of the buffer */ if (n_full_steps) { - get_sort_and_sweep_cost(table, rows, cost); + get_sort_and_sweep_cost(table, rows_in_full_step, cost); cost->multiply(n_full_steps); } else diff --git a/sql/my_decimal.cc b/sql/my_decimal.cc index 1a60d199b13..39be927fd27 100644 --- a/sql/my_decimal.cc +++ b/sql/my_decimal.cc @@ -1,4 +1,4 @@ -/* Copyright (C) 2005-2006 MySQL AB +/* Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved. 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 @@ -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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ #include <my_global.h> #include "sql_priv.h" diff --git a/sql/my_decimal.h b/sql/my_decimal.h index 3a309209b90..e0c47029940 100644 --- a/sql/my_decimal.h +++ b/sql/my_decimal.h @@ -99,12 +99,8 @@ public: { len= DECIMAL_BUFF_LENGTH; buf= buffer; -#if !defined (HAVE_valgrind) && !defined(DBUG_OFF) - /* Set buffer to 'random' value to find wrong buffer usage */ - for (uint i= 0; i < DECIMAL_BUFF_LENGTH; i++) - buffer[i]= i; -#endif } + my_decimal() { init(); @@ -119,8 +115,6 @@ public: void swap(my_decimal &rhs) { swap_variables(my_decimal, *this, rhs); - /* Swap the buffer pointers back */ - swap_variables(decimal_digit_t *, buf, rhs.buf); } }; diff --git a/sql/mysqld.cc b/sql/mysqld.cc index 10107dfab15..46b6ec3978a 100644 --- a/sql/mysqld.cc +++ b/sql/mysqld.cc @@ -409,7 +409,7 @@ my_bool opt_local_infile, opt_slave_compressed_protocol; my_bool opt_safe_user_create = 0; my_bool opt_show_slave_auth_info; my_bool opt_log_slave_updates= 0; -my_bool opt_replicate_annotate_rows_events= 0; +my_bool opt_replicate_annotate_row_events= 0; char *opt_slave_skip_errors; /* @@ -500,6 +500,11 @@ my_decimal decimal_zero; */ ulong max_long_data_size; +/* Limits for internal temporary tables (MyISAM or Aria) */ +uint internal_tmp_table_max_key_length; +uint internal_tmp_table_max_key_segments; + +bool max_user_connections_checking=0; /** Limit of the total number of prepared statements in the server. Is necessary to protect the server against out-of-memory attacks. @@ -1389,7 +1394,7 @@ static void close_connections(void) if (tmp->slave_thread) continue; - tmp->killed= THD::KILL_CONNECTION; + tmp->killed= KILL_SERVER_HARD; MYSQL_CALLBACK(thread_scheduler, post_kill_notification, (tmp)); mysql_mutex_lock(&tmp->LOCK_thd_data); if (tmp->mysys_var) @@ -1449,7 +1454,7 @@ static void close_connections(void) tmp->thread_id, (tmp->main_security_ctx.user ? tmp->main_security_ctx.user : "")); - close_connection(tmp); + close_connection(tmp,ER_SERVER_SHUTDOWN); } #endif DBUG_PRINT("quit",("Unlocking LOCK_thread_count")); @@ -2119,7 +2124,7 @@ static my_socket activate_tcp_port(uint port) for (a= ai; a != NULL; a= a->ai_next) { - ip_sock= socket(a->ai_family, a->ai_socktype, a->ai_protocol); + ip_sock= socket(a->ai_family, a->ai_socktype, a->ai_protocol); if (ip_sock != INVALID_SOCKET) break; } @@ -2335,6 +2340,16 @@ void close_connection(THD *thd, uint sql_errno) if (sql_errno) net_send_error(thd, sql_errno, ER_DEFAULT(sql_errno), NULL); + if (global_system_variables.log_warnings > 3) + { + Security_context *sctx= &thd->main_security_ctx; + sql_print_warning(ER(ER_NEW_ABORTING_CONNECTION), + thd->thread_id,(thd->db ? thd->db : "unconnected"), + sctx->user ? sctx->user : "unauthenticated", + sctx->host_or_ip, + (sql_errno ? ER(sql_errno) : "CLOSE_CONNECTION")); + } + thd->disconnect(); MYSQL_CONNECTION_DONE((int) sql_errno, thd->thread_id); @@ -2503,6 +2518,7 @@ static bool cache_thread() */ thd->mysys_var->abort= 0; thd->thr_create_utime= microsecond_interval_timer(); + thd->start_utime= thd->thr_create_utime; threads.append(thd); return(1); } @@ -2567,24 +2583,6 @@ void flush_thread_cache() } -#ifdef THREAD_SPECIFIC_SIGPIPE -/** - Aborts a thread nicely. Comes here on SIGPIPE. - - @todo - One should have to fix that thr_alarm know about this thread too. -*/ -extern "C" sig_handler abort_thread(int sig __attribute__((unused))) -{ - THD *thd=current_thd; - DBUG_ENTER("abort_thread"); - if (thd) - thd->killed= THD::KILL_CONNECTION; - DBUG_VOID_RETURN; -} -#endif - - /****************************************************************************** Setup a signal thread with handles all signals. Because Linux doesn't support schemas use a mutex to check that @@ -2798,6 +2796,8 @@ or misconfigured. This error can also be caused by malfunctioning hardware.\n", We will try our best to scrape up some info that will hopefully help diagnose\n\ the problem, but since we have already crashed, something is definitely wrong\n\ and this may fail.\n\n"); + set_server_version(); + fprintf(stderr, "Server version: %s\n", server_version); fprintf(stderr, "key_buffer_size=%lu\n", (ulong) dflt_key_cache->key_cache_mem_size); fprintf(stderr, "read_buffer_size=%ld\n", (long) global_system_variables.read_buff_size); @@ -2842,20 +2842,29 @@ the thread stack. Please read http://dev.mysql.com/doc/mysql/en/linux.html\n\n", { const char *kreason= "UNKNOWN"; switch (thd->killed) { - case THD::NOT_KILLED: + case NOT_KILLED: + case KILL_HARD_BIT: kreason= "NOT_KILLED"; break; - case THD::KILL_BAD_DATA: + case KILL_BAD_DATA: + case KILL_BAD_DATA_HARD: kreason= "KILL_BAD_DATA"; break; - case THD::KILL_CONNECTION: + case KILL_CONNECTION: + case KILL_CONNECTION_HARD: kreason= "KILL_CONNECTION"; break; - case THD::KILL_QUERY: + case KILL_QUERY: + case KILL_QUERY_HARD: kreason= "KILL_QUERY"; break; - case THD::KILLED_NO_VALUE: - kreason= "KILLED_NO_VALUE"; + case KILL_SYSTEM_THREAD: + case KILL_SYSTEM_THREAD_HARD: + kreason= "KILL_SYSTEM_THREAD"; + break; + case KILL_SERVER: + case KILL_SERVER_HARD: + kreason= "KILL_SERVER"; break; } fprintf(stderr, "\nTrying to get some variables.\n" @@ -2865,8 +2874,7 @@ the thread stack. Please read http://dev.mysql.com/doc/mysql/en/linux.html\n\n", fprintf(stderr, "\nConnection ID (thread ID): %lu\n", (ulong) thd->thread_id); fprintf(stderr, "Status: %s\n", kreason); fprintf(stderr, "Optimizer switch: "); - - ulonglong optsw= global_system_variables.optimizer_switch; + ulonglong optsw= thd->variables.optimizer_switch; for (uint i= 0; optimizer_switch_names[i+1]; i++, optsw >>= 1) { if (i) @@ -3218,7 +3226,7 @@ void my_message_sql(uint error, const char *str, myf MyFlags) sql_print_message_func func; DBUG_ENTER("my_message_sql"); - DBUG_PRINT("error", ("error: %u message: '%s'", error, str)); + DBUG_PRINT("error", ("error: %u message: '%s' Flag: %d", error, str, MyFlags)); DBUG_ASSERT(str != NULL); DBUG_ASSERT(error != 0); @@ -3250,7 +3258,7 @@ void my_message_sql(uint error, const char *str, myf MyFlags) /* When simulating OOM, skip writing to error log to avoid mtr errors */ DBUG_EXECUTE_IF("simulate_out_of_memory", DBUG_VOID_RETURN;); - if (!thd || (MyFlags & ME_NOREFRESH)) + if (!thd || thd->log_all_errors || (MyFlags & ME_NOREFRESH)) (*func)("%s: %s", my_progname_short, str); /* purecov: inspected */ DBUG_VOID_RETURN; } @@ -4336,11 +4344,13 @@ a file name for --log-bin-index option", opt_binlog_index_name); require a name. But as we don't want to break many existing setups, we only give warning, not error. */ - sql_print_warning("No argument was provided to --log-bin, and " - "--log-bin-index was not used; so replication " - "may break when this MySQL server acts as a " - "master and has his hostname changed!! Please " - "use '--log-bin=%s' to avoid this problem.", ln); + sql_print_warning("No argument was provided to --log-bin and " + "neither --log-basename or --log-bin-index where " + "used; This may cause repliction to break when this " + "server acts as a master and has its hostname " + "changed! Please use '--log-basename=%s' or " + "'--log-bin=%s' to avoid this problem.", + opt_log_basename, ln); } if (ln == buf) { @@ -4497,6 +4507,11 @@ a file name for --log-bin-index option", opt_binlog_index_name); sql_print_error("Aria engine is not enabled or did not start. The Aria engine must be enabled to continue as mysqld was configured with --with-aria-tmp-tables"); unireg_abort(1); } + internal_tmp_table_max_key_length= maria_max_key_length(); + internal_tmp_table_max_key_segments= maria_max_key_segments(); +#else + internal_tmp_table_max_key_length= myisam_max_key_length(); + internal_tmp_table_max_key_segments= myisam_max_key_segments(); #endif tc_log= (total_ha_2pc > 1 ? (opt_bin_log ? @@ -5446,7 +5461,7 @@ void create_thread_to_handle_connection(THD *thd) thread_created++; threads.append(thd); DBUG_PRINT("info",(("creating thread %lu"), thd->thread_id)); - thd->prior_thr_create_utime= thd->start_utime= microsecond_interval_timer(); + thd->prior_thr_create_utime= microsecond_interval_timer(); if ((error= mysql_thread_create(key_thread_one_connection, &thd->real_id, &connection_attrib, handle_one_connection, @@ -5457,7 +5472,7 @@ void create_thread_to_handle_connection(THD *thd) ("Can't create thread to handle request (error %d)", error)); thread_count--; - thd->killed= THD::KILL_CONNECTION; // Safety + thd->killed= KILL_CONNECTION; // Safety mysql_mutex_unlock(&LOCK_thread_count); mysql_mutex_lock(&LOCK_connection_count); @@ -5469,7 +5484,7 @@ void create_thread_to_handle_connection(THD *thd) my_snprintf(error_message_buff, sizeof(error_message_buff), ER_THD(thd, ER_CANT_CREATE_THREAD), error); net_send_error(thd, ER_CANT_CREATE_THREAD, error_message_buff, NULL); - close_connection(thd); + close_connection(thd, ER_OUT_OF_RESOURCES); mysql_mutex_lock(&LOCK_thread_count); delete thd; mysql_mutex_unlock(&LOCK_thread_count); @@ -6543,6 +6558,10 @@ struct my_option my_long_options[]= &table_cache_size, &table_cache_size, 0, GET_ULONG, REQUIRED_ARG, TABLE_OPEN_CACHE_DEFAULT, 1, 512*1024L, 0, 1, 0}, #ifndef DBUG_OFF + {"debug-assert-on-error", 0, + "Do an assert in various functions if we get a fatal error", + &my_assert_on_error, &my_assert_on_error, + 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0}, {"debug-assert-if-crashed-table", 0, "Do an assert in handler::print_error() if we get a crashed table", &debug_assert_if_crashed_table, &debug_assert_if_crashed_table, @@ -7201,7 +7220,7 @@ static void usage(void) if (!default_collation_name) default_collation_name= (char*) default_charset_info->name; print_version(); - puts(ORACLE_WELCOME_COPYRIGHT_NOTICE("2000, 2010")); + puts(ORACLE_WELCOME_COPYRIGHT_NOTICE("2000, 2011")); puts("Starts the MySQL database server.\n"); printf("Usage: %s [OPTIONS]\n", my_progname); if (!opt_verbose) @@ -7969,6 +7988,19 @@ static int get_options(int *argc_ptr, char ***argv_ptr) my_disable_thr_alarm= opt_thread_alarm == 0; my_default_record_cache_size=global_system_variables.read_buff_size; + /* + Log mysys errors when we don't have a thd or thd->log_all_errors is set + (recovery) to the log. This is mainly useful for debugging strange system + errors. + */ + if (global_system_variables.log_warnings >= 10) + my_global_flags= MY_WME | ME_JUST_INFO; + /* Log all errors not handled by thd->handle_error() to my_message_sql() */ + if (global_system_variables.log_warnings >= 11) + my_global_flags|= ME_NOREFRESH; + if (my_assert_on_error) + debug_assert_if_crashed_table= 1; + global_system_variables.long_query_time= (ulonglong) (global_system_variables.long_query_time_double * 1e6); @@ -8012,6 +8044,8 @@ static int get_options(int *argc_ptr, char ***argv_ptr) if (!max_long_data_size_used) max_long_data_size= global_system_variables.max_allowed_packet; + /* Rember if max_user_connections was 0 at startup */ + max_user_connections_checking= global_system_variables.max_user_connections != 0; return 0; } @@ -8090,12 +8124,15 @@ fn_format_relative_to_data_home(char * to, const char *name, bool is_secure_file_path(char *path) { char buff1[FN_REFLEN], buff2[FN_REFLEN]; + size_t opt_secure_file_priv_len; /* All paths are secure if opt_secure_file_path is 0 */ if (!opt_secure_file_priv) return TRUE; + opt_secure_file_priv_len= strlen(opt_secure_file_priv); + if (strlen(path) >= FN_REFLEN) return FALSE; @@ -8111,7 +8148,21 @@ bool is_secure_file_path(char *path) return FALSE; } convert_dirname(buff2, buff1, NullS); - return is_prefix(buff2, opt_secure_file_priv) ? TRUE : FALSE; + if (!lower_case_file_system) + { + if (strncmp(opt_secure_file_priv, buff2, opt_secure_file_priv_len)) + return FALSE; + } + else + { + if (files_charset_info->coll->strnncoll(files_charset_info, + (uchar *) buff2, strlen(buff2), + (uchar *) opt_secure_file_priv, + opt_secure_file_priv_len, + TRUE)) + return FALSE; + } + return TRUE; } diff --git a/sql/mysqld.h b/sql/mysqld.h index 26dc47214f6..658d578a995 100644 --- a/sql/mysqld.h +++ b/sql/mysqld.h @@ -1,4 +1,4 @@ -/* Copyright 2006-2008 MySQL AB, 2008-2009 Sun Microsystems, Inc. +/* Copyright (c) 2006, 2011, Oracle and/or its affiliates. All rights reserved. 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 @@ -161,7 +161,7 @@ extern my_bool allow_slave_start; extern LEX_CSTRING reason_slave_blocked; extern ulong slave_trans_retries; extern uint slave_net_timeout; -extern uint max_user_connections; +extern int max_user_connections; extern ulong what_to_log,flush_time; extern ulong max_prepared_stmt_count, prepared_stmt_count; extern ulong open_files_limit; @@ -534,6 +534,11 @@ extern char *opt_log_basename; extern my_bool opt_master_verify_checksum; extern my_bool opt_slave_sql_verify_checksum; extern ulong binlog_checksum_options; +extern bool max_user_connections_checking; +extern ulong opt_binlog_dbug_fsync_sleep; + +extern uint internal_tmp_table_max_key_length; +extern uint internal_tmp_table_max_key_segments; extern uint volatile global_disable_checkpoint; extern my_bool opt_help, opt_thread_alarm; diff --git a/sql/mysqld_suffix.h b/sql/mysqld_suffix.h index c7ab212f2a2..fd515ac5998 100644 --- a/sql/mysqld_suffix.h +++ b/sql/mysqld_suffix.h @@ -1,7 +1,8 @@ #ifndef MYSQLD_SUFFIX_INCLUDED #define MYSQLD_SUFFIX_INCLUDED -/* Copyright (C) 2000-2004 MySQL AB +/* Copyright (c) 2000-2004, 2006, 2007 MySQL AB, 2009 Sun Microsystems, Inc. + Use is subject to license terms. 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 @@ -14,7 +15,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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ /** @file diff --git a/sql/opt_index_cond_pushdown.cc b/sql/opt_index_cond_pushdown.cc index cee96d88438..12a732176a5 100644 --- a/sql/opt_index_cond_pushdown.cc +++ b/sql/opt_index_cond_pushdown.cc @@ -83,15 +83,44 @@ bool uses_index_fields_only(Item *item, TABLE *tbl, uint keyno, case Item::FIELD_ITEM: { Item_field *item_field= (Item_field*)item; - if (item_field->field->table != tbl) + Field *field= item_field->field; + if (field->table != tbl) return TRUE; /* The below is probably a repetition - the first part checks the other two, but let's play it safe: */ - return item_field->field->part_of_key.is_set(keyno) && - item_field->field->type() != MYSQL_TYPE_GEOMETRY && - item_field->field->type() != MYSQL_TYPE_BLOB; + if(!field->part_of_key.is_set(keyno) || + field->type() == MYSQL_TYPE_GEOMETRY || + field->type() == MYSQL_TYPE_BLOB) + return FALSE; + KEY *key_info= tbl->key_info + keyno; + KEY_PART_INFO *key_part= key_info->key_part; + KEY_PART_INFO *key_part_end= key_part + key_info->key_parts; + for ( ; key_part < key_part_end; key_part++) + { + if (field->eq(key_part->field)) + return !(key_part->key_part_flag & HA_PART_KEY_SEG); + } + if ((tbl->file->ha_table_flags() & HA_PRIMARY_KEY_IN_READ_INDEX) && + tbl->s->primary_key != MAX_KEY && + tbl->s->primary_key != keyno) + { + key_info= tbl->key_info + tbl->s->primary_key; + key_part= key_info->key_part; + key_part_end= key_part + key_info->key_parts; + for ( ; key_part < key_part_end; key_part++) + { + /* + It does not make sense to use the fact that the engine can read in + a full field if the key if the index is built only over a part + of this field. + */ + if (field->eq(key_part->field)) + return !(key_part->key_part_flag & HA_PART_KEY_SEG); + } + } + return FALSE; } case Item::REF_ITEM: return uses_index_fields_only(item->real_item(), tbl, keyno, @@ -210,11 +239,9 @@ Item *make_cond_for_index(Item *cond, TABLE *table, uint keyno, } -Item *make_cond_remainder(Item *cond, bool exclude_index) +Item *make_cond_remainder(Item *cond, TABLE *table, uint keyno, + bool other_tbls_ok, bool exclude_index) { - if (exclude_index && cond->marker == ICP_COND_USES_INDEX_ONLY) - return 0; /* Already checked */ - if (cond->type() == Item::COND_ITEM) { table_map tbl_map= 0; @@ -228,7 +255,8 @@ Item *make_cond_remainder(Item *cond, bool exclude_index) Item *item; while ((item=li++)) { - Item *fix= make_cond_remainder(item, exclude_index); + Item *fix= make_cond_remainder(item, table, keyno, + other_tbls_ok, exclude_index); if (fix) { new_cond->argument_list()->push_back(fix); @@ -255,7 +283,8 @@ Item *make_cond_remainder(Item *cond, bool exclude_index) Item *item; while ((item=li++)) { - Item *fix= make_cond_remainder(item, FALSE); + Item *fix= make_cond_remainder(item, table, keyno, + other_tbls_ok, FALSE); if (!fix) return (COND*) 0; new_cond->argument_list()->push_back(fix); @@ -267,7 +296,14 @@ Item *make_cond_remainder(Item *cond, bool exclude_index) return new_cond; } } - return cond; + else + { + if (exclude_index && + uses_index_fields_only(cond, table, keyno, other_tbls_ok)) + return 0; + else + return cond; + } } @@ -288,30 +324,13 @@ void push_index_cond(JOIN_TAB *tab, uint keyno) { DBUG_ENTER("push_index_cond"); Item *idx_cond; - bool do_index_cond_pushdown= - ((tab->table->file->index_flags(keyno, 0, 1) & - HA_DO_INDEX_COND_PUSHDOWN) && - optimizer_flag(tab->join->thd, OPTIMIZER_SWITCH_INDEX_COND_PUSHDOWN)); - - /* - Do not try index condition pushdown on indexes which have partially-covered - columns. Unpacking from a column prefix into index tuple is not a supported - operation in some engines, see e.g. MySQL BUG#42991. - TODO: a better solution would be not to consider partially-covered columns - as parts of the index and still produce/check index condition for - fully-covered index columns. - */ - KEY *key_info= tab->table->key_info + keyno; - for (uint kp= 0; kp < key_info->key_parts; kp++) - { - if ((key_info->key_part[kp].key_part_flag & HA_PART_KEY_SEG)) - { - do_index_cond_pushdown= FALSE; - break; - } - } - if (do_index_cond_pushdown) + if ((tab->table->file->index_flags(keyno, 0, 1) & + HA_DO_INDEX_COND_PUSHDOWN) && + optimizer_flag(tab->join->thd, OPTIMIZER_SWITCH_INDEX_COND_PUSHDOWN) && + tab->join->thd->lex->sql_command != SQLCOM_UPDATE_MULTI && + tab->join->thd->lex->sql_command != SQLCOM_DELETE_MULTI && + tab->type != JT_CONST && tab->type != JT_SYSTEM) { DBUG_EXECUTE("where", print_where(tab->select_cond, "full cond", QT_ORDINARY);); @@ -356,7 +375,8 @@ void push_index_cond(JOIN_TAB *tab, uint keyno) tab->ref.disable_cache= TRUE; Item *row_cond= tab->idx_cond_fact_out ? - make_cond_remainder(tab->select_cond, TRUE) : + make_cond_remainder(tab->select_cond, tab->table, keyno, + tab->icp_other_tables_ok, TRUE) : tab->pre_idx_push_select_cond; DBUG_EXECUTE("where", diff --git a/sql/opt_range.cc b/sql/opt_range.cc index e5f544747e5..2a922541f72 100644 --- a/sql/opt_range.cc +++ b/sql/opt_range.cc @@ -1,4 +1,5 @@ -/* Copyright (c) 2000, 2010, Oracle and/or its affiliates. +/* Copyright (c) 2000, 2011, Oracle and/or its affiliates. + Copyright (c) 2010, 2011, Monty Program Ab 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 @@ -11,7 +12,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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ /* TODO: @@ -1163,10 +1164,10 @@ int SEL_IMERGE::and_sel_tree(RANGE_OPT_PARAM *param, SEL_TREE *tree, 2. In the second mode, when is_first_check_pass==FALSE : 2.1. For each rt_j in the imerge that can be ored (see the function - sel_trees_can_be_ored), but not must be ored, with rt the function - replaces rt_j for a range tree such that for each index for which - ranges are defined in both in rt_j and rt the tree contains the - result of oring of these ranges. + sel_trees_can_be_ored) with rt the function replaces rt_j for a + range tree such that for each index for which ranges are defined + in both in rt_j and rt the tree contains the result of oring of + these ranges. 2.2. In other cases the function does not produce any imerge. When is_first_check==TRUE the function returns FALSE in the parameter @@ -1190,7 +1191,7 @@ int SEL_IMERGE::or_sel_tree_with_checks(RANGE_OPT_PARAM *param, bool *is_last_check_pass) { bool was_ored= FALSE; - *is_last_check_pass= TRUE; + *is_last_check_pass= is_first_check_pass; SEL_TREE** or_tree = trees; for (uint i= 0; i < n_trees; i++, or_tree++) { @@ -1201,7 +1202,7 @@ int SEL_IMERGE::or_sel_tree_with_checks(RANGE_OPT_PARAM *param, { bool must_be_ored= sel_trees_must_be_ored(param, *or_tree, tree, ored_keys); - if (must_be_ored || !is_first_check_pass) + if (must_be_ored || !is_first_check_pass) { result_keys.clear_all(); result= *or_tree; @@ -1237,22 +1238,19 @@ int SEL_IMERGE::or_sel_tree_with_checks(RANGE_OPT_PARAM *param, { if (result_keys.is_clear_all()) result->type= SEL_TREE::ALWAYS; - *is_last_check_pass= TRUE; if ((result->type == SEL_TREE::MAYBE) || (result->type == SEL_TREE::ALWAYS)) return 1; /* SEL_TREE::IMPOSSIBLE is impossible here */ result->keys_map= result_keys; *or_tree= result; - if (is_first_check_pass) - return 0; was_ored= TRUE; } } if (was_ored) return 0; - if (!*is_last_check_pass && + if (is_first_check_pass && !*is_last_check_pass && !(tree= new SEL_TREE(tree, FALSE, param))) return (-1); return or_sel_tree(param, tree); @@ -8472,9 +8470,9 @@ tree_or(RANGE_OPT_PARAM *param,SEL_TREE *tree1,SEL_TREE *tree2) /* Build the imerge part of the tree for the formula (1) */ SEL_TREE *rt1= tree1; SEL_TREE *rt2= tree2; - if (!no_merges1) + if (no_merges1) rt1= new SEL_TREE(tree1, TRUE, param); - if (!no_merges2) + if (no_merges2) rt2= new SEL_TREE(tree2, TRUE, param); if (!rt1 || !rt2 || result->merges.push_back(imerge_from_ranges) || @@ -9169,6 +9167,13 @@ key_or(RANGE_OPT_PARAM *param, SEL_ARG *key1,SEL_ARG *key2) key2: [---] tmp: [---------] */ + if (key2->use_count) + { + SEL_ARG *key2_cpy= new SEL_ARG(*key2); + if (key2_cpy) + return 0; + key2= key2_cpy; + } key2->copy_max_to_min(tmp); continue; } diff --git a/sql/opt_range.h b/sql/opt_range.h index 38a47dffc30..cf8da1acb0d 100644 --- a/sql/opt_range.h +++ b/sql/opt_range.h @@ -1,4 +1,4 @@ -/* Copyright (C) 2000-2006 MySQL AB +/* Copyright (c) 2000, 2010, Oracle and/or its affiliates. All rights reserved. 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 @@ -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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ /* classes to use when handling where clause */ @@ -375,6 +375,12 @@ public: Table record buffer used by this quick select. */ uchar *record; + + virtual void replace_handler(handler *new_file) + { + DBUG_ASSERT(0); /* Only supported in QUICK_RANGE_SELECT */ + } + #ifndef DBUG_OFF /* Print quick select information to DBUG_FILE. Caller is responsible @@ -475,6 +481,7 @@ public: #ifndef DBUG_OFF void dbug_dump(int indent, bool verbose); #endif + virtual void replace_handler(handler *new_file) { file= new_file; } QUICK_SELECT_I *make_reverse(uint used_key_parts_arg); private: /* Default copy ctor used by QUICK_SELECT_DESC */ diff --git a/sql/opt_subselect.cc b/sql/opt_subselect.cc index c1fe8de51a4..0aa6fb7e913 100644 --- a/sql/opt_subselect.cc +++ b/sql/opt_subselect.cc @@ -209,6 +209,74 @@ end_sj_materialize(JOIN *join, JOIN_TAB *join_tab, bool end_of_records); /* + Check if Materialization strategy is allowed for given subquery predicate. + + @param thd Thread handle + @param in_subs The subquery predicate + @param child_select The select inside predicate (the function will + check it is the only one) + + @return TRUE - Materialization is applicable + FALSE - Otherwise +*/ + +bool is_materialization_applicable(THD *thd, Item_in_subselect *in_subs, + st_select_lex *child_select) +{ + st_select_lex_unit* parent_unit= child_select->master_unit(); + /* + Check if the subquery predicate can be executed via materialization. + The required conditions are: + 0. The materialization optimizer switch was set. + 1. Subquery is a single SELECT (not a UNION). + TODO: this is a limitation that can be fixed + 2. Subquery is not a table-less query. In this case there is no + point in materializing. + 2A The upper query is not a table-less SELECT ... FROM DUAL. We + can't do materialization for SELECT .. FROM DUAL because it + does not call setup_subquery_materialization(). We could make + SELECT ... FROM DUAL call that function but that doesn't seem + to be the case that is worth handling. + 3. Either the subquery predicate is a top-level predicate, or at + least one partial match strategy is enabled. If no partial match + strategy is enabled, then materialization cannot be used for + non-top-level queries because it cannot handle NULLs correctly. + 4. Subquery is non-correlated + TODO: + This condition is too restrictive (limitation). It can be extended to: + (Subquery is non-correlated || + Subquery is correlated to any query outer to IN predicate || + (Subquery is correlated to the immediate outer query && + Subquery !contains {GROUP BY, ORDER BY [LIMIT], + aggregate functions}) && subquery predicate is not under "NOT IN")) + + (*) The subquery must be part of a SELECT statement. The current + condition also excludes multi-table update statements. + A note about prepared statements: we want the if-branch to be taken on + PREPARE and each EXECUTE. The rewrites are only done once, but we need + select_lex->sj_subselects list to be populated for every EXECUTE. + + */ + if (optimizer_flag(thd, OPTIMIZER_SWITCH_MATERIALIZATION) && // 0 + !child_select->is_part_of_union() && // 1 + parent_unit->first_select()->leaf_tables.elements && // 2 + thd->lex->sql_command == SQLCOM_SELECT && // * + child_select->outer_select()->leaf_tables.elements && // 2A + subquery_types_allow_materialization(in_subs) && + (in_subs->is_top_level_item() || //3 + optimizer_flag(thd, + OPTIMIZER_SWITCH_PARTIAL_MATCH_ROWID_MERGE) || //3 + optimizer_flag(thd, + OPTIMIZER_SWITCH_PARTIAL_MATCH_TABLE_SCAN)) && //3 + !in_subs->is_correlated) //4 + { + return TRUE; + } + return FALSE; +} + + +/* Check if we need JOIN::prepare()-phase subquery rewrites and if yes, do them SYNOPSIS @@ -339,10 +407,10 @@ int check_and_do_in_subquery_rewrites(JOIN *join) !select_lex->is_part_of_union() && // 2 !select_lex->group_list.elements && !join->order && // 3 !join->having && !select_lex->with_sum_func && // 4 - thd->thd_marker.emb_on_expr_nest && // 5 + in_subs->emb_on_expr_nest && // 5 select_lex->outer_select()->join && // 6 parent_unit->first_select()->leaf_tables.elements && // 7 - !in_subs->in_strategy && // 8 + !in_subs->has_strategy() && // 8 select_lex->outer_select()->leaf_tables.elements && // 9 !((join->select_options | // 10 select_lex->outer_select()->join->select_options) // 10 @@ -352,7 +420,6 @@ int check_and_do_in_subquery_rewrites(JOIN *join) (void)subquery_types_allow_materialization(in_subs); - in_subs->emb_on_expr_nest= thd->thd_marker.emb_on_expr_nest; in_subs->is_flattenable_semijoin= TRUE; /* Register the subquery for further processing in flatten_subqueries() */ @@ -381,62 +448,17 @@ int check_and_do_in_subquery_rewrites(JOIN *join) */ if (in_subs) { - /* - Check if the subquery predicate can be executed via materialization. - The required conditions are: - 0. The materialization optimizer switch was set. - 1. Subquery is a single SELECT (not a UNION). - TODO: this is a limitation that can be fixed - 2. Subquery is not a table-less query. In this case there is no - point in materializing. - 2A The upper query is not a table-less SELECT ... FROM DUAL. We - can't do materialization for SELECT .. FROM DUAL because it - does not call setup_subquery_materialization(). We could make - SELECT ... FROM DUAL call that function but that doesn't seem - to be the case that is worth handling. - 3. Either the subquery predicate is a top-level predicate, or at - least one partial match strategy is enabled. If no partial match - strategy is enabled, then materialization cannot be used for - non-top-level queries because it cannot handle NULLs correctly. - 4. Subquery is non-correlated - TODO: - This condition is too restrictive (limitation). It can be extended to: - (Subquery is non-correlated || - Subquery is correlated to any query outer to IN predicate || - (Subquery is correlated to the immediate outer query && - Subquery !contains {GROUP BY, ORDER BY [LIMIT], - aggregate functions}) && subquery predicate is not under "NOT IN")) - - (*) The subquery must be part of a SELECT statement. The current - condition also excludes multi-table update statements. - A note about prepared statements: we want the if-branch to be taken on - PREPARE and each EXECUTE. The rewrites are only done once, but we need - select_lex->sj_subselects list to be populated for every EXECUTE. - - */ - if (optimizer_flag(thd, OPTIMIZER_SWITCH_MATERIALIZATION) && // 0 - !select_lex->is_part_of_union() && // 1 - parent_unit->first_select()->leaf_tables.elements && // 2 - thd->lex->sql_command == SQLCOM_SELECT && // * - select_lex->outer_select()->leaf_tables.elements && // 2A - subquery_types_allow_materialization(in_subs) && - (in_subs->is_top_level_item() || //3 - optimizer_flag(thd, - OPTIMIZER_SWITCH_PARTIAL_MATCH_ROWID_MERGE) || //3 - optimizer_flag(thd, - OPTIMIZER_SWITCH_PARTIAL_MATCH_TABLE_SCAN)) && //3 - !in_subs->is_correlated) //4 - { - in_subs->in_strategy|= SUBS_MATERIALIZATION; + if (is_materialization_applicable(thd, in_subs, select_lex)) + { + in_subs->add_strategy(SUBS_MATERIALIZATION); /* If the subquery is an AND-part of WHERE register for being processed with jtbm strategy */ - if (thd->thd_marker.emb_on_expr_nest == NO_JOIN_NEST && + if (in_subs->emb_on_expr_nest == NO_JOIN_NEST && optimizer_flag(thd, OPTIMIZER_SWITCH_SEMIJOIN)) { - in_subs->emb_on_expr_nest= thd->thd_marker.emb_on_expr_nest; in_subs->is_flattenable_semijoin= FALSE; if (!in_subs->is_registered_semijoin) { @@ -456,17 +478,18 @@ int check_and_do_in_subquery_rewrites(JOIN *join) possible. */ if (optimizer_flag(thd, OPTIMIZER_SWITCH_IN_TO_EXISTS) || - !in_subs->in_strategy) - { - in_subs->in_strategy|= SUBS_IN_TO_EXISTS; - } + !in_subs->has_strategy()) + in_subs->add_strategy(SUBS_IN_TO_EXISTS); } /* Check if max/min optimization applicable */ - if (allany_subs) - allany_subs->in_strategy|= (allany_subs->is_maxmin_applicable(join) ? - (SUBS_MAXMIN_INJECTED | SUBS_MAXMIN_ENGINE) : - SUBS_IN_TO_EXISTS); + if (allany_subs && !allany_subs->is_set_strategy()) + { + uchar strategy= (allany_subs->is_maxmin_applicable(join) ? + (SUBS_MAXMIN_INJECTED | SUBS_MAXMIN_ENGINE) : + SUBS_IN_TO_EXISTS); + allany_subs->add_strategy(strategy); + } /* Transform each subquery predicate according to its overloaded @@ -560,6 +583,16 @@ bool subquery_types_allow_materialization(Item_in_subselect *in_subs) if (inner->field_type() == MYSQL_TYPE_BLOB || inner->field_type() == MYSQL_TYPE_GEOMETRY) DBUG_RETURN(FALSE); + /* + Materialization also is unable to work when create_tmp_table() will + create a blob column because item->max_length is too big. + The following check is copied from Item::make_string_field(): + */ + if (inner->max_length / inner->collation.collation->mbmaxlen > + CONVERT_IF_BIGGER_TO_BLOB) + { + DBUG_RETURN(FALSE); + } break; case TIME_RESULT: if (mysql_type_to_time_type(outer->field_type()) != @@ -825,14 +858,14 @@ bool convert_join_subqueries_to_semijoins(JOIN *join) in_subq->unit->first_select()->join->table_count >= MAX_TABLES) break; if (convert_subq_to_sj(join, in_subq)) - DBUG_RETURN(TRUE); + goto restore_arena_and_fail; } else { if (join->table_count + 1 >= MAX_TABLES) break; if (convert_subq_to_jtbm(join, in_subq, &remove_item)) - DBUG_RETURN(TRUE); + goto restore_arena_and_fail; } if (remove_item) { @@ -841,7 +874,7 @@ bool convert_join_subqueries_to_semijoins(JOIN *join) Item *replace_me= in_subq->original_item(); if (replace_where_subcondition(join, tree, replace_me, new Item_int(1), FALSE)) - DBUG_RETURN(TRUE); /* purecov: inspected */ + goto restore_arena_and_fail; } } //skip_conversion: @@ -877,12 +910,6 @@ bool convert_join_subqueries_to_semijoins(JOIN *join) do_fix_fields)) DBUG_RETURN(TRUE); in_subq->substitution= NULL; -#if 0 - /* - Don't do the following, because the simplify_join() call is after this - call, and that call will save to prep_wher/prep_on_expr. - */ - /* If this is a prepared statement, repeat the above operation for prep_where (or prep_on_expr). Subquery-to-semijoin conversion is @@ -893,21 +920,26 @@ bool convert_join_subqueries_to_semijoins(JOIN *join) tree= (in_subq->emb_on_expr_nest == NO_JOIN_NEST)? &join->select_lex->prep_where : &(in_subq->emb_on_expr_nest->prep_on_expr); - - if (replace_where_subcondition(join, tree, replace_me, substitute, + /* + prep_on_expr/ prep_where may be NULL in some cases. + If that is the case, do nothing - simplify_joins() will copy + ON/WHERE expression into prep_on_expr/prep_where. + */ + if (*tree && replace_where_subcondition(join, tree, replace_me, substitute, FALSE)) DBUG_RETURN(TRUE); } -#endif /* Revert to the IN->EXISTS strategy in the rare case when the subquery could not be flattened. - TODO: This is a limitation done for simplicity. Such subqueries could also - be executed via materialization. In order to determine this, we should - re-run the test for materialization that was done in - check_and_do_in_subquery_rewrites. */ - in_subq->in_strategy= SUBS_IN_TO_EXISTS; + in_subq->reset_strategy(SUBS_IN_TO_EXISTS); + if (is_materialization_applicable(thd, in_subq, + in_subq->unit->first_select())) + { + in_subq->add_strategy(SUBS_MATERIALIZATION); + } + in_subq= li++; } @@ -915,6 +947,11 @@ bool convert_join_subqueries_to_semijoins(JOIN *join) thd->restore_active_arena(arena, &backup); join->select_lex->sj_subselects.empty(); DBUG_RETURN(FALSE); + +restore_arena_and_fail: + if (arena) + thd->restore_active_arena(arena, &backup); + DBUG_RETURN(TRUE); } @@ -985,7 +1022,6 @@ static bool replace_where_subcondition(JOIN *join, Item **expr, Item *old_cond, Item *new_cond, bool do_fix_fields) { - //Item **expr= (emb_nest == (TABLE_LIST*)1)? &join->conds : &emb_nest->on_expr; if (*expr == old_cond) { *expr= new_cond; @@ -1009,9 +1045,15 @@ static bool replace_where_subcondition(JOIN *join, Item **expr, } } } - // If we came here it means there were an error during prerequisites check. - DBUG_ASSERT(0); - return TRUE; + /* + We can come to here when + - we're doing replace operations on both on_expr and prep_on_expr + - on_expr is the same as prep_on_expr, or they share a sub-tree + (so, when we do replace in on_expr, we replace in prep_on_expr, too, + and when we try doing a replace in prep_on_expr, the item we wanted + to replace there has already been replaced) + */ + return FALSE; } static int subq_sj_candidate_cmp(Item_in_subselect* el1, Item_in_subselect* el2, @@ -1214,7 +1256,7 @@ static bool convert_subq_to_sj(JOIN *parent_join, Item_in_subselect *subq_pred) /* 3. Remove the original subquery predicate from the WHERE/ON */ // The subqueries were replaced for Item_int(1) earlier - subq_pred->in_strategy= SUBS_SEMI_JOIN; // for subsequent executions + subq_pred->reset_strategy(SUBS_SEMI_JOIN); // for subsequent executions /*TODO: also reset the 'with_subselect' there. */ /* n. Adjust the parent_join->table_count counter */ @@ -1388,8 +1430,9 @@ static bool convert_subq_to_jtbm(JOIN *parent_join, double read_time; DBUG_ENTER("convert_subq_to_jtbm"); - subq_pred->in_strategy &= ~SUBS_IN_TO_EXISTS; - subq_pred->optimize(&rows, &read_time); + subq_pred->set_strategy(SUBS_MATERIALIZATION); + if (subq_pred->optimize(&rows, &read_time)) + DBUG_RETURN(TRUE); subq_pred->jtbm_read_time= read_time; subq_pred->jtbm_record_count=rows; @@ -1760,6 +1803,9 @@ int pull_out_semijoin_tables(JOIN *join) All obtained information is saved and will be used by the main join optimization pass. + + NOTES + Because of Join::reoptimize(), this function may be called multiple times. RETURN FALSE Ok @@ -2134,6 +2180,17 @@ void advance_sj_state(JOIN *join, table_map remaining_tables, pos->sj_strategy= SJ_OPT_NONE; pos->prefix_dups_producing_tables= join->cur_dups_producing_tables; + + /* We're performing optimization inside SJ-Materialization nest */ + if (join->emb_sjm_nest) + { + pos->invalidate_firstmatch_prefix(); + pos->first_loosescan_table= MAX_TABLES; + pos->dupsweedout_tables= 0; + pos->sjm_scan_need_tables= 0; + return; + } + /* Initialize the state or copy it from prev. tables */ if (idx == join->const_tables) { @@ -2640,6 +2697,7 @@ ulonglong get_bound_sj_equalities(TABLE_LIST *sj_nest, { res |= 1ULL << i; } + i++; } return res; } @@ -2936,6 +2994,11 @@ bool setup_sj_materialization_part1(JOIN_TAB *sjm_tab) DBUG_ENTER("setup_sj_materialization"); JOIN_TAB *tab= sjm_tab->bush_children->start; TABLE_LIST *emb_sj_nest= tab->table->pos_in_table_list->embedding; + + /* Walk out of outer join nests until we reach the semi-join nest we're in */ + while (!emb_sj_nest->sj_mat_info) + emb_sj_nest= emb_sj_nest->embedding; + SJ_MATERIALIZATION_INFO *sjm= emb_sj_nest->sj_mat_info; THD *thd= tab->join->thd; /* First the calls come to the materialization function */ @@ -2984,6 +3047,9 @@ bool setup_sj_materialization_part2(JOIN_TAB *sjm_tab) DBUG_ENTER("setup_sj_materialization_part2"); JOIN_TAB *tab= sjm_tab->bush_children->start; TABLE_LIST *emb_sj_nest= tab->table->pos_in_table_list->embedding; + /* Walk out of outer join nests until we reach the semi-join nest we're in */ + while (!emb_sj_nest->sj_mat_info) + emb_sj_nest= emb_sj_nest->embedding; SJ_MATERIALIZATION_INFO *sjm= emb_sj_nest->sj_mat_info; THD *thd= tab->join->thd; uint i; @@ -3320,7 +3386,7 @@ TABLE *create_duplicate_weedout_tmp_table(THD *thd, bool using_unique_constraint=FALSE; bool use_packed_rows= FALSE; Field *field, *key_field; - uint blob_count, null_pack_length, null_count; + uint null_pack_length, null_count; uchar *null_flags; uchar *pos; DBUG_ENTER("create_duplicate_weedout_tmp_table"); @@ -3401,8 +3467,6 @@ TABLE *create_duplicate_weedout_tmp_table(THD *thd, share->keys_for_keyread.init(); share->keys_in_use.init(); - blob_count= 0; - /* Create the field */ { /* @@ -3819,6 +3883,8 @@ int setup_semijoin_dups_elimination(JOIN *join, ulonglong options, { /* We jump from the last table to the first one */ tab->loosescan_match_tab= tab + pos->n_sj_tables - 1; + for (uint j= i; j < i + pos->n_sj_tables; j++) + join->join_tab[j].inside_loosescan_range= TRUE; /* Calculate key length */ keylen= 0; @@ -3854,7 +3920,7 @@ int setup_semijoin_dups_elimination(JOIN *join, ulonglong options, if (j != join->const_tables && js_tab->use_quick != 2 && j <= no_jbuf_after && ((js_tab->type == JT_ALL && join_cache_level != 0) || - (join_cache_level > 4 && (tab->type == JT_REF || + (join_cache_level > 2 && (tab->type == JT_REF || tab->type == JT_EQ_REF)))) { /* Looks like we'll be using join buffer */ @@ -4444,8 +4510,8 @@ bool JOIN::choose_subquery_plan(table_map join_tables) } else return false; - - DBUG_ASSERT(in_subs->in_strategy); /* A strategy must be chosen earlier. */ + /* A strategy must be chosen earlier. */ + DBUG_ASSERT(in_subs->has_strategy()); DBUG_ASSERT(in_to_exists_where || in_to_exists_having); DBUG_ASSERT(!in_to_exists_where || in_to_exists_where->fixed); DBUG_ASSERT(!in_to_exists_having || in_to_exists_having->fixed); @@ -4455,8 +4521,8 @@ bool JOIN::choose_subquery_plan(table_map join_tables) strategies are possible and allowed by the user (checked during the prepare phase. */ - if (in_subs->in_strategy & SUBS_MATERIALIZATION && - in_subs->in_strategy & SUBS_IN_TO_EXISTS) + if (in_subs->test_strategy(SUBS_MATERIALIZATION) && + in_subs->test_strategy(SUBS_IN_TO_EXISTS)) { JOIN *outer_join; JOIN *inner_join= this; @@ -4480,20 +4546,6 @@ bool JOIN::choose_subquery_plan(table_map join_tables) if (outer_join && outer_join->table_count > 0) { /* - The index of the last JOIN_TAB in the outer JOIN where in_subs is - attached (pushed to). - */ - uint max_outer_join_tab_idx; - /* - Make_cond_for_table is called for predicates only in the WHERE/ON - clauses. In all other cases, predicates are not pushed to any - JOIN_TAB, and their join_tab_idx remains MAX_TABLES. Such predicates - are evaluated for each complete row of the outer join. - */ - max_outer_join_tab_idx= (in_subs->get_join_tab_idx() == MAX_TABLES) ? - outer_join->table_count - 1: - in_subs->get_join_tab_idx(); - /* TODO: Currently outer_lookup_keys is computed as the number of rows in the partial join including the JOIN_TAB where the IN predicate is @@ -4505,7 +4557,7 @@ bool JOIN::choose_subquery_plan(table_map join_tables) If the join order: t1, t2, the number of unique lookup keys is ~ to the number of unique values t2.c2 in the partial join t1 join t2. */ - outer_join->get_partial_cost_and_fanout(max_outer_join_tab_idx, + outer_join->get_partial_cost_and_fanout(in_subs->get_join_tab_idx(), table_map(-1), &dummy, &outer_lookup_keys); @@ -4574,9 +4626,9 @@ bool JOIN::choose_subquery_plan(table_map join_tables) /* C.3 Compare the costs and choose the cheaper strategy. */ if (materialize_strategy_cost >= in_exists_strategy_cost) - in_subs->in_strategy&= ~SUBS_MATERIALIZATION; + in_subs->set_strategy(SUBS_IN_TO_EXISTS); else - in_subs->in_strategy&= ~SUBS_IN_TO_EXISTS; + in_subs->set_strategy(SUBS_MATERIALIZATION); DBUG_PRINT("info", ("mat_strategy_cost: %.2f, mat_cost: %.2f, write_cost: %.2f, lookup_cost: %.2f", @@ -4597,7 +4649,7 @@ bool JOIN::choose_subquery_plan(table_map join_tables) otherwise use materialization. */ - if (in_subs->in_strategy & SUBS_MATERIALIZATION && + if (in_subs->test_strategy(SUBS_MATERIALIZATION) && in_subs->setup_mat_engine()) { /* @@ -4605,11 +4657,10 @@ bool JOIN::choose_subquery_plan(table_map join_tables) but it is not possible to execute it due to limitations in the implementation, fall back to IN-TO-EXISTS. */ - in_subs->in_strategy&= ~SUBS_MATERIALIZATION; - in_subs->in_strategy|= SUBS_IN_TO_EXISTS; + in_subs->set_strategy(SUBS_IN_TO_EXISTS); } - if (in_subs->in_strategy & SUBS_MATERIALIZATION) + if (in_subs->test_strategy(SUBS_MATERIALIZATION)) { /* Restore the original query plan used for materialization. */ if (reopt_result == REOPT_NEW_PLAN) @@ -4634,23 +4685,18 @@ bool JOIN::choose_subquery_plan(table_map join_tables) */ select_limit= in_subs->unit->select_limit_cnt; } - else if (in_subs->in_strategy & SUBS_IN_TO_EXISTS) + else if (in_subs->test_strategy(SUBS_IN_TO_EXISTS)) { if (reopt_result == REOPT_NONE && in_to_exists_where && const_tables != table_count) { /* - The subquery was not reoptimized either because the user allowed only - the IN-EXISTS strategy, or because materialization was not possible - based on semantic analysis. Cleanup the original plan and reoptimize. + The subquery was not reoptimized with the newly injected IN-EXISTS + conditions either because the user allowed only the IN-EXISTS strategy, + or because materialization was not possible based on semantic analysis. */ - for (uint i= 0; i < table_count; i++) - { - join_tab[i].keyuse= NULL; - join_tab[i].checked_keys.clear_all(); - } - if ((reopt_result= reoptimize(in_to_exists_where, join_tables, NULL)) == - REOPT_ERROR) + reopt_result= reoptimize(in_to_exists_where, join_tables, NULL); + if (reopt_result == REOPT_ERROR) return TRUE; } @@ -4720,7 +4766,7 @@ bool JOIN::choose_tableless_subquery_plan() { Item_in_subselect *in_subs; in_subs= (Item_in_subselect*) subs_predicate; - in_subs->in_strategy= SUBS_IN_TO_EXISTS; + in_subs->set_strategy(SUBS_IN_TO_EXISTS); if (in_subs->create_in_to_exists_cond(this) || in_subs->inject_in_to_exists_cond(this)) return TRUE; diff --git a/sql/opt_sum.cc b/sql/opt_sum.cc index 3aefa7c99d1..5962e7de706 100644 --- a/sql/opt_sum.cc +++ b/sql/opt_sum.cc @@ -1,4 +1,5 @@ -/* Copyright (c) 2000, 2010 Oracle and/or its affiliates. +/* Copyright (c) 2000, 2011 Oracle and/or its affiliates. + Copyright (c) 2010, 2011 Monty Program Ab 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 @@ -630,6 +631,8 @@ static bool matching_cond(bool max_fl, TABLE_REF *ref, KEY *keyinfo, /* Condition doesn't restrict the used table */ DBUG_RETURN(!cond->const_item()); } + else if (cond->is_expensive()) + DBUG_RETURN(FALSE); if (cond->type() == Item::COND_ITEM) { if (((Item_cond*) cond)->functype() == Item_func::COND_OR_FUNC) @@ -676,6 +679,8 @@ static bool matching_cond(bool max_fl, TABLE_REF *ref, KEY *keyinfo, case Item_func::GE_FUNC: break; case Item_func::BETWEEN: + if (((Item_func_between*) cond)->negated) + DBUG_RETURN(FALSE); between= 1; break; case Item_func::MULT_EQUAL_FUNC: diff --git a/sql/opt_table_elimination.cc b/sql/opt_table_elimination.cc index 9ab6e0e84d2..3de73c3d4cc 100644 --- a/sql/opt_table_elimination.cc +++ b/sql/opt_table_elimination.cc @@ -587,10 +587,8 @@ void eliminate_tables(JOIN *join) if (!join->outer_join) DBUG_VOID_RETURN; -#ifndef DBUG_OFF if (!optimizer_flag(thd, OPTIMIZER_SWITCH_TABLE_ELIMINATION)) DBUG_VOID_RETURN; /* purecov: inspected */ -#endif /* Find the tables that are referred to from WHERE/HAVING */ used_tables= (join->conds? join->conds->used_tables() : 0) | @@ -694,6 +692,8 @@ eliminate_tables_for_list(JOIN *join, List<TABLE_LIST> *join_list, { table_map outside_used_tables= tables_used_elsewhere | tables_used_on_left; + if (on_expr) + outside_used_tables |= on_expr->used_tables(); if (tbl->nested_join) { /* This is "... LEFT JOIN (join_nest) ON cond" */ diff --git a/sql/parse_file.cc b/sql/parse_file.cc index bffcfea3654..699aa7e2b95 100644 --- a/sql/parse_file.cc +++ b/sql/parse_file.cc @@ -1,4 +1,4 @@ -/* Copyright (C) 2004 MySQL AB, 2008-2009 Sun Microsystems, Inc +/* Copyright (c) 2004, 2010, Oracle and/or its affiliates. All rights reserved. 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 @@ -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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ /** @file diff --git a/sql/parse_file.h b/sql/parse_file.h index a075928c6d0..20e3051e671 100644 --- a/sql/parse_file.h +++ b/sql/parse_file.h @@ -1,5 +1,5 @@ /* -*- C++ -*- */ -/* Copyright (C) 2004 MySQL AB +/* Copyright (c) 2004, 2010, Oracle and/or its affiliates. All rights reserved. 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 @@ -12,7 +12,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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ #ifndef _PARSE_FILE_H_ #define _PARSE_FILE_H_ diff --git a/sql/partition_element.h b/sql/partition_element.h index f6816cfecf0..87f3d00e68c 100644 --- a/sql/partition_element.h +++ b/sql/partition_element.h @@ -1,7 +1,7 @@ #ifndef PARTITION_ELEMENT_INCLUDED #define PARTITION_ELEMENT_INCLUDED -/* Copyright 2005-2008 MySQL AB, 2008-2009 Sun Microsystems, Inc. +/* Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved. 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/partition_info.cc b/sql/partition_info.cc index 98b8e79dc6d..7c8a520879f 100644 --- a/sql/partition_info.cc +++ b/sql/partition_info.cc @@ -1,4 +1,4 @@ -/* Copyright (c) 2006, 2010 Oracle and/or its affiliates. All rights reserved. +/* Copyright (c) 2006, 2010, Oracle and/or its affiliates. All rights reserved. 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 @@ -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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ /* Some general useful functions */ diff --git a/sql/partition_info.h b/sql/partition_info.h index 6ae210d9574..e59d4ec8ba4 100644 --- a/sql/partition_info.h +++ b/sql/partition_info.h @@ -1,7 +1,7 @@ #ifndef PARTITION_INFO_INCLUDED #define PARTITION_INFO_INCLUDED -/* Copyright 2006-2008 MySQL AB, 2008-2009 Sun Microsystems, Inc. +/* Copyright (c) 2006, 2010, Oracle and/or its affiliates. All rights reserved. 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/password.c b/sql/password.c index 1b3aa8f356d..a7e599d4777 100644 --- a/sql/password.c +++ b/sql/password.c @@ -1,4 +1,5 @@ -/* Copyright (C) 2000-2006 MySQL AB +/* + Copyright (c) 2000, 2011, Oracle and/or its affiliates. All rights reserved. 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 @@ -11,7 +12,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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ /* password checking routines */ /***************************************************************************** diff --git a/sql/procedure.cc b/sql/procedure.cc index 66e09a42cb4..bdaced20586 100644 --- a/sql/procedure.cc +++ b/sql/procedure.cc @@ -1,4 +1,4 @@ -/* Copyright (C) 2000-2002, 2004-2005 MySQL AB +/* Copyright (c) 2000, 2010, Oracle and/or its affiliates. All rights reserved. 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 @@ -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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ /* Procedures (functions with changes output of select) */ diff --git a/sql/procedure.h b/sql/procedure.h index b0b5583dcb6..6870b97de57 100644 --- a/sql/procedure.h +++ b/sql/procedure.h @@ -1,7 +1,7 @@ #ifndef PROCEDURE_INCLUDED #define PROCEDURE_INCLUDED -/* Copyright (C) 2000-2005 MySQL AB +/* Copyright (c) 2000, 2010, Oracle and/or its affiliates. All rights reserved. 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 @@ -14,7 +14,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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ /* When using sql procedures */ diff --git a/sql/protocol.cc b/sql/protocol.cc index 606bf4ccb00..eb9c3e34dbf 100644 --- a/sql/protocol.cc +++ b/sql/protocol.cc @@ -1,5 +1,5 @@ -/* Copyright (c) 2000, 2011 Oracle and/or its affiliates. - Copyright (c) 2011 Monty Program Ab +/* Copyright (c) 2000, 2011, Oracle and/or its affiliates. + Copyright (c) 2011, Monty Program Ab 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 @@ -12,7 +12,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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ /** @file @@ -368,9 +368,8 @@ bool net_send_error_packet(THD *thd, uint sql_errno, const char *err, buff[]: sql_errno:2 + ('#':1 + SQLSTATE_LENGTH:5) + MYSQL_ERRMSG_SIZE:512 */ uint error; - uchar converted_err[MYSQL_ERRMSG_SIZE]; - uint32 converted_err_len; - uchar buff[2+1+SQLSTATE_LENGTH+MYSQL_ERRMSG_SIZE], *pos; + char converted_err[MYSQL_ERRMSG_SIZE]; + char buff[2+1+SQLSTATE_LENGTH+MYSQL_ERRMSG_SIZE], *pos; DBUG_ENTER("send_error_packet"); @@ -390,19 +389,16 @@ bool net_send_error_packet(THD *thd, uint sql_errno, const char *err, { /* The first # is to make the protocol backward compatible */ buff[2]= '#'; - pos= (uchar*) strmov((char*) buff+3, sqlstate); + pos= strmov(buff+3, sqlstate); } - converted_err_len= convert_error_message((char*)converted_err, - sizeof(converted_err), - thd->variables.character_set_results, - err, strlen(err), - system_charset_info, &error); - length= (uint) (strmake((char*) pos, (char*)converted_err, - MYSQL_ERRMSG_SIZE - 1) - (char*) buff); - err= (char*) buff; + convert_error_message(converted_err, sizeof(converted_err), + thd->variables.character_set_results, + err, strlen(err), system_charset_info, &error); + /* Converted error message is always null-terminated. */ + length= (uint) (strmake(pos, converted_err, MYSQL_ERRMSG_SIZE - 1) - buff); - DBUG_RETURN(net_write_command(net,(uchar) 255, (uchar*) "", 0, (uchar*) err, + DBUG_RETURN(net_write_command(net,(uchar) 255, (uchar*) "", 0, (uchar*) buff, length)); } @@ -1038,7 +1034,7 @@ bool Protocol_text::store(const char *from, size_t length, CHARSET_INFO *tocs= this->thd->variables.character_set_results; #ifndef DBUG_OFF DBUG_PRINT("info", ("Protocol_text::store field %u (%u): %.*s", field_pos, - field_count, (int) length, (length == 0? "" : from))); + field_count, (int) length, (length == 0 ? "" : from))); DBUG_ASSERT(field_pos < field_count); DBUG_ASSERT(field_types == 0 || field_types[field_pos] == MYSQL_TYPE_DECIMAL || diff --git a/sql/protocol.h b/sql/protocol.h index 7d99901ab44..d9bc48ce45d 100644 --- a/sql/protocol.h +++ b/sql/protocol.h @@ -1,7 +1,7 @@ #ifndef PROTOCOL_INCLUDED #define PROTOCOL_INCLUDED -/* Copyright (C) 2002-2006 MySQL AB +/* Copyright (c) 2002, 2010, Oracle and/or its affiliates. All rights reserved. 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 @@ -14,7 +14,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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ #ifdef USE_PRAGMA_INTERFACE #pragma interface /* gcc class implementation */ diff --git a/sql/records.cc b/sql/records.cc index d688ee675e7..1e74e6d7f30 100644 --- a/sql/records.cc +++ b/sql/records.cc @@ -1,4 +1,4 @@ -/* Copyright (C) 2000-2006 MySQL AB +/* Copyright (c) 2000, 2010, Oracle and/or its affiliates. All rights reserved. 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 @@ -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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ #ifdef USE_PRAGMA_INTERFACE #pragma implementation /* gcc class implementation */ @@ -71,7 +71,6 @@ void init_read_record_idx(READ_RECORD *info, THD *thd, TABLE *table, bzero((char*) info,sizeof(*info)); info->thd= thd; info->table= table; - info->file= table->file; info->record= table->record[0]; info->print_error= print_error; info->unlock_row= rr_unlock_row; @@ -181,7 +180,6 @@ bool init_read_record(READ_RECORD *info,THD *thd, TABLE *table, bzero((char*) info,sizeof(*info)); info->thd=thd; info->table=table; - info->file= table->file; info->forms= &info->table; /* Only one table */ if (table->s->tmp_table == NON_TRANSACTIONAL_TMP_TABLE && @@ -304,9 +302,9 @@ void end_read_record(READ_RECORD *info) { filesort_free_buffers(info->table,0); if (info->table->created) - (void) info->file->extra(HA_EXTRA_NO_CACHE); + (void) info->table->file->extra(HA_EXTRA_NO_CACHE); if (info->read_record != rr_quick) // otherwise quick_range does it - (void) info->file->ha_index_or_rnd_end(); + (void) info->table->file->ha_index_or_rnd_end(); info->table=0; } } @@ -365,7 +363,7 @@ static int rr_quick(READ_RECORD *info) static int rr_index_first(READ_RECORD *info) { - int tmp= info->file->ha_index_first(info->record); + int tmp= info->table->file->ha_index_first(info->record); info->read_record= rr_index; if (tmp) tmp= rr_handle_error(info, tmp); @@ -388,7 +386,7 @@ static int rr_index_first(READ_RECORD *info) static int rr_index_last(READ_RECORD *info) { - int tmp= info->file->ha_index_last(info->record); + int tmp= info->table->file->ha_index_last(info->record); info->read_record= rr_index_desc; if (tmp) tmp= rr_handle_error(info, tmp); @@ -414,7 +412,7 @@ static int rr_index_last(READ_RECORD *info) static int rr_index(READ_RECORD *info) { - int tmp= info->file->ha_index_next(info->record); + int tmp= info->table->file->ha_index_next(info->record); if (tmp) tmp= rr_handle_error(info, tmp); return tmp; @@ -439,7 +437,7 @@ static int rr_index(READ_RECORD *info) static int rr_index_desc(READ_RECORD *info) { - int tmp= info->file->ha_index_prev(info->record); + int tmp= info->table->file->ha_index_prev(info->record); if (tmp) tmp= rr_handle_error(info, tmp); return tmp; @@ -449,7 +447,7 @@ static int rr_index_desc(READ_RECORD *info) int rr_sequential(READ_RECORD *info) { int tmp; - while ((tmp= info->file->ha_rnd_next(info->record))) + while ((tmp= info->table->file->ha_rnd_next(info->record))) { /* rnd_next can return RECORD_DELETED for MyISAM when one thread is @@ -474,7 +472,7 @@ static int rr_from_tempfile(READ_RECORD *info) { if (my_b_read(info->io_cache,info->ref_pos,info->ref_length)) return -1; /* End of file */ - if (!(tmp= info->file->ha_rnd_pos(info->record,info->ref_pos))) + if (!(tmp= info->table->file->ha_rnd_pos(info->record,info->ref_pos))) break; /* The following is extremely unlikely to happen */ if (tmp == HA_ERR_RECORD_DELETED || @@ -525,7 +523,7 @@ static int rr_from_pointers(READ_RECORD *info) cache_pos= info->cache_pos; info->cache_pos+= info->ref_length; - if (!(tmp= info->file->ha_rnd_pos(info->record,cache_pos))) + if (!(tmp= info->table->file->ha_rnd_pos(info->record,cache_pos))) break; /* The following is extremely unlikely to happen */ @@ -658,7 +656,7 @@ static int rr_from_cache(READ_RECORD *info) record=uint3korr(position); position+=3; record_pos=info->cache+record*info->reclength; - if ((error=(int16) info->file->ha_rnd_pos(record_pos,info->ref_pos))) + if ((error=(int16) info->table->file->ha_rnd_pos(record_pos,info->ref_pos))) { record_pos[info->error_offset]=1; shortstore(record_pos,error); @@ -689,7 +687,7 @@ static int rr_cmp(uchar *a,uchar *b) if (a[4] != b[4]) return (int) a[4] - (int) b[4]; if (a[5] != b[5]) - return (int) a[1] - (int) b[5]; + return (int) a[5] - (int) b[5]; if (a[6] != b[6]) return (int) a[6] - (int) b[6]; return (int) a[7] - (int) b[7]; diff --git a/sql/records.h b/sql/records.h index fa9bfe3df59..57467d665d4 100644 --- a/sql/records.h +++ b/sql/records.h @@ -1,6 +1,6 @@ #ifndef SQL_RECORDS_H #define SQL_RECORDS_H -/* Copyright (C) 2008 Sun/MySQL +/* Copyright (c) 2008, 2010, Oracle and/or its affiliates. All rights reserved. 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 @@ -13,7 +13,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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ #ifdef USE_PRAGMA_INTERFACE #pragma interface /* gcc class implementation */ @@ -48,7 +48,7 @@ struct READ_RECORD typedef int (*Setup_func)(struct st_join_table*); TABLE *table; /* Head-form */ - handler *file; + //handler *file; TABLE **forms; /* head and ref forms */ Unlock_row_func unlock_row; Read_func read_record; diff --git a/sql/repl_failsafe.cc b/sql/repl_failsafe.cc index 9cf96e84928..e355be185db 100644 --- a/sql/repl_failsafe.cc +++ b/sql/repl_failsafe.cc @@ -1,4 +1,4 @@ -/* Copyright (C) 2001-2006 MySQL AB & Sasha, 2008-2009 Sun Microsystems, Inc +/* Copyright (c) 2001, 2011, Oracle and/or its affiliates. All rights reserved. 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 @@ -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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ /** @file diff --git a/sql/repl_failsafe.h b/sql/repl_failsafe.h index 2ba1f25c591..2cc031a462d 100644 --- a/sql/repl_failsafe.h +++ b/sql/repl_failsafe.h @@ -1,7 +1,7 @@ #ifndef REPL_FAILSAFE_INCLUDED #define REPL_FAILSAFE_INCLUDED -/* Copyright (C) 2001-2005 MySQL AB & Sasha, 2008-2009 Sun Microsystems, Inc +/* Copyright (c) 2001, 2011, Oracle and/or its affiliates. All rights reserved. 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 @@ -14,7 +14,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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ #ifdef HAVE_REPLICATION diff --git a/sql/replication.h b/sql/replication.h index 1c83025e1d6..8027c4830ec 100644 --- a/sql/replication.h +++ b/sql/replication.h @@ -1,4 +1,4 @@ -/* Copyright (C) 2008 MySQL AB, 2008-2009 Sun Microsystems, Inc +/* Copyright (c) 2008, 2010, Oracle and/or its affiliates. All rights reserved. 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 @@ -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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ #ifndef REPLICATION_H #define REPLICATION_H diff --git a/sql/rpl_constants.h b/sql/rpl_constants.h index 32fb4b8a7f2..3c605d24563 100644 --- a/sql/rpl_constants.h +++ b/sql/rpl_constants.h @@ -1,3 +1,19 @@ +/* Copyright (c) 2007 MySQL AB, 2008 Sun Microsystems, Inc. + Use is subject to license terms. + + 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 + the Free Software Foundation; version 2 of the License. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + 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 02110-1301 USA */ + #ifndef RPL_CONSTANTS_H #define RPL_CONSTANTS_H diff --git a/sql/rpl_filter.cc b/sql/rpl_filter.cc index a8ed9cfffe0..5f5473e09ab 100644 --- a/sql/rpl_filter.cc +++ b/sql/rpl_filter.cc @@ -1,4 +1,4 @@ -/* Copyright (C) 2000-2003 MySQL AB +/* Copyright (c) 2000, 2010, Oracle and/or its affiliates. All rights reserved. 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 @@ -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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ #include "sql_priv.h" #include "mysqld.h" // system_charset_info diff --git a/sql/rpl_filter.h b/sql/rpl_filter.h index 3a261db6754..d32fb36d6fb 100644 --- a/sql/rpl_filter.h +++ b/sql/rpl_filter.h @@ -1,4 +1,4 @@ -/* Copyright (C) 2000-2003 MySQL AB +/* Copyright (c) 2000, 2010, Oracle and/or its affiliates. All rights reserved. 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 @@ -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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ #ifndef RPL_FILTER_H #define RPL_FILTER_H diff --git a/sql/rpl_handler.cc b/sql/rpl_handler.cc index 1b1b91c63e9..9267190605c 100644 --- a/sql/rpl_handler.cc +++ b/sql/rpl_handler.cc @@ -1,4 +1,4 @@ -/* Copyright (C) 2008 MySQL AB +/* Copyright (c) 2008, 2010, Oracle and/or its affiliates. All rights reserved. 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 @@ -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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ #include "sql_priv.h" #include "unireg.h" diff --git a/sql/rpl_handler.h b/sql/rpl_handler.h index 9a181250efc..4d1bce45c54 100644 --- a/sql/rpl_handler.h +++ b/sql/rpl_handler.h @@ -1,4 +1,4 @@ -/* Copyright (C) 2008 MySQL AB +/* Copyright (c) 2008, 2010, Oracle and/or its affiliates. All rights reserved. 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 @@ -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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ #ifndef RPL_HANDLER_H #define RPL_HANDLER_H diff --git a/sql/rpl_injector.cc b/sql/rpl_injector.cc index 8f1f494b35a..dfa5ef95e67 100644 --- a/sql/rpl_injector.cc +++ b/sql/rpl_injector.cc @@ -1,4 +1,4 @@ -/* Copyright (C) 2006 MySQL AB +/* Copyright (c) 2006, 2010, Oracle and/or its affiliates. All rights reserved. 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/rpl_injector.h b/sql/rpl_injector.h index 3cb4fa8301e..f4790cc963a 100644 --- a/sql/rpl_injector.h +++ b/sql/rpl_injector.h @@ -1,4 +1,4 @@ -/* Copyright (C) 2006 MySQL AB +/* Copyright (c) 2006, 2010, Oracle and/or its affiliates. All rights reserved. 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/rpl_mi.cc b/sql/rpl_mi.cc index f491db25048..164173467f1 100644 --- a/sql/rpl_mi.cc +++ b/sql/rpl_mi.cc @@ -1,4 +1,5 @@ -/* Copyright (C) 2000-2003 MySQL AB, 2008-2009 Sun Microsystems, Inc +/* Copyright (c) 2006, 2010, Oracle and/or its affiliates. + Copyright (c) 2010, 2011, Monty Program Ab 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 @@ -11,7 +12,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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ #include <my_global.h> // For HAVE_REPLICATION #include "sql_priv.h" @@ -24,6 +25,8 @@ #define DEFAULT_CONNECT_RETRY 60 +static void init_master_log_pos(Master_info* mi); + Master_info::Master_info(bool is_slave_recovery) :Slave_reporting_capability("I/O"), ssl(0), ssl_verify_server_cert(1), fd(-1), io_thd(0), @@ -96,6 +99,16 @@ bool Master_info::shall_ignore_server_id(ulong s_id) != NULL; } +void Master_info::clear_in_memory_info(bool all) +{ + init_master_log_pos(this); + if (all) + { + port= MYSQL_PORT; + host[0] = 0; user[0] = 0; password[0] = 0; + } +} + void init_master_log_pos(Master_info* mi) { DBUG_ENTER("init_master_log_pos"); @@ -230,7 +243,7 @@ file '%s')", fname); } mi->fd = fd; - init_master_log_pos(mi); + mi->clear_in_memory_info(false); } else // file exists diff --git a/sql/rpl_mi.h b/sql/rpl_mi.h index d9ba21eccc7..54623577e0b 100644 --- a/sql/rpl_mi.h +++ b/sql/rpl_mi.h @@ -1,4 +1,4 @@ -/* Copyright (C) 2000-2003 MySQL AB, 2008-2009 Sun Microsystems, Inc +/* Copyright (c) 2006, 2010, Oracle and/or its affiliates. All rights reserved. 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 @@ -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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ #ifndef RPL_MI_H #define RPL_MI_H @@ -62,6 +62,7 @@ class Master_info : public Slave_reporting_capability Master_info(bool is_slave_recovery); ~Master_info(); bool shall_ignore_server_id(ulong s_id); + void clear_in_memory_info(bool all); /* the variables below are needed because we can change masters on the fly */ char master_log_name[FN_REFLEN]; @@ -119,7 +120,6 @@ class Master_info : public Slave_reporting_capability DYNAMIC_ARRAY ignore_server_ids; ulong master_id; }; -void init_master_log_pos(Master_info* mi); int init_master_info(Master_info* mi, const char* master_info_fname, const char* slave_info_fname, bool abort_if_no_master_info_file, diff --git a/sql/rpl_record.cc b/sql/rpl_record.cc index cc3d16bdf85..c893dc52587 100644 --- a/sql/rpl_record.cc +++ b/sql/rpl_record.cc @@ -1,4 +1,4 @@ -/* Copyright 2007 MySQL AB. +/* Copyright (c) 2007, 2010, Oracle and/or its affiliates. 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 @@ -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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ #include "sql_priv.h" #include "unireg.h" diff --git a/sql/rpl_record.h b/sql/rpl_record.h index b7c99c3955c..c857c07c33b 100644 --- a/sql/rpl_record.h +++ b/sql/rpl_record.h @@ -1,4 +1,4 @@ -/* Copyright 2007 MySQL AB. +/* Copyright (c) 2007, 2010, Oracle and/or its affiliates. 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 @@ -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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ #ifndef RPL_RECORD_H #define RPL_RECORD_H diff --git a/sql/rpl_record_old.cc b/sql/rpl_record_old.cc index 09d5bcacd62..b91006d46d1 100644 --- a/sql/rpl_record_old.cc +++ b/sql/rpl_record_old.cc @@ -1,3 +1,17 @@ +/* Copyright (c) 2007, 2010, Oracle and/or its affiliates. All rights reserved. + + 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 + the Free Software Foundation; version 2 of the License. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + 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 02110-1301 USA */ #include "sql_priv.h" #include "unireg.h" // REQUIRED by other includes diff --git a/sql/rpl_record_old.h b/sql/rpl_record_old.h index d0a9bbcb263..201f62b1946 100644 --- a/sql/rpl_record_old.h +++ b/sql/rpl_record_old.h @@ -1,4 +1,4 @@ -/* Copyright 2007 MySQL AB. +/* Copyright (c) 2007, 2010, Oracle and/or its affiliates. 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 @@ -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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ #ifndef RPL_RECORD_OLD_H #define RPL_RECORD_OLD_H diff --git a/sql/rpl_reporting.cc b/sql/rpl_reporting.cc index 051a3609019..f442f3a37c0 100644 --- a/sql/rpl_reporting.cc +++ b/sql/rpl_reporting.cc @@ -1,5 +1,5 @@ -/* Copyright (C) 2008-2009 Sun Microsystems, Inc +/* Copyright (c) 2007, 2010, Oracle and/or its affiliates. All rights reserved. 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 @@ -12,7 +12,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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ #include "sql_priv.h" #include "rpl_reporting.h" diff --git a/sql/rpl_reporting.h b/sql/rpl_reporting.h index 495c74170d2..2b5e0527b9b 100644 --- a/sql/rpl_reporting.h +++ b/sql/rpl_reporting.h @@ -1,4 +1,4 @@ -/* Copyright 2006-2008 MySQL AB, 2008-2009 Sun Microsystems, Inc. +/* Copyright (c) 2006, 2010, Oracle and/or its affiliates. All rights reserved. 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/rpl_rli.cc b/sql/rpl_rli.cc index 3b1f3180443..2e5202d7cb6 100644 --- a/sql/rpl_rli.cc +++ b/sql/rpl_rli.cc @@ -1,4 +1,4 @@ -/* Copyright (C) 2000-2003 MySQL AB, 2008-2009 Sun Microsystems, Inc +/* Copyright (c) 2006, 2011, Oracle and/or its affiliates. All rights reserved. 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 @@ -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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ #include "sql_priv.h" #include "unireg.h" // HAVE_* diff --git a/sql/rpl_rli.h b/sql/rpl_rli.h index 9cea56dc907..8ff70dff825 100644 --- a/sql/rpl_rli.h +++ b/sql/rpl_rli.h @@ -1,4 +1,4 @@ -/* Copyright (C) 2005 MySQL AB, 2008-2009 Sun Microsystems, Inc +/* Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved. 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 @@ -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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ #ifndef RPL_RLI_H #define RPL_RLI_H @@ -455,14 +455,14 @@ public: /** Save pointer to Annotate_rows event and switch on the - binlog_annotate_rows_events for this sql thread. + binlog_annotate_row_events for this sql thread. To be called when sql thread recieves an Annotate_rows event. */ inline void set_annotate_event(Annotate_rows_log_event *event) { free_annotate_event(); m_annotate_event= event; - sql_thd->variables.binlog_annotate_rows_events= 1; + sql_thd->variables.binlog_annotate_row_events= 1; } /** @@ -476,7 +476,7 @@ public: /** Delete saved Annotate_rows event (if any) and switch off the - binlog_annotate_rows_events for this sql thread. + binlog_annotate_row_events for this sql thread. To be called when sql thread has applied the last (i.e. with STMT_END_F flag) rbr event. */ @@ -484,7 +484,7 @@ public: { if (m_annotate_event) { - sql_thd->variables.binlog_annotate_rows_events= 0; + sql_thd->variables.binlog_annotate_row_events= 0; delete m_annotate_event; m_annotate_event= 0; } diff --git a/sql/rpl_tblmap.cc b/sql/rpl_tblmap.cc index 79c8dbf7ec5..b7ac1b2d091 100644 --- a/sql/rpl_tblmap.cc +++ b/sql/rpl_tblmap.cc @@ -1,4 +1,4 @@ -/* Copyright (C) 2005 MySQL AB +/* Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved. 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 @@ -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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ #include "sql_priv.h" #include "my_global.h" // HAVE_REPLICATION diff --git a/sql/rpl_tblmap.h b/sql/rpl_tblmap.h index 3d24a47d9ae..9fb1c4afbd7 100644 --- a/sql/rpl_tblmap.h +++ b/sql/rpl_tblmap.h @@ -1,4 +1,4 @@ -/* Copyright (C) 2005 MySQL AB +/* Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved. 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 @@ -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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ #ifndef TABLE_MAPPING_H #define TABLE_MAPPING_H diff --git a/sql/rpl_utility.cc b/sql/rpl_utility.cc index 23a62b9a532..4ab4542dd13 100644 --- a/sql/rpl_utility.cc +++ b/sql/rpl_utility.cc @@ -1,4 +1,4 @@ -/* Copyright (C) 2006 MySQL AB +/* Copyright (c) 2006, 2010, Oracle and/or its affiliates. All rights reserved. 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/rpl_utility.h b/sql/rpl_utility.h index 25f2a60bece..eebef266754 100644 --- a/sql/rpl_utility.h +++ b/sql/rpl_utility.h @@ -1,4 +1,4 @@ -/* Copyright (C) 2006 MySQL AB +/* Copyright (c) 2006, 2010, Oracle and/or its affiliates. All rights reserved. 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/scheduler.cc b/sql/scheduler.cc index 43d80137bac..f04fdef39f9 100644 --- a/sql/scheduler.cc +++ b/sql/scheduler.cc @@ -1,4 +1,4 @@ -/* Copyright (C) 2007 MySQL AB, 2008-2010 Sun Microsystems, Inc. +/* Copyright (c) 2007, 2011, Oracle and/or its affiliates. All rights reserved. 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 @@ -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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ /* Implementation for the thread scheduler diff --git a/sql/scheduler.h b/sql/scheduler.h index 7c9cafd8a71..03e1ad385c1 100644 --- a/sql/scheduler.h +++ b/sql/scheduler.h @@ -1,7 +1,7 @@ #ifndef SCHEDULER_INCLUDED #define SCHEDULER_INCLUDED -/* Copyright (C) 2007 MySQL AB +/* Copyright (c) 2007, 2011, Oracle and/or its affiliates. All rights reserved. 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 @@ -14,7 +14,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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ /* Classes for the thread scheduler diff --git a/sql/set_var.cc b/sql/set_var.cc index 3494d5b1694..895facee6e9 100644 --- a/sql/set_var.cc +++ b/sql/set_var.cc @@ -1,5 +1,5 @@ -/* Copyright (c) 2002, 2010, Oracle and/or its affiliates. - 2009-2010 Monty Program Ab +/* Copyright (c) 2002, 2011, Oracle and/or its affiliates. + Copyright (c) 2009, 2011, Monty Program Ab 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 @@ -12,7 +12,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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ #ifdef USE_PRAGMA_IMPLEMENTATION #pragma implementation @@ -308,7 +308,7 @@ void sys_var::do_deprecated_warning(THD *thd) bool throw_bounds_warning(THD *thd, const char *name, bool fixed, bool is_unsigned, longlong v) { - if (fixed || (!is_unsigned && v < 0)) + if (fixed) { char buf[22]; diff --git a/sql/set_var.h b/sql/set_var.h index 2c345f3af5f..e2e44ef65da 100644 --- a/sql/set_var.h +++ b/sql/set_var.h @@ -201,7 +201,8 @@ public: enum_var_type type; union ///< temp storage to hold a value between sys_var::check and ::update { - ulonglong ulonglong_value; ///< for all integer, set, enum sysvars + ulonglong ulonglong_value; ///< for unsigned integer, set, enum sysvars + longlong longlong_value; ///< for signed integer double double_value; ///< for Sys_var_double plugin_ref plugin; ///< for Sys_var_plugin Time_zone *time_zone; ///< for Sys_var_tz diff --git a/sql/sha2.cc b/sql/sha2.cc index 1a9de86f2e0..f2201974172 100644 --- a/sql/sha2.cc +++ b/sql/sha2.cc @@ -1,4 +1,4 @@ -/* Copyright (C) 2007 MySQL AB +/* Copyright (c) 2007, 2010, Oracle and/or its affiliates. All rights reserved. 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 @@ -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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ /** diff --git a/sql/share/CMakeLists.txt b/sql/share/CMakeLists.txt index f8fd51fda23..e0521bdd328 100644 --- a/sql/share/CMakeLists.txt +++ b/sql/share/CMakeLists.txt @@ -1,4 +1,5 @@ -# Copyright (c) 2006, 2010, Oracle and/or its affiliates. All rights reserved. +# Copyright (c) 2006 MySQL AB, 2009, 2010 Sun Microsystems, Inc. +# Use is subject to license terms. # # 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/share/charsets/cp1251.xml b/sql/share/charsets/cp1251.xml index 06ba8a5a4b9..4cd584c0bf5 100644 --- a/sql/share/charsets/cp1251.xml +++ b/sql/share/charsets/cp1251.xml @@ -3,7 +3,7 @@ <charsets> <copyright> - Copyright (C) 2003 MySQL AB + Copyright (c) 2003, 2010, Oracle and/or its affiliates. All rights reserved. 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 @@ -16,7 +16,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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA </copyright> <charset name="cp1251"> diff --git a/sql/share/errmsg-utf8.txt b/sql/share/errmsg-utf8.txt index 86700136d6c..e1c16b31b14 100644 --- a/sql/share/errmsg-utf8.txt +++ b/sql/share/errmsg-utf8.txt @@ -2494,10 +2494,10 @@ ER_TOO_BIG_SELECT 42000 cze "Zadan-Bý SELECT by procházel pÅ™ÃliÅ¡ mnoho záznamů a trval velmi dlouho. Zkontrolujte tvar WHERE a je-li SELECT v pořádku, použijte SET SQL_BIG_SELECTS=1" dan "SELECT ville undersøge for mange poster og ville sandsynligvis tage meget lang tid. Undersøg WHERE delen og brug SET SQL_BIG_SELECTS=1 hvis udtrykket er korrekt" nla "Het SELECT-statement zou te veel records analyseren en dus veel tijd in beslagnemen. Kijk het WHERE-gedeelte van de query na en kies SET SQL_BIG_SELECTS=1 als het stament in orde is." - eng "The SELECT would examine more than MAX_JOIN_SIZE rows; check your WHERE and use SET SQL_BIG_SELECTS=1 or SET SQL_MAX_JOIN_SIZE=# if the SELECT is okay" + eng "The SELECT would examine more than MAX_JOIN_SIZE rows; check your WHERE and use SET SQL_BIG_SELECTS=1 or SET MAX_JOIN_SIZE=# if the SELECT is okay" est "SELECT lause peab läbi vaatama suure hulga kirjeid ja võtaks tõenäoliselt liiga kaua aega. Tasub kontrollida WHERE klauslit ja vajadusel kasutada käsku SET SQL_BIG_SELECTS=1" fre "SELECT va devoir examiner beaucoup d'enregistrements ce qui va prendre du temps. Vérifiez la clause WHERE et utilisez SET SQL_BIG_SELECTS=1 si SELECT se passe bien" - ger "Die Ausführung des SELECT würde zu viele Datensätze untersuchen und wahrscheinlich sehr lange dauern. Bitte WHERE-Klausel überprüfen und gegebenenfalls SET SQL_BIG_SELECTS=1 oder SET SQL_MAX_JOIN_SIZE=# verwenden" + ger "Die Ausführung des SELECT würde zu viele Datensätze untersuchen und wahrscheinlich sehr lange dauern. Bitte WHERE-Klausel überprüfen und gegebenenfalls SET SQL_BIG_SELECTS=1 oder SET MAX_JOIN_SIZE=# verwenden" greek "Το SELECT θα εξετάσει μεγάλο αÏιθμό εγγÏαφών και πιθανώς θα καθυστεÏήσει. ΠαÏακαλώ εξετάστε τις παÏαμÎÏ„Ïους του WHERE και χÏησιμοποιείστε SET SQL_BIG_SELECTS=1 αν το SELECT είναι σωστό" hun "A SELECT tul sok rekordot fog megvizsgalni es nagyon sokaig fog tartani. Ellenorizze a WHERE-t es hasznalja a SET SQL_BIG_SELECTS=1 beallitast, ha a SELECT okay" ita "La SELECT dovrebbe esaminare troppi record e usare troppo tempo. Controllare la WHERE e usa SET SQL_BIG_SELECTS=1 se e` tutto a posto." @@ -4701,14 +4701,14 @@ ER_NOT_SUPPORTED_YET 42000 spa "Esta versión de MySQL no soporta todavia '%s'" swe "Denna version av MySQL kan ännu inte utföra '%s'" ER_MASTER_FATAL_ERROR_READING_BINLOG - nla "Kreeg fatale fout %d: '%-.128s' van master tijdens lezen van data uit binaire log" - eng "Got fatal error %d from master when reading data from binary log: '%-.128s'" - ger "Schwerer Fehler %d: '%-.128s vom Master beim Lesen des binären Logs" - ita "Errore fatale %d: '%-.128s' dal master leggendo i dati dal log binario" - por "Obteve fatal erro %d: '%-.128s' do master quando lendo dados do binary log" - rus "Получена неиÑÐ¿Ñ€Ð°Ð²Ð¸Ð¼Ð°Ñ Ð¾ÑˆÐ¸Ð±ÐºÐ° %d: '%-.128s' от головного Ñервера в процеÑÑе выборки данных из двоичного журнала" - spa "Recibió fatal error %d: '%-.128s' del master cuando leyendo datos del binary log" - swe "Fick fatalt fel %d: '%-.128s' frÃ¥n master vid läsning av binärloggen" + nla "Kreeg fatale fout %d: '%-.256s' van master tijdens lezen van data uit binaire log" + eng "Got fatal error %d from master when reading data from binary log: '%-.256s'" + ger "Schwerer Fehler %d: '%-.256s vom Master beim Lesen des binären Logs" + ita "Errore fatale %d: '%-.256s' dal master leggendo i dati dal log binario" + por "Obteve fatal erro %d: '%-.256s' do master quando lendo dados do binary log" + rus "Получена неиÑÐ¿Ñ€Ð°Ð²Ð¸Ð¼Ð°Ñ Ð¾ÑˆÐ¸Ð±ÐºÐ° %d: '%-.256s' от головного Ñервера в процеÑÑе выборки данных из двоичного журнала" + spa "Recibió fatal error %d: '%-.256s' del master cuando leyendo datos del binary log" + swe "Fick fatalt fel %d: '%-.256s' frÃ¥n master vid läsning av binärloggen" ER_SLAVE_IGNORED_TABLE eng "Slave SQL thread ignored the query because of replicate-*-table rules" ger "Slave-SQL-Thread hat die Abfrage aufgrund von replicate-*-table-Regeln ignoriert" @@ -5036,7 +5036,7 @@ ER_FEATURE_DISABLED ger "Das Feature '%s' ist ausgeschaltet, Sie müssen MySQL mit '%s' übersetzen, damit es verfügbar ist" por "O recurso '%s' foi desativado; você necessita MySQL construÃdo com '%s' para ter isto funcionando" spa "El recurso '%s' fue deshabilitado; usted necesita construir MySQL con '%s' para tener eso funcionando" - swe "'%s' är inte aktiverad; För att aktivera detta mÃ¥ste du bygga om MySQL med '%s' definerad" + swe "'%s' är inte aktiverad; För att aktivera detta mÃ¥ste du bygga om MySQL med '%s' definierad" ER_OPTION_PREVENTS_STATEMENT eng "The MySQL server is running with the %s option so it cannot execute this statement" ger "Der MySQL-Server läuft mit der Option %s und kann diese Anweisung deswegen nicht ausführen" @@ -5577,7 +5577,8 @@ ER_VIEW_OTHER_USER eng "You need the SUPER privilege for creation view with '%-.192s'@'%-.192s' definer" ger "Sie brauchen die SUPER-Berechtigung, um einen View mit dem Definierer '%-.192s'@'%-.192s' zu erzeugen" ER_NO_SUCH_USER - eng "The user specified as a definer ('%-.64s'@'%-.64s') does not exist" + eng "The user specified as a definer ('%-.64s'@'%-.64s') does not exist" + ger "Der als Definierer angegebene Benutzer ('%-.64s'@'%-.64s') existiert nicht" ER_FORBID_SCHEMA_CHANGE eng "Changing schema from '%-.192s' to '%-.192s' is not allowed." ger "Wechsel des Schemas von '%-.192s' auf '%-.192s' ist nicht erlaubt" @@ -5618,7 +5619,7 @@ ER_VIEW_RECURSIVE eng "`%-.192s`.`%-.192s` contains view recursion" ger "`%-.192s`.`%-.192s` enthält View-Rekursion" ER_NON_GROUPING_FIELD_USED 42000 - eng "non-grouping field '%-.192s' is used in %-.64s clause" + eng "Non-grouping field '%-.192s' is used in %-.64s clause" ger "In der %-.192s-Klausel wird das die Nicht-Gruppierungsspalte '%-.64s' verwendet" ER_TABLE_CANT_HANDLE_SPKEYS eng "The used table type doesn't support SPATIAL indexes" @@ -5645,15 +5646,20 @@ ER_NON_INSERTABLE_TABLE eng "The target table %-.100s of the %s is not insertable-into" ger "Die Zieltabelle %-.100s von %s ist nicht einfügbar" ER_ADMIN_WRONG_MRG_TABLE - eng "Table '%-.64s' is differently defined or of non-MyISAM type or doesn't exist" + eng "Table '%-.64s' is differently defined or of non-MyISAM type or doesn't exist" + ger "Tabelle '%-.64s' ist unterschiedlich definiert, nicht vom Typ MyISAM oder existiert nicht" ER_TOO_HIGH_LEVEL_OF_NESTING_FOR_SELECT - eng "Too high level of nesting for select" + eng "Too high level of nesting for select" + ger "Zu tief verschachtelte SELECT-Anweisungen" ER_NAME_BECOMES_EMPTY - eng "Name '%-.64s' has become ''" + eng "Name '%-.64s' has become ''" + ger "Name '%-.64s' wurde zu ''" ER_AMBIGUOUS_FIELD_TERM - eng "First character of the FIELDS TERMINATED string is ambiguous; please use non-optional and non-empty FIELDS ENCLOSED BY" + eng "First character of the FIELDS TERMINATED string is ambiguous; please use non-optional and non-empty FIELDS ENCLOSED BY" + ger "Das erste Zeichen der Zeichenkette FIELDS TERMINATED ist mehrdeutig; bitte benutzen Sie nicht optionale und nicht leere FIELDS ENCLOSED BY" ER_FOREIGN_SERVER_EXISTS - eng "The foreign server, %s, you are trying to create already exists." + eng "The foreign server, %s, you are trying to create already exists." + ger "Der entfernte Server %s, den Sie versuchen zu erzeugen, existiert schon." ER_FOREIGN_SERVER_DOESNT_EXIST eng "The foreign server name you are trying to reference does not exist. Data source error: %-.64s" ger "Die externe Verbindung, auf die Sie zugreifen wollen, existiert nicht. Datenquellenfehlermeldung: %-.64s" @@ -5678,8 +5684,8 @@ ER_PARTITION_SUBPARTITION_ERROR swe "Subpartitioner kan bara vara hash och key partitioner" ER_PARTITION_SUBPART_MIX_ERROR eng "Must define subpartitions on all partitions if on one partition" - ger "Unterpartitionen können nur Hash- oder Key-Partitionen sein" - swe "Subpartitioner mÃ¥ste definieras pÃ¥ alla partitioner om pÃ¥ en" + ger "Wenn Sie Unterpartitionen auf einer Partition definieren, müssen Sie das für alle Partitionen tun" + swe "Subpartitioner mÃ¥ste definieras pÃ¥ alla partitioner om pÃ¥ en" ER_PARTITION_WRONG_NO_PART_ERROR eng "Wrong number of partitions defined, mismatch with previous setting" ger "Falsche Anzahl von Partitionen definiert, stimmt nicht mit vorherigen Einstellungen überein" @@ -5854,7 +5860,7 @@ ER_CREATE_FILEGROUP_FAILED ger "Anlegen von %s fehlgeschlagen" ER_DROP_FILEGROUP_FAILED eng "Failed to drop %s" - ger "Löschen (drop) von %s fehlgeschlagen" + ger "Löschen von %s fehlgeschlagen" ER_TABLESPACE_AUTO_EXTEND_ERROR eng "The handler doesn't support autoextend of tablespaces" ger "Der Handler unterstützt keine automatische Erweiterung (Autoextend) von Tablespaces" @@ -5898,7 +5904,8 @@ ER_EVENT_ENDS_BEFORE_STARTS eng "ENDS is either invalid or before STARTS" ger "ENDS ist entweder ungültig oder liegt vor STARTS" ER_EVENT_EXEC_TIME_IN_THE_PAST - eng "Event execution time is in the past. Event has been disabled" + eng "Event execution time is in the past. Event has been disabled" + ger "Ausführungszeit des Events liegt in der Vergangenheit. Event wurde deaktiviert" ER_EVENT_OPEN_TABLE_FAILED eng "Failed to open mysql.event" ger "Öffnen von mysql.event fehlgeschlagen" @@ -5925,7 +5932,7 @@ ER_EVENT_DATA_TOO_LONG ger "Daten der Spalte '%s' zu lang" ER_DROP_INDEX_FK eng "Cannot drop index '%-.192s': needed in a foreign key constraint" - ger "Kann Index '%-.192s' nicht löschen: wird für einen Fremdschlüssel benötigt" + ger "Kann Index '%-.192s' nicht löschen: wird für eine Fremdschlüsselbeschränkung benötigt" # When using this error message, use the ER_WARN_DEPRECATED_SYNTAX error # code. ER_WARN_DEPRECATED_SYNTAX_WITH_VER @@ -5936,10 +5943,10 @@ ER_CANT_WRITE_LOCK_LOG_TABLE ger "Eine Log-Tabelle kann nicht schreibgesperrt werden. Es ist ohnehin nur Lesezugriff möglich" ER_CANT_LOCK_LOG_TABLE eng "You can't use locks with log tables." - ger "Log-Tabellen können nicht mit normalen Lesesperren gesperrt werden. Verwenden Sie statt dessen READ LOCAL" + ger "Log-Tabellen können nicht gesperrt werden." ER_FOREIGN_DUPLICATE_KEY 23000 S1009 eng "Upholding foreign key constraints for table '%.192s', entry '%-.192s', key %d would lead to a duplicate entry" - ger "Aufrechterhalten der Fremdschlüssel-Constraints für Tabelle '%.192s', Eintrag '%-.192s', Schlüssel %d würde zu einem doppelten Eintrag führen" + ger "Aufrechterhalten der Fremdschlüssel-Beschränkungen für Tabelle '%.192s', Eintrag '%-.192s', Schlüssel %d würde zu einem doppelten Eintrag führen" ER_COL_COUNT_DOESNT_MATCH_PLEASE_UPDATE eng "Column count of mysql.%s is wrong. Expected %d, found %d. Created with MySQL %d, now running %d. Please use mysql_upgrade to fix this error." ger "Spaltenanzahl von mysql.%s falsch. %d erwartet, aber %d erhalten. Erzeugt mit MySQL %d, jetzt unter %d. Bitte benutzen Sie mysql_upgrade, um den Fehler zu beheben" @@ -5995,6 +6002,7 @@ ER_CANT_ACTIVATE_LOG ger "Kann Logdatei '%-.64s' nicht aktivieren" ER_RBR_NOT_AVAILABLE eng "The server was not built with row-based replication" + ger "Der Server wurde nicht mit zeilenbasierter Replikation gebaut" ER_BASE64_DECODE_ERROR eng "Decoding of base64 string failed" swe "Avkodning av base64 sträng misslyckades" @@ -6016,7 +6024,7 @@ ER_BAD_LOG_STATEMENT ger "Sie können eine Logtabelle nicht '%s', wenn Loggen angeschaltet ist" ER_CANT_RENAME_LOG_TABLE eng "Cannot rename '%s'. When logging enabled, rename to/from log table must rename two tables: the log table to an archive table and another table back to '%s'" - ger "Kann '%s' nicht umbenennen. Wenn Loggen angeschaltet ist, müssen beim Umbenennen zu/von einer Logtabelle zwei Tabellen angegeben werden: die Logtabelle zu einer Archivtabelle und eine weitere Tabelle zurück zu '%s'" + ger "Kann '%s' nicht umbenennen. Wenn Loggen angeschaltet ist, müssen zwei Tabellen umbenannt werden: die Logtabelle zu einer Archivtabelle, und eine weitere Tabelle zu '%s'" ER_WRONG_PARAMCOUNT_TO_NATIVE_FCT 42000 eng "Incorrect parameter count in the call to native function '%-.192s'" ger "Falsche Anzahl von Parametern beim Aufruf der nativen Funktion '%-.192s'" @@ -6057,206 +6065,240 @@ ER_DUP_ENTRY_WITH_KEY_NAME 23000 S1009 swe "Dubbel nyckel '%-.64s' för nyckel '%-.192s'" ukr "Дублюючий Ð·Ð°Ð¿Ð¸Ñ '%-.64s' Ð´Ð»Ñ ÐºÐ»ÑŽÑ‡Ð° '%-.192s'" ER_BINLOG_PURGE_EMFILE - eng "Too many files opened, please execute the command again" - ger "Zu viele offene Dateien, bitte führen Sie den Befehl noch einmal aus" + eng "Too many files opened, please execute the command again" + ger "Zu viele offene Dateien, bitte führen Sie den Befehl noch einmal aus" ER_EVENT_CANNOT_CREATE_IN_THE_PAST - eng "Event execution time is in the past and ON COMPLETION NOT PRESERVE is set. The event was dropped immediately after creation." + eng "Event execution time is in the past and ON COMPLETION NOT PRESERVE is set. The event was dropped immediately after creation." + ger "Ausführungszeit des Events liegt in der Vergangenheit, und es wurde ON COMPLETION NOT PRESERVE gesetzt. Das Event wurde unmittelbar nach Erzeugung gelöscht." ER_EVENT_CANNOT_ALTER_IN_THE_PAST - eng "Event execution time is in the past and ON COMPLETION NOT PRESERVE is set. The event was dropped immediately after creation." + eng "Event execution time is in the past and ON COMPLETION NOT PRESERVE is set. The event was dropped immediately after creation." + ger "Ausführungszeit des Events liegt in der Vergangenheit, und es wurde ON COMPLETION NOT PRESERVE gesetzt. Das Event wurde unmittelbar nach Erzeugung gelöscht." ER_SLAVE_INCIDENT - eng "The incident %s occured on the master. Message: %-.64s" + eng "The incident %s occured on the master. Message: %-.64s" + ger "Der Vorfall %s passierte auf dem Master. Meldung: %-.64s" ER_NO_PARTITION_FOR_GIVEN_VALUE_SILENT - eng "Table has no partition for some existing values" + eng "Table has no partition for some existing values" + ger "Tabelle hat für einige bestehende Werte keine Partition" ER_BINLOG_UNSAFE_STATEMENT - eng "Unsafe statement written to the binary log using statement format since BINLOG_FORMAT = STATEMENT. %s" + eng "Unsafe statement written to the binary log using statement format since BINLOG_FORMAT = STATEMENT. %s" + swe "Detta är inte säkert att logga i statement-format, för BINLOG_FORMAT = STATEMENT. %s" + ger "Unsichere Anweisung ins Binärlog geschrieben, weil Anweisungsformat BINLOG_FORMAT = STATEMENT. %s" ER_SLAVE_FATAL_ERROR - eng "Fatal error: %s" + eng "Fatal error: %s" + ger "Fataler Fehler: %s" ER_SLAVE_RELAY_LOG_READ_FAILURE - eng "Relay log read failure: %s" + eng "Relay log read failure: %s" + ger "Relaylog-Lesefehler: %s" ER_SLAVE_RELAY_LOG_WRITE_FAILURE - eng "Relay log write failure: %s" + eng "Relay log write failure: %s" + ger "Relaylog-Schreibfehler: %s" ER_SLAVE_CREATE_EVENT_FAILURE - eng "Failed to create %s" + eng "Failed to create %s" + ger "Erzeugen von %s fehlgeschlagen" ER_SLAVE_MASTER_COM_FAILURE - eng "Master command %s failed: %s" + eng "Master command %s failed: %s" + ger "Master-Befehl %s fehlgeschlagen: %s" ER_BINLOG_LOGGING_IMPOSSIBLE - eng "Binary logging not possible. Message: %s" - + eng "Binary logging not possible. Message: %s" + ger "Binärlogging nicht möglich. Meldung: %s" ER_VIEW_NO_CREATION_CTX eng "View `%-.64s`.`%-.64s` has no creation context" + ger "View `%-.64s`.`%-.64s` hat keinen Erzeugungskontext" ER_VIEW_INVALID_CREATION_CTX eng "Creation context of view `%-.64s`.`%-.64s' is invalid" - + ger "Erzeugungskontext des Views`%-.64s`.`%-.64s' ist ungültig" ER_SR_INVALID_CREATION_CTX eng "Creation context of stored routine `%-.64s`.`%-.64s` is invalid" - + ger "Erzeugungskontext der gespeicherten Routine`%-.64s`.`%-.64s` ist ungültig" ER_TRG_CORRUPTED_FILE eng "Corrupted TRG file for table `%-.64s`.`%-.64s`" + ger "Beschädigte TRG-Datei für Tabelle `%-.64s`.`%-.64s`" ER_TRG_NO_CREATION_CTX eng "Triggers for table `%-.64s`.`%-.64s` have no creation context" + ger "Trigger für Tabelle `%-.64s`.`%-.64s` haben keinen Erzeugungskontext" ER_TRG_INVALID_CREATION_CTX eng "Trigger creation context of table `%-.64s`.`%-.64s` is invalid" - + ger "Trigger-Erzeugungskontext der Tabelle `%-.64s`.`%-.64s` ist ungültig" ER_EVENT_INVALID_CREATION_CTX eng "Creation context of event `%-.64s`.`%-.64s` is invalid" - + ger "Erzeugungskontext des Events `%-.64s`.`%-.64s` ist ungültig" ER_TRG_CANT_OPEN_TABLE eng "Cannot open table for trigger `%-.64s`.`%-.64s`" - + ger "Kann Tabelle für den Trigger `%-.64s`.`%-.64s` nicht öffnen" ER_CANT_CREATE_SROUTINE eng "Cannot create stored routine `%-.64s`. Check warnings" + ger "Kann gespeicherte Routine `%-.64s` nicht erzeugen. Beachten Sie die Warnungen" ER_NEVER_USED eng "Ambiguous slave modes combination. %s" - + ger "Mehrdeutige Kombination von Slave-Modi. %s" ER_NO_FORMAT_DESCRIPTION_EVENT_BEFORE_BINLOG_STATEMENT eng "The BINLOG statement of type `%s` was not preceded by a format description BINLOG statement." + ger "Der BINLOG-Anweisung vom Typ `%s` ging keine BINLOG-Anweisung zur Formatbeschreibung voran." ER_SLAVE_CORRUPT_EVENT eng "Corrupted replication event was detected" - + ger "Beschädigtes Replikationsereignis entdeckt" ER_LOAD_DATA_INVALID_COLUMN eng "Invalid column reference (%-.64s) in LOAD DATA" - -ER_LOG_PURGE_NO_FILE + ger "Ungültige Spaltenreferenz (%-.64s) bei LOAD DATA" +ER_LOG_PURGE_NO_FILE eng "Being purged log %s was not found" - + ger "Zu bereinigende Logdatei %s wurde nicht gefunden" ER_XA_RBTIMEOUT XA106 - eng "XA_RBTIMEOUT: Transaction branch was rolled back: took too long" - + eng "XA_RBTIMEOUT: Transaction branch was rolled back: took too long" + ger "XA_RBTIMEOUT: Transaktionszweig wurde zurückgerollt: Zeitüberschreitung" ER_XA_RBDEADLOCK XA102 - eng "XA_RBDEADLOCK: Transaction branch was rolled back: deadlock was detected" - + eng "XA_RBDEADLOCK: Transaction branch was rolled back: deadlock was detected" + ger "XA_RBDEADLOCK: Transaktionszweig wurde zurückgerollt: Deadlock entdeckt" ER_NEED_REPREPARE eng "Prepared statement needs to be re-prepared" - -ER_DELAYED_NOT_SUPPORTED + ger "Vorbereitete Anweisungen müssen noch einmal vorbereitet werden" +ER_DELAYED_NOT_SUPPORTED eng "DELAYED option not supported for table '%-.192s'" - + ger "Die DELAYED-Option wird für Tabelle '%-.192s' nicht unterstützt" WARN_NO_MASTER_INFO eng "The master info structure does not exist" - + ger "Die Master-Info-Struktur existiert nicht" WARN_OPTION_IGNORED eng "<%-.64s> option ignored" - + ger "Option <%-.64s> ignoriert" WARN_PLUGIN_DELETE_BUILTIN eng "Built-in plugins cannot be deleted" - + ger "Eingebaute Plugins können nicht gelöscht werden" WARN_PLUGIN_BUSY eng "Plugin is busy and will be uninstalled on shutdown" - + ger "Plugin wird verwendet und wird erst beim Herunterfahren deinstalliert" ER_VARIABLE_IS_READONLY eng "%s variable '%s' is read-only. Use SET %s to assign the value" - + ger "%s Variable '%s' ist nur lesbar. Benutzen Sie SET %s, um einen Wert zuzuweisen" ER_WARN_ENGINE_TRANSACTION_ROLLBACK eng "Storage engine %s does not support rollback for this statement. Transaction rolled back and must be restarted" - + ger "Speicher-Engine %s unterstützt für diese Anweisung kein Rollback. Transaktion wurde zurückgerollt und muss neu gestartet werden" ER_SLAVE_HEARTBEAT_FAILURE eng "Unexpected master's heartbeat data: %s" + ger "Unerwartete Daten vom Heartbeat des Masters: %s" ER_SLAVE_HEARTBEAT_VALUE_OUT_OF_RANGE eng "The requested value for the heartbeat period is either negative or exceeds the maximum allowed (%s seconds)." - ER_NDB_REPLICATION_SCHEMA_ERROR - eng "Bad schema for mysql.ndb_replication table. Message: %-.64s" + eng "Bad schema for mysql.ndb_replication table. Message: %-.64s" + ger "Fehlerhaftes Schema für mysql.ndb_replication table. Meldung: %-.64s" ER_CONFLICT_FN_PARSE_ERROR - eng "Error in parsing conflict function. Message: %-.64s" + eng "Error in parsing conflict function. Message: %-.64s" + ger "Fehler beim Parsen einer Konflikt-Funktion. Meldung: %-.64s" ER_EXCEPTIONS_WRITE_ERROR - eng "Write to exceptions table failed. Message: %-.128s"" - + eng "Write to exceptions table failed. Message: %-.128s"" + ger "Schreiben in Ausnahme-Tabelle fehlgeschlagen. Meldung: %-.128s"" ER_TOO_LONG_TABLE_COMMENT eng "Comment for table '%-.64s' is too long (max = %lu)" por "Comentário para a tabela '%-.64s' é longo demais (max = %lu)" - + ger "Kommentar für Tabelle '%-.64s' ist zu lang (max = %lu)" ER_TOO_LONG_FIELD_COMMENT eng "Comment for field '%-.64s' is too long (max = %lu)" por "Comentário para o campo '%-.64s' é longo demais (max = %lu)" - + ger "Kommentar für Feld '%-.64s' ist zu lang (max = %lu)" ER_FUNC_INEXISTENT_NAME_COLLISION 42000 eng "FUNCTION %s does not exist. Check the 'Function Name Parsing and Resolution' section in the Reference Manual" - + ger "FUNCTION %s existiert nicht. Erläuterungen im Abschnitt 'Function Name Parsing and Resolution' im Referenzhandbuch" # When updating these, please update EXPLAIN_FILENAME_MAX_EXTRA_LENGTH in # sql_table.h with the new maximal additional length for explain_filename. ER_DATABASE_NAME eng "Database" swe "Databas" + ger "Datenbank" ER_TABLE_NAME eng "Table" swe "Tabell" + ger "Tabelle" ER_PARTITION_NAME eng "Partition" swe "Partition" + ger "Partition" ER_SUBPARTITION_NAME eng "Subpartition" swe "Subpartition" + ger "Unterpartition" ER_TEMPORARY_NAME eng "Temporary" swe "Temporär" + ger "Temporär" ER_RENAMED_NAME eng "Renamed" swe "Namnändrad" + ger "Umbenannt" ER_TOO_MANY_CONCURRENT_TRXS eng "Too many active concurrent transactions" - + ger "Zu viele aktive simultane Transaktionen" WARN_NON_ASCII_SEPARATOR_NOT_IMPLEMENTED eng "Non-ASCII separator arguments are not fully supported" - + ger "Nicht-ASCII-Trennargumente werden nicht vollständig unterstützt" ER_DEBUG_SYNC_TIMEOUT eng "debug sync point wait timed out" ger "Debug Sync Point Wartezeit überschritten" ER_DEBUG_SYNC_HIT_LIMIT eng "debug sync point hit limit reached" ger "Debug Sync Point Hit Limit erreicht" - ER_DUP_SIGNAL_SET 42000 - eng "Duplicate condition information item '%s'" - + eng "Duplicate condition information item '%s'" + ger "Informationselement '%s' für Duplikatbedingung" # Note that the SQLSTATE is not 01000, it is provided by SIGNAL/RESIGNAL ER_SIGNAL_WARN 01000 - eng "Unhandled user-defined warning condition" - + eng "Unhandled user-defined warning condition" + ger "Unbehandelte benutzerdefinierte Warnbedingung" # Note that the SQLSTATE is not 02000, it is provided by SIGNAL/RESIGNAL ER_SIGNAL_NOT_FOUND 02000 - eng "Unhandled user-defined not found condition" - + eng "Unhandled user-defined not found condition" + ger "Unbehandelte benutzerdefinierte Nicht-gefunden-Bedingung" # Note that the SQLSTATE is not HY000, it is provided by SIGNAL/RESIGNAL ER_SIGNAL_EXCEPTION HY000 - eng "Unhandled user-defined exception condition" - + eng "Unhandled user-defined exception condition" + ger "Unbehandelte benutzerdefinierte Ausnahmebedingung" ER_RESIGNAL_WITHOUT_ACTIVE_HANDLER 0K000 - eng "RESIGNAL when handler not active" - + eng "RESIGNAL when handler not active" + ger "RESIGNAL bei nicht aktivem Handler" ER_SIGNAL_BAD_CONDITION_TYPE - eng "SIGNAL/RESIGNAL can only use a CONDITION defined with SQLSTATE" - + eng "SIGNAL/RESIGNAL can only use a CONDITION defined with SQLSTATE" + ger "SIGNAL/RESIGNAL kann nur mit einer Bedingung (CONDITION) benutzt werden, die bei SQLSTATE definiert wurde" WARN_COND_ITEM_TRUNCATED - eng "Data truncated for condition item '%s'" - + eng "Data truncated for condition item '%s'" + ger "Daten gekürzt für Bedingungselement '%s'" ER_COND_ITEM_TOO_LONG - eng "Data too long for condition item '%s'" - + eng "Data too long for condition item '%s'" + ger "Daten zu lang für Bedingungselement '%s'" ER_UNKNOWN_LOCALE - eng "Unknown locale: '%-.64s'" - + eng "Unknown locale: '%-.64s'" + ger "Unbekannte Locale: '%-.64s'" ER_SLAVE_IGNORE_SERVER_IDS eng "The requested server id %d clashes with the slave startup option --replicate-same-server-id" + ger "Die angeforderte Server-ID %d steht im Konflikt mit der Startoption --replicate-same-server-id für den Slave" ER_QUERY_CACHE_DISABLED eng "Query cache is disabled; restart the server with query_cache_type=1 to enable it" + ger "Abfragen-Cache ist deaktiviert. Starten Sie den Server neu mit query_cache_type=1, um ihn zu aktivieren" ER_SAME_NAME_PARTITION_FIELD eng "Duplicate partition field name '%-.192s'" + ger "Partitionsfeld '%-.192s' ist ein Duplikat" ER_PARTITION_COLUMN_LIST_ERROR eng "Inconsistency in usage of column lists for partitioning" + ger "Inkonsistenz bei der Benutzung von Spaltenlisten für Partitionierung" ER_WRONG_TYPE_COLUMN_VALUE_ERROR eng "Partition column values of incorrect type" + ger "Partitionsspaltenwerte sind vom falschen Typ" ER_TOO_MANY_PARTITION_FUNC_FIELDS_ERROR eng "Too many fields in '%-.192s'" + ger "Zu viele Felder in '%-.192s'" ER_MAXVALUE_IN_VALUES_IN eng "Cannot use MAXVALUE as value in VALUES IN" + ger "MAXVALUE kann nicht als Wert in VALUES IN verwendet werden" ER_TOO_MANY_VALUES_ERROR eng "Cannot have more than one value for this type of %-.64s partitioning" + ger "Für den Partionierungstyp %-.64s darf es nicht mehr als einen Wert geben" ER_ROW_SINGLE_PARTITION_FIELD_ERROR eng "Row expressions in VALUES IN only allowed for multi-field column partitioning" + ger "Zeilenausdrücke in VALUES IN sind nur für Mehrfeld-Spaltenpartionierung erlaubt" ER_FIELD_TYPE_NOT_ALLOWED_AS_PARTITION_FIELD eng "Field '%-.192s' is of a not allowed type for this type of partitioning" + ger "Feld '%-.192s' ist für diese Art von Partitionierung von einem nicht zulässigen Typ" ER_PARTITION_FIELDS_TOO_LONG eng "The total length of the partitioning fields is too large" + ger "Die Gesamtlänge der Partitionsfelder ist zu groß" ER_BINLOG_ROW_ENGINE_AND_STMT_ENGINE eng "Cannot execute statement: impossible to write to binary log since both row-incapable engines and statement-incapable engines are involved." ER_BINLOG_ROW_MODE_AND_STMT_ENGINE @@ -6318,7 +6360,7 @@ ER_STORED_FUNCTION_PREVENTS_SWITCH_BINLOG_DIRECT eng "Cannot change the binlog direct flag inside a stored function or trigger" ER_SPATIAL_MUST_HAVE_GEOM_COL 42000 eng "A SPATIAL index may only contain a geometrical type column" - + ger "Ein raumbezogener Index (SPATIAL) darf nur Spalten geometrischen Typs enthalten" ER_TOO_LONG_INDEX_COMMENT eng "Comment for index '%-.64s' is too long (max = %lu)" @@ -6415,6 +6457,36 @@ ER_ERROR_IN_TRIGGER_BODY ER_ERROR_IN_UNKNOWN_TRIGGER_BODY eng "Unknown trigger has an error in its body: '%-.256s'" +ER_INDEX_CORRUPT + eng "Index %s is corrupted" + +ER_UNDO_RECORD_TOO_BIG + eng "Undo log record is too big." + +ER_BINLOG_UNSAFE_INSERT_IGNORE_SELECT + eng "INSERT IGNORE... SELECT is unsafe because the order in which rows are retrieved by the SELECT determines which (if any) rows are ignored. This order cannot be predicted and may differ on master and the slave." + +ER_BINLOG_UNSAFE_INSERT_SELECT_UPDATE + eng "INSERT... SELECT... ON DUPLICATE KEY UPDATE is unsafe because the order in which rows are retrieved by the SELECT determines which (if any) rows are updated. This order cannot be predicted and may differ on master and the slave." + +ER_BINLOG_UNSAFE_REPLACE_SELECT + eng "REPLACE... SELECT is unsafe because the order in which rows are retrieved by the SELECT determines which (if any) rows are replaced. This order cannot be predicted and may differ on master and the slave." + +ER_BINLOG_UNSAFE_CREATE_IGNORE_SELECT + eng "CREATE... IGNORE SELECT is unsafe because the order in which rows are retrieved by the SELECT determines which (if any) rows are ignored. This order cannot be predicted and may differ on master and the slave." + +ER_BINLOG_UNSAFE_CREATE_REPLACE_SELECT + eng "CREATE... REPLACE SELECT is unsafe because the order in which rows are retrieved by the SELECT determines which (if any) rows are replaced. This order cannot be predicted and may differ on master and the slave." + +ER_BINLOG_UNSAFE_UPDATE_IGNORE + eng "UPDATE IGNORE is unsafe because the order in which rows are updated determines which (if any) rows are ignored. This order cannot be predicted and may differ on master and the slave." + +ER_PLUGIN_NO_UNINSTALL + eng "Plugin '%s' is marked as not dynamically uninstallable. You have to stop the server to uninstall it." + +ER_PLUGIN_NO_INSTALL + eng "Plugin '%s' is marked as not dynamically installable. You have to stop the server to install it." + # # MariaDB error messages section starts here # @@ -6482,3 +6554,7 @@ ER_QUERY_CACHE_IS_GLOBALY_DISABLED eng "Query cache is globally disabled and you can't enable it only for this session" ER_VIEW_ORDERBY_IGNORED eng "View '%-.192s'.'%-.192s' ORDER BY clause ignored because there is other ORDER BY clause already." +ER_CONNECTION_KILLED 70100 + eng "Connection was killed" +ER_INTERNAL_ERROR + eng "Internal error: '%-.192s'" diff --git a/sql/slave.cc b/sql/slave.cc index 7e60b0ef3ec..bd6e9aa69f9 100644 --- a/sql/slave.cc +++ b/sql/slave.cc @@ -1,4 +1,4 @@ -/* Copyright (C) 2000, 2011, Oracle and/or its affiliates. +/* Copyright (c) 2000, 2011, Oracle and/or its affiliates. Copyright (c) 2009-2011, Monty Program Ab This program is free software; you can redistribute it and/or modify @@ -12,7 +12,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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ /** @@ -650,7 +650,8 @@ terminate_slave_thread(THD *thd, int err __attribute__((unused))= pthread_kill(thd->real_id, thr_client_alarm); DBUG_ASSERT(err != EINVAL); #endif - thd->awake(THD::NOT_KILLED); + thd->awake(NOT_KILLED); + mysql_mutex_unlock(&thd->LOCK_thd_data); /* @@ -1189,6 +1190,8 @@ bool is_network_error(uint errorno) errorno == CR_SERVER_GONE_ERROR || errorno == CR_SERVER_LOST || errorno == ER_CON_COUNT_ERROR || + errorno == ER_CONNECTION_KILLED || + errorno == ER_NEW_ABORTING_CONNECTION || errorno == ER_SERVER_SHUTDOWN) return TRUE; @@ -2266,7 +2269,7 @@ static int request_dump(THD *thd, MYSQL* mysql, Master_info* mi, *suppress_warnings= FALSE; - if (opt_log_slave_updates && opt_replicate_annotate_rows_events) + if (opt_log_slave_updates && opt_replicate_annotate_row_events) binlog_flags|= BINLOG_SEND_ANNOTATE_ROWS_EVENT; if (RUN_HOOK(binlog_relay_io, @@ -3363,11 +3366,11 @@ pthread_handler_t handle_slave_sql(void *arg) thd->temporary_tables = rli->save_temporary_tables; // restore temp tables set_thd_in_use_temporary_tables(rli); // (re)set sql_thd in use for saved temp tables /* - binlog_annotate_rows_events must be TRUE only after an Annotate_rows event + binlog_annotate_row_events must be TRUE only after an Annotate_rows event has been recieved and only till the last corresponding rbr event has been applied. In all other cases it must be FALSE. */ - thd->variables.binlog_annotate_rows_events= 0; + thd->variables.binlog_annotate_row_events= 0; mysql_mutex_lock(&LOCK_thread_count); threads.append(thd); mysql_mutex_unlock(&LOCK_thread_count); @@ -4536,6 +4539,10 @@ static int connect_to_master(THD* thd, MYSQL* mysql, Master_info* mi, /* This one is not strictly needed but we have it here for completeness */ mysql_options(mysql, MYSQL_SET_CHARSET_DIR, (char *) charsets_dir); + /* Set MYSQL_PLUGIN_DIR in case master asks for an external authentication plugin */ + if (opt_plugin_dir_ptr && *opt_plugin_dir_ptr)
+ mysql_options(mysql, MYSQL_PLUGIN_DIR, opt_plugin_dir_ptr);
+ while (!(slave_was_killed = io_slave_killed(thd,mi)) && (reconnect ? mysql_reconnect(mysql) != 0 : mysql_real_connect(mysql, mi->host, mi->user, mi->password, 0, diff --git a/sql/slave.h b/sql/slave.h index 9e24058cbbc..7bee83af744 100644 --- a/sql/slave.h +++ b/sql/slave.h @@ -1,4 +1,4 @@ -/* Copyright (C) 2000-2003 MySQL AB, 2008-2009 Sun Microsystems, Inc +/* Copyright (c) 2000, 2010, Oracle and/or its affiliates. All rights reserved. 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 @@ -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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ #ifndef SLAVE_H #define SLAVE_H @@ -122,7 +122,7 @@ extern char *opt_relay_logname, *opt_relaylog_index_name; extern my_bool opt_skip_slave_start, opt_reckless_slave; extern my_bool opt_log_slave_updates; extern char *opt_slave_skip_errors; -extern my_bool opt_replicate_annotate_rows_events; +extern my_bool opt_replicate_annotate_row_events; extern ulonglong relay_log_space_limit; /* diff --git a/sql/sp.cc b/sql/sp.cc index 24f7ed4ba90..56827d410b7 100644 --- a/sql/sp.cc +++ b/sql/sp.cc @@ -1,4 +1,5 @@ -/* Copyright (C) 2002 MySQL AB +/* + Copyright (c) 2002, 2011, Oracle and/or its affiliates. All rights reserved. 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 @@ -11,7 +12,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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ #include "sql_priv.h" #include "unireg.h" @@ -33,7 +34,7 @@ static bool create_string(THD *thd, String *buf, - int sp_type, + stored_procedure_type sp_type, const char *db, ulong dblen, const char *name, ulong namelen, const char *params, ulong paramslen, @@ -45,7 +46,8 @@ create_string(THD *thd, String *buf, ulonglong sql_mode); static int -db_load_routine(THD *thd, int type, sp_name *name, sp_head **sphp, +db_load_routine(THD *thd, stored_procedure_type type, sp_name *name, + sp_head **sphp, ulonglong sql_mode, const char *params, const char *returns, const char *body, st_sp_chistics &chistics, const char *definer, longlong created, longlong modified, @@ -474,7 +476,8 @@ static TABLE *open_proc_table_for_update(THD *thd) */ static int -db_find_routine_aux(THD *thd, int type, sp_name *name, TABLE *table) +db_find_routine_aux(THD *thd, stored_procedure_type type, sp_name *name, + TABLE *table) { uchar key[MAX_KEY_LENGTH]; // db, name, optional key length type DBUG_ENTER("db_find_routine_aux"); @@ -527,7 +530,8 @@ db_find_routine_aux(THD *thd, int type, sp_name *name, TABLE *table) */ static int -db_find_routine(THD *thd, int type, sp_name *name, sp_head **sphp) +db_find_routine(THD *thd, stored_procedure_type type, sp_name *name, + sp_head **sphp) { TABLE *table; const char *params, *returns, *body; @@ -758,8 +762,46 @@ static sp_head *sp_compile(THD *thd, String *defstr, ulonglong sql_mode, } +class Bad_db_error_handler : public Internal_error_handler +{ +public: + Bad_db_error_handler() + :m_error_caught(false) + {} + + virtual bool handle_condition(THD *thd, + uint sql_errno, + const char* sqlstate, + MYSQL_ERROR::enum_warning_level level, + const char* message, + MYSQL_ERROR ** cond_hdl); + + bool error_caught() const { return m_error_caught; } + +private: + bool m_error_caught; +}; + +bool +Bad_db_error_handler::handle_condition(THD *thd, + uint sql_errno, + const char* sqlstate, + MYSQL_ERROR::enum_warning_level level, + const char* message, + MYSQL_ERROR ** cond_hdl) +{ + if (sql_errno == ER_BAD_DB_ERROR) + { + m_error_caught= true; + return true; + } + return false; +} + + static int -db_load_routine(THD *thd, int type, sp_name *name, sp_head **sphp, +db_load_routine(THD *thd, stored_procedure_type type, + sp_name *name, sp_head **sphp, ulonglong sql_mode, const char *params, const char *returns, const char *body, st_sp_chistics &chistics, const char *definer, longlong created, longlong modified, @@ -771,7 +813,7 @@ db_load_routine(THD *thd, int type, sp_name *name, sp_head **sphp, LEX_STRING saved_cur_db_name= { saved_cur_db_name_buf, sizeof(saved_cur_db_name_buf) }; bool cur_db_changed; - + Bad_db_error_handler db_not_exists_handler; char definer_user_name_holder[USERNAME_LENGTH + 1]; LEX_STRING definer_user_name= { definer_user_name_holder, USERNAME_LENGTH }; @@ -810,6 +852,7 @@ db_load_routine(THD *thd, int type, sp_name *name, sp_head **sphp, goto end; } + thd->push_internal_handler(&db_not_exists_handler); /* Change the current database (if needed). @@ -820,6 +863,15 @@ db_load_routine(THD *thd, int type, sp_name *name, sp_head **sphp, &cur_db_changed)) { ret= SP_INTERNAL_ERROR; + thd->pop_internal_handler(); + goto end; + } + thd->pop_internal_handler(); + if (db_not_exists_handler.error_caught()) + { + ret= SP_INTERNAL_ERROR; + my_error(ER_BAD_DB_ERROR, MYF(0), name->m_db.str); + goto end; } @@ -918,7 +970,7 @@ sp_returns_type(THD *thd, String &result, sp_head *sp) */ int -sp_create_routine(THD *thd, int type, sp_head *sp) +sp_create_routine(THD *thd, stored_procedure_type type, sp_head *sp) { int ret; TABLE *table; @@ -936,7 +988,8 @@ sp_create_routine(THD *thd, int type, sp_head *sp) bool save_binlog_row_based; DBUG_ENTER("sp_create_routine"); - DBUG_PRINT("enter", ("type: %d name: %.*s",type, (int) sp->m_name.length, + DBUG_PRINT("enter", ("type: %d name: %.*s", (int) type, + (int) sp->m_name.length, sp->m_name.str)); String retstr(64); retstr.set_charset(system_charset_info); @@ -1188,7 +1241,7 @@ done: */ int -sp_drop_routine(THD *thd, int type, sp_name *name) +sp_drop_routine(THD *thd, stored_procedure_type type, sp_name *name) { TABLE *table; int ret; @@ -1269,7 +1322,8 @@ sp_drop_routine(THD *thd, int type, sp_name *name) */ int -sp_update_routine(THD *thd, int type, sp_name *name, st_sp_chistics *chistics) +sp_update_routine(THD *thd, stored_procedure_type type, sp_name *name, + st_sp_chistics *chistics) { TABLE *table; int ret; @@ -1278,7 +1332,8 @@ sp_update_routine(THD *thd, int type, sp_name *name, st_sp_chistics *chistics) MDL_key::FUNCTION : MDL_key::PROCEDURE; DBUG_ENTER("sp_update_routine"); DBUG_PRINT("enter", ("type: %d name: %.*s", - type, (int) name->m_name.length, name->m_name.str)); + (int) type, + (int) name->m_name.length, name->m_name.str)); DBUG_ASSERT(type == TYPE_ENUM_PROCEDURE || type == TYPE_ENUM_FUNCTION); @@ -1542,7 +1597,7 @@ err: */ bool -sp_show_create_routine(THD *thd, int type, sp_name *name) +sp_show_create_routine(THD *thd, stored_procedure_type type, sp_name *name) { sp_head *sp; @@ -1598,8 +1653,8 @@ sp_show_create_routine(THD *thd, int type, sp_name *name) */ sp_head * -sp_find_routine(THD *thd, int type, sp_name *name, sp_cache **cp, - bool cache_only) +sp_find_routine(THD *thd, stored_procedure_type type, sp_name *name, + sp_cache **cp, bool cache_only) { sp_head *sp; ulong depth= (type == TYPE_ENUM_PROCEDURE ? @@ -1828,7 +1883,7 @@ bool sp_add_used_routine(Query_tables_list *prelocking_ctx, Query_arena *arena, */ void sp_add_used_routine(Query_tables_list *prelocking_ctx, Query_arena *arena, - sp_name *rt, char rt_type) + sp_name *rt, enum stored_procedure_type rt_type) { MDL_key key((rt_type == TYPE_ENUM_FUNCTION) ? MDL_key::FUNCTION : MDL_key::PROCEDURE, @@ -1966,7 +2021,7 @@ int sp_cache_routine(THD *thd, Sroutine_hash_entry *rt, char qname_buff[NAME_LEN*2+1+1]; sp_name name(&rt->mdl_request.key, qname_buff); MDL_key::enum_mdl_namespace mdl_type= rt->mdl_request.key.mdl_namespace(); - int type= ((mdl_type == MDL_key::FUNCTION) ? + stored_procedure_type type= ((mdl_type == MDL_key::FUNCTION) ? TYPE_ENUM_FUNCTION : TYPE_ENUM_PROCEDURE); /* @@ -2001,7 +2056,7 @@ int sp_cache_routine(THD *thd, Sroutine_hash_entry *rt, @retval non-0 Error while loading routine from mysql,proc table. */ -int sp_cache_routine(THD *thd, int type, sp_name *name, +int sp_cache_routine(THD *thd, enum stored_procedure_type type, sp_name *name, bool lookup_only, sp_head **sp) { int ret= 0; @@ -2012,7 +2067,6 @@ int sp_cache_routine(THD *thd, int type, sp_name *name, DBUG_ASSERT(type == TYPE_ENUM_FUNCTION || type == TYPE_ENUM_PROCEDURE); - *sp= sp_cache_lookup(spc, name); if (lookup_only) @@ -2080,7 +2134,7 @@ int sp_cache_routine(THD *thd, int type, sp_name *name, */ static bool create_string(THD *thd, String *buf, - int type, + stored_procedure_type type, const char *db, ulong dblen, const char *name, ulong namelen, const char *params, ulong paramslen, @@ -2173,7 +2227,7 @@ create_string(THD *thd, String *buf, sp_head * sp_load_for_information_schema(THD *thd, TABLE *proc_table, String *db, - String *name, ulong sql_mode, int type, + String *name, ulong sql_mode, stored_procedure_type type, const char *returns, const char *params, bool *free_sp_head) { @@ -1,5 +1,5 @@ /* -*- C++ -*- */ -/* Copyright (C) 2002 MySQL AB +/* Copyright (c) 2002, 2010, Oracle and/or its affiliates. All rights reserved. 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 @@ -12,7 +12,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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ #ifndef _SP_H_ #define _SP_H_ @@ -36,6 +36,17 @@ struct TABLE_LIST; typedef struct st_hash HASH; template <typename T> class SQL_I_List; +/* + Values for the type enum. This reflects the order of the enum declaration + in the CREATE TABLE command. +*/ +enum stored_procedure_type +{ + TYPE_ENUM_FUNCTION=1, + TYPE_ENUM_PROCEDURE=2, + TYPE_ENUM_TRIGGER=3, + TYPE_ENUM_PROXY=4 +}; /* Tells what SP_DEFAULT_ACCESS should be mapped to */ #define SP_DEFAULT_ACCESS_MAPPING SP_CONTAINS_SQL @@ -97,7 +108,7 @@ sp_drop_db_routines(THD *thd, char *db); bool lock_db_routines(THD *thd, char *db); sp_head * -sp_find_routine(THD *thd, int type, sp_name *name, +sp_find_routine(THD *thd, stored_procedure_type type, sp_name *name, sp_cache **cp, bool cache_only); int @@ -106,23 +117,24 @@ sp_cache_routine(THD *thd, Sroutine_hash_entry *rt, int -sp_cache_routine(THD *thd, int type, sp_name *name, +sp_cache_routine(THD *thd, stored_procedure_type type, sp_name *name, bool lookup_only, sp_head **sp); bool sp_exist_routines(THD *thd, TABLE_LIST *procs, bool any); bool -sp_show_create_routine(THD *thd, int type, sp_name *name); +sp_show_create_routine(THD *thd, stored_procedure_type type, sp_name *name); int -sp_create_routine(THD *thd, int type, sp_head *sp); +sp_create_routine(THD *thd, stored_procedure_type type, sp_head *sp); int -sp_update_routine(THD *thd, int type, sp_name *name, st_sp_chistics *chistics); +sp_update_routine(THD *thd, stored_procedure_type type, sp_name *name, + st_sp_chistics *chistics); int -sp_drop_routine(THD *thd, int type, sp_name *name); +sp_drop_routine(THD *thd, stored_procedure_type type, sp_name *name); /** @@ -166,7 +178,7 @@ public: Procedures for handling sets of stored routines used by statement or routine. */ void sp_add_used_routine(Query_tables_list *prelocking_ctx, Query_arena *arena, - sp_name *rt, char rt_type); + sp_name *rt, stored_procedure_type rt_type); bool sp_add_used_routine(Query_tables_list *prelocking_ctx, Query_arena *arena, const MDL_key *key, TABLE_LIST *belong_to_view); void sp_remove_not_own_routines(Query_tables_list *prelocking_ctx); @@ -188,7 +200,7 @@ TABLE *open_proc_table_for_read(THD *thd, Open_tables_backup *backup); sp_head * sp_load_for_information_schema(THD *thd, TABLE *proc_table, String *db, - String *name, ulong sql_mode, int type, + String *name, ulong sql_mode, stored_procedure_type type, const char *returns, const char *params, bool *free_sp_head); diff --git a/sql/sp_cache.cc b/sql/sp_cache.cc index eaac4459e99..f0875b9c3f4 100644 --- a/sql/sp_cache.cc +++ b/sql/sp_cache.cc @@ -1,4 +1,4 @@ -/* Copyright (C) 2002 MySQL AB, 2008-2009 Sun Microsystems, Inc +/* Copyright (c) 2002, 2010, Oracle and/or its affiliates. All rights reserved. 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 @@ -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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ #include "sql_priv.h" #include "unireg.h" diff --git a/sql/sp_cache.h b/sql/sp_cache.h index 2d379300354..7c5d1dca6ef 100644 --- a/sql/sp_cache.h +++ b/sql/sp_cache.h @@ -1,5 +1,5 @@ /* -*- C++ -*- */ -/* Copyright (C) 2002 MySQL AB +/* Copyright (c) 2002, 2010, Oracle and/or its affiliates. All rights reserved. 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 @@ -12,7 +12,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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ #ifndef _SP_CACHE_H_ #define _SP_CACHE_H_ diff --git a/sql/sp_head.cc b/sql/sp_head.cc index 078c3111819..e82f1b92312 100644 --- a/sql/sp_head.cc +++ b/sql/sp_head.cc @@ -1,4 +1,5 @@ -/* Copyright (c) 2002, 2011, Oracle and/or its affiliates. All rights reserved. +/* + Copyright (c) 2002, 2011, Oracle and/or its affiliates. All rights reserved. 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 @@ -1504,7 +1505,7 @@ sp_head::execute(THD *thd, bool merge_da_on_success) If the DB has changed, the pointer has changed too, but the original thd->db will then have been freed */ - if (cur_db_changed && thd->killed != THD::KILL_CONNECTION) + if (cur_db_changed && thd->killed != KILL_CONNECTION) { /* Force switching back to the saved current database, because it may be @@ -1939,7 +1940,7 @@ sp_head::execute_function(THD *thd, Item **argp, uint argcount, thd->variables.option_bits= binlog_save_options; if (thd->binlog_evt_union.unioned_events) { - int errcode = query_error_code(thd, thd->killed == THD::NOT_KILLED); + int errcode = query_error_code(thd, thd->killed == NOT_KILLED); Query_log_event qinfo(thd, binlog_buf.ptr(), binlog_buf.length(), thd->binlog_evt_union.unioned_events_trans, FALSE, FALSE, errcode); if (mysql_bin_log.write(&qinfo) && @@ -2584,8 +2585,9 @@ bool check_show_routine_access(THD *thd, sp_head *sp, bool *full_access) bzero((char*) &tables,sizeof(tables)); tables.db= (char*) "mysql"; tables.table_name= tables.alias= (char*) "proc"; - *full_access= (!check_table_access(thd, SELECT_ACL, &tables, FALSE, - 1, TRUE) || + *full_access= ((!check_table_access(thd, SELECT_ACL, &tables, FALSE, + 1, TRUE) && + (tables.grant.privilege & SELECT_ACL) != 0) || (!strcmp(sp->m_definer_user.str, thd->security_ctx->priv_user) && !strcmp(sp->m_definer_host.str, diff --git a/sql/sp_head.h b/sql/sp_head.h index 780e05076c1..96e119f23bc 100644 --- a/sql/sp_head.h +++ b/sql/sp_head.h @@ -1,5 +1,5 @@ /* -*- C++ -*- */ -/* Copyright (C) 2002 MySQL AB +/* Copyright (c) 2002, 2011, Oracle and/or its affiliates. All rights reserved. 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 @@ -12,7 +12,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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ #ifndef _SP_HEAD_H_ #define _SP_HEAD_H_ @@ -29,7 +29,7 @@ #include "my_global.h" /* NO_EMBEDDED_ACCESS_CHECKS */ #include "sql_class.h" // THD, set_var.h: THD #include "set_var.h" // Item - +#include "sp.h" #include <stddef.h> /** @@ -37,12 +37,6 @@ @ingroup Runtime_Environment @{ */ -// Values for the type enum. This reflects the order of the enum declaration -// in the CREATE TABLE command. -#define TYPE_ENUM_FUNCTION 1 -#define TYPE_ENUM_PROCEDURE 2 -#define TYPE_ENUM_TRIGGER 3 -#define TYPE_ENUM_PROXY 4 Item_result sp_map_result_type(enum enum_field_types type); @@ -164,8 +158,7 @@ public: HAS_SQLCOM_FLUSH= 2048 }; - /** TYPE_ENUM_FUNCTION, TYPE_ENUM_PROCEDURE or TYPE_ENUM_TRIGGER */ - int m_type; + stored_procedure_type m_type; uint m_flags; // Boolean attributes of a stored routine Create_field m_return_field_def; /**< This is used for FUNCTIONs only. */ diff --git a/sql/sp_pcontext.cc b/sql/sp_pcontext.cc index bbf38f52efb..4c5087eaf27 100644 --- a/sql/sp_pcontext.cc +++ b/sql/sp_pcontext.cc @@ -1,4 +1,4 @@ -/* Copyright (C) 2002 MySQL AB +/* Copyright (c) 2002, 2010, Oracle and/or its affiliates. All rights reserved. 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 @@ -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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ #include "sql_priv.h" #include "unireg.h" diff --git a/sql/sp_pcontext.h b/sql/sp_pcontext.h index c27c7d22da2..f1d0d250c47 100644 --- a/sql/sp_pcontext.h +++ b/sql/sp_pcontext.h @@ -1,5 +1,5 @@ /* -*- C++ -*- */ -/* Copyright (C) 2002 MySQL AB +/* Copyright (c) 2002, 2010, Oracle and/or its affiliates. All rights reserved. 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 @@ -12,7 +12,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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ #ifndef _SP_PCONTEXT_H_ #define _SP_PCONTEXT_H_ diff --git a/sql/sp_rcontext.cc b/sql/sp_rcontext.cc index 7b8ade26085..6fe4be989db 100644 --- a/sql/sp_rcontext.cc +++ b/sql/sp_rcontext.cc @@ -1,4 +1,4 @@ -/* Copyright (C) 2002 MySQL AB +/* Copyright (c) 2002, 2010, Oracle and/or its affiliates. All rights reserved. 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 @@ -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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ #include "sql_priv.h" #include "unireg.h" @@ -419,7 +419,7 @@ sp_rcontext::activate_handler(THD *thd, /* Reset error state. */ thd->clear_error(); - thd->killed= THD::NOT_KILLED; // Some errors set thd->killed + thd->killed= NOT_KILLED; // Some errors set thd->killed // (e.g. "bad data"). /* Return IP of the activated SQL handler. */ diff --git a/sql/sp_rcontext.h b/sql/sp_rcontext.h index c8903911b83..3d976f94381 100644 --- a/sql/sp_rcontext.h +++ b/sql/sp_rcontext.h @@ -1,5 +1,5 @@ /* -*- C++ -*- */ -/* Copyright (C) 2002 MySQL AB +/* Copyright (c) 2002, 2010, Oracle and/or its affiliates. All rights reserved. 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 @@ -12,7 +12,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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ #ifndef _SP_RCONTEXT_H_ #define _SP_RCONTEXT_H_ diff --git a/sql/spatial.cc b/sql/spatial.cc index b02feb722f7..ee701d82657 100644 --- a/sql/spatial.cc +++ b/sql/spatial.cc @@ -1,4 +1,5 @@ -/* Copyright (C) 2004 MySQL AB +/* + Copyright (c) 2002, 2011, Oracle and/or its affiliates. All rights reserved. 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 @@ -11,7 +12,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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ #include "sql_priv.h" #include "my_global.h" // REQUIRED for HAVE_* below diff --git a/sql/spatial.h b/sql/spatial.h index b0c609ceeef..e93540db862 100644 --- a/sql/spatial.h +++ b/sql/spatial.h @@ -1,4 +1,4 @@ -/* Copyright (C) 2002-2006 MySQL AB +/* Copyright (c) 2002, 2010, Oracle and/or its affiliates. All rights reserved. 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 @@ -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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ #ifndef _spatial_h #define _spatial_h diff --git a/sql/sql_acl.cc b/sql/sql_acl.cc index 0fb8204856e..e4aa41b30ab 100644 --- a/sql/sql_acl.cc +++ b/sql/sql_acl.cc @@ -2420,7 +2420,7 @@ static int replace_user_table(THD *thd, TABLE *table, LEX_USER &combo, table->field[next_field+2]->store((longlong) mqh.conn_per_hour, TRUE); if (table->s->fields >= 36 && (mqh.specified_limits & USER_RESOURCES::USER_CONNECTIONS)) - table->field[next_field+3]->store((longlong) mqh.user_conn, TRUE); + table->field[next_field+3]->store((longlong) mqh.user_conn, FALSE); mqh_used= mqh_used || mqh.questions || mqh.updates || mqh.conn_per_hour; next_field+= 4; @@ -5169,7 +5169,8 @@ ulong get_column_grant(THD *thd, GRANT_INFO *grant, /* Help function for mysql_show_grants */ -static void add_user_option(String *grant, ulong value, const char *name) +static void add_user_option(String *grant, long value, const char *name, + my_bool is_signed) { if (value) { @@ -5177,7 +5178,7 @@ static void add_user_option(String *grant, ulong value, const char *name) grant->append(' '); grant->append(name, strlen(name)); grant->append(' '); - p=int10_to_str(value, buff, 10); + p=int10_to_str(value, buff, is_signed ? -10 : 10); grant->append(buff,p-buff); } } @@ -5359,13 +5360,13 @@ bool mysql_show_grants(THD *thd,LEX_USER *lex_user) if (want_access & GRANT_ACL) global.append(STRING_WITH_LEN(" GRANT OPTION")); add_user_option(&global, acl_user->user_resource.questions, - "MAX_QUERIES_PER_HOUR"); + "MAX_QUERIES_PER_HOUR", 0); add_user_option(&global, acl_user->user_resource.updates, - "MAX_UPDATES_PER_HOUR"); + "MAX_UPDATES_PER_HOUR", 0); add_user_option(&global, acl_user->user_resource.conn_per_hour, - "MAX_CONNECTIONS_PER_HOUR"); + "MAX_CONNECTIONS_PER_HOUR", 0); add_user_option(&global, acl_user->user_resource.user_conn, - "MAX_USER_CONNECTIONS"); + "MAX_USER_CONNECTIONS", 1); } protocol->prepare_for_resend(); protocol->store(global.ptr(),global.length(),global.charset()); @@ -9097,11 +9098,16 @@ bool acl_authenticate(THD *thd, uint connect_errors, DBUG_RETURN(1); } - /* Don't allow the user to connect if he has done too many queries */ - if ((acl_user->user_resource.questions || acl_user->user_resource.updates || + /* + Don't allow the user to connect if he has done too many queries. + As we are testing max_user_connections == 0 here, it means that we + can't let the user change max_user_connections from 0 in the server + without a restart as it would lead to wrong connect counting. + */ + if ((acl_user->user_resource.questions || + acl_user->user_resource.updates || acl_user->user_resource.conn_per_hour || - acl_user->user_resource.user_conn || - global_system_variables.max_user_connections) && + acl_user->user_resource.user_conn || max_user_connections_checking) && get_or_create_user_conn(thd, (opt_old_style_user_limits ? sctx->user : sctx->priv_user), (opt_old_style_user_limits ? sctx->host_or_ip : sctx->priv_host), @@ -9114,7 +9120,7 @@ bool acl_authenticate(THD *thd, uint connect_errors, if (thd->user_connect && (thd->user_connect->user_resources.conn_per_hour || thd->user_connect->user_resources.user_conn || - global_system_variables.max_user_connections) && + max_user_connections_checking) && check_for_max_user_connections(thd, thd->user_connect)) { /* Ensure we don't decrement thd->user_connections->connections twice */ @@ -9201,7 +9207,7 @@ static int native_password_authenticate(MYSQL_PLUGIN_VIO *vio, create_random_string(thd->scramble, SCRAMBLE_LENGTH, &thd->rand); /* and send it to the client */ if (mpvio->write_packet(mpvio, (uchar*)thd->scramble, SCRAMBLE_LENGTH + 1)) - return CR_ERROR; + DBUG_RETURN(CR_ERROR); } /* reply and authenticate */ @@ -9251,12 +9257,7 @@ static int native_password_authenticate(MYSQL_PLUGIN_VIO *vio, #endif if (pkt_len == 0) /* no password */ - { - if (info->auth_string[0]) - DBUG_RETURN(CR_ERROR); - else - DBUG_RETURN(CR_OK); - } + DBUG_RETURN(info->auth_string[0] ? CR_ERROR : CR_OK); info->password_used= PASSWORD_USED_YES; if (pkt_len == SCRAMBLE_LENGTH) @@ -9345,37 +9346,6 @@ static struct st_mysql_auth old_password_handler= old_password_authenticate }; -mysql_declare_plugin(mysql_password) -{ - MYSQL_AUTHENTICATION_PLUGIN, /* type constant */ - &native_password_handler, /* type descriptor */ - native_password_plugin_name.str, /* Name */ - "R.J.Silk, Sergei Golubchik", /* Author */ - "Native MySQL authentication", /* Description */ - PLUGIN_LICENSE_GPL, /* License */ - NULL, /* Init function */ - NULL, /* Deinit function */ - 0x0100, /* Version (1.0) */ - NULL, /* status variables */ - NULL, /* system variables */ - NULL /* config options */ -}, -{ - MYSQL_AUTHENTICATION_PLUGIN, /* type constant */ - &old_password_handler, /* type descriptor */ - old_password_plugin_name.str, /* Name */ - "R.J.Silk, Sergei Golubchik", /* Author */ - "Old MySQL-4.0 authentication", /* Description */ - PLUGIN_LICENSE_GPL, /* License */ - NULL, /* Init function */ - NULL, /* Deinit function */ - 0x0100, /* Version (1.0) */ - NULL, /* status variables */ - NULL, /* system variables */ - NULL /* config options */ -} -mysql_declare_plugin_end; - maria_declare_plugin(mysql_password) { MYSQL_AUTHENTICATION_PLUGIN, /* type constant */ diff --git a/sql/sql_acl.h b/sql/sql_acl.h index 3079f376bee..3169746419c 100644 --- a/sql/sql_acl.h +++ b/sql/sql_acl.h @@ -1,7 +1,7 @@ #ifndef SQL_ACL_INCLUDED #define SQL_ACL_INCLUDED -/* Copyright (C) 2000-2006 MySQL AB, 2008-2009 Sun Microsystems, Inc +/* Copyright (c) 2000, 2010, Oracle and/or its affiliates. All rights reserved. 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 @@ -14,7 +14,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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ #include "my_global.h" /* NO_EMBEDDED_ACCESS_CHECKS */ #include "violite.h" /* SSL_type */ diff --git a/sql/sql_admin.cc b/sql/sql_admin.cc index 5c529e99fac..8a2f475b6f2 100644 --- a/sql/sql_admin.cc +++ b/sql/sql_admin.cc @@ -1,4 +1,4 @@ -/* Copyright (c) 2010, 2011 Oracle and/or its affiliates. All rights reserved. +/* Copyright (c) 2010, 2011, Oracle and/or its affiliates. All rights reserved. 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/sql_admin.h b/sql/sql_admin.h index fdfffec8361..f7ec76efd5e 100644 --- a/sql/sql_admin.h +++ b/sql/sql_admin.h @@ -1,4 +1,4 @@ -/* Copyright (c) 2010 Oracle and/or its affiliates. All rights reserved. +/* Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved. 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/sql_alter.cc b/sql/sql_alter.cc index 2b0e0fecdaa..c6c02773286 100644 --- a/sql/sql_alter.cc +++ b/sql/sql_alter.cc @@ -1,4 +1,4 @@ -/* Copyright (c) 2010 Oracle and/or its affiliates. All rights reserved. +/* Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved. 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/sql_alter.h b/sql/sql_alter.h index 6a17f87f5a4..6660748f666 100644 --- a/sql/sql_alter.h +++ b/sql/sql_alter.h @@ -1,4 +1,4 @@ -/* Copyright (c) 2010 Oracle and/or its affiliates. All rights reserved. +/* Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved. 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/sql_analyse.cc b/sql/sql_analyse.cc index 883ac3c4660..d99337bd210 100644 --- a/sql/sql_analyse.cc +++ b/sql/sql_analyse.cc @@ -1,4 +1,5 @@ -/* Copyright (c) 2000, 2011, Oracle and/or its affiliates. All rights reserved. +/* + Copyright (c) 2000, 2011, Oracle and/or its affiliates. All rights reserved. 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/sql_analyse.h b/sql/sql_analyse.h index 1ef299c5dbc..34c8e2da3d4 100644 --- a/sql/sql_analyse.h +++ b/sql/sql_analyse.h @@ -1,7 +1,7 @@ #ifndef SQL_ANALYSE_INCLUDED #define SQL_ANALYSE_INCLUDED -/* Copyright (C) 2000-2003, 2005 MySQL AB +/* Copyright (c) 2000, 2010, Oracle and/or its affiliates. All rights reserved. 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 @@ -14,7 +14,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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ /* Analyse database */ diff --git a/sql/sql_array.h b/sql/sql_array.h index 19ce4e2e62b..67f1f1c2ad7 100644 --- a/sql/sql_array.h +++ b/sql/sql_array.h @@ -1,7 +1,8 @@ #ifndef SQL_ARRAY_INCLUDED #define SQL_ARRAY_INCLUDED -/* Copyright (C) 2003 MySQL AB +/* Copyright (c) 2003, 2005-2007 MySQL AB, 2009 Sun Microsystems, Inc. + Use is subject to license terms. 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 @@ -14,7 +15,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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ #include <my_sys.h> diff --git a/sql/sql_audit.cc b/sql/sql_audit.cc index be837ec51ba..131a71c1d6b 100644 --- a/sql/sql_audit.cc +++ b/sql/sql_audit.cc @@ -1,4 +1,4 @@ -/* Copyright (C) 2007 MySQL AB, 2008-2009 Sun Microsystems, Inc +/* Copyright (c) 2007, 2011, Oracle and/or its affiliates. All rights reserved. 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 @@ -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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ #include "sql_priv.h" #include "sql_audit.h" diff --git a/sql/sql_audit.h b/sql/sql_audit.h index da44c4a023b..51c695d091d 100644 --- a/sql/sql_audit.h +++ b/sql/sql_audit.h @@ -1,7 +1,7 @@ #ifndef SQL_AUDIT_INCLUDED #define SQL_AUDIT_INCLUDED -/* Copyright (C) 2007 MySQL AB +/* Copyright (c) 2007, 2010, Oracle and/or its affiliates. All rights reserved. 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 @@ -14,7 +14,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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ #include <my_global.h> diff --git a/sql/sql_base.cc b/sql/sql_base.cc index 49cd948791b..2411c9c33ea 100644 --- a/sql/sql_base.cc +++ b/sql/sql_base.cc @@ -65,7 +65,7 @@ bool No_such_table_error_handler::handle_condition(THD *, uint sql_errno, const char*, - MYSQL_ERROR::enum_warning_level, + MYSQL_ERROR::enum_warning_level level, const char*, MYSQL_ERROR ** cond_hdl) { @@ -76,7 +76,8 @@ No_such_table_error_handler::handle_condition(THD *, return TRUE; } - m_unhandled_errors++; + if (level == MYSQL_ERROR::WARN_LEVEL_ERROR) + m_unhandled_errors++; return FALSE; } @@ -91,6 +92,69 @@ bool No_such_table_error_handler::safely_trapped_errors() return ((m_handled_errors > 0) && (m_unhandled_errors == 0)); } + +/** + This internal handler is used to trap ER_NO_SUCH_TABLE and + ER_WRONG_MRG_TABLE errors during CHECK/REPAIR TABLE for MERGE + tables. +*/ + +class Repair_mrg_table_error_handler : public Internal_error_handler +{ +public: + Repair_mrg_table_error_handler() + : m_handled_errors(false), m_unhandled_errors(false) + {} + + bool handle_condition(THD *thd, + uint sql_errno, + const char* sqlstate, + MYSQL_ERROR::enum_warning_level level, + const char* msg, + MYSQL_ERROR ** cond_hdl); + + /** + Returns TRUE if there were ER_NO_SUCH_/WRONG_MRG_TABLE and there + were no unhandled errors. FALSE otherwise. + */ + bool safely_trapped_errors() + { + /* + Check for m_handled_errors is here for extra safety. + It can be useful in situation when call to open_table() + fails because some error which was suppressed by another + error handler (e.g. in case of MDL deadlock which we + decided to solve by back-off and retry). + */ + return (m_handled_errors && (! m_unhandled_errors)); + } + +private: + bool m_handled_errors; + bool m_unhandled_errors; +}; + + +bool +Repair_mrg_table_error_handler::handle_condition(THD *, + uint sql_errno, + const char*, + MYSQL_ERROR::enum_warning_level level, + const char*, + MYSQL_ERROR ** cond_hdl) +{ + *cond_hdl= NULL; + if (sql_errno == ER_NO_SUCH_TABLE || sql_errno == ER_WRONG_MRG_TABLE) + { + m_handled_errors= true; + return TRUE; + } + + m_unhandled_errors= true; + return FALSE; +} + + /** @defgroup Data_Dictionary Data Dictionary @{ @@ -919,7 +983,7 @@ static void kill_delayed_threads_for_table(TABLE_SHARE *share) if ((in_use->system_thread & SYSTEM_THREAD_DELAYED_INSERT) && ! in_use->killed) { - in_use->killed= THD::KILL_CONNECTION; + in_use->killed= KILL_SYSTEM_THREAD; mysql_mutex_lock(&in_use->mysys_var->mutex); if (in_use->mysys_var->current_cond) { @@ -4410,6 +4474,20 @@ open_and_process_table(THD *thd, LEX *lex, TABLE_LIST *tables, thd->pop_internal_handler(); safe_to_ignore_table= no_such_table_handler.safely_trapped_errors(); } + else if (tables->parent_l && (thd->open_options & HA_OPEN_FOR_REPAIR)) + { + /* + Also fail silently for underlying tables of a MERGE table if this + table is opened for CHECK/REPAIR TABLE statement. This is needed + to provide complete list of problematic underlying tables in + CHECK/REPAIR TABLE output. + */ + Repair_mrg_table_error_handler repair_mrg_table_handler; + thd->push_internal_handler(&repair_mrg_table_handler); + error= open_table(thd, tables, new_frm_mem, ot_ctx); + thd->pop_internal_handler(); + safe_to_ignore_table= repair_mrg_table_handler.safely_trapped_errors(); + } else error= open_table(thd, tables, new_frm_mem, ot_ctx); @@ -6641,11 +6719,25 @@ find_field_in_tables(THD *thd, Item_ident *item, { SELECT_LEX *current_sel= thd->lex->current_select; SELECT_LEX *last_select= table_ref->select_lex; + bool all_merged= TRUE; + for (SELECT_LEX *sl= current_sel; sl && sl!=last_select; + sl=sl->outer_select()) + { + Item *subs= sl->master_unit()->item; + if (subs->type() == Item::SUBSELECT_ITEM && + ((Item_subselect*)subs)->substype() == Item_subselect::IN_SUBS && + ((Item_in_subselect*)subs)->test_strategy(SUBS_SEMI_JOIN)) + { + continue; + } + all_merged= FALSE; + break; + } /* If the field was an outer referencee, mark all selects using this sub query as dependent on the outer query */ - if (current_sel != last_select) + if (!all_merged && current_sel != last_select) { mark_select_range_as_dependent(thd, last_select, current_sel, found, *ref, item); @@ -7875,7 +7967,7 @@ bool setup_fields(THD *thd, Item **ref_pointer_array, if (item->with_sum_func && item->type() != Item::SUM_FUNC_ITEM && sum_func_list) item->split_sum_func(thd, ref_pointer_array, *sum_func_list); - thd->used_tables|= item->used_tables(); + thd->lex->used_tables|= item->used_tables(); thd->lex->current_select->cur_pos_in_select_list++; } thd->lex->current_select->is_item_list_lookup= save_is_item_list_lookup; @@ -8293,7 +8385,7 @@ insert_fields(THD *thd, Name_resolution_context *context, const char *db_name, views and natural joins this update is performed inside the loop below. */ if (table) - thd->used_tables|= table->map; + thd->lex->used_tables|= table->map; /* Initialize a generic field iterator for the current table reference. @@ -8384,7 +8476,7 @@ insert_fields(THD *thd, Name_resolution_context *context, const char *db_name, field_table= nj_col->table_ref->table; if (field_table) { - thd->used_tables|= field_table->map; + thd->lex->used_tables|= field_table->map; field_table->covering_keys.intersect(field->part_of_key); field_table->merge_keys.merge(field->part_of_key); field_table->used_fields++; @@ -8392,7 +8484,7 @@ insert_fields(THD *thd, Name_resolution_context *context, const char *db_name, } } else - thd->used_tables|= item->used_tables(); + thd->lex->used_tables|= item->used_tables(); thd->lex->current_select->cur_pos_in_select_list++; } /* @@ -8467,7 +8559,6 @@ int setup_conds(THD *thd, TABLE_LIST *tables, List<TABLE_LIST> &leaves, { SELECT_LEX *select_lex= thd->lex->current_select; TABLE_LIST *table= NULL; // For HP compilers - TABLE_LIST *save_emb_on_expr_nest= thd->thd_marker.emb_on_expr_nest; List_iterator<TABLE_LIST> ti(leaves); /* it_is_update set to TRUE when tables of primary SELECT_LEX (SELECT_LEX @@ -8504,7 +8595,6 @@ int setup_conds(THD *thd, TABLE_LIST *tables, List<TABLE_LIST> &leaves, goto err_no_arena; } - thd->thd_marker.emb_on_expr_nest= NO_JOIN_NEST; if (*conds) { thd->where="where clause"; @@ -8518,11 +8608,11 @@ int setup_conds(THD *thd, TABLE_LIST *tables, List<TABLE_LIST> &leaves, */ if ((*conds)->type() == Item::FIELD_ITEM && !derived) wrap_ident(thd, conds); + (*conds)->mark_as_condition_AND_part(NO_JOIN_NEST); if ((!(*conds)->fixed && (*conds)->fix_fields(thd, conds)) || (*conds)->check_cols(1)) goto err_no_arena; } - thd->thd_marker.emb_on_expr_nest= save_emb_on_expr_nest; /* Apply fix_fields() to all ON clauses at all levels of nesting, @@ -8538,8 +8628,8 @@ int setup_conds(THD *thd, TABLE_LIST *tables, List<TABLE_LIST> &leaves, if (embedded->on_expr) { /* Make a join an a expression */ - thd->thd_marker.emb_on_expr_nest= embedded; thd->where="on clause"; + embedded->on_expr->mark_as_condition_AND_part(embedded); if ((!embedded->on_expr->fixed && embedded->on_expr->fix_fields(thd, &embedded->on_expr)) || embedded->on_expr->check_cols(1)) @@ -8563,7 +8653,6 @@ int setup_conds(THD *thd, TABLE_LIST *tables, List<TABLE_LIST> &leaves, } } } - thd->thd_marker.emb_on_expr_nest= save_emb_on_expr_nest; if (!thd->stmt_arena->is_conventional()) { @@ -9016,7 +9105,7 @@ bool mysql_notify_thread_having_shared_lock(THD *thd, THD *in_use, if ((in_use->system_thread & SYSTEM_THREAD_DELAYED_INSERT) && !in_use->killed) { - in_use->killed= THD::KILL_CONNECTION; + in_use->killed= KILL_SYSTEM_THREAD; mysql_mutex_lock(&in_use->mysys_var->mutex); if (in_use->mysys_var->current_cond) mysql_cond_broadcast(in_use->mysys_var->current_cond); diff --git a/sql/sql_binlog.cc b/sql/sql_binlog.cc index 75a1af02bd2..5ddff949ce3 100644 --- a/sql/sql_binlog.cc +++ b/sql/sql_binlog.cc @@ -1,4 +1,5 @@ -/* Copyright (c) 2005, 2011, Oracle and/or its affiliates. All rights reserved. +/* + Copyright (c) 2005, 2011, Oracle and/or its affiliates. All rights reserved. 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/sql_binlog.h b/sql/sql_binlog.h index 50251eaac50..3a6d561701a 100644 --- a/sql/sql_binlog.h +++ b/sql/sql_binlog.h @@ -1,4 +1,4 @@ -/* Copyright 2006-2008 MySQL AB, 2008-2009 Sun Microsystems, Inc. +/* Copyright (c) 2006, 2010, Oracle and/or its affiliates. All rights reserved. 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/sql_bitmap.h b/sql/sql_bitmap.h index 558240ce19d..db4c7110ac7 100644 --- a/sql/sql_bitmap.h +++ b/sql/sql_bitmap.h @@ -1,4 +1,4 @@ -/* Copyright (C) 2003 MySQL AB +/* Copyright (c) 2003, 2010, Oracle and/or its affiliates. All rights reserved. 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 @@ -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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ /* Implementation of a bitmap type. diff --git a/sql/sql_builtin.cc.in b/sql/sql_builtin.cc.in index c4b8531fc5a..63850650ac9 100644 --- a/sql/sql_builtin.cc.in +++ b/sql/sql_builtin.cc.in @@ -1,4 +1,4 @@ -/* Copyright (C) 2006 MySQL AB +/* Copyright (c) 2006, 2010, Oracle and/or its affiliates. All rights reserved. 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/sql_cache.cc b/sql/sql_cache.cc index c32556c1b59..e3c9ecc1a36 100644 --- a/sql/sql_cache.cc +++ b/sql/sql_cache.cc @@ -1,4 +1,4 @@ -/* Copyright 2000-2008 MySQL AB, 2008-2009 Sun Microsystems, Inc. +/* Copyright (c) 2000, 2010, Oracle and/or its affiliates. All rights reserved. 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 @@ -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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ /* Description of the query cache: @@ -498,11 +498,12 @@ static void make_base_query(String *new_query, continue; // Continue with next symbol case '/': // Start of comment ? /* - Comment of format /#!number #/, must be skipped. + Comment of format /#!number #/ or /#M!number #/, must be skipped. These may include '"' and other comments, but it should be safe to parse the content as a normal string. */ - if (query[0] != '*' || query[1] == '!') + if (query[0] != '*' || query[1] == '!' || + (query[1] == 'M' && query[2] == '!')) break; query++; // skip "/" @@ -4453,7 +4454,7 @@ void Query_cache::wreck(uint line, const char *message) DBUG_PRINT("warning", ("%5d QUERY CACHE WRECK => DISABLED",line)); DBUG_PRINT("warning", ("==================================")); if (thd) - thd->killed= THD::KILL_CONNECTION; + thd->killed= KILL_CONNECTION; cache_dump(); /* check_integrity(0); */ /* Can't call it here because of locks */ bins_dump(); diff --git a/sql/sql_cache.h b/sql/sql_cache.h index 4701b9eae5c..87b861b34f8 100644 --- a/sql/sql_cache.h +++ b/sql/sql_cache.h @@ -1,4 +1,4 @@ -/* Copyright (C) 2001-2006 MySQL AB, 2008-2009 Sun Microsystems, Inc +/* Copyright (c) 2001, 2010, Oracle and/or its affiliates. All rights reserved. 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 @@ -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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ #ifndef _SQL_CACHE_H #define _SQL_CACHE_H diff --git a/sql/sql_callback.h b/sql/sql_callback.h index ea51c107ff9..316f94a0213 100644 --- a/sql/sql_callback.h +++ b/sql/sql_callback.h @@ -1,5 +1,5 @@ /* - Copyright (C) 2010, Oracle and/or its affiliates. All rights reserved. + Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved. 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 @@ -12,7 +12,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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ #ifndef SQL_CALLBACK_INCLUDED diff --git a/sql/sql_class.cc b/sql/sql_class.cc index cde5a431ec1..259e5f2fd4f 100644 --- a/sql/sql_class.cc +++ b/sql/sql_class.cc @@ -1,4 +1,5 @@ -/* Copyright (c) 2000, 2011, Oracle and/or its affiliates. All rights reserved. +/* + Copyright (c) 2000, 2011, Oracle and/or its affiliates. All rights reserved. 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 @@ -11,7 +12,8 @@ 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 02110-1301 USA */ + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +*/ /***************************************************************************** @@ -280,7 +282,7 @@ bool Foreign_key::validate(List<Create_field> &table_fields) */ void thd_set_killed(THD *thd) { - thd->killed= THD::KILL_CONNECTION; + thd->killed= KILL_CONNECTION; } /** @@ -499,11 +501,11 @@ const char *set_thd_proc_info(THD *thd, const char *info, thd= current_thd; const char *old_info= thd->proc_info; - const char *basename= calling_file ? base_name(calling_file) : NULL; - DBUG_PRINT("proc_info", ("%s:%d %s", basename, calling_line, info)); + DBUG_PRINT("proc_info", ("%s:%d %s", calling_file, calling_line, info)); #if defined(ENABLED_PROFILING) - thd->profiling.status_change(info, calling_function, basename, calling_line); + thd->profiling.status_change(info, + calling_function, calling_file, calling_line); #endif thd->proc_info= info; return old_info; @@ -620,7 +622,7 @@ char *thd_security_context(THD *thd, char *buffer, unsigned int length, { String str(buffer, length, &my_charset_latin1); const Security_context *sctx= &thd->main_security_ctx; - char header[64]; + char header[256]; int len; /* The pointers thd->query and thd->proc_info might change since they are @@ -634,8 +636,8 @@ char *thd_security_context(THD *thd, char *buffer, unsigned int length, const char *proc_info= thd->proc_info; len= my_snprintf(header, sizeof(header), - "MySQL thread id %lu, query id %lu", - thd->thread_id, (ulong) thd->query_id); + "MySQL thread id %lu, OS thread handle 0x%lx, query id %lu", + thd->thread_id, (ulong) thd->real_id, (ulong) thd->query_id); str.length(0); str.append(header, len); @@ -724,7 +726,7 @@ THD::THD() :Statement(&main_lex, &main_mem_root, STMT_CONVENTIONAL_EXECUTION, /* statement id */ 0), rli_fake(0), - in_sub_stmt(0), + in_sub_stmt(0), log_all_errors(0), binlog_unsafe_warning_flags(0), binlog_table_maps(0), table_map_for_update(0), @@ -777,7 +779,6 @@ THD::THD() is_slave_error= thread_specific_used= FALSE; my_hash_clear(&handler_tables_hash); tmp_table=0; - used_tables=0; cuted_fields= 0L; sent_row_count= 0L; limit_found_rows= 0; @@ -1057,7 +1058,7 @@ MYSQL_ERROR* THD::raise_condition(uint sql_errno, push_warning and strict SQL_MODE case. */ level= MYSQL_ERROR::WARN_LEVEL_ERROR; - killed= THD::KILL_BAD_DATA; + killed= KILL_BAD_DATA; } switch (level) @@ -1520,17 +1521,27 @@ void add_diff_to_status(STATUS_VAR *to_var, STATUS_VAR *from_var, @note Do always call this while holding LOCK_thd_data. */ -void THD::awake(THD::killed_state state_to_set) +void THD::awake(killed_state state_to_set) { DBUG_ENTER("THD::awake"); DBUG_PRINT("enter", ("this: %p current_thd: %p", this, current_thd)); THD_CHECK_SENTRY(this); mysql_mutex_assert_owner(&LOCK_thd_data); + if (global_system_variables.log_warnings > 3) + { + Security_context *sctx= security_ctx; + sql_print_warning(ER(ER_NEW_ABORTING_CONNECTION), + thread_id,(db ? db : "unconnected"), + sctx->user ? sctx->user : "unauthenticated", + sctx->host_or_ip, + "KILLED"); + } + /* Set the 'killed' flag of 'this', which is the target THD object. */ killed= state_to_set; - if (state_to_set != THD::KILL_QUERY) + if (state_to_set >= KILL_CONNECTION || state_to_set == NOT_KILLED) { #ifdef SIGNAL_WITH_VIO_CLOSE if (this != current_thd) @@ -1651,7 +1662,7 @@ void THD::disconnect() mysql_mutex_lock(&LOCK_thd_data); - killed= THD::KILL_CONNECTION; + killed= KILL_CONNECTION; #ifdef SIGNAL_WITH_VIO_CLOSE /* @@ -1672,6 +1683,37 @@ void THD::disconnect() /* + Get error number for killed state + Note that the error message can't have any parameters. + See thd::kill_message() +*/ + +int killed_errno(killed_state killed) +{ + switch (killed) { + case NOT_KILLED: + case KILL_HARD_BIT: + return 0; // Probably wrong usage + case KILL_BAD_DATA: + case KILL_BAD_DATA_HARD: + return 0; // Not a real error + case KILL_CONNECTION: + case KILL_CONNECTION_HARD: + case KILL_SYSTEM_THREAD: + case KILL_SYSTEM_THREAD_HARD: + return ER_CONNECTION_KILLED; + case KILL_QUERY: + case KILL_QUERY_HARD: + return ER_QUERY_INTERRUPTED; + case KILL_SERVER: + case KILL_SERVER_HARD: + return ER_SERVER_SHUTDOWN; + } + return 0; // Keep compiler happy +} + + +/* Remember the location of thread info, the structure needed for sql_alloc() and the structure for the net buffer */ @@ -2911,26 +2953,32 @@ bool select_max_min_finder_subselect::cmp_real() { Item *maxmin= ((Item_singlerow_subselect *)item)->element_index(0); double val1= cache->val_real(), val2= maxmin->val_real(); + + /* Ignore NULLs for ANY and keep them for ALL subqueries */ + if (cache->null_value) + return (is_all && !maxmin->null_value) || (!is_all && maxmin->null_value); + if (maxmin->null_value) + return !is_all; + if (fmax) - return (cache->null_value && !maxmin->null_value) || - (!cache->null_value && !maxmin->null_value && - val1 > val2); - return (maxmin->null_value && !cache->null_value) || - (!cache->null_value && !maxmin->null_value && - val1 < val2); + return(val1 > val2); + return (val1 < val2); } bool select_max_min_finder_subselect::cmp_int() { Item *maxmin= ((Item_singlerow_subselect *)item)->element_index(0); longlong val1= cache->val_int(), val2= maxmin->val_int(); + + /* Ignore NULLs for ANY and keep them for ALL subqueries */ + if (cache->null_value) + return (is_all && !maxmin->null_value) || (!is_all && maxmin->null_value); + if (maxmin->null_value) + return !is_all; + if (fmax) - return (cache->null_value && !maxmin->null_value) || - (!cache->null_value && !maxmin->null_value && - val1 > val2); - return (maxmin->null_value && !cache->null_value) || - (!cache->null_value && !maxmin->null_value && - val1 < val2); + return(val1 > val2); + return (val1 < val2); } bool select_max_min_finder_subselect::cmp_decimal() @@ -2938,13 +2986,16 @@ bool select_max_min_finder_subselect::cmp_decimal() Item *maxmin= ((Item_singlerow_subselect *)item)->element_index(0); my_decimal cval, *cvalue= cache->val_decimal(&cval); my_decimal mval, *mvalue= maxmin->val_decimal(&mval); + + /* Ignore NULLs for ANY and keep them for ALL subqueries */ + if (cache->null_value) + return (is_all && !maxmin->null_value) || (!is_all && maxmin->null_value); + if (maxmin->null_value) + return !is_all; + if (fmax) - return (cache->null_value && !maxmin->null_value) || - (!cache->null_value && !maxmin->null_value && - my_decimal_cmp(cvalue, mvalue) > 0) ; - return (maxmin->null_value && !cache->null_value) || - (!cache->null_value && !maxmin->null_value && - my_decimal_cmp(cvalue,mvalue) < 0); + return (my_decimal_cmp(cvalue, mvalue) > 0) ; + return (my_decimal_cmp(cvalue,mvalue) < 0); } bool select_max_min_finder_subselect::cmp_str() @@ -2957,13 +3008,16 @@ bool select_max_min_finder_subselect::cmp_str() */ val1= cache->val_str(&buf1); val2= maxmin->val_str(&buf1); + + /* Ignore NULLs for ANY and keep them for ALL subqueries */ + if (cache->null_value) + return (is_all && !maxmin->null_value) || (!is_all && maxmin->null_value); + if (maxmin->null_value) + return !is_all; + if (fmax) - return (cache->null_value && !maxmin->null_value) || - (!cache->null_value && !maxmin->null_value && - sortcmp(val1, val2, cache->collation.collation) > 0) ; - return (maxmin->null_value && !cache->null_value) || - (!cache->null_value && !maxmin->null_value && - sortcmp(val1, val2, cache->collation.collation) < 0); + return (sortcmp(val1, val2, cache->collation.collation) > 0) ; + return (sortcmp(val1, val2, cache->collation.collation) < 0); } int select_exists_subselect::send_data(List<Item> &items) @@ -3696,11 +3750,15 @@ void THD::restore_backup_open_tables_state(Open_tables_backup *backup) @param thd user thread @retval 0 the user thread is active @retval 1 the user thread has been killed + + This is used to signal a storage engine if it should be killed. */ extern "C" int thd_killed(const MYSQL_THD thd) { - return(thd->killed); + if (!(thd->killed & KILL_HARD_BIT)) + return 0; + return thd->killed; } @@ -4149,16 +4207,24 @@ void THD::set_mysys_var(struct st_my_thread_var *new_mysys_var) void THD::leave_locked_tables_mode() { + if (locked_tables_mode == LTM_LOCK_TABLES) + { + /* + When leaving LOCK TABLES mode we have to change the duration of most + of the metadata locks being held, except for HANDLER and GRL locks, + to transactional for them to be properly released at UNLOCK TABLES. + */ + mdl_context.set_transaction_duration_for_all_locks(); + /* + Make sure we don't release the global read lock and commit blocker + when leaving LTM. + */ + global_read_lock.set_explicit_lock_duration(this); + /* Also ensure that we don't release metadata locks for open HANDLERs. */ + if (handler_tables_hash.records) + mysql_ha_set_explicit_lock_duration(this); + } locked_tables_mode= LTM_NONE; - mdl_context.set_transaction_duration_for_all_locks(); - /* - Make sure we don't release the global read lock and commit blocker - when leaving LTM. - */ - global_read_lock.set_explicit_lock_duration(this); - /* Also ensure that we don't release metadata locks for open HANDLERs. */ - if (handler_tables_hash.records) - mysql_ha_set_explicit_lock_duration(this); } void THD::get_definer(LEX_USER *definer) diff --git a/sql/sql_class.h b/sql/sql_class.h index e2786356ac1..70f47521711 100644 --- a/sql/sql_class.h +++ b/sql/sql_class.h @@ -398,6 +398,36 @@ typedef enum enum_diag_condition_item_name */ extern const LEX_STRING Diag_condition_item_names[]; +/* Note: these states are actually bit coded with HARD */ +enum killed_state +{ + NOT_KILLED= 0, + KILL_HARD_BIT= 1, /* Bit for HARD KILL */ + KILL_BAD_DATA= 2, + KILL_BAD_DATA_HARD= 3, + KILL_QUERY= 4, + KILL_QUERY_HARD= 5, + /* + All of the following killed states will kill the connection + KILL_CONNECTION must be the first of these! + */ + KILL_CONNECTION= 6, + KILL_CONNECTION_HARD= 7, + KILL_SYSTEM_THREAD= 8, + KILL_SYSTEM_THREAD_HARD= 9, + KILL_SERVER= 10, + KILL_SERVER_HARD= 11 +}; + +extern int killed_errno(killed_state killed); +#define killed_mask_hard(killed) ((killed_state) ((killed) & ~KILL_HARD_BIT)) + +enum killed_type +{ + KILL_TYPE_ID, + KILL_TYPE_USER +}; + #include "sql_lex.h" /* Must be here */ class Delayed_insert; @@ -483,14 +513,14 @@ typedef struct system_variables ulong log_slow_rate_limit; ulong binlog_format; ///< binlog format for this thd (see enum_binlog_format) ulong progress_report_time; - my_bool binlog_annotate_rows_events; + my_bool binlog_annotate_row_events; my_bool binlog_direct_non_trans_update; my_bool sql_log_bin; ulong completion_type; ulong query_cache_type; ulong tx_isolation; ulong updatable_views_with_limit; - uint max_user_connections; + int max_user_connections; /** In slave thread we need to know in behalf of which thread the query is being run to replicate temp tables properly @@ -1664,19 +1694,12 @@ public: uint in_sub_stmt; /* True when opt_userstat_running is set at start of query */ bool userstat_running; + /* True if we want to log all errors */ + bool log_all_errors; /* container for handler's private per-connection data */ Ha_data ha_data[MAX_HA]; - /* Place to store various things */ - union - { - /* - Used by subquery optimizations, see Item_in_subselect::emb_on_expr_nest. - */ - TABLE_LIST *emb_on_expr_nest; - } thd_marker; - bool prepare_derived_at_open; /* @@ -2062,13 +2085,6 @@ public: */ ha_rows examined_row_count; - /* - The set of those tables whose fields are referenced in all subqueries - of the query. - TODO: possibly this it is incorrect to have used tables in THD because - with more than one subquery, it is not clear what does the field mean. - */ - table_map used_tables; USER_CONN *user_connect; CHARSET_INFO *db_charset; Warning_info *warning_info; @@ -2135,14 +2151,6 @@ public: condition. For details see the implementation of awake(), especially the "broadcast" part. */ - enum killed_state - { - NOT_KILLED=0, - KILL_BAD_DATA=1, - KILL_CONNECTION=ER_SERVER_SHUTDOWN, - KILL_QUERY=ER_QUERY_INTERRUPTED, - KILLED_NO_VALUE /* means neither of the states */ - }; killed_state volatile killed; /* scramble - random string sent to client on handshake */ @@ -2341,7 +2349,7 @@ public: } void close_active_vio(); #endif - void awake(THD::killed_state state_to_set); + void awake(killed_state state_to_set); /** Disconnect the associated communication endpoint. */ void disconnect(); @@ -2653,18 +2661,13 @@ public: void end_statement(); inline int killed_errno() const { - killed_state killed_val; /* to cache the volatile 'killed' */ - return (killed_val= killed) != KILL_BAD_DATA ? killed_val : 0; + return ::killed_errno(killed); } inline void send_kill_message() const { int err= killed_errno(); if (err) - { - if ((err == KILL_CONNECTION) && !shutdown_in_progress) - err = KILL_QUERY; my_message(err, ER(err), MYF(0)); - } } /* return TRUE if we will abort query if we make a warning now */ inline bool really_abort_on_warning() @@ -2955,7 +2958,19 @@ public: { DBUG_ASSERT(locked_tables_mode == LTM_NONE); - mdl_context.set_explicit_duration_for_all_locks(); + if (mode_arg == LTM_LOCK_TABLES) + { + /* + When entering LOCK TABLES mode we should set explicit duration + for all metadata locks acquired so far in order to avoid releasing + them till UNLOCK TABLES statement. + We don't do this when entering prelocked mode since sub-statements + don't release metadata locks and restoring status-quo after leaving + prelocking mode gets complicated. + */ + mdl_context.set_explicit_duration_for_all_locks(); + } + locked_tables_mode= mode_arg; } void leave_locked_tables_mode(); @@ -3582,9 +3597,11 @@ class select_max_min_finder_subselect :public select_subselect Item_cache *cache; bool (select_max_min_finder_subselect::*op)(); bool fmax; + bool is_all; public: - select_max_min_finder_subselect(Item_subselect *item_arg, bool mx) - :select_subselect(item_arg), cache(0), fmax(mx) + select_max_min_finder_subselect(Item_subselect *item_arg, bool mx, + bool all) + :select_subselect(item_arg), cache(0), fmax(mx), is_all(all) {} void cleanup(); int send_data(List<Item> &items); @@ -4036,14 +4053,6 @@ void add_diff_to_status(STATUS_VAR *to_var, STATUS_VAR *from_var, STATUS_VAR *dec_var); void mark_transaction_to_rollback(THD *thd, bool all); -/* - This prototype is placed here instead of in item_func.h because it - depends on the definition of enum_sql_command, which is in this - file. - */ -int get_var_with_binlog(THD *thd, enum_sql_command sql_command, - LEX_STRING &name, user_var_entry **out_entry); - /* Inline functions */ inline bool add_item_to_list(THD *thd, Item *item) diff --git a/sql/sql_client.cc b/sql/sql_client.cc index 0c16449276a..22a7867012a 100644 --- a/sql/sql_client.cc +++ b/sql/sql_client.cc @@ -1,4 +1,4 @@ -/* Copyright (C) 2003 MySQL AB +/* Copyright (c) 2003, 2010, Oracle and/or its affiliates. All rights reserved. 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 @@ -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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ /* This files defines some MySQL C API functions that are server specific diff --git a/sql/sql_connect.cc b/sql/sql_connect.cc index b2e37758d5b..bcffad06ad1 100644 --- a/sql/sql_connect.cc +++ b/sql/sql_connect.cc @@ -1,4 +1,5 @@ -/* Copyright (c) 2007, 2011, Oracle and/or its affiliates. All rights reserved. +/* + Copyright (c) 2007, 2011, Oracle and/or its affiliates. All rights reserved. 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 @@ -11,7 +12,8 @@ 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 02110-1301 USA */ + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +*/ /* Functions to autenticate and handle reqests for a connection @@ -124,9 +126,12 @@ int check_for_max_user_connections(THD *thd, USER_CONN *uc) DBUG_ENTER("check_for_max_user_connections"); mysql_mutex_lock(&LOCK_user_conn); + + /* Root is not affected by the value of max_user_connections */ if (global_system_variables.max_user_connections && !uc->user_resources.user_conn && - global_system_variables.max_user_connections < (uint) uc->connections) + global_system_variables.max_user_connections < uc->connections && + !(thd->security_ctx->master_access & SUPER_ACL)) { my_error(ER_TOO_MANY_USER_CONNECTIONS, MYF(0), uc->user); goto end; @@ -222,7 +227,7 @@ void time_out_user_resource_limits(THD *thd, USER_CONN *uc) /* If more than a hour since last check, reset resource checking */ if (check_time - uc->reset_utime >= LL(3600000000)) { - uc->questions=1; + uc->questions=0; uc->updates=0; uc->conn_per_hour=0; uc->reset_utime= check_time; @@ -251,7 +256,7 @@ bool check_mqh(THD *thd, uint check_command) if (uc->user_resources.questions && uc->questions++ >= uc->user_resources.questions) { - my_error(ER_USER_LIMIT_REACHED, MYF(0), uc->user, "max_questions", + my_error(ER_USER_LIMIT_REACHED, MYF(0), uc->user, "max_queries_per_hour", (long) uc->user_resources.questions); error=1; goto end; @@ -263,7 +268,7 @@ bool check_mqh(THD *thd, uint check_command) (sql_command_flags[check_command] & CF_CHANGES_DATA) && uc->updates++ >= uc->user_resources.updates) { - my_error(ER_USER_LIMIT_REACHED, MYF(0), uc->user, "max_updates", + my_error(ER_USER_LIMIT_REACHED, MYF(0), uc->user, "max_updates_per_hour", (long) uc->user_resources.updates); error=1; goto end; @@ -1110,7 +1115,7 @@ void prepare_new_connection_state(THD* thd) execute_init_command(thd, &opt_init_connect, &LOCK_sys_init_connect); if (thd->is_error()) { - thd->killed= THD::KILL_CONNECTION; + thd->killed= KILL_CONNECTION; sql_print_warning(ER(ER_NEW_ABORTING_CONNECTION), thd->thread_id,(thd->db ? thd->db : "unconnected"), sctx->user ? sctx->user : "unauthenticated", @@ -1172,7 +1177,7 @@ bool thd_is_connection_alive(THD *thd) NET *net= &thd->net; if (!net->error && net->vio != 0 && - !(thd->killed == THD::KILL_CONNECTION)) + thd->killed < KILL_CONNECTION) return TRUE; return FALSE; } @@ -1182,6 +1187,8 @@ void do_handle_one_connection(THD *thd_arg) THD *thd= thd_arg; thd->thr_create_utime= microsecond_interval_timer(); + /* We need to set this because of time_out_user_resource_limits */ + thd->start_utime= thd->thr_create_utime; if (MYSQL_CALLBACK_ELSE(thread_scheduler, init_new_connection_thread, (), 0)) { diff --git a/sql/sql_connect.h b/sql/sql_connect.h index 32d6af72a92..bab171606ba 100644 --- a/sql/sql_connect.h +++ b/sql/sql_connect.h @@ -1,4 +1,4 @@ -/* Copyright 2006-2008 MySQL AB, 2008-2009 Sun Microsystems, Inc. +/* Copyright (c) 2006, 2011, Oracle and/or its affiliates. All rights reserved. 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/sql_const.h b/sql/sql_const.h index 1b2580a2680..cfbf077bd91 100644 --- a/sql/sql_const.h +++ b/sql/sql_const.h @@ -1,4 +1,4 @@ -/* Copyright 2006-2008 MySQL AB, 2008-2009 Sun Microsystems, Inc. +/* Copyright (c) 2006, 2010, Oracle and/or its affiliates. All rights reserved. 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/sql_crypt.cc b/sql/sql_crypt.cc index 0271884b5f3..bcc8ad0b10f 100644 --- a/sql/sql_crypt.cc +++ b/sql/sql_crypt.cc @@ -1,4 +1,4 @@ -/* Copyright (C) 2000-2001, 2003, 2005 MySQL AB +/* Copyright (c) 2000, 2010, Oracle and/or its affiliates. All rights reserved. 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 @@ -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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ diff --git a/sql/sql_crypt.h b/sql/sql_crypt.h index 4dfd5e82e5a..3a12d603601 100644 --- a/sql/sql_crypt.h +++ b/sql/sql_crypt.h @@ -1,7 +1,7 @@ #ifndef SQL_CRYPT_INCLUDED #define SQL_CRYPT_INCLUDED -/* Copyright (C) 2000-2001, 2005 MySQL AB +/* Copyright (c) 2000, 2010, Oracle and/or its affiliates. All rights reserved. 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 @@ -14,7 +14,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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ #ifdef USE_PRAGMA_INTERFACE diff --git a/sql/sql_cursor.h b/sql/sql_cursor.h index d19d14fa167..bff47d654b3 100644 --- a/sql/sql_cursor.h +++ b/sql/sql_cursor.h @@ -1,4 +1,4 @@ -/* Copyright (C) 2005 MySQL AB +/* Copyright (c) 2005, 2011, Oracle and/or its affiliates. All rights reserved. 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 @@ -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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ #ifndef _sql_cursor_h_ #define _sql_cursor_h_ diff --git a/sql/sql_db.cc b/sql/sql_db.cc index 6b5f4a335d5..2301dae5fdf 100644 --- a/sql/sql_db.cc +++ b/sql/sql_db.cc @@ -1,4 +1,5 @@ -/* Copyright (c) 2000, 2011, Oracle and/or its affiliates. All rights reserved. +/* + Copyright (c) 2000, 2011, Oracle and/or its affiliates. All rights reserved. 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 @@ -31,6 +32,7 @@ #include "sql_base.h" // lock_table_names, tdc_remove_table #include "sql_handler.h" // mysql_ha_rm_tables #include <mysys_err.h> +#include "sp_head.h" #include "sp.h" #include "events.h" #include "sql_handler.h" @@ -40,6 +42,7 @@ #ifdef __WIN__ #include <direct.h> #endif +#include "debug_sync.h" #define MAX_DROP_TABLE_Q_LEN 1024 @@ -1530,6 +1533,8 @@ bool mysql_change_db(THD *thd, const LEX_STRING *new_db_name, bool force_switch) } #endif + DEBUG_SYNC(thd, "before_db_dir_check"); + if (check_db_dir_existence(new_db_file_name.str)) { if (force_switch) diff --git a/sql/sql_db.h b/sql/sql_db.h index c99bdb63fc5..1f447c11a52 100644 --- a/sql/sql_db.h +++ b/sql/sql_db.h @@ -1,4 +1,4 @@ -/* Copyright 2006-2008 MySQL AB, 2008-2009 Sun Microsystems, Inc. +/* Copyright (c) 2006, 2010, Oracle and/or its affiliates. All rights reserved. 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/sql_delete.cc b/sql/sql_delete.cc index 9cc63f7b33d..efce55cc18a 100644 --- a/sql/sql_delete.cc +++ b/sql/sql_delete.cc @@ -1,4 +1,4 @@ -/* Copyright (C) 2000 MySQL AB, 2008-2009 Sun Microsystems, Inc +/* Copyright (c) 2000, 2010, Oracle and/or its affiliates. All rights reserved. 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 @@ -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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ /* Delete of records tables. @@ -63,7 +63,7 @@ bool mysql_delete(THD *thd, TABLE_LIST *table_list, COND *conds, order_list->first : NULL); uint usable_index= MAX_KEY; SELECT_LEX *select_lex= &thd->lex->select_lex; - THD::killed_state killed_status= THD::NOT_KILLED; + killed_state killed_status= NOT_KILLED; THD::enum_binlog_query_type query_type= THD::ROW_QUERY_TYPE; DBUG_ENTER("mysql_delete"); @@ -379,7 +379,7 @@ bool mysql_delete(THD *thd, TABLE_LIST *table_list, COND *conds, table->file->unlock_row(); // Row failed selection, release lock on it } killed_status= thd->killed; - if (killed_status != THD::NOT_KILLED || thd->is_error()) + if (killed_status != NOT_KILLED || thd->is_error()) error= 1; // Aborted if (will_batch && (loc_error= table->file->end_bulk_delete())) { @@ -424,8 +424,8 @@ cleanup: if (error < 0) thd->clear_error(); else - errcode= query_error_code(thd, killed_status == THD::NOT_KILLED); - + errcode= query_error_code(thd, killed_status == NOT_KILLED); + /* [binlog]: If 'handler::delete_all_rows()' was called and the storage engine does not inject the rows itself, we replicate @@ -870,7 +870,7 @@ void multi_delete::abort_result_set() */ if (mysql_bin_log.is_open()) { - int errcode= query_error_code(thd, thd->killed == THD::NOT_KILLED); + int errcode= query_error_code(thd, thd->killed == NOT_KILLED); /* possible error of writing binary log is ignored deliberately */ (void) thd->binlog_query(THD::ROW_QUERY_TYPE, thd->query(), thd->query_length(), @@ -1019,7 +1019,7 @@ int multi_delete::do_table_deletes(TABLE *table, bool ignore) bool multi_delete::send_eof() { - THD::killed_state killed_status= THD::NOT_KILLED; + killed_state killed_status= NOT_KILLED; thd_proc_info(thd, "deleting from reference tables"); /* Does deletes for the last n - 1 tables, returns 0 if ok */ @@ -1027,7 +1027,7 @@ bool multi_delete::send_eof() /* compute a total error to know if something failed */ local_error= local_error || error; - killed_status= (local_error == 0)? THD::NOT_KILLED : thd->killed; + killed_status= (local_error == 0)? NOT_KILLED : thd->killed; /* reset used flags */ thd_proc_info(thd, "end"); @@ -1050,7 +1050,7 @@ bool multi_delete::send_eof() if (local_error == 0) thd->clear_error(); else - errcode= query_error_code(thd, killed_status == THD::NOT_KILLED); + errcode= query_error_code(thd, killed_status == NOT_KILLED); if (thd->binlog_query(THD::ROW_QUERY_TYPE, thd->query(), thd->query_length(), transactional_tables, FALSE, FALSE, errcode) && diff --git a/sql/sql_delete.h b/sql/sql_delete.h index 264991c220b..6147e0ea367 100644 --- a/sql/sql_delete.h +++ b/sql/sql_delete.h @@ -1,4 +1,4 @@ -/* Copyright 2006-2008 MySQL AB, 2008-2009 Sun Microsystems, Inc. +/* Copyright (c) 2006, 2010, Oracle and/or its affiliates. All rights reserved. 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/sql_derived.cc b/sql/sql_derived.cc index 03cbf38d4ef..dee2f01fb15 100644 --- a/sql/sql_derived.cc +++ b/sql/sql_derived.cc @@ -1,4 +1,4 @@ -/* Copyright (C) 2002-2003 MySQL AB +/* Copyright (c) 2002, 2011, Oracle and/or its affiliates. All rights reserved. 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 @@ -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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ /* diff --git a/sql/sql_derived.h b/sql/sql_derived.h index e96c363d5f5..f232445879e 100644 --- a/sql/sql_derived.h +++ b/sql/sql_derived.h @@ -1,4 +1,4 @@ -/* Copyright 2006-2008 MySQL AB, 2008-2009 Sun Microsystems, Inc. +/* Copyright (c) 2006, 2010, Oracle and/or its affiliates. All rights reserved. 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/sql_do.cc b/sql/sql_do.cc index 085473c24b8..4ba887b5ab2 100644 --- a/sql/sql_do.cc +++ b/sql/sql_do.cc @@ -1,4 +1,4 @@ -/* Copyright (C) 2000-2006 MySQL AB +/* Copyright (c) 2000, 2010, Oracle and/or its affiliates. All rights reserved. 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 @@ -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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ /* Execute DO statement */ diff --git a/sql/sql_do.h b/sql/sql_do.h index 56479f8f88e..35130cc5836 100644 --- a/sql/sql_do.h +++ b/sql/sql_do.h @@ -1,4 +1,4 @@ -/* Copyright 2006-2008 MySQL AB, 2008-2009 Sun Microsystems, Inc. +/* Copyright (c) 2006, 2010, Oracle and/or its affiliates. All rights reserved. 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/sql_error.cc b/sql/sql_error.cc index 7988523dd3b..06da6250e71 100644 --- a/sql/sql_error.cc +++ b/sql/sql_error.cc @@ -806,14 +806,16 @@ uint32 convert_error_message(char *to, uint32 to_length, CHARSET_INFO *to_cs, my_wc_t wc; const uchar *from_end= (const uchar*) from+from_length; char *to_start= to; - uchar *to_end= (uchar*) to+to_length; + uchar *to_end; my_charset_conv_mb_wc mb_wc= from_cs->cset->mb_wc; my_charset_conv_wc_mb wc_mb; uint error_count= 0; uint length; DBUG_ASSERT(to_length > 0); + /* Make room for the null terminator. */ to_length--; + to_end= (uchar*) (to + to_length); if (!to_cs || from_cs == to_cs || to_cs == &my_charset_bin) { diff --git a/sql/sql_handler.cc b/sql/sql_handler.cc index 460d2f07cfd..0439a3c8265 100644 --- a/sql/sql_handler.cc +++ b/sql/sql_handler.cc @@ -1,4 +1,4 @@ -/* Copyright (c) 2000, 2011, Oracle and/or its affiliates. +/* Copyright (c) 2001, 2011, Oracle and/or its affiliates. Copyright (c) 2011 Monty Program Ab This program is free software; you can redistribute it and/or modify diff --git a/sql/sql_help.cc b/sql/sql_help.cc index 56a16d9b668..ca0e695b3fe 100644 --- a/sql/sql_help.cc +++ b/sql/sql_help.cc @@ -1,4 +1,4 @@ -/* Copyright (c) 2000, 2011, Oracle and/or its affiliates. All rights reserved. +/* Copyright (c) 2002, 2011, Oracle and/or its affiliates. All rights reserved. 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/sql_help.h b/sql/sql_help.h index 74cff691730..b6ae490e757 100644 --- a/sql/sql_help.h +++ b/sql/sql_help.h @@ -1,4 +1,4 @@ -/* Copyright 2006-2008 MySQL AB, 2008-2009 Sun Microsystems, Inc. +/* Copyright (c) 2006, 2010, Oracle and/or its affiliates. All rights reserved. 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/sql_insert.cc b/sql/sql_insert.cc index 8b2884b7f35..70c66d6cf29 100644 --- a/sql/sql_insert.cc +++ b/sql/sql_insert.cc @@ -1,4 +1,5 @@ -/* Copyright (c) 2000, 2011, Oracle and/or its affiliates. All rights reserved. +/* + Copyright (c) 2000, 2011, Oracle and/or its affiliates. All rights reserved. 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 @@ -11,7 +12,8 @@ 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 02110-1301 USA */ + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +*/ /* Insert of records */ @@ -731,7 +733,7 @@ bool mysql_insert(THD *thd,TABLE_LIST *table_list, lock_type= table_list->lock_type; thd_proc_info(thd, "init"); - thd->used_tables=0; + thd->lex->used_tables=0; values= its++; value_count= values->elements; @@ -890,7 +892,7 @@ bool mysql_insert(THD *thd,TABLE_LIST *table_list, } else { - if (thd->used_tables) // Column used in values() + if (thd->lex->used_tables) // Column used in values() restore_record(table,s->default_values); // Get empty record else { @@ -1024,7 +1026,7 @@ bool mysql_insert(THD *thd,TABLE_LIST *table_list, thd->clear_error(); } else - errcode= query_error_code(thd, thd->killed == THD::NOT_KILLED); + errcode= query_error_code(thd, thd->killed == NOT_KILLED); /* bug#22725: @@ -1038,7 +1040,7 @@ bool mysql_insert(THD *thd,TABLE_LIST *table_list, routines did not result in any error due to the KILLED. In such case the flag is ignored for constructing binlog event. */ - DBUG_ASSERT(thd->killed != THD::KILL_BAD_DATA || error > 0); + DBUG_ASSERT(thd->killed != KILL_BAD_DATA || error > 0); if (was_insert_delayed && table_list->lock_type == TL_WRITE) { /* Binlog INSERT DELAYED as INSERT without DELAYED. */ @@ -1663,9 +1665,6 @@ int write_record(THD *thd, TABLE *table,COPY_INFO *info) goto before_trg_err; table->file->restore_auto_increment(prev_insert_id); - if (table->next_number_field) - table->file->adjust_next_insert_id_after_explicit_value( - table->next_number_field->val_int()); info->touched++; if (!records_are_comparable(table) || compare_record(table)) { @@ -1702,8 +1701,6 @@ int write_record(THD *thd, TABLE *table,COPY_INFO *info) if (table->next_number_field) table->file->adjust_next_insert_id_after_explicit_value( table->next_number_field->val_int()); - info->touched++; - goto ok_or_after_trg_err; } else /* DUP_REPLACE */ @@ -2139,7 +2136,7 @@ bool delayed_get_table(THD *thd, MDL_request *grl_protection_request, /* Annotating delayed inserts is not supported. */ - di->thd.variables.binlog_annotate_rows_events= 0; + di->thd.variables.binlog_annotate_row_events= 0; di->thd.set_db(table_list->db, (uint) strlen(table_list->db)); di->thd.set_query(my_strdup(table_list->table_name, @@ -2525,7 +2522,7 @@ void kill_delayed_threads(void) Delayed_insert *di; while ((di= it++)) { - di->thd.killed= THD::KILL_CONNECTION; + di->thd.killed= KILL_CONNECTION; mysql_mutex_lock(&di->thd.LOCK_thd_data); if (di->thd.mysys_var) { @@ -2663,7 +2660,7 @@ pthread_handler_t handle_delayed_insert(void *arg) thd->thread_id= thd->variables.pseudo_thread_id= thread_id++; thd->set_current_time(); threads.append(thd); - thd->killed=abort_loop ? THD::KILL_CONNECTION : THD::NOT_KILLED; + thd->killed=abort_loop ? KILL_CONNECTION : NOT_KILLED; mysql_mutex_unlock(&LOCK_thread_count); mysql_thread_set_psi_id(thd->thread_id); @@ -2785,7 +2782,7 @@ pthread_handler_t handle_delayed_insert(void *arg) #endif #endif if (error == ETIMEDOUT || error == ETIME) - thd->killed= THD::KILL_CONNECTION; + thd->killed= KILL_CONNECTION; } /* We can't lock di->mutex and mysys_var->mutex at the same time */ mysql_mutex_unlock(&di->mutex); @@ -2812,7 +2809,7 @@ pthread_handler_t handle_delayed_insert(void *arg) if (! (thd->lock= mysql_lock_tables(thd, &di->table, 1, 0))) { /* Fatal error */ - thd->killed= THD::KILL_CONNECTION; + thd->killed= KILL_CONNECTION; } mysql_cond_broadcast(&di->cond_client); } @@ -2821,7 +2818,7 @@ pthread_handler_t handle_delayed_insert(void *arg) if (di->handle_inserts()) { /* Some fatal error */ - thd->killed= THD::KILL_CONNECTION; + thd->killed= KILL_CONNECTION; } } di->status=0; @@ -2854,7 +2851,7 @@ pthread_handler_t handle_delayed_insert(void *arg) } di->table=0; - thd->killed= THD::KILL_CONNECTION; // If error + thd->killed= KILL_CONNECTION; // If error mysql_mutex_unlock(&di->mutex); close_thread_tables(thd); // Free the table @@ -2940,7 +2937,7 @@ bool Delayed_insert::handle_inserts(void) max_rows= delayed_insert_limit; if (thd.killed || table->s->has_old_version()) { - thd.killed= THD::KILL_CONNECTION; + thd.killed= KILL_SYSTEM_THREAD; max_rows= ULONG_MAX; // Do as much as possible } @@ -3553,7 +3550,7 @@ bool select_insert::send_eof() bool const trans_table= table->file->has_transactions(); ulonglong id, row_count; bool changed; - THD::killed_state killed_status= thd->killed; + killed_state killed_status= thd->killed; DBUG_ENTER("select_insert::send_eof"); DBUG_PRINT("enter", ("trans_table=%d, table_type='%s'", trans_table, table->file->table_type())); @@ -3594,7 +3591,7 @@ bool select_insert::send_eof() if (!error) thd->clear_error(); else - errcode= query_error_code(thd, killed_status == THD::NOT_KILLED); + errcode= query_error_code(thd, killed_status == NOT_KILLED); if (thd->binlog_query(THD::ROW_QUERY_TYPE, thd->query(), thd->query_length(), trans_table, FALSE, FALSE, errcode)) @@ -3673,7 +3670,7 @@ void select_insert::abort_result_set() { if (mysql_bin_log.is_open()) { - int errcode= query_error_code(thd, thd->killed == THD::NOT_KILLED); + int errcode= query_error_code(thd, thd->killed == NOT_KILLED); /* error of writing binary log is ignored */ (void) thd->binlog_query(THD::ROW_QUERY_TYPE, thd->query(), thd->query_length(), @@ -4064,7 +4061,7 @@ select_create::binlog_show_create_table(TABLE **tables, uint count) if (mysql_bin_log.is_open()) { - int errcode= query_error_code(thd, thd->killed == THD::NOT_KILLED); + int errcode= query_error_code(thd, thd->killed == NOT_KILLED); result= thd->binlog_query(THD::STMT_QUERY_TYPE, query.ptr(), query.length(), /* is_trans */ TRUE, diff --git a/sql/sql_insert.h b/sql/sql_insert.h index 9511cee8526..8564f4d103e 100644 --- a/sql/sql_insert.h +++ b/sql/sql_insert.h @@ -1,4 +1,4 @@ -/* Copyright 2006-2008 MySQL AB, 2008-2009 Sun Microsystems, Inc. +/* Copyright (c) 2006, 2010, Oracle and/or its affiliates. All rights reserved. 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/sql_join_cache.cc b/sql/sql_join_cache.cc index b0fdb7a1c42..76d01b076f0 100644 --- a/sql/sql_join_cache.cc +++ b/sql/sql_join_cache.cc @@ -226,8 +226,6 @@ void JOIN_CACHE::calc_record_fields() flag_fields+= test(tab->table->maybe_null); fields+= tab->used_fields; blobs+= tab->used_blobs; - - fields+= tab->check_rowid_field(); } if ((with_match_flag= join_tab->use_match_flag())) flag_fields++; @@ -621,7 +619,12 @@ void JOIN_CACHE::create_remaining_fields() copy->type= CACHE_ROWID; copy->field= 0; copy->referenced_field_no= 0; - length+= copy->length; + /* + Note: this may seem odd, but at this point we have + table->file->ref==NULL while table->file->ref_length is already set + to correct value. + */ + length += table->file->ref_length; data_field_count++; copy++; } @@ -1298,6 +1301,7 @@ uint JOIN_CACHE::write_record_data(uchar * link, bool *is_full) if (with_length) { rec_len_ptr= cp; + DBUG_ASSERT(cp + size_of_rec_len <= buff + buff_size); cp+= size_of_rec_len; } @@ -1307,6 +1311,7 @@ uint JOIN_CACHE::write_record_data(uchar * link, bool *is_full) */ if (prev_cache) { + DBUG_ASSERT(cp + prev_cache->get_size_of_rec_offset() <= buff + buff_size); cp+= prev_cache->get_size_of_rec_offset(); prev_cache->store_rec_ref(cp, link); } @@ -1323,6 +1328,7 @@ uint JOIN_CACHE::write_record_data(uchar * link, bool *is_full) flags_pos= cp; for ( ; copy < copy_end; copy++) { + DBUG_ASSERT(cp + copy->length <= buff + buff_size); memcpy(cp, copy->str, copy->length); cp+= copy->length; } @@ -1349,6 +1355,7 @@ uint JOIN_CACHE::write_record_data(uchar * link, bool *is_full) { last_rec_blob_data_is_in_rec_buff= 1; /* Put down the length of the blob and the pointer to the data */ + DBUG_ASSERT(cp + copy->length + sizeof(char*) <= buff + buff_size); blob_field->get_image(cp, copy->length+sizeof(char*), blob_field->charset()); cp+= copy->length+sizeof(char*); @@ -1358,6 +1365,7 @@ uint JOIN_CACHE::write_record_data(uchar * link, bool *is_full) /* First put down the length of the blob and then copy the data */ blob_field->get_image(cp, copy->length, blob_field->charset()); + DBUG_ASSERT(cp + copy->length + copy->blob_length <= buff + buff_size); memcpy(cp+copy->length, copy->str, copy->blob_length); cp+= copy->length+copy->blob_length; } @@ -1368,12 +1376,14 @@ uint JOIN_CACHE::write_record_data(uchar * link, bool *is_full) case CACHE_VARSTR1: /* Copy the significant part of the short varstring field */ len= (uint) copy->str[0] + 1; + DBUG_ASSERT(cp + len <= buff + buff_size); memcpy(cp, copy->str, len); cp+= len; break; case CACHE_VARSTR2: /* Copy the significant part of the long varstring field */ len= uint2korr(copy->str) + 2; + DBUG_ASSERT(cp + len <= buff + buff_size); memcpy(cp, copy->str, len); cp+= len; break; @@ -1388,6 +1398,7 @@ uint JOIN_CACHE::write_record_data(uchar * link, bool *is_full) end > str && end[-1] == ' '; end--) ; len=(uint) (end-str); + DBUG_ASSERT(cp + len + 2 <= buff + buff_size); int2store(cp, len); memcpy(cp+2, str, len); cp+= len+2; @@ -1403,11 +1414,22 @@ uint JOIN_CACHE::write_record_data(uchar * link, bool *is_full) TABLE *table= (TABLE *) copy->str; copy->str= table->file->ref; copy->length= table->file->ref_length; + if (!copy->str) + { + /* + If table is an empty inner table of an outer join and it is + a materialized derived table then table->file->ref == NULL. + */ + cp+= copy->length; + break; + } } /* fall through */ default: /* Copy the entire image of the field from the record buffer */ - memcpy(cp, copy->str, copy->length); + DBUG_ASSERT(cp + copy->length <= buff + buff_size); + if (copy->str) + memcpy(cp, copy->str, copy->length); cp+= copy->length; } } @@ -1426,6 +1448,7 @@ uint JOIN_CACHE::write_record_data(uchar * link, bool *is_full) cnt++; } } + DBUG_ASSERT(cp + size_of_fld_ofs*cnt <= buff + buff_size); cp+= size_of_fld_ofs*cnt; } @@ -1799,6 +1822,13 @@ uint JOIN_CACHE::read_record_field(CACHE_FIELD *copy, bool blob_in_rec_buff) memset(copy->str+len, ' ', copy->length-len); len+= 2; break; + case CACHE_ROWID: + if (!copy->str) + { + len= copy->length; + break; + } + /* fall through */ default: /* Copy the entire image of the field from the record buffer */ len= copy->length; @@ -2022,6 +2052,7 @@ enum_nested_loop_state JOIN_CACHE::join_records(bool skip_last) JOIN_TAB *tab; enum_nested_loop_state rc= NESTED_LOOP_OK; bool outer_join_first_inner= join_tab->is_first_inner_for_outer_join(); + DBUG_ENTER("JOIN_CACHE::join_records"); if (outer_join_first_inner && !join_tab->first_unmatched) join_tab->not_null_compl= TRUE; @@ -2103,7 +2134,8 @@ enum_nested_loop_state JOIN_CACHE::join_records(bool skip_last) finish: restore_last_record(); reset(TRUE); - return rc; + DBUG_PRINT("exit", ("rc: %d", rc)); + DBUG_RETURN(rc); } @@ -2165,10 +2197,11 @@ enum_nested_loop_state JOIN_CACHE::join_matching_records(bool skip_last) join_tab->table->null_row= 0; bool check_only_first_match= join_tab->check_only_first_match(); bool outer_join_first_inner= join_tab->is_first_inner_for_outer_join(); + DBUG_ENTER("JOIN_CACHE::join_matching_records"); /* Return at once if there are no records in the join buffer */ if (!records) - return NESTED_LOOP_OK; + DBUG_RETURN(NESTED_LOOP_OK); /* When joining we read records from the join buffer back into record buffers. @@ -2242,7 +2275,7 @@ finish: rc= error < 0 ? NESTED_LOOP_NO_MORE_ROWS: NESTED_LOOP_ERROR; finish2: join_tab_scan->close(); - return rc; + DBUG_RETURN(rc); } @@ -2324,6 +2357,7 @@ bool JOIN_CACHE::set_match_flag_if_none(JOIN_TAB *first_inner, enum_nested_loop_state JOIN_CACHE::generate_full_extensions(uchar *rec_ptr) { enum_nested_loop_state rc= NESTED_LOOP_OK; + DBUG_ENTER("JOIN_CACHE::generate_full_extensions"); /* Check whether the extended partial join record meets @@ -2341,16 +2375,18 @@ enum_nested_loop_state JOIN_CACHE::generate_full_extensions(uchar *rec_ptr) if (rc != NESTED_LOOP_OK && rc != NESTED_LOOP_NO_MORE_ROWS) { reset(TRUE); - return rc; + DBUG_RETURN(rc); } } if (res == -1) { rc= NESTED_LOOP_ERROR; - return rc; + DBUG_RETURN(rc); } } - return rc; + else if (join->thd->is_error()) + rc= NESTED_LOOP_ERROR; + DBUG_RETURN(rc); } @@ -2375,16 +2411,20 @@ enum_nested_loop_state JOIN_CACHE::generate_full_extensions(uchar *rec_ptr) RETURN VALUE TRUE there is a match FALSE there is no match + In this case the caller must also check thd->is_error() to see + if there was a fatal error for the query. */ inline bool JOIN_CACHE::check_match(uchar *rec_ptr) { /* Check whether pushdown conditions are satisfied */ + DBUG_ENTER("JOIN_CACHE:check_match"); + if (join_tab->select && join_tab->select->skip_record(join->thd) <= 0) - return FALSE; + DBUG_RETURN(FALSE); if (!join_tab->is_last_inner_table()) - return TRUE; + DBUG_RETURN(TRUE); /* This is the last inner table of an outer join, @@ -2397,7 +2437,7 @@ inline bool JOIN_CACHE::check_match(uchar *rec_ptr) set_match_flag_if_none(first_inner, rec_ptr); if (first_inner->check_only_first_match() && !join_tab->first_inner) - return TRUE; + DBUG_RETURN(TRUE); /* This is the first match for the outer table row. The function set_match_flag_if_none has turned the flag @@ -2411,13 +2451,12 @@ inline bool JOIN_CACHE::check_match(uchar *rec_ptr) for (JOIN_TAB *tab= first_inner; tab <= join_tab; tab++) { if (tab->select && tab->select->skip_record(join->thd) <= 0) - return FALSE; + DBUG_RETURN(FALSE); } } while ((first_inner= first_inner->first_upper) && first_inner->last_inner == join_tab); - - return TRUE; + DBUG_RETURN(TRUE); } @@ -2452,10 +2491,11 @@ enum_nested_loop_state JOIN_CACHE::join_null_complements(bool skip_last) ulonglong cnt; enum_nested_loop_state rc= NESTED_LOOP_OK; bool is_first_inner= join_tab == join_tab->first_unmatched; + DBUG_ENTER("JOIN_CACHE::join_null_complements"); /* Return at once if there are no records in the join buffer */ if (!records) - return NESTED_LOOP_OK; + DBUG_RETURN(NESTED_LOOP_OK); cnt= records - (is_key_access() ? 0 : test(skip_last)); @@ -2485,7 +2525,7 @@ enum_nested_loop_state JOIN_CACHE::join_null_complements(bool skip_last) } finish: - return rc; + DBUG_RETURN(rc); } diff --git a/sql/sql_lex.cc b/sql/sql_lex.cc index 984b4c998b4..a9d542756fb 100644 --- a/sql/sql_lex.cc +++ b/sql/sql_lex.cc @@ -1,4 +1,4 @@ -/* Copyright 2000-2008 MySQL AB, 2008 Sun Microsystems, Inc. +/* Copyright (c) 2000, 2011, Oracle and/or its affiliates. All rights reserved. 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 @@ -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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ /* A lexical scanner on a temporary buffer with a yacc interface */ @@ -25,8 +25,8 @@ #include "item_create.h" #include <m_ctype.h> #include <hash.h> -#include "sp.h" #include "sp_head.h" +#include "sp.h" #include "sql_select.h" static int lex_one_token(void *arg, void *yythd); @@ -60,6 +60,12 @@ Query_tables_list::binlog_stmt_unsafe_errcode[BINLOG_STMT_UNSAFE_COUNT] = ER_BINLOG_UNSAFE_NONTRANS_AFTER_TRANS, ER_BINLOG_UNSAFE_MULTIPLE_ENGINES_AND_SELF_LOGGING_ENGINE, ER_BINLOG_UNSAFE_MIXED_STATEMENT, + ER_BINLOG_UNSAFE_INSERT_IGNORE_SELECT, + ER_BINLOG_UNSAFE_INSERT_SELECT_UPDATE, + ER_BINLOG_UNSAFE_REPLACE_SELECT, + ER_BINLOG_UNSAFE_CREATE_IGNORE_SELECT, + ER_BINLOG_UNSAFE_CREATE_REPLACE_SELECT, + ER_BINLOG_UNSAFE_UPDATE_IGNORE }; @@ -497,6 +503,7 @@ void lex_start(THD *thd) lex->event_parse_data= NULL; lex->profile_options= PROFILE_NONE; lex->nest_level=0 ; + lex->select_lex.nest_level_base= &lex->unit; lex->allow_sum_func= 0; lex->in_sum_func= NULL; /* @@ -516,6 +523,8 @@ void lex_start(THD *thd) lex->server_options.port= -1; lex->is_lex_started= TRUE; + lex->used_tables= 0; + lex->reset_slave_info.all= false; DBUG_VOID_RETURN; } @@ -1491,39 +1500,39 @@ int lex_one_token(void *arg, void *yythd) lip->save_in_comment_state(); + if (lip->yyPeekn(2) == 'M' && lip->yyPeekn(3) == '!') + { + /* Skip MariaDB unique marker */ + lip->set_echo(FALSE); + lip->yySkip(); + /* The following if will be true */ + } if (lip->yyPeekn(2) == '!') { lip->in_comment= DISCARD_COMMENT; /* Accept '/' '*' '!', but do not keep this marker. */ lip->set_echo(FALSE); - lip->yySkip(); - lip->yySkip(); - lip->yySkip(); + lip->yySkipn(3); /* The special comment format is very strict: - '/' '*' '!', followed by exactly + '/' '*' '!', followed by an optional 'M' and exactly 1 digit (major), 2 digits (minor), then 2 digits (dot). 32302 -> 3.23.02 50032 -> 5.0.32 50114 -> 5.1.14 */ - char version_str[6]; - version_str[0]= lip->yyPeekn(0); - version_str[1]= lip->yyPeekn(1); - version_str[2]= lip->yyPeekn(2); - version_str[3]= lip->yyPeekn(3); - version_str[4]= lip->yyPeekn(4); - version_str[5]= 0; - if ( my_isdigit(cs, version_str[0]) - && my_isdigit(cs, version_str[1]) - && my_isdigit(cs, version_str[2]) - && my_isdigit(cs, version_str[3]) - && my_isdigit(cs, version_str[4]) + if ( my_isdigit(cs, lip->yyPeekn(0)) + && my_isdigit(cs, lip->yyPeekn(1)) + && my_isdigit(cs, lip->yyPeekn(2)) + && my_isdigit(cs, lip->yyPeekn(3)) + && my_isdigit(cs, lip->yyPeekn(4)) ) { ulong version; - version=strtol(version_str, NULL, 10); + char *end_ptr= (char*) lip->get_ptr()+5; + int error; + version= (ulong) my_strtoll10(lip->get_ptr(), &end_ptr, &error); if (version <= MYSQL_VERSION_ID) { @@ -1856,8 +1865,9 @@ void st_select_lex::init_query() exclude_from_table_unique_test= no_wrap_view_item= FALSE; nest_level= 0; link_next= 0; + m_non_agg_field_used= false; + m_agg_func_used= false; is_prep_leaf_list_saved= FALSE; - bzero((char*) expr_cache_may_be_used, sizeof(expr_cache_may_be_used)); } @@ -1891,7 +1901,8 @@ void st_select_lex::init_select() non_agg_fields.empty(); cond_value= having_value= Item::COND_UNDEF; inner_refs_list.empty(); - full_group_by_flag= 0; + m_non_agg_field_used= false; + m_agg_func_used= false; insert_tables= 0; merged_into= 0; } @@ -2275,6 +2286,9 @@ bool st_select_lex::setup_ref_array(THD *thd, uint order_group_num) if (ref_pointer_array) DBUG_RETURN(0); + // find_order_in_list() may need some extra space, so multiply by two. + order_group_num*= 2; + /* We have to create array in prepared statement memory if it is a prepared statement @@ -3442,18 +3456,19 @@ void st_select_lex::append_table_to_list(TABLE_LIST *TABLE_LIST::*link, tl->*link= table; } + /* @brief - Remove given table from the leaf_tables list. + Replace given table from the leaf_tables list for a list of tables - @param link Offset to which list in table structure to use - @param table Table to remove + @param table Table to replace + @param list List to substititute the table for @details - Remove 'table' from the leaf_tables list using the 'link' offset. + Replace 'table' from the leaf_tables list for a list of tables 'tbl_list'. */ -void st_select_lex::remove_table_from_list(TABLE_LIST *table) +void st_select_lex::replace_leaf_table(TABLE_LIST *table, List<TABLE_LIST> &tbl_list) { TABLE_LIST *tl; List_iterator<TABLE_LIST> ti(leaf_tables); @@ -3461,7 +3476,7 @@ void st_select_lex::remove_table_from_list(TABLE_LIST *table) { if (tl == table) { - ti.remove(); + ti.replace(tbl_list); break; } } @@ -3566,8 +3581,6 @@ bool SELECT_LEX::merge_subquery(THD *thd, TABLE_LIST *derived, uint table_no, table_map map) { derived->wrap_into_nested_join(subq_select->top_join_list); - /* Reconnect the next_leaf chain. */ - leaf_tables.concat(&subq_select->leaf_tables); ftfunc_list->concat(subq_select->ftfunc_list); if (join || @@ -3583,18 +3596,14 @@ bool SELECT_LEX::merge_subquery(THD *thd, TABLE_LIST *derived, in_subq->emb_on_expr_nest= derived; } } - /* - Remove merged table from chain. - When merge_subquery is called at a subquery-to-semijoin transformation - the derived isn't in the leaf_tables list, so in this case the call of - remove_table_from_list does not cause any actions. - */ - remove_table_from_list(derived); /* Walk through child's tables and adjust table map, tablenr, * parent_lex */ subq_select->remap_tables(derived, map, table_no, this); subq_select->merged_into= this; + + replace_leaf_table(derived, subq_select->leaf_tables); + return FALSE; } @@ -3635,10 +3644,33 @@ void SELECT_LEX::update_used_tables() { TABLE_LIST *tl; List_iterator<TABLE_LIST> ti(leaf_tables); + while ((tl= ti++)) { - TABLE_LIST *embedding; - embedding= tl; + if (tl->table && !tl->is_view_or_derived()) + { + TABLE_LIST *embedding= tl->embedding; + for (embedding= tl->embedding; embedding; embedding=embedding->embedding) + { + if (embedding->is_view_or_derived()) + { + DBUG_ASSERT(embedding->is_merged_derived()); + TABLE *tab= tl->table; + tab->covering_keys= tab->s->keys_for_keyread; + tab->covering_keys.intersect(tab->keys_in_use_for_query); + tab->merge_keys.clear_all(); + bitmap_clear_all(tab->read_set); + bitmap_clear_all(tab->vcol_set); + break; + } + } + } + } + + ti.rewind(); + while ((tl= ti++)) + { + TABLE_LIST *embedding= tl; do { bool maybe_null; @@ -3667,6 +3699,7 @@ void SELECT_LEX::update_used_tables() embedding= tl->embedding; } } + if (join->conds) { join->conds->update_used_tables(); @@ -3849,6 +3882,47 @@ bool st_select_lex::save_prep_leaf_tables(THD *thd) } +/* + Return true if this select_lex has been converted into a semi-join nest + within 'ancestor'. + + We need a loop to check this because there could be several nested + subselects, like + + SELECT ... FROM grand_parent + WHERE expr1 IN (SELECT ... FROM parent + WHERE expr2 IN ( SELECT ... FROM child) + + which were converted into: + + SELECT ... + FROM grand_parent SEMI_JOIN (parent JOIN child) + WHERE + expr1 AND expr2 + + In this case, both parent and child selects were merged into the parent. +*/ + +bool st_select_lex::is_merged_child_of(st_select_lex *ancestor) +{ + bool all_merged= TRUE; + for (SELECT_LEX *sl= this; sl && sl!=ancestor; + sl=sl->outer_select()) + { + Item *subs= sl->master_unit()->item; + if (subs && subs->type() == Item::SUBSELECT_ITEM && + ((Item_subselect*)subs)->substype() == Item_subselect::IN_SUBS && + ((Item_in_subselect*)subs)->test_strategy(SUBS_SEMI_JOIN)) + { + continue; + } + all_merged= FALSE; + break; + } + return all_merged; +} + + /** A routine used by the parser to decide whether we are specifying a full partitioning or if only partitions to add or to split. diff --git a/sql/sql_lex.h b/sql/sql_lex.h index 1c72586e5f7..c776dfc5a8c 100644 --- a/sql/sql_lex.h +++ b/sql/sql_lex.h @@ -1,4 +1,4 @@ -/* Copyright 2000-2008 MySQL AB, 2008 Sun Microsystems, Inc. +/* Copyright (c) 2000, 2011, Oracle and/or its affiliates. All rights reserved. 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 @@ -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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ /** @defgroup Semantic_Analysis Semantic Analysis @@ -314,6 +314,10 @@ struct LEX_MASTER_INFO } }; +typedef struct st_lex_reset_slave +{ + bool all; +} LEX_RESET_SLAVE; enum sub_select_type { @@ -798,6 +802,13 @@ public: ulong table_join_options; uint in_sum_expr; uint select_number; /* number of select (used for EXPLAIN) */ + + /* + nest_levels are local to the query or VIEW, + and that view merge procedure does not re-calculate them. + So we also have to remember unit against which we count levels. + */ + SELECT_LEX_UNIT *nest_level_base; int nest_level; /* nesting level of select */ Item_sum *inner_sum_func_list; /* list of sum func in nested selects */ uint with_wild; /* item list contain '*' */ @@ -865,16 +876,7 @@ public: joins on the right. */ List<String> *prev_join_using; - /* - Bitmap used in the ONLY_FULL_GROUP_BY_MODE to prevent mixture of aggregate - functions and non aggregated fields when GROUP BY list is absent. - Bits: - 0 - non aggregated fields are used in this select, - defined as NON_AGG_FIELD_USED. - 1 - aggregate functions are used in this select, - defined as SUM_FUNC_USED. - */ - uint8 full_group_by_flag; + void init_query(); void init_select(); st_select_lex_unit* master_unit(); @@ -995,7 +997,7 @@ public: bool handle_derived(LEX *lex, uint phases); void append_table_to_list(TABLE_LIST *TABLE_LIST::*link, TABLE_LIST *table); bool get_free_table_map(table_map *map, uint *tablenr); - void remove_table_from_list(TABLE_LIST *table); + void replace_leaf_table(TABLE_LIST *table, List<TABLE_LIST> &tbl_list); void remap_tables(TABLE_LIST *derived, table_map map, uint tablenr, st_select_lex *parent_lex); bool merge_subquery(THD *thd, TABLE_LIST *derived, st_select_lex *subq_lex, @@ -1014,8 +1016,24 @@ public: bool save_leaf_tables(THD *thd); bool save_prep_leaf_tables(THD *thd); + bool is_merged_child_of(st_select_lex *ancestor); + + /* + For MODE_ONLY_FULL_GROUP_BY we need to maintain two flags: + - Non-aggregated fields are used in this select. + - Aggregate functions are used in this select. + In MODE_ONLY_FULL_GROUP_BY only one of these may be true. + */ + bool non_agg_field_used() const { return m_non_agg_field_used; } + bool agg_func_used() const { return m_agg_func_used; } + + void set_non_agg_field_used(bool val) { m_non_agg_field_used= val; } + void set_agg_func_used(bool val) { m_agg_func_used= val; } + +private: + bool m_non_agg_field_used; + bool m_agg_func_used; -private: /* current index hint kind. used in filling up index_hints */ enum index_hint_type current_index_hint_type; index_clause_map current_index_hint_clause; @@ -1341,6 +1359,48 @@ public: */ BINLOG_STMT_UNSAFE_MIXED_STATEMENT, + /** + INSERT...IGNORE SELECT is unsafe because which rows are ignored depends + on the order that rows are retrieved by SELECT. This order cannot be + predicted and may differ on master and the slave. + */ + BINLOG_STMT_UNSAFE_INSERT_IGNORE_SELECT, + + /** + INSERT...SELECT...UPDATE is unsafe because which rows are updated depends + on the order that rows are retrieved by SELECT. This order cannot be + predicted and may differ on master and the slave. + */ + BINLOG_STMT_UNSAFE_INSERT_SELECT_UPDATE, + + /** + INSERT...REPLACE SELECT is unsafe because which rows are replaced depends + on the order that rows are retrieved by SELECT. This order cannot be + predicted and may differ on master and the slave. + */ + BINLOG_STMT_UNSAFE_REPLACE_SELECT, + + /** + CREATE TABLE... IGNORE... SELECT is unsafe because which rows are ignored + depends on the order that rows are retrieved by SELECT. This order cannot + be predicted and may differ on master and the slave. + */ + BINLOG_STMT_UNSAFE_CREATE_IGNORE_SELECT, + + /** + CREATE TABLE...REPLACE... SELECT is unsafe because which rows are replaced + depends on the order that rows are retrieved from SELECT. This order + cannot be predicted and may differ on master and the slave + */ + BINLOG_STMT_UNSAFE_CREATE_REPLACE_SELECT, + + /** + UPDATE...IGNORE is unsafe because which rows are ignored depends on the + order that rows are updated. This order cannot be predicted and may differ + on master and the slave. + */ + BINLOG_STMT_UNSAFE_UPDATE_IGNORE, + /* The last element of this enumeration type. */ BINLOG_STMT_UNSAFE_COUNT }; @@ -2323,7 +2383,11 @@ struct LEX: public Query_tables_list LEX_MASTER_INFO mi; // used by CHANGE MASTER LEX_SERVER_OPTIONS server_options; USER_RESOURCES mqh; + LEX_RESET_SLAVE reset_slave_info; ulong type; + /* The following is used by KILL */ + killed_state kill_signal; + killed_type kill_type; /* This variable is used in post-parse stage to declare that sum-functions, or functions which have sense only if GROUP BY is present, are allowed. @@ -2495,6 +2559,16 @@ struct LEX: public Query_tables_list bool escape_used; bool is_lex_started; /* If lex_start() did run. For debugging. */ + /* + The set of those tables whose fields are referenced in all subqueries + of the query. + TODO: possibly this it is incorrect to have used tables in LEX because + with subquery, it is not clear what does the field mean. To fix this + we should aggregate used tables information for selected expressions + into the select_lex. + */ + table_map used_tables; + LEX(); virtual ~LEX() diff --git a/sql/sql_list.cc b/sql/sql_list.cc index a256212471d..2c1b3c47d55 100644 --- a/sql/sql_list.cc +++ b/sql/sql_list.cc @@ -1,4 +1,4 @@ -/* Copyright (C) 2000-2001, 2003, 2005 MySQL AB +/* Copyright (c) 2000, 2010, Oracle and/or its affiliates. All rights reserved. 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 @@ -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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ #ifdef USE_PRAGMA_IMPLEMENTATION diff --git a/sql/sql_list.h b/sql/sql_list.h index 46e9923c51a..894edc4516d 100644 --- a/sql/sql_list.h +++ b/sql/sql_list.h @@ -1,6 +1,6 @@ #ifndef INCLUDES_MYSQL_SQL_LIST_H #define INCLUDES_MYSQL_SQL_LIST_H -/* Copyright (C) 2000-2003 MySQL AB +/* Copyright (c) 2000, 2010, Oracle and/or its affiliates. All rights reserved. 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 @@ -13,7 +13,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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ #ifdef USE_PRAGMA_INTERFACE #pragma interface /* gcc class implementation */ @@ -314,6 +314,26 @@ public: friend class error_list; friend class error_list_iterator; + /* + Debugging help: return N-th element in the list, or NULL if the list has + less than N elements. + */ + inline void *nth_element(int n) + { + list_node *node= first; + void *data= NULL; + for (int i=0; i <= n; i++) + { + if (node == &end_of_list) + { + data= NULL; + break; + } + data= node->info; + node= node->next; + } + return data; + } #ifdef LIST_EXTRA_DEBUG /* Check list invariants and print results into trace. Invariants are: @@ -492,6 +512,7 @@ public: } empty(); } + inline T *nth_element(int n) { return (T*)base_list::nth_element(n); } }; diff --git a/sql/sql_load.cc b/sql/sql_load.cc index 5acddc19bed..bc926118723 100644 --- a/sql/sql_load.cc +++ b/sql/sql_load.cc @@ -1,4 +1,5 @@ -/* Copyright (c) 2000, 2011 Oracle and/or its affiliates. All rights reserved. +/* + Copyright (c) 2000, 2011, Oracle and/or its affiliates. All rights reserved. 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 @@ -11,7 +12,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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ /* Copy data from a textfile to table */ @@ -178,7 +179,8 @@ int mysql_load(THD *thd,sql_exchange *ex,TABLE_LIST *table_list, bool is_fifo=0; #ifndef EMBEDDED_LIBRARY LOAD_FILE_INFO lf_info; - THD::killed_state killed_status= THD::NOT_KILLED; + killed_state killed_status; + bool is_concurrent; #endif char *db = table_list->db; // This is never null /* @@ -189,7 +191,6 @@ int mysql_load(THD *thd,sql_exchange *ex,TABLE_LIST *table_list, char *tdb= thd->db ? thd->db : db; // Result is never null ulong skip_lines= ex->skip_lines; bool transactional_table; - bool is_concurrent; DBUG_ENTER("mysql_load"); /* @@ -261,7 +262,9 @@ int mysql_load(THD *thd,sql_exchange *ex,TABLE_LIST *table_list, table= table_list->table; transactional_table= table->file->has_transactions(); +#ifndef EMBEDDED_LIBRARY is_concurrent= (table_list->lock_type == TL_WRITE_CONCURRENT_INSERT); +#endif if (!fields_vars.elements) { @@ -403,8 +406,8 @@ int mysql_load(THD *thd,sql_exchange *ex,TABLE_LIST *table_list, #if !defined(__WIN__) && ! defined(__NETWARE__) MY_STAT stat_info; - if (!my_stat(name,&stat_info,MYF(MY_WME))) - DBUG_RETURN(TRUE); + if (!my_stat(name, &stat_info, MYF(MY_WME))) + DBUG_RETURN(TRUE); // if we are not in slave thread, the file must be: if (!thd->slave_thread && @@ -412,11 +415,11 @@ int mysql_load(THD *thd,sql_exchange *ex,TABLE_LIST *table_list, ((stat_info.st_mode & S_IFREG) == S_IFREG || // regular file (stat_info.st_mode & S_IFIFO) == S_IFIFO))) // named pipe { - my_error(ER_TEXTFILE_NOT_READABLE, MYF(0), name); - DBUG_RETURN(TRUE); + my_error(ER_TEXTFILE_NOT_READABLE, MYF(0), name); + DBUG_RETURN(TRUE); } if ((stat_info.st_mode & S_IFIFO) == S_IFIFO) - is_fifo = 1; + is_fifo= 1; #endif if ((file= mysql_file_open(key_file_load, name, O_RDONLY, MYF(MY_WME))) < 0) @@ -526,11 +529,11 @@ int mysql_load(THD *thd,sql_exchange *ex,TABLE_LIST *table_list, DBUG_EXECUTE_IF("simulate_kill_bug27571", { error=1; - thd->killed= THD::KILL_QUERY; + thd->killed= KILL_QUERY; };); #ifndef EMBEDDED_LIBRARY - killed_status= (error == 0) ? THD::NOT_KILLED : thd->killed; + killed_status= (error == 0) ? NOT_KILLED : thd->killed; #endif /* @@ -574,8 +577,8 @@ int mysql_load(THD *thd,sql_exchange *ex,TABLE_LIST *table_list, /* If the file was not empty, wrote_create_file is true */ if (lf_info.wrote_create_file) { - int errcode= query_error_code(thd, killed_status == THD::NOT_KILLED); - + int errcode= query_error_code(thd, killed_status == NOT_KILLED); + /* since there is already an error, the possible error of writing binary log will be ignored */ if (thd->transaction.stmt.modified_non_trans_table) @@ -627,7 +630,7 @@ int mysql_load(THD *thd,sql_exchange *ex,TABLE_LIST *table_list, read_info.end_io_cache(); if (lf_info.wrote_create_file) { - int errcode= query_error_code(thd, killed_status == THD::NOT_KILLED); + int errcode= query_error_code(thd, killed_status == NOT_KILLED); error= write_execute_load_query_log_event(thd, ex, table_list->db, table_list->table_name, is_concurrent, diff --git a/sql/sql_load.h b/sql/sql_load.h index 344b869854a..f767e39387b 100644 --- a/sql/sql_load.h +++ b/sql/sql_load.h @@ -1,4 +1,4 @@ -/* Copyright 2006-2008 MySQL AB, 2008-2009 Sun Microsystems, Inc. +/* Copyright (c) 2006, 2010, Oracle and/or its affiliates. All rights reserved. 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/sql_locale.cc b/sql/sql_locale.cc index c8aee307362..13e00c99f19 100644 --- a/sql/sql_locale.cc +++ b/sql/sql_locale.cc @@ -1,4 +1,4 @@ -/* Copyright (C) 2005 MySQL AB +/* Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved. 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 @@ -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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ /* The beginnings of locale(7) support. diff --git a/sql/sql_locale.h b/sql/sql_locale.h index e62660aaa47..8357a9ecba4 100644 --- a/sql/sql_locale.h +++ b/sql/sql_locale.h @@ -1,4 +1,4 @@ -/* Copyright 2006-2008 MySQL AB, 2008-2009 Sun Microsystems, Inc. +/* Copyright (c) 2006, 2010, Oracle and/or its affiliates. All rights reserved. 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/sql_manager.cc b/sql/sql_manager.cc index e3929066361..221ba56130a 100644 --- a/sql/sql_manager.cc +++ b/sql/sql_manager.cc @@ -1,4 +1,4 @@ -/* Copyright (C) 2000, 2002, 2005 MySQL AB, 2008-2009 Sun Microsystems, Inc +/* Copyright (c) 2000, 2010, Oracle and/or its affiliates. All rights reserved. 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 @@ -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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ /* * sql_manager.cc diff --git a/sql/sql_manager.h b/sql/sql_manager.h index a0ef8080aa7..8debbe6ead9 100644 --- a/sql/sql_manager.h +++ b/sql/sql_manager.h @@ -1,4 +1,4 @@ -/* Copyright 2006-2008 MySQL AB, 2008-2009 Sun Microsystems, Inc. +/* Copyright (c) 2006, 2010, Oracle and/or its affiliates. All rights reserved. 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/sql_parse.cc b/sql/sql_parse.cc index ad5aa281ea7..714542ab0af 100644 --- a/sql/sql_parse.cc +++ b/sql/sql_parse.cc @@ -118,7 +118,8 @@ "FUNCTION" : "PROCEDURE") static bool execute_sqlcom_select(THD *thd, TABLE_LIST *all_tables); -static void sql_kill(THD *thd, ulong id, bool only_kill_query); +static void sql_kill(THD *thd, ulong id, killed_state state); +static void sql_kill_user(THD *thd, LEX_USER *user, killed_state state); static bool execute_show_status(THD *, TABLE_LIST *); static bool execute_rename_table(THD *, TABLE_LIST *, TABLE_LIST *); @@ -1325,7 +1326,7 @@ bool dispatch_command(enum enum_server_command command, THD *thd, length= my_snprintf(buff, buff_len - 1, "Uptime: %lu Threads: %d Questions: %lu " "Slow queries: %lu Opens: %lu Flush tables: %lu " - "Open tables: %u Queries per second avg: %u.%u", + "Open tables: %u Queries per second avg: %u.%03u", uptime, (int) thread_count, (ulong) thd->query_id, current_global_status_var->long_query_count, @@ -1362,7 +1363,7 @@ bool dispatch_command(enum enum_server_command command, THD *thd, { status_var_increment(thd->status_var.com_stat[SQLCOM_KILL]); ulong id=(ulong) uint4korr(packet); - sql_kill(thd,id,false); + sql_kill(thd,id, KILL_CONNECTION_HARD); break; } case COM_SET_OPTION: @@ -1443,6 +1444,9 @@ bool dispatch_command(enum enum_server_command command, THD *thd, } MYSQL_COMMAND_DONE(res); } + + /* Check that some variables are reset properly */ + DBUG_ASSERT(thd->abort_on_warning == 0); DBUG_RETURN(error); } @@ -2066,6 +2070,11 @@ mysql_execute_command(THD *thd) */ if (stmt_causes_implicit_commit(thd, CF_IMPLICT_COMMIT_BEGIN)) { + /* + Note that this should never happen inside of stored functions + or triggers as all such statements prohibited there. + */ + DBUG_ASSERT(! thd->in_sub_stmt); /* Commit or rollback the statement transaction. */ thd->is_error() ? trans_rollback_stmt(thd) : trans_commit_stmt(thd); /* Commit the normal transaction if one is active. */ @@ -2366,6 +2375,12 @@ case SQLCOM_PREPARE: goto end_with_restore_list; #endif /* + If no engine type was given, work out the default now + rather than at parse-time. + */ + if (!(create_info.used_fields & HA_CREATE_USED_ENGINE)) + create_info.db_type= ha_default_handlerton(thd); + /* If we are using SET CHARSET without DEFAULT, add an implicit DEFAULT to not confuse old users. (This may change). */ @@ -2399,6 +2414,19 @@ case SQLCOM_PREPARE: select_result *result; /* + CREATE TABLE...IGNORE/REPLACE SELECT... can be unsafe, unless + ORDER BY PRIMARY KEY clause is used in SELECT statement. We therefore + use row based logging if mixed or row based logging is available. + TODO: Check if the order of the output of the select statement is + deterministic. Waiting for BUG#42415 + */ + if(lex->ignore) + lex->set_stmt_unsafe(LEX::BINLOG_STMT_UNSAFE_CREATE_IGNORE_SELECT); + + if(lex->duplicates == DUP_REPLACE) + lex->set_stmt_unsafe(LEX::BINLOG_STMT_UNSAFE_CREATE_REPLACE_SELECT); + + /* If: a) we inside an SP and there was NAME_CONST substitution, b) binlogging is on (STMT mode), @@ -2705,6 +2733,16 @@ end_with_restore_list: DBUG_ASSERT(first_table == all_tables && first_table != 0); if (update_precheck(thd, all_tables)) break; + + /* + UPDATE IGNORE can be unsafe. We therefore use row based + logging if mixed or row based logging is available. + TODO: Check if the order of the output of the select statement is + deterministic. Waiting for BUG#42415 + */ + if (lex->ignore) + lex->set_stmt_unsafe(LEX::BINLOG_STMT_UNSAFE_UPDATE_IGNORE); + DBUG_ASSERT(select_lex->offset_limit == 0); unit->set_limit(select_lex); MYSQL_UPDATE_START(thd->query()); @@ -2876,6 +2914,23 @@ end_with_restore_list: DBUG_ASSERT(first_table == all_tables && first_table != 0); if ((res= insert_precheck(thd, all_tables))) break; + /* + INSERT...SELECT...ON DUPLICATE KEY UPDATE/REPLACE SELECT/ + INSERT...IGNORE...SELECT can be unsafe, unless ORDER BY PRIMARY KEY + clause is used in SELECT statement. We therefore use row based + logging if mixed or row based logging is available. + TODO: Check if the order of the output of the select statement is + deterministic. Waiting for BUG#42415 + */ + if (lex->sql_command == SQLCOM_INSERT_SELECT && + lex->duplicates == DUP_UPDATE) + lex->set_stmt_unsafe(LEX::BINLOG_STMT_UNSAFE_INSERT_SELECT_UPDATE); + + if (lex->sql_command == SQLCOM_INSERT_SELECT && lex->ignore) + lex->set_stmt_unsafe(LEX::BINLOG_STMT_UNSAFE_INSERT_IGNORE_SELECT); + + if (lex->sql_command == SQLCOM_REPLACE_SELECT) + lex->set_stmt_unsafe(LEX::BINLOG_STMT_UNSAFE_REPLACE_SELECT); /* Fix lock for first table */ if (first_table->lock_type == TL_WRITE_DELAYED) @@ -3602,8 +3657,6 @@ end_with_restore_list: } case SQLCOM_KILL: { - Item *it= (Item *)lex->value_list.head(); - if (lex->table_or_sp_used()) { my_error(ER_NOT_SUPPORTED_YET, MYF(0), "Usage of subqueries or stored " @@ -3611,13 +3664,20 @@ end_with_restore_list: break; } - if ((!it->fixed && it->fix_fields(lex->thd, &it)) || it->check_cols(1)) + if (lex->kill_type == KILL_TYPE_ID) { - my_message(ER_SET_CONSTANTS_ONLY, ER(ER_SET_CONSTANTS_ONLY), - MYF(0)); - goto error; + Item *it= (Item *)lex->value_list.head(); + if ((!it->fixed && it->fix_fields(lex->thd, &it)) || it->check_cols(1)) + { + my_message(ER_SET_CONSTANTS_ONLY, ER(ER_SET_CONSTANTS_ONLY), + MYF(0)); + goto error; + } + sql_kill(thd, (ulong) it->val_int(), lex->kill_signal); } - sql_kill(thd, (ulong)it->val_int(), lex->type & ONLY_KILL_QUERY); + else + sql_kill_user(thd, get_current_user(thd, lex->users_list.head()), + lex->kill_signal); break; } #ifndef NO_EMBEDDED_ACCESS_CHECKS @@ -3689,7 +3749,17 @@ end_with_restore_list: } /* Disconnect the current client connection. */ if (tx_release) - thd->killed= THD::KILL_CONNECTION; + { + thd->killed= KILL_CONNECTION; + if (global_system_variables.log_warnings > 3) + { + Security_context *sctx= &thd->main_security_ctx; + sql_print_warning(ER(ER_NEW_ABORTING_CONNECTION), + thd->thread_id,(thd->db ? thd->db : "unconnected"), + sctx->user ? sctx->user : "unauthenticated", + sctx->host_or_ip, "RELEASE"); + } + } my_ok(thd); break; } @@ -3719,7 +3789,7 @@ end_with_restore_list: } /* Disconnect the current client connection. */ if (tx_release) - thd->killed= THD::KILL_CONNECTION; + thd->killed= KILL_CONNECTION; my_ok(thd); break; } @@ -3984,7 +4054,8 @@ create_sp_error: case SQLCOM_ALTER_FUNCTION: { int sp_result; - int type= (lex->sql_command == SQLCOM_ALTER_PROCEDURE ? + enum stored_procedure_type type; + type= (lex->sql_command == SQLCOM_ALTER_PROCEDURE ? TYPE_ENUM_PROCEDURE : TYPE_ENUM_FUNCTION); if (check_routine_access(thd, ALTER_PROC_ACL, lex->spname->m_db.str, @@ -4061,7 +4132,8 @@ create_sp_error: #endif int sp_result; - int type= (lex->sql_command == SQLCOM_DROP_PROCEDURE ? + enum stored_procedure_type type; + type= (lex->sql_command == SQLCOM_DROP_PROCEDURE ? TYPE_ENUM_PROCEDURE : TYPE_ENUM_FUNCTION); char *db= lex->spname->m_db.str; char *name= lex->spname->m_name.str; @@ -4148,7 +4220,7 @@ create_sp_error: { #ifndef DBUG_OFF sp_head *sp; - int type= (lex->sql_command == SQLCOM_SHOW_PROC_CODE ? + stored_procedure_type type= (lex->sql_command == SQLCOM_SHOW_PROC_CODE ? TYPE_ENUM_PROCEDURE : TYPE_ENUM_FUNCTION); if (sp_cache_routine(thd, type, lex->spname, FALSE, &sp)) @@ -4394,9 +4466,9 @@ finish: if (! thd->stmt_da->is_set()) thd->send_kill_message(); } - if (thd->killed == THD::KILL_QUERY || thd->killed == THD::KILL_BAD_DATA) + if (thd->killed < KILL_CONNECTION) { - thd->killed= THD::NOT_KILLED; + thd->killed= NOT_KILLED; thd->mysys_var->abort= 0; } if (thd->is_error() || (thd->variables.option_bits & OPTION_MASTER_SQL_ERROR)) @@ -4467,7 +4539,6 @@ static bool execute_sqlcom_select(THD *thd, TABLE_LIST *all_tables) param->select_limit= new Item_int((ulonglong) thd->variables.select_limit); } - thd->thd_marker.emb_on_expr_nest= NULL; if (!(res= open_and_lock_tables(thd, all_tables, TRUE, 0))) { if (lex->describe) @@ -5367,7 +5438,6 @@ void THD::reset_for_next_command(bool calculate_userstat) thd->query_plan_flags= QPLAN_INIT; thd->query_plan_fsort_passes= 0; - thd->thd_marker.emb_on_expr_nest= NULL; thd->reset_current_stmt_binlog_format_row(); thd->binlog_unsafe_warning_flags= 0; @@ -5434,6 +5504,7 @@ mysql_new_select(LEX *lex, bool move_down) DBUG_RETURN(1); } select_lex->nest_level= lex->nest_level; + select_lex->nest_level_base= &thd->lex->unit; if (move_down) { SELECT_LEX_UNIT *unit; @@ -6457,12 +6528,13 @@ void add_join_natural(TABLE_LIST *a, TABLE_LIST *b, List<String> *using_fields, This is written such that we have a short lock on LOCK_thread_count */ -uint kill_one_thread(THD *thd, ulong id, bool only_kill_query) +uint kill_one_thread(THD *thd, ulong id, killed_state kill_signal) { THD *tmp; uint error=ER_NO_SUCH_THREAD; DBUG_ENTER("kill_one_thread"); - DBUG_PRINT("enter", ("id=%lu only_kill=%d", id, only_kill_query)); + DBUG_PRINT("enter", ("id: %lu signal: %u", id, (uint) kill_signal)); + mysql_mutex_lock(&LOCK_thread_count); // For unlink from list I_List_iterator<THD> it(threads); while ((tmp=it++)) @@ -6493,12 +6565,16 @@ uint kill_one_thread(THD *thd, ulong id, bool only_kill_query) If user of both killer and killee are non-NULL, proceed with slayage if both are string-equal. + + It's ok to also kill DELAYED threads with KILL_CONNECTION instead of + KILL_SYSTEM_THREAD; The difference is that KILL_CONNECTION may be + faster and do a harder kill than KILL_SYSTEM_THREAD; */ if ((thd->security_ctx->master_access & SUPER_ACL) || thd->security_ctx->user_matches(tmp->security_ctx)) { - tmp->awake(only_kill_query ? THD::KILL_QUERY : THD::KILL_CONNECTION); + tmp->awake(kill_signal); error=0; } else @@ -6510,6 +6586,76 @@ uint kill_one_thread(THD *thd, ulong id, bool only_kill_query) } +/** + kill all threads from one user + + @param thd Thread class + @param user_name User name for threads we should kill + @param only_kill_query Should it kill the query or the connection + + @note + This is written such that we have a short lock on LOCK_thread_count + + If we can't kill all threads because of security issues, no threads + are killed. +*/ + +static uint kill_threads_for_user(THD *thd, LEX_USER *user, + killed_state kill_signal, ha_rows *rows) +{ + THD *tmp; + List<THD> threads_to_kill; + DBUG_ENTER("kill_threads_for_user"); + + *rows= 0; + + if (thd->is_fatal_error) // If we run out of memory + DBUG_RETURN(ER_OUT_OF_RESOURCES); + + DBUG_PRINT("enter", ("user: %s signal: %u", user->user.str, + (uint) kill_signal)); + + mysql_mutex_lock(&LOCK_thread_count); // For unlink from list + I_List_iterator<THD> it(threads); + while ((tmp=it++)) + { + if (tmp->command == COM_DAEMON) + continue; + /* + Check that hostname (if given) and user name matches. + + host.str[0] == '%' means that host name was not given. See sql_yacc.yy + */ + if (((user->host.str[0] == '%' && !user->host.str[1]) || + !strcmp(tmp->security_ctx->host, user->host.str)) && + !strcmp(tmp->security_ctx->user, user->user.str)) + { + if (!(thd->security_ctx->master_access & SUPER_ACL) && + !thd->security_ctx->user_matches(tmp->security_ctx)) + { + mysql_mutex_unlock(&LOCK_thread_count); + DBUG_RETURN(ER_KILL_DENIED_ERROR); + } + if (!threads_to_kill.push_back(tmp, tmp->mem_root)) + mysql_mutex_lock(&tmp->LOCK_thd_data); // Lock from delete + } + } + mysql_mutex_unlock(&LOCK_thread_count); + if (!threads_to_kill.is_empty()) + { + List_iterator_fast<THD> it(threads_to_kill); + THD *ptr; + while ((ptr= it++)) + { + ptr->awake(kill_signal); + mysql_mutex_unlock(&ptr->LOCK_thd_data); + (*rows)++; + } + } + DBUG_RETURN(0); +} + + /* kills a thread and sends response @@ -6521,10 +6667,10 @@ uint kill_one_thread(THD *thd, ulong id, bool only_kill_query) */ static -void sql_kill(THD *thd, ulong id, bool only_kill_query) +void sql_kill(THD *thd, ulong id, killed_state state) { uint error; - if (!(error= kill_one_thread(thd, id, only_kill_query))) + if (!(error= kill_one_thread(thd, id, state))) { if (! thd->killed) my_ok(thd); @@ -6534,6 +6680,24 @@ void sql_kill(THD *thd, ulong id, bool only_kill_query) } +static +void sql_kill_user(THD *thd, LEX_USER *user, killed_state state) +{ + uint error; + ha_rows rows; + if (!(error= kill_threads_for_user(thd, user, state, &rows))) + my_ok(thd, rows); + else + { + /* + This is probably ER_OUT_OF_RESOURCES, but in the future we may + want to write the name of the user we tried to kill + */ + my_error(error, MYF(0), user->host.str, user->user.str); + } +} + + /** If pointer is not a null pointer, append filename to it. */ bool append_file_to_dir(THD *thd, const char **filename_ptr, diff --git a/sql/sql_parse.h b/sql/sql_parse.h index d5f90b03ebf..4510ebe94e2 100644 --- a/sql/sql_parse.h +++ b/sql/sql_parse.h @@ -1,4 +1,4 @@ -/* Copyright 2006-2008 MySQL AB, 2008-2009 Sun Microsystems, Inc. +/* Copyright (c) 2006, 2011, Oracle and/or its affiliates. All rights reserved. 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 @@ -50,8 +50,6 @@ bool parse_sql(THD *thd, Parser_state *parser_state, Object_creation_ctx *creation_ctx); -uint kill_one_thread(THD *thd, ulong id, bool only_kill_query); - void free_items(Item *item); void cleanup_items(Item *item); diff --git a/sql/sql_partition.cc b/sql/sql_partition.cc index c75b20e577e..646d829a51e 100644 --- a/sql/sql_partition.cc +++ b/sql/sql_partition.cc @@ -1003,8 +1003,6 @@ static bool fix_fields_part_func(THD *thd, Item* func_expr, TABLE *table, int error; LEX *old_lex= thd->lex; LEX lex; - uint8 saved_full_group_by_flag; - nesting_map saved_allow_sum_func; DBUG_ENTER("fix_fields_part_func"); if (init_lex_with_single_table(thd, table, &lex)) @@ -1029,20 +1027,23 @@ static bool fix_fields_part_func(THD *thd, Item* func_expr, TABLE *table, This is a tricky call to prepare for since it can have a large number of interesting side effects, both desirable and undesirable. */ - saved_full_group_by_flag= thd->lex->current_select->full_group_by_flag; - saved_allow_sum_func= thd->lex->allow_sum_func; - thd->lex->allow_sum_func= 0; - - if (!(error= func_expr->fix_fields(thd, (Item**)&func_expr))) - func_expr->walk(&Item::vcol_in_partition_func_processor, 0, NULL); + { + const bool save_agg_field= thd->lex->current_select->non_agg_field_used(); + const bool save_agg_func= thd->lex->current_select->agg_func_used(); + const nesting_map saved_allow_sum_func= thd->lex->allow_sum_func; + thd->lex->allow_sum_func= 0; - /* - Restore full_group_by_flag and allow_sum_func, - fix_fields should not affect mysql_select later, see Bug#46923. - */ - thd->lex->current_select->full_group_by_flag= saved_full_group_by_flag; - thd->lex->allow_sum_func= saved_allow_sum_func; + if (!(error= func_expr->fix_fields(thd, (Item**)&func_expr))) + func_expr->walk(&Item::vcol_in_partition_func_processor, 0, NULL); + /* + Restore agg_field/agg_func and allow_sum_func, + fix_fields should not affect mysql_select later, see Bug#46923. + */ + thd->lex->current_select->set_non_agg_field_used(save_agg_field); + thd->lex->current_select->set_agg_func_used(save_agg_func); + thd->lex->allow_sum_func= saved_allow_sum_func; + } if (unlikely(error)) { DBUG_PRINT("info", ("Field in partition function not part of table")); diff --git a/sql/sql_partition.h b/sql/sql_partition.h index c19eb5802b3..d2c15ae46d8 100644 --- a/sql/sql_partition.h +++ b/sql/sql_partition.h @@ -1,7 +1,7 @@ #ifndef SQL_PARTITION_INCLUDED #define SQL_PARTITION_INCLUDED -/* Copyright 2005-2008 MySQL AB, 2008-2009 Sun Microsystems, Inc. +/* Copyright (c) 2006, 2010, Oracle and/or its affiliates. All rights reserved. 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 @@ -14,7 +14,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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ #ifdef __GNUC__ #pragma interface /* gcc class implementation */ diff --git a/sql/sql_partition_admin.cc b/sql/sql_partition_admin.cc index cadfc587c1c..4edd47de855 100644 --- a/sql/sql_partition_admin.cc +++ b/sql/sql_partition_admin.cc @@ -1,4 +1,4 @@ -/* Copyright (c) 2010 Oracle and/or its affiliates. All rights reserved. +/* Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved. 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/sql_partition_admin.h b/sql/sql_partition_admin.h index 564b8676be8..479371c3b4d 100644 --- a/sql/sql_partition_admin.h +++ b/sql/sql_partition_admin.h @@ -1,4 +1,4 @@ -/* Copyright (c) 2010 Oracle and/or its affiliates. All rights reserved. +/* Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved. 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/sql_plist.h b/sql/sql_plist.h index b71136cd9ab..ca1d15f3015 100644 --- a/sql/sql_plist.h +++ b/sql/sql_plist.h @@ -1,6 +1,6 @@ #ifndef SQL_PLIST_H #define SQL_PLIST_H -/* Copyright (C) 2008 MySQL AB +/* Copyright (c) 2008, 2011, Oracle and/or its affiliates. All rights reserved. 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 @@ -13,7 +13,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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ #include <my_global.h> diff --git a/sql/sql_plugin.cc b/sql/sql_plugin.cc index b725f1c35fc..3024d9d2e46 100644 --- a/sql/sql_plugin.cc +++ b/sql/sql_plugin.cc @@ -1,4 +1,6 @@ -/* Copyright (c) 2005, 2011, Oracle and/or its affiliates. All rights reserved. +/* + Copyright (c) 2005, 2011, Oracle and/or its affiliates. + Copyright (c) 2010, 2011, Monty Program Ab 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 @@ -3447,6 +3449,19 @@ static int construct_options(MEM_ROOT *mem_root, struct st_plugin_int *tmp, opt->name, plugin_name); } } + /* + PLUGIN_VAR_STR command-line options without PLUGIN_VAR_MEMALLOC, point + directly to values in the argv[] array. For plugins started at the + server startup, argv[] array is allocated with load_defaults(), and + freed when the server is shut down. But for plugins loaded with + INSTALL PLUGIN, the memory allocated with load_defaults() is freed with + freed() at the end of mysql_install_plugin(). Which means we cannot + allow any pointers into that area. + Thus, for all plugins loaded after the server was started, + we force all command-line options to be PLUGIN_VAR_MEMALLOC + */ + if (mysqld_server_started && !(opt->flags & PLUGIN_VAR_NOCMDOPT)) + opt->flags|= PLUGIN_VAR_MEMALLOC; break; case PLUGIN_VAR_ENUM: if (!opt->check) @@ -3608,6 +3623,8 @@ static int test_plugin_options(MEM_ROOT *tmp_root, struct st_plugin_int *tmp, */ if (!my_strcasecmp(&my_charset_latin1, tmp->name.str, "ndbcluster")) plugin_load_option= PLUGIN_OFF; + if (!my_strcasecmp(&my_charset_latin1, tmp->name.str, "feedback")) + plugin_load_option= PLUGIN_OFF; for (opt= tmp->plugin->system_vars; opt && *opt; opt++) count+= 2; /* --{plugin}-{optname} and --plugin-{plugin}-{optname} */ diff --git a/sql/sql_plugin.h b/sql/sql_plugin.h index ee1d43e8a2f..f0b706bc322 100644 --- a/sql/sql_plugin.h +++ b/sql/sql_plugin.h @@ -1,4 +1,4 @@ -/* Copyright (C) 2005 MySQL AB, 2008-2009 Sun Microsystems, Inc +/* Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved. 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 @@ -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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ #ifndef _sql_plugin_h #define _sql_plugin_h diff --git a/sql/sql_plugin_services.h b/sql/sql_plugin_services.h index 50c579b6c4c..7f2a4e5f955 100644 --- a/sql/sql_plugin_services.h +++ b/sql/sql_plugin_services.h @@ -1,4 +1,4 @@ -/* Copyright (C) 2009 Sun Microsystems, Inc. +/* Copyright (c) 2009, 2010, Oracle and/or its affiliates. All rights reserved. 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 @@ -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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ /* support for Services */ #include <service_versions.h> diff --git a/sql/sql_prepare.cc b/sql/sql_prepare.cc index 7973713cb32..f35d336fd65 100644 --- a/sql/sql_prepare.cc +++ b/sql/sql_prepare.cc @@ -1503,8 +1503,7 @@ static int mysql_test_select(Prepared_statement *stmt, DT_PREPARE | DT_CREATE)) goto error; - thd->used_tables= 0; // Updated by setup_fields - thd->thd_marker.emb_on_expr_nest= 0; + thd->lex->used_tables= 0; // Updated by setup_fields /* JOIN::prepare calls @@ -1678,7 +1677,7 @@ static bool select_like_stmt_test(Prepared_statement *stmt, if (specific_prepare && (*specific_prepare)(thd)) DBUG_RETURN(TRUE); - thd->used_tables= 0; // Updated by setup_fields + thd->lex->used_tables= 0; // Updated by setup_fields /* Calls JOIN::prepare */ DBUG_RETURN(lex->unit.prepare(thd, 0, setup_tables_done_option)); diff --git a/sql/sql_prepare.h b/sql/sql_prepare.h index 11017b127b1..e0891bbd188 100644 --- a/sql/sql_prepare.h +++ b/sql/sql_prepare.h @@ -1,6 +1,7 @@ #ifndef SQL_PREPARE_H #define SQL_PREPARE_H -/* Copyright (C) 1995-2008 MySQL AB +/* Copyright (c) 1995-2008 MySQL AB, 2009 Sun Microsystems, Inc. + Use is subject to license terms. 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 @@ -13,7 +14,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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ #include "sql_error.h" diff --git a/sql/sql_priv.h b/sql/sql_priv.h index 674366be1b7..30c72d603f4 100644 --- a/sql/sql_priv.h +++ b/sql/sql_priv.h @@ -1,4 +1,4 @@ -/* Copyright 2000-2008 MySQL AB, 2008-2009 Sun Microsystems, Inc. +/* Copyright (c) 2000, 2011, Oracle and/or its affiliates. Copyright (c) 2010-2011 Monty Program Ab This program is free software; you can redistribute it and/or modify @@ -12,7 +12,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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ /** @file @@ -207,7 +207,11 @@ enabled by default, add OPTIMIZER_SWITCH_MATERIALIZATION OPTIMIZER_SWITCH_PARTIAL_MATCH_TABLE_SCAN|\ OPTIMIZER_SWITCH_JOIN_CACHE_INCREMENTAL | \ OPTIMIZER_SWITCH_JOIN_CACHE_HASHED | \ - OPTIMIZER_SWITCH_JOIN_CACHE_BKA) + OPTIMIZER_SWITCH_JOIN_CACHE_BKA | \ + OPTIMIZER_SWITCH_SUBQUERY_CACHE |\ + OPTIMIZER_SWITCH_SEMIJOIN | \ + OPTIMIZER_SWITCH_FIRSTMATCH | \ + OPTIMIZER_SWITCH_LOOSE_SCAN ) /* Replication uses 8 bytes to store SQL_MODE in the binary log. The day you use strictly more than 64 bits by adding one more define above, you should @@ -321,13 +325,6 @@ enum enum_yes_no_unknown #ifdef MYSQL_SERVER /* - A set of constants used for checking non aggregated fields and sum - functions mixture in the ONLY_FULL_GROUP_BY_MODE. -*/ -#define NON_AGG_FIELD_USED 1 -#define SUM_FUNC_USED 2 - -/* External variables */ diff --git a/sql/sql_profile.cc b/sql/sql_profile.cc index dffc03fbc55..aee42af8b71 100644 --- a/sql/sql_profile.cc +++ b/sql/sql_profile.cc @@ -1,4 +1,4 @@ -/* Copyright (c) 2007, 2010 Oracle and/or its affiliates. +/* Copyright (c) 2007, 2010, Oracle and/or its affiliates. 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 @@ -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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ /** @@ -296,7 +296,7 @@ void QUERY_PROFILE::new_status(const char *status_arg, DBUG_ASSERT(status_arg != NULL); if ((function_arg != NULL) && (file_arg != NULL)) - prof= new PROF_MEASUREMENT(this, status_arg, function_arg, file_arg, line_arg); + prof= new PROF_MEASUREMENT(this, status_arg, function_arg, base_name(file_arg), line_arg); else prof= new PROF_MEASUREMENT(this, status_arg); diff --git a/sql/sql_profile.h b/sql/sql_profile.h index 0931fb0df0c..2e93912fb25 100644 --- a/sql/sql_profile.h +++ b/sql/sql_profile.h @@ -1,4 +1,4 @@ -/* Copyright (C) 2007 MySQL AB +/* Copyright (c) 2007, 2010, Oracle and/or its affiliates. All rights reserved. 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 @@ -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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ #ifndef _SQL_PROFILE_H #define _SQL_PROFILE_H diff --git a/sql/sql_rename.cc b/sql/sql_rename.cc index 787912cdc4a..6cc08e64d86 100644 --- a/sql/sql_rename.cc +++ b/sql/sql_rename.cc @@ -1,4 +1,4 @@ -/* Copyright (C) 2000-2006 MySQL AB, 2008-2009 Sun Microsystems, Inc +/* Copyright (c) 2000, 2010, Oracle and/or its affiliates. All rights reserved. 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 @@ -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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ /* Atomic rename of table; RENAME TABLE t1 to t2, tmp to t1 [,...] diff --git a/sql/sql_rename.h b/sql/sql_rename.h index 7fbf9f1e5cd..039a3b8b4a1 100644 --- a/sql/sql_rename.h +++ b/sql/sql_rename.h @@ -1,4 +1,4 @@ -/* Copyright 2006-2008 MySQL AB, 2008-2009 Sun Microsystems, Inc. +/* Copyright (c) 2006, 2010, Oracle and/or its affiliates. All rights reserved. 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/sql_repl.cc b/sql/sql_repl.cc index 400ca28a277..16977d89cd6 100644 --- a/sql/sql_repl.cc +++ b/sql/sql_repl.cc @@ -1,4 +1,4 @@ -/* Copyright (C) 2000, 2011, Oracle and/or its affiliates. +/* Copyright (c) 2000, 2011, Oracle and/or its affiliates. Copyright (c) 2009-2011, Monty Program Ab This program is free software; you can redistribute it and/or modify @@ -12,7 +12,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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ #include "sql_priv.h" #include "unireg.h" @@ -459,7 +459,7 @@ Increase max_allowed_packet on master"; *errmsg = "memory allocation failed reading log event"; break; case LOG_READ_TRUNC: - *errmsg = "binlog truncated in the middle of event"; + *errmsg = "binlog truncated in the middle of event; consider out of disk space on master"; break; case LOG_READ_CHECKSUM_FAILURE: *errmsg = "event read from binlog did not pass crc check"; @@ -557,6 +557,9 @@ void mysql_binlog_send(THD* thd, char* log_ident, my_off_t pos, String* packet = &thd->packet; int error; const char *errmsg = "Unknown error"; + const char *fmt= "%s; the last event was read from '%s' at %s, the last byte read was read from '%s' at %s."; + char llbuff1[22], llbuff2[22]; + char error_text[MAX_SLAVE_ERRMSG]; // to be send to slave via my_message() NET* net = &thd->net; mysql_mutex_t *log_lock; mysql_cond_t *log_cond; @@ -812,11 +815,9 @@ impossible position"; if (reset_transmit_packet(thd, flags, &ev_offset, &errmsg)) goto err; - my_off_t prev_pos= pos; while (!(error = Log_event::read_log_event(&log, packet, log_lock, current_checksum_alg))) { - prev_pos= my_b_tell(&log); #ifndef DBUG_OFF if (max_binlog_dump_events && !left_events--) { @@ -931,18 +932,6 @@ impossible position"; } /* - here we were reading binlog that was not closed properly (as a result - of a crash ?). treat any corruption as EOF - */ - if (binlog_can_be_corrupted && - (error != LOG_READ_MEM && error != LOG_READ_CHECKSUM_FAILURE && - error != LOG_READ_EOF)) - { - my_b_seek(&log, prev_pos); - error=LOG_READ_EOF; - } - - /* TODO: now that we are logging the offset, check to make sure the recorded offset and the actual match. Guilhem 2003-06: this is not true if this master is a slave @@ -1190,6 +1179,21 @@ end: err: thd_proc_info(thd, "Waiting to finalize termination"); + if (my_errno == ER_MASTER_FATAL_ERROR_READING_BINLOG && my_b_inited(&log)) + { + /* + detailing the fatal error message with coordinates + of the last position read. + */ + char b_start[FN_REFLEN], b_end[FN_REFLEN]; + fn_format(b_start, coord->file_name, "", "", MY_REPLACE_DIR); + fn_format(b_end, log_file_name, "", "", MY_REPLACE_DIR); + my_snprintf(error_text, sizeof(error_text), fmt, errmsg, + b_start, (llstr(coord->pos, llbuff1), llbuff1), + b_end, (llstr(my_b_tell(&log), llbuff2), llbuff2)); + } + else + strcpy(error_text, errmsg); end_io_cache(&log); RUN_HOOK(binlog_transmit, transmit_stop, (thd, flags)); /* @@ -1206,7 +1210,7 @@ err: mysql_file_close(file, MYF(MY_WME)); thd->variables.max_allowed_packet= old_max_allowed_packet; - my_message(my_errno, errmsg, MYF(0)); + my_message(my_errno, error_text, MYF(0)); DBUG_VOID_RETURN; } @@ -1454,8 +1458,9 @@ int reset_slave(THD *thd, Master_info* mi) goto err; } - /* Clear master's log coordinates */ - init_master_log_pos(mi); + /* Clear master's log coordinates and associated information */ + mi->clear_in_memory_info(thd->lex->reset_slave_info.all); + /* Reset errors (the idea is that we forget about the old master). @@ -1500,9 +1505,9 @@ err: idle, then this could last long, and if the slave reconnects, we could have 2 Binlog_dump threads in SHOW PROCESSLIST, until a query is written to the binlog. To avoid this, when the slave reconnects and sends COM_BINLOG_DUMP, - the master kills any existing thread with the slave's server id (if this id is - not zero; it will be true for real slaves, but false for mysqlbinlog when it - sends COM_BINLOG_DUMP to get a remote binlog dump). + the master kills any existing thread with the slave's server id (if this id + is not zero; it will be true for real slaves, but false for mysqlbinlog when + it sends COM_BINLOG_DUMP to get a remote binlog dump). SYNOPSIS kill_zombie_dump_threads() @@ -1534,7 +1539,7 @@ void kill_zombie_dump_threads(uint32 slave_server_id) it will be slow because it will iterate through the list again. We just to do kill the thread ourselves. */ - tmp->awake(THD::KILL_QUERY); + tmp->awake(KILL_QUERY); mysql_mutex_unlock(&tmp->LOCK_thd_data); } } diff --git a/sql/sql_repl.h b/sql/sql_repl.h index dfe41d8e688..7dc58c47d52 100644 --- a/sql/sql_repl.h +++ b/sql/sql_repl.h @@ -1,4 +1,4 @@ -/* Copyright (C) 2000-2006 MySQL AB & Sasha +/* Copyright (c) 2000, 2011, Oracle and/or its affiliates. All rights reserved. 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 @@ -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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ #ifndef SQL_REPL_INCLUDED #define SQL_REPL_INCLUDED diff --git a/sql/sql_select.cc b/sql/sql_select.cc index b514d95fca5..4ce278c98ef 100644 --- a/sql/sql_select.cc +++ b/sql/sql_select.cc @@ -190,14 +190,14 @@ int join_read_always_key_or_null(JOIN_TAB *tab); int join_read_next_same_or_null(READ_RECORD *info); static COND *make_cond_for_table(THD *thd, Item *cond,table_map table, table_map used_table, - uint join_tab_idx_arg, + int join_tab_idx_arg, bool exclude_expensive_cond, bool retain_ref_cond); static COND *make_cond_for_table_from_pred(THD *thd, Item *root_cond, Item *cond, table_map tables, table_map used_table, - uint join_tab_idx_arg, + int join_tab_idx_arg, bool exclude_expensive_cond, bool retain_ref_cond); @@ -445,7 +445,7 @@ fix_inner_refs(THD *thd, List<Item> &all_fields, SELECT_LEX *select, if (!ref->fixed && ref->fix_fields(thd, 0)) return TRUE; - thd->used_tables|= item->used_tables(); + thd->lex->used_tables|= item->used_tables(); } return false; } @@ -465,19 +465,18 @@ inline int setup_without_group(THD *thd, Item **ref_pointer_array, int res; nesting_map save_allow_sum_func=thd->lex->allow_sum_func ; /* - Need to save the value, so we can turn off only the new NON_AGG_FIELD + Need to save the value, so we can turn off only any new non_agg_field_used additions coming from the WHERE */ - uint8 saved_flag= thd->lex->current_select->full_group_by_flag; + const bool saved_non_agg_field_used= + thd->lex->current_select->non_agg_field_used(); DBUG_ENTER("setup_without_group"); thd->lex->allow_sum_func&= ~(1 << thd->lex->current_select->nest_level); res= setup_conds(thd, tables, leaves, conds); /* it's not wrong to have non-aggregated columns in a WHERE */ - if (thd->variables.sql_mode & MODE_ONLY_FULL_GROUP_BY) - thd->lex->current_select->full_group_by_flag= saved_flag | - (thd->lex->current_select->full_group_by_flag & ~NON_AGG_FIELD_USED); + thd->lex->current_select->set_non_agg_field_used(saved_non_agg_field_used); thd->lex->allow_sum_func|= 1 << thd->lex->current_select->nest_level; res= res || setup_order(thd, ref_pointer_array, tables, fields, all_fields, @@ -715,7 +714,12 @@ JOIN::prepare(Item ***rref_pointer_array, aggregate functions with implicit grouping (there is no GROUP BY). */ if (thd->variables.sql_mode & MODE_ONLY_FULL_GROUP_BY && !group_list && - select_lex->full_group_by_flag == (NON_AGG_FIELD_USED | SUM_FUNC_USED)) + !(select_lex->master_unit()->item && + select_lex->master_unit()->item->is_in_predicate() && + ((Item_in_subselect*)select_lex->master_unit()->item)-> + test_set_strategy(SUBS_MAXMIN_INJECTED)) && + select_lex->non_agg_field_used() && + select_lex->agg_func_used()) { my_message(ER_MIX_OF_GROUP_FUNC_AND_FIELDS, ER(ER_MIX_OF_GROUP_FUNC_AND_FIELDS), MYF(0)); @@ -839,7 +843,7 @@ inject_jtbm_conds(JOIN *join, List<TABLE_LIST> *join_list, Item **join_where) double rows; double read_time; - subq_pred->in_strategy &= ~SUBS_IN_TO_EXISTS; + DBUG_ASSERT(subq_pred->test_set_strategy(SUBS_MATERIALIZATION)); subq_pred->optimize(&rows, &read_time); subq_pred->jtbm_read_time= read_time; @@ -928,9 +932,6 @@ JOIN::optimize() /* dump_TABLE_LIST_graph(select_lex, select_lex->leaf_tables); */ select_lex->update_used_tables(); - /* Save this info for the next executions */ - if (select_lex->save_leaf_tables(thd)) - DBUG_RETURN(1); } eval_select_list_used_tables(); @@ -990,6 +991,8 @@ JOIN::optimize() /* Convert all outer joins to inner joins if possible */ conds= simplify_joins(this, join_list, conds, TRUE, FALSE); + if (select_lex->save_leaf_tables(thd)) + DBUG_RETURN(1); build_bitmap_for_nested_joins(join_list, 0); sel->prep_where= conds ? conds->copy_andor_structure(thd) : 0; @@ -1118,7 +1121,7 @@ JOIN::optimize() if (conds && !(thd->lex->describe & DESCRIBE_EXTENDED)) { COND *table_independent_conds= - make_cond_for_table(thd, conds, PSEUDO_TABLE_BITS, 0, MAX_TABLES, + make_cond_for_table(thd, conds, PSEUDO_TABLE_BITS, 0, -1, FALSE, FALSE); DBUG_EXECUTE("where", print_where(table_independent_conds, @@ -2424,7 +2427,6 @@ JOIN::exec() thd_proc_info(thd, "Copying to group table"); DBUG_PRINT("info", ("%s", thd->proc_info)); - tmp_error= -1; if (curr_join != this) { if (sum_funcs2) @@ -2451,6 +2453,7 @@ JOIN::exec() JOIN_TAB *first_tab= curr_join->join_tab + curr_join->const_tables; first_tab->sorted= test(first_tab->loosescan_match_tab); } + tmp_error= -1; if (setup_sum_funcs(curr_join->thd, curr_join->sum_funcs) || (tmp_error= do_select(curr_join, (List<Item> *) 0, curr_tmp_table, 0))) @@ -2581,7 +2584,7 @@ JOIN::exec() Item* sort_table_cond= make_cond_for_table(thd, curr_join->tmp_having, used_tables, - (table_map)0, MAX_TABLES, + (table_map)0, -1, FALSE, FALSE); if (sort_table_cond) { @@ -2611,7 +2614,9 @@ JOIN::exec() if (curr_table->pre_idx_push_select_cond && !curr_table->pre_idx_push_select_cond->fixed) curr_table->pre_idx_push_select_cond->fix_fields(thd, 0); - + + curr_table->select->pre_idx_push_select_cond= + curr_table->pre_idx_push_select_cond; curr_table->set_select_cond(curr_table->select->cond, __LINE__); curr_table->select_cond->top_level_item(); DBUG_EXECUTE("where",print_where(curr_table->select->cond, @@ -2619,7 +2624,7 @@ JOIN::exec() QT_ORDINARY);); curr_join->tmp_having= make_cond_for_table(thd, curr_join->tmp_having, ~ (table_map) 0, - ~used_tables, MAX_TABLES, + ~used_tables, -1, FALSE, FALSE); DBUG_EXECUTE("where",print_where(curr_join->tmp_having, "having after sort", @@ -2898,7 +2903,7 @@ mysql_select(THD *thd, Item ***rref_pointer_array, if (!(join= new JOIN(thd, fields, select_options, result))) DBUG_RETURN(TRUE); thd_proc_info(thd, "init"); - thd->used_tables=0; // Updated by setup_fields + thd->lex->used_tables=0; // Updated by setup_fields if ((err= join->prepare(rref_pointer_array, tables, wild_num, conds, og_num, order, group, having, proc_param, select_lex, unit))) @@ -3004,6 +3009,7 @@ make_join_statistics(JOIN *join, List<TABLE_LIST> &tables_list, uint i,table_count,const_count,key; table_map found_const_table_map, all_table_map, found_ref, refs; key_map const_ref, eq_part; + bool has_expensive_keyparts; TABLE **table_vector; JOIN_TAB *stat,*stat_end,*s,**stat_ref; KEYUSE *keyuse,*start_keyuse; @@ -3041,6 +3047,7 @@ make_join_statistics(JOIN *join, List<TABLE_LIST> &tables_list, table_vector[i]=s->table=table=tables->table; table->pos_in_table_list= tables; error= tables->fetch_number_of_rows(); + if (error) { table->file->print_error(error, MYF(0)); @@ -3190,7 +3197,7 @@ make_join_statistics(JOIN *join, List<TABLE_LIST> &tables_list, */ bool skip_unprefixed_keyparts= !(join->is_in_subquery() && - ((Item_in_subselect*)join->unit->item)->in_strategy & SUBS_IN_TO_EXISTS); + ((Item_in_subselect*)join->unit->item)->test_strategy(SUBS_IN_TO_EXISTS)); if (keyuse_array->elements && sort_and_filter_keyuse(join->thd, keyuse_array, @@ -3328,12 +3335,17 @@ make_join_statistics(JOIN *join, List<TABLE_LIST> &tables_list, refs=0; const_ref.clear_all(); eq_part.clear_all(); + has_expensive_keyparts= false; do { if (keyuse->val->type() != Item::NULL_ITEM && !keyuse->optimize) { if (!((~found_const_table_map) & keyuse->used_tables)) + { const_ref.set_bit(keyuse->keypart); + if (keyuse->val->is_expensive()) + has_expensive_keyparts= true; + } else refs|=keyuse->used_tables; eq_part.set_bit(keyuse->keypart); @@ -3355,6 +3367,7 @@ make_join_statistics(JOIN *join, List<TABLE_LIST> &tables_list, if (table->key_info[key].flags & HA_NOSAME) { if (const_ref == eq_part && + !has_expensive_keyparts && !((outer_join & table->map) && (*s->on_expr_ref)->is_expensive())) { // Found everything for ref. @@ -3835,7 +3848,9 @@ add_key_field(JOIN *join, uint optimize= 0; if (eq_func && ((join->is_allowed_hash_join_access() && - field->hash_join_is_possible()) || + field->hash_join_is_possible() && + !(field->table->pos_in_table_list->is_materialized_derived() && + field->table->created)) || (field->table->pos_in_table_list->is_materialized_derived() && !field->table->created))) { @@ -5265,7 +5280,7 @@ best_access_path(JOIN *join, tmp= table->file->keyread_time(key, 1, (ha_rows) tmp); else tmp= table->file->read_time(key, 1, - (ha_rows) min(tmp,s->worst_seeks)-1); + (ha_rows) min(tmp,s->worst_seeks)); tmp*= record_count; } } @@ -5429,13 +5444,14 @@ best_access_path(JOIN *join, tmp= table->file->keyread_time(key, 1, (ha_rows) tmp); else tmp= table->file->read_time(key, 1, - (ha_rows) min(tmp,s->worst_seeks)-1); + (ha_rows) min(tmp,s->worst_seeks)); tmp*= record_count; } else tmp= best_time; // Do nothing } + DBUG_ASSERT(tmp > 0 || record_count == 0); tmp += s->startup_cost; loose_scan_opt.check_ref_access_part2(key, start_key, records, tmp); } /* not ft_key */ @@ -6135,7 +6151,7 @@ greedy_search(JOIN *join, read_time_arg and record_count_arg contain the computed cost and fanout */ -void JOIN::get_partial_cost_and_fanout(uint end_tab_idx, +void JOIN::get_partial_cost_and_fanout(int end_tab_idx, table_map filter_map, double *read_time_arg, double *record_count_arg) @@ -6145,14 +6161,14 @@ void JOIN::get_partial_cost_and_fanout(uint end_tab_idx, double sj_inner_fanout= 1.0; JOIN_TAB *end_tab= NULL; JOIN_TAB *tab; - uint i; - uint last_sj_table= MAX_TABLES; + int i; + int last_sj_table= MAX_TABLES; /* Handle a special case where the join is degenerate, and produces no records */ - if (table_count == 0) + if (table_count == const_tables) { *read_time_arg= 0.0; /* @@ -6162,6 +6178,7 @@ void JOIN::get_partial_cost_and_fanout(uint end_tab_idx, calculations. */ *record_count_arg=1.0; + return; } for (tab= first_depth_first_tab(this), i= const_tables; @@ -6174,19 +6191,17 @@ void JOIN::get_partial_cost_and_fanout(uint end_tab_idx, } for (tab= first_depth_first_tab(this), i= const_tables; - (i <= end_tab_idx && tab); + ; tab= next_depth_first_tab(this, tab), i++) { - /* - We've entered the SJM nest that contains the end_tab. The caller is - actually - - interested in fanout inside the nest (because that's how many times - we'll invoke the attached WHERE conditions) - - not interested in cost - */ if (end_tab->bush_root_tab && end_tab->bush_root_tab == tab) { - /* Ok, end_tab is inside SJM nest and we're entering that nest now */ + /* + We've entered the SJM nest that contains the end_tab. The caller is + - interested in fanout inside the nest (because that's how many times + we'll invoke the attached WHERE conditions) + - not interested in cost + */ record_count= 1.0; read_time= 0.0; } @@ -6200,8 +6215,18 @@ void JOIN::get_partial_cost_and_fanout(uint end_tab_idx, sj_inner_fanout= 1.0; last_sj_table= i + tab->n_sj_tables; } - - if (tab->records_read && (tab->table->map & filter_map)) + + table_map cur_table_map; + if (tab->table) + cur_table_map= tab->table->map; + else + { + /* This is a SJ-Materialization nest. Check all of its tables */ + TABLE *first_child= tab->bush_children->start->table; + TABLE_LIST *sjm_nest= first_child->pos_in_table_list->embedding; + cur_table_map= sjm_nest->nested_join->used_tables; + } + if (tab->records_read && (cur_table_map & filter_map)) { record_count *= tab->records_read; read_time += tab->read_time; @@ -6215,6 +6240,9 @@ void JOIN::get_partial_cost_and_fanout(uint end_tab_idx, sj_inner_fanout= 1.0; last_sj_table= MAX_TABLES; } + + if (tab == end_tab) + break; } *read_time_arg= read_time;// + record_count / TIME_FOR_COMPARE; *record_count_arg= record_count; @@ -6647,6 +6675,16 @@ void JOIN_TAB::calc_used_field_length(bool max_fl) rec_length+=(table->s->null_fields+7)/8; if (table->maybe_null) rec_length+=sizeof(my_bool); + + /* Take into account that DuplicateElimination may need to store rowid */ + uint rowid_add_size= 0; + if (keep_current_rowid) + { + rowid_add_size= table->file->ref_length; + rec_length += rowid_add_size; + fields++; + } + if (max_fl) { // TODO: to improve this estimate for max expected length @@ -6660,13 +6698,9 @@ void JOIN_TAB::calc_used_field_length(bool max_fl) } max_used_fieldlength= rec_length; } - else if (table->file->stats.mean_rec_length) - set_if_smaller(rec_length, table->file->stats.mean_rec_length); + else if (table->file->stats.mean_rec_length) + set_if_smaller(rec_length, table->file->stats.mean_rec_length + rowid_add_size); - /* - TODO: why we don't count here rowid that we might need to store when - using DuplicateElimination? - */ used_fields=fields; used_fieldlength=rec_length; used_blobs=blobs; @@ -6703,7 +6737,7 @@ int JOIN_TAB::make_scan_filter() if (cond && (tmp= make_cond_for_table(join->thd, cond, join->const_table_map | table->map, - table->map, MAX_TABLES, FALSE, TRUE))) + table->map, -1, FALSE, TRUE))) { DBUG_EXECUTE("where",print_where(tmp,"cache", QT_ORDINARY);); if (!(cache_select= @@ -7175,6 +7209,7 @@ get_best_combination(JOIN *join) goto loop_end; // Handled in make_join_stat.. j->loosescan_match_tab= NULL; //non-nulls will be set later + j->inside_loosescan_range= FALSE; j->ref.key = -1; j->ref.key_parts=0; @@ -7308,7 +7343,8 @@ static bool are_tables_local(JOIN_TAB *jtab, table_map used_tables) except the const tables. */ table_map local_tables= jtab->emb_sj_nest->nested_join->used_tables | - jtab->join->const_table_map; + jtab->join->const_table_map | + OUTER_REF_TABLE_BIT; return !test(used_tables & ~local_tables); } @@ -7425,7 +7461,8 @@ static bool create_ref_for_key(JOIN *join, JOIN_TAB *j, while (((~used_tables) & keyuse->used_tables) || (keyuse->keypart != (is_hash_join_key_no(key) ? - keyinfo->key_part[i].field->field_index : i))) + keyinfo->key_part[i].field->field_index : i)) || + !are_tables_local(j, keyuse->val->used_tables())) keyuse++; /* Skip other parts */ uint maybe_null= test(keyinfo->key_part[i].null_bit); @@ -7989,7 +8026,7 @@ make_join_select(JOIN *join,SQL_SELECT *select,COND *cond) join->exec_const_cond= make_cond_for_table(thd, cond, join->const_table_map, - (table_map) 0, MAX_TABLES, FALSE, FALSE); + (table_map) 0, -1, FALSE, FALSE); /* Add conditions added by add_not_null_conds(). */ for (uint i= 0 ; i < join->const_tables ; i++) add_cond_and_fix(thd, &join->exec_const_cond, @@ -8008,7 +8045,7 @@ make_join_select(JOIN *join,SQL_SELECT *select,COND *cond) COND *outer_ref_cond= make_cond_for_table(thd, cond, OUTER_REF_TABLE_BIT, OUTER_REF_TABLE_BIT, - MAX_TABLES, FALSE, FALSE); + -1, FALSE, FALSE); if (outer_ref_cond) { add_cond_and_fix(thd, &outer_ref_cond, join->outer_ref_cond); @@ -8036,7 +8073,7 @@ make_join_select(JOIN *join,SQL_SELECT *select,COND *cond) */ JOIN_TAB *first_inner_tab= tab->first_inner; - if (tab->table) + if (!tab->bush_children) current_map= tab->table->map; else current_map= tab->bush_children->start->emb_sj_nest->sj_inner_tables; @@ -8180,7 +8217,7 @@ make_join_select(JOIN *join,SQL_SELECT *select,COND *cond) { COND *push_cond= make_cond_for_table(thd, tmp, current_map, current_map, - MAX_TABLES, FALSE, FALSE); + -1, FALSE, FALSE); if (push_cond) { /* Push condition to handler */ @@ -8353,7 +8390,7 @@ make_join_select(JOIN *join,SQL_SELECT *select,COND *cond) JOIN_TAB *cond_tab= join_tab->first_inner; COND *tmp= make_cond_for_table(thd, *join_tab->on_expr_ref, join->const_table_map, - (table_map) 0, MAX_TABLES, FALSE, FALSE); + (table_map) 0, -1, FALSE, FALSE); if (!tmp) continue; tmp= new Item_func_trig_cond(tmp, &cond_tab->not_null_compl); @@ -8399,10 +8436,10 @@ make_join_select(JOIN *join,SQL_SELECT *select,COND *cond) current_map= tab->table->map; used_tables2|= current_map; /* - psergey: have put the MAX_TABLES below. It's bad, will need to fix it. + psergey: have put the -1 below. It's bad, will need to fix it. */ COND *tmp_cond= make_cond_for_table(thd, on_expr, used_tables2, - current_map, /*(tab - first_tab)*/ MAX_TABLES, + current_map, /*(tab - first_tab)*/ -1, FALSE, FALSE); if (tab == first_inner_tab && tab->on_precond) add_cond_and_fix(thd, &tmp_cond, tab->on_precond); @@ -8483,17 +8520,17 @@ bool generate_derived_keys_for_table(KEYUSE *keyuse, uint count, uint keys) TABLE *table= keyuse->table; if (table->alloc_keys(keys)) return TRUE; - uint keyno= 0; + uint key_count= 0; KEYUSE *first_keyuse= keyuse; uint prev_part= keyuse->keypart; uint parts= 0; uint i= 0; - for ( ; i < count && keyno < keys; ) + for ( ; i < count && key_count < keys; ) { do { - keyuse->key= keyno; + keyuse->key= table->s->keys; keyuse->keypart_map= (key_part_map) (1 << parts); keyuse++; i++; @@ -8507,14 +8544,14 @@ bool generate_derived_keys_for_table(KEYUSE *keyuse, uint count, uint keys) } else { - if (table->add_tmp_key(keyno, parts, + if (table->add_tmp_key(table->s->keys, parts, get_next_field_for_derived_key, (uchar *) &first_keyuse, FALSE)) return TRUE; - table->reginfo.join_tab->keys.set_bit(keyno); + table->reginfo.join_tab->keys.set_bit(table->s->keys); first_keyuse= keyuse; - keyno++; + key_count++; parts= 0; prev_part= keyuse->keypart; } @@ -8541,12 +8578,23 @@ bool generate_derived_keys(DYNAMIC_ARRAY *keyuse_array) TABLE_LIST *derived= NULL; if (keyuse->table != prev_table) derived= keyuse->table->pos_in_table_list; - while (derived && derived->is_materialized_derived() && - keyuse->key == MAX_KEY) + while (derived && derived->is_materialized_derived()) { if (keyuse->table != prev_table) { prev_table= keyuse->table; + while (keyuse->table == prev_table && keyuse->key != MAX_KEY) + { + keyuse++; + i++; + } + if (keyuse->table != prev_table) + { + keyuse--; + i--; + derived= NULL; + continue; + } first_table_keyuse= keyuse; last_used_tables= keyuse->used_tables; count= 0; @@ -8559,11 +8607,13 @@ bool generate_derived_keys(DYNAMIC_ARRAY *keyuse_array) } count++; keyuse++; + i++; if (keyuse->table != prev_table) { if (generate_derived_keys_for_table(first_table_keyuse, count, ++keys)) return TRUE; keyuse--; + i--; derived= NULL; } } @@ -8594,12 +8644,13 @@ void JOIN::drop_unused_derived_keys() TABLE *table=tab->table; if (!table) continue; - if (!table->pos_in_table_list->is_materialized_derived() || - table->max_keys <= 1) + if (!table->pos_in_table_list->is_materialized_derived()) continue; - table->use_index(tab->ref.key); - if (table->s->keys) + if (table->max_keys > 1) + table->use_index(tab->ref.key); + if (table->s->keys && tab->ref.key >= 0) tab->ref.key= 0; + tab->keys= (key_map) (table->s->keys ? 1 : 0); } } @@ -8728,7 +8779,7 @@ void set_join_cache_denial(JOIN_TAB *join_tab) void rr_unlock_row(st_join_table *tab) { READ_RECORD *info= &tab->read_record; - info->file->unlock_row(); + info->table->file->unlock_row(); } @@ -9062,8 +9113,17 @@ uint check_join_cache_usage(JOIN_TAB *tab, if (tab->use_quick == 2) goto no_join_cache; + + /* + Don't use join cache if we're inside a join tab range covered by LooseScan + strategy (TODO: LooseScan is very similar to FirstMatch so theoretically it + should be possible to use join buffering in the same way we're using it for + multi-table firstmatch ranges). + */ + if (tab->inside_loosescan_range) + goto no_join_cache; - if (tab->is_inner_table_of_semi_join_with_first_match() && + if (tab->is_inner_table_of_semijoin() && !join->allowed_semijoin_with_cache) goto no_join_cache; if (tab->is_inner_table_of_outer_join() && @@ -9143,6 +9203,9 @@ uint check_join_cache_usage(JOIN_TAB *tab, case JT_EQ_REF: if (cache_level <=2 || (no_hashed_cache && no_bka_cache)) goto no_join_cache; + if (tab->ref.is_access_triggered()) + goto no_join_cache; + if (!tab->is_ref_for_hash_join()) { flags= HA_MRR_NO_NULL_ENDPOINTS | HA_MRR_SINGLE_POINT; @@ -9207,7 +9270,10 @@ uint check_join_cache_usage(JOIN_TAB *tab, no_join_cache: if (tab->type != JT_ALL && tab->is_ref_for_hash_join()) + { tab->type= JT_ALL; + tab->ref.key_parts= 0; + } revise_cache_usage(tab); return 0; } @@ -9388,7 +9454,6 @@ make_join_readinfo(JOIN *join, ulonglong options, uint no_jbuf_after) TABLE *table=tab->table; uint jcl= tab->used_join_cache_level; tab->read_record.table= table; - tab->read_record.file=table->file; tab->read_record.unlock_row= rr_unlock_row; tab->sorted= sorted; sorted= 0; // only first must be sorted @@ -9434,9 +9499,9 @@ make_join_readinfo(JOIN *join, ulonglong options, uint no_jbuf_after) table->key_read=1; table->file->extra(HA_EXTRA_KEYREAD); } - else if (!jcl || jcl > 4) + else if ((!jcl || jcl > 4) && !tab->ref.is_access_triggered()) push_index_cond(tab, tab->ref.key); - break; + break; case JT_EQ_REF: tab->read_record.unlock_row= join_read_key_unlock_row; /* fall through */ @@ -9446,7 +9511,7 @@ make_join_readinfo(JOIN *join, ulonglong options, uint no_jbuf_after) table->key_read=1; table->file->extra(HA_EXTRA_KEYREAD); } - else if (!jcl || jcl > 4) + else if ((!jcl || jcl > 4) && !tab->ref.is_access_triggered()) push_index_cond(tab, tab->ref.key); break; case JT_REF_OR_NULL: @@ -9461,7 +9526,7 @@ make_join_readinfo(JOIN *join, ulonglong options, uint no_jbuf_after) if (table->covering_keys.is_set(tab->ref.key) && !table->no_keyread) table->enable_keyread(); - else if (!jcl || jcl > 4) + else if ((!jcl || jcl > 4) && !tab->ref.is_access_triggered()) push_index_cond(tab, tab->ref.key); break; case JT_ALL: @@ -9670,7 +9735,6 @@ void JOIN_TAB::cleanup() table->pos_in_table_list->jtbm_subselect) { end_read_record(&read_record); - //psergey-merge: table->pos_in_table_list->jtbm_subselect->cleanup(); table= NULL; DBUG_VOID_RETURN; @@ -9743,6 +9807,8 @@ bool JOIN_TAB::preread_init() derived, DT_CREATE | DT_FILL)) return TRUE; preread_init_done= TRUE; + if (select && select->quick) + select->quick->replace_handler(table->file); return FALSE; } @@ -9818,6 +9884,22 @@ bool TABLE_REF::tmp_table_index_lookup_init(THD *thd, } +/* + Check if ref access uses "Full scan on NULL key" (i.e. it actually alternates + between ref access and full table scan) +*/ + +bool TABLE_REF::is_access_triggered() +{ + for (uint i = 0; i < key_parts; i++) + { + if (cond_guards[i]) + return TRUE; + } + return FALSE; +} + + /** Partially cleanup JOIN after it has executed: close index or rnd read (table cursors), free quick selects. @@ -13953,6 +14035,7 @@ create_tmp_table(THD *thd, TMP_TABLE_PARAM *param, List<Item> &fields, bool maybe_null=(*cur_group->item)->maybe_null; key_part_info->null_bit=0; key_part_info->field= field; + key_part_info->fieldnr= field->field_index + 1; if (cur_group == group) field->key_start.set_bit(0); key_part_info->offset= field->offset(table->record[0]); @@ -14076,6 +14159,7 @@ create_tmp_table(THD *thd, TMP_TABLE_PARAM *param, List<Item> &fields, key_part_info->field->init(table); key_part_info->key_type=FIELDFLAG_BINARY; key_part_info->type= HA_KEYTYPE_BINARY; + key_part_info->fieldnr= key_part_info->field->field_index + 1; key_part_info++; } /* Create a distinct key over the columns we are going to return */ @@ -14093,6 +14177,7 @@ create_tmp_table(THD *thd, TMP_TABLE_PARAM *param, List<Item> &fields, key_part_info->offset= (*reg_field)->offset(table->record[0]); key_part_info->length= (uint16) (*reg_field)->pack_length(); + key_part_info->fieldnr= (*reg_field)->field_index + 1; /* TODO: The below method of computing the key format length of the key part is a copy/paste from opt_range.cc, and table.cc. @@ -14370,6 +14455,13 @@ bool create_internal_tmp_table(TABLE *table, KEY *keyinfo, keyinfo->key_parts > table->file->max_key_parts() || share->uniques) { + if (!share->uniques && !(keyinfo->flags & HA_NOSAME)) + { + my_error(ER_INTERNAL_ERROR, MYF(0), + "Using too big key for internal temp tables"); + DBUG_RETURN(1); + } + /* Can't create a key; Make a unique constraint instead of a key */ share->keys= 0; share->uniques= 1; @@ -14388,9 +14480,9 @@ bool create_internal_tmp_table(TABLE *table, KEY *keyinfo, } else { - /* Create an unique key */ + /* Create a key */ bzero((char*) &keydef,sizeof(keydef)); - keydef.flag=HA_NOSAME; + keydef.flag= keyinfo->flags & HA_NOSAME; keydef.keysegs= keyinfo->key_parts; keydef.seg= seg; } @@ -14565,7 +14657,8 @@ bool create_internal_tmp_table(TABLE *table, KEY *keyinfo, { /* Create an unique key */ bzero((char*) &keydef,sizeof(keydef)); - keydef.flag=HA_NOSAME | HA_BINARY_PACK_KEY | HA_PACK_KEY; + keydef.flag= ((keyinfo->flags & HA_NOSAME) | HA_BINARY_PACK_KEY | + HA_PACK_KEY); keydef.keysegs= keyinfo->key_parts; keydef.seg= seg; } @@ -15096,10 +15189,12 @@ sub_select_cache(JOIN *join, JOIN_TAB *join_tab, bool end_of_records) { enum_nested_loop_state rc; JOIN_CACHE *cache= join_tab->cache; - DBUG_ENTER("sub_select_cache"); - /* This function cannot be called if join_tab has no associated join buffer */ + /* + This function cannot be called if join_tab has no associated join + buffer + */ DBUG_ASSERT(cache != NULL); join_tab->cache->reset_join(join); @@ -15928,7 +16023,7 @@ int join_read_key2(THD *thd, JOIN_TAB *tab, TABLE *table, TABLE_REF *table_ref) */ if (tab && tab->ref.has_record && tab->ref.use_count == 0) { - tab->read_record.file->unlock_row(); + tab->read_record.table->file->unlock_row(); table_ref->has_record= FALSE; } error=table->file->ha_index_read_map(table->record[0], @@ -16113,7 +16208,7 @@ join_init_quick_read_record(JOIN_TAB *tab) int read_first_record_seq(JOIN_TAB *tab) { - if (tab->read_record.file->ha_rnd_init_with_error(1)) + if (tab->read_record.table->file->ha_rnd_init_with_error(1)) return 1; return (*tab->read_record.read_record)(&tab->read_record); } @@ -16180,7 +16275,6 @@ join_read_first(JOIN_TAB *tab) tab->table->status=0; tab->read_record.read_record=join_read_next; tab->read_record.table=table; - tab->read_record.file=table->file; tab->read_record.index=tab->index; tab->read_record.record=table->record[0]; if (!table->file->inited) @@ -16201,7 +16295,7 @@ static int join_read_next(READ_RECORD *info) { int error; - if ((error= info->file->ha_index_next(info->record))) + if ((error= info->table->file->ha_index_next(info->record))) return report_error(info->table, error); return 0; @@ -16219,7 +16313,6 @@ join_read_last(JOIN_TAB *tab) tab->table->status=0; tab->read_record.read_record=join_read_prev; tab->read_record.table=table; - tab->read_record.file=table->file; tab->read_record.index=tab->index; tab->read_record.record=table->record[0]; if (!table->file->inited) @@ -16237,7 +16330,7 @@ static int join_read_prev(READ_RECORD *info) { int error; - if ((error= info->file->ha_index_prev(info->record))) + if ((error= info->table->file->ha_index_prev(info->record))) return report_error(info->table, error); return 0; } @@ -16266,7 +16359,7 @@ static int join_ft_read_next(READ_RECORD *info) { int error; - if ((error= info->file->ha_ft_read(info->table->record[0]))) + if ((error= info->table->file->ha_ft_read(info->table->record[0]))) return report_error(info->table, error); return 0; } @@ -16848,13 +16941,8 @@ bool test_if_ref(Item *root_cond, Item_field *left_item,Item *right_item) between ref access and full table scan), then no equality can be guaranteed to be true. */ - for (uint i = 0; i < join_tab->ref.key_parts; i++) - { - if (join_tab->ref.cond_guards[i]) - { - return FALSE; - } - } + if (join_tab->ref.is_access_triggered()) + return FALSE; Item *ref_item=part_of_refkey(field->table,field); if (ref_item && (ref_item->eq(right_item,1) || @@ -16936,7 +17024,7 @@ bool test_if_ref(Item *root_cond, Item_field *left_item,Item *right_item) static Item * make_cond_for_table(THD *thd, Item *cond, table_map tables, table_map used_table, - uint join_tab_idx_arg, + int join_tab_idx_arg, bool exclude_expensive_cond __attribute__((unused)), bool retain_ref_cond) { @@ -16950,7 +17038,7 @@ make_cond_for_table(THD *thd, Item *cond, table_map tables, static Item * make_cond_for_table_from_pred(THD *thd, Item *root_cond, Item *cond, table_map tables, table_map used_table, - uint join_tab_idx_arg, + int join_tab_idx_arg, bool exclude_expensive_cond __attribute__ ((unused)), bool retain_ref_cond) @@ -17916,8 +18004,10 @@ check_reverse_order: condition are not relevant anymore */ if (tab->select && tab->select->pre_idx_push_select_cond) + { tab->set_cond(tab->select->pre_idx_push_select_cond); - + tab->table->file->cancel_pushed_idx_cond(); + } /* TODO: update the number of records in join->best_positions[tablenr] */ @@ -17970,14 +18060,11 @@ skipped_filesort: delete save_quick; save_quick= NULL; } - /* - orig_cond is a part of pre_idx_push_cond, - no need to restore it. - */ - orig_cond= 0; - orig_cond_saved= false; if (orig_cond_saved && !changed_key) tab->set_cond(orig_cond); + if (!no_changes && changed_key && table->file->pushed_idx_cond) + table->file->cancel_pushed_idx_cond(); + DBUG_RETURN(1); use_filesort: @@ -17989,6 +18076,7 @@ use_filesort: } if (orig_cond_saved) tab->set_cond(orig_cond); + DBUG_RETURN(0); } @@ -19886,7 +19974,6 @@ static bool add_ref_to_table_cond(THD *thd, JOIN_TAB *join_tab) } if (thd->is_fatal_error) DBUG_RETURN(TRUE); - if (!cond->fixed) { Item *tmp_item= (Item*) cond; @@ -19895,15 +19982,20 @@ static bool add_ref_to_table_cond(THD *thd, JOIN_TAB *join_tab) } if (join_tab->select) { + Item *cond_copy; + UNINIT_VAR(cond_copy); // used when pre_idx_push_select_cond!=NULL + if (join_tab->select->pre_idx_push_select_cond) + cond_copy= cond->copy_andor_structure(thd); if (join_tab->select->cond) error=(int) cond->add(join_tab->select->cond); join_tab->select->cond= cond; if (join_tab->select->pre_idx_push_select_cond) { - Item *new_cond= and_conds(join_tab->select->pre_idx_push_select_cond, cond); + Item *new_cond= and_conds(cond_copy, join_tab->select->pre_idx_push_select_cond); if (!new_cond->fixed && new_cond->fix_fields(thd, &new_cond)) error= 1; - join_tab->select->pre_idx_push_select_cond= new_cond; + join_tab->pre_idx_push_select_cond= + join_tab->select->pre_idx_push_select_cond= new_cond; } join_tab->set_select_cond(cond, __LINE__); } @@ -20698,9 +20790,13 @@ static void select_describe(JOIN *join, bool need_tmp_table, bool need_order, length= (longlong10_to_str(key_len, keylen_str_buf, 10) - keylen_str_buf); tmp3.append(keylen_str_buf, length, cs); +/*<<<<<<< TREE } if ((is_hj || tab->type==JT_RANGE || tab->type == JT_INDEX_MERGE) && tab->select && tab->select->quick) +=======*/ + } + if (tab->type != JT_CONST && tab->select && tab->select->quick) tab->select->quick->add_keys_and_lengths(&tmp2, &tmp3); if (key_info || (tab->select && tab->select->quick)) { @@ -21576,6 +21672,28 @@ void JOIN::save_query_plan(Join_plan_state *save_to) memcpy((uchar*) save_to->best_positions, (uchar*) best_positions, sizeof(POSITION) * (table_count + 1)); memset(best_positions, 0, sizeof(POSITION) * (table_count + 1)); + + /* Save SJM nests */ + List_iterator<TABLE_LIST> it(select_lex->sj_nests); + TABLE_LIST *tlist; + SJ_MATERIALIZATION_INFO **p_info= save_to->sj_mat_info; + while ((tlist= it++)) + { + *(p_info++)= tlist->sj_mat_info; + } +} + + +/** + Reset a query execution plan so that it can be reoptimized in-place. +*/ +void JOIN::reset_query_plan() +{ + for (uint i= 0; i < table_count; i++) + { + join_tab[i].keyuse= NULL; + join_tab[i].checked_keys.clear_all(); + } } @@ -21603,6 +21721,14 @@ void JOIN::restore_query_plan(Join_plan_state *restore_from) } memcpy((uchar*) best_positions, (uchar*) restore_from->best_positions, sizeof(POSITION) * (table_count + 1)); + /* Restore SJM nests */ + List_iterator<TABLE_LIST> it(select_lex->sj_nests); + TABLE_LIST *tlist; + SJ_MATERIALIZATION_INFO **p_info= restore_from->sj_mat_info; + while ((tlist= it++)) + { + tlist->sj_mat_info= *(p_info++); + } } @@ -21612,7 +21738,8 @@ void JOIN::restore_query_plan(Join_plan_state *restore_from) @param added_where An extra conjunct to the WHERE clause to reoptimize with @param join_tables The set of tables to reoptimize - @param save_to If != NULL, save here the state of the current query plan + @param save_to If != NULL, save here the state of the current query plan, + otherwise reuse the existing query plan structures. @notes Given a query plan that was already optimized taking into account some WHERE @@ -21656,6 +21783,8 @@ JOIN::reoptimize(Item *added_where, table_map join_tables, if (save_to) save_query_plan(save_to); + else + reset_query_plan(); if (!keyuse.buffer && my_init_dynamic_array(&keyuse, sizeof(KEYUSE), 20, 64)) @@ -21689,6 +21818,9 @@ JOIN::reoptimize(Item *added_where, table_map join_tables, return REOPT_ERROR; optimize_keyuse(this, &keyuse); + if (optimize_semijoin_nests(this, join_tables)) + return REOPT_ERROR; + /* Re-run the join optimizer to compute a new query plan. */ if (choose_plan(this, join_tables)) return REOPT_ERROR; diff --git a/sql/sql_select.h b/sql/sql_select.h index d456eab5ac5..4b5e2903c1d 100644 --- a/sql/sql_select.h +++ b/sql/sql_select.h @@ -1,7 +1,7 @@ #ifndef SQL_SELECT_INCLUDED #define SQL_SELECT_INCLUDED -/* Copyright (c) 2000, 2010, Oracle and/or its affiliates. +/* Copyright (c) 2000, 2011, Oracle and/or its affiliates. Copyright (c) 2010, 2011, Monty Program Ab This program is free software; you can redistribute it and/or modify @@ -15,7 +15,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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ /** @file @@ -143,6 +143,7 @@ typedef struct st_table_ref bool tmp_table_index_lookup_init(THD *thd, KEY *tmp_key, Item_iterator &it, bool value, uint skip= 0); + bool is_access_triggered(); } TABLE_REF; @@ -284,7 +285,6 @@ typedef struct st_join_table { ulong max_used_fieldlength; uint used_blobs; uint used_null_fields; - uint used_rowid_fields; uint used_uneven_bit_fields; enum join_type type; bool cached_eq_ref_table,eq_ref_table,not_used_in_distinct; @@ -343,6 +343,9 @@ typedef struct st_join_table { NULL - Not doing a loose scan on this join tab. */ struct st_join_table *loosescan_match_tab; + + /* TRUE <=> we are inside LooseScan range */ + bool inside_loosescan_range; /* Buffer to save index tuple to be able to skip duplicates */ uchar *loosescan_buf; @@ -385,19 +388,14 @@ typedef struct st_join_table { return (is_using_loose_index_scan() && ((QUICK_GROUP_MIN_MAX_SELECT *)select->quick)->is_agg_distinct()); } - bool check_rowid_field() - { - if (keep_current_rowid && !used_rowid_fields) - { - used_rowid_fields= 1; - used_fieldlength+= table->file->ref_length; - } - return test(used_rowid_fields); - } bool is_inner_table_of_semi_join_with_first_match() { return first_sj_inner_tab != NULL; } + bool is_inner_table_of_semijoin() + { + return emb_sj_nest != NULL; + } bool is_inner_table_of_outer_join() { return first_inner != NULL; @@ -674,6 +672,7 @@ protected: KEYUSE *join_tab_keyuse[MAX_TABLES]; /* Copies of JOIN_TAB::checked_keys for each JOIN_TAB. */ key_map join_tab_checked_keys[MAX_TABLES]; + SJ_MATERIALIZATION_INFO *sj_mat_info[MAX_TABLES]; public: Join_plan_state() { @@ -699,6 +698,7 @@ protected: enum_reopt_result reoptimize(Item *added_where, table_map join_tables, Join_plan_state *save_to); void save_query_plan(Join_plan_state *save_to); + void reset_query_plan(); void restore_query_plan(Join_plan_state *restore_from); /* Choose a subquery plan for a table-less subquery. */ bool choose_tableless_subquery_plan(); @@ -1152,7 +1152,7 @@ public: max_allowed_join_cache_level > JOIN_CACHE_HASHED_BIT; } bool choose_subquery_plan(table_map join_tables); - void get_partial_cost_and_fanout(uint end_tab_idx, + void get_partial_cost_and_fanout(int end_tab_idx, table_map filter_map, double *read_time_arg, double *record_count_arg); diff --git a/sql/sql_servers.cc b/sql/sql_servers.cc index 7d33abc16cd..dce679a883f 100644 --- a/sql/sql_servers.cc +++ b/sql/sql_servers.cc @@ -1,4 +1,4 @@ -/* Copyright (C) 2000-2003 MySQL AB, 2008-2009 Sun Microsystems, Inc +/* Copyright (c) 2000, 2010, Oracle and/or its affiliates. All rights reserved. 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 @@ -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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ /* diff --git a/sql/sql_servers.h b/sql/sql_servers.h index 3c338bbe3f9..a6186a85ae2 100644 --- a/sql/sql_servers.h +++ b/sql/sql_servers.h @@ -1,7 +1,7 @@ #ifndef SQL_SERVERS_INCLUDED #define SQL_SERVERS_INCLUDED -/* Copyright (C) 2006 MySQL AB +/* Copyright (c) 2006, 2010, Oracle and/or its affiliates. All rights reserved. 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/sql_show.cc b/sql/sql_show.cc index 4485991cdaf..5666225a9d1 100644 --- a/sql/sql_show.cc +++ b/sql/sql_show.cc @@ -1218,7 +1218,7 @@ int store_create_info(THD *thd, TABLE_LIST *table_list, String *packet, handler *file= table->file; TABLE_SHARE *share= table->s; HA_CREATE_INFO create_info; - bool show_table_options= FALSE; + bool show_table_options __attribute__ ((unused))= FALSE; bool foreign_db_mode= (thd->variables.sql_mode & (MODE_POSTGRESQL | MODE_ORACLE | MODE_MSSQL | @@ -1908,7 +1908,8 @@ void mysqld_list_processes(THD *thd,const char *user, bool verbose) mysql_mutex_lock(&tmp->LOCK_thd_data); if ((mysys_var= tmp->mysys_var)) mysql_mutex_lock(&mysys_var->mutex); - thd_info->proc_info= (char*) (tmp->killed == THD::KILL_CONNECTION? "Killed" : 0); + thd_info->proc_info= (char*) (tmp->killed >= KILL_QUERY ? + "Killed" : 0); thd_info->state_info= thread_state_info(tmp); if (mysys_var) mysql_mutex_unlock(&mysys_var->mutex); @@ -2037,7 +2038,8 @@ int fill_schema_processlist(THD* thd, TABLE_LIST* tables, COND* cond) if ((mysys_var= tmp->mysys_var)) mysql_mutex_lock(&mysys_var->mutex); /* COMMAND */ - if ((val= (char *) (tmp->killed == THD::KILL_CONNECTION? "Killed" : 0))) + if ((val= (char *) ((tmp->killed >= KILL_QUERY ? + "Killed" : 0)))) table->field[4]->store(val, strlen(val), cs); else table->field[4]->store(command_name[tmp->command].str, @@ -2365,14 +2367,14 @@ static bool show_status_array(THD *thd, const char *wild, case SHOW_LONG_STATUS: value= ((char *) status_var + (intptr) value); /* fall through */ - case SHOW_LONG: + case SHOW_ULONG: case SHOW_LONG_NOFLUSH: // the difference lies in refresh_status() end= int10_to_str(*(long*) value, buff, 10); break; case SHOW_LONGLONG_STATUS: value= ((char *) status_var + (intptr) value); /* fall through */ - case SHOW_LONGLONG: + case SHOW_ULONGLONG: end= longlong10_to_str(*(longlong*) value, buff, 10); break; case SHOW_HA_ROWS: @@ -2384,8 +2386,17 @@ static bool show_status_array(THD *thd, const char *wild, case SHOW_MY_BOOL: end= strmov(buff, *(my_bool*) value ? "ON" : "OFF"); break; - case SHOW_INT: - end= int10_to_str((long) *(uint32*) value, buff, 10); + case SHOW_UINT: + end= int10_to_str((long) *(uint*) value, buff, 10); + break; + case SHOW_SINT: + end= int10_to_str((long) *(uint*) value, buff, -10); + break; + case SHOW_SLONG: + end= int10_to_str(*(long*) value, buff, -10); + break; + case SHOW_SLONGLONG: + end= longlong10_to_str(*(longlong*) value, buff, -10); break; case SHOW_HAVE: { @@ -3573,6 +3584,10 @@ end: */ thd->temporary_tables= NULL; close_thread_tables(thd); + /* + Release metadata lock we might have acquired. + See comment in fill_schema_table_from_frm() for details. + */ thd->mdl_context.rollback_to_savepoint(open_tables_state_backup->mdl_system_tables_svp); thd->lex= old_lex; @@ -3755,6 +3770,9 @@ try_acquire_high_prio_shared_mdl_lock(THD *thd, TABLE_LIST *table, @param[in] db_name database name @param[in] table_name table name @param[in] schema_table_idx I_S table index + @param[in] open_tables_state_backup Open_tables_state object which is used + to save/restore original state of metadata + locks. @param[in] can_deadlock Indicates that deadlocks are possible due to metadata locks, so to avoid them we should not wait in case if @@ -3772,6 +3790,7 @@ static int fill_schema_table_from_frm(THD *thd, TABLE_LIST *tables, LEX_STRING *db_name, LEX_STRING *table_name, enum enum_schema_tables schema_table_idx, + Open_tables_backup *open_tables_state_backup, bool can_deadlock) { TABLE *table= tables->table; @@ -3916,13 +3935,27 @@ end_share: end_unlock: mysql_mutex_unlock(&LOCK_open); - /* - Don't release the MDL lock, it can be part of a transaction. - If it is not, it will be released by the call to - MDL_context::rollback_to_savepoint() in the caller. - */ end: + /* + Release metadata lock we might have acquired. + + Without this step metadata locks acquired for each table processed + will be accumulated. In situation when a lot of tables are processed + by I_S query this will result in transaction with too many metadata + locks. As result performance of acquisition of new lock will suffer. + + Of course, the fact that we don't hold metadata lock on tables which + were processed till the end of I_S query makes execution less isolated + from concurrent DDL. Consequently one might get 'dirty' results from + such a query. But we have never promised serializability of I_S queries + anyway. + + We don't have any tables open since we took backup, so rolling back to + savepoint is safe. + */ + DBUG_ASSERT(thd->open_tables == NULL); + thd->mdl_context.rollback_to_savepoint(open_tables_state_backup->mdl_system_tables_svp); thd->clear_error(); return res; } @@ -4173,6 +4206,7 @@ int get_all_tables(THD *thd, TABLE_LIST *tables, COND *cond) int res= fill_schema_table_from_frm(thd, tables, schema_table, db_name, table_name, schema_table_idx, + &open_tables_state_backup, can_deadlock); thd->pop_internal_handler(); @@ -5035,7 +5069,7 @@ bool store_schema_params(THD *thd, TABLE *table, TABLE *proc_table, String sp_name(sp_name_buff, sizeof(sp_name_buff), cs); String definer(definer_buff, sizeof(definer_buff), cs); sp_head *sp; - uint routine_type; + stored_procedure_type routine_type; bool free_sp_head; DBUG_ENTER("store_schema_params"); @@ -5046,7 +5080,7 @@ bool store_schema_params(THD *thd, TABLE *table, TABLE *proc_table, get_field(thd->mem_root, proc_table->field[MYSQL_PROC_FIELD_DB], &sp_db); get_field(thd->mem_root, proc_table->field[MYSQL_PROC_FIELD_NAME], &sp_name); get_field(thd->mem_root,proc_table->field[MYSQL_PROC_FIELD_DEFINER],&definer); - routine_type= (uint) proc_table->field[MYSQL_PROC_MYSQL_TYPE]->val_int(); + routine_type= (stored_procedure_type) proc_table->field[MYSQL_PROC_MYSQL_TYPE]->val_int(); if (!full_access) full_access= !strcmp(sp_user, definer.ptr()); @@ -7448,11 +7482,11 @@ bool get_schema_tables_result(JOIN *join, { result= 1; join->error= 1; - tab->read_record.file= table_list->table->file; + tab->read_record.table->file= table_list->table->file; table_list->schema_table_state= executed_place; break; } - tab->read_record.file= table_list->table->file; + tab->read_record.table->file= table_list->table->file; table_list->schema_table_state= executed_place; } } diff --git a/sql/sql_show.h b/sql/sql_show.h index de8f2525baa..8ad9327c08c 100644 --- a/sql/sql_show.h +++ b/sql/sql_show.h @@ -1,4 +1,4 @@ -/* Copyright 2006-2008 MySQL AB, 2008 Sun Microsystems, Inc. +/* Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved. 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/sql_signal.cc b/sql/sql_signal.cc index ed42110f7f6..c9f1f42159f 100644 --- a/sql/sql_signal.cc +++ b/sql/sql_signal.cc @@ -1,4 +1,4 @@ -/* Copyright (C) 2008 Sun Microsystems, Inc +/* Copyright (c) 2008, 2010, Oracle and/or its affiliates. All rights reserved. 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 @@ -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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ #include "sql_priv.h" #include "sp_head.h" diff --git a/sql/sql_signal.h b/sql/sql_signal.h index c9c1517f4ad..058457a3639 100644 --- a/sql/sql_signal.h +++ b/sql/sql_signal.h @@ -1,4 +1,5 @@ -/* Copyright (C) 2008 Sun Microsystems, Inc +/* Copyright (c) 2008 MySQL AB, 2009 Sun Microsystems, Inc. + Use is subject to license terms. 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 @@ -11,7 +12,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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ #ifndef SQL_SIGNAL_H #define SQL_SIGNAL_H diff --git a/sql/sql_sort.h b/sql/sql_sort.h index 4cb2f30d9de..f1a3a2f9d8b 100644 --- a/sql/sql_sort.h +++ b/sql/sql_sort.h @@ -1,7 +1,7 @@ #ifndef SQL_SORT_INCLUDED #define SQL_SORT_INCLUDED -/* Copyright (C) 2000 MySQL AB +/* Copyright (c) 2000, 2010, Oracle and/or its affiliates. All rights reserved. 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 @@ -14,7 +14,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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ #include "my_global.h" /* uchar */ #include "my_base.h" /* ha_rows */ diff --git a/sql/sql_string.cc b/sql/sql_string.cc index e615bf7d4df..6c772617e7b 100644 --- a/sql/sql_string.cc +++ b/sql/sql_string.cc @@ -1,4 +1,4 @@ -/* Copyright (C) 2000 MySQL AB +/* Copyright (c) 2000, 2011, Oracle and/or its affiliates. All rights reserved. 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 @@ -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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ /* This file is originally from the mysql distribution. Coded by monty */ diff --git a/sql/sql_string.h b/sql/sql_string.h index 71ad0960924..fcf04fb7690 100644 --- a/sql/sql_string.h +++ b/sql/sql_string.h @@ -1,7 +1,7 @@ #ifndef SQL_STRING_INCLUDED #define SQL_STRING_INCLUDED -/* Copyright (C) 2000 MySQL AB +/* Copyright (c) 2000, 2011, Oracle and/or its affiliates. All rights reserved. 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 @@ -14,7 +14,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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ /* This file is originally from the mysql distribution. Coded by monty */ diff --git a/sql/sql_table.cc b/sql/sql_table.cc index 9d6be2a805d..abd29ea6a02 100644 --- a/sql/sql_table.cc +++ b/sql/sql_table.cc @@ -1,4 +1,5 @@ -/* Copyright (c) 2000, 2011, Oracle and/or its affiliates. +/* + Copyright (c) 2000, 2011, Oracle and/or its affiliates. Copyright (c) 2010, 2011 Monty Program Ab This program is free software; you can redistribute it and/or modify @@ -12,7 +13,8 @@ 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +*/ /* drop and alter of tables */ @@ -5485,6 +5487,12 @@ mysql_prepare_alter_table(THD *thd, TABLE *table, if (drop) { drop_it.remove(); + /* + ALTER TABLE DROP COLUMN always changes table data even in cases + when new version of the table has the same structure as the old + one. + */ + alter_info->change_level= ALTER_TABLE_DATA_CHANGED; continue; } /* Check if field is changed */ @@ -5568,7 +5576,14 @@ mysql_prepare_alter_table(THD *thd, TABLE *table, if (!def->after) new_create_list.push_back(def); else if (def->after == first_keyword) + { new_create_list.push_front(def); + /* + Re-ordering columns in table can't be done using in-place algorithm + as it always changes table data. + */ + alter_info->change_level= ALTER_TABLE_DATA_CHANGED; + } else { Create_field *find; @@ -5585,6 +5600,10 @@ mysql_prepare_alter_table(THD *thd, TABLE *table, goto err; } find_it.after(def); // Put element after this + /* + Re-ordering columns in table can't be done using in-place algorithm + as it always changes table data. + */ alter_info->change_level= ALTER_TABLE_DATA_CHANGED; } } diff --git a/sql/sql_table.h b/sql/sql_table.h index 333fc7431c0..00de6ed1b8d 100644 --- a/sql/sql_table.h +++ b/sql/sql_table.h @@ -1,4 +1,4 @@ -/* Copyright 2006-2008 MySQL AB, 2008-2009 Sun Microsystems, Inc. +/* Copyright (c) 2006, 2010, Oracle and/or its affiliates. All rights reserved. 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/sql_tablespace.cc b/sql/sql_tablespace.cc index 47b5f6c26fc..3f6daf7a9ec 100644 --- a/sql/sql_tablespace.cc +++ b/sql/sql_tablespace.cc @@ -1,4 +1,4 @@ -/* Copyright (C) 2000-2004 MySQL AB +/* Copyright (c) 2000, 2010, Oracle and/or its affiliates. All rights reserved. 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 @@ -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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ /* drop and alter of tablespaces */ diff --git a/sql/sql_tablespace.h b/sql/sql_tablespace.h index 93544dea4af..ae77d15cbcb 100644 --- a/sql/sql_tablespace.h +++ b/sql/sql_tablespace.h @@ -1,4 +1,4 @@ -/* Copyright 2006-2008 MySQL AB, 2008-2009 Sun Microsystems, Inc. +/* Copyright (c) 2006, 2010, Oracle and/or its affiliates. All rights reserved. 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/sql_test.cc b/sql/sql_test.cc index 9cf16e2bc6a..46f27f184fa 100644 --- a/sql/sql_test.cc +++ b/sql/sql_test.cc @@ -1,4 +1,4 @@ -/* Copyright (C) 2000-2006 MySQL AB, 2008-2009 Sun Microsystems, Inc +/* Copyright (c) 2000, 2010, Oracle and/or its affiliates. All rights reserved. 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 @@ -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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ /* Write some debug info */ diff --git a/sql/sql_test.h b/sql/sql_test.h index 82d4aad838a..3c1ee188eeb 100644 --- a/sql/sql_test.h +++ b/sql/sql_test.h @@ -1,4 +1,4 @@ -/* Copyright 2006-2008 MySQL AB, 2008-2009 Sun Microsystems, Inc. +/* Copyright (c) 2006, 2010, Oracle and/or its affiliates. All rights reserved. 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/sql_time.cc b/sql/sql_time.cc index 4db7fd9cbbb..5972c8918ba 100644 --- a/sql/sql_time.cc +++ b/sql/sql_time.cc @@ -1,4 +1,4 @@ -/* Copyright (C) 2000-2006 MySQL AB +/* Copyright (c) 2000, 2010, Oracle and/or its affiliates. Copyright (c) 2009-2011 Monty Program Ab This program is free software; you can redistribute it and/or modify @@ -12,7 +12,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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ /* Functions to handle date and time */ diff --git a/sql/sql_time.h b/sql/sql_time.h index df3ca9a14c7..026a15cb796 100644 --- a/sql/sql_time.h +++ b/sql/sql_time.h @@ -1,4 +1,4 @@ -/* Copyright 2006-2008 MySQL AB, 2008-2009 Sun Microsystems, Inc. +/* Copyright (c) 2006, 2010, Oracle and/or its affiliates. All rights reserved. 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/sql_trigger.cc b/sql/sql_trigger.cc index 868e803fb99..0ecc43b512f 100644 --- a/sql/sql_trigger.cc +++ b/sql/sql_trigger.cc @@ -1,4 +1,5 @@ -/* Copyright (c) 2004, 2011, Oracle and/or its affiliates. All rights reserved. +/* + Copyright (c) 2004, 2011, Oracle and/or its affiliates. All rights reserved. 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/sql_trigger.h b/sql/sql_trigger.h index c2afa900b74..84637b79818 100644 --- a/sql/sql_trigger.h +++ b/sql/sql_trigger.h @@ -1,7 +1,8 @@ #ifndef SQL_TRIGGER_INCLUDED #define SQL_TRIGGER_INCLUDED -/* Copyright (C) 2004-2005 MySQL AB +/* + Copyright (c) 2004, 2011, Oracle and/or its affiliates. All rights reserved. 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 @@ -14,7 +15,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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ /* Forward declarations */ diff --git a/sql/sql_udf.cc b/sql/sql_udf.cc index 3b3e96082cf..7eb0cd7ebf7 100644 --- a/sql/sql_udf.cc +++ b/sql/sql_udf.cc @@ -1,4 +1,4 @@ -/* Copyright (C) 2000 MySQL AB, 2008-2009 Sun Microsystems, Inc +/* Copyright (c) 2000, 2010, Oracle and/or its affiliates. All rights reserved. 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 @@ -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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ /* This implements 'user defined functions' */ diff --git a/sql/sql_udf.h b/sql/sql_udf.h index 95cb167869e..cdb15b9e0f5 100644 --- a/sql/sql_udf.h +++ b/sql/sql_udf.h @@ -1,7 +1,8 @@ #ifndef SQL_UDF_INCLUDED #define SQL_UDF_INCLUDED -/* Copyright (C) 2000-2001, 2003-2006 MySQL AB +/* Copyright (c) 2000, 2003-2007 MySQL AB, 2009 Sun Microsystems, Inc. + Use is subject to license terms. 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 @@ -14,7 +15,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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ /* This file defines structures needed by udf functions */ diff --git a/sql/sql_union.cc b/sql/sql_union.cc index 200140b5f6a..9f24ed45842 100644 --- a/sql/sql_union.cc +++ b/sql/sql_union.cc @@ -1,4 +1,4 @@ -/* Copyright 2000-2008 MySQL AB, 2008 Sun Microsystems, Inc. +/* Copyright (c) 2000, 2011, Oracle and/or its affiliates. All rights reserved. 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 @@ -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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ /* @@ -474,15 +474,27 @@ bool st_select_lex_unit::prepare(THD *thd_arg, select_result *sel_result, fake_select_lex->table_list.empty(); DBUG_RETURN(TRUE); } + + /* + Fake st_select_lex should have item list for correct ref_array + allocation. + */ fake_select_lex->item_list= item_list; thd_arg->lex->current_select= fake_select_lex; + + /* + We need to add up n_sum_items in order to make the correct + allocation in setup_ref_array(). + */ + fake_select_lex->n_child_sum_items+= global_parameters->n_sum_items; + saved_error= fake_select_lex->join-> prepare(&fake_select_lex->ref_pointer_array, fake_select_lex->table_list.first, 0, 0, - fake_select_lex->order_list.elements, - fake_select_lex->order_list.first, + global_parameters->order_list.elements, // og_num + global_parameters->order_list.first, // order NULL, NULL, NULL, fake_select_lex, this); fake_select_lex->table_list.empty(); @@ -649,6 +661,7 @@ bool st_select_lex_unit::exec() if (!saved_error) { examined_rows+= thd->examined_row_count; + thd->examined_row_count= 0; if (union_result->flush()) { thd->lex->current_select= lex_select_save; @@ -712,11 +725,21 @@ bool st_select_lex_unit::exec() } fake_select_lex->join->no_const_tables= TRUE; - /* - Fake st_select_lex should have item list for correctref_array - allocation. - */ - fake_select_lex->item_list= item_list; + /* + Fake st_select_lex should have item list for correct ref_array + allocation. + */ + fake_select_lex->item_list= item_list; + + /* + We need to add up n_sum_items in order to make the correct + allocation in setup_ref_array(). + Don't add more sum_items if we have already done JOIN::prepare + for this (with a different join object) + */ + if (!fake_select_lex->ref_pointer_array) + fake_select_lex->n_child_sum_items+= global_parameters->n_sum_items; + saved_error= mysql_select(thd, &fake_select_lex->ref_pointer_array, &result_table_list, 0, item_list, NULL, diff --git a/sql/sql_union.h b/sql/sql_union.h index 43e1b7a6910..171f607fba7 100644 --- a/sql/sql_union.h +++ b/sql/sql_union.h @@ -1,4 +1,4 @@ -/* Copyright 2006-2008 MySQL AB, 2008-2009 Sun Microsystems, Inc. +/* Copyright (c) 2006, 2010, Oracle and/or its affiliates. All rights reserved. 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/sql_update.cc b/sql/sql_update.cc index 5cb8d085c33..99cac9f40e7 100644 --- a/sql/sql_update.cc +++ b/sql/sql_update.cc @@ -1,4 +1,4 @@ -/* Copyright (c) 2000, 2010, Oracle and/or its affiliates. +/* Copyright (c) 2000, 2011, Oracle and/or its affiliates. Copyright (c) 2011 Monty Program Ab This program is free software; you can redistribute it and/or modify @@ -12,7 +12,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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ /* @@ -274,7 +274,7 @@ int mysql_update(THD *thd, SELECT_LEX *select_lex= &thd->lex->select_lex; ulonglong id; List<Item> all_fields; - THD::killed_state killed_status= THD::NOT_KILLED; + killed_state killed_status= NOT_KILLED; DBUG_ENTER("mysql_update"); if (open_tables(thd, &table_list, &table_count, 0)) @@ -843,9 +843,9 @@ int mysql_update(THD *thd, // simulated killing after the loop must be ineffective for binlogging DBUG_EXECUTE_IF("simulate_kill_bug27571", { - thd->killed= THD::KILL_QUERY; + thd->killed= KILL_QUERY; };); - error= (killed_status == THD::NOT_KILLED)? error : 1; + error= (killed_status == NOT_KILLED)? error : 1; if (error && will_batch && @@ -908,7 +908,7 @@ int mysql_update(THD *thd, if (error < 0) thd->clear_error(); else - errcode= query_error_code(thd, killed_status == THD::NOT_KILLED); + errcode= query_error_code(thd, killed_status == NOT_KILLED); if (thd->binlog_query(THD::ROW_QUERY_TYPE, thd->query(), thd->query_length(), @@ -2052,7 +2052,7 @@ void multi_update::abort_result_set() got caught and if happens later the killed error is written into repl event. */ - int errcode= query_error_code(thd, thd->killed == THD::NOT_KILLED); + int errcode= query_error_code(thd, thd->killed == NOT_KILLED); /* the error of binary logging is ignored */ (void)thd->binlog_query(THD::ROW_QUERY_TYPE, thd->query(), thd->query_length(), @@ -2265,7 +2265,7 @@ bool multi_update::send_eof() { char buff[STRING_BUFFER_USUAL_SIZE]; ulonglong id; - THD::killed_state killed_status= THD::NOT_KILLED; + killed_state killed_status= NOT_KILLED; DBUG_ENTER("multi_update::send_eof"); thd_proc_info(thd, "updating reference tables"); @@ -2280,7 +2280,7 @@ bool multi_update::send_eof() if local_error is not set ON until after do_updates() then later carried out killing should not affect binlogging. */ - killed_status= (local_error == 0)? THD::NOT_KILLED : thd->killed; + killed_status= (local_error == 0) ? NOT_KILLED : thd->killed; thd_proc_info(thd, "end"); /* We must invalidate the query cache before binlog writing and @@ -2310,7 +2310,7 @@ bool multi_update::send_eof() if (local_error == 0) thd->clear_error(); else - errcode= query_error_code(thd, killed_status == THD::NOT_KILLED); + errcode= query_error_code(thd, killed_status == NOT_KILLED); if (thd->binlog_query(THD::ROW_QUERY_TYPE, thd->query(), thd->query_length(), transactional_tables, FALSE, FALSE, errcode)) diff --git a/sql/sql_update.h b/sql/sql_update.h index 9552ff0ab2d..64029c5d634 100644 --- a/sql/sql_update.h +++ b/sql/sql_update.h @@ -1,4 +1,4 @@ -/* Copyright 2006-2008 MySQL AB, 2008-2009 Sun Microsystems, Inc. +/* Copyright (c) 2006, 2010, Oracle and/or its affiliates. All rights reserved. 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/sql_view.cc b/sql/sql_view.cc index c09b39c2450..94dffad822e 100644 --- a/sql/sql_view.cc +++ b/sql/sql_view.cc @@ -30,8 +30,8 @@ #include "sql_acl.h" // *_ACL, check_grant #include "sql_select.h" #include "parse_file.h" -#include "sp.h" #include "sp_head.h" +#include "sp.h" #include "sp_cache.h" #include "datadict.h" // dd_frm_type() diff --git a/sql/sql_view.h b/sql/sql_view.h index c15ecffccb8..2e9c77252e8 100644 --- a/sql/sql_view.h +++ b/sql/sql_view.h @@ -2,7 +2,7 @@ #define SQL_VIEW_INCLUDED /* -*- C++ -*- */ -/* Copyright (C) 2004 MySQL AB +/* Copyright (c) 2004, 2010, Oracle and/or its affiliates. All rights reserved. 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 @@ -15,7 +15,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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ #include "sql_class.h" /* Required by sql_lex.h */ diff --git a/sql/sql_yacc.yy b/sql/sql_yacc.yy index 93e2729c9fe..64aa42fa337 100644 --- a/sql/sql_yacc.yy +++ b/sql/sql_yacc.yy @@ -1,4 +1,5 @@ -/* Copyright (c) 2000, 2011 Oracle and/or its affiliates. All rights reserved. +/* + Copyright (c) 2000, 2011, Oracle and/or its affiliates. Copyright (c) 2010, 2011 Monty Program Ab This program is free software; you can redistribute it and/or modify @@ -12,7 +13,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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ /* sql_yacc.yy */ @@ -787,10 +788,10 @@ bool my_yyoverflow(short **a, YYSTYPE **b, ulong *yystacksize); %pure_parser /* We have threads */ /* - Currently there are 171 shift/reduce conflicts. + Currently there are 174 shift/reduce conflicts. We should not introduce new conflicts any more. */ -%expect 171 +%expect 174 /* Comments for TOKENS. @@ -1014,6 +1015,7 @@ bool my_yyoverflow(short **a, YYSTYPE **b, ulong *yystacksize); %token GROUP_CONCAT_SYM %token GT_SYM /* OPERATOR */ %token HANDLER_SYM +%token HARD_SYM %token HASH_SYM %token HAVING /* SQL-2003-R */ %token HELP_SYM @@ -1291,6 +1293,7 @@ bool my_yyoverflow(short **a, YYSTYPE **b, ulong *yystacksize); %token SMALLINT /* SQL-2003-R */ %token SNAPSHOT_SYM %token SOCKET_SYM +%token SOFT_SYM %token SONAME_SYM %token SOUNDS_SYM %token SOURCE_SYM @@ -1475,7 +1478,7 @@ bool my_yyoverflow(short **a, YYSTYPE **b, ulong *yystacksize); opt_ev_status opt_ev_on_completion ev_on_completion opt_ev_comment ev_alter_on_schedule_completion opt_ev_rename_to opt_ev_sql_stmt optional_flush_tables_arguments opt_dyncol_type dyncol_type - opt_time_precision + opt_time_precision kill_type kill_option int_num %type <m_yes_no_unk> opt_chain opt_release @@ -1510,7 +1513,7 @@ bool my_yyoverflow(short **a, YYSTYPE **b, ulong *yystacksize); function_call_keyword function_call_nonkeyword function_call_generic - function_call_conflict + function_call_conflict kill_expr signal_allowed_expr %type <item_num> @@ -2071,7 +2074,6 @@ create: lex->change=NullS; bzero((char*) &lex->create_info,sizeof(lex->create_info)); lex->create_info.options=$2 | $4; - lex->create_info.db_type= ha_default_handlerton(thd); lex->create_info.default_table_charset= NULL; lex->name.str= 0; lex->name.length= 0; @@ -2081,7 +2083,8 @@ create: { LEX *lex= YYTHD->lex; lex->current_select= &lex->select_lex; - if (!lex->create_info.db_type) + if ((lex->create_info.used_fields & HA_CREATE_USED_ENGINE) && + !lex->create_info.db_type) { lex->create_info.db_type= ha_default_handlerton(YYTHD); push_warning_printf(YYTHD, MYSQL_ERROR::WARN_LEVEL_WARN, @@ -5080,8 +5083,7 @@ create_table_option: ENGINE_SYM opt_equal storage_engines { Lex->create_info.db_type= $3; - if ($3) - Lex->create_info.used_fields|= HA_CREATE_USED_ENGINE; + Lex->create_info.used_fields|= HA_CREATE_USED_ENGINE; } | MAX_ROWS opt_equal ulonglong_num { @@ -6976,7 +6978,13 @@ alter_list_item: } | create_table_options_space_separated { - Lex->alter_info.flags|= ALTER_OPTIONS; + LEX *lex=Lex; + lex->alter_info.flags|= ALTER_OPTIONS; + if ((lex->create_info.used_fields & HA_CREATE_USED_ENGINE) && + !lex->create_info.db_type) + { + lex->create_info.used_fields&= ~HA_CREATE_USED_ENGINE; + } } | FORCE_SYM { @@ -9036,6 +9044,11 @@ function_call_generic: Create_func *builder; Item *item= NULL; + if (check_routine_name(&$1)) + { + MYSQL_YYABORT; + } + /* Implementation note: names are resolved with the following order: @@ -9099,6 +9112,16 @@ function_call_generic: version() (a vendor can specify any schema). */ + if (!$1.str || check_db_name(&$1)) + { + my_error(ER_WRONG_DB_NAME, MYF(0), $1.str); + MYSQL_YYABORT; + } + if (check_routine_name(&$3)) + { + MYSQL_YYABORT; + } + builder= find_qualified_function_builder(thd); DBUG_ASSERT(builder); item= builder->create_with_db(thd, $1, $3, true, $5); @@ -10394,6 +10417,12 @@ delete_limit_clause: } ; +int_num: + NUM { int error; $$= (int) my_strtoll10($1.str, (char**) 0, &error); } + | '-' NUM { int error; $$= -(int) my_strtoll10($2.str, (char**) 0, &error); } + | '-' LONG_NUM { int error; $$= -(int) my_strtoll10($2.str, (char**) 0, &error); } + ; + ulong_num: NUM { int error; $$= (ulong) my_strtoll10($1.str, (char**) 0, &error); } | HEX_NUM { $$= (ulong) strtol($1.str, (char**) 0, 16); } @@ -11745,7 +11774,10 @@ flush_option: | STATUS_SYM { Lex->type|= REFRESH_STATUS; } | SLAVE - { Lex->type|= REFRESH_SLAVE; } + { + Lex->type|= REFRESH_SLAVE; + Lex->reset_slave_info.all= false; + } | CLIENT_STATS_SYM { Lex->type|= REFRESH_CLIENT_STATS; } | USER_STATS_SYM @@ -11788,10 +11820,16 @@ reset_options: reset_option: SLAVE { Lex->type|= REFRESH_SLAVE; } + slave_reset_options { } | MASTER_SYM { Lex->type|= REFRESH_MASTER; } | QUERY_SYM CACHE_SYM { Lex->type|= REFRESH_QUERY_CACHE;} ; +slave_reset_options: + /* empty */ { Lex->reset_slave_info.all= false; } + | ALL { Lex->reset_slave_info.all= true; } + ; + purge: PURGE { @@ -11824,19 +11862,41 @@ purge_option: /* kill threads */ kill: - KILL_SYM kill_option expr + KILL_SYM { LEX *lex=Lex; lex->value_list.empty(); - lex->value_list.push_front($3); + lex->users_list.empty(); lex->sql_command= SQLCOM_KILL; } + kill_type kill_option kill_expr + { + Lex->kill_signal= (killed_state) ($3 | $4); + } ; +kill_type: + /* Empty */ { $$= (int) KILL_HARD_BIT; } + | HARD_SYM { $$= (int) KILL_HARD_BIT; } + | SOFT_SYM { $$= 0; } + kill_option: - /* empty */ { Lex->type= 0; } - | CONNECTION_SYM { Lex->type= 0; } - | QUERY_SYM { Lex->type= ONLY_KILL_QUERY; } + /* empty */ { $$= (int) KILL_CONNECTION; } + | CONNECTION_SYM { $$= (int) KILL_CONNECTION; } + | QUERY_SYM { $$= (int) KILL_QUERY; } + ; + +kill_expr: + expr + { + Lex->value_list.push_front($$); + Lex->kill_type= KILL_TYPE_ID; + } + | USER user + { + Lex->users_list.push_back($2); + Lex->kill_type= KILL_TYPE_USER; + } ; /* change database */ @@ -12967,6 +13027,7 @@ keyword_sp: | GRANTS {} | GLOBAL_SYM {} | HASH_SYM {} + | HARD_SYM {} | HOSTS_SYM {} | HOUR_SYM {} | IDENTIFIED_SYM {} @@ -13104,6 +13165,7 @@ keyword_sp: | SHUTDOWN {} | SLOW {} | SNAPSHOT_SYM {} + | SOFT_SYM {} | SOUNDS_SYM {} | SOURCE_SYM {} | SQL_CACHE_SYM {} @@ -14212,7 +14274,7 @@ grant_option: lex->mqh.conn_per_hour= $2; lex->mqh.specified_limits|= USER_RESOURCES::CONNECTIONS_PER_HOUR; } - | MAX_USER_CONNECTIONS_SYM ulong_num + | MAX_USER_CONNECTIONS_SYM int_num { LEX *lex=Lex; lex->mqh.user_conn= $2; diff --git a/sql/strfunc.h b/sql/strfunc.h index 6aa446e59ac..57c5427fcd0 100644 --- a/sql/strfunc.h +++ b/sql/strfunc.h @@ -1,4 +1,4 @@ -/* Copyright 2006-2008 MySQL AB, 2008-2009 Sun Microsystems, Inc. +/* Copyright (c) 2006, 2010, Oracle and/or its affiliates. All rights reserved. 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/structs.h b/sql/structs.h index 0d0b32e3d41..8aeb41f7a1e 100644 --- a/sql/structs.h +++ b/sql/structs.h @@ -1,7 +1,7 @@ #ifndef STRUCTS_INCLUDED #define STRUCTS_INCLUDED -/* Copyright (C) 2000-2006 MySQL AB +/* Copyright (c) 2000, 2010, Oracle and/or its affiliates. All rights reserved. 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 @@ -14,7 +14,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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ @@ -183,8 +183,11 @@ typedef struct user_resources { uint updates; /* Maximum number of connections established per hour. */ uint conn_per_hour; - /* Maximum number of concurrent connections. */ - uint user_conn; + /* + Maximum number of concurrent connections. If -1 then no new + connections allowed + */ + int user_conn; /* Values of this enum and specified_limits member are used by the parser to store which user limits were specified in GRANT statement. @@ -217,7 +220,7 @@ typedef struct user_conn { /* Total length of the key. */ uint len; /* Current amount of concurrent connections for this account. */ - uint connections; + int connections; /* Current number of connections per hour, number of updating statements per hour and total number of statements per hour for this account. diff --git a/sql/sys_vars.cc b/sql/sys_vars.cc index 4acd0cf8861..ef0e01b6e4e 100644 --- a/sql/sys_vars.cc +++ b/sql/sys_vars.cc @@ -1,4 +1,4 @@ -/* Copyright (c) 2002, 2010, Oracle and/or its affiliates. All rights reserved. +/* Copyright (c) 2002, 2011, Oracle and/or its affiliates. All rights reserved. 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 @@ -929,7 +929,8 @@ static Sys_var_mybool Sys_log_queries_not_using_indexes( static Sys_var_ulong Sys_log_warnings( "log_warnings", - "Log some not critical warnings to the general log file", + "Log some not critical warnings to the general log file." + "Value can be between 0 and 11. Higher values mean more verbosity", SESSION_VAR(log_warnings), CMD_LINE(OPT_ARG, 'W'), VALID_RANGE(0, ULONG_MAX), DEFAULT(1), BLOCK_SIZE(1)); @@ -1234,14 +1235,28 @@ static Sys_var_ulong Sys_max_sp_recursion_depth( SESSION_VAR(max_sp_recursion_depth), CMD_LINE(OPT_ARG), VALID_RANGE(0, 255), DEFAULT(0), BLOCK_SIZE(1)); + +static bool if_checking_enabled(sys_var *self, THD *thd, set_var *var) +{ + if (session_readonly(self, thd, var)) + return true; + + if (!max_user_connections_checking) + { + my_error(ER_OPTION_PREVENTS_STATEMENT, MYF(0), "--max-user-connections=0"); + return true; + } + + return false; +} // non-standard session_value_ptr() here static Sys_var_max_user_conn Sys_max_user_connections( "max_user_connections", "The maximum number of active connections for a single user " "(0 = no limit)", SESSION_VAR(max_user_connections), CMD_LINE(REQUIRED_ARG), - VALID_RANGE(0, UINT_MAX), DEFAULT(0), BLOCK_SIZE(1), NO_MUTEX_GUARD, - NOT_IN_BINLOG, ON_CHECK(session_readonly)); + VALID_RANGE(-1, INT_MAX), DEFAULT(0), BLOCK_SIZE(1), NO_MUTEX_GUARD, + NOT_IN_BINLOG, ON_CHECK(if_checking_enabled)); static Sys_var_ulong Sys_max_tmp_tables( "max_tmp_tables", @@ -3341,18 +3356,18 @@ static Sys_var_mybool Sys_userstat( CMD_LINE(OPT_ARG), DEFAULT(FALSE)); static Sys_var_mybool Sys_binlog_annotate_row_events( - "binlog_annotate_rows_events", + "binlog_annotate_row_events", "Tells the master to annotate RBR events with the statement that " "caused these events", - SESSION_VAR(binlog_annotate_rows_events), CMD_LINE(OPT_ARG), + SESSION_VAR(binlog_annotate_row_events), CMD_LINE(OPT_ARG), DEFAULT(FALSE)); #ifdef HAVE_REPLICATION -static Sys_var_mybool Sys_replicate_annotate_rows_events( - "replicate_annotate_rows_events", +static Sys_var_mybool Sys_replicate_annotate_row_events( + "replicate_annotate_row_events", "Tells the slave to write annotate rows events recieved from the master " "to its own binary log. Ignored if log_slave_updates is not set", - READ_ONLY GLOBAL_VAR(opt_replicate_annotate_rows_events), + READ_ONLY GLOBAL_VAR(opt_replicate_annotate_row_events), CMD_LINE(OPT_ARG), DEFAULT(0)); #endif @@ -3417,3 +3432,12 @@ static Sys_var_session_special Sys_in_transaction( VALID_RANGE(0, 1), BLOCK_SIZE(1), NO_MUTEX_GUARD, NOT_IN_BINLOG, ON_CHECK(0), ON_UPDATE(0), ON_READ(in_transaction)); +#ifndef DBUG_OFF +static Sys_var_ulong Sys_debug_binlog_fsync_sleep( + "debug_binlog_fsync_sleep", + "Extra sleep (in microseconds) to add to binlog fsync(), for debugging", + GLOBAL_VAR(opt_binlog_dbug_fsync_sleep), + CMD_LINE(REQUIRED_ARG), + VALID_RANGE(0, ULONG_MAX), DEFAULT(0), BLOCK_SIZE(1)); +#endif + diff --git a/sql/sys_vars.h b/sql/sys_vars.h index b06a3eeae2d..e7c03bbf552 100644 --- a/sql/sys_vars.h +++ b/sql/sys_vars.h @@ -1,4 +1,4 @@ -/* Copyright (C) 2002-2006 MySQL AB, 2009-2010 Sun Microsystems, Inc. +/* Copyright (c) 2002, 2010, Oracle and/or its affiliates. All rights reserved. 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 @@ -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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ /** @file @@ -70,6 +70,21 @@ #define GET_HA_ROWS GET_ULONG #endif +/* + special assert for sysvars. Tells the name of the variable, + and fails even in non-debug builds. + + It is supposed to be used *only* in Sys_var* constructors, + and has name_arg hard-coded to prevent incorrect usage. +*/ +#define SYSVAR_ASSERT(X) \ + while(!(X)) \ + { \ + fprintf(stderr, "Sysvar '%s' failed '%s'\n", name_arg, #X); \ + DBUG_ABORT(); \ + exit(255); \ + } + enum charset_enum {IN_SYSTEM_CHARSET, IN_FS_CHARSET}; static const char *bool_values[3]= {"OFF", "ON", 0}; @@ -89,21 +104,22 @@ struct CMD_LINE }; /** - Sys_var_unsigned template is used to generate Sys_var_* classes - for variables that represent the value as an unsigned integer. - They are Sys_var_uint, Sys_var_ulong, Sys_var_harows, Sys_var_ulonglong. + Sys_var_integer template is used to generate Sys_var_* classes + for variables that represent the value as an integer number. + They are Sys_var_uint, Sys_var_ulong, Sys_var_harows, Sys_var_ulonglong, + Sys_var_int. An integer variable has a minimal and maximal values, and a "block_size" (any valid value of the variable must be divisible by the block_size). Class specific constructor arguments: min, max, block_size - Backing store: uint, ulong, ha_rows, ulonglong, depending on the Sys_var_* + Backing store: int, uint, ulong, ha_rows, ulonglong, depending on the class */ template <typename T, ulong ARGT, enum enum_mysql_show_type SHOWT> -class Sys_var_unsigned: public sys_var +class Sys_var_integer: public sys_var { public: - Sys_var_unsigned(const char *name_arg, + Sys_var_integer(const char *name_arg, const char *comment, int flag_args, ptrdiff_t off, size_t size, CMD_LINE getopt, T min_val, T max_val, T def_val, uint block_size, PolyLock *lock=0, @@ -123,33 +139,58 @@ public: if (max_var_ptr()) *max_var_ptr()= max_val; global_var(T)= def_val; - DBUG_ASSERT(size == sizeof(T)); - DBUG_ASSERT(min_val < max_val); - DBUG_ASSERT(min_val <= def_val); - DBUG_ASSERT(max_val >= def_val); - DBUG_ASSERT(block_size > 0); - DBUG_ASSERT(def_val % block_size == 0); + SYSVAR_ASSERT(size == sizeof(T)); + SYSVAR_ASSERT(min_val < max_val); + SYSVAR_ASSERT(min_val <= def_val); + SYSVAR_ASSERT(max_val >= def_val); + SYSVAR_ASSERT(block_size > 0); + SYSVAR_ASSERT(def_val % block_size == 0); } bool do_check(THD *thd, set_var *var) { - my_bool fixed= FALSE; - ulonglong uv; - longlong v; + my_bool fixed= FALSE, unused; + longlong v= var->value->val_int(); + + if ((ARGT == GET_HA_ROWS) || (ARGT == GET_UINT) || + (ARGT == GET_ULONG) || (ARGT == GET_ULL)) + { + ulonglong uv; + + /* + if the value is signed and negative, + and a variable is unsigned, it is set to zero + */ + if ((fixed= (!var->value->unsigned_flag && v < 0))) + uv= 0; + else + uv= v; + + var->save_result.ulonglong_value= + getopt_ull_limit_value(uv, &option, &unused); - v= var->value->val_int(); - if (var->value->unsigned_flag) - uv= (ulonglong) v; + if (max_var_ptr() && (T)var->save_result.ulonglong_value > *max_var_ptr()) + var->save_result.ulonglong_value= *max_var_ptr(); + + fixed= fixed || var->save_result.ulonglong_value != uv; + } else - uv= (ulonglong) (v < 0 ? 0 : v); + { + /* + if the value is unsigned and has the highest bit set + and a variable is signed, it is set to max signed value + */ + if ((fixed= (var->value->unsigned_flag && v < 0))) + v= LONGLONG_MAX; - var->save_result.ulonglong_value= - getopt_ull_limit_value(uv, &option, &fixed); + var->save_result.longlong_value= + getopt_ll_limit_value(v, &option, &unused); - if (max_var_ptr() && var->save_result.ulonglong_value > *max_var_ptr()) - var->save_result.ulonglong_value= *max_var_ptr(); + if (max_var_ptr() && (T)var->save_result.longlong_value > *max_var_ptr()) + var->save_result.longlong_value= *max_var_ptr(); - return throw_bounds_warning(thd, name.str, - var->save_result.ulonglong_value != uv, + fixed= fixed || var->save_result.longlong_value != v; + } + return throw_bounds_warning(thd, name.str, fixed, var->value->unsigned_flag, v); } bool session_update(THD *thd, set_var *var) @@ -176,10 +217,11 @@ public: } }; -typedef Sys_var_unsigned<uint, GET_UINT, SHOW_INT> Sys_var_uint; -typedef Sys_var_unsigned<ulong, GET_ULONG, SHOW_LONG> Sys_var_ulong; -typedef Sys_var_unsigned<ha_rows, GET_HA_ROWS, SHOW_HA_ROWS> Sys_var_harows; -typedef Sys_var_unsigned<ulonglong, GET_ULL, SHOW_LONGLONG> Sys_var_ulonglong; +typedef Sys_var_integer<int, GET_INT, SHOW_SINT> Sys_var_int; +typedef Sys_var_integer<uint, GET_UINT, SHOW_UINT> Sys_var_uint; +typedef Sys_var_integer<ulong, GET_ULONG, SHOW_ULONG> Sys_var_ulong; +typedef Sys_var_integer<ha_rows, GET_HA_ROWS, SHOW_HA_ROWS> Sys_var_harows; +typedef Sys_var_integer<ulonglong, GET_ULL, SHOW_ULONGLONG> Sys_var_ulonglong; /** Helper class for variables that take values from a TYPELIB @@ -271,8 +313,8 @@ public: { option.var_type= GET_ENUM; global_var(ulong)= def_val; - DBUG_ASSERT(def_val < typelib.count); - DBUG_ASSERT(size == sizeof(ulong)); + SYSVAR_ASSERT(def_val < typelib.count); + SYSVAR_ASSERT(size == sizeof(ulong)); } bool session_update(THD *thd, set_var *var) { @@ -318,9 +360,9 @@ public: { option.var_type= GET_BOOL; global_var(my_bool)= def_val; - DBUG_ASSERT(def_val < 2); - DBUG_ASSERT(getopt.arg_type == OPT_ARG || getopt.id == -1); - DBUG_ASSERT(size == sizeof(my_bool)); + SYSVAR_ASSERT(def_val < 2); + SYSVAR_ASSERT(getopt.arg_type == OPT_ARG || getopt.id == -1); + SYSVAR_ASSERT(size == sizeof(my_bool)); } bool session_update(THD *thd, set_var *var) { @@ -379,8 +421,8 @@ public: */ option.var_type= (flags & ALLOCATED) ? GET_STR_ALLOC : GET_STR; global_var(const char*)= def_val; - DBUG_ASSERT(scope() == GLOBAL); - DBUG_ASSERT(size == sizeof(char *)); + SYSVAR_ASSERT(scope() == GLOBAL); + SYSVAR_ASSERT(size == sizeof(char *)); } void cleanup() { @@ -537,7 +579,7 @@ public: on_check_func, on_update_func, deprecated_version, substitute) { global_var(LEX_STRING).length= strlen(def_val); - DBUG_ASSERT(size == sizeof(LEX_STRING)); + SYSVAR_ASSERT(size == sizeof(LEX_STRING)); *const_cast<SHOW_TYPE*>(&show_val_type)= SHOW_LEX_STRING; } bool global_update(THD *thd, set_var *var) @@ -665,7 +707,7 @@ public: option.var_type|= GET_ASK_ADDR; option.value= (uchar**)1; // crash me, please keycache_var(dflt_key_cache, off)= def_val; - DBUG_ASSERT(scope() == GLOBAL); + SYSVAR_ASSERT(scope() == GLOBAL); } bool global_update(THD *thd, set_var *var) { @@ -825,10 +867,10 @@ public: option.min_value= (longlong) double2ulonglong(min_val); option.max_value= (longlong) double2ulonglong(max_val); global_var(double)= (double)option.def_value; - DBUG_ASSERT(min_val < max_val); - DBUG_ASSERT(min_val <= def_val); - DBUG_ASSERT(max_val >= def_val); - DBUG_ASSERT(size == sizeof(double)); + SYSVAR_ASSERT(min_val < max_val); + SYSVAR_ASSERT(min_val <= def_val); + SYSVAR_ASSERT(max_val >= def_val); + SYSVAR_ASSERT(size == sizeof(double)); } bool do_check(THD *thd, set_var *var) { @@ -868,7 +910,7 @@ public: Backing store: uint */ -class Sys_var_max_user_conn: public Sys_var_uint +class Sys_var_max_user_conn: public Sys_var_int { public: Sys_var_max_user_conn(const char *name_arg, @@ -880,7 +922,7 @@ public: on_check_function on_check_func=0, on_update_function on_update_func=0, uint deprecated_version=0, const char *substitute=0) - : Sys_var_uint(name_arg, comment, SESSION, off, size, getopt, + : Sys_var_int(name_arg, comment, SESSION, off, size, getopt, min_val, max_val, def_val, block_size, lock, binlog_status_arg, on_check_func, on_update_func, deprecated_version, substitute) @@ -928,11 +970,11 @@ public: { option.var_type= GET_FLAGSET; global_var(ulonglong)= def_val; - DBUG_ASSERT(typelib.count > 1); - DBUG_ASSERT(typelib.count <= 65); - DBUG_ASSERT(def_val < MAX_SET(typelib.count)); - DBUG_ASSERT(strcmp(values[typelib.count-1], "default") == 0); - DBUG_ASSERT(size == sizeof(ulonglong)); + SYSVAR_ASSERT(typelib.count > 1); + SYSVAR_ASSERT(typelib.count <= 65); + SYSVAR_ASSERT(def_val < MAX_SET(typelib.count)); + SYSVAR_ASSERT(strcmp(values[typelib.count-1], "default") == 0); + SYSVAR_ASSERT(size == sizeof(ulonglong)); } bool do_check(THD *thd, set_var *var) { @@ -1039,10 +1081,10 @@ public: { option.var_type= GET_SET; global_var(ulonglong)= def_val; - DBUG_ASSERT(typelib.count > 0); - DBUG_ASSERT(typelib.count <= 64); - DBUG_ASSERT(def_val <= MAX_SET(typelib.count)); - DBUG_ASSERT(size == sizeof(ulonglong)); + SYSVAR_ASSERT(typelib.count > 0); + SYSVAR_ASSERT(typelib.count <= 64); + SYSVAR_ASSERT(def_val <= MAX_SET(typelib.count)); + SYSVAR_ASSERT(size == sizeof(ulonglong)); } bool do_check(THD *thd, set_var *var) { @@ -1145,8 +1187,8 @@ public: plugin_type(plugin_type_arg) { option.var_type= GET_STR; - DBUG_ASSERT(size == sizeof(plugin_ref)); - DBUG_ASSERT(getopt.id == -1); // force NO_CMD_LINE + SYSVAR_ASSERT(size == sizeof(plugin_ref)); + SYSVAR_ASSERT(getopt.id == -1); // force NO_CMD_LINE } bool do_check(THD *thd, set_var *var) { @@ -1256,7 +1298,7 @@ public: lock, binlog_status_arg, on_check_func, on_update_func, deprecated_version, substitute) { - DBUG_ASSERT(scope() == ONLY_SESSION); + SYSVAR_ASSERT(scope() == ONLY_SESSION); option.var_type= GET_NO_ARG; } bool do_check(THD *thd, set_var *var) @@ -1352,9 +1394,9 @@ public: reverse_semantics= my_count_bits(bitmask_arg) > 1; bitmask= reverse_semantics ? ~bitmask_arg : bitmask_arg; set(global_var_ptr(), def_val); - DBUG_ASSERT(def_val < 2); - DBUG_ASSERT(getopt.id == -1); // force NO_CMD_LINE - DBUG_ASSERT(size == sizeof(ulonglong)); + SYSVAR_ASSERT(def_val < 2); + SYSVAR_ASSERT(getopt.id == -1); // force NO_CMD_LINE + SYSVAR_ASSERT(size == sizeof(ulonglong)); } bool session_update(THD *thd, set_var *var) { @@ -1422,8 +1464,8 @@ public: deprecated_version, substitute), read_func(read_func_arg), update_func(update_func_arg) { - DBUG_ASSERT(scope() == ONLY_SESSION); - DBUG_ASSERT(getopt.id == -1); // NO_CMD_LINE, because the offset is fake + SYSVAR_ASSERT(scope() == ONLY_SESSION); + SYSVAR_ASSERT(getopt.id == -1); // NO_CMD_LINE, because the offset is fake } bool session_update(THD *thd, set_var *var) { return update_func(thd, var); } @@ -1472,8 +1514,8 @@ public: deprecated_version, substitute), read_func(read_func_arg), update_func(update_func_arg) { - DBUG_ASSERT(scope() == ONLY_SESSION); - DBUG_ASSERT(getopt.id == -1); // NO_CMD_LINE, because the offset is fake + SYSVAR_ASSERT(scope() == ONLY_SESSION); + SYSVAR_ASSERT(getopt.id == -1); // NO_CMD_LINE, because the offset is fake } bool session_update(THD *thd, set_var *var) { return update_func(thd, var); } @@ -1525,13 +1567,13 @@ public: lock, binlog_status_arg, on_check_func, on_update_func, deprecated_version, substitute) { - DBUG_ASSERT(scope() == GLOBAL); - DBUG_ASSERT(getopt.id == -1); - DBUG_ASSERT(lock == 0); - DBUG_ASSERT(binlog_status_arg == VARIABLE_NOT_IN_BINLOG); - DBUG_ASSERT(is_readonly()); - DBUG_ASSERT(on_update == 0); - DBUG_ASSERT(size == sizeof(enum SHOW_COMP_OPTION)); + SYSVAR_ASSERT(scope() == GLOBAL); + SYSVAR_ASSERT(getopt.id == -1); + SYSVAR_ASSERT(lock == 0); + SYSVAR_ASSERT(binlog_status_arg == VARIABLE_NOT_IN_BINLOG); + SYSVAR_ASSERT(is_readonly()); + SYSVAR_ASSERT(on_update == 0); + SYSVAR_ASSERT(size == sizeof(enum SHOW_COMP_OPTION)); } bool do_check(THD *thd, set_var *var) { DBUG_ASSERT(FALSE); @@ -1603,8 +1645,8 @@ public: thus all struct command-line options should be added manually to my_long_options in mysqld.cc */ - DBUG_ASSERT(getopt.id == -1); - DBUG_ASSERT(size == sizeof(void *)); + SYSVAR_ASSERT(getopt.id == -1); + SYSVAR_ASSERT(size == sizeof(void *)); } bool do_check(THD *thd, set_var *var) { return false; } @@ -1665,8 +1707,8 @@ public: lock, binlog_status_arg, on_check_func, on_update_func, deprecated_version, substitute) { - DBUG_ASSERT(getopt.id == -1); - DBUG_ASSERT(size == sizeof(Time_zone *)); + SYSVAR_ASSERT(getopt.id == -1); + SYSVAR_ASSERT(size == sizeof(Time_zone *)); } bool do_check(THD *thd, set_var *var) { @@ -1764,9 +1806,10 @@ public: #ifdef HAVE_EXPLICIT_TEMPLATE_INSTANTIATION template class List<set_var_base>; template class List_iterator_fast<set_var_base>; -template class Sys_var_unsigned<uint, GET_UINT, SHOW_INT>; -template class Sys_var_unsigned<ulong, GET_ULONG, SHOW_LONG>; -template class Sys_var_unsigned<ha_rows, GET_HA_ROWS, SHOW_HA_ROWS>; -template class Sys_var_unsigned<ulonglong, GET_ULL, SHOW_LONGLONG>; +template class Sys_var_integer<int, GET_INT, SHOW_SINT>; +template class Sys_var_integer<uint, GET_UINT, SHOW_INT>; +template class Sys_var_integer<ulong, GET_ULONG, SHOW_LONG>; +template class Sys_var_integer<ha_rows, GET_HA_ROWS, SHOW_HA_ROWS>; +template class Sys_var_integer<ulonglong, GET_ULL, SHOW_LONGLONG>; #endif diff --git a/sql/sys_vars_shared.h b/sql/sys_vars_shared.h index 644cc10c853..ff050f63064 100644 --- a/sql/sys_vars_shared.h +++ b/sql/sys_vars_shared.h @@ -1,7 +1,7 @@ #ifndef SYS_VARS_SHARED_INCLUDED #define SYS_VARS_SHARED_INCLUDED -/* Copyright (C) 2002-2006 MySQL AB, 2009-2010 Sun Microsystems, Inc. +/* Copyright (c) 2002, 2010, Oracle and/or its affiliates. All rights reserved. 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 @@ -14,7 +14,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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ /** @file diff --git a/sql/table.cc b/sql/table.cc index ab7ab37331a..07fae7329c8 100644 --- a/sql/table.cc +++ b/sql/table.cc @@ -1,4 +1,5 @@ -/* Copyright (c) 2000, 2011, Oracle and/or its affiliates. +/* + Copyright (c) 2000, 2011, Oracle and/or its affiliates. Copyright (c) 2009-2011, Monty Program Ab This program is free software; you can redistribute it and/or modify @@ -1067,14 +1068,13 @@ static int open_binary_frm(THD *thd, TABLE_SHARE *share, uchar *head, #endif next_chunk+= 5 + partition_info_str_len; } - if (share->mysql_version >= 50110) + if (share->mysql_version >= 50110 && next_chunk < buff_end) { /* New auto_partitioned indicator introduced in 5.1.11 */ #ifdef WITH_PARTITION_STORAGE_ENGINE share->auto_partitioned= *next_chunk; #endif next_chunk++; - DBUG_ASSERT(next_chunk <= buff_end); } keyinfo= share->key_info; for (i= 0; i < keys; i++, keyinfo++) @@ -5570,10 +5570,11 @@ void TABLE::mark_virtual_columns_for_write(bool insert_fl) @brief Allocate space for keys - @param key_count number of keys to allocate + @param key_count number of keys to allocate additionally @details - The function allocates memory to fit 'key_count' keys for this table. + The function allocates memory to fit additionally 'key_count' keys + for this table. @return FALSE space was successfully allocated @return TRUE an error occur @@ -5581,9 +5582,11 @@ void TABLE::mark_virtual_columns_for_write(bool insert_fl) bool TABLE::alloc_keys(uint key_count) { - key_info= s->key_info= (KEY*) alloc_root(&mem_root, sizeof(KEY)*key_count); - s->keys= 0; - max_keys= key_count; + key_info= (KEY*) alloc_root(&mem_root, sizeof(KEY)*(s->keys+key_count)); + if (s->keys) + memmove(key_info, s->key_info, sizeof(KEY)*s->keys); + s->key_info= key_info; + max_keys= s->keys+key_count; return !(key_info); } @@ -5728,7 +5731,7 @@ void TABLE::use_index(int key_to_save) /* Drop all keys; */ i= 0; - s->keys= (key_to_save < 0) ? 0 : 1; + s->keys= i; } /* @@ -6093,7 +6096,7 @@ int update_virtual_fields(THD *thd, TABLE *table, bool for_write) { DBUG_ENTER("update_virtual_fields"); Field **vfield_ptr, *vfield; - int error= 0; + int error __attribute__ ((unused))= 0; if (!table || !table->vfield) DBUG_RETURN(0); diff --git a/sql/table.h b/sql/table.h index 8dd1067ba49..b22cdb6e76b 100644 --- a/sql/table.h +++ b/sql/table.h @@ -1,6 +1,6 @@ #ifndef TABLE_INCLUDED #define TABLE_INCLUDED -/* Copyright (c) 2000, 2010, Oracle and/or its affiliates. +/* Copyright (c) 2000, 2011, Oracle and/or its affiliates. Copyright (c) 2009, 2011 Monty Program Ab This program is free software; you can redistribute it and/or modify @@ -14,7 +14,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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ #include "my_global.h" /* NO_EMBEDDED_ACCESS_CHECKS */ #include "sql_plist.h" diff --git a/sql/thr_malloc.cc b/sql/thr_malloc.cc index bbcfeeda3e8..ba534e52b99 100644 --- a/sql/thr_malloc.cc +++ b/sql/thr_malloc.cc @@ -1,4 +1,4 @@ -/* Copyright (C) 2000-2001, 2003-2004 MySQL AB +/* Copyright (c) 2000, 2010, Oracle and/or its affiliates. All rights reserved. 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 @@ -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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ /* Mallocs for used in threads */ diff --git a/sql/thr_malloc.h b/sql/thr_malloc.h index 52e6752ab70..81b7d3cc238 100644 --- a/sql/thr_malloc.h +++ b/sql/thr_malloc.h @@ -1,4 +1,4 @@ -/* Copyright 2006-2008 MySQL AB, 2008-2009 Sun Microsystems, Inc. +/* Copyright (c) 2006, 2010, Oracle and/or its affiliates. All rights reserved. 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/transaction.h b/sql/transaction.h index 135e6cae73f..e002cd4a9dc 100644 --- a/sql/transaction.h +++ b/sql/transaction.h @@ -1,4 +1,5 @@ -/* Copyright (C) 2008 Sun/MySQL +/* Copyright (c) 2008 MySQL AB, 2009 Sun Microsystems, Inc. + Use is subject to license terms. 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 @@ -11,7 +12,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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ #ifndef TRANSACTION_H #define TRANSACTION_H diff --git a/sql/tzfile.h b/sql/tzfile.h index 1c1800ba1ed..4feba612b36 100644 --- a/sql/tzfile.h +++ b/sql/tzfile.h @@ -1,7 +1,8 @@ #ifndef TZFILE_INCLUDED #define TZFILE_INCLUDED -/* Copyright (C) 2004 MySQL AB +/* Copyright (c) 2004, 2006, 2007 MySQL AB, 2009 Sun Microsystems, Inc. + Use is subject to license terms. 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 @@ -14,7 +15,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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ /* This file is based on public domain code from ftp://elsie.ncih.nist.gov/ diff --git a/sql/tztime.cc b/sql/tztime.cc index f84c62d98c9..aa945687675 100644 --- a/sql/tztime.cc +++ b/sql/tztime.cc @@ -1,4 +1,4 @@ -/* Copyright (C) 2004 MySQL AB, 2008-2009 Sun Microsystems, Inc +/* Copyright (c) 2004, 2010, Oracle and/or its affiliates. All rights reserved. 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 @@ -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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ /* Most of the following code and structures were derived from diff --git a/sql/tztime.h b/sql/tztime.h index c7ee0ff36cc..eb7d85c48b2 100644 --- a/sql/tztime.h +++ b/sql/tztime.h @@ -1,7 +1,7 @@ #ifndef TZTIME_INCLUDED #define TZTIME_INCLUDED -/* Copyright (C) 2004 MySQL AB +/* Copyright (c) 2004, 2010, Oracle and/or its affiliates. All rights reserved. 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 @@ -14,7 +14,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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ #ifdef USE_PRAGMA_INTERFACE diff --git a/sql/udf_example.c b/sql/udf_example.c index e0b72c99d7a..d68f49e1729 100644 --- a/sql/udf_example.c +++ b/sql/udf_example.c @@ -1,4 +1,4 @@ -/* Copyright (C) 2002 MySQL AB +/* Copyright (c) 2000, 2010, Oracle and/or its affiliates. All rights reserved. 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 @@ -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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ /* ** example file of UDF (user definable functions) that are dynamicly loaded diff --git a/sql/uniques.cc b/sql/uniques.cc index 21aa66ec64d..ae50a1d3970 100644 --- a/sql/uniques.cc +++ b/sql/uniques.cc @@ -1,4 +1,4 @@ -/* Copyright (C) 2001 MySQL AB +/* Copyright (c) 2001, 2010, Oracle and/or its affiliates. All rights reserved. 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 @@ -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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ /* Function to handle quick removal of duplicates diff --git a/sql/unireg.cc b/sql/unireg.cc index ef9729bcda4..b5faac3b797 100644 --- a/sql/unireg.cc +++ b/sql/unireg.cc @@ -1,4 +1,5 @@ -/* Copyright (c) 2000, 2011, Oracle and/or its affiliates. All rights reserved. +/* + Copyright (c) 2000, 2011, Oracle and/or its affiliates. All rights reserved. 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 @@ -11,7 +12,8 @@ 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 02110-1301 USA */ + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +*/ /* Functions to create a unireg form-file from a FIELD and a fieldname-fieldinfo diff --git a/storage/archive/archive_reader.c b/storage/archive/archive_reader.c index ab54164dcc0..eac70810e1c 100644 --- a/storage/archive/archive_reader.c +++ b/storage/archive/archive_reader.c @@ -1,3 +1,18 @@ +/* Copyright (c) 2007, 2010, Oracle and/or its affiliates. All rights reserved. + + 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 + the Free Software Foundation; version 2 of the License. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + 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 02110-1301 USA */ + #include "azlib.h" #include <string.h> #include <assert.h> diff --git a/storage/archive/ha_archive.cc b/storage/archive/ha_archive.cc index 4112279d3c6..3ccd1e83800 100644 --- a/storage/archive/ha_archive.cc +++ b/storage/archive/ha_archive.cc @@ -1,4 +1,5 @@ -/* Copyright (c) 2003, 2011, Oracle and/or its affiliates. All rights reserved. +/* + Copyright (c) 2004, 2011, Oracle and/or its affiliates. All rights reserved. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License @@ -12,8 +13,8 @@ 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 - 02110-1301 USA */ + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +*/ #ifdef USE_PRAGMA_IMPLEMENTATION #pragma implementation // gcc: Class implementation @@ -1779,7 +1780,8 @@ mysql_declare_plugin(archive) 0x0300 /* 3.0 */, NULL, /* status variables */ NULL, /* system variables */ - NULL /* config options */ + NULL, /* config options */ + 0, /* flags */ } mysql_declare_plugin_end; maria_declare_plugin(archive) diff --git a/storage/archive/ha_archive.h b/storage/archive/ha_archive.h index 034b759e091..7ae6bf57a32 100644 --- a/storage/archive/ha_archive.h +++ b/storage/archive/ha_archive.h @@ -1,4 +1,4 @@ -/* Copyright (C) 2003 MySQL AB, 2008-2009 Sun Microsystems, Inc +/* Copyright (c) 2003, 2011, Oracle and/or its affiliates. All rights reserved. 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 @@ -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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ #ifdef USE_PRAGMA_INTERFACE #pragma interface /* gcc class implementation */ diff --git a/storage/blackhole/ha_blackhole.cc b/storage/blackhole/ha_blackhole.cc index e758b29b024..7bdbb4349cd 100644 --- a/storage/blackhole/ha_blackhole.cc +++ b/storage/blackhole/ha_blackhole.cc @@ -1,4 +1,4 @@ -/* Copyright 2005-2008 MySQL AB, 2008-2009 Sun Microsystems, Inc. +/* Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved. 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 @@ -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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ #ifdef USE_PRAGMA_IMPLEMENTATION @@ -427,7 +427,8 @@ mysql_declare_plugin(blackhole) 0x0100 /* 1.0 */, NULL, /* status variables */ NULL, /* system variables */ - NULL /* config options */ + NULL, /* config options */ + 0, /* flags */ } mysql_declare_plugin_end; maria_declare_plugin(blackhole) diff --git a/storage/blackhole/ha_blackhole.h b/storage/blackhole/ha_blackhole.h index 17066b6edce..a7efd261ddb 100644 --- a/storage/blackhole/ha_blackhole.h +++ b/storage/blackhole/ha_blackhole.h @@ -1,4 +1,4 @@ -/* Copyright 2005-2008 MySQL AB, 2008 Sun Microsystems, Inc. +/* Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved. 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 @@ -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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ #ifdef USE_PRAGMA_INTERFACE #pragma interface /* gcc class implementation */ diff --git a/storage/csv/ha_tina.cc b/storage/csv/ha_tina.cc index d53f33945fa..719c7b10069 100644 --- a/storage/csv/ha_tina.cc +++ b/storage/csv/ha_tina.cc @@ -1,4 +1,4 @@ -/* Copyright (C) 2003 MySQL AB, 2008-2009 Sun Microsystems, Inc +/* Copyright (c) 2004, 2010, Oracle and/or its affiliates. All rights reserved. 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 @@ -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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ /* Make sure to look at ha_tina.h for more details. @@ -1781,7 +1781,8 @@ mysql_declare_plugin(csv) 0x0100 /* 1.0 */, NULL, /* status variables */ NULL, /* system variables */ - NULL /* config options */ + NULL, /* config options */ + 0, /* flags */ } mysql_declare_plugin_end; maria_declare_plugin(csv) diff --git a/storage/csv/ha_tina.h b/storage/csv/ha_tina.h index a2f12443528..837da613171 100644 --- a/storage/csv/ha_tina.h +++ b/storage/csv/ha_tina.h @@ -1,4 +1,4 @@ -/* Copyright (C) 2003 MySQL AB, 2008-2009 Sun Microsystems, Inc +/* Copyright (c) 2003, 2011, Oracle and/or its affiliates. All rights reserved. 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 @@ -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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ #include <sys/types.h> #include <sys/stat.h> diff --git a/storage/csv/transparent_file.cc b/storage/csv/transparent_file.cc index f92746c7b93..a307f9885c0 100644 --- a/storage/csv/transparent_file.cc +++ b/storage/csv/transparent_file.cc @@ -1,4 +1,4 @@ -/* Copyright (C) 2003 MySQL AB, 2008-2009 Sun Microsystems, Inc +/* Copyright (c) 2003, 2010, Oracle and/or its affiliates. All rights reserved. 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 @@ -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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ #ifdef USE_PRAGMA_IMPLEMENTATION #pragma implementation // gcc: Class implementation diff --git a/storage/csv/transparent_file.h b/storage/csv/transparent_file.h index 0168e271e7d..2536ad16a0f 100644 --- a/storage/csv/transparent_file.h +++ b/storage/csv/transparent_file.h @@ -1,4 +1,5 @@ -/* Copyright (C) 2003 MySQL AB +/* Copyright (c) 2003, 2007 MySQL AB, 2009 Sun Microsystems, Inc. + Use is subject to license terms. 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 @@ -11,7 +12,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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ #include <sys/types.h> #include <sys/stat.h> diff --git a/storage/example/ha_example.cc b/storage/example/ha_example.cc index bea8b4fb9c4..8566b013851 100644 --- a/storage/example/ha_example.cc +++ b/storage/example/ha_example.cc @@ -1,4 +1,4 @@ -/* Copyright (C) 2003 MySQL AB, 2009 Sun Microsystems, Inc. +/* Copyright (c) 2004, 2010, Oracle and/or its affiliates. All rights reserved. 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 @@ -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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ /** @file ha_example.cc @@ -1122,7 +1122,8 @@ mysql_declare_plugin(example) 0x0001 /* 0.1 */, func_status, /* status variables */ example_system_variables, /* system variables */ - NULL /* config options */ + NULL, /* config options */ + 0, /* flags */ } mysql_declare_plugin_end; maria_declare_plugin(example) diff --git a/storage/example/ha_example.h b/storage/example/ha_example.h index 27b97395544..08af1922662 100644 --- a/storage/example/ha_example.h +++ b/storage/example/ha_example.h @@ -1,4 +1,4 @@ -/* Copyright (c) 2003, 2010 Oracle and/or its affiliates. All rights reserved. +/* Copyright (c) 2004, 2010, Oracle and/or its affiliates. All rights reserved. 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 @@ -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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ /** @file ha_example.h diff --git a/storage/federated/ha_federated.cc b/storage/federated/ha_federated.cc index 48b88060a69..b083900e7b7 100644 --- a/storage/federated/ha_federated.cc +++ b/storage/federated/ha_federated.cc @@ -1,4 +1,4 @@ -/* Copyright (c) 2004, 2010 Oracle and/or its affiliates. All rights reserved. +/* Copyright (c) 2004, 2010, Oracle and/or its affiliates. All rights reserved. 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 @@ -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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ /* @@ -3469,7 +3469,8 @@ mysql_declare_plugin(federated) 0x0100 /* 1.0 */, NULL, /* status variables */ NULL, /* system variables */ - NULL /* config options */ + NULL, /* config options */ + 0, /* flags */ } mysql_declare_plugin_end; maria_declare_plugin(federated) diff --git a/storage/federated/ha_federated.h b/storage/federated/ha_federated.h index ad74521042e..796eabf2f2d 100644 --- a/storage/federated/ha_federated.h +++ b/storage/federated/ha_federated.h @@ -1,4 +1,4 @@ -/* Copyright (C) 2003 MySQL AB, 2008-2009 Sun Microsystems, Inc +/* Copyright (c) 2004, 2011, Oracle and/or its affiliates. All rights reserved. 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 @@ -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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ /* Please read ha_exmple.cc before reading this file. diff --git a/storage/federatedx/ha_federatedx.cc b/storage/federatedx/ha_federatedx.cc index c07ec92eac8..80d6b103e4c 100644 --- a/storage/federatedx/ha_federatedx.cc +++ b/storage/federatedx/ha_federatedx.cc @@ -3593,22 +3593,6 @@ int ha_federatedx::rollback(handlerton *hton, MYSQL_THD thd, bool all) struct st_mysql_storage_engine federatedx_storage_engine= { MYSQL_HANDLERTON_INTERFACE_VERSION }; -mysql_declare_plugin(federatedx) -{ - MYSQL_STORAGE_ENGINE_PLUGIN, - &federatedx_storage_engine, - "FEDERATED", - "Patrick Galbraith", - "FederatedX pluggable storage engine", - PLUGIN_LICENSE_GPL, - federatedx_db_init, /* Plugin Init */ - federatedx_done, /* Plugin Deinit */ - 0x0200 /* 2.0 */, - NULL, /* status variables */ - NULL, /* system variables */ - NULL /* config options */ -} -mysql_declare_plugin_end; maria_declare_plugin(federatedx) { MYSQL_STORAGE_ENGINE_PLUGIN, diff --git a/storage/heap/ha_heap.cc b/storage/heap/ha_heap.cc index 7c5fc133679..cf18ee29ee1 100644 --- a/storage/heap/ha_heap.cc +++ b/storage/heap/ha_heap.cc @@ -1,4 +1,5 @@ -/* Copyright (C) 2000-2006 MySQL AB, 2008-2009 Sun Microsystems, Inc +/* + Copyright (c) 2000, 2011, Oracle and/or its affiliates. All rights reserved. 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 @@ -11,7 +12,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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ #ifdef USE_PRAGMA_IMPLEMENTATION @@ -399,6 +400,7 @@ int ha_heap::info(uint flag) stats.index_file_length= hp_info.index_length; stats.max_data_file_length= hp_info.max_records * hp_info.reclength; stats.delete_length= hp_info.deleted * hp_info.reclength; + stats.create_time= (ulong) hp_info.create_time; if (flag & HA_STATUS_AUTO) stats.auto_increment_value= hp_info.auto_increment; /* @@ -814,7 +816,8 @@ mysql_declare_plugin(heap) 0x0100, /* 1.0 */ NULL, /* status variables */ NULL, /* system variables */ - NULL /* config options */ + NULL, /* config options */ + 0, /* flags */ } mysql_declare_plugin_end; maria_declare_plugin(heap) diff --git a/storage/heap/ha_heap.h b/storage/heap/ha_heap.h index 42c41c69ee0..4b4e0d44d99 100644 --- a/storage/heap/ha_heap.h +++ b/storage/heap/ha_heap.h @@ -1,4 +1,6 @@ -/* Copyright (C) 2000-2006 MySQL AB, 2009-2011 Monty Program Ab +/* + Copyright (c) 2000, 2011, Oracle and/or its affiliates. All rights reserved. + Copyright (c) 2009, 2011, Monty Program Ab 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 @@ -11,7 +13,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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ #ifdef USE_PRAGMA_INTERFACE diff --git a/storage/heap/heapdef.h b/storage/heap/heapdef.h index 87866678c2f..e844f90d321 100644 --- a/storage/heap/heapdef.h +++ b/storage/heap/heapdef.h @@ -1,4 +1,4 @@ -/* Copyright (C) 2000-2002, 2004 MySQL AB, 2008-2009 Sun Microsystems, Inc +/* Copyright (c) 2000, 2011, Oracle and/or its affiliates. All rights reserved. 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 @@ -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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ /* This file is included in all heap-files */ diff --git a/storage/heap/hp_block.c b/storage/heap/hp_block.c index 41391fba060..90efeeb7924 100644 --- a/storage/heap/hp_block.c +++ b/storage/heap/hp_block.c @@ -1,4 +1,4 @@ -/* Copyright (C) 2000-2002, 2004 MySQL AB +/* Copyright (c) 2000, 2011, Oracle and/or its affiliates. All rights reserved. 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 @@ -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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ /* functions on blocks; Keys and records are saved in blocks */ diff --git a/storage/heap/hp_clear.c b/storage/heap/hp_clear.c index 254e5d1a8ec..2b1502e6475 100644 --- a/storage/heap/hp_clear.c +++ b/storage/heap/hp_clear.c @@ -1,4 +1,5 @@ -/* Copyright (C) 2000-2002, 2004, 2006 MySQL AB +/* Copyright (c) 2000-2002, 2004-2007 MySQL AB, 2009 Sun Microsystems, Inc. + Use is subject to license terms. 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 @@ -11,7 +12,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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ /* remove all records from database diff --git a/storage/heap/hp_close.c b/storage/heap/hp_close.c index e5a826423db..52663fdaa00 100644 --- a/storage/heap/hp_close.c +++ b/storage/heap/hp_close.c @@ -1,4 +1,4 @@ -/* Copyright (C) 2000-2002 MySQL AB, 2008-2009 Sun Microsystems, Inc +/* Copyright (c) 2000, 2010, Oracle and/or its affiliates. All rights reserved. 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 @@ -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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ /* close a heap-database */ diff --git a/storage/heap/hp_create.c b/storage/heap/hp_create.c index adc507aa28e..5ec38955664 100644 --- a/storage/heap/hp_create.c +++ b/storage/heap/hp_create.c @@ -1,4 +1,4 @@ -/* Copyright (C) 2000-2006 MySQL AB, 2008-2009 Sun Microsystems, Inc +/* Copyright (c) 2000, 2011, Oracle and/or its affiliates. All rights reserved. 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 @@ -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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ #include "heapdef.h" @@ -198,6 +198,7 @@ int heap_create(const char *name, HP_CREATE_INFO *create_info, share->auto_key= create_info->auto_key; share->auto_key_type= create_info->auto_key_type; share->auto_increment= create_info->auto_increment; + share->create_time= (long) time((time_t*) 0); /* Must be allocated separately for rename to work */ if (!(share->name= my_strdup(name,MYF(0)))) { diff --git a/storage/heap/hp_hash.c b/storage/heap/hp_hash.c index fb9ea44a424..424b1de0869 100644 --- a/storage/heap/hp_hash.c +++ b/storage/heap/hp_hash.c @@ -1,4 +1,4 @@ -/* Copyright (C) 2000-2006 MySQL AB +/* Copyright (c) 2000, 2010, Oracle and/or its affiliates. All rights reserved. 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 @@ -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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ /* The hash functions used for saveing keys */ diff --git a/storage/heap/hp_info.c b/storage/heap/hp_info.c index ea78c53fd40..c72dbaf2065 100644 --- a/storage/heap/hp_info.c +++ b/storage/heap/hp_info.c @@ -53,6 +53,7 @@ int heap_info(reg1 HP_INFO *info,reg2 HEAPINFO *x, int flag ) x->index_length = info->s->index_length; x->max_records = info->s->max_records; x->errkey = info->errkey; + x->create_time = info->s->create_time; if (flag & HA_STATUS_AUTO) x->auto_increment= info->s->auto_increment + 1; DBUG_RETURN(0); diff --git a/storage/heap/hp_open.c b/storage/heap/hp_open.c index 5ac4da22e0a..c456dbdfc84 100644 --- a/storage/heap/hp_open.c +++ b/storage/heap/hp_open.c @@ -1,4 +1,4 @@ -/* Copyright (C) 2000-2004, 2006 MySQL AB, 2008-2009 Sun Microsystems, Inc +/* Copyright (c) 2000, 2011, Oracle and/or its affiliates. All rights reserved. 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 @@ -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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ /* open a heap-database */ diff --git a/storage/heap/hp_panic.c b/storage/heap/hp_panic.c index 87d982dff2a..e1e421a5115 100644 --- a/storage/heap/hp_panic.c +++ b/storage/heap/hp_panic.c @@ -1,4 +1,5 @@ -/* Copyright (C) 2000-2002 MySQL AB, 2008-2009 Sun Microsystems, Inc +/* Copyright (c) 2000, 2002, 2005, 2006 MySQL AB, 2009 Sun Microsystems, Inc. + Use is subject to license terms. 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 @@ -11,7 +12,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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ #include "heapdef.h" diff --git a/storage/heap/hp_rename.c b/storage/heap/hp_rename.c index cf0d2b2b387..34c8218e387 100644 --- a/storage/heap/hp_rename.c +++ b/storage/heap/hp_rename.c @@ -1,4 +1,4 @@ -/* Copyright (C) 2000-2002 MySQL AB, 2008-2009 Sun Microsystems, Inc +/* Copyright (c) 2000, 2010, Oracle and/or its affiliates. All rights reserved. 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 @@ -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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ /* Rename a table diff --git a/storage/heap/hp_rkey.c b/storage/heap/hp_rkey.c index 166ed28aed0..d0cbb94eb0e 100644 --- a/storage/heap/hp_rkey.c +++ b/storage/heap/hp_rkey.c @@ -1,4 +1,5 @@ -/* Copyright (C) 2000-2004, 2006 MySQL AB +/* Copyright (c) 2000, 2002-2007 MySQL AB, 2009 Sun Microsystems, Inc. + Use is subject to license terms. 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 @@ -11,7 +12,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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ #include "heapdef.h" diff --git a/storage/heap/hp_static.c b/storage/heap/hp_static.c index a58ecb8b754..c50465cd402 100644 --- a/storage/heap/hp_static.c +++ b/storage/heap/hp_static.c @@ -1,4 +1,4 @@ -/* Copyright (C) 2000-2001 MySQL AB, 2008-2009 Sun Microsystems, Inc +/* Copyright (c) 2000, 2011, Oracle and/or its affiliates. All rights reserved. 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 @@ -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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ /* Static variables for heap library. All definied here for easy making of diff --git a/storage/heap/hp_test1.c b/storage/heap/hp_test1.c index 535db60e237..e6283f171c4 100644 --- a/storage/heap/hp_test1.c +++ b/storage/heap/hp_test1.c @@ -1,4 +1,4 @@ -/* Copyright (C) 2000-2003, 2006 MySQL AB +/* Copyright (c) 2000, 2010, Oracle and/or its affiliates. All rights reserved. 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 @@ -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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ /* Test av heap-database */ /* Programmet skapar en heap-databas. Till denna skrivs ett antal poster. diff --git a/storage/heap/hp_test2.c b/storage/heap/hp_test2.c index 5dab8443f53..caf7ff4daa9 100644 --- a/storage/heap/hp_test2.c +++ b/storage/heap/hp_test2.c @@ -1,5 +1,5 @@ -/* Copyright (C) 2000, 2011, Oracle and/or its affiliates. - Copyright (c) Monty Program Ab +/* Copyright (c) 2000, 2011, Oracle and/or its affiliates. + Copyright (c) 2010, 2011, Monty Program Ab 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 @@ -12,7 +12,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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ /* Test av isam-databas: stor test */ diff --git a/storage/heap/hp_write.c b/storage/heap/hp_write.c index bf27503de9b..fc6c31e324b 100644 --- a/storage/heap/hp_write.c +++ b/storage/heap/hp_write.c @@ -1,4 +1,5 @@ -/* Copyright (C) 2000-2002, 2004-2006 MySQL AB +/* Copyright (c) 2000-2002, 2004-2007 MySQL AB, 2009 Sun Microsystems, Inc. + Use is subject to license terms. 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 @@ -11,7 +12,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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ /* Write a record to heap-databas */ diff --git a/storage/innobase/btr/btr0btr.c b/storage/innobase/btr/btr0btr.c index fb2509a62ff..b476167af29 100644 --- a/storage/innobase/btr/btr0btr.c +++ b/storage/innobase/btr/btr0btr.c @@ -690,7 +690,8 @@ btr_root_block_get( zip_size = dict_table_zip_size(index->table); root_page_no = dict_index_get_page(index); - block = btr_block_get(space, zip_size, root_page_no, RW_X_LATCH, mtr); + block = btr_block_get(space, zip_size, root_page_no, RW_X_LATCH, + index, mtr); ut_a((ibool)!!page_is_comp(buf_block_get_frame(block)) == dict_table_is_comp(index->table)); #ifdef UNIV_BTR_DEBUG @@ -891,7 +892,7 @@ btr_page_alloc_for_ibuf( dict_table_zip_size(index->table), node_addr.page, RW_X_LATCH, mtr); new_page = buf_block_get_frame(new_block); - buf_block_dbg_add_level(new_block, SYNC_TREE_NODE_NEW); + buf_block_dbg_add_level(new_block, SYNC_IBUF_TREE_NODE_NEW); flst_remove(root + PAGE_HEADER + PAGE_BTR_IBUF_FREE_LIST, new_page + PAGE_HEADER + PAGE_BTR_IBUF_FREE_LIST_NODE, @@ -1139,7 +1140,7 @@ btr_node_ptr_get_child( page_no = btr_node_ptr_get_child_page_no(node_ptr, offsets); return(btr_block_get(space, dict_table_zip_size(index->table), - page_no, RW_X_LATCH, mtr)); + page_no, RW_X_LATCH, index, mtr)); } /************************************************************//** @@ -1312,7 +1313,8 @@ btr_create( space, 0, IBUF_HEADER + IBUF_TREE_SEG_HEADER, mtr); - buf_block_dbg_add_level(ibuf_hdr_block, SYNC_TREE_NODE_NEW); + buf_block_dbg_add_level( + ibuf_hdr_block, SYNC_IBUF_TREE_NODE_NEW); ut_ad(buf_block_get_page_no(ibuf_hdr_block) == IBUF_HEADER_PAGE_NO); @@ -1350,10 +1352,9 @@ btr_create( page_no = buf_block_get_page_no(block); frame = buf_block_get_frame(block); - buf_block_dbg_add_level(block, SYNC_TREE_NODE_NEW); - if (type & DICT_IBUF) { /* It is an insert buffer tree: initialize the free list */ + buf_block_dbg_add_level(block, SYNC_IBUF_TREE_NODE_NEW); ut_ad(page_no == IBUF_TREE_ROOT_PAGE_NO); @@ -1361,6 +1362,8 @@ btr_create( } else { /* It is a non-ibuf tree: create a file segment for leaf pages */ + buf_block_dbg_add_level(block, SYNC_TREE_NODE_NEW); + if (!fseg_create(space, page_no, PAGE_HEADER + PAGE_BTR_SEG_LEAF, mtr)) { /* Not enough space for new segment, free root @@ -1432,7 +1435,8 @@ btr_free_but_not_root( leaf_loop: mtr_start(&mtr); - root = btr_page_get(space, zip_size, root_page_no, RW_X_LATCH, &mtr); + root = btr_page_get(space, zip_size, root_page_no, RW_X_LATCH, + NULL, &mtr); #ifdef UNIV_BTR_DEBUG ut_a(btr_root_fseg_validate(FIL_PAGE_DATA + PAGE_BTR_SEG_LEAF + root, space)); @@ -1454,7 +1458,8 @@ leaf_loop: top_loop: mtr_start(&mtr); - root = btr_page_get(space, zip_size, root_page_no, RW_X_LATCH, &mtr); + root = btr_page_get(space, zip_size, root_page_no, RW_X_LATCH, + NULL, &mtr); #ifdef UNIV_BTR_DEBUG ut_a(btr_root_fseg_validate(FIL_PAGE_DATA + PAGE_BTR_SEG_TOP + root, space)); @@ -1480,13 +1485,13 @@ btr_free_root( ulint zip_size, /*!< in: compressed page size in bytes or 0 for uncompressed pages */ ulint root_page_no, /*!< in: root page number */ - mtr_t* mtr) /*!< in: a mini-transaction which has already - been started */ + mtr_t* mtr) /*!< in/out: mini-transaction */ { buf_block_t* block; fseg_header_t* header; - block = btr_block_get(space, zip_size, root_page_no, RW_X_LATCH, mtr); + block = btr_block_get(space, zip_size, root_page_no, RW_X_LATCH, + NULL, mtr); btr_search_drop_page_hash_index(block); @@ -2365,9 +2370,8 @@ btr_attach_half_pages( /* Update page links of the level */ if (prev_page_no != FIL_NULL) { - buf_block_t* prev_block = btr_block_get(space, zip_size, - prev_page_no, - RW_X_LATCH, mtr); + buf_block_t* prev_block = btr_block_get( + space, zip_size, prev_page_no, RW_X_LATCH, index, mtr); #ifdef UNIV_BTR_DEBUG ut_a(page_is_comp(prev_block->frame) == page_is_comp(page)); ut_a(btr_page_get_next(prev_block->frame, mtr) @@ -2380,9 +2384,8 @@ btr_attach_half_pages( } if (next_page_no != FIL_NULL) { - buf_block_t* next_block = btr_block_get(space, zip_size, - next_page_no, - RW_X_LATCH, mtr); + buf_block_t* next_block = btr_block_get( + space, zip_size, next_page_no, RW_X_LATCH, index, mtr); #ifdef UNIV_BTR_DEBUG ut_a(page_is_comp(next_block->frame) == page_is_comp(page)); ut_a(btr_page_get_prev(next_block->frame, mtr) @@ -2804,17 +2807,42 @@ func_exit: return(rec); } +#ifdef UNIV_SYNC_DEBUG +/*************************************************************//** +Removes a page from the level list of pages. +@param space in: space where removed +@param zip_size in: compressed page size in bytes, or 0 for uncompressed +@param page in/out: page to remove +@param index in: index tree +@param mtr in/out: mini-transaction */ +# define btr_level_list_remove(space,zip_size,page,index,mtr) \ + btr_level_list_remove_func(space,zip_size,page,index,mtr) +#else /* UNIV_SYNC_DEBUG */ +/*************************************************************//** +Removes a page from the level list of pages. +@param space in: space where removed +@param zip_size in: compressed page size in bytes, or 0 for uncompressed +@param page in/out: page to remove +@param index in: index tree +@param mtr in/out: mini-transaction */ +# define btr_level_list_remove(space,zip_size,page,index,mtr) \ + btr_level_list_remove_func(space,zip_size,page,mtr) +#endif /* UNIV_SYNC_DEBUG */ + /*************************************************************//** Removes a page from the level list of pages. */ -static +static __attribute__((nonnull)) void -btr_level_list_remove( -/*==================*/ - ulint space, /*!< in: space where removed */ - ulint zip_size,/*!< in: compressed page size in bytes - or 0 for uncompressed pages */ - page_t* page, /*!< in: page to remove */ - mtr_t* mtr) /*!< in: mtr */ +btr_level_list_remove_func( +/*=======================*/ + ulint space, /*!< in: space where removed */ + ulint zip_size,/*!< in: compressed page size in bytes + or 0 for uncompressed pages */ + page_t* page, /*!< in/out: page to remove */ +#ifdef UNIV_SYNC_DEBUG + const dict_index_t* index, /*!< in: index tree */ +#endif /* UNIV_SYNC_DEBUG */ + mtr_t* mtr) /*!< in/out: mini-transaction */ { ulint prev_page_no; ulint next_page_no; @@ -2832,7 +2860,7 @@ btr_level_list_remove( if (prev_page_no != FIL_NULL) { buf_block_t* prev_block = btr_block_get(space, zip_size, prev_page_no, - RW_X_LATCH, mtr); + RW_X_LATCH, index, mtr); page_t* prev_page = buf_block_get_frame(prev_block); #ifdef UNIV_BTR_DEBUG @@ -2849,7 +2877,7 @@ btr_level_list_remove( if (next_page_no != FIL_NULL) { buf_block_t* next_block = btr_block_get(space, zip_size, next_page_no, - RW_X_LATCH, mtr); + RW_X_LATCH, index, mtr); page_t* next_page = buf_block_get_frame(next_block); #ifdef UNIV_BTR_DEBUG @@ -3164,7 +3192,7 @@ btr_compress( if (is_left) { merge_block = btr_block_get(space, zip_size, left_page_no, - RW_X_LATCH, mtr); + RW_X_LATCH, index, mtr); merge_page = buf_block_get_frame(merge_block); #ifdef UNIV_BTR_DEBUG ut_a(btr_page_get_next(merge_page, mtr) @@ -3173,7 +3201,7 @@ btr_compress( } else if (right_page_no != FIL_NULL) { merge_block = btr_block_get(space, zip_size, right_page_no, - RW_X_LATCH, mtr); + RW_X_LATCH, index, mtr); merge_page = buf_block_get_frame(merge_block); #ifdef UNIV_BTR_DEBUG ut_a(btr_page_get_prev(merge_page, mtr) @@ -3262,7 +3290,7 @@ err_exit: btr_search_drop_page_hash_index(block); /* Remove the page from the level list */ - btr_level_list_remove(space, zip_size, page, mtr); + btr_level_list_remove(space, zip_size, page, index, mtr); btr_node_ptr_delete(index, block, mtr); lock_update_merge_left(merge_block, orig_pred, block); @@ -3315,7 +3343,7 @@ err_exit: #endif /* UNIV_BTR_DEBUG */ /* Remove the page from the level list */ - btr_level_list_remove(space, zip_size, page, mtr); + btr_level_list_remove(space, zip_size, page, index, mtr); /* Replace the address of the old child node (= page) with the address of the merge page to the right */ @@ -3498,7 +3526,7 @@ btr_discard_page( if (left_page_no != FIL_NULL) { merge_block = btr_block_get(space, zip_size, left_page_no, - RW_X_LATCH, mtr); + RW_X_LATCH, index, mtr); merge_page = buf_block_get_frame(merge_block); #ifdef UNIV_BTR_DEBUG ut_a(btr_page_get_next(merge_page, mtr) @@ -3506,7 +3534,7 @@ btr_discard_page( #endif /* UNIV_BTR_DEBUG */ } else if (right_page_no != FIL_NULL) { merge_block = btr_block_get(space, zip_size, right_page_no, - RW_X_LATCH, mtr); + RW_X_LATCH, index, mtr); merge_page = buf_block_get_frame(merge_block); #ifdef UNIV_BTR_DEBUG ut_a(btr_page_get_prev(merge_page, mtr) @@ -3541,7 +3569,7 @@ btr_discard_page( btr_node_ptr_delete(index, block, mtr); /* Remove the page from the level list */ - btr_level_list_remove(space, zip_size, page, mtr); + btr_level_list_remove(space, zip_size, page, index, mtr); #ifdef UNIV_ZIP_DEBUG { page_zip_des_t* merge_page_zip @@ -4059,7 +4087,7 @@ loop: if (right_page_no != FIL_NULL) { const rec_t* right_rec; right_block = btr_block_get(space, zip_size, right_page_no, - RW_X_LATCH, &mtr); + RW_X_LATCH, index, &mtr); right_page = buf_block_get_frame(right_block); if (UNIV_UNLIKELY(btr_page_get_prev(right_page, &mtr) != page_get_page_no(page))) { @@ -4285,7 +4313,7 @@ node_ptr_fails: mtr_start(&mtr); block = btr_block_get(space, zip_size, right_page_no, - RW_X_LATCH, &mtr); + RW_X_LATCH, index, &mtr); page = buf_block_get_frame(block); goto loop; diff --git a/storage/innobase/btr/btr0cur.c b/storage/innobase/btr/btr0cur.c index 69dd1e428e1..f63ca20ef24 100644 --- a/storage/innobase/btr/btr0cur.c +++ b/storage/innobase/btr/btr0cur.c @@ -249,7 +249,8 @@ btr_cur_latch_leaves( case BTR_SEARCH_LEAF: case BTR_MODIFY_LEAF: mode = latch_mode == BTR_SEARCH_LEAF ? RW_S_LATCH : RW_X_LATCH; - get_block = btr_block_get(space, zip_size, page_no, mode, mtr); + get_block = btr_block_get( + space, zip_size, page_no, mode, cursor->index, mtr); #ifdef UNIV_BTR_DEBUG ut_a(page_is_comp(get_block->frame) == page_is_comp(page)); #endif /* UNIV_BTR_DEBUG */ @@ -260,9 +261,9 @@ btr_cur_latch_leaves( left_page_no = btr_page_get_prev(page, mtr); if (left_page_no != FIL_NULL) { - get_block = btr_block_get(space, zip_size, - left_page_no, - RW_X_LATCH, mtr); + get_block = btr_block_get( + space, zip_size, left_page_no, + RW_X_LATCH, cursor->index, mtr); #ifdef UNIV_BTR_DEBUG ut_a(page_is_comp(get_block->frame) == page_is_comp(page)); @@ -272,8 +273,9 @@ btr_cur_latch_leaves( get_block->check_index_page_at_flush = TRUE; } - get_block = btr_block_get(space, zip_size, page_no, - RW_X_LATCH, mtr); + get_block = btr_block_get( + space, zip_size, page_no, + RW_X_LATCH, cursor->index, mtr); #ifdef UNIV_BTR_DEBUG ut_a(page_is_comp(get_block->frame) == page_is_comp(page)); #endif /* UNIV_BTR_DEBUG */ @@ -282,9 +284,9 @@ btr_cur_latch_leaves( right_page_no = btr_page_get_next(page, mtr); if (right_page_no != FIL_NULL) { - get_block = btr_block_get(space, zip_size, - right_page_no, - RW_X_LATCH, mtr); + get_block = btr_block_get( + space, zip_size, right_page_no, + RW_X_LATCH, cursor->index, mtr); #ifdef UNIV_BTR_DEBUG ut_a(page_is_comp(get_block->frame) == page_is_comp(page)); @@ -303,8 +305,9 @@ btr_cur_latch_leaves( left_page_no = btr_page_get_prev(page, mtr); if (left_page_no != FIL_NULL) { - get_block = btr_block_get(space, zip_size, - left_page_no, mode, mtr); + get_block = btr_block_get( + space, zip_size, + left_page_no, mode, cursor->index, mtr); cursor->left_block = get_block; #ifdef UNIV_BTR_DEBUG ut_a(page_is_comp(get_block->frame) @@ -315,7 +318,8 @@ btr_cur_latch_leaves( get_block->check_index_page_at_flush = TRUE; } - get_block = btr_block_get(space, zip_size, page_no, mode, mtr); + get_block = btr_block_get( + space, zip_size, page_no, mode, cursor->index, mtr); #ifdef UNIV_BTR_DEBUG ut_a(page_is_comp(get_block->frame) == page_is_comp(page)); #endif /* UNIV_BTR_DEBUG */ @@ -669,7 +673,9 @@ retry_page_get: ut_a(!page_zip || page_zip_validate(page_zip, page)); #endif /* UNIV_ZIP_DEBUG */ - buf_block_dbg_add_level(block, SYNC_TREE_NODE); + buf_block_dbg_add_level( + block, dict_index_is_ibuf(index) + ? SYNC_IBUF_TREE_NODE : SYNC_TREE_NODE); } ut_ad(index->id == btr_page_get_index_id(page)); @@ -767,7 +773,7 @@ retry_page_get: if (level != 0) { /* x-latch the page */ page = btr_page_get( - space, zip_size, page_no, RW_X_LATCH, mtr); + space, zip_size, page_no, RW_X_LATCH, index, mtr); ut_a((ibool)!!page_is_comp(page) == dict_table_is_comp(index->table)); @@ -1839,6 +1845,7 @@ btr_cur_update_in_place( roll_ptr_t roll_ptr = 0; trx_t* trx; ulint was_delete_marked; + ibool is_hashed; mem_heap_t* heap = NULL; ulint offsets_[REC_OFFS_NORMAL_SIZE]; ulint* offsets = offsets_; @@ -1880,7 +1887,21 @@ btr_cur_update_in_place( return(err); } - if (block->is_hashed) { + if (!(flags & BTR_KEEP_SYS_FLAG)) { + row_upd_rec_sys_fields(rec, NULL, + index, offsets, trx, roll_ptr); + } + + was_delete_marked = rec_get_deleted_flag( + rec, page_is_comp(buf_block_get_frame(block))); + + is_hashed = block->is_hashed; + + if (is_hashed) { + /* TO DO: Can we skip this if none of the fields + index->search_info->curr_n_fields + are being updated? */ + /* The function row_upd_changes_ord_field_binary works only if the update vector was built for a clustered index, we must NOT call it if index is secondary */ @@ -1896,17 +1917,9 @@ btr_cur_update_in_place( rw_lock_x_lock(&btr_search_latch); } - if (!(flags & BTR_KEEP_SYS_FLAG)) { - row_upd_rec_sys_fields(rec, NULL, - index, offsets, trx, roll_ptr); - } - - was_delete_marked = rec_get_deleted_flag( - rec, page_is_comp(buf_block_get_frame(block))); - row_upd_rec_in_place(rec, index, offsets, update, page_zip); - if (block->is_hashed) { + if (is_hashed) { rw_lock_x_unlock(&btr_search_latch); } @@ -2607,7 +2620,8 @@ btr_cur_parse_del_mark_set_clust_rec( /* We do not need to reserve btr_search_latch, as the page is only being recovered, and there cannot be a hash index to - it. */ + it. Besides, these fields are being updated in place + and the adaptive hash index does not depend on them. */ btr_rec_set_deleted_flag(rec, page_zip, val); @@ -2687,9 +2701,9 @@ btr_cur_del_mark_set_clust_rec( return(err); } - if (block->is_hashed) { - rw_lock_x_lock(&btr_search_latch); - } + /* The btr_search_latch is not needed here, because + the adaptive hash index does not depend on the delete-mark + and the delete-mark is being updated in place. */ page_zip = buf_block_get_page_zip(block); @@ -2703,10 +2717,6 @@ btr_cur_del_mark_set_clust_rec( index, offsets, trx, roll_ptr); } - if (block->is_hashed) { - rw_lock_x_unlock(&btr_search_latch); - } - btr_cur_del_mark_set_clust_rec_log(flags, rec, index, val, trx, roll_ptr, mtr); @@ -2782,7 +2792,8 @@ btr_cur_parse_del_mark_set_sec_rec( /* We do not need to reserve btr_search_latch, as the page is only being recovered, and there cannot be a hash index to - it. */ + it. Besides, the delete-mark flag is being updated in place + and the adaptive hash index does not depend on it. */ btr_rec_set_deleted_flag(rec, page_zip, val); } @@ -2830,16 +2841,11 @@ btr_cur_del_mark_set_sec_rec( ut_ad(!!page_rec_is_comp(rec) == dict_table_is_comp(cursor->index->table)); - if (block->is_hashed) { - rw_lock_x_lock(&btr_search_latch); - } - + /* We do not need to reserve btr_search_latch, as the + delete-mark flag is being updated in place and the adaptive + hash index does not depend on it. */ btr_rec_set_deleted_flag(rec, buf_block_get_page_zip(block), val); - if (block->is_hashed) { - rw_lock_x_unlock(&btr_search_latch); - } - btr_cur_del_mark_set_sec_rec_log(rec, val, mtr); return(DB_SUCCESS); @@ -2860,8 +2866,11 @@ btr_cur_set_deleted_flag_for_ibuf( ibool val, /*!< in: value to set */ mtr_t* mtr) /*!< in: mtr */ { - /* We do not need to reserve btr_search_latch, as the page has just - been read to the buffer pool and there cannot be a hash index to it. */ + /* We do not need to reserve btr_search_latch, as the page + has just been read to the buffer pool and there cannot be + a hash index to it. Besides, the delete-mark flag is being + updated in place and the adaptive hash index does not depend + on it. */ btr_rec_set_deleted_flag(rec, page_zip, val); @@ -3515,7 +3524,6 @@ static void btr_record_not_null_field_in_rec( /*=============================*/ - rec_t* rec, /*!< in: physical record */ ulint n_unique, /*!< in: dict_index_get_n_unique(index), number of columns uniquely determine an index entry */ @@ -3535,9 +3543,8 @@ btr_record_not_null_field_in_rec( for (i = 0; i < n_unique; i++) { ulint rec_len; - byte* field; - field = rec_get_nth_field(rec, offsets, i, &rec_len); + rec_get_nth_field_offs(offsets, i, &rec_len); if (rec_len != UNIV_SQL_NULL) { n_not_null[i]++; @@ -3652,7 +3659,7 @@ btr_estimate_number_of_different_key_vals( if (n_not_null) { btr_record_not_null_field_in_rec( - rec, n_cols, offsets_rec, n_not_null); + n_cols, offsets_rec, n_not_null); } } @@ -3687,7 +3694,7 @@ btr_estimate_number_of_different_key_vals( if (n_not_null) { btr_record_not_null_field_in_rec( - next_rec, n_cols, offsets_next_rec, + n_cols, offsets_next_rec, n_not_null); } @@ -4095,7 +4102,7 @@ btr_blob_free( && buf_block_get_space(block) == space && buf_block_get_page_no(block) == page_no) { - if (buf_LRU_free_block(&block->page, all) != BUF_LRU_FREED + if (!buf_LRU_free_block(&block->page, all) && all && block->page.zip.data) { /* Attempt to deallocate the uncompressed page if the whole block cannot be deallocted. */ diff --git a/storage/innobase/btr/btr0pcur.c b/storage/innobase/btr/btr0pcur.c index 056896c7927..cbb0d21a7ed 100644 --- a/storage/innobase/btr/btr0pcur.c +++ b/storage/innobase/btr/btr0pcur.c @@ -1,6 +1,6 @@ /***************************************************************************** -Copyright (c) 1996, 2010, Innobase Oy. All Rights Reserved. +Copyright (c) 1996, 2011, Oracle and/or its affiliates. All Rights Reserved. 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 the Free Software @@ -266,8 +266,10 @@ btr_pcur_restore_position_func( file, line, mtr))) { cursor->pos_state = BTR_PCUR_IS_POSITIONED; - buf_block_dbg_add_level(btr_pcur_get_block(cursor), - SYNC_TREE_NODE); + buf_block_dbg_add_level( + btr_pcur_get_block(cursor), + dict_index_is_ibuf(index) + ? SYNC_IBUF_TREE_NODE : SYNC_TREE_NODE); if (cursor->rel_pos == BTR_PCUR_ON) { #ifdef UNIV_DEBUG @@ -356,33 +358,6 @@ btr_pcur_restore_position_func( return(FALSE); } -/**************************************************************//** -If the latch mode of the cursor is BTR_LEAF_SEARCH or BTR_LEAF_MODIFY, -releases the page latch and bufferfix reserved by the cursor. -NOTE! In the case of BTR_LEAF_MODIFY, there should not exist changes -made by the current mini-transaction to the data protected by the -cursor latch, as then the latch must not be released until mtr_commit. */ -UNIV_INTERN -void -btr_pcur_release_leaf( -/*==================*/ - btr_pcur_t* cursor, /*!< in: persistent cursor */ - mtr_t* mtr) /*!< in: mtr */ -{ - buf_block_t* block; - - ut_a(cursor->pos_state == BTR_PCUR_IS_POSITIONED); - ut_ad(cursor->latch_mode != BTR_NO_LATCHES); - - block = btr_pcur_get_block(cursor); - - btr_leaf_page_release(block, cursor->latch_mode, mtr); - - cursor->latch_mode = BTR_NO_LATCHES; - - cursor->pos_state = BTR_PCUR_WAS_POSITIONED; -} - /*********************************************************//** Moves the persistent cursor to the first record on the next page. Releases the latch on the current page, and bufferunfixes it. Note that there must not be @@ -417,7 +392,8 @@ btr_pcur_move_to_next_page( ut_ad(next_page_no != FIL_NULL); next_block = btr_block_get(space, zip_size, next_page_no, - cursor->latch_mode, mtr); + cursor->latch_mode, + btr_pcur_get_btr_cur(cursor)->index, mtr); next_page = buf_block_get_frame(next_block); #ifdef UNIV_BTR_DEBUG ut_a(page_is_comp(next_page) == page_is_comp(page)); diff --git a/storage/innobase/btr/btr0sea.c b/storage/innobase/btr/btr0sea.c index 93573a300e4..7070420425c 100644 --- a/storage/innobase/btr/btr0sea.c +++ b/storage/innobase/btr/btr0sea.c @@ -1,6 +1,6 @@ /***************************************************************************** -Copyright (c) 1996, 2009, Innobase Oy. All Rights Reserved. +Copyright (c) 1996, 2011, Oracle and/or its affiliates. All Rights Reserved. Copyright (c) 2008, Google Inc. Portions of this file contain modifications contributed and copyrighted by @@ -845,6 +845,7 @@ btr_search_guess_on_hash( btr_pcur_t pcur; #endif ut_ad(index && info && tuple && cursor && mtr); + ut_ad(!dict_index_is_ibuf(index)); ut_ad((latch_mode == BTR_SEARCH_LEAF) || (latch_mode == BTR_MODIFY_LEAF)); diff --git a/storage/innobase/buf/buf0buddy.c b/storage/innobase/buf/buf0buddy.c index 75ba832c7e5..30c31dd71a0 100644 --- a/storage/innobase/buf/buf0buddy.c +++ b/storage/innobase/buf/buf0buddy.c @@ -1,6 +1,6 @@ /***************************************************************************** -Copyright (c) 2006, 2010, Innobase Oy. All Rights Reserved. +Copyright (c) 2006, 2011, Oracle and/or its affiliates. All Rights Reserved. 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 the Free Software @@ -56,6 +56,14 @@ buf_buddy_get( } } +/** Validate a given zip_free list. */ +#define BUF_BUDDY_LIST_VALIDATE(b, i) \ + UT_LIST_VALIDATE(list, buf_page_t, \ + b->zip_free[i], \ + ut_ad(buf_page_get_state( \ + ut_list_node_313) \ + == BUF_BLOCK_ZIP_FREE)) + /**********************************************************************//** Add a block to the head of the appropriate buddy free list. */ UNIV_INLINE @@ -67,21 +75,10 @@ buf_buddy_add_to_free( ulint i) /*!< in: index of buf_pool->zip_free[] */ { -#ifdef UNIV_DEBUG_VALGRIND - buf_page_t* b = UT_LIST_GET_FIRST(buf_pool->zip_free[i]); - - if (b) UNIV_MEM_VALID(b, BUF_BUDDY_LOW << i); -#endif /* UNIV_DEBUG_VALGRIND */ - ut_ad(buf_pool_mutex_own(buf_pool)); ut_ad(buf_page_get_state(bpage) == BUF_BLOCK_ZIP_FREE); ut_ad(buf_pool->zip_free[i].start != bpage); UT_LIST_ADD_FIRST(list, buf_pool->zip_free[i], bpage); - -#ifdef UNIV_DEBUG_VALGRIND - if (b) UNIV_MEM_FREE(b, BUF_BUDDY_LOW << i); - UNIV_MEM_ASSERT_AND_FREE(bpage, BUF_BUDDY_LOW << i); -#endif /* UNIV_DEBUG_VALGRIND */ } /**********************************************************************//** @@ -95,25 +92,17 @@ buf_buddy_remove_from_free( ulint i) /*!< in: index of buf_pool->zip_free[] */ { -#ifdef UNIV_DEBUG_VALGRIND +#ifdef UNIV_DEBUG buf_page_t* prev = UT_LIST_GET_PREV(list, bpage); buf_page_t* next = UT_LIST_GET_NEXT(list, bpage); - if (prev) UNIV_MEM_VALID(prev, BUF_BUDDY_LOW << i); - if (next) UNIV_MEM_VALID(next, BUF_BUDDY_LOW << i); - ut_ad(!prev || buf_page_get_state(prev) == BUF_BLOCK_ZIP_FREE); ut_ad(!next || buf_page_get_state(next) == BUF_BLOCK_ZIP_FREE); -#endif /* UNIV_DEBUG_VALGRIND */ +#endif /* UNIV_DEBUG */ ut_ad(buf_pool_mutex_own(buf_pool)); ut_ad(buf_page_get_state(bpage) == BUF_BLOCK_ZIP_FREE); UT_LIST_REMOVE(list, buf_pool->zip_free[i], bpage); - -#ifdef UNIV_DEBUG_VALGRIND - if (prev) UNIV_MEM_FREE(prev, BUF_BUDDY_LOW << i); - if (next) UNIV_MEM_FREE(next, BUF_BUDDY_LOW << i); -#endif /* UNIV_DEBUG_VALGRIND */ } /**********************************************************************//** @@ -130,17 +119,13 @@ buf_buddy_alloc_zip( ut_ad(buf_pool_mutex_own(buf_pool)); ut_a(i < BUF_BUDDY_SIZES); + ut_a(i >= buf_buddy_get_slot(PAGE_ZIP_MIN_SIZE)); + + ut_d(BUF_BUDDY_LIST_VALIDATE(buf_pool, i)); -#ifndef UNIV_DEBUG_VALGRIND - /* Valgrind would complain about accessing free memory. */ - ut_d(UT_LIST_VALIDATE(list, buf_page_t, buf_pool->zip_free[i], - ut_ad(buf_page_get_state(ut_list_node_313) - == BUF_BLOCK_ZIP_FREE))); -#endif /* !UNIV_DEBUG_VALGRIND */ bpage = UT_LIST_GET_FIRST(buf_pool->zip_free[i]); if (bpage) { - UNIV_MEM_VALID(bpage, BUF_BUDDY_LOW << i); ut_a(buf_page_get_state(bpage) == BUF_BLOCK_ZIP_FREE); buf_buddy_remove_from_free(buf_pool, bpage, i); @@ -159,13 +144,10 @@ buf_buddy_alloc_zip( } } -#ifdef UNIV_DEBUG if (bpage) { - memset(bpage, ~i, BUF_BUDDY_LOW << i); + ut_d(memset(bpage, ~i, BUF_BUDDY_LOW << i)); + UNIV_MEM_ALLOC(bpage, BUF_BUDDY_SIZES << i); } -#endif /* UNIV_DEBUG */ - - UNIV_MEM_ALLOC(bpage, BUF_BUDDY_SIZES << i); return(bpage); } @@ -253,6 +235,7 @@ buf_buddy_alloc_from( { ulint offs = BUF_BUDDY_LOW << j; ut_ad(j <= BUF_BUDDY_SIZES); + ut_ad(i >= buf_buddy_get_slot(PAGE_ZIP_MIN_SIZE)); ut_ad(j >= i); ut_ad(!ut_align_offset(buf, offs)); @@ -266,13 +249,7 @@ buf_buddy_alloc_from( bpage = (buf_page_t*) ((byte*) buf + offs); ut_d(memset(bpage, j, BUF_BUDDY_LOW << j)); bpage->state = BUF_BLOCK_ZIP_FREE; -#ifndef UNIV_DEBUG_VALGRIND - /* Valgrind would complain about accessing free memory. */ - ut_d(UT_LIST_VALIDATE(list, buf_page_t, buf_pool->zip_free[i], - ut_ad(buf_page_get_state( - ut_list_node_313) - == BUF_BLOCK_ZIP_FREE))); -#endif /* !UNIV_DEBUG_VALGRIND */ + ut_d(BUF_BUDDY_LIST_VALIDATE(buf_pool, i)); buf_buddy_add_to_free(buf_pool, bpage, j); } @@ -282,26 +259,27 @@ buf_buddy_alloc_from( /**********************************************************************//** Allocate a block. The thread calling this function must hold buf_pool->mutex and must not hold buf_pool->zip_mutex or any block->mutex. -The buf_pool->mutex may only be released and reacquired if lru != NULL. -@return allocated block, possibly NULL if lru==NULL */ +The buf_pool_mutex may be released and reacquired. +@return allocated block, never NULL */ UNIV_INTERN void* buf_buddy_alloc_low( /*================*/ - buf_pool_t* buf_pool, /*!< in: buffer pool instance */ + buf_pool_t* buf_pool, /*!< in/out: buffer pool instance */ ulint i, /*!< in: index of buf_pool->zip_free[], or BUF_BUDDY_SIZES */ ibool* lru) /*!< in: pointer to a variable that will be assigned TRUE if storage was allocated from the LRU list and buf_pool->mutex was temporarily - released, or NULL if the LRU list - should not be used */ + released */ { buf_block_t* block; + ut_ad(lru); ut_ad(buf_pool_mutex_own(buf_pool)); ut_ad(!mutex_own(&buf_pool->zip_mutex)); + ut_ad(i >= buf_buddy_get_slot(PAGE_ZIP_MIN_SIZE)); if (i < BUF_BUDDY_SIZES) { /* Try to allocate from the buddy system. */ @@ -320,11 +298,6 @@ buf_buddy_alloc_low( goto alloc_big; } - if (!lru) { - - return(NULL); - } - /* Try replacing an uncompressed page in the buffer pool. */ buf_pool_mutex_exit(buf_pool); block = buf_LRU_get_free_block(buf_pool); @@ -343,63 +316,6 @@ func_exit: } /**********************************************************************//** -Try to relocate the control block of a compressed page. -@return TRUE if relocated */ -static -ibool -buf_buddy_relocate_block( -/*=====================*/ - buf_page_t* bpage, /*!< in: block to relocate */ - buf_page_t* dpage) /*!< in: free block to relocate to */ -{ - buf_page_t* b; - buf_pool_t* buf_pool = buf_pool_from_bpage(bpage); - - ut_ad(buf_pool_mutex_own(buf_pool)); - - switch (buf_page_get_state(bpage)) { - case BUF_BLOCK_ZIP_FREE: - case BUF_BLOCK_NOT_USED: - case BUF_BLOCK_READY_FOR_USE: - case BUF_BLOCK_FILE_PAGE: - case BUF_BLOCK_MEMORY: - case BUF_BLOCK_REMOVE_HASH: - ut_error; - case BUF_BLOCK_ZIP_DIRTY: - /* Cannot relocate dirty pages. */ - return(FALSE); - - case BUF_BLOCK_ZIP_PAGE: - break; - } - - mutex_enter(&buf_pool->zip_mutex); - - if (!buf_page_can_relocate(bpage)) { - mutex_exit(&buf_pool->zip_mutex); - return(FALSE); - } - - buf_relocate(bpage, dpage); - ut_d(bpage->state = BUF_BLOCK_ZIP_FREE); - - /* relocate buf_pool->zip_clean */ - b = UT_LIST_GET_PREV(list, dpage); - UT_LIST_REMOVE(list, buf_pool->zip_clean, dpage); - - if (b) { - UT_LIST_INSERT_AFTER(list, buf_pool->zip_clean, b, dpage); - } else { - UT_LIST_ADD_FIRST(list, buf_pool->zip_clean, dpage); - } - - UNIV_MEM_INVALID(bpage, sizeof *bpage); - - mutex_exit(&buf_pool->zip_mutex); - return(TRUE); -} - -/**********************************************************************//** Try to relocate a block. @return TRUE if relocated */ static @@ -414,109 +330,89 @@ buf_buddy_relocate( { buf_page_t* bpage; const ulint size = BUF_BUDDY_LOW << i; - ullint usec = ut_time_us(NULL); + mutex_t* mutex; + ulint space; + ulint page_no; ut_ad(buf_pool_mutex_own(buf_pool)); ut_ad(!mutex_own(&buf_pool->zip_mutex)); ut_ad(!ut_align_offset(src, size)); ut_ad(!ut_align_offset(dst, size)); + ut_ad(i >= buf_buddy_get_slot(PAGE_ZIP_MIN_SIZE)); UNIV_MEM_ASSERT_W(dst, size); /* We assume that all memory from buf_buddy_alloc() - is used for either compressed pages or buf_page_t - objects covering compressed pages. */ + is used for compressed page frames. */ /* We look inside the allocated objects returned by - buf_buddy_alloc() and assume that anything of - PAGE_ZIP_MIN_SIZE or larger is a compressed page that contains - a valid space_id and page_no in the page header. Should the - fields be invalid, we will be unable to relocate the block. - We also assume that anything that fits sizeof(buf_page_t) - actually is a properly initialized buf_page_t object. */ - - if (size >= PAGE_ZIP_MIN_SIZE) { - /* This is a compressed page. */ - mutex_t* mutex; - - /* The src block may be split into smaller blocks, - some of which may be free. Thus, the - mach_read_from_4() calls below may attempt to read - from free memory. The memory is "owned" by the buddy - allocator (and it has been allocated from the buffer - pool), so there is nothing wrong about this. The - mach_read_from_4() calls here will only trigger bogus - Valgrind memcheck warnings in UNIV_DEBUG_VALGRIND builds. */ - ulint space = mach_read_from_4( - (const byte*) src + FIL_PAGE_ARCH_LOG_NO_OR_SPACE_ID); - ulint page_no = mach_read_from_4( - (const byte*) src + FIL_PAGE_OFFSET); - /* Suppress Valgrind warnings about conditional jump - on uninitialized value. */ - UNIV_MEM_VALID(&space, sizeof space); - UNIV_MEM_VALID(&page_no, sizeof page_no); - bpage = buf_page_hash_get(buf_pool, space, page_no); - - if (!bpage || bpage->zip.data != src) { - /* The block has probably been freshly - allocated by buf_LRU_get_free_block() but not - added to buf_pool->page_hash yet. Obviously, - it cannot be relocated. */ - - return(FALSE); - } + buf_buddy_alloc() and assume that each block is a compressed + page that contains a valid space_id and page_no in the page + header. Should the fields be invalid, we will be unable to + relocate the block. */ + + /* The src block may be split into smaller blocks, + some of which may be free. Thus, the + mach_read_from_4() calls below may attempt to read + from free memory. The memory is "owned" by the buddy + allocator (and it has been allocated from the buffer + pool), so there is nothing wrong about this. The + mach_read_from_4() calls here will only trigger bogus + Valgrind memcheck warnings in UNIV_DEBUG_VALGRIND builds. */ + space = mach_read_from_4((const byte *) src + + FIL_PAGE_ARCH_LOG_NO_OR_SPACE_ID); + page_no = mach_read_from_4((const byte *) src + + FIL_PAGE_OFFSET); + /* Suppress Valgrind warnings about conditional jump + on uninitialized value. */ + UNIV_MEM_VALID(&space, sizeof space); + UNIV_MEM_VALID(&page_no, sizeof page_no); + bpage = buf_page_hash_get(buf_pool, space, page_no); + + if (!bpage || bpage->zip.data != src) { + /* The block has probably been freshly + allocated by buf_LRU_get_free_block() but not + added to buf_pool->page_hash yet. Obviously, + it cannot be relocated. */ - ut_ad(!buf_pool_watch_is_sentinel(buf_pool, bpage)); + return(FALSE); + } - if (page_zip_get_size(&bpage->zip) != size) { - /* The block is of different size. We would - have to relocate all blocks covered by src. - For the sake of simplicity, give up. */ - ut_ad(page_zip_get_size(&bpage->zip) < size); + if (page_zip_get_size(&bpage->zip) != size) { + /* The block is of different size. We would + have to relocate all blocks covered by src. + For the sake of simplicity, give up. */ + ut_ad(page_zip_get_size(&bpage->zip) < size); - return(FALSE); - } + return(FALSE); + } - /* The block must have been allocated, but it may - contain uninitialized data. */ - UNIV_MEM_ASSERT_W(src, size); - - mutex = buf_page_get_mutex(bpage); - - mutex_enter(mutex); - - if (buf_page_can_relocate(bpage)) { - /* Relocate the compressed page. */ - ut_a(bpage->zip.data == src); - memcpy(dst, src, size); - bpage->zip.data = dst; - mutex_exit(mutex); -success: - UNIV_MEM_INVALID(src, size); - { - buf_buddy_stat_t* buddy_stat - = &buf_pool->buddy_stat[i]; - buddy_stat->relocated++; - buddy_stat->relocated_usec - += ut_time_us(NULL) - usec; - } - return(TRUE); - } + /* The block must have been allocated, but it may + contain uninitialized data. */ + UNIV_MEM_ASSERT_W(src, size); - mutex_exit(mutex); - } else if (i == buf_buddy_get_slot(sizeof(buf_page_t))) { - /* This must be a buf_page_t object. */ -#if UNIV_WORD_SIZE == 4 - /* On 32-bit systems, there is no padding in - buf_page_t. On other systems, Valgrind could complain - about uninitialized pad bytes. */ - UNIV_MEM_ASSERT_RW(src, size); -#endif - if (buf_buddy_relocate_block(src, dst)) { + mutex = buf_page_get_mutex(bpage); + + mutex_enter(mutex); - goto success; + if (buf_page_can_relocate(bpage)) { + /* Relocate the compressed page. */ + ullint usec = ut_time_us(NULL); + ut_a(bpage->zip.data == src); + memcpy(dst, src, size); + bpage->zip.data = dst; + mutex_exit(mutex); + UNIV_MEM_INVALID(src, size); + { + buf_buddy_stat_t* buddy_stat + = &buf_pool->buddy_stat[i]; + buddy_stat->relocated++; + buddy_stat->relocated_usec + += ut_time_us(NULL) - usec; } + return(TRUE); } + mutex_exit(mutex); return(FALSE); } @@ -538,12 +434,13 @@ buf_buddy_free_low( ut_ad(buf_pool_mutex_own(buf_pool)); ut_ad(!mutex_own(&buf_pool->zip_mutex)); ut_ad(i <= BUF_BUDDY_SIZES); + ut_ad(i >= buf_buddy_get_slot(PAGE_ZIP_MIN_SIZE)); ut_ad(buf_pool->buddy_stat[i].used > 0); buf_pool->buddy_stat[i].used--; recombine: UNIV_MEM_ASSERT_AND_ALLOC(buf, BUF_BUDDY_LOW << i); - ut_d(((buf_page_t*) buf)->state = BUF_BLOCK_ZIP_FREE); + ((buf_page_t*) buf)->state = BUF_BLOCK_ZIP_FREE; if (i == BUF_BUDDY_SIZES) { buf_buddy_block_free(buf_pool, buf); @@ -554,32 +451,36 @@ recombine: ut_ad(buf == ut_align_down(buf, BUF_BUDDY_LOW << i)); ut_ad(!buf_pool_contains_zip(buf_pool, buf)); - /* Try to combine adjacent blocks. */ + /* Do not recombine blocks if there are few free blocks. + We may waste up to 15360*max_len bytes to free blocks + (1024 + 2048 + 4096 + 8192 = 15360) */ + if (UT_LIST_GET_LEN(buf_pool->zip_free[i]) < 16) { + goto func_exit; + } + /* Try to combine adjacent blocks. */ buddy = (buf_page_t*) buf_buddy_get(((byte*) buf), BUF_BUDDY_LOW << i); #ifndef UNIV_DEBUG_VALGRIND - /* Valgrind would complain about accessing free memory. */ + /* When Valgrind instrumentation is not enabled, we can read + buddy->state to quickly determine that a block is not free. + When the block is not free, buddy->state belongs to a compressed + page frame that may be flagged uninitialized in our Valgrind + instrumentation. */ if (buddy->state != BUF_BLOCK_ZIP_FREE) { goto buddy_nonfree; } - - /* The field buddy->state can only be trusted for free blocks. - If buddy->state == BUF_BLOCK_ZIP_FREE, the block is free if - it is in the free list. */ #endif /* !UNIV_DEBUG_VALGRIND */ for (bpage = UT_LIST_GET_FIRST(buf_pool->zip_free[i]); bpage; ) { - UNIV_MEM_VALID(bpage, BUF_BUDDY_LOW << i); ut_ad(buf_page_get_state(bpage) == BUF_BLOCK_ZIP_FREE); if (bpage == buddy) { -buddy_free: /* The buddy is free: recombine */ buf_buddy_remove_from_free(buf_pool, bpage, i); -buddy_free2: +buddy_is_free: ut_ad(buf_page_get_state(buddy) == BUF_BLOCK_ZIP_FREE); ut_ad(!buf_pool_contains_zip(buf_pool, buddy)); i++; @@ -589,122 +490,42 @@ buddy_free2: } ut_a(bpage != buf); - - { - buf_page_t* next = UT_LIST_GET_NEXT(list, bpage); - UNIV_MEM_ASSERT_AND_FREE(bpage, BUF_BUDDY_LOW << i); - bpage = next; - } + UNIV_MEM_ASSERT_W(bpage, BUF_BUDDY_LOW << i); + bpage = UT_LIST_GET_NEXT(list, bpage); } #ifndef UNIV_DEBUG_VALGRIND buddy_nonfree: - /* Valgrind would complain about accessing free memory. */ - ut_d(UT_LIST_VALIDATE(list, buf_page_t, buf_pool->zip_free[i], - ut_ad(buf_page_get_state(ut_list_node_313) - == BUF_BLOCK_ZIP_FREE))); -#endif /* UNIV_DEBUG_VALGRIND */ +#endif /* !UNIV_DEBUG_VALGRIND */ + + ut_d(BUF_BUDDY_LIST_VALIDATE(buf_pool, i)); /* The buddy is not free. Is there a free block of this size? */ bpage = UT_LIST_GET_FIRST(buf_pool->zip_free[i]); if (bpage) { + /* Remove the block from the free list, because a successful buf_buddy_relocate() will overwrite bpage->list. */ - - UNIV_MEM_VALID(bpage, BUF_BUDDY_LOW << i); buf_buddy_remove_from_free(buf_pool, bpage, i); /* Try to relocate the buddy of buf to the free block. */ if (buf_buddy_relocate(buf_pool, buddy, bpage, i)) { - ut_d(buddy->state = BUF_BLOCK_ZIP_FREE); - goto buddy_free2; + buddy->state = BUF_BLOCK_ZIP_FREE; + goto buddy_is_free; } buf_buddy_add_to_free(buf_pool, bpage, i); - - /* Try to relocate the buddy of the free block to buf. */ - buddy = (buf_page_t*) buf_buddy_get(((byte*) bpage), - BUF_BUDDY_LOW << i); - -#ifndef UNIV_DEBUG_VALGRIND - /* Valgrind would complain about accessing free memory. */ - - /* The buddy must not be (completely) free, because we - always recombine adjacent free blocks. - - (Parts of the buddy can be free in - buf_pool->zip_free[j] with j < i.) */ - ut_d(UT_LIST_VALIDATE(list, buf_page_t, buf_pool->zip_free[i], - ut_ad(buf_page_get_state( - ut_list_node_313) - == BUF_BLOCK_ZIP_FREE - && ut_list_node_313 != buddy))); -#endif /* !UNIV_DEBUG_VALGRIND */ - - if (buf_buddy_relocate(buf_pool, buddy, buf, i)) { - - buf = bpage; - UNIV_MEM_VALID(bpage, BUF_BUDDY_LOW << i); - ut_d(buddy->state = BUF_BLOCK_ZIP_FREE); - goto buddy_free; - } } +func_exit: /* Free the block to the buddy list. */ bpage = buf; -#ifdef UNIV_DEBUG - if (i < buf_buddy_get_slot(PAGE_ZIP_MIN_SIZE)) { - /* This area has most likely been allocated for at - least one compressed-only block descriptor. Check - that there are no live objects in the area. This is - not a complete check: it may yield false positives as - well as false negatives. Also, due to buddy blocks - being recombined, it is possible (although unlikely) - that this branch is never reached. */ - - char* c; - -# ifndef UNIV_DEBUG_VALGRIND - /* Valgrind would complain about accessing - uninitialized memory. Besides, Valgrind performs a - more exhaustive check, at every memory access. */ - const buf_page_t* b = buf; - const buf_page_t* const b_end = (buf_page_t*) - ((char*) b + (BUF_BUDDY_LOW << i)); - - for (; b < b_end; b++) { - /* Avoid false positives (and cause false - negatives) by checking for b->space < 1000. */ - - if ((b->state == BUF_BLOCK_ZIP_PAGE - || b->state == BUF_BLOCK_ZIP_DIRTY) - && b->space > 0 && b->space < 1000) { - fprintf(stderr, - "buddy dirty %p %u (%u,%u) %p,%lu\n", - (void*) b, - b->state, b->space, b->offset, - buf, i); - } - } -# endif /* !UNIV_DEBUG_VALGRIND */ - - /* Scramble the block. This should make any pointers - invalid and trigger a segmentation violation. Because - the scrambling can be reversed, it may be possible to - track down the object pointing to the freed data by - dereferencing the unscrambled bpage->LRU or - bpage->list pointers. */ - for (c = (char*) buf + (BUF_BUDDY_LOW << i); - c-- > (char*) buf; ) { - *c = ~*c ^ i; - } - } else { - /* Fill large blocks with a constant pattern. */ - memset(bpage, i, BUF_BUDDY_LOW << i); - } -#endif /* UNIV_DEBUG */ + + /* Fill large blocks with a constant pattern. */ + ut_d(memset(bpage, i, BUF_BUDDY_LOW << i)); + UNIV_MEM_INVALID(bpage, BUF_BUDDY_LOW << i); bpage->state = BUF_BLOCK_ZIP_FREE; buf_buddy_add_to_free(buf_pool, bpage, i); } diff --git a/storage/innobase/buf/buf0buf.c b/storage/innobase/buf/buf0buf.c index 52358c52853..33b4cd40215 100644 --- a/storage/innobase/buf/buf0buf.c +++ b/storage/innobase/buf/buf0buf.c @@ -1,6 +1,6 @@ /***************************************************************************** -Copyright (c) 1995, 2010, Innobase Oy. All Rights Reserved. +Copyright (c) 1995, 2011, Oracle and/or its affiliates. All Rights Reserved. Copyright (c) 2008, Google Inc. Portions of this file contain modifications contributed and copyrighted by @@ -400,6 +400,7 @@ buf_get_total_stat( tot_stat->n_pages_read += buf_stat->n_pages_read; tot_stat->n_pages_written += buf_stat->n_pages_written; tot_stat->n_pages_created += buf_stat->n_pages_created; + tot_stat->n_ra_pages_read_rnd += buf_stat->n_ra_pages_read_rnd; tot_stat->n_ra_pages_read += buf_stat->n_ra_pages_read; tot_stat->n_ra_pages_evicted += buf_stat->n_ra_pages_evicted; tot_stat->n_pages_made_young += buf_stat->n_pages_made_young; @@ -1099,70 +1100,6 @@ buf_chunk_not_freed( return(NULL); } -/*********************************************************************//** -Checks that all blocks in the buffer chunk are in BUF_BLOCK_NOT_USED state. -@return TRUE if all freed */ -static -ibool -buf_chunk_all_free( -/*===============*/ - const buf_chunk_t* chunk) /*!< in: chunk being checked */ -{ - const buf_block_t* block; - ulint i; - - block = chunk->blocks; - - for (i = chunk->size; i--; block++) { - - if (buf_block_get_state(block) != BUF_BLOCK_NOT_USED) { - - return(FALSE); - } - } - - return(TRUE); -} - -/********************************************************************//** -Frees a chunk of buffer frames. */ -static -void -buf_chunk_free( -/*===========*/ - buf_pool_t* buf_pool, /*!< in: buffer pool instance */ - buf_chunk_t* chunk) /*!< out: chunk of buffers */ -{ - buf_block_t* block; - const buf_block_t* block_end; - - ut_ad(buf_pool_mutex_own(buf_pool)); - - block_end = chunk->blocks + chunk->size; - - for (block = chunk->blocks; block < block_end; block++) { - ut_a(buf_block_get_state(block) == BUF_BLOCK_NOT_USED); - ut_a(!block->page.zip.data); - - ut_ad(!block->page.in_LRU_list); - ut_ad(!block->in_unzip_LRU_list); - ut_ad(!block->page.in_flush_list); - /* Remove the block from the free list. */ - ut_ad(block->page.in_free_list); - UT_LIST_REMOVE(list, buf_pool->free, (&block->page)); - - /* Free the latches. */ - mutex_free(&block->mutex); - rw_lock_free(&block->lock); -#ifdef UNIV_SYNC_DEBUG - rw_lock_free(&block->debug_latch); -#endif /* UNIV_SYNC_DEBUG */ - UNIV_MEM_UNDESC(block); - } - - os_mem_free_large(chunk->mem, chunk->mem_size); -} - /********************************************************************//** Set buffer pool size variables after resizing it */ static @@ -1272,8 +1209,6 @@ buf_pool_free_instance( chunk = chunks + buf_pool->n_chunks; while (--chunk >= chunks) { - /* Bypass the checks of buf_chunk_free(), since they - would fail at shutdown. */ os_mem_free_large(chunk->mem, chunk->mem_size); } @@ -1533,281 +1468,6 @@ buf_relocate( } /********************************************************************//** -Shrinks a buffer pool instance. */ -static -void -buf_pool_shrink_instance( -/*=====================*/ - buf_pool_t* buf_pool, /*!< in: buffer pool instance */ - ulint chunk_size) /*!< in: number of pages to remove */ -{ - buf_chunk_t* chunks; - buf_chunk_t* chunk; - ulint max_size; - ulint max_free_size; - buf_chunk_t* max_chunk; - buf_chunk_t* max_free_chunk; - - ut_ad(!buf_pool_mutex_own(buf_pool)); - -try_again: - btr_search_disable(); /* Empty the adaptive hash index again */ - buf_pool_mutex_enter(buf_pool); - -shrink_again: - if (buf_pool->n_chunks <= 1) { - - /* Cannot shrink if there is only one chunk */ - goto func_done; - } - - /* Search for the largest free chunk - not larger than the size difference */ - chunks = buf_pool->chunks; - chunk = chunks + buf_pool->n_chunks; - max_size = max_free_size = 0; - max_chunk = max_free_chunk = NULL; - - while (--chunk >= chunks) { - if (chunk->size <= chunk_size - && chunk->size > max_free_size) { - if (chunk->size > max_size) { - max_size = chunk->size; - max_chunk = chunk; - } - - if (buf_chunk_all_free(chunk)) { - max_free_size = chunk->size; - max_free_chunk = chunk; - } - } - } - - if (!max_free_size) { - - ulint dirty = 0; - ulint nonfree = 0; - buf_block_t* block; - buf_block_t* bend; - - /* Cannot shrink: try again later - (do not assign srv_buf_pool_old_size) */ - if (!max_chunk) { - - goto func_exit; - } - - block = max_chunk->blocks; - bend = block + max_chunk->size; - - /* Move the blocks of chunk to the end of the - LRU list and try to flush them. */ - for (; block < bend; block++) { - switch (buf_block_get_state(block)) { - case BUF_BLOCK_NOT_USED: - continue; - case BUF_BLOCK_FILE_PAGE: - break; - default: - nonfree++; - continue; - } - - mutex_enter(&block->mutex); - /* The following calls will temporarily - release block->mutex and buf_pool->mutex. - Therefore, we have to always retry, - even if !dirty && !nonfree. */ - - if (!buf_flush_ready_for_replace(&block->page)) { - - buf_LRU_make_block_old(&block->page); - dirty++; - } else if (buf_LRU_free_block(&block->page, TRUE) - != BUF_LRU_FREED) { - nonfree++; - } - - mutex_exit(&block->mutex); - } - - buf_pool_mutex_exit(buf_pool); - - /* Request for a flush of the chunk if it helps. - Do not flush if there are non-free blocks, since - flushing will not make the chunk freeable. */ - if (nonfree) { - /* Avoid busy-waiting. */ - os_thread_sleep(100000); - } else if (dirty - && buf_flush_LRU(buf_pool, dirty) - == ULINT_UNDEFINED) { - - buf_flush_wait_batch_end(buf_pool, BUF_FLUSH_LRU); - } - - goto try_again; - } - - max_size = max_free_size; - max_chunk = max_free_chunk; - - buf_pool->old_pool_size = buf_pool->curr_pool_size; - - /* Rewrite buf_pool->chunks. Copy everything but max_chunk. */ - chunks = mem_alloc((buf_pool->n_chunks - 1) * sizeof *chunks); - memcpy(chunks, buf_pool->chunks, - (max_chunk - buf_pool->chunks) * sizeof *chunks); - memcpy(chunks + (max_chunk - buf_pool->chunks), - max_chunk + 1, - buf_pool->chunks + buf_pool->n_chunks - - (max_chunk + 1)); - ut_a(buf_pool->curr_size > max_chunk->size); - buf_pool->curr_size -= max_chunk->size; - buf_pool->curr_pool_size = buf_pool->curr_size * UNIV_PAGE_SIZE; - chunk_size -= max_chunk->size; - buf_chunk_free(buf_pool, max_chunk); - mem_free(buf_pool->chunks); - buf_pool->chunks = chunks; - buf_pool->n_chunks--; - - /* Allow a slack of one megabyte. */ - if (chunk_size > 1048576 / UNIV_PAGE_SIZE) { - - goto shrink_again; - } - goto func_exit; - -func_done: - buf_pool->old_pool_size = buf_pool->curr_pool_size; -func_exit: - buf_pool_mutex_exit(buf_pool); - btr_search_enable(); -} - -/********************************************************************//** -Shrinks the buffer pool. */ -static -void -buf_pool_shrink( -/*============*/ - ulint chunk_size) /*!< in: number of pages to remove */ -{ - ulint i; - - for (i = 0; i < srv_buf_pool_instances; i++) { - buf_pool_t* buf_pool; - ulint instance_chunk_size; - - instance_chunk_size = chunk_size / srv_buf_pool_instances; - buf_pool = buf_pool_from_array(i); - buf_pool_shrink_instance(buf_pool, instance_chunk_size); - } - - buf_pool_set_sizes(); -} - -/********************************************************************//** -Rebuild buf_pool->page_hash for a buffer pool instance. */ -static -void -buf_pool_page_hash_rebuild_instance( -/*================================*/ - buf_pool_t* buf_pool) /*!< in: buffer pool instance */ -{ - ulint i; - buf_page_t* b; - buf_chunk_t* chunk; - ulint n_chunks; - hash_table_t* zip_hash; - hash_table_t* page_hash; - - buf_pool_mutex_enter(buf_pool); - - /* Free, create, and populate the hash table. */ - hash_table_free(buf_pool->page_hash); - buf_pool->page_hash = page_hash = hash_create(2 * buf_pool->curr_size); - zip_hash = hash_create(2 * buf_pool->curr_size); - - HASH_MIGRATE(buf_pool->zip_hash, zip_hash, buf_page_t, hash, - BUF_POOL_ZIP_FOLD_BPAGE); - - hash_table_free(buf_pool->zip_hash); - buf_pool->zip_hash = zip_hash; - - /* Insert the uncompressed file pages to buf_pool->page_hash. */ - - chunk = buf_pool->chunks; - n_chunks = buf_pool->n_chunks; - - for (i = 0; i < n_chunks; i++, chunk++) { - ulint j; - buf_block_t* block = chunk->blocks; - - for (j = 0; j < chunk->size; j++, block++) { - if (buf_block_get_state(block) - == BUF_BLOCK_FILE_PAGE) { - ut_ad(!block->page.in_zip_hash); - ut_ad(block->page.in_page_hash); - - HASH_INSERT(buf_page_t, hash, page_hash, - buf_page_address_fold( - block->page.space, - block->page.offset), - &block->page); - } - } - } - - /* Insert the compressed-only pages to buf_pool->page_hash. - All such blocks are either in buf_pool->zip_clean or - in buf_pool->flush_list. */ - - for (b = UT_LIST_GET_FIRST(buf_pool->zip_clean); b; - b = UT_LIST_GET_NEXT(list, b)) { - ut_a(buf_page_get_state(b) == BUF_BLOCK_ZIP_PAGE); - ut_ad(!b->in_flush_list); - ut_ad(b->in_LRU_list); - ut_ad(b->in_page_hash); - ut_ad(!b->in_zip_hash); - - HASH_INSERT(buf_page_t, hash, page_hash, - buf_page_address_fold(b->space, b->offset), b); - } - - buf_flush_list_mutex_enter(buf_pool); - for (b = UT_LIST_GET_FIRST(buf_pool->flush_list); b; - b = UT_LIST_GET_NEXT(list, b)) { - ut_ad(b->in_flush_list); - ut_ad(b->in_LRU_list); - ut_ad(b->in_page_hash); - ut_ad(!b->in_zip_hash); - - switch (buf_page_get_state(b)) { - case BUF_BLOCK_ZIP_DIRTY: - HASH_INSERT(buf_page_t, hash, page_hash, - buf_page_address_fold(b->space, - b->offset), b); - break; - case BUF_BLOCK_FILE_PAGE: - /* uncompressed page */ - break; - case BUF_BLOCK_ZIP_FREE: - case BUF_BLOCK_ZIP_PAGE: - case BUF_BLOCK_NOT_USED: - case BUF_BLOCK_READY_FOR_USE: - case BUF_BLOCK_MEMORY: - case BUF_BLOCK_REMOVE_HASH: - ut_error; - break; - } - } - - buf_flush_list_mutex_exit(buf_pool); - buf_pool_mutex_exit(buf_pool); -} - -/******************************************************************** Determine if a block is a sentinel for a buffer pool watch. @return TRUE if a sentinel for a buffer pool watch, FALSE if not */ UNIV_INTERN @@ -1913,123 +1573,6 @@ buf_pool_watch_set( return(NULL); } -/********************************************************************//** -Rebuild buf_pool->page_hash. */ -static -void -buf_pool_page_hash_rebuild(void) -/*============================*/ -{ - ulint i; - - for (i = 0; i < srv_buf_pool_instances; i++) { - buf_pool_page_hash_rebuild_instance(buf_pool_from_array(i)); - } -} - -/********************************************************************//** -Increase the buffer pool size of one buffer pool instance. */ -static -void -buf_pool_increase_instance( -/*=======================*/ - buf_pool_t* buf_pool, /*!< in: buffer pool instane */ - ulint change_size) /*!< in: new size of the pool */ -{ - buf_chunk_t* chunks; - buf_chunk_t* chunk; - - buf_pool_mutex_enter(buf_pool); - chunks = mem_alloc((buf_pool->n_chunks + 1) * sizeof *chunks); - - memcpy(chunks, buf_pool->chunks, buf_pool->n_chunks * sizeof *chunks); - - chunk = &chunks[buf_pool->n_chunks]; - - if (!buf_chunk_init(buf_pool, chunk, change_size)) { - mem_free(chunks); - } else { - buf_pool->old_pool_size = buf_pool->curr_pool_size; - buf_pool->curr_size += chunk->size; - buf_pool->curr_pool_size = buf_pool->curr_size * UNIV_PAGE_SIZE; - mem_free(buf_pool->chunks); - buf_pool->chunks = chunks; - buf_pool->n_chunks++; - } - - buf_pool_mutex_exit(buf_pool); -} - -/********************************************************************//** -Increase the buffer pool size. */ -static -void -buf_pool_increase( -/*==============*/ - ulint change_size) -{ - ulint i; - - for (i = 0; i < srv_buf_pool_instances; i++) { - buf_pool_increase_instance( - buf_pool_from_array(i), - change_size / srv_buf_pool_instances); - } - - buf_pool_set_sizes(); -} - -/********************************************************************//** -Resizes the buffer pool. */ -UNIV_INTERN -void -buf_pool_resize(void) -/*=================*/ -{ - ulint change_size; - ulint min_change_size = 1048576 * srv_buf_pool_instances; - - buf_pool_mutex_enter_all(); - - if (srv_buf_pool_old_size == srv_buf_pool_size) { - - buf_pool_mutex_exit_all(); - - return; - - } else if (srv_buf_pool_curr_size + min_change_size - > srv_buf_pool_size) { - - change_size = (srv_buf_pool_curr_size - srv_buf_pool_size) - / UNIV_PAGE_SIZE; - - buf_pool_mutex_exit_all(); - - /* Disable adaptive hash indexes and empty the index - in order to free up memory in the buffer pool chunks. */ - buf_pool_shrink(change_size); - - } else if (srv_buf_pool_curr_size + min_change_size - < srv_buf_pool_size) { - - /* Enlarge the buffer pool by at least one megabyte */ - - change_size = srv_buf_pool_size - srv_buf_pool_curr_size; - - buf_pool_mutex_exit_all(); - - buf_pool_increase(change_size); - } else { - srv_buf_pool_size = srv_buf_pool_old_size; - - buf_pool_mutex_exit_all(); - - return; - } - - buf_pool_page_hash_rebuild(); -} - /****************************************************************//** Remove the sentinel block for the watch before replacing it with a real block. buf_page_watch_clear() or buf_page_watch_occurred() will notice that @@ -2365,7 +1908,7 @@ err_exit: mutex_enter(block_mutex); /* Discard the uncompressed page frame if possible. */ - if (buf_LRU_free_block(bpage, FALSE) == BUF_LRU_FREED) { + if (buf_LRU_free_block(bpage, FALSE)) { mutex_exit(block_mutex); goto lookup; @@ -2768,12 +2311,8 @@ loop: if (block) { /* If the guess is a compressed page descriptor that - has been allocated by buf_buddy_alloc(), it may have - been invalidated by buf_buddy_relocate(). In that - case, block could point to something that happens to - contain the expected bits in block->page. Similarly, - the guess may be pointing to a buffer pool chunk that - has been released when resizing the buffer pool. */ + has been allocated by buf_page_alloc_descriptor(), + it may have been freed by buf_relocate(). */ if (!buf_block_is_uncompressed(buf_pool, block) || offset != block->page.offset @@ -2820,6 +2359,9 @@ loop2: } if (buf_read_page(space, zip_size, offset)) { + buf_read_ahead_random(space, zip_size, offset, + ibuf_inside(mtr)); + retries = 0; } else if (retries < BUF_PAGE_READ_MAX_RETRIES) { ++retries; @@ -2951,8 +2493,10 @@ wait_until_unfixed: if (buf_page_get_state(&block->page) == BUF_BLOCK_ZIP_PAGE) { +#if defined UNIV_DEBUG || defined UNIV_BUF_DEBUG UT_LIST_REMOVE(list, buf_pool->zip_clean, &block->page); +#endif /* UNIV_DEBUG || UNIV_BUF_DEBUG */ ut_ad(!block->page.in_flush_list); } else { /* Relocate buf_pool->flush_list. */ @@ -2978,11 +2522,10 @@ wait_until_unfixed: mutex_exit(&buf_pool->zip_mutex); buf_pool->n_pend_unzip++; - bpage->state = BUF_BLOCK_ZIP_FREE; - buf_buddy_free(buf_pool, bpage, sizeof *bpage); - buf_pool_mutex_exit(buf_pool); + buf_page_free_descriptor(bpage); + /* Decompress the page and apply buffered operations while not holding buf_pool->mutex or block->mutex. */ success = buf_zip_decompress(block, srv_use_checksums); @@ -3028,7 +2571,7 @@ wait_until_unfixed: /* Try to evict the block from the buffer pool, to use the insert buffer (change buffer) as much as possible. */ - if (buf_LRU_free_block(&block->page, TRUE) == BUF_LRU_FREED) { + if (buf_LRU_free_block(&block->page, TRUE)) { mutex_exit(&block->mutex); if (mode == BUF_GET_IF_IN_POOL_OR_WATCH) { /* Set the watch, as it would have @@ -3472,19 +3015,20 @@ buf_page_init_low( /********************************************************************//** Inits a page to the buffer buf_pool. */ -static +static __attribute__((nonnull)) void buf_page_init( /*==========*/ + buf_pool_t* buf_pool,/*!< in/out: buffer pool */ ulint space, /*!< in: space id */ ulint offset, /*!< in: offset of the page within space in units of a page */ ulint fold, /*!< in: buf_page_address_fold(space,offset) */ - buf_block_t* block) /*!< in: block to init */ + buf_block_t* block) /*!< in/out: block to init */ { buf_page_t* hash_page; - buf_pool_t* buf_pool = buf_pool_get(space, offset); + ut_ad(buf_pool == buf_pool_get(space, offset)); ut_ad(buf_pool_mutex_own(buf_pool)); ut_ad(mutex_own(&(block->mutex))); ut_a(buf_block_get_state(block) != BUF_BLOCK_FILE_PAGE); @@ -3643,7 +3187,7 @@ err_exit: ut_ad(buf_pool_from_bpage(bpage) == buf_pool); - buf_page_init(space, offset, fold, block); + buf_page_init(buf_pool, space, offset, fold, block); /* The block must be put to the LRU list, to the old blocks */ buf_LRU_add_block(bpage, TRUE/* to old blocks */); @@ -3687,20 +3231,11 @@ err_exit: mutex_exit(&block->mutex); } else { - /* Defer buf_buddy_alloc() until after the block has - been found not to exist. The buf_buddy_alloc() and - buf_buddy_free() calls may be expensive because of - buf_buddy_relocate(). */ - /* The compressed page must be allocated before the control block (bpage), in order to avoid the invocation of buf_buddy_relocate_block() on uninitialized data. */ data = buf_buddy_alloc(buf_pool, zip_size, &lru); - bpage = buf_buddy_alloc(buf_pool, sizeof *bpage, &lru); - - /* Initialize the buf_pool pointer. */ - bpage->buf_pool_index = buf_pool_index(buf_pool); /* If buf_buddy_alloc() allocated storage from the LRU list, it released and reacquired buf_pool->mutex. Thus, we must @@ -3716,8 +3251,6 @@ err_exit: /* The block was added by some other thread. */ watch_page = NULL; - bpage->state = BUF_BLOCK_ZIP_FREE; - buf_buddy_free(buf_pool, bpage, sizeof *bpage); buf_buddy_free(buf_pool, data, zip_size); bpage = NULL; @@ -3725,6 +3258,11 @@ err_exit: } } + bpage = buf_page_alloc_descriptor(); + + /* Initialize the buf_pool pointer. */ + bpage->buf_pool_index = buf_pool_index(buf_pool); + page_zip_des_init(&bpage->zip); page_zip_set_size(&bpage->zip, zip_size); bpage->zip.data = data; @@ -3739,7 +3277,6 @@ err_exit: bpage->space = space; bpage->offset = offset; - #ifdef UNIV_DEBUG bpage->in_page_hash = FALSE; bpage->in_zip_hash = FALSE; @@ -3764,7 +3301,9 @@ err_exit: /* The block must be put to the LRU list, to the old blocks */ buf_LRU_add_block(bpage, TRUE/* to old blocks */); +#if defined UNIV_DEBUG || defined UNIV_BUF_DEBUG buf_LRU_insert_zip_clean(bpage); +#endif /* UNIV_DEBUG || UNIV_BUF_DEBUG */ buf_page_set_io_fix(bpage, BUF_IO_READ); @@ -3852,7 +3391,7 @@ buf_page_create( mutex_enter(&block->mutex); - buf_page_init(space, offset, fold, block); + buf_page_init(buf_pool, space, offset, fold, block); /* The block must be put to the LRU list */ buf_LRU_add_block(&block->page, FALSE); @@ -3936,6 +3475,53 @@ buf_page_create( } /********************************************************************//** +Mark a table with the specified space pointed by bpage->space corrupted. +Also remove the bpage from LRU list. +@return TRUE if successful */ +static +ibool +buf_mark_space_corrupt( +/*===================*/ + buf_page_t* bpage) /*!< in: pointer to the block in question */ +{ + buf_pool_t* buf_pool = buf_pool_from_bpage(bpage); + const ibool uncompressed = (buf_page_get_state(bpage) + == BUF_BLOCK_FILE_PAGE); + ulint space = bpage->space; + ibool ret = TRUE; + + /* First unfix and release lock on the bpage */ + buf_pool_mutex_enter(buf_pool); + mutex_enter(buf_page_get_mutex(bpage)); + ut_ad(buf_page_get_io_fix(bpage) == BUF_IO_READ); + ut_ad(bpage->buf_fix_count == 0); + + /* Set BUF_IO_NONE before we remove the block from LRU list */ + buf_page_set_io_fix(bpage, BUF_IO_NONE); + + if (uncompressed) { + rw_lock_x_unlock_gen( + &((buf_block_t*) bpage)->lock, + BUF_IO_READ); + } + + /* Find the table with specified space id, and mark it corrupted */ + if (dict_set_corrupted_by_space(space)) { + buf_LRU_free_one_page(bpage); + } else { + ret = FALSE; + } + + ut_ad(buf_pool->n_pend_reads > 0); + buf_pool->n_pend_reads--; + + mutex_exit(buf_page_get_mutex(bpage)); + buf_pool_mutex_exit(buf_pool); + + return(ret); +} + +/********************************************************************//** Completes an asynchronous read or write request of a file page to or from the buffer pool. */ UNIV_INTERN @@ -4060,10 +3646,19 @@ corrupt: "InnoDB: about forcing recovery.\n", stderr); if (srv_force_recovery < SRV_FORCE_IGNORE_CORRUPT) { - fputs("InnoDB: Ending processing because of" - " a corrupt database page.\n", - stderr); - exit(1); + /* If page space id is larger than TRX_SYS_SPACE + (0), we will attempt to mark the corresponding + table as corrupted instead of crashing server */ + if (bpage->space > TRX_SYS_SPACE + && buf_mark_space_corrupt(bpage)) { + return; + } else { + fputs("InnoDB: Ending processing" + " because of" + " a corrupt database page.\n", + stderr); + ut_error; + } } } @@ -4847,6 +4442,7 @@ buf_stats_aggregate_pool_info( total_info->n_pages_created += pool_info->n_pages_created; total_info->n_pages_written += pool_info->n_pages_written; total_info->n_page_gets += pool_info->n_page_gets; + total_info->n_ra_pages_read_rnd += pool_info->n_ra_pages_read_rnd; total_info->n_ra_pages_read += pool_info->n_ra_pages_read; total_info->n_ra_pages_evicted += pool_info->n_ra_pages_evicted; total_info->page_made_young_rate += pool_info->page_made_young_rate; @@ -4859,6 +4455,7 @@ buf_stats_aggregate_pool_info( total_info->page_read_delta += pool_info->page_read_delta; total_info->young_making_delta += pool_info->young_making_delta; total_info->not_young_making_delta += pool_info->not_young_making_delta; + total_info->pages_readahead_rnd_rate += pool_info->pages_readahead_rnd_rate; total_info->pages_readahead_rate += pool_info->pages_readahead_rate; total_info->pages_evicted_rate += pool_info->pages_evicted_rate; total_info->unzip_lru_len += pool_info->unzip_lru_len; @@ -4936,6 +4533,7 @@ buf_stats_get_pool_info( pool_info->n_page_gets = buf_pool->stat.n_page_gets; + pool_info->n_ra_pages_read_rnd = buf_pool->stat.n_ra_pages_read_rnd; pool_info->n_ra_pages_read = buf_pool->stat.n_ra_pages_read; pool_info->n_ra_pages_evicted = buf_pool->stat.n_ra_pages_evicted; @@ -4975,6 +4573,10 @@ buf_stats_get_pool_info( buf_pool->stat.n_pages_not_made_young - buf_pool->old_stat.n_pages_not_made_young; } + pool_info->pages_readahead_rnd_rate = + (buf_pool->stat.n_ra_pages_read_rnd + - buf_pool->old_stat.n_ra_pages_read_rnd) / time_elapsed; + pool_info->pages_readahead_rate = (buf_pool->stat.n_ra_pages_read @@ -5060,9 +4662,12 @@ buf_print_io_instance( /* Statistics about read ahead algorithm */ fprintf(file, "Pages read ahead %.2f/s," - " evicted without access %.2f/s\n", + " evicted without access %.2f/s," + " Random read ahead %.2f/s\n", + pool_info->pages_readahead_rate, - pool_info->pages_evicted_rate); + pool_info->pages_evicted_rate, + pool_info->pages_readahead_rnd_rate); /* Print some values to help us with visualizing what is happening with LRU eviction. */ diff --git a/storage/innobase/buf/buf0flu.c b/storage/innobase/buf/buf0flu.c index ebe96a82a10..06b3ec393c1 100644 --- a/storage/innobase/buf/buf0flu.c +++ b/storage/innobase/buf/buf0flu.c @@ -1,6 +1,6 @@ /***************************************************************************** -Copyright (c) 1995, 2010, Innobase Oy. All Rights Reserved. +Copyright (c) 1995, 2011, Oracle and/or its affiliates. All Rights Reserved. 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 the Free Software @@ -524,7 +524,9 @@ buf_flush_remove( case BUF_BLOCK_ZIP_DIRTY: buf_page_set_state(bpage, BUF_BLOCK_ZIP_PAGE); UT_LIST_REMOVE(list, buf_pool->flush_list, bpage); +#if defined UNIV_DEBUG || defined UNIV_BUF_DEBUG buf_LRU_insert_zip_clean(bpage); +#endif /* UNIV_DEBUG || UNIV_BUF_DEBUG */ break; case BUF_BLOCK_FILE_PAGE: UT_LIST_REMOVE(list, buf_pool->flush_list, bpage); diff --git a/storage/innobase/buf/buf0lru.c b/storage/innobase/buf/buf0lru.c index 64afcecfe3c..b5ca21e14a6 100644 --- a/storage/innobase/buf/buf0lru.c +++ b/storage/innobase/buf/buf0lru.c @@ -1,6 +1,6 @@ /***************************************************************************** -Copyright (c) 1995, 2010, Innobase Oy. All Rights Reserved. +Copyright (c) 1995, 2011, Oracle and/or its affiliates. All Rights Reserved. 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 the Free Software @@ -353,31 +353,34 @@ scan_again: while (bpage != NULL) { buf_page_t* prev_bpage; - ibool prev_bpage_buf_fix = FALSE; + mutex_t* block_mutex = NULL; ut_a(buf_page_in_file(bpage)); prev_bpage = UT_LIST_GET_PREV(LRU, bpage); /* bpage->space and bpage->io_fix are protected by - buf_pool->mutex and block_mutex. It is safe to check - them while holding buf_pool->mutex only. */ + buf_pool_mutex and block_mutex. It is safe to check + them while holding buf_pool_mutex only. */ if (buf_page_get_space(bpage) != id) { /* Skip this block, as it does not belong to the space that is being invalidated. */ + goto next_page; } else if (buf_page_get_io_fix(bpage) != BUF_IO_NONE) { /* We cannot remove this page during this scan yet; maybe the system is currently reading it in, or flushing the modifications to the file */ all_freed = FALSE; + goto next_page; } else { - mutex_t* block_mutex = buf_page_get_mutex(bpage); + block_mutex = buf_page_get_mutex(bpage); mutex_enter(block_mutex); if (bpage->buf_fix_count > 0) { + mutex_exit(block_mutex); /* We cannot remove this page during this scan yet; maybe the system is currently reading it in, or flushing @@ -387,106 +390,59 @@ scan_again: goto next_page; } + } + + ut_ad(mutex_own(block_mutex)); #ifdef UNIV_DEBUG - if (buf_debug_prints) { - fprintf(stderr, - "Dropping space %lu page %lu\n", - (ulong) buf_page_get_space(bpage), - (ulong) buf_page_get_page_no(bpage)); - } + if (buf_debug_prints) { + fprintf(stderr, + "Dropping space %lu page %lu\n", + (ulong) buf_page_get_space(bpage), + (ulong) buf_page_get_page_no(bpage)); + } #endif - if (buf_page_get_state(bpage) != BUF_BLOCK_FILE_PAGE) { - /* This is a compressed-only block - descriptor. Ensure that prev_bpage - cannot be relocated when bpage is freed. */ - if (UNIV_LIKELY(prev_bpage != NULL)) { - switch (buf_page_get_state( - prev_bpage)) { - case BUF_BLOCK_FILE_PAGE: - /* Descriptors of uncompressed - blocks will not be relocated, - because we are holding the - buf_pool->mutex. */ - break; - case BUF_BLOCK_ZIP_PAGE: - case BUF_BLOCK_ZIP_DIRTY: - /* Descriptors of compressed- - only blocks can be relocated, - unless they are buffer-fixed. - Because both bpage and - prev_bpage are protected by - buf_pool_zip_mutex, it is - not necessary to acquire - further mutexes. */ - ut_ad(&buf_pool->zip_mutex - == block_mutex); - ut_ad(mutex_own(block_mutex)); - prev_bpage_buf_fix = TRUE; - prev_bpage->buf_fix_count++; - break; - default: - ut_error; - } - } - } else if (((buf_block_t*) bpage)->is_hashed) { - ulint page_no; - ulint zip_size; - - buf_pool_mutex_exit(buf_pool); + if (buf_page_get_state(bpage) != BUF_BLOCK_FILE_PAGE) { + /* This is a compressed-only block + descriptor. Do nothing. */ + } else if (((buf_block_t*) bpage)->is_hashed) { + ulint page_no; + ulint zip_size; - zip_size = buf_page_get_zip_size(bpage); - page_no = buf_page_get_page_no(bpage); + buf_pool_mutex_exit(buf_pool); - mutex_exit(block_mutex); + zip_size = buf_page_get_zip_size(bpage); + page_no = buf_page_get_page_no(bpage); - /* Note that the following call will acquire - an S-latch on the page */ + mutex_exit(block_mutex); - btr_search_drop_page_hash_when_freed( - id, zip_size, page_no); - goto scan_again; - } + /* Note that the following call will acquire + an S-latch on the page */ - if (bpage->oldest_modification != 0) { + btr_search_drop_page_hash_when_freed( + id, zip_size, page_no); + goto scan_again; + } - buf_flush_remove(bpage); - } + if (bpage->oldest_modification != 0) { - /* Remove from the LRU list. */ + buf_flush_remove(bpage); + } - if (buf_LRU_block_remove_hashed_page(bpage, TRUE) - != BUF_BLOCK_ZIP_FREE) { - buf_LRU_block_free_hashed_page((buf_block_t*) - bpage); - } else { - /* The block_mutex should have been - released by buf_LRU_block_remove_hashed_page() - when it returns BUF_BLOCK_ZIP_FREE. */ - ut_ad(block_mutex == &buf_pool->zip_mutex); - ut_ad(!mutex_own(block_mutex)); - - if (prev_bpage_buf_fix) { - /* We temporarily buffer-fixed - prev_bpage, so that - buf_buddy_free() could not - relocate it, in case it was a - compressed-only block - descriptor. */ - - mutex_enter(block_mutex); - ut_ad(prev_bpage->buf_fix_count > 0); - prev_bpage->buf_fix_count--; - mutex_exit(block_mutex); - } + /* Remove from the LRU list. */ - goto next_page_no_mutex; - } -next_page: + if (buf_LRU_block_remove_hashed_page(bpage, TRUE) + != BUF_BLOCK_ZIP_FREE) { + buf_LRU_block_free_hashed_page((buf_block_t*) bpage); mutex_exit(block_mutex); + } else { + /* The block_mutex should have been released + by buf_LRU_block_remove_hashed_page() when it + returns BUF_BLOCK_ZIP_FREE. */ + ut_ad(block_mutex == &buf_pool->zip_mutex); + ut_ad(!mutex_own(block_mutex)); } - -next_page_no_mutex: +next_page: bpage = prev_bpage; } @@ -525,6 +481,7 @@ buf_LRU_invalidate_tablespace( } } +#if defined UNIV_DEBUG || defined UNIV_BUF_DEBUG /********************************************************************//** Insert a compressed block into buf_pool->zip_clean in the LRU order. */ UNIV_INTERN @@ -557,6 +514,7 @@ buf_LRU_insert_zip_clean( UT_LIST_ADD_FIRST(list, buf_pool->zip_clean, bpage); } } +#endif /* UNIV_DEBUG || UNIV_BUF_DEBUG */ /******************************************************************//** Try to free an uncompressed page of a compressed block from the unzip @@ -600,7 +558,7 @@ buf_LRU_free_from_unzip_LRU_list( UNIV_LIKELY(block != NULL) && UNIV_LIKELY(distance > 0); block = UT_LIST_GET_PREV(unzip_LRU, block), distance--) { - enum buf_lru_free_block_status freed; + ibool freed; ut_ad(buf_block_get_state(block) == BUF_BLOCK_FILE_PAGE); ut_ad(block->in_unzip_LRU_list); @@ -610,24 +568,9 @@ buf_LRU_free_from_unzip_LRU_list( freed = buf_LRU_free_block(&block->page, FALSE); mutex_exit(&block->mutex); - switch (freed) { - case BUF_LRU_FREED: + if (freed) { return(TRUE); - - case BUF_LRU_CANNOT_RELOCATE: - /* If we failed to relocate, try - regular LRU eviction. */ - return(FALSE); - - case BUF_LRU_NOT_FREED: - /* The block was buffer-fixed or I/O-fixed. - Keep looking. */ - continue; } - - /* inappropriate return value from - buf_LRU_free_block() */ - ut_error; } return(FALSE); @@ -660,10 +603,9 @@ buf_LRU_free_from_common_LRU_list( UNIV_LIKELY(bpage != NULL) && UNIV_LIKELY(distance > 0); bpage = UT_LIST_GET_PREV(LRU, bpage), distance--) { - enum buf_lru_free_block_status freed; - unsigned accessed; - mutex_t* block_mutex - = buf_page_get_mutex(bpage); + ibool freed; + unsigned accessed; + mutex_t* block_mutex = buf_page_get_mutex(bpage); ut_ad(buf_page_in_file(bpage)); ut_ad(bpage->in_LRU_list); @@ -673,8 +615,7 @@ buf_LRU_free_from_common_LRU_list( freed = buf_LRU_free_block(bpage, TRUE); mutex_exit(block_mutex); - switch (freed) { - case BUF_LRU_FREED: + if (freed) { /* Keep track of pages that are evicted without ever being accessed. This gives us a measure of the effectiveness of readahead */ @@ -682,21 +623,7 @@ buf_LRU_free_from_common_LRU_list( ++buf_pool->stat.n_ra_pages_evicted; } return(TRUE); - - case BUF_LRU_NOT_FREED: - /* The block was dirty, buffer-fixed, or I/O-fixed. - Keep looking. */ - continue; - - case BUF_LRU_CANNOT_RELOCATE: - /* This should never occur, because we - want to discard the compressed page too. */ - break; } - - /* inappropriate return value from - buf_LRU_free_block() */ - ut_error; } return(FALSE); @@ -1422,17 +1349,16 @@ buf_LRU_make_block_old( Try to free a block. If bpage is a descriptor of a compressed-only page, the descriptor object will be freed as well. -NOTE: If this function returns BUF_LRU_FREED, it will temporarily +NOTE: If this function returns TRUE, it will temporarily release buf_pool->mutex. Furthermore, the page frame will no longer be accessible via bpage. The caller must hold buf_pool->mutex and buf_page_get_mutex(bpage) and release these two mutexes after the call. No other buf_page_get_mutex() may be held when calling this function. -@return BUF_LRU_FREED if freed, BUF_LRU_CANNOT_RELOCATE or -BUF_LRU_NOT_FREED otherwise. */ +@return TRUE if freed, FALSE otherwise. */ UNIV_INTERN -enum buf_lru_free_block_status +ibool buf_LRU_free_block( /*===============*/ buf_page_t* bpage, /*!< in: block to be freed */ @@ -1458,7 +1384,7 @@ buf_LRU_free_block( if (!buf_page_can_relocate(bpage)) { /* Do not free buffer-fixed or I/O-fixed blocks. */ - return(BUF_LRU_NOT_FREED); + return(FALSE); } #ifdef UNIV_IBUF_COUNT_DEBUG @@ -1470,7 +1396,7 @@ buf_LRU_free_block( /* Do not completely free dirty blocks. */ if (bpage->oldest_modification) { - return(BUF_LRU_NOT_FREED); + return(FALSE); } } else if (bpage->oldest_modification) { /* Do not completely free dirty blocks. */ @@ -1478,7 +1404,7 @@ buf_LRU_free_block( if (buf_page_get_state(bpage) != BUF_BLOCK_FILE_PAGE) { ut_ad(buf_page_get_state(bpage) == BUF_BLOCK_ZIP_DIRTY); - return(BUF_LRU_NOT_FREED); + return(FALSE); } goto alloc; @@ -1487,14 +1413,8 @@ buf_LRU_free_block( If it cannot be allocated (without freeing a block from the LRU list), refuse to free bpage. */ alloc: - buf_pool_mutex_exit_forbid(buf_pool); - b = buf_buddy_alloc(buf_pool, sizeof *b, NULL); - buf_pool_mutex_exit_allow(buf_pool); - - if (UNIV_UNLIKELY(!b)) { - return(BUF_LRU_CANNOT_RELOCATE); - } - + b = buf_page_alloc_descriptor(); + ut_a(b); memcpy(b, bpage, sizeof *b); } @@ -1598,7 +1518,9 @@ alloc: } if (b->state == BUF_BLOCK_ZIP_PAGE) { +#if defined UNIV_DEBUG || defined UNIV_BUF_DEBUG buf_LRU_insert_zip_clean(b); +#endif /* UNIV_DEBUG || UNIV_BUF_DEBUG */ } else { /* Relocate on buf_pool->flush_list. */ buf_flush_relocate_on_flush_list(bpage, b); @@ -1665,7 +1587,7 @@ alloc: mutex_enter(block_mutex); } - return(BUF_LRU_FREED); + return(TRUE); } /******************************************************************//** @@ -1884,7 +1806,9 @@ buf_LRU_block_remove_hashed_page( ut_a(bpage->zip.data); ut_a(buf_page_get_zip_size(bpage)); +#if defined UNIV_DEBUG || defined UNIV_BUF_DEBUG UT_LIST_REMOVE(list, buf_pool->zip_clean, bpage); +#endif /* UNIV_DEBUG || UNIV_BUF_DEBUG */ mutex_exit(&buf_pool->zip_mutex); buf_pool_mutex_exit_forbid(buf_pool); @@ -1893,11 +1817,8 @@ buf_LRU_block_remove_hashed_page( buf_pool, bpage->zip.data, page_zip_get_size(&bpage->zip)); - bpage->state = BUF_BLOCK_ZIP_FREE; - buf_buddy_free(buf_pool, bpage, sizeof(*bpage)); buf_pool_mutex_exit_allow(buf_pool); - - UNIV_MEM_UNDESC(bpage); + buf_page_free_descriptor(bpage); return(BUF_BLOCK_ZIP_FREE); case BUF_BLOCK_FILE_PAGE: @@ -1964,6 +1885,22 @@ buf_LRU_block_free_hashed_page( buf_LRU_block_free_non_file_page(block); } +/******************************************************************//** +Remove one page from LRU list and put it to free list */ +UNIV_INTERN +void +buf_LRU_free_one_page( +/*==================*/ + buf_page_t* bpage) /*!< in/out: block, must contain a file page and + be in a state where it can be freed; there + may or may not be a hash index to the page */ +{ + if (buf_LRU_block_remove_hashed_page(bpage, TRUE) + != BUF_BLOCK_ZIP_FREE) { + buf_LRU_block_free_hashed_page((buf_block_t*) bpage); + } +} + /**********************************************************************//** Updates buf_pool->LRU_old_ratio for one buffer pool instance. @return updated old_pct */ diff --git a/storage/innobase/buf/buf0rea.c b/storage/innobase/buf/buf0rea.c index eeaa21ae9ef..da804a66b29 100644 --- a/storage/innobase/buf/buf0rea.c +++ b/storage/innobase/buf/buf0rea.c @@ -40,8 +40,10 @@ Created 11/5/1995 Heikki Tuuri #include "mysql/plugin.h" #include "mysql/service_thd_wait.h" -/** The linear read-ahead area size */ -#define BUF_READ_AHEAD_LINEAR_AREA BUF_READ_AHEAD_AREA +/** There must be at least this many pages in buf_pool in the area to start +a random read-ahead */ +#define BUF_READ_AHEAD_RANDOM_THRESHOLD(b) \ + (5 + BUF_READ_AHEAD_AREA(b) / 8) /** If there are buf_pool->curr_size per the number below pending reads, then read-ahead is not done: this is to prevent flooding the buffer pool with @@ -162,6 +164,171 @@ buf_read_page_low( } /********************************************************************//** +Applies a random read-ahead in buf_pool if there are at least a threshold +value of accessed pages from the random read-ahead area. Does not read any +page, not even the one at the position (space, offset), if the read-ahead +mechanism is not activated. NOTE 1: the calling thread may own latches on +pages: to avoid deadlocks this function must be written such that it cannot +end up waiting for these latches! NOTE 2: the calling thread must want +access to the page given: this rule is set to prevent unintended read-aheads +performed by ibuf routines, a situation which could result in a deadlock if +the OS does not support asynchronous i/o. +@return number of page read requests issued; NOTE that if we read ibuf +pages, it may happen that the page at the given page number does not +get read even if we return a positive value! +@return number of page read requests issued */ +UNIV_INTERN +ulint +buf_read_ahead_random( +/*==================*/ + ulint space, /*!< in: space id */ + ulint zip_size, /*!< in: compressed page size in bytes, + or 0 */ + ulint offset, /*!< in: page number of a page which + the current thread wants to access */ + ibool inside_ibuf) /*!< in: TRUE if we are inside ibuf + routine */ +{ + buf_pool_t* buf_pool = buf_pool_get(space, offset); + ib_int64_t tablespace_version; + ulint recent_blocks = 0; + ulint ibuf_mode; + ulint count; + ulint low, high; + ulint err; + ulint i; + const ulint buf_read_ahead_random_area + = BUF_READ_AHEAD_AREA(buf_pool); + + if (!srv_random_read_ahead) { + /* Disabled by user */ + return(0); + } + + if (srv_startup_is_before_trx_rollback_phase) { + /* No read-ahead to avoid thread deadlocks */ + return(0); + } + + if (ibuf_bitmap_page(zip_size, offset) + || trx_sys_hdr_page(space, offset)) { + + /* If it is an ibuf bitmap page or trx sys hdr, we do + no read-ahead, as that could break the ibuf page access + order */ + + return(0); + } + + /* Remember the tablespace version before we ask te tablespace size + below: if DISCARD + IMPORT changes the actual .ibd file meanwhile, we + do not try to read outside the bounds of the tablespace! */ + + tablespace_version = fil_space_get_version(space); + + low = (offset / buf_read_ahead_random_area) + * buf_read_ahead_random_area; + high = (offset / buf_read_ahead_random_area + 1) + * buf_read_ahead_random_area; + if (high > fil_space_get_size(space)) { + + high = fil_space_get_size(space); + } + + buf_pool_mutex_enter(buf_pool); + + if (buf_pool->n_pend_reads + > buf_pool->curr_size / BUF_READ_AHEAD_PEND_LIMIT) { + buf_pool_mutex_exit(buf_pool); + + return(0); + } + + /* Count how many blocks in the area have been recently accessed, + that is, reside near the start of the LRU list. */ + + for (i = low; i < high; i++) { + const buf_page_t* bpage = + buf_page_hash_get(buf_pool, space, i); + + if (bpage + && buf_page_is_accessed(bpage) + && buf_page_peek_if_young(bpage)) { + + recent_blocks++; + + if (recent_blocks + >= BUF_READ_AHEAD_RANDOM_THRESHOLD(buf_pool)) { + + buf_pool_mutex_exit(buf_pool); + goto read_ahead; + } + } + } + + buf_pool_mutex_exit(buf_pool); + /* Do nothing */ + return(0); + +read_ahead: + /* Read all the suitable blocks within the area */ + + if (inside_ibuf) { + ibuf_mode = BUF_READ_IBUF_PAGES_ONLY; + } else { + ibuf_mode = BUF_READ_ANY_PAGE; + } + + count = 0; + + for (i = low; i < high; i++) { + /* It is only sensible to do read-ahead in the non-sync aio + mode: hence FALSE as the first parameter */ + + if (!ibuf_bitmap_page(zip_size, i)) { + count += buf_read_page_low( + &err, FALSE, + ibuf_mode | OS_AIO_SIMULATED_WAKE_LATER, + space, zip_size, FALSE, + tablespace_version, i); + if (err == DB_TABLESPACE_DELETED) { + ut_print_timestamp(stderr); + fprintf(stderr, + " InnoDB: Warning: in random" + " readahead trying to access\n" + "InnoDB: tablespace %lu page %lu,\n" + "InnoDB: but the tablespace does not" + " exist or is just being dropped.\n", + (ulong) space, (ulong) i); + } + } + } + + /* In simulated aio we wake the aio handler threads only after + queuing all aio requests, in native aio the following call does + nothing: */ + + os_aio_simulated_wake_handler_threads(); + +#ifdef UNIV_DEBUG + if (buf_debug_prints && (count > 0)) { + fprintf(stderr, + "Random read-ahead space %lu offset %lu pages %lu\n", + (ulong) space, (ulong) offset, + (ulong) count); + } +#endif /* UNIV_DEBUG */ + + /* Read ahead is considered one I/O operation for the purpose of + LRU policy decision. */ + buf_LRU_stat_inc_io(); + + buf_pool->stat.n_ra_pages_read_rnd += count; + srv_buf_pool_reads += count; + return(count); +} + +/********************************************************************//** High-level function which reads a page asynchronously from a file to the buffer buf_pool if it is not already there. Sets the io_fix flag and sets an exclusive lock on the buffer frame. The flag is cleared and the x-lock @@ -257,7 +424,7 @@ buf_read_ahead_linear( ulint err; ulint i; const ulint buf_read_ahead_linear_area - = BUF_READ_AHEAD_LINEAR_AREA(buf_pool); + = BUF_READ_AHEAD_AREA(buf_pool); ulint threshold; if (UNIV_UNLIKELY(srv_startup_is_before_trx_rollback_phase)) { diff --git a/storage/innobase/dict/dict0crea.c b/storage/innobase/dict/dict0crea.c index 9a528d679a7..d7373a4b8ef 100644 --- a/storage/innobase/dict/dict0crea.c +++ b/storage/innobase/dict/dict0crea.c @@ -1,6 +1,6 @@ /***************************************************************************** -Copyright (c) 1996, 2010, Innobase Oy. All Rights Reserved. +Copyright (c) 1996, 2011, Oracle and/or its affiliates. All Rights Reserved. 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 the Free Software @@ -827,7 +827,7 @@ dict_truncate_index_tree( appropriate field in the SYS_INDEXES record: this mini-transaction marks the B-tree totally truncated */ - btr_block_get(space, zip_size, root_page_no, RW_X_LATCH, mtr); + btr_block_get(space, zip_size, root_page_no, RW_X_LATCH, NULL, mtr); btr_free_root(space, zip_size, root_page_no, mtr); create: diff --git a/storage/innobase/dict/dict0dict.c b/storage/innobase/dict/dict0dict.c index 1e3aed92cf7..2a2c7652817 100644 --- a/storage/innobase/dict/dict0dict.c +++ b/storage/innobase/dict/dict0dict.c @@ -1,6 +1,6 @@ /***************************************************************************** -Copyright (c) 1996, 2010, Innobase Oy. All Rights Reserved. +Copyright (c) 1996, 2011, Oracle and/or its affiliates. All Rights Reserved. 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 the Free Software @@ -54,6 +54,7 @@ UNIV_INTERN dict_index_t* dict_ind_compact; #include "row0merge.h" #include "m_ctype.h" /* my_isspace() */ #include "ha_prototypes.h" /* innobase_strcasecmp(), innobase_casedn_str()*/ +#include "row0upd.h" #include <ctype.h> @@ -611,8 +612,7 @@ dict_table_get_on_id( { dict_table_t* table; - if (table_id <= DICT_FIELDS_ID - || trx->dict_operation_lock_mode == RW_X_LATCH) { + if (trx->dict_operation_lock_mode == RW_X_LATCH) { /* Note: An X latch implies that the transaction already owns the dictionary mutex. */ @@ -1714,7 +1714,8 @@ undo_size_ok: new_index->page = page_no; rw_lock_create(index_tree_rw_lock_key, &new_index->lock, - SYNC_INDEX_TREE); + dict_index_is_ibuf(index) + ? SYNC_IBUF_INDEX_TREE : SYNC_INDEX_TREE); if (!UNIV_UNLIKELY(new_index->type & DICT_UNIVERSAL)) { @@ -5045,4 +5046,187 @@ dict_close(void) rw_lock_free(&dict_table_stats_latches[i]); } } + +/**********************************************************************//** +Find a table in dict_sys->table_LRU list with specified space id +@return table if found, NULL if not */ +static +dict_table_t* +dict_find_table_by_space( +/*=====================*/ + ulint space_id) /*!< in: space ID */ +{ + dict_table_t* table; + ulint num_item; + ulint count = 0; + + ut_ad(space_id > 0); + + table = UT_LIST_GET_FIRST(dict_sys->table_LRU); + num_item = UT_LIST_GET_LEN(dict_sys->table_LRU); + + /* This function intentionally does not acquire mutex as it is used + by error handling code in deep call stack as last means to avoid + killing the server, so it worth to risk some consequencies for + the action. */ + while (table && count < num_item) { + if (table->space == space_id) { + return(table); + } + + table = UT_LIST_GET_NEXT(table_LRU, table); + count++; + } + + return(NULL); +} + +/**********************************************************************//** +Flags a table with specified space_id corrupted in the data dictionary +cache +@return TRUE if successful */ +UNIV_INTERN +ibool +dict_set_corrupted_by_space( +/*========================*/ + ulint space_id) /*!< in: space ID */ +{ + dict_table_t* table; + + table = dict_find_table_by_space(space_id); + + if (!table) { + return(FALSE); + } + + /* mark the table->corrupted bit only, since the caller + could be too deep in the stack for SYS_INDEXES update */ + table->corrupted = TRUE; + + return(TRUE); +} + +/**********************************************************************//** +Flags an index corrupted both in the data dictionary cache +and in the SYS_INDEXES */ +UNIV_INTERN +void +dict_set_corrupted( +/*===============*/ + dict_index_t* index) /*!< in/out: index */ +{ + mem_heap_t* heap; + mtr_t mtr; + dict_index_t* sys_index; + dtuple_t* tuple; + dfield_t* dfield; + byte* buf; + const char* status; + btr_cur_t cursor; + + ut_ad(index); + ut_ad(mutex_own(&dict_sys->mutex)); + ut_ad(!dict_table_is_comp(dict_sys->sys_tables)); + ut_ad(!dict_table_is_comp(dict_sys->sys_indexes)); + +#ifdef UNIV_SYNC_DEBUG + ut_ad(sync_thread_levels_empty_except_dict()); +#endif + + /* Mark the table as corrupted only if the clustered index + is corrupted */ + if (dict_index_is_clust(index)) { + index->table->corrupted = TRUE; + } + + if (UNIV_UNLIKELY(dict_index_is_corrupted(index))) { + /* The index was already flagged corrupted. */ + ut_ad(index->table->corrupted); + return; + } + + heap = mem_heap_create(sizeof(dtuple_t) + 2 * (sizeof(dfield_t) + + sizeof(que_fork_t) + sizeof(upd_node_t) + + sizeof(upd_t) + 12)); + mtr_start(&mtr); + index->type |= DICT_CORRUPT; + + sys_index = UT_LIST_GET_FIRST(dict_sys->sys_indexes->indexes); + + /* Find the index row in SYS_INDEXES */ + tuple = dtuple_create(heap, 2); + + dfield = dtuple_get_nth_field(tuple, 0); + buf = mem_heap_alloc(heap, 8); + mach_write_to_8(buf, index->table->id); + dfield_set_data(dfield, buf, 8); + + dfield = dtuple_get_nth_field(tuple, 1); + buf = mem_heap_alloc(heap, 8); + mach_write_to_8(buf, index->id); + dfield_set_data(dfield, buf, 8); + + dict_index_copy_types(tuple, sys_index, 2); + + btr_cur_search_to_nth_level(sys_index, 0, tuple, PAGE_CUR_GE, + BTR_MODIFY_LEAF, + &cursor, 0, __FILE__, __LINE__, &mtr); + + if (cursor.up_match == dtuple_get_n_fields(tuple)) { + /* UPDATE SYS_INDEXES SET TYPE=index->type + WHERE TABLE_ID=index->table->id AND INDEX_ID=index->id */ + ulint len; + byte* field = rec_get_nth_field_old( + btr_cur_get_rec(&cursor), + DICT_SYS_INDEXES_TYPE_FIELD, &len); + if (len != 4) { + goto fail; + } + mlog_write_ulint(field, index->type, MLOG_4BYTES, &mtr); + status = " InnoDB: Flagged corruption of "; + } else { +fail: + status = " InnoDB: Unable to flag corruption of "; + } + + mtr_commit(&mtr); + mem_heap_free(heap); + + ut_print_timestamp(stderr); + fputs(status, stderr); + dict_index_name_print(stderr, NULL, index); + putc('\n', stderr); +} + +/**********************************************************************//** +Flags an index corrupted in the data dictionary cache only. This +is used mostly to mark a corrupted index when index's own dictionary +is corrupted, and we force to load such index for repair purpose */ +UNIV_INTERN +void +dict_set_corrupted_index_cache_only( +/*================================*/ + dict_index_t* index, /*!< in/out: index */ + dict_table_t* table) /*!< in/out: table */ +{ + ut_ad(index); + ut_ad(mutex_own(&dict_sys->mutex)); + ut_ad(!dict_table_is_comp(dict_sys->sys_tables)); + ut_ad(!dict_table_is_comp(dict_sys->sys_indexes)); + + /* Mark the table as corrupted only if the clustered index + is corrupted */ + if (dict_index_is_clust(index)) { + dict_table_t* corrupt_table; + + corrupt_table = table ? table : index->table; + ut_ad(!index->table || !table || index->table == table); + + if (corrupt_table) { + corrupt_table->corrupted = TRUE; + } + } + + index->type |= DICT_CORRUPT; +} #endif /* !UNIV_HOTBACKUP */ diff --git a/storage/innobase/dict/dict0load.c b/storage/innobase/dict/dict0load.c index a76f1f93202..0a5cfb87140 100644 --- a/storage/innobase/dict/dict0load.c +++ b/storage/innobase/dict/dict0load.c @@ -52,6 +52,11 @@ static const char* SYSTEM_TABLE_NAME[] = { "SYS_FOREIGN", "SYS_FOREIGN_COLS" }; + +/* If this flag is TRUE, then we will load the cluster index's (and tables') +metadata even if it is marked as "corrupted". */ +UNIV_INTERN my_bool srv_load_corrupted = FALSE; + /****************************************************************//** Compare the name of an index column. @return TRUE if the i'th column of index is 'name'. */ @@ -1324,6 +1329,9 @@ err_len: goto err_len; } type = mach_read_from_4(field); + if (UNIV_UNLIKELY(type & (~0 << DICT_IT_BITS))) { + return("unknown SYS_INDEXES.TYPE bits"); + } field = rec_get_nth_field_old(rec, 7/*SPACE*/, &len); if (UNIV_UNLIKELY(len != 4)) { @@ -1423,16 +1431,47 @@ dict_load_indexes( goto next_rec; } else if (err_msg) { fprintf(stderr, "InnoDB: %s\n", err_msg); + if (ignore_err & DICT_ERR_IGNORE_CORRUPT) { + goto next_rec; + } error = DB_CORRUPTION; goto func_exit; } ut_ad(index); + /* Check whether the index is corrupted */ + if (dict_index_is_corrupted(index)) { + ut_print_timestamp(stderr); + fputs(" InnoDB: ", stderr); + dict_index_name_print(stderr, NULL, index); + fputs(" is corrupted\n", stderr); + + if (!srv_load_corrupted + && !(ignore_err & DICT_ERR_IGNORE_CORRUPT) + && dict_index_is_clust(index)) { + dict_mem_index_free(index); + + error = DB_INDEX_CORRUPT; + goto func_exit; + } else { + /* We will load the index if + 1) srv_load_corrupted is TRUE + 2) ignore_err is set with + DICT_ERR_IGNORE_CORRUPT + 3) if the index corrupted is a secondary + index */ + ut_print_timestamp(stderr); + fputs(" InnoDB: load corrupted index ", stderr); + dict_index_name_print(stderr, NULL, index); + putc('\n', stderr); + } + } + /* We check for unsupported types first, so that the subsequent checks are relevant for the supported types. */ - if (index->type & ~(DICT_CLUSTERED | DICT_UNIQUE)) { - + if (index->type & ~(DICT_CLUSTERED | DICT_UNIQUE + | DICT_CORRUPT)) { fprintf(stderr, "InnoDB: Error: unknown type %lu" " of index %s of table %s\n", @@ -1453,9 +1492,14 @@ dict_load_indexes( /* If caller can tolerate this error, we will continue to load the index and let caller deal with this error. However - mark the index and table corrupted */ - index->corrupted = TRUE; - table->corrupted = TRUE; + mark the index and table corrupted. We + only need to mark such in the index + dictionary cache for such metadata corruption, + since we would always be able to set it + when loading the dictionary cache */ + dict_set_corrupted_index_cache_only( + index, table); + fprintf(stderr, "InnoDB: Index is corrupt but forcing" " load into data dictionary\n"); @@ -1495,9 +1539,10 @@ corrupted: index->name, table->name); /* If the force recovery flag is set, and - if the failed index is not the primary index, we - will continue and open other indexes */ - if (srv_force_recovery + if the failed index is not the clustered index, + we will continue and open other indexes */ + if ((srv_force_recovery + || srv_load_corrupted) && !dict_index_is_clust(index)) { error = DB_SUCCESS; goto next_rec; @@ -1812,6 +1857,30 @@ err_exit: err = dict_load_indexes(table, heap, ignore_err); + if (err == DB_INDEX_CORRUPT) { + /* Refuse to load the table if the table has a corrupted + cluster index */ + if (!srv_load_corrupted) { + fprintf(stderr, "InnoDB: Error: Load table "); + ut_print_name(stderr, NULL, TRUE, table->name); + fprintf(stderr, " failed, the table has corrupted" + " clustered indexes. Turn on" + " 'innodb_force_load_corrupted'" + " to drop it\n"); + + dict_table_remove_from_cache(table); + table = NULL; + goto func_exit; + } else { + dict_index_t* clust_index; + clust_index = dict_table_get_first_index(table); + + if (dict_index_is_corrupted(clust_index)) { + table->corrupted = TRUE; + } + } + } + /* Initialize table foreign_child value. Its value could be changed when dict_load_foreigns() is called below */ table->fk_max_recusive_level = 0; @@ -1838,9 +1907,15 @@ err_exit: index = dict_table_get_first_index(table); if (!srv_force_recovery || !index - || !dict_index_is_clust(index)) { + || !dict_index_is_clust(index)) { dict_table_remove_from_cache(table); table = NULL; + } else if (dict_index_is_corrupted(index)) { + + /* It is possible we force to load a corrupted + clustered index if srv_load_corrupted is set. + Mark the table as corrupted in this case */ + table->corrupted = TRUE; } } #if 0 @@ -1867,6 +1942,7 @@ err_exit: mutex_exit(&dict_foreign_err_mutex); } #endif /* 0 */ +func_exit: mem_heap_free(heap); return(table); diff --git a/storage/innobase/handler/ha_innodb.cc b/storage/innobase/handler/ha_innodb.cc index b26a1522cf5..af730f57cb5 100644 --- a/storage/innobase/handler/ha_innodb.cc +++ b/storage/innobase/handler/ha_innodb.cc @@ -1,6 +1,6 @@ /***************************************************************************** -Copyright (c) 2000, 2011, MySQL AB & Innobase Oy. All Rights Reserved. +Copyright (c) 2000, 2011, Oracle and/or its affiliates. All Rights Reserved. Copyright (c) 2008, 2009 Google Inc. Copyright (c) 2009, Percona Inc. @@ -615,6 +615,8 @@ static SHOW_VAR innodb_status_variables[]= { (char*) &export_vars.innodb_buffer_pool_pages_misc, SHOW_LONG}, {"buffer_pool_pages_total", (char*) &export_vars.innodb_buffer_pool_pages_total, SHOW_LONG}, + {"buffer_pool_read_ahead_rnd", + (char*) &export_vars.innodb_buffer_pool_read_ahead_rnd, SHOW_LONG}, {"buffer_pool_read_ahead", (char*) &export_vars.innodb_buffer_pool_read_ahead, SHOW_LONG}, {"buffer_pool_read_ahead_evicted", @@ -991,7 +993,6 @@ convert_error_code_to_mysql( misleading, a new MySQL error code should be introduced */ - case DB_COL_APPEARS_TWICE_IN_INDEX: case DB_CORRUPTION: return(HA_ERR_CRASHED); @@ -1043,6 +1044,10 @@ convert_error_code_to_mysql( #endif /* HA_ERR_TOO_MANY_CONCURRENT_TRXS */ case DB_UNSUPPORTED: return(HA_ERR_UNSUPPORTED); + case DB_INDEX_CORRUPT: + return(HA_ERR_INDEX_CORRUPT); + case DB_UNDO_RECORD_TOO_BIG: + return(HA_ERR_UNDO_REC_TOO_BIG); } } @@ -2074,6 +2079,29 @@ no_db_name: } +/*****************************************************************//** +A wrapper function of innobase_convert_name(), convert a table or +index name to the MySQL system_charset_info (UTF-8) and quote it if needed. +@return pointer to the end of buf */ +static inline +void +innobase_format_name( +/*==================*/ + char* buf, /*!< out: buffer for converted identifier */ + ulint buflen, /*!< in: length of buf, in bytes */ + const char* name, /*!< in: index or table name to format */ + ibool is_index_name) /*!< in: index name */ +{ + const char* bufend; + + bufend = innobase_convert_name(buf, buflen, name, strlen(name), + NULL, !is_index_name); + + ut_ad((ulint) (bufend - buf) < buflen); + + buf[bufend - buf] = '\0'; +} + /**********************************************************************//** Determines if the currently running transaction has been interrupted. @return TRUE if interrupted */ @@ -4089,25 +4117,6 @@ field_in_record_is_null( return(0); } -/**************************************************************//** -Sets a field in a record to SQL NULL. Uses the record format -information in table to track the null bit in record. */ -static inline -void -set_field_in_record_to_null( -/*========================*/ - TABLE* table, /*!< in: MySQL table object */ - Field* field, /*!< in: MySQL field object */ - char* record) /*!< in: a row in MySQL format */ -{ - int null_offset; - - null_offset = (uint) ((char*) field->null_ptr - - (char*) table->record[0]); - - record[null_offset] = record[null_offset] | field->null_bit; -} - /*************************************************************//** InnoDB uses this function to compare two data fields for which the data type is such that we must use MySQL code to compare them. NOTE that the prototype @@ -5690,12 +5699,14 @@ ha_innobase::index_read( index = prebuilt->index; - if (UNIV_UNLIKELY(index == NULL)) { + if (UNIV_UNLIKELY(index == NULL) || dict_index_is_corrupted(index)) { prebuilt->index_usable = FALSE; DBUG_RETURN(HA_ERR_CRASHED); } if (UNIV_UNLIKELY(!prebuilt->index_usable)) { - DBUG_RETURN(HA_ERR_TABLE_DEF_CHANGED); + DBUG_RETURN(dict_index_is_corrupted(index) + ? HA_ERR_INDEX_CORRUPT + : HA_ERR_TABLE_DEF_CHANGED); } /* Note that if the index for which the search template is built is not @@ -5881,10 +5892,33 @@ ha_innobase::change_active_index( prebuilt->index); if (UNIV_UNLIKELY(!prebuilt->index_usable)) { - push_warning_printf(user_thd, MYSQL_ERROR::WARN_LEVEL_WARN, - HA_ERR_TABLE_DEF_CHANGED, - "InnoDB: insufficient history for index %u", - keynr); + if (dict_index_is_corrupted(prebuilt->index)) { + char index_name[MAX_FULL_NAME_LEN + 1]; + char table_name[MAX_FULL_NAME_LEN + 1]; + + innobase_format_name( + index_name, sizeof index_name, + prebuilt->index->name, TRUE); + + innobase_format_name( + table_name, sizeof table_name, + prebuilt->index->table->name, FALSE); + + push_warning_printf( + user_thd, MYSQL_ERROR::WARN_LEVEL_WARN, + HA_ERR_INDEX_CORRUPT, + "InnoDB: Index %s for table %s is" + " marked as corrupted", + index_name, table_name); + DBUG_RETURN(1); + } else { + push_warning_printf( + user_thd, MYSQL_ERROR::WARN_LEVEL_WARN, + HA_ERR_TABLE_DEF_CHANGED, + "InnoDB: insufficient history for index %u", + keynr); + } + /* The caller seems to ignore this. Thus, we must check this again in row_search_for_mysql(). */ DBUG_RETURN(convert_error_code_to_mysql(DB_MISSING_HISTORY, @@ -7545,6 +7579,10 @@ ha_innobase::records_in_range( n_rows = HA_POS_ERROR; goto func_exit; } + if (dict_index_is_corrupted(index)) { + n_rows = HA_ERR_INDEX_CORRUPT; + goto func_exit; + } if (UNIV_UNLIKELY(!row_merge_is_index_usable(prebuilt->trx, index))) { n_rows = HA_ERR_TABLE_DEF_CHANGED; goto func_exit; @@ -7925,6 +7963,8 @@ ha_innobase::info_low( if (flag & HA_STATUS_VARIABLE) { + ulint page_size; + dict_table_stats_lock(ib_table, RW_S_LATCH); n_rows = ib_table->stat_n_rows; @@ -7967,14 +8007,19 @@ ha_innobase::info_low( prebuilt->autoinc_last_value = 0; } + page_size = dict_table_zip_size(ib_table); + if (page_size == 0) { + page_size = UNIV_PAGE_SIZE; + } + stats.records = (ha_rows)n_rows; stats.deleted = 0; - stats.data_file_length = ((ulonglong) - ib_table->stat_clustered_index_size) - * UNIV_PAGE_SIZE; - stats.index_file_length = ((ulonglong) - ib_table->stat_sum_of_other_index_sizes) - * UNIV_PAGE_SIZE; + stats.data_file_length + = ((ulonglong) ib_table->stat_clustered_index_size) + * page_size; + stats.index_file_length = + ((ulonglong) ib_table->stat_sum_of_other_index_sizes) + * page_size; dict_table_stats_unlock(ib_table, RW_S_LATCH); @@ -8206,6 +8251,7 @@ ha_innobase::check( ulint n_rows_in_table = ULINT_UNDEFINED; ibool is_ok = TRUE; ulint old_isolation_level; + ibool table_corrupted; DBUG_ENTER("ha_innobase::check"); DBUG_ASSERT(thd == ha_thd()); @@ -8247,6 +8293,14 @@ ha_innobase::check( prebuilt->trx->isolation_level = TRX_ISO_REPEATABLE_READ; + /* Check whether the table is already marked as corrupted + before running the check table */ + table_corrupted = prebuilt->table->corrupted; + + /* Reset table->corrupted bit so that check table can proceed to + do additional check */ + prebuilt->table->corrupted = FALSE; + /* Enlarge the fatal lock wait timeout during CHECK TABLE. */ mutex_enter(&kernel_mutex); srv_fatal_semaphore_wait_threshold += 7200; /* 2 hours */ @@ -8255,6 +8309,7 @@ ha_innobase::check( for (index = dict_table_get_first_index(prebuilt->table); index != NULL; index = dict_table_get_next_index(index)) { + char index_name[MAX_FULL_NAME_LEN + 1]; #if 0 fputs("Validating index ", stderr); ut_print_name(stderr, trx, FALSE, index->name); @@ -8263,11 +8318,16 @@ ha_innobase::check( if (!btr_validate_index(index, prebuilt->trx)) { is_ok = FALSE; + + innobase_format_name( + index_name, sizeof index_name, + prebuilt->index->name, TRUE); + push_warning_printf(thd, MYSQL_ERROR::WARN_LEVEL_WARN, ER_NOT_KEYFILE, "InnoDB: The B-tree of" - " index '%-.200s' is corrupted.", - index->name); + " index %s is corrupted.", + index_name); continue; } @@ -8280,11 +8340,26 @@ ha_innobase::check( prebuilt->trx, prebuilt->index); if (UNIV_UNLIKELY(!prebuilt->index_usable)) { - push_warning_printf(thd, MYSQL_ERROR::WARN_LEVEL_WARN, - HA_ERR_TABLE_DEF_CHANGED, - "InnoDB: Insufficient history for" - " index '%-.200s'", - index->name); + innobase_format_name( + index_name, sizeof index_name, + prebuilt->index->name, TRUE); + + if (dict_index_is_corrupted(prebuilt->index)) { + push_warning_printf( + user_thd, MYSQL_ERROR::WARN_LEVEL_WARN, + HA_ERR_INDEX_CORRUPT, + "InnoDB: Index %s is marked as" + " corrupted", + index_name); + is_ok = FALSE; + } else { + push_warning_printf( + thd, MYSQL_ERROR::WARN_LEVEL_WARN, + HA_ERR_TABLE_DEF_CHANGED, + "InnoDB: Insufficient history for" + " index %s", + index_name); + } continue; } @@ -8298,12 +8373,19 @@ ha_innobase::check( prebuilt->select_lock_type = LOCK_NONE; if (!row_check_index_for_mysql(prebuilt, index, &n_rows)) { + innobase_format_name( + index_name, sizeof index_name, + index->name, TRUE); + push_warning_printf(thd, MYSQL_ERROR::WARN_LEVEL_WARN, ER_NOT_KEYFILE, "InnoDB: The B-tree of" - " index '%-.200s' is corrupted.", - index->name); + " index %s is corrupted.", + index_name); is_ok = FALSE; + row_mysql_lock_data_dictionary(prebuilt->trx); + dict_set_corrupted(index); + row_mysql_unlock_data_dictionary(prebuilt->trx); } if (thd_killed(user_thd)) { @@ -8330,6 +8412,20 @@ ha_innobase::check( } } + if (table_corrupted) { + /* If some previous operation has marked the table as + corrupted in memory, and has not propagated such to + clustered index, we will do so here */ + index = dict_table_get_first_index(prebuilt->table); + + if (!dict_index_is_corrupted(index)) { + mutex_enter(&dict_sys->mutex); + dict_set_corrupted(index); + mutex_exit(&dict_sys->mutex); + } + prebuilt->table->corrupted = TRUE; + } + /* Restore the original isolation level */ prebuilt->trx->isolation_level = old_isolation_level; @@ -11096,6 +11192,11 @@ static MYSQL_SYSVAR_BOOL(large_prefix, innobase_large_prefix, "Support large index prefix length of REC_VERSION_56_MAX_INDEX_COL_LEN (3072) bytes.", NULL, NULL, FALSE); +static MYSQL_SYSVAR_BOOL(force_load_corrupted, srv_load_corrupted, + PLUGIN_VAR_NOCMDARG | PLUGIN_VAR_READONLY, + "Force InnoDB to load metadata of corrupted table.", + NULL, NULL, FALSE); + static MYSQL_SYSVAR_BOOL(locks_unsafe_for_binlog, innobase_locks_unsafe_for_binlog, PLUGIN_VAR_NOCMDARG | PLUGIN_VAR_READONLY, "Force InnoDB to not use next-key locking, to use only row-level locking.", @@ -11321,6 +11422,11 @@ static MYSQL_SYSVAR_UINT(change_buffering_debug, ibuf_debug, NULL, NULL, 0, 0, 1, 0); #endif /* UNIV_DEBUG || UNIV_IBUF_DEBUG */ +static MYSQL_SYSVAR_BOOL(random_read_ahead, srv_random_read_ahead, + PLUGIN_VAR_NOCMDARG, + "Whether to use read ahead for random access within an extent.", + NULL, NULL, FALSE); + static MYSQL_SYSVAR_ULONG(read_ahead_threshold, srv_read_ahead_threshold, PLUGIN_VAR_RQCMDARG, "Number of pages that must be accessed sequentially for InnoDB to " @@ -11350,6 +11456,7 @@ static struct st_mysql_sys_var* innobase_system_variables[]= { MYSQL_SYSVAR(flush_method), MYSQL_SYSVAR(force_recovery), MYSQL_SYSVAR(large_prefix), + MYSQL_SYSVAR(force_load_corrupted), MYSQL_SYSVAR(locks_unsafe_for_binlog), MYSQL_SYSVAR(lock_wait_timeout), #ifdef UNIV_LOG_ARCHIVE @@ -11389,6 +11496,7 @@ static struct st_mysql_sys_var* innobase_system_variables[]= { #if defined UNIV_DEBUG || defined UNIV_IBUF_DEBUG MYSQL_SYSVAR(change_buffering_debug), #endif /* UNIV_DEBUG || UNIV_IBUF_DEBUG */ + MYSQL_SYSVAR(random_read_ahead), MYSQL_SYSVAR(read_ahead_threshold), MYSQL_SYSVAR(io_capacity), MYSQL_SYSVAR(purge_threads), @@ -11410,7 +11518,8 @@ mysql_declare_plugin(innobase) INNODB_VERSION_SHORT, innodb_status_variables_export,/* status variables */ innobase_system_variables, /* system variables */ - NULL /* reserved */ + NULL, /* reserved */ + 0, /* flags */ }, i_s_innodb_trx, i_s_innodb_locks, diff --git a/storage/innobase/handler/i_s.cc b/storage/innobase/handler/i_s.cc index ad413c3cacd..af168c3f848 100644 --- a/storage/innobase/handler/i_s.cc +++ b/storage/innobase/handler/i_s.cc @@ -638,7 +638,11 @@ UNIV_INTERN struct st_mysql_plugin i_s_innodb_trx = /* reserved for dependency checking */ /* void* */ - STRUCT_FLD(__reserved1, NULL) + STRUCT_FLD(__reserved1, NULL), + + /* Plugin flags */ + /* unsigned long */ + STRUCT_FLD(flags, 0UL), }; /* Fields of the dynamic table INFORMATION_SCHEMA.innodb_locks */ @@ -904,7 +908,11 @@ UNIV_INTERN struct st_mysql_plugin i_s_innodb_locks = /* reserved for dependency checking */ /* void* */ - STRUCT_FLD(__reserved1, NULL) + STRUCT_FLD(__reserved1, NULL), + + /* Plugin flags */ + /* unsigned long */ + STRUCT_FLD(flags, 0UL), }; /* Fields of the dynamic table INFORMATION_SCHEMA.innodb_lock_waits */ @@ -1087,7 +1095,11 @@ UNIV_INTERN struct st_mysql_plugin i_s_innodb_lock_waits = /* reserved for dependency checking */ /* void* */ - STRUCT_FLD(__reserved1, NULL) + STRUCT_FLD(__reserved1, NULL), + + /* Plugin flags */ + /* unsigned long */ + STRUCT_FLD(flags, 0UL), }; /*******************************************************************//** @@ -1420,7 +1432,11 @@ UNIV_INTERN struct st_mysql_plugin i_s_innodb_cmp = /* reserved for dependency checking */ /* void* */ - STRUCT_FLD(__reserved1, NULL) + STRUCT_FLD(__reserved1, NULL), + + /* Plugin flags */ + /* unsigned long */ + STRUCT_FLD(flags, 0UL), }; UNIV_INTERN struct st_mysql_plugin i_s_innodb_cmp_reset = @@ -1470,7 +1486,11 @@ UNIV_INTERN struct st_mysql_plugin i_s_innodb_cmp_reset = /* reserved for dependency checking */ /* void* */ - STRUCT_FLD(__reserved1, NULL) + STRUCT_FLD(__reserved1, NULL), + + /* Plugin flags */ + /* unsigned long */ + STRUCT_FLD(flags, 0UL), }; /* Fields of the dynamic table information_schema.innodb_cmpmem. */ @@ -1711,7 +1731,11 @@ UNIV_INTERN struct st_mysql_plugin i_s_innodb_cmpmem = /* reserved for dependency checking */ /* void* */ - STRUCT_FLD(__reserved1, NULL) + STRUCT_FLD(__reserved1, NULL), + + /* Plugin flags */ + /* unsigned long */ + STRUCT_FLD(flags, 0UL), }; UNIV_INTERN struct st_mysql_plugin i_s_innodb_cmpmem_reset = @@ -1761,7 +1785,11 @@ UNIV_INTERN struct st_mysql_plugin i_s_innodb_cmpmem_reset = /* reserved for dependency checking */ /* void* */ - STRUCT_FLD(__reserved1, NULL) + STRUCT_FLD(__reserved1, NULL), + + /* Plugin flags */ + /* unsigned long */ + STRUCT_FLD(flags, 0UL), }; /*******************************************************************//** diff --git a/storage/innobase/ibuf/ibuf0ibuf.c b/storage/innobase/ibuf/ibuf0ibuf.c index 7d94ebc6438..7f6acb2b042 100644 --- a/storage/innobase/ibuf/ibuf0ibuf.c +++ b/storage/innobase/ibuf/ibuf0ibuf.c @@ -1,6 +1,6 @@ /***************************************************************************** -Copyright (c) 1997, 2010, Innobase Oy. All Rights Reserved. +Copyright (c) 1997, 2011, Oracle and/or its affiliates. All Rights Reserved. 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 the Free Software @@ -402,7 +402,7 @@ ibuf_tree_root_get( block = buf_page_get( IBUF_SPACE_ID, 0, FSP_IBUF_TREE_ROOT_PAGE_NO, RW_X_LATCH, mtr); - buf_block_dbg_add_level(block, SYNC_TREE_NODE); + buf_block_dbg_add_level(block, SYNC_IBUF_TREE_NODE_NEW); root = buf_block_get_frame(block); @@ -549,7 +549,7 @@ ibuf_init_at_db_start(void) block = buf_page_get( IBUF_SPACE_ID, 0, FSP_IBUF_TREE_ROOT_PAGE_NO, RW_X_LATCH, &mtr); - buf_block_dbg_add_level(block, SYNC_TREE_NODE); + buf_block_dbg_add_level(block, SYNC_IBUF_TREE_NODE); root = buf_block_get_frame(block); } @@ -2209,16 +2209,17 @@ ibuf_add_free_page(void) } else { buf_block_t* block = buf_page_get( IBUF_SPACE_ID, 0, page_no, RW_X_LATCH, &mtr); - buf_block_dbg_add_level(block, SYNC_TREE_NODE_NEW); - page = buf_block_get_frame(block); - } + ibuf_enter(&mtr); - ibuf_enter(&mtr); + mutex_enter(&ibuf_mutex); - mutex_enter(&ibuf_mutex); + root = ibuf_tree_root_get(&mtr); - root = ibuf_tree_root_get(&mtr); + buf_block_dbg_add_level(block, SYNC_IBUF_TREE_NODE_NEW); + + page = buf_block_get_frame(block); + } /* Add the page to the free list and update the ibuf size data */ @@ -2332,8 +2333,7 @@ ibuf_remove_free_page(void) block = buf_page_get( IBUF_SPACE_ID, 0, page_no, RW_X_LATCH, &mtr); - buf_block_dbg_add_level(block, SYNC_TREE_NODE); - + buf_block_dbg_add_level(block, SYNC_IBUF_TREE_NODE); page = buf_block_get_frame(block); } @@ -3022,7 +3022,7 @@ ibuf_get_volume_buffered( IBUF_SPACE_ID, 0, prev_page_no, RW_X_LATCH, mtr); - buf_block_dbg_add_level(block, SYNC_TREE_NODE); + buf_block_dbg_add_level(block, SYNC_IBUF_TREE_NODE); prev_page = buf_block_get_frame(block); @@ -3095,7 +3095,7 @@ count_later: IBUF_SPACE_ID, 0, next_page_no, RW_X_LATCH, mtr); - buf_block_dbg_add_level(block, SYNC_TREE_NODE); + buf_block_dbg_add_level(block, SYNC_IBUF_TREE_NODE); next_page = buf_block_get_frame(block); @@ -3333,7 +3333,7 @@ ibuf_set_entry_counter( IBUF_SPACE_ID, 0, prev_page_no, RW_X_LATCH, mtr); - buf_block_dbg_add_level(block, SYNC_TREE_NODE); + buf_block_dbg_add_level(block, SYNC_IBUF_TREE_NODE); prev_page = buf_block_get_frame(block); @@ -4419,6 +4419,7 @@ ibuf_merge_or_delete_for_page( ut_ad(!block || buf_block_get_space(block) == space); ut_ad(!block || buf_block_get_page_no(block) == page_no); ut_ad(!block || buf_block_get_zip_size(block) == zip_size); + ut_ad(!block || buf_block_get_io_fix(block) == BUF_IO_READ); if (srv_force_recovery >= SRV_FORCE_NO_IBUF_MERGE || trx_sys_hdr_page(space, page_no)) { @@ -4571,7 +4572,13 @@ loop: ut_a(success); - buf_block_dbg_add_level(block, SYNC_TREE_NODE); + /* This is a user page (secondary index leaf page), + but we pretend that it is a change buffer page in + order to obey the latching order. This should be OK, + because buffered changes are applied immediately while + the block is io-fixed. Other threads must not try to + latch an io-fixed block. */ + buf_block_dbg_add_level(block, SYNC_IBUF_TREE_NODE); } /* Position pcur in the insert buffer at the first entry for this @@ -4675,7 +4682,12 @@ loop: __FILE__, __LINE__, &mtr); ut_a(success); - buf_block_dbg_add_level(block, SYNC_TREE_NODE); + /* This is a user page (secondary + index leaf page), but it should be OK + to use too low latching order for it, + as the block is io-fixed. */ + buf_block_dbg_add_level( + block, SYNC_IBUF_TREE_NODE); if (!ibuf_restore_pos(space, page_no, search_tuple, diff --git a/storage/innobase/include/btr0btr.h b/storage/innobase/include/btr0btr.h index 5b3e166371d..71e772388a0 100644 --- a/storage/innobase/include/btr0btr.h +++ b/storage/innobase/include/btr0btr.h @@ -199,26 +199,45 @@ btr_block_get_func( ulint mode, /*!< in: latch mode */ const char* file, /*!< in: file name */ ulint line, /*!< in: line where called */ - mtr_t* mtr) /*!< in/out: mtr */ - __attribute__((nonnull)); +# ifdef UNIV_SYNC_DEBUG + const dict_index_t* index, /*!< in: index tree, may be NULL + if it is not an insert buffer tree */ +# endif /* UNIV_SYNC_DEBUG */ + mtr_t* mtr); /*!< in/out: mini-transaction */ +# ifdef UNIV_SYNC_DEBUG +/** Gets a buffer page and declares its latching order level. +@param space tablespace identifier +@param zip_size compressed page size in bytes or 0 for uncompressed pages +@param page_no page number +@param mode latch mode +@param index index tree, may be NULL if not the insert buffer tree +@param mtr mini-transaction handle +@return the block descriptor */ +# define btr_block_get(space,zip_size,page_no,mode,index,mtr) \ + btr_block_get_func(space,zip_size,page_no,mode, \ + __FILE__,__LINE__,index,mtr) +# else /* UNIV_SYNC_DEBUG */ /** Gets a buffer page and declares its latching order level. @param space tablespace identifier @param zip_size compressed page size in bytes or 0 for uncompressed pages @param page_no page number @param mode latch mode +@param idx index tree, may be NULL if not the insert buffer tree @param mtr mini-transaction handle @return the block descriptor */ -# define btr_block_get(space,zip_size,page_no,mode,mtr) \ +# define btr_block_get(space,zip_size,page_no,mode,idx,mtr) \ btr_block_get_func(space,zip_size,page_no,mode,__FILE__,__LINE__,mtr) +# endif /* UNIV_SYNC_DEBUG */ /** Gets a buffer page and declares its latching order level. @param space tablespace identifier @param zip_size compressed page size in bytes or 0 for uncompressed pages @param page_no page number @param mode latch mode +@param idx index tree, may be NULL if not the insert buffer tree @param mtr mini-transaction handle @return the uncompressed page frame */ -# define btr_page_get(space,zip_size,page_no,mode,mtr) \ - buf_block_get_frame(btr_block_get(space,zip_size,page_no,mode,mtr)) +# define btr_page_get(space,zip_size,page_no,mode,idx,mtr) \ + buf_block_get_frame(btr_block_get(space,zip_size,page_no,mode,idx,mtr)) #endif /* !UNIV_HOTBACKUP */ /**************************************************************//** Gets the index id field of a page. @@ -344,8 +363,7 @@ btr_free_root( ulint zip_size, /*!< in: compressed page size in bytes or 0 for uncompressed pages */ ulint root_page_no, /*!< in: root page number */ - mtr_t* mtr); /*!< in: a mini-transaction which has already - been started */ + mtr_t* mtr); /*!< in/out: mini-transaction */ /*************************************************************//** Makes tree one level higher by splitting the root, and inserts the tuple. It is assumed that mtr contains an x-latch on the tree. diff --git a/storage/innobase/include/btr0btr.ic b/storage/innobase/include/btr0btr.ic index ccf41904fd0..1bd22a0ebc6 100644 --- a/storage/innobase/include/btr0btr.ic +++ b/storage/innobase/include/btr0btr.ic @@ -1,6 +1,6 @@ /***************************************************************************** -Copyright (c) 1994, 2010, Innobase Oy. All Rights Reserved. +Copyright (c) 1994, 2011, Oracle and/or its affiliates. All Rights Reserved. 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 the Free Software @@ -48,6 +48,10 @@ btr_block_get_func( ulint mode, /*!< in: latch mode */ const char* file, /*!< in: file name */ ulint line, /*!< in: line where called */ +#ifdef UNIV_SYNC_DEBUG + const dict_index_t* index, /*!< in: index tree, may be NULL + if it is not an insert buffer tree */ +#endif /* UNIV_SYNC_DEBUG */ mtr_t* mtr) /*!< in/out: mtr */ { buf_block_t* block; @@ -57,7 +61,9 @@ btr_block_get_func( if (mode != RW_NO_LATCH) { - buf_block_dbg_add_level(block, SYNC_TREE_NODE); + buf_block_dbg_add_level( + block, index != NULL && dict_index_is_ibuf(index) + ? SYNC_IBUF_TREE_NODE : SYNC_TREE_NODE); } return(block); diff --git a/storage/innobase/include/btr0pcur.h b/storage/innobase/include/btr0pcur.h index 6c11c973fc9..f605c476844 100644 --- a/storage/innobase/include/btr0pcur.h +++ b/storage/innobase/include/btr0pcur.h @@ -1,6 +1,6 @@ /***************************************************************************** -Copyright (c) 1996, 2010, Innobase Oy. All Rights Reserved. +Copyright (c) 1996, 2011, Oracle and/or its affiliates. All Rights Reserved. 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 the Free Software @@ -244,18 +244,6 @@ btr_pcur_restore_position_func( mtr_t* mtr); /*!< in: mtr */ #define btr_pcur_restore_position(l,cur,mtr) \ btr_pcur_restore_position_func(l,cur,__FILE__,__LINE__,mtr) -/**************************************************************//** -If the latch mode of the cursor is BTR_LEAF_SEARCH or BTR_LEAF_MODIFY, -releases the page latch and bufferfix reserved by the cursor. -NOTE! In the case of BTR_LEAF_MODIFY, there should not exist changes -made by the current mini-transaction to the data protected by the -cursor latch, as then the latch must not be released until mtr_commit. */ -UNIV_INTERN -void -btr_pcur_release_leaf( -/*==================*/ - btr_pcur_t* cursor, /*!< in: persistent cursor */ - mtr_t* mtr); /*!< in: mtr */ /*********************************************************//** Gets the rel_pos field for a cursor whose position has been stored. @return BTR_PCUR_ON, ... */ @@ -266,10 +254,9 @@ btr_pcur_get_rel_pos( const btr_pcur_t* cursor);/*!< in: persistent cursor */ /**************************************************************//** Commits the mtr and sets the pcur latch mode to BTR_NO_LATCHES, -that is, the cursor becomes detached. If there have been modifications -to the page where pcur is positioned, this can be used instead of -btr_pcur_release_leaf. Function btr_pcur_store_position should be used -before calling this, if restoration of cursor is wanted later. */ +that is, the cursor becomes detached. +Function btr_pcur_store_position should be used before calling this, +if restoration of cursor is wanted later. */ UNIV_INLINE void btr_pcur_commit_specify_mtr( diff --git a/storage/innobase/include/btr0pcur.ic b/storage/innobase/include/btr0pcur.ic index 59fdb21824b..d86601e5a32 100644 --- a/storage/innobase/include/btr0pcur.ic +++ b/storage/innobase/include/btr0pcur.ic @@ -1,6 +1,6 @@ /***************************************************************************** -Copyright (c) 1996, 2010, Innobase Oy. All Rights Reserved. +Copyright (c) 1996, 2011, Oracle and/or its affiliates. All Rights Reserved. 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 the Free Software @@ -369,10 +369,9 @@ btr_pcur_move_to_next( /**************************************************************//** Commits the mtr and sets the pcur latch mode to BTR_NO_LATCHES, -that is, the cursor becomes detached. If there have been modifications -to the page where pcur is positioned, this can be used instead of -btr_pcur_release_leaf. Function btr_pcur_store_position should be used -before calling this, if restoration of cursor is wanted later. */ +that is, the cursor becomes detached. +Function btr_pcur_store_position should be used before calling this, +if restoration of cursor is wanted later. */ UNIV_INLINE void btr_pcur_commit_specify_mtr( diff --git a/storage/innobase/include/buf0buddy.h b/storage/innobase/include/buf0buddy.h index b255d8c9351..2d7d6146092 100644 --- a/storage/innobase/include/buf0buddy.h +++ b/storage/innobase/include/buf0buddy.h @@ -1,6 +1,6 @@ /***************************************************************************** -Copyright (c) 2006, 2009, Innobase Oy. All Rights Reserved. +Copyright (c) 2006, 2011, Oracle and/or its affiliates. All Rights Reserved. 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 the Free Software @@ -37,37 +37,37 @@ Created December 2006 by Marko Makela /**********************************************************************//** Allocate a block. The thread calling this function must hold buf_pool->mutex and must not hold buf_pool->zip_mutex or any -block->mutex. The buf_pool->mutex may only be released and reacquired -if lru != NULL. This function should only be used for allocating -compressed page frames or control blocks (buf_page_t). Allocated -control blocks must be properly initialized immediately after -buf_buddy_alloc() has returned the memory, before releasing -buf_pool->mutex. -@return allocated block, possibly NULL if lru == NULL */ +block->mutex. The buf_pool->mutex may be released and reacquired. +This function should only be used for allocating compressed page frames. +@return allocated block, never NULL */ UNIV_INLINE -void* +byte* buf_buddy_alloc( /*============*/ - buf_pool_t* buf_pool, - /*!< buffer pool in which the block resides */ - ulint size, /*!< in: block size, up to UNIV_PAGE_SIZE */ - ibool* lru) /*!< in: pointer to a variable that will be assigned - TRUE if storage was allocated from the LRU list - and buf_pool->mutex was temporarily released, - or NULL if the LRU list should not be used */ - __attribute__((malloc)); + buf_pool_t* buf_pool, /*!< in/out: buffer pool in which + the page resides */ + ulint size, /*!< in: compressed page size + (between PAGE_ZIP_MIN_SIZE and + UNIV_PAGE_SIZE) */ + ibool* lru) /*!< in: pointer to a variable + that will be assigned TRUE if + storage was allocated from the + LRU list and buf_pool->mutex was + temporarily released */ + __attribute__((malloc, nonnull)); /**********************************************************************//** -Release a block. */ +Deallocate a block. */ UNIV_INLINE void buf_buddy_free( /*===========*/ - buf_pool_t* buf_pool, - /*!< buffer pool in which the block resides */ - void* buf, /*!< in: block to be freed, must not be - pointed to by the buffer pool */ - ulint size) /*!< in: block size, up to UNIV_PAGE_SIZE */ + buf_pool_t* buf_pool, /*!< in/out: buffer pool in which + the block resides */ + void* buf, /*!< in: block to be freed, must not + be pointed to by the buffer pool */ + ulint size) /*!< in: block size, + up to UNIV_PAGE_SIZE */ __attribute__((nonnull)); #ifndef UNIV_NONINL diff --git a/storage/innobase/include/buf0buddy.ic b/storage/innobase/include/buf0buddy.ic index e50c33ea15a..b8281f7341a 100644 --- a/storage/innobase/include/buf0buddy.ic +++ b/storage/innobase/include/buf0buddy.ic @@ -1,6 +1,6 @@ /***************************************************************************** -Copyright (c) 2006, 2009, Innobase Oy. All Rights Reserved. +Copyright (c) 2006, 2011, Oracle and/or its affiliates. All Rights Reserved. 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 the Free Software @@ -36,21 +36,21 @@ Created December 2006 by Marko Makela /**********************************************************************//** Allocate a block. The thread calling this function must hold buf_pool->mutex and must not hold buf_pool->zip_mutex or any block->mutex. -The buf_pool->mutex may only be released and reacquired if lru != NULL. -@return allocated block, possibly NULL if lru==NULL */ +The buf_pool_mutex may be released and reacquired. +@return allocated block, never NULL */ UNIV_INTERN void* buf_buddy_alloc_low( /*================*/ - buf_pool_t* buf_pool, - /*!< in: buffer pool in which the page resides */ - ulint i, /*!< in: index of buf_pool->zip_free[], - or BUF_BUDDY_SIZES */ - ibool* lru) /*!< in: pointer to a variable that will be assigned - TRUE if storage was allocated from the LRU list - and buf_pool->mutex was temporarily released, - or NULL if the LRU list should not be used */ - __attribute__((malloc)); + buf_pool_t* buf_pool, /*!< in/out: buffer pool instance */ + ulint i, /*!< in: index of buf_pool->zip_free[], + or BUF_BUDDY_SIZES */ + ibool* lru) /*!< in: pointer to a variable that + will be assigned TRUE if storage was + allocated from the LRU list and + buf_pool->mutex was temporarily + released */ + __attribute__((malloc, nonnull)); /**********************************************************************//** Deallocate a block. */ @@ -77,6 +77,8 @@ buf_buddy_get_slot( ulint i; ulint s; + ut_ad(size >= PAGE_ZIP_MIN_SIZE); + for (i = 0, s = BUF_BUDDY_LOW; s < size; i++, s <<= 1) { } @@ -87,31 +89,31 @@ buf_buddy_get_slot( /**********************************************************************//** Allocate a block. The thread calling this function must hold buf_pool->mutex and must not hold buf_pool->zip_mutex or any -block->mutex. The buf_pool->mutex may only be released and reacquired -if lru != NULL. This function should only be used for allocating -compressed page frames or control blocks (buf_page_t). Allocated -control blocks must be properly initialized immediately after -buf_buddy_alloc() has returned the memory, before releasing -buf_pool->mutex. -@return allocated block, possibly NULL if lru == NULL */ +block->mutex. The buf_pool->mutex may be released and reacquired. +This function should only be used for allocating compressed page frames. +@return allocated block, never NULL */ UNIV_INLINE -void* +byte* buf_buddy_alloc( /*============*/ - buf_pool_t* buf_pool, /*!< in: buffer pool in which + buf_pool_t* buf_pool, /*!< in/out: buffer pool in which the page resides */ - ulint size, /*!< in: block size, up to - UNIV_PAGE_SIZE */ + ulint size, /*!< in: compressed page size + (between PAGE_ZIP_MIN_SIZE and + UNIV_PAGE_SIZE) */ ibool* lru) /*!< in: pointer to a variable that will be assigned TRUE if storage was allocated from the LRU list and buf_pool->mutex was - temporarily released, or NULL if - the LRU list should not be used */ + temporarily released */ { ut_ad(buf_pool_mutex_own(buf_pool)); + ut_ad(ut_is_2pow(size)); + ut_ad(size >= PAGE_ZIP_MIN_SIZE); + ut_ad(size <= UNIV_PAGE_SIZE); - return(buf_buddy_alloc_low(buf_pool, buf_buddy_get_slot(size), lru)); + return((byte*) buf_buddy_alloc_low(buf_pool, buf_buddy_get_slot(size), + lru)); } /**********************************************************************//** @@ -120,13 +122,17 @@ UNIV_INLINE void buf_buddy_free( /*===========*/ - buf_pool_t* buf_pool, /*!< in: buffer pool instance */ - void* buf, /*!< in: block to be freed, must not be - pointed to by the buffer pool */ - ulint size) /*!< in: block size, up to - UNIV_PAGE_SIZE */ + buf_pool_t* buf_pool, /*!< in/out: buffer pool in which + the block resides */ + void* buf, /*!< in: block to be freed, must not + be pointed to by the buffer pool */ + ulint size) /*!< in: block size, + up to UNIV_PAGE_SIZE */ { ut_ad(buf_pool_mutex_own(buf_pool)); + ut_ad(ut_is_2pow(size)); + ut_ad(size >= PAGE_ZIP_MIN_SIZE); + ut_ad(size <= UNIV_PAGE_SIZE); buf_buddy_free_low(buf_pool, buf, buf_buddy_get_slot(size)); } diff --git a/storage/innobase/include/buf0buf.h b/storage/innobase/include/buf0buf.h index d83d484bace..ccebb69a4fe 100644 --- a/storage/innobase/include/buf0buf.h +++ b/storage/innobase/include/buf0buf.h @@ -147,6 +147,8 @@ struct buf_pool_info_struct{ ulint n_pages_created; /*!< buf_pool->n_pages_created */ ulint n_pages_written; /*!< buf_pool->n_pages_written */ ulint n_page_gets; /*!< buf_pool->n_page_gets */ + ulint n_ra_pages_read_rnd; /*!< buf_pool->n_ra_pages_read_rnd, + number of pages readahead */ ulint n_ra_pages_read; /*!< buf_pool->n_ra_pages_read, number of pages readahead */ ulint n_ra_pages_evicted; /*!< buf_pool->n_ra_pages_evicted, @@ -171,6 +173,8 @@ struct buf_pool_info_struct{ last printout */ /* Statistics about read ahead algorithm. */ + double pages_readahead_rnd_rate;/*!< random readahead rate in pages per + second */ double pages_readahead_rate; /*!< readahead rate in pages per second */ double pages_evicted_rate; /*!< rate of readahead page evicted @@ -246,12 +250,6 @@ buf_relocate( BUF_BLOCK_ZIP_DIRTY or BUF_BLOCK_ZIP_PAGE */ buf_page_t* dpage) /*!< in/out: destination control block */ __attribute__((nonnull)); -/********************************************************************//** -Resizes the buffer pool. */ -UNIV_INTERN -void -buf_pool_resize(void); -/*=================*/ /*********************************************************************//** Gets the current size of buffer buf_pool in bytes. @return size in bytes */ @@ -275,6 +273,23 @@ ib_uint64_t buf_pool_get_oldest_modification(void); /*==================================*/ /********************************************************************//** +Allocates a buf_page_t descriptor. This function must succeed. In case +of failure we assert in this function. */ +UNIV_INLINE +buf_page_t* +buf_page_alloc_descriptor(void) +/*===========================*/ + __attribute__((malloc)); +/********************************************************************//** +Free a buf_page_t descriptor. */ +UNIV_INLINE +void +buf_page_free_descriptor( +/*=====================*/ + buf_page_t* bpage) /*!< in: bpage descriptor to free. */ + __attribute__((nonnull)); + +/********************************************************************//** Allocates a buffer block. @return own: the allocated block, in state BUF_BLOCK_MEMORY */ UNIV_INTERN @@ -531,6 +546,18 @@ buf_block_get_freed_page_clock( __attribute__((pure)); /********************************************************************//** +Tells if a block is still close enough to the MRU end of the LRU list +meaning that it is not in danger of getting evicted and also implying +that it has been accessed recently. +Note that this is for heuristics only and does not reserve buffer pool +mutex. +@return TRUE if block is close to MRU end of LRU */ +UNIV_INLINE +ibool +buf_page_peek_if_young( +/*===================*/ + const buf_page_t* bpage); /*!< in: block */ +/********************************************************************//** Recommends a move of a block to the start of the LRU list if there is danger of dropping from the buffer pool. NOTE: does not reserve the buffer pool mutex. @@ -1196,7 +1223,7 @@ ulint buf_get_free_list_len(void); /*=======================*/ -/******************************************************************** +/********************************************************************//** Determine if a block is a sentinel for a buffer pool watch. @return TRUE if a sentinel for a buffer pool watch, FALSE if not */ UNIV_INTERN @@ -1569,6 +1596,8 @@ struct buf_pool_stat_struct{ ulint n_pages_written;/*!< number write operations */ ulint n_pages_created;/*!< number of pages created in the pool with no read */ + ulint n_ra_pages_read_rnd;/*!< number of pages read in + as part of random read ahead */ ulint n_ra_pages_read;/*!< number of pages read in as part of read ahead */ ulint n_ra_pages_evicted;/*!< number of read ahead @@ -1708,7 +1737,7 @@ struct buf_pool_struct{ UT_LIST_BASE_NODE_T(buf_page_t) LRU; /*!< base node of the LRU list */ buf_page_t* LRU_old; /*!< pointer to the about - buf_LRU_old_ratio/BUF_LRU_OLD_RATIO_DIV + LRU_old_ratio/BUF_LRU_OLD_RATIO_DIV oldest blocks in the LRU list; NULL if LRU length less than BUF_LRU_OLD_MIN_LEN; @@ -1732,8 +1761,10 @@ struct buf_pool_struct{ frames and buf_page_t descriptors of blocks that exist in the buffer pool only in compressed form. */ /* @{ */ +#if defined UNIV_DEBUG || defined UNIV_BUF_DEBUG UT_LIST_BASE_NODE_T(buf_page_t) zip_clean; /*!< unmodified compressed pages */ +#endif /* UNIV_DEBUG || UNIV_BUF_DEBUG */ UT_LIST_BASE_NODE_T(buf_page_t) zip_free[BUF_BUDDY_SIZES]; /*!< buddy free lists */ diff --git a/storage/innobase/include/buf0buf.ic b/storage/innobase/include/buf0buf.ic index e2e83de0a78..b65b5133c15 100644 --- a/storage/innobase/include/buf0buf.ic +++ b/storage/innobase/include/buf0buf.ic @@ -125,6 +125,29 @@ buf_block_get_freed_page_clock( } /********************************************************************//** +Tells if a block is still close enough to the MRU end of the LRU list +meaning that it is not in danger of getting evicted and also implying +that it has been accessed recently. +Note that this is for heuristics only and does not reserve buffer pool +mutex. +@return TRUE if block is close to MRU end of LRU */ +UNIV_INLINE +ibool +buf_page_peek_if_young( +/*===================*/ + const buf_page_t* bpage) /*!< in: block */ +{ + buf_pool_t* buf_pool = buf_pool_from_bpage(bpage); + + /* FIXME: bpage->freed_page_clock is 31 bits */ + return((buf_pool->freed_page_clock & ((1UL << 31) - 1)) + < ((ulint) bpage->freed_page_clock + + (buf_pool->curr_size + * (BUF_LRU_OLD_RATIO_DIV - buf_pool->LRU_old_ratio) + / (BUF_LRU_OLD_RATIO_DIV * 4)))); +} + +/********************************************************************//** Recommends a move of a block to the start of the LRU list if there is danger of dropping from the buffer pool. NOTE: does not reserve the buffer pool mutex. @@ -154,12 +177,7 @@ buf_page_peek_if_too_old( buf_pool->stat.n_pages_not_made_young++; return(FALSE); } else { - /* FIXME: bpage->freed_page_clock is 31 bits */ - return((buf_pool->freed_page_clock & ((1UL << 31) - 1)) - > ((ulint) bpage->freed_page_clock - + (buf_pool->curr_size - * (BUF_LRU_OLD_RATIO_DIV - buf_pool->LRU_old_ratio) - / (BUF_LRU_OLD_RATIO_DIV * 4)))); + return(!buf_page_peek_if_young(bpage)); } } @@ -754,6 +772,35 @@ buf_block_get_lock_hash_val( } /********************************************************************//** +Allocates a buf_page_t descriptor. This function must succeed. In case +of failure we assert in this function. +@return: the allocated descriptor. */ +UNIV_INLINE +buf_page_t* +buf_page_alloc_descriptor(void) +/*===========================*/ +{ + buf_page_t* bpage; + + bpage = (buf_page_t*) ut_malloc(sizeof *bpage); + ut_d(memset(bpage, 0, sizeof *bpage)); + UNIV_MEM_ALLOC(bpage, sizeof *bpage); + + return(bpage); +} + +/********************************************************************//** +Free a buf_page_t descriptor. */ +UNIV_INLINE +void +buf_page_free_descriptor( +/*=====================*/ + buf_page_t* bpage) /*!< in: bpage descriptor to free. */ +{ + ut_free(bpage); +} + +/********************************************************************//** Frees a buffer block which does not contain a file page. */ UNIV_INLINE void diff --git a/storage/innobase/include/buf0lru.h b/storage/innobase/include/buf0lru.h index 9b150188b03..eb40621abbe 100644 --- a/storage/innobase/include/buf0lru.h +++ b/storage/innobase/include/buf0lru.h @@ -1,6 +1,6 @@ /***************************************************************************** -Copyright (c) 1995, 2009, Innobase Oy. All Rights Reserved. +Copyright (c) 1995, 2011, Oracle and/or its affiliates. All Rights Reserved. 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 the Free Software @@ -30,18 +30,6 @@ Created 11/5/1995 Heikki Tuuri #include "ut0byte.h" #include "buf0types.h" -/** The return type of buf_LRU_free_block() */ -enum buf_lru_free_block_status { - /** freed */ - BUF_LRU_FREED = 0, - /** not freed because the caller asked to remove the - uncompressed frame but the control block cannot be - relocated */ - BUF_LRU_CANNOT_RELOCATE, - /** not freed because of some other reason */ - BUF_LRU_NOT_FREED -}; - /******************************************************************//** Tries to remove LRU flushed blocks from the end of the LRU list and put them to the free list. This is beneficial for the efficiency of the insert buffer @@ -85,6 +73,7 @@ void buf_LRU_invalidate_tablespace( /*==========================*/ ulint id); /*!< in: space id */ +#if defined UNIV_DEBUG || defined UNIV_BUF_DEBUG /********************************************************************//** Insert a compressed block into buf_pool->zip_clean in the LRU order. */ UNIV_INTERN @@ -92,22 +81,22 @@ void buf_LRU_insert_zip_clean( /*=====================*/ buf_page_t* bpage); /*!< in: pointer to the block in question */ +#endif /* UNIV_DEBUG || UNIV_BUF_DEBUG */ /******************************************************************//** Try to free a block. If bpage is a descriptor of a compressed-only page, the descriptor object will be freed as well. -NOTE: If this function returns BUF_LRU_FREED, it will temporarily +NOTE: If this function returns TRUE, it will temporarily release buf_pool->mutex. Furthermore, the page frame will no longer be accessible via bpage. The caller must hold buf_pool->mutex and buf_page_get_mutex(bpage) and release these two mutexes after the call. No other buf_page_get_mutex() may be held when calling this function. -@return BUF_LRU_FREED if freed, BUF_LRU_CANNOT_RELOCATE or -BUF_LRU_NOT_FREED otherwise. */ +@return TRUE if freed, FALSE otherwise. */ UNIV_INTERN -enum buf_lru_free_block_status +ibool buf_LRU_free_block( /*===============*/ buf_page_t* bpage, /*!< in: block to be freed */ @@ -195,7 +184,7 @@ buf_LRU_make_block_old( /*===================*/ buf_page_t* bpage); /*!< in: control block */ /**********************************************************************//** -Updates buf_LRU_old_ratio. +Updates buf_pool->LRU_old_ratio. @return updated old_pct */ UNIV_INTERN ulint @@ -204,7 +193,7 @@ buf_LRU_old_ratio_update( uint old_pct,/*!< in: Reserve this percentage of the buffer pool for "old" blocks. */ ibool adjust);/*!< in: TRUE=adjust the LRU list; - FALSE=just assign buf_LRU_old_ratio + FALSE=just assign buf_pool->LRU_old_ratio during the initialization of InnoDB */ /********************************************************************//** Update the historical stats that we are collecting for LRU eviction @@ -214,6 +203,17 @@ void buf_LRU_stat_update(void); /*=====================*/ +/******************************************************************//** +Remove one page from LRU list and put it to free list */ +UNIV_INTERN +void +buf_LRU_free_one_page( +/*==================*/ + buf_page_t* bpage) /*!< in/out: block, must contain a file page and + be in a state where it can be freed; there + may or may not be a hash index to the page */ + __attribute__((nonnull)); + #if defined UNIV_DEBUG || defined UNIV_BUF_DEBUG /**********************************************************************//** Validates the LRU list. @@ -233,18 +233,15 @@ buf_LRU_print(void); #endif /* UNIV_DEBUG_PRINT || UNIV_DEBUG || UNIV_BUF_DEBUG */ /** @name Heuristics for detecting index scan @{ */ -/** Reserve this much/BUF_LRU_OLD_RATIO_DIV of the buffer pool for -"old" blocks. Protected by buf_pool->mutex. */ -extern uint buf_LRU_old_ratio; -/** The denominator of buf_LRU_old_ratio. */ +/** The denominator of buf_pool->LRU_old_ratio. */ #define BUF_LRU_OLD_RATIO_DIV 1024 -/** Maximum value of buf_LRU_old_ratio. +/** Maximum value of buf_pool->LRU_old_ratio. @see buf_LRU_old_adjust_len -@see buf_LRU_old_ratio_update */ +@see buf_pool->LRU_old_ratio_update */ #define BUF_LRU_OLD_RATIO_MAX BUF_LRU_OLD_RATIO_DIV -/** Minimum value of buf_LRU_old_ratio. +/** Minimum value of buf_pool->LRU_old_ratio. @see buf_LRU_old_adjust_len -@see buf_LRU_old_ratio_update +@see buf_pool->LRU_old_ratio_update The minimum must exceed (BUF_LRU_OLD_TOLERANCE + 5) * BUF_LRU_OLD_RATIO_DIV / BUF_LRU_OLD_MIN_LEN. */ #define BUF_LRU_OLD_RATIO_MIN 51 diff --git a/storage/innobase/include/buf0rea.h b/storage/innobase/include/buf0rea.h index cdf6cdba3d1..cd5eff66ee8 100644 --- a/storage/innobase/include/buf0rea.h +++ b/storage/innobase/include/buf0rea.h @@ -43,6 +43,31 @@ buf_read_page( ulint zip_size,/*!< in: compressed page size in bytes, or 0 */ ulint offset);/*!< in: page number */ /********************************************************************//** +Applies a random read-ahead in buf_pool if there are at least a threshold +value of accessed pages from the random read-ahead area. Does not read any +page, not even the one at the position (space, offset), if the read-ahead +mechanism is not activated. NOTE 1: the calling thread may own latches on +pages: to avoid deadlocks this function must be written such that it cannot +end up waiting for these latches! NOTE 2: the calling thread must want +access to the page given: this rule is set to prevent unintended read-aheads +performed by ibuf routines, a situation which could result in a deadlock if +the OS does not support asynchronous i/o. +@return number of page read requests issued; NOTE that if we read ibuf +pages, it may happen that the page at the given page number does not +get read even if we return a positive value! +@return number of page read requests issued */ +UNIV_INTERN +ulint +buf_read_ahead_random( +/*==================*/ + ulint space, /*!< in: space id */ + ulint zip_size, /*!< in: compressed page size in bytes, + or 0 */ + ulint offset, /*!< in: page number of a page which + the current thread wants to access */ + ibool inside_ibuf); /*!< in: TRUE if we are inside ibuf + routine */ +/********************************************************************//** Applies linear read-ahead if in the buf_pool the page is a border page of a linear read-ahead area and all the pages in the area have been accessed. Does not read any page if the read-ahead mechanism is not activated. Note diff --git a/storage/innobase/include/buf0types.h b/storage/innobase/include/buf0types.h index a2175098704..0cc2defb3ff 100644 --- a/storage/innobase/include/buf0types.h +++ b/storage/innobase/include/buf0types.h @@ -1,6 +1,6 @@ /***************************************************************************** -Copyright (c) 1995, 2009, Innobase Oy. All Rights Reserved. +Copyright (c) 1995, 2011, Oracle and/or its affiliates. All Rights Reserved 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 the Free Software @@ -26,6 +26,8 @@ Created 11/17/1995 Heikki Tuuri #ifndef buf0types_h #define buf0types_h +#include "page0types.h" + /** Buffer page (uncompressed or compressed) */ typedef struct buf_page_struct buf_page_t; /** Buffer block for which an uncompressed page exists */ @@ -60,17 +62,10 @@ enum buf_io_fix { /** Parameters of binary buddy system for compressed pages (buf0buddy.h) */ /* @{ */ -#if UNIV_WORD_SIZE <= 4 /* 32-bit system */ -/** Base-2 logarithm of the smallest buddy block size */ -# define BUF_BUDDY_LOW_SHIFT 6 -#else /* 64-bit system */ -/** Base-2 logarithm of the smallest buddy block size */ -# define BUF_BUDDY_LOW_SHIFT 7 -#endif +#define BUF_BUDDY_LOW_SHIFT PAGE_ZIP_MIN_SIZE_SHIFT + #define BUF_BUDDY_LOW (1 << BUF_BUDDY_LOW_SHIFT) - /*!< minimum block size in the binary - buddy system; must be at least - sizeof(buf_page_t) */ + #define BUF_BUDDY_SIZES (UNIV_PAGE_SIZE_SHIFT - BUF_BUDDY_LOW_SHIFT) /*!< number of buddy sizes */ diff --git a/storage/innobase/include/db0err.h b/storage/innobase/include/db0err.h index 74a2354bce3..e0952f0709d 100644 --- a/storage/innobase/include/db0err.h +++ b/storage/innobase/include/db0err.h @@ -1,6 +1,6 @@ /***************************************************************************** -Copyright (c) 1996, 2009, Innobase Oy. All Rights Reserved. +Copyright (c) 1996, 2011, Oracle and/or its affiliates. All Rights Reserved. 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 the Free Software @@ -64,8 +64,6 @@ enum db_err { DB_CANNOT_ADD_CONSTRAINT, /* adding a foreign key constraint to a table failed */ DB_CORRUPTION, /* data structure corruption noticed */ - DB_COL_APPEARS_TWICE_IN_INDEX, /* InnoDB cannot handle an index - where same column appears twice */ DB_CANNOT_DROP_CONSTRAINT, /* dropping a foreign key constraint from a table failed */ DB_NO_SAVEPOINT, /* no savepoint exists with the given @@ -112,6 +110,8 @@ enum db_err { foreign keys as its prefix columns */ DB_TOO_BIG_INDEX_COL, /* index column size exceeds maximum limit */ + DB_INDEX_CORRUPT, /* we have corrupted index */ + DB_UNDO_RECORD_TOO_BIG, /* the undo log record is too big */ /* The following are partial failure codes */ DB_FAIL = 1000, diff --git a/storage/innobase/include/dict0boot.h b/storage/innobase/include/dict0boot.h index 22df826da65..5d136862bc6 100644 --- a/storage/innobase/include/dict0boot.h +++ b/storage/innobase/include/dict0boot.h @@ -137,8 +137,10 @@ dict_create(void); header is created */ /*-------------------------------------------------------------*/ -/* The field number of the page number field in the sys_indexes table -clustered index */ +/* The field numbers in the SYS_TABLES clustered index */ +#define DICT_SYS_TABLES_TYPE_FIELD 5 + +/* The field numbers in the SYS_INDEXES clustered index */ #define DICT_SYS_INDEXES_PAGE_NO_FIELD 8 #define DICT_SYS_INDEXES_SPACE_NO_FIELD 7 #define DICT_SYS_INDEXES_TYPE_FIELD 6 diff --git a/storage/innobase/include/dict0dict.h b/storage/innobase/include/dict0dict.h index f979d0fcc96..57e51cbb6ba 100644 --- a/storage/innobase/include/dict0dict.h +++ b/storage/innobase/include/dict0dict.h @@ -585,6 +585,20 @@ dict_table_get_next_index( # define dict_table_get_next_index(index) UT_LIST_GET_NEXT(indexes, index) #endif /* UNIV_DEBUG */ #endif /* !UNIV_HOTBACKUP */ + +/* Skip corrupted index */ +#define dict_table_skip_corrupt_index(index) \ + while (index && dict_index_is_corrupted(index)) { \ + index = dict_table_get_next_index(index); \ + } + +/* Get the next non-corrupt index */ +#define dict_table_next_uncorrupted_index(index) \ +do { \ + index = dict_table_get_next_index(index); \ + dict_table_skip_corrupt_index(index); \ +} while (0) + /********************************************************************//** Check whether the index is the clustered index. @return nonzero for clustered index, zero for other indexes */ @@ -593,7 +607,7 @@ ulint dict_index_is_clust( /*================*/ const dict_index_t* index) /*!< in: index */ - __attribute__((pure)); + __attribute__((nonnull, pure, warn_unused_result)); /********************************************************************//** Check whether the index is unique. @return nonzero for unique index, zero for other indexes */ @@ -602,7 +616,7 @@ ulint dict_index_is_unique( /*=================*/ const dict_index_t* index) /*!< in: index */ - __attribute__((pure)); + __attribute__((nonnull, pure, warn_unused_result)); /********************************************************************//** Check whether the index is the insert buffer tree. @return nonzero for insert buffer, zero for other indexes */ @@ -611,7 +625,7 @@ ulint dict_index_is_ibuf( /*===============*/ const dict_index_t* index) /*!< in: index */ - __attribute__((pure)); + __attribute__((nonnull, pure, warn_unused_result)); /********************************************************************//** Check whether the index is a secondary index or the insert buffer tree. @return nonzero for insert buffer, zero for other indexes */ @@ -620,7 +634,7 @@ ulint dict_index_is_sec_or_ibuf( /*======================*/ const dict_index_t* index) /*!< in: index */ - __attribute__((pure)); + __attribute__((nonnull, pure, warn_unused_result)); /********************************************************************//** Gets the number of user-defined columns in a table in the dictionary @@ -630,7 +644,8 @@ UNIV_INLINE ulint dict_table_get_n_user_cols( /*=======================*/ - const dict_table_t* table); /*!< in: table */ + const dict_table_t* table) /*!< in: table */ + __attribute__((nonnull, pure, warn_unused_result)); /********************************************************************//** Gets the number of system columns in a table in the dictionary cache. @return number of system (e.g., ROW_ID) columns of a table */ @@ -638,7 +653,8 @@ UNIV_INLINE ulint dict_table_get_n_sys_cols( /*======================*/ - const dict_table_t* table); /*!< in: table */ + const dict_table_t* table) /*!< in: table */ + __attribute__((nonnull, pure, warn_unused_result)); /********************************************************************//** Gets the number of all columns (also system) in a table in the dictionary cache. @@ -647,7 +663,8 @@ UNIV_INLINE ulint dict_table_get_n_cols( /*==================*/ - const dict_table_t* table); /*!< in: table */ + const dict_table_t* table) /*!< in: table */ + __attribute__((nonnull, pure, warn_unused_result)); #ifdef UNIV_DEBUG /********************************************************************//** Gets the nth column of a table. @@ -1243,6 +1260,57 @@ void dict_close(void); /*============*/ +/**********************************************************************//** +Check whether the table is corrupted. +@return nonzero for corrupted table, zero for valid tables */ +UNIV_INLINE +ulint +dict_table_is_corrupted( +/*====================*/ + const dict_table_t* table) /*!< in: table */ + __attribute__((nonnull, pure, warn_unused_result)); + +/**********************************************************************//** +Check whether the index is corrupted. +@return nonzero for corrupted index, zero for valid indexes */ +UNIV_INLINE +ulint +dict_index_is_corrupted( +/*====================*/ + const dict_index_t* index) /*!< in: index */ + __attribute__((nonnull, pure, warn_unused_result)); + +/**********************************************************************//** +Flags an index and table corrupted both in the data dictionary cache +and in the system table SYS_INDEXES. */ +UNIV_INTERN +void +dict_set_corrupted( +/*===============*/ + dict_index_t* index) /*!< in/out: index */ + UNIV_COLD __attribute__((nonnull)); + +/**********************************************************************//** +Flags an index corrupted in the data dictionary cache only. This +is used mostly to mark a corrupted index when index's own dictionary +is corrupted, and we force to load such index for repair purpose */ +UNIV_INTERN +void +dict_set_corrupted_index_cache_only( +/*================================*/ + dict_index_t* index, /*!< in/out: index */ + dict_table_t* table); /*!< in/out: table */ + +/**********************************************************************//** +Flags a table with specified space_id corrupted in the table dictionary +cache. +@return TRUE if successful */ +UNIV_INTERN +ibool +dict_set_corrupted_by_space( +/*========================*/ + ulint space_id); /*!< in: space ID */ + #ifndef UNIV_NONINL #include "dict0dict.ic" #endif diff --git a/storage/innobase/include/dict0dict.ic b/storage/innobase/include/dict0dict.ic index 59811568556..ade9e627e29 100644 --- a/storage/innobase/include/dict0dict.ic +++ b/storage/innobase/include/dict0dict.ic @@ -27,6 +27,7 @@ Created 1/8/1996 Heikki Tuuri #ifndef UNIV_HOTBACKUP #include "dict0load.h" #include "rem0types.h" +#include "srv0srv.h" /*********************************************************************//** Gets the minimum number of bytes per character. @@ -828,7 +829,7 @@ dict_table_check_if_in_cache_low( } /**********************************************************************//** -load a table into dictionary cache, ignore any error specified during load; +load a table into dictionary cache, ignore any error specified during load; @return table, NULL if not found */ UNIV_INLINE dict_table_t* @@ -872,6 +873,18 @@ dict_table_get_low( table = dict_table_check_if_in_cache_low(table_name); + if (table && table->corrupted) { + fprintf(stderr, "InnoDB: table"); + ut_print_name(stderr, NULL, TRUE, table->name); + if (srv_load_corrupted) { + fputs(" is corrupted, but" + " innodb_force_load_corrupted is set\n", stderr); + } else { + fputs(" is corrupted\n", stderr); + return(NULL); + } + } + if (table == NULL) { table = dict_load_table(table_name, TRUE, DICT_ERR_IGNORE_NONE); } @@ -937,4 +950,35 @@ dict_max_field_len_store_undo( return(prefix_len); } +/********************************************************************//** +Check whether the table is corrupted. +@return nonzero for corrupted table, zero for valid tables */ +UNIV_INLINE +ulint +dict_table_is_corrupted( +/*====================*/ + const dict_table_t* table) /*!< in: table */ +{ + ut_ad(table); + ut_ad(table->magic_n == DICT_TABLE_MAGIC_N); + + return(UNIV_UNLIKELY(table->corrupted)); +} + +/********************************************************************//** +Check whether the index is corrupted. +@return nonzero for corrupted index, zero for valid indexes */ +UNIV_INLINE +ulint +dict_index_is_corrupted( +/*====================*/ + const dict_index_t* index) /*!< in: index */ +{ + ut_ad(index); + ut_ad(index->magic_n == DICT_INDEX_MAGIC_N); + + return(UNIV_UNLIKELY((index->type & DICT_CORRUPT) + || (index->table && index->table->corrupted))); +} + #endif /* !UNIV_HOTBACKUP */ diff --git a/storage/innobase/include/dict0mem.h b/storage/innobase/include/dict0mem.h index 3a475fa85fc..9ded0dba39b 100644 --- a/storage/innobase/include/dict0mem.h +++ b/storage/innobase/include/dict0mem.h @@ -51,7 +51,12 @@ combination of types */ #define DICT_UNIQUE 2 /*!< unique index */ #define DICT_UNIVERSAL 4 /*!< index which can contain records from any other index */ -#define DICT_IBUF 8 /*!< insert buffer tree */ +#define DICT_IBUF 8 /*!< insert buffer tree */ +#define DICT_CORRUPT 16 /*!< bit to store the corrupted flag + in SYS_INDEXES.TYPE */ + +#define DICT_IT_BITS 5 /*!< number of bits used for + SYS_INDEXES.TYPE */ /* @} */ /** Types for a table object */ @@ -369,8 +374,9 @@ struct dict_index_struct{ /*!< space where the index tree is placed */ unsigned page:32;/*!< index tree root page number */ #endif /* !UNIV_HOTBACKUP */ - unsigned type:4; /*!< index type (DICT_CLUSTERED, DICT_UNIQUE, - DICT_UNIVERSAL, DICT_IBUF) */ + unsigned type:DICT_IT_BITS; + /*!< index type (DICT_CLUSTERED, DICT_UNIQUE, + DICT_UNIVERSAL, DICT_IBUF, DICT_CORRUPT) */ unsigned trx_id_offset:10;/*!< position of the trx id column in a clustered index record, if the fields before it are known to be of a fixed size, @@ -391,8 +397,6 @@ struct dict_index_struct{ /*!< TRUE if this index is marked to be dropped in ha_innobase::prepare_drop_index(), otherwise FALSE */ - unsigned corrupted:1; - /*!< TRUE if the index object is corrupted */ dict_field_t* fields; /*!< array of field descriptions */ #ifndef UNIV_HOTBACKUP UT_LIST_NODE_T(dict_index_t) diff --git a/storage/innobase/include/dict0types.h b/storage/innobase/include/dict0types.h index 8cbd7cd5783..f0a05a38070 100644 --- a/storage/innobase/include/dict0types.h +++ b/storage/innobase/include/dict0types.h @@ -51,7 +51,8 @@ be or-ed together */ enum dict_err_ignore { DICT_ERR_IGNORE_NONE = 0, /*!< no error to ignore */ DICT_ERR_IGNORE_INDEX_ROOT = 1, /*!< ignore error if index root - page is FIL_NUL or incorrect value */ + page is FIL_NULL or incorrect value */ + DICT_ERR_IGNORE_CORRUPT = 2, /*!< skip corrupted indexes */ DICT_ERR_IGNORE_ALL = 0xFFFF /*!< ignore all errors */ }; diff --git a/storage/innobase/include/mtr0mtr.h b/storage/innobase/include/mtr0mtr.h index 5582ad63039..7f608546cc2 100644 --- a/storage/innobase/include/mtr0mtr.h +++ b/storage/innobase/include/mtr0mtr.h @@ -213,16 +213,6 @@ ulint mtr_set_savepoint( /*==============*/ mtr_t* mtr); /*!< in: mtr */ -/**********************************************************//** -Releases the latches stored in an mtr memo down to a savepoint. -NOTE! The mtr must not have made changes to buffer pages after the -savepoint, as these can be handled only by mtr_commit. */ -UNIV_INTERN -void -mtr_rollback_to_savepoint( -/*======================*/ - mtr_t* mtr, /*!< in: mtr */ - ulint savepoint); /*!< in: savepoint */ #ifndef UNIV_HOTBACKUP /**********************************************************//** Releases the (index tree) s-latch stored in an mtr memo after a diff --git a/storage/innobase/include/page0page.h b/storage/innobase/include/page0page.h index 7091d8c2707..6a82e820312 100644 --- a/storage/innobase/include/page0page.h +++ b/storage/innobase/include/page0page.h @@ -68,10 +68,7 @@ typedef byte page_header_t; #define PAGE_MAX_TRX_ID 18 /* highest id of a trx which may have modified a record on the page; trx_id_t; defined only in secondary indexes and in the insert buffer - tree; NOTE: this may be modified only - when the thread has an x-latch to the page, - and ALSO an x-latch to btr_search_latch - if there is a hash index to the page! */ + tree */ #define PAGE_HEADER_PRIV_END 26 /* end of private data structure of the page header which are set in a page create */ /*----*/ diff --git a/storage/innobase/include/row0row.h b/storage/innobase/include/row0row.h index 75e15d67246..c2849be7c3e 100644 --- a/storage/innobase/include/row0row.h +++ b/storage/innobase/include/row0row.h @@ -1,6 +1,6 @@ /***************************************************************************** -Copyright (c) 1996, 2010, Innobase Oy. All Rights Reserved. +Copyright (c) 1996, 2011, Oracle and/or its affiliates. All Rights Reserved. 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 the Free Software @@ -38,27 +38,16 @@ Created 4/20/1996 Heikki Tuuri #include "btr0types.h" /*********************************************************************//** -Gets the offset of the trx id field, in bytes relative to the origin of +Gets the offset of the DB_TRX_ID field, in bytes relative to the origin of a clustered index record. @return offset of DATA_TRX_ID */ UNIV_INLINE ulint -row_get_trx_id_offset_func( -/*=======================*/ -#ifdef UNIV_DEBUG - const rec_t* rec, /*!< in: record */ -#endif /* UNIV_DEBUG */ +row_get_trx_id_offset( +/*==================*/ const dict_index_t* index, /*!< in: clustered index */ - const ulint* offsets)/*!< in: rec_get_offsets(rec, index) */ + const ulint* offsets)/*!< in: record offsets */ __attribute__((nonnull, warn_unused_result)); -#ifdef UNIV_DEBUG -# define row_get_trx_id_offset(rec, index, offsets) \ - row_get_trx_id_offset_func(rec, index, offsets) -#else /* UNIV_DEBUG */ -# define row_get_trx_id_offset(rec, index, offsets) \ - row_get_trx_id_offset_func(index, offsets) -#endif /* UNIV_DEBUG */ - /*********************************************************************//** Reads the trx id field from a clustered index record. @return value of the field */ @@ -77,9 +66,10 @@ UNIV_INLINE roll_ptr_t row_get_rec_roll_ptr( /*=================*/ - const rec_t* rec, /*!< in: record */ - dict_index_t* index, /*!< in: clustered index */ - const ulint* offsets);/*!< in: rec_get_offsets(rec, index) */ + const rec_t* rec, /*!< in: record */ + const dict_index_t* index, /*!< in: clustered index */ + const ulint* offsets)/*!< in: rec_get_offsets(rec, index) */ + __attribute__((nonnull, warn_unused_result)); /*****************************************************************//** When an insert or purge to a table is performed, this function builds the entry to be inserted into or purged from an index on the table. diff --git a/storage/innobase/include/row0row.ic b/storage/innobase/include/row0row.ic index 9d19e430e16..0b9ca982af8 100644 --- a/storage/innobase/include/row0row.ic +++ b/storage/innobase/include/row0row.ic @@ -1,6 +1,6 @@ /***************************************************************************** -Copyright (c) 1996, 2009, Innobase Oy. All Rights Reserved. +Copyright (c) 1996, 2011, Oracle and/or its affiliates. All Rights Reserved. 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 the Free Software @@ -28,25 +28,22 @@ Created 4/20/1996 Heikki Tuuri #include "trx0undo.h" /*********************************************************************//** -Gets the offset of trx id field, in bytes relative to the origin of +Gets the offset of the DB_TRX_ID field, in bytes relative to the origin of a clustered index record. @return offset of DATA_TRX_ID */ UNIV_INLINE ulint -row_get_trx_id_offset_func( -/*=======================*/ -#ifdef UNIV_DEBUG - const rec_t* rec, /*!< in: record */ -#endif /* UNIV_DEBUG */ +row_get_trx_id_offset( +/*==================*/ const dict_index_t* index, /*!< in: clustered index */ - const ulint* offsets)/*!< in: rec_get_offsets(rec, index) */ + const ulint* offsets)/*!< in: record offsets */ { ulint pos; ulint offset; ulint len; ut_ad(dict_index_is_clust(index)); - ut_ad(rec_offs_validate(rec, index, offsets)); + ut_ad(rec_offs_validate(NULL, index, offsets)); pos = dict_index_get_sys_col_pos(index, DATA_TRX_ID); @@ -76,7 +73,7 @@ row_get_rec_trx_id( offset = index->trx_id_offset; if (!offset) { - offset = row_get_trx_id_offset(rec, index, offsets); + offset = row_get_trx_id_offset(index, offsets); } return(trx_read_trx_id(rec + offset)); @@ -89,9 +86,9 @@ UNIV_INLINE roll_ptr_t row_get_rec_roll_ptr( /*=================*/ - const rec_t* rec, /*!< in: record */ - dict_index_t* index, /*!< in: clustered index */ - const ulint* offsets)/*!< in: rec_get_offsets(rec, index) */ + const rec_t* rec, /*!< in: record */ + const dict_index_t* index, /*!< in: clustered index */ + const ulint* offsets)/*!< in: rec_get_offsets(rec, index) */ { ulint offset; @@ -101,7 +98,7 @@ row_get_rec_roll_ptr( offset = index->trx_id_offset; if (!offset) { - offset = row_get_trx_id_offset(rec, index, offsets); + offset = row_get_trx_id_offset(index, offsets); } return(trx_read_roll_ptr(rec + offset + DATA_TRX_ID_LEN)); diff --git a/storage/innobase/include/row0upd.ic b/storage/innobase/include/row0upd.ic index 18e22f1eca9..11db82f64da 100644 --- a/storage/innobase/include/row0upd.ic +++ b/storage/innobase/include/row0upd.ic @@ -1,6 +1,6 @@ /***************************************************************************** -Copyright (c) 1996, 2009, Innobase Oy. All Rights Reserved. +Copyright (c) 1996, 2011, Oracle and/or its affiliates. All Rights Reserved. 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 the Free Software @@ -157,11 +157,6 @@ row_upd_rec_sys_fields( { ut_ad(dict_index_is_clust(index)); ut_ad(rec_offs_validate(rec, index, offsets)); -#ifdef UNIV_SYNC_DEBUG - if (!rw_lock_own(&btr_search_latch, RW_LOCK_EX)) { - ut_ad(!buf_block_align(rec)->is_hashed); - } -#endif /* UNIV_SYNC_DEBUG */ if (UNIV_LIKELY_NULL(page_zip)) { ulint pos = dict_index_get_sys_col_pos(index, DATA_TRX_ID); @@ -171,7 +166,7 @@ row_upd_rec_sys_fields( ulint offset = index->trx_id_offset; if (!offset) { - offset = row_get_trx_id_offset(rec, index, offsets); + offset = row_get_trx_id_offset(index, offsets); } #if DATA_TRX_ID + 1 != DATA_ROLL_PTR diff --git a/storage/innobase/include/srv0srv.h b/storage/innobase/include/srv0srv.h index fc9401a12f5..dfe7397d189 100644 --- a/storage/innobase/include/srv0srv.h +++ b/storage/innobase/include/srv0srv.h @@ -141,6 +141,10 @@ extern ulint srv_log_buffer_size; extern ulong srv_flush_log_at_trx_commit; extern char srv_adaptive_flushing; +/* If this flag is TRUE, then we will load the indexes' (and tables') metadata +even if they are marked as "corrupted". Mostly it is for DBA to process +corrupted index and table */ +extern my_bool srv_load_corrupted; /* The sort order table of the MySQL latin1_swedish_ci character set collation */ @@ -158,6 +162,7 @@ extern ulint srv_mem_pool_size; extern ulint srv_lock_table_size; extern ulint srv_n_file_io_threads; +extern my_bool srv_random_read_ahead; extern ulong srv_read_ahead_threshold; extern ulint srv_n_read_io_threads; extern ulint srv_n_write_io_threads; @@ -703,6 +708,7 @@ struct export_var_struct{ ulint innodb_buffer_pool_wait_free; /*!< srv_buf_pool_wait_free */ ulint innodb_buffer_pool_pages_flushed; /*!< srv_buf_pool_flushed */ ulint innodb_buffer_pool_write_requests;/*!< srv_buf_pool_write_requests */ + ulint innodb_buffer_pool_read_ahead_rnd;/*!< srv_read_ahead_rnd */ ulint innodb_buffer_pool_read_ahead; /*!< srv_read_ahead */ ulint innodb_buffer_pool_read_ahead_evicted;/*!< srv_read_ahead evicted*/ ulint innodb_dblwr_pages_written; /*!< srv_dblwr_pages_written */ diff --git a/storage/innobase/include/sync0rw.h b/storage/innobase/include/sync0rw.h index 9e5c96fa323..dedf080d00a 100644 --- a/storage/innobase/include/sync0rw.h +++ b/storage/innobase/include/sync0rw.h @@ -542,7 +542,7 @@ mutex. */ UNIV_INTERN void rw_lock_debug_mutex_enter(void); -/*==========================*/ +/*===========================*/ /******************************************************************//** Releases the debug mutex. */ UNIV_INTERN @@ -632,7 +632,8 @@ struct rw_lock_struct { }; #ifdef UNIV_SYNC_DEBUG -/** The structure for storing debug info of an rw-lock */ +/** The structure for storing debug info of an rw-lock. All access to this +structure must be protected by rw_lock_debug_mutex_enter(). */ struct rw_lock_debug_struct { os_thread_id_t thread_id; /*!< The thread id of the thread which diff --git a/storage/innobase/include/sync0rw.ic b/storage/innobase/include/sync0rw.ic index 2ffd9fdafb5..51cf7121b4c 100644 --- a/storage/innobase/include/sync0rw.ic +++ b/storage/innobase/include/sync0rw.ic @@ -406,6 +406,7 @@ rw_lock_s_lock_func( #ifdef UNIV_SYNC_DEBUG ut_ad(!rw_lock_own(lock, RW_LOCK_SHARED)); /* see NOTE above */ + ut_ad(!rw_lock_own(lock, RW_LOCK_EX)); #endif /* UNIV_SYNC_DEBUG */ /* TODO: study performance of UNIV_LIKELY branch prediction hints. */ diff --git a/storage/innobase/include/sync0sync.h b/storage/innobase/include/sync0sync.h index b823c9d5259..d9dea0aa63d 100644 --- a/storage/innobase/include/sync0sync.h +++ b/storage/innobase/include/sync0sync.h @@ -636,10 +636,6 @@ or row lock! */ #define SYNC_DICT_HEADER 995 #define SYNC_IBUF_HEADER 914 #define SYNC_IBUF_PESS_INSERT_MUTEX 912 -#define SYNC_IBUF_MUTEX 910 /* ibuf mutex is really below - SYNC_FSP_PAGE: we assign a value this - high only to make the program to pass - the debug checks */ /*-------------------------------*/ #define SYNC_INDEX_TREE 900 #define SYNC_TREE_NODE_NEW 892 @@ -655,8 +651,11 @@ or row lock! */ #define SYNC_FSP 400 #define SYNC_FSP_PAGE 395 /*------------------------------------- Insert buffer headers */ -/*------------------------------------- ibuf_mutex */ +#define SYNC_IBUF_MUTEX 370 /* ibuf_mutex */ /*------------------------------------- Insert buffer tree */ +#define SYNC_IBUF_INDEX_TREE 360 +#define SYNC_IBUF_TREE_NODE_NEW 359 +#define SYNC_IBUF_TREE_NODE 358 #define SYNC_IBUF_BITMAP_MUTEX 351 #define SYNC_IBUF_BITMAP 350 /*------------------------------------- MySQL query cache mutex */ @@ -683,7 +682,6 @@ or row lock! */ #define SYNC_BUF_FLUSH_LIST 145 /* Buffer flush list mutex */ #define SYNC_DOUBLEWRITE 140 #define SYNC_ANY_LATCH 135 -#define SYNC_THR_LOCAL 133 #define SYNC_MEM_HASH 131 #define SYNC_MEM_POOL 130 diff --git a/storage/innobase/include/sync0sync.ic b/storage/innobase/include/sync0sync.ic index 2977f71154a..eb21f44c65e 100644 --- a/storage/innobase/include/sync0sync.ic +++ b/storage/innobase/include/sync0sync.ic @@ -272,11 +272,10 @@ pfs_mutex_enter_nowait_func( ulint ret; struct PSI_mutex_locker* locker = NULL; PSI_mutex_locker_state state; - int result = 0; if (UNIV_LIKELY(PSI_server && mutex->pfs_psi)) { locker = PSI_server->get_thread_mutex_locker( - &state, mutex->pfs_psi, PSI_MUTEX_LOCK); + &state, mutex->pfs_psi, PSI_MUTEX_TRYLOCK); if (locker) { PSI_server->start_mutex_wait(locker, file_name, line); } @@ -285,7 +284,7 @@ pfs_mutex_enter_nowait_func( ret = mutex_enter_nowait_func(mutex, file_name, line); if (locker) { - PSI_server->end_mutex_wait(locker, result); + PSI_server->end_mutex_wait(locker, ret); } return(ret); diff --git a/storage/innobase/include/trx0sys.h b/storage/innobase/include/trx0sys.h index dc0ca2285b9..9cec1933e9d 100644 --- a/storage/innobase/include/trx0sys.h +++ b/storage/innobase/include/trx0sys.h @@ -1,6 +1,6 @@ /***************************************************************************** -Copyright (c) 1996, 2011, Innobase Oy. All Rights Reserved. +Copyright (c) 1996, 2011, Oracle and/or its affiliates. All Rights Reserved. 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 the Free Software @@ -278,6 +278,17 @@ ibool trx_in_trx_list( /*============*/ trx_t* in_trx);/*!< in: trx */ +#if defined UNIV_DEBUG || defined UNIV_BLOB_LIGHT_DEBUG +/***********************************************************//** +Assert that a transaction has been recovered. +@return TRUE */ +UNIV_INLINE +ibool +trx_assert_recovered( +/*=================*/ + trx_id_t trx_id) /*!< in: transaction identifier */ + __attribute__((warn_unused_result)); +#endif /* UNIV_DEBUG || UNIV_BLOB_LIGHT_DEBUG */ /*****************************************************************//** Updates the offset information about the end of the MySQL binlog entry which corresponds to the transaction just being committed. In a MySQL diff --git a/storage/innobase/include/trx0sys.ic b/storage/innobase/include/trx0sys.ic index 355f118a1ec..5e702b25325 100644 --- a/storage/innobase/include/trx0sys.ic +++ b/storage/innobase/include/trx0sys.ic @@ -1,6 +1,6 @@ /***************************************************************************** -Copyright (c) 1996, 2009, Innobase Oy. All Rights Reserved. +Copyright (c) 1996, 2011, Oracle and/or its affiliates. All Rights Reserved. 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 the Free Software @@ -277,6 +277,28 @@ trx_get_on_id( return(NULL); } +#if defined UNIV_DEBUG || defined UNIV_BLOB_LIGHT_DEBUG +/***********************************************************//** +Assert that a transaction has been recovered. +@return TRUE */ +UNIV_INLINE +ibool +trx_assert_recovered( +/*=================*/ + trx_id_t trx_id) /*!< in: transaction identifier */ +{ + trx_t* trx; + + mutex_enter(&kernel_mutex); + trx = trx_get_on_id(trx_id); + ut_a(trx); + ut_a(trx->is_recovered); + mutex_exit(&kernel_mutex); + + return(TRUE); +} +#endif /* UNIV_DEBUG || UNIV_BLOB_LIGHT_DEBUG */ + /****************************************************************//** Returns the minumum trx id in trx list. This is the smallest id for which the trx can possibly be active. (But, you must look at the trx->conc_state to diff --git a/storage/innobase/include/trx0undo.h b/storage/innobase/include/trx0undo.h index df16c939070..50aa6d0ac09 100644 --- a/storage/innobase/include/trx0undo.h +++ b/storage/innobase/include/trx0undo.h @@ -1,6 +1,6 @@ /***************************************************************************** -Copyright (c) 1996, 2009, Innobase Oy. All Rights Reserved. +Copyright (c) 1996, 2011, Oracle and/or its affiliates. All Rights Reserved. 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 the Free Software @@ -204,17 +204,51 @@ trx_undo_add_page( mtr_t* mtr); /*!< in: mtr which does not have a latch to any undo log page; the caller must have reserved the rollback segment mutex */ +/********************************************************************//** +Frees the last undo log page. +The caller must hold the rollback segment mutex. */ +UNIV_INTERN +void +trx_undo_free_last_page_func( +/*==========================*/ +#ifdef UNIV_DEBUG + const trx_t* trx, /*!< in: transaction */ +#endif /* UNIV_DEBUG */ + trx_undo_t* undo, /*!< in/out: undo log memory copy */ + mtr_t* mtr) /*!< in/out: mini-transaction which does not + have a latch to any undo log page or which + has allocated the undo log page */ + __attribute__((nonnull)); +#ifdef UNIV_DEBUG +# define trx_undo_free_last_page(trx,undo,mtr) \ + trx_undo_free_last_page_func(trx,undo,mtr) +#else /* UNIV_DEBUG */ +# define trx_undo_free_last_page(trx,undo,mtr) \ + trx_undo_free_last_page_func(undo,mtr) +#endif /* UNIV_DEBUG */ + /***********************************************************************//** Truncates an undo log from the end. This function is used during a rollback to free space from an undo log. */ UNIV_INTERN void -trx_undo_truncate_end( -/*==================*/ - trx_t* trx, /*!< in: transaction whose undo log it is */ - trx_undo_t* undo, /*!< in: undo log */ - undo_no_t limit); /*!< in: all undo records with undo number +trx_undo_truncate_end_func( +/*=======================*/ +#ifdef UNIV_DEBUG + const trx_t* trx, /*!< in: transaction whose undo log it is */ +#endif /* UNIV_DEBUG */ + trx_undo_t* undo, /*!< in/out: undo log */ + undo_no_t limit) /*!< in: all undo records with undo number >= this value should be truncated */ + __attribute__((nonnull)); +#ifdef UNIV_DEBUG +# define trx_undo_truncate_end(trx,undo,limit) \ + trx_undo_truncate_end_func(trx,undo,limit) +#else /* UNIV_DEBUG */ +# define trx_undo_truncate_end(trx,undo,limit) \ + trx_undo_truncate_end_func(undo,limit) +#endif /* UNIV_DEBUG */ + /***********************************************************************//** Truncates an undo log from the start. This function is used during a purge operation. */ diff --git a/storage/innobase/include/ut0mem.h b/storage/innobase/include/ut0mem.h index 57dfb08f41c..faf6f242883 100644 --- a/storage/innobase/include/ut0mem.h +++ b/storage/innobase/include/ut0mem.h @@ -1,6 +1,6 @@ /***************************************************************************** -Copyright (c) 1994, 2009, Innobase Oy. All Rights Reserved. +Copyright (c) 1994, 2011, Oracle and/or its affiliates. All Rights Reserved. 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 the Free Software @@ -210,43 +210,6 @@ ut_strlcpy_rev( ulint size); /*!< in: size of destination buffer */ /**********************************************************************//** -Compute strlen(ut_strcpyq(str, q)). -@return length of the string when quoted */ -UNIV_INLINE -ulint -ut_strlenq( -/*=======*/ - const char* str, /*!< in: null-terminated string */ - char q); /*!< in: the quote character */ - -/**********************************************************************//** -Make a quoted copy of a NUL-terminated string. Leading and trailing -quotes will not be included; only embedded quotes will be escaped. -See also ut_strlenq() and ut_memcpyq(). -@return pointer to end of dest */ -UNIV_INTERN -char* -ut_strcpyq( -/*=======*/ - char* dest, /*!< in: output buffer */ - char q, /*!< in: the quote character */ - const char* src); /*!< in: null-terminated string */ - -/**********************************************************************//** -Make a quoted copy of a fixed-length string. Leading and trailing -quotes will not be included; only embedded quotes will be escaped. -See also ut_strlenq() and ut_strcpyq(). -@return pointer to end of dest */ -UNIV_INTERN -char* -ut_memcpyq( -/*=======*/ - char* dest, /*!< in: output buffer */ - char q, /*!< in: the quote character */ - const char* src, /*!< in: string to be quoted */ - ulint len); /*!< in: length of src */ - -/**********************************************************************//** Return the number of times s2 occurs in s1. Overlapping instances of s2 are only counted once. @return the number of times s2 occurs in s1 */ diff --git a/storage/innobase/include/ut0mem.ic b/storage/innobase/include/ut0mem.ic index f36c28f1989..c06e2b3ae81 100644 --- a/storage/innobase/include/ut0mem.ic +++ b/storage/innobase/include/ut0mem.ic @@ -1,6 +1,6 @@ /***************************************************************************** -Copyright (c) 1994, 2009, Innobase Oy. All Rights Reserved. +Copyright (c) 1994, 2011, Oracle and/or its affiliates. All Rights Reserved. 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 the Free Software @@ -99,27 +99,6 @@ ut_strcmp(const char* str1, const char* str2) } /**********************************************************************//** -Compute strlen(ut_strcpyq(str, q)). -@return length of the string when quoted */ -UNIV_INLINE -ulint -ut_strlenq( -/*=======*/ - const char* str, /*!< in: null-terminated string */ - char q) /*!< in: the quote character */ -{ - ulint len; - - for (len = 0; *str; len++, str++) { - if (*str == q) { - len++; - } - } - - return(len); -} - -/**********************************************************************//** Converts a raw binary data to a NUL-terminated hex string. The output is truncated if there is not enough space in "hex", make sure "hex_size" is at least (2 * raw_size + 1) if you do not want this to happen. Returns the diff --git a/storage/innobase/mtr/mtr0mtr.c b/storage/innobase/mtr/mtr0mtr.c index 439b429db43..08234609ff0 100644 --- a/storage/innobase/mtr/mtr0mtr.c +++ b/storage/innobase/mtr/mtr0mtr.c @@ -282,44 +282,6 @@ mtr_commit( } #ifndef UNIV_HOTBACKUP -/**********************************************************//** -Releases the latches stored in an mtr memo down to a savepoint. -NOTE! The mtr must not have made changes to buffer pages after the -savepoint, as these can be handled only by mtr_commit. */ -UNIV_INTERN -void -mtr_rollback_to_savepoint( -/*======================*/ - mtr_t* mtr, /*!< in: mtr */ - ulint savepoint) /*!< in: savepoint */ -{ - mtr_memo_slot_t* slot; - dyn_array_t* memo; - ulint offset; - - ut_ad(mtr); - ut_ad(mtr->magic_n == MTR_MAGIC_N); - ut_ad(mtr->state == MTR_ACTIVE); - - memo = &(mtr->memo); - - offset = dyn_array_get_data_size(memo); - ut_ad(offset >= savepoint); - - while (offset > savepoint) { - offset -= sizeof(mtr_memo_slot_t); - - slot = dyn_array_get_element(memo, offset); - - ut_ad(slot->type != MTR_MEMO_MODIFY); - - /* We do not call mtr_memo_slot_note_modification() - because there MUST be no changes made to the buffer - pages after the savepoint */ - mtr_memo_slot_release(mtr, slot); - } -} - /***************************************************//** Releases an object in the memo stack. */ UNIV_INTERN diff --git a/storage/innobase/page/page0zip.c b/storage/innobase/page/page0zip.c index c92ad9dc25b..fb618beac7e 100644 --- a/storage/innobase/page/page0zip.c +++ b/storage/innobase/page/page0zip.c @@ -1,6 +1,6 @@ /***************************************************************************** -Copyright (c) 2005, 2009, Innobase Oy. All Rights Reserved. +Copyright (c) 2005, 2011, Oracle and/or its affiliates. All Rights Reserved. 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 the Free Software @@ -151,6 +151,20 @@ page_zip_empty_size( #endif /* !UNIV_HOTBACKUP */ /*************************************************************//** +Gets the number of elements in the dense page directory, +including deleted records (the free list). +@return number of elements in the dense page directory */ +UNIV_INLINE +ulint +page_zip_dir_elems( +/*===============*/ + const page_zip_des_t* page_zip) /*!< in: compressed page */ +{ + /* Exclude the page infimum and supremum from the record count. */ + return(page_dir_get_n_heap(page_zip->data) - PAGE_HEAP_NO_USER_LOW); +} + +/*************************************************************//** Gets the size of the compressed page trailer (the dense page directory), including deleted records (the free list). @return length of dense page directory, in bytes */ @@ -160,14 +174,42 @@ page_zip_dir_size( /*==============*/ const page_zip_des_t* page_zip) /*!< in: compressed page */ { - /* Exclude the page infimum and supremum from the record count. */ - ulint size = PAGE_ZIP_DIR_SLOT_SIZE - * (page_dir_get_n_heap(page_zip->data) - - PAGE_HEAP_NO_USER_LOW); - return(size); + return(PAGE_ZIP_DIR_SLOT_SIZE * page_zip_dir_elems(page_zip)); +} + +/*************************************************************//** +Gets an offset to the compressed page trailer (the dense page directory), +including deleted records (the free list). +@return offset of the dense page directory */ +UNIV_INLINE +ulint +page_zip_dir_start_offs( +/*====================*/ + const page_zip_des_t* page_zip, /*!< in: compressed page */ + ulint n_dense) /*!< in: directory size */ +{ + ut_ad(n_dense * PAGE_ZIP_DIR_SLOT_SIZE < page_zip_get_size(page_zip)); + + return(page_zip_get_size(page_zip) - n_dense * PAGE_ZIP_DIR_SLOT_SIZE); } /*************************************************************//** +Gets a pointer to the compressed page trailer (the dense page directory), +including deleted records (the free list). +@param[in] page_zip compressed page +@param[in] n_dense number of entries in the directory +@return pointer to the dense page directory */ +#define page_zip_dir_start_low(page_zip, n_dense) \ + ((page_zip)->data + page_zip_dir_start_offs(page_zip, n_dense)) +/*************************************************************//** +Gets a pointer to the compressed page trailer (the dense page directory), +including deleted records (the free list). +@param[in] page_zip compressed page +@return pointer to the dense page directory */ +#define page_zip_dir_start(page_zip) \ + page_zip_dir_start_low(page_zip, page_zip_dir_elems(page_zip)) + +/*************************************************************//** Gets the size of the compressed page trailer (the dense page directory), only including user records (excluding the free list). @return length of dense page directory comprising existing records, in bytes */ @@ -2242,8 +2284,7 @@ zlib_done: } /* Restore the uncompressed columns in heap_no order. */ - storage = page_zip->data + page_zip_get_size(page_zip) - - n_dense * PAGE_ZIP_DIR_SLOT_SIZE; + storage = page_zip_dir_start_low(page_zip, n_dense); for (slot = 0; slot < n_dense; slot++) { rec_t* rec = recs[slot]; @@ -2728,8 +2769,7 @@ zlib_done: return(FALSE); } - storage = page_zip->data + page_zip_get_size(page_zip) - - n_dense * PAGE_ZIP_DIR_SLOT_SIZE; + storage = page_zip_dir_start_low(page_zip, n_dense); externs = storage - n_dense * (DATA_TRX_ID_LEN + DATA_ROLL_PTR_LEN); @@ -3457,9 +3497,7 @@ page_zip_write_rec( } /* Write the data bytes. Store the uncompressed bytes separately. */ - storage = page_zip->data + page_zip_get_size(page_zip) - - (page_dir_get_n_heap(page) - PAGE_HEAP_NO_USER_LOW) - * PAGE_ZIP_DIR_SLOT_SIZE; + storage = page_zip_dir_start(page_zip); if (page_is_leaf(page)) { ulint len; @@ -3755,9 +3793,7 @@ corrupt: field = page + offset; storage = page_zip->data + z_offset; - storage_end = page_zip->data + page_zip_get_size(page_zip) - - (page_dir_get_n_heap(page) - PAGE_HEAP_NO_USER_LOW) - * PAGE_ZIP_DIR_SLOT_SIZE; + storage_end = page_zip_dir_start(page_zip); heap_no = 1 + (storage_end - storage) / REC_NODE_PTR_SIZE; @@ -3793,7 +3829,9 @@ page_zip_write_node_ptr( { byte* field; byte* storage; +#ifdef UNIV_DEBUG page_t* page = page_align(rec); +#endif /* UNIV_DEBUG */ ut_ad(PAGE_ZIP_MATCH(rec, page_zip)); ut_ad(page_simple_validate_new(page)); @@ -3810,9 +3848,7 @@ page_zip_write_node_ptr( UNIV_MEM_ASSERT_RW(page_zip->data, page_zip_get_size(page_zip)); UNIV_MEM_ASSERT_RW(rec, size); - storage = page_zip->data + page_zip_get_size(page_zip) - - (page_dir_get_n_heap(page) - PAGE_HEAP_NO_USER_LOW) - * PAGE_ZIP_DIR_SLOT_SIZE + storage = page_zip_dir_start(page_zip) - (rec_get_heap_no_new(rec) - 1) * REC_NODE_PTR_SIZE; field = rec + size - REC_NODE_PTR_SIZE; @@ -3861,7 +3897,9 @@ page_zip_write_trx_id_and_roll_ptr( { byte* field; byte* storage; +#ifdef UNIV_DEBUG page_t* page = page_align(rec); +#endif /* UNIV_DEBUG */ ulint len; ut_ad(PAGE_ZIP_MATCH(rec, page_zip)); @@ -3879,9 +3917,7 @@ page_zip_write_trx_id_and_roll_ptr( UNIV_MEM_ASSERT_RW(page_zip->data, page_zip_get_size(page_zip)); - storage = page_zip->data + page_zip_get_size(page_zip) - - (page_dir_get_n_heap(page) - PAGE_HEAP_NO_USER_LOW) - * PAGE_ZIP_DIR_SLOT_SIZE + storage = page_zip_dir_start(page_zip) - (rec_get_heap_no_new(rec) - 1) * (DATA_TRX_ID_LEN + DATA_ROLL_PTR_LEN); @@ -3912,17 +3948,9 @@ page_zip_write_trx_id_and_roll_ptr( UNIV_MEM_ASSERT_RW(page_zip->data, page_zip_get_size(page_zip)); } -#ifdef UNIV_ZIP_DEBUG -/** Set this variable in a debugger to disable page_zip_clear_rec(). -The only observable effect should be the compression ratio due to -deleted records not being zeroed out. In rare cases, there can be -page_zip_validate() failures on the node_ptr, trx_id and roll_ptr -columns if the space is reallocated for a smaller record. */ -UNIV_INTERN ibool page_zip_clear_rec_disable; -#endif /* UNIV_ZIP_DEBUG */ - /**********************************************************************//** -Clear an area on the uncompressed and compressed page, if possible. */ +Clear an area on the uncompressed and compressed page. +Do not clear the data payload, as that would grow the modification log. */ static void page_zip_clear_rec( @@ -3934,6 +3962,9 @@ page_zip_clear_rec( { ulint heap_no; page_t* page = page_align(rec); + byte* storage; + byte* field; + ulint len; /* page_zip_validate() would fail here if a record containing externally stored columns is being deleted. */ ut_ad(rec_offs_validate(rec, index, offsets)); @@ -3949,60 +3980,38 @@ page_zip_clear_rec( UNIV_MEM_ASSERT_RW(rec - rec_offs_extra_size(offsets), rec_offs_extra_size(offsets)); - if ( -#ifdef UNIV_ZIP_DEBUG - !page_zip_clear_rec_disable && -#endif /* UNIV_ZIP_DEBUG */ - page_zip->m_end - + 1 + ((heap_no - 1) >= 64)/* size of the log entry */ - + page_zip_get_trailer_len(page_zip, - dict_index_is_clust(index), NULL) - < page_zip_get_size(page_zip)) { - byte* data; - - /* Clear only the data bytes, because the allocator and - the decompressor depend on the extra bytes. */ - memset(rec, 0, rec_offs_data_size(offsets)); - - if (!page_is_leaf(page)) { - /* Clear node_ptr on the compressed page. */ - byte* storage = page_zip->data - + page_zip_get_size(page_zip) - - (page_dir_get_n_heap(page) - - PAGE_HEAP_NO_USER_LOW) - * PAGE_ZIP_DIR_SLOT_SIZE; - - memset(storage - (heap_no - 1) * REC_NODE_PTR_SIZE, - 0, REC_NODE_PTR_SIZE); - } else if (dict_index_is_clust(index)) { - /* Clear trx_id and roll_ptr on the compressed page. */ - byte* storage = page_zip->data - + page_zip_get_size(page_zip) - - (page_dir_get_n_heap(page) - - PAGE_HEAP_NO_USER_LOW) - * PAGE_ZIP_DIR_SLOT_SIZE; - - memset(storage - (heap_no - 1) - * (DATA_TRX_ID_LEN + DATA_ROLL_PTR_LEN), - 0, DATA_TRX_ID_LEN + DATA_ROLL_PTR_LEN); - } + if (!page_is_leaf(page)) { + /* Clear node_ptr. On the compressed page, + there is an array of node_ptr immediately before the + dense page directory, at the very end of the page. */ + storage = page_zip_dir_start(page_zip); + ut_ad(dict_index_get_n_unique_in_tree(index) == + rec_offs_n_fields(offsets) - 1); + field = rec_get_nth_field(rec, offsets, + rec_offs_n_fields(offsets) - 1, + &len); + ut_ad(len == REC_NODE_PTR_SIZE); - /* Log that the data was zeroed out. */ - data = page_zip->data + page_zip->m_end; - ut_ad(!*data); - if (UNIV_UNLIKELY(heap_no - 1 >= 64)) { - *data++ = (byte) (0x80 | (heap_no - 1) >> 7); - ut_ad(!*data); - } - *data++ = (byte) ((heap_no - 1) << 1 | 1); - ut_ad(!*data); - ut_ad((ulint) (data - page_zip->data) - < page_zip_get_size(page_zip)); - page_zip->m_end = data - page_zip->data; - page_zip->m_nonempty = TRUE; - } else if (page_is_leaf(page) && dict_index_is_clust(index)) { - /* Do not clear the record, because there is not enough space - to log the operation. */ + ut_ad(!rec_offs_any_extern(offsets)); + memset(field, 0, REC_NODE_PTR_SIZE); + memset(storage - (heap_no - 1) * REC_NODE_PTR_SIZE, + 0, REC_NODE_PTR_SIZE); + } else if (dict_index_is_clust(index)) { + /* Clear trx_id and roll_ptr. On the compressed page, + there is an array of these fields immediately before the + dense page directory, at the very end of the page. */ + const ulint trx_id_pos + = dict_col_get_clust_pos( + dict_table_get_sys_col( + index->table, DATA_TRX_ID), index); + storage = page_zip_dir_start(page_zip); + field = rec_get_nth_field(rec, offsets, trx_id_pos, &len); + ut_ad(len == DATA_TRX_ID_LEN); + + memset(field, 0, DATA_TRX_ID_LEN + DATA_ROLL_PTR_LEN); + memset(storage - (heap_no - 1) + * (DATA_TRX_ID_LEN + DATA_ROLL_PTR_LEN), + 0, DATA_TRX_ID_LEN + DATA_ROLL_PTR_LEN); if (rec_offs_any_extern(offsets)) { ulint i; @@ -4011,15 +4020,18 @@ page_zip_clear_rec( /* Clear all BLOB pointers in order to make page_zip_validate() pass. */ if (rec_offs_nth_extern(offsets, i)) { - ulint len; - byte* field = rec_get_nth_field( + field = rec_get_nth_field( rec, offsets, i, &len); + ut_ad(len + == BTR_EXTERN_FIELD_REF_SIZE); memset(field + len - BTR_EXTERN_FIELD_REF_SIZE, 0, BTR_EXTERN_FIELD_REF_SIZE); } } } + } else { + ut_ad(!rec_offs_any_extern(offsets)); } #ifdef UNIV_ZIP_DEBUG diff --git a/storage/innobase/pars/pars0opt.c b/storage/innobase/pars/pars0opt.c index 2e392ba4836..d992805d9ef 100644 --- a/storage/innobase/pars/pars0opt.c +++ b/storage/innobase/pars/pars0opt.c @@ -568,7 +568,7 @@ opt_search_plan_for_table( best_last_op = last_op; } - index = dict_table_get_next_index(index); + dict_table_next_uncorrupted_index(index); } plan->index = best_index; diff --git a/storage/innobase/rem/rem0rec.c b/storage/innobase/rem/rem0rec.c index 5a96e608ab5..30fc28561fa 100644 --- a/storage/innobase/rem/rem0rec.c +++ b/storage/innobase/rem/rem0rec.c @@ -1,6 +1,6 @@ /***************************************************************************** -Copyright (c) 1994, 2010, Innobase Oy. All Rights Reserved. +Copyright (c) 1994, 2011, Oracle and/or its affiliates. All Rights Reserved. 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 the Free Software @@ -408,7 +408,7 @@ rec_init_offsets( do { ulint len; if (UNIV_UNLIKELY(i == n_node_ptr_field)) { - len = offs += 4; + len = offs += REC_NODE_PTR_SIZE; goto resolved; } @@ -640,7 +640,7 @@ rec_get_offsets_reverse( do { ulint len; if (UNIV_UNLIKELY(i == n_node_ptr_field)) { - len = offs += 4; + len = offs += REC_NODE_PTR_SIZE; goto resolved; } @@ -1131,9 +1131,9 @@ rec_convert_dtuple_to_rec_comp( if (UNIV_UNLIKELY(i == n_node_ptr_field)) { ut_ad(dtype_get_prtype(type) & DATA_NOT_NULL); - ut_ad(len == 4); + ut_ad(len == REC_NODE_PTR_SIZE); memcpy(end, dfield_get_data(field), len); - end += 4; + end += REC_NODE_PTR_SIZE; break; } diff --git a/storage/innobase/row/row0ins.c b/storage/innobase/row/row0ins.c index e0414cde80d..2925feb2904 100644 --- a/storage/innobase/row/row0ins.c +++ b/storage/innobase/row/row0ins.c @@ -118,6 +118,9 @@ ins_node_create_entry_list( node->entry_sys_heap); UT_LIST_ADD_LAST(tuple_list, node->entry_list, entry); + /* We will include all indexes (include those corrupted + secondary indexes) in the entry list. Filteration of + these corrupted index will be done in row_ins() */ index = dict_table_get_next_index(index); } } @@ -2045,7 +2048,6 @@ row_ins_index_entry_low( mtr_start(&mtr); if (err != DB_SUCCESS) { - goto function_exit; } @@ -2395,6 +2397,13 @@ row_ins( node->index = dict_table_get_next_index(node->index); node->entry = UT_LIST_GET_NEXT(tuple_list, node->entry); + + /* Skip corrupted secondar index and its entry */ + while (node->index && dict_index_is_corrupted(node->index)) { + + node->index = dict_table_get_next_index(node->index); + node->entry = UT_LIST_GET_NEXT(tuple_list, node->entry); + } } ut_ad(node->entry == NULL); diff --git a/storage/innobase/row/row0merge.c b/storage/innobase/row/row0merge.c index 5be437add5a..d42f21241ca 100644 --- a/storage/innobase/row/row0merge.c +++ b/storage/innobase/row/row0merge.c @@ -2554,8 +2554,9 @@ row_merge_is_index_usable( const trx_t* trx, /*!< in: transaction */ const dict_index_t* index) /*!< in: index to check */ { - return(!trx->read_view - || read_view_sees_trx_id(trx->read_view, index->trx_id)); + return(!dict_index_is_corrupted(index) + && (!trx->read_view + || read_view_sees_trx_id(trx->read_view, index->trx_id))); } /*********************************************************************//** diff --git a/storage/innobase/row/row0mysql.c b/storage/innobase/row/row0mysql.c index e1ada387729..d0bedd69842 100644 --- a/storage/innobase/row/row0mysql.c +++ b/storage/innobase/row/row0mysql.c @@ -576,6 +576,7 @@ handle_new_error: case DB_DUPLICATE_KEY: case DB_FOREIGN_DUPLICATE_KEY: case DB_TOO_BIG_RECORD: + case DB_UNDO_RECORD_TOO_BIG: case DB_ROW_IS_REFERENCED: case DB_NO_REFERENCED_ROW: case DB_CANNOT_ADD_CONSTRAINT: @@ -2015,41 +2016,13 @@ row_create_index_for_mysql( trx_start_if_not_started(trx); - /* Check that the same column does not appear twice in the index. - Starting from 4.0.14, InnoDB should be able to cope with that, but - safer not to allow them. */ - - for (i = 0; i < dict_index_get_n_fields(index); i++) { - ulint j; - - for (j = 0; j < i; j++) { - if (0 == ut_strcmp( - dict_index_get_nth_field(index, j)->name, - dict_index_get_nth_field(index, i)->name)) { - ut_print_timestamp(stderr); - - fputs(" InnoDB: Error: column ", stderr); - ut_print_name(stderr, trx, FALSE, - dict_index_get_nth_field( - index, i)->name); - fputs(" appears twice in ", stderr); - dict_index_name_print(stderr, trx, index); - fputs("\n" - "InnoDB: This is not allowed" - " in InnoDB.\n", stderr); - - err = DB_COL_APPEARS_TWICE_IN_INDEX; - - goto error_handling; - } - } - - /* Check also that prefix_len and actual length - is less than that from DICT_MAX_FIELD_LEN_BY_FORMAT() */ + for (i = 0; i < index->n_def; i++) { + /* Check that prefix_len and actual length + < DICT_MAX_INDEX_COL_LEN */ len = dict_index_get_nth_field(index, i)->prefix_len; - if (field_lengths) { + if (field_lengths && field_lengths[i]) { len = ut_max(len, field_lengths[i]); } @@ -2057,6 +2030,7 @@ row_create_index_for_mysql( if (len > (ulint) DICT_MAX_FIELD_LEN_BY_FORMAT(table)) { err = DB_TOO_BIG_INDEX_COL; + dict_mem_index_free(index); goto error_handling; } } @@ -3125,7 +3099,8 @@ row_drop_table_for_mysql( ut_ad(rw_lock_own(&dict_operation_lock, RW_LOCK_EX)); #endif /* UNIV_SYNC_DEBUG */ - table = dict_table_get_low_ignore_err(name, DICT_ERR_IGNORE_INDEX_ROOT); + table = dict_table_get_low_ignore_err( + name, DICT_ERR_IGNORE_INDEX_ROOT | DICT_ERR_IGNORE_CORRUPT); if (!table) { err = DB_TABLE_NOT_FOUND; @@ -3272,6 +3247,19 @@ check_next_foreign: "index_id CHAR;\n" "foreign_id CHAR;\n" "found INT;\n" + + "DECLARE CURSOR cur_fk IS\n" + "SELECT ID FROM SYS_FOREIGN\n" + "WHERE FOR_NAME = :table_name\n" + "AND TO_BINARY(FOR_NAME)\n" + " = TO_BINARY(:table_name)\n" + "LOCK IN SHARE MODE;\n" + + "DECLARE CURSOR cur_idx IS\n" + "SELECT ID FROM SYS_INDEXES\n" + "WHERE TABLE_ID = table_id\n" + "LOCK IN SHARE MODE;\n" + "BEGIN\n" "SELECT ID INTO table_id\n" "FROM SYS_TABLES\n" @@ -3294,13 +3282,9 @@ check_next_foreign: "IF (:table_name = 'SYS_FOREIGN_COLS') THEN\n" " found := 0;\n" "END IF;\n" + "OPEN cur_fk;\n" "WHILE found = 1 LOOP\n" - " SELECT ID INTO foreign_id\n" - " FROM SYS_FOREIGN\n" - " WHERE FOR_NAME = :table_name\n" - " AND TO_BINARY(FOR_NAME)\n" - " = TO_BINARY(:table_name)\n" - " LOCK IN SHARE MODE;\n" + " FETCH cur_fk INTO foreign_id;\n" " IF (SQL % NOTFOUND) THEN\n" " found := 0;\n" " ELSE\n" @@ -3310,12 +3294,11 @@ check_next_foreign: " WHERE ID = foreign_id;\n" " END IF;\n" "END LOOP;\n" + "CLOSE cur_fk;\n" "found := 1;\n" + "OPEN cur_idx;\n" "WHILE found = 1 LOOP\n" - " SELECT ID INTO index_id\n" - " FROM SYS_INDEXES\n" - " WHERE TABLE_ID = table_id\n" - " LOCK IN SHARE MODE;\n" + " FETCH cur_idx INTO index_id;\n" " IF (SQL % NOTFOUND) THEN\n" " found := 0;\n" " ELSE\n" @@ -3326,6 +3309,7 @@ check_next_foreign: " AND TABLE_ID = table_id;\n" " END IF;\n" "END LOOP;\n" + "CLOSE cur_idx;\n" "DELETE FROM SYS_COLUMNS\n" "WHERE TABLE_ID = table_id;\n" "DELETE FROM SYS_TABLES\n" diff --git a/storage/innobase/row/row0purge.c b/storage/innobase/row/row0purge.c index 83e7c9e4857..efcfdc3bac5 100644 --- a/storage/innobase/row/row0purge.c +++ b/storage/innobase/row/row0purge.c @@ -1,6 +1,6 @@ /***************************************************************************** -Copyright (c) 1997, 2010, Innobase Oy. All Rights Reserved. +Copyright (c) 1997, 2011, Oracle and/or its affiliates. All Rights Reserved. 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 the Free Software @@ -11,8 +11,8 @@ ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. 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., 59 Temple -Place, Suite 330, Boston, MA 02111-1307 USA +this program; if not, write to the Free Software Foundation, Inc., +51 Franklin Street, Suite 500, Boston, MA 02110-1335 USA *****************************************************************************/ @@ -469,6 +469,13 @@ row_purge_del_mark( heap = mem_heap_create(1024); while (node->index != NULL) { + /* skip corrupted secondary index */ + dict_table_skip_corrupt_index(node->index); + + if (!node->index) { + break; + } + index = node->index; /* Build the index entry */ @@ -508,7 +515,8 @@ row_purge_upd_exist_or_extern_func( ut_ad(node); - if (node->rec_type == TRX_UNDO_UPD_DEL_REC) { + if (node->rec_type == TRX_UNDO_UPD_DEL_REC + || (node->cmpl_info & UPD_NODE_NO_ORD_CHANGE)) { goto skip_secondaries; } @@ -516,6 +524,12 @@ row_purge_upd_exist_or_extern_func( heap = mem_heap_create(1024); while (node->index != NULL) { + dict_table_skip_corrupt_index(node->index); + + if (!node->index) { + break; + } + index = node->index; if (row_upd_changes_ord_field_binary(node->index, node->update, @@ -632,14 +646,14 @@ row_purge_parse_undo_rec( roll_ptr_t roll_ptr; ulint info_bits; ulint type; - ulint cmpl_info; ut_ad(node && thr); trx = thr_get_trx(thr); - ptr = trx_undo_rec_get_pars(node->undo_rec, &type, &cmpl_info, - updated_extern, &undo_no, &table_id); + ptr = trx_undo_rec_get_pars( + node->undo_rec, &type, &node->cmpl_info, + updated_extern, &undo_no, &table_id); node->rec_type = type; if (type == TRX_UNDO_UPD_DEL_REC && !(*updated_extern)) { @@ -652,7 +666,8 @@ row_purge_parse_undo_rec( node->table = NULL; if (type == TRX_UNDO_UPD_EXIST_REC - && cmpl_info & UPD_NODE_NO_ORD_CHANGE && !(*updated_extern)) { + && node->cmpl_info & UPD_NODE_NO_ORD_CHANGE + && !(*updated_extern)) { /* Purge requires no changes to indexes: we may return */ @@ -702,7 +717,7 @@ err_exit: /* Read to the partial row the fields that occur in indexes */ - if (!(cmpl_info & UPD_NODE_NO_ORD_CHANGE)) { + if (!(node->cmpl_info & UPD_NODE_NO_ORD_CHANGE)) { ptr = trx_undo_rec_get_partial_row( ptr, clust_index, &node->row, type == TRX_UNDO_UPD_DEL_REC, diff --git a/storage/innobase/row/row0row.c b/storage/innobase/row/row0row.c index 3bd0323ddbe..20fd475343e 100644 --- a/storage/innobase/row/row0row.c +++ b/storage/innobase/row/row0row.c @@ -101,12 +101,27 @@ row_build_index_entry( dfield_copy(dfield, dfield2); - if (dfield_is_null(dfield) || ind_field->prefix_len == 0) { + if (dfield_is_null(dfield)) { continue; } - /* If a column prefix index, take only the prefix. - Prefix-indexed columns may be externally stored. */ + if (ind_field->prefix_len == 0 + && (!dfield_is_ext(dfield) + || dict_index_is_clust(index))) { + /* The dfield_copy() above suffices for + columns that are stored in-page, or for + clustered index record columns that are not + part of a column prefix in the PRIMARY KEY. */ + continue; + } + + /* If the column is stored externally (off-page) in + the clustered index, it must be an ordering field in + the secondary index. In the Antelope format, only + prefix-indexed columns may be stored off-page in the + clustered index record. In the Barracuda format, also + fully indexed long CHAR or VARCHAR columns may be + stored off-page. */ ut_ad(col->ord_part); if (UNIV_LIKELY_NULL(ext)) { @@ -119,15 +134,41 @@ row_build_index_entry( } dfield_set_data(dfield, buf, len); } + + if (ind_field->prefix_len == 0) { + /* In the Barracuda format + (ROW_FORMAT=DYNAMIC or + ROW_FORMAT=COMPRESSED), we can have a + secondary index on an entire column + that is stored off-page in the + clustered index. As this is not a + prefix index (prefix_len == 0), + include the entire off-page column in + the secondary index record. */ + continue; + } } else if (dfield_is_ext(dfield)) { + /* This table is either in Antelope format + (ROW_FORMAT=REDUNDANT or ROW_FORMAT=COMPACT) + or a purge record where the ordered part of + the field is not external. + In Antelope, the maximum column prefix + index length is 767 bytes, and the clustered + index record contains a 768-byte prefix of + each off-page column. */ ut_a(len >= BTR_EXTERN_FIELD_REF_SIZE); len -= BTR_EXTERN_FIELD_REF_SIZE; + dfield_set_len(dfield, len); } - len = dtype_get_at_most_n_mbchars( - col->prtype, col->mbminmaxlen, - ind_field->prefix_len, len, dfield_get_data(dfield)); - dfield_set_len(dfield, len); + /* If a column prefix index, take only the prefix. */ + if (ind_field->prefix_len) { + len = dtype_get_at_most_n_mbchars( + col->prtype, col->mbminmaxlen, + ind_field->prefix_len, len, + dfield_get_data(dfield)); + dfield_set_len(dfield, len); + } } ut_ad(dtuple_check_typed(entry)); diff --git a/storage/innobase/row/row0sel.c b/storage/innobase/row/row0sel.c index 53d0c2ec232..5d8f53f68da 100644 --- a/storage/innobase/row/row0sel.c +++ b/storage/innobase/row/row0sel.c @@ -1,6 +1,6 @@ /***************************************************************************** -Copyright (c) 1997, 2010, Innobase Oy. All Rights Reserved. +Copyright (c) 1997, 2011, Oracle and/or its affiliates. All Rights Reserved. Copyright (c) 2008, Google Inc. Portions of this file contain modifications contributed and copyrighted by @@ -99,14 +99,22 @@ row_sel_sec_rec_is_for_blob( ulint clust_len, /*!< in: length of clust_field */ const byte* sec_field, /*!< in: column in secondary index */ ulint sec_len, /*!< in: length of sec_field */ + ulint prefix_len, /*!< in: index column prefix length + in bytes */ dict_table_t* table) /*!< in: table */ { ulint len; byte buf[REC_VERSION_56_MAX_INDEX_COL_LEN]; ulint zip_size = dict_table_flags_to_zip_size(table->flags); - ulint max_prefix_len = DICT_MAX_FIELD_LEN_BY_FORMAT(table); + /* This function should never be invoked on an Antelope format + table, because they should always contain enough prefix in the + clustered index record. */ + ut_ad(dict_table_get_format(table) >= DICT_TF_FORMAT_ZIP); ut_a(clust_len >= BTR_EXTERN_FIELD_REF_SIZE); + ut_ad(prefix_len >= sec_len); + ut_ad(prefix_len > 0); + ut_a(prefix_len <= sizeof buf); if (UNIV_UNLIKELY (!memcmp(clust_field + clust_len - BTR_EXTERN_FIELD_REF_SIZE, @@ -118,7 +126,7 @@ row_sel_sec_rec_is_for_blob( return(FALSE); } - len = btr_copy_externally_stored_field_prefix(buf, max_prefix_len, + len = btr_copy_externally_stored_field_prefix(buf, prefix_len, zip_size, clust_field, clust_len); @@ -132,7 +140,7 @@ row_sel_sec_rec_is_for_blob( } len = dtype_get_at_most_n_mbchars(prtype, mbminmaxlen, - sec_len, len, (const char*) buf); + prefix_len, len, (const char*) buf); return(!cmp_data_data(mtype, prtype, buf, len, sec_field, sec_len)); } @@ -224,6 +232,7 @@ row_sel_sec_rec_is_for_clust_rec( col->mbminmaxlen, clust_field, clust_len, sec_field, sec_len, + ifield->prefix_len, clust_index->table)) { goto inequal; } @@ -493,7 +502,7 @@ sel_col_prefetch_buf_alloc( sel_buf = column->prefetch_buf + i; sel_buf->data = NULL; - + sel_buf->len = 0; sel_buf->val_buf_size = 0; } } @@ -518,6 +527,8 @@ sel_col_prefetch_buf_free( mem_free(sel_buf->data); } } + + mem_free(prefetch_buf); } /*********************************************************************//** @@ -2541,6 +2552,8 @@ row_sel_field_store_in_mysql_format( ut_ad(len != UNIV_SQL_NULL); UNIV_MEM_ASSERT_RW(data, len); + UNIV_MEM_ASSERT_W(dest, templ->mysql_col_len); + UNIV_MEM_INVALID(dest, templ->mysql_col_len); switch (templ->type) { const byte* field_end; @@ -2579,14 +2592,16 @@ row_sel_field_store_in_mysql_format( dest = row_mysql_store_true_var_len( dest, len, templ->mysql_length_bytes); + /* Copy the actual data. Leave the rest of the + buffer uninitialized. */ + memcpy(dest, data, len); + break; } /* Copy the actual data */ ut_memcpy(dest, data, len); - /* Pad with trailing spaces. We pad with spaces also the - unused end of a >= 5.0.3 true VARCHAR column, just in case - MySQL expects its contents to be deterministic. */ + /* Pad with trailing spaces. */ pad = dest + len; @@ -3113,6 +3128,39 @@ sel_restore_position_for_mysql( } /********************************************************************//** +Copies a cached field for MySQL from the fetch cache. */ +static +void +row_sel_copy_cached_field_for_mysql( +/*================================*/ + byte* buf, /*!< in/out: row buffer */ + const byte* cache, /*!< in: cached row */ + const mysql_row_templ_t*templ) /*!< in: column template */ +{ + ulint len; + + buf += templ->mysql_col_offset; + cache += templ->mysql_col_offset; + + UNIV_MEM_ASSERT_W(buf, templ->mysql_col_len); + + if (templ->mysql_type == DATA_MYSQL_TRUE_VARCHAR + && templ->type != DATA_INT) { + /* Check for != DATA_INT to make sure we do + not treat MySQL ENUM or SET as a true VARCHAR! + Find the actual length of the true VARCHAR field. */ + row_mysql_read_true_varchar( + &len, cache, templ->mysql_length_bytes); + len += templ->mysql_length_bytes; + UNIV_MEM_INVALID(buf, templ->mysql_col_len); + } else { + len = templ->mysql_col_len; + } + + ut_memcpy(buf, cache, len); +} + +/********************************************************************//** Pops a cached row for MySQL from the fetch cache. */ UNIV_INLINE void @@ -3124,26 +3172,22 @@ row_sel_pop_cached_row_for_mysql( { ulint i; const mysql_row_templ_t*templ; - byte* cached_rec; + const byte* cached_rec; ut_ad(prebuilt->n_fetch_cached > 0); ut_ad(prebuilt->mysql_prefix_len <= prebuilt->mysql_row_len); + UNIV_MEM_ASSERT_W(buf, prebuilt->mysql_row_len); + + cached_rec = prebuilt->fetch_cache[prebuilt->fetch_cache_first]; + if (UNIV_UNLIKELY(prebuilt->keep_other_fields_on_keyread)) { /* Copy cache record field by field, don't touch fields that are not covered by current key */ - cached_rec = prebuilt->fetch_cache[ - prebuilt->fetch_cache_first]; for (i = 0; i < prebuilt->n_template; i++) { templ = prebuilt->mysql_template + i; -#if 0 /* Some of the cached_rec may legitimately be uninitialized. */ - UNIV_MEM_ASSERT_RW(cached_rec - + templ->mysql_col_offset, - templ->mysql_col_len); -#endif - ut_memcpy(buf + templ->mysql_col_offset, - cached_rec + templ->mysql_col_offset, - templ->mysql_col_len); + row_sel_copy_cached_field_for_mysql( + buf, cached_rec, templ); /* Copy NULL bit of the current field from cached_rec to buf */ if (templ->mysql_null_bit_mask) { @@ -3153,17 +3197,24 @@ row_sel_pop_cached_row_for_mysql( & (byte)templ->mysql_null_bit_mask; } } + } else if (prebuilt->mysql_prefix_len > 63) { + /* The record is long. Copy it field by field, in case + there are some long VARCHAR column of which only a + small length is being used. */ + UNIV_MEM_INVALID(buf, prebuilt->mysql_prefix_len); + + /* First copy the NULL bits. */ + ut_memcpy(buf, cached_rec, prebuilt->null_bitmap_len); + /* Then copy the requested fields. */ + + for (i = 0; i < prebuilt->n_template; i++) { + row_sel_copy_cached_field_for_mysql( + buf, cached_rec, prebuilt->mysql_template + i); + } + } else { + ut_memcpy(buf, cached_rec, prebuilt->mysql_prefix_len); } - else { -#if 0 /* Some of the cached_rec may legitimately be uninitialized. */ - UNIV_MEM_ASSERT_RW(prebuilt->fetch_cache - [prebuilt->fetch_cache_first], - prebuilt->mysql_prefix_len); -#endif - ut_memcpy(buf, - prebuilt->fetch_cache[prebuilt->fetch_cache_first], - prebuilt->mysql_prefix_len); - } + prebuilt->n_fetch_cached--; prebuilt->fetch_cache_first++; @@ -3401,6 +3452,13 @@ row_search_for_mysql( return(DB_MISSING_HISTORY); } + if (dict_index_is_corrupted(index)) { +#ifdef UNIV_SYNC_DEBUG + ut_ad(!sync_thread_levels_nonempty_trx(trx->has_search_latch)); +#endif /* UNIV_SYNC_DEBUG */ + return(DB_CORRUPTION); + } + if (UNIV_UNLIKELY(prebuilt->magic_n != ROW_PREBUILT_ALLOCATED)) { fprintf(stderr, "InnoDB: Error: trying to free a corrupt\n" diff --git a/storage/innobase/row/row0uins.c b/storage/innobase/row/row0uins.c index d25afed3840..4fa97c9355d 100644 --- a/storage/innobase/row/row0uins.c +++ b/storage/innobase/row/row0uins.c @@ -328,6 +328,8 @@ row_undo_ins( node->index = dict_table_get_next_index( dict_table_get_first_index(node->table)); + dict_table_skip_corrupt_index(node->index); + while (node->index != NULL) { dtuple_t* entry; ulint err; @@ -355,7 +357,7 @@ row_undo_ins( } } - node->index = dict_table_get_next_index(node->index); + dict_table_next_uncorrupted_index(node->index); } log_free_check(); diff --git a/storage/innobase/row/row0umod.c b/storage/innobase/row/row0umod.c index 2188fdeff49..b86ce9eeabd 100644 --- a/storage/innobase/row/row0umod.c +++ b/storage/innobase/row/row0umod.c @@ -573,6 +573,14 @@ row_undo_mod_upd_del_sec( heap = mem_heap_create(1024); while (node->index != NULL) { + + /* Skip all corrupted secondary index */ + dict_table_skip_corrupt_index(node->index); + + if (!node->index) { + break; + } + index = node->index; entry = row_build_index_entry(node->row, node->ext, @@ -626,6 +634,13 @@ row_undo_mod_del_mark_sec( heap = mem_heap_create(1024); while (node->index != NULL) { + /* Skip all corrupted secondary index */ + dict_table_skip_corrupt_index(node->index); + + if (!node->index) { + break; + } + index = node->index; entry = row_build_index_entry(node->row, node->ext, @@ -677,6 +692,13 @@ row_undo_mod_upd_exist_sec( heap = mem_heap_create(1024); while (node->index != NULL) { + /* Skip all corrupted secondary index */ + dict_table_skip_corrupt_index(node->index); + + if (!node->index) { + break; + } + index = node->index; if (row_upd_changes_ord_field_binary(node->index, node->update, @@ -859,6 +881,9 @@ row_undo_mod( node->index = dict_table_get_next_index( dict_table_get_first_index(node->table)); + /* Skip all corrupted secondary index */ + dict_table_skip_corrupt_index(node->index); + if (node->rec_type == TRX_UNDO_UPD_EXIST_REC) { err = row_undo_mod_upd_exist_sec(node, thr); diff --git a/storage/innobase/row/row0upd.c b/storage/innobase/row/row0upd.c index 053b3513f1d..0c6036fe218 100644 --- a/storage/innobase/row/row0upd.c +++ b/storage/innobase/row/row0upd.c @@ -2305,6 +2305,13 @@ row_upd( while (node->index != NULL) { + /* Skip corrupted index */ + dict_table_skip_corrupt_index(node->index); + + if (!node->index) { + break; + } + log_free_check(); err = row_upd_sec_step(node, thr); diff --git a/storage/innobase/srv/srv0srv.c b/storage/innobase/srv/srv0srv.c index 04503d25cd4..c7427abdddd 100644 --- a/storage/innobase/srv/srv0srv.c +++ b/storage/innobase/srv/srv0srv.c @@ -222,6 +222,8 @@ UNIV_INTERN ulint srv_n_file_io_threads = ULINT_MAX; UNIV_INTERN ulint srv_n_read_io_threads = ULINT_MAX; UNIV_INTERN ulint srv_n_write_io_threads = ULINT_MAX; +/* Switch to enable random read ahead. */ +UNIV_INTERN my_bool srv_random_read_ahead = FALSE; /* User settable value of the number of pages that must be present in the buffer cache and accessed sequentially for InnoDB to trigger a readahead request. */ @@ -2032,6 +2034,8 @@ srv_export_innodb_status(void) export_vars.innodb_buffer_pool_wait_free = srv_buf_pool_wait_free; export_vars.innodb_buffer_pool_pages_flushed = srv_buf_pool_flushed; export_vars.innodb_buffer_pool_reads = srv_buf_pool_reads; + export_vars.innodb_buffer_pool_read_ahead_rnd + = stat.n_ra_pages_read_rnd; export_vars.innodb_buffer_pool_read_ahead = stat.n_ra_pages_read; export_vars.innodb_buffer_pool_read_ahead_evicted diff --git a/storage/innobase/sync/sync0rw.c b/storage/innobase/sync/sync0rw.c index 397d505df50..fc4f987fe65 100644 --- a/storage/innobase/sync/sync0rw.c +++ b/storage/innobase/sync/sync0rw.c @@ -626,6 +626,9 @@ rw_lock_x_lock_func( ibool spinning = FALSE; ut_ad(rw_lock_validate(lock)); +#ifdef UNIV_SYNC_DEBUG + ut_ad(!rw_lock_own(lock, RW_LOCK_SHARED)); +#endif /* UNIV_SYNC_DEBUG */ i = 0; @@ -715,7 +718,7 @@ mutex. */ UNIV_INTERN void rw_lock_debug_mutex_enter(void) -/*==========================*/ +/*===========================*/ { loop: if (0 == mutex_enter_nowait(&rw_lock_debug_mutex)) { @@ -942,11 +945,13 @@ rw_lock_list_print_info( putc('\n', file); } + rw_lock_debug_mutex_enter(); info = UT_LIST_GET_FIRST(lock->debug_list); while (info != NULL) { rw_lock_debug_print(file, info); info = UT_LIST_GET_NEXT(list, info); } + rw_lock_debug_mutex_exit(); } #ifndef INNODB_RW_LOCKS_USE_ATOMICS mutex_exit(&(lock->mutex)); @@ -990,11 +995,13 @@ rw_lock_print( putc('\n', stderr); } + rw_lock_debug_mutex_enter(); info = UT_LIST_GET_FIRST(lock->debug_list); while (info != NULL) { rw_lock_debug_print(stderr, info); info = UT_LIST_GET_NEXT(list, info); } + rw_lock_debug_mutex_exit(); } } diff --git a/storage/innobase/sync/sync0sync.c b/storage/innobase/sync/sync0sync.c index cef50fe4aff..993d44173ee 100644 --- a/storage/innobase/sync/sync0sync.c +++ b/storage/innobase/sync/sync0sync.c @@ -1212,7 +1212,6 @@ sync_thread_add_level( case SYNC_WORK_QUEUE: case SYNC_LOG: case SYNC_LOG_FLUSH_ORDER: - case SYNC_THR_LOCAL: case SYNC_ANY_LATCH: case SYNC_FILE_FORMAT_TAG: case SYNC_DOUBLEWRITE: @@ -1230,6 +1229,7 @@ sync_thread_add_level( case SYNC_DICT_HEADER: case SYNC_TRX_I_S_RWLOCK: case SYNC_TRX_I_S_LAST_READ: + case SYNC_IBUF_MUTEX: if (!sync_thread_levels_g(array, level, TRUE)) { fprintf(stderr, "InnoDB: sync_thread_levels_g(array, %lu)" @@ -1315,22 +1315,33 @@ sync_thread_add_level( || sync_thread_levels_g(array, SYNC_TREE_NODE - 1, TRUE)); break; case SYNC_TREE_NODE_NEW: - ut_a(sync_thread_levels_contain(array, SYNC_FSP_PAGE) - || sync_thread_levels_contain(array, SYNC_IBUF_MUTEX)); + ut_a(sync_thread_levels_contain(array, SYNC_FSP_PAGE)); break; case SYNC_INDEX_TREE: - if (sync_thread_levels_contain(array, SYNC_IBUF_MUTEX) - && sync_thread_levels_contain(array, SYNC_FSP)) { - ut_a(sync_thread_levels_g(array, SYNC_FSP_PAGE - 1, - TRUE)); + ut_a(sync_thread_levels_g(array, SYNC_TREE_NODE - 1, TRUE)); + break; + case SYNC_IBUF_TREE_NODE: + ut_a(sync_thread_levels_contain(array, SYNC_IBUF_INDEX_TREE) + || sync_thread_levels_g(array, SYNC_IBUF_TREE_NODE - 1, + TRUE)); + break; + case SYNC_IBUF_TREE_NODE_NEW: + /* ibuf_add_free_page() allocates new pages for the + change buffer while only holding the tablespace + x-latch. These pre-allocated new pages may only be + taken in use while holding ibuf_mutex, in + btr_page_alloc_for_ibuf(). */ + ut_a(sync_thread_levels_contain(array, SYNC_IBUF_MUTEX) + || sync_thread_levels_contain(array, SYNC_FSP)); + break; + case SYNC_IBUF_INDEX_TREE: + if (sync_thread_levels_contain(array, SYNC_FSP)) { + ut_a(sync_thread_levels_g(array, level - 1, TRUE)); } else { - ut_a(sync_thread_levels_g(array, SYNC_TREE_NODE - 1, - TRUE)); + ut_a(sync_thread_levels_g( + array, SYNC_IBUF_TREE_NODE - 1, TRUE)); } break; - case SYNC_IBUF_MUTEX: - ut_a(sync_thread_levels_g(array, SYNC_FSP_PAGE - 1, TRUE)); - break; case SYNC_IBUF_PESS_INSERT_MUTEX: ut_a(sync_thread_levels_g(array, SYNC_FSP - 1, TRUE)); ut_a(!sync_thread_levels_contain(array, SYNC_IBUF_MUTEX)); diff --git a/storage/innobase/trx/trx0rec.c b/storage/innobase/trx/trx0rec.c index 70b77ace726..0bf41780fcc 100644 --- a/storage/innobase/trx/trx0rec.c +++ b/storage/innobase/trx/trx0rec.c @@ -669,7 +669,6 @@ trx_undo_page_report_modify( /* Save to the undo log the old values of the columns to be updated. */ if (update) { - if (trx_undo_left(undo_page, ptr) < 5) { return(0); @@ -1119,13 +1118,14 @@ trx_undo_rec_get_partial_row( #endif /* !UNIV_HOTBACKUP */ /***********************************************************************//** -Erases the unused undo log page end. */ -static -void +Erases the unused undo log page end. +@return TRUE if the page contained something, FALSE if it was empty */ +static __attribute__((nonnull)) +ibool trx_undo_erase_page_end( /*====================*/ - page_t* undo_page, /*!< in: undo page whose end to erase */ - mtr_t* mtr) /*!< in: mtr */ + page_t* undo_page, /*!< in/out: undo page whose end to erase */ + mtr_t* mtr) /*!< in/out: mini-transaction */ { ulint first_free; @@ -1135,6 +1135,7 @@ trx_undo_erase_page_end( (UNIV_PAGE_SIZE - FIL_PAGE_DATA_END) - first_free); mlog_write_initial_log_record(undo_page, MLOG_UNDO_ERASE_END, mtr); + return(first_free != TRX_UNDO_PAGE_HDR + TRX_UNDO_PAGE_HDR_SIZE); } /***********************************************************//** @@ -1202,6 +1203,9 @@ trx_undo_report_row_operation( mem_heap_t* heap = NULL; ulint offsets_[REC_OFFS_NORMAL_SIZE]; ulint* offsets = offsets_; +#ifdef UNIV_DEBUG + int loop_count = 0; +#endif /* UNIV_DEBUG */ rec_offs_init(offsets_); ut_a(dict_index_is_clust(index)); @@ -1264,7 +1268,7 @@ trx_undo_report_row_operation( mtr_start(&mtr); - for (;;) { + do { buf_block_t* undo_block; page_t* undo_page; ulint offset; @@ -1293,7 +1297,31 @@ trx_undo_report_row_operation( version the replicate page constructed using the log records stays identical to the original page */ - trx_undo_erase_page_end(undo_page, &mtr); + if (!trx_undo_erase_page_end(undo_page, &mtr)) { + /* The record did not fit on an empty + undo page. Discard the freshly allocated + page and return an error. */ + + /* When we remove a page from an undo + log, this is analogous to a + pessimistic insert in a B-tree, and we + must reserve the counterpart of the + tree latch, which is the rseg + mutex. We must commit the mini-transaction + first, because it may be holding lower-level + latches, such as SYNC_FSP and SYNC_FSP_PAGE. */ + + mtr_commit(&mtr); + mtr_start(&mtr); + + mutex_enter(&rseg->mutex); + trx_undo_free_last_page(trx, undo, &mtr); + mutex_exit(&rseg->mutex); + + err = DB_UNDO_RECORD_TOO_BIG; + goto err_exit; + } + mtr_commit(&mtr); } else { /* Success */ @@ -1313,16 +1341,15 @@ trx_undo_report_row_operation( *roll_ptr = trx_undo_build_roll_ptr( op_type == TRX_UNDO_INSERT_OP, rseg->id, page_no, offset); - if (UNIV_LIKELY_NULL(heap)) { - mem_heap_free(heap); - } - return(DB_SUCCESS); + err = DB_SUCCESS; + goto func_exit; } ut_ad(page_no == undo->last_page_no); /* We have to extend the undo log by one page */ + ut_ad(++loop_count < 2); mtr_start(&mtr); /* When we add a page to an undo log, this is analogous to @@ -1334,18 +1361,19 @@ trx_undo_report_row_operation( page_no = trx_undo_add_page(trx, undo, &mtr); mutex_exit(&(rseg->mutex)); + } while (UNIV_LIKELY(page_no != FIL_NULL)); - if (UNIV_UNLIKELY(page_no == FIL_NULL)) { - /* Did not succeed: out of space */ + /* Did not succeed: out of space */ + err = DB_OUT_OF_FILE_SPACE; - mutex_exit(&(trx->undo_mutex)); - mtr_commit(&mtr); - if (UNIV_LIKELY_NULL(heap)) { - mem_heap_free(heap); - } - return(DB_OUT_OF_FILE_SPACE); - } +err_exit: + mutex_exit(&trx->undo_mutex); + mtr_commit(&mtr); +func_exit: + if (UNIV_LIKELY_NULL(heap)) { + mem_heap_free(heap); } + return(err); } /*============== BUILDING PREVIOUS VERSION OF A RECORD ===============*/ diff --git a/storage/innobase/trx/trx0undo.c b/storage/innobase/trx/trx0undo.c index 4cb4b7b79c5..dae0637f72c 100644 --- a/storage/innobase/trx/trx0undo.c +++ b/storage/innobase/trx/trx0undo.c @@ -1004,29 +1004,28 @@ trx_undo_free_page( } /********************************************************************//** -Frees an undo log page when there is also the memory object for the undo -log. */ -static +Frees the last undo log page. +The caller must hold the rollback segment mutex. */ +UNIV_INTERN void -trx_undo_free_page_in_rollback( -/*===========================*/ - trx_t* trx __attribute__((unused)), /*!< in: transaction */ - trx_undo_t* undo, /*!< in: undo log memory copy */ - ulint page_no,/*!< in: page number to free: must not be the - header page */ - mtr_t* mtr) /*!< in: mtr which does not have a latch to any - undo log page; the caller must have reserved - the rollback segment mutex */ +trx_undo_free_last_page_func( +/*==========================*/ +#ifdef UNIV_DEBUG + const trx_t* trx, /*!< in: transaction */ +#endif /* UNIV_DEBUG */ + trx_undo_t* undo, /*!< in/out: undo log memory copy */ + mtr_t* mtr) /*!< in/out: mini-transaction which does not + have a latch to any undo log page or which + has allocated the undo log page */ { - ulint last_page_no; - - ut_ad(undo->hdr_page_no != page_no); - ut_ad(mutex_own(&(trx->undo_mutex))); + ut_ad(mutex_own(&trx->undo_mutex)); + ut_ad(undo->hdr_page_no != undo->last_page_no); + ut_ad(undo->size > 0); - last_page_no = trx_undo_free_page(undo->rseg, FALSE, undo->space, - undo->hdr_page_no, page_no, mtr); + undo->last_page_no = trx_undo_free_page( + undo->rseg, FALSE, undo->space, + undo->hdr_page_no, undo->last_page_no, mtr); - undo->last_page_no = last_page_no; undo->size--; } @@ -1062,9 +1061,11 @@ Truncates an undo log from the end. This function is used during a rollback to free space from an undo log. */ UNIV_INTERN void -trx_undo_truncate_end( -/*==================*/ - trx_t* trx, /*!< in: transaction whose undo log it is */ +trx_undo_truncate_end_func( +/*=======================*/ +#ifdef UNIV_DEBUG + const trx_t* trx, /*!< in: transaction whose undo log it is */ +#endif /* UNIV_DEBUG */ trx_undo_t* undo, /*!< in: undo log */ undo_no_t limit) /*!< in: all undo records with undo number >= this value should be truncated */ @@ -1090,18 +1091,7 @@ trx_undo_truncate_end( rec = trx_undo_page_get_last_rec(undo_page, undo->hdr_page_no, undo->hdr_offset); - for (;;) { - if (rec == NULL) { - if (last_page_no == undo->hdr_page_no) { - - goto function_exit; - } - - trx_undo_free_page_in_rollback( - trx, undo, last_page_no, &mtr); - break; - } - + while (rec) { if (trx_undo_rec_get_undo_no(rec) >= limit) { /* Truncate at least this record off, maybe more */ @@ -1115,6 +1105,14 @@ trx_undo_truncate_end( undo->hdr_offset); } + if (last_page_no == undo->hdr_page_no) { + + goto function_exit; + } + + ut_ad(last_page_no == undo->last_page_no); + trx_undo_free_last_page(trx, undo, &mtr); + mtr_commit(&mtr); } diff --git a/storage/innobase/ut/ut0mem.c b/storage/innobase/ut/ut0mem.c index 53f15029e1b..303fdd6dd44 100644 --- a/storage/innobase/ut/ut0mem.c +++ b/storage/innobase/ut/ut0mem.c @@ -1,6 +1,6 @@ /***************************************************************************** -Copyright (c) 1994, 2009, Innobase Oy. All Rights Reserved. +Copyright (c) 1994, 2011, Oracle and/or its affiliates. All Rights Reserved. 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 the Free Software @@ -483,53 +483,6 @@ ut_strlcpy_rev( return(src_size); } -/**********************************************************************//** -Make a quoted copy of a NUL-terminated string. Leading and trailing -quotes will not be included; only embedded quotes will be escaped. -See also ut_strlenq() and ut_memcpyq(). -@return pointer to end of dest */ -UNIV_INTERN -char* -ut_strcpyq( -/*=======*/ - char* dest, /*!< in: output buffer */ - char q, /*!< in: the quote character */ - const char* src) /*!< in: null-terminated string */ -{ - while (*src) { - if ((*dest++ = *src++) == q) { - *dest++ = q; - } - } - - return(dest); -} - -/**********************************************************************//** -Make a quoted copy of a fixed-length string. Leading and trailing -quotes will not be included; only embedded quotes will be escaped. -See also ut_strlenq() and ut_strcpyq(). -@return pointer to end of dest */ -UNIV_INTERN -char* -ut_memcpyq( -/*=======*/ - char* dest, /*!< in: output buffer */ - char q, /*!< in: the quote character */ - const char* src, /*!< in: string to be quoted */ - ulint len) /*!< in: length of src */ -{ - const char* srcend = src + len; - - while (src < srcend) { - if ((*dest++ = *src++) == q) { - *dest++ = q; - } - } - - return(dest); -} - #ifndef UNIV_HOTBACKUP /**********************************************************************//** Return the number of times s2 occurs in s1. Overlapping instances of s2 diff --git a/storage/innobase/ut/ut0ut.c b/storage/innobase/ut/ut0ut.c index a9c0d381e16..f6dfb3ba0b3 100644 --- a/storage/innobase/ut/ut0ut.c +++ b/storage/innobase/ut/ut0ut.c @@ -674,8 +674,6 @@ ut_strerr( return("Cannot add constraint"); case DB_CORRUPTION: return("Data structure corruption"); - case DB_COL_APPEARS_TWICE_IN_INDEX: - return("Column appears twice in index"); case DB_CANNOT_DROP_CONSTRAINT: return("Cannot drop constraint"); case DB_NO_SAVEPOINT: @@ -714,6 +712,10 @@ ut_strerr( return("No index on referencing keys in referencing table"); case DB_PARENT_NO_INDEX: return("No index on referenced keys in referenced table"); + case DB_INDEX_CORRUPT: + return("Index corrupted"); + case DB_UNDO_RECORD_TOO_BIG: + return("Undo record too big"); case DB_END_OF_INDEX: return("End of index"); /* do not add default: in order to produce a warning if new code diff --git a/storage/maria/ha_maria.cc b/storage/maria/ha_maria.cc index 50b7bf9f5d1..0b58afc23c9 100644 --- a/storage/maria/ha_maria.cc +++ b/storage/maria/ha_maria.cc @@ -156,10 +156,16 @@ static MYSQL_SYSVAR_ULONG(block_size, maria_block_size, static MYSQL_SYSVAR_ULONG(checkpoint_interval, checkpoint_interval, PLUGIN_VAR_RQCMDARG, - "Interval between automatic checkpoints, in seconds; 0 means" + "Interval between tries to do an automatic checkpoints. In seconds; 0 means" " 'no automatic checkpoints' which makes sense only for testing.", NULL, update_checkpoint_interval, 30, 0, UINT_MAX, 1); +static MYSQL_SYSVAR_ULONG(checkpoint_log_activity, maria_checkpoint_min_log_activity, + PLUGIN_VAR_RQCMDARG, + "Number of bytes that the transaction log has to grow between checkpoints before a new " + "checkpoint is written to the log.", + NULL, NULL, 1024*1024, 0, UINT_MAX, 1); + static MYSQL_SYSVAR_ULONG(force_start_after_recovery_failures, force_start_after_recovery_failures, /* @@ -397,7 +403,7 @@ static void _ma_check_print_msg(HA_CHECK *param, const char *msg_type, if (!thd->vio_ok()) { - sql_print_error(fmt, args); + sql_print_error("%s.%s: %s", param->db_name, param->table_name, msgbuf); return; } @@ -405,6 +411,8 @@ static void _ma_check_print_msg(HA_CHECK *param, const char *msg_type, (T_CREATE_MISSING_KEYS | T_SAFE_REPAIR | T_AUTO_REPAIR)) { my_message(ER_NOT_KEYFILE, msgbuf, MYF(MY_WME)); + if (thd->variables.log_warnings > 2) + sql_print_error("%s.%s: %s", param->db_name, param->table_name, msgbuf); return; } length= (uint) (strxmov(name, param->db_name, ".", param->table_name, @@ -423,8 +431,11 @@ static void _ma_check_print_msg(HA_CHECK *param, const char *msg_type, protocol->store(msg_type, system_charset_info); protocol->store(msgbuf, msg_length, system_charset_info); if (protocol->write()) - sql_print_error("Failed on my_net_write, writing to stderr instead: %s\n", - msgbuf); + sql_print_error("Failed on my_net_write, writing to stderr instead: %s.%s: %s\n", + param->db_name, param->table_name, msgbuf); + else if (thd->variables.log_warnings > 2) + sql_print_error("%s.%s: %s", param->db_name, param->table_name, msgbuf); + return; } @@ -1018,8 +1029,7 @@ double ha_maria::scan_time() uint ha_maria::max_supported_key_length() const { - uint tmp= (maria_max_key_length() - 8 - HA_MAX_KEY_SEG*3); - return min(HA_MAX_KEY_BUFF, tmp); + return maria_max_key_length(); } @@ -2151,13 +2161,17 @@ bool ha_maria::check_and_repair(THD *thd) if (crashed) { + bool save_log_all_errors; sql_print_warning("Recovering table: '%s'", table->s->path.str); + save_log_all_errors= thd->log_all_errors; + thd->log_all_errors|= (thd->variables.log_warnings > 2); check_opt.flags= ((maria_recover_options & HA_RECOVER_BACKUP ? T_BACKUP_DATA : 0) | (maria_recover_options & HA_RECOVER_FORCE ? 0 : T_SAFE_REPAIR) | T_AUTO_REPAIR); if (repair(thd, &check_opt)) error= 1; + thd->log_all_errors= save_log_all_errors; } thd->set_query(query_backup); DBUG_RETURN(error); @@ -2480,9 +2494,6 @@ int ha_maria::extra(enum ha_extra_function operation) int ha_maria::reset(void) { - pushed_idx_cond= NULL; - pushed_idx_cond_keyno= MAX_KEY; - in_range_check_pushed_down= FALSE; ma_set_index_cond_func(file, NULL, 0); ds_mrr.dsmrr_close(); if (file->trn) @@ -2542,6 +2553,14 @@ void ha_maria::drop_table(const char *name) } +void ha_maria::change_table_ptr(TABLE *table_arg, TABLE_SHARE *share) +{ + handler::change_table_ptr(table_arg, share); + if (file) + file->external_ref= table_arg; +} + + int ha_maria::external_lock(THD *thd, int lock_type) { DBUG_ENTER("ha_maria::external_lock"); @@ -2641,7 +2660,7 @@ int ha_maria::external_lock(THD *thd, int lock_type) changes to commit (rollback shouldn't be tested). */ DBUG_ASSERT(!thd->stmt_da->is_sent || - thd->killed == THD::KILL_CONNECTION); + thd->killed == KILL_CONNECTION); /* autocommit ? rollback a transaction */ #ifdef MARIA_CANNOT_ROLLBACK if (ma_commit(trn)) @@ -3484,7 +3503,7 @@ my_bool ha_maria::register_query_cache_table(THD *thd, char *table_name, *engine_data= 0; if (file->s->now_transactional && file->s->have_versioning) - return (file->trn->trid >= file->s->state.last_change_trn); + DBUG_RETURN(file->trn->trid >= file->s->state.last_change_trn); /* If a concurrent INSERT has happened just before the currently processed @@ -3519,6 +3538,7 @@ my_bool ha_maria::register_query_cache_table(THD *thd, char *table_name, struct st_mysql_sys_var* system_variables[]= { MYSQL_SYSVAR(block_size), MYSQL_SYSVAR(checkpoint_interval), + MYSQL_SYSVAR(checkpoint_log_activity), MYSQL_SYSVAR(force_start_after_recovery_failures), MYSQL_SYSVAR(group_commit), MYSQL_SYSVAR(group_commit_interval), @@ -3552,6 +3572,7 @@ static void update_checkpoint_interval(MYSQL_THD thd, ma_checkpoint_init(*(ulong *)var_ptr= (ulong)(*(long *)save)); } + /** @brief Updates group commit mode */ @@ -3729,9 +3750,6 @@ Item *ha_maria::idx_cond_push(uint keyno_arg, Item* idx_cond_arg) return NULL; } - - - struct st_mysql_storage_engine maria_storage_engine= { MYSQL_HANDLERTON_INTERFACE_VERSION }; diff --git a/storage/maria/ha_maria.h b/storage/maria/ha_maria.h index 39c23c8d1b6..dba0aeaa20e 100644 --- a/storage/maria/ha_maria.h +++ b/storage/maria/ha_maria.h @@ -78,6 +78,7 @@ public: { return max_supported_key_length(); } enum row_type get_row_type() const; uint checksum() const; + void change_table_ptr(TABLE *table_arg, TABLE_SHARE *share); virtual double scan_time(); int open(const char *name, int mode, uint test_if_locked); diff --git a/storage/maria/ma_bitmap.c b/storage/maria/ma_bitmap.c index 483a7dd5c12..76049a54238 100644 --- a/storage/maria/ma_bitmap.c +++ b/storage/maria/ma_bitmap.c @@ -286,7 +286,7 @@ my_bool _ma_bitmap_init(MARIA_SHARE *share, File file, */ { pgcache_page_no_t last_bitmap_page; - ulong blocks, bytes; + pgcache_page_no_t blocks, bytes; last_bitmap_page= *last_page - *last_page % bitmap->pages_covered; blocks= *last_page - last_bitmap_page; @@ -1415,7 +1415,7 @@ static ulong allocate_full_pages(MARIA_FILE_BITMAP *bitmap, uchar *page_end= data + bitmap->total_size; uchar *best_data= 0; uint min_size; - uint best_area_size, UNINIT_VAR(best_prefix_area_size), best_suffix_area_size; + uint best_area_size, UNINIT_VAR(best_prefix_area_size); uint page, size; ulonglong UNINIT_VAR(best_prefix_bits); DBUG_ENTER("allocate_full_pages"); @@ -1491,7 +1491,6 @@ static ulong allocate_full_pages(MARIA_FILE_BITMAP *bitmap, best_area_size= area_size; best_prefix_bits= prefix_bits; best_prefix_area_size= prefix_area_size; - best_suffix_area_size= suffix_area_size; /* Prefer to put data in biggest possible area */ if (area_size <= pages_needed) diff --git a/storage/maria/ma_blockrec.c b/storage/maria/ma_blockrec.c index 2d2a770ba82..371325594af 100644 --- a/storage/maria/ma_blockrec.c +++ b/storage/maria/ma_blockrec.c @@ -5004,7 +5004,8 @@ static my_bool read_row_extent_info(MARIA_HA *info, uchar *buff, MARIA_EXTENT_CURSOR extent; MARIA_RECORD_POS *tail_pos; uchar *data, *end_of_data; - uint flag, row_extents, row_extents_size, field_lengths; + uint flag, row_extents, row_extents_size; + uint field_lengths __attribute__ ((unused)); uchar *extents, *end; DBUG_ENTER("read_row_extent_info"); @@ -5039,6 +5040,10 @@ static my_bool read_row_extent_info(MARIA_HA *info, uchar *buff, } info->cur_row.extents_count= row_extents; + /* + field_lengths looks unused but get_key_length will + increment data, which is required as data it's used later. + */ if (share->base.max_field_lengths) get_key_length(field_lengths, data); @@ -5327,7 +5332,6 @@ int _ma_scan_block_record(MARIA_HA *info, uchar *record, my_bool skip_deleted __attribute__ ((unused))) { uint block_size; - my_off_t filepos; MARIA_SHARE *share= info->s; DBUG_ENTER("_ma_scan_block_record"); @@ -5457,7 +5461,6 @@ restart_bitmap_scan: /* Read next bitmap */ info->scan.bitmap_page+= share->bitmap.pages_covered; - filepos= (my_off_t) info->scan.bitmap_page * block_size; if (unlikely(info->scan.bitmap_page >= info->scan.max_page)) { DBUG_PRINT("info", ("Found end of file")); @@ -6737,11 +6740,11 @@ uint _ma_apply_redo_insert_row_blobs(MARIA_HA *info, uint i; uint res; uint page_range; - pgcache_page_no_t page, start_page; + pgcache_page_no_t page; uchar *buff; uint data_on_page= data_size; - start_page= page= page_korr(header); + page= page_korr(header); header+= PAGE_STORE_SIZE; page_range= pagerange_korr(header); header+= PAGERANGE_STORE_SIZE; diff --git a/storage/maria/ma_check.c b/storage/maria/ma_check.c index 7f686c28532..4d60b4cafe5 100644 --- a/storage/maria/ma_check.c +++ b/storage/maria/ma_check.c @@ -2343,7 +2343,7 @@ static int initialize_variables_for_repair(HA_CHECK *param, return 1; } - /* Allow us to restore state and check how state changed */ + /* Make a copy to allow us to restore state and check how state changed */ memcpy(org_share, share, sizeof(*share)); /* Repair code relies on share->state.state so we have to update it here */ @@ -2363,6 +2363,14 @@ static int initialize_variables_for_repair(HA_CHECK *param, param->testflag&= ~T_QUICK; param->org_key_map= share->state.key_map; + /* + Clear check variables set by repair. This is needed to allow one to run + several repair's in a row with same param + */ + param->retry_repair= 0; + param->warning_printed= 0; + param->error_printed= 0; + sort_param->sort_info= sort_info; sort_param->fix_datafile= ! rep_quick; sort_param->calc_checksum= test(param->testflag & T_CALC_CHECKSUM); @@ -5660,7 +5668,8 @@ static my_off_t get_record_for_key(MARIA_KEYDEF *keyinfo, MARIA_KEY key; key.keyinfo= keyinfo; key.data= (uchar*) key_data; - key.data_length= _ma_keylength(keyinfo, key_data); + key.data_length= (_ma_keylength(keyinfo, key_data) - + keyinfo->share->rec_reflength); return _ma_row_pos_from_key(&key); } /* get_record_for_key */ @@ -5673,7 +5682,7 @@ static int sort_insert_key(MARIA_SORT_PARAM *sort_param, my_off_t prev_block) { uint a_length,t_length,nod_flag; - my_off_t filepos,key_file_length; + my_off_t filepos; uchar *anc_buff,*lastkey; MARIA_KEY_PARAM s_temp; MARIA_KEYDEF *keyinfo=sort_param->keyinfo; @@ -5741,7 +5750,6 @@ static int sort_insert_key(MARIA_SORT_PARAM *sort_param, _ma_store_page_used(share, anc_buff, key_block->last_length); bzero(anc_buff+key_block->last_length, keyinfo->block_length- key_block->last_length); - key_file_length=share->state.state.key_file_length; if ((filepos= _ma_new(info, DFLT_INIT_HITS, &page_link)) == HA_OFFSET_ERROR) DBUG_RETURN(1); _ma_fast_unlock_key_del(info); @@ -5852,7 +5860,7 @@ static int sort_delete_record(MARIA_SORT_PARAM *sort_param) int _ma_flush_pending_blocks(MARIA_SORT_PARAM *sort_param) { uint nod_flag,length; - my_off_t filepos,key_file_length; + my_off_t filepos; SORT_KEY_BLOCKS *key_block; MARIA_SORT_INFO *sort_info= sort_param->sort_info; myf myf_rw=sort_info->param->myf_rw; @@ -5869,7 +5877,6 @@ int _ma_flush_pending_blocks(MARIA_SORT_PARAM *sort_param) length= _ma_get_page_used(info->s, key_block->buff); if (nod_flag) _ma_kpointer(info,key_block->end_pos,filepos); - key_file_length= info->s->state.state.key_file_length; bzero(key_block->buff+length, keyinfo->block_length-length); if ((filepos= _ma_new(info, DFLT_INIT_HITS, &page_link)) == HA_OFFSET_ERROR) diff --git a/storage/maria/ma_checkpoint.c b/storage/maria/ma_checkpoint.c index dd188501f4e..addb014969a 100644 --- a/storage/maria/ma_checkpoint.c +++ b/storage/maria/ma_checkpoint.c @@ -534,8 +534,9 @@ filter_flush_file_evenly(enum pagecache_page_type type, risk could be that while a checkpoint happens no LRD flushing happens. */ -static uint maria_checkpoint_min_activity= 2*1024*1024; - +static ulong maria_checkpoint_min_cache_activity= 10*1024*1024; +/* Set in ha_maria.cc */ +ulong maria_checkpoint_min_log_activity= 1*1024*1024; pthread_handler_t ma_checkpoint_background(void *arg) { @@ -576,53 +577,62 @@ pthread_handler_t ma_checkpoint_background(void *arg) switch (sleeps % interval) { case 0: + { /* If checkpoints are disabled, wait 1 second and try again */ if (maria_checkpoint_disabled) { sleep_time= 1; break; } - /* - With background flushing evenly distributed over the time - between two checkpoints, we should have only little flushing to do - in the checkpoint. - */ - /* - No checkpoint if little work of interest for recovery was done - since last checkpoint. Such work includes log writing (lengthens - recovery, checkpoint would shorten it), page flushing (checkpoint - would decrease the amount of read pages in recovery). - In case of one short statement per minute (very low load), we don't - want to checkpoint every minute, hence the positive - maria_checkpoint_min_activity. - */ - - if (((translog_get_horizon() - log_horizon_at_last_checkpoint) + - (maria_pagecache->global_cache_write - - pagecache_flushes_at_last_checkpoint) * - maria_pagecache->block_size) < maria_checkpoint_min_activity) { - /* don't take checkpoint, so don't know what to flush */ - pages_to_flush_before_next_checkpoint= 0; - sleep_time= interval; - break; + TRANSLOG_ADDRESS horizon= translog_get_horizon(); + + /* + With background flushing evenly distributed over the time + between two checkpoints, we should have only little flushing to do + in the checkpoint. + */ + /* + No checkpoint if little work of interest for recovery was done + since last checkpoint. Such work includes log writing (lengthens + recovery, checkpoint would shorten it), page flushing (checkpoint + would decrease the amount of read pages in recovery). + In case of one short statement per minute (very low load), we don't + want to checkpoint every minute, hence the positive + maria_checkpoint_min_activity. + */ + if ((ulonglong) (horizon - log_horizon_at_last_checkpoint) <= + maria_checkpoint_min_log_activity && + ((ulonglong) (maria_pagecache->global_cache_write - + pagecache_flushes_at_last_checkpoint) * + maria_pagecache->block_size) <= + maria_checkpoint_min_cache_activity) + { + /* + Not enough has happend since last checkpoint. + Sleep for a while and try again later + */ + sleep_time= interval; + break; + } + sleep_time= 1; + ma_checkpoint_execute(CHECKPOINT_MEDIUM, TRUE); + /* + Snapshot this kind of "state" of the engine. Note that the value + below is possibly greater than last_checkpoint_lsn. + */ + log_horizon_at_last_checkpoint= translog_get_horizon(); + pagecache_flushes_at_last_checkpoint= + maria_pagecache->global_cache_write; + /* + If the checkpoint above succeeded it has set d|kfiles and + d|kfiles_end. If is has failed, it has set + pages_to_flush_before_next_checkpoint to 0 so we will skip flushing + and sleep until the next checkpoint. + */ } - sleep_time= 1; - ma_checkpoint_execute(CHECKPOINT_MEDIUM, TRUE); - /* - Snapshot this kind of "state" of the engine. Note that the value below - is possibly greater than last_checkpoint_lsn. - */ - log_horizon_at_last_checkpoint= translog_get_horizon(); - pagecache_flushes_at_last_checkpoint= - maria_pagecache->global_cache_write; - /* - If the checkpoint above succeeded it has set d|kfiles and - d|kfiles_end. If is has failed, it has set - pages_to_flush_before_next_checkpoint to 0 so we will skip flushing - and sleep until the next checkpoint. - */ break; + } case 1: /* set up parameters for background page flushing */ filter_param.up_to_lsn= last_checkpoint_lsn; diff --git a/storage/maria/ma_create.c b/storage/maria/ma_create.c index 5be819f341b..2173d2cac8f 100644 --- a/storage/maria/ma_create.c +++ b/storage/maria/ma_create.c @@ -621,7 +621,7 @@ int maria_create(const char *name, enum data_file_type datafile_type, to be able to put at least 2 keys on an index block for the key algorithms to work). */ - if (length > maria_max_key_length()) + if (length > _ma_max_key_length()) { my_errno=HA_WRONG_CREATE_OPTION; goto err_no_lock; diff --git a/storage/maria/ma_dynrec.c b/storage/maria/ma_dynrec.c index 70ecac318cc..c1c0a8e9729 100644 --- a/storage/maria/ma_dynrec.c +++ b/storage/maria/ma_dynrec.c @@ -1734,14 +1734,19 @@ int _ma_read_rnd_dynamic_record(MARIA_HA *info, MARIA_RECORD_POS filepos, my_bool skip_deleted_blocks) { - int block_of_record, info_read; + int block_of_record; +#ifdef MARIA_EXTERNAL_LOCKING + int info_read; +#endif uint left_len,b_type; uchar *UNINIT_VAR(to); MARIA_BLOCK_INFO block_info; MARIA_SHARE *share= info->s; DBUG_ENTER("_ma_read_rnd_dynamic_record"); +#ifdef MARIA_EXTERNAL_LOCKING info_read=0; +#endif if (info->lock_type == F_UNLCK) { @@ -1750,8 +1755,10 @@ int _ma_read_rnd_dynamic_record(MARIA_HA *info, info->tmp_lock_type=F_RDLCK; #endif } +#ifdef MARIA_EXTERNAL_LOCKING else info_read=1; /* memory-keyinfoblock is ok */ +#endif block_of_record= 0; /* First block of record is numbered as zero. */ block_info.second_read= 0; diff --git a/storage/maria/ma_ft_update.c b/storage/maria/ma_ft_update.c index 3e47f09c1fa..99748c65ebf 100644 --- a/storage/maria/ma_ft_update.c +++ b/storage/maria/ma_ft_update.c @@ -363,7 +363,7 @@ my_bool _ma_ft_convert_to_ft2(MARIA_HA *info, MARIA_KEY *key) for (key_ptr+=length; key_ptr < end; key_ptr+=keyinfo->keylength) { tmp_key.data= key_ptr; - if (_ma_ck_real_write_btree(info, key, &root, SEARCH_SAME)) + if (_ma_ck_real_write_btree(info, &tmp_key, &root, SEARCH_SAME)) DBUG_RETURN(1); } diff --git a/storage/maria/ma_info.c b/storage/maria/ma_info.c index 361ee41f2c8..fdd9ba7d2c6 100644 --- a/storage/maria/ma_info.c +++ b/storage/maria/ma_info.c @@ -28,6 +28,12 @@ MARIA_RECORD_POS maria_position(MARIA_HA *info) } +uint maria_max_key_length() +{ + uint tmp= (_ma_max_key_length() - 8 - HA_MAX_KEY_SEG*3); + return min(HA_MAX_KEY_BUFF, tmp); +} + /* Get information about the table */ /* if flag == 2 one get current info (no sync from database */ diff --git a/storage/maria/ma_key_recover.c b/storage/maria/ma_key_recover.c index 920f5a08013..9c794501022 100644 --- a/storage/maria/ma_key_recover.c +++ b/storage/maria/ma_key_recover.c @@ -944,7 +944,7 @@ uint _ma_apply_redo_index(MARIA_HA *info, uchar *buff; const uchar *header_end= header + head_length; uint page_offset= 0, org_page_length; - uint nod_flag, page_length, keypage_header, keynr; + uint page_length, keypage_header, keynr; uint max_page_size= share->max_index_block_size; int result; MARIA_PAGE page; @@ -972,7 +972,6 @@ uint _ma_apply_redo_index(MARIA_HA *info, keynr= _ma_get_keynr(share, buff); _ma_page_setup(&page, info, share->keyinfo + keynr, page_pos, buff); - nod_flag= page.node; org_page_length= page_length= page.size; keypage_header= share->keypage_header; diff --git a/storage/maria/ma_loghandler.c b/storage/maria/ma_loghandler.c index f437bf1399f..b3e4acb2995 100644 --- a/storage/maria/ma_loghandler.c +++ b/storage/maria/ma_loghandler.c @@ -2612,14 +2612,12 @@ static my_bool translog_buffer_flush(struct st_translog_buffer *buffer) i < buffer->size; i+= TRANSLOG_PAGE_SIZE, pg++) { - TRANSLOG_ADDRESS addr= (buffer->offset + i); - TRANSLOG_VALIDATOR_DATA data; + TRANSLOG_ADDRESS addr __attribute__((unused))= (buffer->offset + i); DBUG_PRINT("info", ("send log form %lu till %lu address: (%lu,0x%lx) " "page #: %lu buffer size: %lu buffer: 0x%lx", (ulong) i, (ulong) (i + TRANSLOG_PAGE_SIZE), LSN_IN_PARTS(addr), (ulong) pg, (ulong) buffer->size, (ulong) buffer)); - data.addr= &addr; DBUG_ASSERT(log_descriptor.pagecache->block_size == TRANSLOG_PAGE_SIZE); DBUG_ASSERT(i + TRANSLOG_PAGE_SIZE <= buffer->size); if (translog_status != TRANSLOG_OK && translog_status != TRANSLOG_SHUTDOWN) @@ -6568,16 +6566,12 @@ my_bool translog_scanner_init(LSN lsn, TRANSLOG_SCANNER_DATA *scanner, my_bool use_direct) { - TRANSLOG_VALIDATOR_DATA data; DBUG_ENTER("translog_scanner_init"); DBUG_PRINT("enter", ("Scanner: 0x%lx LSN: (%lu,0x%lx)", (ulong) scanner, LSN_IN_PARTS(lsn))); DBUG_ASSERT(translog_status == TRANSLOG_OK || translog_status == TRANSLOG_READONLY); - data.addr= &scanner->page_addr; - data.was_recovered= 0; - scanner->page_offset= LSN_OFFSET(lsn) % TRANSLOG_PAGE_SIZE; scanner->fixed_horizon= fixed_horizon; diff --git a/storage/maria/ma_open.c b/storage/maria/ma_open.c index d545ed76592..82e6e30839b 100644 --- a/storage/maria/ma_open.c +++ b/storage/maria/ma_open.c @@ -469,7 +469,7 @@ MARIA_HA *maria_open(const char *name, int mode, uint open_flags) } key_parts+=fulltext_keys*FT_SEGS; - if (share->base.max_key_length > maria_max_key_length() || + if (share->base.max_key_length > _ma_max_key_length() || keys > MARIA_MAX_KEY || key_parts > MARIA_MAX_KEY * HA_MAX_KEY_SEG) { DBUG_PRINT("error",("Wrong key info: Max_key_length: %d keys: %d key_parts: %d", share->base.max_key_length, keys, key_parts)); @@ -1861,7 +1861,7 @@ int _ma_open_datafile(MARIA_HA *info, MARIA_SHARE *share, const char *org_name, } info->dfile.file= share->bitmap.file.file= - mysql_file_open(key_file_dfile, share->data_file_name.str, + mysql_file_open(key_file_dfile, data_name, share->mode | O_SHARE, MYF(MY_WME)); return info->dfile.file >= 0 ? 0 : 1; } diff --git a/storage/maria/ma_recovery.c b/storage/maria/ma_recovery.c index b0ad778a4f2..893e393a79a 100644 --- a/storage/maria/ma_recovery.c +++ b/storage/maria/ma_recovery.c @@ -3216,9 +3216,11 @@ static LSN parse_checkpoint_record(LSN lsn) tprint(tracef, "Loading data from checkpoint record at LSN (%lu,0x%lx)\n", LSN_IN_PARTS(lsn)); - if ((len= translog_read_record_header(lsn, &rec)) == RECHEADER_READ_ERROR) + if ((len= translog_read_record_header(lsn, &rec)) == RECHEADER_READ_ERROR || + rec.type != LOGREC_CHECKPOINT) { - tprint(tracef, "Cannot find checkpoint record where it should be\n"); + eprint(tracef, "Cannot find checkpoint record at LSN (%lu,0x%lx)", + LSN_IN_PARTS(lsn)); return LSN_ERROR; } diff --git a/storage/maria/ma_rt_split.c b/storage/maria/ma_rt_split.c index 6f32a60c073..ea90b60ce12 100644 --- a/storage/maria/ma_rt_split.c +++ b/storage/maria/ma_rt_split.c @@ -380,7 +380,6 @@ int maria_rtree_split_page(const MARIA_KEY *key, MARIA_PAGE *page, SplitStruct *stop; double *coord_buf; double *next_coord; - double *old_coord; int n_dim; uchar *source_cur, *cur1, *cur2; uchar *new_page_buff, *log_internal_copy, *log_internal_copy_ptr, @@ -426,7 +425,6 @@ int maria_rtree_split_page(const MARIA_KEY *key, MARIA_PAGE *page, maria_rtree_d_mbr(keyinfo->seg, key->data, key_data_length, cur->coords); cur->key= key->data; - old_coord= next_coord; if (split_maria_rtree_node(task, max_keys + 1, page->size + full_length + 2, diff --git a/storage/maria/maria_def.h b/storage/maria/maria_def.h index cd3294e8975..25c09e8de33 100644 --- a/storage/maria/maria_def.h +++ b/storage/maria/maria_def.h @@ -738,7 +738,7 @@ struct st_maria_handler { length=mi_uint2korr((key)+1)+3; } \ } -#define maria_max_key_length() ((maria_block_size - MAX_KEYPAGE_HEADER_SIZE)/3 - MARIA_INDEX_OVERHEAD_SIZE) +#define _ma_max_key_length() ((maria_block_size - MAX_KEYPAGE_HEADER_SIZE)/3 - MARIA_INDEX_OVERHEAD_SIZE) #define get_pack_length(length) ((length) >= 255 ? 3 : 1) #define _ma_have_versioning(info) ((info)->row_flag & ROW_FLAG_TRANSID) @@ -817,6 +817,7 @@ extern uchar maria_zero_string[]; extern my_bool maria_inited, maria_in_ha_maria, maria_recovery_changed_data; extern my_bool maria_recovery_verbose, maria_checkpoint_disabled; extern my_bool maria_assert_if_crashed_table; +extern ulong maria_checkpoint_min_log_activity; extern HASH maria_stored_state; extern int (*maria_create_trn_hook)(MARIA_HA *); extern my_bool (*ma_killed)(MARIA_HA *); diff --git a/storage/maria/maria_pack.c b/storage/maria/maria_pack.c index 4480dabbcad..481b77a2cc6 100644 --- a/storage/maria/maria_pack.c +++ b/storage/maria/maria_pack.c @@ -3051,7 +3051,6 @@ static int mrg_rrnd(PACK_MRG_INFO *info,uchar *buf) { int error; MARIA_HA *isam_info; - my_off_t filepos; if (!info->current) { @@ -3076,7 +3075,6 @@ static int mrg_rrnd(PACK_MRG_INFO *info,uchar *buf) return(HA_ERR_END_OF_FILE); info->current++; isam_info= *info->current; - filepos=isam_info->s->pack.header_length; maria_reset(isam_info); maria_extra(isam_info,HA_EXTRA_CACHE, 0); if ((error= maria_scan_init(isam_info))) diff --git a/storage/maria/trnman.c b/storage/maria/trnman.c index 0f02976dbb4..0734e12cbe4 100644 --- a/storage/maria/trnman.c +++ b/storage/maria/trnman.c @@ -179,6 +179,7 @@ int trnman_init(TrID initial_trid) trnman_allocated_transactions= 0; /* This is needed for recovery and repair */ dummy_transaction_object.min_read_from= ~(TrID) 0; + dummy_transaction_object.first_undo_lsn= TRANSACTION_LOGGED_LONG_ID; pool= 0; global_trid_generator= initial_trid; diff --git a/storage/maria/unittest/CMakeLists.txt b/storage/maria/unittest/CMakeLists.txt index fd3e3f909ce..ba7c8d324f0 100644 --- a/storage/maria/unittest/CMakeLists.txt +++ b/storage/maria/unittest/CMakeLists.txt @@ -13,7 +13,6 @@ # along with this program; if not, write to the Free Software # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR}/include ${CMAKE_SOURCE_DIR}/zlib ${CMAKE_SOURCE_DIR}/unittest/mytap) LINK_LIBRARIES(aria myisam mytap mysys dbug strings ${ZLIB_LIBRARY}) diff --git a/storage/myisam/ft_boolean_search.c b/storage/myisam/ft_boolean_search.c index 650eb160866..56d0149a748 100644 --- a/storage/myisam/ft_boolean_search.c +++ b/storage/myisam/ft_boolean_search.c @@ -1,4 +1,4 @@ -/* Copyright (C) 2001-2005 MySQL AB +/* Copyright (c) 2001, 2010, Oracle and/or its affiliates. All rights reserved. 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 @@ -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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ /* Written by Sergei A. Golubchik, who has a shared copyright to this code */ @@ -358,7 +358,7 @@ static int _ft2_search(FTB *ftb, FTB_WORD *ftbw, my_bool init_search) int subkeys=1; my_bool can_go_down; MI_INFO *info=ftb->info; - uint UNINIT_VAR(off), extra=HA_FT_WLEN+info->s->base.rec_reflength; + uint UNINIT_VAR(off), extra= HA_FT_WLEN + info->s->rec_reflength; uchar *lastkey_buf=ftbw->word+ftbw->off; if (ftbw->flags & FTB_FLAG_TRUNC) diff --git a/storage/myisam/ft_nlq_search.c b/storage/myisam/ft_nlq_search.c index 366b7bc3061..97ab2a6434e 100644 --- a/storage/myisam/ft_nlq_search.c +++ b/storage/myisam/ft_nlq_search.c @@ -1,4 +1,4 @@ -/* Copyright (C) 2001-2005 MySQL AB +/* Copyright (c) 2001, 2010, Oracle and/or its affiliates. All rights reserved. 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 @@ -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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ /* Written by Sergei A. Golubchik, who has a shared copyright to this code */ @@ -73,7 +73,7 @@ static int walk_and_match(FT_WORD *word, uint32 count, ALL_IN_ONE *aio) uchar *keybuff=aio->keybuff; MI_KEYDEF *keyinfo=info->s->keyinfo+aio->keynr; my_off_t key_root=info->s->state.key_root[aio->keynr]; - uint extra=HA_FT_WLEN+info->s->base.rec_reflength; + uint extra= HA_FT_WLEN + info->s->rec_reflength; #if HA_FT_WTYPE == HA_KEYTYPE_FLOAT float tmp_weight; #else diff --git a/storage/myisam/ft_parser.c b/storage/myisam/ft_parser.c index 31e72e8e0a6..c534a9a060b 100644 --- a/storage/myisam/ft_parser.c +++ b/storage/myisam/ft_parser.c @@ -1,4 +1,4 @@ -/* Copyright (C) 2000-2005 MySQL AB +/* Copyright (c) 2000, 2010, Oracle and/or its affiliates. All rights reserved. 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 @@ -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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ /* Written by Sergei A. Golubchik, who has a shared copyright to this code */ diff --git a/storage/myisam/ft_static.c b/storage/myisam/ft_static.c index 6a0bda5b666..aa8adba88a2 100644 --- a/storage/myisam/ft_static.c +++ b/storage/myisam/ft_static.c @@ -1,4 +1,5 @@ -/* Copyright (C) 2000-2005 MySQL AB +/* Copyright (c) 2000-2008 MySQL AB, 2009 Sun Microsystems, Inc. + Use is subject to license terms. 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 @@ -11,7 +12,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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ /* Written by Sergei A. Golubchik, who has a shared copyright to this code */ diff --git a/storage/myisam/ft_update.c b/storage/myisam/ft_update.c index a2ddb49ecf0..19144ff01fb 100644 --- a/storage/myisam/ft_update.c +++ b/storage/myisam/ft_update.c @@ -1,4 +1,4 @@ -/* Copyright (C) 2000-2004, 2006 MySQL AB +/* Copyright (c) 2000, 2010, Oracle and/or its affiliates. All rights reserved. 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 @@ -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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ /* Written by Sergei A. Golubchik, who has a shared copyright to this code */ diff --git a/storage/myisam/ftdefs.h b/storage/myisam/ftdefs.h index cf00594629c..5c7f4c64a51 100644 --- a/storage/myisam/ftdefs.h +++ b/storage/myisam/ftdefs.h @@ -1,4 +1,5 @@ -/* Copyright (C) 2000-2005 MySQL AB +/* Copyright (c) 2000-2007 MySQL AB, 2009 Sun Microsystems, Inc. + Use is subject to license terms. 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 @@ -11,7 +12,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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ /* Written by Sergei A. Golubchik, who has a shared copyright to this code */ diff --git a/storage/myisam/fulltext.h b/storage/myisam/fulltext.h index 9aef2d0d002..f3fda334472 100644 --- a/storage/myisam/fulltext.h +++ b/storage/myisam/fulltext.h @@ -1,4 +1,4 @@ -/* Copyright (C) 2000-2003 MySQL AB +/* Copyright (c) 2000, 2010, Oracle and/or its affiliates. All rights reserved. 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 @@ -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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ /* Written by Sergei A. Golubchik, who has a shared copyright to this code */ diff --git a/storage/myisam/ha_myisam.cc b/storage/myisam/ha_myisam.cc index f20182f8823..8fde949189b 100644 --- a/storage/myisam/ha_myisam.cc +++ b/storage/myisam/ha_myisam.cc @@ -1,4 +1,5 @@ -/* Copyright (C) 2000-2006 MySQL AB, 2008-2009 Sun Microsystems, Inc +/* + Copyright (c) 2000, 2011, Oracle and/or its affiliates. All rights reserved. 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 @@ -11,7 +12,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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ #ifdef USE_PRAGMA_IMPLEMENTATION @@ -145,14 +146,16 @@ static void mi_check_print_msg(HA_CHECK *param, const char* msg_type, if (!thd->vio_ok()) { - sql_print_error("%s", msgbuf); + sql_print_error("%s.%s: %s", param->db_name, param->table_name, msgbuf); return; } if (param->testflag & (T_CREATE_MISSING_KEYS | T_SAFE_REPAIR | T_AUTO_REPAIR)) { - my_message(ER_NOT_KEYFILE,msgbuf,MYF(MY_WME)); + my_message(ER_NOT_KEYFILE, msgbuf, MYF(MY_WME)); + if (thd->variables.log_warnings > 2 && ! thd->log_all_errors) + sql_print_error("%s.%s: %s", param->db_name, param->table_name, msgbuf); return; } length=(uint) (strxmov(name, param->db_name,".",param->table_name,NullS) - @@ -177,7 +180,7 @@ static void mi_check_print_msg(HA_CHECK *param, const char* msg_type, sql_print_error("Failed on my_net_write, writing to stderr instead: %s\n", msgbuf); else if (thd->variables.log_warnings > 2) - sql_print_error("%s", msgbuf); + sql_print_error("%s.%s: %s", param->db_name, param->table_name, msgbuf); if (param->need_print_msg_lock) mysql_mutex_unlock(¶m->print_msg_mutex); @@ -578,6 +581,7 @@ void mi_check_print_info(HA_CHECK *param, const char *fmt,...) va_list args; va_start(args, fmt); mi_check_print_msg(param, "info", fmt, args); + param->note_printed= 1; va_end(args); } @@ -639,7 +643,6 @@ my_bool mi_killed_in_mariadb(MI_INFO *info) } - ha_myisam::ha_myisam(handlerton *hton, TABLE_SHARE *table_arg) :handler(hton, table_arg), file(0), int_table_flags(HA_NULL_IN_KEY | HA_CAN_FULLTEXT | HA_CAN_SQL_HANDLER | @@ -1580,7 +1583,10 @@ bool ha_myisam::check_and_repair(THD *thd) if ((marked_crashed= mi_is_crashed(file)) || check(thd, &check_opt)) { + bool save_log_all_errors; sql_print_warning("Recovering table: '%s'",table->s->path.str); + save_log_all_errors= thd->log_all_errors; + thd->log_all_errors|= (thd->variables.log_warnings > 2); if (myisam_recover_options & HA_RECOVER_FULL_BACKUP) { char buff[MY_BACKUP_NAME_EXTRA_LENGTH+1]; @@ -1598,6 +1604,7 @@ bool ha_myisam::check_and_repair(THD *thd) T_AUTO_REPAIR); if (repair(thd, &check_opt)) error=1; + thd->log_all_errors= save_log_all_errors; } thd->set_query(query_backup); DBUG_RETURN(error); @@ -1857,9 +1864,6 @@ int ha_myisam::extra(enum ha_extra_function operation) int ha_myisam::reset(void) { - pushed_idx_cond= NULL; - pushed_idx_cond_keyno= MAX_KEY; - in_range_check_pushed_down= FALSE; mi_set_index_cond_func(file, NULL, 0); ds_mrr.dsmrr_close(); return mi_reset(file); @@ -1891,6 +1895,13 @@ int ha_myisam::delete_table(const char *name) return mi_delete_table(name); } +void ha_myisam::change_table_ptr(TABLE *table_arg, TABLE_SHARE *share) +{ + handler::change_table_ptr(table_arg, share); + if (file) + file->external_ref= table_arg; +} + int ha_myisam::external_lock(THD *thd, int lock_type) { @@ -2251,7 +2262,8 @@ mysql_declare_plugin(myisam) 0x0100, /* 1.0 */ NULL, /* status variables */ myisam_sysvars, /* system variables */ - NULL + NULL, + 0, } mysql_declare_plugin_end; maria_declare_plugin(myisam) diff --git a/storage/myisam/ha_myisam.h b/storage/myisam/ha_myisam.h index 35d52a22c71..c3c236ad4fe 100644 --- a/storage/myisam/ha_myisam.h +++ b/storage/myisam/ha_myisam.h @@ -1,4 +1,5 @@ -/* Copyright (C) 2000, 2010 Oracle and/or its affiliates. All rights reserved. +/* + Copyright (c) 2000, 2011, Oracle and/or its affiliates. All rights reserved. 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 @@ -75,7 +76,7 @@ class ha_myisam: public handler uint max_supported_key_length() const { return HA_MAX_KEY_LENGTH; } uint max_supported_key_part_length() const { return HA_MAX_KEY_LENGTH; } uint checksum() const; - + void change_table_ptr(TABLE *table_arg, TABLE_SHARE *share); int open(const char *name, int mode, uint test_if_locked); int close(void); int write_row(uchar * buf); diff --git a/storage/myisam/mi_cache.c b/storage/myisam/mi_cache.c index ddbfda11326..6e9feaefb2d 100644 --- a/storage/myisam/mi_cache.c +++ b/storage/myisam/mi_cache.c @@ -1,4 +1,5 @@ -/* Copyright (C) 2000-2003 MySQL AB, 2008-2009 Sun Microsystems, Inc +/* Copyright (c) 2000-2003, 2005-2007 MySQL AB, 2009 Sun Microsystems, Inc. + Use is subject to license terms. 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 @@ -11,7 +12,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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ /* Functions for read record cacheing with myisam diff --git a/storage/myisam/mi_changed.c b/storage/myisam/mi_changed.c index 049974e4a65..e7ceff24287 100644 --- a/storage/myisam/mi_changed.c +++ b/storage/myisam/mi_changed.c @@ -1,4 +1,5 @@ -/* Copyright (C) 2000-2001 MySQL AB +/* Copyright (c) 2000, 2001, 2005, 2006 MySQL AB, 2009 Sun Microsystems, Inc. + Use is subject to license terms. 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 @@ -11,7 +12,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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ /* Check if somebody has changed table since last check. */ diff --git a/storage/myisam/mi_check.c b/storage/myisam/mi_check.c index 65d218b216d..05fd9af9079 100644 --- a/storage/myisam/mi_check.c +++ b/storage/myisam/mi_check.c @@ -1,4 +1,5 @@ -/* Copyright (C) 2000-2006 MySQL AB, 2008-2009 Sun Microsystems, Inc +/* + Copyright (c) 2000, 2011, Oracle and/or its affiliates. All rights reserved. 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 @@ -11,7 +12,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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ /* Describe, check and repair of MyISAM tables */ @@ -937,7 +938,7 @@ static uint isam_key_length(MI_INFO *info, register MI_KEYDEF *keyinfo) int chk_data_link(HA_CHECK *param, MI_INFO *info, my_bool extend) { int error,got_error,flag; - uint key,UNINIT_VAR(left_length),b_type,field; + uint key, UNINIT_VAR(left_length), b_type; ha_rows records,del_blocks; my_off_t used,empty,pos,splits,UNINIT_VAR(start_recpos), del_length,link_used,start_block; @@ -945,7 +946,6 @@ int chk_data_link(HA_CHECK *param, MI_INFO *info, my_bool extend) char llbuff[22],llbuff2[22],llbuff3[22]; ha_checksum intern_record_checksum; ha_checksum key_checksum[HA_MAX_POSSIBLE_KEY]; - my_bool static_row_size; MI_KEYDEF *keyinfo; MI_BLOCK_INFO block_info; DBUG_ENTER("chk_data_link"); @@ -969,21 +969,6 @@ int chk_data_link(HA_CHECK *param, MI_INFO *info, my_bool extend) got_error=error=0; empty=info->s->pack.header_length; - /* Check how to calculate checksum of rows */ - static_row_size=1; - if (info->s->data_file_type == COMPRESSED_RECORD) - { - for (field=0 ; field < info->s->base.fields ; field++) - { - if (info->s->rec[field].base_type == FIELD_BLOB || - info->s->rec[field].base_type == FIELD_VARCHAR) - { - static_row_size=0; - break; - } - } - } - pos=my_b_tell(¶m->read_cache); bzero((char*) key_checksum, info->s->base.keys * sizeof(key_checksum[0])); while (pos < info->state->data_file_length) @@ -1342,7 +1327,7 @@ int chk_data_link(HA_CHECK *param, MI_INFO *info, my_bool extend) } if (param->testflag & T_INFO) { - if (param->warning_printed || param->error_printed) + if (param->warning_printed || param->error_printed || param->note_printed) puts(""); if (used != 0 && ! param->error_printed) { @@ -1535,6 +1520,8 @@ int mi_repair(HA_CHECK *param, register MI_INFO *info, got_error=1; new_file= -1; sort_param.sort_info=&sort_info; + param->retry_repair= 0; + param->warning_printed= param->error_printed= param->note_printed= 0; if (!(param->testflag & T_SILENT)) { @@ -1677,7 +1664,7 @@ int mi_repair(HA_CHECK *param, register MI_INFO *info, if (rep_quick && del+sort_info.dupp != info->state->del) { mi_check_print_error(param,"Couldn't fix table with quick recovery: Found wrong number of deleted records"); - mi_check_print_error(param,"Run recovery again without -q"); + mi_check_print_error(param,"Run recovery again without --quick"); got_error=1; param->retry_repair=1; param->testflag|=T_RETRY_WITHOUT_QUICK; @@ -1906,7 +1893,7 @@ int flush_blocks(HA_CHECK *param, KEY_CACHE *key_cache, File file, { if (flush_key_blocks(key_cache, file, dirty_part_map, FLUSH_RELEASE)) { - mi_check_print_error(param,"%d when trying to write bufferts",my_errno); + mi_check_print_error(param,"%d when trying to write buffers",my_errno); return(1); } if (!param->using_global_keycache) @@ -2215,7 +2202,7 @@ int mi_repair_by_sort(HA_CHECK *param, register MI_INFO *info, MYISAM_SHARE *share=info->s; HA_KEYSEG *keyseg; ulong *rec_per_key_part; - char llbuff[22]; + char llbuff[22], llbuff2[22]; MI_SORT_INFO sort_info; ulonglong UNINIT_VAR(key_map); DBUG_ENTER("mi_repair_by_sort"); @@ -2231,12 +2218,15 @@ int mi_repair_by_sort(HA_CHECK *param, register MI_INFO *info, printf("Data records: %s\n", llstr(start_records,llbuff)); } param->testflag|=T_REP; /* for easy checking */ + param->retry_repair= 0; + param->warning_printed= param->error_printed= param->note_printed= 0; if (info->s->options & (HA_OPTION_CHECKSUM | HA_OPTION_COMPRESS_RECORD)) param->testflag|=T_CALC_CHECKSUM; bzero((char*)&sort_info,sizeof(sort_info)); bzero((char *)&sort_param, sizeof(sort_param)); + if (!(sort_info.key_block= alloc_key_blocks(param, (uint) param->sort_key_blocks, @@ -2248,7 +2238,7 @@ int mi_repair_by_sort(HA_CHECK *param, register MI_INFO *info, init_io_cache(&info->rec_cache,info->dfile, (uint) param->write_buffer_length, WRITE_CACHE,new_header_length,1, - MYF(MY_WME | MY_WAIT_IF_FULL) & param->myf_rw))) + MYF((param->myf_rw & MY_WAIT_IF_FULL) | MY_WME)))) goto err; sort_info.key_block_end=sort_info.key_block+param->sort_key_blocks; info->opt_flag|=WRITE_CACHE_USED; @@ -2418,7 +2408,10 @@ int mi_repair_by_sort(HA_CHECK *param, register MI_INFO *info, (my_bool) (!(param->testflag & T_VERBOSE)), (uint) param->sort_buffer_length)) { - param->retry_repair=1; + param->retry_repair= 1; + if (! param->error_printed) + mi_check_print_error(param, "Couldn't fix table with create_index_by_sort(). Error: %d", + my_errno); goto err; } /* No need to calculate checksum again. */ @@ -2447,7 +2440,10 @@ int mi_repair_by_sort(HA_CHECK *param, register MI_INFO *info, /* Don't repair if we loosed more than one row */ if (info->state->records+1 < start_records) { - info->state->records=start_records; + mi_check_print_error(param, + "Couldn't fix table as SAFE_REPAIR was requested and we would loose too many rows. %s -> %s", + llstr(start_records, llbuff), llstr(info->state->records, llbuff2)); + info->state->records= start_records; goto err; } } @@ -2477,7 +2473,7 @@ int mi_repair_by_sort(HA_CHECK *param, register MI_INFO *info, if (rep_quick && del+sort_info.dupp != info->state->del) { mi_check_print_error(param,"Couldn't fix table with quick recovery: Found wrong number of deleted records"); - mi_check_print_error(param,"Run recovery again without -q"); + mi_check_print_error(param,"Run recovery again without --quick"); got_error=1; param->retry_repair=1; param->testflag|=T_RETRY_WITHOUT_QUICK; @@ -2549,6 +2545,8 @@ err: param->retry_repair= 0; /* Safety */ } mi_mark_crashed_on_repair(info); + if (killed_ptr(param)) + param->retry_repair= 0; /* No use to retry repair */ } else if (key_map == share->state.key_map) share->state.changed&= ~STATE_NOT_OPTIMIZED_KEYS; @@ -2644,6 +2642,9 @@ int mi_repair_parallel(HA_CHECK *param, register MI_INFO *info, printf("Data records: %s\n", llstr(start_records,llbuff)); } param->testflag|=T_REP; /* for easy checking */ + param->retry_repair= 0; + param->warning_printed= 0; + param->error_printed= 0; if (info->s->options & (HA_OPTION_CHECKSUM | HA_OPTION_COMPRESS_RECORD)) param->testflag|=T_CALC_CHECKSUM; @@ -3076,6 +3077,8 @@ err: param->retry_repair= 0; /* Safety */ } mi_mark_crashed_on_repair(info); + if (killed_ptr(param)) + param->retry_repair= 0; } else if (key_map == share->state.key_map) share->state.changed&= ~STATE_NOT_OPTIMIZED_KEYS; @@ -3110,7 +3113,13 @@ static int sort_key_read(MI_SORT_PARAM *sort_param, void *key) DBUG_ENTER("sort_key_read"); if ((error=sort_get_next_record(sort_param))) + { + DBUG_ASSERT(error < 0 || + sort_info->param->error_printed || + sort_info->param->warning_printed || + sort_info->param->note_printed); DBUG_RETURN(error); + } if (info->state->records == sort_info->max_records) { mi_check_print_error(sort_info->param, @@ -3227,7 +3236,12 @@ static int sort_get_next_record(MI_SORT_PARAM *sort_param) DBUG_ENTER("sort_get_next_record"); if (killed_ptr(param)) + { + mi_check_print_error(param, "Repair killed by user with cause: %d", + (int) killed_ptr(param)); + param->retry_repair= 0; DBUG_RETURN(1); + } switch (share->data_file_type) { case STATIC_RECORD: @@ -3313,6 +3327,8 @@ static int sort_get_next_record(MI_SORT_PARAM *sort_param) } if (searching && ! sort_param->fix_datafile) { + mi_check_print_info(param, + "Datafile is corrupted; Restart repair with option to copy datafile"); param->error_printed=1; param->retry_repair=1; param->testflag|=T_RETRY_WITHOUT_QUICK; @@ -3374,6 +3390,7 @@ static int sort_get_next_record(MI_SORT_PARAM *sort_param) } if (error) { + DBUG_ASSERT(param->note_printed); if (found_record) goto try_next; searching=1; @@ -3414,7 +3431,11 @@ static int sort_get_next_record(MI_SORT_PARAM *sort_param) share->state.split++; } if (found_record) + { + mi_check_print_info(param, + "Found row block followed by deleted block"); goto try_next; + } if (searching) { pos+=MI_DYN_ALIGN_SIZE; @@ -3448,6 +3469,7 @@ static int sort_get_next_record(MI_SORT_PARAM *sort_param) mi_check_print_error(param,"Not enough memory for blob at %s (need %lu)", llstr(sort_param->start_recpos,llbuff), (ulong) block_info.rec_len); + DBUG_ASSERT(param->error_printed); DBUG_RETURN(1); } else @@ -3529,8 +3551,6 @@ static int sort_get_next_record(MI_SORT_PARAM *sort_param) if (_mi_rec_unpack(info,sort_param->record,sort_param->rec_buff, sort_param->find_length) != MY_FILE_ERROR) { - if (sort_param->read_cache.error < 0) - DBUG_RETURN(1); if (sort_param->calc_checksum) info->checksum= (*info->s->calc_check_checksum)(info, sort_param->record); @@ -3556,6 +3576,7 @@ static int sort_get_next_record(MI_SORT_PARAM *sort_param) sort_param->key+1, llstr(sort_param->start_recpos,llbuff)); try_next: + DBUG_ASSERT(param->error_printed || param->note_printed); pos=(sort_param->start_recpos+=MI_DYN_ALIGN_SIZE); searching=1; } @@ -3627,6 +3648,7 @@ static int sort_get_next_record(MI_SORT_PARAM *sort_param) DBUG_ASSERT(0); /* Impossible */ break; } + DBUG_ASSERT(0); /* Impossible */ DBUG_RETURN(1); /* Impossible */ } @@ -3685,7 +3707,7 @@ int sort_write_record(MI_SORT_PARAM *sort_param) if (sort_info->buff_length < reclength) { if (!(sort_info->buff=my_realloc(sort_info->buff, (uint) reclength, - MYF(MY_FREE_ON_ERROR | + MYF(MY_FREE_ON_ERROR | MY_WME | MY_ALLOW_ZERO_PTR)))) DBUG_RETURN(1); sort_info->buff_length=reclength; @@ -3885,7 +3907,7 @@ static int sort_ft_key_write(MI_SORT_PARAM *sort_param, const void *a) SORT_FT_BUF *ft_buf=sort_info->ft_buf; SORT_KEY_BLOCKS *key_block=sort_info->key_block; - val_len=HA_FT_WLEN+sort_info->info->s->base.rec_reflength; + val_len= HA_FT_WLEN + sort_info->info->s->rec_reflength; get_key_full_length_rdonly(a_len, (uchar *)a); if (!ft_buf) @@ -3895,7 +3917,7 @@ static int sort_ft_key_write(MI_SORT_PARAM *sort_param, const void *a) and row format is NOT static - for _mi_dpointer not to garble offsets */ if ((sort_info->info->s->base.key_reflength <= - sort_info->info->s->base.rec_reflength) && + sort_info->info->s->rec_reflength) && (sort_info->info->s->options & (HA_OPTION_PACK_RECORD | HA_OPTION_COMPRESS_RECORD))) ft_buf=(SORT_FT_BUF *)my_malloc(sort_param->keyinfo->block_length + diff --git a/storage/myisam/mi_close.c b/storage/myisam/mi_close.c index 473c3086c41..6e9ee7747ae 100644 --- a/storage/myisam/mi_close.c +++ b/storage/myisam/mi_close.c @@ -1,4 +1,4 @@ -/* Copyright (C) 2000-2004 MySQL AB, 2008-2009 Sun Microsystems, Inc +/* Copyright (c) 2000, 2011, Oracle and/or its affiliates. All rights reserved. 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 @@ -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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ /* close a isam-database */ /* diff --git a/storage/myisam/mi_create.c b/storage/myisam/mi_create.c index 0a735f07088..7c7f11ddf78 100644 --- a/storage/myisam/mi_create.c +++ b/storage/myisam/mi_create.c @@ -1,4 +1,5 @@ -/* Copyright (C) 2000-2006 MySQL AB, 2008-2009 Sun Microsystems, Inc +/* + Copyright (c) 2000, 2011, Oracle and/or its affiliates. All rights reserved. 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 @@ -11,7 +12,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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ /* Create a MyISAM table */ diff --git a/storage/myisam/mi_dbug.c b/storage/myisam/mi_dbug.c index 3bcacef0b69..4606e0af170 100644 --- a/storage/myisam/mi_dbug.c +++ b/storage/myisam/mi_dbug.c @@ -1,4 +1,4 @@ -/* Copyright (C) 2000-2005 MySQL AB +/* Copyright (c) 2000, 2010, Oracle and/or its affiliates. All rights reserved. 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 @@ -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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ /* Support rutiner with are using with dbug */ diff --git a/storage/myisam/mi_delete.c b/storage/myisam/mi_delete.c index 6d2ca5b1f8d..907d8e291f6 100644 --- a/storage/myisam/mi_delete.c +++ b/storage/myisam/mi_delete.c @@ -1,4 +1,4 @@ -/* Copyright (C) 2000-2006 MySQL AB +/* Copyright (c) 2000, 2011, Oracle and/or its affiliates. All rights reserved. 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 @@ -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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ /* Remove a row from a MyISAM table */ diff --git a/storage/myisam/mi_delete_all.c b/storage/myisam/mi_delete_all.c index a21a2a3093a..5e9cb26c0ad 100644 --- a/storage/myisam/mi_delete_all.c +++ b/storage/myisam/mi_delete_all.c @@ -1,4 +1,4 @@ -/* Copyright (C) 2000-2003, 2005 MySQL AB, 2008-2009 Sun Microsystems, Inc +/* Copyright (c) 2000, 2011, Oracle and/or its affiliates. All rights reserved. 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 @@ -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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ /* Remove all rows from a MyISAM table */ /* This clears the status information and truncates files */ diff --git a/storage/myisam/mi_delete_table.c b/storage/myisam/mi_delete_table.c index a05a2ad6237..b6530334dd2 100644 --- a/storage/myisam/mi_delete_table.c +++ b/storage/myisam/mi_delete_table.c @@ -1,4 +1,4 @@ -/* Copyright (C) 2000-2001, 2004, 2006 MySQL AB, 2008-2009 Sun Microsystems, Inc +/* Copyright (c) 2000, 2010, Oracle and/or its affiliates. All rights reserved. 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 @@ -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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ /* deletes a table diff --git a/storage/myisam/mi_dynrec.c b/storage/myisam/mi_dynrec.c index aeb81d4e09c..7a86ff63136 100644 --- a/storage/myisam/mi_dynrec.c +++ b/storage/myisam/mi_dynrec.c @@ -1,4 +1,4 @@ -/* Copyright (C) 2000-2006 MySQL AB, 2008-2009 Sun Microsystems, Inc +/* Copyright (c) 2000, 2011, Oracle and/or its affiliates. All rights reserved. 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 @@ -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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ /* Functions to handle space-packed-records and blobs diff --git a/storage/myisam/mi_extra.c b/storage/myisam/mi_extra.c index f139dd1aad7..c3dd9cb6645 100644 --- a/storage/myisam/mi_extra.c +++ b/storage/myisam/mi_extra.c @@ -1,4 +1,4 @@ -/* Copyright (C) 2000-2005 MySQL AB, 2008-2009 Sun Microsystems, Inc +/* Copyright (c) 2000, 2010, Oracle and/or its affiliates. All rights reserved. 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 @@ -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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ #include "myisamdef.h" #ifdef HAVE_SYS_MMAN_H diff --git a/storage/myisam/mi_extrafunc.h b/storage/myisam/mi_extrafunc.h index 4aa28832c6d..2109796763d 100644 --- a/storage/myisam/mi_extrafunc.h +++ b/storage/myisam/mi_extrafunc.h @@ -1,4 +1,5 @@ -/* Copyright (C) 2000-2006 MySQL AB +/* Copyright (c) 2000-2006 MySQL AB, 2009 Sun Microsystems, Inc. + Use is subject to license terms. 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 @@ -11,7 +12,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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ void _mi_report_crashed(MI_INFO *file __attribute__((unused)), const char *message __attribute__((unused)), diff --git a/storage/myisam/mi_info.c b/storage/myisam/mi_info.c index 36d7073a4dc..3b9288eeb83 100644 --- a/storage/myisam/mi_info.c +++ b/storage/myisam/mi_info.c @@ -1,4 +1,5 @@ -/* Copyright (C) 2000-2001, 2003-2004 MySQL AB, 2008-2009 Sun Microsystems, Inc +/* Copyright (c) 2000, 2001, 2003-2007 MySQL AB, 2009 Sun Microsystems, Inc. + Use is subject to license terms. 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 @@ -11,7 +12,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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ /* Return useful base information for an open table */ diff --git a/storage/myisam/mi_key.c b/storage/myisam/mi_key.c index e51534b3180..004fd054f1c 100644 --- a/storage/myisam/mi_key.c +++ b/storage/myisam/mi_key.c @@ -1,4 +1,4 @@ -/* Copyright (C) 2000-2006 MySQL AB +/* Copyright (c) 2000, 2010, Oracle and/or its affiliates. All rights reserved. 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 @@ -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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ /* Functions to handle keys */ diff --git a/storage/myisam/mi_keycache.c b/storage/myisam/mi_keycache.c index be7d3cc6f1e..a2422b71bbf 100644 --- a/storage/myisam/mi_keycache.c +++ b/storage/myisam/mi_keycache.c @@ -1,4 +1,5 @@ -/* Copyright (C) 2003 MySQL AB, 2008-2009 Sun Microsystems, Inc +/* Copyright (c) 2003-2008 MySQL AB, 2009 Sun Microsystems, Inc. + Use is subject to license terms. 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 @@ -11,7 +12,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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ /* Key cache assignments diff --git a/storage/myisam/mi_locking.c b/storage/myisam/mi_locking.c index 6eb25f089b2..824855a0211 100644 --- a/storage/myisam/mi_locking.c +++ b/storage/myisam/mi_locking.c @@ -1,4 +1,4 @@ -/* Copyright (C) 2000-2006 MySQL AB, 2008-2009 Sun Microsystems, Inc +/* Copyright (c) 2000, 2010, Oracle and/or its affiliates. All rights reserved. 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 @@ -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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ /* locking of isam-tables. diff --git a/storage/myisam/mi_log.c b/storage/myisam/mi_log.c index ac3aa7c149b..7004144c8bc 100644 --- a/storage/myisam/mi_log.c +++ b/storage/myisam/mi_log.c @@ -1,4 +1,4 @@ -/* Copyright (C) 2000-2001, 2004 MySQL AB, 2008-2009 Sun Microsystems, Inc +/* Copyright (c) 2000, 2011, Oracle and/or its affiliates. All rights reserved. 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 @@ -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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ /* Logging of MyISAM commands and records on logfile for debugging diff --git a/storage/myisam/mi_open.c b/storage/myisam/mi_open.c index 53ecdaeda21..5c89120c156 100644 --- a/storage/myisam/mi_open.c +++ b/storage/myisam/mi_open.c @@ -1,4 +1,4 @@ -/* Copyright (C) 2000-2006 MySQL AB, 2008-2009 Sun Microsystems, Inc +/* Copyright (c) 2000, 2011, Oracle and/or its affiliates. All rights reserved. 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 @@ -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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ /* open a isam-database */ @@ -75,15 +75,14 @@ MI_INFO *mi_open(const char *name, int mode, uint open_flags) key_parts,unique_key_parts,base_key_parts,fulltext_keys,uniques; char name_buff[FN_REFLEN], org_name[FN_REFLEN], index_name[FN_REFLEN], data_name[FN_REFLEN]; - uchar *disk_cache, *disk_pos, *end_pos; - MI_INFO info,*m_info,*old_info; + uchar *UNINIT_VAR(disk_cache), *disk_pos, *end_pos; + MI_INFO info,*UNINIT_VAR(m_info),*old_info; MYISAM_SHARE share_buff,*share; ulong *rec_per_key_part= 0; my_off_t *key_root, *key_del; ulonglong max_key_file_length, max_data_file_length; DBUG_ENTER("mi_open"); - LINT_INIT(m_info); kfile= -1; lock_error=1; errpos=0; diff --git a/storage/myisam/mi_packrec.c b/storage/myisam/mi_packrec.c index ceb087d67c9..917bc9f4409 100644 --- a/storage/myisam/mi_packrec.c +++ b/storage/myisam/mi_packrec.c @@ -1,4 +1,4 @@ -/* Copyright (C) 2000-2006 MySQL AB, 2008-2009 Sun Microsystems, Inc +/* Copyright (c) 2000, 2010, Oracle and/or its affiliates. All rights reserved. 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 @@ -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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ /* Functions to compressed records */ diff --git a/storage/myisam/mi_page.c b/storage/myisam/mi_page.c index 82acb801c90..868b28315c4 100644 --- a/storage/myisam/mi_page.c +++ b/storage/myisam/mi_page.c @@ -1,4 +1,4 @@ -/* Copyright (C) 2000-2004, 2006 MySQL AB +/* Copyright (c) 2000, 2010, Oracle and/or its affiliates. All rights reserved. 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 @@ -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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ /* Read and write key blocks */ diff --git a/storage/myisam/mi_panic.c b/storage/myisam/mi_panic.c index 93be70d2af3..8607b8aea88 100644 --- a/storage/myisam/mi_panic.c +++ b/storage/myisam/mi_panic.c @@ -1,4 +1,5 @@ -/* Copyright (C) 2000-2001, 2003 MySQL AB, 2008-2009 Sun Microsystems, Inc +/* Copyright (c) 2000, 2003, 2005, 2006 MySQL AB, 2009 Sun Microsystems, Inc. + Use is subject to license terms. 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 @@ -11,7 +12,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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ #include "fulltext.h" diff --git a/storage/myisam/mi_preload.c b/storage/myisam/mi_preload.c index 79d3db83796..5c974cbea0e 100644 --- a/storage/myisam/mi_preload.c +++ b/storage/myisam/mi_preload.c @@ -1,4 +1,4 @@ -/* Copyright (C) 2003, 2005 MySQL AB, 2008-2009 Sun Microsystems, Inc +/* Copyright (c) 2003, 2010, Oracle and/or its affiliates. All rights reserved. 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 @@ -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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ /* Preload indexes into key cache diff --git a/storage/myisam/mi_range.c b/storage/myisam/mi_range.c index 8f598200634..9d40d1a25c4 100644 --- a/storage/myisam/mi_range.c +++ b/storage/myisam/mi_range.c @@ -1,4 +1,5 @@ -/* Copyright (C) 2000-2004, 2006 MySQL AB, 2008-2009 Sun Microsystems, Inc +/* + Copyright (c) 2000, 2011, Oracle and/or its affiliates. All rights reserved. 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 @@ -11,7 +12,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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ /* Gives a approximated number of how many records there is between two keys. diff --git a/storage/myisam/mi_rename.c b/storage/myisam/mi_rename.c index 455d45cecfe..3c0f2e97216 100644 --- a/storage/myisam/mi_rename.c +++ b/storage/myisam/mi_rename.c @@ -1,4 +1,4 @@ -/* Copyright (C) 2000-2001, 2004 MySQL AB, 2008-2009 Sun Microsystems, Inc +/* Copyright (c) 2000, 2010, Oracle and/or its affiliates. All rights reserved. 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 @@ -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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ /* Rename a table diff --git a/storage/myisam/mi_rkey.c b/storage/myisam/mi_rkey.c index c88a81962d8..b1c0c0a4829 100644 --- a/storage/myisam/mi_rkey.c +++ b/storage/myisam/mi_rkey.c @@ -1,4 +1,5 @@ -/* Copyright (C) 2000-2006 MySQL AB, 2008-2009 Sun Microsystems, Inc +/* Copyright (c) 2000-2007 MySQL AB, 2009 Sun Microsystems, Inc. + Use is subject to license terms. 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 @@ -11,7 +12,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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ /* Read record based on a key */ diff --git a/storage/myisam/mi_rnext.c b/storage/myisam/mi_rnext.c index 51a60a76f79..17cd708cd3c 100644 --- a/storage/myisam/mi_rnext.c +++ b/storage/myisam/mi_rnext.c @@ -1,4 +1,4 @@ -/* Copyright (C) 2000-2004 MySQL AB, 2008-2009 Sun Microsystems, Inc +/* Copyright (c) 2000, 2010, Oracle and/or its affiliates. All rights reserved. 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 @@ -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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ #include "myisamdef.h" diff --git a/storage/myisam/mi_rnext_same.c b/storage/myisam/mi_rnext_same.c index ea1449f2c98..d6856459ae7 100644 --- a/storage/myisam/mi_rnext_same.c +++ b/storage/myisam/mi_rnext_same.c @@ -1,4 +1,5 @@ -/* Copyright (C) 2000-2006 MySQL AB, 2008-2009 Sun Microsystems, Inc +/* Copyright (c) 2000-2007 MySQL AB, 2009 Sun Microsystems, Inc. + Use is subject to license terms. 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 @@ -11,7 +12,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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ #include "myisamdef.h" #include "rt_index.h" diff --git a/storage/myisam/mi_rprev.c b/storage/myisam/mi_rprev.c index a0b4ec4d927..27fbda95574 100644 --- a/storage/myisam/mi_rprev.c +++ b/storage/myisam/mi_rprev.c @@ -1,4 +1,5 @@ -/* Copyright (C) 2000-2001, 2004 MySQL AB, 2008-2009 Sun Microsystems, Inc +/* Copyright (c) 2000, 2001, 2004-2007 MySQL AB, 2009 Sun Microsystems, Inc. + Use is subject to license terms. 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 @@ -11,7 +12,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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ #include "myisamdef.h" diff --git a/storage/myisam/mi_rsame.c b/storage/myisam/mi_rsame.c index ea41dc73c92..8258dcdb809 100644 --- a/storage/myisam/mi_rsame.c +++ b/storage/myisam/mi_rsame.c @@ -1,4 +1,5 @@ -/* Copyright (C) 2000-2001, 2005 MySQL AB, 2008-2009 Sun Microsystems, Inc +/* Copyright (c) 2000, 2001, 2005-2007 MySQL AB, 2009 Sun Microsystems, Inc. + Use is subject to license terms. 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 @@ -11,7 +12,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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ #include "myisamdef.h" diff --git a/storage/myisam/mi_search.c b/storage/myisam/mi_search.c index c49fddf0f3b..6011cbe29c2 100644 --- a/storage/myisam/mi_search.c +++ b/storage/myisam/mi_search.c @@ -1,4 +1,4 @@ -/* Copyright (C) 2000-2006 MySQL AB +/* Copyright (c) 2000, 2010, Oracle and/or its affiliates. All rights reserved. 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 @@ -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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ /* key handling functions */ diff --git a/storage/myisam/mi_static.c b/storage/myisam/mi_static.c index 9d480cb414d..30e463746d5 100644 --- a/storage/myisam/mi_static.c +++ b/storage/myisam/mi_static.c @@ -1,4 +1,4 @@ -/* Copyright (C) 2000-2002, 2004-2005 MySQL AB, 2008-2009 Sun Microsystems, Inc +/* Copyright (c) 2000, 2011, Oracle and/or its affiliates. All rights reserved. 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 @@ -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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ /* Static variables for MyISAM library. All definied here for easy making of diff --git a/storage/myisam/mi_statrec.c b/storage/myisam/mi_statrec.c index bf791726aa9..b8fa7554034 100644 --- a/storage/myisam/mi_statrec.c +++ b/storage/myisam/mi_statrec.c @@ -1,4 +1,4 @@ -/* Copyright (C) 2000-2002, 2004-2006 MySQL AB +/* Copyright (c) 2000, 2011, Oracle and/or its affiliates. All rights reserved. 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 @@ -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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ /* Functions to handle fixed-length-records */ diff --git a/storage/myisam/mi_test1.c b/storage/myisam/mi_test1.c index e9dbc7c6a69..e048a83d3f0 100644 --- a/storage/myisam/mi_test1.c +++ b/storage/myisam/mi_test1.c @@ -1,4 +1,5 @@ -/* Copyright (C) 2000-2005 MySQL AB +/* + Copyright (c) 2000, 2011, Oracle and/or its affiliates. All rights reserved. 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 @@ -11,7 +12,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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ /* Testing of the basic functions of a MyISAM table */ diff --git a/storage/myisam/mi_test2.c b/storage/myisam/mi_test2.c index a3303428a08..9270ee4fbb8 100644 --- a/storage/myisam/mi_test2.c +++ b/storage/myisam/mi_test2.c @@ -1,4 +1,4 @@ -/* Copyright (C) 2000-2006 MySQL AB +/* Copyright (c) 2000, 2010, Oracle and/or its affiliates. All rights reserved. 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 @@ -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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ /* Test av isam-databas: stor test */ @@ -836,6 +836,7 @@ end: puts("Locking used"); if (use_blob) puts("blobs used"); + bzero(&stats, sizeof(stats)); get_key_cache_statistics(dflt_key_cache, 0, &stats); printf("key cache status: \n\ blocks used:%10lu\n\ diff --git a/storage/myisam/mi_test3.c b/storage/myisam/mi_test3.c index 742fd06b0e3..885118d4eec 100644 --- a/storage/myisam/mi_test3.c +++ b/storage/myisam/mi_test3.c @@ -1,4 +1,4 @@ -/* Copyright (C) 2000-2004 MySQL AB +/* Copyright (c) 2000, 2010, Oracle and/or its affiliates. All rights reserved. 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 @@ -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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ /* Test av locking */ diff --git a/storage/myisam/mi_unique.c b/storage/myisam/mi_unique.c index cee159951de..6df4c07ee0d 100644 --- a/storage/myisam/mi_unique.c +++ b/storage/myisam/mi_unique.c @@ -1,4 +1,4 @@ -/* Copyright (C) 2000-2006 MySQL AB +/* Copyright (c) 2000, 2010, Oracle and/or its affiliates. All rights reserved. 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 @@ -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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ /* Functions to check if a row is unique */ diff --git a/storage/myisam/mi_update.c b/storage/myisam/mi_update.c index 2104e4c4117..66193ea1673 100644 --- a/storage/myisam/mi_update.c +++ b/storage/myisam/mi_update.c @@ -1,4 +1,5 @@ -/* Copyright (C) 2000-2006 MySQL AB +/* + Copyright (c) 2000, 2011, Oracle and/or its affiliates. All rights reserved. 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 @@ -11,7 +12,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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ /* Update an old row in a MyISAM table */ diff --git a/storage/myisam/mi_write.c b/storage/myisam/mi_write.c index 1c9a25f8e86..f00238347ae 100644 --- a/storage/myisam/mi_write.c +++ b/storage/myisam/mi_write.c @@ -1,4 +1,5 @@ -/* Copyright (C) 2000-2006 MySQL AB, 2008-2009 Sun Microsystems, Inc +/* + Copyright (c) 2000, 2011, Oracle and/or its affiliates. All rights reserved. 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 @@ -11,7 +12,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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ /* Write a row to a MyISAM table */ @@ -518,7 +519,7 @@ int _mi_insert(register MI_INFO *info, register MI_KEYDEF *keyinfo, { if (keyinfo->block_length - a_length < 32 && keyinfo->flag & HA_FULLTEXT && key_pos == endpos && - info->s->base.key_reflength <= info->s->base.rec_reflength && + info->s->base.key_reflength <= info->s->rec_reflength && info->s->options & (HA_OPTION_PACK_RECORD | HA_OPTION_COMPRESS_RECORD)) { /* diff --git a/storage/myisam/myisam_ftdump.c b/storage/myisam/myisam_ftdump.c index d51e079625e..cb09c3d20dd 100644 --- a/storage/myisam/myisam_ftdump.c +++ b/storage/myisam/myisam_ftdump.c @@ -1,4 +1,4 @@ -/* Copyright (C) 2001-2006 MySQL AB +/* Copyright (c) 2001, 2010, Oracle and/or its affiliates. All rights reserved. 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 @@ -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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ /* Written by Sergei A. Golubchik, who has a shared copyright to this code added support for long options (my_getopt) 22.5.2002 by Jani Tolonen */ diff --git a/storage/myisam/myisamchk.c b/storage/myisam/myisamchk.c index 72be3d2f810..6f27b1bc0d2 100644 --- a/storage/myisam/myisamchk.c +++ b/storage/myisam/myisamchk.c @@ -1719,6 +1719,7 @@ void mi_check_print_info(HA_CHECK *param __attribute__((unused)), { va_list args; + param->note_printed=1; va_start(args,fmt); (void) vfprintf(stdout, fmt, args); (void) fputc('\n',stdout); diff --git a/storage/myisam/myisamdef.h b/storage/myisam/myisamdef.h index 8f49ce5a5ed..222097146fc 100644 --- a/storage/myisam/myisamdef.h +++ b/storage/myisam/myisamdef.h @@ -1,4 +1,5 @@ -/* Copyright (C) 2000-2006 MySQL AB, 2008-2009 Sun Microsystems, Inc +/* + Copyright (c) 2000, 2011, Oracle and/or its affiliates. All rights reserved. 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 @@ -11,7 +12,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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ /* This file is included by all internal myisam files */ diff --git a/storage/myisam/myisamlog.c b/storage/myisam/myisamlog.c index a17823a45b5..c09e0091a56 100644 --- a/storage/myisam/myisamlog.c +++ b/storage/myisam/myisamlog.c @@ -1,4 +1,4 @@ -/* Copyright (C) 2000-2006 MySQL AB +/* Copyright (c) 2000, 2010, Oracle and/or its affiliates. All rights reserved. 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 @@ -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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ /* write whats in isam.log */ diff --git a/storage/myisam/myisampack.c b/storage/myisam/myisampack.c index 320954147d1..851f5bda700 100644 --- a/storage/myisam/myisampack.c +++ b/storage/myisam/myisampack.c @@ -1,4 +1,4 @@ -/* Copyright (C) 2000-2007 MySQL AB +/* Copyright (c) 2000, 2010, Oracle and/or its affiliates. All rights reserved. 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 @@ -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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ /* Pack MyISAM file */ diff --git a/storage/myisam/rt_split.c b/storage/myisam/rt_split.c index 0b7cc43e062..48f9b82a0b5 100644 --- a/storage/myisam/rt_split.c +++ b/storage/myisam/rt_split.c @@ -1,4 +1,4 @@ -/* Copyright (C) 2002-2005 MySQL AB & Alexey Botchkov +/* Copyright (c) 2002, 2010, Oracle and/or its affiliates. All rights reserved. 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 @@ -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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ #include "myisamdef.h" diff --git a/storage/myisam/rt_test.c b/storage/myisam/rt_test.c index 50cdc538668..8b537d134ef 100644 --- a/storage/myisam/rt_test.c +++ b/storage/myisam/rt_test.c @@ -1,4 +1,4 @@ -/* Copyright (C) 2002-2004 MySQL AB +/* Copyright (c) 2002, 2010, Oracle and/or its affiliates. All rights reserved. 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 @@ -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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ /* Testing of the basic functions of a MyISAM rtree table */ /* Written by Alex Barkov who has a shared copyright to this code */ diff --git a/storage/myisam/sort.c b/storage/myisam/sort.c index eb462d8c23e..da65ddb7be6 100644 --- a/storage/myisam/sort.c +++ b/storage/myisam/sort.c @@ -1,4 +1,4 @@ -/* Copyright (C) 2000-2006 MySQL AB, 2008-2009 Sun Microsystems, Inc +/* Copyright (c) 2000, 2011, Oracle and/or its affiliates. All rights reserved. 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 @@ -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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ /* Creates a index for a database by reading keys, sorting them and outputing @@ -151,6 +151,7 @@ int _create_index_by_sort(MI_SORT_PARAM *info,my_bool no_messages, { mi_check_print_error(info->sort_info->param, "myisam_sort_buffer_size is too small"); + my_errno= ENOMEM; goto err; } } @@ -175,7 +176,8 @@ int _create_index_by_sort(MI_SORT_PARAM *info,my_bool no_messages, if (memavl < MIN_SORT_BUFFER) { mi_check_print_error(info->sort_info->param,"MyISAM sort buffer too small"); /* purecov: tested */ - goto err; /* purecov: tested */ + my_errno= ENOMEM; /* purecov: tested */ + goto err; /* purecov: tested */ } (*info->lock_in_memory)(info->sort_info->param);/* Everything is allocated */ diff --git a/storage/myisam/sp_key.c b/storage/myisam/sp_key.c index bde0e1cb388..3837ed01bd2 100644 --- a/storage/myisam/sp_key.c +++ b/storage/myisam/sp_key.c @@ -1,4 +1,4 @@ -/* Copyright (C) 2000 MySQL AB & Ramil Kalimullin +/* Copyright (c) 2000, 2010, Oracle and/or its affiliates. All rights reserved. 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 @@ -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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ #include "myisamdef.h" diff --git a/storage/myisam/sp_test.c b/storage/myisam/sp_test.c index d86fdc03908..cf4519a7734 100644 --- a/storage/myisam/sp_test.c +++ b/storage/myisam/sp_test.c @@ -1,4 +1,4 @@ -/* Copyright (C) 2002-2004 MySQL AB +/* Copyright (c) 2002, 2011, Oracle and/or its affiliates. All rights reserved. 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 @@ -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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ /* Testing of the basic functions of a MyISAM spatial table */ /* Written by Alex Barkov, who has a shared copyright to this code */ diff --git a/storage/myisammrg/ha_myisammrg.cc b/storage/myisammrg/ha_myisammrg.cc index 0db96444451..05cd1616dc2 100644 --- a/storage/myisammrg/ha_myisammrg.cc +++ b/storage/myisammrg/ha_myisammrg.cc @@ -1,4 +1,4 @@ -/* Copyright (c) 2000, 2010 Oracle and/or its affiliates. All rights reserved. +/* Copyright (c) 2000, 2011, Oracle and/or its affiliates. All rights reserved. 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 @@ -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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ /* @@ -160,9 +160,14 @@ extern "C" void myrg_print_wrong_table(const char *table_name) buf[db.length]= '.'; memcpy(buf + db.length + 1, name.str, name.length); buf[db.length + name.length + 1]= 0; - push_warning_printf(current_thd, MYSQL_ERROR::WARN_LEVEL_WARN, - ER_ADMIN_WRONG_MRG_TABLE, ER(ER_ADMIN_WRONG_MRG_TABLE), - buf); + /* + Push an error to be reported as part of CHECK/REPAIR result-set. + Note that calling my_error() from handler is a hack which is kept + here to avoid refactoring. Normally engines should report errors + through return value which will be interpreted by caller using + handler::print_error() call. + */ + my_error(ER_ADMIN_WRONG_MRG_TABLE, MYF(0), buf); } @@ -594,8 +599,7 @@ public: @return pointer to open MyISAM table structure @retval !=NULL OK, returning pointer - @retval NULL, my_errno == 0 Ok, no more child tables - @retval NULL, my_errno != 0 error + @retval NULL, Error. @detail This function retrieves the MyISAM table handle from the @@ -615,17 +619,33 @@ extern "C" MI_INFO *myisammrg_attach_children_callback(void *callback_param) MI_INFO *myisam= NULL; DBUG_ENTER("myisammrg_attach_children_callback"); - if (!child_l) - { - DBUG_PRINT("myrg", ("No more children to attach")); - my_errno= 0; /* Ok, no more child tables. */ - goto end; - } + /* + Number of children in the list and MYRG_INFO::tables_count, + which is used by caller of this function, should always match. + */ + DBUG_ASSERT(child_l); + child= child_l->table; /* Prepare for next child. */ param->next(); /* + When MERGE table is opened for CHECK or REPAIR TABLE statements, + failure to open any of underlying tables is ignored until this moment + (this is needed to provide complete list of the problematic underlying + tables in CHECK/REPAIR TABLE output). + Here we detect such a situation and report an appropriate error. + */ + if (! child) + { + DBUG_PRINT("error", ("failed to open underlying table '%s'.'%s'", + child_l->db, child_l->table_name)); + /* This should only happen inside of CHECK/REPAIR TABLE. */ + DBUG_ASSERT(current_thd->open_options & HA_OPEN_FOR_REPAIR); + goto end; + } + + /* Do a quick compatibility check. The table def version is set when the table share is created. The child def version is copied from the table def version after a successful compatibility check. @@ -654,7 +674,6 @@ extern "C" MI_INFO *myisammrg_attach_children_callback(void *callback_param) { DBUG_PRINT("error", ("temporary table mismatch parent: %d child: %d", parent->s->tmp_table, child->s->tmp_table)); - my_errno= HA_ERR_WRONG_MRG_TABLE_DEF; goto end; } @@ -665,12 +684,27 @@ extern "C" MI_INFO *myisammrg_attach_children_callback(void *callback_param) DBUG_PRINT("error", ("no MyISAM handle for child table: '%s'.'%s' 0x%lx", child->s->db.str, child->s->table_name.str, (long) child)); - my_errno= HA_ERR_WRONG_MRG_TABLE_DEF; } - DBUG_PRINT("myrg", ("MyISAM handle: 0x%lx my_errno: %d", - my_errno ? 0L : (long) myisam, my_errno)); + + DBUG_PRINT("myrg", ("MyISAM handle: 0x%lx", (long) myisam)); end: + + if (!myisam && + (current_thd->open_options & HA_OPEN_FOR_REPAIR)) + { + char buf[2*NAME_LEN + 1 + 1]; + strxnmov(buf, sizeof(buf) - 1, child_l->db, ".", child_l->table_name, NULL); + /* + Push an error to be reported as part of CHECK/REPAIR result-set. + Note that calling my_error() from handler is a hack which is kept + here to avoid refactoring. Normally engines should report errors + through return value which will be interpreted by caller using + handler::print_error() call. + */ + my_error(ER_ADMIN_WRONG_MRG_TABLE, MYF(0), buf); + } + DBUG_RETURN(myisam); } @@ -783,12 +817,6 @@ int ha_myisammrg::attach_children(void) /* Must call this with children list in place. */ DBUG_ASSERT(this->table->pos_in_table_list->next_global == this->children_l); - /* - 'my_errno' is set by myisammrg_attach_children_callback() in - case of an error. - */ - my_errno= 0; - if (myrg_attach_children(this->file, this->test_if_locked | current_thd->open_options, myisammrg_attach_children_callback, ¶m, @@ -1665,7 +1693,8 @@ mysql_declare_plugin(myisammrg) 0x0100, /* 1.0 */ NULL, /* status variables */ NULL, /* system variables */ - NULL /* config options */ + NULL, /* config options */ + 0, /* flags */ } mysql_declare_plugin_end; maria_declare_plugin(myisammrg) diff --git a/storage/myisammrg/ha_myisammrg.h b/storage/myisammrg/ha_myisammrg.h index 735c7ff53be..5ebe6c56ca5 100644 --- a/storage/myisammrg/ha_myisammrg.h +++ b/storage/myisammrg/ha_myisammrg.h @@ -1,4 +1,5 @@ -/* Copyright (C) 2000-2006 MySQL AB +/* + Copyright (c) 2000, 2011, Oracle and/or its affiliates. All rights reserved. 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 @@ -11,7 +12,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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ #ifdef USE_PRAGMA_INTERFACE diff --git a/storage/myisammrg/myrg_close.c b/storage/myisammrg/myrg_close.c index 066a09cadbc..97c35619067 100644 --- a/storage/myisammrg/myrg_close.c +++ b/storage/myisammrg/myrg_close.c @@ -1,4 +1,4 @@ -/* Copyright (C) 2000-2001 MySQL AB, 2008-2009 Sun Microsystems, Inc +/* Copyright (c) 2000, 2010, Oracle and/or its affiliates. All rights reserved. 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 @@ -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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ /* close a isam-database */ diff --git a/storage/myisammrg/myrg_create.c b/storage/myisammrg/myrg_create.c index 5fbf8a44b8d..53c104b4c4a 100644 --- a/storage/myisammrg/myrg_create.c +++ b/storage/myisammrg/myrg_create.c @@ -1,4 +1,5 @@ -/* Copyright (C) 2000-2001, 2005 MySQL AB, 2008-2009 Sun Microsystems, Inc +/* Copyright (c) 2000, 2001, 2005-2007 MySQL AB, 2009 Sun Microsystems, Inc. + Use is subject to license terms. 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 @@ -11,7 +12,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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ /* Create a MYMERGE_-file */ diff --git a/storage/myisammrg/myrg_def.h b/storage/myisammrg/myrg_def.h index 9bc0881b212..e6fa869ff9b 100644 --- a/storage/myisammrg/myrg_def.h +++ b/storage/myisammrg/myrg_def.h @@ -1,4 +1,4 @@ -/* Copyright (C) 2000-2001, 2003 MySQL AB, 2008-2009 Sun Microsystems, Inc +/* Copyright (c) 2000, 2011, Oracle and/or its affiliates. All rights reserved. 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 @@ -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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ /* This file is included by all myisam-merge files */ diff --git a/storage/myisammrg/myrg_extra.c b/storage/myisammrg/myrg_extra.c index 0b9c138a188..18cc66cf937 100644 --- a/storage/myisammrg/myrg_extra.c +++ b/storage/myisammrg/myrg_extra.c @@ -1,4 +1,5 @@ -/* Copyright (C) 2000-2003 MySQL AB +/* Copyright (c) 2000-2003, 2005-2007 MySQL AB, 2009 Sun Microsystems, Inc. + Use is subject to license terms. 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 @@ -11,7 +12,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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ /* Extra functions we want to do with a database diff --git a/storage/myisammrg/myrg_info.c b/storage/myisammrg/myrg_info.c index 1930351ec8f..53484b430b3 100644 --- a/storage/myisammrg/myrg_info.c +++ b/storage/myisammrg/myrg_info.c @@ -1,4 +1,5 @@ -/* Copyright (C) 2000-2002 MySQL AB +/* Copyright (c) 2000, 2001, 2005, 2006 MySQL AB, 2009 Sun Microsystems, Inc. + Use is subject to license terms. 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 @@ -11,7 +12,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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ #include "myrg_def.h" diff --git a/storage/myisammrg/myrg_open.c b/storage/myisammrg/myrg_open.c index ab1d9ad7f7e..4f1294b0e89 100644 --- a/storage/myisammrg/myrg_open.c +++ b/storage/myisammrg/myrg_open.c @@ -388,6 +388,7 @@ int myrg_attach_children(MYRG_INFO *m_info, int handle_locking, uint UNINIT_VAR(key_parts); uint min_keys; my_bool bad_children= FALSE; + my_bool first_child= TRUE; DBUG_ENTER("myrg_attach_children"); DBUG_PRINT("myrg", ("handle_locking: %d", handle_locking)); @@ -402,16 +403,26 @@ int myrg_attach_children(MYRG_INFO *m_info, int handle_locking, errpos= 0; file_offset= 0; min_keys= 0; - child_nr= 0; - while ((myisam= (*callback)(callback_param))) + for (child_nr= 0; child_nr < m_info->tables; child_nr++) { + if (! (myisam= (*callback)(callback_param))) + { + if (handle_locking & HA_OPEN_FOR_REPAIR) + { + /* An appropriate error should've been already pushed by callback. */ + bad_children= TRUE; + continue; + } + goto bad_children; + } + DBUG_PRINT("myrg", ("child_nr: %u table: '%s'", child_nr, myisam->filename)); - DBUG_ASSERT(child_nr < m_info->tables); /* Special handling when the first child is attached. */ - if (!child_nr) + if (first_child) { + first_child= FALSE; m_info->reclength= myisam->s->base.reclength; min_keys= myisam->s->base.keys; key_parts= myisam->s->base.key_parts; @@ -461,14 +472,11 @@ int myrg_attach_children(MYRG_INFO *m_info, int handle_locking, for (idx= 0; idx < key_parts; idx++) m_info->rec_per_key_part[idx]+= (myisam->s->state.rec_per_key_part[idx] / m_info->tables); - child_nr++; } if (bad_children) goto bad_children; - /* Note: callback() resets my_errno, so it is safe to check it here */ - if (my_errno == HA_ERR_WRONG_MRG_TABLE_DEF) - goto err; + if (sizeof(my_off_t) == 4 && file_offset > (ulonglong) (ulong) ~0L) { my_errno= HA_ERR_RECORD_FILE_FULL; diff --git a/storage/myisammrg/myrg_queue.c b/storage/myisammrg/myrg_queue.c index b13eee3ed75..2ec580e4797 100644 --- a/storage/myisammrg/myrg_queue.c +++ b/storage/myisammrg/myrg_queue.c @@ -1,4 +1,4 @@ -/* Copyright (C) 2000-2003, 2005 MySQL AB +/* Copyright (c) 2000, 2010, Oracle and/or its affiliates. All rights reserved. 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 @@ -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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ #include "myrg_def.h" diff --git a/storage/myisammrg/myrg_rkey.c b/storage/myisammrg/myrg_rkey.c index c00ca79056f..95056c09a49 100644 --- a/storage/myisammrg/myrg_rkey.c +++ b/storage/myisammrg/myrg_rkey.c @@ -1,4 +1,5 @@ -/* Copyright (C) 2000-2003, 2005 MySQL AB +/* Copyright (c) 2000-2003, 2005-2008 MySQL AB, 2009 Sun Microsystems, Inc. + Use is subject to license terms. 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 @@ -11,7 +12,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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ /* Read record based on a key */ diff --git a/storage/myisammrg/myrg_static.c b/storage/myisammrg/myrg_static.c index b518a3d84c8..b36b7741a64 100644 --- a/storage/myisammrg/myrg_static.c +++ b/storage/myisammrg/myrg_static.c @@ -1,4 +1,5 @@ -/* Copyright (C) 2000-2001, 2004 MySQL AB, 2008-2009 Sun Microsystems, Inc +/* Copyright (c) 2000, 2001, 2005, 2006 MySQL AB, 2009 Sun Microsystems, Inc. + Use is subject to license terms. 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 @@ -11,7 +12,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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ /* Static variables for pisam library. All definied here for easy making of diff --git a/storage/ndb/MAINTAINERS b/storage/ndb/MAINTAINERS index d1547d48234..38f504cd1a1 100644 --- a/storage/ndb/MAINTAINERS +++ b/storage/ndb/MAINTAINERS @@ -1,3 +1,5 @@ +Copyright (c) 2007 MySQL AB + MySQL Cluster MAINTAINERS ------------------------- diff --git a/storage/ndb/config/win-lib.am b/storage/ndb/config/win-lib.am index 1e7bbfae19b..2922cf6cfd2 100644 --- a/storage/ndb/config/win-lib.am +++ b/storage/ndb/config/win-lib.am @@ -1,5 +1,21 @@ # Microsoft Developer Studio Project File - Name="@name@" - Package Owner=<4> # Microsoft Developer Studio Generated Build File, Format Version 6.00 + +# Copyright (c) 2004, 2010, Oracle and/or its affiliates. All rights reserved. +# +# 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 +# the Free Software Foundation; version 2 of the License. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# 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 02110-1301 USA + # ** DO NOT EDIT ** # TARGTYPE "Win32 (x86) Static Library" 0x0104 diff --git a/storage/ndb/config/win-prg.am b/storage/ndb/config/win-prg.am index 5d56d79c41e..838345566a2 100644 --- a/storage/ndb/config/win-prg.am +++ b/storage/ndb/config/win-prg.am @@ -1,5 +1,21 @@ # Microsoft Developer Studio Project File - Name="mysqld" - Package Owner=<4> # Microsoft Developer Studio Generated Build File, Format Version 6.00 + +# Copyright (c) 2004, 2010, Oracle and/or its affiliates. All rights reserved. +# +# 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 +# the Free Software Foundation; version 2 of the License. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# 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 02110-1301 USA + # ** DO NOT EDIT ** # TARGTYPE "Win32 (x86) Console Application" 0x0103 diff --git a/storage/ndb/plug.in b/storage/ndb/plug.in index 04e618923e4..349c0660a1c 100644 --- a/storage/ndb/plug.in +++ b/storage/ndb/plug.in @@ -2,7 +2,6 @@ sinclude(storage/ndb/ndb_configure.m4) MYSQL_STORAGE_ENGINE(ndbcluster, ndbcluster, [Cluster Storage Engine], [High Availability Clustered tables],) -MYSQL_PLUGIN_DIRECTORY(ndbcluster,[storage/ndb]) MYSQL_PLUGIN_STATIC(ndbcluster, [[\$(ndbcluster_libs) \$(ndbcluster_system_libs) \$(NDB_SCI_LIBS)]]) MYSQL_PLUGIN_ACTIONS(ndbcluster,[MYSQL_SETUP_NDBCLUSTER]) MYSQL_PLUGIN_DEPENDS(ndbcluster, [partition]) diff --git a/storage/ndb/src/kernel/blocks/lgman.cpp b/storage/ndb/src/kernel/blocks/lgman.cpp index 7dc71e7399a..cd3fc0d4fbb 100644 --- a/storage/ndb/src/kernel/blocks/lgman.cpp +++ b/storage/ndb/src/kernel/blocks/lgman.cpp @@ -1,4 +1,5 @@ -/* Copyright (c) 2003, 2011, Oracle and/or its affiliates. All rights reserved. +/* + Copyright (c) 2005, 2011, Oracle and/or its affiliates. All rights reserved. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License @@ -12,8 +13,8 @@ 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 - 02110-1301 USA */ + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +*/ #include "lgman.hpp" #include "diskpage.hpp" diff --git a/storage/ndb/test/run-test/autotest-boot.sh b/storage/ndb/test/run-test/autotest-boot.sh index 1df3a26cc8a..f1f8aea2519 100644 --- a/storage/ndb/test/run-test/autotest-boot.sh +++ b/storage/ndb/test/run-test/autotest-boot.sh @@ -1,4 +1,21 @@ #!/bin/sh + +# Copyright (c) 2007 MySQL AB +# Use is subject to license terms. +# +# 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 +# the Free Software Foundation; version 2 of the License. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# 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 02110-1301 USA + ############################################################# # This script created by Jonas does the following # # Cleans up clones and pevious builds, pulls new clones, # diff --git a/storage/ndb/test/run-test/autotest-run.sh b/storage/ndb/test/run-test/autotest-run.sh index b543cd1efb9..0c9c6aee215 100644 --- a/storage/ndb/test/run-test/autotest-run.sh +++ b/storage/ndb/test/run-test/autotest-run.sh @@ -1,4 +1,21 @@ #!/bin/sh + +# Copyright (c) 2007 MySQL AB +# Use is subject to license terms. +# +# 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 +# the Free Software Foundation; version 2 of the License. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# 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 02110-1301 USA + ############################################################# # This script created by Jonas does the following # # Cleans up clones and pevious builds, pulls new clones, # diff --git a/storage/ndb/test/run-test/files.cpp b/storage/ndb/test/run-test/files.cpp index c6a29350b91..294d0aca56e 100644 --- a/storage/ndb/test/run-test/files.cpp +++ b/storage/ndb/test/run-test/files.cpp @@ -1,3 +1,21 @@ +/* + Copyright (c) 2007 MySQL AB + Use is subject to license terms. + + 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 + the Free Software Foundation; version 2 of the License. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + 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 02110-1301 USA +*/ + #include "atrt.hpp" #include <sys/types.h> #include <dirent.h> diff --git a/storage/ndb/test/run-test/setup.cpp b/storage/ndb/test/run-test/setup.cpp index fc30c998865..52fbe5a8e8e 100644 --- a/storage/ndb/test/run-test/setup.cpp +++ b/storage/ndb/test/run-test/setup.cpp @@ -1,3 +1,20 @@ +/* + Copyright (c) 2007, 2011, Oracle and/or its affiliates. All rights reserved. + + 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 + the Free Software Foundation; version 2 of the License. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + 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 02110-1301 USA +*/ + #include "atrt.hpp" #include <ndb_global.h> #include <my_sys.h> diff --git a/storage/ndb/test/run-test/upgrade-boot.sh b/storage/ndb/test/run-test/upgrade-boot.sh index d3542166551..745418dbb7c 100644 --- a/storage/ndb/test/run-test/upgrade-boot.sh +++ b/storage/ndb/test/run-test/upgrade-boot.sh @@ -1,4 +1,21 @@ #!/bin/sh + +# Copyright (c) 2007 MySQL AB +# Use is subject to license terms. +# +# 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 +# the Free Software Foundation; version 2 of the License. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# 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 02110-1301 USA + ############################################################# # This script created by Jonas does the following # # Cleans up clones and pevious builds, pulls new clones, # diff --git a/storage/ndb/test/sql/BANK.sql b/storage/ndb/test/sql/BANK.sql deleted file mode 100644 index 055761621e3..00000000000 --- a/storage/ndb/test/sql/BANK.sql +++ /dev/null @@ -1,44 +0,0 @@ -CREATE DATABASE IF NOT EXISTS BANK default charset=latin1 default collate=latin1_bin; -USE BANK; -DROP TABLE IF EXISTS GL; -CREATE TABLE GL ( TIME BIGINT UNSIGNED NOT NULL, - ACCOUNT_TYPE INT UNSIGNED NOT NULL, - BALANCE INT UNSIGNED NOT NULL, - DEPOSIT_COUNT INT UNSIGNED NOT NULL, - DEPOSIT_SUM INT UNSIGNED NOT NULL, - WITHDRAWAL_COUNT INT UNSIGNED NOT NULL, - WITHDRAWAL_SUM INT UNSIGNED NOT NULL, - PURGED INT UNSIGNED NOT NULL, - PRIMARY KEY USING HASH (TIME,ACCOUNT_TYPE)) - ENGINE = NDB; - -DROP TABLE IF EXISTS ACCOUNT; -CREATE TABLE ACCOUNT ( ACCOUNT_ID INT UNSIGNED NOT NULL, - OWNER INT UNSIGNED NOT NULL, - BALANCE INT UNSIGNED NOT NULL, - ACCOUNT_TYPE INT UNSIGNED NOT NULL, - PRIMARY KEY USING HASH (ACCOUNT_ID)) - ENGINE = NDB; - -DROP TABLE IF EXISTS TRANSACTION; -CREATE TABLE TRANSACTION ( TRANSACTION_ID BIGINT UNSIGNED NOT NULL, - ACCOUNT INT UNSIGNED NOT NULL, - ACCOUNT_TYPE INT UNSIGNED NOT NULL, - OTHER_ACCOUNT INT UNSIGNED NOT NULL, - TRANSACTION_TYPE INT UNSIGNED NOT NULL, - TIME BIGINT UNSIGNED NOT NULL, - AMOUNT INT UNSIGNED NOT NULL, - PRIMARY KEY USING HASH (TRANSACTION_ID,ACCOUNT)) - ENGINE = NDB; - -DROP TABLE IF EXISTS SYSTEM_VALUES; -CREATE TABLE SYSTEM_VALUES ( SYSTEM_VALUES_ID INT UNSIGNED NOT NULL, - VALUE BIGINT UNSIGNED NOT NULL, - PRIMARY KEY USING HASH (SYSTEM_VALUES_ID)) - ENGINE = NDB; - -DROP TABLE IF EXISTS ACCOUNT_TYPE; -CREATE TABLE ACCOUNT_TYPE ( ACCOUNT_TYPE_ID INT UNSIGNED NOT NULL, - DESCRIPTION CHAR(64) NOT NULL, - PRIMARY KEY USING HASH (ACCOUNT_TYPE_ID)) - ENGINE = NDB; diff --git a/storage/ndb/test/sql/T1.sql b/storage/ndb/test/sql/T1.sql deleted file mode 100644 index 754211c4eac..00000000000 --- a/storage/ndb/test/sql/T1.sql +++ /dev/null @@ -1,9 +0,0 @@ -create database if not exists TEST_DB; -use TEST_DB; -drop table if exists T1; -create table T1 (KOL1 int unsigned not null, - KOL2 int unsigned not null, - KOL3 int unsigned not null, - KOL4 int unsigned not null, - KOL5 int unsigned not null, - primary key using hash(KOL1)) engine=ndb; diff --git a/storage/ndb/test/sql/test_create_drop.pl b/storage/ndb/test/sql/test_create_drop.pl deleted file mode 100644 index eb9d5e31dc8..00000000000 --- a/storage/ndb/test/sql/test_create_drop.pl +++ /dev/null @@ -1,196 +0,0 @@ -# Copyright (C) 2005 MySQL AB -# -# This program is free software; you can redistribute it and/or -# modify it under the terms of the GNU Library General Public -# License as published by the Free Software Foundation; version 2 -# of the License. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -# Library General Public License for more details. -# -# You should have received a copy of the GNU Library General Public -# License along with this library; if not, write to the Free -# Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, -# MA 02111-1307, USA - -use strict; -use IO::Socket; -use DBI; - -# mgm info -my $mgmhost = "localhost"; -my $mgmport = 38101; - -# location of ndb_x_fs -my $datadir = "c2"; -my @schemafiles = <$datadir/ndb_*_fs/D[12]/DBDICT/P0.SchemaLog>; -@schemafiles or die "no schemafiles in $datadir"; - -my $dsn; -$dsn = "dbi:mysql:test:localhost;port=38100"; - -# this works better for me -my $cnf = $ENV{MYSQL_HOME} . "/var/my.cnf"; -$dsn = "dbi:mysql:database=test;host=localhost;mysql_read_default_file=$cnf"; - -my $dbh; -$dbh = DBI->connect($dsn, 'root', undef, { RaiseError => 0, PrintError => 0 }); -$dbh or die $DBI::errstr; - -# mgm commands - -my $mgm = undef; - -sub mgmconnect { - $mgm = IO::Socket::INET->new( - Proto => "tcp", - PeerHost => $mgmhost, - PeerPort => $mgmport); - $mgm or die "connect to mgm failed: $!"; - $mgm->autoflush(1); -}; - -mgmconnect(); -warn "connected to mgm $mgmhost $mgmport\n"; - -my $nodeinfo = {}; - -sub getnodeinfo { - $nodeinfo = {}; - $mgm->print("get status\n"); - $mgm->print("\n"); - while (defined($_ = $mgm->getline)) { - /^node\s+status/ && last; - } - while (defined($_ = $mgm->getline)) { - /^\s*$/ && last; - /^node\.(\d+)\.(\w+):\s*(\S+)/ && ($nodeinfo->{$1}{$2} = $3); - } -} - -getnodeinfo(); - -my @dbnode = (); -for my $n (keys %$nodeinfo) { - my $p = $nodeinfo->{$n}; - ($p->{type} eq 'NDB') && push(@dbnode, $n); -} -@dbnode = sort { $a <=> $b } @dbnode; -@dbnode or die "mgm error, found no db nodes"; -warn "db nodes: @dbnode\n"; - -sub restartnode { - my($n, $initialstart) = @_; - warn "restart node $n initialstart=$initialstart\n"; - $mgm->print("restart node\n"); - $mgm->print("node: $n\n"); - $mgm->print("initialstart: $initialstart\n"); - $mgm->print("\n"); - while (1) { - sleep 5; - getnodeinfo(); - my $status = $nodeinfo->{$n}{status}; - my $sp = $nodeinfo->{$n}{startphase}; - warn "node $n status: $status sp: $sp\n"; - last if $status eq 'STARTED'; - } -} - -sub restartall { - warn "restart all\n"; - $mgm->print("restart all\n"); - $mgm->print("\n"); - while (1) { - sleep 5; - getnodeinfo(); - my $ok = 1; - for my $n (@dbnode) { - my $status = $nodeinfo->{$n}{status}; - my $sp = $nodeinfo->{$n}{startphase}; - warn "node $n status: $status sp: $sp\n"; - $ok = 0 if $status ne 'STARTED'; - } - last if $ok; - } -} - -# the sql stuff - -my $maxtab = 300; -my @tab = (); - -sub create { - my($n) = @_; - my $sql = "create table t$n (a int primary key, b varchar(20), key (b)) engine=ndb"; - warn "create t$n\n"; - $dbh->do($sql) or die "$sql\n$DBI::errstr"; -} - -sub drop { - my($n) = @_; - my $sql = "drop table t$n"; - warn "drop t$n\n"; - $dbh->do($sql) or die "$sql\n$DBI::errstr"; -} - -sub dropall { - for my $n (0..($maxtab-1)) { - my $sql = "drop table if exists t$n"; - $dbh->do($sql) or die "$sql\n$DBI::errstr"; - } -} - -sub createdrop { - my $n = int(rand($maxtab)); - if (! $tab[$n]) { - create($n); - $tab[$n] = 1; - } else { - drop($n); - $tab[$n] = 0; - } -} - -sub checkschemafiles { - system("printSchemaFile -ce @schemafiles"); - $? == 0 or die "schemafiles check failed"; -} - -sub randomrestart { - my($k) = @_; - my $s = int(rand(500)); - if ($s < 2) { - my $i = $k % scalar(@dbnode); - my $n = $dbnode[$i]; - my $initialstart = ($s < 1 ? 0 : 1); - restartnode($n, $initialstart); - return 1; - } - if ($s < 3) { - restartall(); - return 1; - } - return 0; -} - -# deterministic -srand(1); - -warn "drop any old tables\n"; -dropall(); - -my $loop = 1000000; -for my $k (0..($loop-1)) { - warn "$k\n"; - createdrop(); - checkschemafiles(); - if (randomrestart($k)) { - checkschemafiles(); - } -} - -$dbh->disconnect or die $DBI::errstr; - -# vim: set sw=2: diff --git a/storage/ndb/test/sql/test_range_bounds.pl b/storage/ndb/test/sql/test_range_bounds.pl deleted file mode 100644 index 964847044de..00000000000 --- a/storage/ndb/test/sql/test_range_bounds.pl +++ /dev/null @@ -1,235 +0,0 @@ -# Copyright (C) 2005 MySQL AB -# -# This program is free software; you can redistribute it and/or -# modify it under the terms of the GNU Library General Public -# License as published by the Free Software Foundation; version 2 -# of the License. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -# Library General Public License for more details. -# -# You should have received a copy of the GNU Library General Public -# License along with this library; if not, write to the Free -# Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, -# MA 02111-1307, USA - -# -# test range scan bounds -# give option --all to test all cases -# set MYSQL_HOME to installation top -# - -use strict; -use integer; -use Getopt::Long; -use DBI; - -my $opt_all = 0; -my $opt_cnt = 5; -my $opt_verbose = 0; -GetOptions("all" => \$opt_all, "cnt=i" => \$opt_cnt, "verbose" => \$opt_verbose) - or die "options are: --all --cnt=N --verbose"; - -my $mysql_home = $ENV{MYSQL_HOME}; -defined($mysql_home) or die "no MYSQL_HOME"; -my $dsn = "dbi:mysql:database=test;host=localhost;mysql_read_default_file=$mysql_home/var/my.cnf"; -my $opts = { RaiseError => 0, PrintError => 0, AutoCommit => 1, }; - -my $dbh; -my $sth; -my $sql; - -$dbh = DBI->connect($dsn, "root", undef, $opts) or die $DBI::errstr; - -my $table = 't'; - -$sql = "drop table if exists $table"; -$dbh->do($sql) or die $DBI::errstr; - -sub cut ($$$) { - my($op, $key, $val) = @_; - $op = '==' if $op eq '='; - my(@w) = @$val; - eval "\@w = grep(\$_ $op $key, \@w)"; - $@ and die $@; - return [ @w ]; -} - -sub mkdummy ($) { - my ($val) = @_; - return { - 'dummy' => 1, - 'exp' => '9 = 9', - 'res' => $val, - }; -} - -sub mkone ($$$$) { - my($col, $op, $key, $val) = @_; - my $res = cut($op, $key, $val); - return { - 'exp' => "$col $op $key", - 'res' => $res, - }; -} - -sub mktwo ($$$$$$) { - my($col, $op1, $key1, $op2, $key2, $val) = @_; - my $res = cut($op2, $key2, cut($op1, $key1, $val)); - return { - 'exp' => "$col $op1 $key1 and $col $op2 $key2", - 'res' => $res, - }; -} - -sub mkall ($$$$) { - my($col, $key1, $key2, $val) = @_; - my @a = (); - my $p = mkdummy($val); - push(@a, $p) if $opt_all; - my @ops = qw(< <= = >= >); - for my $op (@ops) { - my $p = mkone($col, $op, $key1, $val); - push(@a, $p) if $opt_all || @{$p->{res}} != 0; - } - my @ops1 = $opt_all ? @ops : qw(= >= >); - my @ops2 = $opt_all ? @ops : qw(<= <); - for my $op1 (@ops1) { - for my $op2 (@ops2) { - my $p = mktwo($col, $op1, $key1, $op2, $key2, $val); - push(@a, $p) if $opt_all || @{$p->{res}} != 0; - } - } - warn scalar(@a)." cases\n" if $opt_verbose; - return \@a; -} - -my $casecnt = 0; - -sub verify ($$$) { - my($sql, $ord, $res) = @_; - warn "$sql\n" if $opt_verbose; - $sth = $dbh->prepare($sql) or die "prepare: $sql: $DBI::errstr"; - $sth->execute() or die "execute: $sql: $DBI::errstr"; - # - # BUG: execute can return success on error so check again - # - $sth->err and die "execute: $sql: $DBI::errstr"; - my @out = (); - for my $b (@{$res->[0]}) { - for my $c (@{$res->[1]}) { - for my $d (@{$res->[2]}) { - push(@out, [$b, $c, $d]); - } - } - } - if ($ord) { - @out = sort { - $ord * ($a->[0] - $b->[0]) || - $ord * ($a->[1] - $b->[1]) || - $ord * ($a->[2] - $b->[2]) || - 0 - } @out; - } - my $cnt = scalar @out; - my $n = 0; - while (1) { - my $row = $sth->fetchrow_arrayref; - $row || last; - @$row == 3 or die "bad row: $sql: @$row"; - for my $v (@$row) { - $v =~ s/^\s+|\s+$//g; - $v =~ /^\d+$/ or die "bad value: $sql: $v"; - } - if ($ord) { - my $out = $out[$n]; - $row->[0] == $out->[0] && - $row->[1] == $out->[1] && - $row->[2] == $out->[2] or - die "$sql: row $n: got row @$row != @$out"; - } - $n++; - } - $sth->err and die "fetch: $sql: $DBI::errstr"; - $n == $cnt or die "verify: $sql: got row count $n != $cnt"; - $casecnt++; -} - -for my $nn ("bcd", "") { - my %nn; - for my $x (qw(b c d)) { - $nn{$x} = $nn =~ /$x/ ? "not null" : "null"; - } - warn "create table\n"; - $sql = <<EOF; -create table $table ( - a int primary key, - b int $nn{b}, - c int $nn{c}, - d int $nn{d}, - index (b, c, d) -) engine=ndb -EOF - $dbh->do($sql) or die $DBI::errstr; - warn "insert\n"; - $sql = "insert into $table values(?, ?, ?, ?)"; - $sth = $dbh->prepare($sql) or die $DBI::errstr; - my @val = (0..($opt_cnt-1)); - my $v0 = 0; - for my $v1 (@val) { - for my $v2 (@val) { - for my $v3 (@val) { - $sth->bind_param(1, $v0) or die $DBI::errstr; - $sth->bind_param(2, $v1) or die $DBI::errstr; - $sth->bind_param(3, $v2) or die $DBI::errstr; - $sth->bind_param(4, $v3) or die $DBI::errstr; - $sth->execute or die $DBI::errstr; - $v0++; - } - } - } - warn "generate cases\n"; - my $key1 = 1; - my $key2 = 3; - my $a1 = mkall('b', $key1, $key2, \@val); - my $a2 = mkall('c', $key1, $key2, \@val); - my $a3 = mkall('d', $key1, $key2, \@val); - warn "select\n"; - for my $ord (0, +1, -1) { - my $orderby = - $ord == 0 ? "" : - $ord == +1 ? " order by b, c, d" : - $ord == -1 ? " order by b desc, c desc, d desc" : die "not here"; - for my $p1 (@$a1) { - my $res = [ $p1->{res}, \@val, \@val ]; - $sql = "select b, c, d from $table" . - " where $p1->{exp}" . - $orderby; - verify($sql, $ord, $res); - for my $p2 (@$a2) { - my $res = [ $p1->{res}, $p2->{res}, \@val ]; - $sql = "select b, c, d from $table" . - " where $p1->{exp} and $p2->{exp}" . - $orderby; - verify($sql, $ord, $res); - for my $p3 (@$a3) { - my $res = [ $p1->{res}, $p2->{res}, $p3->{res} ]; - $sql = "select b, c, d from $table" . - " where $p1->{exp} and $p2->{exp} and $p3->{exp}" . - $orderby; - verify($sql, $ord, $res); - } - } - } - } - warn "drop table\n"; - $sql = "drop table $table"; - $dbh->do($sql) or die $DBI::errstr; -} - -warn "verified $casecnt cases\n"; -warn "done\n"; - -# vim: set sw=2: diff --git a/storage/ndb/test/tools/log_listner.cpp b/storage/ndb/test/tools/log_listner.cpp index c5125ef7414..a0a03f1319a 100644 --- a/storage/ndb/test/tools/log_listner.cpp +++ b/storage/ndb/test/tools/log_listner.cpp @@ -1,3 +1,21 @@ +/* + Copyright (c) 2007 MySQL AB + Use is subject to license terms. + + 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 + the Free Software Foundation; version 2 of the License. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + 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 02110-1301 USA +*/ + #include <mgmapi.h> #include <ndb_global.h> #include <ndb_opts.h> diff --git a/storage/pbxt/src/database_xt.cc b/storage/pbxt/src/database_xt.cc index 8d1b4e46da9..635cb63224a 100644 --- a/storage/pbxt/src/database_xt.cc +++ b/storage/pbxt/src/database_xt.cc @@ -87,7 +87,7 @@ xtPublic void xt_lock_installation(XTThreadPtr self, char *installation_path) char file_path[PATH_MAX]; char buffer[101]; size_t red_size; - llong pid; + llong pid __attribute__ ((unused)); xtBool cd = pbxt_crash_debug; xt_strcpy(PATH_MAX, file_path, installation_path); diff --git a/storage/pbxt/src/ha_pbxt.cc b/storage/pbxt/src/ha_pbxt.cc index 7305f80f0fb..f574dbd362a 100644 --- a/storage/pbxt/src/ha_pbxt.cc +++ b/storage/pbxt/src/ha_pbxt.cc @@ -1596,7 +1596,7 @@ static int pbxt_rollback(handlerton *hton, THD *thd, bool all) if (!all) self->st_stat_trans = FALSE; } - return 0; + return err; } #ifdef DRIZZLED @@ -2904,11 +2904,9 @@ int ha_pbxt::update_row(const byte * old_data, byte * new_data) * insert into t1 (val) values (1); */ if (table->found_next_number_field && new_data == table->record[0]) { - MX_LONGLONG_T nr; my_bitmap_map *old_map; old_map = mx_tmp_use_all_columns(table, table->read_set); - nr = table->found_next_number_field->val_int(); ha_set_auto_increment(pb_open_tab, table->found_next_number_field); mx_tmp_restore_column_map(table, old_map); } @@ -6120,62 +6118,6 @@ static struct st_mysql_sys_var* pbxt_system_variables[] = { }; #endif -#ifdef DRIZZLED -drizzle_declare_plugin(pbxt) -#else -mysql_declare_plugin(pbxt) -#endif -{ -#ifndef DRIZZLED - MYSQL_STORAGE_ENGINE_PLUGIN, - &pbxt_storage_engine, -#endif - "PBXT", -#ifdef DRIZZLED - "1.0", -#endif - "Paul McCullagh, PrimeBase Technologies GmbH", - "High performance, multi-versioning transactional engine", - PLUGIN_LICENSE_GPL, - pbxt_init, /* Plugin Init */ - pbxt_end, /* Plugin Deinit */ -#ifndef DRIZZLED - 0x0001 /* 0.1 */, -#endif - NULL, /* status variables */ -#if MYSQL_VERSION_ID >= 50118 - pbxt_system_variables, /* system variables */ -#else - NULL, -#endif - NULL /* config options */ -}, -{ -#ifndef DRIZZLED - MYSQL_INFORMATION_SCHEMA_PLUGIN, - &pbxt_statitics, -#endif - "PBXT_STATISTICS", -#ifdef DRIZZLED - "1.0", -#endif - "Paul McCullagh, PrimeBase Technologies GmbH", - "PBXT internal system statitics", - PLUGIN_LICENSE_GPL, - pbxt_init_statistics, /* plugin init */ - pbxt_exit_statistics, /* plugin deinit */ -#ifndef DRIZZLED - 0x0005, -#endif - NULL, /* status variables */ - NULL, /* system variables */ - NULL /* config options */ -} -#ifdef DRIZZLED -drizzle_declare_plugin_end; -#else -mysql_declare_plugin_end; -#if defined(MARIADB_BASE_VERSION) && MYSQL_VERSION_ID > 50200 maria_declare_plugin(pbxt) { /* PBXT */ MYSQL_STORAGE_ENGINE_PLUGIN, @@ -6208,8 +6150,6 @@ maria_declare_plugin(pbxt) MariaDB_PLUGIN_MATURITY_GAMMA /* maturity */ } maria_declare_plugin_end; -#endif -#endif #if defined(XT_WIN) && defined(XT_COREDUMP) diff --git a/storage/pbxt/src/memory_xt.cc b/storage/pbxt/src/memory_xt.cc index b2f6c248b3c..d498336e814 100644 --- a/storage/pbxt/src/memory_xt.cc +++ b/storage/pbxt/src/memory_xt.cc @@ -558,7 +558,7 @@ static size_t mm_checkmem(XTThreadPtr self, MissingMemoryPtr mm_ptr, void *p, xt unsigned char *ptr = (unsigned char *) p - MEM_DEBUG_HDR_SIZE; MemoryDebugPtr debug_ptr = (MemoryDebugPtr) ptr; size_t size = debug_ptr->size; - long a_value; /* Added to simplfy debugging. */ + long a_value __attribute__ ((unused)); /* Added to simplfy debugging. */ if (!ASSERT(p)) return(0); diff --git a/storage/pbxt/src/myxt_xt.cc b/storage/pbxt/src/myxt_xt.cc index 7fd94aeaef7..f04138bd10f 100644 --- a/storage/pbxt/src/myxt_xt.cc +++ b/storage/pbxt/src/myxt_xt.cc @@ -836,7 +836,10 @@ xtPublic xtBool myxt_create_row_from_key(XTOpenTablePtr XT_UNUSED(ot), XTIndexPt { byte *record = (byte *) dest_buff; register byte *key; - byte *pos,*key_end; + byte *pos; +#ifdef CHECK_KEYS + byte *key_end; +#endif register XTIndexSegRec *keyseg = ind->mi_seg; /* GOTCHA: When selecting from multiple @@ -849,7 +852,9 @@ xtPublic xtBool myxt_create_row_from_key(XTOpenTablePtr XT_UNUSED(ot), XTIndexPt memset(dest_buff, 0xFF, table->s->null_bytes); */ key = (byte *) b_value; +#ifdef CHECK_KEYS key_end = key + key_len; +#endif for (u_int i=0; i<ind->mi_seg_count; i++, keyseg++) { if (keyseg->null_bit) { if (!*key++) @@ -1027,7 +1032,8 @@ xtPublic u_int myxt_get_key_length(XTIndexPtr ind, xtWord1 *key_buf) register XTIndexSegRec *keyseg = ind->mi_seg; register uchar *key_data = (uchar *) key_buf; uint seg_len; - uint pack_len; + uint pack_len + __attribute__ ((unused)); for (u_int i=0; i<ind->mi_seg_count; i++, keyseg++) { /* Handle NULL part */ @@ -1512,7 +1518,7 @@ xtPublic u_int myxt_key_seg_length(XTIndexSegRec *keyseg, u_int key_offset, xtWo xtPublic xtWord4 myxt_store_row_length(XTOpenTablePtr ot, char *rec_buff) { TABLE *table = ot->ot_table->tab_dic.dic_my_table; - char *sdata; + char *sdata __attribute__ ((unused)); xtWord4 dlen; xtWord4 item_size; xtWord4 row_size = 0; @@ -1892,7 +1898,8 @@ xtPublic void myxt_print_key(XTIndexPtr ind, xtWord1 *key_value) register XTIndexSegRec *keyseg = ind->mi_seg; register uchar *b = (uchar *) key_value; uint b_length; - uint pack_len; + uint pack_len + __attribute__ ((unused)); for (u_int i = 0; i < ind->mi_seg_count; i++, keyseg++) { if (i!=0) diff --git a/storage/pbxt/src/restart_xt.cc b/storage/pbxt/src/restart_xt.cc index 162ec90d754..54454ac92c5 100644 --- a/storage/pbxt/src/restart_xt.cc +++ b/storage/pbxt/src/restart_xt.cc @@ -94,17 +94,21 @@ void xt_print_log_record(xtLogID log, xtLogOffset offset, XTXactLogBufferDPtr re xtBool xn_set = FALSE; xtXactID xn_id = 0; char buffer[200]; +#ifdef TRACE_RECORD_DATA XTTabRecExtDPtr rec_buf; - XTTabRecExtDPtr ext_rec; XTTabRecFixDPtr fix_rec; u_int rec_len; +#endif + XTTabRecExtDPtr ext_rec; xtLogID log_id = 0; xtLogOffset log_offset = 0; +#ifdef TRACE_RECORD_DATA rec_buf = NULL; - ext_rec = NULL; fix_rec = NULL; rec_len = 0; +#endif + ext_rec = NULL; switch (record->xl.xl_status_1) { case XT_LOG_ENT_REC_MODIFIED: case XT_LOG_ENT_UPDATE: @@ -118,10 +122,12 @@ void xt_print_log_record(xtLogID log, xtLogOffset offset, XTXactLogBufferDPtr re rec_id = XT_GET_DISK_4(record->xu.xu_rec_id_4); xn_id = XT_GET_DISK_4(record->xu.xu_xact_id_4); row_id = XT_GET_DISK_4(record->xu.xu_row_id_4); - rec_len = XT_GET_DISK_2(record->xu.xu_size_2); xn_set = TRUE; type="rec"; +#ifdef TRACE_RECORD_DATA + rec_len = XT_GET_DISK_2(record->xu.xu_size_2); rec_buf = (XTTabRecExtDPtr) &record->xu.xu_rec_type_1; +#endif ext_rec = (XTTabRecExtDPtr) &record->xu.xu_rec_type_1; if (XT_REC_IS_EXT_DLOG(ext_rec->tr_rec_type_1)) { log_id = XT_GET_DISK_2(ext_rec->re_log_id_2); @@ -129,7 +135,9 @@ void xt_print_log_record(xtLogID log, xtLogOffset offset, XTXactLogBufferDPtr re } else { ext_rec = NULL; +#ifdef TRACE_RECORD_DATA fix_rec = (XTTabRecFixDPtr) &record->xu.xu_rec_type_1; +#endif } break; case XT_LOG_ENT_UPDATE_FL: @@ -143,10 +151,12 @@ void xt_print_log_record(xtLogID log, xtLogOffset offset, XTXactLogBufferDPtr re rec_id = XT_GET_DISK_4(record->xf.xf_rec_id_4); xn_id = XT_GET_DISK_4(record->xf.xf_xact_id_4); row_id = XT_GET_DISK_4(record->xf.xf_row_id_4); - rec_len = XT_GET_DISK_2(record->xf.xf_size_2); xn_set = TRUE; type="rec"; +#ifdef TRACE_RECORD_DATA + rec_len = XT_GET_DISK_2(record->xf.xf_size_2); rec_buf = (XTTabRecExtDPtr) &record->xf.xf_rec_type_1; +#endif ext_rec = (XTTabRecExtDPtr) &record->xf.xf_rec_type_1; if (XT_REC_IS_EXT_DLOG(ext_rec->tr_rec_type_1)) { log_id = XT_GET_DISK_2(ext_rec->re_log_id_2); @@ -154,7 +164,9 @@ void xt_print_log_record(xtLogID log, xtLogOffset offset, XTXactLogBufferDPtr re } else { ext_rec = NULL; +#ifdef TRACE_RECORD_DATA fix_rec = (XTTabRecFixDPtr) &record->xf.xf_rec_type_1; +#endif } break; case XT_LOG_ENT_REC_FREED: @@ -173,10 +185,12 @@ void xt_print_log_record(xtLogID log, xtLogOffset offset, XTXactLogBufferDPtr re rec_id = XT_GET_DISK_4(record->rb.rb_rec_id_4); xn_id = XT_GET_DISK_4(record->rb.rb_xact_id_4); row_id = XT_GET_DISK_4(record->rb.rb_row_id_4); - rec_len = XT_GET_DISK_2(record->rb.rb_size_2); xn_set = TRUE; type="rec"; +#ifdef TRACE_RECORD_DATA + rec_len = XT_GET_DISK_2(record->rb.rb_size_2); rec_buf = (XTTabRecExtDPtr) &record->rb.rb_rec_type_1; +#endif ext_rec = (XTTabRecExtDPtr) &record->rb.rb_rec_type_1; if (XT_REC_IS_EXT_DLOG(record->rb.rb_rec_type_1)) { log_id = XT_GET_DISK_2(ext_rec->re_log_id_2); @@ -184,7 +198,9 @@ void xt_print_log_record(xtLogID log, xtLogOffset offset, XTXactLogBufferDPtr re } else { ext_rec = NULL; +#ifdef TRACE_RECORD_DATA fix_rec = (XTTabRecFixDPtr) &record->rb.rb_rec_type_1; +#endif } break; case XT_LOG_ENT_REC_MOVED: @@ -967,7 +983,8 @@ static void xres_apply_change(XTThreadPtr self, XTOpenTablePtr ot, XTXactLogBuff xtLogID data_log_id = 0; xtLogOffset data_log_offset = 0; u_int cols_required = 0; - xtBool record_loaded; + xtBool record_loaded + __attribute__ ((unused)); size_t rec_size; rec_id = XT_GET_DISK_4(record->rb.rb_rec_id_4); diff --git a/storage/pbxt/src/tabcache_xt.cc b/storage/pbxt/src/tabcache_xt.cc index 92958f2da49..c5374b400c3 100644 --- a/storage/pbxt/src/tabcache_xt.cc +++ b/storage/pbxt/src/tabcache_xt.cc @@ -393,7 +393,8 @@ void XTTabCache::xt_tc_release_page(XT_ROW_REC_FILE_PTR XT_UNUSED(file), XTTabCa TAB_CAC_WRITE_LOCK(&seg->tcs_lock, thread->t_id); #ifdef DEBUG - XTTabCachePagePtr lpage, ppage; + XTTabCachePagePtr lpage; + XTTabCachePagePtr ppage __attribute__ ((unused)); ppage = NULL; lpage = seg->tcs_hash_table[page->tcp_hash_idx]; @@ -1202,7 +1203,7 @@ static void tabc_fr_main(XTThreadPtr self) static void *tabc_fr_run_thread(XTThreadPtr self) { int count; - void *mysql_thread; + void *mysql_thread __attribute__ ((unused)); myxt_wait_pbxt_plugin_slot_assigned(self); diff --git a/storage/pbxt/src/table_xt.cc b/storage/pbxt/src/table_xt.cc index 443fc3ee193..7c243d26f9b 100644 --- a/storage/pbxt/src/table_xt.cc +++ b/storage/pbxt/src/table_xt.cc @@ -1976,8 +1976,10 @@ xtPublic void xt_check_table(XTThreadPtr self, XTOpenTablePtr ot) xtLogOffset log_offset; #endif xtRecordID rec_id; +#ifdef DUMP_CHECK_TABLE xtRecordID prev_rec_id; xtXactID xn_id; +#endif xtRowID row_id; u_llong free_rec_count = 0, free_count2 = 0; u_llong delete_rec_count = 0; @@ -2104,8 +2106,10 @@ xtPublic void xt_check_table(XTThreadPtr self, XTOpenTablePtr ot) else printf(" "); #endif +#ifdef DUMP_CHECK_TABLE prev_rec_id = XT_GET_DISK_4(rec_buf->tr_prev_rec_id_4); xn_id = XT_GET_DISK_4(rec_buf->tr_xact_id_4); +#endif row_id = XT_GET_DISK_4(rec_buf->tr_row_id_4); switch (rec_buf->tr_rec_type_1 & XT_TAB_STATUS_MASK) { case XT_TAB_STATUS_FREED: diff --git a/storage/pbxt/src/thread_xt.cc b/storage/pbxt/src/thread_xt.cc index 1addf487153..9e3261bc8e0 100644 --- a/storage/pbxt/src/thread_xt.cc +++ b/storage/pbxt/src/thread_xt.cc @@ -488,8 +488,8 @@ static void thr_free_resources(XTThreadPtr self, XTResourcePtr top) xtPublic void xt_bug(XTThreadPtr XT_UNUSED(self)) { - static int *bug_ptr = NULL; - + static int *bug_ptr __attribute__ ((unused)); + bug_ptr = NULL; } @@ -1178,7 +1178,7 @@ xtPublic XTThreadPtr xt_init_threading(u_int max_threads) #ifdef XT_TRACK_CONNECTIONS if (xt_thr_maximum_threads > XT_TRACK_MAX_CONNS) { xt_log_error(XT_NS_CONTEXT, XT_LOG_FATAL, XT_ERR_TOO_MANY_THREADS, 0, - "XT_TRACK_CONNECTIONS is enabled and xt_thr_maximum_threads > XT_TRACK_MAX_CONNS"); + "XT_TRACK_CONNECTIONS (debugging aid) is enabled and xt_thr_maximum_threads > XT_TRACK_MAX_CONNS. To continue restart with a smaller value for --max-connections"); goto failed; } #endif diff --git a/storage/pbxt/src/xactlog_xt.cc b/storage/pbxt/src/xactlog_xt.cc index addc14ff5d8..69059046067 100644 --- a/storage/pbxt/src/xactlog_xt.cc +++ b/storage/pbxt/src/xactlog_xt.cc @@ -2117,7 +2117,7 @@ xtBool XTDatabaseLog::xlog_seq_next(XTXactSeqReadPtr seq, XTXactLogBufferDPtr *r size_t rec_offset; size_t max_rec_len; size_t size; - u_int check_size = 1; + u_int check_size __attribute__ ((unused))= 1; /* Go to the next record (xseq_record_len must be initialized * to 0 for this to work. @@ -2629,7 +2629,7 @@ static void *xlog_wr_run_thread(XTThreadPtr self) { XTDatabaseHPtr db = (XTDatabaseHPtr) self->t_data; int count; - void *mysql_thread; + void *mysql_thread __attribute__ ((unused)); mysql_thread = myxt_create_thread(); diff --git a/storage/perfschema/ha_perfschema.cc b/storage/perfschema/ha_perfschema.cc index 2113a28d4f8..d7771de7fb8 100644 --- a/storage/perfschema/ha_perfschema.cc +++ b/storage/perfschema/ha_perfschema.cc @@ -166,7 +166,8 @@ mysql_declare_plugin(perfschema) 0x0001 /* 0.1 */, pfs_status_vars, /* status variables */ NULL, /* system variables */ - NULL /* config options */ + NULL, /* config options */ + 0, /* flags */ } mysql_declare_plugin_end; diff --git a/storage/perfschema/pfs.cc b/storage/perfschema/pfs.cc index 139064ab212..27350c59604 100644 --- a/storage/perfschema/pfs.cc +++ b/storage/perfschema/pfs.cc @@ -1574,6 +1574,9 @@ static void unlock_rwlock_v1(PSI_rwlock *rwlock) aggregate_single_stat_chain(&pfs_rwlock->m_read_lock_stat, locked_time); } } +#else + (void) last_reader; + (void) last_writer; #endif } diff --git a/storage/perfschema/pfs_atomic.cc b/storage/perfschema/pfs_atomic.cc index 06090accdc6..3bd744c8ea7 100644 --- a/storage/perfschema/pfs_atomic.cc +++ b/storage/perfschema/pfs_atomic.cc @@ -1,4 +1,6 @@ -/* Copyright (c) 2009, 2010, Oracle and/or its affiliates. All rights reserved. +/* + Copyright (c) 2009, 2010 Sun Microsystems, Inc. + Use is subject to license terms. 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/storage/perfschema/pfs_atomic.h b/storage/perfschema/pfs_atomic.h index b0070f7b8d0..4daebfbbae4 100644 --- a/storage/perfschema/pfs_atomic.h +++ b/storage/perfschema/pfs_atomic.h @@ -1,4 +1,6 @@ -/* Copyright (c) 2009, 2010, Oracle and/or its affiliates. All rights reserved. +/* + Copyright (c) 2009, 2010 Sun Microsystems, Inc. + Use is subject to license terms. 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/storage/perfschema/pfs_column_types.h b/storage/perfschema/pfs_column_types.h index 96b33636ff9..dc990664a8f 100644 --- a/storage/perfschema/pfs_column_types.h +++ b/storage/perfschema/pfs_column_types.h @@ -1,4 +1,5 @@ -/* Copyright (c) 2008, 2010, Oracle and/or its affiliates. All rights reserved. +/* Copyright (c) 2008 MySQL AB, 2010 Sun Microsystems, Inc. + Use is subject to license terms. 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/storage/perfschema/pfs_instr.cc b/storage/perfschema/pfs_instr.cc index ed2df685a2d..f46a2862b6f 100644 --- a/storage/perfschema/pfs_instr.cc +++ b/storage/perfschema/pfs_instr.cc @@ -1,4 +1,4 @@ -/* Copyright (c) 2008, 2010 Oracle and/or its affiliates. All rights reserved. +/* Copyright (c) 2008, 2010, Oracle and/or its affiliates. All rights reserved. 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/storage/perfschema/pfs_timer.cc b/storage/perfschema/pfs_timer.cc index f30a9f8e865..302548c97c2 100644 --- a/storage/perfschema/pfs_timer.cc +++ b/storage/perfschema/pfs_timer.cc @@ -1,4 +1,5 @@ -/* Copyright (c) 2008, 2010, Oracle and/or its affiliates. All rights reserved. +/* Copyright (c) 2008 MySQL AB, 2010 Sun Microsystems, Inc. + Use is subject to license terms. 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/storage/perfschema/pfs_timer.h b/storage/perfschema/pfs_timer.h index cd2a8df9be3..6736a977ab9 100644 --- a/storage/perfschema/pfs_timer.h +++ b/storage/perfschema/pfs_timer.h @@ -1,4 +1,5 @@ -/* Copyright (c) 2008, 2010, Oracle and/or its affiliates. All rights reserved. +/* Copyright (c) 2008 MySQL AB, 2010 Sun Microsystems, Inc. + Use is subject to license terms. 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/storage/perfschema/table_ews_global_by_event_name.cc b/storage/perfschema/table_ews_global_by_event_name.cc index c983a967c4e..01d9bc5678f 100644 --- a/storage/perfschema/table_ews_global_by_event_name.cc +++ b/storage/perfschema/table_ews_global_by_event_name.cc @@ -1,4 +1,4 @@ -/* Copyright (c) 2008, 2010, Oracle and/or its affiliates. All rights reserved. +/* Copyright (c) 2010, 2010, Oracle and/or its affiliates. All rights reserved. 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/storage/perfschema/table_ews_global_by_event_name.h b/storage/perfschema/table_ews_global_by_event_name.h index 402ed9d80de..9b2b5cba5a8 100644 --- a/storage/perfschema/table_ews_global_by_event_name.h +++ b/storage/perfschema/table_ews_global_by_event_name.h @@ -1,4 +1,4 @@ -/* Copyright (c) 2008, 2010, Oracle and/or its affiliates. All rights reserved. +/* Copyright (c) 2010, 2010, Oracle and/or its affiliates. All rights reserved. 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/storage/perfschema/table_setup_consumers.h b/storage/perfschema/table_setup_consumers.h index 4d007645db2..3ef85f6914b 100644 --- a/storage/perfschema/table_setup_consumers.h +++ b/storage/perfschema/table_setup_consumers.h @@ -1,4 +1,5 @@ -/* Copyright (c) 2008, 2010, Oracle and/or its affiliates. All rights reserved. +/* Copyright (c) 2008 MySQL AB, 2010 Sun Microsystems, Inc. + Use is subject to license terms. 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/storage/perfschema/table_setup_instruments.h b/storage/perfschema/table_setup_instruments.h index b9df2dd3e0b..42b1a6122c8 100644 --- a/storage/perfschema/table_setup_instruments.h +++ b/storage/perfschema/table_setup_instruments.h @@ -1,4 +1,5 @@ -/* Copyright (c) 2008, 2010, Oracle and/or its affiliates. All rights reserved. +/* Copyright (c) 2008 MySQL AB, 2010 Sun Microsystems, Inc. + Use is subject to license terms. 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/storage/perfschema/table_setup_timers.h b/storage/perfschema/table_setup_timers.h index a81e6fefaaf..c147de63a21 100644 --- a/storage/perfschema/table_setup_timers.h +++ b/storage/perfschema/table_setup_timers.h @@ -1,4 +1,5 @@ -/* Copyright (c) 2008, 2010, Oracle and/or its affiliates. All rights reserved. +/* Copyright (c) 2008 MySQL AB, 2010 Sun Microsystems, Inc. + Use is subject to license terms. 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/storage/perfschema/unittest/CMakeLists.txt b/storage/perfschema/unittest/CMakeLists.txt index 7858fa4cc3e..a9bb1c3f4f2 100644 --- a/storage/perfschema/unittest/CMakeLists.txt +++ b/storage/perfschema/unittest/CMakeLists.txt @@ -1,4 +1,5 @@ -# Copyright (c) 2009, 2010, Oracle and/or its affiliates. All rights reserved. +# Copyright (c) 2009, 2010 Sun Microsystems, Inc. +# Use is subject to license terms. # # 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/storage/perfschema/unittest/conf.txt b/storage/perfschema/unittest/conf.txt index 8afd0b4dca7..6d262854330 100644 --- a/storage/perfschema/unittest/conf.txt +++ b/storage/perfschema/unittest/conf.txt @@ -1,4 +1,4 @@ -# Copyright (c) 2009, 2010, Oracle and/or its affiliates. All rights reserved. +# Copyright (c) 2009, 2010 Sun Microsystems, Inc. # # 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/storage/perfschema/unittest/pfs-t.cc b/storage/perfschema/unittest/pfs-t.cc index 46e02306aca..24e840f1e19 100644 --- a/storage/perfschema/unittest/pfs-t.cc +++ b/storage/perfschema/unittest/pfs-t.cc @@ -1,4 +1,4 @@ -/* Copyright (c) 2008, 2010, Oracle and/or its affiliates. All rights reserved. +/* Copyright (c) 2008, 2011, Oracle and/or its affiliates. All rights reserved. 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/storage/perfschema/unittest/pfs_instr-oom-t.cc b/storage/perfschema/unittest/pfs_instr-oom-t.cc index a00afe8b36a..38436f02508 100644 --- a/storage/perfschema/unittest/pfs_instr-oom-t.cc +++ b/storage/perfschema/unittest/pfs_instr-oom-t.cc @@ -1,4 +1,4 @@ -/* Copyright (c) 2008, 2010, Oracle and/or its affiliates. All rights reserved. +/* Copyright (c) 2008, 2011, Oracle and/or its affiliates. All rights reserved. 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/storage/perfschema/unittest/pfs_instr-t.cc b/storage/perfschema/unittest/pfs_instr-t.cc index b13135aa615..c781b030202 100644 --- a/storage/perfschema/unittest/pfs_instr-t.cc +++ b/storage/perfschema/unittest/pfs_instr-t.cc @@ -1,4 +1,4 @@ -/* Copyright (c) 2008, 2010, Oracle and/or its affiliates. All rights reserved. +/* Copyright (c) 2008, 2011, Oracle and/or its affiliates. All rights reserved. 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/storage/perfschema/unittest/pfs_instr_class-oom-t.cc b/storage/perfschema/unittest/pfs_instr_class-oom-t.cc index 95dccc420d7..042c6e8e78b 100644 --- a/storage/perfschema/unittest/pfs_instr_class-oom-t.cc +++ b/storage/perfschema/unittest/pfs_instr_class-oom-t.cc @@ -1,4 +1,4 @@ -/* Copyright (c) 2008, 2010, Oracle and/or its affiliates. All rights reserved. +/* Copyright (c) 2008, 2011, Oracle and/or its affiliates. All rights reserved. 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/storage/perfschema/unittest/pfs_instr_class-t.cc b/storage/perfschema/unittest/pfs_instr_class-t.cc index ac34f082fe8..605b3c0bf49 100644 --- a/storage/perfschema/unittest/pfs_instr_class-t.cc +++ b/storage/perfschema/unittest/pfs_instr_class-t.cc @@ -1,4 +1,4 @@ -/* Copyright (c) 2008, 2010, Oracle and/or its affiliates. All rights reserved. +/* Copyright (c) 2008, 2011, Oracle and/or its affiliates. All rights reserved. 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/storage/perfschema/unittest/pfs_timer-t.cc b/storage/perfschema/unittest/pfs_timer-t.cc index 69b554c7b31..9a1c743f642 100644 --- a/storage/perfschema/unittest/pfs_timer-t.cc +++ b/storage/perfschema/unittest/pfs_timer-t.cc @@ -1,4 +1,4 @@ -/* Copyright (c) 2008, 2010, Oracle and/or its affiliates. All rights reserved. +/* Copyright (c) 2008, 2011, Oracle and/or its affiliates. All rights reserved. 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/storage/perfschema/unittest/stub_pfs_global.h b/storage/perfschema/unittest/stub_pfs_global.h index 300d3cb6fa0..2b581f22645 100644 --- a/storage/perfschema/unittest/stub_pfs_global.h +++ b/storage/perfschema/unittest/stub_pfs_global.h @@ -1,4 +1,5 @@ -/* Copyright (c) 2008, 2010, Oracle and/or its affiliates. All rights reserved. +/* Copyright (c) 2008 MySQL AB, 2010 Sun Microsystems, Inc. + Use is subject to license terms. 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/storage/perfschema/unittest/stub_print_error.h b/storage/perfschema/unittest/stub_print_error.h index caad24e5257..adfa3a62d8c 100644 --- a/storage/perfschema/unittest/stub_print_error.h +++ b/storage/perfschema/unittest/stub_print_error.h @@ -1,4 +1,5 @@ -/* Copyright (c) 2008, 2010, Oracle and/or its affiliates. All rights reserved. +/* Copyright (c) 2008 MySQL AB, 2010 Sun Microsystems, Inc. + Use is subject to license terms. 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/storage/sphinx/ha_sphinx.cc b/storage/sphinx/ha_sphinx.cc index e90c2f3e6fb..8abff2003be 100644 --- a/storage/sphinx/ha_sphinx.cc +++ b/storage/sphinx/ha_sphinx.cc @@ -705,7 +705,7 @@ static int sphinx_done_func ( void * ) pthread_mutex_destroy ( &sphinx_mutex ); } - SPH_RET(0); + SPH_RET(error); } @@ -3077,25 +3077,6 @@ struct st_mysql_show_var sphinx_status_vars[] = {0, 0, (enum_mysql_show_type)0} }; - -mysql_declare_plugin(sphinx) -{ - MYSQL_STORAGE_ENGINE_PLUGIN, - &sphinx_storage_engine, - sphinx_hton_name, - "Sphinx developers", - sphinx_hton_comment, - PLUGIN_LICENSE_GPL, - sphinx_init_func, // Plugin Init - sphinx_done_func, // Plugin Deinit - 0x0001, // 0.1 - sphinx_status_vars, - NULL, - NULL -} -mysql_declare_plugin_end; - -#ifdef maria_declare_plugin maria_declare_plugin(sphinx) { MYSQL_STORAGE_ENGINE_PLUGIN, @@ -3113,7 +3094,6 @@ maria_declare_plugin(sphinx) MariaDB_PLUGIN_MATURITY_EXPERIMENTAL } maria_declare_plugin_end; -#endif #endif // >50100 diff --git a/storage/xtradb/btr/btr0cur.c b/storage/xtradb/btr/btr0cur.c index f6ef44e5b5c..20876e73da0 100644 --- a/storage/xtradb/btr/btr0cur.c +++ b/storage/xtradb/btr/btr0cur.c @@ -3598,7 +3598,7 @@ static void btr_record_not_null_field_in_rec( /*=============================*/ - rec_t* rec, /*!< in: physical record */ + rec_t* rec __attribute__ ((unused)),/*!< in: physical record */ ulint n_unique, /*!< in: dict_index_get_n_unique(index), number of columns uniquely determine an index entry */ @@ -3618,9 +3618,8 @@ btr_record_not_null_field_in_rec( for (i = 0; i < n_unique; i++) { ulint rec_len; - byte* field; - field = rec_get_nth_field(rec, offsets, i, &rec_len); + rec_get_nth_field_offs(offsets, i, &rec_len); if (rec_len != UNIV_SQL_NULL) { n_not_null[i]++; diff --git a/storage/xtradb/dict/dict0dict.c b/storage/xtradb/dict/dict0dict.c index 1ad540f47ab..e1b29fa02b0 100644 --- a/storage/xtradb/dict/dict0dict.c +++ b/storage/xtradb/dict/dict0dict.c @@ -484,10 +484,12 @@ Looks for column n in an index. ULINT_UNDEFINED if not contained */ UNIV_INTERN ulint -dict_index_get_nth_col_pos( -/*=======================*/ - const dict_index_t* index, /*!< in: index */ - ulint n) /*!< in: column number */ +dict_index_get_nth_col_or_prefix_pos( +/*=================================*/ + const dict_index_t* index, /*!< in: index */ + ulint n, /*!< in: column number */ + ibool inc_prefix) /*!< in: TRUE=consider + column prefixes too */ { const dict_field_t* field; const dict_col_t* col; @@ -509,7 +511,8 @@ dict_index_get_nth_col_pos( for (pos = 0; pos < n_fields; pos++) { field = dict_index_get_nth_field(index, pos); - if (col == field->col && field->prefix_len == 0) { + if (col == field->col + && (inc_prefix || field->prefix_len == 0)) { return(pos); } diff --git a/storage/xtradb/handler/ha_innodb.cc b/storage/xtradb/handler/ha_innodb.cc index 0964f4925f3..e0a4f77ddd6 100644 --- a/storage/xtradb/handler/ha_innodb.cc +++ b/storage/xtradb/handler/ha_innodb.cc @@ -122,11 +122,6 @@ static mysql_cond_t commit_cond; static mysql_mutex_t commit_cond_m; static bool innodb_inited = 0; -C_MODE_START -static xtradb_icp_result_t index_cond_func_innodb(void *arg); -C_MODE_END - - #define INSIDE_HA_INNOBASE_CC @@ -2305,14 +2300,24 @@ trx_is_strict( /**************************************************************//** Resets some fields of a prebuilt struct. The template is used in fast retrieval of just those column values MySQL needs in its processing. */ -static void -reset_template( -/*===========*/ - row_prebuilt_t* prebuilt) /*!< in/out: prebuilt struct */ +inline +ha_innobase::reset_template(void) +/*=============================*/ { + ut_ad(prebuilt->magic_n == ROW_PREBUILT_ALLOCATED); + ut_ad(prebuilt->magic_n2 == prebuilt->magic_n); + prebuilt->keep_other_fields_on_keyread = 0; prebuilt->read_just_key = 0; + /* Reset index condition pushdown state. */ + if (prebuilt->idx_cond) { + prebuilt->idx_cond = NULL; + prebuilt->idx_cond_n_cols = 0; + /* Invalidate prebuilt->mysql_template + in ha_innobase::write_row(). */ + prebuilt->template_type = ROW_MYSQL_NO_TEMPLATE; + } } /*****************************************************************//** @@ -2367,7 +2372,7 @@ ha_innobase::init_table_handle_for_HANDLER(void) we???? */ prebuilt->used_in_HANDLER = TRUE; - reset_template(prebuilt); + reset_template(); } /*********************************************************************//** @@ -4525,8 +4530,8 @@ static inline uint get_field_offset( /*=============*/ - TABLE* table, /*!< in: MySQL table object */ - Field* field) /*!< in: MySQL field object */ + const TABLE* table, /*!< in: MySQL table object */ + const Field* field) /*!< in: MySQL field object */ { return((uint) (field->ptr - table->record[0])); } @@ -5088,44 +5093,170 @@ ha_innobase::store_key_val_for_row( } /**************************************************************//** +Determines if a field is needed in a prebuilt struct 'template'. +@return field to use, or NULL if the field is not needed */ +static +const Field* +build_template_needs_field( +/*=======================*/ + ibool index_contains, /*!< in: + dict_index_contains_col_or_prefix( + index, i) */ + ibool read_just_key, /*!< in: TRUE when MySQL calls + ha_innobase::extra with the + argument HA_EXTRA_KEYREAD; it is enough + to read just columns defined in + the index (i.e., no read of the + clustered index record necessary) */ + ibool fetch_all_in_key, + /*!< in: true=fetch all fields in + the index */ + ibool fetch_primary_key_cols, + /*!< in: true=fetch the + primary key columns */ + dict_index_t* index, /*!< in: InnoDB index to use */ + const TABLE* table, /*!< in: MySQL table object */ + ulint i, /*!< in: field index in InnoDB table */ + ulint sql_idx) /*!< in: field index in SQL table */ +{ + const Field* field = table->field[sql_idx]; + + ut_ad(index_contains == dict_index_contains_col_or_prefix(index, i)); + + if (!index_contains) { + if (read_just_key) { + /* If this is a 'key read', we do not need + columns that are not in the key */ + + return(NULL); + } + } else if (fetch_all_in_key) { + /* This field is needed in the query */ + + return(field); + } + + if (bitmap_is_set(table->read_set, sql_idx) + || bitmap_is_set(table->write_set, sql_idx)) { + /* This field is needed in the query */ + + return(field); + } + + if (fetch_primary_key_cols + && dict_table_col_in_clustered_key(index->table, i)) { + /* This field is needed in the query */ + + return(field); + } + + /* This field is not needed in the query, skip it */ + + return(NULL); +} + +/**************************************************************//** +Adds a field is to a prebuilt struct 'template'. +@return the field template */ +static +mysql_row_templ_t* +build_template_field( +/*=================*/ + row_prebuilt_t* prebuilt, /*!< in/out: template */ + dict_index_t* clust_index, /*!< in: InnoDB clustered index */ + dict_index_t* index, /*!< in: InnoDB index to use */ + TABLE* table, /*!< in: MySQL table object */ + const Field* field, /*!< in: field in MySQL table */ + ulint i) /*!< in: field index in InnoDB table */ +{ + mysql_row_templ_t* templ; + const dict_col_t* col; + + //ut_ad(field == table->field[i]); + ut_ad(clust_index->table == index->table); + + col = dict_table_get_nth_col(index->table, i); + + templ = prebuilt->mysql_template + prebuilt->n_template++; + UNIV_MEM_INVALID(templ, sizeof *templ); + templ->col_no = i; + templ->clust_rec_field_no = dict_col_get_clust_pos(col, clust_index); + ut_a(templ->clust_rec_field_no != ULINT_UNDEFINED); + + if (dict_index_is_clust(index)) { + templ->rec_field_no = templ->clust_rec_field_no; + } else { + templ->rec_field_no = dict_index_get_nth_col_pos(index, i); + } + + if (field->null_ptr) { + templ->mysql_null_byte_offset = + (ulint) ((char*) field->null_ptr + - (char*) table->record[0]); + + templ->mysql_null_bit_mask = (ulint) field->null_bit; + } else { + templ->mysql_null_bit_mask = 0; + } + + templ->mysql_col_offset = (ulint) get_field_offset(table, field); + + templ->mysql_col_len = (ulint) field->pack_length(); + templ->type = col->mtype; + templ->mysql_type = (ulint)field->type(); + + if (templ->mysql_type == DATA_MYSQL_TRUE_VARCHAR) { + templ->mysql_length_bytes = (ulint) + (((Field_varstring*)field)->length_bytes); + } + + templ->charset = dtype_get_charset_coll(col->prtype); + templ->mbminlen = DATA_MBMINLEN(col->mbminmaxlen); + templ->mbmaxlen = DATA_MBMAXLEN(col->mbminmaxlen); + templ->is_unsigned = col->prtype & DATA_UNSIGNED; + + if (!dict_index_is_clust(index) + && templ->rec_field_no == ULINT_UNDEFINED) { + prebuilt->need_to_access_clustered = TRUE; + } + + if (prebuilt->mysql_prefix_len < templ->mysql_col_offset + + templ->mysql_col_len) { + prebuilt->mysql_prefix_len = templ->mysql_col_offset + + templ->mysql_col_len; + } + + if (templ->type == DATA_BLOB) { + prebuilt->templ_contains_blob = TRUE; + } + + return(templ); +} + +/**************************************************************//** Builds a 'template' to the prebuilt struct. The template is used in fast retrieval of just those column values MySQL needs in its processing. */ -static +UNIV_INTERN void -build_template( -/*===========*/ - row_prebuilt_t* prebuilt, /*!< in/out: prebuilt struct */ - THD* thd, /*!< in: current user thread, used - only if templ_type is - ROW_MYSQL_REC_FIELDS */ - TABLE* table, /* in: MySQL table */ - ha_innobase* file, /* in: ha_innobase handler */ - uint templ_type) /* in: ROW_MYSQL_WHOLE_ROW or - ROW_MYSQL_REC_FIELDS */ +ha_innobase::build_template( +/*========================*/ + bool whole_row) /*!< in: true=ROW_MYSQL_WHOLE_ROW, + false=ROW_MYSQL_REC_FIELDS */ { dict_index_t* index; dict_index_t* clust_index; - mysql_row_templ_t* templ; - Field* field; - ulint n_fields, n_stored_fields; - ulint n_requested_fields = 0; + ulint n_stored_fields; ibool fetch_all_in_key = FALSE; ibool fetch_primary_key_cols = FALSE; - ulint sql_idx, innodb_idx=0; - /* byte offset of the end of last requested column */ - ulint mysql_prefix_len = 0; - ibool do_idx_cond_push= FALSE; - ibool need_second_pass= FALSE; - + ulint i, sql_idx; + if (prebuilt->select_lock_type == LOCK_X) { /* We always retrieve the whole clustered index record if we use exclusive row level locks, for example, if the read is done in an UPDATE statement. */ - templ_type = ROW_MYSQL_WHOLE_ROW; - } - - if (templ_type == ROW_MYSQL_REC_FIELDS) { + whole_row = true; + } else if (!whole_row) { if (prebuilt->hint_need_to_fetch_extra_cols == ROW_RETRIEVE_ALL_COLS) { @@ -5142,7 +5273,7 @@ build_template( fetch_all_in_key = TRUE; } else { - templ_type = ROW_MYSQL_WHOLE_ROW; + whole_row = true; } } else if (prebuilt->hint_need_to_fetch_extra_cols == ROW_RETRIEVE_PRIMARY_KEY) { @@ -5159,21 +5290,13 @@ build_template( clust_index = dict_table_get_first_index(prebuilt->table); - if (templ_type == ROW_MYSQL_REC_FIELDS) { - index = prebuilt->index; - } else { - index = clust_index; - } + index = whole_row ? clust_index : prebuilt->index; - if (index == clust_index) { - prebuilt->need_to_access_clustered = TRUE; - } else { - prebuilt->need_to_access_clustered = FALSE; - /* Below we check column by column if we need to access - the clustered index */ - } + prebuilt->need_to_access_clustered = (index == clust_index); + + /* Below we check column by column if we need to access + the clustered index. */ - n_fields = (ulint)table->s->fields; /* number of columns */ n_stored_fields= (ulint)table->s->stored_fields; /* number of stored columns */ if (!prebuilt->mysql_template) { @@ -5181,160 +5304,206 @@ build_template( mem_alloc(n_stored_fields * sizeof(mysql_row_templ_t)); } - prebuilt->template_type = templ_type; + prebuilt->template_type = whole_row + ? ROW_MYSQL_WHOLE_ROW : ROW_MYSQL_REC_FIELDS; prebuilt->null_bitmap_len = table->s->null_bytes; + /* Prepare to build prebuilt->mysql_template[]. */ prebuilt->templ_contains_blob = FALSE; + prebuilt->mysql_prefix_len = 0; + prebuilt->n_template = 0; + prebuilt->idx_cond_n_cols = 0; + + /* Note that in InnoDB, i is the column number in the table. + MySQL calls columns 'fields'. */ + + if (active_index != MAX_KEY && active_index == pushed_idx_cond_keyno) { + /* Push down an index condition or an end_range check. */ + for (i = 0, sql_idx = 0; i < n_stored_fields; i++, sql_idx++) { + + while (!table->field[sql_idx]->stored_in_db) { + sql_idx++; + } + + const ibool index_contains + = dict_index_contains_col_or_prefix(index, i); + + /* Test if an end_range or an index condition + refers to the field. Note that "index" and + "index_contains" may refer to the clustered index. + Index condition pushdown is relative to prebuilt->index + (the index that is being looked up first). */ + + /* When join_read_always_key() invokes this + code via handler::ha_index_init() and + ha_innobase::index_init(), end_range is not + yet initialized. Because of that, we must + always check for index_contains, instead of + the subset + field->part_of_key.is_set(active_index) + which would be acceptable if end_range==NULL. */ + if (index == prebuilt->index + ? index_contains + : dict_index_contains_col_or_prefix( + prebuilt->index, i)) { + /* Needed in ICP */ + const Field* field; + mysql_row_templ_t* templ; + + if (whole_row) { + field = table->field[sql_idx]; + } else { + field = build_template_needs_field( + index_contains, + prebuilt->read_just_key, + fetch_all_in_key, + fetch_primary_key_cols, + index, table, i, sql_idx); + if (!field) { + continue; + } + } - - /* - Setup index condition pushdown (note: we don't need to check if - this is a scan on primary key as that is checked in idx_cond_push) - */ - if (file->active_index == file->pushed_idx_cond_keyno && - file->active_index != MAX_KEY && - templ_type == ROW_MYSQL_REC_FIELDS) - do_idx_cond_push= need_second_pass= TRUE; - - /* Note that in InnoDB, i is the column number. MySQL calls columns - 'fields'. */ - for (sql_idx = 0; sql_idx < n_fields; sql_idx++) { - const dict_col_t* col = &index->table->cols[innodb_idx]; - templ = prebuilt->mysql_template + n_requested_fields; - field = table->field[sql_idx]; - if (!field->stored_in_db) - goto skip_field; - - if (UNIV_LIKELY(templ_type == ROW_MYSQL_REC_FIELDS)) { - /* Decide which columns we should fetch - and which we can skip. */ - register const ibool index_contains_field = - dict_index_contains_col_or_prefix(index, innodb_idx); - register const ibool index_covers_field = - field->part_of_key.is_set(file->active_index); - - if (!index_contains_field && prebuilt->read_just_key) { - /* If this is a 'key read', we do not need - columns that are not in the key */ - - goto skip_field; - } - - if (index_contains_field && fetch_all_in_key) { - /* This field is needed in the query */ - - goto include_field; - } - - if (bitmap_is_set(table->read_set, sql_idx) || - bitmap_is_set(table->write_set, sql_idx)) { - /* This field is needed in the query */ - - goto include_field; - } + templ = build_template_field( + prebuilt, clust_index, index, + table, field, i); + prebuilt->idx_cond_n_cols++; + ut_ad(prebuilt->idx_cond_n_cols + == prebuilt->n_template); + + if (index == prebuilt->index) { + templ->icp_rec_field_no + = templ->rec_field_no; + } else { + templ->icp_rec_field_no + = dict_index_get_nth_col_pos( + prebuilt->index, i); + } - if (fetch_primary_key_cols - && dict_table_col_in_clustered_key( - index->table, innodb_idx)) { - /* This field is needed in the query */ + if (dict_index_is_clust(prebuilt->index)) { + ut_ad(templ->icp_rec_field_no + != ULINT_UNDEFINED); + /* If the primary key includes + a column prefix, use it in + index condition pushdown, + because the condition is + evaluated before fetching any + off-page (externally stored) + columns. */ + if (templ->icp_rec_field_no + < prebuilt->index->n_uniq) { + /* This is a key column; + all set. */ + continue; + } + } else if (templ->icp_rec_field_no + != ULINT_UNDEFINED) { + continue; + } - goto include_field; + /* This is a column prefix index. + The column prefix can be used in + an end_range comparison. */ + + templ->icp_rec_field_no + = dict_index_get_nth_col_or_prefix_pos( + prebuilt->index, i, TRUE); + ut_ad(templ->icp_rec_field_no + != ULINT_UNDEFINED); + + /* Index condition pushdown can be used on + all columns of a secondary index, and on + the PRIMARY KEY columns. */ + /* TODO: enable this assertion + (but first ensure that end_range is + valid here and use an accurate condition + for end_range) + ut_ad(!dict_index_is_clust(prebuilt->index) + || templ->rec_field_no + < prebuilt->index->n_uniq); + */ } - - /* This field is not needed in the query, skip it */ - - goto skip_field; -include_field: - if (do_idx_cond_push && - ((need_second_pass && !index_covers_field) || - (!need_second_pass && index_covers_field))) - goto skip_field; } - n_requested_fields++; - templ->col_no = innodb_idx; - templ->clust_rec_field_no = dict_col_get_clust_pos( - col, clust_index); - ut_ad(templ->clust_rec_field_no != ULINT_UNDEFINED); + ut_ad(prebuilt->idx_cond_n_cols > 0); + ut_ad(prebuilt->idx_cond_n_cols == prebuilt->n_template); + + /* Include the fields that are not needed in index condition + pushdown. */ + for (i = 0, sql_idx = 0; i < n_stored_fields; i++, sql_idx++) { + + while (!table->field[sql_idx]->stored_in_db) { + sql_idx++; + } + + const ibool index_contains + = dict_index_contains_col_or_prefix(index, i); + + if (index == prebuilt->index + ? !index_contains + : !dict_index_contains_col_or_prefix( + prebuilt->index, i)) { + /* Not needed in ICP */ + const Field* field; + + if (whole_row) { + field = table->field[sql_idx]; + } else { + field = build_template_needs_field( + index_contains, + prebuilt->read_just_key, + fetch_all_in_key, + fetch_primary_key_cols, + index, table, i, sql_idx); + if (!field) { + continue; + } + } - if (index == clust_index) { - templ->rec_field_no = templ->clust_rec_field_no; - } else { - templ->rec_field_no = dict_index_get_nth_col_pos( - index, innodb_idx); - if (templ->rec_field_no == ULINT_UNDEFINED) { - prebuilt->need_to_access_clustered = TRUE; + build_template_field(prebuilt, + clust_index, index, + table, field, i); } } - if (field->null_ptr) { - templ->mysql_null_byte_offset = - (ulint) ((char*) field->null_ptr - - (char*) table->record[0]); + prebuilt->idx_cond = this; + } else { + /* No index condition pushdown */ + prebuilt->idx_cond = NULL; - templ->mysql_null_bit_mask = (ulint) field->null_bit; - } else { - templ->mysql_null_bit_mask = 0; - } - - templ->mysql_col_offset = (ulint) - get_field_offset(table, field); + for (i = 0, sql_idx = 0; i < n_stored_fields; i++, sql_idx++) { + const Field* field; - templ->mysql_col_len = (ulint) field->pack_length(); - if (mysql_prefix_len < templ->mysql_col_offset - + templ->mysql_col_len) { - mysql_prefix_len = templ->mysql_col_offset - + templ->mysql_col_len; - } - templ->type = col->mtype; - templ->mysql_type = (ulint)field->type(); + while (!table->field[sql_idx]->stored_in_db) { + sql_idx++; + } - if (templ->mysql_type == DATA_MYSQL_TRUE_VARCHAR) { - templ->mysql_length_bytes = (ulint) - (((Field_varstring*)field)->length_bytes); - } + if (whole_row) { + field = table->field[sql_idx]; + } else { + field = build_template_needs_field( + dict_index_contains_col_or_prefix( + index, i), + prebuilt->read_just_key, + fetch_all_in_key, + fetch_primary_key_cols, + index, table, i, sql_idx); + if (!field) { + continue; + } + } - templ->charset = dtype_get_charset_coll(col->prtype); - templ->mbminlen = dict_col_get_mbminlen(col); - templ->mbmaxlen = dict_col_get_mbmaxlen(col); - templ->is_unsigned = col->prtype & DATA_UNSIGNED; - if (templ->type == DATA_BLOB) { - prebuilt->templ_contains_blob = TRUE; + build_template_field(prebuilt, clust_index, index, + table, field, i); } -skip_field: - if (need_second_pass && (sql_idx+1 == n_fields)) - { - prebuilt->n_index_fields= n_requested_fields; - need_second_pass= FALSE; - sql_idx= (~(ulint)0); /* to start from 0 */ - innodb_idx= (~(ulint)0); /* to start from 0 */ ///psergey-merge-merge-last-change - } - if (field->stored_in_db) { - innodb_idx++; - } - } - - prebuilt->n_template = n_requested_fields; - prebuilt->mysql_prefix_len = mysql_prefix_len; - - if (do_idx_cond_push) - { - prebuilt->idx_cond_func= index_cond_func_innodb; - prebuilt->idx_cond_func_arg= file; - } - else - { - prebuilt->idx_cond_func= NULL; - prebuilt->n_index_fields= n_requested_fields; } if (index != clust_index && prebuilt->need_to_access_clustered) { /* Change rec_field_no's to correspond to the clustered index record */ - for (ulint i = do_idx_cond_push? prebuilt->n_index_fields : 0; - i < n_requested_fields; i++) { - templ = prebuilt->mysql_template + i; - + for (i = 0; i < prebuilt->n_template; i++) { + mysql_row_templ_t* templ + = &prebuilt->mysql_template[i]; templ->rec_field_no = templ->clust_rec_field_no; } } @@ -5597,7 +5766,7 @@ no_commit: /* Build the template used in converting quickly between the two database formats */ - build_template(prebuilt, NULL, table, this, ROW_MYSQL_WHOLE_ROW); + build_template(true); } innodb_srv_conc_enter_innodb(prebuilt->trx); @@ -6298,8 +6467,7 @@ ha_innobase::index_read( necessarily prebuilt->index, but can also be the clustered index */ if (prebuilt->sql_stat_start) { - build_template(prebuilt, user_thd, table, this, - ROW_MYSQL_REC_FIELDS); + build_template(false); } if (key_ptr) { @@ -6514,7 +6682,7 @@ ha_innobase::change_active_index( the flag ROW_MYSQL_WHOLE_ROW below, but that caused unnecessary copying. Starting from MySQL-4.1 we use a more efficient flag here. */ - build_template(prebuilt, user_thd, table, this, ROW_MYSQL_REC_FIELDS); + build_template(false); DBUG_RETURN(0); } @@ -7439,7 +7607,7 @@ ha_innobase::create( if (srv_file_per_table && !mysqld_embedded - && (!create_info->options & HA_LEX_CREATE_TMP_TABLE)) { + && !(create_info->options & HA_LEX_CREATE_TMP_TABLE)) { if ((name[1] == ':') || (name[0] == '\\' && name[1] == '\\')) { @@ -8602,6 +8770,8 @@ ha_innobase::info_low( if (flag & HA_STATUS_VARIABLE) { + ulint page_size; + dict_table_stats_lock(ib_table, RW_S_LATCH); n_rows = ib_table->stat_n_rows; @@ -8644,14 +8814,19 @@ ha_innobase::info_low( prebuilt->autoinc_last_value = 0; } + page_size = dict_table_zip_size(ib_table); + if (page_size == 0) { + page_size = UNIV_PAGE_SIZE; + } + stats.records = (ha_rows)n_rows; stats.deleted = 0; - stats.data_file_length = ((ulonglong) - ib_table->stat_clustered_index_size) - * UNIV_PAGE_SIZE; - stats.index_file_length = ((ulonglong) - ib_table->stat_sum_of_other_index_sizes) - * UNIV_PAGE_SIZE; + stats.data_file_length + = ((ulonglong) ib_table->stat_clustered_index_size) + * page_size; + stats.index_file_length = + ((ulonglong) ib_table->stat_sum_of_other_index_sizes) + * page_size; dict_table_stats_unlock(ib_table, RW_S_LATCH); @@ -8901,7 +9076,7 @@ ha_innobase::check( /* Build the template; we will use a dummy template in index scans done in checking */ - build_template(prebuilt, NULL, table, this, ROW_MYSQL_WHOLE_ROW); + build_template(true); } if (prebuilt->table->ibd_file_missing) { @@ -9456,12 +9631,7 @@ ha_innobase::extra( } break; case HA_EXTRA_RESET_STATE: - reset_template(prebuilt); - /* Reset index condition pushdown state */ - pushed_idx_cond= FALSE; - pushed_idx_cond_keyno= MAX_KEY; - prebuilt->idx_cond_func= NULL; - in_range_check_pushed_down= FALSE; + reset_template(); break; case HA_EXTRA_NO_KEYREAD: prebuilt->read_just_key = 0; @@ -9507,14 +9677,8 @@ ha_innobase::reset() row_mysql_prebuilt_free_blob_heap(prebuilt); } - reset_template(prebuilt); - - /* Reset index condition pushdown state */ - pushed_idx_cond_keyno= MAX_KEY; - pushed_idx_cond= NULL; - in_range_check_pushed_down= FALSE; + reset_template(); ds_mrr.dsmrr_close(); - prebuilt->idx_cond_func= NULL; /* TODO: This should really be reset in reset_template() but for now it's safer to do it explicitly here. */ @@ -9564,7 +9728,7 @@ ha_innobase::start_stmt( prebuilt->sql_stat_start = TRUE; prebuilt->hint_need_to_fetch_extra_cols = 0; - reset_template(prebuilt); + reset_template(); if (!prebuilt->mysql_has_locked) { /* This handle is for a temporary table created inside @@ -9672,7 +9836,7 @@ ha_innobase::external_lock( prebuilt->sql_stat_start = TRUE; prebuilt->hint_need_to_fetch_extra_cols = 0; - reset_template(prebuilt); + reset_template(); if (lock_type == F_WRLCK) { @@ -9848,7 +10012,7 @@ ha_innobase::transactional_table_lock( prebuilt->sql_stat_start = TRUE; prebuilt->hint_need_to_fetch_extra_cols = 0; - reset_template(prebuilt); + reset_template(); if (lock_type == F_WRLCK) { prebuilt->select_lock_type = LOCK_X; @@ -12383,44 +12547,6 @@ static struct st_mysql_sys_var* innobase_system_variables[]= { NULL }; -mysql_declare_plugin(xtradb) -{ - MYSQL_STORAGE_ENGINE_PLUGIN, - &innobase_storage_engine, - innobase_hton_name, - plugin_author, - "Percona-XtraDB, Supports transactions, row-level locking, and foreign keys", - PLUGIN_LICENSE_GPL, - innobase_init, /* Plugin Init */ - NULL, /* Plugin Deinit */ - INNODB_VERSION_SHORT, - innodb_status_variables_export,/* status variables */ - innobase_system_variables, /* system variables */ - NULL /* reserved */ -}, -i_s_innodb_rseg, -i_s_innodb_trx, -i_s_innodb_locks, -i_s_innodb_lock_waits, -i_s_innodb_cmp, -i_s_innodb_cmp_reset, -i_s_innodb_cmpmem, -i_s_innodb_cmpmem_reset, -i_s_innodb_sys_tables, -i_s_innodb_sys_tablestats, -i_s_innodb_sys_indexes, -i_s_innodb_sys_columns, -i_s_innodb_sys_fields, -i_s_innodb_sys_foreign, -i_s_innodb_sys_foreign_cols, -i_s_innodb_sys_stats, -i_s_innodb_table_stats, -i_s_innodb_index_stats, -i_s_innodb_buffer_pool_pages, -i_s_innodb_buffer_pool_pages_index, -i_s_innodb_buffer_pool_pages_blob, -i_s_innodb_admin_command -mysql_declare_plugin_end; maria_declare_plugin(xtradb) { /* InnoDB */ MYSQL_STORAGE_ENGINE_PLUGIN, @@ -12668,39 +12794,47 @@ bool ha_innobase::is_thd_killed() * Index Condition Pushdown interface implementation */ -C_MODE_START - -/* - Index condition check function to be called from within Innobase. - See note on ICP_RESULT for return values description. -*/ - -static xtradb_icp_result_t index_cond_func_innodb(void *arg) +/*************************************************************//** +InnoDB index push-down condition check +@return ICP_NO_MATCH, ICP_MATCH, or ICP_OUT_OF_RANGE */ +extern "C" UNIV_INTERN +enum icp_result +innobase_index_cond( +/*================*/ + void* file) /*!< in/out: pointer to ha_innobase */ { - ha_innobase *h= (ha_innobase*)arg; + ha_innobase *h= (ha_innobase*) file; + if (h->is_thd_killed()) - return XTRADB_ICP_ABORTED_BY_USER; + return ICP_ABORTED_BY_USER; if (h->end_range) { if (h->compare_key2(h->end_range) > 0) - return XTRADB_ICP_OUT_OF_RANGE; /* caller should return HA_ERR_END_OF_FILE already */ + return ICP_OUT_OF_RANGE; /* caller should return HA_ERR_END_OF_FILE already */ } - return h->pushed_idx_cond->val_int()? XTRADB_ICP_MATCH : XTRADB_ICP_NO_MATCH; + return h->pushed_idx_cond->val_int()? ICP_MATCH : ICP_NO_MATCH; } -C_MODE_END - - -Item *ha_innobase::idx_cond_push(uint keyno_arg, Item* idx_cond_arg) -{ - if (keyno_arg != primary_key && prebuilt->select_lock_type != LOCK_X) - { - pushed_idx_cond_keyno= keyno_arg; - pushed_idx_cond= idx_cond_arg; - in_range_check_pushed_down= TRUE; - return NULL; /* Table handler will check the entire condition */ - } - return idx_cond_arg; /* Table handler will not make any checks */ +/** Attempt to push down an index condition. +* @param[in] keyno MySQL key number +* @param[in] idx_cond Index condition to be checked +* @return idx_cond if pushed; NULL if not pushed +*/ +UNIV_INTERN +class Item* +ha_innobase::idx_cond_push( + uint keyno, + class Item* idx_cond) +{ + DBUG_ENTER("ha_innobase::idx_cond_push"); + DBUG_ASSERT(keyno != MAX_KEY); + DBUG_ASSERT(idx_cond != NULL); + + pushed_idx_cond = idx_cond; + pushed_idx_cond_keyno = keyno; + in_range_check_pushed_down = TRUE; + /* Table handler will check the entire condition */ + DBUG_RETURN(NULL); } diff --git a/storage/xtradb/handler/ha_innodb.h b/storage/xtradb/handler/ha_innodb.h index f368d08f954..628ba536eb9 100644 --- a/storage/xtradb/handler/ha_innodb.h +++ b/storage/xtradb/handler/ha_innodb.h @@ -227,27 +227,81 @@ class ha_innobase: public handler bool check_if_incompatible_data(HA_CREATE_INFO *info, uint table_changes); bool check_if_supported_virtual_columns(void) { return TRUE; } +private: + /** Builds a 'template' to the prebuilt struct. + + The template is used in fast retrieval of just those column + values MySQL needs in its processing. + @param whole_row true if access is needed to a whole row, + false if accessing individual fields is enough */ + void build_template(bool whole_row); + /** Resets a query execution 'template'. + @see build_template() */ + inline void reset_template(); + public: - /** - * Multi Range Read interface - */ - int multi_range_read_init(RANGE_SEQ_IF *seq, void *seq_init_param, - uint n_ranges, uint mode, HANDLER_BUFFER *buf); - int multi_range_read_next(range_id_t *range_info); - ha_rows multi_range_read_info_const(uint keyno, RANGE_SEQ_IF *seq, - void *seq_init_param, - uint n_ranges, uint *bufsz, + /** @name Multi Range Read interface @{ */ + /** Initialize multi range read @see DsMrr_impl::dsmrr_init + * @param seq + * @param seq_init_param + * @param n_ranges + * @param mode + * @param buf + */ + int multi_range_read_init(RANGE_SEQ_IF* seq, + void* seq_init_param, + uint n_ranges, uint mode, + HANDLER_BUFFER *buf); + /** Process next multi range read @see DsMrr_impl::dsmrr_next + * @param range_info + */ + int multi_range_read_next(range_id_t *range_info); + /** Initialize multi range read and get information. + * @see ha_myisam::multi_range_read_info_const + * @see DsMrr_impl::dsmrr_info_const + * @param keyno + * @param seq + * @param seq_init_param + * @param n_ranges + * @param bufsz + * @param flags + * @param cost + */ + ha_rows multi_range_read_info_const(uint keyno, RANGE_SEQ_IF *seq, + void *seq_init_param, + uint n_ranges, uint *bufsz, + uint *flags, COST_VECT *cost); + /** Initialize multi range read and get information. + * @see DsMrr_impl::dsmrr_info + * @param keyno + * @param n_ranges + * @param keys + * @param key_parts + * @param bufsz + * @param flags + * @param cost + */ + ha_rows multi_range_read_info(uint keyno, uint n_ranges, uint keys, + uint key_parts, uint *bufsz, uint *flags, COST_VECT *cost); - ha_rows multi_range_read_info(uint keyno, uint n_ranges, uint keys, - uint key_parts, uint *bufsz, - uint *flags, COST_VECT *cost); - int multi_range_read_explain_info(uint mrr_mode, char *str, size_t size); - DsMrr_impl ds_mrr; + int multi_range_read_explain_info(uint mrr_mode, + char *str, size_t size); + + /** Attempt to push down an index condition. + * @param[in] keyno MySQL key number + * @param[in] idx_cond Index condition to be checked + * @return idx_cond if pushed; NULL if not pushed + */ + class Item* idx_cond_push(uint keyno, class Item* idx_cond); + + /* An helper function for index_cond_func_innodb: */ + bool is_thd_killed(); - Item *idx_cond_push(uint keyno, Item* idx_cond); +private: + /** The multi range read session object */ + DsMrr_impl ds_mrr; - /* An helper function for index_cond_func_innodb: */ - bool is_thd_killed(); + /* @} */ }; /* Some accessor functions which the InnoDB plugin needs, but which diff --git a/storage/xtradb/handler/i_s.cc b/storage/xtradb/handler/i_s.cc index f41919cb99f..12e7448316d 100644 --- a/storage/xtradb/handler/i_s.cc +++ b/storage/xtradb/handler/i_s.cc @@ -599,54 +599,6 @@ static struct st_mysql_information_schema i_s_info = MYSQL_INFORMATION_SCHEMA_INTERFACE_VERSION }; -UNIV_INTERN struct st_mysql_plugin i_s_innodb_trx = -{ - /* the plugin type (a MYSQL_XXX_PLUGIN value) */ - /* int */ - STRUCT_FLD(type, MYSQL_INFORMATION_SCHEMA_PLUGIN), - - /* pointer to type-specific plugin descriptor */ - /* void* */ - STRUCT_FLD(info, &i_s_info), - - /* plugin name */ - /* const char* */ - STRUCT_FLD(name, "INNODB_TRX"), - - /* plugin author (for SHOW PLUGINS) */ - /* const char* */ - STRUCT_FLD(author, plugin_author), - - /* general descriptive text (for SHOW PLUGINS) */ - /* const char* */ - STRUCT_FLD(descr, "InnoDB transactions"), - - /* the plugin license (PLUGIN_LICENSE_XXX) */ - /* int */ - STRUCT_FLD(license, PLUGIN_LICENSE_GPL), - - /* the function to invoke when plugin is loaded */ - /* int (*)(void*); */ - STRUCT_FLD(init, innodb_trx_init), - - /* the function to invoke when plugin is unloaded */ - /* int (*)(void*); */ - STRUCT_FLD(deinit, i_s_common_deinit), - - /* plugin version (for SHOW PLUGINS) */ - /* unsigned int */ - STRUCT_FLD(version, INNODB_VERSION_SHORT), - - /* struct st_mysql_show_var* */ - STRUCT_FLD(status_vars, NULL), - - /* struct st_mysql_sys_var** */ - STRUCT_FLD(system_vars, NULL), - - /* reserved for dependency checking */ - /* void* */ - STRUCT_FLD(__reserved1, NULL) -}; /* Fields of the dynamic table INFORMATION_SCHEMA.innodb_locks */ @@ -866,54 +818,6 @@ innodb_locks_init( DBUG_RETURN(0); } -UNIV_INTERN struct st_mysql_plugin i_s_innodb_locks = -{ - /* the plugin type (a MYSQL_XXX_PLUGIN value) */ - /* int */ - STRUCT_FLD(type, MYSQL_INFORMATION_SCHEMA_PLUGIN), - - /* pointer to type-specific plugin descriptor */ - /* void* */ - STRUCT_FLD(info, &i_s_info), - - /* plugin name */ - /* const char* */ - STRUCT_FLD(name, "INNODB_LOCKS"), - - /* plugin author (for SHOW PLUGINS) */ - /* const char* */ - STRUCT_FLD(author, plugin_author), - - /* general descriptive text (for SHOW PLUGINS) */ - /* const char* */ - STRUCT_FLD(descr, "InnoDB conflicting locks"), - - /* the plugin license (PLUGIN_LICENSE_XXX) */ - /* int */ - STRUCT_FLD(license, PLUGIN_LICENSE_GPL), - - /* the function to invoke when plugin is loaded */ - /* int (*)(void*); */ - STRUCT_FLD(init, innodb_locks_init), - - /* the function to invoke when plugin is unloaded */ - /* int (*)(void*); */ - STRUCT_FLD(deinit, i_s_common_deinit), - - /* plugin version (for SHOW PLUGINS) */ - /* unsigned int */ - STRUCT_FLD(version, INNODB_VERSION_SHORT), - - /* struct st_mysql_show_var* */ - STRUCT_FLD(status_vars, NULL), - - /* struct st_mysql_sys_var** */ - STRUCT_FLD(system_vars, NULL), - - /* reserved for dependency checking */ - /* void* */ - STRUCT_FLD(__reserved1, NULL) -}; /* Fields of the dynamic table INFORMATION_SCHEMA.innodb_lock_waits */ static ST_FIELD_INFO innodb_lock_waits_fields_info[] = @@ -1049,54 +953,6 @@ innodb_lock_waits_init( DBUG_RETURN(0); } -UNIV_INTERN struct st_mysql_plugin i_s_innodb_lock_waits = -{ - /* the plugin type (a MYSQL_XXX_PLUGIN value) */ - /* int */ - STRUCT_FLD(type, MYSQL_INFORMATION_SCHEMA_PLUGIN), - - /* pointer to type-specific plugin descriptor */ - /* void* */ - STRUCT_FLD(info, &i_s_info), - - /* plugin name */ - /* const char* */ - STRUCT_FLD(name, "INNODB_LOCK_WAITS"), - - /* plugin author (for SHOW PLUGINS) */ - /* const char* */ - STRUCT_FLD(author, plugin_author), - - /* general descriptive text (for SHOW PLUGINS) */ - /* const char* */ - STRUCT_FLD(descr, "InnoDB which lock is blocking which"), - - /* the plugin license (PLUGIN_LICENSE_XXX) */ - /* int */ - STRUCT_FLD(license, PLUGIN_LICENSE_GPL), - - /* the function to invoke when plugin is loaded */ - /* int (*)(void*); */ - STRUCT_FLD(init, innodb_lock_waits_init), - - /* the function to invoke when plugin is unloaded */ - /* int (*)(void*); */ - STRUCT_FLD(deinit, i_s_common_deinit), - - /* plugin version (for SHOW PLUGINS) */ - /* unsigned int */ - STRUCT_FLD(version, INNODB_VERSION_SHORT), - - /* struct st_mysql_show_var* */ - STRUCT_FLD(status_vars, NULL), - - /* struct st_mysql_sys_var** */ - STRUCT_FLD(system_vars, NULL), - - /* reserved for dependency checking */ - /* void* */ - STRUCT_FLD(__reserved1, NULL) -}; /*******************************************************************//** Common function to fill any of the dynamic tables: @@ -1382,104 +1238,7 @@ i_s_cmp_reset_init( DBUG_RETURN(0); } -UNIV_INTERN struct st_mysql_plugin i_s_innodb_cmp = -{ - /* the plugin type (a MYSQL_XXX_PLUGIN value) */ - /* int */ - STRUCT_FLD(type, MYSQL_INFORMATION_SCHEMA_PLUGIN), - - /* pointer to type-specific plugin descriptor */ - /* void* */ - STRUCT_FLD(info, &i_s_info), - - /* plugin name */ - /* const char* */ - STRUCT_FLD(name, "INNODB_CMP"), - - /* plugin author (for SHOW PLUGINS) */ - /* const char* */ - STRUCT_FLD(author, plugin_author), - - /* general descriptive text (for SHOW PLUGINS) */ - /* const char* */ - STRUCT_FLD(descr, "Statistics for the InnoDB compression"), - - /* the plugin license (PLUGIN_LICENSE_XXX) */ - /* int */ - STRUCT_FLD(license, PLUGIN_LICENSE_GPL), - - /* the function to invoke when plugin is loaded */ - /* int (*)(void*); */ - STRUCT_FLD(init, i_s_cmp_init), - - /* the function to invoke when plugin is unloaded */ - /* int (*)(void*); */ - STRUCT_FLD(deinit, i_s_common_deinit), - - /* plugin version (for SHOW PLUGINS) */ - /* unsigned int */ - STRUCT_FLD(version, INNODB_VERSION_SHORT), - - /* struct st_mysql_show_var* */ - STRUCT_FLD(status_vars, NULL), - /* struct st_mysql_sys_var** */ - STRUCT_FLD(system_vars, NULL), - - /* reserved for dependency checking */ - /* void* */ - STRUCT_FLD(__reserved1, NULL) -}; - -UNIV_INTERN struct st_mysql_plugin i_s_innodb_cmp_reset = -{ - /* the plugin type (a MYSQL_XXX_PLUGIN value) */ - /* int */ - STRUCT_FLD(type, MYSQL_INFORMATION_SCHEMA_PLUGIN), - - /* pointer to type-specific plugin descriptor */ - /* void* */ - STRUCT_FLD(info, &i_s_info), - - /* plugin name */ - /* const char* */ - STRUCT_FLD(name, "INNODB_CMP_RESET"), - - /* plugin author (for SHOW PLUGINS) */ - /* const char* */ - STRUCT_FLD(author, plugin_author), - - /* general descriptive text (for SHOW PLUGINS) */ - /* const char* */ - STRUCT_FLD(descr, "Statistics for the InnoDB compression;" - " reset cumulated counts"), - - /* the plugin license (PLUGIN_LICENSE_XXX) */ - /* int */ - STRUCT_FLD(license, PLUGIN_LICENSE_GPL), - - /* the function to invoke when plugin is loaded */ - /* int (*)(void*); */ - STRUCT_FLD(init, i_s_cmp_reset_init), - - /* the function to invoke when plugin is unloaded */ - /* int (*)(void*); */ - STRUCT_FLD(deinit, i_s_common_deinit), - - /* plugin version (for SHOW PLUGINS) */ - /* unsigned int */ - STRUCT_FLD(version, INNODB_VERSION_SHORT), - - /* struct st_mysql_show_var* */ - STRUCT_FLD(status_vars, NULL), - - /* struct st_mysql_sys_var** */ - STRUCT_FLD(system_vars, NULL), - - /* reserved for dependency checking */ - /* void* */ - STRUCT_FLD(__reserved1, NULL) -}; /* Fields of the dynamic table information_schema.innodb_cmpmem. */ static ST_FIELD_INFO i_s_cmpmem_fields_info[] = @@ -1675,104 +1434,7 @@ i_s_cmpmem_reset_init( DBUG_RETURN(0); } -UNIV_INTERN struct st_mysql_plugin i_s_innodb_cmpmem = -{ - /* the plugin type (a MYSQL_XXX_PLUGIN value) */ - /* int */ - STRUCT_FLD(type, MYSQL_INFORMATION_SCHEMA_PLUGIN), - - /* pointer to type-specific plugin descriptor */ - /* void* */ - STRUCT_FLD(info, &i_s_info), - - /* plugin name */ - /* const char* */ - STRUCT_FLD(name, "INNODB_CMPMEM"), - - /* plugin author (for SHOW PLUGINS) */ - /* const char* */ - STRUCT_FLD(author, plugin_author), - - /* general descriptive text (for SHOW PLUGINS) */ - /* const char* */ - STRUCT_FLD(descr, "Statistics for the InnoDB compressed buffer pool"), - - /* the plugin license (PLUGIN_LICENSE_XXX) */ - /* int */ - STRUCT_FLD(license, PLUGIN_LICENSE_GPL), - - /* the function to invoke when plugin is loaded */ - /* int (*)(void*); */ - STRUCT_FLD(init, i_s_cmpmem_init), - - /* the function to invoke when plugin is unloaded */ - /* int (*)(void*); */ - STRUCT_FLD(deinit, i_s_common_deinit), - - /* plugin version (for SHOW PLUGINS) */ - /* unsigned int */ - STRUCT_FLD(version, INNODB_VERSION_SHORT), - - /* struct st_mysql_show_var* */ - STRUCT_FLD(status_vars, NULL), - - /* struct st_mysql_sys_var** */ - STRUCT_FLD(system_vars, NULL), - - /* reserved for dependency checking */ - /* void* */ - STRUCT_FLD(__reserved1, NULL) -}; - -UNIV_INTERN struct st_mysql_plugin i_s_innodb_cmpmem_reset = -{ - /* the plugin type (a MYSQL_XXX_PLUGIN value) */ - /* int */ - STRUCT_FLD(type, MYSQL_INFORMATION_SCHEMA_PLUGIN), - - /* pointer to type-specific plugin descriptor */ - /* void* */ - STRUCT_FLD(info, &i_s_info), - /* plugin name */ - /* const char* */ - STRUCT_FLD(name, "INNODB_CMPMEM_RESET"), - - /* plugin author (for SHOW PLUGINS) */ - /* const char* */ - STRUCT_FLD(author, plugin_author), - - /* general descriptive text (for SHOW PLUGINS) */ - /* const char* */ - STRUCT_FLD(descr, "Statistics for the InnoDB compressed buffer pool;" - " reset cumulated counts"), - - /* the plugin license (PLUGIN_LICENSE_XXX) */ - /* int */ - STRUCT_FLD(license, PLUGIN_LICENSE_GPL), - - /* the function to invoke when plugin is loaded */ - /* int (*)(void*); */ - STRUCT_FLD(init, i_s_cmpmem_reset_init), - - /* the function to invoke when plugin is unloaded */ - /* int (*)(void*); */ - STRUCT_FLD(deinit, i_s_common_deinit), - - /* plugin version (for SHOW PLUGINS) */ - /* unsigned int */ - STRUCT_FLD(version, INNODB_VERSION_SHORT), - - /* struct st_mysql_show_var* */ - STRUCT_FLD(status_vars, NULL), - - /* struct st_mysql_sys_var** */ - STRUCT_FLD(system_vars, NULL), - - /* reserved for dependency checking */ - /* void* */ - STRUCT_FLD(__reserved1, NULL) -}; /*******************************************************************//** @@ -1990,54 +1652,6 @@ innodb_sys_tables_init( DBUG_RETURN(0); } -UNIV_INTERN struct st_mysql_plugin i_s_innodb_sys_tables = -{ - /* the plugin type (a MYSQL_XXX_PLUGIN value) */ - /* int */ - STRUCT_FLD(type, MYSQL_INFORMATION_SCHEMA_PLUGIN), - - /* pointer to type-specific plugin descriptor */ - /* void* */ - STRUCT_FLD(info, &i_s_info), - - /* plugin name */ - /* const char* */ - STRUCT_FLD(name, "INNODB_SYS_TABLES"), - - /* plugin author (for SHOW PLUGINS) */ - /* const char* */ - STRUCT_FLD(author, "Percona"), - - /* general descriptive text (for SHOW PLUGINS) */ - /* const char* */ - STRUCT_FLD(descr, "InnoDB SYS_TABLES"), - - /* the plugin license (PLUGIN_LICENSE_XXX) */ - /* int */ - STRUCT_FLD(license, PLUGIN_LICENSE_GPL), - - /* the function to invoke when plugin is loaded */ - /* int (*)(void*); */ - STRUCT_FLD(init, innodb_sys_tables_init), - - /* the function to invoke when plugin is unloaded */ - /* int (*)(void*); */ - STRUCT_FLD(deinit, i_s_common_deinit), - - /* plugin version (for SHOW PLUGINS) */ - /* unsigned int */ - STRUCT_FLD(version, INNODB_VERSION_SHORT), - - /* struct st_mysql_show_var* */ - STRUCT_FLD(status_vars, NULL), - - /* struct st_mysql_sys_var** */ - STRUCT_FLD(system_vars, NULL), - - /* reserved for dependency checking */ - /* void* */ - STRUCT_FLD(__reserved1, NULL) -}; /* Fields of the dynamic table INFORMATION_SCHEMA.SYS_TABLESTATS */ static ST_FIELD_INFO innodb_sys_tablestats_fields_info[] = @@ -2287,54 +1901,6 @@ innodb_sys_tablestats_init( DBUG_RETURN(0); } -UNIV_INTERN struct st_mysql_plugin i_s_innodb_sys_tablestats = -{ - /* the plugin type (a MYSQL_XXX_PLUGIN value) */ - /* int */ - STRUCT_FLD(type, MYSQL_INFORMATION_SCHEMA_PLUGIN), - - /* pointer to type-specific plugin descriptor */ - /* void* */ - STRUCT_FLD(info, &i_s_info), - - /* plugin name */ - /* const char* */ - STRUCT_FLD(name, "INNODB_SYS_TABLESTATS"), - - /* plugin author (for SHOW PLUGINS) */ - /* const char* */ - STRUCT_FLD(author, "Percona"), - - /* general descriptive text (for SHOW PLUGINS) */ - /* const char* */ - STRUCT_FLD(descr, "InnoDB SYS_TABLESTATS"), - - /* the plugin license (PLUGIN_LICENSE_XXX) */ - /* int */ - STRUCT_FLD(license, PLUGIN_LICENSE_GPL), - - /* the function to invoke when plugin is loaded */ - /* int (*)(void*); */ - STRUCT_FLD(init, innodb_sys_tablestats_init), - - /* the function to invoke when plugin is unloaded */ - /* int (*)(void*); */ - STRUCT_FLD(deinit, i_s_common_deinit), - - /* plugin version (for SHOW PLUGINS) */ - /* unsigned int */ - STRUCT_FLD(version, INNODB_VERSION_SHORT), - - /* struct st_mysql_show_var* */ - STRUCT_FLD(status_vars, NULL), - - /* struct st_mysql_sys_var** */ - STRUCT_FLD(system_vars, NULL), - - /* reserved for dependency checking */ - /* void* */ - STRUCT_FLD(__reserved1, NULL) -}; /* Fields of the dynamic table INFORMATION_SCHEMA.SYS_INDEXES */ static ST_FIELD_INFO innodb_sysindex_fields_info[] = @@ -2533,54 +2099,6 @@ innodb_sys_indexes_init( DBUG_RETURN(0); } -UNIV_INTERN struct st_mysql_plugin i_s_innodb_sys_indexes = -{ - /* the plugin type (a MYSQL_XXX_PLUGIN value) */ - /* int */ - STRUCT_FLD(type, MYSQL_INFORMATION_SCHEMA_PLUGIN), - - /* pointer to type-specific plugin descriptor */ - /* void* */ - STRUCT_FLD(info, &i_s_info), - - /* plugin name */ - /* const char* */ - STRUCT_FLD(name, "INNODB_SYS_INDEXES"), - - /* plugin author (for SHOW PLUGINS) */ - /* const char* */ - STRUCT_FLD(author, "Percona"), - - /* general descriptive text (for SHOW PLUGINS) */ - /* const char* */ - STRUCT_FLD(descr, "InnoDB SYS_INDEXES"), - - /* the plugin license (PLUGIN_LICENSE_XXX) */ - /* int */ - STRUCT_FLD(license, PLUGIN_LICENSE_GPL), - - /* the function to invoke when plugin is loaded */ - /* int (*)(void*); */ - STRUCT_FLD(init, innodb_sys_indexes_init), - - /* the function to invoke when plugin is unloaded */ - /* int (*)(void*); */ - STRUCT_FLD(deinit, i_s_common_deinit), - - /* plugin version (for SHOW PLUGINS) */ - /* unsigned int */ - STRUCT_FLD(version, INNODB_VERSION_SHORT), - - /* struct st_mysql_show_var* */ - STRUCT_FLD(status_vars, NULL), - - /* struct st_mysql_sys_var** */ - STRUCT_FLD(system_vars, NULL), - - /* reserved for dependency checking */ - /* void* */ - STRUCT_FLD(__reserved1, NULL) -}; /* Fields of the dynamic table INFORMATION_SCHEMA.SYS_COLUMNS */ static ST_FIELD_INFO innodb_sys_columns_fields_info[] = @@ -2769,54 +2287,6 @@ innodb_sys_columns_init( DBUG_RETURN(0); } -UNIV_INTERN struct st_mysql_plugin i_s_innodb_sys_columns = -{ - /* the plugin type (a MYSQL_XXX_PLUGIN value) */ - /* int */ - STRUCT_FLD(type, MYSQL_INFORMATION_SCHEMA_PLUGIN), - - /* pointer to type-specific plugin descriptor */ - /* void* */ - STRUCT_FLD(info, &i_s_info), - - /* plugin name */ - /* const char* */ - STRUCT_FLD(name, "INNODB_SYS_COLUMNS"), - - /* plugin author (for SHOW PLUGINS) */ - /* const char* */ - STRUCT_FLD(author, "Percona"), - - /* general descriptive text (for SHOW PLUGINS) */ - /* const char* */ - STRUCT_FLD(descr, "InnoDB SYS_COLUMNS"), - - /* the plugin license (PLUGIN_LICENSE_XXX) */ - /* int */ - STRUCT_FLD(license, PLUGIN_LICENSE_GPL), - - /* the function to invoke when plugin is loaded */ - /* int (*)(void*); */ - STRUCT_FLD(init, innodb_sys_columns_init), - - /* the function to invoke when plugin is unloaded */ - /* int (*)(void*); */ - STRUCT_FLD(deinit, i_s_common_deinit), - - /* plugin version (for SHOW PLUGINS) */ - /* unsigned int */ - STRUCT_FLD(version, INNODB_VERSION_SHORT), - - /* struct st_mysql_show_var* */ - STRUCT_FLD(status_vars, NULL), - - /* struct st_mysql_sys_var** */ - STRUCT_FLD(system_vars, NULL), - - /* reserved for dependency checking */ - /* void* */ - STRUCT_FLD(__reserved1, NULL) -}; /* Fields of the dynamic table INFORMATION_SCHEMA.innodb_sys_fields */ static ST_FIELD_INFO innodb_sys_fields_fields_info[] = { @@ -2976,54 +2446,6 @@ innodb_sys_fields_init( DBUG_RETURN(0); } -UNIV_INTERN struct st_mysql_plugin i_s_innodb_sys_fields = -{ - /* the plugin type (a MYSQL_XXX_PLUGIN value) */ - /* int */ - STRUCT_FLD(type, MYSQL_INFORMATION_SCHEMA_PLUGIN), - - /* pointer to type-specific plugin descriptor */ - /* void* */ - STRUCT_FLD(info, &i_s_info), - - /* plugin name */ - /* const char* */ - STRUCT_FLD(name, "INNODB_SYS_FIELDS"), - - /* plugin author (for SHOW PLUGINS) */ - /* const char* */ - STRUCT_FLD(author, "Percona"), - - /* general descriptive text (for SHOW PLUGINS) */ - /* const char* */ - STRUCT_FLD(descr, "InnoDB SYS_FIELDS"), - - /* the plugin license (PLUGIN_LICENSE_XXX) */ - /* int */ - STRUCT_FLD(license, PLUGIN_LICENSE_GPL), - - /* the function to invoke when plugin is loaded */ - /* int (*)(void*); */ - STRUCT_FLD(init, innodb_sys_fields_init), - - /* the function to invoke when plugin is unloaded */ - /* int (*)(void*); */ - STRUCT_FLD(deinit, i_s_common_deinit), - - /* plugin version (for SHOW PLUGINS) */ - /* unsigned int */ - STRUCT_FLD(version, INNODB_VERSION_SHORT), - - /* struct st_mysql_show_var* */ - STRUCT_FLD(status_vars, NULL), - - /* struct st_mysql_sys_var** */ - STRUCT_FLD(system_vars, NULL), - - /* reserved for dependency checking */ - /* void* */ - STRUCT_FLD(__reserved1, NULL) -}; /* Fields of the dynamic table INFORMATION_SCHEMA.innodb_sys_foreign */ static ST_FIELD_INFO innodb_sys_foreign_fields_info[] = @@ -3197,54 +2619,6 @@ innodb_sys_foreign_init( DBUG_RETURN(0); } -UNIV_INTERN struct st_mysql_plugin i_s_innodb_sys_foreign = -{ - /* the plugin type (a MYSQL_XXX_PLUGIN value) */ - /* int */ - STRUCT_FLD(type, MYSQL_INFORMATION_SCHEMA_PLUGIN), - - /* pointer to type-specific plugin descriptor */ - /* void* */ - STRUCT_FLD(info, &i_s_info), - - /* plugin name */ - /* const char* */ - STRUCT_FLD(name, "INNODB_SYS_FOREIGN"), - - /* plugin author (for SHOW PLUGINS) */ - /* const char* */ - STRUCT_FLD(author, "Percona"), - - /* general descriptive text (for SHOW PLUGINS) */ - /* const char* */ - STRUCT_FLD(descr, "InnoDB SYS_FOREIGN"), - - /* the plugin license (PLUGIN_LICENSE_XXX) */ - /* int */ - STRUCT_FLD(license, PLUGIN_LICENSE_GPL), - - /* the function to invoke when plugin is loaded */ - /* int (*)(void*); */ - STRUCT_FLD(init, innodb_sys_foreign_init), - - /* the function to invoke when plugin is unloaded */ - /* int (*)(void*); */ - STRUCT_FLD(deinit, i_s_common_deinit), - - /* plugin version (for SHOW PLUGINS) */ - /* unsigned int */ - STRUCT_FLD(version, INNODB_VERSION_SHORT), - - /* struct st_mysql_show_var* */ - STRUCT_FLD(status_vars, NULL), - - /* struct st_mysql_sys_var** */ - STRUCT_FLD(system_vars, NULL), - - /* reserved for dependency checking */ - /* void* */ - STRUCT_FLD(__reserved1, NULL) -}; /* Fields of the dynamic table INFORMATION_SCHEMA.innodb_sys_foreign_cols */ static ST_FIELD_INFO innodb_sys_foreign_cols_fields_info[] = { @@ -3411,54 +2785,6 @@ innodb_sys_foreign_cols_init( DBUG_RETURN(0); } -UNIV_INTERN struct st_mysql_plugin i_s_innodb_sys_foreign_cols = -{ - /* the plugin type (a MYSQL_XXX_PLUGIN value) */ - /* int */ - STRUCT_FLD(type, MYSQL_INFORMATION_SCHEMA_PLUGIN), - - /* pointer to type-specific plugin descriptor */ - /* void* */ - STRUCT_FLD(info, &i_s_info), - - /* plugin name */ - /* const char* */ - STRUCT_FLD(name, "INNODB_SYS_FOREIGN_COLS"), - - /* plugin author (for SHOW PLUGINS) */ - /* const char* */ - STRUCT_FLD(author, "Percona"), - - /* general descriptive text (for SHOW PLUGINS) */ - /* const char* */ - STRUCT_FLD(descr, "InnoDB SYS_FOREIGN_COLS"), - - /* the plugin license (PLUGIN_LICENSE_XXX) */ - /* int */ - STRUCT_FLD(license, PLUGIN_LICENSE_GPL), - - /* the function to invoke when plugin is loaded */ - /* int (*)(void*); */ - STRUCT_FLD(init, innodb_sys_foreign_cols_init), - - /* the function to invoke when plugin is unloaded */ - /* int (*)(void*); */ - STRUCT_FLD(deinit, i_s_common_deinit), - - /* plugin version (for SHOW PLUGINS) */ - /* unsigned int */ - STRUCT_FLD(version, INNODB_VERSION_SHORT), - - /* struct st_mysql_show_var* */ - STRUCT_FLD(status_vars, NULL), - - /* struct st_mysql_sys_var** */ - STRUCT_FLD(system_vars, NULL), - - /* reserved for dependency checking */ - /* void* */ - STRUCT_FLD(__reserved1, NULL) -}; /* Fields of the dynamic table INFORMATION_SCHEMA.innodb_sys_stats */ static ST_FIELD_INFO innodb_sys_stats_fields_info[] = @@ -3626,54 +2952,6 @@ innodb_sys_stats_init( DBUG_RETURN(0); } -UNIV_INTERN struct st_mysql_plugin i_s_innodb_sys_stats = -{ - /* the plugin type (a MYSQL_XXX_PLUGIN value) */ - /* int */ - STRUCT_FLD(type, MYSQL_INFORMATION_SCHEMA_PLUGIN), - - /* pointer to type-specific plugin descriptor */ - /* void* */ - STRUCT_FLD(info, &i_s_info), - - /* plugin name */ - /* const char* */ - STRUCT_FLD(name, "INNODB_SYS_STATS"), - - /* plugin author (for SHOW PLUGINS) */ - /* const char* */ - STRUCT_FLD(author, "Percona"), - - /* general descriptive text (for SHOW PLUGINS) */ - /* const char* */ - STRUCT_FLD(descr, "XtraDB SYS_STATS table"), - - /* the plugin license (PLUGIN_LICENSE_XXX) */ - /* int */ - STRUCT_FLD(license, PLUGIN_LICENSE_GPL), - - /* the function to invoke when plugin is loaded */ - /* int (*)(void*); */ - STRUCT_FLD(init, innodb_sys_stats_init), - - /* the function to invoke when plugin is unloaded */ - /* int (*)(void*); */ - STRUCT_FLD(deinit, i_s_common_deinit), - - /* plugin version (for SHOW PLUGINS) */ - /* unsigned int */ - STRUCT_FLD(version, INNODB_VERSION_SHORT), - - /* struct st_mysql_show_var* */ - STRUCT_FLD(status_vars, NULL), - - /* struct st_mysql_sys_var** */ - STRUCT_FLD(system_vars, NULL), - - /* reserved for dependency checking */ - /* void* */ - STRUCT_FLD(__reserved1, NULL) -}; /*********************************************************************** */ @@ -3789,54 +3067,6 @@ i_s_innodb_rseg_init( DBUG_RETURN(0); } -UNIV_INTERN struct st_mysql_plugin i_s_innodb_rseg = -{ - /* the plugin type (a MYSQL_XXX_PLUGIN value) */ - /* int */ - STRUCT_FLD(type, MYSQL_INFORMATION_SCHEMA_PLUGIN), - - /* pointer to type-specific plugin descriptor */ - /* void* */ - STRUCT_FLD(info, &i_s_info), - - /* plugin name */ - /* const char* */ - STRUCT_FLD(name, "INNODB_RSEG"), - - /* plugin author (for SHOW PLUGINS) */ - /* const char* */ - STRUCT_FLD(author, "Percona"), - - /* general descriptive text (for SHOW PLUGINS) */ - /* const char* */ - STRUCT_FLD(descr, "InnoDB rollback segment information"), - - /* the plugin license (PLUGIN_LICENSE_XXX) */ - /* int */ - STRUCT_FLD(license, PLUGIN_LICENSE_GPL), - - /* the function to invoke when plugin is loaded */ - /* int (*)(void*); */ - STRUCT_FLD(init, i_s_innodb_rseg_init), - - /* the function to invoke when plugin is unloaded */ - /* int (*)(void*); */ - STRUCT_FLD(deinit, i_s_common_deinit), - - /* plugin version (for SHOW PLUGINS) */ - /* unsigned int */ - STRUCT_FLD(version, 0x0100 /* 1.0 */), - - /* struct st_mysql_show_var* */ - STRUCT_FLD(status_vars, NULL), - - /* struct st_mysql_sys_var** */ - STRUCT_FLD(system_vars, NULL), - - /* reserved for dependency checking */ - /* void* */ - STRUCT_FLD(__reserved1, NULL) -}; /*********************************************************************** */ @@ -4150,37 +3380,7 @@ i_s_innodb_index_stats_init( DBUG_RETURN(0); } -UNIV_INTERN struct st_mysql_plugin i_s_innodb_table_stats = -{ - STRUCT_FLD(type, MYSQL_INFORMATION_SCHEMA_PLUGIN), - STRUCT_FLD(info, &i_s_info), - STRUCT_FLD(name, "INNODB_TABLE_STATS"), - STRUCT_FLD(author, "Percona"), - STRUCT_FLD(descr, "InnoDB table statistics in memory"), - STRUCT_FLD(license, PLUGIN_LICENSE_GPL), - STRUCT_FLD(init, i_s_innodb_table_stats_init), - STRUCT_FLD(deinit, i_s_common_deinit), - STRUCT_FLD(version, 0x0100 /* 1.0 */), - STRUCT_FLD(status_vars, NULL), - STRUCT_FLD(system_vars, NULL), - STRUCT_FLD(__reserved1, NULL) -}; -UNIV_INTERN struct st_mysql_plugin i_s_innodb_index_stats = -{ - STRUCT_FLD(type, MYSQL_INFORMATION_SCHEMA_PLUGIN), - STRUCT_FLD(info, &i_s_info), - STRUCT_FLD(name, "INNODB_INDEX_STATS"), - STRUCT_FLD(author, "Percona"), - STRUCT_FLD(descr, "InnoDB index statistics in memory"), - STRUCT_FLD(license, PLUGIN_LICENSE_GPL), - STRUCT_FLD(init, i_s_innodb_index_stats_init), - STRUCT_FLD(deinit, i_s_common_deinit), - STRUCT_FLD(version, 0x0100 /* 1.0 */), - STRUCT_FLD(status_vars, NULL), - STRUCT_FLD(system_vars, NULL), - STRUCT_FLD(__reserved1, NULL) -}; /*********************************************************************** */ @@ -4332,21 +3532,6 @@ i_s_innodb_admin_command_init( DBUG_RETURN(0); } -UNIV_INTERN struct st_mysql_plugin i_s_innodb_admin_command = -{ - STRUCT_FLD(type, MYSQL_INFORMATION_SCHEMA_PLUGIN), - STRUCT_FLD(info, &i_s_info), - STRUCT_FLD(name, "XTRADB_ADMIN_COMMAND"), - STRUCT_FLD(author, "Percona"), - STRUCT_FLD(descr, "XtraDB specific command acceptor"), - STRUCT_FLD(license, PLUGIN_LICENSE_GPL), - STRUCT_FLD(init, i_s_innodb_admin_command_init), - STRUCT_FLD(deinit, i_s_common_deinit), - STRUCT_FLD(version, 0x0100 /* 1.0 */), - STRUCT_FLD(status_vars, NULL), - STRUCT_FLD(system_vars, NULL), - STRUCT_FLD(__reserved1, NULL) -}; /*********************************************************************** */ @@ -4897,154 +4082,6 @@ i_s_innodb_buffer_pool_pages_blob_init( DBUG_RETURN(0); } - -UNIV_INTERN struct st_mysql_plugin i_s_innodb_buffer_pool_pages = -{ - /* the plugin type (a MYSQL_XXX_PLUGIN value) */ - /* int */ - STRUCT_FLD(type, MYSQL_INFORMATION_SCHEMA_PLUGIN), - - /* pointer to type-specific plugin descriptor */ - /* void* */ - STRUCT_FLD(info, &i_s_info), - - /* plugin name */ - /* const char* */ - STRUCT_FLD(name, "INNODB_BUFFER_POOL_PAGES"), - - /* plugin author (for SHOW PLUGINS) */ - /* const char* */ - STRUCT_FLD(author, "Percona"), - - /* general descriptive text (for SHOW PLUGINS) */ - /* const char* */ - STRUCT_FLD(descr, "InnoDB buffer pool pages"), - - /* the plugin license (PLUGIN_LICENSE_XXX) */ - /* int */ - STRUCT_FLD(license, PLUGIN_LICENSE_GPL), - - /* the function to invoke when plugin is loaded */ - /* int (*)(void*); */ - STRUCT_FLD(init, i_s_innodb_buffer_pool_pages_init), - - /* the function to invoke when plugin is unloaded */ - /* int (*)(void*); */ - STRUCT_FLD(deinit, i_s_common_deinit), - - /* plugin version (for SHOW PLUGINS) */ - /* unsigned int */ - STRUCT_FLD(version, 0x0100 /* 1.0 */), - - /* struct st_mysql_show_var* */ - STRUCT_FLD(status_vars, NULL), - - /* struct st_mysql_sys_var** */ - STRUCT_FLD(system_vars, NULL), - - /* reserved for dependency checking */ - /* void* */ - STRUCT_FLD(__reserved1, NULL) -}; - -UNIV_INTERN struct st_mysql_plugin i_s_innodb_buffer_pool_pages_index = -{ - /* the plugin type (a MYSQL_XXX_PLUGIN value) */ - /* int */ - STRUCT_FLD(type, MYSQL_INFORMATION_SCHEMA_PLUGIN), - - /* pointer to type-specific plugin descriptor */ - /* void* */ - STRUCT_FLD(info, &i_s_info), - - /* plugin name */ - /* const char* */ - STRUCT_FLD(name, "INNODB_BUFFER_POOL_PAGES_INDEX"), - - /* plugin author (for SHOW PLUGINS) */ - /* const char* */ - STRUCT_FLD(author, "Percona"), - - /* general descriptive text (for SHOW PLUGINS) */ - /* const char* */ - STRUCT_FLD(descr, "InnoDB buffer pool index pages"), - - /* the plugin license (PLUGIN_LICENSE_XXX) */ - /* int */ - STRUCT_FLD(license, PLUGIN_LICENSE_GPL), - - /* the function to invoke when plugin is loaded */ - /* int (*)(void*); */ - STRUCT_FLD(init, i_s_innodb_buffer_pool_pages_index_init), - - /* the function to invoke when plugin is unloaded */ - /* int (*)(void*); */ - STRUCT_FLD(deinit, i_s_common_deinit), - - /* plugin version (for SHOW PLUGINS) */ - /* unsigned int */ - STRUCT_FLD(version, 0x0100 /* 1.0 */), - - /* struct st_mysql_show_var* */ - STRUCT_FLD(status_vars, NULL), - - /* struct st_mysql_sys_var** */ - STRUCT_FLD(system_vars, NULL), - - /* reserved for dependency checking */ - /* void* */ - STRUCT_FLD(__reserved1, NULL) -}; - -UNIV_INTERN struct st_mysql_plugin i_s_innodb_buffer_pool_pages_blob = -{ - /* the plugin type (a MYSQL_XXX_PLUGIN value) */ - /* int */ - STRUCT_FLD(type, MYSQL_INFORMATION_SCHEMA_PLUGIN), - - /* pointer to type-specific plugin descriptor */ - /* void* */ - STRUCT_FLD(info, &i_s_info), - - /* plugin name */ - /* const char* */ - STRUCT_FLD(name, "INNODB_BUFFER_POOL_PAGES_BLOB"), - - /* plugin author (for SHOW PLUGINS) */ - /* const char* */ - STRUCT_FLD(author, "Percona"), - - /* general descriptive text (for SHOW PLUGINS) */ - /* const char* */ - STRUCT_FLD(descr, "InnoDB buffer pool blob pages"), - - /* the plugin license (PLUGIN_LICENSE_XXX) */ - /* int */ - STRUCT_FLD(license, PLUGIN_LICENSE_GPL), - - /* the function to invoke when plugin is loaded */ - /* int (*)(void*); */ - STRUCT_FLD(init, i_s_innodb_buffer_pool_pages_blob_init), - - /* the function to invoke when plugin is unloaded */ - /* int (*)(void*); */ - STRUCT_FLD(deinit, i_s_common_deinit), - - /* plugin version (for SHOW PLUGINS) */ - /* unsigned int */ - STRUCT_FLD(version, 0x0100 /* 1.0 */), - - /* struct st_mysql_show_var* */ - STRUCT_FLD(status_vars, NULL), - - /* struct st_mysql_sys_var** */ - STRUCT_FLD(system_vars, NULL), - - /* reserved for dependency checking */ - /* void* */ - STRUCT_FLD(__reserved1, NULL) -}; - /* MariaDB structures of I_S plugins above */ UNIV_INTERN struct st_maria_plugin i_s_innodb_trx_maria = diff --git a/storage/xtradb/include/dict0dict.h b/storage/xtradb/include/dict0dict.h index d99177e0330..28d4413b568 100644 --- a/storage/xtradb/include/dict0dict.h +++ b/storage/xtradb/include/dict0dict.h @@ -884,13 +884,25 @@ dict_index_get_nth_col_no( Looks for column n in an index. @return position in internal representation of the index; ULINT_UNDEFINED if not contained */ -UNIV_INTERN +UNIV_INLINE ulint dict_index_get_nth_col_pos( /*=======================*/ const dict_index_t* index, /*!< in: index */ ulint n); /*!< in: column number */ /********************************************************************//** +Looks for column n in an index. +@return position in internal representation of the index; +ULINT_UNDEFINED if not contained */ +UNIV_INTERN +ulint +dict_index_get_nth_col_or_prefix_pos( +/*=================================*/ + const dict_index_t* index, /*!< in: index */ + ulint n, /*!< in: column number */ + ibool inc_prefix); /*!< in: TRUE=consider + column prefixes too */ +/********************************************************************//** Returns TRUE if the index contains a column or a prefix of that column. @return TRUE if contains the column or its prefix */ UNIV_INTERN diff --git a/storage/xtradb/include/dict0dict.ic b/storage/xtradb/include/dict0dict.ic index b03f5117295..4ec82220ffb 100644 --- a/storage/xtradb/include/dict0dict.ic +++ b/storage/xtradb/include/dict0dict.ic @@ -694,6 +694,20 @@ dict_index_get_nth_col_no( return(dict_col_get_no(dict_index_get_nth_col(index, pos))); } +/********************************************************************//** +Looks for column n in an index. +@return position in internal representation of the index; +ULINT_UNDEFINED if not contained */ +UNIV_INLINE +ulint +dict_index_get_nth_col_pos( +/*=======================*/ + const dict_index_t* index, /*!< in: index */ + ulint n) /*!< in: column number */ +{ + return(dict_index_get_nth_col_or_prefix_pos(index, n, FALSE)); +} + #ifndef UNIV_HOTBACKUP /********************************************************************//** Returns the minimum data size of an index record. diff --git a/storage/xtradb/include/ha_prototypes.h b/storage/xtradb/include/ha_prototypes.h index 02e7712df58..61ec644796b 100644 --- a/storage/xtradb/include/ha_prototypes.h +++ b/storage/xtradb/include/ha_prototypes.h @@ -256,6 +256,15 @@ innobase_get_at_most_n_mbchars( ulint data_len, /*!< in: length of the string in bytes */ const char* str); /*!< in: character string */ +/*************************************************************//** +InnoDB index push-down condition check +@return ICP_NO_MATCH, ICP_MATCH, or ICP_OUT_OF_RANGE */ +UNIV_INTERN +enum icp_result +innobase_index_cond( +/*================*/ + void* file) /*!< in/out: pointer to ha_innobase */ + __attribute__((nonnull, warn_unused_result)); /******************************************************************//** Returns true if the thread supports XA, global value of innodb_supports_xa if thd is NULL. diff --git a/storage/xtradb/include/row0mysql.h b/storage/xtradb/include/row0mysql.h index a75aea1d046..69e59ae120f 100644 --- a/storage/xtradb/include/row0mysql.h +++ b/storage/xtradb/include/row0mysql.h @@ -558,6 +558,10 @@ struct mysql_row_templ_struct { Innobase record in the clustered index; not defined if template_type is ROW_MYSQL_WHOLE_ROW */ + ulint icp_rec_field_no; /*!< field number of the column in an + Innobase record in the current index; + not defined unless + index condition pushdown is used */ ulint mysql_col_offset; /*!< offset of the column in the MySQL row format */ ulint mysql_col_len; /*!< length of the column in the MySQL @@ -596,16 +600,6 @@ struct mysql_row_templ_struct { #define ROW_PREBUILT_ALLOCATED 78540783 #define ROW_PREBUILT_FREED 26423527 - -typedef enum xtradb_icp_result { - XTRADB_ICP_ERROR=-1, - XTRADB_ICP_NO_MATCH=0, - XTRADB_ICP_MATCH=1, - XTRADB_ICP_OUT_OF_RANGE=2, - XTRADB_ICP_ABORTED_BY_USER=3, -} xtradb_icp_result_t; - -typedef xtradb_icp_result_t (*idx_cond_func_t)(void *param); /** A struct for (sometimes lazily) prebuilt structures in an Innobase table handle used within MySQL; these are used to save CPU time. */ @@ -803,16 +797,15 @@ struct row_prebuilt_struct { store it here so that we can return it to MySQL */ /*----------------------*/ + void* idx_cond; /*!< In ICP, pointer to a ha_innobase, + passed to innobase_index_cond(). + NULL if index condition pushdown is + not used. */ + ulint idx_cond_n_cols;/*!< Number of fields in idx_cond_cols. + 0 if and only if idx_cond == NULL. */ + /*----------------------*/ ulint magic_n2; /*!< this should be the same as magic_n */ - /*----------------------*/ - idx_cond_func_t idx_cond_func; /* Index Condition Pushdown function, - or NULL if there is none set */ - void* idx_cond_func_arg;/* ICP function argument */ - ulint n_index_fields; /* Number of fields at the start of - mysql_template. Valid only when using - ICP. */ - /*----------------------*/ }; #define ROW_PREBUILT_FETCH_MAGIC_N 465765687 diff --git a/storage/xtradb/os/os0file.c b/storage/xtradb/os/os0file.c index ee8ee34ea49..8fe8bab5d9a 100644 --- a/storage/xtradb/os/os0file.c +++ b/storage/xtradb/os/os0file.c @@ -3915,7 +3915,7 @@ os_aio_simulated_wake_handler_thread( { os_aio_array_t* array; os_aio_slot_t* slot; - ulint segment; + ulint segment __attribute__ ((unused)); ulint n; ulint i; @@ -4655,7 +4655,7 @@ os_aio_simulated_handle( ulint* space_id) { os_aio_array_t* array; - ulint segment; + ulint segment __attribute__ ((unused)); os_aio_slot_t* slot; os_aio_slot_t* slot2; os_aio_slot_t* consecutive_ios[OS_AIO_MERGE_N_CONSECUTIVE]; diff --git a/storage/xtradb/row/row0sel.c b/storage/xtradb/row/row0sel.c index 1d91b1f4b53..ef5e30ea16d 100644 --- a/storage/xtradb/row/row0sel.c +++ b/storage/xtradb/row/row0sel.c @@ -58,6 +58,8 @@ Created 12/19/1997 Heikki Tuuri #include "buf0lru.h" #include "ha_prototypes.h" +#include "my_compare.h" /* enum icp_result */ + /* Maximum number of rows to prefetch; MySQL interface has another parameter */ #define SEL_MAX_N_PREFETCH 16 @@ -2667,144 +2669,96 @@ row_sel_field_store_in_mysql_format( } /**************************************************************//** -Convert a row in the Innobase format to a row in the MySQL format. -Note that the template in prebuilt may advise us to copy only a few -columns to mysql_rec, other columns are left blank. All columns may not -be needed in the query. -@return TRUE on success, FALSE if not all columns could be retrieved */ +Convert a field in the Innobase format to a field in the MySQL format. */ static __attribute__((warn_unused_result)) ibool -row_sel_store_mysql_rec( -/*====================*/ - byte* mysql_rec, /*!< out: row in the MySQL format */ - row_prebuilt_t* prebuilt, /*!< in: prebuilt struct */ - const rec_t* rec, /*!< in: Innobase record in the index - which was described in prebuilt's - template, or in the clustered index; - must be protected by a page latch */ - ibool rec_clust, /*!< in: TRUE if rec is in the - clustered index instead of - prebuilt->index */ - const ulint* offsets, /*!< in: array returned by - rec_get_offsets(rec) */ - ulint start_field_no, /* in: start from this field */ - ulint end_field_no) /* in: end at this field */ +row_sel_store_mysql_field( +/*======================*/ + byte* mysql_rec, /*!< out: record in the + MySQL format */ + row_prebuilt_t* prebuilt, /*!< in/out: prebuilt struct */ + const rec_t* rec, /*!< in: InnoDB record; + must be protected by + a page latch */ + const ulint* offsets, /*!< in: array returned by + rec_get_offsets() */ + ulint field_no, /*!< in: templ->rec_field_no or + templ->clust_rec_field_no */ + const mysql_row_templ_t*templ) /*!< in: row template */ { - mem_heap_t* extern_field_heap = NULL; - mem_heap_t* heap; - ulint i; + const byte* data; + ulint len; - ut_ad(prebuilt->mysql_template); ut_ad(prebuilt->default_rec); + ut_ad(templ); + ut_ad(templ >= prebuilt->mysql_template); + ut_ad(templ < &prebuilt->mysql_template[prebuilt->n_template]); + ut_ad(field_no == templ->clust_rec_field_no + || field_no == templ->rec_field_no + || field_no == templ->icp_rec_field_no); ut_ad(rec_offs_validate(rec, NULL, offsets)); - ut_ad(!rec_get_deleted_flag(rec, rec_offs_comp(offsets))); - - if (UNIV_LIKELY_NULL(prebuilt->blob_heap)) { - mem_heap_free(prebuilt->blob_heap); - prebuilt->blob_heap = NULL; - } - for (i = start_field_no; i < end_field_no /* prebuilt->n_template */ ; i++) { + if (UNIV_UNLIKELY(rec_offs_nth_extern(offsets, field_no))) { - const mysql_row_templ_t*templ = prebuilt->mysql_template + i; - const byte* data; - ulint len; - ulint field_no; - - field_no = rec_clust - ? templ->clust_rec_field_no : templ->rec_field_no; + mem_heap_t* heap; + /* Copy an externally stored field to a temporary heap */ - if (UNIV_UNLIKELY(rec_offs_nth_extern(offsets, field_no))) { + ut_a(!prebuilt->trx->has_search_latch); + ut_ad(field_no == templ->clust_rec_field_no); - /* Copy an externally stored field to the temporary - heap */ + if (UNIV_UNLIKELY(templ->type == DATA_BLOB)) { + if (prebuilt->blob_heap == NULL) { + prebuilt->blob_heap = mem_heap_create( + UNIV_PAGE_SIZE); + } - ut_a(!prebuilt->trx->has_search_latch); + heap = prebuilt->blob_heap; + } else { + heap = mem_heap_create(UNIV_PAGE_SIZE); + } - if (UNIV_UNLIKELY(templ->type == DATA_BLOB)) { - if (prebuilt->blob_heap == NULL) { - prebuilt->blob_heap = mem_heap_create( - UNIV_PAGE_SIZE); - } + /* NOTE: if we are retrieving a big BLOB, we may + already run out of memory in the next call, which + causes an assert */ - heap = prebuilt->blob_heap; - } else { - extern_field_heap - = mem_heap_create(UNIV_PAGE_SIZE); + data = btr_rec_copy_externally_stored_field( + rec, offsets, + dict_table_zip_size(prebuilt->table), + field_no, &len, heap); - heap = extern_field_heap; - } + if (UNIV_UNLIKELY(!data)) { + /* The externally stored field was not written + yet. This record should only be seen by + recv_recovery_rollback_active() or any + TRX_ISO_READ_UNCOMMITTED transactions. */ - /* NOTE: if we are retrieving a big BLOB, we may - already run out of memory in the next call, which - causes an assert */ - - data = btr_rec_copy_externally_stored_field( - rec, offsets, - dict_table_zip_size(prebuilt->table), - field_no, &len, heap); - - if (UNIV_UNLIKELY(!data)) { - /* The externally stored field - was not written yet. This - record should only be seen by - recv_recovery_rollback_active() - or any TRX_ISO_READ_UNCOMMITTED - transactions. */ - - if (extern_field_heap) { - mem_heap_free(extern_field_heap); - } - - return(FALSE); + if (heap != prebuilt->blob_heap) { + mem_heap_free(heap); } - ut_a(len != UNIV_SQL_NULL); - } else { - /* Field is stored in the row. */ - - data = rec_get_nth_field(rec, offsets, field_no, &len); - - if (UNIV_UNLIKELY(templ->type == DATA_BLOB) - && len != UNIV_SQL_NULL) { + ut_a(prebuilt->trx->isolation_level + == TRX_ISO_READ_UNCOMMITTED); + return(FALSE); + } - /* It is a BLOB field locally stored in the - InnoDB record: we MUST copy its contents to - prebuilt->blob_heap here because later code - assumes all BLOB values have been copied to a - safe place. */ + ut_a(len != UNIV_SQL_NULL); - if (prebuilt->blob_heap == NULL) { - prebuilt->blob_heap = mem_heap_create( - UNIV_PAGE_SIZE); - } + row_sel_field_store_in_mysql_format( + mysql_rec + templ->mysql_col_offset, + templ, data, len); - data = memcpy(mem_heap_alloc( - prebuilt->blob_heap, len), - data, len); - } + if (heap != prebuilt->blob_heap) { + mem_heap_free(heap); } + } else { + /* Field is stored in the row. */ - if (len != UNIV_SQL_NULL) { - row_sel_field_store_in_mysql_format( - mysql_rec + templ->mysql_col_offset, - templ, data, len); - - /* Cleanup */ - if (extern_field_heap) { - mem_heap_free(extern_field_heap); - extern_field_heap = NULL; - } + data = rec_get_nth_field(rec, offsets, field_no, &len); - if (templ->mysql_null_bit_mask) { - /* It is a nullable column with a non-NULL - value */ - mysql_rec[templ->mysql_null_byte_offset] - &= ~(byte) templ->mysql_null_bit_mask; - } - } else { + if (len == UNIV_SQL_NULL) { /* MySQL assumes that the field for an SQL NULL value is set to the default value. */ + ut_ad(templ->mysql_null_bit_mask); UNIV_MEM_ASSERT_RW(prebuilt->default_rec + templ->mysql_col_offset, @@ -2815,6 +2769,85 @@ row_sel_store_mysql_rec( (const byte*) prebuilt->default_rec + templ->mysql_col_offset, templ->mysql_col_len); + return(TRUE); + } + + if (UNIV_UNLIKELY(templ->type == DATA_BLOB)) { + + /* It is a BLOB field locally stored in the + InnoDB record: we MUST copy its contents to + prebuilt->blob_heap here because + row_sel_field_store_in_mysql_format() stores a + pointer to the data, and the data passed to us + will be invalid as soon as the + mini-transaction is committed and the page + latch on the clustered index page is + released. */ + + if (prebuilt->blob_heap == NULL) { + prebuilt->blob_heap = mem_heap_create( + UNIV_PAGE_SIZE); + } + + data = mem_heap_dup(prebuilt->blob_heap, data, len); + } + + row_sel_field_store_in_mysql_format( + mysql_rec + templ->mysql_col_offset, + templ, data, len); + } + + ut_ad(len != UNIV_SQL_NULL); + + if (templ->mysql_null_bit_mask) { + /* It is a nullable column with a non-NULL + value */ + mysql_rec[templ->mysql_null_byte_offset] + &= ~(byte) templ->mysql_null_bit_mask; + } + + return(TRUE); +} + +/**************************************************************//** +Convert a row in the Innobase format to a row in the MySQL format. +Note that the template in prebuilt may advise us to copy only a few +columns to mysql_rec, other columns are left blank. All columns may not +be needed in the query. +@return TRUE on success, FALSE if not all columns could be retrieved */ +static __attribute__((warn_unused_result)) +ibool +row_sel_store_mysql_rec( +/*====================*/ + byte* mysql_rec, /*!< out: row in the MySQL format */ + row_prebuilt_t* prebuilt, /*!< in: prebuilt struct */ + const rec_t* rec, /*!< in: Innobase record in the index + which was described in prebuilt's + template, or in the clustered index; + must be protected by a page latch */ + ibool rec_clust, /*!< in: TRUE if rec is in the + clustered index instead of + prebuilt->index */ + const ulint* offsets) /*!< in: array returned by + rec_get_offsets(rec) */ +{ + ulint i; + + if (UNIV_LIKELY_NULL(prebuilt->blob_heap)) { + mem_heap_free(prebuilt->blob_heap); + prebuilt->blob_heap = NULL; + } + + for (i = 0; i < prebuilt->n_template; i++) { + const mysql_row_templ_t*templ = &prebuilt->mysql_template[i]; + + if (!row_sel_store_mysql_field(mysql_rec, prebuilt, + rec, offsets, + rec_clust + ? templ->clust_rec_field_no + : templ->rec_field_no, + templ)) { + return(FALSE); } } @@ -3185,31 +3218,19 @@ UNIV_INLINE __attribute__((warn_unused_result)) ibool row_sel_push_cache_row_for_mysql( /*=============================*/ - row_prebuilt_t* prebuilt, /*!< in: prebuilt struct */ - const rec_t* rec, /*!< in: record to push, in the index - which was described in prebuilt's - template, or in the clustered index; - must be protected by a page latch */ - ibool rec_clust, /*!< in: TRUE if rec is in the - clustered index instead of - prebuilt->index */ - const ulint* offsets, /*!< in: rec_get_offsets(rec) */ - ulint start_field_no, /* in: start from this field */ - byte* remainder_buf) /* in: if start_field_no !=0, - where to take prev fields */ + byte* mysql_rec, /*!< in/out: MySQL record */ + row_prebuilt_t* prebuilt) /*!< in/out: prebuilt struct */ { - byte* buf; - ulint i; - ut_ad(prebuilt->n_fetch_cached < MYSQL_FETCH_CACHE_SIZE); - ut_ad(rec_offs_validate(rec, NULL, offsets)); - ut_ad(!rec_get_deleted_flag(rec, rec_offs_comp(offsets))); ut_a(!prebuilt->templ_contains_blob); - if (prebuilt->fetch_cache[0] == NULL) { + if (UNIV_UNLIKELY(prebuilt->fetch_cache[0] == NULL)) { + ulint i; /* Allocate memory for the fetch cache */ + ut_ad(prebuilt->n_fetch_cached == 0); for (i = 0; i < MYSQL_FETCH_CACHE_SIZE; i++) { + byte* buf; /* A user has reported memory corruption in these buffers in Linux. Put magic numbers there to help @@ -3229,46 +3250,14 @@ row_sel_push_cache_row_for_mysql( UNIV_MEM_INVALID(prebuilt->fetch_cache[prebuilt->n_fetch_cached], prebuilt->mysql_row_len); - if (UNIV_UNLIKELY(!row_sel_store_mysql_rec( - prebuilt->fetch_cache[ - prebuilt->n_fetch_cached], - prebuilt, - rec, - rec_clust, - offsets, - start_field_no, - prebuilt->n_template))) { - return(FALSE); - } - - if (start_field_no) { - - for (i=0; i < start_field_no; i++) { - register ulint offs; - mysql_row_templ_t* templ; - register byte * null_byte; - - templ = prebuilt->mysql_template + i; - - if (templ->mysql_null_bit_mask) { - offs = templ->mysql_null_byte_offset; - - null_byte= prebuilt->fetch_cache[ - prebuilt->n_fetch_cached]+offs; - (*null_byte)&= ~templ->mysql_null_bit_mask; - (*null_byte)|= (*(remainder_buf + offs) & - templ->mysql_null_bit_mask); - } + memcpy(prebuilt->fetch_cache[prebuilt->n_fetch_cached], + mysql_rec, prebuilt->mysql_row_len); - offs = templ->mysql_col_offset; - memcpy(prebuilt->fetch_cache[prebuilt->n_fetch_cached] - + offs, - remainder_buf + offs, - templ->mysql_col_len); - } + if (++prebuilt->n_fetch_cached < MYSQL_FETCH_CACHE_SIZE) { + return(FALSE); } - prebuilt->n_fetch_cached++; + row_sel_pop_cached_row_for_mysql(mysql_rec, prebuilt); return(TRUE); } @@ -3346,6 +3335,81 @@ row_sel_try_search_shortcut_for_mysql( return(SEL_FOUND); } +/*********************************************************************//** +Check a pushed-down index condition. +@return ICP_NO_MATCH, ICP_MATCH, or ICP_OUT_OF_RANGE */ +static +enum icp_result +row_search_idx_cond_check( +/*======================*/ + byte* mysql_rec, /*!< out: record + in MySQL format (invalid unless + prebuilt->idx_cond!=NULL and + we return ICP_MATCH) */ + row_prebuilt_t* prebuilt, /*!< in/out: prebuilt struct + for the table handle */ + const rec_t* rec, /*!< in: InnoDB record */ + const ulint* offsets) /*!< in: rec_get_offsets() */ +{ + enum icp_result result; + ulint i; + + ut_ad(rec_offs_validate(rec, prebuilt->index, offsets)); + + if (!prebuilt->idx_cond) { + return(ICP_MATCH); + } + + /* Convert to MySQL format those fields that are needed for + evaluating the index condition. */ + + if (UNIV_LIKELY_NULL(prebuilt->blob_heap)) { + mem_heap_empty(prebuilt->blob_heap); + } + + for (i = 0; i < prebuilt->idx_cond_n_cols; i++) { + const mysql_row_templ_t*templ = &prebuilt->mysql_template[i]; + + if (!row_sel_store_mysql_field(mysql_rec, prebuilt, + rec, offsets, + templ->icp_rec_field_no, + templ)) { + return(ICP_NO_MATCH); + } + } + + /* We assume that the index conditions on + case-insensitive columns are case-insensitive. The + case of such columns may be wrong in a secondary + index, if the case of the column has been updated in + the past, or a record has been deleted and a record + inserted in a different case. */ + result = innobase_index_cond(prebuilt->idx_cond); + switch (result) { + case ICP_MATCH: + /* Convert the remaining fields to MySQL format. + If this is a secondary index record, we must defer + this until we have fetched the clustered index record. */ + if (!prebuilt->need_to_access_clustered + || dict_index_is_clust(prebuilt->index)) { + if (!row_sel_store_mysql_rec(mysql_rec, prebuilt, + rec, + FALSE, offsets)) { + ut_ad(dict_index_is_clust(prebuilt->index)); + result = ICP_NO_MATCH; + } + } + /* fall through */ + case ICP_NO_MATCH: + case ICP_OUT_OF_RANGE: + case ICP_ABORTED_BY_USER: + return(result); + default: ; + } + + ut_error; +} + /********************************************************************//** Searches for rows in the database. This is used in the interface to MySQL. This function opens a cursor, and also implements fetch next @@ -3410,10 +3474,8 @@ row_search_for_mysql( mem_heap_t* heap = NULL; ulint offsets_[REC_OFFS_NORMAL_SIZE]; ulint* offsets = offsets_; - ibool some_fields_in_buffer; ibool table_lock_waited = FALSE; - ibool problematic_use = FALSE; - ibool get_clust_rec = 0; + ibool problematic_use = FALSE; rec_offs_init(offsets_); @@ -3715,10 +3777,24 @@ row_search_for_mysql( mtr_commit(&mtr). */ ut_ad(!rec_get_deleted_flag(rec, comp)); + if (prebuilt->idx_cond) { + switch (row_search_idx_cond_check( + buf, prebuilt, + rec, offsets)) { + case ICP_NO_MATCH: + case ICP_OUT_OF_RANGE: + case ICP_ABORTED_BY_USER: + goto shortcut_mismatch; + case ICP_MATCH: + goto shortcut_match; + default: ; + } + ut_error; + } + if (!row_sel_store_mysql_rec(buf, prebuilt, rec, FALSE, - offsets, 0, - prebuilt->n_template)) { + offsets)) { /* Only fresh inserts may contain incomplete externally stored columns. Pretend that such @@ -3729,13 +3805,12 @@ row_search_for_mysql( rolling back a recovered transaction. Rollback happens at a lower level, not here. */ - ut_a(trx->isolation_level - == TRX_ISO_READ_UNCOMMITTED); /* Proceed as in case SEL_RETRY. */ break; } + shortcut_match: mtr_commit(&mtr); /* ut_print_name(stderr, index->name); @@ -3747,6 +3822,7 @@ row_search_for_mysql( goto release_search_latch_if_needed; case SEL_EXHAUSTED: + shortcut_mismatch: mtr_commit(&mtr); /* ut_print_name(stderr, index->name); @@ -3849,8 +3925,9 @@ retry_check: if (!prebuilt->sql_stat_start) { /* No need to set an intention lock or assign a read view */ - if (trx->read_view == NULL - && prebuilt->select_lock_type == LOCK_NONE) { + if (UNIV_UNLIKELY + (trx->read_view == NULL + && prebuilt->select_lock_type == LOCK_NONE)) { fputs("InnoDB: Error: MySQL is trying to" " perform a consistent read\n" @@ -4321,6 +4398,16 @@ no_gap_lock: if (UNIV_LIKELY(trx->wait_lock != NULL)) { lock_cancel_waiting_and_release( trx->wait_lock); + mutex_exit(&kernel_mutex); + + if (old_vers == NULL) { + /* The row was not yet committed */ + + goto next_rec; + } + + did_semi_consistent_read = TRUE; + rec = old_vers; } else { mutex_exit(&kernel_mutex); @@ -4331,19 +4418,7 @@ no_gap_lock: offsets = rec_get_offsets(rec, index, offsets, ULINT_UNDEFINED, &heap); - err = DB_SUCCESS; - break; } - mutex_exit(&kernel_mutex); - - if (old_vers == NULL) { - /* The row was not yet committed */ - - goto next_rec; - } - - did_semi_consistent_read = TRUE; - rec = old_vers; break; default: @@ -4402,8 +4477,27 @@ no_gap_lock: if (!lock_sec_rec_cons_read_sees( rec, trx->read_view)) { - get_clust_rec = TRUE; - goto idx_cond_check; + /* We should look at the clustered index. + However, as this is a non-locking read, + we can skip the clustered index lookup if + the condition does not match the secondary + index entry. */ + switch (row_search_idx_cond_check( + buf, prebuilt, rec, offsets)) { + case ICP_NO_MATCH: + goto next_rec; + case ICP_OUT_OF_RANGE: + err = DB_RECORD_NOT_FOUND; + goto idx_cond_failed; + case ICP_ABORTED_BY_USER: + err = DB_SEARCH_ABORTED_BY_USER; + goto idx_cond_failed; + case ICP_MATCH: + goto requires_clust_rec; + default: ; + } + + ut_error; } } } @@ -4448,38 +4542,31 @@ no_gap_lock: goto next_rec; } - -idx_cond_check: - if (prebuilt->idx_cond_func) { - int res; - ibool ib_res; - ut_ad(prebuilt->template_type != ROW_MYSQL_DUMMY_TEMPLATE); - offsets = rec_get_offsets(rec, index, offsets, ULINT_UNDEFINED, &heap); - ib_res= row_sel_store_mysql_rec(buf, prebuilt, rec, FALSE, - offsets, 0, prebuilt->n_index_fields); - /* - The above call will fail and return FALSE when requested to - store an "externally stored column" (afaiu, a blob). Index - Condition Pushdown is not supported for indexes with blob - columns, so we should never get this error. - */ - ut_ad(ib_res); - res= prebuilt->idx_cond_func(prebuilt->idx_cond_func_arg); - if (res == XTRADB_ICP_NO_MATCH) - goto next_rec; - else if (res != XTRADB_ICP_MATCH) { - err= (res == XTRADB_ICP_ABORTED_BY_USER ? - DB_SEARCH_ABORTED_BY_USER : - DB_RECORD_NOT_FOUND); - goto idx_cond_failed; - } - /* res == XTRADB_ICP_MATCH */ - } + /* Check if the record matches the index condition. */ + switch (row_search_idx_cond_check(buf, prebuilt, rec, offsets)) { + case ICP_NO_MATCH: + if (did_semi_consistent_read) { + row_unlock_for_mysql(prebuilt, TRUE); + } + goto next_rec; + case ICP_ABORTED_BY_USER: + err = DB_SEARCH_ABORTED_BY_USER; + goto idx_cond_failed; + case ICP_OUT_OF_RANGE: + err = DB_RECORD_NOT_FOUND; + goto idx_cond_failed; + case ICP_MATCH: + break; + default: + ut_error; + } /* Get the clustered index record if needed, if we did not do the search using the clustered index. */ - if (get_clust_rec || (index != clust_index - && prebuilt->need_to_access_clustered)) { + if (index != clust_index && prebuilt->need_to_access_clustered) { + +requires_clust_rec: + ut_ad(index != clust_index); /* We use a 'goto' to the preceding label if a consistent read of a secondary index record requires us to look up old @@ -4543,6 +4630,19 @@ idx_cond_check: result_rec = clust_rec; ut_ad(rec_offs_validate(result_rec, clust_index, offsets)); + + if (prebuilt->idx_cond) { + /* Convert the remaining fields to + MySQL format. We were unable to do + this in row_search_idx_cond_check(), + because the condition is on the + secondary index and the requested + column is in the clustered index. */ + if (!row_sel_store_mysql_rec(buf, prebuilt, result_rec, + TRUE, offsets)) { + goto next_rec; + } + } } else { result_rec = rec; } @@ -4576,15 +4676,10 @@ idx_cond_check: are BLOBs in the fields to be fetched. In HANDLER we do not cache rows because there the cursor is a scrollable cursor. */ - some_fields_in_buffer = (index != clust_index - && prebuilt->idx_cond_func); - - if (!row_sel_push_cache_row_for_mysql(prebuilt, result_rec, - result_rec != rec, - offsets, - some_fields_in_buffer? - prebuilt->n_index_fields : 0, - buf)) { + + if (!prebuilt->idx_cond + && !row_sel_store_mysql_rec(buf, prebuilt, result_rec, + result_rec != rec, offsets)) { /* Only fresh inserts may contain incomplete externally stored columns. Pretend that such records do not exist. Such records may only be @@ -4592,14 +4687,10 @@ idx_cond_check: level or when rolling back a recovered transaction. Rollback happens at a lower level, not here. */ - ut_a(trx->isolation_level == TRX_ISO_READ_UNCOMMITTED); - } else if (prebuilt->n_fetch_cached - == MYSQL_FETCH_CACHE_SIZE) { - - goto got_row; + goto next_rec; + } else if (row_sel_push_cache_row_for_mysql(buf, prebuilt)) { + goto next_rec; } - - goto next_rec; } else { if (UNIV_UNLIKELY (prebuilt->template_type == ROW_MYSQL_DUMMY_TEMPLATE)) { @@ -4620,16 +4711,11 @@ idx_cond_check: rec_offs_size(offsets)); mach_write_to_4(buf, rec_offs_extra_size(offsets) + 4); - } else { - /* Returning a row to MySQL */ - - if (!row_sel_store_mysql_rec(buf, prebuilt, - result_rec, - result_rec != rec, - offsets, - prebuilt->idx_cond_func? - prebuilt->n_index_fields: 0, - prebuilt->n_template)) { + } else if (!prebuilt->idx_cond) { + /* The record was not yet converted to MySQL format. */ + if (!row_sel_store_mysql_rec( + buf, prebuilt, + result_rec, result_rec != rec, offsets)) { /* Only fresh inserts may contain incomplete externally stored columns. Pretend that such records do @@ -4638,8 +4724,6 @@ idx_cond_check: isolation level or when rolling back a recovered transaction. Rollback happens at a lower level, not here. */ - ut_a(trx->isolation_level - == TRX_ISO_READ_UNCOMMITTED); goto next_rec; } } @@ -4657,7 +4741,6 @@ idx_cond_check: /* From this point on, 'offsets' are invalid. */ -got_row: /* We have an optimization to save CPU time: if this is a consistent read on a unique condition on the clustered index, then we do not store the pcur position, because any fetch next or prev will anyway @@ -4681,7 +4764,6 @@ idx_cond_failed: next_rec: /* Reset the old and new "did semi-consistent read" flags. */ - get_clust_rec = FALSE; if (UNIV_UNLIKELY(prebuilt->row_read_type == ROW_READ_DID_SEMI_CONSISTENT)) { prebuilt->row_read_type = ROW_READ_TRY_SEMI_CONSISTENT; @@ -4692,6 +4774,7 @@ next_rec: /*-------------------------------------------------------------*/ /* PHASE 5: Move the cursor to the next index record */ + /*TODO: with ICP, do this when switching pages, every N pages */ if (UNIV_UNLIKELY(mtr_has_extra_clust_latch)) { /* We must commit mtr if we are moving to the next non-clustered index record, because we could break the diff --git a/strings/conf_to_src.c b/strings/conf_to_src.c index f8b560422d7..aebeafcda98 100644 --- a/strings/conf_to_src.c +++ b/strings/conf_to_src.c @@ -1,4 +1,5 @@ -/* Copyright (c) 2000, 2011, Oracle and/or its affiliates. +/* Copyright (c) 2000-2003, 2005-2007 MySQL AB, 2009 Sun Microsystems, Inc. + Use is subject to license terms. Copyright (c) 2009-2011, Monty Program Ab This program is free software; you can redistribute it and/or modify @@ -12,7 +13,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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ #include "strings_def.h" #include <m_ctype.h> diff --git a/strings/ctype-big5.c b/strings/ctype-big5.c index e636c6e0263..1b8e2fb5f3a 100644 --- a/strings/ctype-big5.c +++ b/strings/ctype-big5.c @@ -1,4 +1,4 @@ -/* Copyright (c) 2000, 2011, Oracle and/or its affiliates. +/* Copyright (c) 2000, 2010, Oracle and/or its affiliates. Copyright (c) 2009-2011, Monty Program Ab This program is free software; you can redistribute it and/or modify @@ -12,7 +12,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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ /* * This file is basicly usa7 character sets with some extra functions diff --git a/strings/ctype-cp932.c b/strings/ctype-cp932.c index 88459b87d7e..ffab57a7d96 100644 --- a/strings/ctype-cp932.c +++ b/strings/ctype-cp932.c @@ -1,4 +1,4 @@ -/* Copyright (c) 2000, 2011, Oracle and/or its affiliates. +/* Copyright (c) 2005, 2010, Oracle and/or its affiliates. Copyright (c) 2009-2011, Monty Program Ab This program is free software; you can redistribute it and/or modify @@ -12,7 +12,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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ /* This file is for cp932 charaset (Windows Japanese), and created based on ctype-sjis.c file */ diff --git a/strings/ctype-czech.c b/strings/ctype-czech.c index 21af116edf6..08c8412e8ae 100644 --- a/strings/ctype-czech.c +++ b/strings/ctype-czech.c @@ -1,4 +1,4 @@ -/* Copyright (c) 2000, 2011, Oracle and/or its affiliates. +/* Copyright (c) 2000, 2010, Oracle and/or its affiliates. Copyright (c) 2009-2011, Monty Program Ab This program is free software; you can redistribute it and/or modify @@ -12,7 +12,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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ /* File strings/ctype-czech.c for MySQL. diff --git a/strings/ctype-euc_kr.c b/strings/ctype-euc_kr.c index 9321a0ac2c8..77296f34f6a 100644 --- a/strings/ctype-euc_kr.c +++ b/strings/ctype-euc_kr.c @@ -1,4 +1,4 @@ -/* Copyright (c) 2000, 2011, Oracle and/or its affiliates. +/* Copyright (c) 2000, 2010, Oracle and/or its affiliates. Copyright (c) 2009-2011, Monty Program Ab This program is free software; you can redistribute it and/or modify @@ -12,7 +12,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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ /* * This file is for Korean EUC charset, and created by powerm90@tinc.co.kr. diff --git a/strings/ctype-eucjpms.c b/strings/ctype-eucjpms.c index 6d9bbfc0a53..9ad64ca2457 100644 --- a/strings/ctype-eucjpms.c +++ b/strings/ctype-eucjpms.c @@ -1,7 +1,6 @@ -/* Copyright tommy@valley.ne.jp. - Copyright (c) 2002, 2011, Oracle and/or its affiliates. +/* Copyright (c) 2005, 2011, Oracle and/or its affiliates. Copyright (c) 2009-2011, Monty Program Ab - + This library is free software; you can redistribute it and/or modify it under the terms of the GNU Library General Public License as published by the Free Software Foundation; version 2 diff --git a/strings/ctype-extra.c b/strings/ctype-extra.c index e0499c6f2e3..b52cc603e4d 100644 --- a/strings/ctype-extra.c +++ b/strings/ctype-extra.c @@ -6,8 +6,7 @@ ./conf_to_src ../sql/share/charsets/ > FILE */ -/* Copyright 2000-2008 MySQL AB, 2008 Sun Microsystems, Inc. - Copyright (c) 2000, 2011, Oracle and/or its affiliates. +/* Copyright (c) 2003, 2010, Oracle and/or its affiliates. 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/strings/ctype-gb2312.c b/strings/ctype-gb2312.c index af0526790c5..af6c6f9f8c2 100644 --- a/strings/ctype-gb2312.c +++ b/strings/ctype-gb2312.c @@ -1,4 +1,4 @@ -/* Copyright (c) 2000, 2011, Oracle and/or its affiliates. +/* Copyright (c) 2000, 2010, Oracle and/or its affiliates. Copyright (c) 2009-2011, Monty Program Ab This program is free software; you can redistribute it and/or modify @@ -12,7 +12,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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ /* This file is for Chinese EUC character sets (GB2312), and created by Miles Tsai (net-bull@126.com). */ diff --git a/strings/ctype-gbk.c b/strings/ctype-gbk.c index bbe7c31c58c..601bbabddb5 100644 --- a/strings/ctype-gbk.c +++ b/strings/ctype-gbk.c @@ -1,4 +1,4 @@ -/* Copyright (c) 2000, 2011, Oracle and/or its affiliates. +/* Copyright (c) 2000, 2010, Oracle and/or its affiliates. Copyright (c) 2009-2011, Monty Program Ab This program is free software; you can redistribute it and/or modify @@ -12,7 +12,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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ /* This file is for Chinese character sets GBK, created by Wei He (hewei@mail.ied.ac.cn) diff --git a/strings/ctype-latin1.c b/strings/ctype-latin1.c index 63858b56c9e..f5456c1a943 100644 --- a/strings/ctype-latin1.c +++ b/strings/ctype-latin1.c @@ -1,4 +1,5 @@ -/* Copyright (c) 2000, 2011, Oracle and/or its affiliates. +/* Copyright (c) 2000, 2003-2007 MySQL AB, 2009 Sun Microsystems, Inc. + Use is subject to license terms. Copyright (c) 2009-2011, Monty Program Ab This program is free software; you can redistribute it and/or modify @@ -12,7 +13,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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ #include "strings_def.h" #include <m_ctype.h> diff --git a/strings/ctype-mb.c b/strings/ctype-mb.c index d220a80d120..33e0c58cbbf 100644 --- a/strings/ctype-mb.c +++ b/strings/ctype-mb.c @@ -1,4 +1,4 @@ -/* Copyright (c) 2000, 2011, Oracle and/or its affiliates. +/* Copyright (c) 2000, 2010, Oracle and/or its affiliates. Copyright (c) 2009-2011, Monty Program Ab This program is free software; you can redistribute it and/or modify @@ -12,7 +12,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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ #include "strings_def.h" #include <m_ctype.h> diff --git a/strings/ctype-simple.c b/strings/ctype-simple.c index 4f2a42f5905..eb8c44805da 100644 --- a/strings/ctype-simple.c +++ b/strings/ctype-simple.c @@ -1,4 +1,4 @@ -/* Copyright (c) 2002, 2011, Oracle and/or its affiliates. +/* Copyright (c) 2002, 2010, Oracle and/or its affiliates. Copyright (c) 2009-2011, Monty Program Ab This program is free software; you can redistribute it and/or modify @@ -12,7 +12,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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ #include "strings_def.h" #include <m_ctype.h> diff --git a/strings/ctype-sjis.c b/strings/ctype-sjis.c index b782c892fd9..042ceab4f35 100644 --- a/strings/ctype-sjis.c +++ b/strings/ctype-sjis.c @@ -1,4 +1,4 @@ -/* Copyright (c) 2000, 2011, Oracle and/or its affiliates. +/* Copyright (c) 2000, 2010, Oracle and/or its affiliates. Copyright (c) 2009-2011, Monty Program Ab This program is free software; you can redistribute it and/or modify @@ -12,7 +12,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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ /* This file is for Shift JIS charset, and created by tommy@valley.ne.jp. */ diff --git a/strings/ctype-tis620.c b/strings/ctype-tis620.c index 9bf7a73a6d1..f6fe4c0f914 100644 --- a/strings/ctype-tis620.c +++ b/strings/ctype-tis620.c @@ -1,4 +1,6 @@ -/* +/* Copyright (c) 2000, 2010, Oracle and/or its affiliates. + Copyright (c) 2009-2011, Monty Program Ab + 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 the Free Software Foundation; version 2 of the License. @@ -10,11 +12,9 @@ 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ /* - Copyright (c) 2000, 2011, Oracle and/or its affiliates. - Copyright (c) 2009-2011, Monty Program Ab Copyright (C) 2003 by Sathit Jittanupat <jsat66@hotmail.com,jsat66@yahoo.com> * solving bug crash with long text field string diff --git a/strings/ctype-uca.c b/strings/ctype-uca.c index 683fb8f6654..b5f151c4d10 100644 --- a/strings/ctype-uca.c +++ b/strings/ctype-uca.c @@ -1,4 +1,4 @@ -/* Copyright (c) 2004, 2011, Oracle and/or its affiliates. +/* Copyright (c) 2004, 2010, Oracle and/or its affiliates. Copyright (c) 2009-2011, Monty Program Ab This library is free software; you can redistribute it and/or @@ -13,8 +13,8 @@ You should have received a copy of the GNU Library General Public License along with this library; if not, write to the Free - Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, - MA 02111-1307, USA */ + Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, + MA 02110-1301, USA */ /* UCA (Unicode Collation Algorithm) support. @@ -46,6 +46,7 @@ #define MY_UCA_NCHARS 256 #define MY_UCA_CMASK 255 #define MY_UCA_PSHIFT 8 +#define MAX_UCA_CHAR_WITH_EXPLICIT_WEIGHT 0xFFFF static const uint16 page000data[]= { /* 0000 (4 weights per char) */ 0x0000,0x0000,0x0000,0x0000, 0x0000,0x0000,0x0000,0x0000, @@ -7077,7 +7078,7 @@ static int my_uca_scanner_next_any(my_uca_scanner *scanner) return -1; scanner->sbeg+= mb_len; - if (wc > 0xFFFF) + if (wc > MAX_UCA_CHAR_WITH_EXPLICIT_WEIGHT) { /* Return 0xFFFD as weight for all characters outside BMP */ scanner->wbeg= nochar; @@ -7142,30 +7143,6 @@ static my_uca_scanner_handler my_any_uca_scanner_handler= }; -/** - Helper function: - Find address of weights of the given character. - - @weights UCA weight array - @lengths UCA length array - @ch character Unicode code point - - @return Weight array - @retval pointer to weight array for the given character, - or NULL if this page does not have implicit weights. -*/ - -static inline const uint16 * -my_char_weight_addr(CHARSET_INFO *cs, uint wc) -{ - uint page= (wc >> 8); - uint ofst= wc & 0xFF; - return (cs->sort_order_big[page] ? - cs->sort_order_big[page] + ofst * cs->sort_order[page] : - 0); -} - - /* Compares two strings according to the collation @@ -7439,6 +7416,33 @@ static size_t my_strnxfrm_uca(CHARSET_INFO *cs, +/** + Helper function: + Find address of weights of the given character. + + @param weights UCA weight array + @param lengths UCA length array + @param ch character Unicode code point + + @return Weight array + @retval pointer to weight array for the given character, + or NULL if this page does not have implicit weights. +*/ + +static inline const uint16 * +my_char_weight_addr(CHARSET_INFO *cs, uint wc) +{ + uint page, ofst; + const uchar *ucal= cs->sort_order; + const uint16 * const *ucaw= cs->sort_order_big; + + return wc > MAX_UCA_CHAR_WITH_EXPLICIT_WEIGHT ? NULL : + (ucaw[page= (wc >> 8)] ? + ucaw[page] + (ofst= (wc & 0xFF)) * ucal[page] : + NULL); +} + + /* This function compares if two characters are the same. The sign +1 or -1 does not matter. The only @@ -7449,17 +7453,20 @@ static size_t my_strnxfrm_uca(CHARSET_INFO *cs, static int my_uca_charcmp(CHARSET_INFO *cs, my_wc_t wc1, my_wc_t wc2) { - size_t page1= wc1 >> MY_UCA_PSHIFT; - size_t page2= wc2 >> MY_UCA_PSHIFT; - const uchar *ucal= cs->sort_order; - const uint16 *const *ucaw= cs->sort_order_big; - size_t length1= ucal[page1]; - size_t length2= ucal[page2]; - const uint16 *weight1= ucaw[page1] + (wc1 & MY_UCA_CMASK) * ucal[page1]; - const uint16 *weight2= ucaw[page2] + (wc2 & MY_UCA_CMASK) * ucal[page2]; + size_t length1, length2; + const uint16 *weight1= my_char_weight_addr(cs, wc1); + const uint16 *weight2= my_char_weight_addr(cs, wc2); if (!weight1 || !weight2) return wc1 != wc2; + + /* Quickly compare first weights */ + if (weight1[0] != weight2[0]) + return 1; + + /* Thoroughly compare all weights */ + length1= cs->sort_order[wc1 >> MY_UCA_PSHIFT]; + length2= cs->sort_order[wc2 >> MY_UCA_PSHIFT]; if (length1 > length2) return memcmp((const void*)weight1, (const void*)weight2, length2*2) ? @@ -8044,6 +8051,11 @@ static my_bool create_tailoring(struct charset_info_st *cs, */ for (i=0; i < rc; i++) { + /* check if the shift or the reset characters are out of range */ + if (rule[i].curr[0] > MAX_UCA_CHAR_WITH_EXPLICIT_WEIGHT || + rule[i].base > MAX_UCA_CHAR_WITH_EXPLICIT_WEIGHT) + return 1; + if (!rule[i].curr[1]) /* If not a contraction */ { uint pageb= (rule[i].base >> 8) & 0xFF; diff --git a/strings/ctype-ucs2.c b/strings/ctype-ucs2.c index 4f676c8effe..b22ca43a062 100644 --- a/strings/ctype-ucs2.c +++ b/strings/ctype-ucs2.c @@ -1,6 +1,6 @@ -/* Copyright (c) 2000, 2011, Oracle and/or its affiliates. +/* Copyright (c) 2000, 2010, Oracle and/or its affiliates. Copyright (c) 2009-2011, Monty Program Ab - + This library is free software; you can redistribute it and/or modify it under the terms of the GNU Library General Public License as published by the Free Software Foundation; version 2 @@ -13,8 +13,8 @@ You should have received a copy of the GNU Library General Public License along with this library; if not, write to the Free - Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, - MA 02111-1307, USA */ + Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, + MA 02110-1301, USA */ /* UCS2 support. Written by Alexander Barkov <bar@mysql.com> */ diff --git a/strings/ctype-ujis.c b/strings/ctype-ujis.c index ecb0992c70d..32d65a07f23 100644 --- a/strings/ctype-ujis.c +++ b/strings/ctype-ujis.c @@ -1,5 +1,5 @@ /* Copyright tommy@valley.ne.jp. - Copyright (c) 2002, 2011, Oracle and/or its affiliates. + Copyright (c) 2000, 2011, Oracle and/or its affiliates. Copyright (c) 2009-2011, Monty Program Ab This library is free software; you can redistribute it and/or diff --git a/strings/ctype-utf8.c b/strings/ctype-utf8.c index 74dcbcf4fc2..daca63437ca 100644 --- a/strings/ctype-utf8.c +++ b/strings/ctype-utf8.c @@ -1,4 +1,4 @@ -/* Copyright (c) 2000, 2011, Oracle and/or its affiliates. +/* Copyright (c) 2000, 2010, Oracle and/or its affiliates. Copyright (c) 2009-2011, Monty Program Ab This library is free software; you can redistribute it and/or @@ -13,8 +13,8 @@ You should have received a copy of the GNU Library General Public License along with this library; if not, write to the Free - Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, - MA 02111-1307, USA */ + Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, + MA 02110-1301, USA */ /* UTF8 according RFC 2279 */ /* Written by Alexander Barkov <bar@udm.net> */ diff --git a/strings/ctype-win1250ch.c b/strings/ctype-win1250ch.c index 19896de5e66..a22fe7b696f 100644 --- a/strings/ctype-win1250ch.c +++ b/strings/ctype-win1250ch.c @@ -1,5 +1,5 @@ /* Copyright (c) 2001 Jan Pazdziora. - Copyright (c) 2003, 2011, Oracle and/or its affiliates. + Copyright (c) 2002, 2010, Oracle and/or its affiliates. Copyright (c) 2009-2011, Monty Program Ab This program is free software; you can redistribute it and/or modify @@ -13,7 +13,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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ /* Shared, independent copyright: (C) 2001 Jan Pazdziora. diff --git a/strings/ctype.c b/strings/ctype.c index 429f4a0b366..296960b55b5 100644 --- a/strings/ctype.c +++ b/strings/ctype.c @@ -1,4 +1,5 @@ -/* Copyright (c) 2000, 2011, Oracle and/or its affiliates. +/* Copyright (c) 2000-2007 MySQL AB, 2008, 2009 Sun Microsystems, Inc. + Use is subject to license terms. Copyright (c) 2009-2011, Monty Program Ab This program is free software; you can redistribute it and/or modify @@ -12,7 +13,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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ #include "strings_def.h" #include <m_ctype.h> diff --git a/strings/decimal.c b/strings/decimal.c index dc8a8a70809..8ac3d61612d 100644 --- a/strings/decimal.c +++ b/strings/decimal.c @@ -1,4 +1,4 @@ -/* Copyright (c) 2000, 2011, Oracle and/or its affiliates. +/* Copyright (c) 2004, 2011, Oracle and/or its affiliates. Copyright (c) 2009-2011, Monty Program Ab This program is free software; you can redistribute it and/or modify @@ -1403,11 +1403,18 @@ int bin2decimal(const uchar *from, decimal_t *to, int precision, int scale) buf++; } my_afree(d_copy); + + /* + No digits? We have read the number zero, of unspecified precision. + Make it a proper zero, with non-zero precision. + */ + if (to->intg == 0 && to->frac == 0) + decimal_make_zero(to); return error; err: my_afree(d_copy); - decimal_make_zero(((decimal_t*) to)); + decimal_make_zero(to); return(E_DEC_BAD_NUM); } @@ -2183,7 +2190,6 @@ static int do_div_mod(const decimal_t *from1, const decimal_t *from2, } buf0=to->buf; stop0=buf0+intg0+frac0; - DBUG_ASSERT(stop0 <= &to->buf[to->len]); if (likely(div_mod)) while (dintg++ < 0 && buf0 < &to->buf[to->len]) { @@ -2278,7 +2284,10 @@ static int do_div_mod(const decimal_t *from1, const decimal_t *from2, } } if (likely(div_mod)) + { + DBUG_ASSERT(buf0 < to->buf + to->len); *buf0=(dec1)guess; + } dcarry= *start1; start1++; } diff --git a/strings/do_ctype.c b/strings/do_ctype.c index c0e4aaf9be6..addb3a3d7f6 100644 --- a/strings/do_ctype.c +++ b/strings/do_ctype.c @@ -1,4 +1,4 @@ -/* Copyright (c) 2000, 2011, Oracle and/or its affiliates. +/* Copyright (c) 2000, 2010, Oracle and/or its affiliates. Copyright (c) 2009-2011, Monty Program Ab This program is free software; you can redistribute it and/or modify @@ -12,7 +12,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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ /* Prints case-convert and sort-convert tabell on stdout. This is used to make _ctype.c easyer */ diff --git a/strings/dtoa.c b/strings/dtoa.c index 3aeeed9e148..e6339bab1d9 100644 --- a/strings/dtoa.c +++ b/strings/dtoa.c @@ -1,4 +1,4 @@ -/* Copyright (c) 2007, 2011, Oracle and/or its affiliates. All rights reserved. +/* Copyright (c) 2007, 2010, Oracle and/or its affiliates. All rights reserved. This library is free software; you can redistribute it and/or modify it under the terms of the GNU Library General Public @@ -12,7 +12,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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ /**************************************************************** @@ -45,7 +45,7 @@ see if it is possible to get rid of malloc(). this constant is sufficient to avoid malloc() on all inputs I have tried. */ -#define DTOA_BUFF_SIZE (420 * sizeof(void *)) +#define DTOA_BUFF_SIZE (460 * sizeof(void *)) /* Magic value returned by dtoa() to indicate overflow */ #define DTOA_OVERFLOW 9999 @@ -658,6 +658,7 @@ typedef struct Stack_alloc static Bigint *Balloc(int k, Stack_alloc *alloc) { Bigint *rv; + DBUG_ASSERT(k <= Kmax); if (k <= Kmax && alloc->freelist[k]) { rv= alloc->freelist[k]; @@ -1004,9 +1005,10 @@ static Bigint p5_a[]= static Bigint *pow5mult(Bigint *b, int k, Stack_alloc *alloc) { - Bigint *b1, *p5, *p51; + Bigint *b1, *p5, *p51=NULL; int i; static int p05[3]= { 5, 25, 125 }; + my_bool overflow= FALSE; if ((i= k & 3)) b= multadd(b, p05[i-1], 0, alloc); @@ -1025,17 +1027,22 @@ static Bigint *pow5mult(Bigint *b, int k, Stack_alloc *alloc) if (!(k>>= 1)) break; /* Calculate next power of 5 */ - if (p5 < p5_a + P5A_MAX) - ++p5; - else if (p5 == p5_a + P5A_MAX) - p5= mult(p5, p5, alloc); - else + if (overflow) { p51= mult(p5, p5, alloc); Bfree(p5, alloc); p5= p51; } + else if (p5 < p5_a + P5A_MAX) + ++p5; + else if (p5 == p5_a + P5A_MAX) + { + p5= mult(p5, p5, alloc); + overflow= TRUE; + } } + if (p51) + Bfree(p51, alloc); return b; } diff --git a/strings/dump_map.c b/strings/dump_map.c index 61e6cbb6e02..83d35f259a1 100644 --- a/strings/dump_map.c +++ b/strings/dump_map.c @@ -1,4 +1,5 @@ -/* Copyright (c) 2003, 2011, Oracle and/or its affiliates. +/* Copyright (c) 2003, 2004, 2006 MySQL AB + Use is subject to license terms. Copyright (c) 2009-2011, Monty Program Ab This program is free software; you can redistribute it and/or modify diff --git a/strings/my_strchr.c b/strings/my_strchr.c index baf832c9a0a..9bb1f0954ed 100644 --- a/strings/my_strchr.c +++ b/strings/my_strchr.c @@ -1,4 +1,4 @@ -/* Copyright (c) 2005, 2011, Oracle and/or its affiliates. +/* Copyright (c) 2005, 2010, Oracle and/or its affiliates. Copyright (c) 2009-2011, Monty Program Ab This program is free software; you can redistribute it and/or modify @@ -12,7 +12,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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ #include "strings_def.h" #include <m_ctype.h> diff --git a/strings/my_vsnprintf.c b/strings/my_vsnprintf.c index 72fd35e4e0f..dde6b0255ed 100644 --- a/strings/my_vsnprintf.c +++ b/strings/my_vsnprintf.c @@ -1,4 +1,4 @@ -/* Copyright (c) 2000, 2011, Oracle and/or its affiliates. +/* Copyright (c) 2000, 2010, Oracle and/or its affiliates. Copyright (c) 2009-2011, Monty Program Ab This program is free software; you can redistribute it and/or modify @@ -12,7 +12,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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ #include "strings_def.h" #include <m_ctype.h> diff --git a/strings/str_alloc.c b/strings/str_alloc.c index 5233a804153..3e218ff1fbd 100644 --- a/strings/str_alloc.c +++ b/strings/str_alloc.c @@ -1,4 +1,5 @@ -/* Copyright (c) 2000, 2011, Oracle and/or its affiliates. +/* Copyright (c) 2000, 2005, 2006 MySQL AB + Use is subject to license terms. Copyright (c) 2009-2011, Monty Program Ab This program is free software; you can redistribute it and/or modify @@ -12,7 +13,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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ #include "strings_def.h" diff --git a/strings/strmake.c b/strings/strmake.c index 5c26538c9bd..b6f37dd3d88 100644 --- a/strings/strmake.c +++ b/strings/strmake.c @@ -1,4 +1,5 @@ -/* Copyright (c) 2000, 2011, Oracle and/or its affiliates. +/* Copyright (c) 2000, 2001, 2003, 2006-2008 MySQL AB, 2009 Sun Microsystems, Inc. + Use is subject to license terms. Copyright (c) 2009-2011, Monty Program Ab This program is free software; you can redistribute it and/or modify @@ -12,7 +13,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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ /* File : strmake.c Author : Michael Widenius diff --git a/strings/uca-dump.c b/strings/uca-dump.c index d281783aa2b..ab3437d17df 100644 --- a/strings/uca-dump.c +++ b/strings/uca-dump.c @@ -1,4 +1,5 @@ -/* Copyright (c) 2004, 2011, Oracle and/or its affiliates. +/* Copyright (c) 2004, 2006 MySQL AB + Use is subject to license terms. Copyright (c) 2009-2011, Monty Program Ab This program is free software; you can redistribute it and/or modify diff --git a/strings/uctypedump.c b/strings/uctypedump.c index 117db2ba30a..ed3c64969d5 100644 --- a/strings/uctypedump.c +++ b/strings/uctypedump.c @@ -1,4 +1,5 @@ -/* Copyright (c) 2006, 2011, Oracle and/or its affiliates. +/* Copyright (c) 2006 MySQL AB + Use is subject to license terms. 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/strings/utr11-dump.c b/strings/utr11-dump.c index 41cc387b2e0..8bd5e9ee58b 100644 --- a/strings/utr11-dump.c +++ b/strings/utr11-dump.c @@ -1,4 +1,5 @@ -/* Copyright (c) 2004, 2011, Oracle and/or its affiliates. +/* Copyright (c) 2004, 2006 MySQL AB + Use is subject to license terms. Copyright (c) 2009-2011, Monty Program Ab This program is free software; you can redistribute it and/or modify diff --git a/strings/xml.c b/strings/xml.c index 7834f971269..54ff7a26c16 100644 --- a/strings/xml.c +++ b/strings/xml.c @@ -1,4 +1,4 @@ -/* Copyright (c) 2000, 2011, Oracle and/or its affiliates. +/* Copyright (c) 2003, 2011, Oracle and/or its affiliates. Copyright (c) 2011 Monty Program Ab This program is free software; you can redistribute it and/or modify diff --git a/support-files/config.huge.ini.sh b/support-files/config.huge.ini.sh index 938dd3209b8..f98074828a7 100644 --- a/support-files/config.huge.ini.sh +++ b/support-files/config.huge.ini.sh @@ -1,3 +1,19 @@ +# Copyright (c) 2008 MySQL AB +# Use is subject to license terms. +# +# 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 +# the Free Software Foundation; version 2 of the License. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# 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 02110-1301 USA +# ###################################################### # MySQL NDB Cluster Huge Sample Configuration File # ###################################################### diff --git a/support-files/config.medium.ini.sh b/support-files/config.medium.ini.sh index e35dd35e455..1de7f64912e 100644 --- a/support-files/config.medium.ini.sh +++ b/support-files/config.medium.ini.sh @@ -1,3 +1,18 @@ +# Copyright (c) 2008 MySQL AB +# Use is subject to license terms. +# +# 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 +# the Free Software Foundation; version 2 of the License. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# 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 02110-1301 USA # # MySQL NDB Cluster Medium Sample Configuration File # diff --git a/support-files/config.small.ini.sh b/support-files/config.small.ini.sh index 129e2521e17..0af60e5dc91 100644 --- a/support-files/config.small.ini.sh +++ b/support-files/config.small.ini.sh @@ -1,3 +1,18 @@ +# Copyright (c) 2008 MySQL AB +# Use is subject to license terms. +# +# 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 +# the Free Software Foundation; version 2 of the License. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# 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 02110-1301 USA # # MySQL NDB Cluster Small Sample Configuration File # diff --git a/support-files/dtrace/locktime.d b/support-files/dtrace/locktime.d index c9b509ca61e..610da8fbffb 100644 --- a/support-files/dtrace/locktime.d +++ b/support-files/dtrace/locktime.d @@ -1,5 +1,21 @@ #!/usr/sbin/dtrace -s # +# Copyright (c) 2009 Sun Microsystems, Inc. +# Use is subject to license terms. +# +# 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 +# the Free Software Foundation; version 2 of the License. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# 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 02110-1301 USA +# # Shows the time that an individual lock is applied to a database and table # Shows the time to achieve the lock, and the time the table was locked diff --git a/support-files/dtrace/query-execandqc.d b/support-files/dtrace/query-execandqc.d index 64599223f55..27dd5983fb0 100644 --- a/support-files/dtrace/query-execandqc.d +++ b/support-files/dtrace/query-execandqc.d @@ -1,5 +1,21 @@ #!/usr/sbin/dtrace -s # +# Copyright (c) 2009 Sun Microsystems, Inc. +# Use is subject to license terms. +# +# 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 +# the Free Software Foundation; version 2 of the License. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# 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 02110-1301 USA +# # Show query execution times, indicating whether the query-cache was used #pragma D option quiet diff --git a/support-files/dtrace/query-filesort-time.d b/support-files/dtrace/query-filesort-time.d index 425ed3863aa..0705f6ec556 100644 --- a/support-files/dtrace/query-filesort-time.d +++ b/support-files/dtrace/query-filesort-time.d @@ -1,5 +1,21 @@ #!/usr/sbin/dtrace -s # +# Copyright (c) 2009 Sun Microsystems, Inc. +# Use is subject to license terms. +# +# 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 +# the Free Software Foundation; version 2 of the License. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# 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 02110-1301 USA +# # Show the time taken for a query, including the time taken to # sort the results using filesort diff --git a/support-files/dtrace/query-network-time.d b/support-files/dtrace/query-network-time.d index f0483778fb0..1b425284873 100644 --- a/support-files/dtrace/query-network-time.d +++ b/support-files/dtrace/query-network-time.d @@ -1,5 +1,21 @@ #!/usr/sbin/dtrace -s # +# Copyright (c) 2009 Sun Microsystems, Inc. +# Use is subject to license terms. +# +# 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 +# the Free Software Foundation; version 2 of the License. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# 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 02110-1301 USA +# # Show the time taken to execute a query, include the bytes and time taken # to transfer the information over the network to/from the client diff --git a/support-files/dtrace/query-parse-time.d b/support-files/dtrace/query-parse-time.d index 31fe1275e1a..211152afdd2 100644 --- a/support-files/dtrace/query-parse-time.d +++ b/support-files/dtrace/query-parse-time.d @@ -1,5 +1,21 @@ #!/usr/sbin/dtrace -s # +# Copyright (c) 2009 Sun Microsystems, Inc. +# Use is subject to license terms. +# +# 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 +# the Free Software Foundation; version 2 of the License. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# 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 02110-1301 USA +# # Shows time take to actually parse the query statement #pragma D option quiet diff --git a/support-files/dtrace/query-rowops.d b/support-files/dtrace/query-rowops.d index a16f3df90f4..04748955f6c 100644 --- a/support-files/dtrace/query-rowops.d +++ b/support-files/dtrace/query-rowops.d @@ -1,5 +1,21 @@ #!/usr/sbin/dtrace -s # +# Copyright (c) 2009 Sun Microsystems, Inc. +# Use is subject to license terms. +# +# 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 +# the Free Software Foundation; version 2 of the License. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# 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 02110-1301 USA +# # Calculates the time (and operations) for accessing data from individual # rows for each query diff --git a/support-files/dtrace/query-time.d b/support-files/dtrace/query-time.d index 9983a73b7e5..98e4b129838 100644 --- a/support-files/dtrace/query-time.d +++ b/support-files/dtrace/query-time.d @@ -1,5 +1,21 @@ #!/usr/sbin/dtrace -s # +# Copyright (c) 2009 Sun Microsystems, Inc. +# Use is subject to license terms. +# +# 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 +# the Free Software Foundation; version 2 of the License. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# 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 02110-1301 USA +# # Shows basic query execution time, who execute the query, and on what database #pragma D option quiet diff --git a/support-files/dtrace/statement-time.d b/support-files/dtrace/statement-time.d index d00fc10348d..10ef57039ad 100644 --- a/support-files/dtrace/statement-time.d +++ b/support-files/dtrace/statement-time.d @@ -1,5 +1,21 @@ #!/usr/sbin/dtrace -s # +# Copyright (c) 2009 Sun Microsystems, Inc. +# Use is subject to license terms. +# +# 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 +# the Free Software Foundation; version 2 of the License. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# 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 02110-1301 USA +# # Creates a report on each query executed at the individual statement # level, showing rows matched, updated, and total query time diff --git a/support-files/dtrace/statement-type-aggregate.d b/support-files/dtrace/statement-type-aggregate.d index 32d88cb5143..784ee4aee9b 100644 --- a/support-files/dtrace/statement-type-aggregate.d +++ b/support-files/dtrace/statement-type-aggregate.d @@ -1,5 +1,21 @@ #!/usr/sbin/dtrace -s # +# Copyright (c) 2009 Sun Microsystems, Inc. +# Use is subject to license terms. +# +# 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 +# the Free Software Foundation; version 2 of the License. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# 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 02110-1301 USA +# # Creates an aggregate report of the time spent perform queries of the four main # types (select, insert, update, delete) # diff --git a/support-files/mysql.spec.sh b/support-files/mysql.spec.sh index 7e9e8faae46..fad745676e5 100644 --- a/support-files/mysql.spec.sh +++ b/support-files/mysql.spec.sh @@ -127,55 +127,74 @@ %define distro_description Oracle Enterprise Linux 4 %define distro_releasetag oel4 %define distro_buildreq gcc-c++ gperf ncurses-devel perl readline-devel time zlib-devel - %define distro_requires chkconfig coreutils grep procps shadow-utils + %define distro_requires chkconfig coreutils grep procps shadow-utils net-tools %else %if "%oelver" == "5" %define distro_description Oracle Enterprise Linux 5 %define distro_releasetag oel5 %define distro_buildreq gcc-c++ gperf ncurses-devel perl readline-devel time zlib-devel - %define distro_requires chkconfig coreutils grep procps shadow-utils + %define distro_requires chkconfig coreutils grep procps shadow-utils net-tools %else %{error:Oracle Enterprise Linux %{oelver} is unsupported} %endif %endif %else - %if %(test -f /etc/redhat-release && echo 1 || echo 0) - %define rhelver %(rpm -qf --qf '%%{version}\\n' /etc/redhat-release | sed -e 's/^\\([0-9]*\\).*/\\1/g') - %if "%rhelver" == "4" - %define distro_description Red Hat Enterprise Linux 4 - %define distro_releasetag rhel4 - %define distro_buildreq gcc-c++ gperf ncurses-devel perl readline-devel time zlib-devel - %define distro_requires chkconfig coreutils grep procps shadow-utils + %if %(test -f /etc/oracle-release && echo 1 || echo 0) + %define elver %(rpm -qf --qf '%%{version}\\n' /etc/oracle-release | sed -e 's/^\\([0-9]*\\).*/\\1/g') + %if "%elver" == "6" + %define distro_description Oracle Linux 6 + %define distro_releasetag el6 + %define distro_buildreq gcc-c++ ncurses-devel perl readline-devel time zlib-devel + %define distro_requires chkconfig coreutils grep procps shadow-utils net-tools %else - %if "%rhelver" == "5" - %define distro_description Red Hat Enterprise Linux 5 - %define distro_releasetag rhel5 - %define distro_buildreq gcc-c++ gperf ncurses-devel perl readline-devel time zlib-devel - %define distro_requires chkconfig coreutils grep procps shadow-utils - %else - %{error:Red Hat Enterprise Linux %{rhelver} is unsupported} - %endif + %{error:Oracle Linux %{elver} is unsupported} %endif %else - %if %(test -f /etc/SuSE-release && echo 1 || echo 0) - %define susever %(rpm -qf --qf '%%{version}\\n' /etc/SuSE-release) - %if "%susever" == "10" - %define distro_description SUSE Linux Enterprise Server 10 - %define distro_releasetag sles10 - %define distro_buildreq gcc-c++ gdbm-devel gperf ncurses-devel openldap2-client readline-devel zlib-devel - %define distro_requires aaa_base coreutils grep procps pwdutils + %if %(test -f /etc/redhat-release && echo 1 || echo 0) + %define rhelver %(rpm -qf --qf '%%{version}\\n' /etc/redhat-release | sed -e 's/^\\([0-9]*\\).*/\\1/g') + %if "%rhelver" == "4" + %define distro_description Red Hat Enterprise Linux 4 + %define distro_releasetag rhel4 + %define distro_buildreq gcc-c++ gperf ncurses-devel perl readline-devel time zlib-devel + %define distro_requires chkconfig coreutils grep procps shadow-utils net-tools %else - %if "%susever" == "11" - %define distro_description SUSE Linux Enterprise Server 11 - %define distro_releasetag sles11 - %define distro_buildreq gcc-c++ gdbm-devel gperf ncurses-devel openldap2-client procps pwdutils readline-devel zlib-devel - %define distro_requires aaa_base coreutils grep procps pwdutils + %if "%rhelver" == "5" + %define distro_description Red Hat Enterprise Linux 5 + %define distro_releasetag rhel5 + %define distro_buildreq gcc-c++ gperf ncurses-devel perl readline-devel time zlib-devel + %define distro_requires chkconfig coreutils grep procps shadow-utils net-tools %else - %{error:SuSE %{susever} is unsupported} + %if "%rhelver" == "6" + %define distro_description Red Hat Enterprise Linux 6 + %define distro_releasetag rhel6 + %define distro_buildreq gcc-c++ ncurses-devel perl readline-devel time zlib-devel + %define distro_requires chkconfig coreutils grep procps shadow-utils net-tools + %else + %{error:Red Hat Enterprise Linux %{rhelver} is unsupported} + %endif %endif %endif %else - %{error:Unsupported distribution} + %if %(test -f /etc/SuSE-release && echo 1 || echo 0) + %define susever %(rpm -qf --qf '%%{version}\\n' /etc/SuSE-release) + %if "%susever" == "10" + %define distro_description SUSE Linux Enterprise Server 10 + %define distro_releasetag sles10 + %define distro_buildreq gcc-c++ gdbm-devel gperf ncurses-devel openldap2-client readline-devel zlib-devel + %define distro_requires aaa_base coreutils grep procps pwdutils + %else + %if "%susever" == "11" + %define distro_description SUSE Linux Enterprise Server 11 + %define distro_releasetag sles11 + %define distro_buildreq gcc-c++ gdbm-devel gperf ncurses-devel openldap2-client procps pwdutils readline-devel zlib-devel + %define distro_requires aaa_base coreutils grep procps pwdutils + %else + %{error:SuSE %{susever} is unsupported} + %endif + %endif + %else + %{error:Unsupported distribution} + %endif %endif %endif %endif @@ -225,10 +244,10 @@ Group: Applications/Databases Version: @MYSQL_RPM_VERSION@ Release: %{release}%{?distro_releasetag:.%{distro_releasetag}} Distribution: %{distro_description} -License: Copyright (c) 2000, @MYSQL_COPYRIGHT_YEAR@, %{mysql_vendor}. All rights reserved. Use is subject to license terms. Under %{license_type} license as shown in the Description field. +License: Copyright (c) 2000, @MYSQL_COPYRIGHT_YEAR@, %{mysql_vendor}. All rights reserved. Under %{license_type} license as shown in the Description field. Source: http://www.mysql.com/Downloads/MySQL-@MYSQL_BASE_VERSION@/%{src_dir}.tar.gz URL: http://www.mysql.com/ -Packager: MySQL Build Team <build@mysql.com> +Packager: MySQL Release Engineering <mysql-build@oss.oracle.com> Vendor: %{mysql_vendor} Provides: msqlormysql MySQL-server mysql BuildRequires: %{distro_buildreq} @@ -261,11 +280,13 @@ documentation and the manual for more information. ############################################################################## %package -n MySQL-server%{product_suffix} -Summary: MySQL: a very fast and reliable SQL database server -Group: Applications/Databases -Requires: %{distro_requires} -Provides: msqlormysql mysql-server mysql MySQL MySQL-server -Obsoletes: MySQL mysql mysql-server MySQL-server MySQL-server-community +Summary: MySQL: a very fast and reliable SQL database server +Group: Applications/Databases +Requires: %{distro_requires} +Provides: msqlormysql mysql MySQL mysql-server MySQL-server +Obsoletes: mysql MySQL mysql-server MySQL-server +Obsoletes: MySQL-server-classic MySQL-server-community MySQL-server-enterprise +Obsoletes: MySQL-server-advanced MySQL-server-advanced-gpl MySQL-server-enterprise-gpl %description -n MySQL-server%{product_suffix} The MySQL(TM) software delivers a very fast, multi-threaded, multi-user, @@ -293,10 +314,12 @@ package "MySQL-client%{product_suffix}" as well! # ---------------------------------------------------------------------------- %package -n MySQL-client%{product_suffix} -Summary: MySQL - Client -Group: Applications/Databases -Obsoletes: mysql-client MySQL-client MySQL-client-community -Provides: mysql-client MySQL-client +Summary: MySQL - Client +Group: Applications/Databases +Provides: mysql-client MySQL-client +Obsoletes: mysql-client MySQL-client +Obsoletes: MySQL-client-classic MySQL-client-community MySQL-client-enterprise +Obsoletes: MySQL-client-advanced MySQL-client-advanced-gpl MySQL-client-enterprise-gpl %description -n MySQL-client%{product_suffix} This package contains the standard MySQL clients and administration tools. @@ -305,12 +328,15 @@ For a description of MySQL see the base MySQL RPM or http://www.mysql.com/ # ---------------------------------------------------------------------------- %package -n MySQL-test%{product_suffix} -Requires: MySQL-client%{product_suffix} perl -Summary: MySQL - Test suite -Group: Applications/Databases -Provides: mysql-test -Obsoletes: mysql-bench mysql-test MySQL-test-community -AutoReqProv: no +Summary: MySQL - Test suite +Group: Applications/Databases +Requires: MySQL-client perl +Provides: mysql-test MySQL-test +Obsoletes: mysql-test MySQL-test +Obsoletes: mysql-bench MySQL-bench +Obsoletes: MySQL-test-classic MySQL-test-community MySQL-test-enterprise +Obsoletes: MySQL-test-advanced MySQL-test-advanced-gpl MySQL-test-enterprise-gpl +AutoReqProv: no %description -n MySQL-test%{product_suffix} This package contains the MySQL regression test suite. @@ -319,10 +345,12 @@ For a description of MySQL see the base MySQL RPM or http://www.mysql.com/ # ---------------------------------------------------------------------------- %package -n MySQL-devel%{product_suffix} -Summary: MySQL - Development header files and libraries -Group: Applications/Databases -Provides: mysql-devel -Obsoletes: mysql-devel MySQL-devel-community +Summary: MySQL - Development header files and libraries +Group: Applications/Databases +Provides: mysql-devel MySQL-devel +Obsoletes: mysql-devel MySQL-devel +Obsoletes: MySQL-devel-classic MySQL-devel-community MySQL-devel-enterprise +Obsoletes: MySQL-devel-advanced MySQL-devel-advanced-gpl MySQL-devel-enterprise-gpl %description -n MySQL-devel%{product_suffix} This package contains the development header files and libraries necessary @@ -332,10 +360,14 @@ For a description of MySQL see the base MySQL RPM or http://www.mysql.com/ # ---------------------------------------------------------------------------- %package -n MySQL-shared%{product_suffix} -Summary: MySQL - Shared libraries -Group: Applications/Databases -Provides: mysql-shared -Obsoletes: MySQL-shared-community +Summary: MySQL - Shared libraries +Group: Applications/Databases +Provides: mysql-shared MySQL-shared +Obsoletes: mysql-shared MySQL-shared-standard MySQL-shared-pro +Obsoletes: MySQL-shared-pro-cert MySQL-shared-pro-gpl +Obsoletes: MySQL-shared-pro-gpl-cert MySQL-shared +Obsoletes: MySQL-shared-classic MySQL-shared-community MySQL-shared-enterprise +Obsoletes: MySQL-shared-advanced MySQL-shared-advanced-gpl MySQL-shared-enterprise-gpl %description -n MySQL-shared%{product_suffix} This package contains the shared libraries (*.so*) which certain languages @@ -343,10 +375,14 @@ and applications need to dynamically load and use MySQL. # ---------------------------------------------------------------------------- %package -n MySQL-embedded%{product_suffix} -Summary: MySQL - embedded library -Group: Applications/Databases -Requires: MySQL-devel%{product_suffix} -Obsoletes: mysql-embedded MySQL-embedded-community +Summary: MySQL - Embedded library +Group: Applications/Databases +Requires: MySQL-devel +Provides: mysql-embedded MySQL-embedded +Obsoletes: mysql-embedded MySQL-embedded +Obsoletes: MySQL-embedded-pro +Obsoletes: MySQL-embedded-classic MySQL-embedded-community MySQL-embedded-enterprise +Obsoletes: MySQL-embedded-advanced MySQL-embedded-advanced-gpl MySQL-embedded-enterprise-gpl %description -n MySQL-embedded%{product_suffix} This package contains the MySQL server as an embedded library. @@ -421,7 +457,7 @@ mkdir debug # XXX: install_layout so we can't just set it based on INSTALL_LAYOUT=RPM ${CMAKE} ../%{src_dir} -DBUILD_CONFIG=mysql_release -DINSTALL_LAYOUT=RPM \ -DCMAKE_BUILD_TYPE=Debug \ - -DMYSQL_UNIX_ADDR="/var/lib/mysql/mysql.sock" \ + -DMYSQL_UNIX_ADDR="%{mysqldatadir}/mysql.sock" \ -DFEATURE_SET="%{feature_set}" \ -DCOMPILATION_COMMENT="%{compilation_comment_debug}" \ -DMYSQL_SERVER_SUFFIX="%{server_suffix}" @@ -436,7 +472,7 @@ mkdir release # XXX: install_layout so we can't just set it based on INSTALL_LAYOUT=RPM ${CMAKE} ../%{src_dir} -DBUILD_CONFIG=mysql_release -DINSTALL_LAYOUT=RPM \ -DCMAKE_BUILD_TYPE=RelWithDebInfo \ - -DMYSQL_UNIX_ADDR="/var/lib/mysql/mysql.sock" \ + -DMYSQL_UNIX_ADDR="%{mysqldatadir}/mysql.sock" \ -DFEATURE_SET="%{feature_set}" \ -DCOMPILATION_COMMENT="%{compilation_comment_release}" \ -DMYSQL_SERVER_SUFFIX="%{server_suffix}" @@ -444,25 +480,6 @@ mkdir release make ${MAKE_JFLAG} VERBOSE=1 ) -# Use the build root for temporary storage of the shared libraries. -RBR=$RPM_BUILD_ROOT - -# Clean up the BuildRoot first -[ "$RBR" != "/" ] && [ -d "$RBR" ] && rm -rf "$RBR"; - -# For gcc builds, include libgcc.a in the devel subpackage (BUG 4921). This -# needs to be during build phase as $CC is not set during install. -if "$CC" -v 2>&1 | grep '^gcc.version' >/dev/null 2>&1 -then - libgcc=`$CC $CFLAGS --print-libgcc-file` - if [ -f $libgcc ] - then - mkdir -p $RBR%{_libdir}/mysql - install -m 644 $libgcc $RBR%{_libdir}/mysql/libmygcc.a - echo "%{_libdir}/mysql/libmygcc.a" >>optional-files-devel - fi -fi - ############################################################################## %install @@ -485,6 +502,23 @@ install -d $RBR%{_sbindir} make DESTDIR=$RBR install ) +# For gcc builds, include libgcc.a in the devel subpackage (BUG 4921). Do +# this in a sub-shell to ensure we don't pollute the install environment +# with compiler bits. +( + PATH=${MYSQL_BUILD_PATH:-$PATH} + CC=${MYSQL_BUILD_CC:-${CC:-gcc}} + CFLAGS=${MYSQL_BUILD_CFLAGS:-${CFLAGS:-$RPM_OPT_FLAGS}} + if "${CC}" -v 2>&1 | grep '^gcc.version' >/dev/null 2>&1; then + libgcc=`${CC} ${CFLAGS} --print-libgcc-file` + if [ -f ${libgcc} ]; then + mkdir -p $RBR%{_libdir}/mysql + install -m 644 ${libgcc} $RBR%{_libdir}/mysql/libmygcc.a + echo "%{_libdir}/mysql/libmygcc.a" >>optional-files-devel + fi + fi +) + # FIXME: at some point we should stop doing this and just install everything # FIXME: directly into %{_libdir}/mysql - perhaps at the same time as renaming # FIXME: the shared libraries to use libmysql*-$major.$minor.so syntax @@ -516,7 +550,7 @@ install -m 644 "%{malloc_lib_source}" \ # Remove man pages we explicitly do not want to package, avoids 'unpackaged # files' warning. -rm -f $RBR%{_mandir}/man1/make_win_bin_dist.1* +# This has become obsolete: rm -f $RBR%{_mandir}/man1/make_win_bin_dist.1* ############################################################################## # Post processing actions, i.e. when installed @@ -721,13 +755,12 @@ else fi # echo "Analyzed: SERVER_TO_START=$SERVER_TO_START" if [ ! -d $mysql_datadir/mysql ] ; then - mkdir $mysql_datadir/mysql; + mkdir $mysql_datadir/mysql $mysql_datadir/test echo "MySQL RPM installation of version $NEW_VERSION" >> $STATUS_FILE else # If the directory exists, we may assume it is an upgrade. echo "MySQL RPM upgrade to version $NEW_VERSION" >> $STATUS_FILE fi -if [ ! -d $mysql_datadir/test ] ; then mkdir $mysql_datadir/test; fi # ---------------------------------------------------------------------- # Make MySQL start/shutdown automatically when the machine does it. @@ -762,7 +795,12 @@ chown -R %{mysqld_user}:%{mysqld_group} $mysql_datadir # ---------------------------------------------------------------------- # Initiate databases if needed # ---------------------------------------------------------------------- -%{_bindir}/mysql_install_db --rpm --user=%{mysqld_user} +if ! grep '^MySQL RPM upgrade' $STATUS_FILE >/dev/null 2>&1 ; then + # Fix bug#45415: no "mysql_install_db" on an upgrade + # Do this as a negative to err towards more "install" runs + # rather than to miss one. + %{_bindir}/mysql_install_db --rpm --user=%{mysqld_user} +fi # ---------------------------------------------------------------------- # Upgrade databases if needed would go here - but it cannot be automated yet @@ -940,7 +978,7 @@ echo "=====" >> $STATUS_HISTORY # Files section ############################################################################## -%files -n MySQL-server%{product_suffix} +%files -n MySQL-server%{product_suffix} -f release/support-files/plugins.files %defattr(-,root,root,0755) %if %{defined license_files_server} @@ -966,6 +1004,7 @@ echo "=====" >> $STATUS_HISTORY %doc %attr(644, root, man) %{_mandir}/man1/mysqld_safe.1* %doc %attr(644, root, man) %{_mandir}/man1/mysqldumpslow.1* %doc %attr(644, root, man) %{_mandir}/man1/mysql_install_db.1* +%doc %attr(644, root, man) %{_mandir}/man1/mysql_plugin.1* %doc %attr(644, root, man) %{_mandir}/man1/mysql_secure_installation.1* %doc %attr(644, root, man) %{_mandir}/man1/mysql_setpermission.1* %doc %attr(644, root, man) %{_mandir}/man1/mysql_upgrade.1* @@ -980,6 +1019,7 @@ echo "=====" >> $STATUS_HISTORY %doc %attr(644, root, man) %{_mandir}/man1/replace.1* %doc %attr(644, root, man) %{_mandir}/man1/resolve_stack_dump.1* %doc %attr(644, root, man) %{_mandir}/man1/resolveip.1* +%doc %attr(644, root, man) %{_mandir}/man1/mysql_plugin.1* %ghost %config(noreplace,missingok) %{_sysconfdir}/my.cnf @@ -992,10 +1032,12 @@ echo "=====" >> $STATUS_HISTORY %attr(755, root, root) %{_bindir}/mysql_convert_table_format %attr(755, root, root) %{_bindir}/mysql_fix_extensions %attr(755, root, root) %{_bindir}/mysql_install_db +%attr(755, root, root) %{_bindir}/mysql_plugin %attr(755, root, root) %{_bindir}/mysql_secure_installation %attr(755, root, root) %{_bindir}/mysql_setpermission %attr(755, root, root) %{_bindir}/mysql_tzinfo_to_sql %attr(755, root, root) %{_bindir}/mysql_upgrade +%attr(755, root, root) %{_bindir}/mysql_plugin %attr(755, root, root) %{_bindir}/mysql_zap %attr(755, root, root) %{_bindir}/mysqlbug %attr(755, root, root) %{_bindir}/mysqld_multi @@ -1011,28 +1053,7 @@ echo "=====" >> $STATUS_HISTORY %attr(755, root, root) %{_sbindir}/mysqld %attr(755, root, root) %{_sbindir}/mysqld-debug %attr(755, root, root) %{_sbindir}/rcmysql -%attr(755, root, root) %{_libdir}/mysql/plugin/adt_null.so -%attr(755, root, root) %{_libdir}/mysql/plugin/libdaemon_example.so -%attr(755, root, root) %{_libdir}/mysql/plugin/mypluglib.so -%attr(755, root, root) %{_libdir}/mysql/plugin/semisync_master.so -%attr(755, root, root) %{_libdir}/mysql/plugin/semisync_slave.so -%attr(755, root, root) %{_libdir}/mysql/plugin/auth.so -%attr(755, root, root) %{_libdir}/mysql/plugin/auth_socket.so -%attr(755, root, root) %{_libdir}/mysql/plugin/auth_test_plugin.so -%attr(755, root, root) %{_libdir}/mysql/plugin/qa_auth_client.so -%attr(755, root, root) %{_libdir}/mysql/plugin/qa_auth_interface.so -%attr(755, root, root) %{_libdir}/mysql/plugin/qa_auth_server.so -%attr(755, root, root) %{_libdir}/mysql/plugin/debug/adt_null.so -%attr(755, root, root) %{_libdir}/mysql/plugin/debug/libdaemon_example.so -%attr(755, root, root) %{_libdir}/mysql/plugin/debug/mypluglib.so -%attr(755, root, root) %{_libdir}/mysql/plugin/debug/semisync_master.so -%attr(755, root, root) %{_libdir}/mysql/plugin/debug/semisync_slave.so -%attr(755, root, root) %{_libdir}/mysql/plugin/debug/auth.so -%attr(755, root, root) %{_libdir}/mysql/plugin/debug/auth_socket.so -%attr(755, root, root) %{_libdir}/mysql/plugin/debug/auth_test_plugin.so -%attr(755, root, root) %{_libdir}/mysql/plugin/debug/qa_auth_client.so -%attr(755, root, root) %{_libdir}/mysql/plugin/debug/qa_auth_interface.so -%attr(755, root, root) %{_libdir}/mysql/plugin/debug/qa_auth_server.so +%attr(755, root, root) %{_libdir}/mysql/plugin/daemon_example.ini %if %{WITH_TCMALLOC} %attr(755, root, root) %{_libdir}/mysql/%{malloc_lib_target} @@ -1117,6 +1138,7 @@ echo "=====" >> $STATUS_HISTORY # ---------------------------------------------------------------------------- %files -n MySQL-embedded%{product_suffix} %defattr(-, root, root, 0755) +%attr(755, root, root) %{_bindir}/mysql_embedded %attr(644, root, root) %{_libdir}/mysql/libmysqld.a %attr(644, root, root) %{_libdir}/mysql/libmysqld-debug.a @@ -1126,6 +1148,59 @@ echo "=====" >> $STATUS_HISTORY # merging BK trees) ############################################################################## %changelog +* Wed Sep 14 2011 Joerg Bruehe <joerg.bruehe@oracle.com> + +- Let the RPM capabilities ("obsoletes" etc) ensure that an upgrade may replace + the RPMs of any configuration (of the current or the preceding release series) + by the new ones. This is done by not using the implicitly generated capabilities + (which include the configuration name) and relying on more generic ones which + just list the function ("server", "client", ...). + The implicit generation cannot be prevented, so all these capabilities must be + explicitly listed in "Obsoletes:" + +* Tue Sep 13 2011 Jonathan Perkin <jonathan.perkin@oracle.com> + +- Add support for Oracle Linux 6 and Red Hat Enterprise Linux 6. Due to + changes in RPM behaviour ($RPM_BUILD_ROOT is removed prior to install) + this necessitated a move of the libmygcc.a installation to the install + phase, which is probably where it belonged in the first place. + +* Tue Sep 13 2011 Joerg Bruehe <joerg.bruehe@oracle.com> + +- "make_win_bin_dist" and its manual are dropped, cmake does it different. + +* Thu Sep 08 2011 Daniel Fischer <daniel.fischer@oracle.com> + +- Add mysql_plugin man page. + +* Tue Aug 30 2011 Joerg Bruehe <joerg.bruehe@oracle.com> + +- Add the manual page for "mysql_plugin" to the server package. + +* Fri Aug 19 2011 Joerg Bruehe <joerg.bruehe@oracle.com> + +- Null-upmerge the fix of bug#37165: This spec file is not affected. +- Replace "/var/lib/mysql" by the spec file variable "%{mysqldatadir}". + +* Fri Aug 12 2011 Daniel Fischer <daniel.fischer@oracle.com> + +- Source plugin library files list from cmake-generated file. + +* Mon Jul 25 2011 Chuck Bell <chuck.bell@oracle.com> + +- Added the mysql_plugin client - enables or disables plugins. + +* Thu Jul 21 2011 Sunanda Menon <sunanda.menon@oracle.com> + +- Fix bug#12561297: Added the MySQL embedded binary + +* Thu Jul 07 2011 Joerg Bruehe <joerg.bruehe@oracle.com> + +- Fix bug#45415: "rpm upgrade recreates test database" + Let the creation of the "test" database happen only during a new installation, + not in an RPM upgrade. + This affects both the "mkdir" and the call of "mysql_install_db". + * Thu Feb 09 2011 Joerg Bruehe <joerg.bruehe@oracle.com> - Fix bug#56581: If an installation deviates from the default file locations diff --git a/support-files/ndb-config-2-node.ini.sh b/support-files/ndb-config-2-node.ini.sh index be80f1dd0b3..cf3bbfc436e 100644 --- a/support-files/ndb-config-2-node.ini.sh +++ b/support-files/ndb-config-2-node.ini.sh @@ -1,3 +1,18 @@ +# Copyright (c) 2006, 2010, Oracle and/or its affiliates. All rights reserved. +# +# 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 +# the Free Software Foundation; version 2 of the License. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# 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 02110-1301 USA +# # Example Ndbcluster storage engine config file. # [ndbd default] diff --git a/tests/big_record.pl b/tests/big_record.pl index ceedb6f114a..0d5766e5f5d 100755 --- a/tests/big_record.pl +++ b/tests/big_record.pl @@ -1,6 +1,6 @@ #!/usr/bin/perl -# Copyright (C) 2000, 2003 MySQL AB +# Copyright (c) 2000, 2010, Oracle and/or its affiliates. All rights reserved. # # 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 @@ -13,7 +13,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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA # This is a test with stores big records in a blob. # Note that for the default test the mysql server should have been diff --git a/tests/bug25714.c b/tests/bug25714.c index c0d9fbf7652..40c631d76a5 100644 --- a/tests/bug25714.c +++ b/tests/bug25714.c @@ -1,4 +1,5 @@ -/* Copyright (C) 2007 MySQL AB +/* Copyright (c) 2007 MySQL AB, 2009 Sun Microsystems, Inc. + Use is subject to license terms. 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 @@ -11,7 +12,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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ #include <my_global.h> #include <my_sys.h> diff --git a/tests/grant.pl b/tests/grant.pl index 368ce0b3254..23a7d2110fb 100755 --- a/tests/grant.pl +++ b/tests/grant.pl @@ -1,6 +1,7 @@ #!/usr/bin/perl -# Copyright (C) 2000, 2005 MySQL AB, 2009 Sun Microsystems, Inc. +# Copyright (c) 2000, 2005 MySQL AB, 2009 Sun Microsystems, Inc. +# Use is subject to license terms. # # 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 @@ -13,7 +14,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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA # # Testing of grants. diff --git a/tests/mysql_client_test.c b/tests/mysql_client_test.c index f8cdc57b4be..d62220e2aa8 100644 --- a/tests/mysql_client_test.c +++ b/tests/mysql_client_test.c @@ -13486,7 +13486,10 @@ static void test_truncation() ")"; rc= mysql_real_query(mysql, stmt_text, strlen(stmt_text)); myquery(rc); - stmt_text= "insert into t1 VALUES (" + + { + const char insert_text[]= + "insert into t1 VALUES (" "-10, " /* i8 */ "200, " /* ui8 */ "32000, " /* i16 */ @@ -13502,8 +13505,9 @@ static void test_truncation() "'12345.67 ', " /* tx_1 */ "'12345.67abc'" /* ch_2 */ ")"; - rc= mysql_real_query(mysql, stmt_text, strlen(stmt_text)); - myquery(rc); + rc= mysql_real_query(mysql, insert_text, strlen(insert_text)); + myquery(rc); + } stmt_text= "select i8 c1, i8 c2, ui8 c3, i16_1 c4, ui16 c5, " " i16 c6, ui16 c7, i32 c8, i32_1 c9, i32_1 c10, " @@ -18638,11 +18642,8 @@ static void test_bug38486(void) static void test_bug33831(void) { MYSQL *l_mysql; - my_bool error; DBUG_ENTER("test_bug33831"); - - error= 0; if (!(l_mysql= mysql_client_init(NULL))) { @@ -18665,9 +18666,8 @@ static void test_bug33831(void) DIE_UNLESS(0); } - mysql_close(l_mysql); - + DBUG_VOID_RETURN; } @@ -19774,6 +19774,34 @@ static void test_bug12337762() DBUG_VOID_RETURN; } + +/* + BUG 11754979 - 46675: ON DUPLICATE KEY UPDATE AND UPDATECOUNT() POSSIBLY WRONG +*/ + +static void test_bug11754979() +{ + MYSQL* conn; + DBUG_ENTER("test_bug11754979"); + + myheader("test_bug11754979"); + DIE_UNLESS((conn= mysql_client_init(NULL))); + DIE_UNLESS(mysql_real_connect(conn, opt_host, opt_user, + opt_password, opt_db ? opt_db:"test", opt_port, + opt_unix_socket, CLIENT_FOUND_ROWS)); + myquery(mysql_query(conn, "DROP TABLE IF EXISTS t1")); + myquery(mysql_query(conn, "CREATE TABLE t1(id INT, label CHAR(1), PRIMARY KEY(id))")); + myquery(mysql_query(conn, "INSERT INTO t1(id, label) VALUES (1, 'a')")); + myquery(mysql_query(conn, "INSERT INTO t1(id, label) VALUES (1, 'a') " + "ON DUPLICATE KEY UPDATE id = 4")); + DIE_UNLESS(mysql_affected_rows(conn) == 2); + myquery(mysql_query(conn, "DROP TABLE t1")); + mysql_close(conn); + + DBUG_VOID_RETURN; +} + + /* Read and parse arguments and MySQL options from my.cnf */ @@ -20119,6 +20147,7 @@ static struct my_tests_st my_tests[]= { { "test_bug11766854", test_bug11766854 }, { "test_bug12337762", test_bug12337762 }, { "test_progress_reporting", test_progress_reporting }, + { "test_bug11754979", test_bug11754979 }, { 0, 0 } }; diff --git a/tests/thread_test.c b/tests/thread_test.c index e0be59aa7c5..bf0fb8ea2c0 100644 --- a/tests/thread_test.c +++ b/tests/thread_test.c @@ -1,4 +1,4 @@ -/* Copyright (C) 2000 MySQL AB +/* Copyright (c) 2000, 2011, Oracle and/or its affiliates. All rights reserved. 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 @@ -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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ #include <my_global.h> diff --git a/unittest/examples/core-t.c b/unittest/examples/core-t.c index a9b798d3064..5f49e1cb1d9 100644 --- a/unittest/examples/core-t.c +++ b/unittest/examples/core-t.c @@ -1,4 +1,5 @@ -/* Copyright (C) 2006 MySQL AB +/* Copyright (c) 2006 MySQL AB, 2009 Sun Microsystems, Inc. + Use is subject to license terms. 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/unittest/examples/skip-t.c b/unittest/examples/skip-t.c index c8c910b31ff..aa105385c17 100644 --- a/unittest/examples/skip-t.c +++ b/unittest/examples/skip-t.c @@ -1,4 +1,4 @@ -/* Copyright (C) 2006 MySQL AB +/* Copyright (c) 2006, 2010, Oracle and/or its affiliates. All rights reserved. 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/unittest/examples/skip_all-t.c b/unittest/examples/skip_all-t.c index 3751642293b..940d9f0186f 100644 --- a/unittest/examples/skip_all-t.c +++ b/unittest/examples/skip_all-t.c @@ -1,4 +1,4 @@ -/* Copyright (C) 2006 MySQL AB +/* Copyright (c) 2006, 2010, Oracle and/or its affiliates. All rights reserved. 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/unittest/examples/todo-t.c b/unittest/examples/todo-t.c index 67bea51965c..53aaa1c2813 100644 --- a/unittest/examples/todo-t.c +++ b/unittest/examples/todo-t.c @@ -1,4 +1,4 @@ -/* Copyright (C) 2006 MySQL AB +/* Copyright (c) 2006, 2010, Oracle and/or its affiliates. All rights reserved. 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/unittest/mysys/base64-t.c b/unittest/mysys/base64-t.c index cb0437f947c..d610ad52b79 100644 --- a/unittest/mysys/base64-t.c +++ b/unittest/mysys/base64-t.c @@ -1,4 +1,5 @@ -/* Copyright (C) 2003 MySQL AB +/* Copyright (c) 2003, 2006, 2007 MySQL AB, 2009 Sun Microsystems, Inc. + Use is subject to license terms. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as @@ -11,7 +12,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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ #include <my_global.h> #include <my_sys.h> diff --git a/unittest/mysys/bitmap-t.c b/unittest/mysys/bitmap-t.c index 2065e10b53f..75250d157e1 100644 --- a/unittest/mysys/bitmap-t.c +++ b/unittest/mysys/bitmap-t.c @@ -1,4 +1,5 @@ -/* Copyright (c) 2000, 2011, Oracle and/or its affiliates. All rights reserved. +/* + Copyright (c) 2006, 2011, Oracle and/or its affiliates. All rights reserved. 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 @@ -11,7 +12,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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA This test was copied from the unit test inside the mysys/my_bitmap.c file and adapted by Mats Kindahl to use the mytap diff --git a/unittest/mysys/lf-t.c b/unittest/mysys/lf-t.c index c04ef358abe..573a56cc1d6 100644 --- a/unittest/mysys/lf-t.c +++ b/unittest/mysys/lf-t.c @@ -1,4 +1,4 @@ -/* Copyright (C) 2008-2008 MySQL AB, 2008-2009 Sun Microsystems, Inc. +/* Copyright (c) 2008, 2011, Oracle and/or its affiliates. All rights reserved. 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 @@ -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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ /** @file @@ -34,8 +34,7 @@ int with_my_thread_init=0; */ pthread_handler_t test_lf_pinbox(void *arg) { - int m= *(int *)arg; - int32 x= 0; + int m= *(int *)arg; LF_PINS *pins; if (with_my_thread_init) @@ -43,7 +42,7 @@ pthread_handler_t test_lf_pinbox(void *arg) pins= lf_pinbox_get_pins(&lf_allocator.pinbox); - for (x= ((int)(intptr)(&m)); m ; m--) + for (; m ; m--) { lf_pinbox_put_pins(pins); pins= lf_pinbox_get_pins(&lf_allocator.pinbox); diff --git a/unittest/mysys/ma_dyncol-t.c b/unittest/mysys/ma_dyncol-t.c index 0e973b20747..11731ae81d4 100644 --- a/unittest/mysys/ma_dyncol-t.c +++ b/unittest/mysys/ma_dyncol-t.c @@ -61,7 +61,7 @@ void test_value_single_uint(ulonglong num, const char *name) DYNAMIC_COLUMN str; /* init values */ val.type= DYN_COL_UINT; - val.ulong_value= num; + val.x.ulong_value= num; dynamic_column_value_init(&res); /* create column */ if (dynamic_column_create(&str, 1, &val)) @@ -70,8 +70,8 @@ void test_value_single_uint(ulonglong num, const char *name) /* read column */ if (dynamic_column_get(&str, 1, &res)) goto err; - rc= (res.type == DYN_COL_UINT) && (res.ulong_value == num); - num= res.ulong_value; + rc= (res.type == DYN_COL_UINT) && (res.x.ulong_value == num); + num= res.x.ulong_value; err: ok(rc, "%s - %llu", name, num); /* cleanup */ @@ -85,7 +85,7 @@ void test_value_single_sint(longlong num, const char *name) DYNAMIC_COLUMN str; /* init values */ val.type= DYN_COL_INT; - val.long_value= num; + val.x.long_value= num; dynamic_column_value_init(&res); /* create column */ if (dynamic_column_create(&str, 1, &val)) @@ -94,8 +94,8 @@ void test_value_single_sint(longlong num, const char *name) /* read column */ if (dynamic_column_get(&str, 1, &res)) goto err; - rc= (res.type == DYN_COL_INT) && (res.long_value == num); - num= res.ulong_value; + rc= (res.type == DYN_COL_INT) && (res.x.long_value == num); + num= res.x.ulong_value; err: ok(rc, "%s - %lld", name, num); /* cleanup */ @@ -110,7 +110,7 @@ void test_value_single_double(double num, const char *name) DYNAMIC_COLUMN str; /* init values */ val.type= DYN_COL_DOUBLE; - val.double_value= num; + val.x.double_value= num; dynamic_column_value_init(&res); /* create column */ if (dynamic_column_create(&str, 1, &val)) @@ -119,8 +119,8 @@ void test_value_single_double(double num, const char *name) /* read column */ if (dynamic_column_get(&str, 1, &res)) goto err; - rc= (res.type == DYN_COL_DOUBLE) && (res.double_value == num); - num= res.ulong_value; + rc= (res.type == DYN_COL_DOUBLE) && (res.x.double_value == num); + num= res.x.ulong_value; err: ok(rc, "%s - %lf", name, num); /* cleanup */ @@ -138,7 +138,7 @@ void test_value_single_decimal(const char *num) /* init values */ dynamic_column_prepare_decimal(&val); // special procedure for decimal!!! - if (string2decimal(num, &val.decimal_value, &end) != E_DEC_OK) + if (string2decimal(num, &val.x.decimal.value, &end) != E_DEC_OK) goto err; dynamic_column_value_init(&res); @@ -150,8 +150,8 @@ void test_value_single_decimal(const char *num) if (dynamic_column_get(&str, 1, &res)) goto err; rc= ((res.type == DYN_COL_DECIMAL) && - (decimal_cmp(&res.decimal_value, &val.decimal_value) == 0)); - decimal2string(&res.decimal_value, buff, &length, 0, 0, ' '); + (decimal_cmp(&res.x.decimal.value, &val.x.decimal.value) == 0)); + decimal2string(&res.x.decimal.value, buff, &length, 0, 0, ' '); err: ok(rc, "%s - %s", num, buff); /* cleanup */ @@ -211,9 +211,9 @@ void test_value_single_string(const char *string, size_t len, /* init values */ val.type= DYN_COL_STRING; - val.string_value.str= (char*)string; - val.string_value.length= len; - val.charset= cs; + val.x.string.value.str= (char*)string; + val.x.string.value.length= len; + val.x.string.charset= cs; dynamic_column_value_init(&res); /* create column */ @@ -224,15 +224,15 @@ void test_value_single_string(const char *string, size_t len, if (dynamic_column_get(&str, 1, &res)) goto err; rc= ((res.type == DYN_COL_STRING) && - (res.string_value.length == len) && - (memcmp(res.string_value.str, string, len) == 0) && - (res.charset->number == cs->number)); + (res.x.string.value.length == len) && + (memcmp(res.x.string.value.str, string, len) == 0) && + (res.x.string.charset->number == cs->number)); err: ok(rc, "'%s' - '%s' %u %u-%s", string, - res.string_value.str, (uint)res.string_value.length, - (uint)res.charset->number, res.charset->name); + res.x.string.value.str, (uint)res.x.string.value.length, + (uint)res.x.string.charset->number, res.x.string.charset->name); /* cleanup */ - val.string_value.str= NULL; // we did not allocated it + val.x.string.value.str= NULL; // we did not allocated it dynamic_column_column_free(&str); } @@ -243,10 +243,10 @@ void test_value_single_date(uint year, uint month, uint day, const char *name) DYNAMIC_COLUMN str; /* init values */ val.type= DYN_COL_DATE; - val.time_value.time_type= MYSQL_TIMESTAMP_DATE; - val.time_value.year= year; - val.time_value.month= month; - val.time_value.day= day; + val.x.time_value.time_type= MYSQL_TIMESTAMP_DATE; + val.x.time_value.year= year; + val.x.time_value.month= month; + val.x.time_value.day= day; dynamic_column_value_init(&res); /* create column */ if (dynamic_column_create(&str, 1, &val)) @@ -256,10 +256,10 @@ void test_value_single_date(uint year, uint month, uint day, const char *name) if (dynamic_column_get(&str, 1, &res)) goto err; rc= ((res.type == DYN_COL_DATE) && - (res.time_value.time_type == MYSQL_TIMESTAMP_DATE) && - (res.time_value.year == year) && - (res.time_value.month == month) && - (res.time_value.day == day)); + (res.x.time_value.time_type == MYSQL_TIMESTAMP_DATE) && + (res.x.time_value.year == year) && + (res.x.time_value.month == month) && + (res.x.time_value.day == day)); err: ok(rc, "%s - %04u-%02u-%02u", name, year, month, day); /* cleanup */ @@ -274,12 +274,12 @@ void test_value_single_time(uint neg, uint hour, uint minute, uint second, DYNAMIC_COLUMN str; /* init values */ val.type= DYN_COL_TIME; - val.time_value.time_type= MYSQL_TIMESTAMP_TIME; - val.time_value.neg= neg; - val.time_value.hour= hour; - val.time_value.minute= minute; - val.time_value.second= second; - val.time_value.second_part= mic; + val.x.time_value.time_type= MYSQL_TIMESTAMP_TIME; + val.x.time_value.neg= neg; + val.x.time_value.hour= hour; + val.x.time_value.minute= minute; + val.x.time_value.second= second; + val.x.time_value.second_part= mic; dynamic_column_value_init(&res); /* create column */ if (dynamic_column_create(&str, 1, &val)) @@ -289,12 +289,12 @@ void test_value_single_time(uint neg, uint hour, uint minute, uint second, if (dynamic_column_get(&str, 1, &res)) goto err; rc= ((res.type == DYN_COL_TIME) && - (res.time_value.time_type == MYSQL_TIMESTAMP_TIME) && - (res.time_value.neg == (int)neg) && - (res.time_value.hour == hour) && - (res.time_value.minute == minute) && - (res.time_value.second == second) && - (res.time_value.second_part == mic)); + (res.x.time_value.time_type == MYSQL_TIMESTAMP_TIME) && + (res.x.time_value.neg == (int)neg) && + (res.x.time_value.hour == hour) && + (res.x.time_value.minute == minute) && + (res.x.time_value.second == second) && + (res.x.time_value.second_part == mic)); err: ok(rc, "%s - %c%02u:%02u:%02u.%06u", name, (neg ? '-' : '+'), hour, minute, second, mic); @@ -312,15 +312,15 @@ void test_value_single_datetime(uint neg, uint year, uint month, uint day, DYNAMIC_COLUMN str; /* init values */ val.type= DYN_COL_DATETIME; - val.time_value.time_type= MYSQL_TIMESTAMP_DATETIME; - val.time_value.neg= neg; - val.time_value.year= year; - val.time_value.month= month; - val.time_value.day= day; - val.time_value.hour= hour; - val.time_value.minute= minute; - val.time_value.second= second; - val.time_value.second_part= mic; + val.x.time_value.time_type= MYSQL_TIMESTAMP_DATETIME; + val.x.time_value.neg= neg; + val.x.time_value.year= year; + val.x.time_value.month= month; + val.x.time_value.day= day; + val.x.time_value.hour= hour; + val.x.time_value.minute= minute; + val.x.time_value.second= second; + val.x.time_value.second_part= mic; dynamic_column_value_init(&res); /* create column */ if (dynamic_column_create(&str, 1, &val)) @@ -330,15 +330,15 @@ void test_value_single_datetime(uint neg, uint year, uint month, uint day, if (dynamic_column_get(&str, 1, &res)) goto err; rc= ((res.type == DYN_COL_DATETIME) && - (res.time_value.time_type == MYSQL_TIMESTAMP_DATETIME) && - (res.time_value.neg == (int)neg) && - (res.time_value.year == year) && - (res.time_value.month == month) && - (res.time_value.day == day) && - (res.time_value.hour == hour) && - (res.time_value.minute == minute) && - (res.time_value.second == second) && - (res.time_value.second_part == mic)); + (res.x.time_value.time_type == MYSQL_TIMESTAMP_DATETIME) && + (res.x.time_value.neg == (int)neg) && + (res.x.time_value.year == year) && + (res.x.time_value.month == month) && + (res.x.time_value.day == day) && + (res.x.time_value.hour == hour) && + (res.x.time_value.minute == minute) && + (res.x.time_value.second == second) && + (res.x.time_value.second_part == mic)); err: ok(rc, "%s - %c %04u-%02u-%02u %02u:%02u:%02u.%06u", name, (neg ? '-' : '+'), year, month, day, hour, minute, second, mic); @@ -368,40 +368,40 @@ void test_value_multi(ulonglong num0, DYNAMIC_COLUMN str; /* init values */ val[0].type= DYN_COL_UINT; - val[0].ulong_value= num0; + val[0].x.ulong_value= num0; val[1].type= DYN_COL_INT; - val[1].long_value= num1; + val[1].x.long_value= num1; val[2].type= DYN_COL_DOUBLE; - val[2].double_value= num2; + val[2].x.double_value= num2; dynamic_column_prepare_decimal(val + 3); // special procedure for decimal!!! - if (string2decimal(num3, &val[3].decimal_value, &end3) != E_DEC_OK) + if (string2decimal(num3, &val[3].x.decimal.value, &end3) != E_DEC_OK) goto err; val[4].type= DYN_COL_STRING; - val[4].string_value.str= (char*)string4; - val[4].string_value.length= len4; - val[4].charset= cs4; + val[4].x.string.value.str= (char*)string4; + val[4].x.string.value.length= len4; + val[4].x.string.charset= cs4; val[5].type= DYN_COL_DATE; - val[5].time_value.time_type= MYSQL_TIMESTAMP_DATE; - val[5].time_value.year= year5; - val[5].time_value.month= month5; - val[5].time_value.day= day5; + val[5].x.time_value.time_type= MYSQL_TIMESTAMP_DATE; + val[5].x.time_value.year= year5; + val[5].x.time_value.month= month5; + val[5].x.time_value.day= day5; val[6].type= DYN_COL_TIME; - val[6].time_value.time_type= MYSQL_TIMESTAMP_TIME; - val[6].time_value.neg= neg6; - val[6].time_value.hour= hour6; - val[6].time_value.minute= minute6; - val[6].time_value.second= second6; - val[6].time_value.second_part= mic6; + val[6].x.time_value.time_type= MYSQL_TIMESTAMP_TIME; + val[6].x.time_value.neg= neg6; + val[6].x.time_value.hour= hour6; + val[6].x.time_value.minute= minute6; + val[6].x.time_value.second= second6; + val[6].x.time_value.second_part= mic6; val[7].type= DYN_COL_DATETIME; - val[7].time_value.time_type= MYSQL_TIMESTAMP_DATETIME; - val[7].time_value.neg= neg7; - val[7].time_value.year= year7; - val[7].time_value.month= month7; - val[7].time_value.day= day7; - val[7].time_value.hour= hour7; - val[7].time_value.minute= minute7; - val[7].time_value.second= second7; - val[7].time_value.second_part= mic7; + val[7].x.time_value.time_type= MYSQL_TIMESTAMP_DATETIME; + val[7].x.time_value.neg= neg7; + val[7].x.time_value.year= year7; + val[7].x.time_value.month= month7; + val[7].x.time_value.day= day7; + val[7].x.time_value.hour= hour7; + val[7].x.time_value.minute= minute7; + val[7].x.time_value.second= second7; + val[7].x.time_value.second_part= mic7; val[8].type= DYN_COL_NULL; for (i= 0; i < 9; i++) dynamic_column_value_init(res + i); @@ -414,44 +414,44 @@ void test_value_multi(ulonglong num0, if (dynamic_column_get(&str, column_numbers[i], res + i)) goto err; rc= ((res[0].type == DYN_COL_UINT) && - (res[0].ulong_value == num0) && + (res[0].x.ulong_value == num0) && (res[1].type == DYN_COL_INT) && - (res[1].long_value == num1) && + (res[1].x.long_value == num1) && (res[2].type == DYN_COL_DOUBLE) && - (res[2].double_value == num2) && + (res[2].x.double_value == num2) && (res[3].type == DYN_COL_DECIMAL) && - (decimal_cmp(&res[3].decimal_value, &val[3].decimal_value) == 0) && + (decimal_cmp(&res[3].x.decimal.value, &val[3].x.decimal.value) == 0) && (res[4].type == DYN_COL_STRING) && - (res[4].string_value.length == len4) && - (memcmp(res[4].string_value.str, string4, len4) == 0) && - (res[4].charset->number == cs4->number) && + (res[4].x.string.value.length == len4) && + (memcmp(res[4].x.string.value.str, string4, len4) == 0) && + (res[4].x.string.charset->number == cs4->number) && (res[5].type == DYN_COL_DATE) && - (res[5].time_value.time_type == MYSQL_TIMESTAMP_DATE) && - (res[5].time_value.year == year5) && - (res[5].time_value.month == month5) && - (res[5].time_value.day == day5) && + (res[5].x.time_value.time_type == MYSQL_TIMESTAMP_DATE) && + (res[5].x.time_value.year == year5) && + (res[5].x.time_value.month == month5) && + (res[5].x.time_value.day == day5) && (res[6].type == DYN_COL_TIME) && - (res[6].time_value.time_type == MYSQL_TIMESTAMP_TIME) && - (res[6].time_value.neg == (int)neg6) && - (res[6].time_value.hour == hour6) && - (res[6].time_value.minute == minute6) && - (res[6].time_value.second == second6) && - (res[6].time_value.second_part == mic6) && + (res[6].x.time_value.time_type == MYSQL_TIMESTAMP_TIME) && + (res[6].x.time_value.neg == (int)neg6) && + (res[6].x.time_value.hour == hour6) && + (res[6].x.time_value.minute == minute6) && + (res[6].x.time_value.second == second6) && + (res[6].x.time_value.second_part == mic6) && (res[7].type == DYN_COL_DATETIME) && - (res[7].time_value.time_type == MYSQL_TIMESTAMP_DATETIME) && - (res[7].time_value.neg == (int)neg7) && - (res[7].time_value.year == year7) && - (res[7].time_value.month == month7) && - (res[7].time_value.day == day7) && - (res[7].time_value.hour == hour7) && - (res[7].time_value.minute == minute7) && - (res[7].time_value.second == second7) && - (res[7].time_value.second_part == mic7) && + (res[7].x.time_value.time_type == MYSQL_TIMESTAMP_DATETIME) && + (res[7].x.time_value.neg == (int)neg7) && + (res[7].x.time_value.year == year7) && + (res[7].x.time_value.month == month7) && + (res[7].x.time_value.day == day7) && + (res[7].x.time_value.hour == hour7) && + (res[7].x.time_value.minute == minute7) && + (res[7].x.time_value.second == second7) && + (res[7].x.time_value.second_part == mic7) && (res[8].type == DYN_COL_NULL)); err: ok(rc, "%s", name); /* cleanup */ - val[4].string_value.str= NULL; // we did not allocated it + val[4].x.string.value.str= NULL; // we did not allocated it dynamic_column_column_free(&str); } @@ -486,13 +486,13 @@ void test_update_multi(uint *column_numbers, uint *column_values, DYNAMIC_COLUMN_VALUE val; val.type= DYN_COL_UINT; - val.ulong_value= column_values[0]; + val.x.ulong_value= column_values[0]; if (dynamic_column_create(&str, column_numbers[0], &val)) goto err; for (i= 1; i < all; i++) { val.type= (null_values[i] ? DYN_COL_NULL : DYN_COL_UINT); - val.ulong_value= column_values[i]; + val.x.ulong_value= column_values[i]; if (dynamic_column_update(&str, column_numbers[i], &val)) goto err; @@ -510,7 +510,7 @@ void test_update_multi(uint *column_numbers, uint *column_values, else { if (val.type != DYN_COL_UINT || - val.ulong_value != column_values[j] || + val.x.ulong_value != column_values[j] || dynamic_column_exists(&str, column_numbers[j]) == ER_DYNCOL_NO) goto err; } @@ -582,12 +582,12 @@ void test_empty_string() "%s", "empty list"); val.type= DYN_COL_UINT; - val.ulong_value= 1212; + val.x.ulong_value= 1212; rc= dynamic_column_update(&str, 1, &val); if (rc == ER_DYNCOL_OK) rc= dynamic_column_get(&str, 1, &res); ok( (rc == ER_DYNCOL_OK) && - (res.type == DYN_COL_UINT) && (res.ulong_value == val.ulong_value), + (res.type == DYN_COL_UINT) && (res.x.ulong_value == val.x.ulong_value), "%s", "empty update"); } @@ -616,7 +616,7 @@ void test_update_many(uint *column_numbers, uint *column_values, for (i= 0; i < column_count; i++) { val[i].type= DYN_COL_UINT; - val[i].ulong_value= column_values[i]; + val[i].x.ulong_value= column_values[i]; } for (i= 0; i < update_count; i++) { @@ -625,13 +625,13 @@ void test_update_many(uint *column_numbers, uint *column_values, else { upd[i].type= DYN_COL_UINT; - upd[i].ulong_value= update_values[i]; + upd[i].x.ulong_value= update_values[i]; } } for (i= 0; i < result_count; i++) { res[i].type= DYN_COL_UINT; - res[i].ulong_value= result_values[i]; + res[i].x.ulong_value= result_values[i]; } if (dynamic_column_create_many(&str1, column_count, column_numbers, val)) goto err; diff --git a/unittest/mysys/my_atomic-t.c b/unittest/mysys/my_atomic-t.c index 95799be7bb1..ae9bb6903f5 100644 --- a/unittest/mysys/my_atomic-t.c +++ b/unittest/mysys/my_atomic-t.c @@ -1,4 +1,4 @@ -/* Copyright (C) 2006-2008 MySQL AB, 2008 Sun Microsystems, Inc. +/* Copyright (c) 2006, 2010, Oracle and/or its affiliates. All rights reserved. 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 @@ -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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ #include "thr_template.c" @@ -164,7 +164,14 @@ void do_tests() test_concurrently("my_atomic_cas32", test_atomic_cas, THREADS, CYCLES); { - int64 b=0x1000200030004000LL; + /* + If b is not volatile, the wrong assembly code is generated on OSX Lion + as the variable is optimized away as a constant. + See Bug#62533 / Bug#13030056. + Another workaround is to specify architecture explicitly using e.g. + CFLAGS/CXXFLAGS= "-m64". + */ + volatile int64 b=0x1000200030004000LL; a64=0; my_atomic_add64(&a64, b); ok(a64==b, "add64"); diff --git a/unittest/mysys/my_rdtsc-t.c b/unittest/mysys/my_rdtsc-t.c index 286ff29fbfc..76a74a6fc09 100644 --- a/unittest/mysys/my_rdtsc-t.c +++ b/unittest/mysys/my_rdtsc-t.c @@ -1,4 +1,5 @@ -/* Copyright (C) 2008-2009 Sun Microsystems, Inc +/* Copyright (c) 2008 MySQL AB, 2009 Sun Microsystems, Inc. + Use is subject to license terms. 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 @@ -11,7 +12,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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ /* rdtsc3 -- multi-platform timer code diff --git a/unittest/mysys/my_vsnprintf-t.c b/unittest/mysys/my_vsnprintf-t.c index 7f93f5bb195..06f6878826a 100644 --- a/unittest/mysys/my_vsnprintf-t.c +++ b/unittest/mysys/my_vsnprintf-t.c @@ -1,4 +1,4 @@ -/* Copyright (C) 2003 MySQL AB +/* Copyright (c) 2003, 2011, Oracle and/or its affiliates. All rights reserved. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as @@ -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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ #include <my_global.h> #include <m_string.h> diff --git a/unittest/mysys/thr_template.c b/unittest/mysys/thr_template.c index 781bfbe4f9c..5bb9809b1e1 100644 --- a/unittest/mysys/thr_template.c +++ b/unittest/mysys/thr_template.c @@ -1,4 +1,5 @@ -/* Copyright (C) 2006-2008 MySQL AB, 2008 Sun Microsystems, Inc. +/* Copyright (c) 2006-2008 MySQL AB, 2009 Sun Microsystems, Inc. + Use is subject to license terms. 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 @@ -11,7 +12,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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ #include <my_global.h> #include <my_sys.h> diff --git a/unittest/mytap/t/basic-t.c b/unittest/mytap/t/basic-t.c index b588521d192..dcb13b20f11 100644 --- a/unittest/mytap/t/basic-t.c +++ b/unittest/mytap/t/basic-t.c @@ -1,4 +1,4 @@ -/* Copyright (C) 2006 MySQL AB +/* Copyright (c) 2006, 2010, Oracle and/or its affiliates. All rights reserved. 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/unittest/strings/strings-t.c b/unittest/strings/strings-t.c index cb33af3ac03..66b3ac63792 100644 --- a/unittest/strings/strings-t.c +++ b/unittest/strings/strings-t.c @@ -1,4 +1,4 @@ -/* Copyright 2000, 2010, Oracle and/or its affiliates. All rights reserved. +/* Copyright (c) 2010, 2010, Oracle and/or its affiliates. All rights reserved. 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/unittest/unit.pl b/unittest/unit.pl index ec7cc02727f..fe45ece4233 100644 --- a/unittest/unit.pl +++ b/unittest/unit.pl @@ -1,5 +1,6 @@ #!/usr/bin/perl -# Copyright (C) 2006 MySQL AB +# Copyright (c) 2006 MySQL AB, 2009, 2010 Sun Microsystems, Inc. +# Use is subject to license terms. # # 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/vio/test-ssl.c b/vio/test-ssl.c index 4d158ae83f7..c99f5071055 100644 --- a/vio/test-ssl.c +++ b/vio/test-ssl.c @@ -1,4 +1,4 @@ -/* Copyright (C) 2000 MySQL AB +/* Copyright (c) 2000, 2011, Oracle and/or its affiliates. All rights reserved. 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 @@ -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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ #include <my_global.h> #if defined(HAVE_OPENSSL) diff --git a/vio/test-sslclient.c b/vio/test-sslclient.c index 9d8a741e313..93fdb063754 100644 --- a/vio/test-sslclient.c +++ b/vio/test-sslclient.c @@ -1,4 +1,4 @@ -/* Copyright (C) 2000 MySQL AB +/* Copyright (c) 2000, 2011, Oracle and/or its affiliates. All rights reserved. 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 @@ -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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ #include <my_global.h> #ifdef HAVE_OPENSSL diff --git a/vio/test-sslserver.c b/vio/test-sslserver.c index 35cfa26bd00..c81dc03dc58 100644 --- a/vio/test-sslserver.c +++ b/vio/test-sslserver.c @@ -1,4 +1,4 @@ -/* Copyright (C) 2000 MySQL AB +/* Copyright (c) 2000, 2011, Oracle and/or its affiliates. All rights reserved. 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 @@ -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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ #include <my_global.h> #ifdef HAVE_OPENSSL diff --git a/vio/vio.c b/vio/vio.c index 48f103c33e8..b8bc7bdae08 100644 --- a/vio/vio.c +++ b/vio/vio.c @@ -1,4 +1,4 @@ -/* Copyright (C) 2000 MySQL AB +/* Copyright (c) 2000, 2010, Oracle and/or its affiliates. All rights reserved. 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 @@ -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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ /* Note that we can't have assertion on file descriptors; The reason for diff --git a/vio/vio_priv.h b/vio/vio_priv.h index 1bfb857b039..702ba4de38a 100644 --- a/vio/vio_priv.h +++ b/vio/vio_priv.h @@ -1,7 +1,7 @@ #ifndef VIO_PRIV_INCLUDED #define VIO_PRIV_INCLUDED -/* Copyright (C) 2003 MySQL AB +/* Copyright (c) 2003, 2010, Oracle and/or its affiliates. All rights reserved. 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 @@ -14,7 +14,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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ /* Structures and functions private to the vio package */ diff --git a/vio/viosocket.c b/vio/viosocket.c index 43137ac7e92..4772847abd8 100644 --- a/vio/viosocket.c +++ b/vio/viosocket.c @@ -1,4 +1,5 @@ -/* Copyright (c) 2000, 2011, Oracle and/or its affiliates. All rights reserved. +/* + Copyright (c) 2001, 2011, Oracle and/or its affiliates. All rights reserved. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License diff --git a/vio/viossl.c b/vio/viossl.c index 356fca40d13..b40f7b931e6 100644 --- a/vio/viossl.c +++ b/vio/viossl.c @@ -1,4 +1,4 @@ -/* Copyright (C) 2000 MySQL AB +/* Copyright (c) 2000, 2011, Oracle and/or its affiliates. All rights reserved. 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 @@ -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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ /* Note that we can't have assertion on file descriptors; The reason for diff --git a/vio/viosslfactories.c b/vio/viosslfactories.c index 4f4dd5758ba..d71021452d1 100644 --- a/vio/viosslfactories.c +++ b/vio/viosslfactories.c @@ -1,4 +1,4 @@ -/* Copyright (C) 2000 MySQL AB +/* Copyright (c) 2000, 2011, Oracle and/or its affiliates. All rights reserved. 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 @@ -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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ #include "vio_priv.h" diff --git a/vio/viotest-ssl.c b/vio/viotest-ssl.c index 90489b46605..51d171d6923 100644 --- a/vio/viotest-ssl.c +++ b/vio/viotest-ssl.c @@ -1,4 +1,4 @@ -/* Copyright (C) 2000 MySQL AB +/* Copyright (c) 2000, 2011, Oracle and/or its affiliates. All rights reserved. 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 @@ -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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ #include <my_global.h> #ifdef HAVE_OPENSSL diff --git a/vio/viotest-sslconnect.cc b/vio/viotest-sslconnect.cc index 89e1a6e7dfe..18e558159fa 100644 --- a/vio/viotest-sslconnect.cc +++ b/vio/viotest-sslconnect.cc @@ -1,3 +1,18 @@ +/* Copyright (c) 2000 MySQL AB + Use is subject to license terms. + + 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 + the Free Software Foundation; version 2 of the License. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + 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 02110-1301 USA */ /* ** Virtual I/O library diff --git a/vio/viotest.cc b/vio/viotest.cc index 490a9ca6694..b1c11a85cf2 100644 --- a/vio/viotest.cc +++ b/vio/viotest.cc @@ -1,3 +1,19 @@ +/* Copyright (c) 2000 MySQL AB + Use is subject to license terms. + + 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 + the Free Software Foundation; version 2 of the License. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + 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 02110-1301 USA */ + /* ** Virtual I/O library ** Written by Andrei Errapart <andreie@no.spam.ee> diff --git a/win/configure-mariadb.bat b/win/configure-mariadb.bat index 6c4283359b4..dc5b59819a3 100644 --- a/win/configure-mariadb.bat +++ b/win/configure-mariadb.bat @@ -5,4 +5,5 @@ cscript win\configure.js ^ WITH_PARTITION_STORAGE_ENGINE ^ WITH_ARIA_STORAGE_ENGINE ^ WITH_PBXT_STORAGE_ENGINE ^ - WITH_XTRADB_STORAGE_ENGINE + WITH_XTRADB_STORAGE_ENGINE ^ + WITH_FEEDBACK_STORAGE_ENGINE diff --git a/win/configure-mariadb.sh b/win/configure-mariadb.sh index 616d1b790d6..67bfe293639 100644 --- a/win/configure-mariadb.sh +++ b/win/configure-mariadb.sh @@ -18,4 +18,5 @@ cscript win/configure.js \ WITH_ARIA_STORAGE_ENGINE \ WITH_PBXT_STORAGE_ENGINE \ WITH_XTRADB_STORAGE_ENGINE \ + WITH_FEEDBACK_STORAGE_ENGINE \ WITH_EMBEDDED_SERVER diff --git a/win/create_def_file.js b/win/create_def_file.js index 21f884417e3..019bb7471ab 100644 --- a/win/create_def_file.js +++ b/win/create_def_file.js @@ -1,6 +1,7 @@ // create_def_file.js // -// Copyright (C) 2009 Sun Microsystems +// Copyright (c) 2009 Sun Microsystems, Inc. +// Use is subject to license terms. // // 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/win/packaging/extra.wxs.in b/win/packaging/extra.wxs.in index 5aab7bc813c..37b12575328 100644 --- a/win/packaging/extra.wxs.in +++ b/win/packaging/extra.wxs.in @@ -49,6 +49,9 @@ <!-- Disable advertised shortcuts weirdness -->
<Property Id="DISABLEADVTSHORTCUTS" Secure="yes" Value="1"/>
+ <!-- Activate feedback plugin-->
+ <Property Id="FEEDBACK" Secure="yes"/>
+
<?if $(var.HaveInnodb) = "1" ?>
<!-- Quick configuration : set default storage engine to innodb, use strict sql_mode -->
<Property Id="STDCONFIG" Secure="yes" Value="1"/>
@@ -57,6 +60,9 @@ <Property Id="BUFFERPOOLSIZE" Secure="yes"/>
+ <CustomAction Id="LaunchUrl" BinaryKey="WixCA" DllEntry="WixShellExec" Execute="immediate" Return="check" Impersonate="yes" />
+
+
<!--
User interface dialogs
-->
@@ -157,6 +163,43 @@ </Control>
<Control Id="BannerLine" Type="Line" X="0" Y="44" Width="370" Height="0" />
</Dialog>
+
+ <!-- Feedback dialog -->
+ <Dialog Id="Feedback" Width="370" Height="270" Title="[ProductName] Setup" NoMinimize="yes">
+
+ <Control Id="CheckBoxFeedback" Type="CheckBox" X="8" Y="61" Width="360" Height="12" Property="FEEDBACK" CheckBoxValue="1" TabSkip="no">
+ <Text>{\Font1}Enable the Feedback plugin and submit anonymous usage information</Text>
+ </Control>
+
+ <Control Id="Text" Type="Text" X="23" Y="82" Width="290" Height="55">
+ <Text>Monty Program has created a Feedback plugin for MariaDB which, if enabled, collects basic anonymous statistical information. This information is used by the developers to improve MariaDB. Enabling this plugin is an easy way to help with MariaDB development. Collected statistics, and more information on the plugin, can be viewed at http://mariadb.org/feedback_plugin </Text>
+ </Control>
+
+ <Control Id="MoreInfo" Type="PushButton" X="23" Y="140" Width="56" Height="17" Text="More Info" ToolTip="http://mariadb.org/feedback_plugin" >
+ <Publish Property="WixShellExecTarget" Value="http://mariadb.org/feedback_plugin" Order="1">1</Publish>
+ <Publish Event="DoAction" Value="LaunchUrl" Order="2">1</Publish>
+ </Control>
+
+
+ <Control Id="Back" Type="PushButton" X="180" Y="243" Width="56" Height="17" Text="&Back">
+ <Publish Event="NewDialog" Value="ServicePortDlg">1</Publish>
+ </Control>
+ <Control Id="Next" Type="PushButton" X="236" Y="243" Width="56" Height="17" Text="&Next">
+ <Publish Event="NewDialog" Value="VerifyReadyDlg">1</Publish>
+ </Control>
+ <Control Id="Cancel" Type="PushButton" X="304" Y="243" Width="56" Height="17" Cancel="yes" Text="Cancel">
+ <Publish Event="SpawnDialog" Value="CancelDlg">1</Publish>
+ </Control>
+ <Control Id="BannerBitmap" Type="Bitmap" X="0" Y="0" Width="370" Height="44" TabSkip="no" Text="WixUI_Bmp_Banner" />
+ <Control Id="Description" Type="Text" X="25" Y="23" Width="280" Height="15" Transparent="yes" NoPrefix="yes">
+ <Text>Submit usage information</Text>
+ </Control>
+ <Control Id="BottomLine" Type="Line" X="0" Y="234" Width="370" Height="0" />
+ <Control Id="Title" Type="Text" X="15" Y="6" Width="200" Height="15" Transparent="yes" NoPrefix="yes">
+ <Text>{\WixUI_Font_Title}[ProductName] setup</Text>
+ </Control>
+ <Control Id="BannerLine" Type="Line" X="0" Y="44" Width="370" Height="0" />
+ </Dialog>
<!-- Error popup dialog -->
<Dialog Id="WarningDlg" Width="320" Height="85" Title="[ProductName] Setup" NoMinimize="yes">
@@ -320,7 +363,7 @@ </Publish>
<Publish Event="DoAction" Value="CheckDatabaseProperties">NOT WarningText</Publish>
<Publish Event="SpawnDialog" Value="WarningDlg">WarningText</Publish>
- <Publish Event="NewDialog" Value="VerifyReadyDlg">Not WarningText</Publish>
+ <Publish Event="NewDialog" Value="Feedback">Not WarningText</Publish>
</Control>
<Control Id="Cancel" Type="PushButton" X="304" Y="243" Width="56" Height="17" Cancel="no" Text="Cancel">
<Publish Event="SpawnDialog" Value="CancelDlg">1</Publish>
@@ -350,7 +393,7 @@ NOT Installed AND UpgradableServiceFound
</Publish>
- <Publish Dialog="VerifyReadyDlg" Control="Back" Event="NewDialog" Value="ServicePortDlg" Order="3" ><![CDATA[&DBInstance=3 AND NOT !DBInstance=3]]></Publish>
+ <Publish Dialog="VerifyReadyDlg" Control="Back" Event="NewDialog" Value="Feedback" Order="3" ><![CDATA[&DBInstance=3 AND NOT !DBInstance=3]]></Publish>
<Publish Dialog="VerifyReadyDlg" Control="Back" Event="NewDialog" Value="WelcomeDlg" Order="3"> <![CDATA[OLDERVERSIONBEINGUPGRADED <>""]]></Publish>
<Publish Dialog="VerifyReadyDlg" Control="Back" Event="NewDialog" Value="ConfirmDataCleanupDlg" Order="1" ><![CDATA[(&DBInstance=2) AND (!DBInstance=3)]]></Publish>
@@ -460,6 +503,21 @@ Value="[LOGFILESIZE]M" />
</Component>
<?endif?>
+
+ <Component Id="C.feedback" Guid="*" Directory="DATADIR">
+ <Condition>FEEDBACK</Condition>
+ <RegistryValue Root='HKLM'
+ Key='SOFTWARE\@MANUFACTURER@\@CPACK_WIX_PACKAGE_NAME@'
+ Name='FEEDBACK' Value='1' Type='string' KeyPath='yes'/>
+ <IniFile Id="Ini5"
+ Action="createLine"
+ Directory="DATADIR"
+ Section="mysqld"
+ Name="my.ini"
+ Key="feedback"
+ Value="ON" />
+ </Component>
+
<!--- Grant service account permission to the database folder (Windows 7 and later) -->
<Component Id="C.serviceaccount.permission" Guid="*" Directory='DATADIR' Transitive='yes'>
<Condition><![CDATA[SERVICENAME AND (VersionNT > 600)]]></Condition>
|