mariadb/mysql-test/extra/rpl_tests/rpl_row_sp002.test
unknown adaf162bc2 WL#3464: Add replication event to denote gap in replication
Adding an event that can be used to denote that an incident occured
on the master. The event can be used to denote a gap in the replication
stream, but can also be used to denote other incidents.

In addition, the injector interface is extended with functions to
generate an incident event. The function will also rotate the binary
log after generating an incident event to get a fresh binary log.


client/Makefile.am:
  Adding file rpl_constants.h with constants for replication.
mysql-test/extra/binlog_tests/binlog.test:
  Binlog position change
mysql-test/extra/binlog_tests/binlog_insert_delayed.test:
  Binlog position change
mysql-test/extra/binlog_tests/ctype_cp932_binlog.test:
  Binlog position change
mysql-test/extra/binlog_tests/ctype_ucs_binlog.test:
  Binlog position change
mysql-test/extra/binlog_tests/mix_innodb_myisam_binlog.test:
  Binlog position change
mysql-test/extra/rpl_tests/rpl_deadlock.test:
  Binlog position change
mysql-test/extra/rpl_tests/rpl_log.test:
  Binlog position change
mysql-test/extra/rpl_tests/rpl_multi_query.test:
  Binlog position change
mysql-test/extra/rpl_tests/rpl_row_charset.test:
  Binlog position change
mysql-test/extra/rpl_tests/rpl_row_sp002.test:
  Binlog position change
mysql-test/extra/rpl_tests/rpl_row_sp003.test:
  Binlog position change
mysql-test/extra/rpl_tests/rpl_stm_charset.test:
  Binlog position change
mysql-test/include/show_binlog_events.inc:
  Binlog position change
mysql-test/r/binlog_row_binlog.result:
  Result change
mysql-test/r/binlog_row_ctype_ucs.result:
  Result change
mysql-test/r/binlog_row_insert_select.result:
  Result change
mysql-test/r/binlog_row_mix_innodb_myisam.result:
  Result change
mysql-test/r/binlog_stm_binlog.result:
  Result change
mysql-test/r/binlog_stm_ctype_ucs.result:
  Result change
mysql-test/r/binlog_stm_insert_select.result:
  Result change
mysql-test/r/binlog_stm_mix_innodb_myisam.result:
  Result change
mysql-test/r/ctype_cp932_binlog_row.result:
  Result change
mysql-test/r/ctype_cp932_binlog_stm.result:
  Result change
mysql-test/r/flush_block_commit_notembedded.result:
  Result change
mysql-test/r/rpl_000015.result:
  Result change
mysql-test/r/rpl_change_master.result:
  Result change
mysql-test/r/rpl_deadlock_innodb.result:
  Result change
mysql-test/r/rpl_flushlog_loop.result:
  Result change
mysql-test/r/rpl_loaddata.result:
  Result change
mysql-test/r/rpl_loaddata_s.result:
  Result change
mysql-test/r/rpl_log_pos.result:
  Result change
mysql-test/r/rpl_ndb_charset.result:
  Result change
mysql-test/r/rpl_ndb_log.result:
  Result change
mysql-test/r/rpl_ndb_multi.result:
  Result change
mysql-test/r/rpl_rbr_to_sbr.result:
  Result change
mysql-test/r/rpl_rotate_logs.result:
  Result change
mysql-test/r/rpl_row_basic_11bugs.result:
  Result change
mysql-test/r/rpl_row_charset.result:
  Result change
mysql-test/r/rpl_row_create_table.result:
  Result change
mysql-test/r/rpl_row_delayed_ins.result:
  Result change
mysql-test/r/rpl_row_drop.result:
  Result change
mysql-test/r/rpl_row_flsh_tbls.result:
  Result change
mysql-test/r/rpl_row_inexist_tbl.result:
  Result change
mysql-test/r/rpl_row_log.result:
  Result change
mysql-test/r/rpl_row_log_innodb.result:
  Result change
mysql-test/r/rpl_row_max_relay_size.result:
  Result change
mysql-test/r/rpl_row_reset_slave.result:
  Result change
mysql-test/r/rpl_row_until.result:
  Result change
mysql-test/r/rpl_server_id1.result:
  Result change
mysql-test/r/rpl_server_id2.result:
  Result change
mysql-test/r/rpl_sp.result:
  Result change
mysql-test/r/rpl_stm_charset.result:
  Result change
mysql-test/r/rpl_stm_flsh_tbls.result:
  Result change
mysql-test/r/rpl_stm_log.result:
  Result change
mysql-test/r/rpl_stm_max_relay_size.result:
  Result change
mysql-test/r/rpl_stm_multi_query.result:
  Result change
mysql-test/r/rpl_stm_reset_slave.result:
  Result change
mysql-test/r/rpl_stm_until.result:
  Result change
mysql-test/r/rpl_switch_stm_row_mixed.result:
  Result change
