postgresql/src
Tom Lane ac0aa07e96 Guard against bad "dscale" values in numeric_recv().
We were not checking to see if the supplied dscale was valid for the given
digit array when receiving binary-format numeric values.  While dscale can
validly be more than the number of nonzero fractional digits, it shouldn't
be less; that case causes fractional digits to be hidden on display even
though they're there and participate in arithmetic.

Bug #12053 from Tommaso Sala indicates that there's at least one broken
client library out there that sometimes supplies an incorrect dscale value,
leading to strange behavior.  This suggests that simply throwing an error
might not be the best response; it would lead to failures in applications
that might seem to be working fine today.  What seems the least risky fix
is to truncate away any digits that would be hidden by dscale.  This
preserves the existing behavior in terms of what will be printed for the
transmitted value, while preventing subsequent arithmetic from producing
results inconsistent with that.

In passing, throw a specific error for the case of dscale being outside
the range that will fit into a numeric's header.  Before you got "value
overflows numeric format", which is a bit misleading.

Back-patch to all supported branches.
2014-12-01 15:25:05 -05:00
..
backend Guard against bad "dscale" values in numeric_recv(). 2014-12-01 15:25:05 -05:00
bin Reimplement 9f80f4835a with PQconninfo(). 2014-11-29 12:34:14 -05:00
common Small message fixes 2014-08-09 00:07:29 -04:00
include Fix hstore_to_json_loose's detection of valid JSON number values. 2014-12-01 11:40:30 -05:00
interfaces Fix minor bugs in commit 30bf4689a9 et al. 2014-11-30 12:20:47 -05:00
makefiles MinGW: Use -static-libgcc when linking a DLL. 2014-10-21 22:56:42 -04:00
pl Translation updates 2014-11-16 21:31:08 -05:00
port Fix win32setlocale.c const-related warnings. 2014-11-02 21:44:21 -05:00
template Revert to using --enable-auto-import in Cygwin builds. 2014-02-16 15:14:04 -05:00
test Don't require bleeding-edge timezone data in timestamptz regression test. 2014-11-18 21:36:43 -05:00
timezone Update time zone data files to tzdata release 2014j. 2014-11-17 12:09:17 -05:00
tools Rework 'MOVE ALL' to 'ALTER .. ALL IN TABLESPACE' 2014-08-21 19:12:00 -04:00
tutorial pgindent run for 9.4 2014-05-06 12:12:18 -04:00
.gitignore Convert cvsignore to gitignore, and add .gitignore for build targets. 2010-09-22 12:57:04 +02:00
bcc32.mak Autoconfiscate selection of 64-bit int type for 64-bit large object API. 2012-10-07 21:52:43 -04:00
DEVELOPERS Replace a couple of references to files that no longer exist in the source 2009-05-04 08:08:47 +00:00
Makefile Create libpgcommon, and move pg_malloc et al to it 2013-02-12 11:21:05 -03:00
Makefile.global.in Add configure --enable-tap-tests option 2014-11-02 09:17:49 -05:00
Makefile.shlib MinGW: Include .dll extension in .def file LIBRARY commands. 2014-10-27 19:59:52 -04:00
nls-global.mk Setup error context callback for transaction lock waits 2014-03-19 15:10:36 -03:00
win32.mak Autoconfiscate selection of 64-bit int type for 64-bit large object API. 2012-10-07 21:52:43 -04:00