From 4f7ad3f9855cf62649c40d912e6c3a6a2b777913 Mon Sep 17 00:00:00 2001 From: Jonas Wielicki Date: Tue, 28 Nov 2017 18:52:56 +0100 Subject: Support for full postgresql URIs (cf. https://www.postgresql.org/docs/9.4/static/libpq-connect.html#LIBPQ-CONNSTRING) --- src/database/database.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/database') diff --git a/src/database/database.cpp b/src/database/database.cpp index b1a5ba5..19e9988 100644 --- a/src/database/database.cpp +++ b/src/database/database.cpp @@ -37,7 +37,7 @@ void Database::open(const std::string& filename) std::unique_ptr new_db; static const auto psql_prefix = "postgresql://"s; if (filename.substr(0, psql_prefix.size()) == psql_prefix) - new_db = PostgresqlEngine::open("dbname="s + filename.substr(psql_prefix.size())); + new_db = PostgresqlEngine::open(filename); else new_db = Sqlite3Engine::open(filename); if (!new_db) -- cgit v1.2.3 From 14dcc57a19229dfaf878e07229e8f3e66857a75d Mon Sep 17 00:00:00 2001 From: Jonas Wielicki Date: Tue, 28 Nov 2017 18:53:16 +0100 Subject: Make destructor of Statement virtual I got an ASAN error otherwise (type mismatch) --- src/database/statement.hpp | 1 + 1 file changed, 1 insertion(+) (limited to 'src/database') diff --git a/src/database/statement.hpp b/src/database/statement.hpp index db5f31b..4a61928 100644 --- a/src/database/statement.hpp +++ b/src/database/statement.hpp @@ -14,6 +14,7 @@ enum class StepResult class Statement { public: + virtual ~Statement() = default; virtual StepResult step() = 0; virtual void bind(std::vector params) = 0; -- cgit v1.2.3 From 58f78f31e65e8628bb14722eb8b4b42a558cd0e0 Mon Sep 17 00:00:00 2001 From: Jonas Wielicki Date: Tue, 28 Nov 2017 20:38:29 +0100 Subject: Make destructor of DatabaseEngine virtual --- src/database/engine.hpp | 1 + 1 file changed, 1 insertion(+) (limited to 'src/database') diff --git a/src/database/engine.hpp b/src/database/engine.hpp index 2dd4c21..41dccf5 100644 --- a/src/database/engine.hpp +++ b/src/database/engine.hpp @@ -20,6 +20,7 @@ class DatabaseEngine public: DatabaseEngine() = default; + virtual ~DatabaseEngine() = default; DatabaseEngine(const DatabaseEngine&) = delete; DatabaseEngine& operator=(const DatabaseEngine&) = delete; -- cgit v1.2.3 From e1c7a6518a1aeaac1786c321aee35bd5e20acf6f Mon Sep 17 00:00:00 2001 From: Jonas Wielicki Date: Wed, 29 Nov 2017 08:03:23 +0100 Subject: Actually free the database on Database::close() .release() returns the pointer and releases ownership *without* destruction. --- src/database/database.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/database') diff --git a/src/database/database.cpp b/src/database/database.cpp index 19e9988..f9a365d 100644 --- a/src/database/database.cpp +++ b/src/database/database.cpp @@ -242,7 +242,7 @@ std::vector Database::get_full_roster() void Database::close() { - Database::db.release(); + Database::db = nullptr; } std::string Database::gen_uuid() -- cgit v1.2.3