use of org.postgresql.core.TypeInfo in project debezium by debezium.
the class PostgresConnection method initTypeRegistry.
private static TypeRegistry initTypeRegistry(Connection db, Map<String, Integer> nameToJdbc) {
final TypeInfo typeInfo = ((BaseConnection) db).getTypeInfo();
TypeRegistry.Builder typeRegistryBuilder = TypeRegistry.create(typeInfo);
try {
try (final Statement statement = db.createStatement()) {
// Read non-array types
try (final ResultSet rs = statement.executeQuery(SQL_NON_ARRAY_TYPES)) {
while (rs.next()) {
final int oid = rs.getInt("oid");
typeRegistryBuilder.addType(new PostgresType(rs.getString("name"), oid, nameToJdbc.get(rs.getString("name")), typeInfo));
}
}
// Read array types
try (final ResultSet rs = statement.executeQuery(SQL_ARRAY_TYPES)) {
while (rs.next()) {
// int2vector and oidvector will not be treated as arrays
final int oid = rs.getInt("oid");
typeRegistryBuilder.addType(new PostgresType(rs.getString("name"), oid, nameToJdbc.get(rs.getString("name")), typeInfo, typeRegistryBuilder.get(rs.getInt("element"))));
}
}
}
} catch (SQLException e) {
throw new ConnectException("Could not intialize type registry", e);
}
return typeRegistryBuilder.build();
}
Aggregations