List:Internals« Previous MessageNext Message »
From:Mats Kindahl Date:February 24 2005 1:41pm
Subject:bk commit into 5.1 tree (mats:1.1774)
View as plain text  
Below is the list of changes that have just been committed into a local
5.1 repository of mats. When mats does a push these changes will
be propagated to the main repository and, within 24 hours after the
push, to the public repository.
For information on how to access the public repository
see http://www.mysql.com/doc/I/n/Installing_source_tree.html

ChangeSet
  1.1774 05/02/24 14:41:45 mats@stripped +5 -0
  WL#2324: Defining Injector interface for NDB.

  sql/handler.h
    1.122 05/02/24 14:41:40 mats@stripped +11 -2
    Added member function to get an injector instance.

  sql/handler.cc
    1.134 05/02/24 14:41:40 mats@stripped +16 -0
    Added member function to get an injector instance.

  sql/Makefile.am
    1.101 05/02/24 14:41:40 mats@stripped +2 -2
    Added header files and source files.

  sql/injector.cc
    1.1 05/02/24 14:26:02 mats@stripped +62 -0

  sql/injector.h
    1.1 05/02/24 14:26:01 mats@stripped +101 -0

  sql/injector.cc
    1.0 05/02/24 14:26:02 mats@stripped +0 -0
    BitKeeper file /home/bk/w2324-mysql-5.1/sql/injector.cc

  sql/injector.h
    1.0 05/02/24 14:26:01 mats@stripped +0 -0
    BitKeeper file /home/bk/w2324-mysql-5.1/sql/injector.h

# This is a BitKeeper patch.  What follows are the unified diffs for the
# set of deltas contained in the patch.  The rest of the patch, the part
# that BitKeeper cares about, is below these diffs.
# User:	mats
# Host:	romeo.kindahl.net
# Root:	/home/bk/w2324-mysql-5.1

--- 1.100/sql/Makefile.am	2004-12-17 03:40:12 +01:00
+++ 1.101/sql/Makefile.am	2005-02-24 14:41:40 +01:00
@@ -49,7 +49,7 @@
 			mysql_priv.h item_geofunc.h sql_bitmap.h \
 			procedure.h sql_class.h sql_lex.h sql_list.h \
 			sql_manager.h sql_map.h sql_string.h unireg.h \
-			field.h handler.h mysqld_suffix.h \
+			field.h handler.h injector.h mysqld_suffix.h \
 			ha_myisammrg.h\
 			ha_heap.h ha_myisam.h ha_berkeley.h ha_innodb.h \
 			ha_ndbcluster.h opt_range.h protocol.h \
@@ -83,7 +83,7 @@
 			log.cc log_event.cc init.cc derror.cc sql_acl.cc \
 			unireg.cc des_key_file.cc \
 			discover.cc time.cc opt_range.cc opt_sum.cc \
-		   	records.cc filesort.cc handler.cc \
+		   	records.cc filesort.cc handler.cc injector.cc \
 		        ha_heap.cc ha_myisam.cc ha_myisammrg.cc \
 	                ha_berkeley.cc ha_innodb.cc \
 			ha_ndbcluster.cc \

--- 1.133/sql/handler.cc	2005-01-07 15:38:31 +01:00
+++ 1.134/sql/handler.cc	2005-02-24 14:41:40 +01:00
@@ -53,6 +53,8 @@
 #include <myisampack.h>
 #include <errno.h>
 
+#include "injector.h"
+
 	/* static functions defined in this file */
 
 static int NEAR_F delete_file(const char *name,const char *ext,int extflag);
@@ -1009,6 +1011,12 @@
 ** General handler functions
 ****************************************************************************/
 
+handler::
+~handler()
+{
+  delete m_injector;
+}
+
 	/* Open database-handler. Try O_RDONLY if can't open as O_RDWR */
 	/* Don't wait for locks if not HA_OPEN_WAIT_IF_LOCKED is set */
 
@@ -1509,6 +1517,14 @@
   return error;
 }
 
