diff --git a/cli/app.rs b/cli/app.rs index ee432f55d..ff07aa08c 100644 --- a/cli/app.rs +++ b/cli/app.rs @@ -1103,6 +1103,18 @@ impl Limbo { db_display_name: &str, table_name: &str, ) -> anyhow::Result { + // Yeah, sqlite also has this hardcoded: https://github.com/sqlite/sqlite/blob/31efe5a0f2f80a263457a1fc6524783c0c45769b/src/shell.c.in#L10765 + match table_name { + "sqlite_master" | "sqlite_schema" | "sqlite_temp_master" | "sqlite_temp_schema" => { + let schema = format!( + "CREATE TABLE {} (\n type text,\n name text,\n tbl_name text,\n rootpage integer,\n sql text\n);", + table_name + ); + let _ = self.writeln(&schema); + return Ok(true); + } + _ => {} + } let sql = format!( "SELECT sql, type, name FROM {db_prefix}.sqlite_schema WHERE type IN ('table', 'index', 'view') AND (tbl_name = '{table_name}' OR name = '{table_name}') AND name NOT LIKE 'sqlite_%' AND name NOT LIKE '__turso_internal_%' ORDER BY CASE type WHEN 'table' THEN 1 WHEN 'view' THEN 2 WHEN 'index' THEN 3 END, rowid" );