Skip to content

Commit ea023a5

Browse files
author
James Cor
committed
nil implementations are a thing
1 parent 2c62c05 commit ea023a5

File tree

2 files changed

+25
-2
lines changed

2 files changed

+25
-2
lines changed

eventscheduler/event_scheduler.go

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,9 @@ func InitEventScheduler(
9191

9292
// Close closes the EventScheduler.
9393
func (es *EventScheduler) Close() {
94+
if es == nil {
95+
return
96+
}
9497
es.status = SchedulerOff
9598
es.executor.shutdown()
9699
}
@@ -99,6 +102,9 @@ func (es *EventScheduler) Close() {
99102
// This function requires valid analyzer and sql context to evaluate all events in all databases
100103
// to load enabled events to the EventScheduler.
101104
func (es *EventScheduler) TurnOnEventScheduler(a *analyzer.Analyzer) error {
105+
if es == nil {
106+
return nil
107+
}
102108
if es.status == SchedulerDisabled {
103109
return ErrEventSchedulerDisabled
104110
} else if es.status == SchedulerOn {
@@ -120,6 +126,9 @@ func (es *EventScheduler) TurnOnEventScheduler(a *analyzer.Analyzer) error {
120126

121127
// TurnOffEventScheduler is called when user sets --event-scheduler system variable to OFF or 0.
122128
func (es *EventScheduler) TurnOffEventScheduler() error {
129+
if es == nil {
130+
return nil
131+
}
123132
if es.status == SchedulerDisabled {
124133
return ErrEventSchedulerDisabled
125134
} else if es.status == SchedulerOff {
@@ -135,6 +144,9 @@ func (es *EventScheduler) TurnOffEventScheduler() error {
135144
// loadEventsAndStartEventExecutor evaluates all events in all databases and evaluates the enabled events
136145
// with valid schedule to load into the eventExecutor. Then, it starts the eventExecutor.
137146
func (es *EventScheduler) loadEventsAndStartEventExecutor(ctx *sql.Context, a *analyzer.Analyzer) error {
147+
if es == nil {
148+
return nil
149+
}
138150
es.executor.catalog = a.Catalog
139151
es.executor.loadAllEvents(ctx)
140152
go es.executor.start()
@@ -144,6 +156,9 @@ func (es *EventScheduler) loadEventsAndStartEventExecutor(ctx *sql.Context, a *a
144156
// AddEvent implements sql.EventScheduler interface.
145157
// This function is called when there is an event created at runtime.
146158
func (es *EventScheduler) AddEvent(ctx *sql.Context, edb sql.EventDatabase, details sql.EventDefinition) {
159+
if es == nil {
160+
return
161+
}
147162
if es.status == SchedulerDisabled || es.status == SchedulerOff {
148163
return
149164
}
@@ -153,6 +168,9 @@ func (es *EventScheduler) AddEvent(ctx *sql.Context, edb sql.EventDatabase, deta
153168
// UpdateEvent implements sql.EventScheduler interface.
154169
// This function is called when there is an event altered at runtime.
155170
func (es *EventScheduler) UpdateEvent(ctx *sql.Context, edb sql.EventDatabase, orgEventName string, details sql.EventDefinition) {
171+
if es == nil {
172+
return
173+
}
156174
if es.status == SchedulerDisabled || es.status == SchedulerOff {
157175
return
158176
}
@@ -163,6 +181,9 @@ func (es *EventScheduler) UpdateEvent(ctx *sql.Context, edb sql.EventDatabase, o
163181
// This function is called when there is an event dropped at runtime. This function
164182
// removes the given event if it exists in the enabled events list of the EventScheduler.
165183
func (es *EventScheduler) RemoveEvent(dbName, eventName string) {
184+
if es == nil {
185+
return
186+
}
166187
if es.status == SchedulerDisabled || es.status == SchedulerOff {
167188
return
168189
}
@@ -173,6 +194,9 @@ func (es *EventScheduler) RemoveEvent(dbName, eventName string) {
173194
// This function is called when there is a database dropped at runtime. This function
174195
// removes all events of given database that exist in the enabled events list of the EventScheduler.
175196
func (es *EventScheduler) RemoveSchemaEvents(dbName string) {
197+
if es == nil {
198+
return
199+
}
176200
if es.status == SchedulerDisabled || es.status == SchedulerOff {
177201
return
178202
}

sql/information_schema/routines_table.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,6 @@ func routinesRowIter(ctx *Context, c Catalog, p map[string][]*plan.Procedure) (R
139139
privSet = mysql_db.NewPrivilegeSet()
140140
}
141141

142-
builder := planbuilder.New(ctx, c, nil, nil)
143142
for dbName, procedures := range p {
144143
if !hasRoutinePrivsOnDB(privSet, dbName) {
145144
continue
@@ -156,7 +155,7 @@ func routinesRowIter(ctx *Context, c Catalog, p map[string][]*plan.Procedure) (R
156155
}
157156

158157
// todo shortcircuit routineDef->procedure.CreateProcedureString?
159-
parsedProcedure, _, _, _, err := builder.Parse(procedure.CreateProcedureString, nil, false)
158+
parsedProcedure, _, err := planbuilder.Parse(ctx, c, procedure.CreateProcedureString)
160159
if err != nil {
161160
continue
162161
}

0 commit comments

Comments
 (0)