Skip to main content

batch

Function batch 

Source
pub fn batch(
    context: &mut Context,
    arguments: &Arguments,
) -> Result<Outcome, Failed>
Expand description

batch: runs several statements as one transaction.

It is a transaction as of task-1932, and until then it was not. The command’s own description says “either all of them take effect or none of them do, which is what you want when creating a schema or loading related rows”, and the MCP tool inillucent_batch inherits that description - but nothing opened a transaction. execute_batch is a loop of execute_any with nothing around it, so each statement committed as it succeeded, and inillucent batch "INSERT ...; INSERT ...; GARBAGE" reported failure with two rows committed. That is the exact case the description names as the reason to use it.

A script run inside a transaction the caller already opened joins it and does not commit: closing somebody else’s transaction because a command inside it finished would be a worse surprise than the one being fixed, and the outcome’s detail says which of the two happened. An explicit BEGIN inside the script is left to the engine, which refuses it with “cannot start a transaction within a transaction”.