{"record":{"id":"f2bbdb5a2ab4ae27","repo":"NationalSecurityAgency/ghidra","slug":"did-not-get-exetable-sequence-number-after-inserti","errorCode":null,"errorMessage":"Did not get exetable sequence number after insertion","messagePattern":"Did not get exetable sequence number after insertion","errorType":"exception","errorClass":"SQLException","httpStatus":null,"severity":"error","filePath":"Ghidra/Features/BSim/src/main/java/ghidra/features/bsim/query/client/tables/ExeTable.java","lineNumber":586,"sourceCode":"\t\tlong repo_id = repositorytable.writeString(erec.getRepository());\n\t\tlong path_id = pathtable.writeString(erec.getPath());\n\t\tlong milli = erec.getDate().getTime();\n\n\t\tOffsetDateTime odt =\n\t\t\tOffsetDateTime.ofInstant(Instant.ofEpochMilli(milli), ZoneId.systemDefault());\n\n\t\ts.setString(1, erec.getMd5());\n\t\ts.setString(2, erec.getNameExec());\n\t\ts.setInt(3, (int) arch_id);\n\t\ts.setInt(4, (int) compiler_id);\n\t\ts.setObject(5, odt);\n\t\ts.setInt(6, (int) repo_id);\n\t\ts.setInt(7, (int) path_id);\n\n\t\ts.executeUpdate();\n\t\ttry (ResultSet rs = s.getGeneratedKeys()) {\n\t\t\tif (!rs.next()) {\n\t\t\t\tthrow new SQLException(\"Did not get exetable sequence number after insertion\");\n\t\t\t}\n\t\t\tlong rowid = rs.getLong(1);\n\t\t\treturn rowid;\n\t\t}\n\t}\n\n\t/**\n\t * Updates records in the database with information in the given {@link ExecutableRecord}.\n\t * \n\t * @param rec the executable record to update\n\t * @throws SQLException if there is a problem creating or executing the query\n\t */\n\tpublic void updateExecutable(ExecutableRecord.Update rec) throws SQLException {\n\t\tif (rec.architecture || rec.date || rec.name_compiler || rec.name_exec || rec.path ||\n\t\t\trec.repository) {\n\n\t\t\ttry (Statement st = db.createStatement()) {\n\t\t\t\tStringBuilder buf = new StringBuilder();","sourceCodeStart":568,"sourceCodeEnd":604,"githubUrl":"https://github.com/NationalSecurityAgency/ghidra/blob/d5f144c24d6bc53c9cbf4448c6d11143e7696206/Ghidra/Features/BSim/src/main/java/ghidra/features/bsim/query/client/tables/ExeTable.java#L568-L604","documentation":"Thrown by ExeTable after inserting a new executable row when getGeneratedKeys() returns an empty result set. The insert statement (with RETURN_GENERATED_KEYS) succeeded but the driver did not return the auto-generated sequence key, so the new row's id cannot be determined. Same class of driver/config issue as error 807 but for the exetable.","triggerScenarios":"Inserting an ExecutableRecord via the exetable INSERT path on a database/driver that does not support generated keys, or where exetable's id column is not auto-increment. The seven-column insert (md5, name, arch, compiler, date, repo, path) runs but key retrieval yields nothing.","commonSituations":"JDBC driver or database mode lacking RETURN_GENERATED_KEYS support. Exetable schema missing a serial/identity id column. Driver version mismatch. Custom BSim database wrapper that swallows generated keys.","solutions":["Ensure exetable has an auto-increment/serial primary key and the driver supports generated keys.","Update the JDBC driver to a compatible version.","Verify the BSim database layout created the exetable id as a generated identity column.","As a fallback, query the sequence/CURRENT_VALUE after insert if generated keys are unsupported."],"exampleFix":null,"handlingStrategy":"validation","validationCode":"// Verify generated-key support before inserting executables.\nDatabaseMetaData md = db.getConnection().getMetaData();\nif (!md.supportsGetGeneratedKeys()) {\n    throw new IllegalStateException(\"Driver lacks generated-key support; cannot insert executable\");\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Ensure exetable has a serial/identity id column.","Use a compatible JDBC driver version.","Validate the BSim database layout created an identity id column."],"tags":["bsim","database","insert","generated-keys","jdbc","sql-exception"],"backgroundTag":null,"analyzedSha":"d5f144c24d6bc53c9cbf4448c6d11143e7696206","analyzedAt":"2026-08-14T01:00:57.564Z","schemaVersion":2},"datasetVersion":"2026-08-14T05:17:29.042Z"}