From: Craig Ringer <ringerc@ringerc.id.au>
To: the6campbells <the6campbells@gmail.com>
Cc: pgsql-jdbc@postgresql.org
Subject: Re: data set combination of integer and decimal/numeric returns wrong result type
Date: Tue, 02 Oct 2012 11:56:10 +0800
Message-ID: <506A65DA.5000500@ringerc.id.au> (raw)
In-Reply-To: <CAFEjsq4Qc=nf=FO0iAGWZd7oAtxt11pnt7eUsxv1T_wpe=EMHw@mail.gmail.com>
References: <CAFEjsq4oeM25e=7Tn1X2Fe2RLMsDBqp7h9iU6Fu9nxd+ibXEng@mail.gmail.com>
<50662D84.90202@ringerc.id.au>
<CAFEjsq7RmOJnnC2YSG7-Aj3_CYs5E6qc1=NUTZR+VsqwVSPgmw@mail.gmail.com>
<5069867E.80208@ringerc.id.au>
<CAFEjsq4Qc=nf=FO0iAGWZd7oAtxt11pnt7eUsxv1T_wpe=EMHw@mail.gmail.com>
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
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: ringerc@ringerc.id.au, the6campbells@gmail.com
Subject: Re: data set combination of integer and decimal/numeric returns wrong result type
In-Reply-To: <506A65DA.5000500@ringerc.id.au>
References: <CAFEjsq4oeM25e=7Tn1X2Fe2RLMsDBqp7h9iU6Fu9nxd+ibXEng@mail.gmail.com> <50662D84.90202@ringerc.id.au> <CAFEjsq7RmOJnnC2YSG7-Aj3_CYs5E6qc1=NUTZR+VsqwVSPgmw@mail.gmail.com> <5069867E.80208@ringerc.id.au> <CAFEjsq4Qc=nf=FO0iAGWZd7oAtxt11pnt7eUsxv1T_wpe=EMHw@mail.gmail.com> <506A65DA.5000500@ringerc.id.au>
* 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