Documentation
¶
Overview ¶
Package dmlassign is the SET-value matrix for DML assignment casts, and the PostgreSQL answers it is checked against.
Why it exists. The DML doors are two copies of one executor — the embedded API's and the HTTP server's — and they have drifted before (#647 fixed a DECIMAL declaration read at one door and dropped at two others). A matrix written once and run by every door is the only arrangement in which "the doors agree" is a fact rather than an assumption.
What it covers: five value CLASSES (integer literal, fractional literal, integer column, DECIMAL column, expression) against four target TYPES (INT64, DECIMAL(9,2), FLOAT64, STRING), plus the refusals at each boundary.
Every Want, MergeWant and State was read off postgres:17-alpine against the fixture Setup describes — not remembered, and not derived from what wadjet happened to answer. The matrix exists because #678's first round got one of these cells wrong in a way every gate in the tree passed: an integer box assigned to a DECIMAL column was read as the already-unscaled CARRIER (ADR-0018 §4) rather than as a VALUE, so `SET d = n` with n = 10 stored 0.10 and the statement returned success.
Index ¶
Constants ¶
const ( TargetDDL = "CREATE TABLE mv (id INT64, n INT64, d DECIMAL(9,2), f FLOAT64, s STRING)" SourceDDL = "CREATE TABLE mvs (id INT64, k INT64, dk DECIMAL(9,2), fk FLOAT64, sk STRING)" TargetRow = "INSERT INTO mv VALUES (1, 10, 1.50, 2.5, 'ab')" SourceRow = "INSERT INTO mvs VALUES (1, 7, 3.25, 0.5, 'zz')" )
Target is the fixture the expectations were read against:
mv (id 1, n 10, d 1.50, f 2.5, s 'ab') -- the UPDATE / MERGE target mvs (id 1, k 7, dk 3.25, fk 0.5, sk 'zz') -- the MERGE source
The source's VALUE column names (k, dk, fk, sk) are deliberately DISJOINT from the target's, so an unqualified reference in a MERGE resolves to exactly one relation and every cell tests what its name says it does.
`id` is the deliberate exception: BOTH relations spell it, because a matrix in which no name is shared cannot see the one answer that is worse than a wrong error — silently picking a side. `SET n = id` is 1 over one relation and 42702 over two, and that pair is a cell (protocol item 2: a fixture whose values cannot distinguish the two rules passes for the wrong reason).
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Case ¶
type Case struct {
Name string
// Set is the clause body for an UPDATE. Merge is its spelling for a MERGE,
// where the interesting values live on the source; empty Merge reuses Set.
Set string
Merge string
// Col is the column to read back afterwards.
Col string
// Want is the stored value as the engine renders it; MergeWant overrides
// it on the MERGE arm, where the source's values differ. Both are empty
// when State is set.
Want string
MergeWant string
// State is the SQLSTATE PostgreSQL raises, for the cells that must be
// REFUSED. A cell with a State must leave the row unchanged.
// MergeState overrides it on the MERGE arm, where a spelling legal over
// one relation can be ambiguous over two.
State string
MergeState string
}
Case is one cell: a SET clause body, the column to read back, and what PostgreSQL stores (or the SQLSTATE it raises).
func (Case) MergeSQLState ¶
MergeSQLState is the SQLSTATE expected on the MERGE arm.
func (Case) MergeValue ¶
MergeValue is the expected stored value on the MERGE arm.