Skip to content

Commit

Permalink
ExtendBufferedWhat -> BufferManagerRelation.
Browse files Browse the repository at this point in the history
Commit 31966b1 invented a way for functions dealing with relation
extension to accept a Relation in online code and an SMgrRelation in
recovery code.  It seems highly likely that future bufmgr.c interfaces
will face the same problem, and need to do something similar.
Generalize the names so that each interface doesn't have to re-invent
the wheel.

Back-patch to 16.  Since extension AM authors might start using the
constructor macros once 16 ships, we agreed to do the rename in 16
rather than waiting for 17.

Reviewed-by: Peter Geoghegan <pg@bowt.ie>
Reviewed-by: Andres Freund <andres@anarazel.de>
Discussion: https://postgr.es/m/CA%2BhUKG%2B6tLD2BhpRWycEoti6LVLyQq457UL4ticP5xd8LqHySA%40mail.gmail.com
  • Loading branch information
macdice committed Aug 23, 2023
1 parent 37188ce commit 7114791
Show file tree
Hide file tree
Showing 20 changed files with 90 additions and 90 deletions.
2 changes: 1 addition & 1 deletion contrib/bloom/blutils.c
Expand Up @@ -386,7 +386,7 @@ BloomNewBuffer(Relation index)
}

/* Must extend the file */
buffer = ExtendBufferedRel(EB_REL(index), MAIN_FORKNUM, NULL,
buffer = ExtendBufferedRel(BMR_REL(index), MAIN_FORKNUM, NULL,
EB_LOCK_FIRST);

return buffer;
Expand Down
4 changes: 2 additions & 2 deletions src/backend/access/brin/brin.c
Expand Up @@ -848,7 +848,7 @@ brinbuild(Relation heap, Relation index, IndexInfo *indexInfo)
* whole relation will be rolled back.
*/

meta = ExtendBufferedRel(EB_REL(index), MAIN_FORKNUM, NULL,
meta = ExtendBufferedRel(BMR_REL(index), MAIN_FORKNUM, NULL,
EB_LOCK_FIRST | EB_SKIP_EXTENSION_LOCK);
Assert(BufferGetBlockNumber(meta) == BRIN_METAPAGE_BLKNO);

Expand Down Expand Up @@ -915,7 +915,7 @@ brinbuildempty(Relation index)
Buffer metabuf;

/* An empty BRIN index has a metapage only. */
metabuf = ExtendBufferedRel(EB_REL(index), INIT_FORKNUM, NULL,
metabuf = ExtendBufferedRel(BMR_REL(index), INIT_FORKNUM, NULL,
EB_LOCK_FIRST | EB_SKIP_EXTENSION_LOCK);

/* Initialize and xlog metabuffer. */
Expand Down
2 changes: 1 addition & 1 deletion src/backend/access/brin/brin_revmap.c
Expand Up @@ -569,7 +569,7 @@ revmap_physical_extend(BrinRevmap *revmap)
}
else
{
buf = ExtendBufferedRel(EB_REL(irel), MAIN_FORKNUM, NULL,
buf = ExtendBufferedRel(BMR_REL(irel), MAIN_FORKNUM, NULL,
EB_LOCK_FIRST);
if (BufferGetBlockNumber(buf) != mapBlk)
{
Expand Down
4 changes: 2 additions & 2 deletions src/backend/access/gin/gininsert.c
Expand Up @@ -440,9 +440,9 @@ ginbuildempty(Relation index)
MetaBuffer;

/* An empty GIN index has two pages. */
MetaBuffer = ExtendBufferedRel(EB_REL(index), INIT_FORKNUM, NULL,
MetaBuffer = ExtendBufferedRel(BMR_REL(index), INIT_FORKNUM, NULL,
EB_LOCK_FIRST | EB_SKIP_EXTENSION_LOCK);
RootBuffer = ExtendBufferedRel(EB_REL(index), INIT_FORKNUM, NULL,
RootBuffer = ExtendBufferedRel(BMR_REL(index), INIT_FORKNUM, NULL,
EB_LOCK_FIRST | EB_SKIP_EXTENSION_LOCK);

/* Initialize and xlog metabuffer and root buffer. */
Expand Down
2 changes: 1 addition & 1 deletion src/backend/access/gin/ginutil.c
Expand Up @@ -327,7 +327,7 @@ GinNewBuffer(Relation index)
}

/* Must extend the file */
buffer = ExtendBufferedRel(EB_REL(index), MAIN_FORKNUM, NULL,
buffer = ExtendBufferedRel(BMR_REL(index), MAIN_FORKNUM, NULL,
EB_LOCK_FIRST);

return buffer;
Expand Down
2 changes: 1 addition & 1 deletion src/backend/access/gist/gist.c
Expand Up @@ -134,7 +134,7 @@ gistbuildempty(Relation index)
Buffer buffer;

/* Initialize the root page */
buffer = ExtendBufferedRel(EB_REL(index), INIT_FORKNUM, NULL,
buffer = ExtendBufferedRel(BMR_REL(index), INIT_FORKNUM, NULL,
EB_SKIP_EXTENSION_LOCK | EB_LOCK_FIRST);

/* Initialize and xlog buffer */
Expand Down
2 changes: 1 addition & 1 deletion src/backend/access/gist/gistutil.c
Expand Up @@ -877,7 +877,7 @@ gistNewBuffer(Relation r, Relation heaprel)
}

/* Must extend the file */
buffer = ExtendBufferedRel(EB_REL(r), MAIN_FORKNUM, NULL,
buffer = ExtendBufferedRel(BMR_REL(r), MAIN_FORKNUM, NULL,
EB_LOCK_FIRST);

return buffer;
Expand Down
2 changes: 1 addition & 1 deletion src/backend/access/hash/hashpage.c
Expand Up @@ -209,7 +209,7 @@ _hash_getnewbuf(Relation rel, BlockNumber blkno, ForkNumber forkNum)
/* smgr insists we explicitly extend the relation */
if (blkno == nblocks)
{
buf = ExtendBufferedRel(EB_REL(rel), forkNum, NULL,
buf = ExtendBufferedRel(BMR_REL(rel), forkNum, NULL,
EB_LOCK_FIRST | EB_SKIP_EXTENSION_LOCK);
if (BufferGetBlockNumber(buf) != blkno)
elog(ERROR, "unexpected hash relation size: %u, should be %u",
Expand Down
2 changes: 1 addition & 1 deletion src/backend/access/heap/hio.c
Expand Up @@ -339,7 +339,7 @@ RelationAddBlocks(Relation relation, BulkInsertState bistate,
* [auto]vacuum trying to truncate later pages as REL_TRUNCATE_MINIMUM is
* way larger.
*/
first_block = ExtendBufferedRelBy(EB_REL(relation), MAIN_FORKNUM,
first_block = ExtendBufferedRelBy(BMR_REL(relation), MAIN_FORKNUM,
bistate ? bistate->strategy : NULL,
EB_LOCK_FIRST,
extend_by_pages,
Expand Down
2 changes: 1 addition & 1 deletion src/backend/access/heap/visibilitymap.c
Expand Up @@ -628,7 +628,7 @@ vm_extend(Relation rel, BlockNumber vm_nblocks)
{
Buffer buf;

buf = ExtendBufferedRelTo(EB_REL(rel), VISIBILITYMAP_FORKNUM, NULL,
buf = ExtendBufferedRelTo(BMR_REL(rel), VISIBILITYMAP_FORKNUM, NULL,
EB_CREATE_FORK_IF_NEEDED |
EB_CLEAR_SIZE_CACHE,
vm_nblocks,
Expand Down
2 changes: 1 addition & 1 deletion src/backend/access/nbtree/nbtpage.c
Expand Up @@ -975,7 +975,7 @@ _bt_allocbuf(Relation rel, Relation heaprel)
* otherwise would make, as we can't use _bt_lockbuf() without introducing
* a race.
*/
buf = ExtendBufferedRel(EB_REL(rel), MAIN_FORKNUM, NULL, EB_LOCK_FIRST);
buf = ExtendBufferedRel(BMR_REL(rel), MAIN_FORKNUM, NULL, EB_LOCK_FIRST);
if (!RelationUsesLocalBuffers(rel))
VALGRIND_MAKE_MEM_DEFINED(BufferGetPage(buf), BLCKSZ);

Expand Down
2 changes: 1 addition & 1 deletion src/backend/access/spgist/spgutils.c
Expand Up @@ -405,7 +405,7 @@ SpGistNewBuffer(Relation index)
ReleaseBuffer(buffer);
}

buffer = ExtendBufferedRel(EB_REL(index), MAIN_FORKNUM, NULL,
buffer = ExtendBufferedRel(BMR_REL(index), MAIN_FORKNUM, NULL,
EB_LOCK_FIRST);

return buffer;
Expand Down
2 changes: 1 addition & 1 deletion src/backend/access/transam/xlogutils.c
Expand Up @@ -524,7 +524,7 @@ XLogReadBufferExtended(RelFileLocator rlocator, ForkNumber forknum,
/* OK to extend the file */
/* we do this in recovery only - no rel-extension lock needed */
Assert(InRecovery);
buffer = ExtendBufferedRelTo(EB_SMGR(smgr, RELPERSISTENCE_PERMANENT),
buffer = ExtendBufferedRelTo(BMR_SMGR(smgr, RELPERSISTENCE_PERMANENT),
forknum,
NULL,
EB_PERFORMING_RECOVERY |
Expand Down
2 changes: 1 addition & 1 deletion src/backend/commands/sequence.c
Expand Up @@ -377,7 +377,7 @@ fill_seq_fork_with_data(Relation rel, HeapTuple tuple, ForkNumber forkNum)

/* Initialize first page of relation with special magic number */

buf = ExtendBufferedRel(EB_REL(rel), forkNum, NULL,
buf = ExtendBufferedRel(BMR_REL(rel), forkNum, NULL,
EB_LOCK_FIRST | EB_SKIP_EXTENSION_LOCK);
Assert(BufferGetBlockNumber(buf) == 0);

Expand Down

0 comments on commit 7114791

Please sign in to comment.