List:Internals« Previous MessageNext Message »
From:Mats Kindahl Date:April 12 2005 11:44am
Subject:bk commit into 5.1 tree (mats:1.1851)
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://dev.mysql.com/doc/mysql/en/installing-source-tree.html

ChangeSet
  1.1851 05/04/12 13:44:49 mats@stripped +7 -0
  WL#2324: Factoring out 'is_transaction' attribute from handler/engine
  to allow use of "virtual table" that does not have engine present.

  sql/sql_class.h
    1.230 05/04/12 13:44:44 mats@stripped +8 -4
    Adding 'is_transactional' parameter to row-oriented member functions
    for the THD class.

  sql/sql_class.cc
    1.175 05/04/12 13:44:44 mats@stripped +22 -14
    Adding 'is_transactional' parameter to row-oriented member functions
    for the THD class.  Added some comments.

  sql/rpl_injector.h
    1.8 05/04/12 13:44:44 mats@stripped +39 -17
    Factoring out has_transaction() from TABLE into separate
    member variable m_is_transactional.

  sql/rpl_injector.cc
    1.10 05/04/12 13:44:44 mats@stripped +4 -3
    Factoring out has_transaction() from TABLE into separate
    member variable m_is_transactional.

  sql/log_event.h
    1.110 05/04/12 13:44:44 mats@stripped +9 -6
    Factoring out has_transaction() from TABLE into separate
    member variable m_is_transactional.

  sql/log_event.cc
    1.172 05/04/12 13:44:44 mats@stripped +11 -9
    Factoring out has_transaction() from TABLE into separate
    member variable m_is_transactional.

  sql/handler.cc
    1.153 05/04/12 13:44:44 mats@stripped +5 -3
    Adding 'is_transactional' parameter to row-oriented member functions
    for the THD class.

# 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.152/sql/handler.cc	2005-04-07 14:12:58 +02:00
+++ 1.153/sql/handler.cc	2005-04-12 13:44:44 +02:00
@@ -2415,7 +2415,7 @@
       && !this->is_injective()) 
   {
     bitvector const cols(table->s->fields, true);
-    thd->write_row(table, cols, buf);
+    thd->write_row(table, table->file->has_transactions(), cols, buf);
   }
 #endif
   DBUG_PRINT("exit", ("error = %d", 0));
@@ -2448,7 +2448,8 @@
       && !this->is_injective()) 
   {
     bitvector const cols(table->s->fields, true);
-    thd->update_row(table, cols, old_data, new_data);
+    thd->update_row(table, table->file->has_transactions(), 
+		    cols, old_data, new_data);
   }
 #endif
   DBUG_PRINT("exit", ("error = %d", 0));
@@ -2481,7 +2482,8 @@
       && !this->is_injective()) 
   {
     bitvector const cols(table->s->fields, true);
-    thd->delete_row(table, cols, buf);
+    thd->delete_row(table, table->file->has_transactions(),
+		    cols, buf);
   }
 #endif
   DBUG_PRINT("exit", ("error = %d", 0));

--- 1.171/sql/log_event.cc	2005-04-01 13:40:13 +02:00
+++ 1.172/sql/log_event.cc	2005-04-12 13:44:44 +02:00
@@ -4723,7 +4723,8 @@
 
 #ifndef MYSQL_CLIENT
 Rows_log_event::
-Rows_log_event(THD* thd_arg, TABLE* tbl_arg, ulong tid, bitvector const& cols)
+Rows_log_event(THD* thd_arg, TABLE* tbl_arg, ulong tid, 
+	       bitvector const& cols, bool is_transactional)
   : Log_event(thd_arg, 0, tbl_arg->file->has_transactions()),
     m_dbnam(thd_arg->db), m_dblen(m_dbnam ? strlen(m_dbnam) : 0),
     m_table(tbl_arg), 
@@ -4735,7 +4736,8 @@
     m_rows_buf(my_malloc(1024 * sizeof(*m_rows_buf), MYF(MY_WME))),
     m_rows_cur(m_rows_buf),
     m_rows_end(m_rows_buf + 1024),
-    m_rows_flags(0)
+    m_rows_flags(0),
+    m_is_transactional(is_transactional)
 {
 }
 #endif
@@ -5198,8 +5200,8 @@
 #ifndef MYSQL_CLIENT
 Write_rows_log_event::
 Write_rows_log_event(THD* thd_arg, TABLE* tbl_arg, ulong tid_arg, 
-		     bitvector const& cols)
-  : Rows_log_event(thd_arg, tbl_arg, tid_arg, cols)
+		     bitvector const& cols, bool is_transactional)
+  : Rows_log_event(thd_arg, tbl_arg, tid_arg, cols, is_transactional)
 {
 }
 #endif
@@ -5289,11 +5291,11 @@
 #ifndef MYSQL_CLIENT
 Delete_rows_log_event::
 Delete_rows_log_event(THD* thd_arg, TABLE* tbl_arg, ulong tid, 
-		      bitvector const& cols)
+		      bitvector const& cols, bool is_transactional)
 #ifndef HAVE_REPLICATION
-  : Rows_log_event(thd_arg, tbl_arg, tid, cols)
+  : Rows_log_event(thd_arg, tbl_arg, tid, cols, is_transactional)
 #else
-  : Rows_log_event(thd_arg, tbl_arg, tid, cols), 
+  : Rows_log_event(thd_arg, tbl_arg, tid, cols, is_transactional), 
     m_memory(NULL), m_key(NULL), m_search_record(NULL)
 #endif
 {
@@ -5465,8 +5467,8 @@
 #if !defined(MYSQL_CLIENT) && defined(HAVE_REPLICATION)
 Update_rows_log_event::
 Update_rows_log_event(THD* thd_arg, TABLE* tbl_arg, ulong tid, 
-		      bitvector const& cols)
-: Rows_log_event(thd_arg, tbl_arg, tid, cols),
+		      bitvector const& cols, bool is_transactional)
+: Rows_log_event(thd_arg, tbl_arg, tid, cols, is_transactional),
   m_memory(NULL), m_key(NULL)
 {
 }

--- 1.109/sql/log_event.h	2005-04-01 13:32:29 +02:00
+++ 1.110/sql/log_event.h	2005-04-12 13:44:44 +02:00
@@ -1739,7 +1739,7 @@
   // this class, not create instances of this class.
 #ifndef MYSQL_CLIENT
   Rows_log_event(THD*, TABLE*, ulong table_id, 
-		 bitvector const& cols);
+		 bitvector const& cols, bool is_transactional);
 #endif
   Rows_log_event(const char* row_data, uint event_len, 
 		 Log_event_type event_type,
@@ -1765,7 +1765,7 @@
   byte* m_rows_end;		// One-after the end of the allocated space
 
   uint16 m_rows_flags;		// Flags for row-level events
-
+  bool   m_is_transactional;	// The table handler is transactional
 private:
 #ifndef MYSQL_CLIENT
   virtual bool do_write_to_binlog() const {
@@ -1773,7 +1773,7 @@
   }
 
   virtual bool do_can_be_cached() const {
-    return opt_binlog_row_level && m_table->file->has_transactions();
+    return opt_binlog_row_level && m_is_transactional;
   }
 
 #ifdef HAVE_REPLICATION
@@ -1859,7 +1859,8 @@
   };
 
 #ifndef MYSQL_CLIENT
-  Write_rows_log_event(THD*, TABLE*, ulong table_id, bitvector const& cols);
+  Write_rows_log_event(THD*, TABLE*, ulong table_id, 
+		       bitvector const& cols, bool is_transactional);
 #endif
   Write_rows_log_event(const char* buf, uint event_len, 
                        const Format_description_log_event *description_event);
@@ -1904,7 +1905,8 @@
   };
 
 #ifndef MYSQL_CLIENT
