| 9347 | |
| 9348 | |
| 9349 | static void __attribute__ ((noinline)) |
| 9350 | sql_kill_user(THD *thd, LEX_USER *user, killed_state state) |
| 9351 | { |
| 9352 | uint error; |
| 9353 | ha_rows rows; |
| 9354 | #ifdef WITH_WSREP |
| 9355 | if (WSREP(thd)) |
| 9356 | { |
| 9357 | if (!(thd->variables.option_bits & OPTION_GTID_BEGIN)) |
| 9358 | { |
| 9359 | WSREP_DEBUG("implicit commit before KILL"); |
| 9360 | /* Commit the normal transaction if one is active. */ |
| 9361 | bool commit_failed= trans_commit_implicit(thd); |
| 9362 | /* Release metadata locks acquired in this transaction. */ |
| 9363 | thd->release_transactional_locks(); |
| 9364 | if (commit_failed || wsrep_after_statement(thd)) |
| 9365 | { |
| 9366 | WSREP_DEBUG("implicit commit failed, MDL released: %lld", |
| 9367 | (longlong) thd->thread_id); |
| 9368 | return; |
| 9369 | } |
| 9370 | thd->transaction->stmt.mark_trans_did_ddl(); |
| 9371 | } |
| 9372 | } |
| 9373 | #endif /* WITH_WSREP */ |
| 9374 | switch (error= kill_threads_for_user(thd, user, state, &rows)) |
| 9375 | { |
| 9376 | case 0: |
| 9377 | my_ok(thd, rows); |
| 9378 | break; |
| 9379 | case ER_KILL_DENIED_ERROR: |
| 9380 | char buf[DEFINER_LENGTH+1]; |
| 9381 | strxnmov(buf, sizeof(buf)-1, user->user.str, "@", user->host.str, NULL); |
| 9382 | my_printf_error(ER_KILL_DENIED_ERROR, ER_THD(thd, ER_CANNOT_USER), MYF(0), |
| 9383 | "KILL USER", buf); |
| 9384 | break; |
| 9385 | case ER_OUT_OF_RESOURCES: |
| 9386 | default: |
| 9387 | my_error(error, MYF(0)); |
| 9388 | } |
| 9389 | } |
| 9390 | |
| 9391 | |
| 9392 | /** If pointer is not a null pointer, append filename to it. */ |
no test coverage detected