~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/statement/execute.cc

  • Committer: Brian Aker
  • Date: 2011-09-26 15:02:54 UTC
  • mto: This revision was merged to the branch mainline in revision 2427.
  • Revision ID: brian@tangent.org-20110926150254-zpi0gifzexj2crdt
Wrap thread specfic

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