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(mysql): retry Gaea group concat setup on parse error

ccqcabc67ca7272
diff --git a/crates/dbx-drivers/src/db/mysql.rs b/crates/dbx-drivers/src/db/mysql.rs
index b783b718a5..4bcb867548 100644
--- a/crates/dbx-drivers/src/db/mysql.rs
+++ b/crates/dbx-drivers/src/db/mysql.rs
@@ -1484,6 +1484,11 @@ fn mysql_group_concat_setup_fallback_mode(setup_mode: MySqlSetupMode, error: &st
|| lower.contains("syntax error")
|| lower.contains("not supported");
let setup_value_rejected = lower.contains("error 1231") && lower.contains("can't be set to");
+ // Gaea tries to parse the built-in floor expression as an integer literal.
+ let gaea_setup_expression_rejected = lower.contains("error 1105 (hy000)")
+ && compact.contains(&format!(
+ "strconv.parseint:parsing\"cast(greatest(@@session.group_concat_max_len,{MYSQL_GROUP_CONCAT_MAX_LEN})asunsigned)\":invalidsyntax"
+ ));
// SphinxQL / Manticore reject the built-in `group_concat_max_len` setup with a
// boolean-typed 1064 error. The quoted token after `near` depends on the exact
// statement text, so accept any boolean rejection from SphinxQL that mentions
@@ -1501,6 +1506,7 @@ fn mysql_group_concat_setup_fallback_mode(setup_mode: MySqlSetupMode, error: &st
let floor_statement_rejected = lower.contains("group_concat_max_len")
|| compact.contains(&format!("..._len,{MYSQL_GROUP_CONCAT_MAX_LEN})asunsigned)"));
if (floor_statement_rejected && (setup_query_rejected || setup_value_rejected))
+ || gaea_setup_expression_rejected
|| sphinxql_setup_query_rejected
|| gateway_session_variable_rejected
{
@@ -8335,6 +8341,30 @@ mod tests {
);
}
+ #[test]
+ fn mysql_group_concat_gaea_parse_int_error_retries_without_session_variable() {
+ let error = "MySQL connection failed: Server error: `ERROR 1105 (HY000): strconv.ParseInt: parsing \"cast(greatest(@@session.group_concat_max_len, 1048576) as unsigned)\": invalid syntax'";
+
+ assert_eq!(
+ mysql_group_concat_setup_fallback_mode(MySqlSetupMode::Standard, error),
+ Some(MySqlSetupMode::Compatible)
+ );
+ assert_eq!(mysql_group_concat_setup_fallback_mode(MySqlSetupMode::Compatible, error), None);
+ }
+
+ #[test]
+ fn mysql_group_concat_gaea_parse_int_retry_requires_builtin_expression() {
+ for error in [
+ "Server error: `ERROR 1105 (HY000): strconv.ParseInt: parsing \"cast(greatest(@@session.group_concat_max_len, 2097152) as unsigned)\": invalid syntax'",
+ "Server error: `ERROR 1105 (HY000): strconv.ParseInt: parsing \"cast(greatest(@@session.sql_mode, 1048576) as unsigned)\": invalid syntax'",
+ "Server error: `ERROR 1105 (HY000): strconv.ParseInt: parsing \"cast(greatest(@@session.group_concat_max_len, 1048576) as unsigned)\": invalid value'",
+ "Server error: `ERROR 1105 (HY000): strconv.ParseInt: parsing \"1048576\": invalid syntax'",
+ "Server error: `ERROR 1231 (HY000): strconv.ParseInt: parsing \"cast(greatest(@@session.group_concat_max_len, 1048576) as unsigned)\": invalid syntax'",
+ ] {
+ assert_eq!(mysql_group_concat_setup_fallback_mode(MySqlSetupMode::Standard, error), None, "{error}");
+ }
+ }
+
#[test]
fn mysql_gateway_forbidden_global_variables_error_retries_without_session_variable() {
let error = "MySQL connection failed: Server error: `ERROR 10192 (HY000): SET GLOBAL VARIABLES is forbidden'";