List:Commits« Previous MessageNext Message »
From:Mats Kindahl Date:February 15 2008 11:47am
Subject:bk commit into 5.1 tree (mats:1.2548) BUG#34458
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@stripped, 2008-02-15 12:47:42+01:00, mats@stripped +1 -0
  Bug #34458  	Extreneous use of templates in server code
  
  Replacing a template function with a normal static function.
  The template parameter, which previously was the class to
  find a binlogging function in, is now passed as a pointer to
  the actual binlogging function instead.
  
  The patch requires change of indention, but that is submitted
  as a separate patch.

  sql/handler.cc@stripped, 2008-02-15 12:47:37+01:00, mats@stripped +21 -41
    Replacing template function with a normal static function.

diff -Nrup a/sql/handler.cc b/sql/handler.cc
--- a/sql/handler.cc	2008-01-25 18:37:27 +01:00
+++ b/sql/handler.cc	2008-02-15 12:47:37 +01:00
@@ -3843,11 +3843,7 @@ bool ha_show_status(THD *thd, handlerton
   - table is not mysql.event
 */
 
-/* The Sun compiler cannot instantiate the template below if this is
-   declared static, but it works by putting it into an anonymous
-   namespace. */
-namespace {
-  bool check_table_binlog_row_based(THD *thd, TABLE *table)
+  static bool check_table_binlog_row_based(THD *thd, TABLE *table)
   {
     if (table->s->cached_row_logging_check == -1)
     {
@@ -3864,7 +3860,6 @@ namespace {
             (thd->options & OPTION_BIN_LOG) &&
             mysql_bin_log.is_open());
   }
-}
 
 /** @brief
    Write table maps for all (manually or automatically) locked tables
@@ -3888,9 +3883,8 @@ namespace {
        THD::lock
        THD::locked_tables
 */
-namespace
-{
-  int write_locked_table_maps(THD *thd)
+
+  static int write_locked_table_maps(THD *thd)
   {
     DBUG_ENTER("write_locked_table_maps");
     DBUG_PRINT("enter", ("thd: 0x%lx  thd->lock: 0x%lx  thd->locked_tables: 0x%lx  "
@@ -3935,10 +3929,14 @@ namespace
     DBUG_RETURN(0);
   }
 
-  template<class RowsEventT> int
-  binlog_log_row(TABLE* table,
-                 const uchar *before_record,
-                 const uchar *after_record)
+
+typedef bool Log_func(THD*, TABLE*, bool, MY_BITMAP*,
+                      uint, const uchar*, const uchar*);
+
+  static int binlog_log_row(TABLE* table,
+                            const uchar *before_record,
+                            const uchar *after_record,
+                            Log_func *log_func)
   {
     if (table->no_replicate)
       return 0;
@@ -3965,15 +3963,10 @@ namespace
       {
         bitmap_set_all(&cols);
         if (likely(!(error= write_locked_table_maps(thd))))
-        {
-          error=
-            RowsEventT::binlog_row_logging_function(thd, table,
-                                                    table->file->
-                                                    has_transactions(),
-                                                    &cols, table->s->fields,
-                                                    before_record,
-                                                    after_record);
-        }
+          error= (*log_func)(thd, table, table->file->has_transactions(),
+                             &cols, table->s->fields,
+                             before_record, after_record);
+
         if (!use_bitbuf)
           bitmap_free(&cols);
       }
@@ -3981,22 +3974,6 @@ namespace
     return error ? HA_ERR_RBR_LOGGING_FAILED : 0;
   }
 
-  /*
-    Instantiate the versions we need for the above template function,
-    because we have -fno-implicit-template as compiling option.
-  */
-
-  template int
-  binlog_log_row<Write_rows_log_event>(TABLE *, const uchar *, const uchar *);
-
-  template int
-  binlog_log_row<Delete_rows_log_event>(TABLE *, const uchar *, const uchar *);
-
-  template int
-  binlog_log_row<Update_rows_log_event>(TABLE *, const uchar *, const uchar *);
-}
-
-
 int handler::ha_external_lock(THD *thd, int lock_type)
 {
   DBUG_ENTER("handler::ha_external_lock");
@@ -4044,7 +4021,8 @@ int handler::ha_write_row(uchar *buf)
   DBUG_ENTER("handler::ha_write_row");
   if (unlikely(error= write_row(buf)))
     DBUG_RETURN(error);
-  if (unlikely(error= binlog_log_row<Write_rows_log_event>(table, 0, buf)))
+  Log_func *log_func= Write_rows_log_event::binlog_row_logging_function;
+  if (unlikely(error= binlog_log_row(table, 0, buf, log_func)))
     DBUG_RETURN(error); /* purecov: inspected */
   DBUG_RETURN(0);
 }
@@ -4062,7 +4040,8 @@ int handler::ha_update_row(const uchar *
 
   if (unlikely(error= update_row(old_data, new_data)))
     return error;
-  if (unlikely(error= binlog_log_row<Update_rows_log_event>(table, old_data, new_data)))
+  Log_func *log_func= Update_rows_log_event::binlog_row_logging_function;
+  if (unlikely(error= binlog_log_row(table, old_data, new_data, log_func)))
     return error;
   return 0;
 }
@@ -4072,7 +4051,8 @@ int handler::ha_delete_row(const uchar *
   int error;
   if (unlikely(error= delete_row(buf)))
     return error;
-  if (unlikely(error= binlog_log_row<Delete_rows_log_event>(table, buf, 0)))
+  Log_func *log_func= Delete_rows_log_event::binlog_row_logging_function;
+  if (unlikely(error= binlog_log_row(table, buf, 0, log_func)))
     return error;
   return 0;
 }
Thread
bk commit into 5.1 tree (mats:1.2548) BUG#34458Mats Kindahl15 Feb