summaryrefslogtreecommitdiff
path: root/src/backend/storage/buffer/bufmgr.c
diff options
context:
space:
mode:
authorAndres Freund <andres@anarazel.de>2025-03-15 12:30:07 -0400
committerAndres Freund <andres@anarazel.de>2025-03-15 22:07:48 -0400
commit4b4d33b9ea9ff6bdc813b5b7b1aa4a6a3a2a2d5c (patch)
treeeea4e0567dada3dca9ff3dc9a74c28069916575c /src/backend/storage/buffer/bufmgr.c
parentdd6f2618f681e699cb5f2122a3f036beaa89f992 (diff)
localbuf: Introduce FlushLocalBuffer()
Previously we had two paths implementing writing out temporary table buffers. For shared buffers, the logic for that is centralized in FlushBuffer(). Introduce FlushLocalBuffer() to do the same for local buffers. Besides being a nice cleanup on its own, it also makes an upcoming change slightly easier. Reviewed-by: Melanie Plageman <melanieplageman@gmail.com> Discussion: https://postgr.es/m/CAAKRu_b9anbWzEs5AAF9WCvcEVmgz-1AkHSQ-CLLy-p7WHzvFw@mail.gmail.com
Diffstat (limited to 'src/backend/storage/buffer/bufmgr.c')
-rw-r--r--src/backend/storage/buffer/bufmgr.c22
1 files changed, 1 insertions, 21 deletions
diff --git a/src/backend/storage/buffer/bufmgr.c b/src/backend/storage/buffer/bufmgr.c
index a716074467f..f3c27d7e77a 100644
--- a/src/backend/storage/buffer/bufmgr.c
+++ b/src/backend/storage/buffer/bufmgr.c
@@ -4453,7 +4453,6 @@ FlushRelationBuffers(Relation rel)
for (i = 0; i < NLocBuffer; i++)
{
uint32 buf_state;
- instr_time io_start;
bufHdr = GetLocalBufferDescriptor(i);
if (BufTagMatchesRelFileLocator(&bufHdr->tag, &rel->rd_locator) &&
@@ -4461,9 +4460,6 @@ FlushRelationBuffers(Relation rel)
(BM_VALID | BM_DIRTY)) == (BM_VALID | BM_DIRTY))
{
ErrorContextCallback errcallback;
- Page localpage;
-
- localpage = (char *) LocalBufHdrGetBlock(bufHdr);
/* Setup error traceback support for ereport() */
errcallback.callback = local_buffer_write_error_callback;
@@ -4471,23 +4467,7 @@ FlushRelationBuffers(Relation rel)
errcallback.previous = error_context_stack;
error_context_stack = &errcallback;
- PageSetChecksumInplace(localpage, bufHdr->tag.blockNum);
-
- io_start = pgstat_prepare_io_time(track_io_timing);
-
- smgrwrite(srel,
- BufTagGetForkNum(&bufHdr->tag),
- bufHdr->tag.blockNum,
- localpage,
- false);
-
- pgstat_count_io_op_time(IOOBJECT_TEMP_RELATION,
- IOCONTEXT_NORMAL, IOOP_WRITE,
- io_start, 1, BLCKSZ);
-
- TerminateLocalBufferIO(bufHdr, true, 0);
-
- pgBufferUsage.local_blks_written++;
+ FlushLocalBuffer(bufHdr, srel);
/* Pop the error context stack */
error_context_stack = errcallback.previous;