~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/sql_parse.cc

  • Committer: Monty Taylor
  • Date: 2009-04-09 05:35:58 UTC
  • mfrom: (984 merge)
  • mto: (992.1.1 mordred)
  • mto: This revision was merged to the branch mainline in revision 986.
  • Revision ID: mordred@inaugust.com-20090409053558-qi1x0zzsgf1d8f1p
Merged trunk.

Show diffs side-by-side

added added

removed removed

Lines of Context:
147
147
  return (sql_command_flags[command].test(CF_BIT_CHANGES_DATA));
148
148
}
149
149
 
150
 
void execute_init_command(Session *session, sys_var_str *init_command_var,
151
 
                          pthread_rwlock_t *var_mutex)
152
 
{
153
 
  ulong save_client_capabilities;
154
 
 
155
 
  session->set_proc_info("Execution of init_command");
156
 
  /*
157
 
    We need to lock init_command_var because
158
 
    during execution of init_command_var query
159
 
    values of init_command_var can't be changed
160
 
  */
161
 
  pthread_rwlock_rdlock(var_mutex);
162
 
  save_client_capabilities= session->client_capabilities;
163
 
  session->client_capabilities|= CLIENT_MULTI_STATEMENTS;
164
 
  /*
165
 
    We don't need return result of execution to client side.
166
 
  */
167
 
  session->protocol->disable_results();
168
 
  dispatch_command(COM_QUERY, session,
169
 
                   init_command_var->value,
170
 
                   init_command_var->value_length);
171
 
  pthread_rwlock_unlock(var_mutex);
172
 
  session->client_capabilities= save_client_capabilities;
173
 
  session->protocol->enable_results();
174
 
}
175
 
 
176
150
/**
177
151
  Perform one connection-level (COM_XXXX) command.
178
152
 
238
212
  {
239
213
    if (! session->readAndStoreQuery(packet, packet_length))
240
214
      break;                                    // fatal error is set
241
 
    char *packet_end= session->query + session->query_length;
242
215
    const char* end_of_stmt= NULL;
243
216
 
244
217
    mysql_parse(session, session->query, session->query_length, &end_of_stmt);
245
218
 
246
 
    while (!session->killed && (end_of_stmt != NULL) && ! session->is_error())
247
 
    {
248
 
      char *beginning_of_next_stmt= (char*) end_of_stmt;
249
 
 
250
 
      session->protocol->end_statement();
251
 
      /*
252
 
        Multiple queries exits, execute them individually
253
 
      */
254
 
      close_thread_tables(session);
255
 
      ulong length= (ulong)(packet_end - beginning_of_next_stmt);
256
 
 
257
 
      log_slow_statement(session);
258
 
 
259
 
      /* Remove garbage at start of query */
260
 
      while (length > 0 && my_isspace(session->charset(), *beginning_of_next_stmt))
261
 
      {
262
 
        beginning_of_next_stmt++;
263
 
        length--;
264
 
      }
265
 
 
266
 
      /*
267
 
        Count each statement from the client.
268
 
      */
269
 
      statistic_increment(session->status_var.questions, &LOCK_status);
270
 
      session->query_id= query_id.next();
271
 
      session->set_time(); /* Reset the query start time. */
272
 
 
273
 
      session->query_length= length;
274
 
      session->query= beginning_of_next_stmt;
275
 
 
276
 
      strncpy(session->process_list_info, session->query, (length > PROCESS_LIST_WIDTH) ? PROCESS_LIST_WIDTH - 1  : length);
277
 
 
278
 
      /* TODO: set session->lex->sql_command to SQLCOM_END here */
279
 
 
280
 
      mysql_parse(session, beginning_of_next_stmt, length, &end_of_stmt);
281
 
    }
282
219
    break;
283
220
  }
284
221
  case COM_QUIT:
285
222
    /* We don't calculate statistics for this command */
286
 
    session->protocol->set_error(0);
 
223
    session->protocol->setError(0);
287
224
    session->main_da.disable_status();              // Don't send anything back
288
225
    error=true;                                 // End server
289
226
    break;
328
265
    session->mysys_var->abort= 0;
329
266
  }
330
267
 
331
 
  session->protocol->end_statement();
 
268
  /* Can not be true, but do not take chances in production. */
 
269
  assert(! session->main_da.is_sent);
 
270
 
 
271
  switch (session->main_da.status())
 
272
  {
 
273
  case Diagnostics_area::DA_ERROR:
 
274
    /* The query failed, send error to log and abort bootstrap. */
 
275
    session->protocol->sendError(session->main_da.sql_errno(),
 
276
                                 session->main_da.message());
 
277
    break;
 
278
 
 
279
  case Diagnostics_area::DA_EOF:
 
280
    session->protocol->sendEOF();
 
281
    break;
 
282
 
 
283
  case Diagnostics_area::DA_OK:
 
284
    session->protocol->sendOK();
 
285
    break;
 
286
 
 
287
  case Diagnostics_area::DA_DISABLED:
 
288
    break;
 
289
 
 
290
  case Diagnostics_area::DA_EMPTY:
 
291
  default:
 
292
    session->protocol->sendOK();
 
293
    break;
 
294
  }
 
295
 
 
296
  session->main_da.is_sent= true;
332
297
 
333
298
  session->set_proc_info("closing tables");
334
299
  /* Free tables */