pg.ddx.io  pgsql-bugs@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Tom Lane <tgl@sss.pgh.pa.us>
To: emil.lenngren@gmail.com
Cc: pgsql-bugs@postgresql.org
Subject: Re: BUG #12664: numeric_recv does not accept large values
Date: Tue, 27 Jan 2015 00:53:55 -0500
Message-ID: <29641.1422338035@sss.pgh.pa.us> (raw)
In-Reply-To: <20150125205146.6452.25810@wrigleys.postgresql.org>
References: <20150125205146.6452.25810@wrigleys.postgresql.org>
List-Unsubscribe: <mailto:majordomo@postgresql.org?body=unsub%20pgsql-bugs>

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



view thread (2+ messages)

Message-ID: <29641.1422338035@sss.pgh.pa.us>
Permalink:  ../29641.1422338035@sss.pgh.pa.us/
Also on:    postgresql.org/message-id/29641.1422338035@sss.pgh.pa.us

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-bugs@postgresql.org
  Cc: tgl@sss.pgh.pa.us, emil.lenngren@gmail.com
  Subject: Re: BUG #12664: numeric_recv does not accept large values
  In-Reply-To: <29641.1422338035@sss.pgh.pa.us>
  References: <20150125205146.6452.25810@wrigleys.postgresql.org> <29641.1422338035@sss.pgh.pa.us>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox