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
Views: Raw Message | Whole Thread | Download mbox | Resend email
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

Browse pgsql-jdbc by date

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