-  Update_rows_log_event(THD*, TABLE*, ulong table_id, bitvector const& cols);
+  Update_rows_log_event(THD*, TABLE*, ulong table_id, 
+			bitvector const& cols, bool is_transactional);
 #endif
   Update_rows_log_event(const char* buf, uint event_len, 
 			const Format_description_log_event *description_event);
@@ -1953,7 +1955,8 @@
   };
 
 #ifndef MYSQL_CLIENT
-  Delete_rows_log_event(THD*, TABLE*, ulong, bitvector const& cols);
+  Delete_rows_log_event(THD*, TABLE*, ulong, 
+			bitvector const& cols, bool is_transactional);
   virtual ~Delete_rows_log_event();
 #endif
   Delete_rows_log_event(const char* buf, uint event_len, 

--- 1.174/sql/sql_class.cc	2005-04-01 13:40:13 +02:00
+++ 1.175/sql/sql_class.cc	2005-04-12 13:44:44 +02:00
@@ -1851,7 +1851,8 @@
 template <class RowsEventT>
 Rows_log_event* THD::
 prepare_pending(TABLE* table, uint32 server_id, 
-		bitvector const& cols, size_t needed) 
+		bitvector const& cols, size_t needed, 
+		bool is_transactional) 
 {
   // Fetch the type code for the RowsEventT template parameter
   int const type_code = RowsEventT::TYPE_CODE;
@@ -1892,7 +1893,7 @@
     ulong const tid = mysql_bin_log.get_table_id(table);
 
     Rows_log_event* const 
-	ev = new RowsEventT(this, table, tid, cols);
+	ev = new RowsEventT(this, table, tid, cols, is_transactional);
     ev->server_id = server_id; // I don't like this, it's too easy to forget. 
     if (flush_and_set_pending_event(ev))
       DBUG_RETURN(NULL);
@@ -1907,13 +1908,16 @@
 */
 
 template Rows_log_event* THD::
-prepare_pending<Write_rows_log_event>(TABLE*, uint32, bitvector const&, size_t);
+prepare_pending<Write_rows_log_event>(TABLE*, uint32, bitvector const&, 
+				      size_t, bool);
 
 template Rows_log_event* THD::
-prepare_pending<Delete_rows_log_event>(TABLE*, uint32, bitvector const&, size_t);
+prepare_pending<Delete_rows_log_event>(TABLE*, uint32, bitvector const&, 
+				       size_t, bool);
 
 template Rows_log_event* THD::
-prepare_pending<Update_rows_log_event>(TABLE*, uint32, bitvector const&, size_t);
+prepare_pending<Update_rows_log_event>(TABLE*, uint32, bitvector const&, 
+				       size_t, bool);
 
 int THD::
 flush_and_set_pending_event(Rows_log_event* event)
@@ -1961,9 +1965,7 @@
 }
 
 size_t THD::
