Commit 1b6e66fa authored by Igor Babaev's avatar Igor Babaev

Added missing tests for GET DIAGNOSTICS.

parent a3d79f2e
This diff is collapsed.
...@@ -213,4 +213,52 @@ ERROR 23000: Duplicate entry '2147483647' for key 'PRIMARY' ...@@ -213,4 +213,52 @@ ERROR 23000: Duplicate entry '2147483647' for key 'PRIMARY'
include/diff_tables.inc [master:t1,slave:t1] include/diff_tables.inc [master:t1,slave:t1]
DROP TRIGGER tr1; DROP TRIGGER tr1;
DROP TABLE t1; DROP TABLE t1;
# The GET DIAGNOSTICS itself is not replicated, but it can set
# variables which can be used in statements that are replicated.
include/rpl_reset.inc
CREATE TABLE t1 (a INT, b INT);
GET DIAGNOSTICS @var1 = NUMBER;
INSERT INTO t1 VALUES (@var1, 0), (@var1, 0);
CREATE PROCEDURE p1()
LANGUAGE SQL
BEGIN
DECLARE count INT;
UPDATE t1 SET b = 2 WHERE a = 0;
GET DIAGNOSTICS count = ROW_COUNT;
INSERT INTO t1 VALUES (1, count);
END|
CALL p1();
# On slave, check if the statement was replicated.
SELECT * FROM t1 ORDER BY a;
a b
0 2
0 2
1 2
# Show events and cleanup
include/show_binlog_events.inc
Log_name Pos Event_type Server_id End_log_pos Info
master-bin.000001 # Gtid # # GTID #-#-#
master-bin.000001 # Query # # use `test`; CREATE TABLE t1 (a INT, b INT)
master-bin.000001 # Gtid # # BEGIN GTID #-#-#
master-bin.000001 # User var # # @`var1`=0
master-bin.000001 # Query # # use `test`; INSERT INTO t1 VALUES (@var1, 0), (@var1, 0)
master-bin.000001 # Query # # COMMIT
master-bin.000001 # Gtid # # GTID #-#-#
master-bin.000001 # Query # # use `test`; CREATE DEFINER=`root`@`localhost` PROCEDURE `p1`()
BEGIN
DECLARE count INT;
UPDATE t1 SET b = 2 WHERE a = 0;
GET DIAGNOSTICS count = ROW_COUNT;
INSERT INTO t1 VALUES (1, count);
END
master-bin.000001 # Gtid # # BEGIN GTID #-#-#
master-bin.000001 # Query # # use `test`; UPDATE t1 SET b = 2 WHERE a = 0
master-bin.000001 # Query # # COMMIT
master-bin.000001 # Gtid # # BEGIN GTID #-#-#
master-bin.000001 # Query # # use `test`; INSERT INTO t1 VALUES (1, NAME_CONST('count',2))
master-bin.000001 # Query # # COMMIT
DROP TABLE t1;
DROP PROCEDURE p1;
include/rpl_end.inc include/rpl_end.inc
...@@ -167,4 +167,43 @@ DROP TABLE t1; ...@@ -167,4 +167,43 @@ DROP TABLE t1;
-- sync_slave_with_master -- sync_slave_with_master
--echo
--echo # The GET DIAGNOSTICS itself is not replicated, but it can set
--echo # variables which can be used in statements that are replicated.
--echo
--source include/rpl_reset.inc
connection master;
CREATE TABLE t1 (a INT, b INT);
GET DIAGNOSTICS @var1 = NUMBER;
INSERT INTO t1 VALUES (@var1, 0), (@var1, 0);
DELIMITER |;
CREATE PROCEDURE p1()
LANGUAGE SQL
BEGIN
DECLARE count INT;
UPDATE t1 SET b = 2 WHERE a = 0;
GET DIAGNOSTICS count = ROW_COUNT;
INSERT INTO t1 VALUES (1, count);
END|
DELIMITER ;|
CALL p1();
-- sync_slave_with_master
connection slave;
--echo # On slave, check if the statement was replicated.
SELECT * FROM t1 ORDER BY a;
connection master;
--echo # Show events and cleanup
--source include/show_binlog_events.inc
DROP TABLE t1;
DROP PROCEDURE p1;
-- sync_slave_with_master
--source include/rpl_end.inc --source include/rpl_end.inc
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