Skip to main content

Module dml

Module dml 

Source
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§

BoundAssignment
One SET assignment.
BoundCheck
One CHECK constraint, bound against its table.
BoundDefault
A NOT NULL column’s DEFAULT, bound so a REPLACE can stand it in.
BoundDelete
A bound DELETE.
BoundIndexExprs
The expressions one index needs evaluated per row to be maintained.
BoundInsert
A bound INSERT.
BoundTrigger
A trigger, bound against the write that fires it.
BoundUpdate
A bound UPDATE.
BoundUpsert
A bound ON CONFLICT ... DO UPDATE clause.

Enums§

BoundInsertSource
What an INSERT inserts.
BoundTriggerStatement
One statement of a trigger body, bound.
ColumnSource
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.