This commit is contained in:
Kristofer Pettersson 2009-10-06 09:40:30 +02:00
commit 499121a080
47 changed files with 4675 additions and 54 deletions

View File

@ -3064,3 +3064,4 @@ sql/share/spanish
sql/share/swedish sql/share/swedish
sql/share/ukrainian sql/share/ukrainian
libmysqld/examples/mysqltest.cc libmysqld/examples/mysqltest.cc
libmysqld/debug_sync.cc

View File

@ -66,6 +66,12 @@ IF(EXTRA_DEBUG)
ADD_DEFINITIONS(-D EXTRA_DEBUG) ADD_DEFINITIONS(-D EXTRA_DEBUG)
ENDIF(EXTRA_DEBUG) ENDIF(EXTRA_DEBUG)
IF(ENABLED_DEBUG_SYNC)
ADD_DEFINITIONS(-D ENABLED_DEBUG_SYNC)
ENDIF(ENABLED_DEBUG_SYNC)
SET(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -DENABLED_DEBUG_SYNC")
SET(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} -DENABLED_DEBUG_SYNC")
# in some places we use DBUG_OFF # in some places we use DBUG_OFF
SET(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -DDBUG_OFF") SET(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -DDBUG_OFF")
SET(CMAKE_CXX_FLAGS_RELWITHDEBINFO "${CMAKE_CXX_FLAGS_RELWITHDEBINFO} -DDBUG_OFF") SET(CMAKE_CXX_FLAGS_RELWITHDEBINFO "${CMAKE_CXX_FLAGS_RELWITHDEBINFO} -DDBUG_OFF")

View File

@ -1,4 +1,4 @@
# Copyright 2000-2008 MySQL AB, 2008 Sun Microsystems, Inc. # Copyright 2000-2008 MySQL AB, 2009 Sun Microsystems, Inc.
# #
# This program is free software; you can redistribute it and/or modify # This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by # it under the terms of the GNU General Public License as published by
@ -24,7 +24,7 @@ EXTRA_DIST = INSTALL-SOURCE INSTALL-WIN-SOURCE \
SUBDIRS = . include @docs_dirs@ @zlib_dir@ \ SUBDIRS = . include @docs_dirs@ @zlib_dir@ \
@readline_topdir@ sql-common scripts \ @readline_topdir@ sql-common scripts \
@pstack_dir@ \ @pstack_dir@ \
@sql_union_dirs@ unittest storage plugin \ @sql_union_dirs@ unittest \
@sql_server@ @man_dirs@ tests \ @sql_server@ @man_dirs@ tests \
netware @libmysqld_dirs@ \ netware @libmysqld_dirs@ \
mysql-test support-files sql-bench @tools_dirs@ \ mysql-test support-files sql-bench @tools_dirs@ \

View File

@ -1,4 +1,4 @@
/* Copyright (C) 2000-2006 MySQL AB /* Copyright (C) 2000-2006 MySQL AB, 2009 Sun Microsystems, Inc.
This program is free software; you can redistribute it and/or modify This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by it under the terms of the GNU General Public License as published by
@ -583,7 +583,7 @@ error:
counter--; counter--;
pthread_cond_signal(&count_threshhold); pthread_cond_signal(&count_threshhold);
pthread_mutex_unlock(&counter_mutex); pthread_mutex_unlock(&counter_mutex);
my_thread_end(); mysql_thread_end();
return 0; return 0;
} }

View File

@ -1,4 +1,4 @@
/* Copyright (C) 2005 MySQL AB /* Copyright (C) 2005 MySQL AB, 2009 Sun Microsystems, Inc.
This program is free software; you can redistribute it and/or modify This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by it under the terms of the GNU General Public License as published by
@ -1923,7 +1923,7 @@ end:
if (!opt_only_print) if (!opt_only_print)
mysql_close(mysql); mysql_close(mysql);
my_thread_end(); mysql_thread_end();
pthread_mutex_lock(&counter_mutex); pthread_mutex_lock(&counter_mutex);
thread_counter--; thread_counter--;

View File

@ -1648,13 +1648,14 @@ then
DEBUG_OPTIMIZE_CXX="-O" DEBUG_OPTIMIZE_CXX="-O"
OPTIMIZE_CXXFLAGS="$MAX_CXX_OPTIMIZE" OPTIMIZE_CXXFLAGS="$MAX_CXX_OPTIMIZE"
else else
DEBUG_CXXFLAGS="-g"
DEBUG_OPTIMIZE_CXX="" DEBUG_OPTIMIZE_CXX=""
case $SYSTEM_TYPE in case $SYSTEM_TYPE in
*solaris*) *solaris*)
DEBUG_CXXFLAGS="-g0"
OPTIMIZE_CXXFLAGS="-O1" OPTIMIZE_CXXFLAGS="-O1"
;; ;;
*) *)
DEBUG_CXXFLAGS="-g"
OPTIMIZE_CXXFLAGS="-O" OPTIMIZE_CXXFLAGS="-O"
;; ;;
esac esac
@ -1708,6 +1709,23 @@ else
CXXFLAGS="$OPTIMIZE_CXXFLAGS $CXXFLAGS" CXXFLAGS="$OPTIMIZE_CXXFLAGS $CXXFLAGS"
fi fi
# Debug Sync Facility. NOTE: depends on 'with_debug'. Must be behind it.
AC_MSG_CHECKING(if Debug Sync Facility should be enabled.)
AC_ARG_ENABLE(debug_sync,
AS_HELP_STRING([--enable-debug-sync],
[Build a version with Debug Sync Facility]),
[ enable_debug_sync=$enableval ],
[ enable_debug_sync=$with_debug ])
if test "$enable_debug_sync" != "no"
then
AC_DEFINE([ENABLED_DEBUG_SYNC], [1],
[If Debug Sync Facility should be enabled])
AC_MSG_RESULT([yes])
else
AC_MSG_RESULT([no])
fi
# If we should allow error injection tests # If we should allow error injection tests
AC_ARG_WITH(error-inject, AC_ARG_WITH(error-inject,
AC_HELP_STRING([--with-error-inject],[Enable error injection in MySQL Server]), AC_HELP_STRING([--with-error-inject],[Enable error injection in MySQL Server]),
@ -2751,7 +2769,7 @@ server_scripts=
dnl This probably should be cleaned up more - for now the threaded dnl This probably should be cleaned up more - for now the threaded
dnl client is just using plain-old libs. dnl client is just using plain-old libs.
sql_client_dirs="strings regex mysys libmysql" sql_client_dirs="strings regex mysys dbug libmysql"
AM_CONDITIONAL(THREAD_SAFE_CLIENT, test "$THREAD_SAFE_CLIENT" != "no") AM_CONDITIONAL(THREAD_SAFE_CLIENT, test "$THREAD_SAFE_CLIENT" != "no")
@ -2779,15 +2797,20 @@ fi
AC_SUBST(netware_dir) AC_SUBST(netware_dir)
AM_CONDITIONAL(HAVE_NETWARE, test "$netware_dir" = "netware") AM_CONDITIONAL(HAVE_NETWARE, test "$netware_dir" = "netware")
if test "$with_server" = "yes" -o "$THREAD_SAFE_CLIENT" != "no" if test "$with_server" != "no" -o "$THREAD_SAFE_CLIENT" != "no"
then then
AC_DEFINE([THREAD], [1], AC_DEFINE([THREAD], [1],
[Define if you want to have threaded code. This may be undef on client code]) [Define if you want to have threaded code. This may be undef on client code])
# Avoid _PROGRAMS names # Avoid _PROGRAMS names
THREAD_LOBJECTS="thr_alarm.o thr_lock.o thr_mutex.o thr_rwlock.o my_pthread.o my_thr_init.o mf_keycache.o" THREAD_LOBJECTS="thr_alarm.o thr_lock.o thr_mutex.o thr_rwlock.o my_pthread.o my_thr_init.o mf_keycache.o"
AC_SUBST(THREAD_LOBJECTS) AC_SUBST(THREAD_LOBJECTS)
fi
AM_CONDITIONAL(NEED_THREAD, test "$with_server" != "no" -o "$THREAD_SAFE_CLIENT" != "no")
if test "$with_server" != "no"
then
server_scripts="mysqld_safe mysql_install_db" server_scripts="mysqld_safe mysql_install_db"
sql_server_dirs="strings mysys dbug extra regex" sql_server_dirs="strings mysys dbug extra regex storage plugin"
sql_server="vio sql" sql_server="vio sql"
fi fi

View File

@ -172,6 +172,16 @@ extern char *my_strndup(const char *from, size_t length,
#define TRASH(A,B) /* nothing */ #define TRASH(A,B) /* nothing */
#endif #endif
#if defined(ENABLED_DEBUG_SYNC)
extern void (*debug_sync_C_callback_ptr)(const char *, size_t);
#define DEBUG_SYNC_C(_sync_point_name_) do { \
if (debug_sync_C_callback_ptr != NULL) \
(*debug_sync_C_callback_ptr)(STRING_WITH_LEN(_sync_point_name_)); } \
while(0)
#else
#define DEBUG_SYNC_C(_sync_point_name_)
#endif /* defined(ENABLED_DEBUG_SYNC) */
#ifdef HAVE_LARGE_PAGES #ifdef HAVE_LARGE_PAGES
extern uint my_get_large_page_size(void); extern uint my_get_large_page_size(void);
extern uchar * my_large_malloc(size_t size, myf my_flags); extern uchar * my_large_malloc(size_t size, myf my_flags);

View File

