Re: maximum digits for NUMERIC

From: Gianni Ciolli <gianni(dot)ciolli(at)2ndquadrant(dot)it>
To: Noah Misch <noah(at)leadboat(dot)com>
Cc: pgsql-hackers(at)postgresql(dot)org
Subject: Re: maximum digits for NUMERIC
Date: 2011-03-25 08:46:17
Message-ID: 20110325084616.GA4058@albo.gi.lan
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Sun, Mar 20, 2011 at 08:14:21PM -0400, Noah Misch wrote:
> On Fri, Mar 11, 2011 at 11:36:14AM +0000, Gianni Ciolli wrote:
> > maybe we should change the "1000 digits" here:
> >
> > http://developer.postgresql.org/pgdocs/postgres/datatype-numeric.html#DATATYPE-NUMERIC-DECIMAL
> >
> > because ISTM that up to 2^17 digits are supported (which makes more
> > sense than 1000).
>
> Agreed. The documentation is suggestive of this limit:
>
> # CREATE TABLE n (c numeric(1001,0));
> ERROR: NUMERIC precision 1001 must be between 1 and 1000
> LINE 1: CREATE TABLE n (c numeric(1001,0));
>
> However, that's indeed just a limit of the numeric typmod representation, not
> the data type itself. An unqualified "numeric" column hits no such limit.

For the record, the limits I found from my tests are:
* 2^17 - 1 maximum total digits
* 2^14 - 1 maximum fractional digits

(I did tests as I couldn't extract any obvious limit from the source
code of numeric.c)

Best regards,
Dr. Gianni Ciolli - 2ndQuadrant Italia
PostgreSQL Training, Services and Support
gianni(dot)ciolli(at)2ndquadrant(dot)it | www.2ndquadrant.it

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Fujii Masao 2011-03-25 09:03:16 Re: Re: making write location work (was: Efficient transaction-controlled synchronous replication)
Previous Message Heikki Linnakangas 2011-03-25 08:09:42 Re: Pre-set Hint bits/VACUUM FREEZE on data load..?