1999-10-13 11:02:32 -04:00
|
|
|
/*-------------------------------------------------------------------------
|
|
|
|
|
*
|
|
|
|
|
* buffile.h
|
2017-11-25 13:19:43 -05:00
|
|
|
* Management of large buffered temporary files.
|
1999-10-13 11:02:32 -04:00
|
|
|
*
|
|
|
|
|
* The BufFile routines provide a partial replacement for stdio atop
|
|
|
|
|
* virtual file descriptors managed by fd.c. Currently they only support
|
|
|
|
|
* buffered access to a virtual file, without any of stdio's formatting
|
|
|
|
|
* features. That's enough for immediate needs, but the set of facilities
|
|
|
|
|
* could be expanded if necessary.
|
|
|
|
|
*
|
|
|
|
|
* BufFile also supports working with temporary files that exceed the OS
|
|
|
|
|
* file size limit and/or the largest offset representable in an int.
|
|
|
|
|
* It might be better to split that out as a separately accessible module,
|
|
|
|
|
* but currently we have no need for oversize temp files without buffered
|
|
|
|
|
* access.
|
|
|
|
|
*
|
2025-01-01 11:21:55 -05:00
|
|
|
* Portions Copyright (c) 1996-2025, PostgreSQL Global Development Group
|
2000-01-26 00:58:53 -05:00
|
|
|
* Portions Copyright (c) 1994, Regents of the University of California
|
1999-10-13 11:02:32 -04:00
|
|
|
*
|
2010-09-20 16:08:53 -04:00
|
|
|
* src/include/storage/buffile.h
|
1999-10-13 11:02:32 -04:00
|
|
|
*
|
|
|
|
|
*-------------------------------------------------------------------------
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
#ifndef BUFFILE_H
|
|
|
|
|
#define BUFFILE_H
|
|
|
|
|
|
2021-08-29 23:15:35 -04:00
|
|
|
#include "storage/fileset.h"
|
2017-12-01 19:30:56 -05:00
|
|
|
|
1999-10-13 11:02:32 -04:00
|
|
|
/* BufFile is an opaque type whose details are not known outside buffile.c. */
|
|
|
|
|
|
|
|
|
|
typedef struct BufFile BufFile;
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* prototypes for functions in buffile.c
|
|
|
|
|
*/
|
|
|
|
|
|
2007-06-07 15:19:57 -04:00
|
|
|
extern BufFile *BufFileCreateTemp(bool interXact);
|
1999-10-13 11:02:32 -04:00
|
|
|
extern void BufFileClose(BufFile *file);
|
2025-03-14 02:18:07 -04:00
|
|
|
pg_nodiscard extern size_t BufFileRead(BufFile *file, void *ptr, size_t size);
|
2023-01-16 03:20:44 -05:00
|
|
|
extern void BufFileReadExact(BufFile *file, void *ptr, size_t size);
|
|
|
|
|
extern size_t BufFileReadMaybeEOF(BufFile *file, void *ptr, size_t size, bool eofOK);
|
2022-12-30 04:02:59 -05:00
|
|
|
extern void BufFileWrite(BufFile *file, const void *ptr, size_t size);
|
2008-03-10 16:06:27 -04:00
|
|
|
extern int BufFileSeek(BufFile *file, int fileno, off_t offset, int whence);
|
|
|
|
|
extern void BufFileTell(BufFile *file, int *fileno, off_t *offset);
|
2023-11-16 21:20:53 -05:00
|
|
|
extern int BufFileSeekBlock(BufFile *file, int64 blknum);
|
2018-11-14 18:34:04 -05:00
|
|
|
extern int64 BufFileSize(BufFile *file);
|
2023-11-16 21:20:53 -05:00
|
|
|
extern int64 BufFileAppend(BufFile *target, BufFile *source);
|
2001-10-28 01:26:15 -05:00
|
|
|
|
2021-08-29 23:15:35 -04:00
|
|
|
extern BufFile *BufFileCreateFileSet(FileSet *fileset, const char *name);
|
|
|
|
|
extern void BufFileExportFileSet(BufFile *file);
|
|
|
|
|
extern BufFile *BufFileOpenFileSet(FileSet *fileset, const char *name,
|
2021-09-01 22:43:46 -04:00
|
|
|
int mode, bool missing_ok);
|
|
|
|
|
extern void BufFileDeleteFileSet(FileSet *fileset, const char *name,
|
|
|
|
|
bool missing_ok);
|
2021-08-29 23:15:35 -04:00
|
|
|
extern void BufFileTruncateFileSet(BufFile *file, int fileno, off_t offset);
|
2017-12-01 19:30:56 -05:00
|
|
|
|
1999-10-13 11:02:32 -04:00
|
|
|
#endif /* BUFFILE_H */
|