Commit d2db48c6 authored by unknown's avatar unknown
Browse files

WL#3337 (Events new infrasctructure)

Second cut of separating parsing phase from execution phase
Separate Event_timed from parsing phase and introducing Event_parse_data.


sql/event_data_objects.cc:
  second cut,
  copy Event_timed::init_body() to Event_parse_data::init_body()
  Init the body during parsing, everything else keep as a pointer to
  Item or some other pointer to use for later initialization.
sql/event_data_objects.h:
  get the identifier as sp_name*, later will initialize our structures
sql/events.cc:
  for easy transition add temporarily parse_data, later Event_timed *et will be removed.
  Do slow transition because Event_timed is so tightly integrated that a front-attack
  by removing things from this class was unsuccessful. Do things step by step by eliminating
  dependencies. Hence, the code could be checked with the current test suite too
  (early testing)
sql/events.h:
  for easy transition add temporarily parse_data, later Event_timed *et will be removed.
  Do slow transition because Event_timed is so tightly integrated that a front-attack
  by removing things from this class was unsuccessful. Do things step by step by eliminating
  dependencies. Hence, the code could be checked with the current test suite too
  (early testing)
BitKeeper/etc/ignore:
  Added libmysql/viosocket.o.6WmSJk libmysqld/event_data_objects.cc libmysqld/event_db_repository.cc libmysqld/event_queue.cc server-tools/instance-manager/net_serv.cc to the ignore list
sql/share/errmsg.txt:
  remove this message, not used and needed for now
sql/sql_lex.h:
  for easy transition add temporarily parse_data, later Event_timed *et will be removed.
  Do slow transition because Event_timed is so tightly integrated that a front-attack
  by removing things from this class was unsuccessful. Do things step by step by eliminating
  dependencies. Hence, the code could be checked with the current test suite too
  (early testing)
sql/sql_parse.cc:
  for easy transition add temporarily parse_data, later Event_timed *et will be removed.
  Do slow transition because Event_timed is so tightly integrated that a front-attack
  by removing things from this class was unsuccessful. Do things step by step by eliminating
  dependencies. Hence, the code could be checked with the current test suite too
  (early testing)
sql/sql_yacc.yy:
  for easy transition add temporarily parse_data, later Event_timed *et will be removed.
  Do slow transition because Event_timed is so tightly integrated that a front-attack
  by removing things from this class was unsuccessful. Do things step by step by eliminating
  dependencies. Hence, the code could be checked with the current test suite too
  (early testing)
parent e5f8163b
Loading
Loading
Loading
Loading
+5 −0
Original line number Diff line number Diff line
@@ -1778,3 +1778,8 @@ vio/viotest-sslconnect.cpp
vio/viotest.cpp
zlib/*.ds?
zlib/*.vcproj
libmysql/viosocket.o.6WmSJk
libmysqld/event_data_objects.cc
libmysqld/event_db_repository.cc
libmysqld/event_queue.cc
server-tools/instance-manager/net_serv.cc
+89 −0
Original line number Diff line number Diff line
@@ -22,6 +22,95 @@
#include "sp_head.h"


Event_parse_data *
Event_parse_data::new_instance(THD *thd)
{
  return new (thd->mem_root) Event_parse_data;
}


Event_parse_data::Event_parse_data()
{
  item_execute_at= item_expression= item_starts= item_ends= NULL;
}


/*
  Set body of the event - what should be executed.

  SYNOPSIS
    Event_timed::init_body()
      thd   THD

  NOTE
    The body is extracted by copying all data between the
    start of the body set by another method and the current pointer in Lex.
 
    Some questionable removal of characters is done in here, and that part
    should be refactored when the parser is smarter.
*/