mysql-test/r/rpl_truncate_2myisam.result:
  Result change
mysql-test/r/rpl_truncate_3innodb.result:
  Result change
mysql-test/r/rpl_truncate_7ndb.result:
  Result change
mysql-test/r/user_var-binlog.result:
  Result change
mysql-test/t/binlog_row_mix_innodb_myisam.test:
  Binlog position change
mysql-test/t/binlog_stm_mix_innodb_myisam.test:
  Binlog position change
mysql-test/t/ctype_cp932_binlog_stm.test:
  Binlog position change
mysql-test/t/mysqlbinlog.test:
  Binlog position change
mysql-test/t/mysqlbinlog2.test:
  Binlog position change
mysql-test/t/rpl_loaddata_s.test:
  Binlog position change
mysql-test/t/rpl_log_pos.test:
  Binlog position change
mysql-test/t/rpl_row_basic_11bugs.test:
  Binlog position change
mysql-test/t/rpl_row_create_table.test:
  Binlog position change
mysql-test/t/rpl_row_flsh_tbls.test:
  Binlog position change
mysql-test/t/rpl_row_mysqlbinlog.test:
  Binlog position change
mysql-test/t/rpl_sp.test:
  Binlog position change
mysql-test/t/rpl_stm_flsh_tbls.test:
  Binlog position change
mysql-test/t/rpl_switch_stm_row_mixed.test:
  Binlog position change
mysql-test/t/user_var-binlog.test:
  Binlog position change
sql/Makefile.am:
  Adding file rpl_constants.h with constants for replication.
sql/log_event.cc:
  Changing prototype for read_str() to be const-correct and changing code to match that.
  Adding incident log event.
sql/log_event.h:
  Adding incident log event.
sql/rpl_injector.cc:
  Adding support for generating incidents into the binary log.
sql/rpl_injector.h:
  Adding support for generating incidents into the binary log.
sql/share/errmsg.txt:
  Adding new error message to indicate an incident.
sql/sql_parse.cc:
  Adding code to generate an incident log event just before executing a REPLACE
  if the variable "incident_database_resync_on_replace" is set.
mysql-test/r/rpl_incident.result:
  New BitKeeper file ``mysql-test/r/rpl_incident.result''
mysql-test/t/rpl_incident.test:
  New BitKeeper file ``mysql-test/t/rpl_incident.test''
sql/rpl_constants.h:
  New BitKeeper file ``sql/rpl_constants.h''
2007-03-29 20:31:09 +02:00

239 lines
6.1 KiB
Text

