Received: from localhost (unknown [200.46.204.183]) by postgresql.org (Postfix) with ESMTP id 20C7F64FCED for ; Tue, 29 Jul 2008 01:20:01 -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 64612-04-5 for ; Tue, 29 Jul 2008 01:19:40 -0300 (ADT) X-Greylist: from auto-whitelisted by SQLgrey-1.7.6 Received: from mail63.csoft.net (leary.csoft.net [205.205.214.5]) by postgresql.org (Postfix) with SMTP id 963AD650119 for ; Tue, 29 Jul 2008 01:17:27 -0300 (ADT) Received: (qmail 13094 invoked by uid 1112); 29 Jul 2008 04:17:26 -0000 Date: Tue, 29 Jul 2008 00:17:26 -0400 (EDT) From: Kris Jurka X-X-Sender: books@leary.csoft.net To: Peter cc: pgsql-jdbc@postgresql.org Subject: Re: numeric type In-Reply-To: <005b01c8ea53$f64a9fd0$e2dfdf70$@com> Message-ID: References: <005b01c8ea53$f64a9fd0$e2dfdf70$@com> MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII; format=flowed X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=0 tagged_above=0 required=5 tests=none X-Spam-Level: X-Archive-Number: 200807/57 X-Sequence-Number: 18842 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