Kùzu C++ API
Loading...
Searching...
No Matches
transaction_context.h
Go to the documentation of this file.
1#pragma once
2
3#include <mutex>
4
5#include "transaction.h"
6
7namespace kuzu {
8namespace main {
9class ClientContext;
10}
11
12namespace transaction {
13
30enum class TransactionMode : uint8_t { AUTO = 0, MANUAL = 1 };
31
33public:
34 explicit TransactionContext(main::ClientContext& clientContext);
36
37 bool isAutoTransaction() const { return mode == TransactionMode::AUTO; }
38
41 void beginAutoTransaction(bool readOnlyStatement);
43 void validateManualTransaction(bool readOnlyStatement) const;
44
45 void commit();
46 void rollback();
47
48 TransactionMode getTransactionMode() const { return mode; }
49 bool hasActiveTransaction() const { return activeTransaction != nullptr; }
50 Transaction* getActiveTransaction() const { return activeTransaction.get(); }
51
52private:
53 void clearTransaction();
54
55private:
56 void beginTransactionInternal(TransactionType transactionType);
57
58private:
59 std::mutex mtx;
60 main::ClientContext& clientContext;
61 TransactionMode mode;
62 // TODO(Guodong): Should hold a raw pointer. Move ownership to TransactionManager.
63 std::unique_ptr<Transaction> activeTransaction;
64};
65
66} // namespace transaction
67} // namespace kuzu
#define KUZU_API
Definition api.h:25
Contain client side configuration. We make profiler associated per query, so profiler is not maintain...
Definition client_context.h:61
Definition transaction_context.h:32
bool isAutoTransaction() const
Definition transaction_context.h:37
bool hasActiveTransaction() const
Definition transaction_context.h:49
TransactionContext(main::ClientContext &clientContext)
Transaction * getActiveTransaction() const
Definition transaction_context.h:50
void validateManualTransaction(bool readOnlyStatement) const
void beginAutoTransaction(bool readOnlyStatement)
TransactionMode getTransactionMode() const
Definition transaction_context.h:48
Definition transaction.h:31
TransactionType
Definition transaction.h:29
TransactionMode
Definition transaction_context.h:30
Definition array_utils.h:7