-pack_row(TABLE *table, 
-	 byte *row_data, 
-	 size_t max_size, 
+pack_row(TABLE *table, byte *row_data, size_t max_size, 
 	 const byte *record) const
 {
   DBUG_ENTER("THD::pack_row");
@@ -1995,7 +1997,8 @@
 }
 
 int THD::
-write_row(TABLE* table, bitvector const& cols, byte const *record) 
+write_row(TABLE* table, bool is_trans, 
+	  bitvector const& cols, byte const *record) 
 { 
   DBUG_ENTER("THD::write_row");
   DBUG_PRINT("enter", ("cols = { size: %d, data = %p }; "
@@ -2017,7 +2020,8 @@
   size_t const len     = pack_row(table, row_data, max_len, record);
 
   Rows_log_event* const
-    ev = thd->prepare_pending<Write_rows_log_event>(table, server_id, cols, len);
+    ev = thd->prepare_pending<Write_rows_log_event>(table, server_id, cols, 
+						    len, is_trans);
 
   if (ev == NULL)
     DBUG_RETURN(1);
@@ -2031,7 +2035,8 @@
 }
 
 int THD::
-update_row(TABLE* table, bitvector const& cols,
+update_row(TABLE* table, bool is_trans,
+	   bitvector const& cols, 
 	   const byte *before_record, const byte *after_record)
 { 
   DBUG_ENTER("THD::update_row");
@@ -2064,7 +2069,8 @@
   Rows_log_event* const
     ev = thd->prepare_pending<Update_rows_log_event>(table, 
 						     server_id, cols, 
-						     before_size + after_size);
+						     before_size + after_size,
+						     is_trans);
 
   if (ev == NULL)
     DBUG_RETURN(1);
@@ -2080,7 +2086,8 @@
 }
 
 int THD::
-delete_row(TABLE* table, bitvector const& cols, byte const *record)
+delete_row(TABLE* table, bool is_trans, 
+	   bitvector const& cols, byte const *record)
 { 
   DBUG_ENTER("THD::delete_row");
   DBUG_PRINT("enter", ("cols = { size: %d, data = %p }; "
@@ -2100,7 +2107,8 @@
   size_t const len     = pack_row(table, row_data, max_len, record);
 
   Rows_log_event* const
-    ev = prepare_pending<Delete_rows_log_event>(table, server_id, cols, len);
+    ev = prepare_pending<Delete_rows_log_event>(table, server_id, cols, 
+						len, is_trans);
 
   if (ev == NULL)
     DBUG_RETURN(1);

--- 1.229/sql/sql_class.h	2005-04-01 13:40:14 +02:00
+++ 1.230/sql/sql_class.h	2005-04-12 13:44:44 +02:00
@@ -1106,9 +1106,12 @@
   /*
     Public interface to write rows to the binlog
   */
-  int write_row(TABLE* table, bitvector const& cols, const byte *buf);
-  int delete_row(TABLE* table, bitvector const& cols, const byte *buf);
-  int update_row(TABLE* table, bitvector const& cols, 
+  int write_row(TABLE* table, bool is_transactional,
+		bitvector const& cols, const byte *buf);
+  int delete_row(TABLE* table, bool is_transactional,
+		 bitvector const& cols, const byte *buf);
+  int update_row(TABLE* table, bool is_transactional,
+		 bitvector const& cols, 
 		 const byte *old_data, const byte *new_data);
 
   void set_server_id(uint32 sid) { server_id = sid; }
@@ -1133,7 +1136,8 @@
   template <class RowsEventT>
     Rows_log_event* 
       prepare_pending(TABLE* table, uint32 server_id, 
-		      bitvector const& cols, size_t needed);
+		      bitvector const& cols, size_t needed, 
+		      bool is_transactional);
 
   size_t max_row_length(TABLE* table, const byte *data) const;
   size_t pack_row(TABLE* table, byte *row_data, 

--- 1.9/sql/rpl_injector.cc	2005-04-05 15:30:11 +02:00
+++ 1.10/sql/rpl_injector.cc	2005-04-12 13:44:44 +02:00
@@ -70,7 +70,7 @@
 {
    DBUG_ENTER("injector::transaction::write_row(...)");
    m_thd->set_server_id(sid);
-   m_thd->write_row(tbl.get_table(), cols, record);
+   m_thd->write_row(tbl.get_table(), tbl.is_transactional(), cols, record);
    DBUG_RETURN(0);
 }
 
@@ -81,7 +81,7 @@
 {
    DBUG_ENTER("injector::transaction::delete_row(...)");
    m_thd->set_server_id(sid);
-   m_thd->delete_row(tbl.get_table(), cols, record);
+   m_thd->delete_row(tbl.get_table(), tbl.is_transactional(), cols, record);
    DBUG_RETURN(0);
 }
 
@@ -92,7 +92,8 @@
 {
    DBUG_ENTER("injector::transaction::update_row(...)");
    m_thd->set_server_id(sid);
-   m_thd->update_row(tbl.get_table(), cols, before, after);
+   m_thd->update_row(tbl.get_table(), tbl.is_transactional(),
+		     cols, before, after);
    DBUG_RETURN(0);
 }
 

--- 1.7/sql/rpl_injector.h	2005-04-05 15:30:11 +02:00
+++ 1.8/sql/rpl_injector.h	2005-04-12 13:44:44 +02:00
@@ -31,9 +31,11 @@
 typedef st_table TABLE;
 
 /*
+  Injector to inject rows into the MySQL server.
+  
   The injector class is used to notify the MySQL server of new rows that have
-  appeared outside of MySQL control. 
-
+  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
@@ -45,18 +47,24 @@
 public:
 
   /*
-    Return the instance of the injector.
-    The injector is a Singleton, so this static function return the instance
-    of the injector.
+    Get an instance of the injector.
+
+    DESCRIPTION
+      The injector is a Singleton, so this static function return the
+      available instance of the injector.
+
+    RETURN VALUE
+      A pointer to the available injector object.
   */
   static injector* instance();
 
     /*
       A transaction where rows can be added.
 
-      The transaction class satisfy the CopyConstructible and Assignable
-      requirements.  Note that the transaction is *not* default
-      constructible. 
+      DESCRIPTION
+        The transaction class satisfy the **CopyConstructible** and
+        **Assignable** requirements.  Note that the transaction is *not*
+        default constructible.
      */
     class transaction {
       friend class injector;
@@ -80,7 +88,7 @@
 	  construct objects of this type using 'new'; instead construct an
 	  object, possibly a temporary object.  For example:
 
-	    injector::transaction::table tbl(share->table);
+	    injector::transaction::table tbl(share->table, true);
 	    bitvector cols(i, true);
 	    inj->write_row(::server_id, tbl, cols, row_data);
 
@@ -88,7 +96,7 @@
 
 	    bitvector cols(i, true);
 	    inj->write_row(::server_id, 
-	                   injector::transaction::table(share->table), 
+	                   injector::transaction::table(share->table, true), 
 			   cols, row_data);
 
           This will work, be more efficient, and have greater chance of
@@ -103,21 +111,23 @@
       class table 
       {
       public:
-	table(TABLE* table) 
-	    : m_table(table)
+	table(TABLE* table, bool is_transactional) 
+	    : m_table(table), m_is_transactional(is_transactional)
 	{ 
 	}
 
 	char const* db_name() const { return m_table->s->db; }
 	char const* table_name() const { return m_table->s->table_name; }
 	TABLE* get_table() const { return m_table; }
+	bool is_transactional() const { return m_is_transactional; }
 
       private:
-	  TABLE* m_table;
+	TABLE* m_table;
+	bool m_is_transactional;
       };
 
       /*
-	Binlog position as a structure
+	Binlog position as a structure.
       */
       class binlog_pos {
 	friend class transaction;
@@ -169,7 +179,7 @@
 	Get the position for the start of the transaction.
 
 	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
+	transaction. If no event is yet written, the position where the event
 	*will* be written is returned. This position is known, since a
 	new_transaction() will lock the binary log and prevent any other
 	writes to the binary log.
@@ -181,7 +191,19 @@
       transaction(MYSQL_LOG*, THD*);
 
       void swap(transaction& o) {
-	// Nothing to do yet: the class has no members !!!
+	// std::swap(m_start_pos, o.m_start_pos);
+	{
+	  binlog_pos const tmp = m_start_pos;
+	  m_start_pos = o.m_start_pos;
+	  o.m_start_pos = tmp;
+	}
+
+	// std::swap(m_thd, o.m_thd);
+	{
+	  THD* const tmp = m_thd;
+	  m_thd = o.m_thd;
+	  o.m_thd = tmp;
+	}
       }
 
       binlog_pos m_start_pos;
@@ -198,7 +220,7 @@
 private:
     explicit injector();
     ~injector() { }		// Nothing needs to be done
-    injector(injector const&);	// You're now allowed to copy injector
+    injector(injector const&);	// You're not allowed to copy injector
 				// instances. 
 };
 
Thread
bk commit into 5.1 tree (mats:1.1851)Mats Kindahl12 Apr