From 9607d5239207cae868bd011caf6e1f27c305935d Mon Sep 17 00:00:00 2001 From: jkshen <2458684728@qq.com> Date: Thu, 25 Aug 2022 15:11:30 +0800 Subject: [PATCH] =?UTF-8?q?=E5=8E=BB=E9=99=A4HAVE=5FFINCORE=E5=AE=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/common/backend/utils/misc/pgfincore.cpp | 23 ++------------------- 1 file changed, 2 insertions(+), 21 deletions(-) diff --git a/src/common/backend/utils/misc/pgfincore.cpp b/src/common/backend/utils/misc/pgfincore.cpp index 377ae9eca..b3efc2788 100644 --- a/src/common/backend/utils/misc/pgfincore.cpp +++ b/src/common/backend/utils/misc/pgfincore.cpp @@ -49,11 +49,8 @@ #define FINCORE_PRESENT 0x1 #define FINCORE_DIRTY 0x2 -#ifndef HAVE_FINCORE #define FINCORE_BITS 1 -#else -#define FINCORE_BITS 2 -#endif + /* * pgfadvise_fctx structure is needed * to keep track of relation path, segment number, ... @@ -819,9 +816,8 @@ static bool pgfincore_file(char *filename, pgfincoreStruct *pgfncr) int fd; struct stat st; -#ifndef HAVE_FINCORE void *pa = (char *) 0; -#endif + unsigned char *vec = (unsigned char *) 0; /* @@ -863,7 +859,6 @@ static bool pgfincore_file(char *filename, pgfincoreStruct *pgfncr) /* number of pages in the current file */ pgfncr->rel_os_pages = (st.st_size+pgfncr->pageSize-1)/pgfncr->pageSize; -#ifndef HAVE_FINCORE pa = mmap(NULL, st.st_size, PROT_NONE, MAP_SHARED, fd, 0); if (pa == MAP_FAILED) { int save_errno = errno; @@ -872,33 +867,22 @@ static bool pgfincore_file(char *filename, pgfincoreStruct *pgfncr) filename, save_errno, strerror(save_errno)))); return false; } -#endif /* Prepare our vector containing all blocks information */ vec = (unsigned char * ) calloc(1, (st.st_size+pgfncr->pageSize-1)/pgfncr->pageSize); if ((void *)0 == vec) { -#ifndef HAVE_FINCORE munmap(pa, st.st_size); -#endif FreeFile(fp); ereport(ERROR, (errmsg("Can not calloc object file : %s", filename))); return false; } -#ifndef HAVE_FINCORE /* Affect vec with mincore */ if (mincore(pa, st.st_size, vec) != 0) { int save_errno = errno; munmap(pa, st.st_size); ereport(ERROR, (errmsg("mincore(%p, %lld, %p): %s\n", pa, (long long int)st.st_size, vec, strerror(save_errno)))); -#else - /* Affect vec with fincore */ - if (fincore(fd, 0, st.st_size, vec) != 0) { - int save_errno = errno; - ereport(ERROR, (errmsg("fincore(%u, 0, %lld, %p): %s\n", - fd, (long long int)st.st_size, vec, strerror(save_errno)))); -#endif free(vec); FreeFile(fp); return false; @@ -962,9 +946,7 @@ static bool pgfincore_file(char *filename, pgfincoreStruct *pgfncr) * free and close */ free(vec); -#ifndef HAVE_FINCORE munmap(pa, st.st_size); -#endif FreeFile(fp); /* @@ -1100,7 +1082,6 @@ Datum pgfincore(PG_FUNCTION_ARGS) releaseDummyRelation(&partitionRel); } - /* And finally we keep track of our initialization */ ereport(DEBUG1, (errmsg("pgfincore: init done for %s, in fork %s", fctx->relationpath, text_to_cstring(forkName))));