risingwave_frontend/handler/
delete_meta_snapshot.rs

1// Copyright 2026 RisingWave Labs
2//
3// Licensed under the Apache License, Version 2.0 (the "License");
4// you may not use this file except in compliance with the License.
5// You may obtain a copy of the License at
6//
7//     http://www.apache.org/licenses/LICENSE-2.0
8//
9// Unless required by applicable law or agreed to in writing, software
10// distributed under the License is distributed on an "AS IS" BASIS,
11// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12// See the License for the specific language governing permissions and
13// limitations under the License.
14
15use pgwire::pg_response::{PgResponse, StatementType};
16
17use super::RwPgResponse;
18use crate::error::{ErrorCode, Result};
19use crate::handler::HandlerArgs;
20
21pub(super) async fn handle_delete_meta_snapshots(
22    handler_args: HandlerArgs,
23    snapshot_ids: Vec<u64>,
24) -> Result<RwPgResponse> {
25    // Only permit deleting snapshots for super users.
26    if !handler_args.session.is_super_user() {
27        return Err(ErrorCode::PermissionDenied(
28            "only superusers can delete meta snapshots".to_owned(),
29        )
30        .into());
31    }
32    let client = handler_args.session.env().meta_client();
33    client.delete_meta_snapshot(&snapshot_ids).await?;
34    Ok(PgResponse::empty_result(
35        StatementType::DELETE_META_SNAPSHOTS,
36    ))
37}