postgresql/src/backend
Michael Paquier a786cf04df Fix memory leak in pgoutput with relation attribute map
pgoutput caches the attribute map of a relation, that is free()'d only
when validating a RelationSyncEntry.  However, this code path is not
taken when calling any of the SQL functions able to do some logical
decoding, like pg_logical_slot_{get,peek}_changes(), leaking some memory
into CacheMemoryContext on repeated calls.

This is a follow-up of c9b3d4909b, this time for v13 and v14.  The
relation attribute map is stored in a dedicated memory context, tracked
with a static variable whose state is reset with a MemoryContext reset
callback attached to PGOutputData->context.  This implementation is
similar to the approach taken by cfd6cbcf9b.

Reported-by: Masahiko Sawada
Author: Vignesh C
Reviewed-by: Hou Zhijie
Discussion: https://postgr.es/m/CAD21AoDkAhQVSukOfH3_reuF-j4EU0-HxMqU3dU+bSTxsqT14Q@mail.gmail.com
Discussion: https://postgr.es/m/CALDaNm1hewNAsZ_e6FF52a=9drmkRJxtEPrzCB6-9mkJyeBBqA@mail.gmail.com
Backpatch-through: 13
2025-01-08 08:47:24 +09:00
..
access Fix handling of orphaned 2PC files in the future at recovery 2024-12-30 08:06:47 +09:00
bootstrap Skip WAL for new relfilenodes, under wal_level=minimal. 2020-04-04 12:25:34 -07:00
catalog Restore smgrtruncate() prototype in back-branches. 2025-01-08 10:48:57 +13:00
commands In REASSIGN OWNED of a database, lock the tuple as mandated. 2024-12-28 07:16:27 -08:00
executor Fix Assert failure in WITH RECURSIVE UNION queries 2024-12-19 13:13:51 +13:00
foreign Restrict accesses to non-system views and foreign tables during pg_dump. 2024-08-05 06:05:20 -07:00
jit Fix NULLIF()'s handling of read-write expanded objects. 2024-11-25 18:09:11 -05:00
lib Accommodate very large dshash tables. 2024-12-17 15:24:45 -06:00
libpq Fix regression in TLS session ticket disabling 2024-08-19 12:55:11 +02:00
main Fix elog(FATAL) before PostmasterMain() or just after fork(). 2024-12-10 13:52:02 -08:00
nodes Further fixes for MULTIEXPR_SUBLINK fix. 2022-09-06 16:38:18 -04:00
optimizer Compare collations before merging UNION operations. 2024-11-19 18:26:19 -05:00
parser Remove incorrect Assert. 2024-09-11 11:42:19 -04:00
partitioning Fix creation of partition descriptor during concurrent detach+drop 2024-08-12 18:17:56 -04:00
po Translation updates 2024-11-11 13:58:30 +01:00
port Check for STATUS_DELETE_PENDING on Windows. 2024-11-08 09:44:46 +10:30
postmaster Exclude parallel workers from connection privilege/limit checks. 2024-12-28 16:08:50 -05:00
regex Fix recently-exposed portability issue in regex optimization. 2024-11-17 14:14:06 -05:00
replication Fix memory leak in pgoutput with relation attribute map 2025-01-08 08:47:24 +09:00
rewrite Ensure cached plans are correctly marked as dependent on role. 2024-11-11 09:00:00 -06:00
snowball In the Snowball dictionary, don't try to stem excessively-long words. 2022-08-31 10:42:05 -04:00
statistics Fix incorrectly reported stats kind in "can't happen" ERROR 2024-03-05 16:19:05 +13:00
storage Restore smgrtruncate() prototype in back-branches. 2025-01-08 10:48:57 +13:00
tcop Simplify executor's determination of whether to use parallelism. 2024-12-09 14:38:19 -05:00
tsearch Limit to_tsvector_byid's initial array allocation to something sane. 2023-09-25 11:50:28 -04:00
utils Exclude parallel workers from connection privilege/limit checks. 2024-12-28 16:08:50 -05: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