MCPcopy Create free account
hub / github.com/MariaDB/server / processlist_callback

Function processlist_callback

sql/sql_show.cc:3491–3617  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

3489
3490
3491static my_bool processlist_callback(THD *tmp, processlist_callback_arg *arg)
3492{
3493 Security_context *tmp_sctx= tmp->security_ctx;
3494 CHARSET_INFO *cs= system_charset_info;
3495 const char *val;
3496 ulonglong max_counter;
3497 bool got_thd_data;
3498 char *user=
3499 arg->thd->security_ctx->master_access & PRIV_STMT_SHOW_PROCESSLIST ?
3500 NullS : arg->thd->security_ctx->priv_user;
3501
3502 if (!thd_visible_in_processlist(user, tmp))
3503 return 0;
3504
3505 restore_record(arg->table, s->default_values);
3506 /* ID */
3507 arg->table->field[0]->store((longlong) tmp->thread_id, TRUE);
3508 /* USER */
3509 val= tmp_sctx->user && (tmp_sctx->user != slave_user &&
3510 tmp_sctx->user != wsrep_user) ? tmp_sctx->user :
3511 (tmp->system_thread ? "system user" : "unauthenticated user");
3512 arg->table->field[1]->store(val, strlen(val), cs);
3513 /* HOST */
3514 if (tmp->peer_port && (tmp_sctx->host || tmp_sctx->ip) &&
3515 arg->thd->security_ctx->host_or_ip[0])
3516 {
3517 char host[LIST_PROCESS_HOST_LEN + 1];
3518 my_snprintf(host, LIST_PROCESS_HOST_LEN, "%s:%u",
3519 tmp_sctx->host_or_ip, tmp->peer_port);
3520 arg->table->field[2]->store(host, strlen(host), cs);
3521 }
3522 else
3523 arg->table->field[2]->store(tmp_sctx->host_or_ip,
3524 strlen(tmp_sctx->host_or_ip), cs);
3525
3526 if ((got_thd_data= !trylock_short(&tmp->LOCK_thd_data)))
3527 {
3528 /* DB */
3529 if (tmp->db.str)
3530 {
3531 arg->table->field[3]->store(tmp->db.str, tmp->db.length, cs);
3532 arg->table->field[3]->set_notnull();
3533 }
3534 }
3535
3536 /* COMMAND */
3537 if ((val= (char *) (!got_thd_data ? "Busy" :
3538 (tmp->killed >= KILL_QUERY ?
3539 "Killed" : 0))))
3540 arg->table->field[4]->store(val, strlen(val), cs);
3541 else
3542 arg->table->field[4]->store(command_name[tmp->get_command()].str,
3543 command_name[tmp->get_command()].length, cs);
3544
3545 /* MYSQL_TIME */
3546 ulonglong utime= tmp->start_utime;
3547 ulonglong utime_after_query_snapshot= tmp->utime_after_query;
3548 if (utime < utime_after_query_snapshot)

Callers

nothing calls this directly

Calls 10

my_snprintfFunction · 0.85
trylock_shortFunction · 0.85
thread_state_infoFunction · 0.85
set_notnullMethod · 0.80
get_commandMethod · 0.80
query_lengthMethod · 0.80
storeMethod · 0.45
queryMethod · 0.45

Tested by

no test coverage detected