Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1YFz6B-00043P-M5 for pgsql-bugs@arkaria.postgresql.org; Tue, 27 Jan 2015 05:54:03 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.80) (envelope-from ) id 1YFz6B-0007f8-62 for pgsql-bugs@arkaria.postgresql.org; Tue, 27 Jan 2015 05:54:03 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.2:DHE_RSA_AES_256_CBC_SHA256:256) (Exim 4.80) (envelope-from ) id 1YFz6A-0007f2-Ir for pgsql-bugs@postgresql.org; Tue, 27 Jan 2015 05:54:02 +0000 Received: from sss.pgh.pa.us ([66.207.139.130]) by magus.postgresql.org with esmtps (TLS1.2:DHE_RSA_AES_256_CBC_SHA256:256) (Exim 4.80) (envelope-from ) id 1YFz66-0002bj-E4 for pgsql-bugs@postgresql.org; Tue, 27 Jan 2015 05:54:01 +0000 Received: from sss1.sss.pgh.pa.us (localhost [127.0.0.1]) by sss.pgh.pa.us (8.14.4/8.14.4) with ESMTP id t0R5rtFD029642; Tue, 27 Jan 2015 00:53:55 -0500 From: Tom Lane To: emil.lenngren@gmail.com cc: pgsql-bugs@postgresql.org Subject: Re: BUG #12664: numeric_recv does not accept large values In-reply-to: <20150125205146.6452.25810@wrigleys.postgresql.org> References: <20150125205146.6452.25810@wrigleys.postgresql.org> Comments: In-reply-to emil.lenngren@gmail.com message dated "Sun, 25 Jan 2015 20:51:46 +0000" Date: Tue, 27 Jan 2015 00:53:55 -0500 Message-ID: <29641.1422338035@sss.pgh.pa.us> X-Pg-Spam-Score: -1.9 (-) List-Archive: List-Help: List-ID: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: X-Mailing-List: pgsql-bugs Precedence: bulk Sender: pgsql-bugs-owner@postgresql.org emil.lenngren@gmail.com writes: > According to the documentation for data type "numeric" at > http://www.postgresql.org/docs/9.4/static/datatype-numeric.html: > "up to 131072 digits before the decimal point; up to 16383 digits after the > decimal point" > "Note: The maximum allowed precision when explicitly specified in the type > declaration is 1000; NUMERIC without a specified precision is subject to the > limits described in Table 8-2." Note that that's not saying anything about how many significant digits you can write. > In the binary representation, digits are grouped into groups of 4. The > number of such groups is checked in numeric_recv: > len = (uint16) pq_getmsgint(buf, sizeof(uint16)); > if (len < 0 || len > NUMERIC_MAX_PRECISION + NUMERIC_MAX_RESULT_SCALE) > ereport(ERROR, > (errcode(ERRCODE_INVALID_BINARY_REPRESENTATION), > errmsg("invalid length in external \"numeric\" value"))); > but NUMERIC_MAX_PRECISION + NUMERIC_MAX_RESULT_SCALE is 3000 which means a > limit of only 12000 digits. numeric_in has no such limit. It's true that numeric_in and numeric_recv aren't too consistent about the limits they enforce. I doubt that "remove the limits" is the right answer for that, though. In particular, allowing hundreds of thousands of digits would be a good way to lock a backend up for very long times in simple arithmetic operations ... regards, tom lane -- Sent via pgsql-bugs mailing list (pgsql-bugs@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-bugs