1// Copyright Materialize, Inc. and contributors. All rights reserved.
2//
3// Use of this software is governed by the Business Source License
4// included in the LICENSE file.
5//
6// As of the Change Date specified in that file, in accordance with
7// the Business Source License, use of this software will be governed
8// by the Apache License, Version 2.0.
910//! Queries that validate CONNECTION objects.
1112use crate::ast::ValidateConnectionStatement;
13use crate::names::Aug;
14use crate::plan::statement::{StatementContext, StatementDesc};
15use crate::plan::{Plan, PlanError, ValidateConnectionPlan};
16use crate::session::vars;
1718pub fn describe_validate_connection(
19_: &StatementContext,
20_: ValidateConnectionStatement<Aug>,
21) -> Result<StatementDesc, PlanError> {
22Ok(StatementDesc::new(None))
23}
2425pub fn plan_validate_connection(
26 scx: &StatementContext,
27 stmt: ValidateConnectionStatement<Aug>,
28) -> Result<Plan, PlanError> {
29 scx.require_feature_flag(&vars::ENABLE_CONNECTION_VALIDATION_SYNTAX)?;
30let item = scx.get_item_by_resolved_name(&stmt.name)?;
3132// Validate the target of the validate statement.
33match item.connection() {
34Ok(connection) => Ok(Plan::ValidateConnection(ValidateConnectionPlan {
35 id: item.id(),
36 connection,
37 })),
38Err(_) => {
39sql_bail!(
40"cannot validate {} '{}'",
41 item.item_type(),
42 stmt.name.full_name_str()
43 );
44 }
45 }
46}