diff --git a/engine.c b/engine.c index 1efc627..ebd0b61 100644 --- a/engine.c +++ b/engine.c @@ -506,8 +506,13 @@ ptrack_mark_file(Oid dbOid, Oid tablespaceOid, BlockNumber blkno, nblocks = 0; struct stat stat_buf; +#if PG_VERSION_NUM >= 170000 + RelFileNumber relNumber; + unsigned segno; +#else int oidchars; char oidbuf[OIDCHARS + 1]; +#endif /* Do not track temporary relations */ if (looks_like_temp_rel_name(filename)) @@ -519,12 +524,19 @@ ptrack_mark_file(Oid dbOid, Oid tablespaceOid, nodeDb(nodeOf(rnode)) = dbOid; nodeSpc(nodeOf(rnode)) = tablespaceOid; +#if PG_VERSION_NUM >= 170000 + if (!parse_filename_for_nontemp_relation(filename, &relNumber, &forknum, &segno)) + return; + + nodeRel(nodeOf(rnode)) = relNumber; +#else if (!parse_filename_for_nontemp_relation(filename, &oidchars, &forknum)) return; memcpy(oidbuf, filename, oidchars); oidbuf[oidchars] = '\0'; nodeRel(nodeOf(rnode)) = atooid(oidbuf); +#endif /* Compute number of blocks based on file size */ if (stat(filepath, &stat_buf) == 0) diff --git a/ptrack.c b/ptrack.c index 704e2ee..9a8dcaa 100644 --- a/ptrack.c +++ b/ptrack.c @@ -330,25 +330,38 @@ ptrack_gather_filelist(List **filelist, char *path, Oid spcOid, Oid dbOid) /* Regular file inside database directory, otherwise skip it */ if (dbOid != InvalidOid || spcOid == GLOBALTABLESPACE_OID) { +#if PG_VERSION_NUM >= 170000 + RelFileNumber relNumber; + unsigned segno; +#else int oidchars; char oidbuf[OIDCHARS + 1]; +#endif char *segpath; PtrackFileList_i *pfl = palloc0(sizeof(PtrackFileList_i)); /* * Check that filename seems to be a regular relation file. */ +#if PG_VERSION_NUM >= 170000 + if (!parse_filename_for_nontemp_relation(de->d_name, &relNumber, &pfl->forknum, &segno)) + continue; +#else if (!parse_filename_for_nontemp_relation(de->d_name, &oidchars, &pfl->forknum)) continue; - +#endif /* Parse segno */ segpath = strstr(de->d_name, "."); pfl->segno = segpath != NULL ? atoi(segpath + 1) : 0; /* Fill the pfl in */ +#if PG_VERSION_NUM >= 170000 + nodeRel(pfl->relnode) = relNumber; +#else memcpy(oidbuf, de->d_name, oidchars); oidbuf[oidchars] = '\0'; nodeRel(pfl->relnode) = atooid(oidbuf); +#endif nodeDb(pfl->relnode) = dbOid; nodeSpc(pfl->relnode) = spcOid == InvalidOid ? DEFAULTTABLESPACE_OID : spcOid; pfl->path = GetRelationPath(dbOid, nodeSpc(pfl->relnode),