diff options
author | Heikki Linnakangas <heikki.linnakangas@iki.fi> | 2019-07-30 21:43:27 +0300 |
---|---|---|
committer | Heikki Linnakangas <heikki.linnakangas@iki.fi> | 2019-07-30 21:43:27 +0300 |
commit | a29834beb1deeb0aa06742dd77ba1d21b444ca44 (patch) | |
tree | 300f07ccfaed23dbde7c4947edd4f2f1829a84fc /src/backend/utils/cache | |
parent | d8b094dabb0fa16388340ca823d0a38285d2d6ce (diff) | |
download | postgresql-a29834beb1deeb0aa06742dd77ba1d21b444ca44.tar.gz postgresql-a29834beb1deeb0aa06742dd77ba1d21b444ca44.zip |
Allow table AM's to use rd_amcache, too.
The rd_amcache allows an index AM to cache arbitrary information in a
relcache entry. This commit moves the cleanup of rd_amcache so that it
can also be used by table AMs. Nothing takes advantage of that yet, but
I'm sure it'll come handy for anyone writing new table AMs.
Backpatch to v12, where table AM interface was introduced.
Reviewed-by: Julien Rouhaud
Diffstat (limited to 'src/backend/utils/cache')
-rw-r--r-- | src/backend/utils/cache/relcache.c | 11 |
1 files changed, 9 insertions, 2 deletions
diff --git a/src/backend/utils/cache/relcache.c b/src/backend/utils/cache/relcache.c index 7aa5d7c7fa8..248860758ca 100644 --- a/src/backend/utils/cache/relcache.c +++ b/src/backend/utils/cache/relcache.c @@ -2357,6 +2357,10 @@ RelationDestroyRelation(Relation relation, bool remember_tupdesc) pfree(relation->rd_options); if (relation->rd_indextuple) pfree(relation->rd_indextuple); + if (relation->rd_amcache) + pfree(relation->rd_amcache); + if (relation->rd_fdwroutine) + pfree(relation->rd_fdwroutine); if (relation->rd_indexcxt) MemoryContextDelete(relation->rd_indexcxt); if (relation->rd_rulescxt) @@ -2369,8 +2373,6 @@ RelationDestroyRelation(Relation relation, bool remember_tupdesc) MemoryContextDelete(relation->rd_pdcxt); if (relation->rd_partcheckcxt) MemoryContextDelete(relation->rd_partcheckcxt); - if (relation->rd_fdwroutine) - pfree(relation->rd_fdwroutine); pfree(relation); } @@ -2415,6 +2417,11 @@ RelationClearRelation(Relation relation, bool rebuild) */ RelationCloseSmgr(relation); + /* Free AM cached data, if any */ + if (relation->rd_amcache) + pfree(relation->rd_amcache); + relation->rd_amcache = NULL; + /* * Treat nailed-in system relations separately, they always need to be * accessible, so we can't blow them away. |