From 922c4c461d213a422ee7eb6c38e399607539210a Mon Sep 17 00:00:00 2001 From: Alexander Korotkov Date: Thu, 11 Apr 2024 15:54:25 +0300 Subject: Revert: Allow table AM to store complex data structures in rd_amcache This commit reverts 02eb07ea89 per review by Andres Freund. Discussion: https://postgr.es/m/20240410165236.rwyrny7ihi4ddxw4%40awork3.anarazel.de --- src/include/access/tableam.h | 34 ---------------------------------- src/include/utils/rel.h | 10 ++++------ 2 files changed, 4 insertions(+), 40 deletions(-) (limited to 'src/include') diff --git a/src/include/access/tableam.h b/src/include/access/tableam.h index ac24c999453..1cc395317e5 100644 --- a/src/include/access/tableam.h +++ b/src/include/access/tableam.h @@ -687,14 +687,6 @@ typedef struct TableAmRoutine * ------------------------------------------------------------------------ */ - /* - * This callback frees relation private cache data stored in rd_amcache. - * After the call all memory related to rd_amcache must be freed, - * rd_amcache must be set to NULL. If this callback is not provided, - * rd_amcache is assumed to point to a single memory chunk. - */ - void (*free_rd_amcache) (Relation rel); - /* * See table_relation_size(). * @@ -1816,32 +1808,6 @@ table_relation_analyze(Relation relation, AcquireSampleRowsFunc *func, * ---------------------------------------------------------------------------- */ -/* - * Frees relation private cache data stored in rd_amcache. Uses - * free_rd_amcache method if provided. Assumes rd_amcache to point to single - * memory chunk otherwise. - */ -static inline void -table_free_rd_amcache(Relation rel) -{ - if (rel->rd_tableam && rel->rd_tableam->free_rd_amcache) - { - rel->rd_tableam->free_rd_amcache(rel); - - /* - * We are assuming free_rd_amcache() did clear the cache and left NULL - * in rd_amcache. - */ - Assert(rel->rd_amcache == NULL); - } - else - { - if (rel->rd_amcache) - pfree(rel->rd_amcache); - rel->rd_amcache = NULL; - } -} - /* * Return the current size of `rel` in bytes. If `forkNumber` is * InvalidForkNumber, return the relation's overall size, otherwise the size diff --git a/src/include/utils/rel.h b/src/include/utils/rel.h index f25f769af2b..87002049538 100644 --- a/src/include/utils/rel.h +++ b/src/include/utils/rel.h @@ -221,12 +221,10 @@ typedef struct RelationData * rd_amcache is available for index and table AMs to cache private data * about the relation. This must be just a cache since it may get reset * at any time (in particular, it will get reset by a relcache inval - * message for the relation). If used for table AM it must point to a - * single memory chunk palloc'd in CacheMemoryContext, or more complex - * data structure in that memory context to be freed by free_rd_amcache - * method. If used for index AM it must point to a single memory chunk - * palloc'd in rd_indexcxt memory context. A relcache reset will include - * freeing that chunk and setting rd_amcache = NULL. + * message for the relation). If used, it must point to a single memory + * chunk palloc'd in CacheMemoryContext, or in rd_indexcxt for an index + * relation. A relcache reset will include freeing that chunk and setting + * rd_amcache = NULL. */ void *rd_amcache; /* available for use by index/table AM */ -- cgit v1.2.3