diff options
author | Boris Kolpackov <boris@codesynthesis.com> | 2021-04-29 11:55:45 +0200 |
---|---|---|
committer | Boris Kolpackov <boris@codesynthesis.com> | 2021-04-30 10:07:08 +0200 |
commit | fa3f14db14671b4c37c400880d097b17aa12b824 (patch) | |
tree | 6b516f01505cd743c01d714329068fcd56233f73 /odb/sqlite/connection.cxx | |
parent | 2c15821eb8a9d6a7f79b7194b23d84dd8bb773c7 (diff) |
Move begin/commit/rollback statements to connection
Diffstat (limited to 'odb/sqlite/connection.cxx')
-rw-r--r-- | odb/sqlite/connection.cxx | 46 |
1 files changed, 46 insertions, 0 deletions
diff --git a/odb/sqlite/connection.cxx b/odb/sqlite/connection.cxx index cdd4c20..57ce860 100644 --- a/odb/sqlite/connection.cxx +++ b/odb/sqlite/connection.cxx @@ -25,6 +25,8 @@ odb_sqlite_connection_unlock_callback (void**, int); namespace odb { + using namespace details; + namespace sqlite { connection:: @@ -105,6 +107,12 @@ namespace odb db.foreign_keys () ? 22 : 23); st.execute (); + // String lengths include '\0', as per the SQLite manual suggestion. + // + begin_.reset (new (shared) generic_statement (*this, "BEGIN", 6)); + commit_.reset (new (shared) generic_statement (*this, "COMMIT", 7)); + rollback_.reset (new (shared) generic_statement (*this, "ROLLBACK", 9)); + // Create statement cache. // statement_cache_.reset (new statement_cache_type (*this)); @@ -119,6 +127,44 @@ namespace odb clear_prepared_map (); } + generic_statement& connection:: + begin_statement () + { + return static_cast<generic_statement&> (*begin_); + } + + generic_statement& connection:: + begin_immediate_statement () + { + if (!begin_immediate_) + begin_immediate_.reset ( + new (shared) generic_statement (*this, "BEGIN IMMEDIATE", 16)); + + return static_cast<generic_statement&> (*begin_immediate_); + } + + generic_statement& connection:: + begin_exclusive_statement () + { + if (!begin_exclusive_) + begin_exclusive_.reset ( + new (shared) generic_statement (*this, "BEGIN EXCLUSIVE", 16)); + + return static_cast<generic_statement&> (*begin_exclusive_); + } + + generic_statement& connection:: + commit_statement () + { + return static_cast<generic_statement&> (*commit_); + } + + generic_statement& connection:: + rollback_statement () + { + return static_cast<generic_statement&> (*rollback_); + } + transaction_impl* connection:: begin () { |