aboutsummaryrefslogtreecommitdiff
path: root/contrib/jsonb_plpython
diff options
context:
space:
mode:
authorTom Lane <tgl@sss.pgh.pa.us>2019-04-13 13:22:26 -0400
committerTom Lane <tgl@sss.pgh.pa.us>2019-04-13 13:22:26 -0400
commit089e4d405d0f3b94c74a2c6a54357a84a681754b (patch)
treed39988de26e668f625a20f2dca914c389258203f /contrib/jsonb_plpython
parent7ef2b313e6494c2bfece61a2601eea31ebcb3430 (diff)
downloadpostgresql-089e4d405d0f3b94c74a2c6a54357a84a681754b.tar.gz
postgresql-089e4d405d0f3b94c74a2c6a54357a84a681754b.zip
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
Diffstat (limited to 'contrib/jsonb_plpython')
0 files changed, 0 insertions, 0 deletions