56 lines
2.0 KiB
Plaintext
56 lines
2.0 KiB
Plaintext
include/master-slave.inc
|
|
Warnings:
|
|
Note #### Sending passwords in plain text without SSL/TLS is extremely insecure.
|
|
Note #### Storing MySQL user name or password information in the master info repository is not secure and is therefore not recommended. Please consider using the USER and PASSWORD connection options for START SLAVE; see the 'START SLAVE Syntax' in the MySQL Manual for more information.
|
|
[connection master]
|
|
SET sql_mode = default;
|
|
|
|
# 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();
|
|
include/sync_slave_sql_with_master.inc
|
|
# 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 # Query # # use `test`; CREATE TABLE t1 (a INT, b INT)
|
|
master-bin.000001 # Query # # BEGIN
|
|
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 # 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 # Query # # BEGIN
|
|
master-bin.000001 # Query # # use `test`; UPDATE t1 SET b = 2 WHERE a = 0
|
|
master-bin.000001 # Query # # COMMIT
|
|
master-bin.000001 # Query # # BEGIN
|
|
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/sync_slave_sql_with_master.inc
|
|
include/rpl_end.inc
|