Mercurial > hg > orthanc-databases
annotate Framework/PostgreSQL/PostgreSQLStatement.cpp @ 418:a7f0f27fe33c pg-transactions
wip: advisory lock around CreateInstance: not ok see WO-139
author | Alain Mazy <am@osimis.io> |
---|---|
date | Tue, 27 Jun 2023 15:17:39 +0200 |
parents | 3d6886f3e5b3 |
children | dbf811b1bb43 ecd0b719cff5 |
rev | line source |
---|---|
0 | 1 /** |
2 * Orthanc - A Lightweight, RESTful DICOM Store | |
3 * Copyright (C) 2012-2016 Sebastien Jodogne, Medical Physics | |
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 |
0 | 7 * |
8 * This program is free software: you can redistribute it and/or | |
9 * modify it under the terms of the GNU Affero General Public License | |
10 * as published by the Free Software Foundation, either version 3 of | |
11 * the License, or (at your option) any later version. | |
12 * | |
13 * This program is distributed in the hope that it will be useful, but | |
14 * WITHOUT ANY WARRANTY; without even the implied warranty of | |
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
16 * Affero General Public License for more details. | |
17 * | |
18 * You should have received a copy of the GNU Affero General Public License | |
19 * along with this program. If not, see <http://www.gnu.org/licenses/>. | |
20 **/ | |
21 | |
22 | |
107
5765cc5fd268
reverted fix for OS X that breaks other targets
Sebastien Jodogne <s.jodogne@orthanc-labs.com>
parents:
105
diff
changeset
|
23 #include "PostgreSQLIncludes.h" // Must be the first |
105 | 24 #include "PostgreSQLStatement.h" |
0 | 25 |
26 #include "../Common/BinaryStringValue.h" | |
244
02cd7254c949
separating class InputFileValue from FileValue
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
237
diff
changeset
|
27 #include "../Common/InputFileValue.h" |
0 | 28 #include "../Common/Integer64Value.h" |
29 #include "../Common/NullValue.h" | |
30 #include "../Common/ResultBase.h" | |
31 #include "../Common/Utf8StringValue.h" | |
32 #include "PostgreSQLResult.h" | |
33 | |
157
275e14f57f1e
replacing deprecated std::auto_ptr by std::unique_ptr
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
152
diff
changeset
|
34 #include <Compatibility.h> // For std::unique_ptr<> |
152 | 35 #include <Logging.h> |
36 #include <OrthancException.h> | |
37 #include <Toolbox.h> | |
38 #include <Endianness.h> | |
0 | 39 |
40 #include <cassert> | |
41 | |
42 | |
43 namespace OrthancDatabases | |
44 { | |
45 class PostgreSQLStatement::Inputs : public boost::noncopyable | |
46 { | |
47 private: | |
48 std::vector<char*> values_; | |
49 std::vector<int> sizes_; | |
50 | |
51 static char* Allocate(const void* source, int size) | |
52 { | |
53 if (size == 0) | |
54 { | |
55 return NULL; | |
56 } | |
57 else | |
58 { | |
59 char* ptr = reinterpret_cast<char*>(malloc(size)); | |
60 | |
61 if (source != NULL) | |
62 { | |
63 memcpy(ptr, source, size); | |
64 } | |
65 | |
66 return ptr; | |
67 } | |
68 } | |
69 | |
70 void Resize(size_t size) | |
71 { | |
72 // Shrinking of the vector | |
73 for (size_t i = size; i < values_.size(); i++) | |
74 { | |
75 if (values_[i] != NULL) | |
76 free(values_[i]); | |
77 } | |
78 | |
79 values_.resize(size, NULL); | |
80 sizes_.resize(size, 0); | |
81 } | |
82 | |
83 void EnlargeForIndex(size_t index) | |
84 { | |
85 if (index >= values_.size()) | |
86 { | |
87 // The vector is too small | |
88 Resize(index + 1); | |
89 } | |
90 } | |
91 | |
92 public: | |
93 Inputs() | |
94 { | |
95 } | |
96 | |
97 ~Inputs() | |
98 { | |
99 Resize(0); | |
100 } | |
101 | |
102 void SetItem(size_t pos, const void* source, int size) | |
103 { | |
104 EnlargeForIndex(pos); | |
105 | |
106 if (sizes_[pos] == size) | |
107 { | |
108 if (source && size != 0) | |
109 { | |
110 memcpy(values_[pos], source, size); | |
111 } | |
112 } | |
113 else | |
114 { | |
115 if (values_[pos] != NULL) | |
116 { | |
117 free(values_[pos]); | |
118 } | |
119 | |
120 values_[pos] = Allocate(source, size); | |
121 sizes_[pos] = size; | |
122 } | |
123 } | |
124 | |
125 void SetItem(size_t pos, int size) | |
126 { | |
127 SetItem(pos, NULL, size); | |
128 } | |
129 | |
130 void* GetItem(size_t pos) const | |
131 { | |
132 if (pos >= values_.size()) | |
133 { | |
134 throw Orthanc::OrthancException(Orthanc::ErrorCode_ParameterOutOfRange); | |
135 } | |
136 | |
137 return values_[pos]; | |
138 } | |
139 | |
140 const std::vector<char*>& GetValues() const | |
141 { | |
142 return values_; | |
143 } | |
144 | |
145 const std::vector<int>& GetSizes() const | |
146 { | |
147 return sizes_; | |
148 } | |
149 }; | |
150 | |
151 | |
152 void PostgreSQLStatement::Prepare() | |
153 { | |
154 if (id_.size() > 0) | |
155 { | |
156 // Already prepared | |
157 return; | |
158 } | |
159 | |
160 for (size_t i = 0; i < oids_.size(); i++) | |
161 { | |
162 if (oids_[i] == 0) | |
163 { | |
164 // The type of an input parameter was not set | |
165 throw Orthanc::OrthancException(Orthanc::ErrorCode_BadSequenceOfCalls); | |
166 } | |
167 } | |
168 | |
169 id_ = Orthanc::Toolbox::GenerateUuid(); | |
170 | |
171 const unsigned int* tmp = oids_.size() ? &oids_[0] : NULL; | |
172 | |
173 PGresult* result = PQprepare(reinterpret_cast<PGconn*>(database_.pg_), | |
174 id_.c_str(), sql_.c_str(), oids_.size(), tmp); | |
175 | |
176 if (result == NULL) | |
177 { | |
178 id_.clear(); | |
179 database_.ThrowException(true); | |
180 } | |
181 | |
182 bool ok = (PQresultStatus(result) == PGRES_COMMAND_OK); | |
183 if (ok) | |
184 { | |
185 PQclear(result); | |
186 } | |
187 else | |
188 { | |
189 std::string message = PQresultErrorMessage(result); | |
190 PQclear(result); | |
191 id_.clear(); | |
192 LOG(ERROR) << "PostgreSQL error: " << message; | |
193 database_.ThrowException(false); | |
194 } | |
195 } | |
196 | |
197 | |
198 void PostgreSQLStatement::Unprepare() | |
199 { | |
200 if (id_.size() > 0) | |
201 { | |
202 // "Although there is no libpq function for deleting a | |
203 // prepared statement, the SQL DEALLOCATE statement can be | |
204 // used for that purpose." | |
237
35598014f140
refactoring to remove GlobalProperties.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
235
diff
changeset
|
205 database_.ExecuteMultiLines("DEALLOCATE \"" + id_ + "\""); |
0 | 206 } |
207 | |
208 id_.clear(); | |
209 } | |
210 | |
211 | |
212 void PostgreSQLStatement::DeclareInputInternal(unsigned int param, | |
213 unsigned int /*Oid*/ type) | |
214 { | |
215 Unprepare(); | |
216 | |
217 if (oids_.size() <= param) | |
218 { | |
219 oids_.resize(param + 1, 0); | |
220 binary_.resize(param + 1); | |
221 } | |
222 | |
223 oids_[param] = type; | |
224 binary_[param] = (type == TEXTOID || type == BYTEAOID || type == OIDOID) ? 0 : 1; | |
225 } | |
226 | |
227 | |
228 void PostgreSQLStatement::DeclareInputInteger(unsigned int param) | |
229 { | |
230 DeclareInputInternal(param, INT4OID); | |
231 } | |
232 | |
233 | |
234 void PostgreSQLStatement::DeclareInputInteger64(unsigned int param) | |
235 { | |
236 DeclareInputInternal(param, INT8OID); | |
237 } | |
238 | |
239 | |
240 void PostgreSQLStatement::DeclareInputString(unsigned int param) | |
241 { | |
242 DeclareInputInternal(param, TEXTOID); | |
243 } | |
244 | |
245 | |
246 void PostgreSQLStatement::DeclareInputBinary(unsigned int param) | |
247 { | |
248 DeclareInputInternal(param, BYTEAOID); | |
249 } | |
250 | |
251 | |
252 void PostgreSQLStatement::DeclareInputLargeObject(unsigned int param) | |
253 { | |
254 DeclareInputInternal(param, OIDOID); | |
255 } | |
256 | |
257 | |
258 void* /* PGresult* */ PostgreSQLStatement::Execute() | |
259 { | |
260 Prepare(); | |
261 | |
262 PGresult* result; | |
263 | |
264 if (oids_.size() == 0) | |
265 { | |
266 // No parameter | |
267 result = PQexecPrepared(reinterpret_cast<PGconn*>(database_.pg_), | |
268 id_.c_str(), 0, NULL, NULL, NULL, 1); | |
269 } | |
270 else | |
271 { | |
272 // At least 1 parameter | |
273 result = PQexecPrepared(reinterpret_cast<PGconn*>(database_.pg_), | |
274 id_.c_str(), | |
275 oids_.size(), | |
276 &inputs_->GetValues()[0], | |
277 &inputs_->GetSizes()[0], | |
278 &binary_[0], | |
279 1); | |
280 } | |
281 | |
234
d1b124d116c1
PostgreSQL index plugin handles retries for collisions between multiple writers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
214
diff
changeset
|
282 if (PQtransactionStatus(reinterpret_cast<PGconn*>(database_.pg_)) == PQTRANS_INERROR) |
d1b124d116c1
PostgreSQL index plugin handles retries for collisions between multiple writers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
214
diff
changeset
|
283 { |
d1b124d116c1
PostgreSQL index plugin handles retries for collisions between multiple writers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
214
diff
changeset
|
284 if (result != NULL) |
d1b124d116c1
PostgreSQL index plugin handles retries for collisions between multiple writers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
214
diff
changeset
|
285 { |
d1b124d116c1
PostgreSQL index plugin handles retries for collisions between multiple writers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
214
diff
changeset
|
286 PQclear(result); |
d1b124d116c1
PostgreSQL index plugin handles retries for collisions between multiple writers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
214
diff
changeset
|
287 } |
d1b124d116c1
PostgreSQL index plugin handles retries for collisions between multiple writers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
214
diff
changeset
|
288 |
235
f2b32d31fc99
fix lsb build, fix backward compatibility with SDK <= 1.9.1
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
234
diff
changeset
|
289 #if ORTHANC_PLUGINS_VERSION_IS_ABOVE(1, 9, 2) |
234
d1b124d116c1
PostgreSQL index plugin handles retries for collisions between multiple writers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
214
diff
changeset
|
290 throw Orthanc::OrthancException(Orthanc::ErrorCode_DatabaseCannotSerialize); |
235
f2b32d31fc99
fix lsb build, fix backward compatibility with SDK <= 1.9.1
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
234
diff
changeset
|
291 #else |
f2b32d31fc99
fix lsb build, fix backward compatibility with SDK <= 1.9.1
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
234
diff
changeset
|
292 throw Orthanc::OrthancException(Orthanc::ErrorCode_Database, "Collision between multiple writers"); |
f2b32d31fc99
fix lsb build, fix backward compatibility with SDK <= 1.9.1
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
234
diff
changeset
|
293 #endif |
234
d1b124d116c1
PostgreSQL index plugin handles retries for collisions between multiple writers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
214
diff
changeset
|
294 } |
d1b124d116c1
PostgreSQL index plugin handles retries for collisions between multiple writers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
214
diff
changeset
|
295 else if (result == NULL) |
0 | 296 { |
297 database_.ThrowException(true); | |
298 } | |
299 | |
300 return result; | |
301 } | |
302 | |
303 | |
304 PostgreSQLStatement::PostgreSQLStatement(PostgreSQLDatabase& database, | |
214
ab96698c73a3
removed useless information about read-only in ITransaction and IPrecompiledStatement
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
193
diff
changeset
|
305 const std::string& sql) : |
0 | 306 database_(database), |
307 sql_(sql), | |
308 inputs_(new Inputs), | |
309 formatter_(Dialect_PostgreSQL) | |
310 { | |
311 LOG(TRACE) << "PostgreSQL: " << sql; | |
312 } | |
313 | |
314 | |
315 PostgreSQLStatement::PostgreSQLStatement(PostgreSQLDatabase& database, | |
316 const Query& query) : | |
317 database_(database), | |
318 inputs_(new Inputs), | |
319 formatter_(Dialect_PostgreSQL) | |
320 { | |
321 query.Format(sql_, formatter_); | |
322 LOG(TRACE) << "PostgreSQL: " << sql_; | |
323 | |
324 for (size_t i = 0; i < formatter_.GetParametersCount(); i++) | |
325 { | |
326 switch (formatter_.GetParameterType(i)) | |
327 { | |
328 case ValueType_Integer64: | |
329 DeclareInputInteger64(i); | |
330 break; | |
331 | |
332 case ValueType_Utf8String: | |
333 DeclareInputString(i); | |
334 break; | |
335 | |
336 case ValueType_BinaryString: | |
337 DeclareInputBinary(i); | |
338 break; | |
339 | |
244
02cd7254c949
separating class InputFileValue from FileValue
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
237
diff
changeset
|
340 case ValueType_InputFile: |
0 | 341 DeclareInputLargeObject(i); |
342 break; | |
343 | |
344 case ValueType_Null: | |
345 default: | |
346 throw Orthanc::OrthancException(Orthanc::ErrorCode_NotImplemented); | |
347 } | |
348 } | |
349 } | |
350 | |
351 | |
46
6a574d810b98
Compatibility with MySQL 8.0
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
23
diff
changeset
|
352 PostgreSQLStatement::~PostgreSQLStatement() |
6a574d810b98
Compatibility with MySQL 8.0
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
23
diff
changeset
|
353 { |
6a574d810b98
Compatibility with MySQL 8.0
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
23
diff
changeset
|
354 try |
6a574d810b98
Compatibility with MySQL 8.0
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
23
diff
changeset
|
355 { |
6a574d810b98
Compatibility with MySQL 8.0
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
23
diff
changeset
|
356 Unprepare(); |
6a574d810b98
Compatibility with MySQL 8.0
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
23
diff
changeset
|
357 } |
6a574d810b98
Compatibility with MySQL 8.0
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
23
diff
changeset
|
358 catch (Orthanc::OrthancException&) |
6a574d810b98
Compatibility with MySQL 8.0
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
23
diff
changeset
|
359 { |
6a574d810b98
Compatibility with MySQL 8.0
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
23
diff
changeset
|
360 // Ignore possible exceptions due to connection loss |
6a574d810b98
Compatibility with MySQL 8.0
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
23
diff
changeset
|
361 } |
6a574d810b98
Compatibility with MySQL 8.0
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
23
diff
changeset
|
362 } |
6a574d810b98
Compatibility with MySQL 8.0
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
23
diff
changeset
|
363 |
6a574d810b98
Compatibility with MySQL 8.0
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
23
diff
changeset
|
364 |
0 | 365 void PostgreSQLStatement::Run() |
366 { | |
367 PGresult* result = reinterpret_cast<PGresult*>(Execute()); | |
368 assert(result != NULL); // An exception would have been thrown otherwise | |
369 | |
370 bool ok = (PQresultStatus(result) == PGRES_COMMAND_OK || | |
371 PQresultStatus(result) == PGRES_TUPLES_OK); | |
372 if (ok) | |
373 { | |
374 PQclear(result); | |
375 } | |
376 else | |
377 { | |
378 std::string error = PQresultErrorMessage(result); | |
379 PQclear(result); | |
380 LOG(ERROR) << "PostgreSQL error: " << error; | |
381 database_.ThrowException(false); | |
382 } | |
383 } | |
384 | |
385 | |
386 void PostgreSQLStatement::BindNull(unsigned int param) | |
387 { | |
388 if (param >= oids_.size()) | |
389 { | |
390 throw Orthanc::OrthancException(Orthanc::ErrorCode_ParameterOutOfRange); | |
391 } | |
392 | |
393 inputs_->SetItem(param, 0); | |
394 } | |
395 | |
396 | |
397 void PostgreSQLStatement::BindInteger(unsigned int param, | |
398 int value) | |
399 { | |
400 if (param >= oids_.size()) | |
401 { | |
402 throw Orthanc::OrthancException(Orthanc::ErrorCode_ParameterOutOfRange); | |
403 } | |
404 | |
405 if (oids_[param] != INT4OID) | |
406 { | |
407 throw Orthanc::OrthancException(Orthanc::ErrorCode_BadParameterType); | |
408 } | |
409 | |
410 assert(sizeof(int32_t) == 4); | |
411 int32_t v = htobe32(static_cast<int32_t>(value)); | |
412 inputs_->SetItem(param, &v, sizeof(int32_t)); | |
413 } | |
414 | |
415 | |
416 void PostgreSQLStatement::BindInteger64(unsigned int param, | |
417 int64_t value) | |
418 { | |
419 if (param >= oids_.size()) | |
420 { | |
421 throw Orthanc::OrthancException(Orthanc::ErrorCode_ParameterOutOfRange); | |
422 } | |
423 | |
424 if (oids_[param] != INT8OID) | |
425 { | |
426 throw Orthanc::OrthancException(Orthanc::ErrorCode_BadParameterType); | |
427 } | |
428 | |
429 assert(sizeof(int64_t) == 8); | |
430 int64_t v = htobe64(value); | |
431 inputs_->SetItem(param, &v, sizeof(int64_t)); | |
432 } | |
433 | |
434 | |
435 void PostgreSQLStatement::BindString(unsigned int param, | |
436 const std::string& value) | |
437 { | |
438 if (param >= oids_.size()) | |
439 { | |
440 throw Orthanc::OrthancException(Orthanc::ErrorCode_ParameterOutOfRange); | |
441 } | |
442 | |
443 if (oids_[param] != TEXTOID && oids_[param] != BYTEAOID) | |
444 { | |
445 throw Orthanc::OrthancException(Orthanc::ErrorCode_BadParameterType); | |
446 } | |
447 | |
448 if (value.size() == 0) | |
449 { | |
450 inputs_->SetItem(param, "", 1 /* end-of-string character */); | |
451 } | |
452 else | |
453 { | |
454 inputs_->SetItem(param, value.c_str(), | |
455 value.size() + 1); // "+1" for end-of-string character | |
456 } | |
457 } | |
458 | |
459 | |
460 void PostgreSQLStatement::BindLargeObject(unsigned int param, | |
461 const PostgreSQLLargeObject& value) | |
462 { | |
463 if (param >= oids_.size()) | |
464 { | |
465 throw Orthanc::OrthancException(Orthanc::ErrorCode_ParameterOutOfRange); | |
466 } | |
467 | |
468 if (oids_[param] != OIDOID) | |
469 { | |
470 throw Orthanc::OrthancException(Orthanc::ErrorCode_BadParameterType); | |
471 } | |
472 | |
473 inputs_->SetItem(param, value.GetOid().c_str(), | |
474 value.GetOid().size() + 1); // "+1" for end-of-string character | |
475 } | |
476 | |
477 | |
478 class PostgreSQLStatement::ResultWrapper : public ResultBase | |
479 { | |
480 private: | |
157
275e14f57f1e
replacing deprecated std::auto_ptr by std::unique_ptr
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
152
diff
changeset
|
481 std::unique_ptr<PostgreSQLResult> result_; |
0 | 482 |
483 protected: | |
484 virtual IValue* FetchField(size_t index) | |
485 { | |
486 return result_->GetValue(index); | |
487 } | |
488 | |
489 public: | |
186 | 490 explicit ResultWrapper(PostgreSQLStatement& statement) : |
0 | 491 result_(new PostgreSQLResult(statement)) |
492 { | |
493 SetFieldsCount(result_->GetColumnsCount()); | |
494 FetchFields(); | |
495 } | |
496 | |
497 virtual void Next() | |
498 { | |
499 result_->Next(); | |
500 FetchFields(); | |
501 } | |
502 | |
503 virtual bool IsDone() const | |
504 { | |
505 return result_->IsDone(); | |
506 } | |
507 }; | |
508 | |
509 | |
23
b2ff1cd2907a
handling of implicit transactions in DatabaseManager
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
0
diff
changeset
|
510 IResult* PostgreSQLStatement::Execute(ITransaction& transaction, |
0 | 511 const Dictionary& parameters) |
512 { | |
513 for (size_t i = 0; i < formatter_.GetParametersCount(); i++) | |
514 { | |
515 const std::string& name = formatter_.GetParameterName(i); | |
516 | |
517 switch (formatter_.GetParameterType(i)) | |
518 { | |
519 case ValueType_Integer64: | |
520 BindInteger64(i, dynamic_cast<const Integer64Value&>(parameters.GetValue(name)).GetValue()); | |
521 break; | |
522 | |
523 case ValueType_Null: | |
524 BindNull(i); | |
525 break; | |
526 | |
527 case ValueType_Utf8String: | |
528 BindString(i, dynamic_cast<const Utf8StringValue&> | |
529 (parameters.GetValue(name)).GetContent()); | |
530 break; | |
531 | |
532 case ValueType_BinaryString: | |
533 BindString(i, dynamic_cast<const BinaryStringValue&> | |
534 (parameters.GetValue(name)).GetContent()); | |
535 break; | |
536 | |
244
02cd7254c949
separating class InputFileValue from FileValue
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
237
diff
changeset
|
537 case ValueType_InputFile: |
0 | 538 { |
244
02cd7254c949
separating class InputFileValue from FileValue
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
237
diff
changeset
|
539 const InputFileValue& blob = |
02cd7254c949
separating class InputFileValue from FileValue
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
237
diff
changeset
|
540 dynamic_cast<const InputFileValue&>(parameters.GetValue(name)); |
0 | 541 |
542 PostgreSQLLargeObject largeObject(database_, blob.GetContent()); | |
543 BindLargeObject(i, largeObject); | |
544 break; | |
545 } | |
546 | |
547 default: | |
548 throw Orthanc::OrthancException(Orthanc::ErrorCode_InternalError); | |
549 } | |
550 } | |
551 | |
552 return new ResultWrapper(*this); | |
553 } | |
554 | |
555 | |
23
b2ff1cd2907a
handling of implicit transactions in DatabaseManager
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
0
diff
changeset
|
556 void PostgreSQLStatement::ExecuteWithoutResult(ITransaction& transaction, |
0 | 557 const Dictionary& parameters) |
558 { | |
157
275e14f57f1e
replacing deprecated std::auto_ptr by std::unique_ptr
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
152
diff
changeset
|
559 std::unique_ptr<IResult> dummy(Execute(transaction, parameters)); |
0 | 560 } |
561 } |