PostgreSQL Source Code  git master
buffile.h
Go to the documentation of this file.
1 /*-------------------------------------------------------------------------
2  *
3  * buffile.h
4  * Management of large buffered temporary files.
5  *
6  * The BufFile routines provide a partial replacement for stdio atop
7  * virtual file descriptors managed by fd.c. Currently they only support
8  * buffered access to a virtual file, without any of stdio's formatting
9  * features. That's enough for immediate needs, but the set of facilities
10  * could be expanded if necessary.
11  *
12  * BufFile also supports working with temporary files that exceed the OS
13  * file size limit and/or the largest offset representable in an int.
14  * It might be better to split that out as a separately accessible module,
15  * but currently we have no need for oversize temp files without buffered
16  * access.
17  *
18  * Portions Copyright (c) 1996-2020, PostgreSQL Global Development Group
19  * Portions Copyright (c) 1994, Regents of the University of California
20  *
21  * src/include/storage/buffile.h
22  *
23  *-------------------------------------------------------------------------
24  */
25 
26 #ifndef BUFFILE_H
27 #define BUFFILE_H
28 
29 #include "storage/sharedfileset.h"
30 
31 /* BufFile is an opaque type whose details are not known outside buffile.c. */
32 
33 typedef struct BufFile BufFile;
34 
35 /*
36  * prototypes for functions in buffile.c
37  */
38 
39 extern BufFile *BufFileCreateTemp(bool interXact);
40 extern void BufFileClose(BufFile *file);
41 extern size_t BufFileRead(BufFile *file, void *ptr, size_t size);
42 extern void BufFileWrite(BufFile *file, void *ptr, size_t size);
43 extern int BufFileSeek(BufFile *file, int fileno, off_t offset, int whence);
44 extern void BufFileTell(BufFile *file, int *fileno, off_t *offset);
45 extern int BufFileSeekBlock(BufFile *file, long blknum);
46 extern int64 BufFileSize(BufFile *file);
47 extern long BufFileAppend(BufFile *target, BufFile *source);
48 
50 extern void BufFileExportShared(BufFile *file);
51 extern BufFile *BufFileOpenShared(SharedFileSet *fileset, const char *name,
52  int mode);
53 extern void BufFileDeleteShared(SharedFileSet *fileset, const char *name);
54 extern void BufFileTruncateShared(BufFile *file, int fileno, off_t offset);
55 
56 #endif /* BUFFILE_H */
SharedFileSet * fileset
Definition: buffile.c:80
static PgChecksumMode mode
Definition: pg_checksums.c:61
void BufFileTruncateShared(BufFile *file, int fileno, off_t offset)
Definition: buffile.c:861
void BufFileClose(BufFile *file)
Definition: buffile.c:395
int BufFileSeek(BufFile *file, int fileno, off_t offset, int whence)
Definition: buffile.c:650
int64 BufFileSize(BufFile *file)
Definition: buffile.c:794
void BufFileDeleteShared(SharedFileSet *fileset, const char *name)
Definition: buffile.c:347
BufFile * BufFileOpenShared(SharedFileSet *fileset, const char *name, int mode)
Definition: buffile.c:284
BufFile * BufFileCreateTemp(bool interXact)
Definition: buffile.c:188
void BufFileExportShared(BufFile *file)
Definition: buffile.c:377
size_t BufFileRead(BufFile *file, void *ptr, size_t size)
Definition: buffile.c:543
static rewind_source * source
Definition: pg_rewind.c:79
long BufFileAppend(BufFile *target, BufFile *source)
Definition: buffile.c:833
const char * name
Definition: encode.c:561
int BufFileSeekBlock(BufFile *file, long blknum)
Definition: buffile.c:761
BufFile * BufFileCreateShared(SharedFileSet *fileset, const char *name)
Definition: buffile.c:262
void BufFileTell(BufFile *file, int *fileno, off_t *offset)
Definition: buffile.c:743
void BufFileWrite(BufFile *file, void *ptr, size_t size)
Definition: buffile.c:586