Skip to main content

plan_mutation

Function plan_mutation 

Source
fn plan_mutation(
    catalog: &Arc<Catalog>,
    target_id: CatalogItemId,
    kind: MutationKind,
    sql: &str,
) -> Result<ReadThenWritePlan, AdapterError>
Expand description

Plans sql as the read side of a mutation against target_id.

The statement is planned as a SELECT whose columns are already in the target table’s order, so the mutation needs no assignments or projection.

The selection’s column types are checked against the target table here. A user INSERT ... SELECT gets that from the planner, but a hand-built plan bypasses it, and a wrong type would be written into the shard verbatim and break every later read of a table that is deliberately never truncated.