Skip to content

Commit ab97aaa

Browse files
committed
Update buffile.h/.c comments for removal of non-temp option.
Commit 11e2645 removed BufFile's isTemp flag, thereby eliminating the possibility of resurrecting BufFileCreate(). But it left that function in place, as well as a bunch of comments describing how things worked for the non-temp-file case. At best, that's now a source of confusion. So remove the long-since-commented-out function and change relevant comments. I (tgl) wanted to rename BufFileCreateTemp() to BufFileCreate(), but that seems not to be the consensus position, so leave it as-is. In passing, fix commit f0828b2's failure to update BufFileSeek's comment to match the change of its argument type from long to off_t. (I think that might actually have been intentional at the time, but now that 64-bit off_t is nearly universal, it looks anachronistic.) Thomas Munro and Tom Lane Discussion: https://postgr.es/m/E1eFVyl-0008J1-RO@gemulon.postgresql.org
1 parent df3a66e commit ab97aaa

File tree

2 files changed

+10
-30
lines changed

2 files changed

+10
-30
lines changed

src/backend/storage/file/buffile.c

Lines changed: 9 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/*-------------------------------------------------------------------------
22
*
33
* buffile.c
4-
* Management of large buffered files, primarily temporary files.
4+
* Management of large buffered temporary files.
55
*
66
* Portions Copyright (c) 1996-2017, PostgreSQL Global Development Group
77
* Portions Copyright (c) 1994, Regents of the University of California
@@ -20,8 +20,8 @@
2020
* of opening/closing file descriptors.
2121
*
2222
* Note that BufFile structs are allocated with palloc(), and therefore
23-
* will go away automatically at transaction end. If the underlying
24-
* virtual File is made with OpenTemporaryFile, then all resources for
23+
* will go away automatically at query/transaction end. Since the underlying
24+
* virtual Files are made with OpenTemporaryFile, all resources for
2525
* the file are certain to be cleaned up even if processing is aborted
2626
* by ereport(ERROR). The data structures required are made in the
2727
* palloc context that was current when the BufFile was created, and
@@ -45,8 +45,8 @@
4545

4646
/*
4747
* We break BufFiles into gigabyte-sized segments, regardless of RELSEG_SIZE.
48-
* The reason is that we'd like large temporary BufFiles to be spread across
49-
* multiple tablespaces when available.
48+
* The reason is that we'd like large BufFiles to be spread across multiple
49+
* tablespaces when available.
5050
*/
5151
#define MAX_PHYSICAL_FILESIZE 0x40000000
5252
#define BUFFILE_SEG_SIZE (MAX_PHYSICAL_FILESIZE / BLCKSZ)
@@ -175,21 +175,6 @@ BufFileCreateTemp(bool interXact)
175175
return file;
176176
}
177177

178-
#ifdef NOT_USED
179-
/*
180-
* Create a BufFile and attach it to an already-opened virtual File.
181-
*
182-
* This is comparable to fdopen() in stdio. This is the only way at present
183-
* to attach a BufFile to a non-temporary file. Note that BufFiles created
184-
* in this way CANNOT be expanded into multiple files.
185-
*/
186-
BufFile *
187-
BufFileCreate(File file)
188-
{
189-
return makeBufFile(file);
190-
}
191-
#endif
192-
193178
/*
194179
* Close a BufFile
195180
*
@@ -202,7 +187,7 @@ BufFileClose(BufFile *file)
202187

203188
/* flush any unwritten data */
204189
BufFileFlush(file);
205-
/* close the underlying file(s) (with delete if it's a temp file) */
190+
/* close and delete the underlying file(s) */
206191
for (i = 0; i < file->numFiles; i++)
207192
FileClose(file->files[i]);
208193
/* release the buffer space */
@@ -225,10 +210,6 @@ BufFileLoadBuffer(BufFile *file)
225210

226211
/*
227212
* Advance to next component file if necessary and possible.
228-
*
229-
* This path can only be taken if there is more than one component, so it
230-
* won't interfere with reading a non-temp file that is over
231-
* MAX_PHYSICAL_FILESIZE.
232213
*/
233214
if (file->curOffset >= MAX_PHYSICAL_FILESIZE &&
234215
file->curFile + 1 < file->numFiles)
@@ -298,8 +279,7 @@ BufFileDumpBuffer(BufFile *file)
298279
}
299280

300281
/*
301-
* Enforce per-file size limit only for temp files, else just try to
302-
* write as much as asked...
282+
* Determine how much we need to write into this file.
303283
*/
304284
bytestowrite = file->nbytes - wpos;
305285
availbytes = MAX_PHYSICAL_FILESIZE - file->curOffset;
@@ -471,8 +451,8 @@ BufFileFlush(BufFile *file)
471451
* BufFileSeek
472452
*
473453
* Like fseek(), except that target position needs two values in order to
474-
* work when logical filesize exceeds maximum value representable by long.
475-
* We do not support relative seeks across more than LONG_MAX, however.
454+
* work when logical filesize exceeds maximum value representable by off_t.
455+
* We do not support relative seeks across more than that, however.
476456
*
477457
* Result is 0 if OK, EOF if not. Logical position is not moved if an
478458
* impossible seek is attempted.

src/include/storage/buffile.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/*-------------------------------------------------------------------------
22
*
33
* buffile.h
4-
* Management of large buffered files, primarily temporary files.
4+
* Management of large buffered temporary files.
55
*
66
* The BufFile routines provide a partial replacement for stdio atop
77
* virtual file descriptors managed by fd.c. Currently they only support

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy