classUtilityOption
final class UtilityOption
implements Clause
uses Snapshot
@visibility public.One option of EXPLAIN, VACUUM, ANALYZE, CLUSTER or REINDEX: a name and an optional value.
Mirrors PostgreSQL's DefElem of utility_option_elem. The grammar accepts any word as the name and a word, a string, a number or nothing as the value; the command decides which names it knows. A name is a word, or one of the keywords the grammar reads on their own; the keyword FORMAT is read only directly before the word json. Source: https://www.postgresql.org/docs/17/sql-explain.html, https://www.postgresql.org/docs/17/sql-vacuum.html.
$operation = (new \SqlSemantics\Platform\PostgreSql\Semantics())->analyze('VACUUM (PARALLEL 2, ANALYSE)');
[$operation->statement->options[0]->option(), $operation->statement->options[0]->argument->magnitude->digits, $operation->statement->options[1]->option()] // => ['parallel', '2', 'analyze']new \SqlSemantics\Platform\PostgreSql\Statement\Utility\Maintenance\UtilityOption(\SqlSemantics\Platform\PostgreSql\Statement\Utility\Maintenance\OptionKeyword::Format) // throws \SqlSemantics\Platform\PostgreSql\Model\Diagnostic\InvalidConstructionProperties§
public Name|OptionKeyword $namepublic Word|StringConstant|Toggle|SignedNumber|null $argument = nullMethods§
public function __construct(
public Name|OptionKeyword $name,
public Word|StringConstant|Toggle|SignedNumber|null $argument = null,
)Parameters
$name | Name|OptionKeyword | The option name: a word, or a keyword the grammar reads on its own |
$argument | Word|StringConstant|Toggle|SignedNumber|null | The value, when one is written: a word, a string, TRUE, FALSE or ON, or a number |
Calls 2
- static-call Check::input() line 47
- class-const OptionKeyword::Format() line 47
public function option(): stringAnswers the option name as the command receives it.
Returns
stringpublic function deriveClause(Derivation $derivation, Environment $environment): voidDerives the value.
Parameters
$derivation | Derivation | |
$environment | Environment |
public function render(Output $out): voidWrites the name and the value; the word format before the word json is quoted so that it is not read as the keyword.
Parameters
$out | Output |
Calls 5
- method-call Output::keyword() line 72
- method-call Output::name() line 75
- class-const NameUse::Identifier() line 75
- class-const NameUse::Routine() line 75
- method-call Output::node() line 82
public function text(): ?stringAnswers the value as the text the command receives, or null when no value is written.
Returns
?stringTest cases 1
Test cases 10§
Test cases that cover or call this symbol, from the coverage report and from the analyzed test sources.
Dedicated tests 2
Other tests reaching this symbol 8
OptionRuleTest::testOptionsLowersTheListInOrdercallsOptionArgumentsTest::testBooleanReadsTheValuesTheServerAcceptscallsOptionArgumentsTest::testBooleanRefusesOtherValuescallsOptionArgumentsTest::testEnabledReadsTheLastOccurrencecallsOptionArgumentsTest::testIntegerReadsIntegersThatFitIn32BitscallsOptionRulesTest::testFindAnswersTheLastOccurrencecallsOptionRulesTest::testWritableAcceptsWordsInTheOrderOfTheGrammarcallsOptionRulesTest::testWritableRefusesWhatTheWordSyntaxCannotHoldcalls
Relations§
Instantiated in 3
- new SqlSemantics\Platform\PostgreSql\Lowering\Utility\OptionRule::options() packages/sql-semantics-postgres/src/Lowering/Utility/OptionRule.php:65
- new SqlSemantics\Platform\PostgreSql\Lowering\Utility\OptionRule::analyze() packages/sql-semantics-postgres/src/Lowering/Utility/OptionRule.php:132
- new SqlSemantics\Platform\PostgreSql\Lowering\Utility\OptionRule::word() packages/sql-semantics-postgres/src/Lowering/Utility/OptionRule.php:140
Constant reads 5
- class-const SqlSemantics\Platform\PostgreSql\Statement\Utility\Maintenance\Analyze::__construct() packages/sql-semantics-postgres/src/Statement/Utility/Maintenance/Analyze.php:57
- class-const SqlSemantics\Platform\PostgreSql\Statement\Utility\Maintenance\Cluster::__construct() packages/sql-semantics-postgres/src/Statement/Utility/Maintenance/Cluster.php:64
- class-const SqlSemantics\Platform\PostgreSql\Statement\Utility\Maintenance\Explain::__construct() packages/sql-semantics-postgres/src/Statement/Utility/Maintenance/Explain.php:56
- class-const SqlSemantics\Platform\PostgreSql\Statement\Utility\Maintenance\Reindex::__construct() packages/sql-semantics-postgres/src/Statement/Utility/Maintenance/Reindex.php:68
- class-const SqlSemantics\Platform\PostgreSql\Statement\Utility\Maintenance\Vacuum::__construct() packages/sql-semantics-postgres/src/Statement/Utility/Maintenance/Vacuum.php:60
Type declarations 6
- type SqlSemantics\Platform\PostgreSql\Lowering\Utility\OptionRule packages/sql-semantics-postgres/src/Lowering/Utility/OptionRule.php:130
- type SqlSemantics\Platform\PostgreSql\Lowering\Utility\OptionRule packages/sql-semantics-postgres/src/Lowering/Utility/OptionRule.php:138
- type SqlSemantics\Platform\PostgreSql\Rules\Utility\OptionArguments packages/sql-semantics-postgres/src/Rules/Utility/OptionArguments.php:37
- type SqlSemantics\Platform\PostgreSql\Rules\Utility\OptionArguments packages/sql-semantics-postgres/src/Rules/Utility/OptionArguments.php:68
- type SqlSemantics\Platform\PostgreSql\Rules\Utility\OptionRules packages/sql-semantics-postgres/src/Rules/Utility/OptionRules.php:121
- type SqlSemantics\Platform\PostgreSql\Rules\Utility\VacuumChecks packages/sql-semantics-postgres/src/Rules/Utility/VacuumChecks.php:83