postgresql/src/backend
Tomas Vondra 3ce761d5ca Fix memory leak in Incremental Sort rescans
The Incremental Sort had a couple issues, resulting in leaking memory
during rescans, possibly triggering OOM. The code had a couple of
related flaws:

1. During rescans, the sort states were reset but then also set to NULL
   (despite the comment saying otherwise). ExecIncrementalSort then
   sees NULL and initializes a new sort state, leaking the memory used
   by the old one.

2. Initializing the sort state also automatically rebuilt the info about
   presorted keys, leaking the already initialized info. presorted_keys
   was also unnecessarily reset to NULL.

Patch by James Coleman, based on patches by Laurenz Albe and Tom Lane.
Backpatch to 13, where Incremental Sort was introduced.

Author: James Coleman, Laurenz Albe, Tom Lane
Reported-by: Laurenz Albe, Zu-Ming Jiang
Backpatch-through: 13
Discussion: https://postgr.es/m/b2bd02dff61af15e3526293e2771f874cf2a3be7.camel%40cybertec.at
Discussion: https://postgr.es/m/db03c582-086d-e7cd-d4a1-3bc722f81765%40inf.ethz.ch
2023-07-02 20:05:35 +02:00
..
access nbtree VACUUM: cope with topparent inconsistencies. 2023-06-21 17:41:52 -07:00
bootstrap Skip WAL for new relfilenodes, under wal_level=minimal. 2020-04-04 12:25:34 -07:00
catalog Replace last PushOverrideSearchPath() call with set_config_option(). 2023-05-08 06:14:12 -07:00
commands Fix marking of indisvalid for partitioned indexes at creation 2023-06-30 13:54:59 +09:00
executor Fix memory leak in Incremental Sort rescans 2023-07-02 20:05:35 +02:00
foreign Update copyrights for 2020 2020-01-01 12:21:45 -05:00
jit Fix typos in comments, code and documentation 2023-01-03 16:26:34 +09:00
lib Fix lock assertions in dshash.c. 2022-07-11 15:48:54 +12:00
libpq Fix handling of SCRAM-SHA-256's channel binding with RSA-PSS certificates 2023-02-15 10:12:36 +09:00
main Fix outdated --help message for postgres -f 2022-08-15 13:37:40 +09:00
nodes Further fixes for MULTIEXPR_SUBLINK fix. 2022-09-06 16:38:18 -04:00
optimizer Fix hash join when inner hashkey expressions contain Params. 2023-06-20 17:47:36 -04:00
parser Fix crashes with CREATE SCHEMA AUTHORIZATION and schema elements 2023-04-28 19:29:40 +09:00
partitioning Fix incorrect partition pruning logic for boolean partitioned tables 2023-04-14 16:22:11 +12:00
po Translation updates 2023-05-08 14:36:07 +02:00
port Reject huge_pages=on if shared_memory_type=sysv. 2021-10-26 13:04:40 +13:00
postmaster Fix vacuum_cost_delay check for balance calculation. 2023-04-25 13:54:10 +02:00
regex Avoid character classification in regex escape parsing. 2023-04-21 08:20:47 -07:00
replication Don't repeatedly register cache callbacks in pgoutput plugin. 2023-02-23 15:40:28 -05:00
rewrite Fix typo in comment. 2023-06-16 10:19:44 +09:00
snowball In the Snowball dictionary, don't try to stem excessively-long words. 2022-08-31 10:42:05 -04:00
statistics Partially undo commit 94da73281. 2022-08-05 15:57:46 -04:00
storage Fix missing initializations of MyProc.delayChkptEnd 2023-06-11 10:33:56 +09:00
tcop Rethink handling of [Prevent|Is]InTransactionBlock in pipeline mode. 2022-12-13 14:23:59 -05:00
tsearch Check for interrupts and stack overflow in TParserGet(). 2023-06-24 17:18:08 -04:00
utils Avoid Assert failure when processing empty statement in aborted xact. 2023-06-21 11:07:11 -04:00
.gitignore Add .gitignore entries for AIX-specific intermediate build artifacts. 2015-07-08 20:44:22 -04:00
common.mk Remove PARTIAL_LINKING build mode. 2018-03-30 17:33:04 -07:00
Makefile Update copyrights for 2020 2020-01-01 12:21:45 -05:00
nls.mk Translation updates 2020-09-14 13:14:53 +02:00