diff options
author | Alexander Korotkov | 2024-03-21 21:00:34 +0000 |
---|---|---|
committer | Alexander Korotkov | 2024-03-21 21:00:34 +0000 |
commit | 02eb07ea89d27f1d05a5055bf779042d2953b4e7 (patch) | |
tree | 94e20546d3ec27d7b32b09488dda03cfaa58ac2d /src/backend | |
parent | 57184c3b5d89763c882a15adfcdb00990a09d382 (diff) |
Allow table AM to store complex data structures in rd_amcache
The new table AM method free_rd_amcache is responsible for freeing all the
memory related to rd_amcache and setting free_rd_amcache to NULL. If the new
method is not specified, we still assume rd_amcache to be a single chunk of
memory, which could be just pfree'd.
Discussion: https://postgr.es/m/CAPpHfdurb9ycV8udYqM%3Do0sPS66PJ4RCBM1g-bBpvzUfogY0EA%40mail.gmail.com
Reviewed-by: Matthias van de Meent, Mark Dilger, Pavel Borisov
Reviewed-by: Nikita Malakhov, Japin Li
Diffstat (limited to 'src/backend')
-rw-r--r-- | src/backend/access/heap/heapam_handler.c | 1 | ||||
-rw-r--r-- | src/backend/utils/cache/relcache.c | 11 |
2 files changed, 4 insertions, 8 deletions
diff --git a/src/backend/access/heap/heapam_handler.c b/src/backend/access/heap/heapam_handler.c index 680a50bf8b1..4dd1341f606 100644 --- a/src/backend/access/heap/heapam_handler.c +++ b/src/backend/access/heap/heapam_handler.c @@ -2582,6 +2582,7 @@ static const TableAmRoutine heapam_methods = { .index_build_range_scan = heapam_index_build_range_scan, .index_validate_scan = heapam_index_validate_scan, + .free_rd_amcache = NULL, .relation_size = table_block_relation_size, .relation_needs_toast_table = heapam_relation_needs_toast_table, .relation_toast_am = heapam_relation_toast_am, diff --git a/src/backend/utils/cache/relcache.c b/src/backend/utils/cache/relcache.c index 2cd19d603fb..dcd18e46268 100644 --- a/src/backend/utils/cache/relcache.c +++ b/src/backend/utils/cache/relcache.c @@ -2262,9 +2262,7 @@ RelationReloadIndexInfo(Relation relation) RelationCloseSmgr(relation); /* Must free any AM cached data upon relcache flush */ - if (relation->rd_amcache) - pfree(relation->rd_amcache); - relation->rd_amcache = NULL; + table_free_rd_amcache(relation); /* * If it's a shared index, we might be called before backend startup has @@ -2484,8 +2482,7 @@ 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); + table_free_rd_amcache(relation); if (relation->rd_fdwroutine) pfree(relation->rd_fdwroutine); if (relation->rd_indexcxt) @@ -2547,9 +2544,7 @@ 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; + table_free_rd_amcache(relation); /* * Treat nailed-in system relations separately, they always need to be |