~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/statement/kill.cc

  • Committer: Olaf van der Spek
  • Date: 2011-03-29 12:04:36 UTC
  • mto: (2257.1.1 build) (2276.1.2 build)
  • mto: This revision was merged to the branch mainline in revision 2258.
  • Revision ID: olafvdspek@gmail.com-20110329120436-vozkuer8vqgh027p
Always call assert()

Show diffs side-by-side

added added

removed removed

Lines of Context:
18
18
 *  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
19
19
 */
20
20
 
21
 
#include "config.h"
22
 
#include <drizzled/show.h>
 
21
#include <config.h>
 
22
 
 
23
#include <drizzled/kill.h>
23
24
#include <drizzled/session.h>
24
 
#include <drizzled/session/cache.h>
25
25
#include <drizzled/statement/kill.h>
26
 
 
27
 
namespace drizzled
28
 
{
29
 
 
30
 
static bool kill_one_thread(session_id_t id, bool only_kill_query)
31
 
{
32
 
  drizzled::Session::shared_ptr session= session::Cache::singleton().find(id);
33
 
 
34
 
  if (session and session->isViewable())
 
26
#include <drizzled/sql_lex.h>
 
27
 
 
28
namespace drizzled {
 
29
namespace statement {
 
30
 
 
31
Kill::Kill(Session *in_session, Item *item, bool is_query_kill) :
 
32
  Statement(in_session)
35
33
  {
36
 
    session->awake(only_kill_query ? Session::KILL_QUERY : Session::KILL_CONNECTION);
37
 
    return true;
 
34
    if (is_query_kill)
 
35
    {
 
36
      lex().type= ONLY_KILL_QUERY;
 
37
    }
 
38
 
 
39
    lex().value_list.clear();
 
40
    lex().value_list.push_front(item);
 
41
    set_command(SQLCOM_KILL);
38
42
  }
39
43
 
40
 
  return false;
41
 
}
 
44
} // namespace statement
42
45
 
43
46
bool statement::Kill::execute()
44
47
{
45
 
  Item *it= (Item *) session->lex->value_list.head();
 
48
  Item *it= &lex().value_list.front();
46
49
 
47
 
  if ((not it->fixed && it->fix_fields(session->lex->session, &it)) || it->check_cols(1))
 
50
  if ((not it->fixed && it->fix_fields(lex().session, &it)) || it->check_cols(1))
48
51
  {
49
52
    my_message(ER_SET_CONSTANTS_ONLY, 
50
53
               ER(ER_SET_CONSTANTS_ONLY),
52
55
    return true;
53
56
  }
54
57
 
55
 
  if (kill_one_thread(static_cast<session_id_t>(it->val_int()), session->lex->type & ONLY_KILL_QUERY))
 
58
  if (drizzled::kill(*session().user(), static_cast<session_id_t>(it->val_int()), lex().type & ONLY_KILL_QUERY))
56
59
  {
57
 
    session->my_ok();
 
60
    session().my_ok();
58
61
  }
59
62
  else
60
63
  {