Mercurial > hg > orthanc-databases
diff MySQL/Plugins/MySQLIndex.cpp @ 87:48d445f756db db-changes
new extension implemented for MySQL: GetLastChangeIndex
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Thu, 10 Jan 2019 20:39:36 +0100 |
parents | b96446b8718b |
children | 3f31e3fa5114 |
line wrap: on
line diff
--- a/MySQL/Plugins/MySQLIndex.cpp Thu Jan 10 18:04:27 2019 +0100 +++ b/MySQL/Plugins/MySQLIndex.cpp Thu Jan 10 20:39:36 2019 +0100 @@ -128,7 +128,19 @@ SetGlobalIntegerProperty(*db, t, Orthanc::GlobalProperty_DatabasePatchLevel, revision); } - if (revision != 2) + if (revision == 2) + { + std::string query; + + Orthanc::EmbeddedResources::GetFileResource + (query, Orthanc::EmbeddedResources::MYSQL_GET_LAST_CHANGE_INDEX); + db->Execute(query, true); + + revision = 3; + SetGlobalIntegerProperty(*db, t, Orthanc::GlobalProperty_DatabasePatchLevel, revision); + } + + if (revision != 3) { LOG(ERROR) << "MySQL plugin is incompatible with database schema revision: " << revision; throw Orthanc::OrthancException(Orthanc::ErrorCode_Database); @@ -261,4 +273,17 @@ SignalDeletedFiles(); } + + + int64_t MySQLIndex::GetLastChangeIndex() + { + DatabaseManager::CachedStatement statement( + STATEMENT_FROM_HERE, GetManager(), + "SELECT value FROM GlobalIntegers WHERE property = 0"); + + statement.SetReadOnly(true); + statement.Execute(); + + return ReadInteger64(statement, 0); + } }