MCPcopy Create free account
hub / github.com/MaterializeInc/materialize / run_execute

Function run_execute

src/testdrive/src/action/postgres/execute.rs:32–65  ·  view source on GitHub ↗
(
    mut cmd: BuiltinCommand,
    state: &State,
)

Source from the content-addressed store, hash-verified

30}
31
32pub async fn run_execute(
33 mut cmd: BuiltinCommand,
34 state: &State,
35) -> Result<ControlFlow, anyhow::Error> {
36 let connection = cmd.args.string("connection")?;
37 let background = cmd.args.opt_bool("background")?.unwrap_or(false);
38 cmd.args.done()?;
39
40 match (connection.starts_with("postgres://"), background) {
41 (true, true) => {
42 let (client_inner, _) = postgres_client(&connection, state.default_timeout).await?;
43 task::spawn(|| "postgres-execute", async move {
44 match execute_input(cmd, &client_inner).await {
45 Ok(_) => {}
46 Err(e) => println!("Error in backgrounded postgres-execute query: {e}"),
47 }
48 });
49 }
50 (false, true) => bail!("cannot use 'background' arg with referenced connection"),
51 (true, false) => {
52 let (client_inner, _) = postgres_client(&connection, state.default_timeout).await?;
53 execute_input(cmd, &client_inner).await?;
54 }
55 (false, false) => {
56 let client = state
57 .postgres_clients
58 .get(&connection)
59 .ok_or_else(|| anyhow!("connection '{}' not found", &connection))?;
60 execute_input(cmd, client).await?;
61 }
62 }
63
64 Ok(ControlFlow::Continue)
65}

Callers

nothing calls this directly

Calls 7

postgres_clientFunction · 0.85
spawnFunction · 0.85
execute_inputFunction · 0.85
opt_boolMethod · 0.80
stringMethod · 0.45
doneMethod · 0.45
getMethod · 0.45

Tested by

no test coverage detected