postgresql/src/backend
Tom Lane 8ea3e7a75c 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:46 -04:00
..
access Make recovery rename tablespace_map to *.old if backup_label is not present. 2015-08-03 23:04:41 +09:00
bootstrap
catalog Create a pg_shdepend entry for each role in TO clause of policies. 2015-07-28 16:01:53 -07:00
commands Fix a number of places that produced XX000 errors in the regression tests. 2015-08-02 23:49:19 -04:00
executor Share transition state between different aggregates when possible. 2015-08-04 17:53:10 +03:00
foreign
lib Use appendStringInfoString/Char et al where appropriate. 2015-07-02 12:36:03 +03:00
libpq Fix incorrect order of lock file removal and failure to close() sockets. 2015-08-02 14:55:03 -04:00
main Revoke support for strxfrm() that write past the specified array length. 2015-07-08 20:44:21 -04:00
nodes Redesign tablesample method API, and do extensive code review. 2015-07-25 14:39:00 -04:00
optimizer Fix a PlaceHolderVar-related oversight in star-schema planning patch. 2015-08-04 14:55:50 -04:00
parser Share transition state between different aggregates when possible. 2015-08-04 17:53:10 +03:00
po Translation updates 2015-06-28 23:56:55 -04:00
port Make WaitLatchOrSocket's timeout detection more robust. 2015-07-18 11:47:13 -04:00
postmaster Fix incorrect order of lock file removal and failure to close() sockets. 2015-08-02 14:55:03 -04:00
regex
replication Fix logical decoding bug leading to inefficient reopening of files. 2015-07-07 13:12:46 +02:00
rewrite RLS: Keep deny policy when only restrictive exist 2015-08-03 15:32:49 -04:00
snowball Remove no-longer-required function declarations. 2015-05-24 12:20:23 -04:00
storage Micro optimize LWLockAttemptLock() a bit. 2015-08-02 18:41:23 +02:00
tcop Add ALTER OPERATOR command, for changing selectivity estimator functions. 2015-07-14 18:17:55 +03:00
tsearch
utils Fix bogus "out of memory" reports in tuplestore.c. 2015-08-04 18:18:46 -04:00
.gitignore Add .gitignore entries for AIX-specific intermediate build artifacts. 2015-07-08 20:44:22 -04:00
common.mk
Makefile AIX: Link the postgres executable with -Wl,-brtllib. 2015-07-15 21:00:26 -04:00
nls.mk