classCreateEvent
final class CreateEvent
implements Statement
uses Snapshot
Public API: explicitly declared with
@visibility public.CREATE EVENT: a statement the event scheduler runs once or repeatedly.
The statement is structured as a request: it declares nothing to a context. The facts follow MYSQL-EVENT-001. Source: https://dev.mysql.com/doc/refman/8.4/en/create-event.html.
$create = (new \SqlSemantics\Platform\MySql\Semantics())->analyze("CREATE EVENT e ON SCHEDULE EVERY 1 DAY ON COMPLETION PRESERVE DISABLE COMMENT 'nightly' DO DELETE FROM log");
[$create->statement->completion, $create->statement->status, $create->statement->comment->value] // => [\SqlSemantics\Platform\MySql\Statement\Routine\Event\Completion::Preserve, \SqlSemantics\Platform\MySql\Statement\Routine\Event\EventStatus::Disable, 'nightly']Properties§
public ProgramStatement|Statement $bodypublic QualifiedName $namepublic Schedule $schedulepublic Completion|null $completion = nullpublic EventStatus|null $status = nullpublic Text|null $comment = nullpublic Account|null $definer = nullpublic bool $ifNotExists = falseMethods§
public function __construct(
public QualifiedName $name,
public Schedule $schedule,
Node $body,
public Completion|null $completion = null,
public EventStatus|null $status = null,
public Text|null $comment = null,
public Account|null $definer = null,
public bool $ifNotExists = false,
)Parameters
$name | QualifiedName | The event name with its optional database |
$schedule | Schedule | When the event runs |
$body | Node | The statement the event runs: a program statement or an SQL statement |
$completion | Completion|null | The ON COMPLETION clause, when written |
$status | EventStatus|null | The status clause, when written |
$comment | Text|null | The COMMENT clause, when written |
$definer | Account|null | The DEFINER clause, when written |
$ifNotExists | bool | Whether IF NOT EXISTS is written |
Throws
InvalidConstruction When the body is of another classCalls 3
- static-call Check::input() line 68
- method-call StatementSequence::member() line 70
- new StatementSequence line 70
public function deriveStatement(Derivation $derivation): voidDerives the schedule and the body.
Parameters
$derivation | Derivation |
Calls 2
- method-call ProgramFacts::event() line 78
- new ProgramFacts line 78
public function render(Output $out): voidWrites the statement.
Parameters
$out | Output |
Calls 5
- method-call Output::keyword() line 86
- method-call ProgramNames::qualified() line 94
- new ProgramNames line 94
- method-call EventClauses::write() line 96
- new EventClauses line 96
Test cases 18§
Test cases that cover or call this symbol, from the coverage report and from the analyzed test sources.
Dedicated tests 4
Other tests reaching this symbol 14
DefinitionTailsTest::testTailHandsAStoredProgramToTheRoutineFamilycallsEventRuleTest::testBoundLowersStartsAndEndscallsEventRuleTest::testCommentLowersTheTextcallsEventRuleTest::testCompletionLowersPreserveAndNotPreservecallsEventRuleTest::testCreateLeavesTheOptionalClausesAbsentcallsEventRuleTest::testCreateLowersAnEventOfEveryLayoutcallsEventRuleTest::testScheduleLowersAtAndEverycallsEventRuleTest::testStatusLowersEveryStatuscallsStatementRuleTest::testEventLowersTheStatementOfAnEventcallsRoutineRulesTest::testCreateLowersEveryKindOfStoredProgramcallsBodyFactsTest::testStatementResolvesAVariableInAnInspectedStatementcallsOnceScheduleTest::testDeriveScheduleDerivesTheTimecallsRecurringScheduleTest::testDeriveScheduleDerivesAnEndWithoutAStartcallsRecurringScheduleTest::testDeriveScheduleDerivesTheQuantityAndBothTimescalls