Skip to content

Commit

Permalink
fix startup regressions caused by PR #1949. Instead of checking all t…
Browse files Browse the repository at this point in the history
…ypes 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
  • Loading branch information
davecramer committed Sep 21, 2021
1 parent 2917c1f commit 88cfcca
Showing 1 changed file with 20 additions and 1 deletion.
21 changes: 20 additions & 1 deletion pgjdbc/src/main/java/org/postgresql/jdbc/TypeInfoCache.java
Expand Up @@ -286,7 +286,26 @@ private PreparedStatement prepareGetTypeInfoStatement() throws SQLException {
}

public synchronized int getSQLType(String pgTypeName) throws SQLException {
return getSQLType(castNonNull(getPGType(pgTypeName)));
/*
Get a few things out of the way such as arrays and known types
*/
if (pgTypeName.endsWith("[]")) {
return Types.ARRAY;
}
Integer i = this.pgNameToSQLType.get(pgTypeName);
if (i != null) {
return i;
}

/*
All else fails then we will query the database.
save for future calls
*/
i = getSQLType(castNonNull(getPGType(pgTypeName)));

pgNameToSQLType.put(pgTypeName, i);
return i;

}

public synchronized int getSQLType(int typeOid) throws SQLException {
Expand Down

0 comments on commit 88cfcca

Please sign in to comment.