Skip to main content

validate_read_only_with_dialect

Function validate_read_only_with_dialect 

Source
pub fn validate_read_only_with_dialect(
    sql: &str,
    dialect: &impl Dialect,
) -> Result<(), AppError>
Expand description

Validates that a SQL query is read-only.

Parses the query using the given dialect and checks:

  1. Exactly one statement (multi-statement injection blocked)
  2. Statement type is read-only (SELECT, SHOW, DESCRIBE, USE, EXPLAIN)
  3. No dangerous functions (LOAD_FILE)
  4. No INTO OUTFILE/DUMPFILE clauses

ยงErrors

Returns AppError if the query is not allowed in read-only mode.