packages/sql-semantics-mysql/src/Rules/TableChange/PartitionFacts.php

1<?php
2
3declare(strict_types=1);
4
5namespace SqlSemantics\Platform\MySql\Rules\TableChange;
6
7use SqlSemantics\Platform\MySql\Model\Construction\Derivation;
8use SqlSemantics\Platform\MySql\Model\Resolution\Environment;
9use SqlSemantics\Platform\MySql\Statement\Partition\Partitioning;
10
11/**
12 * Derives the partitioning of a table for the statement that holds it.
13 *
14 * Rule: MYSQL-PARTITION-FACTS-001. The entry the table definition family
15 * calls for CREATE TABLE … PARTITION BY: the partitioning functions and
16 * columns are derived in the scope of the partitioned table, the partition
17 * values as constants (MYSQL-PARTITIONING-001). Terminates: delegates once.
18 * Source: https://dev.mysql.com/doc/refman/8.4/en/partitioning-limitations.html.
19 * Status: Implemented.
20 *
21 * @visibility SqlSemantics\Platform\MySql
22 */
23final class PartitionFacts
24{
25    /**
26     * Derives a partitioning in the scope of its table.
27     *
28     * @param Environment $scope The scope whose only visible relation is the partitioned table
29     */
30    public function partitioning(Partitioning $partitioning, Derivation $derivation, Environment $scope): void
31    {
32        $partitioning->derivePartitioning($derivation, $scope);
33    }
34}
35