跳到主要内容

Project 4

讲义

Gitbook

简书

视频

博客

Github

实现

Delete

bustub> explain delete from t1 where v1 = 1;
=== BINDER ===
Delete { table=BoundBaseTableRef { table=t1, oid=22 }, expr=(t1.v1=1) }
=== PLANNER ===
Delete { table_oid=22 } | (__bustub_internal.delete_rows:INTEGER)
Filter { predicate=(#0.0=1) } | (t1.v1:INTEGER)
SeqScan { table=t1 } | (t1.v1:INTEGER)
=== OPTIMIZER ===
Delete { table_oid=22 } | (__bustub_internal.delete_rows:INTEGER)
SeqScan { table=t1, filter=(#0.0=1) } | (t1.v1:INTEGER)

Index

CREATE TABLE nft(id INT, terrier INT);
CREATE INDEX nftid ON nft(id);
INSERT INTO nft VALUES (0, 0), (1, 1);
EXPLAIN UPDATE nft SET terrier = 2 WHERE id = 1;
EXPLAIN SELECT * FROM nft WHERE id = 1;
EXPLAIN SELECT * FROM nft;
SELECT * FROM nft WHERE id = 1;

Q&A

1. For an insert operation, what should we locked? The rid is determined after the insert.

You can first insert then lock. This is a long-term bug to be fixed.

2. Halloween problem