commit 649adbcc295187a98518045fe9c178ce86591d3f
Author: Sachin Setiya <sachinsetia1001@gmail.com>
Date:   Thu May 3 18:14:19 2018 +0530

    MDEV-14472 Assertion `is_current_stmt_binlog_format_row()' failed in...
    THD::binlog_write_table_map
    
    Commit Message it is really very long , will be added after review
    
    More-expermental features

diff --git a/mysql-test/suite/binlog/r/mdev_14472.result b/mysql-test/suite/binlog/r/mdev_14472.result
new file mode 100644
index 00000000000..0a2483678f1
--- /dev/null
+++ b/mysql-test/suite/binlog/r/mdev_14472.result
@@ -0,0 +1,12 @@
+CREATE TABLE t1 (f1 INT);
+CREATE TABLE t2 (f2 INT);
+CREATE TABLE t3 (f3 INT);
+CREATE TABLE t4 (pk INT AUTO_INCREMENT PRIMARY KEY);
+CREATE TRIGGER tr1 BEFORE INSERT ON t1 FOR EACH ROW INSERT INTO t2 VALUES ();
+CREATE TRIGGER tr2 AFTER INSERT ON t1 FOR EACH ROW INSERT INTO t3 VALUES ();
+CREATE TRIGGER tr3 BEFORE INSERT ON t2 FOR EACH ROW INSERT INTO t4 VALUES ();
+LOCK TABLE t1 WRITE;
+INSERT INTO t2 () VALUES ();
+INSERT INTO t3 VALUES ();
+UNLOCK TABLES;
+DROP TABLE t1, t2, t3, t4;
diff --git a/mysql-test/suite/binlog/t/mdev_14472.test b/mysql-test/suite/binlog/t/mdev_14472.test
new file mode 100644
index 00000000000..fd892a44f5c
--- /dev/null
+++ b/mysql-test/suite/binlog/t/mdev_14472.test
@@ -0,0 +1,22 @@
+--source include/have_log_bin.inc
+--source include/have_binlog_format_mixed.inc
+
+# Reproducible with MyISAM, InnoDB, Aria
+
+CREATE TABLE t1 (f1 INT);
+CREATE TABLE t2 (f2 INT);
+CREATE TABLE t3 (f3 INT);
+CREATE TABLE t4 (pk INT AUTO_INCREMENT PRIMARY KEY);
+
+CREATE TRIGGER tr1 BEFORE INSERT ON t1 FOR EACH ROW INSERT INTO t2 VALUES ();
+CREATE TRIGGER tr2 AFTER INSERT ON t1 FOR EACH ROW INSERT INTO t3 VALUES ();
+CREATE TRIGGER tr3 BEFORE INSERT ON t2 FOR EACH ROW INSERT INTO t4 VALUES ();
+
+LOCK TABLE t1 WRITE;
+INSERT INTO t2 () VALUES ();
+INSERT INTO t3 VALUES ();
+
+# Cleanup
+
+UNLOCK TABLES;
+DROP TABLE t1, t2, t3, t4;
diff --git a/sql/handler.cc b/sql/handler.cc
index 06c407b572a..7d96418e195 100644
--- a/sql/handler.cc
+++ b/sql/handler.cc
@@ -5650,7 +5650,12 @@ inline bool handler::check_table_binlog_row_based(bool binlog_row)
 {
   if (unlikely((table->in_use->variables.sql_log_bin_off)))
     return 0;                            /* Called by partitioning engine */
-  if (unlikely((!check_table_binlog_row_based_done)))
+  /* Dont use cached result when current binlog format is stmt */
+  if (unlikely(((check_table_binlog_row_based_result &&
+               !table->in_use->is_current_stmt_binlog_format_row()) ||
+               (!check_table_binlog_row_based_result &&
+               table->in_use->is_current_stmt_binlog_format_row()) ||
+                         !check_table_binlog_row_based_done)))
   {
     check_table_binlog_row_based_done= 1;
     check_table_binlog_row_based_result=
@@ -5933,8 +5938,7 @@ int handler::ha_reset()
   table->default_column_bitmaps();
   pushed_cond= NULL;
   tracker= NULL;
-  mark_trx_read_write_done= check_table_binlog_row_based_done=
-    check_table_binlog_row_based_result= 0;
+  mark_trx_read_write_done=0;
   /* Reset information about pushed engine conditions */
   cancel_pushed_idx_cond();
   /* Reset information about pushed index conditions */


On Sat, May 12, 2018 at 1:12 PM, Sachin Setiya <sachin.setiya@mariadb.com> wrote:

commit 25b6ae86a98fa0346f23e346a3e3cf2f59428129
Author: Sachin Setiya <sachinsetia1001@gmail.com>
Date:   Thu May 3 18:14:19 2018 +0530

    MDEV-14472 Assertion `is_current_stmt_binlog_format_row()' failed in...
    THD::binlog_write_table_map
    
    Commit Message it is really very long , will be added after review

