Mercurial > hg > orthanc-databases
annotate Framework/Common/ImplicitTransaction.cpp @ 152:063aa53b5917
sync
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Wed, 01 Jul 2020 08:54:32 +0200 |
parents | 4cd7e45b671e |
children | 275e14f57f1e |
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 |
140
4cd7e45b671e
upgrade to year 2020
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
67
diff
changeset
|
5 * Copyright (C) 2017-2020 Osimis S.A., Belgium |
23
b2ff1cd2907a
handling of implicit transactions in DatabaseManager
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
6 * |
b2ff1cd2907a
handling of implicit transactions in DatabaseManager
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
7 * 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
|
8 * 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
|
9 * 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
|
10 * 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
|
11 * |
b2ff1cd2907a
handling of implicit transactions in DatabaseManager
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
12 * 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
|
13 * 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
|
14 * 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
|
15 * Affero General Public License for more details. |
b2ff1cd2907a
handling of implicit transactions in DatabaseManager
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
16 * |
b2ff1cd2907a
handling of implicit transactions in DatabaseManager
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
17 * 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
|
18 * 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
|
19 **/ |
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 #include "ImplicitTransaction.h" |
b2ff1cd2907a
handling of implicit transactions in DatabaseManager
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
23 |
152 | 24 #include <Logging.h> |
25 #include <OrthancException.h> | |
23
b2ff1cd2907a
handling of implicit transactions in DatabaseManager
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
26 |
b2ff1cd2907a
handling of implicit transactions in DatabaseManager
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
27 #include <memory> |
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 namespace OrthancDatabases |
b2ff1cd2907a
handling of implicit transactions in DatabaseManager
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
30 { |
28
c0cb5d2cd696
checks depending on Orthanc version
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
25
diff
changeset
|
31 static bool isErrorOnDoubleExecution_ = false; |
c0cb5d2cd696
checks depending on Orthanc version
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
25
diff
changeset
|
32 |
c0cb5d2cd696
checks depending on Orthanc version
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
25
diff
changeset
|
33 |
23
b2ff1cd2907a
handling of implicit transactions in DatabaseManager
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
34 ImplicitTransaction::ImplicitTransaction() : |
b2ff1cd2907a
handling of implicit transactions in DatabaseManager
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
35 state_(State_Ready), |
b2ff1cd2907a
handling of implicit transactions in DatabaseManager
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
36 readOnly_(true) |
b2ff1cd2907a
handling of implicit transactions in DatabaseManager
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
37 { |
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 ImplicitTransaction::~ImplicitTransaction() |
b2ff1cd2907a
handling of implicit transactions in DatabaseManager
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
42 { |
b2ff1cd2907a
handling of implicit transactions in DatabaseManager
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
43 switch (state_) |
b2ff1cd2907a
handling of implicit transactions in DatabaseManager
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
44 { |
b2ff1cd2907a
handling of implicit transactions in DatabaseManager
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
45 case State_Committed: |
b2ff1cd2907a
handling of implicit transactions in DatabaseManager
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
46 case State_Ready: |
b2ff1cd2907a
handling of implicit transactions in DatabaseManager
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
47 break; |
b2ff1cd2907a
handling of implicit transactions in DatabaseManager
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
48 |
b2ff1cd2907a
handling of implicit transactions in DatabaseManager
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
49 case State_Executed: |
b2ff1cd2907a
handling of implicit transactions in DatabaseManager
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
50 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
|
51 break; |
b2ff1cd2907a
handling of implicit transactions in DatabaseManager
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
52 |
b2ff1cd2907a
handling of implicit transactions in DatabaseManager
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
53 default: |
25 | 54 LOG(ERROR) << "Internal error in ImplicitTransaction destructor"; |
55 break; | |
23
b2ff1cd2907a
handling of implicit transactions in DatabaseManager
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
56 } |
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 void ImplicitTransaction::Rollback() |
b2ff1cd2907a
handling of implicit transactions in DatabaseManager
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
61 { |
b2ff1cd2907a
handling of implicit transactions in DatabaseManager
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
62 LOG(ERROR) << "Cannot rollback an implicit transaction"; |
b2ff1cd2907a
handling of implicit transactions in DatabaseManager
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
63 throw Orthanc::OrthancException(Orthanc::ErrorCode_BadSequenceOfCalls); |
b2ff1cd2907a
handling of implicit transactions in DatabaseManager
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
64 } |
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 void ImplicitTransaction::Commit() |
b2ff1cd2907a
handling of implicit transactions in DatabaseManager
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
68 { |
b2ff1cd2907a
handling of implicit transactions in DatabaseManager
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
69 switch (state_) |
b2ff1cd2907a
handling of implicit transactions in DatabaseManager
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
70 { |
b2ff1cd2907a
handling of implicit transactions in DatabaseManager
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
71 case State_Ready: |
b2ff1cd2907a
handling of implicit transactions in DatabaseManager
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
72 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
|
73 throw Orthanc::OrthancException(Orthanc::ErrorCode_BadSequenceOfCalls); |
b2ff1cd2907a
handling of implicit transactions in DatabaseManager
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
74 |
b2ff1cd2907a
handling of implicit transactions in DatabaseManager
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
75 case State_Executed: |
b2ff1cd2907a
handling of implicit transactions in DatabaseManager
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
76 state_ = State_Committed; |
b2ff1cd2907a
handling of implicit transactions in DatabaseManager
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
77 break; |
b2ff1cd2907a
handling of implicit transactions in DatabaseManager
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
78 |
b2ff1cd2907a
handling of implicit transactions in DatabaseManager
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
79 case State_Committed: |
b2ff1cd2907a
handling of implicit transactions in DatabaseManager
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
80 LOG(ERROR) << "Cannot commit twice an implicit transaction"; |
b2ff1cd2907a
handling of implicit transactions in DatabaseManager
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
81 throw Orthanc::OrthancException(Orthanc::ErrorCode_BadSequenceOfCalls); |
b2ff1cd2907a
handling of implicit transactions in DatabaseManager
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
82 |
b2ff1cd2907a
handling of implicit transactions in DatabaseManager
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
83 default: |
b2ff1cd2907a
handling of implicit transactions in DatabaseManager
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
84 throw Orthanc::OrthancException(Orthanc::ErrorCode_InternalError); |
b2ff1cd2907a
handling of implicit transactions in DatabaseManager
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
85 } |
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 void ImplicitTransaction::CheckStateForExecution() |
b2ff1cd2907a
handling of implicit transactions in DatabaseManager
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
90 { |
b2ff1cd2907a
handling of implicit transactions in DatabaseManager
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
91 switch (state_) |
b2ff1cd2907a
handling of implicit transactions in DatabaseManager
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
92 { |
b2ff1cd2907a
handling of implicit transactions in DatabaseManager
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
93 case State_Ready: |
b2ff1cd2907a
handling of implicit transactions in DatabaseManager
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
94 // OK |
b2ff1cd2907a
handling of implicit transactions in DatabaseManager
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
95 break; |
b2ff1cd2907a
handling of implicit transactions in DatabaseManager
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
96 |
b2ff1cd2907a
handling of implicit transactions in DatabaseManager
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
97 case State_Executed: |
28
c0cb5d2cd696
checks depending on Orthanc version
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
25
diff
changeset
|
98 if (isErrorOnDoubleExecution_) |
c0cb5d2cd696
checks depending on Orthanc version
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
25
diff
changeset
|
99 { |
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 * 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
|
102 * transactions in the Orthanc core. |
c0cb5d2cd696
checks depending on Orthanc version
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
25
diff
changeset
|
103 * |
c0cb5d2cd696
checks depending on Orthanc version
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
25
diff
changeset
|
104 * 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
|
105 * was missing because of GetPublicId()). |
c0cb5d2cd696
checks depending on Orthanc version
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
25
diff
changeset
|
106 **/ |
c0cb5d2cd696
checks depending on Orthanc version
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
25
diff
changeset
|
107 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
|
108 throw Orthanc::OrthancException(Orthanc::ErrorCode_BadSequenceOfCalls); |
c0cb5d2cd696
checks depending on Orthanc version
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
25
diff
changeset
|
109 } |
c0cb5d2cd696
checks depending on Orthanc version
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
25
diff
changeset
|
110 |
23
b2ff1cd2907a
handling of implicit transactions in DatabaseManager
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
111 break; |
28
c0cb5d2cd696
checks depending on Orthanc version
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
25
diff
changeset
|
112 |
23
b2ff1cd2907a
handling of implicit transactions in DatabaseManager
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
113 case State_Committed: |
b2ff1cd2907a
handling of implicit transactions in DatabaseManager
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
114 LOG(ERROR) << "Cannot commit twice an implicit transaction"; |
b2ff1cd2907a
handling of implicit transactions in DatabaseManager
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
115 throw Orthanc::OrthancException(Orthanc::ErrorCode_BadSequenceOfCalls); |
b2ff1cd2907a
handling of implicit transactions in DatabaseManager
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
116 |
b2ff1cd2907a
handling of implicit transactions in DatabaseManager
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
117 default: |
b2ff1cd2907a
handling of implicit transactions in DatabaseManager
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
118 throw Orthanc::OrthancException(Orthanc::ErrorCode_InternalError); |
b2ff1cd2907a
handling of implicit transactions in DatabaseManager
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
119 } |
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 IResult* ImplicitTransaction::Execute(IPrecompiledStatement& statement, |
b2ff1cd2907a
handling of implicit transactions in DatabaseManager
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
124 const Dictionary& parameters) |
b2ff1cd2907a
handling of implicit transactions in DatabaseManager
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
125 { |
b2ff1cd2907a
handling of implicit transactions in DatabaseManager
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
126 CheckStateForExecution(); |
b2ff1cd2907a
handling of implicit transactions in DatabaseManager
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
127 std::auto_ptr<IResult> result(ExecuteInternal(statement, parameters)); |
b2ff1cd2907a
handling of implicit transactions in DatabaseManager
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
128 |
b2ff1cd2907a
handling of implicit transactions in DatabaseManager
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
129 if (!statement.IsReadOnly()) |
b2ff1cd2907a
handling of implicit transactions in DatabaseManager
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
130 { |
b2ff1cd2907a
handling of implicit transactions in DatabaseManager
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
131 readOnly_ = false; |
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 state_ = State_Executed; |
b2ff1cd2907a
handling of implicit transactions in DatabaseManager
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
135 return result.release(); |
b2ff1cd2907a
handling of implicit transactions in DatabaseManager
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
136 } |
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 |
b2ff1cd2907a
handling of implicit transactions in DatabaseManager
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
139 void ImplicitTransaction::ExecuteWithoutResult(IPrecompiledStatement& statement, |
b2ff1cd2907a
handling of implicit transactions in DatabaseManager
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
140 const Dictionary& parameters) |
b2ff1cd2907a
handling of implicit transactions in DatabaseManager
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
141 { |
b2ff1cd2907a
handling of implicit transactions in DatabaseManager
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
142 CheckStateForExecution(); |
b2ff1cd2907a
handling of implicit transactions in DatabaseManager
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
143 ExecuteWithoutResultInternal(statement, parameters); |
b2ff1cd2907a
handling of implicit transactions in DatabaseManager
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
144 |
b2ff1cd2907a
handling of implicit transactions in DatabaseManager
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
145 if (!statement.IsReadOnly()) |
b2ff1cd2907a
handling of implicit transactions in DatabaseManager
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
146 { |
b2ff1cd2907a
handling of implicit transactions in DatabaseManager
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
147 readOnly_ = false; |
b2ff1cd2907a
handling of implicit transactions in DatabaseManager
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
148 } |
b2ff1cd2907a
handling of implicit transactions in DatabaseManager
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
149 |
b2ff1cd2907a
handling of implicit transactions in DatabaseManager
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
150 state_ = State_Executed; |
b2ff1cd2907a
handling of implicit transactions in DatabaseManager
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
151 } |
28
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 |
c0cb5d2cd696
checks depending on Orthanc version
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
25
diff
changeset
|
154 void ImplicitTransaction::SetErrorOnDoubleExecution(bool isError) |
c0cb5d2cd696
checks depending on Orthanc version
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
25
diff
changeset
|
155 { |
c0cb5d2cd696
checks depending on Orthanc version
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
25
diff
changeset
|
156 isErrorOnDoubleExecution_ = isError; |
c0cb5d2cd696
checks depending on Orthanc version
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
25
diff
changeset
|
157 } |
c0cb5d2cd696
checks depending on Orthanc version
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
25
diff
changeset
|
158 |
c0cb5d2cd696
checks depending on Orthanc version
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
25
diff
changeset
|
159 |
c0cb5d2cd696
checks depending on Orthanc version
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
25
diff
changeset
|
160 bool ImplicitTransaction::IsErrorOnDoubleExecution() |
c0cb5d2cd696
checks depending on Orthanc version
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
25
diff
changeset
|
161 { |
c0cb5d2cd696
checks depending on Orthanc version
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
25
diff
changeset
|
162 return isErrorOnDoubleExecution_; |
c0cb5d2cd696
checks depending on Orthanc version
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
25
diff
changeset
|
163 } |
23
b2ff1cd2907a
handling of implicit transactions in DatabaseManager
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
164 } |
b2ff1cd2907a
handling of implicit transactions in DatabaseManager
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
165 |