final class CreateConstraintTrigger
    implements SchemaElement, Relation
    uses Snapshot
Public API: explicitly declared with @visibility public.

A request to create a constraint trigger: an AFTER ROW trigger whose firing can be deferred.

Mirrors PostgreSQL's CreateTrigStmt with isconstraint (constrrel, deferrable, initdeferred). The table and the referenced table are resolved; the WHEN condition sees the table's columns as OLD and NEW (PG-TRIGGER-001). Source: https://www.postgresql.org/docs/17/sql-createtrigger.html.

Reading a constraint triggerdoctest
$statement = (new \SqlSemantics\Platform\PostgreSql\Semantics())->analyze('CREATE CONSTRAINT TRIGGER g AFTER INSERT ON t FROM u DEFERRABLE INITIALLY DEFERRED FOR EACH ROW EXECUTE FUNCTION f()');
    $statement->toString() // => 'CREATE CONSTRAINT TRIGGER g AFTER INSERT ON t FROM u DEFERRABLE INITIALLY DEFERRED FOR EACH ROW EXECUTE FUNCTION f()'

Properties§

public non-empty-list<TriggerEvent> $events
public list<TriggerArgument> $arguments
public list<ConstraintAttribute> $attributes
public Name $name
public QualifiedName $table
public DottedName $function
public ParentTable|null $referenced = null
public Scalar|null $when = null
public bool $replace = false

Methods§

public function __construct(
    public Name $name,
    list<TriggerEvent> $events,
    public QualifiedName $table,
    public DottedName $function,
    list<TriggerArgument> $arguments = [],
    public ParentTable|null $referenced = null,
    list<ConstraintAttribute> $attributes = [],
    public Scalar|null $when = null,
    public bool $replace = false,
)

Parameters

$nameNameThe trigger name
$eventslist<TriggerEvent>The events
$tableQualifiedNameThe table
$functionDottedNameThe trigger function
$argumentslist<TriggerArgument>The arguments
$referencedParentTable|nullThe table of FROM, referenced by a foreign key
$attributeslist<ConstraintAttribute>The attributes in the order written
$whenScalar|nullThe WHEN condition
$replaceboolWhether OR REPLACE is written
Calls 5
public function createdSchema(): ?Name

Answers the schema written on the table, or null when it is unqualified.

Returns

public function deriveStatement(Derivation $derivation): void

Resolves the tables, derives the condition and checks the attributes.

Parameters

$derivationDerivation
Calls 2
public function deriveElement(Derivation $derivation, Name $schema): void

Derives the statement inside CREATE SCHEMA: an unqualified table is in that schema.

Parameters

$derivationDerivation
$schemaName
Calls 2
public function deriveRelation(Derivation $derivation, Environment $environment): RelationFact

Resolves the table and answers its facts.

Parameters

$derivationDerivation
$environmentEnvironment
Calls 2
public function render(Output $out): void

Writes the statement.

Parameters

$outOutput
Calls 2

Test cases 3§

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

Dedicated tests 3

Relations§

Instantiated in 1
Constant reads 1
Type declarations 2