1
0
mirror of https://github.com/MariaDB/server.git synced 2025-07-29 05:21:33 +03:00

references lp:1011983

Merged latest MariaDB development in: bzr merge lp:maria/5.5
=> 
Text conflict in CMakeLists.txt
Text conflict in sql/handler.h
Text conflict in support-files/CMakeLists.txt
3 conflicts
This commit is contained in:
Seppo Jaakola
2012-06-12 16:34:18 +03:00
512 changed files with 5116 additions and 5794 deletions

View File

@ -1140,3 +1140,7 @@ libmysqld/gcalc_tools.cc
sql/share/errmsg.sys sql/share/errmsg.sys
sql/share/mysql sql/share/mysql
install_manifest.txt install_manifest.txt
sql/db.opt
./_CPack_Packages
./install_manifest_*.txt
typescript

View File

@ -39,8 +39,6 @@ ENDIF()
SET(CMAKE_BUILD_TYPE "RelWithDebInfo" CACHE STRING SET(CMAKE_BUILD_TYPE "RelWithDebInfo" CACHE STRING
"Choose the type of build, options are: None(CMAKE_CXX_FLAGS or CMAKE_C_FLAGS used) Debug Release RelWithDebInfo MinSizeRel") "Choose the type of build, options are: None(CMAKE_CXX_FLAGS or CMAKE_C_FLAGS used) Debug Release RelWithDebInfo MinSizeRel")
IF(UNIX AND NOT APPLE) IF(UNIX AND NOT APPLE)
# Note, that generally one should not change settings depending # Note, that generally one should not change settings depending
# on CMAKE_BUILD_TYPE, because VS and Xcode configure once (with # on CMAKE_BUILD_TYPE, because VS and Xcode configure once (with
@ -124,18 +122,30 @@ IF(CMAKE_CXX_COMPILER_ID MATCHES "Intel")
SET_MYSQL_MAINTAINER_INTEL_CXX_OPTIONS() SET_MYSQL_MAINTAINER_INTEL_CXX_OPTIONS()
ENDIF() ENDIF()
# Packaging
IF (NOT CPACK_GENERATOR)
IF(WIN32)
SET(CPACK_GENERATOR "ZIP")
ELSE()
SET(CPACK_GENERATOR "TGZ")
ENDIF(WIN32)
ENDIF(NOT CPACK_GENERATOR)
INCLUDE(mysql_version)
INCLUDE(cpack_rpm)
INCLUDE(cpack_source_ignore_files)
INCLUDE(install_layout)
# Add macros # Add macros
INCLUDE(character_sets) INCLUDE(character_sets)
INCLUDE(zlib) INCLUDE(zlib)
INCLUDE(ssl) INCLUDE(ssl)
INCLUDE(readline) INCLUDE(readline)
INCLUDE(mysql_version)
INCLUDE(libutils) INCLUDE(libutils)
INCLUDE(dtrace) INCLUDE(dtrace)
INCLUDE(ctest) INCLUDE(ctest)
INCLUDE(plugin) INCLUDE(plugin)
INCLUDE(install_macros) INCLUDE(install_macros)
INCLUDE(install_layout)
INCLUDE(mysql_add_executable) INCLUDE(mysql_add_executable)
INCLUDE(wsrep) INCLUDE(wsrep)
@ -238,8 +248,8 @@ ELSE()
ENDIF() ENDIF()
SET(DEFAULT_CHARSET_HOME "${DEFAULT_MYSQL_HOME}") SET(DEFAULT_CHARSET_HOME "${DEFAULT_MYSQL_HOME}")
SET(PLUGINDIR "${DEFAULT_MYSQL_HOME}/${INSTALL_PLUGINDIR}") SET(PLUGINDIR "${DEFAULT_MYSQL_HOME}/${INSTALL_PLUGINDIR}")
IF(SYSCONFDIR) IF(INSTALL_SYSCONFDIR)
SET(DEFAULT_SYSCONFDIR "${SYSCONFDIR}") SET(DEFAULT_SYSCONFDIR "${INSTALL_SYSCONFDIR}")
ENDIF() ENDIF()
@ -351,51 +361,18 @@ ADD_CUSTOM_TARGET(INFO_BIN ALL
WORKING_DIRECTORY ${CMAKE_BINARY_DIR} WORKING_DIRECTORY ${CMAKE_BINARY_DIR}
) )
# Packaging INSTALL(FILES COPYING COPYING.LESSER LICENSE.mysql
IF(WIN32) DESTINATION ${INSTALL_DOCREADMEDIR}
SET(CPACK_GENERATOR "ZIP") COMPONENT Readme
ELSE() OPTIONAL
SET(CPACK_GENERATOR "TGZ") )
ENDIF() INSTALL(FILES README DESTINATION ${INSTALL_DOCREADMEDIR} COMPONENT Readme)
INSTALL(FILES ${CMAKE_BINARY_DIR}/Docs/INFO_SRC ${CMAKE_BINARY_DIR}/Docs/INFO_BIN DESTINATION ${INSTALL_DOCDIR})
IF(UNIX)
# Create a single package with "make package" INSTALL(FILES Docs/INSTALL-BINARY Docs/README-wsrep DESTINATION ${INSTALL_DOCREADMEDIR} COMPONENT Readme)
# (see http://public.kitware.com/Bug/view.php?id=11452) ENDIF()
SET(CPACK_MONOLITHIC_INSTALL 1 CACHE INTERNAL "")
INCLUDE(CPack) INCLUDE(CPack)
IF(UNIX)
INSTALL(FILES Docs/mysql.info DESTINATION ${INSTALL_INFODIR} OPTIONAL COMPONENT Info)
ENDIF()
#
# RPM installs documentation directly from the source tree
#
IF(NOT INSTALL_LAYOUT MATCHES "RPM")
INSTALL(FILES COPYING COPYING.LESSER LICENSE.mysql
DESTINATION ${INSTALL_DOCREADMEDIR}
COMPONENT Readme
OPTIONAL
)
INSTALL(FILES README DESTINATION ${INSTALL_DOCREADMEDIR} COMPONENT Readme)
INSTALL(FILES ${CMAKE_BINARY_DIR}/Docs/INFO_SRC ${CMAKE_BINARY_DIR}/Docs/INFO_BIN DESTINATION ${INSTALL_DOCDIR})
IF(UNIX)
INSTALL(FILES Docs/INSTALL-BINARY Docs/README-wsrep DESTINATION ${INSTALL_DOCREADMEDIR} COMPONENT Readme)
ENDIF()
# MYSQL_DOCS_LOCATON is used in "make dist", points to the documentation directory
SET(MYSQL_DOCS_LOCATION "" CACHE PATH "Location from where documentation is copied")
MARK_AS_ADVANCED(MYSQL_DOCS_LOCATION)
INSTALL(DIRECTORY Docs/ DESTINATION ${INSTALL_DOCDIR}
COMPONENT Documentation
PATTERN "INSTALL-BINARY" EXCLUDE
PATTERN "README-wsrep" EXCLUDE
PATTERN "Makefile.*" EXCLUDE
PATTERN "glibc*" EXCLUDE
PATTERN "linuxthreads.txt" EXCLUDE
PATTERN "myisam.txt" EXCLUDE
PATTERN "mysql.info" EXCLUDE
PATTERN "sp-imp-spec.txt" EXCLUDE
)
ENDIF()
IF(NON_DISTRIBUTABLE_WARNING) IF(NON_DISTRIBUTABLE_WARNING)
MESSAGE(WARNING " MESSAGE(WARNING "

View File

@ -1,4 +1,4 @@
MYSQL_VERSION_MAJOR=5 MYSQL_VERSION_MAJOR=5
MYSQL_VERSION_MINOR=5 MYSQL_VERSION_MINOR=5
MYSQL_VERSION_PATCH=23 MYSQL_VERSION_PATCH=24
MYSQL_VERSION_EXTRA= MYSQL_VERSION_EXTRA=

View File

@ -49,7 +49,7 @@ TARGET_LINK_LIBRARIES(mysqldump mysqlclient)
MYSQL_ADD_EXECUTABLE(mysqlimport mysqlimport.c) MYSQL_ADD_EXECUTABLE(mysqlimport mysqlimport.c)
TARGET_LINK_LIBRARIES(mysqlimport mysqlclient) TARGET_LINK_LIBRARIES(mysqlimport mysqlclient)
MYSQL_ADD_EXECUTABLE(mysql_upgrade mysql_upgrade.c) MYSQL_ADD_EXECUTABLE(mysql_upgrade mysql_upgrade.c COMPONENT Server)
TARGET_LINK_LIBRARIES(mysql_upgrade mysqlclient) TARGET_LINK_LIBRARIES(mysql_upgrade mysqlclient)
ADD_DEPENDENCIES(mysql_upgrade GenFixPrivs) ADD_DEPENDENCIES(mysql_upgrade GenFixPrivs)

View File

@ -141,7 +141,8 @@ static my_bool opt_compress= FALSE, tty_password= FALSE,
const char *auto_generate_sql_type= "mixed"; const char *auto_generate_sql_type= "mixed";
static unsigned long connect_flags= CLIENT_MULTI_RESULTS | static unsigned long connect_flags= CLIENT_MULTI_RESULTS |
CLIENT_MULTI_STATEMENTS; CLIENT_MULTI_STATEMENTS |
CLIENT_REMEMBER_OPTIONS;
static int verbose, delimiter_length; static int verbose, delimiter_length;
static uint commit_rate; static uint commit_rate;

View File

@ -33,7 +33,7 @@
And many others And many others
*/ */
#define MTEST_VERSION "3.3" #define MTEST_VERSION "3.4"
#include "client_priv.h" #include "client_priv.h"
#include <mysql_version.h> #include <mysql_version.h>
@ -78,6 +78,8 @@ static my_bool non_blocking_api_enabled= 0;
#define MAX_DELIMITER_LENGTH 16 #define MAX_DELIMITER_LENGTH 16
#define DEFAULT_MAX_CONN 64 #define DEFAULT_MAX_CONN 64
#define DIE_BUFF_SIZE 8192
/* Flags controlling send and reap */ /* Flags controlling send and reap */
#define QUERY_SEND_FLAG 1 #define QUERY_SEND_FLAG 1
#define QUERY_REAP_FLAG 2 #define QUERY_REAP_FLAG 2
@ -106,6 +108,7 @@ static int opt_port= 0;
static int opt_max_connect_retries; static int opt_max_connect_retries;
static int opt_result_format_version; static int opt_result_format_version;
static int opt_max_connections= DEFAULT_MAX_CONN; static int opt_max_connections= DEFAULT_MAX_CONN;
static int error_count= 0;
static my_bool opt_compress= 0, silent= 0, verbose= 0; static my_bool opt_compress= 0, silent= 0, verbose= 0;
static my_bool debug_info_flag= 0, debug_check_flag= 0; static my_bool debug_info_flag= 0, debug_check_flag= 0;
static my_bool tty_password= 0; static my_bool tty_password= 0;
@ -122,7 +125,7 @@ static my_bool disable_connect_log= 1;
static my_bool disable_warnings= 0, disable_column_names= 0; static my_bool disable_warnings= 0, disable_column_names= 0;
static my_bool prepare_warnings_enabled= 0; static my_bool prepare_warnings_enabled= 0;
static my_bool disable_info= 1; static my_bool disable_info= 1;
static my_bool abort_on_error= 1; static my_bool abort_on_error= 1, opt_continue_on_error= 0;
static my_bool server_initialized= 0; static my_bool server_initialized= 0;
static my_bool is_windows= 0; static my_bool is_windows= 0;
static char **default_argv; static char **default_argv;
@ -559,14 +562,15 @@ const char *from, int len);
static void cleanup_and_exit(int exit_code) __attribute__((noreturn)); static void cleanup_and_exit(int exit_code) __attribute__((noreturn));
void die(const char *fmt, ...) void really_die(const char *msg) __attribute__((noreturn));
ATTRIBUTE_FORMAT(printf, 1, 2) __attribute__((noreturn)); void report_or_die(const char *fmt, ...) ATTRIBUTE_FORMAT(printf, 1, 2);
void abort_not_supported_test(const char *fmt, ...) void die(const char *fmt, ...) ATTRIBUTE_FORMAT(printf, 1, 2)
ATTRIBUTE_FORMAT(printf, 1, 2) __attribute__((noreturn)); __attribute__((noreturn));
void verbose_msg(const char *fmt, ...) static void make_error_message(char *buf, size_t len, const char *fmt, va_list args);
ATTRIBUTE_FORMAT(printf, 1, 2); void abort_not_supported_test(const char *fmt, ...) ATTRIBUTE_FORMAT(printf, 1, 2)
void log_msg(const char *fmt, ...) __attribute__((noreturn));
ATTRIBUTE_FORMAT(printf, 1, 2); void verbose_msg(const char *fmt, ...) ATTRIBUTE_FORMAT(printf, 1, 2);
void log_msg(const char *fmt, ...) ATTRIBUTE_FORMAT(printf, 1, 2);
VAR* var_from_env(const char *, const char *); VAR* var_from_env(const char *, const char *);
VAR* var_init(VAR* v, const char *name, int name_len, const char *val, VAR* var_init(VAR* v, const char *name, int name_len, const char *val,
@ -812,6 +816,9 @@ void handle_error(struct st_command*,
void handle_no_error(struct st_command*); void handle_no_error(struct st_command*);
void revert_properties(); void revert_properties();
static void handle_no_active_connection(struct st_command* command,
struct st_connection *cn, DYNAMIC_STRING *ds);
#ifdef EMBEDDED_LIBRARY #ifdef EMBEDDED_LIBRARY
#define EMB_SEND_QUERY 1 #define EMB_SEND_QUERY 1
@ -983,7 +990,10 @@ void do_eval(DYNAMIC_STRING *query_eval, const char *query,
else else
{ {
if (!(v= var_get(p, &p, 0, 0))) if (!(v= var_get(p, &p, 0, 0)))
die("Bad variable in eval"); {
report_or_die( "Bad variable in eval");
return;
}
dynstr_append_mem(query_eval, v->str_val, v->str_val_len); dynstr_append_mem(query_eval, v->str_val, v->str_val_len);
} }
break; break;
@ -1270,9 +1280,13 @@ void handle_command_error(struct st_command *command, uint error,
int i; int i;
if (command->abort_on_error) if (command->abort_on_error)
die("command \"%.*s\" failed with error: %u my_errno: %d errno: %d", {
report_or_die("command \"%.*s\" failed with error: %u my_errno: %d "
"errno: %d",
command->first_word_len, command->query, error, my_errno, command->first_word_len, command->query, error, my_errno,
sys_errno); sys_errno);
return;
}
i= match_expected_error(command, error, NULL); i= match_expected_error(command, error, NULL);
@ -1285,14 +1299,17 @@ void handle_command_error(struct st_command *command, uint error,
DBUG_VOID_RETURN; DBUG_VOID_RETURN;
} }
if (command->expected_errors.count > 0) if (command->expected_errors.count > 0)
die("command \"%.*s\" failed with wrong error: %u my_errno: %d errno: %d", report_or_die("command \"%.*s\" failed with wrong error: %u "
command->first_word_len, command->query, error, my_errno, sys_errno); "my_errno: %d errno: %d",
command->first_word_len, command->query, error, my_errno,
sys_errno);
} }
else if (command->expected_errors.err[0].type == ERR_ERRNO && else if (command->expected_errors.err[0].type == ERR_ERRNO &&
command->expected_errors.err[0].code.errnum != 0) command->expected_errors.err[0].code.errnum != 0)
{ {
/* Error code we wanted was != 0, i.e. not an expected success */ /* Error code we wanted was != 0, i.e. not an expected success */
die("command \"%.*s\" succeeded - should have failed with errno %d...", report_or_die("command \"%.*s\" succeeded - should have failed with "
"errno %d...",
command->first_word_len, command->query, command->first_word_len, command->query,
command->expected_errors.err[0].code.errnum); command->expected_errors.err[0].code.errnum);
} }
@ -1437,50 +1454,59 @@ static void cleanup_and_exit(int exit_code)
exit(exit_code); exit(exit_code);
} }
void print_file_stack() size_t print_file_stack(char *s, const char *end)
{ {
char *start= s;
struct st_test_file* err_file= cur_file; struct st_test_file* err_file= cur_file;
if (err_file == file_stack) if (err_file == file_stack)
return; return 0;
for (;;) for (;;)
{ {
err_file--; err_file--;
fprintf(stderr, "included from %s at line %d:\n", s+= my_snprintf(s, end - s, "included from %s at line %d:\n",
err_file->file_name, err_file->lineno); err_file->file_name, err_file->lineno);
if (err_file == file_stack) if (err_file == file_stack)
break; break;
} }
return s - start;
}
static void make_error_message(char *buf, size_t len, const char *fmt, va_list args)
{
char *s= buf, *end= buf + len;
s+= my_snprintf(s, end - s, "mysqltest: ");
if (cur_file && cur_file != file_stack)
{
s+= my_snprintf(s, end - s, "In included file \"%s\": \n",
cur_file->file_name);
s+= print_file_stack(s, end);
}
if (start_lineno > 0)
s+= my_snprintf(s, end -s, "At line %u: ", start_lineno);
if (!fmt)
fmt= "unknown error";
s+= my_vsnprintf(s, end - s, fmt, args);
s+= my_snprintf(s, end -s, "\n", start_lineno);
} }
void die(const char *fmt, ...) void die(const char *fmt, ...)
{ {
static int dying= 0; char buff[DIE_BUFF_SIZE];
va_list args; va_list args;
DBUG_ENTER("die"); va_start(args, fmt);
DBUG_PRINT("enter", ("start_lineno: %d", start_lineno)); make_error_message(buff, sizeof(buff), fmt, args);
really_die(buff);
}
void really_die(const char *msg)
{
static int dying= 0;
fflush(stdout); fflush(stdout);
/* Print the error message */ fprintf(stderr, "%s", msg);
fprintf(stderr, "mysqltest: ");
if (cur_file && cur_file != file_stack)
{
fprintf(stderr, "In included file \"%s\": \n",
cur_file->file_name);
print_file_stack();
}
if (start_lineno > 0)
fprintf(stderr, "At line %u: ", start_lineno);
if (fmt)
{
va_start(args, fmt);
vfprintf(stderr, fmt, args);
va_end(args);
}
else
fprintf(stderr, "unknown error");
fprintf(stderr, "\n");
fflush(stderr); fflush(stderr);
/* /*
@ -1504,6 +1530,28 @@ void die(const char *fmt, ...)
cleanup_and_exit(1); cleanup_and_exit(1);
} }
void report_or_die(const char *fmt, ...)
{
va_list args;
DBUG_ENTER("report_or_die");
char buff[DIE_BUFF_SIZE];
va_start(args, fmt);
make_error_message(buff, sizeof(buff), fmt, args);
va_end(args);
if (opt_continue_on_error)
{
/* Just log the error and continue */
replace_dynstr_append(&ds_res, buff);
error_count++;
DBUG_VOID_RETURN;
}
really_die(buff);
}
void abort_not_supported_test(const char *fmt, ...) void abort_not_supported_test(const char *fmt, ...)
{ {
@ -1516,7 +1564,10 @@ void abort_not_supported_test(const char *fmt, ...)
file_stack->file_name); file_stack->file_name);
fprintf(stderr, "Detected in file %s at line %d\n", fprintf(stderr, "Detected in file %s at line %d\n",
cur_file->file_name, cur_file->lineno); cur_file->file_name, cur_file->lineno);
print_file_stack();
char buff[DIE_BUFF_SIZE];
print_file_stack(buff, buff + sizeof(buff));
fprintf(stderr, "%s", buff);
/* Print error message */ /* Print error message */
va_start(args, fmt); va_start(args, fmt);
@ -1648,7 +1699,10 @@ static int run_command(char* cmd,
DBUG_PRINT("enter", ("cmd: %s", cmd)); DBUG_PRINT("enter", ("cmd: %s", cmd));
if (!(res_file= popen(cmd, "r"))) if (!(res_file= popen(cmd, "r")))
die("popen(\"%s\", \"r\") failed", cmd); {
report_or_die("popen(\"%s\", \"r\") failed", cmd);
return -1;
}
while (fgets(buf, sizeof(buf), res_file)) while (fgets(buf, sizeof(buf), res_file))
{ {
@ -1748,7 +1802,10 @@ static int diff_check(const char *diff_name)
if (!(res_file= popen(buf, "r"))) if (!(res_file= popen(buf, "r")))
die("popen(\"%s\", \"r\") failed", buf); die("popen(\"%s\", \"r\") failed", buf);
/* if diff is not present, nothing will be in stdout to increment have_diff */ /*
if diff is not present, nothing will be in stdout to increment
have_diff
*/
if (fgets(buf, sizeof(buf), res_file)) if (fgets(buf, sizeof(buf), res_file))
have_diff= 1; have_diff= 1;
@ -2061,7 +2118,7 @@ int dyn_string_cmp(DYNAMIC_STRING* ds, const char *fname)
void check_result() void check_result()
{ {
const char* mess= "Result content mismatch\n"; const char *mess= 0;
DBUG_ENTER("check_result"); DBUG_ENTER("check_result");
DBUG_ASSERT(result_file_name); DBUG_ASSERT(result_file_name);
@ -2069,9 +2126,13 @@ void check_result()
switch (compare_files(log_file.file_name(), result_file_name)) { switch (compare_files(log_file.file_name(), result_file_name)) {
case RESULT_OK: case RESULT_OK:
break; /* ok */ if (!error_count)
break; /* ok */
mess= "Got errors while running test";
/* Fallthrough */
case RESULT_LENGTH_MISMATCH: case RESULT_LENGTH_MISMATCH:
mess= "Result length mismatch\n"; if (!mess)
mess= "Result length mismatch\n";
/* Fallthrough */ /* Fallthrough */
case RESULT_CONTENT_MISMATCH: case RESULT_CONTENT_MISMATCH:
{ {
@ -2081,6 +2142,10 @@ void check_result()
*/ */
char reject_file[FN_REFLEN]; char reject_file[FN_REFLEN];
size_t reject_length; size_t reject_length;
if (!mess)
mess= "Result content mismatch\n";
dirname_part(reject_file, result_file_name, &reject_length); dirname_part(reject_file, result_file_name, &reject_length);
if (access(reject_file, W_OK) == 0) if (access(reject_file, W_OK) == 0)
@ -2180,8 +2245,8 @@ static int strip_surrounding(char* str, char c1, char c2)
static void strip_parentheses(struct st_command *command) static void strip_parentheses(struct st_command *command)
{ {
if (strip_surrounding(command->first_argument, '(', ')')) if (strip_surrounding(command->first_argument, '(', ')'))
die("%.*s - argument list started with '%c' must be ended with '%c'", die("%.*s - argument list started with '%c' must be ended with '%c'",
command->first_word_len, command->query, '(', ')'); command->first_word_len, command->query, '(', ')');
} }
@ -2500,6 +2565,19 @@ void var_query_set(VAR *var, const char *query, const char** query_end)
DBUG_ENTER("var_query_set"); DBUG_ENTER("var_query_set");
LINT_INIT(res); LINT_INIT(res);
if (!mysql)
{
struct st_command command;
memset(&command, 0, sizeof(command));
command.query= (char*)query;
command.first_word_len= (*query_end - query);
command.first_argument= command.query + command.first_word_len;
command.end= (char*)*query_end;
command.abort_on_error= 1; /* avoid uninitialized variables */
handle_no_active_connection(&command, cur_con, &ds_res);
DBUG_VOID_RETURN;
}
/* Only white space or ) allowed past ending ` */ /* Only white space or ) allowed past ending ` */
while (end > query && *end != '`') while (end > query && *end != '`')
{ {
@ -2518,8 +2596,8 @@ void var_query_set(VAR *var, const char *query, const char** query_end)
if (mysql_real_query(mysql, ds_query.str, ds_query.length)) if (mysql_real_query(mysql, ds_query.str, ds_query.length))
{ {
handle_error (curr_command, mysql_errno(mysql), mysql_error(mysql), handle_error(curr_command, mysql_errno(mysql), mysql_error(mysql),
mysql_sqlstate(mysql), &ds_res); mysql_sqlstate(mysql), &ds_res);
/* If error was acceptable, return empty string */ /* If error was acceptable, return empty string */
dynstr_free(&ds_query); dynstr_free(&ds_query);
eval_expr(var, "", 0); eval_expr(var, "", 0);
@ -2527,7 +2605,12 @@ void var_query_set(VAR *var, const char *query, const char** query_end)
} }
if (!(res= mysql_store_result(mysql))) if (!(res= mysql_store_result(mysql)))
die("Query '%s' didn't return a result set", ds_query.str); {
report_or_die("Query '%s' didn't return a result set", ds_query.str);
dynstr_free(&ds_query);
eval_expr(var, "", 0);
return;
}
dynstr_free(&ds_query); dynstr_free(&ds_query);
if ((row= mysql_fetch_row(res)) && row[0]) if ((row= mysql_fetch_row(res)) && row[0])
@ -2674,6 +2757,12 @@ void var_set_query_get_value(struct st_command *command, VAR *var)
DBUG_ENTER("var_set_query_get_value"); DBUG_ENTER("var_set_query_get_value");
LINT_INIT(res); LINT_INIT(res);
if (!mysql)
{
handle_no_active_connection(command, cur_con, &ds_res);
DBUG_VOID_RETURN;
}
strip_parentheses(command); strip_parentheses(command);
DBUG_PRINT("info", ("query: %s", command->query)); DBUG_PRINT("info", ("query: %s", command->query));
check_command_args(command, command->first_argument, query_get_value_args, check_command_args(command, command->first_argument, query_get_value_args,
@ -2696,16 +2785,23 @@ void var_set_query_get_value(struct st_command *command, VAR *var)
/* Run the query */ /* Run the query */
if (mysql_real_query(mysql, ds_query.str, ds_query.length)) if (mysql_real_query(mysql, ds_query.str, ds_query.length))
{ {
handle_error (curr_command, mysql_errno(mysql), mysql_error(mysql), handle_error(curr_command, mysql_errno(mysql), mysql_error(mysql),
mysql_sqlstate(mysql), &ds_res); mysql_sqlstate(mysql), &ds_res);
/* If error was acceptable, return empty string */ /* If error was acceptable, return empty string */
dynstr_free(&ds_query); dynstr_free(&ds_query);
dynstr_free(&ds_col);
eval_expr(var, "", 0); eval_expr(var, "", 0);
DBUG_VOID_RETURN; DBUG_VOID_RETURN;
} }
if (!(res= mysql_store_result(mysql))) if (!(res= mysql_store_result(mysql)))
die("Query '%s' didn't return a result set", ds_query.str); {
report_or_die("Query '%s' didn't return a result set", ds_query.str);
dynstr_free(&ds_query);
dynstr_free(&ds_col);
eval_expr(var, "", 0);
return;
}
{ {
/* Find column number from the given column name */ /* Find column number from the given column name */
@ -2725,8 +2821,11 @@ void var_set_query_get_value(struct st_command *command, VAR *var)
if (col_no == -1) if (col_no == -1)
{ {
mysql_free_result(res); mysql_free_result(res);
die("Could not find column '%s' in the result of '%s'", report_or_die("Could not find column '%s' in the result of '%s'",
ds_col.str, ds_query.str); ds_col.str, ds_query.str);
dynstr_free(&ds_query);
dynstr_free(&ds_col);
return;
} }
DBUG_PRINT("info", ("Found column %d with name '%s'", DBUG_PRINT("info", ("Found column %d with name '%s'",
i, fields[i].name)); i, fields[i].name));
@ -2834,6 +2933,7 @@ void eval_expr(VAR *v, const char *p, const char **p_end,
command.first_word_len= len; command.first_word_len= len;
command.first_argument= command.query + len; command.first_argument= command.query + len;
command.end= (char*)*p_end; command.end= (char*)*p_end;
command.abort_on_error= 1; /* avoid uninitialized variables */
var_set_query_get_value(&command, v); var_set_query_get_value(&command, v);
DBUG_VOID_RETURN; DBUG_VOID_RETURN;
} }
@ -3165,7 +3265,10 @@ void do_exec(struct st_command *command)
while (*cmd && my_isspace(charset_info, *cmd)) while (*cmd && my_isspace(charset_info, *cmd))
cmd++; cmd++;
if (!*cmd) if (!*cmd)
die("Missing argument in exec"); {
report_or_die("Missing argument in exec");
return;
}
command->last_argument= command->end; command->last_argument= command->end;
init_dynamic_string(&ds_cmd, 0, command->query_len+256, 256); init_dynamic_string(&ds_cmd, 0, command->query_len+256, 256);
@ -3197,10 +3300,12 @@ void do_exec(struct st_command *command)
DBUG_PRINT("info", ("Executing '%s' as '%s'", DBUG_PRINT("info", ("Executing '%s' as '%s'",
command->first_argument, ds_cmd.str)); command->first_argument, ds_cmd.str));
if (!(res_file= my_popen(&ds_cmd, "r")) && command->abort_on_error) if (!(res_file= my_popen(&ds_cmd, "r")))
{ {
dynstr_free(&ds_cmd); dynstr_free(&ds_cmd);
die("popen(\"%s\", \"r\") failed", command->first_argument); if (command->abort_on_error)
report_or_die("popen(\"%s\", \"r\") failed", command->first_argument);
return;
} }
ds_result= &ds_res; ds_result= &ds_res;
@ -3237,11 +3342,12 @@ void do_exec(struct st_command *command)
if (command->abort_on_error) if (command->abort_on_error)
{ {
log_msg("exec of '%s' failed, error: %d, status: %d, errno: %d", report_or_die("exec of '%s' failed, error: %d, status: %d, errno: %d\n"
ds_cmd.str, error, status, errno); "Output from before failure:\n%s\n",
ds_cmd.str, error, status, errno,
ds_res.str);
dynstr_free(&ds_cmd); dynstr_free(&ds_cmd);
die("command \"%s\" failed\n\nOutput from before failure:\n%s\n", return;
command->first_argument, ds_res.str);
} }
DBUG_PRINT("info", DBUG_PRINT("info",
@ -3256,8 +3362,8 @@ void do_exec(struct st_command *command)
{ {
dynstr_free(&ds_cmd); dynstr_free(&ds_cmd);
if (command->expected_errors.count > 0) if (command->expected_errors.count > 0)
die("command \"%s\" failed with wrong error: %d", report_or_die("command \"%s\" failed with wrong error: %d",
command->first_argument, status); command->first_argument, status);
} }
} }
else if (command->expected_errors.err[0].type == ERR_ERRNO && else if (command->expected_errors.err[0].type == ERR_ERRNO &&
@ -3267,8 +3373,10 @@ void do_exec(struct st_command *command)
log_msg("exec of '%s failed, error: %d, errno: %d", log_msg("exec of '%s failed, error: %d, errno: %d",
ds_cmd.str, error, errno); ds_cmd.str, error, errno);
dynstr_free(&ds_cmd); dynstr_free(&ds_cmd);
die("command \"%s\" succeeded - should have failed with errno %d...", report_or_die("command \"%s\" succeeded - should have failed with "
command->first_argument, command->expected_errors.err[0].code.errnum); "errno %d...",
command->first_argument,
command->expected_errors.err[0].code.errnum);
} }
dynstr_free(&ds_cmd); dynstr_free(&ds_cmd);
@ -3302,7 +3410,8 @@ int do_modify_var(struct st_command *command,
const char *p= command->first_argument; const char *p= command->first_argument;
VAR* v; VAR* v;
if (!*p) if (!*p)
die("Missing argument to %.*s", command->first_word_len, command->query); die("Missing argument to %.*s", command->first_word_len,
command->query);
if (*p != '$') if (*p != '$')
die("The argument to %.*s must be a variable (start with $)", die("The argument to %.*s must be a variable (start with $)",
command->first_word_len, command->query); command->first_word_len, command->query);
@ -3368,7 +3477,10 @@ void do_system(struct st_command *command)
DBUG_ENTER("do_system"); DBUG_ENTER("do_system");
if (strlen(command->first_argument) == 0) if (strlen(command->first_argument) == 0)
die("Missing arguments to system, nothing to do!"); {
report_or_die("Missing arguments to system, nothing to do!");
return;
}
init_dynamic_string(&ds_cmd, 0, command->query_len + 64, 256); init_dynamic_string(&ds_cmd, 0, command->query_len + 64, 256);
@ -3389,12 +3501,14 @@ void do_system(struct st_command *command)
if (my_system(&ds_cmd)) if (my_system(&ds_cmd))
{ {
if (command->abort_on_error) if (command->abort_on_error)
die("system command '%s' failed", command->first_argument); report_or_die("system command '%s' failed", command->first_argument);
else
/* If ! abort_on_error, log message and continue */ {
dynstr_append(&ds_res, "system command '"); /* If ! abort_on_error, log message and continue */
replace_dynstr_append(&ds_res, command->first_argument); dynstr_append(&ds_res, "system command '");
dynstr_append(&ds_res, "' failed\n"); replace_dynstr_append(&ds_res, command->first_argument);
dynstr_append(&ds_res, "' failed\n");
}
} }
command->last_argument= command->end; command->last_argument= command->end;
@ -3941,12 +4055,12 @@ void read_until_delimiter(DYNAMIC_STRING *ds,
No characters except \n are allowed on No characters except \n are allowed on
the same line as the command the same line as the command
*/ */
die("Trailing characters found after command"); report_or_die("Trailing characters found after command");
} }
if (feof(cur_file->file)) if (feof(cur_file->file))
die("End of file encountered before '%s' delimiter was found", report_or_die("End of file encountered before '%s' delimiter was found",
ds_delimiter->str); ds_delimiter->str);
if (match_delimiter(c, ds_delimiter->str, ds_delimiter->length)) if (match_delimiter(c, ds_delimiter->str, ds_delimiter->length))
{ {
@ -4350,8 +4464,13 @@ void do_perl(struct st_command *command)
/* Format the "perl <filename>" command */ /* Format the "perl <filename>" command */
my_snprintf(buf, sizeof(buf), "perl %s", temp_file_path); my_snprintf(buf, sizeof(buf), "perl %s", temp_file_path);
if (!(res_file= popen(buf, "r")) && command->abort_on_error) if (!(res_file= popen(buf, "r")))
die("popen(\"%s\", \"r\") failed", buf); {
if (command->abort_on_error)
die("popen(\"%s\", \"r\") failed", buf);
dynstr_free(&ds_delimiter);
return;
}
while (fgets(buf, sizeof(buf), res_file)) while (fgets(buf, sizeof(buf), res_file))
{ {
@ -4506,14 +4625,14 @@ void do_sync_with_master2(struct st_command *command, long offset)
information is not initialized, the arguments are information is not initialized, the arguments are
incorrect, or an error has occured incorrect, or an error has occured
*/ */
die("%.*s failed: '%s' returned NULL "\ die("%.*s failed: '%s' returned NULL " \
"indicating slave SQL thread failure", "indicating slave SQL thread failure",
command->first_word_len, command->query, query_buf); command->first_word_len, command->query, query_buf);
} }
if (result == -1) if (result == -1)
die("%.*s failed: '%s' returned -1 "\ die("%.*s failed: '%s' returned -1 " \
"indicating timeout after %d seconds", "indicating timeout after %d seconds",
command->first_word_len, command->query, query_buf, timeout); command->first_word_len, command->query, query_buf, timeout);
else else
@ -4808,7 +4927,8 @@ int do_sleep(struct st_command *command, my_bool real_sleep)
while (my_isspace(charset_info, *p)) while (my_isspace(charset_info, *p))
p++; p++;
if (!*p) if (!*p)
die("Missing argument to %.*s", command->first_word_len, command->query); die("Missing argument to %.*s", command->first_word_len,
command->query);
sleep_start= p; sleep_start= p;
/* Check that arg starts with a digit, not handled by my_strtod */ /* Check that arg starts with a digit, not handled by my_strtod */
if (!my_isdigit(charset_info, *sleep_start)) if (!my_isdigit(charset_info, *sleep_start))
@ -4880,16 +5000,21 @@ int query_get_string(MYSQL* mysql, const char* query,
MYSQL_ROW row; MYSQL_ROW row;
if (mysql_query(mysql, query)) if (mysql_query(mysql, query))
die("'%s' failed: %d %s", query, {
mysql_errno(mysql), mysql_error(mysql)); report_or_die("'%s' failed: %d %s", query,
mysql_errno(mysql), mysql_error(mysql));
return 1;
}
if ((res= mysql_store_result(mysql)) == NULL) if ((res= mysql_store_result(mysql)) == NULL)
die("Failed to store result: %d %s", {
mysql_errno(mysql), mysql_error(mysql)); report_or_die("Failed to store result: %d %s",
mysql_errno(mysql), mysql_error(mysql));
return 1;
}
if ((row= mysql_fetch_row(res)) == NULL) if ((row= mysql_fetch_row(res)) == NULL)
{ {
mysql_free_result(res); mysql_free_result(res);
ds= 0;
return 1; return 1;
} }
init_dynamic_string(ds, (row[column] ? row[column] : "NULL"), ~0, 32); init_dynamic_string(ds, (row[column] ? row[column] : "NULL"), ~0, 32);
@ -5161,7 +5286,7 @@ void do_get_errcodes(struct st_command *command)
while (*p && p != end) while (*p && p != end)
{ {
if (!my_isdigit(charset_info, *p)) if (!my_isdigit(charset_info, *p))
die("Invalid argument to error: '%s' - "\ die("Invalid argument to error: '%s' - " \
"the errno may only consist of digits[0-9]", "the errno may only consist of digits[0-9]",
command->first_argument); command->first_argument);
p++; p++;
@ -6084,7 +6209,7 @@ void do_block(enum block_cmd cmd, struct st_command* command)
eval_expr(&v2, curr_ptr, &expr_end); eval_expr(&v2, curr_ptr, &expr_end);
if ((operand!=EQ_OP && operand!=NE_OP) && ! (v.is_int && v2.is_int)) if ((operand!=EQ_OP && operand!=NE_OP) && ! (v.is_int && v2.is_int))
die ("Only == and != are supported for string values"); die("Only == and != are supported for string values");
/* Now we overwrite the first variable with 0 or 1 (for false or true) */ /* Now we overwrite the first variable with 0 or 1 (for false or true) */
@ -6442,7 +6567,7 @@ int read_line(char *buf, int size)
*p++= c; *p++= c;
} }
} }
die("The input buffer is too small for this query.x\n" \ die("The input buffer is too small for this query.x\n" \
"check your query or increase MAX_QUERY and recompile"); "check your query or increase MAX_QUERY and recompile");
DBUG_RETURN(0); DBUG_RETURN(0);
} }
@ -6675,6 +6800,12 @@ static struct my_option my_long_options[] =
{"compress", 'C', "Use the compressed server/client protocol.", {"compress", 'C', "Use the compressed server/client protocol.",
&opt_compress, &opt_compress, 0, GET_BOOL, NO_ARG, 0, 0, 0, &opt_compress, &opt_compress, 0, GET_BOOL, NO_ARG, 0, 0, 0,
0, 0, 0}, 0, 0, 0},
{"continue-on-error", 0,
"Continue test even if we got an error. "
"This is mostly useful when testing a storage engine to see what from a test file it can execute, "
"or to find all syntax errors in a newly created big test file",
&opt_continue_on_error, &opt_continue_on_error, 0,
GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0},
{"cursor-protocol", 0, "Use cursors for prepared statements.", {"cursor-protocol", 0, "Use cursors for prepared statements.",
&cursor_protocol, &cursor_protocol, 0, &cursor_protocol, &cursor_protocol, 0,
GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0}, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0},
@ -7006,7 +7137,8 @@ int parse_args(int argc, char **argv)
{ {
/* Check that the result file exists */ /* Check that the result file exists */
if (result_file_name && access(result_file_name, F_OK) != 0) if (result_file_name && access(result_file_name, F_OK) != 0)
die("The specified result file '%s' does not exist", result_file_name); die("The specified result file '%s' does not exist",
result_file_name);
} }
return 0; return 0;
@ -7333,8 +7465,8 @@ void append_stmt_result(DYNAMIC_STRING *ds, MYSQL_STMT *stmt,
} }
if (error != MYSQL_NO_DATA) if (error != MYSQL_NO_DATA)
die("mysql_fetch didn't end with MYSQL_NO_DATA from statement: error: %d", die("mysql_fetch didn't end with MYSQL_NO_DATA from statement: "
error); "error: %d", error);
if (mysql_stmt_fetch(stmt) != MYSQL_NO_DATA) if (mysql_stmt_fetch(stmt) != MYSQL_NO_DATA)
die("mysql_fetch didn't end with MYSQL_NO_DATA from statement: %d %s", die("mysql_fetch didn't end with MYSQL_NO_DATA from statement: %d %s",
mysql_stmt_errno(stmt), mysql_stmt_error(stmt)); mysql_stmt_errno(stmt), mysql_stmt_error(stmt));
@ -7481,6 +7613,22 @@ int append_warnings(DYNAMIC_STRING *ds, MYSQL* mysql)
} }
/*
Handle situation where query is sent but there is no active connection
(e.g directly after disconnect).
We emulate MySQL-compatible behaviour of sending something on a closed
connection.
*/
static void handle_no_active_connection(struct st_command *command,
struct st_connection *cn, DYNAMIC_STRING *ds)
{
handle_error(command, 2006, "MySQL server has gone away", "000000", ds);
cn->pending= FALSE;
var_set_errno(2006);
}
/* /*
Run query using MySQL C API Run query using MySQL C API
@ -7507,11 +7655,7 @@ void run_query_normal(struct st_connection *cn, struct st_command *command,
if (!mysql) if (!mysql)
{ {
/* Emulate old behaviour of sending something on a closed connection */ handle_no_active_connection(command, cn, ds);
handle_error(command, 2006, "MySQL server has gone away",
"000000", ds);
cn->pending= FALSE;
var_set_errno(2006);
DBUG_VOID_RETURN; DBUG_VOID_RETURN;
} }
@ -7666,7 +7810,8 @@ static int match_expected_error(struct st_command *command,
NULL is quite likely, but not in conjunction with a SQL-state expect! NULL is quite likely, but not in conjunction with a SQL-state expect!
*/ */
if (unlikely(err_sqlstate == NULL)) if (unlikely(err_sqlstate == NULL))
die("expecting a SQL-state (%s) from query '%s' which cannot produce one...", die("expecting a SQL-state (%s) from query '%s' which cannot "
"produce one...",
command->expected_errors.err[i].code.sqlstate, command->query); command->expected_errors.err[i].code.sqlstate, command->query);
if (strncmp(command->expected_errors.err[i].code.sqlstate, if (strncmp(command->expected_errors.err[i].code.sqlstate,
@ -7720,7 +7865,11 @@ void handle_error(struct st_command *command,
} }
if (command->abort_on_error) if (command->abort_on_error)
die("query '%s' failed: %d: %s", command->query, err_errno, err_error); {
report_or_die("query '%s' failed: %d: %s", command->query, err_errno,
err_error);
DBUG_VOID_RETURN;
}
DBUG_PRINT("info", ("expected_errors.count: %d", DBUG_PRINT("info", ("expected_errors.count: %d",
command->expected_errors.count)); command->expected_errors.count));
@ -7766,13 +7915,15 @@ void handle_error(struct st_command *command,
if (command->expected_errors.count > 0) if (command->expected_errors.count > 0)
{ {
if (command->expected_errors.err[0].type == ERR_ERRNO) if (command->expected_errors.err[0].type == ERR_ERRNO)
die("query '%s' failed with wrong errno %d: '%s', instead of %d...", report_or_die("query '%s' failed with wrong errno %d: '%s', instead of "
command->query, err_errno, err_error, "%d...",
command->expected_errors.err[0].code.errnum); command->query, err_errno, err_error,
command->expected_errors.err[0].code.errnum);
else else
die("query '%s' failed with wrong sqlstate %s: '%s', instead of %s...", report_or_die("query '%s' failed with wrong sqlstate %s: '%s', "
command->query, err_sqlstate, err_error, "instead of %s...",
command->expected_errors.err[0].code.sqlstate); command->query, err_sqlstate, err_error,
command->expected_errors.err[0].code.sqlstate);
} }
revert_properties(); revert_properties();
@ -7799,15 +7950,17 @@ void handle_no_error(struct st_command *command)
command->expected_errors.err[0].code.errnum != 0) command->expected_errors.err[0].code.errnum != 0)
{ {
/* Error code we wanted was != 0, i.e. not an expected success */ /* Error code we wanted was != 0, i.e. not an expected success */
die("query '%s' succeeded - should have failed with errno %d...", report_or_die("query '%s' succeeded - should have failed with errno %d...",
command->query, command->expected_errors.err[0].code.errnum); command->query, command->expected_errors.err[0].code.errnum);
} }
else if (command->expected_errors.err[0].type == ERR_SQLSTATE && else if (command->expected_errors.err[0].type == ERR_SQLSTATE &&
strcmp(command->expected_errors.err[0].code.sqlstate,"00000") != 0) strcmp(command->expected_errors.err[0].code.sqlstate,"00000") != 0)
{ {
/* SQLSTATE we wanted was != "00000", i.e. not an expected success */ /* SQLSTATE we wanted was != "00000", i.e. not an expected success */
die("query '%s' succeeded - should have failed with sqlstate %s...", report_or_die("query '%s' succeeded - should have failed with "
command->query, command->expected_errors.err[0].code.sqlstate); "sqlstate %s...",
command->query,
command->expected_errors.err[0].code.sqlstate);
} }
DBUG_VOID_RETURN; DBUG_VOID_RETURN;
} }
@ -8105,10 +8258,10 @@ void run_query(struct st_connection *cn, struct st_command *command, int flags)
DBUG_ENTER("run_query"); DBUG_ENTER("run_query");
if (cn->pending && (flags & QUERY_SEND_FLAG)) if (cn->pending && (flags & QUERY_SEND_FLAG))
die ("Cannot run query on connection between send and reap"); die("Cannot run query on connection between send and reap");
if (!(flags & QUERY_SEND_FLAG) && !cn->pending) if (!(flags & QUERY_SEND_FLAG) && !cn->pending)
die ("Cannot reap on a connection without pending send"); die("Cannot reap on a connection without pending send");
init_dynamic_string(&ds_warnings, NULL, 0, 256); init_dynamic_string(&ds_warnings, NULL, 0, 256);
ds_warn= &ds_warnings; ds_warn= &ds_warnings;
@ -8293,13 +8446,14 @@ void run_query(struct st_connection *cn, struct st_command *command, int flags)
if (sp_created) if (sp_created)
{ {
if (util_query(mysql, "DROP PROCEDURE mysqltest_tmp_sp ")) if (util_query(mysql, "DROP PROCEDURE mysqltest_tmp_sp "))
die("Failed to drop sp: %d: %s", mysql_errno(mysql), mysql_error(mysql)); report_or_die("Failed to drop sp: %d: %s", mysql_errno(mysql),
mysql_error(mysql));
} }
if (view_created) if (view_created)
{ {
if (util_query(mysql, "DROP VIEW mysqltest_tmp_v ")) if (util_query(mysql, "DROP VIEW mysqltest_tmp_v "))
die("Failed to drop view: %d: %s", report_or_die("Failed to drop view: %d: %s",
mysql_errno(mysql), mysql_error(mysql)); mysql_errno(mysql), mysql_error(mysql));
} }
@ -8463,9 +8617,10 @@ void get_command_type(struct st_command* command)
else else
{ {
/* -- "comment" that didn't contain a mysqltest command */ /* -- "comment" that didn't contain a mysqltest command */
die("Found line beginning with -- that didn't contain "\ report_or_die("Found line beginning with -- that didn't contain " \
"a valid mysqltest command, check your syntax or "\ "a valid mysqltest command, check your syntax or " \
"use # if you intended to write a comment"); "use # if you intended to write a comment");
command->type= Q_COMMENT;
} }
} }
@ -9190,7 +9345,7 @@ int main(int argc, char **argv)
if (parsing_disabled == 0) if (parsing_disabled == 0)
parsing_disabled= 1; parsing_disabled= 1;
else else
die("Parsing is already disabled"); report_or_die("Parsing is already disabled");
break; break;
case Q_ENABLE_PARSING: case Q_ENABLE_PARSING:
/* /*
@ -9200,7 +9355,7 @@ int main(int argc, char **argv)
if (parsing_disabled == 1) if (parsing_disabled == 1)
parsing_disabled= 0; parsing_disabled= 0;
else else
die("Parsing is already enabled"); report_or_die("Parsing is already enabled");
break; break;
case Q_DIE: case Q_DIE:
/* Abort test with error code and error message */ /* Abort test with error code and error message */
@ -9404,7 +9559,8 @@ void do_get_replace_column(struct st_command *command)
if (!(column_number= atoi(to)) || column_number > MAX_COLUMNS) if (!(column_number= atoi(to)) || column_number > MAX_COLUMNS)
die("Wrong column number to replace_column in '%s'", command->query); die("Wrong column number to replace_column in '%s'", command->query);
if (!*from) if (!*from)
die("Wrong number of arguments to replace_column in '%s'", command->query); die("Wrong number of arguments to replace_column in '%s'",
command->query);
to= get_string(&buff, &from, command); to= get_string(&buff, &from, command);
my_free(replace_column[column_number-1]); my_free(replace_column[column_number-1]);
replace_column[column_number-1]= my_strdup(to, MYF(MY_WME | MY_FAE)); replace_column[column_number-1]= my_strdup(to, MYF(MY_WME | MY_FAE));

129
cmake/cpack_rpm.cmake Normal file
View File

@ -0,0 +1,129 @@
IF(RPM)
SET(CPACK_GENERATOR "RPM")
SET(CPACK_RPM_PACKAGE_DEBUG 1)
SET(INSTALL_LAYOUT "RPM")
CMAKE_MINIMUM_REQUIRED(VERSION 2.8.7)
SET(CPACK_RPM_COMPONENT_INSTALL ON)
SET(CPACK_COMPONENT_SERVER_GROUP "server")
SET(CPACK_COMPONENT_MANPAGESSERVER_GROUP "server")
SET(CPACK_COMPONENT_INIFILES_GROUP "server")
SET(CPACK_COMPONENT_SERVER_SCRIPTS_GROUP "server")
SET(CPACK_COMPONENT_SUPPORTFILES_GROUP "server")
SET(CPACK_COMPONENT_DEVELOPMENT_GROUP "devel")
SET(CPACK_COMPONENT_MANPAGESDEVELOPMENT_GROUP "devel")
SET(CPACK_COMPONENT_TEST_GROUP "test")
SET(CPACK_COMPONENT_MANPAGESTEST_GROUP "test")
SET(CPACK_COMPONENT_CLIENT_GROUP "client")
SET(CPACK_COMPONENT_MANPAGESCLIENT_GROUP "client")
SET(CPACK_COMPONENT_README_GROUP "server")
SET(CPACK_COMPONENT_SHAREDLIBRARIES_GROUP "shared")
SET(CPACK_COMPONENT_COMMON_GROUP "common")
SET(CPACK_COMPONENT_COMPAT_GROUP "compat")
SET(CPACK_COMPONENTS_ALL Server ManPagesServer IniFiles Server_Scripts
SupportFiles Development ManPagesDevelopment
ManPagesTest Readme ManPagesClient Test
Common Client SharedLibraries)
SET(CPACK_RPM_PACKAGE_NAME "MariaDB")
SET(CPACK_PACKAGE_FILE_NAME "${CPACK_RPM_PACKAGE_NAME}-${VERSION}-${RPM}-${CMAKE_SYSTEM_PROCESSOR}")
SET(CPACK_RPM_PACKAGE_RELEASE 1) # FIX: add distribution name here
SET(CPACK_RPM_PACKAGE_LICENSE "GPL")
SET(CPACK_RPM_PACKAGE_RELOCATABLE FALSE)
SET(CPACK_RPM_PACKAGE_GROUP "Applications/Databases")
SET(CPACK_RPM_PACKAGE_URL "http://mariadb.org")
SET(CPACK_RPM_PACKAGE_SUMMARY "MariaDB: a very fast and robust SQL database server")
SET(CPACK_RPM_PACKAGE_DESCRIPTION "${CPACK_RPM_PACKAGE_SUMMARY}
It is GPL v2 licensed, which means you can use the it free of charge under the
conditions of the GNU General Public License Version 2 (http://www.gnu.org/licenses/).
MariaDB documentation can be found at http://kb.askmonty.org/
MariaDB bug reports should be submitted through https://mariadb.atlassian.net/
")
SET(CPACK_RPM_SPEC_MORE_DEFINE "
%define mysql_vendor ${CPACK_PACKAGE_VENDOR}
%define mysqlversion ${MYSQL_NO_DASH_VERSION}
%define mysqldatadir /var/lib/mysql
%define mysqld_user mysql
%define mysqld_group mysql
")
# this creative hack is described here: http://www.cmake.org/pipermail/cmake/2012-January/048416.html
# both /etc and /etc/init.d should be ignored as of 2.8.7
# only /etc/init.d as of 2.8.8
# and eventually this hack should go away completely
SET(CPACK_RPM_SPEC_MORE_DEFINE "${CPACK_RPM_SPEC_MORE_DEFINE}
%define ignore \#
")
SET(CPACK_RPM_PACKAGE_REQUIRES "MariaDB-common")
SET(CPACK_RPM_server_USER_FILELIST "%ignore /etc" "%ignore /etc/init.d")
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")
# this is a workaround for CPackRPM.cmake (as of 2.8.8) bug.
# If a package group does not specify OBSOLETES/REQUIRES the values of the
# previous (alphabetically) group will apply.
SET(CPACK_RPM_common_PACKAGE_OBSOLETES "MySQL-common")
SET(CPACK_RPM_common_PACKAGE_PROVIDES "MariaDB-common")
SET(CPACK_RPM_devel_PACKAGE_OBSOLETES "mysql-devel MySQL-devel MySQL-OurDelta-devel")
SET(CPACK_RPM_devel_PACKAGE_PROVIDES "MariaDB-devel MySQL-devel mysql-devel")
SET(CPACK_RPM_server_PACKAGE_OBSOLETES "MariaDB mysql mysql-server MySQL-server MySQL-OurDelta-server")
SET(CPACK_RPM_server_PACKAGE_PROVIDES "MariaDB MariaDB-server MySQL-server config(MariaDB-server) msqlormysql mysql mysql-server")
SET(CPACK_RPM_server_PRE_INSTALL_SCRIPT_FILE ${CMAKE_SOURCE_DIR}/support-files/rpm/server-prein.sh)
SET(CPACK_RPM_server_PRE_UNINSTALL_SCRIPT_FILE ${CMAKE_SOURCE_DIR}/support-files/rpm/server-preun.sh)
SET(CPACK_RPM_server_POST_INSTALL_SCRIPT_FILE ${CMAKE_SOURCE_DIR}/support-files/rpm/server-postin.sh)
SET(CPACK_RPM_shared_PACKAGE_OBSOLETES "mysql-shared MySQL-shared-standard MySQL-shared-pro MySQL-shared-pro-cert MySQL-shared-pro-gpl MySQL-shared-pro-gpl-cert MySQL-shared MySQL-OurDelta-shared")
SET(CPACK_RPM_shared_PACKAGE_PROVIDES "MariaDB-shared MySQL-shared mysql-shared libmysqlclient.so.${SHARED_LIB_MAJOR_VERSION} libmysqlclient.so.${SHARED_LIB_MAJOR_VERSION}(libmysqlclient_${SHARED_LIB_MAJOR_VERSION}) libmysqlclient_r.so.${SHARED_LIB_MAJOR_VERSION} libmysqlclient_r.so.${SHARED_LIB_MAJOR_VERSION}(libmysqlclient_${SHARED_LIB_MAJOR_VERSION})")
SET(CPACK_RPM_shared_POST_INSTALL_SCRIPT_FILE ${CMAKE_SOURCE_DIR}/support-files/rpm/shared-post.sh)
SET(CPACK_RPM_shared_POST_UNINSTALL_SCRIPT_FILE ${CMAKE_SOURCE_DIR}/support-files/rpm/shared-post.sh)
SET(CPACK_RPM_test_PACKAGE_OBSOLETES "mysql-test MySQL-test MySQL-OurDelta-test")
SET(CPACK_RPM_test_PACKAGE_PROVIDES "MariaDB-test MySQL-test mysql-test")
# workaround for lots of perl dependencies added by rpmbuild
SET(CPACK_RPM_test_PACKAGE_PROVIDES "${CPACK_RPM_test_PACKAGE_PROVIDES} perl(lib::mtr_gcov.pl) perl(lib::mtr_gprof.pl) perl(lib::mtr_io.pl) perl(lib::mtr_misc.pl) perl(lib::mtr_process.pl) perl(lib::v1/mtr_cases.pl) perl(lib::v1/mtr_gcov.pl) perl(lib::v1/mtr_gprof.pl) perl(lib::v1/mtr_im.pl) perl(lib::v1/mtr_io.pl) perl(lib::v1/mtr_match.pl) perl(lib::v1/mtr_misc.pl) perl(lib::v1/mtr_process.pl) perl(lib::v1/mtr_report.pl) perl(lib::v1/mtr_stress.pl) perl(lib::v1/mtr_timer.pl) perl(lib::v1/mtr_unique.pl) perl(mtr_misc.pl)")
# If we want to build build MariaDB-shared-compat,
# extract compat libraries from MariaDB-shared-5.3 rpm
FILE(GLOB compat_rpm RELATIVE ${CMAKE_SOURCE_DIR}
"${CMAKE_SOURCE_DIR}/../MariaDB-shared-5.3.*.rpm")
IF (compat_rpm)
MESSAGE("Using ${compat_rpm} to build MariaDB-compat")
INSTALL(CODE "EXECUTE_PROCESS(
COMMAND rpm2cpio ${CMAKE_SOURCE_DIR}/${compat_rpm}
COMMAND cpio --extract --make-directories */libmysqlclient*.so.* -
WORKING_DIRECTORY \$ENV{DESTDIR})
EXECUTE_PROCESS(
COMMAND chmod -R a+rX .
WORKING_DIRECTORY \$ENV{DESTDIR})"
COMPONENT Compat)
SET(CPACK_COMPONENTS_ALL ${CPACK_COMPONENTS_ALL} Compat)
# RHEL6/CentOS6 install Postfix by default, and it requires
# libmysqlclient.so.16 that pulls in mysql-libs-5.1.x
# And the latter conflicts with our rpms.
# Make sure that for these distribuions all our rpms require
# MariaDB-compat, that will replace mysql-libs-5.1
IF(RPM MATCHES "(rhel|centos)6")
SET(CPACK_RPM_common_PACKAGE_REQUIRES "MariaDB-compat")
ENDIF()
ENDIF(compat_rpm)
SET(CPACK_RPM_compat_PACKAGE_REQUIRES "/bin/sh") # to mask CPACK_RPM_PACKAGE_REQUIRES
SET(CPACK_RPM_compat_PACKAGE_PROVIDES "mysql-libs = 5.3.5") # exact version doesn't matter as long as it greater than 5.1
SET(CPACK_RPM_compat_PACKAGE_OBSOLETES "mysql-libs < 5.3.5")
ENDIF(RPM)

View File

@ -41,6 +41,7 @@
# - INSTALL_BINDIR (directory with client executables and scripts) # - INSTALL_BINDIR (directory with client executables and scripts)
# - INSTALL_SBINDIR (directory with mysqld) # - INSTALL_SBINDIR (directory with mysqld)
# - INSTALL_SCRIPTDIR (several scripts, rarely used) # - INSTALL_SCRIPTDIR (several scripts, rarely used)
# - INSTALL_SYSCONFDIR (config files. Usually /etc or nothing)
# #
# - INSTALL_LIBDIR (directory with client end embedded libraries) # - INSTALL_LIBDIR (directory with client end embedded libraries)
# - INSTALL_PLUGINDIR (directory for plugins) # - INSTALL_PLUGINDIR (directory for plugins)
@ -60,23 +61,23 @@
# #
# - INSTALL_MYSQLDATADIR (data directory) # - INSTALL_MYSQLDATADIR (data directory)
# #
# - INSTALL_UNIX_ADDRDIR (path to mysql.sock)
#
# When changing this page, _please_ do not forget to update public Wiki # When changing this page, _please_ do not forget to update public Wiki
# http://forge.mysql.com/wiki/CMake#Fine-tuning_installation_paths # http://forge.mysql.com/wiki/CMake#Fine-tuning_installation_paths
IF(NOT INSTALL_LAYOUT) IF(NOT INSTALL_LAYOUT)
SET(DEFAULT_INSTALL_LAYOUT "STANDALONE") SET(INSTALL_LAYOUT "STANDALONE")
ENDIF() ENDIF()
SET(INSTALL_LAYOUT "${DEFAULT_INSTALL_LAYOUT}" SET(INSTALL_LAYOUT "${INSTALL_LAYOUT}"
CACHE STRING "Installation directory layout. Options are: STANDALONE (as in zip or tar.gz installer) RPM DEB SVR4") CACHE STRING "Installation directory layout. Options are: STANDALONE (as in zip or tar.gz installer) RPM DEB SVR4")
IF(UNIX) IF(UNIX)
IF(INSTALL_LAYOUT MATCHES "RPM") IF(INSTALL_LAYOUT MATCHES "RPM")
SET(default_prefix "/usr") SET(default_prefix "/usr")
ELSEIF(INSTALL_LAYOUT MATCHES "DEB") ELSEIF(INSTALL_LAYOUT MATCHES "DEB")
SET(default_prefix "/opt/mysql/server-${MYSQL_BASE_VERSION}") SET(default_prefix "/usr")
# This is required to avoid "cpack -GDEB" default of prefix=/usr
SET(CPACK_SET_DESTDIR ON)
ELSEIF(INSTALL_LAYOUT MATCHES "SVR4") ELSEIF(INSTALL_LAYOUT MATCHES "SVR4")
SET(default_prefix "/opt/mysql/mysql") SET(default_prefix "/opt/mysql/mysql")
ELSE() ELSE()
@ -92,10 +93,6 @@ IF(UNIX)
MESSAGE(FATAL_ERROR "Invalid INSTALL_LAYOUT parameter:${INSTALL_LAYOUT}." MESSAGE(FATAL_ERROR "Invalid INSTALL_LAYOUT parameter:${INSTALL_LAYOUT}."
" Choose between ${VALID_INSTALL_LAYOUTS}" ) " Choose between ${VALID_INSTALL_LAYOUTS}" )
ENDIF() ENDIF()
SET(SYSCONFDIR "${CMAKE_INSTALL_PREFIX}/etc"
CACHE PATH "config directory (for my.cnf)")
MARK_AS_ADVANCED(SYSCONFDIR)
ENDIF() ENDIF()
# #
@ -131,12 +128,14 @@ SET(INSTALL_SUPPORTFILESDIR_STANDALONE "support-files")
SET(INSTALL_MYSQLDATADIR_STANDALONE "data") SET(INSTALL_MYSQLDATADIR_STANDALONE "data")
SET(INSTALL_PLUGINTESTDIR_STANDALONE ${plugin_tests}) SET(INSTALL_PLUGINTESTDIR_STANDALONE ${plugin_tests})
SET(INSTALL_UNIX_ADDRDIR_STANDALONE "/tmp/mysql.sock")
# #
# RPM layout # RPM layout
# #
SET(INSTALL_BINDIR_RPM "bin") SET(INSTALL_BINDIR_RPM "bin")
SET(INSTALL_SBINDIR_RPM "sbin") SET(INSTALL_SBINDIR_RPM "sbin")
SET(INSTALL_SCRIPTDIR_RPM "bin") SET(INSTALL_SCRIPTDIR_RPM "bin")
SET(INSTALL_SYSCONFDIR_RPM "/etc")
# #
IF(CMAKE_SYSTEM_PROCESSOR MATCHES "x86_64") IF(CMAKE_SYSTEM_PROCESSOR MATCHES "x86_64")
SET(INSTALL_LIBDIR_RPM "lib64") SET(INSTALL_LIBDIR_RPM "lib64")
@ -148,8 +147,8 @@ ENDIF()
# #
SET(INSTALL_INCLUDEDIR_RPM "include/mysql") SET(INSTALL_INCLUDEDIR_RPM "include/mysql")
# #
#SET(INSTALL_DOCDIR_RPM unset - installed directly by RPM) SET(INSTALL_DOCDIR_RPM "share/doc/${CPACK_SOURCE_PACKAGE_FILE_NAME}")
#SET(INSTALL_DOCREADMEDIR_RPM unset - installed directly by RPM) SET(INSTALL_DOCREADMEDIR_RPM "share/doc/${CPACK_SOURCE_PACKAGE_FILE_NAME}")
SET(INSTALL_INFODIR_RPM "share/info") SET(INSTALL_INFODIR_RPM "share/info")
SET(INSTALL_MANDIR_RPM "share/man") SET(INSTALL_MANDIR_RPM "share/man")
# #
@ -162,6 +161,8 @@ SET(INSTALL_SUPPORTFILESDIR_RPM "share/mysql")
SET(INSTALL_MYSQLDATADIR_RPM "/var/lib/mysql") SET(INSTALL_MYSQLDATADIR_RPM "/var/lib/mysql")
SET(INSTALL_PLUGINTESTDIR_RPM ${plugin_tests}) SET(INSTALL_PLUGINTESTDIR_RPM ${plugin_tests})
SET(INSTALL_UNIX_ADDRDIR_RPM "${INSTALL_MYSQLDATADIR_RPM}/mysql.sock")
# #
# DEB layout # DEB layout
# #
@ -188,6 +189,7 @@ SET(INSTALL_SUPPORTFILESDIR_DEB "support-files")
SET(INSTALL_MYSQLDATADIR_DEB "/var/lib/mysql") SET(INSTALL_MYSQLDATADIR_DEB "/var/lib/mysql")
SET(INSTALL_PLUGINTESTDIR_DEB ${plugin_tests}) SET(INSTALL_PLUGINTESTDIR_DEB ${plugin_tests})
SET(INSTALL_UNIX_ADDRDIR_DEB "/var/run/mysqld/mysqld.sock")
# #
# SVR4 layout # SVR4 layout
# #
@ -214,6 +216,7 @@ SET(INSTALL_SUPPORTFILESDIR_SVR4 "support-files")
SET(INSTALL_MYSQLDATADIR_SVR4 "/var/lib/mysql") SET(INSTALL_MYSQLDATADIR_SVR4 "/var/lib/mysql")
SET(INSTALL_PLUGINTESTDIR_SVR4 ${plugin_tests}) SET(INSTALL_PLUGINTESTDIR_SVR4 ${plugin_tests})
SET(INSTALL_UNIX_ADDRDIR_SVR "/tmp/mysql.sock")
# Clear cached variables if install layout was changed # Clear cached variables if install layout was changed
IF(OLD_INSTALL_LAYOUT) IF(OLD_INSTALL_LAYOUT)
@ -226,9 +229,14 @@ SET(OLD_INSTALL_LAYOUT ${INSTALL_LAYOUT} CACHE INTERNAL "")
# Set INSTALL_FOODIR variables for chosen layout (for example, INSTALL_BINDIR # Set INSTALL_FOODIR variables for chosen layout (for example, INSTALL_BINDIR
# will be defined as ${INSTALL_BINDIR_STANDALONE} by default if STANDALONE # will be defined as ${INSTALL_BINDIR_STANDALONE} by default if STANDALONE
# layout is chosen) # layout is chosen)
FOREACH(var BIN SBIN LIB MYSQLSHARE SHARE PLUGIN INCLUDE SCRIPT DOC MAN FOREACH(var BIN SBIN LIB MYSQLSHARE SHARE PLUGIN INCLUDE SCRIPT DOC MAN SYSCONF
INFO MYSQLTEST SQLBENCH DOCREADME SUPPORTFILES MYSQLDATA PLUGINTEST) INFO MYSQLTEST SQLBENCH DOCREADME SUPPORTFILES MYSQLDATA PLUGINTEST UNIX_ADDR)
SET(INSTALL_${var}DIR ${INSTALL_${var}DIR_${INSTALL_LAYOUT}} SET(INSTALL_${var}DIR ${INSTALL_${var}DIR_${INSTALL_LAYOUT}}
CACHE STRING "${var} installation directory" ${FORCE}) CACHE STRING "${var} installation directory" ${FORCE})
MARK_AS_ADVANCED(INSTALL_${var}DIR) MARK_AS_ADVANCED(INSTALL_${var}DIR)
ENDFOREACH() ENDFOREACH()
IF(NOT MYSQL_UNIX_ADDR)
SET(MYSQL_UNIX_ADDR ${INSTALL_UNIX_ADDRDIR})
ENDIF()

View File

@ -19,6 +19,15 @@ INCLUDE(CheckCCompilerFlag)
MACRO(SET_MYSQL_MAINTAINER_GNU_C_OPTIONS) MACRO(SET_MYSQL_MAINTAINER_GNU_C_OPTIONS)
SET(MY_MAINTAINER_WARNINGS SET(MY_MAINTAINER_WARNINGS
"-Wall -Wextra -Wunused -Wwrite-strings -Wno-strict-aliasing") "-Wall -Wextra -Wunused -Wwrite-strings -Wno-strict-aliasing")
CHECK_C_COMPILER_FLAG("-Wno-missing-field-initializers"
HAVE_NO_MISSING_FIELD_INITIALIZERS)
IF (HAVE_NO_MISSING_FIELD_INITIALIZERS)
SET(MY_MAINTAINER_WARNINGS
"${MY_MAINTAINER_WARNINGS} -Wno-missing-field-initializers")
ENDIF()
CHECK_C_COMPILER_FLAG("-Wdeclaration-after-statement" CHECK_C_COMPILER_FLAG("-Wdeclaration-after-statement"
HAVE_DECLARATION_AFTER_STATEMENT) HAVE_DECLARATION_AFTER_STATEMENT)
IF(HAVE_DECLARATION_AFTER_STATEMENT) IF(HAVE_DECLARATION_AFTER_STATEMENT)

View File

@ -80,15 +80,10 @@ ELSEIF(MYSQL_TCP_PORT EQUAL MYSQL_TCP_PORT_DEFAULT)
SET(MYSQL_TCP_PORT_DEFAULT "0") SET(MYSQL_TCP_PORT_DEFAULT "0")
ENDIF() ENDIF()
IF(NOT MYSQL_UNIX_ADDR)
SET(MYSQL_UNIX_ADDR "/tmp/mysql.sock")
ENDIF()
IF(NOT COMPILATION_COMMENT) IF(NOT COMPILATION_COMMENT)
SET(COMPILATION_COMMENT "Source distribution") SET(COMPILATION_COMMENT "Source distribution")
ENDIF() ENDIF()
INCLUDE(package_name) INCLUDE(package_name)
IF(NOT CPACK_PACKAGE_FILE_NAME) IF(NOT CPACK_PACKAGE_FILE_NAME)
GET_PACKAGE_FILE_NAME(CPACK_PACKAGE_FILE_NAME) GET_PACKAGE_FILE_NAME(CPACK_PACKAGE_FILE_NAME)
@ -104,7 +99,6 @@ ENDIF()
SET(CPACK_PACKAGE_CONTACT "MariaDB team <info@montyprogram.com>") SET(CPACK_PACKAGE_CONTACT "MariaDB team <info@montyprogram.com>")
SET(CPACK_PACKAGE_VENDOR "Monty Program AB") SET(CPACK_PACKAGE_VENDOR "Monty Program AB")
SET(CPACK_SOURCE_GENERATOR "TGZ") SET(CPACK_SOURCE_GENERATOR "TGZ")
INCLUDE(cpack_source_ignore_files)
# Defintions for windows version resources # Defintions for windows version resources
SET(PRODUCTNAME "MariaDB Server") SET(PRODUCTNAME "MariaDB Server")
@ -126,10 +120,12 @@ ENDIF()
IF(MSVC) IF(MSVC)
# Tiny version is used to identify the build, it can be set with cmake -DTINY_VERSION=<number> # Tiny version is used to identify the build, it can be set with cmake -DTINY_VERSION=<number>
# to bzr revno for example (in the CI builds) # to bzr revno for example (in the CI builds)
SET(TINY_VERSION "0" CACHE INTERNAL "") IF(NOT TINY_VERSION)
SET(TINY_VERSION "0")
ENDIF()
GET_FILENAME_COMPONENT(MYSQL_CMAKE_SCRIPT_DIR ${CMAKE_CURRENT_LIST_FILE} PATH) GET_FILENAME_COMPONENT(MYSQL_CMAKE_SCRIPT_DIR ${CMAKE_CURRENT_LIST_FILE} PATH)
SET(FILETYPE VFT_APP) SET(FILETYPE VFT_APP)
CONFIGURE_FILE(${MYSQL_CMAKE_SCRIPT_DIR}/versioninfo.rc.in CONFIGURE_FILE(${MYSQL_CMAKE_SCRIPT_DIR}/versioninfo.rc.in
${CMAKE_BINARY_DIR}/versioninfo_exe.rc) ${CMAKE_BINARY_DIR}/versioninfo_exe.rc)
@ -137,7 +133,7 @@ IF(MSVC)
SET(FILETYPE VFT_DLL) SET(FILETYPE VFT_DLL)
CONFIGURE_FILE(${MYSQL_CMAKE_SCRIPT_DIR}/versioninfo.rc.in CONFIGURE_FILE(${MYSQL_CMAKE_SCRIPT_DIR}/versioninfo.rc.in
${CMAKE_BINARY_DIR}/versioninfo_dll.rc) ${CMAKE_BINARY_DIR}/versioninfo_dll.rc)
FUNCTION(ADD_VERSION_INFO target target_type sources_var) FUNCTION(ADD_VERSION_INFO target target_type sources_var)
IF("${target_type}" MATCHES "SHARED" OR "${target_type}" MATCHES "MODULE") IF("${target_type}" MATCHES "SHARED" OR "${target_type}" MATCHES "MODULE")
SET(rcfile ${CMAKE_BINARY_DIR}/versioninfo_dll.rc) SET(rcfile ${CMAKE_BINARY_DIR}/versioninfo_dll.rc)

View File

@ -23,6 +23,15 @@
# The below was used for really old versions of FreeBSD, roughly: before 5.1.9 # The below was used for really old versions of FreeBSD, roughly: before 5.1.9
# ADD_DEFINITIONS(-DHAVE_BROKEN_REALPATH) # ADD_DEFINITIONS(-DHAVE_BROKEN_REALPATH)
# Find libexecinfo (library that contains backtrace_symbols etc)
INCLUDE_DIRECTORIES(/usr/local/include)
SET(CMAKE_REQUIRED_INCLUDES ${CMAKE_REQUIRED_INCLUDES} /usr/local/include )
SET(ENV{LIB} "$ENV{LIB}:/usr/local/lib")
FIND_LIBRARY(EXECINFO NAMES execinfo)
IF(EXECINFO)
SET(LIBEXECINFO ${EXECINFO})
ENDIF()
# Use atomic builtins # Use atomic builtins
IF(CMAKE_SIZEOF_VOID_P EQUAL 4 AND CMAKE_SYSTEM_PROCESSOR STREQUAL "i386") IF(CMAKE_SIZEOF_VOID_P EQUAL 4 AND CMAKE_SYSTEM_PROCESSOR STREQUAL "i386")
SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -march=i686") SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -march=i686")

View File

@ -211,15 +211,7 @@ MACRO(MYSQL_ADD_PLUGIN)
SET(ARG_COMPONENT Server) SET(ARG_COMPONENT Server)
ENDIF() ENDIF()
MYSQL_INSTALL_TARGETS(${target} DESTINATION ${INSTALL_PLUGINDIR} COMPONENT ${ARG_COMPONENT}) MYSQL_INSTALL_TARGETS(${target} DESTINATION ${INSTALL_PLUGINDIR} COMPONENT ${ARG_COMPONENT})
INSTALL_DEBUG_TARGET(${target} DESTINATION ${INSTALL_PLUGINDIR}/debug COMPONENT ${ARG_COMPONENT}) #INSTALL_DEBUG_TARGET(${target} DESTINATION ${INSTALL_PLUGINDIR}/debug COMPONENT ${ARG_COMPONENT})
# Add installed files to list for RPMs
FILE(APPEND ${CMAKE_BINARY_DIR}/support-files/plugins.files
"%attr(755, root, root) %{_prefix}/${INSTALL_PLUGINDIR}/${ARG_MODULE_OUTPUT_NAME}.so\n"
"%attr(755, root, root) %{_prefix}/${INSTALL_PLUGINDIR}/debug/${ARG_MODULE_OUTPUT_NAME}.so\n")
# For internal testing in PB2, append collections files
IF(DEFINED ENV{PB2WORKDIR})
PLUGIN_APPEND_COLLECTIONS(${plugin})
ENDIF()
ELSE() ELSE()
IF(WITHOUT_${plugin}) IF(WITHOUT_${plugin})
# Update cache variable # Update cache variable

View File

@ -150,6 +150,7 @@
#cmakedefine HAVE_FCNTL 1 #cmakedefine HAVE_FCNTL 1
#cmakedefine HAVE_FCONVERT 1 #cmakedefine HAVE_FCONVERT 1
#cmakedefine HAVE_FDATASYNC 1 #cmakedefine HAVE_FDATASYNC 1
#cmakedefine HAVE_DECL_FDATASYNC 1
#cmakedefine HAVE_FESETROUND 1 #cmakedefine HAVE_FESETROUND 1
#cmakedefine HAVE_FINITE 1 #cmakedefine HAVE_FINITE 1
#cmakedefine HAVE_FP_EXCEPT 1 #cmakedefine HAVE_FP_EXCEPT 1

View File

@ -147,7 +147,7 @@ IF(UNIX)
FIND_PACKAGE(Threads) FIND_PACKAGE(Threads)
SET(CMAKE_REQUIRED_LIBRARIES SET(CMAKE_REQUIRED_LIBRARIES
${LIBM} ${LIBNSL} ${LIBBIND} ${LIBCRYPT} ${LIBSOCKET} ${LIBDL} ${CMAKE_THREAD_LIBS_INIT} ${LIBRT}) ${LIBM} ${LIBNSL} ${LIBBIND} ${LIBCRYPT} ${LIBSOCKET} ${LIBDL} ${CMAKE_THREAD_LIBS_INIT} ${LIBRT} ${LIBEXECINFO})
IF(CMAKE_REQUIRED_LIBRARIES) IF(CMAKE_REQUIRED_LIBRARIES)
LIST(REMOVE_DUPLICATES CMAKE_REQUIRED_LIBRARIES) LIST(REMOVE_DUPLICATES CMAKE_REQUIRED_LIBRARIES)

View File

@ -36,7 +36,8 @@ int func1()
DBUG_RETURN(10); DBUG_RETURN(10);
} }
int main (int argc, char *argv[]) int main (int argc __attribute__((unused)),
char *argv[] __attribute__((unused)))
{ {
#ifdef DBUG_OFF #ifdef DBUG_OFF
return 1; return 1;

View File

@ -3,7 +3,7 @@
[client] [client]
# Default is Latin1, if you need UTF-8 set this (also in server section) # Default is Latin1, if you need UTF-8 set this (also in server section)
#default-character-set = utf8 #character-set-server = utf8
[mysqld] [mysqld]
# #
@ -11,7 +11,7 @@
# #
# Default is Latin1, if you need UTF-8 set all this (also in client section) # Default is Latin1, if you need UTF-8 set all this (also in client section)
# #
#default-character-set = utf8 #character-set-server = utf8
#default-collation = utf8_general_ci #collation-server = utf8_general_ci
#character_set_server = utf8 #character_set_server = utf8
#collation_server = utf8_general_ci #collation_server = utf8_general_ci

View File

@ -1,6 +1,5 @@
usr/bin/mysql_config usr/bin/mysql_config
usr/include/mysql/*.h usr/include/mysql
usr/include/mysql/psi/*.h
usr/lib/libmysqlclient.a usr/lib/libmysqlclient.a
usr/lib/libmysqlclient_r.a usr/lib/libmysqlclient_r.a
usr/lib/libmysqlservices.a usr/lib/libmysqlservices.a

View File

@ -1,2 +1,2 @@
usr/lib/libmysqlclient.so.16 usr/lib/libmysqlclient.so usr/lib/libmysqlclient.so.18 usr/lib/libmysqlclient.so
usr/lib/libmysqlclient_r.so.16 usr/lib/libmysqlclient_r.so usr/lib/libmysqlclient_r.so.18 usr/lib/libmysqlclient_r.so

View File

@ -72,7 +72,7 @@ IF(CMAKE_SYSTEM_NAME STREQUAL "SunOS")
ENDIF() ENDIF()
ENDIF() ENDIF()
MYSQL_ADD_EXECUTABLE(replace replace.c COMPONENT Junk) MYSQL_ADD_EXECUTABLE(replace replace.c COMPONENT Server)
TARGET_LINK_LIBRARIES(replace mysys) TARGET_LINK_LIBRARIES(replace mysys)
IF(UNIX) IF(UNIX)
MYSQL_ADD_EXECUTABLE(innochecksum innochecksum.c) MYSQL_ADD_EXECUTABLE(innochecksum innochecksum.c)
@ -80,6 +80,6 @@ IF(UNIX)
MYSQL_ADD_EXECUTABLE(resolve_stack_dump resolve_stack_dump.c) MYSQL_ADD_EXECUTABLE(resolve_stack_dump resolve_stack_dump.c)
TARGET_LINK_LIBRARIES(resolve_stack_dump mysys) TARGET_LINK_LIBRARIES(resolve_stack_dump mysys)
MYSQL_ADD_EXECUTABLE(mysql_waitpid mysql_waitpid.c) MYSQL_ADD_EXECUTABLE(mysql_waitpid mysql_waitpid.c COMPONENT Client)
TARGET_LINK_LIBRARIES(mysql_waitpid mysys) TARGET_LINK_LIBRARIES(mysql_waitpid mysys)
ENDIF() ENDIF()

View File

@ -14,17 +14,18 @@
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
SET(HEADERS_GEN_CONFIGURE SET(HEADERS_GEN_CONFIGURE
${CMAKE_CURRENT_BINARY_DIR}/mysql_version.h mysql_version.h
${CMAKE_CURRENT_BINARY_DIR}/my_config.h my_config.h
${CMAKE_CURRENT_BINARY_DIR}/mysqld_ername.h mysqld_ername.h
${CMAKE_CURRENT_BINARY_DIR}/mysqld_error.h mysqld_error.h
${CMAKE_CURRENT_BINARY_DIR}/sql_state.h sql_state.h
) )
SET(HEADERS SET(HEADERS
mysql.h mysql.h
mysql_com.h mysql_com.h
mysql_time.h mysql_time.h
ma_dyncol.h
my_list.h my_list.h
my_alloc.h my_alloc.h
typelib.h typelib.h
@ -33,6 +34,7 @@ SET(HEADERS
my_sys.h my_sys.h
my_xml.h my_xml.h
mysql_embed.h mysql_embed.h
my_decimal_limits.h
my_pthread.h my_pthread.h
decimal.h decimal.h
errmsg.h errmsg.h
@ -49,8 +51,19 @@ SET(HEADERS
m_ctype.h m_ctype.h
my_attribute.h my_attribute.h
my_compiler.h my_compiler.h
${HEADERS_GEN_CONFIGURE}
) )
INSTALL(FILES ${HEADERS} DESTINATION ${INSTALL_INCLUDEDIR} COMPONENT Development) INSTALL(FILES ${HEADERS} DESTINATION ${INSTALL_INCLUDEDIR} COMPONENT Development)
FOREACH(f ${HEADERS_GEN_CONFIGURE})
INSTALL(FILES ${CMAKE_CURRENT_BINARY_DIR}/${f} DESTINATION ${INSTALL_INCLUDEDIR} COMPONENT Development PERMISSIONS OWNER_READ GROUP_READ WORLD_READ)
ENDFOREACH(f)
INSTALL(DIRECTORY mysql/ DESTINATION ${INSTALL_INCLUDEDIR} COMPONENT Development FILES_MATCHING PATTERN "*.h") INSTALL(DIRECTORY mysql/ DESTINATION ${INSTALL_INCLUDEDIR} COMPONENT Development FILES_MATCHING PATTERN "*.h")
STRING(REPLACE "." "\\." EXCL_RE "${HEADERS};${HEADERS_GEN_CONFIGURE}")
STRING(REPLACE ";" "|" EXCL_RE "${EXCL_RE}")
INSTALL(DIRECTORY . DESTINATION ${INSTALL_INCLUDEDIR}/private COMPONENT Development
FILES_MATCHING PATTERN "*.h"
PATTERN CMakeFiles EXCLUDE
PATTERN mysql EXCLUDE
REGEX "\\./(${EXCL_RE}$)" EXCLUDE)

View File

@ -24,7 +24,6 @@ extern "C" {
#include <my_base.h> #include <my_base.h>
#include <my_sys.h> #include <my_sys.h>
#include <m_ctype.h> #include <m_ctype.h>
#include "../storage/maria/ma_pagecache.h"
#include "my_compare.h" #include "my_compare.h"
#include "ft_global.h" #include "ft_global.h"
#include <myisamchk.h> #include <myisamchk.h>
@ -268,7 +267,6 @@ extern my_bool maria_flush, maria_single_user, maria_page_checksums;
extern my_bool maria_delay_key_write; extern my_bool maria_delay_key_write;
extern my_off_t maria_max_temp_length; extern my_off_t maria_max_temp_length;
extern ulong maria_bulk_insert_tree_size, maria_data_pointer_size; extern ulong maria_bulk_insert_tree_size, maria_data_pointer_size;
extern PAGECACHE maria_pagecache_var, *maria_pagecache;
extern MY_TMPDIR *maria_tmpdir; extern MY_TMPDIR *maria_tmpdir;
/* /*
This is used to check if a symlink points into the mysql data home, This is used to check if a symlink points into the mysql data home,
@ -353,69 +351,6 @@ typedef struct st_maria_bit_buff
uint error; uint error;
} MARIA_BIT_BUFF; } MARIA_BIT_BUFF;
typedef struct st_maria_sort_info
{
/* sync things */
mysql_mutex_t mutex;
mysql_cond_t cond;
MARIA_HA *info, *new_info;
HA_CHECK *param;
char *buff;
SORT_KEY_BLOCKS *key_block, *key_block_end;
SORT_FT_BUF *ft_buf;
my_off_t filelength, dupp, buff_length;
pgcache_page_no_t page;
ha_rows max_records;
uint current_key, total_keys;
uint got_error, threads_running;
myf myf_rw;
enum data_file_type new_data_file_type, org_data_file_type;
} MARIA_SORT_INFO;
typedef struct st_maria_sort_param
{
pthread_t thr;
IO_CACHE read_cache, tempfile, tempfile_for_exceptions;
DYNAMIC_ARRAY buffpek;
MARIA_BIT_BUFF bit_buff; /* For parallel repair of packrec. */
MARIA_KEYDEF *keyinfo;
MARIA_SORT_INFO *sort_info;
HA_KEYSEG *seg;
uchar **sort_keys;
uchar *rec_buff;
void *wordlist, *wordptr;
MEM_ROOT wordroot;
uchar *record;
MY_TMPDIR *tmpdir;
/*
The next two are used to collect statistics, see maria_update_key_parts for
description.
*/
ulonglong unique[HA_MAX_KEY_SEG+1];
ulonglong notnull[HA_MAX_KEY_SEG+1];
MARIA_RECORD_POS pos,max_pos,filepos,start_recpos, current_filepos;
uint key, key_length,real_key_length,sortbuff_size;
uint maxbuffers, keys, find_length, sort_keys_length;
my_bool fix_datafile, master;
my_bool calc_checksum; /* calculate table checksum */
size_t rec_buff_size;
int (*key_cmp)(struct st_maria_sort_param *, const void *, const void *);
int (*key_read)(struct st_maria_sort_param *, uchar *);
int (*key_write)(struct st_maria_sort_param *, const uchar *);
void (*lock_in_memory)(HA_CHECK *);
int (*write_keys)(struct st_maria_sort_param *, register uchar **,
uint , struct st_buffpek *, IO_CACHE *);
uint (*read_to_buffer)(IO_CACHE *,struct st_buffpek *, uint);
int (*write_key)(struct st_maria_sort_param *, IO_CACHE *,uchar *,
uint, uint);
} MARIA_SORT_PARAM;
/* functions in maria_check */ /* functions in maria_check */
void maria_chk_init(HA_CHECK *param); void maria_chk_init(HA_CHECK *param);
void maria_chk_init_for_check(HA_CHECK *param, MARIA_HA *info); void maria_chk_init_for_check(HA_CHECK *param, MARIA_HA *info);
@ -443,7 +378,6 @@ int maria_filecopy(HA_CHECK *param, File to, File from, my_off_t start,
my_off_t length, const char *type); my_off_t length, const char *type);
int maria_movepoint(MARIA_HA *info, uchar *record, my_off_t oldpos, int maria_movepoint(MARIA_HA *info, uchar *record, my_off_t oldpos,
my_off_t newpos, uint prot_key); my_off_t newpos, uint prot_key);
int maria_write_data_suffix(MARIA_SORT_INFO *sort_info, my_bool fix_datafile);
int maria_test_if_almost_full(MARIA_HA *info); int maria_test_if_almost_full(MARIA_HA *info);
int maria_recreate_table(HA_CHECK *param, MARIA_HA **org_info, char *filename); int maria_recreate_table(HA_CHECK *param, MARIA_HA **org_info, char *filename);
int maria_disable_indexes(MARIA_HA *info); int maria_disable_indexes(MARIA_HA *info);
@ -456,10 +390,6 @@ my_bool maria_test_if_sort_rep(MARIA_HA *info, ha_rows rows, ulonglong key_map,
int maria_init_bulk_insert(MARIA_HA *info, ulong cache_size, ha_rows rows); int maria_init_bulk_insert(MARIA_HA *info, ulong cache_size, ha_rows rows);
void maria_flush_bulk_insert(MARIA_HA *info, uint inx); void maria_flush_bulk_insert(MARIA_HA *info, uint inx);
void maria_end_bulk_insert(MARIA_HA *info); void maria_end_bulk_insert(MARIA_HA *info);
int maria_assign_to_pagecache(MARIA_HA *info, ulonglong key_map,
PAGECACHE *key_cache);
void maria_change_pagecache(PAGECACHE *old_key_cache,
PAGECACHE *new_key_cache);
int maria_preload(MARIA_HA *info, ulonglong key_map, my_bool ignore_leaves); int maria_preload(MARIA_HA *info, ulonglong key_map, my_bool ignore_leaves);
void maria_versioning(MARIA_HA *info, my_bool versioning); void maria_versioning(MARIA_HA *info, my_bool versioning);
void maria_ignore_trids(MARIA_HA *info); void maria_ignore_trids(MARIA_HA *info);

View File

@ -1,5 +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.
reserved
This program is free software; you can redistribute it and/or modify This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by it under the terms of the GNU General Public License as published by
@ -11,8 +10,9 @@
GNU General Public License for more details. GNU General Public License for more details.
You should have received a copy of the GNU General Public License You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software along with this program; if not, write to the Free Software Foundation,
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ Inc., 51 Franklin Street, Suite 500, Boston, MA 02110-1335 USA */
/* This file includes constants used with all databases */ /* This file includes constants used with all databases */
@ -459,10 +459,11 @@ enum ha_base_keytype {
#define HA_ERR_INDEX_COL_TOO_LONG 178 /* Index column length exceeds limit */ #define HA_ERR_INDEX_COL_TOO_LONG 178 /* Index column length exceeds limit */
#define HA_ERR_INDEX_CORRUPT 179 /* Index corrupted */ #define HA_ERR_INDEX_CORRUPT 179 /* Index corrupted */
#define HA_ERR_UNDO_REC_TOO_BIG 180 /* Undo log record too big */ #define HA_ERR_UNDO_REC_TOO_BIG 180 /* Undo log record too big */
#define HA_ERR_ROW_NOT_VISIBLE 181 #define HA_ERR_TABLE_IN_FK_CHECK 181 /* Table being used in foreign key check */
#define HA_ERR_ABORTED_BY_USER 182 #define HA_ERR_ROW_NOT_VISIBLE 182
#define HA_ERR_DISK_FULL 183 #define HA_ERR_ABORTED_BY_USER 183
#define HA_ERR_LAST 183 /* Copy of last error nr */ #define HA_ERR_DISK_FULL 184
#define HA_ERR_LAST 184 /* Copy of last error nr */
/* Number of different errors */ /* Number of different errors */
#define HA_ERR_ERRORS (HA_ERR_LAST - HA_ERR_FIRST + 1) #define HA_ERR_ERRORS (HA_ERR_LAST - HA_ERR_FIRST + 1)

View File

@ -1429,6 +1429,10 @@ static inline char *dlerror(void)
/* Length of decimal number represented by INT64. */ /* Length of decimal number represented by INT64. */
#define MY_INT64_NUM_DECIMAL_DIGITS 21 #define MY_INT64_NUM_DECIMAL_DIGITS 21
#ifdef __cplusplus
#include <limits> /* should be included before min/max macros */
#endif
/* Define some useful general macros (should be done after all headers). */ /* Define some useful general macros (should be done after all headers). */
#if !defined(max) #if !defined(max)
#define max(a, b) ((a) > (b) ? (a) : (b)) #define max(a, b) ((a) > (b) ? (a) : (b))

View File

@ -18,28 +18,8 @@
#define PROBES_MYSQL_H #define PROBES_MYSQL_H
#if defined(HAVE_DTRACE) && !defined(DISABLE_DTRACE) #if defined(HAVE_DTRACE) && !defined(DISABLE_DTRACE)
#ifdef __linux__
/*
On Linux, generated probes header may include C++ header
<limits> which conflicts with min and max macros from my_global.h .
To fix, temporarily undefine the macros.
*/
#pragma push_macro("min")
#pragma push_macro("max")
#undef min
#undef max
#endif
#include "probes_mysql_dtrace.h" #include "probes_mysql_dtrace.h"
#ifdef __linux__
#pragma pop_macro("min")
#pragma pop_macro("max")
#endif
#else /* no dtrace */ #else /* no dtrace */
#include "probes_mysql_nodtrace.h" #include "probes_mysql_nodtrace.h"
#endif #endif

View File

@ -59,6 +59,9 @@ Vio* vio_new_win32shared_memory(HANDLE handle_file_map,
#define HANDLE void * #define HANDLE void *
#endif /* __WIN__ */ #endif /* __WIN__ */
/* backport from 5.6 where it is part of PSI, not vio_*() */
int mysql_socket_shutdown(my_socket mysql_socket, int how);
void vio_delete(Vio* vio); void vio_delete(Vio* vio);
int vio_close(Vio* vio); int vio_close(Vio* vio);
void vio_reset(Vio* vio, enum enum_vio_type type, void vio_reset(Vio* vio, enum enum_vio_type type,

View File

@ -134,7 +134,7 @@ FOREACH(LIB ${LIBS})
ENDFOREACH() ENDFOREACH()
MERGE_LIBRARIES(mysqlserver STATIC ${EMBEDDED_LIBS} MERGE_LIBRARIES(mysqlserver STATIC ${EMBEDDED_LIBS}
OUTPUT_NAME ${MYSQLSERVER_OUTPUT_NAME} COMPONENT Embedded) OUTPUT_NAME ${MYSQLSERVER_OUTPUT_NAME} COMPONENT Development)
# Visual Studio users need debug static library # Visual Studio users need debug static library
IF(MSVC) IF(MSVC)
@ -148,7 +148,7 @@ ENDIF()
IF(NOT DISABLE_SHARED) IF(NOT DISABLE_SHARED)
MERGE_LIBRARIES(libmysqld SHARED mysqlserver EXPORTS ${CLIENT_API_FUNCTIONS} MERGE_LIBRARIES(libmysqld SHARED mysqlserver EXPORTS ${CLIENT_API_FUNCTIONS}
COMPONENT Embedded) COMPONENT Server)
IF(UNIX) IF(UNIX)
# Name the shared library, handle versioning (provides same api as client # Name the shared library, handle versioning (provides same api as client
# library hence the same version) # library hence the same version)

View File

@ -26,7 +26,7 @@ ADD_DEFINITIONS(-DEMBEDDED_LIBRARY -UMYSQL_CLIENT)
MYSQL_ADD_EXECUTABLE(mysql_embedded ../../client/completion_hash.cc MYSQL_ADD_EXECUTABLE(mysql_embedded ../../client/completion_hash.cc
../../client/mysql.cc ../../client/readline.cc ../../client/mysql.cc ../../client/readline.cc
COMPONENT Test) COMPONENT Client)
TARGET_LINK_LIBRARIES(mysql_embedded mysqlserver) TARGET_LINK_LIBRARIES(mysql_embedded mysqlserver)
IF(UNIX) IF(UNIX)
TARGET_LINK_LIBRARIES(mysql_embedded ${MY_READLINE_LIBRARY}) TARGET_LINK_LIBRARIES(mysql_embedded ${MY_READLINE_LIBRARY})

View File

@ -344,6 +344,8 @@ static int emb_stmt_execute(MYSQL_STMT *stmt)
set_stmt_errmsg(stmt, net); set_stmt_errmsg(stmt, net);
DBUG_RETURN(1); DBUG_RETURN(1);
} }
else if (stmt->mysql->status == MYSQL_STATUS_GET_RESULT)
stmt->mysql->status= MYSQL_STATUS_STATEMENT_GET_RESULT;
DBUG_RETURN(0); DBUG_RETURN(0);
} }

View File

@ -1,4 +1,4 @@
# Copyright (c) 2006, 2011, Oracle and/or its affiliates. All rights reserved. # Copyright (c) 2012, Monty Program Ab
# #
# This program is free software; you can redistribute it and/or modify # This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by # it under the terms of the GNU General Public License as published by
@ -13,26 +13,26 @@
# along with this program; if not, write to the Free Software # along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
# Copy man pages SET(MAN1_SERVER innochecksum.1 my_print_defaults.1 myisam_ftdump.1 myisamchk.1
FILE(GLOB MAN1_FILES *.1) myisamlog.1 myisampack.1 mysql.server.1
FILE(GLOB MAN1_EXCLUDE make_win_bin_dist.1) mysql_convert_table_format.1 mysql_fix_extensions.1
FILE(GLOB MAN1_NDB ndb*.1) mysql_fix_privilege_tables.1 mysql_install_db.1
FILE(GLOB MAN8_FILES *.8) mysql_secure_installation.1 mysql_setpermission.1
FILE(GLOB MAN8_NDB ndb*.8) mysql_tzinfo_to_sql.1 mysql_upgrade.1 mysql_zap.1
IF(MAN1_FILES) mysqld_multi.1 mysqld_safe.1 mysqldumpslow.1 mysqlhotcopy.1
IF(MAN1_EXCLUDE) mysqlman.1 mysqltest.1 perror.1 replace.1 resolve_stack_dump.1
LIST(REMOVE_ITEM MAN1_FILES ${MAN1_EXCLUDE}) resolveip.1)
ENDIF() SET(MAN8_SERVER mysqld.8 mysqlmanager.8)
IF(MAN1_NDB) SET(MAN1_CLIENT msql2mysql.1 mysql.1 mysql_find_rows.1 mysql_waitpid.1
LIST(REMOVE_ITEM MAN1_FILES ${MAN1_NDB}) mysqlaccess.1 mysqladmin.1 mysqlbinlog.1 mysqlcheck.1
ENDIF() mysqldump.1 mysqlimport.1 mysqlshow.1 mysqlslap.1)
INSTALL(FILES ${MAN1_FILES} DESTINATION ${INSTALL_MANDIR}/man1 SET(MAN1_DEVEL mysql_config.1)
COMPONENT ManPages) SET(MAN1_TEST mysql-stress-test.pl.1 mysql-test-run.pl.1 mysql_client_test.1
ENDIF() mysqltest_embedded.1 mysql_client_test_embedded.1)
IF(MAN8_FILES)
IF(MAN8_NDB) INSTALL(FILES ${MAN1_SERVER} DESTINATION ${INSTALL_MANDIR}/man1 COMPONENT ManPagesServer)
LIST(REMOVE_ITEM MAN8_FILES ${MAN8_NDB}) INSTALL(FILES ${MAN8_SERVER} DESTINATION ${INSTALL_MANDIR}/man8 COMPONENT ManPagesServer)
ENDIF() INSTALL(FILES ${MAN1_CLIENT} DESTINATION ${INSTALL_MANDIR}/man1 COMPONENT ManPagesClient)
INSTALL(FILES ${MAN8_FILES} DESTINATION ${INSTALL_MANDIR}/man8 INSTALL(FILES ${MAN1_DEVEL} DESTINATION ${INSTALL_MANDIR}/man1 COMPONENT ManPagesDevelopment)
COMPONENT ManPages) INSTALL(FILES ${MAN1_TEST} DESTINATION ${INSTALL_MANDIR}/man1 COMPONENT ManPagesTest)
ENDIF()

View File

@ -2,17 +2,19 @@
# Basic tests of row-level logging # Basic tests of row-level logging
# #
--disable_query_log
--disable_result_log
# Add suppression for expected warning(s) in error log
call mtr.add_suppression("Can't find record in 't.'");
--enable_query_log
--enable_result_log
# #
# First we test tables with only an index. # First we test tables with only an index.
# #
#BUG#12662190 - COM_COMMIT IS NOT INCREMENTED FROM THE BINARY LOGS ON SLAVE, COM_BEGIN IS
#Testing command counters -BEFORE
#Storing the before counts of Slave
connection slave;
let $slave_com_commit_before= query_get_value(SHOW GLOBAL STATUS LIKE 'com_commit', Value, 1);
let $slave_com_insert_before= query_get_value(SHOW GLOBAL STATUS LIKE 'com_insert', Value, 1);
let $slave_com_delete_before= query_get_value(SHOW GLOBAL STATUS LIKE 'com_delete', Value, 1);
let $slave_com_update_before= query_get_value(SHOW GLOBAL STATUS LIKE 'com_update', Value, 1);
connection master; connection master;
eval CREATE TABLE t1 (C1 CHAR(1), C2 CHAR(1), INDEX (C1)$extra_index_t1) ENGINE = $type ; eval CREATE TABLE t1 (C1 CHAR(1), C2 CHAR(1), INDEX (C1)$extra_index_t1) ENGINE = $type ;
SELECT * FROM t1; SELECT * FROM t1;
@ -47,6 +49,32 @@ SELECT * FROM t1 ORDER BY C1,C2;
sync_slave_with_master; sync_slave_with_master;
SELECT * FROM t1 ORDER BY C1,C2; SELECT * FROM t1 ORDER BY C1,C2;
#BUG#12662190 - COM_COMMIT IS NOT INCREMENTED FROM THE BINARY LOGS ON SLAVE, COM_BEGIN IS
#Testing command counters -AFTER
#Storing the after counts of Slave
connection slave;
let $slave_com_commit_after= query_get_value(SHOW GLOBAL STATUS LIKE 'com_commit', Value, 1);
let $slave_com_insert_after= query_get_value(SHOW GLOBAL STATUS LIKE 'com_insert', Value, 1);
let $slave_com_delete_after= query_get_value(SHOW GLOBAL STATUS LIKE 'com_delete', Value, 1);
let $slave_com_update_after= query_get_value(SHOW GLOBAL STATUS LIKE 'com_update', Value, 1);
#Commit count check
--let $assert_text= Counter for COM_COMMIT is consistent with the number of actual commits
--let $assert_cond= $slave_com_commit_after - $slave_com_commit_before = 4
--source include/assert.inc
#Insert count check
--let $assert_text= Counter for COM_INSERT is consistent with the number of actual inserts
--let $assert_cond= $slave_com_insert_after - $slave_com_insert_before = 2
--source include/assert.inc
#Delete count check
--let $assert_text= Counter for COM_DELETE is consistent with the number of actual deletes
--let $assert_cond= $slave_com_delete_after - $slave_com_delete_before = 1
--source include/assert.inc
#Update count check
--let $assert_text= Counter for COM_UPDATE is consistent with the number of actual updates
--let $assert_cond= $slave_com_update_after - $slave_com_update_before = 1
--source include/assert.inc
# Testing update with a condition that does not match any rows, but # Testing update with a condition that does not match any rows, but
# which has a match for the index. # which has a match for the index.
connection master; connection master;

View File

@ -1,16 +0,0 @@
# Created by Horst Hunger 2008-04-15
# see also have_64bit_ulong.inc
--disable_query_log
--disable_warnings
let $save = `SELECT @@pseudo_thread_id`;
SET @@pseudo_thread_id = 4294967296;
let $mach32 = `SELECT @@pseudo_thread_id <= 4294967295`;
eval SET @@pseudo_thread_id = $save;
--enable_warnings
--enable_query_log
if (!$mach32)
{
skip Need a 32 bit unsigned long;
}

View File

@ -1,14 +0,0 @@
# Created by Horst Hunger 2008-04-15
# see also have_32bit_ulong.inc
--disable_query_log
let $save = `SELECT @@pseudo_thread_id`;
SET @@pseudo_thread_id = 4294967296;
let $mach64 = `SELECT @@pseudo_thread_id > 4294967295`;
eval SET @@pseudo_thread_id = $save;
--enable_query_log
if (!$mach64)
{
skip Need a 64 unsigned long ;
}

View File

@ -874,3 +874,21 @@ show status like "Handler_icp%";
DROP TABLE t1; DROP TABLE t1;
#
# MDEV-308 lp:1008516 - Failing assertion: templ->mysql_col_len == len
#
create table t1 (a int,b char(5),primary key (a), key (b(1)));
insert into t1 values ('a','b');
select 1 from t1 where a and b >= 'aa';
drop table t1;
--echo #
--echo # Bug#58015 "Assert in row_sel_field_store_in_mysql_format
--echo # when running innodb_mrr_icp test"
--echo #
create table t1 (a char(2) charset utf8,b double, primary key (a(1)),key (b));
insert into t1 values ('',1);
select 1 from t1 where b <= 1 and a <> '';
drop table t1;

View File

@ -78,7 +78,8 @@ BEGIN {
use lib "lib"; use lib "lib";
use Cwd; use Cwd ;
use Cwd 'realpath';
use Getopt::Long; use Getopt::Long;
use My::File::Path; # Patched version of File::Path use My::File::Path; # Patched version of File::Path
use File::Basename; use File::Basename;
@ -163,11 +164,14 @@ our $opt_vs_config = $ENV{'MTR_VS_CONFIG'};
my $DEFAULT_SUITES= join(',', map { "$_-" } qw( my $DEFAULT_SUITES= join(',', map { "$_-" } qw(
main main
archive
binlog binlog
csv
federated federated
funcs_1 funcs_1
funcs_2 funcs_2
handler handler
heap
innodb innodb
maria maria
optimizer_unfixed_bugs optimizer_unfixed_bugs
@ -226,7 +230,7 @@ my %opts_extern;
sub using_extern { return (keys %opts_extern > 0);}; sub using_extern { return (keys %opts_extern > 0);};
our $opt_fast= 0; our $opt_fast= 0;
our $opt_force; our $opt_force= 0;
our $opt_mem= $ENV{'MTR_MEM'}; our $opt_mem= $ENV{'MTR_MEM'};
our $opt_clean_vardir= $ENV{'MTR_CLEAN_VARDIR'}; our $opt_clean_vardir= $ENV{'MTR_CLEAN_VARDIR'};
@ -1037,8 +1041,14 @@ sub ignore_option {
# Setup any paths that are $opt_vardir related # Setup any paths that are $opt_vardir related
sub set_vardir { sub set_vardir {
my ($vardir)= @_; my ($vardir)= @_;
if(IS_WINDOWS)
$opt_vardir= $vardir; {
$opt_vardir= $vardir;
}
else
{
$opt_vardir= realpath($vardir);
}
$path_vardir_trace= $opt_vardir; $path_vardir_trace= $opt_vardir;
# Chop off any "c:", DBUG likes a unix path ex: c:/src/... => /src/... # Chop off any "c:", DBUG likes a unix path ex: c:/src/... => /src/...
@ -1126,7 +1136,7 @@ sub command_line_setup {
'defaults-extra-file=s' => \&collect_option, 'defaults-extra-file=s' => \&collect_option,
# Control what test suites or cases to run # Control what test suites or cases to run
'force' => \$opt_force, 'force+' => \$opt_force,
'with-ndbcluster-only' => \&collect_option, 'with-ndbcluster-only' => \&collect_option,
'include-ndbcluster' => \$opt_include_ndbcluster, 'include-ndbcluster' => \$opt_include_ndbcluster,
'skip-ndbcluster|skip-ndb' => \$opt_skip_ndbcluster, 'skip-ndbcluster|skip-ndb' => \$opt_skip_ndbcluster,
@ -5846,6 +5856,11 @@ sub start_mysqltest ($) {
mtr_add_arg($args, "%s", $_) for @args_saved; mtr_add_arg($args, "%s", $_) for @args_saved;
} }
if ($opt_force > 1)
{
mtr_add_arg($args, "--continue-on-error");
}
my $suite = $tinfo->{suite}; my $suite = $tinfo->{suite};
if ($suite->{parent}) { if ($suite->{parent}) {
mtr_add_arg($args, "--overlay-dir=%s/", $suite->{dir}); mtr_add_arg($args, "--overlay-dir=%s/", $suite->{dir});
@ -6275,7 +6290,11 @@ Options to control directories to use
Options to control what test suites or cases to run Options to control what test suites or cases to run
force Continue to run the suite after failure force Continue after a failure. When specified once, a
failure in a test file will abort this test file, and
the execution will continue from the next test file.
When specified twice, execution will continue executing
the failed test file from the next command.
with-ndbcluster-only Run only tests that include "ndb" in the filename with-ndbcluster-only Run only tests that include "ndb" in the filename
skip-ndb[cluster] Skip all tests that need cluster. Default. skip-ndb[cluster] Skip all tests that need cluster. Default.
include-ndb[cluster] Enable all tests that need cluster include-ndb[cluster] Enable all tests that need cluster

View File

@ -0,0 +1,10 @@
FLUSH STATUS;
SELECT VARIABLE_VALUE FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME='aborted_clients';
VARIABLE_VALUE
0
KILL CONNECTION_ID();
ERROR 70100: Connection was killed
SELECT VARIABLE_VALUE FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME='aborted_clients';
VARIABLE_VALUE
1
FLUSH STATUS;

View File

@ -516,3 +516,25 @@ pk
1 1
18446744073709551614 18446744073709551614
DROP TABLE t1; DROP TABLE t1;
CREATE TABLE t1 (pk BIGINT UNSIGNED AUTO_INCREMENT, PRIMARY KEY (pk));
insert into t1 values((1<<63)+1);
insert into t1 values(null);
select last_insert_id();
last_insert_id()
9223372036854775810
select * from t1;
pk
9223372036854775809
9223372036854775810
drop table t1;
CREATE TABLE t1 (pk BIGINT AUTO_INCREMENT, PRIMARY KEY (pk));
insert into t1 values(-5);
insert into t1 values(null);
select last_insert_id();
last_insert_id()
1
select * from t1;
pk
-5
1
drop table t1;

View File

@ -0,0 +1,11 @@
#
# Bug #11880012: INDEX_SUBQUERY, BLACKHOLE,
# HANG IN PREPARING WITH 100% CPU USAGE
#
CREATE TABLE t1(a INT NOT NULL);
INSERT INTO t1 VALUES (1), (2), (3);
CREATE TABLE t2 (a INT UNSIGNED, b INT, UNIQUE KEY (a, b)) ENGINE=BLACKHOLE;
SELECT 1 FROM t1 WHERE a = ANY (SELECT a FROM t2);
1
DROP TABLE t1, t2;
End of 5.5 tests

View File

@ -728,6 +728,15 @@ length(CONVERT(repeat('a',2048), CHAR(2049)))
Warnings: Warnings:
Warning 1301 Result of cast_as_char() was larger than max_allowed_packet (2048) - truncated Warning 1301 Result of cast_as_char() was larger than max_allowed_packet (2048) - truncated
SET @@GLOBAL.max_allowed_packet=default; SET @@GLOBAL.max_allowed_packet=default;
#
# Bug#13519724 63793: CRASH IN DTCOLLATION::SET(DTCOLLATION &SET)
#
CREATE TABLE t1 (a VARCHAR(50));
SELECT a FROM t1
WHERE CAST(a as BINARY)=x'62736D697468'
AND CAST(a AS BINARY)=x'65736D697468';
a
DROP TABLE t1;
End of 5.1 tests End of 5.1 tests
select cast("2101-00-01 02:03:04" as datetime); select cast("2101-00-01 02:03:04" as datetime);
cast("2101-00-01 02:03:04" as datetime) cast("2101-00-01 02:03:04" as datetime)

View File

@ -257,3 +257,27 @@ connect(localhost,mysqltest_nouser,,test,MASTER_PORT,MASTER_SOCKET);
ERROR 28000: Access denied for user 'mysqltest_nouser'@'localhost' (using password: NO) ERROR 28000: Access denied for user 'mysqltest_nouser'@'localhost' (using password: NO)
DROP USER mysqltest_up1@'%'; DROP USER mysqltest_up1@'%';
DROP USER mysqltest_up2@'%'; DROP USER mysqltest_up2@'%';
#
# BUG#1010351: New "via" keyword in 5.2+ can't be used as identifier anymore
#
create table t1 (via int);
alter table t1 add key(via);
drop table t1;
create table t1 (col1 int);
alter table t1 add via int not null;
drop table t1;
drop procedure if exists p1;
create procedure p1(x int)
foo: loop
if x = 0 then
leave foo;
end if;
select 'test';
set x = x-1;
end loop foo|
call p1(2);
test
test
test
test
drop procedure p1;

View File

@ -2044,6 +2044,77 @@ a
drop table t1,t2; drop table t1,t2;
set optimizer_switch=@save968720_optimizer_switch; set optimizer_switch=@save968720_optimizer_switch;
# #
# LP BUG#978847 Server crashes in Item_ref::real_item on
# INSERT .. SELECT with FROM subquery and derived_merge=ON
SET @save978847_optimizer_switch=@@optimizer_switch;
SET optimizer_switch = 'derived_merge=on';
CREATE TABLE t1 ( a INT, b INT );
INSERT INTO t1 VALUES (2,1),(3,2);
select * from t1;
a b
2 1
3 2
INSERT INTO t1 SELECT * FROM
( SELECT * FROM t1 ) AS alias;
select * from t1;
a b
2 1
3 2
2 1
3 2
prepare stmt1 from 'INSERT INTO t1 SELECT SQL_BIG_RESULT * FROM
( SELECT * FROM t1 ) AS alias';
execute stmt1;
select * from t1;
a b
2 1
3 2
2 1
3 2
2 1
3 2
2 1
3 2
execute stmt1;
select * from t1;
a b
2 1
3 2
2 1
3 2
2 1
3 2
2 1
3 2
2 1
3 2
2 1
3 2
2 1
3 2
2 1
3 2
drop table t1;
set optimizer_switch=@save978847_optimizer_switch;
#
# LP bug998516 Server hangs on INSERT .. SELECT with derived_merge,
# FROM subquery, UNION
#
CREATE TABLE t1 (a INT);
INSERT INTO t1 VALUES (1),(2);
CREATE TABLE t2 (b INT);
INSERT INTO t2 VALUES (3),(4);
INSERT INTO t1 SELECT * FROM ( SELECT * FROM t1 ) AS alias UNION SELECT * FROM t2;
select * from t1;
a
1
2
1
2
3
4
drop table t1,t2;
#
# end of 5.3 tests # end of 5.3 tests
# #
set optimizer_switch=@exit_optimizer_switch; set optimizer_switch=@exit_optimizer_switch;

View File

@ -146,3 +146,17 @@ ERROR 22003: BIGINT value is out of range in '(-(73) * -(2465717823867977728))'
# #
# End Bug#57882 # End Bug#57882
# #
CREATE TABLE t1 (a INT);
CREATE TABLE t2(a INT PRIMARY KEY, b INT);
SELECT '' AS b FROM t1 GROUP BY VALUES(b);
ERROR 42S22: Unknown column '' in 'VALUES() function'
REPLACE t2(b) SELECT '' AS b FROM t1 GROUP BY VALUES(b);
ERROR 42S22: Unknown column '' in 'VALUES() function'
UPDATE t2 SET a=(SELECT '' AS b FROM t1 GROUP BY VALUES(b));
ERROR 42S22: Unknown column '' in 'VALUES() function'
INSERT INTO t2 VALUES (1,0) ON DUPLICATE KEY UPDATE
b=(SELECT '' AS b FROM t1 GROUP BY VALUES(b));
ERROR 42S22: Unknown column '' in 'VALUES() function'
INSERT INTO t2(a,b) VALUES (1,0) ON DUPLICATE KEY UPDATE
b=(SELECT VALUES(a)+2 FROM t1);
DROP TABLE t1, t2;

View File

@ -0,0 +1,5 @@
FLUSH TABLES WITH READ LOCK AND DISABLE CHECKPOINT;
UNLOCK TABLES;
CREATE TABLE t1 ( m MEDIUMTEXT ) ENGINE=InnoDB;
INSERT INTO t1 VALUES ( REPEAT('i',1048576) );
DROP TABLE t1;

View File

@ -692,8 +692,10 @@ PREPARE stmt FROM
WHERE t1.f1 GROUP BY t1.f1))'; WHERE t1.f1 GROUP BY t1.f1))';
EXECUTE stmt; EXECUTE stmt;
1 1
1
EXECUTE stmt; EXECUTE stmt;
1 1
1
DEALLOCATE PREPARE stmt; DEALLOCATE PREPARE stmt;
DROP TABLE t1; DROP TABLE t1;
End of 5.1 tests End of 5.1 tests

View File

@ -146,6 +146,19 @@ count(*) min(7) max(7)
0 NULL NULL 0 NULL NULL
drop table t1m, t1i, t2m, t2i; drop table t1m, t1i, t2m, t2i;
# #
# Bug#13723054 CRASH WITH MIN/MAX AFTER QUICK_GROUP_MIN_MAX_SELECT::NEXT_MIN
#
CREATE TABLE t1(a BLOB, b VARCHAR(255) CHARSET LATIN1, c INT,
KEY(b, c, a(765))) ENGINE=INNODB;
INSERT INTO t1(a, b, c) VALUES ('', 'a', 0), ('', 'a', null), ('', 'a', 0);
SELECT MIN(c) FROM t1 GROUP BY b;
MIN(c)
0
EXPLAIN SELECT MIN(c) FROM t1 GROUP BY b;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 range NULL b 263 NULL 4 Using index for group-by
DROP TABLE t1;
#
# Bug #57954: BIT_AND function returns incorrect results when # Bug #57954: BIT_AND function returns incorrect results when
# semijoin=on # semijoin=on
CREATE TABLE c ( CREATE TABLE c (

View File

@ -217,3 +217,20 @@ foo
Warnings: Warnings:
Warning 1292 Truncated incorrect DOUBLE value: 'a' Warning 1292 Truncated incorrect DOUBLE value: 'a'
Warning 1292 Truncated incorrect DOUBLE value: 'a' Warning 1292 Truncated incorrect DOUBLE value: 'a'
#
# LP bug#998321 Simple query with IF expression causes an
# assertion abort (see also mysql Bug#12620084)
#
SELECT if(0, (SELECT min('hello')), NULL);
if(0, (SELECT min('hello')), NULL)
NULL
SELECT if(1, (SELECT min('hello')), NULL);
if(1, (SELECT min('hello')), NULL)
hello
SELECT if(0, NULL, (SELECT min('hello')));
if(0, NULL, (SELECT min('hello')))
hello
SELECT if(1, NULL, (SELECT min('hello')));
if(1, NULL, (SELECT min('hello')))
NULL
End of 5.2 tests

View File

@ -434,3 +434,21 @@ ST_WITHIN( MULTIPOINTFROMTEXT(' MULTIPOINT( 2 9 , 2 9 , 4 9 , 9 1 ) ') , POLYGON
SELECT ST_INTERSECTS( GeomFromText('MULTILINESTRING( ( 4030 3045 , 3149 2461 , 3004 3831 , 3775 2976 ) )') , GeomFromText('LINESTRING(3058.41 3187.91,3081.52 3153.19,3042.99 3127.57,3019.89 3162.29,3039.07 3175.05,3039.07 3175.05,3058.41 3187.91,3081.52 3153.19,3042.99 3127.57,3019.89 3162.29)') ); SELECT ST_INTERSECTS( GeomFromText('MULTILINESTRING( ( 4030 3045 , 3149 2461 , 3004 3831 , 3775 2976 ) )') , GeomFromText('LINESTRING(3058.41 3187.91,3081.52 3153.19,3042.99 3127.57,3019.89 3162.29,3039.07 3175.05,3039.07 3175.05,3058.41 3187.91,3081.52 3153.19,3042.99 3127.57,3019.89 3162.29)') );
ST_INTERSECTS( GeomFromText('MULTILINESTRING( ( 4030 3045 , 3149 2461 , 3004 3831 , 3775 2976 ) )') , GeomFromText('LINESTRING(3058.41 3187.91,3081.52 3153.19,3042.99 3127.57,3019.89 3162.29,3039.07 3175.05,3039.07 3175.05,3058.41 3187.91,3081.52 3153.19, ST_INTERSECTS( GeomFromText('MULTILINESTRING( ( 4030 3045 , 3149 2461 , 3004 3831 , 3775 2976 ) )') , GeomFromText('LINESTRING(3058.41 3187.91,3081.52 3153.19,3042.99 3127.57,3019.89 3162.29,3039.07 3175.05,3039.07 3175.05,3058.41 3187.91,3081.52 3153.19,
1 1
select ASTEXT(ST_BUFFER(ST_GEOMCOLLFROMTEXT(' GEOMETRYCOLLECTION(LINESTRING(100 100, 31 10, 77 80), POLYGON((0 0,4 7,1 1,0 0)), POINT(20 20))'), -3));
ASTEXT(ST_BUFFER(ST_GEOMCOLLFROMTEXT(' GEOMETRYCOLLECTION(LINESTRING(100 100, 31 10, 77 80), POLYGON((0 0,4 7,1 1,0 0)), POINT(20 20))'), -3))
POLYGON((3.999999999999999 6.999999999999998,4 7,3.999999999999999 6.999999999999998))
SELECT ST_NUMPOINTS(ST_EXTERIORRING(ST_BUFFER( POLYGONFROMTEXT( 'POLYGON( ( 0.0 -3.0,
-2.910427500435995 0.727606875108998,
-0.910427500435995 8.727606875108998,
7.664100588675687 1.503849116986468,
1.664100588675687 -2.496150883013531,
0.0 -3.0
))' ), 3 )));
ST_NUMPOINTS(ST_EXTERIORRING(ST_BUFFER( POLYGONFROMTEXT( 'POLYGON( ( 0.0 -3.0,
-2.910427500435995 0.727606875108998,
-0.910427500435995 8.727606875108998,
7.664100588675687 1.503849116986468,
1.664100588675687 -2.496150883013531,
0.0 -3.0
))' ),
136

View File

@ -20,7 +20,17 @@ id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 range g g 34 NULL 8 Using where 1 SIMPLE t1 range g g 34 NULL 8 Using where
SELECT fid, AsText(g) FROM t1 WHERE ST_Within(g, GeomFromText('Polygon((140 140,160 140,160 160,140 160,140 140))')); SELECT fid, AsText(g) FROM t1 WHERE ST_Within(g, GeomFromText('Polygon((140 140,160 140,160 160,140 160,140 140))'));
fid AsText(g) fid AsText(g)
1 LINESTRING(150 150,150 150)
3 LINESTRING(148 148,152 152)
4 LINESTRING(147 147,153 153)
5 LINESTRING(146 146,154 154)
6 LINESTRING(145 145,155 155)
7 LINESTRING(144 144,156 156)
8 LINESTRING(143 143,157 157)
9 LINESTRING(142 142,158 158)
10 LINESTRING(141 141,159 159)
11 LINESTRING(140 140,160 160) 11 LINESTRING(140 140,160 160)
2 LINESTRING(149 149,151 151)
DROP TABLE t1; DROP TABLE t1;
CREATE TABLE t1 ( CREATE TABLE t1 (
fid INT NOT NULL AUTO_INCREMENT PRIMARY KEY, fid INT NOT NULL AUTO_INCREMENT PRIMARY KEY,
@ -45,5 +55,8 @@ id select_type table type possible_keys key key_len ref rows Extra
SELECT fid, AsText(g) FROM t1 WHERE ST_Within(g, SELECT fid, AsText(g) FROM t1 WHERE ST_Within(g,
GeomFromText('Polygon((40 40,60 40,60 60,40 40))')); GeomFromText('Polygon((40 40,60 40,60 60,40 40))'));
fid AsText(g) fid AsText(g)
46 LINESTRING(51 41,60 50)
56 LINESTRING(41 41,50 50)
45 LINESTRING(51 51,60 60)
DROP TABLE t1; DROP TABLE t1;
End of 5.5 tests. End of 5.5 tests.

View File

@ -170,7 +170,17 @@ id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 range g g 34 NULL 8 Using where 1 SIMPLE t1 range g g 34 NULL 8 Using where
SELECT fid, AsText(g) FROM t1 WHERE Within(g, GeomFromText('Polygon((140 140,160 140,160 160,140 160,140 140))')); SELECT fid, AsText(g) FROM t1 WHERE Within(g, GeomFromText('Polygon((140 140,160 140,160 160,140 160,140 140))'));
fid AsText(g) fid AsText(g)
1 LINESTRING(150 150,150 150)
3 LINESTRING(148 148,152 152)
4 LINESTRING(147 147,153 153)
5 LINESTRING(146 146,154 154)
6 LINESTRING(145 145,155 155)
7 LINESTRING(144 144,156 156)
8 LINESTRING(143 143,157 157)
9 LINESTRING(142 142,158 158)
10 LINESTRING(141 141,159 159)
11 LINESTRING(140 140,160 160) 11 LINESTRING(140 140,160 160)
2 LINESTRING(149 149,151 151)
DROP TABLE t1; DROP TABLE t1;
CREATE TABLE t2 ( CREATE TABLE t2 (
fid INT NOT NULL AUTO_INCREMENT PRIMARY KEY, fid INT NOT NULL AUTO_INCREMENT PRIMARY KEY,
@ -295,6 +305,10 @@ id select_type table type possible_keys key key_len ref rows Extra
SELECT fid, AsText(g) FROM t2 WHERE Within(g, SELECT fid, AsText(g) FROM t2 WHERE Within(g,
GeomFromText('Polygon((40 40,60 40,60 60,40 60,40 40))')); GeomFromText('Polygon((40 40,60 40,60 60,40 60,40 40))'));
fid AsText(g) fid AsText(g)
46 LINESTRING(51 41,60 50)
56 LINESTRING(41 41,50 50)
45 LINESTRING(51 51,60 60)
55 LINESTRING(41 51,50 60)
DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(Point(10 * 10 - 9, 10 * 10 - 9), Point(10 * 10, 10 * 10)))); DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(Point(10 * 10 - 9, 10 * 10 - 9), Point(10 * 10, 10 * 10))));
SELECT count(*) FROM t2; SELECT count(*) FROM t2;
count(*) count(*)

View File

@ -1430,6 +1430,19 @@ count(*)
DROP DATABASE gis_ogs; DROP DATABASE gis_ogs;
USE test; USE test;
# #
# BUG#12414917 - ISCLOSED() CRASHES ON 64-BIT BUILDS
#
SELECT ISCLOSED(CONVERT(CONCAT(' ', 0x2), BINARY(20)));
ISCLOSED(CONVERT(CONCAT(' ', 0x2), BINARY(20)))
NULL
#
# BUG#12537203 - CRASH WHEN SUBSELECTING GLOBAL VARIABLES IN
# GEOMETRY FUNCTION ARGUMENTS
#
SELECT GEOMETRYCOLLECTION((SELECT @@OLD));
ERROR 22007: Illegal non geometric '' value found during parsing
End of 5.1 tests
#
# Bug#11908153: CRASH AND/OR VALGRIND ERRORS IN FIELD_BLOB::GET_KEY_IMAGE # Bug#11908153: CRASH AND/OR VALGRIND ERRORS IN FIELD_BLOB::GET_KEY_IMAGE
# #
CREATE TABLE g1 CREATE TABLE g1

View File

@ -1976,6 +1976,133 @@ Warning 1292 Truncated incorrect DOUBLE value: 'g'
Warning 1292 Truncated incorrect DOUBLE value: 'v' Warning 1292 Truncated incorrect DOUBLE value: 'v'
SET SESSION SQL_MODE=default; SET SESSION SQL_MODE=default;
drop table t1; drop table t1;
#
# LP bug#967242 Wrong result (extra rows, not grouped) with JOIN, AND in ON condition, multi-part key, GROUP BY, OR in WHERE
#
CREATE TABLE t1 ( a VARCHAR(1) ) ENGINE=MyISAM;
INSERT INTO t1 VALUES ('x');
CREATE TABLE t2 ( b INT, c VARCHAR(1), KEY (c, b) ) ENGINE=MyISAM;
INSERT INTO t2 VALUES
(4, 'd'),(8, 'g'),(3, 'x'),(3, 'f'),
(0, 'p'),(3, 'j'),(8, 'c');
SELECT t2_1.b as zzz
FROM t1 JOIN t2 AS t2_1 JOIN t2 AS t2_2
ON (t2_2.b = t2_1.b ) AND (t2_2.c = t2_1.c )
WHERE
rand() + 1 > 0 OR
a = t2_1.c
GROUP BY zzz;
zzz
0
3
4
8
SELECT t2_1.b as zzz
FROM t1 JOIN t2 AS t2_1 JOIN t2 AS t2_2
ON (t2_2.b = t2_1.b ) AND (t2_2.c = t2_1.c )
WHERE
1 > 0 OR
a = t2_1.c
GROUP BY zzz;
zzz
0
3
4
8
SELECT t2_1.b as zzz
FROM t1 JOIN t2 AS t2_1 JOIN t2 AS t2_2
ON (t2_2.b = t2_1.b ) AND (t2_2.c = t2_1.c )
WHERE
t2_1.b + 1 > 0 OR
a = t2_1.c
GROUP BY zzz;
zzz
0
3
4
8
SET @save_optimizer_switch967242=@@optimizer_switch;
SET optimizer_switch = 'in_to_exists=on';
SELECT t2_1.b
FROM t1 JOIN t2 AS t2_1 JOIN t2 AS t2_2
ON (t2_2.b = t2_1.b ) AND (t2_2.c = t2_1.c )
WHERE
( SELECT COUNT(*) FROM t2 ) IS NOT NULL
OR a = t2_1.c
GROUP BY t2_1.b;
b
0
3
4
8
SET optimizer_switch=@save_optimizer_switch967242;
drop table t1, t2;
#
# Bug#12578908: SELECT SQL_BUFFER_RESULT OUTPUTS TOO MANY
# ROWS WHEN GROUP IS OPTIMIZED AWAY
#
CREATE TABLE t1 (col1 int, col2 int) ;
INSERT INTO t1 VALUES (10,1),(11,7);
CREATE TABLE t2 (col1 int, col2 int) ;
INSERT INTO t2 VALUES (10,8);
EXPLAIN SELECT SQL_BUFFER_RESULT t2.col2 FROM t2 JOIN t1 ON t1.col1 GROUP BY t2.col2;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t2 system NULL NULL NULL NULL 1 Using temporary
1 SIMPLE t1 ALL NULL NULL NULL NULL 2 Using where
SELECT SQL_BUFFER_RESULT t2.col2 FROM t2 JOIN t1 ON t1.col1 GROUP BY t2.col2;
col2
8
EXPLAIN SELECT t2.col2 FROM t2 JOIN t1 ON t1.col1 GROUP BY t2.col2;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t2 system NULL NULL NULL NULL 1
1 SIMPLE t1 ALL NULL NULL NULL NULL 2 Using where
SELECT t2.col2 FROM t2 JOIN t1 ON t1.col1 GROUP BY t2.col2;
col2
8
DROP TABLE t1,t2;
#
# BUG#12640437: USING SQL_BUFFER_RESULT RESULTS IN A
# DIFFERENT QUERY OUTPUT
#
CREATE TABLE t1 (
a int,
b varchar(1),
KEY (b,a)
);
INSERT INTO t1 VALUES (1,NULL),(0,'a');
EXPLAIN SELECT SQL_BUFFER_RESULT MIN(a), b FROM t1 WHERE t1.b = 'a' GROUP BY b;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 range b b 9 NULL 2 Using where; Using index for group-by; Using temporary
SELECT SQL_BUFFER_RESULT MIN(a), b FROM t1 WHERE t1.b = 'a' GROUP BY b;
MIN(a) b
0 a
EXPLAIN SELECT MIN(a), b FROM t1 WHERE t1.b = 'a' GROUP BY b;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 range b b 9 NULL 2 Using where; Using index for group-by
SELECT MIN(a), b FROM t1 WHERE t1.b = 'a' GROUP BY b;
MIN(a) b
0 a
DROP TABLE t1;
#
# LP bug#993726 Wrong result from a query with ALL subquery predicate in WHERE
#
CREATE TABLE t1(a INT);
INSERT INTO t1 VALUES (0);
SELECT 1 FROM t1 WHERE 1 > ALL(SELECT 1 FROM t1 WHERE a!=0);
1
1
SELECT max(1) FROM t1 WHERE a!=0;
max(1)
NULL
drop table t1;
# End of 5.2 tests # End of 5.2 tests
# #
# lp:872702: Crash in add_ref_to_table_cond() when grouping by a PK # lp:872702: Crash in add_ref_to_table_cond() when grouping by a PK

View File

@ -1,13 +1,14 @@
install plugin handlersocket soname 'handlersocket.so'; install plugin handlersocket soname 'handlersocket.so';
select plugin_name, plugin_version, plugin_status, plugin_type, plugin_library, plugin_library_version, plugin_author, plugin_description plugin_license, plugin_maturity, plugin_auth_version from information_schema.plugins where plugin_name = 'handlersocket'; select plugin_name, plugin_version, plugin_status, plugin_type, plugin_library, plugin_library_version, plugin_author, plugin_description, plugin_license, plugin_maturity, plugin_auth_version from information_schema.plugins where plugin_name = 'handlersocket';
plugin_name handlersocket plugin_name handlersocket
plugin_version 1.0 plugin_version 1.0
plugin_status ACTIVE plugin_status ACTIVE
plugin_type DAEMON plugin_type DAEMON
plugin_library handlersocket.so plugin_library handlersocket.so
plugin_library_version 0.0 plugin_library_version 1.3
plugin_author higuchi dot akira at dena dot jp plugin_author higuchi dot akira at dena dot jp
plugin_license plugin_description Direct access into InnoDB
plugin_maturity Unknown plugin_license BSD
plugin_auth_version Unknown plugin_maturity Beta
plugin_auth_version 1.0
uninstall plugin handlersocket; uninstall plugin handlersocket;

View File

@ -0,0 +1,5 @@
DROP TABLE IF EXISTS t1;
CREATE TABLE t1 ( a DATE );
SELECT * FROM t1 WHERE ( SELECT a FROM t1 ) IN ('2012-04-25','2012-04-26');
a
DROP TABLE t1;

View File

@ -745,4 +745,36 @@ WHERE v1 IN ('f', 'd', 'h', 'u' ) AND i = 2;
id select_type table type possible_keys key key_len ref rows Extra id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 ref i,v i 5 const 2 Using where 1 SIMPLE t1 ref i,v i 5 const 2 Using where
DROP TABLE t1; DROP TABLE t1;
#
# BUG#1006164: Multi-table DELETE that uses innodb + index_merge/intersect may fail to delete rows
#
create table t0(a int);
insert into t0 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9);
create table t1 (
pk int auto_increment,
zone_id int,
modified tinyint,
primary key(pk),
key (zone_id),
key (modified)
) engine=innodb;
insert into t1 (zone_id, modified) select 0,0 from t0 A, t0 B, t0 C, t0 D;
update t1 set zone_id=487, modified=9 where pk=7259;
update t1 set zone_id=487, modified=9 where pk=7260;
update t1 set zone_id=830, modified=9 where pk=8434;
update t1 set zone_id=830, modified=9 where pk=8435;
update t1 set zone_id=830, modified=9 where pk=8436;
update t1 set zone_id=830, modified=9 where pk=8437;
select * from t1 where t1.zone_id=830 AND modified=9;
pk zone_id modified
8434 830 9
8435 830 9
8436 830 9
8437 830 9
begin;
DELETE t1 FROM t1 WHERE t1.zone_id=830 AND modified=9;
commit;
select * from t1 where t1.zone_id=830 AND modified=9;
pk zone_id modified
drop table t0, t1;
set optimizer_switch= @optimizer_switch_save; set optimizer_switch= @optimizer_switch_save;

View File

@ -835,6 +835,22 @@ Variable_name Value
Handler_icp_attempts 2 Handler_icp_attempts 2
Handler_icp_match 1 Handler_icp_match 1
DROP TABLE t1; DROP TABLE t1;
create table t1 (a int,b char(5),primary key (a), key (b(1)));
insert into t1 values ('a','b');
Warnings:
Warning 1366 Incorrect integer value: 'a' for column 'a' at row 1
select 1 from t1 where a and b >= 'aa';
1
drop table t1;
#
# Bug#58015 "Assert in row_sel_field_store_in_mysql_format
# when running innodb_mrr_icp test"
#
create table t1 (a char(2) charset utf8,b double, primary key (a(1)),key (b));
insert into t1 values ('',1);
select 1 from t1 where b <= 1 and a <> '';
1
drop table t1;
# #
# BUG#920132: Assert trx->n_active_thrs == 1 failed at que0que.c line 1050 # BUG#920132: Assert trx->n_active_thrs == 1 failed at que0que.c line 1050
# #

View File

@ -3221,7 +3221,7 @@ explain
select t1.a, count(t2.p) as count select t1.a, count(t2.p) as count
from t1 left join t2 on t1.a=t2.a and t2.p % 2 = 1 group by t1.a; from t1 left join t2 on t1.a=t2.a and t2.p % 2 = 1 group by t1.a;
id select_type table type possible_keys key key_len ref rows Extra id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 ALL NULL NULL NULL NULL 8 Using temporary; Using filesort 1 SIMPLE t1 index NULL PRIMARY 4 NULL 8 Using index; Using temporary; Using filesort
1 SIMPLE t2 ref i_a i_a 5 test.t1.a 2 Using where; Using join buffer (flat, BKA join); Key-ordered Rowid-ordered scan 1 SIMPLE t2 ref i_a i_a 5 test.t1.a 2 Using where; Using join buffer (flat, BKA join); Key-ordered Rowid-ordered scan
select t1.a, count(t2.p) as count select t1.a, count(t2.p) as count
from t1 left join t2 on t1.a=t2.a and t2.p % 2 = 1 group by t1.a; from t1 left join t2 on t1.a=t2.a and t2.p % 2 = 1 group by t1.a;
@ -4274,7 +4274,7 @@ pk int NOT NULL, i int NOT NULL, v varchar(1) NOT NULL,
PRIMARY KEY (pk), INDEX idx1(i), INDEX idx2 (v,i) PRIMARY KEY (pk), INDEX idx1(i), INDEX idx2 (v,i)
) COLLATE latin1_bin; ) COLLATE latin1_bin;
INSERT INTO t1 VALUES INSERT INTO t1 VALUES
(10,8,'v'), (11,8,'f'), (12,5,'v'), (13,8,'s'), (14,8,'a'), (10,8,'v'), (11,8,'f'), (13,8,'s'), (14,8,'a'),
(15,6,'p'), (16,7,'z'), (17,2,'a'), (18,5,'h'), (19,7,'h'), (15,6,'p'), (16,7,'z'), (17,2,'a'), (18,5,'h'), (19,7,'h'),
(25,3,'m'), (26,5,'a'), (27,9,'n'), (28,1,'d'), (29,107,'a'); (25,3,'m'), (26,5,'a'), (27,9,'n'), (28,1,'d'), (29,107,'a');
INSERT INTO t1 VALUES INSERT INTO t1 VALUES
@ -4327,7 +4327,7 @@ SELECT t2.v FROM t1, t2, t3
WHERE t3.v <> t2.v AND t3.pk = t2.i AND t1.v = t3.v AND t1.pk*2<100 WHERE t3.v <> t2.v AND t3.pk = t2.i AND t1.v = t3.v AND t1.pk*2<100
GROUP BY t2.v ORDER BY t1.pk,t2.v; GROUP BY t2.v ORDER BY t1.pk,t2.v;
id select_type table type possible_keys key key_len ref rows Extra id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t2 ALL idx1 NULL NULL NULL 20 Using temporary; Using filesort 1 SIMPLE t2 index idx1 idx2 7 NULL 20 Using index; Using temporary; Using filesort
1 SIMPLE t3 eq_ref PRIMARY,idx2 PRIMARY 4 test.t2.i 1 Using where; Using join buffer (flat, BKA join); Key-ordered Rowid-ordered scan 1 SIMPLE t3 eq_ref PRIMARY,idx2 PRIMARY 4 test.t2.i 1 Using where; Using join buffer (flat, BKA join); Key-ordered Rowid-ordered scan
1 SIMPLE t1 ref idx2 idx2 3 test.t3.v 5 Using where; Using join buffer (incremental, BKA join); Key-ordered Rowid-ordered scan 1 SIMPLE t1 ref idx2 idx2 3 test.t3.v 5 Using where; Using join buffer (incremental, BKA join); Key-ordered Rowid-ordered scan
SELECT t2.v FROM t1, t2, t3 SELECT t2.v FROM t1, t2, t3
@ -4345,9 +4345,9 @@ SELECT t2.v FROM t1, t2, t3
WHERE t3.v <> t2.v AND t3.pk = t2.i AND t1.v = t3.v AND t1.pk*2<100 WHERE t3.v <> t2.v AND t3.pk = t2.i AND t1.v = t3.v AND t1.pk*2<100
GROUP BY t2.v ORDER BY t1.pk,t2.v; GROUP BY t2.v ORDER BY t1.pk,t2.v;
id select_type table type possible_keys key key_len ref rows Extra id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t2 ALL idx1 NULL NULL NULL 20 Using temporary; Using filesort 1 SIMPLE t2 index idx1 idx2 7 NULL 20 Using index; Using temporary; Using filesort
1 SIMPLE t3 hash_ALL PRIMARY,idx2 #hash#PRIMARY 4 test.t2.i 20 Using where; Using join buffer (flat, BNLH join) 1 SIMPLE t3 hash_ALL PRIMARY,idx2 #hash#PRIMARY 4 test.t2.i 20 Using where; Using join buffer (flat, BNLH join)
1 SIMPLE t1 hash_ALL idx2 #hash#idx2 3 test.t3.v 45 Using where; Using join buffer (incremental, BNLH join) 1 SIMPLE t1 hash_ALL idx2 #hash#idx2 3 test.t3.v 44 Using where; Using join buffer (incremental, BNLH join)
SELECT t2.v FROM t1, t2, t3 SELECT t2.v FROM t1, t2, t3
WHERE t3.v <> t2.v AND t3.pk = t2.i AND t1.v = t3.v AND t1.pk*2<100 WHERE t3.v <> t2.v AND t3.pk = t2.i AND t1.v = t3.v AND t1.pk*2<100
GROUP BY t2.v ORDER BY t1.pk,t2.v; GROUP BY t2.v ORDER BY t1.pk,t2.v;

View File

@ -1855,6 +1855,30 @@ f1 f1 f2
DROP TABLE t1,t2; DROP TABLE t1,t2;
End of 5.1 tests End of 5.1 tests
# #
# LP BUG#994392: Wrong result with RIGHT/LEFT JOIN and ALL subquery
# predicate in WHERE condition.
#
CREATE TABLE t1(a INT);
INSERT INTO t1 VALUES(9);
CREATE TABLE t2(b INT);
INSERT INTO t2 VALUES(8);
CREATE TABLE t3(c INT);
INSERT INTO t3 VALUES(3);
SELECT * FROM t2 RIGHT JOIN t3 ON(c = b) WHERE b < ALL(SELECT a FROM t1 WHERE a <= 7);
b c
NULL 3
SELECT * FROM t3 LEFT JOIN t2 ON(c = b) WHERE b < ALL(SELECT a FROM t1 WHERE a <= 7);
c b
3 NULL
SELECT * FROM t2 RIGHT JOIN t3 ON(c = b) WHERE b not in (SELECT a FROM t1 WHERE a <= 7);
b c
NULL 3
SELECT * FROM t3 LEFT JOIN t2 ON(c = b) WHERE b not in (SELECT a FROM t1 WHERE a <= 7);
c b
3 NULL
drop table t1,t2,t3;
End of 5.2 tests
#
# LP bug #813447: LEFT JOIN with single-row inner table and # LP bug #813447: LEFT JOIN with single-row inner table and
# a subquery in ON expression # a subquery in ON expression
# #
@ -1872,7 +1896,7 @@ 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 id select_type table type possible_keys key key_len ref rows filtered Extra
1 PRIMARY t1 system NULL NULL NULL NULL 1 100.00 1 PRIMARY t1 system NULL NULL NULL NULL 1 100.00
1 PRIMARY t2 ALL NULL NULL NULL NULL 1 100.00 Using where 1 PRIMARY t2 ALL NULL NULL NULL NULL 1 100.00 Using where
2 DEPENDENT SUBQUERY t3 ALL NULL NULL NULL NULL 2 100.00 Using where 2 SUBQUERY t3 ALL NULL NULL NULL NULL 2 100.00 Using where
Warnings: Warnings:
Note 1003 select `test`.`t2`.`a` AS `a` from `test`.`t2` where 1 Note 1003 select `test`.`t2`.`a` AS `a` from `test`.`t2` where 1
DROP TABLE t1,t2,t3; DROP TABLE t1,t2,t3;

View File

@ -1866,6 +1866,30 @@ f1 f1 f2
DROP TABLE t1,t2; DROP TABLE t1,t2;
End of 5.1 tests End of 5.1 tests
# #
# LP BUG#994392: Wrong result with RIGHT/LEFT JOIN and ALL subquery
# predicate in WHERE condition.
#
CREATE TABLE t1(a INT);
INSERT INTO t1 VALUES(9);
CREATE TABLE t2(b INT);
INSERT INTO t2 VALUES(8);
CREATE TABLE t3(c INT);
INSERT INTO t3 VALUES(3);
SELECT * FROM t2 RIGHT JOIN t3 ON(c = b) WHERE b < ALL(SELECT a FROM t1 WHERE a <= 7);
b c
NULL 3
SELECT * FROM t3 LEFT JOIN t2 ON(c = b) WHERE b < ALL(SELECT a FROM t1 WHERE a <= 7);
c b
3 NULL
SELECT * FROM t2 RIGHT JOIN t3 ON(c = b) WHERE b not in (SELECT a FROM t1 WHERE a <= 7);
b c
NULL 3
SELECT * FROM t3 LEFT JOIN t2 ON(c = b) WHERE b not in (SELECT a FROM t1 WHERE a <= 7);
c b
3 NULL
drop table t1,t2,t3;
End of 5.2 tests
#
# LP bug #813447: LEFT JOIN with single-row inner table and # LP bug #813447: LEFT JOIN with single-row inner table and
# a subquery in ON expression # a subquery in ON expression
# #
@ -1883,7 +1907,7 @@ 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 id select_type table type possible_keys key key_len ref rows filtered Extra
1 PRIMARY t1 system NULL NULL NULL NULL 1 100.00 1 PRIMARY t1 system NULL NULL NULL NULL 1 100.00
1 PRIMARY t2 ALL NULL NULL NULL NULL 1 100.00 Using where 1 PRIMARY t2 ALL NULL NULL NULL NULL 1 100.00 Using where
2 DEPENDENT SUBQUERY t3 ALL NULL NULL NULL NULL 2 100.00 Using where 2 SUBQUERY t3 ALL NULL NULL NULL NULL 2 100.00 Using where
Warnings: Warnings:
Note 1003 select `test`.`t2`.`a` AS `a` from `test`.`t2` where 1 Note 1003 select `test`.`t2`.`a` AS `a` from `test`.`t2` where 1
DROP TABLE t1,t2,t3; DROP TABLE t1,t2,t3;

View File

@ -320,22 +320,22 @@ TRUNCATE TABLE mysql.slow_log;
CREATE TABLE t1 (a INT); CREATE TABLE t1 (a INT);
CREATE TABLE t2 (b INT, PRIMARY KEY (b)); CREATE TABLE t2 (b INT, PRIMARY KEY (b));
INSERT INTO t2 VALUES (3),(4); INSERT INTO t2 VALUES (3),(4);
INSERT INTO t1 VALUES (1+sleep(.01)),(2); INSERT INTO t1 VALUES (1+sleep(.02)),(2);
INSERT INTO t1 SELECT b+sleep(.01) from t2; INSERT INTO t1 SELECT b+sleep(.02) from t2;
UPDATE t1 SET a=a+sleep(.01) WHERE a>2; UPDATE t1 SET a=a+sleep(.02) WHERE a>2;
UPDATE t1 SET a=a+sleep(.01) ORDER BY a DESC; UPDATE t1 SET a=a+sleep(.02) ORDER BY a DESC;
UPDATE t2 set b=b+sleep(.01) limit 1; UPDATE t2 set b=b+sleep(.02) limit 1;
UPDATE t1 SET a=a+sleep(.01) WHERE a in (SELECT b from t2); UPDATE t1 SET a=a+sleep(.02) WHERE a in (SELECT b from t2);
DELETE FROM t1 WHERE a=a+sleep(.01) ORDER BY a LIMIT 2; DELETE FROM t1 WHERE a=a+sleep(.02) ORDER BY a LIMIT 2;
SELECT rows_examined,sql_text FROM mysql.slow_log; SELECT rows_examined,sql_text FROM mysql.slow_log;
rows_examined sql_text rows_examined sql_text
0 INSERT INTO t1 VALUES (1+sleep(.01)),(2) 0 INSERT INTO t1 VALUES (1+sleep(.02)),(2)
2 INSERT INTO t1 SELECT b+sleep(.01) from t2 2 INSERT INTO t1 SELECT b+sleep(.02) from t2
4 UPDATE t1 SET a=a+sleep(.01) WHERE a>2 4 UPDATE t1 SET a=a+sleep(.02) WHERE a>2
8 UPDATE t1 SET a=a+sleep(.01) ORDER BY a DESC 8 UPDATE t1 SET a=a+sleep(.02) ORDER BY a DESC
1 UPDATE t2 set b=b+sleep(.01) limit 1 1 UPDATE t2 set b=b+sleep(.02) limit 1
4 UPDATE t1 SET a=a+sleep(.01) WHERE a in (SELECT b from t2) 4 UPDATE t1 SET a=a+sleep(.02) WHERE a in (SELECT b from t2)
6 DELETE FROM t1 WHERE a=a+sleep(.01) ORDER BY a LIMIT 2 6 DELETE FROM t1 WHERE a=a+sleep(.02) ORDER BY a LIMIT 2
DROP TABLE t1,t2; DROP TABLE t1,t2;
TRUNCATE TABLE mysql.slow_log; TRUNCATE TABLE mysql.slow_log;
# end of bug#49756 # end of bug#49756

View File

@ -165,7 +165,7 @@ WHERE ts BETWEEN '0000-00-00' AND '2010-00-01 00:00:00'
ORDER BY ts DESC ORDER BY ts DESC
LIMIT 2; LIMIT 2;
id select_type table type possible_keys key key_len ref rows Extra id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 range PRIMARY PRIMARY 4 NULL 4 Using index condition 1 SIMPLE t1 range PRIMARY PRIMARY 4 NULL 4 Using where
DROP TABLE t1; DROP TABLE t1;
# #
@ -839,6 +839,22 @@ Variable_name Value
Handler_icp_attempts 2 Handler_icp_attempts 2
Handler_icp_match 1 Handler_icp_match 1
DROP TABLE t1; DROP TABLE t1;
create table t1 (a int,b char(5),primary key (a), key (b(1)));
insert into t1 values ('a','b');
Warnings:
Warning 1366 Incorrect integer value: 'a' for column 'a' at row 1
select 1 from t1 where a and b >= 'aa';
1
drop table t1;
#
# Bug#58015 "Assert in row_sel_field_store_in_mysql_format
# when running innodb_mrr_icp test"
#
create table t1 (a char(2) charset utf8,b double, primary key (a(1)),key (b));
insert into t1 values ('',1);
select 1 from t1 where b <= 1 and a <> '';
1
drop table t1;
drop table if exists t0, t1, t1i, t1m; drop table if exists t0, t1, t1i, t1m;
# #
# BUG#826935 Assertion `!table || (!table->read_set || bitmap_is_set(table->read_set, field_index))' failed # BUG#826935 Assertion `!table || (!table->read_set || bitmap_is_set(table->read_set, field_index))' failed
@ -914,4 +930,23 @@ Warning 1292 Truncated incorrect DOUBLE value: 'c'
Warning 1292 Truncated incorrect DOUBLE value: 'c' Warning 1292 Truncated incorrect DOUBLE value: 'c'
SET optimizer_switch=@save_optimizer_switch; SET optimizer_switch=@save_optimizer_switch;
DROP TABLE t1,t2,t3,t4; DROP TABLE t1,t2,t3,t4;
#
# BUG#1000051: Query with simple join and ORDER BY takes thousands times longer when run with ICP
#
create table t0 (a int);
insert into t0 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9);
create table t1 (a int, col int, filler char(100), key(a, col));
insert into t1 select A.a + 10*B.a, 1234, 'filler' from t0 A, t0 B, t0 C;
set @tmp_10000051= @@optimizer_switch;
set optimizer_switch='mrr=off';
# Must not use ICP:
explain select * from t1 where a between 5 and 8 order by a desc, col desc;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 range a a 5 NULL 39 Using where
set optimizer_switch= @tmp_10000051;
# Must not use ICP:
explain select * from t1 where a=3 and col > 500 order by a desc, col desc;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 range a a 10 NULL 10 Using where
drop table t0, t1;
set optimizer_switch=@myisam_icp_tmp; set optimizer_switch=@myisam_icp_tmp;

View File

@ -241,3 +241,13 @@ mysql
performance_schema performance_schema
test test
DROP DATABASE bug58090; DROP DATABASE bug58090;
#
# Bug #11766072 - 59107: MYSQLSLAP CRASHES IF STARTED WITH NO ARGUMENTS ON WINDOWS
#
Benchmark
Average number of seconds to run all queries: TIME seconds
Minimum number of seconds to run all queries: TIME seconds
Maximum number of seconds to run all queries: TIME seconds
Number of clients running queries: 1
Average number of queries per client: 0

View File

@ -0,0 +1,7 @@
select error;
mysqltest: At line 1: query 'select error' failed: 1054: Unknown column 'error' in 'field list'
SELECT ERROR;
mysqltest: At line 1: query 'SELECT ERROR' failed: 1054: Unknown column 'ERROR' in 'field list'
SELECT 2;
2
2

View File

@ -3940,3 +3940,107 @@ Handler_read_rnd_deleted 0
Handler_read_rnd_next 0 Handler_read_rnd_next 0
deallocate prepare st; deallocate prepare st;
drop table t1; drop table t1;
#
# LP bug#993459 Execution of PS for a query with GROUP BY
# returns wrong result (see also mysql bug#13805127)
#
PREPARE s1 FROM
"
SELECT c1, t2.c2, count(c3)
FROM
(
SELECT 3 as c2 FROM dual WHERE @x = 1
UNION
SELECT 2 FROM dual WHERE @x = 1 OR @x = 2
) AS t1,
(
SELECT '2012-03-01 01:00:00' AS c1, 3 as c2, 1 as c3 FROM dual
UNION
SELECT '2012-03-01 02:00:00', 3, 2 FROM dual
UNION
SELECT '2012-03-01 01:00:00', 2, 1 FROM dual
) AS t2
WHERE t2.c2 = t1.c2
GROUP BY c1, c2
";
SET @x = 1;
SELECT c1, t2.c2, count(c3)
FROM
(
SELECT 3 as c2 FROM dual WHERE @x = 1
UNION
SELECT 2 FROM dual WHERE @x = 1 OR @x = 2
) AS t1,
(
SELECT '2012-03-01 01:00:00' AS c1, 3 as c2, 1 as c3 FROM dual
UNION
SELECT '2012-03-01 02:00:00', 3, 2 FROM dual
UNION
SELECT '2012-03-01 01:99345900:00', 2, 1 FROM dual
) AS t2
WHERE t2.c2 = t1.c2
GROUP BY c1, c2;
c1 c2 count(c3)
2012-03-01 01:00:00 3 1
2012-03-01 01:99345900:00 2 1
2012-03-01 02:00:00 3 1
EXECUTE s1;
c1 c2 count(c3)
2012-03-01 01:00:00 2 1
2012-03-01 01:00:00 3 1
2012-03-01 02:00:00 3 1
SET @x = 2;
SELECT c1, t2.c2, count(c3)
FROM
(
SELECT 3 as c2 FROM dual WHERE @x = 1
UNION
SELECT 2 FROM dual WHERE @x = 1 OR @x = 2
) AS t1,
(
SELECT '2012-03-01 01:00:00' AS c1, 3 as c2, 1 as c3 FROM dual
UNION
SELECT '2012-03-01 02:00:00', 3, 2 FROM dual
UNION
SELECT '2012-03-01 01:00:00', 2, 1 FROM dual
) AS t2
WHERE t2.c2 = t1.c2
GROUP BY c1, c2;
c1 c2 count(c3)
2012-03-01 01:00:00 2 1
EXECUTE s1;
c1 c2 count(c3)
2012-03-01 01:00:00 2 1
SET @x = 1;
SELECT c1, t2.c2, count(c3)
FROM
(
SELECT 3 as c2 FROM dual WHERE @x = 1
UNION
SELECT 2 FROM dual WHERE @x = 1 OR @x = 2
) AS t1,
(
SELECT '2012-03-01 01:00:00' AS c1, 3 as c2, 1 as c3 FROM dual
UNION
SELECT '2012-03-01 02:00:00', 3, 2 FROM dual
UNION
SELECT '2012-03-01 01:00:00', 2, 1 FROM dual
) AS t2
WHERE t2.c2 = t1.c2
GROUP BY c1, c2;
c1 c2 count(c3)
2012-03-01 01:00:00 2 1
2012-03-01 01:00:00 3 1
2012-03-01 02:00:00 3 1
EXECUTE s1;
c1 c2 count(c3)
2012-03-01 01:00:00 2 1
2012-03-01 01:00:00 3 1
2012-03-01 02:00:00 3 1
DEALLOCATE PREPARE s1;

View File

@ -442,9 +442,11 @@ show global variables like "query_cache_min_res_unit";
Variable_name Value Variable_name Value
query_cache_min_res_unit 4096 query_cache_min_res_unit 4096
set GLOBAL query_cache_min_res_unit=1001; set GLOBAL query_cache_min_res_unit=1001;
Warnings:
Warning 1292 Truncated incorrect query_cache_min_res_unit value: '1001'
show global variables like "query_cache_min_res_unit"; show global variables like "query_cache_min_res_unit";
Variable_name Value Variable_name Value
query_cache_min_res_unit 1008 query_cache_min_res_unit 1000
create table t1 (a int not null); create table t1 (a int not null);
insert into t1 values (1),(2),(3); insert into t1 values (1),(2),(3);
create table t2 (a int not null); create table t2 (a int not null);

View File

@ -75,18 +75,16 @@ connection default;
set global read_only=1; set global read_only=1;
ERROR HY000: Can't execute the given command because you have active locked tables or an active transaction ERROR HY000: Can't execute the given command because you have active locked tables or an active transaction
unlock tables ; unlock tables ;
send set global read_only=1;
set global read_only=1; set global read_only=1;
connection con1;
select @@global.read_only;
@@global.read_only
0
unlock tables ;
select @@global.read_only; select @@global.read_only;
@@global.read_only @@global.read_only
1 1
connection con1;
select @@global.read_only;
@@global.read_only
1
unlock tables ;
connection default; connection default;
reap;
connection default; connection default;
set global read_only=0; set global read_only=0;
BEGIN; BEGIN;

View File

@ -43,6 +43,15 @@ a
1 1
COMMIT; COMMIT;
UNLOCK TABLES; UNLOCK TABLES;
connection con1;
lock table t1 read;
connection default;
set global read_only=1;
connection con1;
unlock tables;
connection default;
SET GLOBAL read_only=0;
UNLOCK TABLES;
DROP TABLE t1; DROP TABLE t1;
DROP USER test@localhost; DROP USER test@localhost;
echo End of 5.1 tests echo End of 5.1 tests

View File

@ -5291,3 +5291,15 @@ DROP TABLE t1;
DROP VIEW view_t1; DROP VIEW view_t1;
# End of test BUG#63020 # End of test BUG#63020
SET optimizer_switch=@save_optimizer_switch; SET optimizer_switch=@save_optimizer_switch;
#
# LP bug#994275 Assertion `real->type() == Item::FIELD_ITEM' failed
# in add_not_null_conds(JOIN*) with JOIN, ZEROFILL column, PK
#
CREATE TABLE t1 ( a INT(6) ZEROFILL );
INSERT INTO t1 VALUES (1),(2);
CREATE TABLE t2 ( b INT PRIMARY KEY );
INSERT INTO t2 VALUES (3),(4);
SELECT * FROM t1, t2 WHERE a=3 AND a=b;
a b
drop table t1,t2;
End of 5.3 tests

View File

@ -5302,6 +5302,18 @@ DROP TABLE t1;
DROP VIEW view_t1; DROP VIEW view_t1;
# End of test BUG#63020 # End of test BUG#63020
SET optimizer_switch=@save_optimizer_switch; SET optimizer_switch=@save_optimizer_switch;
#
# LP bug#994275 Assertion `real->type() == Item::FIELD_ITEM' failed
# in add_not_null_conds(JOIN*) with JOIN, ZEROFILL column, PK
#
CREATE TABLE t1 ( a INT(6) ZEROFILL );
INSERT INTO t1 VALUES (1),(2);
CREATE TABLE t2 ( b INT PRIMARY KEY );
INSERT INTO t2 VALUES (3),(4);
SELECT * FROM t1, t2 WHERE a=3 AND a=b;
a b
drop table t1,t2;
End of 5.3 tests
set join_cache_level=default; set join_cache_level=default;
show variables like 'join_cache_level'; show variables like 'join_cache_level';
Variable_name Value Variable_name Value

View File

@ -5291,3 +5291,15 @@ DROP TABLE t1;
DROP VIEW view_t1; DROP VIEW view_t1;
# End of test BUG#63020 # End of test BUG#63020
SET optimizer_switch=@save_optimizer_switch; SET optimizer_switch=@save_optimizer_switch;
#
# LP bug#994275 Assertion `real->type() == Item::FIELD_ITEM' failed
# in add_not_null_conds(JOIN*) with JOIN, ZEROFILL column, PK
#
CREATE TABLE t1 ( a INT(6) ZEROFILL );
INSERT INTO t1 VALUES (1),(2);
CREATE TABLE t2 ( b INT PRIMARY KEY );
INSERT INTO t2 VALUES (3),(4);
SELECT * FROM t1, t2 WHERE a=3 AND a=b;
a b
drop table t1,t2;
End of 5.3 tests

View File

@ -7807,3 +7807,45 @@ Warnings:
Error 1424 Recursive stored functions and triggers are not allowed. Error 1424 Recursive stored functions and triggers are not allowed.
Error 1305 FUNCTION test.f1 does not exist Error 1305 FUNCTION test.f1 does not exist
DROP FUNCTION f1; DROP FUNCTION f1;
# ------------------------------------------------------------------
# -- End of 5.1 tests
# ------------------------------------------------------------------
#
# LP bug#993459 Execution of PS for a query with GROUP BY
# returns wrong result (see also mysql bug#13805127)
#
CREATE PROCEDURE p1(x INT UNSIGNED)
BEGIN
SELECT c1, t2.c2, count(c3)
FROM
(
SELECT 3 as c2 FROM dual WHERE x = 1
UNION
SELECT 2 FROM dual WHERE x = 1 OR x = 2
) AS t1,
(
SELECT '2012-03-01 01:00:00' AS c1, 3 as c2, 1 as c3 FROM dual
UNION
SELECT '2012-03-01 02:00:00', 3, 2 FROM dual
UNION
SELECT '2012-03-01 01:00:00', 2, 1 FROM dual
) AS t2
WHERE t2.c2 = t1.c2
GROUP BY c1, c2
;
END|
CALL p1(1);
c1 c2 count(c3)
2012-03-01 01:00:00 2 1
2012-03-01 01:00:00 3 1
2012-03-01 02:00:00 3 1
CALL p1(2);
c1 c2 count(c3)
2012-03-01 01:00:00 2 1
CALL p1(1);
c1 c2 count(c3)
2012-03-01 01:00:00 2 1
2012-03-01 01:00:00 3 1
2012-03-01 02:00:00 3 1
DROP PROCEDURE p1;

View File

@ -1320,7 +1320,7 @@ SELECT 0 IN (SELECT 1 FROM t1 a);
EXPLAIN EXTENDED SELECT 0 IN (SELECT 1 FROM t1 a); EXPLAIN EXTENDED SELECT 0 IN (SELECT 1 FROM t1 a);
id select_type table type possible_keys key key_len ref rows filtered Extra id select_type table type possible_keys key key_len ref rows filtered Extra
1 PRIMARY NULL NULL NULL NULL NULL NULL NULL NULL No tables used 1 PRIMARY NULL NULL NULL NULL NULL NULL NULL NULL No tables used
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: Warnings:
Note 1003 select <in_optimizer>(0,<exists>(select 1 from dual where (0 = 1))) AS `0 IN (SELECT 1 FROM t1 a)` Note 1003 select <in_optimizer>(0,<exists>(select 1 from dual where (0 = 1))) AS `0 IN (SELECT 1 FROM t1 a)`
INSERT INTO t1 (pseudo) VALUES ('test1'); INSERT INTO t1 (pseudo) VALUES ('test1');
@ -1330,7 +1330,7 @@ SELECT 0 IN (SELECT 1 FROM t1 a);
EXPLAIN EXTENDED SELECT 0 IN (SELECT 1 FROM t1 a); EXPLAIN EXTENDED SELECT 0 IN (SELECT 1 FROM t1 a);
id select_type table type possible_keys key key_len ref rows filtered Extra id select_type table type possible_keys key key_len ref rows filtered Extra
1 PRIMARY NULL NULL NULL NULL NULL NULL NULL NULL No tables used 1 PRIMARY NULL NULL NULL NULL NULL NULL NULL NULL No tables used
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: Warnings:
Note 1003 select <in_optimizer>(0,<exists>(select 1 from `test`.`t1` `a` where (0 = 1))) AS `0 IN (SELECT 1 FROM t1 a)` Note 1003 select <in_optimizer>(0,<exists>(select 1 from `test`.`t1` `a` where (0 = 1))) AS `0 IN (SELECT 1 FROM t1 a)`
drop table t1; drop table t1;
@ -3100,7 +3100,7 @@ ON r.a = (SELECT t2.a FROM t2 WHERE t2.c = t1.a AND t2.b <= '359899'
id select_type table type possible_keys key key_len ref rows Extra id select_type table type possible_keys key key_len ref rows Extra
1 PRIMARY t1 system PRIMARY NULL NULL NULL 1 1 PRIMARY t1 system PRIMARY NULL NULL NULL 1
1 PRIMARY r eq_ref PRIMARY PRIMARY 4 const 1 Using where 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 2 DEPENDENT 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 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' 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; ORDER BY t2.c DESC, t2.b DESC LIMIT 1) WHERE t1.a = 10;
@ -4585,7 +4585,7 @@ SELECT MAX(b), (SELECT COUNT(*) FROM st1,st2 WHERE st2.b <= t1.b)
FROM t1 FROM t1
WHERE a = 230; WHERE a = 230;
MAX(b) (SELECT COUNT(*) FROM st1,st2 WHERE st2.b <= t1.b) MAX(b) (SELECT COUNT(*) FROM st1,st2 WHERE st2.b <= t1.b)
NULL 0 NULL NULL
DROP TABLE t1, st1, st2; DROP TABLE t1, st1, st2;
# #
# Bug #48709: Assertion failed in sql_select.cc:11782: # Bug #48709: Assertion failed in sql_select.cc:11782:
@ -5597,6 +5597,15 @@ SELECT 1 FROM
ERROR 21000: Operand should contain 1 column(s) ERROR 21000: Operand should contain 1 column(s)
DROP TABLE t1; DROP TABLE t1;
# #
# Bug#13721076 CRASH WITH TIME TYPE/TIMESTAMP() AND WARNINGS IN SUBQUERY
#
CREATE TABLE t1(a TIME NOT NULL);
INSERT INTO t1 VALUES ('00:00:32');
SELECT 1 FROM t1 WHERE a >
(SELECT timestamp(a) AS a FROM t1);
1
DROP TABLE t1;
#
# No BUG#, a case brought from 5.2's innodb_mysql_lock.test # No BUG#, a case brought from 5.2's innodb_mysql_lock.test
# #
create table t1 (i int not null primary key); create table t1 (i int not null primary key);
@ -5716,7 +5725,7 @@ WHERE ('0') IN ( SELECT a FROM t1 GROUP BY a )
GROUP BY b; GROUP BY b;
id select_type table type possible_keys key key_len ref rows Extra id select_type table type possible_keys key key_len ref rows Extra
1 PRIMARY t1 ALL NULL NULL NULL NULL 2 Using temporary; Using filesort 1 PRIMARY t1 ALL NULL NULL NULL NULL 2 Using temporary; Using filesort
2 DEPENDENT SUBQUERY t1 ALL NULL NULL NULL NULL 2 Using where 2 SUBQUERY t1 ALL NULL NULL NULL NULL 2 Using where
SELECT b FROM t1 SELECT b FROM t1
WHERE ('0') IN ( SELECT a FROM t1 GROUP BY a ) WHERE ('0') IN ( SELECT a FROM t1 GROUP BY a )
GROUP BY b; GROUP BY b;
@ -6521,5 +6530,64 @@ INSERT INTO t1 VALUES (1);
SELECT a FROM t1 WHERE ( SELECT MIN(a) = 100 ); SELECT a FROM t1 WHERE ( SELECT MIN(a) = 100 );
a a
drop table t1; drop table t1;
#
# LP BUG#985667 Wrong result with subquery in SELECT clause, and constant table in
# main query and implicit grouping
#
CREATE TABLE t1 (f1 int) engine=MyISAM;
INSERT INTO t1 VALUES (7),(8);
CREATE TABLE t2 (f2 int, f3 varchar(1)) engine=MyISAM;
INSERT INTO t2 VALUES (3,'f');
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
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
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
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
EXPLAIN
SELECT COUNT(f1), f2 > ALL (SELECT f1 FROM t1 WHERE f2 > 0) 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 Using where
SELECT COUNT(f1), f2 > ALL (SELECT f1 FROM t1 WHERE f2 > 0) AS f4 FROM t2, t1 WHERE 'v'= f3;
COUNT(f1) f4
0 1
EXPLAIN
SELECT COUNT(f1), f2 IN (SELECT f1 FROM t1 WHERE f2 > 0) 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 Using where
SELECT COUNT(f1), f2 IN (SELECT f1 FROM t1 WHERE f2 > 0) AS f4 FROM t2, t1 WHERE 'v'= f3;
COUNT(f1) f4
0 0
drop table t1,t2;
#
# LP BUG#1002079 Server crashes in Item_singlerow_subselect::val_int with constant table,
# HAVING, UNION in subquery
#
CREATE TABLE t1 (a INT);
INSERT INTO t1 VALUES (7),(0);
CREATE TABLE t2 (b INT);
EXPLAIN
SELECT SUM(a) AS f1, a AS f2 FROM (t1, t2) HAVING f2 >= ALL (SELECT 4 UNION SELECT 5) AND f1 = 7;
id select_type table type possible_keys key key_len ref rows Extra
1 PRIMARY t2 system NULL NULL NULL NULL 0 const row not found
1 PRIMARY t1 ALL NULL NULL NULL NULL 2
2 SUBQUERY NULL NULL NULL NULL NULL NULL NULL No tables used
3 UNION NULL NULL NULL NULL NULL NULL NULL No tables used
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;
# return optimizer switch changed in the beginning of this test # return optimizer switch changed in the beginning of this test
set optimizer_switch=@subselect_tmp; set optimizer_switch=@subselect_tmp;

View File

@ -649,7 +649,7 @@ EXPLAIN
SELECT (2, 0) NOT IN (SELECT f3, min(f4) FROM t2) as not_in; 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 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 1 PRIMARY NULL NULL NULL NULL NULL NULL NULL No tables used
2 DEPENDENT SUBQUERY t2 system NULL NULL NULL NULL 0 const row not found 2 SUBQUERY t2 system NULL NULL NULL NULL 0 const row not found
SELECT (2, 0) NOT IN (SELECT f3, min(f4) FROM t2) as not_in; SELECT (2, 0) NOT IN (SELECT f3, min(f4) FROM t2) as not_in;
not_in not_in
NULL NULL
@ -671,7 +671,7 @@ EXPLAIN
SELECT (2, 0) NOT IN (SELECT f3, count(f4) FROM t2) as not_in; 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 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 1 PRIMARY NULL NULL NULL NULL NULL NULL NULL No tables used
2 DEPENDENT SUBQUERY t2 system NULL NULL NULL NULL 0 const row not found 2 SUBQUERY t2 system NULL NULL NULL NULL 0 const row not found
SELECT (2, 0) NOT IN (SELECT f3, count(f4) FROM t2) as not_in; SELECT (2, 0) NOT IN (SELECT f3, count(f4) FROM t2) as not_in;
not_in not_in
NULL NULL
@ -679,7 +679,7 @@ EXPLAIN
SELECT (2, 0) NOT IN (SELECT f3, count(f4) FROM t2 HAVING max(f4) > 7) as not_in; 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 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 1 PRIMARY NULL NULL NULL NULL NULL NULL NULL No tables used
2 DEPENDENT SUBQUERY t2 system NULL NULL NULL NULL 0 const row not found 2 SUBQUERY t2 system NULL NULL NULL NULL 0 const row not found
SELECT (2, 0) NOT IN (SELECT f3, count(f4) FROM t2 HAVING max(f4) > 7) as not_in; SELECT (2, 0) NOT IN (SELECT f3, count(f4) FROM t2 HAVING max(f4) > 7) as not_in;
not_in not_in
1 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; 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 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 1 PRIMARY NULL NULL NULL NULL NULL NULL NULL No tables used
2 DEPENDENT SUBQUERY t2 system NULL NULL NULL NULL 0 const row not found 2 SUBQUERY t2 system NULL NULL NULL NULL 0 const row not found
SELECT (2, 0) NOT IN (SELECT f3, count(f4) FROM t2 HAVING max(f4) is null) as not_in; SELECT (2, 0) NOT IN (SELECT f3, count(f4) FROM t2 HAVING max(f4) is null) as not_in;
not_in not_in
NULL NULL
@ -695,7 +695,7 @@ EXPLAIN
SELECT (2, 0) NOT IN (SELECT max(f3+f3), count(f4) FROM t2) as not_in; 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 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 1 PRIMARY NULL NULL NULL NULL NULL NULL NULL No tables used
2 DEPENDENT SUBQUERY t2 system NULL NULL NULL NULL 0 const row not found 2 SUBQUERY t2 system NULL NULL NULL NULL 0 const row not found
SELECT (2, 0) NOT IN (SELECT max(f3+f3), count(f4) FROM t2) as not_in; SELECT (2, 0) NOT IN (SELECT max(f3+f3), count(f4) FROM t2) as not_in;
not_in not_in
NULL NULL
@ -703,7 +703,7 @@ EXPLAIN
SELECT (2, 0) NOT IN (SELECT max(f3+f3), count(f4)+f3 FROM t2) as not_in; 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 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 1 PRIMARY NULL NULL NULL NULL NULL NULL NULL No tables used
2 DEPENDENT SUBQUERY t2 system NULL NULL NULL NULL 0 const row not found 2 SUBQUERY t2 system NULL NULL NULL NULL 0 const row not found
SELECT (2, 0) NOT IN (SELECT max(f3+f3), count(f4)+f3 FROM t2) as not_in; SELECT (2, 0) NOT IN (SELECT max(f3+f3), count(f4)+f3 FROM t2) as not_in;
not_in not_in
NULL NULL
@ -719,28 +719,28 @@ EXPLAIN
SELECT * FROM t1 WHERE (2, 0) NOT IN (SELECT f3, min(f4) FROM t2); 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 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 NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables
2 DEPENDENT SUBQUERY t2 system NULL NULL NULL NULL 0 const row not found 2 SUBQUERY t2 system NULL NULL NULL NULL 0 const row not found
SELECT * FROM t1 WHERE (2, 0) NOT IN (SELECT f3, min(f4) FROM t2); SELECT * FROM t1 WHERE (2, 0) NOT IN (SELECT f3, min(f4) FROM t2);
f1 f2 f1 f2
EXPLAIN EXPLAIN
SELECT * FROM t1 WHERE (2, 0) NOT IN (SELECT f3+f4, min(f4) FROM t2); 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 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 NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables
2 DEPENDENT SUBQUERY t2 system NULL NULL NULL NULL 0 const row not found 2 SUBQUERY t2 system NULL NULL NULL NULL 0 const row not found
SELECT * FROM t1 WHERE (2, 0) NOT IN (SELECT f3+f4, min(f4) FROM t2); SELECT * FROM t1 WHERE (2, 0) NOT IN (SELECT f3+f4, min(f4) FROM t2);
f1 f2 f1 f2
EXPLAIN EXPLAIN
SELECT * FROM t1 WHERE (2, 0) NOT IN (SELECT f3, min(f4)+max(f4) FROM t2); 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 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 NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables
2 DEPENDENT SUBQUERY t2 system NULL NULL NULL NULL 0 const row not found 2 SUBQUERY t2 system NULL NULL NULL NULL 0 const row not found
SELECT * FROM t1 WHERE (2, 0) NOT IN (SELECT f3, min(f4)+max(f4) FROM t2); SELECT * FROM t1 WHERE (2, 0) NOT IN (SELECT f3, min(f4)+max(f4) FROM t2);
f1 f2 f1 f2
EXPLAIN EXPLAIN
SELECT (2, 0) NOT IN (SELECT f3, min(f4) FROM t2) as not_in; 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 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 1 PRIMARY NULL NULL NULL NULL NULL NULL NULL No tables used
2 DEPENDENT SUBQUERY t2 system NULL NULL NULL NULL 0 const row not found 2 SUBQUERY t2 system NULL NULL NULL NULL 0 const row not found
SELECT (2, 0) NOT IN (SELECT f3, min(f4) FROM t2) as not_in; SELECT (2, 0) NOT IN (SELECT f3, min(f4) FROM t2) as not_in;
not_in not_in
NULL NULL
@ -748,21 +748,21 @@ EXPLAIN
SELECT * FROM t1 WHERE (2, 0) NOT IN (SELECT f3, count(f4) FROM t2); 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 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 NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables
2 DEPENDENT SUBQUERY t2 system NULL NULL NULL NULL 0 const row not found 2 SUBQUERY t2 system NULL NULL NULL NULL 0 const row not found
SELECT * FROM t1 WHERE (2, 0) NOT IN (SELECT f3, count(f4) FROM t2); SELECT * FROM t1 WHERE (2, 0) NOT IN (SELECT f3, count(f4) FROM t2);
f1 f2 f1 f2
EXPLAIN EXPLAIN
SELECT * FROM t1 WHERE (2, 0) NOT IN (SELECT f3, f3 + count(f4) FROM t2); 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 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 NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables
2 DEPENDENT SUBQUERY t2 system NULL NULL NULL NULL 0 const row not found 2 SUBQUERY t2 system NULL NULL NULL NULL 0 const row not found
SELECT * FROM t1 WHERE (2, 0) NOT IN (SELECT f3, f3 + count(f4) FROM t2); SELECT * FROM t1 WHERE (2, 0) NOT IN (SELECT f3, f3 + count(f4) FROM t2);
f1 f2 f1 f2
EXPLAIN EXPLAIN
SELECT (2, 0) NOT IN (SELECT f3, count(f4) FROM t2) as not_in; 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 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 1 PRIMARY NULL NULL NULL NULL NULL NULL NULL No tables used
2 DEPENDENT SUBQUERY t2 system NULL NULL NULL NULL 0 const row not found 2 SUBQUERY t2 system NULL NULL NULL NULL 0 const row not found
SELECT (2, 0) NOT IN (SELECT f3, count(f4) FROM t2) as not_in; SELECT (2, 0) NOT IN (SELECT f3, count(f4) FROM t2) as not_in;
not_in not_in
NULL NULL
@ -770,7 +770,7 @@ EXPLAIN
SELECT (2, 0) NOT IN (SELECT f3, count(f4) FROM t2 HAVING max(f4) > 7) as not_in; 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 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 1 PRIMARY NULL NULL NULL NULL NULL NULL NULL No tables used
2 DEPENDENT SUBQUERY t2 system NULL NULL NULL NULL 0 const row not found 2 SUBQUERY t2 system NULL NULL NULL NULL 0 const row not found
SELECT (2, 0) NOT IN (SELECT f3, count(f4) FROM t2 HAVING max(f4) > 7) as not_in; SELECT (2, 0) NOT IN (SELECT f3, count(f4) FROM t2 HAVING max(f4) > 7) as not_in;
not_in not_in
1 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; 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 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 1 PRIMARY NULL NULL NULL NULL NULL NULL NULL No tables used
2 DEPENDENT SUBQUERY t2 system NULL NULL NULL NULL 0 const row not found 2 SUBQUERY t2 system NULL NULL NULL NULL 0 const row not found
SELECT (2, 0) NOT IN (SELECT f3, count(f4) FROM t2 HAVING max(f4) is null) as not_in; SELECT (2, 0) NOT IN (SELECT f3, count(f4) FROM t2 HAVING max(f4) is null) as not_in;
not_in not_in
NULL NULL
@ -786,7 +786,7 @@ EXPLAIN
SELECT (2, 0) NOT IN (SELECT max(f3+f3), count(f4) FROM t2) as not_in; 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 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 1 PRIMARY NULL NULL NULL NULL NULL NULL NULL No tables used
2 DEPENDENT SUBQUERY t2 system NULL NULL NULL NULL 0 const row not found 2 SUBQUERY t2 system NULL NULL NULL NULL 0 const row not found
SELECT (2, 0) NOT IN (SELECT max(f3+f3), count(f4) FROM t2) as not_in; SELECT (2, 0) NOT IN (SELECT max(f3+f3), count(f4) FROM t2) as not_in;
not_in not_in
NULL NULL
@ -794,7 +794,7 @@ EXPLAIN
SELECT (2, 0) NOT IN (SELECT max(f3+f3), count(f4)+f3 FROM t2) as not_in; 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 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 1 PRIMARY NULL NULL NULL NULL NULL NULL NULL No tables used
2 DEPENDENT SUBQUERY t2 system NULL NULL NULL NULL 0 const row not found 2 SUBQUERY t2 system NULL NULL NULL NULL 0 const row not found
SELECT (2, 0) NOT IN (SELECT max(f3+f3), count(f4)+f3 FROM t2) as not_in; SELECT (2, 0) NOT IN (SELECT max(f3+f3), count(f4)+f3 FROM t2) as not_in;
not_in not_in
NULL NULL
@ -835,7 +835,7 @@ EXPLAIN
SELECT (2, 0) NOT IN (SELECT f3, min(f4) FROM t2 WHERE f3 > 10) as not_in; SELECT (2, 0) NOT IN (SELECT f3, min(f4) FROM t2 WHERE f3 > 10) as not_in;
id select_type table type possible_keys key key_len ref rows Extra 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 1 PRIMARY NULL NULL NULL NULL NULL NULL NULL No tables used
2 DEPENDENT SUBQUERY t2 range PRIMARY PRIMARY 4 NULL 1 Using index condition; Rowid-ordered scan 2 SUBQUERY t2 range PRIMARY PRIMARY 4 NULL 1 Using index condition; Rowid-ordered scan
SELECT (2, 0) NOT IN (SELECT f3, min(f4) FROM t2 WHERE f3 > 10) as not_in; SELECT (2, 0) NOT IN (SELECT f3, min(f4) FROM t2 WHERE f3 > 10) as not_in;
not_in not_in
NULL NULL
@ -857,7 +857,7 @@ EXPLAIN
SELECT (2, 0) NOT IN (SELECT f3, count(f4) FROM t2 WHERE f3 > 10) as not_in; SELECT (2, 0) NOT IN (SELECT f3, count(f4) FROM t2 WHERE f3 > 10) as not_in;
id select_type table type possible_keys key key_len ref rows Extra 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 1 PRIMARY NULL NULL NULL NULL NULL NULL NULL No tables used
2 DEPENDENT SUBQUERY t2 range PRIMARY PRIMARY 4 NULL 1 Using index condition; Rowid-ordered scan 2 SUBQUERY t2 range PRIMARY PRIMARY 4 NULL 1 Using index condition; Rowid-ordered scan
SELECT (2, 0) NOT IN (SELECT f3, count(f4) FROM t2 WHERE f3 > 10) as not_in; SELECT (2, 0) NOT IN (SELECT f3, count(f4) FROM t2 WHERE f3 > 10) as not_in;
not_in not_in
NULL NULL
@ -865,7 +865,7 @@ EXPLAIN
SELECT (2, 0) NOT IN (SELECT f3, count(f4) FROM t2 WHERE f3 > 10 HAVING max(f4) > 7) as not_in; SELECT (2, 0) NOT IN (SELECT f3, count(f4) FROM t2 WHERE f3 > 10 HAVING max(f4) > 7) as not_in;
id select_type table type possible_keys key key_len ref rows Extra 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 1 PRIMARY NULL NULL NULL NULL NULL NULL NULL No tables used
2 DEPENDENT SUBQUERY t2 range PRIMARY PRIMARY 4 NULL 1 Using index condition; Rowid-ordered scan 2 SUBQUERY t2 range PRIMARY PRIMARY 4 NULL 1 Using index condition; Rowid-ordered scan
SELECT (2, 0) NOT IN (SELECT f3, count(f4) FROM t2 WHERE f3 > 10 HAVING max(f4) > 7) as not_in; SELECT (2, 0) NOT IN (SELECT f3, count(f4) FROM t2 WHERE f3 > 10 HAVING max(f4) > 7) as not_in;
not_in not_in
1 1
@ -873,7 +873,7 @@ EXPLAIN
SELECT (2, 0) NOT IN (SELECT f3, count(f4) FROM t2 WHERE f3 > 10 HAVING max(f4) is null) as not_in; SELECT (2, 0) NOT IN (SELECT f3, count(f4) FROM t2 WHERE f3 > 10 HAVING max(f4) is null) as not_in;
id select_type table type possible_keys key key_len ref rows Extra 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 1 PRIMARY NULL NULL NULL NULL NULL NULL NULL No tables used
2 DEPENDENT SUBQUERY t2 range PRIMARY PRIMARY 4 NULL 1 Using index condition; Rowid-ordered scan 2 SUBQUERY t2 range PRIMARY PRIMARY 4 NULL 1 Using index condition; Rowid-ordered scan
SELECT (2, 0) NOT IN (SELECT f3, count(f4) FROM t2 WHERE f3 > 10 HAVING max(f4) is null) as not_in; SELECT (2, 0) NOT IN (SELECT f3, count(f4) FROM t2 WHERE f3 > 10 HAVING max(f4) is null) as not_in;
not_in not_in
NULL NULL
@ -881,7 +881,7 @@ EXPLAIN
SELECT (2, 0) NOT IN (SELECT max(f3+f3), count(f4) FROM t2 WHERE f3 > 10) as not_in; SELECT (2, 0) NOT IN (SELECT max(f3+f3), count(f4) FROM t2 WHERE f3 > 10) as not_in;
id select_type table type possible_keys key key_len ref rows Extra 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 1 PRIMARY NULL NULL NULL NULL NULL NULL NULL No tables used
2 DEPENDENT SUBQUERY t2 range PRIMARY PRIMARY 4 NULL 1 Using index condition; Rowid-ordered scan 2 SUBQUERY t2 range PRIMARY PRIMARY 4 NULL 1 Using index condition; Rowid-ordered scan
SELECT (2, 0) NOT IN (SELECT max(f3+f3), count(f4) FROM t2 WHERE f3 > 10) as not_in; SELECT (2, 0) NOT IN (SELECT max(f3+f3), count(f4) FROM t2 WHERE f3 > 10) as not_in;
not_in not_in
NULL NULL
@ -889,7 +889,7 @@ EXPLAIN
SELECT (2, 0) NOT IN (SELECT max(f3+f3), count(f4)+f3 FROM t2 WHERE f3 > 10) as not_in; SELECT (2, 0) NOT IN (SELECT max(f3+f3), count(f4)+f3 FROM t2 WHERE f3 > 10) as not_in;
id select_type table type possible_keys key key_len ref rows Extra 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 1 PRIMARY NULL NULL NULL NULL NULL NULL NULL No tables used
2 DEPENDENT SUBQUERY t2 range PRIMARY PRIMARY 4 NULL 1 Using index condition; Rowid-ordered scan 2 SUBQUERY t2 range PRIMARY PRIMARY 4 NULL 1 Using index condition; Rowid-ordered scan
SELECT (2, 0) NOT IN (SELECT max(f3+f3), count(f4)+f3 FROM t2 WHERE f3 > 10) as not_in; SELECT (2, 0) NOT IN (SELECT max(f3+f3), count(f4)+f3 FROM t2 WHERE f3 > 10) as not_in;
not_in not_in
NULL NULL
@ -905,28 +905,28 @@ EXPLAIN
SELECT * FROM t1 WHERE (2, 0) NOT IN (SELECT f3, min(f4) FROM t2 WHERE f3 > 10); 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 id select_type table type possible_keys key key_len ref rows Extra
1 PRIMARY t1 ALL NULL NULL NULL NULL 2 1 PRIMARY t1 ALL NULL NULL NULL NULL 2
2 DEPENDENT SUBQUERY t2 range PRIMARY PRIMARY 4 NULL 1 Using index condition; Rowid-ordered scan 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); SELECT * FROM t1 WHERE (2, 0) NOT IN (SELECT f3, min(f4) FROM t2 WHERE f3 > 10);
f1 f2 f1 f2
EXPLAIN EXPLAIN
SELECT * FROM t1 WHERE (2, 0) NOT IN (SELECT f3+f4, min(f4) FROM t2 WHERE f3 > 10); 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 id select_type table type possible_keys key key_len ref rows Extra
1 PRIMARY t1 ALL NULL NULL NULL NULL 2 1 PRIMARY t1 ALL NULL NULL NULL NULL 2
2 DEPENDENT SUBQUERY t2 range PRIMARY PRIMARY 4 NULL 1 Using index condition; Rowid-ordered scan 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); SELECT * FROM t1 WHERE (2, 0) NOT IN (SELECT f3+f4, min(f4) FROM t2 WHERE f3 > 10);
f1 f2 f1 f2
EXPLAIN EXPLAIN
SELECT * FROM t1 WHERE (2, 0) NOT IN (SELECT f3, min(f4)+max(f4) FROM t2 WHERE f3 > 10); 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 id select_type table type possible_keys key key_len ref rows Extra
1 PRIMARY t1 ALL NULL NULL NULL NULL 2 1 PRIMARY t1 ALL NULL NULL NULL NULL 2
2 DEPENDENT SUBQUERY t2 range PRIMARY PRIMARY 4 NULL 1 Using index condition; Rowid-ordered scan 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); SELECT * FROM t1 WHERE (2, 0) NOT IN (SELECT f3, min(f4)+max(f4) FROM t2 WHERE f3 > 10);
f1 f2 f1 f2
EXPLAIN EXPLAIN
SELECT (2, 0) NOT IN (SELECT f3, min(f4) FROM t2 WHERE f3 > 10) as not_in; SELECT (2, 0) NOT IN (SELECT f3, min(f4) FROM t2 WHERE f3 > 10) as not_in;
id select_type table type possible_keys key key_len ref rows Extra 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 1 PRIMARY NULL NULL NULL NULL NULL NULL NULL No tables used
2 DEPENDENT SUBQUERY t2 range PRIMARY PRIMARY 4 NULL 1 Using index condition; Rowid-ordered scan 2 SUBQUERY t2 range PRIMARY PRIMARY 4 NULL 1 Using index condition; Rowid-ordered scan
SELECT (2, 0) NOT IN (SELECT f3, min(f4) FROM t2 WHERE f3 > 10) as not_in; SELECT (2, 0) NOT IN (SELECT f3, min(f4) FROM t2 WHERE f3 > 10) as not_in;
not_in not_in
NULL NULL
@ -934,21 +934,21 @@ EXPLAIN
SELECT * FROM t1 WHERE (2, 0) NOT IN (SELECT f3, count(f4) FROM t2 WHERE f3 > 10); 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 id select_type table type possible_keys key key_len ref rows Extra
1 PRIMARY t1 ALL NULL NULL NULL NULL 2 1 PRIMARY t1 ALL NULL NULL NULL NULL 2
2 DEPENDENT SUBQUERY t2 range PRIMARY PRIMARY 4 NULL 1 Using index condition; Rowid-ordered scan 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); SELECT * FROM t1 WHERE (2, 0) NOT IN (SELECT f3, count(f4) FROM t2 WHERE f3 > 10);
f1 f2 f1 f2
EXPLAIN EXPLAIN
SELECT * FROM t1 WHERE (2, 0) NOT IN (SELECT f3, f3 + count(f4) FROM t2 WHERE f3 > 10); 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 id select_type table type possible_keys key key_len ref rows Extra
1 PRIMARY t1 ALL NULL NULL NULL NULL 2 1 PRIMARY t1 ALL NULL NULL NULL NULL 2
2 DEPENDENT SUBQUERY t2 range PRIMARY PRIMARY 4 NULL 1 Using index condition; Rowid-ordered scan 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); SELECT * FROM t1 WHERE (2, 0) NOT IN (SELECT f3, f3 + count(f4) FROM t2 WHERE f3 > 10);
f1 f2 f1 f2
EXPLAIN EXPLAIN
SELECT (2, 0) NOT IN (SELECT f3, count(f4) FROM t2 WHERE f3 > 10) as not_in; SELECT (2, 0) NOT IN (SELECT f3, count(f4) FROM t2 WHERE f3 > 10) as not_in;
id select_type table type possible_keys key key_len ref rows Extra 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 1 PRIMARY NULL NULL NULL NULL NULL NULL NULL No tables used
2 DEPENDENT SUBQUERY t2 range PRIMARY PRIMARY 4 NULL 1 Using index condition; Rowid-ordered scan 2 SUBQUERY t2 range PRIMARY PRIMARY 4 NULL 1 Using index condition; Rowid-ordered scan
SELECT (2, 0) NOT IN (SELECT f3, count(f4) FROM t2 WHERE f3 > 10) as not_in; SELECT (2, 0) NOT IN (SELECT f3, count(f4) FROM t2 WHERE f3 > 10) as not_in;
not_in not_in
NULL NULL
@ -956,7 +956,7 @@ EXPLAIN
SELECT (2, 0) NOT IN (SELECT f3, count(f4) FROM t2 WHERE f3 > 10 HAVING max(f4) > 7) as not_in; SELECT (2, 0) NOT IN (SELECT f3, count(f4) FROM t2 WHERE f3 > 10 HAVING max(f4) > 7) as not_in;
id select_type table type possible_keys key key_len ref rows Extra 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 1 PRIMARY NULL NULL NULL NULL NULL NULL NULL No tables used
2 DEPENDENT SUBQUERY t2 range PRIMARY PRIMARY 4 NULL 1 Using index condition; Rowid-ordered scan 2 SUBQUERY t2 range PRIMARY PRIMARY 4 NULL 1 Using index condition; Rowid-ordered scan
SELECT (2, 0) NOT IN (SELECT f3, count(f4) FROM t2 WHERE f3 > 10 HAVING max(f4) > 7) as not_in; SELECT (2, 0) NOT IN (SELECT f3, count(f4) FROM t2 WHERE f3 > 10 HAVING max(f4) > 7) as not_in;
not_in not_in
1 1
@ -964,7 +964,7 @@ EXPLAIN
SELECT (2, 0) NOT IN (SELECT f3, count(f4) FROM t2 WHERE f3 > 10 HAVING max(f4) is null) as not_in; SELECT (2, 0) NOT IN (SELECT f3, count(f4) FROM t2 WHERE f3 > 10 HAVING max(f4) is null) as not_in;
id select_type table type possible_keys key key_len ref rows Extra 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 1 PRIMARY NULL NULL NULL NULL NULL NULL NULL No tables used
2 DEPENDENT SUBQUERY t2 range PRIMARY PRIMARY 4 NULL 1 Using index condition; Rowid-ordered scan 2 SUBQUERY t2 range PRIMARY PRIMARY 4 NULL 1 Using index condition; Rowid-ordered scan
SELECT (2, 0) NOT IN (SELECT f3, count(f4) FROM t2 WHERE f3 > 10 HAVING max(f4) is null) as not_in; SELECT (2, 0) NOT IN (SELECT f3, count(f4) FROM t2 WHERE f3 > 10 HAVING max(f4) is null) as not_in;
not_in not_in
NULL NULL
@ -972,7 +972,7 @@ EXPLAIN
SELECT (2, 0) NOT IN (SELECT max(f3+f3), count(f4) FROM t2 WHERE f3 > 10) as not_in; SELECT (2, 0) NOT IN (SELECT max(f3+f3), count(f4) FROM t2 WHERE f3 > 10) as not_in;
id select_type table type possible_keys key key_len ref rows Extra 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 1 PRIMARY NULL NULL NULL NULL NULL NULL NULL No tables used
2 DEPENDENT SUBQUERY t2 range PRIMARY PRIMARY 4 NULL 1 Using index condition; Rowid-ordered scan 2 SUBQUERY t2 range PRIMARY PRIMARY 4 NULL 1 Using index condition; Rowid-ordered scan
SELECT (2, 0) NOT IN (SELECT max(f3+f3), count(f4) FROM t2 WHERE f3 > 10) as not_in; SELECT (2, 0) NOT IN (SELECT max(f3+f3), count(f4) FROM t2 WHERE f3 > 10) as not_in;
not_in not_in
NULL NULL
@ -980,7 +980,7 @@ EXPLAIN
SELECT (2, 0) NOT IN (SELECT max(f3+f3), count(f4)+f3 FROM t2 WHERE f3 > 10) as not_in; SELECT (2, 0) NOT IN (SELECT max(f3+f3), count(f4)+f3 FROM t2 WHERE f3 > 10) as not_in;
id select_type table type possible_keys key key_len ref rows Extra 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 1 PRIMARY NULL NULL NULL NULL NULL NULL NULL No tables used
2 DEPENDENT SUBQUERY t2 range PRIMARY PRIMARY 4 NULL 1 Using index condition; Rowid-ordered scan 2 SUBQUERY t2 range PRIMARY PRIMARY 4 NULL 1 Using index condition; Rowid-ordered scan
SELECT (2, 0) NOT IN (SELECT max(f3+f3), count(f4)+f3 FROM t2 WHERE f3 > 10) as not_in; SELECT (2, 0) NOT IN (SELECT max(f3+f3), count(f4)+f3 FROM t2 WHERE f3 > 10) as not_in;
not_in not_in
NULL NULL
@ -1233,7 +1233,7 @@ EXPLAIN
SELECT i FROM t1 WHERE (1) NOT IN (SELECT i FROM t2); SELECT i FROM t1 WHERE (1) NOT IN (SELECT i FROM t2);
id select_type table type possible_keys key key_len ref rows Extra id select_type table type possible_keys key key_len ref rows Extra
1 PRIMARY t1 system NULL NULL NULL NULL 1 1 PRIMARY t1 system NULL NULL NULL NULL 1
2 DEPENDENT SUBQUERY t2 index_subquery k k 5 const 2 Using index 2 SUBQUERY t2 index_subquery k k 5 const 2 Using index
DROP TABLE t2; DROP TABLE t2;
DROP TABLE t1; DROP TABLE t1;
# #
@ -1252,7 +1252,7 @@ GROUP BY f9;
id select_type table type possible_keys key key_len ref rows Extra id select_type table type possible_keys key key_len ref rows Extra
1 PRIMARY t2 system NULL NULL NULL NULL 1 1 PRIMARY t2 system NULL NULL NULL NULL 1
1 PRIMARY t1 ALL NULL NULL NULL NULL 2 Using where 1 PRIMARY t1 ALL NULL NULL NULL NULL 2 Using where
3 DEPENDENT SUBQUERY NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables 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
SELECT COUNT(t2.f3), SELECT COUNT(t2.f3),
(SELECT COUNT(f3) FROM t1 WHERE t2.f1) AS f9 (SELECT COUNT(f3) FROM t1 WHERE t2.f1) AS f9
@ -1269,7 +1269,7 @@ ORDER BY f9;
id select_type table type possible_keys key key_len ref rows Extra id select_type table type possible_keys key key_len ref rows Extra
1 PRIMARY t2 system NULL NULL NULL NULL 1 1 PRIMARY t2 system NULL NULL NULL NULL 1
1 PRIMARY t1 ALL NULL NULL NULL NULL 2 Using where 1 PRIMARY t1 ALL NULL NULL NULL NULL 2 Using where
3 DEPENDENT SUBQUERY NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables 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
SELECT COUNT(t2.f3), SELECT COUNT(t2.f3),
(SELECT COUNT(f3) FROM t1 WHERE t2.f1) AS f9 (SELECT COUNT(f3) FROM t1 WHERE t2.f1) AS f9
@ -1287,7 +1287,7 @@ GROUP BY f9;
id select_type table type possible_keys key key_len ref rows Extra id select_type table type possible_keys key key_len ref rows Extra
1 PRIMARY t2 system NULL NULL NULL NULL 1 1 PRIMARY t2 system NULL NULL NULL NULL 1
1 PRIMARY t1 ALL NULL NULL NULL NULL 2 1 PRIMARY t1 ALL NULL NULL NULL NULL 2
3 DEPENDENT 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 DEPENDENT SUBQUERY t1 ALL NULL NULL NULL NULL 2 2 DEPENDENT SUBQUERY t1 ALL NULL NULL NULL NULL 2
SELECT COUNT(t2.f3), SELECT COUNT(t2.f3),
(SELECT t2.f1 FROM t1 limit 1) AS f9 (SELECT t2.f1 FROM t1 limit 1) AS f9
@ -1304,7 +1304,7 @@ ORDER BY f9;
id select_type table type possible_keys key key_len ref rows Extra id select_type table type possible_keys key key_len ref rows Extra
1 PRIMARY t2 system NULL NULL NULL NULL 1 1 PRIMARY t2 system NULL NULL NULL NULL 1
1 PRIMARY t1 ALL NULL NULL NULL NULL 2 1 PRIMARY t1 ALL NULL NULL NULL NULL 2
3 DEPENDENT 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 DEPENDENT SUBQUERY t1 ALL NULL NULL NULL NULL 2 2 DEPENDENT SUBQUERY t1 ALL NULL NULL NULL NULL 2
SELECT COUNT(t2.f3), SELECT COUNT(t2.f3),
(SELECT t2.f1 FROM t1 limit 1) AS f9 (SELECT t2.f1 FROM t1 limit 1) AS f9
@ -1387,7 +1387,7 @@ EXPLAIN
SELECT 'bug' FROM DUAL WHERE ( 5 ) IN ( SELECT * FROM v1 ); SELECT 'bug' FROM DUAL WHERE ( 5 ) IN ( SELECT * FROM v1 );
id select_type table type possible_keys key key_len ref rows Extra 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 1 PRIMARY NULL NULL NULL NULL NULL NULL NULL No tables used
2 DEPENDENT SUBQUERY <derived3> ALL NULL NULL NULL NULL 2 Using where 2 SUBQUERY <derived3> ALL NULL NULL NULL NULL 2 Using where
3 DERIVED NULL NULL NULL NULL NULL NULL NULL No tables used 3 DERIVED NULL NULL NULL NULL NULL NULL NULL No tables used
4 UNION NULL NULL NULL NULL NULL NULL NULL No tables used 4 UNION NULL NULL NULL NULL NULL NULL NULL No tables used
NULL UNION RESULT <union3,4> ALL NULL NULL NULL NULL NULL NULL UNION RESULT <union3,4> ALL NULL NULL NULL NULL NULL
@ -1397,7 +1397,7 @@ EXPLAIN
SELECT ( 5 ) IN ( SELECT * FROM v1 ); SELECT ( 5 ) IN ( SELECT * FROM v1 );
id select_type table type possible_keys key key_len ref rows Extra 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 1 PRIMARY NULL NULL NULL NULL NULL NULL NULL No tables used
2 DEPENDENT SUBQUERY <derived3> ALL NULL NULL NULL NULL 2 Using where 2 SUBQUERY <derived3> ALL NULL NULL NULL NULL 2 Using where
3 DERIVED NULL NULL NULL NULL NULL NULL NULL No tables used 3 DERIVED NULL NULL NULL NULL NULL NULL NULL No tables used
4 UNION NULL NULL NULL NULL NULL NULL NULL No tables used 4 UNION NULL NULL NULL NULL NULL NULL NULL No tables used
NULL UNION RESULT <union3,4> ALL NULL NULL NULL NULL NULL NULL UNION RESULT <union3,4> ALL NULL NULL NULL NULL NULL
@ -1408,7 +1408,7 @@ EXPLAIN
SELECT 'bug' FROM DUAL WHERE ( 5 ) IN (SELECT * FROM v2); SELECT 'bug' FROM DUAL WHERE ( 5 ) IN (SELECT * FROM v2);
id select_type table type possible_keys key key_len ref rows Extra 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 1 PRIMARY NULL NULL NULL NULL NULL NULL NULL No tables used
2 DEPENDENT SUBQUERY <derived3> ALL NULL NULL NULL NULL 2 Using where 2 SUBQUERY <derived3> ALL NULL NULL NULL NULL 2 Using where
3 DERIVED t1 system NULL NULL NULL NULL 1 3 DERIVED t1 system NULL NULL NULL NULL 1
4 UNION t2 system NULL NULL NULL NULL 1 4 UNION t2 system NULL NULL NULL NULL 1
NULL UNION RESULT <union3,4> ALL NULL NULL NULL NULL NULL NULL UNION RESULT <union3,4> ALL NULL NULL NULL NULL NULL
@ -1428,7 +1428,7 @@ EXPLAIN
SELECT ( 5 ) IN ( SELECT * FROM v2 ); SELECT ( 5 ) IN ( SELECT * FROM v2 );
id select_type table type possible_keys key key_len ref rows Extra 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 1 PRIMARY NULL NULL NULL NULL NULL NULL NULL No tables used
2 DEPENDENT SUBQUERY <derived3> ALL NULL NULL NULL NULL 2 Using where 2 SUBQUERY <derived3> ALL NULL NULL NULL NULL 2 Using where
3 DERIVED t1 system NULL NULL NULL NULL 1 3 DERIVED t1 system NULL NULL NULL NULL 1
4 UNION t2 system NULL NULL NULL NULL 1 4 UNION t2 system NULL NULL NULL NULL 1
NULL UNION RESULT <union3,4> ALL NULL NULL NULL NULL NULL NULL UNION RESULT <union3,4> ALL NULL NULL NULL NULL NULL
@ -1440,7 +1440,7 @@ EXPLAIN
SELECT 'bug' FROM DUAL WHERE ( 5 ) IN ( SELECT * FROM v1 ); SELECT 'bug' FROM DUAL WHERE ( 5 ) IN ( SELECT * FROM v1 );
id select_type table type possible_keys key key_len ref rows Extra 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 1 PRIMARY NULL NULL NULL NULL NULL NULL NULL No tables used
2 DEPENDENT SUBQUERY <derived3> ALL NULL NULL NULL NULL 2 Using where 2 SUBQUERY <derived3> ALL NULL NULL NULL NULL 2 Using where
3 DERIVED NULL NULL NULL NULL NULL NULL NULL No tables used 3 DERIVED NULL NULL NULL NULL NULL NULL NULL No tables used
4 UNION NULL NULL NULL NULL NULL NULL NULL No tables used 4 UNION NULL NULL NULL NULL NULL NULL NULL No tables used
NULL UNION RESULT <union3,4> ALL NULL NULL NULL NULL NULL NULL UNION RESULT <union3,4> ALL NULL NULL NULL NULL NULL
@ -1450,7 +1450,7 @@ EXPLAIN
SELECT ( 5 ) IN ( SELECT * FROM v1 ); SELECT ( 5 ) IN ( SELECT * FROM v1 );
id select_type table type possible_keys key key_len ref rows Extra 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 1 PRIMARY NULL NULL NULL NULL NULL NULL NULL No tables used
2 DEPENDENT SUBQUERY <derived3> ALL NULL NULL NULL NULL 2 Using where 2 SUBQUERY <derived3> ALL NULL NULL NULL NULL 2 Using where
3 DERIVED NULL NULL NULL NULL NULL NULL NULL No tables used 3 DERIVED NULL NULL NULL NULL NULL NULL NULL No tables used
4 UNION NULL NULL NULL NULL NULL NULL NULL No tables used 4 UNION NULL NULL NULL NULL NULL NULL NULL No tables used
NULL UNION RESULT <union3,4> ALL NULL NULL NULL NULL NULL NULL UNION RESULT <union3,4> ALL NULL NULL NULL NULL NULL
@ -1461,7 +1461,7 @@ EXPLAIN
SELECT 'bug' FROM DUAL WHERE ( 5 ) IN (SELECT * FROM v2); SELECT 'bug' FROM DUAL WHERE ( 5 ) IN (SELECT * FROM v2);
id select_type table type possible_keys key key_len ref rows Extra 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 1 PRIMARY NULL NULL NULL NULL NULL NULL NULL No tables used
2 DEPENDENT SUBQUERY <derived3> ALL NULL NULL NULL NULL 2 Using where 2 SUBQUERY <derived3> ALL NULL NULL NULL NULL 2 Using where
3 DERIVED t1 system NULL NULL NULL NULL 1 3 DERIVED t1 system NULL NULL NULL NULL 1
4 UNION t2 system NULL NULL NULL NULL 1 4 UNION t2 system NULL NULL NULL NULL 1
NULL UNION RESULT <union3,4> ALL NULL NULL NULL NULL NULL NULL UNION RESULT <union3,4> ALL NULL NULL NULL NULL NULL
@ -1471,7 +1471,7 @@ EXPLAIN
SELECT 'bug' FROM t3 WHERE ( 5 ) IN (SELECT * FROM v2); SELECT 'bug' FROM t3 WHERE ( 5 ) IN (SELECT * FROM v2);
id select_type table type possible_keys key key_len ref rows Extra id select_type table type possible_keys key key_len ref rows Extra
1 PRIMARY t3 system NULL NULL NULL NULL 1 1 PRIMARY t3 system NULL NULL NULL NULL 1
2 DEPENDENT SUBQUERY <derived3> ALL NULL NULL NULL NULL 2 Using where 2 SUBQUERY <derived3> ALL NULL NULL NULL NULL 2 Using where
3 DERIVED t1 system NULL NULL NULL NULL 1 3 DERIVED t1 system NULL NULL NULL NULL 1
4 UNION t2 system NULL NULL NULL NULL 1 4 UNION t2 system NULL NULL NULL NULL 1
NULL UNION RESULT <union3,4> ALL NULL NULL NULL NULL NULL NULL UNION RESULT <union3,4> ALL NULL NULL NULL NULL NULL
@ -1481,7 +1481,7 @@ EXPLAIN
SELECT ( 5 ) IN ( SELECT * FROM v2 ); SELECT ( 5 ) IN ( SELECT * FROM v2 );
id select_type table type possible_keys key key_len ref rows Extra 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 1 PRIMARY NULL NULL NULL NULL NULL NULL NULL No tables used
2 DEPENDENT SUBQUERY <derived3> ALL NULL NULL NULL NULL 2 Using where 2 SUBQUERY <derived3> ALL NULL NULL NULL NULL 2 Using where
3 DERIVED t1 system NULL NULL NULL NULL 1 3 DERIVED t1 system NULL NULL NULL NULL 1
4 UNION t2 system NULL NULL NULL NULL 1 4 UNION t2 system NULL NULL NULL NULL 1
NULL UNION RESULT <union3,4> ALL NULL NULL NULL NULL NULL NULL UNION RESULT <union3,4> ALL NULL NULL NULL NULL NULL
@ -1632,8 +1632,8 @@ EXPLAIN
SELECT * FROM t1 WHERE ( 6 ) NOT IN ( SELECT t2.f3 FROM t2 JOIN t3 ON t3.f10 = t2.f10); 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 id select_type table type possible_keys key key_len ref rows Extra
1 PRIMARY t1 ALL NULL NULL NULL NULL 2 1 PRIMARY t1 ALL NULL NULL NULL NULL 2
2 DEPENDENT SUBQUERY t3 system NULL NULL NULL NULL 1 2 SUBQUERY t3 system NULL NULL NULL NULL 1
2 DEPENDENT SUBQUERY t2 ref_or_null f10 f10 10 const,const 2 Using where; Using index 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); SELECT * FROM t1 WHERE ( 6 ) NOT IN ( SELECT t2.f3 FROM t2 JOIN t3 ON t3.f10 = t2.f10);
f4 f4
drop table t1,t2,t3; drop table t1,t2,t3;
@ -2014,6 +2014,21 @@ ERROR 21000: Subquery returns more than 1 row
DROP TABLE t2; DROP TABLE t2;
ERROR 42S02: Unknown table 't2' ERROR 42S02: Unknown table 't2'
DROP TABLE t1; DROP TABLE t1;
#
# LP BUG#1000649 EXPLAIN shows incorrectly a non-correlated constant IN subquery is correlated
#
create table ten (a int);
insert into ten values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9);
create table t1 (a int, b int, c int);
insert into t1 select a,a,a from ten;
create table five (a int, b int, c int);
insert into five select a,a,a from ten limit 5;
set @@optimizer_switch='semijoin=on,in_to_exists=on,materialization=off';
explain select * from t1 where 33 in (select b from five) or c > 11;
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;
set optimizer_switch=@subselect4_tmp; set optimizer_switch=@subselect4_tmp;
SET optimizer_switch= @@global.optimizer_switch; SET optimizer_switch= @@global.optimizer_switch;
set @@tmp_table_size= @@global.tmp_table_size; set @@tmp_table_size= @@global.tmp_table_size;

View File

@ -259,6 +259,66 @@ Warnings:
Warning 1292 Incorrect datetime value: '0' Warning 1292 Incorrect datetime value: '0'
DROP TABLE t1; DROP TABLE t1;
# #
# Bug #11766300 59387: FAILING ASSERTION: CURSOR->POS_STATE == 1997660512 (BTR_PCUR_IS_POSITIONE
#
CREATE TABLE t1 (a INT) ENGINE=INNODB;
INSERT INTO t1 VALUES (0);
CREATE TABLE t2 (d BINARY(2), PRIMARY KEY (d(1)), UNIQUE KEY (d)) ENGINE=INNODB;
SELECT 1 FROM t1 WHERE NOT EXISTS
(SELECT 1 FROM t2 WHERE d = (SELECT d FROM t2 WHERE a >= 1) ORDER BY d);
1
1
EXPLAIN SELECT 1 FROM t1 WHERE NOT EXISTS
(SELECT 1 FROM t2 WHERE d = (SELECT d FROM t2 WHERE a >= 1) ORDER BY d);
id select_type table type possible_keys key key_len ref rows Extra
1 PRIMARY t1 ALL NULL NULL NULL NULL 1 Using where
2 DEPENDENT SUBQUERY t2 eq_ref PRIMARY,d d 2 func 1 Using where
3 DEPENDENT SUBQUERY t2 index NULL d 2 NULL 1 Using where; Using index
DROP TABLE t2;
CREATE TABLE t2 (b INT, c INT, UNIQUE KEY (b), UNIQUE KEY (b, c )) ENGINE=INNODB;
INSERT INTO t2 VALUES (1, 1);
SELECT 1 FROM t1
WHERE a != (SELECT 1 FROM t2 WHERE a <=> b OR a > '' AND 6 = 7 ORDER BY b, c);
1
DROP TABLE t1, t2;
#
# Bug #13639204 64111: CRASH ON SELECT SUBQUERY WITH NON UNIQUE
# INDEX
#
CREATE TABLE t1 (
id int
) ENGINE=InnoDB;
INSERT INTO t1 (id) VALUES (11);
CREATE TABLE t2 (
t1_id int,
position int,
KEY t1_id (t1_id),
KEY t1_id_position (t1_id,position)
) ENGINE=InnoDB;
EXPLAIN SELECT
(SELECT position FROM t2
WHERE t2.t1_id = t1.id
ORDER BY t2.t1_id , t2.position
LIMIT 10,1
) AS maxkey
FROM t1
LIMIT 1;
id select_type table type possible_keys key key_len ref rows Extra
1 PRIMARY t1 ALL NULL NULL NULL NULL 1
2 DEPENDENT SUBQUERY t2 ref t1_id,t1_id_position t1_id_position 5 test.t1.id 1 Using where; Using index
SELECT
(SELECT position FROM t2
WHERE t2.t1_id = t1.id
ORDER BY t2.t1_id , t2.position
LIMIT 10,1
) AS maxkey
FROM t1
LIMIT 1;
maxkey
NULL
DROP TABLE t1,t2;
End of 5.1 tests
#
# lp:827416 Crash in select_describe() on EXPLAIN with DISTINCT in nested subqueries # lp:827416 Crash in select_describe() on EXPLAIN with DISTINCT in nested subqueries
# #
CREATE TABLE t3 ( b int) ENGINE=InnoDB; CREATE TABLE t3 ( b int) ENGINE=InnoDB;
@ -316,4 +376,19 @@ GROUP BY 1
MAX( f1 ) MAX( f1 )
NULL NULL
drop table t1, t2, t3; drop table t1, t2, t3;
#
# LP BUG#1006231 crash in select_describe
#
create table t1(a1 int) ENGINE=InnoDB;
insert into t1 values (1);
explain
select 1 from t1 where 1 like (select 1 from t1 where 1 <=> (select 1 from t1 group by a1));
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
select 1 from t1 where 1 like (select 1 from t1 where 1 <=> (select 1 from t1 group by a1));
1
1
drop table t1;
set optimizer_switch=@subselect_innodb_tmp; set optimizer_switch=@subselect_innodb_tmp;

View File

@ -1163,7 +1163,7 @@ 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); 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 id select_type table type possible_keys key key_len ref rows Extra
1 PRIMARY t1 system NULL NULL NULL NULL 1 1 PRIMARY t1 system NULL NULL NULL NULL 1
2 DEPENDENT SUBQUERY t2 system NULL NULL NULL NULL 0 const row not found 2 SUBQUERY t2 system NULL NULL NULL NULL 0 const row not found
select min(a1) from t1 where 7 in (select max(b1) from t2 group by b1); select min(a1) from t1 where 7 in (select max(b1) from t2 group by b1);
min(a1) min(a1)
NULL NULL
@ -1182,7 +1182,7 @@ set @@optimizer_switch='materialization=off,in_to_exists=on';
explain select min(a1) from t1 where 7 in (select b1 from t2); 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 id select_type table type possible_keys key key_len ref rows Extra
1 PRIMARY t1 system NULL NULL NULL NULL 1 1 PRIMARY t1 system NULL NULL NULL NULL 1
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 min(a1) from t1 where 7 in (select b1 from t2); select min(a1) from t1 where 7 in (select b1 from t2);
min(a1) min(a1)
NULL NULL
@ -1190,7 +1190,7 @@ NULL
explain select min(a1) from t1 where 7 in (select b1 from t2) or 2> 4; 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 id select_type table type possible_keys key key_len ref rows Extra
1 PRIMARY t1 system NULL NULL NULL NULL 1 1 PRIMARY t1 system NULL NULL NULL NULL 1
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 min(a1) from t1 where 7 in (select b1 from t2) or 2> 4; select min(a1) from t1 where 7 in (select b1 from t2) or 2> 4;
min(a1) min(a1)
NULL NULL
@ -1986,6 +1986,19 @@ y
z z
DROP VIEW v2; DROP VIEW v2;
DROP TABLE t1, t2; DROP TABLE t1, t2;
#
# BUG#1000269: Wrong result (extra rows) with semijoin+materialization, IN subqueries, join_cache_level>0
#
CREATE TABLE t1 (a1 VARCHAR(1), a2 VARCHAR(1)) ENGINE=MyISAM;
INSERT INTO t1 VALUES ('b','b'),('e','e');
CREATE TABLE t2 (b1 VARCHAR(1), b2 VARCHAR(1), KEY(b1)) ENGINE=MyISAM;
INSERT INTO t2 VALUES ('v','v'),('s','s'),('l','l'), ('y','y'),('c','c'),('i','i');
SELECT * FROM t1, t2 WHERE b1 IN ( SELECT b2 FROM t2 WHERE b1 > 'o' ) AND ( b1 < 'l' OR a1 IN ('b','c') );
a1 a2 b1 b2
b b v v
b b s s
b b y y
DROP TABLE t1,t2;
# This must be at the end: # This must be at the end:
set optimizer_switch=@subselect_sj_mat_tmp; set optimizer_switch=@subselect_sj_mat_tmp;
set join_cache_level=@save_join_cache_level; set join_cache_level=@save_join_cache_level;
@ -2234,7 +2247,7 @@ EXPLAIN EXTENDED
SELECT MAX(t1.b) AS max_res FROM t1 WHERE (9) IN (SELECT a FROM t2); 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 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 t1 index NULL b 5 NULL 2 100.00 Using index
2 DEPENDENT SUBQUERY t2 ALL NULL NULL NULL NULL 2 100.00 Using where 2 SUBQUERY t2 ALL NULL NULL NULL NULL 2 100.00 Using where
Warnings: 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 <expr_cache><9>(<in_optimizer>(9,<exists>(select `test`.`t2`.`a` from `test`.`t2` where (9 = `test`.`t2`.`a`))))
DROP TABLE t1,t2; DROP TABLE t1,t2;

View File

@ -124,7 +124,7 @@ FROM t3 RIGHT JOIN t1 ON t1.pk = t3.f1
WHERE t3.f3 OR ( 3 ) IN ( SELECT f2 FROM t2 ); WHERE t3.f3 OR ( 3 ) IN ( SELECT f2 FROM t2 );
id select_type table type possible_keys key key_len ref rows Extra 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 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 t1.* SELECT t1.*
FROM t3 RIGHT JOIN t1 ON t1.pk = t3.f1 FROM t3 RIGHT JOIN t1 ON t1.pk = t3.f1
WHERE t3.f3 OR ( 3 ) IN ( SELECT f2 FROM t2 ); WHERE t3.f3 OR ( 3 ) IN ( SELECT f2 FROM t2 );

View File

@ -1327,7 +1327,7 @@ SELECT 0 IN (SELECT 1 FROM t1 a);
EXPLAIN EXTENDED SELECT 0 IN (SELECT 1 FROM t1 a); EXPLAIN EXTENDED SELECT 0 IN (SELECT 1 FROM t1 a);
id select_type table type possible_keys key key_len ref rows filtered Extra id select_type table type possible_keys key key_len ref rows filtered Extra
1 PRIMARY NULL NULL NULL NULL NULL NULL NULL NULL No tables used 1 PRIMARY NULL NULL NULL NULL NULL NULL NULL NULL No tables used
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: Warnings:
Note 1003 select <in_optimizer>(0,<exists>(select 1 from dual where (0 = 1))) AS `0 IN (SELECT 1 FROM t1 a)` Note 1003 select <in_optimizer>(0,<exists>(select 1 from dual where (0 = 1))) AS `0 IN (SELECT 1 FROM t1 a)`
INSERT INTO t1 (pseudo) VALUES ('test1'); INSERT INTO t1 (pseudo) VALUES ('test1');
@ -1337,7 +1337,7 @@ SELECT 0 IN (SELECT 1 FROM t1 a);
EXPLAIN EXTENDED SELECT 0 IN (SELECT 1 FROM t1 a); EXPLAIN EXTENDED SELECT 0 IN (SELECT 1 FROM t1 a);
id select_type table type possible_keys key key_len ref rows filtered Extra id select_type table type possible_keys key key_len ref rows filtered Extra
1 PRIMARY NULL NULL NULL NULL NULL NULL NULL NULL No tables used 1 PRIMARY NULL NULL NULL NULL NULL NULL NULL NULL No tables used
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: Warnings:
Note 1003 select <in_optimizer>(0,<exists>(select 1 from `test`.`t1` `a` where (0 = 1))) AS `0 IN (SELECT 1 FROM t1 a)` Note 1003 select <in_optimizer>(0,<exists>(select 1 from `test`.`t1` `a` where (0 = 1))) AS `0 IN (SELECT 1 FROM t1 a)`
drop table t1; drop table t1;
@ -3106,7 +3106,7 @@ ON r.a = (SELECT t2.a FROM t2 WHERE t2.c = t1.a AND t2.b <= '359899'
id select_type table type possible_keys key key_len ref rows Extra id select_type table type possible_keys key key_len ref rows Extra
1 PRIMARY t1 system PRIMARY NULL NULL NULL 1 1 PRIMARY t1 system PRIMARY NULL NULL NULL 1
1 PRIMARY r eq_ref PRIMARY PRIMARY 4 const 1 Using where 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 2 DEPENDENT 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 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' 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; ORDER BY t2.c DESC, t2.b DESC LIMIT 1) WHERE t1.a = 10;
@ -4529,13 +4529,13 @@ SET join_cache_level=0;
EXPLAIN EXTENDED SELECT 1 FROM t1 WHERE 1 IN (SELECT min(a) FROM t1 GROUP BY a); 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 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 t1 ALL NULL NULL NULL NULL 2 100.00
2 DEPENDENT SUBQUERY 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: 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 <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`))))))
EXPLAIN EXTENDED SELECT 1 FROM t1 WHERE 1 IN (SELECT min(a) FROM t1 WHERE a > 3 GROUP BY a); 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 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 t1 ALL NULL NULL NULL NULL 2 100.00
2 DEPENDENT SUBQUERY t1 ALL NULL NULL NULL NULL 2 100.00 Using where; Using temporary 2 SUBQUERY t1 ALL NULL NULL NULL NULL 2 100.00 Using where; Using temporary
Warnings: 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 <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`))))))
SET join_cache_level=@save_join_cache_level; SET join_cache_level=@save_join_cache_level;
@ -4587,7 +4587,7 @@ SELECT MAX(b), (SELECT COUNT(*) FROM st1,st2 WHERE st2.b <= t1.b)
FROM t1 FROM t1
WHERE a = 230; WHERE a = 230;
MAX(b) (SELECT COUNT(*) FROM st1,st2 WHERE st2.b <= t1.b) MAX(b) (SELECT COUNT(*) FROM st1,st2 WHERE st2.b <= t1.b)
NULL 0 NULL NULL
DROP TABLE t1, st1, st2; DROP TABLE t1, st1, st2;
# #
# Bug #48709: Assertion failed in sql_select.cc:11782: # Bug #48709: Assertion failed in sql_select.cc:11782:
@ -5599,6 +5599,15 @@ SELECT 1 FROM
ERROR 21000: Operand should contain 1 column(s) ERROR 21000: Operand should contain 1 column(s)
DROP TABLE t1; DROP TABLE t1;
# #
# Bug#13721076 CRASH WITH TIME TYPE/TIMESTAMP() AND WARNINGS IN SUBQUERY
#
CREATE TABLE t1(a TIME NOT NULL);
INSERT INTO t1 VALUES ('00:00:32');
SELECT 1 FROM t1 WHERE a >
(SELECT timestamp(a) AS a FROM t1);
1
DROP TABLE t1;
#
# No BUG#, a case brought from 5.2's innodb_mysql_lock.test # No BUG#, a case brought from 5.2's innodb_mysql_lock.test
# #
create table t1 (i int not null primary key); create table t1 (i int not null primary key);
@ -5717,7 +5726,7 @@ WHERE ('0') IN ( SELECT a FROM t1 GROUP BY a )
GROUP BY b; GROUP BY b;
id select_type table type possible_keys key key_len ref rows Extra id select_type table type possible_keys key key_len ref rows Extra
1 PRIMARY t1 ALL NULL NULL NULL NULL 2 Using temporary; Using filesort 1 PRIMARY t1 ALL NULL NULL NULL NULL 2 Using temporary; Using filesort
2 DEPENDENT SUBQUERY t1 ALL NULL NULL NULL NULL 2 Using where 2 SUBQUERY t1 ALL NULL NULL NULL NULL 2 Using where
SELECT b FROM t1 SELECT b FROM t1
WHERE ('0') IN ( SELECT a FROM t1 GROUP BY a ) WHERE ('0') IN ( SELECT a FROM t1 GROUP BY a )
GROUP BY b; GROUP BY b;
@ -6520,6 +6529,65 @@ INSERT INTO t1 VALUES (1);
SELECT a FROM t1 WHERE ( SELECT MIN(a) = 100 ); SELECT a FROM t1 WHERE ( SELECT MIN(a) = 100 );
a a
drop table t1; drop table t1;
#
# LP BUG#985667 Wrong result with subquery in SELECT clause, and constant table in
# main query and implicit grouping
#
CREATE TABLE t1 (f1 int) engine=MyISAM;
INSERT INTO t1 VALUES (7),(8);
CREATE TABLE t2 (f2 int, f3 varchar(1)) engine=MyISAM;
INSERT INTO t2 VALUES (3,'f');
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
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
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
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
EXPLAIN
SELECT COUNT(f1), f2 > ALL (SELECT f1 FROM t1 WHERE f2 > 0) 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 Using where
SELECT COUNT(f1), f2 > ALL (SELECT f1 FROM t1 WHERE f2 > 0) AS f4 FROM t2, t1 WHERE 'v'= f3;
COUNT(f1) f4
0 1
EXPLAIN
SELECT COUNT(f1), f2 IN (SELECT f1 FROM t1 WHERE f2 > 0) 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 Using where
SELECT COUNT(f1), f2 IN (SELECT f1 FROM t1 WHERE f2 > 0) AS f4 FROM t2, t1 WHERE 'v'= f3;
COUNT(f1) f4
0 0
drop table t1,t2;
#
# LP BUG#1002079 Server crashes in Item_singlerow_subselect::val_int with constant table,
# HAVING, UNION in subquery
#
CREATE TABLE t1 (a INT);
INSERT INTO t1 VALUES (7),(0);
CREATE TABLE t2 (b INT);
EXPLAIN
SELECT SUM(a) AS f1, a AS f2 FROM (t1, t2) HAVING f2 >= ALL (SELECT 4 UNION SELECT 5) AND f1 = 7;
id select_type table type possible_keys key key_len ref rows Extra
1 PRIMARY t2 system NULL NULL NULL NULL 0 const row not found
1 PRIMARY t1 ALL NULL NULL NULL NULL 2
2 SUBQUERY NULL NULL NULL NULL NULL NULL NULL No tables used
3 UNION NULL NULL NULL NULL NULL NULL NULL No tables used
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;
# return optimizer switch changed in the beginning of this test # return optimizer switch changed in the beginning of this test
set optimizer_switch=@subselect_tmp; set optimizer_switch=@subselect_tmp;
set optimizer_switch=default; set optimizer_switch=default;

View File

@ -1323,7 +1323,7 @@ SELECT 0 IN (SELECT 1 FROM t1 a);
EXPLAIN EXTENDED SELECT 0 IN (SELECT 1 FROM t1 a); EXPLAIN EXTENDED SELECT 0 IN (SELECT 1 FROM t1 a);
id select_type table type possible_keys key key_len ref rows filtered Extra id select_type table type possible_keys key key_len ref rows filtered Extra
1 PRIMARY NULL NULL NULL NULL NULL NULL NULL NULL No tables used 1 PRIMARY NULL NULL NULL NULL NULL NULL NULL NULL No tables used
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: Warnings:
Note 1003 select <in_optimizer>(0,<exists>(select 1 from dual where (0 = 1))) AS `0 IN (SELECT 1 FROM t1 a)` Note 1003 select <in_optimizer>(0,<exists>(select 1 from dual where (0 = 1))) AS `0 IN (SELECT 1 FROM t1 a)`
INSERT INTO t1 (pseudo) VALUES ('test1'); INSERT INTO t1 (pseudo) VALUES ('test1');
@ -1333,7 +1333,7 @@ SELECT 0 IN (SELECT 1 FROM t1 a);
EXPLAIN EXTENDED SELECT 0 IN (SELECT 1 FROM t1 a); EXPLAIN EXTENDED SELECT 0 IN (SELECT 1 FROM t1 a);
id select_type table type possible_keys key key_len ref rows filtered Extra id select_type table type possible_keys key key_len ref rows filtered Extra
1 PRIMARY NULL NULL NULL NULL NULL NULL NULL NULL No tables used 1 PRIMARY NULL NULL NULL NULL NULL NULL NULL NULL No tables used
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: Warnings:
Note 1003 select <in_optimizer>(0,<exists>(select 1 from `test`.`t1` `a` where (0 = 1))) AS `0 IN (SELECT 1 FROM t1 a)` Note 1003 select <in_optimizer>(0,<exists>(select 1 from `test`.`t1` `a` where (0 = 1))) AS `0 IN (SELECT 1 FROM t1 a)`
drop table t1; drop table t1;
@ -3102,7 +3102,7 @@ ON r.a = (SELECT t2.a FROM t2 WHERE t2.c = t1.a AND t2.b <= '359899'
id select_type table type possible_keys key key_len ref rows Extra id select_type table type possible_keys key key_len ref rows Extra
1 PRIMARY t1 system PRIMARY NULL NULL NULL 1 1 PRIMARY t1 system PRIMARY NULL NULL NULL 1
1 PRIMARY r eq_ref PRIMARY PRIMARY 4 const 1 Using where 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 2 DEPENDENT 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 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' 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; ORDER BY t2.c DESC, t2.b DESC LIMIT 1) WHERE t1.a = 10;
@ -4525,13 +4525,13 @@ SET join_cache_level=0;
EXPLAIN EXTENDED SELECT 1 FROM t1 WHERE 1 IN (SELECT min(a) FROM t1 GROUP BY a); 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 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 t1 ALL NULL NULL NULL NULL 2 100.00
2 DEPENDENT SUBQUERY 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: 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 <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`)))))
EXPLAIN EXTENDED SELECT 1 FROM t1 WHERE 1 IN (SELECT min(a) FROM t1 WHERE a > 3 GROUP BY a); 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 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 t1 ALL NULL NULL NULL NULL 2 100.00
2 DEPENDENT SUBQUERY t1 ALL NULL NULL NULL NULL 2 100.00 Using where; Using temporary 2 SUBQUERY t1 ALL NULL NULL NULL NULL 2 100.00 Using where; Using temporary
Warnings: 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 <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`)))))
SET join_cache_level=@save_join_cache_level; SET join_cache_level=@save_join_cache_level;
@ -4583,7 +4583,7 @@ SELECT MAX(b), (SELECT COUNT(*) FROM st1,st2 WHERE st2.b <= t1.b)
FROM t1 FROM t1
WHERE a = 230; WHERE a = 230;
MAX(b) (SELECT COUNT(*) FROM st1,st2 WHERE st2.b <= t1.b) MAX(b) (SELECT COUNT(*) FROM st1,st2 WHERE st2.b <= t1.b)
NULL 0 NULL NULL
DROP TABLE t1, st1, st2; DROP TABLE t1, st1, st2;
# #
# Bug #48709: Assertion failed in sql_select.cc:11782: # Bug #48709: Assertion failed in sql_select.cc:11782:
@ -5595,6 +5595,15 @@ SELECT 1 FROM
ERROR 21000: Operand should contain 1 column(s) ERROR 21000: Operand should contain 1 column(s)
DROP TABLE t1; DROP TABLE t1;
# #
# Bug#13721076 CRASH WITH TIME TYPE/TIMESTAMP() AND WARNINGS IN SUBQUERY
#
CREATE TABLE t1(a TIME NOT NULL);
INSERT INTO t1 VALUES ('00:00:32');
SELECT 1 FROM t1 WHERE a >
(SELECT timestamp(a) AS a FROM t1);
1
DROP TABLE t1;
#
# No BUG#, a case brought from 5.2's innodb_mysql_lock.test # No BUG#, a case brought from 5.2's innodb_mysql_lock.test
# #
create table t1 (i int not null primary key); create table t1 (i int not null primary key);
@ -5713,7 +5722,7 @@ WHERE ('0') IN ( SELECT a FROM t1 GROUP BY a )
GROUP BY b; GROUP BY b;
id select_type table type possible_keys key key_len ref rows Extra id select_type table type possible_keys key key_len ref rows Extra
1 PRIMARY t1 ALL NULL NULL NULL NULL 2 Using temporary; Using filesort 1 PRIMARY t1 ALL NULL NULL NULL NULL 2 Using temporary; Using filesort
2 DEPENDENT SUBQUERY t1 ALL NULL NULL NULL NULL 2 Using where 2 SUBQUERY t1 ALL NULL NULL NULL NULL 2 Using where
SELECT b FROM t1 SELECT b FROM t1
WHERE ('0') IN ( SELECT a FROM t1 GROUP BY a ) WHERE ('0') IN ( SELECT a FROM t1 GROUP BY a )
GROUP BY b; GROUP BY b;
@ -6516,6 +6525,65 @@ INSERT INTO t1 VALUES (1);
SELECT a FROM t1 WHERE ( SELECT MIN(a) = 100 ); SELECT a FROM t1 WHERE ( SELECT MIN(a) = 100 );
a a
drop table t1; drop table t1;
#
# LP BUG#985667 Wrong result with subquery in SELECT clause, and constant table in
# main query and implicit grouping
#
CREATE TABLE t1 (f1 int) engine=MyISAM;
INSERT INTO t1 VALUES (7),(8);
CREATE TABLE t2 (f2 int, f3 varchar(1)) engine=MyISAM;
INSERT INTO t2 VALUES (3,'f');
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
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
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
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
EXPLAIN
SELECT COUNT(f1), f2 > ALL (SELECT f1 FROM t1 WHERE f2 > 0) 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 Using where
SELECT COUNT(f1), f2 > ALL (SELECT f1 FROM t1 WHERE f2 > 0) AS f4 FROM t2, t1 WHERE 'v'= f3;
COUNT(f1) f4
0 1
EXPLAIN
SELECT COUNT(f1), f2 IN (SELECT f1 FROM t1 WHERE f2 > 0) 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 Using where
SELECT COUNT(f1), f2 IN (SELECT f1 FROM t1 WHERE f2 > 0) AS f4 FROM t2, t1 WHERE 'v'= f3;
COUNT(f1) f4
0 0
drop table t1,t2;
#
# LP BUG#1002079 Server crashes in Item_singlerow_subselect::val_int with constant table,
# HAVING, UNION in subquery
#
CREATE TABLE t1 (a INT);
INSERT INTO t1 VALUES (7),(0);
CREATE TABLE t2 (b INT);
EXPLAIN
SELECT SUM(a) AS f1, a AS f2 FROM (t1, t2) HAVING f2 >= ALL (SELECT 4 UNION SELECT 5) AND f1 = 7;
id select_type table type possible_keys key key_len ref rows Extra
1 PRIMARY t2 system NULL NULL NULL NULL 0 const row not found
1 PRIMARY t1 ALL NULL NULL NULL NULL 2
2 SUBQUERY NULL NULL NULL NULL NULL NULL NULL No tables used
3 UNION NULL NULL NULL NULL NULL NULL NULL No tables used
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;
# return optimizer switch changed in the beginning of this test # return optimizer switch changed in the beginning of this test
set optimizer_switch=@subselect_tmp; set optimizer_switch=@subselect_tmp;
set @optimizer_switch_for_subselect_test=null; set @optimizer_switch_for_subselect_test=null;

View File

@ -1326,7 +1326,7 @@ SELECT 0 IN (SELECT 1 FROM t1 a);
EXPLAIN EXTENDED SELECT 0 IN (SELECT 1 FROM t1 a); EXPLAIN EXTENDED SELECT 0 IN (SELECT 1 FROM t1 a);
id select_type table type possible_keys key key_len ref rows filtered Extra id select_type table type possible_keys key key_len ref rows filtered Extra
1 PRIMARY NULL NULL NULL NULL NULL NULL NULL NULL No tables used 1 PRIMARY NULL NULL NULL NULL NULL NULL NULL NULL No tables used
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: Warnings:
Note 1003 select <in_optimizer>(0,<exists>(select 1 from dual where (0 = 1))) AS `0 IN (SELECT 1 FROM t1 a)` Note 1003 select <in_optimizer>(0,<exists>(select 1 from dual where (0 = 1))) AS `0 IN (SELECT 1 FROM t1 a)`
INSERT INTO t1 (pseudo) VALUES ('test1'); INSERT INTO t1 (pseudo) VALUES ('test1');
@ -1336,7 +1336,7 @@ SELECT 0 IN (SELECT 1 FROM t1 a);
EXPLAIN EXTENDED SELECT 0 IN (SELECT 1 FROM t1 a); EXPLAIN EXTENDED SELECT 0 IN (SELECT 1 FROM t1 a);
id select_type table type possible_keys key key_len ref rows filtered Extra id select_type table type possible_keys key key_len ref rows filtered Extra
1 PRIMARY NULL NULL NULL NULL NULL NULL NULL NULL No tables used 1 PRIMARY NULL NULL NULL NULL NULL NULL NULL NULL No tables used
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: Warnings:
Note 1003 select <in_optimizer>(0,<exists>(select 1 from `test`.`t1` `a` where (0 = 1))) AS `0 IN (SELECT 1 FROM t1 a)` Note 1003 select <in_optimizer>(0,<exists>(select 1 from `test`.`t1` `a` where (0 = 1))) AS `0 IN (SELECT 1 FROM t1 a)`
drop table t1; drop table t1;
@ -3106,7 +3106,7 @@ ON r.a = (SELECT t2.a FROM t2 WHERE t2.c = t1.a AND t2.b <= '359899'
id select_type table type possible_keys key key_len ref rows Extra id select_type table type possible_keys key key_len ref rows Extra
1 PRIMARY t1 system PRIMARY NULL NULL NULL 1 1 PRIMARY t1 system PRIMARY NULL NULL NULL 1
1 PRIMARY r eq_ref PRIMARY PRIMARY 4 const 1 Using where 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 2 DEPENDENT 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 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' 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; ORDER BY t2.c DESC, t2.b DESC LIMIT 1) WHERE t1.a = 10;
@ -4591,7 +4591,7 @@ SELECT MAX(b), (SELECT COUNT(*) FROM st1,st2 WHERE st2.b <= t1.b)
FROM t1 FROM t1
WHERE a = 230; WHERE a = 230;
MAX(b) (SELECT COUNT(*) FROM st1,st2 WHERE st2.b <= t1.b) MAX(b) (SELECT COUNT(*) FROM st1,st2 WHERE st2.b <= t1.b)
NULL 0 NULL NULL
DROP TABLE t1, st1, st2; DROP TABLE t1, st1, st2;
# #
# Bug #48709: Assertion failed in sql_select.cc:11782: # Bug #48709: Assertion failed in sql_select.cc:11782:
@ -5603,6 +5603,15 @@ SELECT 1 FROM
ERROR 21000: Operand should contain 1 column(s) ERROR 21000: Operand should contain 1 column(s)
DROP TABLE t1; DROP TABLE t1;
# #
# Bug#13721076 CRASH WITH TIME TYPE/TIMESTAMP() AND WARNINGS IN SUBQUERY
#
CREATE TABLE t1(a TIME NOT NULL);
INSERT INTO t1 VALUES ('00:00:32');
SELECT 1 FROM t1 WHERE a >
(SELECT timestamp(a) AS a FROM t1);
1
DROP TABLE t1;
#
# No BUG#, a case brought from 5.2's innodb_mysql_lock.test # No BUG#, a case brought from 5.2's innodb_mysql_lock.test
# #
create table t1 (i int not null primary key); create table t1 (i int not null primary key);
@ -5722,7 +5731,7 @@ WHERE ('0') IN ( SELECT a FROM t1 GROUP BY a )
GROUP BY b; GROUP BY b;
id select_type table type possible_keys key key_len ref rows Extra id select_type table type possible_keys key key_len ref rows Extra
1 PRIMARY t1 ALL NULL NULL NULL NULL 2 Using temporary; Using filesort 1 PRIMARY t1 ALL NULL NULL NULL NULL 2 Using temporary; Using filesort
2 DEPENDENT SUBQUERY t1 ALL NULL NULL NULL NULL 2 Using where 2 SUBQUERY t1 ALL NULL NULL NULL NULL 2 Using where
SELECT b FROM t1 SELECT b FROM t1
WHERE ('0') IN ( SELECT a FROM t1 GROUP BY a ) WHERE ('0') IN ( SELECT a FROM t1 GROUP BY a )
GROUP BY b; GROUP BY b;
@ -6527,6 +6536,65 @@ INSERT INTO t1 VALUES (1);
SELECT a FROM t1 WHERE ( SELECT MIN(a) = 100 ); SELECT a FROM t1 WHERE ( SELECT MIN(a) = 100 );
a a
drop table t1; drop table t1;
#
# LP BUG#985667 Wrong result with subquery in SELECT clause, and constant table in
# main query and implicit grouping
#
CREATE TABLE t1 (f1 int) engine=MyISAM;
INSERT INTO t1 VALUES (7),(8);
CREATE TABLE t2 (f2 int, f3 varchar(1)) engine=MyISAM;
INSERT INTO t2 VALUES (3,'f');
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
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
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
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
EXPLAIN
SELECT COUNT(f1), f2 > ALL (SELECT f1 FROM t1 WHERE f2 > 0) 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 Using where
SELECT COUNT(f1), f2 > ALL (SELECT f1 FROM t1 WHERE f2 > 0) AS f4 FROM t2, t1 WHERE 'v'= f3;
COUNT(f1) f4
0 1
EXPLAIN
SELECT COUNT(f1), f2 IN (SELECT f1 FROM t1 WHERE f2 > 0) 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 Using where
SELECT COUNT(f1), f2 IN (SELECT f1 FROM t1 WHERE f2 > 0) AS f4 FROM t2, t1 WHERE 'v'= f3;
COUNT(f1) f4
0 0
drop table t1,t2;
#
# LP BUG#1002079 Server crashes in Item_singlerow_subselect::val_int with constant table,
# HAVING, UNION in subquery
#
CREATE TABLE t1 (a INT);
INSERT INTO t1 VALUES (7),(0);
CREATE TABLE t2 (b INT);
EXPLAIN
SELECT SUM(a) AS f1, a AS f2 FROM (t1, t2) HAVING f2 >= ALL (SELECT 4 UNION SELECT 5) AND f1 = 7;
id select_type table type possible_keys key key_len ref rows Extra
1 PRIMARY t2 system NULL NULL NULL NULL 0 const row not found
1 PRIMARY t1 ALL NULL NULL NULL NULL 2
2 SUBQUERY NULL NULL NULL NULL NULL NULL NULL No tables used
3 UNION NULL NULL NULL NULL NULL NULL NULL No tables used
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;
# return optimizer switch changed in the beginning of this test # return optimizer switch changed in the beginning of this test
set optimizer_switch=@subselect_tmp; set optimizer_switch=@subselect_tmp;
set optimizer_switch=default; set optimizer_switch=default;

View File

@ -1323,7 +1323,7 @@ SELECT 0 IN (SELECT 1 FROM t1 a);
EXPLAIN EXTENDED SELECT 0 IN (SELECT 1 FROM t1 a); EXPLAIN EXTENDED SELECT 0 IN (SELECT 1 FROM t1 a);
id select_type table type possible_keys key key_len ref rows filtered Extra id select_type table type possible_keys key key_len ref rows filtered Extra
1 PRIMARY NULL NULL NULL NULL NULL NULL NULL NULL No tables used 1 PRIMARY NULL NULL NULL NULL NULL NULL NULL NULL No tables used
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: Warnings:
Note 1003 select <in_optimizer>(0,<exists>(select 1 from dual where (0 = 1))) AS `0 IN (SELECT 1 FROM t1 a)` Note 1003 select <in_optimizer>(0,<exists>(select 1 from dual where (0 = 1))) AS `0 IN (SELECT 1 FROM t1 a)`
INSERT INTO t1 (pseudo) VALUES ('test1'); INSERT INTO t1 (pseudo) VALUES ('test1');
@ -1333,7 +1333,7 @@ SELECT 0 IN (SELECT 1 FROM t1 a);
EXPLAIN EXTENDED SELECT 0 IN (SELECT 1 FROM t1 a); EXPLAIN EXTENDED SELECT 0 IN (SELECT 1 FROM t1 a);
id select_type table type possible_keys key key_len ref rows filtered Extra id select_type table type possible_keys key key_len ref rows filtered Extra
1 PRIMARY NULL NULL NULL NULL NULL NULL NULL NULL No tables used 1 PRIMARY NULL NULL NULL NULL NULL NULL NULL NULL No tables used
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: Warnings:
Note 1003 select <in_optimizer>(0,<exists>(select 1 from `test`.`t1` `a` where (0 = 1))) AS `0 IN (SELECT 1 FROM t1 a)` Note 1003 select <in_optimizer>(0,<exists>(select 1 from `test`.`t1` `a` where (0 = 1))) AS `0 IN (SELECT 1 FROM t1 a)`
drop table t1; drop table t1;
@ -3102,7 +3102,7 @@ ON r.a = (SELECT t2.a FROM t2 WHERE t2.c = t1.a AND t2.b <= '359899'
id select_type table type possible_keys key key_len ref rows Extra id select_type table type possible_keys key key_len ref rows Extra
1 PRIMARY t1 system PRIMARY NULL NULL NULL 1 1 PRIMARY t1 system PRIMARY NULL NULL NULL 1
1 PRIMARY r eq_ref PRIMARY PRIMARY 4 const 1 Using where 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 2 DEPENDENT 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 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' 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; ORDER BY t2.c DESC, t2.b DESC LIMIT 1) WHERE t1.a = 10;
@ -4583,7 +4583,7 @@ SELECT MAX(b), (SELECT COUNT(*) FROM st1,st2 WHERE st2.b <= t1.b)
FROM t1 FROM t1
WHERE a = 230; WHERE a = 230;
MAX(b) (SELECT COUNT(*) FROM st1,st2 WHERE st2.b <= t1.b) MAX(b) (SELECT COUNT(*) FROM st1,st2 WHERE st2.b <= t1.b)
NULL 0 NULL NULL
DROP TABLE t1, st1, st2; DROP TABLE t1, st1, st2;
# #
# Bug #48709: Assertion failed in sql_select.cc:11782: # Bug #48709: Assertion failed in sql_select.cc:11782:
@ -5595,6 +5595,15 @@ SELECT 1 FROM
ERROR 21000: Operand should contain 1 column(s) ERROR 21000: Operand should contain 1 column(s)
DROP TABLE t1; DROP TABLE t1;
# #
# Bug#13721076 CRASH WITH TIME TYPE/TIMESTAMP() AND WARNINGS IN SUBQUERY
#
CREATE TABLE t1(a TIME NOT NULL);
INSERT INTO t1 VALUES ('00:00:32');
SELECT 1 FROM t1 WHERE a >
(SELECT timestamp(a) AS a FROM t1);
1
DROP TABLE t1;
#
# No BUG#, a case brought from 5.2's innodb_mysql_lock.test # No BUG#, a case brought from 5.2's innodb_mysql_lock.test
# #
create table t1 (i int not null primary key); create table t1 (i int not null primary key);
@ -5713,7 +5722,7 @@ WHERE ('0') IN ( SELECT a FROM t1 GROUP BY a )
GROUP BY b; GROUP BY b;
id select_type table type possible_keys key key_len ref rows Extra id select_type table type possible_keys key key_len ref rows Extra
1 PRIMARY t1 ALL NULL NULL NULL NULL 2 Using temporary; Using filesort 1 PRIMARY t1 ALL NULL NULL NULL NULL 2 Using temporary; Using filesort
2 DEPENDENT SUBQUERY t1 ALL NULL NULL NULL NULL 2 Using where 2 SUBQUERY t1 ALL NULL NULL NULL NULL 2 Using where
SELECT b FROM t1 SELECT b FROM t1
WHERE ('0') IN ( SELECT a FROM t1 GROUP BY a ) WHERE ('0') IN ( SELECT a FROM t1 GROUP BY a )
GROUP BY b; GROUP BY b;
@ -6516,6 +6525,65 @@ INSERT INTO t1 VALUES (1);
SELECT a FROM t1 WHERE ( SELECT MIN(a) = 100 ); SELECT a FROM t1 WHERE ( SELECT MIN(a) = 100 );
a a
drop table t1; drop table t1;
#
# LP BUG#985667 Wrong result with subquery in SELECT clause, and constant table in
# main query and implicit grouping
#
CREATE TABLE t1 (f1 int) engine=MyISAM;
INSERT INTO t1 VALUES (7),(8);
CREATE TABLE t2 (f2 int, f3 varchar(1)) engine=MyISAM;
INSERT INTO t2 VALUES (3,'f');
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
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
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
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
EXPLAIN
SELECT COUNT(f1), f2 > ALL (SELECT f1 FROM t1 WHERE f2 > 0) 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 Using where
SELECT COUNT(f1), f2 > ALL (SELECT f1 FROM t1 WHERE f2 > 0) AS f4 FROM t2, t1 WHERE 'v'= f3;
COUNT(f1) f4
0 1
EXPLAIN
SELECT COUNT(f1), f2 IN (SELECT f1 FROM t1 WHERE f2 > 0) 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 Using where
SELECT COUNT(f1), f2 IN (SELECT f1 FROM t1 WHERE f2 > 0) AS f4 FROM t2, t1 WHERE 'v'= f3;
COUNT(f1) f4
0 0
drop table t1,t2;
#
# LP BUG#1002079 Server crashes in Item_singlerow_subselect::val_int with constant table,
# HAVING, UNION in subquery
#
CREATE TABLE t1 (a INT);
INSERT INTO t1 VALUES (7),(0);
CREATE TABLE t2 (b INT);
EXPLAIN
SELECT SUM(a) AS f1, a AS f2 FROM (t1, t2) HAVING f2 >= ALL (SELECT 4 UNION SELECT 5) AND f1 = 7;
id select_type table type possible_keys key key_len ref rows Extra
1 PRIMARY t2 system NULL NULL NULL NULL 0 const row not found
1 PRIMARY t1 ALL NULL NULL NULL NULL 2
2 SUBQUERY NULL NULL NULL NULL NULL NULL NULL No tables used
3 UNION NULL NULL NULL NULL NULL NULL NULL No tables used
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;
# return optimizer switch changed in the beginning of this test # return optimizer switch changed in the beginning of this test
set optimizer_switch=@subselect_tmp; set optimizer_switch=@subselect_tmp;
set @optimizer_switch_for_subselect_test=null; set @optimizer_switch_for_subselect_test=null;

View File

@ -879,7 +879,7 @@ EXPLAIN
SELECT * FROM t1 WHERE (6, 4 ) NOT IN (SELECT b, a FROM t2); SELECT * FROM t1 WHERE (6, 4 ) NOT IN (SELECT b, a FROM t2);
id select_type table type possible_keys key key_len ref rows Extra id select_type table type possible_keys key key_len ref rows Extra
1 PRIMARY t1 ALL NULL NULL NULL NULL 2 1 PRIMARY t1 ALL NULL NULL NULL NULL 2
2 DEPENDENT SUBQUERY t2 ALL NULL NULL NULL NULL 2 Using where 2 SUBQUERY t2 ALL NULL NULL NULL NULL 2 Using where
SELECT * FROM t1 WHERE (6, 4 ) NOT IN (SELECT b, a FROM t2); SELECT * FROM t1 WHERE (6, 4 ) NOT IN (SELECT b, a FROM t2);
c c
0 0
@ -888,7 +888,7 @@ EXPLAIN
SELECT * FROM t1 WHERE (6, 4 ) NOT IN (SELECT a, b FROM t2); SELECT * FROM t1 WHERE (6, 4 ) NOT IN (SELECT a, b FROM t2);
id select_type table type possible_keys key key_len ref rows Extra id select_type table type possible_keys key key_len ref rows Extra
1 PRIMARY t1 ALL NULL NULL NULL NULL 2 1 PRIMARY t1 ALL NULL NULL NULL NULL 2
2 DEPENDENT SUBQUERY t2 ALL NULL NULL NULL NULL 2 Using where 2 SUBQUERY t2 ALL NULL NULL NULL NULL 2 Using where
SELECT * FROM t1 WHERE (6, 4 ) NOT IN (SELECT a, b FROM t2); SELECT * FROM t1 WHERE (6, 4 ) NOT IN (SELECT a, b FROM t2);
c c
0 0
@ -913,7 +913,7 @@ set @@optimizer_switch='in_to_exists=on,materialization=off';
EXPLAIN SELECT * FROM t2 WHERE ( 3 , 1 ) NOT IN ( SELECT f1 , f2 FROM t1 ); EXPLAIN SELECT * FROM t2 WHERE ( 3 , 1 ) NOT IN ( SELECT f1 , f2 FROM t1 );
id select_type table type possible_keys key key_len ref rows Extra id select_type table type possible_keys key key_len ref rows Extra
1 PRIMARY t2 system NULL NULL NULL NULL 1 1 PRIMARY t2 system NULL NULL NULL NULL 1
2 DEPENDENT SUBQUERY t1 ALL NULL NULL NULL NULL 3 Using where 2 SUBQUERY t1 ALL NULL NULL NULL NULL 3 Using where
SELECT * FROM t2 WHERE ( 3 , 1 ) NOT IN ( SELECT f1 , f2 FROM t1 ); SELECT * FROM t2 WHERE ( 3 , 1 ) NOT IN ( SELECT f1 , f2 FROM t1 );
f3 f3
5 5

View File

@ -2671,4 +2671,100 @@ a
DEALLOCATE PREPARE pstmt; DEALLOCATE PREPARE pstmt;
DROP VIEW v1; DROP VIEW v1;
DROP TABLE t1, t2; DROP TABLE t1, t2;
#
# BUG#978479: Wrong result (extra rows) with derived_with_keys+loosescan+semijoin=ON, materialization=OFF
#
set @tmp_jcl_978479= @@join_cache_level;
set join_cache_level=0;
set @tmp_os_978479= @@optimizer_switch;
set optimizer_switch = 'derived_with_keys=on,loosescan=on,semijoin=on,materialization=off';
# Part#1: make sure EXPLAIN is using LooseScan:
CREATE TABLE t1 ( a INT, b INT );
INSERT INTO t1 VALUES
(4,0),(6,8),(3,1),(5,8),(3,9),(2,4),
(2,6),(9,1),(5,4),(7,7),(5,4);
CREATE ALGORITHM=TEMPTABLE
VIEW v1 AS SELECT * FROM t1;
# This will use LooseScan:
EXPLAIN
SELECT * FROM t1 AS t1_1, t1 AS t1_2
WHERE (t1_1.a, t1_2.a) IN ( SELECT a, b FROM v1 );
id select_type table type possible_keys key key_len ref rows Extra
1 PRIMARY t1_1 ALL NULL NULL NULL NULL 11 Using where
1 PRIMARY <derived3> ref key0 key0 5 test.t1_1.a 2 Start temporary
1 PRIMARY t1_2 ALL NULL NULL NULL NULL 11 Using where; End temporary
3 DERIVED t1 ALL NULL NULL NULL NULL 11
SELECT * FROM t1 AS t1_1, t1 AS t1_2
WHERE (t1_1.a, t1_2.a) IN ( SELECT a, b FROM v1 );
a b a b
3 1 9 1
5 8 4 0
3 9 9 1
2 4 6 8
2 4 4 0
2 6 6 8
2 6 4 0
5 4 4 0
7 7 7 7
5 4 4 0
DROP VIEW v1;
DROP TABLE t1;
set @@join_cache_level= @tmp_jcl_978479;
set @@optimizer_switch= @tmp_os_978479;
#
# BUG#998236: Assertion failure or valgrind errors at best_access_path ...
#
CREATE TABLE t1 (a1 VARCHAR(3), a2 VARCHAR(35), KEY(a1,a2)) ENGINE=MyISAM;
INSERT INTO t1 VALUES
('USA','Arvada'),('USA','Athens'),('USA','Atlanta'),('USA','Augusta'),
('USA','Aurora'),('USA','Aurora'),('USA','Austin'),('USA','Bakersfield'),
('USA','Baltimore'),('USA','Baton'),('USA','Beaumont'),('USA','Bellevue'),
('USA','Berkeley'),('USA','Billings'),('USA','Birmingham'),('USA','Boise'),
('USA','Boston'),('USA','Boulder'),('USA','Bridgeport'),('USA','Brockton'),
('USA','Brownsville'),('USA','Buffalo'),('USA','Burbank'),('USA','Cambridge'),
('USA','Cape'),('USA','Carrollton'),('USA','Carson'),('USA','Cary'),
('USA','Cedar'),('USA','Chandler'),('USA','Charleston'),('USA','Charlotte'),
('USA','Chattanooga'),('USA','Chesapeake'),('USA','Chicago'),('USA','Chula'),
('USA','Cincinnati'),('USA','Citrus'),('USA','Clarksville'),('USA','Clearwater'),
('USA','Cleveland'),('USA','Colorado'),('USA','Columbia'),('USA','Columbus'),
('USA','Columbus'),('USA','Compton'),('USA','Concord'),('USA','Coral'),
('USA','Corona'),('USA','Corpus'),('USA','Costa'),('USA','Dallas'),('USA','Daly'),
('USA','Davenport'),('USA','Dayton'),('USA','Denver'),('USA','DesMoines'),
('USA','Detroit'),('USA','Downey'),('USA','Durham'),('USA','East'),('USA','ElCajon'),
('USA','ElMonte'),('USA','ElPaso'),('USA','Elgin'),('USA','Elizabeth'),
('USA','Erie'),('USA','Escondido'),('USA','Eugene'),('USA','Evansville'),
('USA','Fairfield'),('USA','Fall'),('USA','Fayetteville'),('USA','Flint'),
('USA','Fontana'),('USA','FortCollins'),('USA','FortLauderdale'),('USA','FortWayne'),
('USA','FortWorth'),('USA','Fremont'),('USA','Fresno'),('USA','Fullerton'),
('USA','Gainesville'),('USA','GardenGrove'),('USA','Garland'),('USA','Gary'),
('USA','Gilbert'),('USA','Glendale'),('USA','Glendale'),('USA','GrandPrairie'),
('USA','GrandRapids'),('USA','Green Bay'),('USA','Greensboro'),('USA','Hampton'),
('USA','Hartford'),('USA','Hayward'),('USA','Henderson'),('USA','Hialeah'),
('USA','Inglewood'),('USA','Livonia');
CREATE TABLE t3 (c1 VARCHAR(3), c2 VARCHAR(16), PRIMARY KEY (c1,c2)) ENGINE=MyISAM;
INSERT INTO t3 VALUES ('USA','Chinese'), ('USA','English');
CREATE TABLE t2 (b1 INT) ENGINE=MyISAM;
INSERT INTO t2 VALUES (1);
SELECT alias1.a1 AS field1
FROM t1 AS alias1, t1 AS alias2
WHERE alias1.a2 IN ( SELECT a1 FROM t1, t2 )
AND alias1.a1 IS NULL
AND ( alias1.a1, alias2.a1 ) IN ( SELECT c1, c1 FROM t3 )
GROUP BY field1;
field1
DROP TABLE t1,t3,t2;
#
# BUG#1002630: Valgrind warnings 'Invalid read' in subselect_engine::calc_const_tables with SELECT
#
CREATE TABLE t1 (a INT);
INSERT INTO t1 VALUES (1),(7);
CREATE TABLE t2 (b INT);
INSERT INTO t2 VALUES (4),(6);
SELECT ( SELECT SUM(a) FROM t1 ) AS t1sum, b
FROM t2
WHERE (1,1) IN ( SELECT MAX(a), MIN(a) FROM t1 )
GROUP BY b
HAVING t1sum <> 1;
t1sum b
DROP TABLE t1, t2;
set optimizer_switch=@subselect_sj_tmp; set optimizer_switch=@subselect_sj_tmp;

View File

@ -2685,6 +2685,102 @@ a
DEALLOCATE PREPARE pstmt; DEALLOCATE PREPARE pstmt;
DROP VIEW v1; DROP VIEW v1;
DROP TABLE t1, t2; DROP TABLE t1, t2;
#
# BUG#978479: Wrong result (extra rows) with derived_with_keys+loosescan+semijoin=ON, materialization=OFF
#
set @tmp_jcl_978479= @@join_cache_level;
set join_cache_level=0;
set @tmp_os_978479= @@optimizer_switch;
set optimizer_switch = 'derived_with_keys=on,loosescan=on,semijoin=on,materialization=off';
# Part#1: make sure EXPLAIN is using LooseScan:
CREATE TABLE t1 ( a INT, b INT );
INSERT INTO t1 VALUES
(4,0),(6,8),(3,1),(5,8),(3,9),(2,4),
(2,6),(9,1),(5,4),(7,7),(5,4);
CREATE ALGORITHM=TEMPTABLE
VIEW v1 AS SELECT * FROM t1;
# This will use LooseScan:
EXPLAIN
SELECT * FROM t1 AS t1_1, t1 AS t1_2
WHERE (t1_1.a, t1_2.a) IN ( SELECT a, b FROM v1 );
id select_type table type possible_keys key key_len ref rows Extra
1 PRIMARY t1_1 ALL NULL NULL NULL NULL 11 Using where
1 PRIMARY <derived3> ref key0 key0 5 test.t1_1.a 2 Start temporary
1 PRIMARY t1_2 ALL NULL NULL NULL NULL 11 Using where; End temporary
3 DERIVED t1 ALL NULL NULL NULL NULL 11
SELECT * FROM t1 AS t1_1, t1 AS t1_2
WHERE (t1_1.a, t1_2.a) IN ( SELECT a, b FROM v1 );
a b a b
3 1 9 1
5 8 4 0
3 9 9 1
2 4 6 8
2 4 4 0
2 6 6 8
2 6 4 0
5 4 4 0
7 7 7 7
5 4 4 0
DROP VIEW v1;
DROP TABLE t1;
set @@join_cache_level= @tmp_jcl_978479;
set @@optimizer_switch= @tmp_os_978479;
#
# BUG#998236: Assertion failure or valgrind errors at best_access_path ...
#
CREATE TABLE t1 (a1 VARCHAR(3), a2 VARCHAR(35), KEY(a1,a2)) ENGINE=MyISAM;
INSERT INTO t1 VALUES
('USA','Arvada'),('USA','Athens'),('USA','Atlanta'),('USA','Augusta'),
('USA','Aurora'),('USA','Aurora'),('USA','Austin'),('USA','Bakersfield'),
('USA','Baltimore'),('USA','Baton'),('USA','Beaumont'),('USA','Bellevue'),
('USA','Berkeley'),('USA','Billings'),('USA','Birmingham'),('USA','Boise'),
('USA','Boston'),('USA','Boulder'),('USA','Bridgeport'),('USA','Brockton'),
('USA','Brownsville'),('USA','Buffalo'),('USA','Burbank'),('USA','Cambridge'),
('USA','Cape'),('USA','Carrollton'),('USA','Carson'),('USA','Cary'),
('USA','Cedar'),('USA','Chandler'),('USA','Charleston'),('USA','Charlotte'),
('USA','Chattanooga'),('USA','Chesapeake'),('USA','Chicago'),('USA','Chula'),
('USA','Cincinnati'),('USA','Citrus'),('USA','Clarksville'),('USA','Clearwater'),
('USA','Cleveland'),('USA','Colorado'),('USA','Columbia'),('USA','Columbus'),
('USA','Columbus'),('USA','Compton'),('USA','Concord'),('USA','Coral'),
('USA','Corona'),('USA','Corpus'),('USA','Costa'),('USA','Dallas'),('USA','Daly'),
('USA','Davenport'),('USA','Dayton'),('USA','Denver'),('USA','DesMoines'),
('USA','Detroit'),('USA','Downey'),('USA','Durham'),('USA','East'),('USA','ElCajon'),
('USA','ElMonte'),('USA','ElPaso'),('USA','Elgin'),('USA','Elizabeth'),
('USA','Erie'),('USA','Escondido'),('USA','Eugene'),('USA','Evansville'),
('USA','Fairfield'),('USA','Fall'),('USA','Fayetteville'),('USA','Flint'),
('USA','Fontana'),('USA','FortCollins'),('USA','FortLauderdale'),('USA','FortWayne'),
('USA','FortWorth'),('USA','Fremont'),('USA','Fresno'),('USA','Fullerton'),
('USA','Gainesville'),('USA','GardenGrove'),('USA','Garland'),('USA','Gary'),
('USA','Gilbert'),('USA','Glendale'),('USA','Glendale'),('USA','GrandPrairie'),
('USA','GrandRapids'),('USA','Green Bay'),('USA','Greensboro'),('USA','Hampton'),
('USA','Hartford'),('USA','Hayward'),('USA','Henderson'),('USA','Hialeah'),
('USA','Inglewood'),('USA','Livonia');
CREATE TABLE t3 (c1 VARCHAR(3), c2 VARCHAR(16), PRIMARY KEY (c1,c2)) ENGINE=MyISAM;
INSERT INTO t3 VALUES ('USA','Chinese'), ('USA','English');
CREATE TABLE t2 (b1 INT) ENGINE=MyISAM;
INSERT INTO t2 VALUES (1);
SELECT alias1.a1 AS field1
FROM t1 AS alias1, t1 AS alias2
WHERE alias1.a2 IN ( SELECT a1 FROM t1, t2 )
AND alias1.a1 IS NULL
AND ( alias1.a1, alias2.a1 ) IN ( SELECT c1, c1 FROM t3 )
GROUP BY field1;
field1
DROP TABLE t1,t3,t2;
#
# BUG#1002630: Valgrind warnings 'Invalid read' in subselect_engine::calc_const_tables with SELECT
#
CREATE TABLE t1 (a INT);
INSERT INTO t1 VALUES (1),(7);
CREATE TABLE t2 (b INT);
INSERT INTO t2 VALUES (4),(6);
SELECT ( SELECT SUM(a) FROM t1 ) AS t1sum, b
FROM t2
WHERE (1,1) IN ( SELECT MAX(a), MIN(a) FROM t1 )
GROUP BY b
HAVING t1sum <> 1;
t1sum b
DROP TABLE t1, t2;
set optimizer_switch=@subselect_sj_tmp; set optimizer_switch=@subselect_sj_tmp;
# #
# BUG#49129: Wrong result with IN-subquery with join_cache_level=6 and firstmatch=off # BUG#49129: Wrong result with IN-subquery with join_cache_level=6 and firstmatch=off

View File

@ -1198,7 +1198,7 @@ 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); 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 id select_type table type possible_keys key key_len ref rows Extra
1 PRIMARY t1 system NULL NULL NULL NULL 1 1 PRIMARY t1 system NULL NULL NULL NULL 1
2 DEPENDENT SUBQUERY t2 system NULL NULL NULL NULL 0 const row not found 2 SUBQUERY t2 system NULL NULL NULL NULL 0 const row not found
select min(a1) from t1 where 7 in (select max(b1) from t2 group by b1); select min(a1) from t1 where 7 in (select max(b1) from t2 group by b1);
min(a1) min(a1)
NULL NULL
@ -1207,7 +1207,7 @@ set @@optimizer_switch='semijoin=off';
explain select min(a1) from t1 where 7 in (select b1 from t2); 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 id select_type table type possible_keys key key_len ref rows Extra
1 PRIMARY t1 system NULL NULL NULL NULL 1 1 PRIMARY t1 system NULL NULL NULL NULL 1
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 min(a1) from t1 where 7 in (select b1 from t2); select min(a1) from t1 where 7 in (select b1 from t2);
min(a1) min(a1)
NULL NULL
@ -1224,7 +1224,7 @@ NULL
explain select min(a1) from t1 where 7 in (select b1 from t2) or 2> 4; 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 id select_type table type possible_keys key key_len ref rows Extra
1 PRIMARY t1 system NULL NULL NULL NULL 1 1 PRIMARY t1 system NULL NULL NULL NULL 1
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 min(a1) from t1 where 7 in (select b1 from t2) or 2> 4; select min(a1) from t1 where 7 in (select b1 from t2) or 2> 4;
min(a1) min(a1)
NULL NULL
@ -2026,6 +2026,19 @@ y
z z
DROP VIEW v2; DROP VIEW v2;
DROP TABLE t1, t2; DROP TABLE t1, t2;
#
# BUG#1000269: Wrong result (extra rows) with semijoin+materialization, IN subqueries, join_cache_level>0
#
CREATE TABLE t1 (a1 VARCHAR(1), a2 VARCHAR(1)) ENGINE=MyISAM;
INSERT INTO t1 VALUES ('b','b'),('e','e');
CREATE TABLE t2 (b1 VARCHAR(1), b2 VARCHAR(1), KEY(b1)) ENGINE=MyISAM;
INSERT INTO t2 VALUES ('v','v'),('s','s'),('l','l'), ('y','y'),('c','c'),('i','i');
SELECT * FROM t1, t2 WHERE b1 IN ( SELECT b2 FROM t2 WHERE b1 > 'o' ) AND ( b1 < 'l' OR a1 IN ('b','c') );
a1 a2 b1 b2
b b v v
b b s s
b b y y
DROP TABLE t1,t2;
# This must be at the end: # This must be at the end:
set optimizer_switch=@subselect_sj_mat_tmp; set optimizer_switch=@subselect_sj_mat_tmp;
set join_cache_level=@save_join_cache_level; set join_cache_level=@save_join_cache_level;

View File

@ -570,6 +570,27 @@ id select_type table type possible_keys key key_len ref rows Extra
# as that violates the "no interleaving of outer join nests" rule. # as that violates the "no interleaving of outer join nests" rule.
DROP TABLE t1,t2,t3,t4,t5; DROP TABLE t1,t2,t3,t4,t5;
# #
# BUG#997747: Assertion `join->best_read < ((double)1.79..5e+308L)'
# failed in greedy_search with LEFT JOINs and unique keys
#
CREATE TABLE t1 (a1 INT);
CREATE TABLE t2 (b1 INT);
CREATE TABLE t3 (c1 INT, UNIQUE KEY(c1));
CREATE TABLE t4 (d1 INT, UNIQUE KEY(d1));
CREATE TABLE t5 (e1 INT);
INSERT INTO t1 VALUES (1),(2);
INSERT INTO t2 VALUES (2),(3);
INSERT INTO t3 VALUES (3),(4);
INSERT INTO t4 VALUES (4),(5);
INSERT INTO t5 VALUES (5),(6);
SELECT a1 FROM t1 LEFT JOIN t2 LEFT JOIN t3 LEFT JOIN t4
ON c1 = d1 ON d1 = b1 ON a1 = b1
LEFT JOIN t5 ON a1 = e1 ;
a1
1
2
DROP TABLE t1,t2,t3,t4,t5;
#
# BUG#884184: Wrong result with RIGHT JOIN + derived_merge # BUG#884184: Wrong result with RIGHT JOIN + derived_merge
# #
CREATE TABLE t1 (a int(11), b varchar(1)) ; CREATE TABLE t1 (a int(11), b varchar(1)) ;

View File

@ -21,6 +21,12 @@ name cdate note
name1 1998-01-01 note01 name1 1998-01-01 note01
name2 1998-01-01 note01 name2 1998-01-01 note01
drop table t1,t2; drop table t1,t2;
CREATE TABLE t1(a INT);
INSERT INTO t1 VALUES(1);
SELECT * FROM t1 WHERE LAST_DAY('0000-00-00 00:00:00') IS NULL;
a
1
DROP TABLE t1;
CREATE TABLE t1 ( datum DATE ); CREATE TABLE t1 ( datum DATE );
INSERT INTO t1 VALUES ( "2000-1-1" ); INSERT INTO t1 VALUES ( "2000-1-1" );
INSERT INTO t1 VALUES ( "2000-1-2" ); INSERT INTO t1 VALUES ( "2000-1-2" );
@ -333,3 +339,17 @@ select @a;
@a @a
0111-01-01 0111-01-01
# #
#
# BUG LP:1008487 virtual bool Item_cache::is_expensive(): Assertion `example' failed
#
create table t1(a date,key(a));
insert into t1 values ('2012-01-01'),('2012-02-02');
explain
select 1 from t1 as t1_0 inner join t1 as t2 on (t1_0.a <=> now()) join t1 on 1;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1_0 ref a a 4 const 0 Using where; Using index
1 SIMPLE t2 index NULL a 4 NULL 2 Using index; Using join buffer (flat, BNL join)
1 SIMPLE t1 index NULL a 4 NULL 2 Using index; Using join buffer (incremental, BNL join)
select 1 from t1 as t1_0 inner join t1 as t2 on (t1_0.a <=> now()) join t1 on 1;
1
drop table t1;

View File

@ -0,0 +1,9 @@
CREATE TABLE t1 ( a INT, b CHAR(3) );
INSERT INTO t1 VALUES ( 1, 'foo' );
CREATE TABLE t2 ( c CHAR(3), d INT );
INSERT INTO t2 VALUES ( 'foo', 1 );
UPDATE IGNORE t1, t2 SET b = 'bar', c = 'bar'
WHERE a != ( SELECT 1 UNION SELECT 2 );
Warnings:
Warning 1242 Subquery returns more than 1 row
DROP TABLE t1, t2;

View File

@ -485,4 +485,10 @@ f1 f2
1 4 1 4
DROP TRIGGER trg1; DROP TRIGGER trg1;
DROP TABLE t1; DROP TABLE t1;
#
# Bug #12408412: GROUP_CONCAT + ORDER BY + INPUT/OUTPUT
# SAME USER VARIABLE = CRASH
#
SET @bug12408412=1;
SELECT GROUP_CONCAT(@bug12408412 ORDER BY 1) INTO @bug12408412;
End of 5.5 tests End of 5.5 tests

Some files were not shown because too many files have changed in this diff Show More