pgbackrest.git / summary / log / commit / refs
commit c4533765fb5cd4b72f9fcb27f53db2a30165b9b2
Author: Cynthia Shang <cynthia.shang@crunchydata.com>
Commit: David Steele <david@crunchydata.com>
Date: Wed Aug 21 15:59:51 2019 +0000
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.
src/db/db.c | 30 ++++++++++++++++++++++++++++++
src/db/db.h | 6 ++++++
test/src/module/db/dbTest.c | 2 ++
3 files changed, 38 insertions(+)
diff --git a/src/db/db.c b/src/db/db.c
index 1e0d67c3c..5c68110f5 100644
--- a/src/db/db.c
+++ b/src/db/db.c
@@ -301,6 +301,36 @@ dbMove(Db *this, MemContext *parentNew)
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
***********************************************************************************************************************************/
diff --git a/src/db/db.h b/src/db/db.h
index e7b1dd4dc..06a4e291b 100644
--- a/src/db/db.h
+++ b/src/db/db.h
@@ -33,6 +33,12 @@ void dbClose(Db *this);
Db *dbMove(Db *this, MemContext *parentNew);
+/***********************************************************************************************************************************
+Getters
+***********************************************************************************************************************************/
+const String *dbPgDataPath(const Db *this);
+unsigned int dbPgVersion(const Db *this);
+
/***********************************************************************************************************************************
Destructor
***********************************************************************************************************************************/
diff --git a/test/src/module/db/dbTest.c b/test/src/module/db/dbTest.c
index f32c304a4..164128b43 100644
--- a/test/src/module/db/dbTest.c
+++ b/test/src/module/db/dbTest.c
@@ -156,6 +156,8 @@ testRun(void)
TEST_RESULT_BOOL(result.primary != NULL, true, " check primary");
TEST_RESULT_INT(result.standbyId, 0, " check standby id");
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");
[parent: 27e823581201]