* avoid making redundant FileSeek calls.
*/
- bool isTemp; /* can only add files if this is true */
bool isInterXact; /* keep open over transactions? */
bool dirty; /* does buffer need to be written? */
/*
* Create a BufFile given the first underlying physical file.
- * NOTE: caller must set isTemp and isInterXact if appropriate.
+ * NOTE: caller must set isInterXact if appropriate.
*/
static BufFile *
makeBufFile(File firstfile)
file->files[0] = firstfile;
file->offsets = (off_t *) palloc(sizeof(off_t));
file->offsets[0] = 0L;
- file->isTemp = false;
file->isInterXact = false;
file->dirty = false;
file->resowner = CurrentResourceOwner;
oldowner = CurrentResourceOwner;
CurrentResourceOwner = file->resowner;
- Assert(file->isTemp);
pfile = OpenTemporaryFile(file->isInterXact);
Assert(pfile >= 0);
Assert(pfile >= 0);
file = makeBufFile(pfile);
- file->isTemp = true;
file->isInterXact = interXact;
return file;
*/
while (wpos < file->nbytes)
{
+ off_t availbytes;
+
/*
* Advance to next component file if necessary and possible.
*/
- if (file->curOffset >= MAX_PHYSICAL_FILESIZE && file->isTemp)
+ if (file->curOffset >= MAX_PHYSICAL_FILESIZE)
{
while (file->curFile + 1 >= file->numFiles)
extendBufFile(file);
* write as much as asked...
*/
bytestowrite = file->nbytes - wpos;
- if (file->isTemp)
- {
- off_t availbytes = MAX_PHYSICAL_FILESIZE - file->curOffset;
+ availbytes = MAX_PHYSICAL_FILESIZE - file->curOffset;
- if ((off_t) bytestowrite > availbytes)
- bytestowrite = (int) availbytes;
- }
+ if ((off_t) bytestowrite > availbytes)
+ bytestowrite = (int) availbytes;
/*
* May need to reposition physical file.
* above flush could have created a new segment, so checking sooner would
* not work (at least not with this code).
*/
- if (file->isTemp)
+
+ /* convert seek to "start of next seg" to "end of last seg" */
+ if (newFile == file->numFiles && newOffset == 0)
{
- /* convert seek to "start of next seg" to "end of last seg" */
- if (newFile == file->numFiles && newOffset == 0)
- {
- newFile--;
- newOffset = MAX_PHYSICAL_FILESIZE;
- }
- while (newOffset > MAX_PHYSICAL_FILESIZE)
- {
- if (++newFile >= file->numFiles)
- return EOF;
- newOffset -= MAX_PHYSICAL_FILESIZE;
- }
+ newFile--;
+ newOffset = MAX_PHYSICAL_FILESIZE;
+ }
+ while (newOffset > MAX_PHYSICAL_FILESIZE)
+ {
+ if (++newFile >= file->numFiles)
+ return EOF;
+ newOffset -= MAX_PHYSICAL_FILESIZE;
}
if (newFile >= file->numFiles)
return EOF;