NationalSecurityAgency/ghidra · error · SQLException

Error during insertion

Error message

Error during insertion

What it means

Thrown by SQLStringTable.writeNewString after inserting a new string row when getGeneratedKeys() returns an empty result set. The string insert succeeded but the driver did not return the auto-generated id, so the new string's id cannot be returned or cached. Same generated-keys class of failure as errors 807/811, applied to the string table.

Source

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

		s.setString(1, value);
		try (ResultSet rs = s.executeQuery()) {
			if (!rs.next()) {
				return id;
			}
			id = rs.getInt(1);
		}
		insertRecord(id, value);
		return id;
	}

	private long writeNewString(String value) throws SQLException {
		PreparedStatement s = insertStatement.prepareIfNeeded(
			() -> db.prepareStatement(insertSQL, Statement.RETURN_GENERATED_KEYS));
		s.setString(1, value);
		s.executeUpdate();
		try (ResultSet rs = s.getGeneratedKeys()) {
			if (!rs.next()) {
				throw new SQLException("Error during insertion");
			}
			long id = rs.getInt(1);
			insertRecord(id, value);
			return id;
		}
	}

}

View on GitHub (pinned to d5f144c24d)

Solutions

  1. Ensure the stringtable id column is auto-increment/serial and the driver returns generated keys.
  2. Update the JDBC driver to a compatible version for your database.
  3. Verify the BSim layout created stringtable with an identity id column.
  4. Fall back to a post-insert sequence query if generated keys are unsupported.
Defensive patterns

Strategy: validation

Validate before calling

// Verify generated-key support before writing strings.
DatabaseMetaData md = db.getConnection().getMetaData();
if (!md.supportsGetGeneratedKeys()) {
    throw new IllegalStateException("Driver lacks generated-key support; cannot write new string");
}

Prevention

When it happens

Trigger: Calling writeNewString (internally from writeString for a previously-unseen value) on a database/driver that does not support generated keys, or where the stringtable id column is not auto-increment. The single-column insert of the value runs but key retrieval fails.

Common situations: JDBC driver/database mode lacking RETURN_GENERATED_KEYS. Stringtable schema without a serial id column. Driver version mismatch. Custom database wrapper that does not propagate generated keys.

Related errors


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