| 36 | } |
| 37 | |
| 38 | pub fn plan_delete_array(ast: &DeleteArrayAst, catalog: &dyn SqlCatalog) -> Result<Vec<SqlPlan>> { |
| 39 | let view = catalog |
| 40 | .lookup_array(&ast.name) |
| 41 | .ok_or_else(|| SqlError::Parse { |
| 42 | detail: format!("DELETE FROM ARRAY {}: array not found", ast.name), |
| 43 | })?; |
| 44 | if ast.coords.is_empty() { |
| 45 | return Err(SqlError::Parse { |
| 46 | detail: format!( |
| 47 | "DELETE FROM ARRAY {}: at least one coord tuple required", |
| 48 | ast.name |
| 49 | ), |
| 50 | }); |
| 51 | } |
| 52 | for (ri, row) in ast.coords.iter().enumerate() { |
| 53 | validate_coords(&ast.name, ri, row, &view)?; |
| 54 | } |
| 55 | Ok(vec![SqlPlan::DeleteArray { |
| 56 | name: ast.name.clone(), |
| 57 | coords: ast.coords.clone(), |
| 58 | }]) |
| 59 | } |
| 60 | |
| 61 | fn validate_coords( |
| 62 | array: &str, |