Skip to main content

Crate h5i_app_pgsql

Crate h5i_app_pgsql 

Source
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, $1 first.
ReadQuery
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 0 is left out on purpose: with an OFFSET parameter 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, then columns. Key: tenant_id and the first key_len columns.

Enums§

Cond
A WHERE condition; $param counts from 1.
Kind
A column type.
ReadSqlMode
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 s for tenant. None on a bad schema, a missing table, or values that do not fit. Delete and DeleteWhere need key columns: a keyless table holds one row, which is only replaced.
compile_read
The SELECT returning q’s rows of tenant (no tenant_id) in ascending key order, or with count the number of them. None on an invalid schema, a missing table or column, a value of the wrong type, IN on 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 TABLE for t.
create_index
CREATE INDEX IF NOT EXISTS on tenant_id and columns cols of table table, so reads that filter on them need not scan the tenant. Indexes change no result, only speed. None on a bad schema, table or column.
render
The text of s, as sent to PostgreSQL.
select
The tenant’s rows of table (no tenant_id), optionally filtered by col IS NOT DISTINCT FROM val. None on 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_id column, no h5i_ table.