@@ -68,7 +68,6 @@ struct BufFile
68
68
* avoid making redundant FileSeek calls.
69
69
*/
70
70
71
- bool isTemp ; /* can only add files if this is true */
72
71
bool isInterXact ; /* keep open over transactions? */
73
72
bool dirty ; /* does buffer need to be written? */
74
73
@@ -99,7 +98,7 @@ static int BufFileFlush(BufFile *file);
99
98
100
99
/*
101
100
* Create a BufFile given the first underlying physical file.
102
- * NOTE: caller must set isTemp and isInterXact if appropriate.
101
+ * NOTE: caller must set isInterXact if appropriate.
103
102
*/
104
103
static BufFile *
105
104
makeBufFile (File firstfile )
@@ -111,7 +110,6 @@ makeBufFile(File firstfile)
111
110
file -> files [0 ] = firstfile ;
112
111
file -> offsets = (off_t * ) palloc (sizeof (off_t ));
113
112
file -> offsets [0 ] = 0L ;
114
- file -> isTemp = false;
115
113
file -> isInterXact = false;
116
114
file -> dirty = false;
117
115
file -> resowner = CurrentResourceOwner ;
@@ -136,7 +134,6 @@ extendBufFile(BufFile *file)
136
134
oldowner = CurrentResourceOwner ;
137
135
CurrentResourceOwner = file -> resowner ;
138
136
139
- Assert (file -> isTemp );
140
137
pfile = OpenTemporaryFile (file -> isInterXact );
141
138
Assert (pfile >= 0 );
142
139
@@ -173,7 +170,6 @@ BufFileCreateTemp(bool interXact)
173
170
Assert (pfile >= 0 );
174
171
175
172
file = makeBufFile (pfile );
176
- file -> isTemp = true;
177
173
file -> isInterXact = interXact ;
178
174
179
175
return file ;
@@ -288,10 +284,12 @@ BufFileDumpBuffer(BufFile *file)
288
284
*/
289
285
while (wpos < file -> nbytes )
290
286
{
287
+ off_t availbytes ;
288
+
291
289
/*
292
290
* Advance to next component file if necessary and possible.
293
291
*/
294
- if (file -> curOffset >= MAX_PHYSICAL_FILESIZE && file -> isTemp )
292
+ if (file -> curOffset >= MAX_PHYSICAL_FILESIZE )
295
293
{
296
294
while (file -> curFile + 1 >= file -> numFiles )
297
295
extendBufFile (file );
@@ -304,13 +302,10 @@ BufFileDumpBuffer(BufFile *file)
304
302
* write as much as asked...
305
303
*/
306
304
bytestowrite = file -> nbytes - wpos ;
307
- if (file -> isTemp )
308
- {
309
- off_t availbytes = MAX_PHYSICAL_FILESIZE - file -> curOffset ;
305
+ availbytes = MAX_PHYSICAL_FILESIZE - file -> curOffset ;
310
306
311
- if ((off_t ) bytestowrite > availbytes )
312
- bytestowrite = (int ) availbytes ;
313
- }
307
+ if ((off_t ) bytestowrite > availbytes )
308
+ bytestowrite = (int ) availbytes ;
314
309
315
310
/*
316
311
* May need to reposition physical file.
@@ -543,20 +538,18 @@ BufFileSeek(BufFile *file, int fileno, off_t offset, int whence)
543
538
* above flush could have created a new segment, so checking sooner would
544
539
* not work (at least not with this code).
545
540
*/
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 )
547
544
{
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
- return EOF ;
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
+ return EOF ;
552
+ newOffset -= MAX_PHYSICAL_FILESIZE ;
560
553
}
561
554
if (newFile >= file -> numFiles )
562
555
return EOF ;
0 commit comments