Received: from localhost (unknown [200.46.204.183]) by postgresql.org (Postfix) with ESMTP id D563C64FCEA for ; Tue, 29 Jul 2008 04:38:06 -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 45100-02 for ; Tue, 29 Jul 2008 04:37:56 -0300 (ADT) X-Greylist: from auto-whitelisted by SQLgrey-1.7.6 Received: from mail2.fintrading.com (mail.fintrading.com [195.2.100.100]) by postgresql.org (Postfix) with ESMTP id 0B97C64FD02 for ; Tue, 29 Jul 2008 04:37:59 -0300 (ADT) Received: from chipmunk (unknown [81.198.70.254]) by mail2.fintrading.com (Postfix) with ESMTP id D115A3807B53; Tue, 29 Jul 2008 10:37:26 +0300 (EEST) From: "Peter" To: "'Kris Jurka'" Cc: References: <005b01c8ea53$f64a9fd0$e2dfdf70$@com> In-Reply-To: Subject: Re: numeric type Date: Tue, 29 Jul 2008 10:36:24 +0300 Message-ID: <001d01c8f14d$cdd715a0$698540e0$@com> MIME-Version: 1.0 Content-Type: text/plain; charset="US-ASCII" Content-Transfer-Encoding: 7bit X-Mailer: Microsoft Office Outlook 12.0 Thread-Index: AcjxMgLvQ6CU2YSjQ7W5MjCFo4x7EAAGwh3w Content-Language: en-us X-greatnowhere.com-MailScanner: Found to be clean X-greatnowhere.com-MailScanner-SpamCheck: not spam, SpamAssassin (not cached, score=-4.9, required 6, BAYES_00 -5.00, RDNS_NONE 0.10) X-greatnowhere.com-MailScanner-From: peter@greatnowhere.com 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/61 X-Sequence-Number: 18846 >> 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? > What we do now certainly isn't all that great, but I haven't heard a > concrete suggestion on what's better. OK, I hear ya. How about allowing user to set the default precision and scale values for "numeric" type? Not sure how this would be done in JDBC world but should be doable. IMO a reasonable default maxing out both precision and scale (1000,500) should work for most applications. Numeric type is not all that common anyway. Peter