Skip to content

Commit 88cfcca

Browse files
authored
fix startup regressions caused by PR #1949. Instead of checking all types by OID, we can return types for well known types (#2257)
* fix startup regressions caused by PR #1949. Instead of checking all types by OID, we can return types for well known types * clarifiy code, add any new types to the pgNameToSQLType cache
1 parent 2917c1f commit 88cfcca

File tree

1 file changed

+20
-1
lines changed

1 file changed

+20
-1
lines changed

pgjdbc/src/main/java/org/postgresql/jdbc/TypeInfoCache.java

+20-1
Original file line numberDiff line numberDiff line change
@@ -286,7 +286,26 @@ private PreparedStatement prepareGetTypeInfoStatement() throws SQLException {
286286
}
287287

288288
public synchronized int getSQLType(String pgTypeName) throws SQLException {
289-
return getSQLType(castNonNull(getPGType(pgTypeName)));
289+
/*
290+
Get a few things out of the way such as arrays and known types
291+
*/
292+
if (pgTypeName.endsWith("[]")) {
293+
return Types.ARRAY;
294+
}
295+
Integer i = this.pgNameToSQLType.get(pgTypeName);
296+
if (i != null) {
297+
return i;
298+
}
299+
300+
/*
301+
All else fails then we will query the database.
302+
save for future calls
303+
*/
304+
i = getSQLType(castNonNull(getPGType(pgTypeName)));
305+
306+
pgNameToSQLType.put(pgTypeName, i);
307+
return i;
308+
290309
}
291310

292311
public synchronized int getSQLType(int typeOid) throws SQLException {

0 commit comments

Comments
 (0)