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

Function list_callback

sql/sql_show.cc:2990–3075  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2988
2989
2990static my_bool list_callback(THD *tmp, list_callback_arg *arg)
2991{
2992
2993 Security_context *tmp_sctx= tmp->security_ctx;
2994 bool got_thd_data;
2995 if (thd_visible_in_processlist(arg->user, tmp))
2996 {
2997 thread_info *thd_info= new (arg->thd->mem_root) thread_info;
2998
2999 thd_info->thread_id=tmp->thread_id;
3000 thd_info->os_thread_id=tmp->os_thread_id;
3001 thd_info->user= arg->thd->strdup(tmp_sctx->user &&
3002 (tmp_sctx->user != slave_user &&
3003 tmp_sctx->user != wsrep_user) ?
3004 tmp_sctx->user :
3005 (tmp->system_thread ?
3006 "system user" : "unauthenticated user"));
3007 if (tmp->peer_port && (tmp_sctx->host || tmp_sctx->ip) &&
3008 arg->thd->security_ctx->host_or_ip[0])
3009 {
3010 if ((thd_info->host= arg->thd->alloc(LIST_PROCESS_HOST_LEN+1)))
3011 my_snprintf((char *) thd_info->host, LIST_PROCESS_HOST_LEN,
3012 "%s:%u", tmp_sctx->host_or_ip, tmp->peer_port);
3013 }
3014 else
3015 thd_info->host= arg->thd->strdup(tmp_sctx->host_or_ip[0] ?
3016 tmp_sctx->host_or_ip :
3017 tmp_sctx->host ? tmp_sctx->host : "");
3018 thd_info->command=(int) tmp->get_command();
3019
3020 if ((got_thd_data= !trylock_short(&tmp->LOCK_thd_data)))
3021 {
3022 /* This is an approximation */
3023 thd_info->proc_info= (char*) (tmp->killed >= KILL_QUERY ?
3024 "Killed" : 0);
3025
3026 /* The following variables are only safe to access under a lock */
3027 thd_info->db= 0;
3028 if (tmp->db.str)
3029 thd_info->db= arg->thd->strmake(tmp->db.str, tmp->db.length);
3030
3031 if (tmp->query())
3032 {
3033 uint length= MY_MIN(arg->max_query_length, tmp->query_length());
3034 char *q= arg->thd->strmake(tmp->query(),length);
3035 /* Safety: in case strmake failed, we set length to 0. */
3036 thd_info->query_string=
3037 CSET_STRING(q, q ? length : 0, tmp->query_charset());
3038 }
3039
3040 /*
3041 Progress report. We need to do this under a lock to ensure that all
3042 is from the same stage.
3043 */
3044 if (tmp->progress.max_counter)
3045 {
3046 uint max_stage= MY_MAX(tmp->progress.max_stage, 1);
3047 thd_info->progress= (((tmp->progress.stage / (double) max_stage) +

Callers

nothing calls this directly

Calls 13

my_snprintfFunction · 0.85
trylock_shortFunction · 0.85
CSET_STRINGClass · 0.85
thread_state_infoFunction · 0.85
strdupMethod · 0.80
get_commandMethod · 0.80
strmakeMethod · 0.80
query_lengthMethod · 0.80
query_charsetMethod · 0.80
allocMethod · 0.45
queryMethod · 0.45

Tested by

no test coverage detected