postgresql/src/include/executor
Tom Lane af33039317 Fix worst memory leaks in tqueue.c.
TupleQueueReaderNext() leaks like a sieve if it has to do any tuple
disassembly/reconstruction.  While we could try to clean up its allocations
piecemeal, it seems like a better idea just to insist that it should be run
in a short-lived memory context, so that any transient space goes away
automatically.  I chose to have nodeGather.c switch into its existing
per-tuple context before the call, rather than inventing a separate
context inside tqueue.c.

This is sufficient to stop all leakage in the simple case I exhibited
earlier today (see link below), but it does not deal with leaks induced
in more complex cases by tqueue.c's insistence on using TopMemoryContext
for data that it's not actually trying hard to keep track of.  That issue
is intertwined with another major source of inefficiency, namely failure
to cache lookup results across calls, so it seems best to deal with it
separately.

In passing, improve some comments, and modify gather_readnext's method for
deciding when it's visited all the readers so that it's more obviously
correct.  (I'm not actually convinced that the previous code *is*
correct in the case of a reader deletion; it certainly seems fragile.)

Discussion: <32763.1469821037@sss.pgh.pa.us>
2016-07-29 19:31:06 -04:00
..
execdebug.h Update copyright for 2016 2016-01-02 13:33:40 -05:00
execdesc.h Update copyright for 2016 2016-01-02 13:33:40 -05:00
execParallel.h pgindent run for 9.6 2016-06-09 18:02:36 -04:00
executor.h Fix latent crash in do_text_output_multiline(). 2016-05-23 14:16:40 -04:00
functions.h Update copyright for 2016 2016-01-02 13:33:40 -05:00
hashjoin.h Update copyright for 2016 2016-01-02 13:33:40 -05:00
instrument.h Update copyright for 2016 2016-01-02 13:33:40 -05:00
nodeAgg.h Update copyright for 2016 2016-01-02 13:33:40 -05:00
nodeAppend.h Update copyright for 2016 2016-01-02 13:33:40 -05:00
nodeBitmapAnd.h Update copyright for 2016 2016-01-02 13:33:40 -05:00
nodeBitmapHeapscan.h Update copyright for 2016 2016-01-02 13:33:40 -05:00
nodeBitmapIndexscan.h Update copyright for 2016 2016-01-02 13:33:40 -05:00
nodeBitmapOr.h Update copyright for 2016 2016-01-02 13:33:40 -05:00
nodeCtescan.h Update copyright for 2016 2016-01-02 13:33:40 -05:00
nodeCustom.h pgindent run for 9.6 2016-06-09 18:02:36 -04:00
nodeForeignscan.h pgindent run for 9.6 2016-06-09 18:02:36 -04:00
nodeFunctionscan.h Update copyright for 2016 2016-01-02 13:33:40 -05:00
nodeGather.h Update copyright for 2016 2016-01-02 13:33:40 -05:00
nodeGroup.h Update copyright for 2016 2016-01-02 13:33:40 -05:00
nodeHash.h Update copyright for 2016 2016-01-02 13:33:40 -05:00
nodeHashjoin.h Update copyright for 2016 2016-01-02 13:33:40 -05:00
nodeIndexonlyscan.h Update copyright for 2016 2016-01-02 13:33:40 -05:00
nodeIndexscan.h Update copyright for 2016 2016-01-02 13:33:40 -05:00
nodeLimit.h Update copyright for 2016 2016-01-02 13:33:40 -05:00
nodeLockRows.h Update copyright for 2016 2016-01-02 13:33:40 -05:00
nodeMaterial.h Update copyright for 2016 2016-01-02 13:33:40 -05:00
nodeMergeAppend.h Update copyright for 2016 2016-01-02 13:33:40 -05:00
nodeMergejoin.h Update copyright for 2016 2016-01-02 13:33:40 -05:00
nodeModifyTable.h Update copyright for 2016 2016-01-02 13:33:40 -05:00
nodeNestloop.h Update copyright for 2016 2016-01-02 13:33:40 -05:00
nodeRecursiveunion.h Update copyright for 2016 2016-01-02 13:33:40 -05:00
nodeResult.h Update copyright for 2016 2016-01-02 13:33:40 -05:00
nodeSamplescan.h Update copyright for 2016 2016-01-02 13:33:40 -05:00
nodeSeqscan.h Update copyright for 2016 2016-01-02 13:33:40 -05:00
nodeSetOp.h Update copyright for 2016 2016-01-02 13:33:40 -05:00
nodeSort.h Update copyright for 2016 2016-01-02 13:33:40 -05:00
nodeSubplan.h Update copyright for 2016 2016-01-02 13:33:40 -05:00
nodeSubqueryscan.h Update copyright for 2016 2016-01-02 13:33:40 -05:00
nodeTidscan.h Update copyright for 2016 2016-01-02 13:33:40 -05:00
nodeUnique.h Update copyright for 2016 2016-01-02 13:33:40 -05:00
nodeValuesscan.h Update copyright for 2016 2016-01-02 13:33:40 -05:00
nodeWindowAgg.h Update copyright for 2016 2016-01-02 13:33:40 -05:00
nodeWorktablescan.h Update copyright for 2016 2016-01-02 13:33:40 -05:00
spi.h Widen query numbers-of-tuples-processed counters to uint64. 2016-03-12 16:05:29 -05:00
spi_priv.h Widen query numbers-of-tuples-processed counters to uint64. 2016-03-12 16:05:29 -05:00
tqueue.h Fix worst memory leaks in tqueue.c. 2016-07-29 19:31:06 -04:00
tstoreReceiver.h Update copyright for 2016 2016-01-02 13:33:40 -05:00
tuptable.h Mark read/write expanded values as read-only in ExecProject(). 2016-06-03 15:14:50 -04:00