mirror of
https://github.com/t8y2/dbx.git
synced 2026-10-23 02:40:11 +00:00
fix: pass connection query timeout to execute_batch so ALTER respects configured timeout
Previously execute_batch always used the hardcoded 30s default timeout, ignoring the user's query_timeout_secs connection setting. This caused long-running ALTER TABLE statements on large tables to time out even when the user configured a longer timeout or disabled it entirely.
This commit is contained in:
@@ -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);
|
||||
|
||||
@@ -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(
|
||||
|
||||
@@ -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
|
||||
{
|
||||
|
||||
@@ -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)?;
|
||||
|
||||
@@ -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
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user