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

CLUSTER: a request to reorder a table by an index, or every previously clustered table.

Rule: PG-CLUSTER-001. Mirrors PostgreSQL's ClusterStmt (relation, indexname, params). Without a table every table clustered before is processed again. The syntax of releases before 8.3, CLUSTER index ON table, makes the same request as CLUSTER table USING index and is kept as written. Facts: the table is resolved; the index is not part of a declaration context. A relation declared as another kind than a table or a materialized view is reported (PG-RELATION-KIND-001). Diagnostic: an option CLUSTER does not know. Source: https://www.postgresql.org/docs/17/sql-cluster.html. Status: Implemented.

Reading a CLUSTER in the old syntaxdoctest
$operation = (new \SqlSemantics\Platform\PostgreSql\Semantics())->analyze('CLUSTER i ON t');
    [$operation->statement->table->name->value, $operation->statement->index->value, $operation->statement->indexFirst] // => ['t', 'i', true]
Refusing an index without a tabledoctest
new \SqlSemantics\Platform\PostgreSql\Statement\Utility\Maintenance\Cluster([], \SqlSemantics\Platform\PostgreSql\Statement\Utility\Maintenance\OptionSyntax::Words, null, new \SqlSemantics\Platform\PostgreSql\Model\Statement\Identifier\Name('i')) // throws \SqlSemantics\Platform\PostgreSql\Model\Diagnostic\InvalidConstruction

Properties§

public list<UtilityOption> $options
public OptionSyntax $syntax = OptionSyntax::Words
public QualifiedName|null $table = null
public Name|null $index = null
public bool $indexFirst = false

Methods§

public function __construct(
    list<UtilityOption> $options = [],
    public OptionSyntax $syntax = OptionSyntax::Words,
    public QualifiedName|null $table = null,
    public Name|null $index = null,
    public bool $indexFirst = false,
)

Parameters

$optionslist<UtilityOption>The options in the order written
$syntaxOptionSyntaxHow the options are written
$tableQualifiedName|nullThe table; null for every previously clustered table
$indexName|nullThe index to cluster by; null for the index used before
$indexFirstboolWhether the old syntax `index ON table` is written
Calls 6
public function deriveStatement(Derivation $derivation): void
public function render(Output $out): void

Writes the request.

Parameters

$outOutput
Calls 7

Test cases 3§

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

Dedicated tests 1
Other tests reaching this symbol 2

Relations§

Instantiated in 5