Package io.debezium.connector.postgresql
Class PostgresSchema
- java.lang.Object
-
- io.debezium.relational.RelationalDatabaseSchema
-
- io.debezium.connector.postgresql.PostgresSchema
-
- All Implemented Interfaces:
DatabaseSchema<TableId>
@NotThreadSafe public class PostgresSchema extends RelationalDatabaseSchema
Component that records the schema information for thePostgresConnector. The schema information contains thetable definitionsand the Kafka ConnectSchemas for each table, where theSchemaexcludes any columns that have beenspecifiedin the configuration.- Author:
- Horia Chiorean
-
-
Field Summary
Fields Modifier and Type Field Description private static org.slf4j.LoggerLOGGERprotected static StringPUBLIC_SCHEMA_NAMEprivate booleanreadToastableColumnsprivate Map<Integer,TableId>relationIdToTableIdprivate Map<TableId,List<String>>tableIdToToastableColumnsprivate TypeRegistrytypeRegistry-
Fields inherited from interface io.debezium.schema.DatabaseSchema
NO_CAPTURED_DATA_COLLECTIONS_WARNING
-
-
Constructor Summary
Constructors Modifier Constructor Description protectedPostgresSchema(PostgresConnectorConfig config, TypeRegistry typeRegistry, TopicSelector<TableId> topicSelector, PostgresValueConverter valueConverter)Create a schema component given the suppliedPostgres connector configuration.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description voidapplySchemaChangesForTable(int relationId, Table table)Applies schema changes for the specified table.private static TableSchemaBuildergetTableSchemaBuilder(PostgresConnectorConfig config, PostgresValueConverter valueConverter)List<String>getToastableColumnsForTableId(TableId tableId)TypeRegistrygetTypeRegistry()protected booleanisFilteredOut(TableId id)protected static TableIdparse(String table)private 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 voidrefreshSchemas()Discard any currently-cached schemas and rebuild them using the filters.private voidrefreshToastableColumnsMap(PostgresConnection connection, TableId tableId)TabletableFor(int relationId)Resolve aTablebased on a supplied table relation unique identifier.booleantableInformationComplete()-
Methods inherited from class io.debezium.relational.RelationalDatabaseSchema
assureNonEmptySchema, buildAndRegisterSchema, clearSchemas, close, getTableFilter, isHistorized, refresh, refreshSchema, removeSchema, schemaFor, tableFor, tableIds, tables
-
-
-
-
Field Detail
-
PUBLIC_SCHEMA_NAME
protected static final String PUBLIC_SCHEMA_NAME
- See Also:
- Constant Field Values
-
LOGGER
private static final org.slf4j.Logger LOGGER
-
typeRegistry
private final TypeRegistry typeRegistry
-
readToastableColumns
private final boolean readToastableColumns
-
-
Constructor Detail
-
PostgresSchema
protected PostgresSchema(PostgresConnectorConfig config, TypeRegistry typeRegistry, TopicSelector<TableId> topicSelector, PostgresValueConverter valueConverter)
Create a schema component given the suppliedPostgres connector configuration.- Parameters:
config- the connector configuration, which is presumed to be valid
-
-
Method Detail
-
getTableSchemaBuilder
private static TableSchemaBuilder getTableSchemaBuilder(PostgresConnectorConfig config, PostgresValueConverter valueConverter)
-
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
private void printReplicaIdentityInfo(PostgresConnection connection, TableId tableId)
-
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
protected boolean isFilteredOut(TableId id)
-
refreshSchemas
protected void refreshSchemas()
Discard any currently-cached schemas and rebuild them using the filters.
-
refreshToastableColumnsMap
private void refreshToastableColumnsMap(PostgresConnection connection, TableId tableId)
-
getTypeRegistry
public TypeRegistry getTypeRegistry()
-
applySchemaChangesForTable
public void applySchemaChangesForTable(int relationId, Table table)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
public Table tableFor(int relationId)
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
-
-