Commit 4cf30d44 authored by Sven Sandberg's avatar Sven Sandberg

merged 5.1 main to 5.1-rpl

manually resolved conflicts:
Text conflict in client/mysqltest.c
Contents conflict in mysql-test/include/have_bug25714.inc
Text conflict in mysql-test/include/have_ndbapi_examples.inc
Text conflict in mysql-test/mysql-test-run.pl
Text conflict in mysql-test/suite/parts/inc/partition_check_drop.inc
Text conflict in mysql-test/suite/parts/inc/partition_layout.inc
Text conflict in mysql-test/suite/parts/inc/partition_layout_check1.inc
Text conflict in mysql-test/suite/parts/inc/partition_layout_check2.inc
Text conflict in mysql-test/suite/parts/r/partition_alter1_1_2_myisam.result
Text conflict in mysql-test/suite/parts/r/partition_alter1_1_myisam.result
Text conflict in mysql-test/suite/parts/r/partition_alter1_2_myisam.result
Text conflict in mysql-test/suite/parts/r/partition_alter2_myisam.result
Text conflict in mysql-test/suite/parts/r/partition_alter3_innodb.result
Text conflict in mysql-test/suite/parts/r/partition_alter3_myisam.result
Text conflict in mysql-test/suite/parts/r/partition_basic_innodb.result
Text conflict in mysql-test/suite/parts/r/partition_basic_myisam.result
Text conflict in mysql-test/suite/parts/r/partition_basic_symlink_myisam.result
Text conflict in mysql-test/suite/parts/r/partition_engine_myisam.result
Text conflict in mysql-test/suite/parts/r/partition_syntax_myisam.result
Text conflict in mysql-test/suite/rpl_ndb/t/disabled.def
Text conflict in mysql-test/t/disabled.def
parents e1130425 e948f38e
......@@ -1286,6 +1286,7 @@ mysql-test/funcs_1.log
mysql-test/funcs_1.tar
mysql-test/gmon.out
mysql-test/install_test_db
mysql-test/lib/My/SafeProcess/my_safe_process
mysql-test/lib/init_db.sql
mysql-test/linux_sys_vars.inc
mysql-test/load_sysvars.inc
......@@ -2094,10 +2095,13 @@ sql/.libs/udf_example.lai
sql/.libs/udf_example.so.0
sql/.libs/udf_example.so.0.0.0
sql/client.c
sql/Doxyfile
sql/f.c
sql/gen_lex_hash
sql/gmon.out
sql/handlerton.cc
sql/html
sql/latex
sql/lex_hash.h
sql/link_sources
sql/max/*
......
......@@ -257,3 +257,4 @@ IF(WITH_EMBEDDED_SERVER)
ADD_SUBDIRECTORY(libmysqld)
ADD_SUBDIRECTORY(libmysqld/examples)
ENDIF(WITH_EMBEDDED_SERVER)
ADD_SUBDIRECTORY(mysql-test/lib/My/SafeProcess)
This diff is collapsed.
......@@ -2789,8 +2789,8 @@ AC_CONFIG_FILES(Makefile extra/Makefile mysys/Makefile dnl
server-tools/Makefile server-tools/instance-manager/Makefile dnl
cmd-line-utils/Makefile cmd-line-utils/libedit/Makefile dnl
libmysqld/Makefile libmysqld/examples/Makefile dnl
mysql-test/Makefile dnl
mysql-test/ndb/Makefile netware/Makefile sql-bench/Makefile dnl
mysql-test/Makefile mysql-test/lib/My/SafeProcess/Makefile dnl
netware/Makefile sql-bench/Makefile dnl
include/mysql_version.h plugin/Makefile win/Makefile)
AC_CONFIG_COMMANDS([default], , test -z "$CONFIG_HEADERS" || echo timestamp > stamp-h)
......
This diff is collapsed.
#! /bin/sh
# This script is a hack for lazy developers who want to get a quick
# start on the result file. The code here is rather dirty, but it works
# If you have a spare moment feel free to improve it - the right way is
# to start mysqld yourself and run mysqltest -r
RESULT_DIR=r
if [ -z "$EDITOR" ] ; then
EDITOR=vi
fi
function die()
{
echo $1
exit 1
}
function usage()
{
echo "Usage: $0 test_name"
exit 1
}
test_name=$1
[ -z "$test_name" ] && usage
result_file=$RESULT_DIR/$test_name.result
reject_file=$RESULT_DIR/$test_name.reject
[ -f $result_file ] && die "result file $result_file has already been created"
touch $result_file
echo "Running the test case against empty file, will fail, but don't worry"
./mysql-test-run --local $test_name
if [ -f $reject_file ] ; then
echo "Below are the contents of the reject file:"
echo "-----start---------------------"
cat $reject_file
echo "-----end-----------------------"
echo "Is this the output you expected from your test case?(y/n)[n]"
read yes_no
if [ x$yes_no = xy ] ; then
echo "Press any key to edit it in $EDITOR, or Ctrl-C to abort"
read junk
$EDITOR $reject_file
edited="edited"
fi
echo "Save $edited file as master result? (y/n)[y]"
read yes_no
if [ x$yes_no != xn ]; then
mv $reject_file $result_file
fi
else
echo "Your test failed so bad, it did not even produce a reject file"
echo "You need to fix your bugs in the test case, the code, or both"
exit 1
fi
......@@ -7,7 +7,7 @@
-- source include/have_log_bin.inc
# The server need to be started in $MYSQLTEST_VARDIR since it
# uses ../std_data_ln/
# uses ../../std_data/
-- source include/uses_vardir.inc
--disable_warnings
......@@ -114,7 +114,7 @@ insert into t1 values(1);
insert ignore into t1 values(1);
replace into t1 values(100);
create table t2 (a varchar(200)) engine=blackhole;
eval load data infile '../std_data_ln/words.dat' into table t2;
eval load data infile '../../std_data/words.dat' into table t2;
alter table t1 add b int;
alter table t1 drop b;
create table t3 like t1;
......
......@@ -16,7 +16,8 @@ source include/show_binlog_events.inc;
# escaped).
flush logs;
--replace_result $MYSQL_TEST_DIR MYSQL_TEST_DIR
--exec $MYSQL_BINLOG --short-form $MYSQLTEST_VARDIR/log/master-bin.000001
let $MYSQLD_DATADIR= `select @@datadir`;
--exec $MYSQL_BINLOG --short-form $MYSQLD_DATADIR/master-bin.000001
drop table t2;
# End of 4.1 tests
......@@ -317,17 +317,18 @@ connection con4;
select get_lock("a",10); # wait for rollback to finish
flush logs;
let $MYSQLD_DATADIR= `select @@datadir`;
# we check that the error code of the "ROLLBACK" event is 0 and not
# ER_SERVER_SHUTDOWN (i.e. disconnection just rolls back transaction
# and does not make slave to stop)
if (`select @@binlog_format = 'ROW'`)
{
--exec $MYSQL_BINLOG --start-position=524 $MYSQLTEST_VARDIR/log/master-bin.000001 > $MYSQLTEST_VARDIR/tmp/mix_innodb_myisam_binlog.output
--exec $MYSQL_BINLOG --start-position=524 $MYSQLD_DATADIR/master-bin.000001 > $MYSQLTEST_VARDIR/tmp/mix_innodb_myisam_binlog.output
}
if (`select @@binlog_format = 'STATEMENT' || @@binlog_format = 'MIXED'`)
{
--exec $MYSQL_BINLOG --start-position=555 $MYSQLTEST_VARDIR/log/master-bin.000001 > $MYSQLTEST_VARDIR/tmp/mix_innodb_myisam_binlog.output
--exec $MYSQL_BINLOG --start-position=555 $MYSQLD_DATADIR/master-bin.000001 > $MYSQLTEST_VARDIR/tmp/mix_innodb_myisam_binlog.output
}
--replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR
......@@ -618,7 +619,7 @@ CREATE TABLE t5 (a int, PRIMARY KEY (a)) ENGINE=InnoDB;
# execute
--error ER_DUP_ENTRY
load data infile '../std_data_ln/rpl_loaddata.dat' into table t4 (a, @b) set b= @b + bug27417(2);
load data infile '../../std_data/rpl_loaddata.dat' into table t4 (a, @b) set b= @b + bug27417(2);
# check
select * from t4;
select count(*) from t1 /* must be 2 */;
......
......@@ -278,7 +278,7 @@ CREATE TABLE t5 (a int, PRIMARY KEY (a)) ENGINE=InnoDB;
# execute
--error ER_DUP_ENTRY
load data infile '../std_data_ln/rpl_loaddata.dat' into table t4 (a, @b) set b= @b + bug27417(2);
load data infile '../../std_data/rpl_loaddata.dat' into table t4 (a, @b) set b= @b + bug27417(2);
# check
select * from t4;
select count(*) from t1 /* must be 2 */;
......
......@@ -20,7 +20,8 @@
eval create table t1 (a int) engine=$engine_type;
flush tables;
system rm $MYSQLTEST_VARDIR/master-data/test/t1.MYI ;
let $MYSQLD_DATADIR= `select @@datadir`;
system rm $MYSQLD_DATADIR/test/t1.MYI ;
drop table if exists t1;
save_master_pos;
connection slave;
......
......@@ -497,7 +497,7 @@ INSERT INTO t10 () VALUES(1,@b1,DEFAULT,'Kyle',DEFAULT),
--echo ********************************************
--echo
connection slave;
wait_for_slave_to_stop;
source include/wait_for_slave_sql_to_stop.inc;
--replace_result $MASTER_MYPORT MASTER_PORT
--replace_column 1 # 4 # 7 # 8 # 9 # 22 # 23 # 33 # 35 # 36 #
--query_vertical SHOW SLAVE STATUS
......@@ -554,7 +554,7 @@ INSERT INTO t11 () VALUES(1,@b1,'Testing is fun','Kyle',DEFAULT),
--echo ********************************************
--echo
connection slave;
wait_for_slave_to_stop;
source include/wait_for_slave_sql_to_stop.inc;
--replace_result $MASTER_MYPORT MASTER_PORT
--replace_column 1 # 4 # 7 # 8 # 9 # 22 # 23 # 33 # 35 # 36 #
--query_vertical SHOW SLAVE STATUS
......@@ -697,7 +697,7 @@ SELECT c1,c3,hex(c4),c5,c6 FROM t14 ORDER BY c1;
# Remove below once fixed
#***************************
connection slave;
wait_for_slave_to_stop;
source include/wait_for_slave_sql_to_stop.inc;
--replace_result $MASTER_MYPORT MASTER_PORT
--replace_column 1 # 4 # 7 # 8 # 9 # 22 # 23 # 33 # 35 # 36 #
--query_vertical SHOW SLAVE STATUS
......@@ -763,7 +763,7 @@ SELECT c1,hex(c4),c5,c6,c7,c2 FROM t15 ORDER BY c1;
--echo ********************************************
--echo
connection slave;
wait_for_slave_to_stop;
source include/wait_for_slave_sql_to_stop.inc;
--replace_result $MASTER_MYPORT MASTER_PORT
--replace_column 1 # 4 # 7 # 8 # 9 # 22 # 23 # 33 # 35 # 36 #
--query_vertical SHOW SLAVE STATUS
......@@ -840,7 +840,7 @@ SELECT c1,hex(c4),c5,c6,c7 FROM t16 ORDER BY c1;
--echo *****************
--echo
connection slave;
wait_for_slave_to_stop;
source include/wait_for_slave_sql_to_stop.inc;
--replace_result $MASTER_MYPORT MASTER_PORT
--replace_column 1 # 4 # 7 # 8 # 9 # 22 # 23 # 33 # 35 # 36 #
--query_vertical SHOW SLAVE STATUS
......
......@@ -94,7 +94,7 @@ SELECT * FROM t2 ORDER BY a;
--echo *** Start Slave ***
connection slave;
START SLAVE;
wait_for_slave_to_stop;
source include/wait_for_slave_sql_to_stop.inc;
--replace_result $MASTER_MYPORT MASTER_PORT
--replace_column 1 # 4 # 7 # 8 # 9 # 16 # 22 # 23 # 33 # 35 # 36 #
--query_vertical SHOW SLAVE STATUS
......@@ -429,6 +429,7 @@ set @b1 = 'b1b1b1b1';
set @b1 = concat(@b1,@b1);
INSERT INTO t9 () VALUES(1,@b1,'Kyle'),(2,@b1,'JOE'),(3,@b1,'QA');
connection slave;
--source include/wait_for_slave_sql_to_stop.inc
--replace_result $MASTER_MYPORT MASTER_PORT
--replace_column 1 # 4 # 7 # 8 # 9 # 16 # 22 # 23 # 33 # 35 # 36 #
......
......@@ -23,12 +23,12 @@ connection master;
select last_insert_id();
create table t1(a int not null auto_increment, b int, primary key(a) );
load data infile '../std_data_ln/rpl_loaddata.dat' into table t1;
load data infile '../../std_data/rpl_loaddata.dat' into table t1;
# verify that LAST_INSERT_ID() is set by LOAD DATA INFILE
select last_insert_id();
create temporary table t2 (day date,id int(9),category enum('a','b','c'),name varchar(60));
load data infile '../std_data_ln/rpl_loaddata2.dat' into table t2 fields terminated by ',' optionally enclosed by '%' escaped by '@' lines terminated by '\n##\n' starting by '>' ignore 1 lines;
load data infile '../../std_data/rpl_loaddata2.dat' into table t2 fields terminated by ',' optionally enclosed by '%' escaped by '@' lines terminated by '\n##\n' starting by '>' ignore 1 lines;
create table t3 (day date,id int(9),category enum('a','b','c'),name varchar(60));
insert into t3 select * from t2;
......@@ -56,7 +56,7 @@ sync_with_master;
insert into t1 values(1,10);
connection master;
load data infile '../std_data_ln/rpl_loaddata.dat' into table t1;
load data infile '../../std_data/rpl_loaddata.dat' into table t1;
save_master_pos;
connection slave;
......@@ -80,7 +80,7 @@ connection master;
set sql_log_bin=0;
delete from t1;
set sql_log_bin=1;
load data infile '../std_data_ln/rpl_loaddata.dat' into table t1;
load data infile '../../std_data/rpl_loaddata.dat' into table t1;
save_master_pos;
connection slave;
# The SQL slave thread should be stopped now.
......@@ -105,7 +105,7 @@ connection master;
set sql_log_bin=0;
delete from t1;
set sql_log_bin=1;
load data infile '../std_data_ln/rpl_loaddata.dat' into table t1;
load data infile '../../std_data/rpl_loaddata.dat' into table t1;
save_master_pos;
connection slave;
# The SQL slave thread should be stopped now.
......@@ -125,7 +125,7 @@ reset master;
eval create table t2 (day date,id int(9),category enum('a','b','c'),name varchar(60),
unique(day)) engine=$engine_type; # no transactions
--error ER_DUP_ENTRY
load data infile '../std_data_ln/rpl_loaddata2.dat' into table t2 fields
load data infile '../../std_data/rpl_loaddata2.dat' into table t2 fields
terminated by ',' optionally enclosed by '%' escaped by '@' lines terminated by
'\n##\n' starting by '>' ignore 1 lines;
select * from t2;
......@@ -141,7 +141,7 @@ alter table t2 drop key day;
connection master;
delete from t2;
--error ER_DUP_ENTRY
load data infile '../std_data_ln/rpl_loaddata2.dat' into table t2 fields
load data infile '../../std_data/rpl_loaddata2.dat' into table t2 fields
terminated by ',' optionally enclosed by '%' escaped by '@' lines terminated by
'\n##\n' starting by '>' ignore 1 lines;
connection slave;
......@@ -155,7 +155,7 @@ drop table t1;
CREATE TABLE t1 (word CHAR(20) NOT NULL PRIMARY KEY) ENGINE=INNODB;
--error ER_DUP_ENTRY
LOAD DATA INFILE "../std_data_ln/words.dat" INTO TABLE t1;
LOAD DATA INFILE "../../std_data/words.dat" INTO TABLE t1;
--disable_warnings
DROP TABLE IF EXISTS t1;
......
......@@ -9,10 +9,8 @@
# test the slave immediately writes DROP TEMPORARY TABLE this_old_table).
# We wait for the slave to have written all he wants to the binlog
# (otherwise RESET MASTER may come too early).
save_master_pos;
connection slave;
sync_with_master;
stop slave;
sync_slave_with_master;
source include/stop_slave.inc;
reset master;
reset slave;
# We are going to read the slave's binlog which contains file_id (for some LOAD
......@@ -32,8 +30,13 @@ reset master;
eval create table t1(n int not null auto_increment primary key)ENGINE=$engine_type;
insert into t1 values (NULL);
drop table t1;
let $LOAD_FILE= ../../std_data/words.dat;
if (!`SELECT length(load_file('$LOAD_FILE'))`){
let $LOAD_FILE= ../$LOAD_FILE;
}
eval create table t1 (word char(20) not null)ENGINE=$engine_type;
load data infile '../std_data_ln/words.dat' into table t1 ignore 1 lines;
--replace_result $LOAD_FILE LOAD_FILE
eval load data infile '$LOAD_FILE' into table t1 ignore 1 lines;
select count(*) from t1;
--replace_result $VERSION VERSION
--replace_column 2 # 5 #
......@@ -76,17 +79,14 @@ select * from t1 order by 1 asc;
save_master_pos;
connection slave;
# Note that the above 'slave start' will cause a 3rd rotate event (a fake one)
# to go into the relay log (the master always sends a fake one when replication
# starts).
start slave;
let $result_pattern= '%127.0.0.1%root%master-bin.000002%slave-relay-bin.000005%Yes%Yes%0%0%None%';
--source include/wait_slave_status.inc
source include/start_slave.inc;
sync_with_master;
#check t1 on slave to ensure whether it's identical with on master
select * from t1 order by 1 asc;
flush logs;
stop slave;
source include/stop_slave.inc;
source include/start_slave.inc;
connection master;
# Create some entries for second log
......@@ -99,10 +99,7 @@ source include/show_binlog_events.inc;
--replace_regex /\/\* xid=.* \*\//\/* XID *\// /table_id: [0-9]+/table_id: #/
show binlog events in 'master-bin.000002';
show binary logs;
save_master_pos;
connection slave;
start slave;
sync_with_master;
sync_slave_with_master;
show binary logs;
--replace_result $MASTER_MYPORT MASTER_PORT $VERSION VERSION
--replace_column 2 # 5 #
......
let $LOAD_FILE= $MYSQLTEST_VARDIR/std_data/words.dat;
CREATE TABLE t1 (word CHAR(20) NOT NULL);
LOAD DATA INFILE '../std_data_ln/words.dat' INTO TABLE t1;
--replace_result $MYSQL_TEST_DIR MYSQL_TEST_DIR
eval LOAD DATA LOCAL INFILE '$MYSQL_TEST_DIR/std_data/words.dat' INTO TABLE t1;
--replace_result $LOAD_FILE LOAD_FILE
eval LOAD DATA INFILE '$LOAD_FILE' INTO TABLE t1;
--replace_result $LOAD_FILE LOAD_FILE
eval LOAD DATA INFILE '$LOAD_FILE' INTO TABLE t1;
SELECT * FROM t1 ORDER BY word LIMIT 10;
#
......
......@@ -122,7 +122,7 @@ INSERT INTO t1_nodef VALUES (1,2);
connection slave;
--source include/wait_for_slave_sql_to_stop.inc
--replace_result $MASTER_MYPORT MASTER_PORT
--replace_column 1 # 4 # 7 # 8 # 9 # 20 <Last_Error> 22 # 23 # 33 # 36 <Last_IO_Error> 38 <Last_SQL_Error>
--replace_column 1 # 4 # 7 # 8 # 9 # 20 <Last_Error> 22 # 23 # 33 # 35 <Last_IO_Errno> 36 <Last_IO_Error> 38 <Last_SQL_Error>
--query_vertical SHOW SLAVE STATUS
SET GLOBAL SQL_SLAVE_SKIP_COUNTER=2;
START SLAVE;
......@@ -142,7 +142,7 @@ sync_slave_with_master;
--echo **** On Slave ****
SELECT * FROM t2;
--replace_result $MASTER_MYPORT MASTER_PORT
--replace_column 1 # 4 # 7 # 8 # 9 # 20 <Last_Error> 22 # 23 # 33 # 36 <Last_IO_Error> 38 <Last_SQL_Error>
--replace_column 1 # 4 # 7 # 8 # 9 # 20 <Last_Error> 22 # 23 # 33 # 35 <Last_IO_Errno> 36 <Last_IO_Error> 38 <Last_SQL_Error>
--query_vertical SHOW SLAVE STATUS
connection master;
......@@ -154,7 +154,7 @@ INSERT INTO t4 VALUES (4);
connection slave;
--source include/wait_for_slave_sql_to_stop.inc
--replace_result $MASTER_MYPORT MASTER_PORT
--replace_column 1 # 4 # 7 # 8 # 9 # 20 <Last_Error> 22 # 23 # 33 # 36 <Last_IO_Error> 38 <Last_SQL_Error>
--replace_column 1 # 4 # 7 # 8 # 9 # 20 <Last_Error> 22 # 23 # 33 # 35 <Last_IO_Errno> 36 <Last_IO_Error> 38 <Last_SQL_Error>
--query_vertical SHOW SLAVE STATUS
SET GLOBAL SQL_SLAVE_SKIP_COUNTER=2;
START SLAVE;
......@@ -168,7 +168,7 @@ INSERT INTO t5 VALUES (5,10,25);
connection slave;
--source include/wait_for_slave_sql_to_stop.inc
--replace_result $MASTER_MYPORT MASTER_PORT
--replace_column 1 # 4 # 7 # 8 # 9 # 20 <Last_Error> 22 # 23 # 33 # 36 <Last_IO_Error> 38 <Last_SQL_Error>
--replace_column 1 # 4 # 7 # 8 # 9 # 20 <Last_Error> 22 # 23 # 33 # 35 <Last_IO_Errno> 36 <Last_IO_Error> 38 <Last_SQL_Error>
--query_vertical SHOW SLAVE STATUS
SET GLOBAL SQL_SLAVE_SKIP_COUNTER=2;
START SLAVE;
......@@ -182,7 +182,7 @@ INSERT INTO t6 VALUES (6,12,36);
connection slave;
--source include/wait_for_slave_sql_to_stop.inc
--replace_result $MASTER_MYPORT MASTER_PORT
--replace_column 1 # 4 # 7 # 8 # 9 # 20 <Last_Error> 22 # 23 # 33 # 36 <Last_IO_Error> 38 <Last_SQL_Error>
--replace_column 1 # 4 # 7 # 8 # 9 # 20 <Last_Error> 22 # 23 # 33 # 35 <Last_IO_Errno> 36 <Last_IO_Error> 38 <Last_SQL_Error>
--query_vertical SHOW SLAVE STATUS
SET GLOBAL SQL_SLAVE_SKIP_COUNTER=2;
START SLAVE;
......@@ -191,7 +191,7 @@ connection master;
INSERT INTO t9 VALUES (6);
sync_slave_with_master;
--replace_result $SLAVE_MYPORT SLAVE_PORT
--replace_column 1 # 4 # 7 # 8 # 9 # 20 <Last_Error> 22 # 23 # 33 # 36 <Last_IO_Error> 38 <Last_SQL_Error>
--replace_column 1 # 4 # 7 # 8 # 9 # 20 <Last_Error> 22 # 23 # 33 # 35 <Last_IO_Errno> 36 <Last_IO_Error> 38 <Last_SQL_Error>
--query_vertical SHOW SLAVE STATUS
# Testing some tables extra field that can be null and cannot be null
......
......@@ -2,7 +2,7 @@
-- source include/master-slave.inc
create table t1 (word char(20) not null);
load data infile '../std_data_ln/words.dat' into table t1;
load data infile '../../std_data/words.dat' into table t1;
--replace_result $MYSQL_TEST_DIR MYSQL_TEST_DIR
eval load data local infile '$MYSQL_TEST_DIR/std_data/words.dat' into table t1;
select * from t1 limit 10;
......
#! /bin/sh
# Sasha's hack to fix results generated with mysql-test-run --record
# to be version and test port independent. In some cases, further minor
# manual edititing may be required, but most of the time it should not
# happen
#It is assumed we are running the script in mysql-test directory
VERSION=4.0.1-alpha-debug-log
TEST_CASE=$1
if [ -z "$TEST_CASE" ] ;
then
echo "usage: $0 test_case_name"
exit 1
fi
../extra/replace $VERSION '$VERSION' 9306 '$MASTER_MYPORT' 9307 \
'$SLAVE_MYPORT' \\ \\\\ -- r/$TEST_CASE.result
#
# This test is executed twice for each test case if mysql-test-run is passed
# the flag --check-testcase.
# Before every testcase it's run with mysqltest in record mode and will
# thus produce an output file
# that can be compared to output from after the tescase.
# In that way it's possible to check that a testcase does not have
# the flag --check-testcase. Before every testcase it is run with mysqltest
# in record mode and will thus produce an output file that can be compared
# to output from after the tescase.
# In that way its possible to check that a testcase does not have
# any unwanted side affects.
#
#
# Dump all global variables
#
show global variables;
#
# Dump all databases
#
show databases;
#
# Dump the "test" database, all it's tables and their data
#
--exec $MYSQL_DUMP --skip-comments --skip-lock-tables test
#
# Dump the "mysql" database and it's tables
# Select data separately to add "order by"
#
--exec $MYSQL_DUMP --skip-comments --skip-lock-tables --no-data mysql
use mysql;
select * from columns_priv;
select * from db order by host, db, user;
select * from func;
select * from help_category;
select * from help_keyword;
select * from help_relation;
select * from help_relation;
select * from host;
select * from proc;
select * from procs_priv;
select * from tables_priv;
select * from time_zone;
select * from time_zone_leap_second;
select * from time_zone_name;
select * from time_zone_transition;
select * from time_zone_transition_type;
select * from user;
--disable_query_log
call mtr.check_testcase();
--enable_query_log
#
# This test is executed once after each test to check the servers
# for unexpected warnings found in the servers error log
#
--disable_query_log
call mtr.check_warnings(@result);
if (`select @result = 0`){
skip OK;
}
echo Found warnings;
--enable_query_log
#############################################################
#
# Author: Serge Kozlov <skozlov@mysql.com>
# Date: 03/11/2008
# Purpose: Set up circular replication based on schema
# A->B->C->D->A
#
# Notes:
# 1. --slave-num=3 must be added to *-master.opt file
# 2. Even the test uses new names for servers but file names
# of log files are still old:
# master_a -> master.[log|err]
# master_b -> slave.[log|err]
# master_c -> slave1.[log|err]
# master_d -> slave2.[log|err]
#
#############################################################
--source include/master-slave.inc
#
# Set up circular ring by schema A->B->C->D->A
#
--connection slave
STOP SLAVE;
RESET SLAVE;
# master a
--connection master
--disconnect master
connect (master_a,127.0.0.1,root,,test,$MASTER_MYPORT,);
RESET MASTER;
--disable_warnings
STOP SLAVE;
--enable_warnings
RESET SLAVE;
SET auto_increment_increment = 4;
SET auto_increment_offset = 1;
let $_binlog_file= query_get_value(SHOW MASTER STATUS, File, 1);
# master b
--connection slave
--disconnect slave
connect (master_b,127.0.0.1,root,,test,$SLAVE_MYPORT,);
RESET MASTER;
RESET SLAVE;
--replace_result $MASTER_MYPORT MASTER_A_PORT $_binlog_file MASTER_A_LOG_FILE
--eval CHANGE MASTER TO master_host='127.0.0.1',master_port=$MASTER_MYPORT,master_user='root',MASTER_LOG_FILE='$_binlog_file'
SET auto_increment_increment = 4;
SET auto_increment_offset = 2;
let $_binlog_file= query_get_value(SHOW MASTER STATUS, File, 1);
# master c
--connection slave1
--disconnect slave1
connect (master_c,127.0.0.1,root,,test,$SLAVE_MYPORT1,);
RESET MASTER;
--disable_warnings
STOP SLAVE;
--enable_warnings
RESET SLAVE;
--replace_result $SLAVE_MYPORT MASTER_B_PORT $_binlog_file MASTER_B_LOG_FILE
--eval CHANGE MASTER TO master_host='127.0.0.1',master_port=$SLAVE_MYPORT,master_user='root',MASTER_LOG_FILE='$_binlog_file'
SET auto_increment_increment = 4;
SET auto_increment_offset = 3;
let $_binlog_file= query_get_value(SHOW MASTER STATUS, File, 1);
# master d
connect (master_d,127.0.0.1,root,,test,$SLAVE_MYPORT2,);
RESET MASTER;
--disable_warnings
STOP SLAVE;
--enable_warnings
RESET SLAVE;
--replace_result $SLAVE_MYPORT1 MASTER_C_PORT $_binlog_file MASTER_C_LOG_FILE
--eval CHANGE MASTER TO master_host='127.0.0.1',master_port=$SLAVE_MYPORT1,master_user='root',MASTER_LOG_FILE='$_binlog_file'
SET auto_increment_increment = 4;
SET auto_increment_offset = 4;
let $_binlog_file= query_get_value(SHOW MASTER STATUS, File, 1);
# master a
--connection master_a
--replace_result $SLAVE_MYPORT2 MASTER_D_PORT $_binlog_file MASTER_D_LOG_FILE
--eval CHANGE MASTER TO master_host='127.0.0.1',master_port=$SLAVE_MYPORT2,master_user='root',MASTER_LOG_FILE='$_binlog_file'
# Check server_ids: they should be different
--connection master_a
let $_id_a= query_get_value(SHOW VARIABLES LIKE 'server_id', Value, 1);
SHOW VARIABLES LIKE 'auto_increment_%';
--connection master_b
let $_id_b= query_get_value(SHOW VARIABLES LIKE 'server_id', Value, 1);
SHOW VARIABLES LIKE 'auto_increment_%';
--connection master_c
let $_id_c= query_get_value(SHOW VARIABLES LIKE 'server_id', Value, 1);
SHOW VARIABLES LIKE 'auto_increment_%';
--connection master_d
let $_id_d= query_get_value(SHOW VARIABLES LIKE 'server_id', Value, 1);
SHOW VARIABLES LIKE 'auto_increment_%';
--connection master_a
let $_compared_ids= (($_id_a <> $_id_b) AND ($_id_a <> $_id_c) AND ($_id_a <> $_id_d) AND ($_id_b <> $_id_c) AND ($_id_b <> $_id_d) AND ($_id_c <> $_id_d)) AS a;
let $_compared_ids_result= query_get_value(SELECT $_compared_ids, a, 1);
--echo $_compared_ids_result
# Start ring
--connection master_a
connect(slave,127.0.0.1,root,,test,$MASTER_MYPORT);
START SLAVE;
--source include/wait_for_slave_to_start.inc
--disconnect slave
--connection master_b
connect(slave,127.0.0.1,root,,test,$SLAVE_MYPORT1);
START SLAVE;
--source include/wait_for_slave_to_start.inc
--disconnect slave
--connection master_c
connect(slave,127.0.0.1,root,,test,$SLAVE_MYPORT);
START SLAVE;
--source include/wait_for_slave_to_start.inc
--disconnect slave
--connection master_d
connect(slave,127.0.0.1,root,,test,$SLAVE_MYPORT2);
START SLAVE;
--source include/wait_for_slave_to_start.inc
--disconnect slave
#############################################################
#
# Author: Serge Kozlov <skozlov@mysql.com>
# Date: 03/11/2008
# Purpose: Sync all hosts for circular replication based on
# schema A->B->C->D->A
#
# Notes: see include/circular_rpl_for_4_hosts_init.inc
#
#############################################################
# Make the full loop of sync
--connection master_a
--disable_query_log
--sync_slave_with_master master_b
--sync_slave_with_master master_c
--sync_slave_with_master master_d
--sync_slave_with_master master_a
--sync_slave_with_master master_b
--sync_slave_with_master master_c
--save_master_pos
--connection master_a
--enable_query_log
......@@ -267,7 +267,7 @@ select * from t2;
insert into t2 (a) values (1026);
--replace_result $MYSQLTEST_VARDIR ..
--error ER_DUP_ENTRY
eval load data infile "../std_data_ln/words.dat" into table t1 (a) set a:=f2(26);
eval load data infile "../../std_data/words.dat" into table t1 (a) set a:=f2(26);
select * from t2;
rollback;
......
# Use default setting for mysqld processes
!include default_mysqld.cnf
[mysqld.1]
# Run the master.sh script before starting this process
#!run-master-sh
log-bin= master-bin
[mysqlbinlog]
disable-force-if-open
# mysql_fix_privilege_tables.sh does not read from [client] so it
# need its own section
[mysql_fix_privilege_tables]
socket= @client.socket
port= @client.port
user= @client.user
password= @client.password
[ENV]
MASTER_MYPORT= @mysqld.1.port
MASTER_MYSOCK= @mysqld.1.socket
# Default values that applies to all MySQL Servers
[mysqld]
open-files-limit= 1024
local-infile
default-character-set= latin1
# Increase default connect_timeout to avoid intermittent
# disconnects when test servers are put under load see BUG#28359
connect-timeout= 60
log-bin-trust-function-creators=1
key_buffer_size= 1M
sort_buffer= 256K
max_heap_table_size= 1M
loose-innodb_data_file_path= ibdata1:10M:autoextend
slave-net-timeout=120
log-bin=mysqld-bin
[cluster_config]
MaxNoOfSavedMessages= 1000
MaxNoOfConcurrentTransactions= 64
MaxNoOfConcurrentOperations= 10000
DataMemory= 20M
IndexMemory= 1M
Diskless= 0
TimeBetweenWatchDogCheck= 30000
MaxNoOfOrderedIndexes= 32
MaxNoOfAttributes= 2048
TimeBetweenGlobalCheckpoints= 500
NoOfFragmentLogFiles= 4
FragmentLogFileSize= 12M
DiskPageBufferMemory= 4M
# O_DIRECT has issues on 2.4 whach have not been handled, Bug #29612
#ODirect= 1
# the following parametes just function as a small regression
# test that the parameter exists
InitialNoOfOpenFiles= 27
# Increase timeouts for slow test-machines
HeartbeatIntervalDbDb= 30000
HeartbeatIntervalDbApi= 30000
#TransactionDeadlockDetectionTimeout= 7500
disable_query_log;
--require r/true.require
select (support = 'YES' or support = 'DEFAULT') as `TRUE` from information_schema.engines where engine = 'blackhole';
enable_query_log;
if (!`SELECT count(*) FROM information_schema.engines WHERE
(support = 'YES' OR support = 'DEFAULT') AND
engine = 'blackhole'`){
skip Need blackhole engine;
}
#
# Check if the variable MYSQL_BUG25714 is set
#
--require r/have_bug25714.require
disable_query_log;
eval select LENGTH('$MYSQL_BUG25714') > 0 as 'have_bug25714_exe';
enable_query_log;
disable_query_log;
--require r/true.require
select (support = 'YES' or support = 'DEFAULT') as `TRUE` from information_schema.engines where engine = 'federated';
enable_query_log;
# ==== Purpose ====
#
# Ensure that the server is running with binlogging on
#
# ==== Usage ====
#
# source include/have_log_bin.inc;
-- require r/have_log_bin.require
disable_query_log;
show variables like 'log_bin';
......
--require r/have_ndbapi_examples.require
disable_query_log;
eval select LENGTH('$MY_NDB_EXAMPLES_BINARY') > 0 as 'have_ndb_example';
eval select LENGTH('$NDB_EXAMPLES_BINARY') > 0 as 'have_ndb_example';
enable_query_log;
......@@ -7,16 +7,20 @@ eval SET SESSION STORAGE_ENGINE = $engine_type;
drop table if exists t1;
--enable_warnings
let $load_file= $MYSQLTEST_VARDIR/std_data/loaddata2.dat;
# NDB does not support the create option 'Binlog of table with BLOB attribute and no PK'
# So use a dummy PK here.
create table t1 (id int unsigned not null auto_increment primary key, a text, b text);
start transaction;
load data infile '../std_data_ln/loaddata2.dat' into table t1 fields terminated by ',' enclosed by '''' (a, b);
--replace_result $load_file LOAD_FILE
eval load data infile '$load_file' into table t1 fields terminated by ',' enclosed by '''' (a, b);
commit;
select count(*) from t1;
truncate table t1;
start transaction;
load data infile '../std_data_ln/loaddata2.dat' into table t1 fields terminated by ',' enclosed by '''' (a, b);
--replace_result $load_file LOAD_FILE
eval load data infile '$load_file' into table t1 fields terminated by ',' enclosed by '''' (a, b);
rollback;
select count(*) from t1;
......
# Reset the master and the slave to start fresh.
#
# It is necessary to execute RESET MASTER and RESET SLAVE on both
# master and slave since the replication setup might be circular.
#
# Since we expect STOP SLAVE to produce a warning as the slave is
# stopped (the server was started with skip-slave-start), we disable
# warnings when doing STOP SLAVE.
connection slave;
#we expect STOP SLAVE to produce a warning as the slave is stopped
#(the server was started with skip-slave-start)
--disable_warnings
stop slave;
source include/wait_for_slave_to_stop.inc;
......@@ -13,11 +20,17 @@ use test;
drop table if exists t1,t2,t3,t4,t5,t6,t7,t8,t9;
--enable_warnings
reset master;
--disable_query_log
reset slave;
--enable_query_log
connection slave;
reset slave;
# Clean up old test tables
--disable_warnings
drop table if exists t1,t2,t3,t4,t5,t6,t7,t8,t9;
--enable_warnings
--disable_query_log
reset master;
--enable_query_log
start slave;
source include/wait_for_slave_to_start.inc;
......@@ -623,7 +623,8 @@ DROP TABLE t1,t2,t3;
#
create table t1 (a int) engine=innodb;
copy_file $MYSQLTEST_VARDIR/master-data/test/t1.frm $MYSQLTEST_VARDIR/master-data/test/bug29807.frm;
let $MYSQLD_DATADIR= `select @@datadir`;
copy_file $MYSQLD_DATADIR/test/t1.frm $MYSQLD_DATADIR/test/bug29807.frm;
--error 1146
select * from bug29807;
drop table t1;
......
delimiter ||;
use mtr||
--
-- Procedure used to check if server has been properly
-- restored after testcase has been run
--
CREATE DEFINER=root@localhost PROCEDURE check_testcase()
BEGIN
-- Dump all global variables except those
-- that are supposed to change
SELECT * FROM INFORMATION_SCHEMA.GLOBAL_VARIABLES
WHERE variable_name != 'timestamp';
-- Dump all databases, there should be none
-- except those that was created during bootstrap
SELECT * FROM INFORMATION_SCHEMA.SCHEMATA;
-- The test database should not contain any tables
SELECT table_name AS tables_in_test FROM INFORMATION_SCHEMA.TABLES
WHERE table_schema='test';
-- Show "mysql" database, tables and columns
SELECT CONCAT(table_schema, '.', table_name) AS tables_in_mysql
FROM INFORMATION_SCHEMA.TABLES
WHERE table_schema='mysql' AND table_name != 'ndb_apply_status'
ORDER BY tables_in_mysql;
SELECT CONCAT(table_schema, '.', table_name) AS columns_in_mysql,
column_name, ordinal_position, column_default, is_nullable,
data_type, character_maximum_length, character_octet_length,
numeric_precision, numeric_scale, character_set_name,
collation_name, column_type, column_key, extra, column_comment
FROM INFORMATION_SCHEMA.COLUMNS
WHERE table_schema='mysql' AND table_name != 'ndb_apply_status'
ORDER BY columns_in_mysql;
-- Checksum system tables to make sure they have been properly
-- restored after test
checksum table
mysql.columns_priv,
mysql.db,
mysql.func,
mysql.help_category,
mysql.help_keyword,
mysql.help_relation,
mysql.host,
mysql.proc,
mysql.procs_priv,
mysql.tables_priv,
mysql.time_zone,
mysql.time_zone_leap_second,
mysql.time_zone_name,
mysql.time_zone_transition,
mysql.time_zone_transition_type,
mysql.user;
END||
delimiter ||;
use mtr||
--
-- Load table with the patterns that are considered
-- as suspicious and should be examined further
--
CREATE TABLE suspicious_patterns (
pattern VARCHAR(255)
)||
--
-- Declare a trigger that makes sure
-- no invalid patterns can be inserted
-- into suspicious_patterns
--
/*!50002
CREATE DEFINER=root@localhost TRIGGER sp_insert
BEFORE INSERT ON suspicious_patterns
FOR EACH ROW BEGIN
DECLARE dummy INT;
SELECT "" REGEXP NEW.pattern INTO dummy;
END
*/||
--
-- Insert patterns for the lines we should check
--
INSERT INTO suspicious_patterns VALUES
("^Warning:|mysqld: Warning|\\[Warning\\]"),
("^Error:|\\[ERROR\\]"),
("^==.* at 0x"),
("InnoDB: Warning"),
("^safe_mutex:|allocated at line"),
("missing DBUG_RETURN"),
("Attempting backtrace"),
("Assertion .* failed")||
--
-- Create table where testcases can insert patterns to
-- be supressed
--
CREATE TABLE test_supressions (
pattern VARCHAR(255)
)||
--
-- Declare a trigger that makes sure
-- no invalid patterns can be inserted
-- into test_supressions
--
/*!50002
CREATE DEFINER=root@localhost TRIGGER ts_insert
BEFORE INSERT ON test_supressions
FOR EACH ROW BEGIN
DECLARE dummy INT;
SELECT "" REGEXP NEW.pattern INTO dummy;
END
*/||
--
-- Load table with patterns that will be supressed globally(always)
--
CREATE TABLE global_supressions (
pattern VARCHAR(255)
)||
-- Declare a trigger that makes sure
-- no invalid patterns can be inserted
-- into global_supressions
--
/*!50002
CREATE DEFINER=root@localhost TRIGGER gs_insert
BEFORE INSERT ON global_supressions
FOR EACH ROW BEGIN
DECLARE dummy INT;
SELECT "" REGEXP NEW.pattern INTO dummy;
END
*/||
--
-- Insert patterns that should always be supressed
--
INSERT INTO global_supressions VALUES
("'SELECT UNIX_TIMESTAMP\\(\\)' failed on master"),
("Aborted connection"),
("Client requested master to start replication from impossible position"),
("Could not find first log file name in binary log"),
("Enabling keys got errno"),
("Error reading master configuration"),
("Error reading packet"),
("Event Scheduler"),
("Failed to open log"),
("Failed to open the existing master info file"),
("Forcing shutdown of [0-9]* plugins"),
/*
Due to timing issues, it might be that this warning
is printed when the server shuts down and the
computer is loaded.
*/
("Got error [0-9]* when reading table"),
("Incorrect definition of table"),
("Incorrect information in file"),
("InnoDB: Warning: we did not need to do crash recovery"),
("Invalid \\(old\\?\\) table or database name"),
("Lock wait timeout exceeded"),
("Log entry on master is longer than max_allowed_packet"),
("unknown option '--loose-"),
("unknown variable 'loose-"),
("You have forced lower_case_table_names to 0 through a command-line option"),
("Setting lower_case_table_names=2"),
("NDB Binlog:"),
("NDB: failed to setup table"),
("NDB: only row based binary logging"),
("Neither --relay-log nor --relay-log-index were used"),
("Query partially completed"),
("Slave I.O thread aborted while waiting for relay log"),
("Slave SQL thread is stopped because UNTIL condition"),
("Slave SQL thread retried transaction"),
("Slave \\(additional info\\)"),
("Slave: .*Duplicate column name"),
("Slave: .*master may suffer from"),
("Slave: According to the master's version"),
("Slave: Column [0-9]* type mismatch"),
("Slave: Error .* doesn't exist"),
("Slave: Error .*Deadlock found"),
("Slave: Error .*Unknown table"),
("Slave: Error in Write_rows event: "),
("Slave: Field .* of table .* has no default value"),
("Slave: Field .* doesn't have a default value"),
("Slave: Query caused different errors on master and slave"),
("Slave: Table .* doesn't exist"),
("Slave: Table width mismatch"),
("Slave: The incident LOST_EVENTS occured on the master"),
("Slave: Unknown error.* 1105"),
("Slave: Can't drop database.* database doesn't exist"),
("Slave SQL:.*(Error_code: \[\[:digit:\]\]+|Query:.*)"),
("Sort aborted"),
("Time-out in NDB"),
("Warning:\s+One can only use the --user.*root"),
("Warning:\s+Setting lower_case_table_names=2"),
("Warning:\s+Table:.* on (delete|rename)"),
("You have an error in your SQL syntax"),
("deprecated"),
("description of time zone"),
("equal MySQL server ids"),
("error .*connecting to master"),
("error reading log entry"),
("lower_case_table_names is set"),
("skip-name-resolve mode"),
("slave SQL thread aborted"),
("Slave: .*Duplicate entry"),
/*
Special case, made as specific as possible, for:
Bug #28436: Incorrect position in SHOW BINLOG EVENTS causes
server coredump
*/
("Error in Log_event::read_log_event\\\(\\\): 'Sanity check failed', data_len: 258, event_type: 49"),
("Statement is not safe to log in statement format"),
/* test case for Bug#bug29807 copies a stray frm into database */
("InnoDB: Error: table `test`.`bug29807` does not exist in the InnoDB internal"),
("Cannot find or open table test\/bug29807 from"),
/* innodb foreign key tests that fail in ALTER or RENAME produce this */
("InnoDB: Error: in ALTER TABLE `test`.`t[12]`"),
("InnoDB: Error: in RENAME TABLE table `test`.`t1`"),
("InnoDB: Error: table `test`.`t[12]` does not exist in the InnoDB internal"),
/* Test case for Bug#14233 produces the following warnings: */
("Stored routine 'test'.'bug14233_1': invalid value in column mysql.proc"),
("Stored routine 'test'.'bug14233_2': invalid value in column mysql.proc"),
("Stored routine 'test'.'bug14233_3': invalid value in column mysql.proc"),
/*
BUG#32080 - Excessive warnings on Solaris: setrlimit could not
change the size of core files
*/
("setrlimit could not change the size of core files to 'infinity'"),
/*
rpl_extrColmaster_*.test, the slave thread produces warnings
when it get updates to a table that has more columns on the
master
*/
("Slave: Unknown column 'c7' in 't15' Error_code: 1054"),
("Slave: Can't DROP 'c7'.* 1091"),
("Slave: Key column 'c6'.* 1072"),
/* Test case for Bug#31590 in order_by.test produces the following error */
("Out of sort memory; increase server sort buffer size"),
/* Special case for Bug #26402 in show_check.test
- Question marks are not valid file name parts on Windows. Ignore
this error message.
*/
("Can't find file: '.\\\\test\\\\\\?{8}.frm'"),
("THE_LAST_SUPPRESSION")||
--
-- Procedure that uses the above created tables to check
-- the servers error log for warnings
--
CREATE DEFINER=root@localhost PROCEDURE check_warnings(OUT result INT)
BEGIN
-- Don't write these queries to binlog
SET SQL_LOG_BIN=0;
--
-- Load the server .err file into "error_log" table
--
CREATE TEMPORARY TABLE error_log (
row INT AUTO_INCREMENT PRIMARY KEY,
line mediumtext NULL
);
SELECT variable_value INTO @log_error
FROM information_schema.global_variables
WHERE variable_name='LOG_ERROR';
SET @@session.max_allowed_packet= 1024*1024*1024;
SET @text= load_file(@log_error);
-- select @text;
WHILE LOCATE('\n', @text) DO
INSERT error_log (line)
VALUES (
SUBSTR(@text, 1, LOCATE('\n', @text)-1)
);
SET @text= SUBSTR(@text FROM LOCATE('\n', @text)+1);
END WHILE;
-- select * from error_log;
--
-- Remove all lines belonging to previous tests
--
SELECT COALESCE(MAX(row),0) INTO @max_row
FROM error_log
WHERE line REGEXP "^CURRENT_TEST:";
DELETE FROM error_log WHERE row < @max_row;
CREATE TEMPORARY TABLE suspect_lines AS
SELECT DISTINCT el.line, 0 as "supressed"
FROM error_log el, suspicious_patterns ep
WHERE el.line REGEXP ep.pattern;
-- Mark lines that are supressed by global supressions
UPDATE suspect_lines sl, global_supressions gs
SET supressed=1
WHERE sl.line REGEXP gs.pattern;
-- Mark lines that are supressed by test specific supressions
UPDATE suspect_lines sl, test_supressions ts
SET supressed=2
WHERE sl.line REGEXP ts.pattern;
SELECT COUNT(*) INTO @num_warnings FROM suspect_lines
WHERE supressed=0;
IF @num_warnings > 0 THEN
SELECT @log_error;
SELECT line as log_error
FROM suspect_lines WHERE supressed=0;
SELECT * FROM test_supressions;
-- Return 2 -> check failed
SELECT 2 INTO result;
ELSE
-- Return 0 -> OK
SELECT 0 INTO RESULT;
END IF;
-- Cleanup for next test
TRUNCATE test_supressions;
END||
--
-- Declare a procedure testcases can use to insert test
-- specific supressions
--
/*!50001
CREATE DEFINER=root@localhost
PROCEDURE add_supression(pattern VARCHAR(255))
BEGIN
INSERT INTO test_supressions (pattern) VALUES (pattern);
END
*/||
......@@ -2,23 +2,21 @@
# By JBM 2006-02-16 So that the code is not repeated #
# in test cases and can be reused. #
######################################################
--exec $NDB_MGM --no-defaults --ndb-connectstring="localhost:$NDBCLUSTER_PORT" -e "start backup" >> $NDB_TOOLS_OUTPUT
--exec $NDB_MGM --no-defaults --ndb-connectstring="$NDB_CONNECTSTRING" -e "start backup" >> $NDB_TOOLS_OUTPUT
# there is no neat way to find the backupid, this is a hack to find it...
let $dump_file= $MYSQLTEST_VARDIR/tmp/tmp.dat;
--exec $NDB_TOOLS_DIR/ndb_select_all --ndb-connectstring="$NDB_CONNECTSTRING" -d sys --delimiter=',' SYSTAB_0 | grep 520093696 > $dump_file
--exec $NDB_TOOLS_DIR/ndb_select_all --ndb-connectstring="localhost:$NDBCLUSTER_PORT" -d sys --delimiter=',' SYSTAB_0 | grep 520093696 > $MYSQLTEST_VARDIR/tmp.dat
CREATE TEMPORARY TABLE test.backup_info (id INT, backup_id INT) ENGINE = HEAP;
CREATE TEMPORARY TABLE IF NOT EXISTS test.backup_info (id INT, backup_id INT) ENGINE = HEAP;
--replace_result $dump_file DUMP_FILE
eval LOAD DATA INFILE '$dump_file' INTO TABLE test.backup_info FIELDS TERMINATED BY ',';
DELETE FROM test.backup_info;
LOAD DATA INFILE '../tmp.dat' INTO TABLE test.backup_info FIELDS TERMINATED BY ',';
--replace_column 1 <the_backup_id>
SELECT @the_backup_id:=backup_id FROM test.backup_info;
# Load backup id into environment variable
let the_backup_id=`SELECT backup_id from test.backup_info`;
DROP TABLE test.backup_info;
let the_backup_id=`select @the_backup_id`;
remove_file $dump_file;
DROP TABLE test.backup_info;
#############################################################
# Author: Serge Kozlov <skozlov@mysql.com>
# Date: 03/17/2008
# Purpose: Set up circular cluster replication where each
# cluster has two mysqlds and replication directions are
# following:
# master ---> slave
# / \
# cluster A cluster B
# \ /
# master1 <--- slave1
#############################################################
--source include/have_log_bin.inc
# Make connections to mysqlds
connect (master,127.0.0.1,root,,test,$MASTER_MYPORT,);
connect (master1,127.0.0.1,root,,test,$MASTER_MYPORT1,);
connect (slave,127.0.0.1,root,,test,$SLAVE_MYPORT,);
connect (slave1,127.0.0.1,root,,test,$SLAVE_MYPORT1,);
# Check that all mysqld compiled with ndb support
--connection master
--disable_query_log
--require r/true.require
SELECT (support = 'YES' or support = 'DEFAULT') AS `TRUE` FROM information_schema.engines WHERE engine = 'ndbcluster';
--source include/ndb_not_readonly.inc
--enable_query_log
--connection master1
--disable_query_log
--require r/true.require
SELECT (support = 'YES' or support = 'DEFAULT') AS `TRUE` FROM information_schema.engines WHERE engine = 'ndbcluster';
--source include/ndb_not_readonly.inc
--enable_query_log
--connection slave
--disable_query_log
--require r/true.require
SELECT (support = 'YES' or support = 'DEFAULT') AS `TRUE` FROM information_schema.engines WHERE engine = 'ndbcluster';
--source include/ndb_not_readonly.inc
--enable_query_log
--connection slave1
--disable_query_log
--require r/true.require
SELECT (support = 'YES' or support = 'DEFAULT') AS `TRUE` FROM information_schema.engines WHERE engine = 'ndbcluster';
--source include/ndb_not_readonly.inc
--enable_query_log
# Stop slaves
--connection master
--disable_warnings
STOP SLAVE;
--wait_for_slave_to_stop
--enable_warnings
--connection master1
--disable_warnings
STOP SLAVE;
--wait_for_slave_to_stop
--enable_warnings
--connection slave
--disable_warnings
STOP SLAVE;
--wait_for_slave_to_stop
--enable_warnings
--connection slave1
--disable_warnings
STOP SLAVE;
--wait_for_slave_to_stop
--enable_warnings
# Reset masters
--connection master
--disable_warnings
--disable_query_log
USE test;
--enable_query_log
DROP TABLE IF EXISTS t1,t2,t3,t4,t5,t6,t7,t8,t9;
--enable_warnings
RESET MASTER;
--connection master1
--disable_warnings
--disable_query_log
USE test;
--enable_query_log
DROP TABLE IF EXISTS t1,t2,t3,t4,t5,t6,t7,t8,t9;
--enable_warnings
RESET MASTER;
--connection slave
--disable_warnings
--disable_query_log
USE test;
--enable_query_log
DROP TABLE IF EXISTS t1,t2,t3,t4,t5,t6,t7,t8,t9;
--enable_warnings
RESET MASTER;
--connection slave1
--disable_warnings
--disable_query_log
USE test;
--enable_query_log
DROP TABLE IF EXISTS t1,t2,t3,t4,t5,t6,t7,t8,t9;
--enable_warnings
RESET MASTER;
# Start slaves
--connection slave
RESET SLAVE;
--replace_result $MASTER_MYPORT MASTER_MYPORT
--eval CHANGE MASTER TO master_host='127.0.0.1',master_port=$MASTER_MYPORT,master_user='root'
START SLAVE;
--source include/wait_for_slave_to_start.inc
--connection master1
RESET SLAVE;
--replace_result $SLAVE_MYPORT1 SLAVE_MYPORT1
--eval CHANGE MASTER TO master_host='127.0.0.1',master_port=$SLAVE_MYPORT1,master_user='root'
START SLAVE;
--source include/wait_for_slave_to_start.inc
# Set the default connection to 'master' (cluster A)
connection master;
......@@ -17,7 +17,7 @@ while ($mysql_errno)
{
if (!$counter)
{
die("Failed while waiting for mysqld to come out of readonly mode");
die Failed while waiting for mysqld to come out of readonly mode;
}
dec $counter;
--sleep 0.1
......
......@@ -3,6 +3,6 @@
# in test cases and can be reused. #
######################################################
--exec $NDB_TOOLS_DIR/ndb_restore --no-defaults --ndb-connectstring="localhost:$NDBCLUSTER_PORT" -p 8 -b $the_backup_id -n 1 -m -r --print --print_meta $NDB_BACKUP_DIR/BACKUP/BACKUP-$the_backup_id >> $NDB_TOOLS_OUTPUT
--exec $NDB_TOOLS_DIR/ndb_restore --no-defaults --ndb-connectstring="$NDB_CONNECTSTRING" -p 8 -b $the_backup_id -n 1 -m -r --print --print_meta $NDB_BACKUP_DIR/BACKUP/BACKUP-$the_backup_id >> $NDB_TOOLS_OUTPUT
--exec $NDB_TOOLS_DIR/ndb_restore --no-defaults --ndb-connectstring="localhost:$NDBCLUSTER_PORT" -p 8 -b $the_backup_id -n 2 -r --print --print_meta $NDB_BACKUP_DIR/BACKUP/BACKUP-$the_backup_id >> $NDB_TOOLS_OUTPUT
--exec $NDB_TOOLS_DIR/ndb_restore --no-defaults --ndb-connectstring="$NDB_CONNECTSTRING" -p 8 -b $the_backup_id -n 2 -r --print --print_meta $NDB_BACKUP_DIR/BACKUP/BACKUP-$the_backup_id >> $NDB_TOOLS_OUTPUT
......@@ -3,9 +3,9 @@
# in test cases and can be reused. #
######################################################
--exec $NDB_TOOLS_DIR/ndb_restore --no-defaults --ndb-connectstring="localhost:$NDBCLUSTER_PORT_SLAVE" -p 8 -b $the_backup_id -n 1 -m -r --print --print_meta $NDB_BACKUP_DIR/BACKUP/BACKUP-$the_backup_id >> $NDB_TOOLS_OUTPUT
--exec $NDB_TOOLS_DIR/ndb_restore --no-defaults --ndb-connectstring="$NDB_CONNECTSTRING_SLAVE" -p 8 -b $the_backup_id -n 1 -m -r --print --print_meta $NDB_BACKUP_DIR/BACKUP/BACKUP-$the_backup_id >> $NDB_TOOLS_OUTPUT
--exec $NDB_TOOLS_DIR/ndb_restore --no-defaults --ndb-connectstring="localhost:$NDBCLUSTER_PORT_SLAVE" -p 8 -b $the_backup_id -n 2 -r -e --print --print_meta $NDB_BACKUP_DIR/BACKUP/BACKUP-$the_backup_id >> $NDB_TOOLS_OUTPUT
--exec $NDB_TOOLS_DIR/ndb_restore --no-defaults --ndb-connectstring="$NDB_CONNECTSTRING_SLAVE" -p 8 -b $the_backup_id -n 2 -r -e --print --print_meta $NDB_BACKUP_DIR/BACKUP/BACKUP-$the_backup_id >> $NDB_TOOLS_OUTPUT
--echo **** Resetting master and slave ****
connection slave;
STOP SLAVE;
source include/wait_for_slave_to_stop.inc;
source include/stop_slave.inc;
RESET SLAVE;
connection master;
RESET MASTER;
connection slave;
START SLAVE;
source include/wait_for_slave_to_start.inc;
source include/start_slave.inc;
# Write file to make mysql-test-run.pl expect crash and restart
--write_file $MYSQLTEST_VARDIR/tmp/mysqld.1.expect
restart
EOF
# Send shutdown to the connected server and give
# it 10 seconds to die before zapping it
shutdown_server 10;
# Turn on reconnect
--enable_reconnect
# Call script that will poll the server waiting for it to be back online again
--source include/wait_until_connected_again.inc
# Turn off reconnect again
--disable_reconnect
......@@ -62,7 +62,9 @@ SELECT db, name, status, originator FROM mysql.event WHERE db = 'test' AND name
DROP EVENT IF EXISTS test.slave_once;
--enable_warnings
CREATE EVENT test.slave_once ON SCHEDULE EVERY 5 MINUTE DO
# Create an event on slave and check its state. An event shouldn't be executed
# so set start time in 1 hour.
CREATE EVENT test.slave_once ON SCHEDULE EVERY 5 MINUTE STARTS CURRENT_TIMESTAMP + INTERVAL 1 HOUR DO
INSERT IGNORE INTO t1(id, c) VALUES (3, 'from slave_once');
--echo "Checking event status on the slave for originator value = slave's server_id"
......@@ -81,8 +83,11 @@ connection master;
DROP EVENT IF EXISTS test.justonce;
--enable_warnings
# Create an event on master and check its state on slave. An event shouldn't be executed
# so set start time in 1 hour. Check that changes of event statement replicated to slave
--echo "Creating event test.er on the master"
CREATE EVENT test.er ON SCHEDULE EVERY 3 SECOND DO
CREATE EVENT test.er ON SCHEDULE EVERY 3 SECOND STARTS CURRENT_TIMESTAMP + INTERVAL 1 HOUR DO
INSERT IGNORE INTO t1(id, c) VALUES (4, 'from er');
--echo "Checking event status on the master"
......@@ -95,7 +100,7 @@ SELECT db, name, status, originator, body FROM mysql.event WHERE db = 'test' AND
connection master;
--echo "Altering event test.er on the master"
ALTER EVENT test.er ON SCHEDULE EVERY 5 SECOND DO
ALTER EVENT test.er ON SCHEDULE EVERY 5 SECOND STARTS CURRENT_TIMESTAMP + INTERVAL 1 HOUR DO
INSERT IGNORE INTO t1(id, c) VALUES (5, 'from alter er');
--echo "Checking event status on the master"
......@@ -123,8 +128,11 @@ SELECT db, name, status, originator FROM mysql.event WHERE db = 'test';
# test the DISABLE ON SLAVE for setting event SLAVESIDE_DISABLED as status
# on CREATE EVENT
# Create an event on slave and check its status. An event shouldn't be executed
# so set start time in 1 hour.
--echo "Creating event test.slave_terminate on the slave"
CREATE EVENT test.slave_terminate ON SCHEDULE EVERY 3 SECOND DO
CREATE EVENT test.slave_terminate ON SCHEDULE EVERY 3 SECOND STARTS CURRENT_TIMESTAMP + INTERVAL 1 HOUR DO
INSERT IGNORE INTO t1(id, c) VALUES (6, 'from slave_terminate');
--echo "Checking event status on the slave"
......
# ==== Purpose ====
#
# Issues START SLAVE on the current connection. Then waits until both
# the IO and SQL threads have started, or until a timeout is reached.
#
# Please use this instead of 'START SLAVE', to reduce the risk of test
# case bugs.
#
# ==== Usage ====
#
# source include/wait_for_slave_to_start.inc;
#
# Parameters to this macro are $slave_timeout and
# $slave_keep_connection. See wait_for_slave_param.inc for
# descriptions.
--disable_query_log
START SLAVE;
--enable_query_log
--echo include/start_slave.inc
source include/wait_for_slave_to_start.inc;
# ==== Purpose ====
#
# Issues STOP SLAVE on the current connection. Then waits until both
# the IO and SQL threads have stopped, or until a timeout is reached.
#
# Please use this instead of 'STOP SLAVE', to reduce the risk of test
# case bugs.
#
# ==== Usage ====
#
# source include/wait_for_slave_to_start.inc;
#
# Parameters to this macro are $slave_timeout and
# $slave_keep_connection. See wait_for_slave_param.inc for
# descriptions.
--disable_query_log
STOP SLAVE;
--enable_query_log
--echo include/stop_slave.inc
source include/wait_for_slave_to_stop.inc;
# ==== Purpose ====
#
# Waits until the slave IO thread has been synced, i.e., all events
# have been copied over to slave. Does not care if the SQL thread is
# in sync.
#
#
# ==== Usage ====
#
# source include/sync_slave_io_with_master.inc;
#
# Syncs to the current position on master, as found by SHOW MASTER
# STATUS.
#
# Must be called on the master. Will change connection to the slave.
#
# Parameters to this macro are $slave_timeout and
# $slave_keep_connection. See wait_for_slave_param.inc for
# descriptions.
let $_master_file= query_get_value("SHOW MASTER STATUS", File, 1);
let $_master_pos= query_get_value("SHOW MASTER STATUS", Position, 1);
connection slave;
let $slave_error_message= Failed while waiting for slave IO thread to sync;
let $slave_param= Master_Log_File;
let $slave_param_value= $_master_file;
source include/wait_for_slave_param.inc;
let $slave_param= Read_Master_Log_Pos;
let $slave_param_value= $_master_pos;
source include/wait_for_slave_param.inc;
let $slave_error_message= ;
......@@ -19,12 +19,6 @@
# #
###################################################################
--disable_query_log
eval set @USE_RUNNING_SERVER= '$USE_RUNNING_SERVER';
--require r/testdb_only.require
SELECT 'use extern server'
AS "Variable_name ",
IF(@USE_RUNNING_SERVER= '1','YES',
IF(@USE_RUNNING_SERVER= '0','NO','UNEXPECTED'))
AS "Value" ;
--enable_query_log
if ($USE_RUNNING_SERVER){
skip Not with extern server;
}
# ==== Purpose ====
#
# Waits until the IO thread of the current connection has started and
# connected to the master (i.e., until SHOW SLAVE STATUS returns Yes
# in the Slave_IO_Running field), or until a timeout is reached.
#
# ==== Usage ====
#
# source include/wait_for_slave_io_to_start.inc;
#
# Parameters to this macro are $slave_timeout and
# $slave_keep_connection. See wait_for_slave_param.inc for
# descriptions.
let $slave_param= Slave_IO_Running;
let $slave_param_value= Yes;
let $slave_error_message= Failed while waiting for slave IO thread to start;
source include/wait_for_slave_param.inc;
let $slave_error_message= ;
###################################################
#Author: Jeb
#Date: 2007-06-11
#Purpose: used for io errors on the slave. If Slave gets an io
# error, the io trhead should stop
#Details:
# 1) Fill in and setup variables
# 2) loop through looking for
# sql threads to stop
# 3) If loops too long die.
####################################################
connection slave;
let $my_show= SHOW SLAVE STATUS;
let $sql_running= Slave_IO_Running;
let $row_number= 1;
let $run= 1;
let $counter= 300;
while ($run)
{
let $io_result= query_get_value("SHOW SLAVE STATUS", Slave_IO_Running, $row_number);
if (`SELECT '$io_result' = 'No'`){
let $run= 0;
}
sleep 0.1;
if (!$counter){
--echo "Failed while waiting for slave IO thread to stop"
query_vertical SHOW SLAVE STATUS;
exit;
}
dec $counter;
}
# ==== Purpose ====
#
# Waits until the IO thread of the current connection has stopped, or
# until a timeout is reached.
#
# ==== Usage ====
#
# source include/wait_for_slave_io_to_stop.inc;
#
# Parameters to this macro are $slave_timeout and
# $slave_keep_connection. See wait_for_slave_param.inc for
# descriptions.
let $slave_param= Slave_IO_Running;
let $slave_param_value= No;
let $slave_error_message= Failed while waiting for slave IO thread to stop;
source include/wait_for_slave_param.inc;
let $slave_error_message= ;
# include/wait_for_slave_param.inc
# ==== Purpose ====
#
# SUMMARY
# Waits until SHOW SLAVE STATUS has returned a specified value, or
# until a timeout is reached.
#
# Waits until SHOW SLAVE STATUS has returned a spicified value.
# ==== Usage ====
#
# USAGE
# let $slave_param= Slave_SQL_Running;
# let $slave_param_value= No;
# --source include/slave_wait_param.inc
#
# let $slave_param= Slave_SQL_Running;
# let $slave_param_value= No;
# --source include/slave_wait_param.inc
# Parameters:
#
# $slave_param, $slave_param_value
# This macro will wait until the column of the output of SHOW SLAVE
# STATUS named $slave_param gets the value $slave_param_value. See
# the example above.
#
# $slave_param_comparison
# By default, this file waits until $slave_param becomes equal to
# $slave_param_value. If you want to wait until $slave_param
# becomes *unequal* to $slave_param_value, set this parameter to the
# string '!=', like this:
# let $slave_param_comparison= !=;
#
# $slave_timeout
# The default timeout is 5 minutes. You can change the timeout by
# setting $slave_timeout. The unit is tenths of seconds.
#
# $slave_keep_connection
# If the timeout is reached, debug info is given by calling SHOW
# SLAVE STATUS, SHOW PROCESSLIST, and SHOW BINLOG EVENTS. By
# default (assuming the current connection is slave), a 'connection
# master' is then issued, and the same information is printed again
# on the master host. You can avoid switching to master (and thus
# suppress debug info on master too) by setting
# $slave_keep_connection to 1.
#
# $slave_error_message
# If set, this is printed when a timeout occurs. This is primarily
# intended to be used by other wait_for_slave_* macros, to indicate
# what the purpose of the wait was. (A very similar error message is
# given by default, but the wait_for_slave_* macros use this to give
# an error message identical to that in previous versions, so that
# errors are easier searchable in the pushbuild history.)
let $_slave_timeout_counter= $slave_timeout;
if (!$_slave_timeout_counter)
{
let $_slave_timeout_counter= 3000;
}
let $_slave_param_comparison= $slave_param_comparison;
if (`SELECT '$_slave_param_comparison' = ''`)
{
let $_slave_param_comparison= =;
}
let $slave_wait_param_counter= 300;
let $slave_value= query_get_value("SHOW SLAVE STATUS", $slave_param, 1);
while (`select "$slave_value" != "$slave_param_value"`)
let $_show_slave_status_value= query_get_value("SHOW SLAVE STATUS", $slave_param, 1);
while (`SELECT NOT('$_show_slave_status_value' $_slave_param_comparison '$slave_param_value')`)
{
dec $slave_wait_param_counter;
if (!$slave_wait_param_counter)
if (!$_slave_timeout_counter)
{
--echo ERROR: failed while waiting for slave parameter $slave_param: $slave_param_value
query_vertical show slave status;
--echo **** ERROR: failed while waiting for slave parameter $slave_param $_slave_param_comparison $slave_param_value ****
if (`SELECT '$slave_error_message' != ''`)
{
--echo Message: $slave_error_message
}
--echo Note: the following output may have changed since the failure was detected
--echo **** Showing SLAVE STATUS, PROCESSLIST, and BINLOG EVENTS on slave ****
query_vertical SHOW SLAVE STATUS;
SHOW PROCESSLIST;
let $binlog_name= query_get_value("SHOW MASTER STATUS", File, 1);
eval SHOW BINLOG EVENTS IN '$binlog_name';
if (!$slave_keep_connection) {
let $master_binlog_name_io= query_get_value("SHOW SLAVE STATUS", Master_Log_File, 1);
let $master_binlog_name_sql= query_get_value("SHOW SLAVE STATUS", Relay_Master_Log_File, 1);
--echo **** Showing MASTER STATUS, PROCESSLIST, and BINLOG EVENTS on master ****
--echo [on master]
connection master;
query_vertical SHOW MASTER STATUS;
SHOW PROCESSLIST;
eval SHOW BINLOG EVENTS IN '$master_binlog_name_sql';
if (`SELECT '$master_binlog_name_io' != '$master_binlog_name_sql'`)
{
eval SHOW BINLOG EVENTS IN '$master_binlog_name_io';
}
}
exit;
}
dec $_slave_timeout_counter;
sleep 0.1;
let $slave_value= query_get_value("SHOW SLAVE STATUS", $slave_param, 1);
let $_show_slave_status_value= query_get_value("SHOW SLAVE STATUS", $slave_param, 1);
}
###################################################
#Author: Sven
#Date: 2007-10-09
#Purpose: Wait until the slave has an error in the
# sql thread, as indicated by
# "SHOW SLAVE STATUS", or at most 30
# seconds.
#Details:
# 1) Fill in and setup variables
# 2) loop, looking for sql error on slave
# 3) If it loops too long, die.
####################################################
connection slave;
let $row_number= 1;
let $run= 1;
let $counter= 300;
# ==== Purpose ====
#
# Waits until the SQL thread of the current connection has got an
# error, or until a timeout is reached.
#
# ==== Usage ====
#
# source include/wait_for_slave_sql_error.inc;
#
# Parameters to this macro are $slave_timeout and
# $slave_keep_connection. See wait_for_slave_param.inc for
# descriptions.
while ($run)
{
let $sql_result= query_get_value("SHOW SLAVE STATUS", Last_SQL_Errno, $row_number);
let $run= `SELECT '$sql_result' = '0'`;
if ($run) {
real_sleep 0.1;
if (!$counter){
--echo "Failed while waiting for slave to produce an error in its sql thread"
--replace_result $MASTER_MYPORT MASTER_PORT
--replace_column 1 # 7 # 8 # 9 # 22 # 23 # 33 #
query_vertical SHOW SLAVE STATUS;
exit;
}
dec $counter;
}
}
let $old_slave_param_comparison= $slave_param_comparison;
let $slave_param= Last_SQL_Errno;
let $slave_param_comparison= !=;
let $slave_param_value= 0;
let $slave_error_message= Failed while waiting for slave to produce an error in its sql thread;
source include/wait_for_slave_param.inc;
let $slave_error_message= ;
let $slave_param_comparison= $old_slave_param_comparison;
###################################################
#Author: Mats (based on file written by Jeb)
#Date: 2008-05-06
#Purpose: To wait for slave SQL thread to start
#Details:
# 1) Fill in and setup variables
# 2) loop through looking for both
# io and sql threads to start
# 3) If loops too long die.
####################################################
connection slave;
let $row_number= 1;
let $run= 1;
let $counter= 300;
while ($run)
{
let $sql_result= query_get_value("SHOW SLAVE STATUS", Slave_SQL_Running, $row_number);
if (`SELECT '$sql_result' = 'Yes'`){
let $run= 0;
}
sleep 0.1;
if (!$counter){
--echo "Failed while waiting for slave SQL to start"
query_vertical SHOW SLAVE STATUS;
exit;
}
dec $counter;
}
# ==== Purpose ====
#
# Waits the SQL thread of the current connection has started, or until
# a timeout is reached.
#
# ==== Usage ====
#
# source include/wait_for_slave_sql_to_start.inc;
#
# Parameters to this macro are $slave_timeout and
# $slave_keep_connection. See wait_for_slave_param.inc for
# descriptions.
let $slave_param= Slave_SQL_Running;
let $slave_param_value= Yes;
let $slave_error_message= Failed while waiting for slave SQL to start;
source include/wait_for_slave_param.inc;
###################################################
#Author: Jeb
#Date: 2007-06-11
#Purpose: used for SQL errors on the slave. If Slave gets a sql
# error, the SQL trhead should stop
#Details:
# 1) Fill in and setup variables
# 2) loop through looking for
# sql threads to stop
# 3) If loops too long die.
####################################################
if (!$keep_connection)
{
connection slave;
}
let $row_number= 1;
let $run= 1;
let $counter= 300;
# ==== Purpose ====
#
# Waits the SQL thread of the current connection has stopped, or until
# a timeout is reached.
#
# ==== Usage ====
#
# source include/wait_for_slave_sql_to_stop.inc;
#
# Parameters to this macro are $slave_timeout and
# $slave_keep_connection. See wait_for_slave_param.inc for
# descriptions.
while ($run)
{
let $sql_result= query_get_value("SHOW SLAVE STATUS", Slave_SQL_Running, $row_number);
if (`SELECT '$sql_result' = 'No'`){
let $run= 0;
}
sleep 0.1;
if (!$counter){
--echo "Failed while waiting for slave SQL thread to stop"
query_vertical SHOW SLAVE STATUS;
exit;
}
dec $counter;
}
let $slave_param= Slave_SQL_Running;
let $slave_param_value= No;
let $slave_error_message= Failed while waiting for slave SQL thread to stop;
source include/wait_for_slave_param.inc;
let $slave_error_message= ;
###################################################
#Author: Jeb
#Date: 2007-06-11
#Purpose: To wait a brief time for slave to start
#Details:
# 1) Fill in and setup variables
# 2) loop through looking for both
# io and sql threads to start
# 3) If loops too long die.
####################################################
connection slave;
let $row_number= 1;
let $run= 1;
let $counter= 300;
# ==== Purpose ====
#
# Waits until both the IO and SQL threads of the current connection
# have started, or until a timeout is reached.
#
# ==== Usage ====
#
# source include/wait_for_slave_to_start.inc;
#
# Parameters to this macro are $slave_timeout and
# $slave_keep_connection. See wait_for_slave_param.inc for
# descriptions.
while ($run)
{
let $io_result= query_get_value("SHOW SLAVE STATUS", Slave_IO_Running, $row_number);
if (`SELECT '$io_result' = 'Yes'`){
let $slave_error_message= Failed while waiting for slave to start;
let $sql_result= query_get_value("SHOW SLAVE STATUS", Slave_SQL_Running, $row_number);
if (`SELECT '$sql_result' = 'Yes'`){
let $run= 0;
}
}
sleep 0.1;
if (!$counter){
--echo "Failed while waiting for slave to start"
query_vertical SHOW SLAVE STATUS;
exit;
}
dec $counter;
}
let $slave_param= Slave_IO_Running;
let $slave_param_value= Yes;
source include/wait_for_slave_param.inc;
let $slave_param= Slave_SQL_Running;
let $slave_param_value= Yes;
source include/wait_for_slave_param.inc;
let $slave_error_message= ;
###################################################
#Author: Jeb
#Date: 2007-06-11
#Purpose: To replace the mysqltest.c executable
# wait_for_slave_to_stop function and
# return this to the test language.
#Details:
# 1) Fill in and setup variables
# 2) loop through looking for both
# io and sql threads to stop
# 3) If loops too long die.
####################################################
connection slave;
let $row_number= 1;
let $run= 1;
let $counter= 300;
# ==== Purpose ====
#
# Waits until both the IO and SQL threads of the current connection
# have stopped, or until a timeout is reached.
#
# ==== Usage ====
#
# source include/wait_for_slave_to_stop.inc;
#
# Parameters to this macro are $slave_timeout and
# $slave_keep_connection. See wait_for_slave_param.inc for
# descriptions.
while ($run)
{
let $io_result= query_get_value("SHOW SLAVE STATUS", Slave_IO_Running, $row_number);
if (`SELECT '$io_result' = 'No'`){
let $slave_error_message= Failed while waiting for slave to stop;
let $sql_result= query_get_value("SHOW SLAVE STATUS", Slave_SQL_Running, $row_number);
if (`SELECT '$sql_result' = 'No'`){
let $run= 0;
}
}
sleep 0.1;
if (!$counter){
--echo "Failed while waiting for slave to stop"
--replace_result $MASTER_MYPORT MASTER_PORT
--replace_column 1 # 7 # 8 # 9 # 22 # 23 # 33 #
query_vertical SHOW SLAVE STATUS;
exit;
}
dec $counter;
}
let $slave_param= Slave_IO_Running;
let $slave_param_value= No;
source include/wait_for_slave_param.inc;
let $slave_param= Slave_SQL_Running;
let $slave_param_value= No;
source include/wait_for_slave_param.inc;
let $slave_error_message= ;
# include/wait_show_pattern.inc
#
# SUMMARY
#
# Waits until output produced by SHOW statement which particular type is
# specified as parameter matches certain pattern or maximum time reached.
#
# NOTES
#
# Only the first row produced by the parameter statement is checked.
#
# USAGE
#
# let $show_type= <Tail of SHOW statement>;
# let $show_pattern= 'Pattern to be used for LIKE matching';
# --source wait_show_pattern.inc
#
# EXAMPLES
#
# alter_table-big.test, wait_slave_status.inc
#
# SEE ALSO
#
# wait_slave_status.inc, wait_condition.inc (>=5.1)
#
###############################################################################
--disable_query_log
# We accept to wait maximum 30 seconds (0.2 sec/loop).
let $wait_counter= 150;
while ($wait_counter)
{
let $result= `SHOW $show_type`;
let $success= `SELECT '$result' LIKE $show_pattern`;
if ($success)
{
let $wait_counter= 0;
}
if (!$success)
{
real_sleep 0.2;
dec $wait_counter;
}
}
if (!$success)
{
echo Timeout in wait_show_pattern.inc \$show_type= $show_type \$show_pattern= $show_pattern (\$result= '$result');
}
--enable_query_log
# include/wait_slave_status.inc
#
# Created by Matthias Leich
#
# SUMMARY
#
# Waits until slave has reached certain state or maximum time reached.
#
# (This script will not work, when the SHOW command delivers more than one
# result record, because only the first record will be caught.)
#
# USAGE
#
# Set $result_pattern in test file and source this file:
#
# let $result_pattern= <pattern used for LIKE on the result of
# SHOW STATUS SLAVE>
# --include wait_slave_status.inc
#
# EXAMPLE
#
# The script rpl_until.test:
# ...
# --replace_result $MASTER_MYPORT MASTER_MYPORT
# --replace_column 1 # 9 # 23 # 33 #
# --vertical_results show slave status;
#
# outputs
# show slave status;
# Slave_IO_State #
# Master_Host 127.0.0.1
# Master_User root
# Master_Port MASTER_MYPORT
# Connect_Retry 1
# Master_Log_File master-bin.000001
# Read_Master_Log_Pos 776
# Relay_Log_File slave-relay-bin.000004
# Relay_Log_Pos #
# Relay_Master_Log_File master-bin.000001
# Slave_IO_Running Yes
# Slave_SQL_Running No
# Replicate_Do_DB
# Replicate_Ignore_DB
# Replicate_Do_Table
# Replicate_Ignore_Table
# Replicate_Wild_Do_Table
# Replicate_Wild_Ignore_Table
# Last_Errno 0
# Last_Error
# Skip_Counter 0
# Exec_Master_Log_Pos 319
# Relay_Log_Space #
# Until_Condition Master
# Until_Log_File master-bin.000001
# Until_Log_Pos 319
# Master_SSL_Allowed No
# Master_SSL_CA_File
# Master_SSL_CA_Path
# Master_SSL_Cert
# Master_SSL_Cipher
# Master_SSL_Key
# Seconds_Behind_Master #
#
# The main problem with the "show slave status;" in rpl_until is, that
# depending on the total test engine power and the current load caused by
# other processes, the expected slave status might be not reached though
# it will happen in maybe some seconds.
#
# The typical problem with rpl_until is that Slave_IO_Running is "No"
# instead of "Yes".
#
# The expected result follows the LIKE pattern:
#
# let $result_pattern= '%127.0.0.1%root%1%master-bin.000001%776%slave-relay-bin.000004%master-bin.000001%Yes%No%0%0%319%Master%master-bin.000001%319%No%';
#
# The Slave_IO_Running value is the "Yes" just after the "master-bin.000001".
#
# How to get this pattern ?
#
# Any lines "--replace_result ..." and "--replace_colum ..." just before
# the SHOW TABLE STATUS and of course the expected result itself
# show us columns where the content must be unified, because it is non
# deterministic or it depends on the current test environment.
#
# Unfortunately "--replace_result ..." and "--replace_colum ..." do not
# affect the result of our assignment let $my_val= `SHOW SLAVE STATUS`;
# Therefore such content must be covered by '%'.
#
# Please be careful. A more simple pattern might be dangerous, because we
# might get "wrong" matches. Example: There might be several "Yes" and "No"
# within one result row.
#
###############################################################################
# We do not want to print the auxiliary commands, because they are not of
# interest and their amount will vary depending how fast we get the
# desired state.
--disable_query_log
# The protocol should show
# - the setting of $result_pattern and
# - that this file is sourced ,
# because this increases the chance to use the protocol as replay script.
eval SELECT "let \$result_pattern= $result_pattern ;" AS "";
SELECT '--source include/wait_slave_status.inc' AS "";
let $show_type= SLAVE STATUS;
let $show_pattern= $result_pattern;
--enable_query_log
--source include/wait_show_pattern.inc
if (!$success)
{
let $message= ! Attention: Timeout in wait_slave_status.inc.
| Possible reasons with decreasing probability:
| - The LIKE pattern is wrong, because the
| testcase was altered or the layout of the
| SHOW SLAVE STATUS result set changed.
| - There is a new bug within the replication.
| - We met an extreme testing environment and timeout is
| too small.;
--source include/show_msg80.inc
--echo DEBUG INFO START (wait_slave_status.inc):
--echo $result_pattern
--vertical_results
show slave status;
--echo DEBUG INFO END
}
......@@ -4,9 +4,13 @@
--disable_result_log
--disable_query_log
let $counter= 500;
let $mysql_errno= 9999;
while ($mysql_errno)
{
--error 0,2002,2006
# Strangely enough, the server might return "Too many connections"
# while being shutdown, thus 1040 is an "allowed" error
# See BUG#36228
--error 0,1040,1053,2002,2003,2006,2013
show status;
dec $counter;
......
#
# Include this script to wait until the connection to the
# server has been dropped
--disable_result_log
--disable_query_log
let $counter= 500;
let $mysql_errno= 9999;
while (!$mysql_errno)
{
--error 0,1053,2002,2006
show status;
dec $counter;
if (!$counter)
{
--die Server failed to dissapear
}
--sleep 0.1
}
--enable_query_log
--enable_result_log
#!/bin/sh
# Copyright (C) 1997-2006 MySQL AB
#
# 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., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
# This scripts creates the privilege tables db, host, user, tables_priv,
# columns_priv in the mysql database, as well as the func table.
if [ x$1 = x"--bin" ]; then
shift 1
BINARY_DIST=1
bindir=../bin
scriptdir=bin
libexecdir=../libexec
# Check if it's a binary distribution or a 'make install'
if test -x ../libexec/mysqld
then
execdir=../libexec
elif test -x ../../sbin/mysqld # RPM installation
then
execdir=../../sbin
bindir=../../bin
scriptdir=../bin
libexecdir=../../libexec
else
execdir=../bin
fi
fix_bin=mysql-test
else
execdir=../sql
bindir=../client
fix_bin=.
scriptdir=scripts
libexecdir=../libexec
fi
vardir=var
logdir=$vardir/log
if [ x$1 = x"-slave" ]
then
shift 1
data=var/slave-data
else
if [ x$1 = x"-1" ]
then
data=var/master-data1
else
data=var/master-data
fi
fi
ldata=$fix_bin/$data
mdata=$data/mysql
EXTRA_ARG=""
mysqld=
if test -x $execdir/mysqld
then
mysqld=$execdir/mysqld
else
if test ! -x $libexecdir/mysqld
then
echo "mysqld is missing - looked in $execdir and in $libexecdir"
exit 1
else
mysqld=$libexecdir/mysqld
fi
fi
# On IRIX hostname is in /usr/bsd so add this to the path
PATH=$PATH:/usr/bsd
hostname=`hostname` # Install this too in the user table
hostname="$hostname%" # Fix if not fully qualified hostname
#create the directories
[ -d $vardir ] || mkdir $vardir
[ -d $logdir ] || mkdir $logdir
# Create database directories mysql & test
if [ -d $data ] ; then rm -rf $data ; fi
mkdir $data $data/mysql $data/test
#for error messages
if [ x$BINARY_DIST = x1 ] ; then
basedir=..
else
basedir=.
EXTRA_ARG="--windows"
fi
INSTALL_CMD="$scriptdir/mysql_install_db --no-defaults $EXTRA_ARG --basedir=$basedir --datadir=mysql-test/$ldata --srcdir=."
echo "running $INSTALL_CMD"
cd ..
if $INSTALL_CMD
then
exit 0
else
echo "Error executing mysqld --bootstrap"
exit 1
fi
......@@ -4,6 +4,7 @@ package My::Config::Option;
use strict;
use warnings;
use Carp;
sub new {
......@@ -31,7 +32,7 @@ package My::Config::Group;
use strict;
use warnings;
use Carp;
sub new {
my ($class, $group_name)= @_;
......@@ -68,7 +69,7 @@ sub remove {
return undef unless defined $option;
# Remove from the hash
delete($self->{options_by_name}->{$option_name}) or die;
delete($self->{options_by_name}->{$option_name}) or croak;
# Remove from the array
@{$self->{options}}= grep { $_->name ne $option_name } @{$self->{options}};
......@@ -88,6 +89,33 @@ sub name {
return $self->{name};
}
sub suffix {
my ($self)= @_;
# Everything in name from the last .
my @parts= split(/\./, $self->{name});
my $suffix= pop(@parts);
return ".$suffix";
}
sub after {
my ($self, $prefix)= @_;
die unless defined $prefix;
# everything after $prefix
my $name= $self->{name};
if ($name =~ /^\Q$prefix\E(.*)$/)
{
return $1;
}
die "Failed to extract the value after '$prefix' in $name";
}
sub split {
my ($self)= @_;
# Return an array with name parts
return split(/\./, $self->{name});
}
#
# Return a specific option in the group
......@@ -100,23 +128,37 @@ sub option {
#
# Return a specific value for an option in the group
# Return value for an option in the group, fail if it does not exist
#
sub value {
my ($self, $option_name)= @_;
my $option= $self->option($option_name);
die "No option named '$option_name' in this group"
croak "No option named '$option_name' in group '$self->{name}'"
if ! defined($option);
return $option->value();
}
#
# Return value for an option if it exist
#
sub if_exist {
my ($self, $option_name)= @_;
my $option= $self->option($option_name);
return undef if ! defined($option);
return $option->value();
}
package My::Config;
use strict;
use warnings;
use Carp;
use IO::File;
use File::Basename;
......@@ -132,13 +174,13 @@ sub new {
my $self= bless { groups => [] }, $class;
my $F= IO::File->new($path, "<")
or die "Could not open '$path': $!";
or croak "Could not open '$path': $!";
while ( my $line= <$F> ) {
chomp($line);
# [group]
if ( $line =~ /\[(.*)\]/ ) {
if ( $line =~ /^\[(.*)\]/ ) {
# New group found
$group_name= $1;
#print "group: $group_name\n";
......@@ -149,7 +191,7 @@ sub new {
# Magic #! comments
elsif ( $line =~ /^#\!/) {
my $magic= $line;
die "Found magic comment '$magic' outside of group"
croak "Found magic comment '$magic' outside of group"
unless $group_name;
#print "$magic\n";
......@@ -171,8 +213,13 @@ sub new {
# !include <filename>
elsif ( $line =~ /^\!include\s*(.*?)\s*$/ ) {
my $include_file_name= dirname($path)."/".$1;
# Check that the file exists
die "The include file '$include_file_name' does not exist"
# Check that the file exists relative to path of first config file
if (! -f $include_file_name){
# Try to include file relativ to current dir
$include_file_name= $1;
}
croak "The include file '$include_file_name' does not exist"
unless -f $include_file_name;
$self->append(My::Config->new($include_file_name));
......@@ -182,7 +229,7 @@ sub new {
elsif ( $line =~ /^([\@\w-]+)\s*$/ ) {
my $option= $1;
die "Found option '$option' outside of group"
croak "Found option '$option' outside of group"
unless $group_name;
#print "$option\n";
......@@ -194,13 +241,13 @@ sub new {
my $option= $1;
my $value= $2;
die "Found option '$option=$value' outside of group"
croak "Found option '$option=$value' outside of group"
unless $group_name;
#print "$option=$value\n";
$self->insert($group_name, $option, $value);
} else {
die "Unexpected line '$line' found in '$path'";
croak "Unexpected line '$line' found in '$path'";
}
}
......@@ -231,6 +278,7 @@ sub insert {
# Add the option to the group
$group->insert($option, $value, $if_not_exist);
}
return $group;
}
#
......@@ -240,11 +288,11 @@ sub remove {
my ($self, $group_name, $option_name)= @_;
my $group= $self->group($group_name);
die "group '$group_name' does not exist"
croak "group '$group_name' does not exist"
unless defined($group);
$group->remove($option_name) or
die "option '$option_name' does not exist";
croak "option '$option_name' does not exist";
}
......@@ -267,10 +315,10 @@ sub group_exists {
#
sub _group_insert {
my ($self, $group_name)= @_;
caller eq __PACKAGE__ or die;
caller eq __PACKAGE__ or croak;
# Check that group does not already exist
die "Group already exists" if $self->group_exists($group_name);
croak "Group already exists" if $self->group_exists($group_name);
my $group= My::Config::Group->new($group_name);
push(@{$self->{groups}}, $group);
......@@ -354,11 +402,11 @@ sub value {
my ($self, $group_name, $option_name)= @_;
my $group= $self->group($group_name);
die "group '$group_name' does not exist"
croak "group '$group_name' does not exist"
unless defined($group);
my $option= $group->option($option_name);
die "option '$option_name' does not exist"
croak "option '$option_name' does not exist"
unless defined($option);
return $option->value();
......@@ -372,7 +420,7 @@ sub exists {
my ($self, $group_name, $option_name)= @_;
my $group= $self->group($group_name);
die "group '$group_name' does not exist"
croak "group '$group_name' does not exist"
unless defined($group);
my $option= $group->option($option_name);
......@@ -412,11 +460,11 @@ sub stringify {
# Save the config to named file
#
sub save {
my ($self, $path)= @_;
my $F= IO::File->new($path, ">")
or die "Could not open '$path': $!";
print $F $self;
undef $F; # Close the file
my ($self, $path)= @_;
my $F= IO::File->new($path, ">")
or croak "Could not open '$path': $!";
print $F $self;
undef $F; # Close the file
}
1;
This diff is collapsed.
# -*- cperl -*-
package My::File::Path;
use strict;
#
# File::Path::rmtree has a problem with deleting files
# and directories where it hasn't got read permission
#
# Patch this by installing a 'rmtree' function in local
# scope that first chmod all files to 0777 before calling
# the original rmtree function.
#
# This is almost gone in version 1.08 of File::Path -
# but unfortunately some hosts still suffers
# from this also in 1.08
#
use Exporter;
use base "Exporter";
our @EXPORT= qw / rmtree mkpath copytree /;
use File::Find;
use File::Path;
use File::Copy;
use Carp;
no warnings 'redefine';
sub rmtree {
my ($dir)= @_;
#
# chmod all files to 0777 before calling rmtree
#
find( {
no_chdir => 1,
wanted => sub {
chmod(0777, $_)
or warn("couldn't chmod(0777, $_): $!");
}
},
$dir
);
# Call rmtree from File::Path
goto &File::Path::rmtree;
};
sub mkpath {
goto &File::Path::mkpath;
};
sub copytree {
my ($from_dir, $to_dir) = @_;
die "Usage: copytree(<fromdir>, <todir>" unless @_ == 2;
mkpath("$to_dir");
opendir(DIR, "$from_dir")
or croak("Can't find $from_dir$!");
for(readdir(DIR)) {
next if "$_" eq "." or "$_" eq "..";
# Skip SCCS/ directories
next if "$_" eq "SCCS";
if ( -d "$from_dir/$_" )
{
copytree("$from_dir/$_", "$to_dir/$_");
next;
}
copy("$from_dir/$_", "$to_dir/$_");
}
closedir(DIR);
}
1;
# -*- cperl -*-
# Copyright (C) 2004-2006 MySQL AB
#
# 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., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
package My::Find;
#
# Utility functions to find files in a MySQL source or bindist
#
use strict;
use Carp;
use My::Platform;
use base qw(Exporter);
our @EXPORT= qw(my_find_bin my_find_dir NOT_REQUIRED);
our $vs_config_dir;
my $bin_extension= ".exe" if IS_WINDOWS;
# Helper function to be used for fourth parameter to find functions
sub NOT_REQUIRED { return 0; }
#
# my_find_bin - find an executable with "name_1...name_n" in
# paths "path_1...path_n" and return the full path
#
# Example:
# my $mysqld_exe= my_find_bin($basedir.
# ["sql", "bin"],
# ["mysqld", "mysqld-debug"]);
# my $mysql_exe= my_find_bin($basedir,
# ["client", "bin"],
# "mysql");
#
#
# To check if something exists, use the required parameter
# set to 0, the function will return an empty string if the
# binary is not found
# my $mysql_exe= my_find_bin($basedir,
# ["client", "bin"],
# "mysql", 0);
#
# NOTE: The function honours MTR_VS_CONFIG environment variable
#
#
sub my_find_bin {
my ($base, $paths, $names, $required)= @_;
croak "usage: my_find_bin(<base>, <paths>, <names>, [<required>])"
unless @_ == 4 or @_ == 3;
# -------------------------------------------------------
# Find and return the first executable
# -------------------------------------------------------
foreach my $path (my_find_paths($base, $paths, $names, $bin_extension)) {
return $path if ( -x $path or (IS_WINDOWS and -f $path) );
}
if (defined $required and $required == NOT_REQUIRED){
# Return empty string to indicate not found
return "";
}
find_error($base, $paths, $names);
}
#
# my_find_dir - find the first existing directory in one of
# the given paths
#
# Example:
# my $charset_set= my_find_dir($basedir,
# ["mysql/share","sql/share", "share"],
# ["charset"]);
# or
# my $charset_set= my_find_dir($basedir,
# ['client_release', 'client_debug',
# 'client', 'bin']);
#
# NOTE: The function honours MTR_VS_CONFIG environment variable
#
#
sub my_find_dir {
my ($base, $paths, $dirs, $required)= @_;
croak "usage: my_find_dir(<base>, <paths>[, <dirs>])"
unless (@_ == 3 or @_ == 2);
# -------------------------------------------------------
# Find and return the first directory
# -------------------------------------------------------
foreach my $path (my_find_paths($base, $paths, $dirs)) {
return $path if ( -d $path );
}
find_error($base, $paths, $dirs);
}
sub my_find_paths {
my ($base, $paths, $names, $extension)= @_;
# Convert the arguments into two normal arrays to ease
# further mappings
my (@names, @paths);
push(@names, ref $names eq "ARRAY" ? @$names : $names);
push(@paths, ref $paths eq "ARRAY" ? @$paths : $paths);
#print "base: $base\n";
#print "names: @names\n";
#print "paths: @paths\n";
# User can select to look in a special build dir
# which is a subdirectory of any of the paths
my @extra_dirs;
my $build_dir= $vs_config_dir || $ENV{MTR_VS_CONFIG} || $ENV{MTR_BUILD_DIR};
push(@extra_dirs, $build_dir) if defined $build_dir;
if (defined $extension){
# Append extension to names, if name does not already have extension
map { $_.=$extension unless /\.(.*)+$/ } @names;
}
# -------------------------------------------------------
# Windows specific
# -------------------------------------------------------
if (IS_WINDOWS) {
# Add the default extra build dirs unless a specific one has
# already been selected
push(@extra_dirs,
("release",
"relwithdebinfo",
"debug")) if @extra_dirs == 0;
}
#print "extra_build_dir: @extra_dirs\n";
# -------------------------------------------------------
# Build cross product of "paths * extra_build_dirs"
# -------------------------------------------------------
push(@paths, map { my $path= $_;
map { "$path/$_" } @extra_dirs
} @paths);
#print "paths: @paths\n";
# -------------------------------------------------------
# Build cross product of "paths * names"
# -------------------------------------------------------
@paths= map { my $path= $_;
map { "$path/$_" } @names
} @paths;
#print "paths: @paths\n";
# -------------------------------------------------------
# Prepend base to all paths
# -------------------------------------------------------
@paths= map { "$base/$_" } @paths;
#print "paths: @paths\n";
# -------------------------------------------------------
# Glob all paths to expand wildcards
# -------------------------------------------------------
@paths= map { glob("$_") } @paths;
#print "paths: @paths\n";
# -------------------------------------------------------
# Return the list of paths
# -------------------------------------------------------
return @paths;
}
sub commify {
return
(@_ == 0) ? '' :
(@_ == 1) ? $_[0] :
(@_ == 2) ? join(" or ", @_) :
join(", ", @_[0..($#_-1)], "or $_[-1]");
}
sub fnuttify {
return map('\''.$_.'\'', @_);
}
sub find_error {
my ($base, $paths, $names)= @_;
my (@names, @paths);
push(@names, ref $names eq "ARRAY" ? @$names : $names);
push(@paths, ref $paths eq "ARRAY" ? @$paths : $paths);
croak "** ERROR: Could not find ",
commify(fnuttify(@names)), " in ",
commify(fnuttify(my_find_paths($base, $paths, $names))), "\n";
}
1;
# -*- cperl -*-
# Copyright (C) 2004-2006 MySQL AB
#
# 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., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
package My::Options;
#
# Utility functions to work with list of options
#
use strict;
sub same($$) {
my $l1= shift;
my $l2= shift;
return compare($l1,$l2) == 0;
}
sub compare ($$) {
my $l1= shift;
my $l2= shift;
my @l1= @$l1;
my @l2= @$l2;
return -1 if @l1 < @l2;
return 1 if @l1 > @l2;
while ( @l1 ) # Same length
{
my $e1= shift @l1;
my $e2= shift @l2;
my $cmp= ($e1 cmp $e2);
return $cmp if $cmp != 0;
}
return 0; # They are the same
}
sub _split_option {
my ($option)= @_;
if ($option=~ /^--(.*)=(.*)$/){
return ($1, $2);
}
elsif ($option=~ /^--(.*)$/){
return ($1, undef)
}
elsif ($option=~ /^\$(.*)$/){ # $VAR
return ($1, undef)
}
elsif ($option=~ /^(.*)=(.*)$/){
return ($1, $2)
}
elsif ($option=~ /^-O$/){
return (undef, undef);
}
die "Unknown option format '$option'";
}
sub _build_option {
my ($name, $value)= @_;
if ($name =~ /^O, /){
return "-".$name."=".$value;
}
elsif ($value){
return "--".$name."=".$value;
}
return "--".$name;
}
#
# Compare two list of options and return what would need
# to be done to get the server running with the new settings
#
sub diff {
my ($from_opts, $to_opts)= @_;
my %from;
foreach my $from (@$from_opts)
{
my ($opt, $value)= _split_option($from);
next unless defined($opt);
$from{$opt}= $value;
}
#print "from: ", %from, "\n";
my %to;
foreach my $to (@$to_opts)
{
my ($opt, $value)= _split_option($to);
next unless defined($opt);
$to{$opt}= $value;
}
#print "to: ", %to, "\n";
# Remove the ones that are in both lists
foreach my $name (keys %from){
if (exists $to{$name} and $to{$name} eq $from{$name}){
#print "removing '$name' from both lists\n";
delete $to{$name};
delete $from{$name};
}
}
#print "from: ", %from, "\n";
#print "to: ", %to, "\n";
# Add all keys in "to" to result
my @result;
foreach my $name (keys %to){
push(@result, _build_option($name, $to{$name}));
}
# Add all keys in "from" that are not in "to"
# to result as "set to default"
foreach my $name (keys %from){
if (not exists $to{$name}) {
push(@result, _build_option($name, "default"));
}
}
return @result;
}
sub is_set {
my ($opts, $set_opts)= @_;
foreach my $opt (@$opts){
my ($opt_name1, $value1)= _split_option($opt);
foreach my $set_opt (@$set_opts){
my ($opt_name2, $value2)= _split_option($set_opt);
if ($opt_name1 eq $opt_name2){
# Option already set
return 1;
}
}
}
return 0;
}
sub toSQL {
my (@options)= @_;
my @sql;
foreach my $option (@options) {
my ($name, $value)= _split_option($option);
#print "name: $name\n";
#print "value: $value\n";
if ($name =~ /^O, (.*)/){
push(@sql, "SET GLOBAL $1=$value");
}
elsif ($name =~ /^set-variable=(.*)/){
push(@sql, "SET GLOBAL $1=$value");
}
else {
my $sql_name= $name;
$sql_name=~ s/-/_/g;
push(@sql, "SET GLOBAL $sql_name=$value");
}
}
return join("; ", @sql);
}
sub toStr {
my $name= shift;
return "$name: ",
"['", join("', '", @_), "']\n";
}
1;
# -*- cperl -*-
# Copyright (C) 2004-2006 MySQL AB
#
# 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., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
package My::Platform;
use strict;
use base qw(Exporter);
our @EXPORT= qw(IS_CYGWIN IS_WINDOWS IS_WIN32PERL
native_path posix_path mixed_path
check_socket_path_length);
BEGIN {
if ($^O eq "cygwin") {
# Make sure cygpath works
if ((system("cygpath > /dev/null 2>&1") >> 8) != 1){
die "Could not execute 'cygpath': $!";
}
eval 'sub IS_CYGWIN { 1 }';
}
else {
eval 'sub IS_CYGWIN { 0 }';
}
if ($^O eq "MSWin32") {
eval 'sub IS_WIN32PERL { 1 }';
}
else {
eval 'sub IS_WIN32PERL { 0 }';
}
}
BEGIN {
if (IS_CYGWIN or IS_WIN32PERL) {
eval 'sub IS_WINDOWS { 1 }';
}
else {
eval 'sub IS_WINDOWS { 0 }';
}
}
#
# native_path
# Convert from path format used by perl to the underlying
# operating systems format
#
# NOTE
# Used when running windows binaries (that expect windows paths)
# in cygwin perl (that uses unix paths)
#
sub mixed_path {
my ($path)= @_;
if (IS_CYGWIN){
return unless defined $path;
$path= `cygpath -m $path`;
chomp $path;
}
return $path;
}
sub native_path {
my ($path)= @_;
$path=~ s/\//\\/g
if (IS_CYGWIN or IS_WIN32PERL);
return $path;
}
sub posix_path {
my ($path)= @_;
if (IS_CYGWIN){
return unless defined $path;
$path= `cygpath $path`;
chomp $path;
}
return $path;
}
sub check_socket_path_length {
my ($path)= @_;
my $truncated= 0;
return 0 if IS_WINDOWS;
require IO::Socket::UNIX;
my $sock = new IO::Socket::UNIX
(
Local => $path,
Listen => 1,
);
if (!defined $sock){
# Could not create a UNIX domain socket
return 0; # Ok, will not be used by mysqld either
}
if ($path ne $sock->hostpath()){
# Path was truncated
$truncated= 1;
# Output diagnostic messages
print "path: '$path', length: ", length($path) ,"\n";
print "hostpath: '", $sock->hostpath(),
"', length: ", length($sock->hostpath()), "\n";
}
$sock= undef; # Close socket
unlink($path); # Remove the physical file
return $truncated;
}
1;
This diff is collapsed.
This diff is collapsed.
# Copyright (C) 2006 MySQL AB
#
# 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., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
ADD_EXECUTABLE(my_safe_process safe_process_win.cc)
ADD_EXECUTABLE(my_safe_kill safe_kill_win.cc)
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
# -*- cperl -*-
use Test::More qw(no_plan);
use strict;
use_ok ("My::Platform");
use My::Platform;
use File::Temp qw / tempdir /;
my $dir = tempdir( CLEANUP => 1 );
print "Running on Windows\n" if (IS_WINDOWS);
print "Using ActiveState perl\n" if (IS_WIN32PERL);
print "Using cygwin perl\n" if (IS_CYGWIN);
print "dir: '$dir'\n";
print "native: '".native_path($dir)."'\n";
print "mixed: '".mixed_path($dir)."'\n";
print "posix: '".posix_path($dir)."'\n";
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment