NationalSecurityAgency/ghidra · error · SQLException
Did not get vector id after insertion
Error message
Did not get vector id after insertion
What it means
Thrown by PostgresFunctionDatabase.storeSignatureRecord() when the insert_vec() stored function returns a ResultSet with no rows. Normally insert_vec() returns the newly assigned vector row id; an empty result set indicates the stored function did not execute as expected or returned no data.
Source
Thrown at Ghidra/Features/BSim/src/main/java/ghidra/features/bsim/query/client/PostgresFunctionDatabase.java:412
}
st.execute("DROP EXTENSION pg_prewarm");
return res;
}
}
/**
* Make sure the vector corresponding to the SignatureRecord is inserted into the vectable
* @param sigrec is the SignatureRecord
* @return the computed id of the vector
* @throws SQLException if there is a problem creating or executing the query
*/
@Override
protected long storeSignatureRecord(SignatureRecord sigrec) throws SQLException {
String sql = "SELECT insert_vec( '" + sigrec.getLSHVector().saveSQL() + "')";
try (ResultSet rs = getReusableStatement().executeQuery(sql)) {
if (!rs.next()) {
throw new SQLException("Did not get vector id after insertion");
}
return rs.getLong(1);
}
}
/**
* Low level count decrement of a vector record from vectable, if count
* reaches zero, the record is deleted
* @param id vector row ID
* @param countdiff the amount to subtract from count
* @return 0 if decrement short of 0, return 1 if record was removed, return
* -1 if there was a problem
* @throws SQLException if there is a problem creating or executing the query
*/
@Override
protected int deleteVectors(long id, int countdiff) throws SQLException {
int res = -100;
String sql =View on GitHub (pinned to d5f144c24d)
Solutions
- Verify the lshvector extension is installed and its insert_vec function returns a scalar bigint.
- Check the BSim extension version matches the client version.
- Inspect the generated SQL (sigrec.getLSHVector().saveSQL()) for malformed output.
- Recreate the database if the extension functions are in an inconsistent state.
Example fix
// before — insert_vec returns no rows due to corrupted extension long vecId = db.storeSignatureRecord(sigrec); // throws // after — verify extension on the server // psql: SELECT proname, prorettype FROM pg_proc WHERE proname = 'insert_vec'; // reinstall extension if missing, then retry
Defensive patterns
Strategy: validation
Validate before calling
// Verify the insert_vec function exists and returns a scalar
try (Connection c = dataSource.getConnection();
Statement st = c.createStatement();
ResultSet rs = st.executeQuery(
"SELECT proname FROM pg_proc WHERE proname = 'insert_vec'")) {
if (!rs.next()) {
throw new IllegalStateException("insert_vec function missing; reinstall lshvector extension");
}
} Try / catch
try {
long vecId = db.storeSignatureRecord(sigrec);
} catch (SQLException e) {
if (e.getMessage().contains("Did not get vector id")) {
// extension issue; verify lshvector functions and version, then retry
throw e;
}
throw e;
} Prevention
- Install and verify the lshvector extension before ingesting signatures.
- Ensure extension version matches the BSim client version.
- Validate that LSHVector.saveSQL() produces well-formed SQL.
When it happens
Trigger: Calling storeSignatureRecord(sigrec) and the SQL "SELECT insert_vec(...)" returns zero rows. This can happen if the lshvector extension's insert_vec function is missing or corrupted, returns void/nothing instead of a scalar, or the vector's saveSQL() output is invalid causing the function to silently fail.
Common situations: The PostgreSQL lshvector extension was not properly installed or was corrupted. A version mismatch between the extension and the BSim client. The LSHVector.saveSQL() produced malformed SQL that the function could not parse. A database restore left stored functions in an inconsistent state.
Related errors
- Did not get result code after deletion
- Could not create database:
- database in use
- attempted to drop non-BSim database
- Bad vectable rowid
AI-assisted analysis of NationalSecurityAgency/ghidra@d5f144c24d (2026-08-14).
Data as JSON: /api/errors/c63974eba329a66b.
Report an issue: GitHub.