classPragma
final class Pragma
implements Statement
uses Snapshot
@visibility public.A pragma: a query or a change of a setting or of internal data of the database library.
Rule: SQLITE-PRAGMA-001. The grammar fixes the pragma name, an optional schema, and an optional value that is a signed number, a name (written as an identifier or as a string), or one of the keywords ON, DELETE and DEFAULT; these are distinct operand kinds. SQLite hands the value to the pragma as text. PRAGMA x = v and PRAGMA x(v) "yield identical results"; the value is written with =. What a pragma does, whether it returns rows and which columns they have, is fixed per pragma name by the manual and is not derived: the operation records no output, no relation use and no diagnostic, and an unknown pragma name is not an error in SQLite either. Source: https://sqlite.org/pragma.html. Status: Implemented.
$pragma = (new \SqlSemantics\Platform\Sqlite\Semantics())->analyze('PRAGMA main.cache_size(4000)');
[$pragma->statement->name->schema?->value, $pragma->statement->name->name->value, $pragma->statement->value->number->digits, $pragma->toString()] // => ['main', 'cache_size', '4000', 'PRAGMA main.cache_size = 4000']Properties§
public QualifiedName $namepublic SignedNumber|Name|PragmaKeyword|null $value = nullMethods§
public function __construct(
public QualifiedName $name,
public SignedNumber|Name|PragmaKeyword|null $value = null,
)Parameters
$name | QualifiedName | The pragma name with its optional schema |
$value | SignedNumber|Name|PragmaKeyword|null | The value: a signed number, a name, a keyword, or null when none is written |
Calls 1
- static-call Check::input() line 48
public function deriveStatement(Derivation $derivation): voidDerives the numeric literal of the value; what a pragma reads and returns depends on its name, which the grammar does not fix.
Parameters
$derivation | Derivation |
Calls 2
- method-call Derivation::scalar() line 57
- method-call Derivation::environment() line 57
public function render(Output $out): voidWrites the pragma, with the value after an equal sign.
Parameters
$out | Output |
Calls 7
- method-call Output::keyword() line 66
- method-call ObjectNames::write() line 67
- new ObjectNames line 67
- class-const NameUse::Label() line 67
- method-call Output::symbol() line 71
- method-call Output::node() line 73
- method-call Output::name() line 75
Test cases 8§
Test cases that cover or call this symbol, from the coverage report and from the analyzed test sources.
Dedicated tests 3
Other tests reaching this symbol 5
DefinitionCommandsTest::testCommandLowersACommandOfEveryFamilycallsMaintenanceRuleTest::testCommandLowersEachAdministrationCommandToItsOwnRequestcallsMaintenanceRuleTest::testCommandReadsTheFirstNameOfAQualifiedPragmaAsItsSchemacallsMaintenanceRuleTest::testValueKeepsEachOperandKindApartcallsSignedNumberTest::testRenderWritesAPragmaValuecalls
Relations§
Instantiated in 3
- new SqlSemantics\Platform\Sqlite\Lowering\Definition\MaintenanceRule::command() packages/sql-semantics-sqlite/src/Lowering/Definition/MaintenanceRule.php:52
- new SqlSemantics\Platform\Sqlite\Lowering\Definition\MaintenanceRule::command() packages/sql-semantics-sqlite/src/Lowering/Definition/MaintenanceRule.php:53
- new SqlSemantics\Platform\Sqlite\Lowering\Definition\MaintenanceRule::command() packages/sql-semantics-sqlite/src/Lowering/Definition/MaintenanceRule.php:54