~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/statement/execute.cc

Refactor

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/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>
 
31
#include <drizzled/sql_lex.h>
31
32
 
32
33
namespace drizzled
33
34
{
34
35
 
35
 
void mysql_parse(drizzled::Session *session, const char *inBuf, uint32_t length);
 
36
void parse(drizzled::Session *session, const char *inBuf, uint32_t length);
36
37
 
37
38
namespace statement
38
39
{
55
56
{
56
57
  if (to_execute.isVariable())
57
58
  {
58
 
    user_var_entry *var= getSession()->getVariable(to_execute, false);
 
59
    user_var_entry *var= session().getVariable(to_execute, false);
59
60
 
60
61
    if (var && var->length && var->value && var->type == STRING_RESULT)
61
62
    {
75
76
bool statement::Execute::runStatement(plugin::NullClient *client, const std::string &arg)
76
77
{
77
78
  client->pushSQL(arg);
78
 
  if (not getSession()->executeStatement())
 
79
  if (not session().executeStatement())
79
80
    return true;
80
81
 
81
 
  if (getSession()->is_error())
 
82
  if (session().is_error())
82
83
    return true;
83
84
 
84
85
  return false;
90
91
  bool ret= execute_shell();
91
92
 
92
93
  // We have to restore ourselves at the top for delete() to work.
93
 
  getSession()->getLex()->statement= this;
 
94
  lex().statement= this;
94
95
 
95
96
  return ret;
96
97
}
115
116
 
116
117
  if (is_concurrent)
117
118
  {
118
 
    if (not getSession()->isConcurrentExecuteAllowed())
 
119
    if (not session().isConcurrentExecuteAllowed())
119
120
    {
120
121
      my_error(ER_WRONG_ARGUMENTS, MYF(0), "A Concurrent Execution Session can not launch another session.");
121
122
      return false;
122
123
    }
123
124
 
124
 
    drizzled::Execute executer(*getSession(), should_wait);
 
125
    drizzled::Execute executer(session(), should_wait);
125
126
    executer.run(to_execute.str, to_execute.length);
126
127
  }
127
128
  else // Non-concurrent run.
128
129
  {
129
130
    if (is_quiet)
130
131
    {
131
 
      plugin::Client *temp= getSession()->getClient();
 
132
      plugin::Client *temp= session().getClient();
132
133
      plugin::NullClient *null_client= new plugin::NullClient;
133
134
 
134
 
      getSession()->setClient(null_client);
 
135
      session().setClient(null_client);
135
136
      
136
137
      bool error_occured= false;
137
138
      bool is_savepoint= false;
138
139
      {
139
140
        std::string start_sql;
140
 
        if (getSession()->inTransaction())
 
141
        if (session().inTransaction())
141
142
        {
142
143
          // @todo Figure out something a bit more solid then this.
143
144
          start_sql.append("SAVEPOINT execute_internal_savepoint");
160
161
        Tokenizer tok(full_string, boost::escaped_list_separator<char>("\\", ";", "\""));
161
162
 
162
163
        for (Tokenizer::iterator iter= tok.begin();
163
 
             iter != tok.end() and getSession()->getKilled() != Session::KILL_CONNECTION;
 
164
             iter != tok.end() and session().getKilled() != Session::KILL_CONNECTION;
164
165
             ++iter)
165
166
        {
166
167
          if (runStatement(null_client, *iter))
202
203
        }
203
204
      }
204
205
 
205
 
      getSession()->setClient(temp);
206
 
      if (getSession()->is_error())
 
206
      session().setClient(temp);
 
207
      if (session().is_error())
207
208
      {
208
 
        getSession()->clear_error(true);
 
209
        session().clear_error(true);
209
210
      }
210
211
      else
211
212
      {
212
 
        getSession()->clearDiagnostics();
 
213
        session().clearDiagnostics();
213
214
      }
214
215
 
215
 
      getSession()->my_ok();
 
216
      session().my_ok();
216
217
 
217
218
      null_client->close();
218
219
      delete null_client;
219
220
    }
220
221
    else
221
222
    {
222
 
      mysql_parse(getSession(), to_execute.str, to_execute.length);
 
223
      parse(&session(), to_execute.str, to_execute.length);
223
224
    }
224
225
  }
225
226