Execute SQL via `execute_request` from sql.rs.
(
client: &mut AuthedClient,
query: &str,
)
| 932 | |
| 933 | /// Execute SQL via `execute_request` from sql.rs. |
| 934 | async fn execute_sql( |
| 935 | client: &mut AuthedClient, |
| 936 | query: &str, |
| 937 | ) -> Result<Vec<Vec<serde_json::Value>>, McpRequestError> { |
| 938 | let mut response = SqlResponse::new(); |
| 939 | |
| 940 | execute_request( |
| 941 | client, |
| 942 | SqlRequest::Simple { |
| 943 | query: mz_ore::sql::Sql::trusted_external_request(query.to_string()), |
| 944 | }, |
| 945 | &mut response, |
| 946 | ) |
| 947 | .await |
| 948 | .map_err(|e| McpRequestError::QueryExecutionFailed(e.to_string()))?; |
| 949 | |
| 950 | // Extract the result with rows (the user's single SELECT/SHOW query) |
| 951 | // Other results will be OK (from BEGIN, SET, COMMIT) or Err |
| 952 | for result in response.results { |
| 953 | match result { |
| 954 | SqlResult::Rows { rows, .. } => return Ok(rows), |
| 955 | SqlResult::Err { error, .. } => { |
| 956 | return Err(McpRequestError::QueryExecutionFailed(error.message)); |
| 957 | } |
| 958 | SqlResult::Ok { .. } => continue, |
| 959 | } |
| 960 | } |
| 961 | |
| 962 | Err(McpRequestError::QueryExecutionFailed( |
| 963 | "Query did not return any results".to_string(), |
| 964 | )) |
| 965 | } |
| 966 | |
| 967 | /// Serialize rows to JSON and enforce the response size cap. |
| 968 | /// |
no test coverage detected