List:Commits« Previous MessageNext Message »
From:Mats Kindahl Date:May 23 2007 6:29pm
Subject:bk commit into 5.1 tree (mats:1.2579)
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, 2007-05-23 20:22:26+02:00, mats@stripped +15 -0
  WL#3303 (RBR: Engine-controlled logging format):
  
  Adding support to allow engines to tell what formats they can handle.
  The server will generate an error if it is not possible to log the
  statement according to the logging mode in effect.
  
  Adding flags to several storage engines to state what they can handle.
  
  Changes to NDB handler removing code that forces row-based mode and
  adding flag saying that NDB can only handle row format.

  mysql-test/r/binlog_multi_engine.result@stripped, 2007-05-23 20:21:35+02:00, mats@stripped +86 -0
    New BitKeeper file ``mysql-test/r/binlog_multi_engine.result''

  mysql-test/r/binlog_multi_engine.result@stripped, 2007-05-23 20:21:35+02:00, mats@stripped +0 -0

  mysql-test/t/binlog_multi_engine.test@stripped, 2007-05-23 20:21:15+02:00, mats@stripped +59 -0
    New BitKeeper file ``mysql-test/t/binlog_multi_engine.test''

  mysql-test/t/binlog_multi_engine.test@stripped, 2007-05-23 20:21:15+02:00, mats@stripped +0 -0

  sql/ha_ndbcluster.cc@stripped, 2007-05-23 20:16:46+02:00, mats@stripped +1 -3
    Removing statements that switch to row-based format.
    Adding row capabilities.

  sql/handler.h@stripped, 2007-05-23 20:17:06+02:00, mats@stripped +19 -4
    Adding handler/table flags to indicate that the engine is row- and/or
    statement-logging capable.
    
    Adding typedef for table_flags type.

  sql/set_var.cc@stripped, 2007-05-23 20:17:33+02:00, mats@stripped +0 -10
    Removing code that prevents changing binlog format when NDB is active.

  sql/share/errmsg.txt@stripped, 2007-05-23 20:18:14+02:00, mats@stripped +6 -0
    Adding error messages for when row- and/or statement-based logging
    formats cannot be used.

  sql/sql_base.cc@stripped, 2007-05-23 20:17:54+02:00, mats@stripped +83 -6
    Adding business logic in lock_tables() to decide when an error should
    be thrown because logging is not possible.
    Add logic to switch to row format when that is allowed and needed.

  storage/archive/ha_archive.h@stripped, 2007-05-23 20:18:34+02:00, mats@stripped +1 -0
    Adding row- and statement-logging capabilities to engine.

  storage/blackhole/ha_blackhole.h@stripped, 2007-05-23 20:18:54+02:00, mats@stripped +1 -0
    Blackhole can handle statement-format only.

  storage/csv/ha_tina.h@stripped, 2007-05-23 20:19:14+02:00, mats@stripped +2 -1
    Adding row- and statement-logging capabilities to engine.

  storage/example/ha_example.h@stripped, 2007-05-23 20:19:35+02:00, mats@stripped +6 -1
    For the example engine, we arbitrarily decided that it only can handle
    row format.

  storage/federated/ha_federated.h@stripped, 2007-05-23 20:19:55+02:00, mats@stripped +1 -0
    Adding row- and statement-logging capabilities to engine.

  storage/heap/ha_heap.h@stripped, 2007-05-23 20:20:15+02:00, mats@stripped +1 -0
    Heap can handle both row- and statement-based logging format.

  storage/myisam/ha_myisam.cc@stripped, 2007-05-23 20:20:35+02:00, mats@stripped +1 -0
    MyISAM can handle both row- and statement-based logging format.

  storage/myisammrg/ha_myisammrg.h@stripped, 2007-05-23 20:20:55+02:00, mats@stripped +1 -0
    MyISAM can handle both row- and statement-based logging format.

# 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/w3303-mysql-5.1-rpl

--- 1.52/storage/heap/ha_heap.h	2007-05-23 20:28:37 +02:00
+++ 1.53/storage/heap/ha_heap.h	2007-05-23 20:28:37 +02:00
@@ -48,6 +48,7 @@
   ulonglong table_flags() const
   {
     return (HA_FAST_KEY_READ | HA_NO_BLOBS | HA_NULL_IN_KEY |
+            HA_BINLOG_ROW_CAPABLE | HA_BINLOG_STMT_CAPABLE |
             HA_REC_NOT_IN_SEQ | HA_CAN_INSERT_DELAYED | HA_NO_TRANSACTIONS |
             HA_HAS_RECORDS | HA_STATS_RECORDS_IS_EXACT);
   }

