~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/sql_parse.cc

Added hook points and the interface for the Query Cache plugin

Show diffs side-by-side

added added

removed removed

Lines of Context:
41
41
#include "drizzled/probes.h"
42
42
#include "drizzled/session_list.h"
43
43
#include "drizzled/global_charset_info.h"
 
44
#include "drizzled/enum.h"
44
45
 
45
46
#include "drizzled/plugin/logging.h"
46
47
#include "drizzled/plugin/query_rewrite.h"
 
48
#include "drizzled/plugin/query_cache.h"
47
49
#include "drizzled/plugin/authorization.h"
48
50
#include "drizzled/optimizer/explain_plan.h"
49
51
#include "drizzled/pthread_globals.h"
476
478
 
477
479
  /* now we are ready to execute the statement */
478
480
  res= lex->statement->execute();
479
 
 
480
481
  session->set_proc_info("query end");
481
 
 
482
482
  /*
483
483
    The return value for ROW_COUNT() is "implementation dependent" if the
484
484
    statement is not DELETE, INSERT or UPDATE, but -1 is what JDBC and ODBC
492
492
 
493
493
  return (res || session->is_error());
494
494
}
495
 
 
496
495
bool execute_sqlcom_select(Session *session, TableList *all_tables)
497
496
{
498
497
  LEX   *lex= session->lex;
540
539
    {
541
540
      if (!result && !(result= new select_send()))
542
541
        return true;
 
542
 
 
543
      /* Init the Query Cache plugin */
 
544
      plugin::QueryCache::prepareResultsetDo(session); 
 
545
      
543
546
      res= handle_select(session, lex, result, 0);
 
547
      
 
548
      /* Send the Resultset to the cache */
 
549
      plugin::QueryCache::setResultsetDo(session); 
 
550
 
544
551
      if (result != lex->result)
545
 
        delete result;
 
552
          delete result;
546
553
    }
547
554
  }
548
555
  return res;
714
721
{
715
722
  lex_start(session);
716
723
  session->reset_for_next_command();
717
 
 
 
724
 /* first try to fetch the result from the cache
 
725
    ToDo: 
 
726
    1) Here the tryFetchAndSendDo is called before the parsing of the query, 
 
727
    thus the plugin need to detect if it's a SELECT statement
 
728
    2) if further information (one that is generated after the parsing) is needed then 
 
729
       we shall move the call to a deeper step */
 
730
 if(plugin::QueryCache::tryFetchAndSendDo(session))
 
731
 {
718
732
  LEX *lex= session->lex;
719
733
 
720
734
  Lex_input_stream lip(session, inBuf, length);
753
767
  session->set_proc_info("freeing items");
754
768
  session->end_statement();
755
769
  session->cleanup_after_query();
 
770
 }
 
771
  else
 
772
    cout << "Cached Results" << endl;
756
773
}
757
774
 
758
775