Mercurial > hg > orthanc-databases
annotate Framework/PostgreSQL/PostgreSQLStatement.h @ 359:16aac0287485
copyright upgraded to 2022
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Mon, 21 Feb 2022 09:32:46 +0100 |
parents | ab96698c73a3 |
children | 3d6886f3e5b3 |
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 | |
359
16aac0287485
copyright upgraded to 2022
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
214
diff
changeset
|
5 * Copyright (C) 2017-2022 Osimis S.A., Belgium |
16aac0287485
copyright upgraded to 2022
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
214
diff
changeset
|
6 * Copyright (C) 2021-2022 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 | |
23 #pragma once | |
24 | |
25 #if ORTHANC_ENABLE_POSTGRESQL != 1 | |
26 # error PostgreSQL support must be enabled to use this file | |
27 #endif | |
28 | |
29 #include "../Common/IPrecompiledStatement.h" | |
30 #include "../Common/Query.h" | |
31 #include "../Common/GenericFormatter.h" | |
32 | |
33 #include "PostgreSQLDatabase.h" | |
34 #include "PostgreSQLLargeObject.h" | |
35 #include "PostgreSQLTransaction.h" | |
36 | |
37 #include <vector> | |
38 #include <memory> | |
39 #include <boost/shared_ptr.hpp> | |
40 | |
41 namespace OrthancDatabases | |
42 { | |
43 class PostgreSQLStatement : public IPrecompiledStatement | |
44 { | |
45 private: | |
46 class ResultWrapper; | |
47 class Inputs; | |
48 friend class PostgreSQLResult; | |
49 | |
50 PostgreSQLDatabase& database_; | |
51 std::string id_; | |
52 std::string sql_; | |
53 std::vector<unsigned int /*Oid*/> oids_; | |
54 std::vector<int> binary_; | |
55 boost::shared_ptr<Inputs> inputs_; | |
56 GenericFormatter formatter_; | |
57 | |
58 void Prepare(); | |
59 | |
60 void Unprepare(); | |
61 | |
62 void DeclareInputInternal(unsigned int param, | |
63 unsigned int /*Oid*/ type); | |
64 | |
65 void* /* PGresult* */ Execute(); | |
66 | |
67 public: | |
68 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
|
69 const std::string& sql); |
0 | 70 |
71 PostgreSQLStatement(PostgreSQLDatabase& database, | |
72 const Query& query); | |
73 | |
46
6a574d810b98
Compatibility with MySQL 8.0
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
23
diff
changeset
|
74 ~PostgreSQLStatement(); |
0 | 75 |
76 void DeclareInputInteger(unsigned int param); | |
77 | |
78 void DeclareInputInteger64(unsigned int param); | |
79 | |
80 void DeclareInputString(unsigned int param); | |
81 | |
82 void DeclareInputBinary(unsigned int param); | |
83 | |
84 void DeclareInputLargeObject(unsigned int param); | |
85 | |
86 void Run(); | |
87 | |
88 void BindNull(unsigned int param); | |
89 | |
90 void BindInteger(unsigned int param, int value); | |
91 | |
92 void BindInteger64(unsigned int param, int64_t value); | |
93 | |
94 void BindString(unsigned int param, const std::string& value); | |
95 | |
96 void BindLargeObject(unsigned int param, const PostgreSQLLargeObject& value); | |
97 | |
98 PostgreSQLDatabase& GetDatabase() const | |
99 { | |
100 return database_; | |
101 } | |
102 | |
23
b2ff1cd2907a
handling of implicit transactions in DatabaseManager
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
0
diff
changeset
|
103 IResult* Execute(ITransaction& transaction, |
0 | 104 const Dictionary& parameters); |
105 | |
23
b2ff1cd2907a
handling of implicit transactions in DatabaseManager
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
0
diff
changeset
|
106 void ExecuteWithoutResult(ITransaction& transaction, |
0 | 107 const Dictionary& parameters); |
108 }; | |
109 } |