1
0
mirror of https://github.com/pgbackrest/pgbackrest.git synced 2025-07-01 00:25:06 +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:
David Steele
2019-09-08 06:53:23 -04:00
parent 051128ed9e
commit d957acb36b
3 changed files with 35 additions and 1 deletions

View File

@ -513,6 +513,32 @@ pgWalFromFile(const String *walFile)
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
***********************************************************************************************************************************/

View File

@ -81,6 +81,9 @@ String *pgVersionToStr(unsigned int version);
PgWal pgWalFromFile(const String *walFile);
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);
/***********************************************************************************************************************************