Skip to content

Commit f8f7afc

Browse files
authored
Merge pull request #28 from postgrespro/PBCKP-278_cfs-ptrack
Pbckp 278 cfs ptrack review fixes
2 parents 6173b21 + d3b427b commit f8f7afc

File tree

3 files changed

+19
-14
lines changed

3 files changed

+19
-14
lines changed

Diff for: engine.c

+9-9
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ is_cfm_file_path(const char *filepath) {
109109
return strlen(filepath) >= 5 && strcmp(&filepath[len-4], ".cfm") == 0;
110110
}
111111

112-
#ifdef PGPRO_EE
112+
#if CFS_SUPPORT
113113
/*
114114
* Determines the relation file size specified by fullpath as if it
115115
* was not compressed.
@@ -120,7 +120,7 @@ get_cfs_relation_file_decompressed_size(RelFileNodeBackend rnode, const char *fu
120120
int compressor;
121121
off_t size;
122122

123-
compressor = md_get_compressor_internal(rnode.node, rnode.backend, forknum);
123+
compressor = md_get_compressor_internal(nodeOf(rnode), rnode.backend, forknum);
124124
fd = PathNameOpenFile(fullpath, O_RDWR | PG_BINARY, compressor);
125125

126126
if(fd < 0)
@@ -540,7 +540,7 @@ assign_ptrack_map_size(int newval, void *extra)
540540
* For use in functions that copy directories bypassing buffer manager.
541541
*/
542542
static void
543-
#ifdef PGPRO_EE
543+
#if CFS_SUPPORT
544544
ptrack_mark_file(Oid dbOid, Oid tablespaceOid,
545545
const char *filepath, const char *filename, bool is_cfs)
546546
#else
@@ -555,7 +555,7 @@ ptrack_mark_file(Oid dbOid, Oid tablespaceOid,
555555
struct stat stat_buf;
556556
int oidchars;
557557
char oidbuf[OIDCHARS + 1];
558-
#ifdef PGPRO_EE
558+
#if CFS_SUPPORT
559559
off_t rel_size;
560560
#endif
561561

@@ -576,11 +576,11 @@ ptrack_mark_file(Oid dbOid, Oid tablespaceOid,
576576
oidbuf[oidchars] = '\0';
577577
nodeRel(nodeOf(rnode)) = atooid(oidbuf);
578578

579-
#ifdef PGPRO_EE
579+
#if CFS_SUPPORT
580580
// if current tablespace is cfs-compressed and md_get_compressor_internal
581581
// returns the type of the compressing algorithm for filepath, then it
582582
// needs to be de-compressed to obtain its size
583-
if(is_cfs && md_get_compressor_internal(rnode.node, rnode.backend, forknum) != 0) {
583+
if(is_cfs && md_get_compressor_internal(nodeOf(rnode), rnode.backend, forknum) != 0) {
584584
rel_size = get_cfs_relation_file_decompressed_size(rnode, filepath, forknum);
585585

586586
if(rel_size == (off_t)-1) {
@@ -611,7 +611,7 @@ ptrack_walkdir(const char *path, Oid tablespaceOid, Oid dbOid)
611611
{
612612
DIR *dir;
613613
struct dirent *de;
614-
#ifdef PGPRO_EE
614+
#if CFS_SUPPORT
615615
bool is_cfs;
616616
#endif
617617

@@ -622,7 +622,7 @@ ptrack_walkdir(const char *path, Oid tablespaceOid, Oid dbOid)
622622
|| InitializingParallelWorker)
623623
return;
624624

625-
#ifdef PGPRO_EE
625+
#if CFS_SUPPORT
626626
is_cfs = file_is_in_cfs_tablespace(path);
627627
#endif
628628

@@ -653,7 +653,7 @@ ptrack_walkdir(const char *path, Oid tablespaceOid, Oid dbOid)
653653
}
654654

655655
if (S_ISREG(fst.st_mode))
656-
#ifdef PGPRO_EE
656+
#if CFS_SUPPORT
657657
ptrack_mark_file(dbOid, tablespaceOid, subpath, de->d_name, is_cfs);
658658
#else
659659
ptrack_mark_file(dbOid, tablespaceOid, subpath, de->d_name);

Diff for: engine.h

+5
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,11 @@
4444
#define PTRACK_MAGIC "ptk"
4545
#define PTRACK_MAGIC_SIZE 4
4646

47+
/* CFS support macro */
48+
#if defined(PGPRO_EE) && PG_VERSION_NUM >= 120000
49+
#define CFS_SUPPORT 1
50+
#endif
51+
4752
/*
4853
* Header of ptrack map.
4954
*/

Diff for: ptrack.c

+5-5
Original file line numberDiff line numberDiff line change
@@ -294,7 +294,7 @@ ptrack_gather_filelist(List **filelist, char *path, Oid spcOid, Oid dbOid)
294294
{
295295
DIR *dir;
296296
struct dirent *de;
297-
#ifdef PGPRO_EE
297+
#if CFS_SUPPORT
298298
bool is_cfs;
299299

300300
is_cfs = file_is_in_cfs_tablespace(path);
@@ -360,7 +360,7 @@ ptrack_gather_filelist(List **filelist, char *path, Oid spcOid, Oid dbOid)
360360
nodeSpc(pfl->relnode) = spcOid == InvalidOid ? DEFAULTTABLESPACE_OID : spcOid;
361361
pfl->path = GetRelationPath(dbOid, nodeSpc(pfl->relnode),
362362
nodeRel(pfl->relnode), InvalidBackendId, pfl->forknum);
363-
#ifdef PGPRO_EE
363+
#if CFS_SUPPORT
364364
pfl->is_cfs_compressed = is_cfs
365365
&& md_get_compressor_internal(pfl->relnode, InvalidBackendId, pfl->forknum) != 0;
366366
#endif
@@ -406,7 +406,7 @@ ptrack_filelist_getnext(PtScanCtx * ctx)
406406
char *fullpath;
407407
struct stat fst;
408408
off_t rel_st_size = 0;
409-
#ifdef PGPRO_EE
409+
#if CFS_SUPPORT
410410
RelFileNodeBackend rnodebackend;
411411
#endif
412412

@@ -455,8 +455,8 @@ ptrack_filelist_getnext(PtScanCtx * ctx)
455455
return ptrack_filelist_getnext(ctx);
456456
}
457457

458-
#ifdef PGPRO_EE
459-
rnodebackend.node = ctx->bid.relnode;
458+
#if CFS_SUPPORT
459+
nodeOf(rnodebackend) = ctx->bid.relnode;
460460
rnodebackend.backend = InvalidBackendId;
461461

462462
if(pfl->is_cfs_compressed) {

0 commit comments

Comments
 (0)