1
0
mirror of https://github.com/pgbackrest/pgbackrest.git synced 2024-12-14 10:13:05 +02:00

Add Db object getters missed in e4901d50.

dbOpen() loaded the version and data directory but there was no way to get the data externally.

Contributed by Cynthia Shang.
This commit is contained in:
Cynthia Shang 2019-08-21 11:59:51 -04:00 committed by David Steele
parent 27e8235812
commit c4533765fb
3 changed files with 38 additions and 0 deletions

View File

@ -301,6 +301,36 @@ dbMove(Db *this, MemContext *parentNew)
FUNCTION_TEST_RETURN(this); FUNCTION_TEST_RETURN(this);
} }
/***********************************************************************************************************************************
Get pg data path loaded from the data_directory GUC
***********************************************************************************************************************************/
const String *
dbPgDataPath(const Db *this)
{
FUNCTION_TEST_BEGIN();
FUNCTION_TEST_PARAM(DB, this);
FUNCTION_TEST_END();
ASSERT(this != NULL);
FUNCTION_TEST_RETURN(this->pgDataPath);
}
/***********************************************************************************************************************************
Get pg version loaded from the server_version_num GUC
***********************************************************************************************************************************/
unsigned int
dbPgVersion(const Db *this)
{
FUNCTION_TEST_BEGIN();
FUNCTION_TEST_PARAM(DB, this);
FUNCTION_TEST_END();
ASSERT(this != NULL);
FUNCTION_TEST_RETURN(this->pgVersion);
}
/*********************************************************************************************************************************** /***********************************************************************************************************************************
Render as string for logging Render as string for logging
***********************************************************************************************************************************/ ***********************************************************************************************************************************/

View File

@ -33,6 +33,12 @@ void dbClose(Db *this);
Db *dbMove(Db *this, MemContext *parentNew); Db *dbMove(Db *this, MemContext *parentNew);
/***********************************************************************************************************************************
Getters
***********************************************************************************************************************************/
const String *dbPgDataPath(const Db *this);
unsigned int dbPgVersion(const Db *this);
/*********************************************************************************************************************************** /***********************************************************************************************************************************
Destructor Destructor
***********************************************************************************************************************************/ ***********************************************************************************************************************************/

View File

@ -156,6 +156,8 @@ testRun(void)
TEST_RESULT_BOOL(result.primary != NULL, true, " check primary"); TEST_RESULT_BOOL(result.primary != NULL, true, " check primary");
TEST_RESULT_INT(result.standbyId, 0, " check standby id"); TEST_RESULT_INT(result.standbyId, 0, " check standby id");
TEST_RESULT_BOOL(result.standby == NULL, true, " check standby"); TEST_RESULT_BOOL(result.standby == NULL, true, " check standby");
TEST_RESULT_INT(dbPgVersion(result.primary), PG_VERSION_84, " version set");
TEST_RESULT_STR(strPtr(dbPgDataPath(result.primary)), "/pgdata", " path set");
TEST_RESULT_VOID(dbFree(result.primary), "free primary"); TEST_RESULT_VOID(dbFree(result.primary), "free primary");