summaryrefslogtreecommitdiff
path: root/mysql-test/include
diff options
context:
space:
mode:
authorunknown <serg@janus.mylan>2007-12-27 18:16:02 +0100
committerunknown <serg@janus.mylan>2007-12-27 18:16:02 +0100
commit7fdbc4230e68171e17e0dd4f6ae2d3fe3acb7549 (patch)
treeb06c9309a63829e580019be688f7e51e47604caa /mysql-test/include
parentc1350b873165429f06b061565b91a0d423e39bdb (diff)
parent3fa2803a7737cd01aea6babd1c601649cab7968c (diff)
downloadmariadb-git-7fdbc4230e68171e17e0dd4f6ae2d3fe3acb7549.tar.gz
Merge janus.mylan:/usr/home/serg/Abk/mysql-5.1
into janus.mylan:/usr/home/serg/Abk/mysql-maria Makefile.am: Auto merged configure.in: Auto merged BitKeeper/triggers/post-commit: Auto merged client/mysqldump.c: Auto merged client/mysqltest.c: Auto merged include/my_dbug.h: Auto merged include/mysql_com.h: Auto merged libmysql/CMakeLists.txt: Auto merged libmysqld/Makefile.am: Auto merged mysql-test/lib/mtr_report.pl: Auto merged mysql-test/mysql-test-run.pl: Auto merged mysql-test/t/disabled.def: Auto merged mysql-test/t/variables.test: Auto merged server-tools/instance-manager/CMakeLists.txt: Auto merged server-tools/instance-manager/mysql_connection.cc: Auto merged sql/Makefile.am: Auto merged sql/filesort.cc: Auto merged sql/gen_lex_hash.cc: Auto merged sql/ha_ndbcluster.cc: Auto merged sql/ha_partition.cc: Auto merged sql/item_func.cc: Auto merged sql/item_strfunc.cc: Auto merged sql/lex.h: Auto merged sql/lock.cc: Auto merged sql/log.cc: Auto merged sql/net_serv.cc: Auto merged sql/opt_range.cc: Auto merged sql/set_var.h: Auto merged sql/slave.cc: Auto merged sql/sql_class.cc: Auto merged sql/sql_class.h: Auto merged sql/sql_delete.cc: Auto merged sql/sql_insert.cc: Auto merged sql/sql_parse.cc: Auto merged sql/sql_select.h: Auto merged sql/sql_table.cc: Auto merged sql/sql_update.cc: Auto merged sql/sql_yacc.yy: Auto merged sql/table.cc: Auto merged sql/table.h: Auto merged storage/myisam/ha_myisam.cc: Auto merged storage/myisam/mi_open.c: Auto merged storage/myisammrg/ha_myisammrg.cc: Auto merged sql/handler.cc: merged sql/handler.h: merged sql/mysql_priv.h: merged sql/mysqld.cc: merged sql/set_var.cc: merged sql/sql_select.cc: merged sql/sql_show.cc: merged unittest/mysys/my_atomic-t.c: merged
Diffstat (limited to 'mysql-test/include')
-rw-r--r--mysql-test/include/have_maria.inc4
-rw-r--r--mysql-test/include/maria_empty_logs.inc33
-rw-r--r--mysql-test/include/maria_make_snapshot.inc48
-rw-r--r--mysql-test/include/maria_make_snapshot_for_comparison.inc30
-rw-r--r--mysql-test/include/maria_make_snapshot_for_feeding_recovery.inc35
-rw-r--r--mysql-test/include/maria_verify_recovery.inc96
-rw-r--r--mysql-test/include/ps_conv.inc2
-rw-r--r--mysql-test/include/wait_until_connected_again.inc6
8 files changed, 251 insertions, 3 deletions
diff --git a/mysql-test/include/have_maria.inc b/mysql-test/include/have_maria.inc
new file mode 100644
index 00000000000..955e2305ca5
--- /dev/null
+++ b/mysql-test/include/have_maria.inc
@@ -0,0 +1,4 @@
+-- require r/have_maria.require
+disable_query_log;
+show variables like "have_maria";
+enable_query_log;
diff --git a/mysql-test/include/maria_empty_logs.inc b/mysql-test/include/maria_empty_logs.inc
new file mode 100644
index 00000000000..7613cea2a52
--- /dev/null
+++ b/mysql-test/include/maria_empty_logs.inc
@@ -0,0 +1,33 @@
+# Maria help script.
+# Cleans up all logs to give recovery a fresh start.
+
+# API: none, just uses vardir, port and socket.
+
+connection admin;
+
+-- echo * shut down mysqld, removed logs, restarted it
+append_file $MYSQLTEST_VARDIR/tmp/master0.expect;
+wait-maria_empty_logs.inc
+EOF
+
+--exec $MYSQLADMIN --no-defaults -S $MASTER_MYSOCK -P $MASTER_MYPORT -u root --password= shutdown 2>&1;
+
+remove_file $MYSQLTEST_VARDIR/master-data/maria_log_control;
+remove_file $MYSQLTEST_VARDIR/master-data/maria_log.00000001;
+-- error 0,1 # maybe there is just one log
+remove_file $MYSQLTEST_VARDIR/master-data/maria_log.00000002;
+# Hope there were not more than these logs.
+
+-- error 0,1
+remove_file $MYSQLTEST_VARDIR/master-data/maria_recovery.trace;
+
+append_file $MYSQLTEST_VARDIR/tmp/master0.expect;
+restart-maria_empty_logs.inc
+EOF
+
+--source include/wait_until_connected_again.inc
+
+connection default;
+# the effect of "use" is lost after a restart so we are back into db "test",
+# because connection 'default' was created with db "test".
+use mysqltest;
diff --git a/mysql-test/include/maria_make_snapshot.inc b/mysql-test/include/maria_make_snapshot.inc
new file mode 100644
index 00000000000..b457f3e1a68
--- /dev/null
+++ b/mysql-test/include/maria_make_snapshot.inc
@@ -0,0 +1,48 @@
+# Maria helper script
+# Copies table' data and index file to other directory, or back, or compares.
+# The other directory looks like a database directory, so that we can
+# read copies from inside mysqld, that's also why we copy the frm.
+
+# "mms" is a namespace for Maria_Make_Snapshot
+
+# API:
+# 1) set one of
+# $mms_copy : to copy table from database to spare directory
+# $mms_reverse : to copy it back
+# $mms_compare_physically : to compare both byte-for-byte
+# 2) set $mms_table_to_use to a number N: table will be mysqltest.tN
+# 3) set $mms_purpose to say what this copy is for (influences the naming
+# of the spare directory).
+
+if ($mms_copy)
+{
+ --echo * copied t$mms_table_to_use for $mms_purpose
+ copy_file $MYSQLTEST_VARDIR/master-data/mysqltest/t$mms_table_to_use.MAD $MYSQLTEST_VARDIR/master-data/mysqltest_for_$mms_purpose/t$mms_table_to_use.MAD;
+ copy_file $MYSQLTEST_VARDIR/master-data/mysqltest/t$mms_table_to_use.MAI $MYSQLTEST_VARDIR/master-data/mysqltest_for_$mms_purpose/t$mms_table_to_use.MAI;
+ copy_file $MYSQLTEST_VARDIR/master-data/mysqltest/t$mms_table_to_use.frm $MYSQLTEST_VARDIR/master-data/mysqltest_for_$mms_purpose/t$mms_table_to_use.frm;
+}
+
+if ($mms_reverse_copy)
+{
+ # do not call this without flushing target table first!
+ --echo * copied t$mms_table_to_use back for $mms_purpose
+ -- error 0,1
+ remove_file $MYSQLTEST_VARDIR/master-data/mysqltest/t$mms_table_to_use.MAD;
+ copy_file $MYSQLTEST_VARDIR/master-data/mysqltest_for_$mms_purpose/t$mms_table_to_use.MAD $MYSQLTEST_VARDIR/master-data/mysqltest/t$mms_table_to_use.MAD;
+ -- error 0,1
+ remove_file $MYSQLTEST_VARDIR/master-data/mysqltest/t$mms_table_to_use.MAI;
+ copy_file $MYSQLTEST_VARDIR/master-data/mysqltest_for_$mms_purpose/t$mms_table_to_use.MAI $MYSQLTEST_VARDIR/master-data/mysqltest/t$mms_table_to_use.MAI;
+}
+
+if ($mms_compare_physically)
+{
+ # After the UNDO phase this is normally impossible
+ # (UNDO execution has created new log records => pages have new LSNs).
+ # So, do this only when testing REDO phase.
+ # If UNDO phase, we nevertheless compare checksums
+ # (see maria_verify_recovery.inc).
+ --echo * compared t$mms_table_to_use to old version
+ diff_files $MYSQLTEST_VARDIR/master-data/mysqltest/t$mms_table_to_use.MAD $MYSQLTEST_VARDIR/master-data/mysqltest_for_$mms_purpose/t$mms_table_to_use.MAD;
+# index file not yet recovered
+# diff_files $MYSQLTEST_VARDIR/master-data/mysqltest/t$mms_table_to_use.MAI $MYSQLTEST_VARDIR/master-data/mysqltest_for_$mms_purpose/t$mms_table_to_use.MAI;
+}
diff --git a/mysql-test/include/maria_make_snapshot_for_comparison.inc b/mysql-test/include/maria_make_snapshot_for_comparison.inc
new file mode 100644
index 00000000000..71b821b5212
--- /dev/null
+++ b/mysql-test/include/maria_make_snapshot_for_comparison.inc
@@ -0,0 +1,30 @@
+# Maria helper script
+# Copies clean tables' data and index file to other directory
+# Tables are t1...t[$mms_tables]
+# They are later used as a reference to see if recovery works.
+
+# API:
+# set $mms_tables to N, the script will cover tables mysqltest.t1,...tN
+
+connection admin;
+
+let $mms_table_to_use=$mms_tables;
+let $mms_purpose=comparison;
+let $mms_copy=1;
+
+--disable_query_log
+--disable_warnings
+eval drop database if exists mysqltest_for_$mms_purpose;
+--enable_warnings
+eval create database mysqltest_for_$mms_purpose;
+--enable_query_log
+
+while ($mms_table_to_use)
+{
+ # to serve as a reference, table must be in a clean state
+ eval flush table t$mms_table_to_use;
+ -- source include/maria_make_snapshot.inc
+ dec $mms_table_to_use;
+}
+let $mms_copy=0;
+connection default;
diff --git a/mysql-test/include/maria_make_snapshot_for_feeding_recovery.inc b/mysql-test/include/maria_make_snapshot_for_feeding_recovery.inc
new file mode 100644
index 00000000000..2ca6fb07808
--- /dev/null
+++ b/mysql-test/include/maria_make_snapshot_for_feeding_recovery.inc
@@ -0,0 +1,35 @@
+# Maria helper script
+# Copies tables' data and index file to other directory, and control file.
+# Tables are t1...t[$mms_tables].
+# Later, mysqld is shutdown, and that snapshot is put back into the
+# datadir, control file too ("flashing recovery's brain"), and recovery is let
+# to run on it (see maria_verify_recovery.inc).
+
+# API:
+# set $mms_tables to N, the script will cover tables mysqltest.t1,...tN
+
+connection admin;
+
+let $mms_table_to_use=$mms_tables;
+let $mms_purpose=feeding_recovery;
+let $mms_copy=1;
+
+--disable_query_log
+--disable_warnings
+eval drop database if exists mysqltest_for_$mms_purpose;
+--enable_warnings
+eval create database mysqltest_for_$mms_purpose;
+--enable_query_log
+
+while ($mms_table_to_use)
+{
+ -- source include/maria_make_snapshot.inc
+ dec $mms_table_to_use;
+}
+let $mms_copy=0;
+
+-- error 0,1
+remove_file $MYSQLTEST_VARDIR/tmp/mms_for_$mms_purpose.maria_log_control;
+copy_file $MYSQLTEST_VARDIR/master-data/maria_log_control $MYSQLTEST_VARDIR/tmp/mms_for_$mms_purpose.maria_log_control;
+
+connection default;
diff --git a/mysql-test/include/maria_verify_recovery.inc b/mysql-test/include/maria_verify_recovery.inc
new file mode 100644
index 00000000000..48d799162a4
--- /dev/null
+++ b/mysql-test/include/maria_verify_recovery.inc
@@ -0,0 +1,96 @@
+# Maria helper script.
+# Runs recovery, compare with expected table data.
+
+# API:
+# 1) set $mms_tables to N, the script will cover tables mysqltest.t1,...tN
+# 2) set $mvr_debug_option to the crash way
+# 3) set $mvr_crash_statement to the statement which will trigger a crash
+# 4) set $mvr_restore_old_snapshot to 1 if you want recovery to run on
+# an old copy of tables and of the control file, 0 for normal recovery.
+# 5) set $mms_compare_physically to 1 if you want a physical byte-for-byte
+# comparison with expected table. Checksum comparison is always done.
+# "mvr" is a namespace for Maria_Verify_Recovery
+
+connection admin;
+
+# we may do a copy-back of tables before comparison, so save comparison
+# request made by caller:
+let $mms_compare_physically_save=$mms_compare_physically;
+let $mms_compare_physically=0;
+
+# warn mtr that mysqld is going to die and should not be restarted immediately
+#append_file $MYSQLTEST_VARDIR/tmp/master0.expect;
+#wait-maria_verify_recovery.inc
+#EOF
+# todo: remove this "system" and uncomment above when BUG#32296 is fixed
+system echo wait-maria_verify_recovery.inc >> $MYSQLTEST_VARDIR/tmp/master0.expect;
+
+# flush page cache and log, only log, or nothing, and kill mysqld with
+# abort().
+# When we restore an old snapshot, we could just kill mysqld nicely,
+# but that would implicitely commit all work, which the tester may
+# not want (tester may want to observe rollback happening).
+
+eval SET SESSION debug=$mvr_debug_option;
+--echo * crashing mysqld intentionally
+--error 2013
+eval $mvr_crash_statement; # this will crash (DBUG magic)
+
+if ($mvr_restore_old_snapshot)
+{
+
+ # copy snapshot made by maria_make_snapshot_for_feeding_recovery back
+ # into datadir.
+
+ let $mms_table_to_use=$mms_tables;
+ let $mms_purpose=feeding_recovery;
+ let $mms_reverse_copy=1;
+ while ($mms_table_to_use)
+ {
+ -- source include/maria_make_snapshot.inc
+ dec $mms_table_to_use;
+ }
+ let $mms_reverse_copy=0;
+
+ # also copy back control file, to force recovery to start from an early
+ # point, ignoring further checkpoints.
+ -- error 0,1
+ remove_file $MYSQLTEST_VARDIR/master-data/maria_log_control;
+ copy_file $MYSQLTEST_VARDIR/tmp/mms_for_$mms_purpose.maria_log_control $MYSQLTEST_VARDIR/master-data/maria_log_control;
+}
+
+--echo * recovery happens
+# let mtr restart mysqld (and thus execute the maria log)
+#append_file $MYSQLTEST_VARDIR/tmp/master0.expect;
+#restart-maria_verify_recovery.inc
+#EOF
+system echo restart-maria_verify_recovery.inc >> $MYSQLTEST_VARDIR/tmp/master0.expect;
+
+--source include/wait_until_connected_again.inc
+
+# Compare that tables of $mms_tables are identical to old.
+# We always compare with CHECKSUM TABLE, and if requested (which makes sense
+# only for testing the REDO phase, as UNDO phase generates new records so new
+# LSNs on pages.) with a physical byte-for-byte comparison.
+let $mms_table_to_use=$mms_tables;
+let $mms_purpose=comparison;
+let $mms_compare_physically=$mms_compare_physically_save;
+while ($mms_table_to_use)
+{
+ eval check table t$mms_table_to_use extended;
+ --echo * testing that checksum after recovery is as expected
+ let $new_checksum=`CHECKSUM TABLE t$mms_table_to_use`;
+ let $old_checksum=`CHECKSUM TABLE mysqltest_for_$mms_purpose.t$mms_table_to_use`;
+ # the $ text variables above are of the form "db.tablename\tchecksum",
+ # as db differs, we use substring().
+ --disable_query_log
+ eval select if(substring("$new_checksum",instr("$new_checksum",".t1")) = substring("$old_checksum",instr("$old_checksum",".t1")),"ok","failure") as "Checksum-check";
+ --enable_query_log
+ # this script may compare physically or do nothing
+ -- source include/maria_make_snapshot.inc
+ dec $mms_table_to_use;
+}
+
+connection default;
+# the effect of "use" is lost after a restart so we are back into db "test"
+use mysqltest;
diff --git a/mysql-test/include/ps_conv.inc b/mysql-test/include/ps_conv.inc
index 195d1061664..8cbe9450063 100644
--- a/mysql-test/include/ps_conv.inc
+++ b/mysql-test/include/ps_conv.inc
@@ -52,7 +52,7 @@ set @arg14= 'abc';
set @arg14= NULL ;
set @arg15= CAST('abc' as binary) ;
set @arg15= NULL ;
-create table t5 as select
+eval create table t5 engine = MyISAM as select
8 as const01, @arg01 as param01,
8.0 as const02, @arg02 as param02,
80.00000000000e-1 as const03, @arg03 as param03,
diff --git a/mysql-test/include/wait_until_connected_again.inc b/mysql-test/include/wait_until_connected_again.inc
index dc96f646cb3..d803dd2f699 100644
--- a/mysql-test/include/wait_until_connected_again.inc
+++ b/mysql-test/include/wait_until_connected_again.inc
@@ -1,12 +1,14 @@
#
# Include this script to wait until the connection to the
-# server has been restored or timeout occurs
+# server has been restored or timeout occurs.
+# You should have done --enable_reconnect first
--disable_result_log
--disable_query_log
let $counter= 500;
+let $mysql_errno= 1;
while ($mysql_errno)
{
- --error 0,2002,2006
+ --error 0,2002,2003,2006
show status;
dec $counter;