Plan a TRUNCATE statement.
(stmt: &ast::Statement)
| 336 | |
| 337 | /// Plan a TRUNCATE statement. |
| 338 | pub fn plan_truncate_stmt(stmt: &ast::Statement) -> Result<Vec<SqlPlan>> { |
| 339 | let ast::Statement::Truncate(truncate) = stmt else { |
| 340 | return Err(SqlError::Parse { |
| 341 | detail: "expected TRUNCATE statement".into(), |
| 342 | }); |
| 343 | }; |
| 344 | let restart_identity = matches!( |
| 345 | truncate.identity, |
| 346 | Some(sqlparser::ast::TruncateIdentityOption::Restart) |
| 347 | ); |
| 348 | truncate |
| 349 | .table_names |
| 350 | .iter() |
| 351 | .map(|t| { |
| 352 | Ok(SqlPlan::Truncate { |
| 353 | collection: normalize_object_name_checked(&t.name)?, |
| 354 | restart_identity, |
| 355 | }) |
| 356 | }) |
| 357 | .collect() |
| 358 | } |
no test coverage detected