@ -129,6 +129,7 @@ SET(LIBMYSQLD_SOURCES emb_qcache.cc libmysqld.c lib_sql.cc
../sql/sql_list.cc ../sql/sql_load.cc ../sql/sql_locale.cc ../sql/sql_list.cc ../sql/sql_load.cc ../sql/sql_locale.cc
../sql/sql_binlog.cc ../sql/sql_manager.cc ../sql/sql_map.cc ../sql/sql_binlog.cc ../sql/sql_manager.cc ../sql/sql_map.cc
../sql/sql_parse.cc ../sql/sql_partition.cc ../sql/sql_plugin.cc ../sql/sql_parse.cc ../sql/sql_partition.cc ../sql/sql_plugin.cc
../sql/debug_sync.cc
../sql/sql_prepare.cc ../sql/sql_rename.cc ../sql/sql_repl.cc ../sql/sql_prepare.cc ../sql/sql_rename.cc ../sql/sql_repl.cc
../sql/sql_select.cc ../sql/sql_servers.cc ../sql/sql_select.cc ../sql/sql_servers.cc
../sql/sql_show.cc ../sql/sql_state.c ../sql/sql_string.cc ../sql/sql_show.cc ../sql/sql_state.c ../sql/sql_string.cc

View File

@ -74,6 +74,7 @@ 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 \
sql_tablespace.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 event_parse_data.cc sql_servers.cc event_parse_data.cc

View File

@ -6,3 +6,5 @@ rpl.rpl_row_create_table* # Bug#45576: rpl_row_create_table fails
rpl_ndb.rpl_ndb_log # Bug#38998 rpl_ndb.rpl_ndb_log # Bug#38998
rpl.rpl_innodb_bug28430* @solaris # Bug#46029 rpl.rpl_innodb_bug28430* @solaris # Bug#46029
rpl.rpl_get_master_version_and_clock* # Bug#46931 2009-08-26 alik rpl.rpl_get_master_version_and_clock fails on hpux11.31 rpl.rpl_get_master_version_and_clock* # Bug#46931 2009-08-26 alik rpl.rpl_get_master_version_and_clock fails on hpux11.31
innodb-autoinc # Bug#47809 2009-10-04 joro innodb-autoinc.test fails with valgrind errors with the innodb plugin
rpl.rpl_trigger # Bug#47810 2009-10-04 joro rpl.rpl_trigger.test fails with valgrind errors with the innodb plugin

View File

@ -0,0 +1,44 @@
#
# This test verifies if inserting data into view that invokes a
# trigger will make the autoinc values become inconsistent on
# master and slave.
#
connection master;
CREATE TABLE t1(i1 int not null auto_increment, c1 INT, primary key(i1)) engine=innodb;
CREATE TABLE t2(i1 int not null auto_increment, c2 INT, primary key(i1)) engine=innodb;
CREATE TABLE t3(i1 int not null auto_increment, a int, primary key(i1)) engine=innodb;
eval create trigger tr16 $insert_action on t1 for each row insert into t3(a) values(new.c1);
eval create trigger tr17 $insert_action on t2 for each row insert into t3(a) values(new.c2);
begin;
INSERT INTO t1(c1) VALUES (11), (12);
INSERT INTO t2(c2) VALUES (13), (14);
CREATE VIEW v16 AS SELECT c1, c2 FROM t1, t2;
INSERT INTO v16(c1) VALUES (15),(16);
INSERT INTO v16(c2) VALUES (17),(18);
connection master1;
INSERT INTO v16(c1) VALUES (19),(20);
INSERT INTO v16(c2) VALUES (21),(22);
connection master;
INSERT INTO v16(c1) VALUES (23), (24);
INSERT INTO v16(c1) VALUES (25), (26);
commit;
sync_slave_with_master;
--echo #Test if the results are consistent on master and slave
--echo #for 'INSERT DATA INTO VIEW WHICH INVOKES TRIGGERS'
let $diff_table_1=master:test.t3;
let $diff_table_2=slave:test.t3;
source include/diff_tables.inc;
connection master;
DROP TABLE t1;
DROP TABLE t2;
DROP TABLE t3;
DROP VIEW v16;
sync_slave_with_master;

View File

@ -0,0 +1,82 @@
#
# This test verifies if concurrent transactions that invoke a
# trigger that inserts more than one values into one or more
# tables with an auto_increment column will make the autoinc
# values become inconsistent on master and slave.
#
connection master;
create table t1(a int, b int) engine=innodb;
create table t2(i1 int not null auto_increment, a int, primary key(i1)) engine=innodb;
eval create trigger tr1 $trigger_action on t1 for each row insert into t2(a) values(6);
create table t3(a int, b int) engine=innodb;
create table t4(i1 int not null auto_increment, a int, primary key(i1)) engine=innodb;
create table t5(a int) engine=innodb;
delimiter |;
eval create trigger tr2 $trigger_action on t3 for each row begin
insert into t4(a) values(f1_insert_triggered());
insert into t4(a) values(f1_insert_triggered());
insert into t5(a) values(8);
end |
delimiter ;|
create table t6(i1 int not null auto_increment, a int, primary key(i1)) engine=innodb;
delimiter //;
CREATE FUNCTION f1_insert_triggered() RETURNS INTEGER
BEGIN
INSERT INTO t6(a) values(2),(3);
RETURN 1;
END//
delimiter ;//
begin;
let $binlog_start= query_get_value("SHOW MASTER STATUS", Position, 1);
insert into t1(a,b) values(1,1),(2,1);
insert into t3(a,b) values(1,1),(2,1);
update t1 set a = a + 5 where b = 1;
update t3 set a = a + 5 where b = 1;
delete from t1 where b = 1;
delete from t3 where b = 1;
connection master1;
#The default autocommit is set to 1, so the statement is auto committed
insert into t2(a) values(3);
insert into t4(a) values(3);
connection master;
commit;
insert into t1(a,b) values(4,2);
insert into t3(a,b) values(4,2);
update t1 set a = a + 5 where b = 2;
update t3 set a = a + 5 where b = 2;
delete from t1 where b = 2;
delete from t3 where b = 2;
--echo # To verify if insert/update in an autoinc column causes statement to be logged in row format
source include/show_binlog_events.inc;
commit;
connection master;
sync_slave_with_master;
--echo #Test if the results are consistent on master and slave
--echo #for 'INVOKES A TRIGGER with $trigger_action action'
let $diff_table_1=master:test.t2;
let $diff_table_2=slave:test.t2;
source include/diff_tables.inc;
let $diff_table_1=master:test.t4;
let $diff_table_2=slave:test.t4;
source include/diff_tables.inc;
let $diff_table_1=master:test.t6;
let $diff_table_2=slave:test.t6;
source include/diff_tables.inc;
connection master;
DROP TABLE t1;
DROP TABLE t2;
DROP TABLE t3;
DROP TABLE t4;
DROP TABLE t5;
DROP TABLE t6;
DROP FUNCTION f1_insert_triggered;
sync_slave_with_master;

View File

@ -0,0 +1,57 @@
#
# This test verifies if concurrent transactions that call a
# function which invokes a 'after/before insert action' trigger
# that inserts more than one values into a table with autoinc
# column will make the autoinc values become inconsistent on
# master and slave.
#
connection master;
create table t1(a int) engine=innodb;
create table t2(i1 int not null auto_increment, a int, primary key(i1)) engine=innodb;
create table t3(i1 int not null auto_increment, a int, primary key(i1)) engine=innodb;
delimiter |;
CREATE FUNCTION f1_two_inserts_trigger() RETURNS INTEGER
BEGIN
INSERT INTO t2(a) values(2),(3);
INSERT INTO t2(a) values(2),(3);
RETURN 1;
END |
eval create trigger tr11 $insert_action on t2 for each row begin
insert into t3(a) values(new.a);
insert into t3(a) values(new.a);
end |
delimiter ;|
begin;
let $binlog_start= query_get_value("SHOW MASTER STATUS", Position, 1);
insert into t1(a) values(f1_two_inserts_trigger());
connection master1;
#The default autocommit is set to 1, so the statement is auto committed
insert into t2(a) values(4),(5);
connection master;
commit;
insert into t1(a) values(f1_two_inserts_trigger());
--echo # To verify if insert/update in an autoinc column causes statement to be logged in row format
source include/show_binlog_events.inc;
commit;
connection master;
sync_slave_with_master;
--echo #Test if the results are consistent on master and slave
--echo #for 'CALLS A FUNCTION which INVOKES A TRIGGER with $insert_action action'
let $diff_table_1=master:test.t2;
let $diff_table_2=slave:test.t2;
source include/diff_tables.inc;
let $diff_table_1=master:test.t3;
let $diff_table_2=slave:test.t3;
source include/diff_tables.inc;
connection master;
drop table t1;
drop table t2;
drop table t3;
drop function f1_two_inserts_trigger;
sync_slave_with_master;

View File

@ -0,0 +1,5 @@
--require r/have_debug_sync.require
disable_query_log;
let $value= query_get_value(SHOW VARIABLES LIKE 'debug_sync', Value, 1);
eval SELECT ('$value' LIKE 'ON %') AS debug_sync;
enable_query_log;

View File

@ -226,6 +226,7 @@ my @default_valgrind_args= ("--show-reachable=yes");
my @valgrind_args; my @valgrind_args;
my $opt_valgrind_path; my $opt_valgrind_path;
my $opt_callgrind; my $opt_callgrind;
my $opt_debug_sync_timeout= 300; # Default timeout for WAIT_FOR actions.
our $opt_warnings= 1; our $opt_warnings= 1;
@ -867,6 +868,7 @@ sub command_line_setup {
'valgrind-option=s' => \@valgrind_args, 'valgrind-option=s' => \@valgrind_args,
'valgrind-path=s' => \$opt_valgrind_path, 'valgrind-path=s' => \$opt_valgrind_path,
'callgrind' => \$opt_callgrind, 'callgrind' => \$opt_callgrind,
'debug-sync-timeout=i' => \$opt_debug_sync_timeout,
# Directories # Directories
'tmpdir=s' => \$opt_tmpdir, 'tmpdir=s' => \$opt_tmpdir,
@ -4170,6 +4172,11 @@ sub mysqld_arguments ($$$) {
mtr_add_arg($args, "%s", "--core-file"); mtr_add_arg($args, "%s", "--core-file");
} }
# Enable the debug sync facility, set default wait timeout.
# Facility stays disabled if timeout value is zero.
mtr_add_arg($args, "--loose-debug-sync-timeout=%s",
$opt_debug_sync_timeout);
return $args; return $args;
} }
@ -5280,6 +5287,8 @@ Misc options
to turn off. to turn off.
sleep=SECONDS Passed to mysqltest, will be used as fixed sleep time sleep=SECONDS Passed to mysqltest, will be used as fixed sleep time
debug-sync-timeout=NUM Set default timeout for WAIT_FOR debug sync
actions. Disable facility with NUM=0.
gcov Collect coverage information after the test. gcov Collect coverage information after the test.
The result is a gcov file per source and header file. The result is a gcov file per source and header file.
experimental=<file> Refer to list of tests considered experimental; experimental=<file> Refer to list of tests considered experimental;

View File

@ -0,0 +1,277 @@
SET DEBUG_SYNC= 'RESET';
DROP TABLE IF EXISTS t1;
SHOW VARIABLES LIKE 'DEBUG_SYNC';
Variable_name Value
debug_sync ON - current signal: ''
SET DEBUG_SYNC='p0 SIGNAL s1 WAIT_FOR s2 TIMEOUT 6 EXECUTE 2 HIT_LIMIT 3';
SET DEBUG_SYNC='p0 SIGNAL s1 WAIT_FOR s2 TIMEOUT 6 EXECUTE 2';
SET DEBUG_SYNC='p0 SIGNAL s1 WAIT_FOR s2 TIMEOUT 6 HIT_LIMIT 3';
SET DEBUG_SYNC='p0 SIGNAL s1 WAIT_FOR s2 TIMEOUT 6';
SET DEBUG_SYNC='p0 SIGNAL s1 WAIT_FOR s2 EXECUTE 2 HIT_LIMIT 3';
SET DEBUG_SYNC='p0 SIGNAL s1 WAIT_FOR s2 EXECUTE 2';
SET DEBUG_SYNC='p0 SIGNAL s1 WAIT_FOR s2 HIT_LIMIT 3';
SET DEBUG_SYNC='p0 SIGNAL s1 WAIT_FOR s2';
SET DEBUG_SYNC='p0 SIGNAL s1 EXECUTE 2 HIT_LIMIT 3';
SET DEBUG_SYNC='p0 SIGNAL s1 EXECUTE 2';
SET DEBUG_SYNC='p0 SIGNAL s1 HIT_LIMIT 3';
SET DEBUG_SYNC='p0 SIGNAL s1';
SET DEBUG_SYNC='p0 WAIT_FOR s2 TIMEOUT 6 EXECUTE 2 HIT_LIMIT 3';
SET DEBUG_SYNC='p0 WAIT_FOR s2 TIMEOUT 6 EXECUTE 2';
SET DEBUG_SYNC='p0 WAIT_FOR s2 TIMEOUT 6 HIT_LIMIT 3';
SET DEBUG_SYNC='p0 WAIT_FOR s2 TIMEOUT 6';
SET DEBUG_SYNC='p0 WAIT_FOR s2 EXECUTE 2 HIT_LIMIT 3';
SET DEBUG_SYNC='p0 WAIT_FOR s2 EXECUTE 2';
SET DEBUG_SYNC='p0 WAIT_FOR s2 HIT_LIMIT 3';
SET DEBUG_SYNC='p0 WAIT_FOR s2';
SET DEBUG_SYNC='p0 HIT_LIMIT 3';
SET DEBUG_SYNC='p0 CLEAR';
SET DEBUG_SYNC='p0 TEST';
SET DEBUG_SYNC='RESET';
set debug_sync='p0 signal s1 wait_for s2 timeout 6 execute 2 hit_limit 3';
set debug_sync='p0 signal s1 wait_for s2 timeout 6 execute 2';
set debug_sync='p0 signal s1 wait_for s2 timeout 6 hit_limit 3';
set debug_sync='p0 signal s1 wait_for s2 timeout 6';
set debug_sync='p0 signal s1 wait_for s2 execute 2 hit_limit 3';
set debug_sync='p0 signal s1 wait_for s2 execute 2';
set debug_sync='p0 signal s1 wait_for s2 hit_limit 3';
set debug_sync='p0 signal s1 wait_for s2';
set debug_sync='p0 signal s1 execute 2 hit_limit 3';
set debug_sync='p0 signal s1 execute 2';
set debug_sync='p0 signal s1 hit_limit 3';
set debug_sync='p0 signal s1';
set debug_sync='p0 wait_for s2 timeout 6 execute 2 hit_limit 3';
set debug_sync='p0 wait_for s2 timeout 6 execute 2';
set debug_sync='p0 wait_for s2 timeout 6 hit_limit 3';
set debug_sync='p0 wait_for s2 timeout 6';
set debug_sync='p0 wait_for s2 execute 2 hit_limit 3';
set debug_sync='p0 wait_for s2 execute 2';
set debug_sync='p0 wait_for s2 hit_limit 3';
set debug_sync='p0 wait_for s2';
set debug_sync='p0 hit_limit 3';
set debug_sync='p0 clear';
set debug_sync='p0 test';
set debug_sync='reset';
SET DEBUG_SYNC='p0 SIGNAL s1 WAIT_FOR s2 TIMEOUT 6
EXECUTE 2 HIT_LIMIT 3';
SET DEBUG_SYNC=' p0 SIGNAL s1 WAIT_FOR s2';
SET DEBUG_SYNC='p0 SIGNAL s1 WAIT_FOR s2';
SET DEBUG_SYNC='p0 SIGNAL s1 WAIT_FOR s2 ';
SET DEBUG_SYNC=' p0 SIGNAL s1 WAIT_FOR s2 ';
SET DEBUG_SYNC=' p0 SIGNAL s1 WAIT_FOR s2 ';
SET DEBUG_SYNC='';
ERROR 42000: Missing synchronization point name
SET DEBUG_SYNC=' ';
ERROR 42000: Missing synchronization point name
SET DEBUG_SYNC='p0';
ERROR 42000: Missing action after synchronization point name 'p0'
SET DEBUG_SYNC='p0 EXECUTE 2';
ERROR 42000: Missing action before EXECUTE
SET DEBUG_SYNC='p0 TIMEOUT 6 EXECUTE 2';
ERROR 42000: Illegal or out of order stuff: 'TIMEOUT'
SET DEBUG_SYNC='p0 TIMEOUT 6';
ERROR 42000: Illegal or out of order stuff: 'TIMEOUT'
SET DEBUG_SYNC='p0 WAIT_FOR s2 SIGNAL s1';
ERROR 42000: Illegal or out of order stuff: 'SIGNAL'
SET DEBUG_SYNC='p0 WAIT_FOR s2 SIGNAL s1 EXECUTE 2';
ERROR 42000: Illegal or out of order stuff: 'SIGNAL'
SET DEBUG_SYNC='p0 WAIT_FOR s2 SIGNAL s1 TIMEOUT 6 EXECUTE 2';
ERROR 42000: Illegal or out of order stuff: 'SIGNAL'
SET DEBUG_SYNC='p0 WAIT_FOR s2 SIGNAL s1 TIMEOUT 6';
ERROR 42000: Illegal or out of order stuff: 'SIGNAL'
SET DEBUG_SYNC='p0 WAIT_FOR s2 TIMEOUT 6 SIGNAL s1 EXECUTE 2';
ERROR 42000: Illegal or out of order stuff: 'SIGNAL'
SET DEBUG_SYNC='p0 WAIT_FOR s2 TIMEOUT 6 SIGNAL s1';
ERROR 42000: Illegal or out of order stuff: 'SIGNAL'
SET DEBUG_SYNC='p0 TIMEOUT 6 WAIT_FOR s2 EXECUTE 2';
ERROR 42000: Illegal or out of order stuff: 'TIMEOUT'
SET DEBUG_SYNC='p0 TIMEOUT 6 WAIT_FOR s2';
ERROR 42000: Illegal or out of order stuff: 'TIMEOUT'
SET DEBUG_SYNC='p0 SIGNAL s1 TIMEOUT 6 EXECUTE 2';
ERROR 42000: Illegal or out of order stuff: 'TIMEOUT'
SET DEBUG_SYNC='p0 SIGNAL s1 TIMEOUT 6';
ERROR 42000: Illegal or out of order stuff: 'TIMEOUT'
SET DEBUG_SYNC='p0 EXECUTE 2 SIGNAL s1 TIMEOUT 6';
ERROR 42000: Missing action before EXECUTE
SET DEBUG_SYNC='p0 TIMEOUT 6 SIGNAL s1';
ERROR 42000: Illegal or out of order stuff: 'TIMEOUT'
SET DEBUG_SYNC='p0 EXECUTE 2 TIMEOUT 6 SIGNAL s1';
ERROR 42000: Missing action before EXECUTE
SET DEBUG_SYNC='p0 CLEAR HIT_LIMIT 3';
ERROR 42000: Nothing must follow action CLEAR
SET DEBUG_SYNC='CLEAR';
ERROR 42000: Missing action after synchronization point name 'CLEAR'
SET DEBUG_SYNC='p0 CLEAR p0';
ERROR 42000: Nothing must follow action CLEAR
SET DEBUG_SYNC='TEST';
ERROR 42000: Missing action after synchronization point name 'TEST'
SET DEBUG_SYNC='p0 TEST p0';
ERROR 42000: Nothing must follow action TEST
SET DEBUG_SYNC='p0 RESET';
ERROR 42000: Illegal or out of order stuff: 'RESET'
SET DEBUG_SYNC='RESET p0';
ERROR 42000: Illegal or out of order stuff: 'p0'
SET DEBUG_SYNC='p0 RESET p0';
ERROR 42000: Illegal or out of order stuff: 'RESET'
SET DEBUG_SYNC='p0 SIGNAL ';
ERROR 42000: Missing signal name after action SIGNAL
SET DEBUG_SYNC='p0 WAIT_FOR ';
ERROR 42000: Missing signal name after action WAIT_FOR
SET DEBUG_SYNC='p0 SIGNAL s1 EXECUTE ';
ERROR 42000: Missing valid number after EXECUTE
SET DEBUG_SYNCx='p0 SIGNAL s1 WAIT_FOR s2 TIMEOUT 6 EXECUTE 2 HIT_LIMIT 3';
ERROR HY000: Unknown system variable 'DEBUG_SYNCx'
SET DEBUG_SYNC='p0 SIGNAx s1 WAIT_FOR s2 TIMEOUT 6 EXECUTE 2 HIT_LIMIT 3';
ERROR 42000: Illegal or out of order stuff: 'SIGNAx'
SET DEBUG_SYNC='p0 SIGNAL s1 WAIT_FOx s2 TIMEOUT 6 EXECUTE 2 HIT_LIMIT 3';
ERROR 42000: Illegal or out of order stuff: 'WAIT_FOx'
SET DEBUG_SYNC='p0 SIGNAL s1 WAIT_FOR s2 TIMEOUx 0 EXECUTE 2 HIT_LIMIT 3';
ERROR 42000: Illegal or out of order stuff: 'TIMEOUx'
SET DEBUG_SYNC='p0 SIGNAL s1 WAIT_FOR s2 TIMEOUT 6 EXECUTx 2 HIT_LIMIT 3';
ERROR 42000: Illegal or out of order stuff: 'EXECUTx'
SET DEBUG_SYNC='p0 SIGNAL s1 WAIT_FOR s2 TIMEOUT 6 EXECUTE 2 HIT_LIMIx 3';
ERROR 42000: Illegal or out of order stuff: 'HIT_LIMIx'
SET DEBUG_SYNC='p0 CLEARx';
ERROR 42000: Illegal or out of order stuff: 'CLEARx'
SET DEBUG_SYNC='p0 TESTx';
ERROR 42000: Illegal or out of order stuff: 'TESTx'
SET DEBUG_SYNC='RESETx';
ERROR 42000: Missing action after synchronization point name 'RESETx'
SET DEBUG_SYNC='p0 WAIT_FOR s2 TIMEOUT 0x6 EXECUTE 2 HIT_LIMIT 3';
ERROR 42000: Missing valid number after TIMEOUT
SET DEBUG_SYNC='p0 WAIT_FOR s2 TIMEOUT 6 EXECUTE 0x2 HIT_LIMIT 3';
ERROR 42000: Missing valid number after EXECUTE
SET DEBUG_SYNC='p0 WAIT_FOR s2 TIMEOUT 7 EXECUTE 2 HIT_LIMIT 0x3';
ERROR 42000: Missing valid number after HIT_LIMIT
SET DEBUG_SYNC= 7;
ERROR 42000: Incorrect argument type to variable 'debug_sync'
SET GLOBAL DEBUG_SYNC= 'p0 CLEAR';
ERROR HY000: Variable 'debug_sync' is a SESSION variable and can't be used with SET GLOBAL
SET @myvar= 'now SIGNAL from_myvar';
SET DEBUG_SYNC= @myvar;
SHOW VARIABLES LIKE 'DEBUG_SYNC';
Variable_name Value
debug_sync ON - current signal: 'from_myvar'
SET DEBUG_SYNC= LEFT('now SIGNAL from_function_cut_here', 24);
SHOW VARIABLES LIKE 'DEBUG_SYNC';
Variable_name Value
debug_sync ON - current signal: 'from_function'
SET DEBUG_SYNC= 'now SIGNAL something';
SHOW VARIABLES LIKE 'DEBUG_SYNC';
Variable_name Value
debug_sync ON - current signal: 'something'
SET DEBUG_SYNC= 'now WAIT_FOR nothing TIMEOUT 0';
Warnings:
Warning #### debug sync point wait timed out
SET DEBUG_SYNC= 'now SIGNAL nothing';
SHOW VARIABLES LIKE 'DEBUG_SYNC';
Variable_name Value
debug_sync ON - current signal: 'nothing'
SET DEBUG_SYNC= 'now WAIT_FOR nothing TIMEOUT 0';
SET DEBUG_SYNC= 'now SIGNAL something EXECUTE 0';
SHOW VARIABLES LIKE 'DEBUG_SYNC';
Variable_name Value
debug_sync ON - current signal: 'nothing'
SET DEBUG_SYNC= 'now WAIT_FOR anotherthing TIMEOUT 0 EXECUTE 0';
SET DEBUG_SYNC= 'now HIT_LIMIT 1';
ERROR HY000: debug sync point hit limit reached
SET DEBUG_SYNC= 'RESET';
SHOW VARIABLES LIKE 'DEBUG_SYNC';
Variable_name Value
debug_sync ON - current signal: ''
SET DEBUG_SYNC= 'p1abcd SIGNAL s1 EXECUTE 2';
SET DEBUG_SYNC= 'p2abc SIGNAL s2 EXECUTE 2';
SET DEBUG_SYNC= 'p9abcdef SIGNAL s9 EXECUTE 2';
SET DEBUG_SYNC= 'p4a SIGNAL s4 EXECUTE 2';
SET DEBUG_SYNC= 'p5abcde SIGNAL s5 EXECUTE 2';
SET DEBUG_SYNC= 'p6ab SIGNAL s6 EXECUTE 2';
SET DEBUG_SYNC= 'p7 SIGNAL s7 EXECUTE 2';
SET DEBUG_SYNC= 'p8abcdef SIGNAL s8 EXECUTE 2';
SET DEBUG_SYNC= 'p3abcdef SIGNAL s3 EXECUTE 2';
SET DEBUG_SYNC= 'p4a TEST';
SHOW VARIABLES LIKE 'DEBUG_SYNC';
Variable_name Value
debug_sync ON - current signal: 's4'
SET DEBUG_SYNC= 'p1abcd TEST';
SHOW VARIABLES LIKE 'DEBUG_SYNC';
Variable_name Value
debug_sync ON - current signal: 's1'
SET DEBUG_SYNC= 'p7 TEST';
SHOW VARIABLES LIKE 'DEBUG_SYNC';
Variable_name Value
debug_sync ON - current signal: 's7'
SET DEBUG_SYNC= 'p9abcdef TEST';
SHOW VARIABLES LIKE 'DEBUG_SYNC';
Variable_name Value
debug_sync ON - current signal: 's9'
SET DEBUG_SYNC= 'p3abcdef TEST';
SHOW VARIABLES LIKE 'DEBUG_SYNC';
Variable_name Value
debug_sync ON - current signal: 's3'
SET DEBUG_SYNC= 'p1abcd CLEAR';
SET DEBUG_SYNC= 'p2abc CLEAR';
SET DEBUG_SYNC= 'p5abcde CLEAR';
SET DEBUG_SYNC= 'p6ab CLEAR';
SET DEBUG_SYNC= 'p8abcdef CLEAR';
SET DEBUG_SYNC= 'p9abcdef CLEAR';
SET DEBUG_SYNC= 'p3abcdef CLEAR';
SET DEBUG_SYNC= 'p4a CLEAR';
SET DEBUG_SYNC= 'p7 CLEAR';
SET DEBUG_SYNC= 'p1abcd TEST';
SHOW VARIABLES LIKE 'DEBUG_SYNC';
Variable_name Value
debug_sync ON - current signal: 's3'
SET DEBUG_SYNC= 'p7 TEST';
SHOW VARIABLES LIKE 'DEBUG_SYNC';
Variable_name Value
debug_sync ON - current signal: 's3'
SET DEBUG_SYNC= 'p9abcdef TEST';
SHOW VARIABLES LIKE 'DEBUG_SYNC';
Variable_name Value
debug_sync ON - current signal: 's3'
SET DEBUG_SYNC= 'RESET';
SHOW VARIABLES LIKE 'DEBUG_SYNC';
Variable_name Value
debug_sync ON - current signal: ''
CREATE USER mysqltest_1@localhost;
GRANT SUPER ON *.* TO mysqltest_1@localhost;
connection con1, mysqltest_1
SET DEBUG_SYNC= 'RESET';
connection default
DROP USER mysqltest_1@localhost;
CREATE USER mysqltest_2@localhost;
GRANT ALL ON *.* TO mysqltest_2@localhost;
REVOKE SUPER ON *.* FROM mysqltest_2@localhost;
connection con1, mysqltest_2
SET DEBUG_SYNC= 'RESET';
ERROR 42000: Access denied; you need the SUPER privilege for this operation
connection default
DROP USER mysqltest_2@localhost;
SET DEBUG_SYNC= 'RESET';
DROP TABLE IF EXISTS t1;
CREATE TABLE t1 (c1 INT);
connection con1
SET DEBUG_SYNC= 'before_lock_tables_takes_lock
SIGNAL opened WAIT_FOR flushed';
INSERT INTO t1 VALUES(1);
connection default
SET DEBUG_SYNC= 'now WAIT_FOR opened';
SET DEBUG_SYNC= 'after_flush_unlock SIGNAL flushed';
FLUSH TABLE t1;
connection con1
connection default
DROP TABLE t1;
SET DEBUG_SYNC= 'RESET';
DROP TABLE IF EXISTS t1;
CREATE TABLE t1 (c1 INT);
LOCK TABLE t1 WRITE;
connection con1
SET DEBUG_SYNC= 'wait_for_lock SIGNAL locked EXECUTE 2';
INSERT INTO t1 VALUES (1);
connection default
SET DEBUG_SYNC= 'now WAIT_FOR locked';
UNLOCK TABLES;
connection con1
retrieve INSERT result.
connection default
DROP TABLE t1;
SET DEBUG_SYNC= 'RESET';

View File

@ -608,4 +608,146 @@ SELECT SUM( DISTINCT e ) FROM t1 GROUP BY b,c,d HAVING (b,c,d) IN
((AVG( 1 ), 1 + c, 1 + d), (AVG( 1 ), 2 + c, 2 + d)); ((AVG( 1 ), 1 + c, 1 + d), (AVG( 1 ), 2 + c, 2 + d));
SUM( DISTINCT e ) SUM( DISTINCT e )
DROP TABLE t1; DROP TABLE t1;
#
# Bug #44139: Table scan when NULL appears in IN clause
#
CREATE TABLE t1 (
c_int INT NOT NULL,
c_decimal DECIMAL(5,2) NOT NULL,
c_float FLOAT(5, 2) NOT NULL,
c_bit BIT(10) NOT NULL,
c_date DATE NOT NULL,
c_datetime DATETIME NOT NULL,
c_timestamp TIMESTAMP NOT NULL,
c_time TIME NOT NULL,
c_year YEAR NOT NULL,
c_char CHAR(10) NOT NULL,
INDEX(c_int), INDEX(c_decimal), INDEX(c_float), INDEX(c_bit), INDEX(c_date),
INDEX(c_datetime), INDEX(c_timestamp), INDEX(c_time), INDEX(c_year),
INDEX(c_char));
INSERT INTO t1 (c_int) VALUES (1), (2), (3), (4), (5);
INSERT INTO t1 (c_int) SELECT 0 FROM t1;
INSERT INTO t1 (c_int) SELECT 0 FROM t1;
EXPLAIN SELECT * FROM t1 WHERE c_int IN (1, 2, 3);
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 range c_int c_int 4 NULL 3 Using where
EXPLAIN SELECT * FROM t1 WHERE c_int IN (NULL, 1, 2, 3);
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 range c_int c_int 4 NULL 3 Using where
EXPLAIN SELECT * FROM t1 WHERE c_int IN (1, 2, 3);
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 range c_int c_int 4 NULL 3 Using where
EXPLAIN SELECT * FROM t1 WHERE c_int IN (1, NULL, 2, NULL, 3, NULL);
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 range c_int c_int 4 NULL 3 Using where
EXPLAIN SELECT * FROM t1 WHERE c_int IN (NULL);
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables
EXPLAIN SELECT * FROM t1 WHERE c_int IN (NULL, NULL);
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables
EXPLAIN SELECT * FROM t1 WHERE c_decimal IN (1, 2, 3);
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 range c_decimal c_decimal 3 NULL 3 Using where
EXPLAIN SELECT * FROM t1 WHERE c_decimal IN (NULL, 1, 2, 3);
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 range c_decimal c_decimal 3 NULL 3 Using where
EXPLAIN SELECT * FROM t1 WHERE c_decimal IN (NULL);
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables
EXPLAIN SELECT * FROM t1 WHERE c_decimal IN (NULL, NULL);
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables
EXPLAIN SELECT * FROM t1 WHERE c_float IN (1, 2, 3);
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 range c_float c_float 4 NULL 3 Using where
EXPLAIN SELECT * FROM t1 WHERE c_float IN (NULL, 1, 2, 3);
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 range c_float c_float 4 NULL 3 Using where
EXPLAIN SELECT * FROM t1 WHERE c_float IN (NULL);
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables
EXPLAIN SELECT * FROM t1 WHERE c_float IN (NULL, NULL);
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables
EXPLAIN SELECT * FROM t1 WHERE c_bit IN (1, 2, 3);
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 range c_bit c_bit 2 NULL 3 Using where
EXPLAIN SELECT * FROM t1 WHERE c_bit IN (NULL, 1, 2, 3);
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 range c_bit c_bit 2 NULL 3 Using where
EXPLAIN SELECT * FROM t1 WHERE c_bit IN (NULL);
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables
EXPLAIN SELECT * FROM t1 WHERE c_bit IN (NULL, NULL);
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables
EXPLAIN SELECT * FROM t1 WHERE c_date
IN ('2009-09-01', '2009-09-02', '2009-09-03');
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 range c_date c_date 3 NULL 3 Using where
EXPLAIN SELECT * FROM t1 WHERE c_date
IN (NULL, '2009-09-01', '2009-09-02', '2009-09-03');
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 range c_date c_date 3 NULL 3 Using where
EXPLAIN SELECT * FROM t1 WHERE c_date IN (NULL);
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables
EXPLAIN SELECT * FROM t1 WHERE c_date IN (NULL, NULL);
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables
EXPLAIN SELECT * FROM t1 WHERE c_datetime
IN ('2009-09-01 00:00:01', '2009-09-02 00:00:01', '2009-09-03 00:00:01');
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 range c_datetime c_datetime 8 NULL 3 Using where
EXPLAIN SELECT * FROM t1 WHERE c_datetime
IN (NULL, '2009-09-01 00:00:01', '2009-09-02 00:00:01', '2009-09-03 00:00:01');
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 range c_datetime c_datetime 8 NULL 3 Using where
EXPLAIN SELECT * FROM t1 WHERE c_datetime IN (NULL);
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables
EXPLAIN SELECT * FROM t1 WHERE c_datetime IN (NULL, NULL);
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables
EXPLAIN SELECT * FROM t1 WHERE c_timestamp
IN ('2009-09-01 00:00:01', '2009-09-01 00:00:02', '2009-09-01 00:00:03');
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 range c_timestamp c_timestamp 4 NULL 3 Using where
EXPLAIN SELECT * FROM t1 WHERE c_timestamp
IN (NULL, '2009-09-01 00:00:01', '2009-09-01 00:00:02', '2009-09-01 00:00:03');
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 range c_timestamp c_timestamp 4 NULL 3 Using where
EXPLAIN SELECT * FROM t1 WHERE c_timestamp IN (NULL);
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables
EXPLAIN SELECT * FROM t1 WHERE c_timestamp IN (NULL, NULL);
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables
EXPLAIN SELECT * FROM t1 WHERE c_year IN (1, 2, 3);
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 range c_year c_year 1 NULL 3 Using where
EXPLAIN SELECT * FROM t1 WHERE c_year IN (NULL, 1, 2, 3);
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 range c_year c_year 1 NULL 3 Using where
EXPLAIN SELECT * FROM t1 WHERE c_year IN (NULL);
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables
EXPLAIN SELECT * FROM t1 WHERE c_year IN (NULL, NULL);
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables
EXPLAIN SELECT * FROM t1 WHERE c_char IN ('1', '2', '3');
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 range c_char c_char 10 NULL 3 Using where
EXPLAIN SELECT * FROM t1 WHERE c_char IN (NULL, '1', '2', '3');
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 range c_char c_char 10 NULL 3 Using where
EXPLAIN SELECT * FROM t1 WHERE c_char IN (NULL);
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables
EXPLAIN SELECT * FROM t1 WHERE c_char IN (NULL, NULL);
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables
DROP TABLE t1;
#
End of 5.1 tests End of 5.1 tests

