~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/execute.cc

  • Committer: Brian Aker
  • Date: 2011-02-25 17:02:30 UTC
  • mfrom: (2116.1.55 slave)
  • Revision ID: brian@tangent.org-20110225170230-zj0h32xlmr42ly2z
Merge in David's slave work

Show diffs side-by-side

added added

removed removed

Lines of Context:
22
22
 
23
23
#include <drizzled/session.h>
24
24
#include <drizzled/user_var_entry.h>
 
25
#include <drizzled/plugin/client/cached.h>
25
26
#include <drizzled/plugin/client/concurrent.h>
26
27
#include <drizzled/catalog/local.h>
27
28
#include <drizzled/execute.h>
45
46
  run(execution_string);
46
47
}
47
48
 
 
49
void Execute::run(std::string &execution_string, sql::ResultSet &result_set)
 
50
{
 
51
  boost_thread_shared_ptr thread;
 
52
  
 
53
  if (_session.isConcurrentExecuteAllowed())
 
54
  {
 
55
    plugin::client::Cached *client= new plugin::client::Cached(result_set);
 
56
    client->pushSQL(execution_string);
 
57
    Session::shared_ptr new_session= Session::make_shared(client, catalog::local());
 
58
    
 
59
    // We set the current schema.  @todo do the same with catalog
 
60
    util::string::const_shared_ptr schema(_session.schema());
 
61
    if (not schema->empty())
 
62
      new_session->set_db(*schema);
 
63
    
 
64
    new_session->setConcurrentExecute(false);
 
65
    
 
66
    // Overwrite the context in the next session, with what we have in our
 
67
    // session. Eventually we will allow someone to change the effective
 
68
    // user.
 
69
    new_session->user()= _session.user();
 
70
    
 
71
    if (Session::schedule(new_session))
 
72
    {
 
73
      Session::unlink(new_session);
 
74
    }
 
75
    else if (wait)
 
76
    {
 
77
      thread= new_session->getThread();
 
78
    }
 
79
  }
 
80
  else
 
81
  {
 
82
    my_error(ER_WRONG_ARGUMENTS, MYF(0), "A Concurrent Execution Session can not launch another session.");
 
83
    return;
 
84
  }
 
85
  
 
86
  if (wait && thread && thread->joinable())
 
87
  {
 
88
    // We want to make sure that we can be killed
 
89
    if (_session.getThread())
 
90
    {
 
91
      boost::this_thread::restore_interruption dl(_session.getThreadInterupt());
 
92
      
 
93
      try {
 
94
        thread->join();
 
95
      }
 
96
      catch(boost::thread_interrupted const&)
 
97
      {
 
98
        // Just surpress and return the error
 
99
        my_error(drizzled::ER_QUERY_INTERRUPTED, MYF(0));
 
100
        return;
 
101
      }
 
102
    }
 
103
    else
 
104
    {
 
105
      thread->join();
 
106
    }
 
107
  }
 
108
}
 
109
 
48
110
void Execute::run(std::string &execution_string)
49
111
{
50
112
  boost_thread_shared_ptr thread;