{"record":{"id":"c4e6d50584b37e29","repo":"NationalSecurityAgency/ghidra","slug":"drop-database-name-must-match","errorCode":null,"errorMessage":"drop database name must match","messagePattern":"drop database name must match","errorType":"exception","errorClass":"UnsupportedOperationException","httpStatus":null,"severity":"error","filePath":"Ghidra/Features/BSim/src/main/java/ghidra/features/bsim/query/client/AbstractSQLFunctionDatabase.java","lineNumber":2106,"sourceCode":"\t\t\t\tthrow new LSHException(\"Could not find function: \" + entry.funcName);\n\t\t\t}\n\t\t\tresponse.correspond.add(func);\n\t\t}\n\n\t\tTreeMap<RowKey, FunctionDescription> funcmap = new TreeMap<>();\n\t\tresponse.manage.generateFunctionIdMap(funcmap);\n\t\tfor (FunctionDescription element : response.correspond) {\n\t\t\tfillinChildren(element, response.manage, funcmap);\n\t\t}\n\t}\n\n\tprivate void fdbDatabaseDrop(DropDatabase query) throws LSHException {\n\t\tResponseDropDatabase response = query.getResponse();\n\t\tif (query.databaseName == null) {\n\t\t\tthrow new LSHException(\"Missing databaseName for drop database\");\n\t\t}\n\t\tif (!query.databaseName.equals(ds.getServerInfo().getDBName())) {\n\t\t\tthrow new UnsupportedOperationException(\"drop database name must match\");\n\t\t}\n\t\tresponse.dropSuccessful = true;\t\t// Response parameters assuming success\n\t\tresponse.errorMessage = null;\n\t\ttry {\n\t\t\tdropDatabase();\n\t\t}\n\t\tcatch (SQLException e) {\n\t\t\tString msg = e.getMessage();\n\t\t\tif (msg.indexOf(\"database \\\"\" + query.databaseName + \"\\\" does not exist\") > 0) {\n\t\t\t\treturn; // missing database\n\t\t\t}\n\t\t\tresponse.dropSuccessful = false;\n\t\t\tresponse.errorMessage = e.getMessage();\n\t\t}\n\t}\n\n\t/**\n\t * Entry point for the CreateDatabase command","sourceCodeStart":2088,"sourceCodeEnd":2124,"githubUrl":"https://github.com/NationalSecurityAgency/ghidra/blob/d5f144c24d6bc53c9cbf4448c6d11143e7696206/Ghidra/Features/BSim/src/main/java/ghidra/features/bsim/query/client/AbstractSQLFunctionDatabase.java#L2088-L2124","documentation":"Thrown by fdbDatabaseDrop when processing a DropDatabase query whose databaseName field does not equal the name of the database the connection (ds.getServerInfo().getDBName()) is currently pointed at. BSim refuses to drop a database with a mismatched name to prevent accidental deletion of a different database than the one the client is connected to.","triggerScenarios":"Issuing a DropDatabase query where query.databaseName is non-null but differs from the live connection's configured database name. Also triggered when databaseName is set but the connection string's DBName differs (e.g., connected to 'postgres' maintenance DB but requesting drop of 'mydb').","commonSituations":"Connecting to a PostgreSQL server using a maintenance/generic database name but trying to drop a differently-named BSim database; mismatch between the BSim URL's database path and the name supplied in the drop request; scripting a batch drop across multiple DBs through one connection.","solutions":["Set query.databaseName to exactly match ds.getServerInfo().getDBName() for the active connection before executing the DropDatabase query.","Establish a fresh connection to the server whose DBName equals the database you intend to drop, then issue the drop.","Verify the name match programmatically via getServerInfo().getDBName() before building the query."],"exampleFix":"// before\ndropQuery.databaseName = \"mydb\"; // connected to 'postgres'\ndb.execute(dropQuery);\n// after\ndropQuery.databaseName = db.getServerInfo().getDBName();\ndb.execute(dropQuery);","handlingStrategy":"validation","validationCode":"String dbName = db.getServerInfo().getDBName();\nif (!dbName.equals(dropQuery.databaseName)) {\n    dropQuery.databaseName = dbName; // or abort\n}","typeGuard":null,"tryCatchPattern":"catch (UnsupportedOperationException e) { /* re-establish connection to correct DB or correct databaseName, then retry */ }","preventionTips":["Always derive databaseName from the active connection's server info rather than hardcoding it.","Use a dedicated connection per database lifecycle operation (create/drop).","Log getDBName() alongside the requested name when scripting admin tasks."],"tags":["database","bsim","configuration","validation"],"backgroundTag":null,"analyzedSha":"d5f144c24d6bc53c9cbf4448c6d11143e7696206","analyzedAt":"2026-08-14T01:00:57.564Z","schemaVersion":2},"datasetVersion":"2026-08-14T05:17:29.042Z"}