From: Johan Miller <johanmiller@gmail.com>
To: pgsql-jdbc@postgresql.org
Subject: Problem with java infinity mapping to postgres real column type
Date: Tue, 15 Jul 2008 08:54:41 +0300
Message-ID: <3713c3aa0807142254p72e8416dsd8c18a5ebf101212@mail.gmail.com> (raw)
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
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients from your mail client; the link fills in
the headers below: reply via email
Some clients, webmail especially, drop In-Reply-To and References from
a link, and the reply then starts a new thread: use the mbox below.
To: pgsql-jdbc@postgresql.org
Cc: johanmiller@gmail.com
Subject: Re: Problem with java infinity mapping to postgres real column type
In-Reply-To: <3713c3aa0807142254p72e8416dsd8c18a5ebf101212@mail.gmail.com>
References: <3713c3aa0807142254p72e8416dsd8c18a5ebf101212@mail.gmail.com>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox