equal
deleted
inserted
replaced
135 int result = sqlite3_prepare(db, sql, -1, &stmt, &remaining); |
135 int result = sqlite3_prepare(db, sql, -1, &stmt, &remaining); |
136 if (result == SQLITE_OK) return new PreparedStatement(stmt); |
136 if (result == SQLITE_OK) return new PreparedStatement(stmt); |
137 else throw SqlException(L"Unable to prepare SQLite statement."); |
137 else throw SqlException(L"Unable to prepare SQLite statement."); |
138 } |
138 } |
139 |
139 |
|
140 void transactionBegin() { |
|
141 sqlite3_exec(db, "BEGIN", nullptr, nullptr, nullptr); |
|
142 } |
|
143 |
|
144 void transactionCommit() { |
|
145 sqlite3_exec(db, "COMMIT", nullptr, nullptr, nullptr); |
|
146 } |
|
147 |
|
148 void transactionRollback() { |
|
149 sqlite3_exec(db, "ROLLBACK", nullptr, nullptr, nullptr); |
|
150 } |
|
151 |
140 }; |
152 }; |
141 |
153 |
142 class SqlHandler : public RelationalReaderValueHandler { |
154 class SqlHandler : public RelationalReaderValueHandler { |
143 private: |
155 private: |
144 Configuration configuration; |
156 Configuration configuration; |
246 } else { |
258 } else { |
247 file = ":memory:"; |
259 file = ":memory:"; |
248 } |
260 } |
249 |
261 |
250 connection.reset(new Connection(file.c_str())); |
262 connection.reset(new Connection(file.c_str())); |
|
263 connection->transactionBegin(); |
251 } |
264 } |
252 |
265 |
253 virtual ~SqlHandler() { |
266 virtual ~SqlHandler() { |
254 } |
267 } |
255 |
268 |
333 // process optional SQL input |
346 // process optional SQL input |
334 processSqlInput(configuration.sqlAfterRelational); |
347 processSqlInput(configuration.sqlAfterRelational); |
335 |
348 |
336 // pass-through some relations: |
349 // pass-through some relations: |
337 for (const CopyRelations& copy : configuration.copyRelations) copyRelations(copy); |
350 for (const CopyRelations& copy : configuration.copyRelations) copyRelations(copy); |
|
351 |
|
352 connection->transactionCommit(); |
338 |
353 |
339 // delete or keep the file: |
354 // delete or keep the file: |
340 if (configuration.file.size()) { |
355 if (configuration.file.size()) { |
341 if (configuration.keepFile == KeepFile::Never || (configuration.keepFile == KeepFile::Automatic && !fileAlreadyExisted)) { |
356 if (configuration.keepFile == KeepFile::Never || (configuration.keepFile == KeepFile::Automatic && !fileAlreadyExisted)) { |
342 std::wcerr << L"will unlink file" << std::endl; |
357 std::wcerr << L"will unlink file" << std::endl; |