summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--client/mysqltest.c9
-rw-r--r--mysql-test/mysql-test-run.sh1
-rw-r--r--mysql-test/r/distinct.result4
-rw-r--r--mysql-test/r/drop_temp_table.result10
-rw-r--r--mysql-test/r/join_outer.result2
-rw-r--r--mysql-test/r/mysqldump.result3
-rw-r--r--mysql-test/r/null_key.result4
-rw-r--r--mysql-test/r/order_by.result6
-rw-r--r--mysql-test/r/rpl_alter.result22
-rw-r--r--mysql-test/r/rpl_loaddata.result4
-rw-r--r--mysql-test/r/rpl_loaddata_rule_m.result7
-rw-r--r--mysql-test/r/rpl_trunc_binlog.result8
-rw-r--r--mysql-test/r/select_safe.result2
-rw-r--r--mysql-test/std_data/trunc_binlog.000001 (renamed from mysql-test/std_data/trunc_binlog.001)bin119 -> 119 bytes
-rw-r--r--mysql-test/t/insert.test10
-rw-r--r--mysql-test/t/mysqlbinlog.test18
-rw-r--r--mysql-test/t/rpl000009.test80
-rw-r--r--mysql-test/t/rpl_alter.test22
-rw-r--r--mysql-test/t/rpl_loaddata_rule_m.test11
-rw-r--r--mysql-test/t/rpl_trunc_binlog.test12
-rw-r--r--sql-common/client.c4
-rw-r--r--sql/item_subselect.cc1
-rw-r--r--sql/repl_failsafe.cc7
-rw-r--r--sql/slave.cc42
-rw-r--r--sql/sql_insert.cc13
25 files changed, 171 insertions, 131 deletions
diff --git a/client/mysqltest.c b/client/mysqltest.c
index 479c368aaa1..6a7f4ab7cac 100644
--- a/client/mysqltest.c
+++ b/client/mysqltest.c
@@ -125,6 +125,7 @@ static int block_stack[BLOCK_STACK_DEPTH];
static int block_ok_stack[BLOCK_STACK_DEPTH];
static uint global_expected_errno[MAX_EXPECTED_ERRORS], global_expected_errors;
+static CHARSET_INFO *charset_info= &my_charset_latin1;
static int embedded_server_arg_count=0;
static char *embedded_server_args[MAX_SERVER_ARGS];
@@ -716,7 +717,7 @@ int do_wait_for_slave_to_stop(struct st_query* q __attribute__((unused)))
MYSQL* mysql = &cur_con->mysql;
for (;;)
{
- MYSQL_RES* res;
+ MYSQL_RES *res;
MYSQL_ROW row;
int done;
LINT_INIT(res);
@@ -770,9 +771,7 @@ int do_server_op(struct st_query* q,const char* op)
if (!*p)
die("Missing server name in server_%s\n",op);
while (*p && !my_isspace(charset_info,*p))
- {
- *com_p++=*p++;
- }
+ *com_p++= *p++;
*com_p++=' ';
com_p=int10_to_str(manager_wait_timeout,com_p,10);
*com_p++ = '\n';
@@ -864,7 +863,7 @@ int do_exec(struct st_query* q)
FILE *res_file;
char *cmd= q->first_argument;
- while (*cmd && isspace(*cmd))
+ while (*cmd && my_isspace(charset_info, *cmd))
cmd++;
if (!*cmd)
die("Missing argument in exec\n");
diff --git a/mysql-test/mysql-test-run.sh b/mysql-test/mysql-test-run.sh
index c4e97d0c92b..b7e39549411 100644
--- a/mysql-test/mysql-test-run.sh
+++ b/mysql-test/mysql-test-run.sh
@@ -437,6 +437,7 @@ if [ x$SOURCE_DIST = x1 ] ; then
MYSQL_BINLOG="$BASEDIR/client/.libs/mysqlbinlog"
else
MYSQL_BINLOG="$BASEDIR/client/mysqlbinlog"
+ fi
if [ -n "$STRACE_CLIENT" ]; then
MYSQL_TEST="strace -o $MYSQL_TEST_DIR/var/log/mysqltest.strace $MYSQL_TEST"
fi
diff --git a/mysql-test/r/distinct.result b/mysql-test/r/distinct.result
index 5e713f59100..d9beed25edf 100644
--- a/mysql-test/r/distinct.result
+++ b/mysql-test/r/distinct.result
@@ -303,9 +303,9 @@ id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t2 index id id 8 NULL 1 Using index; Distinct
1 SIMPLE t3 index id id 8 NULL 1 Using index; Distinct
1 SIMPLE j_lj_t2 index id id 4 NULL 2 Using where; Using index; Distinct
-1 SIMPLE t2_lj index id id 8 NULL 1 Using where; Using index; Distinct
+1 SIMPLE t2_lj ref id id 4 test.j_lj_t2.id 1 Using where; Using index; Distinct
1 SIMPLE j_lj_t3 index id id 4 NULL 2 Using where; Using index; Distinct
-1 SIMPLE t3_lj index id id 8 NULL 1 Using where; Using index; Distinct
+1 SIMPLE t3_lj ref id id 4 test.j_lj_t3.id 1 Using where; Using index; Distinct
SELECT DISTINCT
t1.id
from
diff --git a/mysql-test/r/drop_temp_table.result b/mysql-test/r/drop_temp_table.result
index 6b18b54335d..78efc9d90e2 100644
--- a/mysql-test/r/drop_temp_table.result
+++ b/mysql-test/r/drop_temp_table.result
@@ -10,9 +10,9 @@ get_lock("a",10)
1
show binlog events;
Log_name Pos Event_type Server_id Orig_log_pos Info
-master-bin.001 4 Start 1 4 Server ver: VERSION, Binlog ver: 3
-master-bin.001 79 Query 1 79 use `test`; create database `drop-temp+table-test`
-master-bin.001 152 Query 1 152 use `drop-temp+table-test`; create temporary table `table:name` (a int)
-master-bin.001 246 Query 1 246 use `drop-temp+table-test`; DROP /*!40005 TEMPORARY */ TABLE `drop-temp+table-test`.`table:name`
-master-bin.001 365 Query 1 365 use `drop-temp+table-test`; DO RELEASE_LOCK("a")
+master-bin.000001 4 Start 1 4 Server ver: VERSION, Binlog ver: 3
+master-bin.000001 79 Query 1 79 use `test`; create database `drop-temp+table-test`
+master-bin.000001 152 Query 1 152 use `drop-temp+table-test`; create temporary table `table:name` (a int)
+master-bin.000001 246 Query 1 246 use `drop-temp+table-test`; DROP /*!40005 TEMPORARY */ TABLE `drop-temp+table-test`.`table:name`
+master-bin.000001 365 Query 1 365 use `drop-temp+table-test`; DO RELEASE_LOCK("a")
drop database `drop-temp+table-test`;
diff --git a/mysql-test/r/join_outer.result b/mysql-test/r/join_outer.result
index e852d266664..3a1f68fb6c1 100644
--- a/mysql-test/r/join_outer.result
+++ b/mysql-test/r/join_outer.result
@@ -614,7 +614,7 @@ INSERT INTO t2 VALUES (1,1);
explain SELECT * from t1 left join t2 on t1.id=t2.id where t2.id IS NULL;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 ALL NULL NULL NULL NULL 2
-1 SIMPLE t2 ref id id 4 t1.id 1 Using where; Using index; Not exists
+1 SIMPLE t2 ref id id 4 test.t1.id 1 Using where; Using index; Not exists
SELECT * from t1 left join t2 on t1.id=t2.id where t2.id IS NULL;
id name id idx
2 no NULL NULL
diff --git a/mysql-test/r/mysqldump.result b/mysql-test/r/mysqldump.result
index 085cf2788f9..cf1ef55ca69 100644
--- a/mysql-test/r/mysqldump.result
+++ b/mysql-test/r/mysqldump.result
@@ -4,6 +4,8 @@ INSERT INTO t1 VALUES (1), (2);
<?xml version="1.0"?>
<mysqldump>
<database name="test">
+DROP TABLE IF EXISTS t1;
+LOCK TABLES t1 WRITE;
<table name="t1">
<row>
<field name="a">1</field>
@@ -12,6 +14,7 @@ INSERT INTO t1 VALUES (1), (2);
<field name="a">2</field>
</row>
</table>
+UNLOCK TABLES;
</database>
</mysqldump>
DROP TABLE t1;
diff --git a/mysql-test/r/null_key.result b/mysql-test/r/null_key.result
index 9aaea0d800b..bacd95d852e 100644
--- a/mysql-test/r/null_key.result
+++ b/mysql-test/r/null_key.result
@@ -153,12 +153,12 @@ a b
7 NULL
explain select * from t1 where (a = 7 or a is null) and (b=7 or b is null);
id select_type table type possible_keys key key_len ref rows Extra
-1 SIMPLE t1 range a,b a 10 NULL 3 Using where; Using index
+1 SIMPLE t1 ref_or_null a,b a 5 const 4 Using where; Using index
select * from t1 where (a = 7 or a is null) and (b=7 or b is null);
a b
-NULL 7
7 NULL
7 7
+NULL 7
explain select * from t1 where (a = 7 or a is null) and (a = 7 or a is null);
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 ref_or_null a a 5 const 5 Using where; Using index
diff --git a/mysql-test/r/order_by.result b/mysql-test/r/order_by.result
index 80fe0c266f8..db747e3a7eb 100644
--- a/mysql-test/r/order_by.result
+++ b/mysql-test/r/order_by.result
@@ -470,8 +470,8 @@ id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t3 eq_ref PRIMARY PRIMARY 2 test.t2.uid 1 Using where; Using index
EXPLAIN SELECT t1.gid, t3.uid from t1, t3 where t1.gid = t3.uid order by t1.gid,t3.skr;
id select_type table type possible_keys key key_len ref rows Extra
-1 SIMPLE t1 index PRIMARY PRIMARY 4 NULL 6 Using index
-1 SIMPLE t3 eq_ref PRIMARY PRIMARY 2 test.t1.gid 1 Using where
+1 SIMPLE t3 ALL PRIMARY NULL NULL NULL 6 Using temporary; Using filesort
+1 SIMPLE t1 eq_ref PRIMARY PRIMARY 4 test.t3.uid 1 Using where; Using index
EXPLAIN SELECT t1.gid, t2.sid, t3.uid from t2, t1, t3 where t2.gid = t1.gid and t2.uid = t3.uid order by t3.uid, t1.gid;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 index PRIMARY PRIMARY 4 NULL 6 Using index; Using temporary; Using filesort
@@ -480,7 +480,7 @@ id select_type table type possible_keys key key_len ref rows Extra
EXPLAIN SELECT t1.gid, t3.uid from t1, t3 where t1.gid = t3.uid order by t3.skr,t1.gid;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t3 ALL PRIMARY NULL NULL NULL 6 Using temporary; Using filesort
-1 SIMPLE t1 eq_ref PRIMARY PRIMARY 4 test.t3.uid 1 Using where
+1 SIMPLE t1 eq_ref PRIMARY PRIMARY 4 test.t3.uid 1 Using where; Using index
EXPLAIN SELECT t1.gid, t3.uid from t1, t3 where t1.skr = t3.uid order by t1.gid,t3.skr;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 ALL NULL NULL NULL NULL 6 Using temporary; Using filesort
diff --git a/mysql-test/r/rpl_alter.result b/mysql-test/r/rpl_alter.result
index e7abc3b3b48..6ef5ce3462a 100644
--- a/mysql-test/r/rpl_alter.result
+++ b/mysql-test/r/rpl_alter.result
@@ -4,18 +4,18 @@ reset master;
reset slave;
drop table if exists t1,t2,t3,t4,t5,t6,t7,t8,t9;
start slave;
-drop database if exists test_$1;
-create database test_$1;
-create table test_$1.t1 ( n int);
-alter table test_$1.t1 add m int;
-insert into test_$1.t1 values (1,2);
-create table test_$1.t2 (n int);
-insert into test_$1.t2 values (45);
-rename table test_$1.t2 to test_$1.t3, test_$1.t1 to test_$1.t2;
-select * from test_$1.t2;
+drop database if exists mysqltest;
+create database mysqltest;
+create table mysqltest.t1 ( n int);
+alter table mysqltest.t1 add m int;
+insert into mysqltest.t1 values (1,2);
+create table mysqltest.t2 (n int);
+insert into mysqltest.t2 values (45);
+rename table mysqltest.t2 to mysqltest.t3, mysqltest.t1 to mysqltest.t2;
+select * from mysqltest.t2;
n m
1 2
-select * from test_$1.t3;
+select * from mysqltest.t3;
n
45
-drop database test_$1;
+drop database mysqltest;
diff --git a/mysql-test/r/rpl_loaddata.result b/mysql-test/r/rpl_loaddata.result
index 83968eef14f..2dd5dc5ec08 100644
--- a/mysql-test/r/rpl_loaddata.result
+++ b/mysql-test/r/rpl_loaddata.result
@@ -61,8 +61,8 @@ unique(day));
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;
-Duplicate entry '2003-03-22' for key 1
+ERROR 23000: Duplicate entry '2003-03-22' for key 1
show master status;
File Position Binlog_do_db Binlog_ignore_db
-master-bin.001 491
+master-bin.000001 491
drop table t2;
diff --git a/mysql-test/r/rpl_loaddata_rule_m.result b/mysql-test/r/rpl_loaddata_rule_m.result
index c98b3fb358f..ed0c96bbfe1 100644
--- a/mysql-test/r/rpl_loaddata_rule_m.result
+++ b/mysql-test/r/rpl_loaddata_rule_m.result
@@ -4,11 +4,12 @@ reset master;
reset slave;
drop table if exists t1,t2,t3,t4,t5,t6,t7,t8,t9;
start slave;
+drop database if exists mysqltest;
reset master;
-create database test2;
+create database mysqltest;
create table t1(a int, b int, unique(b));
-use test2;
+use mysqltest;
load data infile '../../std_data/rpl_loaddata.dat' into table test.t1;
show binlog events from 79;
Log_name Pos Event_type Server_id Orig_log_pos Info
-drop database test2;
+drop database mysqltest;
diff --git a/mysql-test/r/rpl_trunc_binlog.result b/mysql-test/r/rpl_trunc_binlog.result
index a006437207a..44d3eeb2ba3 100644
--- a/mysql-test/r/rpl_trunc_binlog.result
+++ b/mysql-test/r/rpl_trunc_binlog.result
@@ -1,14 +1,14 @@
-slave stop;
+stop slave;
drop table if exists t1,t2,t3,t4,t5,t6,t7,t8,t9;
reset master;
reset slave;
drop table if exists t1,t2,t3,t4,t5,t6,t7,t8,t9;
-slave start;
+start slave;
stop slave;
flush logs;
reset slave;
start slave;
show slave status;
-Master_Host Master_User Master_Port Connect_retry Master_Log_File Read_Master_Log_Pos Relay_Log_File Relay_Log_Pos Relay_Master_Log_File Slave_IO_Running Slave_SQL_Running Replicate_do_db Replicate_ignore_db Last_errno Last_error Skip_counter Exec_master_log_pos Relay_log_space
-127.0.0.1 root MASTER_PORT 1 master-bin.002 4 slave-relay-bin.002 161 master-bin.001 Yes No 0 Rolling back unfinished transaction (no COMMIT or ROLLBACK) from relay log. Probably cause is that the master died while writing the transaction to it's binary log. 0 79 317
+Master_Host Master_User Master_Port Connect_retry Master_Log_File Read_Master_Log_Pos Relay_Log_File Relay_Log_Pos Relay_Master_Log_File Slave_IO_Running Slave_SQL_Running Replicate_do_db Replicate_ignore_db Replicate_do_table Replicate_ignore_table Replicate_wild_do_table Replicate_wild_ignore_table Last_errno Last_error Skip_counter Exec_master_log_pos Relay_log_space Until_condition Until_Log_File Until_Log_pos Master_SSL_Allowed Master_SSL_CA_File Master_SSL_CA_Path Master_SSL_Cert Master_SSL_Cipher Master_SSL_Key
+127.0.0.1 root MASTER_PORT 1 master-bin.000002 4 slave-relay-bin.000002 123 master-bin.000001 Yes No 0 Rolling back unfinished transaction (no COMMIT or ROLLBACK) from relay log. Probably cause is that the master died while writing the transaction to it's binary log. 0 79 326 None 0 No
reset master;
diff --git a/mysql-test/r/select_safe.result b/mysql-test/r/select_safe.result
index ea8f2332c3a..6bffdd85aa4 100644
--- a/mysql-test/r/select_safe.result
+++ b/mysql-test/r/select_safe.result
@@ -70,7 +70,7 @@ insert into t1 values (null,"a"),(null,"a"),(null,"a"),(null,"a"),(null,"a"),(nu
explain select STRAIGHT_JOIN * from t1,t1 as t2 where t1.b=t2.b;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 ALL b NULL NULL NULL 21
-1 SIMPLE t2 ref b b 21 t1.b 6 Using where
+1 SIMPLE t2 ref b b 21 test.t1.b 6 Using where
set MAX_SEEKS_FOR_KEY=1;
explain select STRAIGHT_JOIN * from t1,t1 as t2 where t1.b=t2.b;
id select_type table type possible_keys key key_len ref rows Extra
diff --git a/mysql-test/std_data/trunc_binlog.001 b/mysql-test/std_data/trunc_binlog.000001
index 2c2b4ec6ce4..2c2b4ec6ce4 100644
--- a/mysql-test/std_data/trunc_binlog.001
+++ b/mysql-test/std_data/trunc_binlog.000001
Binary files differ
diff --git a/mysql-test/t/insert.test b/mysql-test/t/insert.test
index ae0a87895e1..62d277bfad5 100644
--- a/mysql-test/t/insert.test
+++ b/mysql-test/t/insert.test
@@ -80,10 +80,10 @@ drop table t1,t2;
#
--disable_warnings
-drop database if exists test_$1;
+drop database if exists mysqltest;
--enable_warnings
-create database test_$1;
-use test_$1;
+create database mysqltest;
+use mysqltest;
create table t1 (c int);
-insert into test_$1.t1 set test_$1.t1.c = '1';
-drop database test_$1;
+insert into mysqltest.t1 set mysqltest.t1.c = '1';
+drop database mysqltest;
diff --git a/mysql-test/t/mysqlbinlog.test b/mysql-test/t/mysqlbinlog.test
index 22b63146652..3a24efd9f39 100644
--- a/mysql-test/t/mysqlbinlog.test
+++ b/mysql-test/t/mysqlbinlog.test
@@ -39,28 +39,28 @@ select "--- Local --" as "";
#
--replace_result $MYSQL_TEST_DIR MYSQL_TEST_DIR
---exec $MYSQL_BINLOG --short-form $MYSQL_TEST_DIR/var/log/master-bin.001
+--exec $MYSQL_BINLOG --short-form $MYSQL_TEST_DIR/var/log/master-bin.000001
# this should not fail but shouldn't produce any working statements
--disable_query_log
select "--- Broken LOAD DATA --" as "";
--enable_query_log
--replace_result $MYSQL_TEST_DIR MYSQL_TEST_DIR
---exec $MYSQL_BINLOG --short-form $MYSQL_TEST_DIR/var/log/master-bin.002
+--exec $MYSQL_BINLOG --short-form $MYSQL_TEST_DIR/var/log/master-bin.000002
# this should show almost nothing
--disable_query_log
select "--- --database --" as "";
--enable_query_log
--replace_result $MYSQL_TEST_DIR MYSQL_TEST_DIR
---exec $MYSQL_BINLOG --short-form --database=nottest $MYSQL_TEST_DIR/var/log/master-bin.001
+--exec $MYSQL_BINLOG --short-form --database=nottest $MYSQL_TEST_DIR/var/log/master-bin.000001
# this test for position option
--disable_query_log
select "--- --position --" as "";
--enable_query_log
--replace_result $MYSQL_TEST_DIR MYSQL_TEST_DIR
---exec $MYSQL_BINLOG --short-form --position=27 $MYSQL_TEST_DIR/var/log/master-bin.002
+--exec $MYSQL_BINLOG --short-form --position=27 $MYSQL_TEST_DIR/var/log/master-bin.000002
# These are tests for remote binlog.
# They should return the same as previous test.
@@ -74,30 +74,30 @@ select "--- Remote --" as "";
--enable_query_log
# This is broken now
-# By the way it seems that remote version fetches all events with name >= master-bin.001
+# By the way it seems that remote version fetches all events with name >= master-bin.000001
--replace_result $MYSQL_TEST_DIR MYSQL_TEST_DIR
---exec $MYSQL_BINLOG --short-form --user=root --host=127.0.0.1 --port=$MASTER_MYPORT master-bin.001
+--exec $MYSQL_BINLOG --short-form --read-from-remote-server --user=root --host=127.0.0.1 --port=$MASTER_MYPORT master-bin.000001
# This is broken too
--disable_query_log
select "--- Broken LOAD DATA --" as "";
--enable_query_log
--replace_result $MYSQL_TEST_DIR MYSQL_TEST_DIR
---exec $MYSQL_BINLOG --short-form --user=root --host=127.0.0.1 --port=$MASTER_MYPORT master-bin.002
+--exec $MYSQL_BINLOG --short-form --read-from-remote-server --user=root --host=127.0.0.1 --port=$MASTER_MYPORT master-bin.002
# And this too ! (altough it is documented)
--disable_query_log
select "--- --database --" as "";
--enable_query_log
--replace_result $MYSQL_TEST_DIR MYSQL_TEST_DIR
---exec $MYSQL_BINLOG --short-form --user=root --host=127.0.0.1 --port=$MASTER_MYPORT --database=nottest master-bin.001
+--exec $MYSQL_BINLOG --short-form --read-from-remote-server --user=root --host=127.0.0.1 --port=$MASTER_MYPORT --database=nottest master-bin.000001
# Strangely but this works
--disable_query_log
select "--- --position --" as "";
--enable_query_log
--replace_result $MYSQL_TEST_DIR MYSQL_TEST_DIR
---exec $MYSQL_BINLOG --short-form --position=27 --user=root --host=127.0.0.1 --port=$MASTER_MYPORT master-bin.002
+--exec $MYSQL_BINLOG --short-form --read-from-remote-server --position=27 --user=root --host=127.0.0.1 --port=$MASTER_MYPORT master-bin.002
# clean up
drop table t1;
diff --git a/mysql-test/t/rpl000009.test b/mysql-test/t/rpl000009.test
index 4db62540e7b..cd318efa2b6 100644
--- a/mysql-test/t/rpl000009.test
+++ b/mysql-test/t/rpl000009.test
@@ -3,9 +3,15 @@
source include/master-slave.inc;
--disable_warnings
+drop database if exists mysqltest;
drop database if exists mysqltest2;
-create database mysqltest2;
+drop database if exists mysqltest3;
+connection slave;
drop database if exists mysqltest;
+drop database if exists mysqltest2;
+drop database if exists mysqltest3;
+connection master;
+create database mysqltest2;
create database mysqltest;
--enable_warnings
@@ -60,38 +66,42 @@ sync_with_master;
# This should show that the slave is empty at this point
show databases;
-# Create foo and foo2 on slave; we expect that LOAD DATA FROM MASTER will
-# neither touch database foo nor foo2.
-create database foo;
-create table foo.t1(n int, s char(20));
-insert into foo.t1 values (1, 'original foo.t1');
-create table foo.t3(n int, s char(20));
-insert into foo.t3 values (1, 'original foo.t3');
-create database foo2;
-create table foo2.t1(n int, s char(20));
-insert into foo2.t1 values (1, 'original foo2.t1');
-# Create bar, and bar.t1, to check that it gets replaced,
-# and bar.t3 to check that it is not touched (there is no bar.t3 on master)
-create database bar;
-create table bar.t1(n int, s char(20));
-insert into bar.t1 values (1, 'original bar.t1');
-create table bar.t3(n int, s char(20));
-insert into bar.t3 values (1, 'original bar.t3');
+# Create mysqltest2 and mysqltest3 on slave; we expect that LOAD DATA FROM
+# MASTER will neither touch database mysqltest nor mysqltest3
+create database mysqltest2;
+create table mysqltest2.t1(n int, s char(20));
+insert into mysqltest2.t1 values (1, 'original foo.t1');
+create table mysqltest2.t3(n int, s char(20));
+insert into mysqltest2.t3 values (1, 'original foo.t3');
+create database mysqltest3;
+create table mysqltest3.t1(n int, s char(20));
+insert into mysqltest3.t1 values (1, 'original foo2.t1');
+
+# Create mysqltest, and mysqltest.t1, to check that it gets replaced,
+# and mysqltest.t3 to check that it is not touched (there is no
+# mysqltest.t3 on master)
+create database mysqltest;
+create table mysqltest.t1(n int, s char(20));
+insert into mysqltest.t1 values (1, 'original bar.t1');
+create table mysqltest.t3(n int, s char(20));
+insert into mysqltest.t3 values (1, 'original bar.t3');
load data from master;
# Now let's check if we have the right tables and the right data in them
show databases;
use mysqltest2;
-# LOAD DATA FROM MASTER uses only replicate_*_db rules to decide which databases
-# have to be copied. So it thinks "foo" has to be copied. Before 4.0.16 it would
-# first drop "foo", then create "foo". This "drop" is a bug; in that case t3
-# would disappear.
-# So here the effect of this bug (BUG#1248) would be to leave an empty "foo" on
-# the slave.
+
+# LOAD DATA FROM MASTER uses only replicate_*_db rules to decide which
+# databases have to be copied. So it thinks "mysqltest" has to be
+# copied. Before 4.0.16 it would first drop "mysqltest", then create
+# "mysqltest". This "drop" is a bug; in that case t3 would disappear. So
+# here the effect of this bug (BUG#1248) would be to leave an empty
+# "mysqltest" on the slave.
+
show tables; # should be t1 & t3
select * from t1; # should be slave's original
-use foo2;
+use mysqltest3;
show tables; # should be t1
select * from t1; # should be slave's original
use mysqltest;
@@ -111,19 +121,24 @@ select * from mysqltest.t1;
# Check that LOAD DATA FROM MASTER reports the error if it can't drop a
# table to be overwritten.
# DISABLED FOR NOW AS chmod IS NOT PORTABLE ON NON-UNIX
-# insert into bar.t1 values(10, 'should be there');
+# insert into mysqltest.t1 values(10, 'should be there');
# flush tables;
-# system chmod 500 var/slave-data/bar/;
+# system chmod 500 var/slave-data/mysqltest/;
# --error 6
# load data from master; # should fail (errno 13)
-# system chmod 700 var/slave-data/bar/;
-# select * from bar.t1; # should contain the row (10, ...)
+# system chmod 700 var/slave-data/mysqltest/;
+# select * from mysqltest.t1; # should contain the row (10, ...)
# Check that LOAD TABLE FROM MASTER fails if the table exists on slave
--error 1050
-load table bar.t1 from master;
-drop table bar.t1;
+load table mysqltest.t1 from master;
+drop table mysqltest.t1;
+load table mysqltest.t1 from master;
+
+# Check what happens when requestion not existing table
+#
+--error 1188
load table bar.t1 from master;
# as LOAD DATA FROM MASTER failed it did not restart slave threads
@@ -137,5 +152,6 @@ drop database mysqltest2;
save_master_pos;
connection slave;
sync_with_master;
-drop database mysqltest;
+# These has to be droped on slave as they are not replicated
drop database mysqltest2;
+drop database mysqltest3;
diff --git a/mysql-test/t/rpl_alter.test b/mysql-test/t/rpl_alter.test
index 6b8cf773150..a913f01cd81 100644
--- a/mysql-test/t/rpl_alter.test
+++ b/mysql-test/t/rpl_alter.test
@@ -1,22 +1,22 @@
source include/master-slave.inc;
--disable_warnings
-drop database if exists test_$1;
+drop database if exists mysqltest;
--enable_warnings
-create database test_$1;
+create database mysqltest;
-create table test_$1.t1 ( n int);
-alter table test_$1.t1 add m int;
-insert into test_$1.t1 values (1,2);
-create table test_$1.t2 (n int);
-insert into test_$1.t2 values (45);
-rename table test_$1.t2 to test_$1.t3, test_$1.t1 to test_$1.t2;
+create table mysqltest.t1 ( n int);
+alter table mysqltest.t1 add m int;
+insert into mysqltest.t1 values (1,2);
+create table mysqltest.t2 (n int);
+insert into mysqltest.t2 values (45);
+rename table mysqltest.t2 to mysqltest.t3, mysqltest.t1 to mysqltest.t2;
save_master_pos;
connection slave;
sync_with_master;
-select * from test_$1.t2;
-select * from test_$1.t3;
+select * from mysqltest.t2;
+select * from mysqltest.t3;
connection master;
-drop database test_$1;
+drop database mysqltest;
save_master_pos;
connection slave;
sync_with_master;
diff --git a/mysql-test/t/rpl_loaddata_rule_m.test b/mysql-test/t/rpl_loaddata_rule_m.test
index 18f295f8ce2..ec3a9259e32 100644
--- a/mysql-test/t/rpl_loaddata_rule_m.test
+++ b/mysql-test/t/rpl_loaddata_rule_m.test
@@ -3,6 +3,11 @@
# This is for BUG#1100 (LOAD DATA INFILE was half-logged).
source include/master-slave.inc;
+
+--disable_warnings
+drop database if exists mysqltest;
+--enable_warnings
+
connection slave;
reset master;
@@ -10,9 +15,9 @@ reset master;
connection master;
# 'test' is the current database
-create database test2;
+create database mysqltest;
create table t1(a int, b int, unique(b));
-use test2;
+use mysqltest;
load data infile '../../std_data/rpl_loaddata.dat' into table test.t1;
show binlog events from 79; # should be nothing
-drop database test2;
+drop database mysqltest;
diff --git a/mysql-test/t/rpl_trunc_binlog.test b/mysql-test/t/rpl_trunc_binlog.test
index efdc3012471..1f224423c97 100644
--- a/mysql-test/t/rpl_trunc_binlog.test
+++ b/mysql-test/t/rpl_trunc_binlog.test
@@ -1,7 +1,7 @@
-# We are testing if a binlog which contains BEGIN but not COMMIT (the master did
-# while writing the transaction to the binlog) triggers an error on slave.
-# So we use such a truncated binlog and simulate that the master restarted after
-# this.
+# We are testing if a binlog which contains BEGIN but not COMMIT (the
+# master did while writing the transaction to the binlog) triggers an
+# error on slave. So we use such a truncated binlog and simulate that
+# the master restarted after this.
source include/master-slave.inc;
@@ -9,8 +9,8 @@ connection slave;
stop slave;
connection master;
flush logs;
-system mv -f var/log/master-bin.001 var/log/master-bin.002;
-system cp std_data/trunc_binlog.001 var/log/master-bin.001;
+system mv -f var/log/master-bin.000001 var/log/master-bin.000002;
+system cp std_data/trunc_binlog.000001 var/log/master-bin.000001;
connection slave;
reset slave;
start slave;
diff --git a/sql-common/client.c b/sql-common/client.c
index cedfac67328..80a5a719376 100644
--- a/sql-common/client.c
+++ b/sql-common/client.c
@@ -1317,10 +1317,6 @@ mysql_init(MYSQL *mysql)
#ifndef TO_BE_DELETED
mysql->rpl_pivot = 1;
#endif
-#if defined(SIGPIPE) && defined(THREAD) && !defined(__WIN__) && !defined(MYSQL_SERVER)
- if (!((mysql)->client_flag & CLIENT_IGNORE_SIGPIPE))
- (void) signal(SIGPIPE,pipe_sig_handler);
-#endif
/*
Only enable LOAD DATA INFILE by default if configured with
diff --git a/sql/item_subselect.cc b/sql/item_subselect.cc
index 3d6fd4c316d..fd024daca08 100644
--- a/sql/item_subselect.cc
+++ b/sql/item_subselect.cc
@@ -1096,7 +1096,6 @@ int subselect_indexsubquery_engine::exec()
/* Check if there exists a row with a null value in the index */
if ((error= (safe_index_read(tab) == 1)))
break;
- }
}
}
}
diff --git a/sql/repl_failsafe.cc b/sql/repl_failsafe.cc
index 2fe8946410f..aba887be070 100644
--- a/sql/repl_failsafe.cc
+++ b/sql/repl_failsafe.cc
@@ -755,6 +755,8 @@ int load_master_data(THD* thd)
int error = 0;
const char* errmsg=0;
int restart_thread_mask;
+ HA_CREATE_INFO create_info;
+
mysql_init(&mysql);
/*
@@ -858,7 +860,10 @@ int load_master_data(THD* thd)
continue;
}
- if (mysql_create_db(thd, db, HA_LEX_CREATE_IF_NOT_EXISTS, 1))
+ bzero((char*) &create_info, sizeof(create_info));
+ create_info.options= HA_LEX_CREATE_IF_NOT_EXISTS;
+
+ if (mysql_create_db(thd, db, &create_info, 1))
{
send_error(thd, 0, 0);
cleanup_mysql_results(db_res, cur_table_res - 1, table_res);
diff --git a/sql/slave.cc b/sql/slave.cc
index a221abec2b5..d1a8fe51f33 100644
--- a/sql/slave.cc
+++ b/sql/slave.cc
@@ -1125,12 +1125,13 @@ static int create_table_from_dump(THD* thd, MYSQL *mysql, const char* db,
handler *file;
ulong save_options;
NET *net= &mysql->net;
-
+ DBUG_ENTER("create_table_from_dump");
+
packet_len= my_net_read(net); // read create table statement
if (packet_len == packet_error)
{
send_error(thd, ER_MASTER_NET_READ);
- return 1;
+ DBUG_RETURN(1);
}
if (net->read_pos[0] == 255) // error from master
{
@@ -1139,7 +1140,7 @@ static int create_table_from_dump(THD* thd, MYSQL *mysql, const char* db,
CLIENT_PROTOCOL_41) ?
3+SQLSTATE_LENGTH+1 : 3);
net_printf(thd, ER_MASTER, err_msg);
- return 1;
+ DBUG_RETURN(1);
}
thd->command = COM_TABLE_DUMP;
thd->query_length= packet_len;
@@ -1148,12 +1149,23 @@ static int create_table_from_dump(THD* thd, MYSQL *mysql, const char* db,
{
sql_print_error("create_table_from_dump: out of memory");
net_printf(thd, ER_GET_ERRNO, "Out of memory");
- return 1;
+ DBUG_RETURN(1);
}
thd->query= query;
thd->query_error = 0;
thd->net.no_send_ok = 1;
+ bzero((char*) &tables,sizeof(tables));
+ tables.db = (char*)db;
+ tables.alias= tables.real_name= (char*)table_name;
+ /* Drop the table if 'overwrite' is true */
+ if (overwrite && mysql_rm_table(thd,&tables,1,0)) /* drop if exists */
+ {
+ send_error(thd);
+ sql_print_error("create_table_from_dump: failed to drop the table");
+ goto err;
+ }
+
/* Create the table. We do not want to log the "create table" statement */
save_options = thd->options;
thd->options &= ~(ulong) (OPTION_BIN_LOG);
@@ -1207,7 +1219,7 @@ static int create_table_from_dump(THD* thd, MYSQL *mysql, const char* db,
err:
close_thread_tables(thd);
thd->net.no_send_ok = 0;
- return error;
+ DBUG_RETURN(error);
}
@@ -3431,15 +3443,15 @@ int queue_event(MASTER_INFO* mi,const char* buf, ulong event_len)
case STOP_EVENT:
/*
We needn't write this event to the relay log. Indeed, it just indicates a
- master server shutdown. The only thing this does is cleaning. But cleaning
- is already done on a per-master-thread basis (as the master server is
- shutting down cleanly, it has written all DROP TEMPORARY TABLE and DO
- RELEASE_LOCK; prepared statements' deletion are TODO).
+ master server shutdown. The only thing this does is cleaning. But
+ cleaning is already done on a per-master-thread basis (as the master
+ server is shutting down cleanly, it has written all DROP TEMPORARY TABLE
+ and DO RELEASE_LOCK; prepared statements' deletion are TODO).
- We don't even increment mi->master_log_pos, because we may be just after a
- Rotate event. Btw, in a few milliseconds we are going to have a Start
- event from the next binlog (unless the master is presently running without
- --log-bin).
+ We don't even increment mi->master_log_pos, because we may be just after
+ a Rotate event. Btw, in a few milliseconds we are going to have a Start
+ event from the next binlog (unless the master is presently running
+ without --log-bin).
*/
goto err;
case ROTATE_EVENT:
@@ -3465,8 +3477,8 @@ int queue_event(MASTER_INFO* mi,const char* buf, ulong event_len)
/*
If this event is originating from this server, don't queue it.
We don't check this for 3.23 events because it's simpler like this; 3.23
- will be filtered anyway by the SQL slave thread which also tests the server
- id (we must also keep this test in the SQL thread, in case somebody
+ will be filtered anyway by the SQL slave thread which also tests the
+ server id (we must also keep this test in the SQL thread, in case somebody
upgrades a 4.0 slave which has a not-filtered relay log).
ANY event coming from ourselves can be ignored: it is obvious for queries;
diff --git a/sql/sql_insert.cc b/sql/sql_insert.cc
index d523d868514..f4127265ce6 100644
--- a/sql/sql_insert.cc
+++ b/sql/sql_insert.cc
@@ -1438,15 +1438,17 @@ bool select_insert::send_data(List<Item> &values)
void select_insert::send_error(uint errcode,const char *err)
{
+ DBUG_ENTER("select_insert::send_error");
+
//TODO error should be sent at the query processing end
::send_error(thd,errcode,err);
table->file->extra(HA_EXTRA_NO_CACHE);
table->file->activate_all_index(thd);
- /*
- If at least one row has been inserted/modified and will stay in the table
- (the table doesn't have transactions) (example: we got a duplicate key
- error while inserting into a MyISAM table) we must write to the binlog (and
- the error code will make the slave stop).
+ /*
+ If at least one row has been inserted/modified and will stay in the table
+ (the table doesn't have transactions) (example: we got a duplicate key
+ error while inserting into a MyISAM table) we must write to the binlog (and
+ the error code will make the slave stop).
*/
if ((info.copied || info.deleted) && !table->file->has_transactions())
{
@@ -1465,6 +1467,7 @@ void select_insert::send_error(uint errcode,const char *err)
if (info.copied || info.deleted)
query_cache_invalidate3(thd, table, 1);
ha_rollback_stmt(thd);
+ DBUG_VOID_RETURN;
}