View File

@ -0,0 +1,2 @@
debug_sync
1

View File

@ -0,0 +1 @@
--loose-debug=d,simulate_detached_thread_refresh

View File

@ -0,0 +1,28 @@
CREATE DATABASE federated;
CREATE DATABASE federated;
#
# Bug#47525: MySQL crashed (Federated)
#
# Switch to slave
CREATE TABLE t1(a INT);
INSERT INTO t1 VALUES (1);
# Switch to master
CREATE TABLE t1(a INT) ENGINE=FEDERATED
CONNECTION='mysql://root@127.0.0.1:SLAVE_PORT/test/t1';
SELECT * FROM t1;
a
1
# Start a asynchronous reload
# Wait for tables to be closed
# Ensure that the server didn't crash
SELECT * FROM t1;
a
1
# Drop tables on master and slave
DROP TABLE t1;
DROP TABLE t1;
# Federated cleanup
DROP TABLE IF EXISTS federated.t1;
DROP DATABASE federated;
DROP TABLE IF EXISTS federated.t1;
DROP DATABASE federated;

View File

@ -0,0 +1,39 @@
--source include/have_debug.inc
--source federated.inc
--echo #
--echo # Bug#47525: MySQL crashed (Federated)
--echo #
connection slave;
--echo # Switch to slave
CREATE TABLE t1(a INT);
INSERT INTO t1 VALUES (1);
connection master;
--echo # Switch to master
--replace_result $SLAVE_MYPORT SLAVE_PORT
eval CREATE TABLE t1(a INT) ENGINE=FEDERATED
CONNECTION='mysql://root@127.0.0.1:$SLAVE_MYPORT/test/t1';
SELECT * FROM t1;
--echo # Start a asynchronous reload
--exec $MYSQLADMIN --no-defaults -S $MASTER_MYSOCK -P $MASTER_MYPORT -u root --password= refresh 2>&1
--echo # Wait for tables to be closed
let $show_statement= SHOW STATUS LIKE 'Open_tables';
let $field= Value;
let $condition= = '0';
--source include/wait_show_condition.inc
--echo # Ensure that the server didn't crash
SELECT * FROM t1;
--echo # Drop tables on master and slave
DROP TABLE t1;
connection slave;
DROP TABLE t1;
connection default;
--echo # Federated cleanup
source federated_cleanup.inc;

View File

@ -9,4 +9,7 @@ log-bin= master-bin
[ENV] [ENV]
MASTER_MYPORT= @mysqld.1.port MASTER_MYPORT= @mysqld.1.port
MASTER_MYSOCK= @mysqld.1.socket
SLAVE_MYPORT= @mysqld.2.port SLAVE_MYPORT= @mysqld.2.port
SLAVE_MYSOCK= @mysqld.2.socket

View File

@ -1 +1,2 @@
innodb-index: InnoDB: Error: table `test`.`t1#1` already exists in InnoDB internal innodb-index: InnoDB: Error: table `test`.`t1#1` already exists in InnoDB internal
innodb_information_schema: Bug #47808 joro : innodb_information_schema.test fails when run under valgrind

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,214 @@
#
# Bug45677
# This test verifies the following two properties:
# P1) insert/update in an autoinc column causes statement to
# be logged in row format if binlog_format=mixed.
# P2) if binlog_format=mixed, and a trigger or function contains
# two or more inserts/updates in a table that has an autoinc
# column, then the slave should not go out of sync, even if
# there are concurrent transactions.
#
# Property (P1) is tested by executing an insert and an update on
# a table that has an autoinc column, and verifying that these
# statements result in row events in the binlog.
# Property (P2) is tested by setting up the test scenario and
# verifying that the tables are identical on master and slave.
#
source include/have_binlog_format_mixed.inc;
source include/have_innodb.inc;
source include/master-slave.inc;
--echo # Test case1: INVOKES A TRIGGER with after insert action
let $trigger_action = after insert;
source extra/rpl_tests/rpl_auto_increment_invoke_trigger.test;
--echo # Test case2: INVOKES A TRIGGER with before insert action
let $trigger_action = before insert;
source extra/rpl_tests/rpl_auto_increment_invoke_trigger.test;
--echo # Test case3: INVOKES A TRIGGER with after update action
let $trigger_action = after update;
source extra/rpl_tests/rpl_auto_increment_invoke_trigger.test;
--echo # Test case4: INVOKES A TRIGGER with before update action
let $trigger_action = before update;
source extra/rpl_tests/rpl_auto_increment_invoke_trigger.test;
--echo # Test case5: INVOKES A TRIGGER with after delete action
let $trigger_action = after delete;
source extra/rpl_tests/rpl_auto_increment_invoke_trigger.test;
--echo # Test case6: INVOKES A TRIGGER with before delete action
let $trigger_action = before delete;
source extra/rpl_tests/rpl_auto_increment_invoke_trigger.test;
--echo # Test case7: CALLS A FUNCTION which INVOKES A TRIGGER with after insert action
let $insert_action = after insert;
source extra/rpl_tests/rpl_autoinc_func_invokes_trigger.test;
--echo # Test case8: CALLS A FUNCTION which INVOKES A TRIGGER with before insert action
let $insert_action = before insert;
source extra/rpl_tests/rpl_autoinc_func_invokes_trigger.test;
--echo # Test case9: INSERT DATA INTO VIEW WHICH INVOKES TRIGGERS with after insert action
let $insert_action = after insert;
source extra/rpl_tests/rpl_auto_increment_insert_view.test;
--echo # Test case10: INSERT DATA INTO VIEW WHICH INVOKES TRIGGERS with before insert action
let $insert_action = before insert;
source extra/rpl_tests/rpl_auto_increment_insert_view.test;
--echo # Test case11: INVOKES A FUNCTION TO INSERT TWO OR MORE VALUES INTO A TABLE WITH AUTOINC COLUMN
connection master;
create table t1(a int) engine=innodb;
create table t2(i1 int not null auto_increment, a int, primary key(i1)) engine=innodb;
delimiter //;
CREATE FUNCTION f1_two_inserts() RETURNS INTEGER
BEGIN
INSERT INTO t2(a) values(2);
INSERT INTO t2(a) values(2);
RETURN 1;
END//
delimiter ;//
begin;
insert into t1(a) values(f1_two_inserts());
connection master1;
#The default autocommit is set to 1, so the statement is auto committed
insert into t2(a) values(4),(5);
connection master;
commit;
insert into t1(a) values(f1_two_inserts());
commit;
connection master;
--echo #Test result for INVOKES A FUNCTION TO INSERT TWO OR MORE VALUES on master
select * from t2 ORDER BY i1;
sync_slave_with_master;
connection slave;
--echo #Test result for INVOKES A FUNCTION TO INSERT TWO OR MORE VALUES on slave
select * from t2 ORDER BY i1;
connection master;
drop table t1;
drop table t2;
drop function f1_two_inserts;
sync_slave_with_master;
--echo # Test case12: INVOKES A FUNCTION TO UPDATE TWO OR MORE VALUES OF A TABLE WITH AUTOINC COLUMN
connection master;
create table t1(a int) engine=innodb;
create table t2(i1 int not null auto_increment, a int, b int, primary key(i1)) engine=innodb;
delimiter //;
CREATE FUNCTION f1_two_updates() RETURNS INTEGER
BEGIN
update t2 set a = a + 5 where b = 1;
update t2 set a = a + 5 where b = 2;
update t2 set a = a + 5 where b = 3;
update t2 set a = a + 5 where b = 4;
RETURN 1;
END//
delimiter ;//
connection master1;
#The default autocommit is set to 1, so the statement is auto committed
insert into t2(a,b) values(1,1);
insert into t2(a,b) values(2,2);
insert into t2(a,b) values(3,3);
insert into t2(a,b) values(4,4);
insert into t1(a) values(f1_two_updates());
connection master;
begin;
insert into t1(a) values(f1_two_updates());
commit;
connection master;
--echo #Test result for INVOKES A FUNCTION TO UPDATE TWO OR MORE VALUES on master
select * from t2 ORDER BY i1;
sync_slave_with_master;
connection slave;
--echo #Test result for INVOKES A FUNCTION TO UPDATE TWO OR MORE VALUES on slave
select * from t2 ORDER BY i1;
connection master;
drop table t1;
drop table t2;
drop function f1_two_updates;
sync_slave_with_master;
--echo # Test case13: UPDATE MORE THAN ONE TABLES ON TOP-STATEMENT
connection master;
create table t1(i1 int not null auto_increment, a int, b int, primary key(i1)) engine=innodb;
create table t2(i1 int not null auto_increment, a int, b int, primary key(i1)) engine=innodb;
begin;
let $binlog_start= query_get_value(SHOW MASTER STATUS, Position, 1);
insert into t1(a,b) values(1,1),(2,2);
insert into t2(a,b) values(1,1),(2,2);
update t1,t2 set t1.a=t1.a+5, t2.a=t2.a+5 where t1.b=t2.b;
insert into t1(a,b) values(3,3);
insert into t2(a,b) values(3,3);
commit;
--echo # To verify if it works fine when these statements are not be marked as unsafe
source include/show_binlog_events.inc;
sync_slave_with_master;
--echo #Test if the results are consistent on master and slave
--echo #for 'UPDATE MORE THAN ONE TABLES ON TOP-STATEMENT'
let $diff_table_1=master:test.t1;
let $diff_table_2=slave:test.t1;
source include/diff_tables.inc;
let $diff_table_1=master:test.t2;
let $diff_table_2=slave:test.t2;
source include/diff_tables.inc;
connection master;
drop table t1;
drop table t2;
sync_slave_with_master;
--echo # Test case14: INSERT DATA INTO VIEW WHICH INVOLVED MORE THAN ONE TABLES
connection master;
CREATE TABLE t1(i1 int not null auto_increment, c1 INT, primary key(i1)) engine=innodb;
CREATE TABLE t2(i1 int not null auto_increment, c2 INT, primary key(i1)) engine=innodb;
let $binlog_start= query_get_value(SHOW MASTER STATUS, Position, 1);
begin;
INSERT INTO t1(c1) VALUES (11), (12);
INSERT INTO t2(c2) VALUES (13), (14);
CREATE VIEW v15 AS SELECT c1, c2 FROM t1, t2;
INSERT INTO v15(c1) VALUES (15),(16);
INSERT INTO v15(c2) VALUES (17),(18);
connection master1;
INSERT INTO v15(c1) VALUES (19),(20);
INSERT INTO v15(c2) VALUES (21),(22);
connection master;
INSERT INTO v15(c1) VALUES (23), (24);
INSERT INTO v15(c2) VALUES (25), (26);
commit;
--echo # To verify if it works fine when these statements are not be marked as unsafe
source include/show_binlog_events.inc;
sync_slave_with_master;
--echo #Test if the results are consistent on master and slave
--echo #for 'INSERT DATA INTO VIEW WHICH INVOLVED MORE THAN ONE TABLES'
let $diff_table_1=master:test.t1;
let $diff_table_2=slave:test.t1;
source include/diff_tables.inc;
let $diff_table_1=master:test.t2;
let $diff_table_2=slave:test.t2;
source include/diff_tables.inc;
connection master;
drop table t1;
drop table t2;
drop view v15;
sync_slave_with_master;

View File

