Class PostgresDatabaseDialect
java.lang.Object
io.debezium.connector.jdbc.dialect.GeneralDatabaseDialect
io.debezium.connector.jdbc.dialect.postgres.PostgresDatabaseDialect
- All Implemented Interfaces:
DatabaseDialect
A
DatabaseDialect implementation for PostgreSQL.- Author:
- Chris Cranford
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic class -
Constructor Summary
ConstructorsModifierConstructorDescriptionprivatePostgresDatabaseDialect(JdbcSinkConnectorConfig config, org.hibernate.SessionFactory sessionFactory) -
Method Summary
Modifier and TypeMethodDescriptionGets the prefix used before adding each column-clause toALTER TABLEstatements.Gets the prefix used before adding column-clauses inALTER TABLEstatements.Gets the suffix used after adding the column-clauses inALTER TABLEstatements.Returns the default format for binding a byte arraygetFormattedBoolean(boolean value) Format a boolean.Format a date and time with nonoseconds.getFormattedTime(TemporalAccessor value) Format a time.intGets the maximum precision allowed for a dialect's timestamp data type.intGets the maximum length of a VARCHAR field in a primary key column.getQueryBindingWithValueCast(ColumnDescriptor column, org.apache.kafka.connect.data.Schema schema, Type type) Returns the SQL binding fragment for a column, schema, and type mapping.getUpsertStatement(TableDescriptor table, SinkRecordDescriptor record) Construct aUPSERTstatement specific for this dialect.readTable(Connection connection, TableId tableId) Read the table structure data from the database.protected voidprotected StringresolveColumnNameFromField(String fieldName) booleantableExists(Connection connection, TableId tableId) Check whether the specified table exists.Methods inherited from class io.debezium.connector.jdbc.dialect.GeneralDatabaseDialect
addColumnDefaultValue, bindValue, columnNameFromField, columnNameFromField, columnQueryBindingFromField, getAlterTableColumnDelimiter, getAlterTableColumnSuffix, getAlterTableStatement, getColumnNamingStrategy, getConfig, getCreateTableStatement, getDatabaseTimeZone, getDatabaseTimeZoneQueryResult, getDatabaseVersion, getDefaultDecimalPrecision, getDefaultTimestampPrecision, getDeleteStatement, getFormattedDate, getFormattedDateTime, getFormattedTimestamp, getFormattedTimestampWithTimeZone, getFormattedTimeWithTimeZone, getIdentifierHelper, getInsertStatement, getMaxNVarcharLengthInKey, getMaxVarbinaryLength, getQualifiedTableName, getSchemaType, getTableId, getTruncateStatement, getTypeName, getTypeName, getTypeName, getUpdateStatement, getVersion, isIdentifierUppercaseWhenNotQuoted, isNegativeScaleAllowed, isTimeZoneSet, registerType, resolveColumnName, resolveMissingFields, shouldBindTimeWithTimeZoneAsDatabaseTimeZone, toIdentifier, toIdentifierMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface io.debezium.connector.jdbc.dialect.DatabaseDialect
getMaxTimePrecision, getTimeQueryBinding
-
Constructor Details
-
PostgresDatabaseDialect
private PostgresDatabaseDialect(JdbcSinkConnectorConfig config, org.hibernate.SessionFactory sessionFactory)
-
-
Method Details
-
getMaxTimestampPrecision
public int getMaxTimestampPrecision()Description copied from interface:DatabaseDialectGets the maximum precision allowed for a dialect's timestamp data type.- Returns:
- maximum timestamp precision
-
tableExists
Description copied from interface:DatabaseDialectCheck whether the specified table exists.- Specified by:
tableExistsin interfaceDatabaseDialect- Overrides:
tableExistsin classGeneralDatabaseDialect- Parameters:
connection- the database connection to be used, should not benull.tableId- the table identifier, should not benull.- Returns:
- true if the table exists, false otherwise
- Throws:
SQLException- if a database exception occurs
-
readTable
Description copied from interface:DatabaseDialectRead the table structure data from the database.- Specified by:
readTablein interfaceDatabaseDialect- Overrides:
readTablein classGeneralDatabaseDialect- Parameters:
connection- the database connection to be used, should not benull.tableId- the table identifier, should not benull.- Returns:
- the table relational model if it exists
- Throws:
SQLException- if the table does not exist or a database exception occurs
-
getAlterTablePrefix
Description copied from interface:DatabaseDialectGets the prefix used before adding column-clauses inALTER TABLEstatements.- Specified by:
getAlterTablePrefixin interfaceDatabaseDialect- Overrides:
getAlterTablePrefixin classGeneralDatabaseDialect- Returns:
- the alter table column-clauses prefix
-
getAlterTableSuffix
Description copied from interface:DatabaseDialectGets the suffix used after adding the column-clauses inALTER TABLEstatements.- Specified by:
getAlterTableSuffixin interfaceDatabaseDialect- Overrides:
getAlterTableSuffixin classGeneralDatabaseDialect- Returns:
- the alter table column-clauses suffix
-
getAlterTableColumnPrefix
Description copied from interface:DatabaseDialectGets the prefix used before adding each column-clause toALTER TABLEstatements.- Specified by:
getAlterTableColumnPrefixin interfaceDatabaseDialect- Overrides:
getAlterTableColumnPrefixin classGeneralDatabaseDialect- Returns:
- the alter table prefix just before each column-clause
-
getUpsertStatement
Description copied from interface:DatabaseDialectConstruct aUPSERTstatement specific for this dialect.- Specified by:
getUpsertStatementin interfaceDatabaseDialect- Overrides:
getUpsertStatementin classGeneralDatabaseDialect- Parameters:
table- the current relational table model, should not benullrecord- the current sink record being processed, should not benull- Returns:
- the upsert SQL statement to be executed, never
null
-
getQueryBindingWithValueCast
public String getQueryBindingWithValueCast(ColumnDescriptor column, org.apache.kafka.connect.data.Schema schema, Type type) Description copied from interface:DatabaseDialectReturns the SQL binding fragment for a column, schema, and type mapping.- Specified by:
getQueryBindingWithValueCastin interfaceDatabaseDialect- Overrides:
getQueryBindingWithValueCastin classGeneralDatabaseDialect- Parameters:
column- the relational column type, nevernullschema- the field schema type, nevernulltype- the resolved field type, nevernull- Returns:
- the query binding SQL fragment
-
getByteArrayFormat
Description copied from interface:DatabaseDialectReturns the default format for binding a byte array- Specified by:
getByteArrayFormatin interfaceDatabaseDialect- Overrides:
getByteArrayFormatin classGeneralDatabaseDialect- Returns:
- the format for binding a byte array
-
getFormattedBoolean
Description copied from interface:DatabaseDialectFormat a boolean.- Specified by:
getFormattedBooleanin interfaceDatabaseDialect- Overrides:
getFormattedBooleanin classGeneralDatabaseDialect- Parameters:
value- the boolean value- Returns:
- the formatted string value
-
getFormattedDateTimeWithNanos
Description copied from interface:DatabaseDialectFormat a date and time with nonoseconds.- Specified by:
getFormattedDateTimeWithNanosin interfaceDatabaseDialect- Overrides:
getFormattedDateTimeWithNanosin classGeneralDatabaseDialect- Parameters:
value- the value to be formatted, nevernull- Returns:
- the formatted string value
-
getFormattedTime
Description copied from interface:DatabaseDialectFormat a time.- Specified by:
getFormattedTimein interfaceDatabaseDialect- Overrides:
getFormattedTimein classGeneralDatabaseDialect- Parameters:
value- the value to be formatted, nevernull- Returns:
- the formatted string value
-
getDatabaseTimeZoneQuery
- Overrides:
getDatabaseTimeZoneQueryin classGeneralDatabaseDialect
-
registerTypes
protected void registerTypes()- Overrides:
registerTypesin classGeneralDatabaseDialect
-
getMaxVarcharLengthInKey
public int getMaxVarcharLengthInKey()Description copied from interface:DatabaseDialectGets the maximum length of a VARCHAR field in a primary key column.- Specified by:
getMaxVarcharLengthInKeyin interfaceDatabaseDialect- Overrides:
getMaxVarcharLengthInKeyin classGeneralDatabaseDialect- Returns:
- maximum varchar field length when participating in the primary key
-
resolveColumnNameFromField
- Overrides:
resolveColumnNameFromFieldin classGeneralDatabaseDialect
-