~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/statement/execute.cc

  • Committer: Brian Aker
  • Date: 2010-11-19 00:00:46 UTC
  • mto: (1945.2.1 quick)
  • mto: This revision was merged to the branch mainline in revision 1944.
  • Revision ID: brian@tangent.org-20101119000046-iajnd847tmo595ts
Fix style issue around table for message (though this is imperfect,...)

Show diffs side-by-side

added added

removed removed

Lines of Context:
18
18
 *  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
19
19
 */
20
20
 
21
 
#include <config.h>
 
21
#include "config.h"
22
22
 
23
 
#include <drizzled/statement/execute.h>
24
 
#include <drizzled/session.h>
25
 
#include <drizzled/execute.h>
26
 
#include <drizzled/user_var_entry.h>
27
 
#include <drizzled/plugin/listen.h>
28
 
#include <drizzled/plugin/client.h>
29
 
#include <drizzled/plugin/null_client.h>
30
 
#include <drizzled/plugin/client/concurrent.h>
 
23
#include "drizzled/statement/execute.h"
 
24
#include "drizzled/session.h"
 
25
#include "drizzled/user_var_entry.h"
 
26
#include "drizzled/plugin/listen.h"
 
27
#include "drizzled/plugin/client.h"
 
28
#include "drizzled/plugin/null_client.h"
 
29
#include "drizzled/plugin/client/concurrent.h"
31
30
 
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
{
40
39
Execute::Execute(Session *in_session,
41
40
                 drizzled::execute_string_t to_execute_arg,
42
41
                 bool is_quiet_arg,
43
 
                 bool is_concurrent_arg,
44
 
                 bool should_wait_arg) :
 
42
                 bool is_concurrent_arg) :
45
43
  Statement(in_session),
46
44
  is_quiet(is_quiet_arg),
47
45
  is_concurrent(is_concurrent_arg),
48
 
  should_wait(should_wait_arg),
49
46
  to_execute(to_execute_arg)
50
47
{
51
48
}
87
84
 
88
85
bool statement::Execute::execute()
89
86
{
90
 
  bool ret= execute_shell();
91
 
 
92
 
  // We have to restore ourselves at the top for delete() to work.
93
 
  getSession()->getLex()->statement= this;
94
 
 
95
 
  return ret;
96
 
}
97
 
 
98
 
 
99
 
bool statement::Execute::execute_shell()
100
 
{
101
87
  if (to_execute.length == 0)
102
88
  {
103
89
    my_error(ER_WRONG_ARGUMENTS, MYF(0), "Invalid Variable");
104
90
    return false;
105
91
  }
106
 
 
107
92
  if (to_execute.isVariable())
108
93
  {
109
94
    if (not parseVariable())
115
100
 
116
101
  if (is_concurrent)
117
102
  {
118
 
    if (not getSession()->isConcurrentExecuteAllowed())
 
103
    if (getSession()->isConcurrentExecuteAllowed())
 
104
    {
 
105
      plugin::client::Concurrent *client= new plugin::client::Concurrent;
 
106
      std::string execution_string(to_execute.str, to_execute.length);
 
107
      client->pushSQL(execution_string);
 
108
      Session::shared_ptr new_session(new Session(client));
 
109
 
 
110
      // We set the current schema.  @todo do the same with catalog
 
111
      if (not getSession()->getSchema().empty())
 
112
        new_session->set_db(getSession()->getSchema());
 
113
 
 
114
      new_session->setConcurrentExecute(false);
 
115
 
 
116
      // Overwrite the context in the next session, with what we have in our
 
117
      // session. Eventually we will allow someone to change the effective
 
118
      // user.
 
119
      new_session->getSecurityContext()= getSession()->getSecurityContext();
 
120
 
 
121
      if (Session::schedule(new_session))
 
122
        Session::unlink(new_session);
 
123
    }
 
124
    else
119
125
    {
120
126
      my_error(ER_WRONG_ARGUMENTS, MYF(0), "A Concurrent Execution Session can not launch another session.");
121
127
      return false;
122
128
    }
123
 
 
124
 
    drizzled::Execute executer(*getSession(), should_wait);
125
 
    executer.run(to_execute.str, to_execute.length);
126
129
  }
127
 
  else // Non-concurrent run.
 
130
  else 
128
131
  {
129
132
    if (is_quiet)
130
133
    {
219
222
    }
220
223
    else
221
224
    {
222
 
      parse(getSession(), to_execute.str, to_execute.length);
 
225
      mysql_parse(getSession(), to_execute.str, to_execute.length);
223
226
    }
224
227
  }
225
228
 
 
229
 
 
230
  // We have to restore ourselves at the top for delete() to work.
 
231
  getSession()->getLex()->statement= this;
 
232
 
226
233
  return true;
227
234
}
228
235