How are actions that take place inside stored procedure and functions replicated?


Actually standard actions carried out in stored procedures and functions are replicated from a master MySQL server to a slave MySQL server. Even the creation of stored procedures and functions carried out through normal DDL statements on a master MySQL server are replicated to a slave MySQL server. In this way, objects will exist on both the servers.

The actions that take place inside the stored procedure and functions are replicated because MySQL records each DDL event that occurs inside stored procedures and functions. After recording the events it is replicated to the slave MySQL server. But the actual calls made to execute stored procedures are not replicated. Following is an example in which the procedure CALL will not replicate because it is actually one on the master MySQL server.

Example

mysql> Delimiter //
mysql> CREATE PROCEDURE myproc()
    -> BEGIN
    -> DELETE FROM mytable LIMIT 1;
    -> END //

Now when we call this procedure on master MySQL server then it will not replicate.

mysql> Delimiter ;
mysql> CALL myproc();

Updated on: 22-Jun-2020

95 Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements