Package io.debezium.connector.mysql
Class MySqlDatabaseSchema
java.lang.Object
io.debezium.relational.RelationalDatabaseSchema
io.debezium.relational.HistorizedRelationalDatabaseSchema
io.debezium.connector.mysql.MySqlDatabaseSchema
- All Implemented Interfaces:
DatabaseSchema<TableId>,HistorizedDatabaseSchema<TableId>,AutoCloseable
Component that records the schema history for databases hosted by a MySQL database server. The schema information includes
the
table definitions and the Kafka Connect Schemas for each table, where the
Schema excludes any columns that have been specified in the
configuration.- Author:
- Randall Hauch
-
Nested Class Summary
Nested classes/interfaces inherited from interface io.debezium.schema.HistorizedDatabaseSchema
HistorizedDatabaseSchema.SchemaChangeEventConsumer -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final MySqlConnectorConfigprivate final DdlChangesprivate final DdlParserprivate final RelationalTableFiltersprivate static final org.slf4j.Loggerprivate booleanFields inherited from class io.debezium.relational.HistorizedRelationalDatabaseSchema
schemaHistoryFields inherited from interface io.debezium.schema.DatabaseSchema
NO_CAPTURED_DATA_COLLECTIONS_WARNING -
Constructor Summary
ConstructorsConstructorDescriptionMySqlDatabaseSchema(MySqlConnectorConfig connectorConfig, MySqlValueConverters valueConverter, io.debezium.spi.topic.TopicNamingStrategy<TableId> topicNamingStrategy, SchemaNameAdjuster schemaNameAdjuster, boolean tableIdCaseInsensitive) Create a schema component given the suppliedMySQL connector configuration. -
Method Summary
Modifier and TypeMethodDescriptionprivate booleanacceptableDatabase(String databaseName) protected voidappendCreateTableStatement(StringBuilder sb, Table table) protected voidappendDropTableStatement(StringBuilder sb, TableId tableId) voidapplySchemaChange(SchemaChangeEvent schemaChange) booleanassignTableNumber(long tableNumber, TableId id) Assign the given table number to the table with the specifiedtable ID.String[]Get all table names for all databases that are monitored whose events are captured by DebeziumvoidClear all of the table mappings.private voidemitChangeEvent(MySqlPartition partition, MySqlOffsetContext offset, List<SchemaChangeEvent> schemaChangeEvents, String sanitizedDbName, DdlParserListener.Event event, TableId tableId, SchemaChangeEvent.SchemaChangeEventType type, boolean snapshot) protected DdlParsergetExcludeTableId(long tableNumber) Return the excluded table id associated with MySQL-specific table number.getTableId(long tableNumber) Return the table id associated with MySQL-specific table number.private TableIdbooleanReturn true if the database schema history entity existsvoidbooleanisGlobalSetVariableStatement(String ddl, String databaseName) booleanprivate List<SchemaChangeEvent>parseDdl(MySqlPartition partition, String ddlStatements, String databaseName, MySqlOffsetContext offset, Instant sourceTime, boolean snapshot) parseSnapshotDdl(MySqlPartition partition, String ddlStatements, String databaseName, MySqlOffsetContext offset, Instant sourceTime) parseStreamingDdl(MySqlPartition partition, String ddlStatements, String databaseName, MySqlOffsetContext offset, Instant sourceTime) protected voidDiscard any currently-cached schemas and rebuild them using the filters.voidsetSystemVariables(Map<String, String> variables) Set the system variables on the DDL parser.booleanbooleanGet the system variables as known by the DDL parser.Methods inherited from class io.debezium.relational.HistorizedRelationalDatabaseSchema
close, isHistorized, record, recover, skipUnparseableDdlStatements, tableInformationCompleteMethods inherited from class io.debezium.relational.RelationalDatabaseSchema
assureNonEmptySchema, buildAndRegisterSchema, clearSchemas, getTableFilter, refresh, refreshSchema, removeSchema, schemaFor, tableFor, tableIds, tablesMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface io.debezium.schema.DatabaseSchema
assureNonEmptySchema, schemaForMethods inherited from interface io.debezium.schema.HistorizedDatabaseSchema
recover
-
Field Details
-
LOGGER
private static final org.slf4j.Logger LOGGER -
ignoredQueryStatements
-
ddlParser
-
filters
-
ddlChanges
-
tableIdsByTableNumber
-
excludeTableIdsByTableNumber
-
storageInitializationExecuted
private boolean storageInitializationExecuted -
connectorConfig
-
-
Constructor Details
-
MySqlDatabaseSchema
public MySqlDatabaseSchema(MySqlConnectorConfig connectorConfig, MySqlValueConverters valueConverter, io.debezium.spi.topic.TopicNamingStrategy<TableId> topicNamingStrategy, SchemaNameAdjuster schemaNameAdjuster, boolean tableIdCaseInsensitive) Create a schema component given the suppliedMySQL connector configuration. The DDL statements passed to the schema are parsed and a logical model of the database schema is created.
-
-
Method Details
-
capturedTablesAsStringArray
Get all table names for all databases that are monitored whose events are captured by Debezium- Returns:
- the array with the table names
-
setSystemVariables
Set the system variables on the DDL parser.- Parameters:
variables- the system variables; may not be null but may be empty
-
systemVariables
Get the system variables as known by the DDL parser.- Returns:
- the system variables; never null
-
appendDropTableStatement
-
appendCreateTableStatement
-
refreshSchemas
protected void refreshSchemas()Discard any currently-cached schemas and rebuild them using the filters. -
isGlobalSetVariableStatement
-
applySchemaChange
-
parseSnapshotDdl
public List<SchemaChangeEvent> parseSnapshotDdl(MySqlPartition partition, String ddlStatements, String databaseName, MySqlOffsetContext offset, Instant sourceTime) -
parseStreamingDdl
public List<SchemaChangeEvent> parseStreamingDdl(MySqlPartition partition, String ddlStatements, String databaseName, MySqlOffsetContext offset, Instant sourceTime) -
parseDdl
private List<SchemaChangeEvent> parseDdl(MySqlPartition partition, String ddlStatements, String databaseName, MySqlOffsetContext offset, Instant sourceTime, boolean snapshot) -
emitChangeEvent
private void emitChangeEvent(MySqlPartition partition, MySqlOffsetContext offset, List<SchemaChangeEvent> schemaChangeEvents, String sanitizedDbName, DdlParserListener.Event event, TableId tableId, SchemaChangeEvent.SchemaChangeEventType type, boolean snapshot) -
acceptableDatabase
-
getTableId
-
getDdlParser
- Specified by:
getDdlParserin classHistorizedRelationalDatabaseSchema
-
historyExists
public boolean historyExists()Return true if the database schema history entity exists -
storeOnlyCapturedTables
public boolean storeOnlyCapturedTables()- Specified by:
storeOnlyCapturedTablesin interfaceHistorizedDatabaseSchema<TableId>- Overrides:
storeOnlyCapturedTablesin classHistorizedRelationalDatabaseSchema
-
assignTableNumber
Assign the given table number to the table with the specifiedtable ID.- Parameters:
tableNumber- the table number found in binlog eventsid- the identifier for the corresponding table- Returns:
trueif the assignment was successful, orfalseif the table is currently excluded in the connector's configuration
-
getTableId
Return the table id associated with MySQL-specific table number.- Parameters:
tableNumber-- Returns:
- the table id or null if not known
-
getExcludeTableId
Return the excluded table id associated with MySQL-specific table number.- Parameters:
tableNumber-- Returns:
- the table id or null if not known
-
clearTableMappings
public void clearTableMappings()Clear all of the table mappings. This should be done when the logs are rotated, since in that a different table numbering scheme will be used by all subsequent TABLE_MAP binlog events. -
initializeStorage
public void initializeStorage()- Specified by:
initializeStoragein interfaceHistorizedDatabaseSchema<TableId>- Overrides:
initializeStoragein classHistorizedRelationalDatabaseSchema
-
isStorageInitializationExecuted
public boolean isStorageInitializationExecuted() -
skipSchemaChangeEvent
-