@ -0,0 +1,420 @@
###################### t/debug_sync.test ###############################
# #
# Testing of the Debug Sync Facility. #
# #
# There is important documentation within sql/debug_sync.cc #
# #
# Used objects in this test case: #
# p0 - synchronization point 0. Non-existent dummy sync point. #
# s1 - signal 1. #
# s2 - signal 2. #
# #
# Creation: #
# 2008-02-18 istruewing #
# #
########################################################################
#
# We need the Debug Sync Facility.
#
--source include/have_debug_sync.inc
#
# We are checking privileges, which the embedded server cannot do.
#
--source include/not_embedded.inc
#
# Preparative cleanup.
#
--disable_warnings
SET DEBUG_SYNC= 'RESET';
DROP TABLE IF EXISTS t1;
--enable_warnings
#
# Show the special system variable.
# It shows ON or OFF depending on the command line option --debug-sync.
# The test case assumes it is ON (command line option present).
#
SHOW VARIABLES LIKE 'DEBUG_SYNC';
#
# Syntax. Valid forms.
#
SET DEBUG_SYNC='p0 SIGNAL s1 WAIT_FOR s2 TIMEOUT 6 EXECUTE 2 HIT_LIMIT 3';
SET DEBUG_SYNC='p0 SIGNAL s1 WAIT_FOR s2 TIMEOUT 6 EXECUTE 2';
SET DEBUG_SYNC='p0 SIGNAL s1 WAIT_FOR s2 TIMEOUT 6 HIT_LIMIT 3';
SET DEBUG_SYNC='p0 SIGNAL s1 WAIT_FOR s2 TIMEOUT 6';
SET DEBUG_SYNC='p0 SIGNAL s1 WAIT_FOR s2 EXECUTE 2 HIT_LIMIT 3';
SET DEBUG_SYNC='p0 SIGNAL s1 WAIT_FOR s2 EXECUTE 2';
SET DEBUG_SYNC='p0 SIGNAL s1 WAIT_FOR s2 HIT_LIMIT 3';
SET DEBUG_SYNC='p0 SIGNAL s1 WAIT_FOR s2';
SET DEBUG_SYNC='p0 SIGNAL s1 EXECUTE 2 HIT_LIMIT 3';
SET DEBUG_SYNC='p0 SIGNAL s1 EXECUTE 2';
SET DEBUG_SYNC='p0 SIGNAL s1 HIT_LIMIT 3';
SET DEBUG_SYNC='p0 SIGNAL s1';
SET DEBUG_SYNC='p0 WAIT_FOR s2 TIMEOUT 6 EXECUTE 2 HIT_LIMIT 3';
SET DEBUG_SYNC='p0 WAIT_FOR s2 TIMEOUT 6 EXECUTE 2';
SET DEBUG_SYNC='p0 WAIT_FOR s2 TIMEOUT 6 HIT_LIMIT 3';
SET DEBUG_SYNC='p0 WAIT_FOR s2 TIMEOUT 6';
SET DEBUG_SYNC='p0 WAIT_FOR s2 EXECUTE 2 HIT_LIMIT 3';
SET DEBUG_SYNC='p0 WAIT_FOR s2 EXECUTE 2';
SET DEBUG_SYNC='p0 WAIT_FOR s2 HIT_LIMIT 3';
SET DEBUG_SYNC='p0 WAIT_FOR s2';
SET DEBUG_SYNC='p0 HIT_LIMIT 3';
SET DEBUG_SYNC='p0 CLEAR';
SET DEBUG_SYNC='p0 TEST';
SET DEBUG_SYNC='RESET';
#
# Syntax. Valid forms. Lower case.
#
set debug_sync='p0 signal s1 wait_for s2 timeout 6 execute 2 hit_limit 3';
set debug_sync='p0 signal s1 wait_for s2 timeout 6 execute 2';
set debug_sync='p0 signal s1 wait_for s2 timeout 6 hit_limit 3';
set debug_sync='p0 signal s1 wait_for s2 timeout 6';
set debug_sync='p0 signal s1 wait_for s2 execute 2 hit_limit 3';
set debug_sync='p0 signal s1 wait_for s2 execute 2';
set debug_sync='p0 signal s1 wait_for s2 hit_limit 3';
set debug_sync='p0 signal s1 wait_for s2';
set debug_sync='p0 signal s1 execute 2 hit_limit 3';
set debug_sync='p0 signal s1 execute 2';
set debug_sync='p0 signal s1 hit_limit 3';
set debug_sync='p0 signal s1';
set debug_sync='p0 wait_for s2 timeout 6 execute 2 hit_limit 3';
set debug_sync='p0 wait_for s2 timeout 6 execute 2';
set debug_sync='p0 wait_for s2 timeout 6 hit_limit 3';
set debug_sync='p0 wait_for s2 timeout 6';
set debug_sync='p0 wait_for s2 execute 2 hit_limit 3';
set debug_sync='p0 wait_for s2 execute 2';
set debug_sync='p0 wait_for s2 hit_limit 3';
set debug_sync='p0 wait_for s2';
set debug_sync='p0 hit_limit 3';
set debug_sync='p0 clear';
set debug_sync='p0 test';
set debug_sync='reset';
#
# Syntax. Valid forms. Line wrap, leading, mid, trailing space.
#
SET DEBUG_SYNC='p0 SIGNAL s1 WAIT_FOR s2 TIMEOUT 6
EXECUTE 2 HIT_LIMIT 3';
SET DEBUG_SYNC=' p0 SIGNAL s1 WAIT_FOR s2';
SET DEBUG_SYNC='p0 SIGNAL s1 WAIT_FOR s2';
SET DEBUG_SYNC='p0 SIGNAL s1 WAIT_FOR s2 ';
SET DEBUG_SYNC=' p0 SIGNAL s1 WAIT_FOR s2 ';
SET DEBUG_SYNC=' p0 SIGNAL s1 WAIT_FOR s2 ';
#
# Syntax. Invalid forms.
#
--error ER_PARSE_ERROR
SET DEBUG_SYNC='';
--error ER_PARSE_ERROR
SET DEBUG_SYNC=' ';
--error ER_PARSE_ERROR
SET DEBUG_SYNC='p0';
--error ER_PARSE_ERROR
SET DEBUG_SYNC='p0 EXECUTE 2';
--error ER_PARSE_ERROR
SET DEBUG_SYNC='p0 TIMEOUT 6 EXECUTE 2';
--error ER_PARSE_ERROR
SET DEBUG_SYNC='p0 TIMEOUT 6';
--error ER_PARSE_ERROR
SET DEBUG_SYNC='p0 WAIT_FOR s2 SIGNAL s1';
--error ER_PARSE_ERROR
SET DEBUG_SYNC='p0 WAIT_FOR s2 SIGNAL s1 EXECUTE 2';
--error ER_PARSE_ERROR
SET DEBUG_SYNC='p0 WAIT_FOR s2 SIGNAL s1 TIMEOUT 6 EXECUTE 2';
--error ER_PARSE_ERROR
SET DEBUG_SYNC='p0 WAIT_FOR s2 SIGNAL s1 TIMEOUT 6';
--error ER_PARSE_ERROR
SET DEBUG_SYNC='p0 WAIT_FOR s2 TIMEOUT 6 SIGNAL s1 EXECUTE 2';
--error ER_PARSE_ERROR
SET DEBUG_SYNC='p0 WAIT_FOR s2 TIMEOUT 6 SIGNAL s1';
--error ER_PARSE_ERROR
SET DEBUG_SYNC='p0 TIMEOUT 6 WAIT_FOR s2 EXECUTE 2';
--error ER_PARSE_ERROR
SET DEBUG_SYNC='p0 TIMEOUT 6 WAIT_FOR s2';
--error ER_PARSE_ERROR
SET DEBUG_SYNC='p0 SIGNAL s1 TIMEOUT 6 EXECUTE 2';
--error ER_PARSE_ERROR
SET DEBUG_SYNC='p0 SIGNAL s1 TIMEOUT 6';
--error ER_PARSE_ERROR
SET DEBUG_SYNC='p0 EXECUTE 2 SIGNAL s1 TIMEOUT 6';
--error ER_PARSE_ERROR
SET DEBUG_SYNC='p0 TIMEOUT 6 SIGNAL s1';
--error ER_PARSE_ERROR
SET DEBUG_SYNC='p0 EXECUTE 2 TIMEOUT 6 SIGNAL s1';
--error ER_PARSE_ERROR
SET DEBUG_SYNC='p0 CLEAR HIT_LIMIT 3';
--error ER_PARSE_ERROR
SET DEBUG_SYNC='CLEAR';
--error ER_PARSE_ERROR
SET DEBUG_SYNC='p0 CLEAR p0';
--error ER_PARSE_ERROR
SET DEBUG_SYNC='TEST';
--error ER_PARSE_ERROR
SET DEBUG_SYNC='p0 TEST p0';
--error ER_PARSE_ERROR
SET DEBUG_SYNC='p0 RESET';
--error ER_PARSE_ERROR
SET DEBUG_SYNC='RESET p0';
--error ER_PARSE_ERROR
SET DEBUG_SYNC='p0 RESET p0';
--error ER_PARSE_ERROR
SET DEBUG_SYNC='p0 SIGNAL ';
--error ER_PARSE_ERROR
SET DEBUG_SYNC='p0 WAIT_FOR ';
--error ER_PARSE_ERROR
SET DEBUG_SYNC='p0 SIGNAL s1 EXECUTE ';
#
# Syntax. Invalid keywords used.
#
--error ER_UNKNOWN_SYSTEM_VARIABLE
SET DEBUG_SYNCx='p0 SIGNAL s1 WAIT_FOR s2 TIMEOUT 6 EXECUTE 2 HIT_LIMIT 3';
--error ER_PARSE_ERROR
SET DEBUG_SYNC='p0 SIGNAx s1 WAIT_FOR s2 TIMEOUT 6 EXECUTE 2 HIT_LIMIT 3';
--error ER_PARSE_ERROR
SET DEBUG_SYNC='p0 SIGNAL s1 WAIT_FOx s2 TIMEOUT 6 EXECUTE 2 HIT_LIMIT 3';
--error ER_PARSE_ERROR
SET DEBUG_SYNC='p0 SIGNAL s1 WAIT_FOR s2 TIMEOUx 0 EXECUTE 2 HIT_LIMIT 3';
--error ER_PARSE_ERROR
SET DEBUG_SYNC='p0 SIGNAL s1 WAIT_FOR s2 TIMEOUT 6 EXECUTx 2 HIT_LIMIT 3';
--error ER_PARSE_ERROR
SET DEBUG_SYNC='p0 SIGNAL s1 WAIT_FOR s2 TIMEOUT 6 EXECUTE 2 HIT_LIMIx 3';
--error ER_PARSE_ERROR
SET DEBUG_SYNC='p0 CLEARx';
--error ER_PARSE_ERROR
SET DEBUG_SYNC='p0 TESTx';
--error ER_PARSE_ERROR
SET DEBUG_SYNC='RESETx';
#
# Syntax. Invalid numbers. Decimal only.
#
--error ER_PARSE_ERROR
SET DEBUG_SYNC='p0 WAIT_FOR s2 TIMEOUT 0x6 EXECUTE 2 HIT_LIMIT 3';
--error ER_PARSE_ERROR
SET DEBUG_SYNC='p0 WAIT_FOR s2 TIMEOUT 6 EXECUTE 0x2 HIT_LIMIT 3';
--error ER_PARSE_ERROR
SET DEBUG_SYNC='p0 WAIT_FOR s2 TIMEOUT 7 EXECUTE 2 HIT_LIMIT 0x3';
#
# Syntax. Invalid value type.
#
--error ER_WRONG_TYPE_FOR_VAR
SET DEBUG_SYNC= 7;
#
# Syntax. DEBUG_SYNC is a SESSION-only variable.
#
--error ER_LOCAL_VARIABLE
SET GLOBAL DEBUG_SYNC= 'p0 CLEAR';
#
# Syntax. The variable value does not need to be a string literal.
#
SET @myvar= 'now SIGNAL from_myvar';
SET DEBUG_SYNC= @myvar;
SHOW VARIABLES LIKE 'DEBUG_SYNC';
#
SET DEBUG_SYNC= LEFT('now SIGNAL from_function_cut_here', 24);
SHOW VARIABLES LIKE 'DEBUG_SYNC';
#
# Functional tests.
#
# NOTE: There is the special synchronization point 'now'. It is placed
# immediately after setting of the DEBUG_SYNC variable.
# So it is executed before the SET statement ends.
#
# NOTE: There is only one global signal (say "signal post" or "flag mast").
# A SIGNAL action writes its signal into it ("sets a flag").
# The signal persists until explicitly overwritten.
# To avoid confusion for later tests, it is recommended to clear
# the signal by signalling "empty" ("setting the 'empty' flag"):
# SET DEBUG_SYNC= 'now SIGNAL empty';
# Preferably you can reset the whole facility with:
# SET DEBUG_SYNC= 'RESET';
# The signal is then '' (really empty) which connot be done otherwise.
#
#
# Time out immediately. This gives just a warning.
#
SET DEBUG_SYNC= 'now SIGNAL something';
SHOW VARIABLES LIKE 'DEBUG_SYNC';
# Suppress warning number
--replace_column 2 ####
SET DEBUG_SYNC= 'now WAIT_FOR nothing TIMEOUT 0';
#
# If signal is present already, TIMEOUT 0 does not give a warning.
#
SET DEBUG_SYNC= 'now SIGNAL nothing';
SHOW VARIABLES LIKE 'DEBUG_SYNC';
SET DEBUG_SYNC= 'now WAIT_FOR nothing TIMEOUT 0';
#
# EXECUTE 0 is effectively a no-op.
#
SET DEBUG_SYNC= 'now SIGNAL something EXECUTE 0';
SHOW VARIABLES LIKE 'DEBUG_SYNC';
SET DEBUG_SYNC= 'now WAIT_FOR anotherthing TIMEOUT 0 EXECUTE 0';
#
# Run into HIT_LIMIT. This gives an error.
#
--error ER_DEBUG_SYNC_HIT_LIMIT
SET DEBUG_SYNC= 'now HIT_LIMIT 1';
#
# Many actions. Watch the array growing and shrinking in the debug trace:
# egrep 'query:|debug_sync_action:' mysql-test/var/log/master.trace
#
SET DEBUG_SYNC= 'RESET';
SHOW VARIABLES LIKE 'DEBUG_SYNC';
SET DEBUG_SYNC= 'p1abcd SIGNAL s1 EXECUTE 2';
SET DEBUG_SYNC= 'p2abc SIGNAL s2 EXECUTE 2';
SET DEBUG_SYNC= 'p9abcdef SIGNAL s9 EXECUTE 2';
SET DEBUG_SYNC= 'p4a SIGNAL s4 EXECUTE 2';
SET DEBUG_SYNC= 'p5abcde SIGNAL s5 EXECUTE 2';
SET DEBUG_SYNC= 'p6ab SIGNAL s6 EXECUTE 2';
SET DEBUG_SYNC= 'p7 SIGNAL s7 EXECUTE 2';
SET DEBUG_SYNC= 'p8abcdef SIGNAL s8 EXECUTE 2';
SET DEBUG_SYNC= 'p3abcdef SIGNAL s3 EXECUTE 2';
#
# Execute some actions to show they exist. Each sets a distinct signal.
#
SET DEBUG_SYNC= 'p4a TEST';
SHOW VARIABLES LIKE 'DEBUG_SYNC';
SET DEBUG_SYNC= 'p1abcd TEST';
SHOW VARIABLES LIKE 'DEBUG_SYNC';
SET DEBUG_SYNC= 'p7 TEST';
SHOW VARIABLES LIKE 'DEBUG_SYNC';
SET DEBUG_SYNC= 'p9abcdef TEST';
SHOW VARIABLES LIKE 'DEBUG_SYNC';
SET DEBUG_SYNC= 'p3abcdef TEST';
SHOW VARIABLES LIKE 'DEBUG_SYNC';
#
# Clear the actions.
#
SET DEBUG_SYNC= 'p1abcd CLEAR';
SET DEBUG_SYNC= 'p2abc CLEAR';
SET DEBUG_SYNC= 'p5abcde CLEAR';
SET DEBUG_SYNC= 'p6ab CLEAR';
SET DEBUG_SYNC= 'p8abcdef CLEAR';
SET DEBUG_SYNC= 'p9abcdef CLEAR';
SET DEBUG_SYNC= 'p3abcdef CLEAR';
SET DEBUG_SYNC= 'p4a CLEAR';
SET DEBUG_SYNC= 'p7 CLEAR';
#
# Execute some actions to show they have gone.
#
SET DEBUG_SYNC= 'p1abcd TEST';
SHOW VARIABLES LIKE 'DEBUG_SYNC';
SET DEBUG_SYNC= 'p7 TEST';
SHOW VARIABLES LIKE 'DEBUG_SYNC';
SET DEBUG_SYNC= 'p9abcdef TEST';
SHOW VARIABLES LIKE 'DEBUG_SYNC';
#
# Now cleanup. Actions are clear already, but signal needs to be cleared.
#
SET DEBUG_SYNC= 'RESET';
SHOW VARIABLES LIKE 'DEBUG_SYNC';
#
# Facility requires SUPER privilege.
#
CREATE USER mysqltest_1@localhost;
GRANT SUPER ON *.* TO mysqltest_1@localhost;
--echo connection con1, mysqltest_1
connect (con1,localhost,mysqltest_1,,);
SET DEBUG_SYNC= 'RESET';
disconnect con1;
--echo connection default
connection default;
DROP USER mysqltest_1@localhost;
#
CREATE USER mysqltest_2@localhost;
GRANT ALL ON *.* TO mysqltest_2@localhost;
REVOKE SUPER ON *.* FROM mysqltest_2@localhost;
--echo connection con1, mysqltest_2
connect (con1,localhost,mysqltest_2,,);
--error ER_SPECIFIC_ACCESS_DENIED_ERROR
SET DEBUG_SYNC= 'RESET';
disconnect con1;
--echo connection default
connection default;
DROP USER mysqltest_2@localhost;
#
# Example 1.
#
# Preparative cleanup.
--disable_warnings
SET DEBUG_SYNC= 'RESET';
DROP TABLE IF EXISTS t1;
--enable_warnings
#
# Test.
CREATE TABLE t1 (c1 INT);
--echo connection con1
connect (con1,localhost,root,,);
SET DEBUG_SYNC= 'before_lock_tables_takes_lock
SIGNAL opened WAIT_FOR flushed';
send INSERT INTO t1 VALUES(1);
--echo connection default
connection default;
SET DEBUG_SYNC= 'now WAIT_FOR opened';
SET DEBUG_SYNC= 'after_flush_unlock SIGNAL flushed';
FLUSH TABLE t1;
--echo connection con1
connection con1;
reap;
disconnect con1;
--echo connection default
connection default;
DROP TABLE t1;
#
# Example 2.
#
# Preparative cleanup.
--disable_warnings
SET DEBUG_SYNC= 'RESET';
DROP TABLE IF EXISTS t1;
--enable_warnings
#
# Test.
CREATE TABLE t1 (c1 INT);
LOCK TABLE t1 WRITE;
--echo connection con1
connect (con1,localhost,root,,);
# Retain action after use. First used by general_log.
SET DEBUG_SYNC= 'wait_for_lock SIGNAL locked EXECUTE 2';
send INSERT INTO t1 VALUES (1);
--echo connection default
connection default;
# Wait until INSERT waits for lock.
SET DEBUG_SYNC= 'now WAIT_FOR locked';
# let INSERT continue.
UNLOCK TABLES;
--echo connection con1
connection con1;
--echo retrieve INSERT result.
reap;
disconnect con1;
--echo connection default
connection default;
DROP TABLE t1;
#
# Cleanup after test case.
# Otherwise signal would contain 'flushed' here,
# which could confuse the next test.
#
SET DEBUG_SYNC= 'RESET';

