~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/sql_parse.cc

  • Committer: Andrew Hutchings
  • Date: 2010-09-08 19:03:09 UTC
  • mfrom: (1750 staging)
  • mto: (1750.1.1 build)
  • mto: This revision was merged to the branch mainline in revision 1751.
  • Revision ID: andrew@linuxjedi.co.uk-20100908190309-mya1nu7xvo1fpvk8
Merge trunk into branch

Show diffs side-by-side

added added

removed removed

Lines of Context:
44
44
 
45
45
#include "drizzled/plugin/logging.h"
46
46
#include "drizzled/plugin/query_rewrite.h"
 
47
#include "drizzled/plugin/query_cache.h"
47
48
#include "drizzled/plugin/authorization.h"
48
49
#include "drizzled/optimizer/explain_plan.h"
49
50
#include "drizzled/pthread_globals.h"
476
477
 
477
478
  /* now we are ready to execute the statement */
478
479
  res= lex->statement->execute();
479
 
 
480
480
  session->set_proc_info("query end");
481
 
 
482
481
  /*
483
482
    The return value for ROW_COUNT() is "implementation dependent" if the
484
483
    statement is not DELETE, INSERT or UPDATE, but -1 is what JDBC and ODBC
492
491
 
493
492
  return (res || session->is_error());
494
493
}
495
 
 
496
494
bool execute_sqlcom_select(Session *session, TableList *all_tables)
497
495
{
498
496
  LEX   *lex= session->lex;
540
538
    {
541
539
      if (!result && !(result= new select_send()))
542
540
        return true;
 
541
 
 
542
      /* Init the Query Cache plugin */
 
543
      plugin::QueryCache::prepareResultset(session); 
543
544
      res= handle_select(session, lex, result, 0);
 
545
      /* Send the Resultset to the cache */
 
546
      plugin::QueryCache::setResultset(session); 
 
547
 
544
548
      if (result != lex->result)
545
549
        delete result;
546
550
    }
715
719
  uint64_t start_time= my_getsystime();
716
720
  lex_start(session);
717
721
  session->reset_for_next_command();
718
 
 
 
722
  /* Check if the Query is Cached if and return true if yes
 
723
   * TODO the plugin has to make sure that the query is cacheble
 
724
   * by setting the query_safe_cache param to TRUE
 
725
   */
 
726
  bool res= true;
 
727
  if (plugin::QueryCache::isCached(session))
 
728
  {
 
729
    res= plugin::QueryCache::sendCachedResultset(session);
 
730
  }
 
731
  if (not res)
 
732
  {
 
733
    return;
 
734
  }
719
735
  LEX *lex= session->lex;
720
 
 
721
736
  Lex_input_stream lip(session, inBuf, length);
722
 
 
723
737
  bool err= parse_sql(session, &lip);
724
 
 
725
738
  if (!err)
726
739
  {
727
740
    {
731
744
                                 session->thread_id,
732
745
                                 const_cast<const char *>(session->db.empty() ? "" : session->db.c_str()));
733
746
        // Implement Views here --Brian
734
 
 
735
747
        /* Actually execute the query */
736
 
        try {
 
748
        try 
 
749
        {
737
750
          mysql_execute_command(session);
738
751
        }
739
752
        catch (...)
749
762
  {
750
763
    assert(session->is_error());
751
764
  }
752
 
 
753
765
  lex->unit.cleanup();
754
766
  session->set_proc_info("freeing items");
755
767
  session->end_statement();