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

Commit11e2645

Browse files
committed
Remove BufFile's isTemp flag.
The isTemp flag controls whether buffile.c chops BufFile data up into1GB segments on disk. Since it was badly named and always true, getrid of it.Author: Thomas Munro (based on suggestion by Peter Geoghegan)Reviewed-By: Peter Geoghegan, Andres FreundDiscussion:https://postgr.es/m/CAH2-Wz%3D%2B9Rfqh5UdvdW9rGezdhrMGGH-JL1X9FXXVZdeeGeOJA%40mail.gmail.com
1 parent7082e61 commit11e2645

File tree

1 file changed

+18
-25
lines changed

1 file changed

+18
-25
lines changed

‎src/backend/storage/file/buffile.c

Lines changed: 18 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,6 @@ struct BufFile
6868
* avoid making redundant FileSeek calls.
6969
*/
7070

71-
boolisTemp;/* can only add files if this is true */
7271
boolisInterXact;/* keep open over transactions? */
7372
booldirty;/* does buffer need to be written? */
7473

@@ -99,7 +98,7 @@ static intBufFileFlush(BufFile *file);
9998

10099
/*
101100
* Create a BufFile given the first underlying physical file.
102-
* NOTE: caller must setisTemp andisInterXact if appropriate.
101+
* NOTE: caller must set isInterXact if appropriate.
103102
*/
104103
staticBufFile*
105104
makeBufFile(Filefirstfile)
@@ -111,7 +110,6 @@ makeBufFile(File firstfile)
111110
file->files[0]=firstfile;
112111
file->offsets= (off_t*)palloc(sizeof(off_t));
113112
file->offsets[0]=0L;
114-
file->isTemp= false;
115113
file->isInterXact= false;
116114
file->dirty= false;
117115
file->resowner=CurrentResourceOwner;
@@ -136,7 +134,6 @@ extendBufFile(BufFile *file)
136134
oldowner=CurrentResourceOwner;
137135
CurrentResourceOwner=file->resowner;
138136

139-
Assert(file->isTemp);
140137
pfile=OpenTemporaryFile(file->isInterXact);
141138
Assert(pfile >=0);
142139

@@ -173,7 +170,6 @@ BufFileCreateTemp(bool interXact)
173170
Assert(pfile >=0);
174171

175172
file=makeBufFile(pfile);
176-
file->isTemp= true;
177173
file->isInterXact=interXact;
178174

179175
returnfile;
@@ -288,10 +284,12 @@ BufFileDumpBuffer(BufFile *file)
288284
*/
289285
while (wpos<file->nbytes)
290286
{
287+
off_tavailbytes;
288+
291289
/*
292290
* Advance to next component file if necessary and possible.
293291
*/
294-
if (file->curOffset >=MAX_PHYSICAL_FILESIZE&&file->isTemp)
292+
if (file->curOffset >=MAX_PHYSICAL_FILESIZE)
295293
{
296294
while (file->curFile+1 >=file->numFiles)
297295
extendBufFile(file);
@@ -304,13 +302,10 @@ BufFileDumpBuffer(BufFile *file)
304302
* write as much as asked...
305303
*/
306304
bytestowrite=file->nbytes-wpos;
307-
if (file->isTemp)
308-
{
309-
off_tavailbytes=MAX_PHYSICAL_FILESIZE-file->curOffset;
305+
availbytes=MAX_PHYSICAL_FILESIZE-file->curOffset;
310306

311-
if ((off_t)bytestowrite>availbytes)
312-
bytestowrite= (int)availbytes;
313-
}
307+
if ((off_t)bytestowrite>availbytes)
308+
bytestowrite= (int)availbytes;
314309

315310
/*
316311
* May need to reposition physical file.
@@ -543,20 +538,18 @@ BufFileSeek(BufFile *file, int fileno, off_t offset, int whence)
543538
* above flush could have created a new segment, so checking sooner would
544539
* not work (at least not with this code).
545540
*/
546-
if (file->isTemp)
541+
542+
/* convert seek to "start of next seg" to "end of last seg" */
543+
if (newFile==file->numFiles&&newOffset==0)
547544
{
548-
/* convert seek to "start of next seg" to "end of last seg" */
549-
if (newFile==file->numFiles&&newOffset==0)
550-
{
551-
newFile--;
552-
newOffset=MAX_PHYSICAL_FILESIZE;
553-
}
554-
while (newOffset>MAX_PHYSICAL_FILESIZE)
555-
{
556-
if (++newFile >=file->numFiles)
557-
returnEOF;
558-
newOffset-=MAX_PHYSICAL_FILESIZE;
559-
}
545+
newFile--;
546+
newOffset=MAX_PHYSICAL_FILESIZE;
547+
}
548+
while (newOffset>MAX_PHYSICAL_FILESIZE)
549+
{
550+
if (++newFile >=file->numFiles)
551+
returnEOF;
552+
newOffset-=MAX_PHYSICAL_FILESIZE;
560553
}
561554
if (newFile >=file->numFiles)
562555
returnEOF;

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp