Skip to content

armgit / dbx

Public Imported from GitHub
0

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。

fix: pass connection query timeout to execute_batch so ALTER respects configured timeout

t8y2293600d9b46d
diff --git a/apps/desktop/src/components/structure/TableStructureEditor.vue b/apps/desktop/src/components/structure/TableStructureEditor.vue
index f93943fa4f..415588eb28 100644
--- a/apps/desktop/src/components/structure/TableStructureEditor.vue
+++ b/apps/desktop/src/components/structure/TableStructureEditor.vue
@@ -41,6 +41,7 @@ import { useTheme } from "@/composables/useTheme";
import { useToast } from "@/composables/useToast";
import { type SqlHighlighter, createShikiSqlHighlighter } from "@/lib/sqlHighlighter";
import { copyToClipboard } from "@/lib/clipboard";
+import { queryTimeoutSecsForConnection } from "@/lib/queryTimeout";
import { type EditableStructureColumn, type EditableStructureIndex } from "@/lib/tableStructureEditorSql";
import { getTableStructureCapabilities } from "@/lib/tableStructureCapabilities";
import {
@@ -676,7 +677,15 @@ async function applyChanges() {
const sql = previewSqlText.value;
const startedAt = Date.now();
try {
- const result = await api.executeBatch(props.connectionId, props.database, pendingStatements.value);
+ const connection = store.getConfig(props.connectionId);
+ const timeoutSecs = queryTimeoutSecsForConnection(connection);
+ const result = await api.executeBatch(
+ props.connectionId,
+ props.database,
+ pendingStatements.value,
+ props.schema,
+ timeoutSecs,
+ );
await recordStructureHistory(sql, startedAt, true, result);
toast(t("structureEditor.saved"), 2500);
emit("saved", tableComment.value !== originalTableComment.value);
diff --git a/apps/desktop/src/lib/tauri.ts b/apps/desktop/src/lib/tauri.ts
index d7914b9214..2c93ee777a 100644
--- a/apps/desktop/src/lib/tauri.ts
+++ b/apps/desktop/src/lib/tauri.ts
@@ -520,8 +520,9 @@ export async function executeBatch(
database: string,
statements: string[],
schema?: string,
+ timeoutSecs?: number,
): Promise<QueryResult> {
- return invoke("execute_batch", { connectionId, database, statements, schema });
+ return invoke("execute_batch", { connectionId, database, statements, schema, timeoutSecs });
}
export async function executeScript(
diff --git a/crates/dbx-core/src/query.rs b/crates/dbx-core/src/query.rs
index 01d7b45e28..e46091254a 100644
--- a/crates/dbx-core/src/query.rs
+++ b/crates/dbx-core/src/query.rs
@@ -1011,6 +1011,7 @@ pub async fn execute_statements(
database: &str,
statements: &[String],
schema: Option<&str>,
+ timeout_secs: Option<u64>,
) -> Result<db::QueryResult, String> {
let pool_key = if database.is_empty() {
connection_id.to_string()
@@ -1031,7 +1032,7 @@ pub async fn execute_statements(
sql,
schema,
None,
- QueryExecutionOptions::default(),
+ QueryExecutionOptions { timeout_secs, ..Default::default() },
)
.await
{
diff --git a/crates/dbx-web/src/routes/query.rs b/crates/dbx-web/src/routes/query.rs
index 8a94e73386..dc2ca0be55 100644
--- a/crates/dbx-web/src/routes/query.rs
+++ b/crates/dbx-web/src/routes/query.rs
@@ -53,6 +53,7 @@ pub struct ExecuteBatchRequest {
pub database: String,
pub statements: Vec<String>,
pub schema: Option<String>,
+ pub timeout_secs: Option<u64>,
}
#[derive(Deserialize)]
@@ -336,6 +337,7 @@ pub async fn execute_batch(
&req.database,
&req.statements,
req.schema.as_deref(),
+ req.timeout_secs,
)
.await
.map_err(AppError)?;
@@ -399,6 +401,7 @@ pub async fn execute_script(
&req.database,
&statements,
req.schema.as_deref(),
+ None,
)
.await
.map_err(AppError)?;
diff --git a/src-tauri/src/commands/query.rs b/src-tauri/src/commands/query.rs
index be87a33c02..d91f35c44a 100644
--- a/src-tauri/src/commands/query.rs
+++ b/src-tauri/src/commands/query.rs
@@ -145,8 +145,10 @@ pub async fn execute_batch(
database: String,
statements: Vec<String>,
schema: Option<String>,
+ timeout_secs: Option<u64>,
) -> Result<db::QueryResult, String> {
- dbx_core::query::execute_statements(&state, &connection_id, &database, &statements, schema.as_deref()).await
+ dbx_core::query::execute_statements(&state, &connection_id, &database, &statements, schema.as_deref(), timeout_secs)
+ .await
}
#[tauri::command]
@@ -171,6 +173,7 @@ pub async fn execute_script(
|db_type| dbx_core::sql::split_sql_statements_for_database(&sql, db_type),
),
schema.as_deref(),
+ None,
)
.await
}