--- 1.217/storage/myisam/ha_myisam.cc	2007-05-23 20:28:37 +02:00
+++ 1.218/storage/myisam/ha_myisam.cc	2007-05-23 20:28:37 +02:00
@@ -474,6 +474,7 @@
 ha_myisam::ha_myisam(handlerton *hton, TABLE_SHARE *table_arg)
   :handler(hton, table_arg), file(0),
   int_table_flags(HA_NULL_IN_KEY | HA_CAN_FULLTEXT | HA_CAN_SQL_HANDLER |
+                  HA_BINLOG_ROW_CAPABLE | HA_BINLOG_STMT_CAPABLE |
                   HA_DUPLICATE_POS | HA_CAN_INDEX_BLOBS | HA_AUTO_PART_KEY |
                   HA_FILE_BASED | HA_CAN_GEOMETRY | HA_NO_TRANSACTIONS |
                   HA_CAN_INSERT_DELAYED | HA_CAN_BIT_FIELD | HA_CAN_RTREEKEYS |

--- 1.52/storage/myisammrg/ha_myisammrg.h	2007-05-23 20:28:37 +02:00
+++ 1.53/storage/myisammrg/ha_myisammrg.h	2007-05-23 20:28:37 +02:00
@@ -35,6 +35,7 @@
   ulonglong table_flags() const
   {
     return (HA_REC_NOT_IN_SEQ | HA_AUTO_PART_KEY | HA_NO_TRANSACTIONS |
+            HA_BINLOG_ROW_CAPABLE | HA_BINLOG_STMT_CAPABLE |
 	    HA_NULL_IN_KEY | HA_CAN_INDEX_BLOBS | HA_FILE_BASED |
             HA_ANY_INDEX_MAY_BE_UNIQUE | HA_CAN_BIT_FIELD |
             HA_NO_COPY_ON_ALTER);

--- 1.256/sql/handler.h	2007-05-23 20:28:37 +02:00
+++ 1.257/sql/handler.h	2007-05-23 20:28:37 +02:00
@@ -117,6 +117,18 @@
 #define HA_HAS_RECORDS	       (LL(1) << 32) /* records() gives exact count*/
 /* Has it's own method of binlog logging */
 #define HA_HAS_OWN_BINLOGGING  (LL(1) << 33)
+/*
+  Engine is capable of row-format and statement-format logging,
+  respectively
+*/
+#define HA_BINLOG_ROW_CAPABLE  (LL(1) << 34)
+#define HA_BINLOG_STMT_CAPABLE (LL(1) << 35)
+
+/*
+  Set of all binlog flags. Currently only contain the capabilities
+  flags.
+ */
+#define HA_BINLOG_FLAGS (HA_BINLOG_ROW_CAPABLE | HA_BINLOG_STMT_CAPABLE)
 
 /* bits in index_flags(index_number) for what you can do with index */
 #define HA_READ_NEXT            1       /* TODO really use this flag */
@@ -687,7 +699,7 @@
 };
 
 
-/* Possible flags of a handlerton */
+/* Possible flags of a handlerton (there can be 32 of them) */
 #define HTON_NO_FLAGS                 0
 #define HTON_CLOSE_CURSORS_AT_COMMIT (1 << 0)
 #define HTON_ALTER_NOT_SUPPORTED     (1 << 1) //Engine does not support alter
@@ -889,10 +901,13 @@
 {
   friend class ha_partition;
 
+public:
+  typedef ulonglong Table_flags;
+
  protected:
   struct st_table_share *table_share;   /* The table definition */
   struct st_table *table;               /* The current open table */
-  ulonglong cached_table_flags;         /* Set on init() and open() */
+  Table_flags cached_table_flags;       /* Set on init() and open() */
 
   virtual int index_init(uint idx, bool sorted) { active_index=idx; return 0; }
   virtual int index_end() { active_index=MAX_KEY; return 0; }
@@ -905,7 +920,7 @@
   */
   virtual int rnd_init(bool scan) =0;
   virtual int rnd_end() { return 0; }
-  virtual ulonglong table_flags(void) const =0;
+  virtual Table_flags table_flags(void) const =0;
   void ha_statistic_increment(ulong SSV::*offset) const;
 
   ha_rows estimation_rows_to_insert;
@@ -1115,7 +1130,7 @@
   {
     return inited == INDEX ? ha_index_end() : inited == RND ? ha_rnd_end() : 0;
   }
-  longlong ha_table_flags() { return cached_table_flags; }
+  Table_flags ha_table_flags() const { return cached_table_flags; }
 
   /*
     Signal that the table->read_set and table->write_set table maps changed

--- 1.397/sql/sql_base.cc	2007-05-23 20:28:37 +02:00
+++ 1.398/sql/sql_base.cc	2007-05-23 20:28:37 +02:00
@@ -3585,14 +3585,91 @@
     in prelocked mode.
   */
   DBUG_ASSERT(!thd->prelocked_mode || !thd->lex->requires_prelocking());
-
   *need_reopen= FALSE;
 
-  /*
-    CREATE ... SELECT UUID() locks no tables, we have to test here.
-  */
-  if (thd->lex->is_stmt_unsafe())
-    thd->set_current_stmt_binlog_row_based_if_mixed();
+  if (mysql_bin_log.is_open() && (thd->options | OPTION_BIN_LOG))
+  {
+    /*
+      Compute the capabilities vector for the involved storage engines
+      and mask out the flags for the binary log. Right now, the binlog
+      flags only include the capabilities of the storage engines, so
+      this is safe.
+    */
+    handler::Table_flags binlog_flags= ~handler::Table_flags();
+    for (table= tables; table; table= table->next_global)
+    {
+      DBUG_PRINT("info", ("table_name: %s; flags: 0x%0lx",
+                          table->table_name,
+                          (ulong) table->table->file->ha_table_flags()));
+      DBUG_PRINT("info", ("binlog_flags: 0x%lx", (ulong) binlog_flags));
+      binlog_flags &= table->table->file->ha_table_flags();
+    }
+    binlog_flags&= HA_BINLOG_FLAGS;
+    DBUG_PRINT("info", ("binlog_flags: 0x%0lx", (ulong) binlog_flags));
+    DBUG_PRINT("info", ("thd->variables.binlog_format: %ld",
+                        thd->variables.binlog_format));
+
+    /*
+      We have three alternatives that prevent the statement from being
+      loggable:
+
+      1. If there are no capabilities left (all flags are clear) it is
+         not possible to log the statement at all, so we roll back the
+         statement and report an error.
+
+      2. Statement mode is set, but the capabilities indicate that
+         statement format is not possible.
+
+      3. Row mode is set, but the capabilities indicate that row
+         format is not possible.
+
+      4. Statement is unsafe, but the capabilities indicate that row
+         format is not possible.
+    */
+    int error= 0;
+    if (binlog_flags == 0)
+    {
+      error= ER_BINLOG_ENGINES_INCOMPATIBLE;
+    }
+    else if (thd->variables.binlog_format == BINLOG_FORMAT_STMT &&
+             (binlog_flags & HA_BINLOG_STMT_CAPABLE) == 0)
+    {
+      error= ER_BINLOG_STMT_FORMAT_FORBIDDEN;
+    }
+    else if ((thd->variables.binlog_format == BINLOG_FORMAT_ROW ||
+              thd->lex->is_stmt_unsafe()) &&
+             (binlog_flags & HA_BINLOG_ROW_CAPABLE) == 0)
+    {
+      error= ER_BINLOG_ROW_FORMAT_FORBIDDEN;
+    }
+
+    DBUG_PRINT("info", ("error: %d", error));
+
+    if (error)
+    {
+      ha_rollback_stmt(thd);
+      my_error(error, MYF(0));
+      DBUG_RETURN(-1);
+    }
+
+    /*
+      We switch to row-based format if we are in mixed mode and one of
+      the following are true:
+
+      1. If the statement is unsafe
+      2. If statement format cannot be used
+
+      Observe that point to cannot be decided before the tables
+      involved in a statement has been checked, i.e., we cannot put
+      this code in reset_current_stmt_binlog_row_based(), it has to be
+      here.
+     */
+    if (thd->lex->is_stmt_unsafe() ||
+        (binlog_flags | HA_BINLOG_STMT_CAPABLE) == 0)
+    {
+      thd->set_current_stmt_binlog_row_based_if_mixed();
+    }
+  }
 
   if (!tables && !thd->lex->requires_prelocking())
     DBUG_RETURN(0);

--- 1.155/sql/share/errmsg.txt	2007-05-23 20:28:37 +02:00
+++ 1.156/sql/share/errmsg.txt	2007-05-23 20:28:37 +02:00
@@ -6062,3 +6062,9 @@
 ER_BINLOG_UNSAFE_STATEMENT
         eng "Statement is not safe to log in statement format."
+ER_BINLOG_ENGINES_INCOMPATIBLE
+        eng "It is not possible to log anything with this combination of engines"
+ER_BINLOG_STMT_FORMAT_FORBIDDEN
+        eng "Attempting to log statement in in statement format, but statement format is not possible with this combination of engines"
+ER_BINLOG_ROW_FORMAT_FORBIDDEN
+        eng "Attempting to log statement in in row format, but row format is not possible with this combination of engines"

--- 1.63/storage/archive/ha_archive.h	2007-05-23 20:28:37 +02:00
+++ 1.64/storage/archive/ha_archive.h	2007-05-23 20:28:37 +02:00
@@ -87,6 +87,7 @@
   ulonglong table_flags() const
   {
     return (HA_NO_TRANSACTIONS | HA_REC_NOT_IN_SEQ | HA_CAN_BIT_FIELD |
+            HA_BINLOG_ROW_CAPABLE | HA_BINLOG_STMT_CAPABLE |
             HA_FILE_BASED | HA_CAN_INSERT_DELAYED | HA_CAN_GEOMETRY);
   }
   ulong index_flags(uint idx, uint part, bool all_parts) const

--- 1.28/storage/csv/ha_tina.h	2007-05-23 20:28:37 +02:00
+++ 1.29/storage/csv/ha_tina.h	2007-05-23 20:28:37 +02:00
@@ -99,7 +99,8 @@
   const char **bas_ext() const;
   ulonglong table_flags() const
   {
-    return (HA_NO_TRANSACTIONS | HA_REC_NOT_IN_SEQ | HA_NO_AUTO_INCREMENT);
+    return (HA_NO_TRANSACTIONS | HA_REC_NOT_IN_SEQ | HA_NO_AUTO_INCREMENT |
+            HA_BINLOG_ROW_CAPABLE | HA_BINLOG_STMT_CAPABLE);
   }
   ulong index_flags(uint idx, uint part, bool all_parts) const
   {

--- 1.22/storage/example/ha_example.h	2007-05-23 20:28:37 +02:00
+++ 1.23/storage/example/ha_example.h	2007-05-23 20:28:37 +02:00
@@ -82,7 +82,12 @@
   */
   ulonglong table_flags() const
   {
-    return 0;
+    /*
+      We are saying that this engine is just row capable to have an
+      engine that can only handle row-based logging. This is used in
+      testing.
+    */
+    return HA_BINLOG_ROW_CAPABLE;
   }
 
   /** @brief

--- 1.14/storage/blackhole/ha_blackhole.h	2007-05-23 20:28:37 +02:00
+++ 1.15/storage/blackhole/ha_blackhole.h	2007-05-23 20:28:37 +02:00
@@ -42,6 +42,7 @@
   ulonglong table_flags() const
   {
     return(HA_NULL_IN_KEY | HA_CAN_FULLTEXT | HA_CAN_SQL_HANDLER |
+           HA_BINLOG_STMT_CAPABLE |
            HA_CAN_INDEX_BLOBS | HA_AUTO_PART_KEY |
            HA_FILE_BASED | HA_CAN_GEOMETRY | HA_CAN_INSERT_DELAYED);
   }

--- 1.438/sql/ha_ndbcluster.cc	2007-05-23 20:28:37 +02:00
+++ 1.439/sql/ha_ndbcluster.cc	2007-05-23 20:28:37 +02:00
@@ -4444,7 +4444,6 @@
       DBUG_PRINT("warning", ("ops_pending != 0L"));
     m_ops_pending= 0;
   }
-  thd->set_current_stmt_binlog_row_based_if_mixed();
   DBUG_RETURN(error);
 }
 
@@ -4494,7 +4493,6 @@
   m_active_trans= trans;
   // Start of statement
   m_ops_pending= 0;    
-  thd->set_current_stmt_binlog_row_based_if_mixed();
 
   DBUG_RETURN(error);
 }
@@ -6000,6 +5998,7 @@
                 HA_PRIMARY_KEY_REQUIRED_FOR_DELETE | \
                 HA_PARTIAL_COLUMN_READ | \
                 HA_HAS_OWN_BINLOGGING | \
+                HA_BINLOG_ROW_CAPABLE | \
                 HA_HAS_RECORDS
 
 ha_ndbcluster::ha_ndbcluster(handlerton *hton, TABLE_SHARE *table_arg):
@@ -8788,7 +8787,6 @@
   my_net_init(&thd->net, 0);
   thd->main_security_ctx.master_access= ~0;
   thd->main_security_ctx.priv_user = 0;
-  thd->current_stmt_binlog_row_based= TRUE;     // If in mixed mode
 
   /* Signal successful initialization */
   ndb_util_thread_running= 1;
--- New file ---
+++ mysql-test/r/binlog_multi_engine.result	07/05/23 20:21:35
CREATE TABLE t1m (m INT, n INT) ENGINE=MYISAM;
CREATE TABLE t1b (b INT, c INT) ENGINE=BLACKHOLE;
CREATE TABLE t1n (e INT, f INT) ENGINE=NDB;
SET SESSION BINLOG_FORMAT=STATEMENT;
INSERT INTO t1m VALUES (1,1), (1,2), (2,1), (2,2);
INSERT INTO t1b VALUES (1,1), (1,2), (2,1), (2,2);
INSERT INTO t1n VALUES (1,1), (1,2), (2,1), (2,2);
ERROR HY000: Attempting to log statement in in statement format, but statement format is not possible with this combination of engines
UPDATE t1m, t1b SET m = 2, b = 3 WHERE n = c;
UPDATE t1m, t1n SET m = 2, e = 3 WHERE n = f;
ERROR HY000: Attempting to log statement in in statement format, but statement format is not possible with this combination of engines
UPDATE t1n, t1b SET e = 2, b = 3 WHERE f = c;
ERROR HY000: It is not possible to log anything with this combination of engines
TRUNCATE t1m;
TRUNCATE t1b;
TRUNCATE t1n;
SET SESSION BINLOG_FORMAT=MIXED;
INSERT INTO t1m VALUES (1,1), (1,2), (2,1), (2,2);
INSERT INTO t1b VALUES (1,1), (1,2), (2,1), (2,2);
INSERT INTO t1n VALUES (1,1), (1,2), (2,1), (2,2);
UPDATE t1m, t1b SET m = 2, b = 3 WHERE n = c;
UPDATE t1m, t1n SET m = 2, e = 3 WHERE n = f;
UPDATE t1n, t1b SET e = 2, b = 3 WHERE f = c;
ERROR HY000: It is not possible to log anything with this combination of engines
TRUNCATE t1m;
TRUNCATE t1b;
TRUNCATE t1n;
SET SESSION BINLOG_FORMAT=ROW;
INSERT INTO t1m VALUES (1,1), (1,2), (2,1), (2,2);
INSERT INTO t1b VALUES (1,1), (1,2), (2,1), (2,2);
ERROR HY000: Attempting to log statement in in row format, but row format is not possible with this combination of engines
INSERT INTO t1n VALUES (1,1), (1,2), (2,1), (2,2);
UPDATE t1m, t1b SET m = 2, b = 3 WHERE n = c;
ERROR HY000: Attempting to log statement in in row format, but row format is not possible with this combination of engines
UPDATE t1m, t1n SET m = 2, e = 3 WHERE n = f;
UPDATE t1n, t1b SET e = 2, b = 3 WHERE f = c;
ERROR HY000: It is not possible to log anything with this combination of engines
TRUNCATE t1m;
TRUNCATE t1b;
TRUNCATE t1n;
show binlog events from <binlog_start>;
Log_name	Pos	Event_type	Server_id	End_log_pos	Info
master-bin.000001	#	Query	#	#	use `test`; CREATE TABLE t1m (m INT, n INT) ENGINE=MYISAM
master-bin.000001	#	Query	#	#	use `test`; CREATE TABLE t1b (b INT, c INT) ENGINE=BLACKHOLE
master-bin.000001	#	Query	#	#	use `test`; CREATE TABLE t1n (e INT, f INT) ENGINE=NDB
master-bin.000001	#	Query	#	#	use `test`; INSERT INTO t1m VALUES (1,1), (1,2), (2,1), (2,2)
master-bin.000001	#	Query	#	#	use `test`; INSERT INTO t1b VALUES (1,1), (1,2), (2,1), (2,2)
master-bin.000001	#	Query	#	#	use `test`; UPDATE t1m, t1b SET m = 2, b = 3 WHERE n = c
master-bin.000001	#	Query	#	#	use `test`; TRUNCATE t1m
master-bin.000001	#	Query	#	#	use `test`; TRUNCATE t1b
master-bin.000001	#	Query	#	#	use `test`; TRUNCATE t1n
master-bin.000001	#	Query	#	#	use `test`; INSERT INTO t1m VALUES (1,1), (1,2), (2,1), (2,2)
master-bin.000001	#	Query	#	#	use `test`; INSERT INTO t1b VALUES (1,1), (1,2), (2,1), (2,2)
master-bin.000001	#	Query	#	#	use `test`; INSERT INTO t1n VALUES (1,1), (1,2), (2,1), (2,2)
master-bin.000001	#	Query	#	#	use `test`; UPDATE t1m, t1b SET m = 2, b = 3 WHERE n = c
master-bin.000001	#	Query	#	#	use `test`; UPDATE t1m, t1n SET m = 2, e = 3 WHERE n = f
master-bin.000001	#	Query	#	#	use `test`; TRUNCATE t1m
master-bin.000001	#	Query	#	#	use `test`; TRUNCATE t1b
master-bin.000001	#	Query	#	#	BEGIN
master-bin.000001	#	Table_map	#	#	table_id: # (test.t1n)
master-bin.000001	#	Table_map	#	#	table_id: # (mysql.ndb_apply_status)
master-bin.000001	#	Write_rows	#	#	table_id: #
master-bin.000001	#	Write_rows	#	#	table_id: #
master-bin.000001	#	Write_rows	#	#	table_id: #
master-bin.000001	#	Update_rows	#	#	table_id: #
master-bin.000001	#	Update_rows	#	#	table_id: # flags: STMT_END_F
master-bin.000001	#	Query	#	#	COMMIT
master-bin.000001	#	Query	#	#	use `test`; TRUNCATE t1n
master-bin.000001	#	Table_map	#	#	table_id: # (test.t1m)
master-bin.000001	#	Write_rows	#	#	table_id: # flags: STMT_END_F
master-bin.000001	#	Table_map	#	#	table_id: # (test.t1m)
master-bin.000001	#	Table_map	#	#	table_id: # (test.t1n)
master-bin.000001	#	Update_rows	#	#	table_id: # flags: STMT_END_F
master-bin.000001	#	Query	#	#	use `test`; TRUNCATE t1m
master-bin.000001	#	Query	#	#	use `test`; TRUNCATE t1b
master-bin.000001	#	Query	#	#	BEGIN
master-bin.000001	#	Table_map	#	#	table_id: # (test.t1n)
master-bin.000001	#	Table_map	#	#	table_id: # (mysql.ndb_apply_status)
master-bin.000001	#	Write_rows	#	#	table_id: #
master-bin.000001	#	Write_rows	#	#	table_id: #
master-bin.000001	#	Write_rows	#	#	table_id: #
master-bin.000001	#	Update_rows	#	#	table_id: #
master-bin.000001	#	Update_rows	#	#	table_id: # flags: STMT_END_F
master-bin.000001	#	Query	#	#	COMMIT
master-bin.000001	#	Query	#	#	use `test`; TRUNCATE t1n
DROP TABLE t1m, t1b, t1n;

--- New file ---
+++ mysql-test/t/binlog_multi_engine.test	07/05/23 20:21:15
source include/have_blackhole.inc;
source include/have_ndb.inc;

CREATE TABLE t1m (m INT, n INT) ENGINE=MYISAM;
CREATE TABLE t1b (b INT, c INT) ENGINE=BLACKHOLE;
CREATE TABLE t1n (e INT, f INT) ENGINE=NDB;

SET SESSION BINLOG_FORMAT=STATEMENT;

INSERT INTO t1m VALUES (1,1), (1,2), (2,1), (2,2);
INSERT INTO t1b VALUES (1,1), (1,2), (2,1), (2,2);
error ER_BINLOG_STMT_FORMAT_FORBIDDEN;
INSERT INTO t1n VALUES (1,1), (1,2), (2,1), (2,2);

UPDATE t1m, t1b SET m = 2, b = 3 WHERE n = c;
error ER_BINLOG_STMT_FORMAT_FORBIDDEN;
UPDATE t1m, t1n SET m = 2, e = 3 WHERE n = f;
error ER_BINLOG_ENGINES_INCOMPATIBLE;
UPDATE t1n, t1b SET e = 2, b = 3 WHERE f = c;

TRUNCATE t1m;
TRUNCATE t1b;
TRUNCATE t1n;

SET SESSION BINLOG_FORMAT=MIXED;

INSERT INTO t1m VALUES (1,1), (1,2), (2,1), (2,2);
INSERT INTO t1b VALUES (1,1), (1,2), (2,1), (2,2);
INSERT INTO t1n VALUES (1,1), (1,2), (2,1), (2,2);

UPDATE t1m, t1b SET m = 2, b = 3 WHERE n = c;
UPDATE t1m, t1n SET m = 2, e = 3 WHERE n = f;
error ER_BINLOG_ENGINES_INCOMPATIBLE;
UPDATE t1n, t1b SET e = 2, b = 3 WHERE f = c;

TRUNCATE t1m;
TRUNCATE t1b;
TRUNCATE t1n;

SET SESSION BINLOG_FORMAT=ROW;

INSERT INTO t1m VALUES (1,1), (1,2), (2,1), (2,2);
error ER_BINLOG_ROW_FORMAT_FORBIDDEN;
INSERT INTO t1b VALUES (1,1), (1,2), (2,1), (2,2);
INSERT INTO t1n VALUES (1,1), (1,2), (2,1), (2,2);

error ER_BINLOG_ROW_FORMAT_FORBIDDEN;
UPDATE t1m, t1b SET m = 2, b = 3 WHERE n = c;
UPDATE t1m, t1n SET m = 2, e = 3 WHERE n = f;
error ER_BINLOG_ENGINES_INCOMPATIBLE;
UPDATE t1n, t1b SET e = 2, b = 3 WHERE f = c;

TRUNCATE t1m;
TRUNCATE t1b;
TRUNCATE t1n;

source include/show_binlog_events.inc;

DROP TABLE t1m, t1b, t1n;


--- 1.229/sql/set_var.cc	2007-05-23 20:28:37 +02:00
+++ 1.230/sql/set_var.cc	2007-05-23 20:28:37 +02:00
@@ -1343,16 +1343,6 @@
     my_error(ER_STORED_FUNCTION_PREVENTS_SWITCH_BINLOG_FORMAT, MYF(0));
     return 1;    
   }
-#ifdef HAVE_NDB_BINLOG
-  /*
-    Cluster does not support changing the binlog format on the fly yet.
-  */
-  if (opt_bin_log && (have_ndbcluster == SHOW_OPTION_YES))
-  {
-    my_error(ER_NDB_CANT_SWITCH_BINLOG_FORMAT, MYF(0));
-    return 1;
-  }
-#endif /* HAVE_NDB_BINLOG */
   return sys_var_thd_enum::is_readonly();
 }
 

--- 1.45/storage/federated/ha_federated.h	2007-05-23 20:28:37 +02:00
+++ 1.46/storage/federated/ha_federated.h	2007-05-23 20:28:37 +02:00
@@ -128,6 +128,7 @@
     /* fix server to be able to get remote server table flags */
     return (HA_PRIMARY_KEY_IN_READ_INDEX | HA_FILE_BASED
             | HA_REC_NOT_IN_SEQ | HA_AUTO_PART_KEY | HA_CAN_INDEX_BLOBS |
+            HA_BINLOG_ROW_CAPABLE | HA_BINLOG_STMT_CAPABLE |
             HA_NO_PREFIX_CHAR_KEYS | HA_PRIMARY_KEY_REQUIRED_FOR_DELETE |
             HA_PARTIAL_COLUMN_READ | HA_NULL_IN_KEY);
   }
Thread
bk commit into 5.1 tree (mats:1.2579)Mats Kindahl23 May