Fix leaked hash scans in pg_listening_channels().

Commit 282b1cde9 changed pg_listening_channels() to keep a hash table
scan open between calls of this set-returning function.  If the
executor stops fetching rows early, as with a target-list call under
LIMIT, the scan remains registered until transaction end, resulting in
leak complaints and eventually a PANIC.

Instead materialize the result in a tuplestore, so that we can
complete the hash scan within a single call.

Author: Joel Jacobson <[email protected]>
Reviewed-by: Tom Lane <[email protected]>
Discussion: 
https://postgr.es/m/[email protected]
Backpatch-through: 19

Branch
------
master

Details
-------
https://git.postgresql.org/pg/commitdiff/dfd7ede529f288639760444a9c69f3f7bb65450c

Modified Files
--------------
src/backend/commands/async.c        | 56 ++++++++++++++-----------------------
src/test/regress/expected/async.out |  7 +++++
src/test/regress/sql/async.sql      |  4 +++
3 files changed, 32 insertions(+), 35 deletions(-)

Reply via email to