View File

@ -456,4 +456,89 @@ SELECT SUM( DISTINCT e ) FROM t1 GROUP BY b,c,d HAVING (b,c,d) IN
((AVG( 1 ), 1 + c, 1 + d), (AVG( 1 ), 2 + c, 2 + d)); ((AVG( 1 ), 1 + c, 1 + d), (AVG( 1 ), 2 + c, 2 + d));
DROP TABLE t1; DROP TABLE t1;
--echo #
--echo # Bug #44139: Table scan when NULL appears in IN clause
--echo #
--disable_warnings
CREATE TABLE t1 (
c_int INT NOT NULL,
c_decimal DECIMAL(5,2) NOT NULL,
c_float FLOAT(5, 2) NOT NULL,
c_bit BIT(10) NOT NULL,
c_date DATE NOT NULL,
c_datetime DATETIME NOT NULL,
c_timestamp TIMESTAMP NOT NULL,
c_time TIME NOT NULL,
c_year YEAR NOT NULL,
c_char CHAR(10) NOT NULL,
INDEX(c_int), INDEX(c_decimal), INDEX(c_float), INDEX(c_bit), INDEX(c_date),
INDEX(c_datetime), INDEX(c_timestamp), INDEX(c_time), INDEX(c_year),
INDEX(c_char));
INSERT INTO t1 (c_int) VALUES (1), (2), (3), (4), (5);
INSERT INTO t1 (c_int) SELECT 0 FROM t1;
INSERT INTO t1 (c_int) SELECT 0 FROM t1;
--enable_warnings
EXPLAIN SELECT * FROM t1 WHERE c_int IN (1, 2, 3);
EXPLAIN SELECT * FROM t1 WHERE c_int IN (NULL, 1, 2, 3);
EXPLAIN SELECT * FROM t1 WHERE c_int IN (1, 2, 3);
EXPLAIN SELECT * FROM t1 WHERE c_int IN (1, NULL, 2, NULL, 3, NULL);
EXPLAIN SELECT * FROM t1 WHERE c_int IN (NULL);
EXPLAIN SELECT * FROM t1 WHERE c_int IN (NULL, NULL);
EXPLAIN SELECT * FROM t1 WHERE c_decimal IN (1, 2, 3);
EXPLAIN SELECT * FROM t1 WHERE c_decimal IN (NULL, 1, 2, 3);
EXPLAIN SELECT * FROM t1 WHERE c_decimal IN (NULL);
EXPLAIN SELECT * FROM t1 WHERE c_decimal IN (NULL, NULL);
EXPLAIN SELECT * FROM t1 WHERE c_float IN (1, 2, 3);
EXPLAIN SELECT * FROM t1 WHERE c_float IN (NULL, 1, 2, 3);
EXPLAIN SELECT * FROM t1 WHERE c_float IN (NULL);
EXPLAIN SELECT * FROM t1 WHERE c_float IN (NULL, NULL);
EXPLAIN SELECT * FROM t1 WHERE c_bit IN (1, 2, 3);
EXPLAIN SELECT * FROM t1 WHERE c_bit IN (NULL, 1, 2, 3);
EXPLAIN SELECT * FROM t1 WHERE c_bit IN (NULL);
EXPLAIN SELECT * FROM t1 WHERE c_bit IN (NULL, NULL);
EXPLAIN SELECT * FROM t1 WHERE c_date
IN ('2009-09-01', '2009-09-02', '2009-09-03');
EXPLAIN SELECT * FROM t1 WHERE c_date
IN (NULL, '2009-09-01', '2009-09-02', '2009-09-03');
EXPLAIN SELECT * FROM t1 WHERE c_date IN (NULL);
EXPLAIN SELECT * FROM t1 WHERE c_date IN (NULL, NULL);
EXPLAIN SELECT * FROM t1 WHERE c_datetime
IN ('2009-09-01 00:00:01', '2009-09-02 00:00:01', '2009-09-03 00:00:01');
EXPLAIN SELECT * FROM t1 WHERE c_datetime
IN (NULL, '2009-09-01 00:00:01', '2009-09-02 00:00:01', '2009-09-03 00:00:01');
EXPLAIN SELECT * FROM t1 WHERE c_datetime IN (NULL);
EXPLAIN SELECT * FROM t1 WHERE c_datetime IN (NULL, NULL);
EXPLAIN SELECT * FROM t1 WHERE c_timestamp
IN ('2009-09-01 00:00:01', '2009-09-01 00:00:02', '2009-09-01 00:00:03');
EXPLAIN SELECT * FROM t1 WHERE c_timestamp
IN (NULL, '2009-09-01 00:00:01', '2009-09-01 00:00:02', '2009-09-01 00:00:03');
EXPLAIN SELECT * FROM t1 WHERE c_timestamp IN (NULL);
EXPLAIN SELECT * FROM t1 WHERE c_timestamp IN (NULL, NULL);
EXPLAIN SELECT * FROM t1 WHERE c_year IN (1, 2, 3);
EXPLAIN SELECT * FROM t1 WHERE c_year IN (NULL, 1, 2, 3);
EXPLAIN SELECT * FROM t1 WHERE c_year IN (NULL);
EXPLAIN SELECT * FROM t1 WHERE c_year IN (NULL, NULL);
EXPLAIN SELECT * FROM t1 WHERE c_char IN ('1', '2', '3');
EXPLAIN SELECT * FROM t1 WHERE c_char IN (NULL, '1', '2', '3');
EXPLAIN SELECT * FROM t1 WHERE c_char IN (NULL);
EXPLAIN SELECT * FROM t1 WHERE c_char IN (NULL, NULL);
DROP TABLE t1;
--echo #
--echo End of 5.1 tests --echo End of 5.1 tests

View File

@ -1,4 +1,4 @@
# Copyright (C) 2000-2006 MySQL AB # Copyright (C) 2000-2006 MySQL AB, 2009 Sun Microsystems, Inc.
# #
# This program is free software; you can redistribute it and/or modify # This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by # it under the terms of the GNU General Public License as published by
@ -25,7 +25,7 @@ libmysys_a_SOURCES = my_init.c my_getwd.c mf_getdate.c my_mmap.c \
mf_path.c mf_loadpath.c my_file.c \ mf_path.c mf_loadpath.c my_file.c \
my_open.c my_create.c my_dup.c my_seek.c my_read.c \ my_open.c my_create.c my_dup.c my_seek.c my_read.c \
my_pread.c my_write.c my_getpagesize.c \ my_pread.c my_write.c my_getpagesize.c \
mf_keycache.c mf_keycaches.c my_crc32.c \ mf_keycaches.c my_crc32.c \
mf_iocache.c mf_iocache2.c mf_cache.c mf_tempfile.c \ mf_iocache.c mf_iocache2.c mf_cache.c mf_tempfile.c \
mf_tempdir.c my_lock.c mf_brkhant.c my_alarm.c \ mf_tempdir.c my_lock.c mf_brkhant.c my_alarm.c \
my_malloc.c my_realloc.c my_once.c mulalloc.c \ my_malloc.c my_realloc.c my_once.c mulalloc.c \
@ -53,6 +53,14 @@ libmysys_a_SOURCES = my_init.c my_getwd.c mf_getdate.c my_mmap.c \
my_handler.c my_netware.c my_largepage.c \ my_handler.c my_netware.c my_largepage.c \
my_memmem.c stacktrace.c \ my_memmem.c stacktrace.c \
my_windac.c my_access.c base64.c my_libwrap.c my_windac.c my_access.c base64.c my_libwrap.c
if NEED_THREAD
# mf_keycache is used only in the server, so it is safe to leave the file
# out of the non-threaded library.
# In fact, it will currently not compile without thread support.
libmysys_a_SOURCES += mf_keycache.c
endif
EXTRA_DIST = thr_alarm.c thr_lock.c my_pthread.c my_thr_init.c \ EXTRA_DIST = thr_alarm.c thr_lock.c my_pthread.c my_thr_init.c \
thr_mutex.c thr_rwlock.c \ thr_mutex.c thr_rwlock.c \
CMakeLists.txt mf_soundex.c \ CMakeLists.txt mf_soundex.c \

View File

@ -92,6 +92,14 @@ int (*error_handler_hook)(uint error,const char *str,myf MyFlags)=
int (*fatal_error_handler_hook)(uint error,const char *str,myf MyFlags)= int (*fatal_error_handler_hook)(uint error,const char *str,myf MyFlags)=
my_message_no_curses; my_message_no_curses;
#if defined(ENABLED_DEBUG_SYNC)
/**
Global pointer to be set if callback function is defined
(e.g. in mysqld). See sql/debug_sync.cc.
*/
void (*debug_sync_C_callback_ptr)(const char *, size_t);
#endif /* defined(ENABLED_DEBUG_SYNC) */
#ifdef __WIN__ #ifdef __WIN__
/* from my_getsystime.c */ /* from my_getsystime.c */
ulonglong query_performance_frequency, query_performance_offset; ulonglong query_performance_frequency, query_performance_offset;

View File

@ -120,13 +120,12 @@ int pthread_cond_timedwait(pthread_cond_t *cond, pthread_mutex_t *mutex,
LeaveCriticalSection(&cond->lock_waiting); LeaveCriticalSection(&cond->lock_waiting);
LeaveCriticalSection(mutex); LeaveCriticalSection(mutex);
result= WaitForMultipleObjects(2, cond->events, FALSE, timeout); result= WaitForMultipleObjects(2, cond->events, FALSE, timeout);
EnterCriticalSection(&cond->lock_waiting); EnterCriticalSection(&cond->lock_waiting);
cond->waiting--; cond->waiting--;
if (cond->waiting == 0 && result == (WAIT_OBJECT_0+BROADCAST)) if (cond->waiting == 0)
{ {
/* /*
We're the last waiter to be notified or to stop waiting, so We're the last waiter to be notified or to stop waiting, so

View File

@ -398,6 +398,28 @@ wait_for_lock(struct st_lock_list *wait, THR_LOCK_DATA *data,
my_bool can_deadlock= test(data->owner->info->n_cursors); my_bool can_deadlock= test(data->owner->info->n_cursors);
DBUG_ENTER("wait_for_lock"); DBUG_ENTER("wait_for_lock");
/*
One can use this to signal when a thread is going to wait for a lock.
See debug_sync.cc.
Beware of waiting for a signal here. The lock has aquired its mutex.
While waiting on a signal here, the locking thread could not aquire
the mutex to release the lock. One could lock up the table
completely.
In detail it works so: When thr_lock() tries to acquire a table
lock, it locks the lock->mutex, checks if it can have the lock, and
if not, it calls wait_for_lock(). Here it unlocks the table lock
while waiting on a condition. The sync point is located before this
wait for condition. If we have a waiting action here, we hold the
the table locks mutex all the time. Any attempt to look at the table
lock by another thread blocks it immediately on lock->mutex. This
can easily become an unexpected and unobvious blockage. So be
warned: Do not request a WAIT_FOR action for the 'wait_for_lock'
sync point unless you really know what you do.
*/
DEBUG_SYNC_C("wait_for_lock");
if (!in_wait_list) if (!in_wait_list)
{ {
(*wait->last)=data; /* Wait for lock */ (*wait->last)=data; /* Wait for lock */

View File

@ -64,6 +64,7 @@ SET (SQL_SOURCE
sql_error.cc sql_handler.cc sql_help.cc sql_insert.cc sql_lex.cc sql_error.cc sql_handler.cc sql_help.cc sql_insert.cc sql_lex.cc
sql_list.cc sql_load.cc sql_manager.cc sql_map.cc sql_parse.cc sql_list.cc sql_load.cc sql_manager.cc sql_map.cc sql_parse.cc
sql_partition.cc sql_plugin.cc sql_prepare.cc sql_rename.cc sql_partition.cc sql_plugin.cc sql_prepare.cc sql_rename.cc
debug_sync.cc debug_sync.h
sql_repl.cc sql_select.cc sql_show.cc sql_state.c sql_string.cc sql_repl.cc sql_select.cc sql_show.cc sql_state.c sql_string.cc
sql_table.cc sql_test.cc sql_trigger.cc sql_udf.cc sql_union.cc sql_table.cc sql_test.cc sql_trigger.cc sql_udf.cc sql_union.cc
sql_update.cc sql_view.cc strfunc.cc table.cc thr_malloc.cc sql_update.cc sql_view.cc strfunc.cc table.cc thr_malloc.cc

View File

@ -58,6 +58,7 @@ noinst_HEADERS = item.h item_func.h item_sum.h item_cmpfunc.h \
ha_ndbcluster.h ha_ndbcluster_cond.h \ ha_ndbcluster.h ha_ndbcluster_cond.h \
ha_ndbcluster_binlog.h ha_ndbcluster_tables.h \ ha_ndbcluster_binlog.h ha_ndbcluster_tables.h \
ha_partition.h rpl_constants.h \ ha_partition.h rpl_constants.h \
debug_sync.h \
opt_range.h protocol.h rpl_tblmap.h rpl_utility.h \ opt_range.h protocol.h rpl_tblmap.h rpl_utility.h \
rpl_reporting.h \ rpl_reporting.h \
log.h sql_show.h rpl_rli.h rpl_mi.h \ log.h sql_show.h rpl_rli.h rpl_mi.h \
@ -102,6 +103,7 @@ mysqld_SOURCES = sql_lex.cc sql_handler.cc sql_partition.cc \
discover.cc time.cc opt_range.cc opt_sum.cc \ discover.cc time.cc opt_range.cc opt_sum.cc \
records.cc filesort.cc handler.cc \ records.cc filesort.cc handler.cc \
ha_partition.cc \ ha_partition.cc \
debug_sync.cc \
sql_db.cc sql_table.cc sql_rename.cc sql_crypt.cc \ sql_db.cc sql_table.cc sql_rename.cc sql_crypt.cc \
sql_load.cc mf_iocache.cc field_conv.cc sql_show.cc \ sql_load.cc mf_iocache.cc field_conv.cc sql_show.cc \
sql_udf.cc sql_analyse.cc sql_analyse.h sql_cache.cc \ sql_udf.cc sql_analyse.cc sql_analyse.h sql_cache.cc \

1906
sql/debug_sync.cc Normal file

File diff suppressed because it is too large Load Diff

60
sql/debug_sync.h Normal file
View File

@ -0,0 +1,60 @@
#ifndef DEBUG_SYNC_INCLUDED
#define DEBUG_SYNC_INCLUDED
/* Copyright (C) 2008 Sun Microsystems, Inc.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; version 2 of the License.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
/**
@file
Declarations for the Debug Sync Facility. See debug_sync.cc for details.
*/
#ifdef USE_PRAGMA_INTERFACE
#pragma interface /* gcc class implementation */
#endif
#include <my_global.h>
class THD;
#if defined(ENABLED_DEBUG_SYNC)
/* Macro to be put in the code at synchronization points. */
#define DEBUG_SYNC(_thd_, _sync_point_name_) \
do { if (unlikely(opt_debug_sync_timeout)) \
debug_sync(_thd_, STRING_WITH_LEN(_sync_point_name_)); \
} while (0)
/* Command line option --debug-sync-timeout. See mysqld.cc. */
extern uint opt_debug_sync_timeout;
/* Default WAIT_FOR timeout if command line option is given without argument. */
#define DEBUG_SYNC_DEFAULT_WAIT_TIMEOUT 300
/* Debug Sync prototypes. See debug_sync.cc. */
extern int debug_sync_init(void);
extern void debug_sync_end(void);
extern void debug_sync_init_thread(THD *thd);
extern void debug_sync_end_thread(THD *thd);
extern void debug_sync(THD *thd, const char *sync_point_name, size_t name_len);
#else /* defined(ENABLED_DEBUG_SYNC) */
#define DEBUG_SYNC(_thd_, _sync_point_name_) /* disabled DEBUG_SYNC */
#endif /* defined(ENABLED_DEBUG_SYNC) */
#endif /* DEBUG_SYNC_INCLUDED */

View File

@ -189,6 +189,7 @@ enum_field_types agg_field_type(Item **items, uint nitems)
collect_cmp_types() collect_cmp_types()
items Array of items to collect types from items Array of items to collect types from
nitems Number of items in the array nitems Number of items in the array
skip_nulls Don't collect types of NULL items if TRUE
DESCRIPTION DESCRIPTION
This function collects different result types for comparison of the first This function collects different result types for comparison of the first
@ -199,7 +200,7 @@ enum_field_types agg_field_type(Item **items, uint nitems)
Bitmap of collected types - otherwise Bitmap of collected types - otherwise
*/ */
static uint collect_cmp_types(Item **items, uint nitems) static uint collect_cmp_types(Item **items, uint nitems, bool skip_nulls= FALSE)
{ {
uint i; uint i;
uint found_types; uint found_types;
@ -208,6 +209,8 @@ static uint collect_cmp_types(Item **items, uint nitems)
found_types= 0; found_types= 0;
for (i= 1; i < nitems ; i++) for (i= 1; i < nitems ; i++)
{ {
if (skip_nulls && items[i]->type() == Item::NULL_ITEM)
continue; // Skip NULL constant items
if ((left_result == ROW_RESULT || if ((left_result == ROW_RESULT ||
items[i]->result_type() == ROW_RESULT) && items[i]->result_type() == ROW_RESULT) &&
cmp_row_type(items[0], items[i])) cmp_row_type(items[0], items[i]))
@ -215,6 +218,12 @@ static uint collect_cmp_types(Item **items, uint nitems)
found_types|= 1<< (uint)item_cmp_type(left_result, found_types|= 1<< (uint)item_cmp_type(left_result,
items[i]->result_type()); items[i]->result_type());
} }
/*
Even if all right-hand items are NULLs and we are skipping them all, we need
at least one type bit in the found_type bitmask.
*/
if (skip_nulls && !found_types)
found_types= 1 << (uint)left_result;
return found_types; return found_types;
} }
@ -3515,7 +3524,7 @@ void Item_func_in::fix_length_and_dec()
uint type_cnt= 0, i; uint type_cnt= 0, i;
Item_result cmp_type= STRING_RESULT; Item_result cmp_type= STRING_RESULT;
left_result_type= args[0]->result_type(); left_result_type= args[0]->result_type();
if (!(found_types= collect_cmp_types(args, arg_count))) if (!(found_types= collect_cmp_types(args, arg_count, true)))
return; return;
for (arg= args + 1, arg_end= args + arg_count; arg != arg_end ; arg++) for (arg= args + 1, arg_end= args + arg_count; arg != arg_end ; arg++)
@ -3693,9 +3702,11 @@ void Item_func_in::fix_length_and_dec()
uint j=0; uint j=0;
for (uint i=1 ; i < arg_count ; i++) for (uint i=1 ; i < arg_count ; i++)
{ {
array->set(j,args[i]);
if (!args[i]->null_value) // Skip NULL values if (!args[i]->null_value) // Skip NULL values
{
array->set(j,args[i]);
j++; j++;
}
else else
have_null= 1; have_null= 1;
} }

View File

@ -26,6 +26,7 @@
#include "mysqld_suffix.h" #include "mysqld_suffix.h"
#include "mysys_err.h" #include "mysys_err.h"
#include "events.h" #include "events.h"
#include "debug_sync.h"
#include "../storage/myisam/ha_myisam.h" #include "../storage/myisam/ha_myisam.h"
@ -486,6 +487,9 @@ my_bool lower_case_file_system= 0;
my_bool opt_large_pages= 0; my_bool opt_large_pages= 0;
my_bool opt_myisam_use_mmap= 0; my_bool opt_myisam_use_mmap= 0;
uint opt_large_page_size= 0; uint opt_large_page_size= 0;
#if defined(ENABLED_DEBUG_SYNC)
uint opt_debug_sync_timeout= 0;
#endif /* defined(ENABLED_DEBUG_SYNC) */
my_bool opt_old_style_user_limits= 0, trust_function_creators= 0; my_bool opt_old_style_user_limits= 0, trust_function_creators= 0;
/* /*
True if there is at least one per-hour limit for some user, so we should True if there is at least one per-hour limit for some user, so we should
@ -1333,6 +1337,10 @@ void clean_up(bool print_message)
#ifdef USE_REGEX #ifdef USE_REGEX
my_regex_end(); my_regex_end();
#endif #endif
#if defined(ENABLED_DEBUG_SYNC)
/* End the debug sync facility. See debug_sync.cc. */
debug_sync_end();
#endif /* defined(ENABLED_DEBUG_SYNC) */
#if !defined(EMBEDDED_LIBRARY) #if !defined(EMBEDDED_LIBRARY)
if (!opt_bootstrap) if (!opt_bootstrap)
@ -3464,6 +3472,12 @@ static int init_common_variables(const char *conf_file_name, int argc,
sys_var_slow_log_path.value= my_strdup(s, MYF(0)); sys_var_slow_log_path.value= my_strdup(s, MYF(0));
sys_var_slow_log_path.value_length= strlen(s); sys_var_slow_log_path.value_length= strlen(s);
#if defined(ENABLED_DEBUG_SYNC)
/* Initialize the debug sync facility. See debug_sync.cc. */
if (debug_sync_init())
return 1; /* purecov: tested */
#endif /* defined(ENABLED_DEBUG_SYNC) */
#if (ENABLE_TEMP_POOL) #if (ENABLE_TEMP_POOL)
if (use_temp_pool && bitmap_init(&temp_pool,0,1024,1)) if (use_temp_pool && bitmap_init(&temp_pool,0,1024,1))
return 1; return 1;
@ -4858,7 +4872,7 @@ void create_thread_to_handle_connection(THD *thd)
handle_one_connection, handle_one_connection,
(void*) thd))) (void*) thd)))
{ {
/* purify: begin inspected */ /* purecov: begin inspected */
DBUG_PRINT("error", DBUG_PRINT("error",
("Can't create thread to handle request (error %d)", ("Can't create thread to handle request (error %d)",
error)); error));
@ -5671,6 +5685,9 @@ enum options_mysqld
OPT_SECURE_FILE_PRIV, OPT_SECURE_FILE_PRIV,
OPT_MIN_EXAMINED_ROW_LIMIT, OPT_MIN_EXAMINED_ROW_LIMIT,
OPT_LOG_SLOW_SLAVE_STATEMENTS, OPT_LOG_SLOW_SLAVE_STATEMENTS,
#if defined(ENABLED_DEBUG_SYNC)
OPT_DEBUG_SYNC_TIMEOUT,
#endif /* defined(ENABLED_DEBUG_SYNC) */
OPT_OLD_MODE, OPT_OLD_MODE,
OPT_SLAVE_EXEC_MODE, OPT_SLAVE_EXEC_MODE,
OPT_GENERAL_LOG_FILE, OPT_GENERAL_LOG_FILE,
@ -6442,6 +6459,14 @@ log and this option does nothing anymore.",
"Decision to use in heuristic recover process. Possible values are COMMIT or ROLLBACK.", "Decision to use in heuristic recover process. Possible values are COMMIT or ROLLBACK.",
(uchar**) &opt_tc_heuristic_recover, (uchar**) &opt_tc_heuristic_recover, (uchar**) &opt_tc_heuristic_recover, (uchar**) &opt_tc_heuristic_recover,
0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
#if defined(ENABLED_DEBUG_SYNC)
{"debug-sync-timeout", OPT_DEBUG_SYNC_TIMEOUT,
"Enable the debug sync facility "
"and optionally specify a default wait timeout in seconds. "
"A zero value keeps the facility disabled.",
(uchar**) &opt_debug_sync_timeout, 0,
0, GET_UINT, OPT_ARG, 0, 0, UINT_MAX, 0, 0, 0},
#endif /* defined(ENABLED_DEBUG_SYNC) */
{"temp-pool", OPT_TEMP_POOL, {"temp-pool", OPT_TEMP_POOL,
#if (ENABLE_TEMP_POOL) #if (ENABLE_TEMP_POOL)
"Using this option will cause most temporary files created to use a small set of names, rather than a unique name for each new file.", "Using this option will cause most temporary files created to use a small set of names, rather than a unique name for each new file.",
@ -7626,6 +7651,9 @@ static int mysql_init_variables(void)
bzero((uchar*) &mysql_tmpdir_list, sizeof(mysql_tmpdir_list)); bzero((uchar*) &mysql_tmpdir_list, sizeof(mysql_tmpdir_list));
bzero((char *) &global_status_var, sizeof(global_status_var)); bzero((char *) &global_status_var, sizeof(global_status_var));
opt_large_pages= 0; opt_large_pages= 0;
#if defined(ENABLED_DEBUG_SYNC)
opt_debug_sync_timeout= 0;
#endif /* defined(ENABLED_DEBUG_SYNC) */
key_map_full.set_all(); key_map_full.set_all();
/* Character sets */ /* Character sets */
@ -8360,6 +8388,22 @@ mysqld_get_one_option(int optid,
lower_case_table_names= argument ? atoi(argument) : 1; lower_case_table_names= argument ? atoi(argument) : 1;
lower_case_table_names_used= 1; lower_case_table_names_used= 1;
break; break;
#if defined(ENABLED_DEBUG_SYNC)
case OPT_DEBUG_SYNC_TIMEOUT:
/*
Debug Sync Facility. See debug_sync.cc.
Default timeout for WAIT_FOR action.
Default value is zero (facility disabled).
If option is given without an argument, supply a non-zero value.
*/
if (!argument)
{
/* purecov: begin tested */
opt_debug_sync_timeout= DEBUG_SYNC_DEFAULT_WAIT_TIMEOUT;
/* purecov: end */
}
break;
#endif /* defined(ENABLED_DEBUG_SYNC) */
} }
return 0; return 0;
} }

View File

@ -625,6 +625,12 @@ static sys_var_long_ptr sys_table_cache_size(&vars, "table_open_cache",
&table_cache_size); &table_cache_size);
static sys_var_long_ptr sys_table_lock_wait_timeout(&vars, "table_lock_wait_timeout", static sys_var_long_ptr sys_table_lock_wait_timeout(&vars, "table_lock_wait_timeout",
&table_lock_wait_timeout); &table_lock_wait_timeout);
#if defined(ENABLED_DEBUG_SYNC)
/* Debug Sync Facility. Implemented in debug_sync.cc. */
static sys_var_debug_sync sys_debug_sync(&vars, "debug_sync");
#endif /* defined(ENABLED_DEBUG_SYNC) */
static sys_var_long_ptr sys_thread_cache_size(&vars, "thread_cache_size", static sys_var_long_ptr sys_thread_cache_size(&vars, "thread_cache_size",
&thread_cache_size); &thread_cache_size);
#if HAVE_POOL_OF_THREADS == 1 #if HAVE_POOL_OF_THREADS == 1

View File

@ -637,6 +637,21 @@ public:
}; };
#endif /* DBUG_OFF */ #endif /* DBUG_OFF */
#if defined(ENABLED_DEBUG_SYNC)
/* Debug Sync Facility. Implemented in debug_sync.cc. */
class sys_var_debug_sync :public sys_var_thd
{
public:
sys_var_debug_sync(sys_var_chain *chain, const char *name_arg)
:sys_var_thd(name_arg)
{ chain_sys_var(chain); }
bool check(THD *thd, set_var *var);
bool update(THD *thd, set_var *var);
SHOW_TYPE show_type() { return SHOW_CHAR; }
bool check_update_type(Item_result type) { return type != STRING_RESULT; }
uchar *value_ptr(THD *thd, enum_var_type type, LEX_STRING *base);
};
#endif /* defined(ENABLED_DEBUG_SYNC) */
/* some variables that require special handling */ /* some variables that require special handling */

