~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/sql_parse.cc

Merged trunk.

Show diffs side-by-side

added added

removed removed

Lines of Context:
35
35
#include <drizzled/select_send.h>
36
36
#include <drizzled/plugin/client.h>
37
37
#include <drizzled/statement.h>
 
38
#include "drizzled/probes.h"
38
39
 
39
40
#include "drizzled/plugin/registry.h"
40
41
 
170
171
  Query_id &query_id= Query_id::get_query_id();
171
172
  plugin::Registry &plugins= plugin::Registry::singleton();
172
173
 
173
 
  session->command=command;
 
174
  DRIZZLE_COMMAND_START(session->thread_id,
 
175
                        command);
 
176
 
 
177
  session->command= command;
174
178
  session->lex->sql_command= SQLCOM_END; /* to avoid confusing VIEW detectors */
175
179
  session->set_time();
176
180
  session->query_id= query_id.value();
208
212
  {
209
213
    if (! session->readAndStoreQuery(packet, packet_length))
210
214
      break;                                    // fatal error is set
 
215
    DRIZZLE_QUERY_START(session->query,
 
216
                        session->thread_id,
 
217
                        const_cast<const char *>(session->db ? session->db : ""));
211
218
    const char* end_of_stmt= NULL;
212
219
 
213
220
    mysql_parse(session, session->query, session->query_length, &end_of_stmt);
298
305
 
299
306
  /* Store temp state for processlist */
300
307
  session->set_proc_info("cleaning up");
301
 
  session->command=COM_SLEEP;
 
308
  session->command= COM_SLEEP;
302
309
  memset(session->process_list_info, 0, PROCESS_LIST_WIDTH);
303
 
  session->query=0;
304
 
  session->query_length=0;
 
310
  session->query= 0;
 
311
  session->query_length= 0;
305
312
 
306
313
  session->set_proc_info(NULL);
307
314
  session->packet.shrink(session->variables.net_buffer_length); // Reclaim some memory
308
315
  free_root(session->mem_root,MYF(MY_KEEP_PREALLOC));
309
 
  return(error);
 
316
 
 
317
  if (DRIZZLE_QUERY_DONE_ENABLED() || DRIZZLE_COMMAND_DONE_ENABLED())
 
318
  {
 
319
    if (command == COM_QUERY)
 
320
    {
 
321
      DRIZZLE_QUERY_DONE(session->is_error());
 
322
    }
 
323
    DRIZZLE_COMMAND_DONE(session->is_error());
 
324
  }
 
325
 
 
326
  return error;
310
327
}
311
328
 
312
329
 
519
536
        even if the query itself redirects the output.
520
537
      */
521
538
      if (!(result= new select_send()))
522
 
        return true;                               /* purecov: inspected */
 
539
        return true;
523
540
      session->send_explain_fields(result);
524
541
      res= mysql_explain_union(session, &session->lex->unit, result);
525
542
      if (lex->describe & DESCRIBE_EXTENDED)
541
558
    else
542
559
    {
543
560
      if (!result && !(result= new select_send()))
544
 
        return true;                               /* purecov: inspected */
 
561
        return true;
545
562
      res= handle_select(session, lex, result, 0);
546
563
      if (result != lex->result)
547
564
        delete result;
762
779
          if (*found_semicolon &&
763
780
              (session->query_length= (ulong)(*found_semicolon - session->query)))
764
781
            session->query_length--;
 
782
          DRIZZLE_QUERY_EXEC_START(session->query,
 
783
                                   session->thread_id,
 
784
                                   const_cast<const char *>(session->db ? session->db : ""));
765
785
          /* Actually execute the query */
766
786
          mysql_execute_command(session);
 
787
          DRIZZLE_QUERY_EXEC_DONE(0);
767
788
        }
768
789
      }
769
790
    }
802
823
  LEX  *lex= session->lex;
803
824
 
804
825
  if (check_identifier_name(field_name, ER_TOO_LONG_IDENT))
805
 
    return(1);                          /* purecov: inspected */
 
826
    return(1);
806
827
 
807
828
  if (type_modifier & PRI_KEY_FLAG)
808
829
  {
944
965
      return NULL;
945
966
  }
946
967
  if (!(ptr = (TableList *) session->calloc(sizeof(TableList))))
947
 
    return NULL;                                /* purecov: inspected */
 
968
    return NULL;
948
969
  if (table->db.str)
949
970
  {
950
971
    ptr->is_fqtn= true;
1001
1022
      if (!my_strcasecmp(table_alias_charset, alias_str, tables->alias) &&
1002
1023
          !strcmp(ptr->db, tables->db))
1003
1024
      {
1004
 
        my_error(ER_NONUNIQ_TABLE, MYF(0), alias_str); /* purecov: tested */
1005
 
        return NULL;                            /* purecov: tested */
 
1025
        my_error(ER_NONUNIQ_TABLE, MYF(0), alias_str);
 
1026
        return NULL;
1006
1027
      }
1007
1028
    }
1008
1029
  }
1822
1843
{
1823
1844
  assert(session->m_lip == NULL);
1824
1845
 
 
1846
  DRIZZLE_QUERY_PARSE_START(session->query);
 
1847
 
1825
1848
  /* Set Lex_input_stream. */
1826
1849
 
1827
1850
  session->m_lip= lip;
1838
1861
 
1839
1862
  session->m_lip= NULL;
1840
1863
 
 
1864
  DRIZZLE_QUERY_PARSE_DONE(mysql_parse_status || session->is_fatal_error);
 
1865
 
1841
1866
  /* That's it. */
1842
1867
 
1843
1868
  return mysql_parse_status || session->is_fatal_error;