~ubuntu-branches/ubuntu/saucy/drizzle/saucy-proposed

« back to all changes in this revision

Viewing changes to drizzled/execute.cc

  • Committer: Package Import Robot
  • Author(s): Clint Byrum
  • Date: 2012-06-19 10:46:49 UTC
  • mfrom: (1.1.6)
  • mto: This revision was merged to the branch mainline in revision 29.
  • Revision ID: package-import@ubuntu.com-20120619104649-e2l0ggd4oz3um0f4
Tags: upstream-7.1.36-stable
ImportĀ upstreamĀ versionĀ 7.1.36-stable

Show diffs side-by-side

added added

removed removed

Lines of Context:
27
27
#include <drizzled/catalog/local.h>
28
28
#include <drizzled/execute.h>
29
29
 
30
 
namespace drizzled
31
 
{
 
30
namespace drizzled {
32
31
 
33
32
Execute::Execute(Session &arg, bool wait_arg) :
34
33
  wait(wait_arg),
36
35
{
37
36
}
38
37
 
39
 
Execute::~Execute()
40
 
{
41
 
}
42
 
 
43
 
void Execute::run(const char *arg, size_t length)
44
 
{
45
 
  std::string execution_string(arg, length);
46
 
  run(execution_string);
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())
 
38
void Execute::run(str_ref execution_string, sql::ResultSet &result_set)
 
39
{
 
40
  if (not _session.isConcurrentExecuteAllowed())
 
41
  {
 
42
    my_error(ER_WRONG_ARGUMENTS, MYF(0), "A Concurrent Execution Session can not launch another session.");
 
43
    return;
 
44
  }
 
45
  thread_ptr thread;
54
46
  {
55
47
    plugin::client::Cached *client= new plugin::client::Cached(result_set);
56
48
    client->pushSQL(execution_string);
57
49
    Session::shared_ptr new_session= Session::make_shared(client, catalog::local());
58
50
    
59
51
    // We set the current schema.  @todo do the same with catalog
60
 
    util::string::const_shared_ptr schema(_session.schema());
 
52
    util::string::ptr schema(_session.schema());
61
53
    if (not schema->empty())
62
 
      new_session->set_db(*schema);
 
54
      new_session->set_schema(*schema);
63
55
    
64
56
    new_session->setConcurrentExecute(false);
65
57
    
67
59
    // session. Eventually we will allow someone to change the effective
68
60
    // user.
69
61
    new_session->user()= _session.user();
 
62
    new_session->setOriginatingServerUUID(_session.getOriginatingServerUUID());
 
63
    new_session->setOriginatingCommitID(_session.getOriginatingCommitID());
70
64
    
71
65
    if (Session::schedule(new_session))
72
66
    {
77
71
      thread= new_session->getThread();
78
72
    }
79
73
  }
80
 
  else
81
 
  {
82
 
    my_error(ER_WRONG_ARGUMENTS, MYF(0), "A Concurrent Execution Session can not launch another session.");
83
 
    return;
84
 
  }
85
74
  
86
75
  if (wait && thread && thread->joinable())
87
76
  {
90
79
    {
91
80
      boost::this_thread::restore_interruption dl(_session.getThreadInterupt());
92
81
      
93
 
      try {
 
82
      try 
 
83
      {
94
84
        thread->join();
95
85
      }
96
86
      catch(boost::thread_interrupted const&)
107
97
  }
108
98
}
109
99
 
110
 
void Execute::run(std::string &execution_string)
 
100
void Execute::run(str_ref execution_string)
111
101
{
112
 
  boost_thread_shared_ptr thread;
113
 
 
114
 
  if (_session.isConcurrentExecuteAllowed())
 
102
  if (not _session.isConcurrentExecuteAllowed())
 
103
  {
 
104
    my_error(ER_WRONG_ARGUMENTS, MYF(0), "A Concurrent Execution Session can not launch another session.");
 
105
    return;
 
106
  }
 
107
  thread_ptr thread;
115
108
  {
116
109
    plugin::client::Concurrent *client= new plugin::client::Concurrent;
117
110
    client->pushSQL(execution_string);
118
111
    Session::shared_ptr new_session= Session::make_shared(client, catalog::local());
119
112
 
120
113
    // We set the current schema.  @todo do the same with catalog
121
 
    util::string::const_shared_ptr schema(_session.schema());
 
114
    util::string::ptr schema(_session.schema());
122
115
    if (not schema->empty())
123
 
      new_session->set_db(*schema);
 
116
      new_session->set_schema(*schema);
124
117
 
125
118
    new_session->setConcurrentExecute(false);
126
119
 
138
131
      thread= new_session->getThread();
139
132
    }
140
133
  }
141
 
  else
142
 
  {
143
 
    my_error(ER_WRONG_ARGUMENTS, MYF(0), "A Concurrent Execution Session can not launch another session.");
144
 
    return;
145
 
  }
146
134
 
147
135
  if (wait && thread && thread->joinable())
148
136
  {
151
139
    {
152
140
      boost::this_thread::restore_interruption dl(_session.getThreadInterupt());
153
141
 
154
 
      try {
 
142
      try 
 
143
      {
155
144
        thread->join();
156
145
      }
157
146
      catch(boost::thread_interrupted const&)