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.
910use anyhow::{Context, anyhow};
11use mz_ore::str::StrExt;
1213use crate::action::{ControlFlow, State};
14use crate::parser::BuiltinCommand;
1516pub async fn run_execute(
17mut cmd: BuiltinCommand,
18 state: &mut State,
19) -> Result<ControlFlow, anyhow::Error> {
20let name = cmd.args.string("name")?;
21 cmd.args.done()?;
2223let client = state
24 .sql_server_clients
25 .get_mut(&name)
26 .ok_or_else(|| anyhow!("connection {} not found", name.quoted()))?;
2728for query in cmd.input {
29println!(">> {}", query);
30 client
31 .execute(query, &[])
32 .await
33.context("executing SQL Server query")?;
34 }
3536Ok(ControlFlow::Continue)
37}