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

Lowers the index, key and constraint elements of a table definition.

Rule: MYSQL-KEY-DEFINITION-001. Scope: key_def (5.x), table_constraint_def (8.0 and later), normal_key_type, constraint_key_type, fulltext, spatial, opt_constraint, constraint, opt_constraint_name, opt_check_constraint, check_constraint, opt_not, opt_constraint_enforcement, constraint_enforcement. KEY and INDEX are synonyms; whether the optional INDEX or KEY follows UNIQUE, FULLTEXT or SPATIAL is kept. Constructs: IndexDefinition, ForeignKey, CheckConstraint, ConstraintName. Terminates: every child is a strict subtree. Source: https://dev.mysql.com/doc/refman/8.4/en/create-table.html, https://dev.mysql.com/doc/refman/8.4/en/create-table-check-constraints.html. Status: Implemented.

Methods§

public function __construct(private Lowering $lowering)

Parameters

$loweringLoweringThe lowering this rule belongs to
public function constrained(
    Form $form,
    ?ConstraintName $constraint,
    ColumnName|null $name,
    IndexAlgorithm|null $algorithm,
    int $parts,
    int $options,
): IndexDefinition
public function constraint(Node $clause): ?ConstraintName

Lowers an optional CONSTRAINT clause: a node of opt_constraint, constraint or opt_constraint_name.

Parameters

$clauseNode

Throws

ImplementationGap When a production has no rule
Test cases 1
Called from 7
Calls 3
public function optionalCheck(Node $check): ?CheckConstraint

Lowers the optional CHECK clause after a 5.x column: a node of opt_check_constraint.

Parameters

$checkNode

Throws

ImplementationGap When a production has no rule
Test cases 1
Called from 1
Calls 3
public function enforcement(Node $enforcement): ?bool

Lowers an optional enforcement clause: a node of opt_constraint_enforcement; absent is null.

Parameters

$enforcementNode

Returns

?bool

Throws

ImplementationGap When a production has no rule
Test cases 1
Called from 1
Calls 2

Private surface 2§

Implementation details, listed for orientation only.

private const INDEXES = ['key_def: normal_key_type opt_ident key_alg ( key_list ) normal_key_options' =…
private Lowering $lowering

Test cases 8§

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

Dedicated tests 8

Relations§

Instantiated in 5
Method calls 6