1 | //===----------------------------------------------------------------------===// |
---|---|
2 | // DuckDB |
3 | // |
4 | // duckdb/transaction/transaction_manager.hpp |
5 | // |
6 | // |
7 | //===----------------------------------------------------------------------===// |
8 | |
9 | #pragma once |
10 | |
11 | #include "duckdb/catalog/catalog_set.hpp" |
12 | #include "duckdb/common/common.hpp" |
13 | #include "duckdb/common/mutex.hpp" |
14 | #include "duckdb/common/vector.hpp" |
15 | |
16 | #include "duckdb/common/atomic.hpp" |
17 | |
18 | namespace duckdb { |
19 | |
20 | class AttachedDatabase; |
21 | class ClientContext; |
22 | class Catalog; |
23 | struct ClientLockWrapper; |
24 | class DatabaseInstance; |
25 | class Transaction; |
26 | |
27 | //! The Transaction Manager is responsible for creating and managing |
28 | //! transactions |
29 | class TransactionManager { |
30 | public: |
31 | explicit TransactionManager(AttachedDatabase &db); |
32 | virtual ~TransactionManager(); |
33 | |
34 | //! Start a new transaction |
35 | virtual Transaction *StartTransaction(ClientContext &context) = 0; |
36 | //! Commit the given transaction. Returns a non-empty error message on failure. |
37 | virtual string CommitTransaction(ClientContext &context, Transaction *transaction) = 0; |
38 | //! Rollback the given transaction |
39 | virtual void RollbackTransaction(Transaction *transaction) = 0; |
40 | |
41 | virtual void Checkpoint(ClientContext &context, bool force = false) = 0; |
42 | |
43 | static TransactionManager &Get(AttachedDatabase &db); |
44 | |
45 | virtual bool IsDuckTransactionManager() { |
46 | return false; |
47 | } |
48 | |
49 | AttachedDatabase &GetDB() { |
50 | return db; |
51 | } |
52 | |
53 | protected: |
54 | //! The attached database |
55 | AttachedDatabase &db; |
56 | }; |
57 | |
58 | } // namespace duckdb |
59 |