25 MB lightweight cross-platform database client for 100+ databases, including MySQL, PostgreSQL, SQLite, Redis, MongoDB, DuckDB, SQL Server, and Dameng. Built-in AI, MCP Server, CLI, desktop and Docker. | 轻量级跨平台数据库管理工具,支持 MySQL、PostgreSQL、SQLite、Redis、MongoDB、达梦等 100+ 数据库,提供桌面端、Docker、CLI、内置 AI 助手和 MCP。
TypeScript aicliclickhousedatabasedatabase-clientdatabase-managementdockerguimcpmongodbmysqlpostgresqlredisrustsql-serversqlitetaurivue
fix(sidebar): explain when other sessions block dropping a database (#13746)
Loc Nguyen3d58f8e49d74
diff --git a/apps/desktop/src/components/sidebar/SidebarTreeRuntimeHost.vue b/apps/desktop/src/components/sidebar/SidebarTreeRuntimeHost.vueindex 45a951ff38..38d329aec7 100644--- a/apps/desktop/src/components/sidebar/SidebarTreeRuntimeHost.vue+++ b/apps/desktop/src/components/sidebar/SidebarTreeRuntimeHost.vue@@ -15,6 +15,7 @@ import { useSidebarTreeExportRuntime } from "@/composables/useSidebarTreeExportRimport { mysqlDataCharsetEnabled } from "@/lib/connection/mysqlDataCharset";import { useSidebarTreeToolRuntime } from "@/composables/useSidebarTreeToolRuntime";import { canDropDatabaseNode, notifyDatabaseBrowserMutation } from "@/lib/database/databaseBrowserActions";+import { dropDatabaseOtherSessionCount } from "@/lib/database/dropDatabaseError";import { canDropDatabaseTables, canEmptyDatabaseTables, useDatabaseTableEmpty } from "@/composables/useDatabaseTableEmpty";import { useI18n } from "vue-i18n";import { launchPlDebug, openPlDebugRecovery } from "@/components/debug/plDebugLaunch";@@ -5818,7 +5819,10 @@ async function confirmDropDatabase() {notifyDatabaseBrowserMutation({ connectionId, database: node.database || node.label, operation: "drop-database" });queryStore.closeDatabaseTabs(connectionId, node.database || node.label);} catch (e: any) {- toast(t("contextMenu.tableOperationFailed", { message: e?.message || String(e) }), 5000);+ const message = e?.message || String(e);+ const otherSessions = dropDatabaseOtherSessionCount(message);+ if (otherSessions === undefined) toast(t("contextMenu.tableOperationFailed", { message }), 5000);+ else toast(otherSessions === null ? t("contextMenu.dropDatabaseInUse", { name: node.label }) : t("contextMenu.dropDatabaseInUseSessions", { name: node.label, count: otherSessions }), 5000);} finally {dropDatabaseLoading.value = false;}diff --git a/apps/desktop/src/i18n/locales/az.ts b/apps/desktop/src/i18n/locales/az.tsindex 4fc424ca54..4693cc0628 100644--- a/apps/desktop/src/i18n/locales/az.ts+++ b/apps/desktop/src/i18n/locales/az.ts@@ -4084,6 +4084,8 @@ export default withEnglishFallback({attachSqliteDatabaseSuccess: '"{name}" adlı SQLite verilənlər bazası qoşuldu',attachSqliteDatabaseDesktopOnly: "SQLite verilənlər bazası fayllarını qoşmaq yalnız masaüstü tətbiqdə mümkündür",dropDatabaseSuccess: '"{name}" verilənlər bazası silindi',+ dropDatabaseInUseSessions: '"{name}" verilənlər bazası silinə bilmir: hələ {count} başqa sessiya qoşulub. Bu bağlantıları bağlayıb yenidən cəhd edin.',+ dropDatabaseInUse: '"{name}" verilənlər bazası silinə bilmir: başqa bağlantılar hələ də ondan istifadə edir. Bu bağlantıları bağlayıb yenidən cəhd edin.',dropCollection: "Kolleksiyanı sil",elasticsearchViewMapping: "Sahə uyğunlaşdırmasına bax",elasticsearchViewSettings: "İndeks parametrlərinə bax",diff --git a/apps/desktop/src/i18n/locales/en.ts b/apps/desktop/src/i18n/locales/en.tsindex 244fd41547..898aa89af6 100644--- a/apps/desktop/src/i18n/locales/en.ts+++ b/apps/desktop/src/i18n/locales/en.ts@@ -5437,6 +5437,8 @@ export default {attachSqliteDatabaseSuccess: 'SQLite database "{name}" attached',attachSqliteDatabaseDesktopOnly: "Attaching SQLite database files is only available in the desktop app",dropDatabaseSuccess: 'Database "{name}" dropped',+ dropDatabaseInUseSessions: 'Cannot drop database "{name}": {count} other session(s) are still connected to it. Close those connections and try again.',+ dropDatabaseInUse: 'Cannot drop database "{name}": other connections are still using it. Close those connections and try again.',dropCollection: "Drop Collection",elasticsearchViewMapping: "View Mapping",elasticsearchViewSettings: "View Index Settings",diff --git a/apps/desktop/src/i18n/locales/es.ts b/apps/desktop/src/i18n/locales/es.tsindex 243166a74d..16ac906499 100644--- a/apps/desktop/src/i18n/locales/es.ts+++ b/apps/desktop/src/i18n/locales/es.ts@@ -5093,6 +5093,8 @@ export default withEnglishFallback({attachSqliteDatabaseSuccess: 'Base de datos SQLite "{name}" adjuntada',attachSqliteDatabaseDesktopOnly: "Adjuntar archivos de base de datos SQLite solo está disponible en la app de escritorio",dropDatabaseSuccess: 'Base de datos "{name}" eliminada',+ dropDatabaseInUseSessions: 'No se puede eliminar la base de datos "{name}": {count} sesión(es) más siguen conectadas. Cierre esas conexiones e inténtelo de nuevo.',+ dropDatabaseInUse: 'No se puede eliminar la base de datos "{name}": otras conexiones aún la están usando. Cierre esas conexiones e inténtelo de nuevo.',dropCollection: "Eliminar colección",elasticsearchViewMapping: "Ver mapping",elasticsearchViewSettings: "Ver configuración del índice",diff --git a/apps/desktop/src/i18n/locales/id.ts b/apps/desktop/src/i18n/locales/id.tsindex d3be72f11a..06529cba57 100644--- a/apps/desktop/src/i18n/locales/id.ts+++ b/apps/desktop/src/i18n/locales/id.ts@@ -4422,6 +4422,8 @@ export default withEnglishFallback({attachSqliteDatabaseSuccess: 'Database SQLite "{name}" dilampirkan',attachSqliteDatabaseDesktopOnly: "Melampirkan file database SQLite hanya tersedia di aplikasi desktop",dropDatabaseSuccess: 'Database "{name}" telah di-drop',+ dropDatabaseInUseSessions: 'Tidak dapat men-drop database "{name}": masih ada {count} sesi lain yang terhubung. Tutup koneksi tersebut lalu coba lagi.',+ dropDatabaseInUse: 'Tidak dapat men-drop database "{name}": koneksi lain masih menggunakannya. Tutup koneksi tersebut lalu coba lagi.',dropCollection: "Drop Koleksi",elasticsearchViewMapping: "Lihat Mapping",elasticsearchViewSettings: "Lihat Pengaturan Indeks",diff --git a/apps/desktop/src/i18n/locales/it.ts b/apps/desktop/src/i18n/locales/it.tsindex 78a60aba33..a02dc4e0f3 100644--- a/apps/desktop/src/i18n/locales/it.ts+++ b/apps/desktop/src/i18n/locales/it.ts@@ -4910,6 +4910,8 @@ export default withEnglishFallback({attachSqliteDatabaseSuccess: 'Database SQLite "{name}" collegato',attachSqliteDatabaseDesktopOnly: "Il collegamento di file di database SQLite è disponibile solo nell'applicazione desktop",dropDatabaseSuccess: 'Database "{name}" eliminato',+ dropDatabaseInUseSessions: 'Impossibile eliminare il database "{name}": {count} altre sessioni sono ancora connesse. Chiudi queste connessioni e riprova.',+ dropDatabaseInUse: 'Impossibile eliminare il database "{name}": altre connessioni lo stanno ancora usando. Chiudi queste connessioni e riprova.',dropCollection: "Elimina Collection",elasticsearchViewMapping: "Visualizza mapping",elasticsearchViewSettings: "Visualizza impostazioni indice",diff --git a/apps/desktop/src/i18n/locales/ja.ts b/apps/desktop/src/i18n/locales/ja.tsindex 557509b8d4..99bb712d1f 100644--- a/apps/desktop/src/i18n/locales/ja.ts+++ b/apps/desktop/src/i18n/locales/ja.ts@@ -4921,6 +4921,8 @@ export default withEnglishFallback({attachSqliteDatabaseSuccess: "SQLiteデータベース「{name}」をアタッチしました",attachSqliteDatabaseDesktopOnly: "SQLiteデータベースファイルのアタッチはデスクトップアプリでのみ利用可能です",dropDatabaseSuccess: "データベース「{name}」を削除しました",+ dropDatabaseInUseSessions: "データベース「{name}」を削除できません:他のセッションが {count} 件接続中です。それらの接続を閉じてから再試行してください。",+ dropDatabaseInUse: "データベース「{name}」を削除できません:他の接続が使用中です。それらの接続を閉じてから再試行してください。",dropCollection: "コレクションを削除",elasticsearchViewMapping: "マッピングを表示",elasticsearchViewSettings: "インデックス設定を表示",diff --git a/apps/desktop/src/i18n/locales/ko.ts b/apps/desktop/src/i18n/locales/ko.tsindex f9e6b8f3e0..db1eddd3e1 100644--- a/apps/desktop/src/i18n/locales/ko.ts+++ b/apps/desktop/src/i18n/locales/ko.ts@@ -4856,6 +4856,8 @@ export default withEnglishFallback({attachSqliteDatabaseSuccess: 'SQLite 데이터베이스 "{name}"이(가) 연결되었습니다',attachSqliteDatabaseDesktopOnly: "SQLite 데이터베이스 파일 연결은 데스크톱 앱에서만 사용할 수 있습니다",dropDatabaseSuccess: '데이터베이스 "{name}" 삭제됨',+ dropDatabaseInUseSessions: '데이터베이스 "{name}"을(를) 삭제할 수 없습니다: 다른 세션 {count}개가 아직 연결되어 있습니다. 해당 연결을 닫은 후 다시 시도하세요.',+ dropDatabaseInUse: '데이터베이스 "{name}"을(를) 삭제할 수 없습니다: 다른 연결이 아직 사용 중입니다. 해당 연결을 닫은 후 다시 시도하세요.',dropCollection: "컬렉션 삭제",elasticsearchViewMapping: "매핑 보기",elasticsearchViewSettings: "인덱스 설정 보기",diff --git a/apps/desktop/src/i18n/locales/pl.ts b/apps/desktop/src/i18n/locales/pl.tsindex 3baaf8e3df..52891ebacb 100644--- a/apps/desktop/src/i18n/locales/pl.ts+++ b/apps/desktop/src/i18n/locales/pl.ts@@ -4474,6 +4474,8 @@ export default withEnglishFallback({attachSqliteDatabaseSuccess: "Baza danych SQLite „{name}” została podłączona",attachSqliteDatabaseDesktopOnly: "Podłączanie plików baz SQLite jest dostępne tylko w aplikacji na komputery",dropDatabaseSuccess: "Baza danych „{name}” została usunięta",+ dropDatabaseInUseSessions: "Nie można usunąć bazy danych „{name}”: nadal połączone są inne sesje ({count}). Zamknij te połączenia i spróbuj ponownie.",+ dropDatabaseInUse: "Nie można usunąć bazy danych „{name}”: nadal używają jej inne połączenia. Zamknij te połączenia i spróbuj ponownie.",dropCollection: "Usuń kolekcję",elasticsearchViewMapping: "Pokaż mapowanie (Mapping)",elasticsearchViewSettings: "Pokaż ustawienia indeksu",diff --git a/apps/desktop/src/i18n/locales/pt-BR.ts b/apps/desktop/src/i18n/locales/pt-BR.tsindex 7e67a6ddd7..03dfa0748d 100644--- a/apps/desktop/src/i18n/locales/pt-BR.ts+++ b/apps/desktop/src/i18n/locales/pt-BR.ts@@ -4904,6 +4904,8 @@ export default withEnglishFallback({attachSqliteDatabaseSuccess: 'Banco de dados SQLite "{name}" anexado',attachSqliteDatabaseDesktopOnly: "Anexar arquivos de banco de dados SQLite só está disponível no aplicativo desktop",dropDatabaseSuccess: 'Banco de dados "{name}" removido',+ dropDatabaseInUseSessions: 'Não é possível remover o banco de dados "{name}": {count} outra(s) sessão(ões) ainda estão conectadas. Feche essas conexões e tente novamente.',+ dropDatabaseInUse: 'Não é possível remover o banco de dados "{name}": outras conexões ainda o estão usando. Feche essas conexões e tente novamente.',dropCollection: "Remover coleção",elasticsearchViewMapping: "Ver mapping",elasticsearchViewSettings: "Ver configurações do índice",diff --git a/apps/desktop/src/i18n/locales/ru.ts b/apps/desktop/src/i18n/locales/ru.tsindex a23862ad99..3bf2def919 100644--- a/apps/desktop/src/i18n/locales/ru.ts+++ b/apps/desktop/src/i18n/locales/ru.ts@@ -5076,6 +5076,8 @@ export default withEnglishFallback({attachSqliteDatabaseSuccess: "База данных SQLite «{name}» присоединена",attachSqliteDatabaseDesktopOnly: "Присоединение файлов баз данных SQLite доступно только в настольном приложении",dropDatabaseSuccess: "База данных «{name}» удалена",+ dropDatabaseInUseSessions: "Не удалось удалить базу данных «{name}»: к ней всё ещё подключено других сеансов: {count}. Закройте эти подключения и повторите попытку.",+ dropDatabaseInUse: "Не удалось удалить базу данных «{name}»: она всё ещё используется другими подключениями. Закройте эти подключения и повторите попытку.",dropCollection: "Удалить коллекцию",elasticsearchViewMapping: "Просмотреть mapping",elasticsearchViewSettings: "Просмотреть настройки индекса",diff --git a/apps/desktop/src/i18n/locales/th.ts b/apps/desktop/src/i18n/locales/th.tsindex 7ce9056881..e3261454f5 100644--- a/apps/desktop/src/i18n/locales/th.ts+++ b/apps/desktop/src/i18n/locales/th.ts@@ -5251,6 +5251,8 @@ export default withEnglishFallback({attachSqliteDatabaseSuccess: "แนบฐานข้อมูล SQLite “{name}” แล้ว",attachSqliteDatabaseDesktopOnly: "การแนบไฟล์ฐานข้อมูล SQLite ใช้ได้เฉพาะใน Desktop App",dropDatabaseSuccess: "Drop ฐานข้อมูล “{name}” แล้ว",+ dropDatabaseInUseSessions: "ไม่สามารถ Drop ฐานข้อมูล “{name}” ได้: ยังมีเซสชันอื่นเชื่อมต่ออยู่ {count} รายการ ปิดการเชื่อมต่อเหล่านั้นแล้วลองอีกครั้ง",+ dropDatabaseInUse: "ไม่สามารถ Drop ฐานข้อมูล “{name}” ได้: ยังมีการเชื่อมต่ออื่นใช้งานอยู่ ปิดการเชื่อมต่อเหล่านั้นแล้วลองอีกครั้ง",dropCollection: "Drop Collection",elasticsearchViewMapping: "ดู Mapping",elasticsearchViewSettings: "ดู Settings ของ Index",diff --git a/apps/desktop/src/i18n/locales/tr.ts b/apps/desktop/src/i18n/locales/tr.tsindex c870b48733..5894508f07 100644--- a/apps/desktop/src/i18n/locales/tr.ts+++ b/apps/desktop/src/i18n/locales/tr.ts@@ -4053,6 +4053,8 @@ export default withEnglishFallback({attachSqliteDatabaseSuccess: '"{name}" SQLite veritabanı eklendi',attachSqliteDatabaseDesktopOnly: "SQLite veritabanı dosyası eklemek yalnızca masaüstü uygulamasında kullanılabilir",dropDatabaseSuccess: '"{name}" veritabanı silindi',+ dropDatabaseInUseSessions: '"{name}" veritabanı silinemiyor: {count} başka oturum hâlâ bağlı. Bu bağlantıları kapatıp yeniden deneyin.',+ dropDatabaseInUse: '"{name}" veritabanı silinemiyor: başka bağlantılar hâlâ kullanıyor. Bu bağlantıları kapatıp yeniden deneyin.',dropCollection: "Koleksiyonu Sil",elasticsearchViewMapping: "Eşlemeyi Görüntüle",elasticsearchViewSettings: "Dizin Ayarlarını Görüntüle",diff --git a/apps/desktop/src/i18n/locales/zh-CN.ts b/apps/desktop/src/i18n/locales/zh-CN.tsindex f0082109aa..e5618bd810 100644--- a/apps/desktop/src/i18n/locales/zh-CN.ts+++ b/apps/desktop/src/i18n/locales/zh-CN.ts@@ -5364,6 +5364,8 @@ export default withEnglishFallback({attachSqliteDatabaseSuccess: "SQLite 数据库「{name}」已附加",attachSqliteDatabaseDesktopOnly: "附加 SQLite 数据库文件仅支持桌面端",dropDatabaseSuccess: "数据库「{name}」已删除",+ dropDatabaseInUseSessions: "无法删除数据库「{name}」:仍有 {count} 个其他会话连接到该数据库。请关闭这些连接后重试。",+ dropDatabaseInUse: "无法删除数据库「{name}」:仍有其他连接正在使用该数据库。请关闭这些连接后重试。",dropCollection: "删除集合",elasticsearchViewMapping: "查看 Mapping",elasticsearchViewSettings: "查看索引配置",diff --git a/apps/desktop/src/i18n/locales/zh-TW.ts b/apps/desktop/src/i18n/locales/zh-TW.tsindex 010d0fc2d8..f5bae97424 100644--- a/apps/desktop/src/i18n/locales/zh-TW.ts+++ b/apps/desktop/src/i18n/locales/zh-TW.ts@@ -4892,6 +4892,8 @@ export default withEnglishFallback({attachSqliteDatabaseSuccess: "SQLite 資料庫「{name}」已附加",attachSqliteDatabaseDesktopOnly: "附加 SQLite 資料庫檔案僅支援桌面端",dropDatabaseSuccess: "資料庫「{name}」已刪除",+ dropDatabaseInUseSessions: "無法刪除資料庫「{name}」:仍有 {count} 個其他工作階段連線到此資料庫。請關閉這些連線後重試。",+ dropDatabaseInUse: "無法刪除資料庫「{name}」:仍有其他連線正在使用此資料庫。請關閉這些連線後重試。",dropCollection: "刪除集合",elasticsearchViewMapping: "檢視 Mapping",elasticsearchViewSettings: "檢視索引設定",diff --git a/apps/desktop/src/lib/database/dropDatabaseError.ts b/apps/desktop/src/lib/database/dropDatabaseError.tsnew file mode 100644index 0000000000..e40510bbca--- /dev/null+++ b/apps/desktop/src/lib/database/dropDatabaseError.ts@@ -0,0 +1,19 @@+/**+ * PostgreSQL-family engines (PostgreSQL, openGauss, GaussDB, Kingbase, ...) refuse+ * `DROP DATABASE` while other sessions are connected. DBX already disconnects its own+ * sessions first, so this error always names someone else's connection; the raw text+ * mixes engine-specific force commands and DBX's own diagnostics notice (#13733).+ */+const DATABASE_IN_USE_PATTERN = /\bdatabase\s+"(?:[^"]|"")*"\s+is being accessed by other users\b/i;+const OTHER_SESSION_COUNT_PATTERN = /\bthere (?:is|are) (\d+) other sessions? using the database\b/i;++/**+ * `undefined` when `message` is not the "database is in use" error; otherwise the number of+ * other sessions the engine reported, or `null` when it did not report one (for example a+ * prepared transaction holds the database instead).+ */+export function dropDatabaseOtherSessionCount(message: string): number | null | undefined {+ if (!DATABASE_IN_USE_PATTERN.test(message)) return undefined;+ const count = OTHER_SESSION_COUNT_PATTERN.exec(message)?.[1];+ return count === undefined ? null : Number(count);+}diff --git a/packages/app-tests/dropDatabaseError.test.ts b/packages/app-tests/dropDatabaseError.test.tsnew file mode 100644index 0000000000..4ab25d87e7--- /dev/null+++ b/packages/app-tests/dropDatabaseError.test.ts@@ -0,0 +1,26 @@+import { describe, expect, it } from "vitest";+import { dropDatabaseOtherSessionCount } from "@/lib/database/dropDatabaseError";++describe("dropDatabaseOtherSessionCount", () => {+ it("reads the session count from the openGauss error (#13733)", () => {+ const message = [+ 'ERROR: Database "app_db" is being accessed by other users. You can stop all connections by command: "clean connection to all force for database XXXX;" or wait for the sessions to end by querying view: "pg_stat_activity".',+ "DETAIL: There is 1 other session using the database.",+ "SQL text omitted from user-facing error; enable debug SQL diagnostics to inspect the original statement.",+ ].join("\n");+ expect(dropDatabaseOtherSessionCount(message)).toBe(1);+ });++ it("reads the plural PostgreSQL form", () => {+ expect(dropDatabaseOtherSessionCount('ERROR: database "my ""quoted"" db" is being accessed by other users\nDETAIL: There are 3 other sessions using the database.')).toBe(3);+ });++ it("reports an unknown count when another holder is named", () => {+ expect(dropDatabaseOtherSessionCount('ERROR: database "app" is being accessed by other users\nDETAIL: There is 1 prepared transaction using the database.')).toBeNull();+ });++ it("ignores other drop failures", () => {+ expect(dropDatabaseOtherSessionCount("ERROR: must be owner of database app")).toBeUndefined();+ expect(dropDatabaseOtherSessionCount('ERROR: database "app" does not exist')).toBeUndefined();+ });+});