1
/* - mode: c; c-basic-offset: 2; indent-tabs-mode: nil; -*-
2
* vim:expandtab:shiftwidth=2:tabstop=2:smarttab:
4
* Copyright (C) 2010 Brian Aker
6
* This program is free software; you can redistribute it and/or modify
7
* it under the terms of the GNU General Public License as published by
8
* the Free Software Foundation; either version 2 of the License, or
9
* (at your option) any later version.
11
* This program is distributed in the hope that it will be useful,
12
* but WITHOUT ANY WARRANTY; without even the implied warranty of
13
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
* GNU General Public License for more details.
16
* You should have received a copy of the GNU General Public License
17
* along with this program; if not, write to the Free Software
18
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
23
#include "drizzled/session.h"
24
#include "drizzled/user_var_entry.h"
25
#include "drizzled/plugin/client/concurrent.h"
26
#include "drizzled/execute.h"
31
Execute::Execute(Session &arg, bool wait_arg) :
41
void Execute::run(const char *arg, size_t length)
43
std::string execution_string(arg, length);
44
run(execution_string);
47
void Execute::run(std::string &execution_string)
49
boost_thread_shared_ptr thread;
51
if (_session.isConcurrentExecuteAllowed())
53
plugin::client::Concurrent *client= new plugin::client::Concurrent;
54
client->pushSQL(execution_string);
55
Session::shared_ptr new_session(new Session(client));
57
// We set the current schema. @todo do the same with catalog
58
util::string::const_shared_ptr schema(_session.schema());
59
if (not schema->empty())
60
new_session->set_db(*schema);
62
new_session->setConcurrentExecute(false);
64
// Overwrite the context in the next session, with what we have in our
65
// session. Eventually we will allow someone to change the effective
67
new_session->getSecurityContext()= _session.getSecurityContext();
69
if (Session::schedule(new_session))
71
Session::unlink(new_session);
75
thread= new_session->getThread();
80
my_error(ER_WRONG_ARGUMENTS, MYF(0), "A Concurrent Execution Session can not launch another session.");
84
if (wait && thread && thread->joinable())
86
// We want to make sure that we can be killed
87
boost::this_thread::restore_interruption dl(_session.getThreadInterupt());
91
catch(boost::thread_interrupted const&)
93
// Just surpress and return the error
94
my_error(drizzled::ER_QUERY_INTERRUPTED, MYF(0));
101
} /* namespace drizzled */