Package io.debezium.connector.postgresql
Class TypeRegistry
- java.lang.Object
-
- io.debezium.connector.postgresql.TypeRegistry
-
public class TypeRegistry extends Object
A registry of types supported by a PostgreSQL instance. Allows lookup of the types according to type name or OID.- Author:
- Jiri Pechanec
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description private static classTypeRegistry.SqlTypeMapperAllows to obtain the SQL type corresponding to PG types.
-
Field Summary
-
Constructor Summary
Constructors Constructor Description TypeRegistry(PostgresConnection connection)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description private voidaddType(PostgresType type)intcitextArrayOid()intcitextOid()private PostgresType.BuildercreateTypeBuilderFromResultSet(ResultSet rs)intgeographyArrayOid()intgeographyOid()intgeometryArrayOid()intgeometryOid()PostgresTypeget(int oid)PostgresTypeget(String name)private static Map<String,String>getLongTypeNames()inthstoreArrayOid()inthstoreOid()private PostgresTypeloadType(PreparedStatement statement)intltreeArrayOid()intltreeOid()static StringnormalizeTypeName(String typeName)Converts a type name in long (readable) format likebooleanto s standard data type name likebool.private voidprime()Prime theTypeRegistrywith all existing database typesprivate PostgresTyperesolveUnknownType(int lookupOid)private PostgresTyperesolveUnknownType(String name)
-
-
-
Field Detail
-
LOGGER
private static final org.slf4j.Logger LOGGER
-
TYPE_NAME_GEOGRAPHY
public static final String TYPE_NAME_GEOGRAPHY
- See Also:
- Constant Field Values
-
TYPE_NAME_GEOMETRY
public static final String TYPE_NAME_GEOMETRY
- See Also:
- Constant Field Values
-
TYPE_NAME_CITEXT
public static final String TYPE_NAME_CITEXT
- See Also:
- Constant Field Values
-
TYPE_NAME_HSTORE
public static final String TYPE_NAME_HSTORE
- See Also:
- Constant Field Values
-
TYPE_NAME_LTREE
public static final String TYPE_NAME_LTREE
- See Also:
- Constant Field Values
-
TYPE_NAME_HSTORE_ARRAY
public static final String TYPE_NAME_HSTORE_ARRAY
- See Also:
- Constant Field Values
-
TYPE_NAME_GEOGRAPHY_ARRAY
public static final String TYPE_NAME_GEOGRAPHY_ARRAY
- See Also:
- Constant Field Values
-
TYPE_NAME_GEOMETRY_ARRAY
public static final String TYPE_NAME_GEOMETRY_ARRAY
- See Also:
- Constant Field Values
-
TYPE_NAME_CITEXT_ARRAY
public static final String TYPE_NAME_CITEXT_ARRAY
- See Also:
- Constant Field Values
-
TYPE_NAME_LTREE_ARRAY
public static final String TYPE_NAME_LTREE_ARRAY
- See Also:
- Constant Field Values
-
NO_TYPE_MODIFIER
public static final int NO_TYPE_MODIFIER
- See Also:
- Constant Field Values
-
UNKNOWN_LENGTH
public static final int UNKNOWN_LENGTH
- See Also:
- Constant Field Values
-
DOMAIN_TYPE
public static final int DOMAIN_TYPE
- See Also:
- Constant Field Values
-
CATEGORY_ARRAY
private static final String CATEGORY_ARRAY
- See Also:
- Constant Field Values
-
CATEGORY_ENUM
private static final String CATEGORY_ENUM
- See Also:
- Constant Field Values
-
SQL_ENUM_VALUES
private static final String SQL_ENUM_VALUES
- See Also:
- Constant Field Values
-
SQL_TYPES
private static final String SQL_TYPES
- See Also:
- Constant Field Values
-
SQL_NAME_LOOKUP
private static final String SQL_NAME_LOOKUP
- See Also:
- Constant Field Values
-
SQL_OID_LOOKUP
private static final String SQL_OID_LOOKUP
- See Also:
- Constant Field Values
-
nameToType
private final Map<String,PostgresType> nameToType
-
oidToType
private final Map<Integer,PostgresType> oidToType
-
connection
private final Connection connection
-
typeInfo
private final org.postgresql.core.TypeInfo typeInfo
-
sqlTypeMapper
private final TypeRegistry.SqlTypeMapper sqlTypeMapper
-
geometryOid
private int geometryOid
-
geographyOid
private int geographyOid
-
citextOid
private int citextOid
-
hstoreOid
private int hstoreOid
-
ltreeOid
private int ltreeOid
-
hstoreArrayOid
private int hstoreArrayOid
-
geometryArrayOid
private int geometryArrayOid
-
geographyArrayOid
private int geographyArrayOid
-
citextArrayOid
private int citextArrayOid
-
ltreeArrayOid
private int ltreeArrayOid
-
-
Constructor Detail
-
TypeRegistry
public TypeRegistry(PostgresConnection connection)
-
-
Method Detail
-
addType
private void addType(PostgresType type)
-
get
public PostgresType get(int oid)
- Parameters:
oid- - PostgreSQL OID- Returns:
- type associated with the given OID
-
get
public PostgresType get(String name)
- Parameters:
name- - PostgreSQL type name- Returns:
- type associated with the given type name
-
geometryOid
public int geometryOid()
- Returns:
- OID for
GEOMETRYtype of this PostgreSQL instance
-
geographyOid
public int geographyOid()
- Returns:
- OID for
GEOGRAPHYtype of this PostgreSQL instance
-
citextOid
public int citextOid()
- Returns:
- OID for
CITEXTtype of this PostgreSQL instance
-
hstoreOid
public int hstoreOid()
- Returns:
- OID for
HSTOREtype of this PostgreSQL instance
-
ltreeOid
public int ltreeOid()
- Returns:
- OID for
LTREEtype of this PostgreSQL instance
-
hstoreArrayOid
public int hstoreArrayOid()
- Returns:
- OID for array of
HSTOREtype of this PostgreSQL instance
-
geometryArrayOid
public int geometryArrayOid()
- Returns:
- OID for array of
GEOMETRYtype of this PostgreSQL instance
-
geographyArrayOid
public int geographyArrayOid()
- Returns:
- OID for array of
GEOGRAPHYtype of this PostgreSQL instance
-
citextArrayOid
public int citextArrayOid()
- Returns:
- OID for array of
CITEXTtype of this PostgreSQL instance
-
ltreeArrayOid
public int ltreeArrayOid()
- Returns:
- OID for array of
LTREEtype of this PostgreSQL instance
-
normalizeTypeName
public static String normalizeTypeName(String typeName)
Converts a type name in long (readable) format likebooleanto s standard data type name likebool.- Parameters:
typeName- - a type name in long format- Returns:
- - the type name in standardized format
-
prime
private void prime() throws SQLExceptionPrime theTypeRegistrywith all existing database types- Throws:
SQLException
-
createTypeBuilderFromResultSet
private PostgresType.Builder createTypeBuilderFromResultSet(ResultSet rs) throws SQLException
- Throws:
SQLException
-
resolveUnknownType
private PostgresType resolveUnknownType(String name)
-
resolveUnknownType
private PostgresType resolveUnknownType(int lookupOid)
-
loadType
private PostgresType loadType(PreparedStatement statement) throws SQLException
- Throws:
SQLException
-
-