You've already forked pgbackrest
mirror of
https://github.com/pgbackrest/pgbackrest.git
synced 2025-07-03 00:26:59 +02:00
Add pgLsnName() and pgXactPath().
This commit is contained in:
@ -29,6 +29,14 @@ STRING_EXTERN(PG_PATH_GLOBAL_STR, PG_PATH_GLOB
|
||||
STRING_EXTERN(PG_NAME_WAL_STR, PG_NAME_WAL);
|
||||
STRING_EXTERN(PG_NAME_XLOG_STR, PG_NAME_XLOG);
|
||||
|
||||
// Transaction commit log path names depending on version
|
||||
STRING_STATIC(PG_PATH_PGCLOG_STR, "pg_clog");
|
||||
STRING_STATIC(PG_PATH_PGXACT_STR, "pg_xact");
|
||||
|
||||
// Lsn name used in functions depnding on version
|
||||
STRING_STATIC(PG_NAME_LSN_STR, "lsn");
|
||||
STRING_STATIC(PG_NAME_LOCATION_STR, "location");
|
||||
|
||||
/***********************************************************************************************************************************
|
||||
Define default wal segment size
|
||||
|
||||
@ -562,6 +570,17 @@ pgTablespaceId(unsigned int pgVersion)
|
||||
FUNCTION_TEST_RETURN(result);
|
||||
}
|
||||
|
||||
/**********************************************************************************************************************************/
|
||||
const String *
|
||||
pgLsnName(unsigned int pgVersion)
|
||||
{
|
||||
FUNCTION_TEST_BEGIN();
|
||||
FUNCTION_TEST_PARAM(UINT, pgVersion);
|
||||
FUNCTION_TEST_END();
|
||||
|
||||
FUNCTION_TEST_RETURN(pgVersion >= PG_VERSION_WAL_RENAME ? PG_NAME_LSN_STR : PG_NAME_LOCATION_STR);
|
||||
}
|
||||
|
||||
/***********************************************************************************************************************************
|
||||
Get WAL name (wal/xlog) for a PostgreSQL version
|
||||
***********************************************************************************************************************************/
|
||||
@ -575,6 +594,17 @@ pgWalName(unsigned int pgVersion)
|
||||
FUNCTION_TEST_RETURN(pgVersion >= PG_VERSION_WAL_RENAME ? PG_NAME_WAL_STR : PG_NAME_XLOG_STR);
|
||||
}
|
||||
|
||||
/**********************************************************************************************************************************/
|
||||
const String *
|
||||
pgXactPath(unsigned int pgVersion)
|
||||
{
|
||||
FUNCTION_TEST_BEGIN();
|
||||
FUNCTION_TEST_PARAM(UINT, pgVersion);
|
||||
FUNCTION_TEST_END();
|
||||
|
||||
FUNCTION_TEST_RETURN(pgVersion >= PG_VERSION_WAL_RENAME ? PG_PATH_PGXACT_STR : PG_PATH_PGCLOG_STR);
|
||||
}
|
||||
|
||||
/***********************************************************************************************************************************
|
||||
Create pg_control for testing
|
||||
***********************************************************************************************************************************/
|
||||
|
@ -105,8 +105,14 @@ PgWal pgWalFromBuffer(const Buffer *walBuffer);
|
||||
// Get the tablespace identifier used to distinguish versions in a tablespace directory, e.g. PG_9.0_201008051
|
||||
String *pgTablespaceId(unsigned int pgVersion);
|
||||
|
||||
// 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);
|
||||
|
||||
const String *pgWalName(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);
|
||||
|
||||
/***********************************************************************************************************************************
|
||||
Test Functions
|
||||
***********************************************************************************************************************************/
|
||||
|
@ -102,8 +102,11 @@ testRun(void)
|
||||
}
|
||||
|
||||
// *****************************************************************************************************************************
|
||||
if (testBegin("pgTablespaceId() and pgWalName()"))
|
||||
if (testBegin("pgLsnName(), pgTablespaceId(), pgWalName(), and pgXactPath()"))
|
||||
{
|
||||
TEST_RESULT_STR(strPtr(pgLsnName(PG_VERSION_96)), "location", "check location name");
|
||||
TEST_RESULT_STR(strPtr(pgLsnName(PG_VERSION_10)), "lsn", "check lsn name");
|
||||
|
||||
TEST_RESULT_STR_Z(pgTablespaceId(PG_VERSION_84), NULL, "check 8.4 tablespace id");
|
||||
TEST_RESULT_STR_Z(pgTablespaceId(PG_VERSION_90), "PG_9.0_201008051", "check 9.0 tablespace id");
|
||||
TEST_RESULT_STR_Z(pgTablespaceId(PG_VERSION_94), "PG_9.4_201409291", "check 9.4 tablespace id");
|
||||
@ -111,6 +114,9 @@ testRun(void)
|
||||
|
||||
TEST_RESULT_STR(strPtr(pgWalName(PG_VERSION_96)), "xlog", "check xlog name");
|
||||
TEST_RESULT_STR(strPtr(pgWalName(PG_VERSION_10)), "wal", "check wal name");
|
||||
|
||||
TEST_RESULT_STR(strPtr(pgXactPath(PG_VERSION_96)), "pg_clog", "check pg_clog name");
|
||||
TEST_RESULT_STR(strPtr(pgXactPath(PG_VERSION_10)), "pg_xact", "check pg_xact name");
|
||||
}
|
||||
|
||||
// *****************************************************************************************************************************
|
||||
|
Reference in New Issue
Block a user