postgresql/src
Tom Lane 1d352325b8 Fix power_var_int() for large integer exponents.
The code for raising a NUMERIC value to an integer power wasn't very
careful about large powers.  It got an outright wrong answer for an
exponent of INT_MIN, due to failure to consider overflow of the Abs(exp)
operation; which is fixable by using an unsigned rather than signed
exponent value after that point.  Also, even though the number of
iterations of the power-computation loop is pretty limited, it's easy for
the repeated squarings to result in ridiculously enormous intermediate
values, which can take unreasonable amounts of time/memory to process,
or even overflow the internal "weight" field and so produce a wrong answer.
We can forestall misbehaviors of that sort by bailing out as soon as the
weight value exceeds what will fit in int16, since then the final answer
must overflow (if exp > 0) or underflow (if exp < 0) the packed numeric
format.

Per off-list report from Pavel Stehule.  Back-patch to all supported
branches.
2014-09-11 23:30:51 -04:00
..
backend Fix power_var_int() for large integer exponents. 2014-09-11 23:30:51 -04:00
bin Fix vacuumdb --analyze-in-stages --all order 2014-09-11 21:40:46 -04:00
common Small message fixes 2014-08-09 00:07:00 -04:00
include Add 'ignore_nulls' option to row_to_json 2014-09-11 21:23:51 -04:00
interfaces Install libpq DLL with $(INSTALL_SHLIB). 2014-08-18 23:00:38 -04:00
makefiles Add file version information to most installed Windows binaries. 2014-07-14 14:07:52 -04:00
pl Check number of parameters in RAISE statement at compile time. 2014-09-02 15:56:50 +03:00
port Add support for optional_argument to our own getopt_long() implementation. 2014-09-10 17:21:50 +02:00
template Remove Alpha and Tru64 support. 2014-06-28 21:46:15 +02:00
test Fix power_var_int() for large integer exponents. 2014-09-11 23:30:51 -04:00
timezone Finish adding file version information to installed Windows binaries. 2014-08-18 22:59:53 -04:00
tools Add valgrind suppression for padding bytes in twophase records. 2014-09-01 15:59:44 +02:00
tutorial Adjust blank lines around PG_MODULE_MAGIC defines, for consistency 2014-07-10 14:02:08 -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 Support older versions of "prove" 2014-09-10 20:52:34 -04:00
Makefile.shlib Remove Alpha and Tru64 support. 2014-06-28 21:46:15 +02: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