MCPcopy Create free account
hub / github.com/Meituan-Dianping/SQLAdvisor / find_handler

Method find_handler

sql/sp_pcontext.cc:309–416  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

307
308
309sp_handler*
310sp_pcontext::find_handler(const char *sql_state,
311 uint sql_errno,
312 Sql_condition::enum_warning_level level) const
313{
314 sp_handler *found_handler= NULL;
315 sp_condition_value *found_cv= NULL;
316
317 for (int i= 0; i < m_handlers.elements(); ++i)
318 {
319 sp_handler *h= m_handlers.at(i);
320
321 List_iterator_fast<sp_condition_value> li(h->condition_values);
322 sp_condition_value *cv;
323
324 while ((cv= li++))
325 {
326 switch (cv->type)
327 {
328 case sp_condition_value::ERROR_CODE:
329 if (sql_errno == cv->mysqlerr &&
330 (!found_cv ||
331 found_cv->type > sp_condition_value::ERROR_CODE))
332 {
333 found_cv= cv;
334 found_handler= h;
335 }
336 break;
337
338 case sp_condition_value::SQLSTATE:
339 if (strcmp(sql_state, cv->sql_state) == 0 &&
340 (!found_cv ||
341 found_cv->type > sp_condition_value::SQLSTATE))
342 {
343 found_cv= cv;
344 found_handler= h;
345 }
346 break;
347
348 case sp_condition_value::WARNING:
349 if ((is_sqlstate_warning(sql_state) ||
350 level == Sql_condition::WARN_LEVEL_WARN) && !found_cv)
351 {
352 found_cv= cv;
353 found_handler= h;
354 }
355 break;
356
357 case sp_condition_value::NOT_FOUND:
358 if (is_sqlstate_not_found(sql_state) && !found_cv)
359 {
360 found_cv= cv;
361 found_handler= h;
362 }
363 break;
364
365 case sp_condition_value::EXCEPTION:
366 if (is_sqlstate_exception(sql_state) &&

Callers

nothing calls this directly

Calls 4

is_sqlstate_warningFunction · 0.85
is_sqlstate_not_foundFunction · 0.85
is_sqlstate_exceptionFunction · 0.85
elementsMethod · 0.45

Tested by

no test coverage detected