Expand description
Binding INSERT, UPDATE and DELETE.
Invariant: a bound DML statement names every value it will write, in table
column order, before anything is compiled. A column the statement did not
mention is not left to be filled in later by whoever runs it - it carries
its DEFAULT, or a NULL, as an expression like any other. That is what
makes INSERT INTO t(b) VALUES(1) and INSERT INTO t VALUES(NULL, 1)
compile to the same shape, and it is why the constraint checks can be
written once against a row image rather than twice against two.
Constraints are bound here too, out of the CREATE TABLE text the file
stores. The catalog keeps them as source, because the catalog sits below
the binder and cannot bind anything; the binder parses that source against
the table it belongs to and gets an ordinary expression back. A CHECK is
therefore evaluated by exactly the machinery that evaluates a WHERE clause,
which is the only way to be sure the two agree about what x > 0 means
when x is text.
Modules§
- codes
- The extended result codes a rejected write reports.
Structs§
- Bound
Assignment - One
SETassignment. - Bound
Check - One
CHECKconstraint, bound against its table. - Bound
Default - A
NOT NULLcolumn’sDEFAULT, bound so aREPLACEcan stand it in. - Bound
Delete - A bound
DELETE. - Bound
Index Exprs - The expressions one index needs evaluated per row to be maintained.
- Bound
Insert - A bound
INSERT. - Bound
Trigger - A trigger, bound against the write that fires it.
- Bound
Update - A bound
UPDATE. - Bound
Upsert - A bound
ON CONFLICT ... DO UPDATEclause.
Enums§
- Bound
Insert Source - What an INSERT inserts.
- Bound
Trigger Statement - One statement of a trigger body, bound.
- Column
Source - Where one column’s value comes from in an INSERT.
Constants§
- MAX_
FOREIGN_ KEY_ DEPTH - How deep one chain of foreign-key actions may go.
- MAX_
FOREIGN_ KEY_ STATEMENTS - How many foreign-key action bodies one statement may inline in total.
- MAX_
TRIGGER_ DEPTH - How deep one write may drive triggers firing other triggers.
Functions§
- rowid_
message - Returns the message a duplicate rowid reports, and its extended code.
- unique_
message - Returns the message a unique-index violation reports.