{"record":{"id":"bab115facb4fb551","repo":"tursodatabase/turso","slug":"name-virtual-table-creation-should-not-fail","errorCode":null,"errorMessage":"{name} virtual table creation should not fail","messagePattern":"(.+?) virtual table creation should not fail","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"critical","filePath":"postgres/frontend/catalog.rs","lineNumber":1510,"sourceCode":"        _idx_num: i32,\n    ) -> Result<bool, LimboError> {\n        Ok(false)\n    }\n}\n\nfn empty_catalog_table(name: &str, create_sql: &str) -> Arc<VirtualTable> {\n    let table = EmptyPgCatalogTable {\n        name: name.to_string(),\n        create_sql: create_sql.to_string(),\n    };\n    Arc::new(\n        VirtualTable::new_internal(\n            name.to_string(),\n            table.sql(),\n            VTabKind::VirtualTable,\n            Arc::new(RwLock::new(table)),\n        )\n        .unwrap_or_else(|_| panic!(\"{name} virtual table creation should not fail\")),\n    )\n}\n\n/// Virtual table implementation for pg_tables\n/// Maps user tables to PostgreSQL's pg_tables view\n#[derive(Debug)]\npub struct PgTablesTable;\n\nimpl PgTablesTable {\n    pub fn new() -> Self {\n        Self\n    }\n}\n\nimpl InternalVirtualTable for PgTablesTable {\n    fn name(&self) -> String {\n        \"pg_tables\".to_string()\n    }","sourceCodeStart":1492,"sourceCodeEnd":1528,"githubUrl":"https://github.com/tursodatabase/turso/blob/244cde92a7df7f9b8b8b7a4075c35a12977e303e/postgres/frontend/catalog.rs#L1492-L1528","documentation":"The PostgreSQL frontend builds its static catalog (pg_tables, pg_class, etc.) by constructing VirtualTables from hardcoded module definitions via VirtualTable::new_internal and asserts success — the embedded CREATE SQL and module registration are expected to always parse and construct. The panic means one of the built-in catalog vtabs failed to construct: the shipped SQL/constructor is incompatible with the current parser or vtab API. It aborts frontend startup.","triggerScenarios":"Starting the postgres-frontend server in a build where VirtualTable::new_internal rejects a catalog table's SQL — version skew between postgres/frontend/catalog.rs and the parser/extensions, stale partial builds, or feature-flag combinations (e.g. cli_only) changing vtab registration behavior.","commonSituations":"Partial or mixed-version workspace builds; forks that modified the parser grammar or VirtualTable::new_internal; experimental feature combos not covered by CI.","solutions":["Do a clean full-workspace build (cargo clean && cargo build) to rule out stale artifacts and version skew","Report immediately with the exact commit and feature flags — a stock build must start; include the catalog table name from the panic","Verify the feature set used for the postgres frontend matches CI; drop experimental combos","If maintaining a fork, replace unwrap_or_else(panic) temporarily to print the underlying error from new_internal and fix that mismatch"],"exampleFix":"// contributor fix: surface the real cause instead of a bare assertion\nlet table = VirtualTable::new_internal(\n    name.to_string(),\n    table.sql(),\n    VTabKind::VirtualTable,\n    Arc::new(RwLock::new(table)),\n)\n.unwrap_or_else(|e| panic!(\"{name} virtual table creation failed: {e:?}\"));","handlingStrategy":"validation","validationCode":"// startup smoke test: every built-in catalog vtab must construct before serving traffic\n#[test]\nfn pg_catalog_tables_construct() {\n    for (name, sql) in builtin_catalog_definitions() {\n        let module = empty_module_for(name);\n        assert!(\n            VirtualTable::new_internal(name.into(), sql, VTabKind::VirtualTable, module).is_ok(),\n            \"catalog table {name} failed to construct\"\n        );\n    }\n}","typeGuard":null,"tryCatchPattern":"// isolate catalog init so a failure is a diagnosable startup error, not a raw panic\ncatalog = std::panic::catch_unwind(build_catalog)\n    .map_err(|payload| format!(\"pg catalog init failed: {payload:?}\"))?;","preventionTips":["Run the pg-frontend startup smoke test in CI with the exact feature matrix you ship","Clean full workspace builds when switching versions or forks","Do not enable experimental feature combos without the matching catalog construction test"],"tags":["postgres","virtual-table","catalog","startup","panic","initialization"],"backgroundTag":"virtual-table-initialization-failure","analyzedSha":"244cde92a7df7f9b8b8b7a4075c35a12977e303e","analyzedAt":"2026-08-20T07:02:18.389Z","contentChangedAt":"2026-08-20T07:02:18.389Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}