~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/statement/execute.cc

  • Committer: Brian Aker
  • Date: 2010-12-08 02:27:22 UTC
  • mto: This revision was merged to the branch mainline in revision 1987.
  • Revision ID: brian@tangent.org-20101208022722-jm5yy7tmhat6w53n
Adding execute command to go along with main command.

Show diffs side-by-side

added added

removed removed

Lines of Context:
22
22
 
23
23
#include "drizzled/statement/execute.h"
24
24
#include "drizzled/session.h"
 
25
#include "drizzled/execute.h"
25
26
#include "drizzled/user_var_entry.h"
26
27
#include "drizzled/plugin/listen.h"
27
28
#include "drizzled/plugin/client.h"
114
115
 
115
116
  if (is_concurrent)
116
117
  {
117
 
    boost_thread_shared_ptr thread;
118
 
 
119
 
    if (getSession()->isConcurrentExecuteAllowed())
120
 
    {
121
 
      plugin::client::Concurrent *client= new plugin::client::Concurrent;
122
 
      std::string execution_string(to_execute.str, to_execute.length);
123
 
      client->pushSQL(execution_string);
124
 
      Session::shared_ptr new_session(new Session(client));
125
 
 
126
 
      // We set the current schema.  @todo do the same with catalog
127
 
      util::string::const_shared_ptr schema(getSession()->schema());
128
 
      if (not schema->empty())
129
 
        new_session->set_db(*schema);
130
 
 
131
 
      new_session->setConcurrentExecute(false);
132
 
 
133
 
      // Overwrite the context in the next session, with what we have in our
134
 
      // session. Eventually we will allow someone to change the effective
135
 
      // user.
136
 
      new_session->getSecurityContext()= getSession()->getSecurityContext();
137
 
 
138
 
      if (Session::schedule(new_session))
139
 
      {
140
 
        Session::unlink(new_session);
141
 
      }
142
 
      else if (should_wait)
143
 
      {
144
 
        thread= new_session->getThread();
145
 
      }
146
 
    }
147
 
    else
 
118
    if (not getSession()->isConcurrentExecuteAllowed())
148
119
    {
149
120
      my_error(ER_WRONG_ARGUMENTS, MYF(0), "A Concurrent Execution Session can not launch another session.");
150
121
      return false;
151
122
    }
152
123
 
153
 
    if (should_wait && thread && thread->joinable())
154
 
    {
155
 
      // We want to make sure that we can be killed
156
 
      boost::this_thread::restore_interruption dl(getSession()->getThreadInterupt());
157
 
      try {
158
 
        thread->join();
159
 
      }
160
 
      catch(boost::thread_interrupted const&)
161
 
      {
162
 
        // Just surpress and return the error
163
 
        my_error(drizzled::ER_QUERY_INTERRUPTED, MYF(0));
164
 
 
165
 
        return false;
166
 
      }
167
 
    }
 
124
    drizzled::Execute executer(*getSession(), should_wait);
 
125
    executer.run(to_execute.str, to_execute.length);
168
126
  }
169
 
  else 
 
127
  else // Non-concurrent run.
170
128
  {
171
129
    if (is_quiet)
172
130
    {