postgresql/src/backend
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
..
access Update transaction README for persistent multixacts 2014-11-28 18:06:44 -03:00
bootstrap Revert "Fix bogus %name-prefix option syntax in all our Bison files." 2014-05-28 19:21:01 -04:00
catalog Fix dependency searching for case where column is visited before table. 2014-11-11 17:00:18 -05:00
commands Use just one database connection in the "tablespace" test. 2014-11-12 07:34:07 -05:00
executor Explicitly support the case that a plancache's raw_parse_tree is NULL. 2014-11-12 15:59:06 -05:00
foreign Update copyright for 2014 2014-01-07 16:05:30 -05:00
lib pgindent run for 9.4 2014-05-06 12:12:18 -04:00
libpq Message improvements 2014-11-11 20:03:08 -05:00
main Make fallback implementation of pg_memory_barrier() work. 2014-05-17 18:29:46 -04:00
nodes Avoid core dump in _outPathInfo() for Path without a parent RelOptInfo. 2014-10-17 22:33:04 -04:00
optimizer Fix mishandling of system columns in FDW queries. 2014-11-22 16:01:08 -05:00
parser Explicitly support the case that a plancache's raw_parse_tree is NULL. 2014-11-12 15:59:06 -05:00
po Translation updates 2014-11-16 21:31:08 -05:00
port Fix spinlock implementation for some !solaris sparc platforms. 2014-09-09 23:36:32 +02:00
postmaster Eliminate one background-worker-related flag variable. 2014-10-04 22:15:06 -04:00
regex Fix incorrect search for "x?" style matches in creviterdissect(). 2014-09-23 20:26:21 -04:00
replication Improve logical decoding log messages 2014-11-13 20:43:55 -05:00
rewrite Assorted message improvements 2014-08-29 00:01:34 -04:00
snowball Fix ancient encoding error in hungarian.stop. 2014-06-10 22:48:31 -04:00
storage Sync unlogged relations to disk after they have been reset. 2014-11-15 01:20:02 +01:00
tcop Explicitly support the case that a plancache's raw_parse_tree is NULL. 2014-11-12 15:59:06 -05:00
tsearch Cope with more than 64K phrases in a thesaurus dictionary. 2014-11-06 20:52:47 -05:00
utils Guard against bad "dscale" values in numeric_recv(). 2014-12-01 15:25:05 -05:00
.gitignore Add gitignore for mingw/cygwin build outputs 2011-06-09 18:11:47 +02:00
common.mk Remove maintainer-check target, fold into normal build 2013-10-10 20:11:56 -04:00
Makefile Get rid of use of dlltool in Mingw builds. 2014-02-11 12:56:20 -05:00
nls.mk Add libpgcommon to backend gettext source files 2013-10-19 13:49:05 -04:00