merged 5.1-bugteam into B37548 tree

This commit is contained in:
Georgi Kodinov 2008-08-27 18:39:09 +03:00
commit 0b24a95498
658 changed files with 159049 additions and 27034 deletions

View file

@ -389,6 +389,9 @@ client/readline.cpp
client/rpl_constants.h client/rpl_constants.h
client/rpl_record_old.cc client/rpl_record_old.cc
client/rpl_record_old.h client/rpl_record_old.h
client/rpl_tblmap.h
client/rpl_tblmap.cc
client/rpl_utility.h
client/select_test client/select_test
client/sql_string.cpp client/sql_string.cpp
client/ssl_test client/ssl_test

View file

@ -176,7 +176,7 @@ check_cpu () {
fi fi
cc_ver=`$cc --version | sed 1q` cc_ver=`$cc --version | sed 1q`
cc_verno=`echo $cc_ver | sed -e 's/^.*gcc/gcc/g; s/[^0-9. ]//g; s/^ *//g; s/ .*//g'` cc_verno=`echo $cc_ver | sed -e 's/^.*(GCC)//g; s/[^0-9. ]//g; s/^ *//g; s/ .*//g'`
set -- `echo $cc_verno | tr '.' ' '` set -- `echo $cc_verno | tr '.' ' '`
cc_major=$1 cc_major=$1
cc_minor=$2 cc_minor=$2

View file

@ -49,7 +49,7 @@ bin-dist: all
$(top_builddir)/scripts/make_binary_distribution @MAKE_BINARY_DISTRIBUTION_OPTIONS@ $(top_builddir)/scripts/make_binary_distribution @MAKE_BINARY_DISTRIBUTION_OPTIONS@
# Remove BK's "SCCS" subdirectories from source distribution # Remove BK's "SCCS" subdirectories from source distribution
# Create initial database files for Windows installations. # Create initial database files for Windows installations and check them.
dist-hook: dist-hook:
rm -rf `find $(distdir) -type d -name SCCS -print` rm -rf `find $(distdir) -type d -name SCCS -print`
mkdir -p $(distdir)/win mkdir -p $(distdir)/win
@ -57,6 +57,7 @@ dist-hook:
--builddir=$(top_builddir) \ --builddir=$(top_builddir) \
--datadir=$(distdir)/win/data \ --datadir=$(distdir)/win/data \
--srcdir=$(top_srcdir) --srcdir=$(top_srcdir)
storage/myisam/myisamchk --silent --fast $(distdir)/win/data/mysql/*.MYI
tags: tags:
support-files/build-tags support-files/build-tags

View file

@ -88,11 +88,12 @@ mysqlslap_LDADD = $(CXXLDFLAGS) $(CLIENT_THREAD_LIBS) \
mysqltest_SOURCES= mysqltest.c mysqltest_SOURCES= mysqltest.c
mysqltest_CFLAGS= -DTHREAD -UUNDEF_THREADS_HACK mysqltest_CFLAGS= -DTHREAD -UUNDEF_THREADS_HACK
mysqltest_LDADD = $(CXXLDFLAGS) $(CLIENT_THREAD_LIBS) \ mysqltest_LDADD = $(CXXLDFLAGS) \
@CLIENT_EXTRA_LDFLAGS@ \ @CLIENT_EXTRA_LDFLAGS@ \
$(LIBMYSQLCLIENT_LA) \ $(LIBMYSQLCLIENT_LA) \
$(top_builddir)/mysys/libmysys.a \ $(top_builddir)/mysys/libmysys.a \
$(top_builddir)/regex/libregex.a $(top_builddir)/regex/libregex.a \
$(CLIENT_THREAD_LIBS)
mysql_upgrade_SOURCES= mysql_upgrade.c \ mysql_upgrade_SOURCES= mysql_upgrade.c \
$(top_srcdir)/mysys/my_getpagesize.c $(top_srcdir)/mysys/my_getpagesize.c
@ -103,6 +104,7 @@ DEFS = -DUNDEF_THREADS_HACK \
-DDATADIR="\"$(localstatedir)\"" -DDATADIR="\"$(localstatedir)\""
sql_src=log_event.h mysql_priv.h rpl_constants.h \ sql_src=log_event.h mysql_priv.h rpl_constants.h \
rpl_utility.h rpl_tblmap.h rpl_tblmap.cc \
log_event.cc my_decimal.h my_decimal.cc \ log_event.cc my_decimal.h my_decimal.cc \
log_event_old.h log_event_old.cc \ log_event_old.h log_event_old.cc \
rpl_record_old.h rpl_record_old.cc rpl_record_old.h rpl_record_old.cc

View file

@ -1821,7 +1821,7 @@ static int read_and_execute(bool interactive)
the very beginning of a text file when the very beginning of a text file when
you save the file using "Unicode UTF-8" format. you save the file using "Unicode UTF-8" format.
*/ */
if (!line_number && if (line && !line_number &&
(uchar) line[0] == 0xEF && (uchar) line[0] == 0xEF &&
(uchar) line[1] == 0xBB && (uchar) line[1] == 0xBB &&
(uchar) line[2] == 0xBF) (uchar) line[2] == 0xBF)
@ -2176,7 +2176,14 @@ static bool add_line(String &buffer,char *line,char *in_string,
} }
else if (!*ml_comment && (!*in_string && (inchar == '#' || else if (!*ml_comment && (!*in_string && (inchar == '#' ||
inchar == '-' && pos[1] == '-' && inchar == '-' && pos[1] == '-' &&
my_isspace(charset_info,pos[2])))) /*
The third byte is either whitespace or is the
end of the line -- which would occur only
because of the user sending newline -- which is
itself whitespace and should also match.
*/
(my_isspace(charset_info,pos[2]) ||
!pos[2]))))
{ {
// Flush previously accepted characters // Flush previously accepted characters
if (out != line) if (out != line)

View file

@ -269,6 +269,10 @@ get_one_option(int optid, const struct my_option *opt,
} }
/**
Run a command using the shell, storing its output in the supplied dynamic
string.
*/
static int run_command(char* cmd, static int run_command(char* cmd,
DYNAMIC_STRING *ds_res) DYNAMIC_STRING *ds_res)
{ {
@ -341,37 +345,15 @@ static int run_tool(char *tool_path, DYNAMIC_STRING *ds_res, ...)
} }
/* /**
Try to get the full path to this exceutable Look for the filename of given tool, with the presumption that it is in the
same directory as mysql_upgrade and that the same executable-searching
Return 0 if path found mechanism will be used when we run our sub-shells with popen() later.
*/ */
static void find_tool(char *tool_executable_name, const char *tool_name,
static my_bool get_full_path_to_executable(char* path) const char *self_name)
{ {
my_bool ret; char *last_fn_libchar;
DBUG_ENTER("get_full_path_to_executable");
#ifdef __WIN__
ret= (GetModuleFileName(NULL, path, FN_REFLEN) == 0);
#else
/* my_readlink returns 0 if a symlink was read */
ret= (my_readlink(path, "/proc/self/exe", MYF(0)) != 0);
/* Might also want to try with /proc/$$/exe if the above fails */
#endif
DBUG_PRINT("exit", ("path: %s", path));
DBUG_RETURN(ret);
}
/*
Look for the tool in the same directory as mysql_upgrade.
*/
static void find_tool(char *tool_path, const char *tool_name)
{
size_t path_len;
char path[FN_REFLEN];
DYNAMIC_STRING ds_tmp; DYNAMIC_STRING ds_tmp;
DBUG_ENTER("find_tool"); DBUG_ENTER("find_tool");
DBUG_PRINT("enter", ("progname: %s", my_progname)); DBUG_PRINT("enter", ("progname: %s", my_progname));
@ -379,77 +361,59 @@ static void find_tool(char *tool_path, const char *tool_name)
if (init_dynamic_string(&ds_tmp, "", 32, 32)) if (init_dynamic_string(&ds_tmp, "", 32, 32))
die("Out of memory"); die("Out of memory");
/* Initialize path with the full path to this program */ last_fn_libchar= strrchr(self_name, FN_LIBCHAR);
if (get_full_path_to_executable(path))
if (last_fn_libchar == NULL)
{ {
/* /*
Easy way to get full executable path failed, try mysql_upgrade was found by the shell searching the path. A sibling
other methods next to us should be found the same way.
*/ */
if (my_progname[0] == FN_LIBCHAR) strncpy(tool_executable_name, tool_name, FN_REFLEN);
{
/* 1. my_progname contains full path */
strmake(path, my_progname, FN_REFLEN);
}
else if (my_progname[0] == '.')
{
/* 2. my_progname contains relative path, prepend wd */
char buf[FN_REFLEN];
my_getwd(buf, FN_REFLEN, MYF(0));
my_snprintf(path, FN_REFLEN, "%s%s", buf, my_progname);
}
else
{
/* 3. Just go for it and hope tool is in path */
path[0]= 0;
}
} }
else
DBUG_PRINT("info", ("path: '%s'", path));
/* Chop off binary name (i.e mysql-upgrade) from path */
dirname_part(path, path, &path_len);
/*
When running in a not yet installed build and using libtool,
the program(mysql_upgrade) will be in .libs/ and executed
through a libtool wrapper in order to use the dynamic libraries
from this build. The same must be done for the tools(mysql and
mysqlcheck). Thus if path ends in .libs/, step up one directory
and execute the tools from there
*/
path[max(path_len-1, 0)]= 0; /* Chop off last / */
if (strncmp(path + dirname_length(path), ".libs", 5) == 0)
{ {
DBUG_PRINT("info", ("Chopping off .libs from '%s'", path)); int len;
/* Chop off .libs */ /*
dirname_part(path, path, &path_len); mysql_upgrade was run absolutely or relatively. We can find a sibling
by replacing our name after the LIBCHAR with the new tool name.
*/
/*
When running in a not yet installed build and using libtool,
the program(mysql_upgrade) will be in .libs/ and executed
through a libtool wrapper in order to use the dynamic libraries
from this build. The same must be done for the tools(mysql and
mysqlcheck). Thus if path ends in .libs/, step up one directory
and execute the tools from there
*/
if (((last_fn_libchar - 6) >= self_name) &&
(strncmp(last_fn_libchar - 5, ".libs", 5) == 0) &&
(*(last_fn_libchar - 6) == FN_LIBCHAR))
{
DBUG_PRINT("info", ("Chopping off \".libs\" from end of path"));
last_fn_libchar -= 6;
}
len= last_fn_libchar - self_name;
my_snprintf(tool_executable_name, FN_REFLEN, "%.*s%c%s",
len, self_name, FN_LIBCHAR, tool_name);
} }
verbose("Looking for '%s' as: %s", tool_name, tool_executable_name);
DBUG_PRINT("info", ("path: '%s'", path));
/* Format name of the tool to search for */
fn_format(tool_path, tool_name,
path, "", MYF(MY_REPLACE_DIR));
verbose("Looking for '%s' in: %s", tool_name, tool_path);
/* Make sure the tool exists */
if (my_access(tool_path, F_OK) != 0)
die("Can't find '%s'", tool_path);
/* /*
Make sure it can be executed Make sure it can be executed
*/ */
if (run_tool(tool_path, if (run_tool(tool_executable_name,
&ds_tmp, /* Get output from command, discard*/ &ds_tmp, /* Get output from command, discard*/
"--help", "--help",
"2>&1", "2>&1",
IF_WIN("> NUL", "> /dev/null"), IF_WIN("> NUL", "> /dev/null"),
NULL)) NULL))
die("Can't execute '%s'", tool_path); die("Can't execute '%s'", tool_executable_name);
dynstr_free(&ds_tmp); dynstr_free(&ds_tmp);
@ -759,11 +723,20 @@ static const char *load_default_groups[]=
int main(int argc, char **argv) int main(int argc, char **argv)
{ {
char self_name[FN_REFLEN];
MY_INIT(argv[0]); MY_INIT(argv[0]);
#ifdef __NETWARE__ #ifdef __NETWARE__
setscreenmode(SCR_AUTOCLOSE_ON_EXIT); setscreenmode(SCR_AUTOCLOSE_ON_EXIT);
#endif #endif
#if __WIN__
if (GetModuleFileName(NULL, self_name, FN_REFLEN) == 0)
#endif
{
strncpy(self_name, argv[0], FN_REFLEN);
}
if (init_dynamic_string(&ds_args, "", 512, 256)) if (init_dynamic_string(&ds_args, "", 512, 256))
die("Out of memory"); die("Out of memory");
@ -789,10 +762,10 @@ int main(int argc, char **argv)
dynstr_append(&ds_args, " "); dynstr_append(&ds_args, " ");
/* Find mysql */ /* Find mysql */
find_tool(mysql_path, IF_WIN("mysql.exe", "mysql")); find_tool(mysql_path, IF_WIN("mysql.exe", "mysql"), self_name);
/* Find mysqlcheck */ /* Find mysqlcheck */
find_tool(mysqlcheck_path, IF_WIN("mysqlcheck.exe", "mysqlcheck")); find_tool(mysqlcheck_path, IF_WIN("mysqlcheck.exe", "mysqlcheck"), self_name);
/* /*
Read the mysql_upgrade_info file to check if mysql_upgrade Read the mysql_upgrade_info file to check if mysql_upgrade

View file

@ -64,7 +64,8 @@ static void warning(const char *format, ...) ATTRIBUTE_FORMAT(printf, 1, 2);
static bool one_database=0, to_last_remote_log= 0, disable_log_bin= 0; static bool one_database=0, to_last_remote_log= 0, disable_log_bin= 0;
static bool opt_hexdump= 0; static bool opt_hexdump= 0;
const char *base64_output_mode_names[]= {"NEVER", "AUTO", "ALWAYS", NullS}; const char *base64_output_mode_names[]=
{"NEVER", "AUTO", "ALWAYS", "UNSPEC", "DECODE-ROWS", NullS};
TYPELIB base64_output_mode_typelib= TYPELIB base64_output_mode_typelib=
{ array_elements(base64_output_mode_names) - 1, "", { array_elements(base64_output_mode_names) - 1, "",
base64_output_mode_names, NULL }; base64_output_mode_names, NULL };
@ -83,6 +84,8 @@ static const char* user = 0;
static char* pass = 0; static char* pass = 0;
static char *charset= 0; static char *charset= 0;
static uint verbose= 0;
static ulonglong start_position, stop_position; static ulonglong start_position, stop_position;
#define start_position_mot ((my_off_t)start_position) #define start_position_mot ((my_off_t)start_position)
#define stop_position_mot ((my_off_t)stop_position) #define stop_position_mot ((my_off_t)stop_position)
@ -1063,6 +1066,9 @@ that may lead to an endless loop.",
{"user", 'u', "Connect to the remote server as username.", {"user", 'u', "Connect to the remote server as username.",
(uchar**) &user, (uchar**) &user, 0, GET_STR_ALLOC, REQUIRED_ARG, 0, 0, 0, 0, (uchar**) &user, (uchar**) &user, 0, GET_STR_ALLOC, REQUIRED_ARG, 0, 0, 0, 0,
0, 0}, 0, 0},
{"verbose", 'v', "Reconstruct SQL statements out of row events. "
"-v -v adds comments on column data types",
0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0},
{"version", 'V', "Print version and exit.", 0, 0, 0, GET_NO_ARG, NO_ARG, 0, {"version", 'V', "Print version and exit.", 0, 0, 0, GET_NO_ARG, NO_ARG, 0,
0, 0, 0, 0, 0}, 0, 0, 0, 0, 0},
{"open_files_limit", OPT_OPEN_FILES_LIMIT, {"open_files_limit", OPT_OPEN_FILES_LIMIT,
@ -1258,6 +1264,12 @@ get_one_option(int optid, const struct my_option *opt __attribute__((unused)),
(find_type_or_exit(argument, &base64_output_mode_typelib, opt->name)-1); (find_type_or_exit(argument, &base64_output_mode_typelib, opt->name)-1);
} }
break; break;
case 'v':
if (argument == disabled_my_option)
verbose= 0;
else
verbose++;
break;
case 'V': case 'V':
print_version(); print_version();
exit(0); exit(0);
@ -1343,6 +1355,8 @@ static Exit_status dump_log_entries(const char* logname)
*/ */
fprintf(result_file, "DELIMITER /*!*/;\n"); fprintf(result_file, "DELIMITER /*!*/;\n");
strmov(print_event_info.delimiter, "/*!*/;"); strmov(print_event_info.delimiter, "/*!*/;");
print_event_info.verbose= short_form ? 0 : verbose;
rc= (remote_opt ? dump_remote_log_entries(&print_event_info, logname) : rc= (remote_opt ? dump_remote_log_entries(&print_event_info, logname) :
dump_local_log_entries(&print_event_info, logname)); dump_local_log_entries(&print_event_info, logname));

View file

@ -171,6 +171,8 @@ static ulonglong timer_now(void);
static ulonglong progress_start= 0; static ulonglong progress_start= 0;
static ulong connection_retry_sleep= 100000; /* Microseconds */
/* Precompiled re's */ /* Precompiled re's */
static my_regex_t ps_re; /* the query can be run using PS protocol */ static my_regex_t ps_re; /* the query can be run using PS protocol */
static my_regex_t sp_re; /* the query can be run as a SP */ static my_regex_t sp_re; /* the query can be run as a SP */
@ -276,7 +278,8 @@ enum enum_commands {
Q_REPLACE_REGEX, Q_REMOVE_FILE, Q_FILE_EXIST, Q_REPLACE_REGEX, Q_REMOVE_FILE, Q_FILE_EXIST,
Q_WRITE_FILE, Q_COPY_FILE, Q_PERL, Q_DIE, Q_EXIT, Q_SKIP, Q_WRITE_FILE, Q_COPY_FILE, Q_PERL, Q_DIE, Q_EXIT, Q_SKIP,
Q_CHMOD_FILE, Q_APPEND_FILE, Q_CAT_FILE, Q_DIFF_FILES, Q_CHMOD_FILE, Q_APPEND_FILE, Q_CAT_FILE, Q_DIFF_FILES,
Q_SEND_QUIT, Q_CHANGE_USER, Q_MKDIR, Q_RMDIR, Q_SEND_QUIT, Q_CHANGE_USER, Q_MKDIR, Q_RMDIR, Q_LIST_FILES,
Q_LIST_FILES_WRITE_FILE, Q_LIST_FILES_APPEND_FILE,
Q_UNKNOWN, /* Unknown command. */ Q_UNKNOWN, /* Unknown command. */
Q_COMMENT, /* Comments, ignored. */ Q_COMMENT, /* Comments, ignored. */
@ -368,6 +371,9 @@ const char *command_names[]=
"change_user", "change_user",
"mkdir", "mkdir",
"rmdir", "rmdir",
"list_files",
"list_files_write_file",
"list_files_append_file",
0 0
}; };
@ -491,6 +497,9 @@ void replace_dynstr_append(DYNAMIC_STRING *ds, const char *val);
void replace_dynstr_append_uint(DYNAMIC_STRING *ds, uint val); void replace_dynstr_append_uint(DYNAMIC_STRING *ds, uint val);
void dynstr_append_sorted(DYNAMIC_STRING* ds, DYNAMIC_STRING* ds_input); void dynstr_append_sorted(DYNAMIC_STRING* ds, DYNAMIC_STRING* ds_input);
static int match_expected_error(struct st_command *command,
unsigned int err_errno,
const char *err_sqlstate);
void handle_error(struct st_command*, void handle_error(struct st_command*,
unsigned int err_errno, const char *err_error, unsigned int err_errno, const char *err_error,
const char *err_sqlstate, DYNAMIC_STRING *ds); const char *err_sqlstate, DYNAMIC_STRING *ds);
@ -844,29 +853,25 @@ void check_command_args(struct st_command *command,
DBUG_VOID_RETURN; DBUG_VOID_RETURN;
} }
void handle_command_error(struct st_command *command, uint error) void handle_command_error(struct st_command *command, uint error)
{ {
DBUG_ENTER("handle_command_error"); DBUG_ENTER("handle_command_error");
DBUG_PRINT("enter", ("error: %d", error)); DBUG_PRINT("enter", ("error: %d", error));
if (error != 0) if (error != 0)
{ {
uint i; int i;
if (command->abort_on_error) if (command->abort_on_error)
die("command \"%.*s\" failed with error %d", die("command \"%.*s\" failed with error %d",
command->first_word_len, command->query, error); command->first_word_len, command->query, error);
for (i= 0; i < command->expected_errors.count; i++)
i= match_expected_error(command, error, NULL);
if (i >= 0)
{ {
DBUG_PRINT("info", ("expected error: %d", DBUG_PRINT("info", ("command \"%.*s\" failed with expected error: %d",
command->expected_errors.err[i].code.errnum)); command->first_word_len, command->query, error));
if ((command->expected_errors.err[i].type == ERR_ERRNO) && DBUG_VOID_RETURN;
(command->expected_errors.err[i].code.errnum == error))
{
DBUG_PRINT("info", ("command \"%.*s\" failed with expected error: %d",
command->first_word_len, command->query, error));
DBUG_VOID_RETURN;
}
} }
die("command \"%.*s\" failed with wrong error: %d", die("command \"%.*s\" failed with wrong error: %d",
command->first_word_len, command->query, error); command->first_word_len, command->query, error);
@ -2461,8 +2466,8 @@ void do_exec(struct st_command *command)
error= pclose(res_file); error= pclose(res_file);
if (error > 0) if (error > 0)
{ {
uint status= WEXITSTATUS(error), i; uint status= WEXITSTATUS(error);
my_bool ok= 0; int i;
if (command->abort_on_error) if (command->abort_on_error)
{ {
@ -2474,19 +2479,13 @@ void do_exec(struct st_command *command)
DBUG_PRINT("info", DBUG_PRINT("info",
("error: %d, status: %d", error, status)); ("error: %d, status: %d", error, status));
for (i= 0; i < command->expected_errors.count; i++)
{ i= match_expected_error(command, status, NULL);
DBUG_PRINT("info", ("expected error: %d",
command->expected_errors.err[i].code.errnum)); if (i >= 0)
if ((command->expected_errors.err[i].type == ERR_ERRNO) && DBUG_PRINT("info", ("command \"%s\" failed with expected error: %d",
(command->expected_errors.err[i].code.errnum == status)) command->first_argument, status));
{ else
ok= 1;
DBUG_PRINT("info", ("command \"%s\" failed with expected error: %d",
command->first_argument, status));
}
}
if (!ok)
{ {
dynstr_free(&ds_cmd); dynstr_free(&ds_cmd);
die("command \"%s\" failed with wrong error: %d", die("command \"%s\" failed with wrong error: %d",
@ -2836,6 +2835,126 @@ void do_rmdir(struct st_command *command)
} }
/*
SYNOPSIS
get_list_files
ds output
ds_dirname dir to list
ds_wild wild-card file pattern (can be empty)
DESCRIPTION
list all entries in directory (matching ds_wild if given)
*/
static int get_list_files(DYNAMIC_STRING *ds, const DYNAMIC_STRING *ds_dirname,
const DYNAMIC_STRING *ds_wild)
{
uint i;
MY_DIR *dir_info;
FILEINFO *file;
DBUG_ENTER("get_list_files");
DBUG_PRINT("info", ("listing directory: %s", ds_dirname->str));
/* Note that my_dir sorts the list if not given any flags */
if (!(dir_info= my_dir(ds_dirname->str, MYF(0))))
DBUG_RETURN(1);
for (i= 0; i < (uint) dir_info->number_off_files; i++)
{
file= dir_info->dir_entry + i;
if (file->name[0] == '.' &&
(file->name[1] == '\0' ||
(file->name[1] == '.' && file->name[2] == '\0')))
continue; /* . or .. */
if (ds_wild && ds_wild->length &&
wild_compare(file->name, ds_wild->str, 0))
continue;
dynstr_append(ds, file->name);
dynstr_append(ds, "\n");
}
my_dirend(dir_info);
DBUG_RETURN(0);
}
/*
SYNOPSIS
do_list_files
command called command
DESCRIPTION
list_files <dir_name> [<file_name>]
List files and directories in directory <dir_name> (like `ls`)
[Matching <file_name>, where wild-cards are allowed]
*/
static void do_list_files(struct st_command *command)
{
int error;
static DYNAMIC_STRING ds_dirname;
static DYNAMIC_STRING ds_wild;
const struct command_arg list_files_args[] = {
{"dirname", ARG_STRING, TRUE, &ds_dirname, "Directory to list"},
{"file", ARG_STRING, FALSE, &ds_wild, "Filename (incl. wildcard)"}
};
DBUG_ENTER("do_list_files");
check_command_args(command, command->first_argument,
list_files_args,
sizeof(list_files_args)/sizeof(struct command_arg), ' ');
error= get_list_files(&ds_res, &ds_dirname, &ds_wild);
handle_command_error(command, error);
dynstr_free(&ds_dirname);
dynstr_free(&ds_wild);
DBUG_VOID_RETURN;
}
/*
SYNOPSIS
do_list_files_write_file_command
command called command
append append file, or create new
DESCRIPTION
list_files_{write|append}_file <filename> <dir_name> [<match_file>]
List files and directories in directory <dir_name> (like `ls`)
[Matching <match_file>, where wild-cards are allowed]
Note: File will be truncated if exists and append is not true.
*/
static void do_list_files_write_file_command(struct st_command *command,
my_bool append)
{
int error;
static DYNAMIC_STRING ds_content;
static DYNAMIC_STRING ds_filename;
static DYNAMIC_STRING ds_dirname;
static DYNAMIC_STRING ds_wild;
const struct command_arg list_files_args[] = {
{"filename", ARG_STRING, TRUE, &ds_filename, "Filename for write"},
{"dirname", ARG_STRING, TRUE, &ds_dirname, "Directory to list"},
{"file", ARG_STRING, FALSE, &ds_wild, "Filename (incl. wildcard)"}
};
DBUG_ENTER("do_list_files_write_file");
check_command_args(command, command->first_argument,
list_files_args,
sizeof(list_files_args)/sizeof(struct command_arg), ' ');
init_dynamic_string(&ds_content, "", 1024, 1024);
error= get_list_files(&ds_content, &ds_dirname, &ds_wild);
handle_command_error(command, error);
str_to_file2(ds_filename.str, ds_content.str, ds_content.length, append);
dynstr_free(&ds_content);
dynstr_free(&ds_filename);
dynstr_free(&ds_dirname);
dynstr_free(&ds_wild);
DBUG_VOID_RETURN;
}
/* /*
Read characters from line buffer or file. This is needed to allow Read characters from line buffer or file. This is needed to allow
my_ungetc() to buffer MAX_DELIMITER_LENGTH characters for a file my_ungetc() to buffer MAX_DELIMITER_LENGTH characters for a file
@ -4166,7 +4285,6 @@ void safe_connect(MYSQL* mysql, const char *name, const char *host,
int port, const char *sock) int port, const char *sock)
{ {
int failed_attempts= 0; int failed_attempts= 0;
static ulong connection_retry_sleep= 100000; /* Microseconds */
DBUG_ENTER("safe_connect"); DBUG_ENTER("safe_connect");
while(!mysql_real_connect(mysql, host,user, pass, db, port, sock, while(!mysql_real_connect(mysql, host,user, pass, db, port, sock,
@ -4233,6 +4351,7 @@ int connect_n_handle_errors(struct st_command *command,
const char* db, int port, const char* sock) const char* db, int port, const char* sock)
{ {
DYNAMIC_STRING *ds; DYNAMIC_STRING *ds;
int failed_attempts= 0;
ds= &ds_res; ds= &ds_res;
@ -4261,9 +4380,41 @@ int connect_n_handle_errors(struct st_command *command,
dynstr_append_mem(ds, delimiter, delimiter_length); dynstr_append_mem(ds, delimiter, delimiter_length);
dynstr_append_mem(ds, "\n", 1); dynstr_append_mem(ds, "\n", 1);
} }
if (!mysql_real_connect(con, host, user, pass, db, port, sock ? sock: 0, while (!mysql_real_connect(con, host, user, pass, db, port, sock ? sock: 0,
CLIENT_MULTI_STATEMENTS)) CLIENT_MULTI_STATEMENTS))
{ {
/*
If we have used up all our connections check whether this
is expected (by --error). If so, handle the error right away.
Otherwise, give it some extra time to rule out race-conditions.
If extra-time doesn't help, we have an unexpected error and
must abort -- just proceeding to handle_error() when second
and third chances are used up will handle that for us.
There are various user-limits of which only max_user_connections
and max_connections_per_hour apply at connect time. For the
the second to create a race in our logic, we'd need a limits
test that runs without a FLUSH for longer than an hour, so we'll
stay clear of trying to work out which exact user-limit was
exceeded.
*/
if (((mysql_errno(con) == ER_TOO_MANY_USER_CONNECTIONS) ||
(mysql_errno(con) == ER_USER_LIMIT_REACHED)) &&
(failed_attempts++ < opt_max_connect_retries))
{
int i;
i= match_expected_error(command, mysql_errno(con), mysql_sqlstate(con));
if (i >= 0)
goto do_handle_error; /* expected error, handle */
my_sleep(connection_retry_sleep); /* unexpected error, wait */
continue; /* and give it 1 more chance */
}
do_handle_error:
var_set_errno(mysql_errno(con)); var_set_errno(mysql_errno(con));
handle_error(command, mysql_errno(con), mysql_error(con), handle_error(command, mysql_errno(con), mysql_error(con),
mysql_sqlstate(con), ds); mysql_sqlstate(con), ds);
@ -6025,6 +6176,56 @@ end:
} }
/*
Check whether given error is in list of expected errors
SYNOPSIS
match_expected_error()
PARAMETERS
command the current command (and its expect-list)
err_errno error number of the error that actually occurred
err_sqlstate SQL-state that was thrown, or NULL for impossible
(file-ops, diff, etc.)
RETURNS
-1 for not in list, index in list of expected errors otherwise
NOTE
If caller needs to know whether the list was empty, they should
check command->expected_errors.count.
*/
static int match_expected_error(struct st_command *command,
unsigned int err_errno,
const char *err_sqlstate)
{
uint i;
for (i= 0 ; (uint) i < command->expected_errors.count ; i++)
{
if ((command->expected_errors.err[i].type == ERR_ERRNO) &&
(command->expected_errors.err[i].code.errnum == err_errno))
return i;
if (command->expected_errors.err[i].type == ERR_SQLSTATE)
{
/*
NULL is quite likely, but not in conjunction with a SQL-state expect!
*/
if (unlikely(err_sqlstate == NULL))
die("expecting a SQL-state (%s) from query '%s' which cannot produce one...",
command->expected_errors.err[i].code.sqlstate, command->query);
if (strncmp(command->expected_errors.err[i].code.sqlstate,
err_sqlstate, SQLSTATE_LENGTH) == 0)
return i;
}
}
return -1;
}
/* /*
Handle errors which occurred during execution Handle errors which occurred during execution
@ -6045,7 +6246,7 @@ void handle_error(struct st_command *command,
unsigned int err_errno, const char *err_error, unsigned int err_errno, const char *err_error,
const char *err_sqlstate, DYNAMIC_STRING *ds) const char *err_sqlstate, DYNAMIC_STRING *ds)
{ {
uint i; int i;
DBUG_ENTER("handle_error"); DBUG_ENTER("handle_error");
@ -6071,34 +6272,30 @@ void handle_error(struct st_command *command,
DBUG_PRINT("info", ("expected_errors.count: %d", DBUG_PRINT("info", ("expected_errors.count: %d",
command->expected_errors.count)); command->expected_errors.count));
for (i= 0 ; (uint) i < command->expected_errors.count ; i++)
i= match_expected_error(command, err_errno, err_sqlstate);
if (i >= 0)
{ {
if (((command->expected_errors.err[i].type == ERR_ERRNO) && if (!disable_result_log)
(command->expected_errors.err[i].code.errnum == err_errno)) ||
((command->expected_errors.err[i].type == ERR_SQLSTATE) &&
(strncmp(command->expected_errors.err[i].code.sqlstate,
err_sqlstate, SQLSTATE_LENGTH) == 0)))
{ {
if (!disable_result_log) if (command->expected_errors.count == 1)
{ {
if (command->expected_errors.count == 1) /* Only log error if there is one possible error */
{ dynstr_append_mem(ds, "ERROR ", 6);
/* Only log error if there is one possible error */ replace_dynstr_append(ds, err_sqlstate);
dynstr_append_mem(ds, "ERROR ", 6); dynstr_append_mem(ds, ": ", 2);
replace_dynstr_append(ds, err_sqlstate); replace_dynstr_append(ds, err_error);
dynstr_append_mem(ds, ": ", 2); dynstr_append_mem(ds,"\n",1);
replace_dynstr_append(ds, err_error);
dynstr_append_mem(ds,"\n",1);
}
/* Don't log error if we may not get an error */
else if (command->expected_errors.err[0].type == ERR_SQLSTATE ||
(command->expected_errors.err[0].type == ERR_ERRNO &&
command->expected_errors.err[0].code.errnum != 0))
dynstr_append(ds,"Got one of the listed errors\n");
} }
/* OK */ /* Don't log error if we may not get an error */
DBUG_VOID_RETURN; else if (command->expected_errors.err[0].type == ERR_SQLSTATE ||
(command->expected_errors.err[0].type == ERR_ERRNO &&
command->expected_errors.err[0].code.errnum != 0))
dynstr_append(ds,"Got one of the listed errors\n");
} }
/* OK */
DBUG_VOID_RETURN;
} }
DBUG_PRINT("info",("i: %d expected_errors: %d", i, DBUG_PRINT("info",("i: %d expected_errors: %d", i,
@ -6113,7 +6310,7 @@ void handle_error(struct st_command *command,
dynstr_append_mem(ds, "\n", 1); dynstr_append_mem(ds, "\n", 1);
} }
if (i) 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...", die("query '%s' failed with wrong errno %d: '%s', instead of %d...",
@ -7147,6 +7344,13 @@ int main(int argc, char **argv)
case Q_REMOVE_FILE: do_remove_file(command); break; case Q_REMOVE_FILE: do_remove_file(command); break;
case Q_MKDIR: do_mkdir(command); break; case Q_MKDIR: do_mkdir(command); break;
case Q_RMDIR: do_rmdir(command); break; case Q_RMDIR: do_rmdir(command); break;
case Q_LIST_FILES: do_list_files(command); break;
case Q_LIST_FILES_WRITE_FILE:
do_list_files_write_file_command(command, FALSE);
break;
case Q_LIST_FILES_APPEND_FILE:
do_list_files_write_file_command(command, TRUE);
break;
case Q_FILE_EXIST: do_file_exist(command); break; case Q_FILE_EXIST: do_file_exist(command); break;
case Q_WRITE_FILE: do_write_file(command); break; case Q_WRITE_FILE: do_write_file(command); break;
case Q_APPEND_FILE: do_append_file(command); break; case Q_APPEND_FILE: do_append_file(command); break;

View file

@ -343,8 +343,8 @@ case $default_charset in
default_charset_default_collation="ucs2_general_ci" default_charset_default_collation="ucs2_general_ci"
define(UCSC1, ucs2_general_ci ucs2_bin) define(UCSC1, ucs2_general_ci ucs2_bin)
define(UCSC2, ucs2_czech_ci ucs2_danish_ci) define(UCSC2, ucs2_czech_ci ucs2_danish_ci)
define(UCSC3, ucs2_esperanto_ci ucs2_estonian_ci ucs2_icelandic_ci) define(UCSC3, ucs2_esperanto_ci ucs2_estonian_ci ucs2_hungarian_ci)
define(UCSC4, ucs2_latvian_ci ucs2_lithuanian_ci) define(UCSC4, ucs2_icelandic_ci ucs2_latvian_ci ucs2_lithuanian_ci)
define(UCSC5, ucs2_persian_ci ucs2_polish_ci ucs2_romanian_ci) define(UCSC5, ucs2_persian_ci ucs2_polish_ci ucs2_romanian_ci)
define(UCSC6, ucs2_slovak_ci ucs2_slovenian_ci) define(UCSC6, ucs2_slovak_ci ucs2_slovenian_ci)
define(UCSC7, ucs2_spanish2_ci ucs2_spanish_ci) define(UCSC7, ucs2_spanish2_ci ucs2_spanish_ci)
@ -367,8 +367,8 @@ case $default_charset in
else else
define(UTFC1, utf8_general_ci utf8_bin) define(UTFC1, utf8_general_ci utf8_bin)
define(UTFC2, utf8_czech_ci utf8_danish_ci) define(UTFC2, utf8_czech_ci utf8_danish_ci)
define(UTFC3, utf8_esperanto_ci utf8_estonian_ci utf8_icelandic_ci) define(UTFC3, utf8_esperanto_ci utf8_estonian_ci utf8_hungarian_ci)
define(UTFC4, utf8_latvian_ci utf8_lithuanian_ci) define(UTFC4, utf8_icelandic_ci utf8_latvian_ci utf8_lithuanian_ci)
define(UTFC5, utf8_persian_ci utf8_polish_ci utf8_romanian_ci) define(UTFC5, utf8_persian_ci utf8_polish_ci utf8_romanian_ci)
define(UTFC6, utf8_slovak_ci utf8_slovenian_ci) define(UTFC6, utf8_slovak_ci utf8_slovenian_ci)
define(UTFC7, utf8_spanish2_ci utf8_spanish_ci) define(UTFC7, utf8_spanish2_ci utf8_spanish_ci)

View file

@ -10,7 +10,7 @@ AC_CANONICAL_SYSTEM
# #
# When changing major version number please also check switch statement # When changing major version number please also check switch statement
# in mysqlbinlog::check_master_version(). # in mysqlbinlog::check_master_version().
AM_INIT_AUTOMAKE(mysql, 5.1.26-rc) AM_INIT_AUTOMAKE(mysql, 5.1.28)
AM_CONFIG_HEADER([include/config.h:config.h.in]) AM_CONFIG_HEADER([include/config.h:config.h.in])
PROTOCOL_VERSION=10 PROTOCOL_VERSION=10
@ -617,19 +617,19 @@ fi
AC_MSG_CHECKING(whether features provided by the user community should be included.) AC_MSG_CHECKING(whether features provided by the user community should be included.)
AC_ARG_ENABLE(community-features, AC_ARG_ENABLE(community-features,
AC_HELP_STRING( AC_HELP_STRING(
[--enable-community-features], [--disable-community-features],
[Enable additional features provided by the user community.]), [Disable additional features provided by the user community.]),
[ ENABLE_COMMUNITY_FEATURES=$enableval ], [ ENABLE_COMMUNITY_FEATURES=$enableval ],
[ ENABLE_COMMUNITY_FEATURES=no ] [ ENABLE_COMMUNITY_FEATURES=yes ]
) )
if test "$ENABLE_COMMUNITY_FEATURES" = "yes" if test "$ENABLE_COMMUNITY_FEATURES" = "yes"
then then
AC_DEFINE([COMMUNITY_SERVER], [1], AC_DEFINE([COMMUNITY_SERVER], [1],
[Whether features provided by the user community should be included]) [Whether features provided by the user community should be included])
AC_MSG_RESULT([yes, community server]) AC_MSG_RESULT([yes])
else else
AC_MSG_RESULT([no, enterprise server]) AC_MSG_RESULT([no])
fi fi
AC_ARG_WITH(server-suffix, AC_ARG_WITH(server-suffix,

View file

@ -246,7 +246,7 @@ extern int NEAR my_umask, /* Default creation mask */
NEAR my_safe_to_handle_signal, /* Set when allowed to SIGTSTP */ NEAR my_safe_to_handle_signal, /* Set when allowed to SIGTSTP */
NEAR my_dont_interrupt; /* call remember_intr when set */ NEAR my_dont_interrupt; /* call remember_intr when set */
extern my_bool NEAR mysys_uses_curses, my_use_symdir; extern my_bool NEAR mysys_uses_curses, my_use_symdir;
extern ulong sf_malloc_cur_memory, sf_malloc_max_memory; extern size_t sf_malloc_cur_memory, sf_malloc_max_memory;
extern ulong my_default_record_cache_size; extern ulong my_default_record_cache_size;
extern my_bool NEAR my_disable_locking,NEAR my_disable_async_io, extern my_bool NEAR my_disable_locking,NEAR my_disable_async_io,
@ -577,6 +577,7 @@ extern int my_close(File Filedes,myf MyFlags);
extern File my_dup(File file, myf MyFlags); extern File my_dup(File file, myf MyFlags);
extern int my_mkdir(const char *dir, int Flags, myf MyFlags); extern int my_mkdir(const char *dir, int Flags, myf MyFlags);
extern int my_readlink(char *to, const char *filename, myf MyFlags); extern int my_readlink(char *to, const char *filename, myf MyFlags);
extern int my_is_symlink(const char *filename);
extern int my_realpath(char *to, const char *filename, myf MyFlags); extern int my_realpath(char *to, const char *filename, myf MyFlags);
extern File my_create_with_symlink(const char *linkname, const char *filename, extern File my_create_with_symlink(const char *linkname, const char *filename,
int createflags, int access_flags, int createflags, int access_flags,
@ -693,6 +694,7 @@ extern char * fn_format(char * to,const char *name,const char *dir,
const char *form, uint flag); const char *form, uint flag);
extern size_t strlength(const char *str); extern size_t strlength(const char *str);
extern void pack_dirname(char * to,const char *from); extern void pack_dirname(char * to,const char *from);
extern size_t normalize_dirname(char * to, const char *from);
extern size_t unpack_dirname(char * to,const char *from); extern size_t unpack_dirname(char * to,const char *from);
extern size_t cleanup_dirname(char * to,const char *from); extern size_t cleanup_dirname(char * to,const char *from);
extern size_t system_filename(char * to,const char *from); extern size_t system_filename(char * to,const char *from);

View file

@ -256,6 +256,10 @@ extern my_bool myisam_flush,myisam_delay_key_write,myisam_single_user;
extern my_off_t myisam_max_temp_length; extern my_off_t myisam_max_temp_length;
extern ulong myisam_bulk_insert_tree_size, myisam_data_pointer_size; extern ulong myisam_bulk_insert_tree_size, myisam_data_pointer_size;
/* usually used to check if a symlink points into the mysql data home */
/* which is normally forbidden */
extern int (*myisam_test_invalid_symlink)(const char *filename);
/* Prototypes for myisam-functions */ /* Prototypes for myisam-functions */
extern int mi_close(struct st_myisam_info *file); extern int mi_close(struct st_myisam_info *file);

View file

@ -447,7 +447,8 @@ int emb_load_querycache_result(THD *thd, Querycache_stream *src)
if (thd->protocol == &thd->protocol_binary) if (thd->protocol == &thd->protocol_binary)
{ {
uint length; uint length;
row= (MYSQL_ROWS *)alloc_root(&data->alloc, rows * sizeof(MYSQL_ROWS)); row= (MYSQL_ROWS *)alloc_root(&data->alloc,
(size_t) (rows * sizeof(MYSQL_ROWS)));
end_row= row + rows; end_row= row + rows;
data->data= row; data->data= row;

View file

@ -1103,6 +1103,9 @@ void Protocol_text::prepare_for_resend()
data->embedded_info->prev_ptr= &cur->next; data->embedded_info->prev_ptr= &cur->next;
next_field=cur->data; next_field=cur->data;
next_mysql_field= data->embedded_info->fields_list; next_mysql_field= data->embedded_info->fields_list;
#ifndef DBUG_OFF
field_pos= 0;
#endif
DBUG_VOID_RETURN; DBUG_VOID_RETURN;
} }

View file

@ -77,6 +77,7 @@ dist-hook:
$(INSTALL_DATA) $(srcdir)/std_data/ndb_backup51_data_be/BACKUP* $(distdir)/std_data/ndb_backup51_data_be $(INSTALL_DATA) $(srcdir)/std_data/ndb_backup51_data_be/BACKUP* $(distdir)/std_data/ndb_backup51_data_be
$(INSTALL_DATA) $(srcdir)/std_data/ndb_backup51_data_le/BACKUP* $(distdir)/std_data/ndb_backup51_data_le $(INSTALL_DATA) $(srcdir)/std_data/ndb_backup51_data_le/BACKUP* $(distdir)/std_data/ndb_backup51_data_le
$(INSTALL_DATA) $(srcdir)/std_data/parts/part_* $(distdir)/std_data/parts $(INSTALL_DATA) $(srcdir)/std_data/parts/part_* $(distdir)/std_data/parts
$(INSTALL_DATA) $(srcdir)/std_data/parts/*.MY* $(distdir)/std_data/parts
$(INSTALL_DATA) $(srcdir)/std_data/funcs_1/* $(distdir)/std_data/funcs_1 $(INSTALL_DATA) $(srcdir)/std_data/funcs_1/* $(distdir)/std_data/funcs_1
$(INSTALL_DATA) $(srcdir)/lib/*.pl $(distdir)/lib $(INSTALL_DATA) $(srcdir)/lib/*.pl $(distdir)/lib
$(INSTALL_DATA) $(srcdir)/lib/My/*.pm $(distdir)/lib/My $(INSTALL_DATA) $(srcdir)/lib/My/*.pm $(distdir)/lib/My
@ -132,6 +133,7 @@ install-data-local:
$(INSTALL_DATA) $(srcdir)/std_data/ndb_backup51_data_be/BACKUP* $(DESTDIR)$(testdir)/std_data/ndb_backup51_data_be $(INSTALL_DATA) $(srcdir)/std_data/ndb_backup51_data_be/BACKUP* $(DESTDIR)$(testdir)/std_data/ndb_backup51_data_be
$(INSTALL_DATA) $(srcdir)/std_data/ndb_backup51_data_le/BACKUP* $(DESTDIR)$(testdir)/std_data/ndb_backup51_data_le $(INSTALL_DATA) $(srcdir)/std_data/ndb_backup51_data_le/BACKUP* $(DESTDIR)$(testdir)/std_data/ndb_backup51_data_le
$(INSTALL_DATA) $(srcdir)/std_data/parts/part_* $(DESTDIR)$(testdir)/std_data/parts $(INSTALL_DATA) $(srcdir)/std_data/parts/part_* $(DESTDIR)$(testdir)/std_data/parts
$(INSTALL_DATA) $(srcdir)/std_data/parts/*.MY* $(DESTDIR)$(testdir)/std_data/parts
$(INSTALL_DATA) $(srcdir)/std_data/funcs_1/* $(DESTDIR)$(testdir)/std_data/funcs_1 $(INSTALL_DATA) $(srcdir)/std_data/funcs_1/* $(DESTDIR)$(testdir)/std_data/funcs_1
$(INSTALL_DATA) $(srcdir)/lib/*.pl $(DESTDIR)$(testdir)/lib $(INSTALL_DATA) $(srcdir)/lib/*.pl $(DESTDIR)$(testdir)/lib
$(INSTALL_DATA) $(srcdir)/lib/My/*.pm $(DESTDIR)$(testdir)/lib/My $(INSTALL_DATA) $(srcdir)/lib/My/*.pm $(DESTDIR)$(testdir)/lib/My

View file

@ -1,17 +1,43 @@
# Test of binlogging of INSERT_ID with INSERT DELAYED # ==== Purpose ====
#
# Verify that INSERT DELAYED in mixed or row mode writes events to the
# binlog, and that AUTO_INCREMENT works correctly.
#
# ==== Method ====
#
# Insert both single and multiple rows into an autoincrement column,
# both with specified value and with NULL.
#
# With INSERT DELAYED, the rows do not show up in the table
# immediately, so we must do source include/wait_until_rows_count.inc
# between any two INSERT DELAYED statements. Moreover, if mixed or
# row-based logging is used, there is also a delay between when rows
# show up in the table and when they show up in the binlog. To ensure
# that the rows show up in the binlog, we call FLUSH TABLES, which
# waits until the delayed_insert thread has finished.
#
# We cannot read the binlog after executing INSERT DELAYED statements
# that insert multiple rows, because that is nondeterministic. More
# precisely, rows may be written in batches to the binlog, where each
# batch has one Table_map_log_event and one or more
# Write_rows_log_event. The number of rows included in each batch is
# nondeterministic.
#
# ==== Related bugs ====
#
# BUG#20627: INSERT DELAYED does not honour auto_increment_* variables
# Bug in this test: BUG#38068: binlog_stm_binlog fails sporadically in pushbuild
create table t1 (a int not null auto_increment, primary key (a)) engine=myisam; create table t1 (a int not null auto_increment, primary key (a)) engine=myisam;
# First, avoid BUG#20627:
set @@session.auto_increment_increment=1, @@session.auto_increment_offset=1;
# Verify that only one INSERT_ID event is binlogged.
# Note, that because of WL#3368 mixed mode binlog records RBR events for the delayed
let $table=t1; let $table=t1;
let $rows_inserted=11; # total number of inserted rows in this test let $count=0;
insert delayed into t1 values (207); insert delayed into t1 values (207);
let $count=1; inc $count;
# use this macro instead of sleeps.
--source include/wait_until_rows_count.inc --source include/wait_until_rows_count.inc
insert delayed into t1 values (null); insert delayed into t1 values (null);
inc $count; inc $count;
--source include/wait_until_rows_count.inc --source include/wait_until_rows_count.inc
@ -20,9 +46,10 @@ insert delayed into t1 values (300);
inc $count; inc $count;
--source include/wait_until_rows_count.inc --source include/wait_until_rows_count.inc
# moving binlog check affront of multi-rows queries which work is indeterministic (extra table_maps) # It is not enough to wait until all rows have been inserted into the
# todo: better check is to substitute SHOW BINLOG with reading from binlog, probably bug#19459 is in # table. FLUSH TABLES ensures that they are in the binlog too. See
# the way # comment above.
FLUSH TABLES;
source include/show_binlog_events.inc; source include/show_binlog_events.inc;
insert delayed into t1 values (null),(null),(null),(null); insert delayed into t1 values (null),(null),(null),(null);
@ -33,8 +60,5 @@ insert delayed into t1 values (null),(null),(400),(null);
inc $count; inc $count; inc $count; inc $count; inc $count; inc $count; inc $count; inc $count;
--source include/wait_until_rows_count.inc --source include/wait_until_rows_count.inc
#check this assertion about $count calculation
--echo $count == $rows_inserted
select * from t1; select * from t1;
drop table t1; drop table t1;

View file

@ -259,7 +259,7 @@ DELETE FROM t1;
query_vertical SELECT COUNT(*) FROM t1 ORDER BY c1,c2; query_vertical SELECT COUNT(*) FROM t1 ORDER BY c1,c2;
sync_slave_with_master; sync_slave_with_master;
set @@global.slave_exec_mode= default; set @@global.slave_exec_mode= default;
let $last_error = query_get_value("SHOW SLAVE STATUS", Last_SQL_Errno, 1); let $last_error = query_get_value("SHOW SLAVE STATUS", Last_SQL_Error, 1);
disable_query_log; disable_query_log;
eval SELECT "$last_error" AS Last_SQL_Error; eval SELECT "$last_error" AS Last_SQL_Error;
enable_query_log; enable_query_log;
@ -288,3 +288,166 @@ SELECT * FROM t1;
connection master; connection master;
DROP TABLE IF EXISTS t1,t2,t3,t4,t5,t6,t7,t8; DROP TABLE IF EXISTS t1,t2,t3,t4,t5,t6,t7,t8;
sync_slave_with_master; sync_slave_with_master;
#
# BUG#37426: RBR breaks for CHAR() UTF8 fields > 85 chars
#
# We have 4 combinations to test with respect to the field length
# (i.e., the number of bytes) of the CHAR fields:
#
# 1. Replicating from CHAR<256 to CHAR<256
# 2. Replicating from CHAR<256 to CHAR>255
# 3. Replicating from CHAR>255 to CHAR<256
# 4. Replicating from CHAR>255 to CHAR>255
# We also make a special case of using the max size of a field on the
# master, i.e. CHAR(255) in UTF-8, giving another three cases.
#
# 5. Replicating UTF-8 CHAR(255) to CHAR(<256)
# 6. Replicating UTF-8 CHAR(255) to CHAR(>255)
# 7. Replicating UTF-8 CHAR(255) to CHAR(255) UTF-8
connection master;
eval CREATE TABLE t1 (i INT NOT NULL,
c CHAR(16) CHARACTER SET utf8 NOT NULL,
j INT NOT NULL) ENGINE = $type ;
eval CREATE TABLE t2 (i INT NOT NULL,
c CHAR(16) CHARACTER SET utf8 NOT NULL,
j INT NOT NULL) ENGINE = $type ;
sync_slave_with_master;
ALTER TABLE t2 MODIFY c CHAR(128) CHARACTER SET utf8 NOT NULL;
connection master;
eval CREATE TABLE t3 (i INT NOT NULL,
c CHAR(128) CHARACTER SET utf8 NOT NULL,
j INT NOT NULL) ENGINE = $type ;
sync_slave_with_master;
ALTER TABLE t3 MODIFY c CHAR(16) CHARACTER SET utf8 NOT NULL;
connection master;
eval CREATE TABLE t4 (i INT NOT NULL,
c CHAR(128) CHARACTER SET utf8 NOT NULL,
j INT NOT NULL) ENGINE = $type ;
eval CREATE TABLE t5 (i INT NOT NULL,
c CHAR(255) CHARACTER SET utf8 NOT NULL,
j INT NOT NULL) ENGINE = $type ;
sync_slave_with_master;
ALTER TABLE t5 MODIFY c CHAR(16) CHARACTER SET utf8 NOT NULL;
connection master;
eval CREATE TABLE t6 (i INT NOT NULL,
c CHAR(255) CHARACTER SET utf8 NOT NULL,
j INT NOT NULL) ENGINE = $type ;
sync_slave_with_master;
ALTER TABLE t6 MODIFY c CHAR(128) CHARACTER SET utf8 NOT NULL;
connection master;
eval CREATE TABLE t7 (i INT NOT NULL,
c CHAR(255) CHARACTER SET utf8 NOT NULL,
j INT NOT NULL) ENGINE = $type ;
--echo [expecting slave to replicate correctly]
connection master;
INSERT INTO t1 VALUES (1, "", 1);
INSERT INTO t1 VALUES (2, repeat(_utf8'a', 16), 2);
sync_slave_with_master;
let $diff_table_1=master:test.t1;
let $diff_table_2=slave:test.t1;
source include/diff_tables.inc;
--echo [expecting slave to replicate correctly]
connection master;
INSERT INTO t2 VALUES (1, "", 1);
INSERT INTO t2 VALUES (2, repeat(_utf8'a', 16), 2);
sync_slave_with_master;
let $diff_table_1=master:test.t2;
let $diff_table_2=slave:test.t2;
source include/diff_tables.inc;
--echo [expecting slave to stop]
connection master;
INSERT INTO t3 VALUES (1, "", 1);
INSERT INTO t3 VALUES (2, repeat(_utf8'a', 128), 2);
connection slave;
source include/wait_for_slave_sql_to_stop.inc;
let $last_error = query_get_value("SHOW SLAVE STATUS", Last_SQL_Error, 1);
disable_query_log;
eval SELECT "$last_error" AS Last_SQL_Error;
enable_query_log;
connection master;
RESET MASTER;
connection slave;
STOP SLAVE;
RESET SLAVE;
START SLAVE;
source include/wait_for_slave_to_start.inc;
--echo [expecting slave to replicate correctly]
connection master;
INSERT INTO t4 VALUES (1, "", 1);
INSERT INTO t4 VALUES (2, repeat(_utf8'a', 128), 2);
sync_slave_with_master;
let $diff_table_1=master:test.t4;
let $diff_table_2=slave:test.t4;
source include/diff_tables.inc;
--echo [expecting slave to stop]
connection master;
INSERT INTO t5 VALUES (1, "", 1);
INSERT INTO t5 VALUES (2, repeat(_utf8'a', 255), 2);
connection slave;
source include/wait_for_slave_sql_to_stop.inc;
let $last_error = query_get_value("SHOW SLAVE STATUS", Last_SQL_Error, 1);
disable_query_log;
eval SELECT "$last_error" AS Last_SQL_Error;
enable_query_log;
connection master;
RESET MASTER;
connection slave;
STOP SLAVE;
RESET SLAVE;
START SLAVE;
source include/wait_for_slave_to_start.inc;
--echo [expecting slave to stop]
connection master;
INSERT INTO t6 VALUES (1, "", 1);
INSERT INTO t6 VALUES (2, repeat(_utf8'a', 255), 2);
connection slave;
source include/wait_for_slave_sql_to_stop.inc;
let $last_error = query_get_value("SHOW SLAVE STATUS", Last_SQL_Error, 1);
disable_query_log;
eval SELECT "$last_error" AS Last_SQL_Error;
enable_query_log;
connection master;
RESET MASTER;
connection slave;
STOP SLAVE;
RESET SLAVE;
START SLAVE;
source include/wait_for_slave_to_start.inc;
--echo [expecting slave to replicate correctly]
connection master;
INSERT INTO t7 VALUES (1, "", 1);
INSERT INTO t7 VALUES (2, repeat(_utf8'a', 255), 2);
sync_slave_with_master;
let $diff_table_1=master:test.t7;
let $diff_table_2=slave:test.t7;
source include/diff_tables.inc;
connection master;
drop table t1, t2, t3, t4, t5, t6, t7;
sync_slave_with_master;

View file

@ -4,354 +4,641 @@
# Bug#3300 # Bug#3300
# Designed and tested by Sinisa Milivojevic, sinisa@mysql.com # Designed and tested by Sinisa Milivojevic, sinisa@mysql.com
# #
# two non-interfering UPDATE's not changing result set # These variables have to be set before sourcing this script:
# # TRANSACTION ISOLATION LEVEL REPEATABLE READ
# The variable # innodb_locks_unsafe_for_binlog 0 (default) or 1 (by
# $engine_type -- storage engine to be tested # --innodb_locks_unsafe_for_binlog)
# has to be set before sourcing this script. # $engine_type storage engine to be tested
# #
# Last update: # Last update:
# 2006-08-02 ML test refactored # 2006-08-02 ML test refactored
# old name was t/innodb_concurrent.test # old name was t/innodb_concurrent.test
# main code went into include/concurrent.inc # main code went into include/concurrent.inc
# 2008-06-03 KP test refactored; removed name locks, added comments.
# renamed wrapper t/concurrent_innodb.test ->
# t/concurrent_innodb_unsafelog.test
# new wrapper t/concurrent_innodb_safelog.test
# #
connection default; connection default;
eval SET SESSION STORAGE_ENGINE = $engine_type;
#
# Show prerequisites for this test.
#
SELECT @@global.tx_isolation;
SELECT @@global.innodb_locks_unsafe_for_binlog;
#
# When innodb_locks_unsafe_for_binlog is not set (zero), which is the
# default, InnoDB takes "next-key locks"/"gap locks". This means it
# locks the gap before the keys that it accessed to find the rows to
# use for a statement. In this case we have to expect some more lock
# wait timeouts in the tests below as if innodb_locks_unsafe_for_binlog
# is set (non-zero). In the latter case no "next-key locks"/"gap locks"
# are taken and locks on keys that do not match the WHERE conditon are
# released. Hence less lock collisions occur.
# We use the variable $keep_locks to set the expectations for
# lock wait timeouts accordingly.
#
let $keep_locks= `SELECT NOT @@global.innodb_locks_unsafe_for_binlog`;
--echo # keep_locks == $keep_locks
#
# Set up privileges and remove user level locks, if exist.
#
GRANT USAGE ON test.* TO mysqltest@localhost;
#
# Preparatory cleanup.
#
DO release_lock("hello");
DO release_lock("hello2");
--disable_warnings --disable_warnings
drop table if exists t1; drop table if exists t1;
--enable_warnings --enable_warnings
create table t1(eta int(11) not null, tipo int(11), c varchar(255));
connect (thread1, localhost, mysqltest,,);
connection thread1;
eval SET SESSION STORAGE_ENGINE = $engine_type;
insert into t1 values (7,7, "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa");
insert into t1 values (8,8, "bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb");
insert into t1 values (10,1,"ccccccccccccccccccccccccccccccccccccccccccc");
insert into t1 values (20,2,"ddddddddddddddddddddddddddddddddddddddddddd");
insert into t1 values (30,1,"eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee");
insert into t1 values (40,2,"fffffffffffffffffffffffffffffffffffffffffff");
insert into t1 values (50,1,"ggggggggggggggggggggggggggggggggggggggggggg");
insert into t1 values (60,2,"hhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhh");
insert into t1 values (70,1,"iiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiii");
insert into t1 values (80,22,"jjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjj");
insert into t1 values (90,11,"kkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkk");
select get_lock("hello",1);
connect (thread2, localhost, mysqltest,,);
connection thread2;
begin;
send update t1 set eta=1+get_lock("hello",1)*0 where tipo=11;
sleep 1;
connection thread1;
begin;
update t1 set eta=2 where tipo=22;
select release_lock("hello");
select * from t1;
connection thread2;
reap;
select * from t1;
send commit;
connection thread1;
select * from t1;
commit;
select * from t1;
connection thread2;
reap;
select * from t1;
connection thread1;
select * from t1;
connection default;
drop table t1;
#
# two UPDATE's running and one changing result set --echo
# --echo **
#connect (thread1, localhost, mysqltest,,); --echo ** two UPDATE's running and both changing distinct result sets
connection thread1; --echo **
create table t1(eta int(11) not null, tipo int(11), c varchar(255)); --echo ** connection thread1
insert into t1 values (7,7, "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"); connect (thread1, localhost, mysqltest,,);
insert into t1 values (8,8, "bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb"); connection thread1;
insert into t1 values (10,1,"ccccccccccccccccccccccccccccccccccccccccccc"); --echo ** Set up table
insert into t1 values (20,2,"ddddddddddddddddddddddddddddddddddddddddddd"); eval SET SESSION STORAGE_ENGINE = $engine_type;
insert into t1 values (30,1,"eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee"); create table t1(eta int(11) not null, tipo int(11), c varchar(255));
insert into t1 values (40,2,"fffffffffffffffffffffffffffffffffffffffffff"); insert into t1 values (7,7, "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa");
insert into t1 values (50,1,"ggggggggggggggggggggggggggggggggggggggggggg"); insert into t1 values (8,8, "bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb");
insert into t1 values (60,2,"hhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhh"); insert into t1 values (10,1,"ccccccccccccccccccccccccccccccccccccccccccc");
insert into t1 values (70,1,"iiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiii"); insert into t1 values (20,2,"ddddddddddddddddddddddddddddddddddddddddddd");
insert into t1 values (80,22,"jjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjj"); insert into t1 values (30,1,"eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee");
insert into t1 values (90,11,"kkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkk"); insert into t1 values (40,2,"fffffffffffffffffffffffffffffffffffffffffff");
select get_lock("hello",10); insert into t1 values (50,1,"ggggggggggggggggggggggggggggggggggggggggggg");
#connect (thread2, localhost, mysqltest,,); insert into t1 values (60,2,"hhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhh");
connection thread2; insert into t1 values (70,1,"iiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiii");
begin; insert into t1 values (80,22,"jjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjj");
send update t1 set eta=1+get_lock("hello",10)*0 where tipo=1; insert into t1 values (90,11,"kkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkk");
sleep 1; --echo ** Get user level lock (ULL) for thread 1
connection thread1; select get_lock("hello",10);
begin;
update t1 set tipo=1 where tipo=2; --echo ** connection thread2
select release_lock("hello"); connect (thread2, localhost, mysqltest,,);
select * from t1; connection thread2;
connection thread2; --echo ** Start transaction for thread 2
reap; begin;
select * from t1; --echo ** Update will cause a table scan and a new ULL will
send commit; --echo ** be created and blocked on the first row where tipo=11.
connection thread1; send update t1 set eta=1+get_lock("hello",10)*0 where tipo=11;
select * from t1; sleep 1;
commit;
select * from t1; --echo ** connection thread1
connection thread2; connection thread1;
reap; --echo ** Start new transaction for thread 1
select * from t1; begin;
connection thread1; --echo ** Update on t1 will cause a table scan which will be blocked because
select * from t1; --echo ** the previously initiated table scan applied exclusive key locks on
--echo ** all primary keys.
--echo ** Not so if innodb_locks_unsafe_for_binlog is set. The locks that
--echo ** do not match the WHERE condition are released.
if ($keep_locks)
{
--error ER_LOCK_WAIT_TIMEOUT
update t1 set eta=2 where tipo=22;
}
if (!$keep_locks)
{
update t1 set eta=2 where tipo=22;
}
--echo ** Release user level name lock from thread 1. This will cause the ULL
--echo ** on thread 2 to end its wait.
select release_lock("hello");
--echo ** Table is now updated with a new eta on tipo=22 for thread 1.
select * from t1;
--echo ** connection thread2
connection thread2;
--echo ** Release the lock and collect result from update on thread 2
reap;
select release_lock("hello");
--echo ** Table should have eta updates where tipo=11 but updates made by
--echo ** thread 1 shouldn't be visible yet.
select * from t1;
--echo ** Sending commit on thread 2.
commit;
--echo ** connection thread1
connection thread1;
--echo ** Make sure table reads didn't change yet on thread 1.
select * from t1;
--echo ** And send final commit on thread 1.
commit;
--echo ** Table should now be updated by both updates in the order of
--echo ** thread 1,2.
select * from t1;
--echo ** connection thread2
connection thread2;
--echo ** Make sure the output is similar for t1.
select * from t1;
--echo ** connection thread1
connection thread1;
select * from t1;
--echo ** connection default
connection default; connection default;
drop table t1; drop table t1;
# --echo
# One UPDATE and one INSERT .... Monty's test --echo **
# --echo ** two UPDATE's running and one changing result set
--echo **
--echo ** connection thread1
#connect (thread1, localhost, mysqltest,,);
connection thread1;
--echo ** Set up table
eval SET SESSION STORAGE_ENGINE = $engine_type;
create table t1(eta int(11) not null, tipo int(11), c varchar(255));
insert into t1 values (7,7, "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa");
insert into t1 values (8,8, "bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb");
insert into t1 values (10,1,"ccccccccccccccccccccccccccccccccccccccccccc");
insert into t1 values (20,2,"ddddddddddddddddddddddddddddddddddddddddddd");
insert into t1 values (30,1,"eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee");
insert into t1 values (40,2,"fffffffffffffffffffffffffffffffffffffffffff");
insert into t1 values (50,1,"ggggggggggggggggggggggggggggggggggggggggggg");
insert into t1 values (60,2,"hhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhh");
insert into t1 values (70,1,"iiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiii");
insert into t1 values (80,22,"jjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjj");
insert into t1 values (90,11,"kkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkk");
--echo ** Get ULL "hello" on thread 1
select get_lock("hello",10);
#connect (thread1, localhost, mysqltest,,); --echo ** connection thread2
connection thread1; #connect (thread2, localhost, mysqltest,,);
create table t1 (a int not null, b int not null); connection thread2;
insert into t1 values (1,1),(2,1),(3,1),(4,1); --echo ** Start transaction on thread 2
select get_lock("hello2",1000); begin;
#connect (thread2, localhost, mysqltest,,); --echo ** Update will cause a table scan.
connection thread2; --echo ** This will cause a hang on the first row where tipo=1 until the
begin; --echo ** blocking ULL is released.
send update t1 set b=10+get_lock(concat("hello",a),1000)*0 where send update t1 set eta=1+get_lock("hello",10)*0 where tipo=1;
a=2; sleep 1;
sleep 1;
connection thread1;
insert into t1 values (1,1);
select release_lock("hello2");
select * from t1;
connection thread2;
reap;
select * from t1;
send commit;
connection thread1;
sleep 1;
connection thread2;
reap;
connection default;
drop table t1;
# --echo ** connection thread1
# one UPDATE changing result set and SELECT ... FOR UPDATE connection thread1;
# --echo ** Start transaction on thread 1
#connect (thread1, localhost, mysqltest,,); begin;
connection thread1; --echo ** Update on t1 will cause a table scan which will be blocked because
create table t1(eta int(11) not null, tipo int(11), c varchar(255)); --echo ** the previously initiated table scan applied exclusive key locks on
insert into t1 values (7,7, "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"); --echo ** all primary keys.
insert into t1 values (8,8, "bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb"); --echo ** Not so if innodb_locks_unsafe_for_binlog is set. The locks that
insert into t1 values (10,1,"ccccccccccccccccccccccccccccccccccccccccccc"); --echo ** do not match the WHERE condition are released.
insert into t1 values (20,2,"ddddddddddddddddddddddddddddddddddddddddddd"); if ($keep_locks)
insert into t1 values (30,1,"eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee"); {
insert into t1 values (40,2,"fffffffffffffffffffffffffffffffffffffffffff"); --error ER_LOCK_WAIT_TIMEOUT
insert into t1 values (50,1,"ggggggggggggggggggggggggggggggggggggggggggg"); update t1 set tipo=1 where tipo=2;
insert into t1 values (60,2,"hhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhh"); }
insert into t1 values (70,1,"iiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiii"); if (!$keep_locks)
insert into t1 values (80,22,"jjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjj"); {
insert into t1 values (90,11,"kkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkk"); update t1 set tipo=1 where tipo=2;
select get_lock("hello",10); }
#connect (thread2, localhost, mysqltest,,); --echo ** Release ULL. This will release the next waiting ULL on thread 2.
connection thread2; select release_lock("hello");
begin; --echo ** The table should still be updated with updates for thread 1 only:
send select * from t1 where tipo=2 FOR UPDATE; select * from t1;
sleep 1;
connection thread1;
begin;
select release_lock("hello");
--error 1205
update t1 set tipo=1+get_lock("hello",10)*0 where tipo=2;
select * from t1;
connection thread2;
reap;
select * from t1;
send commit;
connection thread1;
commit;
connection thread2;
reap;
select * from t1;
connection thread1;
select * from t1;
connection default;
drop table t1;
# --echo ** connection thread2
# one UPDATE not changing result set and SELECT ... FOR UPDATE connection thread2;
# --echo ** Release the lock and collect result from thread 2:
#connect (thread1, localhost, mysqltest,,); reap;
connection thread1; select release_lock("hello");
create table t1(eta int(11) not null, tipo int(11), c varchar(255)); --echo ** Seen from thread 2 the table should have been updated on four
insert into t1 values (7,7, "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"); --echo ** places.
insert into t1 values (8,8, "bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb"); select * from t1;
insert into t1 values (10,1,"ccccccccccccccccccccccccccccccccccccccccccc"); commit;
insert into t1 values (20,2,"ddddddddddddddddddddddddddddddddddddddddddd");
insert into t1 values (30,1,"eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee");
insert into t1 values (40,2,"fffffffffffffffffffffffffffffffffffffffffff");
insert into t1 values (50,1,"ggggggggggggggggggggggggggggggggggggggggggg");
insert into t1 values (60,2,"hhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhh");
insert into t1 values (70,1,"iiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiii");
insert into t1 values (80,22,"jjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjj");
insert into t1 values (90,11,"kkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkk");
select get_lock("hello",10);
#connect (thread2, localhost, mysqltest,,);
connection thread2;
begin;
send select * from t1 where tipo=2 FOR UPDATE;
sleep 1;
connection thread1;
begin;
select release_lock("hello");
--error 1205
update t1 set tipo=11+get_lock("hello",10)*0 where tipo=22;
select * from t1;
connection thread2;
reap;
select * from t1;
send commit;
connection thread1;
commit;
connection thread2;
reap;
select * from t1;
connection thread1;
select * from t1;
connection default;
drop table t1;
# --echo ** connection thread1
# two SELECT ... FOR UPDATE connection thread1;
# --echo ** Thread 2 has committed but the result should remain the same for
#connect (thread1, localhost, mysqltest,,); --echo ** thread 1 (updated on three places):
connection thread1; select * from t1;
create table t1(eta int(11) not null, tipo int(11), c varchar(255)); commit;
insert into t1 values (7,7, "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"); --echo ** After a commit the table should be merged with the previous
insert into t1 values (8,8, "bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb"); --echo ** commit.
insert into t1 values (10,1,"ccccccccccccccccccccccccccccccccccccccccccc"); --echo ** This select should show both updates:
insert into t1 values (20,2,"ddddddddddddddddddddddddddddddddddddddddddd"); select * from t1;
insert into t1 values (30,1,"eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee");
insert into t1 values (40,2,"fffffffffffffffffffffffffffffffffffffffffff"); --echo ** connection thread2
insert into t1 values (50,1,"ggggggggggggggggggggggggggggggggggggggggggg"); connection thread2;
insert into t1 values (60,2,"hhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhh"); select * from t1;
insert into t1 values (70,1,"iiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiii");
insert into t1 values (80,22,"jjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjj"); --echo ** connection thread1
insert into t1 values (90,11,"kkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkk"); connection thread1;
select get_lock("hello",10); select * from t1;
#connect (thread2, localhost, mysqltest,,);
connection thread2; --echo ** connection default
begin;
send select * from t1 where tipo=2 FOR UPDATE;
sleep 1;
connection thread1;
begin;
select release_lock("hello");
--error 1205
select * from t1 where tipo=1 FOR UPDATE;
connection thread2;
reap;
select * from t1;
send commit;
connection thread1;
commit;
connection thread2;
reap;
select * from t1;
connection thread1;
select * from t1;
connection default; connection default;
drop table t1; drop table t1;
# --echo
# one UPDATE changing result set and DELETE --echo **
# --echo ** One UPDATE and one INSERT .... Monty's test
#connect (thread1, localhost, mysqltest,,); --echo **
connection thread1; --echo ** connection thread1
create table t1(eta int(11) not null, tipo int(11), c varchar(255)); #connect (thread1, localhost, mysqltest,,);
insert into t1 values (7,7, "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"); connection thread1;
insert into t1 values (8,8, "bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb"); --echo ** Set up table
insert into t1 values (10,1,"ccccccccccccccccccccccccccccccccccccccccccc"); eval SET SESSION STORAGE_ENGINE = $engine_type;
insert into t1 values (20,2,"ddddddddddddddddddddddddddddddddddddddddddd"); create table t1 (a int not null, b int not null);
insert into t1 values (30,1,"eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee"); insert into t1 values (1,1),(2,1),(3,1),(4,1);
insert into t1 values (40,2,"fffffffffffffffffffffffffffffffffffffffffff"); --echo ** Create ULL 'hello2'
insert into t1 values (50,1,"ggggggggggggggggggggggggggggggggggggggggggg"); select get_lock("hello2",10);
insert into t1 values (60,2,"hhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhh");
insert into t1 values (70,1,"iiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiii"); --echo ** connection thread2
insert into t1 values (80,22,"jjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjj"); #connect (thread2, localhost, mysqltest,,);
insert into t1 values (90,11,"kkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkk"); connection thread2;
select get_lock("hello",10); --echo ** Begin a new transaction on thread 2
#connect (thread2, localhost, mysqltest,,); begin;
connection thread2; --echo ** Update will create a table scan which creates a ULL where a=2;
begin; --echo ** this will hang waiting on thread 1.
send delete from t1 where tipo=2; send update t1 set b=10+get_lock(concat("hello",a),10)*0 where a=2;
sleep 1; sleep 1;
connection thread1;
begin; --echo ** connection thread1
select release_lock("hello"); connection thread1;
--error 1205 --echo ** Insert new values to t1 from thread 1; this created an implicit
update t1 set tipo=1+get_lock("hello",10)*0 where tipo=2; --echo ** commit since there are no on-going transactions.
select * from t1; insert into t1 values (1,1);
connection thread2; --echo ** Release the ULL (thread 2 updates will finish).
reap; select release_lock("hello2");
select * from t1; --echo ** ..but thread 1 will still see t1 as if nothing has happend:
send commit; select * from t1;
connection thread1;
commit; --echo ** connection thread2
connection thread2; connection thread2;
reap; --echo ** Collect results from thread 2 and release the lock.
select * from t1; reap;
connection thread1; select release_lock("hello2");
select * from t1; --echo ** The table should look like the original+updates for thread 2,
--echo ** and consist of new rows:
select * from t1;
--echo ** Commit changes from thread 2
commit;
--echo ** connection default
connection default; connection default;
drop table t1; drop table t1;
# --echo
# one UPDATE not changing result set and DELETE --echo **
# --echo ** one UPDATE changing result set and SELECT ... FOR UPDATE
#connect (thread1, localhost, mysqltest,,); --echo **
connection thread1; --echo ** connection thread1
create table t1(eta int(11) not null, tipo int(11), c varchar(255)); #connect (thread1, localhost, mysqltest,,);
insert into t1 values (7,7, "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"); connection thread1;
insert into t1 values (8,8, "bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb"); --echo ** Set up table
insert into t1 values (10,1,"ccccccccccccccccccccccccccccccccccccccccccc"); eval SET SESSION STORAGE_ENGINE = $engine_type;
insert into t1 values (20,2,"ddddddddddddddddddddddddddddddddddddddddddd"); create table t1(eta int(11) not null, tipo int(11), c varchar(255));
insert into t1 values (30,1,"eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee"); insert into t1 values (7,7, "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa");
insert into t1 values (40,2,"fffffffffffffffffffffffffffffffffffffffffff"); insert into t1 values (8,8, "bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb");
insert into t1 values (50,1,"ggggggggggggggggggggggggggggggggggggggggggg"); insert into t1 values (10,1,"ccccccccccccccccccccccccccccccccccccccccccc");
insert into t1 values (60,2,"hhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhh"); insert into t1 values (20,2,"ddddddddddddddddddddddddddddddddddddddddddd");
insert into t1 values (70,1,"iiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiii"); insert into t1 values (30,1,"eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee");
insert into t1 values (80,22,"jjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjj"); insert into t1 values (40,2,"fffffffffffffffffffffffffffffffffffffffffff");
insert into t1 values (90,11,"kkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkk"); insert into t1 values (50,1,"ggggggggggggggggggggggggggggggggggggggggggg");
select get_lock("hello",10); insert into t1 values (60,2,"hhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhh");
#connect (thread2, localhost, mysqltest,,); insert into t1 values (70,1,"iiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiii");
connection thread2; insert into t1 values (80,22,"jjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjj");
begin; insert into t1 values (90,11,"kkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkk");
send delete from t1 where tipo=2;
sleep 1; --echo ** connection thread2
connection thread1; #connect (thread2, localhost, mysqltest,,);
begin; connection thread2;
select release_lock("hello"); --echo ** Begin a new transaction on thread 2
update t1 set tipo=1+get_lock("hello",10)*0 where tipo=22; begin;
select * from t1; --echo ** Select a range for update.
connection thread2; select * from t1 where tipo=2 FOR UPDATE;
reap;
select * from t1; --echo ** connection thread1
send commit; connection thread1;
connection thread1; --echo ** Begin a new transaction on thread 1
commit; begin;
connection thread2; --echo ** Update the same range which is marked for update on thread 2; this
reap; --echo ** will hang because of row locks.
select * from t1; --error ER_LOCK_WAIT_TIMEOUT
connection thread1; update t1 set tipo=1 where tipo=2;
select * from t1; --echo ** After the update the table will be unmodified because the previous
--echo ** transaction failed and was rolled back.
select * from t1;
--echo ** connection thread2
connection thread2;
--echo ** The table should look unmodified from thread 2.
select * from t1;
--echo ** Sending a commit should release the row locks and enable
--echo ** thread 1 to complete the transaction.
commit;
--echo ** connection thread1
connection thread1;
--echo ** Commit on thread 1.
commit;
--echo ** connection thread2
connection thread2;
--echo ** The table should not have been changed.
select * from t1;
--echo ** connection thread1
connection thread1;
--echo ** Even on thread 1:
select * from t1;
--echo ** connection default
connection default; connection default;
sleep 1;
drop table t1; drop table t1;
--echo
--echo **
--echo ** one UPDATE not changing result set and SELECT ... FOR UPDATE
--echo **
--echo ** connection thread1
#connect (thread1, localhost, mysqltest,,);
connection thread1;
--echo ** Set up table
eval SET SESSION STORAGE_ENGINE = $engine_type;
create table t1(eta int(11) not null, tipo int(11), c varchar(255));
insert into t1 values (7,7, "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa");
insert into t1 values (8,8, "bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb");
insert into t1 values (10,1,"ccccccccccccccccccccccccccccccccccccccccccc");
insert into t1 values (20,2,"ddddddddddddddddddddddddddddddddddddddddddd");
insert into t1 values (30,1,"eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee");
insert into t1 values (40,2,"fffffffffffffffffffffffffffffffffffffffffff");
insert into t1 values (50,1,"ggggggggggggggggggggggggggggggggggggggggggg");
insert into t1 values (60,2,"hhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhh");
insert into t1 values (70,1,"iiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiii");
insert into t1 values (80,22,"jjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjj");
insert into t1 values (90,11,"kkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkk");
--echo ** connection thread2
#connect (thread2, localhost, mysqltest,,);
connection thread2;
--echo ** Starting new transaction on thread 2.
begin;
--echo ** Starting SELECT .. FOR UPDATE
select * from t1 where tipo=2 FOR UPDATE;
--echo ** connection thread1
connection thread1;
--echo
--echo ** Starting new transaction on thread 1
begin;
--echo ** Updating single row using a table scan. This will time out
--echo ** because of ongoing transaction on thread 1 holding lock on
--echo ** all primary keys in the scan.
--echo ** Not so if innodb_locks_unsafe_for_binlog is set. The locks that
--echo ** do not match the WHERE condition are released.
if ($keep_locks)
{
--error ER_LOCK_WAIT_TIMEOUT
update t1 set tipo=11 where tipo=22;
}
if (!$keep_locks)
{
update t1 set tipo=11 where tipo=22;
}
--echo ** After the time out the transaction is aborted; no rows should
--echo ** have changed.
select * from t1;
--echo ** connection thread2
connection thread2;
--echo ** The same thing should hold true for the transaction on
--echo ** thread 2
select * from t1;
send commit;
--echo ** connection thread1
connection thread1;
commit;
--echo ** connection thread2
connection thread2;
--echo ** Even after committing:
reap;
select * from t1;
--echo ** connection thread1
connection thread1;
select * from t1;
--echo ** connection default
connection default;
drop table t1;
--echo
--echo **
--echo ** two SELECT ... FOR UPDATE
--echo **
--echo ** connection thread1
#connect (thread1, localhost, mysqltest,,);
connection thread1;
--echo ** Set up table
eval SET SESSION STORAGE_ENGINE = $engine_type;
create table t1(eta int(11) not null, tipo int(11), c varchar(255));
insert into t1 values (7,7, "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa");
insert into t1 values (8,8, "bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb");
insert into t1 values (10,1,"ccccccccccccccccccccccccccccccccccccccccccc");
insert into t1 values (20,2,"ddddddddddddddddddddddddddddddddddddddddddd");
insert into t1 values (30,1,"eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee");
insert into t1 values (40,2,"fffffffffffffffffffffffffffffffffffffffffff");
insert into t1 values (50,1,"ggggggggggggggggggggggggggggggggggggggggggg");
insert into t1 values (60,2,"hhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhh");
insert into t1 values (70,1,"iiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiii");
insert into t1 values (80,22,"jjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjj");
insert into t1 values (90,11,"kkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkk");
--echo ** connection thread2
#connect (thread2, localhost, mysqltest,,);
connection thread2;
--echo ** Begin a new transaction on thread 2
begin;
select * from t1 where tipo=2 FOR UPDATE;
--echo ** connection thread1
connection thread1;
--echo ** Begin a new transaction on thread 1
begin;
--echo ** Selecting a range for update by table scan will be blocked
--echo ** because of on-going transaction on thread 2.
--error ER_LOCK_WAIT_TIMEOUT
select * from t1 where tipo=1 FOR UPDATE;
--echo ** connection thread2
connection thread2;
--echo ** Table will be unchanged and the select command will not be
--echo ** blocked:
select * from t1;
--echo ** Commit transacton on thread 2.
commit;
--echo ** connection thread1
connection thread1;
--echo ** Commit transaction on thread 1.
commit;
--echo ** connection thread2
connection thread2;
--echo ** Make sure table isn't blocked on thread 2:
select * from t1;
--echo ** connection thread1
connection thread1;
--echo ** Make sure table isn't blocked on thread 1:
select * from t1;
--echo ** connection default
connection default;
drop table t1;
--echo
--echo **
--echo ** one UPDATE changing result set and DELETE
--echo **
--echo ** connection thread1
#connect (thread1, localhost, mysqltest,,);
connection thread1;
--echo ** Set up table
eval SET SESSION STORAGE_ENGINE = $engine_type;
create table t1(eta int(11) not null, tipo int(11), c varchar(255));
insert into t1 values (7,7, "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa");
insert into t1 values (8,8, "bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb");
insert into t1 values (10,1,"ccccccccccccccccccccccccccccccccccccccccccc");
insert into t1 values (20,2,"ddddddddddddddddddddddddddddddddddddddddddd");
insert into t1 values (30,1,"eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee");
insert into t1 values (40,2,"fffffffffffffffffffffffffffffffffffffffffff");
insert into t1 values (50,1,"ggggggggggggggggggggggggggggggggggggggggggg");
insert into t1 values (60,2,"hhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhh");
insert into t1 values (70,1,"iiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiii");
insert into t1 values (80,22,"jjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjj");
insert into t1 values (90,11,"kkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkk");
--echo ** connection thread2
#connect (thread2, localhost, mysqltest,,);
connection thread2;
begin;
send delete from t1 where tipo=2;
sleep 1;
--echo ** connection thread1
connection thread1;
begin;
--error ER_LOCK_WAIT_TIMEOUT
update t1 set tipo=1 where tipo=2;
select * from t1;
--echo ** connection thread2
connection thread2;
reap;
select * from t1;
send commit;
--echo ** connection thread1
connection thread1;
commit;
--echo ** connection thread2
connection thread2;
reap;
select * from t1;
--echo ** connection thread1
connection thread1;
select * from t1;
--echo ** connection default
connection default;
drop table t1;
--echo
--echo **
--echo ** one UPDATE not changing result set and DELETE
--echo **
--echo ** connection thread1
#connect (thread1, localhost, mysqltest,,);
connection thread1;
--echo ** Set up table
eval SET SESSION STORAGE_ENGINE = $engine_type;
create table t1(eta int(11) not null, tipo int(11), c varchar(255));
insert into t1 values (7,7, "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa");
insert into t1 values (8,8, "bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb");
insert into t1 values (10,1,"ccccccccccccccccccccccccccccccccccccccccccc");
insert into t1 values (20,2,"ddddddddddddddddddddddddddddddddddddddddddd");
insert into t1 values (30,1,"eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee");
insert into t1 values (40,2,"fffffffffffffffffffffffffffffffffffffffffff");
insert into t1 values (50,1,"ggggggggggggggggggggggggggggggggggggggggggg");
insert into t1 values (60,2,"hhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhh");
insert into t1 values (70,1,"iiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiii");
insert into t1 values (80,22,"jjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjj");
insert into t1 values (90,11,"kkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkk");
--echo ** connection thread2
#connect (thread2, localhost, mysqltest,,);
connection thread2;
begin;
send delete from t1 where tipo=2;
sleep 1;
--echo ** connection thread1
connection thread1;
begin;
--echo ** Update on t1 will cause a table scan which will be blocked because
--echo ** the previously initiated table scan applied exclusive key locks on
--echo ** all primary keys.
--echo ** Not so if innodb_locks_unsafe_for_binlog is set. The locks that
--echo ** do not match the WHERE condition are released.
if ($keep_locks)
{
--error ER_LOCK_WAIT_TIMEOUT
update t1 set tipo=1 where tipo=22;
}
if (!$keep_locks)
{
update t1 set tipo=1 where tipo=22;
}
select * from t1;
--echo ** connection thread2
connection thread2;
reap;
select * from t1;
send commit;
--echo ** connection thread1
connection thread1;
commit;
--echo ** connection thread2
connection thread2;
reap;
select * from t1;
--echo ** connection thread1
connection thread1;
select * from t1;
--echo ** connection default
connection default;
drop table t1;
disconnect thread1; disconnect thread1;
disconnect thread2; disconnect thread2;

View file

@ -1,4 +1,4 @@
-- require r/have_big5.require -- require r/have_big5.require
disable_query_log; disable_query_log;
show collation like "big5_chinese_ci"; show collation like 'big5_chinese_ci';
enable_query_log; enable_query_log;

View file

@ -2,5 +2,5 @@
-- require r/have_binlog_format_mixed.require -- require r/have_binlog_format_mixed.require
disable_query_log; disable_query_log;
show variables like "binlog_format"; show variables like 'binlog_format';
enable_query_log; enable_query_log;

View file

@ -3,5 +3,5 @@
--require r/have_binlog_format_row.require --require r/have_binlog_format_row.require
--disable_query_log --disable_query_log
--replace_result MIXED ROW --replace_result MIXED ROW
show variables like "binlog_format"; show variables like 'binlog_format';
--enable_query_log --enable_query_log

View file

@ -4,5 +4,5 @@ source include/have_log_bin.inc;
--require r/have_binlog_format_statement.require --require r/have_binlog_format_statement.require
--disable_query_log --disable_query_log
--replace_result MIXED STATEMENT --replace_result MIXED STATEMENT
show variables like "binlog_format"; show variables like 'binlog_format';
--enable_query_log --enable_query_log

View file

@ -2,5 +2,5 @@
-- require r/have_binlog_format_row.require -- require r/have_binlog_format_row.require
disable_query_log; disable_query_log;
show variables like "binlog_format"; show variables like 'binlog_format';
enable_query_log; enable_query_log;

View file

@ -3,5 +3,5 @@
-- require r/have_binlog_format_statement.require -- require r/have_binlog_format_statement.require
--disable_query_log --disable_query_log
--replace_result ROW STATEMENT --replace_result ROW STATEMENT
show variables like "binlog_format"; show variables like 'binlog_format';
--enable_query_log --enable_query_log

View file

@ -2,5 +2,5 @@
-- require r/have_binlog_format_statement.require -- require r/have_binlog_format_statement.require
disable_query_log; disable_query_log;
show variables like "binlog_format"; show variables like 'binlog_format';
enable_query_log; enable_query_log;

View file

@ -3,5 +3,5 @@
# #
--require r/have_bug25714.require --require r/have_bug25714.require
disable_query_log; disable_query_log;
eval select LENGTH("$MYSQL_BUG25714") > 0 as "have_bug25714_exe"; eval select LENGTH('$MYSQL_BUG25714') > 0 as 'have_bug25714_exe';
enable_query_log; enable_query_log;

View file

@ -0,0 +1,4 @@
--require r/case_insensitive_file_system.require
--disable_query_log
show variables like "lower_case_file_system";
--enable_query_log

View file

@ -1,4 +1,4 @@
--require r/case_sensitive_file_system.require --require r/case_sensitive_file_system.require
--disable_query_log --disable_query_log
show variables like "lower_case_file_system"; show variables like 'lower_case_file_system';
--enable_query_log --enable_query_log

View file

@ -1,4 +1,4 @@
--require r/have_community_features.require --require r/have_community_features.require
--disable_query_log --disable_query_log
show variables like "have_community_features"; show variables like 'have_community_features';
--enable_query_log --enable_query_log

View file

@ -1,4 +1,4 @@
-- require r/have_compress.require -- require r/have_compress.require
disable_query_log; disable_query_log;
show variables like "have_compress"; show variables like 'have_compress';
enable_query_log; enable_query_log;

View file

@ -1,4 +1,4 @@
-- require r/have_cp1250_ch.require -- require r/have_cp1250_ch.require
disable_query_log; disable_query_log;
show collation like "cp1250_czech_cs"; show collation like 'cp1250_czech_cs';
enable_query_log; enable_query_log;

View file

@ -1,4 +1,4 @@
-- require r/have_cp932.require -- require r/have_cp932.require
disable_query_log; disable_query_log;
show collation like "cp932_japanese_ci"; show collation like 'cp932_japanese_ci';
enable_query_log; enable_query_log;

View file

@ -1,4 +1,4 @@
-- require r/have_crypt.require -- require r/have_crypt.require
disable_query_log; disable_query_log;
show variables like "have_crypt"; show variables like 'have_crypt';
enable_query_log; enable_query_log;

View file

@ -1,4 +1,4 @@
-- require r/have_debug.require -- require r/have_debug.require
disable_query_log; disable_query_log;
select (version() like "%debug%") as debug; select (version() like '%debug%') as debug;
enable_query_log; enable_query_log;

View file

@ -1,4 +1,4 @@
-- require r/have_eucjpms.require -- require r/have_eucjpms.require
disable_query_log; disable_query_log;
show collation like "eucjpms_japanese_ci"; show collation like 'eucjpms_japanese_ci';
enable_query_log; enable_query_log;

View file

@ -1,4 +1,4 @@
-- require r/have_euckr.require -- require r/have_euckr.require
disable_query_log; disable_query_log;
show collation like "euckr_korean_ci"; show collation like 'euckr_korean_ci';
enable_query_log; enable_query_log;

View file

@ -4,7 +4,7 @@
# #
--require r/have_dynamic_loading.require --require r/have_dynamic_loading.require
disable_query_log; disable_query_log;
show variables like "have_dynamic_loading"; show variables like 'have_dynamic_loading';
enable_query_log; enable_query_log;
# #
@ -12,5 +12,5 @@ enable_query_log;
# #
--require r/have_example_plugin.require --require r/have_example_plugin.require
disable_query_log; disable_query_log;
eval select LENGTH("$EXAMPLE_PLUGIN") > 0 as "have_example_plugin"; eval select LENGTH('$EXAMPLE_PLUGIN') > 0 as 'have_example_plugin';
enable_query_log; enable_query_log;

View file

@ -1,4 +1,4 @@
-- require r/have_gb2312.require -- require r/have_gb2312.require
disable_query_log; disable_query_log;
show collation like "gb2312_chinese_ci"; show collation like 'gb2312_chinese_ci';
enable_query_log; enable_query_log;

View file

@ -1,4 +1,4 @@
-- require r/have_gbk.require -- require r/have_gbk.require
disable_query_log; disable_query_log;
show collation like "gbk_chinese_ci"; show collation like 'gbk_chinese_ci';
enable_query_log; enable_query_log;

View file

@ -1,4 +1,4 @@
--require r/have_geometry.require --require r/have_geometry.require
--disable_query_log --disable_query_log
show variables like "have_geometry"; show variables like 'have_geometry';
--enable_query_log --enable_query_log

View file

@ -1,4 +1,4 @@
-- require r/have_latin2_ch.require -- require r/have_latin2_ch.require
disable_query_log; disable_query_log;
show collation like "latin2_czech_cs"; show collation like 'latin2_czech_cs';
enable_query_log; enable_query_log;

View file

@ -1,4 +1,4 @@
-- require r/have_log_bin.require -- require r/have_log_bin.require
disable_query_log; disable_query_log;
show variables like "log_bin"; show variables like 'log_bin';
enable_query_log; enable_query_log;

View file

@ -1,4 +1,4 @@
--require r/lowercase0.require --require r/lowercase0.require
--disable_query_log --disable_query_log
show variables like "lower_case_%"; show variables like "lower_case_table_names";
--enable_query_log --enable_query_log

View file

@ -0,0 +1,4 @@
--require r/lowercase2.require
--disable_query_log
show variables like 'lower_case_table_names';
--enable_query_log

View file

@ -1,4 +1,4 @@
--require r/have_ndbapi_examples.require --require r/have_ndbapi_examples.require
disable_query_log; disable_query_log;
eval select LENGTH("$MY_NDB_EXAMPLES_BINARY") > 0 as "have_ndb_example"; eval select LENGTH('$MY_NDB_EXAMPLES_BINARY') > 0 as 'have_ndb_example';
enable_query_log; enable_query_log;

View file

@ -1,5 +1,5 @@
-- require r/have_outfile.require -- require r/have_outfile.require
disable_query_log; disable_query_log;
select load_file(concat(@tmpdir,"/outfile.test")); select load_file(concat(@tmpdir,'/outfile.test'));
--remove_file $MYSQLTEST_VARDIR/tmp/outfile.test --remove_file $MYSQLTEST_VARDIR/tmp/outfile.test
enable_query_log; enable_query_log;

View file

@ -1,4 +1,4 @@
-- require r/have_partition.require -- require r/have_partition.require
disable_query_log; disable_query_log;
show variables like "have_partitioning"; show variables like 'have_partitioning';
enable_query_log; enable_query_log;

View file

@ -1,4 +1,4 @@
-- require r/have_query_cache.require -- require r/have_query_cache.require
disable_query_log; disable_query_log;
show variables like "have_query_cache"; show variables like 'have_query_cache';
enable_query_log; enable_query_log;

View file

@ -1,4 +1,4 @@
-- require r/have_sjis.require -- require r/have_sjis.require
disable_query_log; disable_query_log;
show collation like "sjis_japanese_ci"; show collation like 'sjis_japanese_ci';
enable_query_log; enable_query_log;

View file

@ -1,4 +1,4 @@
-- require r/have_ssl.require -- require r/have_ssl.require
disable_query_log; disable_query_log;
show variables like "have_ssl"; show variables like 'have_ssl';
enable_query_log; enable_query_log;

View file

@ -6,5 +6,5 @@
-- require r/have_symlink.require -- require r/have_symlink.require
disable_query_log; disable_query_log;
show variables like "have_symlink"; show variables like 'have_symlink';
enable_query_log; enable_query_log;

View file

@ -1,4 +1,4 @@
-- require r/have_tis620.require -- require r/have_tis620.require
disable_query_log; disable_query_log;
show collation like "tis620_thai_ci"; show collation like 'tis620_thai_ci';
enable_query_log; enable_query_log;

View file

@ -1,4 +1,4 @@
-- require r/have_ucs2.require -- require r/have_ucs2.require
disable_query_log; disable_query_log;
show collation like "ucs2_general_ci"; show collation like 'ucs2_general_ci';
enable_query_log; enable_query_log;

View file

@ -4,7 +4,7 @@
# #
--require r/have_dynamic_loading.require --require r/have_dynamic_loading.require
disable_query_log; disable_query_log;
show variables like "have_dynamic_loading"; show variables like 'have_dynamic_loading';
enable_query_log; enable_query_log;
# #
@ -12,5 +12,5 @@ enable_query_log;
# #
--require r/have_udf_example.require --require r/have_udf_example.require
disable_query_log; disable_query_log;
eval select LENGTH("$UDF_EXAMPLE_LIB") > 0 as "have_udf_example_lib"; eval select LENGTH('$UDF_EXAMPLE_LIB') > 0 as 'have_udf_example_lib';
enable_query_log; enable_query_log;

View file

@ -1,4 +1,4 @@
-- require r/have_ujis.require -- require r/have_ujis.require
disable_query_log; disable_query_log;
show collation like "ujis_japanese_ci"; show collation like 'ujis_japanese_ci';
enable_query_log; enable_query_log;

View file

@ -1103,6 +1103,24 @@ set @my_innodb_commit_concurrency=@@global.innodb_commit_concurrency;
set global innodb_commit_concurrency=0; set global innodb_commit_concurrency=0;
set global innodb_commit_concurrency=@my_innodb_commit_concurrency; set global innodb_commit_concurrency=@my_innodb_commit_concurrency;
#
# Bug #37830: ORDER BY ASC/DESC - no difference
#
CREATE TABLE t1 (a int, b int, c int, PRIMARY KEY (a), KEY t1_b (b))
ENGINE=InnoDB;
INSERT INTO t1 (a,b,c) VALUES (1,1,1), (2,1,1), (3,1,1), (4,1,1);
INSERT INTO t1 (a,b,c) SELECT a+4,b,c FROM t1;
# should be range access
EXPLAIN SELECT a, b, c FROM t1 WHERE b = 1 ORDER BY a DESC LIMIT 5;
# should produce '8 7 6 5 4' for a
SELECT a, b, c FROM t1 WHERE b = 1 ORDER BY a DESC LIMIT 5;
DROP TABLE t1;
--echo End of 5.0 tests --echo End of 5.0 tests
# Fix for BUG#19243 "wrong LAST_INSERT_ID() after ON DUPLICATE KEY # Fix for BUG#19243 "wrong LAST_INSERT_ID() after ON DUPLICATE KEY

File diff suppressed because it is too large Load diff

View file

@ -0,0 +1,25 @@
# include/ps_ddl_1.inc
#
# Auxiliary script to be used in ps_ddl.test
#
prepare stmt_sf from 'select f_12093();';
prepare stmt_sp from 'call p_12093(f_12093())';
execute stmt_sf;
execute stmt_sp;
connection con1;
eval $my_drop;
#
connection default;
--echo # XXX: used to be a bug
execute stmt_sf;
--echo # XXX: used to be a bug
execute stmt_sp;
#
--echo # XXX: used to be a bug
execute stmt_sf;
--echo # XXX: used to be a bug
execute stmt_sp;
connection default;

View file

@ -4,7 +4,7 @@ if (!$binlog_start)
{ {
let $binlog_start=106; let $binlog_start=106;
} }
--replace_result $binlog_start <binlog_start> --replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR $binlog_start <binlog_start>
--replace_column 2 # 4 # 5 # --replace_column 2 # 4 # 5 #
--replace_regex /\/\* xid=.* \*\//\/* XID *\// /table_id: [0-9]+/table_id: #/ /file_id=[0-9]+/file_id=#/ --replace_regex /\/\* xid=.* \*\//\/* XID *\// /table_id: [0-9]+/table_id: #/ /file_id=[0-9]+/file_id=#/ /block_len=[0-9]+/block_len=#/
--eval show binlog events from $binlog_start --eval show binlog events from $binlog_start

View file

@ -0,0 +1,59 @@
# include/wait_condition.inc
#
# SUMMARY
#
# Waits until the passed statement returns true, or the operation
# times out.
#
# USAGE
#
# let $wait_condition=
# SELECT c = 3 FROM t;
# --source include/wait_condition.inc
#
# OR
#
# let $wait_timeout= 60; # Override default 30 seconds with 60.
# let $wait_condition=
# SELECT c = 3 FROM t;
# --source include/wait_condition.inc
# --echo Executed the test condition $wait_condition_reps times
#
# EXAMPLE
# events_bugs.test, events_time_zone.test
#
--disable_query_log
let $wait_counter= 300;
if ($wait_timeout)
{
let $wait_counter= `SELECT $wait_timeout * 10`;
}
# Reset $wait_timeout so that its value won't be used on subsequent
# calls, and default will be used instead.
let $wait_timeout= 0;
# Keep track of how many times the wait condition is tested
# This is used by some tests (e.g., main.status)
let $wait_condition_reps= 0;
while ($wait_counter)
{
let $success= `$wait_condition`;
inc $wait_condition_reps;
if ($success)
{
let $wait_counter= 0;
}
if (!$success)
{
real_sleep 0.1;
dec $wait_counter;
}
}
if (!$success)
{
echo Timeout in wait_condition.inc for $wait_condition;
}
--enable_query_log

View file

@ -327,7 +327,6 @@ sub mtr_report_stats ($) {
/Sort aborted/ or /Sort aborted/ or
/Time-out in NDB/ or /Time-out in NDB/ or
/One can only use the --user.*root/ or /One can only use the --user.*root/ or
/Setting lower_case_table_names=2/ or
/Table:.* on (delete|rename)/ or /Table:.* on (delete|rename)/ or
/You have an error in your SQL syntax/ or /You have an error in your SQL syntax/ or
/deprecated/ or /deprecated/ or
@ -402,7 +401,18 @@ sub mtr_report_stats ($) {
)) or )) or
# Test case for Bug#31590 produces the following error: # Test case for Bug#31590 produces the following error:
/Out of sort memory; increase server sort buffer size/ /Out of sort memory; increase server sort buffer size/ or
# Bug#35161, test of auto repair --myisam-recover
/able.*_will_crash/ or
# lowercase_table3 using case sensitive option on
# case insensitive filesystem (InnoDB error).
/Cannot find or open table test\/BUG29839 from/ or
# When trying to set lower_case_table_names = 2
# on a case sensitive file system. Bug#37402.
/lower_case_table_names was set to 2, even though your the file system '.*' is case sensitive. Now setting lower_case_table_names to 0 to avoid future problems./
) )
{ {
next; # Skip these lines next; # Skip these lines

View file

@ -251,7 +251,7 @@ our $opt_sleep;
our $opt_testcase_timeout; our $opt_testcase_timeout;
our $opt_suite_timeout; our $opt_suite_timeout;
my $default_testcase_timeout= 15; # 15 min max my $default_testcase_timeout= 15; # 15 min max
my $default_suite_timeout= 180; # 3 hours max my $default_suite_timeout= 300; # 5 hours max
our $opt_start_and_exit; our $opt_start_and_exit;
our $opt_start_dirty; our $opt_start_dirty;
@ -1579,13 +1579,15 @@ sub executable_setup_ndb () {
$exe_ndbd= $exe_ndbd=
mtr_exe_maybe_exists("$ndb_path/src/kernel/ndbd", mtr_exe_maybe_exists("$ndb_path/src/kernel/ndbd",
"$ndb_path/ndbd"); "$ndb_path/ndbd",
"$glob_basedir/libexec/ndbd");
$exe_ndb_mgm= $exe_ndb_mgm=
mtr_exe_maybe_exists("$ndb_path/src/mgmclient/ndb_mgm", mtr_exe_maybe_exists("$ndb_path/src/mgmclient/ndb_mgm",
"$ndb_path/ndb_mgm"); "$ndb_path/ndb_mgm");
$exe_ndb_mgmd= $exe_ndb_mgmd=
mtr_exe_maybe_exists("$ndb_path/src/mgmsrv/ndb_mgmd", mtr_exe_maybe_exists("$ndb_path/src/mgmsrv/ndb_mgmd",
"$ndb_path/ndb_mgmd"); "$ndb_path/ndb_mgmd",
"$glob_basedir/libexec/ndb_mgmd");
$exe_ndb_waiter= $exe_ndb_waiter=
mtr_exe_maybe_exists("$ndb_path/tools/ndb_waiter", mtr_exe_maybe_exists("$ndb_path/tools/ndb_waiter",
"$ndb_path/ndb_waiter"); "$ndb_path/ndb_waiter");
@ -1682,7 +1684,8 @@ sub executable_setup () {
# Look for mysql_fix_privilege_tables.sql script # Look for mysql_fix_privilege_tables.sql script
$file_mysql_fix_privilege_tables= $file_mysql_fix_privilege_tables=
mtr_file_exists("$glob_basedir/scripts/mysql_fix_privilege_tables.sql", mtr_file_exists("$glob_basedir/scripts/mysql_fix_privilege_tables.sql",
"$glob_basedir/share/mysql_fix_privilege_tables.sql"); "$glob_basedir/share/mysql_fix_privilege_tables.sql",
"$glob_basedir/share/mysql/mysql_fix_privilege_tables.sql");
if ( ! $opt_skip_ndbcluster and executable_setup_ndb()) if ( ! $opt_skip_ndbcluster and executable_setup_ndb())
{ {

View file

@ -0,0 +1,2 @@
Variable_name Value
lower_case_file_system ON

View file

@ -1,5 +1,6 @@
set @old_concurrent_insert= @@global.concurrent_insert; set @old_concurrent_insert= @@global.concurrent_insert;
set @@global.concurrent_insert= 0; set @@global.concurrent_insert= 0;
drop table if exists t1;
create table t1 ( create table t1 (
`a&b` int, `a&b` int,
`a<b` int, `a<b` int,

View file

@ -45,7 +45,7 @@ ERROR 42000: You have an error in your SQL syntax; check the manual that corresp
prepare bar from "DELETE FROM table_28779 WHERE a = 7 OR 1=1/*! AND 2=2;"; prepare bar from "DELETE FROM table_28779 WHERE a = 7 OR 1=1/*! AND 2=2;";
ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '' at line 1 ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '' at line 1
prepare bar from "DELETE FROM table_28779 WHERE a = 7 OR 1=1/*! AND 2=2;*"; prepare bar from "DELETE FROM table_28779 WHERE a = 7 OR 1=1/*! AND 2=2;*";
ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ';*' at line 1 ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '*' at line 1
prepare bar from "DELETE FROM table_28779 WHERE a = 7 OR 1=1/*!98765' AND b = 'bar';"; prepare bar from "DELETE FROM table_28779 WHERE a = 7 OR 1=1/*!98765' AND b = 'bar';";
ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '/*!98765' AND b = 'bar'' at line 1 ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '/*!98765' AND b = 'bar'' at line 1
prepare bar from "DELETE FROM table_28779 WHERE a = 7 OR 1=1/*!98765' AND b = 'bar';*"; prepare bar from "DELETE FROM table_28779 WHERE a = 7 OR 1=1/*!98765' AND b = 'bar';*";

View file

@ -0,0 +1,803 @@
SET GLOBAL TRANSACTION ISOLATION LEVEL REPEATABLE READ;
SELECT @@global.tx_isolation;
@@global.tx_isolation
REPEATABLE-READ
SELECT @@global.innodb_locks_unsafe_for_binlog;
@@global.innodb_locks_unsafe_for_binlog
0
# keep_locks == 1
GRANT USAGE ON test.* TO mysqltest@localhost;
DO release_lock("hello");
DO release_lock("hello2");
drop table if exists t1;
**
** two UPDATE's running and both changing distinct result sets
**
** connection thread1
** Set up table
SET SESSION STORAGE_ENGINE = InnoDB;
create table t1(eta int(11) not null, tipo int(11), c varchar(255));
insert into t1 values (7,7, "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa");
insert into t1 values (8,8, "bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb");
insert into t1 values (10,1,"ccccccccccccccccccccccccccccccccccccccccccc");
insert into t1 values (20,2,"ddddddddddddddddddddddddddddddddddddddddddd");
insert into t1 values (30,1,"eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee");
insert into t1 values (40,2,"fffffffffffffffffffffffffffffffffffffffffff");
insert into t1 values (50,1,"ggggggggggggggggggggggggggggggggggggggggggg");
insert into t1 values (60,2,"hhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhh");
insert into t1 values (70,1,"iiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiii");
insert into t1 values (80,22,"jjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjj");
insert into t1 values (90,11,"kkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkk");
** Get user level lock (ULL) for thread 1
select get_lock("hello",10);
get_lock("hello",10)
1
** connection thread2
** Start transaction for thread 2
begin;
** Update will cause a table scan and a new ULL will
** be created and blocked on the first row where tipo=11.
update t1 set eta=1+get_lock("hello",10)*0 where tipo=11;
** connection thread1
** Start new transaction for thread 1
begin;
** Update on t1 will cause a table scan which will be blocked because
** the previously initiated table scan applied exclusive key locks on
** all primary keys.
** Not so if innodb_locks_unsafe_for_binlog is set. The locks that
** do not match the WHERE condition are released.
update t1 set eta=2 where tipo=22;
ERROR HY000: Lock wait timeout exceeded; try restarting transaction
** Release user level name lock from thread 1. This will cause the ULL
** on thread 2 to end its wait.
select release_lock("hello");
release_lock("hello")
1
** Table is now updated with a new eta on tipo=22 for thread 1.
select * from t1;
eta tipo c
7 7 aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
8 8 bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb
10 1 ccccccccccccccccccccccccccccccccccccccccccc
20 2 ddddddddddddddddddddddddddddddddddddddddddd
30 1 eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee
40 2 fffffffffffffffffffffffffffffffffffffffffff
50 1 ggggggggggggggggggggggggggggggggggggggggggg
60 2 hhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhh
70 1 iiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiii
80 22 jjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjj
90 11 kkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkk
** connection thread2
** Release the lock and collect result from update on thread 2
select release_lock("hello");
release_lock("hello")
1
** Table should have eta updates where tipo=11 but updates made by
** thread 1 shouldn't be visible yet.
select * from t1;
eta tipo c
7 7 aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
8 8 bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb
10 1 ccccccccccccccccccccccccccccccccccccccccccc
20 2 ddddddddddddddddddddddddddddddddddddddddddd
30 1 eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee
40 2 fffffffffffffffffffffffffffffffffffffffffff
50 1 ggggggggggggggggggggggggggggggggggggggggggg
60 2 hhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhh
70 1 iiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiii
80 22 jjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjj
1 11 kkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkk
** Sending commit on thread 2.
commit;
** connection thread1
** Make sure table reads didn't change yet on thread 1.
select * from t1;
eta tipo c
7 7 aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
8 8 bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb
10 1 ccccccccccccccccccccccccccccccccccccccccccc
20 2 ddddddddddddddddddddddddddddddddddddddddddd
30 1 eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee
40 2 fffffffffffffffffffffffffffffffffffffffffff
50 1 ggggggggggggggggggggggggggggggggggggggggggg
60 2 hhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhh
70 1 iiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiii
80 22 jjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjj
90 11 kkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkk
** And send final commit on thread 1.
commit;
** Table should now be updated by both updates in the order of
** thread 1,2.
select * from t1;
eta tipo c
7 7 aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
8 8 bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb
10 1 ccccccccccccccccccccccccccccccccccccccccccc
20 2 ddddddddddddddddddddddddddddddddddddddddddd
30 1 eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee
40 2 fffffffffffffffffffffffffffffffffffffffffff
50 1 ggggggggggggggggggggggggggggggggggggggggggg
60 2 hhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhh
70 1 iiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiii
80 22 jjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjj
1 11 kkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkk
** connection thread2
** Make sure the output is similar for t1.
select * from t1;
eta tipo c
7 7 aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
8 8 bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb
10 1 ccccccccccccccccccccccccccccccccccccccccccc
20 2 ddddddddddddddddddddddddddddddddddddddddddd
30 1 eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee
40 2 fffffffffffffffffffffffffffffffffffffffffff
50 1 ggggggggggggggggggggggggggggggggggggggggggg
60 2 hhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhh
70 1 iiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiii
80 22 jjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjj
1 11 kkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkk
** connection thread1
select * from t1;
eta tipo c
7 7 aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
8 8 bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb
10 1 ccccccccccccccccccccccccccccccccccccccccccc
20 2 ddddddddddddddddddddddddddddddddddddddddddd
30 1 eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee
40 2 fffffffffffffffffffffffffffffffffffffffffff
50 1 ggggggggggggggggggggggggggggggggggggggggggg
60 2 hhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhh
70 1 iiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiii
80 22 jjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjj
1 11 kkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkk
** connection default
drop table t1;
**
** two UPDATE's running and one changing result set
**
** connection thread1
** Set up table
SET SESSION STORAGE_ENGINE = InnoDB;
create table t1(eta int(11) not null, tipo int(11), c varchar(255));
insert into t1 values (7,7, "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa");
insert into t1 values (8,8, "bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb");
insert into t1 values (10,1,"ccccccccccccccccccccccccccccccccccccccccccc");
insert into t1 values (20,2,"ddddddddddddddddddddddddddddddddddddddddddd");
insert into t1 values (30,1,"eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee");
insert into t1 values (40,2,"fffffffffffffffffffffffffffffffffffffffffff");
insert into t1 values (50,1,"ggggggggggggggggggggggggggggggggggggggggggg");
insert into t1 values (60,2,"hhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhh");
insert into t1 values (70,1,"iiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiii");
insert into t1 values (80,22,"jjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjj");
insert into t1 values (90,11,"kkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkk");
** Get ULL "hello" on thread 1
select get_lock("hello",10);
get_lock("hello",10)
1
** connection thread2
** Start transaction on thread 2
begin;
** Update will cause a table scan.
** This will cause a hang on the first row where tipo=1 until the
** blocking ULL is released.
update t1 set eta=1+get_lock("hello",10)*0 where tipo=1;
** connection thread1
** Start transaction on thread 1
begin;
** Update on t1 will cause a table scan which will be blocked because
** the previously initiated table scan applied exclusive key locks on
** all primary keys.
** Not so if innodb_locks_unsafe_for_binlog is set. The locks that
** do not match the WHERE condition are released.
update t1 set tipo=1 where tipo=2;
ERROR HY000: Lock wait timeout exceeded; try restarting transaction
** Release ULL. This will release the next waiting ULL on thread 2.
select release_lock("hello");
release_lock("hello")
1
** The table should still be updated with updates for thread 1 only:
select * from t1;
eta tipo c
7 7 aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
8 8 bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb
10 1 ccccccccccccccccccccccccccccccccccccccccccc
20 2 ddddddddddddddddddddddddddddddddddddddddddd
30 1 eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee
40 2 fffffffffffffffffffffffffffffffffffffffffff
50 1 ggggggggggggggggggggggggggggggggggggggggggg
60 2 hhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhh
70 1 iiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiii
80 22 jjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjj
90 11 kkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkk
** connection thread2
** Release the lock and collect result from thread 2:
select release_lock("hello");
release_lock("hello")
1
** Seen from thread 2 the table should have been updated on four
** places.
select * from t1;
eta tipo c
7 7 aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
8 8 bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb
1 1 ccccccccccccccccccccccccccccccccccccccccccc
20 2 ddddddddddddddddddddddddddddddddddddddddddd
1 1 eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee
40 2 fffffffffffffffffffffffffffffffffffffffffff
1 1 ggggggggggggggggggggggggggggggggggggggggggg
60 2 hhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhh
1 1 iiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiii
80 22 jjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjj
90 11 kkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkk
commit;
** connection thread1
** Thread 2 has committed but the result should remain the same for
** thread 1 (updated on three places):
select * from t1;
eta tipo c
7 7 aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
8 8 bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb
10 1 ccccccccccccccccccccccccccccccccccccccccccc
20 2 ddddddddddddddddddddddddddddddddddddddddddd
30 1 eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee
40 2 fffffffffffffffffffffffffffffffffffffffffff
50 1 ggggggggggggggggggggggggggggggggggggggggggg
60 2 hhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhh
70 1 iiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiii
80 22 jjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjj
90 11 kkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkk
commit;
** After a commit the table should be merged with the previous
** commit.
** This select should show both updates:
select * from t1;
eta tipo c
7 7 aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
8 8 bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb
1 1 ccccccccccccccccccccccccccccccccccccccccccc
20 2 ddddddddddddddddddddddddddddddddddddddddddd
1 1 eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee
40 2 fffffffffffffffffffffffffffffffffffffffffff
1 1 ggggggggggggggggggggggggggggggggggggggggggg
60 2 hhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhh
1 1 iiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiii
80 22 jjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjj
90 11 kkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkk
** connection thread2
select * from t1;
eta tipo c
7 7 aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
8 8 bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb
1 1 ccccccccccccccccccccccccccccccccccccccccccc
20 2 ddddddddddddddddddddddddddddddddddddddddddd
1 1 eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee
40 2 fffffffffffffffffffffffffffffffffffffffffff
1 1 ggggggggggggggggggggggggggggggggggggggggggg
60 2 hhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhh
1 1 iiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiii
80 22 jjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjj
90 11 kkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkk
** connection thread1
select * from t1;
eta tipo c
7 7 aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
8 8 bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb
1 1 ccccccccccccccccccccccccccccccccccccccccccc
20 2 ddddddddddddddddddddddddddddddddddddddddddd
1 1 eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee
40 2 fffffffffffffffffffffffffffffffffffffffffff
1 1 ggggggggggggggggggggggggggggggggggggggggggg
60 2 hhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhh
1 1 iiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiii
80 22 jjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjj
90 11 kkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkk
** connection default
drop table t1;
**
** One UPDATE and one INSERT .... Monty's test
**
** connection thread1
** Set up table
SET SESSION STORAGE_ENGINE = InnoDB;
create table t1 (a int not null, b int not null);
insert into t1 values (1,1),(2,1),(3,1),(4,1);
** Create ULL 'hello2'
select get_lock("hello2",10);
get_lock("hello2",10)
1
** connection thread2
** Begin a new transaction on thread 2
begin;
** Update will create a table scan which creates a ULL where a=2;
** this will hang waiting on thread 1.
update t1 set b=10+get_lock(concat("hello",a),10)*0 where a=2;
** connection thread1
** Insert new values to t1 from thread 1; this created an implicit
** commit since there are no on-going transactions.
insert into t1 values (1,1);
** Release the ULL (thread 2 updates will finish).
select release_lock("hello2");
release_lock("hello2")
1
** ..but thread 1 will still see t1 as if nothing has happend:
select * from t1;
a b
1 1
2 1
3 1
4 1
1 1
** connection thread2
** Collect results from thread 2 and release the lock.
select release_lock("hello2");
release_lock("hello2")
1
** The table should look like the original+updates for thread 2,
** and consist of new rows:
select * from t1;
a b
1 1
2 10
3 1
4 1
1 1
** Commit changes from thread 2
commit;
** connection default
drop table t1;
**
** one UPDATE changing result set and SELECT ... FOR UPDATE
**
** connection thread1
** Set up table
SET SESSION STORAGE_ENGINE = InnoDB;
create table t1(eta int(11) not null, tipo int(11), c varchar(255));
insert into t1 values (7,7, "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa");
insert into t1 values (8,8, "bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb");
insert into t1 values (10,1,"ccccccccccccccccccccccccccccccccccccccccccc");
insert into t1 values (20,2,"ddddddddddddddddddddddddddddddddddddddddddd");
insert into t1 values (30,1,"eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee");
insert into t1 values (40,2,"fffffffffffffffffffffffffffffffffffffffffff");
insert into t1 values (50,1,"ggggggggggggggggggggggggggggggggggggggggggg");
insert into t1 values (60,2,"hhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhh");
insert into t1 values (70,1,"iiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiii");
insert into t1 values (80,22,"jjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjj");
insert into t1 values (90,11,"kkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkk");
** connection thread2
** Begin a new transaction on thread 2
begin;
** Select a range for update.
select * from t1 where tipo=2 FOR UPDATE;
eta tipo c
20 2 ddddddddddddddddddddddddddddddddddddddddddd
40 2 fffffffffffffffffffffffffffffffffffffffffff
60 2 hhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhh
** connection thread1
** Begin a new transaction on thread 1
begin;
** Update the same range which is marked for update on thread 2; this
** will hang because of row locks.
update t1 set tipo=1 where tipo=2;
ERROR HY000: Lock wait timeout exceeded; try restarting transaction
** After the update the table will be unmodified because the previous
** transaction failed and was rolled back.
select * from t1;
eta tipo c
7 7 aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
8 8 bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb
10 1 ccccccccccccccccccccccccccccccccccccccccccc
20 2 ddddddddddddddddddddddddddddddddddddddddddd
30 1 eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee
40 2 fffffffffffffffffffffffffffffffffffffffffff
50 1 ggggggggggggggggggggggggggggggggggggggggggg
60 2 hhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhh
70 1 iiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiii
80 22 jjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjj
90 11 kkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkk
** connection thread2
** The table should look unmodified from thread 2.
select * from t1;
eta tipo c
7 7 aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
8 8 bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb
10 1 ccccccccccccccccccccccccccccccccccccccccccc
20 2 ddddddddddddddddddddddddddddddddddddddddddd
30 1 eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee
40 2 fffffffffffffffffffffffffffffffffffffffffff
50 1 ggggggggggggggggggggggggggggggggggggggggggg
60 2 hhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhh
70 1 iiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiii
80 22 jjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjj
90 11 kkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkk
** Sending a commit should release the row locks and enable
** thread 1 to complete the transaction.
commit;
** connection thread1
** Commit on thread 1.
commit;
** connection thread2
** The table should not have been changed.
select * from t1;
eta tipo c
7 7 aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
8 8 bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb
10 1 ccccccccccccccccccccccccccccccccccccccccccc
20 2 ddddddddddddddddddddddddddddddddddddddddddd
30 1 eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee
40 2 fffffffffffffffffffffffffffffffffffffffffff
50 1 ggggggggggggggggggggggggggggggggggggggggggg
60 2 hhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhh
70 1 iiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiii
80 22 jjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjj
90 11 kkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkk
** connection thread1
** Even on thread 1:
select * from t1;
eta tipo c
7 7 aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
8 8 bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb
10 1 ccccccccccccccccccccccccccccccccccccccccccc
20 2 ddddddddddddddddddddddddddddddddddddddddddd
30 1 eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee
40 2 fffffffffffffffffffffffffffffffffffffffffff
50 1 ggggggggggggggggggggggggggggggggggggggggggg
60 2 hhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhh
70 1 iiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiii
80 22 jjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjj
90 11 kkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkk
** connection default
drop table t1;
**
** one UPDATE not changing result set and SELECT ... FOR UPDATE
**
** connection thread1
** Set up table
SET SESSION STORAGE_ENGINE = InnoDB;
create table t1(eta int(11) not null, tipo int(11), c varchar(255));
insert into t1 values (7,7, "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa");
insert into t1 values (8,8, "bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb");
insert into t1 values (10,1,"ccccccccccccccccccccccccccccccccccccccccccc");
insert into t1 values (20,2,"ddddddddddddddddddddddddddddddddddddddddddd");
insert into t1 values (30,1,"eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee");
insert into t1 values (40,2,"fffffffffffffffffffffffffffffffffffffffffff");
insert into t1 values (50,1,"ggggggggggggggggggggggggggggggggggggggggggg");
insert into t1 values (60,2,"hhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhh");
insert into t1 values (70,1,"iiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiii");
insert into t1 values (80,22,"jjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjj");
insert into t1 values (90,11,"kkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkk");
** connection thread2
** Starting new transaction on thread 2.
begin;
** Starting SELECT .. FOR UPDATE
select * from t1 where tipo=2 FOR UPDATE;
eta tipo c
20 2 ddddddddddddddddddddddddddddddddddddddddddd
40 2 fffffffffffffffffffffffffffffffffffffffffff
60 2 hhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhh
** connection thread1
** Starting new transaction on thread 1
begin;
** Updating single row using a table scan. This will time out
** because of ongoing transaction on thread 1 holding lock on
** all primary keys in the scan.
** Not so if innodb_locks_unsafe_for_binlog is set. The locks that
** do not match the WHERE condition are released.
update t1 set tipo=11 where tipo=22;
ERROR HY000: Lock wait timeout exceeded; try restarting transaction
** After the time out the transaction is aborted; no rows should
** have changed.
select * from t1;
eta tipo c
7 7 aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
8 8 bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb
10 1 ccccccccccccccccccccccccccccccccccccccccccc
20 2 ddddddddddddddddddddddddddddddddddddddddddd
30 1 eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee
40 2 fffffffffffffffffffffffffffffffffffffffffff
50 1 ggggggggggggggggggggggggggggggggggggggggggg
60 2 hhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhh
70 1 iiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiii
80 22 jjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjj
90 11 kkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkk
** connection thread2
** The same thing should hold true for the transaction on
** thread 2
select * from t1;
eta tipo c
7 7 aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
8 8 bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb
10 1 ccccccccccccccccccccccccccccccccccccccccccc
20 2 ddddddddddddddddddddddddddddddddddddddddddd
30 1 eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee
40 2 fffffffffffffffffffffffffffffffffffffffffff
50 1 ggggggggggggggggggggggggggggggggggggggggggg
60 2 hhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhh
70 1 iiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiii
80 22 jjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjj
90 11 kkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkk
commit;
** connection thread1
commit;
** connection thread2
** Even after committing:
select * from t1;
eta tipo c
7 7 aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
8 8 bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb
10 1 ccccccccccccccccccccccccccccccccccccccccccc
20 2 ddddddddddddddddddddddddddddddddddddddddddd
30 1 eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee
40 2 fffffffffffffffffffffffffffffffffffffffffff
50 1 ggggggggggggggggggggggggggggggggggggggggggg
60 2 hhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhh
70 1 iiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiii
80 22 jjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjj
90 11 kkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkk
** connection thread1
select * from t1;
eta tipo c
7 7 aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
8 8 bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb
10 1 ccccccccccccccccccccccccccccccccccccccccccc
20 2 ddddddddddddddddddddddddddddddddddddddddddd
30 1 eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee
40 2 fffffffffffffffffffffffffffffffffffffffffff
50 1 ggggggggggggggggggggggggggggggggggggggggggg
60 2 hhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhh
70 1 iiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiii
80 22 jjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjj
90 11 kkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkk
** connection default
drop table t1;
**
** two SELECT ... FOR UPDATE
**
** connection thread1
** Set up table
SET SESSION STORAGE_ENGINE = InnoDB;
create table t1(eta int(11) not null, tipo int(11), c varchar(255));
insert into t1 values (7,7, "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa");
insert into t1 values (8,8, "bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb");
insert into t1 values (10,1,"ccccccccccccccccccccccccccccccccccccccccccc");
insert into t1 values (20,2,"ddddddddddddddddddddddddddddddddddddddddddd");
insert into t1 values (30,1,"eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee");
insert into t1 values (40,2,"fffffffffffffffffffffffffffffffffffffffffff");
insert into t1 values (50,1,"ggggggggggggggggggggggggggggggggggggggggggg");
insert into t1 values (60,2,"hhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhh");
insert into t1 values (70,1,"iiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiii");
insert into t1 values (80,22,"jjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjj");
insert into t1 values (90,11,"kkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkk");
** connection thread2
** Begin a new transaction on thread 2
begin;
select * from t1 where tipo=2 FOR UPDATE;
eta tipo c
20 2 ddddddddddddddddddddddddddddddddddddddddddd
40 2 fffffffffffffffffffffffffffffffffffffffffff
60 2 hhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhh
** connection thread1
** Begin a new transaction on thread 1
begin;
** Selecting a range for update by table scan will be blocked
** because of on-going transaction on thread 2.
select * from t1 where tipo=1 FOR UPDATE;
ERROR HY000: Lock wait timeout exceeded; try restarting transaction
** connection thread2
** Table will be unchanged and the select command will not be
** blocked:
select * from t1;
eta tipo c
7 7 aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
8 8 bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb
10 1 ccccccccccccccccccccccccccccccccccccccccccc
20 2 ddddddddddddddddddddddddddddddddddddddddddd
30 1 eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee
40 2 fffffffffffffffffffffffffffffffffffffffffff
50 1 ggggggggggggggggggggggggggggggggggggggggggg
60 2 hhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhh
70 1 iiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiii
80 22 jjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjj
90 11 kkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkk
** Commit transacton on thread 2.
commit;
** connection thread1
** Commit transaction on thread 1.
commit;
** connection thread2
** Make sure table isn't blocked on thread 2:
select * from t1;
eta tipo c
7 7 aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
8 8 bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb
10 1 ccccccccccccccccccccccccccccccccccccccccccc
20 2 ddddddddddddddddddddddddddddddddddddddddddd
30 1 eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee
40 2 fffffffffffffffffffffffffffffffffffffffffff
50 1 ggggggggggggggggggggggggggggggggggggggggggg
60 2 hhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhh
70 1 iiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiii
80 22 jjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjj
90 11 kkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkk
** connection thread1
** Make sure table isn't blocked on thread 1:
select * from t1;
eta tipo c
7 7 aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
8 8 bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb
10 1 ccccccccccccccccccccccccccccccccccccccccccc
20 2 ddddddddddddddddddddddddddddddddddddddddddd
30 1 eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee
40 2 fffffffffffffffffffffffffffffffffffffffffff
50 1 ggggggggggggggggggggggggggggggggggggggggggg
60 2 hhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhh
70 1 iiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiii
80 22 jjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjj
90 11 kkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkk
** connection default
drop table t1;
**
** one UPDATE changing result set and DELETE
**
** connection thread1
** Set up table
SET SESSION STORAGE_ENGINE = InnoDB;
create table t1(eta int(11) not null, tipo int(11), c varchar(255));
insert into t1 values (7,7, "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa");
insert into t1 values (8,8, "bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb");
insert into t1 values (10,1,"ccccccccccccccccccccccccccccccccccccccccccc");
insert into t1 values (20,2,"ddddddddddddddddddddddddddddddddddddddddddd");
insert into t1 values (30,1,"eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee");
insert into t1 values (40,2,"fffffffffffffffffffffffffffffffffffffffffff");
insert into t1 values (50,1,"ggggggggggggggggggggggggggggggggggggggggggg");
insert into t1 values (60,2,"hhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhh");
insert into t1 values (70,1,"iiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiii");
insert into t1 values (80,22,"jjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjj");
insert into t1 values (90,11,"kkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkk");
** connection thread2
begin;
delete from t1 where tipo=2;
** connection thread1
begin;
update t1 set tipo=1 where tipo=2;
ERROR HY000: Lock wait timeout exceeded; try restarting transaction
select * from t1;
eta tipo c
7 7 aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
8 8 bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb
10 1 ccccccccccccccccccccccccccccccccccccccccccc
20 2 ddddddddddddddddddddddddddddddddddddddddddd
30 1 eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee
40 2 fffffffffffffffffffffffffffffffffffffffffff
50 1 ggggggggggggggggggggggggggggggggggggggggggg
60 2 hhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhh
70 1 iiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiii
80 22 jjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjj
90 11 kkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkk
** connection thread2
select * from t1;
eta tipo c
7 7 aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
8 8 bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb
10 1 ccccccccccccccccccccccccccccccccccccccccccc
30 1 eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee
50 1 ggggggggggggggggggggggggggggggggggggggggggg
70 1 iiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiii
80 22 jjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjj
90 11 kkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkk
commit;
** connection thread1
commit;
** connection thread2
select * from t1;
eta tipo c
7 7 aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
8 8 bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb
10 1 ccccccccccccccccccccccccccccccccccccccccccc
30 1 eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee
50 1 ggggggggggggggggggggggggggggggggggggggggggg
70 1 iiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiii
80 22 jjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjj
90 11 kkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkk
** connection thread1
select * from t1;
eta tipo c
7 7 aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
8 8 bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb
10 1 ccccccccccccccccccccccccccccccccccccccccccc
30 1 eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee
50 1 ggggggggggggggggggggggggggggggggggggggggggg
70 1 iiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiii
80 22 jjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjj
90 11 kkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkk
** connection default
drop table t1;
**
** one UPDATE not changing result set and DELETE
**
** connection thread1
** Set up table
SET SESSION STORAGE_ENGINE = InnoDB;
create table t1(eta int(11) not null, tipo int(11), c varchar(255));
insert into t1 values (7,7, "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa");
insert into t1 values (8,8, "bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb");
insert into t1 values (10,1,"ccccccccccccccccccccccccccccccccccccccccccc");
insert into t1 values (20,2,"ddddddddddddddddddddddddddddddddddddddddddd");
insert into t1 values (30,1,"eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee");
insert into t1 values (40,2,"fffffffffffffffffffffffffffffffffffffffffff");
insert into t1 values (50,1,"ggggggggggggggggggggggggggggggggggggggggggg");
insert into t1 values (60,2,"hhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhh");
insert into t1 values (70,1,"iiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiii");
insert into t1 values (80,22,"jjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjj");
insert into t1 values (90,11,"kkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkk");
** connection thread2
begin;
delete from t1 where tipo=2;
** connection thread1
begin;
** Update on t1 will cause a table scan which will be blocked because
** the previously initiated table scan applied exclusive key locks on
** all primary keys.
** Not so if innodb_locks_unsafe_for_binlog is set. The locks that
** do not match the WHERE condition are released.
update t1 set tipo=1 where tipo=22;
ERROR HY000: Lock wait timeout exceeded; try restarting transaction
select * from t1;
eta tipo c
7 7 aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
8 8 bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb
10 1 ccccccccccccccccccccccccccccccccccccccccccc
20 2 ddddddddddddddddddddddddddddddddddddddddddd
30 1 eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee
40 2 fffffffffffffffffffffffffffffffffffffffffff
50 1 ggggggggggggggggggggggggggggggggggggggggggg
60 2 hhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhh
70 1 iiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiii
80 22 jjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjj
90 11 kkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkk
** connection thread2
select * from t1;
eta tipo c
7 7 aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
8 8 bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb
10 1 ccccccccccccccccccccccccccccccccccccccccccc
30 1 eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee
50 1 ggggggggggggggggggggggggggggggggggggggggggg
70 1 iiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiii
80 22 jjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjj
90 11 kkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkk
commit;
** connection thread1
commit;
** connection thread2
select * from t1;
eta tipo c
7 7 aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
8 8 bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb
10 1 ccccccccccccccccccccccccccccccccccccccccccc
30 1 eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee
50 1 ggggggggggggggggggggggggggggggggggggggggggg
70 1 iiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiii
80 22 jjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjj
90 11 kkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkk
** connection thread1
select * from t1;
eta tipo c
7 7 aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
8 8 bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb
10 1 ccccccccccccccccccccccccccccccccccccccccccc
30 1 eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee
50 1 ggggggggggggggggggggggggggggggggggggggggggg
70 1 iiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiii
80 22 jjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjj
90 11 kkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkk
** connection default
drop table t1;

View file

@ -1,109 +1,22 @@
SET SESSION STORAGE_ENGINE = InnoDB; SET GLOBAL TRANSACTION ISOLATION LEVEL REPEATABLE READ;
SELECT @@global.tx_isolation;
@@global.tx_isolation
REPEATABLE-READ
SELECT @@global.innodb_locks_unsafe_for_binlog;
@@global.innodb_locks_unsafe_for_binlog
1
# keep_locks == 0
GRANT USAGE ON test.* TO mysqltest@localhost;
DO release_lock("hello");
DO release_lock("hello2");
drop table if exists t1; drop table if exists t1;
create table t1(eta int(11) not null, tipo int(11), c varchar(255));
**
** two UPDATE's running and both changing distinct result sets
**
** connection thread1
** Set up table
SET SESSION STORAGE_ENGINE = InnoDB; SET SESSION STORAGE_ENGINE = InnoDB;
insert into t1 values (7,7, "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa");
insert into t1 values (8,8, "bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb");
insert into t1 values (10,1,"ccccccccccccccccccccccccccccccccccccccccccc");
insert into t1 values (20,2,"ddddddddddddddddddddddddddddddddddddddddddd");
insert into t1 values (30,1,"eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee");
insert into t1 values (40,2,"fffffffffffffffffffffffffffffffffffffffffff");
insert into t1 values (50,1,"ggggggggggggggggggggggggggggggggggggggggggg");
insert into t1 values (60,2,"hhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhh");
insert into t1 values (70,1,"iiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiii");
insert into t1 values (80,22,"jjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjj");
insert into t1 values (90,11,"kkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkk");
select get_lock("hello",1);
get_lock("hello",1)
1
begin;
update t1 set eta=1+get_lock("hello",1)*0 where tipo=11;
begin;
update t1 set eta=2 where tipo=22;
select release_lock("hello");
release_lock("hello")
1
select * from t1;
eta tipo c
7 7 aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
8 8 bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb
10 1 ccccccccccccccccccccccccccccccccccccccccccc
20 2 ddddddddddddddddddddddddddddddddddddddddddd
30 1 eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee
40 2 fffffffffffffffffffffffffffffffffffffffffff
50 1 ggggggggggggggggggggggggggggggggggggggggggg
60 2 hhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhh
70 1 iiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiii
2 22 jjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjj
90 11 kkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkk
select * from t1;
eta tipo c
7 7 aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
8 8 bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb
10 1 ccccccccccccccccccccccccccccccccccccccccccc
20 2 ddddddddddddddddddddddddddddddddddddddddddd
30 1 eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee
40 2 fffffffffffffffffffffffffffffffffffffffffff
50 1 ggggggggggggggggggggggggggggggggggggggggggg
60 2 hhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhh
70 1 iiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiii
80 22 jjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjj
1 11 kkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkk
commit;
select * from t1;
eta tipo c
7 7 aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
8 8 bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb
10 1 ccccccccccccccccccccccccccccccccccccccccccc
20 2 ddddddddddddddddddddddddddddddddddddddddddd
30 1 eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee
40 2 fffffffffffffffffffffffffffffffffffffffffff
50 1 ggggggggggggggggggggggggggggggggggggggggggg
60 2 hhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhh
70 1 iiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiii
2 22 jjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjj
90 11 kkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkk
commit;
select * from t1;
eta tipo c
7 7 aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
8 8 bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb
10 1 ccccccccccccccccccccccccccccccccccccccccccc
20 2 ddddddddddddddddddddddddddddddddddddddddddd
30 1 eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee
40 2 fffffffffffffffffffffffffffffffffffffffffff
50 1 ggggggggggggggggggggggggggggggggggggggggggg
60 2 hhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhh
70 1 iiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiii
2 22 jjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjj
1 11 kkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkk
select * from t1;
eta tipo c
7 7 aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
8 8 bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb
10 1 ccccccccccccccccccccccccccccccccccccccccccc
20 2 ddddddddddddddddddddddddddddddddddddddddddd
30 1 eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee
40 2 fffffffffffffffffffffffffffffffffffffffffff
50 1 ggggggggggggggggggggggggggggggggggggggggggg
60 2 hhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhh
70 1 iiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiii
2 22 jjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjj
1 11 kkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkk
select * from t1;
eta tipo c
7 7 aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
8 8 bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb
10 1 ccccccccccccccccccccccccccccccccccccccccccc
20 2 ddddddddddddddddddddddddddddddddddddddddddd
30 1 eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee
40 2 fffffffffffffffffffffffffffffffffffffffffff
50 1 ggggggggggggggggggggggggggggggggggggggggggg
60 2 hhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhh
70 1 iiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiii
2 22 jjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjj
1 11 kkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkk
drop table t1;
create table t1(eta int(11) not null, tipo int(11), c varchar(255)); create table t1(eta int(11) not null, tipo int(11), c varchar(255));
insert into t1 values (7,7, "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"); insert into t1 values (7,7, "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa");
insert into t1 values (8,8, "bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb"); insert into t1 values (8,8, "bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb");
@ -116,16 +29,173 @@ insert into t1 values (60,2,"hhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhh");
insert into t1 values (70,1,"iiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiii"); insert into t1 values (70,1,"iiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiii");
insert into t1 values (80,22,"jjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjj"); insert into t1 values (80,22,"jjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjj");
insert into t1 values (90,11,"kkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkk"); insert into t1 values (90,11,"kkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkk");
** Get user level lock (ULL) for thread 1
select get_lock("hello",10); select get_lock("hello",10);
get_lock("hello",10) get_lock("hello",10)
0 1
** connection thread2
** Start transaction for thread 2
begin; begin;
update t1 set eta=1+get_lock("hello",10)*0 where tipo=1; ** Update will cause a table scan and a new ULL will
** be created and blocked on the first row where tipo=11.
update t1 set eta=1+get_lock("hello",10)*0 where tipo=11;
** connection thread1
** Start new transaction for thread 1
begin; begin;
update t1 set tipo=1 where tipo=2; ** Update on t1 will cause a table scan which will be blocked because
** the previously initiated table scan applied exclusive key locks on
** all primary keys.
** Not so if innodb_locks_unsafe_for_binlog is set. The locks that
** do not match the WHERE condition are released.
update t1 set eta=2 where tipo=22;
** Release user level name lock from thread 1. This will cause the ULL
** on thread 2 to end its wait.
select release_lock("hello"); select release_lock("hello");
release_lock("hello") release_lock("hello")
0 1
** Table is now updated with a new eta on tipo=22 for thread 1.
select * from t1;
eta tipo c
7 7 aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
8 8 bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb
10 1 ccccccccccccccccccccccccccccccccccccccccccc
20 2 ddddddddddddddddddddddddddddddddddddddddddd
30 1 eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee
40 2 fffffffffffffffffffffffffffffffffffffffffff
50 1 ggggggggggggggggggggggggggggggggggggggggggg
60 2 hhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhh
70 1 iiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiii
2 22 jjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjj
90 11 kkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkk
** connection thread2
** Release the lock and collect result from update on thread 2
select release_lock("hello");
release_lock("hello")
1
** Table should have eta updates where tipo=11 but updates made by
** thread 1 shouldn't be visible yet.
select * from t1;
eta tipo c
7 7 aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
8 8 bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb
10 1 ccccccccccccccccccccccccccccccccccccccccccc
20 2 ddddddddddddddddddddddddddddddddddddddddddd
30 1 eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee
40 2 fffffffffffffffffffffffffffffffffffffffffff
50 1 ggggggggggggggggggggggggggggggggggggggggggg
60 2 hhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhh
70 1 iiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiii
80 22 jjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjj
1 11 kkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkk
** Sending commit on thread 2.
commit;
** connection thread1
** Make sure table reads didn't change yet on thread 1.
select * from t1;
eta tipo c
7 7 aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
8 8 bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb
10 1 ccccccccccccccccccccccccccccccccccccccccccc
20 2 ddddddddddddddddddddddddddddddddddddddddddd
30 1 eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee
40 2 fffffffffffffffffffffffffffffffffffffffffff
50 1 ggggggggggggggggggggggggggggggggggggggggggg
60 2 hhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhh
70 1 iiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiii
2 22 jjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjj
90 11 kkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkk
** And send final commit on thread 1.
commit;
** Table should now be updated by both updates in the order of
** thread 1,2.
select * from t1;
eta tipo c
7 7 aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
8 8 bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb
10 1 ccccccccccccccccccccccccccccccccccccccccccc
20 2 ddddddddddddddddddddddddddddddddddddddddddd
30 1 eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee
40 2 fffffffffffffffffffffffffffffffffffffffffff
50 1 ggggggggggggggggggggggggggggggggggggggggggg
60 2 hhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhh
70 1 iiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiii
2 22 jjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjj
1 11 kkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkk
** connection thread2
** Make sure the output is similar for t1.
select * from t1;
eta tipo c
7 7 aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
8 8 bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb
10 1 ccccccccccccccccccccccccccccccccccccccccccc
20 2 ddddddddddddddddddddddddddddddddddddddddddd
30 1 eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee
40 2 fffffffffffffffffffffffffffffffffffffffffff
50 1 ggggggggggggggggggggggggggggggggggggggggggg
60 2 hhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhh
70 1 iiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiii
2 22 jjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjj
1 11 kkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkk
** connection thread1
select * from t1;
eta tipo c
7 7 aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
8 8 bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb
10 1 ccccccccccccccccccccccccccccccccccccccccccc
20 2 ddddddddddddddddddddddddddddddddddddddddddd
30 1 eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee
40 2 fffffffffffffffffffffffffffffffffffffffffff
50 1 ggggggggggggggggggggggggggggggggggggggggggg
60 2 hhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhh
70 1 iiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiii
2 22 jjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjj
1 11 kkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkk
** connection default
drop table t1;
**
** two UPDATE's running and one changing result set
**
** connection thread1
** Set up table
SET SESSION STORAGE_ENGINE = InnoDB;
create table t1(eta int(11) not null, tipo int(11), c varchar(255));
insert into t1 values (7,7, "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa");
insert into t1 values (8,8, "bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb");
insert into t1 values (10,1,"ccccccccccccccccccccccccccccccccccccccccccc");
insert into t1 values (20,2,"ddddddddddddddddddddddddddddddddddddddddddd");
insert into t1 values (30,1,"eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee");
insert into t1 values (40,2,"fffffffffffffffffffffffffffffffffffffffffff");
insert into t1 values (50,1,"ggggggggggggggggggggggggggggggggggggggggggg");
insert into t1 values (60,2,"hhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhh");
insert into t1 values (70,1,"iiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiii");
insert into t1 values (80,22,"jjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjj");
insert into t1 values (90,11,"kkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkk");
** Get ULL "hello" on thread 1
select get_lock("hello",10);
get_lock("hello",10)
1
** connection thread2
** Start transaction on thread 2
begin;
** Update will cause a table scan.
** This will cause a hang on the first row where tipo=1 until the
** blocking ULL is released.
update t1 set eta=1+get_lock("hello",10)*0 where tipo=1;
** connection thread1
** Start transaction on thread 1
begin;
** Update on t1 will cause a table scan which will be blocked because
** the previously initiated table scan applied exclusive key locks on
** all primary keys.
** Not so if innodb_locks_unsafe_for_binlog is set. The locks that
** do not match the WHERE condition are released.
update t1 set tipo=1 where tipo=2;
** Release ULL. This will release the next waiting ULL on thread 2.
select release_lock("hello");
release_lock("hello")
1
** The table should still be updated with updates for thread 1 only:
select * from t1; select * from t1;
eta tipo c eta tipo c
7 7 aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa 7 7 aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
@ -139,6 +209,13 @@ eta tipo c
70 1 iiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiii 70 1 iiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiii
80 22 jjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjj 80 22 jjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjj
90 11 kkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkk 90 11 kkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkk
** connection thread2
** Release the lock and collect result from thread 2:
select release_lock("hello");
release_lock("hello")
1
** Seen from thread 2 the table should have been updated on four
** places.
select * from t1; select * from t1;
eta tipo c eta tipo c
7 7 aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa 7 7 aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
@ -152,7 +229,10 @@ eta tipo c
1 1 iiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiii 1 1 iiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiii
80 22 jjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjj 80 22 jjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjj
90 11 kkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkk 90 11 kkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkk
commit; commit;
** connection thread1
** Thread 2 has committed but the result should remain the same for
** thread 1 (updated on three places):
select * from t1; select * from t1;
eta tipo c eta tipo c
7 7 aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa 7 7 aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
@ -167,19 +247,9 @@ eta tipo c
80 22 jjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjj 80 22 jjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjj
90 11 kkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkk 90 11 kkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkk
commit; commit;
select * from t1; ** After a commit the table should be merged with the previous
eta tipo c ** commit.
7 7 aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa ** This select should show both updates:
8 8 bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb
10 1 ccccccccccccccccccccccccccccccccccccccccccc
20 1 ddddddddddddddddddddddddddddddddddddddddddd
30 1 eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee
40 1 fffffffffffffffffffffffffffffffffffffffffff
50 1 ggggggggggggggggggggggggggggggggggggggggggg
60 1 hhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhh
70 1 iiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiii
80 22 jjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjj
90 11 kkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkk
select * from t1; select * from t1;
eta tipo c eta tipo c
7 7 aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa 7 7 aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
@ -193,6 +263,7 @@ eta tipo c
1 1 iiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiii 1 1 iiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiii
80 22 jjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjj 80 22 jjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjj
90 11 kkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkk 90 11 kkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkk
** connection thread2
select * from t1; select * from t1;
eta tipo c eta tipo c
7 7 aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa 7 7 aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
@ -206,19 +277,50 @@ eta tipo c
1 1 iiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiii 1 1 iiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiii
80 22 jjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjj 80 22 jjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjj
90 11 kkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkk 90 11 kkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkk
** connection thread1
select * from t1;
eta tipo c
7 7 aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
8 8 bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb
1 1 ccccccccccccccccccccccccccccccccccccccccccc
20 1 ddddddddddddddddddddddddddddddddddddddddddd
1 1 eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee
40 1 fffffffffffffffffffffffffffffffffffffffffff
1 1 ggggggggggggggggggggggggggggggggggggggggggg
60 1 hhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhh
1 1 iiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiii
80 22 jjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjj
90 11 kkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkk
** connection default
drop table t1; drop table t1;
**
** One UPDATE and one INSERT .... Monty's test
**
** connection thread1
** Set up table
SET SESSION STORAGE_ENGINE = InnoDB;
create table t1 (a int not null, b int not null); create table t1 (a int not null, b int not null);
insert into t1 values (1,1),(2,1),(3,1),(4,1); insert into t1 values (1,1),(2,1),(3,1),(4,1);
select get_lock("hello2",1000); ** Create ULL 'hello2'
get_lock("hello2",1000) select get_lock("hello2",10);
get_lock("hello2",10)
1 1
** connection thread2
** Begin a new transaction on thread 2
begin; begin;
update t1 set b=10+get_lock(concat("hello",a),1000)*0 where ** Update will create a table scan which creates a ULL where a=2;
a=2; ** this will hang waiting on thread 1.
update t1 set b=10+get_lock(concat("hello",a),10)*0 where a=2;
** connection thread1
** Insert new values to t1 from thread 1; this created an implicit
** commit since there are no on-going transactions.
insert into t1 values (1,1); insert into t1 values (1,1);
** Release the ULL (thread 2 updates will finish).
select release_lock("hello2"); select release_lock("hello2");
release_lock("hello2") release_lock("hello2")
1 1
** ..but thread 1 will still see t1 as if nothing has happend:
select * from t1; select * from t1;
a b a b
1 1 1 1
@ -226,6 +328,13 @@ a b
3 1 3 1
4 1 4 1
1 1 1 1
** connection thread2
** Collect results from thread 2 and release the lock.
select release_lock("hello2");
release_lock("hello2")
1
** The table should look like the original+updates for thread 2,
** and consist of new rows:
select * from t1; select * from t1;
a b a b
1 1 1 1
@ -233,90 +342,17 @@ a b
3 1 3 1
4 1 4 1
1 1 1 1
commit; ** Commit changes from thread 2
drop table t1;
create table t1(eta int(11) not null, tipo int(11), c varchar(255));
insert into t1 values (7,7, "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa");
insert into t1 values (8,8, "bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb");
insert into t1 values (10,1,"ccccccccccccccccccccccccccccccccccccccccccc");
insert into t1 values (20,2,"ddddddddddddddddddddddddddddddddddddddddddd");
insert into t1 values (30,1,"eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee");
insert into t1 values (40,2,"fffffffffffffffffffffffffffffffffffffffffff");
insert into t1 values (50,1,"ggggggggggggggggggggggggggggggggggggggggggg");
insert into t1 values (60,2,"hhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhh");
insert into t1 values (70,1,"iiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiii");
insert into t1 values (80,22,"jjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjj");
insert into t1 values (90,11,"kkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkk");
select get_lock("hello",10);
get_lock("hello",10)
1
begin;
select * from t1 where tipo=2 FOR UPDATE;
begin;
select release_lock("hello");
release_lock("hello")
1
update t1 set tipo=1+get_lock("hello",10)*0 where tipo=2;
ERROR HY000: Lock wait timeout exceeded; try restarting transaction
select * from t1;
eta tipo c
7 7 aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
8 8 bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb
10 1 ccccccccccccccccccccccccccccccccccccccccccc
20 2 ddddddddddddddddddddddddddddddddddddddddddd
30 1 eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee
40 2 fffffffffffffffffffffffffffffffffffffffffff
50 1 ggggggggggggggggggggggggggggggggggggggggggg
60 2 hhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhh
70 1 iiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiii
80 22 jjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjj
90 11 kkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkk
eta tipo c
20 2 ddddddddddddddddddddddddddddddddddddddddddd
40 2 fffffffffffffffffffffffffffffffffffffffffff
60 2 hhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhh
select * from t1;
eta tipo c
7 7 aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
8 8 bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb
10 1 ccccccccccccccccccccccccccccccccccccccccccc
20 2 ddddddddddddddddddddddddddddddddddddddddddd
30 1 eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee
40 2 fffffffffffffffffffffffffffffffffffffffffff
50 1 ggggggggggggggggggggggggggggggggggggggggggg
60 2 hhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhh
70 1 iiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiii
80 22 jjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjj
90 11 kkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkk
commit;
commit; commit;
select * from t1; ** connection default
eta tipo c
7 7 aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
8 8 bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb
10 1 ccccccccccccccccccccccccccccccccccccccccccc
20 2 ddddddddddddddddddddddddddddddddddddddddddd
30 1 eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee
40 2 fffffffffffffffffffffffffffffffffffffffffff
50 1 ggggggggggggggggggggggggggggggggggggggggggg
60 2 hhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhh
70 1 iiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiii
80 22 jjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjj
90 11 kkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkk
select * from t1;
eta tipo c
7 7 aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
8 8 bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb
10 1 ccccccccccccccccccccccccccccccccccccccccccc
20 2 ddddddddddddddddddddddddddddddddddddddddddd
30 1 eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee
40 2 fffffffffffffffffffffffffffffffffffffffffff
50 1 ggggggggggggggggggggggggggggggggggggggggggg
60 2 hhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhh
70 1 iiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiii
80 22 jjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjj
90 11 kkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkk
drop table t1; drop table t1;
**
** one UPDATE changing result set and SELECT ... FOR UPDATE
**
** connection thread1
** Set up table
SET SESSION STORAGE_ENGINE = InnoDB;
create table t1(eta int(11) not null, tipo int(11), c varchar(255)); create table t1(eta int(11) not null, tipo int(11), c varchar(255));
insert into t1 values (7,7, "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"); insert into t1 values (7,7, "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa");
insert into t1 values (8,8, "bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb"); insert into t1 values (8,8, "bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb");
@ -329,17 +365,24 @@ insert into t1 values (60,2,"hhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhh");
insert into t1 values (70,1,"iiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiii"); insert into t1 values (70,1,"iiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiii");
insert into t1 values (80,22,"jjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjj"); insert into t1 values (80,22,"jjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjj");
insert into t1 values (90,11,"kkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkk"); insert into t1 values (90,11,"kkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkk");
select get_lock("hello",10); ** connection thread2
get_lock("hello",10) ** Begin a new transaction on thread 2
1
begin; begin;
select * from t1 where tipo=2 FOR UPDATE; ** Select a range for update.
select * from t1 where tipo=2 FOR UPDATE;
eta tipo c
20 2 ddddddddddddddddddddddddddddddddddddddddddd
40 2 fffffffffffffffffffffffffffffffffffffffffff
60 2 hhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhh
** connection thread1
** Begin a new transaction on thread 1
begin; begin;
select release_lock("hello"); ** Update the same range which is marked for update on thread 2; this
release_lock("hello") ** will hang because of row locks.
1 update t1 set tipo=1 where tipo=2;
update t1 set tipo=11+get_lock("hello",10)*0 where tipo=22;
ERROR HY000: Lock wait timeout exceeded; try restarting transaction ERROR HY000: Lock wait timeout exceeded; try restarting transaction
** After the update the table will be unmodified because the previous
** transaction failed and was rolled back.
select * from t1; select * from t1;
eta tipo c eta tipo c
7 7 aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa 7 7 aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
@ -353,10 +396,8 @@ eta tipo c
70 1 iiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiii 70 1 iiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiii
80 22 jjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjj 80 22 jjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjj
90 11 kkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkk 90 11 kkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkk
eta tipo c ** connection thread2
20 2 ddddddddddddddddddddddddddddddddddddddddddd ** The table should look unmodified from thread 2.
40 2 fffffffffffffffffffffffffffffffffffffffffff
60 2 hhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhh
select * from t1; select * from t1;
eta tipo c eta tipo c
7 7 aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa 7 7 aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
@ -370,8 +411,14 @@ eta tipo c
70 1 iiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiii 70 1 iiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiii
80 22 jjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjj 80 22 jjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjj
90 11 kkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkk 90 11 kkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkk
commit; ** Sending a commit should release the row locks and enable
** thread 1 to complete the transaction.
commit; commit;
** connection thread1
** Commit on thread 1.
commit;
** connection thread2
** The table should not have been changed.
select * from t1; select * from t1;
eta tipo c eta tipo c
7 7 aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa 7 7 aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
@ -385,6 +432,8 @@ eta tipo c
70 1 iiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiii 70 1 iiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiii
80 22 jjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjj 80 22 jjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjj
90 11 kkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkk 90 11 kkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkk
** connection thread1
** Even on thread 1:
select * from t1; select * from t1;
eta tipo c eta tipo c
7 7 aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa 7 7 aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
@ -398,7 +447,15 @@ eta tipo c
70 1 iiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiii 70 1 iiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiii
80 22 jjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjj 80 22 jjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjj
90 11 kkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkk 90 11 kkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkk
** connection default
drop table t1; drop table t1;
**
** one UPDATE not changing result set and SELECT ... FOR UPDATE
**
** connection thread1
** Set up table
SET SESSION STORAGE_ENGINE = InnoDB;
create table t1(eta int(11) not null, tipo int(11), c varchar(255)); create table t1(eta int(11) not null, tipo int(11), c varchar(255));
insert into t1 values (7,7, "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"); insert into t1 values (7,7, "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa");
insert into t1 values (8,8, "bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb"); insert into t1 values (8,8, "bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb");
@ -411,21 +468,127 @@ insert into t1 values (60,2,"hhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhh");
insert into t1 values (70,1,"iiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiii"); insert into t1 values (70,1,"iiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiii");
insert into t1 values (80,22,"jjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjj"); insert into t1 values (80,22,"jjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjj");
insert into t1 values (90,11,"kkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkk"); insert into t1 values (90,11,"kkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkk");
select get_lock("hello",10); ** connection thread2
get_lock("hello",10) ** Starting new transaction on thread 2.
1
begin; begin;
select * from t1 where tipo=2 FOR UPDATE; ** Starting SELECT .. FOR UPDATE
select * from t1 where tipo=2 FOR UPDATE;
eta tipo c
20 2 ddddddddddddddddddddddddddddddddddddddddddd
40 2 fffffffffffffffffffffffffffffffffffffffffff
60 2 hhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhh
** connection thread1
** Starting new transaction on thread 1
begin; begin;
select release_lock("hello"); ** Updating single row using a table scan. This will time out
release_lock("hello") ** because of ongoing transaction on thread 1 holding lock on
1 ** all primary keys in the scan.
** Not so if innodb_locks_unsafe_for_binlog is set. The locks that
** do not match the WHERE condition are released.
update t1 set tipo=11 where tipo=22;
** After the time out the transaction is aborted; no rows should
** have changed.
select * from t1;
eta tipo c
7 7 aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
8 8 bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb
10 1 ccccccccccccccccccccccccccccccccccccccccccc
20 2 ddddddddddddddddddddddddddddddddddddddddddd
30 1 eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee
40 2 fffffffffffffffffffffffffffffffffffffffffff
50 1 ggggggggggggggggggggggggggggggggggggggggggg
60 2 hhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhh
70 1 iiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiii
80 11 jjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjj
90 11 kkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkk
** connection thread2
** The same thing should hold true for the transaction on
** thread 2
select * from t1;
eta tipo c
7 7 aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
8 8 bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb
10 1 ccccccccccccccccccccccccccccccccccccccccccc
20 2 ddddddddddddddddddddddddddddddddddddddddddd
30 1 eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee
40 2 fffffffffffffffffffffffffffffffffffffffffff
50 1 ggggggggggggggggggggggggggggggggggggggggggg
60 2 hhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhh
70 1 iiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiii
80 22 jjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjj
90 11 kkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkk
commit;
** connection thread1
commit;
** connection thread2
** Even after committing:
select * from t1;
eta tipo c
7 7 aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
8 8 bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb
10 1 ccccccccccccccccccccccccccccccccccccccccccc
20 2 ddddddddddddddddddddddddddddddddddddddddddd
30 1 eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee
40 2 fffffffffffffffffffffffffffffffffffffffffff
50 1 ggggggggggggggggggggggggggggggggggggggggggg
60 2 hhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhh
70 1 iiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiii
80 11 jjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjj
90 11 kkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkk
** connection thread1
select * from t1;
eta tipo c
7 7 aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
8 8 bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb
10 1 ccccccccccccccccccccccccccccccccccccccccccc
20 2 ddddddddddddddddddddddddddddddddddddddddddd
30 1 eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee
40 2 fffffffffffffffffffffffffffffffffffffffffff
50 1 ggggggggggggggggggggggggggggggggggggggggggg
60 2 hhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhh
70 1 iiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiii
80 11 jjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjj
90 11 kkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkk
** connection default
drop table t1;
**
** two SELECT ... FOR UPDATE
**
** connection thread1
** Set up table
SET SESSION STORAGE_ENGINE = InnoDB;
create table t1(eta int(11) not null, tipo int(11), c varchar(255));
insert into t1 values (7,7, "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa");
insert into t1 values (8,8, "bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb");
insert into t1 values (10,1,"ccccccccccccccccccccccccccccccccccccccccccc");
insert into t1 values (20,2,"ddddddddddddddddddddddddddddddddddddddddddd");
insert into t1 values (30,1,"eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee");
insert into t1 values (40,2,"fffffffffffffffffffffffffffffffffffffffffff");
insert into t1 values (50,1,"ggggggggggggggggggggggggggggggggggggggggggg");
insert into t1 values (60,2,"hhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhh");
insert into t1 values (70,1,"iiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiii");
insert into t1 values (80,22,"jjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjj");
insert into t1 values (90,11,"kkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkk");
** connection thread2
** Begin a new transaction on thread 2
begin;
select * from t1 where tipo=2 FOR UPDATE;
eta tipo c
20 2 ddddddddddddddddddddddddddddddddddddddddddd
40 2 fffffffffffffffffffffffffffffffffffffffffff
60 2 hhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhh
** connection thread1
** Begin a new transaction on thread 1
begin;
** Selecting a range for update by table scan will be blocked
** because of on-going transaction on thread 2.
select * from t1 where tipo=1 FOR UPDATE; select * from t1 where tipo=1 FOR UPDATE;
ERROR HY000: Lock wait timeout exceeded; try restarting transaction ERROR HY000: Lock wait timeout exceeded; try restarting transaction
eta tipo c ** connection thread2
20 2 ddddddddddddddddddddddddddddddddddddddddddd ** Table will be unchanged and the select command will not be
40 2 fffffffffffffffffffffffffffffffffffffffffff ** blocked:
60 2 hhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhh
select * from t1; select * from t1;
eta tipo c eta tipo c
7 7 aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa 7 7 aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
@ -439,8 +602,13 @@ eta tipo c
70 1 iiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiii 70 1 iiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiii
80 22 jjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjj 80 22 jjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjj
90 11 kkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkk 90 11 kkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkk
commit; ** Commit transacton on thread 2.
commit; commit;
** connection thread1
** Commit transaction on thread 1.
commit;
** connection thread2
** Make sure table isn't blocked on thread 2:
select * from t1; select * from t1;
eta tipo c eta tipo c
7 7 aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa 7 7 aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
@ -454,6 +622,8 @@ eta tipo c
70 1 iiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiii 70 1 iiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiii
80 22 jjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjj 80 22 jjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjj
90 11 kkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkk 90 11 kkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkk
** connection thread1
** Make sure table isn't blocked on thread 1:
select * from t1; select * from t1;
eta tipo c eta tipo c
7 7 aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa 7 7 aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
@ -467,7 +637,15 @@ eta tipo c
70 1 iiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiii 70 1 iiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiii
80 22 jjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjj 80 22 jjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjj
90 11 kkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkk 90 11 kkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkk
** connection default
drop table t1; drop table t1;
**
** one UPDATE changing result set and DELETE
**
** connection thread1
** Set up table
SET SESSION STORAGE_ENGINE = InnoDB;
create table t1(eta int(11) not null, tipo int(11), c varchar(255)); create table t1(eta int(11) not null, tipo int(11), c varchar(255));
insert into t1 values (7,7, "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"); insert into t1 values (7,7, "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa");
insert into t1 values (8,8, "bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb"); insert into t1 values (8,8, "bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb");
@ -480,16 +658,12 @@ insert into t1 values (60,2,"hhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhh");
insert into t1 values (70,1,"iiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiii"); insert into t1 values (70,1,"iiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiii");
insert into t1 values (80,22,"jjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjj"); insert into t1 values (80,22,"jjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjj");
insert into t1 values (90,11,"kkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkk"); insert into t1 values (90,11,"kkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkk");
select get_lock("hello",10); ** connection thread2
get_lock("hello",10)
1
begin; begin;
delete from t1 where tipo=2; delete from t1 where tipo=2;
** connection thread1
begin; begin;
select release_lock("hello"); update t1 set tipo=1 where tipo=2;
release_lock("hello")
1
update t1 set tipo=1+get_lock("hello",10)*0 where tipo=2;
ERROR HY000: Lock wait timeout exceeded; try restarting transaction ERROR HY000: Lock wait timeout exceeded; try restarting transaction
select * from t1; select * from t1;
eta tipo c eta tipo c
@ -504,6 +678,7 @@ eta tipo c
70 1 iiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiii 70 1 iiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiii
80 22 jjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjj 80 22 jjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjj
90 11 kkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkk 90 11 kkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkk
** connection thread2
select * from t1; select * from t1;
eta tipo c eta tipo c
7 7 aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa 7 7 aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
@ -514,8 +689,10 @@ eta tipo c
70 1 iiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiii 70 1 iiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiii
80 22 jjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjj 80 22 jjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjj
90 11 kkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkk 90 11 kkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkk
commit;
commit; commit;
** connection thread1
commit;
** connection thread2
select * from t1; select * from t1;
eta tipo c eta tipo c
7 7 aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa 7 7 aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
@ -526,6 +703,7 @@ eta tipo c
70 1 iiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiii 70 1 iiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiii
80 22 jjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjj 80 22 jjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjj
90 11 kkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkk 90 11 kkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkk
** connection thread1
select * from t1; select * from t1;
eta tipo c eta tipo c
7 7 aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa 7 7 aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
@ -536,7 +714,15 @@ eta tipo c
70 1 iiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiii 70 1 iiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiii
80 22 jjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjj 80 22 jjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjj
90 11 kkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkk 90 11 kkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkk
** connection default
drop table t1; drop table t1;
**
** one UPDATE not changing result set and DELETE
**
** connection thread1
** Set up table
SET SESSION STORAGE_ENGINE = InnoDB;
create table t1(eta int(11) not null, tipo int(11), c varchar(255)); create table t1(eta int(11) not null, tipo int(11), c varchar(255));
insert into t1 values (7,7, "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"); insert into t1 values (7,7, "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa");
insert into t1 values (8,8, "bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb"); insert into t1 values (8,8, "bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb");
@ -549,16 +735,17 @@ insert into t1 values (60,2,"hhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhh");
insert into t1 values (70,1,"iiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiii"); insert into t1 values (70,1,"iiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiii");
insert into t1 values (80,22,"jjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjj"); insert into t1 values (80,22,"jjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjj");
insert into t1 values (90,11,"kkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkk"); insert into t1 values (90,11,"kkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkk");
select get_lock("hello",10); ** connection thread2
get_lock("hello",10)
1
begin; begin;
delete from t1 where tipo=2; delete from t1 where tipo=2;
** connection thread1
begin; begin;
select release_lock("hello"); ** Update on t1 will cause a table scan which will be blocked because
release_lock("hello") ** the previously initiated table scan applied exclusive key locks on
1 ** all primary keys.
update t1 set tipo=1+get_lock("hello",10)*0 where tipo=22; ** Not so if innodb_locks_unsafe_for_binlog is set. The locks that
** do not match the WHERE condition are released.
update t1 set tipo=1 where tipo=22;
select * from t1; select * from t1;
eta tipo c eta tipo c
7 7 aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa 7 7 aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
@ -572,6 +759,7 @@ eta tipo c
70 1 iiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiii 70 1 iiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiii
80 1 jjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjj 80 1 jjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjj
90 11 kkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkk 90 11 kkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkk
** connection thread2
select * from t1; select * from t1;
eta tipo c eta tipo c
7 7 aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa 7 7 aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
@ -582,8 +770,10 @@ eta tipo c
70 1 iiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiii 70 1 iiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiii
80 22 jjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjj 80 22 jjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjj
90 11 kkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkk 90 11 kkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkk
commit;
commit; commit;
** connection thread1
commit;
** connection thread2
select * from t1; select * from t1;
eta tipo c eta tipo c
7 7 aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa 7 7 aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
@ -594,6 +784,7 @@ eta tipo c
70 1 iiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiii 70 1 iiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiii
80 1 jjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjj 80 1 jjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjj
90 11 kkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkk 90 11 kkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkk
** connection thread1
select * from t1; select * from t1;
eta tipo c eta tipo c
7 7 aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa 7 7 aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
@ -604,4 +795,5 @@ eta tipo c
70 1 iiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiii 70 1 iiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiii
80 1 jjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjj 80 1 jjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjj
90 11 kkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkk 90 11 kkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkk
** connection default
drop table t1; drop table t1;

View file

@ -5388,4 +5388,10 @@ select * from t1;
c1 c1
That That
drop table t1; drop table t1;
create table t1 (a int not null) engine=csv;
lock tables t1 read;
select * from t1;
ERROR HY000: File './test/t1.CSV' not found (Errcode: 2)
unlock tables;
drop table t1;
End of 5.1 tests End of 5.1 tests

View file

@ -1009,13 +1009,13 @@ Warning 1101 BLOB/TEXT column 'blurb' can't have a default value
INSERT INTO federated.t1 VALUES (1, " MySQL supports a number of column types in several categories: numeric types, date and time types, and string (character) types. This chapter first gives an overview of these column types, and then provides a more detailed description of the properties of the types in each category, and a summary of the column type storage requirements. The overview is intentionally brief. The more detailed descriptions should be consulted for additional information about particular column types, such as the allowable formats in which you can specify values."); INSERT INTO federated.t1 VALUES (1, " MySQL supports a number of column types in several categories: numeric types, date and time types, and string (character) types. This chapter first gives an overview of these column types, and then provides a more detailed description of the properties of the types in each category, and a summary of the column type storage requirements. The overview is intentionally brief. The more detailed descriptions should be consulted for additional information about particular column types, such as the allowable formats in which you can specify values.");
INSERT INTO federated.t1 VALUES (2, "All arithmetic is done using signed BIGINT or DOUBLE values, so you should not use unsigned big integers larger than 9223372036854775807 (63 bits) except with bit functions! If you do that, some of the last digits in the result may be wrong because of rounding errors when converting a BIGINT value to a DOUBLE."); INSERT INTO federated.t1 VALUES (2, "All arithmetic is done using signed BIGINT or DOUBLE values, so you should not use unsigned big integers larger than 9223372036854775807 (63 bits) except with bit functions! If you do that, some of the last digits in the result may be wrong because of rounding errors when converting a BIGINT value to a DOUBLE.");
INSERT INTO federated.t1 VALUES (3, " A floating-point number. p represents the precision. It can be from 0 to 24 for a single-precision floating-point number and from 25 to 53 for a double-precision floating-point number. These types are like the FLOAT and DOUBLE types described immediately following. FLOAT(p) has the same range as the corresponding FLOAT and DOUBLE types, but the display size and number of decimals are undefined. "); INSERT INTO federated.t1 VALUES (3, " A floating-point number. p represents the precision. It can be from 0 to 24 for a single-precision floating-point number and from 25 to 53 for a double-precision floating-point number. These types are like the FLOAT and DOUBLE types described immediately following. FLOAT(p) has the same range as the corresponding FLOAT and DOUBLE types, but the display size and number of decimals are undefined. ");
INSERT INTO federated.t1 VALUES(4, "Die Übersetzung einer so umfangreichen technischen Dokumentation wie des MySQL-Referenzhandbuchs ist schon eine besondere Herausforderung. Zumindest für jemanden, der seine Zielsprache ernst nimmt:"); INSERT INTO federated.t1 VALUES(4, "Die <EFBFBD>bersetzung einer so umfangreichen technischen Dokumentation wie des MySQL-Referenzhandbuchs ist schon eine besondere Herausforderung. Zumindest f<EFBFBD>r jemanden, der seine Zielsprache ernst nimmt:");
SELECT * FROM federated.t1; SELECT * FROM federated.t1;
blurb_id blurb blurb_id blurb
1 MySQL supports a number of column types in several categories: numeric types, date and time types, and string (character) types. This chapter first gives an overview of these column types, and then provides a more detailed description of the properties of the types in each category, and a summary of the column type storage requirements. The overview is intentionally brief. The more detailed descriptions should be consulted for additional information about particular column types, such as the allowable formats in which you can specify values. 1 MySQL supports a number of column types in several categories: numeric types, date and time types, and string (character) types. This chapter first gives an overview of these column types, and then provides a more detailed description of the properties of the types in each category, and a summary of the column type storage requirements. The overview is intentionally brief. The more detailed descriptions should be consulted for additional information about particular column types, such as the allowable formats in which you can specify values.
2 All arithmetic is done using signed BIGINT or DOUBLE values, so you should not use unsigned big integers larger than 9223372036854775807 (63 bits) except with bit functions! If you do that, some of the last digits in the result may be wrong because of rounding errors when converting a BIGINT value to a DOUBLE. 2 All arithmetic is done using signed BIGINT or DOUBLE values, so you should not use unsigned big integers larger than 9223372036854775807 (63 bits) except with bit functions! If you do that, some of the last digits in the result may be wrong because of rounding errors when converting a BIGINT value to a DOUBLE.
3 A floating-point number. p represents the precision. It can be from 0 to 24 for a single-precision floating-point number and from 25 to 53 for a double-precision floating-point number. These types are like the FLOAT and DOUBLE types described immediately following. FLOAT(p) has the same range as the corresponding FLOAT and DOUBLE types, but the display size and number of decimals are undefined. 3 A floating-point number. p represents the precision. It can be from 0 to 24 for a single-precision floating-point number and from 25 to 53 for a double-precision floating-point number. These types are like the FLOAT and DOUBLE types described immediately following. FLOAT(p) has the same range as the corresponding FLOAT and DOUBLE types, but the display size and number of decimals are undefined.
4 Die Übersetzung einer so umfangreichen technischen Dokumentation wie des MySQL-Referenzhandbuchs ist schon eine besondere Herausforderung. Zumindest für jemanden, der seine Zielsprache ernst nimmt: 4 Die <EFBFBD>bersetzung einer so umfangreichen technischen Dokumentation wie des MySQL-Referenzhandbuchs ist schon eine besondere Herausforderung. Zumindest f<EFBFBD>r jemanden, der seine Zielsprache ernst nimmt:
DROP TABLE IF EXISTS federated.t1; DROP TABLE IF EXISTS federated.t1;
CREATE TABLE federated.t1 ( CREATE TABLE federated.t1 (
`a` int NOT NULL, `a` int NOT NULL,
@ -2118,6 +2118,17 @@ DROP TABLE t1;
DROP TABLE t1; DROP TABLE t1;
CREATE TABLE t1 (a INT) ENGINE=federated CONNECTION='mysql://@:://'; CREATE TABLE t1 (a INT) ENGINE=federated CONNECTION='mysql://@:://';
DROP TABLE t1; DROP TABLE t1;
CREATE TABLE t1 (a LONGBLOB, b LONGBLOB);
INSERT INTO t1 VALUES ('aaaaaaaaaaaaaaaaaaaaaaaaaaaa', NULL);
CREATE TABLE t1
(a LONGBLOB, b LONGBLOB) ENGINE=FEDERATED
CONNECTION='mysql://root@127.0.0.1:SLAVE_PORT/test/t1';
CHECKSUM TABLE t1;
Table Checksum
test.t1 2465757603
DROP TABLE t1;
DROP TABLE t1;
End of 5.0 tests
create server 's1' foreign data wrapper 'mysql' options (port 3306); create server 's1' foreign data wrapper 'mysql' options (port 3306);
drop server 's1'; drop server 's1';
End of 5.1 tests End of 5.1 tests
@ -2125,4 +2136,3 @@ DROP TABLE IF EXISTS federated.t1;
DROP DATABASE IF EXISTS federated; DROP DATABASE IF EXISTS federated;
DROP TABLE IF EXISTS federated.t1; DROP TABLE IF EXISTS federated.t1;
DROP DATABASE IF EXISTS federated; DROP DATABASE IF EXISTS federated;
SET @@GLOBAL.CONCURRENT_INSERT= @OLD_CONCURRENT_INSERT;

View file

@ -131,3 +131,49 @@ drop table t1;
select if(0, 18446744073709551610, 18446744073709551610); select if(0, 18446744073709551610, 18446744073709551610);
if(0, 18446744073709551610, 18446744073709551610) if(0, 18446744073709551610, 18446744073709551610)
18446744073709551610 18446744073709551610
CREATE TABLE t1(a DECIMAL(10,3));
SELECT t1.a,
IF((ROUND(t1.a,2)=1), 2,
IF((ROUND(t1.a,2)=1), 2,
IF((ROUND(t1.a,2)=1), 2,
IF((ROUND(t1.a,2)=1), 2,
IF((ROUND(t1.a,2)=1), 2,
IF((ROUND(t1.a,2)=1), 2,
IF((ROUND(t1.a,2)=1), 2,
IF((ROUND(t1.a,2)=1), 2,
IF((ROUND(t1.a,2)=1), 2,
IF((ROUND(t1.a,2)=1), 2,
IF((ROUND(t1.a,2)=1), 2,
IF((ROUND(t1.a,2)=1), 2,
IF((ROUND(t1.a,2)=1), 2,
IF((ROUND(t1.a,2)=1), 2,
IF((ROUND(t1.a,2)=1), 2,
IF((ROUND(t1.a,2)=1), 2,
IF((ROUND(t1.a,2)=1), 2,
IF((ROUND(t1.a,2)=1), 2,
IF((ROUND(t1.a,2)=1), 2,
IF((ROUND(t1.a,2)=1), 2,
IF((ROUND(t1.a,2)=1), 2,
IF((ROUND(t1.a,2)=1), 2,
IF((ROUND(t1.a,2)=1), 2,
IF((ROUND(t1.a,2)=1), 2,
IF((ROUND(t1.a,2)=1), 2,
IF((ROUND(t1.a,2)=1), 2,
IF((ROUND(t1.a,2)=1), 2,
IF((ROUND(t1.a,2)=1), 2,
IF((ROUND(t1.a,2)=1), 2,
IF((ROUND(t1.a,2)=1), 2,0)))))))))))))))))))))))))))))) + 1
FROM t1;
a IF((ROUND(t1.a,2)=1), 2,
IF((ROUND(t1.a,2)=1), 2,
IF((ROUND(t1.a,2)=1), 2,
IF((ROUND(t1.a,2)=1), 2,
IF((ROUND(t1.a,2)=1), 2,
IF((ROUND(t1.a,2)=1), 2,
IF((ROUND(t1.a,2)=1), 2,
IF((ROUND(t1.a,2)=1), 2,
IF((ROUND(t1.a,2)=1), 2,
IF((ROUND(t1.a,2)=1), 2,
IF((R
DROP TABLE t1;
End of 5.0 tests

View file

@ -569,4 +569,10 @@ insert into t1 values (),(),(),(),(),(),(),(),(),();
select a from t1 where a not in (a,a,a) group by a; select a from t1 where a not in (a,a,a) group by a;
a a
drop table t1; drop table t1;
create table t1 (id int);
select * from t1 where NOT id in (select null union all select 1);
id
select * from t1 where NOT id in (null, 1);
id
drop table t1;
End of 5.1 tests End of 5.1 tests

View file

@ -310,6 +310,20 @@ drop table t1;
SELECT NAME_CONST('var', 'value') COLLATE latin1_general_cs; SELECT NAME_CONST('var', 'value') COLLATE latin1_general_cs;
NAME_CONST('var', 'value') COLLATE latin1_general_cs NAME_CONST('var', 'value') COLLATE latin1_general_cs
value value
select @@session.time_zone into @save_tz;
set @@session.time_zone='UTC';
select uuid() into @my_uuid;
select mid(@my_uuid,15,1);
mid(@my_uuid,15,1)
1
select 24 * 60 * 60 * 1000 * 1000 * 10 into @my_uuid_one_day;
select concat('0',mid(@my_uuid,16,3),mid(@my_uuid,10,4),left(@my_uuid,8)) into @my_uuidate;
select floor(conv(@my_uuidate,16,10)/@my_uuid_one_day) into @my_uuid_date;
select 141427 + datediff(curdate(),'1970-01-01') into @my_uuid_synthetic;
select @my_uuid_date - @my_uuid_synthetic;
@my_uuid_date - @my_uuid_synthetic
0
set @@session.time_zone=@save_tz;
End of 5.0 tests End of 5.0 tests
select connection_id() > 0; select connection_id() > 0;
connection_id() > 0 connection_id() > 0

View file

@ -115,3 +115,21 @@ SELECT 1 REGEXP NULL;
1 REGEXP NULL 1 REGEXP NULL
NULL NULL
End of 5.0 tests End of 5.0 tests
CREATE TABLE t1(a INT, b CHAR(4));
INSERT INTO t1 VALUES (1, '6.1'), (1, '7.0'), (1, '8.0');
PREPARE stmt1 FROM "SELECT a FROM t1 WHERE a=1 AND '7.0' REGEXP b LIMIT 1";
EXECUTE stmt1;
a
1
EXECUTE stmt1;
a
1
EXECUTE stmt1;
a
1
EXECUTE stmt1;
a
1
DEALLOCATE PREPARE stmt1;
DROP TABLE t1;
End of 5.1 tests

View file

@ -1,3 +1,5 @@
drop view if exists v1;
drop table if exists t1,t4;
create table t4 ( create table t4 (
pk_col int auto_increment primary key, a1 char(64), a2 char(64), b char(16), c char(16) not null, d char(16), dummy char(64) default ' ' pk_col int auto_increment primary key, a1 char(64), a2 char(64), b char(16), c char(16) not null, d char(16), dummy char(64) default ' '
) engine=innodb; ) engine=innodb;
@ -70,3 +72,25 @@ explain select distinct 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 SIMPLE t1 range NULL PRIMARY 5 NULL 3 Using index for group-by; Using temporary 1 SIMPLE t1 range NULL PRIMARY 5 NULL 3 Using index for group-by; Using temporary
drop table t1; drop table t1;
create table t1(pk int primary key) engine=innodb;
create view v1 as select pk from t1 where pk < 20;
insert into t1 values (1), (2), (3), (4);
select distinct pk from v1;
pk
1
2
3
4
insert into t1 values (5), (6), (7);
select distinct pk from v1;
pk
1
2
3
4
5
6
7
drop view v1;
drop table t1;
End of 5.1 tests

View file

@ -484,6 +484,7 @@ c1
handler t1 close; handler t1 close;
read the result from the other connection read the result from the other connection
Table Op Msg_type Msg_text Table Op Msg_type Msg_text
test.t1 optimize note Table does not support optimize, doing recreate + analyze instead
test.t1 optimize status OK test.t1 optimize status OK
proceed with the normal connection proceed with the normal connection
drop table t1; drop table t1;
@ -698,6 +699,7 @@ handler a2 read a first;
a a
optimize table t1; optimize table t1;
Table Op Msg_type Msg_text Table Op Msg_type Msg_text
test.t1 optimize note Table does not support optimize, doing recreate + analyze instead
test.t1 optimize status OK test.t1 optimize status OK
handler a1 close; handler a1 close;
ERROR 42S02: Unknown table 'a1' in HANDLER ERROR 42S02: Unknown table 'a1' in HANDLER

View file

@ -0,0 +1,7 @@
drop table if exists t1;
create table t1(a int not null auto_increment primary key) engine=innodb;
insert into t1 set a = -1;
optimize table t1;
Table Op Msg_type Msg_text
test.t1 optimize note Table does not support optimize, doing recreate + analyze instead
test.t1 optimize status OK

View file

@ -0,0 +1,171 @@
drop table if exists t1;
CREATE TABLE t1 (c1 BIGINT PRIMARY KEY AUTO_INCREMENT, c2 VARCHAR(10)) ENGINE=InnoDB;
INSERT INTO t1 VALUES (9223372036854775807, null);
INSERT INTO t1 (c2) VALUES ('innodb');
Got one of the listed errors
SELECT * FROM t1;
c1 c2
9223372036854775807 NULL
DROP TABLE t1;
CREATE TABLE t1 (c1 TINYINT PRIMARY KEY AUTO_INCREMENT, c2 VARCHAR(10)) ENGINE=InnoDB;
INSERT INTO t1 VALUES (127, null);
INSERT INTO t1 (c2) VALUES ('innodb');
Got one of the listed errors
SELECT * FROM t1;
c1 c2
127 NULL
DROP TABLE t1;
CREATE TABLE t1 (c1 TINYINT UNSIGNED PRIMARY KEY AUTO_INCREMENT, c2 VARCHAR(10)) ENGINE=InnoDB;
INSERT INTO t1 VALUES (255, null);
INSERT INTO t1 (c2) VALUES ('innodb');
Got one of the listed errors
SELECT * FROM t1;
c1 c2
255 NULL
DROP TABLE t1;
CREATE TABLE t1 (c1 SMALLINT PRIMARY KEY AUTO_INCREMENT, c2 VARCHAR(10)) ENGINE=InnoDB;
INSERT INTO t1 VALUES (32767, null);
INSERT INTO t1 (c2) VALUES ('innodb');
Got one of the listed errors
SELECT * FROM t1;
c1 c2
32767 NULL
DROP TABLE t1;
CREATE TABLE t1 (c1 SMALLINT UNSIGNED PRIMARY KEY AUTO_INCREMENT, c2 VARCHAR(10)) ENGINE=InnoDB;
INSERT INTO t1 VALUES (65535, null);
INSERT INTO t1 (c2) VALUES ('innodb');
Got one of the listed errors
SELECT * FROM t1;
c1 c2
65535 NULL
DROP TABLE t1;
CREATE TABLE t1 (c1 MEDIUMINT PRIMARY KEY AUTO_INCREMENT, c2 VARCHAR(10)) ENGINE=InnoDB;
INSERT INTO t1 VALUES (8388607, null);
INSERT INTO t1 (c2) VALUES ('innodb');
Got one of the listed errors
SELECT * FROM t1;
c1 c2
8388607 NULL
DROP TABLE t1;
CREATE TABLE t1 (c1 MEDIUMINT UNSIGNED PRIMARY KEY AUTO_INCREMENT, c2 VARCHAR(10)) ENGINE=InnoDB;
INSERT INTO t1 VALUES (16777215, null);
INSERT INTO t1 (c2) VALUES ('innodb');
Got one of the listed errors
SELECT * FROM t1;
c1 c2
16777215 NULL
DROP TABLE t1;
CREATE TABLE t1 (c1 INT PRIMARY KEY AUTO_INCREMENT, c2 VARCHAR(10)) ENGINE=InnoDB;
INSERT INTO t1 VALUES (2147483647, null);
INSERT INTO t1 (c2) VALUES ('innodb');
Got one of the listed errors
SELECT * FROM t1;
c1 c2
2147483647 NULL
DROP TABLE t1;
CREATE TABLE t1 (c1 INT UNSIGNED PRIMARY KEY AUTO_INCREMENT, c2 VARCHAR(10)) ENGINE=InnoDB;
INSERT INTO t1 VALUES (4294967295, null);
INSERT INTO t1 (c2) VALUES ('innodb');
Got one of the listed errors
SELECT * FROM t1;
c1 c2
4294967295 NULL
DROP TABLE t1;
CREATE TABLE t1 (c1 BIGINT PRIMARY KEY AUTO_INCREMENT, c2 VARCHAR(10)) ENGINE=InnoDB;
INSERT INTO t1 VALUES (9223372036854775807, null);
INSERT INTO t1 (c2) VALUES ('innodb');
Got one of the listed errors
SELECT * FROM t1;
c1 c2
9223372036854775807 NULL
DROP TABLE t1;
CREATE TABLE t1 (c1 BIGINT UNSIGNED PRIMARY KEY AUTO_INCREMENT, c2 VARCHAR(10)) ENGINE=InnoDB;
INSERT INTO t1 VALUES (18446744073709551615, null);
INSERT INTO t1 (c2) VALUES ('innodb');
Got one of the listed errors
SELECT * FROM t1;
c1 c2
18446744073709551615 NULL
DROP TABLE t1;
CREATE TABLE t1(c1 INT PRIMARY KEY AUTO_INCREMENT) ENGINE=InnoDB;
INSERT INTO t1 VALUES (1), (2), (3);
INSERT INTO t1 VALUES (NULL), (NULL), (NULL);
SELECT c1 FROM t1;
c1
1
2
3
4
5
6
SHOW CREATE TABLE t1;
Table Create Table
t1 CREATE TABLE `t1` (
`c1` int(11) NOT NULL AUTO_INCREMENT,
PRIMARY KEY (`c1`)
) ENGINE=InnoDB AUTO_INCREMENT=7 DEFAULT CHARSET=latin1
TRUNCATE TABLE t1;
SHOW CREATE TABLE t1;
Table Create Table
t1 CREATE TABLE `t1` (
`c1` int(11) NOT NULL AUTO_INCREMENT,
PRIMARY KEY (`c1`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1
INSERT INTO t1 VALUES (1), (2), (3);
INSERT INTO t1 VALUES (NULL), (NULL), (NULL);
SELECT c1 FROM t1;
c1
1
2
3
4
5
6
SHOW CREATE TABLE t1;
Table Create Table
t1 CREATE TABLE `t1` (
`c1` int(11) NOT NULL AUTO_INCREMENT,
PRIMARY KEY (`c1`)
) ENGINE=InnoDB AUTO_INCREMENT=7 DEFAULT CHARSET=latin1
DROP TABLE t1;
CREATE TABLE t1(c1 INT PRIMARY KEY AUTO_INCREMENT) ENGINE=InnoDB;
INSERT INTO t1 VALUES (1), (2), (3);
INSERT INTO t1 VALUES (NULL), (NULL), (NULL);
SELECT c1 FROM t1;
c1
1
2
3
4
5
6
SHOW CREATE TABLE t1;
Table Create Table
t1 CREATE TABLE `t1` (
`c1` int(11) NOT NULL AUTO_INCREMENT,
PRIMARY KEY (`c1`)
) ENGINE=InnoDB AUTO_INCREMENT=7 DEFAULT CHARSET=latin1
DELETE FROM t1;
SHOW CREATE TABLE t1;
Table Create Table
t1 CREATE TABLE `t1` (
`c1` int(11) NOT NULL AUTO_INCREMENT,
PRIMARY KEY (`c1`)
) ENGINE=InnoDB AUTO_INCREMENT=7 DEFAULT CHARSET=latin1
INSERT INTO t1 VALUES (1), (2), (3);
INSERT INTO t1 VALUES (NULL), (NULL), (NULL);
SELECT c1 FROM t1;
c1
1
2
3
7
8
9
SHOW CREATE TABLE t1;
Table Create Table
t1 CREATE TABLE `t1` (
`c1` int(11) NOT NULL AUTO_INCREMENT,
PRIMARY KEY (`c1`)
) ENGINE=InnoDB AUTO_INCREMENT=10 DEFAULT CHARSET=latin1
DROP TABLE t1;

View file

@ -166,6 +166,7 @@ level id parent_id
1 1007 101 1 1007 101
optimize table t1; optimize table t1;
Table Op Msg_type Msg_text Table Op Msg_type Msg_text
test.t1 optimize note Table does not support optimize, doing recreate + analyze instead
test.t1 optimize status OK test.t1 optimize status OK
show keys from t1; show keys from t1;
Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment
@ -190,6 +191,7 @@ create table t1 (a int) engine=innodb;
insert into t1 values (1), (2); insert into t1 values (1), (2);
optimize table t1; optimize table t1;
Table Op Msg_type Msg_text Table Op Msg_type Msg_text
test.t1 optimize note Table does not support optimize, doing recreate + analyze instead
test.t1 optimize status OK test.t1 optimize status OK
delete from t1 where a = 1; delete from t1 where a = 1;
select * from t1; select * from t1;
@ -738,6 +740,7 @@ world 2
hello 1 hello 1
optimize table t1; optimize table t1;
Table Op Msg_type Msg_text Table Op Msg_type Msg_text
test.t1 optimize note Table does not support optimize, doing recreate + analyze instead
test.t1 optimize status OK test.t1 optimize status OK
show keys from t1; show keys from t1;
Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment
@ -3109,6 +3112,7 @@ BEGIN;
INSERT INTO t1 VALUES (1); INSERT INTO t1 VALUES (1);
OPTIMIZE TABLE t1; OPTIMIZE TABLE t1;
Table Op Msg_type Msg_text Table Op Msg_type Msg_text
test.t1 optimize note Table does not support optimize, doing recreate + analyze instead
test.t1 optimize status OK test.t1 optimize status OK
DROP TABLE t1; DROP TABLE t1;
CREATE TABLE t1 (id int PRIMARY KEY, f int NOT NULL, INDEX(f)) ENGINE=InnoDB; CREATE TABLE t1 (id int PRIMARY KEY, f int NOT NULL, INDEX(f)) ENGINE=InnoDB;
@ -3263,3 +3267,14 @@ AUTO_INCREMENT
200 200
DROP TABLE t2; DROP TABLE t2;
DROP TABLE t1; DROP TABLE t1;
CREATE TABLE t1 (c1 int default NULL,
c2 int default NULL
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
TRUNCATE TABLE t1;
affected rows: 0
INSERT INTO t1 VALUES (1, 1), (2, 2), (3, 3), (4, 4), (5, 5);
affected rows: 5
info: Records: 5 Duplicates: 0 Warnings: 0
TRUNCATE TABLE t1;
affected rows: 0
DROP TABLE t1;

View file

@ -0,0 +1,4 @@
f4 f8
xxx zzz
f4 f8
xxx zzz

View file

@ -0,0 +1 @@
SET storage_engine=InnoDB;

View file

@ -577,6 +577,7 @@ id select_type table type possible_keys key key_len ref rows Extra
INSERT INTO t2 SELECT * FROM t1; INSERT INTO t2 SELECT * FROM t1;
OPTIMIZE TABLE t2; OPTIMIZE TABLE t2;
Table Op Msg_type Msg_text Table Op Msg_type Msg_text
test.t2 optimize note Table does not support optimize, doing recreate + analyze instead
test.t2 optimize status OK test.t2 optimize status OK
EXPLAIN SELECT COUNT(*) FROM t2 WHERE stat_id IN (1,3) AND acct_id=785; EXPLAIN SELECT COUNT(*) FROM t2 WHERE stat_id IN (1,3) AND acct_id=785;
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
@ -1362,6 +1363,21 @@ set global innodb_autoextend_increment=@my_innodb_autoextend_increment;
set @my_innodb_commit_concurrency=@@global.innodb_commit_concurrency; set @my_innodb_commit_concurrency=@@global.innodb_commit_concurrency;
set global innodb_commit_concurrency=0; set global innodb_commit_concurrency=0;
set global innodb_commit_concurrency=@my_innodb_commit_concurrency; set global innodb_commit_concurrency=@my_innodb_commit_concurrency;
CREATE TABLE t1 (a int, b int, c int, PRIMARY KEY (a), KEY t1_b (b))
ENGINE=InnoDB;
INSERT INTO t1 (a,b,c) VALUES (1,1,1), (2,1,1), (3,1,1), (4,1,1);
INSERT INTO t1 (a,b,c) SELECT a+4,b,c FROM t1;
EXPLAIN SELECT a, b, c FROM t1 WHERE b = 1 ORDER BY a DESC LIMIT 5;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 index t1_b PRIMARY 4 NULL 8 Using where
SELECT a, b, c FROM t1 WHERE b = 1 ORDER BY a DESC LIMIT 5;
a b c
8 1 1
7 1 1
6 1 1
5 1 1
4 1 1
DROP TABLE t1;
End of 5.0 tests End of 5.0 tests
CREATE TABLE `t2` ( CREATE TABLE `t2` (
`k` int(11) NOT NULL auto_increment, `k` int(11) NOT NULL auto_increment,

View file

@ -750,8 +750,8 @@ ERROR 42S22: Unknown column 't1.b' in 'on clause'
select * from information_schema.statistics join information_schema.columns select * from information_schema.statistics join information_schema.columns
using(table_name,column_name) where table_name='user'; using(table_name,column_name) where table_name='user';
TABLE_NAME COLUMN_NAME TABLE_CATALOG TABLE_SCHEMA NON_UNIQUE INDEX_SCHEMA INDEX_NAME SEQ_IN_INDEX COLLATION CARDINALITY SUB_PART PACKED NULLABLE INDEX_TYPE COMMENT TABLE_CATALOG TABLE_SCHEMA ORDINAL_POSITION COLUMN_DEFAULT IS_NULLABLE DATA_TYPE CHARACTER_MAXIMUM_LENGTH CHARACTER_OCTET_LENGTH NUMERIC_PRECISION NUMERIC_SCALE CHARACTER_SET_NAME COLLATION_NAME COLUMN_TYPE COLUMN_KEY EXTRA PRIVILEGES COLUMN_COMMENT TABLE_NAME COLUMN_NAME TABLE_CATALOG TABLE_SCHEMA NON_UNIQUE INDEX_SCHEMA INDEX_NAME SEQ_IN_INDEX COLLATION CARDINALITY SUB_PART PACKED NULLABLE INDEX_TYPE COMMENT TABLE_CATALOG TABLE_SCHEMA ORDINAL_POSITION COLUMN_DEFAULT IS_NULLABLE DATA_TYPE CHARACTER_MAXIMUM_LENGTH CHARACTER_OCTET_LENGTH NUMERIC_PRECISION NUMERIC_SCALE CHARACTER_SET_NAME COLLATION_NAME COLUMN_TYPE COLUMN_KEY EXTRA PRIVILEGES COLUMN_COMMENT
user Host NULL mysql 0 mysql PRIMARY 1 A NULL NULL NULL BTREE NULL mysql 1 NO char 60 180 NULL NULL utf8 utf8_bin char(60) PRI # user Host NULL mysql 0 mysql PRIMARY 1 A # NULL NULL BTREE NULL mysql 1 NO char 60 180 NULL NULL utf8 utf8_bin char(60) PRI #
user User NULL mysql 0 mysql PRIMARY 2 A 3 NULL NULL BTREE NULL mysql 2 NO char 16 48 NULL NULL utf8 utf8_bin char(16) PRI # user User NULL mysql 0 mysql PRIMARY 2 A # NULL NULL BTREE NULL mysql 2 NO char 16 48 NULL NULL utf8 utf8_bin char(16) PRI #
drop table t1; drop table t1;
drop table t2; drop table t2;
drop table t3; drop table t3;

View file

@ -1,3 +1,2 @@
Variable_name Value Variable_name Value
lower_case_file_system ON
lower_case_table_names 0 lower_case_table_names 0

View file

@ -1,6 +1,6 @@
** Setup ** ** Setup **
SET @default_max_user_connections = @@max_user_connections; SET @default_max_user_connections = @@global.max_user_connections;
Set Global max_user_connections=2; Set Global max_user_connections=2;
'#--------------------FN_DYNVARS_114_01-------------------------#' '#--------------------FN_DYNVARS_114_01-------------------------#'
** Connecting conn1 using username 'root' ** ** Connecting conn1 using username 'root' **
@ -9,10 +9,11 @@ Set Global max_user_connections=2;
ERROR 42000: User root already has more than 'max_user_connections' active connections ERROR 42000: User root already has more than 'max_user_connections' active connections
Expected error "too many connections" Expected error "too many connections"
** Disconnecting conn1 ** ** Disconnecting conn1 **
** Poll till disconnected conn1 disappears from processlist
'#--------------------FN_DYNVARS_114_02-------------------------#' '#--------------------FN_DYNVARS_114_02-------------------------#'
Set Global max_user_connections=3; Set Global max_user_connections=3;
** Connecting conn5 using username 'root' ** ** Connecting conn5 using username 'root' **
** Connecting conn6 using username 'root' ** ** Connecting conn6 using username 'root' **
** Connection default ** ** Connection default **
** Disconnecting conn5, conn6 ** ** Disconnecting conn5, conn6 **
SET GLOBAL max_user_connections = @default_max_user_connections; SET @@global.max_user_connections = @default_max_user_connections;

View file

@ -108,11 +108,11 @@ id
1 1
select * from v1 group by id limit 0; select * from v1 group by id limit 0;
Catalog Database Table Table_alias Column Column_alias Type Length Max length Is_null Flags Decimals Charsetnr Catalog Database Table Table_alias Column Column_alias Type Length Max length Is_null Flags Decimals Charsetnr
def test t1 v1 id id 3 10 0 Y 32768 0 63 def test v1 v1 id id 3 10 0 Y 32768 0 63
id id
select * from v1 where id=1000 group by id; select * from v1 where id=1000 group by id;
Catalog Database Table Table_alias Column Column_alias Type Length Max length Is_null Flags Decimals Charsetnr Catalog Database Table Table_alias Column Column_alias Type Length Max length Is_null Flags Decimals Charsetnr
def test t1 v1 id id 3 10 0 Y 32768 0 63 def test v1 v1 id id 3 10 0 Y 32768 0 63
id id
select * from v1 where id=1 group by id; select * from v1 where id=1 group by id;
Catalog Database Table Table_alias Column Column_alias Type Length Max length Is_null Flags Decimals Charsetnr Catalog Database Table Table_alias Column Column_alias Type Length Max length Is_null Flags Decimals Charsetnr
@ -126,7 +126,7 @@ renamed
1 1
select * from v3 where renamed=1 group by renamed; select * from v3 where renamed=1 group by renamed;
Catalog Database Table Table_alias Column Column_alias Type Length Max length Is_null Flags Decimals Charsetnr Catalog Database Table Table_alias Column Column_alias Type Length Max length Is_null Flags Decimals Charsetnr
def v3 renamed 8 12 0 Y 32896 0 63 def v3 v3 renamed renamed 8 12 0 Y 32896 0 63
renamed renamed
drop table t1; drop table t1;
drop view v1,v2,v3; drop view v1,v2,v3;
@ -156,8 +156,8 @@ c1
3 3
SELECT v1.c1, v2.c2 FROM v1 JOIN v2 ON c1=c2; SELECT v1.c1, v2.c2 FROM v1 JOIN v2 ON c1=c2;
Catalog Database Table Table_alias Column Column_alias Type Length Max length Is_null Flags Decimals Charsetnr Catalog Database Table Table_alias Column Column_alias Type Length Max length Is_null Flags Decimals Charsetnr
def test t1 v1 c1 c1 254 1 1 Y 0 0 8 def test v1 v1 c1 c1 254 1 1 Y 0 0 8
def test t2 v2 c2 c2 254 1 1 Y 0 0 8 def test v2 v2 c2 c2 254 1 1 Y 0 0 8
c1 c2 c1 c2
1 1 1 1
2 2 2 2

View file

@ -1831,6 +1831,28 @@ id ref
3 2 3 2
4 5 4 5
DROP TABLE t1, t2; DROP TABLE t1, t2;
CREATE TABLE t1 (a INT) ENGINE=MyISAM CHECKSUM=1 ROW_FORMAT=DYNAMIC;
INSERT INTO t1 VALUES (0);
UPDATE t1 SET a=1;
SELECT a FROM t1;
a
1
CHECK TABLE t1;
Table Op Msg_type Msg_text
test.t1 check status OK
INSERT INTO t1 VALUES (0), (5), (4), (2);
UPDATE t1 SET a=2;
SELECT a FROM t1;
a
2
2
2
2
2
CHECK TABLE t1;
Table Op Msg_type Msg_text
test.t1 check status OK
DROP TABLE t1;
End of 5.0 tests End of 5.0 tests
create table t1 (a int not null, key `a` (a) key_block_size=1024); create table t1 (a int not null, key `a` (a) key_block_size=1024);
show create table t1; show create table t1;

File diff suppressed because it is too large Load diff

View file

@ -0,0 +1,74 @@
#
# Preparatory cleanup.
#
DROP TABLE IF EXISTS t1;
#
# We need a fixed timestamp to avoid varying results.
#
SET timestamp=1000000000;
#
# We need big packets.
#
SET @@session.max_allowed_packet= 1024*1024*1024;
#
# Delete all existing binary logs.
#
RESET MASTER;
#
# Create a test table.
#
CREATE TABLE t1 (
c1 LONGTEXT
) ENGINE=MyISAM DEFAULT CHARSET latin1;
#
# Show how much rows are affected by each statement.
#
#
# Insert a big row.
#
INSERT INTO t1 VALUES (REPEAT('ManyMegaByteBlck', 2097152));
affected rows: 1
#
# Show what we have in the table.
# Do not display the column value itself, just its length.
#
SELECT LENGTH(c1) FROM t1;
LENGTH(c1) 33554432
affected rows: 1
#
# Grow the row by updating.
#
UPDATE t1 SET c1 = CONCAT(c1, c1);
affected rows: 1
info: Rows matched: 1 Changed: 1 Warnings: 0
#
# Show what we have in the table.
# Do not display the column value itself, just its length.
#
SELECT LENGTH(c1) FROM t1;
LENGTH(c1) 67108864
affected rows: 1
#
# Delete the row.
#
DELETE FROM t1 WHERE c1 >= 'ManyMegaByteBlck';
affected rows: 1
#
# Hide how much rows are affected by each statement.
#
#
# Flush all log buffers to the log file.
#
FLUSH LOGS;
#
# Call mysqlbinlog to display the log file contents.
# NOTE: The output of mysqlbinlog is redirected to
# $MYSQLTEST_VARDIR/tmp/mysqlbinlog_big_1.out
# If you want to examine it, disable remove_file
# at the bottom of the test script.
#
#
# Cleanup.
#
DROP TABLE t1;
remove_file $MYSQLTEST_VARDIR/tmp/mysqlbinlog_big_1.out

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

View file

@ -0,0 +1,500 @@
#
# Preparatory cleanup.
#
DROP TABLE IF EXISTS t1, t2;
#
# We need a fixed timestamp to avoid varying results.
#
SET timestamp=1000000000;
#
# Delete all existing binary logs.
#
RESET MASTER;
#
# Create test tables.
#
CREATE TABLE t1 (
c1 INT,
c2 VARCHAR(20)
) ENGINE=InnoDB DEFAULT CHARSET latin1;
CREATE TABLE t2 (
c1 INT,
c2 VARCHAR(20)
) ENGINE=MyISAM DEFAULT CHARSET latin1;
#
# Start transaction #1, transactional table only, commit.
#
START TRANSACTION;
#
# Do some statements.
#
INSERT INTO t1 VALUES (1,'varchar-1'), (2,'varchar-2'), (3,'varchar-3');
UPDATE t1 SET c1 = c1 + 10;
DELETE FROM t1 WHERE c1 = 12;
#
# Commit transaction.
#
COMMIT;
SELECT * FROM t1;
c1 c2
11 varchar-1
13 varchar-3
TRUNCATE TABLE t1;
#
# Start transaction #2, transactional table only, rollback.
#
START TRANSACTION;
#
# Do some statements.
#
INSERT INTO t1 VALUES (1,'varchar-1'), (2,'varchar-2'), (3,'varchar-3');
UPDATE t1 SET c1 = c1 + 10;
DELETE FROM t1 WHERE c1 = 12;
#
# Rollback transaction.
#
ROLLBACK;
SELECT * FROM t1;
c1 c2
TRUNCATE TABLE t1;
#
# Start transaction #3, both tables, commit.
#
START TRANSACTION;
#
# Do some statements on the transactional table.
#
INSERT INTO t1 VALUES (1,'varchar-1'), (2,'varchar-2'), (3,'varchar-3');
UPDATE t1 SET c1 = c1 + 10;
DELETE FROM t1 WHERE c1 = 12;
#
# Do some statements on the non-transactional table.
#
INSERT INTO t2 VALUES (1,'varchar-1'), (2,'varchar-2'), (3,'varchar-3');
UPDATE t2 SET c1 = c1 + 10;
DELETE FROM t2 WHERE c1 = 12;
#
# Commit transaction.
#
COMMIT;
SELECT * FROM t1;
c1 c2
11 varchar-1
13 varchar-3
SELECT * FROM t2;
c1 c2
11 varchar-1
13 varchar-3
TRUNCATE TABLE t1;
TRUNCATE TABLE t2;
#
# Start transaction #4, both tables, rollback.
#
START TRANSACTION;
#
# Do some statements on the transactional table.
#
INSERT INTO t1 VALUES (1,'varchar-1'), (2,'varchar-2'), (3,'varchar-3');
UPDATE t1 SET c1 = c1 + 10;
DELETE FROM t1 WHERE c1 = 12;
#
# Do some statements on the non-transactional table.
#
INSERT INTO t2 VALUES (1,'varchar-1'), (2,'varchar-2'), (3,'varchar-3');
UPDATE t2 SET c1 = c1 + 10;
DELETE FROM t2 WHERE c1 = 12;
#
# Rollback transaction.
#
ROLLBACK;
Warnings:
Warning 1196 Some non-transactional changed tables couldn't be rolled back
SELECT * FROM t1;
c1 c2
SELECT * FROM t2;
c1 c2
11 varchar-1
13 varchar-3
TRUNCATE TABLE t1;
TRUNCATE TABLE t2;
#
# Flush all log buffers to the log file.
#
FLUSH LOGS;
#
# Call mysqlbinlog to display the log file contents.
#
/*!40019 SET @@session.max_insert_delayed_threads=0*/;
/*!50003 SET @OLD_COMPLETION_TYPE=@@COMPLETION_TYPE,COMPLETION_TYPE=0*/;
DELIMITER /*!*/;
# at #
#010909 4:46:40 server id 1 end_log_pos # Start: binlog v 4, server v #.##.## created 010909 4:46:40 at startup
ROLLBACK/*!*/;
# at #
#010909 4:46:40 server id 1 end_log_pos # Query thread_id=# exec_time=# error_code=0
use test/*!*/;
SET TIMESTAMP=1000000000/*!*/;
SET @@session.pseudo_thread_id=#/*!*/;
SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=1, @@session.unique_checks=1/*!*/;
SET @@session.sql_mode=0/*!*/;
SET @@session.auto_increment_increment=1, @@session.auto_increment_offset=1/*!*/;
/*!\C latin1 *//*!*/;
SET @@session.character_set_client=8,@@session.collation_connection=8,@@session.collation_server=8/*!*/;
SET @@session.lc_time_names=0/*!*/;
SET @@session.collation_database=DEFAULT/*!*/;
CREATE TABLE t1 (
c1 INT,
c2 VARCHAR(20)
) ENGINE=InnoDB DEFAULT CHARSET latin1
/*!*/;
# at #
#010909 4:46:40 server id 1 end_log_pos # Query thread_id=# exec_time=# error_code=0
SET TIMESTAMP=1000000000/*!*/;
CREATE TABLE t2 (
c1 INT,
c2 VARCHAR(20)
) ENGINE=MyISAM DEFAULT CHARSET latin1
/*!*/;
# at #
#010909 4:46:40 server id 1 end_log_pos # Query thread_id=# exec_time=# error_code=0
SET TIMESTAMP=1000000000/*!*/;
BEGIN
/*!*/;
# at #
# at #
#010909 4:46:40 server id 1 end_log_pos # Table_map: `test`.`t1` mapped to number #
#010909 4:46:40 server id 1 end_log_pos # Write_rows: table id # flags: STMT_END_F
### INSERT INTO test.t1
### SET
### @1=1 /* INT meta=0 nullable=1 is_null=0 */
### @2='varchar-1' /* VARSTRING(20) meta=20 nullable=1 is_null=0 */
### INSERT INTO test.t1
### SET
### @1=2 /* INT meta=0 nullable=1 is_null=0 */
### @2='varchar-2' /* VARSTRING(20) meta=20 nullable=1 is_null=0 */
### INSERT INTO test.t1
### SET
### @1=3 /* INT meta=0 nullable=1 is_null=0 */
### @2='varchar-3' /* VARSTRING(20) meta=20 nullable=1 is_null=0 */
# at #
# at #
#010909 4:46:40 server id 1 end_log_pos # Table_map: `test`.`t1` mapped to number #
#010909 4:46:40 server id 1 end_log_pos # Update_rows: table id # flags: STMT_END_F
### UPDATE test.t1
### WHERE
### @1=1 /* INT meta=0 nullable=1 is_null=0 */
### @2='varchar-1' /* VARSTRING(20) meta=20 nullable=1 is_null=0 */
### SET
### @1=11 /* INT meta=0 nullable=1 is_null=0 */
### @2='varchar-1' /* VARSTRING(20) meta=20 nullable=1 is_null=0 */
### UPDATE test.t1
### WHERE
### @1=2 /* INT meta=0 nullable=1 is_null=0 */
### @2='varchar-2' /* VARSTRING(20) meta=20 nullable=1 is_null=0 */
### SET
### @1=12 /* INT meta=0 nullable=1 is_null=0 */
### @2='varchar-2' /* VARSTRING(20) meta=20 nullable=1 is_null=0 */
### UPDATE test.t1
### WHERE
### @1=3 /* INT meta=0 nullable=1 is_null=0 */
### @2='varchar-3' /* VARSTRING(20) meta=20 nullable=1 is_null=0 */
### SET
### @1=13 /* INT meta=0 nullable=1 is_null=0 */
### @2='varchar-3' /* VARSTRING(20) meta=20 nullable=1 is_null=0 */
# at #
# at #
#010909 4:46:40 server id 1 end_log_pos # Table_map: `test`.`t1` mapped to number #
#010909 4:46:40 server id 1 end_log_pos # Delete_rows: table id # flags: STMT_END_F
### DELETE FROM test.t1
### WHERE
### @1=12 /* INT meta=0 nullable=1 is_null=0 */
### @2='varchar-2' /* VARSTRING(20) meta=20 nullable=1 is_null=0 */
# at #
#010909 4:46:40 server id 1 end_log_pos # Xid = #
COMMIT/*!*/;
# at #
#010909 4:46:40 server id 1 end_log_pos # Query thread_id=# exec_time=# error_code=0
SET TIMESTAMP=1000000000/*!*/;
BEGIN
/*!*/;
# at #
#010909 4:46:40 server id 1 end_log_pos # Query thread_id=# exec_time=# error_code=0
SET TIMESTAMP=1000000000/*!*/;
TRUNCATE TABLE t1
/*!*/;
# at #
#010909 4:46:40 server id 1 end_log_pos # Xid = #
COMMIT/*!*/;
# at #
#010909 4:46:40 server id 1 end_log_pos # Query thread_id=# exec_time=# error_code=0
SET TIMESTAMP=1000000000/*!*/;
BEGIN
/*!*/;
# at #
#010909 4:46:40 server id 1 end_log_pos # Query thread_id=# exec_time=# error_code=0
SET TIMESTAMP=1000000000/*!*/;
TRUNCATE TABLE t1
/*!*/;
# at #
#010909 4:46:40 server id 1 end_log_pos # Xid = #
COMMIT/*!*/;
# at #
#010909 4:46:40 server id 1 end_log_pos # Query thread_id=# exec_time=# error_code=0
SET TIMESTAMP=1000000000/*!*/;
BEGIN
/*!*/;
# at #
# at #
#010909 4:46:40 server id 1 end_log_pos # Table_map: `test`.`t1` mapped to number #
#010909 4:46:40 server id 1 end_log_pos # Write_rows: table id # flags: STMT_END_F
### INSERT INTO test.t1
### SET
### @1=1 /* INT meta=0 nullable=1 is_null=0 */
### @2='varchar-1' /* VARSTRING(20) meta=20 nullable=1 is_null=0 */
### INSERT INTO test.t1
### SET
### @1=2 /* INT meta=0 nullable=1 is_null=0 */
### @2='varchar-2' /* VARSTRING(20) meta=20 nullable=1 is_null=0 */
### INSERT INTO test.t1
### SET
### @1=3 /* INT meta=0 nullable=1 is_null=0 */
### @2='varchar-3' /* VARSTRING(20) meta=20 nullable=1 is_null=0 */
# at #
# at #
#010909 4:46:40 server id 1 end_log_pos # Table_map: `test`.`t1` mapped to number #
#010909 4:46:40 server id 1 end_log_pos # Update_rows: table id # flags: STMT_END_F
### UPDATE test.t1
### WHERE
### @1=1 /* INT meta=0 nullable=1 is_null=0 */
### @2='varchar-1' /* VARSTRING(20) meta=20 nullable=1 is_null=0 */
### SET
### @1=11 /* INT meta=0 nullable=1 is_null=0 */
### @2='varchar-1' /* VARSTRING(20) meta=20 nullable=1 is_null=0 */
### UPDATE test.t1
### WHERE
### @1=2 /* INT meta=0 nullable=1 is_null=0 */
### @2='varchar-2' /* VARSTRING(20) meta=20 nullable=1 is_null=0 */
### SET
### @1=12 /* INT meta=0 nullable=1 is_null=0 */
### @2='varchar-2' /* VARSTRING(20) meta=20 nullable=1 is_null=0 */
### UPDATE test.t1
### WHERE
### @1=3 /* INT meta=0 nullable=1 is_null=0 */
### @2='varchar-3' /* VARSTRING(20) meta=20 nullable=1 is_null=0 */
### SET
### @1=13 /* INT meta=0 nullable=1 is_null=0 */
### @2='varchar-3' /* VARSTRING(20) meta=20 nullable=1 is_null=0 */
# at #
# at #
#010909 4:46:40 server id 1 end_log_pos # Table_map: `test`.`t1` mapped to number #
#010909 4:46:40 server id 1 end_log_pos # Delete_rows: table id # flags: STMT_END_F
### DELETE FROM test.t1
### WHERE
### @1=12 /* INT meta=0 nullable=1 is_null=0 */
### @2='varchar-2' /* VARSTRING(20) meta=20 nullable=1 is_null=0 */
# at #
# at #
#010909 4:46:40 server id 1 end_log_pos # Table_map: `test`.`t2` mapped to number #
#010909 4:46:40 server id 1 end_log_pos # Write_rows: table id # flags: STMT_END_F
### INSERT INTO test.t2
### SET
### @1=1 /* INT meta=0 nullable=1 is_null=0 */
### @2='varchar-1' /* VARSTRING(20) meta=20 nullable=1 is_null=0 */
### INSERT INTO test.t2
### SET
### @1=2 /* INT meta=0 nullable=1 is_null=0 */
### @2='varchar-2' /* VARSTRING(20) meta=20 nullable=1 is_null=0 */
### INSERT INTO test.t2
### SET
### @1=3 /* INT meta=0 nullable=1 is_null=0 */
### @2='varchar-3' /* VARSTRING(20) meta=20 nullable=1 is_null=0 */
# at #
# at #
#010909 4:46:40 server id 1 end_log_pos # Table_map: `test`.`t2` mapped to number #
#010909 4:46:40 server id 1 end_log_pos # Update_rows: table id # flags: STMT_END_F
### UPDATE test.t2
### WHERE
### @1=1 /* INT meta=0 nullable=1 is_null=0 */
### @2='varchar-1' /* VARSTRING(20) meta=20 nullable=1 is_null=0 */
### SET
### @1=11 /* INT meta=0 nullable=1 is_null=0 */
### @2='varchar-1' /* VARSTRING(20) meta=20 nullable=1 is_null=0 */
### UPDATE test.t2
### WHERE
### @1=2 /* INT meta=0 nullable=1 is_null=0 */
### @2='varchar-2' /* VARSTRING(20) meta=20 nullable=1 is_null=0 */
### SET
### @1=12 /* INT meta=0 nullable=1 is_null=0 */
### @2='varchar-2' /* VARSTRING(20) meta=20 nullable=1 is_null=0 */
### UPDATE test.t2
### WHERE
### @1=3 /* INT meta=0 nullable=1 is_null=0 */
### @2='varchar-3' /* VARSTRING(20) meta=20 nullable=1 is_null=0 */
### SET
### @1=13 /* INT meta=0 nullable=1 is_null=0 */
### @2='varchar-3' /* VARSTRING(20) meta=20 nullable=1 is_null=0 */
# at #
# at #
#010909 4:46:40 server id 1 end_log_pos # Table_map: `test`.`t2` mapped to number #
#010909 4:46:40 server id 1 end_log_pos # Delete_rows: table id # flags: STMT_END_F
### DELETE FROM test.t2
### WHERE
### @1=12 /* INT meta=0 nullable=1 is_null=0 */
### @2='varchar-2' /* VARSTRING(20) meta=20 nullable=1 is_null=0 */
# at #
#010909 4:46:40 server id 1 end_log_pos # Xid = #
COMMIT/*!*/;
# at #
#010909 4:46:40 server id 1 end_log_pos # Query thread_id=# exec_time=# error_code=0
SET TIMESTAMP=1000000000/*!*/;
BEGIN
/*!*/;
# at #
#010909 4:46:40 server id 1 end_log_pos # Query thread_id=# exec_time=# error_code=0
SET TIMESTAMP=1000000000/*!*/;
TRUNCATE TABLE t1
/*!*/;
# at #
#010909 4:46:40 server id 1 end_log_pos # Xid = #
COMMIT/*!*/;
# at #
#010909 4:46:40 server id 1 end_log_pos # Query thread_id=# exec_time=# error_code=0
SET TIMESTAMP=1000000000/*!*/;
TRUNCATE TABLE t2
/*!*/;
# at #
#010909 4:46:40 server id 1 end_log_pos # Query thread_id=# exec_time=# error_code=0
SET TIMESTAMP=1000000000/*!*/;
BEGIN
/*!*/;
# at #
# at #
#010909 4:46:40 server id 1 end_log_pos # Table_map: `test`.`t1` mapped to number #
#010909 4:46:40 server id 1 end_log_pos # Write_rows: table id # flags: STMT_END_F
### INSERT INTO test.t1
### SET
### @1=1 /* INT meta=0 nullable=1 is_null=0 */
### @2='varchar-1' /* VARSTRING(20) meta=20 nullable=1 is_null=0 */
### INSERT INTO test.t1
### SET
### @1=2 /* INT meta=0 nullable=1 is_null=0 */
### @2='varchar-2' /* VARSTRING(20) meta=20 nullable=1 is_null=0 */
### INSERT INTO test.t1
### SET
### @1=3 /* INT meta=0 nullable=1 is_null=0 */
### @2='varchar-3' /* VARSTRING(20) meta=20 nullable=1 is_null=0 */
# at #
# at #
#010909 4:46:40 server id 1 end_log_pos # Table_map: `test`.`t1` mapped to number #
#010909 4:46:40 server id 1 end_log_pos # Update_rows: table id # flags: STMT_END_F
### UPDATE test.t1
### WHERE
### @1=1 /* INT meta=0 nullable=1 is_null=0 */
### @2='varchar-1' /* VARSTRING(20) meta=20 nullable=1 is_null=0 */
### SET
### @1=11 /* INT meta=0 nullable=1 is_null=0 */
### @2='varchar-1' /* VARSTRING(20) meta=20 nullable=1 is_null=0 */
### UPDATE test.t1
### WHERE
### @1=2 /* INT meta=0 nullable=1 is_null=0 */
### @2='varchar-2' /* VARSTRING(20) meta=20 nullable=1 is_null=0 */
### SET
### @1=12 /* INT meta=0 nullable=1 is_null=0 */
### @2='varchar-2' /* VARSTRING(20) meta=20 nullable=1 is_null=0 */
### UPDATE test.t1
### WHERE
### @1=3 /* INT meta=0 nullable=1 is_null=0 */
### @2='varchar-3' /* VARSTRING(20) meta=20 nullable=1 is_null=0 */
### SET
### @1=13 /* INT meta=0 nullable=1 is_null=0 */
### @2='varchar-3' /* VARSTRING(20) meta=20 nullable=1 is_null=0 */
# at #
# at #
#010909 4:46:40 server id 1 end_log_pos # Table_map: `test`.`t1` mapped to number #
#010909 4:46:40 server id 1 end_log_pos # Delete_rows: table id # flags: STMT_END_F
### DELETE FROM test.t1
### WHERE
### @1=12 /* INT meta=0 nullable=1 is_null=0 */
### @2='varchar-2' /* VARSTRING(20) meta=20 nullable=1 is_null=0 */
# at #
# at #
#010909 4:46:40 server id 1 end_log_pos # Table_map: `test`.`t2` mapped to number #
#010909 4:46:40 server id 1 end_log_pos # Write_rows: table id # flags: STMT_END_F
### INSERT INTO test.t2
### SET
### @1=1 /* INT meta=0 nullable=1 is_null=0 */
### @2='varchar-1' /* VARSTRING(20) meta=20 nullable=1 is_null=0 */
### INSERT INTO test.t2
### SET
### @1=2 /* INT meta=0 nullable=1 is_null=0 */
### @2='varchar-2' /* VARSTRING(20) meta=20 nullable=1 is_null=0 */
### INSERT INTO test.t2
### SET
### @1=3 /* INT meta=0 nullable=1 is_null=0 */
### @2='varchar-3' /* VARSTRING(20) meta=20 nullable=1 is_null=0 */
# at #
# at #
#010909 4:46:40 server id 1 end_log_pos # Table_map: `test`.`t2` mapped to number #
#010909 4:46:40 server id 1 end_log_pos # Update_rows: table id # flags: STMT_END_F
### UPDATE test.t2
### WHERE
### @1=1 /* INT meta=0 nullable=1 is_null=0 */
### @2='varchar-1' /* VARSTRING(20) meta=20 nullable=1 is_null=0 */
### SET
### @1=11 /* INT meta=0 nullable=1 is_null=0 */
### @2='varchar-1' /* VARSTRING(20) meta=20 nullable=1 is_null=0 */
### UPDATE test.t2
### WHERE
### @1=2 /* INT meta=0 nullable=1 is_null=0 */
### @2='varchar-2' /* VARSTRING(20) meta=20 nullable=1 is_null=0 */
### SET
### @1=12 /* INT meta=0 nullable=1 is_null=0 */
### @2='varchar-2' /* VARSTRING(20) meta=20 nullable=1 is_null=0 */
### UPDATE test.t2
### WHERE
### @1=3 /* INT meta=0 nullable=1 is_null=0 */
### @2='varchar-3' /* VARSTRING(20) meta=20 nullable=1 is_null=0 */
### SET
### @1=13 /* INT meta=0 nullable=1 is_null=0 */
### @2='varchar-3' /* VARSTRING(20) meta=20 nullable=1 is_null=0 */
# at #
# at #
#010909 4:46:40 server id 1 end_log_pos # Table_map: `test`.`t2` mapped to number #
#010909 4:46:40 server id 1 end_log_pos # Delete_rows: table id # flags: STMT_END_F
### DELETE FROM test.t2
### WHERE
### @1=12 /* INT meta=0 nullable=1 is_null=0 */
### @2='varchar-2' /* VARSTRING(20) meta=20 nullable=1 is_null=0 */
# at #
#010909 4:46:40 server id 1 end_log_pos # Query thread_id=# exec_time=# error_code=0
SET TIMESTAMP=1000000000/*!*/;
ROLLBACK
/*!*/;
# at #
#010909 4:46:40 server id 1 end_log_pos # Query thread_id=# exec_time=# error_code=0
SET TIMESTAMP=1000000000/*!*/;
BEGIN
/*!*/;
# at #
#010909 4:46:40 server id 1 end_log_pos # Query thread_id=# exec_time=# error_code=0
SET TIMESTAMP=1000000000/*!*/;
TRUNCATE TABLE t1
/*!*/;
# at #
#010909 4:46:40 server id 1 end_log_pos # Xid = #
COMMIT/*!*/;
# at #
#010909 4:46:40 server id 1 end_log_pos # Query thread_id=# exec_time=# error_code=0
SET TIMESTAMP=1000000000/*!*/;
TRUNCATE TABLE t2
/*!*/;
# at #
#010909 4:46:40 server id 1 end_log_pos # Rotate to master-bin.000002 pos: 4
DELIMITER ;
# End of log file
ROLLBACK /* added by mysqlbinlog */;
/*!50003 SET COMPLETION_TYPE=@OLD_COMPLETION_TYPE*/;
#
# Cleanup.
#
DROP TABLE t1, t2;

View file

@ -14,6 +14,7 @@ select otto from (select 1 as otto) as t1;
otto otto
1 1
mysqltest: At line 1: query 'select otto from (select 1 as otto) as t1' succeeded - should have failed with sqlstate 42S22... mysqltest: At line 1: query 'select otto from (select 1 as otto) as t1' succeeded - should have failed with sqlstate 42S22...
mysqltest: At line 1: expecting a SQL-state (00000) from query 'remove_file MYSQLTEST_VARDIR/tmp/test_nonexistent.tmp' which cannot produce one...
select friedrich from (select 1 as otto) as t1; select friedrich from (select 1 as otto) as t1;
ERROR 42S22: Unknown column 'friedrich' in 'field list' ERROR 42S22: Unknown column 'friedrich' in 'field list'
mysqltest: At line 1: query 'select friedrich from (select 1 as otto) as t1' failed with wrong sqlstate 42S22: 'Unknown column 'friedrich' in 'field list'', instead of 00000... mysqltest: At line 1: query 'select friedrich from (select 1 as otto) as t1' failed with wrong sqlstate 42S22: 'Unknown column 'friedrich' in 'field list'', instead of 00000...
@ -725,6 +726,9 @@ drop table t1;
mysqltest: At line 1: change user failed: Unknown database 'inexistent' mysqltest: At line 1: change user failed: Unknown database 'inexistent'
mysqltest: At line 1: change user failed: Access denied for user 'inexistent'@'localhost' (using password: NO) mysqltest: At line 1: change user failed: Access denied for user 'inexistent'@'localhost' (using password: NO)
mysqltest: At line 1: change user failed: Access denied for user 'root'@'localhost' (using password: YES) mysqltest: At line 1: change user failed: Access denied for user 'root'@'localhost' (using password: YES)
file1.txt
file1.txt
file2.txt
SELECT 'c:\\a.txt' AS col; SELECT 'c:\\a.txt' AS col;
col col
z z

View file

@ -284,6 +284,74 @@ Field Type Null Key Default Extra
DROP TABLE table_25930_a; DROP TABLE table_25930_a;
DROP TABLE table_25930_b; DROP TABLE table_25930_b;
SET @@sql_mode=@save_sql_mode; SET @@sql_mode=@save_sql_mode;
DROP PROCEDURE IF EXISTS p26030;
select "non terminated"$$
non terminated
non terminated
select "terminated";$$
terminated
terminated
select "non terminated, space" $$
non terminated, space
non terminated, space
select "terminated, space"; $$
terminated, space
terminated, space
select "non terminated, comment" /* comment */$$
non terminated, comment
non terminated, comment
select "terminated, comment"; /* comment */$$
terminated, comment
terminated, comment
select "stmt 1";select "stmt 2 non terminated"$$
stmt 1
stmt 1
stmt 2 non terminated
stmt 2 non terminated
select "stmt 1";select "stmt 2 terminated";$$
stmt 1
stmt 1
stmt 2 terminated
stmt 2 terminated
select "stmt 1";select "stmt 2 non terminated, space" $$
stmt 1
stmt 1
stmt 2 non terminated, space
stmt 2 non terminated, space
select "stmt 1";select "stmt 2 terminated, space"; $$
stmt 1
stmt 1
stmt 2 terminated, space
stmt 2 terminated, space
select "stmt 1";select "stmt 2 non terminated, comment" /* comment */$$
stmt 1
stmt 1
stmt 2 non terminated, comment
stmt 2 non terminated, comment
select "stmt 1";select "stmt 2 terminated, comment"; /* comment */$$
stmt 1
stmt 1
stmt 2 terminated, comment
stmt 2 terminated, comment
select "stmt 1"; select "space, stmt 2"$$
stmt 1
stmt 1
space, stmt 2
space, stmt 2
select "stmt 1";/* comment */select "comment, stmt 2"$$
stmt 1
stmt 1
comment, stmt 2
comment, stmt 2
DROP PROCEDURE IF EXISTS p26030; CREATE PROCEDURE p26030() BEGIN SELECT 1; END; CALL p26030()
$$
1
1
DROP PROCEDURE IF EXISTS p26030; CREATE PROCEDURE p26030() SELECT 1; CALL p26030()
$$
1
1
DROP PROCEDURE p26030;
select pi(3.14); select pi(3.14);
ERROR 42000: Incorrect parameter count in the call to native function 'pi' ERROR 42000: Incorrect parameter count in the call to native function 'pi'
select tan(); select tan();

View file

@ -0,0 +1,306 @@
use test;
SELECT
((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((
((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((
((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((
1
))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))
))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))
))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))
;
1
1
prepare stmt from
"
SELECT
((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((
((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((
((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((
1
))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))
))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))
))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))
"
;
execute stmt;
1
1
drop view if exists view_overflow;
CREATE VIEW view_overflow AS
SELECT
((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((
((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((
((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((
1
))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))
))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))
))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))
;
SELECT * from view_overflow;
1
1
drop view view_overflow;
drop procedure if exists proc_overflow;
CREATE PROCEDURE proc_overflow()
BEGIN
BEGIN BEGIN BEGIN BEGIN BEGIN BEGIN BEGIN BEGIN BEGIN BEGIN BEGIN BEGIN
BEGIN BEGIN BEGIN BEGIN BEGIN BEGIN BEGIN BEGIN BEGIN BEGIN BEGIN BEGIN
BEGIN BEGIN BEGIN BEGIN BEGIN BEGIN BEGIN BEGIN BEGIN BEGIN BEGIN BEGIN
BEGIN BEGIN BEGIN BEGIN BEGIN BEGIN BEGIN BEGIN BEGIN BEGIN BEGIN BEGIN
BEGIN BEGIN BEGIN BEGIN BEGIN BEGIN BEGIN BEGIN BEGIN BEGIN BEGIN BEGIN
BEGIN BEGIN BEGIN BEGIN BEGIN BEGIN BEGIN BEGIN BEGIN BEGIN BEGIN BEGIN
BEGIN BEGIN BEGIN BEGIN BEGIN BEGIN BEGIN BEGIN BEGIN BEGIN BEGIN BEGIN
BEGIN BEGIN BEGIN BEGIN BEGIN BEGIN BEGIN BEGIN BEGIN BEGIN BEGIN BEGIN
BEGIN BEGIN BEGIN BEGIN BEGIN BEGIN BEGIN BEGIN BEGIN BEGIN BEGIN BEGIN
BEGIN BEGIN BEGIN BEGIN BEGIN BEGIN BEGIN BEGIN BEGIN BEGIN BEGIN BEGIN
select 1;
select 2;
select 3;
END; END; END; END; END; END; END; END; END; END; END; END;
END; END; END; END; END; END; END; END; END; END; END; END;
END; END; END; END; END; END; END; END; END; END; END; END;
END; END; END; END; END; END; END; END; END; END; END; END;
END; END; END; END; END; END; END; END; END; END; END; END;
END; END; END; END; END; END; END; END; END; END; END; END;
END; END; END; END; END; END; END; END; END; END; END; END;
END; END; END; END; END; END; END; END; END; END; END; END;
END; END; END; END; END; END; END; END; END; END; END; END;
END; END; END; END; END; END; END; END; END; END; END; END;
END $$
call proc_overflow();
1
1
2
2
3
3
drop procedure proc_overflow;
drop function if exists func_overflow;
create function func_overflow() returns int
BEGIN
DECLARE x int default 0;
BEGIN BEGIN BEGIN BEGIN BEGIN BEGIN BEGIN BEGIN BEGIN BEGIN BEGIN BEGIN
BEGIN BEGIN BEGIN BEGIN BEGIN BEGIN BEGIN BEGIN BEGIN BEGIN BEGIN BEGIN
BEGIN BEGIN BEGIN BEGIN BEGIN BEGIN BEGIN BEGIN BEGIN BEGIN BEGIN BEGIN
BEGIN BEGIN BEGIN BEGIN BEGIN BEGIN BEGIN BEGIN BEGIN BEGIN BEGIN BEGIN
BEGIN BEGIN BEGIN BEGIN BEGIN BEGIN BEGIN BEGIN BEGIN BEGIN BEGIN BEGIN
BEGIN BEGIN BEGIN BEGIN BEGIN BEGIN BEGIN BEGIN BEGIN BEGIN BEGIN BEGIN
BEGIN BEGIN BEGIN BEGIN BEGIN BEGIN BEGIN BEGIN BEGIN BEGIN BEGIN BEGIN
BEGIN BEGIN BEGIN BEGIN BEGIN BEGIN BEGIN BEGIN BEGIN BEGIN BEGIN BEGIN
BEGIN BEGIN BEGIN BEGIN BEGIN BEGIN BEGIN BEGIN BEGIN BEGIN BEGIN BEGIN
BEGIN BEGIN BEGIN BEGIN BEGIN BEGIN BEGIN BEGIN BEGIN BEGIN BEGIN BEGIN
SET x=x+1;
SET x=x+2;
SET x=x+3;
END; END; END; END; END; END; END; END; END; END; END; END;
END; END; END; END; END; END; END; END; END; END; END; END;
END; END; END; END; END; END; END; END; END; END; END; END;
END; END; END; END; END; END; END; END; END; END; END; END;
END; END; END; END; END; END; END; END; END; END; END; END;
END; END; END; END; END; END; END; END; END; END; END; END;
END; END; END; END; END; END; END; END; END; END; END; END;
END; END; END; END; END; END; END; END; END; END; END; END;
END; END; END; END; END; END; END; END; END; END; END; END;
END; END; END; END; END; END; END; END; END; END; END; END;
return x;
END $$
select func_overflow();
func_overflow()
6
drop function func_overflow;
drop table if exists table_overflow;
create table table_overflow(a int, b int);
create trigger trigger_overflow before insert on table_overflow
for each row
BEGIN
BEGIN BEGIN BEGIN BEGIN BEGIN BEGIN BEGIN BEGIN BEGIN BEGIN BEGIN BEGIN
BEGIN BEGIN BEGIN BEGIN BEGIN BEGIN BEGIN BEGIN BEGIN BEGIN BEGIN BEGIN
BEGIN BEGIN BEGIN BEGIN BEGIN BEGIN BEGIN BEGIN BEGIN BEGIN BEGIN BEGIN
BEGIN BEGIN BEGIN BEGIN BEGIN BEGIN BEGIN BEGIN BEGIN BEGIN BEGIN BEGIN
BEGIN BEGIN BEGIN BEGIN BEGIN BEGIN BEGIN BEGIN BEGIN BEGIN BEGIN BEGIN
BEGIN BEGIN BEGIN BEGIN BEGIN BEGIN BEGIN BEGIN BEGIN BEGIN BEGIN BEGIN
BEGIN BEGIN BEGIN BEGIN BEGIN BEGIN BEGIN BEGIN BEGIN BEGIN BEGIN BEGIN
BEGIN BEGIN BEGIN BEGIN BEGIN BEGIN BEGIN BEGIN BEGIN BEGIN BEGIN BEGIN
BEGIN BEGIN BEGIN BEGIN BEGIN BEGIN BEGIN BEGIN BEGIN BEGIN BEGIN BEGIN
BEGIN BEGIN BEGIN BEGIN BEGIN BEGIN BEGIN BEGIN BEGIN BEGIN BEGIN BEGIN
SET NEW.b := NEW.a;
SET NEW.b := NEW.b + 1;
SET NEW.b := NEW.b + 2;
SET NEW.b := NEW.b + 3;
END; END; END; END; END; END; END; END; END; END; END; END;
END; END; END; END; END; END; END; END; END; END; END; END;
END; END; END; END; END; END; END; END; END; END; END; END;
END; END; END; END; END; END; END; END; END; END; END; END;
END; END; END; END; END; END; END; END; END; END; END; END;
END; END; END; END; END; END; END; END; END; END; END; END;
END; END; END; END; END; END; END; END; END; END; END; END;
END; END; END; END; END; END; END; END; END; END; END; END;
END; END; END; END; END; END; END; END; END; END; END; END;
END; END; END; END; END; END; END; END; END; END; END; END;
END $$
insert into table_overflow set a=10;
insert into table_overflow set a=20;
select * from table_overflow;
a b
10 16
20 26
drop table table_overflow;
drop procedure if exists proc_35577;
CREATE PROCEDURE proc_35577()
BEGIN
DECLARE z_done INT DEFAULT 0;
DECLARE t_done VARCHAR(5000);
outer_loop: LOOP
IF t_done=1 THEN
LEAVE outer_loop;
END IF;
inner_block:BEGIN
DECLARE z_done INT DEFAULT 0;
SET z_done = 0;
inner_loop: LOOP
IF z_done=1 THEN
LEAVE inner_loop;
END IF;
IF (t_done = 'a') THEN
IF (t_done <> 0) THEN
IF ( t_done > 0) THEN
IF (t_done = 'a') THEN
SET t_done = 'a';
ELSEIF (t_done = 'a') THEN
SET t_done = 'a';
ELSEIF(t_done = 'a') THEN
SET t_done = 'a';
ELSEIF(t_done = 'a') THEN
SET t_done = 'a';
ELSEIF(t_done = 'a') THEN
SET t_done = 'a';
ELSEIF(t_done = 'a') THEN
SET t_done = 'a';
ELSEIF(t_done = 'a') THEN
SET t_done = 'a';
ELSEIF(t_done = 'a') THEN
SET t_done = 'a';
END IF;
END IF;
END IF;
END IF;
END LOOP inner_loop;
END inner_block;
END LOOP outer_loop;
END $$
drop procedure proc_35577;
drop procedure if exists p_37269;
create procedure p_37269()
begin
declare done int default 0;
declare varb int default 0;
declare vara int default 0;
repeat
select now();
until done end repeat;
while varb do
select now();
begin
select now();
repeat
select now();
until done end repeat;
if vara then
select now();
repeat
select now();
loop
select now();
end loop;
repeat
select now();
label1: while varb do
select now();
end while label1;
if vara then
select now();
repeat
select now();
until done end repeat;
begin
select now();
while varb do
select now();
label1: while varb do
select now();
end while label1;
if vara then
select now();
while varb do
select now();
loop
select now();
end loop;
repeat
select now();
loop
select now();
while varb do
select now();
end while;
repeat
select now();
label1: loop
select now();
if vara then
select now();
end if;
end loop label1;
until done end repeat;
end loop;
until done end repeat;
end while;
end if;
end while;
end;
end if;
until done end repeat;
until done end repeat;
end if;
end;
end while;
end $$
drop procedure p_37269;
drop procedure if exists p_37228;
create procedure p_37228 ()
BEGIN
DECLARE v INT DEFAULT 123;
IF (v > 1) THEN SET v = 1;
ELSEIF (v < 10) THEN SET v = 10;
ELSEIF (v < 11) THEN SET v = 11;
ELSEIF (v < 12) THEN SET v = 12;
ELSEIF (v < 13) THEN SET v = 13;
ELSEIF (v < 14) THEN SET v = 14;
ELSEIF (v < 15) THEN SET v = 15;
ELSEIF (v < 16) THEN SET v = 16;
ELSEIF (v < 17) THEN SET v = 17;
ELSEIF (v < 18) THEN SET v = 18;
ELSEIF (v < 19) THEN SET v = 19;
ELSEIF (v < 20) THEN SET v = 20;
ELSEIF (v < 21) THEN SET v = 21;
ELSEIF (v < 22) THEN SET v = 22;
ELSEIF (v < 23) THEN SET v = 23;
ELSEIF (v < 24) THEN SET v = 24;
ELSEIF (v < 25) THEN SET v = 25;
ELSEIF (v < 26) THEN SET v = 26;
ELSEIF (v < 27) THEN SET v = 27;
ELSEIF (v < 28) THEN SET v = 28;
ELSEIF (v < 29) THEN SET v = 29;
ELSEIF (v < 30) THEN SET v = 30;
ELSEIF (v < 31) THEN SET v = 31;
ELSEIF (v < 32) THEN SET v = 32;
ELSEIF (v < 33) THEN SET v = 33;
ELSEIF (v < 34) THEN SET v = 34;
ELSEIF (v < 35) THEN SET v = 35;
ELSEIF (v < 36) THEN SET v = 36;
ELSEIF (v < 37) THEN SET v = 37;
ELSEIF (v < 38) THEN SET v = 38;
ELSEIF (v < 39) THEN SET v = 39;
END IF;
END $$
drop procedure p_37228;

View file

@ -538,7 +538,7 @@ PARTITION BY LIST (a)
(PARTITION x1 VALUES IN (10), PARTITION x2 VALUES IN (20)); (PARTITION x1 VALUES IN (10), PARTITION x2 VALUES IN (20));
analyze table t1; analyze table t1;
Table Op Msg_type Msg_text Table Op Msg_type Msg_text
test.t1 analyze note The storage engine for the table doesn't support analyze test.t1 analyze status OK
drop table t1; drop table t1;
create table t1 create table t1
(a int) (a int)
@ -1131,7 +1131,7 @@ NULL
2 2
explain partitions select * from t1 where a is null or a < 0 or a > 1; explain partitions select * from t1 where a is null or a < 0 or a > 1;
id select_type table partitions type possible_keys key key_len ref rows Extra id select_type table partitions type possible_keys key key_len ref rows Extra
1 SIMPLE t1 pn,p2 ALL NULL NULL NULL NULL 2 Using where 1 SIMPLE t1 pn,p2 ALL NULL NULL NULL NULL 4 Using where
drop table t1; drop table t1;
CREATE TABLE t1 (id INT NOT NULL PRIMARY KEY, name VARCHAR(20)) CREATE TABLE t1 (id INT NOT NULL PRIMARY KEY, name VARCHAR(20))
ENGINE=MyISAM DEFAULT CHARSET=latin1 ENGINE=MyISAM DEFAULT CHARSET=latin1
@ -1239,7 +1239,11 @@ SHOW TABLE STATUS;
Name Engine Version Row_format Rows Avg_row_length Data_length Max_data_length Index_length Data_free Auto_increment Create_time Update_time Check_time Collation Checksum Create_options Comment Name Engine Version Row_format Rows Avg_row_length Data_length Max_data_length Index_length Data_free Auto_increment Create_time Update_time Check_time Collation Checksum Create_options Comment
t1 MyISAM 10 Fixed 1 14 14 0 0 7 NULL NULL NULL NULL latin1_swedish_ci NULL partitioned t1 MyISAM 10 Fixed 1 14 14 0 0 7 NULL NULL NULL NULL latin1_swedish_ci NULL partitioned
ALTER TABLE t1 OPTIMIZE PARTITION p0; ALTER TABLE t1 OPTIMIZE PARTITION p0;
ERROR 42000: The storage engine for the table doesn't support optimize partition Table Op Msg_type Msg_text
test.t1 optimize status OK
SHOW TABLE STATUS;
Name Engine Version Row_format Rows Avg_row_length Data_length Max_data_length Index_length Data_free Auto_increment Create_time Update_time Check_time Collation Checksum Create_options Comment
t1 MyISAM 10 Fixed 1 7 7 0 1024 0 NULL NULL NULL NULL latin1_swedish_ci NULL partitioned
DROP TABLE t1; DROP TABLE t1;
CREATE TABLE t1 (a int, index(a)) PARTITION BY KEY(a); CREATE TABLE t1 (a int, index(a)) PARTITION BY KEY(a);
ALTER TABLE t1 DISABLE KEYS; ALTER TABLE t1 DISABLE KEYS;
@ -1499,13 +1503,17 @@ ERROR 42000: You have an error in your SQL syntax; check the manual that corresp
ALTER TABLE t1 ANALYZE PARTITION p1 EXTENDED; ALTER TABLE t1 ANALYZE PARTITION p1 EXTENDED;
ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'EXTENDED' at line 1 ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'EXTENDED' at line 1
ALTER TABLE t1 ANALYZE PARTITION p1; ALTER TABLE t1 ANALYZE PARTITION p1;
ERROR 42000: The storage engine for the table doesn't support analyze partition Table Op Msg_type Msg_text
test.t1 analyze status OK
ALTER TABLE t1 CHECK PARTITION p1; ALTER TABLE t1 CHECK PARTITION p1;
ERROR 42000: The storage engine for the table doesn't support check partition Table Op Msg_type Msg_text
test.t1 check status OK
ALTER TABLE t1 REPAIR PARTITION p1; ALTER TABLE t1 REPAIR PARTITION p1;
ERROR 42000: The storage engine for the table doesn't support repair partition Table Op Msg_type Msg_text
test.t1 repair status OK
ALTER TABLE t1 OPTIMIZE PARTITION p1; ALTER TABLE t1 OPTIMIZE PARTITION p1;
ERROR 42000: The storage engine for the table doesn't support optimize partition Table Op Msg_type Msg_text
test.t1 optimize status OK
DROP TABLE t1; DROP TABLE t1;
CREATE TABLE t1 (s1 BIGINT UNSIGNED) CREATE TABLE t1 (s1 BIGINT UNSIGNED)
PARTITION BY RANGE (s1) ( PARTITION BY RANGE (s1) (
@ -1604,4 +1612,29 @@ t1 CREATE TABLE `t1` (
PRIMARY KEY (`id`) PRIMARY KEY (`id`)
) ENGINE=MyISAM AUTO_INCREMENT=16 DEFAULT CHARSET=latin1 /*!50100 PARTITION BY RANGE (id) SUBPARTITION BY HASH (id) SUBPARTITIONS 2 (PARTITION pa1 VALUES LESS THAN (10) ENGINE = MyISAM, PARTITION pa2 VALUES LESS THAN (20) ENGINE = MyISAM, PARTITION pa11 VALUES LESS THAN MAXVALUE ENGINE = MyISAM) */ ) ENGINE=MyISAM AUTO_INCREMENT=16 DEFAULT CHARSET=latin1 /*!50100 PARTITION BY RANGE (id) SUBPARTITION BY HASH (id) SUBPARTITIONS 2 (PARTITION pa1 VALUES LESS THAN (10) ENGINE = MyISAM, PARTITION pa2 VALUES LESS THAN (20) ENGINE = MyISAM, PARTITION pa11 VALUES LESS THAN MAXVALUE ENGINE = MyISAM) */
drop table t1; drop table t1;
CREATE TABLE t1 (
`ID` bigint(20) NOT NULL AUTO_INCREMENT,
`createdDate` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
`number` int,
PRIMARY KEY (`ID`, number)
)
PARTITION BY RANGE (number) (
PARTITION p0 VALUES LESS THAN (6),
PARTITION p1 VALUES LESS THAN (11)
);
create table t2 (
`ID` bigint(20),
`createdDate` TIMESTAMP,
`number` int
);
INSERT INTO t1 SET number=1;
insert into t2 select * from t1;
SELECT SLEEP(1);
SLEEP(1)
0
UPDATE t1 SET number=6;
select count(*) from t1, t2 where t1.createdDate = t2.createdDate;
count(*)
1
drop table t1, t2;
End of 5.1 tests End of 5.1 tests

View file

@ -69,25 +69,25 @@ id select_type table partitions type possible_keys key key_len ref rows Extra
1 SIMPLE t1 p0,p1,p2,p3 ALL NULL NULL NULL NULL 9 Using where 1 SIMPLE t1 p0,p1,p2,p3 ALL NULL NULL NULL NULL 9 Using where
explain partitions select * from t1 where a is null or (a >= 5 and a <= 7); explain partitions select * from t1 where a is null or (a >= 5 and a <= 7);
id select_type table partitions type possible_keys key key_len ref rows Extra id select_type table partitions type possible_keys key key_len ref rows Extra
1 SIMPLE t1 p0,p2,p3 ALL NULL NULL NULL NULL 7 Using where 1 SIMPLE t1 p0,p2,p3 ALL NULL NULL NULL NULL 9 Using where
explain partitions select * from t1 where a is null; explain partitions select * from t1 where a is null;
id select_type table partitions type possible_keys key key_len ref rows Extra id select_type table partitions type possible_keys key key_len ref rows Extra
1 SIMPLE t1 p0 ALL NULL NULL NULL NULL 3 Using where 1 SIMPLE t1 p0 ALL NULL NULL NULL NULL 9 Using where
explain partitions select * from t1 where a is not null; explain partitions select * from t1 where a is not null;
id select_type table partitions type possible_keys key key_len ref rows Extra id select_type table partitions type possible_keys key key_len ref rows Extra
1 SIMPLE t1 p0,p1,p2,p3 ALL NULL NULL NULL NULL 9 Using where 1 SIMPLE t1 p0,p1,p2,p3 ALL NULL NULL NULL NULL 9 Using where
explain partitions select * from t1 where a >= 1 and a < 3; explain partitions select * from t1 where a >= 1 and a < 3;
id select_type table partitions type possible_keys key key_len ref rows Extra id select_type table partitions type possible_keys key key_len ref rows Extra
1 SIMPLE t1 p0,p1 ALL NULL NULL NULL NULL 5 Using where 1 SIMPLE t1 p0,p1 ALL NULL NULL NULL NULL 9 Using where
explain partitions select * from t1 where a >= 3 and a <= 5; explain partitions select * from t1 where a >= 3 and a <= 5;
id select_type table partitions type possible_keys key key_len ref rows Extra id select_type table partitions type possible_keys key key_len ref rows Extra
1 SIMPLE t1 p1,p2 ALL NULL NULL NULL NULL 4 Using where 1 SIMPLE t1 p1,p2 ALL NULL NULL NULL NULL 9 Using where
explain partitions select * from t1 where a > 2 and a < 4; explain partitions select * from t1 where a > 2 and a < 4;
id select_type table partitions type possible_keys key key_len ref rows Extra id select_type table partitions type possible_keys key key_len ref rows Extra
1 SIMPLE t1 p1 ALL NULL NULL NULL NULL 2 Using where 1 SIMPLE t1 p1 ALL NULL NULL NULL NULL 9 Using where
explain partitions select * from t1 where a > 3 and a <= 6; explain partitions select * from t1 where a > 3 and a <= 6;
id select_type table partitions type possible_keys key key_len ref rows Extra id select_type table partitions type possible_keys key key_len ref rows Extra
1 SIMPLE t1 p2,p3 ALL NULL NULL NULL NULL 4 Using where 1 SIMPLE t1 p2,p3 ALL NULL NULL NULL NULL 9 Using where
explain partitions select * from t1 where a > 5; explain partitions select * from t1 where a > 5;
id select_type table partitions type possible_keys key key_len ref rows Extra id select_type table partitions type possible_keys key key_len ref rows Extra
1 SIMPLE t1 p0,p1,p2,p3 ALL NULL NULL NULL NULL 9 Using where 1 SIMPLE t1 p0,p1,p2,p3 ALL NULL NULL NULL NULL 9 Using where

View file

@ -31,7 +31,7 @@ id select_type table partitions type possible_keys key key_len ref rows Extra
1 SIMPLE t2 p0,p1 ALL NULL NULL NULL NULL 3 Using where 1 SIMPLE t2 p0,p1 ALL NULL NULL NULL NULL 3 Using where
explain partitions select * from t2 where a=1 and b=1; explain partitions select * from t2 where a=1 and b=1;
id select_type table partitions type possible_keys key key_len ref rows Extra id select_type table partitions type possible_keys key key_len ref rows Extra
1 SIMPLE t2 p0 ALL NULL NULL NULL NULL 2 Using where 1 SIMPLE t2 p0 ALL NULL NULL NULL NULL 3 Using where
create table t3 ( create table t3 (
a int a int
) )
@ -89,25 +89,25 @@ id select_type table partitions type possible_keys key key_len ref rows Extra
explain partitions select * from t5 explain partitions select * from t5
where (a=10 and b=1) or (a=10 and b=2) or (a=10 and b = 3); where (a=10 and b=1) or (a=10 and b=2) or (a=10 and b = 3);
id select_type table partitions type possible_keys key key_len ref rows Extra id select_type table partitions type possible_keys key key_len ref rows Extra
1 SIMPLE t5 p0_p0sp0,p0_p0sp1 ALL NULL NULL NULL NULL 2 Using where 1 SIMPLE t5 p0_p0sp0,p0_p0sp1 ALL NULL NULL NULL NULL 4 Using where
explain partitions select * from t5 where (a=10 and b=2) or (a=10 and b=3) explain partitions select * from t5 where (a=10 and b=2) or (a=10 and b=3)
or (a=10 and b = 4); or (a=10 and b = 4);
id select_type table partitions type possible_keys key key_len ref rows Extra id select_type table partitions type possible_keys key key_len ref rows Extra
1 SIMPLE t5 p0_p0sp0,p0_p0sp1,p1_p1sp0,p1_p1sp1 ALL NULL NULL NULL NULL 4 Using where 1 SIMPLE t5 p0_p0sp0,p0_p0sp1,p1_p1sp0,p1_p1sp1 ALL NULL NULL NULL NULL 4 Using where
explain partitions select * from t5 where (c=1 and d=1); explain partitions select * from t5 where (c=1 and d=1);
id select_type table partitions type possible_keys key key_len ref rows Extra id select_type table partitions type possible_keys key key_len ref rows Extra
1 SIMPLE t5 p0_p0sp0,p1_p1sp0 ALL NULL NULL NULL NULL 2 Using where 1 SIMPLE t5 p0_p0sp0,p1_p1sp0 ALL NULL NULL NULL NULL 4 Using where
explain partitions select * from t5 where (c=2 and d=1); explain partitions select * from t5 where (c=2 and d=1);
id select_type table partitions type possible_keys key key_len ref rows Extra id select_type table partitions type possible_keys key key_len ref rows Extra
1 SIMPLE t5 p0_p0sp1,p1_p1sp1 ALL NULL NULL NULL NULL 2 Using where 1 SIMPLE t5 p0_p0sp1,p1_p1sp1 ALL NULL NULL NULL NULL 4 Using where
explain partitions select * from t5 where (a=10 and b=2 and c=1 and d=1) or explain partitions select * from t5 where (a=10 and b=2 and c=1 and d=1) or
(c=2 and d=1); (c=2 and d=1);
id select_type table partitions type possible_keys key key_len ref rows Extra id select_type table partitions type possible_keys key key_len ref rows Extra
1 SIMPLE t5 p0_p0sp0,p0_p0sp1,p1_p1sp1 ALL NULL NULL NULL NULL 3 Using where 1 SIMPLE t5 p0_p0sp0,p0_p0sp1,p1_p1sp1 ALL NULL NULL NULL NULL 4 Using where
explain partitions select * from t5 where (a=10 and b=2 and c=1 and d=1) or explain partitions select * from t5 where (a=10 and b=2 and c=1 and d=1) or
(b=2 and c=2 and d=1); (b=2 and c=2 and d=1);
id select_type table partitions type possible_keys key key_len ref rows Extra id select_type table partitions type possible_keys key key_len ref rows Extra
1 SIMPLE t5 p0_p0sp0,p0_p0sp1,p1_p1sp1 ALL NULL NULL NULL NULL 3 Using where 1 SIMPLE t5 p0_p0sp0,p0_p0sp1,p1_p1sp1 ALL NULL NULL NULL NULL 4 Using where
create table t6 (a int not null) partition by LIST(a) ( create table t6 (a int not null) partition by LIST(a) (
partition p1 values in (1), partition p1 values in (1),
partition p3 values in (3), partition p3 values in (3),
@ -145,7 +145,7 @@ id select_type table partitions type possible_keys key key_len ref rows Extra
1 SIMPLE t6 p5,p7,p9 system NULL NULL NULL NULL 1 1 SIMPLE t6 p5,p7,p9 system NULL NULL NULL NULL 1
explain partitions select * from t6 where a >= 3 and a <= 8; explain partitions select * from t6 where a >= 3 and a <= 8;
id select_type table partitions type possible_keys key key_len ref rows Extra id select_type table partitions type possible_keys key key_len ref rows Extra
1 SIMPLE t6 p3,p5,p7 ALL NULL NULL NULL NULL 2 Using where 1 SIMPLE t6 p3,p5,p7 ALL NULL NULL NULL NULL 3 Using where
explain partitions select * from t6 where a > 3 and a < 5; explain partitions select * from t6 where a > 3 and a < 5;
id select_type table partitions type possible_keys key key_len ref rows Extra id select_type table partitions type possible_keys key key_len ref rows Extra
1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables 1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables
@ -187,7 +187,7 @@ id select_type table partitions type possible_keys key key_len ref rows Extra
1 SIMPLE t6 p5,p7,p9 system NULL NULL NULL NULL 1 1 SIMPLE t6 p5,p7,p9 system NULL NULL NULL NULL 1
explain partitions select * from t6 where a >= 3 and a <= 8; explain partitions select * from t6 where a >= 3 and a <= 8;
id select_type table partitions type possible_keys key key_len ref rows Extra id select_type table partitions type possible_keys key key_len ref rows Extra
1 SIMPLE t6 p3,p5,p7 ALL NULL NULL NULL NULL 2 Using where 1 SIMPLE t6 p3,p5,p7 ALL NULL NULL NULL NULL 3 Using where
explain partitions select * from t6 where a > 3 and a < 5; explain partitions select * from t6 where a > 3 and a < 5;
id select_type table partitions type possible_keys key key_len ref rows Extra id select_type table partitions type possible_keys key key_len ref rows Extra
1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables 1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables
@ -342,7 +342,7 @@ id select_type table partitions type possible_keys key key_len ref rows Extra
explain partitions explain partitions
select * from t1 X, t1 Y where X.a = Y.a and (X.a=1 or X.a=2); select * from t1 X, t1 Y where X.a = Y.a and (X.a=1 or X.a=2);
id select_type table partitions type possible_keys key key_len ref rows Extra id select_type table partitions type possible_keys key key_len ref rows Extra
1 SIMPLE X p1,p2 ALL a NULL NULL NULL 2 Using where 1 SIMPLE X p1,p2 ALL a NULL NULL NULL 4 Using where
1 SIMPLE Y p1,p2 ref a a 4 test.X.a 2 1 SIMPLE Y p1,p2 ref a a 4 test.X.a 2
drop table t1; drop table t1;
create table t1 (a int) partition by hash(a) partitions 20; create table t1 (a int) partition by hash(a) partitions 20;
@ -355,7 +355,7 @@ id select_type table partitions type possible_keys key key_len ref rows Extra
1 SIMPLE t1 p1,p2 ALL NULL NULL NULL NULL 2 Using where 1 SIMPLE t1 p1,p2 ALL NULL NULL NULL NULL 2 Using where
explain partitions select * from t1 where a > 1 and a <= 3; explain partitions select * from t1 where a > 1 and a <= 3;
id select_type table partitions type possible_keys key key_len ref rows Extra id select_type table partitions type possible_keys key key_len ref rows Extra
1 SIMPLE t1 p2,p3 ALL NULL NULL NULL NULL 2 Using where 1 SIMPLE t1 p2,p3 ALL NULL NULL NULL NULL 3 Using where
explain partitions select * from t1 where a >= 1 and a <= 3; explain partitions select * from t1 where a >= 1 and a <= 3;
id select_type table partitions type possible_keys key key_len ref rows Extra id select_type table partitions type possible_keys key key_len ref rows Extra
1 SIMPLE t1 p1,p2,p3 ALL NULL NULL NULL NULL 3 Using where 1 SIMPLE t1 p1,p2,p3 ALL NULL NULL NULL NULL 3 Using where
@ -445,22 +445,22 @@ id select_type table partitions type possible_keys key key_len ref rows Extra
1 SIMPLE t2 p0,p1,p2,p3,p4 ALL NULL NULL NULL NULL 1010 1 SIMPLE t2 p0,p1,p2,p3,p4 ALL NULL NULL NULL NULL 1010
explain partitions select * from t2 where a < 801 and a > 200; explain partitions select * from t2 where a < 801 and a > 200;
id select_type table partitions type possible_keys key key_len ref rows Extra id select_type table partitions type possible_keys key key_len ref rows Extra
1 SIMPLE t2 p1,p2,p3,p4 ALL NULL NULL NULL NULL 800 Using where 1 SIMPLE t2 p1,p2,p3,p4 ALL NULL NULL NULL NULL 1010 Using where
explain partitions select * from t2 where a < 801 and a > 800; explain partitions select * from t2 where a < 801 and a > 800;
id select_type table partitions type possible_keys key key_len ref rows Extra id select_type table partitions type possible_keys key key_len ref rows Extra
1 SIMPLE t2 p4 ALL NULL NULL NULL NULL 200 Using where 1 SIMPLE t2 p4 ALL NULL NULL NULL NULL 1010 Using where
explain partitions select * from t2 where a > 600; explain partitions select * from t2 where a > 600;
id select_type table partitions type possible_keys key key_len ref rows Extra id select_type table partitions type possible_keys key key_len ref rows Extra
1 SIMPLE t2 p3,p4 ALL NULL NULL NULL NULL 400 Using where 1 SIMPLE t2 p3,p4 ALL NULL NULL NULL NULL 1010 Using where
explain partitions select * from t2 where a > 600 and b = 1; explain partitions select * from t2 where a > 600 and b = 1;
id select_type table partitions type possible_keys key key_len ref rows Extra id select_type table partitions type possible_keys key key_len ref rows Extra
1 SIMPLE t2 p3,p4 ALL NULL NULL NULL NULL 400 Using where 1 SIMPLE t2 p3,p4 ALL NULL NULL NULL NULL 1010 Using where
explain partitions select * from t2 where a > 600 and b = 4; explain partitions select * from t2 where a > 600 and b = 4;
id select_type table partitions type possible_keys key key_len ref rows Extra id select_type table partitions type possible_keys key key_len ref rows Extra
1 SIMPLE t2 p3,p4 ALL NULL NULL NULL NULL 400 Using where 1 SIMPLE t2 p3,p4 ALL NULL NULL NULL NULL 1010 Using where
explain partitions select * from t2 where a > 600 and b = 5; explain partitions select * from t2 where a > 600 and b = 5;
id select_type table partitions type possible_keys key key_len ref rows Extra id select_type table partitions type possible_keys key key_len ref rows Extra
1 SIMPLE t2 p3,p4 ALL NULL NULL NULL NULL 400 Using where 1 SIMPLE t2 p3,p4 ALL NULL NULL NULL NULL 1010 Using where
explain partitions select * from t2 where b = 5; explain partitions select * from t2 where b = 5;
id select_type table partitions type possible_keys key key_len ref rows Extra id select_type table partitions type possible_keys key key_len ref rows Extra
1 SIMPLE t2 p0,p1,p2,p3,p4 ALL NULL NULL NULL NULL 1010 Using where 1 SIMPLE t2 p0,p1,p2,p3,p4 ALL NULL NULL NULL NULL 1010 Using where
@ -515,19 +515,19 @@ id select_type table partitions type possible_keys key key_len ref rows Extra
1 SIMPLE t2 p0,p1,p2,p3,p4 ALL NULL NULL NULL NULL 910 1 SIMPLE t2 p0,p1,p2,p3,p4 ALL NULL NULL NULL NULL 910
explain partitions select * from t2 where a = 101; explain partitions select * from t2 where a = 101;
id select_type table partitions type possible_keys key key_len ref rows Extra id select_type table partitions type possible_keys key key_len ref rows Extra
1 SIMPLE t2 p0 ALL NULL NULL NULL NULL 110 Using where 1 SIMPLE t2 p0 ALL NULL NULL NULL NULL 910 Using where
explain partitions select * from t2 where a = 550; explain partitions select * from t2 where a = 550;
id select_type table partitions type possible_keys key key_len ref rows Extra id select_type table partitions type possible_keys key key_len ref rows Extra
1 SIMPLE t2 p2 ALL NULL NULL NULL NULL 200 Using where 1 SIMPLE t2 p2 ALL NULL NULL NULL NULL 910 Using where
explain partitions select * from t2 where a = 833; explain partitions select * from t2 where a = 833;
id select_type table partitions type possible_keys key key_len ref rows Extra id select_type table partitions type possible_keys key key_len ref rows Extra
1 SIMPLE t2 p4 ALL NULL NULL NULL NULL 200 Using where 1 SIMPLE t2 p4 ALL NULL NULL NULL NULL 910 Using where
explain partitions select * from t2 where (a = 100 OR a = 900); explain partitions select * from t2 where (a = 100 OR a = 900);
id select_type table partitions type possible_keys key key_len ref rows Extra id select_type table partitions type possible_keys key key_len ref rows Extra
1 SIMPLE t2 p0,p4 ALL NULL NULL NULL NULL 310 Using where 1 SIMPLE t2 p0,p4 ALL NULL NULL NULL NULL 910 Using where
explain partitions select * from t2 where (a > 100 AND a < 600); explain partitions select * from t2 where (a > 100 AND a < 600);
id select_type table partitions type possible_keys key key_len ref rows Extra id select_type table partitions type possible_keys key key_len ref rows Extra
1 SIMPLE t2 p0,p1,p2,p3 ALL NULL NULL NULL NULL 710 Using where 1 SIMPLE t2 p0,p1,p2,p3 ALL NULL NULL NULL NULL 910 Using where
explain partitions select * from t2 where b = 4; explain partitions select * from t2 where b = 4;
id select_type table partitions type possible_keys key key_len ref rows Extra id select_type table partitions type possible_keys key key_len ref rows Extra
1 SIMPLE t2 p0,p1,p2,p3,p4 ref b b 5 const 76 Using where 1 SIMPLE t2 p0,p1,p2,p3,p4 ref b b 5 const 76 Using where
@ -813,17 +813,17 @@ id select_type table partitions type possible_keys key key_len ref rows Extra
explain partitions select * from t1 explain partitions select * from t1
where a >= 18446744073709551000-1 and a <= 18446744073709551000+1; where a >= 18446744073709551000-1 and a <= 18446744073709551000+1;
id select_type table partitions type possible_keys key key_len ref rows Extra id select_type table partitions type possible_keys key key_len ref rows Extra
1 SIMPLE t1 p3,p4 ALL NULL NULL NULL NULL 3 Using where 1 SIMPLE t1 p3,p4 ALL NULL NULL NULL NULL 4 Using where
explain partitions select * from t1 explain partitions select * from t1
where a between 18446744073709551001 and 18446744073709551002; where a between 18446744073709551001 and 18446744073709551002;
id select_type table partitions type possible_keys key key_len ref rows Extra id select_type table partitions type possible_keys key key_len ref rows Extra
1 SIMPLE t1 p4 ALL NULL NULL NULL NULL 2 Using where 1 SIMPLE t1 p4 ALL NULL NULL NULL NULL 4 Using where
explain partitions select * from t1 where a = 18446744073709551000; explain partitions select * from t1 where a = 18446744073709551000;
id select_type table partitions type possible_keys key key_len ref rows Extra id select_type table partitions type possible_keys key key_len ref rows Extra
1 SIMPLE t1 p4 ALL NULL NULL NULL NULL 2 Using where 1 SIMPLE t1 p4 ALL NULL NULL NULL NULL 4 Using where
explain partitions select * from t1 where a = 18446744073709551613; explain partitions select * from t1 where a = 18446744073709551613;
id select_type table partitions type possible_keys key key_len ref rows Extra id select_type table partitions type possible_keys key key_len ref rows Extra
1 SIMPLE t1 p4 ALL NULL NULL NULL NULL 2 Using where 1 SIMPLE t1 p4 ALL NULL NULL NULL NULL 4 Using where
explain partitions select * from t1 where a = 18446744073709551614; explain partitions select * from t1 where a = 18446744073709551614;
id select_type table partitions type possible_keys key key_len ref rows Extra id select_type table partitions type possible_keys key key_len ref rows Extra
1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables 1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables
@ -850,10 +850,10 @@ id select_type table partitions type possible_keys key key_len ref rows Extra
1 SIMPLE t2 p0 ALL NULL NULL NULL NULL 2 Using where 1 SIMPLE t2 p0 ALL NULL NULL NULL NULL 2 Using where
explain partitions select * from t1 where a=0xFE; explain partitions select * from t1 where a=0xFE;
id select_type table partitions type possible_keys key key_len ref rows Extra id select_type table partitions type possible_keys key key_len ref rows Extra
1 SIMPLE t1 p2 ALL NULL NULL NULL NULL 2 Using where 1 SIMPLE t1 p2 ALL NULL NULL NULL NULL 4 Using where
explain partitions select * from t2 where a=0xFE; explain partitions select * from t2 where a=0xFE;
id select_type table partitions type possible_keys key key_len ref rows Extra id select_type table partitions type possible_keys key key_len ref rows Extra
1 SIMPLE t2 p2 ALL NULL NULL NULL NULL 2 Using where 1 SIMPLE t2 p2 ALL NULL NULL NULL NULL 4 Using where
explain partitions select * from t1 where a > 0xFE AND a <= 0xFF; explain partitions select * from t1 where a > 0xFE AND a <= 0xFF;
id select_type table partitions type possible_keys key key_len ref rows Extra id select_type table partitions type possible_keys key key_len ref rows Extra
1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables 1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables
@ -862,22 +862,22 @@ id select_type table partitions type possible_keys key key_len ref rows Extra
1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables 1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables
explain partitions select * from t1 where a >= 0xFE AND a <= 0xFF; explain partitions select * from t1 where a >= 0xFE AND a <= 0xFF;
id select_type table partitions type possible_keys key key_len ref rows Extra id select_type table partitions type possible_keys key key_len ref rows Extra
1 SIMPLE t1 p2 ALL NULL NULL NULL NULL 2 Using where 1 SIMPLE t1 p2 ALL NULL NULL NULL NULL 4 Using where
explain partitions select * from t2 where a >= 0xFE AND a <= 0xFF; explain partitions select * from t2 where a >= 0xFE AND a <= 0xFF;
id select_type table partitions type possible_keys key key_len ref rows Extra id select_type table partitions type possible_keys key key_len ref rows Extra
1 SIMPLE t2 p2 ALL NULL NULL NULL NULL 2 Using where 1 SIMPLE t2 p2 ALL NULL NULL NULL NULL 4 Using where
explain partitions select * from t1 where a < 64 AND a >= 63; explain partitions select * from t1 where a < 64 AND a >= 63;
id select_type table partitions type possible_keys key key_len ref rows Extra id select_type table partitions type possible_keys key key_len ref rows Extra
1 SIMPLE t1 p0 ALL NULL NULL NULL NULL 2 Using where 1 SIMPLE t1 p0 ALL NULL NULL NULL NULL 4 Using where
explain partitions select * from t2 where a < 64 AND a >= 63; explain partitions select * from t2 where a < 64 AND a >= 63;
id select_type table partitions type possible_keys key key_len ref rows Extra id select_type table partitions type possible_keys key key_len ref rows Extra
1 SIMPLE t2 p0 ALL NULL NULL NULL NULL 2 Using where 1 SIMPLE t2 p0 ALL NULL NULL NULL NULL 4 Using where
explain partitions select * from t1 where a <= 64 AND a >= 63; explain partitions select * from t1 where a <= 64 AND a >= 63;
id select_type table partitions type possible_keys key key_len ref rows Extra id select_type table partitions type possible_keys key key_len ref rows Extra
1 SIMPLE t1 p0,p1 ALL NULL NULL NULL NULL 4 Using where 1 SIMPLE t1 p0,p1 ALL NULL NULL NULL NULL 6 Using where
explain partitions select * from t2 where a <= 64 AND a >= 63; explain partitions select * from t2 where a <= 64 AND a >= 63;
id select_type table partitions type possible_keys key key_len ref rows Extra id select_type table partitions type possible_keys key key_len ref rows Extra
1 SIMPLE t2 p0,p1 ALL NULL NULL NULL NULL 4 Using where 1 SIMPLE t2 p0,p1 ALL NULL NULL NULL NULL 6 Using where
drop table t1; drop table t1;
drop table t2; drop table t2;
create table t1(a bigint unsigned not null) partition by range(a+0) ( create table t1(a bigint unsigned not null) partition by range(a+0) (

View file

@ -57,13 +57,13 @@ id select_type table partitions type possible_keys key key_len ref rows Extra
1 SIMPLE t1 pnull system NULL NULL NULL NULL 1 1 SIMPLE t1 pnull system NULL NULL NULL NULL 1
explain partitions select * from t1 where a >= 0; explain partitions select * from t1 where a >= 0;
id select_type table partitions type possible_keys key key_len ref rows Extra id select_type table partitions type possible_keys key key_len ref rows Extra
1 SIMPLE t1 p0,p1 ALL NULL NULL NULL NULL 2 Using where 1 SIMPLE t1 p0,p1 ALL NULL NULL NULL NULL 3 Using where
explain partitions select * from t1 where a < 0; explain partitions select * from t1 where a < 0;
id select_type table partitions type possible_keys key key_len ref rows Extra id select_type table partitions type possible_keys key key_len ref rows Extra
1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables 1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables
explain partitions select * from t1 where a <= 0; explain partitions select * from t1 where a <= 0;
id select_type table partitions type possible_keys key key_len ref rows Extra id select_type table partitions type possible_keys key key_len ref rows Extra
1 SIMPLE t1 pnull,p0 ALL NULL NULL NULL NULL 2 Using where 1 SIMPLE t1 pnull,p0 ALL NULL NULL NULL NULL 3 Using where
explain partitions select * from t1 where a > 1; explain partitions select * from t1 where a > 1;
id select_type table partitions type possible_keys key key_len ref rows Extra id select_type table partitions type possible_keys key key_len ref rows Extra
1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables 1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables
@ -96,16 +96,16 @@ select * from t1 where a > 1;
a b a b
explain partitions select * from t1 where a is null; explain partitions select * from t1 where a is null;
id select_type table partitions type possible_keys key key_len ref rows Extra id select_type table partitions type possible_keys key key_len ref rows Extra
1 SIMPLE t1 pnull_pnullsp0,pnull_pnullsp1 ALL NULL NULL NULL NULL 2 Using where 1 SIMPLE t1 pnull_pnullsp0,pnull_pnullsp1 ALL NULL NULL NULL NULL 6 Using where
explain partitions select * from t1 where a >= 0; explain partitions select * from t1 where a >= 0;
id select_type table partitions type possible_keys key key_len ref rows Extra id select_type table partitions type possible_keys key key_len ref rows Extra
1 SIMPLE t1 p0_p0sp0,p0_p0sp1,p1_p1sp0,p1_p1sp1 ALL NULL NULL NULL NULL 4 Using where 1 SIMPLE t1 p0_p0sp0,p0_p0sp1,p1_p1sp0,p1_p1sp1 ALL NULL NULL NULL NULL 6 Using where
explain partitions select * from t1 where a < 0; explain partitions select * from t1 where a < 0;
id select_type table partitions type possible_keys key key_len ref rows Extra id select_type table partitions type possible_keys key key_len ref rows Extra
1 SIMPLE t1 pnull_pnullsp0,pnull_pnullsp1 ALL NULL NULL NULL NULL 2 Using where 1 SIMPLE t1 pnull_pnullsp0,pnull_pnullsp1 ALL NULL NULL NULL NULL 6 Using where
explain partitions select * from t1 where a <= 0; explain partitions select * from t1 where a <= 0;
id select_type table partitions type possible_keys key key_len ref rows Extra id select_type table partitions type possible_keys key key_len ref rows Extra
1 SIMPLE t1 pnull_pnullsp0,pnull_pnullsp1,p0_p0sp0,p0_p0sp1 ALL NULL NULL NULL NULL 4 Using where 1 SIMPLE t1 pnull_pnullsp0,pnull_pnullsp1,p0_p0sp0,p0_p0sp1 ALL NULL NULL NULL NULL 6 Using where
explain partitions select * from t1 where a > 1; explain partitions select * from t1 where a > 1;
id select_type table partitions type possible_keys key key_len ref rows Extra id select_type table partitions type possible_keys key key_len ref rows Extra
1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables 1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables

View file

@ -113,9 +113,9 @@ set @@sql_mode=@org_mode;
create table t1 (a int) create table t1 (a int)
partition by key (a) partition by key (a)
(partition p0 DATA DIRECTORY 'part-data' INDEX DIRECTORY 'part-data'); (partition p0 DATA DIRECTORY 'part-data' INDEX DIRECTORY 'part-data');
ERROR 42000: Incorrect table name 'part-data' Got one of the listed errors
create table t1 (a int) create table t1 (a int)
partition by key (a) partition by key (a)
(partition p0, (partition p0,
partition p1 DATA DIRECTORY 'part-data' INDEX DIRECTORY 'part-data'); partition p1 DATA DIRECTORY 'part-data' INDEX DIRECTORY 'part-data');
ERROR 42000: Incorrect table name 'part-data' Got one of the listed errors

View file

@ -85,9 +85,9 @@ NULL
NULL NULL
NULL NULL
prepare stmt6 from 'select 1; select2'; prepare stmt6 from 'select 1; select2';
ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '; select2' at line 1 ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'select2' at line 1
prepare stmt6 from 'insert into t1 values (5,"five"); select2'; prepare stmt6 from 'insert into t1 values (5,"five"); select2';
ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '; select2' at line 1 ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'select2' at line 1
explain prepare stmt6 from 'insert into t1 values (5,"five"); select2'; explain prepare stmt6 from 'insert into t1 values (5,"five"); select2';
ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'from 'insert into t1 values (5,"five"); select2'' at line 1 ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'from 'insert into t1 values (5,"five"); select2'' at line 1
create table t2 create table t2

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