| 307 | |
| 308 | |
| 309 | sp_handler* |
| 310 | sp_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) && |
nothing calls this directly
no test coverage detected