diff --git a/mysql-test/suite/binlog/r/mdev_14472.result b/mysql-test/suite/binlog/r/mdev_14472.result
new file mode 100644
index 00000000000..0a2483678f1
--- /dev/null
+++ b/mysql-test/suite/binlog/r/mdev_14472.result
@@ -0,0 +1,12 @@
+CREATE TABLE t1 (f1 INT);
+CREATE TABLE t2 (f2 INT);
+CREATE TABLE t3 (f3 INT);
+CREATE TABLE t4 (pk INT AUTO_INCREMENT PRIMARY KEY);
+CREATE TRIGGER tr1 BEFORE INSERT ON t1 FOR EACH ROW INSERT INTO t2 VALUES ();
+CREATE TRIGGER tr2 AFTER INSERT ON t1 FOR EACH ROW INSERT INTO t3 VALUES ();
+CREATE TRIGGER tr3 BEFORE INSERT ON t2 FOR EACH ROW INSERT INTO t4 VALUES ();
+LOCK TABLE t1 WRITE;
+INSERT INTO t2 () VALUES ();
+INSERT INTO t3 VALUES ();
+UNLOCK TABLES;
+DROP TABLE t1, t2, t3, t4;
diff --git a/mysql-test/suite/binlog/t/mdev_14472.test b/mysql-test/suite/binlog/t/mdev_14472.test
new file mode 100644
index 00000000000..fd892a44f5c
--- /dev/null
+++ b/mysql-test/suite/binlog/t/mdev_14472.test
@@ -0,0 +1,22 @@
+--source include/have_log_bin.inc
+--source include/have_binlog_format_mixed.inc
+
+# Reproducible with MyISAM, InnoDB, Aria
+
+CREATE TABLE t1 (f1 INT);
+CREATE TABLE t2 (f2 INT);
+CREATE TABLE t3 (f3 INT);
+CREATE TABLE t4 (pk INT AUTO_INCREMENT PRIMARY KEY);
+
+CREATE TRIGGER tr1 BEFORE INSERT ON t1 FOR EACH ROW INSERT INTO t2 VALUES ();
+CREATE TRIGGER tr2 AFTER INSERT ON t1 FOR EACH ROW INSERT INTO t3 VALUES ();
+CREATE TRIGGER tr3 BEFORE INSERT ON t2 FOR EACH ROW INSERT INTO t4 VALUES ();
+
+LOCK TABLE t1 WRITE;
+INSERT INTO t2 () VALUES ();
+INSERT INTO t3 VALUES ();
+
+# Cleanup
+
+UNLOCK TABLES;
+DROP TABLE t1, t2, t3, t4;
diff --git a/sql/handler.cc b/sql/handler.cc
index 06c407b572a..c0c9d39856b 100644
--- a/sql/handler.cc
+++ b/sql/handler.cc
@@ -5650,7 +5650,10 @@ inline bool handler::check_table_binlog_row_based(bool binlog_row)
 {
   if (unlikely((table->in_use->variables.sql_log_bin_off)))
     return 0;                            /* Called by partitioning engine */
-  if (unlikely((!check_table_binlog_row_based_done)))
+  /* Dont use cached result when current binlog format is stmt */
+  if (unlikely(check_table_binlog_row_based_result &&
+              !table->in_use->is_current_stmt_binlog_format_row() ||
+               (!check_table_binlog_row_based_done)))
   {
     check_table_binlog_row_based_done= 1;
     check_table_binlog_row_based_result=
--
Regards
Sachin Setiya
Software Engineer at  MariaDB



--
Regards
Sachin Setiya
Software Engineer at  MariaDB