On Tue, Apr 11, 2017 at 3:53 PM, Tom Lane <t...@sss.pgh.pa.us> wrote:
> Magnus Hagander <mag...@hagander.net> writes: > > On Tue, Apr 11, 2017 at 3:19 PM, Tom Lane <t...@sss.pgh.pa.us> wrote: > >> I think the patch is correct, but if there's any documentation of the > >> walmethod APIs that would allow one to assert which side of the API got > >> this wrong, I sure don't see it. Would it be unreasonable to insist > >> on some documentation around that? > > > Would you say comments in the struct in walmethods.h is enough, or were > you > > thinking actual sgml docs when you commented that? > > This is just internal to pg_basebackup isn't it? I think comments in > walmethods.h would be plenty. > Local to pg_basebackup and pg_receivewal, yes. Something like the attached? -- Magnus Hagander Me: https://www.hagander.net/ <http://www.hagander.net/> Work: https://www.redpill-linpro.com/ <http://www.redpill-linpro.com/>
diff --git a/src/bin/pg_basebackup/walmethods.h b/src/bin/pg_basebackup/walmethods.h index 8d679da..a3316a6 100644 --- a/src/bin/pg_basebackup/walmethods.h +++ b/src/bin/pg_basebackup/walmethods.h @@ -19,18 +19,50 @@ typedef enum CLOSE_NO_RENAME } WalCloseMethod; +/* + * A WalWriteMethod structure represents the different methods used + * to write the streaming WAL as it's received. + * + * All methods that have a failure path will set errno on failure. + */ typedef struct WalWriteMethod WalWriteMethod; struct WalWriteMethod { + /* Open a target file. Returns Walfile, or NULL if open failed. */ Walfile(*open_for_write) (const char *pathname, const char *temp_suffix, size_t pad_to_size); + + /* + * Close an open Walfile, using one or more methods for handling + * automatic unlinking etc. Returns 0 on success, other values + * for error. + */ int (*close) (Walfile f, WalCloseMethod method); + + /* Check if a file exist */ bool (*existsfile) (const char *pathname); + + /* Return the size of a file, or -1 on failure. */ ssize_t (*get_file_size) (const char *pathname); + /* + * Write count number of bytes to the file, and return the number + * of bytes actually written or -1 for error. + */ ssize_t (*write) (Walfile f, const void *buf, size_t count); + + /* Return the current position in a file or -1 on error */ off_t (*get_current_pos) (Walfile f); + + /* + * fsync the contents of the specified file. Returns 0 on + * success. + */ int (*sync) (Walfile f); + + /* Clean up the Walmethod, closing any shared resources */ bool (*finish) (void); + + /* Return a text for the last error in this Walfile */ char *(*getlasterror) (void); };
-- Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-hackers