void
Event_parse_data::init_body(THD *thd)
{
  DBUG_ENTER("Event_parse_data::init_body");
  DBUG_PRINT("info", ("body=[%s] body_begin=0x%ld end=0x%ld", body_begin,
             body_begin, thd->lex->ptr));

  body.length= thd->lex->ptr - body_begin;
  const uchar *body_end= body_begin + body.length - 1;

  /* Trim nuls or close-comments ('*'+'/') or spaces at the end */
  while (body_begin < body_end)
  {

    if ((*body_end == '\0') || 
        (my_isspace(thd->variables.character_set_client, *body_end)))
    { /* consume NULs and meaningless whitespace */
      --body.length;
      --body_end;
      continue;
    }

    /*  
       consume closing comments

       This is arguably wrong, but it's the best we have until the parser is
       changed to be smarter.   FIXME PARSER 

       See also the sp_head code, where something like this is done also.

       One idea is to keep in the lexer structure the count of the number of
       open-comments we've entered, and scan left-to-right looking for a
       closing comment IFF the count is greater than zero.

       Another idea is to remove the closing comment-characters wholly in the
       parser, since that's where it "removes" the opening characters.
    */
    if ((*(body_end - 1) == '*') && (*body_end == '/'))
    {
      DBUG_PRINT("info", ("consumend one '*" "/' comment in the query '%s'", 
          body_begin));
      body.length-= 2;
      body_end-= 2;
      continue;
    }

    break;  /* none were found, so we have excised all we can. */
  }

  /* the first is always whitespace which I cannot skip in the parser */
  while (my_isspace(thd->variables.character_set_client, *body_begin))
  {
    ++body_begin;
    --body.length;
  }
  body.str= thd->strmake((char *)body_begin, body.length);

  DBUG_VOID_RETURN;
}


/*
  Constructor

+3 −6
Original line number Diff line number Diff line
@@ -259,19 +259,16 @@ class Event_parse_data : public Sql_alloc
  my_bool ends_null;
  my_bool execute_at_null;

  sp_name *identifier;
  Item* item_expression;
  Item* item_interval;
  longlong expression;
  interval_type interval;

//  ulonglong created;
//  ulonglong modified;

  static Event_parse_data *
  new_instance(THD *thd);

  Event_parse_data() {}
  ~Event_parse_data() {}
  Event_parse_data();
  ~Event_parse_data();

  int
  init_definer(THD *thd);
+7 −7
Original line number Diff line number Diff line
@@ -904,8 +904,8 @@ db_find_event(THD *thd, sp_name *name, Event_timed **ett, TABLE *tbl,
*/

int
Events::create_event(THD *thd, Event_timed *et, uint create_options,
                     uint *rows_affected)
Events::create_event(THD *thd, Event_timed *et, Event_parse_data *parse_data,
                     uint create_options, uint *rows_affected)
{
  int ret;

@@ -948,8 +948,8 @@ Events::create_event(THD *thd, Event_timed *et, uint create_options,
*/

int
Events::update_event(THD *thd, Event_timed *et, sp_name *new_name,
                               uint *rows_affected)
Events::update_event(THD *thd, Event_timed *et, Event_parse_data *parse_data,
                     sp_name *new_name, uint *rows_affected)
{
  int ret;

@@ -1054,8 +1054,8 @@ int db_drop_event(THD *thd, Event_timed *et, bool drop_if_exists,
*/

int
Events::drop_event(THD *thd, Event_timed *et, bool drop_if_exists,
                             uint *rows_affected)
Events::drop_event(THD *thd, Event_timed *et, Event_parse_data *parse_data,
                   bool drop_if_exists, uint *rows_affected)
{
  int ret;

@@ -1091,7 +1091,7 @@ Events::show_create_event(THD *thd, sp_name *spn)
  Event_timed *et= NULL;
  Open_tables_state backup;

  DBUG_ENTER("evex_update_event");
  DBUG_ENTER("Events::show_create_event");
  DBUG_PRINT("enter", ("name: %*s", spn->m_name.length, spn->m_name.str));

  thd->reset_n_backup_open_tables_state(&backup);
+7 −6
Original line number Diff line number Diff line
@@ -18,6 +18,7 @@


class Event_timed;
class Event_parse_data;

class Events
{
@@ -47,16 +48,16 @@ class Events
  };

  static int
  create_event(THD *thd, Event_timed *et, uint create_options,
               uint *rows_affected);
  create_event(THD *thd, Event_timed *et, Event_parse_data *parse_data,
               uint create_options, uint *rows_affected);

  static int
  update_event(THD *thd, Event_timed *et, sp_name *new_name,
               uint *rows_affected);
  update_event(THD *thd, Event_timed *et, Event_parse_data *parse_data,
               sp_name *new_name, uint *rows_affected);

  static int
  drop_event(THD *thd, Event_timed *et, bool drop_if_exists,
             uint *rows_affected);
  drop_event(THD *thd, Event_timed *et, Event_parse_data *parse_data,
             bool drop_if_exists, uint *rows_affected);

  static int
  open_event_table(THD *thd, enum thr_lock_type lock_type, TABLE **table);
Loading