Skip to content

Commit d42f9b5

Browse files
committed
Here is a patch for interfaces/jdbc/org/postgresql/jdbc2/ResultSet.java
It addresses three issues: 1. The problem with ResultSet's interface specifying 1-based indexing was not quite fixed in 7.0.2. absolute would stop the user form moving to the first record (record 0 internally). 2. Absolute did not set current_row 3. For field.mod=-1, GetObject would try to return numeric values with a precision of around 65000. Now GetObject detects when field.mod==-1, and passes that as the scale to getBigDecimal. getBigDecimal detects when a -1 is passed and simply does not scale the value returned. You still get the correct value back, it simply does not tweak the precision. I'm working off of a source tree I just checked out from the repository. The diff is based on what was in the repository about ten minutes ago. ---------------------------------------------------------------- Travis Bauer | CS Grad Student | IU |www.cs.indiana.edu/~trbauer ----------------------------------------------------------------
1 parent 00156fa commit d42f9b5

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

src/interfaces/jdbc/org/postgresql/jdbc2/ResultSet.java

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -347,6 +347,7 @@ public BigDecimal getBigDecimal(int columnIndex, int scale) throws SQLException
347347
} catch (NumberFormatException e) {
348348
throw new PSQLException ("postgresql.res.badbigdec",s);
349349
}
350+
if (scale==-1) return val;
350351
try
351352
{
352353
return val.setScale(scale);
@@ -739,7 +740,8 @@ public Object getObject(int columnIndex) throws SQLException
739740
case Types.BIGINT:
740741
return new Long(getLong(columnIndex));
741742
case Types.NUMERIC:
742-
return getBigDecimal(columnIndex, ((field.mod-4) & 0xffff));
743+
return getBigDecimal
744+
(columnIndex, (field.mod==-1)?-1:((field.mod-4) & 0xffff));
743745
case Types.REAL:
744746
return new Float(getFloat(columnIndex));
745747
case Types.DOUBLE:
@@ -804,9 +806,10 @@ public boolean absolute(int index) throws SQLException
804806
if(index<0)
805807
index=rows.size()+index;
806808

807-
if (index==0 || index > rows.size())
809+
if (index > rows.size())
808810
return false;
809811

812+
current_row=index;
810813
this_row = (byte [][])rows.elementAt(index);
811814
return true;
812815
}

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy