~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/statement/execute.cc

  • Committer: Brian Aker
  • Date: 2010-11-11 23:42:09 UTC
  • mto: (1932.2.1 trunk)
  • mto: This revision was merged to the branch mainline in revision 1930.
  • Revision ID: brian@tangent.org-20101111234209-u3j07lya1dhcon45
Adding in concurrent execute support.

Show diffs side-by-side

added added

removed removed

Lines of Context:
25
25
#include "drizzled/user_var_entry.h"
26
26
#include "drizzled/plugin/listen.h"
27
27
#include "drizzled/plugin/client.h"
 
28
#include "drizzled/plugin/null_client.h"
28
29
 
29
30
namespace drizzled
30
31
{
34
35
namespace statement
35
36
{
36
37
 
37
 
Execute::Execute(Session *in_session, drizzled::execute_string_t to_execute_arg, bool is_quiet_arg) :
 
38
Execute::Execute(Session *in_session,
 
39
                 drizzled::execute_string_t to_execute_arg,
 
40
                 bool is_quiet_arg,
 
41
                 bool is_concurrent_arg) :
38
42
  Statement(in_session),
39
43
  is_quiet(is_quiet_arg),
 
44
  is_concurrent(is_concurrent_arg),
40
45
  to_execute(to_execute_arg)
41
46
{
42
47
}
77
82
    }
78
83
  }
79
84
 
80
 
  if (is_quiet)
 
85
  if (is_concurrent)
81
86
  {
82
 
    plugin::Client *temp= getSession()->getClient();
83
 
    plugin::Client *null_client= plugin::Listen::getNullClient();
84
 
 
85
 
    getSession()->setClient(null_client);
86
 
 
87
 
    mysql_parse(getSession(), to_execute.str, to_execute.length);
88
 
 
89
 
    getSession()->setClient(temp);
90
 
    if (getSession()->is_error())
91
 
    {
92
 
      getSession()->clear_error(true);
93
 
      getSession()->my_ok();
94
 
    }
95
 
    null_client->close();
96
 
    delete null_client;
 
87
 
 
88
    if (getSession()->isConcurrentExecuteAllowed())
 
89
    {
 
90
      plugin::NullClient *null_client= new plugin::NullClient;
 
91
      null_client->pushSQL(std::string(to_execute.str, to_execute.length));
 
92
      Session *new_session= new Session(null_client);
 
93
 
 
94
      new_session->setConcurrentExecute(false);
 
95
 
 
96
      // Overwrite the context in the next session, with what we have in our
 
97
      // session. Eventually we will allow someone to change the effective
 
98
      // user.
 
99
      new_session->getSecurityContext()= getSession()->getSecurityContext();
 
100
 
 
101
      if (new_session->schedule())
 
102
        Session::unlink(new_session);
 
103
    }
 
104
    else
 
105
    {
 
106
      my_error(ER_WRONG_ARGUMENTS, MYF(0), "A Concurrent Execution Session can not launch another session.");
 
107
      return false;
 
108
    }
97
109
  }
98
 
  else
 
110
  else 
99
111
  {
100
 
    mysql_parse(getSession(), to_execute.str, to_execute.length);
 
112
    if (is_quiet)
 
113
    {
 
114
      plugin::Client *temp= getSession()->getClient();
 
115
      plugin::Client *null_client= plugin::Listen::getNullClient();
 
116
 
 
117
      getSession()->setClient(null_client);
 
118
 
 
119
      mysql_parse(getSession(), to_execute.str, to_execute.length);
 
120
 
 
121
      getSession()->setClient(temp);
 
122
      if (getSession()->is_error())
 
123
      {
 
124
        getSession()->clear_error(true);
 
125
        getSession()->my_ok();
 
126
      }
 
127
      null_client->close();
 
128
      delete null_client;
 
129
    }
 
130
    else
 
131
    {
 
132
      mysql_parse(getSession(), to_execute.str, to_execute.length);
 
133
    }
101
134
  }
102
135
 
103
136