mirror of
https://github.com/postgres/postgres.git
synced 2025-10-27 00:12:01 +03:00
Add BufFileRead variants with short read and EOF detection
Most callers of BufFileRead() want to check whether they read the full specified length. Checking this at every call site is very tedious. This patch provides additional variants BufFileReadExact() and BufFileReadMaybeEOF() that include the length checks. I considered changing BufFileRead() itself, but this function is also used in extensions, and so changing the behavior like this would create a lot of problems there. The new names are analogous to the existing LogicalTapeReadExact(). Reviewed-by: Amit Kapila <amit.kapila16@gmail.com> Discussion: https://www.postgresql.org/message-id/flat/f3501945-c591-8cc3-5ef0-b72a2e0eaa9c@enterprisedb.com
This commit is contained in:
@@ -38,7 +38,9 @@ typedef struct BufFile BufFile;
|
||||
|
||||
extern BufFile *BufFileCreateTemp(bool interXact);
|
||||
extern void BufFileClose(BufFile *file);
|
||||
extern size_t BufFileRead(BufFile *file, void *ptr, size_t size);
|
||||
extern pg_nodiscard size_t BufFileRead(BufFile *file, void *ptr, size_t size);
|
||||
extern void BufFileReadExact(BufFile *file, void *ptr, size_t size);
|
||||
extern size_t BufFileReadMaybeEOF(BufFile *file, void *ptr, size_t size, bool eofOK);
|
||||
extern void BufFileWrite(BufFile *file, const void *ptr, size_t size);
|
||||
extern int BufFileSeek(BufFile *file, int fileno, off_t offset, int whence);
|
||||
extern void BufFileTell(BufFile *file, int *fileno, off_t *offset);
|
||||
|
||||
Reference in New Issue
Block a user