Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitab97aaa

Browse files
committed
Update buffile.h/.c comments for removal of non-temp option.
Commit11e2645 removed BufFile's isTemp flag, thereby eliminatingthe possibility of resurrecting BufFileCreate(). But it left thatfunction in place, as well as a bunch of comments describing how thingsworked for the non-temp-file case. At best, that's now a source ofconfusion. So remove the long-since-commented-out function and changerelevant comments.I (tgl) wanted to rename BufFileCreateTemp() to BufFileCreate(), butthat seems not to be the consensus position, so leave it as-is.In passing, fix commitf0828b2's failure to update BufFileSeek'scomment to match the change of its argument type from long to off_t.(I think that might actually have been intentional at the time, butnow that 64-bit off_t is nearly universal, it looks anachronistic.)Thomas Munro and Tom LaneDiscussion:https://postgr.es/m/E1eFVyl-0008J1-RO@gemulon.postgresql.org
1 parentdf3a66e commitab97aaa

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 bufferedfiles, primarilytemporary 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-
* virtualFile is made with OpenTemporaryFile, then all resources for
23+
* will go away automatically atquery/transaction end.Since the underlying
24+
* virtualFiles 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 largetemporaryBufFiles to be spread across
49-
*multipletablespaces when available.
48+
* The reason is that we'd like large BufFiles to be spread across multiple
49+
* tablespaces when available.
5050
*/
5151
#defineMAX_PHYSICAL_FILESIZE0x40000000
5252
#defineBUFFILE_SEG_SIZE(MAX_PHYSICAL_FILESIZE / BLCKSZ)
@@ -175,21 +175,6 @@ BufFileCreateTemp(bool interXact)
175175
returnfile;
176176
}
177177

178-
#ifdefNOT_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(Filefile)
188-
{
189-
returnmakeBufFile(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+
/* closeand deletethe 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 bylong.
475-
* We do not support relative seeks across more thanLONG_MAX, however.
454+
* work when logical filesize exceeds maximum value representable byoff_t.
455+
* We do not support relative seeks across more thanthat, 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 bufferedfiles, primarilytemporary 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)

[8]ページ先頭

©2009-2025 Movatter.jp