Skip to content

Commit 1d6ac6d

Browse files
authored
p3: check commit success and explain full q1 (#657)
Signed-off-by: Alex Chi <[email protected]>
1 parent 048f425 commit 1d6ac6d

File tree

2 files changed

+10
-6
lines changed

2 files changed

+10
-6
lines changed

src/common/bustub_instance.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -213,7 +213,9 @@ auto BustubInstance::ExecuteSql(const std::string &sql, ResultWriter &writer,
213213
auto *txn = txn_manager_->Begin();
214214
try {
215215
auto result = ExecuteSqlTxn(sql, writer, txn, std::move(check_options));
216-
txn_manager_->Commit(txn);
216+
if (!txn_manager_->Commit(txn)) {
217+
throw Exception("failed to commit txn");
218+
}
217219
return result;
218220
} catch (bustub::Exception &ex) {
219221
txn_manager_->Abort(txn);

test/sql/p3.leaderboard-q1-window.slt

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
11
statement ok
2-
explain (o) select x, y from (
3-
select x, y, rank() over (partition by x order by y) as rank
4-
from __mock_t9
5-
) where rank <= 3;
2+
explain (o) select * from (
3+
select x, y from (
4+
select x, y, rank() over (partition by x order by y) as rank
5+
from __mock_t9
6+
) where rank <= 3
7+
) order by y limit 10;
68

79
query nosort +timing:x10:.q1
810
select * from (
@@ -21,4 +23,4 @@ select * from (
2123
998 5005001
2224
998 5005001
2325
998 5005002
24-
998 5005002
26+
998 5005002

0 commit comments

Comments
 (0)