mirror of
https://github.com/postgres/postgres.git
synced 2025-06-30 21:42:05 +03:00
Rewrite the FSM. Instead of relying on a fixed-size shared memory segment, the
free space information is stored in a dedicated FSM relation fork, with each relation (except for hash indexes; they don't use FSM). This eliminates the max_fsm_relations and max_fsm_pages GUC options; remove any trace of them from the backend, initdb, and documentation. Rewrite contrib/pg_freespacemap to match the new FSM implementation. Also introduce a new variant of the get_raw_page(regclass, int4, int4) function in contrib/pageinspect that let's you to return pages from any relation fork, and a new fsm_page_contents() function to inspect the new FSM pages.
This commit is contained in:
10
src/backend/utils/cache/relcache.c
vendored
10
src/backend/utils/cache/relcache.c
vendored
@ -8,7 +8,7 @@
|
||||
*
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $PostgreSQL: pgsql/src/backend/utils/cache/relcache.c,v 1.273 2008/08/10 19:02:33 tgl Exp $
|
||||
* $PostgreSQL: pgsql/src/backend/utils/cache/relcache.c,v 1.274 2008/09/30 10:52:13 heikki Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
@ -304,6 +304,7 @@ AllocateRelationDesc(Relation relation, Form_pg_class relp)
|
||||
*/
|
||||
MemSet(relation, 0, sizeof(RelationData));
|
||||
relation->rd_targblock = InvalidBlockNumber;
|
||||
relation->rd_fsm_nblocks_cache = InvalidBlockNumber;
|
||||
|
||||
/* make sure relation is marked as having no open file yet */
|
||||
relation->rd_smgr = NULL;
|
||||
@ -1364,6 +1365,7 @@ formrdesc(const char *relationName, Oid relationReltype,
|
||||
*/
|
||||
relation = (Relation) palloc0(sizeof(RelationData));
|
||||
relation->rd_targblock = InvalidBlockNumber;
|
||||
relation->rd_fsm_nblocks_cache = InvalidBlockNumber;
|
||||
|
||||
/* make sure relation is marked as having no open file yet */
|
||||
relation->rd_smgr = NULL;
|
||||
@ -1652,8 +1654,9 @@ RelationReloadIndexInfo(Relation relation)
|
||||
heap_freetuple(pg_class_tuple);
|
||||
/* We must recalculate physical address in case it changed */
|
||||
RelationInitPhysicalAddr(relation);
|
||||
/* Make sure targblock is reset in case rel was truncated */
|
||||
/* Must reset targblock and fsm_nblocks_cache in case rel was truncated */
|
||||
relation->rd_targblock = InvalidBlockNumber;
|
||||
relation->rd_fsm_nblocks_cache = InvalidBlockNumber;
|
||||
/* Must free any AM cached data, too */
|
||||
if (relation->rd_amcache)
|
||||
pfree(relation->rd_amcache);
|
||||
@ -1736,6 +1739,7 @@ RelationClearRelation(Relation relation, bool rebuild)
|
||||
if (relation->rd_isnailed)
|
||||
{
|
||||
relation->rd_targblock = InvalidBlockNumber;
|
||||
relation->rd_fsm_nblocks_cache = InvalidBlockNumber;
|
||||
if (relation->rd_rel->relkind == RELKIND_INDEX)
|
||||
{
|
||||
relation->rd_isvalid = false; /* needs to be revalidated */
|
||||
@ -2330,6 +2334,7 @@ RelationBuildLocalRelation(const char *relname,
|
||||
rel = (Relation) palloc0(sizeof(RelationData));
|
||||
|
||||
rel->rd_targblock = InvalidBlockNumber;
|
||||
rel->rd_fsm_nblocks_cache = InvalidBlockNumber;
|
||||
|
||||
/* make sure relation is marked as having no open file yet */
|
||||
rel->rd_smgr = NULL;
|
||||
@ -3586,6 +3591,7 @@ load_relcache_init_file(void)
|
||||
*/
|
||||
rel->rd_smgr = NULL;
|
||||
rel->rd_targblock = InvalidBlockNumber;
|
||||
rel->rd_fsm_nblocks_cache = InvalidBlockNumber;
|
||||
if (rel->rd_isnailed)
|
||||
rel->rd_refcnt = 1;
|
||||
else
|
||||
|
Reference in New Issue
Block a user