~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-10-14 07:28:20 UTC
  • mfrom: (2436 drizzle)
  • mto: This revision was merged to the branch mainline in revision 2438.
  • Revision ID: olafvdspek@gmail.com-20111014072820-nic6rljx3sg6bl9t
Merge trunk

Show diffs side-by-side

added added

removed removed

Lines of Context:
59
59
    if (var && var->length && var->value && var->type == STRING_RESULT)
60
60
    {
61
61
      lex_string_t tmp_for_var;
62
 
      tmp_for_var.str= var->value; 
63
 
      tmp_for_var.length= var->length; 
 
62
      tmp_for_var.assign(var->value, var->length); 
64
63
      to_execute.set(tmp_for_var);
65
64
 
66
65
      return true;
71
70
}
72
71
 
73
72
 
74
 
bool statement::Execute::runStatement(plugin::NullClient *client, const std::string &arg)
 
73
bool statement::Execute::runStatement(plugin::NullClient& client, const std::string &arg)
75
74
{
76
 
  client->pushSQL(arg);
 
75
  client.pushSQL(arg);
77
76
  if (not session().executeStatement())
78
77
    return true;
79
78
 
128
127
    if (is_quiet)
129
128
    {
130
129
      plugin::Client *temp= session().getClient();
131
 
      plugin::NullClient *null_client= new plugin::NullClient;
 
130
      boost::scoped_ptr<plugin::NullClient> null_client(new plugin::NullClient);
132
131
 
133
 
      session().setClient(null_client);
 
132
      session().setClient(null_client.get());
134
133
      
135
134
      bool error_occured= false;
136
135
      bool is_savepoint= false;
147
146
          start_sql.append("START TRANSACTION");
148
147
        }
149
148
 
150
 
        error_occured= runStatement(null_client, start_sql);
 
149
        error_occured= runStatement(*null_client, start_sql);
151
150
      }
152
151
 
153
152
      // @note this is copied from code in NULL client, all of this belongs
155
154
      if (not error_occured)
156
155
      {
157
156
        typedef boost::tokenizer<boost::escaped_list_separator<char> > Tokenizer;
158
 
        std::string full_string(to_execute.str, to_execute.length);
 
157
        std::string full_string(to_execute.data(), to_execute.size());
159
158
        Tokenizer tok(full_string, boost::escaped_list_separator<char>("\\", ";", "\""));
160
159
 
161
 
        for (Tokenizer::iterator iter= tok.begin();
162
 
             iter != tok.end() and session().getKilled() != Session::KILL_CONNECTION;
163
 
             ++iter)
 
160
        for (Tokenizer::iterator iter= tok.begin(); iter != tok.end(); ++iter)
164
161
        {
165
 
          if (runStatement(null_client, *iter))
 
162
          if (session().getKilled() == Session::KILL_CONNECTION)
 
163
            break;
 
164
          if (runStatement(*null_client, *iter))
166
165
          {
167
166
            error_occured= true;
168
167
            break;
174
173
          std::string final_sql;
175
174
          if (is_savepoint)
176
175
          {
177
 
            final_sql.append(error_occured ? 
 
176
            final_sql= error_occured ? 
178
177
              "ROLLBACK TO SAVEPOINT execute_internal_savepoint" : 
179
 
              "RELEASE SAVEPOINT execute_internal_savepoint");
 
178
              "RELEASE SAVEPOINT execute_internal_savepoint";
180
179
          }
181
180
          else
182
181
          {
183
 
            final_sql.append(error_occured ? "ROLLBACK" : "COMMIT");
 
182
            final_sql= error_occured ? "ROLLBACK" : "COMMIT";
184
183
          }
185
184
 
186
185
          // Run the cleanup command, we currently ignore if an error occurs
187
186
          // here.
188
 
          (void)runStatement(null_client, final_sql);
 
187
          (void)runStatement(*null_client, final_sql);
189
188
        }
190
189
      }
191
190
 
202
201
      session().my_ok();
203
202
 
204
203
      null_client->close();
205
 
      delete null_client;
206
204
    }
207
205
    else
208
206
    {
209
 
      parse(session(), to_execute.str, to_execute.length);
 
207
      parse(session(), to_execute.data(), to_execute.size());
210
208
    }
211
209
  }
212
210