Mercurial > hg > orthanc-databases
comparison Framework/PostgreSQL/PostgreSQLDatabase.cpp @ 216:fbb52129158a
TransactionType given to PostgreSQLTransaction constructor
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Fri, 26 Mar 2021 17:47:56 +0100 |
parents | b40b30075c51 |
children | a4918d57435c |
comparison
equal
deleted
inserted
replaced
215:b40b30075c51 | 216:fbb52129158a |
---|---|
110 } | 110 } |
111 | 111 |
112 | 112 |
113 bool PostgreSQLDatabase::RunAdvisoryLockStatement(const std::string& statement) | 113 bool PostgreSQLDatabase::RunAdvisoryLockStatement(const std::string& statement) |
114 { | 114 { |
115 PostgreSQLTransaction transaction(*this); | 115 PostgreSQLTransaction transaction(*this, TransactionType_ReadWrite); |
116 | 116 |
117 Query query(statement, false); | 117 Query query(statement, false); |
118 PostgreSQLStatement s(*this, query); | 118 PostgreSQLStatement s(*this, query); |
119 | 119 |
120 PostgreSQLResult result(s); | 120 PostgreSQLResult result(s); |
204 } | 204 } |
205 | 205 |
206 | 206 |
207 void PostgreSQLDatabase::ClearAll() | 207 void PostgreSQLDatabase::ClearAll() |
208 { | 208 { |
209 PostgreSQLTransaction transaction(*this); | 209 PostgreSQLTransaction transaction(*this, TransactionType_ReadWrite); |
210 | 210 |
211 // Remove all the large objects | 211 // Remove all the large objects |
212 Execute("SELECT lo_unlink(loid) FROM (SELECT DISTINCT loid FROM pg_catalog.pg_largeobject) as loids;"); | 212 Execute("SELECT lo_unlink(loid) FROM (SELECT DISTINCT loid FROM pg_catalog.pg_largeobject) as loids;"); |
213 | 213 |
214 // http://stackoverflow.com/a/21247009/881731 | 214 // http://stackoverflow.com/a/21247009/881731 |
253 switch (type) | 253 switch (type) |
254 { | 254 { |
255 case TransactionType_Implicit: | 255 case TransactionType_Implicit: |
256 return new PostgreSQLImplicitTransaction; | 256 return new PostgreSQLImplicitTransaction; |
257 | 257 |
258 case TransactionType_ReadWrite: | |
258 case TransactionType_ReadOnly: | 259 case TransactionType_ReadOnly: |
259 // TODO => READ-ONLY | 260 return new PostgreSQLTransaction(*this, type); |
260 return new PostgreSQLTransaction(*this); | |
261 | |
262 case TransactionType_ReadWrite: | |
263 return new PostgreSQLTransaction(*this); | |
264 | 261 |
265 default: | 262 default: |
266 throw Orthanc::OrthancException(Orthanc::ErrorCode_ParameterOutOfRange); | 263 throw Orthanc::OrthancException(Orthanc::ErrorCode_ParameterOutOfRange); |
267 } | 264 } |
268 } | 265 } |