Problem with java infinity mapping to postgres real column type

From: "Johan Miller" <johanmiller(at)gmail(dot)com>
To: pgsql-jdbc(at)postgresql(dot)org
Subject: Problem with java infinity mapping to postgres real column type
Date: 2008-07-15 05:54:41
Message-ID: 3713c3aa0807142254p72e8416dsd8c18a5ebf101212@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-jdbc

Hi,

I have searched the mail archives at the postgres site but have not come up
with anything that addresses this particular issue.
I have found that when trying to insert a Java Float.POSITIVE_INFINITY or
its negative counterpart into a database column with data type real using a
jdbc driver 8.1-406 or 8.2-504 postgres will throw an overflow error.
Since both Java and Postgres real data type support infinity then this seems
very strange.

After some testing I found that the situation described above does not throw
an error using a jdbc driver 8.0-310. After some more debugging it seems
that this is caused by the Oid type being used for float input. The 8.0
driver uses Oid.FLOAT4 but the 8.1 and 8.2 drivers both use Oid.FLOAT8
(AbstractJdbc2Statement.java setFloat()). I also found that it is possible
to insert inifinity into a column with data type real if the setObject
function is used with the targetSqlType being REAL since this data type uses
Oid.FLOAT4.

What would be the best practice in this situation?
This did not seem a problem when using the double precision column data
type. Althouh it seems a little extreme to have to convert a column data
type to accomodate a few values that can not be inserted correctly. How much
would a tables size increase if a real data type is converted to a double
precision?

--
Johan Miller

Responses

Browse pgsql-jdbc by date

  From Date Subject
Next Message quintesse 2008-07-15 12:36:30 And once again getGeneratedKeys()
Previous Message Sreeraj Pillai 2008-07-11 16:42:11 Re: Schema in URL