final class GeneratedWrites
Restricted visibility: declared "@visibility SqlSemantics\Platform\Sqlite". Code outside that scope must not name this declaration.

Reports the writes of generated columns, and counts the columns an INSERT without a column list fills.

Rule: SQLITE-GENERATED-WRITE-001. A generated column, VIRTUAL or STORED, cannot be written. Naming one in the column list of an INSERT is rejected with "cannot INSERT into generated column" (sqlite3Insert() in insert.c); assigning one in UPDATE SET or in DO UPDATE SET is rejected with "cannot UPDATE generated column" (sqlite3Update() in update.c). Both messages name the column as declared. An INSERT without a column list supplies one value per column that is not generated.

SQLite compiles the DO UPDATE of an upsert, and so checks it, only where a uniqueness check of the INSERT selects that clause (sqlite3GenerateConstraintChecks() in insert.c, sqlite3UpsertOfIndex() in upsert.c). The rowid check runs when the row supplies the rowid: the column list names it or the integer primary key, or there is no column list and the table has an integer primary key. It selects the first clause without a conflict target or with the rowid as its target. Every unique index is checked on INSERT and selects the first clause whose target matches it, or else the clause without a target; a conflict target that matches no index is an error of its own. So a DO UPDATE is certainly compiled when it has a target other than the rowid and no earlier clause has one (a later clause for the same index never fires), when the rowid check selects it, and when it is the only clause, has no target and writes a WITHOUT ROWID table, whose primary key is a unique index. Otherwise it depends on the unique indexes of the table, which a declaration does not hold, and no write is reported. Source: https://sqlite.org/gencol.html, https://sqlite.org/lang_insert.html, https://sqlite.org/lang_upsert.html. Status: Implemented.

Methods§

public function writable(RowShape $shape): int

Answers how many columns of a complete row shape an INSERT without a column list fills: those that are not generated.

Parameters

$shapeRowShape

Returns

int
Test cases 1
Called from 1
public function inserted(
    list<Name> $columns,
    VisibleRelation $target,
    Derivation $derivation,
): void

Reports each name of an INSERT column list that denotes a generated column of the written table.

Parameters

$columnslist<Name>
$targetVisibleRelation
$derivationDerivation
Called from 1
Calls 4
public function reached(
    list<Upsert> $upserts,
    int $index,
    Table $table,
    bool $supplied,
    Environment $environment,
): bool

Tells whether SQLite certainly compiles the DO UPDATE of the clause at a position.

Parameters

$upsertslist<Upsert>The ON CONFLICT clauses in written order
$indexintThe position of the clause
$tableTableThe declaration of the written table
$suppliedboolWhether the inserted row supplies the rowid
$environmentEnvironmentThe scope of the conflict targets

Returns

bool
Called from 1
Calls 5
public function rowidTarget(
    ConflictTarget $target,
    Column $rowid,
    Environment $environment,
): bool

Tells whether a conflict target is the rowid: a single term that is a name denoting it, possibly in parentheses.

Parameters

$targetConflictTarget
$rowidColumnThe column the rowid names denote
$environmentEnvironment

Returns

bool
Test cases 1
Called from 1
Calls 3
public function supplied(
    list<Name> $columns,
    Table $table,
    VisibleRelation $target,
    Derivation $derivation,
): bool

Tells whether the inserted row supplies the rowid: through the column list, or by the integer primary key when there is no list.

Parameters

$columnslist<Name>The column list; empty when none is written
$tableTable
$targetVisibleRelation
$derivationDerivation

Returns

bool
Test cases 1
Called from 1
Calls 4

Test cases 4§

Test cases that cover or call this symbol, from the coverage report and from the analyzed test sources.

Dedicated tests 4

Relations§

Instantiated in 2
Method calls 6