Commit fca24158 authored by Alexander Nozdrin's avatar Alexander Nozdrin

Auto-merge from mysql-next-mr.

parents c42767e5 f027e4e0
[MYSQL] [MYSQL]
post_commit_to = "commits@lists.mysql.com" post_commit_to = "commits@lists.mysql.com"
post_push_to = "commits@lists.mysql.com" post_push_to = "commits@lists.mysql.com"
tree_name = "mysql-5.5-next-mr-bugfixing" tree_name = "mysql-next-mr-bugfixing"
...@@ -3072,6 +3072,9 @@ libmysqld/rpl_handler.cc ...@@ -3072,6 +3072,9 @@ libmysqld/rpl_handler.cc
libmysqld/debug_sync.cc libmysqld/debug_sync.cc
libmysqld/rpl_handler.cc libmysqld/rpl_handler.cc
dbug/tests dbug/tests
libmysqld/mdl.cc
client/transaction.h
libmysqld/transaction.cc
libmysqld/sys_vars.cc libmysqld/sys_vars.cc
libmysqld/keycaches.cc libmysqld/keycaches.cc
client/dtoa.c client/dtoa.c
......
...@@ -107,8 +107,9 @@ sql_src=log_event.h mysql_priv.h rpl_constants.h \ ...@@ -107,8 +107,9 @@ sql_src=log_event.h mysql_priv.h rpl_constants.h \
rpl_tblmap.h rpl_tblmap.cc \ rpl_tblmap.h rpl_tblmap.cc \
log_event.cc my_decimal.h my_decimal.cc \ log_event.cc my_decimal.h my_decimal.cc \
log_event_old.h log_event_old.cc \ log_event_old.h log_event_old.cc \
rpl_record_old.h rpl_record_old.cc \
rpl_utility.h rpl_utility.cc \ rpl_utility.h rpl_utility.cc \
rpl_record_old.h rpl_record_old.cc transaction.h
strings_src=decimal.c dtoa.c strings_src=decimal.c dtoa.c
link_sources: link_sources:
......
This diff is collapsed.
...@@ -38,6 +38,23 @@ extern "C" { ...@@ -38,6 +38,23 @@ extern "C" {
#define my_wc_t ulong #define my_wc_t ulong
/*
On i386 we store Unicode->CS conversion tables for
some character sets using Big-endian order,
to copy two bytes at onces.
This gives some performance improvement.
*/
#ifdef __i386__
#define MB2(x) (((x) >> 8) + (((x) & 0xFF) << 8))
#define MY_PUT_MB2(s, code) { *((uint16*)(s))= (code); }
#else
#define MB2(x) (x)
#define MY_PUT_MB2(s, code) { (s)[0]= code >> 8; (s)[1]= code & 0xFF; }
#endif
typedef struct unicase_info_st typedef struct unicase_info_st
{ {
uint32 toupper; uint32 toupper;
......
...@@ -191,10 +191,11 @@ enum ha_extra_function { ...@@ -191,10 +191,11 @@ enum ha_extra_function {
/* Inform handler that we will do a rename */ /* Inform handler that we will do a rename */
HA_EXTRA_PREPARE_FOR_RENAME, HA_EXTRA_PREPARE_FOR_RENAME,
/* /*
Orders MERGE handler to attach or detach its child tables. Used at Special actions for MERGE tables.
begin and end of a statement.
*/ */
HA_EXTRA_ADD_CHILDREN_LIST,
HA_EXTRA_ATTACH_CHILDREN, HA_EXTRA_ATTACH_CHILDREN,
HA_EXTRA_IS_ATTACHED_CHILDREN,
HA_EXTRA_DETACH_CHILDREN HA_EXTRA_DETACH_CHILDREN
}; };
......
...@@ -1598,7 +1598,7 @@ inline void operator delete[](void*, void*) { /* Do nothing */ } ...@@ -1598,7 +1598,7 @@ inline void operator delete[](void*, void*) { /* Do nothing */ }
#if !defined(max) #if !defined(max)
#define max(a, b) ((a) > (b) ? (a) : (b)) #define max(a, b) ((a) > (b) ? (a) : (b))
#define min(a, b) ((a) < (b) ? (a) : (b)) #define min(a, b) ((a) < (b) ? (a) : (b))
#endif #endif
/* /*
Only Linux is known to need an explicit sync of the directory to make sure a Only Linux is known to need an explicit sync of the directory to make sure a
file creation/deletion/renaming in(from,to) this directory durable. file creation/deletion/renaming in(from,to) this directory durable.
...@@ -1611,6 +1611,25 @@ inline void operator delete[](void*, void*) { /* Do nothing */ } ...@@ -1611,6 +1611,25 @@ inline void operator delete[](void*, void*) { /* Do nothing */ }
#define bool In_C_you_should_use_my_bool_instead() #define bool In_C_you_should_use_my_bool_instead()
#endif #endif
/* Provide __func__ macro definition for platforms that miss it. */
#if __STDC_VERSION__ < 199901L
# if __GNUC__ >= 2
# define __func__ __FUNCTION__
# else
# define __func__ "<unknown>"
# endif
#elif defined(_MSC_VER)
# if _MSC_VER < 1300
# define __func__ "<unknown>"
# else
# define __func__ __FUNCTION__
# endif
#elif defined(__BORLANDC__)
# define __func__ __FUNC__
#else
# define __func__ "<unknown>"
#endif
#ifndef HAVE_RINT #ifndef HAVE_RINT
/** /**
All integers up to this number can be represented exactly as double precision All integers up to this number can be represented exactly as double precision
......
...@@ -102,6 +102,19 @@ struct timespec { ...@@ -102,6 +102,19 @@ struct timespec {
(ABSTIME).max_timeout_msec= (long)((NSEC)/1000000); \ (ABSTIME).max_timeout_msec= (long)((NSEC)/1000000); \
} }
/**
Compare two timespec structs.
@retval 1 If TS1 ends after TS2.
@retval 0 If TS1 is equal to TS2.
@retval -1 If TS1 ends before TS2.
*/
#define cmp_timespec(TS1, TS2) \
((TS1.tv.i64 > TS2.tv.i64) ? 1 : \
((TS1.tv.i64 < TS2.tv.i64) ? -1 : 0))
int win_pthread_mutex_trylock(pthread_mutex_t *mutex); int win_pthread_mutex_trylock(pthread_mutex_t *mutex);
int pthread_create(pthread_t *, const pthread_attr_t *, pthread_handler, void *); int pthread_create(pthread_t *, const pthread_attr_t *, pthread_handler, void *);
...@@ -412,6 +425,33 @@ int my_pthread_mutex_trylock(pthread_mutex_t *mutex); ...@@ -412,6 +425,33 @@ int my_pthread_mutex_trylock(pthread_mutex_t *mutex);
(ABSTIME).tv_nsec= (long) (now % ULL(10000000) * 100 + ((NSEC) % 100)); \ (ABSTIME).tv_nsec= (long) (now % ULL(10000000) * 100 + ((NSEC) % 100)); \
} }
#endif /* !set_timespec_nsec */ #endif /* !set_timespec_nsec */
#endif /* HAVE_TIMESPEC_TS_SEC */
/**
Compare two timespec structs.
@retval 1 If TS1 ends after TS2.
@retval 0 If TS1 is equal to TS2.
@retval -1 If TS1 ends before TS2.
*/
#ifdef HAVE_TIMESPEC_TS_SEC
#ifndef cmp_timespec
#define cmp_timespec(TS1, TS2) \
((TS1.ts_sec > TS2.ts_sec || \
(TS1.ts_sec == TS2.ts_sec && TS1.ts_nsec > TS2.ts_nsec)) ? 1 : \
((TS1.ts_sec < TS2.ts_sec || \
(TS1.ts_sec == TS2.ts_sec && TS1.ts_nsec < TS2.ts_nsec)) ? -1 : 0))
#endif /* !cmp_timespec */
#else
#ifndef cmp_timespec
#define cmp_timespec(TS1, TS2) \
((TS1.tv_sec > TS2.tv_sec || \
(TS1.tv_sec == TS2.tv_sec && TS1.tv_nsec > TS2.tv_nsec)) ? 1 : \
((TS1.tv_sec < TS2.tv_sec || \
(TS1.tv_sec == TS2.tv_sec && TS1.tv_nsec < TS2.tv_nsec)) ? -1 : 0))
#endif /* !cmp_timespec */
#endif /* HAVE_TIMESPEC_TS_SEC */ #endif /* HAVE_TIMESPEC_TS_SEC */
/* safe_mutex adds checking to mutex for easier debugging */ /* safe_mutex adds checking to mutex for easier debugging */
......
...@@ -235,6 +235,9 @@ extern void (*fatal_error_handler_hook)(uint my_err, const char *str, ...@@ -235,6 +235,9 @@ extern void (*fatal_error_handler_hook)(uint my_err, const char *str,
extern uint my_file_limit; extern uint my_file_limit;
extern ulong my_thread_stack_size; extern ulong my_thread_stack_size;
extern const char *(*proc_info_hook)(void *, const char *, const char *,
const char *, const unsigned int);
#ifdef HAVE_LARGE_PAGES #ifdef HAVE_LARGE_PAGES
extern my_bool my_use_large_pages; extern my_bool my_use_large_pages;
extern uint my_large_page_size; extern uint my_large_page_size;
......
...@@ -83,7 +83,6 @@ enum enum_thr_lock_result { THR_LOCK_SUCCESS= 0, THR_LOCK_ABORTED= 1, ...@@ -83,7 +83,6 @@ enum enum_thr_lock_result { THR_LOCK_SUCCESS= 0, THR_LOCK_ABORTED= 1,
extern ulong max_write_lock_count; extern ulong max_write_lock_count;
extern ulong table_lock_wait_timeout;
extern my_bool thr_lock_inited; extern my_bool thr_lock_inited;
extern enum thr_lock_type thr_upgraded_concurrent_insert_lock; extern enum thr_lock_type thr_upgraded_concurrent_insert_lock;
...@@ -156,19 +155,25 @@ void thr_lock_data_init(THR_LOCK *lock,THR_LOCK_DATA *data, ...@@ -156,19 +155,25 @@ void thr_lock_data_init(THR_LOCK *lock,THR_LOCK_DATA *data,
void *status_param); void *status_param);
enum enum_thr_lock_result thr_lock(THR_LOCK_DATA *data, enum enum_thr_lock_result thr_lock(THR_LOCK_DATA *data,
THR_LOCK_OWNER *owner, THR_LOCK_OWNER *owner,
enum thr_lock_type lock_type); enum thr_lock_type lock_type,
ulong lock_wait_timeout);
void thr_unlock(THR_LOCK_DATA *data); void thr_unlock(THR_LOCK_DATA *data);
enum enum_thr_lock_result thr_multi_lock(THR_LOCK_DATA **data, enum enum_thr_lock_result thr_multi_lock(THR_LOCK_DATA **data,
uint count, THR_LOCK_OWNER *owner); uint count, THR_LOCK_OWNER *owner,
ulong lock_wait_timeout);
void thr_multi_unlock(THR_LOCK_DATA **data,uint count); void thr_multi_unlock(THR_LOCK_DATA **data,uint count);
void
thr_lock_merge_status(THR_LOCK_DATA **data, uint count);
void thr_abort_locks(THR_LOCK *lock, my_bool upgrade_lock); void thr_abort_locks(THR_LOCK *lock, my_bool upgrade_lock);
my_bool thr_abort_locks_for_thread(THR_LOCK *lock, my_thread_id thread); my_bool thr_abort_locks_for_thread(THR_LOCK *lock, my_thread_id thread);
void thr_print_locks(void); /* For debugging */ void thr_print_locks(void); /* For debugging */
my_bool thr_upgrade_write_delay_lock(THR_LOCK_DATA *data, my_bool thr_upgrade_write_delay_lock(THR_LOCK_DATA *data,
enum thr_lock_type new_lock_type); enum thr_lock_type new_lock_type,
ulong lock_wait_timeout);
void thr_downgrade_write_lock(THR_LOCK_DATA *data, void thr_downgrade_write_lock(THR_LOCK_DATA *data,
enum thr_lock_type new_lock_type); enum thr_lock_type new_lock_type);
my_bool thr_reschedule_write_lock(THR_LOCK_DATA *data); my_bool thr_reschedule_write_lock(THR_LOCK_DATA *data,
ulong lock_wait_timeout);
#ifdef __cplusplus #ifdef __cplusplus
} }
#endif #endif
......
...@@ -135,6 +135,7 @@ SET(LIBMYSQLD_SOURCES emb_qcache.cc libmysqld.c lib_sql.cc ...@@ -135,6 +135,7 @@ SET(LIBMYSQLD_SOURCES emb_qcache.cc libmysqld.c lib_sql.cc
../sql/scheduler.cc ../sql/sql_audit.cc ../sql/scheduler.cc ../sql/sql_audit.cc
../sql/event_parse_data.cc ../sql/event_parse_data.cc
../sql/sql_signal.cc ../sql/rpl_handler.cc ../sql/sql_signal.cc ../sql/rpl_handler.cc
../sql/mdl.cc ../sql/transaction.cc
${GEN_SOURCES} ${GEN_SOURCES}
${LIB_SOURCES}) ${LIB_SOURCES})
......
...@@ -75,11 +75,10 @@ sqlsources = derror.cc field.cc field_conv.cc strfunc.cc filesort.cc \ ...@@ -75,11 +75,10 @@ sqlsources = derror.cc field.cc field_conv.cc strfunc.cc filesort.cc \
sp_head.cc sp_pcontext.cc sp.cc sp_cache.cc sp_rcontext.cc \ sp_head.cc sp_pcontext.cc sp.cc sp_cache.cc sp_rcontext.cc \
parse_file.cc sql_view.cc sql_trigger.cc my_decimal.cc \ parse_file.cc sql_view.cc sql_trigger.cc my_decimal.cc \
rpl_filter.cc sql_partition.cc sql_builtin.cc sql_plugin.cc \ rpl_filter.cc sql_partition.cc sql_builtin.cc sql_plugin.cc \
debug_sync.cc \ debug_sync.cc sql_tablespace.cc transaction.cc \
sql_tablespace.cc \
rpl_injector.cc my_user.c partition_info.cc \ rpl_injector.cc my_user.c partition_info.cc \
sql_servers.cc sql_audit.cc event_parse_data.cc \ sql_servers.cc event_parse_data.cc sql_signal.cc \
sql_signal.cc rpl_handler.cc keycaches.cc rpl_handler.cc mdl.cc keycaches.cc sql_audit.cc
libmysqld_int_a_SOURCES= $(libmysqld_sources) libmysqld_int_a_SOURCES= $(libmysqld_sources)
nodist_libmysqld_int_a_SOURCES= $(libmysqlsources) $(sqlsources) nodist_libmysqld_int_a_SOURCES= $(libmysqlsources) $(sqlsources)
......
#
# Bug#989: If DROP TABLE while there's an active transaction, wrong binlog order
#
--disable_warnings
DROP TABLE IF EXISTS t1;
--enable_warnings
connect (con1,localhost,root,,);
connect (con2,localhost,root,,);
connection con1;
RESET MASTER;
CREATE TABLE t1 (a INT);
SET AUTOCOMMIT=OFF;
BEGIN;
INSERT INTO t1 VALUES(1);
connection con2;
--send DROP TABLE t1;
connection con1;
COMMIT;
connection con2;
--reap
connection default;
--disconnect con1
--disconnect con2
let $VERSION=`select version()`;
source include/show_binlog_events.inc;
...@@ -205,6 +205,10 @@ select (@after:=unix_timestamp())*0; # always give repeatable output ...@@ -205,6 +205,10 @@ select (@after:=unix_timestamp())*0; # always give repeatable output
# the bug, the reap would return immediately after the insert into t2. # the bug, the reap would return immediately after the insert into t2.
select (@after-@before) >= 2; select (@after-@before) >= 2;
connection con3;
commit;
connection con2;
drop table t1,t2; drop table t1,t2;
commit; commit;
......
...@@ -118,6 +118,71 @@ connection master; ...@@ -118,6 +118,71 @@ connection master;
FLUSH LOGS; FLUSH LOGS;
DROP DATABASE mysqltest1; DROP DATABASE mysqltest1;
-- source include/master-slave-end.inc
--echo End of 5.1 tests --echo End of 5.1 tests
--echo #
--echo # Bug#39675 rename tables on innodb tables with pending
--echo # transactions causes slave data issue.
--echo #
--disable_warnings
DROP TABLE IF EXISTS t1;
DROP TABLE IF EXISTS t2;
DROP TABLE IF EXISTS t3;
--enable_warnings
CREATE TABLE t1 (
id INT PRIMARY KEY auto_increment,
b INT DEFAULT NULL
) ENGINE=InnoDB;
CREATE TABLE t2 (
id INT PRIMARY KEY auto_increment,
b INT DEFAULT NULL
) ENGINE=InnoDB;
INSERT INTO t1 (b) VALUES (1),(2),(3);
BEGIN;
INSERT INTO t1(b) VALUES (4);
--echo -------- switch to master1 --------
connection master1;
--send RENAME TABLE t1 TO t3, t2 TO t1;
--echo -------- switch to master --------
connection master;
# Need to wait until RENAME is received
let $wait_condition=
SELECT COUNT(*) = 1 FROM information_schema.processlist
WHERE info = "RENAME TABLE t1 TO t3, t2 TO t1" and
state = "Waiting for table";
--source include/wait_condition.inc
COMMIT;
--echo -------- switch to master1 --------
connection master1;
--reap
--echo -------- switch to master --------
connection master;
SELECT * FROM t1;
SELECT * FROM t3;
sync_slave_with_master;
--echo -------- switch to slave --------
connection slave;
SELECT * FROM t1;
SELECT * FROM t3;
--echo -------- switch to master --------
connection master;
DROP TABLE t1;
DROP TABLE t3;
--echo End of 6.0 tests
--source include/master-slave-end.inc
...@@ -729,15 +729,15 @@ call p_verify_status_increment(2, 0, 4, 4); ...@@ -729,15 +729,15 @@ call p_verify_status_increment(2, 0, 4, 4);
alter table t3 add column (b int); alter table t3 add column (b int);
call p_verify_status_increment(2, 0, 2, 0); call p_verify_status_increment(2, 0, 2, 0);
alter table t3 rename t4; alter table t3 rename t4;
call p_verify_status_increment(1, 0, 1, 0); call p_verify_status_increment(2, 0, 2, 0);
rename table t4 to t3; rename table t4 to t3;
call p_verify_status_increment(1, 0, 1, 0); call p_verify_status_increment(0, 0, 0, 0);
truncate table t3; truncate table t3;
call p_verify_status_increment(2, 0, 2, 0); call p_verify_status_increment(2, 0, 2, 0);
create view v1 as select * from t2; create view v1 as select * from t2;
call p_verify_status_increment(1, 0, 1, 0); call p_verify_status_increment(2, 0, 2, 0);
check table t1; check table t1;
call p_verify_status_increment(3, 0, 3, 0); call p_verify_status_increment(2, 0, 2, 0);
--echo # Sic: after this bug is fixed, CHECK leaves no pending transaction --echo # Sic: after this bug is fixed, CHECK leaves no pending transaction
commit; commit;
call p_verify_status_increment(0, 0, 0, 0); call p_verify_status_increment(0, 0, 0, 0);
......
CREATE TABLE t1 (a CHAR(1)) CHARACTER SET utf8;
INSERT INTO t1 VALUES ('0'),('1'),('2'),('3'),('4'),('5'),('6'),('7');
INSERT INTO t1 VALUES ('8'),('9'),('A'),('B'),('C'),('D'),('E'),('F');
#
# Populate tables head and tail with values '00'-'FF'
#
CREATE TEMPORARY TABLE head AS SELECT concat(b1.a, b2.a) AS head FROM t1 b1, t1 b2;
CREATE TEMPORARY TABLE tail AS SELECT concat(b1.a, b2.a) AS tail FROM t1 b1, t1 b2;
CREATE TEMPORARY TABLE middle AS SELECT concat(b1.a, b2.a) AS middle FROM t1 b1, t1 b2;
DROP TABLE t1;
CREATE TABLE t1 (a varchar(1)) CHARACTER SET utf8;
#
# Populate single byte characters
#
INSERT INTO t1 SELECT UNHEX(head)
FROM head WHERE (head BETWEEN '00' AND '7F') ORDER BY head;
#
# Populate 2-byte byte characters: U+80..U+7FF: [C2-DF][80-BF]
#
INSERT INTO t1
SELECT UNHEX(CONCAT(head,tail))
FROM head, tail
WHERE (head BETWEEN 'C2' AND 'DF') AND (tail BETWEEN '80' AND 'BF')
ORDER BY head, tail;
#
# Populate 3-byte characters: U+800..U+FFFF: [E0-EF][80-BF][80-BF]
# excluding overlong [E0][80-9F][80-BF]
#
INSERT INTO t1
SELECT UNHEX(CONCAT(head, middle, tail))
FROM head, middle, tail
WHERE (head BETWEEN 'E0' AND 'EF')
AND (middle BETWEEN '80' AND 'BF')
AND (tail BETWEEN '80' AND 'BF')
AND NOT (head='E0' AND middle BETWEEN '80' AND '9F')
ORDER BY head, middle, tail;
SELECT count(*) FROM t1;
This diff is collapsed.
INSERT INTO db1.trans (a) VALUES (1);
--disable_result_log
eval $statement;
--enable_result_log
CALL db1.test_if_commit();
...@@ -899,6 +899,8 @@ CREATE PROCEDURE p1 () ...@@ -899,6 +899,8 @@ CREATE PROCEDURE p1 ()
BEGIN BEGIN
DECLARE i INT DEFAULT 50; DECLARE i INT DEFAULT 50;
DECLARE cnt INT; DECLARE cnt INT;
# Continue even in the presence of ER_LOCK_DEADLOCK.
DECLARE CONTINUE HANDLER FOR 1213 BEGIN END;
START TRANSACTION; START TRANSACTION;
ALTER TABLE t1 ENGINE=InnoDB; ALTER TABLE t1 ENGINE=InnoDB;
COMMIT; COMMIT;
...@@ -1392,6 +1394,7 @@ SELECT * FROM t1; ...@@ -1392,6 +1394,7 @@ SELECT * FROM t1;
connection con2; connection con2;
--reap --reap
SELECT * FROM t1; SELECT * FROM t1;
COMMIT;
--echo # Switch to connection con1 --echo # Switch to connection con1
connection con1; connection con1;
......
...@@ -1994,6 +1994,7 @@ commit; ...@@ -1994,6 +1994,7 @@ commit;
connection b; connection b;
set autocommit = 0; set autocommit = 0;
update t1 set b = 5 where a = 2; update t1 set b = 5 where a = 2;
commit;
connection a; connection a;
delimiter |; delimiter |;
create trigger t1t before insert on t1 for each row begin set NEW.b = NEW.a * 10 + 5, NEW.c = NEW.a / 10; end | create trigger t1t before insert on t1 for each row begin set NEW.b = NEW.a * 10 + 5, NEW.c = NEW.a / 10; end |
...@@ -2056,6 +2057,7 @@ update t2 set b = b + 5 where a = 1; ...@@ -2056,6 +2057,7 @@ update t2 set b = b + 5 where a = 1;
update t3 set b = b + 5 where a = 1; update t3 set b = b + 5 where a = 1;
update t4 set b = b + 5 where a = 1; update t4 set b = b + 5 where a = 1;
insert into t5(a) values(20); insert into t5(a) values(20);
commit;
connection b; connection b;
set autocommit = 0; set autocommit = 0;
insert into t1(a) values(7); insert into t1(a) values(7);
......
...@@ -194,6 +194,35 @@ INSERT INTO global_suppressions VALUES ...@@ -194,6 +194,35 @@ INSERT INTO global_suppressions VALUES
("Slave I/O: Get master COLLATION_SERVER failed with error:.*"), ("Slave I/O: Get master COLLATION_SERVER failed with error:.*"),
("Slave I/O: Get master TIME_ZONE failed with error:.*"), ("Slave I/O: Get master TIME_ZONE failed with error:.*"),
/* Messages from valgrind */
("==[0-9]*== Memcheck,"),
("==[0-9]*== Copyright"),
("==[0-9]*== Using"),
("==[0-9]*== For more details"),
/* This comes with innodb plugin tests */
("==[0-9]*== Warning: set address range perms: large range"),
/* valgrind warnings: invalid file descriptor -1 in syscall
write()/read(). Bug #50414 */
("==[0-9]*== Warning: invalid file descriptor -1 in syscall write()"),
("==[0-9]*== Warning: invalid file descriptor -1 in syscall read()"),
/*
Transient network failures that cause warnings on reconnect.
BUG#47743 and BUG#47983.
*/
("Slave I/O: Get master SERVER_ID failed with error:.*"),
("Slave I/O: Get master clock failed with error:.*"),
("Slave I/O: Get master COLLATION_SERVER failed with error:.*"),
("Slave I/O: Get master TIME_ZONE failed with error:.*"),
/*
BUG#42147 - Concurrent DML and LOCK TABLE ... READ for InnoDB
table cause warnings in errlog
Note: This is a temporary suppression until Bug#42147 can be
fixed properly. See bug page for more information.
*/
("Found lock of type 6 that is write and read locked"),
("THE_LAST_SUPPRESSION")|| ("THE_LAST_SUPPRESSION")||
......
...@@ -81,24 +81,28 @@ sub is_child { ...@@ -81,24 +81,28 @@ sub is_child {
} }
# Find the safe process binary or script
my @safe_process_cmd; my @safe_process_cmd;
my $safe_kill; my $safe_kill;
if (IS_WIN32PERL or IS_CYGWIN){
# Use my_safe_process.exe # Find the safe process binary or script
my $exe= my_find_bin(".", ["lib/My/SafeProcess", "My/SafeProcess"], sub find_bin {
"my_safe_process"); if (IS_WIN32PERL or IS_CYGWIN)
push(@safe_process_cmd, $exe); {
# Use my_safe_process.exe
# Use my_safe_kill.exe my $exe= my_find_bin(".", ["lib/My/SafeProcess", "My/SafeProcess"],
$safe_kill= my_find_bin(".", "lib/My/SafeProcess", "my_safe_kill"); "my_safe_process");
} push(@safe_process_cmd, $exe);
else
{ # Use my_safe_kill.exe
# Use my_safe_process $safe_kill= my_find_bin(".", "lib/My/SafeProcess", "my_safe_kill");
my $exe= my_find_bin(".", ["lib/My/SafeProcess", "My/SafeProcess"], }
"my_safe_process"); else
push(@safe_process_cmd, $exe); {
# Use my_safe_process
my $exe= my_find_bin(".", ["lib/My/SafeProcess", "My/SafeProcess"],
"my_safe_process");
push(@safe_process_cmd, $exe);
}
} }
...@@ -183,63 +187,6 @@ sub run { ...@@ -183,63 +187,6 @@ sub run {
return $proc->exit_status(); return $proc->exit_status();
} }
#
# Start a process that returns after "duration" seconds
# or when it's parent process does not exist anymore
#
sub timer {
my $class= shift;
my $duration= shift or croak "duration required";
my $parent_pid= $$;
my $pid= My::SafeProcess::Base::_safe_fork();
if ($pid){
# Parent
my $proc= bless
({
SAFE_PID => $pid,
SAFE_NAME => "timer",
PARENT => $$,
}, $class);
# Put the new process in list of running
$running{$pid}= $proc;
return $proc;
}
# Child, install signal handlers and sleep for "duration"
$SIG{INT}= 'IGNORE';
$SIG{TERM}= sub {
#print STDERR "timer $$: woken up, exiting!\n";
exit(0);
};
$0= "safe_timer($duration)";
if (IS_WIN32PERL){
# Just a thread in same process
sleep($duration);
print STDERR "timer $$: expired after $duration seconds\n";
exit(0);
}
my $count_down= $duration;
while($count_down--){
# Check that parent is still alive
if (kill(0, $parent_pid) == 0){
#print STDERR "timer $$: parent gone, exiting!\n";
exit(0);
}
sleep(1);
}
print STDERR "timer $$: expired after $duration seconds\n";
exit(0);
}
# #
# Shutdown process nicely, and wait for shutdown_timeout seconds # Shutdown process nicely, and wait for shutdown_timeout seconds
# If processes hasn't shutdown, kill them hard and wait for return # If processes hasn't shutdown, kill them hard and wait for return
...@@ -338,12 +285,12 @@ sub start_kill { ...@@ -338,12 +285,12 @@ sub start_kill {
$ret= system($safe_kill, $winpid) >> 8; $ret= system($safe_kill, $winpid) >> 8;
if ($ret == 3){ if ($ret == 3){
print "Couldn't open the winpid: $winpid ", print "Couldn't open the winpid: $winpid ".
"for pid: $pid, try one more time\n"; "for pid: $pid, try one more time\n";
sleep(1); sleep(1);
$winpid= _winpid($pid); $winpid= _winpid($pid);
$ret= system($safe_kill, $winpid) >> 8; $ret= system($safe_kill, $winpid) >> 8;
print "Couldn't open the winpid: $winpid ", print "Couldn't open the winpid: $winpid ".
"for pid: $pid, continue and see what happens...\n"; "for pid: $pid, continue and see what happens...\n";
} }
} }
...@@ -537,6 +484,40 @@ sub wait_any { ...@@ -537,6 +484,40 @@ sub wait_any {
} }
#
# Wait for any process to exit, or a timeout
#
# Returns a reference to the SafeProcess that
# exited or a pseudo-process with $proc->{timeout} == 1
#
sub wait_any_timeout {
my $class= shift;
my $timeout= shift;
my $proc;
my $millis=10;
do {
::mtr_milli_sleep($millis);
# Slowly increse interval up to max. 1 second
$millis++ if $millis < 1000;
# Return a "fake" process for timeout
if (::has_expired($timeout)) {
$proc= bless
({
SAFE_PID => 0,
SAFE_NAME => "timer",
timeout => 1,
}, $class);
} else {
$proc= check_any();
}
} while (! $proc);
return $proc;
}
# #
# Wait for all processes to exit # Wait for all processes to exit
# #
...@@ -594,7 +575,7 @@ sub self2str { ...@@ -594,7 +575,7 @@ sub self2str {
sub _verbose { sub _verbose {
return unless $_verbose; return unless $_verbose;
print STDERR " ## ", @_, "\n"; print STDERR " ## ". @_. "\n";
} }
......
...@@ -186,14 +186,20 @@ int main(int argc, const char** argv ) ...@@ -186,14 +186,20 @@ int main(int argc, const char** argv )
die("No real args -> nothing to do"); die("No real args -> nothing to do");
/* Copy the remaining args to child_arg */ /* Copy the remaining args to child_arg */
for (int j= i+1; j < argc; j++) { for (int j= i+1; j < argc; j++) {
if (strchr (argv[j], ' ')) { arg= argv[j];
/* Protect with "" if this arg contains a space */ if (strchr (arg, ' ') &&
to+= _snprintf(to, child_args + sizeof(child_args) - to, arg[0] != '\"' &&
"\"%s\" ", argv[j]); arg[strlen(arg)] != '\"')
} else { {
to+= _snprintf(to, child_args + sizeof(child_args) - to, /* Quote arg that contains spaces and are not quoted already */
"%s ", argv[j]); to+= _snprintf(to, child_args + sizeof(child_args) - to,
} "\"%s\" ", arg);
}
else
{
to+= _snprintf(to, child_args + sizeof(child_args) - to,
"%s ", arg);
}
} }
break; break;
} else { } else {
......
...@@ -40,7 +40,6 @@ our $default_storage_engine; ...@@ -40,7 +40,6 @@ our $default_storage_engine;
our $opt_with_ndbcluster_only; our $opt_with_ndbcluster_only;
our $defaults_file; our $defaults_file;
our $defaults_extra_file; our $defaults_extra_file;
our $reorder= 1;
our $quick_collect; our $quick_collect;
sub collect_option { sub collect_option {
...@@ -99,7 +98,8 @@ sub init_pattern { ...@@ -99,7 +98,8 @@ sub init_pattern {
# #
############################################################################## ##############################################################################
sub collect_test_cases ($$) { sub collect_test_cases ($$$) {
my $opt_reorder= shift; # True if we're reordering tests
my $suites= shift; # Semicolon separated list of test suites my $suites= shift; # Semicolon separated list of test suites
my $opt_cases= shift; my $opt_cases= shift;
my $cases= []; # Array of hash(one hash for each testcase) my $cases= []; # Array of hash(one hash for each testcase)
...@@ -118,10 +118,16 @@ sub collect_test_cases ($$) { ...@@ -118,10 +118,16 @@ sub collect_test_cases ($$) {
!(IS_WINDOWS && $::opt_embedded_server) && !(IS_WINDOWS && $::opt_embedded_server) &&
$lib_innodb_plugin); $lib_innodb_plugin);
foreach my $suite (split(",", $suites)) # If not reordering, we also shouldn't group by suites, unless
# no test cases were named.
# This also effects some logic in the loop following this.
if ($opt_reorder or !@$opt_cases)
{ {
push(@$cases, collect_one_suite($suite, $opt_cases)); foreach my $suite (split(",", $suites))
last if $some_test_found; {
push(@$cases, collect_one_suite($suite, $opt_cases));
last if $some_test_found;
}
} }
if ( @$opt_cases ) if ( @$opt_cases )
...@@ -135,6 +141,7 @@ sub collect_test_cases ($$) { ...@@ -135,6 +141,7 @@ sub collect_test_cases ($$) {
my ($sname, $tname, $extension)= split_testname($test_name_spec); my ($sname, $tname, $extension)= split_testname($test_name_spec);
foreach my $test ( @$cases ) foreach my $test ( @$cases )
{ {
last unless $opt_reorder;
# test->{name} is always in suite.name format # test->{name} is always in suite.name format
if ( $test->{name} =~ /.*\.$tname/ ) if ( $test->{name} =~ /.*\.$tname/ )
{ {
...@@ -144,12 +151,13 @@ sub collect_test_cases ($$) { ...@@ -144,12 +151,13 @@ sub collect_test_cases ($$) {
} }
if ( not $found ) if ( not $found )
{ {
$sname= "main" if !$opt_reorder and !$sname;
mtr_error("Could not find '$tname' in '$suites' suite(s)") unless $sname; mtr_error("Could not find '$tname' in '$suites' suite(s)") unless $sname;
# If suite was part of name, find it there # If suite was part of name, find it there, may come with combinations
my ($this_case) = collect_one_suite($sname, [ $tname ]); my @this_case = collect_one_suite($sname, [ $tname ]);
if ($this_case) if (@this_case)
{ {
push (@$cases, $this_case); push (@$cases, @this_case);
} }
else else
{ {
...@@ -159,7 +167,7 @@ sub collect_test_cases ($$) { ...@@ -159,7 +167,7 @@ sub collect_test_cases ($$) {
} }
} }
if ( $reorder && !$quick_collect) if ( $opt_reorder && !$quick_collect)
{ {
# Reorder the test cases in an order that will make them faster to run # Reorder the test cases in an order that will make them faster to run
my %sort_criteria; my %sort_criteria;
......
...@@ -20,43 +20,20 @@ ...@@ -20,43 +20,20 @@
use strict; use strict;
# These are not to be prefixed with "mtr_" sub gprof_collect ($@) {
my ($exe_mysqld, @gprof_dirs)= @_;
sub gprof_prepare (); print ("Collecting gprof reports.....\n");
sub gprof_collect ();
############################################################################## foreach my $datadir (@gprof_dirs)
#
#
#
##############################################################################
sub gprof_prepare () {
rmtree($::opt_gprof_dir);
mkdir($::opt_gprof_dir);
}
# FIXME what about master1 and slave1?!
sub gprof_collect () {
if ( -f "$::master->[0]->{'path_myddir'}/gmon.out" )
{
# FIXME check result code?!
mtr_run("gprof",
[$::exe_master_mysqld,
"$::master->[0]->{'path_myddir'}/gmon.out"],
$::opt_gprof_master, "", "", "");
print "Master execution profile has been saved in $::opt_gprof_master\n";
}
if ( -f "$::slave->[0]->{'path_myddir'}/gmon.out" )
{ {
# FIXME check result code?! my $gprof_msg= "$datadir/gprof.msg";
mtr_run("gprof", my $gprof_err= "$datadir/gprof.err";
[$::exe_slave_mysqld, if ( -f "$datadir/gmon.out" )
"$::slave->[0]->{'path_myddir'}/gmon.out"], {
$::opt_gprof_slave, "", "", ""); system("gprof $exe_mysqld $datadir/gmon.out 2>$gprof_err >$gprof_msg");
print "Slave execution profile has been saved in $::opt_gprof_slave\n"; print ("GPROF output in $gprof_msg, errors in $gprof_err\n");
}
} }
} }
......
...@@ -30,7 +30,9 @@ sub mtr_script_exists(@); ...@@ -30,7 +30,9 @@ sub mtr_script_exists(@);
sub mtr_file_exists(@); sub mtr_file_exists(@);
sub mtr_exe_exists(@); sub mtr_exe_exists(@);
sub mtr_exe_maybe_exists(@); sub mtr_exe_maybe_exists(@);
sub mtr_milli_sleep($);
sub start_timer($);
sub has_expired($);
############################################################################## ##############################################################################
# #
...@@ -167,11 +169,18 @@ sub mtr_exe_exists (@) { ...@@ -167,11 +169,18 @@ sub mtr_exe_exists (@) {
} }
sub mtr_milli_sleep { sub mtr_milli_sleep ($) {
die "usage: mtr_milli_sleep(milliseconds)" unless @_ == 1; die "usage: mtr_milli_sleep(milliseconds)" unless @_ == 1;
my ($millis)= @_; my ($millis)= @_;
select(undef, undef, undef, ($millis/1000)); select(undef, undef, undef, ($millis/1000));
} }
# Simple functions to start and check timers (have to be actively polled)
# Timer can be "killed" by setting it to 0
sub start_timer ($) { return time + $_[0]; }
sub has_expired ($) { return $_[0] && time gt $_[0]; }
1; 1;
...@@ -69,7 +69,7 @@ sub _mtr_report_test_name ($) { ...@@ -69,7 +69,7 @@ sub _mtr_report_test_name ($) {
$tname.= " '$tinfo->{combination}'" $tname.= " '$tinfo->{combination}'"
if defined $tinfo->{combination}; if defined $tinfo->{combination};
print _name(), _timestamp(); print _name(). _timestamp();
printf "%-40s ", $tname; printf "%-40s ", $tname;
my $worker = $tinfo->{worker}; my $worker = $tinfo->{worker};
printf "w$worker " if $worker; printf "w$worker " if $worker;
...@@ -222,8 +222,8 @@ sub mtr_report_test ($) { ...@@ -222,8 +222,8 @@ sub mtr_report_test ($) {
} }
sub mtr_report_stats ($;$) { sub mtr_report_stats ($$;$) {
my ($tests, $dont_error)= @_; my ($prefix, $tests, $dont_error)= @_;
# ---------------------------------------------------------------------- # ----------------------------------------------------------------------
# Find out how we where doing # Find out how we where doing
...@@ -328,6 +328,9 @@ sub mtr_report_stats ($;$) { ...@@ -328,6 +328,9 @@ sub mtr_report_stats ($;$) {
} }
} }
# Print summary line prefix
print "$prefix: ";
# Print a list of testcases that failed # Print a list of testcases that failed
if ( $tot_failed != 0 ) if ( $tot_failed != 0 )
{ {
...@@ -387,13 +390,13 @@ sub mtr_report_stats ($;$) { ...@@ -387,13 +390,13 @@ sub mtr_report_stats ($;$) {
############################################################################## ##############################################################################
sub mtr_print_line () { sub mtr_print_line () {
print '-' x 60, "\n"; print '-' x 60 . "\n";
} }
sub mtr_print_thick_line { sub mtr_print_thick_line {
my $char= shift || '='; my $char= shift || '=';
print $char x 78, "\n"; print $char x 78 . "\n";
} }
...@@ -451,7 +454,7 @@ sub _timestamp { ...@@ -451,7 +454,7 @@ sub _timestamp {
# Always print message to screen # Always print message to screen
sub mtr_print (@) { sub mtr_print (@) {
print _name(), join(" ", @_), "\n"; print _name(). join(" ", @_). "\n";
} }
...@@ -459,22 +462,22 @@ sub mtr_print (@) { ...@@ -459,22 +462,22 @@ sub mtr_print (@) {
sub mtr_report (@) { sub mtr_report (@) {
if (defined $verbose) if (defined $verbose)
{ {
print _name(), join(" ", @_), "\n"; print _name(). join(" ", @_). "\n";
} }
} }
# Print warning to screen # Print warning to screen
sub mtr_warning (@) { sub mtr_warning (@) {
print STDERR _name(), _timestamp(), print STDERR _name(). _timestamp().
"mysql-test-run: WARNING: ", join(" ", @_), "\n"; "mysql-test-run: WARNING: ". join(" ", @_). "\n";
} }
# Print error to screen and then exit # Print error to screen and then exit
sub mtr_error (@) { sub mtr_error (@) {
print STDERR _name(), _timestamp(), print STDERR _name(). _timestamp().
"mysql-test-run: *** ERROR: ", join(" ", @_), "\n"; "mysql-test-run: *** ERROR: ". join(" ", @_). "\n";
if (IS_WINDOWS) if (IS_WINDOWS)
{ {
POSIX::_exit(1); POSIX::_exit(1);
...@@ -489,8 +492,8 @@ sub mtr_error (@) { ...@@ -489,8 +492,8 @@ sub mtr_error (@) {
sub mtr_debug (@) { sub mtr_debug (@) {
if ( $verbose > 2 ) if ( $verbose > 2 )
{ {
print STDERR _name(), print STDERR _name().
_timestamp(), "####: ", join(" ", @_), "\n"; _timestamp(). "####: ". join(" ", @_). "\n";
} }
} }
...@@ -498,8 +501,8 @@ sub mtr_debug (@) { ...@@ -498,8 +501,8 @@ sub mtr_debug (@) {
sub mtr_verbose (@) { sub mtr_verbose (@) {
if ( $verbose ) if ( $verbose )
{ {
print STDERR _name(), _timestamp(), print STDERR _name(). _timestamp().
"> ",join(" ", @_),"\n"; "> ".join(" ", @_)."\n";
} }
} }
...@@ -509,8 +512,8 @@ sub mtr_verbose_restart (@) { ...@@ -509,8 +512,8 @@ sub mtr_verbose_restart (@) {
my $proc= $server->{proc}; my $proc= $server->{proc};
if ( $verbose_restart ) if ( $verbose_restart )
{ {
print STDERR _name(),_timestamp(), print STDERR _name()._timestamp().
"> Restart $proc - ",join(" ", @args),"\n"; "> Restart $proc - ".join(" ", @args)."\n";
} }
} }
......
...@@ -150,7 +150,7 @@ sub run_stress_test () ...@@ -150,7 +150,7 @@ sub run_stress_test ()
mtr_add_arg($args, "--verbose"); mtr_add_arg($args, "--verbose");
mtr_add_arg($args, "--cleanup"); mtr_add_arg($args, "--cleanup");
mtr_add_arg($args, "--log-error-details"); mtr_add_arg($args, "--log-error-details");
mtr_add_arg($args, "--abort-on-error"); mtr_add_arg($args, "--abort-on-error=1");
if ( $::opt_stress_init_file ) if ( $::opt_stress_init_file )
{ {
......
...@@ -376,6 +376,9 @@ sub mtr_report_stats ($) { ...@@ -376,6 +376,9 @@ sub mtr_report_stats ($) {
/Slave: Can't DROP 'c7'.* 1091/ or /Slave: Can't DROP 'c7'.* 1091/ or
/Slave: Key column 'c6'.* 1072/ or /Slave: Key column 'c6'.* 1072/ or
# Warnings generated until bug#42147 is properly resolved
/Found lock of type 6 that is write and read locked/ or
# rpl_idempotency.test produces warnings for the slave. # rpl_idempotency.test produces warnings for the slave.
($testname eq 'rpl.rpl_idempotency' and ($testname eq 'rpl.rpl_idempotency' and
(/Slave: Can\'t find record in \'t1\' Error_code: 1032/ or (/Slave: Can\'t find record in \'t1\' Error_code: 1032/ or
......
...@@ -150,7 +150,7 @@ sub run_stress_test () ...@@ -150,7 +150,7 @@ sub run_stress_test ()
mtr_add_arg($args, "--verbose"); mtr_add_arg($args, "--verbose");
mtr_add_arg($args, "--cleanup"); mtr_add_arg($args, "--cleanup");
mtr_add_arg($args, "--log-error-details"); mtr_add_arg($args, "--log-error-details");
mtr_add_arg($args, "--abort-on-error"); mtr_add_arg($args, "--abort-on-error=1");
if ( $::opt_stress_init_file ) if ( $::opt_stress_init_file )
{ {
......
...@@ -905,6 +905,11 @@ sub command_line_setup () { ...@@ -905,6 +905,11 @@ sub command_line_setup () {
mtr_report("Using default engine '$used_default_engine'") mtr_report("Using default engine '$used_default_engine'")
if defined $used_default_engine; if defined $used_default_engine;
if ($glob_win32 and defined $opt_mem) {
mtr_report("--mem not supported on Windows, ignored");
$opt_mem= undef;
}
# -------------------------------------------------------------------------- # --------------------------------------------------------------------------
# Check if we should speed up tests by trying to run on tmpfs # Check if we should speed up tests by trying to run on tmpfs
# -------------------------------------------------------------------------- # --------------------------------------------------------------------------
......
This diff is collapsed.
...@@ -842,11 +842,11 @@ call p_verify_status_increment(2, 0, 2, 0); ...@@ -842,11 +842,11 @@ call p_verify_status_increment(2, 0, 2, 0);
SUCCESS SUCCESS
alter table t3 rename t4; alter table t3 rename t4;
call p_verify_status_increment(1, 0, 1, 0); call p_verify_status_increment(2, 0, 2, 0);
SUCCESS SUCCESS
rename table t4 to t3; rename table t4 to t3;
call p_verify_status_increment(1, 0, 1, 0); call p_verify_status_increment(0, 0, 0, 0);
SUCCESS SUCCESS
truncate table t3; truncate table t3;
...@@ -854,13 +854,13 @@ call p_verify_status_increment(2, 0, 2, 0); ...@@ -854,13 +854,13 @@ call p_verify_status_increment(2, 0, 2, 0);
SUCCESS SUCCESS
create view v1 as select * from t2; create view v1 as select * from t2;
call p_verify_status_increment(1, 0, 1, 0); call p_verify_status_increment(2, 0, 2, 0);
SUCCESS SUCCESS
check table t1; check table t1;
Table Op Msg_type Msg_text Table Op Msg_type Msg_text
test.t1 check status OK test.t1 check status OK
call p_verify_status_increment(3, 0, 3, 0); call p_verify_status_increment(2, 0, 2, 0);
SUCCESS SUCCESS
# Sic: after this bug is fixed, CHECK leaves no pending transaction # Sic: after this bug is fixed, CHECK leaves no pending transaction
......
...@@ -785,7 +785,7 @@ drop table t1; ...@@ -785,7 +785,7 @@ drop table t1;
create table t1 select * from t2; create table t1 select * from t2;
ERROR 42S02: Table 'test.t2' doesn't exist ERROR 42S02: Table 'test.t2' doesn't exist
create table t1 select * from t1; create table t1 select * from t1;
ERROR HY000: You can't specify target table 't1' for update in FROM clause ERROR 42S02: Table 'test.t1' doesn't exist
create table t1 select coalesce('a' collate latin1_swedish_ci,'b' collate latin1_bin); create table t1 select coalesce('a' collate latin1_swedish_ci,'b' collate latin1_bin);
ERROR HY000: Illegal mix of collations (latin1_swedish_ci,EXPLICIT) and (latin1_bin,EXPLICIT) for operation 'coalesce' ERROR HY000: Illegal mix of collations (latin1_swedish_ci,EXPLICIT) and (latin1_bin,EXPLICIT) for operation 'coalesce'
create table t1 (primary key(a)) select "b" as b; create table t1 (primary key(a)) select "b" as b;
...@@ -805,6 +805,11 @@ Note 1050 Table 't1' already exists ...@@ -805,6 +805,11 @@ Note 1050 Table 't1' already exists
select * from t1; select * from t1;
i i
1 1
create table if not exists t1 select * from t1;
ERROR HY000: You can't specify target table 't1' for update in FROM clause
select * from t1;
i
1
create table t1 select coalesce('a' collate latin1_swedish_ci,'b' collate latin1_bin); create table t1 select coalesce('a' collate latin1_swedish_ci,'b' collate latin1_bin);
ERROR HY000: Illegal mix of collations (latin1_swedish_ci,EXPLICIT) and (latin1_bin,EXPLICIT) for operation 'coalesce' ERROR HY000: Illegal mix of collations (latin1_swedish_ci,EXPLICIT) and (latin1_bin,EXPLICIT) for operation 'coalesce'
select * from t1; select * from t1;
...@@ -1953,3 +1958,22 @@ END ;| ...@@ -1953,3 +1958,22 @@ END ;|
ERROR 42000: This version of MySQL doesn't yet support 'multiple triggers with the same action time and event for one table' ERROR 42000: This version of MySQL doesn't yet support 'multiple triggers with the same action time and event for one table'
DROP TABLE t1; DROP TABLE t1;
DROP TABLE B; DROP TABLE B;
#
# Bug #47107 assert in notify_shared_lock on incorrect
# CREATE TABLE , HANDLER
#
DROP TABLE IF EXISTS t1;
CREATE TABLE t1(f1 integer);
# The following CREATE TABLEs before gave an assert.
HANDLER t1 OPEN AS A;
CREATE TABLE t1 SELECT 1 AS f2;
ERROR 42S01: Table 't1' already exists
HANDLER t1 OPEN AS A;
CREATE TABLE t1(f1 integer);
ERROR 42S01: Table 't1' already exists
CREATE TABLE t2(f1 integer);
HANDLER t1 OPEN AS A;
CREATE TABLE t1 LIKE t2;
ERROR 42S01: Table 't1' already exists
DROP TABLE t2;
DROP TABLE t1;
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
...@@ -263,7 +263,7 @@ DROP TABLE t1; ...@@ -263,7 +263,7 @@ DROP TABLE t1;
SET DEBUG_SYNC= 'RESET'; SET DEBUG_SYNC= 'RESET';
DROP TABLE IF EXISTS t1; DROP TABLE IF EXISTS t1;
CREATE TABLE t1 (c1 INT); CREATE TABLE t1 (c1 INT);
LOCK TABLE t1 WRITE; LOCK TABLE t1 READ;
connection con1 connection con1
SET DEBUG_SYNC= 'wait_for_lock SIGNAL locked EXECUTE 2'; SET DEBUG_SYNC= 'wait_for_lock SIGNAL locked EXECUTE 2';
INSERT INTO t1 VALUES (1); INSERT INTO t1 VALUES (1);
......
...@@ -79,8 +79,8 @@ drop table t1; ...@@ -79,8 +79,8 @@ drop table t1;
drop database if exists mysqltest; drop database if exists mysqltest;
drop table if exists t1; drop table if exists t1;
create table t1 (i int); create table t1 (i int);
lock tables t1 read;
create database mysqltest; create database mysqltest;
lock tables t1 read;
drop table t1; drop table t1;
show open tables; show open tables;
drop database mysqltest; drop database mysqltest;
......
...@@ -7,12 +7,16 @@ DROP DATABASE IF EXISTS mysql_test; ...@@ -7,12 +7,16 @@ DROP DATABASE IF EXISTS mysql_test;
CREATE DATABASE mysql_test; CREATE DATABASE mysql_test;
CREATE TABLE mysql_test.t1(a INT); CREATE TABLE mysql_test.t1(a INT);
CREATE TABLE mysql_test.t2(b INT);
CREATE TABLE mysql_test.t3(c INT);
SET SESSION DEBUG = "+d,bug43138"; SET SESSION DEBUG = "+d,bug43138";
DROP DATABASE mysql_test; DROP DATABASE mysql_test;
Warnings: Warnings:
Error 1051 Unknown table 't1' Error 1051 Unknown table 't1'
Error 1051 Unknown table 't2'
Error 1051 Unknown table 't3'
SET SESSION DEBUG = "-d,bug43138"; SET SESSION DEBUG = "-d,bug43138";
......
...@@ -33,6 +33,9 @@ flush tables with read lock; ...@@ -33,6 +33,9 @@ flush tables with read lock;
ERROR HY000: Can't execute the given command because you have active locked tables or an active transaction ERROR HY000: Can't execute the given command because you have active locked tables or an active transaction
lock table t1 read; lock table t1 read;
flush tables with read lock; flush tables with read lock;
ERROR HY000: Can't execute the given command because you have active locked tables or an active transaction
unlock tables;
flush tables with read lock;
lock table t1 write; lock table t1 write;
ERROR HY000: Can't execute the query because you have a conflicting read lock ERROR HY000: Can't execute the query because you have a conflicting read lock
lock table t1 read; lock table t1 read;
...@@ -46,6 +49,7 @@ flush tables with read lock; ...@@ -46,6 +49,7 @@ flush tables with read lock;
ERROR HY000: Can't execute the given command because you have active locked tables or an active transaction ERROR HY000: Can't execute the given command because you have active locked tables or an active transaction
lock table t1 read, t2 read, t3 read; lock table t1 read, t2 read, t3 read;
flush tables with read lock; flush tables with read lock;
ERROR HY000: Can't execute the given command because you have active locked tables or an active transaction
unlock tables; unlock tables;
drop table t1, t2, t3; drop table t1, t2, t3;
create table t1 (c1 int); create table t1 (c1 int);
...@@ -69,6 +73,7 @@ ERROR HY000: Can't execute the given command because you have active locked tabl ...@@ -69,6 +73,7 @@ ERROR HY000: Can't execute the given command because you have active locked tabl
unlock tables; unlock tables;
lock tables t1 read; lock tables t1 read;
flush tables with read lock; flush tables with read lock;
ERROR HY000: Can't execute the given command because you have active locked tables or an active transaction
unlock tables; unlock tables;
drop table t1, t2; drop table t1, t2;
set session low_priority_updates=default; set session low_priority_updates=default;
...@@ -89,3 +94,20 @@ unlock tables; ...@@ -89,3 +94,20 @@ unlock tables;
set global general_log= @old_general_log; set global general_log= @old_general_log;
set global read_only= @old_read_only; set global read_only= @old_read_only;
End of 5.1 tests End of 5.1 tests
#
# Additional test for bug #51136 "Crash in pthread_rwlock_rdlock
# on TEMPORARY + HANDLER + LOCK + SP".
# Also see the main test for this bug in include/handler.inc.
#
drop tables if exists t1, t2;
create table t1 (i int);
create temporary table t2 (j int);
flush tables with read lock;
lock table t2 read;
# This commit should not release any MDL locks.
commit;
# The below statement crashed before the bug fix as it
# has attempted to release global shared metadata lock
# which was already released by commit.
unlock tables;
drop tables t1, t2;
# Save the initial number of concurrent sessions
# Establish connection con1 (user=root) # Establish connection con1 (user=root)
# Establish connection con2 (user=root) # Establish connection con2 (user=root)
# Establish connection con3 (user=root) # Establish connection con3 (user=root)
...@@ -8,15 +9,17 @@ BEGIN; ...@@ -8,15 +9,17 @@ BEGIN;
INSERT INTO t1 VALUES(1); INSERT INTO t1 VALUES(1);
# Switch to connection con2 # Switch to connection con2
FLUSH TABLES WITH READ LOCK; FLUSH TABLES WITH READ LOCK;
SELECT * FROM t1;
a
# Switch to connection con1 # Switch to connection con1
# Sending:
COMMIT; COMMIT;
# Switch to connection con2 # Switch to connection con2
# Wait until COMMIT gets blocked.
# Verify that 'con1' was blocked and data did not move.
SELECT * FROM t1; SELECT * FROM t1;
a a
UNLOCK TABLES; UNLOCK TABLES;
# Switch to connection con1 # Switch to connection con1
# Reaping COMMIT
# Switch to connection con1 # Switch to connection con1
BEGIN; BEGIN;
SELECT * FROM t1 FOR UPDATE; SELECT * FROM t1 FOR UPDATE;
...@@ -32,6 +35,7 @@ COMMIT; ...@@ -32,6 +35,7 @@ COMMIT;
# Switch to connection con2 # Switch to connection con2
a a
1 1
COMMIT;
# Switch to connection con3 # Switch to connection con3
UNLOCK TABLES; UNLOCK TABLES;
# Switch to connection con2 # Switch to connection con2
...@@ -40,8 +44,6 @@ COMMIT; ...@@ -40,8 +44,6 @@ COMMIT;
BEGIN; BEGIN;
INSERT INTO t1 VALUES(10); INSERT INTO t1 VALUES(10);
FLUSH TABLES WITH READ LOCK; FLUSH TABLES WITH READ LOCK;
COMMIT;
UNLOCK TABLES;
# Switch to connection con2 # Switch to connection con2
FLUSH TABLES WITH READ LOCK; FLUSH TABLES WITH READ LOCK;
UNLOCK TABLES; UNLOCK TABLES;
...@@ -53,5 +55,11 @@ a ...@@ -53,5 +55,11 @@ a
SHOW CREATE DATABASE test; SHOW CREATE DATABASE test;
Database Create Database Database Create Database
test CREATE DATABASE `test` /*!40100 DEFAULT CHARACTER SET latin1 */ test CREATE DATABASE `test` /*!40100 DEFAULT CHARACTER SET latin1 */
DROP TABLE t1; COMMIT;
# Cleanup
# Switch to connection default and close connections con1, con2, con3 # Switch to connection default and close connections con1, con2, con3
# We commit open transactions when we disconnect: only then we can
# drop the table.
DROP TABLE t1;
# End of 4.1 tests
# Wait till all disconnects are completed
# Save the initial number of concurrent sessions
# Establish connection con1 (user=root) # Establish connection con1 (user=root)
# Establish connection con2 (user=root) # Establish connection con2 (user=root)
# Switch to connection con1 # Switch to connection con1
CREATE TABLE t1 (a INT) ENGINE=innodb; CREATE TABLE t1 (a INT) ENGINE=innodb;
RESET MASTER; RESET MASTER;
SET AUTOCOMMIT=0; SET AUTOCOMMIT=0;
INSERT t1 VALUES (1); SELECT 1;
1
1
# Switch to connection con2 # Switch to connection con2
FLUSH TABLES WITH READ LOCK; FLUSH TABLES WITH READ LOCK;
SHOW MASTER STATUS; SHOW MASTER STATUS;
File Position Binlog_Do_DB Binlog_Ignore_DB File Position Binlog_Do_DB Binlog_Ignore_DB
master-bin.000001 107 master-bin.000001 107
# Switch to connection con1 # Switch to connection con1
COMMIT; INSERT INTO t1 VALUES (1);
# Switch to connection con2 # Switch to connection con2
SHOW MASTER STATUS; SHOW MASTER STATUS;
File Position Binlog_Do_DB Binlog_Ignore_DB File Position Binlog_Do_DB Binlog_Ignore_DB
...@@ -20,4 +23,12 @@ UNLOCK TABLES; ...@@ -20,4 +23,12 @@ UNLOCK TABLES;
# Switch to connection con1 # Switch to connection con1
DROP TABLE t1; DROP TABLE t1;
SET AUTOCOMMIT=1; SET AUTOCOMMIT=1;
create table t1 (a int) engine=innodb;
flush tables with read lock;
begin;
insert into t1 values (1);;
unlock tables;
commit;
drop table t1;
# Switch to connection default and close connections con1 and con2 # Switch to connection default and close connections con1 and con2
# Wait till all disconnects are completed
...@@ -3,21 +3,14 @@ create table t1 (a int not null auto_increment primary key); ...@@ -3,21 +3,14 @@ create table t1 (a int not null auto_increment primary key);
insert into t1 values(0); insert into t1 values(0);
lock table t1 read; lock table t1 read;
flush table t1; flush table t1;
ERROR HY000: Table 't1' was locked with a READ lock and can't be updated
unlock tables;
lock table t1 write;
flush table t1;
check table t1; check table t1;
Table Op Msg_type Msg_text Table Op Msg_type Msg_text
test.t1 check status OK test.t1 check status OK
unlock tables; unlock tables;
lock table t1 read;
lock table t1 read;
flush table t1;
select * from t1;
a
1
unlock tables;
select * from t1;
a
1
unlock tables;
lock table t1 write; lock table t1 write;
lock table t1 read; lock table t1 read;
flush table t1; flush table t1;
...@@ -26,7 +19,7 @@ a ...@@ -26,7 +19,7 @@ a
1 1
unlock tables; unlock tables;
unlock tables; unlock tables;
lock table t1 read; lock table t1 write;
lock table t1 write; lock table t1 write;
flush table t1; flush table t1;
select * from t1; select * from t1;
......
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
...@@ -1682,6 +1682,57 @@ DROP USER nonpriv; ...@@ -1682,6 +1682,57 @@ DROP USER nonpriv;
DROP TABLE db1.t1; DROP TABLE db1.t1;
DROP DATABASE db1; DROP DATABASE db1;
End of 5.1 tests. End of 5.1 tests.
#
# Additional test for WL#3726 "DDL locking for all metadata objects"
# To avoid possible deadlocks process of filling of I_S tables should
# use high-priority metadata lock requests when opening tables.
# Below we just test that we really use high-priority lock request
# since reproducing a deadlock will require much more complex test.
#
drop tables if exists t1, t2, t3;
create table t1 (i int);
create table t2 (j int primary key auto_increment);
# Switching to connection 'con3726_1'
lock table t2 read;
# Switching to connection 'con3726_2'
# RENAME below will be blocked by 'lock table t2 read' above but
# will add two pending requests for exclusive metadata locks.
rename table t2 to t3;
# Switching to connection 'default'
# These statements should not be blocked by pending lock requests
select table_name, column_name, data_type from information_schema.columns
where table_schema = 'test' and table_name in ('t1', 't2');
table_name column_name data_type
t1 i int
t2 j int
select table_name, auto_increment from information_schema.tables
where table_schema = 'test' and table_name in ('t1', 't2');
table_name auto_increment
t1 NULL
t2 1
# Switching to connection 'con3726_1'
unlock tables;
# Switching to connection 'con3726_2'
# Switching to connection 'default'
drop tables t1, t3;
EXPLAIN SELECT * FROM INFORMATION_SCHEMA.KEY_COLUMN_USAGE;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE KEY_COLUMN_USAGE ALL NULL NULL NULL NULL NULL Open_full_table; Scanned all databases
EXPLAIN SELECT * FROM INFORMATION_SCHEMA.PARTITIONS WHERE TABLE_NAME='t1';
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE PARTITIONS ALL NULL TABLE_NAME NULL NULL NULL Using where; Open_full_table; Scanned 1 database
EXPLAIN SELECT * FROM INFORMATION_SCHEMA.REFERENTIAL_CONSTRAINTS
WHERE CONSTRAINT_SCHEMA='test';
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE REFERENTIAL_CONSTRAINTS ALL NULL CONSTRAINT_SCHEMA NULL NULL NULL Using where; Open_full_table; Scanned 1 database
EXPLAIN SELECT * FROM INFORMATION_SCHEMA.TABLE_CONSTRAINTS
WHERE TABLE_NAME='t1' and TABLE_SCHEMA='test';
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE TABLE_CONSTRAINTS ALL NULL TABLE_SCHEMA,TABLE_NAME NULL NULL NULL Using where; Open_full_table; Scanned 0 databases
EXPLAIN SELECT * FROM INFORMATION_SCHEMA.TRIGGERS
WHERE EVENT_OBJECT_SCHEMA='test';
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE TRIGGERS ALL NULL EVENT_OBJECT_SCHEMA NULL NULL NULL Using where; Open_frm_only; Scanned 1 database
create table information_schema.t1 (f1 INT); create table information_schema.t1 (f1 INT);
ERROR 42000: Access denied for user 'root'@'localhost' to database 'information_schema' ERROR 42000: Access denied for user 'root'@'localhost' to database 'information_schema'
drop table information_schema.t1; drop table information_schema.t1;
...@@ -1720,28 +1771,10 @@ ERROR 42000: Access denied for user 'root'@'localhost' to database 'information_ ...@@ -1720,28 +1771,10 @@ ERROR 42000: Access denied for user 'root'@'localhost' to database 'information_
LOCK TABLES t1 READ, information_schema.tables READ; LOCK TABLES t1 READ, information_schema.tables READ;
ERROR 42000: Access denied for user 'root'@'localhost' to database 'information_schema' ERROR 42000: Access denied for user 'root'@'localhost' to database 'information_schema'
DROP TABLE t1; DROP TABLE t1;
EXPLAIN SELECT * FROM INFORMATION_SCHEMA.KEY_COLUMN_USAGE;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE KEY_COLUMN_USAGE ALL NULL NULL NULL NULL NULL Open_full_table; Scanned all databases
EXPLAIN SELECT * FROM INFORMATION_SCHEMA.PARTITIONS WHERE TABLE_NAME='t1';
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE PARTITIONS ALL NULL TABLE_NAME NULL NULL NULL Using where; Open_full_table; Scanned 1 database
EXPLAIN SELECT * FROM INFORMATION_SCHEMA.REFERENTIAL_CONSTRAINTS
WHERE CONSTRAINT_SCHEMA='test';
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE REFERENTIAL_CONSTRAINTS ALL NULL CONSTRAINT_SCHEMA NULL NULL NULL Using where; Open_full_table; Scanned 1 database
EXPLAIN SELECT * FROM INFORMATION_SCHEMA.TABLE_CONSTRAINTS
WHERE TABLE_NAME='t1' and TABLE_SCHEMA='test';
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE TABLE_CONSTRAINTS ALL NULL TABLE_SCHEMA,TABLE_NAME NULL NULL NULL Using where; Open_full_table; Scanned 0 databases
EXPLAIN SELECT * FROM INFORMATION_SCHEMA.TRIGGERS
WHERE EVENT_OBJECT_SCHEMA='test';
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE TRIGGERS ALL NULL EVENT_OBJECT_SCHEMA NULL NULL NULL Using where; Open_frm_only; Scanned 1 database
SELECT * SELECT *
FROM INFORMATION_SCHEMA.KEY_COLUMN_USAGE FROM INFORMATION_SCHEMA.KEY_COLUMN_USAGE
LEFT JOIN INFORMATION_SCHEMA.COLUMNS LEFT JOIN INFORMATION_SCHEMA.COLUMNS
USING (TABLE_SCHEMA, TABLE_NAME, COLUMN_NAME) USING (TABLE_SCHEMA, TABLE_NAME, COLUMN_NAME)
WHERE COLUMNS.TABLE_SCHEMA = 'test' WHERE COLUMNS.TABLE_SCHEMA = 'test'
AND COLUMNS.TABLE_NAME = 't1'; AND COLUMNS.TABLE_NAME = 't1';
TABLE_SCHEMA TABLE_NAME COLUMN_NAME CONSTRAINT_CATALOG CONSTRAINT_SCHEMA CONSTRAINT_NAME TABLE_CATALOG ORDINAL_POSITION POSITION_IN_UNIQUE_CONSTRAINT REFERENCED_TABLE_SCHEMA REFERENCED_TABLE_NAME REFERENCED_COLUMN_NAME TABLE_CATALOG ORDINAL_POSITION COLUMN_DEFAULT IS_NULLABLE DATA_TYPE CHARACTER_MAXIMUM_LENGTH CHARACTER_OCTET_LENGTH NUMERIC_PRECISION NUMERIC_SCALE CHARACTER_SET_NAME COLLATION_NAME COLUMN_TYPE COLUMN_KEY EXTRA PRIVILEGES COLUMN_COMMENT TABLE_SCHEMA TABLE_NAME COLUMN_NAME CONSTRAINT_CATALOG CONSTRAINT_SCHEMA CONSTRAINT_NAME TABLE_CATALOG ORDINAL_POSITION POSITION_IN_UNIQUE_CONSTRAINT REFERENCED_TABLE_SCHEMA REFERENCED_TABLE_NAME REFERENCED_COLUMN_NAME TABLE_CATALOG ORDINAL_POSITION COLUMN_DEFAULT IS_NULLABLE DATA_TYPE CHARACTER_MAXIMUM_LENGTH CHARACTER_OCTET_LENGTH NUMERIC_PRECISION NUMERIC_SCALE CHARACTER_SET_NAME COLLATION_NAME COLUMN_TYPE COLUMN_KEY EXTRA PRIVILEGES COLUMN_COMMENT
...@@ -25,6 +25,12 @@ id x ...@@ -25,6 +25,12 @@ id x
0 2 0 2
commit; commit;
drop table t1; drop table t1;
#
# Old lock method (where LOCK TABLE was ignored by InnoDB) no longer
# works due to fix for bugs #46272 "MySQL 5.4.4, new MDL: unnecessary
# deadlock" and bug #37346 "innodb does not detect deadlock between
# update and alter table".
#
set @@innodb_table_locks=0; set @@innodb_table_locks=0;
create table t1 (id integer primary key, x integer) engine=INNODB; create table t1 (id integer primary key, x integer) engine=INNODB;
insert into t1 values(0, 0),(1,1),(2,2); insert into t1 values(0, 0),(1,1),(2,2);
...@@ -32,26 +38,27 @@ commit; ...@@ -32,26 +38,27 @@ commit;
SELECT * from t1 where id = 0 FOR UPDATE; SELECT * from t1 where id = 0 FOR UPDATE;
id x id x
0 0 0 0
# Connection 'con2'.
set autocommit=0; set autocommit=0;
set @@innodb_table_locks=0; set @@innodb_table_locks=0;
lock table t1 write; # The following statement should block because SQL-level lock
update t1 set x=10 where id = 2; # is taken on t1 which will wait until concurrent transaction
SELECT * from t1 where id = 2; # is commited.
id x # Sending:
2 2 lock table t1 write;;
UPDATE t1 set x=3 where id = 2; # Connection 'con1'.
commit; # Wait until LOCK TABLE is blocked on SQL-level lock.
SELECT * from t1; # We should be able to do UPDATEs and SELECTs within transaction.
update t1 set x=1 where id = 0;
select * from t1;
id x id x
0 0 0 1
1 1 1 1
2 3 2 2
# Unblock LOCK TABLE.
commit; commit;
# Connection 'con2'.
# Reap LOCK TABLE.
unlock tables; unlock tables;
commit; # Connection 'con1'.
select * from t1;
id x
0 0
1 1
2 10
drop table t1; drop table t1;
...@@ -2834,10 +2834,10 @@ t2 CREATE TABLE `t2` ( ...@@ -2834,10 +2834,10 @@ t2 CREATE TABLE `t2` (
DROP TABLE t2,t1; DROP TABLE t2,t1;
create table t1(a int not null, b int, c int, d int, primary key(a)) engine=innodb; create table t1(a int not null, b int, c int, d int, primary key(a)) engine=innodb;
insert into t1(a) values (1),(2),(3); insert into t1(a) values (1),(2),(3);
create trigger t1t before insert on t1 for each row begin set NEW.b = NEW.a * 10 + 5, NEW.c = NEW.a / 10; end |
commit; commit;
set autocommit = 0; set autocommit = 0;
update t1 set b = 5 where a = 2; update t1 set b = 5 where a = 2;
create trigger t1t before insert on t1 for each row begin set NEW.b = NEW.a * 10 + 5, NEW.c = NEW.a / 10; end |
set autocommit = 0; set autocommit = 0;
insert into t1(a) values (10),(20),(30),(40),(50),(60),(70),(80),(90),(100), insert into t1(a) values (10),(20),(30),(40),(50),(60),(70),(80),(90),(100),
(11),(21),(31),(41),(51),(61),(71),(81),(91),(101), (11),(21),(31),(41),(51),(61),(71),(81),(91),(101),
...@@ -2885,6 +2885,7 @@ insert into t2(a) values(8); ...@@ -2885,6 +2885,7 @@ insert into t2(a) values(8);
delete from t2 where a = 3; delete from t2 where a = 3;
update t4 set b = b + 1 where a = 3; update t4 set b = b + 1 where a = 3;
commit; commit;
commit;
drop trigger t1t; drop trigger t1t;
drop trigger t2t; drop trigger t2t;
drop trigger t3t; drop trigger t3t;
......
...@@ -1105,6 +1105,8 @@ CREATE PROCEDURE p1 () ...@@ -1105,6 +1105,8 @@ CREATE PROCEDURE p1 ()
BEGIN BEGIN
DECLARE i INT DEFAULT 50; DECLARE i INT DEFAULT 50;
DECLARE cnt INT; DECLARE cnt INT;
# Continue even in the presence of ER_LOCK_DEADLOCK.
DECLARE CONTINUE HANDLER FOR 1213 BEGIN END;
START TRANSACTION; START TRANSACTION;
ALTER TABLE t1 ENGINE=InnoDB; ALTER TABLE t1 ENGINE=InnoDB;
COMMIT; COMMIT;
...@@ -1618,6 +1620,7 @@ a b ...@@ -1618,6 +1620,7 @@ a b
SELECT * FROM t1; SELECT * FROM t1;
a b a b
1 init+con1+con2 1 init+con1+con2
COMMIT;
# Switch to connection con1 # Switch to connection con1
# 3. test for updated key column: # 3. test for updated key column:
TRUNCATE t1; TRUNCATE t1;
......
#
# Bug #22876 Four-way deadlock
#
DROP TABLE IF EXISTS t1;
# Connection 1
set @@autocommit=0;
CREATE TABLE t1(s1 INT UNIQUE) ENGINE=innodb;
INSERT INTO t1 VALUES (1);
# Connection 2
set @@autocommit=0;
INSERT INTO t1 VALUES (2);
INSERT INTO t1 VALUES (1);
# Connection 3
set @@autocommit=0;
DROP TABLE t1;
# Connection 1
# Connection 1 is now holding the lock.
# Issuing insert from connection 1 while connection 2&3
# is waiting for the lock should give a deadlock error.
INSERT INTO t1 VALUES (2);
ERROR 40001: Deadlock found when trying to get lock; try restarting transaction
# Cleanup
commit;
set @@autocommit=1;
commit;
set @@autocommit=1;
set @@autocommit=1;
#
# Test for bug #37346 "innodb does not detect deadlock between update
# and alter table".
#
drop table if exists t1;
create table t1 (c1 int primary key, c2 int, c3 int) engine=InnoDB;
insert into t1 values (1,1,0),(2,2,0),(3,3,0),(4,4,0),(5,5,0);
begin;
# Run statement which acquires X-lock on one of table's rows.
update t1 set c3=c3+1 where c2=3;
#
# Switching to connection 'con37346'.
# The below ALTER TABLE statement should wait till transaction
# in connection 'default' is complete and then succeed.
# It should not deadlock or fail with ER_LOCK_DEADLOCK error.
# Sending:
alter table t1 add column c4 int;;
#
# Switching to connection 'default'.
# Wait until the above ALTER TABLE gets blocked because this
# connection holds SW metadata lock on table to be altered.
# The below statement should succeed. It should not
# deadlock or end with ER_LOCK_DEADLOCK error.
update t1 set c3=c3+1 where c2=4;
# Unblock ALTER TABLE by committing transaction.
commit;
#
# Switching to connection 'con37346'.
# Reaping ALTER TABLE.
#
# Switching to connection 'default'.
drop table t1;
#
# Bug #42147 Concurrent DML and LOCK TABLE ... READ for InnoDB
# table cause warnings in errlog
#
#
# Note that this test for now relies on a global suppression of
# the warning "Found lock of type 6 that is write and read locked"
# This suppression rule can be removed once Bug#42147 is properly
# fixed. See bug page for more info.
#
DROP TABLE IF EXISTS t1;
CREATE TABLE t1 (i INT) engine= innodb;
# Connection 2
# Get user-level lock
SELECT get_lock('bug42147_lock', 60);
get_lock('bug42147_lock', 60)
1
# Connection 1
INSERT INTO t1 SELECT get_lock('bug42147_lock', 60);
# Connection 2
LOCK TABLES t1 READ;
SELECT release_lock('bug42147_lock');
release_lock('bug42147_lock')
1
# Connection 1
# Connection 2
UNLOCK TABLES;
# Connection 1
DROP TABLE t1;
#
# Bug 42074 concurrent optimize table and
# alter table = Assertion failed: thd->is_error()
#
DROP TABLE IF EXISTS t1;
# Create InnoDB table
CREATE TABLE t1 (id INT) engine=innodb;
# Connection 1
# Start optimizing table
SET DEBUG_SYNC='ha_admin_try_alter SIGNAL optimize_started WAIT_FOR table_altered';
OPTIMIZE TABLE t1;
# Connection 2
# Change table to engine=memory
SET DEBUG_SYNC='now WAIT_FOR optimize_started';
ALTER TABLE t1 engine=memory;
SET DEBUG_SYNC='now SIGNAL table_altered';
# Connection 1
# Complete optimization
Table Op Msg_type Msg_text
test.t1 optimize note Table does not support optimize, doing recreate + analyze instead
test.t1 optimize error Got error -1 from storage engine
test.t1 optimize status Operation failed
Warnings:
Error 1030 Got error -1 from storage engine
DROP TABLE t1;
SET DEBUG_SYNC='RESET';
...@@ -138,4 +138,107 @@ KILL CONNECTION_ID(); ...@@ -138,4 +138,107 @@ KILL CONNECTION_ID();
# of close of the connection socket # of close of the connection socket
SELECT 1; SELECT 1;
Got one of the listed errors Got one of the listed errors
#
# Additional test for WL#3726 "DDL locking for all metadata objects"
# Check that DDL and DML statements waiting for metadata locks can
# be killed. Note that we don't cover all situations here since it
# can be tricky to write test case for some of them (e.g. REPAIR or
# ALTER and other statements under LOCK TABLES).
#
drop tables if exists t1, t2, t3;
create table t1 (i int primary key);
# Test for RENAME TABLE
# Switching to connection 'blocker'
lock table t1 read;
# Switching to connection 'ddl'
rename table t1 to t2;
# Switching to connection 'default'
kill query ID;
# Switching to connection 'ddl'
ERROR 70100: Query execution was interrupted
# Test for DROP TABLE
drop table t1;
# Switching to connection 'default'
kill query ID;
# Switching to connection 'ddl'
ERROR 70100: Query execution was interrupted
# Test for CREATE TRIGGER
create trigger t1_bi before insert on t1 for each row set @a:=1;
# Switching to connection 'default'
kill query ID;
# Switching to connection 'ddl'
ERROR 70100: Query execution was interrupted
#
# Tests for various kinds of ALTER TABLE
#
# Full-blown ALTER which should copy table
alter table t1 add column j int;
# Switching to connection 'default'
kill query ID;
# Switching to connection 'ddl'
ERROR 70100: Query execution was interrupted
# Two kinds of simple ALTER
alter table t1 rename to t2;
# Switching to connection 'default'
kill query ID;
# Switching to connection 'ddl'
ERROR 70100: Query execution was interrupted
alter table t1 disable keys;
# Switching to connection 'default'
kill query ID;
# Switching to connection 'ddl'
ERROR 70100: Query execution was interrupted
# Fast ALTER
alter table t1 alter column i set default 100;
# Switching to connection 'default'
kill query ID;
# Switching to connection 'ddl'
ERROR 70100: Query execution was interrupted
# Special case which is triggered only for MERGE tables.
# Switching to connection 'blocker'
unlock tables;
create table t2 (i int primary key) engine=merge union=(t1);
lock tables t2 read;
# Switching to connection 'ddl'
alter table t2 alter column i set default 100;
# Switching to connection 'default'
kill query ID;
# Switching to connection 'ddl'
ERROR 70100: Query execution was interrupted
# Test for DML waiting for meta-data lock
# Switching to connection 'blocker'
unlock tables;
drop table t2;
create table t2 (k int);
lock tables t1 read;
# Switching to connection 'ddl'
rename tables t1 to t3, t2 to t1;
# Switching to connection 'dml'
insert into t2 values (1);
# Switching to connection 'default'
kill query ID2;
# Switching to connection 'dml'
ERROR 70100: Query execution was interrupted
# Switching to connection 'blocker'
unlock tables;
# Switching to connection 'ddl'
# Test for DML waiting for tables to be flushed
# Switching to connection 'blocker'
lock tables t1 read;
# Switching to connection 'ddl'
# Let us mark locked table t1 as old
flush tables;
# Switching to connection 'dml'
select * from t1;
# Switching to connection 'default'
kill query ID2;
# Switching to connection 'dml'
ERROR 70100: Query execution was interrupted
# Switching to connection 'blocker'
unlock tables;
# Switching to connection 'ddl'
# Cleanup.
# Switching to connection 'default'
drop table t3;
drop table t1;
set @@global.concurrent_insert= @old_concurrent_insert; set @@global.concurrent_insert= @old_concurrent_insert;
This diff is collapsed.
This diff is collapsed.
...@@ -6,6 +6,7 @@ ...@@ -6,6 +6,7 @@
# statements which tried to acquire stronger write lock (TL_WRITE, # statements which tried to acquire stronger write lock (TL_WRITE,
# TL_WRITE_ALLOW_READ) on this table might have led to deadlock. # TL_WRITE_ALLOW_READ) on this table might have led to deadlock.
drop table if exists t1; drop table if exists t1;
drop view if exists v1;
# Create auxiliary connections used through the test. # Create auxiliary connections used through the test.
# Reset DEBUG_SYNC facility before using it. # Reset DEBUG_SYNC facility before using it.
set debug_sync= 'RESET'; set debug_sync= 'RESET';
...@@ -14,6 +15,9 @@ set debug_sync= 'RESET'; ...@@ -14,6 +15,9 @@ set debug_sync= 'RESET';
set @old_general_log = @@global.general_log; set @old_general_log = @@global.general_log;
set @@global.general_log= OFF; set @@global.general_log= OFF;
create table t1 (i int) engine=InnoDB; create table t1 (i int) engine=InnoDB;
# We have to use view in order to make LOCK TABLES avoid
# acquiring SNRW metadata lock on table.
create view v1 as select * from t1;
insert into t1 values (1); insert into t1 values (1);
# Prepare user lock which will be used for resuming execution of # Prepare user lock which will be used for resuming execution of
# the first statement after it acquires TL_WRITE_ALLOW_WRITE lock. # the first statement after it acquires TL_WRITE_ALLOW_WRITE lock.
...@@ -36,7 +40,7 @@ select count(*) > 0 from t1 as a, t1 as b for update;; ...@@ -36,7 +40,7 @@ select count(*) > 0 from t1 as a, t1 as b for update;;
# acquiring lock for the the first instance of 't1'. # acquiring lock for the the first instance of 't1'.
set debug_sync= 'now WAIT_FOR parked'; set debug_sync= 'now WAIT_FOR parked';
# Send LOCK TABLE statement which will try to get TL_WRITE lock on 't1': # Send LOCK TABLE statement which will try to get TL_WRITE lock on 't1':
lock table t1 write;; lock table v1 write;;
# Switch to connection 'default'. # Switch to connection 'default'.
# Wait until this LOCK TABLES statement starts waiting for table lock. # Wait until this LOCK TABLES statement starts waiting for table lock.
# Allow SELECT ... FOR UPDATE to resume. # Allow SELECT ... FOR UPDATE to resume.
...@@ -56,6 +60,9 @@ release_lock("lock_bug45143_wait") ...@@ -56,6 +60,9 @@ release_lock("lock_bug45143_wait")
1 1
# Switch to connection 'con_bug45143_1'. # Switch to connection 'con_bug45143_1'.
# Reap INSERT statement. # Reap INSERT statement.
# In Statement and Mixed replication mode we get here "Unsafe
# for binlog" warnings. In row mode there are no warnings.
# Hide the discrepancy.
# Switch to connection 'con_bug45143_3'. # Switch to connection 'con_bug45143_3'.
# Reap LOCK TABLES statement. # Reap LOCK TABLES statement.
unlock tables; unlock tables;
...@@ -63,4 +70,25 @@ unlock tables; ...@@ -63,4 +70,25 @@ unlock tables;
# Do clean-up. # Do clean-up.
set debug_sync= 'RESET'; set debug_sync= 'RESET';
set @@global.general_log= @old_general_log; set @@global.general_log= @old_general_log;
drop view v1;
drop table t1; drop table t1;
#
# Bug#50821 Deadlock between LOCK TABLES and ALTER TABLE
#
DROP TABLE IF EXISTS t1, t2;
CREATE TABLE t1(id INT);
CREATE TABLE t2(id INT);
# Connection con2
START TRANSACTION;
SELECT * FROM t1;
id
# Connection default
# Sending:
ALTER TABLE t1 ADD COLUMN j INT;
# Connection con2
# This used to cause a deadlock.
INSERT INTO t2 SELECT * FROM t1;
COMMIT;
# Connection default
# Reaping ALTER TABLE t1 ADD COLUMN j INT
DROP TABLE t1, t2;
...@@ -226,10 +226,9 @@ drop table t_bug44738_UPPERCASE; ...@@ -226,10 +226,9 @@ drop table t_bug44738_UPPERCASE;
create table t_bug44738_UPPERCASE (i int); create table t_bug44738_UPPERCASE (i int);
drop table t_bug44738_UPPERCASE; drop table t_bug44738_UPPERCASE;
# Finally, let us check that another issue which was exposed by # Finally, let us check that another issue which was exposed by
# the original test case is solved. I.e. that fuse in CREATE TABLE # the original test case is solved. I.e. that the table is not
# which ensures that table is not created if there is an entry for # created if there is an entry for it in TDC even though it was
# it in TDC even though it was removed from disk uses normalized # removed from disk.
# version of the table name.
create table t_bug44738_UPPERCASE (i int) engine = myisam; create table t_bug44738_UPPERCASE (i int) engine = myisam;
# Load table definition in TDC. # Load table definition in TDC.
select table_schema, table_name, table_comment from information_schema.tables select table_schema, table_name, table_comment from information_schema.tables
...@@ -237,10 +236,13 @@ where table_schema = 'test' and table_name like 't_bug44738_%'; ...@@ -237,10 +236,13 @@ where table_schema = 'test' and table_name like 't_bug44738_%';
table_schema table_name table_comment table_schema table_name table_comment
test t_bug44738_UPPERCASE test t_bug44738_UPPERCASE
# Simulate manual removal of the table. # Simulate manual removal of the table.
# After manual removal of table still there should be an entry for table # Check that still there is an entry for table in TDC.
# in TDC so attempt to create table with the same name should fail. show open tables like 't_bug44738_%';
Database Table In_use Name_locked
test t_bug44738_uppercase 0 0
# So attempt to create table with the same name should fail.
create table t_bug44738_UPPERCASE (i int); create table t_bug44738_UPPERCASE (i int);
ERROR 42S01: Table 't_bug44738_uppercase' already exists ERROR HY000: Can't find file: 't_bug44738_uppercase' (errno: 2)
# And should succeed after FLUSH TABLES. # And should succeed after FLUSH TABLES.
flush tables; flush tables;
create table t_bug44738_UPPERCASE (i int); create table t_bug44738_UPPERCASE (i int);
......
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
...@@ -102,7 +102,7 @@ a b ...@@ -102,7 +102,7 @@ a b
# Switch to connection con1 # Switch to connection con1
# 3. test for updated key column: # 3. test for updated key column:
TRUNCATE t1; TRUNCATE t1;
TRUNCATE t2; DELETE FROM t2;
INSERT INTO t1 VALUES (1,'init'); INSERT INTO t1 VALUES (1,'init');
BEGIN; BEGIN;
UPDATE t1 SET a = 2, b = CONCAT(b, '+con1') WHERE a = 1; UPDATE t1 SET a = 2, b = CONCAT(b, '+con1') WHERE a = 1;
......
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment