In SQLite, when [AUTOVACUUM](https://www.sqlite.org/lang_vacuum.html) is
enabled (in SQLite, the `SQLITE_OMIT_AUTOVACUUM` flag is used), and a
table is dropped, if the root page of the table is destroyed and *it is
not the last page*, then the last root page is transferred here to avoid
empty gaps.
At this point, the old root page value is copied into a register and
SQLite will copy over all rows using the old root page from the schema
table into an ephemeral table. Later, it copies over the rows from the
ephemeral table back into the schema table with the new root page number
to "patch" the row.
This PR introduces the same semantics to Limbo. It doesn't perform the
AUTOVACUUM functionality of moving the last root page into the empty
page currently, so it no-ops that by returning 0. This triggers an
`IfNot` instruction to skip the inserts into the ephemeral table.
I plan to address the auto vacuuming in a future PR. But this brings us
a lot closer to matching SQLite semantics.

Closes#1548
this commit changes the btree_destroy() signature to return an Option<usize>. This more closely resembles Rust semantics instead of passing a pointer to a usize.
However, I'm unsure if I'm handling the cursor result correctly
this commit addresses comments regarding using decsriptive variable names for the loops and loop labels. Also, adds documentation for instructions that cause jumps in both loops
Earlier this test broke because the code to translate the drop table was not checking to see if a table was not a virtual table.
SQLite does this with a macro called IsVirtualTable. Here, I check with the existing methods on the BTree struct
Now when dropping a table, an ephemeral table is created as a scratch table. If a root page of some other table is moved into the page occupied by the root page of the table being dropped, that row is first written into an ephemeral table. Then on a next pass, it is deleted from the schema table and then re-inserted with the new root page.
This happens during AUTOVACUUM when deleting a root page will force the last root page to move into the slot being vacated by the root page of the table being deleted
This PR introduces some modifications to the Program Builder to allow us
to use nested parsing. By focusing the emission of Init and the last
Goto (prologue and epilogue), inside the ProgramBuilder, we can just not
emit them if we are parsing/translating in a nested context. For this
PR, I only migrated insert to use these functions as I need them to
support Insert statements that use `SELECT FROM` syntax. Nested parsing
overall enables code reuse for us and arguably is one of the only ways
to parse deeply nested queries without a lot of code duplication.
#1528Closes#1543
This PR builds on top of
https://github.com/tursodatabase/limbo/pull/1368 and adds few things
like allowing inserting pages with the same page key, fix fuzz tests by
adding transactions and some minor improvements to cacheflush.
Closes#1523
This PR adds a port of [SQLite's CSV virtual table
extension](https://www.sqlite.org/csv.html).
Planned follow-ups:
* Pass detailed error messages from `VTabModule::create`, not just
`ResultCode`s.
* Address the TODO in `VTabModuleImpl::create_schema`.
Reviewed-by: Jussi Saurio <jussi.saurio@gmail.com>
Closes#1544
I was trying to run the TPC-H 9.sql in the CLI, but it kept truncating
my input due to a comment that is present in the query. After removing
it, I can just copy and paste the query and it works. @PThorpe92 is it
safe to remove this? Or is there a particular reason that was included
that I am not aware of?
Closes#1525