{"record":{"id":"eecc390a1808e22d","repo":"tursodatabase/turso","slug":"error-querying-schema","errorCode":null,"errorMessage":"Error querying schema: {}","messagePattern":"Error querying schema: (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"cli/app.rs","lineNumber":1661,"sourceCode":"                ),\n                None => format!(\"SELECT name FROM {name}.sqlite_schema WHERE type='index' ORDER BY 1\"),\n            };\n            let handler = |row: &turso_core::Row| {\n                if let Ok(Value::Text(idx)) = row.get::<&Value>(0) {\n                    if let Some(prefix) = prefix {\n                        indexes.push_str(prefix);\n                        indexes.push('.');\n                    }\n                    indexes.push_str(idx.as_str());\n                    indexes.push(' ');\n                }\n                Ok(())\n            };\n            if let Err(err) = self.handle_row(&sql, handler) {\n                if err.to_string().contains(\"no such table: sqlite_schema\") {\n                    return Err(anyhow::anyhow!(\"Unable to access database schema. The database may be using an older SQLite version or may not be properly initialized.\"));\n                } else {\n                    return Err(anyhow::anyhow!(\"Error querying schema: {}\", err));\n                }\n            }\n        }\n        if !indexes.is_empty() {\n            let _ = self.writeln(indexes.trim_end().as_bytes());\n        }\n        Ok(())\n    }\n\n    fn display_tables(&mut self, pattern: Option<&str>) -> anyhow::Result<()> {\n        let mut tables = String::new();\n\n        for name in self.database_names()? {\n            let prefix = (name != \"main\").then_some(&name);\n            let sql = match pattern {\n                Some(pattern) => format!(\n                    \"SELECT name FROM {name}.sqlite_schema WHERE type in ('table', 'view') AND name NOT LIKE 'sqlite_%' AND name LIKE '{pattern}' ORDER BY 1\"\n                ),","sourceCodeStart":1643,"sourceCodeEnd":1679,"githubUrl":"https://github.com/tursodatabase/turso/blob/492c4a71cd7c2649e7df83da1471b74f4b1c7aa9/cli/app.rs#L1643-L1679","documentation":"Generic wrapper thrown while listing indexes: the query against sqlite_schema failed with something other than the recognized 'no such table: sqlite_schema' error, so the original error is chained into 'Error querying schema' (cli/app.rs:1651). The underlying cause is visible in the message.","triggerScenarios":".indexes (or a prefixed .indexes db.pattern) while the schema query fails for a non-schema-missing reason: corrupt header, I/O error reading page 1, interrupted statement, or an engine-level failure preparing the query.","commonSituations":"Database file truncated or corrupted mid-session; storage I/O errors on network mounts; engine regressions in preparing a simple SELECT from sqlite_schema.","solutions":["Read the chained error text - it names the underlying LimboError","Run SELECT name FROM sqlite_schema WHERE type='index' manually to reproduce","Run PRAGMA integrity_check to rule out corruption","Reopen the database file; if the error persists, capture it and report with the file's header info"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"if let Err(e) = app.list_indexes(None) {\n    if !e.to_string().contains(\"Unable to access database schema\") {\n        return Err(e); // real I/O or corruption problem, not a legacy/empty db\n    }\n}","preventionTips":["Distinguish the legacy-schema case from real failures before reporting","Run PRAGMA integrity_check after unclean shutdowns","Keep database files on reliable storage; I/O errors surface here as chained causes"],"tags":["cli","schema","indexes","query-wrapper","rust"],"backgroundTag":"metadata-query-failed","analyzedSha":"492c4a71cd7c2649e7df83da1471b74f4b1c7aa9","analyzedAt":"2026-08-20T07:02:18.389Z","contentChangedAt":"2026-08-20T07:02:18.389Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}