{"record":{"id":"ec6bf8958e1716b3","repo":"databendlabs/databend","slug":"internal-error-entered-unreachable-code-ec6bf8","errorCode":null,"errorMessage":"internal error: entered unreachable code","messagePattern":"internal error: entered unreachable code","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src/query/service/src/interpreters/interpreter_mutation.rs","lineNumber":225,"sourceCode":"            PhysicalPlanBuilder::new(mutation.metadata.clone(), self.ctx.clone(), dry_run);\n        builder.set_mutation_build_info(mutation_build_info);\n        builder\n            .build(&self.s_expr, *mutation.required_columns.clone())\n            .await\n    }\n\n    fn get_mutation_table_result(&self) -> Result<Vec<DataBlock>> {\n        let binding = self.ctx.mutation_state().mutation_status();\n        let status = binding.read().unwrap();\n        let mut columns = Vec::new();\n        for field in self.schema.as_ref().fields() {\n            match field.name().as_str() {\n                plans::INSERT_NAME => columns.push(UInt64Type::from_data(vec![status.insert_rows])),\n                plans::UPDATE_NAME => columns.push(UInt64Type::from_data(vec![status.update_rows])),\n                plans::DELETE_NAME => {\n                    columns.push(UInt64Type::from_data(vec![status.deleted_rows]))\n                }\n                _ => unreachable!(),\n            }\n        }\n        Ok(vec![DataBlock::new_from_columns(columns)])\n    }\n}\n\npub async fn build_mutation_info(\n    ctx: Arc<QueryContext>,\n    mutation: &Mutation,\n    dry_run: bool,\n    materialized_view_refresh_target: Option<u64>,\n) -> Result<MutationBuildInfo> {\n    let table = ctx\n        .get_table(\n            &mutation.catalog_name,\n            &mutation.database_name,\n            &mutation.table_name,\n        )","sourceCodeStart":207,"sourceCodeEnd":243,"githubUrl":"https://github.com/databendlabs/databend/blob/288d84d76e20a2f8f7173bda9691eb6ece301aa9/src/query/service/src/interpreters/interpreter_mutation.rs#L207-L243","documentation":"get_mutation_table_result builds a summary DataBlock for mutation results and maps each mutation plan kind (INSERT/UPDATE/DELETE) to a row-count column. Any plan name outside those three constants is treated as impossible and hits an `unreachable!()`, panicking with \"internal error: entered unreachable code\". It signals that a mutation plan variant reached result aggregation without a defined row-count mapping.","triggerScenarios":"inject_result is called with a mutation status whose plan name is not one of plans::INSERT_NAME, plans::UPDATE_NAME, or plans::DELETE_NAME — i.e. a new Mutation/InsertPlan variant (e.g. a REPLACE or MERGE-like plan) is executed but was not registered in this match.","commonSituations":"Running a freshly added DML statement type on an engine build that still maps only the classic three mutation kinds; internal version skew after adding a new mutation plan without updating the result interpreter.","solutions":["Check which mutation plan name reached get_mutation_table_result (add the name to the panic or log it).","Add a match arm for the new plan kind that pushes its row-count column.","Audit all creators of Mutation plan nodes to ensure their plan names are covered.","Pin/query on a release where only INSERT/UPDATE/DELETE mutation plans exist if you hit this at runtime."],"exampleFix":"// before\n_ => unreachable!(),\n// after\nother => {\n    columns.push(UInt64Type::from_data(vec![0]));\n    tracing::warn!(\"unhandled mutation plan {} in mutation result\", other);\n}","handlingStrategy":"validation","validationCode":"// Before executing a mutation, confirm its plan kind is one of the supported ones\nassert!(matches!(plan_name.as_str(), \"insert\" | \"update\" | \"delete\"),\n    \"unsupported mutation plan: {}\", plan_name);","typeGuard":"fn is_supported_mutation(name: &str) -> bool {\n    matches!(name, plans::INSERT_NAME | plans::UPDATE_NAME | plans::DELETE_NAME)\n}","tryCatchPattern":null,"preventionTips":["When adding a new mutation plan variant, grep for matches on INSERT_NAME/UPDATE_NAME/DELETE_NAME and update all arms","Add a unit test in the interpreter that iterates every mutation plan variant","Prefer returning ErrorCode::Internal over unreachable! for planner-facing code"],"tags":["rust","unreachable","internal-error"],"backgroundTag":"internal-invariant-violation","analyzedSha":"288d84d76e20a2f8f7173bda9691eb6ece301aa9","analyzedAt":"2026-09-11T11:29:36.208Z","contentChangedAt":"2026-09-11T11:29:36.208Z","schemaVersion":2},"datasetVersion":"2026-09-16T04:17:20.429Z"}