Skip site navigation (1) Skip section navigation (2)

Re: data set combination of integer and decimal/numeric returns wrong result type

From: Craig Ringer <ringerc(at)ringerc(dot)id(dot)au>
To: the6campbells <the6campbells(at)gmail(dot)com>
Cc: pgsql-jdbc(at)postgresql(dot)org
Subject: Re: data set combination of integer and decimal/numeric returns wrong result type
Date: 2012-10-02 03:56:10
Message-ID: 506A65DA.5000500@ringerc.id.au (view raw or flat)
Thread:
Lists: pgsql-jdbc
On 10/02/2012 01:47 AM, the6campbells wrote:
> The test case can be shown with one table that contains a column for
> each supported Postgres type that maps to ISO-SQL or one table per type.
> This example compares an integer and a precise numeric type.

OK, so your issue is that PgJDBC reports zero scale and precision for 
numerics as results when the numeric didn't come directly from a column 
with defined scale and precision. Right?

If so, this has nothing to do with integer combinations, it's *any* 
operation on numeric. It isn't a JDBC driver issue as such, it's the 
behaviour of the underlying PostgreSQL backend.

Witness:

regress=# CREATE TABLE plain AS SELECT NUMERIC(6,4) '12.345678' ;
SELECT 1
regress=# CREATE TABLE modified AS SELECT ABS(NUMERIC(6,4) '12.345678') ;
SELECT 1

regress=# \d plain
         Table "public.plain"
  Column  |     Type     | Modifiers
---------+--------------+-----------
  numeric | numeric(6,4) |

regress=# \d modified
    Table "public.modified"
  Column |  Type   | Modifiers
--------+---------+-----------
  abs    | numeric |



As such there isn't tons the JDBC driver can do about it. The scale and 
precision aren't preserved in results, so the JDBC driver has no way to 
obtain them.

Would it be better if PgJDBC reported these numerics as having the 
maximum supported size?


--
Craig Ringer



In response to

pgsql-jdbc by date

Next:From: Craig RingerDate: 2012-10-02 14:26:57
Subject: Re: ResultSet metadata for a prepared statement missing the applicable table, schema etc properties
Previous:From: Craig RingerDate: 2012-10-02 01:33:24
Subject: Re: Re: Not able to insert array of integers into column of type integer array

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group