summaryrefslogtreecommitdiff
path: root/mysql-test/t
diff options
context:
space:
mode:
authorunknown <kostja@bodhi.local>2006-11-30 02:36:18 +0300
committerunknown <kostja@bodhi.local>2006-11-30 02:36:18 +0300
commit126375b16aa31066cfb6e1332b73d8fb9f23467c (patch)
tree04251b69b15ebb521e538025af2e5124e09aabb1 /mysql-test/t
parent66b53b16426509150fecaf7a4d6dd0625bff4424 (diff)
parent4ec847218dca3fa31d6b7d61fffdf71c444c1c74 (diff)
downloadmariadb-git-126375b16aa31066cfb6e1332b73d8fb9f23467c.tar.gz
Merge bk-internal.mysql.com:/home/bk/mysql-5.0
into bodhi.local:/opt/local/work/mysql-5.1-runtime-merge libmysql/libmysql.c: Auto merged libmysqld/lib_sql.cc: Auto merged mysql-test/lib/mtr_io.pl: Auto merged mysql-test/r/im_daemon_life_cycle.result: Auto merged mysql-test/r/im_life_cycle.result: Auto merged mysql-test/r/rpl_trigger.result: Auto merged mysql-test/r/trigger.result: Auto merged mysql-test/t/im_daemon_life_cycle.imtest: Auto merged mysql-test/t/im_life_cycle.imtest: Auto merged mysql-test/t/im_utils.imtest: Auto merged mysql-test/t/rpl_trigger.test: Auto merged mysql-test/t/trigger.test: Auto merged sql/item_cmpfunc.cc: Auto merged sql/item_func.cc: Auto merged sql/item_strfunc.cc: Auto merged sql/item_sum.cc: Auto merged sql/mysqld.cc: Auto merged sql/sql_cache.cc: Auto merged tests/mysql_client_test.c: Auto merged mysql-test/lib/mtr_process.pl: Use local. mysql-test/r/func_str.result: SCCS merged mysql-test/t/func_str.test: Manual merge. sql/sql_trigger.cc: Manual merge. sql/sql_yacc.yy: Manual merge.
Diffstat (limited to 'mysql-test/t')
-rw-r--r--mysql-test/t/func_str.test204
-rw-r--r--mysql-test/t/im_daemon_life_cycle.imtest71
-rw-r--r--mysql-test/t/im_life_cycle.imtest10
-rw-r--r--mysql-test/t/im_utils.imtest4
-rwxr-xr-xmysql-test/t/kill_n_check.sh82
-rwxr-xr-xmysql-test/t/log.sh24
-rw-r--r--mysql-test/t/rpl_trigger.test37
-rw-r--r--mysql-test/t/trigger.test28
-rw-r--r--mysql-test/t/utils.sh55
-rwxr-xr-xmysql-test/t/wait_for_process.sh92
-rwxr-xr-xmysql-test/t/wait_for_socket.sh58
11 files changed, 573 insertions, 92 deletions
diff --git a/mysql-test/t/func_str.test b/mysql-test/t/func_str.test
index 7ae84ea4767..2ec1afc70ee 100644
--- a/mysql-test/t/func_str.test
+++ b/mysql-test/t/func_str.test
@@ -895,4 +895,208 @@ select benchmark(5+5, pi());
select benchmark((select 10 from dual), pi());
select benchmark(@bench_count, pi());
+
+#
+# Bug #10963
+# 4294967296 18446744073709551616
+
+select locate('he','hello',-2);
+select locate('lo','hello',-4294967295);
+select locate('lo','hello',4294967295);
+select locate('lo','hello',-4294967296);
+select locate('lo','hello',4294967296);
+select locate('lo','hello',-4294967297);
+select locate('lo','hello',4294967297);
+select locate('lo','hello',-18446744073709551615);
+select locate('lo','hello',18446744073709551615);
+select locate('lo','hello',-18446744073709551616);
+select locate('lo','hello',18446744073709551616);
+select locate('lo','hello',-18446744073709551617);
+select locate('lo','hello',18446744073709551617);
+
+select left('hello', 10);
+select left('hello', 0);
+select left('hello', -1);
+select left('hello', -4294967295);
+select left('hello', 4294967295);
+select left('hello', -4294967296);
+select left('hello', 4294967296);
+select left('hello', -4294967297);
+select left('hello', 4294967297);
+select left('hello', -18446744073709551615);
+select left('hello', 18446744073709551615);
+select left('hello', -18446744073709551616);
+select left('hello', 18446744073709551616);
+select left('hello', -18446744073709551617);
+select left('hello', 18446744073709551617);
+
+select right('hello', 10);
+select right('hello', 0);
+select right('hello', -1);
+select right('hello', -4294967295);
+select right('hello', 4294967295);
+select right('hello', -4294967296);
+select right('hello', 4294967296);
+select right('hello', -4294967297);
+select right('hello', 4294967297);
+select right('hello', -18446744073709551615);
+select right('hello', 18446744073709551615);
+select right('hello', -18446744073709551616);
+select right('hello', 18446744073709551616);
+select right('hello', -18446744073709551617);
+select right('hello', 18446744073709551617);
+
+select substring('hello', 2, -1);
+
+select substring('hello', -1, 1);
+select substring('hello', -2, 1);
+select substring('hello', -4294967295, 1);
+select substring('hello', 4294967295, 1);
+select substring('hello', -4294967296, 1);
+select substring('hello', 4294967296, 1);
+select substring('hello', -4294967297, 1);
+select substring('hello', 4294967297, 1);
+select substring('hello', -18446744073709551615, 1);
+select substring('hello', 18446744073709551615, 1);
+select substring('hello', -18446744073709551616, 1);
+select substring('hello', 18446744073709551616, 1);
+select substring('hello', -18446744073709551617, 1);
+select substring('hello', 18446744073709551617, 1);
+select substring('hello', 1, -1);
+select substring('hello', 1, -4294967295);
+select substring('hello', 1, 4294967295);
+select substring('hello', 1, -4294967296);
+select substring('hello', 1, 4294967296);
+select substring('hello', 1, -4294967297);
+select substring('hello', 1, 4294967297);
+select substring('hello', 1, -18446744073709551615);
+select substring('hello', 1, 18446744073709551615);
+select substring('hello', 1, -18446744073709551616);
+select substring('hello', 1, 18446744073709551616);
+select substring('hello', 1, -18446744073709551617);
+select substring('hello', 1, 18446744073709551617);
+select substring('hello', -1, -1);
+select substring('hello', -4294967295, -4294967295);
+select substring('hello', 4294967295, 4294967295);
+select substring('hello', -4294967296, -4294967296);
+select substring('hello', 4294967296, 4294967296);
+select substring('hello', -4294967297, -4294967297);
+select substring('hello', 4294967297, 4294967297);
+select substring('hello', -18446744073709551615, -18446744073709551615);
+select substring('hello', 18446744073709551615, 18446744073709551615);
+select substring('hello', -18446744073709551616, -18446744073709551616);
+select substring('hello', 18446744073709551616, 18446744073709551616);
+select substring('hello', -18446744073709551617, -18446744073709551617);
+select substring('hello', 18446744073709551617, 18446744073709551617);
+
+select insert('hello', -1, 1, 'hi');
+select insert('hello', -4294967295, 1, 'hi');
+select insert('hello', 4294967295, 1, 'hi');
+select insert('hello', -4294967296, 1, 'hi');
+select insert('hello', 4294967296, 1, 'hi');
+select insert('hello', -4294967297, 1, 'hi');
+select insert('hello', 4294967297, 1, 'hi');
+select insert('hello', -18446744073709551615, 1, 'hi');
+select insert('hello', 18446744073709551615, 1, 'hi');
+select insert('hello', -18446744073709551616, 1, 'hi');
+select insert('hello', 18446744073709551616, 1, 'hi');
+select insert('hello', -18446744073709551617, 1, 'hi');
+select insert('hello', 18446744073709551617, 1, 'hi');
+select insert('hello', 1, -1, 'hi');
+select insert('hello', 1, -4294967295, 'hi');
+select insert('hello', 1, 4294967295, 'hi');
+select insert('hello', 1, -4294967296, 'hi');
+select insert('hello', 1, 4294967296, 'hi');
+select insert('hello', 1, -4294967297, 'hi');
+select insert('hello', 1, 4294967297, 'hi');
+select insert('hello', 1, -18446744073709551615, 'hi');
+select insert('hello', 1, 18446744073709551615, 'hi');
+select insert('hello', 1, -18446744073709551616, 'hi');
+select insert('hello', 1, 18446744073709551616, 'hi');
+select insert('hello', 1, -18446744073709551617, 'hi');
+select insert('hello', 1, 18446744073709551617, 'hi');
+select insert('hello', -1, -1, 'hi');
+select insert('hello', -4294967295, -4294967295, 'hi');
+select insert('hello', 4294967295, 4294967295, 'hi');
+select insert('hello', -4294967296, -4294967296, 'hi');
+select insert('hello', 4294967296, 4294967296, 'hi');
+select insert('hello', -4294967297, -4294967297, 'hi');
+select insert('hello', 4294967297, 4294967297, 'hi');
+select insert('hello', -18446744073709551615, -18446744073709551615, 'hi');
+select insert('hello', 18446744073709551615, 18446744073709551615, 'hi');
+select insert('hello', -18446744073709551616, -18446744073709551616, 'hi');
+select insert('hello', 18446744073709551616, 18446744073709551616, 'hi');
+select insert('hello', -18446744073709551617, -18446744073709551617, 'hi');
+select insert('hello', 18446744073709551617, 18446744073709551617, 'hi');
+
+select repeat('hello', -1);
+select repeat('hello', -4294967295);
+select repeat('hello', 4294967295);
+select repeat('hello', -4294967296);
+select repeat('hello', 4294967296);
+select repeat('hello', -4294967297);
+select repeat('hello', 4294967297);
+select repeat('hello', -18446744073709551615);
+select repeat('hello', 18446744073709551615);
+select repeat('hello', -18446744073709551616);
+select repeat('hello', 18446744073709551616);
+select repeat('hello', -18446744073709551617);
+select repeat('hello', 18446744073709551617);
+
+select space(-1);
+select space(-4294967295);
+select space(4294967295);
+select space(-4294967296);
+select space(4294967296);
+select space(-4294967297);
+select space(4294967297);
+select space(-18446744073709551615);
+select space(18446744073709551615);
+select space(-18446744073709551616);
+select space(18446744073709551616);
+select space(-18446744073709551617);
+select space(18446744073709551617);
+
+select rpad('hello', -1, '1');
+select rpad('hello', -4294967295, '1');
+select rpad('hello', 4294967295, '1');
+select rpad('hello', -4294967296, '1');
+select rpad('hello', 4294967296, '1');
+select rpad('hello', -4294967297, '1');
+select rpad('hello', 4294967297, '1');
+select rpad('hello', -18446744073709551615, '1');
+select rpad('hello', 18446744073709551615, '1');
+select rpad('hello', -18446744073709551616, '1');
+select rpad('hello', 18446744073709551616, '1');
+select rpad('hello', -18446744073709551617, '1');
+select rpad('hello', 18446744073709551617, '1');
+
+select lpad('hello', -1, '1');
+select lpad('hello', -4294967295, '1');
+select lpad('hello', 4294967295, '1');
+select lpad('hello', -4294967296, '1');
+select lpad('hello', 4294967296, '1');
+select lpad('hello', -4294967297, '1');
+select lpad('hello', 4294967297, '1');
+select lpad('hello', -18446744073709551615, '1');
+select lpad('hello', 18446744073709551615, '1');
+select lpad('hello', -18446744073709551616, '1');
+select lpad('hello', 18446744073709551616, '1');
+select lpad('hello', -18446744073709551617, '1');
+select lpad('hello', 18446744073709551617, '1');
+
+
+#
+# BUG#17047: CHAR() and IN() can return NULL without signaling NULL
+# result
+#
+SET @orig_sql_mode = @@SQL_MODE;
+SET SQL_MODE=traditional;
+
+SELECT CHAR(0xff,0x8f USING utf8);
+SELECT CHAR(0xff,0x8f USING utf8) IS NULL;
+
+SET SQL_MODE=@orig_sql_mode;
+
+
--echo End of 5.0 tests
diff --git a/mysql-test/t/im_daemon_life_cycle.imtest b/mysql-test/t/im_daemon_life_cycle.imtest
index fd19b6f8527..c5b8ee16d9a 100644
--- a/mysql-test/t/im_daemon_life_cycle.imtest
+++ b/mysql-test/t/im_daemon_life_cycle.imtest
@@ -6,59 +6,73 @@
#
###########################################################################
+--exec $MYSQL_TEST_DIR/t/log.sh im_daemon_life_cycle im_daemon_life_cycle.imtest started.
+
+###########################################################################
+
--source include/im_check_env.inc
-# Turn on reconnect, not on by default anymore
+# Turn on reconnect, not on by default anymore.
--enable_reconnect
###########################################################################
+#
+# The main daemon-life-cycle test case -- check that IM-angel will restart
+# IM-main if it got killed:
+# - kill IM-main and check that IM-angel will restart it;
+# - wait for IM-main to start accepting connections before continue test
+# case;
+#
+###########################################################################
-# Kill the IM main process and check that the IM Angel will restart the main
-# process.
-
---exec $MYSQL_TEST_DIR/t/kill_n_check.sh $IM_PATH_PID restarted 30
+--exec $MYSQL_TEST_DIR/t/log.sh im_daemon_life_cycle Main-test: starting...
-###########################################################################
+--exec $MYSQL_TEST_DIR/t/log.sh im_daemon_life_cycle Killing IM-main...
+--exec $MYSQL_TEST_DIR/t/kill_n_check.sh $IM_PATH_PID restarted 30 im_daemon_life_cycle
-# Wait for IM to start accepting connections.
+--exec $MYSQL_TEST_DIR/t/log.sh im_daemon_life_cycle Waiting for IM-main to start accepting connections...
+--exec $MYSQL_TEST_DIR/t/wait_for_socket.sh $EXE_MYSQL $IM_PATH_SOCK $IM_USERNAME $IM_PASSWORD '' 30 im_daemon_life_cycle
---exec $MYSQL_TEST_DIR/t/wait_for_socket.sh $EXE_MYSQL $IM_PATH_SOCK $IM_USERNAME $IM_PASSWORD '' 30
+--exec $MYSQL_TEST_DIR/t/log.sh im_daemon_life_cycle Main-test: done.
###########################################################################
-
#
# BUG#12751: Instance Manager: client hangs
+# - start nonguarded instance (mysqld2);
+# - kill IM-main and get it restarted by IM-angel;
+# - check that guarded instance (mysqld1) is accepting connections.
+# - check that non-guarded instance (mysqld2) were not stopped.
#
+###########################################################################
--echo
--echo --------------------------------------------------------------------
--echo -- Test for BUG#12751
--echo --------------------------------------------------------------------
-# Give some time to begin accepting connections after restart.
-# FIXME: race condition here.
-
---sleep 3
+--exec $MYSQL_TEST_DIR/t/log.sh im_daemon_life_cycle BUG12751: starting...
# 1. Start mysqld;
+--exec $MYSQL_TEST_DIR/t/log.sh im_daemon_life_cycle mysqld2: starting...
START INSTANCE mysqld2;
-# FIXME: START INSTANCE should be synchronous.
---exec $MYSQL_TEST_DIR/t/wait_for_process.sh $IM_MYSQLD2_PATH_PID 30 started
-# 2. Restart IM-main: kill it and IM-angel will restart it; wait for IM to
-# start accepting connections again.
+--exec $MYSQL_TEST_DIR/t/log.sh im_daemon_life_cycle mysqld2: waiting to start...
+--exec $MYSQL_TEST_DIR/t/wait_for_process.sh $IM_MYSQLD2_PATH_PID 30 started im_daemon_life_cycle
---exec $MYSQL_TEST_DIR/t/kill_n_check.sh $IM_PATH_PID restarted 30
+--exec $MYSQL_TEST_DIR/t/log.sh im_daemon_life_cycle mysqld2: started.
---exec $MYSQL_TEST_DIR/t/wait_for_socket.sh $EXE_MYSQL $IM_PATH_SOCK $IM_USERNAME $IM_PASSWORD '' 30
+# 2. Restart IM-main;
-# 3. Issue some statement -- connection should be re-established.
+--exec $MYSQL_TEST_DIR/t/log.sh im_daemon_life_cycle Killing IM-main...
+--exec $MYSQL_TEST_DIR/t/kill_n_check.sh $IM_PATH_PID restarted 30 im_daemon_life_cycle
-# Give some time to begin accepting connections after restart.
-# FIXME: race condition here.
+--exec $MYSQL_TEST_DIR/t/log.sh im_daemon_life_cycle Waiting for IM-main to start accepting connections...
+--exec $MYSQL_TEST_DIR/t/wait_for_socket.sh $EXE_MYSQL $IM_PATH_SOCK $IM_USERNAME $IM_PASSWORD '' 30 im_daemon_life_cycle
+
+# 3. Issue some statement -- connection should be re-established.
---sleep 3
+--exec $MYSQL_TEST_DIR/t/log.sh im_daemon_life_cycle Checking that IM-main processing commands...
--replace_column 3 VERSION_NUMBER 4 VERSION
SHOW INSTANCE STATUS mysqld1;
@@ -67,6 +81,13 @@ SHOW INSTANCE STATUS mysqld1;
# So, if it we do not stop it, it will be stopped by mysql-test-run.pl with
# warning.
+--exec $MYSQL_TEST_DIR/t/log.sh im_daemon_life_cycle mysqld2: stopping...
STOP INSTANCE mysqld2;
-# FIXME: STOP INSTANCE should be synchronous.
---exec $MYSQL_TEST_DIR/t/wait_for_process.sh $IM_MYSQLD2_PATH_PID 30 stopped
+
+--exec $MYSQL_TEST_DIR/t/log.sh im_daemon_life_cycle mysqld2: waiting to stop...
+--exec $MYSQL_TEST_DIR/t/wait_for_process.sh $IM_MYSQLD2_PATH_PID 30 stopped im_daemon_life_cycle
+--exec $MYSQL_TEST_DIR/t/log.sh im_daemon_life_cycle mysqld2: stopped.
+
+###########################################################################
+
+--exec $MYSQL_TEST_DIR/t/log.sh im_daemon_life_cycle BUG12751: done.
diff --git a/mysql-test/t/im_life_cycle.imtest b/mysql-test/t/im_life_cycle.imtest
index ddfb62d312e..3721b92e2b7 100644
--- a/mysql-test/t/im_life_cycle.imtest
+++ b/mysql-test/t/im_life_cycle.imtest
@@ -25,7 +25,7 @@
START INSTANCE mysqld2;
# FIXME: START INSTANCE should be synchronous.
---exec $MYSQL_TEST_DIR/t/wait_for_process.sh $IM_MYSQLD2_PATH_PID 30 started
+--exec $MYSQL_TEST_DIR/t/wait_for_process.sh $IM_MYSQLD2_PATH_PID 30 started im_life_cycle
# FIXME: Result of SHOW INSTANCES here is not deterministic unless START
# INSTANCE is synchronous. Even waiting for mysqld to start by looking at
@@ -58,7 +58,7 @@ SHOW VARIABLES LIKE 'port';
STOP INSTANCE mysqld2;
# FIXME: STOP INSTANCE should be synchronous.
---exec $MYSQL_TEST_DIR/t/wait_for_process.sh $IM_MYSQLD2_PATH_PID 30 stopped
+--exec $MYSQL_TEST_DIR/t/wait_for_process.sh $IM_MYSQLD2_PATH_PID 30 stopped im_life_cycle
# FIXME: Result of SHOW INSTANCES here is not deterministic unless START
# INSTANCE is synchronous. Even waiting for mysqld to start by looking at
@@ -121,7 +121,7 @@ STOP INSTANCE mysqld3;
--echo -- 1.1.6.
--echo --------------------------------------------------------------------
---exec $MYSQL_TEST_DIR/t/kill_n_check.sh $IM_MYSQLD1_PATH_PID restarted 30
+--exec $MYSQL_TEST_DIR/t/kill_n_check.sh $IM_MYSQLD1_PATH_PID restarted 30 im_life_cycle
# Give some time to IM to detect that mysqld was restarted. It should be
# longer than monitoring interval.
@@ -143,7 +143,7 @@ SHOW INSTANCES;
START INSTANCE mysqld2;
# FIXME: START INSTANCE should be synchronous.
---exec $MYSQL_TEST_DIR/t/wait_for_process.sh $IM_MYSQLD2_PATH_PID 30 started
+--exec $MYSQL_TEST_DIR/t/wait_for_process.sh $IM_MYSQLD2_PATH_PID 30 started im_life_cycle
# FIXME: Result of SHOW INSTANCES here is not deterministic unless START
# INSTANCE is synchronous. Even waiting for mysqld to start by looking at
@@ -151,7 +151,7 @@ START INSTANCE mysqld2;
# mysqld has started.
# SHOW INSTANCES;
---exec $MYSQL_TEST_DIR/t/kill_n_check.sh $IM_MYSQLD2_PATH_PID killed 10
+--exec $MYSQL_TEST_DIR/t/kill_n_check.sh $IM_MYSQLD2_PATH_PID killed 10 im_life_cycle
# FIXME: Result of SHOW INSTANCES here is not deterministic unless START
# INSTANCE is synchronous. Even waiting for mysqld to start by looking at
diff --git a/mysql-test/t/im_utils.imtest b/mysql-test/t/im_utils.imtest
index 52878f6c2b5..0866b87204a 100644
--- a/mysql-test/t/im_utils.imtest
+++ b/mysql-test/t/im_utils.imtest
@@ -31,10 +31,10 @@ SHOW INSTANCE OPTIONS mysqld2;
#
START INSTANCE mysqld2;
---exec $MYSQL_TEST_DIR/t/wait_for_process.sh $IM_MYSQLD2_PATH_PID 30 started
+--exec $MYSQL_TEST_DIR/t/wait_for_process.sh $IM_MYSQLD2_PATH_PID 30 started im_utils
STOP INSTANCE mysqld2;
---exec $MYSQL_TEST_DIR/t/wait_for_process.sh $IM_MYSQLD2_PATH_PID 30 stopped
+--exec $MYSQL_TEST_DIR/t/wait_for_process.sh $IM_MYSQLD2_PATH_PID 30 stopped im_utils
#
# Check 'SHOW LOG FILES' command:
diff --git a/mysql-test/t/kill_n_check.sh b/mysql-test/t/kill_n_check.sh
index a54fb6ef8bb..96c402a638c 100755
--- a/mysql-test/t/kill_n_check.sh
+++ b/mysql-test/t/kill_n_check.sh
@@ -2,74 +2,101 @@
###########################################################################
-# NOTE: this script returns 0 (success) even in case of failure. This is
-# because this script is executed under mysql-test-run[.pl] and it's better to
-# examine particular problem in log file, than just having said that the test
-# case has failed.
+# NOTE: this script returns 0 (success) even in case of failure (except for
+# usage-error). This is because this script is executed under
+# mysql-test-run[.pl] and it's better to examine particular problem in log
+# file, than just having said that the test case has failed.
+
+###########################################################################
+
+basename=`basename "$0"`
+dirname=`dirname "$0"`
+
+###########################################################################
+
+. "$dirname/utils.sh"
###########################################################################
check_restart()
{
if [ ! -r "$pid_path" ]; then
+ log_debug "No '$pid_path' found."
user_msg='the process was killed'
return 1
fi
new_pid=`cat "$pid_path" 2>/dev/null`
+ err_code=$?
- if [ $? -eq 0 -a "$original_pid" = "$new_pid" ]; then
+ log_debug "err_code: $err_code; original_pid: $original_pid; new_pid: $new_pid."
+
+ if [ $err_code -eq 0 -a "$original_pid" = "$new_pid" ]; then
+ log_debug "The process was not restarted."
user_msg='the process was not restarted'
return 1
fi
+ log_debug "The process was restarted."
user_msg='the process was restarted'
return 0
}
###########################################################################
-if [ $# -ne 3 ]; then
- echo "Usage: kill_n_check.sh <pid file path> killed|restarted <timeout>"
- exit 0
+if [ $# -ne 4 ]; then
+ echo "Usage: $basename <pid file path> killed|restarted <timeout> <test id>"
+ exit 1
fi
pid_path="$1"
expected_result="$2"
total_timeout="$3"
+test_id="$4"
+log_file="$MYSQLTEST_VARDIR/log/$test_id.log"
+
+log_debug "-- $basename: starting --"
+log_debug "pid_path: '$pid_path'"
+log_debug "expected_result: '$expected_result'"
+log_debug "total_timeout: '$total_timeout'"
+log_debug "test_id: '$test_id'"
+log_debug "log_file: '$log_file'"
+
+###########################################################################
if [ "$expected_result" != 'killed' -a \
"$expected_result" != 'restarted' ]; then
- echo "Error: invalid second argument ('killed' or 'restarted' expected)."
- exit 0
+ log_error "Invalid second argument ($expected_result): 'killed' or 'restarted' expected."
+ quit 0
fi
if [ -z "$pid_path" ]; then
- echo "Error: invalid PID path ($pid_path)."
- exit 0
+ log_error "Invalid PID path ($pid_path)."
+ quit 0
fi
if [ ! -r "$pid_path" ]; then
- echo "Error: PID file ($pid_path) does not exist."
- exit 0
+ log_error "PID file ($pid_path) does not exist."
+ quit 0
fi
if [ -z "$total_timeout" ]; then
- echo "Error: timeout is not specified."
- exit 0
+ log_error "Timeout is not specified."
+ quit 0
fi
###########################################################################
original_pid=`cat "$pid_path"`
+log_debug "original_pid: $original_pid."
-echo "Killing the process..."
+log_info "Killing the process..."
kill -9 $original_pid
###########################################################################
-echo "Sleeping..."
+log_info "Waiting..."
if [ "$expected_result" = "restarted" ]; then
@@ -79,37 +106,42 @@ if [ "$expected_result" = "restarted" ]; then
while true; do
+ log_debug "cur_attempt: $cur_attempt."
+
if check_restart; then
- echo "Success: $user_msg."
- exit 0
+ log_info "Success: $user_msg."
+ quit 0
fi
[ $cur_attempt -ge $total_timeout ] && break
+ log_debug "Sleeping for 1 second..."
sleep 1
cur_attempt=`expr $cur_attempt + 1`
done
- echo "Error: $user_msg."
- exit 0
+ log_error "$user_msg."
+ quit 0
else # $expected_result == killed
# Here we have to sleep for some long time to ensure that the process will
# not be restarted.
+ log_debug "Sleeping for $total_timeout seconds..."
sleep $total_timeout
new_pid=`cat "$pid_path" 2>/dev/null`
+ log_debug "new_pid: $new_pid."
if [ "$new_pid" -a "$new_pid" -ne "$original_pid" ]; then
- echo "Error: the process was restarted."
+ log_error "The process was restarted."
else
- echo "Success: the process was killed."
+ log_info "Success: the process was killed."
fi
- exit 0
+ quit 0
fi
diff --git a/mysql-test/t/log.sh b/mysql-test/t/log.sh
new file mode 100755
index 00000000000..20b265087cc
--- /dev/null
+++ b/mysql-test/t/log.sh
@@ -0,0 +1,24 @@
+#!/bin/bash
+
+###########################################################################
+
+basename=`basename "$0"`
+dirname=`dirname "$0"`
+
+###########################################################################
+
+. "$dirname/utils.sh"
+
+###########################################################################
+
+if [ $# -lt 2 ]; then
+ echo "Usage: $basename <test id> log message ..."
+ exit 1
+fi
+
+test_id="$1"
+log_file="$MYSQLTEST_VARDIR/log/$test_id.log"
+
+shift
+
+log_debug "$*"
diff --git a/mysql-test/t/rpl_trigger.test b/mysql-test/t/rpl_trigger.test
index 6ec0021635a..9f5f6fc9b4c 100644
--- a/mysql-test/t/rpl_trigger.test
+++ b/mysql-test/t/rpl_trigger.test
@@ -431,6 +431,43 @@ DROP TABLE t2;
--sync_with_master
--connection master
+#
+# BUG#23703: DROP TRIGGER needs an IF EXISTS
+#
+
+connection master;
+
+--disable_warnings
+drop table if exists t1;
+--enable_warnings
+
+create table t1(a int, b varchar(50));
+
+-- error ER_TRG_DOES_NOT_EXIST
+drop trigger not_a_trigger;
+
+drop trigger if exists not_a_trigger;
+
+create trigger t1_bi before insert on t1
+for each row set NEW.b := "In trigger t1_bi";
+
+insert into t1 values (1, "a");
+drop trigger if exists t1_bi;
+insert into t1 values (2, "b");
+drop trigger if exists t1_bi;
+insert into t1 values (3, "c");
+
+select * from t1;
+
+save_master_pos;
+connection slave;
+sync_with_master;
+
+select * from t1;
+
+connection master;
+
+drop table t1;
#
# End of tests
diff --git a/mysql-test/t/trigger.test b/mysql-test/t/trigger.test
index bee2bca47d2..12262894e5b 100644
--- a/mysql-test/t/trigger.test
+++ b/mysql-test/t/trigger.test
@@ -1519,4 +1519,32 @@ connection default;
drop table t1;
drop function f1;
+#
+# Bug#23703: DROP TRIGGER needs an IF EXISTS
+#
+
+--disable_warnings
+drop table if exists t1;
+--enable_warnings
+
+create table t1(a int, b varchar(50));
+
+-- error ER_TRG_DOES_NOT_EXIST
+drop trigger not_a_trigger;
+
+drop trigger if exists not_a_trigger;
+
+create trigger t1_bi before insert on t1
+for each row set NEW.b := "In trigger t1_bi";
+
+insert into t1 values (1, "a");
+drop trigger if exists t1_bi;
+insert into t1 values (2, "b");
+drop trigger if exists t1_bi;
+insert into t1 values (3, "c");
+
+select * from t1;
+
+drop table t1;
+
--echo End of 5.0 tests
diff --git a/mysql-test/t/utils.sh b/mysql-test/t/utils.sh
new file mode 100644
index 00000000000..b3f4744947d
--- /dev/null
+++ b/mysql-test/t/utils.sh
@@ -0,0 +1,55 @@
+###########################################################################
+#
+# This file provides utility functions and is included by other scripts.
+#
+# The following global variables must be set before calling functions from this
+# file:
+# - basename -- base name of the calling script (main application);
+# - log_file -- where to store log records;
+#
+###########################################################################
+
+log()
+{
+ [ -z "$log_file" ] && return;
+
+ log_level="$1"
+ log_msg="$2"
+ ts=`date`
+
+ echo "[$ts] [$basename] [$log_level] $log_msg" >> "$log_file";
+}
+
+###########################################################################
+
+log_debug()
+{
+ log 'DEBUG' "$1"
+}
+
+###########################################################################
+
+log_info()
+{
+ log 'INFO' "$1"
+ echo "$1"
+}
+
+###########################################################################
+
+log_error()
+{
+ log 'ERROR' "$1"
+ echo "Error: $1"
+}
+
+###########################################################################
+
+quit()
+{
+ exit_status="$1"
+
+ log_debug "-- $basename: finished (exit_status: $exit_status) --"
+
+ exit $exit_status
+}
diff --git a/mysql-test/t/wait_for_process.sh b/mysql-test/t/wait_for_process.sh
index df0f4a17e3a..4c2d89cfea6 100755
--- a/mysql-test/t/wait_for_process.sh
+++ b/mysql-test/t/wait_for_process.sh
@@ -2,34 +2,40 @@
###########################################################################
-pid_path="$1"
-total_attempts="$2"
-event="$3"
+# NOTE: this script returns 0 (success) even in case of failure (except for
+# usage-error). This is because this script is executed under
+# mysql-test-run[.pl] and it's better to examine particular problem in log
+# file, than just having said that the test case has failed.
-case "$3" in
- started)
- check_fn='check_started';
- ;;
+###########################################################################
- stopped)
- check_fn='check_stopped';
- ;;
+basename=`basename "$0"`
+dirname=`dirname "$0"`
- *)
- echo "Error: invalid third argument ('started' or 'stopped' expected)."
- exit 0
-esac
+###########################################################################
+
+. "$dirname/utils.sh"
###########################################################################
check_started()
{
- [ ! -r "$pid_path" ] && return 1
+ if [ ! -r "$pid_path" ]; then
+ log_debug "No PID-file ($pid_path) found -- not started."
+ return 1
+ fi
new_pid=`cat "$pid_path" 2>/dev/null`
+ err_code=$?
+
+ log_debug "err_code: $err_code; new_pid: $new_pid."
- [ $? -eq 0 -a "$original_pid" = "$new_pid" ] && return 1
+ if [ $? -ne 0 -o -z "$new_pid" ]; then
+ log_debug "The process was not started."
+ return 1
+ fi
+ log_debug "The process was started."
return 0
}
@@ -37,30 +43,72 @@ check_started()
check_stopped()
{
- [ -r "$pid_path" ] && return 1
+ if [ -r "$pid_path" ]; then
+ log_debug "PID-file '$pid_path' exists -- not stopped."
+ return 1
+ fi
+ log_debug "No PID-file ($pid_path) found -- stopped."
return 0
}
###########################################################################
+if [ $# -ne 4 ]; then
+ echo "Usage: $basename <pid file path> <total attempts> started|stopped <test id>"
+ exit 1
+fi
+
+pid_path="$1"
+total_attempts="$2"
+event="$3"
+test_id="$4"
+log_file="$MYSQLTEST_VARDIR/log/$test_id.log"
+
+log_debug "-- $basename: starting --"
+log_debug "pid_path: '$pid_path'"
+log_debug "total_attempts: '$total_attempts'"
+log_debug "event: '$event'"
+log_debug "test_id: '$test_id'"
+log_debug "log_file: '$log_file'"
+
+###########################################################################
+
+case "$event" in
+ started)
+ check_fn='check_started';
+ ;;
+
+ stopped)
+ check_fn='check_stopped';
+ ;;
+
+ *)
+ log_error "Invalid third argument ('started' or 'stopped' expected)."
+ quit 0
+esac
+
+###########################################################################
+
cur_attempt=1
while true; do
+ log_debug "cur_attempt: $cur_attempt."
+
if ( eval $check_fn ); then
- echo "Success: the process has been $event."
- exit 0
+ log_info "Success: the process has been $event."
+ quit 0
fi
[ $cur_attempt -ge $total_attempts ] && break
+ log_debug "Sleeping for 1 second..."
sleep 1
cur_attempt=`expr $cur_attempt + 1`
done
-echo "Error: the process has not been $event in $total_attempts secs."
-exit 0
-
+log_error "The process has not been $event in $total_attempts secs."
+quit 0
diff --git a/mysql-test/t/wait_for_socket.sh b/mysql-test/t/wait_for_socket.sh
index b6526b7d19c..1bce74dfd3a 100755
--- a/mysql-test/t/wait_for_socket.sh
+++ b/mysql-test/t/wait_for_socket.sh
@@ -2,9 +2,25 @@
###########################################################################
-if [ $# -ne 6 ]; then
- echo "Usage: wait_for_socket.sh <executable path> <socket path> <username> <password> <db> <timeout>"
- exit 0
+# NOTE: this script returns 0 (success) even in case of failure (except for
+# usage-error). This is because this script is executed under
+# mysql-test-run[.pl] and it's better to examine particular problem in log
+# file, than just having said that the test case has failed.
+
+###########################################################################
+
+basename=`basename "$0"`
+dirname=`dirname "$0"`
+
+###########################################################################
+
+. "$dirname/utils.sh"
+
+###########################################################################
+
+if [ $# -ne 7 ]; then
+ echo "Usage: wait_for_socket.sh <executable path> <socket path> <username> <password> <db> <timeout> <test id>"
+ exit 1
fi
client_exe="$1"
@@ -13,22 +29,34 @@ username="$3"
password="$4"
db="$5"
total_timeout="$6"
+test_id="$7"
+log_file="$MYSQLTEST_VARDIR/log/$test_id.log"
+
+log_debug "-- $basename: starting --"
+log_debug "client_exe: '$client_exe'"
+log_debug "socket_path: '$socket_path'"
+log_debug "username: '$username'"
+log_debug "password: '$password'"
+log_debug "db: '$db'"
+log_debug "total_timeout: '$total_timeout'"
+log_debug "test_id: '$test_id'"
+log_debug "log_file: '$log_file'"
###########################################################################
if [ -z "$client_exe" ]; then
- echo "Error: invalid path to client executable ($client_exe)."
- exit 0;
+ log_error "Invalid path to client executable ($client_exe)."
+ quit 0;
fi
if [ ! -x "$client_exe" ]; then
- echo "Error: client by path '$client_exe' is not available."
- exit 0;
+ log_error "Client by path '$client_exe' is not available."
+ quit 0;
fi
if [ -z "$socket_path" ]; then
- echo "Error: invalid socket patch."
- exit 0
+ log_error "Invalid socket patch ($socket_path)."
+ quit 0
fi
###########################################################################
@@ -39,15 +67,19 @@ client_args="--silent --socket=$socket_path --connect_timeout=1 "
[ -n "$password" ] && client_args="$client_args --password=$password "
[ -n "$db" ] && client_args="$client_args $db"
+log_debug "client_args: '$client_args'"
+
###########################################################################
cur_attempt=1
while true; do
+ log_debug "cur_attempt: $cur_attempt."
+
if ( echo 'quit' | "$client_exe" $client_args >/dev/null 2>&1 ); then
- echo "Success: server is ready to accept connection on socket."
- exit 0
+ log_info "Success: server is ready to accept connection on socket."
+ quit 0
fi
[ $cur_attempt -ge $total_timeout ] && break
@@ -58,5 +90,5 @@ while true; do
done
-echo "Error: server does not accept connections after $total_timeout seconds."
-exit 0
+log_error "Server does not accept connections after $total_timeout seconds."
+quit 0