config root man

Current Path : /home/usr.opt/mysql57/mysql-test/suite/rpl/t/

FreeBSD hs32.drive.ne.jp 9.1-RELEASE FreeBSD 9.1-RELEASE #1: Wed Jan 14 12:18:08 JST 2015 root@hs32.drive.ne.jp:/sys/amd64/compile/hs32 amd64
Upload File :
Current File : //home/usr.opt/mysql57/mysql-test/suite/rpl/t/rpl_mix_found_rows.test

source include/master-slave.inc;
source include/have_binlog_format_mixed.inc;

# It is not possible to replicate FOUND_ROWS() using statement-based
# replication, but there is a workaround that stores the result of
# FOUND_ROWS() into a user variable and then replicates this instead.
#
# The purpose of this test case is to test that the workaround works
# properly even when inside stored programs (i.e., stored routines and
# triggers).

--echo ==== Initialize ====

--echo **** On Master ****
connection master;
CREATE TABLE t1 (a INT);
CREATE TABLE logtbl (sect INT, test INT, count INT);

INSERT INTO t1 VALUES (1),(2),(3);
INSERT INTO t1 SELECT 2*a+3 FROM t1;
INSERT INTO t1 SELECT 2*a+3 FROM t1;
INSERT INTO t1 SELECT 2*a+3 FROM t1;
INSERT INTO t1 SELECT 2*a+3 FROM t1;
INSERT INTO t1 SELECT 2*a+3 FROM t1;
INSERT INTO t1 SELECT 2*a+3 FROM t1;

--echo ==== Checking a procedure ====

--echo **** On Master ****
connection master;

# We will now check some stuff that will not work in statement-based
# replication, but which should cause the binary log to switch to
# row-based logging.

--delimiter $$
CREATE PROCEDURE just_log(sect INT, test INT) BEGIN
  INSERT INTO logtbl VALUES (sect,test,FOUND_ROWS());
END $$
--delimiter ;
--source include/sync_slave_sql_with_master.inc

--echo **** On Master 1 ****
connection master1;
SELECT SQL_CALC_FOUND_ROWS * FROM t1 WHERE a > 5 ORDER BY a LIMIT 1;
CALL just_log(1,1);

--echo **** On Master ****
connection master;
SELECT SQL_CALC_FOUND_ROWS * FROM t1 WHERE a > 5 ORDER BY a LIMIT 1;
CALL just_log(1,2);

--echo **** On Master 1 ****

connection master1;
SELECT SQL_CALC_FOUND_ROWS * FROM t1 WHERE a < 5 ORDER BY a LIMIT 1;
CALL just_log(1,3);
--source include/sync_slave_sql_with_master.inc

--echo **** On Master ****
connection master;
SELECT SQL_CALC_FOUND_ROWS * FROM t1 WHERE a > 5 ORDER BY a LIMIT 1;
CALL just_log(1,4);
--source include/sync_slave_sql_with_master.inc

connection master;
SELECT * FROM logtbl WHERE sect = 1 ORDER BY sect,test;
--echo **** On Slave ****
--source include/sync_slave_sql_with_master.inc
SELECT * FROM logtbl WHERE sect = 1 ORDER BY sect,test;

--echo ==== Checking a stored function ====
--echo **** On Master ****
connection master;
--delimiter $$
CREATE FUNCTION log_rows(sect INT, test INT)
  RETURNS INT
BEGIN
  DECLARE found_rows INT;
  SELECT FOUND_ROWS() INTO found_rows;
  INSERT INTO logtbl VALUES(sect,test,found_rows);
  RETURN found_rows;
END $$
--delimiter ;

SELECT SQL_CALC_FOUND_ROWS * FROM t1 WHERE a < 5 ORDER BY a LIMIT 1;
SELECT log_rows(2,1), log_rows(2,2);

CREATE TABLE t2 (a INT, b INT);

# Trying with referencing FOUND_ROWS() directly in the trigger.

--delimiter $$
CREATE TRIGGER t2_tr BEFORE INSERT ON t2 FOR EACH ROW
BEGIN
  INSERT INTO logtbl VALUES (NEW.a, NEW.b, FOUND_ROWS());
END $$
--delimiter ;

SELECT SQL_CALC_FOUND_ROWS * FROM t1 WHERE a < 5 ORDER BY a LIMIT 1;
INSERT INTO t2 VALUES (2,3), (2,4);

# Referencing FOUND_ROWS() indirectly.

DROP TRIGGER t2_tr;

--delimiter $$
CREATE TRIGGER t2_tr BEFORE INSERT ON t2 FOR EACH ROW
BEGIN
  DECLARE dummy INT;
  SELECT log_rows(NEW.a, NEW.b) INTO dummy;
END $$
--delimiter ;

SELECT SQL_CALC_FOUND_ROWS * FROM t1 WHERE a > 5 ORDER BY a LIMIT 1;
INSERT INTO t2 VALUES (2,5), (2,6);

# Putting FOUND_ROWS() even lower in the call chain.

connection master;
DROP TRIGGER t2_tr;

--delimiter $$
CREATE PROCEDURE log_me_inner(sect INT, test INT)
BEGIN
  DECLARE dummy INT;
  SELECT log_rows(sect, test) INTO dummy;
  SELECT log_rows(sect, test+1) INTO dummy;
END $$

CREATE PROCEDURE log_me(sect INT, test INT)
BEGIN
  CALL log_me_inner(sect,test);
END $$
--delimiter ;

--delimiter $$
CREATE TRIGGER t2_tr BEFORE INSERT ON t2 FOR EACH ROW
BEGIN
  CALL log_me(NEW.a, NEW.b);
END $$
--delimiter ;

SELECT SQL_CALC_FOUND_ROWS * FROM t1 WHERE a > 5 ORDER BY a LIMIT 1;
INSERT INTO t2 VALUES (2,5), (2,6);

SELECT * FROM logtbl WHERE sect = 2 ORDER BY sect,test;
--source include/sync_slave_sql_with_master.inc
SELECT * FROM logtbl WHERE sect = 2 ORDER BY sect,test;

connection master;
DROP TABLE t1, t2, logtbl;
DROP PROCEDURE just_log;
DROP PROCEDURE log_me;
DROP PROCEDURE log_me_inner;
DROP FUNCTION log_rows;
--source include/sync_slave_sql_with_master.inc

--source include/rpl_end.inc

Man Man