v1-0001-MD-smgr-Unlink-the-requested-file-segment-not-mai.patch
application/octet-stream
Filename: v1-0001-MD-smgr-Unlink-the-requested-file-segment-not-mai.patch
Type: application/octet-stream
Part: 0
Patch
Same data as JSON:
GET /api/v1/attachments/:id/patch
the parsed metadata as JSON — format, series position, per-file stats; never the diff bytes.
API reference →
Format: format-patch
Series: patch v1-0001
Subject: MD smgr: Unlink the requested file segment, not main fork segment 0
| File | + | − |
|---|---|---|
| src/backend/storage/smgr/md.c | 16 | 2 |
From e7818a6579d644eb1caeedd6edb3740ae796f718 Mon Sep 17 00:00:00 2001
From: Matthias van de Meent <boekewurm+postgres@gmail.com>
Date: Fri, 20 Dec 2024 19:25:16 +0100
Subject: [PATCH v1] MD smgr: Unlink the requested file segment, not main fork
segment 0
While it seems like we only unlink segment 0 of any fork, it's
better to just comply with the request, instead of ignoring the
provided information.
Backpatch: 13, the oldest supported release.
---
src/backend/storage/smgr/md.c | 18 ++++++++++++++++--
1 file changed, 16 insertions(+), 2 deletions(-)
diff --git a/src/backend/storage/smgr/md.c b/src/backend/storage/smgr/md.c
index cc8a80ee96..3175ec252a 100644
--- a/src/backend/storage/smgr/md.c
+++ b/src/backend/storage/smgr/md.c
@@ -133,6 +133,8 @@ static void _fdvec_resize(SMgrRelation reln,
int nseg);
static char *_mdfd_segpath(SMgrRelation reln, ForkNumber forknum,
BlockNumber segno);
+static char *_mdfd_segpath_rflb(RelFileLocatorBackend reln, ForkNumber forknum,
+ BlockNumber segno);
static MdfdVec *_mdfd_openseg(SMgrRelation reln, ForkNumber forknum,
BlockNumber segno, int oflags);
static MdfdVec *_mdfd_getseg(SMgrRelation reln, ForkNumber forknum,
@@ -1535,11 +1537,18 @@ _fdvec_resize(SMgrRelation reln,
*/
static char *
_mdfd_segpath(SMgrRelation reln, ForkNumber forknum, BlockNumber segno)
+{
+ return _mdfd_segpath_rflb(reln->smgr_rlocator, forknum, segno);
+}
+
+static char *
+_mdfd_segpath_rflb(RelFileLocatorBackend reln, ForkNumber forknum,
+ BlockNumber segno)
{
char *path,
*fullpath;
- path = relpath(reln->smgr_rlocator, forknum);
+ path = relpath(reln, forknum);
if (segno > 0)
{
@@ -1810,9 +1819,14 @@ int
mdunlinkfiletag(const FileTag *ftag, char *path)
{
char *p;
+ RelFileLocatorBackend rlfb = {
+ .locator = ftag->rlocator,
+ .backend = INVALID_PROC_NUMBER,
+ };
+ Assert(ftag->segno == 0);
/* Compute the path. */
- p = relpathperm(ftag->rlocator, MAIN_FORKNUM);
+ p = _mdfd_segpath_rflb(rlfb, ftag->forknum, ftag->segno);
strlcpy(path, p, MAXPGPATH);
pfree(p);
--
2.45.2