| 1 | #include "duckdb/transaction/transaction.hpp" |
|---|---|
| 2 | #include "duckdb/transaction/meta_transaction.hpp" |
| 3 | #include "duckdb/transaction/transaction_manager.hpp" |
| 4 | #include "duckdb/main/client_context.hpp" |
| 5 | |
| 6 | namespace duckdb { |
| 7 | |
| 8 | Transaction::Transaction(TransactionManager &manager_p, ClientContext &context_p) |
| 9 | : manager(manager_p), context(context_p.shared_from_this()), active_query(MAXIMUM_QUERY_ID) { |
| 10 | } |
| 11 | |
| 12 | Transaction::~Transaction() { |
| 13 | } |
| 14 | |
| 15 | bool Transaction::IsReadOnly() { |
| 16 | auto ctxt = context.lock(); |
| 17 | if (!ctxt) { |
| 18 | throw InternalException("Transaction::IsReadOnly() called after client context has been destroyed"); |
| 19 | } |
| 20 | auto &db = manager.GetDB(); |
| 21 | return MetaTransaction::Get(context&: *ctxt).ModifiedDatabase().get() != &db; |
| 22 | } |
| 23 | |
| 24 | } // namespace duckdb |
| 25 |