classOptionRules
final class OptionRules
The rules of the option lists of EXPLAIN, VACUUM, ANALYZE, CLUSTER and REINDEX.
Rule: PG-UTILITY-OPTION-001. Writing: a parenthesized list holds at least one option; the older word syntax holds only the words the command reads there, each once, without a value, in the order of the grammar, and the word ANALYZE is the keyword. Checking: each command knows the option names its manual page lists for the release (EXPLAIN gains SERIALIZE and MEMORY in 17); the server compares the names exactly, after the lexer folded unquoted words to lower case, and rejects any other name. A known option whose value the server reads as a Boolean must have a Boolean value by PG-UTILITY-OPTION-VALUE-001, and one it reads as text must have a value; the options whose values follow rules of their own (FORMAT and SERIALIZE of EXPLAIN, PARALLEL and INDEX_CLEANUP of VACUUM) are checked by the command. Termination: one pass over a finite list. Source: https://www.postgresql.org/docs/17/sql-explain.html, https://www.postgresql.org/docs/16/sql-explain.html, https://www.postgresql.org/docs/17/sql-vacuum.html, https://www.postgresql.org/docs/17/sql-analyze.html, https://www.postgresql.org/docs/17/sql-cluster.html, https://www.postgresql.org/docs/17/sql-reindex.html. Status: Implemented.
Methods§
public function writable(
list<UtilityOption> $options,
OptionSyntax $syntax,
list<string> $words,
): boolTells whether options can be written in a syntax: a parenthesized list is not empty, and words are those the command reads, in order.
Parameters
$options | list<UtilityOption> | |
$syntax | OptionSyntax | |
$words | list<string> | The option names the word syntax of the command reads, in the order of the grammar |
Returns
boolTest cases 2
Called from 4
- method-call SqlSemantics\Platform\PostgreSql\Statement\Utility\Maintenance\Analyze::__construct() packages/sql-semantics-postgres/src/Statement/Utility/Maintenance/Analyze.php:59
- method-call SqlSemantics\Platform\PostgreSql\Statement\Utility\Maintenance\Cluster::__construct() packages/sql-semantics-postgres/src/Statement/Utility/Maintenance/Cluster.php:65
- method-call SqlSemantics\Platform\PostgreSql\Statement\Utility\Maintenance\Explain::__construct() packages/sql-semantics-postgres/src/Statement/Utility/Maintenance/Explain.php:57
- method-call SqlSemantics\Platform\PostgreSql\Statement\Utility\Maintenance\Vacuum::__construct() packages/sql-semantics-postgres/src/Statement/Utility/Maintenance/Vacuum.php:62
Calls 3
- class-const OptionSyntax::Parenthesized() line 80
- function-call
array_searchline 85 - function-call
is_intline 87
public function write(Output $out, list<UtilityOption> $options, OptionSyntax $syntax): voidWrites options in a syntax; no option writes nothing.
Parameters
$out | Output | |
$options | list<UtilityOption> | |
$syntax | OptionSyntax |
Called from 5
- method-call SqlSemantics\Platform\PostgreSql\Statement\Utility\Maintenance\Analyze::render() packages/sql-semantics-postgres/src/Statement/Utility/Maintenance/Analyze.php:77
- method-call SqlSemantics\Platform\PostgreSql\Statement\Utility\Maintenance\Cluster::render() packages/sql-semantics-postgres/src/Statement/Utility/Maintenance/Cluster.php:89
- method-call SqlSemantics\Platform\PostgreSql\Statement\Utility\Maintenance\Explain::render() packages/sql-semantics-postgres/src/Statement/Utility/Maintenance/Explain.php:78
- method-call SqlSemantics\Platform\PostgreSql\Statement\Utility\Maintenance\Reindex::render() packages/sql-semantics-postgres/src/Statement/Utility/Maintenance/Reindex.php:98
- method-call SqlSemantics\Platform\PostgreSql\Statement\Utility\Maintenance\Vacuum::render() packages/sql-semantics-postgres/src/Statement/Utility/Maintenance/Vacuum.php:81
Calls 4
- class-const OptionSyntax::Parenthesized() line 106
- method-call Output::symbol() line 107
- method-call Output::keyword() line 112
- function-call
strtoupperline 112
public function find(list<UtilityOption> $options, string $name): ?UtilityOptionAnswers the last option of a name, or null when none is written.
Parameters
$options | list<UtilityOption> | |
$name | string |
Returns
Test cases 1
Called from 3
- method-call SqlSemantics\Platform\PostgreSql\Rules\Utility\ExplainFacts::checks() packages/sql-semantics-postgres/src/Rules/Utility/ExplainFacts.php:97
- method-call SqlSemantics\Platform\PostgreSql\Rules\Utility\OptionArguments::enabled() packages/sql-semantics-postgres/src/Rules/Utility/OptionArguments.php:86
- method-call SqlSemantics\Platform\PostgreSql\Rules\Utility\VacuumChecks::check() packages/sql-semantics-postgres/src/Rules/Utility/VacuumChecks.php:63
public function known(string $command, GrammarRelease $release): list<string>Answers the option names a command knows in a release.
Parameters
$command | string | |
$release | GrammarRelease |
Returns
list<string>Test cases 1
Called from 2
- method-call SqlSemantics\Platform\PostgreSql\Rules\Utility\ExplainFacts::checks() packages/sql-semantics-postgres/src/Rules/Utility/ExplainFacts.php:87
- method-call SqlSemantics\Platform\PostgreSql\Rules\Utility\OptionRules::derive() packages/sql-semantics-postgres/src/Rules/Utility/OptionRules.php:152
Calls 3
- class-const OptionRules::KNOWN() line 140
- class-const GrammarRelease::PostgreSql166() line 142
- class-const OptionRules::ADDED() line 142
public function derive(
Derivation $derivation,
string $command,
list<UtilityOption> $options,
): voidDerives the option values and reports each option the command does not know and each value it cannot read.
Parameters
$derivation | Derivation | |
$command | string | |
$options | list<UtilityOption> |
Called from 5
- method-call SqlSemantics\Platform\PostgreSql\Statement\Utility\Maintenance\Analyze::deriveStatement() packages/sql-semantics-postgres/src/Statement/Utility/Maintenance/Analyze.php:67
- method-call SqlSemantics\Platform\PostgreSql\Statement\Utility\Maintenance\Cluster::deriveStatement() packages/sql-semantics-postgres/src/Statement/Utility/Maintenance/Cluster.php:75
- method-call SqlSemantics\Platform\PostgreSql\Statement\Utility\Maintenance\Explain::deriveStatement() packages/sql-semantics-postgres/src/Statement/Utility/Maintenance/Explain.php:65
- method-call SqlSemantics\Platform\PostgreSql\Statement\Utility\Maintenance\Reindex::deriveStatement() packages/sql-semantics-postgres/src/Statement/Utility/Maintenance/Reindex.php:81
- method-call SqlSemantics\Platform\PostgreSql\Statement\Utility\Maintenance\Vacuum::deriveStatement() packages/sql-semantics-postgres/src/Statement/Utility/Maintenance/Vacuum.php:70
Calls 12
- method-call OptionRules::known() line 152
- method-call Derivation::environment() line 154
- function-call
in_arrayline 156 - method-call Derivation::report() line 157
- new UtilityProblem line 157
- class-const UtilityProblemKind::UnknownOption() line 157
- class-const OptionRules::BOOLEAN() line 158
- method-call OptionArguments::boolean() line 158
- new OptionArguments line 158
- class-const UtilityProblemKind::NotBoolean() line 159
- class-const OptionRules::TEXT() line 160
- class-const UtilityProblemKind::MissingArgument() line 161
Private surface 4§
Implementation details, listed for orientation only.
private const KNOWN = ['EXPLAIN' => ['analyze', 'verbose', 'costs', 'settings', 'generic_plan', 'buff…private const BOOLEAN = ['EXPLAIN' => ['analyze', 'verbose', 'costs', 'settings', 'generic_plan', 'buff…private const TEXT = ['EXPLAIN' => ['format'], 'VACUUM' => ['buffer_usage_limit'], 'ANALYZE' => ['bu…private const ADDED = ['EXPLAIN' => ['serialize', 'memory']]Test cases 4§
Test cases that cover or call this symbol, from the coverage report and from the analyzed test sources.
Relations§
Instantiated in 18
- new SqlSemantics\Platform\PostgreSql\Rules\Utility\ExplainFacts::checks() packages/sql-semantics-postgres/src/Rules/Utility/ExplainFacts.php:87
- new SqlSemantics\Platform\PostgreSql\Rules\Utility\ExplainFacts::checks() packages/sql-semantics-postgres/src/Rules/Utility/ExplainFacts.php:97
- new SqlSemantics\Platform\PostgreSql\Rules\Utility\OptionArguments::enabled() packages/sql-semantics-postgres/src/Rules/Utility/OptionArguments.php:86
- new SqlSemantics\Platform\PostgreSql\Rules\Utility\VacuumChecks::check() packages/sql-semantics-postgres/src/Rules/Utility/VacuumChecks.php:63
- new SqlSemantics\Platform\PostgreSql\Statement\Utility\Maintenance\Analyze::__construct() packages/sql-semantics-postgres/src/Statement/Utility/Maintenance/Analyze.php:59
- new SqlSemantics\Platform\PostgreSql\Statement\Utility\Maintenance\Analyze::deriveStatement() packages/sql-semantics-postgres/src/Statement/Utility/Maintenance/Analyze.php:67
- new SqlSemantics\Platform\PostgreSql\Statement\Utility\Maintenance\Analyze::render() packages/sql-semantics-postgres/src/Statement/Utility/Maintenance/Analyze.php:77
- new SqlSemantics\Platform\PostgreSql\Statement\Utility\Maintenance\Cluster::__construct() packages/sql-semantics-postgres/src/Statement/Utility/Maintenance/Cluster.php:65
- new SqlSemantics\Platform\PostgreSql\Statement\Utility\Maintenance\Cluster::deriveStatement() packages/sql-semantics-postgres/src/Statement/Utility/Maintenance/Cluster.php:75
- new SqlSemantics\Platform\PostgreSql\Statement\Utility\Maintenance\Cluster::render() packages/sql-semantics-postgres/src/Statement/Utility/Maintenance/Cluster.php:89
- new SqlSemantics\Platform\PostgreSql\Statement\Utility\Maintenance\Explain::__construct() packages/sql-semantics-postgres/src/Statement/Utility/Maintenance/Explain.php:57
- new SqlSemantics\Platform\PostgreSql\Statement\Utility\Maintenance\Explain::deriveStatement() packages/sql-semantics-postgres/src/Statement/Utility/Maintenance/Explain.php:65
- new SqlSemantics\Platform\PostgreSql\Statement\Utility\Maintenance\Explain::render() packages/sql-semantics-postgres/src/Statement/Utility/Maintenance/Explain.php:78
- new SqlSemantics\Platform\PostgreSql\Statement\Utility\Maintenance\Reindex::deriveStatement() packages/sql-semantics-postgres/src/Statement/Utility/Maintenance/Reindex.php:81
- new SqlSemantics\Platform\PostgreSql\Statement\Utility\Maintenance\Reindex::render() packages/sql-semantics-postgres/src/Statement/Utility/Maintenance/Reindex.php:98
- new SqlSemantics\Platform\PostgreSql\Statement\Utility\Maintenance\Vacuum::__construct() packages/sql-semantics-postgres/src/Statement/Utility/Maintenance/Vacuum.php:62
- new SqlSemantics\Platform\PostgreSql\Statement\Utility\Maintenance\Vacuum::deriveStatement() packages/sql-semantics-postgres/src/Statement/Utility/Maintenance/Vacuum.php:70
- new SqlSemantics\Platform\PostgreSql\Statement\Utility\Maintenance\Vacuum::render() packages/sql-semantics-postgres/src/Statement/Utility/Maintenance/Vacuum.php:81
Method calls 18
- method-call SqlSemantics\Platform\PostgreSql\Rules\Utility\ExplainFacts::checks() packages/sql-semantics-postgres/src/Rules/Utility/ExplainFacts.php:87
- method-call SqlSemantics\Platform\PostgreSql\Rules\Utility\ExplainFacts::checks() packages/sql-semantics-postgres/src/Rules/Utility/ExplainFacts.php:97
- method-call SqlSemantics\Platform\PostgreSql\Rules\Utility\OptionArguments::enabled() packages/sql-semantics-postgres/src/Rules/Utility/OptionArguments.php:86
- method-call SqlSemantics\Platform\PostgreSql\Rules\Utility\VacuumChecks::check() packages/sql-semantics-postgres/src/Rules/Utility/VacuumChecks.php:63
- method-call SqlSemantics\Platform\PostgreSql\Statement\Utility\Maintenance\Analyze::__construct() packages/sql-semantics-postgres/src/Statement/Utility/Maintenance/Analyze.php:59
- method-call SqlSemantics\Platform\PostgreSql\Statement\Utility\Maintenance\Analyze::deriveStatement() packages/sql-semantics-postgres/src/Statement/Utility/Maintenance/Analyze.php:67
- method-call SqlSemantics\Platform\PostgreSql\Statement\Utility\Maintenance\Analyze::render() packages/sql-semantics-postgres/src/Statement/Utility/Maintenance/Analyze.php:77
- method-call SqlSemantics\Platform\PostgreSql\Statement\Utility\Maintenance\Cluster::__construct() packages/sql-semantics-postgres/src/Statement/Utility/Maintenance/Cluster.php:65
- method-call SqlSemantics\Platform\PostgreSql\Statement\Utility\Maintenance\Cluster::deriveStatement() packages/sql-semantics-postgres/src/Statement/Utility/Maintenance/Cluster.php:75
- method-call SqlSemantics\Platform\PostgreSql\Statement\Utility\Maintenance\Cluster::render() packages/sql-semantics-postgres/src/Statement/Utility/Maintenance/Cluster.php:89
- method-call SqlSemantics\Platform\PostgreSql\Statement\Utility\Maintenance\Explain::__construct() packages/sql-semantics-postgres/src/Statement/Utility/Maintenance/Explain.php:57
- method-call SqlSemantics\Platform\PostgreSql\Statement\Utility\Maintenance\Explain::deriveStatement() packages/sql-semantics-postgres/src/Statement/Utility/Maintenance/Explain.php:65
- method-call SqlSemantics\Platform\PostgreSql\Statement\Utility\Maintenance\Explain::render() packages/sql-semantics-postgres/src/Statement/Utility/Maintenance/Explain.php:78
- method-call SqlSemantics\Platform\PostgreSql\Statement\Utility\Maintenance\Reindex::deriveStatement() packages/sql-semantics-postgres/src/Statement/Utility/Maintenance/Reindex.php:81
- method-call SqlSemantics\Platform\PostgreSql\Statement\Utility\Maintenance\Reindex::render() packages/sql-semantics-postgres/src/Statement/Utility/Maintenance/Reindex.php:98
- method-call SqlSemantics\Platform\PostgreSql\Statement\Utility\Maintenance\Vacuum::__construct() packages/sql-semantics-postgres/src/Statement/Utility/Maintenance/Vacuum.php:62
- method-call SqlSemantics\Platform\PostgreSql\Statement\Utility\Maintenance\Vacuum::deriveStatement() packages/sql-semantics-postgres/src/Statement/Utility/Maintenance/Vacuum.php:70
- method-call SqlSemantics\Platform\PostgreSql\Statement\Utility\Maintenance\Vacuum::render() packages/sql-semantics-postgres/src/Statement/Utility/Maintenance/Vacuum.php:81