Skip to content

Commit 45e795e

Browse files
committed
In the event that the table is fully qualified in a DDL statement ensure
that the provided schema matches the replicatedSchema. This catches situations in which the context of the query matches the replicatedSchema but the query itself modifies a table in a different schema.
1 parent 6bacf99 commit 45e795e

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

mysql-replicator-augmenter/src/main/java/com/booking/replication/augmenter/AugmenterContext.java

+8-1
Original file line numberDiff line numberDiff line change
@@ -486,7 +486,14 @@ private void processQueryEvent(RawEventHeaderV4 eventHeader, RawEventData eventD
486486

487487
// If the tableName contains a period it has both a schema and table name
488488
if ( tableName.indexOf(".") != -1 ) {
489-
tableName = tableName.split("\\.")[1];
489+
String[] matches = tableName.split("\\.");
490+
String schema = matches[0].replaceAll("`","");
491+
if ( !schema.equals(replicatedSchema) ) {
492+
LOG.info("Skipping DDL TABLE event due to affected table schema (" + schema + ") not matching replicatedSchema (" + replicatedSchema + "), while the getDatabase() ("+ queryRawEventData.getDatabase() + ") schema *DOES* match replicatedSchema");
493+
shouldProcess = false;
494+
} else {
495+
tableName = matches[1];
496+
}
490497
}
491498

492499
if (tableName.startsWith("`") && tableName.endsWith("`")) {

0 commit comments

Comments
 (0)