Received: from localhost (unknown [200.46.204.183]) by postgresql.org (Postfix) with ESMTP id B87356504CB for ; Tue, 15 Jul 2008 02:54:47 -0300 (ADT) Received: from postgresql.org ([200.46.204.86]) by localhost (mx1.hub.org [200.46.204.183]) (amavisd-maia, port 10024) with ESMTP id 38055-09 for ; Tue, 15 Jul 2008 02:54:42 -0300 (ADT) X-Greylist: domain auto-whitelisted by SQLgrey-1.7.6 Received: from rv-out-0506.google.com (rv-out-0506.google.com [209.85.198.231]) by postgresql.org (Postfix) with ESMTP id 8569464FD04 for ; Tue, 15 Jul 2008 02:54:43 -0300 (ADT) Received: by rv-out-0506.google.com with SMTP id b25so6257318rvf.43 for ; Mon, 14 Jul 2008 22:54:42 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:received:message-id:date:from:to :subject:mime-version:content-type; bh=qoJlEtrvWVnAGN+At7nIh0Bqs2gZWLn77cvjGOM7FPo=; b=mt/+nbN1m/wdF2xnkS+croPtx8uBSqmwhezSPF7MEJaBKwM4R/fmPIw07O+UvW6lBM g5t8Y/N/KFwgh3y4sA+6IknKzPyRRVNFK4TJzcnm2IHCaM+qHzaW+nmx2zLXMV12/GMQ f8puMwYhKHwt4HbmrkFTC5+xNnplZoQVzgPLQ= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=message-id:date:from:to:subject:mime-version:content-type; b=WHbTtLIMNm4Hk6LAN2gAENcN1Z6yI5ZtyWZ89/APCzXvI89QNRyJoyJiOVIpjk2y2M T773IFWRsg9KlE3KWi2EekSVTAX4QVRGoHUDQWSeyIzGK/QduugL2gf5+SoMGMOgUGvz wGBABd5CutaZ6mMW9jTYn0f+053fxGAG6ALzM= Received: by 10.140.249.20 with SMTP id w20mr7163309rvh.21.1216101281803; Mon, 14 Jul 2008 22:54:41 -0700 (PDT) Received: by 10.141.210.9 with HTTP; Mon, 14 Jul 2008 22:54:41 -0700 (PDT) Message-ID: <3713c3aa0807142254p72e8416dsd8c18a5ebf101212@mail.gmail.com> Date: Tue, 15 Jul 2008 08:54:41 +0300 From: "Johan Miller" To: pgsql-jdbc@postgresql.org Subject: Problem with java infinity mapping to postgres real column type MIME-Version: 1.0 Content-Type: multipart/alternative; boundary="----=_Part_727_13562716.1216101281772" X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=0.001 tagged_above=0 required=5 tests=HTML_MESSAGE=0.001 X-Spam-Level: X-Archive-Number: 200807/35 X-Sequence-Number: 18820 ------=_Part_727_13562716.1216101281772 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Content-Disposition: inline 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 ------=_Part_727_13562716.1216101281772 Content-Type: text/html; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Content-Disposition: inline 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 ------=_Part_727_13562716.1216101281772--