From 862de87af68fb057227809381992d3341615befb Mon Sep 17 00:00:00 2001 From: DualFroz Date: Sun, 6 Sep 2026 19:37:12 +0200 Subject: [PATCH] feat: build out main --- src/main.zig | 182 +++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 182 insertions(+) diff --git a/src/main.zig b/src/main.zig index fb9c4a4..7ab545c 100644 --- a/src/main.zig +++ b/src/main.zig @@ -374,6 +374,188 @@ const usage = \\ matches a row where the field was never set OR set to an explicit \\ none, e.g. city is_null and age gte i:18 (never uses an index, a \\ sparse row's absence is not something a B-tree entry can represent) + \\ (empty expr selects every row; --limit/--offset page the result, + \\ limit 0 or omitted means unlimited; --order-by sorts by one or more + \\ comma-separated fields, applied left to right (later fields only + \\ break ties left by earlier ones), ascending by default or ":desc" + \\ per field for descending - rows missing a sort field sort first + \\ on it) + \\ table explain [expr...] + \\ reports which strategy `table select` would use for the same + \\
/expr WITHOUT running the query: full scan, a single-field + \\ index (equality or range), or a composite index (equality or range, + \\ naming how many of its leading columns the expr actually pinned down) + \\ table update
--set field=value[,field=value...] [expr...] + \\ applies the --set field list to every row matched by expr (empty expr + \\ updates every row); each set field overrides an existing field of the + \\ same name or is added if the row does not have it; unmentioned fields + \\ are left as-is; secondary/composite indexes on a changed field are + \\ kept in sync exactly like `table put` would; prints the number of + \\ rows updated + \\ table delete
[expr...] + \\ removes every row matched by expr (empty expr deletes every row, same + \\ convention as `table select`/`table update`); secondary/composite + \\ indexes on the deleted rows are kept in sync exactly like `table del` + \\ would for a single row; prints the number of rows deleted + \\ table index create|drop
(multiple fields = composite index) + \\ create --unique
: single-field index that also enforces the + \\ field holds a distinct value across every row (SQL UNIQUE); refuses to + \\ install over data that already has a duplicate; dropping the index drops + \\ the constraint too. Not available for composite (multi-field) indexes. + \\ table fk create
[restrict|cascade] + \\ installs a FOREIGN KEY: every
row's (non-null) value must + \\ name an existing on (SQL FOREIGN KEY REFERENCES); + \\ must be either the special primary-key name "__pk" or a field + \\ already carrying its own --unique index on , or the create is + \\ refused; refuses to install over a
row whose current value has + \\ no matching target; rows missing entirely are exempt (nullable FK). + \\ Last argument picks ON DELETE behavior for a `table delete`/`table_delete` + \\ against , default "restrict": restrict refuses the delete while + \\ a
row still points at it, cascade removes those rows too (and + \\ anything cascading from them, recursively). A `txn