62 #define MAX_PHYSICAL_FILESIZE 0x40000000
63 #define BUFFILE_SEG_SIZE (MAX_PHYSICAL_FILESIZE / BLCKSZ)
139 file->
files[0] = firstfile;
304 if (nfiles + 1 > capacity)
312 if (files[nfiles] <= 0)
333 errmsg(
"could not open temporary file \"%s\" from BufFile \"%s\": %m",
334 segment_name,
name)));
381 if (!found && !missing_ok)
382 elog(
ERROR,
"could not delete unknown BufFile \"%s\"",
name);
465 errmsg(
"could not read file \"%s\": %m",
500 while (wpos < file->nbytes)
523 if ((off_t) bytestowrite > availbytes)
524 bytestowrite = (int) availbytes;
538 if (bytestowrite <= 0)
541 errmsg(
"could not write to file \"%s\": %m",
552 wpos += bytestowrite;
592 size_t start_size = size;
612 if (nthistime > size)
618 file->
pos += nthistime;
619 ptr = (
char *) ptr + nthistime;
625 (nread != start_size && !(nread == 0 && eofOK)))
629 errmsg(
"could not read from file set \"%s\": read only %zu of %zu bytes",
630 file->
name, nread, start_size) :
631 errmsg(
"could not read from temporary file: read only %zu of %zu bytes",
681 if (file->
pos >= BLCKSZ)
695 nthistime = BLCKSZ - file->
pos;
696 if (nthistime > size)
703 file->
pos += nthistime;
706 ptr = (
const char *) ptr + nthistime;
771 errmsg(
"could not determine size of temporary file \"%s\" from BufFile \"%s\": %m",
776 elog(
ERROR,
"invalid whence: %d", whence);
779 while (newOffset < 0)
785 if (newFile == file->
curFile &&
787 newOffset <= file->curOffset + file->
nbytes)
808 if (newFile == file->
numFiles && newOffset == 0)
863 BufFileTellBlock(
BufFile *file)
889 if (lastFileSize < 0)
892 errmsg(
"could not determine size of temporary file \"%s\" from BufFile \"%s\": %m",
932 elog(
ERROR,
"could not append BufFile with non-matching resource owner");
951 int newFile = fileno;
964 if ((
i != fileno || offset == 0) &&
i != 0)
971 errmsg(
"could not delete fileset \"%s\": %m",
989 errmsg(
"could not truncate file \"%s\": %m",
1001 if (newFile == file->
curFile &&
1003 newOffset <= file->curOffset + file->
nbytes)
1006 if (newOffset <= file->curOffset + file->
pos)
1012 else if (newFile == file->
curFile &&
1013 newOffset < file->curOffset)
1024 else if (newFile < file->curFile)
void PrepareTempTablespaces(void)
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)
long BufFileAppend(BufFile *target, BufFile *source)
BufFile * BufFileOpenFileSet(FileSet *fileset, const char *name, int mode, bool missing_ok)
int BufFileSeekBlock(BufFile *file, long blknum)
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)
void BufFileDeleteFileSet(FileSet *fileset, const char *name, bool missing_ok)
static void BufFileDumpBuffer(BufFile *file)
elog(ERROR, "%s: %s", p2, msg)
int errcode_for_file_access(void)
int errmsg(const char *fmt,...)
#define ereport(elevel,...)
void FileClose(File file)
int FileWrite(File file, const void *buffer, size_t amount, off_t offset, uint32 wait_event_info)
int FileRead(File file, void *buffer, size_t amount, off_t offset, uint32 wait_event_info)
File OpenTemporaryFile(bool interXact)
char * FilePathName(File file)
off_t FileSize(File file)
int FileTruncate(File file, 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_ADD(x, y)
#define INSTR_TIME_SUBTRACT(x, y)
#define INSTR_TIME_SET_ZERO(t)
BufferUsage pgBufferUsage
Assert(fmt[strlen(fmt) - 1] !='\n')
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
instr_time temp_blk_write_time
instr_time temp_blk_read_time
@ WAIT_EVENT_BUFFILE_WRITE
@ WAIT_EVENT_BUFFILE_TRUNCATE
@ WAIT_EVENT_BUFFILE_READ