2018-04-29 11:20:51 -04:00
|
|
|
/***********************************************************************************************************************************
|
2018-09-25 10:24:42 +01:00
|
|
|
PostgreSQL Interface
|
2018-04-29 11:20:51 -04:00
|
|
|
***********************************************************************************************************************************/
|
2018-09-25 10:24:42 +01:00
|
|
|
#ifndef POSTGRES_INTERFACE_H
|
|
|
|
#define POSTGRES_INTERFACE_H
|
2018-04-29 11:20:51 -04:00
|
|
|
|
|
|
|
#include <stdint.h>
|
|
|
|
#include <sys/types.h>
|
|
|
|
|
2018-09-25 10:24:42 +01:00
|
|
|
#include "common/type/string.h"
|
|
|
|
|
|
|
|
/***********************************************************************************************************************************
|
|
|
|
Defines for various Postgres paths and files
|
|
|
|
***********************************************************************************************************************************/
|
|
|
|
#define PG_FILE_PGCONTROL "pg_control"
|
|
|
|
|
|
|
|
#define PG_PATH_GLOBAL "global"
|
|
|
|
|
2018-04-29 11:20:51 -04:00
|
|
|
/***********************************************************************************************************************************
|
|
|
|
PostgreSQL Control File Info
|
|
|
|
***********************************************************************************************************************************/
|
2018-09-25 10:24:42 +01:00
|
|
|
typedef struct PgControl
|
2018-04-29 11:20:51 -04:00
|
|
|
{
|
2018-09-25 10:24:42 +01:00
|
|
|
unsigned int version;
|
2018-04-29 11:20:51 -04:00
|
|
|
uint64_t systemId;
|
2018-09-25 10:24:42 +01:00
|
|
|
|
2018-04-29 11:20:51 -04:00
|
|
|
uint32_t controlVersion;
|
|
|
|
uint32_t catalogVersion;
|
|
|
|
|
2018-09-25 10:24:42 +01:00
|
|
|
unsigned int pageSize;
|
|
|
|
unsigned int walSegmentSize;
|
|
|
|
|
|
|
|
bool pageChecksum;
|
|
|
|
} PgControl;
|
2018-04-29 11:20:51 -04:00
|
|
|
|
|
|
|
/***********************************************************************************************************************************
|
|
|
|
Functions
|
|
|
|
***********************************************************************************************************************************/
|
2018-09-25 10:24:42 +01:00
|
|
|
PgControl pgControlFromFile(const String *pgPath);
|
|
|
|
PgControl pgControlFromBuffer(const Buffer *controlFile);
|
2018-09-06 10:12:14 -07:00
|
|
|
unsigned int pgVersionFromStr(const String *version);
|
|
|
|
String *pgVersionToStr(unsigned int version);
|
2018-04-29 11:20:51 -04:00
|
|
|
|
2018-09-25 10:24:42 +01:00
|
|
|
/***********************************************************************************************************************************
|
|
|
|
Test Functions
|
|
|
|
***********************************************************************************************************************************/
|
|
|
|
#ifdef DEBUG
|
|
|
|
Buffer *pgControlTestToBuffer(PgControl pgControl);
|
|
|
|
#endif
|
|
|
|
|
2018-05-18 11:57:32 -04:00
|
|
|
/***********************************************************************************************************************************
|
|
|
|
Macros for function logging
|
|
|
|
***********************************************************************************************************************************/
|
2018-09-25 10:24:42 +01:00
|
|
|
String *pgControlToLog(const PgControl *pgControl);
|
|
|
|
|
2019-01-21 17:41:59 +02:00
|
|
|
#define FUNCTION_LOG_PG_CONTROL_TYPE \
|
2018-09-25 10:24:42 +01:00
|
|
|
PgControl
|
2019-01-21 17:41:59 +02:00
|
|
|
#define FUNCTION_LOG_PG_CONTROL_FORMAT(value, buffer, bufferSize) \
|
|
|
|
FUNCTION_LOG_STRING_OBJECT_FORMAT(&value, pgControlToLog, buffer, bufferSize)
|
2018-05-18 11:57:32 -04:00
|
|
|
|
2018-04-29 11:20:51 -04:00
|
|
|
#endif
|