Home  >  Article  >  Database  >  How can I replicate the operations that occur within stored procedures and functions?

How can I replicate the operations that occur within stored procedures and functions?

PHPz
PHPzforward
2023-09-07 11:57:021448browse

How can I replicate the operations that occur within stored procedures and functions?

In fact, standard operations performed in stored procedures and functions are replicated from the master MySQL server to the slave MySQL server. Even the creation of stored procedures and functions executed through normal DDL statements on the master MySQL server will be replicated to the slave MySQL server. This way the object will exist on both servers at the same time.

Operations that occur within stored procedures and functions are replicated because MySQL logs every DDL event that occurs within stored procedures and functions. After the event is logged, it is replicated to the slave MySQL server. But the actual calls that execute the stored procedure are not copied. Here is an example where the procedure CALL is not replicated as it is actually the one on the main MySQL server.

Example

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

Now when we call this procedure on the main MySQL server, it will not replicate.

mysql> Delimiter ;
mysql> CALL myproc();

The above is the detailed content of How can I replicate the operations that occur within stored procedures and functions?. For more information, please follow other related articles on the PHP Chinese website!

Statement:
This article is reproduced at:tutorialspoint.com. If there is any infringement, please contact admin@php.cn delete