Merge of the patch introducing virtual columns into maria-5.2

This commit is contained in:
Igor Babaev 2009-11-11 20:31:28 -08:00
commit e4e1ae0d13
300 changed files with 28400 additions and 1296 deletions

View File

@ -1921,3 +1921,4 @@ sql/share/ukrainian
libmysqld/examples/mysqltest.cc
extra/libevent/event-config.h
libmysqld/opt_table_elimination.cc
libmysqld/ha_federatedx.cc

View File

@ -146,6 +146,13 @@ then
debug_cflags="$debug_cflags $debug_extra_cflags"
fi
static_link="--with-mysqld-ldflags=-all-static "
static_link="$static_link --with-client-ldflags=-all-static"
# we need local-infile in all binaries for rpl000001
# if you need to disable local-infile in the client, write a build script
# and unset local_infile_configs
local_infile_configs="--enable-local-infile"
#
# Configuration options.
#
@ -154,6 +161,8 @@ base_configs="$base_configs --with-extra-charsets=complex "
base_configs="$base_configs --enable-thread-safe-client "
base_configs="$base_configs --with-big-tables"
base_configs="$base_configs --with-plugin-maria --with-maria-tmp-tables --without-plugin-innodb_plugin"
# Compile our client programs with static libraries to allow them to be moved
base_configs="$base_configs --with-mysqld-ldflags=-static --with-client-ldflags=-static"
if test -d "$path/../cmd-line-utils/readline"
then
@ -163,14 +172,6 @@ then
base_configs="$base_configs --with-libedit"
fi
static_link="--with-mysqld-ldflags=-all-static "
static_link="$static_link --with-client-ldflags=-all-static"
# we need local-infile in all binaries for rpl000001
# if you need to disable local-infile in the client, write a build script
# and unset local_infile_configs
local_infile_configs="--enable-local-infile"
max_no_embedded_configs="$SSL_LIBRARY --with-plugins=max"
max_no_qc_configs="$SSL_LIBRARY --with-plugins=max --without-query-cache"
max_no_ndb_configs="$SSL_LIBRARY --with-plugins=max-no-ndb --with-embedded-server --with-libevent"

View File

@ -70,6 +70,11 @@ check_cpu () {
Alpha*EV6*)
cpu_arg="ev6";
;;
#Core 2 Duo
*Intel*Core\(TM\)2*)
cpu_arg="nocona"
core2="yes"
;;
# Intel ia32
*Intel*Core*|*X[eE][oO][nN]*)
# a Xeon is just another pentium4 ...
@ -134,10 +139,6 @@ check_cpu () {
*i386*)
cpu_arg="i386"
;;
#Core 2 Duo
*Intel*Core\(TM\)2*)
cpu_arg="nocona"
;;
# Intel ia64
*Itanium*)
cpu_arg="itanium"

View File

