Row-level SQL expressions -- CHECK constraints, domain checks, RETURNING, ON CONFLICT ... WHERE -- evaluated by the SELECT translator, not by a second interpreter.
PostgreSQL evaluates these by projecting over a tuple (ExecCheck,
ExecQual, ExecProcessReturning): the expression's column references are
Vars bound to the tuple's attributes. Here the tuple is a ROW SCOPE: a
table's columns bound (params/from-bindings) to placeholders typed by
their declared OIDs, the expressions translated once as
SELECT <exprs>, and run per row with the row's values bound. Names
resolve by the translator's own scoping: a subquery that references the
row correlates through params/row-scope-aliases exactly as it would
against an outer FROM item, and the scope's table supplies column
metadata (params/row-scope-tables).
Errors propagate with their SQLSTATE, as they do in PostgreSQL.
Row-level SQL expressions -- CHECK constraints, domain checks, RETURNING, ON CONFLICT ... WHERE -- evaluated by the SELECT translator, not by a second interpreter. PostgreSQL evaluates these by projecting over a tuple (ExecCheck, ExecQual, ExecProcessReturning): the expression's column references are Vars bound to the tuple's attributes. Here the tuple is a ROW SCOPE: a table's columns bound (params/*from-bindings*) to placeholders typed by their declared OIDs, the expressions translated once as `SELECT <exprs>`, and run per row with the row's values bound. Names resolve by the translator's own scoping: a subquery that references the row correlates through params/*row-scope-aliases* exactly as it would against an outer FROM item, and the scope's table supplies column metadata (params/*row-scope-tables*). Errors propagate with their SQLSTATE, as they do in PostgreSQL.
(check-fn db)The CHECK evaluator constraint validation takes: (fn [ast row ns schema
& [column-types]]) over db.
The CHECK evaluator constraint validation takes: (fn [ast row ns schema & [column-types]]) over `db`.
(check-result ast row ns schema db)(check-result ast row ns schema db opts)true, false or nil (unknown) for the CHECK expression ast over row
(see row-values for opts). Only false is a violation: CHECK passes on
NULL, unlike WHERE.
true, false or nil (unknown) for the CHECK expression `ast` over `row` (see row-values for `opts`). Only false is a violation: CHECK passes on NULL, unlike WHERE.
(row-oids asts table schema db & [opts])The OIDs row-values returns for asts over table, without a row:
what Describe reports for RETURNING.
The OIDs `row-values` returns for `asts` over `table`, without a row: what Describe reports for RETURNING.
(row-values asts row table schema db & [{:keys [exec-db] :as opts}])The values of the SQL expressions asts over one row of table, and
their OIDs: {:values [...] :oids [...]}, NULL as nil. row holds the
row's storage attributes.
Options:
:alias the name the row is visible under (default table)
:excluded? ON CONFLICT: excluded is in scope too, its values the
row's :excluded/<column> entries
:column-types {name attr-or-type-name} for names the table lacks --
a domain's VALUE, typed as the domain's base type,
read from the row's bare key
:exec-db the database subqueries read (default db):
RETURNING's command snapshot, which does not see the
statement's own writes
Parameters in the expressions ($1) take the values of
params/bound-params.
The values of the SQL expressions `asts` over one row of `table`, and
their OIDs: {:values [...] :oids [...]}, NULL as nil. `row` holds the
row's storage attributes.
Options:
:alias the name the row is visible under (default `table`)
:excluded? ON CONFLICT: `excluded` is in scope too, its values the
row's :excluded/<column> entries
:column-types {name attr-or-type-name} for names the table lacks --
a domain's VALUE, typed as the domain's base type,
read from the row's bare key
:exec-db the database subqueries read (default `db`):
RETURNING's command snapshot, which does not see the
statement's own writes
Parameters in the expressions (`$1`) take the values of
params/*bound-params*.(table-columns db schema table)A table's columns, [{:name :attr :oid}] in order, inherited ones included, each stored under the table that declares it and typed by that table.
A table's columns, [{:name :attr :oid}] in order, inherited ones
included, each stored under the table that declares it and typed by
that table.cljdoc builds & hosts documentation for Clojure/Script libraries
| Ctrl+k | Jump to recent docs |
| ← | Move to previous article |
| → | Move to next article |
| Ctrl+/ | Jump to the search field |