Skip to main content

Plans

Plans are the structured operation format executed by CSDB. All public query surfaces converge on the same executor:

  • The fluent table API builds plans from chained method calls.
  • SQL text is parsed into plans before execution.
  • JSON sends plans directly inside a server command envelope.

Flow

TableQuery API ─┐
SQL text ───┼─> QueryPlan ─> Executor ─> rows or mutation result
JSON command ───┘

Plan Kinds

type QueryPlan =
| SelectPlan
| InsertPlan
| UpdatePlan
| DeletePlan
| CreateTablePlan
| DropTablePlan;

Select Rows

Produced by fluent selection methods, SELECT, or a JSON select command.

{
kind: "select",
table: "workers",
columns: ["id", "email"],
joins: [],
where: {
type: "is-null",
expr: { type: "identifier", name: "email" },
not: true
},
orderBy: [{ column: "id", direction: "asc" }],
limit: 10,
output: "objects"
}

Mutate Rows

Produced by fluent mutation methods, SQL, or JSON mutation commands.

{ kind: "insert", table: "workers", rows: [{ id: "w_001" }] }
{ kind: "update", table: "workers", set: { email: "ada@example.com" }, where: expression }
{ kind: "delete", table: "workers", where: expression }

Change Tables

Produced by database table methods, compact DDL SQL, or JSON DDL commands.

{ kind: "create-table", schema }
{ kind: "drop-table", table: "tags" }

Expressions

Expressions represent literals, identifiers, comparisons, IS NULL, AND, OR, and NOT. They are used in plan where fields and constraint evaluation. JSON uses the exact discriminated expression objects documented in Command Requests.