1
0
mirror of https://github.com/pgbackrest/pgbackrest.git synced 2025-07-05 00:28:52 +02:00

Refactor PostgreSQL interface to remove most code duplication.

Having a copy per version worked well until it was time to add new features or modify existing functions.  Then it was necessary to modify every version and try to keep them all in sync.

Consolidate all the PostgreSQL types into a single file using #if for type versions.  Many types do not change or change infrequently so this cuts down on duplication.  In addition, it is far easier to see what has changed when a new version is added.

Use macros to write the interface functions.  There is still duplication here since some changes require a new copy of the macro, but it is far less than before.
This commit is contained in:
David Steele
2019-03-21 21:11:36 +04:00
parent e938a89250
commit 7cf7373761
42 changed files with 2359 additions and 4911 deletions

View File

@ -0,0 +1,105 @@
/***********************************************************************************************************************************
PostgreSQL Version Interface
***********************************************************************************************************************************/
#ifndef POSTGRES_INTERFACE_VERSION_H
#define POSTGRES_INTERFACE_VERSION_H
#include "postgres/interface.h"
/***********************************************************************************************************************************
Functions
***********************************************************************************************************************************/
bool pgInterfaceControlIs083(const unsigned char *controlFile);
PgControl pgInterfaceControl083(const unsigned char *controlFile);
bool pgInterfaceWalIs083(const unsigned char *walFile);
PgWal pgInterfaceWal083(const unsigned char *controlFile);
bool pgInterfaceControlIs084(const unsigned char *controlFile);
PgControl pgInterfaceControl084(const unsigned char *controlFile);
bool pgInterfaceWalIs084(const unsigned char *walFile);
PgWal pgInterfaceWal084(const unsigned char *controlFile);
bool pgInterfaceControlIs090(const unsigned char *controlFile);
PgControl pgInterfaceControl090(const unsigned char *controlFile);
bool pgInterfaceWalIs090(const unsigned char *walFile);
PgWal pgInterfaceWal090(const unsigned char *controlFile);
bool pgInterfaceControlIs091(const unsigned char *controlFile);
PgControl pgInterfaceControl091(const unsigned char *controlFile);
bool pgInterfaceWalIs091(const unsigned char *walFile);
PgWal pgInterfaceWal091(const unsigned char *controlFile);
bool pgInterfaceControlIs092(const unsigned char *controlFile);
PgControl pgInterfaceControl092(const unsigned char *controlFile);
bool pgInterfaceWalIs092(const unsigned char *walFile);
PgWal pgInterfaceWal092(const unsigned char *controlFile);
bool pgInterfaceControlIs093(const unsigned char *controlFile);
PgControl pgInterfaceControl093(const unsigned char *controlFile);
bool pgInterfaceWalIs093(const unsigned char *walFile);
PgWal pgInterfaceWal093(const unsigned char *controlFile);
bool pgInterfaceControlIs094(const unsigned char *controlFile);
PgControl pgInterfaceControl094(const unsigned char *controlFile);
bool pgInterfaceWalIs094(const unsigned char *walFile);
PgWal pgInterfaceWal094(const unsigned char *controlFile);
bool pgInterfaceControlIs095(const unsigned char *controlFile);
PgControl pgInterfaceControl095(const unsigned char *controlFile);
bool pgInterfaceWalIs095(const unsigned char *walFile);
PgWal pgInterfaceWal095(const unsigned char *controlFile);
bool pgInterfaceControlIs096(const unsigned char *controlFile);
PgControl pgInterfaceControl096(const unsigned char *controlFile);
bool pgInterfaceWalIs096(const unsigned char *walFile);
PgWal pgInterfaceWal096(const unsigned char *controlFile);
bool pgInterfaceControlIs100(const unsigned char *controlFile);
PgControl pgInterfaceControl100(const unsigned char *controlFile);
bool pgInterfaceWalIs100(const unsigned char *walFile);
PgWal pgInterfaceWal100(const unsigned char *controlFile);
bool pgInterfaceControlIs110(const unsigned char *controlFile);
PgControl pgInterfaceControl110(const unsigned char *controlFile);
bool pgInterfaceWalIs110(const unsigned char *walFile);
PgWal pgInterfaceWal110(const unsigned char *controlFile);
/***********************************************************************************************************************************
Test Functions
***********************************************************************************************************************************/
#ifdef DEBUG
void pgInterfaceControlTest083(PgControl pgControl, unsigned char *buffer);
void pgInterfaceWalTest083(PgWal pgWal, unsigned char *buffer);
void pgInterfaceControlTest084(PgControl pgControl, unsigned char *buffer);
void pgInterfaceWalTest084(PgWal pgWal, unsigned char *buffer);
void pgInterfaceControlTest090(PgControl pgControl, unsigned char *buffer);
void pgInterfaceWalTest090(PgWal pgWal, unsigned char *buffer);
void pgInterfaceControlTest091(PgControl pgControl, unsigned char *buffer);
void pgInterfaceWalTest091(PgWal pgWal, unsigned char *buffer);
void pgInterfaceControlTest092(PgControl pgControl, unsigned char *buffer);
void pgInterfaceWalTest092(PgWal pgWal, unsigned char *buffer);
void pgInterfaceControlTest093(PgControl pgControl, unsigned char *buffer);
void pgInterfaceWalTest093(PgWal pgWal, unsigned char *buffer);
void pgInterfaceControlTest094(PgControl pgControl, unsigned char *buffer);
void pgInterfaceWalTest094(PgWal pgWal, unsigned char *buffer);
void pgInterfaceControlTest095(PgControl pgControl, unsigned char *buffer);
void pgInterfaceWalTest095(PgWal pgWal, unsigned char *buffer);
void pgInterfaceControlTest096(PgControl pgControl, unsigned char *buffer);
void pgInterfaceWalTest096(PgWal pgWal, unsigned char *buffer);
void pgInterfaceControlTest100(PgControl pgControl, unsigned char *buffer);
void pgInterfaceWalTest100(PgWal pgWal, unsigned char *buffer);
void pgInterfaceControlTest110(PgControl pgControl, unsigned char *buffer);
void pgInterfaceWalTest110(PgWal pgWal, unsigned char *buffer);
#endif
#endif