~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/sql_parse.cc

  • Committer: Olaf van der Spek
  • Date: 2011-04-08 14:05:22 UTC
  • mto: (2275.1.1 build)
  • mto: This revision was merged to the branch mainline in revision 2276.
  • Revision ID: olafvdspek@gmail.com-20110408140522-7yhd0yxc0njnshf9
Session Times

Show diffs side-by-side

added added

removed removed

Lines of Context:
57
57
#include <drizzled/table_ident.h>
58
58
#include <drizzled/statistics_variables.h>
59
59
#include <drizzled/system_variables.h>
 
60
#include <drizzled/session/times.h>
60
61
#include <drizzled/session/transactions.h>
61
62
 
62
63
#include <limits.h>
193
194
 
194
195
  session->command= command;
195
196
  session->lex().sql_command= SQLCOM_END; /* to avoid confusing VIEW detectors */
196
 
  session->set_time();
 
197
  session->times.set_time();
197
198
  session->setQueryId(query_id.value());
198
199
 
199
200
  switch( command ) {
784
785
void parse(Session *session, const char *inBuf, uint32_t length)
785
786
{
786
787
  session->lex().start(session);
787
 
 
788
788
  session->reset_for_next_command();
789
789
  /* Check if the Query is Cached if and return true if yes
790
790
   * TODO the plugin has to make sure that the query is cacheble
791
791
   * by setting the query_safe_cache param to TRUE
792
792
   */
793
 
  bool res= true;
794
 
  if (plugin::QueryCache::isCached(session))
795
 
  {
796
 
    res= plugin::QueryCache::sendCachedResultset(session);
797
 
  }
798
 
  if (not res)
799
 
  {
800
 
    return;
801
 
  }
802
 
  LEX *lex= &session->lex();
 
793
  if (plugin::QueryCache::isCached(session) && not plugin::QueryCache::sendCachedResultset(session))
 
794
      return;
803
795
  Lex_input_stream lip(session, inBuf, length);
804
 
  bool err= parse_sql(session, &lip);
805
 
  if (!err)
806
 
  {
807
 
    {
808
 
      if (not session->is_error())
809
 
      {
810
 
        DRIZZLE_QUERY_EXEC_START(session->getQueryString()->c_str(),
811
 
                                 session->thread_id,
812
 
                                 const_cast<const char *>(session->schema()->c_str()));
813
 
        // Implement Views here --Brian
814
 
        /* Actually execute the query */
815
 
        try
816
 
        {
817
 
          execute_command(session);
818
 
        }
819
 
        catch (...)
820
 
        {
821
 
          // Just try to catch any random failures that could have come
822
 
          // during execution.
823
 
          DRIZZLE_ABORT;
824
 
        }
825
 
        DRIZZLE_QUERY_EXEC_DONE(0);
826
 
      }
827
 
    }
828
 
  }
829
 
  else
830
 
  {
 
796
  if (parse_sql(session, &lip))
831
797
    assert(session->is_error());
 
798
  else if (not session->is_error())
 
799
  {
 
800
    DRIZZLE_QUERY_EXEC_START(session->getQueryString()->c_str(), session->thread_id,
 
801
                             const_cast<const char *>(session->schema()->c_str()));
 
802
    // Implement Views here --Brian
 
803
    /* Actually execute the query */
 
804
    try
 
805
    {
 
806
      execute_command(session);
 
807
    }
 
808
    catch (...)
 
809
    {
 
810
      // Just try to catch any random failures that could have come
 
811
      // during execution.
 
812
      DRIZZLE_ABORT;
 
813
    }
 
814
    DRIZZLE_QUERY_EXEC_DONE(0);
832
815
  }
833
 
  lex->unit.cleanup();
 
816
  session->lex().unit.cleanup();
834
817
  session->set_proc_info("freeing items");
835
818
  session->end_statement();
836
819
  session->cleanup_after_query();
837
 
  session->set_end_timer();
 
820
  session->times.set_end_timer(*session);
838
821
}
839
822
 
840
823
 
841
 
 
842
824
/**
843
825
  Store field definition for create.
844
826