Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit922c4c4

Browse files
committed
Revert: Allow table AM to store complex data structures in rd_amcache
This commit reverts02eb07e per review by Andres Freund.Discussion:https://postgr.es/m/20240410165236.rwyrny7ihi4ddxw4%40awork3.anarazel.de
1 parent8dd0bb8 commit922c4c4

File tree

4 files changed

+12
-44
lines changed

4 files changed

+12
-44
lines changed

‎src/backend/access/heap/heapam_handler.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2656,7 +2656,6 @@ static const TableAmRoutine heapam_methods = {
26562656
.index_validate_scan=heapam_index_validate_scan,
26572657
.relation_analyze=heapam_analyze,
26582658

2659-
.free_rd_amcache=NULL,
26602659
.relation_size=table_block_relation_size,
26612660
.relation_needs_toast_table=heapam_relation_needs_toast_table,
26622661
.relation_toast_am=heapam_relation_toast_am,

‎src/backend/utils/cache/relcache.c

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2269,7 +2269,9 @@ RelationReloadIndexInfo(Relation relation)
22692269
RelationCloseSmgr(relation);
22702270

22712271
/* Must free any AM cached data upon relcache flush */
2272-
table_free_rd_amcache(relation);
2272+
if (relation->rd_amcache)
2273+
pfree(relation->rd_amcache);
2274+
relation->rd_amcache=NULL;
22732275

22742276
/*
22752277
* If it's a shared index, we might be called before backend startup has
@@ -2489,7 +2491,8 @@ RelationDestroyRelation(Relation relation, bool remember_tupdesc)
24892491
pfree(relation->rd_options);
24902492
if (relation->rd_indextuple)
24912493
pfree(relation->rd_indextuple);
2492-
table_free_rd_amcache(relation);
2494+
if (relation->rd_amcache)
2495+
pfree(relation->rd_amcache);
24932496
if (relation->rd_fdwroutine)
24942497
pfree(relation->rd_fdwroutine);
24952498
if (relation->rd_indexcxt)
@@ -2551,7 +2554,9 @@ RelationClearRelation(Relation relation, bool rebuild)
25512554
RelationCloseSmgr(relation);
25522555

25532556
/* Free AM cached data, if any */
2554-
table_free_rd_amcache(relation);
2557+
if (relation->rd_amcache)
2558+
pfree(relation->rd_amcache);
2559+
relation->rd_amcache=NULL;
25552560

25562561
/*
25572562
* Treat nailed-in system relations separately, they always need to be

‎src/include/access/tableam.h

Lines changed: 0 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -687,14 +687,6 @@ typedef struct TableAmRoutine
687687
* ------------------------------------------------------------------------
688688
*/
689689

690-
/*
691-
* This callback frees relation private cache data stored in rd_amcache.
692-
* After the call all memory related to rd_amcache must be freed,
693-
* rd_amcache must be set to NULL. If this callback is not provided,
694-
* rd_amcache is assumed to point to a single memory chunk.
695-
*/
696-
void(*free_rd_amcache) (Relationrel);
697-
698690
/*
699691
* See table_relation_size().
700692
*
@@ -1816,32 +1808,6 @@ table_relation_analyze(Relation relation, AcquireSampleRowsFunc *func,
18161808
* ----------------------------------------------------------------------------
18171809
*/
18181810

1819-
/*
1820-
* Frees relation private cache data stored in rd_amcache. Uses
1821-
* free_rd_amcache method if provided. Assumes rd_amcache to point to single
1822-
* memory chunk otherwise.
1823-
*/
1824-
staticinlinevoid
1825-
table_free_rd_amcache(Relationrel)
1826-
{
1827-
if (rel->rd_tableam&&rel->rd_tableam->free_rd_amcache)
1828-
{
1829-
rel->rd_tableam->free_rd_amcache(rel);
1830-
1831-
/*
1832-
* We are assuming free_rd_amcache() did clear the cache and left NULL
1833-
* in rd_amcache.
1834-
*/
1835-
Assert(rel->rd_amcache==NULL);
1836-
}
1837-
else
1838-
{
1839-
if (rel->rd_amcache)
1840-
pfree(rel->rd_amcache);
1841-
rel->rd_amcache=NULL;
1842-
}
1843-
}
1844-
18451811
/*
18461812
* Return the current size of `rel` in bytes. If `forkNumber` is
18471813
* InvalidForkNumber, return the relation's overall size, otherwise the size

‎src/include/utils/rel.h

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -221,12 +221,10 @@ typedef struct RelationData
221221
* rd_amcache is available for index and table AMs to cache private data
222222
* about the relation. This must be just a cache since it may get reset
223223
* at any time (in particular, it will get reset by a relcache inval
224-
* message for the relation). If used for table AM it must point to a
225-
* single memory chunk palloc'd in CacheMemoryContext, or more complex
226-
* data structure in that memory context to be freed by free_rd_amcache
227-
* method. If used for index AM it must point to a single memory chunk
228-
* palloc'd in rd_indexcxt memory context. A relcache reset will include
229-
* freeing that chunk and setting rd_amcache = NULL.
224+
* message for the relation). If used, it must point to a single memory
225+
* chunk palloc'd in CacheMemoryContext, or in rd_indexcxt for an index
226+
* relation. A relcache reset will include freeing that chunk and setting
227+
* rd_amcache = NULL.
230228
*/
231229
void*rd_amcache;/* available for use by index/table AM */
232230

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp