Skip to main content

classify_sql

Function classify_sql 

Source
pub fn classify_sql(sql: &str) -> Result<SqlClassification>
Expand description

Classify a SQL statement as read-only or rejected.

Uses a whitelist-only approach: only SELECT queries and EXPLAIN (without ANALYZE) are allowed. All other statements are rejected.

§Arguments

  • sql - The SQL statement to classify

§Returns

  • Ok(SqlClassification::ReadOnly) if the statement is safe
  • Ok(SqlClassification::Rejected(reason)) if the statement is not allowed
  • Err if parsing fails

§Errors

Returns a validation error if the SQL cannot be parsed.