walmethods.c/h: Make WalWriteMethod more object-oriented.
authorRobert Haas <[email protected]>
Mon, 19 Sep 2022 16:53:46 +0000 (12:53 -0400)
committerRobert Haas <[email protected]>
Mon, 19 Sep 2022 16:53:46 +0000 (12:53 -0400)
commitebfb814f7ce0d5ab6f47f0b86db51a1b8f3342f4
tree787012d7a8e3e26b511c308ebb358ed99468c340
parentc35ba141de1fa04373671ba24c73eb0fe4862415
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
src/bin/pg_basebackup/pg_basebackup.c
src/bin/pg_basebackup/pg_receivewal.c
src/bin/pg_basebackup/receivelog.c
src/bin/pg_basebackup/walmethods.c
src/bin/pg_basebackup/walmethods.h