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

Add meson unity build and tests.

This is immediately useful because it will detect any extern'd functions or variables that are not being used. It also detects functions or variables that are declared but not defined.

If a FV/VR_EXTERN macro is missing it will be detected either because of a mismatch in the declaration/definition or because a new defined symbol will appear in the nm test.

Eventually the unity build will be used to create a more optimized pgbackrest binary but that will need to wait.
This commit is contained in:
David Steele
2022-12-31 17:13:41 +07:00
parent 8aa2b101bb
commit 4fb8a0ecdd
365 changed files with 1990 additions and 1885 deletions

View File

@ -39,7 +39,7 @@ pgClientFreeResource(THIS_VOID)
}
/**********************************************************************************************************************************/
PgClient *
FV_EXTERN PgClient *
pgClientNew(const String *host, const unsigned int port, const String *database, const String *user, const TimeMSec timeout)
{
FUNCTION_LOG_BEGIN(logLevelDebug);
@ -118,7 +118,7 @@ pgClientEscape(const String *string)
}
/**********************************************************************************************************************************/
PgClient *
FV_EXTERN PgClient *
pgClientOpen(PgClient *this)
{
FUNCTION_LOG_BEGIN(logLevelDebug);
@ -165,7 +165,7 @@ pgClientOpen(PgClient *this)
}
/**********************************************************************************************************************************/
Pack *
FV_EXTERN Pack *
pgClientQuery(PgClient *const this, const String *const query, const PgClientQueryResult resultType)
{
FUNCTION_LOG_BEGIN(logLevelDebug);
@ -357,7 +357,7 @@ pgClientQuery(PgClient *const this, const String *const query, const PgClientQue
}
/**********************************************************************************************************************************/
void
FV_EXTERN void
pgClientClose(PgClient *this)
{
FUNCTION_LOG_BEGIN(logLevelDebug);
@ -377,7 +377,7 @@ pgClientClose(PgClient *this)
}
/**********************************************************************************************************************************/
String *
FV_EXTERN String *
pgClientToLog(const PgClient *this)
{
return strNewFmt(

View File

@ -32,7 +32,7 @@ typedef struct PgClient PgClient;
/***********************************************************************************************************************************
Constructors
***********************************************************************************************************************************/
PgClient *pgClientNew(
FV_EXTERN PgClient *pgClientNew(
const String *host, const unsigned int port, const String *database, const String *user, const TimeMSec timeout);
/***********************************************************************************************************************************
@ -86,7 +86,7 @@ pgClientTimeout(const PgClient *const this)
Functions
***********************************************************************************************************************************/
// Open connection to PostgreSQL
PgClient *pgClientOpen(PgClient *this);
FV_EXTERN PgClient *pgClientOpen(PgClient *this);
// Move to a new parent mem context
FN_INLINE_ALWAYS PgClient *
@ -96,10 +96,10 @@ pgClientMove(PgClient *const this, MemContext *const parentNew)
}
// Execute a query and return results
Pack *pgClientQuery(PgClient *this, const String *query, PgClientQueryResult resultType);
FV_EXTERN Pack *pgClientQuery(PgClient *this, const String *query, PgClientQueryResult resultType);
// Close connection to PostgreSQL
void pgClientClose(PgClient *this);
FV_EXTERN void pgClientClose(PgClient *this);
/***********************************************************************************************************************************
Destructor
@ -113,7 +113,7 @@ pgClientFree(PgClient *const this)
/***********************************************************************************************************************************
Macros for function logging
***********************************************************************************************************************************/
String *pgClientToLog(const PgClient *this);
FV_EXTERN String *pgClientToLog(const PgClient *this);
#define FUNCTION_LOG_PG_CLIENT_TYPE \
PgClient *

View File

@ -117,7 +117,7 @@ pgInterfaceVersion(unsigned int pgVersion)
}
/**********************************************************************************************************************************/
bool
FV_EXTERN bool
pgDbIsTemplate(const String *const name)
{
FUNCTION_TEST_BEGIN();
@ -128,7 +128,7 @@ pgDbIsTemplate(const String *const name)
}
/**********************************************************************************************************************************/
bool
FV_EXTERN bool
pgDbIsSystem(const String *const name)
{
FUNCTION_TEST_BEGIN();
@ -139,7 +139,7 @@ pgDbIsSystem(const String *const name)
}
/**********************************************************************************************************************************/
bool
FV_EXTERN bool
pgDbIsSystemId(const unsigned int id)
{
FUNCTION_TEST_BEGIN();
@ -218,7 +218,7 @@ pgControlFromBuffer(const Buffer *controlFile)
FUNCTION_LOG_RETURN(PG_CONTROL, result);
}
PgControl
FV_EXTERN PgControl
pgControlFromFile(const Storage *storage)
{
FUNCTION_LOG_BEGIN(logLevelDebug);
@ -243,7 +243,7 @@ pgControlFromFile(const Storage *storage)
}
/**********************************************************************************************************************************/
uint32_t
FV_EXTERN uint32_t
pgControlVersion(unsigned int pgVersion)
{
FUNCTION_TEST_BEGIN();
@ -266,7 +266,7 @@ typedef struct PgWalCommon
#define PG_WAL_LONG_HEADER 0x0002
/**********************************************************************************************************************************/
PgWal
FV_EXTERN PgWal
pgWalFromBuffer(const Buffer *walBuffer)
{
FUNCTION_LOG_BEGIN(logLevelTrace);
@ -311,7 +311,7 @@ pgWalFromBuffer(const Buffer *walBuffer)
FUNCTION_LOG_RETURN(PG_WAL, result);
}
PgWal
FV_EXTERN PgWal
pgWalFromFile(const String *walFile, const Storage *storage)
{
FUNCTION_LOG_BEGIN(logLevelDebug);
@ -335,7 +335,7 @@ pgWalFromFile(const String *walFile, const Storage *storage)
}
/**********************************************************************************************************************************/
String *
FV_EXTERN String *
pgTablespaceId(unsigned int pgVersion, unsigned int pgCatalogVersion)
{
FUNCTION_TEST_BEGIN();
@ -361,7 +361,7 @@ pgTablespaceId(unsigned int pgVersion, unsigned int pgCatalogVersion)
}
/**********************************************************************************************************************************/
uint64_t
FV_EXTERN uint64_t
pgLsnFromStr(const String *lsn)
{
FUNCTION_TEST_BEGIN();
@ -383,7 +383,7 @@ pgLsnFromStr(const String *lsn)
FUNCTION_TEST_RETURN(UINT64, result);
}
String *
FV_EXTERN String *
pgLsnToStr(uint64_t lsn)
{
FUNCTION_TEST_BEGIN();
@ -394,7 +394,7 @@ pgLsnToStr(uint64_t lsn)
}
/**********************************************************************************************************************************/
String *
FV_EXTERN String *
pgLsnToWalSegment(uint32_t timeline, uint64_t lsn, unsigned int walSegmentSize)
{
FUNCTION_TEST_BEGIN();
@ -408,7 +408,7 @@ pgLsnToWalSegment(uint32_t timeline, uint64_t lsn, unsigned int walSegmentSize)
}
/**********************************************************************************************************************************/
uint32_t
FV_EXTERN uint32_t
pgTimelineFromWalSegment(const String *const walSegment)
{
FUNCTION_TEST_BEGIN();
@ -422,7 +422,7 @@ pgTimelineFromWalSegment(const String *const walSegment)
}
/**********************************************************************************************************************************/
StringList *
FV_EXTERN StringList *
pgLsnRangeToWalSegmentList(
const uint32_t timeline, const uint64_t lsnStart, const uint64_t lsnStop, const unsigned int walSegmentSize)
{
@ -472,7 +472,7 @@ pgLsnRangeToWalSegmentList(
}
/**********************************************************************************************************************************/
const String *
FV_EXTERN const String *
pgLsnName(unsigned int pgVersion)
{
FUNCTION_TEST_BEGIN();
@ -485,7 +485,7 @@ pgLsnName(unsigned int pgVersion)
/***********************************************************************************************************************************
Get WAL name (wal/xlog) for a PostgreSQL version
***********************************************************************************************************************************/
const String *
FV_EXTERN const String *
pgWalName(unsigned int pgVersion)
{
FUNCTION_TEST_BEGIN();
@ -496,7 +496,7 @@ pgWalName(unsigned int pgVersion)
}
/**********************************************************************************************************************************/
const String *
FV_EXTERN const String *
pgWalPath(unsigned int pgVersion)
{
FUNCTION_TEST_BEGIN();
@ -507,7 +507,7 @@ pgWalPath(unsigned int pgVersion)
}
/**********************************************************************************************************************************/
const String *
FV_EXTERN const String *
pgXactPath(unsigned int pgVersion)
{
FUNCTION_TEST_BEGIN();
@ -518,7 +518,7 @@ pgXactPath(unsigned int pgVersion)
}
/**********************************************************************************************************************************/
unsigned int
FV_EXTERN unsigned int
pgVersionFromStr(const String *const version)
{
FUNCTION_LOG_BEGIN(logLevelTrace);
@ -542,7 +542,7 @@ pgVersionFromStr(const String *const version)
UINT, cvtZSubNToUInt(strZ(version), 0, (size_t)idxStart) * 10000 + cvtZToUInt(strZ(version) + (size_t)idxStart + 1) * 100);
}
String *
FV_EXTERN String *
pgVersionToStr(unsigned int version)
{
FUNCTION_LOG_BEGIN(logLevelTrace);
@ -556,7 +556,7 @@ pgVersionToStr(unsigned int version)
}
/**********************************************************************************************************************************/
String *
FV_EXTERN String *
pgControlToLog(const PgControl *pgControl)
{
return strNewFmt(
@ -564,7 +564,7 @@ pgControlToLog(const PgControl *pgControl)
pgControl->walSegmentSize, cvtBoolToConstZ(pgControl->pageChecksum));
}
String *
FV_EXTERN String *
pgWalToLog(const PgWal *pgWal)
{
return strNewFmt("{version: %u, systemId: %" PRIu64 "}", pgWal->version, pgWal->systemId);

View File

@ -121,63 +121,64 @@ typedef struct PgWal
Functions
***********************************************************************************************************************************/
// Is this a template database?
bool pgDbIsTemplate(const String *name);
FV_EXTERN bool pgDbIsTemplate(const String *name);
// Is this a system database, i.e. template or postgres?
bool pgDbIsSystem(const String *name);
FV_EXTERN bool pgDbIsSystem(const String *name);
// Does this database have a system id, i.e. less than the minimum assignable user id?
bool pgDbIsSystemId(unsigned int id);
FV_EXTERN bool pgDbIsSystemId(unsigned int id);
// Get info from pg_control
PgControl pgControlFromFile(const Storage *storage);
FV_EXTERN PgControl pgControlFromFile(const Storage *storage);
// Get the control version for a PostgreSQL version
uint32_t pgControlVersion(unsigned int pgVersion);
FV_EXTERN uint32_t pgControlVersion(unsigned int pgVersion);
// Convert version string to version number and vice versa
unsigned int pgVersionFromStr(const String *version);
String *pgVersionToStr(unsigned int version);
FV_EXTERN unsigned int pgVersionFromStr(const String *version);
FV_EXTERN String *pgVersionToStr(unsigned int version);
// Get info from WAL header
PgWal pgWalFromFile(const String *walFile, const Storage *storage);
PgWal pgWalFromBuffer(const Buffer *walBuffer);
FV_EXTERN PgWal pgWalFromFile(const String *walFile, const Storage *storage);
FV_EXTERN PgWal pgWalFromBuffer(const Buffer *walBuffer);
// Get the tablespace identifier used to distinguish versions in a tablespace directory, e.g. PG_15_202209061
String *pgTablespaceId(unsigned int pgVersion, unsigned int pgCatalogVersion);
FV_EXTERN String *pgTablespaceId(unsigned int pgVersion, unsigned int pgCatalogVersion);
// Convert a string to an lsn and vice versa
uint64_t pgLsnFromStr(const String *lsn);
String *pgLsnToStr(uint64_t lsn);
FV_EXTERN uint64_t pgLsnFromStr(const String *lsn);
FV_EXTERN String *pgLsnToStr(uint64_t lsn);
// Convert a timeline and lsn to a wal segment
String *pgLsnToWalSegment(uint32_t timeline, uint64_t lsn, unsigned int walSegmentSize);
// Convert a timeline and lsn to a wal segment and vice versa
FV_EXTERN String *pgLsnToWalSegment(uint32_t timeline, uint64_t lsn, unsigned int walSegmentSize);
// Get timeline from WAL segment name
uint32_t pgTimelineFromWalSegment(const String *walSegment);
FV_EXTERN uint32_t pgTimelineFromWalSegment(const String *walSegment);
// Convert a timeline and lsn range to a list of wal segments
StringList *pgLsnRangeToWalSegmentList(uint32_t timeline, uint64_t lsnStart, uint64_t lsnStop, unsigned int walSegmentSize);
FV_EXTERN StringList *pgLsnRangeToWalSegmentList(
uint32_t timeline, uint64_t lsnStart, uint64_t lsnStop, unsigned int walSegmentSize);
// Get name used for lsn in functions (this was changed in PostgreSQL 10 for consistency since lots of names were changing)
const String *pgLsnName(unsigned int pgVersion);
FV_EXTERN const String *pgLsnName(unsigned int pgVersion);
// Calculate the checksum for a page. Page cannot be const because the page header is temporarily modified during processing.
uint16_t pgPageChecksum(unsigned char *page, uint32_t blockNo);
FV_EXTERN uint16_t pgPageChecksum(unsigned char *page, uint32_t blockNo);
const String *pgWalName(unsigned int pgVersion);
FV_EXTERN const String *pgWalName(unsigned int pgVersion);
// Get wal path (this was changed in PostgreSQL 10 to avoid including "log" in the name)
const String *pgWalPath(unsigned int pgVersion);
FV_EXTERN const String *pgWalPath(unsigned int pgVersion);
// Get transaction commit log path (this was changed in PostgreSQL 10 to avoid including "log" in the name)
const String *pgXactPath(unsigned int pgVersion);
FV_EXTERN const String *pgXactPath(unsigned int pgVersion);
/***********************************************************************************************************************************
Macros for function logging
***********************************************************************************************************************************/
String *pgControlToLog(const PgControl *pgControl);
String *pgWalToLog(const PgWal *pgWal);
FV_EXTERN String *pgControlToLog(const PgControl *pgControl);
FV_EXTERN String *pgWalToLog(const PgWal *pgWal);
#define FUNCTION_LOG_PG_CONTROL_TYPE \
PgControl

View File

@ -13,7 +13,7 @@ Include the page checksum code
#include "postgres/interface/pageChecksum.vendor.c.inc"
/**********************************************************************************************************************************/
uint16_t
FV_EXTERN uint16_t
pgPageChecksum(unsigned char *page, uint32_t blockNo)
{
return pg_checksum_page((char *)page, blockNo);