Class PostgresSchema

java.lang.Object
io.debezium.relational.RelationalDatabaseSchema
io.debezium.connector.postgresql.PostgresSchema
All Implemented Interfaces:
DatabaseSchema<TableId>, AutoCloseable

@NotThreadSafe public class PostgresSchema extends RelationalDatabaseSchema
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 Details

    • PUBLIC_SCHEMA_NAME

      protected static final String PUBLIC_SCHEMA_NAME
      See Also:
    • LOGGER

      private static final org.slf4j.Logger LOGGER
    • tableIdToToastableColumns

      private final Map<TableId,List<String>> tableIdToToastableColumns
    • relationIdToTableId

      private final Map<Integer,TableId> relationIdToTableId
    • readToastableColumns

      private final boolean readToastableColumns
  • Constructor Details

  • 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 - a JdbcConnection instance, never null
      printReplicaIdentityInfo - 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 - a JdbcConnection instance, never null
      tableId - the table identifier; may not be null
      refreshToastableColumns - refreshes the cache of toastable columns for `tableId`, if true
      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)
    • parse

      protected static TableId parse(String table)
    • getToastableColumnsForTableId

      public List<String> getToastableColumnsForTableId(TableId tableId)
    • applySchemaChangesForTable

      public void applySchemaChangesForTable(int relationId, Table table)
      Applies schema changes for the specified table.
      Parameters:
      relationId - the postgres relation unique identifier for the table
      table - externally constructed table, typically from the decoder; must not be null
    • tableFor

      public Table tableFor(int relationId)
      Resolve a Table based 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 the relationId for 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:
      tableInformationComplete in interface DatabaseSchema<TableId>
      Overrides:
      tableInformationComplete in class RelationalDatabaseSchema