Mercurial > hg > orthanc-databases
annotate Framework/Common/ImplicitTransaction.cpp @ 415:7e123f047771
LookupResources optimization continued
author | Alain Mazy <am@osimis.io> |
---|---|
date | Thu, 22 Jun 2023 18:07:41 +0200 |
parents | 3d6886f3e5b3 |
children | ecd0b719cff5 |
rev | line source |
---|---|
23
b2ff1cd2907a
handling of implicit transactions in DatabaseManager
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1 /** |
b2ff1cd2907a
handling of implicit transactions in DatabaseManager
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
2 * Orthanc - A Lightweight, RESTful DICOM Store |
b2ff1cd2907a
handling of implicit transactions in DatabaseManager
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
3 * Copyright (C) 2012-2016 Sebastien Jodogne, Medical Physics |
b2ff1cd2907a
handling of implicit transactions in DatabaseManager
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
4 * Department, University Hospital of Liege, Belgium |
389
3d6886f3e5b3
upgrade to year 2023
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
359
diff
changeset
|
5 * Copyright (C) 2017-2023 Osimis S.A., Belgium |
3d6886f3e5b3
upgrade to year 2023
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
359
diff
changeset
|
6 * Copyright (C) 2021-2023 Sebastien Jodogne, ICTEAM UCLouvain, Belgium |
23
b2ff1cd2907a
handling of implicit transactions in DatabaseManager
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
7 * |
b2ff1cd2907a
handling of implicit transactions in DatabaseManager
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
8 * This program is free software: you can redistribute it and/or |
b2ff1cd2907a
handling of implicit transactions in DatabaseManager
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
9 * modify it under the terms of the GNU Affero General Public License |
b2ff1cd2907a
handling of implicit transactions in DatabaseManager
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
10 * as published by the Free Software Foundation, either version 3 of |
b2ff1cd2907a
handling of implicit transactions in DatabaseManager
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
11 * the License, or (at your option) any later version. |
b2ff1cd2907a
handling of implicit transactions in DatabaseManager
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
12 * |
b2ff1cd2907a
handling of implicit transactions in DatabaseManager
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
13 * This program is distributed in the hope that it will be useful, but |
b2ff1cd2907a
handling of implicit transactions in DatabaseManager
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
14 * WITHOUT ANY WARRANTY; without even the implied warranty of |
b2ff1cd2907a
handling of implicit transactions in DatabaseManager
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
b2ff1cd2907a
handling of implicit transactions in DatabaseManager
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
16 * Affero General Public License for more details. |
b2ff1cd2907a
handling of implicit transactions in DatabaseManager
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
17 * |
b2ff1cd2907a
handling of implicit transactions in DatabaseManager
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
18 * You should have received a copy of the GNU Affero General Public License |
b2ff1cd2907a
handling of implicit transactions in DatabaseManager
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
19 * along with this program. If not, see <http://www.gnu.org/licenses/>. |
b2ff1cd2907a
handling of implicit transactions in DatabaseManager
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
20 **/ |
b2ff1cd2907a
handling of implicit transactions in DatabaseManager
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
21 |
b2ff1cd2907a
handling of implicit transactions in DatabaseManager
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
22 |
b2ff1cd2907a
handling of implicit transactions in DatabaseManager
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
23 #include "ImplicitTransaction.h" |
b2ff1cd2907a
handling of implicit transactions in DatabaseManager
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
24 |
157
275e14f57f1e
replacing deprecated std::auto_ptr by std::unique_ptr
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
152
diff
changeset
|
25 #include <Compatibility.h> // For std::unique_ptr<> |
152 | 26 #include <Logging.h> |
27 #include <OrthancException.h> | |
23
b2ff1cd2907a
handling of implicit transactions in DatabaseManager
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
28 |
b2ff1cd2907a
handling of implicit transactions in DatabaseManager
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
29 #include <memory> |
b2ff1cd2907a
handling of implicit transactions in DatabaseManager
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
30 |
b2ff1cd2907a
handling of implicit transactions in DatabaseManager
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
31 namespace OrthancDatabases |
b2ff1cd2907a
handling of implicit transactions in DatabaseManager
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
32 { |
28
c0cb5d2cd696
checks depending on Orthanc version
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
25
diff
changeset
|
33 static bool isErrorOnDoubleExecution_ = false; |
c0cb5d2cd696
checks depending on Orthanc version
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
25
diff
changeset
|
34 |
c0cb5d2cd696
checks depending on Orthanc version
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
25
diff
changeset
|
35 |
23
b2ff1cd2907a
handling of implicit transactions in DatabaseManager
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
36 ImplicitTransaction::ImplicitTransaction() : |
214
ab96698c73a3
removed useless information about read-only in ITransaction and IPrecompiledStatement
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
193
diff
changeset
|
37 state_(State_Ready) |
23
b2ff1cd2907a
handling of implicit transactions in DatabaseManager
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
38 { |
b2ff1cd2907a
handling of implicit transactions in DatabaseManager
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
39 } |
b2ff1cd2907a
handling of implicit transactions in DatabaseManager
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
40 |
b2ff1cd2907a
handling of implicit transactions in DatabaseManager
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
41 |
b2ff1cd2907a
handling of implicit transactions in DatabaseManager
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
42 ImplicitTransaction::~ImplicitTransaction() |
b2ff1cd2907a
handling of implicit transactions in DatabaseManager
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
43 { |
b2ff1cd2907a
handling of implicit transactions in DatabaseManager
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
44 switch (state_) |
b2ff1cd2907a
handling of implicit transactions in DatabaseManager
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
45 { |
b2ff1cd2907a
handling of implicit transactions in DatabaseManager
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
46 case State_Committed: |
b2ff1cd2907a
handling of implicit transactions in DatabaseManager
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
47 case State_Ready: |
b2ff1cd2907a
handling of implicit transactions in DatabaseManager
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
48 break; |
b2ff1cd2907a
handling of implicit transactions in DatabaseManager
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
49 |
b2ff1cd2907a
handling of implicit transactions in DatabaseManager
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
50 case State_Executed: |
b2ff1cd2907a
handling of implicit transactions in DatabaseManager
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
51 LOG(ERROR) << "An implicit transaction has not been committed"; |
b2ff1cd2907a
handling of implicit transactions in DatabaseManager
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
52 break; |
b2ff1cd2907a
handling of implicit transactions in DatabaseManager
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
53 |
b2ff1cd2907a
handling of implicit transactions in DatabaseManager
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
54 default: |
25 | 55 LOG(ERROR) << "Internal error in ImplicitTransaction destructor"; |
56 break; | |
23
b2ff1cd2907a
handling of implicit transactions in DatabaseManager
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
57 } |
b2ff1cd2907a
handling of implicit transactions in DatabaseManager
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
58 } |
b2ff1cd2907a
handling of implicit transactions in DatabaseManager
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
59 |
b2ff1cd2907a
handling of implicit transactions in DatabaseManager
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
60 |
b2ff1cd2907a
handling of implicit transactions in DatabaseManager
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
61 void ImplicitTransaction::Rollback() |
b2ff1cd2907a
handling of implicit transactions in DatabaseManager
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
62 { |
b2ff1cd2907a
handling of implicit transactions in DatabaseManager
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
63 LOG(ERROR) << "Cannot rollback an implicit transaction"; |
b2ff1cd2907a
handling of implicit transactions in DatabaseManager
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
64 throw Orthanc::OrthancException(Orthanc::ErrorCode_BadSequenceOfCalls); |
b2ff1cd2907a
handling of implicit transactions in DatabaseManager
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
65 } |
b2ff1cd2907a
handling of implicit transactions in DatabaseManager
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
66 |
b2ff1cd2907a
handling of implicit transactions in DatabaseManager
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
67 |
b2ff1cd2907a
handling of implicit transactions in DatabaseManager
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
68 void ImplicitTransaction::Commit() |
b2ff1cd2907a
handling of implicit transactions in DatabaseManager
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
69 { |
b2ff1cd2907a
handling of implicit transactions in DatabaseManager
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
70 switch (state_) |
b2ff1cd2907a
handling of implicit transactions in DatabaseManager
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
71 { |
b2ff1cd2907a
handling of implicit transactions in DatabaseManager
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
72 case State_Ready: |
b2ff1cd2907a
handling of implicit transactions in DatabaseManager
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
73 LOG(ERROR) << "Cannot commit an implicit transaction that has not been executed yet"; |
b2ff1cd2907a
handling of implicit transactions in DatabaseManager
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
74 throw Orthanc::OrthancException(Orthanc::ErrorCode_BadSequenceOfCalls); |
b2ff1cd2907a
handling of implicit transactions in DatabaseManager
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
75 |
b2ff1cd2907a
handling of implicit transactions in DatabaseManager
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
76 case State_Executed: |
b2ff1cd2907a
handling of implicit transactions in DatabaseManager
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
77 state_ = State_Committed; |
b2ff1cd2907a
handling of implicit transactions in DatabaseManager
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
78 break; |
b2ff1cd2907a
handling of implicit transactions in DatabaseManager
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
79 |
b2ff1cd2907a
handling of implicit transactions in DatabaseManager
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
80 case State_Committed: |
b2ff1cd2907a
handling of implicit transactions in DatabaseManager
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
81 LOG(ERROR) << "Cannot commit twice an implicit transaction"; |
b2ff1cd2907a
handling of implicit transactions in DatabaseManager
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
82 throw Orthanc::OrthancException(Orthanc::ErrorCode_BadSequenceOfCalls); |
b2ff1cd2907a
handling of implicit transactions in DatabaseManager
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
83 |
b2ff1cd2907a
handling of implicit transactions in DatabaseManager
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
84 default: |
b2ff1cd2907a
handling of implicit transactions in DatabaseManager
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
85 throw Orthanc::OrthancException(Orthanc::ErrorCode_InternalError); |
b2ff1cd2907a
handling of implicit transactions in DatabaseManager
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
86 } |
b2ff1cd2907a
handling of implicit transactions in DatabaseManager
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
87 } |
b2ff1cd2907a
handling of implicit transactions in DatabaseManager
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
88 |
b2ff1cd2907a
handling of implicit transactions in DatabaseManager
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
89 |
b2ff1cd2907a
handling of implicit transactions in DatabaseManager
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
90 void ImplicitTransaction::CheckStateForExecution() |
b2ff1cd2907a
handling of implicit transactions in DatabaseManager
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
91 { |
b2ff1cd2907a
handling of implicit transactions in DatabaseManager
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
92 switch (state_) |
b2ff1cd2907a
handling of implicit transactions in DatabaseManager
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
93 { |
b2ff1cd2907a
handling of implicit transactions in DatabaseManager
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
94 case State_Ready: |
b2ff1cd2907a
handling of implicit transactions in DatabaseManager
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
95 // OK |
b2ff1cd2907a
handling of implicit transactions in DatabaseManager
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
96 break; |
b2ff1cd2907a
handling of implicit transactions in DatabaseManager
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
97 |
b2ff1cd2907a
handling of implicit transactions in DatabaseManager
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
98 case State_Executed: |
28
c0cb5d2cd696
checks depending on Orthanc version
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
25
diff
changeset
|
99 if (isErrorOnDoubleExecution_) |
c0cb5d2cd696
checks depending on Orthanc version
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
25
diff
changeset
|
100 { |
c0cb5d2cd696
checks depending on Orthanc version
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
25
diff
changeset
|
101 /** |
c0cb5d2cd696
checks depending on Orthanc version
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
25
diff
changeset
|
102 * This allows to detect errors wrt. the handling of |
c0cb5d2cd696
checks depending on Orthanc version
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
25
diff
changeset
|
103 * transactions in the Orthanc core. |
c0cb5d2cd696
checks depending on Orthanc version
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
25
diff
changeset
|
104 * |
c0cb5d2cd696
checks depending on Orthanc version
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
25
diff
changeset
|
105 * In Orthanc <= 1.3.2: problems in "/changes" (a transaction |
c0cb5d2cd696
checks depending on Orthanc version
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
25
diff
changeset
|
106 * was missing because of GetPublicId()). |
c0cb5d2cd696
checks depending on Orthanc version
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
25
diff
changeset
|
107 **/ |
c0cb5d2cd696
checks depending on Orthanc version
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
25
diff
changeset
|
108 LOG(ERROR) << "Cannot execute more than one statement in an implicit transaction"; |
c0cb5d2cd696
checks depending on Orthanc version
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
25
diff
changeset
|
109 throw Orthanc::OrthancException(Orthanc::ErrorCode_BadSequenceOfCalls); |
c0cb5d2cd696
checks depending on Orthanc version
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
25
diff
changeset
|
110 } |
c0cb5d2cd696
checks depending on Orthanc version
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
25
diff
changeset
|
111 |
23
b2ff1cd2907a
handling of implicit transactions in DatabaseManager
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
112 break; |
28
c0cb5d2cd696
checks depending on Orthanc version
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
25
diff
changeset
|
113 |
23
b2ff1cd2907a
handling of implicit transactions in DatabaseManager
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
114 case State_Committed: |
b2ff1cd2907a
handling of implicit transactions in DatabaseManager
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
115 LOG(ERROR) << "Cannot commit twice an implicit transaction"; |
b2ff1cd2907a
handling of implicit transactions in DatabaseManager
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
116 throw Orthanc::OrthancException(Orthanc::ErrorCode_BadSequenceOfCalls); |
b2ff1cd2907a
handling of implicit transactions in DatabaseManager
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
117 |
b2ff1cd2907a
handling of implicit transactions in DatabaseManager
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
118 default: |
b2ff1cd2907a
handling of implicit transactions in DatabaseManager
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
119 throw Orthanc::OrthancException(Orthanc::ErrorCode_InternalError); |
b2ff1cd2907a
handling of implicit transactions in DatabaseManager
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
120 } |
b2ff1cd2907a
handling of implicit transactions in DatabaseManager
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
121 } |
b2ff1cd2907a
handling of implicit transactions in DatabaseManager
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
122 |
b2ff1cd2907a
handling of implicit transactions in DatabaseManager
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
123 |
b2ff1cd2907a
handling of implicit transactions in DatabaseManager
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
124 IResult* ImplicitTransaction::Execute(IPrecompiledStatement& statement, |
b2ff1cd2907a
handling of implicit transactions in DatabaseManager
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
125 const Dictionary& parameters) |
b2ff1cd2907a
handling of implicit transactions in DatabaseManager
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
126 { |
b2ff1cd2907a
handling of implicit transactions in DatabaseManager
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
127 CheckStateForExecution(); |
157
275e14f57f1e
replacing deprecated std::auto_ptr by std::unique_ptr
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
152
diff
changeset
|
128 std::unique_ptr<IResult> result(ExecuteInternal(statement, parameters)); |
23
b2ff1cd2907a
handling of implicit transactions in DatabaseManager
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
129 |
b2ff1cd2907a
handling of implicit transactions in DatabaseManager
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
130 state_ = State_Executed; |
b2ff1cd2907a
handling of implicit transactions in DatabaseManager
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
131 return result.release(); |
b2ff1cd2907a
handling of implicit transactions in DatabaseManager
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
132 } |
b2ff1cd2907a
handling of implicit transactions in DatabaseManager
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
133 |
b2ff1cd2907a
handling of implicit transactions in DatabaseManager
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
134 |
b2ff1cd2907a
handling of implicit transactions in DatabaseManager
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
135 void ImplicitTransaction::ExecuteWithoutResult(IPrecompiledStatement& statement, |
b2ff1cd2907a
handling of implicit transactions in DatabaseManager
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
136 const Dictionary& parameters) |
b2ff1cd2907a
handling of implicit transactions in DatabaseManager
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
137 { |
b2ff1cd2907a
handling of implicit transactions in DatabaseManager
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
138 CheckStateForExecution(); |
b2ff1cd2907a
handling of implicit transactions in DatabaseManager
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
139 ExecuteWithoutResultInternal(statement, parameters); |
b2ff1cd2907a
handling of implicit transactions in DatabaseManager
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
140 |
b2ff1cd2907a
handling of implicit transactions in DatabaseManager
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
141 state_ = State_Executed; |
b2ff1cd2907a
handling of implicit transactions in DatabaseManager
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
142 } |
28
c0cb5d2cd696
checks depending on Orthanc version
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
25
diff
changeset
|
143 |
c0cb5d2cd696
checks depending on Orthanc version
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
25
diff
changeset
|
144 |
c0cb5d2cd696
checks depending on Orthanc version
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
25
diff
changeset
|
145 void ImplicitTransaction::SetErrorOnDoubleExecution(bool isError) |
c0cb5d2cd696
checks depending on Orthanc version
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
25
diff
changeset
|
146 { |
c0cb5d2cd696
checks depending on Orthanc version
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
25
diff
changeset
|
147 isErrorOnDoubleExecution_ = isError; |
c0cb5d2cd696
checks depending on Orthanc version
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
25
diff
changeset
|
148 } |
c0cb5d2cd696
checks depending on Orthanc version
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
25
diff
changeset
|
149 |
c0cb5d2cd696
checks depending on Orthanc version
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
25
diff
changeset
|
150 |
c0cb5d2cd696
checks depending on Orthanc version
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
25
diff
changeset
|
151 bool ImplicitTransaction::IsErrorOnDoubleExecution() |
c0cb5d2cd696
checks depending on Orthanc version
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
25
diff
changeset
|
152 { |
c0cb5d2cd696
checks depending on Orthanc version
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
25
diff
changeset
|
153 return isErrorOnDoubleExecution_; |
c0cb5d2cd696
checks depending on Orthanc version
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
25
diff
changeset
|
154 } |
23
b2ff1cd2907a
handling of implicit transactions in DatabaseManager
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
155 } |
b2ff1cd2907a
handling of implicit transactions in DatabaseManager
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
156 |