List:Commits« Previous MessageNext Message »
From:Li-Bing.Song Date:November 23 2010 9:19am
Subject:bzr commit into mysql-trunk branch (Li-Bing.Song:3350) Bug#48183
View as plain text  
#At file:///home/anders/Work/bzrwork/wt4/mysql-trunk-bugfixing/ based on revid:dao-gang.qu@stripped

 3350 Li-Bing.Song@stripped	2010-11-23
      Bug#48183 statements using fulltext parser plugins should be marked unsafe
      
      Any use of plugins that could affect rows in a table should be marked unsafe
      because it cannot be determined that the statement will have the same effect
      on the slave. For example, UDFs are currently marked unsafe.  However, use of
      fulltext parser plugins is currently not marked as unsafe.
      
      After this patch, any statement which uses fulltext parser plugins is marked
      unsafe.
     @ mysql-test/suite/binlog/t/binlog_stm_unsafe_warning-master.opt
        Add SIMPLE_PARSER_OPT option.
     @ mysql-test/suite/binlog/t/binlog_stm_unsafe_warning.test
        Add test for this bug.
     @ sql/share/errmsg-utf8.txt
        Add ER_BINLOG_UNSAFE_PLUGIN.
     @ sql/sql_base.cc
        Mark current statement is unsafe when setup fulltext parsers.
     @ sql/sql_class.h
        Add auxiliary function to set binlog_unsafe_warning_flags.
     @ sql/sql_lex.cc
        Initilaize unsafe plugin error message.
     @ sql/sql_lex.h
        Add unsafe type BINLOG_STMT_UNSAFE_PLUGIN.

    modified:
      mysql-test/suite/binlog/r/binlog_stm_unsafe_warning.result
      mysql-test/suite/binlog/t/binlog_stm_unsafe_warning-master.opt
      mysql-test/suite/binlog/t/binlog_stm_unsafe_warning.test
      sql/share/errmsg-utf8.txt
      sql/sql_base.cc
      sql/sql_class.h
      sql/sql_lex.cc
      sql/sql_lex.h
=== modified file 'mysql-test/suite/binlog/r/binlog_stm_unsafe_warning.result'
--- a/mysql-test/suite/binlog/r/binlog_stm_unsafe_warning.result	2010-08-10 11:58:46 +0000
+++ b/mysql-test/suite/binlog/r/binlog_stm_unsafe_warning.result	2010-11-23 09:19:35 +0000
@@ -94,3 +94,21 @@ Note	1592	Unsafe statement written to th
 DROP FUNCTION sf_bug50192;
 DROP TRIGGER tr_bug50192;
 DROP TABLE t1, t2;
+
+# BUG#48183 statements using fulltext parser plugins should be marked unsafe
+INSTALL PLUGIN simple_parser SONAME 'mypluglib.so';
+
+CREATE TABLE t1 (a TEXT, FULLTEXT(a) WITH PARSER simple_parser);
+CREATE TABLE t2 (a TEXT, FULLTEXT(a));
+CREATE TABLE t3 (a TEXT);
+
+# It should generate an unsafe warning
+INSERT INTO t3 SELECT * FROM t1 WHERE MATCH (a) AGAINST ('test');
+Warnings:
+Note	1592	Unsafe statement written to the binary log using statement format since BINLOG_FORMAT = STATEMENT. Statement is unsafe because it uses a plugin which may not return the same value on the slave.
+
+# It should not generate an unsafe warning
+INSERT INTO t3 SELECT * FROM t2 WHERE MATCH (a) AGAINST ('test');
+
+DROP TABLE t1, t2, t3;
+UNINSTALL PLUGIN simple_parser;

=== modified file 'mysql-test/suite/binlog/t/binlog_stm_unsafe_warning-master.opt'
--- a/mysql-test/suite/binlog/t/binlog_stm_unsafe_warning-master.opt	2009-07-31 13:00:35 +0000
+++ b/mysql-test/suite/binlog/t/binlog_stm_unsafe_warning-master.opt	2010-11-23 09:19:35 +0000
@@ -1 +1,2 @@
 --binlog-ignore-db=b42851 --log-error
+$SIMPLE_PARSER_OPT

=== modified file 'mysql-test/suite/binlog/t/binlog_stm_unsafe_warning.test'
--- a/mysql-test/suite/binlog/t/binlog_stm_unsafe_warning.test	2010-08-10 11:58:46 +0000
+++ b/mysql-test/suite/binlog/t/binlog_stm_unsafe_warning.test	2010-11-23 09:19:35 +0000
@@ -168,3 +168,25 @@ SHOW WARNINGS;
 DROP FUNCTION sf_bug50192;
 DROP TRIGGER tr_bug50192;
 DROP TABLE t1, t2;
+
+--echo
+--echo # BUG#48183 statements using fulltext parser plugins should be marked unsafe
+--source include/have_simple_parser.inc
+
+INSTALL PLUGIN simple_parser SONAME 'mypluglib.so';
+
+--echo
+CREATE TABLE t1 (a TEXT, FULLTEXT(a) WITH PARSER simple_parser);
+CREATE TABLE t2 (a TEXT, FULLTEXT(a));
+CREATE TABLE t3 (a TEXT);
+
+--echo
+--echo # It should generate an unsafe warning
+INSERT INTO t3 SELECT * FROM t1 WHERE MATCH (a) AGAINST ('test');
+--echo
+--echo # It should not generate an unsafe warning
+INSERT INTO t3 SELECT * FROM t2 WHERE MATCH (a) AGAINST ('test');
+
+--echo
+DROP TABLE t1, t2, t3;
+UNINSTALL PLUGIN simple_parser;
\ No newline at end of file

