pg.ddx.io  pgsql-jdbc@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Kris Jurka <books@ejurka.com>
To: Peter <peter@greatnowhere.com>
Cc: pgsql-jdbc@postgresql.org
Subject: Re: numeric type
Date: Tue, 29 Jul 2008 00:17:26 -0400 (EDT)
Message-ID: <Pine.BSO.4.64.0807290011180.2814@leary.csoft.net> (raw)
In-Reply-To: <005b01c8ea53$f64a9fd0$e2dfdf70$@com>
References: <005b01c8ea53$f64a9fd0$e2dfdf70$@com>



On Sun, 20 Jul 2008, Peter wrote:

> For numeric types (with no explicit scale and precision) JDBC returns 0 for
> both precision and scale (ResultSetMetaData.getPrecision and getScale
> methods). This is breaking my app and IMO does not reflect true state of
> things since Postgres docs state: "NUMERIC without any precision or scale
> creates a column in which numeric values of any precision and scale can be
> stored, up to the implementation limit on precision".
>
> Shouldn't PG JDBC driver return maximum possible values for precision and
> scale in such cases?
>

There are a couple of issues here:

1) While PG supports larger numeric values, the maximum precision you can 
constrain it to is 1000.

jurka=# create temp table tt (a numeric (1001, 1));
ERROR:  NUMERIC precision 1001 must be between 1 and 1000

So do you return 1000 as the maximum precision because that's the maximum 
that they can pass into create table even if they might actually receive a 
value back that has a higher precision?  Or do you return something larger 
(the internal pg limit which I don't know offhand) even though they can't 
create a table column with that limit?

2) Once you've set the maximum precision, how do you set the maximum 
scale as the scale is a dependent on the precision.  Is it (1000,500) ? 
(1000, 0)? (1000, 1000)?

What we do now certainly isn't all that great, but I haven't heard a 
concrete suggestion on what's better.

Kris Jurka




view thread (10+ messages)  latest in thread

Message-ID: <Pine.BSO.4.64.0807290011180.2814@leary.csoft.net>
Permalink:  ../Pine.BSO.4.64.0807290011180.2814@leary.csoft.net/
Also on:    postgresql.org/message-id/Pine.BSO.4.64.0807290011180.2814@leary.csoft.net

 · 

reply

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: books@ejurka.com, peter@greatnowhere.com
  Subject: Re: numeric type
  In-Reply-To: <Pine.BSO.4.64.0807290011180.2814@leary.csoft.net>
  References: <005b01c8ea53$f64a9fd0$e2dfdf70$@com> <Pine.BSO.4.64.0807290011180.2814@leary.csoft.net>

* 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