classCreateConstraintTrigger
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.
$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> $eventspublic list<TriggerArgument> $argumentspublic list<ConstraintAttribute> $attributespublic Name $namepublic QualifiedName $tablepublic DottedName $functionpublic ParentTable|null $referenced = nullpublic Scalar|null $when = nullpublic bool $replace = falseMethods§
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
$name | Name | The trigger name |
$events | list<TriggerEvent> | The events |
$table | QualifiedName | The table |
$function | DottedName | The trigger function |
$arguments | list<TriggerArgument> | The arguments |
$referenced | ParentTable|null | The table of FROM, referenced by a foreign key |
$attributes | list<ConstraintAttribute> | The attributes in the order written |
$when | Scalar|null | The WHEN condition |
$replace | bool | Whether OR REPLACE is written |
Calls 5
- static-call Check::listOf() line 79
- class-const TriggerEvent::class() line 79
- class-const TriggerArgument::class() line 80
- method-call Attributes::checked() line 81
- new Attributes line 81
public function createdSchema(): ?NameAnswers the schema written on the table, or null when it is unqualified.
Returns
?Namepublic function deriveStatement(Derivation $derivation): voidResolves the tables, derives the condition and checks the attributes.
Parameters
$derivation | Derivation |
Calls 2
- method-call Triggers::deriveConstraint() line 97
- new Triggers line 97
public function deriveElement(Derivation $derivation, Name $schema): voidDerives the statement inside CREATE SCHEMA: an unqualified table is in that schema.
Parameters
$derivation | Derivation | |
$schema | Name |
Calls 2
- method-call Triggers::deriveConstraint() line 105
- new Triggers line 105
public function deriveRelation(Derivation $derivation, Environment $environment): RelationFactResolves the table and answers its facts.
Parameters
$derivation | Derivation | |
$environment | Environment |
Returns
Calls 2
- method-call Targets::resolve() line 113
- new Targets line 113
Test cases 3§
Test cases that cover or call this symbol, from the coverage report and from the analyzed test sources.