~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/statement/execute.cc

  • Committer: Olaf van der Spek
  • Date: 2011-07-04 19:11:47 UTC
  • mto: This revision was merged to the branch mainline in revision 2367.
  • Revision ID: olafvdspek@gmail.com-20110704191147-s99ojek811zi1fzj
Remove unused Name_resolution_context::error_reporter

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"
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"
31
 
 
32
 
namespace drizzled
33
 
{
34
 
 
35
 
void parse(drizzled::Session *session, const char *inBuf, uint32_t length);
36
 
 
37
 
namespace statement
38
 
{
 
21
#include <config.h>
 
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>
 
31
#include <drizzled/sql_lex.h>
 
32
 
 
33
namespace drizzled {
 
34
 
 
35
void parse(drizzled::Session&, const char *inBuf, uint32_t length);
 
36
 
 
37
namespace statement {
39
38
 
40
39
Execute::Execute(Session *in_session,
41
40
                 drizzled::execute_string_t to_execute_arg,
55
54
{
56
55
  if (to_execute.isVariable())
57
56
  {
58
 
    user_var_entry *var= getSession()->getVariable(to_execute, false);
 
57
    user_var_entry *var= session().getVariable(to_execute, false);
59
58
 
60
59
    if (var && var->length && var->value && var->type == STRING_RESULT)
61
60
    {
75
74
bool statement::Execute::runStatement(plugin::NullClient *client, const std::string &arg)
76
75
{
77
76
  client->pushSQL(arg);
78
 
  if (not getSession()->executeStatement())
 
77
  if (not session().executeStatement())
79
78
    return true;
80
79
 
81
 
  if (getSession()->is_error())
 
80
  if (session().is_error())
82
81
    return true;
83
82
 
84
83
  return false;
90
89
  bool ret= execute_shell();
91
90
 
92
91
  // We have to restore ourselves at the top for delete() to work.
93
 
  getSession()->getLex()->statement= this;
 
92
  lex().statement= this;
94
93
 
95
94
  return ret;
96
95
}
115
114
 
116
115
  if (is_concurrent)
117
116
  {
118
 
    if (not getSession()->isConcurrentExecuteAllowed())
 
117
    if (not session().isConcurrentExecuteAllowed())
119
118
    {
120
119
      my_error(ER_WRONG_ARGUMENTS, MYF(0), "A Concurrent Execution Session can not launch another session.");
121
120
      return false;
122
121
    }
123
122
 
124
 
    drizzled::Execute executer(*getSession(), should_wait);
 
123
    drizzled::Execute executer(session(), should_wait);
125
124
    executer.run(to_execute.str, to_execute.length);
126
125
  }
127
126
  else // Non-concurrent run.
128
127
  {
129
128
    if (is_quiet)
130
129
    {
131
 
      plugin::Client *temp= getSession()->getClient();
 
130
      plugin::Client *temp= session().getClient();
132
131
      plugin::NullClient *null_client= new plugin::NullClient;
133
132
 
134
 
      getSession()->setClient(null_client);
 
133
      session().setClient(null_client);
135
134
      
136
135
      bool error_occured= false;
137
136
      bool is_savepoint= false;
138
137
      {
139
138
        std::string start_sql;
140
 
        if (getSession()->inTransaction())
 
139
        if (session().inTransaction())
141
140
        {
142
141
          // @todo Figure out something a bit more solid then this.
143
142
          start_sql.append("SAVEPOINT execute_internal_savepoint");
160
159
        Tokenizer tok(full_string, boost::escaped_list_separator<char>("\\", ";", "\""));
161
160
 
162
161
        for (Tokenizer::iterator iter= tok.begin();
163
 
             iter != tok.end() and getSession()->getKilled() != Session::KILL_CONNECTION;
 
162
             iter != tok.end() and session().getKilled() != Session::KILL_CONNECTION;
164
163
             ++iter)
165
164
        {
166
165
          if (runStatement(null_client, *iter))
175
174
          std::string final_sql;
176
175
          if (is_savepoint)
177
176
          {
178
 
            if (error_occured)
179
 
            {
180
 
              final_sql.append("ROLLBACK TO SAVEPOINT execute_internal_savepoint");
181
 
            }
182
 
            else
183
 
            {
184
 
              final_sql.append("RELEASE SAVEPOINT execute_internal_savepoint");
185
 
            }
 
177
            final_sql.append(error_occured ? 
 
178
              "ROLLBACK TO SAVEPOINT execute_internal_savepoint" : 
 
179
              "RELEASE SAVEPOINT execute_internal_savepoint");
186
180
          }
187
181
          else
188
182
          {
189
 
            if (error_occured)
190
 
            {
191
 
              final_sql.append("ROLLBACK");
192
 
            }
193
 
            else
194
 
            {
195
 
              final_sql.append("COMMIT");
196
 
            }
 
183
            final_sql.append(error_occured ? "ROLLBACK" : "COMMIT");
197
184
          }
198
185
 
199
186
          // Run the cleanup command, we currently ignore if an error occurs
202
189
        }
203
190
      }
204
191
 
205
 
      getSession()->setClient(temp);
206
 
      if (getSession()->is_error())
 
192
      session().setClient(temp);
 
193
      if (session().is_error())
207
194
      {
208
 
        getSession()->clear_error(true);
 
195
        session().clear_error(true);
209
196
      }
210
197
      else
211
198
      {
212
 
        getSession()->clearDiagnostics();
 
199
        session().clearDiagnostics();
213
200
      }
214
201
 
215
 
      getSession()->my_ok();
 
202
      session().my_ok();
216
203
 
217
204
      null_client->close();
218
205
      delete null_client;
219
206
    }
220
207
    else
221
208
    {
222
 
      parse(getSession(), to_execute.str, to_execute.length);
 
209
      parse(session(), to_execute.str, to_execute.length);
223
210
    }
224
211
  }
225
212