postgresql/src/include/utils
Tom Lane 089e4d405d Prevent memory leaks associated with relcache rd_partcheck structures.
The original coding of generate_partition_qual() just copied the list
of predicate expressions into the global CacheMemoryContext, making it
effectively impossible to clean up when the owning relcache entry is
destroyed --- the relevant code in RelationDestroyRelation() only managed
to free the topmost List header :-(.  This resulted in a session-lifespan
memory leak whenever a table partition's relcache entry is rebuilt.
Fortunately, that's not normally a large data structure, and rebuilds
shouldn't occur all that often in production situations; but this is
still a bug worth fixing back to v10 where the code was introduced.

To fix, put the cached expression tree into its own small memory context,
as we do with other complicated substructures of relcache entries.
Also, deal more honestly with the case that a partition has an empty
partcheck list; while that probably isn't a case that's very interesting
for production use, it's legal.

In passing, clarify comments about how partitioning-related relcache
data structures are managed, and add some Asserts that we're not leaking
old copies when we overwrite these data fields.

Amit Langote and Tom Lane

Discussion: https://postgr.es/m/7961.1552498252@sss.pgh.pa.us
2019-04-13 13:22:26 -04:00
..
.gitignore Rearrange makefile rules for running Gen_fmgrtab.pl. 2018-05-03 17:54:18 -04:00
acl.h Fix missing role dependencies for some schema and type ACLs. 2018-11-09 20:42:03 -05:00
aclchk_internal.h Replace GrantObjectType with ObjectType 2018-01-19 14:01:14 -05:00
array.h Update copyright for 2018 2018-01-02 23:30:12 -05:00
arrayaccess.h Update copyright for 2018 2018-01-02 23:30:12 -05:00
ascii.h Update copyright for 2018 2018-01-02 23:30:12 -05:00
attoptcache.h Update copyright for 2018 2018-01-02 23:30:12 -05:00
backend_random.h Update copyright for 2018 2018-01-02 23:30:12 -05:00
builtins.h Fix some corner-case issues in REFRESH MATERIALIZED VIEW CONCURRENTLY. 2018-03-19 18:50:05 -04:00
bytea.h Update copyright for 2018 2018-01-02 23:30:12 -05:00
cash.h Phase 2 of pgindent updates. 2017-06-21 15:19:25 -04:00
catcache.h Save a few bytes by removing useless last argument to SearchCatCacheList. 2018-01-29 15:13:17 -05:00
combocid.h Update copyright for 2018 2018-01-02 23:30:12 -05:00
date.h Fix compiler warnings due to commit cc4feded 2018-01-17 03:33:02 -05:00
datetime.h Update copyright for 2018 2018-01-02 23:30:12 -05:00
datum.h Update copyright for 2018 2018-01-02 23:30:12 -05:00
dsa.h Use size_t consistently in dsa.{ch}. 2018-09-22 00:41:49 +12:00
dynahash.h Update copyright for 2018 2018-01-02 23:30:12 -05:00
dynamic_loader.h Update copyright for 2018 2018-01-02 23:30:12 -05:00
elog.h Update copyright for 2018 2018-01-02 23:30:12 -05:00
evtcache.h Update copyright for 2018 2018-01-02 23:30:12 -05:00
expandeddatum.h Update copyright for 2018 2018-01-02 23:30:12 -05:00
expandedrecord.h Detoast plpgsql variables if they might live across a transaction boundary. 2018-05-16 14:56:52 -04:00
fmgrtab.h Update copyright for 2018 2018-01-02 23:30:12 -05:00
formatting.h Update copyright for 2018 2018-01-02 23:30:12 -05:00
freepage.h Update copyright for 2018 2018-01-02 23:30:12 -05:00
geo_decls.h Update copyright for 2018 2018-01-02 23:30:12 -05:00
guc.h Teach SHOW ALL to honor pg_read_all_settings membership 2018-06-08 16:19:05 -04:00
guc_tables.h Split out documentation of SSL parameters into their own section 2018-01-23 07:11:38 -05:00
hashutils.h Update copyright for 2018 2018-01-02 23:30:12 -05:00
help_config.h Update copyright for 2018 2018-01-02 23:30:12 -05:00
hsearch.h Update copyright for 2018 2018-01-02 23:30:12 -05:00
index_selfuncs.h Update copyright for 2018 2018-01-02 23:30:12 -05:00
inet.h Update copyright for 2018 2018-01-02 23:30:12 -05:00
int8.h Update copyright for 2018 2018-01-02 23:30:12 -05:00
inval.h Update copyright for 2018 2018-01-02 23:30:12 -05:00
json.h Update copyright for 2018 2018-01-02 23:30:12 -05:00
jsonapi.h Post-feature-freeze pgindent run. 2018-04-26 14:47:16 -04:00
jsonb.h Update copyright for 2018 2018-01-02 23:30:12 -05:00
logtape.h Fix some sloppiness in the new BufFileSize() and BufFileAppend() functions. 2018-05-02 17:23:13 +03:00
lsyscache.h Fix assorted bugs in pg_get_partition_constraintdef(). 2018-09-27 18:15:06 -04:00
memdebug.h Update copyright for 2018 2018-01-02 23:30:12 -05:00
memutils.h Simplify use of AllocSetContextCreate() wrapper macro. 2018-10-12 14:26:56 -04:00
nabstime.h Update copyright for 2018 2018-01-02 23:30:12 -05:00
numeric.h Update copyright for 2018 2018-01-02 23:30:12 -05:00
palloc.h Update copyright for 2018 2018-01-02 23:30:12 -05:00
partcache.h Post-feature-freeze pgindent run. 2018-04-26 14:47:16 -04:00
pg_crc.h Update copyright for 2018 2018-01-02 23:30:12 -05:00
pg_locale.h Update copyright for 2018 2018-01-02 23:30:12 -05:00
pg_lsn.h Update copyright for 2018 2018-01-02 23:30:12 -05:00
pg_rusage.h Update copyright for 2018 2018-01-02 23:30:12 -05:00
pidfile.h Update copyright for 2018 2018-01-02 23:30:12 -05:00
plancache.h Update copyright for 2018 2018-01-02 23:30:12 -05:00
portal.h Post-feature-freeze pgindent run. 2018-04-26 14:47:16 -04:00
ps_status.h Phase 2 of pgindent updates. 2017-06-21 15:19:25 -04:00
queryenvironment.h Update copyright for 2018 2018-01-02 23:30:12 -05:00
rangetypes.h Update copyright for 2018 2018-01-02 23:30:12 -05:00
regproc.h Update copyright for 2018 2018-01-02 23:30:12 -05:00
rel.h Prevent memory leaks associated with relcache rd_partcheck structures. 2019-04-13 13:22:26 -04:00
relcache.h Allow HOT updates for some expression indexes 2018-03-27 19:57:02 +01:00
relfilenodemap.h Update copyright for 2018 2018-01-02 23:30:12 -05:00
relmapper.h Update copyright for 2018 2018-01-02 23:30:12 -05:00
relptr.h Update copyright for 2018 2018-01-02 23:30:12 -05:00
reltrigger.h Update copyright for 2018 2018-01-02 23:30:12 -05:00
resowner.h Update copyright for 2018 2018-01-02 23:30:12 -05:00
resowner_private.h Post-feature-freeze pgindent run. 2018-04-26 14:47:16 -04:00
rls.h Update copyright for 2018 2018-01-02 23:30:12 -05:00
ruleutils.h Update copyright for 2018 2018-01-02 23:30:12 -05:00
sampling.h Update copyright for 2018 2018-01-02 23:30:12 -05:00
selfuncs.h Add prefix operator for TEXT type. 2018-04-03 19:46:45 +03:00
sharedtuplestore.h Update copyright for 2018 2018-01-02 23:30:12 -05:00
snapmgr.h Update copyright for 2018 2018-01-02 23:30:12 -05:00
snapshot.h Update copyright for 2018 2018-01-02 23:30:12 -05:00
sortsupport.h Allow btree comparison functions to return INT_MIN. 2018-10-05 16:01:29 -04:00
spccache.h Update copyright for 2018 2018-01-02 23:30:12 -05:00
syscache.h Save a few bytes by removing useless last argument to SearchCatCacheList. 2018-01-29 15:13:17 -05:00
timeout.h Update copyright for 2018 2018-01-02 23:30:12 -05:00
timestamp.h Update copyright for 2018 2018-01-02 23:30:12 -05:00
tqual.h Update copyright for 2018 2018-01-02 23:30:12 -05:00
tuplesort.h Post-feature-freeze pgindent run. 2018-04-26 14:47:16 -04:00
tuplestore.h Update copyright for 2018 2018-01-02 23:30:12 -05:00
typcache.h Make plpgsql use its DTYPE_REC code paths for composite-type variables. 2018-02-13 18:52:21 -05:00
tzparser.h Update copyright for 2018 2018-01-02 23:30:12 -05:00
uuid.h Update copyright for 2018 2018-01-02 23:30:12 -05:00
varbit.h Update copyright for 2018 2018-01-02 23:30:12 -05:00
varlena.h Further fixes for quoted-list GUC values in pg_dump and ruleutils.c. 2018-07-31 13:00:08 -04:00
xml.h Update copyright for 2018 2018-01-02 23:30:12 -05:00