2018-09-25 10:24:42 +01:00
|
|
|
/***********************************************************************************************************************************
|
|
|
|
PostgreSQL 8.3 Interface
|
|
|
|
***********************************************************************************************************************************/
|
|
|
|
#include "common/debug.h"
|
|
|
|
#include "common/log.h"
|
|
|
|
#include "postgres/interface/v083.h"
|
|
|
|
|
|
|
|
/***********************************************************************************************************************************
|
|
|
|
Include PostgreSQL Types
|
|
|
|
***********************************************************************************************************************************/
|
|
|
|
#include "postgres/interface/v083.auto.c"
|
|
|
|
|
|
|
|
/***********************************************************************************************************************************
|
|
|
|
Is the control file for this version of PostgreSQL?
|
|
|
|
***********************************************************************************************************************************/
|
|
|
|
bool
|
|
|
|
pgInterfaceIs083(const Buffer *controlFile)
|
|
|
|
{
|
|
|
|
FUNCTION_TEST_BEGIN();
|
|
|
|
FUNCTION_TEST_PARAM(BUFFER, controlFile);
|
|
|
|
FUNCTION_TEST_END();
|
|
|
|
|
2019-01-21 17:41:59 +02:00
|
|
|
ASSERT(controlFile != NULL);
|
|
|
|
|
2018-09-25 10:24:42 +01:00
|
|
|
ControlFileData *controlData = (ControlFileData *)bufPtr(controlFile);
|
|
|
|
|
2019-01-21 17:41:59 +02:00
|
|
|
FUNCTION_TEST_RETURN(
|
2019-01-28 15:06:28 +02:00
|
|
|
controlData->pg_control_version == PG_CONTROL_VERSION && controlData->catalog_version_no == CATALOG_VERSION_NO);
|
2018-09-25 10:24:42 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/***********************************************************************************************************************************
|
|
|
|
Get information from pg_control in a common format
|
|
|
|
***********************************************************************************************************************************/
|
|
|
|
PgControl
|
|
|
|
pgInterfaceControl083(const Buffer *controlFile)
|
|
|
|
{
|
2019-01-21 17:41:59 +02:00
|
|
|
FUNCTION_LOG_BEGIN(logLevelTrace);
|
|
|
|
FUNCTION_LOG_PARAM(BUFFER, controlFile);
|
|
|
|
FUNCTION_LOG_END();
|
2018-09-25 10:24:42 +01:00
|
|
|
|
2019-01-21 17:41:59 +02:00
|
|
|
ASSERT(controlFile != NULL);
|
|
|
|
ASSERT(pgInterfaceIs083(controlFile));
|
2018-09-25 10:24:42 +01:00
|
|
|
|
|
|
|
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;
|
|
|
|
|
2019-01-21 17:41:59 +02:00
|
|
|
FUNCTION_LOG_RETURN(PG_CONTROL, result);
|
2018-09-25 10:24:42 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/***********************************************************************************************************************************
|
|
|
|
Create pg_control for testing
|
|
|
|
***********************************************************************************************************************************/
|
|
|
|
#ifdef DEBUG
|
|
|
|
|
|
|
|
void
|
|
|
|
pgInterfaceControlTest083(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;
|
|
|
|
|
2019-01-21 17:41:59 +02:00
|
|
|
FUNCTION_TEST_RETURN_VOID();
|
2018-09-25 10:24:42 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
#endif
|