#############################################################################
# This test is being created to test out the non deterministic items with #
# row based replication. #
# Original Author: JBM #
# Original Date: Aug/09/2005 #
# Updated: Aug/29/2005 #
#############################################################################
# Test: Contains two stored procedures test one that insert data into tables#
# and use the LAST_INSERTED_ID() on tables with FOREIGN KEY(a) #
# REFERENCES ON DELETE CASCADE. This test also has a delete sp that #
# should cause a delete cascade. #
# The second test has a sp that will either insert rows or delete from#
# the table depending on the CASE outcome. The test uses this SP in a#
# transaction first rolling back and then commiting, #
#############################################################################
# Mod Date: 08/22/2005 #
# TEST: Added test to include UPDATE CASCADE on table with FK per Trudy #
#############################################################################
# Includes
-- source include/have_binlog_format_row.inc
-- source include/master-slave.inc
# Begin clean up test section
connection master;
--disable_warnings
DROP PROCEDURE IF EXISTS test.p1;
DROP PROCEDURE IF EXISTS test.p2;
DROP PROCEDURE IF EXISTS test.p3;
DROP TABLE IF EXISTS test.t3;
DROP TABLE IF EXISTS test.t1;
DROP TABLE IF EXISTS test.t2;
--enable_warnings
# End of cleanup
# Begin test section 1
eval CREATE TABLE test.t1 (a INT AUTO_INCREMENT KEY, t CHAR(6)) ENGINE=$engine_type;
eval CREATE TABLE test.t2 (a INT AUTO_INCREMENT KEY, f INT, FOREIGN KEY(a) REFERENCES test.t1(a) ON DELETE CASCADE) ENGINE=$engine_type;
delimiter |;
create procedure test.p1(IN i CHAR(6))
begin
INSERT INTO test.t1 (t) VALUES (i);
INSERT INTO test.t2 VALUES (NULL,LAST_INSERT_ID());
end|
create procedure test.p2(IN i INT)
begin
DELETE FROM test.t1 where a < i;
end|
delimiter ;|
let $message=< -- test 1 call p1 -- >;
--source include/show_msg.inc
SET FOREIGN_KEY_CHECKS=1;
call test.p1('texas');
call test.p1('Live');
call test.p1('next');
call test.p1('to');
call test.p1('OK');
call test.p1('MySQL');
let $message=< -- test 1 select master after p1 -- >;
--source include/show_msg.inc
SELECT * FROM test.t1;
SELECT * FROM test.t2;
let $message=< -- test 1 select slave after p1 -- >;
--source include/show_msg.inc
save_master_pos;
connection slave;
sync_with_master;
SELECT * FROM test.t1;
SELECT * FROM test.t2;
let $message=< -- test 1 call p2 & select master -- >;
--source include/show_msg.inc
connection master;
call test.p2(4);
SELECT * FROM test.t1;
SELECT * FROM test.t2;
let $message=< -- test 1 select slave after p2 -- >;
--source include/show_msg.inc
save_master_pos;
connection slave;
sync_with_master;
SELECT * FROM test.t1;
SELECT * FROM test.t2;
connection master;
#show binlog events;
let $message=< -- End test 1 Begin test 2 -- >;
--source include/show_msg.inc
# End test 1 Begin test 2
--disable_warnings
SET FOREIGN_KEY_CHECKS=0;
DROP PROCEDURE IF EXISTS test.p1;
DROP PROCEDURE IF EXISTS test.p2;
DROP TABLE IF EXISTS test.t1;
DROP TABLE IF EXISTS test.t2;
--enable_warnings
# End of cleanup
eval CREATE TABLE test.t1 (a INT, t CHAR(6), PRIMARY KEY(a)) ENGINE=$engine_type;
eval CREATE TABLE test.t2 (a INT, f INT, FOREIGN KEY(a) REFERENCES test.t1(a) ON UPDATE CASCADE, PRIMARY KEY(a)) ENGINE=$engine_type;
delimiter |;
CREATE PROCEDURE test.p1(IN nm INT, IN ch CHAR(6))
BEGIN
INSERT INTO test.t1 (a,t) VALUES (nm, ch);
INSERT INTO test.t2 VALUES (nm, LAST_INSERT_ID());
END|
CREATE PROCEDURE test.p2(IN i INT)
BEGIN
UPDATE test.t1 SET a = i*10 WHERE a = i;
END|
delimiter ;|
SET FOREIGN_KEY_CHECKS=1;
CALL test.p1(1,'texas');
CALL test.p1(2,'Live');
CALL test.p1(3,'next');
CALL test.p1(4,'to');
CALL test.p1(5,'OK');
CALL test.p1(6,'MySQL');
let $message=< -- test 2 select Master after p1 -- >;
--source include/show_msg.inc
SELECT * FROM test.t1;
SELECT * FROM test.t2;
let $message=< -- test 2 select Slave after p1 -- >;
--source include/show_msg.inc
save_master_pos;
connection slave;
sync_with_master;
SELECT * FROM test.t1;
SELECT * FROM test.t2;
let $message=< -- test 2 call p2 & select Master -- >;
--source include/show_msg.inc
connection master;
CALL test.p2(2);
CALL test.p2(4);
CALL test.p2(6);
SELECT * FROM test.t1;
SELECT * FROM test.t2;
let $message=< -- test 1 select Slave after p2 -- >;
--source include/show_msg.inc
save_master_pos;
connection slave;
sync_with_master;
SELECT * FROM test.t1;
SELECT * FROM test.t2;
connection master;
#show binlog events;
let $message=< -- End test 2 Begin test 3 -- >;
--source include/show_msg.inc
# End test 2 begin test 3
eval CREATE TABLE test.t3 (a INT AUTO_INCREMENT KEY, t CHAR(6))ENGINE=$engine_type;
delimiter |;
CREATE PROCEDURE test.p3(IN n INT)
begin
CASE n
WHEN 2 THEN
DELETE from test.t3;
ELSE
INSERT INTO test.t3 VALUES (NULL,'NONE');
END CASE;
end|
delimiter ;|
SET AUTOCOMMIT=0;
START TRANSACTION;
-- disable_query_log
-- disable_result_log
let $n=50;
while ($n)
{
eval call test.p3($n);
dec $n;
}
-- enable_result_log
-- enable_query_log
ROLLBACK;
select * from test.t3;
save_master_pos;
connection slave;
sync_with_master;
select * from test.t3;
connection master;
START TRANSACTION;
-- disable_query_log
-- disable_result_log
let $n=50;
while ($n>3)
{
eval call test.p3($n);
dec $n;
}
-- enable_result_log
-- enable_query_log
COMMIT;
select * from test.t3;
save_master_pos;
connection slave;
sync_with_master;
select * from test.t3;
connection master;
#show binlog events from 1627;
# First lets cleanup
SET AUTOCOMMIT=1;
SET FOREIGN_KEY_CHECKS=0;
DROP PROCEDURE IF EXISTS test.p3;
DROP PROCEDURE IF EXISTS test.p1;
DROP PROCEDURE IF EXISTS test.p2;
DROP TABLE IF EXISTS test.t1;
DROP TABLE IF EXISTS test.t2;
DROP TABLE IF EXISTS test.t3;
sync_slave_with_master;
# End of 5.0 test case