Package io.debezium.connector.postgresql
Class PostgresSchema
java.lang.Object
io.debezium.relational.RelationalDatabaseSchema
io.debezium.connector.postgresql.PostgresSchema
- All Implemented Interfaces:
DatabaseSchema<TableId>,AutoCloseable
Component that records the schema information for the
PostgresConnector. The schema information contains
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:
- Horia Chiorean
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate static final org.slf4j.Loggerprotected static final Stringprivate final booleanFields inherited from interface io.debezium.schema.DatabaseSchema
NO_CAPTURED_DATA_COLLECTIONS_WARNING -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedPostgresSchema(PostgresConnectorConfig config, PostgresDefaultValueConverter defaultValueConverter, io.debezium.spi.topic.TopicNamingStrategy<TableId> topicNamingStrategy, PostgresValueConverter valueConverter) Create a schema component given the suppliedPostgres connector configuration. -
Method Summary
Modifier and TypeMethodDescriptionvoidapplySchemaChangesForTable(int relationId, Table table) Applies schema changes for the specified table.private static TableSchemaBuildergetTableSchemaBuilder(PostgresConnectorConfig config, PostgresValueConverter valueConverter, PostgresDefaultValueConverter defaultValueConverter) getToastableColumnsForTableId(TableId tableId) protected booleanisFilteredOut(TableId id) protected static TableIdprivate voidprintReplicaIdentityInfo(PostgresConnection connection, TableId tableId) protected PostgresSchemarefresh(PostgresConnection connection, boolean printReplicaIdentityInfo) Initializes the content for this schema by reading all the database information from the supplied connection.protected voidrefresh(PostgresConnection connection, TableId tableId, boolean refreshToastableColumns) Refreshes this schema's content for a particular tableprotected voidDiscard any currently-cached schemas and rebuild them using the filters.private voidrefreshToastableColumnsMap(PostgresConnection connection, TableId tableId) tableFor(int relationId) Resolve aTablebased on a supplied table relation unique identifier.booleanMethods inherited from class io.debezium.relational.RelationalDatabaseSchema
assureNonEmptySchema, buildAndRegisterSchema, clearSchemas, close, getTableFilter, isHistorized, refresh, refreshSchema, removeSchema, schemaFor, tableFor, tableIds, tables
-
Field Details
-
PUBLIC_SCHEMA_NAME
- See Also:
-
LOGGER
private static final org.slf4j.Logger LOGGER -
tableIdToToastableColumns
-
relationIdToTableId
-
readToastableColumns
private final boolean readToastableColumns
-
-
Constructor Details
-
PostgresSchema
protected PostgresSchema(PostgresConnectorConfig config, PostgresDefaultValueConverter defaultValueConverter, io.debezium.spi.topic.TopicNamingStrategy<TableId> topicNamingStrategy, PostgresValueConverter valueConverter) Create a schema component given the suppliedPostgres connector configuration.- Parameters:
config- the connector configuration, which is presumed to be valid
-
-
Method Details
-
getTableSchemaBuilder
private static TableSchemaBuilder getTableSchemaBuilder(PostgresConnectorConfig config, PostgresValueConverter valueConverter, PostgresDefaultValueConverter defaultValueConverter) -
refresh
protected PostgresSchema refresh(PostgresConnection connection, boolean printReplicaIdentityInfo) throws SQLException Initializes the content for this schema by reading all the database information from the supplied connection.- Parameters:
connection- aJdbcConnectioninstance, nevernullprintReplicaIdentityInfo- whether or not to look and print out replica identity information about the tables- Returns:
- this object so methods can be chained together; never null
- Throws:
SQLException- if there is a problem obtaining the schema from the database server
-
printReplicaIdentityInfo
-
refresh
protected void refresh(PostgresConnection connection, TableId tableId, boolean refreshToastableColumns) throws SQLException Refreshes this schema's content for a particular table- Parameters:
connection- aJdbcConnectioninstance, nevernulltableId- the table identifier; may not be nullrefreshToastableColumns- refreshes the cache of toastable columns for `tableId`, iftrue- Throws:
SQLException- if there is a problem refreshing the schema from the database server
-
isFilteredOut
-
refreshSchemas
protected void refreshSchemas()Discard any currently-cached schemas and rebuild them using the filters. -
refreshToastableColumnsMap
-
parse
-
getToastableColumnsForTableId
-
applySchemaChangesForTable
Applies schema changes for the specified table.- Parameters:
relationId- the postgres relation unique identifier for the tabletable- externally constructed table, typically from the decoder; must not be null
-
tableFor
Resolve aTablebased on a supplied table relation unique identifier.This implementation relies on a prior call to
applySchemaChangesForTable(int, Table)to have applied schema changes from a replication stream with therelationIdfor the relationship to exist and be capable of lookup.- Parameters:
relationId- the unique table relation identifier- Returns:
- the resolved table or null
-
tableInformationComplete
public boolean tableInformationComplete()- Specified by:
tableInformationCompletein interfaceDatabaseSchema<TableId>- Overrides:
tableInformationCompletein classRelationalDatabaseSchema
-