~ubuntu-branches/ubuntu/trusty/drizzle/trusty

« back to all changes in this revision

Viewing changes to plugin/session_dictionary/processlist.cc

  • Committer: Bazaar Package Importer
  • Author(s): Monty Taylor
  • Date: 2010-12-21 16:39:40 UTC
  • mfrom: (1.2.4 upstream)
  • Revision ID: james.westby@ubuntu.com-20101221163940-c1pfo1jjvx7909xq
Tags: 2010.12.06-0ubuntu1
* New upstream release.
* Added libaio-dev build depend for InnoDB.
* Removed libpcre patch - applied upstream.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
/* - mode: c; c-basic-offset: 2; indent-tabs-mode: nil; -*-
2
2
 *  vim:expandtab:shiftwidth=2:tabstop=2:smarttab:
3
3
 *
4
 
 *  Copyright (C) 2009 Sun Microsystems
 
4
 *  Copyright (C) 2009 Sun Microsystems, Inc.
5
5
 *
6
6
 *  This program is free software; you can redistribute it and/or modify
7
7
 *  it under the terms of the GNU General Public License as published by
41
41
  add_field("ID", plugin::TableFunction::NUMBER, 0, false);
42
42
  add_field("USER", 16);
43
43
  add_field("HOST", NI_MAXHOST);
44
 
  add_field("DB");
 
44
  add_field("DB", plugin::TableFunction::STRING, MAXIMUM_IDENTIFIER_LENGTH, true);
45
45
  add_field("COMMAND", 16);
46
 
  add_field("TIME", plugin::TableFunction::NUMBER, 0, false);
 
46
  add_field("TIME", plugin::TableFunction::SIZE, 0, false);
47
47
  add_field("STATE", plugin::TableFunction::STRING, 256, true);
48
48
  add_field("INFO", plugin::TableFunction::STRING, PROCESS_LIST_WIDTH, true);
49
49
  add_field("HAS_GLOBAL_LOCK", plugin::TableFunction::BOOLEAN);
65
65
 
66
66
  while ((tmp= session_generator))
67
67
  {
68
 
    const SecurityContext *tmp_sctx= &tmp->getSecurityContext();
69
 
    const char *val;
 
68
    drizzled::Session::State::const_shared_ptr state(tmp->state());
 
69
    identifier::User::const_shared_ptr tmp_sctx= tmp->user();
70
70
 
71
71
    /* ID */
72
72
    push((int64_t) tmp->thread_id);
73
73
 
74
 
 
75
74
    /* USER */
76
 
    if (not tmp_sctx->getUser().empty())
77
 
      push(tmp_sctx->getUser());
 
75
    if (not tmp_sctx->username().empty())
 
76
      push(tmp_sctx->username());
78
77
    else 
79
78
      push(_("no user"));
80
79
 
81
80
    /* HOST */
82
 
    push(tmp_sctx->getIp());
 
81
    push(tmp_sctx->address());
83
82
 
84
83
    /* DB */
85
 
    if (! tmp->db.empty())
 
84
    drizzled::util::string::const_shared_ptr schema(tmp->schema());
 
85
    if (schema and not schema->empty())
86
86
    {
87
 
      push(tmp->db);
 
87
      push(*schema);
88
88
    }
89
89
    else
90
90
    {
92
92
    }
93
93
 
94
94
    /* COMMAND */
95
 
    if ((val= const_cast<char *>(tmp->getKilled() == Session::KILL_CONNECTION ? "Killed" : 0)))
 
95
    const char *val= tmp->getKilled() == Session::KILL_CONNECTION ? "Killed" : NULL;
 
96
    if (val)
96
97
    {
97
98
      push(val);
98
99
    }
105
106
    push(static_cast<uint64_t>(tmp->start_time ?  now - tmp->start_time : 0));
106
107
 
107
108
    /* STATE */
108
 
    val= (char*) (tmp->client->isWriting() ?
109
 
                  "Writing to net" :
110
 
                  tmp->client->isReading() ?
111
 
                  (tmp->command == COM_SLEEP ?
112
 
                   NULL : "Reading from net") :
113
 
                  tmp->get_proc_info() ? tmp->get_proc_info() :
114
 
                  tmp->getThreadVar() &&
115
 
                  tmp->getThreadVar()->current_cond ?
116
 
                  "Waiting on cond" : NULL);
117
 
    val ? push(val) : push();
 
109
    const char *step= tmp->get_proc_info();
 
110
 
 
111
    if (step)
 
112
    {
 
113
      push(step);
 
114
    }
 
115
    else
 
116
    {
 
117
      push();
 
118
    }
118
119
 
119
120
    /* INFO */
120
 
    push(*tmp->getQueryString());
 
121
    if (state)
 
122
    {
 
123
      size_t length;
 
124
      const char *tmp_ptr= state->query(length);
 
125
      push(tmp_ptr, length);
 
126
    }
 
127
    else
 
128
    {
 
129
      push();
 
130
    }
121
131
 
122
132
    /* HAS_GLOBAL_LOCK */
123
133
    bool has_global_lock= tmp->isGlobalReadLock();