@@ -896,19 +896,6 @@ dropdb(const char *dbname, bool missing_ok)
896896 nslots_active , nslots_active )));
897897 }
898898
899- /*
900- * Check for other backends in the target database. (Because we hold the
901- * database lock, no new ones can start after this.)
902- *
903- * As in CREATE DATABASE, check this after other error conditions.
904- */
905- if (CountOtherDBBackends (db_id , & notherbackends , & npreparedxacts ))
906- ereport (ERROR ,
907- (errcode (ERRCODE_OBJECT_IN_USE ),
908- errmsg ("database \"%s\" is being accessed by other users" ,
909- dbname ),
910- errdetail_busy_db (notherbackends , npreparedxacts )));
911-
912899 /*
913900 * Check if there are subscriptions defined in the target database.
914901 *
@@ -924,6 +911,19 @@ dropdb(const char *dbname, bool missing_ok)
924911 "There are %d subscriptions." ,
925912 nsubscriptions , nsubscriptions )));
926913
914+ /*
915+ * Check for other backends in the target database. (Because we hold the
916+ * database lock, no new ones can start after this.)
917+ *
918+ * As in CREATE DATABASE, check this after other error conditions.
919+ */
920+ if (CountOtherDBBackends (db_id , & notherbackends , & npreparedxacts ))
921+ ereport (ERROR ,
922+ (errcode (ERRCODE_OBJECT_IN_USE ),
923+ errmsg ("database \"%s\" is being accessed by other users" ,
924+ dbname ),
925+ errdetail_busy_db (notherbackends , npreparedxacts )));
926+
927927 /*
928928 * Remove the database's tuple from pg_database.
929929 */
0 commit comments