classCreateProcedure
final class CreateProcedure
implements Statement
uses Snapshot
Public API: explicitly declared with
@visibility public.CREATE PROCEDURE: a stored procedure with its parameters, characteristics and body.
The statement is structured as a request: it declares nothing to a context. The facts follow MYSQL-ROUTINE-001. Source: https://dev.mysql.com/doc/refman/8.4/en/create-procedure.html.
$create = (new \SqlSemantics\Platform\MySql\Semantics())->analyze('CREATE PROCEDURE shop.p(IN a INT) DETERMINISTIC SELECT a');
[$create->statement->name->name->value, count($create->statement->parameters->parameters), $create->toString()] // => ['p', 1, 'CREATE PROCEDURE shop.p(IN a INT) DETERMINISTIC SELECT a']Properties§
public list<Characteristic> $characteristicspublic ExternalBody|ProgramStatement|Statement $bodypublic QualifiedName $namepublic ParameterList $parameterspublic Account|null $definer = nullpublic bool $ifNotExists = falseMethods§
public function __construct(
public QualifiedName $name,
public ParameterList $parameters,
Node $body,
list<Characteristic> $characteristics = [],
public Account|null $definer = null,
public bool $ifNotExists = false,
)Parameters
$name | QualifiedName | The procedure name with its optional database |
$parameters | ParameterList | The parameters |
$body | Node | The body: a program statement, an SQL statement, or external code |
$characteristics | list<Characteristic> | The characteristics in written order |
$definer | Account|null | The DEFINER clause, when written |
$ifNotExists | bool | Whether IF NOT EXISTS is written (MySQL 8.0.29 and later) |
Throws
InvalidConstruction When the body or a characteristic is of another classCalls 5
- static-call Check::input() line 64
- static-call Check::listOf() line 65
- class-const Characteristic::class() line 65
- method-call ProgramFacts::body() line 66
- new ProgramFacts line 66
public function deriveStatement(Derivation $derivation): voidDerives the parameters and the body.
Parameters
$derivation | Derivation |
Calls 3
- method-call ProgramFacts::routine() line 74
- new ProgramFacts line 74
- class-const ProgramKind::Procedure() line 74
public function render(Output $out): voidWrites the statement.
Parameters
$out | Output |
Calls 5
- method-call Output::keyword() line 82
- method-call ProgramNames::qualified() line 90
- new ProgramNames line 90
- method-call Output::glue() line 91
- method-call Output::node() line 93
Test cases 75§
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 72
CharacteristicRuleTest::testCharacteristicLowersTheCommentTextcallsCharacteristicRuleTest::testCharacteristicLowersTheDataAccesscallsCharacteristicRuleTest::testCharacteristicLowersTheLanguagecallsCharacteristicRuleTest::testCharacteristicsKeepTheWrittenOrderOfACreatecallsConditionRuleTest::testHandledLowersASingleConditioncallsConditionRuleTest::testHandledLowersEveryKindOfConditioncallsConditionRuleTest::testValueLowersAnErrorCodeAndAnSqlstatecallsDiagnosticsRuleTest::testItemsLowersLocalVariableTargetscallsSignalRuleTest::testConditionLowersAConditionNamecallsSignalRuleTest::testOperandLowersLiteralsVariablesAndNamescallsDefinitionRuleTest::testRoutineLowersAProcedurecallsDefinitionRuleTest::testRoutineLowersAStoredRoutineBodycallsDefinitionRuleTest::testRoutineReadsIfNotExistscallsParameterRuleTest::testDeclaredLowersATypeWithItsCollationcallsParameterRuleTest::testParameterReadsTheModeNameAndTypecallsParameterRuleTest::testParametersLowersAnEmptyListcallsParameterRuleTest::testParametersLowersAProcedureListInOrdercallsBlockRuleTest::testBlockLowersALabeledBlockcallsBlockRuleTest::testBlockLowersAnUnlabeledBlockcallsBlockRuleTest::testCursorLowersOpenFetchAndClosecallsBlockRuleTest::testDeclarationLowersAConditionAndAHandlercallsBlockRuleTest::testDeclarationLowersACursorcallsBlockRuleTest::testDeclarationLowersAVariableWithItsCollationAndDefaultcallsBlockRuleTest::testInitialLowersTheDefaultClausecallsBlockRuleTest::testNamesLowersTheDeclaredAndTheFetchedNamescallsFlowRuleTest::testChoiceLowersASearchedCasecallsFlowRuleTest::testChoiceLowersASimpleCasecallsFlowRuleTest::testConditionalLowersAnIfWithoutElsecallsFlowRuleTest::testConditionalLowersTheBranchesAndTheElsecallsFlowRuleTest::testEndLabelLowersTheLabelAfterEndcallsFlowRuleTest::testLabeledLowersALabeledLoopcallsFlowRuleTest::testLoopLowersLoopWhileAndRepeatcallsStatementRuleTest::testBodyLowersAnExternalBodycallsStatementRuleTest::testBodyLowersAProgramStatementcallsStatementRuleTest::testDollarQuotedSplitsTheTagAndTheTextcallsRoutineRulesTest::testCreateLowersEveryKindOfStoredProgramcallsSequenceTest::testItemsAnswersTheMembersInSourceOrdercallsBlockFactsTest::testDeriveDerivesTheCursorQueryInTheScopeOfTheBlockcallsBlockFactsTest::testDeriveResolvesTheVariableOfTheInnermostBlockcallsBlockFactsTest::testVariablesHidesAParameterOfTheSameNamecallsBlockFactsTest::testVariablesReportsADuplicateNameAndKeepsTheFirstMeaningcallsBodyFactsTest::testStatementResolvesAVariableInANestedQuerycallsConditionFactsTest::testSignalResolvesTheValueOfAnItemToAParametercallsFlowFactsTest::testBranchesResolvesAVariableInTheConditioncallsFlowFactsTest::testLoopResolvesAVariableInTheConditioncallsStatementSequenceTest::testMemberAcceptsAProgramStatementAndAnSqlStatementcallsStatementSequenceTest::testMembersKeepsProgramStatementsAndSqlStatementsInOrdercallsRoutineLanguageTest::testRenderQuotesALanguageNameThatNeedsQuotingcallsConditionNameTest::testRenderWritesTheNameASignalRaisescallsConditionTest::testImplementationsAreTheValuesAHandlerNamescallsGetDiagnosticsTest::testDeriveProgramResolvesParametersAndLocalVariablescallsErrorCodeTest::testRenderWritesTheCodesOfADeclarationAndAHandlercallsGeneralConditionTest::testRenderWritesTheClassesAHandlerNamescallsResignalTest::testDeriveProgramResolvesADeclaredConditionInAHandlercallsSignalTest::testDeriveProgramResolvesADeclaredConditionAndTheVariablesOfTheItemscallsDollarQuotedTextTest::testRenderKeepsTheTextBetweenTheDelimiterscallsParameterListTest::testDeriveRelationAnswersTheRowOfAnAnalyzedRoutinecallsParameterTest::testRenderKeepsTheDirectionTheNameTheTypeAndTheCollationcallsBlockTest::testDeriveProgramHidesAParameterWithAVariableOfTheSameNamecallsBlockTest::testDeriveProgramKeepsTheFirstMeaningOfADuplicateVariablecallsConditionDeclarationTest::testRenderWritesTheNameAndTheErrorCodecallsCloseCursorTest::testDeriveProgramReportsAnUndefinedCursorcallsCursorDeclarationTest::testRenderWritesTheNameAndTheQuerycallsFetchCursorTest::testDeriveProgramResolvesTheCursorAndTheTargetscallsOpenCursorTest::testDeriveProgramReportsAnUndefinedCursorcallsConditionalBranchTest::testRenderWritesTheConditionAndTheStatementscallsIfStatementTest::testDeriveProgramDerivesEveryBranchcallsSearchedCaseTest::testDeriveProgramDerivesEveryBranchcallsSimpleCaseTest::testDeriveProgramDerivesTheOperandAndEveryBranchcallsHandlerDeclarationTest::testRenderWritesTheActionTheConditionsAndTheStatementcallsProgramStatementTest::testDeriveProgramIsNotImplementedByAQueryOfABodycallsVariableDeclarationTest::testDeriveRelationAnswersANullablePositionPerNamecalls