Home > Database > Mysql Tutorial > 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
Release: 2023-09-07 11:57:02
forward
1510 people have browsed it

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 //
Copy after login

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

mysql> Delimiter ;
mysql> CALL myproc();
Copy after login

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!

source:tutorialspoint.com
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template