This is an automated email from the ASF dual-hosted git repository.

chenjinbao1989 pushed a commit to branch cbdb-postgres-merge
in repository https://gitbox.apache.org/repos/asf/cloudberry.git


The following commit(s) were added to refs/heads/cbdb-postgres-merge by this 
push:
     new 2d379a3cf1d Add BM_TEMP to buffer state for temp relation
2d379a3cf1d is described below

commit 2d379a3cf1dcc2375164c47fff971ffe7565c72d
Author: Jinbao Chen <[email protected]>
AuthorDate: Wed Dec 24 00:37:41 2025 +0800

    Add BM_TEMP to buffer state for temp relation
---
 src/backend/access/bitmap/bitmappages.c | 6 ++----
 src/backend/storage/buffer/bufmgr.c     | 7 +++++++
 2 files changed, 9 insertions(+), 4 deletions(-)

diff --git a/src/backend/access/bitmap/bitmappages.c 
b/src/backend/access/bitmap/bitmappages.c
index d4b9d1e3f4c..e9749000d9d 100644
--- a/src/backend/access/bitmap/bitmappages.c
+++ b/src/backend/access/bitmap/bitmappages.c
@@ -88,10 +88,8 @@ _bitmap_getbuf(Relation rel, BlockNumber blkno, int access)
                if (needLock)
                        LockRelationForExtension(rel, ExclusiveLock);
 
-               buf = ReadBuffer(rel, P_NEW);
-
-               /* Acquire buffer lock on new page */
-               LockBuffer(buf, BM_WRITE);
+               buf = ExtendBufferedRel(BMR_REL(rel), MAIN_FORKNUM, NULL,
+                                                               
EB_SKIP_EXTENSION_LOCK | EB_LOCK_FIRST);
 
                /*
                 * Release the file-extension lock; it's now OK for someone 
else to
diff --git a/src/backend/storage/buffer/bufmgr.c 
b/src/backend/storage/buffer/bufmgr.c
index f35efc9e13b..0f23037fb0e 100644
--- a/src/backend/storage/buffer/bufmgr.c
+++ b/src/backend/storage/buffer/bufmgr.c
@@ -2135,6 +2135,8 @@ ExtendBufferedRelShared(BufferManagerRelation bmr,
                        buf_state |= BM_TAG_VALID | BUF_USAGECOUNT_ONE;
                        if (bmr.relpersistence == RELPERSISTENCE_PERMANENT || 
fork == INIT_FORKNUM)
                                buf_state |= BM_PERMANENT;
+                       else if (bmr.relpersistence == RELPERSISTENCE_TEMP)
+                               buf_state |= BM_TAG_VALID | BM_TEMP | 
BUF_USAGECOUNT_ONE;
 
                        UnlockBufHdr(victim_buf_hdr, buf_state);
 
@@ -5472,6 +5474,11 @@ AbortBufferIO(Buffer buffer)
 
                        path = 
relpathperm(BufTagGetRelFileLocator(&buf_hdr->tag),
                                                           
BufTagGetForkNum(&buf_hdr->tag));
+
+                       path = 
relpathbackend(BufTagGetRelFileLocator(&buf_hdr->tag),
+                                                                 (buf_state & 
BM_TEMP) ?
+                                                                 
TempRelBackendId : InvalidBackendId,
+                                                                 
BufTagGetForkNum(&buf_hdr->tag));
                        ereport(WARNING,
                                        (errcode(ERRCODE_IO_ERROR),
                                         errmsg("could not write block %u of 
%s",


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to