mirror of
https://github.com/t8y2/dbx.git
synced 2026-10-20 00:17:44 +00:00
fix(mysql): return CHECKSUM TABLE result set
This commit is contained in:
@@ -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();
|
||||
|
||||
@@ -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]
|
||||
|
||||
Reference in New Issue
Block a user