Row Images
Enterprise Replication evaluates the initial and final images of a row and any changes that occur between the two row images to determine which rows to replicate. Each row image contains the data in the row and the action that is performed on that row.
A row might change more than once in a particular transaction. For example, a transaction might insert and then update a row before committing. Enterprise Replication evaluates the net effect (final state) of a transaction based on the row buffers in the log. Enterprise Replication then determines what must be replicated, based on the net effect, the initial state of the row, and whether the replicate definition (in particular, the WHERE clause) applies to the initial and final state. Enterprise Replication evaluates the row-image type (INSERT, UPDATE, DELETE), the results of evaluating the replicate WHERE clause for both the initial and final image, and whether the replication key changes as a result of the transaction.
The following table shows the logic that determines which rows are candidates for replication. The source and destination tables are assumed to be initially synchronized (identical before replication begins). If the tables were not synchronized, anomalous behavior might result.
Initial Image | Replicate Evaluates | Final Image | Replicate Evaluates | Replication-Key Changed? | Send to Destination Database Server | Comments |
---|---|---|---|---|---|---|
INSERT | T or F | DELETE | T or F | Yes or no | Nothing | Net change of transaction results in no replication |
INSERT | T or F | UPDATE | T | Yes or no | INSERT with final row image | Inserts final data of transaction |
INSERT | T or F | UPDATE | F | Yes or no | Nothing | Final evaluation determines no replication |
UPDATE | T | DELETE | T or F | Yes or no | DELETE with initial row image | Net result of transaction is delete |
UPDATE | F | DELETE | T or F | Yes or no | Nothing | Net change of transaction results in no replication |
UPDATE | T | UPDATE | T | Yes | DELETE with initial row image and INSERT with final row image | Ensures old replication key does not replicate |
UPDATE | T | UPDATE | T | No | UPDATE with final row image | Simple update |
UPDATE | T | UPDATE | F | Yes or no | DELETE with initial row image | Row no longer matches replicate definition |
UPDATE | F | UPDATE | T | Yes or no | INSERT with final row image | Row now matches replicate definition |
UPDATE | F | UPDATE | F | Yes or no | Nothing | No match exists, and therefore, no replication |
- The initial image is the before image of the transaction in the logical log.
- The replicate evaluates to T (true) or F (false).
- The final image is the image of the transaction that is replicated.
After Enterprise Replication identifies transactions that qualify for replication, Enterprise Replication transfers the transaction data to a queue.