diff options
author | Marc G. Fournier | 1998-04-18 18:32:44 +0000 |
---|---|---|
committer | Marc G. Fournier | 1998-04-18 18:32:44 +0000 |
commit | b542fa1a6e838d3e32857cdfbe8aeff940a91c74 (patch) | |
tree | c9a93d39e6a88df94b25cdb336b7a95a14665116 /src/interfaces/jdbc/postgresql/Field.java | |
parent | 87d96ed6725c5a95ca618937f6fdd762b599b9e9 (diff) |
From: Peter T Mount <[email protected]>REL6_3_2
This fixes a problem in ResultSet.getDate() when the column is NULL
(reported by Vincent Partington <[email protected]>)
And fixes a problem with Field's (ResultSet.getObject() was proving to be
slow as it repetedly send queries for oid -> name mapping - fixed by
creating a cache. (reported by Mario Ellebrecht <[email protected]>)
Diffstat (limited to 'src/interfaces/jdbc/postgresql/Field.java')
-rw-r--r-- | src/interfaces/jdbc/postgresql/Field.java | 20 |
1 files changed, 14 insertions, 6 deletions
diff --git a/src/interfaces/jdbc/postgresql/Field.java b/src/interfaces/jdbc/postgresql/Field.java index dd8918e99b7..b39aab20c15 100644 --- a/src/interfaces/jdbc/postgresql/Field.java +++ b/src/interfaces/jdbc/postgresql/Field.java @@ -54,13 +54,21 @@ public class Field public int getSQLType() throws SQLException { if(sql_type == -1) { - ResultSet result = (postgresql.ResultSet)conn.ExecSQL("select typname from pg_type where oid = " + oid); - if (result.getColumnCount() != 1 || result.getTupleCount() != 1) - throw new SQLException("Unexpected return from query for type"); - result.next(); - type_name = result.getString(1); + type_name = (String)conn.fieldCache.get(new Integer(oid)); + + // it's not in the cache, so perform a query, and add the result to + // the cache + if(type_name==null) { + ResultSet result = (postgresql.ResultSet)conn.ExecSQL("select typname from pg_type where oid = " + oid); + if (result.getColumnCount() != 1 || result.getTupleCount() != 1) + throw new SQLException("Unexpected return from query for type"); + result.next(); + type_name = result.getString(1); + conn.fieldCache.put(new Integer(oid),type_name); + result.close(); + } + sql_type = getSQLType(type_name); - result.close(); } return sql_type; } |