62 #define MAX_PHYSICAL_FILESIZE 0x40000000
63 #define BUFFILE_SEG_SIZE (MAX_PHYSICAL_FILESIZE / BLCKSZ)
144 file->
files[0] = firstfile;
309 if (nfiles + 1 > capacity)
317 if (files[nfiles] <= 0)
338 errmsg(
"could not open temporary file \"%s\" from BufFile \"%s\": %m",
339 segment_name,
name)));
386 if (!found && !missing_ok)
387 elog(
ERROR,
"could not delete unknown BufFile \"%s\"",
name);
464 WAIT_EVENT_BUFFILE_READ);
470 errmsg(
"could not read file \"%s\": %m",
504 while (wpos < file->nbytes)
527 if ((off_t) bytestowrite > availbytes)
528 bytestowrite = (int) availbytes;
541 WAIT_EVENT_BUFFILE_WRITE);
542 if (bytestowrite <= 0)
545 errmsg(
"could not write to file \"%s\": %m",
555 wpos += bytestowrite;
595 size_t start_size =
size;
615 if (nthistime >
size)
621 file->
pos += nthistime;
622 ptr = (
char *) ptr + nthistime;
628 (nread != start_size && !(nread == 0 && eofOK)))
632 errmsg(
"could not read from file set \"%s\": read only %zu of %zu bytes",
633 file->
name, nread, start_size) :
634 errmsg(
"could not read from temporary file: read only %zu of %zu bytes",
684 if (file->
pos >= BLCKSZ)
698 nthistime = BLCKSZ - file->
pos;
699 if (nthistime >
size)
706 file->
pos += nthistime;
709 ptr = (
const char *) ptr + nthistime;
774 errmsg(
"could not determine size of temporary file \"%s\" from BufFile \"%s\": %m",
779 elog(
ERROR,
"invalid whence: %d", whence);
782 while (newOffset < 0)
788 if (newFile == file->
curFile &&
790 newOffset <= file->curOffset + file->
nbytes)
811 if (newFile == file->
numFiles && newOffset == 0)
872 if (lastFileSize < 0)
875 errmsg(
"could not determine size of temporary file \"%s\" from BufFile \"%s\": %m",
912 elog(
ERROR,
"could not append BufFile with non-matching resource owner");
931 int newFile = fileno;
944 if ((
i != fileno || offset == 0) &&
i != 0)
951 errmsg(
"could not delete fileset \"%s\": %m",
966 WAIT_EVENT_BUFFILE_TRUNCATE) < 0)
969 errmsg(
"could not truncate file \"%s\": %m",
981 if (newFile == file->
curFile &&
983 newOffset <= file->curOffset + file->
nbytes)
986 if (newOffset <= file->curOffset + file->
pos)
992 else if (newFile == file->
curFile &&
993 newOffset < file->curOffset)
1004 else if (newFile < file->curFile)
void PrepareTempTablespaces(void)
int BufFileSeekBlock(BufFile *file, int64 blknum)
void BufFileExportFileSet(BufFile *file)
size_t BufFileRead(BufFile *file, void *ptr, size_t size)
void BufFileReadExact(BufFile *file, void *ptr, size_t size)
static void FileSetSegmentName(char *name, const char *buffile_name, int segment)
BufFile * BufFileOpenFileSet(FileSet *fileset, const char *name, int mode, bool missing_ok)
static BufFile * makeBufFileCommon(int nfiles)
static void BufFileLoadBuffer(BufFile *file)
static File MakeNewFileSetSegment(BufFile *buffile, int segment)
void BufFileTell(BufFile *file, int *fileno, off_t *offset)
BufFile * BufFileCreateTemp(bool interXact)
static void extendBufFile(BufFile *file)
#define MAX_PHYSICAL_FILESIZE
static void BufFileFlush(BufFile *file)
void BufFileWrite(BufFile *file, const void *ptr, size_t size)
size_t BufFileReadMaybeEOF(BufFile *file, void *ptr, size_t size, bool eofOK)
void BufFileTruncateFileSet(BufFile *file, int fileno, off_t offset)
int BufFileSeek(BufFile *file, int fileno, off_t offset, int whence)
int64 BufFileSize(BufFile *file)
BufFile * BufFileCreateFileSet(FileSet *fileset, const char *name)
static BufFile * makeBufFile(File firstfile)
static size_t BufFileReadCommon(BufFile *file, void *ptr, size_t size, bool exact, bool eofOK)
void BufFileClose(BufFile *file)
int64 BufFileAppend(BufFile *target, BufFile *source)
void BufFileDeleteFileSet(FileSet *fileset, const char *name, bool missing_ok)
static void BufFileDumpBuffer(BufFile *file)
#define Assert(condition)
int errcode_for_file_access(void)
int errmsg(const char *fmt,...)
#define ereport(elevel,...)
void FileClose(File file)
File OpenTemporaryFile(bool interXact)
char * FilePathName(File file)
off_t FileSize(File file)
int FileTruncate(File file, off_t offset, uint32 wait_event_info)
static ssize_t FileRead(File file, void *buffer, size_t amount, off_t offset, uint32 wait_event_info)
static ssize_t FileWrite(File file, const void *buffer, size_t amount, off_t offset, uint32 wait_event_info)
File FileSetOpen(FileSet *fileset, const char *name, int mode)
bool FileSetDelete(FileSet *fileset, const char *name, bool error_on_failure)
File FileSetCreate(FileSet *fileset, const char *name)
#define INSTR_TIME_SET_CURRENT(t)
#define INSTR_TIME_SET_ZERO(t)
#define INSTR_TIME_ACCUM_DIFF(x, y, z)
BufferUsage pgBufferUsage
char * pstrdup(const char *in)
void pfree(void *pointer)
void * repalloc(void *pointer, Size size)
#define CHECK_FOR_INTERRUPTS()
static PgChecksumMode mode
static rewind_source * source
ResourceOwner CurrentResourceOwner
static pg_noinline void Size size
instr_time temp_blk_write_time
instr_time temp_blk_read_time