fix(mysql): return CHECKSUM TABLE result set

This commit is contained in:
Melody Ruch
2026-08-20 08:35:14 +08:00
committed by GitHub
parent c35f791681
commit dc8b083c63
2 changed files with 11 additions and 2 deletions
+9 -1
View File
@@ -5291,7 +5291,7 @@ fn prefers_text_protocol_query(sql: &str, dialect: MySqlQueryDialect) -> bool {
pub(crate) fn is_result_set_query(sql: &str, dialect: MySqlQueryDialect) -> bool {
starts_with_executable_sql_keyword_for_database(
sql,
&["SELECT", "SHOW", "DESCRIBE", "EXPLAIN", "WITH", "CALL"],
&["SELECT", "SHOW", "DESCRIBE", "EXPLAIN", "WITH", "CALL", "CHECKSUM"],
DatabaseType::Mysql,
) || mysql_statement_returns_rows(sql)
|| is_xa_recover_query(sql)
@@ -6087,6 +6087,14 @@ mod tests {
assert!(is_result_set_query("DESC users", MySqlQueryDialect::default()));
}
#[test]
fn mysql_checksum_queries_are_treated_as_result_sets() {
let dialect = MySqlQueryDialect::default();
assert!(is_result_set_query("CHECKSUM TABLE `issue6693_repro`", dialect));
assert!(prefers_text_protocol_query("CHECKSUM TABLE `issue6693_repro`", dialect));
}
#[test]
fn mysql_call_queries_are_treated_as_text_result_sets() {
let dialect = MySqlQueryDialect::default();
+2 -1
View File
@@ -211,7 +211,7 @@ pub fn contains_dangerous_sql_keyword(sql: &str) -> bool {
/// PRAGMA is intentionally NOT in this list because some PRAGMA statements modify
/// database or session state (e.g. SQLite `PRAGMA journal_mode=WAL`). Instead,
/// read-only PRAGMA forms are handled separately in `is_safe_read_pragma`.
const READ_SQL_KEYWORDS: &[&str] = &["SELECT", "WITH", "SHOW", "DESCRIBE", "DESC", "EXPLAIN", "FROM"];
const READ_SQL_KEYWORDS: &[&str] = &["SELECT", "WITH", "SHOW", "DESCRIBE", "DESC", "EXPLAIN", "FROM", "CHECKSUM"];
/// PRAGMA names that are known to be safe read-only queries in SQLite/DuckDB.
/// Only the function-call form `PRAGMA name(args)` matching these names is allowed.
@@ -1288,6 +1288,7 @@ mod tests {
assert!(!is_write_sql("EXPLAIN SELECT * FROM users"));
assert!(!is_write_sql("PRAGMA table_info(users)"));
assert!(!is_write_sql("FROM users SELECT *"));
assert!(!is_write_sql("CHECKSUM TABLE `issue6693_repro`"));
}
#[test]