Bug 149552 - ResultSet.getInt alters numbers >= 2^24
Summary: ResultSet.getInt alters numbers >= 2^24
Keywords:
Status: CLOSED ERRATA
Alias: None
Product: Red Hat Enterprise Linux 3
Classification: Red Hat
Component: postgresql
Version: 3.0
Hardware: All
OS: Linux
medium
medium
Target Milestone: ---
Assignee: Tom Lane
QA Contact: David Lawrence
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2005-02-23 22:23 UTC by Nathan Bronson
Modified: 2013-07-03 03:03 UTC (History)
1 user (show)

Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Clone Of:
Environment:
Last Closed: 2005-02-24 01:19:30 UTC
Target Upstream Version:
Embargoed:


Attachments (Terms of Use)

Description Nathan Bronson 2005-02-23 22:23:40 UTC
Description of problem:

  ResultSet.getInt loses precision for values larger than 2^24.

Version-Release number of selected component (if applicable):

  7.3.4-9

How reproducible:

  Every time.

Steps to Reproduce:

  Use the JDBC driver to select an int4 column containing the value
  16777217, retrieve it with ResultSet.getInt(1), and observe that
  the returned value is 16777216.
  
Actual results:

  Returned int is 16777216.

Expected results:

  Returned int is 16777217.

Additional info:

  org.postgresql.jdbc1.AbstractJdbc1ResultSet.toInt(String) parses
  string values by converting to a Float and then rounding to an
  int.  Float cannot exactly represent 16777217 (and many other
  useful values of int4).  A similar bug exists in the toLong method
  for large values of long.  Appears to be fixed in 7.3.9 and 7.4.6,
  but it should be documented somewhere that the 7.3.4 driver is
  fundamentally flawed.

Comment 1 Tom Lane 2005-02-23 23:24:44 UTC
Since we're already shipping 7.3.9 as a security erratum for RHEL3,
shouldn't I just close this report as RESOLVED ERRATA?  AFAIK there
isn't any place to document historical bugs.  Or were you just
interested in creating a bugzilla entry for it?

Comment 2 Nathan Bronson 2005-02-24 01:06:56 UTC
Yes, I was just trying to create a bugzilla entry, as it would have
saved me a day of work.  There may be others out there who haven't
upgraded to the latest version yet or who are trying to balance the
risk of an upgrade against the risk of not applying the errata.

Comment 3 Tom Lane 2005-02-24 01:19:30 UTC
Fair enough, though we seldom try to make bugzilla entries for every
single upstream patch included in an update ...


Note You need to log in before you can comment on or make changes to this bug.