comparison Framework/Common/DatabaseManager.cpp @ 435:326f8304daa1 pg-transactions

new creating temporary tables inside functions
author Alain Mazy <am@osimis.io>
date Thu, 14 Dec 2023 09:25:45 +0100
parents 23c7af6f671a
children cec6a0cd399f
comparison
equal deleted inserted replaced
434:23c7af6f671a 435:326f8304daa1
569 LOG(TRACE) << "Reusing cached statement from " 569 LOG(TRACE) << "Reusing cached statement from "
570 << location_.GetFile() << ":" << location_.GetLine(); 570 << location_.GetFile() << ":" << location_.GetLine();
571 } 571 }
572 } 572 }
573 573
574 574 void DatabaseManager::CachedStatement::ExecuteInternal(const Dictionary& parameters, bool withResults)
575 void DatabaseManager::CachedStatement::Execute(const Dictionary& parameters)
576 { 575 {
577 try 576 try
578 { 577 {
579 std::unique_ptr<Query> query(ReleaseQuery()); 578 std::unique_ptr<Query> query(ReleaseQuery());
580 579
596 boost::lexical_cast<std::string>(location_.GetLine())); 595 boost::lexical_cast<std::string>(location_.GetLine()));
597 OrthancPlugins::MetricsTimer timer(name.c_str()); 596 OrthancPlugins::MetricsTimer timer(name.c_str());
598 #endif 597 #endif
599 */ 598 */
600 599
601 SetResult(GetTransaction().Execute(*statement_, parameters)); 600 if (withResults)
601 {
602 SetResult(GetTransaction().Execute(*statement_, parameters));
603 }
604 else
605 {
606 GetTransaction().ExecuteWithoutResult(*statement_, parameters);
607 }
602 } 608 }
603 catch (Orthanc::OrthancException& e) 609 catch (Orthanc::OrthancException& e)
604 { 610 {
605 GetManager().CloseIfUnavailable(e.GetErrorCode()); 611 GetManager().CloseIfUnavailable(e.GetErrorCode());
606 throw; 612 throw;
607 } 613 }
608 } 614 }
609 615
616
617 void DatabaseManager::CachedStatement::Execute(const Dictionary& parameters)
618 {
619 ExecuteInternal(parameters, true);
620 }
621
622 void DatabaseManager::CachedStatement::ExecuteWithoutResult(const Dictionary& parameters)
623 {
624 ExecuteInternal(parameters, false);
625 }
626
610 627
611 DatabaseManager::StandaloneStatement::StandaloneStatement(DatabaseManager& manager, 628 DatabaseManager::StandaloneStatement::StandaloneStatement(DatabaseManager& manager,
612 const std::string& sql) : 629 const std::string& sql) :
613 StatementBase(manager) 630 StatementBase(manager)
614 { 631 {