postgresql/src/backend
Tom Lane 9965aff1ca Fix bogus "out of memory" reports in tuplestore.c.
The tuplesort/tuplestore memory management logic assumed that the chunk
allocation overhead for its memtuples array could not increase when
increasing the array size.  This is and always was true for tuplesort,
but we (I, I think) blindly copied that logic into tuplestore.c without
noticing that the assumption failed to hold for the much smaller array
elements used by tuplestore.  Given rather small work_mem, this could
result in an improper complaint about "unexpected out-of-memory situation",
as reported by Brent DeSpain in bug #13530.

The easiest way to fix this is just to increase tuplestore's initial
array size so that the assumption holds.  Rather than relying on magic
constants, though, let's export a #define from aset.c that represents
the safe allocation threshold, and make tuplestore's calculation depend
on that.

Do the same in tuplesort.c to keep the logic looking parallel, even though
tuplesort.c isn't actually at risk at present.  This will keep us from
breaking it if we ever muck with the allocation parameters in aset.c.

Back-patch to all supported versions.  The error message doesn't occur
pre-9.3, not so much because the problem can't happen as because the
pre-9.3 tuplestore code neglected to check for it.  (The chance of
trouble is a great deal larger as of 9.3, though, due to changes in the
array-size-increasing strategy.)  However, allowing LACKMEM() to become
true unexpectedly could still result in less-than-desirable behavior,
so let's patch it all the way back.
2015-08-04 18:18:47 -04:00
..
access Reuse all-zero pages in GIN. 2015-07-27 12:33:13 +03:00
bootstrap Fix off-by-one loop count in MapArrayTypeName, and get rid of static array. 2014-12-16 15:35:46 -05:00
catalog Rename pg_shdepend.c's typedef "objectType" to SharedDependencyObjectType. 2015-05-24 13:03:45 -04:00
commands Fix incorrect checking of deferred exclusion constraint after a HOT update. 2015-05-11 12:25:28 -04:00
executor Avoid some zero-divide hazards in the planner. 2015-07-30 12:11:23 -04:00
foreign deflist_to_tuplestore dumped core on an option with no value. 2011-09-13 11:36:53 -04:00
lib Remove tabs after spaces in C comments 2014-05-06 11:26:26 -04:00
libpq Back-patch libpq support for TLS versions beyond v1. 2015-05-21 20:41:55 -04:00
main Report more information if pg_perm_setlocale() fails at startup. 2015-06-09 13:37:08 -04:00
nodes Avoid core dump in _outPathInfo() for Path without a parent RelOptInfo. 2014-10-17 22:33:14 -04:00
optimizer Fix some planner issues with degenerate outer join clauses. 2015-08-01 20:57:41 -04:00
parser Remove spurious semicolons. 2015-03-31 15:21:16 +03:00
po Translation updates 2015-05-18 08:51:06 -04:00
port Fix spinlock implementation for some !solaris sparc platforms. 2014-09-09 23:45:07 +02:00
postmaster Fix incorrect order of lock file removal and failure to close() sockets. 2015-08-02 14:54:44 -04:00
regex Fix two low-probability memory leaks in regular expression parsing. 2014-07-18 13:00:52 -04:00
replication Truncate strings in tarCreateHeader() with strlcpy(), not sprintf(). 2015-06-21 20:05:35 -04:00
rewrite Add some errdetail to checkRuleResultList(). 2014-07-02 14:20:44 -04:00
snowball Fix ancient encoding error in hungarian.stop. 2014-06-10 22:48:52 -04:00
storage Reduce chatter from signaling of autovacuum workers. 2015-07-28 17:34:00 -04:00
tcop Be more careful to not lose sync in the FE/BE protocol. 2015-02-02 17:09:31 +02:00
tsearch Cope with more than 64K phrases in a thesaurus dictionary. 2014-11-06 20:53:02 -05:00
utils Fix bogus "out of memory" reports in tuplestore.c. 2015-08-04 18:18:47 -04:00
.gitignore Add gitignore for mingw/cygwin build outputs 2011-06-09 18:11:47 +02:00
common.mk Workaround for recursive make breakage 2011-01-13 09:32:06 +02:00
Makefile AIX: Link the postgres executable with -Wl,-brtllib. 2015-07-15 21:00:31 -04:00
nls.mk Translation updates 2013-02-03 23:58:38 -05:00