+
+injector* handler::
+get_injector()
+{ 
+  if (m_injector == NULL)
+    m_injector = new injector(this);
+  return m_injector; 
+}
 
 /****************************************************************************
 ** Some general functions that isn't in the handler class

--- 1.121/sql/handler.h	2005-01-07 15:38:58 +01:00
+++ 1.122/sql/handler.h	2005-02-24 14:41:40 +01:00
@@ -293,6 +293,8 @@
 } HANDLER_BUFFER;
 
 
+class injector;			/* Forward declaration */
+
 class handler :public Sql_alloc
 {
  protected:
@@ -310,6 +312,8 @@
   virtual int rnd_init(bool scan) =0;
   virtual int rnd_end() { return 0; }
 
+  injector* get_injector();
+
 public:
   byte *ref;				/* Pointer to current row */
   byte *dupp_ref;			/* Pointer to dupp row */
@@ -359,9 +363,10 @@
     create_time(0), check_time(0), update_time(0),
     key_used_on_scan(MAX_KEY), active_index(MAX_KEY),
     ref_length(sizeof(my_off_t)), block_size(0),
-    raid_type(0), ft_handler(0), inited(NONE), implicit_emptied(0)
+    raid_type(0), ft_handler(0), inited(NONE), implicit_emptied(0),
+    m_injector(0)
     {}
-  virtual ~handler(void) { /* TODO: DBUG_ASSERT(inited == NONE); */ }
+  virtual ~handler(void);
   int ha_open(const char *name, int mode, int test_if_locked);
   void update_auto_increment();
   virtual void print_error(int error, myf errflag);
@@ -604,6 +609,10 @@
  {
    return memcmp(ref1, ref2, ref_length);
  }
+
+private:
+  injector* m_injector;
+
 };
 
 	/* Some extern variables used with handlers */
--- New file ---
+++ sql/injector.cc	05/02/24 14:26:02

#include "injector.h"
#include "mysql_priv.h"

injector::
injector(handler* file)
   : m_file(file)
{
   
}

int injector::
start_transaction()
{
   DBUG_PRINT("info", ("Starting transaction"));
   return 0;
}


int injector::
commit_transaction()
{
   DBUG_PRINT("info", ("Committing transaction"));
   return 0;
}


int injector::
write_row (server_identity_type sid, record_type record)
{
   DBUG_ENTER("injector::write_row(...)");
   DBUG_RETURN(0);
   return 0;
}


int injector::
delete_row(server_identity_type sid, record_type record)
{
   DBUG_ENTER("injector::delete_row(...)");
   DBUG_RETURN(0);
}


int injector::
update_row(server_identity_type sid, 
	   record_type before, 
	   record_type after)
{
   DBUG_ENTER("injector::update_row(...)");
   DBUG_RETURN(0);
}


injector::binlog_position_type injector::
transaction_start_position() const
{
   return 0;			// Really an illegal position!!!
}




--- New file ---
+++ sql/injector.h	05/02/24 14:26:01
/* -*- Mode: C++ -*-

   Copyright (C) 2005 MySQL AB & MySQL Finland AB & TCX DataKonsult AB

   This program is free software; you can redistribute it and/or modify
   it under the terms of the GNU General Public License as published by
   the Free Software Foundation; either version 2 of the License, or
   (at your option) any later version.

   This program is distributed in the hope that it will be useful,
   but WITHOUT ANY WARRANTY; without even the implied warranty of
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
   GNU General Public License for more details.

   You should have received a copy of the GNU General Public License
   along with this program; if not, write to the Free Software
   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA */

#ifndef INJECTOR_H
#define INJECTOR_H

#include "my_global.h"		// Pull in 'byte', 'my_off_t', and 'uint32'

// Forward declarations
class handler;

/*
  The injector class is used to notify the MySQL server of new rows that have
  appeared outside of MySQL control. 

  The original purpose of this is to allow clusters---which handle replication
  inside the cluster through other means---to insert new rows into binary log.
  Note, however, that the injector should be used whenever rows are altered in
  any manner that is outside of MySQL server visibility and which therefore
  are not seen by the MySQL server.
 */
class injector 
{
public:
    // Convenience definitions
    typedef byte*    record_type;
    typedef my_off_t binlog_position_type;
    typedef uint32   server_identity_type;

    explicit injector(handler*);
    ~injector() { /* Nothing needs to be done */ }

    /* 
       Start a transaction. 
       This member function will prepare for a sequence of *_row calls by,
       for example, reserving resources and locking files. 
     */
    int start_transaction();

    /*
      Commit a transaction.
      This member function will clean up after a sequence of *_row calls by,
      for example, releasing resource and unlocking files.
    */
    int commit_transaction();

    /*
     Add a 'write row' entry to the transaction.
    */
   
    int write_row (server_identity_type sid, record_type record);

    /*
     Add a 'delete row' entry to the transaction.
    */
    int delete_row(server_identity_type sid, record_type record);

    /*
     Add an 'update row' entry to the transaction.
    */
    int update_row(server_identity_type sid, record_type before, 
		   record_type after);

    /*
      Get the position for the start of the transaction.

      This call requires that a transaction is open, otherwise the call will
      fail. 

      Returns the position in the binary log of the first event in this
      transaction. If now event is yet written, the position where the event
      *will* be written is returned. This position is known, since a
      start_transaction() will lock the binary log and prevent any other
      writes to the binary log.
    */
    binlog_position_type transaction_start_position() const;

private:
    // You're now allowed to copy injector instances.
    injector(injector const&);

    handler* m_file;		// It's called 'file' in st_table.
};


#endif // INJECTOR_H

Thread
bk commit into 5.1 tree (mats:1.1774)Mats Kindahl24 Feb