From 20d667a19b35910cfc2bebf3a8015310ee382f6d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20No=C3=A9=20N=C3=BA=C3=B1ez=20L=C3=B3pez?= Date: Fri, 26 Jun 2026 13:23:53 -0700 Subject: [PATCH] fix(mysql): route view DDL through text protocol create_view, alter_view and drop_view executed their statements via sqlx::query(), which uses MySQL's prepared-statement protocol. MySQL rejects CREATE VIEW / ALTER VIEW there with error 1295 ("This command is not supported in the prepared statement protocol yet"), so saving a view from the view editor failed. Route all three through sqlx::raw_sql() (COM_QUERY text protocol), matching the existing handling for transaction-control statements. --- src-tauri/src/drivers/mysql/mod.rs | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/src-tauri/src/drivers/mysql/mod.rs b/src-tauri/src/drivers/mysql/mod.rs index a01e5591..5c23b690 100644 --- a/src-tauri/src/drivers/mysql/mod.rs +++ b/src-tauri/src/drivers/mysql/mod.rs @@ -651,7 +651,10 @@ pub async fn create_view( let pool = get_mysql_pool(params).await?; let escaped_name = escape_identifier(view_name); let query = format!("CREATE VIEW `{}` AS {}", escaped_name, definition); - sqlx::query(&query) + // `CREATE VIEW` is not supported by MySQL's prepared-statement protocol + // (server error 1295), so it must go through `raw_sql()` (text protocol) + // rather than `sqlx::query()`. See `is_text_protocol_stmt` for context. + sqlx::raw_sql(&query) .execute(&pool) .await .map_err(|e| format!("Failed to create view: {}", e))?; @@ -666,7 +669,10 @@ pub async fn alter_view( let pool = get_mysql_pool(params).await?; let escaped_name = escape_identifier(view_name); let query = format!("ALTER VIEW `{}` AS {}", escaped_name, definition); - sqlx::query(&query) + // `ALTER VIEW` is not supported by MySQL's prepared-statement protocol + // (server error 1295), so it must go through `raw_sql()` (text protocol) + // rather than `sqlx::query()`. See `is_text_protocol_stmt` for context. + sqlx::raw_sql(&query) .execute(&pool) .await .map_err(|e| format!("Failed to alter view: {}", e))?; @@ -677,7 +683,10 @@ pub async fn drop_view(params: &ConnectionParams, view_name: &str) -> Result<(), let pool = get_mysql_pool(params).await?; let escaped_name = escape_identifier(view_name); let query = format!("DROP VIEW IF EXISTS `{}`", escaped_name); - sqlx::query(&query) + // Routed through `raw_sql()` (text protocol) for consistency with + // create/alter view, which the prepared-statement protocol rejects + // with server error 1295. + sqlx::raw_sql(&query) .execute(&pool) .await .map_err(|e| format!("Failed to drop view: {}", e))?;