Mercurial > hg > orthanc-databases
annotate MySQL/Plugins/MySQLStorageArea.cpp @ 518:e3102bad13a4
fix SDK 1.12.4 protobuf
author | Alain Mazy <am@orthanc.team> |
---|---|
date | Thu, 06 Jun 2024 12:38:28 +0200 |
parents | 54d518dcd74a |
children |
rev | line source |
---|---|
17 | 1 /** |
2 * Orthanc - A Lightweight, RESTful DICOM Store | |
3 * Copyright (C) 2012-2016 Sebastien Jodogne, Medical Physics | |
4 * Department, University Hospital of Liege, Belgium | |
507
54d518dcd74a
updated copyright, as Orthanc Team now replaces Osimis
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
459
diff
changeset
|
5 * Copyright (C) 2017-2023 Osimis S.A., Belgium |
54d518dcd74a
updated copyright, as Orthanc Team now replaces Osimis
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
459
diff
changeset
|
6 * Copyright (C) 2024-2024 Orthanc Team SRL, Belgium |
459
ecd0b719cff5
update year to 2024
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
389
diff
changeset
|
7 * Copyright (C) 2021-2024 Sebastien Jodogne, ICTEAM UCLouvain, Belgium |
17 | 8 * |
9 * This program is free software: you can redistribute it and/or | |
10 * modify it under the terms of the GNU Affero General Public License | |
11 * as published by the Free Software Foundation, either version 3 of | |
12 * the License, or (at your option) any later version. | |
13 * | |
14 * This program is distributed in the hope that it will be useful, but | |
15 * WITHOUT ANY WARRANTY; without even the implied warranty of | |
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
17 * Affero General Public License for more details. | |
18 * | |
19 * You should have received a copy of the GNU Affero General Public License | |
20 * along with this program. If not, see <http://www.gnu.org/licenses/>. | |
21 **/ | |
22 | |
23 | |
24 #include "MySQLStorageArea.h" | |
25 | |
242
b97a537f4613
MySQL: Support of range reads for the storage area
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
237
diff
changeset
|
26 #include "../../Framework/Common/BinaryStringValue.h" |
17 | 27 #include "../../Framework/MySQL/MySQLDatabase.h" |
28 #include "../../Framework/MySQL/MySQLTransaction.h" | |
137
52b3859ee0b7
MySQL: acquiring named locks instead of numbers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
135
diff
changeset
|
29 #include "MySQLDefinitions.h" |
17 | 30 |
157
275e14f57f1e
replacing deprecated std::auto_ptr by std::unique_ptr
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
152
diff
changeset
|
31 #include <Compatibility.h> // For std::unique_ptr<> |
152 | 32 #include <Logging.h> |
17 | 33 |
34 #include <boost/math/special_functions/round.hpp> | |
35 | |
36 | |
37 namespace OrthancDatabases | |
38 { | |
226
a4918d57435c
DatabaseManager doesn't IDatabaseFactory anymore
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
217
diff
changeset
|
39 void MySQLStorageArea::ConfigureDatabase(MySQLDatabase& db, |
a4918d57435c
DatabaseManager doesn't IDatabaseFactory anymore
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
217
diff
changeset
|
40 const MySQLParameters& parameters, |
a4918d57435c
DatabaseManager doesn't IDatabaseFactory anymore
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
217
diff
changeset
|
41 bool clearAll) |
17 | 42 { |
43 { | |
226
a4918d57435c
DatabaseManager doesn't IDatabaseFactory anymore
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
217
diff
changeset
|
44 MySQLDatabase::TransientAdvisoryLock lock(db, MYSQL_LOCK_DATABASE_SETUP); |
a4918d57435c
DatabaseManager doesn't IDatabaseFactory anymore
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
217
diff
changeset
|
45 MySQLTransaction t(db, TransactionType_ReadWrite); |
17 | 46 |
47 int64_t size; | |
226
a4918d57435c
DatabaseManager doesn't IDatabaseFactory anymore
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
217
diff
changeset
|
48 if (db.LookupGlobalIntegerVariable(size, "max_allowed_packet")) |
17 | 49 { |
50 int mb = boost::math::iround(static_cast<double>(size) / | |
51 static_cast<double>(1024 * 1024)); | |
52 LOG(WARNING) << "Your MySQL server cannot " | |
53 << "store DICOM files larger than " << mb << "MB"; | |
54 LOG(WARNING) << " => Consider increasing \"max_allowed_packet\" " | |
55 << "in \"my.cnf\" if this limit is insufficient for your use"; | |
56 } | |
57 else | |
58 { | |
59 LOG(WARNING) << "Unable to auto-detect the maximum size of DICOM " | |
60 << "files that can be stored in this MySQL server"; | |
61 } | |
62 | |
226
a4918d57435c
DatabaseManager doesn't IDatabaseFactory anymore
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
217
diff
changeset
|
63 if (clearAll) |
17 | 64 { |
237
35598014f140
refactoring to remove GlobalProperties.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
226
diff
changeset
|
65 db.ExecuteMultiLines("DROP TABLE IF EXISTS StorageArea", false); |
17 | 66 } |
67 | |
237
35598014f140
refactoring to remove GlobalProperties.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
226
diff
changeset
|
68 db.ExecuteMultiLines("CREATE TABLE IF NOT EXISTS StorageArea(" |
35598014f140
refactoring to remove GlobalProperties.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
226
diff
changeset
|
69 "uuid VARCHAR(64) NOT NULL PRIMARY KEY," |
35598014f140
refactoring to remove GlobalProperties.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
226
diff
changeset
|
70 "content LONGBLOB NOT NULL," |
35598014f140
refactoring to remove GlobalProperties.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
226
diff
changeset
|
71 "type INTEGER NOT NULL)", false); |
17 | 72 |
73 t.Commit(); | |
74 } | |
75 | |
137
52b3859ee0b7
MySQL: acquiring named locks instead of numbers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
135
diff
changeset
|
76 /** |
52b3859ee0b7
MySQL: acquiring named locks instead of numbers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
135
diff
changeset
|
77 * WARNING: This lock must be acquired after |
52b3859ee0b7
MySQL: acquiring named locks instead of numbers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
135
diff
changeset
|
78 * "MYSQL_LOCK_DATABASE_SETUP" is released. Indeed, in MySQL < |
52b3859ee0b7
MySQL: acquiring named locks instead of numbers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
135
diff
changeset
|
79 * 5.7, it is impossible to acquire more than one lock at a time, |
52b3859ee0b7
MySQL: acquiring named locks instead of numbers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
135
diff
changeset
|
80 * as calling "SELECT GET_LOCK()" releases all the |
52b3859ee0b7
MySQL: acquiring named locks instead of numbers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
135
diff
changeset
|
81 * previously-acquired locks. |
52b3859ee0b7
MySQL: acquiring named locks instead of numbers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
135
diff
changeset
|
82 * https://dev.mysql.com/doc/refman/5.7/en/locking-functions.html |
52b3859ee0b7
MySQL: acquiring named locks instead of numbers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
135
diff
changeset
|
83 **/ |
226
a4918d57435c
DatabaseManager doesn't IDatabaseFactory anymore
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
217
diff
changeset
|
84 if (parameters.HasLock()) |
137
52b3859ee0b7
MySQL: acquiring named locks instead of numbers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
135
diff
changeset
|
85 { |
226
a4918d57435c
DatabaseManager doesn't IDatabaseFactory anymore
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
217
diff
changeset
|
86 db.AdvisoryLock(MYSQL_LOCK_STORAGE); |
137
52b3859ee0b7
MySQL: acquiring named locks instead of numbers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
135
diff
changeset
|
87 } |
17 | 88 } |
89 | |
90 | |
226
a4918d57435c
DatabaseManager doesn't IDatabaseFactory anymore
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
217
diff
changeset
|
91 MySQLStorageArea::MySQLStorageArea(const MySQLParameters& parameters, |
255
d663d9e44f8d
reintroduction of IDatabaseFactory into DatabaseManager
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
252
diff
changeset
|
92 bool clearAll) : |
269
567761f0c1ea
fix issue #151: support of retries in the storage area plugins to deal with multiple writers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
255
diff
changeset
|
93 StorageBackend(MySQLDatabase::CreateDatabaseFactory(parameters), |
567761f0c1ea
fix issue #151: support of retries in the storage area plugins to deal with multiple writers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
255
diff
changeset
|
94 parameters.GetMaxConnectionRetries()) |
17 | 95 { |
226
a4918d57435c
DatabaseManager doesn't IDatabaseFactory anymore
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
217
diff
changeset
|
96 { |
255
d663d9e44f8d
reintroduction of IDatabaseFactory into DatabaseManager
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
252
diff
changeset
|
97 AccessorBase accessor(*this); |
d663d9e44f8d
reintroduction of IDatabaseFactory into DatabaseManager
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
252
diff
changeset
|
98 MySQLDatabase& database = dynamic_cast<MySQLDatabase&>(accessor.GetManager().GetDatabase()); |
d663d9e44f8d
reintroduction of IDatabaseFactory into DatabaseManager
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
252
diff
changeset
|
99 ConfigureDatabase(database, parameters, clearAll); |
226
a4918d57435c
DatabaseManager doesn't IDatabaseFactory anymore
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
217
diff
changeset
|
100 } |
17 | 101 } |
242
b97a537f4613
MySQL: Support of range reads for the storage area
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
237
diff
changeset
|
102 |
b97a537f4613
MySQL: Support of range reads for the storage area
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
237
diff
changeset
|
103 |
b97a537f4613
MySQL: Support of range reads for the storage area
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
237
diff
changeset
|
104 class MySQLStorageArea::Accessor : public StorageBackend::AccessorBase |
b97a537f4613
MySQL: Support of range reads for the storage area
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
237
diff
changeset
|
105 { |
b97a537f4613
MySQL: Support of range reads for the storage area
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
237
diff
changeset
|
106 public: |
252 | 107 explicit Accessor(MySQLStorageArea& backend) : |
242
b97a537f4613
MySQL: Support of range reads for the storage area
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
237
diff
changeset
|
108 AccessorBase(backend) |
b97a537f4613
MySQL: Support of range reads for the storage area
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
237
diff
changeset
|
109 { |
b97a537f4613
MySQL: Support of range reads for the storage area
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
237
diff
changeset
|
110 } |
b97a537f4613
MySQL: Support of range reads for the storage area
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
237
diff
changeset
|
111 |
b97a537f4613
MySQL: Support of range reads for the storage area
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
237
diff
changeset
|
112 virtual void ReadRange(IFileContentVisitor& visitor, |
b97a537f4613
MySQL: Support of range reads for the storage area
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
237
diff
changeset
|
113 const std::string& uuid, |
b97a537f4613
MySQL: Support of range reads for the storage area
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
237
diff
changeset
|
114 OrthancPluginContentType type, |
b97a537f4613
MySQL: Support of range reads for the storage area
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
237
diff
changeset
|
115 uint64_t start, |
250 | 116 size_t length) ORTHANC_OVERRIDE |
242
b97a537f4613
MySQL: Support of range reads for the storage area
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
237
diff
changeset
|
117 { |
b97a537f4613
MySQL: Support of range reads for the storage area
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
237
diff
changeset
|
118 DatabaseManager::Transaction transaction(GetManager(), TransactionType_ReadOnly); |
b97a537f4613
MySQL: Support of range reads for the storage area
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
237
diff
changeset
|
119 |
b97a537f4613
MySQL: Support of range reads for the storage area
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
237
diff
changeset
|
120 { |
b97a537f4613
MySQL: Support of range reads for the storage area
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
237
diff
changeset
|
121 // https://stackoverflow.com/a/6545557/881731 |
b97a537f4613
MySQL: Support of range reads for the storage area
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
237
diff
changeset
|
122 DatabaseManager::CachedStatement statement( |
b97a537f4613
MySQL: Support of range reads for the storage area
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
237
diff
changeset
|
123 STATEMENT_FROM_HERE, GetManager(), |
b97a537f4613
MySQL: Support of range reads for the storage area
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
237
diff
changeset
|
124 "SELECT SUBSTRING(content, ${start}, ${length}) FROM StorageArea WHERE uuid=${uuid} AND type=${type}"); |
b97a537f4613
MySQL: Support of range reads for the storage area
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
237
diff
changeset
|
125 |
b97a537f4613
MySQL: Support of range reads for the storage area
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
237
diff
changeset
|
126 statement.SetParameterType("uuid", ValueType_Utf8String); |
b97a537f4613
MySQL: Support of range reads for the storage area
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
237
diff
changeset
|
127 statement.SetParameterType("type", ValueType_Integer64); |
b97a537f4613
MySQL: Support of range reads for the storage area
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
237
diff
changeset
|
128 statement.SetParameterType("start", ValueType_Integer64); |
b97a537f4613
MySQL: Support of range reads for the storage area
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
237
diff
changeset
|
129 statement.SetParameterType("length", ValueType_Integer64); |
b97a537f4613
MySQL: Support of range reads for the storage area
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
237
diff
changeset
|
130 |
b97a537f4613
MySQL: Support of range reads for the storage area
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
237
diff
changeset
|
131 Dictionary args; |
b97a537f4613
MySQL: Support of range reads for the storage area
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
237
diff
changeset
|
132 args.SetUtf8Value("uuid", uuid); |
b97a537f4613
MySQL: Support of range reads for the storage area
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
237
diff
changeset
|
133 args.SetIntegerValue("type", type); |
b97a537f4613
MySQL: Support of range reads for the storage area
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
237
diff
changeset
|
134 args.SetIntegerValue("length", length); |
b97a537f4613
MySQL: Support of range reads for the storage area
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
237
diff
changeset
|
135 |
b97a537f4613
MySQL: Support of range reads for the storage area
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
237
diff
changeset
|
136 /** |
b97a537f4613
MySQL: Support of range reads for the storage area
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
237
diff
changeset
|
137 * "For all forms of SUBSTRING(), the position of the first |
b97a537f4613
MySQL: Support of range reads for the storage area
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
237
diff
changeset
|
138 * character in the string from which the substring is to be |
b97a537f4613
MySQL: Support of range reads for the storage area
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
237
diff
changeset
|
139 * extracted is reckoned as 1." => hence the "+ 1" |
b97a537f4613
MySQL: Support of range reads for the storage area
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
237
diff
changeset
|
140 * https://dev.mysql.com/doc/refman/8.0/en/string-functions.html#function_substring |
b97a537f4613
MySQL: Support of range reads for the storage area
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
237
diff
changeset
|
141 **/ |
b97a537f4613
MySQL: Support of range reads for the storage area
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
237
diff
changeset
|
142 args.SetIntegerValue("start", start + 1); |
b97a537f4613
MySQL: Support of range reads for the storage area
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
237
diff
changeset
|
143 |
b97a537f4613
MySQL: Support of range reads for the storage area
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
237
diff
changeset
|
144 statement.Execute(args); |
b97a537f4613
MySQL: Support of range reads for the storage area
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
237
diff
changeset
|
145 |
b97a537f4613
MySQL: Support of range reads for the storage area
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
237
diff
changeset
|
146 if (statement.IsDone()) |
b97a537f4613
MySQL: Support of range reads for the storage area
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
237
diff
changeset
|
147 { |
b97a537f4613
MySQL: Support of range reads for the storage area
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
237
diff
changeset
|
148 throw Orthanc::OrthancException(Orthanc::ErrorCode_UnknownResource); |
b97a537f4613
MySQL: Support of range reads for the storage area
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
237
diff
changeset
|
149 } |
b97a537f4613
MySQL: Support of range reads for the storage area
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
237
diff
changeset
|
150 else if (statement.GetResultFieldsCount() != 1) |
b97a537f4613
MySQL: Support of range reads for the storage area
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
237
diff
changeset
|
151 { |
b97a537f4613
MySQL: Support of range reads for the storage area
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
237
diff
changeset
|
152 throw Orthanc::OrthancException(Orthanc::ErrorCode_Database); |
b97a537f4613
MySQL: Support of range reads for the storage area
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
237
diff
changeset
|
153 } |
b97a537f4613
MySQL: Support of range reads for the storage area
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
237
diff
changeset
|
154 else |
b97a537f4613
MySQL: Support of range reads for the storage area
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
237
diff
changeset
|
155 { |
b97a537f4613
MySQL: Support of range reads for the storage area
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
237
diff
changeset
|
156 const IValue& value = statement.GetResultField(0); |
b97a537f4613
MySQL: Support of range reads for the storage area
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
237
diff
changeset
|
157 |
b97a537f4613
MySQL: Support of range reads for the storage area
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
237
diff
changeset
|
158 if (value.GetType() == ValueType_BinaryString) |
b97a537f4613
MySQL: Support of range reads for the storage area
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
237
diff
changeset
|
159 { |
b97a537f4613
MySQL: Support of range reads for the storage area
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
237
diff
changeset
|
160 const std::string& content = dynamic_cast<const BinaryStringValue&>(value).GetContent(); |
b97a537f4613
MySQL: Support of range reads for the storage area
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
237
diff
changeset
|
161 |
b97a537f4613
MySQL: Support of range reads for the storage area
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
237
diff
changeset
|
162 if (static_cast<uint64_t>(content.size()) == length) |
b97a537f4613
MySQL: Support of range reads for the storage area
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
237
diff
changeset
|
163 { |
b97a537f4613
MySQL: Support of range reads for the storage area
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
237
diff
changeset
|
164 visitor.Assign(content); |
b97a537f4613
MySQL: Support of range reads for the storage area
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
237
diff
changeset
|
165 } |
b97a537f4613
MySQL: Support of range reads for the storage area
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
237
diff
changeset
|
166 else |
b97a537f4613
MySQL: Support of range reads for the storage area
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
237
diff
changeset
|
167 { |
b97a537f4613
MySQL: Support of range reads for the storage area
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
237
diff
changeset
|
168 throw Orthanc::OrthancException(Orthanc::ErrorCode_BadRange); |
b97a537f4613
MySQL: Support of range reads for the storage area
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
237
diff
changeset
|
169 } |
b97a537f4613
MySQL: Support of range reads for the storage area
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
237
diff
changeset
|
170 } |
b97a537f4613
MySQL: Support of range reads for the storage area
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
237
diff
changeset
|
171 else |
b97a537f4613
MySQL: Support of range reads for the storage area
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
237
diff
changeset
|
172 { |
b97a537f4613
MySQL: Support of range reads for the storage area
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
237
diff
changeset
|
173 throw Orthanc::OrthancException(Orthanc::ErrorCode_Database); |
b97a537f4613
MySQL: Support of range reads for the storage area
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
237
diff
changeset
|
174 } |
b97a537f4613
MySQL: Support of range reads for the storage area
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
237
diff
changeset
|
175 } |
b97a537f4613
MySQL: Support of range reads for the storage area
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
237
diff
changeset
|
176 } |
b97a537f4613
MySQL: Support of range reads for the storage area
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
237
diff
changeset
|
177 |
b97a537f4613
MySQL: Support of range reads for the storage area
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
237
diff
changeset
|
178 transaction.Commit(); |
b97a537f4613
MySQL: Support of range reads for the storage area
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
237
diff
changeset
|
179 |
b97a537f4613
MySQL: Support of range reads for the storage area
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
237
diff
changeset
|
180 if (!visitor.IsSuccess()) |
b97a537f4613
MySQL: Support of range reads for the storage area
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
237
diff
changeset
|
181 { |
b97a537f4613
MySQL: Support of range reads for the storage area
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
237
diff
changeset
|
182 throw Orthanc::OrthancException(Orthanc::ErrorCode_Database, "Could not read range from the storage area"); |
b97a537f4613
MySQL: Support of range reads for the storage area
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
237
diff
changeset
|
183 } |
b97a537f4613
MySQL: Support of range reads for the storage area
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
237
diff
changeset
|
184 } |
b97a537f4613
MySQL: Support of range reads for the storage area
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
237
diff
changeset
|
185 }; |
b97a537f4613
MySQL: Support of range reads for the storage area
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
237
diff
changeset
|
186 |
b97a537f4613
MySQL: Support of range reads for the storage area
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
237
diff
changeset
|
187 |
b97a537f4613
MySQL: Support of range reads for the storage area
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
237
diff
changeset
|
188 StorageBackend::IAccessor* MySQLStorageArea::CreateAccessor() |
b97a537f4613
MySQL: Support of range reads for the storage area
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
237
diff
changeset
|
189 { |
b97a537f4613
MySQL: Support of range reads for the storage area
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
237
diff
changeset
|
190 return new Accessor(*this); |
b97a537f4613
MySQL: Support of range reads for the storage area
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
237
diff
changeset
|
191 } |
17 | 192 } |