NationalSecurityAgency/ghidra · error · SQLException

Did not get exetable sequence number after insertion

Error message

Did not get exetable sequence number after insertion

What it means

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.

Source

Thrown at Ghidra/Features/BSim/src/main/java/ghidra/features/bsim/query/client/tables/ExeTable.java:586

		long repo_id = repositorytable.writeString(erec.getRepository());
		long path_id = pathtable.writeString(erec.getPath());
		long milli = erec.getDate().getTime();

		OffsetDateTime odt =
			OffsetDateTime.ofInstant(Instant.ofEpochMilli(milli), ZoneId.systemDefault());

		s.setString(1, erec.getMd5());
		s.setString(2, erec.getNameExec());
		s.setInt(3, (int) arch_id);
		s.setInt(4, (int) compiler_id);
		s.setObject(5, odt);
		s.setInt(6, (int) repo_id);
		s.setInt(7, (int) path_id);

		s.executeUpdate();
		try (ResultSet rs = s.getGeneratedKeys()) {
			if (!rs.next()) {
				throw new SQLException("Did not get exetable sequence number after insertion");
			}
			long rowid = rs.getLong(1);
			return rowid;
		}
	}

	/**
	 * Updates records in the database with information in the given {@link ExecutableRecord}.
	 * 
	 * @param rec the executable record to update
	 * @throws SQLException if there is a problem creating or executing the query
	 */
	public void updateExecutable(ExecutableRecord.Update rec) throws SQLException {
		if (rec.architecture || rec.date || rec.name_compiler || rec.name_exec || rec.path ||
			rec.repository) {

			try (Statement st = db.createStatement()) {
				StringBuilder buf = new StringBuilder();

View on GitHub (pinned to d5f144c24d)

Solutions

  1. Ensure exetable has an auto-increment/serial primary key and the driver supports generated keys.
  2. Update the JDBC driver to a compatible version.
  3. Verify the BSim database layout created the exetable id as a generated identity column.
  4. As a fallback, query the sequence/CURRENT_VALUE after insert if generated keys are unsupported.
Defensive patterns

Strategy: validation

Validate before calling

// Verify generated-key support before inserting executables.
DatabaseMetaData md = db.getConnection().getMetaData();
if (!md.supportsGetGeneratedKeys()) {
    throw new IllegalStateException("Driver lacks generated-key support; cannot insert executable");
}

Prevention

When it happens

Trigger: 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.

Common situations: 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.

Related errors


AI-assisted analysis of NationalSecurityAgency/ghidra@d5f144c24d (2026-08-14). Data as JSON: /api/errors/f2bbdb5a2ab4ae27. Report an issue: GitHub.