MCPcopy Create free account
hub / github.com/erans/pgsqlite / is_read_only_query

Function is_read_only_query

src/session/read_only_handler.rs:165–176  ·  view source on GitHub ↗

Check if a SQL query is read-only

(sql: &str)

Source from the content-addressed store, hash-verified

163
164/// Check if a SQL query is read-only
165fn is_read_only_query(sql: &str) -> bool {
166 let sql_upper = sql.trim().to_uppercase();
167
168 // Allow only SELECT statements and certain pragmas
169 sql_upper.starts_with("SELECT")
170 || sql_upper.starts_with("WITH") // CTEs
171 || sql_upper.starts_with("EXPLAIN")
172 || sql_upper.starts_with("PRAGMA TABLE_INFO")
173 || sql_upper.starts_with("PRAGMA INDEX_LIST")
174 || sql_upper.starts_with("PRAGMA FOREIGN_KEY_LIST")
175 // Add other read-only pragmas as needed
176}
177
178
179#[cfg(test)]

Callers 2

queryMethod · 0.85
query_with_paramsMethod · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected