1
0
mirror of https://github.com/pgbackrest/pgbackrest.git synced 2025-06-18 23:57:33 +02:00
Files
pgbackrest/src/postgres/interface/v084.c
David Steele db08656537 Rename FUNCTION_DEBUG_* and consolidate ASSERT_* macros for consistency.
Rename FUNCTION_DEBUG_* macros to FUNCTION_LOG_* to more accurately reflect what they do.  Further rename FUNCTION_DEBUG_RESULT* macros to FUNCTION_LOG_RETURN* to make it clearer that they return from the function as well as logging.  Leave FUNCTION_TEST_* macros as they are.

Consolidate the various ASSERT* macros into a single ASSERT macro that is always compiled out of production builds.  It was difficult to figure out when an assert would be checked with all the different types in play.  When ASSERTs are compiled in they will always be checked regardless of the log level -- tying these two concepts together was not a good idea.
2019-01-21 17:41:59 +02:00

82 lines
3.4 KiB
C

/***********************************************************************************************************************************
PostgreSQL 8.4 Interface
***********************************************************************************************************************************/
#include "common/debug.h"
#include "common/log.h"
#include "postgres/interface/v084.h"
/***********************************************************************************************************************************
Include PostgreSQL Types
***********************************************************************************************************************************/
#include "postgres/interface/v084.auto.c"
/***********************************************************************************************************************************
Is the control file for this version of PostgreSQL?
***********************************************************************************************************************************/
bool
pgInterfaceIs084(const Buffer *controlFile)
{
FUNCTION_TEST_BEGIN();
FUNCTION_TEST_PARAM(BUFFER, controlFile);
FUNCTION_TEST_END();
ASSERT(controlFile != NULL);
ControlFileData *controlData = (ControlFileData *)bufPtr(controlFile);
FUNCTION_TEST_RETURN(
BOOL, controlData->pg_control_version == PG_CONTROL_VERSION && controlData->catalog_version_no == CATALOG_VERSION_NO);
}
/***********************************************************************************************************************************
Get information from pg_control in a common format
***********************************************************************************************************************************/
PgControl
pgInterfaceControl084(const Buffer *controlFile)
{
FUNCTION_LOG_BEGIN(logLevelTrace);
FUNCTION_LOG_PARAM(BUFFER, controlFile);
FUNCTION_LOG_END();
ASSERT(controlFile != NULL);
ASSERT(pgInterfaceIs084(controlFile));
PgControl result = {0};
ControlFileData *controlData = (ControlFileData *)bufPtr(controlFile);
result.systemId = controlData->system_identifier;
result.controlVersion = controlData->pg_control_version;
result.catalogVersion = controlData->catalog_version_no;
result.pageSize = controlData->blcksz;
result.walSegmentSize = controlData->xlog_seg_size;
FUNCTION_LOG_RETURN(PG_CONTROL, result);
}
/***********************************************************************************************************************************
Create pg_control for testing
***********************************************************************************************************************************/
#ifdef DEBUG
void
pgInterfaceControlTest084(PgControl pgControl, Buffer *buffer)
{
FUNCTION_TEST_BEGIN();
FUNCTION_TEST_PARAM(PG_CONTROL, pgControl);
FUNCTION_TEST_END();
ControlFileData *controlData = (ControlFileData *)bufPtr(buffer);
controlData->system_identifier = pgControl.systemId;
controlData->pg_control_version = pgControl.controlVersion == 0 ? PG_CONTROL_VERSION : pgControl.controlVersion;
controlData->catalog_version_no = pgControl.catalogVersion == 0 ? CATALOG_VERSION_NO : pgControl.catalogVersion;
controlData->blcksz = pgControl.pageSize;
controlData->xlog_seg_size = pgControl.walSegmentSize;
FUNCTION_TEST_RETURN_VOID();
}
#endif