comparison Framework/PostgreSQL/PostgreSQLTransaction.cpp @ 214:ab96698c73a3

removed useless information about read-only in ITransaction and IPrecompiledStatement
author Sebastien Jodogne <s.jodogne@gmail.com>
date Thu, 25 Mar 2021 13:56:26 +0100
parents 3236894320d6
children fbb52129158a
comparison
equal deleted inserted replaced
213:c2e4a909de0e 214:ab96698c73a3
29 29
30 namespace OrthancDatabases 30 namespace OrthancDatabases
31 { 31 {
32 PostgreSQLTransaction::PostgreSQLTransaction(PostgreSQLDatabase& database) : 32 PostgreSQLTransaction::PostgreSQLTransaction(PostgreSQLDatabase& database) :
33 database_(database), 33 database_(database),
34 isOpen_(false), 34 isOpen_(false)
35 readOnly_(true)
36 { 35 {
37 Begin(); 36 Begin();
38 } 37 }
39 38
40 39
64 throw Orthanc::OrthancException(Orthanc::ErrorCode_BadSequenceOfCalls); 63 throw Orthanc::OrthancException(Orthanc::ErrorCode_BadSequenceOfCalls);
65 } 64 }
66 65
67 database_.Execute("BEGIN"); 66 database_.Execute("BEGIN");
68 database_.Execute("SET TRANSACTION ISOLATION LEVEL SERIALIZABLE"); 67 database_.Execute("SET TRANSACTION ISOLATION LEVEL SERIALIZABLE");
69 readOnly_ = true;
70 isOpen_ = true; 68 isOpen_ = true;
71 } 69 }
72 70
73 71
74 void PostgreSQLTransaction::Rollback() 72 void PostgreSQLTransaction::Rollback()
100 98
101 99
102 IResult* PostgreSQLTransaction::Execute(IPrecompiledStatement& statement, 100 IResult* PostgreSQLTransaction::Execute(IPrecompiledStatement& statement,
103 const Dictionary& parameters) 101 const Dictionary& parameters)
104 { 102 {
105 std::unique_ptr<IResult> result(dynamic_cast<PostgreSQLStatement&>(statement).Execute(*this, parameters)); 103 return dynamic_cast<PostgreSQLStatement&>(statement).Execute(*this, parameters);
106
107 if (!statement.IsReadOnly())
108 {
109 readOnly_ = false;
110 }
111
112 return result.release();
113 } 104 }
114 105
115 106
116 void PostgreSQLTransaction::ExecuteWithoutResult(IPrecompiledStatement& statement, 107 void PostgreSQLTransaction::ExecuteWithoutResult(IPrecompiledStatement& statement,
117 const Dictionary& parameters) 108 const Dictionary& parameters)
118 { 109 {
119 dynamic_cast<PostgreSQLStatement&>(statement).ExecuteWithoutResult(*this, parameters); 110 dynamic_cast<PostgreSQLStatement&>(statement).ExecuteWithoutResult(*this, parameters);
120
121 if (!statement.IsReadOnly())
122 {
123 readOnly_ = false;
124 }
125 } 111 }
126 } 112 }