~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/statement/execute.cc

  • Committer: Lee Bieber
  • Date: 2010-12-02 18:56:33 UTC
  • mfrom: (1966.3.1 bug683842)
  • mto: This revision was merged to the branch mainline in revision 1969.
  • Revision ID: kalebral@gmail.com-20101202185633-e27o1zhpev18dlsn
Merge Monty - fix bug 683842: remove generic catch blocks       

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"
26
25
#include "drizzled/user_var_entry.h"
27
26
#include "drizzled/plugin/listen.h"
28
27
#include "drizzled/plugin/client.h"
32
31
namespace drizzled
33
32
{
34
33
 
35
 
void parse(drizzled::Session *session, const char *inBuf, uint32_t length);
 
34
void mysql_parse(drizzled::Session *session, const char *inBuf, uint32_t length);
36
35
 
37
36
namespace statement
38
37
{
115
114
 
116
115
  if (is_concurrent)
117
116
  {
118
 
    if (not getSession()->isConcurrentExecuteAllowed())
 
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
      if (not getSession()->getSchema().empty())
 
128
        new_session->set_db(getSession()->getSchema());
 
129
 
 
130
      new_session->setConcurrentExecute(false);
 
131
 
 
132
      // Overwrite the context in the next session, with what we have in our
 
133
      // session. Eventually we will allow someone to change the effective
 
134
      // user.
 
135
      new_session->getSecurityContext()= getSession()->getSecurityContext();
 
136
 
 
137
      if (Session::schedule(new_session))
 
138
      {
 
139
        Session::unlink(new_session);
 
140
      }
 
141
      else if (should_wait)
 
142
      {
 
143
        thread= new_session->getThread();
 
144
      }
 
145
    }
 
146
    else
119
147
    {
120
148
      my_error(ER_WRONG_ARGUMENTS, MYF(0), "A Concurrent Execution Session can not launch another session.");
121
149
      return false;
122
150
    }
123
151
 
124
 
    drizzled::Execute executer(*getSession(), should_wait);
125
 
    executer.run(to_execute.str, to_execute.length);
 
152
    if (should_wait && thread && thread->joinable())
 
153
    {
 
154
      // We want to make sure that we can be killed
 
155
      boost::this_thread::restore_interruption dl(getSession()->getThreadInterupt());
 
156
      try {
 
157
        thread->join();
 
158
      }
 
159
      catch(boost::thread_interrupted const&)
 
160
      {
 
161
        // Just surpress and return the error
 
162
        my_error(drizzled::ER_QUERY_INTERRUPTED, MYF(0));
 
163
 
 
164
        return false;
 
165
      }
 
166
    }
126
167
  }
127
 
  else // Non-concurrent run.
 
168
  else 
128
169
  {
129
170
    if (is_quiet)
130
171
    {
219
260
    }
220
261
    else
221
262
    {
222
 
      parse(getSession(), to_execute.str, to_execute.length);
 
263
      mysql_parse(getSession(), to_execute.str, to_execute.length);
223
264
    }
224
265
  }
225
266