You've already forked pgbackrest
mirror of
https://github.com/pgbackrest/pgbackrest.git
synced 2025-06-27 00:21:08 +02:00
Add function to generate PostgreSQL tablespace identifier.
In PostgreSQL >= 9.0 each tablespace data is stored in a specially named directory so different major versions can share the same tablespace path.
This commit is contained in:
@ -513,6 +513,32 @@ pgWalFromFile(const String *walFile)
|
|||||||
FUNCTION_LOG_RETURN(PG_WAL, result);
|
FUNCTION_LOG_RETURN(PG_WAL, result);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**********************************************************************************************************************************/
|
||||||
|
String *
|
||||||
|
pgTablespaceId(unsigned int pgVersion)
|
||||||
|
{
|
||||||
|
FUNCTION_TEST_BEGIN();
|
||||||
|
FUNCTION_TEST_PARAM(UINT, pgVersion);
|
||||||
|
FUNCTION_TEST_END();
|
||||||
|
|
||||||
|
String *result = NULL;
|
||||||
|
|
||||||
|
if (pgVersion >= PG_VERSION_90)
|
||||||
|
{
|
||||||
|
MEM_CONTEXT_TEMP_BEGIN()
|
||||||
|
{
|
||||||
|
String *pgVersionStr = pgVersionToStr(pgVersion);
|
||||||
|
|
||||||
|
memContextSwitch(MEM_CONTEXT_OLD());
|
||||||
|
result = strNewFmt("PG_%s_%u", strPtr(pgVersionStr), pgCatalogVersion(pgVersion));
|
||||||
|
memContextSwitch(MEM_CONTEXT_TEMP());
|
||||||
|
}
|
||||||
|
MEM_CONTEXT_TEMP_END();
|
||||||
|
}
|
||||||
|
|
||||||
|
FUNCTION_TEST_RETURN(result);
|
||||||
|
}
|
||||||
|
|
||||||
/***********************************************************************************************************************************
|
/***********************************************************************************************************************************
|
||||||
Get WAL name (wal/xlog) for a PostgreSQL version
|
Get WAL name (wal/xlog) for a PostgreSQL version
|
||||||
***********************************************************************************************************************************/
|
***********************************************************************************************************************************/
|
||||||
|
@ -81,6 +81,9 @@ String *pgVersionToStr(unsigned int version);
|
|||||||
PgWal pgWalFromFile(const String *walFile);
|
PgWal pgWalFromFile(const String *walFile);
|
||||||
PgWal pgWalFromBuffer(const Buffer *walBuffer);
|
PgWal pgWalFromBuffer(const Buffer *walBuffer);
|
||||||
|
|
||||||
|
// Get the tablespace identifier used to distinguish versions in a tablespace directory, e.g. XXX
|
||||||
|
String *pgTablespaceId(unsigned int pgVersion);
|
||||||
|
|
||||||
const String *pgWalName(unsigned int pgVersion);
|
const String *pgWalName(unsigned int pgVersion);
|
||||||
|
|
||||||
/***********************************************************************************************************************************
|
/***********************************************************************************************************************************
|
||||||
|
@ -103,8 +103,13 @@ testRun(void)
|
|||||||
}
|
}
|
||||||
|
|
||||||
// *****************************************************************************************************************************
|
// *****************************************************************************************************************************
|
||||||
if (testBegin("pgWalName()"))
|
if (testBegin("pgTablespaceId() and pgWalName()"))
|
||||||
{
|
{
|
||||||
|
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");
|
||||||
|
TEST_RESULT_STR_Z(pgTablespaceId(PG_VERSION_11), "PG_11_201809051", "check 11 tablespace id");
|
||||||
|
|
||||||
TEST_RESULT_STR(strPtr(pgWalName(PG_VERSION_96)), "xlog", "check xlog name");
|
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(pgWalName(PG_VERSION_10)), "wal", "check wal name");
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user