packages/sql-semantics-mysql/src/Statement/Server/Problem/BucketCountOutOfRange.php

1<?php
2
3declare(strict_types=1);
4
5namespace SqlSemantics\Platform\MySql\Statement\Server\Problem;
6
7use SqlSemantics\Platform\MySql\Model\Statement\Fact\Diagnostic;
8use SqlSemantics\Platform\MySql\Model\Statement\Snapshot;
9use SqlSemantics\Platform\MySql\Statement\Literal\Numeral;
10
11/**
12 * A histogram bucket count outside 1 to 1024.
13 *
14 * The server rejects the statement with ER_DATA_OUT_OF_RANGE while it
15 * parses it.
16 * Source: https://dev.mysql.com/doc/refman/8.4/en/analyze-table.html.
17 *
18 * @visibility public
19 * @example Describing the problem
20 *     (new \SqlSemantics\Platform\MySql\Statement\Server\Problem\BucketCountOutOfRange(new \SqlSemantics\Platform\MySql\Statement\Literal\Numeral('0')))->message() // => 'Number of buckets 0 is out of range in ANALYZE TABLE: it is 1 to 1024.'
21 */
22final class BucketCountOutOfRange implements Diagnostic
23{
24    use Snapshot;
25
26    /**
27     * @param Numeral $buckets The bucket count as written
28     */
29    public function __construct(public readonly Numeral $buckets)
30    {
31    }
32
33    /**
34     * Describes the problem.
35     */
36    public function message(): string
37    {
38        return 'Number of buckets ' . $this->buckets->text . ' is out of range in ANALYZE TABLE: it is 1 to 1024.';
39    }
40}
41