classErrorCode
final class ErrorCode
implements Condition
uses Snapshot
@visibility public.A MySQL error code as a condition value.
The grammar reads the code as an unsigned number (rule ulong_num of sql_yacc.yy): the leading decimal digits of a decimal or floating number (1e2 is 1, 0.5 is 0), or the digits of a hexadecimal literal; a value beyond the range of the conversion is its largest value. The code 0 is rejected (ER_WRONG_VALUE), and the server keeps the code as a 32-bit error number. Source: https://dev.mysql.com/doc/refman/8.4/en/declare-condition.html, https://github.com/mysql/mysql-server/blob/mysql-8.0.44/sql/sql_yacc.yy (rules sp_cond, ulong_num).
(new \SqlSemantics\Platform\MySql\Statement\Routine\Condition\ErrorCode(new \SqlSemantics\Platform\MySql\Statement\Literal\Numeral('1051')))->code->text // => '1051'(new \SqlSemantics\Platform\MySql\Statement\Routine\Condition\ErrorCode(new \SqlSemantics\Platform\MySql\Statement\Literal\Numeral('1051.9e3')))->number() // => 1051Properties§
public Numeral $codeMethods§
public function valid(): boolTells whether the code is not 0, the value the grammar rejects.
Returns
boolTest cases 1
Calls 2
- function-call
ltrimline 45 - method-call ErrorCode::digits() line 45
public function number(): intAnswers the error number the server keeps: the value read by the grammar, truncated to 32 bits.
Returns
intTest cases 1
public function digits(): stringAnswers the digits the grammar converts: all digits of a hexadecimal literal, the leading decimal digits otherwise.
Returns
stringTest cases 1
Called from 2
- method-call SqlSemantics\Platform\MySql\Statement\Routine\Condition\ErrorCode::valid() packages/sql-semantics-mysql/src/Statement/Routine/Condition/ErrorCode.php:45
- method-call SqlSemantics\Platform\MySql\Statement\Routine\Condition\ErrorCode::number() packages/sql-semantics-mysql/src/Statement/Routine/Condition/ErrorCode.php:53
Calls 1
- function-call
preg_replaceline 76
public function render(Output $out): voidTest cases 14§
Test cases that cover or call this symbol, from the coverage report and from the analyzed test sources.
Dedicated tests 5
ErrorCodeTest::testDigitsAnswersTheDigitsTheGrammarConvertscallsErrorCodeTest::testNumberAnswersTheErrorNumberTheServerKeepscallsErrorCodeTest::testRenderWritesTheCodecallsErrorCodeTest::testRenderWritesTheCodesOfADeclarationAndAHandlercallsErrorCodeTest::testValidTellsWhetherTheCodeIsNotZerocalls
Other tests reaching this symbol 9
ConditionRuleTest::testHandledLowersEveryKindOfConditioncallsConditionRuleTest::testValueLowersAnErrorCodeAndAnSqlstatecallsConditionFactsTest::providerSameComparesTheValuescallsConditionFactsTest::testMeaningAnswersTheDeclaredValueOfAConditionNamecallsProgramScopeTest::testConditionFindsTheInnermostDeclarationOfTheNamecallsProgramScopeTest::testDeclaredReplacesTheEnvironmentConditionsAndCursorscallsProgramScopeTest::testHandlerSeesNoLabelOutsideTheHandlercallsConditionTest::testImplementationsAreTheValuesAHandlerNamescallsConditionDeclarationTest::testRenderWritesTheNameAndTheErrorCodecalls
Relations§
Instantiated in 1
Type checks 3
- instanceof SqlSemantics\Platform\MySql\Rules\Routine\ConditionFacts::value() packages/sql-semantics-mysql/src/Rules/Routine/ConditionFacts.php:49
- instanceof SqlSemantics\Platform\MySql\Rules\Routine\ConditionFacts::same() packages/sql-semantics-mysql/src/Rules/Routine/ConditionFacts.php:75
- instanceof SqlSemantics\Platform\MySql\Rules\Routine\ConditionFacts::signal() packages/sql-semantics-mysql/src/Rules/Routine/ConditionFacts.php:91
Type declarations 2
- type SqlSemantics\Platform\MySql\Lowering\Routine\Condition\ConditionRule packages/sql-semantics-mysql/src/Lowering/Routine/Condition/ConditionRule.php:45
- type SqlSemantics\Platform\MySql\Statement\Routine\Program\ConditionDeclaration packages/sql-semantics-mysql/src/Statement/Routine/Program/ConditionDeclaration.php:33