@@ -68,7 +68,6 @@ struct BufFile
6868 * avoid making redundant FileSeek calls.
6969 */
7070
71- bool isTemp ;/* can only add files if this is true */
7271bool isInterXact ;/* keep open over transactions? */
7372bool dirty ;/* 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 and isInterXact if appropriate.
101+ * NOTE: caller must set isInterXact if appropriate.
103102 */
104103static BufFile *
105104makeBufFile (File firstfile )
@@ -111,7 +110,6 @@ makeBufFile(File firstfile)
111110file -> files [0 ]= firstfile ;
112111file -> offsets = (off_t * )palloc (sizeof (off_t ));
113112file -> offsets [0 ]= 0L ;
114- file -> isTemp = false;
115113file -> isInterXact = false;
116114file -> dirty = false;
117115file -> resowner = CurrentResourceOwner ;
@@ -136,7 +134,6 @@ extendBufFile(BufFile *file)
136134oldowner = CurrentResourceOwner ;
137135CurrentResourceOwner = file -> resowner ;
138136
139- Assert (file -> isTemp );
140137pfile = OpenTemporaryFile (file -> isInterXact );
141138Assert (pfile >=0 );
142139
@@ -173,7 +170,6 @@ BufFileCreateTemp(bool interXact)
173170Assert (pfile >=0 );
174171
175172file = makeBufFile (pfile );
176- file -> isTemp = true;
177173file -> isInterXact = interXact ;
178174
179175return file ;
@@ -288,10 +284,12 @@ BufFileDumpBuffer(BufFile *file)
288284 */
289285while (wpos < file -> nbytes )
290286{
287+ off_t availbytes ;
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{
296294while (file -> curFile + 1 >=file -> numFiles )
297295extendBufFile (file );
@@ -304,13 +302,10 @@ BufFileDumpBuffer(BufFile *file)
304302 * write as much as asked...
305303 */
306304bytestowrite = file -> nbytes - wpos ;
307- if (file -> isTemp )
308- {
309- off_t availbytes = 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- 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 ;
560553}
561554if (newFile >=file -> numFiles )
562555return EOF ;