From 1ba0db4d826c0b1a661a52a3e215c11286edc645 Mon Sep 17 00:00:00 2001 From: Thomas Munro Date: Sat, 18 Nov 2017 08:50:32 +1100 Subject: [PATCH] Remove vestiges of non-temporary file support from buffile.c. Following on from 11e264517dff7a911d9e6494de86049cab42cde3, it seems a good time to remove some dead code and some comments that alluded to the possibility of creating non-temporary BufFiles. Also rename BufFileCreateTemp() to BufFileCreate(). Author: Thomas Munro, based on feedback from Tom Lane and Andres Freund Discussion: https://postgr.es/m/32216.1510935834%40sss.pgh.pa.us --- src/backend/access/gist/gistbuildbuffers.c | 2 +- src/backend/executor/nodeHashjoin.c | 2 +- src/backend/storage/file/buffile.c | 19 ++----------------- src/backend/utils/sort/logtape.c | 2 +- src/backend/utils/sort/tuplestore.c | 2 +- src/include/storage/buffile.h | 4 ++-- 6 files changed, 8 insertions(+), 23 deletions(-) diff --git a/src/backend/access/gist/gistbuildbuffers.c b/src/backend/access/gist/gistbuildbuffers.c index 88cee2028da..205aab09ace 100644 --- a/src/backend/access/gist/gistbuildbuffers.c +++ b/src/backend/access/gist/gistbuildbuffers.c @@ -58,7 +58,7 @@ gistInitBuildBuffers(int pagesPerBuffer, int levelStep, int maxLevel) * Create a temporary file to hold buffer pages that are swapped out of * memory. */ - gfbb->pfile = BufFileCreateTemp(false); + gfbb->pfile = BufFileCreate(false); gfbb->nFileBlocks = 0; /* Initialize free page management. */ diff --git a/src/backend/executor/nodeHashjoin.c b/src/backend/executor/nodeHashjoin.c index ab1632cc13d..d60e538b1ab 100644 --- a/src/backend/executor/nodeHashjoin.c +++ b/src/backend/executor/nodeHashjoin.c @@ -824,7 +824,7 @@ ExecHashJoinSaveTuple(MinimalTuple tuple, uint32 hashvalue, if (file == NULL) { /* First write to this batch file, so open it. */ - file = BufFileCreateTemp(false); + file = BufFileCreate(false); *fileptr = file; } diff --git a/src/backend/storage/file/buffile.c b/src/backend/storage/file/buffile.c index b527d38b05b..bed58148b91 100644 --- a/src/backend/storage/file/buffile.c +++ b/src/backend/storage/file/buffile.c @@ -1,7 +1,7 @@ /*------------------------------------------------------------------------- * * buffile.c - * Management of large buffered files, primarily temporary files. + * Management of large buffered temporary files. * * Portions Copyright (c) 1996-2017, PostgreSQL Global Development Group * Portions Copyright (c) 1994, Regents of the University of California @@ -161,7 +161,7 @@ extendBufFile(BufFile *file) * transaction boundaries. */ BufFile * -BufFileCreateTemp(bool interXact) +BufFileCreate(bool interXact) { BufFile *file; File pfile; @@ -175,21 +175,6 @@ BufFileCreateTemp(bool interXact) return file; } -#ifdef NOT_USED -/* - * Create a BufFile and attach it to an already-opened virtual File. - * - * This is comparable to fdopen() in stdio. This is the only way at present - * to attach a BufFile to a non-temporary file. Note that BufFiles created - * in this way CANNOT be expanded into multiple files. - */ -BufFile * -BufFileCreate(File file) -{ - return makeBufFile(file); -} -#endif - /* * Close a BufFile * diff --git a/src/backend/utils/sort/logtape.c b/src/backend/utils/sort/logtape.c index 5ebb6fb11ab..6911dd7bff2 100644 --- a/src/backend/utils/sort/logtape.c +++ b/src/backend/utils/sort/logtape.c @@ -388,7 +388,7 @@ LogicalTapeSetCreate(int ntapes) Assert(ntapes > 0); lts = (LogicalTapeSet *) palloc(offsetof(LogicalTapeSet, tapes) + ntapes * sizeof(LogicalTape)); - lts->pfile = BufFileCreateTemp(false); + lts->pfile = BufFileCreate(false); lts->nBlocksAllocated = 0L; lts->nBlocksWritten = 0L; lts->forgetFreeSpace = false; diff --git a/src/backend/utils/sort/tuplestore.c b/src/backend/utils/sort/tuplestore.c index 1977b61fd94..93efd195cba 100644 --- a/src/backend/utils/sort/tuplestore.c +++ b/src/backend/utils/sort/tuplestore.c @@ -818,7 +818,7 @@ tuplestore_puttuple_common(Tuplestorestate *state, void *tuple) oldowner = CurrentResourceOwner; CurrentResourceOwner = state->resowner; - state->myfile = BufFileCreateTemp(state->interXact); + state->myfile = BufFileCreate(state->interXact); CurrentResourceOwner = oldowner; diff --git a/src/include/storage/buffile.h b/src/include/storage/buffile.h index fafcb3f0898..b6e4b4b0148 100644 --- a/src/include/storage/buffile.h +++ b/src/include/storage/buffile.h @@ -1,7 +1,7 @@ /*------------------------------------------------------------------------- * * buffile.h - * Management of large buffered files, primarily temporary files. + * Management of large buffered temporary files. * * The BufFile routines provide a partial replacement for stdio atop * virtual file descriptors managed by fd.c. Currently they only support @@ -34,7 +34,7 @@ typedef struct BufFile BufFile; * prototypes for functions in buffile.c */ -extern BufFile *BufFileCreateTemp(bool interXact); +extern BufFile *BufFileCreate(bool interXact); extern void BufFileClose(BufFile *file); extern size_t BufFileRead(BufFile *file, void *ptr, size_t size); extern size_t BufFileWrite(BufFile *file, void *ptr, size_t size); -- 2.15.0