From 7b1b2c897396a348125526235c5b327f883464c7 Mon Sep 17 00:00:00 2001 From: Alex Chi Date: Tue, 24 Oct 2023 21:11:05 -0400 Subject: [PATCH] fix Signed-off-by: Alex Chi --- src/common/bustub_instance.cpp | 4 ++++ test/table/tuple_test.cpp | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/src/common/bustub_instance.cpp b/src/common/bustub_instance.cpp index 58697ccc3..5946d76dc 100644 --- a/src/common/bustub_instance.cpp +++ b/src/common/bustub_instance.cpp @@ -214,9 +214,11 @@ auto BustubInstance::ExecuteSql(const std::string &sql, ResultWriter &writer, try { auto result = ExecuteSqlTxn(sql, writer, txn, std::move(check_options)); txn_manager_->Commit(txn); + delete txn; return result; } catch (bustub::Exception &ex) { txn_manager_->Abort(txn); + delete txn; throw ex; } } @@ -345,6 +347,7 @@ void BustubInstance::GenerateTestTable() { l.unlock(); txn_manager_->Commit(txn); + delete txn; } /** @@ -363,6 +366,7 @@ void BustubInstance::GenerateMockTable() { l.unlock(); txn_manager_->Commit(txn); + delete txn; } BustubInstance::~BustubInstance() { diff --git a/test/table/tuple_test.cpp b/test/table/tuple_test.cpp index ab023ea0a..780559496 100644 --- a/test/table/tuple_test.cpp +++ b/test/table/tuple_test.cpp @@ -43,7 +43,7 @@ TEST(TupleTest, DISABLED_TableHeapTest) { std::vector rid_v; for (int i = 0; i < 5000; ++i) { - auto rid = table->InsertTuple(TupleMeta{INVALID_TXN_ID, INVALID_TXN_ID, false}, tuple); + auto rid = table->InsertTuple(TupleMeta{0, false}, tuple); rid_v.push_back(*rid); }