diff options
author | Robert Haas <rhaas@postgresql.org> | 2022-09-19 12:53:46 -0400 |
---|---|---|
committer | Robert Haas <rhaas@postgresql.org> | 2022-09-19 12:53:46 -0400 |
commit | ebfb814f7ce0d5ab6f47f0b86db51a1b8f3342f4 (patch) | |
tree | 787012d7a8e3e26b511c308ebb358ed99468c340 /src/bin/pg_basebackup/pg_receivewal.c | |
parent | c35ba141de1fa04373671ba24c73eb0fe4862415 (diff) | |
download | postgresql-ebfb814f7ce0d5ab6f47f0b86db51a1b8f3342f4.tar.gz postgresql-ebfb814f7ce0d5ab6f47f0b86db51a1b8f3342f4.zip |
walmethods.c/h: Make WalWriteMethod more object-oriented.
Normally when we use object-oriented programming techniques, we
provide a pointer to an object and then some way of looking up the
associated table of callbacks, but walmethods.c/h took the alternative
approach of providing only a pointer to the table of callbacks and
thus imposed the artificial restriction that there could only ever be
one object of each type, so that the callbacks could find it via a
global variable. That doesn't seem like the right idea, so revise the
approach.
Each callback which does not already have an argument of type
Walfile * now takes a pointer to the relevant WalWriteMethod *
so that these callbacks need not rely on there being only one
object of each type.
Freeing a WalWriteMethod is now performed via a callback provided
for that purpose rather than requiring the caller to know which
WAL method they want to free.
Discussion: http://postgr.es/m/CA+TgmoZS0Kw98fOoAcGz8B9iDhdqB4Be4e=vDZaJZ5A-xMYBqA@mail.gmail.com
Diffstat (limited to 'src/bin/pg_basebackup/pg_receivewal.c')
-rw-r--r-- | src/bin/pg_basebackup/pg_receivewal.c | 6 |
1 files changed, 2 insertions, 4 deletions
diff --git a/src/bin/pg_basebackup/pg_receivewal.c b/src/bin/pg_basebackup/pg_receivewal.c index 5c22c914bc7..a7180e2955b 100644 --- a/src/bin/pg_basebackup/pg_receivewal.c +++ b/src/bin/pg_basebackup/pg_receivewal.c @@ -658,7 +658,7 @@ StreamLog(void) ReceiveXlogStream(conn, &stream); - if (!stream.walmethod->finish()) + if (!stream.walmethod->ops->finish(stream.walmethod)) { pg_log_info("could not finish writing WAL files: %m"); return; @@ -667,9 +667,7 @@ StreamLog(void) PQfinish(conn); conn = NULL; - FreeWalDirectoryMethod(); - pg_free(stream.walmethod); - pg_free(stream.sysidentifier); + stream.walmethod->ops->free(stream.walmethod); } /* |