Expand description
The SQL h5i-app runs on PostgreSQL.
compile turns an h5i_app_sql::Stmt into a Query over a small SQL
subset (Sql); render prints it. Extracted to Lean (proofs/): a
compiled statement matches H5iAppLib.Sql.exec on the tenant’s rows and
leaves other tenants alone.
Aeneas subset: no ?, no String, no iterator adapters.
Structs§
- ColDef
- A column definition in
CREATE TABLE. - Column
- A column of a tenant table.
- Query
- A statement and the values of its parameters,
$1first. - Read
Query - A read’s text and its parameters,
$1(the tenant) first. Every value, limit and offset is a parameter, so the text depends only on the read’s shape and on whether its window has a limit and a non-zero offset: at most four texts per shape, whatever the numbers.OFFSET 0is left out on purpose: with anOFFSETparameter PostgreSQL estimates a generic plan as dearer than the custom ones and never reuses it, re-planning on every execution of the prepared statement. - Table
- A tenant table:
tenant_id, thencolumns. Key:tenant_idand the firstkey_lencolumns.
Enums§
- Cond
- A
WHEREcondition;$paramcounts from 1. - Kind
- A column type.
- Read
SqlMode - SQL spelling for membership predicates. Both modes preserve the same read and exact-count semantics; their PostgreSQL execution plans can differ.
- Sql
- A statement of the subset. Names are printed quoted.
Functions§
- compile
- The query that runs
sfortenant.Noneon a bad schema, a missing table, or values that do not fit.DeleteandDeleteWhereneed key columns: a keyless table holds one row, which is only replaced. - compile_
read - The
SELECTreturningq’s rows oftenant(notenant_id) in ascending key order, or withcountthe number of them.Noneon an invalid schema, a missing table or column, a value of the wrong type,INon a nullable column, or a window on a table without an integer key. - compile_
read_ with_ mode - Compile a read or exact count with an explicit SQL strategy. The mode applies recursively to nested membership predicates; validation is identical.
- create
CREATE TABLEfort.- create_
index CREATE INDEX IF NOT EXISTSontenant_idand columnscolsof tabletable, so reads that filter on them need not scan the tenant. Indexes change no result, only speed.Noneon a bad schema, table or column.- render
- The text of
s, as sent to PostgreSQL. - select
- The tenant’s rows of
table(notenant_id), optionally filtered bycol IS NOT DISTINCT FROM val.Noneon a bad schema, table, column, or type. - tenant_
col tenant_id, the first column of every table.- valid
- Tables well formed with distinct names; no
tenant_idcolumn, noh5i_table.