comparison MySQL/Plugins/MySQLIndex.cpp @ 521:2ab3d45c0b3c large-queries

merge default -> large-queries
author Alain Mazy <am@orthanc.team>
date Thu, 04 Jul 2024 07:44:39 +0200
parents 54d518dcd74a
children 451125122692
comparison
equal deleted inserted replaced
501:594859656a06 521:2ab3d45c0b3c
1 /** 1 /**
2 * Orthanc - A Lightweight, RESTful DICOM Store 2 * Orthanc - A Lightweight, RESTful DICOM Store
3 * Copyright (C) 2012-2016 Sebastien Jodogne, Medical Physics 3 * Copyright (C) 2012-2016 Sebastien Jodogne, Medical Physics
4 * Department, University Hospital of Liege, Belgium 4 * Department, University Hospital of Liege, Belgium
5 * Copyright (C) 2017-2024 Osimis S.A., Belgium 5 * Copyright (C) 2017-2023 Osimis S.A., Belgium
6 * Copyright (C) 2024-2024 Orthanc Team SRL, Belgium
6 * Copyright (C) 2021-2024 Sebastien Jodogne, ICTEAM UCLouvain, Belgium 7 * Copyright (C) 2021-2024 Sebastien Jodogne, ICTEAM UCLouvain, Belgium
7 * 8 *
8 * This program is free software: you can redistribute it and/or 9 * This program is free software: you can redistribute it and/or
9 * modify it under the terms of the GNU Affero General Public License 10 * modify it under the terms of the GNU Affero General Public License
10 * as published by the Free Software Foundation, either version 3 of 11 * as published by the Free Software Foundation, either version 3 of
315 SetGlobalIntegerProperty(manager, MISSING_SERVER_IDENTIFIER, Orthanc::GlobalProperty_DatabasePatchLevel, revision); 316 SetGlobalIntegerProperty(manager, MISSING_SERVER_IDENTIFIER, Orthanc::GlobalProperty_DatabasePatchLevel, revision);
316 317
317 t.Commit(); 318 t.Commit();
318 } 319 }
319 320
320 if (revision != 7) 321 if (revision == 7)
322 {
323 DatabaseManager::Transaction t(manager, TransactionType_ReadWrite);
324
325 // Install the "CreateInstance" extension
326 std::string query;
327
328 Orthanc::EmbeddedResources::GetFileResource
329 (query, Orthanc::EmbeddedResources::MYSQL_DELETE_RESOURCES);
330
331 // Need to escape arobases: Don't use "t.GetDatabaseTransaction().ExecuteMultiLines()" here
332 db.ExecuteMultiLines(query, true);
333
334 revision = 8;
335 SetGlobalIntegerProperty(manager, MISSING_SERVER_IDENTIFIER, Orthanc::GlobalProperty_DatabasePatchLevel, revision);
336
337 t.Commit();
338 }
339
340
341 if (revision != 8)
321 { 342 {
322 LOG(ERROR) << "MySQL plugin is incompatible with database schema revision: " << revision; 343 LOG(ERROR) << "MySQL plugin is incompatible with database schema revision: " << revision;
323 throw Orthanc::OrthancException(Orthanc::ErrorCode_Database); 344 throw Orthanc::OrthancException(Orthanc::ErrorCode_Database);
324 } 345 }
325 } 346 }
469 Dictionary args; 490 Dictionary args;
470 args.SetIntegerValue("id", id); 491 args.SetIntegerValue("id", id);
471 lookupResourcesToDelete.Execute(args); 492 lookupResourcesToDelete.Execute(args);
472 } 493 }
473 494
474 { 495 // {
475 DatabaseManager::CachedStatement deleteHierarchy( 496 // DatabaseManager::CachedStatement deleteHierarchy(
476 STATEMENT_FROM_HERE, manager, 497 // STATEMENT_FROM_HERE, manager,
477 "DELETE FROM Resources WHERE internalId IN (SELECT internalId FROM DeletedResources)"); 498 // "DELETE FROM Resources WHERE internalId IN (SELECT internalId FROM DeletedResources)");
478 deleteHierarchy.Execute(); 499 // deleteHierarchy.Execute();
500 // }
501
502
503 {
504 DatabaseManager::CachedStatement deleteResources(
505 STATEMENT_FROM_HERE, manager,
506 "CALL DeleteResources(${id})");
507
508 deleteResources.SetParameterType("id", ValueType_Integer64);
509
510 Dictionary args;
511 args.SetIntegerValue("id", id);
512
513 deleteResources.Execute(args);
479 } 514 }
480 515
481 SignalDeletedResources(output, manager); 516 SignalDeletedResources(output, manager);
482 SignalDeletedFiles(output, manager); 517 SignalDeletedFiles(output, manager);
483 } 518 }