Package io.debezium.connector.postgresql
Class TypeRegistry.SqlTypeMapper
- java.lang.Object
-
- io.debezium.connector.postgresql.TypeRegistry.SqlTypeMapper
-
- Enclosing class:
- TypeRegistry
private static class TypeRegistry.SqlTypeMapper extends Object
Allows to obtain the SQL type corresponding to PG types. This uses a custom statement instead of going throughPgDatabaseMetaData.getTypeInfo()as the latter causes N+1 SELECTs, making it very slow on installations with many custom types.- Author:
- Gunnar Morling
-
-
Field Summary
Fields Modifier and Type Field Description private Set<String>preloadedSqlTypesprivate static StringSQL_TYPE_DETAILSBased on org.postgresql.jdbc.TypeInfoCache.getSQLType(String).private Map<String,Integer>sqlTypesByPgTypeNamesprivate org.postgresql.core.TypeInfotypeInfo
-
Constructor Summary
Constructors Modifier Constructor Description privateSqlTypeMapper(Connection db, org.postgresql.core.TypeInfo typeInfo)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description intgetSqlType(String typeName)private static Map<String,Integer>getSqlTypes(Connection db, org.postgresql.core.TypeInfo typeInfo)Builds up a map of SQL (JDBC) types by PG type name; contains only values for non-core types.
-
-
-
Field Detail
-
SQL_TYPE_DETAILS
private static final String SQL_TYPE_DETAILS
Based on org.postgresql.jdbc.TypeInfoCache.getSQLType(String). To emulate the original statement's behavior (which works for single types only), PG's DISTINCT ON extension is used to just return the first entry should a type exist in multiple schemas.- See Also:
- Constant Field Values
-
typeInfo
private final org.postgresql.core.TypeInfo typeInfo
-
preloadedSqlTypes
@Immutable private final Set<String> preloadedSqlTypes
-
sqlTypesByPgTypeNames
@Immutable private final Map<String,Integer> sqlTypesByPgTypeNames
-
-
Constructor Detail
-
SqlTypeMapper
private SqlTypeMapper(Connection db, org.postgresql.core.TypeInfo typeInfo) throws SQLException
- Throws:
SQLException
-
-
Method Detail
-
getSqlType
public int getSqlType(String typeName) throws SQLException
- Throws:
SQLException
-
getSqlTypes
private static Map<String,Integer> getSqlTypes(Connection db, org.postgresql.core.TypeInfo typeInfo) throws SQLException
Builds up a map of SQL (JDBC) types by PG type name; contains only values for non-core types.- Throws:
SQLException
-
-