classCluster
final class Cluster
implements Statement
uses Snapshot
@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.
$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]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\InvalidConstructionProperties§
public list<UtilityOption> $optionspublic OptionSyntax $syntax = OptionSyntax::Wordspublic QualifiedName|null $table = nullpublic Name|null $index = nullpublic bool $indexFirst = falseMethods§
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
$options | list<UtilityOption> | The options in the order written |
$syntax | OptionSyntax | How the options are written |
$table | QualifiedName|null | The table; null for every previously clustered table |
$index | Name|null | The index to cluster by; null for the index used before |
$indexFirst | bool | Whether the old syntax `index ON table` is written |
Calls 6
- class-const OptionSyntax::Words() line 59
- static-call Check::listOf() line 64
- class-const UtilityOption::class() line 64
- static-call Check::input() line 65
- method-call OptionRules::writable() line 65
- new OptionRules line 65
public function deriveStatement(Derivation $derivation): voidResolves the table and reports what CLUSTER rejects.
Parameters
$derivation | Derivation |
Calls 11
- method-call OptionRules::derive() line 75
- new OptionRules line 75
- new RelationKinds line 77
- method-call RelationKinds::of() line 78
- method-call Derivation::target() line 78
- method-call Targets::resolve() line 78
- new Targets line 78
- method-call RelationKinds::require() line 79
- class-const RelationKind::BaseTable() line 79
- class-const RelationKind::MaterializedView() line 79
- class-const KindRule::NotTableOrMaterializedView() line 79
public function render(Output $out): voidWrites the request.
Parameters
$out | Output |
Calls 7
- method-call Output::keyword() line 88
- method-call OptionRules::write() line 89
- new OptionRules line 89
- method-call Output::name() line 94
- class-const NameUse::Column() line 94
- method-call Spelling::qualified() line 95
- new Spelling line 95
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
- new SqlSemantics\Platform\PostgreSql\Lowering\Utility\MaintenanceRule::statement() packages/sql-semantics-postgres/src/Lowering/Utility/MaintenanceRule.php:102
- new SqlSemantics\Platform\PostgreSql\Lowering\Utility\MaintenanceRule::statement() packages/sql-semantics-postgres/src/Lowering/Utility/MaintenanceRule.php:103
- new SqlSemantics\Platform\PostgreSql\Lowering\Utility\MaintenanceRule::statement() packages/sql-semantics-postgres/src/Lowering/Utility/MaintenanceRule.php:104
- new SqlSemantics\Platform\PostgreSql\Lowering\Utility\MaintenanceRule::statement() packages/sql-semantics-postgres/src/Lowering/Utility/MaintenanceRule.php:105
- new SqlSemantics\Platform\PostgreSql\Lowering\Utility\MaintenanceRule::statement() packages/sql-semantics-postgres/src/Lowering/Utility/MaintenanceRule.php:106