diff --git a/mysql-test/suite/tianmu/r/issue1325.result b/mysql-test/suite/tianmu/r/issue1325.result new file mode 100644 index 0000000000..a6cd600add --- /dev/null +++ b/mysql-test/suite/tianmu/r/issue1325.result @@ -0,0 +1,159 @@ +include/master-slave.inc +[connection master] +DROP DATABASE IF EXISTS issue1325_test; +include/sync_slave_sql_with_master.inc +# on master: +CREATE DATABASE issue1325_test; +USE issue1325_test; +include/sync_slave_sql_with_master.inc +# on slave: +USE issue1325_test; +show databases; +Database +information_schema +cache +issue1325_test +mtr +mysql +performance_schema +sys +sys_tianmu +test +set global sql_mode='STRICT_TRANS_TABLES,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION,MANDATORY_TIANMU,NO_KEY_ERROR'; +# +# Secondary INDEX +# +# on master: +create table ttt(id int primary key,name varchar(10),key idx_name(name))engine=innodb; +drop table ttt; +create table ttt(id int primary key,name varchar(10))engine=innodb; +create index idx_name on ttt(name); +drop index idx_name on ttt; +show create table ttt; +Table Create Table +ttt CREATE TABLE `ttt` ( + `id` int(11) NOT NULL, + `name` varchar(10) DEFAULT NULL, + PRIMARY KEY (`id`) +) ENGINE=InnoDB DEFAULT CHARSET=latin1 +include/sync_slave_sql_with_master.inc +# on slave: +# on master: +show create table ttt; +Table Create Table +ttt CREATE TABLE `ttt` ( + `id` int(11) NOT NULL, + `name` varchar(10) DEFAULT NULL, + PRIMARY KEY (`id`) +) ENGINE=InnoDB DEFAULT CHARSET=latin1 +# +# UNIQUE INDEX +# +# on master: +create table xxx(id int,name varchar(10),unique key idx_id(id))engine=innodb; +drop table xxx; +create table xxx(id int,name varchar(10))engine=innodb; +create unique index idx_id on xxx(id); +drop index idx_id on xxx; +show create table xxx; +Table Create Table +xxx CREATE TABLE `xxx` ( + `id` int(11) DEFAULT NULL, + `name` varchar(10) DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=latin1 +include/sync_slave_sql_with_master.inc +# on slave: +show create table xxx; +Table Create Table +xxx CREATE TABLE `xxx` ( + `id` int(11) DEFAULT NULL, + `name` varchar(10) DEFAULT NULL +) ENGINE=TIANMU DEFAULT CHARSET=latin1 +# +# Full-text index +# +# on master: +drop table ttt; +create table ttt(id int primary key,name text,fulltext key idx_name(name))engine=innodb; +drop table ttt; +create table ttt(id int primary key,name text)engine=innodb; +create fulltext index idx_name on ttt(name); +Warnings: +Warning 124 InnoDB rebuilding table to add column FTS_DOC_ID +show create table ttt; +Table Create Table +ttt CREATE TABLE `ttt` ( + `id` int(11) NOT NULL, + `name` text, + PRIMARY KEY (`id`), + FULLTEXT KEY `idx_name` (`name`) +) ENGINE=InnoDB DEFAULT CHARSET=latin1 +include/sync_slave_sql_with_master.inc +# on slave: +show create table ttt; +Table Create Table +ttt CREATE TABLE `ttt` ( + `id` int(11) NOT NULL, + `name` text, + PRIMARY KEY (`id`), + FULLTEXT KEY `idx_name` (`name`) +) ENGINE=TIANMU DEFAULT CHARSET=latin1 +# +# foreign key +# +# on master: +CREATE TABLE student +(id int (11) primary key, +name char(10), +sex char(100), +age int(11) +)engine=innodb; +create table student_score +(id int primary key, +class varchar(10), +score char(100), +student_id int, +address text, +unique key idx_uk(class), +key idx_score(score), +fulltext key idx_address(address), +constraint s_id foreign key (student_id) references student(id) +)engine=innodb; +drop index idx_uk on student_score; +drop index idx_score on student_score; +include/sync_slave_sql_with_master.inc +# on slave: +show tables; +Tables_in_issue1325_test +student +student_score +ttt +xxx +show create table student_score; +Table Create Table +student_score CREATE TABLE `student_score` ( + `id` int(11) NOT NULL, + `class` varchar(10) DEFAULT NULL, + `score` char(100) DEFAULT NULL, + `student_id` int(11) DEFAULT NULL, + `address` text, + PRIMARY KEY (`id`), + KEY `s_id` (`student_id`), + FULLTEXT KEY `idx_address` (`address`) +) ENGINE=TIANMU DEFAULT CHARSET=latin1 +# on master: +DROP DATABASE issue1325_test; +include/sync_slave_sql_with_master.inc +# on slave: +show databases; +Database +information_schema +cache +mtr +mysql +performance_schema +sys +sys_tianmu +test +tianmu_data +stop slave; diff --git a/mysql-test/suite/tianmu/t/issue1325.test b/mysql-test/suite/tianmu/t/issue1325.test new file mode 100644 index 0000000000..128ebe1677 --- /dev/null +++ b/mysql-test/suite/tianmu/t/issue1325.test @@ -0,0 +1,121 @@ +--source include/have_tianmu.inc +--source include/have_binlog_format_row.inc + +--disable_warnings +-- source include/master-slave.inc +DROP DATABASE IF EXISTS issue1325_test; +--enable_warnings + +--source include/sync_slave_sql_with_master.inc + +connection master; +--echo # on master: + +CREATE DATABASE issue1325_test; + +USE issue1325_test; + +--source include/sync_slave_sql_with_master.inc +--echo # on slave: +USE issue1325_test; +show databases; +--disable_warnings +set global sql_mode='STRICT_TRANS_TABLES,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION,MANDATORY_TIANMU,NO_KEY_ERROR'; +--enable_warnings + +--echo # +--echo # Secondary INDEX +--echo # + +connection master; +--echo # on master: + +create table ttt(id int primary key,name varchar(10),key idx_name(name))engine=innodb; +drop table ttt; +create table ttt(id int primary key,name varchar(10))engine=innodb; +create index idx_name on ttt(name); +drop index idx_name on ttt; +show create table ttt; + +--source include/sync_slave_sql_with_master.inc +--echo # on slave: +connection master; +--echo # on master: +show create table ttt; + +--echo # +--echo # UNIQUE INDEX +--echo # +connection master; +--echo # on master: + +create table xxx(id int,name varchar(10),unique key idx_id(id))engine=innodb; +drop table xxx; +create table xxx(id int,name varchar(10))engine=innodb; +create unique index idx_id on xxx(id); +drop index idx_id on xxx; +show create table xxx; + +--source include/sync_slave_sql_with_master.inc +--echo # on slave: +show create table xxx; + + +--echo # +--echo # Full-text index +--echo # +connection master; +--echo # on master: +drop table ttt; +create table ttt(id int primary key,name text,fulltext key idx_name(name))engine=innodb; +drop table ttt; +create table ttt(id int primary key,name text)engine=innodb; +create fulltext index idx_name on ttt(name); + +show create table ttt; +--source include/sync_slave_sql_with_master.inc +--echo # on slave: +show create table ttt; + + +--echo # +--echo # foreign key +--echo # +connection master; +--echo # on master: +CREATE TABLE student +(id int (11) primary key, + name char(10), + sex char(100), + age int(11) +)engine=innodb; + +create table student_score +(id int primary key, + class varchar(10), + score char(100), + student_id int, + address text, + unique key idx_uk(class), + key idx_score(score), + fulltext key idx_address(address), + constraint s_id foreign key (student_id) references student(id) +)engine=innodb; + +drop index idx_uk on student_score; +drop index idx_score on student_score; + +--source include/sync_slave_sql_with_master.inc +--echo # on slave: +show tables; + +show create table student_score; + +connection master; +--echo # on master: +DROP DATABASE issue1325_test; + +--source include/sync_slave_sql_with_master.inc +--echo # on slave: +show databases; +stop slave; diff --git a/sql/auth/sql_authorization.cc b/sql/auth/sql_authorization.cc index 6167d0e068..b946b1d64a 100644 --- a/sql/auth/sql_authorization.cc +++ b/sql/auth/sql_authorization.cc @@ -4389,9 +4389,11 @@ bool check_fk_parent_table_access(THD *thd, // Return if engine does not support Foreign key Constraint. if (!ha_check_storage_engine_flag(db_type, HTON_SUPPORTS_FOREIGN_KEYS)) { + sql_mode_t sql_mode = thd->variables.sql_mode; + if(thd->slave_thread) sql_mode = global_system_variables.sql_mode; if (db_type == tianmu_hton && (alter_info->flags & Alter_info::ADD_FOREIGN_KEY) && - (!(thd->variables.sql_mode & MODE_NO_KEY_ERROR))) { + (!(sql_mode & MODE_NO_KEY_ERROR))) { my_error(ER_TIANMU_NOT_SUPPORTED_FOREIGN_KEY, MYF(0)); return true; } diff --git a/sql/log_event.cc b/sql/log_event.cc index 852d969bb5..f1e657490c 100644 --- a/sql/log_event.cc +++ b/sql/log_event.cc @@ -4975,7 +4975,7 @@ int Query_log_event::do_apply_event(Relay_log_info const *rli, /* Tianmu engine as slave: ignore some errors */ - else if(ER_TIANMU_NOT_SUPPORTED_SECONDARY_INDEX == actual_error + /*else if(ER_TIANMU_NOT_SUPPORTED_SECONDARY_INDEX == actual_error || ER_TIANMU_NOT_SUPPORTED_UNIQUE_INDEX == actual_error || ER_TIANMU_NOT_SUPPORTED_FULLTEXT_INDEX == actual_error || ER_TIANMU_NOT_SUPPORTED_TRIGGER == actual_error @@ -4985,7 +4985,7 @@ int Query_log_event::do_apply_event(Relay_log_info const *rli, DBUG_PRINT("info",("error ignored")); clear_all_errors(thd, const_cast(rli)); thd->killed= THD::NOT_KILLED; - } + }*/ /* Other cases: mostly we expected no error and get one. */ diff --git a/sql/sql_table.cc b/sql/sql_table.cc index 9d87a11bed..c0521884c7 100644 --- a/sql/sql_table.cc +++ b/sql/sql_table.cc @@ -3934,16 +3934,18 @@ mysql_prepare_create_table(THD *thd, const char *error_schema_name, (*key_count)++; tmp=file->max_key_parts(); + sql_mode_t sql_mode = thd->variables.sql_mode; + if(thd->slave_thread) sql_mode = global_system_variables.sql_mode; if ((create_info->db_type->db_type == DB_TYPE_TIANMU)) { if ((file->ha_table_flags() & HA_NON_SECONDARY_KEY) && (key->type == KEYTYPE_MULTIPLE) && - !(thd->variables.sql_mode & MODE_NO_KEY_ERROR)) { + !(sql_mode & MODE_NO_KEY_ERROR)) { my_error(ER_TIANMU_NOT_SUPPORTED_SECONDARY_INDEX, MYF(0)); DBUG_RETURN(TRUE); } if ((file->ha_table_flags() & HA_NON_UNIQUE_KEY) && (key->type == KEYTYPE_UNIQUE) && - (!(thd->variables.sql_mode & MODE_NO_KEY_ERROR))) { + (!(sql_mode & MODE_NO_KEY_ERROR))) { my_error(ER_TIANMU_NOT_SUPPORTED_UNIQUE_INDEX, MYF(0)); DBUG_RETURN(TRUE); } @@ -4080,15 +4082,19 @@ mysql_prepare_create_table(THD *thd, const char *error_schema_name, MYF(0)); DBUG_RETURN(TRUE); } - if ((create_info->db_type->db_type == DB_TYPE_TIANMU) && - (!(thd->variables.sql_mode & MODE_NO_KEY_ERROR))) { - my_message(ER_TIANMU_NOT_SUPPORTED_FULLTEXT_INDEX, - ER(ER_TIANMU_NOT_SUPPORTED_FULLTEXT_INDEX), MYF(0)); + if (create_info->db_type->db_type == DB_TYPE_TIANMU){ + sql_mode_t sql_mode = thd->variables.sql_mode; + if(thd->slave_thread) sql_mode = global_system_variables.sql_mode; + if(!(sql_mode & MODE_NO_KEY_ERROR)) { + my_message(ER_TIANMU_NOT_SUPPORTED_FULLTEXT_INDEX, + ER(ER_TIANMU_NOT_SUPPORTED_FULLTEXT_INDEX), MYF(0)); + DBUG_RETURN(TRUE); + } } else { my_message(ER_TABLE_CANT_HANDLE_FT, ER(ER_TABLE_CANT_HANDLE_FT), MYF(0)); + DBUG_RETURN(TRUE); } - DBUG_RETURN(TRUE); } } /* @@ -8493,11 +8499,13 @@ mysql_prepare_alter_table(THD *thd, TABLE *table, // Now this contains only DROP for foreign keys and not-found objects Alter_drop *drop; drop_it.rewind(); + sql_mode_t sql_mode = thd->variables.sql_mode; + if(thd->slave_thread) sql_mode = global_system_variables.sql_mode; while ((drop=drop_it++)) { switch (drop->type) { case Alter_drop::KEY: if ((create_info->db_type->db_type == DB_TYPE_TIANMU) && - (!(thd->variables.sql_mode & MODE_NO_KEY_ERROR))) { + (!(sql_mode & MODE_NO_KEY_ERROR))) { my_error(ER_TIANMU_NOT_FOUND_INDEX, MYF(0)); goto err; } @@ -8508,7 +8516,7 @@ mysql_prepare_alter_table(THD *thd, TABLE *table, goto err; case Alter_drop::FOREIGN_KEY: if ((create_info->db_type->db_type == DB_TYPE_TIANMU) && - (!(thd->variables.sql_mode & MODE_NO_KEY_ERROR))) { + (!(sql_mode & MODE_NO_KEY_ERROR))) { my_error(ER_TIANMU_NOT_SUPPORTED_FOREIGN_KEY, MYF(0)); } break; @@ -8522,14 +8530,18 @@ mysql_prepare_alter_table(THD *thd, TABLE *table, } if (rename_key_list.elements) { - if ((create_info->db_type->db_type == DB_TYPE_TIANMU) && - (!(thd->variables.sql_mode & MODE_NO_KEY_ERROR))) { - my_error(ER_TIANMU_NOT_FOUND_INDEX, MYF(0)); + if (create_info->db_type->db_type == DB_TYPE_TIANMU){ + sql_mode_t sql_mode = thd->variables.sql_mode; + if(thd->slave_thread) sql_mode = global_system_variables.sql_mode; + if(!(sql_mode & MODE_NO_KEY_ERROR)){ + my_error(ER_TIANMU_NOT_FOUND_INDEX, MYF(0)); + goto err; + } } else { my_error(ER_KEY_DOES_NOT_EXITS, MYF(0), rename_key_list.head()->old_name, table->s->table_name.str); + goto err; } - goto err; } if (!create_info->comment.str) diff --git a/sql/sql_trigger.cc b/sql/sql_trigger.cc index ccafc6dae8..8503f33fba 100644 --- a/sql/sql_trigger.cc +++ b/sql/sql_trigger.cc @@ -226,10 +226,13 @@ bool mysql_create_or_drop_trigger(THD *thd, TABLE_LIST *tables, bool create) } table= tables->table; table->pos_in_table_list= tables; - if ((table->file && table->file->ht == tianmu_hton) && - (!(thd->variables.sql_mode & MODE_NO_KEY_ERROR))) { - my_error(ER_TIANMU_NOT_SUPPORTED_TRIGGER, MYF(0)); - goto end; + if ((table->file && table->file->ht == tianmu_hton)){ + sql_mode_t sql_mode = thd->variables.sql_mode; + if(thd->slave_thread) sql_mode = global_system_variables.sql_mode; + if(!(sql_mode & MODE_NO_KEY_ERROR)) { + my_error(ER_TIANMU_NOT_SUPPORTED_TRIGGER, MYF(0)); + goto end; + } } /* Later on we will need it to downgrade the lock */ diff --git a/storage/tianmu/handler/ha_tianmu.cpp b/storage/tianmu/handler/ha_tianmu.cpp index ae1e63b696..b1e6b9a823 100644 --- a/storage/tianmu/handler/ha_tianmu.cpp +++ b/storage/tianmu/handler/ha_tianmu.cpp @@ -1683,11 +1683,14 @@ enum_alter_inplace_result ha_tianmu::check_if_supported_inplace_alter([[maybe_un ha_alter_info->handler_flags & Alter_inplace_info::DROP_PK_INDEX) DBUG_RETURN(HA_ALTER_INPLACE_NOT_SUPPORTED); // support alter table: mix add/drop key + sql_mode_t sql_mode = ha_thd()->variables.sql_mode; + if(ha_thd()->slave_thread) + sql_mode = global_system_variables.sql_mode; if ((ha_alter_info->handler_flags & Alter_inplace_info::ADD_INDEX || ha_alter_info->handler_flags & Alter_inplace_info::DROP_INDEX || ha_alter_info->handler_flags & Alter_inplace_info::ADD_UNIQUE_INDEX || ha_alter_info->handler_flags & Alter_inplace_info::DROP_UNIQUE_INDEX) && - (ha_thd()->variables.sql_mode & MODE_NO_KEY_ERROR)) + (sql_mode & MODE_NO_KEY_ERROR)) DBUG_RETURN(HA_ALTER_INPLACE_NOT_SUPPORTED); DBUG_RETURN(HA_ALTER_ERROR);