Delete Statements (also with Where-Clauses)
You can now delete data using the delete from {table} [where {condition}]; syntax, which let’s you optionally have the where part so you can either delete the WHOLE table, or just a part of it.
It was fairly easy, since it’s just combining what happens in a select and using the rows’ primary keys for the delete KEY operation in the storage. This is also a single WriteBatch btw, which is more efficient than N different disk operations for N rows while also giving us atomicity: Either the whole delete operation is committed completely, or nothing.
What still has to happen in the future, is optimizing:
When we delete based on the primary key, or want to drop the whole table, we can implement a range-deletion in the KV-Store, which will let us 1) avoid scanning and filtering and 2) results in not just one batch, but rather one operation, so it’s more compact for storage.
One more thing: I added .clear (or the .c shorthand) in the REPL that clears the screen. Was literally just two lines.
The attachment shows how executing delete works and looks like like in the REPL.
Full diff: https://codeberg.org/Vimthusiast/tempest/compare/b8f10ea...89d9950