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-2024, 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/fileset.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 pg_nodiscard size_t BufFileRead(BufFile *file, void *ptr, size_t size);
42 extern void BufFileReadExact(BufFile *file, void *ptr, size_t size);
43 extern size_t BufFileReadMaybeEOF(BufFile *file, void *ptr, size_t size, bool eofOK);
44 extern void BufFileWrite(BufFile *file, const void *ptr, size_t size);
45 extern int BufFileSeek(BufFile *file, int fileno, off_t offset, int whence);
46 extern void BufFileTell(BufFile *file, int *fileno, off_t *offset);
47 extern int BufFileSeekBlock(BufFile *file, int64 blknum);
48 extern int64 BufFileSize(BufFile *file);
49 extern int64 BufFileAppend(BufFile *target, BufFile *source);
50 
51 extern BufFile *BufFileCreateFileSet(FileSet *fileset, const char *name);
52 extern void BufFileExportFileSet(BufFile *file);
53 extern BufFile *BufFileOpenFileSet(FileSet *fileset, const char *name,
54  int mode, bool missing_ok);
55 extern void BufFileDeleteFileSet(FileSet *fileset, const char *name,
56  bool missing_ok);
57 extern void BufFileTruncateFileSet(BufFile *file, int fileno, off_t offset);
58 
59 #endif /* BUFFILE_H */
int BufFileSeekBlock(BufFile *file, int64 blknum)
Definition: buffile.c:851
pg_nodiscard size_t BufFileRead(BufFile *file, void *ptr, size_t size)
Definition: buffile.c:645
void BufFileExportFileSet(BufFile *file)
Definition: buffile.c:394
void BufFileReadExact(BufFile *file, void *ptr, size_t size)
Definition: buffile.c:654
BufFile * BufFileOpenFileSet(FileSet *fileset, const char *name, int mode, bool missing_ok)
Definition: buffile.c:291
void BufFileTell(BufFile *file, int *fileno, off_t *offset)
Definition: buffile.c:833
BufFile * BufFileCreateTemp(bool interXact)
Definition: buffile.c:193
void BufFileWrite(BufFile *file, const void *ptr, size_t size)
Definition: buffile.c:676
size_t BufFileReadMaybeEOF(BufFile *file, void *ptr, size_t size, bool eofOK)
Definition: buffile.c:664
void BufFileTruncateFileSet(BufFile *file, int fileno, off_t offset)
Definition: buffile.c:928
int BufFileSeek(BufFile *file, int fileno, off_t offset, int whence)
Definition: buffile.c:740
int64 BufFileSize(BufFile *file)
Definition: buffile.c:866
BufFile * BufFileCreateFileSet(FileSet *fileset, const char *name)
Definition: buffile.c:267
void BufFileClose(BufFile *file)
Definition: buffile.c:412
int64 BufFileAppend(BufFile *target, BufFile *source)
Definition: buffile.c:902
void BufFileDeleteFileSet(FileSet *fileset, const char *name, bool missing_ok)
Definition: buffile.c:364
#define pg_nodiscard
Definition: c.h:138
static PgChecksumMode mode
Definition: pg_checksums.c:56
static rewind_source * source
Definition: pg_rewind.c:89
static pg_noinline void Size size
Definition: slab.c:607
FileSet * fileset
Definition: buffile.c:80
const char * name