Permalink
Browse files

perf: optimize getBigDecimal

  • Loading branch information...
vlsi committed Oct 30, 2015
1 parent 567e268 commit 33904ef00aa545b8a8997e62d0e5da58ea9348de
Showing with 17 additions and 1 deletion.
  1. +17 −1 org/postgresql/jdbc2/AbstractJdbc2ResultSet.java
@@ -2447,6 +2447,18 @@ public BigDecimal getBigDecimal(int columnIndex, int scale) throws SQLException
checkResultSet(columnIndex);
if (wasNullFlag)
return null;
if (isBinary(columnIndex)) {
int sqlType = getSQLType(columnIndex);
if (sqlType != Types.NUMERIC && sqlType != Types.DECIMAL) {
Object obj = internalGetObject(columnIndex, fields[columnIndex - 1]);
if (obj == null) return null;
if (obj instanceof Long || obj instanceof Integer || obj instanceof Byte) {
return BigDecimal.valueOf(((Number) obj).longValue(), scale);
}
return toBigDecimal(trimMoney(String.valueOf(obj)), scale);
}
}
Encoding encoding = connection.getEncoding();
if (encoding.hasAsciiNumbers()) {
@@ -2848,7 +2860,11 @@ public int getColumnOID(int field)
*/
public String getFixedString(int col) throws SQLException
{
String s = getString(col);
return trimMoney(getString(col));
}
private String trimMoney(String s)
{
if (s == null)
return null;

0 comments on commit 33904ef

Please sign in to comment.