Mercurial > hg > orthanc-databases
comparison Framework/MySQL/MySQLTransaction.cpp @ 237:35598014f140
refactoring to remove GlobalProperties.cpp
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Thu, 08 Apr 2021 19:09:04 +0200 |
parents | d1b124d116c1 |
children | 16aac0287485 |
comparison
equal
deleted
inserted
replaced
236:d1d2edbbe6fb | 237:35598014f140 |
---|---|
37 active_(false) | 37 active_(false) |
38 { | 38 { |
39 switch (type) | 39 switch (type) |
40 { | 40 { |
41 case TransactionType_ReadWrite: | 41 case TransactionType_ReadWrite: |
42 db_.Execute("START TRANSACTION READ WRITE", false); | 42 db_.ExecuteMultiLines("START TRANSACTION READ WRITE", false); |
43 break; | 43 break; |
44 | 44 |
45 case TransactionType_ReadOnly: | 45 case TransactionType_ReadOnly: |
46 db_.Execute("START TRANSACTION READ ONLY", false); | 46 db_.ExecuteMultiLines("START TRANSACTION READ ONLY", false); |
47 break; | 47 break; |
48 | 48 |
49 default: | 49 default: |
50 throw Orthanc::OrthancException(Orthanc::ErrorCode_ParameterOutOfRange); | 50 throw Orthanc::OrthancException(Orthanc::ErrorCode_ParameterOutOfRange); |
51 } | 51 } |
60 { | 60 { |
61 LOG(INFO) << "An active MySQL transaction was dismissed"; | 61 LOG(INFO) << "An active MySQL transaction was dismissed"; |
62 | 62 |
63 try | 63 try |
64 { | 64 { |
65 db_.Execute("ROLLBACK", false); | 65 db_.ExecuteMultiLines("ROLLBACK", false); |
66 } | 66 } |
67 catch (Orthanc::OrthancException&) | 67 catch (Orthanc::OrthancException&) |
68 { | 68 { |
69 // Ignore possible exceptions due to connection loss | 69 // Ignore possible exceptions due to connection loss |
70 } | 70 } |
74 | 74 |
75 void MySQLTransaction::Rollback() | 75 void MySQLTransaction::Rollback() |
76 { | 76 { |
77 if (active_) | 77 if (active_) |
78 { | 78 { |
79 db_.Execute("ROLLBACK", false); | 79 db_.ExecuteMultiLines("ROLLBACK", false); |
80 active_ = false; | 80 active_ = false; |
81 } | 81 } |
82 else | 82 else |
83 { | 83 { |
84 LOG(ERROR) << "MySQL: This transaction is already finished"; | 84 LOG(ERROR) << "MySQL: This transaction is already finished"; |
89 | 89 |
90 void MySQLTransaction::Commit() | 90 void MySQLTransaction::Commit() |
91 { | 91 { |
92 if (active_) | 92 if (active_) |
93 { | 93 { |
94 db_.Execute("COMMIT", false); | 94 db_.ExecuteMultiLines("COMMIT", false); |
95 active_ = false; | 95 active_ = false; |
96 } | 96 } |
97 else | 97 else |
98 { | 98 { |
99 LOG(ERROR) << "MySQL: This transaction is already finished"; | 99 LOG(ERROR) << "MySQL: This transaction is already finished"; |