mirror of
https://github.com/postgres/postgres.git
synced 2025-08-19 23:22:23 +03:00
Convert many uses of ReadBuffer[Extended](P_NEW) to ExtendBufferedRel()
A few places are not converted. Some because they are tackled in later commits (e.g. hio.c, xlogutils.c), some because they are more complicated (e.g. brin_pageops.c). Having a few users of ReadBuffer(P_NEW) is good anyway, to ensure the backward compat path stays working. Discussion: https://postgr.es/m/20221029025420.eplyow6k7tgu6he3@awork3.anarazel.de
This commit is contained in:
@@ -440,12 +440,10 @@ ginbuildempty(Relation index)
|
||||
MetaBuffer;
|
||||
|
||||
/* An empty GIN index has two pages. */
|
||||
MetaBuffer =
|
||||
ReadBufferExtended(index, INIT_FORKNUM, P_NEW, RBM_NORMAL, NULL);
|
||||
LockBuffer(MetaBuffer, BUFFER_LOCK_EXCLUSIVE);
|
||||
RootBuffer =
|
||||
ReadBufferExtended(index, INIT_FORKNUM, P_NEW, RBM_NORMAL, NULL);
|
||||
LockBuffer(RootBuffer, BUFFER_LOCK_EXCLUSIVE);
|
||||
MetaBuffer = ExtendBufferedRel(EB_REL(index), INIT_FORKNUM, NULL,
|
||||
EB_LOCK_FIRST | EB_SKIP_EXTENSION_LOCK);
|
||||
RootBuffer = ExtendBufferedRel(EB_REL(index), INIT_FORKNUM, NULL,
|
||||
EB_LOCK_FIRST | EB_SKIP_EXTENSION_LOCK);
|
||||
|
||||
/* Initialize and xlog metabuffer and root buffer. */
|
||||
START_CRIT_SECTION();
|
||||
|
@@ -299,7 +299,6 @@ Buffer
|
||||
GinNewBuffer(Relation index)
|
||||
{
|
||||
Buffer buffer;
|
||||
bool needLock;
|
||||
|
||||
/* First, try to get a page from FSM */
|
||||
for (;;)
|
||||
@@ -328,15 +327,8 @@ GinNewBuffer(Relation index)
|
||||
}
|
||||
|
||||
/* Must extend the file */
|
||||
needLock = !RELATION_IS_LOCAL(index);
|
||||
if (needLock)
|
||||
LockRelationForExtension(index, ExclusiveLock);
|
||||
|
||||
buffer = ReadBuffer(index, P_NEW);
|
||||
LockBuffer(buffer, GIN_EXCLUSIVE);
|
||||
|
||||
if (needLock)
|
||||
UnlockRelationForExtension(index, ExclusiveLock);
|
||||
buffer = ExtendBufferedRel(EB_REL(index), MAIN_FORKNUM, NULL,
|
||||
EB_LOCK_FIRST);
|
||||
|
||||
return buffer;
|
||||
}
|
||||
|
Reference in New Issue
Block a user