# citadeldb-sql
SQL engine for the [Citadel](https://github.com/yp3y5akh0v/citadel) encrypted embedded database engine. Supports CREATE/DROP TABLE (incl. `STRICT` and `TEMP`), ALTER TABLE (incl. `DISABLE/ENABLE TRIGGER`), TRUNCATE, SELECT with JOINs (INNER, LEFT, RIGHT, CROSS, FULL OUTER, LATERAL), subqueries, CTEs (recursive + WITH-DML), UNION/INTERSECT/EXCEPT, window functions, `ANY` / `ALL` quantified comparisons, INSERT (with UPSERT / `ON CONFLICT`), UPDATE, DELETE, RETURNING (with `OLD`/`NEW` row aliases), generated columns (`STORED` + `VIRTUAL`), triggers (BEFORE/AFTER/INSTEAD OF × ROW/STATEMENT, transition tables, `WHEN`, `UPDATE OF`, ENABLE/DISABLE, name-order firing), materialized views (with `REFRESH [CONCURRENTLY]` diff-merge), `BEGIN [READ ONLY | READ WRITE]` snapshot transactions, partial indexes (`CREATE INDEX … WHERE`), expression indexes (`CREATE INDEX ON t (LOWER(email))` with full symbolic-equivalence matching), `CREATE INDEX … CONCURRENTLY` (PG-faithful three-pass build, non-blocking for readers/writers), GIN inverted indexes (`CREATE INDEX … USING gin`) for JSONB `@>` containment queries, FTS inverted indexes (`CREATE INDEX … USING fts`) for `tsvector @@ tsquery` matching, `COLLATE` (BINARY/NOCASE/RTRIM) at column/expression/ORDER BY/index level, JSON / JSONB types with 14 PG operators (`->`, `->>`, `#>`, `#>>`, `@>`, `<@`, `?`, `?|`, `?&`, `#-`, `@?`, `@@`, `@?_tz`, `@@_tz`), `JSON_TABLE` / `JSON_EXISTS` / `JSON_VALUE` / `JSON_QUERY` with SQL/JSON predicate path language, 16 JSON scalar functions, 4 JSON/JSONB aggregates (`json_agg`, `jsonb_agg`, `json_object_agg`, `jsonb_object_agg`), and 5 set-returning JSON functions, ARRAY type with element-wise comparison, full-text search (`tsvector` / `tsquery`, `to_tsvector` / `to_tsquery` / `plainto_tsquery` / `phraseto_tsquery` / `websearch_to_tsquery`, `ts_rank` / `ts_rank_cd`, `strip`, `setweight` (2- and 3-arg selective), `tsvector || tsvector`, weighted-vector A/B/C/D and prefix-match support), `information_schema.*` (including `triggers`) and `pg_timezone_names` / `pg_timezone_abbrevs` / `pg_matviews` system catalog tables, `SHOW TRIGGERS` / `SHOW MATERIALIZED VIEWS` extensions, foreign keys with full referential actions (CASCADE / SET NULL / SET DEFAULT / RESTRICT / NO ACTION), aggregates, constraints, transactions with savepoints, prepared statements with snapshot-tagged plan caching (join inner-side and compound branches cached across executions, invalidated on commit), and multi-statement scripts. Large values (TEXT / BLOB / JSON / JSONB) transparently spill to overflow page chains.
This crate is part of the Citadel workspace. Depend on the main [`citadeldb`](https://crates.io/crates/citadeldb) crate instead.
## License
MIT OR Apache-2.0