mirror of
https://github.com/MariaDB/server.git
synced 2025-01-29 02:05:57 +01:00
References lp:1034621 - Merge up to mysql-5.5.25 level
merged codership-mysql/5.5 revisions: bzr diff -r3759..3767 merged codership-mysql/5.5 revisions: bzr diff -r3768..3771
This commit is contained in:
commit
ebfa24b1d2
789 changed files with 48567 additions and 3235 deletions
11
BUILD-CMAKE
11
BUILD-CMAKE
|
@ -1,6 +1,7 @@
|
|||
Copyright (c) 2009, 2010 Sun Microsystems, Inc.
|
||||
Copyright (c) 2012 Monty Program Ab
|
||||
|
||||
How to Build MySQL server with CMake
|
||||
How to Build MariaDB server with CMake
|
||||
|
||||
WHAT YOU NEED
|
||||
---------------------------------------------------------------
|
||||
|
@ -11,7 +12,7 @@ HOW TO INSTALL:
|
|||
Linux distributions:
|
||||
shell> sudo apt-get install cmake
|
||||
|
||||
The above works on do Debian/Ubuntu based distributions.On others, command
|
||||
The above works on Debian/Ubuntu based distributions. On others, the command
|
||||
line needs to be modified to e.g "yum install" on Fedora or "zypper install"
|
||||
on OpenSUSE.
|
||||
|
||||
|
@ -20,8 +21,9 @@ shell> pfexec pkgadd install SUNWcmake
|
|||
|
||||
Windows and Mac OSX:
|
||||
Download and install the latest distribution from
|
||||
http://www.cmake.org/cmake/resources/software.html.On Windows, download
|
||||
installer exe file and run it. On Mac, download the .dmg image and open it.
|
||||
http://www.cmake.org/cmake/resources/software.html
|
||||
On Windows, download installer exe file and run it. On MacOS, download
|
||||
the .dmg image and open it.
|
||||
|
||||
Other Unixes:
|
||||
Precompiled packages for other Unix flavors (HPUX, AIX) are available from
|
||||
|
@ -243,3 +245,4 @@ later corrected, the cached result is still used. If you encounter this
|
|||
situation, which should be a rare occation, you need either to remove the
|
||||
offending entry from CMakeCache.txt (if test was for HAVE_FOO, remove lines
|
||||
containing HAVE_FOO from CMakeCache.txt) or just remove the cache file.
|
||||
|
||||
|
|
|
@ -131,6 +131,10 @@ IF (NOT CPACK_GENERATOR)
|
|||
ENDIF(WIN32)
|
||||
ENDIF(NOT CPACK_GENERATOR)
|
||||
|
||||
IF(DEB)
|
||||
SET(INSTALL_LAYOUT "DEB")
|
||||
ENDIF(DEB)
|
||||
|
||||
INCLUDE(mysql_version)
|
||||
INCLUDE(cpack_rpm)
|
||||
INCLUDE(cpack_source_ignore_files)
|
||||
|
|
|
@ -31,7 +31,7 @@ also applies.
|
|||
first.
|
||||
|
||||
If you run into problems and need to file a bug report,
|
||||
please report them to: http://bugs.launchpad.net/maria
|
||||
please report them to: http://mariadb.org/jira
|
||||
|
||||
See the instructions in Section 1.6, "How to Report Bugs or Problems."
|
||||
|
||||
|
|
|
@ -1,10 +1,11 @@
|
|||
MariaDB is in most aspects identical to MySQL.
|
||||
|
||||
Differences between MySQL and MariaDB can be found at:
|
||||
http://askmonty.org/wiki/index.php/MariaDB_versus_MySQL
|
||||
http://kb.askmonty.org/en/mariadb-versus-mysql-features/
|
||||
http://kb.askmonty.org/en/mariadb-versus-mysql-compatibility/
|
||||
|
||||
The MariaDB references manual can be found at:
|
||||
http://askmonty.org/wiki/index.php/Manual
|
||||
The MariaDB manual can be found at:
|
||||
http://kb.askmonty.org/
|
||||
|
||||
The MySQL Reference Manual is available in various formats on
|
||||
http://dev.mysql.com/doc; if you're interested in the DocBook XML
|
||||
|
|
|
@ -1,3 +1,14 @@
|
|||
Installing and Upgrading MariaDB
|
||||
|
||||
This file contains chapter two of the MySQL manual and describes how
|
||||
to obtain and install MySQL. The instructions below are generally
|
||||
applicable to both MySQL and MariaDB, but differ in some particulars
|
||||
(like, for example, the GPG signing key we use is different).
|
||||
|
||||
Detailed, MariaDB-specific instructions are available at:
|
||||
http://kb.askmonty.org/en/getting-installing-and-upgrading-mariadb/
|
||||
|
||||
- - - -
|
||||
|
||||
Chapter 2. Installing and Upgrading MySQL
|
||||
|
||||
|
|
|
@ -1,2 +1,3 @@
|
|||
Up-to-date instructions on MariaDB building on Windows can be found in http://kb.askmonty.org/en/building-mariadb-on-windows.
|
||||
Up-to-date instructions about building MariaDB on Windows can be found
|
||||
at: http://kb.askmonty.org/en/building-mariadb-on-windows
|
||||
|
||||
|
|
|
@ -1,35 +1,35 @@
|
|||
This file should contain all know fatal bugs in the Mariadb and the
|
||||
Maria storage engine for the last source or binary release. Minor
|
||||
bugs, extensions and feature request and bugs found since this release
|
||||
can be find in the MariaDB bugs database at:
|
||||
https://bugs.launchpad.net/maria and in the MySQL bugs databases at:
|
||||
http://bugs.mysql.com/ (category "Maria storage engine").
|
||||
This file should contain all known fatal bugs in Mariadb and the Aria
|
||||
storage engine for the last source or binary release. Minor bugs,
|
||||
extensions and feature requests, and bugs found since this release can
|
||||
be found in the MariaDB bugs database at: http://mariadb.org/jira and
|
||||
in the MySQL bugs databases at: http://bugs.mysql.com/ (category
|
||||
"Maria storage engine").
|
||||
|
||||
There shouldn't normally be any bugs that affects normal operations in
|
||||
any MariaDB release. Still, there are always exceptions and edge cases
|
||||
and that's what this file is for.
|
||||
There should not normally be any bugs which affect normal operations
|
||||
in any MariaDB release. Still, there are always exceptions and edge
|
||||
cases and that is what this file is for.
|
||||
|
||||
If you have found a bug that is not listed here, please add it to
|
||||
http://bugs.launchpad.net/maria so that we can either fix it for next
|
||||
release or in the worst case add it here for others to know!
|
||||
http://mariadb.org/jira so we can either fix it for next release or in
|
||||
the worst case add it here for others to know!
|
||||
|
||||
|
||||
IMPORTANT:
|
||||
|
||||
If you have been using the Maria storage engine with
|
||||
MySQL-5.1-Maria-alpha build and upgrading to a newer MariaDB you MUST
|
||||
run maria_chk --recover on all your Maria tables. This is because we
|
||||
made an incompatible change of how transaction id is stored and old
|
||||
transaction id's must be reset!
|
||||
If you have been using the Maria (now Aria) storage engine with the
|
||||
MySQL-5.1-Maria-alpha build and are upgrading to a newer MariaDB you
|
||||
MUST run [m]aria_chk --recover on all your Aria tables. This is because
|
||||
we made an incompatible change with how the transaction id is stored
|
||||
and old transaction id's must be reset!
|
||||
|
||||
cd mysql-data-directory
|
||||
maria_chk --recover */*.MAI
|
||||
aria_chk --recover */*.MAI
|
||||
|
||||
As the Maria storage engine is now in beta we will do our best to not
|
||||
introduce any incompatible changes in the data format for the Maria
|
||||
tables; If this would be ever be needed, we will, if possible, support
|
||||
both the old and the new version to make upgrades as easy as possible.
|
||||
Going forward, we will do our best to not introduce any incompatible
|
||||
changes in the data format for Aria tables. If this would be ever be
|
||||
needed, we will, if possible, support both the old and the new version
|
||||
to make upgrades as easy as possible.
|
||||
|
||||
Note that for the MariaDB 5.1 release the Maria storage engine is
|
||||
classified as 'beta'; It should work, but use it with caution. Please
|
||||
report all bugs to https://bugs.launchpad.net/maria so that we can fix
|
||||
them!
|
||||
Note that for the MariaDB 5.1 release the Aria storage engine is
|
||||
classified as 'beta'; It should work, but use it with caution. Please
|
||||
report all bugs to http://mariadb.org/jira so we can fix them!
|
||||
|
|
8
README
8
README
|
@ -13,9 +13,9 @@ see the Credits appendix. You can also do 'SHOW authors' to get a
|
|||
list of active contributors.
|
||||
|
||||
A description of the MariaDB project and a manual can be found at:
|
||||
http://askmonty.org/wiki/index.php/MariaDB
|
||||
http://askmonty.org/wiki/index.php/MariaDB_versus_MySQL
|
||||
http://askmonty.org/wiki/index.php/Manual:Contents
|
||||
http://kb.askmonty.org/
|
||||
http://kb.askmonty.org/en/mariadb-versus-mysql-features/
|
||||
http://kb.askmonty.org/en/mariadb-versus-mysql-compatibility/
|
||||
|
||||
As MariaDB is a full replacement of MySQL, the MySQL manual at
|
||||
http://dev.mysql.com/doc is generally applicable.
|
||||
|
@ -41,7 +41,7 @@ EXCEPTIONS-CLIENT file.
|
|||
IMPORTANT:
|
||||
|
||||
Bug and/or error reports regarding MariaDB should be submitted at
|
||||
https://bugs.launchpad.net/maria
|
||||
http://mariadb.org/jira
|
||||
|
||||
Bugs in the MySQL code can also be submitted at http://bugs.mysql.com
|
||||
|
||||
|
|
2
VERSION
2
VERSION
|
@ -1,4 +1,4 @@
|
|||
MYSQL_VERSION_MAJOR=5
|
||||
MYSQL_VERSION_MINOR=5
|
||||
MYSQL_VERSION_PATCH=24
|
||||
MYSQL_VERSION_PATCH=25
|
||||
MYSQL_VERSION_EXTRA=
|
||||
|
|
|
@ -23,10 +23,6 @@
|
|||
#include <m_string.h>
|
||||
#include <m_ctype.h>
|
||||
|
||||
#if defined(HAVE_BROKEN_GETPASS) && !defined(HAVE_GETPASSPHRASE)
|
||||
#undef HAVE_GETPASS
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_GETPASS
|
||||
#ifdef HAVE_PWD_H
|
||||
#include <pwd.h>
|
||||
|
|
|
@ -2916,7 +2916,7 @@ com_help(String *buffer __attribute__((unused)),
|
|||
}
|
||||
|
||||
put_info("\nGeneral information about MariaDB can be found at\n"
|
||||
"http://askmonty.org/wiki/index.php/Manual:Contents\n", INFO_INFO);
|
||||
"http://mariadb.org\n", INFO_INFO);
|
||||
put_info("List of all MySQL commands:", INFO_INFO);
|
||||
if (!named_cmds)
|
||||
put_info("Note that all text commands must be first on line and end with ';'",INFO_INFO);
|
||||
|
|
|
@ -86,6 +86,15 @@
|
|||
/* Chars needed to store LONGLONG, excluding trailing '\0'. */
|
||||
#define LONGLONG_LEN 20
|
||||
|
||||
/* general_log or slow_log tables under mysql database */
|
||||
static inline my_bool general_log_or_slow_log_tables(const char *db,
|
||||
const char *table)
|
||||
{
|
||||
return (strcmp(db, "mysql") == 0) &&
|
||||
((strcmp(table, "general_log") == 0) ||
|
||||
(strcmp(table, "slow_log") == 0));
|
||||
}
|
||||
|
||||
static void add_load_option(DYNAMIC_STRING *str, const char *option,
|
||||
const char *option_value);
|
||||
static ulong find_set(TYPELIB *lib, const char *x, uint length,
|
||||
|
@ -2503,6 +2512,7 @@ static uint get_table_structure(char *table, char *db, char *table_type,
|
|||
"TABLE_SCHEMA = '%s' AND TABLE_NAME = '%s'";
|
||||
FILE *sql_file= md_result_file;
|
||||
int len;
|
||||
my_bool is_log_table;
|
||||
MYSQL_RES *result;
|
||||
MYSQL_ROW row;
|
||||
DBUG_ENTER("get_table_structure");
|
||||
|
@ -2587,9 +2597,12 @@ static uint get_table_structure(char *table, char *db, char *table_type,
|
|||
/*
|
||||
Even if the "table" is a view, we do a DROP TABLE here. The
|
||||
view-specific code below fills in the DROP VIEW.
|
||||
We will skip the DROP TABLE for general_log and slow_log, since
|
||||
those stmts will fail, in case we apply dump by enabling logging.
|
||||
*/
|
||||
fprintf(sql_file, "DROP TABLE IF EXISTS %s;\n",
|
||||
opt_quoted_table);
|
||||
if (!general_log_or_slow_log_tables(db, table))
|
||||
fprintf(sql_file, "DROP TABLE IF EXISTS %s;\n",
|
||||
opt_quoted_table);
|
||||
check_io(sql_file);
|
||||
}
|
||||
|
||||
|
@ -2701,12 +2714,25 @@ static uint get_table_structure(char *table, char *db, char *table_type,
|
|||
|
||||
row= mysql_fetch_row(result);
|
||||
|
||||
fprintf(sql_file, (opt_compatible_mode & 3) ? "%s;\n" :
|
||||
"/*!40101 SET @saved_cs_client = @@character_set_client */;\n"
|
||||
"/*!40101 SET character_set_client = utf8 */;\n"
|
||||
"%s;\n"
|
||||
"/*!40101 SET character_set_client = @saved_cs_client */;\n",
|
||||
row[1]);
|
||||
is_log_table= general_log_or_slow_log_tables(db, table);
|
||||
if (is_log_table)
|
||||
row[1]+= 13; /* strlen("CREATE TABLE ")= 13 */
|
||||
if (opt_compatible_mode & 3)
|
||||
{
|
||||
fprintf(sql_file,
|
||||
is_log_table ? "CREATE TABLE IF NOT EXISTS %s;\n" : "%s;\n",
|
||||
row[1]);
|
||||
}
|
||||
else
|
||||
{
|
||||
fprintf(sql_file,
|
||||
"/*!40101 SET @saved_cs_client = @@character_set_client */;\n"
|
||||
"/*!40101 SET character_set_client = utf8 */;\n"
|
||||
"%s%s;\n"
|
||||
"/*!40101 SET character_set_client = @saved_cs_client */;\n",
|
||||
is_log_table ? "CREATE TABLE IF NOT EXISTS " : "",
|
||||
row[1]);
|
||||
}
|
||||
|
||||
check_io(sql_file);
|
||||
mysql_free_result(result);
|
||||
|
@ -4315,6 +4341,22 @@ static int dump_all_tables_in_db(char *database)
|
|||
if (opt_xml)
|
||||
print_xml_tag(md_result_file, "", "\n", "database", "name=", database, NullS);
|
||||
|
||||
if (strcmp(database, "mysql") == 0)
|
||||
{
|
||||
char table_type[NAME_LEN];
|
||||
char ignore_flag;
|
||||
uint num_fields;
|
||||
num_fields= get_table_structure((char *) "general_log",
|
||||
database, table_type, &ignore_flag);
|
||||
if (num_fields == 0)
|
||||
verbose_msg("-- Warning: get_table_structure() failed with some internal "
|
||||
"error for 'general_log' table\n");
|
||||
num_fields= get_table_structure((char *) "slow_log",
|
||||
database, table_type, &ignore_flag);
|
||||
if (num_fields == 0)
|
||||
verbose_msg("-- Warning: get_table_structure() failed with some internal "
|
||||
"error for 'slow_log' table\n");
|
||||
}
|
||||
if (lock_tables)
|
||||
{
|
||||
DYNAMIC_STRING query;
|
||||
|
@ -4773,7 +4815,7 @@ static int do_show_slave_status(MYSQL *mysql_con)
|
|||
if (row[1])
|
||||
fprintf(md_result_file, "MASTER_HOST='%s', ", row[1]);
|
||||
if (row[3])
|
||||
fprintf(md_result_file, "MASTER_PORT='%s', ", row[3]);
|
||||
fprintf(md_result_file, "MASTER_PORT=%s, ", row[3]);
|
||||
}
|
||||
fprintf(md_result_file,
|
||||
"MASTER_LOG_FILE='%s', MASTER_LOG_POS=%s;\n", row[9], row[21]);
|
||||
|
|
|
@ -621,6 +621,8 @@ void free_all_replace(){
|
|||
free_replace_column();
|
||||
}
|
||||
|
||||
void var_set_int(const char* name, int value);
|
||||
|
||||
|
||||
class LogFile {
|
||||
FILE* m_file;
|
||||
|
@ -1275,6 +1277,8 @@ void handle_command_error(struct st_command *command, uint error,
|
|||
{
|
||||
DBUG_ENTER("handle_command_error");
|
||||
DBUG_PRINT("enter", ("error: %d", error));
|
||||
var_set_int("$sys_errno",sys_errno);
|
||||
var_set_int("$errno",error);
|
||||
if (error != 0)
|
||||
{
|
||||
int i;
|
||||
|
@ -1285,7 +1289,7 @@ void handle_command_error(struct st_command *command, uint error,
|
|||
"errno: %d",
|
||||
command->first_word_len, command->query, error, my_errno,
|
||||
sys_errno);
|
||||
return;
|
||||
DBUG_VOID_RETURN;
|
||||
}
|
||||
|
||||
i= match_expected_error(command, error, NULL);
|
||||
|
@ -5201,15 +5205,32 @@ const char *get_errname_from_code (uint error_code)
|
|||
void do_get_errcodes(struct st_command *command)
|
||||
{
|
||||
struct st_match_err *to= saved_expected_errors.err;
|
||||
char *p= command->first_argument;
|
||||
uint count= 0;
|
||||
char *next;
|
||||
|
||||
DBUG_ENTER("do_get_errcodes");
|
||||
|
||||
if (!*p)
|
||||
if (!*command->first_argument)
|
||||
die("Missing argument(s) to 'error'");
|
||||
|
||||
/* TODO: Potentially, there is a possibility of variables
|
||||
being expanded twice, e.g.
|
||||
|
||||
let $errcodes = 1,\$a;
|
||||
let $a = 1051;
|
||||
error $errcodes;
|
||||
DROP TABLE unknown_table;
|
||||
...
|
||||
Got one of the listed errors
|
||||
|
||||
But since it requires manual escaping, it does not seem
|
||||
particularly dangerous or error-prone.
|
||||
*/
|
||||
DYNAMIC_STRING ds;
|
||||
init_dynamic_string(&ds, 0, command->query_len + 64, 256);
|
||||
do_eval(&ds, command->first_argument, command->end, !is_windows);
|
||||
char *p= ds.str;
|
||||
|
||||
uint count= 0;
|
||||
char *next;
|
||||
|
||||
do
|
||||
{
|
||||
char *end;
|
||||
|
@ -5319,11 +5340,15 @@ void do_get_errcodes(struct st_command *command)
|
|||
|
||||
} while (*p);
|
||||
|
||||
command->last_argument= p;
|
||||
command->last_argument= command->first_argument;
|
||||
while (*command->last_argument)
|
||||
command->last_argument++;
|
||||
|
||||
to->type= ERR_EMPTY; /* End of data */
|
||||
|
||||
DBUG_PRINT("info", ("Expected errors: %d", count));
|
||||
saved_expected_errors.count= count;
|
||||
dynstr_free(&ds);
|
||||
DBUG_VOID_RETURN;
|
||||
}
|
||||
|
||||
|
@ -9012,8 +9037,12 @@ int main(int argc, char **argv)
|
|||
command->abort_on_error= (command->expected_errors.count == 0 &&
|
||||
abort_on_error);
|
||||
|
||||
/* delimiter needs to be executed so we can continue to parse */
|
||||
ok_to_do= cur_block->ok || command->type == Q_DELIMITER;
|
||||
/*
|
||||
some commmands need to be executed or at least parsed unconditionally,
|
||||
because they change the grammar.
|
||||
*/
|
||||
ok_to_do= cur_block->ok || command->type == Q_DELIMITER
|
||||
|| command->type == Q_PERL;
|
||||
/*
|
||||
Some commands need to be "done" the first time if they may get
|
||||
re-iterated over in a true context. This can only happen if there's
|
||||
|
@ -9024,8 +9053,7 @@ int main(int argc, char **argv)
|
|||
if (command->type == Q_SOURCE ||
|
||||
command->type == Q_ERROR ||
|
||||
command->type == Q_WRITE_FILE ||
|
||||
command->type == Q_APPEND_FILE ||
|
||||
command->type == Q_PERL)
|
||||
command->type == Q_APPEND_FILE)
|
||||
{
|
||||
for (struct st_block *stb= cur_block-1; stb >= block_stack; stb--)
|
||||
{
|
||||
|
|
|
@ -94,8 +94,19 @@ IF(FEATURE_SET)
|
|||
ENDIF()
|
||||
|
||||
OPTION(ENABLED_LOCAL_INFILE "" ON)
|
||||
SET(WITH_SSL bundled CACHE STRING "")
|
||||
SET(WITH_ZLIB bundled CACHE STRING "")
|
||||
IF(RPM)
|
||||
SET(WITH_SSL system CACHE STRING "")
|
||||
SET(WITH_ZLIB system CACHE STRING "")
|
||||
ELSEIF(DEB)
|
||||
SET(WITH_SSL system CACHE STRING "")
|
||||
SET(WITH_ZLIB system CACHE STRING "")
|
||||
SET(WITH_LIBWRAP ON)
|
||||
SET(WITH_MAX ON)
|
||||
SET(HAVE_EMBEDDED_PRIVILEGE_CONTROL ON)
|
||||
ELSE()
|
||||
SET(WITH_SSL bundled CACHE STRING "")
|
||||
SET(WITH_ZLIB bundled CACHE STRING "")
|
||||
ENDIF()
|
||||
|
||||
IF(NOT COMPILATION_COMMENT)
|
||||
SET(COMPILATION_COMMENT "MariaDB Server")
|
||||
|
|
|
@ -65,6 +65,7 @@ SET(CPACK_RPM_SPEC_MORE_DEFINE "${CPACK_RPM_SPEC_MORE_DEFINE}
|
|||
SET(CPACK_RPM_PACKAGE_REQUIRES "MariaDB-common")
|
||||
|
||||
SET(CPACK_RPM_server_USER_FILELIST "%ignore /etc" "%ignore /etc/init.d")
|
||||
SET(CPACK_RPM_common_USER_FILELIST "%config(noreplace) /etc/my.cnf")
|
||||
|
||||
SET(CPACK_RPM_client_PACKAGE_OBSOLETES "mysql-client MySQL-client MySQL-OurDelta-client")
|
||||
SET(CPACK_RPM_client_PACKAGE_PROVIDES "MariaDB-client MySQL-client mysql-client")
|
||||
|
|
|
@ -364,4 +364,7 @@ SET(HAVE_SOCKADDR_IN_SIN_LEN CACHE INTERNAL "")
|
|||
SET(HAVE_SOCKADDR_IN6_SIN6_LEN CACHE INTERNAL "")
|
||||
SET(HAVE_VALGRIND CACHE INTERNAL "")
|
||||
SET(HAVE_EVENT_H CACHE INTERNAL "")
|
||||
SET(HAVE_LINUX_UNISTD_H CACHE INTERNAL "")
|
||||
SET(HAVE_SYS_UTSNAME_H CACHE INTERNAL "")
|
||||
SET(HAVE_PTHREAD_ATTR_GETGUARDSIZE CACHE INTERNAL "")
|
||||
ENDIF()
|
||||
|
|
|
@ -109,6 +109,8 @@ MACRO (FIND_CURSES)
|
|||
ENDIF()
|
||||
ENDIF()
|
||||
ENDIF()
|
||||
CHECK_LIBRARY_EXISTS(${CURSES_LIBRARY} setupterm "" HAVE_SETUPTERM)
|
||||
CHECK_LIBRARY_EXISTS(${CURSES_LIBRARY} vidattr "" HAVE_VIDATTR)
|
||||
ENDMACRO()
|
||||
|
||||
MACRO (MYSQL_USE_BUNDLED_READLINE)
|
||||
|
|
|
@ -46,6 +46,7 @@
|
|||
#cmakedefine HAVE_IEEEFP_H 1
|
||||
#cmakedefine HAVE_INTTYPES_H 1
|
||||
#cmakedefine HAVE_LIMITS_H 1
|
||||
#cmakedefine HAVE_LINUX_UNISTD_H 1
|
||||
#cmakedefine HAVE_LOCALE_H 1
|
||||
#cmakedefine HAVE_MALLOC_H 1
|
||||
#cmakedefine HAVE_MEMORY_H 1
|
||||
|
@ -83,6 +84,7 @@
|
|||
#cmakedefine HAVE_SYS_SHM_H 1
|
||||
#cmakedefine HAVE_SYS_SOCKET_H 1
|
||||
#cmakedefine HAVE_SYS_SOCKIO_H 1
|
||||
#cmakedefine HAVE_SYS_UTSNAME_H 1
|
||||
#cmakedefine HAVE_SYS_STAT_H 1
|
||||
#cmakedefine HAVE_SYS_STREAM_H 1
|
||||
#cmakedefine HAVE_SYS_TERMCAP_H 1
|
||||
|
@ -130,6 +132,7 @@
|
|||
#cmakedefine FIONREAD_IN_SYS_FILIO 1
|
||||
|
||||
/* Functions we may want to use. */
|
||||
#cmakedefine HAVE_ACCESS 1
|
||||
#cmakedefine HAVE_AIOWAIT 1
|
||||
#cmakedefine HAVE_ALARM 1
|
||||
#cmakedefine HAVE_ALLOCA 1
|
||||
|
@ -151,6 +154,7 @@
|
|||
#cmakedefine HAVE_FCONVERT 1
|
||||
#cmakedefine HAVE_FDATASYNC 1
|
||||
#cmakedefine HAVE_DECL_FDATASYNC 1
|
||||
#cmakedefine HAVE_FEDISABLEEXCEPT 1
|
||||
#cmakedefine HAVE_FESETROUND 1
|
||||
#cmakedefine HAVE_FINITE 1
|
||||
#cmakedefine HAVE_FP_EXCEPT 1
|
||||
|
@ -175,6 +179,7 @@
|
|||
#cmakedefine HAVE_GETWD 1
|
||||
#cmakedefine HAVE_GMTIME_R 1
|
||||
#cmakedefine gmtime_r @gmtime_r@
|
||||
#cmakedefine HAVE_IN_ADDR_T 1
|
||||
#cmakedefine HAVE_INITGROUPS 1
|
||||
#cmakedefine HAVE_ISSETUGID 1
|
||||
#cmakedefine HAVE_GETUID 1
|
||||
|
@ -215,6 +220,7 @@
|
|||
#cmakedefine HAVE_RDTSCLL 1
|
||||
#cmakedefine HAVE_READ_REAL_TIME 1
|
||||
#cmakedefine HAVE_PTHREAD_ATTR_CREATE 1
|
||||
#cmakedefine HAVE_PTHREAD_ATTR_GETGUARDSIZE 1
|
||||
#cmakedefine HAVE_PTHREAD_ATTR_GETSTACKSIZE 1
|
||||
#cmakedefine HAVE_PTHREAD_ATTR_SETPRIO 1
|
||||
#cmakedefine HAVE_PTHREAD_ATTR_SETSCHEDPARAM 1
|
||||
|
@ -247,6 +253,7 @@
|
|||
#cmakedefine HAVE_SETFD 1
|
||||
#cmakedefine HAVE_SETENV 1
|
||||
#cmakedefine HAVE_SETLOCALE 1
|
||||
#cmakedefine HAVE_SETUPTERM 1
|
||||
#cmakedefine HAVE_SIGADDSET 1
|
||||
#cmakedefine HAVE_SIGEMPTYSET 1
|
||||
#cmakedefine HAVE_SIGHOLD 1
|
||||
|
@ -284,6 +291,7 @@
|
|||
#cmakedefine HAVE_TIME 1
|
||||
#cmakedefine HAVE_TIMES 1
|
||||
#cmakedefine HAVE_VALLOC 1
|
||||
#cmakedefine HAVE_VIDATTR 1
|
||||
#define HAVE_VIO_READ_BUFF 1
|
||||
#cmakedefine HAVE_VASPRINTF 1
|
||||
#cmakedefine HAVE_VPRINTF 1
|
||||
|
|
|
@ -151,7 +151,7 @@ IF(UNIX)
|
|||
|
||||
IF(CMAKE_REQUIRED_LIBRARIES)
|
||||
LIST(REMOVE_DUPLICATES CMAKE_REQUIRED_LIBRARIES)
|
||||
ENDIF()
|
||||
ENDIF()
|
||||
LINK_LIBRARIES(${CMAKE_THREAD_LIBS_INIT})
|
||||
|
||||
OPTION(WITH_LIBWRAP "Compile with tcp wrappers support" OFF)
|
||||
|
@ -202,6 +202,7 @@ CHECK_INCLUDE_FILES (grp.h HAVE_GRP_H)
|
|||
CHECK_INCLUDE_FILES (ieeefp.h HAVE_IEEEFP_H)
|
||||
CHECK_INCLUDE_FILES (inttypes.h HAVE_INTTYPES_H)
|
||||
CHECK_INCLUDE_FILES (langinfo.h HAVE_LANGINFO_H)
|
||||
CHECK_INCLUDE_FILES (linux/unistd.h HAVE_LINUX_UNISTD_H)
|
||||
CHECK_INCLUDE_FILES (limits.h HAVE_LIMITS_H)
|
||||
CHECK_INCLUDE_FILES (locale.h HAVE_LOCALE_H)
|
||||
CHECK_INCLUDE_FILES (malloc.h HAVE_MALLOC_H)
|
||||
|
@ -261,6 +262,7 @@ 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)
|
||||
CHECK_INCLUDE_FILES (sys/utsname.h HAVE_SYS_UTSNAME_H)
|
||||
|
||||
IF(BFD_H_EXISTS)
|
||||
IF(NOT_FOR_DISTRIBUTION)
|
||||
|
@ -326,6 +328,7 @@ ENDIF()
|
|||
#
|
||||
# Tests for functions
|
||||
#
|
||||
CHECK_FUNCTION_EXISTS (access HAVE_ACCESS)
|
||||
#CHECK_FUNCTION_EXISTS (aiowait HAVE_AIOWAIT)
|
||||
CHECK_FUNCTION_EXISTS (aio_read HAVE_AIO_READ)
|
||||
CHECK_FUNCTION_EXISTS (alarm HAVE_ALARM)
|
||||
|
@ -554,6 +557,10 @@ IF(NOT SIZEOF_MODE_T)
|
|||
SET(mode_t int)
|
||||
ENDIF()
|
||||
|
||||
IF(HAVE_NETINET_IN_H)
|
||||
SET(CMAKE_EXTRA_INCLUDE_FILES netinet/in.h)
|
||||
MY_CHECK_TYPE_SIZE(in_addr_t IN_ADDR_T)
|
||||
ENDIF(HAVE_NETINET_IN_H)
|
||||
|
||||
IF(HAVE_STDINT_H)
|
||||
SET(CMAKE_EXTRA_INCLUDE_FILES stdint.h)
|
||||
|
|
2
debian/additions/mariadb.cnf
vendored
2
debian/additions/mariadb.cnf
vendored
|
@ -3,7 +3,7 @@
|
|||
|
||||
[client]
|
||||
# Default is Latin1, if you need UTF-8 set this (also in server section)
|
||||
#character-set-server = utf8
|
||||
#default-character-set = utf8
|
||||
|
||||
[mysqld]
|
||||
#
|
||||
|
|
2
debian/additions/my.cnf
vendored
2
debian/additions/my.cnf
vendored
|
@ -65,7 +65,7 @@ max_heap_table_size = 32M
|
|||
myisam_recover = BACKUP
|
||||
key_buffer_size = 128M
|
||||
#open-files-limit = 2000
|
||||
table_cache = 400
|
||||
table_open_cache = 400
|
||||
myisam_sort_buffer_size = 512M
|
||||
concurrent_insert = 2
|
||||
read_buffer_size = 2M
|
||||
|
|
7
debian/dist/Debian/control
vendored
7
debian/dist/Debian/control
vendored
|
@ -124,8 +124,9 @@ Provides: virtual-mysql-client, mysql-client,
|
|||
mysql-client-4.1, mysql-client-5.1, mysql-client-5.5
|
||||
Conflicts: mysql-client (<< 5.0.51), mysql-client-5.0, mysql-client-5.1,
|
||||
mariadb-client (<< ${source:Version}),
|
||||
mariadb-client-5.1, mariadb-client-5.2, mariadb-client-5.3
|
||||
mariadb-client-5.1, mariadb-client-5.2, mariadb-client-5.3, mysql-client-5.5
|
||||
Replaces: mysql-client (<< 5.0.51), mysql-client-5.0, mysql-client-5.1,
|
||||
mysql-client-5.5,
|
||||
mariadb-client (<< ${source:Version}),
|
||||
mariadb-client-5.1, mariadb-client-5.2, mariadb-client-5.3
|
||||
Description: MariaDB database client binaries
|
||||
|
@ -185,10 +186,10 @@ Pre-Depends: mariadb-common, adduser (>= 3.40), debconf
|
|||
Depends: mariadb-client-5.5 (>= ${source:Version}), libdbi-perl, perl (>= 5.6), ${shlibs:Depends}, ${misc:Depends}, psmisc, passwd, lsb-base (>= 3.0-10), mariadb-server-core-5.5 (>= ${binary:Version})
|
||||
Provides: mariadb-server, mysql-server, virtual-mysql-server
|
||||
Conflicts: mariadb-server (<< ${source:Version}), mysql-server (<< ${source:Version}),
|
||||
mysql-server-4.1, mysql-server-5.0, mysql-server-5.1,
|
||||
mysql-server-4.1, mysql-server-5.0, mysql-server-5.1, mysql-server-5.5,
|
||||
mariadb-server-5.1, mariadb-server-5.2, mariadb-server-5.3
|
||||
Replaces: mariadb-server (<< ${source:Version}), mysql-server (<< ${source:Version}),
|
||||
mysql-server-4.1, mysql-server-5.0, mysql-server-5.1,
|
||||
mysql-server-4.1, mysql-server-5.0, mysql-server-5.1, mysql-server-5.5,
|
||||
mariadb-server-5.1, mariadb-server-5.2, mariadb-server-5.3,
|
||||
libmariadbclient16 (<< 5.3.4),
|
||||
libmariadbclient-dev (<< 5.5.0)
|
||||
|
|
|
@ -21,7 +21,7 @@ invoke() {
|
|||
fi
|
||||
}
|
||||
|
||||
MYSQL_BOOTSTRAP="/usr/sbin/mysqld --bootstrap --user=mysql --skip-grant-tables --loose-innodb=OFF --loose-pbxt=OFF --default-storage-engine=myisam"
|
||||
MYSQL_BOOTSTRAP="/usr/sbin/mysqld --bootstrap --user=mysql --skip-grant-tables --loose-innodb=OFF --default-storage-engine=myisam"
|
||||
|
||||
test_mysql_access() {
|
||||
mysql --no-defaults -u root -h localhost </dev/null >/dev/null 2>&1
|
||||
|
|
23
debian/dist/Debian/rules
vendored
23
debian/dist/Debian/rules
vendored
|
@ -70,30 +70,11 @@ endif
|
|||
CXX=$${MYSQL_BUILD_CXX:-g++} \
|
||||
CXXFLAGS=$${MYSQL_BUILD_CXXFLAGS:-"-O2 -fno-omit-frame-pointer -g -pipe -Wall -Wno-uninitialized"} \
|
||||
cmake .. \
|
||||
-DCMAKE_INSTALL_PREFIX=/usr \
|
||||
-DINSTALL_SBINDIR=sbin \
|
||||
-DMYSQL_DATADIR=/var/lib/mysql \
|
||||
-DINSTALL_INCLUDEDIR=include/mysql \
|
||||
-DINSTALL_INFODIR=share/info \
|
||||
-DINSTALL_MANDIR=share/man \
|
||||
\
|
||||
-DMYSQL_SERVER_SUFFIX="-$(DEBVERSION)" \
|
||||
-DBUILD_CONFIG=mysql_release \
|
||||
-DCOMPILATION_COMMENT="mariadb.org binary distribution" \
|
||||
-DSYSTEM_TYPE="debian-linux-gnu" \
|
||||
-DINSTALL_LAYOUT=DEB \
|
||||
\
|
||||
-DENABLED_LOCAL_INFILE=1 \
|
||||
-DWITH_FAST_MUTEXES=1 \
|
||||
\
|
||||
-DMYSQL_UNIX_ADDR=/var/run/mysqld/mysqld.sock \
|
||||
\
|
||||
-DEXTRA_CHARSETS=all \
|
||||
-DWITH_LIBWRAP=1 \
|
||||
-DWITH_SSL=system \
|
||||
-DWITH_ZLIB=system \
|
||||
-DWITH_EMBEDDED_SERVER=1 \
|
||||
-DHAVE_EMBEDDED_PRIVILEGE_CONTROL=ON \
|
||||
-DWITH_MAX=1'
|
||||
-DDEB=debian'
|
||||
|
||||
touch $@
|
||||
|
||||
|
|
7
debian/dist/Ubuntu/control
vendored
7
debian/dist/Ubuntu/control
vendored
|
@ -124,8 +124,9 @@ Provides: virtual-mysql-client, mysql-client,
|
|||
mysql-client-4.1, mysql-client-5.1, mysql-client-5.5
|
||||
Conflicts: mysql-client (<< 5.0.51), mysql-client-5.0, mysql-client-5.1,
|
||||
mariadb-client (<< ${source:Version}),
|
||||
mariadb-client-5.1, mariadb-client-5.2, mariadb-client-5.3
|
||||
mariadb-client-5.1, mariadb-client-5.2, mariadb-client-5.3, mysql-client-5.5
|
||||
Replaces: mysql-client (<< 5.0.51), mysql-client-5.0, mysql-client-5.1,
|
||||
mysql-client-5.5,
|
||||
mariadb-client (<< ${source:Version}),
|
||||
mariadb-client-5.1, mariadb-client-5.2, mariadb-client-5.3
|
||||
Description: MariaDB database client binaries
|
||||
|
@ -179,10 +180,10 @@ Pre-Depends: mariadb-common, adduser (>= 3.40), debconf
|
|||
Depends: mariadb-client-5.5 (>= ${source:Version}), libdbi-perl, perl (>= 5.6), ${shlibs:Depends}, ${misc:Depends}, psmisc, passwd, lsb-base (>= 3.0-10), mariadb-server-core-5.5 (>= ${binary:Version})
|
||||
Provides: mariadb-server, mysql-server, virtual-mysql-server
|
||||
Conflicts: mariadb-server (<< ${source:Version}), mysql-server (<< ${source:Version}),
|
||||
mysql-server-4.1, mysql-server-5.0, mysql-server-5.1,
|
||||
mysql-server-4.1, mysql-server-5.0, mysql-server-5.1, mysql-server-5.5,
|
||||
mariadb-server-5.1, mariadb-server-5.2, mariadb-server-5.3
|
||||
Replaces: mariadb-server (<< ${source:Version}), mysql-server (<< ${source:Version}),
|
||||
mysql-server-4.1, mysql-server-5.0, mysql-server-5.1,
|
||||
mysql-server-4.1, mysql-server-5.0, mysql-server-5.1, mysql-server-5.5,
|
||||
mariadb-server-5.1, mariadb-server-5.2, mariadb-server-5.3,
|
||||
libmariadbclient16 (<< 5.3.4),
|
||||
libmariadbclient-dev (<< 5.5.0)
|
||||
|
|
|
@ -21,7 +21,7 @@ invoke() {
|
|||
fi
|
||||
}
|
||||
|
||||
MYSQL_BOOTSTRAP="/usr/sbin/mysqld --bootstrap --user=mysql --skip-grant-tables --loose-innodb=OFF --loose-pbxt=OFF --default-storage-engine=myisam"
|
||||
MYSQL_BOOTSTRAP="/usr/sbin/mysqld --bootstrap --user=mysql --skip-grant-tables --loose-innodb=OFF --default-storage-engine=myisam"
|
||||
|
||||
test_mysql_access() {
|
||||
mysql --no-defaults -u root -h localhost </dev/null >/dev/null 2>&1
|
||||
|
|
23
debian/dist/Ubuntu/rules
vendored
23
debian/dist/Ubuntu/rules
vendored
|
@ -70,30 +70,11 @@ endif
|
|||
CXX=$${MYSQL_BUILD_CXX:-g++} \
|
||||
CXXFLAGS=$${MYSQL_BUILD_CXXFLAGS:-"-O2 -fno-omit-frame-pointer -g -pipe -Wall -Wno-uninitialized"} \
|
||||
cmake .. \
|
||||
-DCMAKE_INSTALL_PREFIX=/usr \
|
||||
-DINSTALL_SBINDIR=sbin \
|
||||
-DMYSQL_DATADIR=/var/lib/mysql \
|
||||
-DINSTALL_INCLUDEDIR=include/mysql \
|
||||
-DINSTALL_INFODIR=share/info \
|
||||
-DINSTALL_MANDIR=share/man \
|
||||
\
|
||||
-DMYSQL_SERVER_SUFFIX="-$(DEBVERSION)" \
|
||||
-DBUILD_CONFIG=mysql_release \
|
||||
-DCOMPILATION_COMMENT="mariadb.org binary distribution" \
|
||||
-DSYSTEM_TYPE="debian-linux-gnu" \
|
||||
-DINSTALL_LAYOUT=DEB \
|
||||
\
|
||||
-DENABLED_LOCAL_INFILE=1 \
|
||||
-DWITH_FAST_MUTEXES=1 \
|
||||
\
|
||||
-DMYSQL_UNIX_ADDR=/var/run/mysqld/mysqld.sock \
|
||||
\
|
||||
-DEXTRA_CHARSETS=all \
|
||||
-DWITH_LIBWRAP=1 \
|
||||
-DWITH_SSL=system \
|
||||
-DWITH_ZLIB=system \
|
||||
-DWITH_EMBEDDED_SERVER=1 \
|
||||
-DHAVE_EMBEDDED_PRIVILEGE_CONTROL=ON \
|
||||
-DWITH_MAX=1'
|
||||
-DDEB=ubuntu'
|
||||
|
||||
touch $@
|
||||
|
||||
|
|
|
@ -25,9 +25,7 @@
|
|||
#ifndef WIN32
|
||||
# include <sys/types.h>
|
||||
# include <sys/socket.h>
|
||||
# ifndef HAVE_BROKEN_NETINET_INCLUDES
|
||||
# include <netinet/in.h>
|
||||
# endif
|
||||
# include <netinet/in.h>
|
||||
# include <arpa/inet.h>
|
||||
# include <netdb.h>
|
||||
#endif
|
||||
|
|
|
@ -36,7 +36,7 @@
|
|||
choose the Solaris implementation on Solaris (mainly for SunStudio
|
||||
compilers).
|
||||
*/
|
||||
# if defined(_MSV_VER)
|
||||
# if defined(_MSC_VER)
|
||||
# include "generic-msvc.h"
|
||||
# elif __GNUC__
|
||||
# if defined(HAVE_SOLARIS_ATOMIC)
|
||||
|
|
|
@ -148,9 +148,10 @@ typedef struct st_key_cache
|
|||
ulonglong param_partitions; /* number of the key cache partitions */
|
||||
my_bool key_cache_inited; /* <=> key cache has been created */
|
||||
my_bool can_be_used; /* usage of cache for read/write is allowed */
|
||||
my_bool in_init; /* Set to 1 in MySQL during init/resize */
|
||||
my_bool in_init; /* set to 1 in MySQL during init/resize */
|
||||
uint partitions; /* actual number of partitions */
|
||||
size_t key_cache_mem_size; /* specified size of the cache memory */
|
||||
pthread_mutex_t op_lock; /* to serialize operations like 'resize' */
|
||||
} KEY_CACHE;
|
||||
|
||||
|
||||
|
|
|
@ -62,13 +62,9 @@
|
|||
|
||||
# define bmove_align(A,B,C) memcpy((A),(B),(C))
|
||||
|
||||
#if !defined(HAVE_BCMP)
|
||||
# define bcmp(A,B,C) memcmp((A),(B),(C))
|
||||
#endif
|
||||
|
||||
#if !defined(bzero) && (!defined(HAVE_BZERO) || !HAVE_DECL_BZERO || defined(_AIX))
|
||||
/* See autoconf doku: "HAVE_DECL_symbol" will be defined after configure, to 0 or 1 */
|
||||
/* AIX has bzero() as a function, but the declaration prototype is strangely hidden */
|
||||
#if !defined(bzero)
|
||||
# define bzero(A,B) memset((A),0,(B))
|
||||
#endif
|
||||
|
||||
|
|
|
@ -229,11 +229,6 @@
|
|||
#include <sys/types.h>
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_THREADS_WITHOUT_SOCKETS
|
||||
/* MIT pthreads does not work with unix sockets */
|
||||
#undef HAVE_SYS_UN_H
|
||||
#endif
|
||||
|
||||
#define __EXTENSIONS__ 1 /* We want some extension */
|
||||
#ifndef __STDC_EXT__
|
||||
#define __STDC_EXT__ 1 /* To get large file support on hpux */
|
||||
|
@ -306,18 +301,6 @@ inline double my_ulonglong2double(unsigned long long A) { return (double A); }
|
|||
C_MODE_END
|
||||
#endif /* _AIX */
|
||||
|
||||
#ifdef HAVE_BROKEN_SNPRINTF /* HPUX 10.20 don't have this defined */
|
||||
#undef HAVE_SNPRINTF
|
||||
#endif
|
||||
#ifdef HAVE_BROKEN_PREAD
|
||||
/*
|
||||
pread()/pwrite() are not 64 bit safe on HP-UX 11.0 without
|
||||
installing the kernel patch PHKL_20349 or greater
|
||||
*/
|
||||
#undef HAVE_PREAD
|
||||
#undef HAVE_PWRITE
|
||||
#endif
|
||||
|
||||
#ifdef UNDEF_HAVE_INITGROUPS /* For AIX 4.3 */
|
||||
#undef HAVE_INITGROUPS
|
||||
#endif
|
||||
|
@ -823,18 +806,7 @@ inline unsigned long long my_double2ulonglong(double d)
|
|||
#endif
|
||||
|
||||
#ifdef HAVE_ISINF
|
||||
/* Check if C compiler is affected by GCC bug #39228 */
|
||||
#if !defined(__cplusplus) && defined(HAVE_BROKEN_ISINF)
|
||||
/* Force store/reload of the argument to/from a 64-bit double */
|
||||
static inline double my_isinf(double x)
|
||||
{
|
||||
volatile double t= x;
|
||||
return isinf(t);
|
||||
}
|
||||
#else
|
||||
/* System-provided isinf() is available and safe to use */
|
||||
#define my_isinf(X) isinf(X)
|
||||
#endif
|
||||
#else /* !HAVE_ISINF */
|
||||
#define my_isinf(X) (!finite(X) && !isnan(X))
|
||||
#endif
|
||||
|
|
|
@ -43,7 +43,7 @@ C_MODE_START
|
|||
#include <sys/ioctl.h>
|
||||
#endif
|
||||
|
||||
#if !defined(__WIN__) && !defined(HAVE_BROKEN_NETINET_INCLUDES)
|
||||
#if !defined(__WIN__)
|
||||
#include <netinet/in_systm.h>
|
||||
#include <netinet/in.h>
|
||||
#include <netinet/ip.h>
|
||||
|
|
|
@ -200,28 +200,13 @@ extern int my_pthread_create_detached;
|
|||
int sigwait(sigset_t *set, int *sig);
|
||||
#endif
|
||||
|
||||
#ifndef HAVE_NONPOSIX_SIGWAIT
|
||||
#define my_sigwait(A,B) sigwait((A),(B))
|
||||
#else
|
||||
int my_sigwait(const sigset_t *set,int *sig);
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_NONPOSIX_PTHREAD_MUTEX_INIT
|
||||
#ifndef SAFE_MUTEX
|
||||
#define pthread_mutex_init(a,b) my_pthread_mutex_noposix_init((a),(b))
|
||||
extern int my_pthread_mutex_noposix_init(pthread_mutex_t *mp,
|
||||
const pthread_mutexattr_t *attr);
|
||||
#endif /* SAFE_MUTEX */
|
||||
#define pthread_cond_init(a,b) my_pthread_cond_noposix_init((a),(b))
|
||||
extern int my_pthread_cond_noposix_init(pthread_cond_t *mp,
|
||||
const pthread_condattr_t *attr);
|
||||
#endif /* HAVE_NONPOSIX_PTHREAD_MUTEX_INIT */
|
||||
|
||||
#if defined(HAVE_SIGTHREADMASK) && !defined(HAVE_PTHREAD_SIGMASK)
|
||||
#define pthread_sigmask(A,B,C) sigthreadmask((A),(B),(C))
|
||||
#endif
|
||||
|
||||
#if !defined(HAVE_SIGWAIT) && !defined(HAVE_rts_threads) && !defined(sigwait) && !defined(alpha_linux_port) && !defined(HAVE_NONPOSIX_SIGWAIT) && !defined(HAVE_DEC_3_2_THREADS) && !defined(_AIX)
|
||||
#if !defined(HAVE_SIGWAIT) && !defined(HAVE_rts_threads) && !defined(sigwait) && !defined(alpha_linux_port) && !defined(_AIX)
|
||||
int sigwait(sigset_t *setp, int *sigp); /* Use our implemention */
|
||||
#endif
|
||||
|
||||
|
@ -247,24 +232,12 @@ int sigwait(sigset_t *setp, int *sigp); /* Use our implemention */
|
|||
#define my_sigset(A,B) signal((A),(B))
|
||||
#endif
|
||||
|
||||
#if !defined(HAVE_PTHREAD_ATTR_SETSCOPE) || defined(HAVE_DEC_3_2_THREADS)
|
||||
#if !defined(HAVE_PTHREAD_ATTR_SETSCOPE)
|
||||
#define pthread_attr_setscope(A,B)
|
||||
#undef HAVE_GETHOSTBYADDR_R /* No definition */
|
||||
#endif
|
||||
|
||||
#if defined(HAVE_BROKEN_PTHREAD_COND_TIMEDWAIT) && !defined(SAFE_MUTEX)
|
||||
extern int my_pthread_cond_timedwait(pthread_cond_t *cond,
|
||||
pthread_mutex_t *mutex,
|
||||
struct timespec *abstime);
|
||||
#define pthread_cond_timedwait(A,B,C) my_pthread_cond_timedwait((A),(B),(C))
|
||||
#endif
|
||||
|
||||
#if !defined( HAVE_NONPOSIX_PTHREAD_GETSPECIFIC)
|
||||
#define my_pthread_getspecific(A,B) ((A) pthread_getspecific(B))
|
||||
#else
|
||||
#define my_pthread_getspecific(A,B) ((A) my_pthread_getspecific_imp(B))
|
||||
void *my_pthread_getspecific_imp(pthread_key_t key);
|
||||
#endif
|
||||
|
||||
#ifndef HAVE_LOCALTIME_R
|
||||
struct tm *localtime_r(const time_t *clock, struct tm *res);
|
||||
|
@ -285,34 +258,7 @@ struct tm *gmtime_r(const time_t *clock, struct tm *res);
|
|||
#define pthread_key_delete(A) pthread_dummy(0)
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_CTHREADS_WRAPPER /* For MacOSX */
|
||||
#define pthread_cond_destroy(A) pthread_dummy(0)
|
||||
#define pthread_mutex_destroy(A) pthread_dummy(0)
|
||||
#define pthread_attr_delete(A) pthread_dummy(0)
|
||||
#define pthread_condattr_delete(A) pthread_dummy(0)
|
||||
#define pthread_attr_setstacksize(A,B) pthread_dummy(0)
|
||||
#define pthread_equal(A,B) ((A) == (B))
|
||||
#define pthread_cond_timedwait(a,b,c) pthread_cond_wait((a),(b))
|
||||
#define pthread_attr_init(A) pthread_attr_create(A)
|
||||
#define pthread_attr_destroy(A) pthread_attr_delete(A)
|
||||
#define pthread_attr_setdetachstate(A,B) pthread_dummy(0)
|
||||
#define pthread_create(A,B,C,D) pthread_create((A),*(B),(C),(D))
|
||||
#define pthread_sigmask(A,B,C) sigprocmask((A),(B),(C))
|
||||
#define pthread_kill(A,B) pthread_dummy((A) ? 0 : ESRCH)
|
||||
#undef pthread_detach_this_thread
|
||||
#define pthread_detach_this_thread() { pthread_t tmp=pthread_self() ; pthread_detach(&tmp); }
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_DARWIN5_THREADS
|
||||
#define pthread_sigmask(A,B,C) sigprocmask((A),(B),(C))
|
||||
#define pthread_kill(A,B) pthread_dummy((A) ? 0 : ESRCH)
|
||||
#define pthread_condattr_init(A) pthread_dummy(0)
|
||||
#define pthread_condattr_destroy(A) pthread_dummy(0)
|
||||
#undef pthread_detach_this_thread
|
||||
#define pthread_detach_this_thread() { pthread_t tmp=pthread_self() ; pthread_detach(tmp); }
|
||||
#endif
|
||||
|
||||
#if ((defined(HAVE_PTHREAD_ATTR_CREATE) && !defined(HAVE_SIGWAIT)) || defined(HAVE_DEC_3_2_THREADS)) && !defined(HAVE_CTHREADS_WRAPPER)
|
||||
#if defined(HAVE_PTHREAD_ATTR_CREATE) && !defined(HAVE_SIGWAIT)
|
||||
/* This is set on AIX_3_2 and Siemens unix (and DEC OSF/1 3.2 too) */
|
||||
#define pthread_key_create(A,B) \
|
||||
pthread_keycreate(A,(B) ?\
|
||||
|
@ -352,7 +298,7 @@ void my_pthread_attr_getstacksize(pthread_attr_t *attrib, size_t *size);
|
|||
int my_pthread_mutex_trylock(pthread_mutex_t *mutex);
|
||||
#endif
|
||||
|
||||
#if !defined(HAVE_PTHREAD_YIELD_ONE_ARG) && !defined(HAVE_PTHREAD_YIELD_ZERO_ARG)
|
||||
#if !defined(HAVE_PTHREAD_YIELD_ZERO_ARG)
|
||||
/* no pthread_yield() available */
|
||||
#ifdef HAVE_SCHED_YIELD
|
||||
#define pthread_yield() sched_yield()
|
||||
|
@ -541,12 +487,6 @@ int my_pthread_fastmutex_lock(my_pthread_fastmutex_t *mp);
|
|||
|
||||
/* READ-WRITE thread locking */
|
||||
|
||||
#ifdef HAVE_BROKEN_RWLOCK /* For OpenUnix */
|
||||
#undef HAVE_PTHREAD_RWLOCK_RDLOCK
|
||||
#undef HAVE_RWLOCK_INIT
|
||||
#undef HAVE_RWLOCK_T
|
||||
#endif
|
||||
|
||||
#if defined(USE_MUTEX_INSTEAD_OF_RW_LOCKS)
|
||||
/* use these defs for simple mutex locking */
|
||||
#define rw_lock_t pthread_mutex_t
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* Copyright (c) 2000, 2011, Oracle and/or its affiliates. All rights reserved.
|
||||
/* Copyright (c) 2000, 2012, Oracle and/or its affiliates. All rights reserved.
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
|
@ -10,8 +10,8 @@
|
|||
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 */
|
||||
along with this program; if not, write to the Free Software Foundation, Inc.,
|
||||
51 Franklin Street, Suite 500, Boston, MA 02110-1335 USA */
|
||||
|
||||
/*
|
||||
* Vio Lite.
|
||||
|
|
|
@ -26,10 +26,6 @@
|
|||
#include <m_string.h>
|
||||
#include <m_ctype.h>
|
||||
|
||||
#if defined(HAVE_BROKEN_GETPASS) && !defined(HAVE_GETPASSPHRASE)
|
||||
#undef HAVE_GETPASS
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_GETPASS
|
||||
#ifdef HAVE_PWD_H
|
||||
#include <pwd.h>
|
||||
|
|
|
@ -69,10 +69,10 @@ extension. For example:
|
|||
|
||||
If you want to submit your test case you can send it
|
||||
to maria-developers@lists.launchpad.com or attach it to a bug report on
|
||||
https://bugs.launchpad.net/maria/.
|
||||
http://mariadb.org/jira/.
|
||||
|
||||
If the test case is really big or if it contains 'not public' data,
|
||||
then put your .test file and .result file(s) into a tar.gz archive,
|
||||
add a README that explains the problem, ftp the archive to
|
||||
ftp://ftp.askmonty.org/private and send a mail to
|
||||
https://bugs.launchpad.net/maria/ about it.
|
||||
ftp://ftp.askmonty.org/private and submit a report to
|
||||
http://mariadb.org/jira about it.
|
||||
|
|
|
@ -30,6 +30,7 @@ BEGIN
|
|||
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_USE_NATIVE_AIO'
|
||||
ORDER BY variable_name;
|
||||
|
||||
-- Dump all databases, there should be none
|
||||
|
|
126
mysql-test/include/query_cache_partitions.inc
Normal file
126
mysql-test/include/query_cache_partitions.inc
Normal file
|
@ -0,0 +1,126 @@
|
|||
# include/query_cache_partitions.inc
|
||||
#
|
||||
# The variables
|
||||
# $engine_type -- storage engine to be tested
|
||||
# have to be set before sourcing this script.
|
||||
|
||||
eval SET SESSION STORAGE_ENGINE = $engine_type;
|
||||
|
||||
# Initialise
|
||||
--disable_warnings
|
||||
drop table if exists t1;
|
||||
--enable_warnings
|
||||
|
||||
set @save_query_cache_size = @@global.query_cache_size;
|
||||
|
||||
--echo # Test that partitions works with query cache
|
||||
|
||||
flush query cache;
|
||||
|
||||
SET GLOBAL query_cache_size=1024*1024*512;
|
||||
CREATE TABLE `t1` (
|
||||
`id` int(11) NOT NULL ,
|
||||
`created_at` datetime NOT NULL,
|
||||
`cool` tinyint default 0
|
||||
);
|
||||
|
||||
ALTER TABLE t1 PARTITION BY RANGE (TO_DAYS(created_at)) (
|
||||
PARTITION month_2010_4 VALUES LESS THAN (734258),
|
||||
PARTITION month_2010_5 VALUES LESS THAN (734289),
|
||||
PARTITION month_max VALUES LESS THAN MAXVALUE
|
||||
);
|
||||
|
||||
show create table t1;
|
||||
|
||||
INSERT INTO t1 VALUES (1, now(), 0);
|
||||
|
||||
flush status;
|
||||
show status like "Qcache_queries_in_cache";
|
||||
show status like "Qcache_hits";
|
||||
|
||||
|
||||
SELECT cool FROM `t1` WHERE (`t1`.id = 1) LIMIT 1;
|
||||
SELECT cool FROM `t1` WHERE (`t1`.id = 1) LIMIT 1;
|
||||
SELECT cool FROM `t1` WHERE (`t1`.id = 1) LIMIT 1;
|
||||
|
||||
show status like "Qcache_queries_in_cache";
|
||||
show status like "Qcache_hits";
|
||||
|
||||
drop table t1;
|
||||
|
||||
--echo # Test that sub-partitions works with query cache
|
||||
|
||||
flush query cache;
|
||||
|
||||
SET GLOBAL query_cache_size=1024*1024*512;
|
||||
CREATE TABLE `t1` (
|
||||
`id` int(11) NOT NULL ,
|
||||
`created_at` datetime NOT NULL,
|
||||
`cool` tinyint default 0
|
||||
)
|
||||
PARTITION BY RANGE (TO_DAYS(created_at))
|
||||
subpartition by hash(cool) subpartitions 3 (
|
||||
PARTITION month_2010_4 VALUES LESS THAN (734258),
|
||||
PARTITION month_2010_5 VALUES LESS THAN (734289),
|
||||
PARTITION month_max VALUES LESS THAN MAXVALUE
|
||||
);
|
||||
|
||||
show create table t1;
|
||||
|
||||
INSERT INTO t1 VALUES (1, now(), 0);
|
||||
|
||||
flush status;
|
||||
show status like "Qcache_queries_in_cache";
|
||||
show status like "Qcache_hits";
|
||||
|
||||
SELECT cool FROM `t1` WHERE (`t1`.id = 1) LIMIT 1;
|
||||
SELECT cool FROM `t1` WHERE (`t1`.id = 1) LIMIT 1;
|
||||
SELECT cool FROM `t1` WHERE (`t1`.id = 1) LIMIT 1;
|
||||
|
||||
show status like "Qcache_queries_in_cache";
|
||||
show status like "Qcache_hits";
|
||||
|
||||
drop table t1;
|
||||
|
||||
--echo #
|
||||
--echo # MySQL bug#53775 Query on partitioned table returns cached result
|
||||
--echo # from previous transaction
|
||||
--echo #
|
||||
|
||||
flush query cache;
|
||||
flush status;
|
||||
|
||||
SET GLOBAL query_cache_size=1024*1024*512;
|
||||
CREATE TABLE `t1` (
|
||||
`id` int(11) NOT NULL ,
|
||||
`created_at` datetime NOT NULL,
|
||||
`cool` tinyint default 0
|
||||
);
|
||||
|
||||
ALTER TABLE t1 PARTITION BY RANGE (TO_DAYS(created_at)) (
|
||||
PARTITION month_2010_4 VALUES LESS THAN (734258),
|
||||
PARTITION month_2010_5 VALUES LESS THAN (734289),
|
||||
PARTITION month_max VALUES LESS THAN MAXVALUE
|
||||
);
|
||||
|
||||
INSERT INTO t1 VALUES (1, now(), 0);
|
||||
|
||||
show status like "Qcache_queries_in_cache";
|
||||
show status like "Qcache_hits";
|
||||
|
||||
BEGIN;
|
||||
UPDATE `t1` SET `cool` = 1 WHERE `id` = 1;
|
||||
SELECT cool FROM `t1` WHERE (`t1`.id = 1) LIMIT 1;
|
||||
ROLLBACK;
|
||||
SELECT cool FROM `t1` WHERE (`t1`.id = 1) LIMIT 1;
|
||||
BEGIN;
|
||||
SELECT cool FROM `t1` WHERE (`t1`.id = 1) LIMIT 1;
|
||||
ROLLBACK;
|
||||
SELECT cool FROM `t1` WHERE (`t1`.id = 1) LIMIT 1;
|
||||
|
||||
show status like "Qcache_queries_in_cache";
|
||||
show status like "Qcache_hits";
|
||||
|
||||
drop table t1;
|
||||
|
||||
set @@global.query_cache_size = @save_query_cache_size;
|
|
@ -472,11 +472,13 @@ sub process_suite {
|
|||
else
|
||||
{
|
||||
my @combs;
|
||||
@combs = combinations_from_file($parent, "$suitedir/combinations")
|
||||
unless $suite->{skip};
|
||||
my $from = "$suitedir/combinations";
|
||||
@combs = combinations_from_file($parent, $from) unless $suite->{skip};
|
||||
$suite->{combinations} = [ @combs ];
|
||||
# in overlays it's a union of parent's and overlay's files.
|
||||
unshift @{$suite->{combinations}}, @{$parent->{combinations}} if $parent;
|
||||
unshift @{$suite->{combinations}},
|
||||
grep { not $skip_combinations{"$from => $_->{name}"} }
|
||||
@{$parent->{combinations}} if $parent;
|
||||
}
|
||||
|
||||
# suite.opt
|
||||
|
@ -1039,8 +1041,11 @@ sub get_tags_from_file($$) {
|
|||
$suite = load_suite_for_file($comb_file) if $prefix[0] eq '';
|
||||
my @comb;
|
||||
unless ($suite->{skip}) {
|
||||
@comb = combinations_from_file($over, "$prefix[0]$comb_file");
|
||||
push @comb, combinations_from_file(undef, "$prefix[1]$comb_file") if $over;
|
||||
my $from = "$prefix[0]$comb_file";
|
||||
@comb = combinations_from_file($over, $from);
|
||||
push @comb,
|
||||
grep { not $skip_combinations{"$from => $_->{name}"} }
|
||||
combinations_from_file(undef, "$prefix[1]$comb_file") if $over;
|
||||
}
|
||||
push @combinations, [ @comb ];
|
||||
|
||||
|
|
|
@ -1518,7 +1518,7 @@ sub command_line_setup {
|
|||
|
||||
# We make the path absolute, as the server will do a chdir() before usage
|
||||
unless ( $opt_vardir =~ m,^/, or
|
||||
(IS_WINDOWS and $opt_vardir =~ m,^[a-z]:/,i) )
|
||||
(IS_WINDOWS and $opt_vardir =~ m,^[a-z]:[/\\],i) )
|
||||
{
|
||||
# Make absolute path, relative test dir
|
||||
$opt_vardir= "$glob_mysql_test_dir/$opt_vardir";
|
||||
|
@ -2717,6 +2717,7 @@ sub setup_vardir() {
|
|||
# hm, what paths work for debs and for rpms ?
|
||||
for (<$bindir/lib64/mysql/plugin/*.so>,
|
||||
<$bindir/lib/mysql/plugin/*.so>,
|
||||
<$bindir/lib/plugin/*.so>, # bintar
|
||||
<$bindir/lib/plugin/*.dll>)
|
||||
{
|
||||
my $pname=basename($_);
|
||||
|
@ -3463,12 +3464,6 @@ sub mysql_install_db {
|
|||
mtr_add_arg($args, "--lc-messages-dir=%s", $install_lang);
|
||||
mtr_add_arg($args, "--character-sets-dir=%s", $install_chsdir);
|
||||
|
||||
# On some old linux kernels, aio on tmpfs is not supported
|
||||
# Remove this if/when Bug #58421 fixes this in the server
|
||||
if ($^O eq "linux" && $opt_mem) {
|
||||
mtr_add_arg($args, "--loose-skip-innodb-use-native-aio");
|
||||
}
|
||||
|
||||
# InnoDB arguments that affect file location and sizes may
|
||||
# need to be given to the bootstrap process as well as the
|
||||
# server process.
|
||||
|
@ -4742,6 +4737,10 @@ sub extract_warning_lines ($$) {
|
|||
qr|Access denied for user|,
|
||||
qr|Aborted connection|,
|
||||
qr|table.*is full|,
|
||||
qr|Linux Native AIO|, # warning that aio does not work on /dev/shm
|
||||
qr|Error: io_setup\(\) failed|,
|
||||
qr|Warning: io_setup\(\) failed|,
|
||||
qr|Warning: io_setup\(\) attempt|,
|
||||
);
|
||||
|
||||
my $matched_lines= [];
|
||||
|
@ -5245,13 +5244,6 @@ sub mysqld_arguments ($$$) {
|
|||
mtr_add_arg($args, "--user=root");
|
||||
}
|
||||
|
||||
# On some old linux kernels, aio on tmpfs is not supported
|
||||
# Remove this if/when Bug #58421 fixes this in the server
|
||||
if ($^O eq "linux" && $opt_mem)
|
||||
{
|
||||
mtr_add_arg($args, "--loose-skip-innodb-use-native-aio");
|
||||
}
|
||||
|
||||
if (!using_extern() and !$opt_user_args)
|
||||
{
|
||||
# Turn on logging to file
|
||||
|
@ -5292,6 +5284,7 @@ sub mysqld_arguments ($$$) {
|
|||
}
|
||||
elsif ($plugin = mtr_match_prefix($arg, "--plugin-load="))
|
||||
{
|
||||
next if $plugin =~ /=$/;
|
||||
push @plugins, $plugin unless $seen{$plugin};
|
||||
$seen{$plugin} = 1;
|
||||
}
|
||||
|
|
56
mysql-test/r/bug12427262.result
Normal file
56
mysql-test/r/bug12427262.result
Normal file
|
@ -0,0 +1,56 @@
|
|||
#
|
||||
# Bug#12427262 : 60961: SHOW TABLES VERY SLOW WHEN NOT IN SYSTEM DISK CACHE.
|
||||
#
|
||||
create database show_table_lw_db;
|
||||
use show_table_lw_db;
|
||||
create table t1 (c1 int);
|
||||
create table t2 (c1 int);
|
||||
create table t3 (c1 int);
|
||||
create table t4 (c1 int);
|
||||
create table t5 (c1 int);
|
||||
create table t6 (c1 int);
|
||||
create table t7 (c1 int);
|
||||
create table t8 (c1 int);
|
||||
create table t9 (c1 int);
|
||||
create table t10 (c1 int);
|
||||
select Sum(ALL(COUNT_READ)) from performance_schema.file_summary_by_instance where FILE_NAME
|
||||
like "%show_table_lw_db%" AND FILE_NAME like "%.frm%" AND EVENT_NAME='wait/io/file/sql/FRM'
|
||||
into @count_read_before;
|
||||
show tables;
|
||||
Tables_in_show_table_lw_db
|
||||
t1
|
||||
t10
|
||||
t2
|
||||
t3
|
||||
t4
|
||||
t5
|
||||
t6
|
||||
t7
|
||||
t8
|
||||
t9
|
||||
select Sum(ALL(COUNT_READ)) from performance_schema.file_summary_by_instance where FILE_NAME
|
||||
like "%show_table_lw_db%" AND FILE_NAME like "%.frm%" AND EVENT_NAME='wait/io/file/sql/FRM'
|
||||
into @count_read_after;
|
||||
select @count_read_after-@count_read_before;
|
||||
@count_read_after-@count_read_before
|
||||
0.000000000000000000000000000000
|
||||
show full tables;
|
||||
Tables_in_show_table_lw_db Table_type
|
||||
t1 BASE TABLE
|
||||
t10 BASE TABLE
|
||||
t2 BASE TABLE
|
||||
t3 BASE TABLE
|
||||
t4 BASE TABLE
|
||||
t5 BASE TABLE
|
||||
t6 BASE TABLE
|
||||
t7 BASE TABLE
|
||||
t8 BASE TABLE
|
||||
t9 BASE TABLE
|
||||
select Sum(ALL(COUNT_READ)) from performance_schema.file_summary_by_instance where FILE_NAME
|
||||
like "%show_table_lw_db%" AND FILE_NAME like "%.frm%" AND EVENT_NAME='wait/io/file/sql/FRM'
|
||||
into @count_read_after;
|
||||
select @count_read_after-@count_read_before;
|
||||
@count_read_after-@count_read_before
|
||||
10.000000000000000000000000000000
|
||||
drop table t1;
|
||||
drop database show_table_lw_db;
|
|
@ -161,24 +161,24 @@ prepare stmt1 from @stmt ;
|
|||
execute stmt1 ;
|
||||
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
|
||||
5 DEPENDENT SUBQUERY NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables
|
||||
4 DEPENDENT SUBQUERY NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables
|
||||
3 DEPENDENT SUBQUERY NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables
|
||||
2 DEPENDENT SUBQUERY NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables
|
||||
5 SUBQUERY NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables
|
||||
4 SUBQUERY NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables
|
||||
3 SUBQUERY NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables
|
||||
2 SUBQUERY NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables
|
||||
execute stmt1 ;
|
||||
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
|
||||
5 DEPENDENT SUBQUERY NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables
|
||||
4 DEPENDENT SUBQUERY NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables
|
||||
3 DEPENDENT SUBQUERY NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables
|
||||
2 DEPENDENT SUBQUERY NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables
|
||||
5 SUBQUERY NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables
|
||||
4 SUBQUERY NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables
|
||||
3 SUBQUERY NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables
|
||||
2 SUBQUERY NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables
|
||||
explain SELECT (SELECT SUM(c1 + c12 + 0.0) FROM t2 where (t1.c2 - 0e-3) = t2.c2 GROUP BY t1.c15 LIMIT 1) as scalar_s, exists (select 1.0e+0 from t2 where t2.c3 * 9.0000000000 = t1.c4) as exists_s, c5 * 4 in (select c6 + 0.3e+1 from t2) as in_s, (c7 - 4, c8 - 4) in (select c9 + 4.0, c10 + 40e-1 from t2) as in_row_s FROM t1, (select c25 x, c32 y from t2) tt WHERE x * 1 = c25;
|
||||
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
|
||||
5 DEPENDENT SUBQUERY NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables
|
||||
4 DEPENDENT SUBQUERY NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables
|
||||
3 DEPENDENT SUBQUERY NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables
|
||||
2 DEPENDENT SUBQUERY NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables
|
||||
5 SUBQUERY NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables
|
||||
4 SUBQUERY NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables
|
||||
3 SUBQUERY NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables
|
||||
2 SUBQUERY NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables
|
||||
deallocate prepare stmt1;
|
||||
drop tables t1,t2;
|
||||
set @@optimizer_switch=@save_optimizer_switch;
|
||||
|
|
|
@ -1682,7 +1682,7 @@ 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)
|
||||
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`)
|
||||
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 AND t.c = t1.a;
|
||||
|
@ -1713,7 +1713,7 @@ 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; 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`)
|
||||
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 AND t.c = t1.a;
|
||||
|
|
|
@ -225,10 +225,10 @@ INSERT INTO t2 VALUES (NULL), (0);
|
|||
EXPLAIN EXTENDED SELECT (SELECT 1 FROM t2 WHERE d = c) 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
|
||||
2 DEPENDENT SUBQUERY t2 ALL NULL NULL NULL NULL 2 100.00 Using where
|
||||
2 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 <expr_cache><NULL>((select 1 from `test`.`t2` where (`test`.`t2`.`d` = NULL))) AS `(SELECT 1 FROM t2 WHERE d = c)` from dual
|
||||
Note 1003 select (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
|
||||
|
@ -260,7 +260,7 @@ FLUSH TABLES;
|
|||
EXPLAIN SELECT 1 FROM t1 WHERE a = (SELECT 1 FROM t1 t JOIN t2 WHERE b <= 1 AND t.a);
|
||||
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 NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables
|
||||
2 SUBQUERY NULL NULL NULL NULL NULL NULL NULL no matching row in const table
|
||||
DROP TABLE t1, t2;
|
||||
#
|
||||
# Bug #48573: difference of index selection between rpm binary and
|
||||
|
@ -287,7 +287,7 @@ WHERE t1.f1 GROUP BY t1.f1));
|
|||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 PRIMARY t1 system NULL NULL NULL NULL 1
|
||||
2 SUBQUERY a system NULL NULL NULL NULL 1
|
||||
2 SUBQUERY t1 fulltext f1_2,f1 f1 0 1 Using where
|
||||
2 SUBQUERY t1 fulltext f1_2,f1 f1 0 1
|
||||
PREPARE stmt FROM
|
||||
'EXPLAIN SELECT 1 FROM t1
|
||||
WHERE 1 > ALL((SELECT t1.f1 FROM t1 RIGHT OUTER JOIN t1 a
|
||||
|
@ -297,12 +297,12 @@ EXECUTE stmt;
|
|||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 PRIMARY t1 system NULL NULL NULL NULL 1
|
||||
2 SUBQUERY a system NULL NULL NULL NULL 1
|
||||
2 SUBQUERY t1 fulltext f1_2,f1 f1 0 1 Using where
|
||||
2 SUBQUERY t1 fulltext f1_2,f1 f1 0 1
|
||||
EXECUTE stmt;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 PRIMARY t1 system NULL NULL NULL NULL 1
|
||||
2 SUBQUERY a system NULL NULL NULL NULL 1
|
||||
2 SUBQUERY t1 fulltext f1_2,f1 f1 0 1 Using where
|
||||
2 SUBQUERY t1 fulltext f1_2,f1 f1 0 1
|
||||
DEALLOCATE PREPARE stmt;
|
||||
PREPARE stmt FROM
|
||||
'EXPLAIN SELECT 1 FROM t1
|
||||
|
@ -313,12 +313,12 @@ EXECUTE stmt;
|
|||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 PRIMARY t1 system NULL NULL NULL NULL 1
|
||||
2 SUBQUERY a system NULL NULL NULL NULL 1
|
||||
2 SUBQUERY t1 fulltext f1_2,f1 f1 0 1 Using where
|
||||
2 SUBQUERY t1 fulltext f1_2,f1 f1 0 1
|
||||
EXECUTE stmt;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 PRIMARY t1 system NULL NULL NULL NULL 1
|
||||
2 SUBQUERY a system NULL NULL NULL NULL 1
|
||||
2 SUBQUERY t1 fulltext f1_2,f1 f1 0 1 Using where
|
||||
2 SUBQUERY t1 fulltext f1_2,f1 f1 0 1
|
||||
DEALLOCATE PREPARE stmt;
|
||||
DROP TABLE t1;
|
||||
End of 5.1 tests.
|
||||
|
|
|
@ -1838,7 +1838,7 @@ id select_type table type possible_keys key key_len ref rows filtered Extra
|
|||
1 PRIMARY t1 range a a 4 NULL 4 100.00 Using where; Using index
|
||||
2 SUBQUERY NULL NULL NULL NULL NULL NULL NULL NULL No tables used
|
||||
Warnings:
|
||||
Note 1003 select max(`test`.`t1`.`a`) AS `MAX(a)` from `test`.`t1` where (<expr_cache><<cache>(1),<cache>(2)>(<in_optimizer>(<cache>((1,2)),<exists>(select 3,4 having (((1 = 3) or isnull(3)) and ((2 = 4) or isnull(4)) and <is_not_null_test>(3) and <is_not_null_test>(4))))) and (`test`.`t1`.`a` < 10))
|
||||
Note 1003 select max(`test`.`t1`.`a`) AS `MAX(a)` from `test`.`t1` where (<cache>(<in_optimizer>((1,2),<exists>(select 3,4 having (((1 = 3) or isnull(3)) and ((2 = 4) or isnull(4)) and <is_not_null_test>(3) and <is_not_null_test>(4))))) and (`test`.`t1`.`a` < 10))
|
||||
SELECT MAX(a) FROM t1 WHERE (1,2) IN (SELECT 3,4) AND a<10;
|
||||
MAX(a)
|
||||
NULL
|
||||
|
|
|
@ -204,4 +204,30 @@ SELECT BIT_XOR(t1.b) FROM t1 JOIN t2 ON t1.c=t2.c WHERE t1.pk=1;
|
|||
BIT_XOR(t1.b)
|
||||
0
|
||||
DROP TABLE t1, t2;
|
||||
#
|
||||
# Bug#12713907: STRANGE OPTIMIZE & WRONG RESULT UNDER ORDER BY
|
||||
# COUNT(*) LIMIT.
|
||||
#
|
||||
CREATE TABLE t1 (
|
||||
id BIGINT(20) ,
|
||||
member_id_to INT(11) ,
|
||||
r_date DATE ,
|
||||
PRIMARY KEY (id,r_date),
|
||||
KEY r_date_idx (r_date),
|
||||
KEY t1_idx01 (member_id_to)
|
||||
) ENGINE=InnoDB;
|
||||
INSERT INTO t1 VALUES
|
||||
(107924526,518491,'2011-05-01'),
|
||||
(107924527,518491,'2011-05-01'),
|
||||
(107924534,518491,'2011-06-21'),
|
||||
(107924535,518491,'2011-06-21'),
|
||||
(107924542,1601319,'2011-06-21'),
|
||||
(107924543,1601319,'2011-06-21'),
|
||||
(107924544,1601319,'2011-06-21'),
|
||||
(107924545,1601319,'2011-06-21');
|
||||
SELECT member_id_to, COUNT(*) FROM t1 WHERE r_date =
|
||||
'2011-06-21' GROUP BY member_id_to ORDER BY 2 LIMIT 1;
|
||||
member_id_to COUNT(*)
|
||||
518491 2
|
||||
DROP TABLE t1;
|
||||
End of 5.5 tests
|
||||
|
|
|
@ -789,3 +789,26 @@ DROP TABLE t1;
|
|||
# End of test BUG#13012483
|
||||
#
|
||||
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
|
||||
select * from t1 where b in ('2.1');
|
||||
a b
|
||||
select * from t1 where a='2.1';
|
||||
a b
|
||||
select * from t1 where b='2.1';
|
||||
a b
|
||||
select * from t1 where IF(1,a,a)='2.1';
|
||||
a b
|
||||
drop table t1;
|
||||
#
|
||||
# LP bug#992380 Crash when creating PS for a query with
|
||||
# subquery in WHERE (see also mysql bug#13012483)
|
||||
#
|
||||
CREATE TABLE t1 (a INT);
|
||||
PREPARE s FROM "SELECT 1 FROM t1 WHERE 1 < ALL (SELECT @:= (1 IN (SELECT 1 FROM t1)) FROM t1)";
|
||||
EXECUTE s;
|
||||
1
|
||||
DROP TABLE t1;
|
||||
# End of 5.3 tests
|
||||
|
|
|
@ -279,3 +279,44 @@ NULL
|
|||
SELECT GREATEST(1.5E+2,1.3E+2,NULL) FROM DUAL;
|
||||
GREATEST(1.5E+2,1.3E+2,NULL)
|
||||
NULL
|
||||
create table t1 (a int);
|
||||
insert into t1 values (1), (100), (0), (NULL);
|
||||
select not a from t1;
|
||||
not a
|
||||
0
|
||||
0
|
||||
1
|
||||
NULL
|
||||
explain extended select not a from t1;
|
||||
id select_type table type possible_keys key key_len ref rows filtered Extra
|
||||
1 SIMPLE t1 ALL NULL NULL NULL NULL 4 100.00
|
||||
Warnings:
|
||||
Note 1003 select (`test`.`t1`.`a` = 0) AS `not a` from `test`.`t1`
|
||||
select * from t1 where not a;
|
||||
a
|
||||
0
|
||||
explain extended select * from t1 where not a;
|
||||
id select_type table type possible_keys key key_len ref rows filtered Extra
|
||||
1 SIMPLE t1 ALL NULL NULL NULL NULL 4 100.00 Using where
|
||||
Warnings:
|
||||
Note 1003 select `test`.`t1`.`a` AS `a` from `test`.`t1` where (`test`.`t1`.`a` = 0)
|
||||
select not (a+0) from t1;
|
||||
not (a+0)
|
||||
0
|
||||
0
|
||||
1
|
||||
NULL
|
||||
explain extended select not (a+0) from t1;
|
||||
id select_type table type possible_keys key key_len ref rows filtered Extra
|
||||
1 SIMPLE t1 ALL NULL NULL NULL NULL 4 100.00
|
||||
Warnings:
|
||||
Note 1003 select (not((`test`.`t1`.`a` + 0))) AS `not (a+0)` from `test`.`t1`
|
||||
select * from t1 where not (a+0);
|
||||
a
|
||||
0
|
||||
explain extended select * from t1 where not (a+0);
|
||||
id select_type table type possible_keys key key_len ref rows filtered Extra
|
||||
1 SIMPLE t1 ALL NULL NULL NULL NULL 4 100.00 Using where
|
||||
Warnings:
|
||||
Note 1003 select `test`.`t1`.`a` AS `a` from `test`.`t1` where (not((`test`.`t1`.`a` + 0)))
|
||||
drop table t1;
|
||||
|
|
|
@ -2398,12 +2398,12 @@ EXPLAIN SELECT 1 FROM t1 AS t1_outer WHERE EXISTS
|
|||
(SELECT max(b) FROM t1 GROUP BY a HAVING a < 2);
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 PRIMARY t1_outer index NULL a 10 NULL 15 Using index
|
||||
2 SUBQUERY t1 index NULL a 10 NULL 1 Using index
|
||||
2 SUBQUERY t1 index NULL a 10 NULL 15 Using index
|
||||
EXPLAIN SELECT 1 FROM t1 AS t1_outer WHERE
|
||||
(SELECT max(b) FROM t1 GROUP BY a HAVING a < 2) > 12;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 PRIMARY t1_outer index NULL a 10 NULL 15 Using index
|
||||
2 SUBQUERY t1 range NULL a 5 NULL 8 Using index for group-by
|
||||
1 PRIMARY NULL NULL NULL NULL NULL NULL NULL Impossible WHERE
|
||||
2 SUBQUERY t1 index NULL a 10 NULL 15 Using index
|
||||
EXPLAIN SELECT 1 FROM t1 AS t1_outer WHERE
|
||||
a IN (SELECT max(b) FROM t1 GROUP BY a HAVING a < 2);
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
|
@ -2419,9 +2419,9 @@ EXPLAIN SELECT 1 FROM t1 AS t1_outer1 JOIN t1 AS t1_outer2
|
|||
ON t1_outer1.a = (SELECT max(b) FROM t1 GROUP BY a HAVING a < 2)
|
||||
AND t1_outer1.b = t1_outer2.b;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 PRIMARY t1_outer1 ref a a 5 const 2 Using where; Using index
|
||||
1 PRIMARY t1_outer1 ref a a 5 const 1 Using where; Using index
|
||||
1 PRIMARY t1_outer2 index NULL a 10 NULL 15 Using where; Using index; Using join buffer (flat, BNL join)
|
||||
2 SUBQUERY t1 range NULL a 5 NULL 8 Using index for group-by
|
||||
2 SUBQUERY t1 index NULL a 10 NULL 15 Using index
|
||||
EXPLAIN SELECT (SELECT (SELECT max(b) FROM t1 GROUP BY a HAVING a < 2) x
|
||||
FROM t1 AS t1_outer) x2 FROM t1 AS t1_outer2;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
|
@ -2756,8 +2756,8 @@ 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 Using where; Using index
|
||||
x x x x x x x x x Using where; Using index
|
||||
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 index
|
||||
SELECT MIN( a ) FROM t1 WHERE a = (SELECT a FROM t1 WHERE a < 0);
|
||||
MIN( a )
|
||||
NULL
|
||||
|
@ -2828,8 +2828,8 @@ 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 Using where; Using index
|
||||
x x x x x x x x x Using where; Using index
|
||||
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 index
|
||||
SELECT MIN( a ) FROM t1 WHERE a = (SELECT a FROM t1 WHERE a < 0);
|
||||
MIN( a )
|
||||
NULL
|
||||
|
@ -2907,8 +2907,8 @@ 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 Using where; Using index
|
||||
x x x x x x x x x Using where; Using index
|
||||
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 index
|
||||
SELECT MIN( a ) FROM t1 WHERE a = (SELECT a FROM t1 WHERE a < 0);
|
||||
MIN( a )
|
||||
NULL
|
||||
|
|
|
@ -654,7 +654,7 @@ EXPLAIN SELECT t1.f1 FROM t1
|
|||
WHERE (SELECT COUNT(*) FROM t2 WHERE t2.f3 = 'h' AND t2.f2 = t1.f1) = 0 AND t1.f1 = 2;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 PRIMARY t1 const PRIMARY PRIMARY 4 const 1 Using index
|
||||
2 DEPENDENT SUBQUERY t2 index_merge f2,f3 f3,f2 2,5 NULL 1 Using intersect(f3,f2); Using where; Using index
|
||||
2 SUBQUERY t2 index_merge f2,f3 f3,f2 2,5 NULL 1 Using intersect(f3,f2); Using where; Using index
|
||||
DROP TABLE t1,t2;
|
||||
#
|
||||
# BUG#56862/640419: Wrong result with sort_union index merge when one
|
||||
|
@ -777,4 +777,19 @@ commit;
|
|||
select * from t1 where t1.zone_id=830 AND modified=9;
|
||||
pk zone_id modified
|
||||
drop table t0, t1;
|
||||
#
|
||||
# MDEV-376: Wrong result (missing rows) with index_merge+index_merge_intersection, join
|
||||
#
|
||||
CREATE TABLE t1 (
|
||||
a INT, b CHAR(1), c CHAR(1), KEY(a), KEY(b)
|
||||
) ENGINE=InnoDB;
|
||||
INSERT INTO t1 VALUES (8,'v','v'),(8,'m','m'),(9,'d','d');
|
||||
SELECT ta.* FROM t1 AS ta, t1 AS tb
|
||||
WHERE ( tb.b != ta.b OR tb.a = ta.a )
|
||||
AND ( tb.b = ta.c OR tb.b = ta.b );
|
||||
a b c
|
||||
8 v v
|
||||
8 m m
|
||||
9 d d
|
||||
DROP TABLE t1;
|
||||
set optimizer_switch= @optimizer_switch_save;
|
||||
|
|
|
@ -1487,7 +1487,7 @@ EXPLAIN SELECT t1.f1 FROM t1
|
|||
WHERE (SELECT COUNT(*) FROM t2 WHERE t2.f3 = 'h' AND t2.f2 = t1.f1) = 0 AND t1.f1 = 2;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 PRIMARY t1 system PRIMARY NULL NULL NULL 1
|
||||
2 DEPENDENT SUBQUERY t2 ref f2,f3 f2 5 const 1 Using where
|
||||
2 SUBQUERY t2 ref f2,f3 f2 5 const 1 Using where
|
||||
DROP TABLE t1,t2;
|
||||
create table t0 (a int);
|
||||
insert into t0 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9);
|
||||
|
|
|
@ -1895,10 +1895,10 @@ EXPLAIN EXTENDED
|
|||
SELECT t2.a FROM t1 LEFT JOIN t2 ON (6) IN (SELECT a FROM t3);
|
||||
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 1 100.00 Using where
|
||||
1 PRIMARY t2 system NULL NULL NULL NULL 1 100.00
|
||||
2 SUBQUERY t3 ALL NULL NULL NULL NULL 2 100.00 Using where
|
||||
Warnings:
|
||||
Note 1003 select `test`.`t2`.`a` AS `a` from `test`.`t2` where 1
|
||||
Note 1003 select NULL AS `a` from `test`.`t2` where 1
|
||||
DROP TABLE t1,t2,t3;
|
||||
#
|
||||
# LP bug #817384 Wrong result with outer join + subquery in ON
|
||||
|
|
|
@ -1906,10 +1906,10 @@ EXPLAIN EXTENDED
|
|||
SELECT t2.a FROM t1 LEFT JOIN t2 ON (6) IN (SELECT a FROM t3);
|
||||
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 1 100.00 Using where
|
||||
1 PRIMARY t2 system NULL NULL NULL NULL 1 100.00
|
||||
2 SUBQUERY t3 ALL NULL NULL NULL NULL 2 100.00 Using where
|
||||
Warnings:
|
||||
Note 1003 select `test`.`t2`.`a` AS `a` from `test`.`t2` where 1
|
||||
Note 1003 select NULL AS `a` from `test`.`t2` where 1
|
||||
DROP TABLE t1,t2,t3;
|
||||
#
|
||||
# LP bug #817384 Wrong result with outer join + subquery in ON
|
||||
|
|
|
@ -598,8 +598,8 @@ VALUES
|
|||
EXPLAIN SELECT 1 FROM t1 AS t1_outer WHERE
|
||||
(SELECT max(b) FROM t1 GROUP BY a HAVING a < 2) > 12;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 PRIMARY t1_outer index NULL a 10 NULL 15 Using index
|
||||
2 SUBQUERY t1 range NULL a 5 NULL 8 Using index for group-by
|
||||
1 PRIMARY NULL NULL NULL NULL NULL NULL NULL Impossible WHERE
|
||||
2 SUBQUERY t1 index NULL a 10 NULL 15 Using index
|
||||
SELECT 1 as RES FROM t1 AS t1_outer WHERE
|
||||
(SELECT max(b) FROM t1 GROUP BY a HAVING a < 2) > 12;
|
||||
RES
|
||||
|
|
|
@ -679,7 +679,7 @@ id select_type table type possible_keys key key_len ref rows Extra
|
|||
1 PRIMARY t1 system NULL NULL NULL NULL 1 Using temporary
|
||||
1 PRIMARY t2 ALL NULL NULL NULL NULL 3 Distinct
|
||||
2 SUBQUERY t3 ALL NULL NULL NULL NULL 3
|
||||
2 SUBQUERY t2 ALL NULL NULL NULL NULL 3 Using where; Using join buffer (flat, BNL join)
|
||||
2 SUBQUERY t2 ALL NULL NULL NULL NULL 3
|
||||
SELECT DISTINCT a AS field1 FROM t1, t2
|
||||
WHERE EXISTS (SELECT c FROM t3 LEFT JOIN t2 ON b = d)
|
||||
HAVING field1 > 'aaa' LIMIT ROWS EXAMINED 20;
|
||||
|
|
22
mysql-test/r/mdev316.result
Normal file
22
mysql-test/r/mdev316.result
Normal file
|
@ -0,0 +1,22 @@
|
|||
set names swe7;
|
||||
select '' in ('',convert(0,time));
|
||||
'' in ('',convert(0,time))
|
||||
1
|
||||
select case '' when '' then 1 when convert(0,time) then 2 end;
|
||||
case '' when '' then 1 when convert(0,time) then 2 end
|
||||
1
|
||||
select convert(0x0030 using ucs2) div 1, concat(convert(0x0030 using ucs2)) div 1;
|
||||
convert(0x0030 using ucs2) div 1 concat(convert(0x0030 using ucs2)) div 1
|
||||
0 0
|
||||
select cast(convert(0x0030 using ucs2) as double), cast(concat(convert(0x0030 using ucs2)) as double);
|
||||
cast(convert(0x0030 using ucs2) as double) cast(concat(convert(0x0030 using ucs2)) as double)
|
||||
0 0
|
||||
select cast(convert(0x0030 using ucs2) as decimal(5.2)), cast(concat(convert(0x0030 using ucs2)) as decimal(5.2));
|
||||
cast(convert(0x0030 using ucs2) as decimal(5.2)) cast(concat(convert(0x0030 using ucs2)) as decimal(5.2))
|
||||
0 0
|
||||
select cast(convert(_ucs2 0x0030 using latin1) as date), cast(concat(convert(_ucs2 0x0030 using latin1)) as date);
|
||||
cast(convert(_ucs2 0x0030 using latin1) as date) cast(concat(convert(_ucs2 0x0030 using latin1)) as date)
|
||||
NULL NULL
|
||||
Warnings:
|
||||
Warning 1292 Incorrect datetime value: '0'
|
||||
Warning 1292 Incorrect datetime value: '0'
|
14
mysql-test/r/mdev375.result
Normal file
14
mysql-test/r/mdev375.result
Normal file
|
@ -0,0 +1,14 @@
|
|||
SET GLOBAL log_warnings=4;
|
||||
SET GLOBAL max_connections=2;
|
||||
SELECT 1;
|
||||
1
|
||||
1
|
||||
SELECT 2;
|
||||
2
|
||||
2
|
||||
ERROR HY000: Too many connections
|
||||
SELECT 0;
|
||||
0
|
||||
0
|
||||
SET GLOBAL log_warnings=default;
|
||||
SET GLOBAL max_connections=default;
|
|
@ -349,10 +349,10 @@ WHERE t2.int_key IS NULL
|
|||
GROUP BY t2.pk
|
||||
);
|
||||
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 NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE
|
||||
2 SUBQUERY t2 ref int_key int_key 5 const 1 100.00 Using index condition
|
||||
Warnings:
|
||||
Note 1003 select min(1) AS `MIN(t1.pk)` from dual where exists(select `test`.`t2`.`pk` from `test`.`t2` where isnull(`test`.`t2`.`int_key`))
|
||||
Note 1003 select min(`test`.`t1`.`pk`) AS `MIN(t1.pk)` from `test`.`t1` where 0
|
||||
DROP TABLE t1, t2;
|
||||
#
|
||||
# BUG#42048 Discrepancy between MyISAM and Maria's ICP implementation
|
||||
|
|
|
@ -159,6 +159,10 @@ The following options may be given as the first argument:
|
|||
Enable the event scheduler. Possible values are ON, OFF,
|
||||
and DISABLED (keep the event scheduler completely
|
||||
deactivated, it cannot be activated run-time)
|
||||
--expensive-subquery-limit=#
|
||||
The maximum number of rows a subquery may examine in
|
||||
order to be executed during optimization and used for
|
||||
constant optimization
|
||||
--expire-logs-days=#
|
||||
If non-zero, binary logs will be purged after
|
||||
expire_logs_days days; possible purges happen at startup
|
||||
|
@ -885,6 +889,7 @@ delayed-queue-size 1000
|
|||
div-precision-increment 4
|
||||
engine-condition-pushdown FALSE
|
||||
event-scheduler OFF
|
||||
expensive-subquery-limit 100
|
||||
expire-logs-days 0
|
||||
external-locking FALSE
|
||||
extra-max-connections 1
|
||||
|
|
|
@ -5222,3 +5222,48 @@ DROP DATABASE b12809202_db;
|
|||
# Delete all existing binary logs.
|
||||
#
|
||||
RESET MASTER;
|
||||
#
|
||||
# Bug#45740 MYSQLDUMP DOESN'T DUMP GENERAL_LOG AND SLOW_QUERY CAUSES RESTORE PROBLEM
|
||||
#
|
||||
SET @old_log_output_state= @@global.log_output;
|
||||
SET @old_general_log_state= @@global.general_log;
|
||||
SET @old_slow_query_log_state= @@global.slow_query_log;
|
||||
call mtr.add_suppression("Failed to write to mysql.general_log");
|
||||
SET @@global.log_output="TABLE";
|
||||
SET @@global.general_log='OFF';
|
||||
SET @@global.slow_query_log='OFF';
|
||||
DROP DATABASE mysql;
|
||||
Warnings:
|
||||
Error 1146 Table 'mysql.proc' doesn't exist
|
||||
Error 1146 Table 'mysql.event' doesn't exist
|
||||
SHOW CREATE TABLE mysql.general_log;
|
||||
Table Create Table
|
||||
general_log CREATE TABLE `general_log` (
|
||||
`event_time` timestamp(6) NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
|
||||
`user_host` mediumtext NOT NULL,
|
||||
`thread_id` int(11) NOT NULL,
|
||||
`server_id` int(10) unsigned NOT NULL,
|
||||
`command_type` varchar(64) NOT NULL,
|
||||
`argument` mediumtext NOT NULL
|
||||
) ENGINE=CSV DEFAULT CHARSET=utf8 COMMENT='General log'
|
||||
SHOW CREATE TABLE mysql.slow_log;
|
||||
Table Create Table
|
||||
slow_log CREATE TABLE `slow_log` (
|
||||
`start_time` timestamp(6) NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
|
||||
`user_host` mediumtext NOT NULL,
|
||||
`query_time` time(6) NOT NULL,
|
||||
`lock_time` time(6) NOT NULL,
|
||||
`rows_sent` int(11) NOT NULL,
|
||||
`rows_examined` int(11) NOT NULL,
|
||||
`db` varchar(512) NOT NULL,
|
||||
`last_insert_id` int(11) NOT NULL,
|
||||
`insert_id` int(11) NOT NULL,
|
||||
`server_id` int(10) unsigned NOT NULL,
|
||||
`sql_text` mediumtext NOT NULL
|
||||
) ENGINE=CSV DEFAULT CHARSET=utf8 COMMENT='Slow log'
|
||||
SET @@global.log_output= @old_log_output_state;
|
||||
SET @@global.slow_query_log= @old_slow_query_log_state;
|
||||
SET @@global.general_log= @old_general_log_state;
|
||||
#
|
||||
# End of 5.1 tests
|
||||
#
|
||||
|
|
|
@ -690,6 +690,7 @@ Got one of the listed errors
|
|||
insert into t1 values ("Abcd");
|
||||
Got one of the listed errors
|
||||
garbage;
|
||||
SELECT * FROM non_existing_table;
|
||||
drop table t2;
|
||||
create table t1 ( f1 char(10));
|
||||
insert into t1 values ("Abcd");
|
||||
|
|
1
mysql-test/r/mysqltest_256.result
Normal file
1
mysql-test/r/mysqltest_256.result
Normal file
|
@ -0,0 +1 @@
|
|||
# Done
|
|
@ -321,7 +321,7 @@ select * from t1 where not(NULL or a);
|
|||
a
|
||||
explain select * from t1 where not(NULL and a);
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t1 index NULL a 5 NULL 21 Using where; Using index
|
||||
1 SIMPLE t1 ref a a 5 const 1 Using index
|
||||
select * from t1 where not(NULL and a);
|
||||
a
|
||||
0
|
||||
|
@ -502,5 +502,5 @@ explain extended select a, not(not(a)), not(a <= 2 and not(a)), not(a not like "
|
|||
id select_type table type possible_keys key key_len ref rows filtered Extra
|
||||
1 SIMPLE t1 range a a 5 NULL 4 100.00 Using where; Using index
|
||||
Warnings:
|
||||
Note 1003 select `test`.`t1`.`a` AS `a`,(`test`.`t1`.`a` <> 0) AS `not(not(a))`,((`test`.`t1`.`a` > 2) or `test`.`t1`.`a`) AS `not(a <= 2 and not(a))`,(`test`.`t1`.`a` like '1') AS `not(a not like "1")`,(`test`.`t1`.`a` in (1,2)) AS `not (a not in (1,2))`,(`test`.`t1`.`a` = 2) AS `not(a != 2)` from `test`.`t1` where (`test`.`t1`.`a` <> 0) having (`test`.`t1`.`a` <> 0)
|
||||
Note 1003 select `test`.`t1`.`a` AS `a`,(`test`.`t1`.`a` <> 0) AS `not(not(a))`,((`test`.`t1`.`a` > 2) or (`test`.`t1`.`a` <> 0)) AS `not(a <= 2 and not(a))`,(`test`.`t1`.`a` like '1') AS `not(a not like "1")`,(`test`.`t1`.`a` in (1,2)) AS `not (a not in (1,2))`,(`test`.`t1`.`a` = 2) AS `not(a != 2)` from `test`.`t1` where (`test`.`t1`.`a` <> 0) having (`test`.`t1`.`a` <> 0)
|
||||
drop table t1;
|
||||
|
|
|
@ -2461,3 +2461,15 @@ SELECT 1 FROM t1 JOIN t1 AS t2 USING (a);
|
|||
1
|
||||
1
|
||||
drop table t1;
|
||||
#
|
||||
# LP BUG#1001117 Crash on a simple select that uses a temptable view
|
||||
# MySQL Bug #12330344 Crash and/or valgrind errors in free_io_cache with join, view,
|
||||
# partitioned table
|
||||
#
|
||||
CREATE TABLE t1(a INT PRIMARY KEY) PARTITION BY LINEAR KEY (a);
|
||||
CREATE ALGORITHM=TEMPTABLE VIEW vtmp AS
|
||||
SELECT 1 FROM t1 AS t1_0 JOIN t1 ON t1_0.a LIKE (SELECT 1 FROM t1);
|
||||
SELECT * FROM vtmp;
|
||||
1
|
||||
DROP VIEW vtmp;
|
||||
DROP TABLE t1;
|
||||
|
|
|
@ -27,7 +27,7 @@ a
|
|||
3
|
||||
show status like "Qcache_queries_in_cache";
|
||||
Variable_name Value
|
||||
Qcache_queries_in_cache 0
|
||||
Qcache_queries_in_cache 1
|
||||
drop table t1;
|
||||
commit;
|
||||
create table t1 (a int not null) PARTITION BY KEY (a) PARTITIONS 3;
|
||||
|
@ -50,7 +50,7 @@ a
|
|||
2
|
||||
show status like "Qcache_queries_in_cache";
|
||||
Variable_name Value
|
||||
Qcache_queries_in_cache 0
|
||||
Qcache_queries_in_cache 3
|
||||
show status like "Qcache_hits";
|
||||
Variable_name Value
|
||||
Qcache_hits 0
|
||||
|
@ -69,7 +69,7 @@ a
|
|||
2
|
||||
show status like "Qcache_queries_in_cache";
|
||||
Variable_name Value
|
||||
Qcache_queries_in_cache 0
|
||||
Qcache_queries_in_cache 6
|
||||
show status like "Qcache_hits";
|
||||
Variable_name Value
|
||||
Qcache_hits 0
|
||||
|
@ -93,14 +93,14 @@ a
|
|||
2
|
||||
show status like "Qcache_queries_in_cache";
|
||||
Variable_name Value
|
||||
Qcache_queries_in_cache 0
|
||||
Qcache_queries_in_cache 2
|
||||
show status like "Qcache_hits";
|
||||
Variable_name Value
|
||||
Qcache_hits 0
|
||||
Qcache_hits 1
|
||||
commit;
|
||||
show status like "Qcache_queries_in_cache";
|
||||
Variable_name Value
|
||||
Qcache_queries_in_cache 0
|
||||
Qcache_queries_in_cache 2
|
||||
drop table t3,t2,t1;
|
||||
CREATE TABLE t1 (id int(11) NOT NULL auto_increment, PRIMARY KEY (id)) PARTITION BY HASH (id) PARTITIONS 3;
|
||||
select count(*) from t1;
|
||||
|
@ -164,7 +164,7 @@ count(*)
|
|||
2
|
||||
show status like "Qcache_queries_in_cache";
|
||||
Variable_name Value
|
||||
Qcache_queries_in_cache 0
|
||||
Qcache_queries_in_cache 1
|
||||
connection connection1
|
||||
SELECT sql_cache count(*) FROM t2 WHERE s2 = 'w';
|
||||
count(*)
|
||||
|
@ -197,9 +197,9 @@ count(*)
|
|||
2
|
||||
show status like "Qcache_queries_in_cache";
|
||||
Variable_name Value
|
||||
Qcache_queries_in_cache 0
|
||||
Qcache_queries_in_cache 1
|
||||
show status like "Qcache_hits";
|
||||
Variable_name Value
|
||||
Qcache_hits 0
|
||||
Qcache_hits 1
|
||||
set @@global.query_cache_size = @save_query_cache_size;
|
||||
drop table t2;
|
||||
|
|
151
mysql-test/r/partition_cache_innodb.result
Normal file
151
mysql-test/r/partition_cache_innodb.result
Normal file
|
@ -0,0 +1,151 @@
|
|||
SET SESSION STORAGE_ENGINE = innodb;
|
||||
drop table if exists t1;
|
||||
set @save_query_cache_size = @@global.query_cache_size;
|
||||
# Test that partitions works with query cache
|
||||
flush query cache;
|
||||
SET GLOBAL query_cache_size=1024*1024*512;
|
||||
CREATE TABLE `t1` (
|
||||
`id` int(11) NOT NULL ,
|
||||
`created_at` datetime NOT NULL,
|
||||
`cool` tinyint default 0
|
||||
);
|
||||
ALTER TABLE t1 PARTITION BY RANGE (TO_DAYS(created_at)) (
|
||||
PARTITION month_2010_4 VALUES LESS THAN (734258),
|
||||
PARTITION month_2010_5 VALUES LESS THAN (734289),
|
||||
PARTITION month_max VALUES LESS THAN MAXVALUE
|
||||
);
|
||||
show create table t1;
|
||||
Table Create Table
|
||||
t1 CREATE TABLE `t1` (
|
||||
`id` int(11) NOT NULL,
|
||||
`created_at` datetime NOT NULL,
|
||||
`cool` tinyint(4) DEFAULT '0'
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=latin1
|
||||
/*!50100 PARTITION BY RANGE (TO_DAYS(created_at))
|
||||
(PARTITION month_2010_4 VALUES LESS THAN (734258) ENGINE = InnoDB,
|
||||
PARTITION month_2010_5 VALUES LESS THAN (734289) ENGINE = InnoDB,
|
||||
PARTITION month_max VALUES LESS THAN MAXVALUE ENGINE = InnoDB) */
|
||||
INSERT INTO t1 VALUES (1, now(), 0);
|
||||
flush status;
|
||||
show status like "Qcache_queries_in_cache";
|
||||
Variable_name Value
|
||||
Qcache_queries_in_cache 0
|
||||
show status like "Qcache_hits";
|
||||
Variable_name Value
|
||||
Qcache_hits 0
|
||||
SELECT cool FROM `t1` WHERE (`t1`.id = 1) LIMIT 1;
|
||||
cool
|
||||
0
|
||||
SELECT cool FROM `t1` WHERE (`t1`.id = 1) LIMIT 1;
|
||||
cool
|
||||
0
|
||||
SELECT cool FROM `t1` WHERE (`t1`.id = 1) LIMIT 1;
|
||||
cool
|
||||
0
|
||||
show status like "Qcache_queries_in_cache";
|
||||
Variable_name Value
|
||||
Qcache_queries_in_cache 1
|
||||
show status like "Qcache_hits";
|
||||
Variable_name Value
|
||||
Qcache_hits 2
|
||||
drop table t1;
|
||||
# Test that sub-partitions works with query cache
|
||||
flush query cache;
|
||||
SET GLOBAL query_cache_size=1024*1024*512;
|
||||
CREATE TABLE `t1` (
|
||||
`id` int(11) NOT NULL ,
|
||||
`created_at` datetime NOT NULL,
|
||||
`cool` tinyint default 0
|
||||
)
|
||||
PARTITION BY RANGE (TO_DAYS(created_at))
|
||||
subpartition by hash(cool) subpartitions 3 (
|
||||
PARTITION month_2010_4 VALUES LESS THAN (734258),
|
||||
PARTITION month_2010_5 VALUES LESS THAN (734289),
|
||||
PARTITION month_max VALUES LESS THAN MAXVALUE
|
||||
);
|
||||
show create table t1;
|
||||
Table Create Table
|
||||
t1 CREATE TABLE `t1` (
|
||||
`id` int(11) NOT NULL,
|
||||
`created_at` datetime NOT NULL,
|
||||
`cool` tinyint(4) DEFAULT '0'
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=latin1
|
||||
/*!50100 PARTITION BY RANGE (TO_DAYS(created_at))
|
||||
SUBPARTITION BY HASH (cool)
|
||||
SUBPARTITIONS 3
|
||||
(PARTITION month_2010_4 VALUES LESS THAN (734258) ENGINE = InnoDB,
|
||||
PARTITION month_2010_5 VALUES LESS THAN (734289) ENGINE = InnoDB,
|
||||
PARTITION month_max VALUES LESS THAN MAXVALUE ENGINE = InnoDB) */
|
||||
INSERT INTO t1 VALUES (1, now(), 0);
|
||||
flush status;
|
||||
show status like "Qcache_queries_in_cache";
|
||||
Variable_name Value
|
||||
Qcache_queries_in_cache 0
|
||||
show status like "Qcache_hits";
|
||||
Variable_name Value
|
||||
Qcache_hits 0
|
||||
SELECT cool FROM `t1` WHERE (`t1`.id = 1) LIMIT 1;
|
||||
cool
|
||||
0
|
||||
SELECT cool FROM `t1` WHERE (`t1`.id = 1) LIMIT 1;
|
||||
cool
|
||||
0
|
||||
SELECT cool FROM `t1` WHERE (`t1`.id = 1) LIMIT 1;
|
||||
cool
|
||||
0
|
||||
show status like "Qcache_queries_in_cache";
|
||||
Variable_name Value
|
||||
Qcache_queries_in_cache 1
|
||||
show status like "Qcache_hits";
|
||||
Variable_name Value
|
||||
Qcache_hits 2
|
||||
drop table t1;
|
||||
#
|
||||
# MySQL bug#53775 Query on partitioned table returns cached result
|
||||
# from previous transaction
|
||||
#
|
||||
flush query cache;
|
||||
flush status;
|
||||
SET GLOBAL query_cache_size=1024*1024*512;
|
||||
CREATE TABLE `t1` (
|
||||
`id` int(11) NOT NULL ,
|
||||
`created_at` datetime NOT NULL,
|
||||
`cool` tinyint default 0
|
||||
);
|
||||
ALTER TABLE t1 PARTITION BY RANGE (TO_DAYS(created_at)) (
|
||||
PARTITION month_2010_4 VALUES LESS THAN (734258),
|
||||
PARTITION month_2010_5 VALUES LESS THAN (734289),
|
||||
PARTITION month_max VALUES LESS THAN MAXVALUE
|
||||
);
|
||||
INSERT INTO t1 VALUES (1, now(), 0);
|
||||
show status like "Qcache_queries_in_cache";
|
||||
Variable_name Value
|
||||
Qcache_queries_in_cache 0
|
||||
show status like "Qcache_hits";
|
||||
Variable_name Value
|
||||
Qcache_hits 0
|
||||
BEGIN;
|
||||
UPDATE `t1` SET `cool` = 1 WHERE `id` = 1;
|
||||
SELECT cool FROM `t1` WHERE (`t1`.id = 1) LIMIT 1;
|
||||
cool
|
||||
1
|
||||
ROLLBACK;
|
||||
SELECT cool FROM `t1` WHERE (`t1`.id = 1) LIMIT 1;
|
||||
cool
|
||||
0
|
||||
BEGIN;
|
||||
SELECT cool FROM `t1` WHERE (`t1`.id = 1) LIMIT 1;
|
||||
cool
|
||||
0
|
||||
ROLLBACK;
|
||||
SELECT cool FROM `t1` WHERE (`t1`.id = 1) LIMIT 1;
|
||||
cool
|
||||
0
|
||||
show status like "Qcache_queries_in_cache";
|
||||
Variable_name Value
|
||||
Qcache_queries_in_cache 2
|
||||
show status like "Qcache_hits";
|
||||
Variable_name Value
|
||||
Qcache_hits 1
|
||||
drop table t1;
|
||||
set @@global.query_cache_size = @save_query_cache_size;
|
153
mysql-test/r/partition_cache_myisam.result
Normal file
153
mysql-test/r/partition_cache_myisam.result
Normal file
|
@ -0,0 +1,153 @@
|
|||
SET SESSION STORAGE_ENGINE = myisam;
|
||||
drop table if exists t1;
|
||||
set @save_query_cache_size = @@global.query_cache_size;
|
||||
# Test that partitions works with query cache
|
||||
flush query cache;
|
||||
SET GLOBAL query_cache_size=1024*1024*512;
|
||||
CREATE TABLE `t1` (
|
||||
`id` int(11) NOT NULL ,
|
||||
`created_at` datetime NOT NULL,
|
||||
`cool` tinyint default 0
|
||||
);
|
||||
ALTER TABLE t1 PARTITION BY RANGE (TO_DAYS(created_at)) (
|
||||
PARTITION month_2010_4 VALUES LESS THAN (734258),
|
||||
PARTITION month_2010_5 VALUES LESS THAN (734289),
|
||||
PARTITION month_max VALUES LESS THAN MAXVALUE
|
||||
);
|
||||
show create table t1;
|
||||
Table Create Table
|
||||
t1 CREATE TABLE `t1` (
|
||||
`id` int(11) NOT NULL,
|
||||
`created_at` datetime NOT NULL,
|
||||
`cool` tinyint(4) DEFAULT '0'
|
||||
) ENGINE=MyISAM DEFAULT CHARSET=latin1
|
||||
/*!50100 PARTITION BY RANGE (TO_DAYS(created_at))
|
||||
(PARTITION month_2010_4 VALUES LESS THAN (734258) ENGINE = MyISAM,
|
||||
PARTITION month_2010_5 VALUES LESS THAN (734289) ENGINE = MyISAM,
|
||||
PARTITION month_max VALUES LESS THAN MAXVALUE ENGINE = MyISAM) */
|
||||
INSERT INTO t1 VALUES (1, now(), 0);
|
||||
flush status;
|
||||
show status like "Qcache_queries_in_cache";
|
||||
Variable_name Value
|
||||
Qcache_queries_in_cache 0
|
||||
show status like "Qcache_hits";
|
||||
Variable_name Value
|
||||
Qcache_hits 0
|
||||
SELECT cool FROM `t1` WHERE (`t1`.id = 1) LIMIT 1;
|
||||
cool
|
||||
0
|
||||
SELECT cool FROM `t1` WHERE (`t1`.id = 1) LIMIT 1;
|
||||
cool
|
||||
0
|
||||
SELECT cool FROM `t1` WHERE (`t1`.id = 1) LIMIT 1;
|
||||
cool
|
||||
0
|
||||
show status like "Qcache_queries_in_cache";
|
||||
Variable_name Value
|
||||
Qcache_queries_in_cache 1
|
||||
show status like "Qcache_hits";
|
||||
Variable_name Value
|
||||
Qcache_hits 2
|
||||
drop table t1;
|
||||
# Test that sub-partitions works with query cache
|
||||
flush query cache;
|
||||
SET GLOBAL query_cache_size=1024*1024*512;
|
||||
CREATE TABLE `t1` (
|
||||
`id` int(11) NOT NULL ,
|
||||
`created_at` datetime NOT NULL,
|
||||
`cool` tinyint default 0
|
||||
)
|
||||
PARTITION BY RANGE (TO_DAYS(created_at))
|
||||
subpartition by hash(cool) subpartitions 3 (
|
||||
PARTITION month_2010_4 VALUES LESS THAN (734258),
|
||||
PARTITION month_2010_5 VALUES LESS THAN (734289),
|
||||
PARTITION month_max VALUES LESS THAN MAXVALUE
|
||||
);
|
||||
show create table t1;
|
||||
Table Create Table
|
||||
t1 CREATE TABLE `t1` (
|
||||
`id` int(11) NOT NULL,
|
||||
`created_at` datetime NOT NULL,
|
||||
`cool` tinyint(4) DEFAULT '0'
|
||||
) ENGINE=MyISAM DEFAULT CHARSET=latin1
|
||||
/*!50100 PARTITION BY RANGE (TO_DAYS(created_at))
|
||||
SUBPARTITION BY HASH (cool)
|
||||
SUBPARTITIONS 3
|
||||
(PARTITION month_2010_4 VALUES LESS THAN (734258) ENGINE = MyISAM,
|
||||
PARTITION month_2010_5 VALUES LESS THAN (734289) ENGINE = MyISAM,
|
||||
PARTITION month_max VALUES LESS THAN MAXVALUE ENGINE = MyISAM) */
|
||||
INSERT INTO t1 VALUES (1, now(), 0);
|
||||
flush status;
|
||||
show status like "Qcache_queries_in_cache";
|
||||
Variable_name Value
|
||||
Qcache_queries_in_cache 0
|
||||
show status like "Qcache_hits";
|
||||
Variable_name Value
|
||||
Qcache_hits 0
|
||||
SELECT cool FROM `t1` WHERE (`t1`.id = 1) LIMIT 1;
|
||||
cool
|
||||
0
|
||||
SELECT cool FROM `t1` WHERE (`t1`.id = 1) LIMIT 1;
|
||||
cool
|
||||
0
|
||||
SELECT cool FROM `t1` WHERE (`t1`.id = 1) LIMIT 1;
|
||||
cool
|
||||
0
|
||||
show status like "Qcache_queries_in_cache";
|
||||
Variable_name Value
|
||||
Qcache_queries_in_cache 1
|
||||
show status like "Qcache_hits";
|
||||
Variable_name Value
|
||||
Qcache_hits 2
|
||||
drop table t1;
|
||||
#
|
||||
# MySQL bug#53775 Query on partitioned table returns cached result
|
||||
# from previous transaction
|
||||
#
|
||||
flush query cache;
|
||||
flush status;
|
||||
SET GLOBAL query_cache_size=1024*1024*512;
|
||||
CREATE TABLE `t1` (
|
||||
`id` int(11) NOT NULL ,
|
||||
`created_at` datetime NOT NULL,
|
||||
`cool` tinyint default 0
|
||||
);
|
||||
ALTER TABLE t1 PARTITION BY RANGE (TO_DAYS(created_at)) (
|
||||
PARTITION month_2010_4 VALUES LESS THAN (734258),
|
||||
PARTITION month_2010_5 VALUES LESS THAN (734289),
|
||||
PARTITION month_max VALUES LESS THAN MAXVALUE
|
||||
);
|
||||
INSERT INTO t1 VALUES (1, now(), 0);
|
||||
show status like "Qcache_queries_in_cache";
|
||||
Variable_name Value
|
||||
Qcache_queries_in_cache 0
|
||||
show status like "Qcache_hits";
|
||||
Variable_name Value
|
||||
Qcache_hits 0
|
||||
BEGIN;
|
||||
UPDATE `t1` SET `cool` = 1 WHERE `id` = 1;
|
||||
SELECT cool FROM `t1` WHERE (`t1`.id = 1) LIMIT 1;
|
||||
cool
|
||||
1
|
||||
ROLLBACK;
|
||||
Warnings:
|
||||
Warning 1196 Some non-transactional changed tables couldn't be rolled back
|
||||
SELECT cool FROM `t1` WHERE (`t1`.id = 1) LIMIT 1;
|
||||
cool
|
||||
1
|
||||
BEGIN;
|
||||
SELECT cool FROM `t1` WHERE (`t1`.id = 1) LIMIT 1;
|
||||
cool
|
||||
1
|
||||
ROLLBACK;
|
||||
SELECT cool FROM `t1` WHERE (`t1`.id = 1) LIMIT 1;
|
||||
cool
|
||||
1
|
||||
show status like "Qcache_queries_in_cache";
|
||||
Variable_name Value
|
||||
Qcache_queries_in_cache 2
|
||||
show status like "Qcache_hits";
|
||||
Variable_name Value
|
||||
Qcache_hits 2
|
||||
drop table t1;
|
||||
set @@global.query_cache_size = @save_query_cache_size;
|
|
@ -160,26 +160,26 @@ execute stmt1 ;
|
|||
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
|
||||
6 DERIVED NULL NULL NULL NULL NULL NULL NULL no matching row in const table
|
||||
5 DEPENDENT SUBQUERY NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables
|
||||
4 DEPENDENT SUBQUERY NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables
|
||||
3 DEPENDENT SUBQUERY NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables
|
||||
2 DEPENDENT SUBQUERY NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables
|
||||
5 SUBQUERY NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables
|
||||
4 SUBQUERY NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables
|
||||
3 SUBQUERY NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables
|
||||
2 SUBQUERY NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables
|
||||
execute stmt1 ;
|
||||
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
|
||||
6 DERIVED NULL NULL NULL NULL NULL NULL NULL no matching row in const table
|
||||
5 DEPENDENT SUBQUERY NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables
|
||||
4 DEPENDENT SUBQUERY NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables
|
||||
3 DEPENDENT SUBQUERY NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables
|
||||
2 DEPENDENT SUBQUERY NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables
|
||||
5 SUBQUERY NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables
|
||||
4 SUBQUERY NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables
|
||||
3 SUBQUERY NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables
|
||||
2 SUBQUERY NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables
|
||||
explain SELECT (SELECT SUM(c1 + c12 + 0.0) FROM t2 where (t1.c2 - 0e-3) = t2.c2 GROUP BY t1.c15 LIMIT 1) as scalar_s, exists (select 1.0e+0 from t2 where t2.c3 * 9.0000000000 = t1.c4) as exists_s, c5 * 4 in (select c6 + 0.3e+1 from t2) as in_s, (c7 - 4, c8 - 4) in (select c9 + 4.0, c10 + 40e-1 from t2) as in_row_s FROM t1, (select c25 x, c32 y from t2) tt WHERE x * 1 = c25;
|
||||
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
|
||||
6 DERIVED NULL NULL NULL NULL NULL NULL NULL no matching row in const table
|
||||
5 DEPENDENT SUBQUERY NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables
|
||||
4 DEPENDENT SUBQUERY NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables
|
||||
3 DEPENDENT SUBQUERY NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables
|
||||
2 DEPENDENT SUBQUERY NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables
|
||||
5 SUBQUERY NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables
|
||||
4 SUBQUERY NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables
|
||||
3 SUBQUERY NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables
|
||||
2 SUBQUERY NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables
|
||||
deallocate prepare stmt1;
|
||||
set optimizer_switch=@tmp_optimizer_switch;
|
||||
drop tables t1,t2;
|
||||
|
@ -255,15 +255,15 @@ deallocate prepare StMt1;
|
|||
deallocate prepare Stmt1;
|
||||
ERROR HY000: Unknown prepared statement handler (Stmt1) given to DEALLOCATE PREPARE
|
||||
set names utf8;
|
||||
prepare `ü` from 'select 1234';
|
||||
execute `ü` ;
|
||||
prepare `ü` from 'select 1234';
|
||||
execute `ü` ;
|
||||
1234
|
||||
1234
|
||||
set names latin1;
|
||||
execute `ü`;
|
||||
execute `ü`;
|
||||
1234
|
||||
1234
|
||||
deallocate prepare `ü`;
|
||||
deallocate prepare `ü`;
|
||||
set names default;
|
||||
create table t1 (a varchar(10)) charset=utf8;
|
||||
insert into t1 (a) values ('yahoo');
|
||||
|
@ -3055,6 +3055,62 @@ DEALLOCATE PREPARE stmt;
|
|||
DROP TABLE t1;
|
||||
|
||||
End of 5.1 tests.
|
||||
#
|
||||
# LP bug#1001500 Crash on the second execution of the PS for
|
||||
# a query with degenerated conjunctive condition
|
||||
# (see also mysql bug#12582849)
|
||||
#
|
||||
CREATE TABLE t1 (
|
||||
pk INTEGER AUTO_INCREMENT,
|
||||
col_int_nokey INTEGER,
|
||||
col_int_key INTEGER,
|
||||
col_varchar_key VARCHAR(1),
|
||||
col_varchar_nokey VARCHAR(1),
|
||||
PRIMARY KEY (pk),
|
||||
KEY (col_int_key),
|
||||
KEY (col_varchar_key, col_int_key)
|
||||
);
|
||||
INSERT INTO t1 (
|
||||
col_int_key, col_int_nokey,
|
||||
col_varchar_key, col_varchar_nokey
|
||||
) VALUES
|
||||
(4, 2, 'v', 'v'),
|
||||
(62, 150, 'v', 'v');
|
||||
CREATE TABLE t2 (
|
||||
pk INTEGER AUTO_INCREMENT,
|
||||
col_int_nokey INTEGER,
|
||||
col_int_key INTEGER,
|
||||
col_varchar_key VARCHAR(1),
|
||||
col_varchar_nokey VARCHAR(1),
|
||||
PRIMARY KEY (pk),
|
||||
KEY (col_int_key),
|
||||
KEY (col_varchar_key, col_int_key)
|
||||
);
|
||||
INSERT INTO t2 (
|
||||
col_int_key, col_int_nokey,
|
||||
col_varchar_key, col_varchar_nokey
|
||||
) VALUES
|
||||
(8, NULL, 'x', 'x'),
|
||||
(7, 8, 'd', 'd');
|
||||
PREPARE stmt FROM '
|
||||
SELECT
|
||||
( SELECT MAX( SQ1_alias2 .col_int_nokey ) AS SQ1_field1
|
||||
FROM ( t2 AS SQ1_alias1 RIGHT JOIN t1 AS SQ1_alias2
|
||||
ON ( SQ1_alias2.col_varchar_key = SQ1_alias1.col_varchar_nokey )
|
||||
)
|
||||
WHERE SQ1_alias2.pk < alias1.col_int_nokey OR alias1.pk
|
||||
) AS field1
|
||||
FROM ( t1 AS alias1 JOIN t2 AS alias2 ON alias2.pk )
|
||||
GROUP BY field1
|
||||
';
|
||||
EXECUTE stmt;
|
||||
field1
|
||||
150
|
||||
EXECUTE stmt;
|
||||
field1
|
||||
150
|
||||
DEALLOCATE PREPARE stmt;
|
||||
DROP TABLE t1, t2;
|
||||
|
||||
#
|
||||
# WL#4435: Support OUT-parameters in prepared statements.
|
||||
|
@ -4044,3 +4100,4 @@ c1 c2 count(c3)
|
|||
2012-03-01 01:00:00 3 1
|
||||
2012-03-01 02:00:00 3 1
|
||||
DEALLOCATE PREPARE s1;
|
||||
# End of 5.3 tests
|
||||
|
|
|
@ -9,6 +9,6 @@ STOP SLAVE;
|
|||
CHANGE MASTER TO MASTER_LOG_FILE='master-bin.000001', MASTER_LOG_POS=BINLOG_START;
|
||||
START SLAVE;
|
||||
STOP SLAVE;
|
||||
CHANGE MASTER TO MASTER_HOST='127.0.0.1', MASTER_PORT='MASTER_MYPORT', MASTER_LOG_FILE='master-bin.000001', MASTER_LOG_POS=BINLOG_START;
|
||||
CHANGE MASTER TO MASTER_HOST='127.0.0.1', MASTER_PORT=MASTER_MYPORT, MASTER_LOG_FILE='master-bin.000001', MASTER_LOG_POS=BINLOG_START;
|
||||
START SLAVE;
|
||||
include/rpl_end.inc
|
||||
|
|
|
@ -7849,3 +7849,36 @@ c1 c2 count(c3)
|
|||
2012-03-01 01:00:00 3 1
|
||||
2012-03-01 02:00:00 3 1
|
||||
DROP PROCEDURE p1;
|
||||
#
|
||||
# LP bug#1002157 : testing stored function
|
||||
# bug#62125 result for null incorrectly yields 1292 warning.
|
||||
#
|
||||
DROP FUNCTION IF EXISTS f1;
|
||||
DROP FUNCTION IF EXISTS f2;
|
||||
DROP FUNCTION IF EXISTS f3;
|
||||
DROP FUNCTION IF EXISTS f4;
|
||||
CREATE FUNCTION f1() RETURNS VARCHAR(1)
|
||||
BEGIN RETURN 'X'; END;/
|
||||
CREATE FUNCTION f2() RETURNS CHAR(1)
|
||||
BEGIN RETURN 'X'; END;/
|
||||
CREATE FUNCTION f3() RETURNS VARCHAR(1)
|
||||
BEGIN RETURN NULL; END;/
|
||||
CREATE FUNCTION f4() RETURNS CHAR(1)
|
||||
BEGIN RETURN NULL; END;/
|
||||
SELECT f1() IS NULL;
|
||||
f1() IS NULL
|
||||
0
|
||||
SELECT f2() IS NULL;
|
||||
f2() IS NULL
|
||||
0
|
||||
SELECT f3() IS NULL;
|
||||
f3() IS NULL
|
||||
1
|
||||
SELECT f4() IS NULL;
|
||||
f4() IS NULL
|
||||
1
|
||||
DROP FUNCTION f1;
|
||||
DROP FUNCTION f2;
|
||||
DROP FUNCTION f3;
|
||||
DROP FUNCTION f4;
|
||||
# End of 5.5 test
|
||||
|
|
|
@ -51,12 +51,12 @@ ERROR 42S22: Reference 'a' not supported (forward reference in item list)
|
|||
EXPLAIN EXTENDED SELECT 1 FROM (SELECT 1 as a) as b HAVING (SELECT a)=1;
|
||||
id select_type table type possible_keys key key_len ref rows filtered Extra
|
||||
1 PRIMARY <derived2> system NULL NULL NULL NULL 1 100.00
|
||||
3 DEPENDENT SUBQUERY NULL NULL NULL NULL NULL NULL NULL NULL No tables used
|
||||
3 SUBQUERY NULL NULL NULL NULL NULL NULL NULL NULL No tables used
|
||||
2 DERIVED NULL NULL NULL NULL NULL NULL NULL NULL No tables used
|
||||
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
|
||||
|
@ -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 where; Using index
|
||||
1 PRIMARY t8 const PRIMARY PRIMARY 37 const 1 100.00 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 Using where
|
||||
2 SUBQUERY t8 const PRIMARY PRIMARY 37 const 1 100.00
|
||||
3 SUBQUERY t8 const PRIMARY PRIMARY 37 const 1 100.00 Using index
|
||||
Warnings:
|
||||
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))
|
||||
Note 1003 select 'joce' AS `pseudo`,(select 'test' from `test`.`t8` where 1) AS `(SELECT email FROM t8 WHERE pseudo=(SELECT pseudo FROM t8 WHERE pseudo='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)
|
||||
|
@ -517,6 +517,7 @@ ERROR 21000: Subquery returns more than 1 row
|
|||
show warnings;
|
||||
Level Code Message
|
||||
Error 1242 Subquery returns more than 1 row
|
||||
Error 1028 Sort aborted: Subquery returns more than 1 row
|
||||
drop table t1;
|
||||
create table t1 (a int);
|
||||
insert into t1 values (1),(2),(3);
|
||||
|
@ -547,11 +548,7 @@ 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'))))
|
||||
ERROR 21000: Subquery returns more than 1 row
|
||||
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';
|
||||
|
@ -907,7 +904,7 @@ a t1.a in (select t2.a from t2)
|
|||
explain extended SELECT t1.a, t1.a in (select t2.a from t2) FROM t1;
|
||||
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
|
||||
2 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`
|
||||
CREATE TABLE t3 (a int(11) default '0');
|
||||
|
@ -1608,25 +1605,25 @@ a3 1
|
|||
explain extended select s1, s1 NOT IN (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
|
||||
2 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`
|
||||
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
|
||||
2 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`
|
||||
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
|
||||
2 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`
|
||||
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
|
||||
2 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`
|
||||
drop table t1,t2;
|
||||
|
@ -1675,34 +1672,34 @@ select * from t3 where NULL >= any (select b from t2);
|
|||
a
|
||||
explain extended select * from t3 where NULL >= any (select b from t2);
|
||||
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
|
||||
2 SUBQUERY t2 system NULL NULL NULL NULL 0 0.00 const row not found
|
||||
1 PRIMARY NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE
|
||||
2 SUBQUERY NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table
|
||||
Warnings:
|
||||
Note 1003 select `test`.`t3`.`a` AS `a` from `test`.`t3` where <nop>(<in_optimizer>(NULL,((select min(NULL) from `test`.`t2`) <= NULL)))
|
||||
Note 1003 select `test`.`t3`.`a` AS `a` from `test`.`t3` where 0
|
||||
select * from t3 where NULL >= any (select b from t2 group by 1);
|
||||
a
|
||||
explain extended select * from t3 where NULL >= any (select b from t2 group by 1);
|
||||
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
|
||||
2 SUBQUERY t2 system NULL NULL NULL NULL 0 0.00 const row not found
|
||||
1 PRIMARY NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE
|
||||
2 SUBQUERY NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table
|
||||
Warnings:
|
||||
Note 1003 select `test`.`t3`.`a` AS `a` from `test`.`t3` where <nop>(<in_optimizer>(NULL,((select min(NULL) from `test`.`t2`) <= NULL)))
|
||||
Note 1003 select `test`.`t3`.`a` AS `a` from `test`.`t3` where 0
|
||||
select * from t3 where NULL >= some (select b from t2);
|
||||
a
|
||||
explain extended select * from t3 where NULL >= some (select b from t2);
|
||||
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
|
||||
2 SUBQUERY t2 system NULL NULL NULL NULL 0 0.00 const row not found
|
||||
1 PRIMARY NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE
|
||||
2 SUBQUERY NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table
|
||||
Warnings:
|
||||
Note 1003 select `test`.`t3`.`a` AS `a` from `test`.`t3` where <nop>(<in_optimizer>(NULL,((select min(NULL) from `test`.`t2`) <= NULL)))
|
||||
Note 1003 select `test`.`t3`.`a` AS `a` from `test`.`t3` where 0
|
||||
select * from t3 where NULL >= some (select b from t2 group by 1);
|
||||
a
|
||||
explain extended select * from t3 where NULL >= some (select b from t2 group by 1);
|
||||
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
|
||||
2 SUBQUERY t2 system NULL NULL NULL NULL 0 0.00 const row not found
|
||||
1 PRIMARY NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE
|
||||
2 SUBQUERY NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table
|
||||
Warnings:
|
||||
Note 1003 select `test`.`t3`.`a` AS `a` from `test`.`t3` where <nop>(<in_optimizer>(NULL,((select min(NULL) from `test`.`t2`) <= NULL)))
|
||||
Note 1003 select `test`.`t3`.`a` AS `a` from `test`.`t3` where 0
|
||||
insert into t2 values (2,2), (2,1), (3,3), (3,1);
|
||||
select * from t3 where a > all (select max(b) from t2 group by a);
|
||||
a
|
||||
|
@ -1764,7 +1761,7 @@ id select_type table type possible_keys key key_len ref rows filtered Extra
|
|||
3 UNION t1 system NULL NULL NULL NULL 1 100.00
|
||||
NULL UNION RESULT <union2,3> ALL NULL NULL NULL NULL NULL NULL
|
||||
Warnings:
|
||||
Note 1003 select 'e' AS `s1` from dual where <nop>(<in_optimizer>('f',(<min>(select 'e' from dual union select 'e' from dual) < 'f')))
|
||||
Note 1003 select 'e' AS `s1` from dual where 1
|
||||
drop table t1;
|
||||
CREATE TABLE t1 (number char(11) NOT NULL default '') ENGINE=MyISAM CHARSET=latin1;
|
||||
INSERT INTO t1 VALUES ('69294728265'),('18621828126'),('89356874041'),('95895001874');
|
||||
|
@ -3099,8 +3096,8 @@ ON r.a = (SELECT t2.a FROM t2 WHERE t2.c = t1.a AND t2.b <= '359899'
|
|||
ORDER BY t2.c DESC, t2.b DESC LIMIT 1) WHERE t1.a = 10;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 PRIMARY t1 system PRIMARY NULL NULL NULL 1
|
||||
1 PRIMARY r eq_ref PRIMARY PRIMARY 4 const 1 Using where
|
||||
2 DEPENDENT SUBQUERY t2 range b b 40 NULL 2 Using where
|
||||
1 PRIMARY r const PRIMARY PRIMARY 4 const 1
|
||||
2 SUBQUERY t2 range b b 40 NULL 2 Using where
|
||||
SELECT sql_no_cache t1.a, r.a, r.b FROM t1 LEFT JOIN t2 r
|
||||
ON r.a = (SELECT t2.a FROM t2 WHERE t2.c = t1.a AND t2.b <= '359899'
|
||||
ORDER BY t2.c DESC, t2.b DESC LIMIT 1) WHERE t1.a = 10;
|
||||
|
@ -3111,8 +3108,8 @@ ON r.a = (SELECT t2.a FROM t2 WHERE t2.c = t1.a AND t2.b <= '359899'
|
|||
ORDER BY t2.c, t2.b LIMIT 1) WHERE t1.a = 10;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 PRIMARY t1 system PRIMARY NULL NULL NULL 1
|
||||
1 PRIMARY r eq_ref PRIMARY PRIMARY 4 const 1 Using where
|
||||
2 DEPENDENT SUBQUERY t2 range b b 40 NULL 2 Using index condition
|
||||
1 PRIMARY r const PRIMARY PRIMARY 4 const 1
|
||||
2 SUBQUERY t2 range b b 40 NULL 2 Using index condition
|
||||
SELECT sql_no_cache t1.a, r.a, r.b FROM t1 LEFT JOIN t2 r
|
||||
ON r.a = (SELECT t2.a FROM t2 WHERE t2.c = t1.a AND t2.b <= '359899'
|
||||
ORDER BY t2.c, t2.b LIMIT 1) WHERE t1.a = 10;
|
||||
|
@ -3163,7 +3160,7 @@ INSERT INTO t2 VALUES (1),(2),(3);
|
|||
EXPLAIN SELECT a, a IN (SELECT a FROM t1) FROM t2;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 PRIMARY t2 ALL NULL NULL NULL NULL 3
|
||||
2 DEPENDENT SUBQUERY t1 index_subquery a a 5 func 2 Using index; Full scan on NULL key
|
||||
2 SUBQUERY t1 index_subquery a a 5 func 2 Using index; Full scan on NULL key
|
||||
SELECT a, a IN (SELECT a FROM t1) FROM t2;
|
||||
a a IN (SELECT a FROM t1)
|
||||
1 1
|
||||
|
@ -3699,7 +3696,7 @@ ORDER BY t1.t DESC LIMIT 1);
|
|||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 PRIMARY t2 system NULL NULL NULL NULL 1
|
||||
1 PRIMARY t1 index NULL PRIMARY 16 NULL 11 Using where; Using index
|
||||
2 DEPENDENT SUBQUERY t1 range PRIMARY PRIMARY 16 NULL 5 Using where; Using index
|
||||
2 SUBQUERY t1 range PRIMARY PRIMARY 16 NULL 5 Using where; Using index
|
||||
SELECT * FROM t1,t2
|
||||
WHERE t1.t = (SELECT t1.t FROM t1
|
||||
WHERE t1.t < t2.t AND t1.i2=1 AND t2.i1=t1.i1
|
||||
|
@ -3726,9 +3723,9 @@ from t1' at line 1
|
|||
explain select * from t1 where not exists
|
||||
((select t11.i from t1 t11) union (select t12.i from t1 t12));
|
||||
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 t11 system NULL NULL NULL NULL 0 const row not found
|
||||
3 UNION t12 system NULL NULL NULL NULL 0 const row not found
|
||||
1 PRIMARY t1 system NULL NULL NULL NULL 0 const row not found
|
||||
2 SUBQUERY NULL NULL NULL NULL NULL NULL NULL no matching row in const table
|
||||
3 UNION NULL NULL NULL NULL NULL NULL NULL no matching row in const table
|
||||
NULL UNION RESULT <union2,3> ALL NULL NULL NULL NULL NULL
|
||||
DROP TABLE t1;
|
||||
CREATE TABLE t1 (a VARCHAR(250), b INT auto_increment, PRIMARY KEY (b));
|
||||
|
@ -4198,8 +4195,8 @@ CREATE TABLE t1 (a int, b int, KEY (a));
|
|||
INSERT INTO t1 VALUES (1,1),(2,1);
|
||||
EXPLAIN SELECT 1 FROM t1 WHERE a = (SELECT COUNT(*) FROM t1 GROUP BY b);
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 PRIMARY t1 ref a a 5 const 0 Using where; Using index
|
||||
2 SUBQUERY t1 ALL NULL NULL NULL NULL 2 Using temporary; Using filesort
|
||||
1 PRIMARY t1 ref a a 5 const 1 Using where; Using index
|
||||
2 SUBQUERY internal_tmp_table ALL group_key NULL NULL NULL 1 Using temporary; Using filesort
|
||||
DROP TABLE t1;
|
||||
CREATE TABLE t1 (id int NOT NULL, st CHAR(2), INDEX idx(id));
|
||||
INSERT INTO t1 VALUES
|
||||
|
@ -4580,7 +4577,7 @@ FROM t1
|
|||
WHERE a = 230;
|
||||
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 DEPENDENT SUBQUERY NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables
|
||||
2 SUBQUERY NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables
|
||||
SELECT MAX(b), (SELECT COUNT(*) FROM st1,st2 WHERE st2.b <= t1.b)
|
||||
FROM t1
|
||||
WHERE a = 230;
|
||||
|
@ -4626,7 +4623,7 @@ 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 SUBQUERY t1 ALL NULL NULL NULL NULL 2 100.00
|
||||
Warnings:
|
||||
Note 1003 select 1 AS `1` from `test`.`t1` where <nop>(<in_optimizer>(1,((select max(`test`.`t1`.`a1`) from `test`.`t1`) > 1)))
|
||||
Note 1003 select 1 AS `1` from `test`.`t1` where 1
|
||||
SELECT 1 FROM t1 WHERE 1 < SOME (SELECT a1 FROM t1);
|
||||
1
|
||||
1
|
||||
|
@ -5969,7 +5966,7 @@ id select_type table type possible_keys key key_len ref rows Extra
|
|||
EXPLAIN SELECT * FROM t1 WHERE EXISTS (SELECT * FROM t1 WHERE a=7);
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 PRIMARY t1 ALL NULL NULL NULL NULL 4
|
||||
2 SUBQUERY t1 ref a a 5 const 1 Using index
|
||||
2 SUBQUERY t1 ref a a 5 const 1
|
||||
DROP TABLE t1;
|
||||
#
|
||||
# BUG#12616253 - WRONG RESULT WITH EXISTS(SUBQUERY) (MISSING ROWS)
|
||||
|
@ -6130,7 +6127,7 @@ set optimizer_switch=@tmp_optimizer_switch;
|
|||
EXPLAIN SELECT * FROM t1 WHERE EXISTS (SELECT * FROM t1 WHERE a=7);
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 PRIMARY t1 ALL NULL NULL NULL NULL 4
|
||||
2 SUBQUERY t1 ref a a 5 const 1 Using index
|
||||
2 SUBQUERY t1 ref a a 5 const 1
|
||||
|
||||
DROP TABLE t1;
|
||||
#
|
||||
|
@ -6542,7 +6539,7 @@ EXPLAIN
|
|||
SELECT COUNT(f1), (SELECT f1 FROM t1 WHERE f2 > 0 limit 1) AS f4 FROM t2, t1 WHERE 'v'= f3;
|
||||
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 DEPENDENT SUBQUERY t1 ALL NULL NULL NULL NULL 2
|
||||
2 SUBQUERY t1 ALL NULL NULL NULL NULL 2
|
||||
SELECT COUNT(f1), (SELECT f1 FROM t1 WHERE f2 > 0 limit 1) AS f4 FROM t2, t1 WHERE 'v'= f3;
|
||||
COUNT(f1) f4
|
||||
0 NULL
|
||||
|
@ -6550,7 +6547,7 @@ EXPLAIN
|
|||
SELECT COUNT(f1), exists(SELECT f1 FROM t1 WHERE f2 > 0 limit 1) AS f4 FROM t2, t1 WHERE 'v'= f3;
|
||||
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 DEPENDENT SUBQUERY t1 ALL NULL NULL NULL NULL 2
|
||||
2 SUBQUERY t1 ALL NULL NULL NULL NULL 2
|
||||
SELECT COUNT(f1), exists(SELECT f1 FROM t1 WHERE f2 > 0 limit 1) AS f4 FROM t2, t1 WHERE 'v'= f3;
|
||||
COUNT(f1) f4
|
||||
0 0
|
||||
|
@ -6589,5 +6586,225 @@ NULL UNION RESULT <union2,3> ALL NULL NULL NULL NULL NULL
|
|||
SELECT SUM(a) AS f1, a AS f2 FROM (t1, t2) HAVING f2 >= ALL (SELECT 4 UNION SELECT 5) AND f1 = 7;
|
||||
f1 f2
|
||||
drop table t1,t2;
|
||||
#
|
||||
# LP BUG#1008686 Server crashes in subselect_union_engine::no_rows on SELECT with impossible
|
||||
# WHERE and UNION in HAVING
|
||||
#
|
||||
CREATE TABLE t1 (a INT);
|
||||
INSERT INTO t1 VALUES (1),(7);
|
||||
EXPLAIN
|
||||
SELECT MIN(a) AS min_a, a FROM t1 WHERE 0 HAVING a NOT IN ( SELECT 2 UNION SELECT 5 ) OR min_a != 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
|
||||
2 DEPENDENT SUBQUERY NULL NULL NULL NULL NULL NULL NULL No tables used
|
||||
3 DEPENDENT UNION NULL NULL NULL NULL NULL NULL NULL No tables used
|
||||
NULL UNION RESULT <union2,3> ALL NULL NULL NULL NULL NULL
|
||||
SELECT MIN(a) AS min_a, a FROM t1 WHERE 0 HAVING a NOT IN ( SELECT 2 UNION SELECT 5 ) OR min_a != 1;
|
||||
min_a a
|
||||
EXPLAIN
|
||||
SELECT MIN(a) AS min_a, a FROM t1 WHERE 1=2 HAVING a NOT IN ( SELECT a from t1 UNION select a+1 from t1 ) OR min_a != 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
|
||||
2 DEPENDENT SUBQUERY t1 ALL NULL NULL NULL NULL 2 Using where
|
||||
3 DEPENDENT UNION t1 ALL NULL NULL NULL NULL 2 Using where
|
||||
NULL UNION RESULT <union2,3> ALL NULL NULL NULL NULL NULL
|
||||
SELECT MIN(a) AS min_a, a FROM t1 WHERE 1=2 HAVING a NOT IN ( SELECT a from t1 UNION select a+1 from t1 ) OR min_a != 1;
|
||||
min_a a
|
||||
drop table t1;
|
||||
#
|
||||
# LP BUG#944706 Query with impossible or constant subquery in WHERE or HAVING is not
|
||||
# precomputed and thus not part of optimization
|
||||
#
|
||||
CREATE TABLE t1 ( a VARCHAR(16), KEY (a) );
|
||||
INSERT INTO t1 VALUES ('Abilene'),('Akron'),('Albany'),('Albuquerque'),('Alexandria'),('Allentown'),
|
||||
('Amarillo'),('Anaheim'),('Anchorage'),('Ann Arbor'),('Arden-Arcade');
|
||||
EXPLAIN
|
||||
SELECT MAX( alias2.a ) AS field
|
||||
FROM t1 AS alias1, t1 AS alias2, t1 AS alias3
|
||||
WHERE alias1.a = alias2.a OR alias1.a = 'y'
|
||||
HAVING field>'B' AND ( 'Moscow' ) IN ( SELECT a FROM t1 );
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 PRIMARY NULL NULL NULL NULL NULL NULL NULL Impossible HAVING
|
||||
2 SUBQUERY t1 index_subquery a a 19 const 1 Using index; Using where
|
||||
SELECT MAX( alias2.a ) AS field
|
||||
FROM t1 AS alias1, t1 AS alias2, t1 AS alias3
|
||||
WHERE alias1.a = alias2.a OR alias1.a = 'y'
|
||||
HAVING field>'B' AND ( 'Moscow' ) IN ( SELECT a FROM t1 );
|
||||
field
|
||||
EXPLAIN
|
||||
SELECT MAX( alias2.a )
|
||||
FROM t1 AS alias1, t1 AS alias2, t1 AS alias3
|
||||
WHERE alias1.a = alias2.a OR ('Moscow') IN ( SELECT a FROM t1 );
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 PRIMARY alias1 index a a 19 NULL 11 Using where; Using index
|
||||
1 PRIMARY alias2 ref a a 19 test.alias1.a 2 Using index
|
||||
1 PRIMARY alias3 index NULL a 19 NULL 11 Using index; Using join buffer (flat, BNL join)
|
||||
2 SUBQUERY t1 index_subquery a a 19 const 1 Using index; Using where
|
||||
SELECT MAX( alias2.a )
|
||||
FROM t1 AS alias1, t1 AS alias2, t1 AS alias3
|
||||
WHERE alias1.a = alias2.a OR ('Moscow') IN ( SELECT a FROM t1 );
|
||||
MAX( alias2.a )
|
||||
Arden-Arcade
|
||||
drop table t1;
|
||||
#
|
||||
# MDEV-277 CHEAP SQ: Server crashes in st_join_table::get_examined_rows
|
||||
# with semijoin+materialization, IN and = subqueries
|
||||
#
|
||||
CREATE TABLE t1 (a1 INT);
|
||||
INSERT INTO t1 VALUES (4),(6);
|
||||
CREATE TABLE t2 (b1 INT);
|
||||
INSERT INTO t2 VALUES (1),(7);
|
||||
EXPLAIN
|
||||
SELECT * FROM t1
|
||||
WHERE a1 = (SELECT COUNT(*) FROM t1 WHERE a1 IN (SELECT a1 FROM t1, 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 t1 ALL NULL NULL NULL NULL 2
|
||||
2 SUBQUERY <subquery3> eq_ref distinct_key distinct_key 4 func 1
|
||||
3 MATERIALIZED t1 ALL NULL NULL NULL NULL 2
|
||||
3 MATERIALIZED t2 ALL NULL NULL NULL NULL 2 Using join buffer (flat, BNL join)
|
||||
SELECT * FROM t1
|
||||
WHERE a1 = (SELECT COUNT(*) FROM t1 WHERE a1 IN (SELECT a1 FROM t1, t2));
|
||||
a1
|
||||
drop table t1, t2;
|
||||
#
|
||||
# MDEV-287 CHEAP SQ: A query with subquery in SELECT list, EXISTS,
|
||||
# inner joins takes hundreds times longer
|
||||
#
|
||||
CREATE TABLE t1 (a INT);
|
||||
INSERT INTO t1 VALUES (1),(7);
|
||||
CREATE TABLE t2 (b INT);
|
||||
INSERT INTO t2 VALUES (4),(5);
|
||||
CREATE TABLE t3 (c INT);
|
||||
INSERT INTO t3 VALUES (8),(3);
|
||||
set @@expensive_subquery_limit= 0;
|
||||
EXPLAIN
|
||||
SELECT (SELECT MIN(b) FROM t1, t2 WHERE b = a AND (b = alias1.b OR EXISTS (SELECT * FROM t3)))
|
||||
FROM t2 alias1, t1 alias2, t1 alias3;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 PRIMARY alias1 ALL NULL NULL NULL NULL 2
|
||||
1 PRIMARY alias2 ALL NULL NULL NULL NULL 2 Using join buffer (flat, BNL join)
|
||||
1 PRIMARY alias3 ALL NULL NULL NULL NULL 2 Using join buffer (flat, BNL join)
|
||||
2 DEPENDENT SUBQUERY t1 ALL NULL NULL NULL NULL 2 Using where
|
||||
2 DEPENDENT SUBQUERY t2 ALL NULL NULL NULL NULL 2 Using where; Using join buffer (flat, BNL join)
|
||||
3 SUBQUERY t3 ALL NULL NULL NULL NULL 2
|
||||
flush status;
|
||||
SELECT (SELECT MIN(b) FROM t1, t2 WHERE b = a AND (b = alias1.b OR EXISTS (SELECT * FROM t3)))
|
||||
FROM t2 alias1, t1 alias2, t1 alias3;
|
||||
(SELECT MIN(b) FROM t1, t2 WHERE b = a AND (b = alias1.b OR EXISTS (SELECT * FROM t3)))
|
||||
NULL
|
||||
NULL
|
||||
NULL
|
||||
NULL
|
||||
NULL
|
||||
NULL
|
||||
NULL
|
||||
NULL
|
||||
show status like "subquery_cache%";
|
||||
Variable_name Value
|
||||
Subquery_cache_hit 6
|
||||
Subquery_cache_miss 2
|
||||
show status like '%Handler_read%';
|
||||
Variable_name Value
|
||||
Handler_read_first 0
|
||||
Handler_read_key 8
|
||||
Handler_read_last 0
|
||||
Handler_read_next 0
|
||||
Handler_read_prev 0
|
||||
Handler_read_rnd 0
|
||||
Handler_read_rnd_deleted 0
|
||||
Handler_read_rnd_next 22
|
||||
set @@expensive_subquery_limit= default;
|
||||
EXPLAIN
|
||||
SELECT (SELECT MIN(b) FROM t1, t2 WHERE b = a AND (b = alias1.b OR EXISTS (SELECT * FROM t3)))
|
||||
FROM t2 alias1, t1 alias2, t1 alias3;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 PRIMARY alias1 ALL NULL NULL NULL NULL 2
|
||||
1 PRIMARY alias2 ALL NULL NULL NULL NULL 2 Using join buffer (flat, BNL join)
|
||||
1 PRIMARY alias3 ALL NULL NULL NULL NULL 2 Using join buffer (flat, BNL join)
|
||||
2 SUBQUERY t1 ALL NULL NULL NULL NULL 2
|
||||
2 SUBQUERY t2 ALL NULL NULL NULL NULL 2 Using where; Using join buffer (flat, BNL join)
|
||||
3 SUBQUERY t3 ALL NULL NULL NULL NULL 2
|
||||
flush status;
|
||||
SELECT (SELECT MIN(b) FROM t1, t2 WHERE b = a AND (b = alias1.b OR EXISTS (SELECT * FROM t3)))
|
||||
FROM t2 alias1, t1 alias2, t1 alias3;
|
||||
(SELECT MIN(b) FROM t1, t2 WHERE b = a AND (b = alias1.b OR EXISTS (SELECT * FROM t3)))
|
||||
NULL
|
||||
NULL
|
||||
NULL
|
||||
NULL
|
||||
NULL
|
||||
NULL
|
||||
NULL
|
||||
NULL
|
||||
show status like "subquery_cache%";
|
||||
Variable_name Value
|
||||
Subquery_cache_hit 0
|
||||
Subquery_cache_miss 0
|
||||
show status like '%Handler_read%';
|
||||
Variable_name Value
|
||||
Handler_read_first 0
|
||||
Handler_read_key 0
|
||||
Handler_read_last 0
|
||||
Handler_read_next 0
|
||||
Handler_read_prev 0
|
||||
Handler_read_rnd 0
|
||||
Handler_read_rnd_deleted 0
|
||||
Handler_read_rnd_next 16
|
||||
drop table t1, t2, t3;
|
||||
#
|
||||
# MDEV-288 CHEAP SQ: Valgrind warnings "Memory lost" with IN and EXISTS nested subquery, materialization+semijoin
|
||||
#
|
||||
CREATE TABLE t1 (a INT);
|
||||
INSERT INTO t1 VALUES (0),(8);
|
||||
CREATE TABLE t2 (b INT PRIMARY KEY);
|
||||
INSERT INTO t2 VALUES (1),(2);
|
||||
EXPLAIN
|
||||
SELECT * FROM t1 WHERE 4 IN (SELECT MAX(b) FROM t2 WHERE EXISTS (SELECT * FROM t1));
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 PRIMARY NULL NULL NULL NULL NULL NULL NULL Impossible WHERE
|
||||
2 MATERIALIZED NULL NULL NULL NULL NULL NULL NULL Select tables optimized away
|
||||
3 SUBQUERY t1 ALL NULL NULL NULL NULL 2
|
||||
SELECT * FROM t1 WHERE 4 IN (SELECT MAX(b) FROM t2 WHERE EXISTS (SELECT * FROM t1));
|
||||
a
|
||||
drop table t1,t2;
|
||||
#
|
||||
# MDEV-410: EXPLAIN shows type=range, while SHOW EXPLAIN and userstat show full table scan is used
|
||||
#
|
||||
CREATE TABLE t1 (a VARCHAR(3) PRIMARY KEY) ENGINE=MyISAM;
|
||||
INSERT INTO t1 VALUES ('USA');
|
||||
CREATE TABLE t2 (b INT, c VARCHAR(52), KEY(b)) ENGINE=MyISAM;
|
||||
INSERT INTO t2 VALUES (3813,'United States'),(3940,'Russia');
|
||||
CREATE TABLE t3 (d INT, KEY(d)) ENGINE=MyISAM;
|
||||
INSERT INTO t3 VALUES (12),(22),(9),(45);
|
||||
create table t4 like t3;
|
||||
insert into t4 select * from t3;
|
||||
# This should not show range access for table t2
|
||||
explain
|
||||
SELECT MIN(b) FROM ( SELECT * FROM t1, t2, t3 WHERE d = b ) AS alias1
|
||||
WHERE SLEEP(0.1) OR c < 'p' OR b = ( SELECT MIN(b) FROM t2 );
|
||||
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 ALL b NULL NULL NULL 2 Using where
|
||||
1 PRIMARY t3 ref d d 5 test.t2.b 2 Using where; Using index
|
||||
3 SUBQUERY NULL NULL NULL NULL NULL NULL NULL Select tables optimized away
|
||||
set @tmp_mdev410=@@global.userstat;
|
||||
set global userstat=on;
|
||||
flush table_statistics;
|
||||
flush index_statistics;
|
||||
SELECT MIN(b) FROM ( SELECT * FROM t1, t2, t3 WHERE d = b ) AS alias1
|
||||
WHERE SLEEP(0.1) OR c < 'p' OR b = ( SELECT MIN(b) FROM t2 );
|
||||
MIN(b)
|
||||
NULL
|
||||
# The following shows that t2 was indeed scanned with a full scan.
|
||||
show table_statistics;
|
||||
Table_schema Table_name Rows_read Rows_changed Rows_changed_x_#indexes
|
||||
test t1 2 0 0
|
||||
test t2 3 0 0
|
||||
show index_statistics;
|
||||
Table_schema Table_name Index_name Rows_read
|
||||
test t2 b 1
|
||||
set global userstat=@tmp_mdev410;
|
||||
DROP TABLE t1,t2,t3,t4;
|
||||
# return optimizer switch changed in the beginning of this test
|
||||
set optimizer_switch=@subselect_tmp;
|
||||
|
|
|
@ -161,18 +161,18 @@ SET optimizer_switch='materialization=on,in_to_exists=on';
|
|||
EXPLAIN
|
||||
SELECT * FROM t2,t3 WHERE (2,9) IN (SELECT DISTINCT a,pk FROM t1) OR a = b;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 PRIMARY t2 index a a 5 NULL 2 Using index
|
||||
1 PRIMARY t3 index b b 5 NULL 4 Using where; Using index; Using join buffer (flat, BNL join)
|
||||
2 MATERIALIZED t1 index PRIMARY,a a 5 NULL 2 Using index
|
||||
1 PRIMARY t2 index a a 5 NULL 2 Using where; Using index
|
||||
1 PRIMARY t3 ref b b 5 test.t2.a 2 Using index
|
||||
2 SUBQUERY t1 index_subquery PRIMARY,a a 5 const 0 Using index; Using where
|
||||
SELECT * FROM t2,t3 WHERE (2,9) IN (SELECT DISTINCT a,pk FROM t1) OR a = b;
|
||||
pk a b
|
||||
0 4 4
|
||||
EXPLAIN
|
||||
SELECT * FROM t2,t3 WHERE (2,9) IN (SELECT DISTINCT a,pk FROM v1) OR a = b;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 PRIMARY t2 index a a 5 NULL 2 Using index
|
||||
1 PRIMARY t3 index b b 5 NULL 4 Using where; Using index; Using join buffer (flat, BNL join)
|
||||
2 MATERIALIZED t1 index PRIMARY,a a 5 NULL 2 Using index
|
||||
1 PRIMARY t2 index a a 5 NULL 2 Using where; Using index
|
||||
1 PRIMARY t3 ref b b 5 test.t2.a 2 Using index
|
||||
2 SUBQUERY t1 index_subquery PRIMARY,a a 5 const 0 Using index; Using where
|
||||
SELECT * FROM t2,t3 WHERE (2,9) IN (SELECT DISTINCT a,pk FROM v1) OR a = b;
|
||||
pk a b
|
||||
0 4 4
|
||||
|
|
|
@ -1479,7 +1479,7 @@ id select_type table type possible_keys key key_len ref rows filtered Extra
|
|||
3 MATERIALIZED 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`))))))))
|
||||
Note 1003 select `test`.`t1`.`a` AS `a` from `test`.`t1` where 1
|
||||
SELECT * FROM t1
|
||||
WHERE (
|
||||
( SELECT a FROM t2 WHERE a = 9 ),
|
||||
|
|
|
@ -1489,7 +1489,7 @@ id select_type table type possible_keys key key_len ref rows filtered Extra
|
|||
3 MATERIALIZED 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`))))))))
|
||||
Note 1003 select `test`.`t1`.`a` AS `a` from `test`.`t1` where 1
|
||||
SELECT * FROM t1
|
||||
WHERE (
|
||||
( SELECT a FROM t2 WHERE a = 9 ),
|
||||
|
|
|
@ -226,10 +226,10 @@ NULL
|
|||
EXPLAIN EXTENDED SELECT (SELECT 1 FROM t2 WHERE d = c) AS RESULT 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
|
||||
2 DEPENDENT SUBQUERY NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables
|
||||
2 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 <expr_cache><>((select 1 from `test`.`t2` where 0)) AS `RESULT` from dual
|
||||
Note 1003 select (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
|
||||
|
@ -237,10 +237,10 @@ NULL
|
|||
EXPLAIN EXTENDED SELECT (SELECT 1 FROM t2 WHERE d = IFNULL(c,NULL)) AS RESULT FROM t1 GROUP BY c;
|
||||
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 noticed after reading const tables
|
||||
2 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 <expr_cache><>((select 1 from `test`.`t2` where 0)) AS `RESULT` from dual group by NULL
|
||||
Note 1003 select (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
|
||||
|
@ -248,10 +248,10 @@ NULL
|
|||
EXPLAIN EXTENDED SELECT (SELECT 1 FROM t2 WHERE d = c) AS RESULT FROM t1 GROUP BY c ;
|
||||
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 noticed after reading const tables
|
||||
2 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 <expr_cache><>((select 1 from `test`.`t2` where 0)) AS `RESULT` from dual group by NULL
|
||||
Note 1003 select (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
|
||||
|
@ -562,7 +562,7 @@ WHERE f3 = (
|
|||
SELECT t1.f3 FROM t1
|
||||
WHERE ( t1.f10 ) IN ( SELECT f11 FROM t2 GROUP BY f11 ));
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 PRIMARY t1 ref f3 f3 5 const 0 Using where
|
||||
1 PRIMARY NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables
|
||||
2 SUBQUERY t1 ALL NULL NULL NULL NULL 2
|
||||
2 SUBQUERY <subquery3> eq_ref distinct_key distinct_key 4 func 1
|
||||
3 MATERIALIZED t2 ALL NULL NULL NULL NULL 2
|
||||
|
@ -577,7 +577,7 @@ WHERE f3 = (
|
|||
SELECT f3 FROM t1
|
||||
WHERE ( f10, f10 ) IN ( SELECT f11, f11 FROM t2 GROUP BY f11 ));
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 PRIMARY t1 ref f3 f3 5 const 0 Using where
|
||||
1 PRIMARY NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables
|
||||
2 SUBQUERY t1 ALL NULL NULL NULL NULL 2
|
||||
2 SUBQUERY <subquery3> eq_ref distinct_key distinct_key 8 func,func 1
|
||||
3 MATERIALIZED t2 ALL NULL NULL NULL NULL 2
|
||||
|
@ -627,51 +627,51 @@ SET @@optimizer_switch = 'materialization=on,in_to_exists=off,semijoin=off';
|
|||
EXPLAIN
|
||||
SELECT * FROM t1 WHERE (2, 0) NOT IN (SELECT f3, min(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
|
||||
2 MATERIALIZED t2 system NULL NULL NULL NULL 0 const row not found
|
||||
1 PRIMARY NULL NULL NULL NULL NULL NULL NULL Impossible WHERE
|
||||
2 MATERIALIZED NULL NULL NULL NULL NULL NULL NULL no matching row in const table
|
||||
SELECT * FROM t1 WHERE (2, 0) NOT IN (SELECT f3, min(f4) FROM t2);
|
||||
f1 f2
|
||||
EXPLAIN
|
||||
SELECT * FROM t1 WHERE (2, 0) NOT IN (SELECT f3+f4, min(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
|
||||
2 MATERIALIZED t2 system NULL NULL NULL NULL 0 const row not found
|
||||
1 PRIMARY NULL NULL NULL NULL NULL NULL NULL Impossible WHERE
|
||||
2 MATERIALIZED NULL NULL NULL NULL NULL NULL NULL no matching row in const table
|
||||
SELECT * FROM t1 WHERE (2, 0) NOT IN (SELECT f3+f4, min(f4) FROM t2);
|
||||
f1 f2
|
||||
EXPLAIN
|
||||
SELECT * FROM t1 WHERE (2, 0) NOT IN (SELECT f3, min(f4)+max(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
|
||||
2 MATERIALIZED t2 system NULL NULL NULL NULL 0 const row not found
|
||||
1 PRIMARY NULL NULL NULL NULL NULL NULL NULL Impossible WHERE
|
||||
2 MATERIALIZED NULL NULL NULL NULL NULL NULL NULL no matching row in const table
|
||||
SELECT * FROM t1 WHERE (2, 0) NOT IN (SELECT f3, min(f4)+max(f4) FROM t2);
|
||||
f1 f2
|
||||
EXPLAIN
|
||||
SELECT (2, 0) NOT IN (SELECT f3, min(f4) FROM t2) as not_in;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 PRIMARY NULL NULL NULL NULL NULL NULL NULL No tables used
|
||||
2 SUBQUERY t2 system NULL NULL NULL NULL 0 const row not found
|
||||
2 SUBQUERY NULL NULL NULL NULL NULL NULL NULL no matching row in const table
|
||||
SELECT (2, 0) NOT IN (SELECT f3, min(f4) FROM t2) as not_in;
|
||||
not_in
|
||||
NULL
|
||||
EXPLAIN
|
||||
SELECT * FROM t1 WHERE (2, 0) NOT IN (SELECT f3, count(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
|
||||
2 MATERIALIZED t2 system NULL NULL NULL NULL 0 const row not found
|
||||
1 PRIMARY NULL NULL NULL NULL NULL NULL NULL Impossible WHERE
|
||||
2 MATERIALIZED NULL NULL NULL NULL NULL NULL NULL no matching row in const table
|
||||
SELECT * FROM t1 WHERE (2, 0) NOT IN (SELECT f3, count(f4) FROM t2);
|
||||
f1 f2
|
||||
EXPLAIN
|
||||
SELECT * FROM t1 WHERE (2, 0) NOT IN (SELECT f3, f3 + count(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
|
||||
2 MATERIALIZED t2 system NULL NULL NULL NULL 0 const row not found
|
||||
1 PRIMARY NULL NULL NULL NULL NULL NULL NULL Impossible WHERE
|
||||
2 MATERIALIZED NULL NULL NULL NULL NULL NULL NULL no matching row in const table
|
||||
SELECT * FROM t1 WHERE (2, 0) NOT IN (SELECT f3, f3 + count(f4) FROM t2);
|
||||
f1 f2
|
||||
EXPLAIN
|
||||
SELECT (2, 0) NOT IN (SELECT f3, count(f4) FROM t2) as not_in;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 PRIMARY NULL NULL NULL NULL NULL NULL NULL No tables used
|
||||
2 SUBQUERY t2 system NULL NULL NULL NULL 0 const row not found
|
||||
2 SUBQUERY NULL NULL NULL NULL NULL NULL NULL no matching row in const table
|
||||
SELECT (2, 0) NOT IN (SELECT f3, count(f4) FROM t2) as not_in;
|
||||
not_in
|
||||
NULL
|
||||
|
@ -679,7 +679,7 @@ EXPLAIN
|
|||
SELECT (2, 0) NOT IN (SELECT f3, count(f4) FROM t2 HAVING max(f4) > 7) as not_in;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 PRIMARY NULL NULL NULL NULL NULL NULL NULL No tables used
|
||||
2 SUBQUERY t2 system NULL NULL NULL NULL 0 const row not found
|
||||
2 SUBQUERY NULL NULL NULL NULL NULL NULL NULL no matching row in const table
|
||||
SELECT (2, 0) NOT IN (SELECT f3, count(f4) FROM t2 HAVING max(f4) > 7) as not_in;
|
||||
not_in
|
||||
1
|
||||
|
@ -687,7 +687,7 @@ EXPLAIN
|
|||
SELECT (2, 0) NOT IN (SELECT f3, count(f4) FROM t2 HAVING max(f4) is null) as not_in;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 PRIMARY NULL NULL NULL NULL NULL NULL NULL No tables used
|
||||
2 SUBQUERY t2 system NULL NULL NULL NULL 0 const row not found
|
||||
2 SUBQUERY NULL NULL NULL NULL NULL NULL NULL no matching row in const table
|
||||
SELECT (2, 0) NOT IN (SELECT f3, count(f4) FROM t2 HAVING max(f4) is null) as not_in;
|
||||
not_in
|
||||
NULL
|
||||
|
@ -695,7 +695,7 @@ EXPLAIN
|
|||
SELECT (2, 0) NOT IN (SELECT max(f3+f3), count(f4) FROM t2) as not_in;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 PRIMARY NULL NULL NULL NULL NULL NULL NULL No tables used
|
||||
2 SUBQUERY t2 system NULL NULL NULL NULL 0 const row not found
|
||||
2 SUBQUERY NULL NULL NULL NULL NULL NULL NULL no matching row in const table
|
||||
SELECT (2, 0) NOT IN (SELECT max(f3+f3), count(f4) FROM t2) as not_in;
|
||||
not_in
|
||||
NULL
|
||||
|
@ -703,7 +703,7 @@ EXPLAIN
|
|||
SELECT (2, 0) NOT IN (SELECT max(f3+f3), count(f4)+f3 FROM t2) as not_in;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 PRIMARY NULL NULL NULL NULL NULL NULL NULL No tables used
|
||||
2 SUBQUERY t2 system NULL NULL NULL NULL 0 const row not found
|
||||
2 SUBQUERY NULL NULL NULL NULL NULL NULL NULL no matching row in const table
|
||||
SELECT (2, 0) NOT IN (SELECT max(f3+f3), count(f4)+f3 FROM t2) as not_in;
|
||||
not_in
|
||||
NULL
|
||||
|
@ -718,51 +718,51 @@ SET @@optimizer_switch = 'materialization=off,in_to_exists=on,semijoin=off';
|
|||
EXPLAIN
|
||||
SELECT * FROM t1 WHERE (2, 0) NOT IN (SELECT f3, min(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
|
||||
2 SUBQUERY t2 system NULL NULL NULL NULL 0 const row not found
|
||||
1 PRIMARY NULL NULL NULL NULL NULL NULL NULL Impossible WHERE
|
||||
2 SUBQUERY NULL NULL NULL NULL NULL NULL NULL no matching row in const table
|
||||
SELECT * FROM t1 WHERE (2, 0) NOT IN (SELECT f3, min(f4) FROM t2);
|
||||
f1 f2
|
||||
EXPLAIN
|
||||
SELECT * FROM t1 WHERE (2, 0) NOT IN (SELECT f3+f4, min(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
|
||||
2 SUBQUERY t2 system NULL NULL NULL NULL 0 const row not found
|
||||
1 PRIMARY NULL NULL NULL NULL NULL NULL NULL Impossible WHERE
|
||||
2 SUBQUERY NULL NULL NULL NULL NULL NULL NULL no matching row in const table
|
||||
SELECT * FROM t1 WHERE (2, 0) NOT IN (SELECT f3+f4, min(f4) FROM t2);
|
||||
f1 f2
|
||||
EXPLAIN
|
||||
SELECT * FROM t1 WHERE (2, 0) NOT IN (SELECT f3, min(f4)+max(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
|
||||
2 SUBQUERY t2 system NULL NULL NULL NULL 0 const row not found
|
||||
1 PRIMARY NULL NULL NULL NULL NULL NULL NULL Impossible WHERE
|
||||
2 SUBQUERY NULL NULL NULL NULL NULL NULL NULL no matching row in const table
|
||||
SELECT * FROM t1 WHERE (2, 0) NOT IN (SELECT f3, min(f4)+max(f4) FROM t2);
|
||||
f1 f2
|
||||
EXPLAIN
|
||||
SELECT (2, 0) NOT IN (SELECT f3, min(f4) FROM t2) as not_in;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 PRIMARY NULL NULL NULL NULL NULL NULL NULL No tables used
|
||||
2 SUBQUERY t2 system NULL NULL NULL NULL 0 const row not found
|
||||
2 SUBQUERY NULL NULL NULL NULL NULL NULL NULL no matching row in const table
|
||||
SELECT (2, 0) NOT IN (SELECT f3, min(f4) FROM t2) as not_in;
|
||||
not_in
|
||||
NULL
|
||||
EXPLAIN
|
||||
SELECT * FROM t1 WHERE (2, 0) NOT IN (SELECT f3, count(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
|
||||
2 SUBQUERY t2 system NULL NULL NULL NULL 0 const row not found
|
||||
1 PRIMARY NULL NULL NULL NULL NULL NULL NULL Impossible WHERE
|
||||
2 SUBQUERY NULL NULL NULL NULL NULL NULL NULL no matching row in const table
|
||||
SELECT * FROM t1 WHERE (2, 0) NOT IN (SELECT f3, count(f4) FROM t2);
|
||||
f1 f2
|
||||
EXPLAIN
|
||||
SELECT * FROM t1 WHERE (2, 0) NOT IN (SELECT f3, f3 + count(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
|
||||
2 SUBQUERY t2 system NULL NULL NULL NULL 0 const row not found
|
||||
1 PRIMARY NULL NULL NULL NULL NULL NULL NULL Impossible WHERE
|
||||
2 SUBQUERY NULL NULL NULL NULL NULL NULL NULL no matching row in const table
|
||||
SELECT * FROM t1 WHERE (2, 0) NOT IN (SELECT f3, f3 + count(f4) FROM t2);
|
||||
f1 f2
|
||||
EXPLAIN
|
||||
SELECT (2, 0) NOT IN (SELECT f3, count(f4) FROM t2) as not_in;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 PRIMARY NULL NULL NULL NULL NULL NULL NULL No tables used
|
||||
2 SUBQUERY t2 system NULL NULL NULL NULL 0 const row not found
|
||||
2 SUBQUERY NULL NULL NULL NULL NULL NULL NULL no matching row in const table
|
||||
SELECT (2, 0) NOT IN (SELECT f3, count(f4) FROM t2) as not_in;
|
||||
not_in
|
||||
NULL
|
||||
|
@ -770,7 +770,7 @@ EXPLAIN
|
|||
SELECT (2, 0) NOT IN (SELECT f3, count(f4) FROM t2 HAVING max(f4) > 7) as not_in;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 PRIMARY NULL NULL NULL NULL NULL NULL NULL No tables used
|
||||
2 SUBQUERY t2 system NULL NULL NULL NULL 0 const row not found
|
||||
2 SUBQUERY NULL NULL NULL NULL NULL NULL NULL no matching row in const table
|
||||
SELECT (2, 0) NOT IN (SELECT f3, count(f4) FROM t2 HAVING max(f4) > 7) as not_in;
|
||||
not_in
|
||||
1
|
||||
|
@ -778,7 +778,7 @@ EXPLAIN
|
|||
SELECT (2, 0) NOT IN (SELECT f3, count(f4) FROM t2 HAVING max(f4) is null) as not_in;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 PRIMARY NULL NULL NULL NULL NULL NULL NULL No tables used
|
||||
2 SUBQUERY t2 system NULL NULL NULL NULL 0 const row not found
|
||||
2 SUBQUERY NULL NULL NULL NULL NULL NULL NULL no matching row in const table
|
||||
SELECT (2, 0) NOT IN (SELECT f3, count(f4) FROM t2 HAVING max(f4) is null) as not_in;
|
||||
not_in
|
||||
NULL
|
||||
|
@ -786,7 +786,7 @@ EXPLAIN
|
|||
SELECT (2, 0) NOT IN (SELECT max(f3+f3), count(f4) FROM t2) as not_in;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 PRIMARY NULL NULL NULL NULL NULL NULL NULL No tables used
|
||||
2 SUBQUERY t2 system NULL NULL NULL NULL 0 const row not found
|
||||
2 SUBQUERY NULL NULL NULL NULL NULL NULL NULL no matching row in const table
|
||||
SELECT (2, 0) NOT IN (SELECT max(f3+f3), count(f4) FROM t2) as not_in;
|
||||
not_in
|
||||
NULL
|
||||
|
@ -794,7 +794,7 @@ EXPLAIN
|
|||
SELECT (2, 0) NOT IN (SELECT max(f3+f3), count(f4)+f3 FROM t2) as not_in;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 PRIMARY NULL NULL NULL NULL NULL NULL NULL No tables used
|
||||
2 SUBQUERY t2 system NULL NULL NULL NULL 0 const row not found
|
||||
2 SUBQUERY NULL NULL NULL NULL NULL NULL NULL no matching row in const table
|
||||
SELECT (2, 0) NOT IN (SELECT max(f3+f3), count(f4)+f3 FROM t2) as not_in;
|
||||
not_in
|
||||
NULL
|
||||
|
@ -813,21 +813,21 @@ SET @@optimizer_switch = 'materialization=on,in_to_exists=off,semijoin=off';
|
|||
EXPLAIN
|
||||
SELECT * FROM t1 WHERE (2, 0) NOT IN (SELECT f3, min(f4) FROM t2 WHERE f3 > 10);
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 PRIMARY t1 ALL NULL NULL NULL NULL 2
|
||||
1 PRIMARY NULL NULL NULL NULL NULL NULL NULL Impossible WHERE
|
||||
2 MATERIALIZED t2 range PRIMARY PRIMARY 4 NULL 1 Using index condition; Rowid-ordered scan
|
||||
SELECT * FROM t1 WHERE (2, 0) NOT IN (SELECT f3, min(f4) FROM t2 WHERE f3 > 10);
|
||||
f1 f2
|
||||
EXPLAIN
|
||||
SELECT * FROM t1 WHERE (2, 0) NOT IN (SELECT f3+f4, min(f4) FROM t2 WHERE f3 > 10);
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 PRIMARY t1 ALL NULL NULL NULL NULL 2
|
||||
1 PRIMARY NULL NULL NULL NULL NULL NULL NULL Impossible WHERE
|
||||
2 MATERIALIZED t2 range PRIMARY PRIMARY 4 NULL 1 Using index condition; Rowid-ordered scan
|
||||
SELECT * FROM t1 WHERE (2, 0) NOT IN (SELECT f3+f4, min(f4) FROM t2 WHERE f3 > 10);
|
||||
f1 f2
|
||||
EXPLAIN
|
||||
SELECT * FROM t1 WHERE (2, 0) NOT IN (SELECT f3, min(f4)+max(f4) FROM t2 WHERE f3 > 10);
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 PRIMARY t1 ALL NULL NULL NULL NULL 2
|
||||
1 PRIMARY NULL NULL NULL NULL NULL NULL NULL Impossible WHERE
|
||||
2 MATERIALIZED t2 range PRIMARY PRIMARY 4 NULL 1 Using index condition; Rowid-ordered scan
|
||||
SELECT * FROM t1 WHERE (2, 0) NOT IN (SELECT f3, min(f4)+max(f4) FROM t2 WHERE f3 > 10);
|
||||
f1 f2
|
||||
|
@ -842,14 +842,14 @@ NULL
|
|||
EXPLAIN
|
||||
SELECT * FROM t1 WHERE (2, 0) NOT IN (SELECT f3, count(f4) FROM t2 WHERE f3 > 10);
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 PRIMARY t1 ALL NULL NULL NULL NULL 2
|
||||
1 PRIMARY NULL NULL NULL NULL NULL NULL NULL Impossible WHERE
|
||||
2 MATERIALIZED t2 range PRIMARY PRIMARY 4 NULL 1 Using index condition; Rowid-ordered scan
|
||||
SELECT * FROM t1 WHERE (2, 0) NOT IN (SELECT f3, count(f4) FROM t2 WHERE f3 > 10);
|
||||
f1 f2
|
||||
EXPLAIN
|
||||
SELECT * FROM t1 WHERE (2, 0) NOT IN (SELECT f3, f3 + count(f4) FROM t2 WHERE f3 > 10);
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 PRIMARY t1 ALL NULL NULL NULL NULL 2
|
||||
1 PRIMARY NULL NULL NULL NULL NULL NULL NULL Impossible WHERE
|
||||
2 MATERIALIZED t2 range PRIMARY PRIMARY 4 NULL 1 Using index condition; Rowid-ordered scan
|
||||
SELECT * FROM t1 WHERE (2, 0) NOT IN (SELECT f3, f3 + count(f4) FROM t2 WHERE f3 > 10);
|
||||
f1 f2
|
||||
|
@ -904,21 +904,21 @@ SET @@optimizer_switch = 'materialization=off,in_to_exists=on,semijoin=off';
|
|||
EXPLAIN
|
||||
SELECT * FROM t1 WHERE (2, 0) NOT IN (SELECT f3, min(f4) FROM t2 WHERE f3 > 10);
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 PRIMARY t1 ALL NULL NULL NULL NULL 2
|
||||
1 PRIMARY NULL NULL NULL NULL NULL NULL NULL Impossible WHERE
|
||||
2 SUBQUERY t2 range PRIMARY PRIMARY 4 NULL 1 Using index condition; Rowid-ordered scan
|
||||
SELECT * FROM t1 WHERE (2, 0) NOT IN (SELECT f3, min(f4) FROM t2 WHERE f3 > 10);
|
||||
f1 f2
|
||||
EXPLAIN
|
||||
SELECT * FROM t1 WHERE (2, 0) NOT IN (SELECT f3+f4, min(f4) FROM t2 WHERE f3 > 10);
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 PRIMARY t1 ALL NULL NULL NULL NULL 2
|
||||
1 PRIMARY NULL NULL NULL NULL NULL NULL NULL Impossible WHERE
|
||||
2 SUBQUERY t2 range PRIMARY PRIMARY 4 NULL 1 Using index condition; Rowid-ordered scan
|
||||
SELECT * FROM t1 WHERE (2, 0) NOT IN (SELECT f3+f4, min(f4) FROM t2 WHERE f3 > 10);
|
||||
f1 f2
|
||||
EXPLAIN
|
||||
SELECT * FROM t1 WHERE (2, 0) NOT IN (SELECT f3, min(f4)+max(f4) FROM t2 WHERE f3 > 10);
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 PRIMARY t1 ALL NULL NULL NULL NULL 2
|
||||
1 PRIMARY NULL NULL NULL NULL NULL NULL NULL Impossible WHERE
|
||||
2 SUBQUERY t2 range PRIMARY PRIMARY 4 NULL 1 Using index condition; Rowid-ordered scan
|
||||
SELECT * FROM t1 WHERE (2, 0) NOT IN (SELECT f3, min(f4)+max(f4) FROM t2 WHERE f3 > 10);
|
||||
f1 f2
|
||||
|
@ -933,14 +933,14 @@ NULL
|
|||
EXPLAIN
|
||||
SELECT * FROM t1 WHERE (2, 0) NOT IN (SELECT f3, count(f4) FROM t2 WHERE f3 > 10);
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 PRIMARY t1 ALL NULL NULL NULL NULL 2
|
||||
1 PRIMARY NULL NULL NULL NULL NULL NULL NULL Impossible WHERE
|
||||
2 SUBQUERY t2 range PRIMARY PRIMARY 4 NULL 1 Using index condition; Rowid-ordered scan
|
||||
SELECT * FROM t1 WHERE (2, 0) NOT IN (SELECT f3, count(f4) FROM t2 WHERE f3 > 10);
|
||||
f1 f2
|
||||
EXPLAIN
|
||||
SELECT * FROM t1 WHERE (2, 0) NOT IN (SELECT f3, f3 + count(f4) FROM t2 WHERE f3 > 10);
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 PRIMARY t1 ALL NULL NULL NULL NULL 2
|
||||
1 PRIMARY NULL NULL NULL NULL NULL NULL NULL Impossible WHERE
|
||||
2 SUBQUERY t2 range PRIMARY PRIMARY 4 NULL 1 Using index condition; Rowid-ordered scan
|
||||
SELECT * FROM t1 WHERE (2, 0) NOT IN (SELECT f3, f3 + count(f4) FROM t2 WHERE f3 > 10);
|
||||
f1 f2
|
||||
|
@ -1220,6 +1220,13 @@ id select_type table type possible_keys key key_len ref rows Extra
|
|||
2 SUBQUERY t2 ALL NULL NULL NULL NULL 2 Using where
|
||||
3 SUBQUERY SQ1_t1 index NULL f4 5 NULL 2 Using index; Using temporary
|
||||
3 SUBQUERY SQ1_t3 index f4 f4 5 NULL 2 Using where; Using index; Using join buffer (flat, BNL join)
|
||||
SELECT * FROM t1 WHERE
|
||||
(SELECT f2 FROM t2
|
||||
WHERE f4 <= ALL
|
||||
(SELECT max(SQ1_t1.f4)
|
||||
FROM t3 AS SQ1_t1 JOIN t3 AS SQ1_t3 ON SQ1_t3.f4
|
||||
GROUP BY SQ1_t1.f4));
|
||||
ERROR 21000: Subquery returns more than 1 row
|
||||
drop table t1, t2, t3;
|
||||
#
|
||||
# BUG#52317: Assertion failing in Field_varstring::store()
|
||||
|
@ -1250,10 +1257,9 @@ 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 t2 system NULL NULL NULL NULL 1
|
||||
1 PRIMARY t1 ALL NULL NULL NULL NULL 2 Using where
|
||||
1 PRIMARY NULL NULL NULL NULL NULL NULL NULL Impossible WHERE
|
||||
3 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
|
||||
2 DEPENDENT SUBQUERY t1 ALL NULL NULL NULL NULL 2 Using where
|
||||
SELECT COUNT(t2.f3),
|
||||
(SELECT COUNT(f3) FROM t1 WHERE t2.f1) AS f9
|
||||
FROM t2 JOIN t1 ON t1.f3
|
||||
|
@ -1267,17 +1273,16 @@ 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 t2 system NULL NULL NULL NULL 1
|
||||
1 PRIMARY t1 ALL NULL NULL NULL NULL 2 Using where
|
||||
1 PRIMARY NULL NULL NULL NULL NULL NULL NULL Impossible WHERE
|
||||
3 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
|
||||
2 DEPENDENT SUBQUERY t1 ALL NULL NULL NULL NULL 2 Using where
|
||||
SELECT COUNT(t2.f3),
|
||||
(SELECT COUNT(f3) FROM t1 WHERE t2.f1) AS f9
|
||||
FROM t2 JOIN t1 ON t1.f3
|
||||
WHERE ('v') IN (SELECT f4 FROM t2)
|
||||
ORDER BY f9;
|
||||
COUNT(t2.f3) f9
|
||||
0 2
|
||||
0 NULL
|
||||
EXPLAIN
|
||||
SELECT COUNT(t2.f3),
|
||||
(SELECT t2.f1 FROM t1 limit 1) AS f9
|
||||
|
@ -1285,8 +1290,7 @@ FROM t2 JOIN t1
|
|||
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 t2 system NULL NULL NULL NULL 1
|
||||
1 PRIMARY t1 ALL NULL NULL NULL NULL 2
|
||||
1 PRIMARY NULL NULL NULL NULL NULL NULL NULL Impossible WHERE
|
||||
3 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),
|
||||
|
@ -1302,8 +1306,7 @@ FROM t2 JOIN t1
|
|||
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 t2 system NULL NULL NULL NULL 1
|
||||
1 PRIMARY t1 ALL NULL NULL NULL NULL 2
|
||||
1 PRIMARY NULL NULL NULL NULL NULL NULL NULL Impossible WHERE
|
||||
3 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),
|
||||
|
@ -1325,7 +1328,7 @@ EXPLAIN
|
|||
SELECT (SELECT f1 FROM t1) AS field1 FROM t2 GROUP BY field1;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 PRIMARY t2 ALL NULL NULL NULL NULL 2
|
||||
2 SUBQUERY t1 system NULL NULL NULL NULL 0 const row not found
|
||||
2 SUBQUERY NULL NULL NULL NULL NULL NULL NULL no matching row in const table
|
||||
SELECT (SELECT f1 FROM t1) AS field1 FROM t2 GROUP BY field1;
|
||||
field1
|
||||
NULL
|
||||
|
@ -1333,7 +1336,7 @@ EXPLAIN
|
|||
SELECT (SELECT f1 FROM t1) AS field1 FROM t2 ORDER BY field1;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 PRIMARY t2 ALL NULL NULL NULL NULL 2
|
||||
2 SUBQUERY t1 system NULL NULL NULL NULL 0 const row not found
|
||||
2 SUBQUERY NULL NULL NULL NULL NULL NULL NULL no matching row in const table
|
||||
SELECT (SELECT f1 FROM t1) AS field1 FROM t2 ORDER BY field1;
|
||||
field1
|
||||
NULL
|
||||
|
@ -1631,7 +1634,7 @@ SET SESSION optimizer_switch='in_to_exists=on,materialization=off';
|
|||
EXPLAIN
|
||||
SELECT * FROM t1 WHERE ( 6 ) NOT IN ( SELECT t2.f3 FROM t2 JOIN t3 ON t3.f10 = t2.f10);
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 PRIMARY t1 ALL NULL NULL NULL NULL 2
|
||||
1 PRIMARY NULL NULL NULL NULL NULL NULL NULL Impossible WHERE
|
||||
2 SUBQUERY t3 system NULL NULL NULL NULL 1
|
||||
2 SUBQUERY t2 ref_or_null f10 f10 10 const,const 2 Using where; Using index
|
||||
SELECT * FROM t1 WHERE ( 6 ) NOT IN ( SELECT t2.f3 FROM t2 JOIN t3 ON t3.f10 = t2.f10);
|
||||
|
@ -1852,8 +1855,8 @@ GROUP BY 1, 2;
|
|||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 PRIMARY t3 system NULL NULL NULL NULL 1 Using temporary; Using filesort
|
||||
1 PRIMARY t2 ALL NULL NULL NULL NULL 2 Using where
|
||||
2 SUBQUERY NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables
|
||||
3 MATERIALIZED t1 system NULL NULL NULL NULL 0 const row not found
|
||||
2 SUBQUERY NULL NULL NULL NULL NULL NULL NULL Impossible WHERE
|
||||
3 MATERIALIZED NULL NULL NULL NULL NULL NULL NULL no matching row in const table
|
||||
PREPARE st1 FROM "
|
||||
SELECT t2.f1, (SELECT f2 FROM t1 WHERE (7) IN (SELECT f1 FROM t1))
|
||||
FROM t2 JOIN t3 ON t3.f4 = t2.f4
|
||||
|
@ -2029,6 +2032,61 @@ id select_type table type possible_keys key key_len ref rows Extra
|
|||
1 PRIMARY t1 ALL NULL NULL NULL NULL 10 Using where
|
||||
2 SUBQUERY five ALL NULL NULL NULL NULL 5 Using where
|
||||
drop table ten, t1, five;
|
||||
#
|
||||
# LP BUG#1008773 Wrong result (NULL instead of a value) with no matching rows, subquery in FROM and HAVING
|
||||
#
|
||||
CREATE TABLE t1 (a INT) ENGINE=MyISAM;
|
||||
CREATE TABLE t2 (b INT) ENGINE=MyISAM;
|
||||
INSERT INTO t2 VALUES (1);
|
||||
EXPLAIN
|
||||
SELECT MAX(a), ( SELECT 1 FROM t2 ) AS bb FROM t1;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 PRIMARY t1 system NULL NULL NULL NULL 0 const row not found
|
||||
2 SUBQUERY t2 system NULL NULL NULL NULL 1
|
||||
SELECT MAX(a), ( SELECT 1 FROM t2 ) AS bb FROM t1;
|
||||
MAX(a) bb
|
||||
NULL 1
|
||||
EXPLAIN
|
||||
SELECT MAX(a), 1 in ( SELECT b FROM t2 ) AS bb FROM t1;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 PRIMARY t1 system NULL NULL NULL NULL 0 const row not found
|
||||
2 SUBQUERY t2 system NULL NULL NULL NULL 1
|
||||
SELECT MAX(a), 1 in ( SELECT b FROM t2 ) AS bb FROM t1;
|
||||
MAX(a) bb
|
||||
NULL 1
|
||||
EXPLAIN
|
||||
SELECT MAX(a), 1 >= ALL ( SELECT b FROM t2 ) AS bb FROM t1;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 PRIMARY t1 system NULL NULL NULL NULL 0 const row not found
|
||||
2 SUBQUERY NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables
|
||||
SELECT MAX(a), 1 >= ALL ( SELECT b FROM t2 ) AS bb FROM t1;
|
||||
MAX(a) bb
|
||||
NULL 1
|
||||
EXPLAIN
|
||||
SELECT MAX(a), ( SELECT 1 FROM t2 where b = a) AS bb FROM t1;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 PRIMARY t1 system NULL NULL NULL NULL 0 const row not found
|
||||
2 SUBQUERY NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables
|
||||
SELECT MAX(a), ( SELECT 1 FROM t2 where b = a) AS bb FROM t1;
|
||||
MAX(a) bb
|
||||
NULL NULL
|
||||
EXPLAIN
|
||||
SELECT MAX(a), a in ( SELECT b FROM t2 ) AS bb FROM t1;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 PRIMARY t1 system NULL NULL NULL NULL 0 const row not found
|
||||
2 DEPENDENT SUBQUERY t2 system NULL NULL NULL NULL 1
|
||||
SELECT MAX(a), a in ( SELECT b FROM t2 ) AS bb FROM t1;
|
||||
MAX(a) bb
|
||||
NULL NULL
|
||||
EXPLAIN
|
||||
SELECT MAX(a), a >= ALL ( SELECT b FROM t2 ) AS bb FROM t1;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 PRIMARY t1 system NULL NULL NULL NULL 0 const row not found
|
||||
2 DEPENDENT SUBQUERY t2 system NULL NULL NULL NULL 1
|
||||
SELECT MAX(a), a >= ALL ( SELECT b FROM t2 ) AS bb FROM t1;
|
||||
MAX(a) bb
|
||||
NULL NULL
|
||||
drop table t1, t2;
|
||||
set optimizer_switch=@subselect4_tmp;
|
||||
SET optimizer_switch= @@global.optimizer_switch;
|
||||
set @@tmp_table_size= @@global.tmp_table_size;
|
||||
|
|
|
@ -486,9 +486,9 @@ Handler_read_key 7
|
|||
Handler_read_last 0
|
||||
Handler_read_next 0
|
||||
Handler_read_prev 0
|
||||
Handler_read_rnd 10
|
||||
Handler_read_rnd 0
|
||||
Handler_read_rnd_deleted 0
|
||||
Handler_read_rnd_next 42
|
||||
Handler_read_rnd_next 31
|
||||
set optimizer_switch='subquery_cache=off';
|
||||
flush status;
|
||||
select a from t1 ORDER BY (select d from t2 where b=c);
|
||||
|
@ -514,9 +514,9 @@ Handler_read_key 0
|
|||
Handler_read_last 0
|
||||
Handler_read_next 0
|
||||
Handler_read_prev 0
|
||||
Handler_read_rnd 10
|
||||
Handler_read_rnd 0
|
||||
Handler_read_rnd_deleted 0
|
||||
Handler_read_rnd_next 72
|
||||
Handler_read_rnd_next 61
|
||||
set optimizer_switch='subquery_cache=on';
|
||||
#single value subquery test (distinct ORDER BY)
|
||||
flush status;
|
||||
|
|
|
@ -46,7 +46,7 @@ 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
|
||||
2 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)))
|
||||
|
@ -58,7 +58,7 @@ 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
|
||||
2 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)))
|
||||
|
|
|
@ -332,8 +332,8 @@ 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
|
||||
2 SUBQUERY NULL NULL NULL NULL NULL NULL NULL Impossible WHERE
|
||||
3 SUBQUERY internal_tmp_table ALL group_key NULL NULL NULL 0 Using temporary
|
||||
SELECT *
|
||||
FROM t1
|
||||
WHERE t1.a = (
|
||||
|
@ -361,7 +361,7 @@ 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
|
||||
2 SUBQUERY NULL NULL NULL NULL NULL NULL NULL Impossible WHERE
|
||||
3 SUBQUERY t3 ALL NULL NULL NULL NULL 1
|
||||
SELECT MAX( f1 ) FROM t2
|
||||
WHERE f2 >= (
|
||||
|
@ -386,7 +386,7 @@ select 1 from t1 where 1 like (select 1 from t1 where 1 <=> (select 1 from t1 gr
|
|||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 PRIMARY t1 ALL NULL NULL NULL NULL 1
|
||||
2 SUBQUERY t1 ALL NULL NULL NULL NULL 1
|
||||
3 SUBQUERY t1 ALL NULL NULL NULL NULL 1 Using temporary; Using filesort
|
||||
3 SUBQUERY internal_tmp_table ALL group_key NULL NULL NULL 1 Using temporary; Using filesort
|
||||
select 1 from t1 where 1 like (select 1 from t1 where 1 <=> (select 1 from t1 group by a1));
|
||||
1
|
||||
1
|
||||
|
|
|
@ -1152,8 +1152,8 @@ create table t2 (b1 int);
|
|||
insert into t1 values (5);
|
||||
explain select min(a1) from t1 where 7 in (select max(b1) from t2 group by b1);
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 PRIMARY t1 system NULL NULL NULL NULL 1
|
||||
2 MATERIALIZED t2 system NULL NULL NULL NULL 0 const row not found
|
||||
1 PRIMARY NULL NULL NULL NULL NULL NULL NULL Impossible WHERE
|
||||
2 MATERIALIZED NULL NULL NULL NULL NULL NULL NULL no matching row in const table
|
||||
select min(a1) from t1 where 7 in (select max(b1) from t2 group by b1);
|
||||
min(a1)
|
||||
NULL
|
||||
|
@ -1162,8 +1162,8 @@ set @@optimizer_switch=@optimizer_switch_local_default;
|
|||
set @@optimizer_switch='materialization=off,in_to_exists=on';
|
||||
explain select min(a1) from t1 where 7 in (select max(b1) from t2 group by b1);
|
||||
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 system NULL NULL NULL NULL 0 const row not found
|
||||
1 PRIMARY NULL NULL NULL NULL NULL NULL NULL Impossible WHERE
|
||||
2 SUBQUERY NULL NULL NULL NULL NULL NULL NULL no matching row in const table
|
||||
select min(a1) from t1 where 7 in (select max(b1) from t2 group by b1);
|
||||
min(a1)
|
||||
NULL
|
||||
|
@ -1171,8 +1171,8 @@ set @@optimizer_switch=@optimizer_switch_local_default;
|
|||
set @@optimizer_switch='semijoin=off';
|
||||
explain select min(a1) from t1 where 7 in (select b1 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 MATERIALIZED t2 system NULL NULL NULL NULL 0 const row not found
|
||||
1 PRIMARY NULL NULL NULL NULL NULL NULL NULL Impossible WHERE
|
||||
2 MATERIALIZED NULL NULL NULL NULL NULL NULL NULL no matching row in const table
|
||||
select min(a1) from t1 where 7 in (select b1 from t2);
|
||||
min(a1)
|
||||
NULL
|
||||
|
@ -1181,16 +1181,16 @@ set @@optimizer_switch='materialization=off,in_to_exists=on';
|
|||
# with MariaDB and MWL#90, this particular case is solved:
|
||||
explain select min(a1) from t1 where 7 in (select b1 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 NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables
|
||||
1 PRIMARY NULL NULL NULL NULL NULL NULL NULL Impossible WHERE
|
||||
2 SUBQUERY NULL NULL NULL NULL NULL NULL NULL no matching row in const table
|
||||
select min(a1) from t1 where 7 in (select b1 from t2);
|
||||
min(a1)
|
||||
NULL
|
||||
# but when we go around MWL#90 code, the problem still shows up:
|
||||
explain select min(a1) from t1 where 7 in (select b1 from t2) or 2> 4;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 PRIMARY t1 system NULL NULL NULL NULL 1
|
||||
2 SUBQUERY NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables
|
||||
1 PRIMARY NULL NULL NULL NULL NULL NULL NULL Impossible WHERE
|
||||
2 SUBQUERY NULL NULL NULL NULL NULL NULL NULL no matching row in const table
|
||||
select min(a1) from t1 where 7 in (select b1 from t2) or 2> 4;
|
||||
min(a1)
|
||||
NULL
|
||||
|
@ -1932,7 +1932,7 @@ WHERE s2.d = s1.e AND s1.e = (SELECT MAX(e) FROM t2));
|
|||
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 index NULL c 5 NULL 8 Using where; Using index
|
||||
2 MATERIALIZED s2 ref d d 4 const 1 Using where; Using index
|
||||
2 MATERIALIZED s2 ref d d 4 const 2 Using where; Using index
|
||||
2 MATERIALIZED s1 ALL NULL NULL NULL NULL 8 Using where; Using join buffer (flat, BNL join)
|
||||
3 SUBQUERY t2 ALL NULL NULL NULL NULL 8
|
||||
SELECT a, c FROM t1, t2
|
||||
|
@ -1951,8 +1951,8 @@ WHERE s2.d = s1.e AND s1.e = (SELECT MAX(e) FROM t2));
|
|||
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 index NULL c 5 NULL 8 Using where; Using index
|
||||
2 MATERIALIZED s2 ref d d 4 const 1 Using where; Using index
|
||||
2 MATERIALIZED s1 hash_ALL NULL #hash#$hj 5 test.s2.d 8 Using where; Using join buffer (flat, BNLH join)
|
||||
2 MATERIALIZED s2 ref d d 4 const 2 Using where; Using index
|
||||
2 MATERIALIZED s1 ALL NULL NULL NULL NULL 8 Using where; Using join buffer (flat, BNL join)
|
||||
3 SUBQUERY t2 ALL NULL NULL NULL NULL 8
|
||||
SELECT a, c FROM t1, t2
|
||||
WHERE (a, c) IN (SELECT s1.b, s1.c FROM t2 AS s1, t2 AS s2
|
||||
|
@ -2166,7 +2166,7 @@ set @@optimizer_switch='materialization=on,partial_match_rowid_merge=on,partial_
|
|||
EXPLAIN
|
||||
SELECT * FROM t2 WHERE (SELECT f3a FROM t3) NOT IN (SELECT f1a FROM t1);
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 PRIMARY t2 ALL NULL NULL NULL NULL 2
|
||||
1 PRIMARY NULL NULL NULL NULL NULL NULL NULL Impossible WHERE
|
||||
3 MATERIALIZED t1 ALL NULL NULL NULL NULL 2
|
||||
2 SUBQUERY NULL NULL NULL NULL NULL NULL NULL no matching row in const table
|
||||
SELECT * FROM t2 WHERE (SELECT f3a FROM t3) NOT IN (SELECT f1a FROM t1);
|
||||
|
@ -2175,7 +2175,7 @@ EXPLAIN
|
|||
SELECT (SELECT f3a FROM t3) NOT IN (SELECT f1a FROM t1);
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 PRIMARY NULL NULL NULL NULL NULL NULL NULL No tables used
|
||||
3 DEPENDENT SUBQUERY t1 ALL NULL NULL NULL NULL 2 Using where
|
||||
3 SUBQUERY t1 ALL NULL NULL NULL NULL 2 Using where
|
||||
2 SUBQUERY NULL NULL NULL NULL NULL NULL NULL no matching row in const table
|
||||
SELECT (SELECT f3a FROM t3) NOT IN (SELECT f1a FROM t1);
|
||||
(SELECT f3a FROM t3) NOT IN (SELECT f1a FROM t1)
|
||||
|
@ -2183,7 +2183,7 @@ NULL
|
|||
EXPLAIN
|
||||
SELECT * FROM t2 WHERE (SELECT f3a, f3b FROM t3) NOT IN (SELECT f1a, f1b FROM t1);
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 PRIMARY t2 ALL NULL NULL NULL NULL 2
|
||||
1 PRIMARY NULL NULL NULL NULL NULL NULL NULL Impossible WHERE
|
||||
3 MATERIALIZED t1 ALL NULL NULL NULL NULL 2
|
||||
2 SUBQUERY NULL NULL NULL NULL NULL NULL NULL no matching row in const table
|
||||
SELECT * FROM t2 WHERE (SELECT f3a, f3b FROM t3) NOT IN (SELECT f1a, f1b FROM t1);
|
||||
|
@ -2192,7 +2192,7 @@ EXPLAIN
|
|||
SELECT (SELECT f3a, f3b FROM t3) NOT IN (SELECT f1a, f1b FROM t1);
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 PRIMARY NULL NULL NULL NULL NULL NULL NULL No tables used
|
||||
3 DEPENDENT SUBQUERY t1 ALL NULL NULL NULL NULL 2 Using where
|
||||
3 SUBQUERY t1 ALL NULL NULL NULL NULL 2 Using where
|
||||
2 SUBQUERY NULL NULL NULL NULL NULL NULL NULL no matching row in const table
|
||||
SELECT (SELECT f3a, f3b FROM t3) NOT IN (SELECT f1a, f1b FROM t1);
|
||||
(SELECT f3a, f3b FROM t3) NOT IN (SELECT f1a, f1b FROM t1)
|
||||
|
@ -2235,10 +2235,10 @@ NULL
|
|||
EXPLAIN EXTENDED
|
||||
SELECT MAX(t1.b) AS max_res FROM t1 WHERE (9) IN (SELECT a FROM t2);
|
||||
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
|
||||
1 PRIMARY NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE
|
||||
2 MATERIALIZED t2 ALL NULL NULL NULL NULL 2 100.00
|
||||
Warnings:
|
||||
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`))))))
|
||||
Note 1003 select max(`test`.`t1`.`b`) AS `max_res` from `test`.`t1` where 0
|
||||
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
|
||||
|
@ -2246,10 +2246,10 @@ NULL
|
|||
EXPLAIN EXTENDED
|
||||
SELECT MAX(t1.b) AS max_res FROM t1 WHERE (9) IN (SELECT a FROM t2);
|
||||
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
|
||||
1 PRIMARY NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE
|
||||
2 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 <expr_cache><9>(<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 0
|
||||
DROP TABLE t1,t2;
|
||||
#
|
||||
# LPBUG#825095: Wrong result with materialization and NOT IN with 2 expressions
|
||||
|
|
|
@ -496,7 +496,7 @@ from City
|
|||
where City.population > 10000000;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 PRIMARY City range Population Population 5 NULL 4 Using index condition; Rowid-ordered scan
|
||||
2 DEPENDENT SUBQUERY Country index_subquery CountryCapital CountryCapital 5 func 2 Using index; Using where
|
||||
2 SUBQUERY Country index_subquery CountryCapital CountryCapital 5 func 2 Using index; Using where
|
||||
select Name, City.id in (select capital from Country where capital is not null) as is_capital
|
||||
from City
|
||||
where City.population > 10000000;
|
||||
|
|
|
@ -124,7 +124,7 @@ FROM t3 RIGHT JOIN t1 ON t1.pk = t3.f1
|
|||
WHERE t3.f3 OR ( 3 ) IN ( SELECT f2 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
|
||||
2 SUBQUERY NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables
|
||||
2 SUBQUERY NULL NULL NULL NULL NULL NULL NULL no matching row in const table
|
||||
SELECT t1.*
|
||||
FROM t3 RIGHT JOIN t1 ON t1.pk = t3.f1
|
||||
WHERE t3.f3 OR ( 3 ) IN ( SELECT f2 FROM t2 );
|
||||
|
@ -148,7 +148,7 @@ FROM t2 GROUP BY 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
|
||||
2 SUBQUERY t1 system NULL NULL NULL NULL 1
|
||||
3 SUBQUERY t2 ALL NULL NULL NULL NULL 2 Using temporary; Using filesort
|
||||
3 SUBQUERY internal_tmp_table ALL group_key NULL NULL NULL 1 Using temporary; Using filesort
|
||||
drop table t1, t2, t3;
|
||||
#
|
||||
# LP BUG#715034 Item_sum_distinct::clear(): Assertion `tree != 0' failed
|
||||
|
@ -162,7 +162,7 @@ EXPLAIN
|
|||
SELECT * FROM (SELECT * FROM t2) AS a2
|
||||
WHERE (SELECT distinct SUM(distinct f3 ) FROM t1);
|
||||
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 <derived2> system NULL NULL NULL NULL 0 const row not found
|
||||
3 SUBQUERY t1 index NULL f3 5 NULL 2 Using index
|
||||
2 DERIVED NULL NULL NULL NULL NULL NULL NULL no matching row in const table
|
||||
insert into t2 values (1),(2);
|
||||
|
@ -209,8 +209,8 @@ WHERE t1.f1 AND alias2.f10
|
|||
ORDER BY field1 ;
|
||||
field1
|
||||
Warnings:
|
||||
Warning 1292 Truncated incorrect INTEGER value: 'f'
|
||||
Warning 1292 Truncated incorrect INTEGER value: 'd'
|
||||
Warning 1292 Truncated incorrect DOUBLE value: 'f'
|
||||
Warning 1292 Truncated incorrect DOUBLE value: 'd'
|
||||
set optimizer_switch=@tmp_optimizer_switch;
|
||||
drop table t1,t2;
|
||||
#
|
||||
|
|
|
@ -58,12 +58,12 @@ ERROR 42S22: Reference 'a' not supported (forward reference in item list)
|
|||
EXPLAIN EXTENDED SELECT 1 FROM (SELECT 1 as a) as b HAVING (SELECT a)=1;
|
||||
id select_type table type possible_keys key key_len ref rows filtered Extra
|
||||
1 PRIMARY <derived2> system NULL NULL NULL NULL 1 100.00
|
||||
3 DEPENDENT SUBQUERY NULL NULL NULL NULL NULL NULL NULL NULL No tables used
|
||||
3 SUBQUERY NULL NULL NULL NULL NULL NULL NULL NULL No tables used
|
||||
2 DERIVED NULL NULL NULL NULL NULL NULL NULL NULL No tables used
|
||||
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
|
||||
|
@ -378,12 +378,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 where; Using index
|
||||
1 PRIMARY t8 const PRIMARY PRIMARY 37 const 1 100.00 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 Using where
|
||||
2 SUBQUERY t8 const PRIMARY PRIMARY 37 const 1 100.00
|
||||
3 SUBQUERY t8 const PRIMARY PRIMARY 37 const 1 100.00 Using index
|
||||
Warnings:
|
||||
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))
|
||||
Note 1003 select 'joce' AS `pseudo`,(select 'test' from `test`.`t8` where 1) AS `(SELECT email FROM t8 WHERE pseudo=(SELECT pseudo FROM t8 WHERE pseudo='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)
|
||||
|
@ -524,6 +524,7 @@ ERROR 21000: Subquery returns more than 1 row
|
|||
show warnings;
|
||||
Level Code Message
|
||||
Error 1242 Subquery returns more than 1 row
|
||||
Error 1028 Sort aborted: Subquery returns more than 1 row
|
||||
drop table t1;
|
||||
create table t1 (a int);
|
||||
insert into t1 values (1),(2),(3);
|
||||
|
@ -554,11 +555,7 @@ 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'))))
|
||||
ERROR 21000: Subquery returns more than 1 row
|
||||
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';
|
||||
|
@ -914,7 +911,7 @@ a t1.a in (select t2.a from t2)
|
|||
explain extended SELECT t1.a, t1.a in (select t2.a from t2) FROM t1;
|
||||
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
|
||||
2 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`
|
||||
CREATE TABLE t3 (a int(11) default '0');
|
||||
|
@ -1615,25 +1612,25 @@ a3 1
|
|||
explain extended select s1, s1 NOT IN (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
|
||||
2 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`
|
||||
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
|
||||
2 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`
|
||||
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
|
||||
2 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`
|
||||
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
|
||||
2 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`
|
||||
drop table t1,t2;
|
||||
|
@ -1682,34 +1679,34 @@ select * from t3 where NULL >= any (select b from t2);
|
|||
a
|
||||
explain extended select * from t3 where NULL >= any (select b from t2);
|
||||
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
|
||||
2 SUBQUERY t2 system NULL NULL NULL NULL 0 0.00 const row not found
|
||||
1 PRIMARY NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE
|
||||
2 SUBQUERY NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table
|
||||
Warnings:
|
||||
Note 1003 select `test`.`t3`.`a` AS `a` from `test`.`t3` where <nop>(<in_optimizer>(NULL,((select min(NULL) from `test`.`t2`) <= NULL)))
|
||||
Note 1003 select `test`.`t3`.`a` AS `a` from `test`.`t3` where 0
|
||||
select * from t3 where NULL >= any (select b from t2 group by 1);
|
||||
a
|
||||
explain extended select * from t3 where NULL >= any (select b from t2 group by 1);
|
||||
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
|
||||
2 SUBQUERY t2 system NULL NULL NULL NULL 0 0.00 const row not found
|
||||
1 PRIMARY NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE
|
||||
2 SUBQUERY NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table
|
||||
Warnings:
|
||||
Note 1003 select `test`.`t3`.`a` AS `a` from `test`.`t3` where <nop>(<in_optimizer>(NULL,((select min(NULL) from `test`.`t2`) <= NULL)))
|
||||
Note 1003 select `test`.`t3`.`a` AS `a` from `test`.`t3` where 0
|
||||
select * from t3 where NULL >= some (select b from t2);
|
||||
a
|
||||
explain extended select * from t3 where NULL >= some (select b from t2);
|
||||
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
|
||||
2 SUBQUERY t2 system NULL NULL NULL NULL 0 0.00 const row not found
|
||||
1 PRIMARY NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE
|
||||
2 SUBQUERY NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table
|
||||
Warnings:
|
||||
Note 1003 select `test`.`t3`.`a` AS `a` from `test`.`t3` where <nop>(<in_optimizer>(NULL,((select min(NULL) from `test`.`t2`) <= NULL)))
|
||||
Note 1003 select `test`.`t3`.`a` AS `a` from `test`.`t3` where 0
|
||||
select * from t3 where NULL >= some (select b from t2 group by 1);
|
||||
a
|
||||
explain extended select * from t3 where NULL >= some (select b from t2 group by 1);
|
||||
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
|
||||
2 SUBQUERY t2 system NULL NULL NULL NULL 0 0.00 const row not found
|
||||
1 PRIMARY NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE
|
||||
2 SUBQUERY NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table
|
||||
Warnings:
|
||||
Note 1003 select `test`.`t3`.`a` AS `a` from `test`.`t3` where <nop>(<in_optimizer>(NULL,((select min(NULL) from `test`.`t2`) <= NULL)))
|
||||
Note 1003 select `test`.`t3`.`a` AS `a` from `test`.`t3` where 0
|
||||
insert into t2 values (2,2), (2,1), (3,3), (3,1);
|
||||
select * from t3 where a > all (select max(b) from t2 group by a);
|
||||
a
|
||||
|
@ -1771,7 +1768,7 @@ id select_type table type possible_keys key key_len ref rows filtered Extra
|
|||
3 UNION t1 system NULL NULL NULL NULL 1 100.00
|
||||
NULL UNION RESULT <union2,3> ALL NULL NULL NULL NULL NULL NULL
|
||||
Warnings:
|
||||
Note 1003 select 'e' AS `s1` from dual where <nop>(<in_optimizer>('f',(<min>(select 'e' from dual union select 'e' from dual) < 'f')))
|
||||
Note 1003 select 'e' AS `s1` from dual where 1
|
||||
drop table t1;
|
||||
CREATE TABLE t1 (number char(11) NOT NULL default '') ENGINE=MyISAM CHARSET=latin1;
|
||||
INSERT INTO t1 VALUES ('69294728265'),('18621828126'),('89356874041'),('95895001874');
|
||||
|
@ -3105,8 +3102,8 @@ ON r.a = (SELECT t2.a FROM t2 WHERE t2.c = t1.a AND t2.b <= '359899'
|
|||
ORDER BY t2.c DESC, t2.b DESC LIMIT 1) WHERE t1.a = 10;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 PRIMARY t1 system PRIMARY NULL NULL NULL 1
|
||||
1 PRIMARY r eq_ref PRIMARY PRIMARY 4 const 1 Using where
|
||||
2 DEPENDENT SUBQUERY t2 range b b 40 NULL 2 Using where
|
||||
1 PRIMARY r const PRIMARY PRIMARY 4 const 1
|
||||
2 SUBQUERY t2 range b b 40 NULL 2 Using where
|
||||
SELECT sql_no_cache t1.a, r.a, r.b FROM t1 LEFT JOIN t2 r
|
||||
ON r.a = (SELECT t2.a FROM t2 WHERE t2.c = t1.a AND t2.b <= '359899'
|
||||
ORDER BY t2.c DESC, t2.b DESC LIMIT 1) WHERE t1.a = 10;
|
||||
|
@ -3117,8 +3114,8 @@ ON r.a = (SELECT t2.a FROM t2 WHERE t2.c = t1.a AND t2.b <= '359899'
|
|||
ORDER BY t2.c, t2.b LIMIT 1) WHERE t1.a = 10;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 PRIMARY t1 system PRIMARY NULL NULL NULL 1
|
||||
1 PRIMARY r eq_ref PRIMARY PRIMARY 4 const 1 Using where
|
||||
2 DEPENDENT SUBQUERY t2 range b b 40 NULL 2 Using index condition
|
||||
1 PRIMARY r const PRIMARY PRIMARY 4 const 1
|
||||
2 SUBQUERY t2 range b b 40 NULL 2 Using index condition
|
||||
SELECT sql_no_cache t1.a, r.a, r.b FROM t1 LEFT JOIN t2 r
|
||||
ON r.a = (SELECT t2.a FROM t2 WHERE t2.c = t1.a AND t2.b <= '359899'
|
||||
ORDER BY t2.c, t2.b LIMIT 1) WHERE t1.a = 10;
|
||||
|
@ -3169,7 +3166,7 @@ INSERT INTO t2 VALUES (1),(2),(3);
|
|||
EXPLAIN SELECT a, a IN (SELECT a FROM t1) FROM t2;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 PRIMARY t2 ALL NULL NULL NULL NULL 3
|
||||
2 DEPENDENT SUBQUERY t1 index_subquery a a 5 func 2 Using index; Full scan on NULL key
|
||||
2 SUBQUERY t1 index_subquery a a 5 func 2 Using index; Full scan on NULL key
|
||||
SELECT a, a IN (SELECT a FROM t1) FROM t2;
|
||||
a a IN (SELECT a FROM t1)
|
||||
1 1
|
||||
|
@ -3703,7 +3700,7 @@ ORDER BY t1.t DESC LIMIT 1);
|
|||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 PRIMARY t2 system NULL NULL NULL NULL 1
|
||||
1 PRIMARY t1 index NULL PRIMARY 16 NULL 11 Using where; Using index
|
||||
2 DEPENDENT SUBQUERY t1 range PRIMARY PRIMARY 16 NULL 5 Using where; Using index
|
||||
2 SUBQUERY t1 range PRIMARY PRIMARY 16 NULL 5 Using where; Using index
|
||||
SELECT * FROM t1,t2
|
||||
WHERE t1.t = (SELECT t1.t FROM t1
|
||||
WHERE t1.t < t2.t AND t1.i2=1 AND t2.i1=t1.i1
|
||||
|
@ -3730,9 +3727,9 @@ from t1' at line 1
|
|||
explain select * from t1 where not exists
|
||||
((select t11.i from t1 t11) union (select t12.i from t1 t12));
|
||||
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 t11 system NULL NULL NULL NULL 0 const row not found
|
||||
3 UNION t12 system NULL NULL NULL NULL 0 const row not found
|
||||
1 PRIMARY t1 system NULL NULL NULL NULL 0 const row not found
|
||||
2 SUBQUERY NULL NULL NULL NULL NULL NULL NULL no matching row in const table
|
||||
3 UNION NULL NULL NULL NULL NULL NULL NULL no matching row in const table
|
||||
NULL UNION RESULT <union2,3> ALL NULL NULL NULL NULL NULL
|
||||
DROP TABLE t1;
|
||||
CREATE TABLE t1 (a VARCHAR(250), b INT auto_increment, PRIMARY KEY (b));
|
||||
|
@ -4202,8 +4199,8 @@ CREATE TABLE t1 (a int, b int, KEY (a));
|
|||
INSERT INTO t1 VALUES (1,1),(2,1);
|
||||
EXPLAIN SELECT 1 FROM t1 WHERE a = (SELECT COUNT(*) FROM t1 GROUP BY b);
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 PRIMARY t1 ref a a 5 const 0 Using where; Using index
|
||||
2 SUBQUERY t1 ALL NULL NULL NULL NULL 2 Using temporary; Using filesort
|
||||
1 PRIMARY t1 ref a a 5 const 1 Using where; Using index
|
||||
2 SUBQUERY internal_tmp_table ALL group_key NULL NULL NULL 1 Using temporary; Using filesort
|
||||
DROP TABLE t1;
|
||||
CREATE TABLE t1 (id int NOT NULL, st CHAR(2), INDEX idx(id));
|
||||
INSERT INTO t1 VALUES
|
||||
|
@ -4531,13 +4528,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 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 min(`test`.`t1`.`a`) from `test`.`t1` group by `test`.`t1`.`a` having (1 = <ref_null_helper>(min(`test`.`t1`.`a`))))))
|
||||
Note 1003 select 1 AS `1` from `test`.`t1` where 1
|
||||
EXPLAIN EXTENDED SELECT 1 FROM t1 WHERE 1 IN (SELECT min(a) 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
|
||||
1 PRIMARY NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE
|
||||
2 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 min(`test`.`t1`.`a`) from `test`.`t1` where (`test`.`t1`.`a` > 3) group by `test`.`t1`.`a` having (1 = <ref_null_helper>(min(`test`.`t1`.`a`))))))
|
||||
Note 1003 select 1 AS `1` from `test`.`t1` where 0
|
||||
SET join_cache_level=@save_join_cache_level;
|
||||
DROP TABLE t1;
|
||||
#
|
||||
|
@ -4582,7 +4579,7 @@ FROM t1
|
|||
WHERE a = 230;
|
||||
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 DEPENDENT SUBQUERY NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables
|
||||
2 SUBQUERY NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables
|
||||
SELECT MAX(b), (SELECT COUNT(*) FROM st1,st2 WHERE st2.b <= t1.b)
|
||||
FROM t1
|
||||
WHERE a = 230;
|
||||
|
@ -4628,7 +4625,7 @@ 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 SUBQUERY t1 ALL NULL NULL NULL NULL 2 100.00
|
||||
Warnings:
|
||||
Note 1003 select 1 AS `1` from `test`.`t1` where <nop>(<in_optimizer>(1,((select max(`test`.`t1`.`a1`) from `test`.`t1`) > 1)))
|
||||
Note 1003 select 1 AS `1` from `test`.`t1` where 1
|
||||
SELECT 1 FROM t1 WHERE 1 < SOME (SELECT a1 FROM t1);
|
||||
1
|
||||
1
|
||||
|
@ -5970,7 +5967,7 @@ id select_type table type possible_keys key key_len ref rows Extra
|
|||
EXPLAIN SELECT * FROM t1 WHERE EXISTS (SELECT * FROM t1 WHERE a=7);
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 PRIMARY t1 ALL NULL NULL NULL NULL 4
|
||||
2 SUBQUERY t1 ref a a 5 const 1 Using index
|
||||
2 SUBQUERY t1 ref a a 5 const 1
|
||||
DROP TABLE t1;
|
||||
#
|
||||
# BUG#12616253 - WRONG RESULT WITH EXISTS(SUBQUERY) (MISSING ROWS)
|
||||
|
@ -6129,7 +6126,7 @@ set optimizer_switch=@tmp_optimizer_switch;
|
|||
EXPLAIN SELECT * FROM t1 WHERE EXISTS (SELECT * FROM t1 WHERE a=7);
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 PRIMARY t1 ALL NULL NULL NULL NULL 4
|
||||
2 SUBQUERY t1 ref a a 5 const 1 Using index
|
||||
2 SUBQUERY t1 ref a a 5 const 1
|
||||
|
||||
DROP TABLE t1;
|
||||
#
|
||||
|
@ -6541,7 +6538,7 @@ EXPLAIN
|
|||
SELECT COUNT(f1), (SELECT f1 FROM t1 WHERE f2 > 0 limit 1) AS f4 FROM t2, t1 WHERE 'v'= f3;
|
||||
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 DEPENDENT SUBQUERY t1 ALL NULL NULL NULL NULL 2
|
||||
2 SUBQUERY t1 ALL NULL NULL NULL NULL 2
|
||||
SELECT COUNT(f1), (SELECT f1 FROM t1 WHERE f2 > 0 limit 1) AS f4 FROM t2, t1 WHERE 'v'= f3;
|
||||
COUNT(f1) f4
|
||||
0 NULL
|
||||
|
@ -6549,7 +6546,7 @@ EXPLAIN
|
|||
SELECT COUNT(f1), exists(SELECT f1 FROM t1 WHERE f2 > 0 limit 1) AS f4 FROM t2, t1 WHERE 'v'= f3;
|
||||
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 DEPENDENT SUBQUERY t1 ALL NULL NULL NULL NULL 2
|
||||
2 SUBQUERY t1 ALL NULL NULL NULL NULL 2
|
||||
SELECT COUNT(f1), exists(SELECT f1 FROM t1 WHERE f2 > 0 limit 1) AS f4 FROM t2, t1 WHERE 'v'= f3;
|
||||
COUNT(f1) f4
|
||||
0 0
|
||||
|
@ -6588,6 +6585,225 @@ NULL UNION RESULT <union2,3> ALL NULL NULL NULL NULL NULL
|
|||
SELECT SUM(a) AS f1, a AS f2 FROM (t1, t2) HAVING f2 >= ALL (SELECT 4 UNION SELECT 5) AND f1 = 7;
|
||||
f1 f2
|
||||
drop table t1,t2;
|
||||
#
|
||||
# LP BUG#1008686 Server crashes in subselect_union_engine::no_rows on SELECT with impossible
|
||||
# WHERE and UNION in HAVING
|
||||
#
|
||||
CREATE TABLE t1 (a INT);
|
||||
INSERT INTO t1 VALUES (1),(7);
|
||||
EXPLAIN
|
||||
SELECT MIN(a) AS min_a, a FROM t1 WHERE 0 HAVING a NOT IN ( SELECT 2 UNION SELECT 5 ) OR min_a != 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
|
||||
2 DEPENDENT SUBQUERY NULL NULL NULL NULL NULL NULL NULL No tables used
|
||||
3 DEPENDENT UNION NULL NULL NULL NULL NULL NULL NULL No tables used
|
||||
NULL UNION RESULT <union2,3> ALL NULL NULL NULL NULL NULL
|
||||
SELECT MIN(a) AS min_a, a FROM t1 WHERE 0 HAVING a NOT IN ( SELECT 2 UNION SELECT 5 ) OR min_a != 1;
|
||||
min_a a
|
||||
EXPLAIN
|
||||
SELECT MIN(a) AS min_a, a FROM t1 WHERE 1=2 HAVING a NOT IN ( SELECT a from t1 UNION select a+1 from t1 ) OR min_a != 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
|
||||
2 DEPENDENT SUBQUERY t1 ALL NULL NULL NULL NULL 2 Using where
|
||||
3 DEPENDENT UNION t1 ALL NULL NULL NULL NULL 2 Using where
|
||||
NULL UNION RESULT <union2,3> ALL NULL NULL NULL NULL NULL
|
||||
SELECT MIN(a) AS min_a, a FROM t1 WHERE 1=2 HAVING a NOT IN ( SELECT a from t1 UNION select a+1 from t1 ) OR min_a != 1;
|
||||
min_a a
|
||||
drop table t1;
|
||||
#
|
||||
# LP BUG#944706 Query with impossible or constant subquery in WHERE or HAVING is not
|
||||
# precomputed and thus not part of optimization
|
||||
#
|
||||
CREATE TABLE t1 ( a VARCHAR(16), KEY (a) );
|
||||
INSERT INTO t1 VALUES ('Abilene'),('Akron'),('Albany'),('Albuquerque'),('Alexandria'),('Allentown'),
|
||||
('Amarillo'),('Anaheim'),('Anchorage'),('Ann Arbor'),('Arden-Arcade');
|
||||
EXPLAIN
|
||||
SELECT MAX( alias2.a ) AS field
|
||||
FROM t1 AS alias1, t1 AS alias2, t1 AS alias3
|
||||
WHERE alias1.a = alias2.a OR alias1.a = 'y'
|
||||
HAVING field>'B' AND ( 'Moscow' ) IN ( SELECT a FROM t1 );
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 PRIMARY NULL NULL NULL NULL NULL NULL NULL Impossible HAVING
|
||||
2 SUBQUERY t1 index_subquery a a 19 const 1 Using index; Using where
|
||||
SELECT MAX( alias2.a ) AS field
|
||||
FROM t1 AS alias1, t1 AS alias2, t1 AS alias3
|
||||
WHERE alias1.a = alias2.a OR alias1.a = 'y'
|
||||
HAVING field>'B' AND ( 'Moscow' ) IN ( SELECT a FROM t1 );
|
||||
field
|
||||
EXPLAIN
|
||||
SELECT MAX( alias2.a )
|
||||
FROM t1 AS alias1, t1 AS alias2, t1 AS alias3
|
||||
WHERE alias1.a = alias2.a OR ('Moscow') IN ( SELECT a FROM t1 );
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 PRIMARY alias1 index a a 19 NULL 11 Using where; Using index
|
||||
1 PRIMARY alias2 ref a a 19 test.alias1.a 2 Using index
|
||||
1 PRIMARY alias3 index NULL a 19 NULL 11 Using index; Using join buffer (flat, BNL join)
|
||||
2 SUBQUERY t1 index_subquery a a 19 const 1 Using index; Using where
|
||||
SELECT MAX( alias2.a )
|
||||
FROM t1 AS alias1, t1 AS alias2, t1 AS alias3
|
||||
WHERE alias1.a = alias2.a OR ('Moscow') IN ( SELECT a FROM t1 );
|
||||
MAX( alias2.a )
|
||||
Arden-Arcade
|
||||
drop table t1;
|
||||
#
|
||||
# MDEV-277 CHEAP SQ: Server crashes in st_join_table::get_examined_rows
|
||||
# with semijoin+materialization, IN and = subqueries
|
||||
#
|
||||
CREATE TABLE t1 (a1 INT);
|
||||
INSERT INTO t1 VALUES (4),(6);
|
||||
CREATE TABLE t2 (b1 INT);
|
||||
INSERT INTO t2 VALUES (1),(7);
|
||||
EXPLAIN
|
||||
SELECT * FROM t1
|
||||
WHERE a1 = (SELECT COUNT(*) FROM t1 WHERE a1 IN (SELECT a1 FROM t1, 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 t1 ALL NULL NULL NULL NULL 2
|
||||
2 SUBQUERY t1 ALL NULL NULL NULL NULL 2 Using where; Start temporary; Using join buffer (flat, BNL join)
|
||||
2 SUBQUERY t2 ALL NULL NULL NULL NULL 2 End temporary; Using join buffer (flat, BNL join)
|
||||
SELECT * FROM t1
|
||||
WHERE a1 = (SELECT COUNT(*) FROM t1 WHERE a1 IN (SELECT a1 FROM t1, t2));
|
||||
a1
|
||||
drop table t1, t2;
|
||||
#
|
||||
# MDEV-287 CHEAP SQ: A query with subquery in SELECT list, EXISTS,
|
||||
# inner joins takes hundreds times longer
|
||||
#
|
||||
CREATE TABLE t1 (a INT);
|
||||
INSERT INTO t1 VALUES (1),(7);
|
||||
CREATE TABLE t2 (b INT);
|
||||
INSERT INTO t2 VALUES (4),(5);
|
||||
CREATE TABLE t3 (c INT);
|
||||
INSERT INTO t3 VALUES (8),(3);
|
||||
set @@expensive_subquery_limit= 0;
|
||||
EXPLAIN
|
||||
SELECT (SELECT MIN(b) FROM t1, t2 WHERE b = a AND (b = alias1.b OR EXISTS (SELECT * FROM t3)))
|
||||
FROM t2 alias1, t1 alias2, t1 alias3;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 PRIMARY alias1 ALL NULL NULL NULL NULL 2
|
||||
1 PRIMARY alias2 ALL NULL NULL NULL NULL 2 Using join buffer (flat, BNL join)
|
||||
1 PRIMARY alias3 ALL NULL NULL NULL NULL 2 Using join buffer (flat, BNL join)
|
||||
2 DEPENDENT SUBQUERY t1 ALL NULL NULL NULL NULL 2 Using where
|
||||
2 DEPENDENT SUBQUERY t2 ALL NULL NULL NULL NULL 2 Using where; Using join buffer (flat, BNL join)
|
||||
3 SUBQUERY t3 ALL NULL NULL NULL NULL 2
|
||||
flush status;
|
||||
SELECT (SELECT MIN(b) FROM t1, t2 WHERE b = a AND (b = alias1.b OR EXISTS (SELECT * FROM t3)))
|
||||
FROM t2 alias1, t1 alias2, t1 alias3;
|
||||
(SELECT MIN(b) FROM t1, t2 WHERE b = a AND (b = alias1.b OR EXISTS (SELECT * FROM t3)))
|
||||
NULL
|
||||
NULL
|
||||
NULL
|
||||
NULL
|
||||
NULL
|
||||
NULL
|
||||
NULL
|
||||
NULL
|
||||
show status like "subquery_cache%";
|
||||
Variable_name Value
|
||||
Subquery_cache_hit 6
|
||||
Subquery_cache_miss 2
|
||||
show status like '%Handler_read%';
|
||||
Variable_name Value
|
||||
Handler_read_first 0
|
||||
Handler_read_key 8
|
||||
Handler_read_last 0
|
||||
Handler_read_next 0
|
||||
Handler_read_prev 0
|
||||
Handler_read_rnd 0
|
||||
Handler_read_rnd_deleted 0
|
||||
Handler_read_rnd_next 22
|
||||
set @@expensive_subquery_limit= default;
|
||||
EXPLAIN
|
||||
SELECT (SELECT MIN(b) FROM t1, t2 WHERE b = a AND (b = alias1.b OR EXISTS (SELECT * FROM t3)))
|
||||
FROM t2 alias1, t1 alias2, t1 alias3;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 PRIMARY alias1 ALL NULL NULL NULL NULL 2
|
||||
1 PRIMARY alias2 ALL NULL NULL NULL NULL 2 Using join buffer (flat, BNL join)
|
||||
1 PRIMARY alias3 ALL NULL NULL NULL NULL 2 Using join buffer (flat, BNL join)
|
||||
2 SUBQUERY t1 ALL NULL NULL NULL NULL 2
|
||||
2 SUBQUERY t2 ALL NULL NULL NULL NULL 2 Using where; Using join buffer (flat, BNL join)
|
||||
3 SUBQUERY t3 ALL NULL NULL NULL NULL 2
|
||||
flush status;
|
||||
SELECT (SELECT MIN(b) FROM t1, t2 WHERE b = a AND (b = alias1.b OR EXISTS (SELECT * FROM t3)))
|
||||
FROM t2 alias1, t1 alias2, t1 alias3;
|
||||
(SELECT MIN(b) FROM t1, t2 WHERE b = a AND (b = alias1.b OR EXISTS (SELECT * FROM t3)))
|
||||
NULL
|
||||
NULL
|
||||
NULL
|
||||
NULL
|
||||
NULL
|
||||
NULL
|
||||
NULL
|
||||
NULL
|
||||
show status like "subquery_cache%";
|
||||
Variable_name Value
|
||||
Subquery_cache_hit 0
|
||||
Subquery_cache_miss 0
|
||||
show status like '%Handler_read%';
|
||||
Variable_name Value
|
||||
Handler_read_first 0
|
||||
Handler_read_key 0
|
||||
Handler_read_last 0
|
||||
Handler_read_next 0
|
||||
Handler_read_prev 0
|
||||
Handler_read_rnd 0
|
||||
Handler_read_rnd_deleted 0
|
||||
Handler_read_rnd_next 16
|
||||
drop table t1, t2, t3;
|
||||
#
|
||||
# MDEV-288 CHEAP SQ: Valgrind warnings "Memory lost" with IN and EXISTS nested subquery, materialization+semijoin
|
||||
#
|
||||
CREATE TABLE t1 (a INT);
|
||||
INSERT INTO t1 VALUES (0),(8);
|
||||
CREATE TABLE t2 (b INT PRIMARY KEY);
|
||||
INSERT INTO t2 VALUES (1),(2);
|
||||
EXPLAIN
|
||||
SELECT * FROM t1 WHERE 4 IN (SELECT MAX(b) FROM t2 WHERE EXISTS (SELECT * 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 NULL NULL NULL NULL NULL NULL NULL Select tables optimized away
|
||||
3 SUBQUERY t1 ALL NULL NULL NULL NULL 2
|
||||
SELECT * FROM t1 WHERE 4 IN (SELECT MAX(b) FROM t2 WHERE EXISTS (SELECT * FROM t1));
|
||||
a
|
||||
drop table t1,t2;
|
||||
#
|
||||
# MDEV-410: EXPLAIN shows type=range, while SHOW EXPLAIN and userstat show full table scan is used
|
||||
#
|
||||
CREATE TABLE t1 (a VARCHAR(3) PRIMARY KEY) ENGINE=MyISAM;
|
||||
INSERT INTO t1 VALUES ('USA');
|
||||
CREATE TABLE t2 (b INT, c VARCHAR(52), KEY(b)) ENGINE=MyISAM;
|
||||
INSERT INTO t2 VALUES (3813,'United States'),(3940,'Russia');
|
||||
CREATE TABLE t3 (d INT, KEY(d)) ENGINE=MyISAM;
|
||||
INSERT INTO t3 VALUES (12),(22),(9),(45);
|
||||
create table t4 like t3;
|
||||
insert into t4 select * from t3;
|
||||
# This should not show range access for table t2
|
||||
explain
|
||||
SELECT MIN(b) FROM ( SELECT * FROM t1, t2, t3 WHERE d = b ) AS alias1
|
||||
WHERE SLEEP(0.1) OR c < 'p' OR b = ( SELECT MIN(b) FROM t2 );
|
||||
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 ALL b NULL NULL NULL 2 Using where
|
||||
1 PRIMARY t3 ref d d 5 test.t2.b 2 Using where; Using index
|
||||
3 SUBQUERY NULL NULL NULL NULL NULL NULL NULL Select tables optimized away
|
||||
set @tmp_mdev410=@@global.userstat;
|
||||
set global userstat=on;
|
||||
flush table_statistics;
|
||||
flush index_statistics;
|
||||
SELECT MIN(b) FROM ( SELECT * FROM t1, t2, t3 WHERE d = b ) AS alias1
|
||||
WHERE SLEEP(0.1) OR c < 'p' OR b = ( SELECT MIN(b) FROM t2 );
|
||||
MIN(b)
|
||||
NULL
|
||||
# The following shows that t2 was indeed scanned with a full scan.
|
||||
show table_statistics;
|
||||
Table_schema Table_name Rows_read Rows_changed Rows_changed_x_#indexes
|
||||
test t1 2 0 0
|
||||
test t2 3 0 0
|
||||
show index_statistics;
|
||||
Table_schema Table_name Index_name Rows_read
|
||||
test t2 b 1
|
||||
set global userstat=@tmp_mdev410;
|
||||
DROP TABLE t1,t2,t3,t4;
|
||||
# return optimizer switch changed in the beginning of this test
|
||||
set optimizer_switch=@subselect_tmp;
|
||||
set optimizer_switch=default;
|
||||
|
|
|
@ -54,7 +54,7 @@ ERROR 42S22: Reference 'a' not supported (forward reference in item list)
|
|||
EXPLAIN EXTENDED SELECT 1 FROM (SELECT 1 as a) as b HAVING (SELECT a)=1;
|
||||
id select_type table type possible_keys key key_len ref rows filtered Extra
|
||||
1 PRIMARY <derived2> system NULL NULL NULL NULL 1 100.00
|
||||
3 DEPENDENT SUBQUERY NULL NULL NULL NULL NULL NULL NULL NULL No tables used
|
||||
3 SUBQUERY NULL NULL NULL NULL NULL NULL NULL NULL No tables used
|
||||
2 DERIVED NULL NULL NULL NULL NULL NULL NULL NULL No tables used
|
||||
Warnings:
|
||||
Note 1276 Field or reference 'b.a' of SELECT #3 was resolved in SELECT #1
|
||||
|
@ -374,12 +374,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 where; Using index
|
||||
1 PRIMARY t8 const PRIMARY PRIMARY 37 const 1 100.00 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 Using where
|
||||
2 SUBQUERY t8 const PRIMARY PRIMARY 37 const 1 100.00
|
||||
3 SUBQUERY t8 const PRIMARY PRIMARY 37 const 1 100.00 Using index
|
||||
Warnings:
|
||||
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))
|
||||
Note 1003 select 'joce' AS `pseudo`,(select 'test' from `test`.`t8` where 1) AS `(SELECT email FROM t8 WHERE pseudo=(SELECT pseudo FROM t8 WHERE pseudo='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)
|
||||
|
@ -520,6 +520,7 @@ ERROR 21000: Subquery returns more than 1 row
|
|||
show warnings;
|
||||
Level Code Message
|
||||
Error 1242 Subquery returns more than 1 row
|
||||
Error 1028 Sort aborted: Subquery returns more than 1 row
|
||||
drop table t1;
|
||||
create table t1 (a int);
|
||||
insert into t1 values (1),(2),(3);
|
||||
|
@ -550,11 +551,7 @@ 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'))))
|
||||
ERROR 21000: Subquery returns more than 1 row
|
||||
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';
|
||||
|
@ -910,7 +907,7 @@ a t1.a in (select t2.a from t2)
|
|||
explain extended SELECT t1.a, t1.a in (select t2.a from t2) FROM t1;
|
||||
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
|
||||
2 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`
|
||||
CREATE TABLE t3 (a int(11) default '0');
|
||||
|
@ -1611,25 +1608,25 @@ a3 1
|
|||
explain extended select s1, s1 NOT IN (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
|
||||
2 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`
|
||||
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
|
||||
2 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`
|
||||
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
|
||||
2 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`
|
||||
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
|
||||
2 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`
|
||||
drop table t1,t2;
|
||||
|
@ -1678,34 +1675,34 @@ select * from t3 where NULL >= any (select b from t2);
|
|||
a
|
||||
explain extended select * from t3 where NULL >= any (select b from t2);
|
||||
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
|
||||
2 SUBQUERY t2 system NULL NULL NULL NULL 0 0.00 const row not found
|
||||
1 PRIMARY NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE
|
||||
2 SUBQUERY NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table
|
||||
Warnings:
|
||||
Note 1003 select `test`.`t3`.`a` AS `a` from `test`.`t3` where <nop>(<in_optimizer>(NULL,((select min(NULL) from `test`.`t2`) <= NULL)))
|
||||
Note 1003 select `test`.`t3`.`a` AS `a` from `test`.`t3` where 0
|
||||
select * from t3 where NULL >= any (select b from t2 group by 1);
|
||||
a
|
||||
explain extended select * from t3 where NULL >= any (select b from t2 group by 1);
|
||||
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
|
||||
2 SUBQUERY t2 system NULL NULL NULL NULL 0 0.00 const row not found
|
||||
1 PRIMARY NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE
|
||||
2 SUBQUERY NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table
|
||||
Warnings:
|
||||
Note 1003 select `test`.`t3`.`a` AS `a` from `test`.`t3` where <nop>(<in_optimizer>(NULL,((select min(NULL) from `test`.`t2`) <= NULL)))
|
||||
Note 1003 select `test`.`t3`.`a` AS `a` from `test`.`t3` where 0
|
||||
select * from t3 where NULL >= some (select b from t2);
|
||||
a
|
||||
explain extended select * from t3 where NULL >= some (select b from t2);
|
||||
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
|
||||
2 SUBQUERY t2 system NULL NULL NULL NULL 0 0.00 const row not found
|
||||
1 PRIMARY NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE
|
||||
2 SUBQUERY NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table
|
||||
Warnings:
|
||||
Note 1003 select `test`.`t3`.`a` AS `a` from `test`.`t3` where <nop>(<in_optimizer>(NULL,((select min(NULL) from `test`.`t2`) <= NULL)))
|
||||
Note 1003 select `test`.`t3`.`a` AS `a` from `test`.`t3` where 0
|
||||
select * from t3 where NULL >= some (select b from t2 group by 1);
|
||||
a
|
||||
explain extended select * from t3 where NULL >= some (select b from t2 group by 1);
|
||||
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
|
||||
2 SUBQUERY t2 system NULL NULL NULL NULL 0 0.00 const row not found
|
||||
1 PRIMARY NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE
|
||||
2 SUBQUERY NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table
|
||||
Warnings:
|
||||
Note 1003 select `test`.`t3`.`a` AS `a` from `test`.`t3` where <nop>(<in_optimizer>(NULL,((select min(NULL) from `test`.`t2`) <= NULL)))
|
||||
Note 1003 select `test`.`t3`.`a` AS `a` from `test`.`t3` where 0
|
||||
insert into t2 values (2,2), (2,1), (3,3), (3,1);
|
||||
select * from t3 where a > all (select max(b) from t2 group by a);
|
||||
a
|
||||
|
@ -1767,7 +1764,7 @@ id select_type table type possible_keys key key_len ref rows filtered Extra
|
|||
3 UNION t1 system NULL NULL NULL NULL 1 100.00
|
||||
NULL UNION RESULT <union2,3> ALL NULL NULL NULL NULL NULL NULL
|
||||
Warnings:
|
||||
Note 1003 select 'e' AS `s1` from dual where <nop>(<in_optimizer>('f',(<min>(select 'e' from dual union select 'e' from dual) < 'f')))
|
||||
Note 1003 select 'e' AS `s1` from dual where 1
|
||||
drop table t1;
|
||||
CREATE TABLE t1 (number char(11) NOT NULL default '') ENGINE=MyISAM CHARSET=latin1;
|
||||
INSERT INTO t1 VALUES ('69294728265'),('18621828126'),('89356874041'),('95895001874');
|
||||
|
@ -3101,8 +3098,8 @@ ON r.a = (SELECT t2.a FROM t2 WHERE t2.c = t1.a AND t2.b <= '359899'
|
|||
ORDER BY t2.c DESC, t2.b DESC LIMIT 1) WHERE t1.a = 10;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 PRIMARY t1 system PRIMARY NULL NULL NULL 1
|
||||
1 PRIMARY r eq_ref PRIMARY PRIMARY 4 const 1 Using where
|
||||
2 DEPENDENT SUBQUERY t2 range b b 40 NULL 2 Using where
|
||||
1 PRIMARY r const PRIMARY PRIMARY 4 const 1
|
||||
2 SUBQUERY t2 range b b 40 NULL 2 Using where
|
||||
SELECT sql_no_cache t1.a, r.a, r.b FROM t1 LEFT JOIN t2 r
|
||||
ON r.a = (SELECT t2.a FROM t2 WHERE t2.c = t1.a AND t2.b <= '359899'
|
||||
ORDER BY t2.c DESC, t2.b DESC LIMIT 1) WHERE t1.a = 10;
|
||||
|
@ -3113,8 +3110,8 @@ ON r.a = (SELECT t2.a FROM t2 WHERE t2.c = t1.a AND t2.b <= '359899'
|
|||
ORDER BY t2.c, t2.b LIMIT 1) WHERE t1.a = 10;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 PRIMARY t1 system PRIMARY NULL NULL NULL 1
|
||||
1 PRIMARY r eq_ref PRIMARY PRIMARY 4 const 1 Using where
|
||||
2 DEPENDENT SUBQUERY t2 range b b 40 NULL 2 Using index condition
|
||||
1 PRIMARY r const PRIMARY PRIMARY 4 const 1
|
||||
2 SUBQUERY t2 range b b 40 NULL 2 Using index condition
|
||||
SELECT sql_no_cache t1.a, r.a, r.b FROM t1 LEFT JOIN t2 r
|
||||
ON r.a = (SELECT t2.a FROM t2 WHERE t2.c = t1.a AND t2.b <= '359899'
|
||||
ORDER BY t2.c, t2.b LIMIT 1) WHERE t1.a = 10;
|
||||
|
@ -3165,7 +3162,7 @@ INSERT INTO t2 VALUES (1),(2),(3);
|
|||
EXPLAIN SELECT a, a IN (SELECT a FROM t1) FROM t2;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 PRIMARY t2 ALL NULL NULL NULL NULL 3
|
||||
2 DEPENDENT SUBQUERY t1 index_subquery a a 5 func 2 Using index; Full scan on NULL key
|
||||
2 SUBQUERY t1 index_subquery a a 5 func 2 Using index; Full scan on NULL key
|
||||
SELECT a, a IN (SELECT a FROM t1) FROM t2;
|
||||
a a IN (SELECT a FROM t1)
|
||||
1 1
|
||||
|
@ -3699,7 +3696,7 @@ ORDER BY t1.t DESC LIMIT 1);
|
|||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 PRIMARY t2 system NULL NULL NULL NULL 1
|
||||
1 PRIMARY t1 index NULL PRIMARY 16 NULL 11 Using where; Using index
|
||||
2 DEPENDENT SUBQUERY t1 range PRIMARY PRIMARY 16 NULL 5 Using where; Using index
|
||||
2 SUBQUERY t1 range PRIMARY PRIMARY 16 NULL 5 Using where; Using index
|
||||
SELECT * FROM t1,t2
|
||||
WHERE t1.t = (SELECT t1.t FROM t1
|
||||
WHERE t1.t < t2.t AND t1.i2=1 AND t2.i1=t1.i1
|
||||
|
@ -3726,9 +3723,9 @@ from t1' at line 1
|
|||
explain select * from t1 where not exists
|
||||
((select t11.i from t1 t11) union (select t12.i from t1 t12));
|
||||
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 t11 system NULL NULL NULL NULL 0 const row not found
|
||||
3 UNION t12 system NULL NULL NULL NULL 0 const row not found
|
||||
1 PRIMARY t1 system NULL NULL NULL NULL 0 const row not found
|
||||
2 SUBQUERY NULL NULL NULL NULL NULL NULL NULL no matching row in const table
|
||||
3 UNION NULL NULL NULL NULL NULL NULL NULL no matching row in const table
|
||||
NULL UNION RESULT <union2,3> ALL NULL NULL NULL NULL NULL
|
||||
DROP TABLE t1;
|
||||
CREATE TABLE t1 (a VARCHAR(250), b INT auto_increment, PRIMARY KEY (b));
|
||||
|
@ -4198,8 +4195,8 @@ CREATE TABLE t1 (a int, b int, KEY (a));
|
|||
INSERT INTO t1 VALUES (1,1),(2,1);
|
||||
EXPLAIN SELECT 1 FROM t1 WHERE a = (SELECT COUNT(*) FROM t1 GROUP BY b);
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 PRIMARY t1 ref a a 5 const 0 Using where; Using index
|
||||
2 SUBQUERY t1 ALL NULL NULL NULL NULL 2 Using temporary; Using filesort
|
||||
1 PRIMARY t1 ref a a 5 const 1 Using where; Using index
|
||||
2 SUBQUERY internal_tmp_table ALL group_key NULL NULL NULL 1 Using temporary; Using filesort
|
||||
DROP TABLE t1;
|
||||
CREATE TABLE t1 (id int NOT NULL, st CHAR(2), INDEX idx(id));
|
||||
INSERT INTO t1 VALUES
|
||||
|
@ -4527,13 +4524,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 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 min(`test`.`t1`.`a`) from `test`.`t1` group by `test`.`t1`.`a` having (1 = <ref_null_helper>(min(`test`.`t1`.`a`)))))
|
||||
Note 1003 select 1 AS `1` from `test`.`t1` where 1
|
||||
EXPLAIN EXTENDED SELECT 1 FROM t1 WHERE 1 IN (SELECT min(a) 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
|
||||
1 PRIMARY NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE
|
||||
2 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 min(`test`.`t1`.`a`) from `test`.`t1` where (`test`.`t1`.`a` > 3) group by `test`.`t1`.`a` having (1 = <ref_null_helper>(min(`test`.`t1`.`a`)))))
|
||||
Note 1003 select 1 AS `1` from `test`.`t1` where 0
|
||||
SET join_cache_level=@save_join_cache_level;
|
||||
DROP TABLE t1;
|
||||
#
|
||||
|
@ -4578,7 +4575,7 @@ FROM t1
|
|||
WHERE a = 230;
|
||||
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 DEPENDENT SUBQUERY NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables
|
||||
2 SUBQUERY NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables
|
||||
SELECT MAX(b), (SELECT COUNT(*) FROM st1,st2 WHERE st2.b <= t1.b)
|
||||
FROM t1
|
||||
WHERE a = 230;
|
||||
|
@ -4624,7 +4621,7 @@ 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 SUBQUERY t1 ALL NULL NULL NULL NULL 2 100.00
|
||||
Warnings:
|
||||
Note 1003 select 1 AS `1` from `test`.`t1` where <nop>(<in_optimizer>(1,((select max(`test`.`t1`.`a1`) from `test`.`t1`) > 1)))
|
||||
Note 1003 select 1 AS `1` from `test`.`t1` where 1
|
||||
SELECT 1 FROM t1 WHERE 1 < SOME (SELECT a1 FROM t1);
|
||||
1
|
||||
1
|
||||
|
@ -5966,7 +5963,7 @@ id select_type table type possible_keys key key_len ref rows Extra
|
|||
EXPLAIN SELECT * FROM t1 WHERE EXISTS (SELECT * FROM t1 WHERE a=7);
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 PRIMARY t1 ALL NULL NULL NULL NULL 4
|
||||
2 SUBQUERY t1 ref a a 5 const 1 Using index
|
||||
2 SUBQUERY t1 ref a a 5 const 1
|
||||
DROP TABLE t1;
|
||||
#
|
||||
# BUG#12616253 - WRONG RESULT WITH EXISTS(SUBQUERY) (MISSING ROWS)
|
||||
|
@ -6125,7 +6122,7 @@ set optimizer_switch=@tmp_optimizer_switch;
|
|||
EXPLAIN SELECT * FROM t1 WHERE EXISTS (SELECT * FROM t1 WHERE a=7);
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 PRIMARY t1 ALL NULL NULL NULL NULL 4
|
||||
2 SUBQUERY t1 ref a a 5 const 1 Using index
|
||||
2 SUBQUERY t1 ref a a 5 const 1
|
||||
|
||||
DROP TABLE t1;
|
||||
#
|
||||
|
@ -6537,7 +6534,7 @@ EXPLAIN
|
|||
SELECT COUNT(f1), (SELECT f1 FROM t1 WHERE f2 > 0 limit 1) AS f4 FROM t2, t1 WHERE 'v'= f3;
|
||||
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 DEPENDENT SUBQUERY t1 ALL NULL NULL NULL NULL 2
|
||||
2 SUBQUERY t1 ALL NULL NULL NULL NULL 2
|
||||
SELECT COUNT(f1), (SELECT f1 FROM t1 WHERE f2 > 0 limit 1) AS f4 FROM t2, t1 WHERE 'v'= f3;
|
||||
COUNT(f1) f4
|
||||
0 NULL
|
||||
|
@ -6545,7 +6542,7 @@ EXPLAIN
|
|||
SELECT COUNT(f1), exists(SELECT f1 FROM t1 WHERE f2 > 0 limit 1) AS f4 FROM t2, t1 WHERE 'v'= f3;
|
||||
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 DEPENDENT SUBQUERY t1 ALL NULL NULL NULL NULL 2
|
||||
2 SUBQUERY t1 ALL NULL NULL NULL NULL 2
|
||||
SELECT COUNT(f1), exists(SELECT f1 FROM t1 WHERE f2 > 0 limit 1) AS f4 FROM t2, t1 WHERE 'v'= f3;
|
||||
COUNT(f1) f4
|
||||
0 0
|
||||
|
@ -6584,6 +6581,226 @@ NULL UNION RESULT <union2,3> ALL NULL NULL NULL NULL NULL
|
|||
SELECT SUM(a) AS f1, a AS f2 FROM (t1, t2) HAVING f2 >= ALL (SELECT 4 UNION SELECT 5) AND f1 = 7;
|
||||
f1 f2
|
||||
drop table t1,t2;
|
||||
#
|
||||
# LP BUG#1008686 Server crashes in subselect_union_engine::no_rows on SELECT with impossible
|
||||
# WHERE and UNION in HAVING
|
||||
#
|
||||
CREATE TABLE t1 (a INT);
|
||||
INSERT INTO t1 VALUES (1),(7);
|
||||
EXPLAIN
|
||||
SELECT MIN(a) AS min_a, a FROM t1 WHERE 0 HAVING a NOT IN ( SELECT 2 UNION SELECT 5 ) OR min_a != 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
|
||||
2 DEPENDENT SUBQUERY NULL NULL NULL NULL NULL NULL NULL No tables used
|
||||
3 DEPENDENT UNION NULL NULL NULL NULL NULL NULL NULL No tables used
|
||||
NULL UNION RESULT <union2,3> ALL NULL NULL NULL NULL NULL
|
||||
SELECT MIN(a) AS min_a, a FROM t1 WHERE 0 HAVING a NOT IN ( SELECT 2 UNION SELECT 5 ) OR min_a != 1;
|
||||
min_a a
|
||||
EXPLAIN
|
||||
SELECT MIN(a) AS min_a, a FROM t1 WHERE 1=2 HAVING a NOT IN ( SELECT a from t1 UNION select a+1 from t1 ) OR min_a != 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
|
||||
2 DEPENDENT SUBQUERY t1 ALL NULL NULL NULL NULL 2 Using where
|
||||
3 DEPENDENT UNION t1 ALL NULL NULL NULL NULL 2 Using where
|
||||
NULL UNION RESULT <union2,3> ALL NULL NULL NULL NULL NULL
|
||||
SELECT MIN(a) AS min_a, a FROM t1 WHERE 1=2 HAVING a NOT IN ( SELECT a from t1 UNION select a+1 from t1 ) OR min_a != 1;
|
||||
min_a a
|
||||
drop table t1;
|
||||
#
|
||||
# LP BUG#944706 Query with impossible or constant subquery in WHERE or HAVING is not
|
||||
# precomputed and thus not part of optimization
|
||||
#
|
||||
CREATE TABLE t1 ( a VARCHAR(16), KEY (a) );
|
||||
INSERT INTO t1 VALUES ('Abilene'),('Akron'),('Albany'),('Albuquerque'),('Alexandria'),('Allentown'),
|
||||
('Amarillo'),('Anaheim'),('Anchorage'),('Ann Arbor'),('Arden-Arcade');
|
||||
EXPLAIN
|
||||
SELECT MAX( alias2.a ) AS field
|
||||
FROM t1 AS alias1, t1 AS alias2, t1 AS alias3
|
||||
WHERE alias1.a = alias2.a OR alias1.a = 'y'
|
||||
HAVING field>'B' AND ( 'Moscow' ) IN ( SELECT a FROM t1 );
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 PRIMARY NULL NULL NULL NULL NULL NULL NULL Impossible HAVING
|
||||
2 SUBQUERY t1 index_subquery a a 19 const 1 Using index; Using where
|
||||
SELECT MAX( alias2.a ) AS field
|
||||
FROM t1 AS alias1, t1 AS alias2, t1 AS alias3
|
||||
WHERE alias1.a = alias2.a OR alias1.a = 'y'
|
||||
HAVING field>'B' AND ( 'Moscow' ) IN ( SELECT a FROM t1 );
|
||||
field
|
||||
EXPLAIN
|
||||
SELECT MAX( alias2.a )
|
||||
FROM t1 AS alias1, t1 AS alias2, t1 AS alias3
|
||||
WHERE alias1.a = alias2.a OR ('Moscow') IN ( SELECT a FROM t1 );
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 PRIMARY alias1 index a a 19 NULL 11 Using where; Using index
|
||||
1 PRIMARY alias2 ref a a 19 test.alias1.a 2 Using index
|
||||
1 PRIMARY alias3 index NULL a 19 NULL 11 Using index; Using join buffer (flat, BNL join)
|
||||
2 SUBQUERY t1 index_subquery a a 19 const 1 Using index; Using where
|
||||
SELECT MAX( alias2.a )
|
||||
FROM t1 AS alias1, t1 AS alias2, t1 AS alias3
|
||||
WHERE alias1.a = alias2.a OR ('Moscow') IN ( SELECT a FROM t1 );
|
||||
MAX( alias2.a )
|
||||
Arden-Arcade
|
||||
drop table t1;
|
||||
#
|
||||
# MDEV-277 CHEAP SQ: Server crashes in st_join_table::get_examined_rows
|
||||
# with semijoin+materialization, IN and = subqueries
|
||||
#
|
||||
CREATE TABLE t1 (a1 INT);
|
||||
INSERT INTO t1 VALUES (4),(6);
|
||||
CREATE TABLE t2 (b1 INT);
|
||||
INSERT INTO t2 VALUES (1),(7);
|
||||
EXPLAIN
|
||||
SELECT * FROM t1
|
||||
WHERE a1 = (SELECT COUNT(*) FROM t1 WHERE a1 IN (SELECT a1 FROM t1, 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 t1 ALL NULL NULL NULL NULL 2
|
||||
2 SUBQUERY <subquery3> eq_ref distinct_key distinct_key 4 func 1
|
||||
3 MATERIALIZED t1 ALL NULL NULL NULL NULL 2
|
||||
3 MATERIALIZED t2 ALL NULL NULL NULL NULL 2 Using join buffer (flat, BNL join)
|
||||
SELECT * FROM t1
|
||||
WHERE a1 = (SELECT COUNT(*) FROM t1 WHERE a1 IN (SELECT a1 FROM t1, t2));
|
||||
a1
|
||||
drop table t1, t2;
|
||||
#
|
||||
# MDEV-287 CHEAP SQ: A query with subquery in SELECT list, EXISTS,
|
||||
# inner joins takes hundreds times longer
|
||||
#
|
||||
CREATE TABLE t1 (a INT);
|
||||
INSERT INTO t1 VALUES (1),(7);
|
||||
CREATE TABLE t2 (b INT);
|
||||
INSERT INTO t2 VALUES (4),(5);
|
||||
CREATE TABLE t3 (c INT);
|
||||
INSERT INTO t3 VALUES (8),(3);
|
||||
set @@expensive_subquery_limit= 0;
|
||||
EXPLAIN
|
||||
SELECT (SELECT MIN(b) FROM t1, t2 WHERE b = a AND (b = alias1.b OR EXISTS (SELECT * FROM t3)))
|
||||
FROM t2 alias1, t1 alias2, t1 alias3;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 PRIMARY alias1 ALL NULL NULL NULL NULL 2
|
||||
1 PRIMARY alias2 ALL NULL NULL NULL NULL 2 Using join buffer (flat, BNL join)
|
||||
1 PRIMARY alias3 ALL NULL NULL NULL NULL 2 Using join buffer (flat, BNL join)
|
||||
2 DEPENDENT SUBQUERY t1 ALL NULL NULL NULL NULL 2 Using where
|
||||
2 DEPENDENT SUBQUERY t2 ALL NULL NULL NULL NULL 2 Using where; Using join buffer (flat, BNL join)
|
||||
3 SUBQUERY t3 ALL NULL NULL NULL NULL 2
|
||||
flush status;
|
||||
SELECT (SELECT MIN(b) FROM t1, t2 WHERE b = a AND (b = alias1.b OR EXISTS (SELECT * FROM t3)))
|
||||
FROM t2 alias1, t1 alias2, t1 alias3;
|
||||
(SELECT MIN(b) FROM t1, t2 WHERE b = a AND (b = alias1.b OR EXISTS (SELECT * FROM t3)))
|
||||
NULL
|
||||
NULL
|
||||
NULL
|
||||
NULL
|
||||
NULL
|
||||
NULL
|
||||
NULL
|
||||
NULL
|
||||
show status like "subquery_cache%";
|
||||
Variable_name Value
|
||||
Subquery_cache_hit 6
|
||||
Subquery_cache_miss 2
|
||||
show status like '%Handler_read%';
|
||||
Variable_name Value
|
||||
Handler_read_first 0
|
||||
Handler_read_key 8
|
||||
Handler_read_last 0
|
||||
Handler_read_next 0
|
||||
Handler_read_prev 0
|
||||
Handler_read_rnd 0
|
||||
Handler_read_rnd_deleted 0
|
||||
Handler_read_rnd_next 22
|
||||
set @@expensive_subquery_limit= default;
|
||||
EXPLAIN
|
||||
SELECT (SELECT MIN(b) FROM t1, t2 WHERE b = a AND (b = alias1.b OR EXISTS (SELECT * FROM t3)))
|
||||
FROM t2 alias1, t1 alias2, t1 alias3;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 PRIMARY alias1 ALL NULL NULL NULL NULL 2
|
||||
1 PRIMARY alias2 ALL NULL NULL NULL NULL 2 Using join buffer (flat, BNL join)
|
||||
1 PRIMARY alias3 ALL NULL NULL NULL NULL 2 Using join buffer (flat, BNL join)
|
||||
2 SUBQUERY t1 ALL NULL NULL NULL NULL 2
|
||||
2 SUBQUERY t2 ALL NULL NULL NULL NULL 2 Using where; Using join buffer (flat, BNL join)
|
||||
3 SUBQUERY t3 ALL NULL NULL NULL NULL 2
|
||||
flush status;
|
||||
SELECT (SELECT MIN(b) FROM t1, t2 WHERE b = a AND (b = alias1.b OR EXISTS (SELECT * FROM t3)))
|
||||
FROM t2 alias1, t1 alias2, t1 alias3;
|
||||
(SELECT MIN(b) FROM t1, t2 WHERE b = a AND (b = alias1.b OR EXISTS (SELECT * FROM t3)))
|
||||
NULL
|
||||
NULL
|
||||
NULL
|
||||
NULL
|
||||
NULL
|
||||
NULL
|
||||
NULL
|
||||
NULL
|
||||
show status like "subquery_cache%";
|
||||
Variable_name Value
|
||||
Subquery_cache_hit 0
|
||||
Subquery_cache_miss 0
|
||||
show status like '%Handler_read%';
|
||||
Variable_name Value
|
||||
Handler_read_first 0
|
||||
Handler_read_key 0
|
||||
Handler_read_last 0
|
||||
Handler_read_next 0
|
||||
Handler_read_prev 0
|
||||
Handler_read_rnd 0
|
||||
Handler_read_rnd_deleted 0
|
||||
Handler_read_rnd_next 16
|
||||
drop table t1, t2, t3;
|
||||
#
|
||||
# MDEV-288 CHEAP SQ: Valgrind warnings "Memory lost" with IN and EXISTS nested subquery, materialization+semijoin
|
||||
#
|
||||
CREATE TABLE t1 (a INT);
|
||||
INSERT INTO t1 VALUES (0),(8);
|
||||
CREATE TABLE t2 (b INT PRIMARY KEY);
|
||||
INSERT INTO t2 VALUES (1),(2);
|
||||
EXPLAIN
|
||||
SELECT * FROM t1 WHERE 4 IN (SELECT MAX(b) FROM t2 WHERE EXISTS (SELECT * FROM t1));
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 PRIMARY NULL NULL NULL NULL NULL NULL NULL Impossible WHERE
|
||||
2 MATERIALIZED NULL NULL NULL NULL NULL NULL NULL Select tables optimized away
|
||||
3 SUBQUERY t1 ALL NULL NULL NULL NULL 2
|
||||
SELECT * FROM t1 WHERE 4 IN (SELECT MAX(b) FROM t2 WHERE EXISTS (SELECT * FROM t1));
|
||||
a
|
||||
drop table t1,t2;
|
||||
#
|
||||
# MDEV-410: EXPLAIN shows type=range, while SHOW EXPLAIN and userstat show full table scan is used
|
||||
#
|
||||
CREATE TABLE t1 (a VARCHAR(3) PRIMARY KEY) ENGINE=MyISAM;
|
||||
INSERT INTO t1 VALUES ('USA');
|
||||
CREATE TABLE t2 (b INT, c VARCHAR(52), KEY(b)) ENGINE=MyISAM;
|
||||
INSERT INTO t2 VALUES (3813,'United States'),(3940,'Russia');
|
||||
CREATE TABLE t3 (d INT, KEY(d)) ENGINE=MyISAM;
|
||||
INSERT INTO t3 VALUES (12),(22),(9),(45);
|
||||
create table t4 like t3;
|
||||
insert into t4 select * from t3;
|
||||
# This should not show range access for table t2
|
||||
explain
|
||||
SELECT MIN(b) FROM ( SELECT * FROM t1, t2, t3 WHERE d = b ) AS alias1
|
||||
WHERE SLEEP(0.1) OR c < 'p' OR b = ( SELECT MIN(b) FROM t2 );
|
||||
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 ALL b NULL NULL NULL 2 Using where
|
||||
1 PRIMARY t3 ref d d 5 test.t2.b 2 Using where; Using index
|
||||
3 SUBQUERY NULL NULL NULL NULL NULL NULL NULL Select tables optimized away
|
||||
set @tmp_mdev410=@@global.userstat;
|
||||
set global userstat=on;
|
||||
flush table_statistics;
|
||||
flush index_statistics;
|
||||
SELECT MIN(b) FROM ( SELECT * FROM t1, t2, t3 WHERE d = b ) AS alias1
|
||||
WHERE SLEEP(0.1) OR c < 'p' OR b = ( SELECT MIN(b) FROM t2 );
|
||||
MIN(b)
|
||||
NULL
|
||||
# The following shows that t2 was indeed scanned with a full scan.
|
||||
show table_statistics;
|
||||
Table_schema Table_name Rows_read Rows_changed Rows_changed_x_#indexes
|
||||
test t1 2 0 0
|
||||
test t2 3 0 0
|
||||
show index_statistics;
|
||||
Table_schema Table_name Index_name Rows_read
|
||||
test t2 b 1
|
||||
set global userstat=@tmp_mdev410;
|
||||
DROP TABLE t1,t2,t3,t4;
|
||||
# return optimizer switch changed in the beginning of this test
|
||||
set optimizer_switch=@subselect_tmp;
|
||||
set @optimizer_switch_for_subselect_test=null;
|
||||
|
|
|
@ -57,7 +57,7 @@ ERROR 42S22: Reference 'a' not supported (forward reference in item list)
|
|||
EXPLAIN EXTENDED SELECT 1 FROM (SELECT 1 as a) as b HAVING (SELECT a)=1;
|
||||
id select_type table type possible_keys key key_len ref rows filtered Extra
|
||||
1 PRIMARY <derived2> system NULL NULL NULL NULL 1 100.00
|
||||
3 DEPENDENT SUBQUERY NULL NULL NULL NULL NULL NULL NULL NULL No tables used
|
||||
3 SUBQUERY NULL NULL NULL NULL NULL NULL NULL NULL No tables used
|
||||
2 DERIVED NULL NULL NULL NULL NULL NULL NULL NULL No tables used
|
||||
Warnings:
|
||||
Note 1276 Field or reference 'b.a' of SELECT #3 was resolved in SELECT #1
|
||||
|
@ -377,12 +377,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 where; Using index
|
||||
1 PRIMARY t8 const PRIMARY PRIMARY 37 const 1 100.00 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 Using where
|
||||
2 SUBQUERY t8 const PRIMARY PRIMARY 37 const 1 100.00
|
||||
3 SUBQUERY t8 const PRIMARY PRIMARY 37 const 1 100.00 Using index
|
||||
Warnings:
|
||||
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))
|
||||
Note 1003 select 'joce' AS `pseudo`,(select 'test' from `test`.`t8` where 1) AS `(SELECT email FROM t8 WHERE pseudo=(SELECT pseudo FROM t8 WHERE pseudo='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)
|
||||
|
@ -523,6 +523,7 @@ ERROR 21000: Subquery returns more than 1 row
|
|||
show warnings;
|
||||
Level Code Message
|
||||
Error 1242 Subquery returns more than 1 row
|
||||
Error 1028 Sort aborted: Subquery returns more than 1 row
|
||||
drop table t1;
|
||||
create table t1 (a int);
|
||||
insert into t1 values (1),(2),(3);
|
||||
|
@ -553,11 +554,7 @@ 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'))))
|
||||
ERROR 21000: Subquery returns more than 1 row
|
||||
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';
|
||||
|
@ -913,7 +910,7 @@ a t1.a in (select t2.a from t2)
|
|||
explain extended SELECT t1.a, t1.a in (select t2.a from t2) FROM t1;
|
||||
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
|
||||
2 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`
|
||||
CREATE TABLE t3 (a int(11) default '0');
|
||||
|
@ -1614,25 +1611,25 @@ a3 1
|
|||
explain extended select s1, s1 NOT IN (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
|
||||
2 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`
|
||||
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
|
||||
2 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`
|
||||
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
|
||||
2 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`
|
||||
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
|
||||
2 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`
|
||||
drop table t1,t2;
|
||||
|
@ -1681,34 +1678,34 @@ select * from t3 where NULL >= any (select b from t2);
|
|||
a
|
||||
explain extended select * from t3 where NULL >= any (select b from t2);
|
||||
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
|
||||
2 SUBQUERY t2 system NULL NULL NULL NULL 0 0.00 const row not found
|
||||
1 PRIMARY NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE
|
||||
2 SUBQUERY NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table
|
||||
Warnings:
|
||||
Note 1003 select `test`.`t3`.`a` AS `a` from `test`.`t3` where <nop>(<in_optimizer>(NULL,((select min(NULL) from `test`.`t2`) <= NULL)))
|
||||
Note 1003 select `test`.`t3`.`a` AS `a` from `test`.`t3` where 0
|
||||
select * from t3 where NULL >= any (select b from t2 group by 1);
|
||||
a
|
||||
explain extended select * from t3 where NULL >= any (select b from t2 group by 1);
|
||||
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
|
||||
2 SUBQUERY t2 system NULL NULL NULL NULL 0 0.00 const row not found
|
||||
1 PRIMARY NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE
|
||||
2 SUBQUERY NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table
|
||||
Warnings:
|
||||
Note 1003 select `test`.`t3`.`a` AS `a` from `test`.`t3` where <nop>(<in_optimizer>(NULL,((select min(NULL) from `test`.`t2`) <= NULL)))
|
||||
Note 1003 select `test`.`t3`.`a` AS `a` from `test`.`t3` where 0
|
||||
select * from t3 where NULL >= some (select b from t2);
|
||||
a
|
||||
explain extended select * from t3 where NULL >= some (select b from t2);
|
||||
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
|
||||
2 SUBQUERY t2 system NULL NULL NULL NULL 0 0.00 const row not found
|
||||
1 PRIMARY NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE
|
||||
2 SUBQUERY NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table
|
||||
Warnings:
|
||||
Note 1003 select `test`.`t3`.`a` AS `a` from `test`.`t3` where <nop>(<in_optimizer>(NULL,((select min(NULL) from `test`.`t2`) <= NULL)))
|
||||
Note 1003 select `test`.`t3`.`a` AS `a` from `test`.`t3` where 0
|
||||
select * from t3 where NULL >= some (select b from t2 group by 1);
|
||||
a
|
||||
explain extended select * from t3 where NULL >= some (select b from t2 group by 1);
|
||||
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
|
||||
2 SUBQUERY t2 system NULL NULL NULL NULL 0 0.00 const row not found
|
||||
1 PRIMARY NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE
|
||||
2 SUBQUERY NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table
|
||||
Warnings:
|
||||
Note 1003 select `test`.`t3`.`a` AS `a` from `test`.`t3` where <nop>(<in_optimizer>(NULL,((select min(NULL) from `test`.`t2`) <= NULL)))
|
||||
Note 1003 select `test`.`t3`.`a` AS `a` from `test`.`t3` where 0
|
||||
insert into t2 values (2,2), (2,1), (3,3), (3,1);
|
||||
select * from t3 where a > all (select max(b) from t2 group by a);
|
||||
a
|
||||
|
@ -1770,7 +1767,7 @@ id select_type table type possible_keys key key_len ref rows filtered Extra
|
|||
3 UNION t1 system NULL NULL NULL NULL 1 100.00
|
||||
NULL UNION RESULT <union2,3> ALL NULL NULL NULL NULL NULL NULL
|
||||
Warnings:
|
||||
Note 1003 select 'e' AS `s1` from dual where <nop>(<in_optimizer>('f',(<min>(select 'e' from dual union select 'e' from dual) < 'f')))
|
||||
Note 1003 select 'e' AS `s1` from dual where 1
|
||||
drop table t1;
|
||||
CREATE TABLE t1 (number char(11) NOT NULL default '') ENGINE=MyISAM CHARSET=latin1;
|
||||
INSERT INTO t1 VALUES ('69294728265'),('18621828126'),('89356874041'),('95895001874');
|
||||
|
@ -3105,8 +3102,8 @@ ON r.a = (SELECT t2.a FROM t2 WHERE t2.c = t1.a AND t2.b <= '359899'
|
|||
ORDER BY t2.c DESC, t2.b DESC LIMIT 1) WHERE t1.a = 10;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 PRIMARY t1 system PRIMARY NULL NULL NULL 1
|
||||
1 PRIMARY r eq_ref PRIMARY PRIMARY 4 const 1 Using where
|
||||
2 DEPENDENT SUBQUERY t2 range b b 40 NULL 2 Using where
|
||||
1 PRIMARY r const PRIMARY PRIMARY 4 const 1
|
||||
2 SUBQUERY t2 range b b 40 NULL 2 Using where
|
||||
SELECT sql_no_cache t1.a, r.a, r.b FROM t1 LEFT JOIN t2 r
|
||||
ON r.a = (SELECT t2.a FROM t2 WHERE t2.c = t1.a AND t2.b <= '359899'
|
||||
ORDER BY t2.c DESC, t2.b DESC LIMIT 1) WHERE t1.a = 10;
|
||||
|
@ -3117,8 +3114,8 @@ ON r.a = (SELECT t2.a FROM t2 WHERE t2.c = t1.a AND t2.b <= '359899'
|
|||
ORDER BY t2.c, t2.b LIMIT 1) WHERE t1.a = 10;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 PRIMARY t1 system PRIMARY NULL NULL NULL 1
|
||||
1 PRIMARY r eq_ref PRIMARY PRIMARY 4 const 1 Using where
|
||||
2 DEPENDENT SUBQUERY t2 range b b 40 NULL 2 Using index condition
|
||||
1 PRIMARY r const PRIMARY PRIMARY 4 const 1
|
||||
2 SUBQUERY t2 range b b 40 NULL 2 Using index condition
|
||||
SELECT sql_no_cache t1.a, r.a, r.b FROM t1 LEFT JOIN t2 r
|
||||
ON r.a = (SELECT t2.a FROM t2 WHERE t2.c = t1.a AND t2.b <= '359899'
|
||||
ORDER BY t2.c, t2.b LIMIT 1) WHERE t1.a = 10;
|
||||
|
@ -3169,7 +3166,7 @@ INSERT INTO t2 VALUES (1),(2),(3);
|
|||
EXPLAIN SELECT a, a IN (SELECT a FROM t1) FROM t2;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 PRIMARY t2 ALL NULL NULL NULL NULL 3
|
||||
2 DEPENDENT SUBQUERY t1 index_subquery a a 5 func 2 Using index; Full scan on NULL key
|
||||
2 SUBQUERY t1 index_subquery a a 5 func 2 Using index; Full scan on NULL key
|
||||
SELECT a, a IN (SELECT a FROM t1) FROM t2;
|
||||
a a IN (SELECT a FROM t1)
|
||||
1 1
|
||||
|
@ -3705,7 +3702,7 @@ ORDER BY t1.t DESC LIMIT 1);
|
|||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 PRIMARY t2 system NULL NULL NULL NULL 1
|
||||
1 PRIMARY t1 index NULL PRIMARY 16 NULL 11 Using where; Using index
|
||||
2 DEPENDENT SUBQUERY t1 range PRIMARY PRIMARY 16 NULL 5 Using where; Using index
|
||||
2 SUBQUERY t1 range PRIMARY PRIMARY 16 NULL 5 Using where; Using index
|
||||
SELECT * FROM t1,t2
|
||||
WHERE t1.t = (SELECT t1.t FROM t1
|
||||
WHERE t1.t < t2.t AND t1.i2=1 AND t2.i1=t1.i1
|
||||
|
@ -3732,9 +3729,9 @@ from t1' at line 1
|
|||
explain select * from t1 where not exists
|
||||
((select t11.i from t1 t11) union (select t12.i from t1 t12));
|
||||
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 t11 system NULL NULL NULL NULL 0 const row not found
|
||||
3 UNION t12 system NULL NULL NULL NULL 0 const row not found
|
||||
1 PRIMARY t1 system NULL NULL NULL NULL 0 const row not found
|
||||
2 SUBQUERY NULL NULL NULL NULL NULL NULL NULL no matching row in const table
|
||||
3 UNION NULL NULL NULL NULL NULL NULL NULL no matching row in const table
|
||||
NULL UNION RESULT <union2,3> ALL NULL NULL NULL NULL NULL
|
||||
DROP TABLE t1;
|
||||
CREATE TABLE t1 (a VARCHAR(250), b INT auto_increment, PRIMARY KEY (b));
|
||||
|
@ -4204,8 +4201,8 @@ CREATE TABLE t1 (a int, b int, KEY (a));
|
|||
INSERT INTO t1 VALUES (1,1),(2,1);
|
||||
EXPLAIN SELECT 1 FROM t1 WHERE a = (SELECT COUNT(*) FROM t1 GROUP BY b);
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 PRIMARY t1 ref a a 5 const 0 Using where; Using index
|
||||
2 SUBQUERY t1 ALL NULL NULL NULL NULL 2 Using temporary; Using filesort
|
||||
1 PRIMARY t1 ref a a 5 const 1 Using where; Using index
|
||||
2 SUBQUERY internal_tmp_table ALL group_key NULL NULL NULL 1 Using temporary; Using filesort
|
||||
DROP TABLE t1;
|
||||
CREATE TABLE t1 (id int NOT NULL, st CHAR(2), INDEX idx(id));
|
||||
INSERT INTO t1 VALUES
|
||||
|
@ -4586,7 +4583,7 @@ FROM t1
|
|||
WHERE a = 230;
|
||||
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 DEPENDENT SUBQUERY NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables
|
||||
2 SUBQUERY NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables
|
||||
SELECT MAX(b), (SELECT COUNT(*) FROM st1,st2 WHERE st2.b <= t1.b)
|
||||
FROM t1
|
||||
WHERE a = 230;
|
||||
|
@ -4632,7 +4629,7 @@ 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 SUBQUERY t1 ALL NULL NULL NULL NULL 2 100.00
|
||||
Warnings:
|
||||
Note 1003 select 1 AS `1` from `test`.`t1` where <nop>(<in_optimizer>(1,((select max(`test`.`t1`.`a1`) from `test`.`t1`) > 1)))
|
||||
Note 1003 select 1 AS `1` from `test`.`t1` where 1
|
||||
SELECT 1 FROM t1 WHERE 1 < SOME (SELECT a1 FROM t1);
|
||||
1
|
||||
1
|
||||
|
@ -5975,7 +5972,7 @@ id select_type table type possible_keys key key_len ref rows Extra
|
|||
EXPLAIN SELECT * FROM t1 WHERE EXISTS (SELECT * FROM t1 WHERE a=7);
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 PRIMARY t1 ALL NULL NULL NULL NULL 4
|
||||
2 SUBQUERY t1 ref a a 5 const 1 Using index
|
||||
2 SUBQUERY t1 ref a a 5 const 1
|
||||
DROP TABLE t1;
|
||||
#
|
||||
# BUG#12616253 - WRONG RESULT WITH EXISTS(SUBQUERY) (MISSING ROWS)
|
||||
|
@ -6136,7 +6133,7 @@ set optimizer_switch=@tmp_optimizer_switch;
|
|||
EXPLAIN SELECT * FROM t1 WHERE EXISTS (SELECT * FROM t1 WHERE a=7);
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 PRIMARY t1 ALL NULL NULL NULL NULL 4
|
||||
2 SUBQUERY t1 ref a a 5 const 1 Using index
|
||||
2 SUBQUERY t1 ref a a 5 const 1
|
||||
|
||||
DROP TABLE t1;
|
||||
#
|
||||
|
@ -6548,7 +6545,7 @@ EXPLAIN
|
|||
SELECT COUNT(f1), (SELECT f1 FROM t1 WHERE f2 > 0 limit 1) AS f4 FROM t2, t1 WHERE 'v'= f3;
|
||||
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 DEPENDENT SUBQUERY t1 ALL NULL NULL NULL NULL 2
|
||||
2 SUBQUERY t1 ALL NULL NULL NULL NULL 2
|
||||
SELECT COUNT(f1), (SELECT f1 FROM t1 WHERE f2 > 0 limit 1) AS f4 FROM t2, t1 WHERE 'v'= f3;
|
||||
COUNT(f1) f4
|
||||
0 NULL
|
||||
|
@ -6556,7 +6553,7 @@ EXPLAIN
|
|||
SELECT COUNT(f1), exists(SELECT f1 FROM t1 WHERE f2 > 0 limit 1) AS f4 FROM t2, t1 WHERE 'v'= f3;
|
||||
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 DEPENDENT SUBQUERY t1 ALL NULL NULL NULL NULL 2
|
||||
2 SUBQUERY t1 ALL NULL NULL NULL NULL 2
|
||||
SELECT COUNT(f1), exists(SELECT f1 FROM t1 WHERE f2 > 0 limit 1) AS f4 FROM t2, t1 WHERE 'v'= f3;
|
||||
COUNT(f1) f4
|
||||
0 0
|
||||
|
@ -6595,6 +6592,226 @@ NULL UNION RESULT <union2,3> ALL NULL NULL NULL NULL NULL
|
|||
SELECT SUM(a) AS f1, a AS f2 FROM (t1, t2) HAVING f2 >= ALL (SELECT 4 UNION SELECT 5) AND f1 = 7;
|
||||
f1 f2
|
||||
drop table t1,t2;
|
||||
#
|
||||
# LP BUG#1008686 Server crashes in subselect_union_engine::no_rows on SELECT with impossible
|
||||
# WHERE and UNION in HAVING
|
||||
#
|
||||
CREATE TABLE t1 (a INT);
|
||||
INSERT INTO t1 VALUES (1),(7);
|
||||
EXPLAIN
|
||||
SELECT MIN(a) AS min_a, a FROM t1 WHERE 0 HAVING a NOT IN ( SELECT 2 UNION SELECT 5 ) OR min_a != 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
|
||||
2 DEPENDENT SUBQUERY NULL NULL NULL NULL NULL NULL NULL No tables used
|
||||
3 DEPENDENT UNION NULL NULL NULL NULL NULL NULL NULL No tables used
|
||||
NULL UNION RESULT <union2,3> ALL NULL NULL NULL NULL NULL
|
||||
SELECT MIN(a) AS min_a, a FROM t1 WHERE 0 HAVING a NOT IN ( SELECT 2 UNION SELECT 5 ) OR min_a != 1;
|
||||
min_a a
|
||||
EXPLAIN
|
||||
SELECT MIN(a) AS min_a, a FROM t1 WHERE 1=2 HAVING a NOT IN ( SELECT a from t1 UNION select a+1 from t1 ) OR min_a != 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
|
||||
2 DEPENDENT SUBQUERY t1 ALL NULL NULL NULL NULL 2 Using where
|
||||
3 DEPENDENT UNION t1 ALL NULL NULL NULL NULL 2 Using where
|
||||
NULL UNION RESULT <union2,3> ALL NULL NULL NULL NULL NULL
|
||||
SELECT MIN(a) AS min_a, a FROM t1 WHERE 1=2 HAVING a NOT IN ( SELECT a from t1 UNION select a+1 from t1 ) OR min_a != 1;
|
||||
min_a a
|
||||
drop table t1;
|
||||
#
|
||||
# LP BUG#944706 Query with impossible or constant subquery in WHERE or HAVING is not
|
||||
# precomputed and thus not part of optimization
|
||||
#
|
||||
CREATE TABLE t1 ( a VARCHAR(16), KEY (a) );
|
||||
INSERT INTO t1 VALUES ('Abilene'),('Akron'),('Albany'),('Albuquerque'),('Alexandria'),('Allentown'),
|
||||
('Amarillo'),('Anaheim'),('Anchorage'),('Ann Arbor'),('Arden-Arcade');
|
||||
EXPLAIN
|
||||
SELECT MAX( alias2.a ) AS field
|
||||
FROM t1 AS alias1, t1 AS alias2, t1 AS alias3
|
||||
WHERE alias1.a = alias2.a OR alias1.a = 'y'
|
||||
HAVING field>'B' AND ( 'Moscow' ) IN ( SELECT a FROM t1 );
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 PRIMARY NULL NULL NULL NULL NULL NULL NULL Impossible HAVING
|
||||
2 SUBQUERY t1 index_subquery a a 19 const 1 Using index; Using where
|
||||
SELECT MAX( alias2.a ) AS field
|
||||
FROM t1 AS alias1, t1 AS alias2, t1 AS alias3
|
||||
WHERE alias1.a = alias2.a OR alias1.a = 'y'
|
||||
HAVING field>'B' AND ( 'Moscow' ) IN ( SELECT a FROM t1 );
|
||||
field
|
||||
EXPLAIN
|
||||
SELECT MAX( alias2.a )
|
||||
FROM t1 AS alias1, t1 AS alias2, t1 AS alias3
|
||||
WHERE alias1.a = alias2.a OR ('Moscow') IN ( SELECT a FROM t1 );
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 PRIMARY alias1 index a a 19 NULL 11 Using where; Using index
|
||||
1 PRIMARY alias2 ref a a 19 test.alias1.a 2 Using index
|
||||
1 PRIMARY alias3 index NULL a 19 NULL 11 Using index; Using join buffer (flat, BNL join)
|
||||
2 SUBQUERY t1 index_subquery a a 19 const 1 Using index; Using where
|
||||
SELECT MAX( alias2.a )
|
||||
FROM t1 AS alias1, t1 AS alias2, t1 AS alias3
|
||||
WHERE alias1.a = alias2.a OR ('Moscow') IN ( SELECT a FROM t1 );
|
||||
MAX( alias2.a )
|
||||
Arden-Arcade
|
||||
drop table t1;
|
||||
#
|
||||
# MDEV-277 CHEAP SQ: Server crashes in st_join_table::get_examined_rows
|
||||
# with semijoin+materialization, IN and = subqueries
|
||||
#
|
||||
CREATE TABLE t1 (a1 INT);
|
||||
INSERT INTO t1 VALUES (4),(6);
|
||||
CREATE TABLE t2 (b1 INT);
|
||||
INSERT INTO t2 VALUES (1),(7);
|
||||
EXPLAIN
|
||||
SELECT * FROM t1
|
||||
WHERE a1 = (SELECT COUNT(*) FROM t1 WHERE a1 IN (SELECT a1 FROM t1, 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 t1 ALL NULL NULL NULL NULL 2
|
||||
2 SUBQUERY <subquery3> eq_ref distinct_key distinct_key 4 func 1
|
||||
3 MATERIALIZED t1 ALL NULL NULL NULL NULL 2
|
||||
3 MATERIALIZED t2 ALL NULL NULL NULL NULL 2 Using join buffer (flat, BNL join)
|
||||
SELECT * FROM t1
|
||||
WHERE a1 = (SELECT COUNT(*) FROM t1 WHERE a1 IN (SELECT a1 FROM t1, t2));
|
||||
a1
|
||||
drop table t1, t2;
|
||||
#
|
||||
# MDEV-287 CHEAP SQ: A query with subquery in SELECT list, EXISTS,
|
||||
# inner joins takes hundreds times longer
|
||||
#
|
||||
CREATE TABLE t1 (a INT);
|
||||
INSERT INTO t1 VALUES (1),(7);
|
||||
CREATE TABLE t2 (b INT);
|
||||
INSERT INTO t2 VALUES (4),(5);
|
||||
CREATE TABLE t3 (c INT);
|
||||
INSERT INTO t3 VALUES (8),(3);
|
||||
set @@expensive_subquery_limit= 0;
|
||||
EXPLAIN
|
||||
SELECT (SELECT MIN(b) FROM t1, t2 WHERE b = a AND (b = alias1.b OR EXISTS (SELECT * FROM t3)))
|
||||
FROM t2 alias1, t1 alias2, t1 alias3;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 PRIMARY alias1 ALL NULL NULL NULL NULL 2
|
||||
1 PRIMARY alias2 ALL NULL NULL NULL NULL 2 Using join buffer (flat, BNL join)
|
||||
1 PRIMARY alias3 ALL NULL NULL NULL NULL 2 Using join buffer (flat, BNL join)
|
||||
2 DEPENDENT SUBQUERY t1 ALL NULL NULL NULL NULL 2 Using where
|
||||
2 DEPENDENT SUBQUERY t2 ALL NULL NULL NULL NULL 2 Using where; Using join buffer (flat, BNL join)
|
||||
3 SUBQUERY t3 ALL NULL NULL NULL NULL 2
|
||||
flush status;
|
||||
SELECT (SELECT MIN(b) FROM t1, t2 WHERE b = a AND (b = alias1.b OR EXISTS (SELECT * FROM t3)))
|
||||
FROM t2 alias1, t1 alias2, t1 alias3;
|
||||
(SELECT MIN(b) FROM t1, t2 WHERE b = a AND (b = alias1.b OR EXISTS (SELECT * FROM t3)))
|
||||
NULL
|
||||
NULL
|
||||
NULL
|
||||
NULL
|
||||
NULL
|
||||
NULL
|
||||
NULL
|
||||
NULL
|
||||
show status like "subquery_cache%";
|
||||
Variable_name Value
|
||||
Subquery_cache_hit 0
|
||||
Subquery_cache_miss 0
|
||||
show status like '%Handler_read%';
|
||||
Variable_name Value
|
||||
Handler_read_first 0
|
||||
Handler_read_key 0
|
||||
Handler_read_last 0
|
||||
Handler_read_next 0
|
||||
Handler_read_prev 0
|
||||
Handler_read_rnd 0
|
||||
Handler_read_rnd_deleted 0
|
||||
Handler_read_rnd_next 58
|
||||
set @@expensive_subquery_limit= default;
|
||||
EXPLAIN
|
||||
SELECT (SELECT MIN(b) FROM t1, t2 WHERE b = a AND (b = alias1.b OR EXISTS (SELECT * FROM t3)))
|
||||
FROM t2 alias1, t1 alias2, t1 alias3;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 PRIMARY alias1 ALL NULL NULL NULL NULL 2
|
||||
1 PRIMARY alias2 ALL NULL NULL NULL NULL 2 Using join buffer (flat, BNL join)
|
||||
1 PRIMARY alias3 ALL NULL NULL NULL NULL 2 Using join buffer (flat, BNL join)
|
||||
2 SUBQUERY t1 ALL NULL NULL NULL NULL 2
|
||||
2 SUBQUERY t2 ALL NULL NULL NULL NULL 2 Using where; Using join buffer (flat, BNL join)
|
||||
3 SUBQUERY t3 ALL NULL NULL NULL NULL 2
|
||||
flush status;
|
||||
SELECT (SELECT MIN(b) FROM t1, t2 WHERE b = a AND (b = alias1.b OR EXISTS (SELECT * FROM t3)))
|
||||
FROM t2 alias1, t1 alias2, t1 alias3;
|
||||
(SELECT MIN(b) FROM t1, t2 WHERE b = a AND (b = alias1.b OR EXISTS (SELECT * FROM t3)))
|
||||
NULL
|
||||
NULL
|
||||
NULL
|
||||
NULL
|
||||
NULL
|
||||
NULL
|
||||
NULL
|
||||
NULL
|
||||
show status like "subquery_cache%";
|
||||
Variable_name Value
|
||||
Subquery_cache_hit 0
|
||||
Subquery_cache_miss 0
|
||||
show status like '%Handler_read%';
|
||||
Variable_name Value
|
||||
Handler_read_first 0
|
||||
Handler_read_key 0
|
||||
Handler_read_last 0
|
||||
Handler_read_next 0
|
||||
Handler_read_prev 0
|
||||
Handler_read_rnd 0
|
||||
Handler_read_rnd_deleted 0
|
||||
Handler_read_rnd_next 16
|
||||
drop table t1, t2, t3;
|
||||
#
|
||||
# MDEV-288 CHEAP SQ: Valgrind warnings "Memory lost" with IN and EXISTS nested subquery, materialization+semijoin
|
||||
#
|
||||
CREATE TABLE t1 (a INT);
|
||||
INSERT INTO t1 VALUES (0),(8);
|
||||
CREATE TABLE t2 (b INT PRIMARY KEY);
|
||||
INSERT INTO t2 VALUES (1),(2);
|
||||
EXPLAIN
|
||||
SELECT * FROM t1 WHERE 4 IN (SELECT MAX(b) FROM t2 WHERE EXISTS (SELECT * FROM t1));
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 PRIMARY NULL NULL NULL NULL NULL NULL NULL Impossible WHERE
|
||||
2 MATERIALIZED NULL NULL NULL NULL NULL NULL NULL Select tables optimized away
|
||||
3 SUBQUERY t1 ALL NULL NULL NULL NULL 2
|
||||
SELECT * FROM t1 WHERE 4 IN (SELECT MAX(b) FROM t2 WHERE EXISTS (SELECT * FROM t1));
|
||||
a
|
||||
drop table t1,t2;
|
||||
#
|
||||
# MDEV-410: EXPLAIN shows type=range, while SHOW EXPLAIN and userstat show full table scan is used
|
||||
#
|
||||
CREATE TABLE t1 (a VARCHAR(3) PRIMARY KEY) ENGINE=MyISAM;
|
||||
INSERT INTO t1 VALUES ('USA');
|
||||
CREATE TABLE t2 (b INT, c VARCHAR(52), KEY(b)) ENGINE=MyISAM;
|
||||
INSERT INTO t2 VALUES (3813,'United States'),(3940,'Russia');
|
||||
CREATE TABLE t3 (d INT, KEY(d)) ENGINE=MyISAM;
|
||||
INSERT INTO t3 VALUES (12),(22),(9),(45);
|
||||
create table t4 like t3;
|
||||
insert into t4 select * from t3;
|
||||
# This should not show range access for table t2
|
||||
explain
|
||||
SELECT MIN(b) FROM ( SELECT * FROM t1, t2, t3 WHERE d = b ) AS alias1
|
||||
WHERE SLEEP(0.1) OR c < 'p' OR b = ( SELECT MIN(b) FROM t2 );
|
||||
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 ALL b NULL NULL NULL 2 Using where
|
||||
1 PRIMARY t3 ref d d 5 test.t2.b 2 Using where; Using index
|
||||
3 SUBQUERY NULL NULL NULL NULL NULL NULL NULL Select tables optimized away
|
||||
set @tmp_mdev410=@@global.userstat;
|
||||
set global userstat=on;
|
||||
flush table_statistics;
|
||||
flush index_statistics;
|
||||
SELECT MIN(b) FROM ( SELECT * FROM t1, t2, t3 WHERE d = b ) AS alias1
|
||||
WHERE SLEEP(0.1) OR c < 'p' OR b = ( SELECT MIN(b) FROM t2 );
|
||||
MIN(b)
|
||||
NULL
|
||||
# The following shows that t2 was indeed scanned with a full scan.
|
||||
show table_statistics;
|
||||
Table_schema Table_name Rows_read Rows_changed Rows_changed_x_#indexes
|
||||
test t1 2 0 0
|
||||
test t2 3 0 0
|
||||
show index_statistics;
|
||||
Table_schema Table_name Index_name Rows_read
|
||||
test t2 b 1
|
||||
set global userstat=@tmp_mdev410;
|
||||
DROP TABLE t1,t2,t3,t4;
|
||||
# return optimizer switch changed in the beginning of this test
|
||||
set optimizer_switch=@subselect_tmp;
|
||||
set optimizer_switch=default;
|
||||
|
|
|
@ -54,12 +54,12 @@ ERROR 42S22: Reference 'a' not supported (forward reference in item list)
|
|||
EXPLAIN EXTENDED SELECT 1 FROM (SELECT 1 as a) as b HAVING (SELECT a)=1;
|
||||
id select_type table type possible_keys key key_len ref rows filtered Extra
|
||||
1 PRIMARY <derived2> system NULL NULL NULL NULL 1 100.00
|
||||
3 DEPENDENT SUBQUERY NULL NULL NULL NULL NULL NULL NULL NULL No tables used
|
||||
3 SUBQUERY NULL NULL NULL NULL NULL NULL NULL NULL No tables used
|
||||
2 DERIVED NULL NULL NULL NULL NULL NULL NULL NULL No tables used
|
||||
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
|
||||
|
@ -374,12 +374,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 where; Using index
|
||||
1 PRIMARY t8 const PRIMARY PRIMARY 37 const 1 100.00 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 Using where
|
||||
2 SUBQUERY t8 const PRIMARY PRIMARY 37 const 1 100.00
|
||||
3 SUBQUERY t8 const PRIMARY PRIMARY 37 const 1 100.00 Using index
|
||||
Warnings:
|
||||
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))
|
||||
Note 1003 select 'joce' AS `pseudo`,(select 'test' from `test`.`t8` where 1) AS `(SELECT email FROM t8 WHERE pseudo=(SELECT pseudo FROM t8 WHERE pseudo='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)
|
||||
|
@ -520,6 +520,7 @@ ERROR 21000: Subquery returns more than 1 row
|
|||
show warnings;
|
||||
Level Code Message
|
||||
Error 1242 Subquery returns more than 1 row
|
||||
Error 1028 Sort aborted: Subquery returns more than 1 row
|
||||
drop table t1;
|
||||
create table t1 (a int);
|
||||
insert into t1 values (1),(2),(3);
|
||||
|
@ -550,11 +551,7 @@ 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'))))
|
||||
ERROR 21000: Subquery returns more than 1 row
|
||||
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';
|
||||
|
@ -1678,34 +1675,34 @@ select * from t3 where NULL >= any (select b from t2);
|
|||
a
|
||||
explain extended select * from t3 where NULL >= any (select b from t2);
|
||||
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
|
||||
2 SUBQUERY t2 system NULL NULL NULL NULL 0 0.00 const row not found
|
||||
1 PRIMARY NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE
|
||||
2 SUBQUERY NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table
|
||||
Warnings:
|
||||
Note 1003 select `test`.`t3`.`a` AS `a` from `test`.`t3` where <nop>(<in_optimizer>(NULL,((select min(NULL) from `test`.`t2`) <= NULL)))
|
||||
Note 1003 select `test`.`t3`.`a` AS `a` from `test`.`t3` where 0
|
||||
select * from t3 where NULL >= any (select b from t2 group by 1);
|
||||
a
|
||||
explain extended select * from t3 where NULL >= any (select b from t2 group by 1);
|
||||
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
|
||||
2 SUBQUERY t2 system NULL NULL NULL NULL 0 0.00 const row not found
|
||||
1 PRIMARY NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE
|
||||
2 SUBQUERY NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table
|
||||
Warnings:
|
||||
Note 1003 select `test`.`t3`.`a` AS `a` from `test`.`t3` where <nop>(<in_optimizer>(NULL,((select min(NULL) from `test`.`t2`) <= NULL)))
|
||||
Note 1003 select `test`.`t3`.`a` AS `a` from `test`.`t3` where 0
|
||||
select * from t3 where NULL >= some (select b from t2);
|
||||
a
|
||||
explain extended select * from t3 where NULL >= some (select b from t2);
|
||||
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
|
||||
2 SUBQUERY t2 system NULL NULL NULL NULL 0 0.00 const row not found
|
||||
1 PRIMARY NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE
|
||||
2 SUBQUERY NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table
|
||||
Warnings:
|
||||
Note 1003 select `test`.`t3`.`a` AS `a` from `test`.`t3` where <nop>(<in_optimizer>(NULL,((select min(NULL) from `test`.`t2`) <= NULL)))
|
||||
Note 1003 select `test`.`t3`.`a` AS `a` from `test`.`t3` where 0
|
||||
select * from t3 where NULL >= some (select b from t2 group by 1);
|
||||
a
|
||||
explain extended select * from t3 where NULL >= some (select b from t2 group by 1);
|
||||
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
|
||||
2 SUBQUERY t2 system NULL NULL NULL NULL 0 0.00 const row not found
|
||||
1 PRIMARY NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE
|
||||
2 SUBQUERY NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table
|
||||
Warnings:
|
||||
Note 1003 select `test`.`t3`.`a` AS `a` from `test`.`t3` where <nop>(<in_optimizer>(NULL,((select min(NULL) from `test`.`t2`) <= NULL)))
|
||||
Note 1003 select `test`.`t3`.`a` AS `a` from `test`.`t3` where 0
|
||||
insert into t2 values (2,2), (2,1), (3,3), (3,1);
|
||||
select * from t3 where a > all (select max(b) from t2 group by a);
|
||||
a
|
||||
|
@ -1767,7 +1764,7 @@ id select_type table type possible_keys key key_len ref rows filtered Extra
|
|||
3 UNION t1 system NULL NULL NULL NULL 1 100.00
|
||||
NULL UNION RESULT <union2,3> ALL NULL NULL NULL NULL NULL NULL
|
||||
Warnings:
|
||||
Note 1003 select 'e' AS `s1` from dual where <nop>(<in_optimizer>('f',(<min>(select 'e' from dual union select 'e' from dual) < 'f')))
|
||||
Note 1003 select 'e' AS `s1` from dual where 1
|
||||
drop table t1;
|
||||
CREATE TABLE t1 (number char(11) NOT NULL default '') ENGINE=MyISAM CHARSET=latin1;
|
||||
INSERT INTO t1 VALUES ('69294728265'),('18621828126'),('89356874041'),('95895001874');
|
||||
|
@ -3101,8 +3098,8 @@ ON r.a = (SELECT t2.a FROM t2 WHERE t2.c = t1.a AND t2.b <= '359899'
|
|||
ORDER BY t2.c DESC, t2.b DESC LIMIT 1) WHERE t1.a = 10;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 PRIMARY t1 system PRIMARY NULL NULL NULL 1
|
||||
1 PRIMARY r eq_ref PRIMARY PRIMARY 4 const 1 Using where
|
||||
2 DEPENDENT SUBQUERY t2 range b b 40 NULL 2 Using where
|
||||
1 PRIMARY r const PRIMARY PRIMARY 4 const 1
|
||||
2 SUBQUERY t2 range b b 40 NULL 2 Using where
|
||||
SELECT sql_no_cache t1.a, r.a, r.b FROM t1 LEFT JOIN t2 r
|
||||
ON r.a = (SELECT t2.a FROM t2 WHERE t2.c = t1.a AND t2.b <= '359899'
|
||||
ORDER BY t2.c DESC, t2.b DESC LIMIT 1) WHERE t1.a = 10;
|
||||
|
@ -3113,8 +3110,8 @@ ON r.a = (SELECT t2.a FROM t2 WHERE t2.c = t1.a AND t2.b <= '359899'
|
|||
ORDER BY t2.c, t2.b LIMIT 1) WHERE t1.a = 10;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 PRIMARY t1 system PRIMARY NULL NULL NULL 1
|
||||
1 PRIMARY r eq_ref PRIMARY PRIMARY 4 const 1 Using where
|
||||
2 DEPENDENT SUBQUERY t2 range b b 40 NULL 2 Using index condition
|
||||
1 PRIMARY r const PRIMARY PRIMARY 4 const 1
|
||||
2 SUBQUERY t2 range b b 40 NULL 2 Using index condition
|
||||
SELECT sql_no_cache t1.a, r.a, r.b FROM t1 LEFT JOIN t2 r
|
||||
ON r.a = (SELECT t2.a FROM t2 WHERE t2.c = t1.a AND t2.b <= '359899'
|
||||
ORDER BY t2.c, t2.b LIMIT 1) WHERE t1.a = 10;
|
||||
|
@ -3699,7 +3696,7 @@ ORDER BY t1.t DESC LIMIT 1);
|
|||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 PRIMARY t2 system NULL NULL NULL NULL 1
|
||||
1 PRIMARY t1 index NULL PRIMARY 16 NULL 11 Using where; Using index
|
||||
2 DEPENDENT SUBQUERY t1 range PRIMARY PRIMARY 16 NULL 5 Using where; Using index
|
||||
2 SUBQUERY t1 range PRIMARY PRIMARY 16 NULL 5 Using where; Using index
|
||||
SELECT * FROM t1,t2
|
||||
WHERE t1.t = (SELECT t1.t FROM t1
|
||||
WHERE t1.t < t2.t AND t1.i2=1 AND t2.i1=t1.i1
|
||||
|
@ -3726,9 +3723,9 @@ from t1' at line 1
|
|||
explain select * from t1 where not exists
|
||||
((select t11.i from t1 t11) union (select t12.i from t1 t12));
|
||||
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 t11 system NULL NULL NULL NULL 0 const row not found
|
||||
3 UNION t12 system NULL NULL NULL NULL 0 const row not found
|
||||
1 PRIMARY t1 system NULL NULL NULL NULL 0 const row not found
|
||||
2 SUBQUERY NULL NULL NULL NULL NULL NULL NULL no matching row in const table
|
||||
3 UNION NULL NULL NULL NULL NULL NULL NULL no matching row in const table
|
||||
NULL UNION RESULT <union2,3> ALL NULL NULL NULL NULL NULL
|
||||
DROP TABLE t1;
|
||||
CREATE TABLE t1 (a VARCHAR(250), b INT auto_increment, PRIMARY KEY (b));
|
||||
|
@ -4198,8 +4195,8 @@ CREATE TABLE t1 (a int, b int, KEY (a));
|
|||
INSERT INTO t1 VALUES (1,1),(2,1);
|
||||
EXPLAIN SELECT 1 FROM t1 WHERE a = (SELECT COUNT(*) FROM t1 GROUP BY b);
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 PRIMARY t1 ref a a 5 const 0 Using where; Using index
|
||||
2 SUBQUERY t1 ALL NULL NULL NULL NULL 2 Using temporary; Using filesort
|
||||
1 PRIMARY t1 ref a a 5 const 1 Using where; Using index
|
||||
2 SUBQUERY internal_tmp_table ALL group_key NULL NULL NULL 1 Using temporary; Using filesort
|
||||
DROP TABLE t1;
|
||||
CREATE TABLE t1 (id int NOT NULL, st CHAR(2), INDEX idx(id));
|
||||
INSERT INTO t1 VALUES
|
||||
|
@ -4525,15 +4522,15 @@ SET join_cache_level=0;
|
|||
EXPLAIN EXTENDED SELECT 1 FROM t1 WHERE 1 IN (SELECT min(a) FROM t1 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 MATERIALIZED t1 ALL NULL NULL NULL NULL 2 100.00 Using temporary
|
||||
2 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,1 in ( <materialize> (select min(`test`.`t1`.`a`) from `test`.`t1` group by `test`.`t1`.`a` ), <primary_index_lookup>(1 in <temporary table> on distinct_key where ((1 = `<subquery2>`.`min(a)`))))))
|
||||
Note 1003 select 1 AS `1` from `test`.`t1` where 1
|
||||
EXPLAIN EXTENDED SELECT 1 FROM t1 WHERE 1 IN (SELECT min(a) 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 MATERIALIZED t1 ALL NULL NULL NULL NULL 2 100.00 Using where; Using temporary
|
||||
1 PRIMARY NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE
|
||||
2 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,1 in ( <materialize> (select min(`test`.`t1`.`a`) from `test`.`t1` where (`test`.`t1`.`a` > 3) group by `test`.`t1`.`a` ), <primary_index_lookup>(1 in <temporary table> on distinct_key where ((1 = `<subquery2>`.`min(a)`))))))
|
||||
Note 1003 select 1 AS `1` from `test`.`t1` where 0
|
||||
SET join_cache_level=@save_join_cache_level;
|
||||
DROP TABLE t1;
|
||||
#
|
||||
|
@ -4578,7 +4575,7 @@ FROM t1
|
|||
WHERE a = 230;
|
||||
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 DEPENDENT SUBQUERY NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables
|
||||
2 SUBQUERY NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables
|
||||
SELECT MAX(b), (SELECT COUNT(*) FROM st1,st2 WHERE st2.b <= t1.b)
|
||||
FROM t1
|
||||
WHERE a = 230;
|
||||
|
@ -4624,7 +4621,7 @@ 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 SUBQUERY t1 ALL NULL NULL NULL NULL 2 100.00
|
||||
Warnings:
|
||||
Note 1003 select 1 AS `1` from `test`.`t1` where <nop>(<in_optimizer>(1,((select max(`test`.`t1`.`a1`) from `test`.`t1`) > 1)))
|
||||
Note 1003 select 1 AS `1` from `test`.`t1` where 1
|
||||
SELECT 1 FROM t1 WHERE 1 < SOME (SELECT a1 FROM t1);
|
||||
1
|
||||
1
|
||||
|
@ -5966,7 +5963,7 @@ id select_type table type possible_keys key key_len ref rows Extra
|
|||
EXPLAIN SELECT * FROM t1 WHERE EXISTS (SELECT * FROM t1 WHERE a=7);
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 PRIMARY t1 ALL NULL NULL NULL NULL 4
|
||||
2 SUBQUERY t1 ref a a 5 const 1 Using index
|
||||
2 SUBQUERY t1 ref a a 5 const 1
|
||||
DROP TABLE t1;
|
||||
#
|
||||
# BUG#12616253 - WRONG RESULT WITH EXISTS(SUBQUERY) (MISSING ROWS)
|
||||
|
@ -6125,7 +6122,7 @@ set optimizer_switch=@tmp_optimizer_switch;
|
|||
EXPLAIN SELECT * FROM t1 WHERE EXISTS (SELECT * FROM t1 WHERE a=7);
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 PRIMARY t1 ALL NULL NULL NULL NULL 4
|
||||
2 SUBQUERY t1 ref a a 5 const 1 Using index
|
||||
2 SUBQUERY t1 ref a a 5 const 1
|
||||
|
||||
DROP TABLE t1;
|
||||
#
|
||||
|
@ -6537,7 +6534,7 @@ EXPLAIN
|
|||
SELECT COUNT(f1), (SELECT f1 FROM t1 WHERE f2 > 0 limit 1) AS f4 FROM t2, t1 WHERE 'v'= f3;
|
||||
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 DEPENDENT SUBQUERY t1 ALL NULL NULL NULL NULL 2
|
||||
2 SUBQUERY t1 ALL NULL NULL NULL NULL 2
|
||||
SELECT COUNT(f1), (SELECT f1 FROM t1 WHERE f2 > 0 limit 1) AS f4 FROM t2, t1 WHERE 'v'= f3;
|
||||
COUNT(f1) f4
|
||||
0 NULL
|
||||
|
@ -6545,7 +6542,7 @@ EXPLAIN
|
|||
SELECT COUNT(f1), exists(SELECT f1 FROM t1 WHERE f2 > 0 limit 1) AS f4 FROM t2, t1 WHERE 'v'= f3;
|
||||
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 DEPENDENT SUBQUERY t1 ALL NULL NULL NULL NULL 2
|
||||
2 SUBQUERY t1 ALL NULL NULL NULL NULL 2
|
||||
SELECT COUNT(f1), exists(SELECT f1 FROM t1 WHERE f2 > 0 limit 1) AS f4 FROM t2, t1 WHERE 'v'= f3;
|
||||
COUNT(f1) f4
|
||||
0 0
|
||||
|
@ -6584,6 +6581,226 @@ NULL UNION RESULT <union2,3> ALL NULL NULL NULL NULL NULL
|
|||
SELECT SUM(a) AS f1, a AS f2 FROM (t1, t2) HAVING f2 >= ALL (SELECT 4 UNION SELECT 5) AND f1 = 7;
|
||||
f1 f2
|
||||
drop table t1,t2;
|
||||
#
|
||||
# LP BUG#1008686 Server crashes in subselect_union_engine::no_rows on SELECT with impossible
|
||||
# WHERE and UNION in HAVING
|
||||
#
|
||||
CREATE TABLE t1 (a INT);
|
||||
INSERT INTO t1 VALUES (1),(7);
|
||||
EXPLAIN
|
||||
SELECT MIN(a) AS min_a, a FROM t1 WHERE 0 HAVING a NOT IN ( SELECT 2 UNION SELECT 5 ) OR min_a != 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
|
||||
2 DEPENDENT SUBQUERY NULL NULL NULL NULL NULL NULL NULL No tables used
|
||||
3 DEPENDENT UNION NULL NULL NULL NULL NULL NULL NULL No tables used
|
||||
NULL UNION RESULT <union2,3> ALL NULL NULL NULL NULL NULL
|
||||
SELECT MIN(a) AS min_a, a FROM t1 WHERE 0 HAVING a NOT IN ( SELECT 2 UNION SELECT 5 ) OR min_a != 1;
|
||||
min_a a
|
||||
EXPLAIN
|
||||
SELECT MIN(a) AS min_a, a FROM t1 WHERE 1=2 HAVING a NOT IN ( SELECT a from t1 UNION select a+1 from t1 ) OR min_a != 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
|
||||
2 DEPENDENT SUBQUERY t1 ALL NULL NULL NULL NULL 2 Using where
|
||||
3 DEPENDENT UNION t1 ALL NULL NULL NULL NULL 2 Using where
|
||||
NULL UNION RESULT <union2,3> ALL NULL NULL NULL NULL NULL
|
||||
SELECT MIN(a) AS min_a, a FROM t1 WHERE 1=2 HAVING a NOT IN ( SELECT a from t1 UNION select a+1 from t1 ) OR min_a != 1;
|
||||
min_a a
|
||||
drop table t1;
|
||||
#
|
||||
# LP BUG#944706 Query with impossible or constant subquery in WHERE or HAVING is not
|
||||
# precomputed and thus not part of optimization
|
||||
#
|
||||
CREATE TABLE t1 ( a VARCHAR(16), KEY (a) );
|
||||
INSERT INTO t1 VALUES ('Abilene'),('Akron'),('Albany'),('Albuquerque'),('Alexandria'),('Allentown'),
|
||||
('Amarillo'),('Anaheim'),('Anchorage'),('Ann Arbor'),('Arden-Arcade');
|
||||
EXPLAIN
|
||||
SELECT MAX( alias2.a ) AS field
|
||||
FROM t1 AS alias1, t1 AS alias2, t1 AS alias3
|
||||
WHERE alias1.a = alias2.a OR alias1.a = 'y'
|
||||
HAVING field>'B' AND ( 'Moscow' ) IN ( SELECT a FROM t1 );
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 PRIMARY NULL NULL NULL NULL NULL NULL NULL Impossible HAVING
|
||||
2 SUBQUERY t1 index_subquery a a 19 const 1 Using index; Using where
|
||||
SELECT MAX( alias2.a ) AS field
|
||||
FROM t1 AS alias1, t1 AS alias2, t1 AS alias3
|
||||
WHERE alias1.a = alias2.a OR alias1.a = 'y'
|
||||
HAVING field>'B' AND ( 'Moscow' ) IN ( SELECT a FROM t1 );
|
||||
field
|
||||
EXPLAIN
|
||||
SELECT MAX( alias2.a )
|
||||
FROM t1 AS alias1, t1 AS alias2, t1 AS alias3
|
||||
WHERE alias1.a = alias2.a OR ('Moscow') IN ( SELECT a FROM t1 );
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 PRIMARY alias1 index a a 19 NULL 11 Using where; Using index
|
||||
1 PRIMARY alias2 ref a a 19 test.alias1.a 2 Using index
|
||||
1 PRIMARY alias3 index NULL a 19 NULL 11 Using index; Using join buffer (flat, BNL join)
|
||||
2 SUBQUERY t1 index_subquery a a 19 const 1 Using index; Using where
|
||||
SELECT MAX( alias2.a )
|
||||
FROM t1 AS alias1, t1 AS alias2, t1 AS alias3
|
||||
WHERE alias1.a = alias2.a OR ('Moscow') IN ( SELECT a FROM t1 );
|
||||
MAX( alias2.a )
|
||||
Arden-Arcade
|
||||
drop table t1;
|
||||
#
|
||||
# MDEV-277 CHEAP SQ: Server crashes in st_join_table::get_examined_rows
|
||||
# with semijoin+materialization, IN and = subqueries
|
||||
#
|
||||
CREATE TABLE t1 (a1 INT);
|
||||
INSERT INTO t1 VALUES (4),(6);
|
||||
CREATE TABLE t2 (b1 INT);
|
||||
INSERT INTO t2 VALUES (1),(7);
|
||||
EXPLAIN
|
||||
SELECT * FROM t1
|
||||
WHERE a1 = (SELECT COUNT(*) FROM t1 WHERE a1 IN (SELECT a1 FROM t1, 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 t1 ALL NULL NULL NULL NULL 2
|
||||
2 SUBQUERY <subquery3> eq_ref distinct_key distinct_key 4 func 1
|
||||
3 MATERIALIZED t1 ALL NULL NULL NULL NULL 2
|
||||
3 MATERIALIZED t2 ALL NULL NULL NULL NULL 2 Using join buffer (flat, BNL join)
|
||||
SELECT * FROM t1
|
||||
WHERE a1 = (SELECT COUNT(*) FROM t1 WHERE a1 IN (SELECT a1 FROM t1, t2));
|
||||
a1
|
||||
drop table t1, t2;
|
||||
#
|
||||
# MDEV-287 CHEAP SQ: A query with subquery in SELECT list, EXISTS,
|
||||
# inner joins takes hundreds times longer
|
||||
#
|
||||
CREATE TABLE t1 (a INT);
|
||||
INSERT INTO t1 VALUES (1),(7);
|
||||
CREATE TABLE t2 (b INT);
|
||||
INSERT INTO t2 VALUES (4),(5);
|
||||
CREATE TABLE t3 (c INT);
|
||||
INSERT INTO t3 VALUES (8),(3);
|
||||
set @@expensive_subquery_limit= 0;
|
||||
EXPLAIN
|
||||
SELECT (SELECT MIN(b) FROM t1, t2 WHERE b = a AND (b = alias1.b OR EXISTS (SELECT * FROM t3)))
|
||||
FROM t2 alias1, t1 alias2, t1 alias3;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 PRIMARY alias1 ALL NULL NULL NULL NULL 2
|
||||
1 PRIMARY alias2 ALL NULL NULL NULL NULL 2 Using join buffer (flat, BNL join)
|
||||
1 PRIMARY alias3 ALL NULL NULL NULL NULL 2 Using join buffer (flat, BNL join)
|
||||
2 DEPENDENT SUBQUERY t1 ALL NULL NULL NULL NULL 2 Using where
|
||||
2 DEPENDENT SUBQUERY t2 ALL NULL NULL NULL NULL 2 Using where; Using join buffer (flat, BNL join)
|
||||
3 SUBQUERY t3 ALL NULL NULL NULL NULL 2
|
||||
flush status;
|
||||
SELECT (SELECT MIN(b) FROM t1, t2 WHERE b = a AND (b = alias1.b OR EXISTS (SELECT * FROM t3)))
|
||||
FROM t2 alias1, t1 alias2, t1 alias3;
|
||||
(SELECT MIN(b) FROM t1, t2 WHERE b = a AND (b = alias1.b OR EXISTS (SELECT * FROM t3)))
|
||||
NULL
|
||||
NULL
|
||||
NULL
|
||||
NULL
|
||||
NULL
|
||||
NULL
|
||||
NULL
|
||||
NULL
|
||||
show status like "subquery_cache%";
|
||||
Variable_name Value
|
||||
Subquery_cache_hit 6
|
||||
Subquery_cache_miss 2
|
||||
show status like '%Handler_read%';
|
||||
Variable_name Value
|
||||
Handler_read_first 0
|
||||
Handler_read_key 8
|
||||
Handler_read_last 0
|
||||
Handler_read_next 0
|
||||
Handler_read_prev 0
|
||||
Handler_read_rnd 0
|
||||
Handler_read_rnd_deleted 0
|
||||
Handler_read_rnd_next 22
|
||||
set @@expensive_subquery_limit= default;
|
||||
EXPLAIN
|
||||
SELECT (SELECT MIN(b) FROM t1, t2 WHERE b = a AND (b = alias1.b OR EXISTS (SELECT * FROM t3)))
|
||||
FROM t2 alias1, t1 alias2, t1 alias3;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 PRIMARY alias1 ALL NULL NULL NULL NULL 2
|
||||
1 PRIMARY alias2 ALL NULL NULL NULL NULL 2 Using join buffer (flat, BNL join)
|
||||
1 PRIMARY alias3 ALL NULL NULL NULL NULL 2 Using join buffer (flat, BNL join)
|
||||
2 SUBQUERY t1 ALL NULL NULL NULL NULL 2
|
||||
2 SUBQUERY t2 ALL NULL NULL NULL NULL 2 Using where; Using join buffer (flat, BNL join)
|
||||
3 SUBQUERY t3 ALL NULL NULL NULL NULL 2
|
||||
flush status;
|
||||
SELECT (SELECT MIN(b) FROM t1, t2 WHERE b = a AND (b = alias1.b OR EXISTS (SELECT * FROM t3)))
|
||||
FROM t2 alias1, t1 alias2, t1 alias3;
|
||||
(SELECT MIN(b) FROM t1, t2 WHERE b = a AND (b = alias1.b OR EXISTS (SELECT * FROM t3)))
|
||||
NULL
|
||||
NULL
|
||||
NULL
|
||||
NULL
|
||||
NULL
|
||||
NULL
|
||||
NULL
|
||||
NULL
|
||||
show status like "subquery_cache%";
|
||||
Variable_name Value
|
||||
Subquery_cache_hit 0
|
||||
Subquery_cache_miss 0
|
||||
show status like '%Handler_read%';
|
||||
Variable_name Value
|
||||
Handler_read_first 0
|
||||
Handler_read_key 0
|
||||
Handler_read_last 0
|
||||
Handler_read_next 0
|
||||
Handler_read_prev 0
|
||||
Handler_read_rnd 0
|
||||
Handler_read_rnd_deleted 0
|
||||
Handler_read_rnd_next 16
|
||||
drop table t1, t2, t3;
|
||||
#
|
||||
# MDEV-288 CHEAP SQ: Valgrind warnings "Memory lost" with IN and EXISTS nested subquery, materialization+semijoin
|
||||
#
|
||||
CREATE TABLE t1 (a INT);
|
||||
INSERT INTO t1 VALUES (0),(8);
|
||||
CREATE TABLE t2 (b INT PRIMARY KEY);
|
||||
INSERT INTO t2 VALUES (1),(2);
|
||||
EXPLAIN
|
||||
SELECT * FROM t1 WHERE 4 IN (SELECT MAX(b) FROM t2 WHERE EXISTS (SELECT * FROM t1));
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 PRIMARY NULL NULL NULL NULL NULL NULL NULL Impossible WHERE
|
||||
2 MATERIALIZED NULL NULL NULL NULL NULL NULL NULL Select tables optimized away
|
||||
3 SUBQUERY t1 ALL NULL NULL NULL NULL 2
|
||||
SELECT * FROM t1 WHERE 4 IN (SELECT MAX(b) FROM t2 WHERE EXISTS (SELECT * FROM t1));
|
||||
a
|
||||
drop table t1,t2;
|
||||
#
|
||||
# MDEV-410: EXPLAIN shows type=range, while SHOW EXPLAIN and userstat show full table scan is used
|
||||
#
|
||||
CREATE TABLE t1 (a VARCHAR(3) PRIMARY KEY) ENGINE=MyISAM;
|
||||
INSERT INTO t1 VALUES ('USA');
|
||||
CREATE TABLE t2 (b INT, c VARCHAR(52), KEY(b)) ENGINE=MyISAM;
|
||||
INSERT INTO t2 VALUES (3813,'United States'),(3940,'Russia');
|
||||
CREATE TABLE t3 (d INT, KEY(d)) ENGINE=MyISAM;
|
||||
INSERT INTO t3 VALUES (12),(22),(9),(45);
|
||||
create table t4 like t3;
|
||||
insert into t4 select * from t3;
|
||||
# This should not show range access for table t2
|
||||
explain
|
||||
SELECT MIN(b) FROM ( SELECT * FROM t1, t2, t3 WHERE d = b ) AS alias1
|
||||
WHERE SLEEP(0.1) OR c < 'p' OR b = ( SELECT MIN(b) FROM t2 );
|
||||
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 ALL b NULL NULL NULL 2 Using where
|
||||
1 PRIMARY t3 ref d d 5 test.t2.b 2 Using where; Using index
|
||||
3 SUBQUERY NULL NULL NULL NULL NULL NULL NULL Select tables optimized away
|
||||
set @tmp_mdev410=@@global.userstat;
|
||||
set global userstat=on;
|
||||
flush table_statistics;
|
||||
flush index_statistics;
|
||||
SELECT MIN(b) FROM ( SELECT * FROM t1, t2, t3 WHERE d = b ) AS alias1
|
||||
WHERE SLEEP(0.1) OR c < 'p' OR b = ( SELECT MIN(b) FROM t2 );
|
||||
MIN(b)
|
||||
NULL
|
||||
# The following shows that t2 was indeed scanned with a full scan.
|
||||
show table_statistics;
|
||||
Table_schema Table_name Rows_read Rows_changed Rows_changed_x_#indexes
|
||||
test t1 2 0 0
|
||||
test t2 3 0 0
|
||||
show index_statistics;
|
||||
Table_schema Table_name Index_name Rows_read
|
||||
test t2 b 1
|
||||
set global userstat=@tmp_mdev410;
|
||||
DROP TABLE t1,t2,t3,t4;
|
||||
# return optimizer switch changed in the beginning of this test
|
||||
set optimizer_switch=@subselect_tmp;
|
||||
set @optimizer_switch_for_subselect_test=null;
|
||||
|
|
|
@ -1197,8 +1197,8 @@ set @@optimizer_switch=@optimizer_switch_local_default;
|
|||
set @@optimizer_switch='materialization=off,in_to_exists=on';
|
||||
explain select min(a1) from t1 where 7 in (select max(b1) from t2 group by b1);
|
||||
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 system NULL NULL NULL NULL 0 const row not found
|
||||
1 PRIMARY NULL NULL NULL NULL NULL NULL NULL Impossible WHERE
|
||||
2 SUBQUERY NULL NULL NULL NULL NULL NULL NULL no matching row in const table
|
||||
select min(a1) from t1 where 7 in (select max(b1) from t2 group by b1);
|
||||
min(a1)
|
||||
NULL
|
||||
|
@ -1206,8 +1206,8 @@ set @@optimizer_switch=@optimizer_switch_local_default;
|
|||
set @@optimizer_switch='semijoin=off';
|
||||
explain select min(a1) from t1 where 7 in (select b1 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 NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables
|
||||
1 PRIMARY NULL NULL NULL NULL NULL NULL NULL Impossible WHERE
|
||||
2 SUBQUERY NULL NULL NULL NULL NULL NULL NULL no matching row in const table
|
||||
select min(a1) from t1 where 7 in (select b1 from t2);
|
||||
min(a1)
|
||||
NULL
|
||||
|
@ -1223,8 +1223,8 @@ NULL
|
|||
# but when we go around MWL#90 code, the problem still shows up:
|
||||
explain select min(a1) from t1 where 7 in (select b1 from t2) or 2> 4;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 PRIMARY t1 system NULL NULL NULL NULL 1
|
||||
2 SUBQUERY NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables
|
||||
1 PRIMARY NULL NULL NULL NULL NULL NULL NULL Impossible WHERE
|
||||
2 SUBQUERY NULL NULL NULL NULL NULL NULL NULL no matching row in const table
|
||||
select min(a1) from t1 where 7 in (select b1 from t2) or 2> 4;
|
||||
min(a1)
|
||||
NULL
|
||||
|
@ -1971,7 +1971,7 @@ 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 index c c 5 NULL 8 Using index
|
||||
1 PRIMARY <subquery2> eq_ref distinct_key distinct_key 8 func,func 1
|
||||
2 MATERIALIZED s2 ref d d 4 const 1 Using where; Using index
|
||||
2 MATERIALIZED s2 ref d d 4 const 2 Using where; Using index
|
||||
2 MATERIALIZED s1 ALL c NULL NULL NULL 8 Using where; Using join buffer (flat, BNL join)
|
||||
3 SUBQUERY t2 ALL NULL NULL NULL NULL 8
|
||||
SELECT a, c FROM t1, t2
|
||||
|
@ -1991,8 +1991,8 @@ 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 index c c 5 NULL 8 Using index
|
||||
1 PRIMARY <subquery2> eq_ref distinct_key distinct_key 8 func,func 1
|
||||
2 MATERIALIZED s2 ref d d 4 const 1 Using where; Using index
|
||||
2 MATERIALIZED s1 hash_ALL c #hash#$hj 10 const,test.s2.d 8 Using where; Using join buffer (flat, BNLH join)
|
||||
2 MATERIALIZED s2 ref d d 4 const 2 Using where; Using index
|
||||
2 MATERIALIZED s1 hash_ALL c #hash#$hj 5 const 8 Using where; Using join buffer (flat, BNLH join)
|
||||
3 SUBQUERY t2 ALL NULL NULL NULL NULL 8
|
||||
SELECT a, c FROM t1, t2
|
||||
WHERE (a, c) IN (SELECT s1.b, s1.c FROM t2 AS s1, t2 AS s2
|
||||
|
|
|
@ -1845,3 +1845,20 @@ dev
|
|||
SELECT(SELECT 1 AS a FROM dual ORDER BY a DESC LIMIT 1) AS dev;
|
||||
dev
|
||||
1
|
||||
#
|
||||
# LP bug#1010729: Unexpected syntax error from UNION
|
||||
# (bug #54382) with single-table join nest
|
||||
#
|
||||
CREATE TABLE t1 (a int);
|
||||
CREATE TABLE t2 (b int);
|
||||
CREATE TABLE t3 (c int);
|
||||
SELECT a FROM t1 UNION SELECT b FROM t2 JOIN (t3) ON ( t2.b = t3.c );
|
||||
a
|
||||
DROP TABLE t1, t2, t3;
|
||||
CREATE TABLE t1 (pk int NOT NULL);
|
||||
CREATE TABLE t2 (pk int NOT NULL, fk int NOT NULL);
|
||||
SELECT t1.pk FROM t1 LEFT JOIN (t2) ON (t1.pk = t2.fk)
|
||||
UNION
|
||||
SELECT t1.pk FROM t1 LEFT JOIN (t2) ON (t1.pk = t2.fk);
|
||||
pk
|
||||
DROP TABLE t1,t2;
|
||||
|
|
|
@ -454,6 +454,13 @@ SELECT (@v:=a) <> (@v:=1) FROM t1;
|
|||
(@v:=a) <> (@v:=1)
|
||||
1
|
||||
DROP TABLE t1;
|
||||
CREATE TABLE t1(a int);
|
||||
INSERT INTO t1 VALUES (1), (2);
|
||||
SELECT DISTINCT @a:=MIN(t1.a) FROM t1, t1 AS t2
|
||||
GROUP BY @b:=(SELECT COUNT(*) > t2.a);
|
||||
@a:=MIN(t1.a)
|
||||
1
|
||||
DROP TABLE t1;
|
||||
End of 5.1 tests
|
||||
DROP TABLE IF EXISTS t1;
|
||||
CREATE TABLE t1(f1 INT AUTO_INCREMENT, PRIMARY KEY(f1));
|
||||
|
|
|
@ -4324,13 +4324,13 @@ MM
|
|||
ZZ
|
||||
ZZ
|
||||
Warnings:
|
||||
Warning 1292 Truncated incorrect INTEGER value: 'VV'
|
||||
Warning 1292 Truncated incorrect DOUBLE value: 'VV'
|
||||
EXPLAIN EXTENDED
|
||||
SELECT * FROM v1 WHERE a > 'JJ' OR a AND a = 'VV';
|
||||
id select_type table type possible_keys key key_len ref rows filtered Extra
|
||||
1 SIMPLE t1 range a a 13 NULL 4 100.00 Using where; Using index
|
||||
Warnings:
|
||||
Warning 1292 Truncated incorrect INTEGER value: 'VV'
|
||||
Warning 1292 Truncated incorrect DOUBLE value: 'VV'
|
||||
Note 1003 select `test`.`t1`.`a` AS `a` from `test`.`t1` where (`test`.`t1`.`a` > 'JJ')
|
||||
DROP VIEW v1;
|
||||
DROP TABLE t1;
|
||||
|
@ -4674,6 +4674,19 @@ INSERT INTO t2 VALUES (1);
|
|||
DROP TRIGGER tr;
|
||||
DROP VIEW v1;
|
||||
DROP TABLE t1,t2,t3;
|
||||
#
|
||||
# LP bug#1007622 Server crashes in handler::increment_statistics on
|
||||
# inserting into a view over a view
|
||||
#
|
||||
CREATE TABLE t1 (a INT);
|
||||
CREATE ALGORITHM=MERGE VIEW v1 AS SELECT a1.* FROM t1 AS a1, t1 AS a2;
|
||||
CREATE ALGORITHM=MERGE VIEW v2 AS SELECT * FROM v1;
|
||||
INSERT INTO v2 (a) VALUES (1) ;
|
||||
select * from t1;
|
||||
a
|
||||
1
|
||||
drop view v2,v1;
|
||||
drop table t1;
|
||||
# -----------------------------------------------------------------
|
||||
# -- End of 5.3 tests.
|
||||
# -----------------------------------------------------------------
|
||||
|
|
|
@ -96,3 +96,21 @@ master-bin.000001 # Query # # use `test`; DROP VIEW IF EXISTS db_bug_13684.v
|
|||
master-bin.000001 # Query # # use `test`; DROP EVENT IF EXISTS db_bug_13684.e
|
||||
master-bin.000001 # Query # # use `test`; DROP TABLE IF EXISTS `db_bug_13684`.`t` /* generated by server */
|
||||
master-bin.000001 # Query # # DROP DATABASE IF EXISTS db_bug_13684
|
||||
CREATE TABLE t1(id int);
|
||||
DROP TABLE /* comment */ t1;
|
||||
CREATE TABLE t1(id int);
|
||||
DROP TABLE IF EXISTS /* comment */ t1;
|
||||
CREATE TABLE t1(id int);
|
||||
DROP TABLE /**/ t1;
|
||||
CREATE TABLE t1(id int);
|
||||
DROP TABLE IF EXISTS /* */ t1;
|
||||
show binlog events from <binlog_start>;
|
||||
Log_name Pos Event_type Server_id End_log_pos Info
|
||||
master-bin.000001 # Query # # use `test`; CREATE TABLE t1(id int)
|
||||
master-bin.000001 # Query # # use `test`; DROP TABLE /* comment */ `t1` /* generated by server */
|
||||
master-bin.000001 # Query # # use `test`; CREATE TABLE t1(id int)
|
||||
master-bin.000001 # Query # # use `test`; DROP TABLE IF EXISTS /* comment */ `t1` /* generated by server */
|
||||
master-bin.000001 # Query # # use `test`; CREATE TABLE t1(id int)
|
||||
master-bin.000001 # Query # # use `test`; DROP TABLE /**/ `t1` /* generated by server */
|
||||
master-bin.000001 # Query # # use `test`; CREATE TABLE t1(id int)
|
||||
master-bin.000001 # Query # # use `test`; DROP TABLE IF EXISTS /* */ `t1` /* generated by server */
|
||||
|
|
|
@ -22,3 +22,7 @@ ERROR 42000: Access denied; you need (at least one of) the SUPER privilege(s) fo
|
|||
**** Clean up ****
|
||||
set global binlog_format = @saved_binlog_format;
|
||||
drop user mysqltest_1@localhost;
|
||||
GRANT REPLICATION CLIENT ON *.* TO 'mysqltest_1'@'localhost';
|
||||
SHOW MASTER LOGS;
|
||||
SHOW BINARY LOGS;
|
||||
DROP USER 'mysqltest_1'@'localhost';
|
||||
|
|
30
mysql-test/suite/binlog/r/binlog_mdev342.result
Normal file
30
mysql-test/suite/binlog/r/binlog_mdev342.result
Normal file
|
@ -0,0 +1,30 @@
|
|||
SET GLOBAL max_binlog_size= 4096;
|
||||
SET GLOBAL innodb_flush_log_at_trx_commit= 1;
|
||||
RESET MASTER;
|
||||
CREATE TABLE t1 (a INT PRIMARY KEY, b MEDIUMTEXT) ENGINE=Innodb;
|
||||
SET DEBUG_SYNC= "binlog_open_before_update_index SIGNAL con1_ready WAIT_FOR con1_cont";
|
||||
SET SESSION debug_dbug="+d,crash_create_critical_before_update_index";
|
||||
INSERT INTO t1 VALUES (1, REPEAT("x", 4100));
|
||||
SET DEBUG_SYNC= "now WAIT_FOR con1_ready";
|
||||
SET DEBUG_SYNC= "ha_commit_trans_after_prepare SIGNAL con2_ready";
|
||||
INSERT INTO t1 VALUES (2, NULL);
|
||||
SET DEBUG_SYNC= "now WAIT_FOR con2_ready";
|
||||
SET DEBUG_SYNC= "now SIGNAL con1_cont";
|
||||
Got one of the listed errors
|
||||
SELECT a FROM t1 ORDER BY a;
|
||||
a
|
||||
1
|
||||
show binary logs;
|
||||
Log_name File_size
|
||||
master-bin.000001 #
|
||||
master-bin.000002 #
|
||||
show binlog events in 'master-bin.000001' from <binlog_start>;
|
||||
Log_name Pos Event_type Server_id End_log_pos Info
|
||||
master-bin.000001 # Format_desc # # SERVER_VERSION, BINLOG_VERSION
|
||||
master-bin.000001 # Query # # use `test`; CREATE TABLE t1 (a INT PRIMARY KEY, b MEDIUMTEXT) ENGINE=Innodb
|
||||
master-bin.000001 # Query # # BEGIN
|
||||
master-bin.000001 # Table_map # # table_id: # (test.t1)
|
||||
master-bin.000001 # Write_rows # # table_id: # flags: STMT_END_F
|
||||
master-bin.000001 # Xid # # COMMIT /* XID */
|
||||
master-bin.000001 # Rotate # # master-bin.000002;pos=<binlog_start>
|
||||
DROP TABLE t1;
|
|
@ -113,3 +113,18 @@ if($fixed_bug_25705)
|
|||
--source include/show_binlog_events.inc
|
||||
|
||||
enable_warnings;
|
||||
|
||||
# Drop comments in binlog
|
||||
let $binlog_start= query_get_value(SHOW MASTER STATUS, Position, 1);
|
||||
CREATE TABLE t1(id int);
|
||||
DROP TABLE /* comment */ t1;
|
||||
CREATE TABLE t1(id int);
|
||||
DROP TABLE IF EXISTS /* comment */ t1;
|
||||
|
||||
CREATE TABLE t1(id int);
|
||||
DROP TABLE /**/ t1;
|
||||
CREATE TABLE t1(id int);
|
||||
DROP TABLE IF EXISTS /* */ t1;
|
||||
|
||||
--source include/show_binlog_events.inc
|
||||
|
||||
|
|
|
@ -54,3 +54,22 @@ disconnect root;
|
|||
connection default;
|
||||
set global binlog_format = @saved_binlog_format;
|
||||
drop user mysqltest_1@localhost;
|
||||
|
||||
|
||||
# Testing if REPLICATION CLIENT privilege is enough to execute
|
||||
# SHOW MASTER LOGS and SHOW BINARY.
|
||||
GRANT REPLICATION CLIENT ON *.* TO 'mysqltest_1'@'localhost';
|
||||
--connect(rpl,localhost,mysqltest_1,,)
|
||||
|
||||
--connection rpl
|
||||
# We are only interested if the following commands succeed and not on
|
||||
# their output.
|
||||
--disable_result_log
|
||||
SHOW MASTER LOGS;
|
||||
SHOW BINARY LOGS;
|
||||
--enable_result_log
|
||||
|
||||
# clean up
|
||||
--disconnect rpl
|
||||
connection default;
|
||||
DROP USER 'mysqltest_1'@'localhost';
|
||||
|
|
1
mysql-test/suite/binlog/t/binlog_mdev342-master.opt
Normal file
1
mysql-test/suite/binlog/t/binlog_mdev342-master.opt
Normal file
|
@ -0,0 +1 @@
|
|||
--skip-stack-trace --skip-core-file
|
66
mysql-test/suite/binlog/t/binlog_mdev342.test
Normal file
66
mysql-test/suite/binlog/t/binlog_mdev342.test
Normal file
|
@ -0,0 +1,66 @@
|
|||
--source include/have_innodb.inc
|
||||
--source include/have_debug.inc
|
||||
--source include/have_debug_sync.inc
|
||||
--source include/have_binlog_format_row.inc
|
||||
# Valgrind does not work well with test that crashes the server
|
||||
--source include/not_valgrind.inc
|
||||
|
||||
# (We do not need to restore these settings, as we crash the server).
|
||||
SET GLOBAL max_binlog_size= 4096;
|
||||
SET GLOBAL innodb_flush_log_at_trx_commit= 1;
|
||||
RESET MASTER;
|
||||
|
||||
CREATE TABLE t1 (a INT PRIMARY KEY, b MEDIUMTEXT) ENGINE=Innodb;
|
||||
|
||||
# One connection does an insert that causes a binlog rotate.
|
||||
# The rotate is paused after writing new file but before updating index.
|
||||
connect(con1,localhost,root,,);
|
||||
SET DEBUG_SYNC= "binlog_open_before_update_index SIGNAL con1_ready WAIT_FOR con1_cont";
|
||||
SET SESSION debug_dbug="+d,crash_create_critical_before_update_index";
|
||||
send INSERT INTO t1 VALUES (1, REPEAT("x", 4100));
|
||||
|
||||
connection default;
|
||||
SET DEBUG_SYNC= "now WAIT_FOR con1_ready";
|
||||
|
||||
# Another connection creates a prepared transaction.
|
||||
# After the transaction is prepared, it will hang waiting for LOCK_log.
|
||||
connect(con2,localhost,root,,);
|
||||
SET DEBUG_SYNC= "ha_commit_trans_after_prepare SIGNAL con2_ready";
|
||||
send INSERT INTO t1 VALUES (2, NULL);
|
||||
|
||||
connection default;
|
||||
SET DEBUG_SYNC= "now WAIT_FOR con2_ready";
|
||||
|
||||
# Now crash the server in con1, with old binlog closed, new binlog not yet in
|
||||
# index, and one transaction in prepared-but-not-committed state.
|
||||
--write_file $MYSQLTEST_VARDIR/tmp/mysqld.1.expect
|
||||
wait-binlog_mdev342.test
|
||||
EOF
|
||||
# If con1 manages to race ahead and crash, we can see the crash already in the
|
||||
# SET DEBUG_SYNC statement, so need --error here also.
|
||||
--error 0,2006,2013
|
||||
SET DEBUG_SYNC= "now SIGNAL con1_cont";
|
||||
connection con1;
|
||||
--error 2006,2013
|
||||
reap;
|
||||
|
||||
--remove_file $MYSQLTEST_VARDIR/tmp/mysqld.1.expect
|
||||
--write_file $MYSQLTEST_VARDIR/tmp/mysqld.1.expect
|
||||
restart-binlog_mdev342.test
|
||||
EOF
|
||||
|
||||
connection default;
|
||||
--enable_reconnect
|
||||
--source include/wait_until_connected_again.inc
|
||||
|
||||
# Check that all transactions are recovered.
|
||||
SELECT a FROM t1 ORDER BY a;
|
||||
|
||||
--source include/show_binary_logs.inc
|
||||
--let $binlog_file= master-bin.000001
|
||||
--let $binlog_start= 4
|
||||
--source include/show_binlog_events.inc
|
||||
|
||||
# Cleanup
|
||||
connection default;
|
||||
DROP TABLE t1;
|
|
@ -16,7 +16,13 @@ DROP TABLE t1;
|
|||
CREATE TABLE t1(c1 TIME NULL, c2 TIME NULL);
|
||||
SET TIMESTAMP=1171346973;
|
||||
INSERT INTO t1 VALUES(NOW(),NOW());
|
||||
Warnings:
|
||||
Note 1265 Data truncated for column 'c1' at row 1
|
||||
Note 1265 Data truncated for column 'c2' at row 1
|
||||
INSERT INTO t1 VALUES(NOW(),NOW());
|
||||
Warnings:
|
||||
Note 1265 Data truncated for column 'c1' at row 1
|
||||
Note 1265 Data truncated for column 'c2' at row 1
|
||||
ANALYZE TABLE t1;
|
||||
Table Op Msg_type Msg_text
|
||||
test.t1 analyze status OK
|
||||
|
|
|
@ -25,7 +25,15 @@ INSERT INTO t3 VALUES('2008-02-29 13:13:13');
|
|||
DROP TABLE t3;
|
||||
CREATE TABLE t3(c1 TIME NOT NULL);
|
||||
INSERT INTO t3 VALUES('1000-01-01 00:00:00');
|
||||
Warnings:
|
||||
Note 1265 Data truncated for column 'c1' at row 1
|
||||
INSERT INTO t3 VALUES('1999-12-31 23:59:59');
|
||||
Warnings:
|
||||
Note 1265 Data truncated for column 'c1' at row 1
|
||||
INSERT INTO t3 VALUES('2000-01-01 00:00:00');
|
||||
Warnings:
|
||||
Note 1265 Data truncated for column 'c1' at row 1
|
||||
INSERT INTO t3 VALUES('2008-02-29 13:13:13');
|
||||
Warnings:
|
||||
Note 1265 Data truncated for column 'c1' at row 1
|
||||
DROP TABLE t3;
|
||||
|
|
|
@ -77,6 +77,7 @@ utf8_persian_ci utf8 208 # #
|
|||
utf8_esperanto_ci utf8 209 # #
|
||||
utf8_hungarian_ci utf8 210 # #
|
||||
utf8_sinhala_ci utf8 211 # #
|
||||
utf8_croatian_ci utf8 213 # #
|
||||
utf8_general_mysql500_ci utf8 223 # #
|
||||
ucs2_general_ci ucs2 35 Yes # #
|
||||
ucs2_bin ucs2 90 # #
|
||||
|
@ -100,6 +101,7 @@ ucs2_persian_ci ucs2 144 # #
|
|||
ucs2_esperanto_ci ucs2 145 # #
|
||||
ucs2_hungarian_ci ucs2 146 # #
|
||||
ucs2_sinhala_ci ucs2 147 # #
|
||||
ucs2_croatian_ci ucs2 149 # #
|
||||
ucs2_general_mysql500_ci ucs2 159 # #
|
||||
cp866_general_ci cp866 36 Yes # #
|
||||
cp866_bin cp866 68 # #
|
||||
|
@ -137,6 +139,7 @@ utf8mb4_persian_ci utf8mb4 240 # #
|
|||
utf8mb4_esperanto_ci utf8mb4 241 # #
|
||||
utf8mb4_hungarian_ci utf8mb4 242 # #
|
||||
utf8mb4_sinhala_ci utf8mb4 243 # #
|
||||
utf8mb4_croatian_ci utf8mb4 245 # #
|
||||
cp1251_bulgarian_ci cp1251 14 # #
|
||||
cp1251_ukrainian_ci cp1251 23 # #
|
||||
cp1251_bin cp1251 50 # #
|
||||
|
@ -164,6 +167,7 @@ utf16_persian_ci utf16 117 # #
|
|||
utf16_esperanto_ci utf16 118 # #
|
||||
utf16_hungarian_ci utf16 119 # #
|
||||
utf16_sinhala_ci utf16 120 # #
|
||||
utf16_croatian_ci utf16 215 # #
|
||||
cp1256_general_ci cp1256 57 Yes # #
|
||||
cp1256_bin cp1256 67 # #
|
||||
cp1257_lithuanian_ci cp1257 29 # #
|
||||
|
@ -191,6 +195,7 @@ utf32_persian_ci utf32 176 # #
|
|||
utf32_esperanto_ci utf32 177 # #
|
||||
utf32_hungarian_ci utf32 178 # #
|
||||
utf32_sinhala_ci utf32 179 # #
|
||||
utf32_croatian_ci utf32 214 # #
|
||||
binary binary 63 Yes # #
|
||||
geostd8_general_ci geostd8 92 Yes # #
|
||||
geostd8_bin geostd8 93 # #
|
||||
|
|
Some files were not shown because too many files have changed in this diff Show more
Loading…
Add table
Reference in a new issue