Loading mysql-test/include/show_binlog_events.inc 0 → 100644 +4 −0 Original line number Diff line number Diff line --let $binlog_start=102 --replace_result $binlog_start <binlog_start> --replace_column 2 # 4 # 5 # --eval show binlog events from $binlog_start mysql-test/r/ndb_binlog_ddl_multi.result +67 −2 Original line number Diff line number Diff line drop database if exists mysqltest; drop table if exists t1,t2; drop table if exists t1,t2,t3; drop database if exists mysqltest; drop table if exists t1,t2; drop table if exists t1,t2,t3; reset master; reset master; create database mysqltest; Loading Loading @@ -123,3 +123,68 @@ master-bin1.000001 # Table_map # # cluster.apply_status master-bin1.000001 # Write_rows # # master-bin1.000001 # Query # # COMMIT master-bin1.000001 # Query # # use `test`; drop table `t1` reset master; show tables; Tables_in_test reset master; show tables; Tables_in_test create table t1 (a int key) engine=ndb; create table t2 (a int key) engine=ndb; create table t3 (a int key) engine=ndb; rename table t3 to t4, t2 to t3, t1 to t2, t4 to t1; show binlog events from <binlog_start>; Log_name Pos Event_type Server_id End_log_pos Info master-bin1.000001 # Query # # use `test`; create table t1 (a int key) engine=ndb master-bin1.000001 # Query # # use `test`; create table t2 (a int key) engine=ndb master-bin1.000001 # Query # # use `test`; create table t3 (a int key) engine=ndb master-bin1.000001 # Query # # BEGIN master-bin1.000001 # Table_map # # cluster.apply_status master-bin1.000001 # Write_rows # # master-bin1.000001 # Query # # COMMIT master-bin1.000001 # Query # # use `test`; rename table `test.t3` to `test.t4` master-bin1.000001 # Query # # BEGIN master-bin1.000001 # Table_map # # cluster.apply_status master-bin1.000001 # Write_rows # # master-bin1.000001 # Query # # COMMIT master-bin1.000001 # Query # # use `test`; rename table `test.t2` to `test.t3` master-bin1.000001 # Query # # BEGIN master-bin1.000001 # Table_map # # cluster.apply_status master-bin1.000001 # Write_rows # # master-bin1.000001 # Query # # COMMIT master-bin1.000001 # Query # # use `test`; rename table `test.t1` to `test.t2` master-bin1.000001 # Query # # BEGIN master-bin1.000001 # Table_map # # cluster.apply_status master-bin1.000001 # Write_rows # # master-bin1.000001 # Query # # COMMIT master-bin1.000001 # Query # # use `test`; rename table `test.t4` to `test.t1` drop table t1; drop table t2; drop table t3; reset master; show tables; Tables_in_test reset master; show tables; Tables_in_test create table t1 (a int key) engine=ndb; insert into t1 values(1); rename table t1 to t2; insert into t2 values(2); show binlog events from <binlog_start>; Log_name Pos Event_type Server_id End_log_pos Info master-bin1.000001 # Query # # use `test`; create table t1 (a int key) engine=ndb master-bin1.000001 # Query # # BEGIN master-bin1.000001 # Table_map # # cluster.apply_status master-bin1.000001 # Write_rows # # master-bin1.000001 # Table_map # # test.t1 master-bin1.000001 # Write_rows # # master-bin1.000001 # Query # # COMMIT master-bin1.000001 # Query # # use `test`; rename table `test.t1` to `test.t2` master-bin1.000001 # Query # # BEGIN master-bin1.000001 # Table_map # # cluster.apply_status master-bin1.000001 # Write_rows # # master-bin1.000001 # Table_map # # test.t2 master-bin1.000001 # Write_rows # # master-bin1.000001 # Query # # COMMIT drop table t2; mysql-test/t/ndb_binlog_ddl_multi.test +54 −20 Original line number Diff line number Diff line Loading @@ -5,18 +5,16 @@ --disable_warnings connection server2; drop database if exists mysqltest; drop table if exists t1,t2; drop table if exists t1,t2,t3; connection server1; drop database if exists mysqltest; drop table if exists t1,t2; drop table if exists t1,t2,t3; --connection server1 reset master; --connection server2 reset master; --enable_warnings --let $binlog_start=102 # # basic test to see if ddl distribution works across # multiple binlogs Loading @@ -33,15 +31,10 @@ create table t1 (a int primary key) engine=ndb; --connection server2 create table t2 (a int primary key) engine=ndb; --replace_result $binlog_start <binlog_start> --replace_column 2 # 4 # 5 # --eval show binlog events from $binlog_start --source include/show_binlog_events.inc --connection server1 --replace_result $binlog_start <binlog_start> --replace_column 2 # 4 # 5 # --eval show binlog events from $binlog_start -- source include/show_binlog_events.inc # alter table --connection server1 Loading @@ -53,9 +46,7 @@ reset master; alter table t2 add column (b int); --connections server1 --replace_result $binlog_start <binlog_start> --replace_column 2 # 4 # 5 # --eval show binlog events from $binlog_start --source include/show_binlog_events.inc # alter database Loading Loading @@ -91,9 +82,7 @@ drop database mysqltest; create table t1 (a int primary key) engine=ndb; --connection server2 --replace_result $binlog_start <binlog_start> --replace_column 2 # 4 # 5 # --eval show binlog events from $binlog_start --source include/show_binlog_events.inc --connection server2 drop table t2; Loading Loading @@ -144,6 +133,51 @@ ENGINE =NDB; drop table t1; --connection server2 --replace_result $binlog_start <binlog_start> --replace_column 2 # 4 # 5 # --eval show binlog events from $binlog_start --source include/show_binlog_events.inc # # Bug #17827 cluster: rename of several tables in one statement, # gets multiply logged # --connection server1 reset master; show tables; --connection server2 reset master; show tables; --connection server1 create table t1 (a int key) engine=ndb; create table t2 (a int key) engine=ndb; create table t3 (a int key) engine=ndb; rename table t3 to t4, t2 to t3, t1 to t2, t4 to t1; --connection server2 --source include/show_binlog_events.inc drop table t1; drop table t2; drop table t3; # # Bug #17838 binlog not setup on seconday master after rename # # --connection server1 reset master; show tables; --connection server2 reset master; show tables; --connection server1 create table t1 (a int key) engine=ndb; insert into t1 values(1); rename table t1 to t2; insert into t2 values(2); # now we should see data in table t1 _and_ t2 # prior to bug fix, data was missing for t2 --connection server2 --source include/show_binlog_events.inc drop table t2; sql/ha_ndbcluster.cc +6 −4 Original line number Diff line number Diff line Loading @@ -1367,15 +1367,17 @@ int ha_ndbcluster::drop_indexes(Ndb *ndb, TABLE *tab) */ NDB_INDEX_TYPE ha_ndbcluster::get_index_type_from_table(uint inx) const { return get_index_type_from_key(inx, table_share->key_info); return get_index_type_from_key(inx, table_share->key_info, inx == table_share->primary_key); } NDB_INDEX_TYPE ha_ndbcluster::get_index_type_from_key(uint inx, KEY *key_info) const KEY *key_info, bool primary) const { bool is_hash_index= (key_info[inx].algorithm == HA_KEY_ALG_HASH); if (inx == table_share->primary_key) if (primary) return is_hash_index ? PRIMARY_KEY_INDEX : PRIMARY_KEY_ORDERED_INDEX; return ((key_info[inx].flags & HA_NOSAME) ? Loading Loading @@ -4644,7 +4646,7 @@ int ha_ndbcluster::add_index(TABLE *table_arg, KEY *key= key_info + idx; KEY_PART_INFO *key_part= key->key_part; KEY_PART_INFO *end= key_part + key->key_parts; NDB_INDEX_TYPE idx_type= get_index_type_from_key(idx, key); NDB_INDEX_TYPE idx_type= get_index_type_from_key(idx, key, false); DBUG_PRINT("info", ("Adding index: '%s'", key_info[idx].name)); // Add fields to key_part struct for (; key_part != end; key_part++) Loading sql/ha_ndbcluster.h +2 −1 Original line number Diff line number Diff line Loading @@ -719,7 +719,8 @@ static void set_tabname(const char *pathname, char *tabname); void release_metadata(); NDB_INDEX_TYPE get_index_type(uint idx_no) const; NDB_INDEX_TYPE get_index_type_from_table(uint index_no) const; NDB_INDEX_TYPE get_index_type_from_key(uint index_no, KEY *key_info) const; NDB_INDEX_TYPE get_index_type_from_key(uint index_no, KEY *key_info, bool primary) const; int check_index_fields_not_null(uint index_no); uint set_up_partition_info(partition_info *part_info, Loading Loading
mysql-test/include/show_binlog_events.inc 0 → 100644 +4 −0 Original line number Diff line number Diff line --let $binlog_start=102 --replace_result $binlog_start <binlog_start> --replace_column 2 # 4 # 5 # --eval show binlog events from $binlog_start
mysql-test/r/ndb_binlog_ddl_multi.result +67 −2 Original line number Diff line number Diff line drop database if exists mysqltest; drop table if exists t1,t2; drop table if exists t1,t2,t3; drop database if exists mysqltest; drop table if exists t1,t2; drop table if exists t1,t2,t3; reset master; reset master; create database mysqltest; Loading Loading @@ -123,3 +123,68 @@ master-bin1.000001 # Table_map # # cluster.apply_status master-bin1.000001 # Write_rows # # master-bin1.000001 # Query # # COMMIT master-bin1.000001 # Query # # use `test`; drop table `t1` reset master; show tables; Tables_in_test reset master; show tables; Tables_in_test create table t1 (a int key) engine=ndb; create table t2 (a int key) engine=ndb; create table t3 (a int key) engine=ndb; rename table t3 to t4, t2 to t3, t1 to t2, t4 to t1; show binlog events from <binlog_start>; Log_name Pos Event_type Server_id End_log_pos Info master-bin1.000001 # Query # # use `test`; create table t1 (a int key) engine=ndb master-bin1.000001 # Query # # use `test`; create table t2 (a int key) engine=ndb master-bin1.000001 # Query # # use `test`; create table t3 (a int key) engine=ndb master-bin1.000001 # Query # # BEGIN master-bin1.000001 # Table_map # # cluster.apply_status master-bin1.000001 # Write_rows # # master-bin1.000001 # Query # # COMMIT master-bin1.000001 # Query # # use `test`; rename table `test.t3` to `test.t4` master-bin1.000001 # Query # # BEGIN master-bin1.000001 # Table_map # # cluster.apply_status master-bin1.000001 # Write_rows # # master-bin1.000001 # Query # # COMMIT master-bin1.000001 # Query # # use `test`; rename table `test.t2` to `test.t3` master-bin1.000001 # Query # # BEGIN master-bin1.000001 # Table_map # # cluster.apply_status master-bin1.000001 # Write_rows # # master-bin1.000001 # Query # # COMMIT master-bin1.000001 # Query # # use `test`; rename table `test.t1` to `test.t2` master-bin1.000001 # Query # # BEGIN master-bin1.000001 # Table_map # # cluster.apply_status master-bin1.000001 # Write_rows # # master-bin1.000001 # Query # # COMMIT master-bin1.000001 # Query # # use `test`; rename table `test.t4` to `test.t1` drop table t1; drop table t2; drop table t3; reset master; show tables; Tables_in_test reset master; show tables; Tables_in_test create table t1 (a int key) engine=ndb; insert into t1 values(1); rename table t1 to t2; insert into t2 values(2); show binlog events from <binlog_start>; Log_name Pos Event_type Server_id End_log_pos Info master-bin1.000001 # Query # # use `test`; create table t1 (a int key) engine=ndb master-bin1.000001 # Query # # BEGIN master-bin1.000001 # Table_map # # cluster.apply_status master-bin1.000001 # Write_rows # # master-bin1.000001 # Table_map # # test.t1 master-bin1.000001 # Write_rows # # master-bin1.000001 # Query # # COMMIT master-bin1.000001 # Query # # use `test`; rename table `test.t1` to `test.t2` master-bin1.000001 # Query # # BEGIN master-bin1.000001 # Table_map # # cluster.apply_status master-bin1.000001 # Write_rows # # master-bin1.000001 # Table_map # # test.t2 master-bin1.000001 # Write_rows # # master-bin1.000001 # Query # # COMMIT drop table t2;
mysql-test/t/ndb_binlog_ddl_multi.test +54 −20 Original line number Diff line number Diff line Loading @@ -5,18 +5,16 @@ --disable_warnings connection server2; drop database if exists mysqltest; drop table if exists t1,t2; drop table if exists t1,t2,t3; connection server1; drop database if exists mysqltest; drop table if exists t1,t2; drop table if exists t1,t2,t3; --connection server1 reset master; --connection server2 reset master; --enable_warnings --let $binlog_start=102 # # basic test to see if ddl distribution works across # multiple binlogs Loading @@ -33,15 +31,10 @@ create table t1 (a int primary key) engine=ndb; --connection server2 create table t2 (a int primary key) engine=ndb; --replace_result $binlog_start <binlog_start> --replace_column 2 # 4 # 5 # --eval show binlog events from $binlog_start --source include/show_binlog_events.inc --connection server1 --replace_result $binlog_start <binlog_start> --replace_column 2 # 4 # 5 # --eval show binlog events from $binlog_start -- source include/show_binlog_events.inc # alter table --connection server1 Loading @@ -53,9 +46,7 @@ reset master; alter table t2 add column (b int); --connections server1 --replace_result $binlog_start <binlog_start> --replace_column 2 # 4 # 5 # --eval show binlog events from $binlog_start --source include/show_binlog_events.inc # alter database Loading Loading @@ -91,9 +82,7 @@ drop database mysqltest; create table t1 (a int primary key) engine=ndb; --connection server2 --replace_result $binlog_start <binlog_start> --replace_column 2 # 4 # 5 # --eval show binlog events from $binlog_start --source include/show_binlog_events.inc --connection server2 drop table t2; Loading Loading @@ -144,6 +133,51 @@ ENGINE =NDB; drop table t1; --connection server2 --replace_result $binlog_start <binlog_start> --replace_column 2 # 4 # 5 # --eval show binlog events from $binlog_start --source include/show_binlog_events.inc # # Bug #17827 cluster: rename of several tables in one statement, # gets multiply logged # --connection server1 reset master; show tables; --connection server2 reset master; show tables; --connection server1 create table t1 (a int key) engine=ndb; create table t2 (a int key) engine=ndb; create table t3 (a int key) engine=ndb; rename table t3 to t4, t2 to t3, t1 to t2, t4 to t1; --connection server2 --source include/show_binlog_events.inc drop table t1; drop table t2; drop table t3; # # Bug #17838 binlog not setup on seconday master after rename # # --connection server1 reset master; show tables; --connection server2 reset master; show tables; --connection server1 create table t1 (a int key) engine=ndb; insert into t1 values(1); rename table t1 to t2; insert into t2 values(2); # now we should see data in table t1 _and_ t2 # prior to bug fix, data was missing for t2 --connection server2 --source include/show_binlog_events.inc drop table t2;
sql/ha_ndbcluster.cc +6 −4 Original line number Diff line number Diff line Loading @@ -1367,15 +1367,17 @@ int ha_ndbcluster::drop_indexes(Ndb *ndb, TABLE *tab) */ NDB_INDEX_TYPE ha_ndbcluster::get_index_type_from_table(uint inx) const { return get_index_type_from_key(inx, table_share->key_info); return get_index_type_from_key(inx, table_share->key_info, inx == table_share->primary_key); } NDB_INDEX_TYPE ha_ndbcluster::get_index_type_from_key(uint inx, KEY *key_info) const KEY *key_info, bool primary) const { bool is_hash_index= (key_info[inx].algorithm == HA_KEY_ALG_HASH); if (inx == table_share->primary_key) if (primary) return is_hash_index ? PRIMARY_KEY_INDEX : PRIMARY_KEY_ORDERED_INDEX; return ((key_info[inx].flags & HA_NOSAME) ? Loading Loading @@ -4644,7 +4646,7 @@ int ha_ndbcluster::add_index(TABLE *table_arg, KEY *key= key_info + idx; KEY_PART_INFO *key_part= key->key_part; KEY_PART_INFO *end= key_part + key->key_parts; NDB_INDEX_TYPE idx_type= get_index_type_from_key(idx, key); NDB_INDEX_TYPE idx_type= get_index_type_from_key(idx, key, false); DBUG_PRINT("info", ("Adding index: '%s'", key_info[idx].name)); // Add fields to key_part struct for (; key_part != end; key_part++) Loading
sql/ha_ndbcluster.h +2 −1 Original line number Diff line number Diff line Loading @@ -719,7 +719,8 @@ static void set_tabname(const char *pathname, char *tabname); void release_metadata(); NDB_INDEX_TYPE get_index_type(uint idx_no) const; NDB_INDEX_TYPE get_index_type_from_table(uint index_no) const; NDB_INDEX_TYPE get_index_type_from_key(uint index_no, KEY *key_info) const; NDB_INDEX_TYPE get_index_type_from_key(uint index_no, KEY *key_info, bool primary) const; int check_index_fields_not_null(uint index_no); uint set_up_partition_info(partition_info *part_info, Loading