diff --git a/src/backend/commands/dbcommands.c b/src/backend/commands/dbcommands.c index 93f0c739e5519711a44f3e1d6e9e9540891b598a..1cd2b16ae38323ae7453081600845e463348577e 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 = diff --git a/src/backend/storage/smgr/md.c b/src/backend/storage/smgr/md.c index 1c8910563180e2c6f4258e42531915f40aba1e23..1cfad80e9ae062027195474d726483ae1afb4c8a 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,14 +916,14 @@ mdnblocks(SMgrRelation reln, ForkNumber forknum) */ segno = reln->md_num_open_segs[forknum] - 1; v = &reln->md_seg_fds[forknum][segno]; - + 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); } } @@ -1321,13 +1321,13 @@ _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)); - - targetseg = blkno / ((BlockNumber) 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 */ 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 c31f6996bf2d33b33850d9f1ef32cf20d781fe72..16d53b067e3e4e3a4d8587f35bade17f502e35e3 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 +#define KPHC_CFS_LOGIC_COUNT_PER_FILE (RELSEG_SIZE / KPHC_CFS_EXTENT_SIZE) +#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;