turso-cli
turso-cli copied to clipboard
There's nothing stopping people from dropping internal tables
I don't know if this is the right repo for this issue, apologies if this is wrong.
→ select * from sqlite_schema;
TYPE NAME TBL_NAME ROOTPAGE SQL
table libsql_wasm_func_table libsql_wasm_func_table 2 CREATE TABLE libsql_wasm_func_table (name text PRIMARY KEY, body text) WITHOUT ROWID
table _litestream_seq _litestream_seq 3 CREATE TABLE _litestream_seq (id INTEGER PRIMARY KEY, seq INTEGER)
table _litestream_lock _litestream_lock 4 CREATE TABLE _litestream_lock (id INTEGER)
→ drop table libsql_wasm_func_table;
→ drop table _litestream_seq;
→ drop table _litestream_lock;
→ select * from sqlite_schema;
TYPE NAME TBL_NAME ROOTPAGE SQL
Did I just do something very bad to this database? If I later create a replica, that db will have libsql_wasm_func_table, and then it reappears at the primary. But the litestream tables seem to be gone permanently.
SQLite stops important tables from being dropped:
→ drop table sqlite_schema;
Error: table sqlite_master may not be dropped
We should probably do the same. Also probably control read/write access on them as appropriate.
I think it's an sqld issue.
@haaawk The main reason why I didn't initially file this under sqld is because I couldn't find any references to "litestream" anywhere in that codebase. I don't know where it comes from.
Fair point. The litestream tables are turso. wasm_func_table is sqld/libsql
sqld could allow marking tables as protected, without protecting any, and then turso-api could, on database creation, protect the ones we care about.