On Fri, Mar 25, 2011 at 08:46:17AM +0000, Gianni Ciolli wrote:
> On Sun, Mar 20, 2011 at 08:14:21PM -0400, Noah Misch wrote:
> > 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)

The attached patch resumes this short discussion.

Best regards,
Dr. Gianni Ciolli - 2ndQuadrant Italia
PostgreSQL Training, Services and Support
gianni.cio...@2ndquadrant.it | www.2ndquadrant.it
diff --git a/doc/src/sgml/datatype.sgml b/doc/src/sgml/datatype.sgml
index 0bb6594..259523d 100644
--- a/doc/src/sgml/datatype.sgml
+++ b/doc/src/sgml/datatype.sgml
@@ -476,7 +476,7 @@
     </indexterm>
 
     <para>
-     The type <type>numeric</type> can store numbers with up to 1000
+     The type <type>numeric</type> can store numbers with up to 131071
      digits of precision and perform calculations exactly. It is
      especially recommended for storing monetary amounts and other
      quantities where exactness is required. However, arithmetic on
@@ -493,7 +493,7 @@
      the whole number, that is, the number of digits to both sides of
      the decimal point.  So the number 23.5141 has a precision of 6
      and a scale of 4.  Integers can be considered to have a scale of
-     zero.
+     zero. The maximum allowed scale is 16383.
     </para>
 
     <para>
@@ -525,6 +525,15 @@ NUMERIC
      explicitly.)
     </para>
 
+    <note>
+     <para>
+      The maximum allowed precision when explicitely specified in the
+      type declaration is 1000; otherwise the <type>NUMERIC</type>
+      data type supports a maximum precision of 131071 and a maximum
+      scale of 16383.
+     </para>
+    </note>
+
     <para>
      If the scale of a value to be stored is greater than the declared
      scale of the column, the system will round the value to the specified
-- 
Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-hackers

Reply via email to