Sending data from a replica to its master is called propagating the data to the master. The replica controls when and how much data should be sent.
When data is propagated from a replica to a master, the propagation is done by composing a message that is sent from the replica to the master. The message contains SQL statements rather than rows of data. A single message can contain multiple statements and multiple transactions. There is no way to send a fragment of a transaction to the master; the message must commit the SQL statements that it sends. You can divide a message into multiple transactions, but you cannot divide a transaction into multiple messages.
Although there is almost no restriction on the SQL statements that you can use, as a practical matter, the statements that you send to the master are typically the same as the statements that you executed on the replica. Instead of sending raw data to the master, you send a series of statements that perform the same operations on the master as you performed on the replica. For example, if you performed the following steps on the replica, you send the same commands to the master so that the same steps are repeated on the master.
INSERT INTO employees (id, name) VALUES (12, 'Michelle Uhuru'); UPDATE employees SET department = 'Telecommunications' WHERE id = 12;
Important: If your replica contains a subset of the data on master, executing statements can affect more records on the master than on the replica. For example, a command that uses a unique employee ID in the WHERE clause is likely to have the same effect on the master as on the replica. If the replica has only a subset of the data on the master, a command that has a broad WHERE clause can affect more records on the master than on the replica.
You use SAVE statements to compose the message that is send from replica to master. In pseudo-code, this looks similar to the following:
INSERT INTO employees (id, name) VALUES (12, "Michelle Uhuru'); UPDATE employees SET department = 'Telecommunications' WHERE id = 12; -- Save the statements for later propagation to the master -- database. SAVE INSERT INTO employees (id, name) VALUES (12, 'Michelle Uhuru'); SAVE UPDATE employees SET department = 'Telecommunications' WHERE id = 12; COMMIT WORK;
Tip: The propagated SQL statements can include stored procedure calls.