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
feat(mysql): support AUTO_INCREMENT for compatible profiles
t8y27815319a7aac
diff --git a/apps/desktop/src/components/sidebar/SidebarTreeRuntimeHost.vue b/apps/desktop/src/components/sidebar/SidebarTreeRuntimeHost.vueindex 326e3f8d68..488a1256f0 100644--- a/apps/desktop/src/components/sidebar/SidebarTreeRuntimeHost.vue+++ b/apps/desktop/src/components/sidebar/SidebarTreeRuntimeHost.vue@@ -187,7 +187,7 @@ import {buildMysqlAutoIncrementSql,supportsDropTableCascade,supportsTruncateTableCascade,- supportsNativeMysqlAutoIncrement,+ supportsMysqlAutoIncrement as connectionSupportsMysqlAutoIncrement,supportsSchemaComment,type DropTableChildObjectSqlOptions,type DropObjectSqlOptions,@@ -3324,7 +3324,7 @@ function selectedBatchMysqlAutoIncrementTargets(): TreeNode[] {const targets = selectedBatchTableTargets();return targets.filter((node) => {const config = node.connectionId ? connectionStore.getConfig(node.connectionId) : undefined;- return supportsNativeMysqlAutoIncrement(config);+ return connectionSupportsMysqlAutoIncrement(config);});}@@ -3376,7 +3376,7 @@ async function confirmBatchMysqlAutoIncrement() {}try {const config = connectionStore.getConfig(target.connectionId);- if (!supportsNativeMysqlAutoIncrement(config)) throw new Error("Setting AUTO_INCREMENT is supported only for native MySQL connections.");+ if (!connectionSupportsMysqlAutoIncrement(config)) throw new Error("Setting AUTO_INCREMENT is supported only for compatible MySQL-family connections.");await connectionStore.ensureConnected(target.connectionId);const sqlOptions = batchMysqlAutoIncrementSqlOptionsForNode(target);const sql = await buildMysqlAutoIncrementSql(sqlOptions);diff --git a/apps/desktop/src/components/structure/TableStructureEditor.charsetCollation.spec.ts b/apps/desktop/src/components/structure/TableStructureEditor.charsetCollation.spec.tsindex c1cd0ff3ef..7a910169e6 100644--- a/apps/desktop/src/components/structure/TableStructureEditor.charsetCollation.spec.ts+++ b/apps/desktop/src/components/structure/TableStructureEditor.charsetCollation.spec.ts@@ -379,6 +379,18 @@ describe("TableStructureEditor MySQL AUTO_INCREMENT counter", () => {expect(root.querySelector("[data-mysql-auto-increment-editor-trigger]")?.getAttribute("title")).toContain("structureEditor.editMysqlAutoIncrementValue");});+ it("loads and renders the counter for MariaDB connections", async () => {+ mocks.connection.name = "MariaDB";+ mocks.connection.driver_label = "MariaDB";+ mocks.connection.driver_profile = "mariadb";++ const root = await mountEditor(true);++ await vi.waitFor(() => expect(mocks.getMysqlTableAutoIncrement).toHaveBeenCalledWith("structure-charset-test", "test", "users"));+ expect(root.querySelector<HTMLInputElement>("[data-mysql-auto-increment-counter]")?.value).toBe("10");+ expect(root.querySelector("[data-mysql-auto-increment-editor-trigger]")).not.toBeNull();+ });+it("loads an editable blank counter when auto-increment is checked before saving", async () => {mocks.getMysqlTableAutoIncrement.mockResolvedValueOnce(null);const root = await mountEditor(false);diff --git a/apps/desktop/src/composables/__tests__/useSidebarTableMutationRuntime.mysqlAutoIncrement.spec.ts b/apps/desktop/src/composables/__tests__/useSidebarTableMutationRuntime.mysqlAutoIncrement.spec.tsindex b4bbce2466..6ef28c8977 100644--- a/apps/desktop/src/composables/__tests__/useSidebarTableMutationRuntime.mysqlAutoIncrement.spec.ts+++ b/apps/desktop/src/composables/__tests__/useSidebarTableMutationRuntime.mysqlAutoIncrement.spec.ts@@ -96,12 +96,13 @@ describe("useSidebarTableMutationRuntime MySQL AUTO_INCREMENT action", () => {expect(mocks.refreshMutatedTableDataTabsForNode).toHaveBeenCalledWith(tableNode());});- it("excludes MySQL-compatible profiles", () => {- expect(runtime("mariadb").supportsMysqlAutoIncrement.value).toBe(false);- expect(runtime("tidb").supportsMysqlAutoIncrement.value).toBe(false);- expect(runtime("oceanbase").supportsMysqlAutoIncrement.value).toBe(false);- expect(runtime("dolt").supportsMysqlAutoIncrement.value).toBe(false);- expect(runtime("goldendb").supportsMysqlAutoIncrement.value).toBe(false);+ it("includes supported MySQL-compatible profiles and excludes analytics profiles", () => {+ for (const profile of ["mariadb", "tidb", "oceanbase", "tdsql", "polardb", "greatsql", "custom_mysql", "dolt", "goldendb"]) {+ expect(runtime(profile).supportsMysqlAutoIncrement.value, profile).toBe(true);+ }+ for (const profile of ["doris", "selectdb", "starrocks", "manticoresearch"]) {+ expect(runtime(profile).supportsMysqlAutoIncrement.value, profile).toBe(false);+ }});it("ignores out-of-order preview responses", async () => {diff --git a/apps/desktop/src/composables/useSidebarTableMutationRuntime.ts b/apps/desktop/src/composables/useSidebarTableMutationRuntime.tsindex 2547b72a49..c95cd6f9f3 100644--- a/apps/desktop/src/composables/useSidebarTableMutationRuntime.ts+++ b/apps/desktop/src/composables/useSidebarTableMutationRuntime.ts@@ -12,7 +12,7 @@ import {buildTruncateTableSql,buildVacuumTableSql,supportsDropTableCascade,- supportsNativeMysqlAutoIncrement,+ supportsMysqlAutoIncrement,supportsTruncateTableCascade,type MysqlAutoIncrementSqlOptions,type TableAdminSqlOptions,@@ -74,7 +74,7 @@ export function useSidebarTableMutationRuntime(options: SidebarTableMutationRunt});const canDropTableCascade = computed(() => activeNode.value.type === "table" && supportsDropTableCascade(currentDatabaseType()));const canTruncateTableCascade = computed(() => activeNode.value.type === "table" && supportsTruncateTableCascade(currentDatabaseType()));- const supportsMysqlAutoIncrement = computed(() => activeNode.value.type === "table" && supportsNativeMysqlAutoIncrement(activeNode.value.connectionId ? connectionStore.getConfig(activeNode.value.connectionId) : undefined));+ const supportsMysqlAutoIncrementAction = computed(() => activeNode.value.type === "table" && supportsMysqlAutoIncrement(activeNode.value.connectionId ? connectionStore.getConfig(activeNode.value.connectionId) : undefined));function tableAdminSqlOptions(optionsOverride?: { cascade?: boolean }): TableAdminSqlOptions {const config = activeNode.value.connectionId ? connectionStore.getConfig(activeNode.value.connectionId) : undefined;@@ -153,7 +153,7 @@ export function useSidebarTableMutationRuntime(options: SidebarTableMutationRunt}function mysqlAutoIncrement() {- if (!supportsMysqlAutoIncrement.value) return;+ if (!supportsMysqlAutoIncrementAction.value) return;mysqlAutoIncrementValue.value = "1";mysqlAutoIncrementPreviewKey.value = "";void refreshMysqlAutoIncrementPreviewSql();@@ -165,7 +165,7 @@ export function useSidebarTableMutationRuntime(options: SidebarTableMutationRuntif (!node.connectionId || !node.database) return;try {const config = connectionStore.getConfig(node.connectionId);- if (!supportsNativeMysqlAutoIncrement(config)) throw new Error("Setting AUTO_INCREMENT is supported only for native MySQL connections.");+ if (!supportsMysqlAutoIncrement(config)) throw new Error("Setting AUTO_INCREMENT is supported only for compatible MySQL-family connections.");await connectionStore.ensureConnected(node.connectionId);const sqlOptions = mysqlAutoIncrementSqlOptionsForNode(node);const previewKey = mysqlAutoIncrementPreviewKeyForNode(node, sqlOptions);@@ -571,7 +571,7 @@ export function useSidebarTableMutationRuntime(options: SidebarTableMutationRuntsupportsVacuum,canDropTableCascade,canTruncateTableCascade,- supportsMysqlAutoIncrement,+ supportsMysqlAutoIncrement: supportsMysqlAutoIncrementAction,refreshDropTablePreviewSql,refreshTruncateTablePreviewSql,dropTable,diff --git a/apps/desktop/src/i18n/locales/az.ts b/apps/desktop/src/i18n/locales/az.tsindex 5cf72ba92c..147cf9e08b 100644--- a/apps/desktop/src/i18n/locales/az.ts+++ b/apps/desktop/src/i18n/locales/az.ts@@ -3675,7 +3675,7 @@ export default withEnglishFallback({mysqlAutoIncrement: "AUTO_INCREMENT təyin et",mysqlAutoIncrementTitle: "MySQL AUTO_INCREMENT təyin et",mysqlAutoIncrementMessage: '"{name}" üçün tələb olunan növbəti AUTO_INCREMENT dəyəri təyin edilsin?',- mysqlAutoIncrementNonemptyHint: "Boş olmayan cədvəldə MySQL istifadə olunan ID-ləri təkrar istifadə etmir. Növbəti faktiki dəyər ən azı MAX(id) + 1 olaraq qalır.",+ mysqlAutoIncrementNonemptyHint: "Boş olmayan cədvəldə sayğacı mövcud avtomatik artan sütunun maksimum dəyəri + 1-dən aşağı təyin etməyin; uyğun verilənlər bazaları daha aşağı dəyəri yox saya və ya rədd edə bilər.",mysqlAutoIncrementValue: "Tələb olunan növbəti dəyər",duplicateStructure: "Yeni cədvəl kimi klonla",renameObject: "Adını dəyiş",@@ -4879,7 +4879,7 @@ export default withEnglishFallback({autoIncrement: "Avtomatik artım",mysqlAutoIncrementSingleColumn: "MySQL hər cədvəldə yalnız bir avtomatik artan sütuna icazə verir.",mysqlAutoIncrementRequiresIndex: 'Avtomatik artan "{column}" sütunu üçün indeks tələb olunur; InnoDB-də bu sütun indeksin ilk sütunu olmalıdır.',- mysqlAutoIncrementRequiresNativeColumn: "Birbaşa MySQL bağlantısında avtomatik artan sütun tələb olunur.",+ mysqlAutoIncrementRequiresNativeColumn: "Avtomatik artan sütun tələb olunur.",mysqlAutoIncrementStartValue: "Avtomatik artımın başlanğıc dəyəri",editMysqlAutoIncrementStartValue: "Avtomatik artımın başlanğıc dəyərini dəyiş (cari: {value})",mysqlAutoIncrementStartHint: "Verilənlər bazasının standart dəyərini (adətən 1) istifadə etmək üçün boş saxlayın.",diff --git a/apps/desktop/src/i18n/locales/en.ts b/apps/desktop/src/i18n/locales/en.tsindex b7098e82b0..3d9ffe3978 100644--- a/apps/desktop/src/i18n/locales/en.ts+++ b/apps/desktop/src/i18n/locales/en.ts@@ -4459,7 +4459,7 @@ export default {mysqlAutoIncrement: "Set AUTO_INCREMENT",mysqlAutoIncrementTitle: "Set MySQL AUTO_INCREMENT",mysqlAutoIncrementMessage: 'Set the next AUTO_INCREMENT value requested for "{name}"?',- mysqlAutoIncrementNonemptyHint: "For a nonempty table, MySQL does not reuse occupied IDs. The effective next value remains at least MAX(id) + 1.",+ mysqlAutoIncrementNonemptyHint: "For a nonempty table, do not set the counter below the maximum existing auto-increment value plus 1; compatible databases may ignore or reject a lower value.",mysqlAutoIncrementValue: "Requested next value",duplicateStructure: "Clone as New Table",renameObject: "Rename",@@ -6021,7 +6021,7 @@ export default {autoIncrement: "Auto Increment",mysqlAutoIncrementSingleColumn: "MySQL allows only one auto-increment column per table.",mysqlAutoIncrementRequiresIndex: 'Auto-increment column "{column}" requires a supporting index; in InnoDB it must be the first key column.',- mysqlAutoIncrementRequiresNativeColumn: "An auto-increment column on a native MySQL connection is required.",+ mysqlAutoIncrementRequiresNativeColumn: "An auto-increment column is required.",mysqlAutoIncrementStartValue: "Auto-increment starting value",editMysqlAutoIncrementStartValue: "Edit auto-increment starting value (current: {value})",mysqlAutoIncrementStartHint: "Leave blank to use the database default (usually 1).",diff --git a/apps/desktop/src/i18n/locales/es.ts b/apps/desktop/src/i18n/locales/es.tsindex 9ad2f7186e..c4e50a20ec 100644--- a/apps/desktop/src/i18n/locales/es.ts+++ b/apps/desktop/src/i18n/locales/es.ts@@ -4200,7 +4200,7 @@ export default withEnglishFallback({mysqlAutoIncrement: "Establecer AUTO_INCREMENT",mysqlAutoIncrementTitle: "Establecer AUTO_INCREMENT de MySQL",mysqlAutoIncrementMessage: '¿Establecer el siguiente valor de AUTO_INCREMENT solicitado para "{name}"?',- mysqlAutoIncrementNonemptyHint: "En una tabla que no está vacía, MySQL no reutiliza los IDs ya ocupados. El siguiente valor efectivo seguirá siendo al menos MAX(id) + 1.",+ mysqlAutoIncrementNonemptyHint: "En una tabla que no esté vacía, no establezca el contador por debajo del valor máximo existente de autoincremento más 1; las bases de datos compatibles pueden ignorar o rechazar un valor inferior.",mysqlAutoIncrementValue: "Siguiente valor solicitado",duplicateStructure: "Clonar como tabla nueva",renameObject: "Renombrar",@@ -5278,7 +5278,7 @@ export default withEnglishFallback({autoIncrement: "Auto Incremento",mysqlAutoIncrementSingleColumn: "MySQL solo permite una columna de autoincremento por tabla.",mysqlAutoIncrementRequiresIndex: 'La columna de autoincremento "{column}" requiere un índice; en InnoDB debe ser la primera columna del índice.',- mysqlAutoIncrementRequiresNativeColumn: "Se requiere una columna de autoincremento en una conexión MySQL nativa.",+ mysqlAutoIncrementRequiresNativeColumn: "Se requiere una columna de autoincremento.",mysqlAutoIncrementStartValue: "Valor inicial de autoincremento",editMysqlAutoIncrementStartValue: "Editar el valor inicial de autoincremento (actual: {value})",mysqlAutoIncrementStartHint: "Deje en blanco para usar el valor predeterminado de la base de datos (normalmente 1).",diff --git a/apps/desktop/src/i18n/locales/id.ts b/apps/desktop/src/i18n/locales/id.tsindex bf38ef8a15..4f54894ec9 100644--- a/apps/desktop/src/i18n/locales/id.ts+++ b/apps/desktop/src/i18n/locales/id.ts@@ -4006,7 +4006,7 @@ export default withEnglishFallback({mysqlAutoIncrement: "Atur AUTO_INCREMENT",mysqlAutoIncrementTitle: "Atur AUTO_INCREMENT MySQL",mysqlAutoIncrementMessage: 'Atur nilai AUTO_INCREMENT berikutnya yang diminta untuk "{name}"?',- mysqlAutoIncrementNonemptyHint: "Untuk tabel yang tidak kosong, MySQL tidak menggunakan kembali ID yang sudah terpakai. Nilai efektif berikutnya tetap minimal MAX(id) + 1.",+ mysqlAutoIncrementNonemptyHint: "Untuk tabel yang tidak kosong, jangan atur penghitung di bawah nilai maksimum penambahan otomatis yang ada ditambah 1; basis data yang kompatibel dapat mengabaikan atau menolak nilai yang lebih rendah.",mysqlAutoIncrementValue: "Nilai berikutnya yang diminta",duplicateStructure: "Klon sebagai Tabel Baru",renameObject: "Ganti Nama",@@ -5538,7 +5538,7 @@ export default withEnglishFallback({autoIncrement: "Auto Increment",mysqlAutoIncrementSingleColumn: "MySQL hanya mengizinkan satu kolom penambahan otomatis per tabel.",mysqlAutoIncrementRequiresIndex: 'Kolom penambahan otomatis "{column}" memerlukan indeks; pada InnoDB kolom ini harus menjadi kolom pertama dalam indeks.',- mysqlAutoIncrementRequiresNativeColumn: "Diperlukan kolom penambahan otomatis pada koneksi MySQL native.",+ mysqlAutoIncrementRequiresNativeColumn: "Diperlukan kolom penambahan otomatis.",mysqlAutoIncrementStartValue: "Nilai awal penambahan otomatis",editMysqlAutoIncrementStartValue: "Edit nilai awal penambahan otomatis (saat ini: {value})",mysqlAutoIncrementStartHint: "Biarkan kosong untuk menggunakan nilai bawaan basis data (biasanya 1).",diff --git a/apps/desktop/src/i18n/locales/it.ts b/apps/desktop/src/i18n/locales/it.tsindex 4e7eff1f9e..3de4e00f2f 100644--- a/apps/desktop/src/i18n/locales/it.ts+++ b/apps/desktop/src/i18n/locales/it.ts@@ -5093,7 +5093,7 @@ export default withEnglishFallback({autoIncrement: "Auto Incremento",mysqlAutoIncrementSingleColumn: "MySQL consente una sola colonna di incremento automatico per tabella.",mysqlAutoIncrementRequiresIndex: 'La colonna di incremento automatico "{column}" richiede un indice; in InnoDB deve essere la prima colonna dell’indice.',- mysqlAutoIncrementRequiresNativeColumn: "È richiesta una colonna di incremento automatico su una connessione MySQL nativa.",+ mysqlAutoIncrementRequiresNativeColumn: "È richiesta una colonna di incremento automatico.",mysqlAutoIncrementStartValue: "Valore iniziale di incremento automatico",editMysqlAutoIncrementStartValue: "Modifica il valore iniziale di incremento automatico (attuale: {value})",mysqlAutoIncrementStartHint: "Lascia vuoto per usare il valore predefinito del database (di solito 1).",diff --git a/apps/desktop/src/i18n/locales/ja.ts b/apps/desktop/src/i18n/locales/ja.tsindex 1a220bd335..2f8b179d9d 100644--- a/apps/desktop/src/i18n/locales/ja.ts+++ b/apps/desktop/src/i18n/locales/ja.ts@@ -5155,7 +5155,7 @@ export default withEnglishFallback({autoIncrement: "自動採番",mysqlAutoIncrementSingleColumn: "MySQL ではテーブルごとに自動増分列を 1 つだけ設定できます。",mysqlAutoIncrementRequiresIndex: "自動増分列「{column}」にはインデックスが必要です。InnoDB ではインデックスの先頭列である必要があります。",- mysqlAutoIncrementRequiresNativeColumn: "ネイティブ MySQL 接続と自動増分列が必要です。",+ mysqlAutoIncrementRequiresNativeColumn: "自動増分列が必要です。",mysqlAutoIncrementStartValue: "自動増分の開始値",editMysqlAutoIncrementStartValue: "自動増分の開始値を編集(現在: {value})",mysqlAutoIncrementStartHint: "空欄の場合はデータベースの既定値(通常は 1)を使用します。",diff --git a/apps/desktop/src/i18n/locales/ko.ts b/apps/desktop/src/i18n/locales/ko.tsindex 2c0122e1a3..6185a92f37 100644--- a/apps/desktop/src/i18n/locales/ko.ts+++ b/apps/desktop/src/i18n/locales/ko.ts@@ -5135,7 +5135,7 @@ export default withEnglishFallback({autoIncrement: "자동 증가",mysqlAutoIncrementSingleColumn: "MySQL 테이블에는 자동 증가 열을 하나만 지정할 수 있습니다.",mysqlAutoIncrementRequiresIndex: '자동 증가 열 "{column}"에는 인덱스가 필요합니다. InnoDB에서는 인덱스의 첫 번째 열이어야 합니다.',- mysqlAutoIncrementRequiresNativeColumn: "네이티브 MySQL 연결과 자동 증가 열이 필요합니다.",+ mysqlAutoIncrementRequiresNativeColumn: "자동 증가 열이 필요합니다.",mysqlAutoIncrementStartValue: "자동 증가 시작값",editMysqlAutoIncrementStartValue: "자동 증가 시작값 편집 (현재: {value})",mysqlAutoIncrementStartHint: "비워 두면 데이터베이스 기본값(일반적으로 1)을 사용합니다.",diff --git a/apps/desktop/src/i18n/locales/pt-BR.ts b/apps/desktop/src/i18n/locales/pt-BR.tsindex c53769eacc..62c32f5119 100644--- a/apps/desktop/src/i18n/locales/pt-BR.ts+++ b/apps/desktop/src/i18n/locales/pt-BR.ts@@ -5093,7 +5093,7 @@ export default withEnglishFallback({autoIncrement: "Auto incremento",mysqlAutoIncrementSingleColumn: "O MySQL permite apenas uma coluna de incremento automático por tabela.",mysqlAutoIncrementRequiresIndex: 'A coluna de incremento automático "{column}" requer um índice; no InnoDB, ela deve ser a primeira coluna do índice.',- mysqlAutoIncrementRequiresNativeColumn: "É necessária uma coluna de incremento automático em uma conexão MySQL nativa.",+ mysqlAutoIncrementRequiresNativeColumn: "É necessária uma coluna de incremento automático.",mysqlAutoIncrementStartValue: "Valor inicial de incremento automático",editMysqlAutoIncrementStartValue: "Editar valor inicial de incremento automático (atual: {value})",mysqlAutoIncrementStartHint: "Deixe em branco para usar o padrão do banco de dados (geralmente 1).",diff --git a/apps/desktop/src/i18n/locales/ru.ts b/apps/desktop/src/i18n/locales/ru.tsindex c6fe069a49..d251148888 100644--- a/apps/desktop/src/i18n/locales/ru.ts+++ b/apps/desktop/src/i18n/locales/ru.ts@@ -4168,7 +4168,7 @@ export default withEnglishFallback({mysqlAutoIncrement: "Задать AUTO_INCREMENT",mysqlAutoIncrementTitle: "Задать MySQL AUTO_INCREMENT",mysqlAutoIncrementMessage: "Задать запрошенное следующее значение AUTO_INCREMENT для «{name}»?",- mysqlAutoIncrementNonemptyHint: "Для непустой таблицы MySQL не переиспользует занятые ID. Фактическое следующее значение остаётся не меньше MAX(id) + 1.",+ mysqlAutoIncrementNonemptyHint: "Для непустой таблицы не задавайте счётчик ниже максимального существующего значения автоинкремента плюс 1; совместимая база данных может проигнорировать или отклонить меньшее значение.",mysqlAutoIncrementValue: "Запрошенное следующее значение",duplicateStructure: "Клонировать как новую таблицу",renameObject: "Переименовать",@@ -5667,7 +5667,7 @@ export default withEnglishFallback({autoIncrement: "Автоувеличение",mysqlAutoIncrementSingleColumn: "MySQL допускает только один столбец автоинкремента в таблице.",mysqlAutoIncrementRequiresIndex: "Столбцу автоинкремента «{column}» нужен индекс; в InnoDB он должен быть первым столбцом индекса.",- mysqlAutoIncrementRequiresNativeColumn: "Требуется столбец автоинкремента при нативном подключении MySQL.",+ mysqlAutoIncrementRequiresNativeColumn: "Требуется столбец автоинкремента.",mysqlAutoIncrementStartValue: "Начальное значение автоинкремента",editMysqlAutoIncrementStartValue: "Изменить начальное значение автоинкремента (текущее: {value})",mysqlAutoIncrementStartHint: "Оставьте пустым для значения по умолчанию базы данных (обычно 1).",diff --git a/apps/desktop/src/i18n/locales/th.ts b/apps/desktop/src/i18n/locales/th.tsindex 8918851991..c8a48fdd2a 100644--- a/apps/desktop/src/i18n/locales/th.ts+++ b/apps/desktop/src/i18n/locales/th.ts@@ -4381,7 +4381,7 @@ export default withEnglishFallback({mysqlAutoIncrement: "ตั้งค่า AUTO_INCREMENT",mysqlAutoIncrementTitle: "ตั้งค่า MySQL AUTO_INCREMENT",mysqlAutoIncrementMessage: "ตั้งค่า AUTO_INCREMENT ถัดไปตามที่ขอสำหรับ “{name}” หรือไม่",- mysqlAutoIncrementNonemptyHint: "สำหรับ Table ที่มีข้อมูล MySQL จะไม่ใช้ ID ที่มีอยู่ซ้ำ ค่าถัดไปที่ใช้จริงจะไม่น้อยกว่า MAX(id) + 1",+ mysqlAutoIncrementNonemptyHint: "สำหรับตารางที่มีข้อมูล อย่าตั้งค่าตัวนับต่ำกว่าค่าสูงสุดของคอลัมน์ Auto-increment ที่มีอยู่บวก 1 ฐานข้อมูลที่เข้ากันได้อาจละเว้นหรือปฏิเสธค่าที่ต่ำกว่า",mysqlAutoIncrementValue: "ค่าถัดไปที่ขอ",duplicateStructure: "Clone เป็น Table ใหม่",renameObject: "เปลี่ยนชื่อ",@@ -5995,7 +5995,7 @@ export default withEnglishFallback({autoIncrement: "Auto Increment",mysqlAutoIncrementSingleColumn: "MySQL อนุญาต Column Auto-increment ได้เพียงหนึ่ง Column ต่อ Table",mysqlAutoIncrementRequiresIndex: "Column Auto-increment “{column}” ต้องมี Index รองรับ สำหรับ InnoDB ต้องเป็น Key Column แรก",- mysqlAutoIncrementRequiresNativeColumn: "ต้องมี Column Auto-increment บนการเชื่อมต่อ MySQL Native",+ mysqlAutoIncrementRequiresNativeColumn: "ต้องมีคอลัมน์ Auto-increment",mysqlAutoIncrementStartValue: "ค่าเริ่มต้น Auto-increment",editMysqlAutoIncrementStartValue: "แก้ไขค่าเริ่มต้น Auto-increment (ปัจจุบัน: {value})",mysqlAutoIncrementStartHint: "ปล่อยว่างเพื่อใช้ค่าเริ่มต้นของฐานข้อมูล (โดยทั่วไปคือ 1)",diff --git a/apps/desktop/src/i18n/locales/tr.ts b/apps/desktop/src/i18n/locales/tr.tsindex 3d675b42f7..1c591fe867 100644--- a/apps/desktop/src/i18n/locales/tr.ts+++ b/apps/desktop/src/i18n/locales/tr.ts@@ -3646,7 +3646,7 @@ export default withEnglishFallback({mysqlAutoIncrement: "AUTO_INCREMENT Ayarla",mysqlAutoIncrementTitle: "MySQL AUTO_INCREMENT Ayarla",mysqlAutoIncrementMessage: '"{name}" için istenen bir sonraki AUTO_INCREMENT değeri ayarlansın mı?',- mysqlAutoIncrementNonemptyHint: "Boş olmayan bir tabloda MySQL, kullanılmış kimlikleri yeniden kullanmaz. Geçerli sonraki değer en az MAX(id) + 1 olarak kalır.",+ mysqlAutoIncrementNonemptyHint: "Boş olmayan bir tabloda sayacı mevcut en yüksek otomatik artış değerinin 1 fazlasından daha düşük ayarlamayın; uyumlu veritabanları daha düşük bir değeri yok sayabilir veya reddedebilir.",mysqlAutoIncrementValue: "İstenen sonraki değer",duplicateStructure: "Yeni Tablo Olarak Çoğalt",renameObject: "Yeniden Adlandır",@@ -4781,7 +4781,7 @@ export default withEnglishFallback({autoIncrement: "Otomatik Artan",mysqlAutoIncrementSingleColumn: "MySQL her tabloda yalnızca bir otomatik artan sütuna izin verir.",mysqlAutoIncrementRequiresIndex: 'Otomatik artan "{column}" sütunu bir dizin gerektirir; InnoDB için dizinin ilk sütunu olmalıdır.',- mysqlAutoIncrementRequiresNativeColumn: "Yerel MySQL bağlantısında bir otomatik artan sütun gereklidir.",+ mysqlAutoIncrementRequiresNativeColumn: "Bir otomatik artan sütun gereklidir.",mysqlAutoIncrementStartValue: "Otomatik artış başlangıç değeri",editMysqlAutoIncrementStartValue: "Otomatik artış başlangıç değerini düzenle (geçerli: {value})",mysqlAutoIncrementStartHint: "Veritabanı varsayılanını (genellikle 1) kullanmak için boş bırakın.",diff --git a/apps/desktop/src/i18n/locales/zh-CN.ts b/apps/desktop/src/i18n/locales/zh-CN.tsindex efa75dd6a4..ac08beb8bf 100644--- a/apps/desktop/src/i18n/locales/zh-CN.ts+++ b/apps/desktop/src/i18n/locales/zh-CN.ts@@ -4389,7 +4389,7 @@ export default withEnglishFallback({mysqlAutoIncrement: "设置自增起始值",mysqlAutoIncrementTitle: "设置 MySQL 自增起始值",mysqlAutoIncrementMessage: "确定要设置表「{name}」请求的下一个自增值吗?",- mysqlAutoIncrementNonemptyHint: "对于非空表,MySQL 不会复用已占用的 ID;实际下一个值不会低于 MAX(id) + 1。",+ mysqlAutoIncrementNonemptyHint: "对于非空表,请勿将计数器设为低于现有自增列最大值 + 1;兼容数据库可能忽略或拒绝更低的值。",mysqlAutoIncrementValue: "请求的下一个值",duplicateStructure: "克隆为新表",renameObject: "重命名",@@ -6009,7 +6009,7 @@ export default withEnglishFallback({autoIncrement: "自增",mysqlAutoIncrementSingleColumn: "MySQL 每张表只能有一个自增字段。",mysqlAutoIncrementRequiresIndex: "自增字段“{column}”必须有有效索引;使用 InnoDB 时,该字段必须位于索引首列。",- mysqlAutoIncrementRequiresNativeColumn: "需要使用原生 MySQL 连接,并为表配置自增字段。",+ mysqlAutoIncrementRequiresNativeColumn: "需要为表配置自增字段。",mysqlAutoIncrementStartValue: "自增起始值",editMysqlAutoIncrementStartValue: "编辑自增起始值(当前:{value})",mysqlAutoIncrementStartHint: "留空使用数据库默认值(通常为 1)。",diff --git a/apps/desktop/src/i18n/locales/zh-TW.ts b/apps/desktop/src/i18n/locales/zh-TW.tsindex 27e4136bb7..4636acf802 100644--- a/apps/desktop/src/i18n/locales/zh-TW.ts+++ b/apps/desktop/src/i18n/locales/zh-TW.ts@@ -4835,7 +4835,7 @@ export default withEnglishFallback({autoIncrement: "自動遞增",mysqlAutoIncrementSingleColumn: "MySQL 每張表只能有一個自動遞增欄位。",mysqlAutoIncrementRequiresIndex: "自動遞增欄位「{column}」必須有有效索引;使用 InnoDB 時,該欄位必須位於索引首欄。",- mysqlAutoIncrementRequiresNativeColumn: "需要使用原生 MySQL 連線,並為資料表設定自動遞增欄位。",+ mysqlAutoIncrementRequiresNativeColumn: "需要為資料表設定自動遞增欄位。",mysqlAutoIncrementStartValue: "自動遞增起始值",editMysqlAutoIncrementStartValue: "編輯自動遞增起始值(目前:{value})",mysqlAutoIncrementStartHint: "留空使用資料庫預設值(通常為 1)。",diff --git a/apps/desktop/src/lib/__tests__/database/dbAdminSql.spec.ts b/apps/desktop/src/lib/__tests__/database/dbAdminSql.spec.tsindex dd264fcb33..e00452f77e 100644--- a/apps/desktop/src/lib/__tests__/database/dbAdminSql.spec.ts+++ b/apps/desktop/src/lib/__tests__/database/dbAdminSql.spec.ts@@ -25,7 +25,7 @@ import {oracleDuplicateTableCreateOptions,sqlServerClonePrimaryKeyConstraintName,SQLSERVER_IDENTIFIER_MAX_LENGTH,- supportsNativeMysqlAutoIncrement,+ supportsMysqlAutoIncrement,} from "@/lib/database/dbAdminSql";beforeEach(() => {@@ -33,24 +33,37 @@ beforeEach(() => {});describe("MySQL AUTO_INCREMENT administration", () => {- it("is available only for explicit native MySQL connections", () => {- expect(supportsNativeMysqlAutoIncrement({ db_type: "mysql", driver_profile: undefined })).toBe(true);- expect(supportsNativeMysqlAutoIncrement({ db_type: "mysql", driver_profile: "" })).toBe(true);- expect(supportsNativeMysqlAutoIncrement({ db_type: "mysql", driver_profile: " MySQL " })).toBe(true);-+ it("is available for supported MySQL-family connections", () => {for (const connection of [- { db_type: "jdbc", driver_profile: "mysql" },+ { db_type: "mysql", driver_profile: undefined },+ { db_type: "mysql", driver_profile: "" },+ { db_type: "mysql", driver_profile: " MySQL " },{ db_type: "mysql", driver_profile: "mariadb" },{ db_type: "mysql", driver_profile: "tidb" },{ db_type: "mysql", driver_profile: "oceanbase" },+ { db_type: "mysql", driver_profile: "tdsql" },+ { db_type: "mysql", driver_profile: "polardb" },+ { db_type: "mysql", driver_profile: "greatsql" },+ { db_type: "mysql", driver_profile: "custom_mysql" },{ db_type: "mysql", driver_profile: "dolt" },- { db_type: "goldendb", driver_profile: "goldendb" },{ db_type: "mysql", driver_profile: "goldendb" },+ { db_type: "goldendb", driver_profile: "goldendb" },+ ] as const) {+ expect(supportsMysqlAutoIncrement(connection as any), JSON.stringify(connection)).toBe(true);+ }++ for (const connection of [+ { db_type: "jdbc", driver_profile: "mysql" },+ { db_type: "mysql", driver_profile: "unknown" },{ db_type: "doris", driver_profile: "doris" },+ { db_type: "mysql", driver_profile: "doris" },+ { db_type: "mysql", driver_profile: "selectdb" },+ { db_type: "mysql", driver_profile: "starrocks" },+ { db_type: "mysql", driver_profile: "manticoresearch" },{ db_type: "doris", driver_profile: "selectdb" },{ db_type: "starrocks", driver_profile: "starrocks" },] as const) {- expect(supportsNativeMysqlAutoIncrement(connection as any)).toBe(false);+ expect(supportsMysqlAutoIncrement(connection as any), JSON.stringify(connection)).toBe(false);}});diff --git a/apps/desktop/src/lib/__tests__/table/mysqlAutoIncrementCounter.spec.ts b/apps/desktop/src/lib/__tests__/table/mysqlAutoIncrementCounter.spec.tsindex d9ffbb499d..3f864f04ef 100644--- a/apps/desktop/src/lib/__tests__/table/mysqlAutoIncrementCounter.spec.ts+++ b/apps/desktop/src/lib/__tests__/table/mysqlAutoIncrementCounter.spec.ts@@ -40,7 +40,7 @@ describe("MySQL table AUTO_INCREMENT counter", () => {});});- it("is editable for native-MySQL tables with an active auto-increment column draft", () => {+ it("is editable for supported MySQL-family tables with an active auto-increment column draft", () => {const nativeMysql = { db_type: "mysql", driver_profile: "mysql" } as any;expect(canEditMysqlAutoIncrementCounter(nativeMysql, false, [existingColumn(true)])).toBe(true);expect(canEditMysqlAutoIncrementCounter(nativeMysql, false, [{ ...existingColumn(true), original: undefined }])).toBe(true);@@ -49,12 +49,24 @@ describe("MySQL table AUTO_INCREMENT counter", () => {expect(canEditMysqlAutoIncrementCounter(nativeMysql, false, [{ ...existingColumn(true), markedForDrop: true }])).toBe(false);for (const connection of [- { db_type: "jdbc", driver_profile: "mysql" },{ db_type: "mysql", driver_profile: "mariadb" },{ db_type: "mysql", driver_profile: "tidb" },{ db_type: "mysql", driver_profile: "oceanbase" },+ { db_type: "mysql", driver_profile: "tdsql" },+ { db_type: "mysql", driver_profile: "polardb" },+ { db_type: "mysql", driver_profile: "greatsql" },+ { db_type: "mysql", driver_profile: "custom_mysql" },{ db_type: "mysql", driver_profile: "dolt" },{ db_type: "goldendb", driver_profile: "goldendb" },+ ] as const) {+ expect(canEditMysqlAutoIncrementCounter(connection as any, false, [existingColumn(true)])).toBe(true);+ }++ for (const connection of [+ { db_type: "jdbc", driver_profile: "mysql" },+ { db_type: "mysql", driver_profile: "doris" },+ { db_type: "mysql", driver_profile: "selectdb" },+ { db_type: "mysql", driver_profile: "starrocks" },] as const) {expect(canEditMysqlAutoIncrementCounter(connection as any, false, [existingColumn(true)])).toBe(false);}@@ -102,7 +114,8 @@ describe("MySQL auto-increment warning translations", () => {const t = (key: string, params: Record<string, unknown> = {}) => i18n.global.t(key, params);it("translates backend warnings and preserves unusual column names as text", () => {expect(translateMysqlAutoIncrementWarning(t, "MySQL allows only one AUTO_INCREMENT column per table.")).toBe("MySQL 每张表只能有一个自增字段。");- expect(translateMysqlAutoIncrementWarning(t, "AUTO_INCREMENT requires a native MySQL auto-increment column.")).toBe("需要使用原生 MySQL 连接,并为表配置自增字段。");+ expect(translateMysqlAutoIncrementWarning(t, "AUTO_INCREMENT requires an auto-increment column.")).toBe("需要为表配置自增字段。");+ expect(translateMysqlAutoIncrementWarning(t, "AUTO_INCREMENT requires a native MySQL auto-increment column.")).toBe("需要为表配置自增字段。");const column = 'id"<tag>\n{value}';expect(translateMysqlAutoIncrementWarning(t, `AUTO_INCREMENT column "${column}" requires a supporting index (first key column for InnoDB).`)).toBe(`自增字段“${column}”必须有有效索引;使用 InnoDB 时,该字段必须位于索引首列。`);expect(translateMysqlAutoIncrementWarning(t, "Unknown backend warning")).toBe("Unknown backend warning");diff --git a/apps/desktop/src/lib/database/dbAdminSql.ts b/apps/desktop/src/lib/database/dbAdminSql.tsindex 297d778293..3e45649b1d 100644--- a/apps/desktop/src/lib/database/dbAdminSql.ts+++ b/apps/desktop/src/lib/database/dbAdminSql.ts@@ -389,10 +389,14 @@ export function buildMysqlAutoIncrementSql(options: MysqlAutoIncrementSqlOptionsreturn api.buildMysqlAutoIncrementSql(options);}-export function supportsNativeMysqlAutoIncrement(connection: Pick<ConnectionConfig, "db_type" | "driver_profile"> | undefined): boolean {- if (connection?.db_type !== "mysql") return false;+const MYSQL_AUTO_INCREMENT_PROFILES = new Set(["mysql", "mariadb", "tidb", "oceanbase", "tdsql", "polardb", "greatsql", "custom_mysql", "dolt", "goldendb"]);++export function supportsMysqlAutoIncrement(connection: Pick<ConnectionConfig, "db_type" | "driver_profile"> | undefined): boolean {+ if (!connection) return false;+ if (connection.db_type === "goldendb") return true;+ if (connection.db_type !== "mysql") return false;const profile = connection.driver_profile?.trim().toLowerCase();- return !profile || profile === "mysql";+ return !profile || MYSQL_AUTO_INCREMENT_PROFILES.has(profile);}const DROP_TABLE_CASCADE_DATABASE_TYPES: readonly DatabaseType[] = ["postgres", "redshift", "gaussdb", "kwdb", "kingbase", "highgo", "uxdb", "vastbase", "opengauss"];diff --git a/apps/desktop/src/lib/table/mysqlAutoIncrementCounter.ts b/apps/desktop/src/lib/table/mysqlAutoIncrementCounter.tsindex bc2a7ab2ba..7a3389dfe8 100644--- a/apps/desktop/src/lib/table/mysqlAutoIncrementCounter.ts+++ b/apps/desktop/src/lib/table/mysqlAutoIncrementCounter.ts@@ -1,6 +1,6 @@import type { BackendErrorTranslate } from "@/i18n/backend-errors";import type { ConnectionConfig, DatabaseType } from "@/types/database";-import { supportsNativeMysqlAutoIncrement, type MysqlAutoIncrementSqlOptions } from "@/lib/database/dbAdminSql";+import { supportsMysqlAutoIncrement, type MysqlAutoIncrementSqlOptions } from "@/lib/database/dbAdminSql";import type { EditableStructureColumn } from "@/lib/table/tableStructureEditorSql";export interface MysqlAutoIncrementCounterDraft {@@ -20,7 +20,7 @@ export function refreshMysqlAutoIncrementCounterDraft(serverValue: string | null}export function canEditMysqlAutoIncrementCounter(connection: Pick<ConnectionConfig, "db_type" | "driver_profile"> | undefined, _isCreateMode: boolean, columns: readonly EditableStructureColumn[]): boolean {- if (!supportsNativeMysqlAutoIncrement(connection)) return false;+ if (!supportsMysqlAutoIncrement(connection)) return false;return columns.some((column) => !column.markedForDrop && column.extra.autoIncrement === true);}@@ -45,7 +45,7 @@ export function translateMysqlAutoIncrementWarning(t: BackendErrorTranslate, warif (warning === "MySQL allows only one AUTO_INCREMENT column per table.") {return t("structureEditor.mysqlAutoIncrementSingleColumn");}- if (warning === "AUTO_INCREMENT requires a native MySQL auto-increment column.") {+ if (warning === "AUTO_INCREMENT requires an auto-increment column." || warning === "AUTO_INCREMENT requires a native MySQL auto-increment column.") {return t("structureEditor.mysqlAutoIncrementRequiresNativeColumn");}const missingIndex = /^AUTO_INCREMENT column "([\s\S]*)" requires a supporting index \(first key column for InnoDB\)\.$/.exec(warning);diff --git a/crates/dbx-core/src/schema/mod.rs b/crates/dbx-core/src/schema/mod.rsindex bef1dbfff5..450f18aac1 100644--- a/crates/dbx-core/src/schema/mod.rs+++ b/crates/dbx-core/src/schema/mod.rs@@ -1159,17 +1159,13 @@ pub async fn get_mysql_table_auto_increment_core(table: &str,) -> Result<Option<String>, String> {let db_config = connection_config(state, connection_id).await;- let native_mysql = db_config.as_ref().is_some_and(|config| {- config.db_type == DatabaseType::Mysql- && config- .driver_profile- .as_deref()- .map(str::trim)- .is_none_or(|profile| profile.is_empty() || profile.eq_ignore_ascii_case("mysql"))+ let supported = db_config.as_ref().is_some_and(|config| {+ crate::db_admin_sql::supports_mysql_auto_increment(Some(config.db_type), config.driver_profile.as_deref())});- if !native_mysql {- return Err("AUTO_INCREMENT metadata is supported only for native MySQL connections.".to_string());+ if !supported {+ return Err("AUTO_INCREMENT metadata is supported only for compatible MySQL-family connections.".to_string());}+ let uses_agent_metadata = db_config.as_ref().is_some_and(|config| config.db_type == DatabaseType::Goldendb);retry_metadata_connection_for_session(state, connection_id, Some(database), None, || async {let pool_key = state.get_or_create_metadata_pool_for_session(connection_id, Some(database), None).await?;@@ -1178,12 +1174,60 @@ pub async fn get_mysql_table_auto_increment_core(PoolKind::Mysql(pool, mode) if *mode != MysqlMode::OceanBaseOracle => {db::mysql::get_table_auto_increment(pool, database, table).await}- _ => Err("AUTO_INCREMENT metadata is supported only for native MySQL connections.".to_string()),+ PoolKind::Agent(client) if uses_agent_metadata => {+ let sql = mysql_auto_increment_metadata_sql(database, table);+ let mut client = client.lock().await;+ let result = client+ .execute_query_with_timeout::<db::QueryResult>(+ agent_execute_query_params(+ &sql,+ Some(database),+ None,+ QueryExecutionOptions { max_rows: Some(1), ..Default::default() },+ ),+ agent_metadata_timeout(db_config.as_ref()),+ )+ .await?;+ mysql_auto_increment_from_query_result(result)+ }+ _ => Err("AUTO_INCREMENT metadata is supported only for compatible MySQL-family connections.".to_string()),}}).await}+fn mysql_auto_increment_metadata_sql(database: &str, table: &str) -> String {+ format!(+ "SELECT CAST(AUTO_INCREMENT AS CHAR) AS AUTO_INCREMENT FROM information_schema.TABLES WHERE TABLE_SCHEMA = {} AND TABLE_NAME = {} LIMIT 1",+ sql_string(database),+ sql_string(table),+ )+}++fn mysql_auto_increment_from_query_result(result: db::QueryResult) -> Result<Option<String>, String> {+ let column_index = result+ .columns+ .iter()+ .position(|column| column.eq_ignore_ascii_case("AUTO_INCREMENT"))+ .ok_or_else(|| "AUTO_INCREMENT metadata query did not return the AUTO_INCREMENT column.".to_string())?;+ let Some(value) = result.rows.first().and_then(|row| row.get(column_index)) else {+ return Ok(None);+ };+ let text = match value {+ serde_json::Value::Null => return Ok(None),+ serde_json::Value::String(value) => value.trim().to_string(),+ serde_json::Value::Number(value) => value.to_string(),+ _ => return Err("AUTO_INCREMENT metadata query returned a non-numeric value.".to_string()),+ };+ if text.is_empty() {+ return Ok(None);+ }+ if !text.bytes().all(|byte| byte.is_ascii_digit()) || text.parse::<u64>().is_err() {+ return Err("AUTO_INCREMENT metadata query returned an out-of-range value.".to_string());+ }+ Ok(Some(text))+}+async fn get_table_comment_core_for_session(state: &AppState,connection_id: &str,@@ -3141,18 +3185,19 @@ mod tests {filter_table_infos, filter_visible_schema_names, finalize_object_source, gaussdb_m_view_object_source_sql,gbase8a_object_statistics_sql, is_agent_postgres_metadata_fallback_config, is_mysql_external_driver_config,is_oracle_external_driver_config, is_retryable_metadata_error, metadata_error_action,- metadata_name_or_comment_matches, mysql_database_list_timeout, mysql_external_driver_ddl_from_query_result,- mysql_external_driver_ddl_sql, mysql_object_source_ddl_column_index, mysql_object_source_sql,- mysql_table_list_source_for_config, mysql_table_metadata_catalog, normalize_information_schema_table_type,- oracle_columns_from_query_result, oracle_columns_sql, oracle_columns_sql_for_resolved_owner,- oracle_completion_synonyms_sql, oracle_current_schema_from_query_result,- oracle_object_statistics_dba_segments_sql, oracle_object_statistics_from_query_result,- oracle_object_statistics_rows_only_sql, oracle_object_statistics_sql,- oracle_object_statistics_user_segments_sql, oracle_synonym_target_from_query_result, oracle_synonym_target_sql,- oracle_table_comment_sql, oracle_table_comments_sql, presto_like_columns_from_query_result,- presto_like_information_schema_columns_sql, presto_like_information_schema_tables_sql,- presto_like_tables_from_query_result, reference_key_columns_from_indexes, reference_keys_from_indexes,- replace_metadata_runtime, should_append_oracle_style_comment_ddl, should_query_oracle_columns_via_sql_first,+ metadata_name_or_comment_matches, mysql_auto_increment_from_query_result, mysql_auto_increment_metadata_sql,+ mysql_database_list_timeout, mysql_external_driver_ddl_from_query_result, mysql_external_driver_ddl_sql,+ mysql_object_source_ddl_column_index, mysql_object_source_sql, mysql_table_list_source_for_config,+ mysql_table_metadata_catalog, normalize_information_schema_table_type, oracle_columns_from_query_result,+ oracle_columns_sql, oracle_columns_sql_for_resolved_owner, oracle_completion_synonyms_sql,+ oracle_current_schema_from_query_result, oracle_object_statistics_dba_segments_sql,+ oracle_object_statistics_from_query_result, oracle_object_statistics_rows_only_sql,+ oracle_object_statistics_sql, oracle_object_statistics_user_segments_sql,+ oracle_synonym_target_from_query_result, oracle_synonym_target_sql, oracle_table_comment_sql,+ oracle_table_comments_sql, presto_like_columns_from_query_result, presto_like_information_schema_columns_sql,+ presto_like_information_schema_tables_sql, presto_like_tables_from_query_result,+ reference_key_columns_from_indexes, reference_keys_from_indexes, replace_metadata_runtime,+ should_append_oracle_style_comment_ddl, should_query_oracle_columns_via_sql_first,single_table_comment_from_query_result, table_comments_from_query_result, table_name_filter_matches,tdengine_table_comment_like_pattern, tdengine_table_comment_sql, tdengine_table_comments_sql,uses_mongodb_agent_collection_listing, visible_schema_filter, ExternalDriverStatisticsDialect,@@ -5750,6 +5795,44 @@ for line in sys.stdin:assert_eq!(single_table_comment_from_query_result(empty).unwrap(), None);}+ #[test]+ fn mysql_auto_increment_agent_metadata_is_quoted_and_lossless() {+ let sql = mysql_auto_increment_metadata_sql("sales'archive", "order'items");+ assert!(sql.contains("CAST(AUTO_INCREMENT AS CHAR) AS AUTO_INCREMENT"));+ assert!(sql.contains("TABLE_SCHEMA = 'sales''archive'"));+ assert!(sql.contains("TABLE_NAME = 'order''items'"));++ let result = db::QueryResult {+ columns: vec!["AUTO_INCREMENT".to_string()],+ column_types: Vec::new(),+ column_sortables: Vec::new(),+ spatial_columns: vec![],+ spatial_values: vec![],+ rows: vec![vec![serde_json::json!("18446744073709551615")]],+ affected_rows: 0,+ execution_time_ms: 0,+ server_execute_time_us: None,+ query_timings_ms: None,+ truncated: false,+ session_id: None,+ has_more: false,+ elasticsearch_raw_body: None,+ messages: Vec::new(),+ };+ assert_eq!(+ mysql_auto_increment_from_query_result(result.clone()).unwrap().as_deref(),+ Some("18446744073709551615")+ );++ let mut null = result.clone();+ null.rows = vec![vec![serde_json::Value::Null]];+ assert_eq!(mysql_auto_increment_from_query_result(null).unwrap(), None);++ let mut out_of_range = result;+ out_of_range.rows = vec![vec![serde_json::json!("18446744073709551616")]];+ assert!(mysql_auto_increment_from_query_result(out_of_range).is_err());+ }+#[test]fn oracle_table_comments_sql_targets_current_page_tables() {let sql = oracle_table_comments_sql("dbx_test", &["ORDERS".to_string(), "USER'S".to_string()]).unwrap();diff --git a/crates/dbx-sql-schema/src/db_admin_sql.rs b/crates/dbx-sql-schema/src/db_admin_sql.rsindex 4ae28a90ca..99a78d1ffc 100644--- a/crates/dbx-sql-schema/src/db_admin_sql.rs+++ b/crates/dbx-sql-schema/src/db_admin_sql.rs@@ -250,6 +250,8 @@ pub struct CopyTableDataSqlOptions {const MYSQL_COMPATIBLE_PROFILES: &[&str] = &["mysql", "mariadb", "tidb", "oceanbase", "custom_mysql"];const CREATE_DATABASE_CHARSET_UNSUPPORTED_PROFILES: &[&str] = &["doris", "selectdb", "starrocks"];+const MYSQL_AUTO_INCREMENT_PROFILES: &[&str] =+ &["mysql", "mariadb", "tidb", "oceanbase", "tdsql", "polardb", "greatsql", "custom_mysql", "dolt", "goldendb"];pub fn supports_create_database_charset(database_type: Option<DatabaseType>, driver_profile: Option<&str>) -> bool {let normalized_profile = driver_profile.map(str::to_ascii_lowercase);@@ -263,6 +265,17 @@ pub fn supports_create_database_charset(database_type: Option<DatabaseType>, dri|| normalized_profile.as_deref().is_some_and(|profile| MYSQL_COMPATIBLE_PROFILES.contains(&profile))}+pub fn supports_mysql_auto_increment(database_type: Option<DatabaseType>, driver_profile: Option<&str>) -> bool {+ if database_type == Some(DatabaseType::Goldendb) {+ return true;+ }+ if database_type != Some(DatabaseType::Mysql) {+ return false;+ }+ let profile = driver_profile.map(str::trim).unwrap_or_default();+ profile.is_empty() || MYSQL_AUTO_INCREMENT_PROFILES.iter().any(|candidate| profile.eq_ignore_ascii_case(candidate))+}+pub fn build_create_database_sql(options: CreateDatabaseSqlOptions) -> Result<String, String> {match options.target.unwrap_or(DatabaseCreationTarget::Database) {DatabaseCreationTarget::Database => build_create_database_statement(&options),@@ -653,11 +666,8 @@ fn supports_vacuum_table(database_type: Option<DatabaseType>) -> bool {}pub(crate) fn validate_mysql_auto_increment_options(options: &MysqlAutoIncrementSqlOptions) -> Result<(), String> {- let profile = options.driver_profile.as_deref().map(str::trim).unwrap_or_default();- if options.database_type != Some(DatabaseType::Mysql)- || (!profile.is_empty() && !profile.eq_ignore_ascii_case("mysql"))- {- return Err("Setting AUTO_INCREMENT is supported only for native MySQL connections.".to_string());+ if !supports_mysql_auto_increment(options.database_type, options.driver_profile.as_deref()) {+ return Err("Setting AUTO_INCREMENT is supported only for compatible MySQL-family connections.".to_string());}let value = options.value.as_str();@@ -2169,6 +2179,31 @@ mod tests {);}+ for (database_type, driver_profile) in [+ (Some(DatabaseType::Mysql), None),+ (Some(DatabaseType::Mysql), Some("mariadb".to_string())),+ (Some(DatabaseType::Mysql), Some("tidb".to_string())),+ (Some(DatabaseType::Mysql), Some("oceanbase".to_string())),+ (Some(DatabaseType::Mysql), Some("tdsql".to_string())),+ (Some(DatabaseType::Mysql), Some("polardb".to_string())),+ (Some(DatabaseType::Mysql), Some("greatsql".to_string())),+ (Some(DatabaseType::Mysql), Some("custom_mysql".to_string())),+ (Some(DatabaseType::Mysql), Some("dolt".to_string())),+ (Some(DatabaseType::Mysql), Some("goldendb".to_string())),+ (Some(DatabaseType::Goldendb), Some("goldendb".to_string())),+ ] {+ assert_eq!(+ build_mysql_auto_increment_sql(MysqlAutoIncrementSqlOptions {+ database_type,+ driver_profile,+ schema: Some("sales".to_string()),+ table_name: "events".to_string(),+ value: "42".to_string(),+ }),+ Ok("ALTER TABLE `sales`.`events` AUTO_INCREMENT = 42;".to_string())+ );+ }+for value in["", "0", "01", " 1", "1 ", "+1", "-1", "1.0", "1e3", "1; DROP TABLE users", "18446744073709551616"]{@@ -2188,12 +2223,12 @@ mod tests {for (database_type, driver_profile) in [(Some(DatabaseType::Postgres), None),(Some(DatabaseType::Jdbc), Some("mysql".to_string())),- (Some(DatabaseType::Mysql), Some("mariadb".to_string())),- (Some(DatabaseType::Mysql), Some("tidb".to_string())),- (Some(DatabaseType::Mysql), Some("oceanbase".to_string())),- (Some(DatabaseType::Mysql), Some("dolt".to_string())),- (Some(DatabaseType::Goldendb), Some("goldendb".to_string())),- (Some(DatabaseType::Doris), Some("selectdb".to_string())),+ (Some(DatabaseType::Mysql), Some("unknown".to_string())),+ (Some(DatabaseType::Mysql), Some("doris".to_string())),+ (Some(DatabaseType::Mysql), Some("selectdb".to_string())),+ (Some(DatabaseType::Mysql), Some("starrocks".to_string())),+ (Some(DatabaseType::Mysql), Some("manticoresearch".to_string())),+ (Some(DatabaseType::Doris), Some("doris".to_string())),(Some(DatabaseType::StarRocks), Some("starrocks".to_string())),] {assert!(build_mysql_auto_increment_sql(MysqlAutoIncrementSqlOptions {diff --git a/crates/dbx-sql-schema/src/table_structure_sql/create_table.rs b/crates/dbx-sql-schema/src/table_structure_sql/create_table.rsindex 7981f9781c..3addb3b8d1 100644--- a/crates/dbx-sql-schema/src/table_structure_sql/create_table.rs+++ b/crates/dbx-sql-schema/src/table_structure_sql/create_table.rs@@ -100,7 +100,7 @@ fn build_create_table_sql_impl(!column.marked_for_drop && column.extra.as_ref().is_some_and(|extra| extra.auto_increment == Some(true))}){- warnings.push("AUTO_INCREMENT requires a native MySQL auto-increment column.".to_string());+ warnings.push("AUTO_INCREMENT requires an auto-increment column.".to_string());}}// Fail closed: a concurrent-index request on a partitioned parent (or on an