Mercurial > hg > orthanc-databases
annotate Framework/PostgreSQL/PostgreSQLStatement.h @ 319:baaa265d84f4
fix
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Tue, 20 Jul 2021 08:14:24 +0200 |
parents | ab96698c73a3 |
children | 16aac0287485 |
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 | |
193
3236894320d6
upgrade to year 2021
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
186
diff
changeset
|
5 * Copyright (C) 2017-2021 Osimis S.A., Belgium |
0 | 6 * |
7 * This program is free software: you can redistribute it and/or | |
8 * modify it under the terms of the GNU Affero General Public License | |
9 * as published by the Free Software Foundation, either version 3 of | |
10 * the License, or (at your option) any later version. | |
11 * | |
12 * This program is distributed in the hope that it will be useful, but | |
13 * WITHOUT ANY WARRANTY; without even the implied warranty of | |
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
15 * Affero General Public License for more details. | |
16 * | |
17 * You should have received a copy of the GNU Affero General Public License | |
18 * along with this program. If not, see <http://www.gnu.org/licenses/>. | |
19 **/ | |
20 | |
21 | |
22 #pragma once | |
23 | |
24 #if ORTHANC_ENABLE_POSTGRESQL != 1 | |
25 # error PostgreSQL support must be enabled to use this file | |
26 #endif | |
27 | |
28 #include "../Common/IPrecompiledStatement.h" | |
29 #include "../Common/Query.h" | |
30 #include "../Common/GenericFormatter.h" | |
31 | |
32 #include "PostgreSQLDatabase.h" | |
33 #include "PostgreSQLLargeObject.h" | |
34 #include "PostgreSQLTransaction.h" | |
35 | |
36 #include <vector> | |
37 #include <memory> | |
38 #include <boost/shared_ptr.hpp> | |
39 | |
40 namespace OrthancDatabases | |
41 { | |
42 class PostgreSQLStatement : public IPrecompiledStatement | |
43 { | |
44 private: | |
45 class ResultWrapper; | |
46 class Inputs; | |
47 friend class PostgreSQLResult; | |
48 | |
49 PostgreSQLDatabase& database_; | |
50 std::string id_; | |
51 std::string sql_; | |
52 std::vector<unsigned int /*Oid*/> oids_; | |
53 std::vector<int> binary_; | |
54 boost::shared_ptr<Inputs> inputs_; | |
55 GenericFormatter formatter_; | |
56 | |
57 void Prepare(); | |
58 | |
59 void Unprepare(); | |
60 | |
61 void DeclareInputInternal(unsigned int param, | |
62 unsigned int /*Oid*/ type); | |
63 | |
64 void* /* PGresult* */ Execute(); | |
65 | |
66 public: | |
67 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
|
68 const std::string& sql); |
0 | 69 |
70 PostgreSQLStatement(PostgreSQLDatabase& database, | |
71 const Query& query); | |
72 | |
46
6a574d810b98
Compatibility with MySQL 8.0
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
23
diff
changeset
|
73 ~PostgreSQLStatement(); |
0 | 74 |
75 void DeclareInputInteger(unsigned int param); | |
76 | |
77 void DeclareInputInteger64(unsigned int param); | |
78 | |
79 void DeclareInputString(unsigned int param); | |
80 | |
81 void DeclareInputBinary(unsigned int param); | |
82 | |
83 void DeclareInputLargeObject(unsigned int param); | |
84 | |
85 void Run(); | |
86 | |
87 void BindNull(unsigned int param); | |
88 | |
89 void BindInteger(unsigned int param, int value); | |
90 | |
91 void BindInteger64(unsigned int param, int64_t value); | |
92 | |
93 void BindString(unsigned int param, const std::string& value); | |
94 | |
95 void BindLargeObject(unsigned int param, const PostgreSQLLargeObject& value); | |
96 | |
97 PostgreSQLDatabase& GetDatabase() const | |
98 { | |
99 return database_; | |
100 } | |
101 | |
23
b2ff1cd2907a
handling of implicit transactions in DatabaseManager
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
0
diff
changeset
|
102 IResult* Execute(ITransaction& transaction, |
0 | 103 const Dictionary& parameters); |
104 | |
23
b2ff1cd2907a
handling of implicit transactions in DatabaseManager
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
0
diff
changeset
|
105 void ExecuteWithoutResult(ITransaction& transaction, |
0 | 106 const Dictionary& parameters); |
107 }; | |
108 } |