{"record":{"id":"f73ad38a20e6efcb","repo":"NationalSecurityAgency/ghidra","slug":"problem-deleting-executable-record","errorCode":null,"errorMessage":"Problem deleting executable record","messagePattern":"Problem deleting executable record","errorType":"exception","errorClass":"SQLException","httpStatus":null,"severity":"critical","filePath":"Ghidra/Features/BSim/src/main/java/ghidra/features/bsim/query/client/tables/ExeTable.java","lineNumber":140,"sourceCode":"\n\t@Override\n\tpublic void create(Statement st) throws SQLException {\n\t\tst.executeUpdate(CREATE_STMT);\n\t}\n\n\t@Override\n\tpublic void drop(Statement st) throws SQLException {\n\t\tthrow new UnsupportedOperationException(\"ExeTable may not be dropped\");\n\t}\n\n\t@Override\n\tpublic int delete(long id) throws SQLException {\n\t\tint rowcount = super.delete(id);\n\t\tif (rowcount == 0) {\n\t\t\tthrow new SQLException(\"Could not delete executable record\");\n\t\t}\n\t\tif (rowcount > 1) {\n\t\t\tthrow new SQLException(\"Problem deleting executable record\");\n\t\t}\n\t\treturn rowcount;\n\t}\n\n\t/**\n\t * Pulls information out of the given {@link ExecutableRow} object into the given\n\t * {@link ResultSet}\n\t * \n\t * @param pgres the result set\n\t * @param res the executable row\n\t * @throws SQLException if there is a problem parsing the result set\n\t */\n\tprotected static void extractExecutableRow(ResultSet pgres, ExecutableRow res)\n\t\tthrows SQLException {\n\t\tres.rowid = pgres.getInt(1);\n\t\tres.md5 = pgres.getString(2);\n\t\tres.exename = pgres.getString(3);\n\t\tres.arch_id = pgres.getInt(4);","sourceCodeStart":122,"sourceCodeEnd":158,"githubUrl":"https://github.com/NationalSecurityAgency/ghidra/blob/d5f144c24d6bc53c9cbf4448c6d11143e7696206/Ghidra/Features/BSim/src/main/java/ghidra/features/bsim/query/client/tables/ExeTable.java#L122-L158","documentation":"Thrown by ExeTable.delete when super.delete(id) returns a row count greater than 1, meaning the delete affected multiple rows. Because exetable ids should be unique primary keys, deleting more than one row signals data corruption or a schema/constraint problem where the id is not unique. This is a data-integrity alarm.","triggerScenarios":"Calling delete(id) on an exetable where the id column is not uniquely constrained, so multiple rows share the id. Caused by a corrupted database, a failed/rolled-back migration that left duplicate rows, or a custom table layout that broke the primary-key assumption. The internal code casts id to int for the WHERE clause, so an int-overflow collision could also cause spurious multi-row matches if two distinct long ids truncate to the same int.","commonSituations":"Database corruption producing duplicate primary keys. A botched schema migration. Using a database backend that does not enforce primary-key uniqueness on exetable. Int-overflow if a long id exceeds Integer.MAX_VALUE and is truncated by setInt.","solutions":["Run a database integrity/reindex check on exetable and remove duplicate-id rows.","Verify the exetable id column has a proper unique primary-key constraint enforced by the backend.","If ids exceed Integer.MAX_VALUE, audit the BSim database for very large row ids (the setInt cast is a latent bug for huge databases).","Restore from a known-good backup if corruption is severe."],"exampleFix":null,"handlingStrategy":"validation","validationCode":"// Detect duplicate ids before deleting (data-integrity alarm).\n// Run: SELECT id, COUNT(*) FROM exetable GROUP BY id HAVING COUNT(*) > 1\n// If any results, the database is corrupted — do not proceed with delete.","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Enforce unique primary-key constraints on exetable at schema creation.","Run periodic integrity/reindex checks.","Never bypass the database's uniqueness enforcement."],"tags":["bsim","database","delete","data-corruption","duplicate-keys","sql-exception"],"backgroundTag":null,"analyzedSha":"d5f144c24d6bc53c9cbf4448c6d11143e7696206","analyzedAt":"2026-08-14T01:00:57.564Z","schemaVersion":2},"datasetVersion":"2026-08-14T05:17:29.042Z"}