@ -86,7 +86,7 @@ extern "C" {
#endif
#undef bcmp // Fix problem with new readline
#if defined( __WIN__)
#if defined(__WIN__)
#include <conio.h>
#elif !defined(__NETWARE__)
#include <readline/readline.h>
@ -106,7 +106,7 @@ extern "C" {
#define cmp_database(cs,A,B) strcmp((A),(B))
#endif
#if !defined( __WIN__) && !defined(__NETWARE__) && !defined(THREAD)
#if !defined(__WIN__) && !defined(__NETWARE__) && !defined(THREAD)
#define USE_POPEN
#endif
@ -1870,7 +1870,7 @@ static int read_and_execute(bool interactive)
if (opt_outfile && glob_buffer.is_empty())
fflush(OUTFILE);
#if defined( __WIN__) || defined(__NETWARE__)
#if defined(__WIN__) || defined(__NETWARE__)
tee_fputs(prompt, stdout);
#if defined(__NETWARE__)
line=fgets(linebuffer, sizeof(linebuffer)-1, stdin);
@ -1881,7 +1881,7 @@ static int read_and_execute(bool interactive)
if (p != NULL)
*p = '\0';
}
#else defined(__WIN__)
#else
if (!tmpbuf.is_alloced())
tmpbuf.alloc(65535);
tmpbuf.length(0);
@ -1907,7 +1907,7 @@ static int read_and_execute(bool interactive)
if (opt_outfile)
fputs(prompt, OUTFILE);
line= readline(prompt);
#endif /* defined( __WIN__) || defined(__NETWARE__) */
#endif /* defined(__WIN__) || defined(__NETWARE__) */
/*
When Ctrl+d or Ctrl+z is pressed, the line may be NULL on some OS
@ -1955,10 +1955,10 @@ static int read_and_execute(bool interactive)
}
}
#if defined( __WIN__) || defined(__NETWARE__)
#if defined(__WIN__) || defined(__NETWARE__)
buffer.free();
#endif
#if defined( __WIN__)
#if defined(__WIN__)
tmpbuf.free();
#endif
@ -3835,6 +3835,7 @@ com_edit(String *buffer,char *line __attribute__((unused)))
char errmsg[100];
sprintf(errmsg, "Command '%.40s' failed", buff);
put_info(errmsg, INFO_ERROR, 0, NullS);
goto err;
}
if (!my_stat(filename,&stat_arg,MYF(MY_WME)))
@ -4635,7 +4636,7 @@ void tee_putc(int c, FILE *file)
putc(c, OUTFILE);
}
#if defined( __WIN__) || defined(__NETWARE__)
#if defined(__WIN__) || defined(__NETWARE__)
#include <time.h>
#else
#include <sys/times.h>
@ -4647,7 +4648,7 @@ void tee_putc(int c, FILE *file)
static ulong start_timer(void)
{
#if defined( __WIN__) || defined(__NETWARE__)
#if defined(__WIN__) || defined(__NETWARE__)
return clock();
#else
struct tms tms_tmp;

View File

@ -552,6 +552,7 @@ static int upgrade_already_done(void)
FILE *in;
char upgrade_info_file[FN_REFLEN]= {0};
char buf[sizeof(MYSQL_SERVER_VERSION)+1];
char *res;
if (get_upgrade_info_file_name(upgrade_info_file))
return 0; /* Could not get filename => not sure */

View File

@ -22,6 +22,7 @@
#endif
#include <sys/stat.h>
#include <mysql.h>
#include <sql_common.h>
#define ADMIN_VERSION "9.0"
#define MAX_MYSQL_VAR 512
@ -359,6 +360,11 @@ int main(int argc,char *argv[])
if (sql_connect(&mysql, option_wait))
{
/*
We couldn't get an initial connection and will definitely exit.
The following just determines the exit-code we'll give.
*/
unsigned int err= mysql_errno(&mysql);
if (err >= CR_MIN_ERROR && err <= CR_MAX_ERROR)
error= 1;
@ -377,41 +383,79 @@ int main(int argc,char *argv[])
}
else
{
while (!interrupted)
/*
--count=0 aborts right here. Otherwise iff --sleep=t ("interval")
is given a t!=0, we get an endless loop, or n iterations if --count=n
was given an n!=0. If --sleep wasn't given, we get one iteration.
To wit, --wait loops the connection-attempts, while --sleep loops
the command execution (endlessly if no --count is given).
*/
while (!interrupted && (!opt_count_iterations || nr_iterations))
{
new_line = 0;
if ((error=execute_commands(&mysql,argc,commands)))
if ((error= execute_commands(&mysql,argc,commands)))
{
/*
Unknown/malformed command always aborts and can't be --forced.
If the user got confused about the syntax, proceeding would be
dangerous ...
*/
if (error > 0)
break; /* Wrong command error */
if (!option_force)
break;
/*
Command was well-formed, but failed on the server. Might succeed
on retry (if conditions on server change etc.), but needs --force
to retry.
*/
if (!option_force)
break;
} /* if((error= ... */
if (interval) /* --sleep=interval given */
{
/*
If connection was dropped (unintentionally, or due to SHUTDOWN),
re-establish it if --wait ("retry-connect") was given and user
didn't signal for us to die. Otherwise, signal failure.
*/
if (mysql.net.vio == 0)
{
if (option_wait && !interrupted)
{
mysql_close(&mysql);
if (!sql_connect(&mysql, option_wait))
{
sleep(1); /* Don't retry too rapidly */
continue; /* Retry */
}
sleep(1);
sql_connect(&mysql, option_wait);
/*
continue normally and decrease counters so that
"mysqladmin --count=1 --wait=1 shutdown"
cannot loop endlessly.
*/
}
error=1;
break;
}
}
if (interval)
{
if (opt_count_iterations && --nr_iterations == 0)
break;
else
{
/*
connexion broke, and we have no order to re-establish it. fail.
*/
if (!option_force)
error= 1;
break;
}
} /* lost connection */
sleep(interval);
if (new_line)
puts("");
}
else
break;
}
mysql_close(&mysql);
}
break; /* no --sleep, done looping */
} /* command-loop */
} /* got connection */
mysql_close(&mysql);
my_free(opt_password,MYF(MY_ALLOW_ZERO_PTR));
my_free(user,MYF(MY_ALLOW_ZERO_PTR));
#ifdef HAVE_SMEM
@ -429,6 +473,17 @@ sig_handler endprog(int signal_number __attribute__((unused)))
interrupted=1;
}
/**
@brief connect to server, optionally waiting for same to come up
@param mysql connection struct
@param wait wait for server to come up?
(0: no, ~0: forever, n: cycles)
@return Operation result
@retval 0 success
@retval 1 failure
*/
static my_bool sql_connect(MYSQL *mysql, uint wait)
{
@ -437,7 +492,7 @@ static my_bool sql_connect(MYSQL *mysql, uint wait)
for (;;)
{
if (mysql_real_connect(mysql,host,user,opt_password,NullS,tcp_port,
unix_port, 0))
unix_port, CLIENT_REMEMBER_OPTIONS))
{
mysql->reconnect= 1;
if (info)
@ -448,9 +503,9 @@ static my_bool sql_connect(MYSQL *mysql, uint wait)
return 0;
}
if (!wait)
if (!wait) // was or reached 0, fail
{
if (!option_silent)
if (!option_silent) // print diagnostics
{
if (!host)
host= (char*) LOCAL_HOST;
@ -474,11 +529,18 @@ static my_bool sql_connect(MYSQL *mysql, uint wait)
}
return 1;
}
if (wait != (uint) ~0)
wait--; /* One less retry */
wait--; /* count down, one less retry */
if ((mysql_errno(mysql) != CR_CONN_HOST_ERROR) &&
(mysql_errno(mysql) != CR_CONNECTION_ERROR))
{
/*
Error is worse than "server doesn't answer (yet?)";
fail even if we still have "wait-coins" unless --force
was also given.
*/
fprintf(stderr,"Got error: %s\n", mysql_error(mysql));
if (!option_force)
return 1;
@ -502,11 +564,18 @@ static my_bool sql_connect(MYSQL *mysql, uint wait)
}
/*
Execute a command.
Return 0 on ok
-1 on retryable error
1 on fatal error
/**
@brief Execute all commands
@details We try to execute all commands we were given, in the order
given, but return with non-zero as soon as we encounter trouble.
By that token, individual commands can be considered a conjunction
with boolean short-cut.
@return success?
@retval 0 Yes! ALL commands worked!
@retval 1 No, one failed and will never work (malformed): fatal error!
@retval -1 No, one failed on the server, may work next time!
*/
static int execute_commands(MYSQL *mysql,int argc, char **argv)
@ -577,7 +646,6 @@ static int execute_commands(MYSQL *mysql,int argc, char **argv)
mysql_error(mysql));
return -1;
}
mysql_close(mysql); /* Close connection to avoid error messages */
argc=1; /* force SHUTDOWN to be the last command */
if (got_pidfile)
{
@ -1130,14 +1198,16 @@ static void usage(void)
static int drop_db(MYSQL *mysql, const char *db)
{
char name_buff[FN_REFLEN+20], buf[10];
char *input;
if (!option_force)
{
puts("Dropping the database is potentially a very bad thing to do.");
puts("Any data stored in the database will be destroyed.\n");
printf("Do you really want to drop the '%s' database [y/N] ",db);
fflush(stdout);
if (fgets(buf,sizeof(buf)-1,stdin) == 0 ||
(*buf != 'y') && (*buf != 'Y'))
input= fgets(buf, sizeof(buf)-1, stdin);
if (!input || ((*input != 'y') && (*input != 'Y')))
{
puts("\nOK, aborting database drop!");
return -1;

View File

@ -5008,7 +5008,7 @@ int main(int argc, char **argv)
exit_code= get_options(&argc, &argv);
if (exit_code)
{
free_resources(0);
free_resources();
exit(exit_code);
}
@ -5016,14 +5016,14 @@ int main(int argc, char **argv)
{
if(!(stderror_file= freopen(log_error_file, "a+", stderr)))
{
free_resources(0);
free_resources();
exit(EX_MYSQLERR);
}
}
if (connect_to_db(current_host, current_user, opt_password))
{
free_resources(0);
free_resources();
exit(EX_MYSQLERR);
}
if (!path)

View File

@ -443,10 +443,12 @@ DYNAMIC_STRING ds_res;
char builtin_echo[FN_REFLEN];
static void cleanup_and_exit(int exit_code) __attribute__((noreturn));
void die(const char *fmt, ...)
ATTRIBUTE_FORMAT(printf, 1, 2);
ATTRIBUTE_FORMAT(printf, 1, 2) __attribute__((noreturn));
void abort_not_supported_test(const char *fmt, ...)
ATTRIBUTE_FORMAT(printf, 1, 2);
ATTRIBUTE_FORMAT(printf, 1, 2) __attribute__((noreturn));
void verbose_msg(const char *fmt, ...)
ATTRIBUTE_FORMAT(printf, 1, 2);
void log_msg(const char *fmt, ...)
@ -3737,10 +3739,9 @@ void do_wait_for_slave_to_stop(struct st_command *c __attribute__((unused)))
MYSQL* mysql = &cur_con->mysql;
for (;;)
{
MYSQL_RES *res;
MYSQL_RES *UNINIT_VAR(res);
MYSQL_ROW row;
int done;
LINT_INIT(res);
if (mysql_query(mysql,"show status like 'Slave_running'") ||
!(res=mysql_store_result(mysql)))
@ -5275,13 +5276,12 @@ my_bool end_of_query(int c)
int read_line(char *buf, int size)
{
char c, last_quote;
char c, UNINIT_VAR(last_quote);
char *p= buf, *buf_end= buf + size - 1;
int skip_char= 0;
enum {R_NORMAL, R_Q, R_SLASH_IN_Q,
R_COMMENT, R_LINE_START} state= R_LINE_START;
DBUG_ENTER("read_line");
LINT_INIT(last_quote);
start_lineno= cur_file->lineno;
DBUG_PRINT("info", ("Starting to read at lineno: %d", start_lineno));
@ -6530,8 +6530,7 @@ void run_query_normal(struct st_connection *cn, struct st_command *command,
if (!disable_result_log)
{
ulonglong affected_rows; /* Ok to be undef if 'disable_info' is set */
LINT_INIT(affected_rows);
ulonglong UNINIT_VAR(affected_rows); /* Ok to be undef if 'disable_info' is set */
if (res)
{

View File

@ -339,9 +339,7 @@ rl_generic_bind (type, keyseq, data, map)
char *keys;
int keys_len;
register int i;
KEYMAP_ENTRY k;
k.function = 0;
KEYMAP_ENTRY k= { 0, NULL };
/* If no keys to bind to, exit right away. */
if (keyseq == 0 || *keyseq == 0)
@ -776,7 +774,7 @@ _rl_read_file (filename, sizep)
file_size = (size_t)finfo.st_size;
/* check for overflow on very large files */
if ((sizeof(off_t) > sizeof(size_t) && finfo.st_size > (off_t)(size_t)~0) ||
if ((sizeof(off_t) > sizeof(size_t) && finfo.st_size > (off_t)(size_t)~0) ||
file_size + 1 < file_size)
{
if (file >= 0)

View File

@ -186,7 +186,7 @@ read_history_range (filename, from, to)
file_size = (size_t)finfo.st_size;
/* check for overflow on very large files */
if ((sizeof(off_t) > sizeof(size_t) && finfo.st_size > (off_t)(size_t)~0) ||
if ((sizeof(off_t) > sizeof(size_t) && finfo.st_size > (off_t)(size_t)~0) ||
file_size + 1 < file_size)
{
errno = overflow_errno;
@ -311,6 +311,7 @@ history_truncate_file (fname, lines)
int file, chars_read, rv;
struct stat finfo;
size_t file_size;
size_t bytes_written;
buffer = (char *)NULL;
filename = history_filename (fname);
@ -340,7 +341,7 @@ history_truncate_file (fname, lines)
file_size = (size_t)finfo.st_size;
/* check for overflow on very large files */
if ((sizeof(off_t) > sizeof(size_t) && finfo.st_size > (off_t)(size_t)~0) ||
if ((sizeof(off_t) > sizeof(size_t) && finfo.st_size > (off_t)(size_t)~0) ||
file_size + 1 < file_size)
{
close (file);
@ -400,7 +401,7 @@ if ((sizeof(off_t) > sizeof(size_t) && finfo.st_size > (off_t)(size_t)~0) ||
truncate to. */
if (bp > buffer && ((file = open (filename, O_WRONLY|O_TRUNC|O_BINARY, 0600)) != -1))
{
write (file, bp, chars_read - (bp - buffer));
bytes_written= write (file, bp, chars_read - (bp - buffer));
#if defined (__BEOS__)
/* BeOS ignores O_TRUNC. */

View File

@ -137,7 +137,8 @@ UNDO_LIST *
_rl_copy_undo_list (head)
UNDO_LIST *head;
{
UNDO_LIST *list, *new, *roving, *c;
UNDO_LIST *list, *new, *c;
UNDO_LIST *roving= NULL;
list = head;
new = 0;

View File

@ -70,6 +70,11 @@ struct event_base {
/* Internal use only: Functions that might be missing from <sys/queue.h> */
#ifndef HAVE_TAILQFOREACH
/* These following macros are copied from BSD sys/queue.h
Copyright (c) 1991, 1993, The Regents of the University of California.
All rights reserved.
*/
#define TAILQ_EMPTY(head) ((head)->tqh_first == NULL)
#define TAILQ_FIRST(head) ((head)->tqh_first)
#define TAILQ_END(head) NULL
#define TAILQ_NEXT(elm, field) ((elm)->field.tqe_next)

View File

@ -55,6 +55,7 @@ void Twofish::Process(byte* out, const byte* in, word32 sz)
in += BLOCK_SIZE;
}
else if (mode_ == CBC)
{
if (dir_ == ENCRYPTION)
while (blocks--) {
r_[0] ^= *(word32*)in;
@ -82,6 +83,7 @@ void Twofish::Process(byte* out, const byte* in, word32 sz)
out += BLOCK_SIZE;
in += BLOCK_SIZE;
}
}
}
#endif // DO_TWOFISH_ASM

View File

@ -578,6 +578,25 @@ int __void__;
#define IF_VALGRIND(A,B) (B)
#endif
/*
Suppress uninitialized variable warning without generating code.
The _cplusplus is a temporary workaround for C++ code pending a fix
for a g++ bug (http://gcc.gnu.org/bugzilla/show_bug.cgi?id=34772).
*/
#if defined(_lint) || defined(FORCE_INIT_OF_VARS) || defined(__cplusplus) || \
!defined(__GNUC__)
#define UNINIT_VAR(x) x= 0
#else
#define UNINIT_VAR(x) x= x
#endif
/* Define some useful general macros */
#if !defined(max)
#define max(a, b) ((a) > (b) ? (a) : (b))
#define min(a, b) ((a) < (b) ? (a) : (b))
#endif
#if !defined(HAVE_UINT)
#undef HAVE_UINT
#define HAVE_UINT

View File

@ -68,7 +68,8 @@ enum enum_server_command
COM_END
};
/* sql type stored in .frm files for virtual fields */
#define MYSQL_TYPE_VIRTUAL 245
/*
Length of random string sent by server on handshake; this is also length of
obfuscated password, recieved from client

View File

@ -1648,8 +1648,7 @@ myodbc_remove_escape(MYSQL *mysql,char *name)
char *to;
#ifdef USE_MB
my_bool use_mb_flag=use_mb(mysql->charset);
char *end;
LINT_INIT(end);
char *UNINIT_VAR(end);
if (use_mb_flag)
for (end=name; *end ; end++) ;
#endif

View File

@ -124,7 +124,7 @@ handler.o: handler.cc
# found to append fileslists that collected by configure
# to the sources list
ha_federated.o:ha_federated.cc
ha_federatedx.o:ha_federatedx.cc
$(CXXCOMPILE) $(LM_CFLAGS) -c $<
ha_heap.o:ha_heap.cc

View File

@ -2,12 +2,5 @@ funcs_1.charset_collation_1 # depends on compile-time decisions
binlog.binlog_tmp_table # Bug#45578: Test binlog_tmp_table fails ramdonly on PB2: Unknown table 't2'
main.ctype_gbk_binlog # Bug#46010: main.ctype_gbk_binlog fails sporadically : Table 't2' already exists
rpl.rpl_row_create_table # Bug#45576: rpl_row_create_table fails on PB2
rpl.rpl_extraColmaster_myisam # Bug#46013: rpl_extraColmaster_myisam fails on pb2
rpl.rpl_stm_reset_slave # Bug#46014: rpl_stm_reset_slave crashes the server sporadically in pb2
rpl.rpl_extraCol_myisam # Bug#40796
rpl.rpl_extraColmaster_innodb # Bug#40796
rpl.rpl_extraCol_innodb # Bug#40796
rpl_ndb.rpl_ndb_log # Bug#38998
rpl.rpl_innodb_bug28430 # Bug#46029
rpl.rpl_row_basic_3innodb # Bug#45243
rpl.rpl_truncate_3innodb # Bug#46030

View File

@ -0,0 +1,710 @@
###################################################################################
# This test checks if transactions that mixes transactional and non-transactional
# tables are correctly handled in statement mode. In an nutshell, we have what
# follows:
#
# 1) "B T T C" generates in binlog the "B T T C" entries.
#
# 2) "B T T R" generates in binlog an "empty" entry.
#
# 3) "B T N C" generates in binlog the "B T N C" entries.
#
# 4) "B T N R" generates in binlog the "B T N R" entries.
#
# 5) "T" generates in binlog the "B T C" entry.
#
# 6) "N" generates in binlog the "N" entry.
#
# 7) "M" generates in binglog the "B M C" entries.
#
# 8) "B N N T C" generates in binglog the "N N B T C" entries.
#
# 9) "B N N T R" generates in binlog the "N N B T R" entries.
#
# 10) "B N N C" generates in binglog the "N N" entries.
#
# 11) "B N N R" generates in binlog the "N N" entries.
#
# 12) "B M T C" generates in the binlog the "B M T C" entries.
#
# 13) "B M T R" generates in the binlog the "B M T R" entries.
###################################################################################
--echo ###################################################################################
--echo # CONFIGURATION
--echo ###################################################################################
connection master;
SET SQL_LOG_BIN=0;
CREATE TABLE nt_1 (a text, b int PRIMARY KEY, c text) ENGINE = MyISAM;
CREATE TABLE nt_2 (a text, b int PRIMARY KEY, c text) ENGINE = MyISAM;
CREATE TABLE nt_3 (a text, b int PRIMARY KEY, c text) ENGINE = MyISAM;
CREATE TABLE nt_4 (a text, b int PRIMARY KEY, c text) ENGINE = MyISAM;
CREATE TABLE tt_1 (a text, b int PRIMARY KEY, c text) ENGINE = Innodb;
CREATE TABLE tt_2 (a text, b int PRIMARY KEY, c text) ENGINE = Innodb;
CREATE TABLE tt_3 (a text, b int PRIMARY KEY, c text) ENGINE = Innodb;
CREATE TABLE tt_4 (a text, b int PRIMARY KEY, c text) ENGINE = Innodb;
SET SQL_LOG_BIN=1;
connection slave;
SET SQL_LOG_BIN=0;
CREATE TABLE nt_1 (a text, b int PRIMARY KEY, c text) ENGINE = MyISAM;
CREATE TABLE nt_2 (a text, b int PRIMARY KEY, c text) ENGINE = MyISAM;
CREATE TABLE nt_3 (a text, b int PRIMARY KEY, c text) ENGINE = MyISAM;
CREATE TABLE nt_4 (a text, b int PRIMARY KEY, c text) ENGINE = MyISAM;
CREATE TABLE tt_1 (a text, b int PRIMARY KEY, c text) ENGINE = Innodb;
CREATE TABLE tt_2 (a text, b int PRIMARY KEY, c text) ENGINE = Innodb;
CREATE TABLE tt_3 (a text, b int PRIMARY KEY, c text) ENGINE = Innodb;
CREATE TABLE tt_4 (a text, b int PRIMARY KEY, c text) ENGINE = Innodb;
SET SQL_LOG_BIN=1;
connection master;
DELIMITER |;
CREATE FUNCTION f1 () RETURNS VARCHAR(64)
BEGIN
RETURN "Testing...";
END|
CREATE FUNCTION f2 () RETURNS VARCHAR(64)
BEGIN
RETURN f1();
END|
CREATE PROCEDURE pc_i_tt_3 (IN x INT, IN y VARCHAR(64))
BEGIN
INSERT INTO tt_3 VALUES (y,x,x);
END|
CREATE TRIGGER tr_i_tt_3_to_nt_3 BEFORE INSERT ON tt_3 FOR EACH ROW
BEGIN
INSERT INTO nt_3 VALUES (NEW.a, NEW.b, NEW.c);
END|
CREATE TRIGGER tr_i_nt_4_to_tt_4 BEFORE INSERT ON nt_4 FOR EACH ROW
BEGIN
INSERT INTO tt_4 VALUES (NEW.a, NEW.b, NEW.c);
END|
DELIMITER ;|
--echo ###################################################################################
--echo # MIXING TRANSACTIONAL and NON-TRANSACTIONAL TABLES
--echo ###################################################################################
connection master;
let $binlog_start= query_get_value("SHOW MASTER STATUS", Position, 1);
--echo #
--echo #1) "B T T C" generates in binlog the "B T T C" entries.
--echo #
BEGIN;
INSERT INTO tt_1 VALUES ("new text 4", 4, "new text 4");
INSERT INTO tt_2 VALUES ("new text 4", 4, "new text 4");
COMMIT;
--source include/show_binlog_events.inc
--echo
--echo
--echo
--echo
let $binlog_start= query_get_value("SHOW MASTER STATUS", Position, 1);
--echo #
--echo #1.e) "B T T C" with error in T generates in binlog the "B T T C" entries.
--echo #
INSERT INTO tt_1 VALUES ("new text -2", -2, "new text -2");
BEGIN;
--error ER_DUP_ENTRY
INSERT INTO tt_1 VALUES ("new text -1", -1, "new text -1"), ("new text -2", -2, "new text -2");
INSERT INTO tt_2 VALUES ("new text -3", -3, "new text -3");
COMMIT;
BEGIN;
INSERT INTO tt_2 VALUES ("new text -5", -5, "new text -5");
--error ER_DUP_ENTRY
INSERT INTO tt_2 VALUES ("new text -4", -4, "new text -4"), ("new text -5", -5, "new text -5");
COMMIT;
--source include/show_binlog_events.inc
--echo
--echo
--echo
--echo
let $binlog_start= query_get_value("SHOW MASTER STATUS", Position, 1);
--echo #
--echo #2) "B T T R" generates in binlog an "empty" entry.
--echo #
BEGIN;
INSERT INTO tt_1 VALUES ("new text 5", 5, "new text 5");
INSERT INTO tt_2 VALUES ("new text 5", 5, "new text 5");
ROLLBACK;
--source include/show_binlog_events.inc
--echo
--echo
--echo
--echo
let $binlog_start= query_get_value("SHOW MASTER STATUS", Position, 1);
--echo #
--echo #2.e) "B T T R" with error in T generates in binlog an "empty" entry.
--echo #
INSERT INTO tt_1 VALUES ("new text -7", -7, "new text -7");
BEGIN;
--error ER_DUP_ENTRY
INSERT INTO tt_1 VALUES ("new text -6", -6, "new text -6"), ("new text -7", -7, "new text -7");
INSERT INTO tt_2 VALUES ("new text -8", -8, "new text -8");
ROLLBACK;
BEGIN;
INSERT INTO tt_2 VALUES ("new text -10", -10, "new text -10");
--error ER_DUP_ENTRY
INSERT INTO tt_2 VALUES ("new text -9", -9, "new text -9"), ("new text -10", -10, "new text -10");
ROLLBACK;
--source include/show_binlog_events.inc
--echo
--echo
--echo
--echo
let $binlog_start= query_get_value("SHOW MASTER STATUS", Position, 1);
--echo #
--echo #3) "B T N C" generates in binlog the "B T N C" entries.
--echo #
BEGIN;
INSERT INTO tt_1 VALUES ("new text 6", 6, "new text 6");
INSERT INTO nt_1 VALUES ("new text 6", 6, "new text 6");
COMMIT;
--source include/show_binlog_events.inc
--echo
--echo
--echo
--echo
let $binlog_start= query_get_value("SHOW MASTER STATUS", Position, 1);
--echo #
--echo #3.e) "B T N C" with error in either T or N generates in binlog the "B T N C" entries.
--echo #
INSERT INTO tt_1 VALUES ("new text -12", -12, "new text -12");
BEGIN;
--error ER_DUP_ENTRY
INSERT INTO tt_1 VALUES ("new text -11", -11, "new text -11"), ("new text -12", -12, "new text -12");
INSERT INTO nt_1 VALUES ("new text -13", -13, "new text -13");
COMMIT;
BEGIN;
INSERT INTO tt_1 VALUES ("new text -14", -14, "new text -14");
INSERT INTO nt_1 VALUES ("new text -16", -16, "new text -16");
--error ER_DUP_ENTRY
INSERT INTO nt_1 VALUES ("new text -15", -15, "new text -15"), ("new text -16", -16, "new text -16");
COMMIT;
--source include/show_binlog_events.inc
--echo
--echo
--echo
--echo
let $binlog_start= query_get_value("SHOW MASTER STATUS", Position, 1);
--echo #
--echo #4) "B T N R" generates in binlog the "B T N R" entries.
--echo #
BEGIN;
INSERT INTO tt_1 VALUES ("new text 7", 7, "new text 7");
INSERT INTO nt_1 VALUES ("new text 7", 7, "new text 7");
ROLLBACK;
--source include/show_binlog_events.inc
--echo
--echo
--echo
--echo
let $binlog_start= query_get_value("SHOW MASTER STATUS", Position, 1);
--echo #
--echo #4.e) "B T N R" with error in either T or N generates in binlog the "B T N R" entries.
--echo #
INSERT INTO tt_1 VALUES ("new text -17", -17, "new text -17");
BEGIN;
--error ER_DUP_ENTRY
INSERT INTO tt_1 VALUES ("new text -16", -16, "new text -16"), ("new text -17", -17, "new text -17");
INSERT INTO nt_1 VALUES ("new text -18", -18, "new text -18");
ROLLBACK;
BEGIN;
INSERT INTO tt_1 VALUES ("new text -19", -19, "new text -19");
INSERT INTO nt_1 VALUES ("new text -21", -21, "new text -21");
--error ER_DUP_ENTRY
INSERT INTO nt_1 VALUES ("new text -20", -20, "new text -20"), ("new text -21", -21, "new text -21");
ROLLBACK;
--source include/show_binlog_events.inc
--echo
--echo
--echo
--echo
let $binlog_start= query_get_value("SHOW MASTER STATUS", Position, 1);
--echo #
--echo #5) "T" generates in binlog the "B T C" entry.
--echo #
INSERT INTO tt_1 VALUES ("new text 8", 8, "new text 8");
--source include/show_binlog_events.inc
--echo
--echo
--echo
--echo
let $binlog_start= query_get_value("SHOW MASTER STATUS", Position, 1);
--echo #
--echo #5.e) "T" with error in T generates in binlog an "empty" entry.
--echo #
INSERT INTO tt_1 VALUES ("new text -1", -1, "new text -1");
--error ER_DUP_ENTRY
INSERT INTO tt_1 VALUES ("new text -1", -1, "new text -1"), ("new text -22", -22, "new text -22");
--error ER_DUP_ENTRY
INSERT INTO tt_1 VALUES ("new text -23", -23, "new text -23"), ("new text -1", -1, "new text -1");
--source include/show_binlog_events.inc
--echo
--echo
--echo
--echo
let $binlog_start= query_get_value("SHOW MASTER STATUS", Position, 1);
--echo #
--echo #6) "N" generates in binlog the "N" entry.
--echo #
INSERT INTO nt_1 VALUES ("new text 9", 9, "new text 9");
--source include/show_binlog_events.inc
--echo
--echo
--echo
--echo
let $binlog_start= query_get_value("SHOW MASTER STATUS", Position, 1);
--echo #
--echo #6.e) "N" with error in N generates in binlog an empty entry if the error
--echo # happens in the first tuple. Otherwise, generates the "N" entry and
--echo # the error is appended.
--echo #
INSERT INTO nt_1 VALUES ("new text -1", -1, "new text -1");
--error ER_DUP_ENTRY
INSERT INTO nt_1 VALUES ("new text -1", -1, "new text -1");
--error ER_DUP_ENTRY
INSERT INTO nt_1 VALUES ("new text -24", -24, "new text -24"), ("new text -1", -1, "new text -1");
--source include/show_binlog_events.inc
--echo
--echo
--echo
--echo
let $binlog_start= query_get_value("SHOW MASTER STATUS", Position, 1);
--echo #
--echo #7) "M" generates in binglog the "B M C" entries.
--echo #
DELETE FROM nt_1;
INSERT INTO nt_1 SELECT * FROM tt_1;
DELETE FROM tt_1;
INSERT INTO tt_1 SELECT * FROM nt_1;
INSERT INTO tt_3 VALUES ("new text 000", 000, '');
INSERT INTO tt_3 VALUES("new text 100", 100, f1());
INSERT INTO nt_4 VALUES("new text 100", 100, f1());
INSERT INTO tt_3 VALUES("new text 200", 200, f2());
INSERT INTO nt_4 VALUES ("new text 300", 300, '');
INSERT INTO nt_4 VALUES ("new text 400", 400, f1());
INSERT INTO nt_4 VALUES ("new text 500", 500, f2());
CALL pc_i_tt_3(600, "Testing...");
UPDATE nt_3, nt_4, tt_3, tt_4 SET nt_3.a= "new text 1", nt_4.a= "new text 1", tt_3.a= "new text 1", tt_4.a= "new text 1" where nt_3.b = nt_4.b and nt_4.b = tt_3.b and tt_3.b = tt_4.b and tt_4.b = 100;
UPDATE tt_3, tt_4, nt_3, nt_4 SET tt_3.a= "new text 2", tt_4.a= "new text 2", nt_3.a= "new text 2", nt_4.a = "new text 2" where nt_3.b = nt_4.b and nt_4.b = tt_3.b and tt_3.b = tt_4.b and tt_4.b = 100;
UPDATE tt_3, nt_3, nt_4, tt_4 SET tt_3.a= "new text 3", nt_3.a= "new text 3", nt_4.a= "new text 3", tt_4.a = "new text 3" where nt_3.b = nt_4.b and nt_4.b = tt_3.b and tt_3.b = tt_4.b and tt_4.b = 100;
UPDATE tt_3, nt_3, nt_4, tt_4 SET tt_3.a= "new text 4", nt_3.a= "new text 4", nt_4.a= "new text 4", tt_4.a = "new text 4" where nt_3.b = nt_4.b and nt_4.b = tt_3.b and tt_3.b = tt_4.b and tt_4.b = 100;
--source include/show_binlog_events.inc
--echo
--echo
--echo
--echo
let $binlog_start= query_get_value("SHOW MASTER STATUS", Position, 1);
--echo #
--echo #7.e) "M" with error in M generates in binglog the "B M R" entries.
--echo #
INSERT INTO nt_3 VALUES ("new text -26", -26, '');
SELECT * FROM tt_3;
--error ER_DUP_ENTRY
INSERT INTO tt_3 VALUES ("new text -25", -25, ''), ("new text -26", -26, '');
SELECT * FROM tt_3;
INSERT INTO tt_4 VALUES ("new text -26", -26, '');
SELECT * FROM nt_4;
--error ER_DUP_ENTRY
INSERT INTO nt_4 VALUES ("new text -25", -25, ''), ("new text -26", -26, '');
SELECT * FROM nt_4;
--source include/show_binlog_events.inc
--echo
--echo
--echo
--echo
let $binlog_start= query_get_value("SHOW MASTER STATUS", Position, 1);
--echo #
--echo #8) "B N N T C" generates in binglog the "N N B T C" entries.
--echo #
BEGIN;
INSERT INTO nt_1 VALUES ("new text 10", 10, "new text 10");
INSERT INTO nt_2 VALUES ("new text 10", 10, "new text 10");
INSERT INTO tt_1 VALUES ("new text 10", 10, "new text 10");
COMMIT;
--source include/show_binlog_events.inc
--echo
--echo
--echo
--echo
--echo #
--echo #8.e) "B N N T R" See 6.e and 9.e.
--echo #
--echo
--echo
--echo
--echo
let $binlog_start= query_get_value("SHOW MASTER STATUS", Position, 1);
--echo #
--echo #9) "B N N T R" generates in binlog the "N N B T R" entries.
--echo #
BEGIN;
INSERT INTO nt_1 VALUES ("new text 11", 11, "new text 11");
INSERT INTO nt_2 VALUES ("new text 11", 11, "new text 11");
INSERT INTO tt_1 VALUES ("new text 11", 11, "new text 11");
ROLLBACK;
--source include/show_binlog_events.inc
--echo
--echo
--echo
--echo
let $binlog_start= query_get_value("SHOW MASTER STATUS", Position, 1);
--echo #
--echo #9.e) "B N N T R" with error in N generates in binlog the "N N B T R" entries.
--echo #
BEGIN;
INSERT INTO nt_1 VALUES ("new text -25", -25, "new text -25");
INSERT INTO nt_2 VALUES ("new text -25", -25, "new text -25");
--error ER_DUP_ENTRY
INSERT INTO nt_2 VALUES ("new text -26", -26, "new text -26"), ("new text -25", -25, "new text -25");
INSERT INTO tt_1 VALUES ("new text -27", -27, "new text -27");
ROLLBACK;
--source include/show_binlog_events.inc
--echo
--echo
--echo
--echo
let $binlog_start= query_get_value("SHOW MASTER STATUS", Position, 1);
--echo #
--echo #10) "B N N C" generates in binglog the "N N" entries.
--echo #
BEGIN;
INSERT INTO nt_1 VALUES ("new text 12", 12, "new text 12");
INSERT INTO nt_2 VALUES ("new text 12", 12, "new text 12");
COMMIT;
--source include/show_binlog_events.inc
--echo
--echo
--echo
--echo
--echo #
--echo #10.e) "B N N C" See 6.e and 9.e.
--echo #
--echo
--echo
--echo
--echo
let $binlog_start= query_get_value("SHOW MASTER STATUS", Position, 1);
--echo #
--echo #11) "B N N R" generates in binlog the "N N" entries.
--echo #
BEGIN;
INSERT INTO nt_1 VALUES ("new text 13", 13, "new text 13");
INSERT INTO nt_2 VALUES ("new text 13", 13, "new text 13");
ROLLBACK;
--source include/show_binlog_events.inc
--echo
--echo
--echo
--echo
--echo #
--echo #11.e) "B N N R" See 6.e and 9.e.
--echo #
--echo
--echo
--echo
--echo
let $binlog_start= query_get_value("SHOW MASTER STATUS", Position, 1);
--echo #
--echo #12) "B M T C" generates in the binlog the "B M T C" entries.
--echo #
DELETE FROM nt_1;
BEGIN;
INSERT INTO nt_1 SELECT * FROM tt_1;
INSERT INTO tt_2 VALUES ("new text 14", 14, "new text 14");
COMMIT;
DELETE FROM tt_1;
BEGIN;
INSERT INTO tt_1 SELECT * FROM nt_1;
INSERT INTO tt_2 VALUES ("new text 15", 15, "new text 15");
COMMIT;
BEGIN;
INSERT INTO tt_3 VALUES ("new text 700", 700, '');
INSERT INTO tt_1 VALUES ("new text 800", 800, '');
COMMIT;
BEGIN;
INSERT INTO tt_3 VALUES("new text 900", 900, f1());
INSERT INTO tt_1 VALUES ("new text 1000", 1000, '');
COMMIT;
BEGIN;
INSERT INTO tt_3 VALUES(1100, 1100, f2());
INSERT INTO tt_1 VALUES ("new text 1200", 1200, '');
COMMIT;
BEGIN;
INSERT INTO nt_4 VALUES ("new text 1300", 1300, '');
INSERT INTO tt_1 VALUES ("new text 1400", 1400, '');
COMMIT;
BEGIN;
INSERT INTO nt_4 VALUES("new text 1500", 1500, f1());
INSERT INTO tt_1 VALUES ("new text 1600", 1600, '');
COMMIT;
BEGIN;
INSERT INTO nt_4 VALUES("new text 1700", 1700, f2());
INSERT INTO tt_1 VALUES ("new text 1800", 1800, '');
COMMIT;
BEGIN;
CALL pc_i_tt_3(1900, "Testing...");
INSERT INTO tt_1 VALUES ("new text 2000", 2000, '');
COMMIT;
BEGIN;
UPDATE nt_3, nt_4, tt_3, tt_4 SET nt_3.a= "new text 5", nt_4.a= "new text 5", tt_3.a= "new text 5", tt_4.a= "new text 5" where nt_3.b = nt_4.b and nt_4.b = tt_3.b and tt_3.b = tt_4.b and tt_4.b = 100;
INSERT INTO tt_1 VALUES ("new text 2100", 2100, '');
COMMIT;
BEGIN;
UPDATE tt_3, tt_4, nt_3, nt_4 SET tt_3.a= "new text 6", tt_4.a= "new text 6", nt_3.a= "new text 6", nt_4.a = "new text 6" where nt_3.b = nt_4.b and nt_4.b = tt_3.b and tt_3.b = tt_4.b and tt_4.b = 100;
INSERT INTO tt_1 VALUES ("new text 2200", 2200, '');
COMMIT;
BEGIN;
UPDATE tt_3, nt_3, nt_4, tt_4 SET tt_3.a= "new text 7", nt_3.a= "new text 7", nt_4.a= "new text 7", tt_4.a = "new text 7" where nt_3.b = nt_4.b and nt_4.b = tt_3.b and tt_3.b = tt_4.b and tt_4.b = 100;
INSERT INTO tt_1 VALUES ("new text 2300", 2300, '');
COMMIT;
BEGIN;
UPDATE tt_3, nt_3, nt_4, tt_4 SET tt_3.a= "new text 8", nt_3.a= "new text 8", nt_4.a= "new text 8", tt_4.a = "new text 8" where nt_3.b = nt_4.b and nt_4.b = tt_3.b and tt_3.b = tt_4.b and tt_4.b = 100;
INSERT INTO tt_1 VALUES ("new text 2400", 2400, '');
COMMIT;
--source include/show_binlog_events.inc
--echo
--echo
--echo
--echo
let $binlog_start= query_get_value("SHOW MASTER STATUS", Position, 1);
--echo #
--echo #12.e) "B M T C" with error in M generates in the binlog the "B M T C" entries.
--echo #
--echo # There is a bug in the slave that needs to be fixed before enabling
--echo # this part of the test. A bug report will be filed referencing this
--echo # test case.
BEGIN;
INSERT INTO nt_3 VALUES ("new text -28", -28, '');
--error ER_DUP_ENTRY
INSERT INTO tt_3 VALUES ("new text -27", -27, ''), ("new text -28", -28, '');
INSERT INTO tt_1 VALUES ("new text -27", -27, '');
COMMIT;
BEGIN;
INSERT INTO tt_4 VALUES ("new text -28", -28, '');
--error ER_DUP_ENTRY
INSERT INTO nt_4 VALUES ("new text -27", -27, ''), ("new text -28", -28, '');
INSERT INTO tt_1 VALUES ("new text -28", -28, '');
COMMIT;
--source include/show_binlog_events.inc
--echo
--echo
--echo
--echo
let $binlog_start= query_get_value("SHOW MASTER STATUS", Position, 1);
--echo #
--echo #13) "B M T R" generates in the binlog the "B M T R" entries
--echo #
DELETE FROM nt_1;
BEGIN;
INSERT INTO nt_1 SELECT * FROM tt_1;
INSERT INTO tt_2 VALUES ("new text 17", 17, "new text 17");
ROLLBACK;
DELETE FROM tt_1;
BEGIN;
INSERT INTO tt_1 SELECT * FROM nt_1;
INSERT INTO tt_2 VALUES ("new text 18", 18, "new text 18");
ROLLBACK;
INSERT INTO tt_1 SELECT * FROM nt_1;
BEGIN;
INSERT INTO tt_3 VALUES ("new text 2500", 2500, '');
INSERT INTO tt_1 VALUES ("new text 2600", 2600, '');
ROLLBACK;
BEGIN;
INSERT INTO tt_3 VALUES("new text 2700", 2700, f1());
INSERT INTO tt_1 VALUES ("new text 2800", 2800, '');
ROLLBACK;
BEGIN;
INSERT INTO tt_3 VALUES(2900, 2900, f2());
INSERT INTO tt_1 VALUES ("new text 3000", 3000, '');
ROLLBACK;
BEGIN;
INSERT INTO nt_4 VALUES ("new text 3100", 3100, '');
INSERT INTO tt_1 VALUES ("new text 3200", 3200, '');
ROLLBACK;
BEGIN;
INSERT INTO nt_4 VALUES("new text 3300", 3300, f1());
INSERT INTO tt_1 VALUES ("new text 3400", 3400, '');
ROLLBACK;
BEGIN;
INSERT INTO nt_4 VALUES("new text 3500", 3500, f2());
INSERT INTO tt_1 VALUES ("new text 3600", 3600, '');
ROLLBACK;
BEGIN;
CALL pc_i_tt_3(3700, "Testing...");
INSERT INTO tt_1 VALUES ("new text 3700", 3700, '');
ROLLBACK;
BEGIN;
UPDATE nt_3, nt_4, tt_3, tt_4 SET nt_3.a= "new text 9", nt_4.a= "new text 9", tt_3.a= "new text 9", tt_4.a= "new text 9" where nt_3.b = nt_4.b and nt_4.b = tt_3.b and tt_3.b = tt_4.b and tt_4.b = 100;
INSERT INTO tt_1 VALUES ("new text 3800", 3800, '');
ROLLBACK;
BEGIN;
UPDATE tt_3, tt_4, nt_3, nt_4 SET tt_3.a= "new text 10", tt_4.a= "new text 10", nt_3.a= "new text 10", nt_4.a = "new text 10" where nt_3.b = nt_4.b and nt_4.b = tt_3.b and tt_3.b = tt_4.b and tt_4.b = 100;
INSERT INTO tt_1 VALUES ("new text 3900", 3900, '');
ROLLBACK;
BEGIN;
UPDATE tt_3, nt_3, nt_4, tt_4 SET tt_3.a= "new text 11", nt_3.a= "new text 11", nt_4.a= "new text 11", tt_4.a = "new text 11" where nt_3.b = nt_4.b and nt_4.b = tt_3.b and tt_3.b = tt_4.b and tt_4.b = 100;
INSERT INTO tt_1 VALUES ("new text 4000", 4000, '');
ROLLBACK;
BEGIN;
UPDATE tt_3, nt_3, nt_4, tt_4 SET tt_3.a= "new text 12", nt_3.a= "new text 12", nt_4.a= "new text 12", tt_4.a = "new text 12" where nt_3.b = nt_4.b and nt_4.b = tt_3.b and tt_3.b = tt_4.b and tt_4.b = 100;
INSERT INTO tt_1 VALUES ("new text 4100", 4100, '');
ROLLBACK;
--source include/show_binlog_events.inc
--echo
--echo
--echo
--echo
let $binlog_start= query_get_value("SHOW MASTER STATUS", Position, 1);
--echo #
--echo #13.e) "B M T R" with error in M generates in the binlog the "B M T R" entries.
--echo #
BEGIN;
INSERT INTO nt_3 VALUES ("new text -30", -30, '');
--error ER_DUP_ENTRY
INSERT INTO tt_3 VALUES ("new text -29", -29, ''), ("new text -30", -30, '');
INSERT INTO tt_1 VALUES ("new text -30", -30, '');
ROLLBACK;
BEGIN;
INSERT INTO tt_4 VALUES ("new text -30", -30, '');
--error ER_DUP_ENTRY
INSERT INTO nt_4 VALUES ("new text -29", -29, ''), ("new text -30", -30, '');
INSERT INTO tt_1 VALUES ("new text -31", -31, '');
ROLLBACK;
--source include/show_binlog_events.inc
connection master;
sync_slave_with_master;
--exec $MYSQL_DUMP --compact --order-by-primary --skip-extended-insert --no-create-info test > $MYSQLTEST_VARDIR/tmp/test-master.sql
--exec $MYSQL_DUMP_SLAVE --compact --order-by-primary --skip-extended-insert --no-create-info test > $MYSQLTEST_VARDIR/tmp/test-slave.sql
--diff_files $MYSQLTEST_VARDIR/tmp/test-master.sql $MYSQLTEST_VARDIR/tmp/test-slave.sql
--echo ###################################################################################
--echo # CLEAN
--echo ###################################################################################
connection master;
DROP TABLE tt_1;
DROP TABLE tt_2;
DROP TABLE tt_3;
DROP TABLE tt_4;
DROP TABLE nt_1;
DROP TABLE nt_2;
DROP TABLE nt_3;
DROP TABLE nt_4;
DROP PROCEDURE pc_i_tt_3;
DROP FUNCTION f1;
DROP FUNCTION f2;
sync_slave_with_master;

View File

@ -725,9 +725,9 @@ call p_verify_status_increment(4, 4, 4, 4);
alter table t3 add column (b int);
call p_verify_status_increment(2, 0, 2, 0);
alter table t3 rename t4;
call p_verify_status_increment(1, 0, 1, 0);
call p_verify_status_increment(2, 2, 2, 2);
rename table t4 to t3;
call p_verify_status_increment(1, 0, 1, 0);
call p_verify_status_increment(2, 2, 2, 2);
truncate table t3;
call p_verify_status_increment(4, 4, 4, 4);
create view v1 as select * from t2;

View File

@ -0,0 +1,69 @@
# Created for verifying bug#20577.
# expects TABLE t1 (... , a DATE, ...)
--sorted_result
SELECT * FROM t1 WHERE a < '1001-01-01';
--sorted_result
SELECT * FROM t1 WHERE a <= '1001-01-01';
--sorted_result
SELECT * FROM t1 WHERE a >= '1001-01-01';
--sorted_result
SELECT * FROM t1 WHERE a > '1001-01-01';
--sorted_result
SELECT * FROM t1 WHERE a = '1001-01-01';
--sorted_result
SELECT * FROM t1 WHERE a < '1001-00-00';
--sorted_result
SELECT * FROM t1 WHERE a <= '1001-00-00';
--sorted_result
SELECT * FROM t1 WHERE a >= '1001-00-00';
--sorted_result
SELECT * FROM t1 WHERE a > '1001-00-00';
--sorted_result
SELECT * FROM t1 WHERE a = '1001-00-00';
--echo # Disabling warnings for the invalid date
--disable_warnings
--sorted_result
SELECT * FROM t1 WHERE a < '1999-02-31';
--sorted_result
SELECT * FROM t1 WHERE a <= '1999-02-31';
--sorted_result
SELECT * FROM t1 WHERE a >= '1999-02-31';
--sorted_result
SELECT * FROM t1 WHERE a > '1999-02-31';
--sorted_result
SELECT * FROM t1 WHERE a = '1999-02-31';
--enable_warnings
--sorted_result
SELECT * FROM t1 WHERE a BETWEEN '0000-00-00' AND '1002-00-00';
--sorted_result
SELECT * FROM t1 WHERE a BETWEEN '0000-00-00' AND '1001-01-01';
--sorted_result
SELECT * FROM t1 WHERE a BETWEEN '0001-01-02' AND '1002-00-00';
--sorted_result
SELECT * FROM t1 WHERE a BETWEEN '0001-01-01' AND '1001-01-01';
if ($explain_partitions)
{
EXPLAIN PARTITIONS SELECT * FROM t1 WHERE a < '1001-01-01';
EXPLAIN PARTITIONS SELECT * FROM t1 WHERE a <= '1001-01-01';
EXPLAIN PARTITIONS SELECT * FROM t1 WHERE a >= '1001-01-01';
EXPLAIN PARTITIONS SELECT * FROM t1 WHERE a > '1001-01-01';
EXPLAIN PARTITIONS SELECT * FROM t1 WHERE a = '1001-01-01';
EXPLAIN PARTITIONS SELECT * FROM t1 WHERE a < '1001-00-00';
EXPLAIN PARTITIONS SELECT * FROM t1 WHERE a <= '1001-00-00';
EXPLAIN PARTITIONS SELECT * FROM t1 WHERE a >= '1001-00-00';
EXPLAIN PARTITIONS SELECT * FROM t1 WHERE a > '1001-00-00';
EXPLAIN PARTITIONS SELECT * FROM t1 WHERE a = '1001-00-00';
--echo # Disabling warnings for the invalid date
--disable_warnings
EXPLAIN PARTITIONS SELECT * FROM t1 WHERE a < '1999-02-31';
EXPLAIN PARTITIONS SELECT * FROM t1 WHERE a <= '1999-02-31';
EXPLAIN PARTITIONS SELECT * FROM t1 WHERE a >= '1999-02-31';
EXPLAIN PARTITIONS SELECT * FROM t1 WHERE a > '1999-02-31';
EXPLAIN PARTITIONS SELECT * FROM t1 WHERE a = '1999-02-31';
--enable_warnings
EXPLAIN PARTITIONS SELECT * FROM t1 WHERE a BETWEEN '0000-00-00' AND '1002-00-00';
EXPLAIN PARTITIONS SELECT * FROM t1 WHERE a BETWEEN '0000-00-00' AND '1001-01-01';
EXPLAIN PARTITIONS SELECT * FROM t1 WHERE a BETWEEN '0001-01-02' AND '1002-00-00';
EXPLAIN PARTITIONS SELECT * FROM t1 WHERE a BETWEEN '0001-01-01' AND '1001-01-01';
}

View File

@ -0,0 +1,35 @@
connection master;
--disable_warnings
DROP DATABASE IF EXISTS mysqltest;
--enable_warnings
CREATE DATABASE mysqltest CHARSET UTF8;
USE mysqltest;
CREATE TABLE t (cl varchar(100)) CHARSET UTF8;
if (!$LOAD_LOCAL)
{
LOAD DATA INFILE '../../std_data/loaddata_utf8.dat' INTO TABLE t
FIELDS TERMINATED BY ',' LINES TERMINATED BY '\n';
}
if ($LOAD_LOCAL)
{
LOAD DATA LOCAL INFILE './std_data/loaddata_utf8.dat' INTO TABLE t
FIELDS TERMINATED BY ',' LINES TERMINATED BY '\n';
}
save_master_pos;
echo ----------content on master----------;
SELECT hex(cl) FROM t;
connection slave;
sync_with_master;
echo ----------content on slave----------;
USE mysqltest;
SELECT hex(cl) FROM t;
connection master;
DROP DATABASE mysqltest;
save_master_pos;
connection slave;
sync_with_master;

View File

@ -249,6 +249,10 @@ sub collect_one_suite($)
$suitedir= my_find_dir($::basedir,
["mysql-test/suite",
"mysql-test",
"share/mysql-test/suite",
"share/mysql-test",
"share/mysql/mysql-test/suite",
"share/mysql/mysql-test",
# Look in storage engine specific suite dirs
"storage/*/mysql-test-suites"
],

View File

@ -127,7 +127,6 @@ my $path_config_file; # The generated config file, var/my.cnf
our $opt_vs_config = $ENV{'MTR_VS_CONFIG'};
my $DEFAULT_SUITES= "binlog,federated,main,maria,rpl,innodb,parts";
my $opt_suites;
our $opt_usage;
our $opt_list_options;
@ -1001,6 +1000,12 @@ sub command_line_setup {
{
$basedir= dirname($basedir);
}
# For .deb, it's like RPM, but installed in /usr/share/mysql/mysql-test.
# So move up one more directory level yet.
if ( ! $source_dist and ! -d "$basedir/bin" )
{
$basedir= dirname($basedir);
}
# Look for the client binaries directory
if ($path_client_bindir)

View File

@ -28,9 +28,7 @@ test.t1.bool N Y 1 1 0 0 1.0000 NULL ENUM('N','Y') NOT NULL
test.t1.d 2002-03-03 2002-03-05 10 10 0 0 10.0000 NULL ENUM('2002-03-03','2002-03-04','2002-03-05') NOT NULL
drop table t1,t2;
EXPLAIN SELECT 1 FROM (SELECT 1) a PROCEDURE ANALYSE();
id select_type table type possible_keys key key_len ref rows Extra
1 PRIMARY <derived2> system NULL NULL NULL NULL 1
2 DERIVED NULL NULL NULL NULL NULL NULL NULL No tables used
ERROR HY000: Incorrect usage of PROCEDURE and subquery
create table t1 (a int not null);
create table t2 select * from t1 where 0=1 procedure analyse();
show create table t2;
@ -153,4 +151,9 @@ select f3 from t1 procedure analyse(1, 1);
Field_name Min_value Max_value Min_length Max_length Empties_or_zeros Nulls Avg_value_or_avg_length Std Optimal_fieldtype
test.t1.f3 5.99999 9.55555 7 7 0 0 7.77777 1.77778 FLOAT(6,5) NOT NULL
drop table t1;
CREATE TABLE t1(a INT,b INT,c INT,d INT,e INT,f INT,g INT,h INT,i INT,j INT,k INT);
INSERT INTO t1 VALUES ();
SELECT * FROM (SELECT * FROM t1) d PROCEDURE ANALYSE();
ERROR HY000: Incorrect usage of PROCEDURE and subquery
DROP TABLE t1;
End of 4.1 tests

View File

@ -462,3 +462,17 @@ select last_insert_id();
last_insert_id()
3
drop table t1;
#
# Bug#46616: Assertion `!table->auto_increment_field_not_null' on view
# manipulations
#
CREATE TABLE t1 ( a INT );
INSERT INTO t1 VALUES (1), (1);
CREATE TABLE t2 ( a INT AUTO_INCREMENT KEY );
CREATE TABLE IF NOT EXISTS t2 AS SELECT a FROM t1;
ERROR 23000: Duplicate entry '1' for key 'PRIMARY'
UPDATE t2 SET a = 2;
SELECT a FROM t2;
a
2
DROP TABLE t1, t2;

View File

@ -841,17 +841,17 @@ call p_verify_status_increment(2, 0, 2, 0);
SUCCESS
alter table t3 rename t4;
call p_verify_status_increment(1, 0, 1, 0);
call p_verify_status_increment(2, 2, 2, 2);
SUCCESS
rename table t4 to t3;
call p_verify_status_increment(1, 0, 1, 0);
call p_verify_status_increment(2, 2, 2, 2);
SUCCESS
truncate table t3;
call p_verify_status_increment(4, 4, 4, 4);
ERROR
Expected commit increment: 4 actual: 2
SUCCESS
create view v1 as select * from t2;
call p_verify_status_increment(1, 0, 1, 0);
SUCCESS

View File

@ -0,0 +1,2 @@
Variable_name Value
have_partitioning DISABLED

View File

@ -2502,3 +2502,15 @@ a MAX(b)
2 1
DROP TABLE t;
End of 5.0 tests
#
# Bug #46607: Assertion failed: (cond_type == Item::FUNC_ITEM) results in
# server crash
#
CREATE TABLE t (a INT, b INT, INDEX (a,b));
INSERT INTO t VALUES (2,0), (2,0), (2,1), (2,1);
INSERT INTO t SELECT * FROM t;
SELECT a, MAX(b) FROM t WHERE b GROUP BY a;
a MAX(b)
2 1
DROP TABLE t;
End of 5.1 tests

View File

@ -741,3 +741,19 @@ USE information_schema;
HANDLER COLUMNS OPEN;
ERROR HY000: Incorrect usage of HANDLER OPEN and information_schema
USE test;
#
# BUG #46456: HANDLER OPEN + TRUNCATE + DROP (temporary) TABLE, crash
#
CREATE TABLE t1 AS SELECT 1 AS f1;
HANDLER t1 OPEN;
TRUNCATE t1;
HANDLER t1 READ FIRST;
ERROR 42S02: Unknown table 't1' in HANDLER
DROP TABLE t1;
CREATE TEMPORARY TABLE t1 AS SELECT 1 AS f1;
HANDLER t1 OPEN;
TRUNCATE t1;
HANDLER t1 READ FIRST;
ERROR 42S02: Unknown table 't1' in HANDLER
DROP TABLE t1;
End of 5.1 tests

View File

@ -1,3 +1,5 @@
SET @odl_sync_frm = @@global.sync_frm;
SET @@global.sync_frm = OFF;
DROP TABLE IF EXISTS t1;
CREATE TABLE t1( a INT, b INT );
INSERT INTO t1 VALUES (1, 1), (2, 2), (3, 3), (4, 4);
@ -17,3 +19,4 @@ ALTER TABLE t1 ADD COLUMN a INT;
# 2.2.1. normal mode
# 2.2.2. PS mode
DROP TABLE t1;
SET @@global.sync_frm = @odl_sync_frm;

View File

@ -1,3 +1,5 @@
SET @odl_sync_frm = @@global.sync_frm;
SET @@global.sync_frm = OFF;
DROP TABLE IF EXISTS t1,t2,t3;
CREATE TABLE t1 (
a int(11) unsigned default NULL,
@ -15,3 +17,4 @@ CREATE TABLE t3 SELECT * FROM t1;
# normal mode
# PS mode
DROP TABLE t1, t2, t3;
SET @@global.sync_frm = @odl_sync_frm;

View File

@ -2159,4 +2159,16 @@ ERROR HY000: Table storage engine for 'm1' doesn't have this option
DROP TABLE m1,t1,t2,t3,t4,t5,t6,t7;
SELECT 1 FROM m1;
ERROR 42S02: Table 'test.m1' doesn't exist
#
# Bug #46614: Assertion in show_create_trigger()
#
CREATE TABLE t1(a int);
CREATE TABLE t2(a int);
CREATE TABLE t3(a int) ENGINE = MERGE UNION(t1, t2);
CREATE TRIGGER tr1 AFTER INSERT ON t3 FOR EACH ROW CALL foo();
SHOW CREATE TRIGGER tr1;
Trigger sql_mode SQL Original Statement character_set_client collation_connection Database Collation
tr1 CREATE DEFINER=`root`@`localhost` TRIGGER tr1 AFTER INSERT ON t3 FOR EACH ROW CALL foo() latin1 latin1_swedish_ci latin1_swedish_ci
DROP TRIGGER tr1;
DROP TABLE t1, t2, t3;
End of 5.1 tests

View File

@ -215,7 +215,7 @@ 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 t1
BEGIN
/*!*/;
# at #
#010909 4:46:40 server id 1 end_log_pos # Query thread_id=# exec_time=# error_code=0
@ -223,6 +223,22 @@ 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
@ -331,9 +347,17 @@ 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
@ -449,9 +473,17 @@ 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

View File

@ -1,3 +1,48 @@
DROP TABLE IF EXISTS t1;
FLUSH TABLES;
SELECT * FROM t1;
ERROR 42000: Unknown table engine 'partition'
TRUNCATE TABLE t1;
ERROR 42000: Unknown table engine 'partition'
ANALYZE TABLE t1;
Table Op Msg_type Msg_text
test.t1 analyze Error Unknown table engine 'partition'
test.t1 analyze error Corrupt
CHECK TABLE t1;
Table Op Msg_type Msg_text
test.t1 check Error Unknown table engine 'partition'
test.t1 check error Corrupt
OPTIMIZE TABLE t1;
Table Op Msg_type Msg_text
test.t1 optimize Error Unknown table engine 'partition'
test.t1 optimize error Corrupt
REPAIR TABLE t1;
Table Op Msg_type Msg_text
test.t1 repair Error Unknown table engine 'partition'
test.t1 repair error Corrupt
ALTER TABLE t1 REPAIR PARTITION ALL;
Table Op Msg_type Msg_text
test.t1 repair Error Unknown table engine 'partition'
test.t1 repair error Corrupt
ALTER TABLE t1 CHECK PARTITION ALL;
Table Op Msg_type Msg_text
test.t1 check Error Unknown table engine 'partition'
test.t1 check error Corrupt
ALTER TABLE t1 OPTIMIZE PARTITION ALL;
Table Op Msg_type Msg_text
test.t1 optimize Error Unknown table engine 'partition'
test.t1 optimize error Corrupt
ALTER TABLE t1 ANALYZE PARTITION ALL;
Table Op Msg_type Msg_text
test.t1 analyze Error Unknown table engine 'partition'
test.t1 analyze error Corrupt
ALTER TABLE t1 REBUILD PARTITION ALL;
ERROR 42000: Unknown table engine 'partition'
ALTER TABLE t1 ENGINE Memory;
ERROR 42000: Unknown table engine 'partition'
ALTER TABLE t1 ADD (new INT);
ERROR 42000: Unknown table engine 'partition'
DROP TABLE t1;
CREATE TABLE t1 (
firstname VARCHAR(25) NOT NULL,
lastname VARCHAR(25) NOT NULL,

View File

@ -1,4 +1,55 @@
drop table if exists t1, t2;
CREATE TABLE t1 (
a int NOT NULL,
b int NOT NULL);
CREATE TABLE t2 (
a int NOT NULL,
b int NOT NULL,
INDEX(b)
)
PARTITION BY HASH(a) PARTITIONS 2;
INSERT INTO t1 VALUES (399, 22);
INSERT INTO t2 VALUES (1, 22), (1, 42);
INSERT INTO t2 SELECT 1, 399 FROM t2, t1
WHERE t1.b = t2.b;
DROP TABLE t1, t2;
CREATE TABLE t1 (
a timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
b varchar(10),
PRIMARY KEY (a)
)
PARTITION BY RANGE (to_days(a)) (
PARTITION p1 VALUES LESS THAN (733407),
PARTITION pmax VALUES LESS THAN MAXVALUE
);
INSERT INTO t1 VALUES ('2007-07-30 17:35:48', 'p1');
INSERT INTO t1 VALUES ('2009-07-14 17:35:55', 'pmax');
INSERT INTO t1 VALUES ('2009-09-21 17:31:42', 'pmax');
SELECT * FROM t1;
a b
2007-07-30 17:35:48 p1
2009-07-14 17:35:55 pmax
2009-09-21 17:31:42 pmax
ALTER TABLE t1 REORGANIZE PARTITION pmax INTO (
PARTITION p3 VALUES LESS THAN (733969),
PARTITION pmax VALUES LESS THAN MAXVALUE);
SELECT * FROM t1;
a b
2007-07-30 17:35:48 p1
2009-07-14 17:35:55 pmax
2009-09-21 17:31:42 pmax
SHOW CREATE TABLE t1;
Table Create Table
t1 CREATE TABLE `t1` (
`a` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
`b` varchar(10) DEFAULT NULL,
PRIMARY KEY (`a`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1
/*!50100 PARTITION BY RANGE (to_days(a))
(PARTITION p1 VALUES LESS THAN (733407) ENGINE = MyISAM,
PARTITION p3 VALUES LESS THAN (733969) ENGINE = MyISAM,
PARTITION pmax VALUES LESS THAN MAXVALUE ENGINE = MyISAM) */
DROP TABLE t1;
CREATE TABLE t1 (a INT, FOREIGN KEY (a) REFERENCES t0 (a))
ENGINE=MyISAM
PARTITION BY HASH (a);

View File

@ -0,0 +1,93 @@
DROP TABLE IF EXISTS t1;
FLUSH TABLES;
SELECT * FROM t1;
ERROR HY000: The MySQL server is running with the --skip-partition option so it cannot execute this statement
TRUNCATE TABLE t1;
ERROR HY000: The MySQL server is running with the --skip-partition option so it cannot execute this statement
ANALYZE TABLE t1;
Table Op Msg_type Msg_text
test.t1 analyze Error The MySQL server is running with the --skip-partition option so it cannot execute this statement
test.t1 analyze error Corrupt
CHECK TABLE t1;
Table Op Msg_type Msg_text
test.t1 check Error The MySQL server is running with the --skip-partition option so it cannot execute this statement
test.t1 check error Corrupt
OPTIMIZE TABLE t1;
Table Op Msg_type Msg_text
test.t1 optimize Error The MySQL server is running with the --skip-partition option so it cannot execute this statement
test.t1 optimize error Corrupt
REPAIR TABLE t1;
Table Op Msg_type Msg_text
test.t1 repair Error The MySQL server is running with the --skip-partition option so it cannot execute this statement
test.t1 repair error Corrupt
ALTER TABLE t1 REPAIR PARTITION ALL;
Table Op Msg_type Msg_text
test.t1 repair Error The MySQL server is running with the --skip-partition option so it cannot execute this statement
test.t1 repair error Corrupt
ALTER TABLE t1 CHECK PARTITION ALL;
Table Op Msg_type Msg_text
test.t1 check Error The MySQL server is running with the --skip-partition option so it cannot execute this statement
test.t1 check error Corrupt
ALTER TABLE t1 OPTIMIZE PARTITION ALL;
Table Op Msg_type Msg_text
test.t1 optimize Error The MySQL server is running with the --skip-partition option so it cannot execute this statement
test.t1 optimize error Corrupt
ALTER TABLE t1 ANALYZE PARTITION ALL;
Table Op Msg_type Msg_text
test.t1 analyze Error The MySQL server is running with the --skip-partition option so it cannot execute this statement
test.t1 analyze error Corrupt
ALTER TABLE t1 REBUILD PARTITION ALL;
ERROR HY000: The MySQL server is running with the --skip-partition option so it cannot execute this statement
ALTER TABLE t1 ENGINE Memory;
ERROR HY000: The MySQL server is running with the --skip-partition option so it cannot execute this statement
ALTER TABLE t1 ADD (new INT);
ERROR HY000: The MySQL server is running with the --skip-partition option so it cannot execute this statement
DROP TABLE t1;
CREATE TABLE t1 (
firstname VARCHAR(25) NOT NULL,
lastname VARCHAR(25) NOT NULL,
username VARCHAR(16) NOT NULL,
email VARCHAR(35),
joined DATE NOT NULL
)
PARTITION BY KEY(joined)
PARTITIONS 6;
ERROR HY000: The MySQL server is running with the --skip-partition option so it cannot execute this statement
ALTER TABLE t1 PARTITION BY KEY(joined) PARTITIONS 2;
ERROR HY000: The MySQL server is running with the --skip-partition option so it cannot execute this statement
drop table t1;
ERROR 42S02: Unknown table 't1'
CREATE TABLE t1 (
firstname VARCHAR(25) NOT NULL,
lastname VARCHAR(25) NOT NULL,
username VARCHAR(16) NOT NULL,
email VARCHAR(35),
joined DATE NOT NULL
)
PARTITION BY RANGE( YEAR(joined) ) (
PARTITION p0 VALUES LESS THAN (1960),
PARTITION p1 VALUES LESS THAN (1970),
PARTITION p2 VALUES LESS THAN (1980),
PARTITION p3 VALUES LESS THAN (1990),
PARTITION p4 VALUES LESS THAN MAXVALUE
);
ERROR HY000: The MySQL server is running with the --skip-partition option so it cannot execute this statement
drop table t1;
ERROR 42S02: Unknown table 't1'
CREATE TABLE t1 (id INT, purchased DATE)
PARTITION BY RANGE( YEAR(purchased) )
SUBPARTITION BY HASH( TO_DAYS(purchased) )
SUBPARTITIONS 2 (
PARTITION p0 VALUES LESS THAN (1990),
PARTITION p1 VALUES LESS THAN (2000),
PARTITION p2 VALUES LESS THAN MAXVALUE
);
ERROR HY000: The MySQL server is running with the --skip-partition option so it cannot execute this statement
drop table t1;
ERROR 42S02: Unknown table 't1'
create table t1 (a varchar(10) charset latin1 collate latin1_bin);
insert into t1 values (''),(' '),('a'),('a '),('a ');
explain partitions select * from t1 where a='a ' OR a='a';
id select_type table partitions type possible_keys key key_len ref rows Extra
1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 5 Using where
drop table t1;

File diff suppressed because it is too large Load Diff

View File

@ -745,7 +745,7 @@ a
EXPLAIN PARTITIONS SELECT * FROM t1
WHERE a >= '2004-07-01' AND a <= '2004-09-30';
id select_type table partitions type possible_keys key key_len ref rows Extra
1 SIMPLE t1 p407,p408,p409 ALL NULL NULL NULL NULL 9 Using where
1 SIMPLE t1 p3xx,p407,p408,p409 ALL NULL NULL NULL NULL 18 Using where
SELECT * from t1
WHERE (a >= '2004-07-01' AND a <= '2004-09-30') OR
(a >= '2005-07-01' AND a <= '2005-09-30');
@ -772,7 +772,7 @@ EXPLAIN PARTITIONS SELECT * from t1
WHERE (a >= '2004-07-01' AND a <= '2004-09-30') OR
(a >= '2005-07-01' AND a <= '2005-09-30');
id select_type table partitions type possible_keys key key_len ref rows Extra
1 SIMPLE t1 p407,p408,p409,p507,p508,p509 ALL NULL NULL NULL NULL 18 Using where
1 SIMPLE t1 p3xx,p407,p408,p409,p507,p508,p509 ALL NULL NULL NULL NULL 27 Using where
DROP TABLE t1;
create table t1 (a int);
insert into t1 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9);

View File

@ -75,7 +75,7 @@ SELECT 1 FROM (SELECT 1 as a) b WHERE 1 IN (SELECT (SELECT a));
select (SELECT 1 FROM (SELECT 1) a PROCEDURE ANALYSE(1));
ERROR HY000: Incorrect usage of PROCEDURE and subquery
SELECT 1 FROM (SELECT 1) a PROCEDURE ANALYSE((SELECT 1));
ERROR HY000: Incorrect parameters to procedure 'ANALYSE'
ERROR HY000: Incorrect usage of PROCEDURE and subquery
SELECT (SELECT 1) as a FROM (SELECT 1) b WHERE (SELECT a) IS NULL;
ERROR 42S22: Unknown column 'a' in 'field list'
SELECT (SELECT 1) as a FROM (SELECT 1) b WHERE (SELECT a) IS NOT NULL;
@ -4383,6 +4383,34 @@ id select_type table type possible_keys key key_len ref rows filtered Extra
1 PRIMARY C ALL NULL NULL NULL NULL 20 100.00 Using where
DROP TABLE C;
# End of test for bug#45061.
#
# Bug #46749: Segfault in add_key_fields() with outer subquery level
# field references
#
CREATE TABLE t1 (
a int,
b int,
UNIQUE (a), KEY (b)
);
INSERT INTO t1 VALUES (1,1), (2,1);
CREATE TABLE st1 like t1;
INSERT INTO st1 VALUES (1,1), (2,1);
CREATE TABLE st2 like t1;
INSERT INTO st2 VALUES (1,1), (2,1);
EXPLAIN
SELECT MAX(b), (SELECT COUNT(*) FROM st1,st2 WHERE st2.b <= t1.b)
FROM t1
WHERE a = 230;
id select_type table type possible_keys key key_len ref rows Extra
1 PRIMARY NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables
2 DEPENDENT SUBQUERY st1 index NULL a 5 NULL 2 Using index
2 DEPENDENT SUBQUERY st2 index b b 5 NULL 2 Using where; Using index; Using join buffer
SELECT MAX(b), (SELECT COUNT(*) FROM st1,st2 WHERE st2.b <= t1.b)
FROM t1
WHERE a = 230;
MAX(b) (SELECT COUNT(*) FROM st1,st2 WHERE st2.b <= t1.b)
NULL 0
DROP TABLE t1, st1, st2;
End of 5.0 tests.
CREATE TABLE t1 (a INT, b INT);
INSERT INTO t1 VALUES (2,22),(1,11),(2,22);

View File

@ -0,0 +1,22 @@
drop table if exists t1, t2;
create table t1 (a int);
insert into t1 values (0),(1),(2),(3);
create table t2 (a int primary key, b int)
as select a, a as b from t1 where a in (1,2);
explain select t1.a from t1 left join t2 on t2.a=t1.a;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 ALL NULL NULL NULL NULL 4
set optimizer_switch='table_elimination=off';
explain select t1.a from t1 left join t2 on t2.a=t1.a;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 ALL NULL NULL NULL NULL 4
1 SIMPLE t2 eq_ref PRIMARY PRIMARY 4 test.t1.a 1 Using index
set optimizer_switch='table_elimination=on';
explain select t1.a from t1 left join t2 on t2.a=t1.a;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 ALL NULL NULL NULL NULL 4
set optimizer_switch='table_elimination=default';
explain select t1.a from t1 left join t2 on t2.a=t1.a;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 ALL NULL NULL NULL NULL 4
drop table t1, t2;

View File

@ -1495,9 +1495,9 @@ CREATE TABLE t1 (a int DEFAULT NULL, b int DEFAULT NULL);
INSERT INTO t1 VALUES (3,30), (1,10), (2,10);
SELECT a+CAST(1 AS decimal(65,30)) AS aa, SUM(b) FROM t1 GROUP BY aa;
aa SUM(b)
2.000000000000000000000000000000 10
3.000000000000000000000000000000 10
4.000000000000000000000000000000 30
2.00000000000000000000000000000 10
3.00000000000000000000000000000 10
4.00000000000000000000000000000 30
SELECT a+CAST(1 AS decimal(65,31)) AS aa, SUM(b) FROM t1 GROUP BY aa;
ERROR 42000: Too big scale 31 specified for column '1'. Maximum is 30.
DROP TABLE t1;
@ -1521,13 +1521,13 @@ f1
DROP TABLE t1;
CREATE TABLE t1 SELECT 123451234512345123451234512345123451234512345.678906789067890678906789067890678906789067890 AS f1;
Warnings:
Warning 1264 Out of range value for column 'f1' at row 1
Note 1265 Data truncated for column 'f1' at row 1
DESC t1;
Field Type Null Key Default Extra
f1 decimal(65,30) NO 0.000000000000000000000000000000
f1 decimal(65,20) NO 0.00000000000000000000
SELECT f1 FROM t1;
f1
99999999999999999999999999999999999.999999999999999999999999999999
123451234512345123451234512345123451234512345.67890678906789067891
DROP TABLE t1;
select (1.20396873 * 0.89550000 * 0.68000000 * 1.08721696 * 0.99500000 *
1.01500000 * 1.01500000 * 0.99500000);
@ -1595,7 +1595,7 @@ Warnings:
Note 1265 Data truncated for column 'my_col' at row 1
DESCRIBE t1;
Field Type Null Key Default Extra
my_col decimal(65,30) NO 0.000000000000000000000000000000
my_col decimal(32,30) NO 0.000000000000000000000000000000
SELECT my_col FROM t1;
my_col
1.123456789123456789123456789123
@ -1625,8 +1625,212 @@ Warnings:
Note 1265 Data truncated for column 'my_col' at row 1
DESCRIBE t1;
Field Type Null Key Default Extra
my_col decimal(65,30) YES NULL
my_col decimal(30,30) YES NULL
SELECT my_col FROM t1;
my_col
0.012345687012345687012345687012
DROP TABLE t1;
#
# Bug#45261: Crash, stored procedure + decimal
#
DROP TABLE IF EXISTS t1;
CREATE TABLE t1 SELECT
/* 81 */ 100000000000000000000000000000000000000000000000000000000000000000000000000000001
AS c1;
Warnings:
Warning 1264 Out of range value for column 'c1' at row 1
DESC t1;
Field Type Null Key Default Extra
c1 decimal(65,0) NO 0
SELECT * FROM t1;
c1
99999999999999999999999999999999999999999999999999999999999999999
DROP TABLE t1;
CREATE TABLE t1 SELECT
/* 81 */ 100000000000000000000000000000000000000000000000000000000000000000000000000000001.
AS c1;
Warnings:
Warning 1264 Out of range value for column 'c1' at row 1
DESC t1;
Field Type Null Key Default Extra
c1 decimal(65,0) NO 0
SELECT * FROM t1;
c1
99999999999999999999999999999999999999999999999999999999999999999
DROP TABLE t1;
CREATE TABLE t1 SELECT
/* 81 */ 100000000000000000000000000000000000000000000000000000000000000000000000000000001.1 /* 1 */
AS c1;
Warnings:
Warning 1264 Out of range value for column 'c1' at row 1
DESC t1;
Field Type Null Key Default Extra
c1 decimal(65,0) NO 0
SELECT * FROM t1;
c1
99999999999999999999999999999999999999999999999999999999999999999
DROP TABLE t1;
CREATE TABLE t1 SELECT
/* 82 */ 1000000000000000000000000000000000000000000000000000000000000000000000000000000001
AS c1;
Warnings:
Error 1292 Truncated incorrect DECIMAL value: ''
DESC t1;
Field Type Null Key Default Extra
c1 decimal(65,0) NO 0
SELECT * FROM t1;
c1
99999999999999999999999999999999999999999999999999999999999999999
DROP TABLE t1;
CREATE TABLE t1 SELECT
/* 40 */ 1000000000000000000000000000000000000001.1000000000000000000000000000000000000001 /* 40 */
AS c1;
DESC t1;
Field Type Null Key Default Extra
c1 decimal(65,25) NO 0.0000000000000000000000000
SELECT * FROM t1;
c1
1000000000000000000000000000000000000001.1000000000000000000000000
DROP TABLE t1;
CREATE TABLE t1 SELECT
/* 1 */ 1.10000000000000000000000000000000000000000000000000000000000000000000000000000001 /* 80 */
AS c1;
DESC t1;
Field Type Null Key Default Extra
c1 decimal(31,30) NO 0.000000000000000000000000000000
SELECT * FROM t1;
c1
1.100000000000000000000000000000
DROP TABLE t1;
CREATE TABLE t1 SELECT
/* 1 */ 1.100000000000000000000000000000000000000000000000000000000000000000000000000000001 /* 81 */
AS c1;
DESC t1;
Field Type Null Key Default Extra
c1 decimal(31,30) NO 0.000000000000000000000000000000
SELECT * FROM t1;
c1
1.100000000000000000000000000000
DROP TABLE t1;
CREATE TABLE t1 SELECT
.100000000000000000000000000000000000000000000000000000000000000000000000000000001 /* 81 */
AS c1;
Warnings:
Note 1265 Data truncated for column 'c1' at row 1
DESC t1;
Field Type Null Key Default Extra
c1 decimal(30,30) NO 0.000000000000000000000000000000
SELECT * FROM t1;
c1
0.100000000000000000000000000000
DROP TABLE t1;
CREATE TABLE t1 SELECT
/* 45 */ 123456789012345678901234567890123456789012345.123456789012345678901234567890123456789012345 /* 45 */
AS c1;
Warnings:
Note 1265 Data truncated for column 'c1' at row 1
DESC t1;
Field Type Null Key Default Extra
c1 decimal(65,20) NO 0.00000000000000000000
SELECT * FROM t1;
c1
123456789012345678901234567890123456789012345.12345678901234567890
DROP TABLE t1;
CREATE TABLE t1 SELECT
/* 65 */ 12345678901234567890123456789012345678901234567890123456789012345.1 /* 1 */
AS c1;
Warnings:
Note 1265 Data truncated for column 'c1' at row 1
DESC t1;
Field Type Null Key Default Extra
c1 decimal(65,0) NO 0
SELECT * FROM t1;
c1
12345678901234567890123456789012345678901234567890123456789012345
DROP TABLE t1;
CREATE TABLE t1 SELECT
/* 66 */ 123456789012345678901234567890123456789012345678901234567890123456.1 /* 1 */
AS c1;
Warnings:
Warning 1264 Out of range value for column 'c1' at row 1
DESC t1;
Field Type Null Key Default Extra
c1 decimal(65,0) NO 0
SELECT * FROM t1;
c1
99999999999999999999999999999999999999999999999999999999999999999
DROP TABLE t1;
CREATE TABLE t1 SELECT
.123456789012345678901234567890123456789012345678901234567890123456 /* 66 */
AS c1;
Warnings:
Note 1265 Data truncated for column 'c1' at row 1
DESC t1;
Field Type Null Key Default Extra
c1 decimal(30,30) NO 0.000000000000000000000000000000
SELECT * FROM t1;
c1
0.123456789012345678901234567890
DROP TABLE t1;
CREATE TABLE t1 AS SELECT 123.1234567890123456789012345678901 /* 31 */ AS c1;
Warnings:
Note 1265 Data truncated for column 'c1' at row 1
DESC t1;
Field Type Null Key Default Extra
c1 decimal(33,30) NO 0.000000000000000000000000000000
SELECT * FROM t1;
c1
123.123456789012345678901234567890
DROP TABLE t1;
CREATE TABLE t1 SELECT 1.1 + CAST(1 AS DECIMAL(65,30)) AS c1;
DESC t1;
Field Type Null Key Default Extra
c1 decimal(65,29) NO 0.00000000000000000000000000000
SELECT * FROM t1;
c1
2.10000000000000000000000000000
DROP TABLE t1;
#
# Test that the integer and decimal parts are properly calculated.
#
CREATE TABLE t1 (a DECIMAL(30,30));
INSERT INTO t1 VALUES (0.1),(0.2),(0.3);
CREATE TABLE t2 SELECT MIN(a + 0.0000000000000000000000000000001) AS c1 FROM t1;
Warnings:
Note 1265 Data truncated for column 'c1' at row 3
DESC t2;
Field Type Null Key Default Extra
c1 decimal(32,30) YES NULL
DROP TABLE t1,t2;
CREATE TABLE t1 (a DECIMAL(30,30));
INSERT INTO t1 VALUES (0.1),(0.2),(0.3);
CREATE TABLE t2 SELECT IFNULL(a + 0.0000000000000000000000000000001, NULL) AS c1 FROM t1;
Warnings:
Note 1265 Data truncated for column 'c1' at row 1
Note 1265 Data truncated for column 'c1' at row 2
Note 1265 Data truncated for column 'c1' at row 3
DESC t2;
Field Type Null Key Default Extra
c1 decimal(32,30) YES NULL
DROP TABLE t1,t2;
CREATE TABLE t1 (a DECIMAL(30,30));
INSERT INTO t1 VALUES (0.1),(0.2),(0.3);
CREATE TABLE t2 SELECT CASE a WHEN 0.1 THEN 0.0000000000000000000000000000000000000000000000000000000000000000001 END AS c1 FROM t1;
Warnings:
Note 1265 Data truncated for column 'c1' at row 1
DESC t2;
Field Type Null Key Default Extra
c1 decimal(31,30) YES NULL
DROP TABLE t1,t2;
#
# Test that variables get maximum precision.
#
SET @decimal= 1.1;
CREATE TABLE t1 SELECT @decimal AS c1;
DESC t1;
Field Type Null Key Default Extra
c1 decimal(65,30) YES NULL
SELECT * FROM t1;
c1
1.100000000000000000000000000000
DROP TABLE t1;

View File

@ -3718,117 +3718,6 @@ DROP TABLE t1;
# -- End of test case for Bug#40825
#
# Bug #45806 crash when replacing into a view with a join!
#
CREATE TABLE t1(a INT UNIQUE);
CREATE VIEW v1 AS SELECT t1.a FROM t1, t1 AS a;
INSERT INTO t1 VALUES (1), (2);
REPLACE INTO v1(a) SELECT 1 FROM t1,t1 AS c;
SELECT * FROM v1;
a
1
2
1
2
REPLACE INTO v1(a) SELECT 3 FROM t1,t1 AS c;
SELECT * FROM v1;
a
1
2
3
1
2
3
1
2
3
DELETE FROM t1 WHERE a=3;
INSERT INTO v1(a) SELECT 1 FROM t1,t1 AS c
ON DUPLICATE KEY UPDATE `v1`.`a`= 1;
SELECT * FROM v1;
a
1
2
1
2
CREATE VIEW v2 AS SELECT t1.a FROM t1, v1 AS a;
REPLACE INTO v2(a) SELECT 1 FROM t1,t1 AS c;
SELECT * FROM v2;
a
1
2
1
2
1
2
1
2
REPLACE INTO v2(a) SELECT 3 FROM t1,t1 AS c;
SELECT * FROM v2;
a
1
2
3
1
2
3
1
2
3
1
2
3
1
2
3
1
2
3
1
2
3
1
2
3
1
2
3
INSERT INTO v2(a) SELECT 1 FROM t1,t1 AS c
ON DUPLICATE KEY UPDATE `v2`.`a`= 1;
SELECT * FROM v2;
a
1
2
3
1
2
3
1
2
3
1
2
3
1
2
3
1
2
3
1
2
3
1
2
3
1
2
3
DROP VIEW v1;
DROP VIEW v2;
DROP TABLE t1;
# -- End of test case for Bug#45806
# -----------------------------------------------------------------
# -- End of 5.0 tests.
# -----------------------------------------------------------------

View File

@ -0,0 +1,3 @@
一二三
四五六
七八九

Binary file not shown.

View File

@ -379,7 +379,9 @@ master-bin.000001 # Query # # BEGIN
master-bin.000001 # Table_map # # table_id: # (test.t1)
master-bin.000001 # Write_rows # # table_id: # flags: STMT_END_F
master-bin.000001 # Query # # COMMIT
master-bin.000001 # Query # # BEGIN
master-bin.000001 # Query # # use `test`; TRUNCATE table t2
master-bin.000001 # Xid # # COMMIT /* XID */
master-bin.000001 # Query # # BEGIN
master-bin.000001 # Table_map # # table_id: # (test.t1)
master-bin.000001 # Write_rows # # table_id: # flags: STMT_END_F
@ -838,8 +840,10 @@ UPDATE t4,t3 SET t4.a=t3.a + bug27417(1) /* top level non-ta table */;
ERROR 23000: Duplicate entry '2' for key 'PRIMARY'
show binlog events from <binlog_start>;
Log_name Pos Event_type Server_id End_log_pos Info
master-bin.000001 # Query # # BEGIN
master-bin.000001 # Intvar # # INSERT_ID=6
master-bin.000001 # Query # # use `test`; UPDATE t4,t3 SET t4.a=t3.a + bug27417(1) /* top level non-ta table */
master-bin.000001 # Query # # ROLLBACK
select count(*) from t1 /* must be 4 */;
count(*)
4

View File

@ -17,5 +17,5 @@ master-bin.000001 # Query # # create database `drop-temp+table-test`
master-bin.000001 # Query # # use `drop-temp+table-test`; create temporary table shortn1 (a int)
master-bin.000001 # Query # # use `drop-temp+table-test`; create temporary table `table:name` (a int)
master-bin.000001 # Query # # use `drop-temp+table-test`; create temporary table shortn2 (a int)
master-bin.000001 # Query # # use `drop-temp+table-test`; DROP /*!40005 TEMPORARY */ TABLE IF EXISTS `drop-temp+table-test`.`shortn2`,`drop-temp+table-test`.`table:name`,`drop-temp+table-test`.`shortn1`
master-bin.000001 # Query # # use `drop-temp+table-test`; DROP /*!40005 TEMPORARY */ TABLE IF EXISTS `shortn2`,`table:name`,`shortn1`
drop database `drop-temp+table-test`;

View File

@ -258,7 +258,7 @@ master-bin.000001 # Query # # use `test`; create table t0 (n int)
master-bin.000001 # Query # # use `test`; insert t0 select * from t1
master-bin.000001 # Query # # use `test`; insert into t0 select GET_LOCK("lock1",null)
master-bin.000001 # Query # # use `test`; create table t2 (n int) engine=innodb
master-bin.000001 # Query # # use `test`; DROP /*!40005 TEMPORARY */ TABLE IF EXISTS `test`.`t1`,`test`.`ti`
master-bin.000001 # Query # # use `test`; DROP /*!40005 TEMPORARY */ TABLE IF EXISTS `t1`,`ti`
do release_lock("lock1");
drop table t0,t2;
set autocommit=0;
@ -346,7 +346,9 @@ master-bin.000001 # Query # # use `test`; INSERT INTO t1 values (3,3)
master-bin.000001 # Query # # use `test`; DROP TABLE IF EXISTS t2
master-bin.000001 # Query # # use `test`; CREATE TABLE t2 (a int, b int, primary key (a)) engine=innodb
master-bin.000001 # Query # # use `test`; INSERT INTO t1 VALUES (4,4)
master-bin.000001 # Query # # BEGIN
master-bin.000001 # Query # # use `test`; TRUNCATE table t2
master-bin.000001 # Xid # # COMMIT /* XID */
master-bin.000001 # Query # # use `test`; INSERT INTO t1 VALUES (5,5)
master-bin.000001 # Query # # use `test`; DROP TABLE t2
master-bin.000001 # Query # # use `test`; INSERT INTO t1 values (6,6)
@ -545,8 +547,10 @@ UPDATE t4,t3 SET t4.a=t3.a + bug27417(1) /* top level non-ta table */;
ERROR 23000: Duplicate entry '2' for key 'PRIMARY'
show binlog events from <binlog_start>;
Log_name Pos Event_type Server_id End_log_pos Info
master-bin.000001 # Query # # BEGIN
master-bin.000001 # Intvar # # INSERT_ID=6
master-bin.000001 # Query # # use `test`; UPDATE t4,t3 SET t4.a=t3.a + bug27417(1) /* top level non-ta table */
master-bin.000001 # Query # # ROLLBACK
/* the output must denote there is the query */;
select count(*) from t1 /* must be 4 */;
count(*)
@ -782,8 +786,10 @@ UPDATE t4,t3 SET t4.a=t3.a + bug27417(1) /* top level non-ta table */;
ERROR 23000: Duplicate entry '2' for key 'PRIMARY'
show binlog events from <binlog_start>;
Log_name Pos Event_type Server_id End_log_pos Info
master-bin.000001 # Query # # BEGIN
master-bin.000001 # Intvar # # INSERT_ID=6
master-bin.000001 # Query # # use `test`; UPDATE t4,t3 SET t4.a=t3.a + bug27417(1) /* top level non-ta table */
master-bin.000001 # Query # # ROLLBACK
select count(*) from t1 /* must be 4 */;
count(*)
4

View File

@ -9,4 +9,5 @@
# Do not use any TAB characters for whitespace.
#
##############################################################################
federated_transactions : Bug#29523 Transactions do not work
federated_server : needs fixup

View File

@ -47,9 +47,10 @@ CREATE TABLE federated.t1 (
)
ENGINE="FEDERATED" DEFAULT CHARSET=latin1
CONNECTION='mysql://root@127.0.0.1:SLAVE_PORT/federated/t3';
SELECT * FROM federated.t1;
ERROR HY000: The foreign data source you are trying to reference does not exist. Data source error: error: 1146 'Table 'federated.t3' doesn't exist'
DROP TABLE federated.t1;
ERROR HY000: Can't create federated table. Foreign data src error: database: 'federated' username: 'root' hostname: '127.0.0.1'
DROP TABLE IF EXISTS federated.t1;
Warnings:
Note 1051 Unknown table 't1'
CREATE TABLE federated.t1 (
`id` int(20) NOT NULL,
`group` int NOT NULL default 0,
@ -59,9 +60,10 @@ CREATE TABLE federated.t1 (
)
ENGINE="FEDERATED" DEFAULT CHARSET=latin1
CONNECTION='mysql://user:pass@127.0.0.1:SLAVE_PORT/federated/t1';
SELECT * FROM federated.t1;
ERROR HY000: Unable to connect to foreign data source: Access denied for user 'user'@'localhost' (using password: YES)
DROP TABLE federated.t1;
ERROR HY000: Can't create federated table. Foreign data src error: database: 'federated' username: 'user' hostname: '127.0.0.1'
DROP TABLE IF EXISTS federated.t1;
Warnings:
Note 1051 Unknown table 't1'
CREATE TABLE federated.t1 (
`id` int(20) NOT NULL,
`group` int NOT NULL default 0,
@ -1944,15 +1946,7 @@ Bug#18287 create federated table always times out, error 1159 ' '
Test that self-references work
create table federated.t1 (a int primary key);
create table federated.t2 (a int primary key)
ENGINE=FEDERATED
connection='mysql://root@127.0.0.1:SLAVE_PORT/federated/t1';
insert into federated.t1 (a) values (1);
select * from federated.t2;
a
1
drop table federated.t1, federated.t2;
fix LOCK_open before reenabling test for Bug#18287
CREATE TABLE federated.t1 (a INT PRIMARY KEY) DEFAULT CHARSET=utf8;
CREATE TABLE federated.t1 (a INT PRIMARY KEY)
ENGINE=FEDERATED
@ -1960,13 +1954,11 @@ CONNECTION='mysql://root@127.0.0.1:SLAVE_PORT/federated/t1'
DEFAULT CHARSET=utf8;
SELECT transactions FROM information_schema.engines WHERE engine="FEDERATED";
transactions
NO
YES
INSERT INTO federated.t1 VALUES (1);
SET autocommit=0;
INSERT INTO federated.t1 VALUES (2);
ROLLBACK;
Warnings:
Warning 1196 Some non-transactional changed tables couldn't be rolled back
SET autocommit=1;
SELECT * FROM federated.t1;
a
@ -2157,6 +2149,6 @@ End of 5.1 tests
SET @@GLOBAL.CONCURRENT_INSERT= @OLD_MASTER_CONCURRENT_INSERT;
SET @@GLOBAL.CONCURRENT_INSERT= @OLD_SLAVE_CONCURRENT_INSERT;
DROP TABLE IF EXISTS federated.t1;
DROP DATABASE federated;
DROP DATABASE IF EXISTS federated;
DROP TABLE IF EXISTS federated.t1;
DROP DATABASE federated;
DROP DATABASE IF EXISTS federated;

View File

@ -57,6 +57,7 @@ CREATE TABLE federated.t1 (
# test non-existant table
--replace_result $SLAVE_MYPORT SLAVE_PORT
--error ER_CANT_CREATE_FEDERATED_TABLE
eval CREATE TABLE federated.t1 (
`id` int(20) NOT NULL,
`group` int NOT NULL default 0,
@ -66,12 +67,11 @@ eval CREATE TABLE federated.t1 (
)
ENGINE="FEDERATED" DEFAULT CHARSET=latin1
CONNECTION='mysql://root@127.0.0.1:$SLAVE_MYPORT/federated/t3';
--error ER_FOREIGN_DATA_SOURCE_DOESNT_EXIST
SELECT * FROM federated.t1;
DROP TABLE federated.t1;
DROP TABLE IF EXISTS federated.t1;
# test bad user/password
--replace_result $SLAVE_MYPORT SLAVE_PORT
--error ER_CANT_CREATE_FEDERATED_TABLE
eval CREATE TABLE federated.t1 (
`id` int(20) NOT NULL,
`group` int NOT NULL default 0,
@ -81,9 +81,7 @@ eval CREATE TABLE federated.t1 (
)
ENGINE="FEDERATED" DEFAULT CHARSET=latin1
CONNECTION='mysql://user:pass@127.0.0.1:$SLAVE_MYPORT/federated/t1';
--error ER_CONNECT_TO_FOREIGN_DATA_SOURCE
SELECT * FROM federated.t1;
DROP TABLE federated.t1;
DROP TABLE IF EXISTS federated.t1;
# # correct connection, same named tables
--replace_result $SLAVE_MYPORT SLAVE_PORT
@ -1806,6 +1804,8 @@ drop table federated.t1;
--echo
--echo Test that self-references work
--echo
--echo fix LOCK_open before reenabling test for Bug#18287
--disable_parsing
connection slave;
create table federated.t1 (a int primary key);
--replace_result $SLAVE_MYPORT SLAVE_PORT
@ -1815,7 +1815,7 @@ eval create table federated.t2 (a int primary key)
insert into federated.t1 (a) values (1);
select * from federated.t2;
drop table federated.t1, federated.t2;
--enable_parsing
#
# BUG#29875 Disable support for transactions
#

View File

@ -34,6 +34,6 @@ id name
DROP TABLE federated.t1;
DROP TABLE federated.archive_table;
DROP TABLE IF EXISTS federated.t1;
DROP DATABASE federated;
DROP DATABASE IF EXISTS federated;
DROP TABLE IF EXISTS federated.t1;
DROP DATABASE federated;
DROP DATABASE IF EXISTS federated;

View File

@ -25,6 +25,6 @@ foo bar
DROP TABLE federated.t1;
DROP TABLE federated.bug_13118_table;
DROP TABLE IF EXISTS federated.t1;
DROP DATABASE federated;
DROP DATABASE IF EXISTS federated;
DROP TABLE IF EXISTS federated.t1;
DROP DATABASE federated;
DROP DATABASE IF EXISTS federated;

View File

@ -48,6 +48,6 @@ SET @@GLOBAL.CONCURRENT_INSERT= @OLD_MASTER_CONCURRENT_INSERT;
DROP TABLE federated.t1;
SET @@GLOBAL.CONCURRENT_INSERT= @OLD_SLAVE_CONCURRENT_INSERT;
DROP TABLE IF EXISTS federated.t1;
DROP DATABASE federated;
DROP DATABASE IF EXISTS federated;
DROP TABLE IF EXISTS federated.t1;
DROP DATABASE federated;
DROP DATABASE IF EXISTS federated;

View File

@ -1,9 +1,9 @@
connection master;
--disable_warnings
DROP TABLE IF EXISTS federated.t1;
DROP DATABASE federated;
DROP DATABASE IF EXISTS federated;
connection slave;
DROP TABLE IF EXISTS federated.t1;
DROP DATABASE federated;
DROP DATABASE IF EXISTS federated;
--enable_warnings

View File

@ -20,6 +20,6 @@ a b
drop table federated.t1;
drop table federated.t1;
DROP TABLE IF EXISTS federated.t1;
DROP DATABASE federated;
DROP DATABASE IF EXISTS federated;
DROP TABLE IF EXISTS federated.t1;
DROP DATABASE federated;
DROP DATABASE IF EXISTS federated;

View File

@ -178,8 +178,8 @@ INSERT INTO db_bogus.t1 VALUES ('2','this is bogus');
create server 's1' foreign data wrapper 'mysql' options
(HOST '127.0.0.1',
DATABASE 'db_legitimate',
USER 'root',
PASSWORD '',
USER 'test_fed',
PASSWORD 'foo',
PORT SLAVE_PORT,
SOCKET '',
OWNER 'root');

View File

@ -3,6 +3,7 @@
# Slow test, don't run during staging part
-- source include/not_staging.inc
-- source include/big_test.inc
-- source federated.inc
connection slave;
@ -182,13 +183,17 @@ CREATE TABLE db_bogus.t1 (
;
INSERT INTO db_bogus.t1 VALUES ('2','this is bogus');
connection slave;
create user test_fed@localhost identified by 'foo';
grant all on db_legitimate.* to test_fed@localhost;
connection master;
--replace_result $SLAVE_MYPORT SLAVE_PORT
eval create server 's1' foreign data wrapper 'mysql' options
(HOST '127.0.0.1',
DATABASE 'db_legitimate',
USER 'root',
PASSWORD '',
USER 'test_fed',
PASSWORD 'foo',
PORT $SLAVE_MYPORT,
SOCKET '',
OWNER 'root');

View File

@ -1,13 +1,4 @@
stop slave;
drop table if exists t1,t2,t3,t4,t5,t6,t7,t8,t9;
reset master;
reset slave;
drop table if exists t1,t2,t3,t4,t5,t6,t7,t8,t9;
start slave;
stop slave;
DROP DATABASE IF EXISTS federated;
CREATE DATABASE federated;
DROP DATABASE IF EXISTS federated;
CREATE DATABASE federated;
DROP TABLE IF EXISTS federated.t1;
Warnings:

View File

@ -2,7 +2,7 @@ SELECT * FROM information_schema.engines
WHERE ENGINE = 'FEDERATED';
ENGINE FEDERATED
SUPPORT YES
COMMENT Federated MySQL storage engine
TRANSACTIONS NO
COMMENT FederatedX pluggable storage engine
TRANSACTIONS YES
XA NO
SAVEPOINTS NO
SAVEPOINTS YES

View File

@ -710,7 +710,7 @@ a
EXPLAIN PARTITIONS SELECT * FROM t1
WHERE a >= '2004-07-01' AND a <= '2004-09-30';
id select_type table partitions type possible_keys key key_len ref rows Extra
1 SIMPLE t1 p407,p408,p409 ALL NULL NULL NULL NULL 9 Using where
1 SIMPLE t1 p3xx,p407,p408,p409 ALL NULL NULL NULL NULL 18 Using where
SELECT * from t1
WHERE (a >= '2004-07-01' AND a <= '2004-09-30') OR
(a >= '2005-07-01' AND a <= '2005-09-30');
@ -737,5 +737,5 @@ EXPLAIN PARTITIONS SELECT * from t1
WHERE (a >= '2004-07-01' AND a <= '2004-09-30') OR
(a >= '2005-07-01' AND a <= '2005-09-30');
id select_type table partitions type possible_keys key key_len ref rows Extra
1 SIMPLE t1 p407,p408,p409,p507,p508,p509 ALL NULL NULL NULL NULL 18 Using where
1 SIMPLE t1 p3xx,p407,p408,p409,p507,p508,p509 ALL NULL NULL NULL NULL 27 Using where
DROP TABLE t1;

View File

@ -75,7 +75,7 @@ SELECT 1 FROM (SELECT 1 as a) b WHERE 1 IN (SELECT (SELECT a));
select (SELECT 1 FROM (SELECT 1) a PROCEDURE ANALYSE(1));
ERROR HY000: Incorrect usage of PROCEDURE and subquery
SELECT 1 FROM (SELECT 1) a PROCEDURE ANALYSE((SELECT 1));
ERROR HY000: Incorrect parameters to procedure 'ANALYSE'
ERROR HY000: Incorrect usage of PROCEDURE and subquery
SELECT (SELECT 1) as a FROM (SELECT 1) b WHERE (SELECT a) IS NULL;
ERROR 42S22: Unknown column 'a' in 'field list'
SELECT (SELECT 1) as a FROM (SELECT 1) b WHERE (SELECT a) IS NOT NULL;

View File

@ -30,7 +30,7 @@ SELECT 1 IN (SELECT 1);
SELECT 1 FROM (SELECT 1 as a) b WHERE 1 IN (SELECT (SELECT a));
-- error 1221
select (SELECT 1 FROM (SELECT 1) a PROCEDURE ANALYSE(1));
-- error 1108
-- error ER_WRONG_USAGE
SELECT 1 FROM (SELECT 1) a PROCEDURE ANALYSE((SELECT 1));
-- error ER_BAD_FIELD_ERROR
SELECT (SELECT 1) as a FROM (SELECT 1) b WHERE (SELECT a) IS NULL;

View File

@ -101,6 +101,8 @@ master-bin.000001 # Query # # use `test`; UPDATE t SET f = 'dark blue 1' WHERE f
master-bin.000001 # Query # # use `test`; INSERT INTO t VALUES (6 + (1 * 10),"brown")
master-bin.000001 # Query # # use `test`; INSERT INTO n VALUES (now(),"brown")
master-bin.000001 # Xid # # COMMIT /* XID */
source include/diff_master_slave.inc;
source include/diff_master_slave.inc;
########################################################################
# Cleanup
########################################################################

View File

@ -0,0 +1,33 @@
stop slave;
drop table if exists t1,t2,t3,t4,t5,t6,t7,t8,t9;
reset master;
reset slave;
drop table if exists t1,t2,t3,t4,t5,t6,t7,t8,t9;
start slave;
DROP DATABASE IF EXISTS mysqltest;
CREATE DATABASE IF NOT EXISTS mysqltest;
USE mysqltest;
CREATE TABLE IF NOT EXISTS t(c1 int);
CREATE TABLE IF NOT EXISTS t1 LIKE t;
CREATE TABLE IF NOT EXISTS t2 SELECT * FROM t;
CREATE EVENT IF NOT EXISTS e
ON SCHEDULE AT CURRENT_TIMESTAMP + INTERVAL 1 HOUR
DO SELECT now();
DROP DATABASE mysqltest;
CREATE DATABASE IF NOT EXISTS mysqltest;
USE mysqltest;
CREATE TABLE IF NOT EXISTS t(c1 int);
CREATE TABLE IF NOT EXISTS t1 LIKE t;
CREATE TABLE IF NOT EXISTS t2 SELECT * FROM t;
CREATE EVENT IF NOT EXISTS e
ON SCHEDULE AT CURRENT_TIMESTAMP + INTERVAL 1 HOUR
DO SELECT now();
SHOW TABLES in mysqltest;
Tables_in_mysqltest
t
t1
t2
SHOW EVENTS in mysqltest;
Db Name Definer Time zone Type Execute at Interval value Interval field Starts Ends Status Originator character_set_client collation_connection Database Collation
mysqltest e root@localhost SYSTEM ONE TIME # NULL NULL NULL NULL SLAVESIDE_DISABLED 1 latin1 latin1_swedish_ci latin1_swedish_ci
DROP DATABASE IF EXISTS mysqltest;

View File

@ -0,0 +1,22 @@
stop slave;
drop table if exists t1,t2,t3,t4,t5,t6,t7,t8,t9;
reset master;
reset slave;
drop table if exists t1,t2,t3,t4,t5,t6,t7,t8,t9;
start slave;
DROP DATABASE IF EXISTS mysqltest;
CREATE TEMPORARY TABLE IF NOT EXISTS tmp(c1 int);
CREATE TEMPORARY TABLE IF NOT EXISTS tmp(c1 int);
CREATE TEMPORARY TABLE IF NOT EXISTS tmp1 LIKE tmp;
CREATE TEMPORARY TABLE IF NOT EXISTS tmp1 LIKE tmp;
CREATE TEMPORARY TABLE IF NOT EXISTS tmp2 SELECT * FROM tmp;
CREATE TEMPORARY TABLE IF NOT EXISTS tmp2 SELECT * FROM tmp;
show binlog events from <binlog_start>;
Log_name Pos Event_type Server_id End_log_pos Info
master-bin.000001 # Query # # DROP DATABASE IF EXISTS mysqltest
master-bin.000001 # Query # # use `test`; CREATE TEMPORARY TABLE IF NOT EXISTS tmp(c1 int)
master-bin.000001 # Query # # use `test`; CREATE TEMPORARY TABLE IF NOT EXISTS tmp(c1 int)
master-bin.000001 # Query # # use `test`; CREATE TEMPORARY TABLE IF NOT EXISTS tmp1 LIKE tmp
master-bin.000001 # Query # # use `test`; CREATE TEMPORARY TABLE IF NOT EXISTS tmp1 LIKE tmp
master-bin.000001 # Query # # use `test`; CREATE TEMPORARY TABLE IF NOT EXISTS tmp2 SELECT * FROM tmp
master-bin.000001 # Query # # use `test`; CREATE TEMPORARY TABLE IF NOT EXISTS tmp2 SELECT * FROM tmp

View File

@ -43,7 +43,7 @@ master-bin.000001 # Query # # use `test`; DROP TABLE IF EXISTS db_bug_13684.t
master-bin.000001 # Query # # DROP DATABASE IF EXISTS db_bug_13684
master-bin.000001 # Query # # CREATE DATABASE db_bug_13684
master-bin.000001 # Query # # use `test`; CREATE TABLE db_bug_13684.t (a int)
master-bin.000001 # Query # # use `test`; CREATE EVENT db_bug_13684.e
master-bin.000001 # Query # # use `test`; CREATE DEFINER=`root`@`localhost` EVENT db_bug_13684.e
ON SCHEDULE AT CURRENT_TIMESTAMP + INTERVAL 1 HOUR
DO
UPDATE db_bug_13684.t SET a = a + 1
@ -75,7 +75,7 @@ master-bin.000001 # Query # # use `test`; DROP TABLE IF EXISTS db_bug_13684.t
master-bin.000001 # Query # # DROP DATABASE IF EXISTS db_bug_13684
master-bin.000001 # Query # # CREATE DATABASE db_bug_13684
master-bin.000001 # Query # # use `test`; CREATE TABLE db_bug_13684.t (a int)
master-bin.000001 # Query # # use `test`; CREATE EVENT db_bug_13684.e
master-bin.000001 # Query # # use `test`; CREATE DEFINER=`root`@`localhost` EVENT db_bug_13684.e
ON SCHEDULE AT CURRENT_TIMESTAMP + INTERVAL 1 HOUR
DO
UPDATE db_bug_13684.t SET a = a + 1

View File

@ -5,6 +5,7 @@ reset slave;
drop table if exists t1,t2,t3,t4,t5,t6,t7,t8,t9;
start slave;
create database if not exists mysqltest;
use mysqltest;
create temporary table mysqltest.t1 (n int)ENGINE=MyISAM;
create temporary table mysqltest.t2 (n int)ENGINE=MyISAM;
show status like 'Slave_open_temp_tables';

View File

@ -191,5 +191,63 @@ select * from t28953;
END;|
ALTER EVENT event1 RENAME TO event2;
DROP EVENT event2;
CREATE TABLE test.t1(details CHAR(30));
CREATE EVENT /*!50000 event44331_1 */
ON SCHEDULE AT CURRENT_TIMESTAMP
ON COMPLETION PRESERVE DISABLE
DO INSERT INTO test.t1 VALUES('event event44331_1 fired - no definer');
CREATE DEFINER=CURRENT_USER /*!50000 EVENT event44331_2 */
ON SCHEDULE AT CURRENT_TIMESTAMP
ON COMPLETION PRESERVE DISABLE
DO INSERT INTO test.t1 VALUES('event event44331_2 fired - DEFINER=CURRENT_USER');
CREATE DEFINER=CURRENT_USER() EVENT event44331_3
ON SCHEDULE AT CURRENT_TIMESTAMP
ON COMPLETION PRESERVE DISABLE
DO INSERT INTO test.t1 VALUES('event event44331_3 fired - DEFINER=CURRENT_USER() function');
CREATE /*!50000 DEFINER='user44331' */ EVENT event44331_4
ON SCHEDULE AT CURRENT_TIMESTAMP
ON COMPLETION PRESERVE DISABLE
DO INSERT INTO test.t1 VALUES('event event44331_4 fired - DEFINER=user1');
Warnings:
Note 1449 The user specified as a definer ('user44331'@'%') does not exist
#on master
select EVENT_SCHEMA, EVENT_NAME, DEFINER from information_schema.events
where EVENT_NAME='event44331_1';
EVENT_SCHEMA EVENT_NAME DEFINER
test event44331_1 root@localhost
select EVENT_SCHEMA, EVENT_NAME, DEFINER from information_schema.events
where EVENT_NAME='event44331_2';
EVENT_SCHEMA EVENT_NAME DEFINER
test event44331_2 root@localhost
select EVENT_SCHEMA, EVENT_NAME, DEFINER from information_schema.events
where EVENT_NAME='event44331_3';
EVENT_SCHEMA EVENT_NAME DEFINER
test event44331_3 root@localhost
select EVENT_SCHEMA, EVENT_NAME, DEFINER from information_schema.events
where EVENT_NAME='event44331_4';
EVENT_SCHEMA EVENT_NAME DEFINER
test event44331_4 user44331@%
#on slave
select EVENT_SCHEMA, EVENT_NAME, DEFINER from information_schema.events
where EVENT_NAME='event44331_1';
EVENT_SCHEMA EVENT_NAME DEFINER
test event44331_1 root@localhost
select EVENT_SCHEMA, EVENT_NAME, DEFINER from information_schema.events
where EVENT_NAME='event44331_2';
EVENT_SCHEMA EVENT_NAME DEFINER
test event44331_2 root@localhost
select EVENT_SCHEMA, EVENT_NAME, DEFINER from information_schema.events
where EVENT_NAME='event44331_3';
EVENT_SCHEMA EVENT_NAME DEFINER
test event44331_3 root@localhost
select EVENT_SCHEMA, EVENT_NAME, DEFINER from information_schema.events
where EVENT_NAME='event44331_4';
EVENT_SCHEMA EVENT_NAME DEFINER
test event44331_4 user44331@%
SET @@global.event_scheduler= @old_event_scheduler;
DROP TABLE t28953;
DROP TABLE t1;
DROP EVENT event44331_1;
DROP EVENT event44331_2;
DROP EVENT event44331_3;
DROP EVENT event44331_4;

View File

@ -690,7 +690,7 @@ test_rpl e1 root@localhost SYSTEM RECURRING NULL 1 # # NULL ENABLED 1 latin1 lat
USE test_rpl;
SHOW EVENTS;
Db Name Definer Time zone Type Execute at Interval value Interval field Starts Ends Status Originator character_set_client collation_connection Database Collation
test_rpl e1 @ SYSTEM RECURRING NULL 1 # # NULL SLAVESIDE_DISABLED 1 latin1 latin1_swedish_ci latin1_swedish_ci
test_rpl e1 root@localhost SYSTEM RECURRING NULL 1 # # NULL SLAVESIDE_DISABLED 1 latin1 latin1_swedish_ci latin1_swedish_ci
==========MASTER==========
SELECT COUNT(*) FROM t1;
COUNT(*)
@ -963,7 +963,9 @@ master-bin.000001 # Xid 1 # #
master-bin.000001 # Query 1 # BEGIN
master-bin.000001 # Query 1 # use `test_rpl`; INSERT INTO t1 VALUES(1, 't1, text 1')
master-bin.000001 # Xid 1 # #
master-bin.000001 # Query 1 # BEGIN
master-bin.000001 # Query 1 # use `test_rpl`; TRUNCATE t1
master-bin.000001 # Xid 1 # #
master-bin.000001 # Query 1 # BEGIN
master-bin.000001 # Query 1 # use `test_rpl`; DELETE FROM t1
master-bin.000001 # Xid 1 # #
@ -1076,7 +1078,7 @@ master-bin.000001 # Query 1 # use `test_rpl`; GRANT EVENT ON *.* TO 'root'@'loca
master-bin.000001 # Query 1 # BEGIN
master-bin.000001 # Query 1 # use `test_rpl`; INSERT INTO t1 VALUES(1, 'test1')
master-bin.000001 # Xid 1 # #
master-bin.000001 # Query 1 # use `test_rpl`; CREATE EVENT e1 ON SCHEDULE EVERY '1' SECOND COMMENT 'e_second_comment' DO DELETE FROM t1
master-bin.000001 # Query 1 # use `test_rpl`; CREATE DEFINER=`root`@`localhost` EVENT e1 ON SCHEDULE EVERY '1' SECOND COMMENT 'e_second_comment' DO DELETE FROM t1
master-bin.000001 # Query 1 # use `test_rpl`; ALTER EVENT e1 RENAME TO e2
master-bin.000001 # Query 1 # use `test_rpl`; DROP EVENT e2
master-bin.000001 # Query 1 # BEGIN

View File

@ -35,3 +35,44 @@ C3BF
D0AA
D0AA
drop table t1;
-------------test bug#45516------------------
DROP DATABASE IF EXISTS mysqltest;
CREATE DATABASE mysqltest CHARSET UTF8;
USE mysqltest;
CREATE TABLE t (cl varchar(100)) CHARSET UTF8;
LOAD DATA LOCAL INFILE './std_data/loaddata_utf8.dat' INTO TABLE t
FIELDS TERMINATED BY ',' LINES TERMINATED BY '\n';
----------content on master----------
SELECT hex(cl) FROM t;
hex(cl)
E4B880E4BA8CE4B889
E59B9BE4BA94E585AD
E4B883E585ABE4B99D
----------content on slave----------
USE mysqltest;
SELECT hex(cl) FROM t;
hex(cl)
E4B880E4BA8CE4B889
E59B9BE4BA94E585AD
E4B883E585ABE4B99D
DROP DATABASE mysqltest;
DROP DATABASE IF EXISTS mysqltest;
CREATE DATABASE mysqltest CHARSET UTF8;
USE mysqltest;
CREATE TABLE t (cl varchar(100)) CHARSET UTF8;
LOAD DATA INFILE '../../std_data/loaddata_utf8.dat' INTO TABLE t
FIELDS TERMINATED BY ',' LINES TERMINATED BY '\n';
----------content on master----------
SELECT hex(cl) FROM t;
hex(cl)
E4B880E4BA8CE4B889
E59B9BE4BA94E585AD
E4B883E585ABE4B99D
----------content on slave----------
USE mysqltest;
SELECT hex(cl) FROM t;
hex(cl)
E4B880E4BA8CE4B889
E59B9BE4BA94E585AD
E4B883E585ABE4B99D
DROP DATABASE mysqltest;

View File

@ -90,5 +90,132 @@ a b
2 row 2
3 row 3
0
set sql_log_bin= 0;
drop database rewrite;
set sql_log_bin= 1;
set sql_log_bin= 0;
drop table t1;
set sql_log_bin= 1;
****
**** Bug #46861 Auto-closing of temporary tables broken by replicate-rewrite-db
****
****
**** Preparing the environment
****
SET sql_log_bin= 0;
CREATE DATABASE database_master_temp_01;
CREATE DATABASE database_master_temp_02;
CREATE DATABASE database_master_temp_03;
SET sql_log_bin= 1;
SET sql_log_bin= 0;
CREATE DATABASE database_slave_temp_01;
CREATE DATABASE database_slave_temp_02;
CREATE DATABASE database_slave_temp_03;
SET sql_log_bin= 1;
****
**** Creating temporary tables on different databases with different connections
****
**** con_temp_01 --> creates
**** t_01_01_temp on database_master_temp_01
****
**** con_temp_02 --> creates
**** t_01_01_temp on database_master_temp_01
**** t_02_01_temp, t_02_02_temp on database_master_temp_02
****
**** con_temp_02 --> creates
**** t_01_01_temp on database_master_temp_01
**** t_02_01_temp, t_02_02_temp on database_master_temp_02
**** t_03_01_temp, t_03_02_temp, t_03_03_temp on database_master_temp_03
****
con_temp_01
USE database_master_temp_01;
CREATE TEMPORARY TABLE t_01_01_temp(a int);
INSERT INTO t_01_01_temp VALUES(1);
con_temp_02
USE database_master_temp_01;
CREATE TEMPORARY TABLE t_01_01_temp(a int);
INSERT INTO t_01_01_temp VALUES(1);
USE database_master_temp_02;
CREATE TEMPORARY TABLE t_02_01_temp(a int);
INSERT INTO t_02_01_temp VALUES(1);
CREATE TEMPORARY TABLE t_02_02_temp(a int);
INSERT INTO t_02_02_temp VALUES(1);
con_temp_03
USE database_master_temp_01;
CREATE TEMPORARY TABLE t_01_01_temp(a int);
INSERT INTO t_01_01_temp VALUES(1);
USE database_master_temp_02;
CREATE TEMPORARY TABLE t_02_01_temp(a int);
INSERT INTO t_02_01_temp VALUES(1);
CREATE TEMPORARY TABLE t_02_02_temp(a int);
INSERT INTO t_02_02_temp VALUES(1);
USE database_master_temp_03;
CREATE TEMPORARY TABLE t_03_01_temp(a int);
INSERT INTO t_03_01_temp VALUES(1);
CREATE TEMPORARY TABLE t_03_02_temp(a int);
INSERT INTO t_03_02_temp VALUES(1);
CREATE TEMPORARY TABLE t_03_03_temp(a int);
INSERT INTO t_03_03_temp VALUES(1);
**** Dropping the connections
**** We want to SHOW BINLOG EVENTS, to know what was logged. But there is no
**** guarantee that logging of the terminated con1 has been done yet.a To be
**** sure that logging has been done, we use a user lock.
show status like 'Slave_open_temp_tables';
Variable_name Value
Slave_open_temp_tables 10
select get_lock("con_01",10);
get_lock("con_01",10)
1
select get_lock("con_01",10);
get_lock("con_01",10)
1
select get_lock("con_02",10);
get_lock("con_02",10)
1
select get_lock("con_02",10);
get_lock("con_02",10)
1
select get_lock("con_03",10);
get_lock("con_03",10)
1
select get_lock("con_03",10);
get_lock("con_03",10)
1
**** Checking the binary log and temporary tables
show status like 'Slave_open_temp_tables';
Variable_name Value
Slave_open_temp_tables 0
show binlog events from <binlog_start>;
Log_name Pos Event_type Server_id End_log_pos Info
master-bin.000001 # Query # # use `database_master_temp_01`; DROP /*!40005 TEMPORARY */ TABLE IF EXISTS `t_01_01_temp`
master-bin.000001 # Query # # use `database_master_temp_02`; DROP /*!40005 TEMPORARY */ TABLE IF EXISTS `t_02_02_temp`,`t_02_01_temp`
master-bin.000001 # Query # # use `database_master_temp_01`; DROP /*!40005 TEMPORARY */ TABLE IF EXISTS `t_01_01_temp`
master-bin.000001 # Query # # use `database_master_temp_03`; DROP /*!40005 TEMPORARY */ TABLE IF EXISTS `t_03_03_temp`,`t_03_02_temp`,`t_03_01_temp`
master-bin.000001 # Query # # use `database_master_temp_02`; DROP /*!40005 TEMPORARY */ TABLE IF EXISTS `t_02_02_temp`,`t_02_01_temp`
master-bin.000001 # Query # # use `database_master_temp_01`; DROP /*!40005 TEMPORARY */ TABLE IF EXISTS `t_01_01_temp`
****
**** Cleaning up the test case
****
SET sql_log_bin= 0;
DROP DATABASE database_master_temp_01;
DROP DATABASE database_master_temp_02;
DROP DATABASE database_master_temp_03;
SET sql_log_bin= 1;
SET sql_log_bin= 0;
DROP DATABASE database_slave_temp_01;
DROP DATABASE database_slave_temp_02;
DROP DATABASE database_slave_temp_03;
SET sql_log_bin= 1;

View File

@ -0,0 +1,870 @@
stop slave;
drop table if exists t1,t2,t3,t4,t5,t6,t7,t8,t9;
reset master;
reset slave;
drop table if exists t1,t2,t3,t4,t5,t6,t7,t8,t9;
start slave;
###################################################################################
# CONFIGURATION
###################################################################################
SET SQL_LOG_BIN=0;
CREATE TABLE nt_1 (a text, b int PRIMARY KEY, c text) ENGINE = MyISAM;
CREATE TABLE nt_2 (a text, b int PRIMARY KEY, c text) ENGINE = MyISAM;
CREATE TABLE nt_3 (a text, b int PRIMARY KEY, c text) ENGINE = MyISAM;
CREATE TABLE nt_4 (a text, b int PRIMARY KEY, c text) ENGINE = MyISAM;
CREATE TABLE tt_1 (a text, b int PRIMARY KEY, c text) ENGINE = Innodb;
CREATE TABLE tt_2 (a text, b int PRIMARY KEY, c text) ENGINE = Innodb;
CREATE TABLE tt_3 (a text, b int PRIMARY KEY, c text) ENGINE = Innodb;
CREATE TABLE tt_4 (a text, b int PRIMARY KEY, c text) ENGINE = Innodb;
SET SQL_LOG_BIN=1;
SET SQL_LOG_BIN=0;
CREATE TABLE nt_1 (a text, b int PRIMARY KEY, c text) ENGINE = MyISAM;
CREATE TABLE nt_2 (a text, b int PRIMARY KEY, c text) ENGINE = MyISAM;
CREATE TABLE nt_3 (a text, b int PRIMARY KEY, c text) ENGINE = MyISAM;
CREATE TABLE nt_4 (a text, b int PRIMARY KEY, c text) ENGINE = MyISAM;
CREATE TABLE tt_1 (a text, b int PRIMARY KEY, c text) ENGINE = Innodb;
CREATE TABLE tt_2 (a text, b int PRIMARY KEY, c text) ENGINE = Innodb;
CREATE TABLE tt_3 (a text, b int PRIMARY KEY, c text) ENGINE = Innodb;
CREATE TABLE tt_4 (a text, b int PRIMARY KEY, c text) ENGINE = Innodb;
SET SQL_LOG_BIN=1;
CREATE FUNCTION f1 () RETURNS VARCHAR(64)
BEGIN
RETURN "Testing...";
END|
CREATE FUNCTION f2 () RETURNS VARCHAR(64)
BEGIN
RETURN f1();
END|
CREATE PROCEDURE pc_i_tt_3 (IN x INT, IN y VARCHAR(64))
BEGIN
INSERT INTO tt_3 VALUES (y,x,x);
END|
CREATE TRIGGER tr_i_tt_3_to_nt_3 BEFORE INSERT ON tt_3 FOR EACH ROW
BEGIN
INSERT INTO nt_3 VALUES (NEW.a, NEW.b, NEW.c);
END|
CREATE TRIGGER tr_i_nt_4_to_tt_4 BEFORE INSERT ON nt_4 FOR EACH ROW
BEGIN
INSERT INTO tt_4 VALUES (NEW.a, NEW.b, NEW.c);
END|
###################################################################################
# MIXING TRANSACTIONAL and NON-TRANSACTIONAL TABLES
###################################################################################
#
#1) "B T T C" generates in binlog the "B T T C" entries.
#
BEGIN;
INSERT INTO tt_1 VALUES ("new text 4", 4, "new text 4");
INSERT INTO tt_2 VALUES ("new text 4", 4, "new text 4");
COMMIT;
show binlog events from <binlog_start>;
Log_name Pos Event_type Server_id End_log_pos Info
master-bin.000001 # Query # # BEGIN
master-bin.000001 # Query # # use `test`; INSERT INTO tt_1 VALUES ("new text 4", 4, "new text 4")
master-bin.000001 # Query # # use `test`; INSERT INTO tt_2 VALUES ("new text 4", 4, "new text 4")
master-bin.000001 # Xid # # COMMIT /* XID */
#
#1.e) "B T T C" with error in T generates in binlog the "B T T C" entries.
#
INSERT INTO tt_1 VALUES ("new text -2", -2, "new text -2");
BEGIN;
INSERT INTO tt_1 VALUES ("new text -1", -1, "new text -1"), ("new text -2", -2, "new text -2");
ERROR 23000: Duplicate entry '-2' for key 'PRIMARY'
INSERT INTO tt_2 VALUES ("new text -3", -3, "new text -3");
COMMIT;
BEGIN;
INSERT INTO tt_2 VALUES ("new text -5", -5, "new text -5");
INSERT INTO tt_2 VALUES ("new text -4", -4, "new text -4"), ("new text -5", -5, "new text -5");
ERROR 23000: Duplicate entry '-5' for key 'PRIMARY'
COMMIT;
show binlog events from <binlog_start>;
Log_name Pos Event_type Server_id End_log_pos Info
master-bin.000001 # Query # # BEGIN
master-bin.000001 # Query # # use `test`; INSERT INTO tt_1 VALUES ("new text -2", -2, "new text -2")
master-bin.000001 # Xid # # COMMIT /* XID */
master-bin.000001 # Query # # BEGIN
master-bin.000001 # Query # # use `test`; INSERT INTO tt_2 VALUES ("new text -3", -3, "new text -3")
master-bin.000001 # Xid # # COMMIT /* XID */
master-bin.000001 # Query # # BEGIN
master-bin.000001 # Query # # use `test`; INSERT INTO tt_2 VALUES ("new text -5", -5, "new text -5")
master-bin.000001 # Xid # # COMMIT /* XID */
#
#2) "B T T R" generates in binlog an "empty" entry.
#
BEGIN;
INSERT INTO tt_1 VALUES ("new text 5", 5, "new text 5");
INSERT INTO tt_2 VALUES ("new text 5", 5, "new text 5");
ROLLBACK;
show binlog events from <binlog_start>;
Log_name Pos Event_type Server_id End_log_pos Info
#
#2.e) "B T T R" with error in T generates in binlog an "empty" entry.
#
INSERT INTO tt_1 VALUES ("new text -7", -7, "new text -7");
BEGIN;
INSERT INTO tt_1 VALUES ("new text -6", -6, "new text -6"), ("new text -7", -7, "new text -7");
ERROR 23000: Duplicate entry '-7' for key 'PRIMARY'
INSERT INTO tt_2 VALUES ("new text -8", -8, "new text -8");
ROLLBACK;
BEGIN;
INSERT INTO tt_2 VALUES ("new text -10", -10, "new text -10");
INSERT INTO tt_2 VALUES ("new text -9", -9, "new text -9"), ("new text -10", -10, "new text -10");
ERROR 23000: Duplicate entry '-10' for key 'PRIMARY'
ROLLBACK;
show binlog events from <binlog_start>;
Log_name Pos Event_type Server_id End_log_pos Info
master-bin.000001 # Query # # BEGIN
master-bin.000001 # Query # # use `test`; INSERT INTO tt_1 VALUES ("new text -7", -7, "new text -7")
master-bin.000001 # Xid # # COMMIT /* XID */
#
#3) "B T N C" generates in binlog the "B T N C" entries.
#
BEGIN;
INSERT INTO tt_1 VALUES ("new text 6", 6, "new text 6");
INSERT INTO nt_1 VALUES ("new text 6", 6, "new text 6");
COMMIT;
show binlog events from <binlog_start>;
Log_name Pos Event_type Server_id End_log_pos Info
master-bin.000001 # Query # # BEGIN
master-bin.000001 # Query # # use `test`; INSERT INTO tt_1 VALUES ("new text 6", 6, "new text 6")
master-bin.000001 # Query # # use `test`; INSERT INTO nt_1 VALUES ("new text 6", 6, "new text 6")
master-bin.000001 # Xid # # COMMIT /* XID */
#
#3.e) "B T N C" with error in either T or N generates in binlog the "B T N C" entries.
#
INSERT INTO tt_1 VALUES ("new text -12", -12, "new text -12");
BEGIN;
INSERT INTO tt_1 VALUES ("new text -11", -11, "new text -11"), ("new text -12", -12, "new text -12");
ERROR 23000: Duplicate entry '-12' for key 'PRIMARY'
INSERT INTO nt_1 VALUES ("new text -13", -13, "new text -13");
COMMIT;
BEGIN;
INSERT INTO tt_1 VALUES ("new text -14", -14, "new text -14");
INSERT INTO nt_1 VALUES ("new text -16", -16, "new text -16");
INSERT INTO nt_1 VALUES ("new text -15", -15, "new text -15"), ("new text -16", -16, "new text -16");
ERROR 23000: Duplicate entry '-16' for key 'PRIMARY'
COMMIT;
show binlog events from <binlog_start>;
Log_name Pos Event_type Server_id End_log_pos Info
master-bin.000001 # Query # # BEGIN
master-bin.000001 # Query # # use `test`; INSERT INTO tt_1 VALUES ("new text -12", -12, "new text -12")
master-bin.000001 # Xid # # COMMIT /* XID */
master-bin.000001 # Query # # use `test`; INSERT INTO nt_1 VALUES ("new text -13", -13, "new text -13")
master-bin.000001 # Query # # BEGIN
master-bin.000001 # Query # # use `test`; INSERT INTO tt_1 VALUES ("new text -14", -14, "new text -14")
master-bin.000001 # Query # # use `test`; INSERT INTO nt_1 VALUES ("new text -16", -16, "new text -16")
master-bin.000001 # Query # # use `test`; INSERT INTO nt_1 VALUES ("new text -15", -15, "new text -15"), ("new text -16", -16, "new text -16")
master-bin.000001 # Xid # # COMMIT /* XID */
#
#4) "B T N R" generates in binlog the "B T N R" entries.
#
BEGIN;
INSERT INTO tt_1 VALUES ("new text 7", 7, "new text 7");
INSERT INTO nt_1 VALUES ("new text 7", 7, "new text 7");
ROLLBACK;
Warnings:
Warning 1196 Some non-transactional changed tables couldn't be rolled back
show binlog events from <binlog_start>;
Log_name Pos Event_type Server_id End_log_pos Info
master-bin.000001 # Query # # BEGIN
master-bin.000001 # Query # # use `test`; INSERT INTO tt_1 VALUES ("new text 7", 7, "new text 7")
master-bin.000001 # Query # # use `test`; INSERT INTO nt_1 VALUES ("new text 7", 7, "new text 7")
master-bin.000001 # Query # # ROLLBACK
#
#4.e) "B T N R" with error in either T or N generates in binlog the "B T N R" entries.
#
INSERT INTO tt_1 VALUES ("new text -17", -17, "new text -17");
BEGIN;
INSERT INTO tt_1 VALUES ("new text -16", -16, "new text -16"), ("new text -17", -17, "new text -17");
ERROR 23000: Duplicate entry '-17' for key 'PRIMARY'
INSERT INTO nt_1 VALUES ("new text -18", -18, "new text -18");
ROLLBACK;
Warnings:
Warning 1196 Some non-transactional changed tables couldn't be rolled back
BEGIN;
INSERT INTO tt_1 VALUES ("new text -19", -19, "new text -19");
INSERT INTO nt_1 VALUES ("new text -21", -21, "new text -21");
INSERT INTO nt_1 VALUES ("new text -20", -20, "new text -20"), ("new text -21", -21, "new text -21");
ERROR 23000: Duplicate entry '-21' for key 'PRIMARY'
ROLLBACK;
Warnings:
Warning 1196 Some non-transactional changed tables couldn't be rolled back
show binlog events from <binlog_start>;
Log_name Pos Event_type Server_id End_log_pos Info
master-bin.000001 # Query # # BEGIN
master-bin.000001 # Query # # use `test`; INSERT INTO tt_1 VALUES ("new text -17", -17, "new text -17")
master-bin.000001 # Xid # # COMMIT /* XID */
master-bin.000001 # Query # # use `test`; INSERT INTO nt_1 VALUES ("new text -18", -18, "new text -18")
master-bin.000001 # Query # # BEGIN
master-bin.000001 # Query # # use `test`; INSERT INTO tt_1 VALUES ("new text -19", -19, "new text -19")
master-bin.000001 # Query # # use `test`; INSERT INTO nt_1 VALUES ("new text -21", -21, "new text -21")
master-bin.000001 # Query # # use `test`; INSERT INTO nt_1 VALUES ("new text -20", -20, "new text -20"), ("new text -21", -21, "new text -21")
master-bin.000001 # Query # # ROLLBACK
#
#5) "T" generates in binlog the "B T C" entry.
#
INSERT INTO tt_1 VALUES ("new text 8", 8, "new text 8");
show binlog events from <binlog_start>;
Log_name Pos Event_type Server_id End_log_pos Info
master-bin.000001 # Query # # BEGIN
master-bin.000001 # Query # # use `test`; INSERT INTO tt_1 VALUES ("new text 8", 8, "new text 8")
master-bin.000001 # Xid # # COMMIT /* XID */
#
#5.e) "T" with error in T generates in binlog an "empty" entry.
#
INSERT INTO tt_1 VALUES ("new text -1", -1, "new text -1");
INSERT INTO tt_1 VALUES ("new text -1", -1, "new text -1"), ("new text -22", -22, "new text -22");
ERROR 23000: Duplicate entry '-1' for key 'PRIMARY'
INSERT INTO tt_1 VALUES ("new text -23", -23, "new text -23"), ("new text -1", -1, "new text -1");
ERROR 23000: Duplicate entry '-1' for key 'PRIMARY'
show binlog events from <binlog_start>;
Log_name Pos Event_type Server_id End_log_pos Info
master-bin.000001 # Query # # BEGIN
master-bin.000001 # Query # # use `test`; INSERT INTO tt_1 VALUES ("new text -1", -1, "new text -1")
master-bin.000001 # Xid # # COMMIT /* XID */
#
#6) "N" generates in binlog the "N" entry.
#
INSERT INTO nt_1 VALUES ("new text 9", 9, "new text 9");
show binlog events from <binlog_start>;
Log_name Pos Event_type Server_id End_log_pos Info
master-bin.000001 # Query # # use `test`; INSERT INTO nt_1 VALUES ("new text 9", 9, "new text 9")
#
#6.e) "N" with error in N generates in binlog an empty entry if the error
# happens in the first tuple. Otherwise, generates the "N" entry and
# the error is appended.
#
INSERT INTO nt_1 VALUES ("new text -1", -1, "new text -1");
INSERT INTO nt_1 VALUES ("new text -1", -1, "new text -1");
ERROR 23000: Duplicate entry '-1' for key 'PRIMARY'
INSERT INTO nt_1 VALUES ("new text -24", -24, "new text -24"), ("new text -1", -1, "new text -1");
ERROR 23000: Duplicate entry '-1' for key 'PRIMARY'
show binlog events from <binlog_start>;
Log_name Pos Event_type Server_id End_log_pos Info
master-bin.000001 # Query # # use `test`; INSERT INTO nt_1 VALUES ("new text -1", -1, "new text -1")
master-bin.000001 # Query # # use `test`; INSERT INTO nt_1 VALUES ("new text -24", -24, "new text -24"), ("new text -1", -1, "new text -1")
#
#7) "M" generates in binglog the "B M C" entries.
#
DELETE FROM nt_1;
INSERT INTO nt_1 SELECT * FROM tt_1;
DELETE FROM tt_1;
INSERT INTO tt_1 SELECT * FROM nt_1;
INSERT INTO tt_3 VALUES ("new text 000", 000, '');
INSERT INTO tt_3 VALUES("new text 100", 100, f1());
INSERT INTO nt_4 VALUES("new text 100", 100, f1());
INSERT INTO tt_3 VALUES("new text 200", 200, f2());
INSERT INTO nt_4 VALUES ("new text 300", 300, '');
INSERT INTO nt_4 VALUES ("new text 400", 400, f1());
INSERT INTO nt_4 VALUES ("new text 500", 500, f2());
CALL pc_i_tt_3(600, "Testing...");
UPDATE nt_3, nt_4, tt_3, tt_4 SET nt_3.a= "new text 1", nt_4.a= "new text 1", tt_3.a= "new text 1", tt_4.a= "new text 1" where nt_3.b = nt_4.b and nt_4.b = tt_3.b and tt_3.b = tt_4.b and tt_4.b = 100;
UPDATE tt_3, tt_4, nt_3, nt_4 SET tt_3.a= "new text 2", tt_4.a= "new text 2", nt_3.a= "new text 2", nt_4.a = "new text 2" where nt_3.b = nt_4.b and nt_4.b = tt_3.b and tt_3.b = tt_4.b and tt_4.b = 100;
UPDATE tt_3, nt_3, nt_4, tt_4 SET tt_3.a= "new text 3", nt_3.a= "new text 3", nt_4.a= "new text 3", tt_4.a = "new text 3" where nt_3.b = nt_4.b and nt_4.b = tt_3.b and tt_3.b = tt_4.b and tt_4.b = 100;
UPDATE tt_3, nt_3, nt_4, tt_4 SET tt_3.a= "new text 4", nt_3.a= "new text 4", nt_4.a= "new text 4", tt_4.a = "new text 4" where nt_3.b = nt_4.b and nt_4.b = tt_3.b and tt_3.b = tt_4.b and tt_4.b = 100;
show binlog events from <binlog_start>;
Log_name Pos Event_type Server_id End_log_pos Info
master-bin.000001 # Query # # use `test`; DELETE FROM nt_1
master-bin.000001 # Query # # use `test`; INSERT INTO nt_1 SELECT * FROM tt_1
master-bin.000001 # Query # # BEGIN
master-bin.000001 # Query # # use `test`; DELETE FROM tt_1
master-bin.000001 # Xid # # COMMIT /* XID */
master-bin.000001 # Query # # BEGIN
master-bin.000001 # Query # # use `test`; INSERT INTO tt_1 SELECT * FROM nt_1
master-bin.000001 # Xid # # COMMIT /* XID */
master-bin.000001 # Query # # BEGIN
master-bin.000001 # Query # # use `test`; INSERT INTO tt_3 VALUES ("new text 000", 000, '')
master-bin.000001 # Xid # # COMMIT /* XID */
master-bin.000001 # Query # # BEGIN
master-bin.000001 # Query # # use `test`; INSERT INTO tt_3 VALUES("new text 100", 100, f1())
master-bin.000001 # Xid # # COMMIT /* XID */
master-bin.000001 # Query # # BEGIN
master-bin.000001 # Query # # use `test`; INSERT INTO nt_4 VALUES("new text 100", 100, f1())
master-bin.000001 # Xid # # COMMIT /* XID */
master-bin.000001 # Query # # BEGIN
master-bin.000001 # Query # # use `test`; INSERT INTO tt_3 VALUES("new text 200", 200, f2())
master-bin.000001 # Xid # # COMMIT /* XID */
master-bin.000001 # Query # # BEGIN
master-bin.000001 # Query # # use `test`; INSERT INTO nt_4 VALUES ("new text 300", 300, '')
master-bin.000001 # Xid # # COMMIT /* XID */
master-bin.000001 # Query # # BEGIN
master-bin.000001 # Query # # use `test`; INSERT INTO nt_4 VALUES ("new text 400", 400, f1())
master-bin.000001 # Xid # # COMMIT /* XID */
master-bin.000001 # Query # # BEGIN
master-bin.000001 # Query # # use `test`; INSERT INTO nt_4 VALUES ("new text 500", 500, f2())
master-bin.000001 # Xid # # COMMIT /* XID */
master-bin.000001 # Query # # BEGIN
master-bin.000001 # Query # # use `test`; INSERT INTO tt_3 VALUES ( NAME_CONST('y',_latin1'Testing...' COLLATE 'latin1_swedish_ci'), NAME_CONST('x',600), NAME_CONST('x',600))
master-bin.000001 # Xid # # COMMIT /* XID */
master-bin.000001 # Query # # BEGIN
master-bin.000001 # Query # # use `test`; UPDATE nt_3, nt_4, tt_3, tt_4 SET nt_3.a= "new text 1", nt_4.a= "new text 1", tt_3.a= "new text 1", tt_4.a= "new text 1" where nt_3.b = nt_4.b and nt_4.b = tt_3.b and tt_3.b = tt_4.b and tt_4.b = 100
master-bin.000001 # Xid # # COMMIT /* XID */
master-bin.000001 # Query # # BEGIN
master-bin.000001 # Query # # use `test`; UPDATE tt_3, tt_4, nt_3, nt_4 SET tt_3.a= "new text 2", tt_4.a= "new text 2", nt_3.a= "new text 2", nt_4.a = "new text 2" where nt_3.b = nt_4.b and nt_4.b = tt_3.b and tt_3.b = tt_4.b and tt_4.b = 100
master-bin.000001 # Xid # # COMMIT /* XID */
master-bin.000001 # Query # # BEGIN
master-bin.000001 # Query # # use `test`; UPDATE tt_3, nt_3, nt_4, tt_4 SET tt_3.a= "new text 3", nt_3.a= "new text 3", nt_4.a= "new text 3", tt_4.a = "new text 3" where nt_3.b = nt_4.b and nt_4.b = tt_3.b and tt_3.b = tt_4.b and tt_4.b = 100
master-bin.000001 # Xid # # COMMIT /* XID */
master-bin.000001 # Query # # BEGIN
master-bin.000001 # Query # # use `test`; UPDATE tt_3, nt_3, nt_4, tt_4 SET tt_3.a= "new text 4", nt_3.a= "new text 4", nt_4.a= "new text 4", tt_4.a = "new text 4" where nt_3.b = nt_4.b and nt_4.b = tt_3.b and tt_3.b = tt_4.b and tt_4.b = 100
master-bin.000001 # Xid # # COMMIT /* XID */
#
#7.e) "M" with error in M generates in binglog the "B M R" entries.
#
INSERT INTO nt_3 VALUES ("new text -26", -26, '');
SELECT * FROM tt_3;
a b c
new text 000 0
new text 4 100 Testing...
new text 200 200 Testing...
Testing... 600 600
INSERT INTO tt_3 VALUES ("new text -25", -25, ''), ("new text -26", -26, '');
ERROR 23000: Duplicate entry '-26' for key 'PRIMARY'
SELECT * FROM tt_3;
a b c
new text 000 0
new text 4 100 Testing...
new text 200 200 Testing...
Testing... 600 600
INSERT INTO tt_4 VALUES ("new text -26", -26, '');
SELECT * FROM nt_4;
a b c
new text 4 100 Testing...
new text 300 300
new text 400 400 Testing...
new text 500 500 Testing...
INSERT INTO nt_4 VALUES ("new text -25", -25, ''), ("new text -26", -26, '');
ERROR 23000: Duplicate entry '-26' for key 'PRIMARY'
SELECT * FROM nt_4;
a b c
new text 4 100 Testing...
new text 300 300
new text 400 400 Testing...
new text 500 500 Testing...
new text -25 -25
show binlog events from <binlog_start>;
Log_name Pos Event_type Server_id End_log_pos Info
master-bin.000001 # Query # # use `test`; INSERT INTO nt_3 VALUES ("new text -26", -26, '')
master-bin.000001 # Query # # BEGIN
master-bin.000001 # Query # # use `test`; INSERT INTO tt_3 VALUES ("new text -25", -25, ''), ("new text -26", -26, '')
master-bin.000001 # Query # # ROLLBACK
master-bin.000001 # Query # # BEGIN
master-bin.000001 # Query # # use `test`; INSERT INTO tt_4 VALUES ("new text -26", -26, '')
master-bin.000001 # Xid # # COMMIT /* XID */
master-bin.000001 # Query # # BEGIN
master-bin.000001 # Query # # use `test`; INSERT INTO nt_4 VALUES ("new text -25", -25, ''), ("new text -26", -26, '')
master-bin.000001 # Query # # ROLLBACK
#
#8) "B N N T C" generates in binglog the "N N B T C" entries.
#
BEGIN;
INSERT INTO nt_1 VALUES ("new text 10", 10, "new text 10");
INSERT INTO nt_2 VALUES ("new text 10", 10, "new text 10");
INSERT INTO tt_1 VALUES ("new text 10", 10, "new text 10");
COMMIT;
show binlog events from <binlog_start>;
Log_name Pos Event_type Server_id End_log_pos Info
master-bin.000001 # Query # # use `test`; INSERT INTO nt_1 VALUES ("new text 10", 10, "new text 10")
master-bin.000001 # Query # # use `test`; INSERT INTO nt_2 VALUES ("new text 10", 10, "new text 10")
master-bin.000001 # Query # # BEGIN
master-bin.000001 # Query # # use `test`; INSERT INTO tt_1 VALUES ("new text 10", 10, "new text 10")
master-bin.000001 # Xid # # COMMIT /* XID */
#
#8.e) "B N N T R" See 6.e and 9.e.
#
#
#9) "B N N T R" generates in binlog the "N N B T R" entries.
#
BEGIN;
INSERT INTO nt_1 VALUES ("new text 11", 11, "new text 11");
INSERT INTO nt_2 VALUES ("new text 11", 11, "new text 11");
INSERT INTO tt_1 VALUES ("new text 11", 11, "new text 11");
ROLLBACK;
Warnings:
Warning 1196 Some non-transactional changed tables couldn't be rolled back
show binlog events from <binlog_start>;
Log_name Pos Event_type Server_id End_log_pos Info
master-bin.000001 # Query # # use `test`; INSERT INTO nt_1 VALUES ("new text 11", 11, "new text 11")
master-bin.000001 # Query # # use `test`; INSERT INTO nt_2 VALUES ("new text 11", 11, "new text 11")
master-bin.000001 # Query # # BEGIN
master-bin.000001 # Query # # use `test`; INSERT INTO tt_1 VALUES ("new text 11", 11, "new text 11")
master-bin.000001 # Query # # ROLLBACK
#
#9.e) "B N N T R" with error in N generates in binlog the "N N B T R" entries.
#
BEGIN;
INSERT INTO nt_1 VALUES ("new text -25", -25, "new text -25");
INSERT INTO nt_2 VALUES ("new text -25", -25, "new text -25");
INSERT INTO nt_2 VALUES ("new text -26", -26, "new text -26"), ("new text -25", -25, "new text -25");
ERROR 23000: Duplicate entry '-25' for key 'PRIMARY'
INSERT INTO tt_1 VALUES ("new text -27", -27, "new text -27");
ROLLBACK;
Warnings:
Warning 1196 Some non-transactional changed tables couldn't be rolled back
show binlog events from <binlog_start>;
Log_name Pos Event_type Server_id End_log_pos Info
master-bin.000001 # Query # # use `test`; INSERT INTO nt_1 VALUES ("new text -25", -25, "new text -25")
master-bin.000001 # Query # # use `test`; INSERT INTO nt_2 VALUES ("new text -25", -25, "new text -25")
master-bin.000001 # Query # # use `test`; INSERT INTO nt_2 VALUES ("new text -26", -26, "new text -26"), ("new text -25", -25, "new text -25")
master-bin.000001 # Query # # BEGIN
master-bin.000001 # Query # # use `test`; INSERT INTO tt_1 VALUES ("new text -27", -27, "new text -27")
master-bin.000001 # Query # # ROLLBACK
#
#10) "B N N C" generates in binglog the "N N" entries.
#
BEGIN;
INSERT INTO nt_1 VALUES ("new text 12", 12, "new text 12");
INSERT INTO nt_2 VALUES ("new text 12", 12, "new text 12");
COMMIT;
show binlog events from <binlog_start>;
Log_name Pos Event_type Server_id End_log_pos Info
master-bin.000001 # Query # # use `test`; INSERT INTO nt_1 VALUES ("new text 12", 12, "new text 12")
master-bin.000001 # Query # # use `test`; INSERT INTO nt_2 VALUES ("new text 12", 12, "new text 12")
#
#10.e) "B N N C" See 6.e and 9.e.
#
#
#11) "B N N R" generates in binlog the "N N" entries.
#
BEGIN;
INSERT INTO nt_1 VALUES ("new text 13", 13, "new text 13");
INSERT INTO nt_2 VALUES ("new text 13", 13, "new text 13");
ROLLBACK;
Warnings:
Warning 1196 Some non-transactional changed tables couldn't be rolled back
show binlog events from <binlog_start>;
Log_name Pos Event_type Server_id End_log_pos Info
master-bin.000001 # Query # # use `test`; INSERT INTO nt_1 VALUES ("new text 13", 13, "new text 13")
master-bin.000001 # Query # # use `test`; INSERT INTO nt_2 VALUES ("new text 13", 13, "new text 13")
#
#11.e) "B N N R" See 6.e and 9.e.
#
#
#12) "B M T C" generates in the binlog the "B M T C" entries.
#
DELETE FROM nt_1;
BEGIN;
INSERT INTO nt_1 SELECT * FROM tt_1;
INSERT INTO tt_2 VALUES ("new text 14", 14, "new text 14");
COMMIT;
DELETE FROM tt_1;
BEGIN;
INSERT INTO tt_1 SELECT * FROM nt_1;
INSERT INTO tt_2 VALUES ("new text 15", 15, "new text 15");
COMMIT;
BEGIN;
INSERT INTO tt_3 VALUES ("new text 700", 700, '');
INSERT INTO tt_1 VALUES ("new text 800", 800, '');
COMMIT;
BEGIN;
INSERT INTO tt_3 VALUES("new text 900", 900, f1());
INSERT INTO tt_1 VALUES ("new text 1000", 1000, '');
COMMIT;
BEGIN;
INSERT INTO tt_3 VALUES(1100, 1100, f2());
INSERT INTO tt_1 VALUES ("new text 1200", 1200, '');
COMMIT;
BEGIN;
INSERT INTO nt_4 VALUES ("new text 1300", 1300, '');
INSERT INTO tt_1 VALUES ("new text 1400", 1400, '');
COMMIT;
BEGIN;
INSERT INTO nt_4 VALUES("new text 1500", 1500, f1());
INSERT INTO tt_1 VALUES ("new text 1600", 1600, '');
COMMIT;
BEGIN;
INSERT INTO nt_4 VALUES("new text 1700", 1700, f2());
INSERT INTO tt_1 VALUES ("new text 1800", 1800, '');
COMMIT;
BEGIN;
CALL pc_i_tt_3(1900, "Testing...");
INSERT INTO tt_1 VALUES ("new text 2000", 2000, '');
COMMIT;
BEGIN;
UPDATE nt_3, nt_4, tt_3, tt_4 SET nt_3.a= "new text 5", nt_4.a= "new text 5", tt_3.a= "new text 5", tt_4.a= "new text 5" where nt_3.b = nt_4.b and nt_4.b = tt_3.b and tt_3.b = tt_4.b and tt_4.b = 100;
INSERT INTO tt_1 VALUES ("new text 2100", 2100, '');
COMMIT;
BEGIN;
UPDATE tt_3, tt_4, nt_3, nt_4 SET tt_3.a= "new text 6", tt_4.a= "new text 6", nt_3.a= "new text 6", nt_4.a = "new text 6" where nt_3.b = nt_4.b and nt_4.b = tt_3.b and tt_3.b = tt_4.b and tt_4.b = 100;
INSERT INTO tt_1 VALUES ("new text 2200", 2200, '');
COMMIT;
BEGIN;
UPDATE tt_3, nt_3, nt_4, tt_4 SET tt_3.a= "new text 7", nt_3.a= "new text 7", nt_4.a= "new text 7", tt_4.a = "new text 7" where nt_3.b = nt_4.b and nt_4.b = tt_3.b and tt_3.b = tt_4.b and tt_4.b = 100;
INSERT INTO tt_1 VALUES ("new text 2300", 2300, '');
COMMIT;
BEGIN;
UPDATE tt_3, nt_3, nt_4, tt_4 SET tt_3.a= "new text 8", nt_3.a= "new text 8", nt_4.a= "new text 8", tt_4.a = "new text 8" where nt_3.b = nt_4.b and nt_4.b = tt_3.b and tt_3.b = tt_4.b and tt_4.b = 100;
INSERT INTO tt_1 VALUES ("new text 2400", 2400, '');
COMMIT;
show binlog events from <binlog_start>;
Log_name Pos Event_type Server_id End_log_pos Info
master-bin.000001 # Query # # use `test`; DELETE FROM nt_1
master-bin.000001 # Query # # use `test`; INSERT INTO nt_1 SELECT * FROM tt_1
master-bin.000001 # Query # # BEGIN
master-bin.000001 # Query # # use `test`; INSERT INTO tt_2 VALUES ("new text 14", 14, "new text 14")
master-bin.000001 # Xid # # COMMIT /* XID */
master-bin.000001 # Query # # BEGIN
master-bin.000001 # Query # # use `test`; DELETE FROM tt_1
master-bin.000001 # Xid # # COMMIT /* XID */
master-bin.000001 # Query # # BEGIN
master-bin.000001 # Query # # use `test`; INSERT INTO tt_1 SELECT * FROM nt_1
master-bin.000001 # Query # # use `test`; INSERT INTO tt_2 VALUES ("new text 15", 15, "new text 15")
master-bin.000001 # Xid # # COMMIT /* XID */
master-bin.000001 # Query # # BEGIN
master-bin.000001 # Query # # use `test`; INSERT INTO tt_3 VALUES ("new text 700", 700, '')
master-bin.000001 # Query # # use `test`; INSERT INTO tt_1 VALUES ("new text 800", 800, '')
master-bin.000001 # Xid # # COMMIT /* XID */
master-bin.000001 # Query # # BEGIN
master-bin.000001 # Query # # use `test`; INSERT INTO tt_3 VALUES("new text 900", 900, f1())
master-bin.000001 # Query # # use `test`; INSERT INTO tt_1 VALUES ("new text 1000", 1000, '')
master-bin.000001 # Xid # # COMMIT /* XID */
master-bin.000001 # Query # # BEGIN
master-bin.000001 # Query # # use `test`; INSERT INTO tt_3 VALUES(1100, 1100, f2())
master-bin.000001 # Query # # use `test`; INSERT INTO tt_1 VALUES ("new text 1200", 1200, '')
master-bin.000001 # Xid # # COMMIT /* XID */
master-bin.000001 # Query # # BEGIN
master-bin.000001 # Query # # use `test`; INSERT INTO nt_4 VALUES ("new text 1300", 1300, '')
master-bin.000001 # Query # # use `test`; INSERT INTO tt_1 VALUES ("new text 1400", 1400, '')
master-bin.000001 # Xid # # COMMIT /* XID */
master-bin.000001 # Query # # BEGIN
master-bin.000001 # Query # # use `test`; INSERT INTO nt_4 VALUES("new text 1500", 1500, f1())
master-bin.000001 # Query # # use `test`; INSERT INTO tt_1 VALUES ("new text 1600", 1600, '')
master-bin.000001 # Xid # # COMMIT /* XID */
master-bin.000001 # Query # # BEGIN
master-bin.000001 # Query # # use `test`; INSERT INTO nt_4 VALUES("new text 1700", 1700, f2())
master-bin.000001 # Query # # use `test`; INSERT INTO tt_1 VALUES ("new text 1800", 1800, '')
master-bin.000001 # Xid # # COMMIT /* XID */
master-bin.000001 # Query # # BEGIN
master-bin.000001 # Query # # use `test`; INSERT INTO tt_3 VALUES ( NAME_CONST('y',_latin1'Testing...' COLLATE 'latin1_swedish_ci'), NAME_CONST('x',1900), NAME_CONST('x',1900))
master-bin.000001 # Query # # use `test`; INSERT INTO tt_1 VALUES ("new text 2000", 2000, '')
master-bin.000001 # Xid # # COMMIT /* XID */
master-bin.000001 # Query # # BEGIN
master-bin.000001 # Query # # use `test`; UPDATE nt_3, nt_4, tt_3, tt_4 SET nt_3.a= "new text 5", nt_4.a= "new text 5", tt_3.a= "new text 5", tt_4.a= "new text 5" where nt_3.b = nt_4.b and nt_4.b = tt_3.b and tt_3.b = tt_4.b and tt_4.b = 100
master-bin.000001 # Query # # use `test`; INSERT INTO tt_1 VALUES ("new text 2100", 2100, '')
master-bin.000001 # Xid # # COMMIT /* XID */
master-bin.000001 # Query # # BEGIN
master-bin.000001 # Query # # use `test`; UPDATE tt_3, tt_4, nt_3, nt_4 SET tt_3.a= "new text 6", tt_4.a= "new text 6", nt_3.a= "new text 6", nt_4.a = "new text 6" where nt_3.b = nt_4.b and nt_4.b = tt_3.b and tt_3.b = tt_4.b and tt_4.b = 100
master-bin.000001 # Query # # use `test`; INSERT INTO tt_1 VALUES ("new text 2200", 2200, '')
master-bin.000001 # Xid # # COMMIT /* XID */
master-bin.000001 # Query # # BEGIN
master-bin.000001 # Query # # use `test`; UPDATE tt_3, nt_3, nt_4, tt_4 SET tt_3.a= "new text 7", nt_3.a= "new text 7", nt_4.a= "new text 7", tt_4.a = "new text 7" where nt_3.b = nt_4.b and nt_4.b = tt_3.b and tt_3.b = tt_4.b and tt_4.b = 100
master-bin.000001 # Query # # use `test`; INSERT INTO tt_1 VALUES ("new text 2300", 2300, '')
master-bin.000001 # Xid # # COMMIT /* XID */
master-bin.000001 # Query # # BEGIN
master-bin.000001 # Query # # use `test`; UPDATE tt_3, nt_3, nt_4, tt_4 SET tt_3.a= "new text 8", nt_3.a= "new text 8", nt_4.a= "new text 8", tt_4.a = "new text 8" where nt_3.b = nt_4.b and nt_4.b = tt_3.b and tt_3.b = tt_4.b and tt_4.b = 100
master-bin.000001 # Query # # use `test`; INSERT INTO tt_1 VALUES ("new text 2400", 2400, '')
master-bin.000001 # Xid # # COMMIT /* XID */
#
#12.e) "B M T C" with error in M generates in the binlog the "B M T C" entries.
#
# There is a bug in the slave that needs to be fixed before enabling
# this part of the test. A bug report will be filed referencing this
# test case.
BEGIN;
INSERT INTO nt_3 VALUES ("new text -28", -28, '');
INSERT INTO tt_3 VALUES ("new text -27", -27, ''), ("new text -28", -28, '');
ERROR 23000: Duplicate entry '-28' for key 'PRIMARY'
INSERT INTO tt_1 VALUES ("new text -27", -27, '');
COMMIT;
BEGIN;
INSERT INTO tt_4 VALUES ("new text -28", -28, '');
INSERT INTO nt_4 VALUES ("new text -27", -27, ''), ("new text -28", -28, '');
ERROR 23000: Duplicate entry '-28' for key 'PRIMARY'
INSERT INTO tt_1 VALUES ("new text -28", -28, '');
COMMIT;
show binlog events from <binlog_start>;
Log_name Pos Event_type Server_id End_log_pos Info
master-bin.000001 # Query # # use `test`; INSERT INTO nt_3 VALUES ("new text -28", -28, '')
master-bin.000001 # Query # # BEGIN
master-bin.000001 # Query # # use `test`; INSERT INTO tt_3 VALUES ("new text -27", -27, ''), ("new text -28", -28, '')
master-bin.000001 # Query # # use `test`; INSERT INTO tt_1 VALUES ("new text -27", -27, '')
master-bin.000001 # Xid # # COMMIT /* XID */
master-bin.000001 # Query # # BEGIN
master-bin.000001 # Query # # use `test`; INSERT INTO tt_4 VALUES ("new text -28", -28, '')
master-bin.000001 # Query # # use `test`; INSERT INTO nt_4 VALUES ("new text -27", -27, ''), ("new text -28", -28, '')
master-bin.000001 # Query # # use `test`; INSERT INTO tt_1 VALUES ("new text -28", -28, '')
master-bin.000001 # Xid # # COMMIT /* XID */
#
#13) "B M T R" generates in the binlog the "B M T R" entries
#
DELETE FROM nt_1;
BEGIN;
INSERT INTO nt_1 SELECT * FROM tt_1;
INSERT INTO tt_2 VALUES ("new text 17", 17, "new text 17");
ROLLBACK;
Warnings:
Warning 1196 Some non-transactional changed tables couldn't be rolled back
DELETE FROM tt_1;
BEGIN;
INSERT INTO tt_1 SELECT * FROM nt_1;
INSERT INTO tt_2 VALUES ("new text 18", 18, "new text 18");
ROLLBACK;
INSERT INTO tt_1 SELECT * FROM nt_1;
BEGIN;
INSERT INTO tt_3 VALUES ("new text 2500", 2500, '');
INSERT INTO tt_1 VALUES ("new text 2600", 2600, '');
ROLLBACK;
Warnings:
Warning 1196 Some non-transactional changed tables couldn't be rolled back
BEGIN;
INSERT INTO tt_3 VALUES("new text 2700", 2700, f1());
INSERT INTO tt_1 VALUES ("new text 2800", 2800, '');
ROLLBACK;
Warnings:
Warning 1196 Some non-transactional changed tables couldn't be rolled back
BEGIN;
INSERT INTO tt_3 VALUES(2900, 2900, f2());
INSERT INTO tt_1 VALUES ("new text 3000", 3000, '');
ROLLBACK;
Warnings:
Warning 1196 Some non-transactional changed tables couldn't be rolled back
BEGIN;
INSERT INTO nt_4 VALUES ("new text 3100", 3100, '');
INSERT INTO tt_1 VALUES ("new text 3200", 3200, '');
ROLLBACK;
Warnings:
Warning 1196 Some non-transactional changed tables couldn't be rolled back
BEGIN;
INSERT INTO nt_4 VALUES("new text 3300", 3300, f1());
INSERT INTO tt_1 VALUES ("new text 3400", 3400, '');
ROLLBACK;
Warnings:
Warning 1196 Some non-transactional changed tables couldn't be rolled back
BEGIN;
INSERT INTO nt_4 VALUES("new text 3500", 3500, f2());
INSERT INTO tt_1 VALUES ("new text 3600", 3600, '');
ROLLBACK;
Warnings:
Warning 1196 Some non-transactional changed tables couldn't be rolled back
BEGIN;
CALL pc_i_tt_3(3700, "Testing...");
INSERT INTO tt_1 VALUES ("new text 3700", 3700, '');
ROLLBACK;
Warnings:
Warning 1196 Some non-transactional changed tables couldn't be rolled back
BEGIN;
UPDATE nt_3, nt_4, tt_3, tt_4 SET nt_3.a= "new text 9", nt_4.a= "new text 9", tt_3.a= "new text 9", tt_4.a= "new text 9" where nt_3.b = nt_4.b and nt_4.b = tt_3.b and tt_3.b = tt_4.b and tt_4.b = 100;
INSERT INTO tt_1 VALUES ("new text 3800", 3800, '');
ROLLBACK;
Warnings:
Warning 1196 Some non-transactional changed tables couldn't be rolled back
BEGIN;
UPDATE tt_3, tt_4, nt_3, nt_4 SET tt_3.a= "new text 10", tt_4.a= "new text 10", nt_3.a= "new text 10", nt_4.a = "new text 10" where nt_3.b = nt_4.b and nt_4.b = tt_3.b and tt_3.b = tt_4.b and tt_4.b = 100;
INSERT INTO tt_1 VALUES ("new text 3900", 3900, '');
ROLLBACK;
Warnings:
Warning 1196 Some non-transactional changed tables couldn't be rolled back
BEGIN;
UPDATE tt_3, nt_3, nt_4, tt_4 SET tt_3.a= "new text 11", nt_3.a= "new text 11", nt_4.a= "new text 11", tt_4.a = "new text 11" where nt_3.b = nt_4.b and nt_4.b = tt_3.b and tt_3.b = tt_4.b and tt_4.b = 100;
INSERT INTO tt_1 VALUES ("new text 4000", 4000, '');
ROLLBACK;
Warnings:
Warning 1196 Some non-transactional changed tables couldn't be rolled back
BEGIN;
UPDATE tt_3, nt_3, nt_4, tt_4 SET tt_3.a= "new text 12", nt_3.a= "new text 12", nt_4.a= "new text 12", tt_4.a = "new text 12" where nt_3.b = nt_4.b and nt_4.b = tt_3.b and tt_3.b = tt_4.b and tt_4.b = 100;
INSERT INTO tt_1 VALUES ("new text 4100", 4100, '');
ROLLBACK;
Warnings:
Warning 1196 Some non-transactional changed tables couldn't be rolled back
show binlog events from <binlog_start>;
Log_name Pos Event_type Server_id End_log_pos Info
master-bin.000001 # Query # # use `test`; DELETE FROM nt_1
master-bin.000001 # Query # # use `test`; INSERT INTO nt_1 SELECT * FROM tt_1
master-bin.000001 # Query # # BEGIN
master-bin.000001 # Query # # use `test`; INSERT INTO tt_2 VALUES ("new text 17", 17, "new text 17")
master-bin.000001 # Query # # ROLLBACK
master-bin.000001 # Query # # BEGIN
master-bin.000001 # Query # # use `test`; DELETE FROM tt_1
master-bin.000001 # Xid # # COMMIT /* XID */
master-bin.000001 # Query # # BEGIN
master-bin.000001 # Query # # use `test`; INSERT INTO tt_1 SELECT * FROM nt_1
master-bin.000001 # Xid # # COMMIT /* XID */
master-bin.000001 # Query # # BEGIN
master-bin.000001 # Query # # use `test`; INSERT INTO tt_3 VALUES ("new text 2500", 2500, '')
master-bin.000001 # Query # # use `test`; INSERT INTO tt_1 VALUES ("new text 2600", 2600, '')
master-bin.000001 # Query # # ROLLBACK
master-bin.000001 # Query # # BEGIN
master-bin.000001 # Query # # use `test`; INSERT INTO tt_3 VALUES("new text 2700", 2700, f1())
master-bin.000001 # Query # # use `test`; INSERT INTO tt_1 VALUES ("new text 2800", 2800, '')
master-bin.000001 # Query # # ROLLBACK
master-bin.000001 # Query # # BEGIN
master-bin.000001 # Query # # use `test`; INSERT INTO tt_3 VALUES(2900, 2900, f2())
master-bin.000001 # Query # # use `test`; INSERT INTO tt_1 VALUES ("new text 3000", 3000, '')
master-bin.000001 # Query # # ROLLBACK
master-bin.000001 # Query # # BEGIN
master-bin.000001 # Query # # use `test`; INSERT INTO nt_4 VALUES ("new text 3100", 3100, '')
master-bin.000001 # Query # # use `test`; INSERT INTO tt_1 VALUES ("new text 3200", 3200, '')
master-bin.000001 # Query # # ROLLBACK
master-bin.000001 # Query # # BEGIN
master-bin.000001 # Query # # use `test`; INSERT INTO nt_4 VALUES("new text 3300", 3300, f1())
master-bin.000001 # Query # # use `test`; INSERT INTO tt_1 VALUES ("new text 3400", 3400, '')
master-bin.000001 # Query # # ROLLBACK
master-bin.000001 # Query # # BEGIN
master-bin.000001 # Query # # use `test`; INSERT INTO nt_4 VALUES("new text 3500", 3500, f2())
master-bin.000001 # Query # # use `test`; INSERT INTO tt_1 VALUES ("new text 3600", 3600, '')
master-bin.000001 # Query # # ROLLBACK
master-bin.000001 # Query # # BEGIN
master-bin.000001 # Query # # use `test`; INSERT INTO tt_3 VALUES ( NAME_CONST('y',_latin1'Testing...' COLLATE 'latin1_swedish_ci'), NAME_CONST('x',3700), NAME_CONST('x',3700))
master-bin.000001 # Query # # use `test`; INSERT INTO tt_1 VALUES ("new text 3700", 3700, '')
master-bin.000001 # Query # # ROLLBACK
master-bin.000001 # Query # # BEGIN
master-bin.000001 # Query # # use `test`; UPDATE nt_3, nt_4, tt_3, tt_4 SET nt_3.a= "new text 9", nt_4.a= "new text 9", tt_3.a= "new text 9", tt_4.a= "new text 9" where nt_3.b = nt_4.b and nt_4.b = tt_3.b and tt_3.b = tt_4.b and tt_4.b = 100
master-bin.000001 # Query # # use `test`; INSERT INTO tt_1 VALUES ("new text 3800", 3800, '')
master-bin.000001 # Query # # ROLLBACK
master-bin.000001 # Query # # BEGIN
master-bin.000001 # Query # # use `test`; UPDATE tt_3, tt_4, nt_3, nt_4 SET tt_3.a= "new text 10", tt_4.a= "new text 10", nt_3.a= "new text 10", nt_4.a = "new text 10" where nt_3.b = nt_4.b and nt_4.b = tt_3.b and tt_3.b = tt_4.b and tt_4.b = 100
master-bin.000001 # Query # # use `test`; INSERT INTO tt_1 VALUES ("new text 3900", 3900, '')
master-bin.000001 # Query # # ROLLBACK
master-bin.000001 # Query # # BEGIN
master-bin.000001 # Query # # use `test`; UPDATE tt_3, nt_3, nt_4, tt_4 SET tt_3.a= "new text 11", nt_3.a= "new text 11", nt_4.a= "new text 11", tt_4.a = "new text 11" where nt_3.b = nt_4.b and nt_4.b = tt_3.b and tt_3.b = tt_4.b and tt_4.b = 100
master-bin.000001 # Query # # use `test`; INSERT INTO tt_1 VALUES ("new text 4000", 4000, '')
master-bin.000001 # Query # # ROLLBACK
master-bin.000001 # Query # # BEGIN
master-bin.000001 # Query # # use `test`; UPDATE tt_3, nt_3, nt_4, tt_4 SET tt_3.a= "new text 12", nt_3.a= "new text 12", nt_4.a= "new text 12", tt_4.a = "new text 12" where nt_3.b = nt_4.b and nt_4.b = tt_3.b and tt_3.b = tt_4.b and tt_4.b = 100
master-bin.000001 # Query # # use `test`; INSERT INTO tt_1 VALUES ("new text 4100", 4100, '')
master-bin.000001 # Query # # ROLLBACK
#
#13.e) "B M T R" with error in M generates in the binlog the "B M T R" entries.
#
BEGIN;
INSERT INTO nt_3 VALUES ("new text -30", -30, '');
INSERT INTO tt_3 VALUES ("new text -29", -29, ''), ("new text -30", -30, '');
ERROR 23000: Duplicate entry '-30' for key 'PRIMARY'
INSERT INTO tt_1 VALUES ("new text -30", -30, '');
ROLLBACK;
Warnings:
Warning 1196 Some non-transactional changed tables couldn't be rolled back
BEGIN;
INSERT INTO tt_4 VALUES ("new text -30", -30, '');
INSERT INTO nt_4 VALUES ("new text -29", -29, ''), ("new text -30", -30, '');
ERROR 23000: Duplicate entry '-30' for key 'PRIMARY'
INSERT INTO tt_1 VALUES ("new text -31", -31, '');
ROLLBACK;
Warnings:
Warning 1196 Some non-transactional changed tables couldn't be rolled back
show binlog events from <binlog_start>;
Log_name Pos Event_type Server_id End_log_pos Info
master-bin.000001 # Query # # use `test`; INSERT INTO nt_3 VALUES ("new text -30", -30, '')
master-bin.000001 # Query # # BEGIN
master-bin.000001 # Query # # use `test`; INSERT INTO tt_3 VALUES ("new text -29", -29, ''), ("new text -30", -30, '')
master-bin.000001 # Query # # use `test`; INSERT INTO tt_1 VALUES ("new text -30", -30, '')
master-bin.000001 # Query # # ROLLBACK
master-bin.000001 # Query # # BEGIN
master-bin.000001 # Query # # use `test`; INSERT INTO tt_4 VALUES ("new text -30", -30, '')
master-bin.000001 # Query # # use `test`; INSERT INTO nt_4 VALUES ("new text -29", -29, ''), ("new text -30", -30, '')
master-bin.000001 # Query # # use `test`; INSERT INTO tt_1 VALUES ("new text -31", -31, '')
master-bin.000001 # Query # # ROLLBACK
###################################################################################
# CLEAN
###################################################################################
DROP TABLE tt_1;
DROP TABLE tt_2;
DROP TABLE tt_3;
DROP TABLE tt_4;
DROP TABLE nt_1;
DROP TABLE nt_2;
DROP TABLE nt_3;
DROP TABLE nt_4;
DROP PROCEDURE pc_i_tt_3;
DROP FUNCTION f1;
DROP FUNCTION f2;

View File

@ -125,14 +125,13 @@ while ($type)
connection master;
sync_slave_with_master;
# Re-enable this after fixing BUG#46130
#connection master;
#let $diff_statement= SELECT * FROM t order by i;
#source include/diff_master_slave.inc;
connection master;
let $diff_statement= SELECT * FROM t order by i;
source include/diff_master_slave.inc;
#connection master;
#let $diff_statement= SELECT * FROM n order by d, f;
#source include/diff_master_slave.inc;
connection master;
let $diff_statement= SELECT * FROM n order by d, f;
source include/diff_master_slave.inc;
--echo ########################################################################
--echo # Cleanup

View File

@ -0,0 +1,70 @@
# BUG#45574:
# SP: CREATE DATABASE|TABLE IF NOT EXISTS not binlogged if routine exists.
#
# There is an inconsistency with DROP DATABASE|TABLE|EVENT IF EXISTS and
# CREATE DATABASE|TABLE|EVENT IF NOT EXISTS. DROP IF EXISTS statements are
# binlogged even if either the DB, TABLE or EVENT does not exist. In
# contrast, Only the CREATE EVENT IF NOT EXISTS is binlogged when the EVENT
# exists.
#
# This problem caused some of the tests to fail randomly on PB or PB2.
#
# Description:
# Fixed this bug by adding calls to write_bin_log in:
# mysql_create_db
# mysql_create_table_no_lock
# mysql_create_like_table
# create_table_from_items
#
# Test is implemented as follows:
# i) test each "CREATE IF NOT EXISTS" (DDL), found in MySQL 5.1 manual
# exclude CREATE TEMPORARY TABLE, on existent objects;
#
# Note:
# rpl_create_tmp_table_if_not_exists.test tests CREATE TEMPORARY TABLE cases.
#
# References:
# http://dev.mysql.com/doc/refman/5.1/en/sql-syntax-data-definition.html
#
source include/master-slave.inc;
disable_warnings;
DROP DATABASE IF EXISTS mysqltest;
CREATE DATABASE IF NOT EXISTS mysqltest;
USE mysqltest;
CREATE TABLE IF NOT EXISTS t(c1 int);
CREATE TABLE IF NOT EXISTS t1 LIKE t;
CREATE TABLE IF NOT EXISTS t2 SELECT * FROM t;
CREATE EVENT IF NOT EXISTS e
ON SCHEDULE AT CURRENT_TIMESTAMP + INTERVAL 1 HOUR
DO SELECT now();
sync_slave_with_master;
connection slave;
#DROP database from slave.
#The database and all tables can be recreated in slave
#if binlog of the second CREATE command is recorded and sent from master to slave.
DROP DATABASE mysqltest;
connection master;
CREATE DATABASE IF NOT EXISTS mysqltest;
USE mysqltest;
CREATE TABLE IF NOT EXISTS t(c1 int);
CREATE TABLE IF NOT EXISTS t1 LIKE t;
CREATE TABLE IF NOT EXISTS t2 SELECT * FROM t;
CREATE EVENT IF NOT EXISTS e
ON SCHEDULE AT CURRENT_TIMESTAMP + INTERVAL 1 HOUR
DO SELECT now();
sync_slave_with_master;
connection slave;
SHOW TABLES in mysqltest;
#Execution time changes in each run. So we disregard it by calling replace_column.
replace_column 6 #;
SHOW EVENTS in mysqltest;
connection master;
DROP DATABASE IF EXISTS mysqltest;
source include/master-slave-end.inc;

View File

@ -0,0 +1,41 @@
# BUG#45574:
# SP: CREATE DATABASE|TABLE IF NOT EXISTS not binlogged if routine exists.
#
# There is an inconsistency with DROP DATABASE|TABLE|EVENT IF EXISTS and
# CREATE DATABASE|TABLE|EVENT IF NOT EXISTS. DROP IF EXISTS statements are
# binlogged even if either the DB, TABLE or EVENT does not exist. In
# contrast, Only the CREATE EVENT IF NOT EXISTS is binlogged when the EVENT
# exists.
#
# This problem caused some of the tests to fail randomly on PB or PB2.
#
# Test is implemented as follows:
#
# i) test each "CREATE TEMPORARY TABLE IF EXISTS" (DDL), found in MySQL
# 5.1 manual, on existent objects;
# ii) show binlog events;
#
# Note:
# rpl_create_if_not_exists.test tests other cases.
#
# References:
# http://dev.mysql.com/doc/refman/5.1/en/sql-syntax-data-definition.html
#
source include/master-slave.inc;
#CREATE TEMPORARY TABLE statements are not binlogged in row mode,
#So it must be test by itself.
source include/have_binlog_format_mixed_or_statement.inc;
disable_warnings;
DROP DATABASE IF EXISTS mysqltest;
CREATE TEMPORARY TABLE IF NOT EXISTS tmp(c1 int);
CREATE TEMPORARY TABLE IF NOT EXISTS tmp(c1 int);
CREATE TEMPORARY TABLE IF NOT EXISTS tmp1 LIKE tmp;
CREATE TEMPORARY TABLE IF NOT EXISTS tmp1 LIKE tmp;
CREATE TEMPORARY TABLE IF NOT EXISTS tmp2 SELECT * FROM tmp;
CREATE TEMPORARY TABLE IF NOT EXISTS tmp2 SELECT * FROM tmp;
source include/show_binlog_events.inc;
source include/master-slave-end.inc;

View File

@ -12,21 +12,23 @@ source include/have_binlog_format_mixed_or_statement.inc;
create database if not exists mysqltest;
--enable_warnings
connect (con_temp,127.0.0.1,root,,test,$MASTER_MYPORT,);
connection con_temp;
use mysqltest;
create temporary table mysqltest.t1 (n int)ENGINE=MyISAM;
create temporary table mysqltest.t2 (n int)ENGINE=MyISAM;
disconnect con_temp;
--source include/wait_until_disconnected.inc
connection master;
disconnect master;
connection master1;
# Wait until drop of temp tables appears in binlog
let $wait_binlog_event= DROP;
source include/wait_for_binlog_event.inc;
sync_slave_with_master;
connection slave;
show status like 'Slave_open_temp_tables';
# Cleanup
connection default;
connection master;
drop database mysqltest;
sync_slave_with_master;

View File

@ -46,12 +46,62 @@ connection master;
DROP EVENT event2;
sync_slave_with_master;
#
# BUG#44331
# This test verifies if the definer is consistent between master and slave,
# when the event is created without the DEFINER clause set explicitly or the
# DEFINER is set to CURRENT_USER
#
CREATE TABLE test.t1(details CHAR(30));
# Doing cleanup of the table referred to in the event to guarantee
# that there is no bad timing cauing it to try to access the table.
CREATE EVENT /*!50000 event44331_1 */
ON SCHEDULE AT CURRENT_TIMESTAMP
ON COMPLETION PRESERVE DISABLE
DO INSERT INTO test.t1 VALUES('event event44331_1 fired - no definer');
CREATE DEFINER=CURRENT_USER /*!50000 EVENT event44331_2 */
ON SCHEDULE AT CURRENT_TIMESTAMP
ON COMPLETION PRESERVE DISABLE
DO INSERT INTO test.t1 VALUES('event event44331_2 fired - DEFINER=CURRENT_USER');
CREATE DEFINER=CURRENT_USER() EVENT event44331_3
ON SCHEDULE AT CURRENT_TIMESTAMP
ON COMPLETION PRESERVE DISABLE
DO INSERT INTO test.t1 VALUES('event event44331_3 fired - DEFINER=CURRENT_USER() function');
CREATE /*!50000 DEFINER='user44331' */ EVENT event44331_4
ON SCHEDULE AT CURRENT_TIMESTAMP
ON COMPLETION PRESERVE DISABLE
DO INSERT INTO test.t1 VALUES('event event44331_4 fired - DEFINER=user1');
--echo #on master
select EVENT_SCHEMA, EVENT_NAME, DEFINER from information_schema.events
where EVENT_NAME='event44331_1';
select EVENT_SCHEMA, EVENT_NAME, DEFINER from information_schema.events
where EVENT_NAME='event44331_2';
select EVENT_SCHEMA, EVENT_NAME, DEFINER from information_schema.events
where EVENT_NAME='event44331_3';
select EVENT_SCHEMA, EVENT_NAME, DEFINER from information_schema.events
where EVENT_NAME='event44331_4';
sync_slave_with_master;
connection slave;
--echo #on slave
select EVENT_SCHEMA, EVENT_NAME, DEFINER from information_schema.events
where EVENT_NAME='event44331_1';
select EVENT_SCHEMA, EVENT_NAME, DEFINER from information_schema.events
where EVENT_NAME='event44331_2';
select EVENT_SCHEMA, EVENT_NAME, DEFINER from information_schema.events
where EVENT_NAME='event44331_3';
select EVENT_SCHEMA, EVENT_NAME, DEFINER from information_schema.events
where EVENT_NAME='event44331_4';
connection master;
SET @@global.event_scheduler= @old_event_scheduler;
DROP TABLE t28953;
DROP TABLE t1;
DROP EVENT event44331_1;
DROP EVENT event44331_2;
DROP EVENT event44331_3;
DROP EVENT event44331_4;
sync_slave_with_master;

View File

@ -31,3 +31,20 @@ select hex(a) from t1;
connection master;
drop table t1;
sync_slave_with_master;
#
# Bug#45516
# When slave SQL thread executing LOAD DATA command, the
# thd->variables.collation_database was not set properly to the default
# database charset
#
echo -------------test bug#45516------------------;
# LOAD DATA INFILE
let $LOAD_LOCAL=1;
source include/rpl_loaddata_charset.inc;
# LOAD DATA LOCAL INFILE
let $LOAD_LOCAL=0;
source include/rpl_loaddata_charset.inc;

View File

@ -1 +1 @@
"--replicate-rewrite-db=test->rewrite" "--replicate-rewrite-db=mysqltest1->test"
"--replicate-rewrite-db=test->rewrite" "--replicate-rewrite-db=mysqltest1->test" "--replicate-rewrite-db=database_master_temp_01->database_slave_temp_01" "--replicate-rewrite-db=database_master_temp_02->database_slave_temp_02" "--replicate-rewrite-db=database_master_temp_03->database_slave_temp_03"

View File

@ -76,9 +76,164 @@ connection slave;
# The empty line last comes from the end line field in the file
select * from rewrite.t1;
set sql_log_bin= 0;
drop database rewrite;
set sql_log_bin= 1;
connection master;
set sql_log_bin= 0;
drop table t1;
set sql_log_bin= 1;
# End of 4.1 tests
--echo
--echo ****
--echo **** Bug #46861 Auto-closing of temporary tables broken by replicate-rewrite-db
--echo ****
--echo
--echo ****
--echo **** Preparing the environment
--echo ****
connection master;
connect (con_temp_03,127.0.0.1,root,,test,$MASTER_MYPORT,);
connect (con_temp_02,127.0.0.1,root,,test,$MASTER_MYPORT,);
connect (con_temp_01,127.0.0.1,root,,test,$MASTER_MYPORT,);
connection master;
SET sql_log_bin= 0;
CREATE DATABASE database_master_temp_01;
CREATE DATABASE database_master_temp_02;
CREATE DATABASE database_master_temp_03;
SET sql_log_bin= 1;
connection slave;
SET sql_log_bin= 0;
CREATE DATABASE database_slave_temp_01;
CREATE DATABASE database_slave_temp_02;
CREATE DATABASE database_slave_temp_03;
SET sql_log_bin= 1;
--echo
--echo ****
--echo **** Creating temporary tables on different databases with different connections
--echo ****
--echo **** con_temp_01 --> creates
--echo **** t_01_01_temp on database_master_temp_01
--echo ****
--echo **** con_temp_02 --> creates
--echo **** t_01_01_temp on database_master_temp_01
--echo **** t_02_01_temp, t_02_02_temp on database_master_temp_02
--echo ****
--echo **** con_temp_02 --> creates
--echo **** t_01_01_temp on database_master_temp_01
--echo **** t_02_01_temp, t_02_02_temp on database_master_temp_02
--echo **** t_03_01_temp, t_03_02_temp, t_03_03_temp on database_master_temp_03
--echo ****
--echo
--echo con_temp_01
--echo
connection con_temp_01;
USE database_master_temp_01;
CREATE TEMPORARY TABLE t_01_01_temp(a int);
INSERT INTO t_01_01_temp VALUES(1);
--echo
--echo con_temp_02
--echo
connection con_temp_02;
USE database_master_temp_01;
CREATE TEMPORARY TABLE t_01_01_temp(a int);
INSERT INTO t_01_01_temp VALUES(1);
USE database_master_temp_02;
CREATE TEMPORARY TABLE t_02_01_temp(a int);
INSERT INTO t_02_01_temp VALUES(1);
CREATE TEMPORARY TABLE t_02_02_temp(a int);
INSERT INTO t_02_02_temp VALUES(1);
--echo
--echo con_temp_03
--echo
connection con_temp_03;
USE database_master_temp_01;
CREATE TEMPORARY TABLE t_01_01_temp(a int);
INSERT INTO t_01_01_temp VALUES(1);
USE database_master_temp_02;
CREATE TEMPORARY TABLE t_02_01_temp(a int);
INSERT INTO t_02_01_temp VALUES(1);
CREATE TEMPORARY TABLE t_02_02_temp(a int);
INSERT INTO t_02_02_temp VALUES(1);
USE database_master_temp_03;
CREATE TEMPORARY TABLE t_03_01_temp(a int);
INSERT INTO t_03_01_temp VALUES(1);
CREATE TEMPORARY TABLE t_03_02_temp(a int);
INSERT INTO t_03_02_temp VALUES(1);
CREATE TEMPORARY TABLE t_03_03_temp(a int);
INSERT INTO t_03_03_temp VALUES(1);
--echo
--echo **** Dropping the connections
--echo **** We want to SHOW BINLOG EVENTS, to know what was logged. But there is no
--echo **** guarantee that logging of the terminated con1 has been done yet.a To be
--echo **** sure that logging has been done, we use a user lock.
--echo
connection master;
sync_slave_with_master;
connection slave;
show status like 'Slave_open_temp_tables';
connection master;
let $binlog_start= query_get_value(SHOW MASTER STATUS, Position, 1);
connection con_temp_01;
select get_lock("con_01",10);
connection master;
disconnect con_temp_01;
select get_lock("con_01",10);
connection con_temp_02;
select get_lock("con_02",10);
connection master;
disconnect con_temp_02;
select get_lock("con_02",10);
connection con_temp_03;
select get_lock("con_03",10);
connection master;
disconnect con_temp_03;
select get_lock("con_03",10);
--echo
--echo **** Checking the binary log and temporary tables
--echo
connection master;
sync_slave_with_master;
connection slave;
show status like 'Slave_open_temp_tables';
connection master;
--source include/show_binlog_events.inc
--echo ****
--echo **** Cleaning up the test case
--echo ****
connection master;
SET sql_log_bin= 0;
DROP DATABASE database_master_temp_01;
DROP DATABASE database_master_temp_02;
DROP DATABASE database_master_temp_03;
SET sql_log_bin= 1;
connection slave;
SET sql_log_bin= 0;
DROP DATABASE database_slave_temp_01;
DROP DATABASE database_slave_temp_02;
DROP DATABASE database_slave_temp_03;
SET sql_log_bin= 1;
connection master;
sync_slave_with_master;
# end of 5.0 tests

View File

@ -0,0 +1,5 @@
--source include/have_binlog_format_statement.inc
--source include/master-slave.inc
--source include/have_innodb.inc
--source extra/rpl_tests/rpl_mixing_engines.test

View File

@ -0,0 +1,344 @@
################################################################################
# inc/vcol_blocked_sql_funcs_main.inc #
# #
# Purpose: #
# Tests around sql functions #
# #
# #
#------------------------------------------------------------------------------#
# Original Author: Andrey Zhakov #
# Original Date: 2008-08-31 #
# Change Author: Oleksandr Byelkin (Monty program Ab)
# Date: 2009-03-24
# Change: Syntax changed
################################################################################
#
# NOTE: All SQL functions should be rejected, otherwise BUG.
#
--echo # RAND()
-- error ER_VIRTUAL_COLUMN_FUNCTION_IS_NOT_ALLOWED
create table t1 (b double as (rand()));
--echo # LOAD_FILE()
-- error ER_VIRTUAL_COLUMN_FUNCTION_IS_NOT_ALLOWED
create table t1 (a varchar(64), b varchar(1024) as (load_file(a)));
--echo # CURDATE()
-- error ER_VIRTUAL_COLUMN_FUNCTION_IS_NOT_ALLOWED
create table t1 (a datetime as (curdate()));
--echo # CURRENT_DATE(), CURRENT_DATE
-- error ER_VIRTUAL_COLUMN_FUNCTION_IS_NOT_ALLOWED
create table t1 (a datetime as (current_date));
-- error ER_VIRTUAL_COLUMN_FUNCTION_IS_NOT_ALLOWED
create table t1 (a datetime as (current_date()));
--echo # CURRENT_TIME(), CURRENT_TIME
-- error ER_VIRTUAL_COLUMN_FUNCTION_IS_NOT_ALLOWED
create table t1 (a datetime as (current_time));
-- error ER_VIRTUAL_COLUMN_FUNCTION_IS_NOT_ALLOWED
create table t1 (a datetime as (current_time()));
--echo # CURRENT_TIMESTAMP(), CURRENT_TIMESTAMP
-- error ER_VIRTUAL_COLUMN_FUNCTION_IS_NOT_ALLOWED
create table t1 (a datetime as (current_timestamp()));
-- error ER_VIRTUAL_COLUMN_FUNCTION_IS_NOT_ALLOWED
create table t1 (a datetime as (current_timestamp));
--echo # CURTIME()
-- error ER_VIRTUAL_COLUMN_FUNCTION_IS_NOT_ALLOWED
create table t1 (a datetime as (curtime()));
--echo # LOCALTIME(), LOCALTIME
-- error ER_VIRTUAL_COLUMN_FUNCTION_IS_NOT_ALLOWED
create table t1 (a datetime, b varchar(10) as (localtime()));
-- error ER_VIRTUAL_COLUMN_FUNCTION_IS_NOT_ALLOWED
create table t1 (a datetime, b varchar(10) as (localtime));
--echo # LOCALTIMESTAMP, LOCALTIMESTAMP()(v4.0.6)
-- error ER_VIRTUAL_COLUMN_FUNCTION_IS_NOT_ALLOWED
create table t1 (a datetime, b varchar(10) as (localtimestamp()));
-- error ER_VIRTUAL_COLUMN_FUNCTION_IS_NOT_ALLOWED
create table t1 (a datetime, b varchar(10) as (localtimestamp));
--echo # NOW()
-- error ER_VIRTUAL_COLUMN_FUNCTION_IS_NOT_ALLOWED
create table t1 (a datetime, b varchar(10) as (now()));
--echo # SYSDATE()
-- error ER_VIRTUAL_COLUMN_FUNCTION_IS_NOT_ALLOWED
create table t1 (a int, b varchar(10) as (sysdate()));
--echo # UNIX_TIMESTAMP()
-- error ER_VIRTUAL_COLUMN_FUNCTION_IS_NOT_ALLOWED
create table t1 (a datetime, b datetime as (unix_timestamp()));
--echo # UTC_DATE()
-- error ER_VIRTUAL_COLUMN_FUNCTION_IS_NOT_ALLOWED
create table t1 (a datetime, b datetime as (utc_date()));
--echo # UTC_TIME()
-- error ER_VIRTUAL_COLUMN_FUNCTION_IS_NOT_ALLOWED
create table t1 (a datetime, b datetime as (utc_time()));
--echo # UTC_TIMESTAMP()
-- error ER_VIRTUAL_COLUMN_FUNCTION_IS_NOT_ALLOWED
create table t1 (a datetime, b datetime as (utc_timestamp()));
--echo # MATCH()
if (!$skip_full_text_checks)
{
-- error ER_VIRTUAL_COLUMN_FUNCTION_IS_NOT_ALLOWED
create table t1 (a varchar(32), b bool as (match a against ('sample text')));
}
--echo # BENCHMARK()
-- error ER_VIRTUAL_COLUMN_FUNCTION_IS_NOT_ALLOWED
create table t1 (a varchar(1024), b varchar(1024) as (benchmark(a,3)));
--echo # CONNECTION_ID()
-- error ER_VIRTUAL_COLUMN_FUNCTION_IS_NOT_ALLOWED
create table t1 (a int as (connection_id()));
--echo # CURRENT_USER(), CURRENT_USER
-- error ER_VIRTUAL_COLUMN_FUNCTION_IS_NOT_ALLOWED
create table t1 (a varchar(32) as (current_user()));
-- error ER_VIRTUAL_COLUMN_FUNCTION_IS_NOT_ALLOWED
create table t1 (a varchar(32) as (current_user));
--echo # DATABASE()
-- error ER_VIRTUAL_COLUMN_FUNCTION_IS_NOT_ALLOWED
create table t1 (a varchar(1024), b varchar(1024) as (database()));
--echo # FOUND_ROWS()
-- error ER_VIRTUAL_COLUMN_FUNCTION_IS_NOT_ALLOWED
create table t1 (a varchar(1024), b varchar(1024) as (found_rows()));
--echo # GET_LOCK()
-- error ER_VIRTUAL_COLUMN_FUNCTION_IS_NOT_ALLOWED
create table t1 (a varchar(1024), b varchar(1024) as (get_lock(a,10)));
--echo # IS_FREE_LOCK()
-- error ER_VIRTUAL_COLUMN_FUNCTION_IS_NOT_ALLOWED
create table t1 (a varchar(1024), b varchar(1024) as (is_free_lock(a)));
--echo # IS_USED_LOCK()
-- error ER_VIRTUAL_COLUMN_FUNCTION_IS_NOT_ALLOWED
create table t1 (a varchar(1024), b varchar(1024) as (is_used_lock(a)));
--echo # LAST_INSERT_ID()
-- error ER_VIRTUAL_COLUMN_FUNCTION_IS_NOT_ALLOWED
create table t1 (a int as (last_insert_id()));
--echo # MASTER_POS_WAIT()
-- error ER_VIRTUAL_COLUMN_FUNCTION_IS_NOT_ALLOWED
create table t1 (a varchar(32), b int as (master_pos_wait(a,0,2)));
--echo # NAME_CONST()
-- error ER_VIRTUAL_COLUMN_FUNCTION_IS_NOT_ALLOWED
create table t1 (a varchar(32) as (name_const('test',1)));
--echo # RELEASE_LOCK()
-- error ER_VIRTUAL_COLUMN_FUNCTION_IS_NOT_ALLOWED
create table t1 (a varchar(32), b int as (release_lock(a)));
--echo # ROW_COUNT()
-- error ER_VIRTUAL_COLUMN_FUNCTION_IS_NOT_ALLOWED
create table t1 (a int as (row_count()));
--echo # SCHEMA()
-- error ER_VIRTUAL_COLUMN_FUNCTION_IS_NOT_ALLOWED
create table t1 (a varchar(32) as (schema()));
--echo # SESSION_USER()
-- error ER_VIRTUAL_COLUMN_FUNCTION_IS_NOT_ALLOWED
create table t1 (a varchar(32) as (session_user()));
--echo # SLEEP()
-- error ER_VIRTUAL_COLUMN_FUNCTION_IS_NOT_ALLOWED
create table t1 (a int, b int as (sleep(a)));
--echo # SYSTEM_USER()
-- error ER_VIRTUAL_COLUMN_FUNCTION_IS_NOT_ALLOWED
create table t1 (a varchar(32) as (system_user()));
--echo # USER()
-- error ER_VIRTUAL_COLUMN_FUNCTION_IS_NOT_ALLOWED
create table t1 (a varchar(1024), b varchar(1024) as (user()));
--echo # UUID_SHORT()
-- error ER_VIRTUAL_COLUMN_FUNCTION_IS_NOT_ALLOWED
create table t1 (a varchar(1024) as (uuid_short()));
--echo # UUID()
-- error ER_VIRTUAL_COLUMN_FUNCTION_IS_NOT_ALLOWED
create table t1 (a varchar(1024) as (uuid()));
--echo # VALUES()
-- error ER_VIRTUAL_COLUMN_FUNCTION_IS_NOT_ALLOWED
create table t1 (a varchar(1024), b varchar(1024) as (values(a)));
--echo # VERSION()
-- error ER_VIRTUAL_COLUMN_FUNCTION_IS_NOT_ALLOWED
create table t1 (a varchar(1024), b varchar(1024) as (version()));
--echo # ENCRYPT()
-- error ER_VIRTUAL_COLUMN_FUNCTION_IS_NOT_ALLOWED
create table t1 (a varchar(1024), b varchar(1024) as (encrypt(a)));
--echo # Stored procedures
delimiter //;
create procedure p1()
begin
select current_user();
end //
create function f1()
returns int
begin
return 1;
end //
delimiter ;//
-- error ER_VIRTUAL_COLUMN_FUNCTION_IS_NOT_ALLOWED
create table t1 (a int as (p1()));
-- error ER_VIRTUAL_COLUMN_FUNCTION_IS_NOT_ALLOWED
create table t1 (a int as (f1()));
drop procedure p1;
drop function f1;
--echo # Unknown functions
-- error ER_VIRTUAL_COLUMN_FUNCTION_IS_NOT_ALLOWED
create table t1 (a int as (f1()));
--echo #
--echo # GROUP BY FUNCTIONS
--echo #
--echo # AVG()
-- error ER_VIRTUAL_COLUMN_FUNCTION_IS_NOT_ALLOWED
create table t1 (a int, b int as (avg(a)));
--echo # BIT_AND()
-- error ER_VIRTUAL_COLUMN_FUNCTION_IS_NOT_ALLOWED
create table t1 (a int, b int as (bit_and(a)));
--echo # BIT_OR()
-- error ER_VIRTUAL_COLUMN_FUNCTION_IS_NOT_ALLOWED
create table t1 (a int, b int as (bit_or(a)));
--echo # BIT_XOR()
-- error ER_VIRTUAL_COLUMN_FUNCTION_IS_NOT_ALLOWED
create table t1 (a int, b int as (bit_xor(a)));
--echo # COUNT(DISTINCT)
-- error ER_VIRTUAL_COLUMN_FUNCTION_IS_NOT_ALLOWED
create table t1 (a int, b int as (count(distinct a)));
--echo # COUNT()
-- error ER_VIRTUAL_COLUMN_FUNCTION_IS_NOT_ALLOWED
create table t1 (a int, b int as (count(a)));
--echo # GROUP_CONCAT()
-- error ER_VIRTUAL_COLUMN_FUNCTION_IS_NOT_ALLOWED
create table t1 (a varchar(32), b int as (group_concat(a,'')));
--echo # MAX()
-- error ER_VIRTUAL_COLUMN_FUNCTION_IS_NOT_ALLOWED
create table t1 (a int, b int as (max(a)));
--echo # MIN()
-- error ER_VIRTUAL_COLUMN_FUNCTION_IS_NOT_ALLOWED
create table t1 (a int, b int as (min(a)));
--echo # STD()
-- error ER_VIRTUAL_COLUMN_FUNCTION_IS_NOT_ALLOWED
create table t1 (a int, b int as (std(a)));
--echo # STDDEV_POP()
-- error ER_VIRTUAL_COLUMN_FUNCTION_IS_NOT_ALLOWED
create table t1 (a int, b int as (stddev_pop(a)));
--echo # STDDEV_SAMP()
-- error ER_VIRTUAL_COLUMN_FUNCTION_IS_NOT_ALLOWED
create table t1 (a int, b int as (stddev_samp(a)));
--echo # STDDEV()
-- error ER_VIRTUAL_COLUMN_FUNCTION_IS_NOT_ALLOWED
create table t1 (a int, b int as (stddev(a)));
--echo # SUM()
-- error ER_VIRTUAL_COLUMN_FUNCTION_IS_NOT_ALLOWED
create table t1 (a int, b int as (sum(a)));
--echo # VAR_POP()
-- error ER_VIRTUAL_COLUMN_FUNCTION_IS_NOT_ALLOWED
create table t1 (a int, b int as (var_pop(a)));
--echo # VAR_SAMP()
-- error ER_VIRTUAL_COLUMN_FUNCTION_IS_NOT_ALLOWED
create table t1 (a int, b int as (var_samp(a)));
--echo # VARIANCE()
-- error ER_VIRTUAL_COLUMN_FUNCTION_IS_NOT_ALLOWED
create table t1 (a int, b int as (variance(a)));
--echo #
--echo # XML FUNCTIONS
--echo #
--echo # ExtractValue()
-- error ER_VIRTUAL_COLUMN_FUNCTION_IS_NOT_ALLOWED
create table t1 (a varchar(1024), b varchar(1024) as (ExtractValue(a,'//b[$@j]')));
--echo # UpdateXML()
-- error ER_VIRTUAL_COLUMN_FUNCTION_IS_NOT_ALLOWED
create table t1 (a varchar(1024), b varchar(1024) as (UpdateXML(a,'/a','<e>fff</e>')));
--echo #
--echo # Sub-selects
--echo #
create table t1 (a int);
-- error ER_PARSE_ERROR
create table t2 (a int, b int as (select count(*) from t1));
drop table t1;
-- error ER_VIRTUAL_COLUMN_FUNCTION_IS_NOT_ALLOWED
create table t1 (a int, b int as ((select 1)));
-- error ER_VIRTUAL_COLUMN_FUNCTION_IS_NOT_ALLOWED
create table t1 (a int, b int as (a+(select 1)));
--echo #
--echo # SP functions
--echo #
--disable_warnings
drop function if exists sub1;
--enable_warnings
create function sub1(i int) returns int deterministic
return i+1;
select sub1(1);
-- error ER_VIRTUAL_COLUMN_FUNCTION_IS_NOT_ALLOWED
create table t1 (a int, b int as (a+sub3(1)));
drop function sub1;
--echo #
--echo # Long expression
let $tmp_long_string = `SELECT repeat('a',240)`;
eval create table t1 (a int, b varchar(300) as (concat(a,'$tmp_long_string')));
drop table t1;
let $tmp_long_string = `SELECT repeat('a',243)`;
--error ER_WRONG_STRING_LENGTH
eval create table t1 (a int, b varchar(300) as (concat(a,'$tmp_long_string')));
--echo #
--echo # Constant expression
--error ER_CONST_EXPR_IN_VCOL
create table t1 (a int as (PI()));

View File

@ -0,0 +1,25 @@
################################################################################
# inc/vcol_cleanup.inc #
# #
# Purpose: #
# Removal of the objects created by the t/<test_name>.test #
# scripts. #
# #
#------------------------------------------------------------------------------#
# Original Author: Andrey Zhakov #
# Original Date: 2008-08-31 #
# Change Author: #
# Change Date: #
# Change: #
################################################################################
--disable_warnings
--disable_query_log
DROP VIEW IF EXISTS v1,v2;
DROP TABLE IF EXISTS t1,t2,t3;
DROP PROCEDURE IF EXISTS p1;
DROP FUNCTION IF EXISTS f1;
DROP TRIGGER IF EXISTS trg1;
DROP TRIGGER IF EXISTS trg2;
--enable_query_log
--enable_warnings

View File

@ -0,0 +1,113 @@
################################################################################
# inc/vcol_column_def_options.inc #
# #
# Purpose: #
# Testing different optional parameters specified when defining #
# a virtual column. #
# #
# #
#------------------------------------------------------------------------------#
# Original Author: Andrey Zhakov #
# Original Date: 2008-09-02 #
# Change Author: Oleksandr Byelkin (Monty program Ab)
# Date: 2009-03-24
# Change: Syntax changed
################################################################################
--echo #
--echo # Section 1. Wrong column definition options
--echo # - NOT NULL
--echo # - NULL
--echo # - DEFAULT <value>
--echo # - AUTO_INCREMENT
--echo # - [PRIMARY] KEY
--echo # NOT NULL
--error ER_PARSE_ERROR
create table t1 (a int, b int as (a+1) not null);
create table t1 (a int);
--error ER_PARSE_ERROR
alter table t1 add column b int as (a+1) not null;
drop table t1;
--echo # NULL
--error ER_PARSE_ERROR
create table t1 (a int, b int as (a+1) null);
create table t1 (a int);
--error ER_PARSE_ERROR
alter table t1 add column b int as (a+1) null;
drop table t1;
--echo # DEFAULT
--error ER_PARSE_ERROR
create table t1 (a int, b int as (a+1) default 0);
create table t1 (a int);
--error ER_PARSE_ERROR
alter table t1 add column b int as (a+1) default 0;
drop table t1;
--echo # AUTO_INCREMENT
--error ER_PARSE_ERROR
create table t1 (a int, b int as (a+1) AUTO_INCREMENT);
create table t1 (a int);
--error ER_PARSE_ERROR
alter table t1 add column b int as (a+1) AUTO_INCREMENT;
drop table t1;
--echo # [PRIMARY] KEY
--error ER_PARSE_ERROR
create table t1 (a int, b int as (a+1) key);
--error ER_PARSE_ERROR
create table t1 (a int, b int as (a+1) primary key);
create table t1 (a int);
--error ER_PARSE_ERROR
alter table t1 add column b int as (a+1) key;
--error ER_PARSE_ERROR
alter table t1 add column b int as (a+1) primary key;
drop table t1;
--echo # Section 2. Other column definition options
--echo # - COMMENT
--echo # - REFERENCES (only syntax testing here)
--echo # - STORED (only systax testing here)
create table t1 (a int, b int as (a % 2) comment 'my comment');
show create table t1;
describe t1;
drop table t1;
create table t1 (a int, b int as (a % 2));
alter table t1 modify b int as (a % 2) comment 'my comment';
show create table t1;
describe t1;
insert into t1 (a) values (1);
select * from t1;
insert into t1 values (2,default);
select a,b from t1;
create table t2 like t1;
show create table t2;
describe t2;
insert into t2 (a) values (1);
select * from t2;
insert into t2 values (2,default);
select a,b from t2;
drop table t2;
drop table t1;
create table t1 (a int, b int as (a % 2) persistent);
show create table t1;
describe t1;
insert into t1 (a) values (1);
select * from t1;
insert into t1 values (2,default);
select a,b from t1;
drop table t1;
create table t2 (a int);
create table t1 (a int, b int as (a % 2) persistent references t2(a));
show create table t1;
drop table t1;
create table t1 (a int, b int as (a % 2));
--error ER_PARSE_ERROR
alter table t1 modify b int as (a % 2) persistent references t2(a);
show create table t1;
drop table t1;

View File

@ -0,0 +1,43 @@
################################################################################
# inc/vcol_dependencies_on_vcol.inc #
# #
# Purpose: #
# Testing scenarios when columns depend on virtual columns, i.e. such as #
# - a virtual column is based on a virtual column #
# - a "real" column on which a virtual one is renamed/dropped #
# - a virtual column involved in partitioning is renamed/dropped #
# #
#------------------------------------------------------------------------------#
# Original Author: Andrey Zhakov #
# Original Date: 2008-09-02 #
# Change Author: Oleksandr Byelkin (Monty program Ab)
# Date: 2009-03-24
# Change: Syntax changed
################################################################################
--echo # Can't define a virtual column on another virtual column
--error ER_VCOL_BASED_ON_VCOL
create table t1 (a int, b int as (a+1), c int as (b+1));
create table t1 (a int, b int as (a+1));
--error ER_VCOL_BASED_ON_VCOL
alter table t1 add column c int as (b+1);
drop table t1;
--echo # Can't rename or drop a column used in the function of a virtual column
create table t1 (a int, b int as (a+1));
--echo # On renaming/dropping a column on which a virtual field is
--echo # defined the following error is displayed:
--echo # "Unknown column 'a' in 'virtual column function'"
--error ER_BAD_FIELD_ERROR
alter table t1 drop column a;
--error ER_BAD_FIELD_ERROR
alter table t1 change a c int;
drop table t1;
--echo # Can't rename or drop a virtual column used by the paritition function
create table t1 (a int, b int as (a+1)) partition by hash(b);
--error ER_BAD_FIELD_ERROR
alter table t1 drop b;
--error ER_BAD_FIELD_ERROR
alter table t1 change b c int as (a+1);

View File

@ -0,0 +1,77 @@
################################################################################
# inc/vcol_handler.inc #
# #
# Purpose: #
# Testing HANDLER. #
# #
# #
# #
#------------------------------------------------------------------------------#
# Original Author: Andrey Zhakov #
# Original Date: 2008-09-04 #
# Change Author: Oleksandr Byelkin (Monty program Ab)
# Date: 2009-03-24
# Change: Syntax changed
################################################################################
create table t1 (a int,
b int as (-a),
c int as (-a) persistent,
d char(1),
index (a),
index (c));
insert into t1 (a,d) values (4,'a'), (2,'b'), (1,'c'), (3,'d');
select * from t1;
--echo # HANDLER tbl_name OPEN
handler t1 open;
--echo # HANDLER tbl_name READ non-vcol_index_name > (value1,value2,...)
handler t1 read a > (2);
--echo # HANDLER tbl_name READ non-vcol_index_name > (value1,value2,...) WHERE non-vcol_field=expr
handler t1 read a > (2) where d='c';
--echo # HANDLER tbl_name READ vcol_index_name = (value1,value2,...)
handler t1 read c = (-2);
--echo # HANDLER tbl_name READ vcol_index_name = (value1,value2,...) WHERE non-vcol_field=expr
handler t1 read c = (-2) where d='c';
--echo # HANDLER tbl_name READ non-vcol_index_name > (value1,value2,...) WHERE vcol_field=expr
handler t1 read a > (2) where b=-3 && c=-3;
--echo # HANDLER tbl_name READ vcol_index_name <= (value1,value2,...)
handler t1 read c <= (-2);
--echo # HANDLER tbl_name READ vcol_index_name > (value1,value2,...) WHERE vcol_field=expr
handler t1 read c <= (-2) where b=-3;
--echo # HANDLER tbl_name READ vcol_index_name FIRST
handler t1 read c first;
--echo # HANDLER tbl_name READ vcol_index_name NEXT
handler t1 read c next;
--echo # HANDLER tbl_name READ vcol_index_name PREV
handler t1 read c prev;
--echo # HANDLER tbl_name READ vcol_index_name LAST
handler t1 read c last;
--echo # HANDLER tbl_name READ FIRST where non-vcol=expr
handler t1 read FIRST where a >= 2;
--echo # HANDLER tbl_name READ FIRST where vcol=expr
handler t1 read FIRST where b >= -2;
--echo # HANDLER tbl_name READ NEXT where non-vcol=expr
handler t1 read NEXT where d='c';
--echo # HANDLER tbl_name READ NEXT where vcol=expr
handler t1 read NEXT where b<=-4;
--echo # HANDLER tbl_name CLOSE
handler t1 close;
drop table t1;

View File

@ -0,0 +1,17 @@
################################################################################
# inc/vcol_init_vars.pre #
# #
# Purpose: #
# Initialize variables used in t/<name> test cases. #
# #
# #
#------------------------------------------------------------------------------#
# Original Author: Andrey Zhakov #
# Original Date: 2008-08-31 #
# Change Author: #
# Change Date: #
# Change: #
################################################################################
let $skip_full_text_check = 0;
let $skip_spatial_index_check = 0;

View File

@ -0,0 +1,289 @@
################################################################################
# inc/vcol_ins_upd.inc #
# #
# Purpose: #
# Testing DDL operations such as INSERT, UPDATE, REPLACE and DELETE. #
# #
# #
# #
#------------------------------------------------------------------------------#
# Original Author: Andrey Zhakov #
# Original Date: 2008-09-04 #
# Change Author: Oleksandr Byelkin (Monty program Ab)
# Date: 2009-03-24
# Change: Syntax changed
################################################################################
let $create1 = create table t1 (a int,
b int as (-a),
c int as (-a) persistent);
let $create2 = create table t1 (a int unique,
b int as (-a),
c int as (-a) persistent);
let $create3 = create table t1 (a int,
b int as (-a),
c int as (-a) persistent unique);
let $create4 = create table t1 (a int,
b int as (-a),
c int as (-a) persistent unique,
d varchar(16));
eval $create1;
set sql_warnings = 1;
--echo #
--echo # *** INSERT ***
--echo #
--echo # INSERT INTO tbl_name VALUES... DEFAULT is specified against vcols
insert into t1 values (1,default,default);
select * from t1;
delete from t1;
select * from t1;
--echo # INSERT INTO tbl_name VALUES... NULL is specified against vcols
insert into t1 values (1,null,null);
select * from t1;
delete from t1;
select * from t1;
--echo # INSERT INTO tbl_name VALUES... a non-NULL value is specified against vcols
insert into t1 values (1,2,3);
select * from t1;
delete from t1;
select * from t1;
--echo # INSERT INTO tbl_name (<non_vcol_list>) VALUES...
insert into t1 (a) values (1), (2);
select * from t1;
delete from t1;
select * from t1;
--echo # INSERT INTO tbl_name (<normal+vcols>) VALUES... DEFAULT is specified
--echo # against vcols
insert into t1 (a,b) values (1,default), (2,default);
select * from t1;
delete from t1;
select * from t1;
--echo # INSERT INTO tbl_name (<normal+vcols>) VALUES... NULL is specified against vcols
insert into t1 (a,b) values (1,null), (2,null);
select * from t1;
delete from t1;
select * from t1;
--echo # INSERT INTO tbl_name (<normal+vcols>) VALUES... a non-NULL value is specified
--echo # against vcols
insert into t1 (a,b) values (1,3), (2,4);
select * from t1;
delete from t1;
select * from t1;
drop table t1;
--echo # Table with UNIQUE non-vcol field. INSERT INTO tbl_name VALUES... ON DUPLICATE
--echo # KEY UPDATE <non_vcol>=expr, <vcol>=expr
eval $create2;
insert into t1 values (1,default,default);
insert into t1 values (1,default,default)
on duplicate key update a=2, b=default;
select a,b,c from t1;
delete from t1 where b in (1,2);
select * from t1;
drop table t1;
--echo # Table with UNIQUE vcol field. INSERT INTO tbl_name VALUES... ON DUPLICATE
--echo # KEY UPDATE <non_vcol>=expr, <vcol>=expr
eval $create3;
insert into t1 values (1,default,default);
insert into t1 values (1,default,default)
on duplicate key update a=2, b=default;
select a,b,c from t1;
--echo # CREATE new_table ... LIKE old_table
--echo # INSERT INTO new_table SELECT * from old_table
create table t2 like t1;
insert into t2 select * from t1;
select * from t1;
drop table t2;
--echo # CREATE new_table ... LIKE old_table INSERT INTO new_table (<non-vcols>, <vcols>)
--echo # SELECT <non-vcols>, <vcols> from old_table
insert into t1 values (1,default,default);
select * from t1;
create table t2 like t1;
insert into t2 (a,b) select a,b from t1;
select * from t2;
drop table t2;
drop table t1;
--echo #
--echo # *** UPDATE ***
--echo #
--echo # UPDATE tbl_name SET non-vcol=expr WHERE non-vcol=expr
eval $create1;
insert into t1 (a) values (1), (2);
select * from t1;
update t1 set a=3 where a=2;
select * from t1;
delete from t1;
select * from t1;
--echo # UPDATE tbl_name SET vcol=expr WHERE non-vcol=expr
insert into t1 (a) values (1), (2);
select * from t1;
update t1 set c=3 where a=2;
select * from t1;
delete from t1;
select * from t1;
--echo # UPDATE tbl_name SET non-vcol=expr WHERE vcol=expr
insert into t1 (a) values (1), (2);
select * from t1;
update t1 set a=3 where b=-2;
select * from t1;
delete from t1;
select * from t1;
--echo # UPDATE tbl_name SET vcol=expr WHERE vcol=expr
insert into t1 (a) values (1), (2);
select * from t1;
update t1 set c=3 where b=-2;
select * from t1;
delete from t1;
select * from t1;
drop table t1;
--echo # INDEX created on vcol
--echo # UPDATE tbl_name SET non-vcol=expr WHERE vcol=const
eval $create3;
insert into t1 (a) values (1), (2);
select * from t1;
update t1 set a=3 where c=-2;
select * from t1;
delete from t1;
select * from t1;
--echo # INDEX created on vcol
--echo # UPDATE tbl_name SET non-vcol=expr WHERE vcol=between const1 and const2
insert into t1 (a) values (1), (2);
select * from t1;
update t1 set a=3 where c between -3 and -2;
select * from t1;
delete from t1;
select * from t1;
--echo # No INDEX created on vcol
--echo # UPDATE tbl_name SET non-vcol=expr WHERE vcol=between const1 and const2
insert into t1 (a) values (1), (2);
select * from t1;
update t1 set a=3 where b between -3 and -2;
select * from t1;
delete from t1;
select * from t1;
--echo # INDEX created on vcol
--echo # UPDATE tbl_name SET non-vcol=expr
--echo # WHERE vcol=between const1 and const2 ORDER BY vcol
insert into t1 (a) values (1), (2), (3), (4), (5);
select * from t1;
update t1 set a=6 where c between -1 and 0
order by c;
select * from t1;
delete from t1 where c between -6 and 0;
select * from t1;
--echo # INDEX created on vcol
--echo # UPDATE tbl_name SET non-vcol=expr
--echo # WHERE vcol=between const1 and const2 ORDER BY vcol LIMIT 2
insert into t1 (a) values (1), (2), (3), (4), (5);
select * from t1;
update t1 set a=6 where c between -1 and 0
order by c limit 2;
select * from t1;
delete from t1 where c between -2 and 0 order by c;
select * from t1;
delete from t1;
--echo # INDEX created on vcol
--echo # UPDATE tbl_name SET non-vcol=expr
--echo # WHERE indexed vcol=between const1 and const2 and non-indexed vcol=const3
insert into t1 (a) values (1), (2), (3), (4), (5);
select * from t1;
update t1 set a=6 where (c between -2 and 0) and (b=-1);
select * from t1;
delete from t1;
--echo # INDEX created on vcol
--echo # UPDATE tbl_name SET non-vcol=expr
--echo # WHERE indexed vcol=between const1 and const2 and non-indexed vcol=const3
--echo # ORDER BY indexed vcol
insert into t1 (a) values (1), (2), (3), (4), (5);
select * from t1;
update t1 set a=6 where (c between -2 and 0) and (b=-1) order by c;
select * from t1;
delete from t1;
drop table t1;
let $innodb_engine = `SELECT @@session.storage_engine='innodb'`;
if ($innodb_engine)
{
--echo #
--echo # Verify ON UPDATE/DELETE actions of FOREIGN KEYs
create table t2 (a int primary key, name varchar(10));
create table t1 (a int primary key, b int as (a % 10) persistent);
insert into t2 values (1, 'value1'), (2,'value2'), (3,'value3');
insert into t1 (a) values (1),(2),(3);
select * from t1;
select * from t2;
select t1.a, t1.b, t2.name from t1,t2 where t1.b=t2.a;
--echo # - ON UPDATE RESTRICT
alter table t1 add foreign key (b) references t2(a) on update restrict;
--error ER_NO_REFERENCED_ROW_2
insert into t1 (a) values (4);
--error ER_ROW_IS_REFERENCED_2
update t2 set a=4 where a=3;
select t1.a, t1.b, t2.name from t1,t2 where t1.b=t2.a;
alter table t1 drop foreign key t1_ibfk_1;
--echo # - ON DELETE RESTRICT
alter table t1 add foreign key (b) references t2(a) on delete restrict;
--error ER_ROW_IS_REFERENCED_2
delete from t2 where a=3;
select t1.a, t1.b, t2.name from t1,t2 where t1.b=t2.a;
select t1.a, t1.b, t2.name from t1 left outer join t2 on (t1.b=t2.a);
alter table t1 drop foreign key t1_ibfk_1;
--echo # - ON DELETE CASCADE
alter table t1 add foreign key (b) references t2(a) on delete cascade;
delete from t2 where a=3;
select t1.a, t1.b, t2.name from t1,t2 where t1.b=t2.a;
select t1.a, t1.b, t2.name from t1 left outer join t2 on (t1.b=t2.a);
alter table t1 drop foreign key t1_ibfk_1;
drop table t1;
drop table t2;
}
--echo #
--echo # *** REPLACE ***
--echo #
--echo # UNIQUE INDEX on vcol
--echo # REPLACE tbl_name (non-vcols) VALUES (non-vcols);
eval $create4;
insert into t1 (a,d) values (1,'a'), (2,'b');
select * from t1;
replace t1 (a,d) values (1,'c');
select * from t1;
delete from t1;
select * from t1;
# *** DELETE
# All required tests for DELETE are performed as part of the above testing
# for INSERT, UPDATE and REPLACE.
set sql_warnings = 0;
drop table t1;

View File

@ -0,0 +1,163 @@
################################################################################
# inc/vcol_keys.inc #
# #
# Purpose: #
# Testing keys, indexes defined upon virtual columns. #
# #
# #
# #
#------------------------------------------------------------------------------#
# Original Author: Andrey Zhakov #
# Original Date: 2008-09-02 #
# Change Author: Oleksandr Byelkin (Monty program Ab)
# Date: 2009-03-24
# Change: Syntax changed
################################################################################
--echo # - UNIQUE KEY
--echo # - INDEX
--echo # - FULLTEXT INDEX
--echo # - SPATIAL INDEX (not supported)
--echo # - FOREIGN INDEX (partially supported)
--echo # - CHECK (allowed but not used)
--echo # UNIQUE
--error ER_KEY_BASED_ON_GENERATED_VIRTUAL_COLUMN
create table t1 (a int, b int as (a*2) unique);
create table t1 (a int, b int as (a*2) persistent unique);
show create table t1;
describe t1;
drop table t1;
--error ER_KEY_BASED_ON_GENERATED_VIRTUAL_COLUMN
create table t1 (a int, b int as (a*2), unique key (b));
create table t1 (a int, b int as (a*2) persistent, unique (b));
show create table t1;
describe t1;
drop table t1;
create table t1 (a int, b int as (a*2));
--error ER_KEY_BASED_ON_GENERATED_VIRTUAL_COLUMN
alter table t1 add unique key (b);
drop table t1;
create table t1 (a int, b int as (a*2) persistent);
alter table t1 add unique key (b);
drop table t1;
--echo # Testing data manipulation operations involving UNIQUE keys
--echo # on virtual columns can be found in:
--echo # - vcol_ins_upd.inc
--echo # - vcol_select.inc
--echo #
--echo # INDEX
--error ER_KEY_BASED_ON_GENERATED_VIRTUAL_COLUMN
create table t1 (a int, b int as (a*2), index (b));
--error ER_KEY_BASED_ON_GENERATED_VIRTUAL_COLUMN
create table t1 (a int, b int as (a*2), index (a,b));
create table t1 (a int, b int as (a*2) persistent, index (b));
show create table t1;
describe t1;
drop table t1;
create table t1 (a int, b int as (a*2) persistent, index (a,b));
show create table t1;
describe t1;
drop table t1;
create table t1 (a int, b int as (a*2));
--error ER_KEY_BASED_ON_GENERATED_VIRTUAL_COLUMN
alter table t1 add index (b);
--error ER_KEY_BASED_ON_GENERATED_VIRTUAL_COLUMN
alter table t1 add index (a,b);
drop table t1;
create table t1 (a int, b int as (a*2) persistent);
alter table t1 add index (b);
drop table t1;
create table t1 (a int, b int as (a*2) persistent);
alter table t1 add index (a,b);
create table t2 like t1;
drop table t2;
drop table t1;
--echo # Testing data manipulation operations involving INDEX
--echo # on virtual columns can be found in:
--echo # - vcol_select.inc
--echo #
--echo # TODO: FULLTEXT INDEX
--echo # SPATIAL INDEX
if (!$skip_spatial_index_check)
{
--echo # Error "All parts of a SPATIAL index must be NOT NULL"
--error ER_SPATIAL_CANT_HAVE_NULL
create table t1 (a int, b int as (a+1) persistent, spatial index (b));
create table t1 (a int, b int as (a+1) persistent);
--error ER_SPATIAL_CANT_HAVE_NULL
alter table t1 add spatial index (b);
drop table t1;
}
--echo # FOREIGN KEY
--echo # Rejected FK options.
--error ER_WRONG_FK_OPTION_FOR_VIRTUAL_COLUMN
create table t1 (a int, b int as (a+1) persistent,
foreign key (b) references t2(a) on update set null);
--error ER_WRONG_FK_OPTION_FOR_VIRTUAL_COLUMN
create table t1 (a int, b int as (a+1) persistent,
foreign key (b) references t2(a) on update cascade);
--error ER_WRONG_FK_OPTION_FOR_VIRTUAL_COLUMN
create table t1 (a int, b int as (a+1) persistent,
foreign key (b) references t2(a) on delete set null);
create table t1 (a int, b int as (a+1) persistent);
--error ER_WRONG_FK_OPTION_FOR_VIRTUAL_COLUMN
alter table t1 add foreign key (b) references t2(a) on update set null;
--error ER_WRONG_FK_OPTION_FOR_VIRTUAL_COLUMN
alter table t1 add foreign key (b) references t2(a) on update cascade;
--error ER_WRONG_FK_OPTION_FOR_VIRTUAL_COLUMN
alter table t1 add foreign key (b) references t2(a) on delete set null;
drop table t1;
--error ER_KEY_BASED_ON_GENERATED_VIRTUAL_COLUMN
create table t1 (a int, b int as (a+1),
foreign key (b) references t2(a));
create table t1 (a int, b int as (a+1));
--error ER_KEY_BASED_ON_GENERATED_VIRTUAL_COLUMN
alter table t1 add foreign key (b) references t2(a);
drop table t1;
--echo # Allowed FK options.
create table t2 (a int primary key, b char(5));
create table t1 (a int, b int as (a % 10) persistent,
foreign key (b) references t2(a) on update restrict);
drop table t1;
create table t1 (a int, b int as (a % 10) persistent,
foreign key (b) references t2(a) on update no action);
drop table t1;
create table t1 (a int, b int as (a % 10) persistent,
foreign key (b) references t2(a) on delete restrict);
drop table t1;
create table t1 (a int, b int as (a % 10) persistent,
foreign key (b) references t2(a) on delete cascade);
drop table t1;
create table t1 (a int, b int as (a % 10) persistent,
foreign key (b) references t2(a) on delete no action);
drop table t1;
--echo
--echo # Testing data manipulation operations involving FOREIGN KEY
--echo # on virtual columns can be found in:
--echo # - vcol_ins_upd.inc
--echo # - vcol_select.inc
--echo #
--echo # TODO: CHECK

View File

@ -0,0 +1,162 @@
################################################################################
# inc/vcol_non_stored_columns.inc #
# #
# Purpose: #
# Ensure that MySQL behaviour is consistent irrelevant of #
# - the place of a non-stored column among other columns, #
# - the total number of non-stored fields. #
# #
#------------------------------------------------------------------------------#
# Original Author: Andrey Zhakov #
# Original Date: 2008-09-04 #
# Change Author: Oleksandr Byelkin (Monty program Ab)
# Date: 2009-03-24
# Change: Syntax changed
################################################################################
--echo # Case 1. All non-stored columns.
--echo # This scenario is currently impossible due to the fact that virtual columns
--echo # with a constant expression are not allowed.
--echo # Case 2. CREATE
--echo # - Column1: "real"
--echo # - Column 2: virtual non-stored
create table t1 (a int, b int as (-a));
insert into t1 values (1,default);
select * from t1;
insert into t1 values (2,default);
select * from t1;
drop table t1;
--echo # Case 3. CREATE
--echo # - Column1: "real"
--echo # - Column 2: virtual stored
create table t1 (a int, b int as (-a) persistent);
insert into t1 values (1,default);
select * from t1;
insert into t1 values (2,default);
select * from t1;
drop table t1;
--echo # Case 4. CREATE
--echo # - Column1: virtual non-stored
--echo # - Column2: "real"
create table t1 (a int as (-b), b int);
insert into t1 values (default,1);
select * from t1;
insert into t1 values (default,2);
select * from t1;
drop table t1;
--echo # Case 5. CREATE
--echo # - Column1: virtual stored
--echo # - Column2: "real"
create table t1 (a int as (-b) persistent, b int);
insert into t1 values (default,1);
select * from t1;
insert into t1 values (default,2);
select * from t1;
drop table t1;
--echo # Case 6. CREATE
--echo # - Column1: "real"
--echo # - Column2: virtual non-stored
--echo # - Column3: virtual stored
create table t1 (a int, b int as (-a), c int as (-a) persistent);
insert into t1 values (1,default,default);
select * from t1;
insert into t1 values (2,default,default);
select * from t1;
drop table t1;
--echo # Case 7. ALTER. Modify virtual stored -> virtual non-stored
create table t1 (a int, b int as (a % 2) persistent);
--error ER_UNSUPPORTED_ACTION_ON_VIRTUAL_COLUMN
alter table t1 modify b int as (a % 2);
show create table t1;
drop table t1;
--echo # Case 8. ALTER. Modify virtual non-stored -> virtual stored
create table t1 (a int, b int as (a % 2));
--error ER_UNSUPPORTED_ACTION_ON_VIRTUAL_COLUMN
alter table t1 modify b int as (a % 2) persistent;
show create table t1;
drop table t1;
--echo # Case 9. CREATE LIKE
--echo # - Column1: "real"
--echo # - Column2: virtual non-stored
--echo # - Column3: virtual stored
create table t1 (a int, b int as (-a), c int as (-a) persistent);
create table t2 like t1;
insert into t2 values (1,default,default);
select * from t2;
insert into t2 values (2,default,default);
select * from t2;
drop table t2;
drop table t1;
--echo # Case 10. ALTER. Dropping a virtual non-stored column.
--echo # - Column1: virtual non-stored
--echo # - Column2: "real"
create table t1 (a int as (-b), b int, c varchar(5));
insert into t1 values (default,1,'v1');
insert into t1 values (default,2,'v2');
select * from t1;
alter table t1 drop column a;
select * from t1;
show create table t1;
drop table t1;
--echo # Case 11. ALTER. Dropping a virtual stored column.
--echo # - Column1: virtual stored
--echo # - Column2: "real"
create table t1 (a int as (-b) persistent, b int, c char(5));
insert into t1 values (default,1,'v1');
insert into t1 values (default,2,'v2');
select * from t1;
alter table t1 drop column a;
select * from t1;
show create table t1;
drop table t1;
--echo # Case 12. ALTER. Adding a new virtual non-stored column.
create table t1 (a int, b datetime);
insert into t1 values (1,'2008-09-04');
insert into t1 values (2,'2008-09-05');
select * from t1;
alter table t1 add column c int as (dayofyear(b)) after a;
select * from t1;
show create table t1;
drop table t1;
--echo # Case 13. ALTER. Adding a new virtual stored column.
create table t1 (a int, b datetime);
insert into t1 values (1,'2008-09-04');
insert into t1 values (2,'2008-09-05');
select * from t1;
alter table t1 add column c int as (dayofyear(b)) persistent after a;
select * from t1;
show create table t1;
drop table t1;
--echo # Case 14. ALTER. Changing the expression of a virtual stored column.
create table t1 (a int, b datetime, c int as (week(b)) persistent);
insert into t1 values (1,'2008-09-04',default);
insert into t1 values (2,'2008-09-05',default);
select * from t1;
alter table t1 change column c c int as (week(b,1)) persistent;
select * from t1;
show create table t1;
drop table t1;
--echo # Case 15. ALTER. Changing the expression of a virtual non-stored column.
create table t1 (a int, b datetime, c int as (week(b)));
insert into t1 values (1,'2008-09-04',default);
insert into t1 values (2,'2008-09-05',default);
select * from t1;
alter table t1 change column c c int as (week(b,1));
select * from t1;
show create table t1;
drop table t1;

View File

@ -0,0 +1,160 @@
################################################################################
# inc/vcol_partition.inc #
# #
# Purpose: #
# Testing partitioning tables with virtual columns. #
# #
# #
# #
#------------------------------------------------------------------------------#
# Original Author: Andrey Zhakov #
# Original Date: 2008-09-04 #
# Change Author: Oleksandr Byelkin (Monty program Ab)
# Date: 2009-03-24
# Change: Syntax changed
################################################################################
--source include/have_partition.inc
--disable_warnings
drop table if exists t1;
--enable_warnings
--echo # Case 1. Partitioning by RANGE based on a non-stored virtual column.
CREATE TABLE t1 (
a DATE NOT NULL,
b int as (year(a))
)
PARTITION BY RANGE( b ) (
PARTITION p0 VALUES LESS THAN (2006),
PARTITION p2 VALUES LESS THAN (2008)
);
insert into t1 values ('2006-01-01',default);
insert into t1 values ('2007-01-01',default);
insert into t1 values ('2005-01-01',default);
select * from t1;
# Specifically for MyISAM, check that data is written into correct
# $MYSQLTEST_VARDIR/mysqld.1/data/test/t1*p?.MYD files
let $myisam_engine = `select @@session.storage_engine='myisam'`;
if ($myisam_engine)
{
--echo # Check how data is physically partitioned.
--replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR
--exec du -b $MYSQLTEST_VARDIR/mysqld.1/data/test/t1*p?.MYD
}
--echo # Modify the expression of virtual column b
ALTER TABLE t1 modify b int as (year(a)-1);
select * from t1;
if ($myisam_engine)
{
--echo # Check how data is physically partitioned.
--replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR
--exec du -b $MYSQLTEST_VARDIR/mysqld.1/data/test/t1*p?.MYD
}
drop table t1;
--echo # Case 2. Partitioning by LIST based on a stored virtual column.
CREATE TABLE t1 (a int, b int as (a % 3 ) persistent)
PARTITION BY LIST (a+1)
(PARTITION p1 VALUES IN (1), PARTITION p2 VALUES IN (2));
insert into t1 values (1,default);
if ($myisam_engine)
{
--echo # Check how data is physically partitioned.
--replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR
--exec du -b $MYSQLTEST_VARDIR/mysqld.1/data/test/t1*p?.MYD
}
select * from t1;
#
# NOTE: The following tests are currently failing due to a
# [suspected] bug in the existing partition functionality.
# Here is what was observed when using mysqld compiled prior
# to adding the virtual column functionality.
# mysql> create table t1 (a int) partition by list (a)
# (partition p1 values in (1), partition p2 values in (2));
# Query OK, 0 rows affected (0.00 sec)
#
# mysql> insert into t1 values (1), (1), (2);
# Query OK, 3 rows affected (0.00 sec)
# Records: 3 Duplicates: 0 Warnings: 0
#
# mysql> select * from t1;
# +------+
# | a |
# +------+
# | 1 |
# | 1 |
# | 2 |
# +------+
# 3 rows in set (0.00 sec)
#
# mysql> alter table t1 reorganize partition p1 into
# (partition p1 values in (3));
# Query OK, 2 rows affected (3.90 sec)
# Records: 2 Duplicates: 2 Warnings: 0
#
# mysql> select * from t1;
# +------+
# | a |
# +------+
# | 2 | <- Two row have been lost!!!
# +------+
# 1 row in set (0.00 sec)
#
#alter table t1 change b b int as ((a % 3)+1) persistent;
#--error ER_NO_PARTITION_FOR_GIVEN_VALUE
#alter table t1 change b b int as (a % 2) persistent;
#if ($myisam_engine)
#{
# --echo # Check how data is physically partitioned.
# --replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR
# --exec du -b $MYSQLTEST_VARDIR/mysqld.1/data/test/t1*p?.MYD
#}
select * from t1;
drop table t1;
--echo # Case 3. Partitioning by HASH based on a non-stored virtual column.
CREATE TABLE t1 (
a DATE NOT NULL,
b int as (year(a))
)
PARTITION BY HASH( b % 3 ) PARTITIONS 3;
insert into t1 values ('2005-01-01',default);
insert into t1 values ('2006-01-01',default);
select * from t1;
if ($myisam_engine)
{
--echo # Check how data is physically partitioned.
--replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR
--exec du -b $MYSQLTEST_VARDIR/mysqld.1/data/test/t1*p?.MYD
}
--echo # Modify the expression of virtual column b
ALTER TABLE t1 modify b int as (year(a)-1);
select * from t1;
if ($myisam_engine)
{
--echo # Check how data is physically partitioned.
--replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR
--exec du -b $MYSQLTEST_VARDIR/mysqld.1/data/test/t1*p?.MYD
}
drop table t1;

View File

@ -0,0 +1,216 @@
################################################################################
# inc/vcol_select.inc #
# #
# Purpose: #
# Testing different SELECTs. #
# #
# #
#------------------------------------------------------------------------------#
# Original Author: Andrey Zhakov #
# Original Date: 2008-09-18 #
# Change Author: Oleksandr Byelkin (Monty program Ab)
# Date: 2009-03-24
# Change: Syntax changed
################################################################################
# Table t1 is used below to test:
# - Join type of ALL (sequential scan of the entire table)
# - Join type of Index
# - Join type of Range
# - Join type of Ref_or_null
create table t1 (a int,
b int as (-a),
c int as (-a) persistent,
index (c));
insert into t1 (a) values (2), (1), (1), (3), (NULL);
# Table t2 is used below to test:
# - Join type of system and const
create table t2 like t1;
insert into t2 (a) values (1);
# Table t3 is used below to test
# - Join type of Eq_ref with a unique virtual column
# - Join type of Const
create table t3 (a int primary key,
b int as (-a),
c int as (-a) persistent unique);
insert into t3 (a) values (2),(1),(3);
--echo # select_type=SIMPLE, type=system
let $s = select * from t2;
eval $s;
eval explain $s;
let $s = select * from t2 where c=-1;
eval $s;
eval explain $s;
--echo # select_type=SIMPLE, type=ALL
let $s = select * from t1 where b=-1;
eval $s;
eval explain $s;
--echo # select_type=SIMPLE, type=const
let $s = select * from t3 where a=1;
eval $s;
eval explain $s;
--echo # select_type=SIMPLE, type=range
let $s = select * from t3 where c>=-1;
eval $s;
eval explain $s;
--echo # select_type=SIMPLE, type=ref
let $s = select * from t1,t3 where t1.c=t3.c and t3.c=-1;
eval $s;
eval explain $s;
--echo # select_type=PRIMARY, type=index,ALL
let $s = select * from t1 where b in (select c from t3);
eval $s;
eval explain $s;
--echo # select_type=PRIMARY, type=range,ref
let $s = select * from t1 where c in (select c from t3 where c between -2 and -1);
eval $s;
eval explain $s;
--echo # select_type=UNION, type=system
--echo # select_type=UNION RESULT, type=<union1,2>
let $s = select * from t1 union select * from t2;
eval $s;
eval explain $s;
--echo # select_type=DERIVED, type=system
let $s = select * from (select a,b,c from t1) as t11;
eval $s;
eval explain $s;
--echo ###
--echo ### Using aggregate functions with/without DISTINCT
--echo ###
--echo # SELECT COUNT(*) FROM tbl_name
let $s = select count(*) from t1;
eval $s;
eval explain $s;
--echo # SELECT COUNT(DISTINCT <non-vcol>) FROM tbl_name
let $s = select count(distinct a) from t1;
eval $s;
eval explain $s;
--echo # SELECT COUNT(DISTINCT <non-stored vcol>) FROM tbl_name
let $s = select count(distinct b) from t1;
eval $s;
eval explain $s;
--echo # SELECT COUNT(DISTINCT <stored vcol>) FROM tbl_name
let $s = select count(distinct c) from t1;
eval $s;
eval explain $s;
--echo ###
--echo ### filesort & range-based utils
--echo ###
--echo # SELECT * FROM tbl_name WHERE <vcol expr>
let $s = select * from t3 where c >= -2;
eval $s;
eval explain $s;
--echo # SELECT * FROM tbl_name WHERE <non-vcol expr>
let $s = select * from t3 where a between 1 and 2;
eval $s;
eval explain $s;
--echo # SELECT * FROM tbl_name WHERE <non-indexed vcol expr>
let $s = select * from t3 where b between -2 and -1;
eval $s;
eval explain $s;
--echo # SELECT * FROM tbl_name WHERE <indexed vcol expr>
let $s = select * from t3 where c between -2 and -1;
eval $s;
eval explain $s;
#### Remove for MyISAM due to a bug
#### when all the three records are returned (a=1,2,3)
#### instead of just two (a=1,2).
#### This bug is presumably in base SQL routines as the same happens
#### with this table:
#### create table t4 (a int primary key, b int, c int unique);
let $myisam_engine = `SELECT @@session.storage_engine='myisam'`;
if (!$myisam_engine)
{
--echo # SELECT * FROM tbl_name WHERE <non-vcol expr> ORDER BY <non-indexed vcol>
let $s = select * from t3 where a between 1 and 2 order by b;
eval $s;
eval explain $s;
}
--echo # SELECT * FROM tbl_name WHERE <non-vcol expr> ORDER BY <indexed vcol>
let $s = select * from t3 where a between 1 and 2 order by c;
eval $s;
eval explain $s;
--echo # SELECT * FROM tbl_name WHERE <non-indexed vcol expr> ORDER BY <non-vcol>
let $s = select * from t3 where b between -2 and -1 order by a;
eval $s;
eval explain $s;
#### Remove for MyISAM due to a bug
#### when all the three records are returned (a=1,2,3)
#### instead of just two (a=1,2).
#### This bug is presumably in base SQL routines as the same happens
#### with this table:
#### create table t4 (a int primary key, b int, c int unique);
let $innodb_engine = `SELECT @@session.storage_engine='innodb'`;
if (!$innodb_engine)
{
--echo # SELECT * FROM tbl_name WHERE <indexed vcol expr> ORDER BY <non-vcol>
let $s = select * from t3 where c between -2 and -1 order by a;
eval $s;
eval explain $s;
}
--echo # SELECT * FROM tbl_name WHERE <non-indexed vcol expr> ORDER BY <non-indexed vcol>
let $s = select * from t3 where b between -2 and -1 order by b;
eval $s;
eval explain $s;
--echo # SELECT * FROM tbl_name WHERE <indexed vcol expr> ORDER BY <non-indexed vcol>
let $s = select * from t3 where c between -2 and -1 order by b;
eval $s;
eval explain $s;
--echo # SELECT * FROM tbl_name WHERE <non-indexed vcol expr> ORDER BY <indexed vcol>
let $s = select * from t3 where b between -2 and -1 order by c;
eval $s;
eval explain $s;
--echo # SELECT * FROM tbl_name WHERE <indexed vcol expr> ORDER BY <indexed vcol>
let $s = select * from t3 where c between -2 and -1 order by c;
eval $s;
eval explain $s;
--echo # SELECT sum(<non-indexed vcol>) FROM tbl_name GROUP BY <non-indexed vcol>
let $s = select sum(b) from t1 group by b;
eval $s;
eval explain $s;
--echo # SELECT sum(<indexed vcol>) FROM tbl_name GROUP BY <indexed vcol>
let $s = select sum(c) from t1 group by c;
eval $s;
eval explain $s;
--echo # SELECT sum(<non-indexed vcol>) FROM tbl_name GROUP BY <indexed vcol>
let $s = select sum(b) from t1 group by c;
eval $s;
eval explain $s;
--echo # SELECT sum(<indexed vcol>) FROM tbl_name GROUP BY <non-indexed vcol>
let $s = select sum(c) from t1 group by b;
eval $s;
eval explain $s;

View File

@ -0,0 +1,42 @@
################################################################################
# inc/vcol_supported_sql_funcs.inc #
# #
# Purpose: #
# Tests frame for allowed sql functions #
# #
# #
#------------------------------------------------------------------------------#
# Original Author: Andrey Zhakov #
# Original Date: 2008-08-31 #
# Change Author: #
# Change Date: #
# Change: #
################################################################################
--enable_warnings
set sql_warnings = 1;
eval create table t1 ($cols);
show create table t1;
if ($rows)
{
eval insert into t1 values ($values1);
dec $rows;
}
if ($rows)
{
eval insert into t1 values ($values2);
dec $rows;
}
if ($rows)
{
eval insert into t1 values ($values3);
dec $rows;
}
if ($rows)
{
eval insert into t1 values ($values4);
dec $rows;
}
select * from t1;
drop table t1;
set sql_warnings = 0;

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,110 @@
################################################################################
# inc/vcol_trigger_sp.inc #
# #
# Purpose: #
# Testing triggers, stored procedures and functions #
# defined on tables with virtual columns. #
# #
# #
# #
#------------------------------------------------------------------------------#
# Original Author: Andrey Zhakov #
# Original Date: 2008-09-04 #
# Change Author: Oleksandr Byelkin (Monty program Ab)
# Date: 2009-03-24
# Change: Syntax changed
################################################################################
create table t1 (a int,
b int as (a/10),
c int as (a/10) persistent);
create table t2 (a timestamp);
delimiter |;
create trigger trg1 before insert on t1 for each row
begin
if (new.b < 10) then
set new.a:= 100;
set new.b:= 9;
set new.c:= 9;
end if;
if (new.c > 50) then
set new.a:= 500;
end if;
end|
create trigger trg2 after insert on t1 for each row
begin
if (new.b >= 60) then
insert into t2 values (now());
end if;
end|
create function f1()
returns int
begin
declare sum1 int default '0';
declare cur1 cursor for select sum(b) from t1;
open cur1;
fetch cur1 into sum1;
close cur1;
return sum1;
end|
delimiter ;|
set sql_warnings = 1;
insert into t1 (a) values (200);
select * from t1;
select * from t2;
insert into t1 (a) values (10);
select * from t1;
select * from t2;
insert into t1 (a) values (600);
select * from t1;
--replace_column 1 <timestamp>
select * from t2;
select f1();
set sql_warnings = 0;
drop trigger trg1;
drop trigger trg2;
drop table t2;
delimiter |;
create procedure p1()
begin
declare i int default '0';
create table t2 like t1;
insert into t2 (a) values (100), (200);
begin
declare cur1 cursor for select sum(c) from t2;
open cur1;
fetch cur1 into i;
close cur1;
if (i=30) then
insert into t1 values (300,default,default);
end if;
end;
end|
delimiter ;|
delete from t1;
call p1();
select * from t2;
select * from t1;
drop table t1,t2;
drop procedure p1;

View File

@ -0,0 +1,21 @@
################################################################################
# inc/vcol_unsupported_storage_engines.inc #
# #
# Purpose: #
# Ensure that defining a virtual column for an unsupported table type #
# results in a graceful error. #
# #
#------------------------------------------------------------------------------#
# Original Author: Andrey Zhakov #
# Original Date: 2008-09-02 #
# Change Author: Oleksandr Byelkin (Monty program Ab)
# Date: 2009-03-24
# Change: Syntax changed
################################################################################
--error ER_UNSUPPORTED_ACTION_ON_VIRTUAL_COLUMN
create table t1 (a int, b int as (a+1));
create table t1 (a int);
--error ER_UNSUPPORTED_ACTION_ON_VIRTUAL_COLUMN
alter table t1 add column b int as (a+1);
drop table t1;

View File

@ -0,0 +1,201 @@
################################################################################
# inc/vcol_view.inc #
# #
# Purpose: #
# Testing views defined on tables with virtual columns. #
# #
# #
# #
#------------------------------------------------------------------------------#
# Original Author: Andrey Zhakov #
# Original Date: 2008-09-04 #
# Change Author: Oleksandr Byelkin (Monty program Ab)
# Date: 2009-03-24
# Change: Syntax changed
################################################################################
create table t1 (a int not null,
b int as (-a),
c int as (-a) persistent);
insert into t1 (a) values (1), (1), (2), (2), (3);
# simple view
create view v1 (d,e) as select abs(b), abs(c) from t1;
select d,e from v1;
select is_updatable from information_schema.views where table_name='v1';
# view with different algorithms (explain output differs)
explain extended select d,e from v1;
create algorithm=temptable view v2 (d,e) as select abs(b), abs(c) from t1;
show create view v2;
select d,e from v2;
explain extended select d,e from v2;
# VIEW on VIEW test
create view v3 (d,e) as select d*2, e*2 from v1;
select * from v3;
explain extended select * from v3;
drop view v1,v2,v3;
drop table t1;
#
# DISTINCT option for VIEW
#
create table t1 (a int not null,
b int as (-a),
c int as (-a) persistent);
insert into t1 (a) values (1), (2), (3), (1), (2), (3);
create view v1 as select distinct b from t1;
select * from v1;
explain select * from v1;
select * from t1;
drop view v1;
create view v1 as select distinct c from t1;
select * from v1;
explain select * from v1;
select * from t1;
drop view v1;
drop table t1;
#
# LIMIT clause test
#
create table t1 (a int not null,
b int as (-a),
c int as (-a) persistent);
insert into t1 (a) values (1), (2), (3), (4);
create view v1 as select b+1 from t1 order by 1 desc limit 2;
select * from v1;
explain select * from v1;
drop view v1;
create view v1 as select c+1 from t1 order by 1 desc limit 2;
select * from v1;
explain select * from v1;
drop view v1;
drop table t1;
#
# simple view + simple update, insert and delete
#
create table t1 (a int,
b int,
c int as (-a),
d int as (-a) persistent,
primary key(a));
insert into t1 (a,b) values (10,2), (20,3), (30,4), (40,5), (50,10);
create view v1 (a,e,f,g) as select a, b+1,c+1,d+1 from t1;
# updatable field of updateable view
update v1 set a=a+e;
select * from v1;
select * from t1;
delete from v1;
select * from v1;
select * from t1;
--error ER_NON_INSERTABLE_TABLE
insert into v1 (a,e) values (60,15);
drop table t1;
drop view v1;
#
# outer join based on VIEW with WHERE clause
#
create table t1 (a int,
b int as (-a),
c int as (-a) persistent,
primary key(a));
insert into t1 (a) values (1), (2), (3);
create view v1 (x,y,z) as select a,b,c from t1 where b < -1;
select t1.a, v1.x, v1.y, v1.z from t1 left join v1 on (t1.b= v1.y);
drop view v1;
create view v1 (x,y,z) as select a,b,c from t1 where c < -1;
select t1.a, v1.x, v1.y, v1.z from t1 left join v1 on (t1.c= v1.z);
drop view v1;
drop table t1;
#
# VIEW built over UNION
#
create table t1 (a1 int,
b1 int as (-a1),
c1 int as (-a1) persistent);
create table t2 (a2 int,
b2 int as (-a2),
c2 int as (-a2) persistent);
insert into t1 (a1) values (1), (2);
insert into t2 (a2) values (2), (3);
create view v1 as select * from t1,t2 union all select * from t1,t2;
select * from v1;
drop view v1;
drop table t1, t2;
#
# Showing VIEW with VIEWs in subquery
#
create table t1 (a int,
b int as (-a),
c int as (-a) persistent);
create table t2 like t1;
create view v1 as select a,b,c from t1;
create view v2 as select a,b,c from t2 where b in (select b from v1);
show create view v2;
drop view v2, v1;
drop table t1, t2;
#
# TODO: VIEW with full text
#
#CREATE TABLE t1 (c1 int not null auto_increment primary key, c2 varchar(20), fulltext(c2));
#insert into t1 (c2) VALUES ('real Beer'),('Water'),('Kossu'),('Coca-Cola'),('Vodka'),('Wine'),('almost real Beer');
#select * from t1 WHERE match (c2) against ('Beer');
#CREATE VIEW v1 AS SELECT * from t1 WHERE match (c2) against ('Beer');
#select * from v1;
#drop view v1;
#drop table t1;
#
# distinct in temporary table with a VIEW
#
create table t1 (a int,
b int as (-a),
c int as (-a) persistent);
insert into t1 (a) values (1),(1),(2),(2),(3),(3);
create view v1 as select b from t1;
select distinct b from v1;
select distinct b from v1 limit 2;
select distinct b from t1 limit 2;
prepare stmt1 from "select distinct b from v1 limit 2";
execute stmt1;
execute stmt1;
deallocate prepare stmt1;
drop view v1;
create view v1 as select c from t1;
select distinct c from v1;
select distinct c from v1 limit 2;
select distinct c from t1 limit 2;
prepare stmt1 from "select distinct c from v1 limit 2";
execute stmt1;
execute stmt1;
deallocate prepare stmt1;
drop view v1;
drop table t1;
#
# WITH CHECK OPTION insert/update test
#
create table t1 (a int,
b int as (-a),
c int as (-a) persistent);
create view v1 as select * from t1 where b > -2 && c >-2 with check option;
# simple insert
insert into v1 (a) values (1);
-- error 1369
insert into v1 (a) values (3);
# simple insert with ignore
insert ignore into v1 (a) values (2),(3),(0);
select * from t1;
drop view v1;
drop table t1;

View File

@ -0,0 +1,25 @@
SET @@session.storage_engine = 'InnoDB';
stop slave;
drop table if exists t1,t2,t3,t4,t5,t6,t7,t8,t9;
reset master;
reset slave;
drop table if exists t1,t2,t3,t4,t5,t6,t7,t8,t9;
start slave;
create table t1 (a int, b int as (a+1));
show create table t1;
Table Create Table
t1 CREATE TABLE `t1` (
`a` int(11) DEFAULT NULL,
`b` int(11) AS (a+1) VIRTUAL
) ENGINE=MyISAM DEFAULT CHARSET=latin1
insert into t1 values (1,default);
insert into t1 values (2,default);
select * from t1;
a b
1 2
2 3
select * from t1;
a b
1 2
2 3
drop table t1;

View File

@ -0,0 +1,7 @@
SET @@session.storage_engine = 'archive';
create table t1 (a int, b int as (a+1));
ERROR HY000: 'Specified storage engine' is not yet supported for computed columns.
create table t1 (a int);
alter table t1 add column b int as (a+1);
ERROR HY000: 'Specified storage engine' is not yet supported for computed columns.
drop table t1;

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