From f732357784a87fa8b55686c5266413fe773031e1 Mon Sep 17 00:00:00 2001 From: chenlinfeng <723609220@qq.com> Date: Mon, 17 Feb 2025 09:48:05 +0800 Subject: [PATCH 1/5] =?UTF-8?q?1=EF=BC=9A=E8=A7=A3=E5=86=B3=E9=87=8D?= =?UTF-8?q?=E5=90=AF=E5=90=8E=E6=97=A0=E6=B3=95=E8=BF=9E=E6=8E=A5database?= =?UTF-8?q?=202:=E8=A7=A3=E5=86=B3=E6=96=B0=E5=A2=9E=E6=AE=B5=E6=96=87?= =?UTF-8?q?=E4=BB=B6=E5=A4=B1=E8=B4=A5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/backend/storage/smgr/md.c | 22 +++++++++++----------- src/include/storage/page_compression.h | 2 ++ 2 files changed, 13 insertions(+), 11 deletions(-) diff --git a/src/backend/storage/smgr/md.c b/src/backend/storage/smgr/md.c index 1c89105..ed2638a 100644 --- a/src/backend/storage/smgr/md.c +++ b/src/backend/storage/smgr/md.c @@ -916,14 +916,14 @@ mdnblocks(SMgrRelation reln, ForkNumber forknum) */ segno = reln->md_num_open_segs[forknum] - 1; v = &reln->md_seg_fds[forknum][segno]; - + BlockNumber relSegSize = KPHC_IS_COMPRESSED_MAINFORK(reln, forknum) ? KPHC_CFS_LOGIC_BLOCKS_PER_FILE : RELSEG_SIZE; for (;;) { nblocks = _mdnblocks(reln, forknum, v); - if (nblocks > ((BlockNumber) RELSEG_SIZE)) + if (nblocks > ((BlockNumber) relSegSize)) elog(FATAL, "segment too big"); - if (nblocks < ((BlockNumber) RELSEG_SIZE)) - return (segno * ((BlockNumber) RELSEG_SIZE)) + nblocks; + if (nblocks < ((BlockNumber) relSegSize)) + return (segno * ((BlockNumber) relSegSize)) + nblocks; /* * If segment is exactly RELSEG_SIZE, advance to next one. @@ -939,7 +939,7 @@ mdnblocks(SMgrRelation reln, ForkNumber forknum) */ v = _mdfd_openseg(reln, forknum, segno, 0); if (v == NULL) - return segno * ((BlockNumber) RELSEG_SIZE); + return segno * ((BlockNumber) relSegSize); } } @@ -1326,8 +1326,8 @@ _mdfd_getseg(SMgrRelation reln, ForkNumber forknum, BlockNumber blkno, Assert(behavior & (EXTENSION_FAIL | EXTENSION_CREATE | EXTENSION_RETURN_NULL | EXTENSION_DONT_OPEN)); - - targetseg = blkno / ((BlockNumber) RELSEG_SIZE); + BlockNumber relSegSize = KPHC_IS_COMPRESSED_MAINFORK(reln, forknum) ? KPHC_CFS_LOGIC_BLOCKS_PER_FILE : RELSEG_SIZE; + targetseg = blkno / ((BlockNumber) relSegSize); /* if an existing and opened segment, we're done */ if (targetseg < reln->md_num_open_segs[forknum]) @@ -1364,7 +1364,7 @@ _mdfd_getseg(SMgrRelation reln, ForkNumber forknum, BlockNumber blkno, Assert(nextsegno == v->mdfd_segno + 1); - if (nblocks > ((BlockNumber) RELSEG_SIZE)) + if (nblocks > ((BlockNumber) relSegSize)) elog(FATAL, "segment too big"); if ((behavior & EXTENSION_CREATE) || @@ -1384,19 +1384,19 @@ _mdfd_getseg(SMgrRelation reln, ForkNumber forknum, BlockNumber blkno, * matters if in recovery, or if the caller is extending the * relation discontiguously, but that can happen in hash indexes.) */ - if (nblocks < ((BlockNumber) RELSEG_SIZE)) + if (nblocks < ((BlockNumber) relSegSize)) { char *zerobuf = palloc0(BLCKSZ); mdextend(reln, forknum, - nextsegno * ((BlockNumber) RELSEG_SIZE) - 1, + nextsegno * ((BlockNumber) relSegSize) - 1, zerobuf, skipFsync); pfree(zerobuf); } flags = O_CREAT; } else if (!(behavior & EXTENSION_DONT_CHECK_SIZE) && - nblocks < ((BlockNumber) RELSEG_SIZE)) + nblocks < ((BlockNumber) relSegSize)) { /* * When not extending (or explicitly including truncated diff --git a/src/include/storage/page_compression.h b/src/include/storage/page_compression.h index c31f699..05ab684 100644 --- a/src/include/storage/page_compression.h +++ b/src/include/storage/page_compression.h @@ -117,6 +117,8 @@ extern const uint32 INDEX_OF_SIXTEENTHS_BLCKSZ; #define KPHC_CFS_EXTENT_SIZE 129 +#defien KPHC_CFS_LOGIC_COUNT_PER_FILE (RELSEG_SIZE / KPHC_CFS_EXTENT_SIZE) +#define KPHC_CFS_LOGIC_BLOCKS_PERpFILE (KPHC_CFS_LOGIC_BLOCKS_PER_EXTENT * KPHC_CFS_LOGIC_COUNT_PER_FILE) #define KPHC_CFS_LOGIC_BLOCKS_PER_EXTENT (KPHC_CFS_EXTENT_SIZE - 1) extern const int KPHC_EXTENT_OPEN_FILE; -- Gitee From ada6ba103e8b7190216bd8fb752ac5449430f0d7 Mon Sep 17 00:00:00 2001 From: chenlinfeng <723609220@qq.com> Date: Mon, 17 Feb 2025 09:59:30 +0800 Subject: [PATCH 2/5] =?UTF-8?q?1=EF=BC=9A=E8=A7=A3=E5=86=B3=E9=87=8D?= =?UTF-8?q?=E5=90=AF=E5=90=8E=E6=97=A0=E6=B3=95=E8=BF=9E=E6=8E=A5database?= =?UTF-8?q?=202:=E8=A7=A3=E5=86=B3=E6=96=B0=E5=A2=9E=E6=AE=B5=E6=96=87?= =?UTF-8?q?=E4=BB=B6=E5=A4=B1=E8=B4=A5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/include/storage/page_compression.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/include/storage/page_compression.h b/src/include/storage/page_compression.h index 05ab684..0b0331a 100644 --- a/src/include/storage/page_compression.h +++ b/src/include/storage/page_compression.h @@ -117,7 +117,7 @@ extern const uint32 INDEX_OF_SIXTEENTHS_BLCKSZ; #define KPHC_CFS_EXTENT_SIZE 129 -#defien KPHC_CFS_LOGIC_COUNT_PER_FILE (RELSEG_SIZE / KPHC_CFS_EXTENT_SIZE) +#define KPHC_CFS_LOGIC_COUNT_PER_FILE (RELSEG_SIZE / KPHC_CFS_EXTENT_SIZE) #define KPHC_CFS_LOGIC_BLOCKS_PERpFILE (KPHC_CFS_LOGIC_BLOCKS_PER_EXTENT * KPHC_CFS_LOGIC_COUNT_PER_FILE) #define KPHC_CFS_LOGIC_BLOCKS_PER_EXTENT (KPHC_CFS_EXTENT_SIZE - 1) -- Gitee From af9e565d7177b6e752ad53e6d70ffdeb4c62529f Mon Sep 17 00:00:00 2001 From: chenlinfeng <723609220@qq.com> Date: Mon, 17 Feb 2025 10:02:12 +0800 Subject: [PATCH 3/5] =?UTF-8?q?1=EF=BC=9A=E8=A7=A3=E5=86=B3=E9=87=8D?= =?UTF-8?q?=E5=90=AF=E5=90=8E=E6=97=A0=E6=B3=95=E8=BF=9E=E6=8E=A5database?= =?UTF-8?q?=202:=E8=A7=A3=E5=86=B3=E6=96=B0=E5=A2=9E=E6=AE=B5=E6=96=87?= =?UTF-8?q?=E4=BB=B6=E5=A4=B1=E8=B4=A5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/include/storage/page_compression.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/include/storage/page_compression.h b/src/include/storage/page_compression.h index 0b0331a..16d53b0 100644 --- a/src/include/storage/page_compression.h +++ b/src/include/storage/page_compression.h @@ -118,7 +118,7 @@ extern const uint32 INDEX_OF_SIXTEENTHS_BLCKSZ; #define KPHC_CFS_EXTENT_SIZE 129 #define KPHC_CFS_LOGIC_COUNT_PER_FILE (RELSEG_SIZE / KPHC_CFS_EXTENT_SIZE) -#define KPHC_CFS_LOGIC_BLOCKS_PERpFILE (KPHC_CFS_LOGIC_BLOCKS_PER_EXTENT * KPHC_CFS_LOGIC_COUNT_PER_FILE) +#define KPHC_CFS_LOGIC_BLOCKS_PER_FILE (KPHC_CFS_LOGIC_BLOCKS_PER_EXTENT * KPHC_CFS_LOGIC_COUNT_PER_FILE) #define KPHC_CFS_LOGIC_BLOCKS_PER_EXTENT (KPHC_CFS_EXTENT_SIZE - 1) extern const int KPHC_EXTENT_OPEN_FILE; -- Gitee From e9ad9bcdbc35fe3224df5a646e249948335eda01 Mon Sep 17 00:00:00 2001 From: chenlinfeng <723609220@qq.com> Date: Mon, 17 Feb 2025 10:10:38 +0800 Subject: [PATCH 4/5] =?UTF-8?q?1=EF=BC=9A=E8=A7=A3=E5=86=B3=E9=87=8D?= =?UTF-8?q?=E5=90=AF=E5=90=8E=E6=97=A0=E6=B3=95=E8=BF=9E=E6=8E=A5database?= =?UTF-8?q?=202:=E8=A7=A3=E5=86=B3=E6=96=B0=E5=A2=9E=E6=AE=B5=E6=96=87?= =?UTF-8?q?=E4=BB=B6=E5=A4=B1=E8=B4=A5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/backend/storage/smgr/md.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/backend/storage/smgr/md.c b/src/backend/storage/smgr/md.c index ed2638a..1cfad80 100644 --- a/src/backend/storage/smgr/md.c +++ b/src/backend/storage/smgr/md.c @@ -895,7 +895,7 @@ mdnblocks(SMgrRelation reln, ForkNumber forknum) MdfdVec *v; BlockNumber nblocks; BlockNumber segno; - + BlockNumber relSegSize; mdopenfork(reln, forknum, EXTENSION_FAIL); /* mdopen has opened the first segment */ @@ -916,7 +916,7 @@ mdnblocks(SMgrRelation reln, ForkNumber forknum) */ segno = reln->md_num_open_segs[forknum] - 1; v = &reln->md_seg_fds[forknum][segno]; - BlockNumber relSegSize = KPHC_IS_COMPRESSED_MAINFORK(reln, forknum) ? KPHC_CFS_LOGIC_BLOCKS_PER_FILE : RELSEG_SIZE; + relSegSize = KPHC_IS_COMPRESSED_MAINFORK(reln, forknum) ? KPHC_CFS_LOGIC_BLOCKS_PER_FILE : RELSEG_SIZE; for (;;) { nblocks = _mdnblocks(reln, forknum, v); @@ -1321,12 +1321,12 @@ _mdfd_getseg(SMgrRelation reln, ForkNumber forknum, BlockNumber blkno, MdfdVec *v; BlockNumber targetseg; BlockNumber nextsegno; - + BlockNumber relSegSize; /* some way to handle non-existent segments needs to be specified */ Assert(behavior & (EXTENSION_FAIL | EXTENSION_CREATE | EXTENSION_RETURN_NULL | EXTENSION_DONT_OPEN)); - BlockNumber relSegSize = KPHC_IS_COMPRESSED_MAINFORK(reln, forknum) ? KPHC_CFS_LOGIC_BLOCKS_PER_FILE : RELSEG_SIZE; + relSegSize = KPHC_IS_COMPRESSED_MAINFORK(reln, forknum) ? KPHC_CFS_LOGIC_BLOCKS_PER_FILE : RELSEG_SIZE; targetseg = blkno / ((BlockNumber) relSegSize); /* if an existing and opened segment, we're done */ -- Gitee From 201a7aff71410d000ff421dec8715859e506127e Mon Sep 17 00:00:00 2001 From: chenlinfeng <723609220@qq.com> Date: Mon, 17 Feb 2025 10:23:40 +0800 Subject: [PATCH 5/5] =?UTF-8?q?1=EF=BC=9A=E8=A7=A3=E5=86=B3=E9=87=8D?= =?UTF-8?q?=E5=90=AF=E5=90=8E=E6=97=A0=E6=B3=95=E8=BF=9E=E6=8E=A5database?= =?UTF-8?q?=202:=E8=A7=A3=E5=86=B3=E6=96=B0=E5=A2=9E=E6=AE=B5=E6=96=87?= =?UTF-8?q?=E4=BB=B6=E5=A4=B1=E8=B4=A5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/backend/commands/dbcommands.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/backend/commands/dbcommands.c b/src/backend/commands/dbcommands.c index 93f0c73..1cd2b16 100644 --- a/src/backend/commands/dbcommands.c +++ b/src/backend/commands/dbcommands.c @@ -438,7 +438,7 @@ ScanSourceDatabasePgClassTuple(HeapTupleData *tuple, Oid tbid, Oid dbid, relinfo->rnode.dbNode = dbid; relinfo->rnode.relNode = relfilenode; relinfo->reloid = classForm->oid; - + relinfo->rnode.opt = 0; /* Temporary relations were rejected above. */ Assert(classForm->relpersistence != RELPERSISTENCE_TEMP); relinfo->permanent = -- Gitee