#[derive(Debug, thiserror::Error)]
pub enum SqlError {
#[error("Query blocked: only SELECT, SHOW, DESC, DESCRIBE, USE queries are allowed in read-only mode")]
ReadOnlyViolation,
#[error("Operation forbidden: LOAD_FILE() is not allowed for security reasons")]
LoadFileBlocked,
#[error("Operation forbidden: SELECT INTO OUTFILE/DUMPFILE is not allowed for security reasons")]
IntoOutfileBlocked,
#[error("Query blocked: only single statements are allowed")]
MultiStatement,
#[error("Invalid identifier '{0}': must not be empty, whitespace-only, or contain control characters")]
InvalidIdentifier(String),
#[error("Query timed out after {elapsed_secs:.1}s: {sql}")]
QueryTimeout {
elapsed_secs: f64,
sql: String,
},
#[error("Database error: {0}")]
Query(String),
#[error("Table not found: {0}")]
TableNotFound(String),
}
impl From<SqlError> for rmcp::model::ErrorData {
fn from(e: SqlError) -> Self {
Self::internal_error(e.to_string(), None)
}
}