NationalSecurityAgency/ghidra · error · SQLException
Could not create database:
Error message
Could not create database:
What it means
Thrown by PostgresFunctionDatabase.createDatabase() wrapping any SQLException during the multi-step database creation: creating the lshvector extension, the vectable and its GIN index, the vector stored functions, GRANT statements, weight loading, or setting synchronous_commit. The original SQLException message is appended for diagnostics.
Source
Thrown at Ghidra/Features/BSim/src/main/java/ghidra/features/bsim/query/client/PostgresFunctionDatabase.java:239
st.executeUpdate("GRANT SELECT ON ALL TABLES IN SCHEMA PUBLIC TO PUBLIC");
st.executeUpdate("GRANT USAGE ON ALL SEQUENCES IN SCHEMA PUBLIC TO PUBLIC");
serverLoadWeights(db);
// Tell server to do asynchronous commits. This speeds up large
// ingests with a (slight) danger of
// losing the most recent commits if the server crashes (NOTE:
// database integrity should still be recoverable)
if (asynchronous) {
st.executeUpdate("SET SESSION synchronous_commit TO OFF");
}
else {
st.executeUpdate("SET SESSION synchronous_commit to ON");
}
}
}
catch (final SQLException err) {
throw new SQLException("Could not create database: " + err.getMessage());
}
}
@Override
protected void dropDatabase() throws SQLException {
if (getStatus() == Status.Busy || postgresDs.getActiveConnections() != 0) {
throw new SQLException("database in use");
}
BSimServerInfo serverInfo = postgresDs.getServerInfo();
BSimServerInfo defaultServerInfo =
new BSimServerInfo(DBType.postgres, serverInfo.getUserInfo(),
serverInfo.getServerName(), serverInfo.getPort(), DEFAULT_DATABASE_NAME);
BSimPostgresDataSource defaultDs =
BSimPostgresDBConnectionManager.getDataSource(defaultServerInfo);
if (getStatus() == Status.Ready) {View on GitHub (pinned to d5f144c24d)
Solutions
- Install the BSim PostgreSQL extension (lshvector) on the target server before calling createDatabase.
- Ensure the connecting user has CREATEDB and CREATE EXTENSION privileges.
- Inspect the wrapped SQLException message to identify the exact failing SQL statement.
- If a partial create left orphaned tables, manually drop them or the database before retrying.
Example fix
// before db.createDatabase(config); // throws "Could not create database: extension \"lshvector\" does not exist" // after — install extension on the server first // (run on the PostgreSQL host, once) // CREATE EXTENSION lshvector; // then retry db.createDatabase(config);
Defensive patterns
Strategy: validation
Validate before calling
// Verify the lshvector extension is installed before createDatabase
try (Connection c = dataSource.getConnection();
Statement st = c.createStatement();
ResultSet rs = st.executeQuery(
"SELECT 1 FROM pg_extension WHERE extname = 'lshvector'")) {
if (!rs.next()) {
throw new IllegalStateException("lshvector extension not installed on server");
}
} Try / catch
try {
db.createDatabase(config);
} catch (SQLException e) {
if (e.getMessage().startsWith("Could not create database")) {
// inspect root cause; install extension, fix privileges, clean partial tables
throw e;
}
throw e;
} Prevention
- Install the lshvector extension on the PostgreSQL server before createDatabase.
- Ensure the connecting user has CREATEDB and CREATE EXTENSION privileges.
- Clean up partially-created tables before retrying a failed create.
When it happens
Trigger: Calling createDatabase(config) on a PostgresFunctionDatabase when any SQL step fails — most commonly the CREATE EXTENSION lshvector fails because the extension is not installed on the PostgreSQL server, or table/index creation fails due to insufficient privileges.
Common situations: The PostgreSQL server does not have the BSim lshvector extension installed. The connecting user lacks CREATEDB or CREATE EXTENSION privileges. A table or index name already exists from a prior partial create. PostgreSQL version incompatibility with the extension.
Related errors
- database in use
- attempted to drop non-BSim database
- Did not get vector id after insertion
- Did not get result code after deletion
- Bad vectable rowid
AI-assisted analysis of NationalSecurityAgency/ghidra@d5f144c24d (2026-08-14).
Data as JSON: /api/errors/ad83f77415e9fece.
Report an issue: GitHub.