final class Define
    implements Statement
    uses Snapshot
Public API: explicitly declared with @visibility public.

CREATE kind name [arguments] ( definition ): defines an aggregate, operator, base or shell type, text search object or collation.

Mirrors PostgreSQL's DefineStmt (kind, oldstyle, defnames, args, definition, if_not_exists, replace). The definition is the list of attributes in written order, each read the way the command for the kind reads it (DefineAggregate, DefineOperator, DefineType, DefineCollation or the text search commands): the function of an operator is a routine name, its argument types are types. An aggregate is written with its argument list, or in the old style without one, where every attribute has a value and its name is an identifier. CREATE TYPE name alone defines a shell type. Source: https://www.postgresql.org/docs/17/sql-createaggregate.html, https://www.postgresql.org/docs/17/sql-createoperator.html, https://www.postgresql.org/docs/17/sql-createtype.html, https://www.postgresql.org/docs/17/sql-createtsdictionary.html, https://www.postgresql.org/docs/17/sql-createcollation.html.

Reading an operator definitiondoctest
$operation = (new \SqlSemantics\Platform\PostgreSql\Semantics())->analyze('CREATE OPERATOR === (leftarg = int4, rightarg = int4, function = int4eq)');
    [$operation->statement->kind->value, count($operation->statement->definition ?? [])] // => ['OPERATOR', 3]

Properties§

public list<Attribute>|null $definition
public ObjectKind $kind
public AggregateArguments|null $arguments = null
public bool $replace = false
public bool $ifNotExists = false

Methods§

public function __construct(
    public ObjectKind $kind,
    public DottedName|OperatorName $name,
    list<Attribute>|null $definition,
    public AggregateArguments|null $arguments = null,
    public bool $replace = false,
    public bool $ifNotExists = false,
)

Parameters

$kindObjectKindAGGREGATE, OPERATOR, TYPE, one of the four text search kinds, or COLLATION
$nameDottedName|OperatorNameThe object name; an operator for OPERATOR
$definitionlist<Attribute>|nullThe attributes of the kind's command, at least one; null for a shell type
$argumentsAggregateArguments|nullThe argument list of an aggregate; null for an old-style aggregate and other kinds
$replaceboolWhether OR REPLACE is written; aggregates only
$ifNotExistsboolWhether IF NOT EXISTS is written; collations only
Calls 14
public function deriveStatement(Derivation $derivation): void

Derives the arguments and attributes and reports the attribute problems the command reports.

Parameters

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

Writes the statement.

Parameters

$outOutput
Calls 8

Test cases 12§

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

Dedicated tests 10
Other tests reaching this symbol 2

Relations§

Instantiated in 8
Type declarations 1