=== modified file 'sql/share/errmsg-utf8.txt'
--- a/sql/share/errmsg-utf8.txt	2010-10-29 09:43:58 +0000
+++ b/sql/share/errmsg-utf8.txt	2010-11-23 09:19:35 +0000
@@ -6439,3 +6439,6 @@ ER_SLAVE_HEARTBEAT_VALUE_OUT_OF_RANGE_MA
 ER_PARTITION_EXCHANGE_FOREIGN_KEY
   eng "Table to exchange with partition has foreign key references: '%-.64s'"
   swe "Tabellen att byta ut mot partition har foreign key referenser: '%-.64s'"
+
+ER_BINLOG_UNSAFE_PLUGIN
+  eng "Statement is unsafe because it uses a plugin which may not return the same value on the slave."

=== modified file 'sql/sql_base.cc'
--- a/sql/sql_base.cc	2010-10-25 12:13:13 +0000
+++ b/sql/sql_base.cc	2010-11-23 09:19:35 +0000
@@ -8791,7 +8791,7 @@ int setup_ftfuncs(SELECT_LEX *select_lex
   List_iterator<Item_func_match> li(*(select_lex->ftfunc_list)),
                                  lj(*(select_lex->ftfunc_list));
   Item_func_match *ftf, *ftf2;
-
+  THD *thd= current_thd;
   while ((ftf=li++))
   {
     if (ftf->fix_index())
@@ -8802,6 +8802,12 @@ int setup_ftfuncs(SELECT_LEX *select_lex
       if (ftf->eq(ftf2,1) && !ftf2->master)
         ftf2->master=ftf;
     }
+
+    /* Just like UDF, we don't know if plugin's funtions will output same value
+       on both master and slave, So the statement is marked unsafe.
+    */
+    if (ftf->table->key_info[ftf->key].parser)
+      thd->set_binlog_unsafe_warning_flags(LEX::BINLOG_STMT_UNSAFE_PLUGIN);
   }
 
   return 0;

=== modified file 'sql/sql_class.h'
--- a/sql/sql_class.h	2010-11-05 08:13:09 +0000
+++ b/sql/sql_class.h	2010-11-23 09:19:35 +0000
@@ -1624,6 +1624,10 @@ private:
   */
   uint binlog_table_maps;
 public:
+  void set_binlog_unsafe_warning_flags(LEX::enum_binlog_stmt_unsafe unsafe_type)
+  {
+    binlog_unsafe_warning_flags|= (1U << unsafe_type);
+  }
   void issue_unsafe_warnings();
 
   uint get_binlog_table_maps() const {

=== modified file 'sql/sql_lex.cc'
--- a/sql/sql_lex.cc	2010-11-10 11:26:45 +0000
+++ b/sql/sql_lex.cc	2010-11-23 09:19:35 +0000
@@ -58,7 +58,8 @@ Query_tables_list::binlog_stmt_unsafe_er
   ER_BINLOG_UNSAFE_SYSTEM_FUNCTION,
   ER_BINLOG_UNSAFE_NONTRANS_AFTER_TRANS,
   ER_BINLOG_UNSAFE_MULTIPLE_ENGINES_AND_SELF_LOGGING_ENGINE,
-  ER_BINLOG_UNSAFE_MIXED_STATEMENT
+  ER_BINLOG_UNSAFE_MIXED_STATEMENT,
+  ER_BINLOG_UNSAFE_PLUGIN,
 };
 
 

=== modified file 'sql/sql_lex.h'
--- a/sql/sql_lex.h	2010-11-10 11:26:45 +0000
+++ b/sql/sql_lex.h	2010-11-23 09:19:35 +0000
@@ -1189,6 +1189,11 @@ public:
     */
     BINLOG_STMT_UNSAFE_MIXED_STATEMENT,
 
+    /**
+       Using a plugin is unsafe.
+    */
+    BINLOG_STMT_UNSAFE_PLUGIN,
+
     /* The last element of this enumeration type. */
     BINLOG_STMT_UNSAFE_COUNT
   };


Attachment: [text/bzr-bundle] bzr/li-bing.song@sun.com-20101123091935-2xsc2k7yyi5tggr8.bundle
Thread
bzr commit into mysql-trunk branch (Li-Bing.Song:3350) Bug#48183Li-Bing.Song23 Nov
  • Re: bzr commit into mysql-trunk branch (Li-Bing.Song:3350) Bug#48183He Zhenxing29 Nov
  • Re: bzr commit into mysql-trunk branch (Li-Bing.Song:3350)Bug#48183Sergey Vojtovich29 Nov
    • Re: bzr commit into mysql-trunk branch (Li-Bing.Song:3350) Bug#48183Libing Song1 Dec
      • Re: bzr commit into mysql-trunk branch (Li-Bing.Song:3350)Bug#48183Sergey Vojtovich1 Dec
        • Re: bzr commit into mysql-trunk branch (Li-Bing.Song:3350) Bug#48183Libing Song2 Dec
          • Re: bzr commit into mysql-trunk branch (Li-Bing.Song:3350)Bug#48183Sergey Vojtovich2 Dec
            • Re: bzr commit into mysql-trunk branch (Li-Bing.Song:3350) Bug#48183Alfranio Correia2 Dec
              • Re: bzr commit into mysql-trunk branch (Li-Bing.Song:3350)Bug#48183Sergey Vojtovich2 Dec
            • Re: bzr commit into mysql-trunk branch (Li-Bing.Song:3350) Bug#48183Libing Song3 Dec