mirror of
https://github.com/postgres/postgres.git
synced 2025-08-24 09:27:52 +03:00
Rethink the way FSM truncation works. Instead of WAL-logging FSM
truncations in FSM code, call FreeSpaceMapTruncateRel from smgr_redo. To make that cleaner from modularity point of view, move the WAL-logging one level up to RelationTruncate, and move RelationTruncate and all the related WAL-logging to new src/backend/catalog/storage.c file. Introduce new RelationCreateStorage and RelationDropStorage functions that are used instead of calling smgrcreate/smgrscheduleunlink directly. Move the pending rel deletion stuff from smgrcreate/smgrscheduleunlink to the new functions. This leaves smgr.c as a thin wrapper around md.c; all the transactional stuff is now in storage.c. This will make it easier to add new forks with similar truncation logic, like the visibility map.
This commit is contained in:
@@ -8,7 +8,7 @@
|
||||
* Portions Copyright (c) 1994, Regents of the University of California
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $PostgreSQL: pgsql/src/backend/storage/freespace/indexfsm.c,v 1.2 2008/10/06 08:04:11 heikki Exp $
|
||||
* $PostgreSQL: pgsql/src/backend/storage/freespace/indexfsm.c,v 1.3 2008/11/19 10:34:52 heikki Exp $
|
||||
*
|
||||
*
|
||||
* NOTES:
|
||||
@@ -30,20 +30,6 @@
|
||||
* Exported routines
|
||||
*/
|
||||
|
||||
/*
|
||||
* InitIndexFreeSpaceMap - Create or reset the FSM fork for relation.
|
||||
*/
|
||||
void
|
||||
InitIndexFreeSpaceMap(Relation rel)
|
||||
{
|
||||
/* Create FSM fork if it doesn't exist yet, or truncate it if it does */
|
||||
RelationOpenSmgr(rel);
|
||||
if (!smgrexists(rel->rd_smgr, FSM_FORKNUM))
|
||||
smgrcreate(rel->rd_smgr, FSM_FORKNUM, rel->rd_istemp, false);
|
||||
else
|
||||
smgrtruncate(rel->rd_smgr, FSM_FORKNUM, 0, rel->rd_istemp);
|
||||
}
|
||||
|
||||
/*
|
||||
* GetFreeIndexPage - return a free page from the FSM
|
||||
*
|
||||
@@ -79,18 +65,6 @@ RecordUsedIndexPage(Relation rel, BlockNumber usedBlock)
|
||||
RecordPageWithFreeSpace(rel, usedBlock, 0);
|
||||
}
|
||||
|
||||
/*
|
||||
* IndexFreeSpaceMapTruncate - adjust for truncation of a relation.
|
||||
*
|
||||
* We need to delete any stored data past the new relation length, so that
|
||||
* we don't bogusly return removed block numbers.
|
||||
*/
|
||||
void
|
||||
IndexFreeSpaceMapTruncate(Relation rel, BlockNumber nblocks)
|
||||
{
|
||||
FreeSpaceMapTruncateRel(rel, nblocks);
|
||||
}
|
||||
|
||||
/*
|
||||
* IndexFreeSpaceMapVacuum - scan and fix any inconsistencies in the FSM
|
||||
*/
|
||||
|
Reference in New Issue
Block a user