NationalSecurityAgency/ghidra · error · SQLException

Did not get result code after deletion

Error message

Did not get result code after deletion

What it means

Thrown by PostgresFunctionDatabase.deleteVectors() when the remove_vec() stored function returns a ResultSet with no rows. Normally remove_vec returns an integer status code (0 = decremented, 1 = removed, -1 = problem); an empty result set means the function did not return the expected scalar.

Source

Thrown at Ghidra/Features/BSim/src/main/java/ghidra/features/bsim/query/client/PostgresFunctionDatabase.java:434

	}

	/**
	 * 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 =
			"SELECT remove_vec( " + Long.toString(id) + ',' + Integer.toString(countdiff) + ")";
		try (ResultSet rs = getReusableStatement().executeQuery(sql)) {
			if (!rs.next()) {
				throw new SQLException("Did not get result code after deletion");
			}
			res = rs.getInt(1);
		}
		return res;
	}

	/**
	 * 
	 * @param resultset the list of result set objects to populate
	 * @param vec the vector containing the saveSQL query statement
	 * @param simthresh the similarity threshold
	 * @param sigthresh the confidence threshold
	 * @param max the max number of results to return
	 * @return the number of results returned
	 * @throws SQLException if there is a problem creating or executing the query
	 */
	@Override
	protected int queryNearestVector(List<VectorResult> resultset, LSHVector vec, double simthresh,

View on GitHub (pinned to d5f144c24d)

Solutions

  1. Verify the lshvector extension is intact and remove_vec returns a scalar integer.
  2. Reinstall or recreate the extension if the function is missing.
  3. Check extension/client version compatibility.
  4. Ensure the vector id and countdiff parameters are valid (id exists in vectable).

Example fix

// before
int res = db.deleteVectors(id, countdiff); // throws "Did not get result code after deletion"

// after — verify the stored function exists and works
// psql: SELECT remove_vec(1, 1); -- should return an int
// reinstall extension if it returns nothing, then retry
Defensive patterns

Strategy: validation

Validate before calling

// Verify the remove_vec function exists
try (Connection c = dataSource.getConnection();
     Statement st = c.createStatement();
     ResultSet rs = st.executeQuery(
         "SELECT proname FROM pg_proc WHERE proname = 'remove_vec'")) {
    if (!rs.next()) {
        throw new IllegalStateException("remove_vec function missing; reinstall extension");
    }
}

Try / catch

try {
    int res = db.deleteVectors(id, countdiff);
} catch (SQLException e) {
    if (e.getMessage().contains("Did not get result code")) {
        // extension function issue; verify and reinstall if needed
        throw e;
    }
    throw e;
}

Prevention

When it happens

Trigger: Calling deleteVectors(id, countdiff) and the SQL "SELECT remove_vec(...)" returns zero rows. This indicates the remove_vec stored function is missing, corrupted, or not behaving as expected — analogous to the insert_vec case but for vector deletion.

Common situations: The lshvector extension is corrupted or missing the remove_vec function. A version mismatch between the extension and client. The database was partially restored leaving stored functions inconsistent.

Related errors


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