View File

@ -6206,3 +6206,10 @@ ER_TOO_MANY_CONCURRENT_TRXS
WARN_NON_ASCII_SEPARATOR_NOT_IMPLEMENTED WARN_NON_ASCII_SEPARATOR_NOT_IMPLEMENTED
eng "Non-ASCII separator arguments are not fully supported" eng "Non-ASCII separator arguments are not fully supported"
ER_DEBUG_SYNC_TIMEOUT
eng "debug sync point wait timed out"
ger "Debug Sync Point Wartezeit überschritten"
ER_DEBUG_SYNC_HIT_LIMIT
eng "debug sync point hit limit reached"
ger "Debug Sync Point Hit Limit erreicht"

View File

@ -3761,7 +3761,7 @@ extern "C" void slave_io_thread_detach_vio()
{ {
#ifdef SIGNAL_WITH_VIO_CLOSE #ifdef SIGNAL_WITH_VIO_CLOSE
THD *thd= current_thd; THD *thd= current_thd;
if (thd->slave_thread) if (thd && thd->slave_thread)
thd->clear_active_vio(); thd->clear_active_vio();
#endif #endif
} }

View File

@ -17,6 +17,7 @@
/* Basic functions needed by many modules */ /* Basic functions needed by many modules */
#include "mysql_priv.h" #include "mysql_priv.h"
#include "debug_sync.h"
#include "sql_select.h" #include "sql_select.h"
#include "sp_head.h" #include "sp_head.h"
#include "sp.h" #include "sp.h"
@ -106,7 +107,7 @@ static bool open_new_frm(THD *thd, TABLE_SHARE *share, const char *alias,
static void close_old_data_files(THD *thd, TABLE *table, bool morph_locks, static void close_old_data_files(THD *thd, TABLE *table, bool morph_locks,
bool send_refresh); bool send_refresh);
static bool static bool
has_two_write_locked_tables_with_auto_increment(TABLE_LIST *tables); has_write_table_with_auto_increment(TABLE_LIST *tables);
extern "C" uchar *table_cache_key(const uchar *record, size_t *length, extern "C" uchar *table_cache_key(const uchar *record, size_t *length,
@ -950,6 +951,7 @@ bool close_cached_tables(THD *thd, TABLE_LIST *tables, bool have_lock,
close_old_data_files(thd,thd->open_tables,1,1); close_old_data_files(thd,thd->open_tables,1,1);
mysql_ha_flush(thd); mysql_ha_flush(thd);
DEBUG_SYNC(thd, "after_flush_unlock");
bool found=1; bool found=1;
/* Wait until all threads has closed all the tables we had locked */ /* Wait until all threads has closed all the tables we had locked */
@ -5277,18 +5279,22 @@ int lock_tables(THD *thd, TABLE_LIST *tables, uint count, bool *need_reopen)
thd->in_lock_tables=1; thd->in_lock_tables=1;
thd->options|= OPTION_TABLE_LOCK; thd->options|= OPTION_TABLE_LOCK;
/* /*
If we have >= 2 different tables to update with auto_inc columns, A query that modifies autoinc column in sub-statement can make the
statement-based binlogging won't work. We can solve this problem in master and slave inconsistent.
mixed mode by switching to row-based binlogging: We can solve these problems in mixed mode by switching to binlogging
if at least one updated table is used by sub-statement
*/ */
if (thd->variables.binlog_format == BINLOG_FORMAT_MIXED && /* The BINLOG_FORMAT_MIXED judgement is saved for suppressing
has_two_write_locked_tables_with_auto_increment(tables)) warnings, but it will be removed by fixing bug#45827 */
if (thd->variables.binlog_format == BINLOG_FORMAT_MIXED && tables &&
has_write_table_with_auto_increment(thd->lex->first_not_own_table()))
{ {
thd->lex->set_stmt_unsafe(); thd->lex->set_stmt_unsafe();
thd->set_current_stmt_binlog_row_based_if_mixed();
} }
} }
DEBUG_SYNC(thd, "before_lock_tables_takes_lock");
if (! (thd->lock= mysql_lock_tables(thd, start, (uint) (ptr - start), if (! (thd->lock= mysql_lock_tables(thd, start, (uint) (ptr - start),
lock_flag, need_reopen))) lock_flag, need_reopen)))
{ {
@ -8815,47 +8821,31 @@ void mysql_wait_completed_table(ALTER_PARTITION_PARAM_TYPE *lpt, TABLE *my_table
/* /*
Tells if two (or more) tables have auto_increment columns and we want to Check if one (or more) write tables have auto_increment columns.
lock those tables with a write lock.
SYNOPSIS @param[in] tables Table list
has_two_write_locked_tables_with_auto_increment
tables Table list @retval 0 if at least one write tables has an auto_increment column
@retval 1 otherwise
NOTES: NOTES:
Call this function only when you have established the list of all tables Call this function only when you have established the list of all tables
which you'll want to update (including stored functions, triggers, views which you'll want to update (including stored functions, triggers, views
inside your statement). inside your statement).
RETURN
0 No
1 Yes
*/ */
static bool static bool
has_two_write_locked_tables_with_auto_increment(TABLE_LIST *tables) has_write_table_with_auto_increment(TABLE_LIST *tables)
{ {
char *first_table_name= NULL, *first_db;
LINT_INIT(first_db);
for (TABLE_LIST *table= tables; table; table= table->next_global) for (TABLE_LIST *table= tables; table; table= table->next_global)
{ {
/* we must do preliminary checks as table->table may be NULL */ /* we must do preliminary checks as table->table may be NULL */
if (!table->placeholder() && if (!table->placeholder() &&
table->table->found_next_number_field && table->table->found_next_number_field &&
(table->lock_type >= TL_WRITE_ALLOW_WRITE)) (table->lock_type >= TL_WRITE_ALLOW_WRITE))
{ return 1;
if (first_table_name == NULL)
{
first_table_name= table->table_name;
first_db= table->db;
DBUG_ASSERT(first_db);
}
else if (strcmp(first_db, table->db) ||
strcmp(first_table_name, table->table_name))
return 1;
}
} }
return 0; return 0;
} }

View File

@ -42,6 +42,7 @@
#include "sp_rcontext.h" #include "sp_rcontext.h"
#include "sp_cache.h" #include "sp_cache.h"
#include "debug_sync.h"
/* /*
The following is used to initialise Table_ident with a internal The following is used to initialise Table_ident with a internal
@ -584,6 +585,9 @@ THD::THD()
derived_tables_processing(FALSE), derived_tables_processing(FALSE),
spcont(NULL), spcont(NULL),
m_parser_state(NULL) m_parser_state(NULL)
#if defined(ENABLED_DEBUG_SYNC)
, debug_sync_control(0)
#endif /* defined(ENABLED_DEBUG_SYNC) */
{ {
ulong tmp; ulong tmp;
@ -832,6 +836,11 @@ void THD::init(void)
reset_current_stmt_binlog_row_based(); reset_current_stmt_binlog_row_based();
bzero((char *) &status_var, sizeof(status_var)); bzero((char *) &status_var, sizeof(status_var));
sql_log_bin_toplevel= options & OPTION_BIN_LOG; sql_log_bin_toplevel= options & OPTION_BIN_LOG;
#if defined(ENABLED_DEBUG_SYNC)
/* Initialize the Debug Sync Facility. See debug_sync.cc. */
debug_sync_init_thread(this);
#endif /* defined(ENABLED_DEBUG_SYNC) */
} }
@ -911,6 +920,12 @@ void THD::cleanup(void)
lock=locked_tables; locked_tables=0; lock=locked_tables; locked_tables=0;
close_thread_tables(this); close_thread_tables(this);
} }
#if defined(ENABLED_DEBUG_SYNC)
/* End the Debug Sync Facility. See debug_sync.cc. */
debug_sync_end_thread(this);
#endif /* defined(ENABLED_DEBUG_SYNC) */
mysql_ha_cleanup(this); mysql_ha_cleanup(this);
delete_dynamic(&user_var_events); delete_dynamic(&user_var_events);
hash_free(&user_vars); hash_free(&user_vars);

View File

@ -1896,6 +1896,11 @@ public:
partition_info *work_part_info; partition_info *work_part_info;
#endif #endif
#if defined(ENABLED_DEBUG_SYNC)
/* Debug Sync facility. See debug_sync.cc. */
struct st_debug_sync_control *debug_sync_control;
#endif /* defined(ENABLED_DEBUG_SYNC) */
THD(); THD();
~THD(); ~THD();

View File

@ -1428,7 +1428,28 @@ bool dispatch_command(enum enum_server_command command, THD *thd,
if (check_global_access(thd,RELOAD_ACL)) if (check_global_access(thd,RELOAD_ACL))
break; break;
general_log_print(thd, command, NullS); general_log_print(thd, command, NullS);
if (!reload_acl_and_cache(thd, options, (TABLE_LIST*) 0, &not_used)) #ifndef DBUG_OFF
bool debug_simulate= FALSE;
DBUG_EXECUTE_IF("simulate_detached_thread_refresh", debug_simulate= TRUE;);
if (debug_simulate)
{
/*
Simulate a reload without a attached thread session.
Provides a environment similar to that of when the
server receives a SIGHUP signal and reloads caches
and flushes tables.
*/
bool res;
my_pthread_setspecific_ptr(THR_THD, NULL);
res= reload_acl_and_cache(NULL, options | REFRESH_FAST,
NULL, &not_used);
my_pthread_setspecific_ptr(THR_THD, thd);
if (!res)
my_ok(thd);
break;
}
#endif
if (!reload_acl_and_cache(thd, options, NULL, &not_used))
my_ok(thd); my_ok(thd);
break; break;
} }

View File

@ -837,7 +837,7 @@ static int myisamchk(MI_CHECK *param, char * filename)
mi_check_print_error(param,"'%s' is marked as crashed after last repair",filename); mi_check_print_error(param,"'%s' is marked as crashed after last repair",filename);
break; break;
case HA_ERR_OLD_FILE: case HA_ERR_OLD_FILE:
mi_check_print_error(param,"'%s' is a old type of MyISAM-table", filename); mi_check_print_error(param,"'%s' is an old type of MyISAM-table", filename);
break; break;
case HA_ERR_END_OF_FILE: case HA_ERR_END_OF_FILE:
mi_check_print_error(param,"Couldn't read complete header from '%s'", filename); mi_check_print_error(param,"Couldn't read complete header from '%s'", filename);

View File

@ -1,4 +1,4 @@
# Copyright (C) 2006 MySQL AB # Copyright (C) 2009 Sun Microsystems, Inc.
# #
# This program is free software; you can redistribute it and/or modify # This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by # it under the terms of the GNU General Public License as published by
@ -21,7 +21,14 @@ LDADD = $(top_builddir)/unittest/mytap/libmytap.a \
$(top_builddir)/dbug/libdbug.a \ $(top_builddir)/dbug/libdbug.a \
$(top_builddir)/strings/libmystrings.a $(top_builddir)/strings/libmystrings.a
noinst_PROGRAMS = bitmap-t base64-t my_atomic-t noinst_PROGRAMS = bitmap-t base64-t
if NEED_THREAD
# my_atomic-t is used to check thread functions, so it is safe to
# ignore the file in non-threaded builds.
# In fact, it will not compile without thread support.
noinst_PROGRAMS += my_atomic-t
endif
# Don't update the files from bitkeeper # Don't update the files from bitkeeper
%::SCCS/s.% %::SCCS/s.%