limbo/core/storage
Pekka Enberg b0636e4494 Merge 'Adds Drop Table' from Zaid Humayun
This PR adds support for `DROP TABLE` and addresses issue
https://github.com/tursodatabase/limbo/issues/894
It depends on https://github.com/tursodatabase/limbo/pull/785 being
merged in because it requires the implementation of `free_page`.
EDIT: The PR above has been merged.
It adds the following:
* an implementation for the `DropTable` AST instruction via a method
called `translate_drop_table`
* a couple of new instructions - `Destroy` and `DropTable`. The former
is to modify physical b-tree pages and the latter is to modify in-memory
structures like the schema hash table.
* `btree_destroy` on `BTreeCursor` to walk the tree of pages for this
table and place it in free list.
* state machine traversal for both `btree_destroy` and
`clear_overflow_pages` to ensure performant, correct code.
* unit & tcl tests
* modifies the `Null` instruction to follow SQLite semantics and accept
a second register. It will set all registers in this range to null. This
is required for `DROP TABLE`.
The screenshots below have a comparison of the bytecodes generated via
SQLite & Limbo.
Limbo has the same instruction set except for the subroutines which
involve opening an ephemeral table, copying over the triggers from the
`sqlite_schema` table and then re-inserting them back into the
`sqlite_schema` table.
This is because `OpenEphemeral` is still a WIP and is being tracked at
https://github.com/tursodatabase/limbo/pull/768
![Screenshot 2025-02-09 at 7 05 03 PM](https://github.com/user-
attachments/assets/1d597001-a60c-4a76-89fd-8b90881c77c9)
![Screenshot 2025-02-09 at 7 05 35 PM](https://github.com/user-
attachments/assets/ecfd2a7a-2edc-49cd-a8d1-7b4db8657444)

Reviewed-by: Pere Diaz Bou <pere-altea@homail.com>

Closes #897
2025-03-06 18:27:41 +02:00
..
btree.rs Merge 'Adds Drop Table' from Zaid Humayun 2025-03-06 18:27:41 +02:00
buffer_pool.rs core: Move buffer_pool.rs to storage module 2024-08-01 11:53:14 +03:00
database.rs fix generic and windows sync compilation 2025-03-05 14:07:48 +01:00
mod.rs Minor improvements and cleanups in btree 2025-03-01 15:48:42 -05:00
page_cache.rs rm log, switch all to tracing 2025-02-11 09:03:36 -04:00
pager.rs Make database Sync + Send 2025-03-05 14:07:48 +01:00
sqlite3_ondisk.rs fix clippy arc warnings for now 2025-03-05 14:07:48 +01:00
wal.rs add logs to wal locks 2025-03-05 22:32:59 +01:00