comparison OrthancServer/Sources/Database/SQLiteDatabaseWrapper.cpp @ 4607:f75c63aa9de0 db-changes

differentiating between shared and private global properties
author Sebastien Jodogne <s.jodogne@gmail.com>
date Tue, 30 Mar 2021 18:10:27 +0200
parents cc64385593ef
children 95ffe3b6ef7c
comparison
equal deleted inserted replaced
4606:d01702fb29a9 4607:f75c63aa9de0
825 } 825 }
826 } 826 }
827 827
828 828
829 virtual bool LookupGlobalProperty(std::string& target, 829 virtual bool LookupGlobalProperty(std::string& target,
830 GlobalProperty property) ORTHANC_OVERRIDE 830 GlobalProperty property,
831 { 831 bool shared) ORTHANC_OVERRIDE
832 {
833 // The "shared" info is not used by the SQLite database, as it
834 // can only be used by one Orthanc server.
835
832 SQLite::Statement s(db_, SQLITE_FROM_HERE, 836 SQLite::Statement s(db_, SQLITE_FROM_HERE,
833 "SELECT value FROM GlobalProperties WHERE property=?"); 837 "SELECT value FROM GlobalProperties WHERE property=?");
834 s.BindInt(0, property); 838 s.BindInt(0, property);
835 839
836 if (!s.Step()) 840 if (!s.Step())
962 } 966 }
963 } 967 }
964 968
965 969
966 virtual void SetGlobalProperty(GlobalProperty property, 970 virtual void SetGlobalProperty(GlobalProperty property,
971 bool shared,
967 const std::string& value) ORTHANC_OVERRIDE 972 const std::string& value) ORTHANC_OVERRIDE
968 { 973 {
974 // The "shared" info is not used by the SQLite database, as it
975 // can only be used by one Orthanc server.
976
969 SQLite::Statement s(db_, SQLITE_FROM_HERE, "INSERT OR REPLACE INTO GlobalProperties VALUES(?, ?)"); 977 SQLite::Statement s(db_, SQLITE_FROM_HERE, "INSERT OR REPLACE INTO GlobalProperties VALUES(?, ?)");
970 s.BindInt(0, property); 978 s.BindInt(0, property);
971 s.BindString(1, value); 979 s.BindString(1, value);
972 s.Run(); 980 s.Run();
973 } 981 }
1316 db_.Execute(query); 1324 db_.Execute(query);
1317 } 1325 }
1318 1326
1319 // Check the version of the database 1327 // Check the version of the database
1320 std::string tmp; 1328 std::string tmp;
1321 if (!transaction->LookupGlobalProperty(tmp, GlobalProperty_DatabaseSchemaVersion)) 1329 if (!transaction->LookupGlobalProperty(tmp, GlobalProperty_DatabaseSchemaVersion, true /* unused in SQLite */))
1322 { 1330 {
1323 tmp = "Unknown"; 1331 tmp = "Unknown";
1324 } 1332 }
1325 1333
1326 bool ok = false; 1334 bool ok = false;
1341 } 1349 }
1342 1350
1343 // New in Orthanc 1.5.1 1351 // New in Orthanc 1.5.1
1344 if (version_ == 6) 1352 if (version_ == 6)
1345 { 1353 {
1346 if (!transaction->LookupGlobalProperty(tmp, GlobalProperty_GetTotalSizeIsFast) || 1354 if (!transaction->LookupGlobalProperty(tmp, GlobalProperty_GetTotalSizeIsFast, true /* unused in SQLite */) ||
1347 tmp != "1") 1355 tmp != "1")
1348 { 1356 {
1349 LOG(INFO) << "Installing the SQLite triggers to track the size of the attachments"; 1357 LOG(INFO) << "Installing the SQLite triggers to track the size of the attachments";
1350 std::string query; 1358 std::string query;
1351 ServerResources::GetFileResource(query, ServerResources::INSTALL_TRACK_ATTACHMENTS_SIZE); 1359 ServerResources::GetFileResource(query, ServerResources::INSTALL_TRACK_ATTACHMENTS_SIZE);