Mercurial > hg > orthanc-databases
comparison 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 |
comparison
equal
deleted
inserted
replaced
86:d16e94157efe | 87:48d445f756db |
---|---|
126 | 126 |
127 revision = 2; | 127 revision = 2; |
128 SetGlobalIntegerProperty(*db, t, Orthanc::GlobalProperty_DatabasePatchLevel, revision); | 128 SetGlobalIntegerProperty(*db, t, Orthanc::GlobalProperty_DatabasePatchLevel, revision); |
129 } | 129 } |
130 | 130 |
131 if (revision != 2) | 131 if (revision == 2) |
132 { | |
133 std::string query; | |
134 | |
135 Orthanc::EmbeddedResources::GetFileResource | |
136 (query, Orthanc::EmbeddedResources::MYSQL_GET_LAST_CHANGE_INDEX); | |
137 db->Execute(query, true); | |
138 | |
139 revision = 3; | |
140 SetGlobalIntegerProperty(*db, t, Orthanc::GlobalProperty_DatabasePatchLevel, revision); | |
141 } | |
142 | |
143 if (revision != 3) | |
132 { | 144 { |
133 LOG(ERROR) << "MySQL plugin is incompatible with database schema revision: " << revision; | 145 LOG(ERROR) << "MySQL plugin is incompatible with database schema revision: " << revision; |
134 throw Orthanc::OrthancException(Orthanc::ErrorCode_Database); | 146 throw Orthanc::OrthancException(Orthanc::ErrorCode_Database); |
135 } | 147 } |
136 | 148 |
259 deleteHierarchy.Execute(args); | 271 deleteHierarchy.Execute(args); |
260 } | 272 } |
261 | 273 |
262 SignalDeletedFiles(); | 274 SignalDeletedFiles(); |
263 } | 275 } |
276 | |
277 | |
278 int64_t MySQLIndex::GetLastChangeIndex() | |
279 { | |
280 DatabaseManager::CachedStatement statement( | |
281 STATEMENT_FROM_HERE, GetManager(), | |
282 "SELECT value FROM GlobalIntegers WHERE property = 0"); | |
283 | |
284 statement.SetReadOnly(true); | |
285 statement.Execute(); | |
286 | |
287 return ReadInteger64(statement, 0); | |
288 } | |
264 } | 289 } |