comparison PostgreSQL/Plugins/PostgreSQLIndex.cpp @ 432:8b7c1c423367 pg-transactions

new 'TransactionMode' config + rewrote ResourceDeletedFunc to avoid IF/THEN/ELSE pattern
author Alain Mazy <am@osimis.io>
date Mon, 11 Dec 2023 14:39:27 +0100
parents 7c1fe5d6c12c
children 5964ce6385a5
comparison
equal deleted inserted replaced
431:7c1fe5d6c12c 432:8b7c1c423367
140 140
141 revision = 2; 141 revision = 2;
142 SetGlobalIntegerProperty(manager, MISSING_SERVER_IDENTIFIER, Orthanc::GlobalProperty_DatabasePatchLevel, revision); 142 SetGlobalIntegerProperty(manager, MISSING_SERVER_IDENTIFIER, Orthanc::GlobalProperty_DatabasePatchLevel, revision);
143 } 143 }
144 144
145 if (revision != 2) 145 if (revision == 2)
146 {
147 LOG(WARNING) << "PostgreSQL plugin: adding or replacing ResourceDeletedFunc";
148
149 std::string query;
150 Orthanc::EmbeddedResources::GetFileResource
151 (query, Orthanc::EmbeddedResources::POSTGRESQL_RESOURCE_DELETED_FUNC);
152 t.GetDatabaseTransaction().ExecuteMultiLines(query);
153
154 revision = 3;
155 SetGlobalIntegerProperty(manager, MISSING_SERVER_IDENTIFIER, Orthanc::GlobalProperty_DatabasePatchLevel, revision);
156 }
157
158 if (revision != 3)
146 { 159 {
147 LOG(ERROR) << "PostgreSQL plugin is incompatible with database schema revision: " << revision; 160 LOG(ERROR) << "PostgreSQL plugin is incompatible with database schema revision: " << revision;
148 throw Orthanc::OrthancException(Orthanc::ErrorCode_Database); 161 throw Orthanc::OrthancException(Orthanc::ErrorCode_Database);
149 } 162 }
150 163
487 for (size_t i = 0; i < 8; i++) 500 for (size_t i = 0; i < 8; i++)
488 { 501 {
489 statement.SetResultFieldType(i, ValueType_Integer64); 502 statement.SetResultFieldType(i, ValueType_Integer64);
490 } 503 }
491 504
505 // LOG(INFO) << statement.ReadInteger64(0) << statement.ReadInteger64(1) << statement.ReadInteger64(2) << statement.ReadInteger64(3);
506
492 result.isNewInstance = (statement.ReadInteger64(3) == 1); 507 result.isNewInstance = (statement.ReadInteger64(3) == 1);
493 result.instanceId = statement.ReadInteger64(7); 508 result.instanceId = statement.ReadInteger64(7);
494 509
495 if (result.isNewInstance) 510 if (result.isNewInstance)
496 { 511 {