From 8f578447240417d1f87bdb5a5a4d96880484bddf Mon Sep 17 00:00:00 2001 From: Alex Chi Date: Thu, 9 Nov 2023 15:48:37 -0500 Subject: [PATCH] p3: check commit success and explain full q1 Signed-off-by: Alex Chi --- src/common/bustub_instance.cpp | 4 +++- test/sql/p3.leaderboard-q1-window.slt | 12 +++++++----- 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/src/common/bustub_instance.cpp b/src/common/bustub_instance.cpp index 58697ccc3..7078c2865 100644 --- a/src/common/bustub_instance.cpp +++ b/src/common/bustub_instance.cpp @@ -213,7 +213,9 @@ auto BustubInstance::ExecuteSql(const std::string &sql, ResultWriter &writer, auto *txn = txn_manager_->Begin(); try { auto result = ExecuteSqlTxn(sql, writer, txn, std::move(check_options)); - txn_manager_->Commit(txn); + if (!txn_manager_->Commit(txn)) { + throw Exception("failed to commit txn"); + } return result; } catch (bustub::Exception &ex) { txn_manager_->Abort(txn); diff --git a/test/sql/p3.leaderboard-q1-window.slt b/test/sql/p3.leaderboard-q1-window.slt index 4b5025241..ca669e0dc 100644 --- a/test/sql/p3.leaderboard-q1-window.slt +++ b/test/sql/p3.leaderboard-q1-window.slt @@ -1,8 +1,10 @@ statement ok -explain (o) select x, y from ( - select x, y, rank() over (partition by x order by y) as rank - from __mock_t9 -) where rank <= 3; +explain (o) select * from ( + select x, y from ( + select x, y, rank() over (partition by x order by y) as rank + from __mock_t9 + ) where rank <= 3 +) order by y limit 10; query nosort +timing:x10:.q1 select * from ( @@ -21,4 +23,4 @@ select * from ( 998 5005001 998 5005001 998 5005002 -998 5005002 \ No newline at end of file +998 5005002