postgresql/src/include/utils
Tom Lane 5f1433ac5e 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 Revert "Add gitignore entries for jsonpath_gram.h" 2019-03-23 00:19:34 +01:00
acl.h Update copyright for 2019 2019-01-02 12:44:25 -05:00
aclchk_internal.h Update copyright for 2019 2019-01-02 12:44:25 -05:00
array.h Update copyright for 2019 2019-01-02 12:44:25 -05:00
arrayaccess.h Update copyright for 2019 2019-01-02 12:44:25 -05:00
ascii.h Update copyright for 2019 2019-01-02 12:44:25 -05:00
attoptcache.h Update copyright for 2019 2019-01-02 12:44:25 -05:00
builtins.h Update copyright for 2019 2019-01-02 12:44:25 -05:00
bytea.h Update copyright for 2019 2019-01-02 12:44:25 -05:00
cash.h Phase 2 of pgindent updates. 2017-06-21 15:19:25 -04:00
catcache.h Update copyright for 2019 2019-01-02 12:44:25 -05:00
combocid.h Update copyright for 2019 2019-01-02 12:44:25 -05:00
date.h Update copyright for 2019 2019-01-02 12:44:25 -05:00
datetime.h Create the infrastructure for planner support functions. 2019-02-09 18:08:48 -05:00
datum.h Fix optimization of foreign-key on update actions 2019-03-18 17:19:21 +01:00
dsa.h Update copyright for 2019 2019-01-02 12:44:25 -05:00
dynahash.h Update copyright for 2019 2019-01-02 12:44:25 -05:00
elog.h Fix misleading PG_RE_THROW commentary 2019-02-11 15:56:09 -03:00
evtcache.h Update copyright for 2019 2019-01-02 12:44:25 -05:00
expandeddatum.h Update copyright for 2019 2019-01-02 12:44:25 -05:00
expandedrecord.h Update copyright for 2019 2019-01-02 12:44:25 -05:00
float.h Numeric error suppression in jsonpath 2019-03-16 12:21:19 +03:00
fmgrtab.h Reduce the size of the fmgr_builtin_oid_index[] array. 2019-01-09 15:22:43 -05:00
formatting.h Update copyright for 2019 2019-01-02 12:44:25 -05:00
freepage.h Update copyright for 2019 2019-01-02 12:44:25 -05:00
geo_decls.h Update copyright for 2019 2019-01-02 12:44:25 -05:00
guc.h Add support TCP user timeout in libpq and the backend server 2019-04-06 15:23:37 +09:00
guc_tables.h Add SETTINGS option to EXPLAIN, to print modified settings. 2019-04-04 00:04:31 +02:00
hashutils.h Move hash_any prototype from access/hash.h to utils/hashutils.h 2019-03-11 13:17:50 -03:00
help_config.h Update copyright for 2019 2019-01-02 12:44:25 -05:00
hsearch.h Update copyright for 2019 2019-01-02 12:44:25 -05:00
index_selfuncs.h Update copyright for 2019 2019-01-02 12:44:25 -05:00
inet.h Update copyright for 2019 2019-01-02 12:44:25 -05:00
int8.h Update copyright for 2019 2019-01-02 12:44:25 -05:00
inval.h Update copyright for 2019 2019-01-02 12:44:25 -05:00
json.h Update copyright for 2019 2019-01-02 12:44:25 -05:00
jsonapi.h Update copyright for 2019 2019-01-02 12:44:25 -05:00
jsonb.h GIN support for @@ and @? jsonpath operators 2019-04-01 18:08:52 +03:00
jsonpath.h GIN support for @@ and @? jsonpath operators 2019-04-01 18:08:52 +03:00
logtape.h Update copyright for 2019 2019-01-02 12:44:25 -05:00
lsyscache.h Generated columns 2019-03-30 08:15:57 +01:00
memdebug.h Update copyright for 2019 2019-01-02 12:44:25 -05:00
memutils.h Update copyright for 2019 2019-01-02 12:44:25 -05:00
numeric.h Numeric error suppression in jsonpath 2019-03-16 12:21:19 +03:00
palloc.h Update copyright for 2019 2019-01-02 12:44:25 -05:00
partcache.h Move code for managing PartitionDescs into a new file, partdesc.c 2019-02-21 11:45:02 -05:00
pg_crc.h Update copyright for 2019 2019-01-02 12:44:25 -05:00
pg_locale.h Collations with nondeterministic comparison 2019-03-22 12:12:43 +01:00
pg_lsn.h Update copyright for 2019 2019-01-02 12:44:25 -05:00
pg_rusage.h Update copyright for 2019 2019-01-02 12:44:25 -05:00
pidfile.h Update copyright for 2019 2019-01-02 12:44:25 -05:00
plancache.h Update copyright for 2019 2019-01-02 12:44:25 -05:00
portal.h Update copyright for 2019 2019-01-02 12:44:25 -05:00
ps_status.h Phase 2 of pgindent updates. 2017-06-21 15:19:25 -04:00
queryenvironment.h Update copyright for 2019 2019-01-02 12:44:25 -05:00
rangetypes.h Update copyright for 2019 2019-01-02 12:44:25 -05:00
regproc.h Update copyright for 2019 2019-01-02 12:44:25 -05:00
rel.h Prevent memory leaks associated with relcache rd_partcheck structures. 2019-04-13 13:22:26 -04:00
relcache.h tableam: relation creation, VACUUM FULL/CLUSTER, SET TABLESPACE. 2019-03-28 20:01:43 -07:00
relfilenodemap.h Update copyright for 2019 2019-01-02 12:44:25 -05:00
relmapper.h Update copyright for 2019 2019-01-02 12:44:25 -05:00
relptr.h Update copyright for 2019 2019-01-02 12:44:25 -05:00
reltrigger.h Update copyright for 2019 2019-01-02 12:44:25 -05:00
resowner.h Update copyright for 2019 2019-01-02 12:44:25 -05:00
resowner_private.h Update copyright for 2019 2019-01-02 12:44:25 -05:00
rls.h Update copyright for 2019 2019-01-02 12:44:25 -05:00
ruleutils.h Support foreign keys that reference partitioned tables 2019-04-03 14:40:21 -03:00
sampling.h Update copyright for 2019 2019-01-02 12:44:25 -05:00
selfuncs.h Move estimate_hashagg_tablesize to selfuncs.c, and widen result to double. 2019-02-21 14:59:12 -05:00
sharedtuplestore.h Update copyright for 2019 2019-01-02 12:44:25 -05:00
snapmgr.h Move generic snapshot related code from tqual.h to snapmgr.h. 2019-01-21 17:06:41 -08:00
snapshot.h tableam: Add tuple_{insert, delete, update, lock} and use. 2019-03-23 19:55:57 -07:00
sortsupport.h Update copyright for 2019 2019-01-02 12:44:25 -05:00
spccache.h Update copyright for 2019 2019-01-02 12:44:25 -05:00
syscache.h Update copyright for 2019 2019-01-02 12:44:25 -05:00
timeout.h Update copyright for 2019 2019-01-02 12:44:25 -05:00
timestamp.h Avoid some table rewrites for ALTER TABLE .. SET DATA TYPE timestamp. 2019-03-08 20:16:27 -08:00
tuplesort.h Update copyright for 2019 2019-01-02 12:44:25 -05:00
tuplestore.h Update copyright for 2019 2019-01-02 12:44:25 -05:00
typcache.h Update copyright for 2019 2019-01-02 12:44:25 -05:00
tzparser.h Update copyright for 2019 2019-01-02 12:44:25 -05:00
uuid.h Update copyright for 2019 2019-01-02 12:44:25 -05:00
varbit.h Update copyright for 2019 2019-01-02 12:44:25 -05:00
varlena.h Fix C++ compile failures in headers. 2019-01-10 14:07:01 -05:00
xml.h Update copyright for 2019 2019-01-02 12:44:25 -05:00