mirror of
https://github.com/pgbackrest/pgbackrest.git
synced 2025-06-06 23:16:26 +02:00
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.
62 lines
2.9 KiB
C
62 lines
2.9 KiB
C
/***********************************************************************************************************************************
|
|
PostgreSQL Interface
|
|
***********************************************************************************************************************************/
|
|
#ifndef POSTGRES_INTERFACE_H
|
|
#define POSTGRES_INTERFACE_H
|
|
|
|
#include <stdint.h>
|
|
#include <sys/types.h>
|
|
|
|
#include "common/type/string.h"
|
|
|
|
/***********************************************************************************************************************************
|
|
Defines for various Postgres paths and files
|
|
***********************************************************************************************************************************/
|
|
#define PG_FILE_PGCONTROL "pg_control"
|
|
|
|
#define PG_PATH_GLOBAL "global"
|
|
|
|
/***********************************************************************************************************************************
|
|
PostgreSQL Control File Info
|
|
***********************************************************************************************************************************/
|
|
typedef struct PgControl
|
|
{
|
|
unsigned int version;
|
|
uint64_t systemId;
|
|
|
|
uint32_t controlVersion;
|
|
uint32_t catalogVersion;
|
|
|
|
unsigned int pageSize;
|
|
unsigned int walSegmentSize;
|
|
|
|
bool pageChecksum;
|
|
} PgControl;
|
|
|
|
/***********************************************************************************************************************************
|
|
Functions
|
|
***********************************************************************************************************************************/
|
|
PgControl pgControlFromFile(const String *pgPath);
|
|
PgControl pgControlFromBuffer(const Buffer *controlFile);
|
|
unsigned int pgVersionFromStr(const String *version);
|
|
String *pgVersionToStr(unsigned int version);
|
|
|
|
/***********************************************************************************************************************************
|
|
Test Functions
|
|
***********************************************************************************************************************************/
|
|
#ifdef DEBUG
|
|
Buffer *pgControlTestToBuffer(PgControl pgControl);
|
|
#endif
|
|
|
|
/***********************************************************************************************************************************
|
|
Macros for function logging
|
|
***********************************************************************************************************************************/
|
|
String *pgControlToLog(const PgControl *pgControl);
|
|
|
|
#define FUNCTION_LOG_PG_CONTROL_TYPE \
|
|
PgControl
|
|
#define FUNCTION_LOG_PG_CONTROL_FORMAT(value, buffer, bufferSize) \
|
|
FUNCTION_LOG_STRING_OBJECT_FORMAT(&value, pgControlToLog, buffer, bufferSize)
|
|
|
|
#endif
|