From 350bfdb5ea9b4f7e50746c50a46d8032cbc5a104 Mon Sep 17 00:00:00 2001 From: Kelly Rauchenberger Date: Wed, 8 Nov 2017 14:53:26 -0500 Subject: Created database versioning system Also added an ANALYZE statement to the end of the datafile generation process. This generates information that allows sqlite to sometimes come up with a better query plan, and in many cases can significant speed up queries. This constitutes a minor database update, but because this is the first version that uses the database versioning system, older versions are essentially incompatible. refs #2 --- lib/database.h | 44 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 44 insertions(+) (limited to 'lib/database.h') diff --git a/lib/database.h b/lib/database.h index ef5ff87..efb54e1 100644 --- a/lib/database.h +++ b/lib/database.h @@ -3,6 +3,7 @@ #include #include +#include #include #include #include "notion.h" @@ -45,6 +46,18 @@ namespace verbly { ~database(); + // Information + + int getMajorVersion() const + { + return major_; + } + + int getMinorVersion() const + { + return minor_; + } + // Queries query notions(filter where, order sortOrder = {}, int limit = 1) const; @@ -69,6 +82,37 @@ namespace verbly { sqlite3* ppdb_ = nullptr; + int major_; + int minor_; + + }; + + class database_version_mismatch : public std::logic_error { + public: + + database_version_mismatch(int right, int wrong) : + std::logic_error(generateMessage(right, wrong)), + right_(right), + wrong_(wrong) + { + } + + int getRightVersion() const noexcept + { + return right_; + } + + int getWrongVersion() const noexcept + { + return wrong_; + } + + private: + + static std::string generateMessage(int right, int wrong); + + int right_; + int wrong_; }; }; -- cgit 1.4.1