18
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/catalog/local.h"
27
#include "drizzled/execute.h"
23
#include <drizzled/session.h>
24
#include <drizzled/user_var_entry.h>
25
#include <drizzled/plugin/client/cached.h>
26
#include <drizzled/plugin/client/concurrent.h>
27
#include <drizzled/catalog/local.h>
28
#include <drizzled/execute.h>
32
32
Execute::Execute(Session &arg, bool wait_arg) :
42
38
void Execute::run(const char *arg, size_t length)
44
std::string execution_string(arg, length);
45
run(execution_string);
48
void Execute::run(std::string &execution_string)
50
boost_thread_shared_ptr thread;
52
if (_session.isConcurrentExecuteAllowed())
40
run(std::string(arg, length));
43
void Execute::run(const std::string &execution_string, sql::ResultSet &result_set)
45
if (not _session.isConcurrentExecuteAllowed())
47
my_error(ER_WRONG_ARGUMENTS, MYF(0), "A Concurrent Execution Session can not launch another session.");
52
plugin::client::Cached *client= new plugin::client::Cached(result_set);
53
client->pushSQL(execution_string);
54
Session::shared_ptr new_session= Session::make_shared(client, catalog::local());
56
// We set the current schema. @todo do the same with catalog
57
util::string::ptr schema(_session.schema());
58
if (not schema->empty())
59
new_session->set_db(*schema);
61
new_session->setConcurrentExecute(false);
63
// Overwrite the context in the next session, with what we have in our
64
// session. Eventually we will allow someone to change the effective
66
new_session->user()= _session.user();
67
new_session->setOriginatingServerUUID(_session.getOriginatingServerUUID());
68
new_session->setOriginatingCommitID(_session.getOriginatingCommitID());
70
if (Session::schedule(new_session))
72
Session::unlink(new_session);
76
thread= new_session->getThread();
80
if (wait && thread && thread->joinable())
82
// We want to make sure that we can be killed
83
if (_session.getThread())
85
boost::this_thread::restore_interruption dl(_session.getThreadInterupt());
90
catch(boost::thread_interrupted const&)
92
// Just surpress and return the error
93
my_error(drizzled::ER_QUERY_INTERRUPTED, MYF(0));
104
void Execute::run(const std::string &execution_string)
106
if (not _session.isConcurrentExecuteAllowed())
108
my_error(ER_WRONG_ARGUMENTS, MYF(0), "A Concurrent Execution Session can not launch another session.");
54
113
plugin::client::Concurrent *client= new plugin::client::Concurrent;
55
114
client->pushSQL(execution_string);
56
115
Session::shared_ptr new_session= Session::make_shared(client, catalog::local());
58
117
// We set the current schema. @todo do the same with catalog
59
util::string::const_shared_ptr schema(_session.schema());
118
util::string::ptr schema(_session.schema());
60
119
if (not schema->empty())
61
120
new_session->set_db(*schema);