diff options
Diffstat (limited to 'mysql-test/suite/ndb')
157 files changed, 37727 insertions, 0 deletions
diff --git a/mysql-test/suite/ndb/r/loaddata_autocom_ndb.result b/mysql-test/suite/ndb/r/loaddata_autocom_ndb.result new file mode 100644 index 00000000000..f98e6a76981 --- /dev/null +++ b/mysql-test/suite/ndb/r/loaddata_autocom_ndb.result @@ -0,0 +1,23 @@ +SET SESSION STORAGE_ENGINE = ndbcluster; +drop table if exists t1; +create table t1 (id int unsigned not null auto_increment primary key, a text, b text); +start transaction; +load data infile '../std_data_ln/loaddata2.dat' into table t1 fields terminated by ',' enclosed by '''' (a, b); +Warnings: +Warning 1261 Row 3 doesn't contain data for all columns +commit; +select count(*) from t1; +count(*) +4 +truncate table t1; +start transaction; +load data infile '../std_data_ln/loaddata2.dat' into table t1 fields terminated by ',' enclosed by '''' (a, b); +Warnings: +Warning 1261 Row 3 doesn't contain data for all columns +rollback; +Warnings: +Warning 1196 Some non-transactional changed tables couldn't be rolled back +select count(*) from t1; +count(*) +4 +drop table t1; diff --git a/mysql-test/suite/ndb/r/ndb_alter_table.result b/mysql-test/suite/ndb/r/ndb_alter_table.result new file mode 100644 index 00000000000..13c445b44ca --- /dev/null +++ b/mysql-test/suite/ndb/r/ndb_alter_table.result @@ -0,0 +1,401 @@ +DROP TABLE IF EXISTS t1, t2; +drop database if exists mysqltest; +CREATE TABLE t1 ( +a INT NOT NULL, +b INT NOT NULL +) ENGINE=ndbcluster; +INSERT INTO t1 VALUES (9410,9412); +ALTER TABLE t1 ADD COLUMN c int not null; +SELECT * FROM t1; +a b c +9410 9412 0 +DROP TABLE t1; +CREATE DATABASE mysqltest; +USE mysqltest; +CREATE TABLE t1 ( +a INT NOT NULL, +b INT NOT NULL +) ENGINE=ndbcluster; +RENAME TABLE t1 TO test.t1; +SHOW TABLES; +Tables_in_mysqltest +DROP DATABASE mysqltest; +USE test; +SHOW TABLES; +Tables_in_test +t1 +DROP TABLE t1; +create table t1 ( +col1 int not null auto_increment primary key, +col2 varchar(30) not null, +col3 varchar (20) not null, +col4 varchar(4) not null, +col5 enum('PENDING', 'ACTIVE', 'DISABLED') not null, +col6 int not null, to_be_deleted int) ENGINE=ndbcluster; +show table status; +Name Engine Version Row_format Rows Avg_row_length Data_length Max_data_length Index_length Data_free Auto_increment Create_time Update_time Check_time Collation Checksum Create_options Comment +t1 NDBCLUSTER 10 Dynamic 0 # # # 0 # 1 # # # latin1_swedish_ci NULL # +SET SQL_MODE=NO_AUTO_VALUE_ON_ZERO; +insert into t1 values +(0,4,3,5,"PENDING",1,7),(NULL,4,3,5,"PENDING",1,7),(31,4,3,5,"PENDING",1,7), (7,4,3,5,"PENDING",1,7), (NULL,4,3,5,"PENDING",1,7), (100,4,3,5,"PENDING",1,7), (99,4,3,5,"PENDING",1,7), (8,4,3,5,"PENDING",1,7), (NULL,4,3,5,"PENDING",1,7); +show table status; +Name Engine Version Row_format Rows Avg_row_length Data_length Max_data_length Index_length Data_free Auto_increment Create_time Update_time Check_time Collation Checksum Create_options Comment +t1 NDBCLUSTER 10 Dynamic 9 # # # 0 # 102 # # # latin1_swedish_ci NULL # +select * from t1 order by col1; +col1 col2 col3 col4 col5 col6 to_be_deleted +0 4 3 5 PENDING 1 7 +1 4 3 5 PENDING 1 7 +7 4 3 5 PENDING 1 7 +8 4 3 5 PENDING 1 7 +31 4 3 5 PENDING 1 7 +32 4 3 5 PENDING 1 7 +99 4 3 5 PENDING 1 7 +100 4 3 5 PENDING 1 7 +101 4 3 5 PENDING 1 7 +alter table t1 +add column col4_5 varchar(20) not null after col4, +add column col7 varchar(30) not null after col5, +add column col8 datetime not null, drop column to_be_deleted, +change column col2 fourth varchar(30) not null after col3, +modify column col6 int not null first; +show table status; +Name Engine Version Row_format Rows Avg_row_length Data_length Max_data_length Index_length Data_free Auto_increment Create_time Update_time Check_time Collation Checksum Create_options Comment +t1 NDBCLUSTER 10 Dynamic 9 # # # 0 # 102 # # # latin1_swedish_ci NULL # +select * from t1 order by col1; +col6 col1 col3 fourth col4 col4_5 col5 col7 col8 +1 0 3 4 5 PENDING 0000-00-00 00:00:00 +1 1 3 4 5 PENDING 0000-00-00 00:00:00 +1 7 3 4 5 PENDING 0000-00-00 00:00:00 +1 8 3 4 5 PENDING 0000-00-00 00:00:00 +1 31 3 4 5 PENDING 0000-00-00 00:00:00 +1 32 3 4 5 PENDING 0000-00-00 00:00:00 +1 99 3 4 5 PENDING 0000-00-00 00:00:00 +1 100 3 4 5 PENDING 0000-00-00 00:00:00 +1 101 3 4 5 PENDING 0000-00-00 00:00:00 +insert into t1 values (2, NULL,4,3,5,99,"PENDING","EXTRA",'2004-01-01 00:00:00'); +show table status; +Name Engine Version Row_format Rows Avg_row_length Data_length Max_data_length Index_length Data_free Auto_increment Create_time Update_time Check_time Collation Checksum Create_options Comment +t1 NDBCLUSTER 10 Dynamic 10 # # # 0 # 103 # # # latin1_swedish_ci NULL # +select * from t1 order by col1; +col6 col1 col3 fourth col4 col4_5 col5 col7 col8 +1 0 3 4 5 PENDING 0000-00-00 00:00:00 +1 1 3 4 5 PENDING 0000-00-00 00:00:00 +1 7 3 4 5 PENDING 0000-00-00 00:00:00 +1 8 3 4 5 PENDING 0000-00-00 00:00:00 +1 31 3 4 5 PENDING 0000-00-00 00:00:00 +1 32 3 4 5 PENDING 0000-00-00 00:00:00 +1 99 3 4 5 PENDING 0000-00-00 00:00:00 +1 100 3 4 5 PENDING 0000-00-00 00:00:00 +1 101 3 4 5 PENDING 0000-00-00 00:00:00 +2 102 4 3 5 99 PENDING EXTRA 2004-01-01 00:00:00 +delete from t1; +insert into t1 values (0,0,4,3,5,99,"PENDING","EXTRA",'2004-01-01 00:00:00'); +SET SQL_MODE=''; +insert into t1 values (1,0,4,3,5,99,"PENDING","EXTRA",'2004-01-01 00:00:00'); +select * from t1 order by col1; +col6 col1 col3 fourth col4 col4_5 col5 col7 col8 +0 0 4 3 5 99 PENDING EXTRA 2004-01-01 00:00:00 +1 103 4 3 5 99 PENDING EXTRA 2004-01-01 00:00:00 +alter table t1 drop column col4_5; +insert into t1 values (2,0,4,3,5,"PENDING","EXTRA",'2004-01-01 00:00:00'); +select * from t1 order by col1; +col6 col1 col3 fourth col4 col5 col7 col8 +0 0 4 3 5 PENDING EXTRA 2004-01-01 00:00:00 +1 103 4 3 5 PENDING EXTRA 2004-01-01 00:00:00 +2 104 4 3 5 PENDING EXTRA 2004-01-01 00:00:00 +drop table t1; +CREATE TABLE t1 ( +a INT NOT NULL, +b INT NOT NULL +) ENGINE=ndbcluster; +INSERT INTO t1 VALUES (9410,9412); +ALTER TABLE t1 ADD COLUMN c int not null; +select * from t1 order by a; +a b c +9410 9412 0 +select * from t1 order by a; +a b c +9410 9412 0 +alter table t1 drop c; +select * from t1 order by a; +a b +9410 9412 +drop table t1; +select * from t1 order by a; +ERROR 42S02: Table 'test.t1' doesn't exist +CREATE TABLE t1 ( +a INT NOT NULL PRIMARY KEY, +b INT NOT NULL +) ENGINE=ndbcluster; +INSERT INTO t1 VALUES (0,1),(17,18); +select * from t1 order by a; +a b +0 1 +17 18 +SET SQL_MODE=NO_AUTO_VALUE_ON_ZERO; +alter table t1 modify column a int not null auto_increment; +SET SQL_MODE=''; +select * from t1 order by a; +a b +0 1 +17 18 +INSERT INTO t1 VALUES (0,19),(20,21); +select * from t1 order by a; +a b +0 1 +17 18 +18 19 +20 21 +drop table t1; +CREATE TABLE t1 ( +a INT NOT NULL PRIMARY KEY, +b INT NOT NULL +) ENGINE=ndbcluster; +INSERT INTO t1 VALUES (0,1),(17,18); +select * from t1 order by a; +a b +0 1 +17 18 +alter table t1 add c int not null unique auto_increment; +select c from t1 order by c; +c +1 +2 +INSERT INTO t1 VALUES (1,2,0),(18,19,4),(20,21,0); +select c from t1 order by c; +c +1 +2 +3 +4 +5 +drop table t1; +create table t1 ( +ai bigint auto_increment, +c001 int(11) not null, +c002 int(11) not null, +c003 int(11) not null, +c004 int(11) not null, +c005 int(11) not null, +c006 int(11) not null, +c007 int(11) not null, +c008 int(11) not null, +c009 int(11) not null, +c010 int(11) not null, +c011 int(11) not null, +c012 int(11) not null, +c013 int(11) not null, +c014 int(11) not null, +c015 int(11) not null, +c016 int(11) not null, +c017 int(11) not null, +c018 int(11) not null, +c019 int(11) not null, +c020 int(11) not null, +c021 int(11) not null, +c022 int(11) not null, +c023 int(11) not null, +c024 int(11) not null, +c025 int(11) not null, +c026 int(11) not null, +c027 int(11) not null, +c028 int(11) not null, +c029 int(11) not null, +c030 int(11) not null, +c031 int(11) not null, +c032 int(11) not null, +c033 int(11) not null, +c034 int(11) not null, +c035 int(11) not null, +c036 int(11) not null, +c037 int(11) not null, +c038 int(11) not null, +c039 int(11) not null, +c040 int(11) not null, +c041 int(11) not null, +c042 int(11) not null, +c043 int(11) not null, +c044 int(11) not null, +c045 int(11) not null, +c046 int(11) not null, +c047 int(11) not null, +c048 int(11) not null, +c049 int(11) not null, +c050 int(11) not null, +c051 int(11) not null, +c052 int(11) not null, +c053 int(11) not null, +c054 int(11) not null, +c055 int(11) not null, +c056 int(11) not null, +c057 int(11) not null, +c058 int(11) not null, +c059 int(11) not null, +c060 int(11) not null, +c061 int(11) not null, +c062 int(11) not null, +c063 int(11) not null, +c064 int(11) not null, +c065 int(11) not null, +c066 int(11) not null, +c067 int(11) not null, +c068 int(11) not null, +c069 int(11) not null, +c070 int(11) not null, +c071 int(11) not null, +c072 int(11) not null, +c073 int(11) not null, +c074 int(11) not null, +c075 int(11) not null, +c076 int(11) not null, +c077 int(11) not null, +c078 int(11) not null, +c079 int(11) not null, +c080 int(11) not null, +c081 int(11) not null, +c082 int(11) not null, +c083 int(11) not null, +c084 int(11) not null, +c085 int(11) not null, +c086 int(11) not null, +c087 int(11) not null, +c088 int(11) not null, +c089 int(11) not null, +c090 int(11) not null, +c091 int(11) not null, +c092 int(11) not null, +c093 int(11) not null, +c094 int(11) not null, +c095 int(11) not null, +c096 int(11) not null, +c097 int(11) not null, +c098 int(11) not null, +c099 int(11) not null, +c100 int(11) not null, +c101 int(11) not null, +c102 int(11) not null, +c103 int(11) not null, +c104 int(11) not null, +c105 int(11) not null, +c106 int(11) not null, +c107 int(11) not null, +c108 int(11) not null, +c109 int(11) not null, +primary key (ai), +unique key tx1 (c002, c003, c004, c005)) engine=ndb; +create index tx2 +on t1 (c010, c011, c012, c013); +drop table t1; +CREATE TABLE t1 ( +auto int(5) unsigned NOT NULL auto_increment, +string char(10), +vstring varchar(10), +bin binary(2), +vbin varbinary(7), +tiny tinyint(4) DEFAULT '0' NOT NULL , +short smallint(6) DEFAULT '1' NOT NULL , +medium mediumint(8) DEFAULT '0' NOT NULL, +long_int int(11) DEFAULT '0' NOT NULL, +longlong bigint(13) DEFAULT '0' NOT NULL, +real_float float(13,1) DEFAULT 0.0 NOT NULL, +real_double double(16,4), +real_decimal decimal(16,4), +utiny tinyint(3) unsigned DEFAULT '0' NOT NULL, +ushort smallint(5) unsigned zerofill DEFAULT '00000' NOT NULL, +umedium mediumint(8) unsigned DEFAULT '0' NOT NULL, +ulong int(11) unsigned DEFAULT '0' NOT NULL, +ulonglong bigint(13) unsigned DEFAULT '0' NOT NULL, +bits bit(3), +options enum('zero','one','two','three','four') not null, +flags set('zero','one','two','three','four') not null, +date_field date, +year_field year, +time_field time, +date_time datetime, +time_stamp timestamp, +PRIMARY KEY (auto) +) engine=ndb; +CREATE TEMPORARY TABLE ndb_show_tables (id INT, type VARCHAR(20), state VARCHAR(20), logging VARCHAR(20), _database VARCHAR(255), _schema VARCHAR(20), name VARCHAR(255)); +LOAD DATA INFILE 'tmp.dat' INTO TABLE ndb_show_tables; +set @t1_id = (select id from ndb_show_tables where name like '%t1%'); +truncate ndb_show_tables; +alter table t1 change tiny new_tiny tinyint(4) DEFAULT '0' NOT NULL; +LOAD DATA INFILE 'tmp.dat' INTO TABLE ndb_show_tables; +select 'no_copy' from ndb_show_tables where id = @t1_id and name like '%t1%'; +no_copy +set @t1_id = (select id from ndb_show_tables where name like '%t1%'); +truncate ndb_show_tables; +create index i1 on t1(medium); +alter table t1 add index i2(new_tiny); +drop index i1 on t1; +LOAD DATA INFILE 'tmp.dat' INTO TABLE ndb_show_tables; +select 'no_copy' from ndb_show_tables where id = @t1_id and name like '%t1%'; +no_copy +no_copy +DROP TABLE t1, ndb_show_tables; +create table t1 (a int primary key auto_increment, b int) engine=ndb; +insert into t1 (b) values (101),(102),(103); +select * from t1 where a = 3; +a b +3 103 +alter table t1 rename t2; +insert into t2 (b) values (201),(202),(203); +select * from t2 where a = 6; +a b +6 203 +alter table t2 add c int; +insert into t2 (b) values (301),(302),(303); +select * from t2 where a = 9; +a b c +9 303 NULL +alter table t2 rename t1; +insert into t1 (b) values (401),(402),(403); +select * from t1 where a = 12; +a b c +12 403 NULL +drop table t1; +create table t1 (a int not null, b varchar(10)) engine=ndb; +show index from t1; +Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment +alter table t1 add primary key (a); +show index from t1; +Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment +t1 0 PRIMARY 1 a A 0 NULL NULL BTREE +alter table t1 drop primary key; +show index from t1; +Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment +drop table t1; +create table t1 (a int not null primary key, b int not null default 0, c varchar(254)) engine=ndb; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` int(11) NOT NULL, + `b` int(11) NOT NULL DEFAULT '0', + `c` varchar(254) DEFAULT NULL, + PRIMARY KEY (`a`) +) ENGINE=ndbcluster DEFAULT CHARSET=latin1 +alter table t1 alter b set default 1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` int(11) NOT NULL, + `b` int(11) NOT NULL DEFAULT '1', + `c` varchar(254) DEFAULT NULL, + PRIMARY KEY (`a`) +) ENGINE=ndbcluster DEFAULT CHARSET=latin1 +drop table t1; +create table t1 (a int not null, b int not null) engine=ndb; +insert into t1 values (1, 300), (2, 200), (3, 100); +select * from t1 order by a; +a b +1 300 +2 200 +3 100 +alter table t1 order by b; +select * from t1 order by b; +a b +3 100 +2 200 +1 300 +drop table t1; +End of 5.1 tests diff --git a/mysql-test/suite/ndb/r/ndb_alter_table2.result b/mysql-test/suite/ndb/r/ndb_alter_table2.result new file mode 100644 index 00000000000..3783c76447c --- /dev/null +++ b/mysql-test/suite/ndb/r/ndb_alter_table2.result @@ -0,0 +1,41 @@ +DROP TABLE IF EXISTS t1; +CREATE TABLE t1 ( +a INT NOT NULL PRIMARY KEY, +b INT NOT NULL +) ENGINE=ndbcluster; +BEGIN; +INSERT INTO t1 VALUES (9410,9412); +BEGIN; +INSERT INTO t1 VALUES (9411,9412); +BEGIN; +INSERT INTO t1 VALUES (9412,9412); +BEGIN; +INSERT INTO t1 VALUES (9413,9412); +BEGIN; +INSERT INTO t1 VALUES (9414,9412); +BEGIN; +INSERT INTO t1 VALUES (9415,9412); +ROLLBACK; +ROLLBACK; +ROLLBACK; +ROLLBACK; +ROLLBACK; +ROLLBACK; +drop table t1; +CREATE TABLE t1 ( +a INT NOT NULL PRIMARY KEY, +b INT NOT NULL, +c INT NOT NULL +) ENGINE=ndbcluster; +select * from t1; +select * from t1; +a b c +select * from t1; +a b c +select * from t1; +a b c +select * from t1; +a b c +select * from t1; +a b c +drop table t1; diff --git a/mysql-test/suite/ndb/r/ndb_alter_table3.result b/mysql-test/suite/ndb/r/ndb_alter_table3.result new file mode 100644 index 00000000000..ee7c9b1c7b0 --- /dev/null +++ b/mysql-test/suite/ndb/r/ndb_alter_table3.result @@ -0,0 +1,35 @@ +DROP TABLE IF EXISTS t1; +create table t1 ( a int primary key, b varchar(10), c varchar(10), index (b) ) +engine=ndb; +insert into t1 values (1,'one','one'), (2,'two','two'), (3,'three','three'); +create index c on t1(c); +show indexes from t1; +Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment +t1 0 PRIMARY 1 a A 3 NULL NULL BTREE +t1 1 b 1 b A 3 NULL NULL YES BTREE +t1 1 c 1 c A 3 NULL NULL YES BTREE +select * from t1 where c = 'two'; +a b c +2 two two +alter table t1 drop index c; +show indexes from t1; +Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment +t1 0 PRIMARY 1 a A 3 NULL NULL BTREE +t1 1 b 1 b A 3 NULL NULL YES BTREE +select * from t1 where c = 'two'; +a b c +2 two two +drop table t1; +create table t3 (a int primary key) engine=ndbcluster; +begin; +insert into t3 values (1); +alter table t3 rename t4; +commit; +select * from t3; +ERROR 42S02: Table 'test.t3' doesn't exist +select * from t4; +a +1 +drop table t4; +show tables; +Tables_in_test diff --git a/mysql-test/suite/ndb/r/ndb_autodiscover.result b/mysql-test/suite/ndb/r/ndb_autodiscover.result new file mode 100644 index 00000000000..487f52f6427 --- /dev/null +++ b/mysql-test/suite/ndb/r/ndb_autodiscover.result @@ -0,0 +1,397 @@ +drop table if exists t1,t2,t3,t4,t5,t6,t7,t8,t9,t10; +flush status; +create table t1( +id int not null primary key, +name char(20) +) engine=ndb; +insert into t1 values(1, "Autodiscover"); +flush tables; +select * from t1; +id name +1 Autodiscover +show status like 'handler_discover%'; +Variable_name Value +Handler_discover 1 +flush tables; +insert into t1 values (2, "Auto 2"); +show status like 'handler_discover%'; +Variable_name Value +Handler_discover 2 +insert into t1 values (3, "Discover 3"); +show status like 'handler_discover%'; +Variable_name Value +Handler_discover 2 +flush tables; +select * from t1 order by id; +id name +1 Autodiscover +2 Auto 2 +3 Discover 3 +show status like 'handler_discover%'; +Variable_name Value +Handler_discover 3 +flush tables; +update t1 set name="Autodiscover" where id = 2; +show status like 'handler_discover%'; +Variable_name Value +Handler_discover 4 +select * from t1 order by id; +id name +1 Autodiscover +2 Autodiscover +3 Discover 3 +show status like 'handler_discover%'; +Variable_name Value +Handler_discover 4 +flush tables; +delete from t1 where id = 3; +select * from t1 order by id; +id name +1 Autodiscover +2 Autodiscover +show status like 'handler_discover%'; +Variable_name Value +Handler_discover 5 +drop table t1; +flush status; +create table t2( +id int not null primary key, +name char(22) +) engine=ndb; +insert into t2 values (1, "Discoverer"); +select * from t2; +id name +1 Discoverer +show status like 'handler_discover%'; +Variable_name Value +Handler_discover 0 +flush tables; +select * from t2; +id name +1 Discoverer +show status like 'handler_discover%'; +Variable_name Value +Handler_discover 1 +drop table t2; +flush status; +create table t3( +id int not null primary key, +name char(255) +) engine=ndb; +insert into t3 values (1, "Explorer"); +select * from t3; +id name +1 Explorer +show status like 'handler_discover%'; +Variable_name Value +Handler_discover 0 +flush tables; +create table t3( +id int not null primary key, +name char(20), a int, b float, c char(24) +) engine=ndb; +ERROR 42S01: Table 't3' already exists +show status like 'handler_discover%'; +Variable_name Value +Handler_discover 0 +create table IF NOT EXISTS t3( +id int not null primary key, +id2 int not null, +name char(20) +) engine=ndb; +Warnings: +Note 1050 Table 't3' already exists +show status like 'handler_discover%'; +Variable_name Value +Handler_discover 0 +SHOW CREATE TABLE t3; +Table Create Table +t3 CREATE TABLE `t3` ( + `id` int(11) NOT NULL, + `name` char(255) default NULL, + PRIMARY KEY (`id`) +) ENGINE=ndbcluster DEFAULT CHARSET=latin1 PARTITION BY KEY () +select * from t3; +id name +1 Explorer +show status like 'handler_discover%'; +Variable_name Value +Handler_discover 1 +drop table t3; +flush status; +create table t7( +id int not null primary key, +name char(255) +) engine=ndb; +create table t6( +id int not null primary key, +name char(255) +) engine=MyISAM; +insert into t7 values (1, "Explorer"); +insert into t6 values (2, "MyISAM table"); +select * from t7; +id name +1 Explorer +show status like 'handler_discover%'; +Variable_name Value +Handler_discover 0 +flush tables; +show tables from test; +Tables_in_test +t6 +t7 +show status like 'handler_discover%'; +Variable_name Value +Handler_discover 1 +flush tables; +show table status; +Name Engine Version Row_format Rows Avg_row_length Data_length Max_data_length Index_length Data_free Auto_increment Create_time Update_time Check_time Collation Checksum Create_options Comment +t6 MyISAM 10 Fixed 1 # # # # 0 NULL # # NULL # NULL # +t7 NDBCLUSTER 10 Fixed 1 # # # # 0 NULL # # NULL # NULL # +show status like 'handler_discover%'; +Variable_name Value +Handler_discover 2 +drop table t6, t7; +flush status; +create table t4( +id int not null primary key, +name char(27) +) engine=ndb; +insert into t4 values (1, "Automatic"); +select * from t4; +id name +1 Automatic +select * from t4; +ERROR 42S02: Table 'test.t4' doesn't exist +select * from t4; +ERROR 42S02: Table 'test.t4' doesn't exist +show status like 'handler_discover%'; +Variable_name Value +Handler_discover 0 +drop table t4; +ERROR 42S02: Unknown table 't4' +create table t4( +id int not null primary key, +name char(27) +) engine=ndb; +insert into t4 values (1, "Automatic"); +select * from t4; +id name +1 Automatic +select * from t4; +ERROR 42S02: Table 'test.t4' doesn't exist +drop table if exists t4; +Warnings: +Error 155 Table 'test.t4' doesn't exist +drop table t5; +ERROR 42S02: Unknown table 't5' +drop table if exists t5; +Warnings: +Note 1051 Unknown table 't5' +flush status; +create table t4( +id int not null primary key, +id2 int, +name char(27) +) engine=ndb; +insert into t4 values (1, 76, "Automatic2"); +select * from t4; +id id2 name +1 76 Automatic2 +flush tables; +SHOW TABLES; +Tables_in_test +select * from t4; +ERROR 42S02: Table 'test.t4' doesn't exist +flush status; +create table t1(id int) engine=ndbcluster; +create table t2(id int, b char(255)) engine=myisam; +create table t3(id int, c char(255)) engine=ndbcluster; +create table t4(id int) engine=myisam; +create table t5(id int, d char(56)) engine=ndbcluster; +create table t6(id int) engine=ndbcluster; +create table t7(id int) engine=ndbcluster; +create table t8(id int, e char(34)) engine=myisam; +create table t9(id int) engine=myisam; +insert into t2 values (2, "myisam table 2"); +insert into t3 values (3, "ndb table 3"); +insert into t5 values (5, "ndb table 5"); +insert into t6 values (6); +insert into t8 values (8, "myisam table 8"); +insert into t9 values (9); +SHOW TABLES; +Tables_in_test +t1 +t2 +t4 +t8 +t9 +t7 +t6 +select * from t6; +id +6 +select * from t7; +id +show status like 'handler_discover%'; +Variable_name Value +Handler_discover 2 +drop table t1, t2, t4, t6, t7, t8, t9; +flush status; +create table t1(id int) engine=ndbcluster; +create table t2(id int, b char(255)) engine=myisam; +create table t3(id int, c char(255)) engine=ndbcluster; +create table t4(id int) engine=myisam; +create table t5(id int, d char(56)) engine=ndbcluster; +create table t6(id int) engine=ndbcluster; +create table t7(id int) engine=ndbcluster; +create table t8(id int, e char(34)) engine=myisam; +create table t9(id int) engine=myisam; +insert into t2 values (2, "myisam table 2"); +insert into t3 values (3, "ndb table 3"); +insert into t5 values (5, "ndb table 5"); +insert into t6 values (6); +insert into t8 values (8, "myisam table 8"); +insert into t9 values (9); +SHOW TABLES LIKE 't6'; +Tables_in_test (t6) +t6 +show status like 'handler_discover%'; +Variable_name Value +Handler_discover 1 +create table t3(a int); +ERROR 42S01: Table 't3' already exists +create table t5(a int); +ERROR 42S01: Table 't5' already exists +SHOW TABLES LIKE 't%'; +Tables_in_test (t%) +t1 +t2 +t4 +t6 +t8 +t9 +t7 +show status like 'handler_discover%'; +Variable_name Value +Handler_discover 2 +drop table t1, t2, t4, t6, t7, t8, t9; +flush status; +create table t1(id int) engine=ndbcluster; +create table t2(id int, b char(255)) engine=ndbcluster; +create table t3(id int, c char(255)) engine=ndbcluster; +create table t4(id int) engine=myisam; +insert into t1 values (1); +insert into t2 values (2, "table 2"); +insert into t3 values (3, "ndb table 3"); +insert into t4 values (4); +flush tables; +select * from t1, t2, t3, t4; +id id b id c id +1 2 table 2 3 ndb table 3 4 +show status like 'handler_discover%'; +Variable_name Value +Handler_discover 3 +drop table t1, t2, t3, t4; +flush status; +show status like 'handler_discover%'; +Variable_name Value +Handler_discover 0 +create table t5( +id int not null primary key, +name char(200) +) engine=ndb; +insert into t5 values (1, "Magnus"); +select * from t5; +id name +1 Magnus +ALTER TABLE t5 ADD COLUMN adress char(255) FIRST; +select * from t5; +adress id name +NULL 1 Magnus +insert into t5 values +("Adress for record 2", 2, "Carl-Gustav"), +("Adress for record 3", 3, "Karl-Emil"); +update t5 set name="Bertil" where id = 2; +select * from t5 order by id; +adress id name +NULL 1 Magnus +Adress for record 2 2 Bertil +Adress for record 3 3 Karl-Emil +show status like 'handler_discover%'; +Variable_name Value +Handler_discover 0 +drop table t5; +flush status; +show status like 'handler_discover%'; +Variable_name Value +Handler_discover 0 +create table t6( +id int not null primary key, +name char(20) +) engine=ndb; +insert into t6 values (1, "Magnus"); +select * from t6; +id name +1 Magnus +ALTER TABLE t6 ADD COLUMN adress char(255) FIRST; +select * from t6; +adress id name +NULL 1 Magnus +insert into t6 values +("Adress for record 2", 2, "Carl-Gustav"), +("Adress for record 3", 3, "Karl-Emil"); +update t6 set name="Bertil" where id = 2; +select * from t6 order by id; +adress id name +NULL 1 Magnus +Adress for record 2 2 Bertil +Adress for record 3 3 Karl-Emil +show status like 'handler_discover%'; +Variable_name Value +Handler_discover 0 +drop table t6; +show tables; +Tables_in_test +create table t1 (a int,b longblob) engine=ndb; +show tables; +Tables_in_test +t1 +create database test2; +use test2; +show tables; +Tables_in_test2 +select * from t1; +ERROR 42S02: Table 'test2.t1' doesn't exist +create table t2 (b int,c longblob) engine=ndb; +use test; +select * from t1; +a b +show tables; +Tables_in_test +t1 +drop table t1; +use test2; +drop table t2; +drop database test2; +use test; +drop database if exists test_only_ndb_tables; +create database test_only_ndb_tables; +use test_only_ndb_tables; +create table t1 (a int primary key) engine=ndb; +select * from t1; +a +select * from t1; +ERROR HY000: Can't lock file (errno: 157) +use test; +drop database test_only_ndb_tables; +CREATE TABLE t9 ( +a int NOT NULL PRIMARY KEY, +b int +) engine=ndb; +insert t9 values(1, 2), (2,3), (3, 4), (4, 5); +create table t10 ( +a int not null primary key, +b blob +) engine=ndb; +insert into t10 values (1, 'kalle'); diff --git a/mysql-test/suite/ndb/r/ndb_autodiscover2.result b/mysql-test/suite/ndb/r/ndb_autodiscover2.result new file mode 100644 index 00000000000..269888e0820 --- /dev/null +++ b/mysql-test/suite/ndb/r/ndb_autodiscover2.result @@ -0,0 +1,13 @@ +select * from t9 order by a; +a b +1 2 +2 3 +3 4 +4 5 +show status like 'handler_discover%'; +Variable_name Value +Handler_discover 0 +drop table t9; +select * from t10; +ERROR HY000: Got error 4263 'Invalid blob attributes or invalid blob parts table' from NDBCLUSTER +drop table t10; diff --git a/mysql-test/suite/ndb/r/ndb_autodiscover3.result b/mysql-test/suite/ndb/r/ndb_autodiscover3.result new file mode 100644 index 00000000000..86495ebb3eb --- /dev/null +++ b/mysql-test/suite/ndb/r/ndb_autodiscover3.result @@ -0,0 +1,53 @@ +drop table if exists t1, t2; +create table t1 (a int key) engine=ndbcluster; +begin; +insert into t1 values (1); +insert into t1 values (2); +ERROR HY000: Got temporary error 4025 'Node failure caused abort of transaction' from NDBCLUSTER +commit; +ERROR HY000: Got error 4350 'Transaction already aborted' from NDBCLUSTER +drop table t1; +create table t2 (a int, b int, primary key(a,b)) engine=ndbcluster; +insert into t2 values (1,1),(2,1),(3,1),(4,1),(5,1),(6,1),(7,1),(8,1),(9,1),(10,1); +select * from t2 order by a limit 3; +a b +1 1 +2 1 +3 1 +select * from t2; +ERROR 42S02: Table 'test.t2' doesn't exist +show tables like 't2'; +Tables_in_test (t2) +reset master; +create table t2 (a int key) engine=ndbcluster; +insert into t2 values (1),(2),(3),(4),(5),(6),(7),(8),(9),(10); +select * from t2 order by a limit 3; +a +1 +2 +3 +select * from t2 order by a limit 3; +a +1 +2 +3 +reset master; +select * from t2; +ERROR 42S02: Table 'test.t2' doesn't exist +show tables like 't2'; +Tables_in_test (t2) +reset master; +create table t2 (a int key) engine=ndbcluster; +insert into t2 values (1),(2),(3),(4),(5),(6),(7),(8),(9),(10); +select * from t2 order by a limit 3; +a +1 +2 +3 +select * from t2 order by a limit 3; +a +1 +2 +3 +reset master; +drop table t2; diff --git a/mysql-test/suite/ndb/r/ndb_backup_print.result b/mysql-test/suite/ndb/r/ndb_backup_print.result new file mode 100644 index 00000000000..7fa073bafb5 --- /dev/null +++ b/mysql-test/suite/ndb/r/ndb_backup_print.result @@ -0,0 +1,65 @@ +use test; +drop table if exists t1,t2,t3,t4,t5,t6,t7,t8,t9,t10; +Connected to Management Server at: : +Waiting for completed, this may take several minutes +Node : Backup started from node +Node : Backup started from node completed + StartGCP: StopGCP: + #Records: #LogRecords: + Data: bytes Log: bytes +create table t1 +(pk int key +,a1 BIT(1), a2 BIT(5), a3 BIT(33), a4 BIT(63), a5 BIT(64) +,b1 TINYINT, b2 TINYINT UNSIGNED +,c1 SMALLINT, c2 SMALLINT UNSIGNED +,d1 INT, d2 INT UNSIGNED +,e1 BIGINT, e2 BIGINT UNSIGNED +,f1 CHAR(1) BINARY, f2 CHAR(32) BINARY, f3 CHAR(255) BINARY +,g1 VARCHAR(32) BINARY, g2 VARCHAR(255) BINARY, g3 VARCHAR(1000) BINARY +,h1 BINARY(1), h2 BINARY(8), h3 BINARY(255) +,i1 VARBINARY(32), i2 VARBINARY(255), i3 VARBINARY(1000) +) engine ndb; +insert into t1 values +(1 +,0x1, 0x17, 0x789a, 0x789abcde, 0xfedc0001 +,127, 255 +,32767, 65535 +,2147483647, 4294967295 +,9223372036854775807, 18446744073709551615 +,'1','12345678901234567890123456789012','123456789' + ,'1','12345678901234567890123456789012','123456789' + ,0x12,0x123456789abcdef0, 0x012345 +,0x12,0x123456789abcdef0, 0x00123450 +); +insert into t1 values +(2 +,0, 0, 0, 0, 0 +,-128, 0 +,-32768, 0 +,-2147483648, 0 +,-9223372036854775808, 0 +,'','','' + ,'','','' + ,0x0,0x0,0x0 +,0x0,0x0,0x0 +); +insert into t1 values +(3 +,NULL,NULL,NULL,NULL,NULL +,NULL,NULL +,NULL,NULL +,NULL,NULL +,NULL,NULL +,NULL,NULL,NULL +,NULL,NULL,NULL +,NULL,NULL,NULL +,NULL,NULL,NULL +); +Connected to Management Server at: : +Waiting for completed, this may take several minutes +Node : Backup started from node +Node : Backup started from node completed + StartGCP: StopGCP: + #Records: #LogRecords: + Data: bytes Log: bytes +drop table t1; diff --git a/mysql-test/suite/ndb/r/ndb_basic.result b/mysql-test/suite/ndb/r/ndb_basic.result new file mode 100644 index 00000000000..4eddaeb1227 --- /dev/null +++ b/mysql-test/suite/ndb/r/ndb_basic.result @@ -0,0 +1,901 @@ +DROP TABLE IF EXISTS t1,t2,t3,t4,t5,t6,t7; +drop database if exists mysqltest; +CREATE TABLE t1 ( +pk1 INT NOT NULL PRIMARY KEY, +attr1 INT NOT NULL, +attr2 INT, +attr3 VARCHAR(10) +) ENGINE=ndbcluster; +drop table t1; +SHOW GLOBAL STATUS LIKE 'ndb%'; +Variable_name Value +Ndb_cluster_node_id # +Ndb_config_from_host # +Ndb_config_from_port # +Ndb_number_of_data_nodes # +SHOW GLOBAL VARIABLES LIKE 'ndb%'; +Variable_name Value +ndb_autoincrement_prefetch_sz # +ndb_cache_check_time # +ndb_connectstring # +ndb_extra_logging # +ndb_force_send # +ndb_index_stat_cache_entries # +ndb_index_stat_enable # +ndb_index_stat_update_freq # +ndb_report_thresh_binlog_epoch_slip # +ndb_report_thresh_binlog_mem_usage # +ndb_use_copying_alter_table # +ndb_use_exact_count # +ndb_use_transactions # +CREATE TABLE t1 ( +pk1 INT NOT NULL PRIMARY KEY, +attr1 INT NOT NULL, +attr2 INT, +attr3 VARCHAR(10) +) ENGINE=ndbcluster; +SHOW INDEX FROM t1; +Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment +t1 0 PRIMARY 1 pk1 A 0 NULL NULL BTREE +INSERT INTO t1 VALUES (9410,9412, NULL, '9412'), (9411,9413, 17, '9413'); +SHOW INDEX FROM t1; +Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment +t1 0 PRIMARY 1 pk1 A 2 NULL NULL BTREE +SELECT pk1 FROM t1 ORDER BY pk1; +pk1 +9410 +9411 +SELECT * FROM t1 ORDER BY pk1; +pk1 attr1 attr2 attr3 +9410 9412 NULL 9412 +9411 9413 17 9413 +SELECT t1.* FROM t1 ORDER BY pk1; +pk1 attr1 attr2 attr3 +9410 9412 NULL 9412 +9411 9413 17 9413 +UPDATE t1 SET attr1=1 WHERE pk1=9410; +SELECT * FROM t1 ORDER BY pk1; +pk1 attr1 attr2 attr3 +9410 1 NULL 9412 +9411 9413 17 9413 +UPDATE t1 SET pk1=2 WHERE attr1=1; +SELECT * FROM t1 ORDER BY pk1; +pk1 attr1 attr2 attr3 +2 1 NULL 9412 +9411 9413 17 9413 +UPDATE t1 SET pk1=pk1 + 1; +SELECT * FROM t1 ORDER BY pk1; +pk1 attr1 attr2 attr3 +3 1 NULL 9412 +9412 9413 17 9413 +UPDATE t1 SET pk1=4 WHERE pk1 = 3; +SELECT * FROM t1 ORDER BY pk1; +pk1 attr1 attr2 attr3 +4 1 NULL 9412 +9412 9413 17 9413 +DELETE FROM t1; +SELECT * FROM t1; +pk1 attr1 attr2 attr3 +INSERT INTO t1 VALUES (9410,9412, NULL, '9412'), (9408, 8765, NULL, '8765'), +(7,8, NULL, NULL), (8,9, NULL, NULL), (9,10, NULL, NULL), (10,11, NULL, NULL), (11,12, NULL, NULL), (12,13, NULL, NULL), (13,14, NULL, NULL); +UPDATE t1 SET attr1 = 9999; +SELECT * FROM t1 ORDER BY pk1; +pk1 attr1 attr2 attr3 +7 9999 NULL NULL +8 9999 NULL NULL +9 9999 NULL NULL +10 9999 NULL NULL +11 9999 NULL NULL +12 9999 NULL NULL +13 9999 NULL NULL +9408 9999 NULL 8765 +9410 9999 NULL 9412 +UPDATE t1 SET attr1 = 9998 WHERE pk1 < 1000; +SELECT * FROM t1 ORDER BY pk1; +pk1 attr1 attr2 attr3 +7 9998 NULL NULL +8 9998 NULL NULL +9 9998 NULL NULL +10 9998 NULL NULL +11 9998 NULL NULL +12 9998 NULL NULL +13 9998 NULL NULL +9408 9999 NULL 8765 +9410 9999 NULL 9412 +UPDATE t1 SET attr1 = 9997 WHERE attr1 = 9999; +SELECT * FROM t1 ORDER BY pk1; +pk1 attr1 attr2 attr3 +7 9998 NULL NULL +8 9998 NULL NULL +9 9998 NULL NULL +10 9998 NULL NULL +11 9998 NULL NULL +12 9998 NULL NULL +13 9998 NULL NULL +9408 9997 NULL 8765 +9410 9997 NULL 9412 +DELETE FROM t1 WHERE pk1 = 9410; +SELECT * FROM t1 ORDER BY pk1; +pk1 attr1 attr2 attr3 +7 9998 NULL NULL +8 9998 NULL NULL +9 9998 NULL NULL +10 9998 NULL NULL +11 9998 NULL NULL +12 9998 NULL NULL +13 9998 NULL NULL +9408 9997 NULL 8765 +DELETE FROM t1; +SELECT * FROM t1; +pk1 attr1 attr2 attr3 +INSERT INTO t1 values (1, 4, NULL, NULL), (2, 4, NULL, NULL), (3, 5, NULL, NULL), (4, 4, NULL, NULL), (5, 5, NULL, NULL); +DELETE FROM t1 WHERE attr1=4; +SELECT * FROM t1 order by pk1; +pk1 attr1 attr2 attr3 +3 5 NULL NULL +5 5 NULL NULL +DELETE FROM t1; +INSERT INTO t1 VALUES (9410,9412, NULL, NULL), (9411, 9413, NULL, NULL); +DELETE FROM t1 WHERE pk1 = 9410; +SELECT * FROM t1; +pk1 attr1 attr2 attr3 +9411 9413 NULL NULL +DROP TABLE t1; +CREATE TABLE t1 (id INT, id2 int) engine=ndbcluster; +INSERT INTO t1 values(3456, 7890); +SELECT * FROM t1; +id id2 +3456 7890 +UPDATE t1 SET id=2 WHERE id2=12; +SELECT * FROM t1; +id id2 +3456 7890 +UPDATE t1 SET id=1234 WHERE id2=7890; +SELECT * FROM t1; +id id2 +1234 7890 +DELETE FROM t1; +INSERT INTO t1 values(3456, 7890), (3456, 7890), (3456, 7890), (3454, 7890); +SELECT * FROM t1 ORDER BY id; +id id2 +3454 7890 +3456 7890 +3456 7890 +3456 7890 +DELETE FROM t1 WHERE id = 3456; +SELECT * FROM t1 ORDER BY id; +id id2 +3454 7890 +DROP TABLE t1; +CREATE TABLE t1 ( +pk1 INT NOT NULL PRIMARY KEY, +attr1 INT NOT NULL +) ENGINE=NDBCLUSTER; +INSERT INTO t1 values(1, 9999); +DROP TABLE t1; +CREATE TABLE t1 ( +pk1 INT NOT NULL PRIMARY KEY, +attr1 INT NOT NULL +) ENGINE=NDB; +INSERT INTO t1 values(1, 9999); +DROP TABLE t1; +CREATE TABLE t2 ( +a bigint unsigned NOT NULL PRIMARY KEY, +b int unsigned not null, +c int unsigned +) engine=ndbcluster; +CREATE TABLE t3 ( +a bigint unsigned NOT NULL, +b bigint unsigned not null, +c bigint unsigned, +PRIMARY KEY(a) +) engine=ndbcluster; +CREATE TABLE t4 ( +a bigint unsigned NOT NULL, +b bigint unsigned not null, +c bigint unsigned NOT NULL, +d int unsigned, +PRIMARY KEY(a, b, c) +) engine=ndbcluster; +select * from t2 where a = 7 order by b; +a b c +7 16 5 +select * from t2 where a = 7 order by a; +a b c +7 16 5 +select * from t2 where a = 7 order by 2; +a b c +7 16 5 +select * from t2 where a = 7 order by c; +a b c +7 16 5 +select * from t2 where a = 7 and b = 16 order by b; +a b c +7 16 5 +select * from t2 where a = 7 and b = 16 order by a; +a b c +7 16 5 +select * from t2 where a = 7 and b = 17 order by a; +a b c +select * from t2 where a = 7 and b != 16 order by b; +a b c +select * from t2 where a = 7 and b = 16 and c = 5 order by b; +a b c +7 16 5 +select * from t2 where a = 7 and b = 16 and c = 5 order by a; +a b c +7 16 5 +select * from t2 where a = 7 and b = 16 and c = 6 order by a; +a b c +select * from t2 where a = 7 and b != 16 and c = 5 order by b; +a b c +select * from t3 where a = 7 order by b; +a b c +7 16 5 +select * from t3 where a = 7 order by a; +a b c +7 16 5 +select * from t3 where a = 7 order by 2; +a b c +7 16 5 +select * from t3 where a = 7 order by c; +a b c +7 16 5 +select * from t3 where a = 7 and b = 16 order by b; +a b c +7 16 5 +select * from t3 where a = 7 and b = 16 order by a; +a b c +7 16 5 +select * from t3 where a = 7 and b = 17 order by a; +a b c +select * from t3 where a = 7 and b != 16 order by b; +a b c +select * from t4 where a = 7 order by b; +a b c d +7 16 5 26007 +select * from t4 where a = 7 order by a; +a b c d +7 16 5 26007 +select * from t4 where a = 7 order by 2; +a b c d +7 16 5 26007 +select * from t4 where a = 7 order by c; +a b c d +7 16 5 26007 +select * from t4 where a = 7 and b = 16 order by b; +a b c d +7 16 5 26007 +select * from t4 where a = 7 and b = 16 order by a; +a b c d +7 16 5 26007 +select * from t4 where a = 7 and b = 17 order by a; +a b c d +select * from t4 where a = 7 and b != 16 order by b; +a b c d +delete from t2 where a > 5; +select x1.a, x1.b from t2 x1, t2 x2 where x1.b = x2.b order by x1.a; +a b +1 10 +3 12 +5 14 +select a, b FROM t2 outer_table where +a = (select a from t2 where b = outer_table.b ) order by a; +a b +1 10 +3 12 +5 14 +delete from t2; +delete from t3; +delete from t4; +drop table t2; +drop table t3; +drop table t4; +CREATE TABLE t5 ( +a bigint unsigned NOT NULL, +b bigint unsigned not null, +c bigint unsigned NOT NULL, +d int unsigned, +PRIMARY KEY(a, b, c) +) engine=ndbcluster; +insert into t5 values(10, 19, 5, 26010); +delete from t5 where a=10 and b=19 and c=5; +select * from t5; +a b c d +insert into t5 values(10, 19, 5, 26010); +update t5 set d=21997 where a=10 and b=19 and c=5; +select * from t5; +a b c d +10 19 5 21997 +delete from t5; +drop table t5; +CREATE TABLE t6 ( +adress char(255), +a int NOT NULL PRIMARY KEY, +b int +) engine = NDB; +insert into t6 values +("Nice road 3456", 1, 23), +("Street Road 78", 3, 92), +("Road street 89C", 5, 71), +(NULL, 7, NULL); +select * from t6 order by a; +adress a b +Nice road 3456 1 23 +Street Road 78 3 92 +Road street 89C 5 71 +NULL 7 NULL +select a, b from t6 order by a; +a b +1 23 +3 92 +5 71 +7 NULL +update t6 set adress="End of road 09" where a=3; +update t6 set b=181, adress="Street 76" where a=7; +select * from t6 order by a; +adress a b +Nice road 3456 1 23 +End of road 09 3 92 +Road street 89C 5 71 +Street 76 7 181 +select * from t6 where a=1; +adress a b +Nice road 3456 1 23 +delete from t6 where a=1; +select * from t6 order by a; +adress a b +End of road 09 3 92 +Road street 89C 5 71 +Street 76 7 181 +delete from t6 where b=71; +select * from t6 order by a; +adress a b +End of road 09 3 92 +Street 76 7 181 +drop table t6; +CREATE TABLE t7 ( +adress char(255), +a int NOT NULL, +b int, +c int NOT NULL, +PRIMARY KEY(a, c) +) engine = NDB; +insert into t7 values +("Highway 3456", 1, 23, 2), +("Street Road 78", 3, 92, 3), +("Main street 89C", 5, 71, 4), +(NULL, 8, NULL, 12); +select * from t7 order by a; +adress a b c +Highway 3456 1 23 2 +Street Road 78 3 92 3 +Main street 89C 5 71 4 +NULL 8 NULL 12 +select a, b from t7 order by a; +a b +1 23 +3 92 +5 71 +8 NULL +update t7 set adress="End of road 09" where a=3; +update t7 set adress="Gatuvägen 90C" where a=5 and c=4; +update t7 set adress="No adress" where adress is NULL; +select * from t7 order by a; +adress a b c +Highway 3456 1 23 2 +End of road 09 3 92 3 +Gatuvägen 90C 5 71 4 +No adress 8 NULL 12 +select * from t7 where a=1 and c=2; +adress a b c +Highway 3456 1 23 2 +delete from t7 where a=1; +delete from t7 where a=3 and c=3; +delete from t7 where a=5 and c=4; +select * from t7; +adress a b c +No adress 8 NULL 12 +delete from t7 where b=23; +select * from t7; +adress a b c +No adress 8 NULL 12 +drop table t7; +CREATE TABLE t1 ( +pk1 INT NOT NULL PRIMARY KEY, +attr1 INT NOT NULL, +attr2 INT, +attr3 VARCHAR(10) +) ENGINE=ndbcluster; +INSERT INTO t1 VALUES (9410,9412, NULL, '9412'), (9411,9413, 17, '9413'); +create database mysqltest; +use mysqltest; +CREATE TABLE t2 ( +a bigint unsigned NOT NULL PRIMARY KEY, +b int unsigned not null, +c int unsigned +) engine=ndbcluster; +insert into t2 select pk1,attr1,attr2 from test.t1; +select * from t2 order by a; +a b c +9410 9412 NULL +9411 9413 17 +select b from test.t1, t2 where c = test.t1.attr2; +b +9413 +select b,test.t1.attr1 from test.t1, t2 where test.t1.pk1 < a; +b attr1 +9413 9412 +drop table test.t1, t2; +drop database mysqltest; +drop database if exists ndbtest1; +create database ndbtest1; +use ndbtest1; +create table t1(id int) engine=ndbcluster; +drop database ndbtest1; +drop database ndbtest1; +ERROR HY000: Can't drop database 'ndbtest1'; database doesn't exist +use test; +create table t1 (a int primary key, b char(0)); +insert into t1 values (1,""); +insert into t1 values (2,NULL); +select * from t1 order by a; +a b +1 +2 NULL +select * from t1 order by b; +a b +2 NULL +1 +select * from t1 where b IS NULL; +a b +2 NULL +select * from t1 where b IS NOT NULL; +a b +1 +drop table t1; +create table t1 ( +c1 int, +c2 int, +c3 int, +c4 int, +c5 int, +c6 int, +c7 int, +c8 int, +c9 int, +c10 int, +c11 int, +c12 int, +c13 int, +c14 int, +c15 int, +c16 int, +c17 int, +c18 int, +c19 int, +c20 int, +c21 int, +c22 int, +c23 int, +c24 int, +c25 int, +c26 int, +c27 int, +c28 int, +c29 int, +c30 int, +c31 int, +c32 int, +c33 int, +c34 int, +c35 int, +c36 int, +c37 int, +c38 int, +c39 int, +c40 int, +c41 int, +c42 int, +c43 int, +c44 int, +c45 int, +c46 int, +c47 int, +c48 int, +c49 int, +c50 int, +c51 int, +c52 int, +c53 int, +c54 int, +c55 int, +c56 int, +c57 int, +c58 int, +c59 int, +c60 int, +c61 int, +c62 int, +c63 int, +c64 int, +c65 int, +c66 int, +c67 int, +c68 int, +c69 int, +c70 int, +c71 int, +c72 int, +c73 int, +c74 int, +c75 int, +c76 int, +c77 int, +c78 int, +c79 int, +c80 int, +c81 int, +c82 int, +c83 int, +c84 int, +c85 int, +c86 int, +c87 int, +c88 int, +c89 int, +c90 int, +c91 int, +c92 int, +c93 int, +c94 int, +c95 int, +c96 int, +c97 int, +c98 int, +c99 int, +c100 int, +c101 int, +c102 int, +c103 int, +c104 int, +c105 int, +c106 int, +c107 int, +c108 int, +c109 int, +c110 int, +c111 int, +c112 int, +c113 int, +c114 int, +c115 int, +c116 int, +c117 int, +c118 int, +c119 int, +c120 int, +c121 int, +c122 int, +c123 int, +c124 int, +c125 int, +c126 int, +c127 int, +c128 int, +primary key using hash(c1)) engine=ndb partition by key(c1); +drop table t1; +create table t1 ( +a1234567890123456789012345678901234567890 int primary key, +a12345678901234567890123456789a1234567890 int, +index(a12345678901234567890123456789a1234567890) +) engine=ndb; +show tables; +Tables_in_test +t1 +insert into t1 values (1,1),(2,1),(3,1),(4,1),(5,2),(6,1),(7,1); +explain select * from t1 where a12345678901234567890123456789a1234567890=2; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t1 ref a12345678901234567890123456789a1234567890 a12345678901234567890123456789a1234567890 5 const # Using where with pushed condition +select * from t1 where a12345678901234567890123456789a1234567890=2; +a1234567890123456789012345678901234567890 a12345678901234567890123456789a1234567890 +5 2 +drop table t1; +create table t1 +(a bigint, b bigint, c bigint, d bigint, +primary key (a,b,c,d)) +engine=ndb +max_rows=800000000; +Warnings: +Warning 1105 Ndb might have problems storing the max amount of rows specified +insert into t1 values +(1,2,3,4),(2,3,4,5),(3,4,5,6), +(3,2,3,4),(1,3,4,5),(2,4,5,6), +(1,2,3,5),(2,3,4,8),(3,4,5,9), +(3,2,3,5),(1,3,4,8),(2,4,5,9), +(1,2,3,6),(2,3,4,6),(3,4,5,7), +(3,2,3,6),(1,3,4,6),(2,4,5,7), +(1,2,3,7),(2,3,4,7),(3,4,5,8), +(3,2,3,7),(1,3,4,7),(2,4,5,8), +(1,3,3,4),(2,4,4,5),(3,5,5,6), +(3,3,3,4),(1,4,4,5),(2,5,5,6), +(1,3,3,5),(2,4,4,8),(3,5,5,9), +(3,3,3,5),(1,4,4,8),(2,5,5,9), +(1,3,3,6),(2,4,4,6),(3,5,5,7), +(3,3,3,6),(1,4,4,6),(2,5,5,7), +(1,3,3,7),(2,4,4,7),(3,5,5,8), +(3,3,3,7),(1,4,4,7),(2,5,5,8); +select count(*) from t1; +count(*) +48 +drop table t1; +create table t1 +(a bigint, b bigint, c bigint, d bigint, +primary key (a)) +engine=ndb +max_rows=1; +drop table t1; +create table t1 +(counter int(64) NOT NULL auto_increment, +datavalue char(40) default 'XXXX', +primary key (counter) +) ENGINE=ndbcluster; +insert into t1 (datavalue) values ('newval'); +insert into t1 (datavalue) values ('newval'); +select * from t1 order by counter; +counter datavalue +1 newval +2 newval +insert into t1 (datavalue) select datavalue from t1 where counter < 100; +insert into t1 (datavalue) select datavalue from t1 where counter < 100; +select * from t1 order by counter; +counter datavalue +1 newval +2 newval +3 newval +4 newval +5 newval +6 newval +7 newval +8 newval +insert into t1 (datavalue) select datavalue from t1 where counter < 100; +insert into t1 (datavalue) select datavalue from t1 where counter < 100; +select * from t1 order by counter; +counter datavalue +1 newval +2 newval +3 newval +4 newval +5 newval +6 newval +7 newval +8 newval +9 newval +10 newval +11 newval +12 newval +13 newval +14 newval +15 newval +16 newval +17 newval +18 newval +19 newval +20 newval +21 newval +22 newval +23 newval +24 newval +25 newval +26 newval +27 newval +28 newval +29 newval +30 newval +31 newval +32 newval +drop table t1; +create table t1 (a int primary key auto_increment) engine = ndb; +insert into t1() values (),(),(),(),(),(),(),(),(),(),(),(); +insert into t1(a) values (20),(28); +insert into t1() values (),(),(),(),(),(),(),(),(),(),(),(); +insert into t1() values (21), (22); +drop table t1; +CREATE TABLE t1 ( b INT ) PACK_KEYS = 0 ENGINE = ndb; +select * from t1; +b +drop table t1; +create table t1 (a int) engine=ndb; +create table t2 (a int) engine=ndb; +insert into t1 values (1); +insert into t2 values (1); +delete t1.* from t1, t2 where t1.a = t2.a; +select * from t1; +a +select * from t2; +a +1 +drop table t1; +drop table t2; +CREATE TABLE t1 ( +i INT, +j INT, +x INT, +y INT, +z INT +) engine=ndb; +CREATE TABLE t2 ( +i INT, +k INT, +x INT, +y INT, +z INT +) engine=ndb; +CREATE TABLE t3 ( +j INT, +k INT, +x INT, +y INT, +z INT +) engine=ndb; +INSERT INTO t1 VALUES ( 1, 2,13,14,15); +INSERT INTO t2 VALUES ( 1, 3,23,24,25); +INSERT INTO t3 VALUES ( 2, 3, 1,34,35), ( 2, 3, 1,34,36); +UPDATE t1 AS a +INNER JOIN t2 AS b +ON a.i = b.i +INNER JOIN t3 AS c +ON a.j = c.j AND b.k = c.k +SET a.x = b.x, +a.y = b.y, +a.z = ( +SELECT sum(z) +FROM t3 +WHERE y = 34 +) +WHERE b.x = 23; +select * from t1; +i j x y z +1 2 23 24 71 +drop table t1; +drop table t2; +drop table t3; +create table atablewithareallylongandirritatingname (a int); +insert into atablewithareallylongandirritatingname values (2); +select * from atablewithareallylongandirritatingname; +a +2 +drop table atablewithareallylongandirritatingname; +create table t1 (f1 varchar(50), f2 text,f3 int, primary key(f1)) engine=NDB; +insert into t1 (f1,f2,f3)VALUES("111111","aaaaaa",1); +insert into t1 (f1,f2,f3)VALUES("222222","bbbbbb",2); +select * from t1 order by f1; +f1 f2 f3 +111111 aaaaaa 1 +222222 bbbbbb 2 +select * from t1 order by f2; +f1 f2 f3 +111111 aaaaaa 1 +222222 bbbbbb 2 +select * from t1 order by f3; +f1 f2 f3 +111111 aaaaaa 1 +222222 bbbbbb 2 +drop table t1; +Illegal ndb error code: 1186 +CREATE TABLE t1 ( +a VARBINARY(40) NOT NULL, +b VARCHAR (256) CHARACTER SET UTF8 NOT NULL, +c VARCHAR(256) CHARACTER SET UTF8 NOT NULL, +PRIMARY KEY (b,c)) ENGINE=ndbcluster; +INSERT INTO t1 VALUES +("a","ab","abc"),("b","abc","abcd"),("c","abc","ab"),("d","ab","ab"),("e","abc","abc"); +SELECT * FROM t1 ORDER BY a; +a b c +a ab abc +b abc abcd +c abc ab +d ab ab +e abc abc +DROP TABLE t1; +create table t1 (a int not null primary key, b int not null) engine=ndb; +create table t2 (a int not null primary key, b int not null) engine=ndb; +insert into t1 values (1,10), (2,20), (3,30); +insert into t2 values (1,10), (2,20), (3,30); +select * from t1 order by a; +a b +1 10 +2 20 +3 30 +delete from t1 where a > 0 order by a desc limit 1; +select * from t1 order by a; +a b +1 10 +2 20 +delete from t1,t2 using t1,t2 where t1.a = t2.a; +select * from t2 order by a; +a b +3 30 +drop table t1,t2; +create table t1 (a int not null primary key, b int not null) engine=ndb; +insert into t1 values (1,10), (2,20), (3,30); +insert into t1 set a=1, b=100; +ERROR 23000: Duplicate entry '1' for key 'PRIMARY' +insert ignore into t1 set a=1, b=100; +select * from t1 order by a; +a b +1 10 +2 20 +3 30 +insert into t1 set a=1, b=1000 on duplicate key update b=b+1; +select * from t1 order by a; +a b +1 11 +2 20 +3 30 +drop table t1; +create table t1 (a int not null primary key, b int not null) engine=ndb; +create table t2 (c int not null primary key, d int not null) engine=ndb; +insert into t1 values (1,10), (2,10), (3,30), (4, 30); +insert into t2 values (1,10), (2,10), (3,30), (4, 30); +update t1 set a = 1 where a = 3; +ERROR 23000: Duplicate entry '1' for key 'PRIMARY' +select * from t1 order by a; +a b +1 10 +2 10 +3 30 +4 30 +update t1 set b = 1 where a > 1 order by a desc limit 1; +select * from t1 order by a; +a b +1 10 +2 10 +3 30 +4 1 +update t1,t2 set a = 1, c = 1 where a = 3 and c = 3; +ERROR 23000: Duplicate entry '1' for key 'PRIMARY' +select * from t1 order by a; +a b +1 10 +2 10 +3 30 +4 1 +update ignore t1,t2 set a = 1, c = 1 where a = 3 and c = 3; +select * from t1 order by a; +a b +1 10 +2 10 +3 30 +4 1 +drop table t1,t2; +End of 5.0 tests +CREATE TABLE t1 (a VARCHAR(255) NOT NULL, +CONSTRAINT pk_a PRIMARY KEY (a))engine=ndb; +CREATE TABLE t2(a VARCHAR(255) NOT NULL, +b VARCHAR(255) NOT NULL, +c VARCHAR(255) NOT NULL, +CONSTRAINT pk_b_c_id PRIMARY KEY (b,c), +CONSTRAINT fk_a FOREIGN KEY(a) REFERENCES t1(a))engine=ndb; +drop table t1, t2; +create table t1 (a int not null primary key, b int) engine=ndb; +insert into t1 values(1,1),(2,2),(3,3); +create table t2 like t1; +insert into t2 select * from t1; +select * from t1 order by a; +a b +1 1 +2 2 +3 3 +select * from t2 order by a; +a b +1 1 +2 2 +3 3 +drop table t1, t2; +create table t1 (a int not null primary key, b int not null default 0, c varchar(254)) engine=ndb; +create table if not exists t1 (a int not null primary key, b int not null default 0, c varchar(254)) engine=ndb; +create table t2 like t1; +rename table t1 to t10, t2 to t20; +drop table t10,t20; +End of 5.1 tests diff --git a/mysql-test/suite/ndb/r/ndb_binlog_basic.result b/mysql-test/suite/ndb/r/ndb_binlog_basic.result new file mode 100644 index 00000000000..931d01dbebe --- /dev/null +++ b/mysql-test/suite/ndb/r/ndb_binlog_basic.result @@ -0,0 +1,51 @@ +drop table if exists t1, t2; +drop database if exists mysqltest; +create database mysqltest; +use mysqltest; +drop database mysqltest; +use test; +create table t1 (a int primary key) engine=ndb; +insert into t1 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9); +select @max_epoch:=max(epoch)-1 from mysql.ndb_binlog_index; +@max_epoch:=max(epoch)-1 +# +delete from t1; +alter table t1 add (b int); +insert into t1 values (3,3),(4,4); +alter table t1 rename t2; +begin; +insert into t2 values (1,1),(2,2); +update t2 set b=1 where a=3; +delete from t2 where a=4; +commit; +drop table t2; +select inserts from mysql.ndb_binlog_index where epoch > @max_epoch and inserts > 5; +inserts +10 +select deletes from mysql.ndb_binlog_index where epoch > @max_epoch and deletes > 5; +deletes +10 +select inserts,updates,deletes from +mysql.ndb_binlog_index where epoch > @max_epoch and updates > 0; +inserts updates deletes +2 1 1 +flush logs; +purge master logs before now(); +select count(*) from mysql.ndb_binlog_index; +count(*) +0 +create table t1 (a int primary key, b int) engine=ndb; +create database mysqltest; +use mysqltest; +create table t1 (c int, d int primary key) engine=ndb; +use test; +insert into mysqltest.t1 values (2,1),(2,2); +select @max_epoch:=max(epoch)-1 from mysql.ndb_binlog_index; +@max_epoch:=max(epoch)-1 +# +drop table t1; +drop database mysqltest; +select inserts,updates,deletes from +mysql.ndb_binlog_index where epoch > @max_epoch and inserts > 0; +inserts updates deletes +2 0 0 diff --git a/mysql-test/suite/ndb/r/ndb_binlog_ddl_multi.result b/mysql-test/suite/ndb/r/ndb_binlog_ddl_multi.result new file mode 100644 index 00000000000..6631feeaa17 --- /dev/null +++ b/mysql-test/suite/ndb/r/ndb_binlog_ddl_multi.result @@ -0,0 +1,196 @@ +drop database if exists mysqltest; +drop table if exists t1,t2,t3; +drop database if exists mysqltest; +drop table if exists t1,t2,t3; +reset master; +reset master; +create database mysqltest; +use mysqltest; +create table t1 (a int primary key) engine=ndb; +create table t2 (a int primary key) engine=ndb; +show binlog events from <binlog_start>; +Log_name Pos Event_type Server_id End_log_pos Info +master-bin1.000001 # Query 1 # create database mysqltest +master-bin1.000001 # Query 1 # use `mysqltest`; create table t1 (a int primary key) engine=ndb +master-bin1.000001 # Query 102 # use `test`; create table t2 (a int primary key) engine=ndb +show binlog events from <binlog_start>; +Log_name Pos Event_type Server_id End_log_pos Info +master-bin.000001 # Query 1 # create database mysqltest +master-bin.000001 # Query 1 # use `mysqltest`; create table t1 (a int primary key) engine=ndb +master-bin.000001 # Query 102 # use `test`; create table t2 (a int primary key) engine=ndb +reset master; +reset master; +alter table t2 add column (b int); +show binlog events from <binlog_start>; +Log_name Pos Event_type Server_id End_log_pos Info +master-bin.000001 # Query 102 # use `test`; alter table t2 add column (b int) +reset master; +reset master; +ALTER DATABASE mysqltest CHARACTER SET latin1; +drop table mysqltest.t1; +show binlog events from <binlog_start>; +Log_name Pos Event_type Server_id End_log_pos Info +master-bin.000001 # Query 102 # ALTER DATABASE mysqltest CHARACTER SET latin1 +master-bin.000001 # Query 102 # use `mysqltest`; drop table `t1` +show binlog events from <binlog_start>; +Log_name Pos Event_type Server_id End_log_pos Info +master-bin.000001 # Query 102 # ALTER DATABASE mysqltest CHARACTER SET latin1 +master-bin.000001 # Query 102 # use `mysqltest`; drop table `t1` +reset master; +reset master; +use test; +insert into t2 values (1,2); +drop database mysqltest; +create table t1 (a int primary key) engine=ndb; +show binlog events from <binlog_start>; +Log_name Pos Event_type Server_id End_log_pos Info +master-bin1.000001 # Query 102 # BEGIN +master-bin1.000001 # Table_map 102 # table_id: # (test.t2) +master-bin1.000001 # Table_map 102 # table_id: # (mysql.ndb_apply_status) +master-bin1.000001 # Write_rows 102 # table_id: # +master-bin1.000001 # Write_rows 102 # table_id: # flags: STMT_END_F +master-bin1.000001 # Query 102 # COMMIT +master-bin1.000001 # Query 1 # drop database mysqltest +master-bin1.000001 # Query 1 # use `test`; create table t1 (a int primary key) engine=ndb +drop table t2; +reset master; +reset master; +CREATE LOGFILE GROUP lg1 +ADD UNDOFILE 'undofile.dat' +INITIAL_SIZE 16M +UNDO_BUFFER_SIZE = 1M +ENGINE=NDB; +ALTER LOGFILE GROUP lg1 +ADD UNDOFILE 'undofile02.dat' +INITIAL_SIZE = 4M +ENGINE=NDB; +CREATE TABLESPACE ts1 +ADD DATAFILE 'datafile.dat' +USE LOGFILE GROUP lg1 +INITIAL_SIZE 12M +ENGINE NDB; +ALTER TABLESPACE ts1 +ADD DATAFILE 'datafile02.dat' +INITIAL_SIZE = 4M +ENGINE=NDB; +ALTER TABLESPACE ts1 +DROP DATAFILE 'datafile.dat' +ENGINE = NDB; +ALTER TABLESPACE ts1 +DROP DATAFILE 'datafile02.dat' +ENGINE = NDB; +DROP TABLESPACE ts1 +ENGINE = NDB; +DROP LOGFILE GROUP lg1 +ENGINE =NDB; +show binlog events from <binlog_start>; +Log_name Pos Event_type Server_id End_log_pos Info +master-bin1.000001 # Query 1 # CREATE LOGFILE GROUP lg1 +ADD UNDOFILE 'undofile.dat' +INITIAL_SIZE 16M +UNDO_BUFFER_SIZE = 1M +ENGINE=NDB +master-bin1.000001 # Query 1 # ALTER LOGFILE GROUP lg1 +ADD UNDOFILE 'undofile02.dat' +INITIAL_SIZE = 4M +ENGINE=NDB +master-bin1.000001 # Query 1 # CREATE TABLESPACE ts1 +ADD DATAFILE 'datafile.dat' +USE LOGFILE GROUP lg1 +INITIAL_SIZE 12M +ENGINE NDB +master-bin1.000001 # Query 1 # ALTER TABLESPACE ts1 +ADD DATAFILE 'datafile02.dat' +INITIAL_SIZE = 4M +ENGINE=NDB +master-bin1.000001 # Query 1 # ALTER TABLESPACE ts1 +DROP DATAFILE 'datafile.dat' +ENGINE = NDB +master-bin1.000001 # Query 1 # ALTER TABLESPACE ts1 +DROP DATAFILE 'datafile02.dat' +ENGINE = NDB +master-bin1.000001 # Query 1 # DROP TABLESPACE ts1 +ENGINE = NDB +master-bin1.000001 # Query 1 # DROP LOGFILE GROUP lg1 +ENGINE =NDB +show binlog events from <binlog_start>; +Log_name Pos Event_type Server_id End_log_pos Info +master-bin1.000001 # Query 1 # CREATE LOGFILE GROUP lg1 +ADD UNDOFILE 'undofile.dat' +INITIAL_SIZE 16M +UNDO_BUFFER_SIZE = 1M +ENGINE=NDB +master-bin1.000001 # Query 1 # ALTER LOGFILE GROUP lg1 +ADD UNDOFILE 'undofile02.dat' +INITIAL_SIZE = 4M +ENGINE=NDB +master-bin1.000001 # Query 1 # CREATE TABLESPACE ts1 +ADD DATAFILE 'datafile.dat' +USE LOGFILE GROUP lg1 +INITIAL_SIZE 12M +ENGINE NDB +master-bin1.000001 # Query 1 # ALTER TABLESPACE ts1 +ADD DATAFILE 'datafile02.dat' +INITIAL_SIZE = 4M +ENGINE=NDB +master-bin1.000001 # Query 1 # ALTER TABLESPACE ts1 +DROP DATAFILE 'datafile.dat' +ENGINE = NDB +master-bin1.000001 # Query 1 # ALTER TABLESPACE ts1 +DROP DATAFILE 'datafile02.dat' +ENGINE = NDB +master-bin1.000001 # Query 1 # DROP TABLESPACE ts1 +ENGINE = NDB +master-bin1.000001 # Query 1 # DROP LOGFILE GROUP lg1 +ENGINE =NDB +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 1 # use `test`; create table t1 (a int key) engine=ndb +master-bin1.000001 # Query 1 # use `test`; create table t2 (a int key) engine=ndb +master-bin1.000001 # Query 1 # use `test`; create table t3 (a int key) engine=ndb +master-bin1.000001 # Query 1 # use `test`; rename table `test.t3` to `test.t4` +master-bin1.000001 # Query 1 # use `test`; rename table `test.t2` to `test.t3` +master-bin1.000001 # Query 1 # use `test`; rename table `test.t1` to `test.t2` +master-bin1.000001 # Query 1 # 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); +drop table t2; +show binlog events from <binlog_start>; +Log_name Pos Event_type Server_id End_log_pos Info +master-bin1.000001 # Query 1 # use `test`; create table t1 (a int key) engine=ndb +master-bin1.000001 # Query 102 # BEGIN +master-bin1.000001 # Table_map 102 # table_id: # (test.t1) +master-bin1.000001 # Table_map 102 # table_id: # (mysql.ndb_apply_status) +master-bin1.000001 # Write_rows 102 # table_id: # +master-bin1.000001 # Write_rows 102 # table_id: # flags: STMT_END_F +master-bin1.000001 # Query 102 # COMMIT +master-bin1.000001 # Query 1 # use `test`; rename table `test.t1` to `test.t2` +master-bin1.000001 # Query 102 # BEGIN +master-bin1.000001 # Table_map 102 # table_id: # (test.t2) +master-bin1.000001 # Table_map 102 # table_id: # (mysql.ndb_apply_status) +master-bin1.000001 # Write_rows 102 # table_id: # +master-bin1.000001 # Write_rows 102 # table_id: # flags: STMT_END_F +master-bin1.000001 # Query 102 # COMMIT +master-bin1.000001 # Query 102 # use `test`; drop table t2 diff --git a/mysql-test/suite/ndb/r/ndb_binlog_discover.result b/mysql-test/suite/ndb/r/ndb_binlog_discover.result new file mode 100644 index 00000000000..7c3a976c4d5 --- /dev/null +++ b/mysql-test/suite/ndb/r/ndb_binlog_discover.result @@ -0,0 +1,17 @@ +drop table if exists t1; +create table t1 (a int key) engine=ndb; +reset master; +show binlog events from <binlog_start>; +Log_name Pos Event_type Server_id End_log_pos Info +master-bin.000001 # Incident 1 # #1 (LOST_EVENTS) +master-bin.000001 # Rotate 1 # master-bin.000002;pos=4 +PURGE MASTER LOGS TO 'master-bin.000002'; +show binlog events from <binlog_start>; +Log_name Pos Event_type Server_id End_log_pos Info +master-bin.000002 # Query 1 # BEGIN +master-bin.000002 # Table_map 1 # table_id: # (test.t1) +master-bin.000002 # Table_map 1 # table_id: # (mysql.ndb_apply_status) +master-bin.000002 # Write_rows 1 # table_id: # +master-bin.000002 # Write_rows 1 # table_id: # flags: STMT_END_F +master-bin.000002 # Query 1 # COMMIT +drop table t1; diff --git a/mysql-test/suite/ndb/r/ndb_binlog_format.result b/mysql-test/suite/ndb/r/ndb_binlog_format.result new file mode 100644 index 00000000000..ed26060e2a4 --- /dev/null +++ b/mysql-test/suite/ndb/r/ndb_binlog_format.result @@ -0,0 +1,30 @@ +drop table if exists t1, t2, t3; +CREATE TABLE t1 (m INT, n INT) ENGINE=MYISAM; +CREATE TABLE t2 (b INT, c INT) ENGINE=BLACKHOLE; +CREATE TABLE t3 (e INT, f INT) ENGINE=NDB; +RESET MASTER; +SET SESSION BINLOG_FORMAT=STATEMENT; +INSERT INTO t1 VALUES (1,1), (1,2), (2,1), (2,2); +INSERT INTO t2 VALUES (1,1), (1,2), (2,1), (2,2); +UPDATE t1, t2 SET m = 2, b = 3 WHERE n = c; +START TRANSACTION; +INSERT INTO t3 VALUES (1,1), (1,2), (2,1), (2,2); +UPDATE t1, t3 SET m = 2, e = 3 WHERE n = f; +UPDATE t3, t2 SET e = 2, b = 3 WHERE f = c; +COMMIT; +show binlog events from <binlog_start>; +Log_name Pos Event_type Server_id End_log_pos Info +master-bin.000001 # Query # # use `test`; INSERT INTO t1 VALUES (1,1), (1,2), (2,1), (2,2) +master-bin.000001 # Query # # use `test`; INSERT INTO t2 VALUES (1,1), (1,2), (2,1), (2,2) +master-bin.000001 # Query # # use `test`; UPDATE t1, t2 SET m = 2, b = 3 WHERE n = c +master-bin.000001 # Query # # use `test`; BEGIN +master-bin.000001 # Query # # use `test`; INSERT INTO t3 VALUES (1,1), (1,2), (2,1), (2,2) +master-bin.000001 # Query # # use `test`; UPDATE t1, t3 SET m = 2, e = 3 WHERE n = f +master-bin.000001 # Query # # use `test`; UPDATE t3, t2 SET e = 2, b = 3 WHERE f = c +master-bin.000001 # Query # # use `test`; COMMIT +master-bin.000001 # Query # # BEGIN +master-bin.000001 # Table_map # # table_id: # (test.t3) +master-bin.000001 # Table_map # # table_id: # (mysql.ndb_apply_status) +master-bin.000001 # Write_rows # # table_id: # flags: STMT_END_F +master-bin.000001 # Query # # COMMIT +DROP TABLE t1, t2, t3; diff --git a/mysql-test/suite/ndb/r/ndb_binlog_ignore_db.result b/mysql-test/suite/ndb/r/ndb_binlog_ignore_db.result new file mode 100644 index 00000000000..e4c9faa802c --- /dev/null +++ b/mysql-test/suite/ndb/r/ndb_binlog_ignore_db.result @@ -0,0 +1,11 @@ +reset master; +drop table if exists t1; +drop database if exists mysqltest; +create database mysqltest; +use mysqltest; +create table t1 (a int primary key, b int) engine=ndb; +insert into t1 values (1, 1); +show binlog events from <binlog_start>; +Log_name Pos Event_type Server_id End_log_pos Info +master-bin.000001 # Query 1 # use `test`; drop table if exists t1 +drop database mysqltest; diff --git a/mysql-test/suite/ndb/r/ndb_binlog_log_bin.result b/mysql-test/suite/ndb/r/ndb_binlog_log_bin.result new file mode 100644 index 00000000000..f80a46324e0 --- /dev/null +++ b/mysql-test/suite/ndb/r/ndb_binlog_log_bin.result @@ -0,0 +1,80 @@ +drop table if exists t1,t2,t3; +reset master; +drop table if exists t1,t2,t3; +reset master; +set SQL_LOG_BIN=0; +create database mysqltest; +use mysqltest; +create table t1 (a int key, b int) engine=ndb; +create table t2 (a int key, b int) engine=ndb; +insert into t1 values (1,1); +alter table t1 add c int; +show binlog events from <binlog_start>; +Log_name Pos Event_type Server_id End_log_pos Info +master-bin.000001 # Query 1 # BEGIN +master-bin.000001 # Table_map 1 # table_id: # (mysqltest.t1) +master-bin.000001 # Table_map 1 # table_id: # (mysql.ndb_apply_status) +master-bin.000001 # Write_rows 1 # table_id: # flags: STMT_END_F +master-bin.000001 # Query 1 # COMMIT +reset master; +use mysqltest; +insert into t2 values (1,1); +show binlog events from <binlog_start>; +Log_name Pos Event_type Server_id End_log_pos Info +master-bin1.000001 # Query 102 # BEGIN +master-bin1.000001 # Table_map 102 # table_id: # (mysqltest.t1) +master-bin1.000001 # Table_map 102 # table_id: # (mysql.ndb_apply_status) +master-bin1.000001 # Write_rows 102 # table_id: # flags: STMT_END_F +master-bin1.000001 # Query 102 # COMMIT +master-bin1.000001 # Query 102 # BEGIN +master-bin1.000001 # Table_map 102 # table_id: # (mysqltest.t2) +master-bin1.000001 # Table_map 102 # table_id: # (mysql.ndb_apply_status) +master-bin1.000001 # Write_rows 102 # table_id: # +master-bin1.000001 # Write_rows 102 # table_id: # flags: STMT_END_F +master-bin1.000001 # Query 102 # COMMIT +reset master; +use mysqltest; +drop table t1; +drop table t2; +create table t1 (d int key, e int) engine=ndb; +create table t2 (d int key, e int) engine=ndb; +insert into t1 values (1,1); +show binlog events from <binlog_start>; +Log_name Pos Event_type Server_id End_log_pos Info +master-bin.000001 # Query 1 # BEGIN +master-bin.000001 # Table_map 1 # table_id: # (mysqltest.t2) +master-bin.000001 # Table_map 1 # table_id: # (mysql.ndb_apply_status) +master-bin.000001 # Write_rows 1 # table_id: # +master-bin.000001 # Write_rows 1 # table_id: # flags: STMT_END_F +master-bin.000001 # Query 1 # COMMIT +master-bin.000001 # Query 1 # use `mysqltest`; drop table t1 +master-bin.000001 # Query 1 # use `mysqltest`; drop table t2 +master-bin.000001 # Query 1 # use `mysqltest`; create table t1 (d int key, e int) engine=ndb +master-bin.000001 # Query 1 # use `mysqltest`; create table t2 (d int key, e int) engine=ndb +master-bin.000001 # Query 1 # BEGIN +master-bin.000001 # Table_map 1 # table_id: # (mysqltest.t1) +master-bin.000001 # Table_map 1 # table_id: # (mysql.ndb_apply_status) +master-bin.000001 # Write_rows 1 # table_id: # +master-bin.000001 # Write_rows 1 # table_id: # flags: STMT_END_F +master-bin.000001 # Query 1 # COMMIT +use mysqltest; +insert into t2 values (1,1); +show binlog events from <binlog_start>; +Log_name Pos Event_type Server_id End_log_pos Info +master-bin1.000001 # Query 1 # use `mysqltest`; drop table `t1` +master-bin1.000001 # Query 1 # use `mysqltest`; drop table `t2` +master-bin1.000001 # Query 1 # use `mysqltest`; create table t1 (d int key, e int) engine=ndb +master-bin1.000001 # Query 1 # use `mysqltest`; create table t2 (d int key, e int) engine=ndb +master-bin1.000001 # Query 102 # BEGIN +master-bin1.000001 # Table_map 102 # table_id: # (mysqltest.t1) +master-bin1.000001 # Table_map 102 # table_id: # (mysql.ndb_apply_status) +master-bin1.000001 # Write_rows 102 # table_id: # +master-bin1.000001 # Write_rows 102 # table_id: # flags: STMT_END_F +master-bin1.000001 # Query 102 # COMMIT +master-bin1.000001 # Query 102 # BEGIN +master-bin1.000001 # Table_map 102 # table_id: # (mysqltest.t2) +master-bin1.000001 # Table_map 102 # table_id: # (mysql.ndb_apply_status) +master-bin1.000001 # Write_rows 102 # table_id: # +master-bin1.000001 # Write_rows 102 # table_id: # flags: STMT_END_F +master-bin1.000001 # Query 102 # COMMIT +drop database mysqltest; diff --git a/mysql-test/suite/ndb/r/ndb_binlog_multi.result b/mysql-test/suite/ndb/r/ndb_binlog_multi.result new file mode 100644 index 00000000000..b2a9da39be0 --- /dev/null +++ b/mysql-test/suite/ndb/r/ndb_binlog_multi.result @@ -0,0 +1,80 @@ +drop table if exists t1,t2,t3; +drop table if exists t1,t2,t3; +CREATE TABLE t3 (dummy INT PRIMARY KEY) ENGINE = NDB; +DROP TABLE t3; +reset master; +reset master; +CREATE TABLE t2 (a INT PRIMARY KEY, b int) ENGINE = NDB; +INSERT INTO t2 VALUES (1,1),(2,2); +show binlog events from <binlog_start>; +Log_name Pos Event_type Server_id End_log_pos Info +master-bin1.000001 # Query 102 # use `test`; CREATE TABLE t2 (a INT PRIMARY KEY, b int) ENGINE = NDB +master-bin1.000001 # Query 102 # BEGIN +master-bin1.000001 # Table_map 102 # table_id: # (test.t2) +master-bin1.000001 # Table_map 102 # table_id: # (mysql.ndb_apply_status) +master-bin1.000001 # Write_rows 102 # table_id: # +master-bin1.000001 # Write_rows 102 # table_id: # flags: STMT_END_F +master-bin1.000001 # Query 102 # COMMIT +select * from t2 order by a; +a b +1 1 +2 2 +SELECT @the_epoch:=epoch,inserts,updates,deletes,schemaops FROM +mysql.ndb_binlog_index ORDER BY epoch DESC LIMIT 1; +@the_epoch:=epoch inserts updates deletes schemaops +<the_epoch> 2 0 0 0 +SELECT * FROM t2 ORDER BY a; +a b +1 1 +2 2 +DROP TABLE t2; +show binlog events from <binlog_start>; +Log_name Pos Event_type Server_id End_log_pos Info +master-bin.000001 # Query 102 # use `test`; CREATE TABLE t2 (a INT PRIMARY KEY, b int) ENGINE = NDB +master-bin.000001 # Query 1 # BEGIN +master-bin.000001 # Table_map 1 # table_id: # (test.t2) +master-bin.000001 # Table_map 1 # table_id: # (mysql.ndb_apply_status) +master-bin.000001 # Write_rows 1 # table_id: # +master-bin.000001 # Write_rows 1 # table_id: # flags: STMT_END_F +master-bin.000001 # Query 1 # COMMIT +master-bin.000001 # Query 1 # use `test`; DROP TABLE t2 +SELECT inserts,updates,deletes,schemaops FROM +mysql.ndb_binlog_index WHERE epoch=<the_epoch>; +inserts updates deletes schemaops +2 0 0 0 +reset master; +reset master; +CREATE TABLE t1 (a INT PRIMARY KEY) ENGINE = NDB; +INSERT INTO t1 VALUES (1),(2); +show binlog events from <binlog_start>; +Log_name Pos Event_type Server_id End_log_pos Info +master-bin1.000001 # Query 102 # use `test`; CREATE TABLE t1 (a INT PRIMARY KEY) ENGINE = NDB +master-bin1.000001 # Query 102 # BEGIN +master-bin1.000001 # Table_map 102 # table_id: # (test.t1) +master-bin1.000001 # Table_map 102 # table_id: # (mysql.ndb_apply_status) +master-bin1.000001 # Write_rows 102 # table_id: # +master-bin1.000001 # Write_rows 102 # table_id: # flags: STMT_END_F +master-bin1.000001 # Query 102 # COMMIT +SELECT @the_epoch2:=epoch,inserts,updates,deletes,schemaops FROM +mysql.ndb_binlog_index ORDER BY epoch DESC LIMIT 1; +@the_epoch2:=epoch inserts updates deletes schemaops +<the_epoch2> 2 0 0 0 +SELECT inserts,updates,deletes,schemaops FROM +mysql.ndb_binlog_index WHERE epoch > <the_epoch> AND epoch <= <the_epoch2>; +inserts updates deletes schemaops +2 0 0 0 +drop table t1; +show binlog events from <binlog_start>; +Log_name Pos Event_type Server_id End_log_pos Info +master-bin1.000001 # Query 102 # use `test`; CREATE TABLE t1 (a INT PRIMARY KEY) ENGINE = NDB +master-bin1.000001 # Query 102 # BEGIN +master-bin1.000001 # Table_map 102 # table_id: # (test.t1) +master-bin1.000001 # Table_map 102 # table_id: # (mysql.ndb_apply_status) +master-bin1.000001 # Write_rows 102 # table_id: # +master-bin1.000001 # Write_rows 102 # table_id: # flags: STMT_END_F +master-bin1.000001 # Query 102 # COMMIT +master-bin1.000001 # Query 102 # use `test`; drop table t1 +SELECT inserts,updates,deletes,schemaops FROM +mysql.ndb_binlog_index WHERE epoch > <the_epoch> AND epoch <= <the_epoch2>; +inserts updates deletes schemaops +2 0 0 0 diff --git a/mysql-test/suite/ndb/r/ndb_bitfield.result b/mysql-test/suite/ndb/r/ndb_bitfield.result new file mode 100644 index 00000000000..59c4d420b22 --- /dev/null +++ b/mysql-test/suite/ndb/r/ndb_bitfield.result @@ -0,0 +1,224 @@ +drop table if exists t1; +create table t1 ( +pk1 int not null primary key, +b bit(64) +) engine=ndbcluster; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `pk1` int(11) NOT NULL, + `b` bit(64) DEFAULT NULL, + PRIMARY KEY (`pk1`) +) ENGINE=ndbcluster DEFAULT CHARSET=latin1 +insert into t1 values +(0,b'1111111111111111111111111111111111111111111111111111111111111111'), +(1,b'1000000000000000000000000000000000000000000000000000000000000000'), +(2,b'0000000000000000000000000000000000000000000000000000000000000001'), +(3,b'1010101010101010101010101010101010101010101010101010101010101010'), +(4,b'0101010101010101010101010101010101010101010101010101010101010101'); +select hex(b) from t1 order by pk1; +hex(b) +FFFFFFFFFFFFFFFF +8000000000000000 +1 +AAAAAAAAAAAAAAAA +5555555555555555 +drop table t1; +create table t1 ( +pk1 int not null primary key, +b bit(9) +) engine=ndbcluster; +insert into t1 values +(0,b'000000000'), +(1,b'000000001'), +(2,b'000000010'), +(3,b'000000011'), +(4,b'000000100'); +select hex(b) from t1 order by pk1; +hex(b) +0 +1 +2 +3 +4 +update t1 set b = b + b'101010101'; +select hex(b) from t1 order by pk1; +hex(b) +155 +156 +157 +158 +159 +drop table t1; +create table t1 (a bit(7), b bit(9)) engine = ndbcluster; +insert into t1 values +(94, 46), (31, 438), (61, 152), (78, 123), (88, 411), (122, 118), (0, 177), +(75, 42), (108, 67), (79, 349), (59, 188), (68, 206), (49, 345), (118, 380), +(111, 368), (94, 468), (56, 379), (77, 133), (29, 399), (9, 363), (23, 36), +(116, 390), (119, 368), (87, 351), (123, 411), (24, 398), (34, 202), (28, 499), +(30, 83), (5, 178), (60, 343), (4, 245), (104, 280), (106, 446), (127, 403), +(44, 307), (68, 454), (57, 135); +select a+0 from t1 order by a; +a+0 +0 +4 +5 +9 +23 +24 +28 +29 +30 +31 +34 +44 +49 +56 +57 +59 +60 +61 +68 +68 +75 +77 +78 +79 +87 +88 +94 +94 +104 +106 +108 +111 +116 +118 +119 +122 +123 +127 +select b+0 from t1 order by b; +b+0 +36 +42 +46 +67 +83 +118 +123 +133 +135 +152 +177 +178 +188 +202 +206 +245 +280 +307 +343 +345 +349 +351 +363 +368 +368 +379 +380 +390 +398 +399 +403 +411 +411 +438 +446 +454 +468 +499 +drop table t1; +create table t1 ( +dummyKey INTEGER NOT NULL, +a001 TINYINT, +a010 TINYINT, +a012 TINYINT, +a015 TINYINT, +a016 TINYINT, +a017 TINYINT, +a019 TINYINT, +a029 TINYINT, +a030 TINYINT, +a031 TINYINT, +a032 TINYINT, +a042 TINYINT, +a043 TINYINT, +a044 TINYINT, +a3001 TINYINT, +a3002 TINYINT, +a3003 TINYINT, +a3004 TINYINT, +a3005 TINYINT, +a3021 TINYINT, +a3022 TINYINT, +a BIT(6), +b BIT(6), +c BIT(6), +d TINYINT, +e TINYINT, +f TINYINT, +g TINYINT, +h TINYINT, +i TINYINT, +j TINYINT, +k TINYINT, +l TINYINT, +m TINYINT, +n TINYINT, +o TINYINT, +a034 TINYINT, +PRIMARY KEY USING HASH (dummyKey) ) engine=ndb; +INSERT INTO `t1` VALUES +(1,1,1,1,1,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,b'000001',b'111111',b'111110',4,5,5,5,5,5,5,5,5,5,3,2,1), +(2,1,1,1,1,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,b'000010',b'000000',b'111101',4,5,5,5,5,5,5,5,5,5,3,2,1), +(3,1,1,1,1,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,b'000100',b'001111',b'111011',4,5,5,5,5,5,5,5,5,5,3,2,1), +(4,1,1,1,1,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,b'001000',b'110000',b'110111',4,5,5,5,5,5,5,5,5,5,3,2,1), +(5,1,1,1,1,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,b'010000',b'100001',b'101111',4,5,5,5,5,5,5,5,5,5,3,2,1), +(6,1,1,1,1,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,b'100000',b'010010',b'011111',4,5,5,5,5,5,5,5,5,5,3,2,1), +(7,1,1,1,1,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,b'000000',b'001100',b'111111',4,5,5,5,5,5,5,5,5,5,3,2,1), +(8,1,1,1,1,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,b'111111',b'000000',b'000000',4,5,5,5,5,5,5,5,5,5,3,2,1); +INSERT INTO `t1` VALUES (1,1,1,1,1,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0x01,0x3F,0x3E,4,5,5,5,5,5,5,5,5,5,3,2,1); +INSERT INTO `t1` VALUES (2,1,1,1,1,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0x02,0x00,0x3D,4,5,5,5,5,5,5,5,5,5,3,2,1); +INSERT INTO `t1` VALUES (3,1,1,1,1,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0x04,0x0F,0x3B,4,5,5,5,5,5,5,5,5,5,3,2,1); +INSERT INTO `t1` VALUES (4,1,1,1,1,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0x08,0x30,0x37,4,5,5,5,5,5,5,5,5,5,3,2,1); +INSERT INTO `t1` VALUES (5,1,1,1,1,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0x10,0x21,0x2F,4,5,5,5,5,5,5,5,5,5,3,2,1); +INSERT INTO `t1` VALUES (6,1,1,1,1,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0x20,0x12,0x1F,4,5,5,5,5,5,5,5,5,5,3,2,1); +INSERT INTO `t1` VALUES (7,1,1,1,1,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0x00,0x0C,0x3F,4,5,5,5,5,5,5,5,5,5,3,2,1); +INSERT INTO `t1` VALUES (8,1,1,1,1,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0x3F,0x00,0x00,4,5,5,5,5,5,5,5,5,5,3,2,1); +drop table t1; +create table t1 ( +pk1 bit(9) not null primary key, +b int +) engine=ndbcluster; +ERROR HY000: Can't create table 'test.t1' (errno: 906) +show warnings; +Level Code Message +Error 1296 Got error 906 'Unsupported attribute type in index' from NDB +Error 1005 Can't create table 'test.t1' (errno: 906) +create table t1 ( +pk1 int not null primary key, +b bit(9), +key(b) +) engine=ndbcluster; +ERROR HY000: Can't create table 'test.t1' (errno: 906) +show warnings; +Level Code Message +Error 1296 Got error 906 'Unsupported attribute type in index' from NDB +Error 1005 Can't create table 'test.t1' (errno: 906) +create table t1 ( +pk1 int primary key, +b bit(32) not null +) engine=ndbcluster; +insert into t1 values (1,1); +drop table t1; diff --git a/mysql-test/suite/ndb/r/ndb_blob.result b/mysql-test/suite/ndb/r/ndb_blob.result new file mode 100644 index 00000000000..34f2c5fdd66 --- /dev/null +++ b/mysql-test/suite/ndb/r/ndb_blob.result @@ -0,0 +1,570 @@ +drop table if exists t1; +drop database if exists test2; +set autocommit=0; +create table t1 ( +a int not null primary key, +b text not null, +c int not null, +d longblob, +key (c) +) engine=ndbcluster; +set @x0 = '01234567012345670123456701234567'; +set @x0 = concat(@x0,@x0,@x0,@x0,@x0,@x0,@x0,@x0); +set @b1 = 'b1'; +set @b1 = concat(@b1,@b1,@b1,@b1,@b1,@b1,@b1,@b1,@b1,@b1); +set @b1 = concat(@b1,@b1,@b1,@b1,@b1,@b1,@b1,@b1,@b1,@b1); +set @b1 = concat(@b1,@b1,@b1,@b1,@b1,@b1,@b1,@b1,@b1,@b1); +set @b1 = concat(@b1,@x0); +set @d1 = 'dd1'; +set @d1 = concat(@d1,@d1,@d1,@d1,@d1,@d1,@d1,@d1,@d1,@d1); +set @d1 = concat(@d1,@d1,@d1,@d1,@d1,@d1,@d1,@d1,@d1,@d1); +set @d1 = concat(@d1,@d1,@d1,@d1,@d1,@d1,@d1,@d1,@d1,@d1); +set @b2 = 'b2'; +set @b2 = concat(@b2,@b2,@b2,@b2,@b2,@b2,@b2,@b2,@b2,@b2); +set @b2 = concat(@b2,@b2,@b2,@b2,@b2,@b2,@b2,@b2,@b2,@b2); +set @b2 = concat(@b2,@b2,@b2,@b2,@b2,@b2,@b2,@b2,@b2,@b2); +set @b2 = concat(@b2,@b2,@b2,@b2,@b2,@b2,@b2,@b2,@b2,@b2); +set @d2 = 'dd2'; +set @d2 = concat(@d2,@d2,@d2,@d2,@d2,@d2,@d2,@d2,@d2,@d2); +set @d2 = concat(@d2,@d2,@d2,@d2,@d2,@d2,@d2,@d2,@d2,@d2); +set @d2 = concat(@d2,@d2,@d2,@d2,@d2,@d2,@d2,@d2,@d2,@d2); +set @d2 = concat(@d2,@d2,@d2,@d2,@d2,@d2,@d2,@d2,@d2,@d2); +select length(@x0),length(@b1),length(@d1) from dual; +length(@x0) length(@b1) length(@d1) +256 2256 3000 +select length(@x0),length(@b2),length(@d2) from dual; +length(@x0) length(@b2) length(@d2) +256 20000 30000 +insert into t1 values(1,@b1,111,@d1); +insert into t1 values(2,@b2,222,@d2); +commit; +explain select * from t1 where a = 1; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t1 const PRIMARY PRIMARY 4 const # +select a,length(b),substr(b,1+2*900,2),length(d),substr(d,1+3*900,3) +from t1 where a=1; +a length(b) substr(b,1+2*900,2) length(d) substr(d,1+3*900,3) +1 2256 b1 3000 dd1 +select a,length(b),substr(b,1+2*9000,2),length(d),substr(d,1+3*9000,3) +from t1 where a=2; +a length(b) substr(b,1+2*9000,2) length(d) substr(d,1+3*9000,3) +2 20000 b2 30000 dd2 +update t1 set b=@b2,d=@d2 where a=1; +update t1 set b=@b1,d=@d1 where a=2; +commit; +select a,length(b),substr(b,1+2*9000,2),length(d),substr(d,1+3*9000,3) +from t1 where a=1; +a length(b) substr(b,1+2*9000,2) length(d) substr(d,1+3*9000,3) +1 20000 b2 30000 dd2 +select a,length(b),substr(b,1+2*900,2),length(d),substr(d,1+3*900,3) +from t1 where a=2; +a length(b) substr(b,1+2*900,2) length(d) substr(d,1+3*900,3) +2 2256 b1 3000 dd1 +update t1 set b=concat(b,b),d=concat(d,d) where a=1; +update t1 set b=concat(b,b),d=concat(d,d) where a=2; +commit; +select a,length(b),substr(b,1+4*9000,2),length(d),substr(d,1+6*9000,3) +from t1 where a=1; +a length(b) substr(b,1+4*9000,2) length(d) substr(d,1+6*9000,3) +1 40000 b2 60000 dd2 +select a,length(b),substr(b,1+4*900,2),length(d),substr(d,1+6*900,3) +from t1 where a=2; +a length(b) substr(b,1+4*900,2) length(d) substr(d,1+6*900,3) +2 4512 b1 6000 dd1 +update t1 set d=null where a=1; +commit; +select a from t1 where d is null; +a +1 +delete from t1 where a=45567; +commit; +delete from t1 where a=1; +delete from t1 where a=2; +commit; +select count(*) from t1; +count(*) +0 +replace t1 set a=1,b=@b1,c=111,d=@d1; +replace t1 set a=2,b=@b2,c=222,d=@d2; +commit; +explain select * from t1 where a = 1; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t1 const PRIMARY PRIMARY 4 const # +select a,length(b),substr(b,1+2*900,2),length(d),substr(d,1+3*900,3) +from t1 where a=1; +a length(b) substr(b,1+2*900,2) length(d) substr(d,1+3*900,3) +1 2256 b1 3000 dd1 +select a,length(b),substr(b,1+2*9000,2),length(d),substr(d,1+3*9000,3) +from t1 where a=2; +a length(b) substr(b,1+2*9000,2) length(d) substr(d,1+3*9000,3) +2 20000 b2 30000 dd2 +replace t1 set a=1,b=@b2,c=111,d=@d2; +replace t1 set a=2,b=@b1,c=222,d=@d1; +commit; +select a,length(b),substr(b,1+2*9000,2),length(d),substr(d,1+3*9000,3) +from t1 where a=1; +a length(b) substr(b,1+2*9000,2) length(d) substr(d,1+3*9000,3) +1 20000 b2 30000 dd2 +select a,length(b),substr(b,1+2*900,2),length(d),substr(d,1+3*900,3) +from t1 where a=2; +a length(b) substr(b,1+2*900,2) length(d) substr(d,1+3*900,3) +2 2256 b1 3000 dd1 +replace t1 set a=1,b=concat(@b2,@b2),c=111,d=concat(@d2,@d2); +replace t1 set a=2,b=concat(@b1,@b1),c=222,d=concat(@d1,@d1); +commit; +select a,length(b),substr(b,1+4*9000,2),length(d),substr(d,1+6*9000,3) +from t1 where a=1; +a length(b) substr(b,1+4*9000,2) length(d) substr(d,1+6*9000,3) +1 40000 b2 60000 dd2 +select a,length(b),substr(b,1+4*900,2),length(d),substr(d,1+6*900,3) +from t1 where a=2; +a length(b) substr(b,1+4*900,2) length(d) substr(d,1+6*900,3) +2 4512 b1 6000 dd1 +replace t1 set a=1,b='xyz',c=111,d=null; +commit; +select a,b from t1 where d is null; +a b +1 xyz +delete from t1 where a=1; +delete from t1 where a=2; +commit; +select count(*) from t1; +count(*) +0 +insert into t1 values(1,@b1,111,@d1); +insert into t1 values(2,@b2,222,@d2); +commit; +explain select * from t1 where c = 111; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t1 ref c c 4 const # +select a,length(b),substr(b,1+2*900,2),length(d),substr(d,1+3*900,3) +from t1 where c=111; +a length(b) substr(b,1+2*900,2) length(d) substr(d,1+3*900,3) +1 2256 b1 3000 dd1 +select a,length(b),substr(b,1+2*9000,2),length(d),substr(d,1+3*9000,3) +from t1 where c=222; +a length(b) substr(b,1+2*9000,2) length(d) substr(d,1+3*9000,3) +2 20000 b2 30000 dd2 +update t1 set b=@b2,d=@d2 where c=111; +update t1 set b=@b1,d=@d1 where c=222; +commit; +select a,length(b),substr(b,1+2*9000,2),length(d),substr(d,1+3*9000,3) +from t1 where c=111; +a length(b) substr(b,1+2*9000,2) length(d) substr(d,1+3*9000,3) +1 20000 b2 30000 dd2 +select a,length(b),substr(b,1+2*900,2),length(d),substr(d,1+3*900,3) +from t1 where c=222; +a length(b) substr(b,1+2*900,2) length(d) substr(d,1+3*900,3) +2 2256 b1 3000 dd1 +update t1 set d=null where c=111; +commit; +select a from t1 where d is null; +a +1 +delete from t1 where c=111; +delete from t1 where c=222; +commit; +select count(*) from t1; +count(*) +0 +insert into t1 values(1,'b1',111,'dd1'); +insert into t1 values(2,'b2',222,'dd2'); +insert into t1 values(3,'b3',333,'dd3'); +insert into t1 values(4,'b4',444,'dd4'); +insert into t1 values(5,'b5',555,'dd5'); +insert into t1 values(6,'b6',666,'dd6'); +insert into t1 values(7,'b7',777,'dd7'); +insert into t1 values(8,'b8',888,'dd8'); +insert into t1 values(9,'b9',999,'dd9'); +commit; +explain select * from t1; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t1 ALL NULL NULL NULL NULL # +select * from t1 order by a; +a b c d +1 b1 111 dd1 +2 b2 222 dd2 +3 b3 333 dd3 +4 b4 444 dd4 +5 b5 555 dd5 +6 b6 666 dd6 +7 b7 777 dd7 +8 b8 888 dd8 +9 b9 999 dd9 +update t1 set b=concat(a,'x',b),d=concat(a,'x',d); +commit; +select * from t1 order by a; +a b c d +1 1xb1 111 1xdd1 +2 2xb2 222 2xdd2 +3 3xb3 333 3xdd3 +4 4xb4 444 4xdd4 +5 5xb5 555 5xdd5 +6 6xb6 666 6xdd6 +7 7xb7 777 7xdd7 +8 8xb8 888 8xdd8 +9 9xb9 999 9xdd9 +delete from t1; +commit; +select count(*) from t1; +count(*) +0 +insert into t1 values(1,@b1,111,@d1); +insert into t1 values(2,@b2,222,@d2); +commit; +explain select * from t1; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t1 ALL NULL NULL NULL NULL # +select a,length(b),substr(b,1+2*900,2),length(d),substr(d,1+3*900,3) +from t1 order by a; +a length(b) substr(b,1+2*900,2) length(d) substr(d,1+3*900,3) +1 2256 b1 3000 dd1 +2 20000 b2 30000 dd2 +update t1 set b=concat(b,b),d=concat(d,d); +commit; +select a,length(b),substr(b,1+4*9000,2),length(d),substr(d,1+6*9000,3) +from t1 order by a; +a length(b) substr(b,1+4*9000,2) length(d) substr(d,1+6*9000,3) +1 4512 6000 +2 40000 b2 60000 dd2 +delete from t1; +commit; +select count(*) from t1; +count(*) +0 +insert into t1 values(1,'b1',111,'dd1'); +insert into t1 values(2,'b2',222,'dd2'); +insert into t1 values(3,'b3',333,'dd3'); +insert into t1 values(4,'b4',444,'dd4'); +insert into t1 values(5,'b5',555,'dd5'); +insert into t1 values(6,'b6',666,'dd6'); +insert into t1 values(7,'b7',777,'dd7'); +insert into t1 values(8,'b8',888,'dd8'); +insert into t1 values(9,'b9',999,'dd9'); +commit; +explain select * from t1 where c >= 100 order by a; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t1 range c c 4 NULL # Using where with pushed condition; Using filesort +select * from t1 where c >= 100 order by a; +a b c d +1 b1 111 dd1 +2 b2 222 dd2 +3 b3 333 dd3 +4 b4 444 dd4 +5 b5 555 dd5 +6 b6 666 dd6 +7 b7 777 dd7 +8 b8 888 dd8 +9 b9 999 dd9 +update t1 set b=concat(a,'x',b),d=concat(a,'x',d) +where c >= 100; +commit; +select * from t1 where c >= 100 order by a; +a b c d +1 1xb1 111 1xdd1 +2 2xb2 222 2xdd2 +3 3xb3 333 3xdd3 +4 4xb4 444 4xdd4 +5 5xb5 555 5xdd5 +6 6xb6 666 6xdd6 +7 7xb7 777 7xdd7 +8 8xb8 888 8xdd8 +9 9xb9 999 9xdd9 +delete from t1 where c >= 100; +commit; +select count(*) from t1; +count(*) +0 +insert into t1 values(1,@b1,111,@d1); +insert into t1 values(2,@b2,222,@d2); +commit; +explain select * from t1 where c >= 100 order by a; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t1 range c c 4 NULL # Using where with pushed condition; Using filesort +select a,length(b),substr(b,1+2*900,2),length(d),substr(d,1+3*900,3) +from t1 where c >= 100 order by a; +a length(b) substr(b,1+2*900,2) length(d) substr(d,1+3*900,3) +1 2256 b1 3000 dd1 +2 20000 b2 30000 dd2 +update t1 set b=concat(b,b),d=concat(d,d); +commit; +select a,length(b),substr(b,1+4*9000,2),length(d),substr(d,1+6*9000,3) +from t1 where c >= 100 order by a; +a length(b) substr(b,1+4*9000,2) length(d) substr(d,1+6*9000,3) +1 4512 6000 +2 40000 b2 60000 dd2 +delete from t1 where c >= 100; +commit; +select count(*) from t1; +count(*) +0 +insert into t1 values(1,@b1,111,@d1); +insert into t1 values(2,@b2,222,@d2); +select a,length(b),substr(b,1+2*900,2),length(d),substr(d,1+3*900,3) +from t1 where a = 0; +a length(b) substr(b,1+2*900,2) length(d) substr(d,1+3*900,3) +select a,length(b),substr(b,1+2*900,2),length(d),substr(d,1+3*900,3) +from t1 where a = 1; +a length(b) substr(b,1+2*900,2) length(d) substr(d,1+3*900,3) +1 2256 b1 3000 dd1 +select a,length(b),substr(b,1+2*900,2),length(d),substr(d,1+3*900,3) +from t1 where a = 2; +a length(b) substr(b,1+2*900,2) length(d) substr(d,1+3*900,3) +2 20000 b2 30000 dd2 +select a,length(b),substr(b,1+2*900,2),length(d),substr(d,1+3*900,3) +from t1 order by a; +a length(b) substr(b,1+2*900,2) length(d) substr(d,1+3*900,3) +1 2256 b1 3000 dd1 +2 20000 b2 30000 dd2 +rollback; +select count(*) from t1; +count(*) +0 +insert into t1 values(1,'b1',111,'dd1'); +insert into t1 values(2,'b2',222,'dd2'); +insert into t1 values(3,'b3',333,'dd3'); +insert into t1 values(4,'b4',444,'dd4'); +insert into t1 values(5,'b5',555,'dd5'); +insert into t1 values(6,'b6',666,'dd6'); +insert into t1 values(7,'b7',777,'dd7'); +insert into t1 values(8,'b8',888,'dd8'); +insert into t1 values(9,'b9',999,'dd9'); +commit; +select * from t1 order by a; +a b c d +1 b1 111 dd1 +2 b2 222 dd2 +3 b3 333 dd3 +4 b4 444 dd4 +5 b5 555 dd5 +6 b6 666 dd6 +7 b7 777 dd7 +8 b8 888 dd8 +9 b9 999 dd9 +alter table t1 add x int; +select * from t1 order by a; +a b c d x +1 b1 111 dd1 NULL +2 b2 222 dd2 NULL +3 b3 333 dd3 NULL +4 b4 444 dd4 NULL +5 b5 555 dd5 NULL +6 b6 666 dd6 NULL +7 b7 777 dd7 NULL +8 b8 888 dd8 NULL +9 b9 999 dd9 NULL +alter table t1 drop x; +select * from t1 order by a; +a b c d +1 b1 111 dd1 +2 b2 222 dd2 +3 b3 333 dd3 +4 b4 444 dd4 +5 b5 555 dd5 +6 b6 666 dd6 +7 b7 777 dd7 +8 b8 888 dd8 +9 b9 999 dd9 +create database test2; +use test2; +CREATE TABLE t2 ( +a bigint unsigned NOT NULL PRIMARY KEY, +b int unsigned not null, +c int unsigned +) engine=ndbcluster; +insert into t2 values (1,1,1),(2,2,2); +select * from test.t1,t2 where test.t1.a = t2.a order by test.t1.a; +a b c d a b c +1 b1 111 dd1 1 1 1 +2 b2 222 dd2 2 2 2 +drop table t2; +use test; +select * from t1 order by a; +a b c d +1 b1 111 dd1 +2 b2 222 dd2 +3 b3 333 dd3 +4 b4 444 dd4 +5 b5 555 dd5 +6 b6 666 dd6 +7 b7 777 dd7 +8 b8 888 dd8 +9 b9 999 dd9 +alter table t1 add x int; +select * from t1 order by a; +a b c d x +1 b1 111 dd1 NULL +2 b2 222 dd2 NULL +3 b3 333 dd3 NULL +4 b4 444 dd4 NULL +5 b5 555 dd5 NULL +6 b6 666 dd6 NULL +7 b7 777 dd7 NULL +8 b8 888 dd8 NULL +9 b9 999 dd9 NULL +alter table t1 drop x; +select * from t1 order by a; +a b c d +1 b1 111 dd1 +2 b2 222 dd2 +3 b3 333 dd3 +4 b4 444 dd4 +5 b5 555 dd5 +6 b6 666 dd6 +7 b7 777 dd7 +8 b8 888 dd8 +9 b9 999 dd9 +drop table t1; +drop database test2; +set autocommit=0; +create table t1 ( +a int not null primary key, +b tinytext +) engine=ndbcluster; +insert into t1 values(1, 'x'); +update t1 set b = 'y'; +select * from t1; +a b +1 y +delete from t1; +select * from t1; +a b +commit; +replace t1 set a=2, b='y'; +select * from t1; +a b +2 y +delete from t1; +select * from t1; +a b +drop table t1; +set autocommit=0; +create table t1 ( +a int not null primary key, +b text not null +) engine=ndbcluster; +insert into t1 values(1, ''); +select * from t1; +a b +1 +commit; +drop table t1; +set autocommit=1; +use test; +CREATE TABLE t1 ( +a int, +b text, +PRIMARY KEY (a) +) ENGINE=MyISAM DEFAULT CHARSET=latin1; +INSERT INTO t1 VALUES +(1,'AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA'); +INSERT INTO t1 VALUES +(2,'BBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBB'); +select * from t1 order by a; +a b +1 AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA +2 BBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBB +alter table t1 engine=ndb; +select * from t1 order by a; +a b +1 AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA +2 BBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBB +set autocommit=1; +alter table t1 engine=myisam; +select * from t1 order by a; +a b +1 AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA +2 BBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBB +drop table t1; +create table t1 ( +id int(11) unsigned primary key NOT NULL auto_increment, +msg text NOT NULL +) engine=ndbcluster default charset=utf8; +insert into t1 (msg) values( +'Tries to validate (8 byte length + inline bytes) as UTF8 :( +Fast fix: removed validation for Text. It is not yet indexable +so bad data will not crash kernel.'); +select * from t1; +id msg +1 Tries to validate (8 byte length + inline bytes) as UTF8 :( +Fast fix: removed validation for Text. It is not yet indexable +so bad data will not crash kernel. +drop table t1; +create table t1 ( +a int primary key not null auto_increment, +b text +) engine=ndbcluster; +select count(*) from t1; +count(*) +500 +truncate t1; +select count(*) from t1; +count(*) +0 +drop table t1; +create table t1 ( +a varchar(40) not null, +b mediumint not null, +t text, +c varchar(2) not null, +d bigint not null, +primary key (a,b,c), +key (c,a), +unique key (d) +) engine=ndb; +insert into t1 (a,b,c,d,t) values ('a',1110,'a',1,@v1); +insert into t1 (a,b,c,d,t) values ('b',1110,'a',2,@v2); +insert into t1 (a,b,c,d,t) values ('a',1110,'b',3,@v3); +insert into t1 (a,b,c,d,t) values ('b',1110,'b',4,@v4); +select a,b,c,d,sha1(t) from t1 order by c,a; +a b c d sha1(t) +a 1110 a 1 558a30713786aa72f66abc1e6a521d55aacdeeb5 +b 1110 a 2 b238654911689bfb626a3ef9dba4a1ca074e6a5e +a 1110 b 3 2b6515f29c20b8e9e17cc597527e516c0de8d612 +b 1110 b 4 NULL +select a,b,c,d,sha1(t) from t1 where a='a' and b=1110 and c='a'; +a b c d sha1(t) +a 1110 a 1 558a30713786aa72f66abc1e6a521d55aacdeeb5 +select a,b,c,d,sha1(t) from t1 where a='a' and b=1110 and c='b'; +a b c d sha1(t) +a 1110 b 3 2b6515f29c20b8e9e17cc597527e516c0de8d612 +update t1 set t=@v4 where a='b' and b=1110 and c='a'; +update t1 set t=@v2 where a='b' and b=1110 and c='b'; +select a,b,c,d,sha1(t) from t1 order by c,a; +a b c d sha1(t) +a 1110 a 1 558a30713786aa72f66abc1e6a521d55aacdeeb5 +b 1110 a 2 NULL +a 1110 b 3 2b6515f29c20b8e9e17cc597527e516c0de8d612 +b 1110 b 4 b238654911689bfb626a3ef9dba4a1ca074e6a5e +update t1 set t=@v2 where d=2; +update t1 set t=@v4 where d=4; +select a,b,c,d,sha1(t) from t1 order by c,a; +a b c d sha1(t) +a 1110 a 1 558a30713786aa72f66abc1e6a521d55aacdeeb5 +b 1110 a 2 b238654911689bfb626a3ef9dba4a1ca074e6a5e +a 1110 b 3 2b6515f29c20b8e9e17cc597527e516c0de8d612 +b 1110 b 4 NULL +update t1 set t=@v4 where a='b' and c='a'; +update t1 set t=@v2 where a='b' and c='b'; +select a,b,c,d,sha1(t) from t1 order by c,a; +a b c d sha1(t) +a 1110 a 1 558a30713786aa72f66abc1e6a521d55aacdeeb5 +b 1110 a 2 NULL +a 1110 b 3 2b6515f29c20b8e9e17cc597527e516c0de8d612 +b 1110 b 4 b238654911689bfb626a3ef9dba4a1ca074e6a5e +update t1 set t=@v2 where b+d=1112; +update t1 set t=@v4 where b+d=1114; +select a,b,c,d,sha1(t) from t1 order by c,a; +a b c d sha1(t) +a 1110 a 1 558a30713786aa72f66abc1e6a521d55aacdeeb5 +b 1110 a 2 b238654911689bfb626a3ef9dba4a1ca074e6a5e +a 1110 b 3 2b6515f29c20b8e9e17cc597527e516c0de8d612 +b 1110 b 4 NULL +delete from t1 where a='a' and b=1110 and c='a'; +delete from t1 where a='b' and c='a'; +delete from t1 where d=3; +delete from t1 where b+d=1114; +select count(*) from t1; +count(*) +0 +drop table t1; diff --git a/mysql-test/suite/ndb/r/ndb_blob_partition.result b/mysql-test/suite/ndb/r/ndb_blob_partition.result new file mode 100644 index 00000000000..b08a91f0cdd --- /dev/null +++ b/mysql-test/suite/ndb/r/ndb_blob_partition.result @@ -0,0 +1,104 @@ +drop table if exists t1; +create table t1 ( +a mediumint not null, +b text not null, +c int not null, +d longblob, +primary key using hash (a,c), +unique key (c) +) +engine=ndb +partition by range (c) +partitions 3 +( partition p1 values less than (200), +partition p2 values less than (300), +partition p3 values less than (400)); +insert into t1 values (1, @v1, 101, @v2); +insert into t1 values (1, @v2, 102, @v3); +insert into t1 values (1, @v3, 103, @v4); +insert into t1 values (2, @v4, 201, @v5); +insert into t1 values (2, @v5, 202, @v6); +insert into t1 values (2, @v6, 203, @v7); +insert into t1 values (3, @v7, 301, @v8); +insert into t1 values (3, @v8, 302, @v9); +insert into t1 values (3, @v9, 303, @v1); +select a, sha1(b), c, sha1(d) from t1 order by a; +a sha1(b) c sha1(d) +1 1d42dd9090cf78314a06665d4ea938c35cc760f4 101 10d3c783026b310218d10b7188da96a2401648c6 +1 10d3c783026b310218d10b7188da96a2401648c6 102 a33549d9844092289a58ac348dd59f09fc28406a +1 a33549d9844092289a58ac348dd59f09fc28406a 103 daa61c6de36a0526f0d47dc29d6b9de7e6d2630c +2 daa61c6de36a0526f0d47dc29d6b9de7e6d2630c 201 70fc9a7d08beebc522258bfb02000a30c77a8f1d +2 70fc9a7d08beebc522258bfb02000a30c77a8f1d 202 090565c580809efed3d369481a4bbb168b20713e +2 090565c580809efed3d369481a4bbb168b20713e 203 1e0070bec426871a46291de27b9bd6e4255ab4e5 +3 1e0070bec426871a46291de27b9bd6e4255ab4e5 301 acbaba01bc2e682f015f40e79d9cbe475db3002e +3 acbaba01bc2e682f015f40e79d9cbe475db3002e 302 9ee30d99162574f79c66ae95cdf132dcf9cbc259 +3 9ee30d99162574f79c66ae95cdf132dcf9cbc259 303 1d42dd9090cf78314a06665d4ea938c35cc760f4 +select a, sha1(b), c, sha1(d) from t1 where a = 1 and c = 101; +a sha1(b) c sha1(d) +1 1d42dd9090cf78314a06665d4ea938c35cc760f4 101 10d3c783026b310218d10b7188da96a2401648c6 +select a, sha1(b), c, sha1(d) from t1 where a = 2 and c = 201; +a sha1(b) c sha1(d) +2 daa61c6de36a0526f0d47dc29d6b9de7e6d2630c 201 70fc9a7d08beebc522258bfb02000a30c77a8f1d +select a, sha1(b), c, sha1(d) from t1 where a = 3 and c = 301; +a sha1(b) c sha1(d) +3 1e0070bec426871a46291de27b9bd6e4255ab4e5 301 acbaba01bc2e682f015f40e79d9cbe475db3002e +update t1 set b = @v3, d = @v4 where a = 1 and c = 102; +update t1 set b = @v6, d = @v7 where a = 2 and c = 202; +update t1 set b = @v9, d = @v1 where a = 3 and c = 302; +select a, sha1(b), c, sha1(d) from t1 order by a; +a sha1(b) c sha1(d) +1 1d42dd9090cf78314a06665d4ea938c35cc760f4 101 10d3c783026b310218d10b7188da96a2401648c6 +1 a33549d9844092289a58ac348dd59f09fc28406a 102 daa61c6de36a0526f0d47dc29d6b9de7e6d2630c +1 a33549d9844092289a58ac348dd59f09fc28406a 103 daa61c6de36a0526f0d47dc29d6b9de7e6d2630c +2 daa61c6de36a0526f0d47dc29d6b9de7e6d2630c 201 70fc9a7d08beebc522258bfb02000a30c77a8f1d +2 090565c580809efed3d369481a4bbb168b20713e 202 1e0070bec426871a46291de27b9bd6e4255ab4e5 +2 090565c580809efed3d369481a4bbb168b20713e 203 1e0070bec426871a46291de27b9bd6e4255ab4e5 +3 1e0070bec426871a46291de27b9bd6e4255ab4e5 301 acbaba01bc2e682f015f40e79d9cbe475db3002e +3 9ee30d99162574f79c66ae95cdf132dcf9cbc259 302 1d42dd9090cf78314a06665d4ea938c35cc760f4 +3 9ee30d99162574f79c66ae95cdf132dcf9cbc259 303 1d42dd9090cf78314a06665d4ea938c35cc760f4 +update t1 set b = @v4, d = @v5 where c = 103; +update t1 set b = @v7, d = @v8 where c = 203; +update t1 set b = @v1, d = @v2 where c = 303; +select a, sha1(b), c, sha1(d) from t1 order by a; +a sha1(b) c sha1(d) +1 1d42dd9090cf78314a06665d4ea938c35cc760f4 101 10d3c783026b310218d10b7188da96a2401648c6 +1 a33549d9844092289a58ac348dd59f09fc28406a 102 daa61c6de36a0526f0d47dc29d6b9de7e6d2630c +1 daa61c6de36a0526f0d47dc29d6b9de7e6d2630c 103 70fc9a7d08beebc522258bfb02000a30c77a8f1d +2 daa61c6de36a0526f0d47dc29d6b9de7e6d2630c 201 70fc9a7d08beebc522258bfb02000a30c77a8f1d +2 090565c580809efed3d369481a4bbb168b20713e 202 1e0070bec426871a46291de27b9bd6e4255ab4e5 +2 1e0070bec426871a46291de27b9bd6e4255ab4e5 203 acbaba01bc2e682f015f40e79d9cbe475db3002e +3 1e0070bec426871a46291de27b9bd6e4255ab4e5 301 acbaba01bc2e682f015f40e79d9cbe475db3002e +3 9ee30d99162574f79c66ae95cdf132dcf9cbc259 302 1d42dd9090cf78314a06665d4ea938c35cc760f4 +3 1d42dd9090cf78314a06665d4ea938c35cc760f4 303 10d3c783026b310218d10b7188da96a2401648c6 +update t1 set b = @v5, d = @v6; +select a, sha1(b), c, sha1(d) from t1 order by a; +a sha1(b) c sha1(d) +1 70fc9a7d08beebc522258bfb02000a30c77a8f1d 101 090565c580809efed3d369481a4bbb168b20713e +1 70fc9a7d08beebc522258bfb02000a30c77a8f1d 102 090565c580809efed3d369481a4bbb168b20713e +1 70fc9a7d08beebc522258bfb02000a30c77a8f1d 103 090565c580809efed3d369481a4bbb168b20713e +2 70fc9a7d08beebc522258bfb02000a30c77a8f1d 201 090565c580809efed3d369481a4bbb168b20713e +2 70fc9a7d08beebc522258bfb02000a30c77a8f1d 202 090565c580809efed3d369481a4bbb168b20713e +2 70fc9a7d08beebc522258bfb02000a30c77a8f1d 203 090565c580809efed3d369481a4bbb168b20713e +3 70fc9a7d08beebc522258bfb02000a30c77a8f1d 301 090565c580809efed3d369481a4bbb168b20713e +3 70fc9a7d08beebc522258bfb02000a30c77a8f1d 302 090565c580809efed3d369481a4bbb168b20713e +3 70fc9a7d08beebc522258bfb02000a30c77a8f1d 303 090565c580809efed3d369481a4bbb168b20713e +update t1 set b = @v1, d = @v2 where 100 < c and c < 200; +update t1 set b = @v4, d = @v5 where 200 < c and c < 300; +update t1 set b = @v7, d = @v8 where 300 < c and c < 400; +select a, sha1(b), c, sha1(d) from t1 order by a; +a sha1(b) c sha1(d) +1 1d42dd9090cf78314a06665d4ea938c35cc760f4 101 10d3c783026b310218d10b7188da96a2401648c6 +1 1d42dd9090cf78314a06665d4ea938c35cc760f4 102 10d3c783026b310218d10b7188da96a2401648c6 +1 1d42dd9090cf78314a06665d4ea938c35cc760f4 103 10d3c783026b310218d10b7188da96a2401648c6 +2 daa61c6de36a0526f0d47dc29d6b9de7e6d2630c 201 70fc9a7d08beebc522258bfb02000a30c77a8f1d +2 daa61c6de36a0526f0d47dc29d6b9de7e6d2630c 202 70fc9a7d08beebc522258bfb02000a30c77a8f1d +2 daa61c6de36a0526f0d47dc29d6b9de7e6d2630c 203 70fc9a7d08beebc522258bfb02000a30c77a8f1d +3 1e0070bec426871a46291de27b9bd6e4255ab4e5 301 acbaba01bc2e682f015f40e79d9cbe475db3002e +3 1e0070bec426871a46291de27b9bd6e4255ab4e5 302 acbaba01bc2e682f015f40e79d9cbe475db3002e +3 1e0070bec426871a46291de27b9bd6e4255ab4e5 303 acbaba01bc2e682f015f40e79d9cbe475db3002e +delete from t1 where a = 1 and c = 101; +delete from t1 where c = 102; +delete from t1; +select a, sha1(b), c, sha1(d) from t1 order by a; +a sha1(b) c sha1(d) +drop table t1; diff --git a/mysql-test/suite/ndb/r/ndb_cache.result b/mysql-test/suite/ndb/r/ndb_cache.result new file mode 100644 index 00000000000..478663b1aa1 --- /dev/null +++ b/mysql-test/suite/ndb/r/ndb_cache.result @@ -0,0 +1,191 @@ +drop table if exists t1; +set GLOBAL query_cache_type=on; +set GLOBAL query_cache_size=1355776; +reset query cache; +flush status; +CREATE TABLE t1 ( pk int not null primary key, +a int, b int not null, c varchar(20)) ENGINE=ndbcluster; +insert into t1 value (1, 2, 3, 'First row'); +select * from t1; +pk a b c +1 2 3 First row +show status like "Qcache_queries_in_cache"; +Variable_name Value +Qcache_queries_in_cache 1 +show status like "Qcache_inserts"; +Variable_name Value +Qcache_inserts 1 +show status like "Qcache_hits"; +Variable_name Value +Qcache_hits 0 +select * from t1; +pk a b c +1 2 3 First row +show status like "Qcache_hits"; +Variable_name Value +Qcache_hits 1 +update t1 set a=3 where pk=1; +select * from t1; +pk a b c +1 3 3 First row +show status like "Qcache_inserts"; +Variable_name Value +Qcache_inserts 2 +show status like "Qcache_hits"; +Variable_name Value +Qcache_hits 1 +insert into t1 value (2, 7, 8, 'Second row'); +insert into t1 value (4, 5, 6, 'Fourth row'); +select * from t1 order by pk; +pk a b c +1 3 3 First row +2 7 8 Second row +4 5 6 Fourth row +show status like "Qcache_inserts"; +Variable_name Value +Qcache_inserts 3 +show status like "Qcache_hits"; +Variable_name Value +Qcache_hits 1 +select * from t1 order by pk; +pk a b c +1 3 3 First row +2 7 8 Second row +4 5 6 Fourth row +show status like "Qcache_hits"; +Variable_name Value +Qcache_hits 2 +select * from t1 where b=3; +pk a b c +1 3 3 First row +show status like "Qcache_queries_in_cache"; +Variable_name Value +Qcache_queries_in_cache 2 +show status like "Qcache_hits"; +Variable_name Value +Qcache_hits 2 +select * from t1 where b=3; +pk a b c +1 3 3 First row +show status like "Qcache_hits"; +Variable_name Value +Qcache_hits 3 +delete from t1 where c='Fourth row'; +show status like "Qcache_queries_in_cache"; +Variable_name Value +Qcache_queries_in_cache 0 +select * from t1 where b=3; +pk a b c +1 3 3 First row +show status like "Qcache_hits"; +Variable_name Value +Qcache_hits 3 +use test; +select * from t1 order by pk; +pk a b c +1 3 3 First row +2 7 8 Second row +select * from t1 where b=3; +pk a b c +1 3 3 First row +show status like "Qcache_hits"; +Variable_name Value +Qcache_hits 4 +update t1 set a=4 where b=3; +use test; +show status like "Qcache_queries_in_cache"; +Variable_name Value +Qcache_queries_in_cache 0 +select * from t1 order by pk desc; +pk a b c +2 7 8 Second row +1 4 3 First row +select * from t1 order by pk desc; +pk a b c +2 7 8 Second row +1 4 3 First row +show status like "Qcache_inserts"; +Variable_name Value +Qcache_inserts 7 +show status like "Qcache_hits"; +Variable_name Value +Qcache_hits 5 +select * from t1 order by pk desc; +pk a b c +2 7 8 Second row +1 4 3 First row +select * from t1 order by pk desc; +pk a b c +2 7 8 Second row +1 4 3 First row +show status like "Qcache_queries_in_cache"; +Variable_name Value +Qcache_queries_in_cache 1 +show status like "Qcache_inserts"; +Variable_name Value +Qcache_inserts 7 +show status like "Qcache_hits"; +Variable_name Value +Qcache_hits 7 +begin; +update t1 set a=5 where pk=1; +show status like "Qcache_queries_in_cache"; +Variable_name Value +Qcache_queries_in_cache 0 +show status like "Qcache_inserts"; +Variable_name Value +Qcache_inserts 7 +show status like "Qcache_hits"; +Variable_name Value +Qcache_hits 7 +select * from t1 order by pk desc; +pk a b c +2 7 8 Second row +1 4 3 First row +show status like "Qcache_queries_in_cache"; +Variable_name Value +Qcache_queries_in_cache 1 +show status like "Qcache_inserts"; +Variable_name Value +Qcache_inserts 8 +show status like "Qcache_hits"; +Variable_name Value +Qcache_hits 7 +commit; +show status like "Qcache_queries_in_cache"; +Variable_name Value +Qcache_queries_in_cache 1 +show status like "Qcache_inserts"; +Variable_name Value +Qcache_inserts 8 +show status like "Qcache_hits"; +Variable_name Value +Qcache_hits 7 +select * from t1 order by pk desc; +pk a b c +2 7 8 Second row +1 5 3 First row +show status like "Qcache_inserts"; +Variable_name Value +Qcache_inserts 9 +show status like "Qcache_hits"; +Variable_name Value +Qcache_hits 7 +select * from t1 order by pk desc; +pk a b c +2 7 8 Second row +1 5 3 First row +show status like "Qcache_queries_in_cache"; +Variable_name Value +Qcache_queries_in_cache 1 +show status like "Qcache_inserts"; +Variable_name Value +Qcache_inserts 9 +show status like "Qcache_hits"; +Variable_name Value +Qcache_hits 8 +drop table t1; +show status like "Qcache_queries_in_cache"; +Variable_name Value +Qcache_queries_in_cache 0 +SET GLOBAL query_cache_size=0; diff --git a/mysql-test/suite/ndb/r/ndb_cache2.result b/mysql-test/suite/ndb/r/ndb_cache2.result new file mode 100644 index 00000000000..2876002f864 --- /dev/null +++ b/mysql-test/suite/ndb/r/ndb_cache2.result @@ -0,0 +1,623 @@ +drop table if exists t1, t2, t3, t4, t5; +set GLOBAL query_cache_type=on; +set GLOBAL query_cache_size=1355776; +set GLOBAL ndb_cache_check_time=100; +reset query cache; +flush status; +CREATE TABLE t1 ( +pk int not null primary key, +a1 int, +b1 int not null, +c1 varchar(20) +) ENGINE=ndb; +CREATE TABLE t2 ( +pk int not null primary key, +a2 int, +b2 int not null +) ENGINE=ndb; +CREATE TABLE t3 ( +pk int not null primary key, +a3 int, +b3 int not null, +c3 int not null, +d3 varchar(20) +) ENGINE=ndb; +CREATE TABLE t4 ( +a4 int, +b4 int not null, +c4 char(20) +) ENGINE=ndbcluster; +CREATE TABLE t5 ( +pk int not null primary key, +a5 int, +b5 int not null, +c5 varchar(255) +) ENGINE=ndbcluster; +insert into t1 value (1, 2, 3, 'First row'); +insert into t2 value (1, 2, 3); +insert into t3 value (1, 2, 3, 4, '3 - First row'); +insert into t4 value (2, 3, '4 - First row'); +insert into t5 value (1, 2, 3, '5 - First row'); +select * from t1; +pk a1 b1 c1 +1 2 3 First row +show status like "Qcache_queries_in_cache"; +Variable_name Value +Qcache_queries_in_cache 1 +show status like "Qcache_inserts"; +Variable_name Value +Qcache_inserts 1 +show status like "Qcache_hits"; +Variable_name Value +Qcache_hits 0 +select * from t1; +pk a1 b1 c1 +1 2 3 First row +show status like "Qcache_hits"; +Variable_name Value +Qcache_hits 1 +update t1 set a1=3 where pk=1; +select * from t1; +pk a1 b1 c1 +1 3 3 First row +show status like "Qcache_inserts"; +Variable_name Value +Qcache_inserts 2 +show status like "Qcache_hits"; +Variable_name Value +Qcache_hits 1 +insert into t1 value (2, 7, 8, 'Second row'); +insert into t1 value (4, 5, 6, 'Fourth row'); +select * from t1 order by pk desc; +pk a1 b1 c1 +4 5 6 Fourth row +2 7 8 Second row +1 3 3 First row +show status like "Qcache_inserts"; +Variable_name Value +Qcache_inserts 3 +show status like "Qcache_hits"; +Variable_name Value +Qcache_hits 1 +select * from t1 order by pk desc; +pk a1 b1 c1 +4 5 6 Fourth row +2 7 8 Second row +1 3 3 First row +show status like "Qcache_hits"; +Variable_name Value +Qcache_hits 2 +select * from t1 where b1=3; +pk a1 b1 c1 +1 3 3 First row +show status like "Qcache_queries_in_cache"; +Variable_name Value +Qcache_queries_in_cache 2 +show status like "Qcache_hits"; +Variable_name Value +Qcache_hits 2 +select * from t1 where b1=3; +pk a1 b1 c1 +1 3 3 First row +show status like "Qcache_hits"; +Variable_name Value +Qcache_hits 3 +delete from t1 where c1='Fourth row'; +show status like "Qcache_queries_in_cache"; +Variable_name Value +Qcache_queries_in_cache 0 +select * from t1 where b1=3; +pk a1 b1 c1 +1 3 3 First row +show status like "Qcache_hits"; +Variable_name Value +Qcache_hits 3 +use test; +select * from t1 order by pk desc; +pk a1 b1 c1 +2 7 8 Second row +1 3 3 First row +select * from t1 where b1=3; +pk a1 b1 c1 +1 3 3 First row +show status like "Qcache_hits"; +Variable_name Value +Qcache_hits 4 +update t1 set a1=4 where b1=3; +use test; +show status like "Qcache_queries_in_cache"; +Variable_name Value +Qcache_queries_in_cache 0 +select * from t1 order by pk desc; +pk a1 b1 c1 +2 7 8 Second row +1 4 3 First row +select * from t1 order by pk desc; +pk a1 b1 c1 +2 7 8 Second row +1 4 3 First row +show status like "Qcache_inserts"; +Variable_name Value +Qcache_inserts 7 +show status like "Qcache_hits"; +Variable_name Value +Qcache_hits 5 +select * from t1 order by pk desc; +pk a1 b1 c1 +2 7 8 Second row +1 4 3 First row +select * from t1 order by pk desc; +pk a1 b1 c1 +2 7 8 Second row +1 4 3 First row +show status like "Qcache_queries_in_cache"; +Variable_name Value +Qcache_queries_in_cache 1 +show status like "Qcache_inserts"; +Variable_name Value +Qcache_inserts 7 +show status like "Qcache_hits"; +Variable_name Value +Qcache_hits 7 +select * from t2; +pk a2 b2 +1 2 3 +select * from t3; +pk a3 b3 c3 d3 +1 2 3 4 3 - First row +select * from t4; +a4 b4 c4 +2 3 4 - First row +select * from t5; +pk a5 b5 c5 +1 2 3 5 - First row +show status like "Qcache_queries_in_cache"; +Variable_name Value +Qcache_queries_in_cache 5 +flush status; +begin; +update t1 set a1=5 where pk=1; +show status like "Qcache_queries_in_cache"; +Variable_name Value +Qcache_queries_in_cache 4 +show status like "Qcache_inserts"; +Variable_name Value +Qcache_inserts 0 +show status like "Qcache_hits"; +Variable_name Value +Qcache_hits 0 +select * from t1 order by pk desc; +pk a1 b1 c1 +2 7 8 Second row +1 4 3 First row +show status like "Qcache_queries_in_cache"; +Variable_name Value +Qcache_queries_in_cache 5 +show status like "Qcache_inserts"; +Variable_name Value +Qcache_inserts 1 +show status like "Qcache_hits"; +Variable_name Value +Qcache_hits 0 +commit; +show status like "Qcache_queries_in_cache"; +Variable_name Value +Qcache_queries_in_cache 5 +show status like "Qcache_inserts"; +Variable_name Value +Qcache_inserts 1 +show status like "Qcache_hits"; +Variable_name Value +Qcache_hits 0 +select * from t1 order by pk desc; +pk a1 b1 c1 +2 7 8 Second row +1 5 3 First row +show status like "Qcache_inserts"; +Variable_name Value +Qcache_inserts 2 +show status like "Qcache_hits"; +Variable_name Value +Qcache_hits 0 +select * from t1 order by pk desc; +pk a1 b1 c1 +2 7 8 Second row +1 5 3 First row +show status like "Qcache_queries_in_cache"; +Variable_name Value +Qcache_queries_in_cache 5 +show status like "Qcache_inserts"; +Variable_name Value +Qcache_inserts 2 +show status like "Qcache_hits"; +Variable_name Value +Qcache_hits 1 +flush status; +begin; +update t1 set a1=6 where pk=1; +show status like "Qcache_queries_in_cache"; +Variable_name Value +Qcache_queries_in_cache 4 +show status like "Qcache_inserts"; +Variable_name Value +Qcache_inserts 0 +show status like "Qcache_hits"; +Variable_name Value +Qcache_hits 0 +select * from t1 order by pk desc; +pk a1 b1 c1 +2 7 8 Second row +1 5 3 First row +select * from t1 order by pk desc; +pk a1 b1 c1 +2 7 8 Second row +1 5 3 First row +show status like "Qcache_queries_in_cache"; +Variable_name Value +Qcache_queries_in_cache 5 +show status like "Qcache_inserts"; +Variable_name Value +Qcache_inserts 1 +show status like "Qcache_hits"; +Variable_name Value +Qcache_hits 1 +select * from t1 order by pk desc; +pk a1 b1 c1 +2 7 8 Second row +1 6 3 First row +select * from t1 order by pk desc; +pk a1 b1 c1 +2 7 8 Second row +1 6 3 First row +show status like "Qcache_queries_in_cache"; +Variable_name Value +Qcache_queries_in_cache 5 +show status like "Qcache_inserts"; +Variable_name Value +Qcache_inserts 1 +show status like "Qcache_hits"; +Variable_name Value +Qcache_hits 1 +commit; +show status like "Qcache_queries_in_cache"; +Variable_name Value +Qcache_queries_in_cache 5 +show status like "Qcache_inserts"; +Variable_name Value +Qcache_inserts 1 +show status like "Qcache_hits"; +Variable_name Value +Qcache_hits 1 +select * from t1 order by pk desc; +pk a1 b1 c1 +2 7 8 Second row +1 6 3 First row +show status like "Qcache_inserts"; +Variable_name Value +Qcache_inserts 2 +show status like "Qcache_hits"; +Variable_name Value +Qcache_hits 1 +select * from t1 order by pk desc; +pk a1 b1 c1 +2 7 8 Second row +1 6 3 First row +show status like "Qcache_queries_in_cache"; +Variable_name Value +Qcache_queries_in_cache 5 +show status like "Qcache_inserts"; +Variable_name Value +Qcache_inserts 2 +show status like "Qcache_hits"; +Variable_name Value +Qcache_hits 2 +flush status; +begin; +insert into t1 set pk=5, a1=6, b1=3, c1="New row"; +show status like "Qcache_queries_in_cache"; +Variable_name Value +Qcache_queries_in_cache 4 +show status like "Qcache_inserts"; +Variable_name Value +Qcache_inserts 0 +show status like "Qcache_hits"; +Variable_name Value +Qcache_hits 0 +select * from t1 where pk=5; +pk a1 b1 c1 +select * from t1 order by pk desc; +pk a1 b1 c1 +2 7 8 Second row +1 6 3 First row +show status like "Qcache_queries_in_cache"; +Variable_name Value +Qcache_queries_in_cache 6 +show status like "Qcache_inserts"; +Variable_name Value +Qcache_inserts 2 +show status like "Qcache_hits"; +Variable_name Value +Qcache_hits 0 +select * from t1 where pk=5; +pk a1 b1 c1 +5 6 3 New row +select * from t1 where pk=5; +pk a1 b1 c1 +5 6 3 New row +select * from t1 order by pk desc; +pk a1 b1 c1 +5 6 3 New row +2 7 8 Second row +1 6 3 First row +select * from t1 order by pk desc; +pk a1 b1 c1 +5 6 3 New row +2 7 8 Second row +1 6 3 First row +show status like "Qcache_queries_in_cache"; +Variable_name Value +Qcache_queries_in_cache 6 +show status like "Qcache_inserts"; +Variable_name Value +Qcache_inserts 2 +show status like "Qcache_hits"; +Variable_name Value +Qcache_hits 0 +commit; +select * from t1 order by pk desc; +pk a1 b1 c1 +5 6 3 New row +2 7 8 Second row +1 6 3 First row +show status like "Qcache_queries_in_cache"; +Variable_name Value +Qcache_queries_in_cache 5 +show status like "Qcache_inserts"; +Variable_name Value +Qcache_inserts 3 +show status like "Qcache_hits"; +Variable_name Value +Qcache_hits 0 +flush status; +begin; +delete from t1 where pk=2; +show status like "Qcache_queries_in_cache"; +Variable_name Value +Qcache_queries_in_cache 4 +show status like "Qcache_inserts"; +Variable_name Value +Qcache_inserts 0 +show status like "Qcache_hits"; +Variable_name Value +Qcache_hits 0 +select * from t1 where pk=2; +pk a1 b1 c1 +2 7 8 Second row +select * from t1 order by pk desc; +pk a1 b1 c1 +5 6 3 New row +2 7 8 Second row +1 6 3 First row +show status like "Qcache_queries_in_cache"; +Variable_name Value +Qcache_queries_in_cache 6 +show status like "Qcache_inserts"; +Variable_name Value +Qcache_inserts 2 +show status like "Qcache_hits"; +Variable_name Value +Qcache_hits 0 +select * from t1 where pk=2; +pk a1 b1 c1 +select * from t1 order by pk desc; +pk a1 b1 c1 +5 6 3 New row +1 6 3 First row +select * from t1 order by pk desc; +pk a1 b1 c1 +5 6 3 New row +1 6 3 First row +select * from t1 where pk=2; +pk a1 b1 c1 +show status like "Qcache_queries_in_cache"; +Variable_name Value +Qcache_queries_in_cache 6 +show status like "Qcache_inserts"; +Variable_name Value +Qcache_inserts 2 +show status like "Qcache_hits"; +Variable_name Value +Qcache_hits 0 +commit; +select * from t1 order by pk desc; +pk a1 b1 c1 +5 6 3 New row +1 6 3 First row +select * from t1 where pk=2; +pk a1 b1 c1 +show status like "Qcache_queries_in_cache"; +Variable_name Value +Qcache_queries_in_cache 6 +show status like "Qcache_inserts"; +Variable_name Value +Qcache_inserts 4 +show status like "Qcache_hits"; +Variable_name Value +Qcache_hits 0 +flush status; +begin; +update t1 set a1=9 where pk=1; +update t2 set a2=9 where pk=1; +update t3 set a3=9 where pk=1; +update t4 set a4=9 where a4=2; +update t5 set a5=9 where pk=1; +show status like "Qcache_queries_in_cache"; +Variable_name Value +Qcache_queries_in_cache 0 +show status like "Qcache_inserts"; +Variable_name Value +Qcache_inserts 0 +show status like "Qcache_hits"; +Variable_name Value +Qcache_hits 0 +select * from t1 order by pk desc; +pk a1 b1 c1 +5 6 3 New row +1 6 3 First row +select * from t2; +pk a2 b2 +1 2 3 +select * from t3; +pk a3 b3 c3 d3 +1 2 3 4 3 - First row +select * from t4; +a4 b4 c4 +2 3 4 - First row +select * from t5; +pk a5 b5 c5 +1 2 3 5 - First row +show status like "Qcache_queries_in_cache"; +Variable_name Value +Qcache_queries_in_cache 5 +show status like "Qcache_inserts"; +Variable_name Value +Qcache_inserts 5 +show status like "Qcache_hits"; +Variable_name Value +Qcache_hits 0 +select * from t1 order by pk desc; +pk a1 b1 c1 +5 6 3 New row +1 9 3 First row +select * from t1 order by pk desc; +pk a1 b1 c1 +5 6 3 New row +1 9 3 First row +select * from t2; +pk a2 b2 +1 9 3 +select * from t3; +pk a3 b3 c3 d3 +1 9 3 4 3 - First row +select * from t4; +a4 b4 c4 +9 3 4 - First row +select * from t5; +pk a5 b5 c5 +1 9 3 5 - First row +show status like "Qcache_queries_in_cache"; +Variable_name Value +Qcache_queries_in_cache 5 +show status like "Qcache_inserts"; +Variable_name Value +Qcache_inserts 5 +show status like "Qcache_hits"; +Variable_name Value +Qcache_hits 0 +commit; +select * from t1 order by pk desc; +pk a1 b1 c1 +5 6 3 New row +1 9 3 First row +select * from t2; +pk a2 b2 +1 9 3 +select * from t3; +pk a3 b3 c3 d3 +1 9 3 4 3 - First row +select * from t4; +a4 b4 c4 +9 3 4 - First row +select * from t5; +pk a5 b5 c5 +1 9 3 5 - First row +show status like "Qcache_queries_in_cache"; +Variable_name Value +Qcache_queries_in_cache 5 +show status like "Qcache_inserts"; +Variable_name Value +Qcache_inserts 10 +show status like "Qcache_hits"; +Variable_name Value +Qcache_hits 0 +select * from t1 order by pk desc; +pk a1 b1 c1 +5 6 3 New row +1 9 3 First row +select * from t2; +pk a2 b2 +1 9 3 +select * from t3; +pk a3 b3 c3 d3 +1 9 3 4 3 - First row +select * from t4; +a4 b4 c4 +9 3 4 - First row +select * from t5; +pk a5 b5 c5 +1 9 3 5 - First row +show status like "Qcache_queries_in_cache"; +Variable_name Value +Qcache_queries_in_cache 5 +show status like "Qcache_inserts"; +Variable_name Value +Qcache_inserts 10 +show status like "Qcache_hits"; +Variable_name Value +Qcache_hits 5 +select * from t1 order by pk desc; +pk a1 b1 c1 +5 6 3 New row +1 9 3 First row +select * from t2; +pk a2 b2 +1 9 3 +select * from t3; +pk a3 b3 c3 d3 +1 9 3 4 3 - First row +select * from t4; +a4 b4 c4 +9 3 4 - First row +select * from t5; +pk a5 b5 c5 +1 9 3 5 - First row +show status like "Qcache_queries_in_cache"; +Variable_name Value +Qcache_queries_in_cache 5 +show status like "Qcache_inserts"; +Variable_name Value +Qcache_inserts 10 +show status like "Qcache_hits"; +Variable_name Value +Qcache_hits 10 +select * from t1 order by pk desc; +pk a1 b1 c1 +5 6 3 New row +1 9 3 First row +select * from t2; +pk a2 b2 +1 9 3 +select * from t3; +pk a3 b3 c3 d3 +1 9 3 4 3 - First row +select * from t4; +a4 b4 c4 +9 3 4 - First row +select * from t5; +pk a5 b5 c5 +1 9 3 5 - First row +show status like "Qcache_queries_in_cache"; +Variable_name Value +Qcache_queries_in_cache 5 +show status like "Qcache_inserts"; +Variable_name Value +Qcache_inserts 10 +show status like "Qcache_hits"; +Variable_name Value +Qcache_hits 15 +drop table t1, t2, t3, t4, t5; +show status like "Qcache_queries_in_cache"; +Variable_name Value +Qcache_queries_in_cache 0 +SET GLOBAL query_cache_size=0; +SET GLOBAL ndb_cache_check_time=0; diff --git a/mysql-test/suite/ndb/r/ndb_cache_multi.result b/mysql-test/suite/ndb/r/ndb_cache_multi.result new file mode 100644 index 00000000000..388131ec30a --- /dev/null +++ b/mysql-test/suite/ndb/r/ndb_cache_multi.result @@ -0,0 +1,74 @@ +drop table if exists t1, t2; +set GLOBAL query_cache_type=on; +set GLOBAL query_cache_size=1355776; +reset query cache; +flush status; +set GLOBAL query_cache_type=on; +set GLOBAL query_cache_size=1355776; +reset query cache; +flush status; +create table t1 (a int) engine=ndbcluster; +create table t2 (a int) engine=ndbcluster; +insert into t1 value (2); +insert into t2 value (3); +select * from t1; +a +2 +select * from t2; +a +3 +show status like "Qcache_queries_in_cache"; +Variable_name Value +Qcache_queries_in_cache 2 +show status like "Qcache_inserts"; +Variable_name Value +Qcache_inserts 2 +show status like "Qcache_hits"; +Variable_name Value +Qcache_hits 0 +show status like "Qcache_queries_in_cache"; +Variable_name Value +Qcache_queries_in_cache 0 +show status like "Qcache_inserts"; +Variable_name Value +Qcache_inserts 0 +show status like "Qcache_hits"; +Variable_name Value +Qcache_hits 0 +select * from t1; +a +2 +show status like "Qcache_queries_in_cache"; +Variable_name Value +Qcache_queries_in_cache 1 +show status like "Qcache_inserts"; +Variable_name Value +Qcache_inserts 1 +show status like "Qcache_hits"; +Variable_name Value +Qcache_hits 0 +update t1 set a=3 where a=2; +show status like "Qcache_queries_in_cache"; +Variable_name Value +Qcache_queries_in_cache 2 +show status like "Qcache_inserts"; +Variable_name Value +Qcache_inserts 2 +show status like "Qcache_hits"; +Variable_name Value +Qcache_hits 0 +select * from t1; +a +3 +show status like "Qcache_queries_in_cache"; +Variable_name Value +Qcache_queries_in_cache 2 +show status like "Qcache_inserts"; +Variable_name Value +Qcache_inserts 3 +show status like "Qcache_hits"; +Variable_name Value +Qcache_hits 0 +drop table t1, t2; +set GLOBAL query_cache_size=0; +set GLOBAL query_cache_size=0; diff --git a/mysql-test/suite/ndb/r/ndb_cache_multi2.result b/mysql-test/suite/ndb/r/ndb_cache_multi2.result new file mode 100644 index 00000000000..53767bb6d3c --- /dev/null +++ b/mysql-test/suite/ndb/r/ndb_cache_multi2.result @@ -0,0 +1,75 @@ +drop table if exists t1, t2; +== Connected to server1 == +set GLOBAL query_cache_type=on; +set GLOBAL query_cache_size=1355776; +set GLOBAL ndb_cache_check_time=1; +reset query cache; +flush status; +== Connected to server2 == +set GLOBAL query_cache_type=on; +set GLOBAL query_cache_size=1355776; +set GLOBAL ndb_cache_check_time=1; +reset query cache; +flush status; +== Connected to server1 == +create table t1 (a int) engine=ndbcluster; +create table t2 (a int) engine=ndbcluster; +insert into t1 value (2); +insert into t2 value (3); +select * from t1; +a +2 +select a != 3 from t1; +a != 3 +1 +select * from t2; +a +3 +show status like "Qcache_queries_in_cache"; +Variable_name Value +Qcache_queries_in_cache 3 +show status like "Qcache_inserts"; +Variable_name Value +Qcache_inserts 3 +show status like "Qcache_hits"; +Variable_name Value +Qcache_hits 0 +== Connected to server2 == +show status like "Qcache_queries_in_cache"; +Variable_name Value +Qcache_queries_in_cache 0 +show status like "Qcache_inserts"; +Variable_name Value +Qcache_inserts 0 +show status like "Qcache_hits"; +Variable_name Value +Qcache_hits 0 +select * from t1; +a +2 +show status like "Qcache_queries_in_cache"; +Variable_name Value +Qcache_queries_in_cache 1 +show status like "Qcache_inserts"; +Variable_name Value +Qcache_inserts 1 +show status like "Qcache_hits"; +Variable_name Value +Qcache_hits 0 +update t1 set a=3 where a=2; +== Connected to server1 == +select * from t1; +a +3 +show status like "Qcache_queries_in_cache"; +Variable_name Value +Qcache_queries_in_cache 3 +drop table t1, t2; +set GLOBAL query_cache_size=0; +set GLOBAL ndb_cache_check_time=0; +reset query cache; +flush status; +set GLOBAL query_cache_size=0; +set GLOBAL ndb_cache_check_time=0; +reset query cache; +flush status; diff --git a/mysql-test/suite/ndb/r/ndb_charset.result b/mysql-test/suite/ndb/r/ndb_charset.result new file mode 100644 index 00000000000..1c65a380039 --- /dev/null +++ b/mysql-test/suite/ndb/r/ndb_charset.result @@ -0,0 +1,320 @@ +drop table if exists t1; +create table t1 ( +a char(3) character set latin1 collate latin1_bin primary key +) engine=ndb; +insert into t1 values('aAa'); +insert into t1 values('aaa'); +insert into t1 values('AAA'); +select * from t1 order by a; +a +AAA +aAa +aaa +select * from t1 where a = 'aAa'; +a +aAa +select * from t1 where a = 'aaa'; +a +aaa +select * from t1 where a = 'AaA'; +a +select * from t1 where a = 'AAA'; +a +AAA +drop table t1; +create table t1 ( +a char(3) character set latin1 collate latin1_swedish_ci primary key +) engine=ndb; +insert into t1 values('aAa'); +insert into t1 values('aaa'); +ERROR 23000: Duplicate entry 'aaa' for key 'PRIMARY' +insert into t1 values('AAA'); +ERROR 23000: Duplicate entry 'AAA' for key 'PRIMARY' +select * from t1 order by a; +a +aAa +select * from t1 where a = 'aAa'; +a +aAa +select * from t1 where a = 'aaa'; +a +aAa +select * from t1 where a = 'AaA'; +a +aAa +select * from t1 where a = 'AAA'; +a +aAa +drop table t1; +create table t1 ( +a varchar(20) character set latin1 collate latin1_swedish_ci primary key +) engine=ndb; +insert into t1 values ('A'),('b '),('C '),('d '),('E'),('f'); +insert into t1 values('b'); +ERROR 23000: Duplicate entry 'b' for key 'PRIMARY' +insert into t1 values('a '); +ERROR 23000: Duplicate entry 'a ' for key 'PRIMARY' +select a,length(a) from t1 order by a; +a length(a) +A 1 +b 2 +C 3 +d 7 +E 1 +f 1 +select a,length(a) from t1 order by a desc; +a length(a) +f 1 +E 1 +d 7 +C 3 +b 2 +A 1 +select * from t1 where a = 'a'; +a +A +select * from t1 where a = 'a '; +a +A +select * from t1 where a = 'd'; +a +d +drop table t1; +create table t1 ( +p int primary key, +a char(3) character set latin1 collate latin1_bin not null, +unique key(a) +) engine=ndb; +insert into t1 values(1, 'aAa'); +insert into t1 values(2, 'aaa'); +insert into t1 values(3, 'AAA'); +select * from t1 order by p; +p a +1 aAa +2 aaa +3 AAA +select * from t1 where a = 'aAa'; +p a +1 aAa +select * from t1 where a = 'aaa'; +p a +2 aaa +select * from t1 where a = 'AaA'; +p a +select * from t1 where a = 'AAA'; +p a +3 AAA +drop table t1; +create table t1 ( +p int primary key, +a char(3) character set latin1 collate latin1_swedish_ci not null, +unique key(a) +) engine=ndb; +insert into t1 values(1, 'aAa'); +insert into t1 values(2, 'aaa'); +ERROR 23000: Duplicate entry '' for key '*UNKNOWN*' +insert into t1 values(3, 'AAA'); +ERROR 23000: Duplicate entry '' for key '*UNKNOWN*' +select * from t1 order by p; +p a +1 aAa +select * from t1 where a = 'aAa'; +p a +1 aAa +select * from t1 where a = 'aaa'; +p a +1 aAa +select * from t1 where a = 'AaA'; +p a +1 aAa +select * from t1 where a = 'AAA'; +p a +1 aAa +drop table t1; +create table t1 ( +p int primary key, +a varchar(20) character set latin1 collate latin1_swedish_ci not null, +unique key(a) +) engine=ndb; +insert into t1 values (1,'A'),(2,'b '),(3,'C '),(4,'d '),(5,'E'),(6,'f'); +insert into t1 values(99,'b'); +ERROR 23000: Duplicate entry '' for key '*UNKNOWN*' +insert into t1 values(99,'a '); +ERROR 23000: Duplicate entry '' for key '*UNKNOWN*' +select a,length(a) from t1 order by a; +a length(a) +A 1 +b 2 +C 3 +d 7 +E 1 +f 1 +select a,length(a) from t1 order by a desc; +a length(a) +f 1 +E 1 +d 7 +C 3 +b 2 +A 1 +select * from t1 where a = 'a'; +p a +1 A +select * from t1 where a = 'a '; +p a +1 A +select * from t1 where a = 'd'; +p a +4 d +drop table t1; +create table t1 ( +p int primary key, +a char(3) character set latin1 collate latin1_bin not null, +index(a) +) engine=ndb; +insert into t1 values(1, 'aAa'); +insert into t1 values(2, 'aaa'); +insert into t1 values(3, 'AAA'); +insert into t1 values(4, 'aAa'); +insert into t1 values(5, 'aaa'); +insert into t1 values(6, 'AAA'); +select * from t1 order by p; +p a +1 aAa +2 aaa +3 AAA +4 aAa +5 aaa +6 AAA +select * from t1 where a = 'aAa' order by p; +p a +1 aAa +4 aAa +select * from t1 where a = 'aaa' order by p; +p a +2 aaa +5 aaa +select * from t1 where a = 'AaA' order by p; +p a +select * from t1 where a = 'AAA' order by p; +p a +3 AAA +6 AAA +drop table t1; +create table t1 ( +p int primary key, +a char(3) character set latin1 collate latin1_swedish_ci not null, +index(a) +) engine=ndb; +insert into t1 values(1, 'aAa'); +insert into t1 values(2, 'aaa'); +insert into t1 values(3, 'AAA'); +insert into t1 values(4, 'aAa'); +insert into t1 values(5, 'aaa'); +insert into t1 values(6, 'AAA'); +select * from t1 order by p; +p a +1 aAa +2 aaa +3 AAA +4 aAa +5 aaa +6 AAA +select * from t1 where a = 'aAa' order by p; +p a +1 aAa +2 aaa +3 AAA +4 aAa +5 aaa +6 AAA +select * from t1 where a = 'aaa' order by p; +p a +1 aAa +2 aaa +3 AAA +4 aAa +5 aaa +6 AAA +select * from t1 where a = 'AaA' order by p; +p a +1 aAa +2 aaa +3 AAA +4 aAa +5 aaa +6 AAA +select * from t1 where a = 'AAA' order by p; +p a +1 aAa +2 aaa +3 AAA +4 aAa +5 aaa +6 AAA +drop table t1; +create table t1 ( +p int primary key, +a varchar(20) character set latin1 collate latin1_swedish_ci not null, +index(a, p) +) engine=ndb; +insert into t1 values (1,'A'),(2,'b '),(3,'C '),(4,'d '),(5,'E'),(6,'f'); +insert into t1 values (7,'a'),(8,'B '),(9,'c '),(10,'D'),(11,'e'),(12,'F '); +select p,a,length(a) from t1 order by a, p; +p a length(a) +1 A 1 +7 a 1 +2 b 2 +8 B 2 +3 C 3 +9 c 3 +4 d 7 +10 D 1 +5 E 1 +11 e 1 +6 f 1 +12 F 3 +select * from t1 where a = 'a ' order by a desc, p desc; +p a +7 a +1 A +select * from t1 where a >= 'D' order by a, p; +p a +4 d +10 D +5 E +11 e +6 f +12 F +select * from t1 where a < 'D' order by a, p; +p a +1 A +7 a +2 b +8 B +3 C +9 c +select count(*) from t1 x, t1 y, t1 z where x.a = y.a and y.a = z.a; +count(*) +48 +drop table t1; +create table t1 ( +a char(10) primary key +) engine=ndbcluster default charset=latin1; +insert into t1 values ('aaabb'); +select * from t1; +a +aaabb +replace into t1 set a = 'AAABB'; +select * from t1; +a +AAABB +replace into t1 set a = 'aAaBb'; +select * from t1; +a +aAaBb +replace into t1 set a = 'aaabb'; +select * from t1; +a +aaabb +drop table t1; diff --git a/mysql-test/suite/ndb/r/ndb_condition_pushdown.result b/mysql-test/suite/ndb/r/ndb_condition_pushdown.result new file mode 100644 index 00000000000..8d1dcc4ef18 --- /dev/null +++ b/mysql-test/suite/ndb/r/ndb_condition_pushdown.result @@ -0,0 +1,1892 @@ +DROP TABLE IF EXISTS t1,t2,t3,t4; +CREATE TABLE t1 ( +auto int(5) unsigned NOT NULL auto_increment, +string char(10), +vstring varchar(10), +bin binary(2), +vbin varbinary(7), +tiny tinyint(4) DEFAULT '0' NOT NULL , +short smallint(6) DEFAULT '1' NOT NULL , +medium mediumint(8) DEFAULT '0' NOT NULL, +long_int int(11) DEFAULT '0' NOT NULL, +longlong bigint(13) DEFAULT '0' NOT NULL, +real_float float(13,1) DEFAULT 0.0 NOT NULL, +real_double double(16,4), +real_decimal decimal(16,4), +utiny tinyint(3) unsigned DEFAULT '0' NOT NULL, +ushort smallint(5) unsigned zerofill DEFAULT '00000' NOT NULL, +umedium mediumint(8) unsigned DEFAULT '0' NOT NULL, +ulong int(11) unsigned DEFAULT '0' NOT NULL, +ulonglong bigint(13) unsigned DEFAULT '0' NOT NULL, +bits bit(3), +options enum('zero','one','two','three','four') not null, +flags set('zero','one','two','three','four') not null, +date_field date, +year_field year, +time_field time, +date_time datetime, +time_stamp timestamp, +PRIMARY KEY (auto) +) engine=ndb; +insert into t1 values +(NULL,"aaaa","aaaa",0xAAAA,0xAAAA,-1,-1,-1,-1,-1,1.1,1.1,1.1,1,1,1,1,1, +b'001','one','one', +'1901-01-01','1901', +'01:01:01','1901-01-01 01:01:01',NULL), +(NULL,"bbbb","bbbb",0xBBBB,0xBBBB,-2,-2,-2,-2,-2,2.2,2.2,2.2,2,2,2,2,2, +b'010','two','one,two', +'1902-02-02','1902', +'02:02:02','1902-02-02 02:02:02',NULL), +(NULL,"cccc","cccc",0xCCCC,0xCCCC,-3,-3,-3,-3,-3,3.3,3.3,3.3,3,3,3,3,3, +b'011','three','one,two,three', +'1903-03-03','1903', +'03:03:03','1903-03-03 03:03:03',NULL), +(NULL,"dddd","dddd",0xDDDD,0xDDDD,-4,-4,-4,-4,-4,4.4,4.4,4.4,4,4,4,4,4, +b'100','four','one,two,three,four', +'1904-04-04','1904', +'04:04:04','1904-04-04 04:04:04',NULL); +CREATE TABLE t2 (pk1 int unsigned NOT NULL PRIMARY KEY, attr1 int unsigned NOT NULL, attr2 int unsigned, attr3 VARCHAR(10) ) ENGINE=ndbcluster; +insert into t2 values (0,0,0, "a"),(1,1,1,"b"),(2,2,NULL,NULL),(3,3,3,"d"),(4,4,4,"e"),(5,5,5,"f"); +CREATE TABLE t3 (pk1 int unsigned NOT NULL PRIMARY KEY, attr1 int unsigned NOT NULL, attr2 bigint unsigned, attr3 tinyint unsigned, attr4 VARCHAR(10) ) ENGINE=ndbcluster; +insert into t3 values (0,0,0,0,"a"),(1,1,9223372036854775803,1,"b"),(2,2,9223372036854775804,2,"c"),(3,3,9223372036854775805,3,"d"),(4,4,9223372036854775806,4,"e"),(5,5,9223372036854775807,5,"f"); +CREATE TABLE t4 (pk1 int unsigned NOT NULL PRIMARY KEY, attr1 int unsigned NOT NULL, attr2 bigint unsigned, attr3 tinyint unsigned, attr4 VARCHAR(10) , KEY (attr1)) ENGINE=ndbcluster; +insert into t4 values (0,0,0,0,"a"),(1,1,9223372036854775803,1,"b"),(2,2,9223372036854775804,2,"c"),(3,3,9223372036854775805,3,"d"),(4,4,9223372036854775806,4,"e"),(5,5,9223372036854775807,5,"f"); +set @old_ecpd = @@session.engine_condition_pushdown; +set engine_condition_pushdown = off; +select auto from t1 where +string = "aaaa" and +vstring = "aaaa" and +bin = 0xAAAA and +vbin = 0xAAAA and +tiny = -1 and +short = -1 and +medium = -1 and +long_int = -1 and +longlong = -1 and +real_float > 1.0 and real_float < 2.0 and +real_double > 1.0 and real_double < 2.0 and +real_decimal > 1.0 and real_decimal < 2.0 and +utiny = 1 and +ushort = 1 and +umedium = 1 and +ulong = 1 and +ulonglong = 1 and +bits = b'001' and +options = 'one' and +flags = 'one' and +date_field = '1901-01-01' and +year_field = '1901' and +time_field = '01:01:01' and +date_time = '1901-01-01 01:01:01' +order by auto; +auto +1 +select auto from t1 where +string != "aaaa" and +vstring != "aaaa" and +bin != 0xAAAA and +vbin != 0xAAAA and +tiny != -1 and +short != -1 and +medium != -1 and +long_int != -1 and +longlong != -1 and +(real_float < 1.0 or real_float > 2.0) and +(real_double < 1.0 or real_double > 2.0) and +(real_decimal < 1.0 or real_decimal > 2.0) and +utiny != 1 and +ushort != 1 and +umedium != 1 and +ulong != 1 and +ulonglong != 1 and +bits != b'001' and +options != 'one' and +flags != 'one' and +date_field != '1901-01-01' and +year_field != '1901' and +time_field != '01:01:01' and +date_time != '1901-01-01 01:01:01' +order by auto; +auto +2 +3 +4 +select auto from t1 where +string > "aaaa" and +vstring > "aaaa" and +bin > 0xAAAA and +vbin > 0xAAAA and +tiny < -1 and +short < -1 and +medium < -1 and +long_int < -1 and +longlong < -1 and +real_float > 1.1 and +real_double > 1.1 and +real_decimal > 1.1 and +utiny > 1 and +ushort > 1 and +umedium > 1 and +ulong > 1 and +ulonglong > 1 and +bits > b'001' and +(options = 'two' or options = 'three' or options = 'four') and +(flags = 'one,two' or flags = 'one,two,three' or flags = 'one,two,three,four') and +date_field > '1901-01-01' and +year_field > '1901' and +time_field > '01:01:01' and +date_time > '1901-01-01 01:01:01' +order by auto; +auto +2 +3 +4 +select auto from t1 where +string >= "aaaa" and +vstring >= "aaaa" and +bin >= 0xAAAA and +vbin >= 0xAAAA and +tiny <= -1 and +short <= -1 and +medium <= -1 and +long_int <= -1 and +longlong <= -1 and +real_float >= 1.0 and +real_double >= 1.0 and +real_decimal >= 1.0 and +utiny >= 1 and +ushort >= 1 and +umedium >= 1 and +ulong >= 1 and +ulonglong >= 1 and +bits >= b'001' and +(options = 'one' or options = 'two' or options = 'three' or options = 'four') and +(flags = 'one' or flags = 'one,two' or flags = 'one,two,three' or flags = 'one,two,three,four') and +date_field >= '1901-01-01' and +year_field >= '1901' and +time_field >= '01:01:01' and +date_time >= '1901-01-01 01:01:01' +order by auto; +auto +1 +2 +3 +4 +select auto from t1 where +string < "dddd" and +vstring < "dddd" and +bin < 0xDDDD and +vbin < 0xDDDD and +tiny > -4 and +short > -4 and +medium > -4 and +long_int > -4 and +longlong > -4 and +real_float < 4.4 and +real_double < 4.4 and +real_decimal < 4.4 and +utiny < 4 and +ushort < 4 and +umedium < 4 and +ulong < 4 and +ulonglong < 4 and +bits < b'100' and +(options = 'one' or options = 'two' or options = 'three') and +(flags = 'one' or flags = 'one,two' or flags = 'one,two,three') and +date_field < '1904-01-01' and +year_field < '1904' and +time_field < '04:04:04' and +date_time < '1904-04-04 04:04:04' +order by auto; +auto +1 +2 +3 +select auto from t1 where +string <= "dddd" and +vstring <= "dddd" and +bin <= 0xDDDD and +vbin <= 0xDDDD and +tiny >= -4 and +short >= -4 and +medium >= -4 and +long_int >= -4 and +longlong >= -4 and +real_float <= 4.5 and +real_double <= 4.5 and +real_decimal <= 4.5 and +utiny <= 4 and +ushort <= 4 and +umedium <= 4 and +ulong <= 4 and +ulonglong <= 4 and +bits <= b'100' and +(options = 'one' or options = 'two' or options = 'three' or options = 'four') and +(flags = 'one' or flags = 'one,two' or flags = 'one,two,three' or flags = 'one,two,three,four') and +date_field <= '1904-04-04' and +year_field <= '1904' and +time_field <= '04:04:04' and +date_time <= '1904-04-04 04:04:04' +order by auto; +auto +1 +2 +3 +4 +select auto from t1 where +string like "b%" and +vstring like "b%" and +bin like concat(0xBB, '%') and +vbin like concat(0xBB, '%') +order by auto; +auto +2 +select auto from t1 where +string not like "b%" and +vstring not like "b%" and +bin not like concat(0xBB, '%') and +vbin not like concat(0xBB, '%') +order by auto; +auto +1 +3 +4 +select auto from t1 where +(string between "aaaa" and "cccc") and +(vstring between "aaaa" and "cccc") and +(bin between 0xAAAA and 0xCCCC) and +(vbin between 0xAAAA and 0xCCCC) and +(tiny between -3 and -1) and +(short between -3 and -1) and +(medium between -3 and -1) and +(long_int between -3 and -1) and +(longlong between -3 and -1) and +(utiny between 1 and 3) and +(ushort between 1 and 3) and +(umedium between 1 and 3) and +(ulong between 1 and 3) and +(ulonglong between 1 and 3) and +(bits between b'001' and b'011') and +(options between 'one' and 'three') and +(flags between 'one' and 'one,two,three') and +(date_field between '1901-01-01' and '1903-03-03') and +(year_field between '1901' and '1903') and +(time_field between '01:01:01' and '03:03:03') and +(date_time between '1901-01-01 01:01:01' and '1903-03-03 03:03:03') +order by auto; +auto +1 +3 +select auto from t1 where +("aaaa" between string and string) and +("aaaa" between vstring and vstring) and +(0xAAAA between bin and bin) and +(0xAAAA between vbin and vbin) and +(-1 between tiny and tiny) and +(-1 between short and short) and +(-1 between medium and medium) and +(-1 between long_int and long_int) and +(-1 between longlong and longlong) and +(1 between utiny and utiny) and +(1 between ushort and ushort) and +(1 between umedium and umedium) and +(1 between ulong and ulong) and +(1 between ulonglong and ulonglong) and +(b'001' between bits and bits) and +('one' between options and options) and +('one' between flags and flags) and +('1901-01-01' between date_field and date_field) and +('1901' between year_field and year_field) and +('01:01:01' between time_field and time_field) and +('1901-01-01 01:01:01' between date_time and date_time) +order by auto; +auto +1 +select auto from t1 where +(string not between "aaaa" and "cccc") and +(vstring not between "aaaa" and "cccc") and +(bin not between 0xAAAA and 0xCCCC) and +(vbin not between 0xAAAA and 0xCCCC) and +(tiny not between -3 and -1) and +(short not between -3 and -1) and +(medium not between -3 and -1) and +(long_int not between -3 and -1) and +(longlong not between -3 and -1) and +(utiny not between 1 and 3) and +(ushort not between 1 and 3) and +(umedium not between 1 and 3) and +(ulong not between 1 and 3) and +(ulonglong not between 1 and 3) and +(bits not between b'001' and b'011') and +(options not between 'one' and 'three') and +(flags not between 'one' and 'one,two,three') and +(date_field not between '1901-01-01' and '1903-03-03') and +(year_field not between '1901' and '1903') and +(time_field not between '01:01:01' and '03:03:03') and +(date_time not between '1901-01-01 01:01:01' and '1903-03-03 03:03:03') +order by auto; +auto +4 +select auto from t1 where +("aaaa" not between string and string) and +("aaaa" not between vstring and vstring) and +(0xAAAA not between bin and bin) and +(0xAAAA not between vbin and vbin) and +(-1 not between tiny and tiny) and +(-1 not between short and short) and +(-1 not between medium and medium) and +(-1 not between long_int and long_int) and +(-1 not between longlong and longlong) and +(1 not between utiny and utiny) and +(1 not between ushort and ushort) and +(1 not between umedium and umedium) and +(1 not between ulong and ulong) and +(1 not between ulonglong and ulonglong) and +(b'001' not between bits and bits) and +('one' not between options and options) and +('one' not between flags and flags) and +('1901-01-01' not between date_field and date_field) and +('1901' not between year_field and year_field) and +('01:01:01' not between time_field and time_field) and +('1901-01-01 01:01:01' not between date_time and date_time) +order by auto; +auto +2 +3 +4 +select auto from t1 where +string in("aaaa","cccc") and +vstring in("aaaa","cccc") and +bin in(0xAAAA,0xCCCC) and +vbin in(0xAAAA,0xCCCC) and +tiny in(-1,-3) and +short in(-1,-3) and +medium in(-1,-3) and +long_int in(-1,-3) and +longlong in(-1,-3) and +utiny in(1,3) and +ushort in(1,3) and +umedium in(1,3) and +ulong in(1,3) and +ulonglong in(1,3) and +bits in(b'001',b'011') and +options in('one','three') and +flags in('one','one,two,three') and +date_field in('1901-01-01','1903-03-03') and +year_field in('1901','1903') and +time_field in('01:01:01','03:03:03') and +date_time in('1901-01-01 01:01:01','1903-03-03 03:03:03') +order by auto; +auto +1 +3 +select auto from t1 where +"aaaa" in(string) and +"aaaa" in(vstring) and +0xAAAA in(bin) and +0xAAAA in(vbin) and +(-1 in(tiny)) and +(-1 in(short)) and +(-1 in(medium)) and +(-1 in(long_int)) and +(-1 in(longlong)) and +1 in(utiny) and +1 in(ushort) and +1 in(umedium) and +1 in(ulong) and +1 in(ulonglong) and +b'001' in(bits) and +'one' in(options) and +'one' in(flags) and +'1901-01-01' in(date_field) and +'1901' in(year_field) and +'01:01:01' in(time_field) and +'1901-01-01 01:01:01' in(date_time) +order by auto; +auto +1 +select auto from t1 where +string not in("aaaa","cccc") and +vstring not in("aaaa","cccc") and +bin not in(0xAAAA,0xCCCC) and +vbin not in(0xAAAA,0xCCCC) and +tiny not in(-1,-3) and +short not in(-1,-3) and +medium not in(-1,-3) and +long_int not in(-1,-3) and +longlong not in(-1,-3) and +utiny not in(1,3) and +ushort not in(1,3) and +umedium not in(1,3) and +ulong not in(1,3) and +ulonglong not in(1,3) and +bits not in(b'001',b'011') and +options not in('one','three') and +flags not in('one','one,two,three') and +date_field not in('1901-01-01','1903-03-03') and +year_field not in('1901','1903') and +time_field not in('01:01:01','03:03:03') and +date_time not in('1901-01-01 01:01:01','1903-03-03 03:03:03') +order by auto; +auto +2 +4 +select auto from t1 where +"aaaa" not in(string) and +"aaaa" not in(vstring) and +0xAAAA not in(bin) and +0xAAAA not in(vbin) and +(-1 not in(tiny)) and +(-1 not in(short)) and +(-1 not in(medium)) and +(-1 not in(long_int)) and +(-1 not in(longlong)) and +1 not in(utiny) and +1 not in(ushort) and +1 not in(umedium) and +1 not in(ulong) and +1 not in(ulonglong) and +b'001' not in(bits) and +'one' not in(options) and +'one' not in(flags) and +'1901-01-01' not in(date_field) and +'1901' not in(year_field) and +'01:01:01' not in(time_field) and +'1901-01-01 01:01:01' not in(date_time) +order by auto; +auto +2 +3 +4 +select * from t2 where attr3 is null or attr1 > 2 and pk1= 3 order by pk1; +pk1 attr1 attr2 attr3 +2 2 NULL NULL +3 3 3 d +select * from t2 where attr3 is not null and attr1 > 2 order by pk1; +pk1 attr1 attr2 attr3 +3 3 3 d +4 4 4 e +5 5 5 f +select * from t3 where attr2 > 9223372036854775803 and attr3 != 3 order by pk1; +pk1 attr1 attr2 attr3 attr4 +2 2 9223372036854775804 2 c +4 4 9223372036854775806 4 e +5 5 9223372036854775807 5 f +select * from t2,t3 where t2.attr1 < 1 and t2.attr2 = t3.attr2 and t3.attr1 < 5 order by t2.pk1; +pk1 attr1 attr2 attr3 pk1 attr1 attr2 attr3 attr4 +0 0 0 a 0 0 0 0 a +select * from t4 where attr1 < 5 and attr2 > 9223372036854775803 and attr3 != 3 order by t4.pk1; +pk1 attr1 attr2 attr3 attr4 +2 2 9223372036854775804 2 c +4 4 9223372036854775806 4 e +select * from t3,t4 where t4.attr1 > 1 and t4.attr2 = t3.attr2 and t4.attr3 < 5 order by t4.pk1; +pk1 attr1 attr2 attr3 attr4 pk1 attr1 attr2 attr3 attr4 +2 2 9223372036854775804 2 c 2 2 9223372036854775804 2 c +3 3 9223372036854775805 3 d 3 3 9223372036854775805 3 d +4 4 9223372036854775806 4 e 4 4 9223372036854775806 4 e +set engine_condition_pushdown = on; +explain +select auto from t1 where +string = "aaaa" and +vstring = "aaaa" and +bin = 0xAAAA and +vbin = 0xAAAA and +tiny = -1 and +short = -1 and +medium = -1 and +long_int = -1 and +longlong = -1 and +real_float > 1.0 and real_float < 2.0 and +real_double > 1.0 and real_double < 2.0 and +real_decimal > 1.0 and real_decimal < 2.0 and +utiny = 1 and +ushort = 1 and +umedium = 1 and +ulong = 1 and +ulonglong = 1 and +/* bits = b'001' and */ +options = 'one' and +flags = 'one' and +date_field = '1901-01-01' and +year_field = '1901' and +time_field = '01:01:01' and +date_time = '1901-01-01 01:01:01' +order by auto; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t1 ALL NULL NULL NULL NULL # Using where with pushed condition; Using filesort +select auto from t1 where +string = "aaaa" and +vstring = "aaaa" and +bin = 0xAAAA and +vbin = 0xAAAA and +tiny = -1 and +short = -1 and +medium = -1 and +long_int = -1 and +longlong = -1 and +real_float > 1.0 and real_float < 2.0 and +real_double > 1.0 and real_double < 2.0 and +real_decimal > 1.0 and real_decimal < 2.0 and +utiny = 1 and +ushort = 1 and +umedium = 1 and +ulong = 1 and +ulonglong = 1 and +/* bits = b'001' and */ +options = 'one' and +flags = 'one' and +date_field = '1901-01-01' and +year_field = '1901' and +time_field = '01:01:01' and +date_time = '1901-01-01 01:01:01' +order by auto; +auto +1 +explain +select auto from t1 where +string != "aaaa" and +vstring != "aaaa" and +bin != 0xAAAA and +vbin != 0xAAAA and +tiny != -1 and +short != -1 and +medium != -1 and +long_int != -1 and +longlong != -1 and +(real_float < 1.0 or real_float > 2.0) and +(real_double < 1.0 or real_double > 2.0) and +(real_decimal < 1.0 or real_decimal > 2.0) and +utiny != 1 and +ushort != 1 and +umedium != 1 and +ulong != 1 and +ulonglong != 1 and +/* bits != b'001' and */ +options != 'one' and +flags != 'one' and +date_field != '1901-01-01' and +year_field != '1901' and +time_field != '01:01:01' and +date_time != '1901-01-01 01:01:01' +order by auto; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t1 ALL NULL NULL NULL NULL # Using where with pushed condition; Using filesort +select auto from t1 where +string != "aaaa" and +vstring != "aaaa" and +bin != 0xAAAA and +vbin != 0xAAAA and +tiny != -1 and +short != -1 and +medium != -1 and +long_int != -1 and +longlong != -1 and +(real_float < 1.0 or real_float > 2.0) and +(real_double < 1.0 or real_double > 2.0) and +(real_decimal < 1.0 or real_decimal > 2.0) and +utiny != 1 and +ushort != 1 and +umedium != 1 and +ulong != 1 and +ulonglong != 1 and +/* bits != b'001' and */ +options != 'one' and +flags != 'one' and +date_field != '1901-01-01' and +year_field != '1901' and +time_field != '01:01:01' and +date_time != '1901-01-01 01:01:01' +order by auto; +auto +2 +3 +4 +explain +select auto from t1 where +string > "aaaa" and +vstring > "aaaa" and +bin > 0xAAAA and +vbin > 0xAAAA and +tiny < -1 and +short < -1 and +medium < -1 and +long_int < -1 and +longlong < -1 and +real_float > 1.1 and +real_double > 1.1 and +real_decimal > 1.1 and +utiny > 1 and +ushort > 1 and +umedium > 1 and +ulong > 1 and +ulonglong > 1 and +/* bits > b'001' and */ +(options = 'two' or options = 'three' or options = 'four') and +(flags = 'one,two' or flags = 'one,two,three' or flags = 'one,two,three,four') and +date_field > '1901-01-01' and +year_field > '1901' and +time_field > '01:01:01' and +date_time > '1901-01-01 01:01:01' +order by auto; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t1 ALL NULL NULL NULL NULL # Using where with pushed condition; Using filesort +select auto from t1 where +string > "aaaa" and +vstring > "aaaa" and +bin > 0xAAAA and +vbin > 0xAAAA and +tiny < -1 and +short < -1 and +medium < -1 and +long_int < -1 and +longlong < -1 and +real_float > 1.1 and +real_double > 1.1 and +real_decimal > 1.1 and +utiny > 1 and +ushort > 1 and +umedium > 1 and +ulong > 1 and +ulonglong > 1 and +/* bits > b'001' and */ +(options = 'two' or options = 'three' or options = 'four') and +(flags = 'one,two' or flags = 'one,two,three' or flags = 'one,two,three,four') and +date_field > '1901-01-01' and +year_field > '1901' and +time_field > '01:01:01' and +date_time > '1901-01-01 01:01:01' +order by auto; +auto +2 +3 +4 +explain +select auto from t1 where +string >= "aaaa" and +vstring >= "aaaa" and +bin >= 0xAAAA and +vbin >= 0xAAAA and +tiny <= -1 and +short <= -1 and +medium <= -1 and +long_int <= -1 and +longlong <= -1 and +real_float >= 1.0 and +real_double >= 1.0 and +real_decimal >= 1.0 and +utiny >= 1 and +ushort >= 1 and +umedium >= 1 and +ulong >= 1 and +ulonglong >= 1 and +/* bits >= b'001' and */ +(options = 'one' or options = 'two' or options = 'three' or options = 'four') and +(flags = 'one' or flags = 'one,two' or flags = 'one,two,three' or flags = 'one,two,three,four') and +date_field >= '1901-01-01' and +year_field >= '1901' and +time_field >= '01:01:01' and +date_time >= '1901-01-01 01:01:01' +order by auto; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t1 ALL NULL NULL NULL NULL # Using where with pushed condition; Using filesort +select auto from t1 where +string >= "aaaa" and +vstring >= "aaaa" and +bin >= 0xAAAA and +vbin >= 0xAAAA and +tiny <= -1 and +short <= -1 and +medium <= -1 and +long_int <= -1 and +longlong <= -1 and +real_float >= 1.0 and +real_double >= 1.0 and +real_decimal >= 1.0 and +utiny >= 1 and +ushort >= 1 and +umedium >= 1 and +ulong >= 1 and +ulonglong >= 1 and +/* bits >= b'001' and */ +(options = 'one' or options = 'two' or options = 'three' or options = 'four') and +(flags = 'one' or flags = 'one,two' or flags = 'one,two,three' or flags = 'one,two,three,four') and +date_field >= '1901-01-01' and +year_field >= '1901' and +time_field >= '01:01:01' and +date_time >= '1901-01-01 01:01:01' +order by auto; +auto +1 +2 +3 +4 +explain +select auto from t1 where +string < "dddd" and +vstring < "dddd" and +bin < 0xDDDD and +vbin < 0xDDDD and +tiny > -4 and +short > -4 and +medium > -4 and +long_int > -4 and +longlong > -4 and +real_float < 4.4 and +real_double < 4.4 and +real_decimal < 4.4 and +utiny < 4 and +ushort < 4 and +umedium < 4 and +ulong < 4 and +ulonglong < 4 and +/* bits < b'100' and */ +(options = 'one' or options = 'two' or options = 'three') and +(flags = 'one' or flags = 'one,two' or flags = 'one,two,three') and +date_field < '1904-01-01' and +year_field < '1904' and +time_field < '04:04:04' and +date_time < '1904-04-04 04:04:04' +order by auto; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t1 ALL NULL NULL NULL NULL # Using where with pushed condition; Using filesort +select auto from t1 where +string < "dddd" and +vstring < "dddd" and +bin < 0xDDDD and +vbin < 0xDDDD and +tiny > -4 and +short > -4 and +medium > -4 and +long_int > -4 and +longlong > -4 and +real_float < 4.4 and +real_double < 4.4 and +real_decimal < 4.4 and +utiny < 4 and +ushort < 4 and +umedium < 4 and +ulong < 4 and +ulonglong < 4 and +/* bits < b'100' and */ +(options = 'one' or options = 'two' or options = 'three') and +(flags = 'one' or flags = 'one,two' or flags = 'one,two,three') and +date_field < '1904-01-01' and +year_field < '1904' and +time_field < '04:04:04' and +date_time < '1904-04-04 04:04:04' +order by auto; +auto +1 +2 +3 +explain +select auto from t1 where +string <= "dddd" and +vstring <= "dddd" and +bin <= 0xDDDD and +vbin <= 0xDDDD and +tiny >= -4 and +short >= -4 and +medium >= -4 and +long_int >= -4 and +longlong >= -4 and +real_float <= 4.5 and +real_double <= 4.5 and +real_decimal <= 4.5 and +utiny <= 4 - 1 + 1 and /* Checking function composition */ +ushort <= 4 and +umedium <= 4 and +ulong <= 4 and +ulonglong <= 4 and +/* bits <= b'100' and */ +(options = 'one' or options = 'two' or options = 'three' or options = 'four') and +(flags = 'one' or flags = 'one,two' or flags = 'one,two,three' or flags = 'one,two,three,four') and +date_field <= '1904-04-04' and +year_field <= '1904' and +time_field <= '04:04:04' and +date_time <= '1904-04-04 04:04:04' +order by auto; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t1 ALL NULL NULL NULL NULL # Using where with pushed condition; Using filesort +select auto from t1 where +string <= "dddd" and +vstring <= "dddd" and +bin <= 0xDDDD and +vbin <= 0xDDDD and +tiny >= -4 and +short >= -4 and +medium >= -4 and +long_int >= -4 and +longlong >= -4 and +real_float <= 4.5 and +real_double <= 4.5 and +real_decimal <= 4.5 and +utiny <= 4 - 1 + 1 and /* Checking function composition */ +ushort <= 4 and +umedium <= 4 and +ulong <= 4 and +ulonglong <= 4 and +/* bits <= b'100' and */ +(options = 'one' or options = 'two' or options = 'three' or options = 'four') and +(flags = 'one' or flags = 'one,two' or flags = 'one,two,three' or flags = 'one,two,three,four') and +date_field <= '1904-04-04' and +year_field <= '1904' and +time_field <= '04:04:04' and +date_time <= '1904-04-04 04:04:04' +order by auto; +auto +1 +2 +3 +4 +create index medium_index on t1(medium); +explain +select auto from t1 where +string = "aaaa" and +vstring = "aaaa" and +bin = 0xAAAA and +vbin = 0xAAAA and +tiny = -1 and +short = -1 and +medium = -1 and +long_int = -1 and +longlong = -1 and +real_float > 1.0 and real_float < 2.0 and +real_double > 1.0 and real_double < 2.0 and +real_decimal > 1.0 and real_decimal < 2.0 and +utiny = 1 and +ushort = 1 and +umedium = 1 and +ulong = 1 and +ulonglong = 1 and +/* bits = b'001' and */ +options = 'one' and +flags = 'one' and +date_field = '1901-01-01' and +year_field = '1901' and +time_field = '01:01:01' and +date_time = '1901-01-01 01:01:01' +order by auto; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t1 ref medium_index medium_index 3 const # Using where with pushed condition; Using filesort +select auto from t1 where +string = "aaaa" and +vstring = "aaaa" and +bin = 0xAAAA and +vbin = 0xAAAA and +tiny = -1 and +short = -1 and +medium = -1 and +long_int = -1 and +longlong = -1 and +real_float > 1.0 and real_float < 2.0 and +real_double > 1.0 and real_double < 2.0 and +real_decimal > 1.0 and real_decimal < 2.0 and +utiny = 1 and +ushort = 1 and +umedium = 1 and +ulong = 1 and +ulonglong = 1 and +/* bits = b'001' and */ +options = 'one' and +flags = 'one' and +date_field = '1901-01-01' and +year_field = '1901' and +time_field = '01:01:01' and +date_time = '1901-01-01 01:01:01' +order by auto; +auto +1 +explain +select auto from t1 where +string != "aaaa" and +vstring != "aaaa" and +bin != 0xAAAA and +vbin != 0xAAAA and +tiny != -1 and +short != -1 and +medium != -1 and +long_int != -1 and +longlong != -1 and +(real_float < 1.0 or real_float > 2.0) and +(real_double < 1.0 or real_double > 2.0) and +(real_decimal < 1.0 or real_decimal > 2.0) and +utiny != 1 and +ushort != 1 and +umedium != 1 and +ulong != 1 and +ulonglong != 1 and +/* bits != b'001' and */ +options != 'one' and +flags != 'one' and +date_field != '1901-01-01' and +year_field != '1901' and +time_field != '01:01:01' and +date_time != '1901-01-01 01:01:01' +order by auto; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t1 range medium_index medium_index 3 NULL # Using where with pushed condition; Using filesort +select auto from t1 where +string != "aaaa" and +vstring != "aaaa" and +bin != 0xAAAA and +vbin != 0xAAAA and +tiny != -1 and +short != -1 and +medium != -1 and +long_int != -1 and +longlong != -1 and +(real_float < 1.0 or real_float > 2.0) and +(real_double < 1.0 or real_double > 2.0) and +(real_decimal < 1.0 or real_decimal > 2.0) and +utiny != 1 and +ushort != 1 and +umedium != 1 and +ulong != 1 and +ulonglong != 1 and +/* bits != b'001' and */ +options != 'one' and +flags != 'one' and +date_field != '1901-01-01' and +year_field != '1901' and +time_field != '01:01:01' and +date_time != '1901-01-01 01:01:01' +order by auto; +auto +2 +3 +4 +explain +select auto from t1 where +string > "aaaa" and +vstring > "aaaa" and +bin > 0xAAAA and +vbin > 0xAAAA and +tiny < -1 and +short < -1 and +medium < -1 and +long_int < -1 and +longlong < -1 and +real_float > 1.1 and +real_double > 1.1 and +real_decimal > 1.1 and +utiny > 1 and +ushort > 1 and +umedium > 1 and +ulong > 1 and +ulonglong > 1 and +/* bits > b'001' and */ +(options = 'two' or options = 'three' or options = 'four') and +(flags = 'one,two' or flags = 'one,two,three' or flags = 'one,two,three,four') and +date_field > '1901-01-01' and +year_field > '1901' and +time_field > '01:01:01' and +date_time > '1901-01-01 01:01:01' +order by auto; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t1 range medium_index medium_index 3 NULL # Using where with pushed condition; Using filesort +select auto from t1 where +string > "aaaa" and +vstring > "aaaa" and +bin > 0xAAAA and +vbin > 0xAAAA and +tiny < -1 and +short < -1 and +medium < -1 and +long_int < -1 and +longlong < -1 and +real_float > 1.1 and +real_double > 1.1 and +real_decimal > 1.1 and +utiny > 1 and +ushort > 1 and +umedium > 1 and +ulong > 1 and +ulonglong > 1 and +/* bits > b'001' and */ +(options = 'two' or options = 'three' or options = 'four') and +(flags = 'one,two' or flags = 'one,two,three' or flags = 'one,two,three,four') and +date_field > '1901-01-01' and +year_field > '1901' and +time_field > '01:01:01' and +date_time > '1901-01-01 01:01:01' +order by auto; +auto +2 +3 +4 +explain +select auto from t1 where +string >= "aaaa" and +vstring >= "aaaa" and +bin >= 0xAAAA and +vbin >= 0xAAAA and +tiny <= -1 and +short <= -1 and +medium <= -1 and +long_int <= -1 and +longlong <= -1 and +real_float >= 1.0 and +real_double >= 1.0 and +real_decimal >= 1.0 and +utiny >= 1 and +ushort >= 1 and +umedium >= 1 and +ulong >= 1 and +ulonglong >= 1 and +/* bits >= b'001' and */ +(options = 'one' or options = 'two' or options = 'three' or options = 'four') and +(flags = 'one' or flags = 'one,two' or flags = 'one,two,three' or flags = 'one,two,three,four') and +date_field >= '1901-01-01' and +year_field >= '1901' and +time_field >= '01:01:01' and +date_time >= '1901-01-01 01:01:01' +order by auto; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t1 range medium_index medium_index 3 NULL # Using where with pushed condition; Using filesort +select auto from t1 where +string >= "aaaa" and +vstring >= "aaaa" and +bin >= 0xAAAA and +vbin >= 0xAAAA and +tiny <= -1 and +short <= -1 and +medium <= -1 and +long_int <= -1 and +longlong <= -1 and +real_float >= 1.0 and +real_double >= 1.0 and +real_decimal >= 1.0 and +utiny >= 1 and +ushort >= 1 and +umedium >= 1 and +ulong >= 1 and +ulonglong >= 1 and +/* bits >= b'001' and */ +(options = 'one' or options = 'two' or options = 'three' or options = 'four') and +(flags = 'one' or flags = 'one,two' or flags = 'one,two,three' or flags = 'one,two,three,four') and +date_field >= '1901-01-01' and +year_field >= '1901' and +time_field >= '01:01:01' and +date_time >= '1901-01-01 01:01:01' +order by auto; +auto +1 +2 +3 +4 +explain +select auto from t1 where +string < "dddd" and +vstring < "dddd" and +bin < 0xDDDD and +vbin < 0xDDDD and +tiny > -4 and +short > -4 and +medium > -4 and +long_int > -4 and +longlong > -4 and +real_float < 4.4 and +real_double < 4.4 and +real_decimal < 4.4 and +utiny < 4 and +ushort < 4 and +umedium < 4 and +ulong < 4 and +ulonglong < 4 and +/* bits < b'100' and */ +(options = 'one' or options = 'two' or options = 'three') and +(flags = 'one' or flags = 'one,two' or flags = 'one,two,three') and +date_field < '1904-01-01' and +year_field < '1904' and +time_field < '04:04:04' and +date_time < '1904-04-04 04:04:04' +order by auto; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t1 range medium_index medium_index 3 NULL # Using where with pushed condition; Using filesort +select auto from t1 where +string < "dddd" and +vstring < "dddd" and +bin < 0xDDDD and +vbin < 0xDDDD and +tiny > -4 and +short > -4 and +medium > -4 and +long_int > -4 and +longlong > -4 and +real_float < 4.4 and +real_double < 4.4 and +real_decimal < 4.4 and +utiny < 4 and +ushort < 4 and +umedium < 4 and +ulong < 4 and +ulonglong < 4 and +/* bits < b'100' and */ +(options = 'one' or options = 'two' or options = 'three') and +(flags = 'one' or flags = 'one,two' or flags = 'one,two,three') and +date_field < '1904-01-01' and +year_field < '1904' and +time_field < '04:04:04' and +date_time < '1904-04-04 04:04:04' +order by auto; +auto +1 +2 +3 +explain +select auto from t1 where +string <= "dddd" and +vstring <= "dddd" and +bin <= 0xDDDD and +vbin <= 0xDDDD and +tiny >= -4 and +short >= -4 and +medium >= -4 and +long_int >= -4 and +longlong >= -4 and +real_float <= 4.5 and +real_double <= 4.5 and +real_decimal <= 4.5 and +utiny <= 4 - 1 + 1 and /* Checking function composition */ +ushort <= 4 and +umedium <= 4 and +ulong <= 4 and +ulonglong <= 4 and +/* bits <= b'100' and */ +(options = 'one' or options = 'two' or options = 'three' or options = 'four') and +(flags = 'one' or flags = 'one,two' or flags = 'one,two,three' or flags = 'one,two,three,four') and +date_field <= '1904-04-04' and +year_field <= '1904' and +time_field <= '04:04:04' and +date_time <= '1904-04-04 04:04:04' +order by auto; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t1 range medium_index medium_index 3 NULL # Using where with pushed condition; Using filesort +select auto from t1 where +string <= "dddd" and +vstring <= "dddd" and +bin <= 0xDDDD and +vbin <= 0xDDDD and +tiny >= -4 and +short >= -4 and +medium >= -4 and +long_int >= -4 and +longlong >= -4 and +real_float <= 4.5 and +real_double <= 4.5 and +real_decimal <= 4.5 and +utiny <= 4 - 1 + 1 and /* Checking function composition */ +ushort <= 4 and +umedium <= 4 and +ulong <= 4 and +ulonglong <= 4 and +/* bits <= b'100' and */ +(options = 'one' or options = 'two' or options = 'three' or options = 'four') and +(flags = 'one' or flags = 'one,two' or flags = 'one,two,three' or flags = 'one,two,three,four') and +date_field <= '1904-04-04' and +year_field <= '1904' and +time_field <= '04:04:04' and +date_time <= '1904-04-04 04:04:04' +order by auto; +auto +1 +2 +3 +4 +explain +select auto from t1 where +string like "b%" and +vstring like "b%" and +bin like concat(0xBB, '%') and +vbin like concat(0xBB, '%') +order by auto; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t1 ALL NULL NULL NULL NULL # Using where with pushed condition; Using filesort +select auto from t1 where +string like "b%" and +vstring like "b%" and +bin like concat(0xBB, '%') and +vbin like concat(0xBB, '%') +order by auto; +auto +2 +explain +select auto from t1 where +string not like "b%" and +vstring not like "b%" and +bin not like concat(0xBB, '%') and +vbin not like concat(0xBB, '%') +order by auto; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t1 ALL NULL NULL NULL NULL # Using where with pushed condition; Using filesort +select auto from t1 where +string not like "b%" and +vstring not like "b%" and +bin not like concat(0xBB, '%') and +vbin not like concat(0xBB, '%') +order by auto; +auto +1 +3 +4 +explain +select auto from t1 where +(string between "aaaa" and "cccc") and +(vstring between "aaaa" and "cccc") and +(bin between 0xAAAA and 0xCCCC) and +(vbin between 0xAAAA and 0xCCCC) and +(tiny between -3 and -1) and +(short between -3 and -1) and +(medium between -3 and -1) and +(long_int between -3 and -1) and +(longlong between -3 and -1) and +(utiny between 1 and 3) and +(ushort between 1 and 3) and +(umedium between 1 and 3) and +(ulong between 1 and 3) and +(ulonglong between 1 and 3) and +/* (bits between b'001' and b'011') and */ +(options between 'one' and 'three') and +(flags between 'one' and 'one,two,three') and +(date_field between '1901-01-01' and '1903-03-03') and +(year_field between '1901' and '1903') and +(time_field between '01:01:01' and '03:03:03') and +(date_time between '1901-01-01 01:01:01' and '1903-03-03 03:03:03') +order by auto; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t1 range medium_index medium_index 3 NULL # Using where with pushed condition; Using filesort +select auto from t1 where +(string between "aaaa" and "cccc") and +(vstring between "aaaa" and "cccc") and +(bin between 0xAAAA and 0xCCCC) and +(vbin between 0xAAAA and 0xCCCC) and +(tiny between -3 and -1) and +(short between -3 and -1) and +(medium between -3 and -1) and +(long_int between -3 and -1) and +(longlong between -3 and -1) and +(utiny between 1 and 3) and +(ushort between 1 and 3) and +(umedium between 1 and 3) and +(ulong between 1 and 3) and +(ulonglong between 1 and 3) and +/* (bits between b'001' and b'011') and */ +(options between 'one' and 'three') and +(flags between 'one' and 'one,two,three') and +(date_field between '1901-01-01' and '1903-03-03') and +(year_field between '1901' and '1903') and +(time_field between '01:01:01' and '03:03:03') and +(date_time between '1901-01-01 01:01:01' and '1903-03-03 03:03:03') +order by auto; +auto +1 +3 +explain +select auto from t1 where +("aaaa" between string and string) and +("aaaa" between vstring and vstring) and +(0xAAAA between bin and bin) and +(0xAAAA between vbin and vbin) and +(-1 between tiny and tiny) and +(-1 between short and short) and +(-1 between medium and medium) and +(-1 between long_int and long_int) and +(-1 between longlong and longlong) and +(1 between utiny and utiny) and +(1 between ushort and ushort) and +(1 between umedium and umedium) and +(1 between ulong and ulong) and +(1 between ulonglong and ulonglong) and +/* (b'001' between bits and bits) and */ +('one' between options and options) and +('one' between flags and flags) and +('1901-01-01' between date_field and date_field) and +('1901' between year_field and year_field) and +('01:01:01' between time_field and time_field) and +('1901-01-01 01:01:01' between date_time and date_time) +order by auto; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t1 range medium_index medium_index 3 NULL # Using where with pushed condition; Using filesort +select auto from t1 where +("aaaa" between string and string) and +("aaaa" between vstring and vstring) and +(0xAAAA between bin and bin) and +(0xAAAA between vbin and vbin) and +(-1 between tiny and tiny) and +(-1 between short and short) and +(-1 between medium and medium) and +(-1 between long_int and long_int) and +(-1 between longlong and longlong) and +(1 between utiny and utiny) and +(1 between ushort and ushort) and +(1 between umedium and umedium) and +(1 between ulong and ulong) and +(1 between ulonglong and ulonglong) and +/* (b'001' between bits and bits) and */ +('one' between options and options) and +('one' between flags and flags) and +('1901-01-01' between date_field and date_field) and +('1901' between year_field and year_field) and +('01:01:01' between time_field and time_field) and +('1901-01-01 01:01:01' between date_time and date_time) +order by auto; +auto +1 +explain +select auto from t1 where +(string not between "aaaa" and "cccc") and +(vstring not between "aaaa" and "cccc") and +(bin not between 0xAAAA and 0xCCCC) and +(vbin not between 0xAAAA and 0xCCCC) and +(tiny not between -3 and -1) and +(short not between -3 and -1) and +(medium not between -3 and -1) and +(long_int not between -3 and -1) and +(longlong not between -3 and -1) and +(utiny not between 1 and 3) and +(ushort not between 1 and 3) and +(umedium not between 1 and 3) and +(ulong not between 1 and 3) and +(ulonglong not between 1 and 3) and +/* (bits not between b'001' and b'011') and */ +(options not between 'one' and 'three') and +(flags not between 'one' and 'one,two,three') and +(date_field not between '1901-01-01' and '1903-03-03') and +(year_field not between '1901' and '1903') and +(time_field not between '01:01:01' and '03:03:03') and +(date_time not between '1901-01-01 01:01:01' and '1903-03-03 03:03:03') +order by auto; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t1 range medium_index medium_index 3 NULL # Using where with pushed condition; Using filesort +select auto from t1 where +(string not between "aaaa" and "cccc") and +(vstring not between "aaaa" and "cccc") and +(bin not between 0xAAAA and 0xCCCC) and +(vbin not between 0xAAAA and 0xCCCC) and +(tiny not between -3 and -1) and +(short not between -3 and -1) and +(medium not between -3 and -1) and +(long_int not between -3 and -1) and +(longlong not between -3 and -1) and +(utiny not between 1 and 3) and +(ushort not between 1 and 3) and +(umedium not between 1 and 3) and +(ulong not between 1 and 3) and +(ulonglong not between 1 and 3) and +/* (bits not between b'001' and b'011') and */ +(options not between 'one' and 'three') and +(flags not between 'one' and 'one,two,three') and +(date_field not between '1901-01-01' and '1903-03-03') and +(year_field not between '1901' and '1903') and +(time_field not between '01:01:01' and '03:03:03') and +(date_time not between '1901-01-01 01:01:01' and '1903-03-03 03:03:03') +order by auto; +auto +4 +explain +select auto from t1 where +("aaaa" not between string and string) and +("aaaa" not between vstring and vstring) and +(0xAAAA not between bin and bin) and +(0xAAAA not between vbin and vbin) and +(-1 not between tiny and tiny) and +(-1 not between short and short) and +(-1 not between medium and medium) and +(-1 not between long_int and long_int) and +(-1 not between longlong and longlong) and +(1 not between utiny and utiny) and +(1 not between ushort and ushort) and +(1 not between umedium and umedium) and +(1 not between ulong and ulong) and +(1 not between ulonglong and ulonglong) and +/* (b'001' not between bits and bits) and */ +('one' not between options and options) and +('one' not between flags and flags) and +('1901-01-01' not between date_field and date_field) and +('1901' not between year_field and year_field) and +('01:01:01' not between time_field and time_field) and +('1901-01-01 01:01:01' not between date_time and date_time) +order by auto; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t1 range medium_index medium_index 3 NULL # Using where with pushed condition; Using filesort +select auto from t1 where +("aaaa" not between string and string) and +("aaaa" not between vstring and vstring) and +(0xAAAA not between bin and bin) and +(0xAAAA not between vbin and vbin) and +(-1 not between tiny and tiny) and +(-1 not between short and short) and +(-1 not between medium and medium) and +(-1 not between long_int and long_int) and +(-1 not between longlong and longlong) and +(1 not between utiny and utiny) and +(1 not between ushort and ushort) and +(1 not between umedium and umedium) and +(1 not between ulong and ulong) and +(1 not between ulonglong and ulonglong) and +/* (b'001' not between bits and bits) and */ +('one' not between options and options) and +('one' not between flags and flags) and +('1901-01-01' not between date_field and date_field) and +('1901' not between year_field and year_field) and +('01:01:01' not between time_field and time_field) and +('1901-01-01 01:01:01' not between date_time and date_time) +order by auto; +auto +2 +3 +4 +explain +select auto from t1 where +string in("aaaa","cccc") and +vstring in("aaaa","cccc") and +bin in(0xAAAA,0xCCCC) and +vbin in(0xAAAA,0xCCCC) and +tiny in(-1,-3) and +short in(-1,-3) and +medium in(-1,-3) and +long_int in(-1,-3) and +longlong in(-1,-3) and +utiny in(1,3) and +ushort in(1,3) and +umedium in(1,3) and +ulong in(1,3) and +ulonglong in(1,3) and +/* bits in(b'001',b'011') and */ +options in('one','three') and +flags in('one','one,two,three') and +date_field in('1901-01-01','1903-03-03') and +year_field in('1901','1903') and +time_field in('01:01:01','03:03:03') and +date_time in('1901-01-01 01:01:01','1903-03-03 03:03:03') +order by auto; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t1 range medium_index medium_index 3 NULL # Using where with pushed condition; Using filesort +select auto from t1 where +string in("aaaa","cccc") and +vstring in("aaaa","cccc") and +bin in(0xAAAA,0xCCCC) and +vbin in(0xAAAA,0xCCCC) and +tiny in(-1,-3) and +short in(-1,-3) and +medium in(-1,-3) and +long_int in(-1,-3) and +longlong in(-1,-3) and +utiny in(1,3) and +ushort in(1,3) and +umedium in(1,3) and +ulong in(1,3) and +ulonglong in(1,3) and +/* bits in(b'001',b'011') and */ +options in('one','three') and +flags in('one','one,two,three') and +date_field in('1901-01-01','1903-03-03') and +year_field in('1901','1903') and +time_field in('01:01:01','03:03:03') and +date_time in('1901-01-01 01:01:01','1903-03-03 03:03:03') +order by auto; +auto +1 +3 +explain +select auto from t1 where +"aaaa" in(string) and +"aaaa" in(vstring) and +0xAAAA in(bin) and +0xAAAA in(vbin) and +(-1 in(tiny)) and +(-1 in (short)) and +(-1 in(medium)) and +(-1 in(long_int)) and +(-1 in(longlong)) and +1 in(utiny) and +1 in(ushort) and +1 in(umedium) and +1 in(ulong) and +1 in(ulonglong) and +/* b'001' in(bits) and */ +'one' in(options) and +'one' in(flags) and +'1901-01-01' in(date_field) and +'1901' in(year_field) and +'01:01:01' in(time_field) and +'1901-01-01 01:01:01' in(date_time) +order by auto; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t1 ref medium_index medium_index 3 const # Using where with pushed condition; Using filesort +select auto from t1 where +"aaaa" in(string) and +"aaaa" in(vstring) and +0xAAAA in(bin) and +0xAAAA in(vbin) and +(-1 in(tiny)) and +(-1 in (short)) and +(-1 in(medium)) and +(-1 in(long_int)) and +(-1 in(longlong)) and +1 in(utiny) and +1 in(ushort) and +1 in(umedium) and +1 in(ulong) and +1 in(ulonglong) and +/* b'001' in(bits) and */ +'one' in(options) and +'one' in(flags) and +'1901-01-01' in(date_field) and +'1901' in(year_field) and +'01:01:01' in(time_field) and +'1901-01-01 01:01:01' in(date_time) +order by auto; +auto +1 +explain +select auto from t1 where +string not in("aaaa","cccc") and +vstring not in("aaaa","cccc") and +bin not in(0xAAAA,0xCCCC) and +vbin not in(0xAAAA,0xCCCC) and +tiny not in(-1,-3) and +short not in(-1,-3) and +medium not in(-1,-3) and +long_int not in(-1,-3) and +longlong not in(-1,-3) and +utiny not in(1,3) and +ushort not in(1,3) and +umedium not in(1,3) and +ulong not in(1,3) and +ulonglong not in(1,3) and +/* bits not in(b'001',b'011') and */ +options not in('one','three') and +flags not in('one','one,two,three') and +date_field not in('1901-01-01','1903-03-03') and +year_field not in('1901','1903') and +time_field not in('01:01:01','03:03:03') and +date_time not in('1901-01-01 01:01:01','1903-03-03 03:03:03') +order by auto; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t1 range medium_index medium_index 3 NULL # Using where with pushed condition; Using filesort +select auto from t1 where +string not in("aaaa","cccc") and +vstring not in("aaaa","cccc") and +bin not in(0xAAAA,0xCCCC) and +vbin not in(0xAAAA,0xCCCC) and +tiny not in(-1,-3) and +short not in(-1,-3) and +medium not in(-1,-3) and +long_int not in(-1,-3) and +longlong not in(-1,-3) and +utiny not in(1,3) and +ushort not in(1,3) and +umedium not in(1,3) and +ulong not in(1,3) and +ulonglong not in(1,3) and +/* bits not in(b'001',b'011') and */ +options not in('one','three') and +flags not in('one','one,two,three') and +date_field not in('1901-01-01','1903-03-03') and +year_field not in('1901','1903') and +time_field not in('01:01:01','03:03:03') and +date_time not in('1901-01-01 01:01:01','1903-03-03 03:03:03') +order by auto; +auto +2 +4 +explain +select auto from t1 where +"aaaa" not in(string) and +"aaaa" not in(vstring) and +0xAAAA not in(bin) and +0xAAAA not in(vbin) and +(-1 not in(tiny)) and +(-1 not in(short)) and +(-1 not in(medium)) and +(-1 not in(long_int)) and +(-1 not in(longlong)) and +1 not in(utiny) and +1 not in(ushort) and +1 not in(umedium) and +1 not in(ulong) and +1 not in(ulonglong) and +/* b'001' not in(bits) and */ +'one' not in(options) and +'one' not in(flags) and +'1901-01-01' not in(date_field) and +'1901' not in(year_field) and +'01:01:01' not in(time_field) and +'1901-01-01 01:01:01' not in(date_time) +order by auto; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t1 ALL NULL NULL NULL NULL # Using where with pushed condition; Using filesort +select auto from t1 where +"aaaa" not in(string) and +"aaaa" not in(vstring) and +0xAAAA not in(bin) and +0xAAAA not in(vbin) and +(-1 not in(tiny)) and +(-1 not in(short)) and +(-1 not in(medium)) and +(-1 not in(long_int)) and +(-1 not in(longlong)) and +1 not in(utiny) and +1 not in(ushort) and +1 not in(umedium) and +1 not in(ulong) and +1 not in(ulonglong) and +/* b'001' not in(bits) and */ +'one' not in(options) and +'one' not in(flags) and +'1901-01-01' not in(date_field) and +'1901' not in(year_field) and +'01:01:01' not in(time_field) and +'1901-01-01 01:01:01' not in(date_time) +order by auto; +auto +2 +3 +4 +update t1 +set medium = 17 +where +string = "aaaa" and +vstring = "aaaa" and +bin = 0xAAAA and +vbin = 0xAAAA and +tiny = -1 and +short = -1 and +medium = -1 and +long_int = -1 and +longlong = -1 and +real_float > 1.0 and real_float < 2.0 and +real_double > 1.0 and real_double < 2.0 and +real_decimal > 1.0 and real_decimal < 2.0 and +utiny = 1 and +ushort = 1 and +umedium = 1 and +ulong = 1 and +ulonglong = 1 and +/* bits = b'001' and */ +options = 'one' and +flags = 'one' and +date_field = '1901-01-01' and +year_field = '1901' and +time_field = '01:01:01' and +date_time = '1901-01-01 01:01:01'; +delete from t1 +where +string = "aaaa" and +vstring = "aaaa" and +bin = 0xAAAA and +vbin = 0xAAAA and +tiny = -1 and +short = -1 and +medium = 17 and +long_int = -1 and +longlong = -1 and +real_float > 1.0 and real_float < 2.0 and +real_double > 1.0 and real_double < 2.0 and +real_decimal > 1.0 and real_decimal < 2.0 and +utiny = 1 and +ushort = 1 and +umedium = 1 and +ulong = 1 and +ulonglong = 1 and +/* bits = b'001' and */ +options = 'one' and +flags = 'one' and +date_field = '1901-01-01' and +year_field = '1901' and +time_field = '01:01:01' and +date_time = '1901-01-01 01:01:01'; +select count(*) from t1; +count(*) +3 +explain +select * from t2 where attr3 is null or attr1 > 2 and pk1= 3 order by pk1; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t2 ALL PRIMARY NULL NULL NULL # Using where with pushed condition; Using filesort +select * from t2 where attr3 is null or attr1 > 2 and pk1= 3 order by pk1; +pk1 attr1 attr2 attr3 +2 2 NULL NULL +3 3 3 d +explain +select * from t2 where attr3 is not null and attr1 > 2 order by pk1; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t2 ALL NULL NULL NULL NULL # Using where with pushed condition; Using filesort +select * from t2 where attr3 is not null and attr1 > 2 order by pk1; +pk1 attr1 attr2 attr3 +3 3 3 d +4 4 4 e +5 5 5 f +explain +select * from t3 where attr2 > 9223372036854775803 and attr3 != 3 order by pk1; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t3 ALL NULL NULL NULL NULL # Using where with pushed condition; Using filesort +select * from t3 where attr2 > 9223372036854775803 and attr3 != 3 order by pk1; +pk1 attr1 attr2 attr3 attr4 +2 2 9223372036854775804 2 c +4 4 9223372036854775806 4 e +5 5 9223372036854775807 5 f +explain +select * from t2,t3 where t2.attr1 < 1 and t2.attr2 = t3.attr2 and t3.attr1 < 5 order by t2.pk1; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t2 ALL NULL NULL NULL NULL # Using where with pushed condition; Using temporary; Using filesort +1 SIMPLE t3 ALL NULL NULL NULL NULL # Using where with pushed condition; Using join buffer +select * from t2,t3 where t2.attr1 < 1 and t2.attr2 = t3.attr2 and t3.attr1 < 5 order by t2.pk1; +pk1 attr1 attr2 attr3 pk1 attr1 attr2 attr3 attr4 +0 0 0 a 0 0 0 0 a +explain +select * from t4 where attr1 < 5 and attr2 > 9223372036854775803 and attr3 != 3 order by t4.pk1; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t4 range attr1 attr1 4 NULL # Using where with pushed condition; Using filesort +select * from t4 where attr1 < 5 and attr2 > 9223372036854775803 and attr3 != 3 order by t4.pk1; +pk1 attr1 attr2 attr3 attr4 +2 2 9223372036854775804 2 c +4 4 9223372036854775806 4 e +explain +select * from t3,t4 where t4.attr1 > 1 and t4.attr2 = t3.attr2 and t4.attr3 < 5 order by t4.pk1; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t4 range attr1 attr1 4 NULL # Using where with pushed condition; Using temporary; Using filesort +1 SIMPLE t3 ALL NULL NULL NULL NULL # Using where; Using join buffer +select * from t3,t4 where t4.attr1 > 1 and t4.attr2 = t3.attr2 and t4.attr3 < 5 order by t4.pk1; +pk1 attr1 attr2 attr3 attr4 pk1 attr1 attr2 attr3 attr4 +2 2 9223372036854775804 2 c 2 2 9223372036854775804 2 c +3 3 9223372036854775805 3 d 3 3 9223372036854775805 3 d +4 4 9223372036854775806 4 e 4 4 9223372036854775806 4 e +explain +select auto from t1 where string = "aaaa" collate latin1_general_ci order by auto; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t1 ALL NULL NULL NULL NULL # Using where; Using filesort +explain +select * from t2 where (attr1 < 2) = (attr2 < 2) order by pk1; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t2 ALL NULL NULL NULL NULL # Using where; Using filesort +explain +select * from t3 left join t4 on t4.attr2 = t3.attr2 where t4.attr1 > 1 and t4.attr3 < 5 or t4.attr1 is null order by t4.pk1; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t3 ALL NULL NULL NULL NULL # Using temporary; Using filesort +1 SIMPLE t4 ALL NULL NULL NULL NULL # Using where +create table t5 (a int primary key auto_increment, b tinytext not null) +engine = ndb; +insert into t5 (b) values ('jonas'), ('jensing'), ('johan'); +set engine_condition_pushdown = off; +select * from t5 where b like '%jo%' order by a; +a b +1 jonas +3 johan +set engine_condition_pushdown = on; +explain select * from t5 where b like '%jo%'; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t5 ALL NULL NULL NULL NULL # Using where +select * from t5 where b like '%jo%' order by a; +a b +1 jonas +3 johan +set engine_condition_pushdown = off; +select auto from t1 where date_time like '1902-02-02 %' order by auto; +auto +2 +select auto from t1 where date_time not like '1902-02-02 %' order by auto; +auto +3 +4 +set engine_condition_pushdown = on; +explain select auto from t1 where date_time like '1902-02-02 %'; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t1 ALL NULL NULL NULL NULL # Using where +select auto from t1 where date_time like '1902-02-02 %' order by auto; +auto +2 +explain select auto from t1 where date_time not like '1902-02-02 %'; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t1 ALL NULL NULL NULL NULL # Using where +select auto from t1 where date_time not like '1902-02-02 %' order by auto; +auto +3 +4 +drop table t1; +create table t1 (a int, b varchar(3), primary key using hash(a)) +engine=ndb; +insert into t1 values (1,'a'), (2,'ab'), (3,'abc'); +set engine_condition_pushdown = off; +select * from t1 where b like 'ab'; +a b +2 ab +select * from t1 where b like 'ab' or b like 'ab'; +a b +2 ab +select * from t1 where b like 'abc'; +a b +3 abc +select * from t1 where b like 'abc' or b like 'abc'; +a b +3 abc +set engine_condition_pushdown = on; +select * from t1 where b like 'ab'; +a b +2 ab +select * from t1 where b like 'ab' or b like 'ab'; +a b +2 ab +select * from t1 where b like 'abc'; +a b +3 abc +select * from t1 where b like 'abc' or b like 'abc'; +a b +3 abc +drop table t1; +create table t1 (a int, b char(3), primary key using hash(a)) +engine=ndb; +insert into t1 values (1,'a'), (2,'ab'), (3,'abc'); +set engine_condition_pushdown = off; +select * from t1 where b like 'ab'; +a b +2 ab +select * from t1 where b like 'ab' or b like 'ab'; +a b +2 ab +select * from t1 where b like 'abc'; +a b +3 abc +select * from t1 where b like 'abc' or b like 'abc'; +a b +3 abc +set engine_condition_pushdown = on; +select * from t1 where b like 'ab'; +a b +2 ab +select * from t1 where b like 'ab' or b like 'ab'; +a b +2 ab +select * from t1 where b like 'abc'; +a b +3 abc +select * from t1 where b like 'abc' or b like 'abc'; +a b +3 abc +drop table t1; +create table t1 ( fname varchar(255), lname varchar(255) ) +engine=ndbcluster; +insert into t1 values ("Young","Foo"); +set engine_condition_pushdown = 0; +SELECT fname, lname FROM t1 WHERE (fname like 'Y%') or (lname like 'F%'); +fname lname +Young Foo +set engine_condition_pushdown = 1; +SELECT fname, lname FROM t1 WHERE (fname like 'Y%') or (lname like 'F%'); +fname lname +Young Foo +insert into t1 values ("aaa", "aaa"); +insert into t1 values ("bbb", "bbb"); +insert into t1 values ("ccc", "ccc"); +insert into t1 values ("ddd", "ddd"); +set engine_condition_pushdown = 0; +SELECT fname, lname FROM t1 WHERE (fname like 'Y%') or (lname like 'F%'); +fname lname +Young Foo +set engine_condition_pushdown = 1; +SELECT fname, lname FROM t1 WHERE (fname like 'Y%') or (lname like 'F%'); +fname lname +Young Foo +set engine_condition_pushdown = @old_ecpd; +DROP TABLE t1,t2,t3,t4,t5; diff --git a/mysql-test/suite/ndb/r/ndb_config.result b/mysql-test/suite/ndb/r/ndb_config.result new file mode 100644 index 00000000000..9495af29df6 --- /dev/null +++ b/mysql-test/suite/ndb/r/ndb_config.result @@ -0,0 +1,14 @@ +ndbd,1,localhost ndbd,2,localhost ndb_mgmd,3,localhost mysqld,4, mysqld,5, mysqld,6, mysqld,7, mysqld,8, mysqld,9, mysqld,10, mysqld,11, +1,localhost,20971520,1048576 2,localhost,20971520,1048576 +1 localhost 20971520 1048576 +2 localhost 20971520 1048576 +1 2 +ndbd,1,localhost ndbd,2,localhost ndb_mgmd,3,localhost mysqld,4, mysqld,5, mysqld,6, mysqld,7, mysqld,8, mysqld,9, mysqld,10, mysqld,11, +ndbd,1,localhost,52428800,26214400 ndbd,2,localhost,52428800,36700160 ndbd,3,localhost,52428800,52428800 ndbd,4,localhost,52428800,52428800 ndb_mgmd,5,localhost,, mysqld,6,localhost,, +ndbd,1,localhost ndbd,2,localhost ndbd,3,localhost ndbd,4,localhost ndb_mgmd,5,localhost mysqld,6, mysqld,7, mysqld,8, mysqld,9, mysqld,10, +ndbd,2,localhost ndbd,3,localhost ndbd,4,localhost ndbd,5,localhost ndb_mgmd,6,localhost mysqld,1, mysqld,7, mysqld,8, mysqld,9, mysqld,10, +ndbd,3,localhost ndbd,4,localhost ndbd,5,localhost ndbd,6,localhost ndb_mgmd,1,localhost ndb_mgmd,2,localhost mysqld,11, mysqld,12, mysqld,13, mysqld,14, mysqld,15, +shm,3,4,35,3 shm,3,5,35,3 shm,3,6,35,3 shm,4,5,35,4 shm,4,6,35,4 shm,5,6,35,5 tcp,11,3,55,3 tcp,11,4,55,4 tcp,11,5,55,5 tcp,11,6,55,6 tcp,12,3,55,3 tcp,12,4,55,4 tcp,12,5,55,5 tcp,12,6,55,6 tcp,13,3,55,3 tcp,13,4,55,4 tcp,13,5,55,5 tcp,13,6,55,6 tcp,14,3,55,3 tcp,14,4,55,4 tcp,14,5,55,5 tcp,14,6,55,6 tcp,15,3,55,3 tcp,15,4,55,4 tcp,15,5,55,5 tcp,15,6,55,6 tcp,1,3,55,1 tcp,1,4,55,1 tcp,1,5,55,1 tcp,1,6,55,1 tcp,2,3,55,2 tcp,2,4,55,2 tcp,2,5,55,2 tcp,2,6,55,2 +1 2 3 + +1 2 3 diff --git a/mysql-test/suite/ndb/r/ndb_config2.result b/mysql-test/suite/ndb/r/ndb_config2.result new file mode 100644 index 00000000000..cfd012933c4 --- /dev/null +++ b/mysql-test/suite/ndb/r/ndb_config2.result @@ -0,0 +1 @@ +shm,3,4,35,3 shm,3,5,35,3 shm,3,6,35,3 shm,4,5,35,4 shm,4,6,35,4 shm,5,6,35,5 tcp,11,3,55,3 tcp,11,4,55,4 tcp,11,5,55,5 tcp,11,6,55,6 tcp,12,3,55,3 tcp,12,4,55,4 tcp,12,5,55,5 tcp,12,6,55,6 tcp,13,3,55,3 tcp,13,4,55,4 tcp,13,5,55,5 tcp,13,6,55,6 tcp,14,3,55,3 tcp,14,4,55,4 tcp,14,5,55,5 tcp,14,6,55,6 tcp,15,3,55,3 tcp,15,4,55,4 tcp,15,5,55,5 tcp,15,6,55,6 tcp,1,3,55,1 tcp,1,4,55,1 tcp,1,5,55,1 tcp,1,6,55,1 tcp,2,3,55,2 tcp,2,4,55,2 tcp,2,5,55,2 tcp,2,6,55,2 diff --git a/mysql-test/suite/ndb/r/ndb_cursor.result b/mysql-test/suite/ndb/r/ndb_cursor.result new file mode 100644 index 00000000000..b3b815ef891 --- /dev/null +++ b/mysql-test/suite/ndb/r/ndb_cursor.result @@ -0,0 +1,40 @@ +drop table if exists t1; +drop table if exists t2; +create table t1 ( +a int not null primary key, +b int not null +) engine=ndb; +create table t2 ( +a int not null primary key, +b int not null +) engine=ndb; +insert into t1 values (1,10), (2,20), (3,30), (4, 40); +create procedure test_cursor () +begin +declare done int default 0; +declare temp_a int; +declare temp_b int; +declare cur1 cursor for select a,b from t1; +declare continue handler for sqlstate '02000' set done = 1; +open cur1; +repeat +fetch cur1 into temp_a, temp_b; +if not done then +insert into t2 values (temp_a, temp_b); +end if; +until done end repeat; +close cur1; +end; +// +select * from t2 order by a; +a b +call test_cursor(); +select * from t2 order by a; +a b +1 10 +2 20 +3 30 +4 40 +drop procedure test_cursor; +drop table t1,t2; +end of 5.1 tests diff --git a/mysql-test/suite/ndb/r/ndb_database.result b/mysql-test/suite/ndb/r/ndb_database.result new file mode 100644 index 00000000000..e3da4af0265 --- /dev/null +++ b/mysql-test/suite/ndb/r/ndb_database.result @@ -0,0 +1,13 @@ +drop database if exists mysqltest; +create database mysqltest; +create table mysqltest.t1 (a int primary key, b int) engine=ndb; +use mysqltest; +show tables; +Tables_in_mysqltest +t1 +drop database mysqltest; +create database mysqltest; +use mysqltest; +show tables; +Tables_in_mysqltest +drop database mysqltest; diff --git a/mysql-test/suite/ndb/r/ndb_dd_alter.result b/mysql-test/suite/ndb/r/ndb_dd_alter.result new file mode 100644 index 00000000000..94426546115 --- /dev/null +++ b/mysql-test/suite/ndb/r/ndb_dd_alter.result @@ -0,0 +1,560 @@ +DROP TABLE IF EXISTS test.t1; +DROP TABLE IF EXISTS test.t2; +**** Test Setup Section **** +CREATE LOGFILE GROUP lg +ADD UNDOFILE './lg_group/undofile.dat' + INITIAL_SIZE 16M +UNDO_BUFFER_SIZE = 1M +ENGINE=NDB; +CREATE TABLESPACE ts +ADD DATAFILE './table_space/datafile.dat' + USE LOGFILE GROUP lg +INITIAL_SIZE 12M +ENGINE NDB; +CREATE TABLE test.t1 ( +a1 smallint NOT NULL, +a2 int NOT NULL, +a3 bigint NOT NULL, +a4 char(10), +a5 decimal(5,1), +a6 time, +a7 date, +a8 datetime, +a9 VARCHAR(255), +a10 blob, +PRIMARY KEY(a1) +) ENGINE=InnoDB; +SHOW CREATE TABLE test.t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a1` smallint(6) NOT NULL, + `a2` int(11) NOT NULL, + `a3` bigint(20) NOT NULL, + `a4` char(10) DEFAULT NULL, + `a5` decimal(5,1) DEFAULT NULL, + `a6` time DEFAULT NULL, + `a7` date DEFAULT NULL, + `a8` datetime DEFAULT NULL, + `a9` varchar(255) DEFAULT NULL, + `a10` blob, + PRIMARY KEY (`a1`) +) ENGINE=InnoDB DEFAULT CHARSET=latin1 +SELECT * FROM test.t1 ORDER BY a1; +a1 a2 a3 a4 a5 a6 a7 a8 a9 a10 +1 2 2000000001 aaa1 34.2 04:03:02 2006-01-01 1971-05-28 16:55:03 bbbbbbbbbbbbb1 binary data +2 3 2000000002 aaa2 34.2 04:03:02 2006-01-01 1971-05-28 16:55:03 bbbbbbbbbbbbb2 binary data +3 4 2000000003 aaa3 34.2 04:03:02 2006-01-01 1971-05-28 16:55:03 bbbbbbbbbbbbb3 binary data +4 5 2000000004 aaa4 34.2 04:03:02 2006-01-01 1971-05-28 16:55:03 bbbbbbbbbbbbb4 binary data +5 6 2000000005 aaa5 34.2 04:03:02 2006-01-01 1971-05-28 16:55:03 bbbbbbbbbbbbb5 binary data +6 7 2000000006 aaa6 34.2 04:03:02 2006-01-01 1971-05-28 16:55:03 bbbbbbbbbbbbb6 binary data +7 8 2000000007 aaa7 34.2 04:03:02 2006-01-01 1971-05-28 16:55:03 bbbbbbbbbbbbb7 binary data +8 9 2000000008 aaa8 34.2 04:03:02 2006-01-01 1971-05-28 16:55:03 bbbbbbbbbbbbb8 binary data +9 10 2000000009 aaa9 34.2 04:03:02 2006-01-01 1971-05-28 16:55:03 bbbbbbbbbbbbb9 binary data +10 11 2000000010 aaa10 34.2 04:03:02 2006-01-01 1971-05-28 16:55:03 bbbbbbbbbbbbb10 binary data +11 12 2000000011 aaa11 34.2 04:03:02 2006-01-01 1971-05-28 16:55:03 bbbbbbbbbbbbb11 binary data +12 13 2000000012 aaa12 34.2 04:03:02 2006-01-01 1971-05-28 16:55:03 bbbbbbbbbbbbb12 binary data +13 14 2000000013 aaa13 34.2 04:03:02 2006-01-01 1971-05-28 16:55:03 bbbbbbbbbbbbb13 binary data +14 15 2000000014 aaa14 34.2 04:03:02 2006-01-01 1971-05-28 16:55:03 bbbbbbbbbbbbb14 binary data +15 16 2000000015 aaa15 34.2 04:03:02 2006-01-01 1971-05-28 16:55:03 bbbbbbbbbbbbb15 binary data +16 17 2000000016 aaa16 34.2 04:03:02 2006-01-01 1971-05-28 16:55:03 bbbbbbbbbbbbb16 binary data +17 18 2000000017 aaa17 34.2 04:03:02 2006-01-01 1971-05-28 16:55:03 bbbbbbbbbbbbb17 binary data +18 19 2000000018 aaa18 34.2 04:03:02 2006-01-01 1971-05-28 16:55:03 bbbbbbbbbbbbb18 binary data +19 20 2000000019 aaa19 34.2 04:03:02 2006-01-01 1971-05-28 16:55:03 bbbbbbbbbbbbb19 binary data +20 21 2000000020 aaa20 34.2 04:03:02 2006-01-01 1971-05-28 16:55:03 bbbbbbbbbbbbb20 binary data +ALTER TABLE test.t1 TABLESPACE ts STORAGE DISK ENGINE=NDB; +SHOW CREATE TABLE test.t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a1` smallint(6) NOT NULL, + `a2` int(11) NOT NULL, + `a3` bigint(20) NOT NULL, + `a4` char(10) DEFAULT NULL, + `a5` decimal(5,1) DEFAULT NULL, + `a6` time DEFAULT NULL, + `a7` date DEFAULT NULL, + `a8` datetime DEFAULT NULL, + `a9` varchar(255) DEFAULT NULL, + `a10` blob, + PRIMARY KEY (`a1`) +) /*!50100 TABLESPACE ts STORAGE DISK */ ENGINE=ndbcluster DEFAULT CHARSET=latin1 +a1 Smallint PRIMARY KEY DISTRIBUTION KEY AT=FIXED ST=MEMORY +a2 Int NOT NULL AT=FIXED ST=DISK +a3 Bigint NOT NULL AT=FIXED ST=DISK +a4 Char(10;latin1_swedish_ci) NULL AT=FIXED ST=DISK +a5 Decimal(5,1) NULL AT=FIXED ST=DISK +a6 Time NULL AT=FIXED ST=DISK +a7 Date NULL AT=FIXED ST=DISK +a8 Datetime NULL AT=FIXED ST=DISK +a9 Varchar(255;latin1_swedish_ci) NULL AT=FIXED ST=DISK +a10 Blob(256,2000;16) NULL AT=FIXED ST=MEMORY +SELECT * FROM test.t1 ORDER BY a1; +a1 a2 a3 a4 a5 a6 a7 a8 a9 a10 +1 2 2000000001 aaa1 34.2 04:03:02 2006-01-01 1971-05-28 16:55:03 bbbbbbbbbbbbb1 binary data +2 3 2000000002 aaa2 34.2 04:03:02 2006-01-01 1971-05-28 16:55:03 bbbbbbbbbbbbb2 binary data +3 4 2000000003 aaa3 34.2 04:03:02 2006-01-01 1971-05-28 16:55:03 bbbbbbbbbbbbb3 binary data +4 5 2000000004 aaa4 34.2 04:03:02 2006-01-01 1971-05-28 16:55:03 bbbbbbbbbbbbb4 binary data +5 6 2000000005 aaa5 34.2 04:03:02 2006-01-01 1971-05-28 16:55:03 bbbbbbbbbbbbb5 binary data +6 7 2000000006 aaa6 34.2 04:03:02 2006-01-01 1971-05-28 16:55:03 bbbbbbbbbbbbb6 binary data +7 8 2000000007 aaa7 34.2 04:03:02 2006-01-01 1971-05-28 16:55:03 bbbbbbbbbbbbb7 binary data +8 9 2000000008 aaa8 34.2 04:03:02 2006-01-01 1971-05-28 16:55:03 bbbbbbbbbbbbb8 binary data +9 10 2000000009 aaa9 34.2 04:03:02 2006-01-01 1971-05-28 16:55:03 bbbbbbbbbbbbb9 binary data +10 11 2000000010 aaa10 34.2 04:03:02 2006-01-01 1971-05-28 16:55:03 bbbbbbbbbbbbb10 binary data +11 12 2000000011 aaa11 34.2 04:03:02 2006-01-01 1971-05-28 16:55:03 bbbbbbbbbbbbb11 binary data +12 13 2000000012 aaa12 34.2 04:03:02 2006-01-01 1971-05-28 16:55:03 bbbbbbbbbbbbb12 binary data +13 14 2000000013 aaa13 34.2 04:03:02 2006-01-01 1971-05-28 16:55:03 bbbbbbbbbbbbb13 binary data +14 15 2000000014 aaa14 34.2 04:03:02 2006-01-01 1971-05-28 16:55:03 bbbbbbbbbbbbb14 binary data +15 16 2000000015 aaa15 34.2 04:03:02 2006-01-01 1971-05-28 16:55:03 bbbbbbbbbbbbb15 binary data +16 17 2000000016 aaa16 34.2 04:03:02 2006-01-01 1971-05-28 16:55:03 bbbbbbbbbbbbb16 binary data +17 18 2000000017 aaa17 34.2 04:03:02 2006-01-01 1971-05-28 16:55:03 bbbbbbbbbbbbb17 binary data +18 19 2000000018 aaa18 34.2 04:03:02 2006-01-01 1971-05-28 16:55:03 bbbbbbbbbbbbb18 binary data +19 20 2000000019 aaa19 34.2 04:03:02 2006-01-01 1971-05-28 16:55:03 bbbbbbbbbbbbb19 binary data +20 21 2000000020 aaa20 34.2 04:03:02 2006-01-01 1971-05-28 16:55:03 bbbbbbbbbbbbb20 binary data +DROP TABLE test.t1; +CREATE TABLE test.t1 ( +a1 smallint NOT NULL, +a2 int NOT NULL, +a3 bigint NOT NULL, +a4 char(10), +a5 decimal(5,1), +a6 time, +a7 date, +a8 datetime, +a9 VARCHAR(255), +a10 blob, +PRIMARY KEY(a1) +) ENGINE=MyISAM; +SHOW CREATE TABLE test.t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a1` smallint(6) NOT NULL, + `a2` int(11) NOT NULL, + `a3` bigint(20) NOT NULL, + `a4` char(10) DEFAULT NULL, + `a5` decimal(5,1) DEFAULT NULL, + `a6` time DEFAULT NULL, + `a7` date DEFAULT NULL, + `a8` datetime DEFAULT NULL, + `a9` varchar(255) DEFAULT NULL, + `a10` blob, + PRIMARY KEY (`a1`) +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +SELECT * FROM test.t1 ORDER BY a1; +a1 a2 a3 a4 a5 a6 a7 a8 a9 a10 +1 2 2000000001 aaa1 34.2 04:03:02 2006-01-01 1971-05-28 16:55:03 bbbbbbbbbbbbb1 binary data +2 3 2000000002 aaa2 34.2 04:03:02 2006-01-01 1971-05-28 16:55:03 bbbbbbbbbbbbb2 binary data +3 4 2000000003 aaa3 34.2 04:03:02 2006-01-01 1971-05-28 16:55:03 bbbbbbbbbbbbb3 binary data +4 5 2000000004 aaa4 34.2 04:03:02 2006-01-01 1971-05-28 16:55:03 bbbbbbbbbbbbb4 binary data +5 6 2000000005 aaa5 34.2 04:03:02 2006-01-01 1971-05-28 16:55:03 bbbbbbbbbbbbb5 binary data +6 7 2000000006 aaa6 34.2 04:03:02 2006-01-01 1971-05-28 16:55:03 bbbbbbbbbbbbb6 binary data +7 8 2000000007 aaa7 34.2 04:03:02 2006-01-01 1971-05-28 16:55:03 bbbbbbbbbbbbb7 binary data +8 9 2000000008 aaa8 34.2 04:03:02 2006-01-01 1971-05-28 16:55:03 bbbbbbbbbbbbb8 binary data +9 10 2000000009 aaa9 34.2 04:03:02 2006-01-01 1971-05-28 16:55:03 bbbbbbbbbbbbb9 binary data +10 11 2000000010 aaa10 34.2 04:03:02 2006-01-01 1971-05-28 16:55:03 bbbbbbbbbbbbb10 binary data +11 12 2000000011 aaa11 34.2 04:03:02 2006-01-01 1971-05-28 16:55:03 bbbbbbbbbbbbb11 binary data +12 13 2000000012 aaa12 34.2 04:03:02 2006-01-01 1971-05-28 16:55:03 bbbbbbbbbbbbb12 binary data +13 14 2000000013 aaa13 34.2 04:03:02 2006-01-01 1971-05-28 16:55:03 bbbbbbbbbbbbb13 binary data +14 15 2000000014 aaa14 34.2 04:03:02 2006-01-01 1971-05-28 16:55:03 bbbbbbbbbbbbb14 binary data +15 16 2000000015 aaa15 34.2 04:03:02 2006-01-01 1971-05-28 16:55:03 bbbbbbbbbbbbb15 binary data +16 17 2000000016 aaa16 34.2 04:03:02 2006-01-01 1971-05-28 16:55:03 bbbbbbbbbbbbb16 binary data +17 18 2000000017 aaa17 34.2 04:03:02 2006-01-01 1971-05-28 16:55:03 bbbbbbbbbbbbb17 binary data +18 19 2000000018 aaa18 34.2 04:03:02 2006-01-01 1971-05-28 16:55:03 bbbbbbbbbbbbb18 binary data +19 20 2000000019 aaa19 34.2 04:03:02 2006-01-01 1971-05-28 16:55:03 bbbbbbbbbbbbb19 binary data +20 21 2000000020 aaa20 34.2 04:03:02 2006-01-01 1971-05-28 16:55:03 bbbbbbbbbbbbb20 binary data +ALTER TABLE test.t1 TABLESPACE ts STORAGE DISK ENGINE=NDB; +SHOW CREATE TABLE test.t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a1` smallint(6) NOT NULL, + `a2` int(11) NOT NULL, + `a3` bigint(20) NOT NULL, + `a4` char(10) DEFAULT NULL, + `a5` decimal(5,1) DEFAULT NULL, + `a6` time DEFAULT NULL, + `a7` date DEFAULT NULL, + `a8` datetime DEFAULT NULL, + `a9` varchar(255) DEFAULT NULL, + `a10` blob, + PRIMARY KEY (`a1`) +) /*!50100 TABLESPACE ts STORAGE DISK */ ENGINE=ndbcluster DEFAULT CHARSET=latin1 +a1 Smallint PRIMARY KEY DISTRIBUTION KEY AT=FIXED ST=MEMORY +a2 Int NOT NULL AT=FIXED ST=DISK +a3 Bigint NOT NULL AT=FIXED ST=DISK +a4 Char(10;latin1_swedish_ci) NULL AT=FIXED ST=DISK +a5 Decimal(5,1) NULL AT=FIXED ST=DISK +a6 Time NULL AT=FIXED ST=DISK +a7 Date NULL AT=FIXED ST=DISK +a8 Datetime NULL AT=FIXED ST=DISK +a9 Varchar(255;latin1_swedish_ci) NULL AT=FIXED ST=DISK +a10 Blob(256,2000;16) NULL AT=FIXED ST=MEMORY +SELECT * FROM test.t1 ORDER BY a1; +a1 a2 a3 a4 a5 a6 a7 a8 a9 a10 +1 2 2000000001 aaa1 34.2 04:03:02 2006-01-01 1971-05-28 16:55:03 bbbbbbbbbbbbb1 binary data +2 3 2000000002 aaa2 34.2 04:03:02 2006-01-01 1971-05-28 16:55:03 bbbbbbbbbbbbb2 binary data +3 4 2000000003 aaa3 34.2 04:03:02 2006-01-01 1971-05-28 16:55:03 bbbbbbbbbbbbb3 binary data +4 5 2000000004 aaa4 34.2 04:03:02 2006-01-01 1971-05-28 16:55:03 bbbbbbbbbbbbb4 binary data +5 6 2000000005 aaa5 34.2 04:03:02 2006-01-01 1971-05-28 16:55:03 bbbbbbbbbbbbb5 binary data +6 7 2000000006 aaa6 34.2 04:03:02 2006-01-01 1971-05-28 16:55:03 bbbbbbbbbbbbb6 binary data +7 8 2000000007 aaa7 34.2 04:03:02 2006-01-01 1971-05-28 16:55:03 bbbbbbbbbbbbb7 binary data +8 9 2000000008 aaa8 34.2 04:03:02 2006-01-01 1971-05-28 16:55:03 bbbbbbbbbbbbb8 binary data +9 10 2000000009 aaa9 34.2 04:03:02 2006-01-01 1971-05-28 16:55:03 bbbbbbbbbbbbb9 binary data +10 11 2000000010 aaa10 34.2 04:03:02 2006-01-01 1971-05-28 16:55:03 bbbbbbbbbbbbb10 binary data +11 12 2000000011 aaa11 34.2 04:03:02 2006-01-01 1971-05-28 16:55:03 bbbbbbbbbbbbb11 binary data +12 13 2000000012 aaa12 34.2 04:03:02 2006-01-01 1971-05-28 16:55:03 bbbbbbbbbbbbb12 binary data +13 14 2000000013 aaa13 34.2 04:03:02 2006-01-01 1971-05-28 16:55:03 bbbbbbbbbbbbb13 binary data +14 15 2000000014 aaa14 34.2 04:03:02 2006-01-01 1971-05-28 16:55:03 bbbbbbbbbbbbb14 binary data +15 16 2000000015 aaa15 34.2 04:03:02 2006-01-01 1971-05-28 16:55:03 bbbbbbbbbbbbb15 binary data +16 17 2000000016 aaa16 34.2 04:03:02 2006-01-01 1971-05-28 16:55:03 bbbbbbbbbbbbb16 binary data +17 18 2000000017 aaa17 34.2 04:03:02 2006-01-01 1971-05-28 16:55:03 bbbbbbbbbbbbb17 binary data +18 19 2000000018 aaa18 34.2 04:03:02 2006-01-01 1971-05-28 16:55:03 bbbbbbbbbbbbb18 binary data +19 20 2000000019 aaa19 34.2 04:03:02 2006-01-01 1971-05-28 16:55:03 bbbbbbbbbbbbb19 binary data +20 21 2000000020 aaa20 34.2 04:03:02 2006-01-01 1971-05-28 16:55:03 bbbbbbbbbbbbb20 binary data +ALTER TABLE test.t1 ENGINE=InnoDB; +SHOW CREATE TABLE test.t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a1` smallint(6) NOT NULL, + `a2` int(11) NOT NULL, + `a3` bigint(20) NOT NULL, + `a4` char(10) DEFAULT NULL, + `a5` decimal(5,1) DEFAULT NULL, + `a6` time DEFAULT NULL, + `a7` date DEFAULT NULL, + `a8` datetime DEFAULT NULL, + `a9` varchar(255) DEFAULT NULL, + `a10` blob, + PRIMARY KEY (`a1`) +) ENGINE=InnoDB DEFAULT CHARSET=latin1 +SELECT * FROM test.t1 ORDER BY a1; +a1 a2 a3 a4 a5 a6 a7 a8 a9 a10 +1 2 2000000001 aaa1 34.2 04:03:02 2006-01-01 1971-05-28 16:55:03 bbbbbbbbbbbbb1 binary data +2 3 2000000002 aaa2 34.2 04:03:02 2006-01-01 1971-05-28 16:55:03 bbbbbbbbbbbbb2 binary data +3 4 2000000003 aaa3 34.2 04:03:02 2006-01-01 1971-05-28 16:55:03 bbbbbbbbbbbbb3 binary data +4 5 2000000004 aaa4 34.2 04:03:02 2006-01-01 1971-05-28 16:55:03 bbbbbbbbbbbbb4 binary data +5 6 2000000005 aaa5 34.2 04:03:02 2006-01-01 1971-05-28 16:55:03 bbbbbbbbbbbbb5 binary data +6 7 2000000006 aaa6 34.2 04:03:02 2006-01-01 1971-05-28 16:55:03 bbbbbbbbbbbbb6 binary data +7 8 2000000007 aaa7 34.2 04:03:02 2006-01-01 1971-05-28 16:55:03 bbbbbbbbbbbbb7 binary data +8 9 2000000008 aaa8 34.2 04:03:02 2006-01-01 1971-05-28 16:55:03 bbbbbbbbbbbbb8 binary data +9 10 2000000009 aaa9 34.2 04:03:02 2006-01-01 1971-05-28 16:55:03 bbbbbbbbbbbbb9 binary data +10 11 2000000010 aaa10 34.2 04:03:02 2006-01-01 1971-05-28 16:55:03 bbbbbbbbbbbbb10 binary data +11 12 2000000011 aaa11 34.2 04:03:02 2006-01-01 1971-05-28 16:55:03 bbbbbbbbbbbbb11 binary data +12 13 2000000012 aaa12 34.2 04:03:02 2006-01-01 1971-05-28 16:55:03 bbbbbbbbbbbbb12 binary data +13 14 2000000013 aaa13 34.2 04:03:02 2006-01-01 1971-05-28 16:55:03 bbbbbbbbbbbbb13 binary data +14 15 2000000014 aaa14 34.2 04:03:02 2006-01-01 1971-05-28 16:55:03 bbbbbbbbbbbbb14 binary data +15 16 2000000015 aaa15 34.2 04:03:02 2006-01-01 1971-05-28 16:55:03 bbbbbbbbbbbbb15 binary data +16 17 2000000016 aaa16 34.2 04:03:02 2006-01-01 1971-05-28 16:55:03 bbbbbbbbbbbbb16 binary data +17 18 2000000017 aaa17 34.2 04:03:02 2006-01-01 1971-05-28 16:55:03 bbbbbbbbbbbbb17 binary data +18 19 2000000018 aaa18 34.2 04:03:02 2006-01-01 1971-05-28 16:55:03 bbbbbbbbbbbbb18 binary data +19 20 2000000019 aaa19 34.2 04:03:02 2006-01-01 1971-05-28 16:55:03 bbbbbbbbbbbbb19 binary data +20 21 2000000020 aaa20 34.2 04:03:02 2006-01-01 1971-05-28 16:55:03 bbbbbbbbbbbbb20 binary data +ALTER TABLE test.t1 TABLESPACE ts STORAGE DISK ENGINE=NDB; +SHOW CREATE TABLE test.t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a1` smallint(6) NOT NULL, + `a2` int(11) NOT NULL, + `a3` bigint(20) NOT NULL, + `a4` char(10) DEFAULT NULL, + `a5` decimal(5,1) DEFAULT NULL, + `a6` time DEFAULT NULL, + `a7` date DEFAULT NULL, + `a8` datetime DEFAULT NULL, + `a9` varchar(255) DEFAULT NULL, + `a10` blob, + PRIMARY KEY (`a1`) +) /*!50100 TABLESPACE ts STORAGE DISK */ ENGINE=ndbcluster DEFAULT CHARSET=latin1 +a1 Smallint PRIMARY KEY DISTRIBUTION KEY AT=FIXED ST=MEMORY +a2 Int NOT NULL AT=FIXED ST=DISK +a3 Bigint NOT NULL AT=FIXED ST=DISK +a4 Char(10;latin1_swedish_ci) NULL AT=FIXED ST=DISK +a5 Decimal(5,1) NULL AT=FIXED ST=DISK +a6 Time NULL AT=FIXED ST=DISK +a7 Date NULL AT=FIXED ST=DISK +a8 Datetime NULL AT=FIXED ST=DISK +a9 Varchar(255;latin1_swedish_ci) NULL AT=FIXED ST=DISK +a10 Blob(256,2000;16) NULL AT=FIXED ST=MEMORY +ALTER TABLE test.t1 ENGINE=MyISAM; +SHOW CREATE TABLE test.t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a1` smallint(6) NOT NULL, + `a2` int(11) NOT NULL, + `a3` bigint(20) NOT NULL, + `a4` char(10) DEFAULT NULL, + `a5` decimal(5,1) DEFAULT NULL, + `a6` time DEFAULT NULL, + `a7` date DEFAULT NULL, + `a8` datetime DEFAULT NULL, + `a9` varchar(255) DEFAULT NULL, + `a10` blob, + PRIMARY KEY (`a1`) +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +DROP TABLE test.t1; +CREATE TABLE test.t1 (a1 INT PRIMARY KEY) TABLESPACE ts STORAGE DISK ENGINE=NDB; +SELECT * FROM test.t1 ORDER BY a1; +a1 +1 +2 +3 +4 +5 +6 +7 +8 +9 +10 +11 +12 +13 +14 +15 +16 +17 +18 +19 +20 +SELECT * FROM information_schema.partitions WHERE table_name= 't1' AND partition_name = 'p0'; +TABLE_CATALOG TABLE_SCHEMA TABLE_NAME PARTITION_NAME SUBPARTITION_NAME PARTITION_ORDINAL_POSITION SUBPARTITION_ORDINAL_POSITION PARTITION_METHOD SUBPARTITION_METHOD PARTITION_EXPRESSION SUBPARTITION_EXPRESSION PARTITION_DESCRIPTION TABLE_ROWS AVG_ROW_LENGTH DATA_LENGTH MAX_DATA_LENGTH INDEX_LENGTH DATA_FREE CREATE_TIME UPDATE_TIME CHECK_TIME CHECKSUM PARTITION_COMMENT NODEGROUP TABLESPACE_NAME +NULL test t1 p0 NULL 1 NULL KEY NULL NULL NULL 0 0 0 NULL 0 0 NULL NULL NULL NULL default ts +ALTER TABLE test.t1 ADD a2 FLOAT, ADD a3 DOUBLE; +SELECT * FROM information_schema.partitions WHERE table_name= 't1' AND partition_name = 'p0'; +TABLE_CATALOG TABLE_SCHEMA TABLE_NAME PARTITION_NAME SUBPARTITION_NAME PARTITION_ORDINAL_POSITION SUBPARTITION_ORDINAL_POSITION PARTITION_METHOD SUBPARTITION_METHOD PARTITION_EXPRESSION SUBPARTITION_EXPRESSION PARTITION_DESCRIPTION TABLE_ROWS AVG_ROW_LENGTH DATA_LENGTH MAX_DATA_LENGTH INDEX_LENGTH DATA_FREE CREATE_TIME UPDATE_TIME CHECK_TIME CHECKSUM PARTITION_COMMENT NODEGROUP TABLESPACE_NAME +NULL test t1 p0 NULL 1 NULL KEY NULL NULL NULL 0 0 0 NULL 0 0 NULL NULL NULL NULL default ts +SELECT * FROM test.t1 ORDER BY a1; +a1 a2 a3 +1 2.2345 20000001 +2 3.2345 20000002 +3 4.2345 20000003 +4 5.2345 20000004 +5 6.2345 20000005 +6 7.2345 20000006 +7 8.2345 20000007 +8 9.2345 20000008 +9 10.2345 20000009 +10 11.2345 20000010 +11 12.2345 20000011 +12 13.2345 20000012 +13 14.2345 20000013 +14 15.2345 20000014 +15 16.2345 20000015 +16 17.2345 20000016 +17 18.2345 20000017 +18 19.2345 20000018 +19 20.2345 20000019 +20 21.2345 20000020 +ALTER TABLE test.t1 ADD a4 BIT, ADD a5 TINYINT, ADD a6 BIGINT, ADD a7 DATE, ADD a8 TIME; +SELECT a1,a2,a3,hex(a4), a5,a6,a7,a8 FROM test.t1 ORDER BY a1; +a1 a2 a3 hex(a4) a5 a6 a7 a8 +1 2.2345 20000001 0 1 23457 2006-01-01 07:04:00 +2 3.2345 20000002 0 1 23458 2006-01-01 07:04:00 +3 4.2345 20000003 0 1 23459 2006-01-01 07:04:00 +4 5.2345 20000004 0 1 23460 2006-01-01 07:04:00 +5 6.2345 20000005 0 1 23461 2006-01-01 07:04:00 +6 7.2345 20000006 0 1 23462 2006-01-01 07:04:00 +7 8.2345 20000007 0 1 23463 2006-01-01 07:04:00 +8 9.2345 20000008 0 1 23464 2006-01-01 07:04:00 +9 10.2345 20000009 0 1 23465 2006-01-01 07:04:00 +10 11.2345 20000010 0 1 23466 2006-01-01 07:04:00 +11 12.2345 20000011 0 1 23467 2006-01-01 07:04:00 +12 13.2345 20000012 0 1 23468 2006-01-01 07:04:00 +13 14.2345 20000013 0 1 23469 2006-01-01 07:04:00 +14 15.2345 20000014 0 1 23470 2006-01-01 07:04:00 +15 16.2345 20000015 0 1 23471 2006-01-01 07:04:00 +16 17.2345 20000016 0 1 23472 2006-01-01 07:04:00 +17 18.2345 20000017 0 1 23473 2006-01-01 07:04:00 +18 19.2345 20000018 0 1 23474 2006-01-01 07:04:00 +19 20.2345 20000019 0 1 23475 2006-01-01 07:04:00 +20 21.2345 20000020 0 1 23476 2006-01-01 07:04:00 +ALTER TABLE test.t1 ADD a9 DATETIME, ADD a10 TINYTEXT, ADD a11 MEDIUMTEXT, ADD a12 LONGTEXT, ADD a13 TEXT, ADD a14 BLOB; +SHOW CREATE TABLE test.t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a1` int(11) NOT NULL, + `a2` float DEFAULT NULL, + `a3` double DEFAULT NULL, + `a4` bit(1) DEFAULT NULL, + `a5` tinyint(4) DEFAULT NULL, + `a6` bigint(20) DEFAULT NULL, + `a7` date DEFAULT NULL, + `a8` time DEFAULT NULL, + `a9` datetime DEFAULT NULL, + `a10` tinytext, + `a11` mediumtext, + `a12` longtext, + `a13` text, + `a14` blob, + PRIMARY KEY (`a1`) +) /*!50100 TABLESPACE ts STORAGE DISK */ ENGINE=ndbcluster DEFAULT CHARSET=latin1 +a1 Int PRIMARY KEY DISTRIBUTION KEY AT=FIXED ST=MEMORY +a2 Float NULL AT=FIXED ST=DISK +a3 Double NULL AT=FIXED ST=DISK +a4 Bit(1) NULL AT=FIXED ST=DISK +a5 Tinyint NULL AT=FIXED ST=DISK +a6 Bigint NULL AT=FIXED ST=DISK +a7 Date NULL AT=FIXED ST=DISK +a8 Time NULL AT=FIXED ST=DISK +a9 Datetime NULL AT=FIXED ST=DISK +a10 Text(256,0;0;latin1_swedish_ci) NULL AT=FIXED ST=MEMORY +a11 Text(256,4000;8;latin1_swedish_ci) NULL AT=FIXED ST=MEMORY +a12 Text(256,8000;4;latin1_swedish_ci) NULL AT=FIXED ST=MEMORY +a13 Text(256,2000;16;latin1_swedish_ci) NULL AT=FIXED ST=MEMORY +a14 Blob(256,2000;16) NULL AT=FIXED ST=MEMORY +SELECT a1, a2,a3,hex(a4),a5,a6,a7,a8,a9,a10,a11,a12,a13 FROM test.t1 ORDER BY a1; +a1 a2 a3 hex(a4) a5 a6 a7 a8 a9 a10 a11 a12 a13 +1 2.2345 20000001 0 1 23457 2006-01-01 07:04:00 1971-05-28 16:55:03 abc abcdefg LLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLL Text Field +2 3.2345 20000002 0 1 23458 2006-01-01 07:04:00 1971-05-28 16:55:03 abc abcdefg LLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLL Text Field +3 4.2345 20000003 0 1 23459 2006-01-01 07:04:00 1971-05-28 16:55:03 abc abcdefg LLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLL Text Field +4 5.2345 20000004 0 1 23460 2006-01-01 07:04:00 1971-05-28 16:55:03 abc abcdefg LLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLL Text Field +5 6.2345 20000005 0 1 23461 2006-01-01 07:04:00 1971-05-28 16:55:03 abc abcdefg LLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLL Text Field +6 7.2345 20000006 0 1 23462 2006-01-01 07:04:00 1971-05-28 16:55:03 abc abcdefg LLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLL Text Field +7 8.2345 20000007 0 1 23463 2006-01-01 07:04:00 1971-05-28 16:55:03 abc abcdefg LLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLL Text Field +8 9.2345 20000008 0 1 23464 2006-01-01 07:04:00 1971-05-28 16:55:03 abc abcdefg LLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLL Text Field +9 10.2345 20000009 0 1 23465 2006-01-01 07:04:00 1971-05-28 16:55:03 abc abcdefg LLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLL Text Field +10 11.2345 20000010 0 1 23466 2006-01-01 07:04:00 1971-05-28 16:55:03 abc abcdefg LLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLL Text Field +11 12.2345 20000011 0 1 23467 2006-01-01 07:04:00 1971-05-28 16:55:03 abc abcdefg LLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLL Text Field +12 13.2345 20000012 0 1 23468 2006-01-01 07:04:00 1971-05-28 16:55:03 abc abcdefg LLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLL Text Field +13 14.2345 20000013 0 1 23469 2006-01-01 07:04:00 1971-05-28 16:55:03 abc abcdefg LLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLL Text Field +14 15.2345 20000014 0 1 23470 2006-01-01 07:04:00 1971-05-28 16:55:03 abc abcdefg LLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLL Text Field +15 16.2345 20000015 0 1 23471 2006-01-01 07:04:00 1971-05-28 16:55:03 abc abcdefg LLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLL Text Field +16 17.2345 20000016 0 1 23472 2006-01-01 07:04:00 1971-05-28 16:55:03 abc abcdefg LLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLL Text Field +17 18.2345 20000017 0 1 23473 2006-01-01 07:04:00 1971-05-28 16:55:03 abc abcdefg LLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLL Text Field +18 19.2345 20000018 0 1 23474 2006-01-01 07:04:00 1971-05-28 16:55:03 abc abcdefg LLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLL Text Field +19 20.2345 20000019 0 1 23475 2006-01-01 07:04:00 1971-05-28 16:55:03 abc abcdefg LLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLL Text Field +20 21.2345 20000020 0 1 23476 2006-01-01 07:04:00 1971-05-28 16:55:03 abc abcdefg LLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLL Text Field +ALTER TABLE test.t1 ADD INDEX a2_i (a2), ADD INDEX a3_i (a3); +SHOW CREATE TABLE test.t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a1` int(11) NOT NULL, + `a2` float DEFAULT NULL, + `a3` double DEFAULT NULL, + `a4` bit(1) DEFAULT NULL, + `a5` tinyint(4) DEFAULT NULL, + `a6` bigint(20) DEFAULT NULL, + `a7` date DEFAULT NULL, + `a8` time DEFAULT NULL, + `a9` datetime DEFAULT NULL, + `a10` tinytext, + `a11` mediumtext, + `a12` longtext, + `a13` text, + `a14` blob, + PRIMARY KEY (`a1`), + KEY `a2_i` (`a2`), + KEY `a3_i` (`a3`) +) /*!50100 TABLESPACE ts STORAGE DISK */ ENGINE=ndbcluster DEFAULT CHARSET=latin1 +a1 Int PRIMARY KEY DISTRIBUTION KEY AT=FIXED ST=MEMORY +a2 Float NULL AT=FIXED ST=MEMORY +a3 Double NULL AT=FIXED ST=MEMORY +a4 Bit(1) NULL AT=FIXED ST=DISK +a5 Tinyint NULL AT=FIXED ST=DISK +a6 Bigint NULL AT=FIXED ST=DISK +a7 Date NULL AT=FIXED ST=DISK +a8 Time NULL AT=FIXED ST=DISK +a9 Datetime NULL AT=FIXED ST=DISK +a10 Text(256,0;0;latin1_swedish_ci) NULL AT=FIXED ST=MEMORY +a11 Text(256,4000;8;latin1_swedish_ci) NULL AT=FIXED ST=MEMORY +a12 Text(256,8000;4;latin1_swedish_ci) NULL AT=FIXED ST=MEMORY +a13 Text(256,2000;16;latin1_swedish_ci) NULL AT=FIXED ST=MEMORY +a14 Blob(256,2000;16) NULL AT=FIXED ST=MEMORY +ALTER TABLE test.t1 DROP INDEX a2_i; +SHOW CREATE TABLE test.t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a1` int(11) NOT NULL, + `a2` float DEFAULT NULL, + `a3` double DEFAULT NULL, + `a4` bit(1) DEFAULT NULL, + `a5` tinyint(4) DEFAULT NULL, + `a6` bigint(20) DEFAULT NULL, + `a7` date DEFAULT NULL, + `a8` time DEFAULT NULL, + `a9` datetime DEFAULT NULL, + `a10` tinytext, + `a11` mediumtext, + `a12` longtext, + `a13` text, + `a14` blob, + PRIMARY KEY (`a1`), + KEY `a3_i` (`a3`) +) /*!50100 TABLESPACE ts STORAGE DISK */ ENGINE=ndbcluster DEFAULT CHARSET=latin1 +a1 Int PRIMARY KEY DISTRIBUTION KEY AT=FIXED ST=MEMORY +a2 Float NULL AT=FIXED ST=DISK +a3 Double NULL AT=FIXED ST=MEMORY +a4 Bit(1) NULL AT=FIXED ST=DISK +a5 Tinyint NULL AT=FIXED ST=DISK +a6 Bigint NULL AT=FIXED ST=DISK +a7 Date NULL AT=FIXED ST=DISK +a8 Time NULL AT=FIXED ST=DISK +a9 Datetime NULL AT=FIXED ST=DISK +a10 Text(256,0;0;latin1_swedish_ci) NULL AT=FIXED ST=MEMORY +a11 Text(256,4000;8;latin1_swedish_ci) NULL AT=FIXED ST=MEMORY +a12 Text(256,8000;4;latin1_swedish_ci) NULL AT=FIXED ST=MEMORY +a13 Text(256,2000;16;latin1_swedish_ci) NULL AT=FIXED ST=MEMORY +a14 Blob(256,2000;16) NULL AT=FIXED ST=MEMORY +TRUNCATE TABLE test.t1; +SHOW CREATE TABLE test.t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a1` int(11) NOT NULL, + `a2` float DEFAULT NULL, + `a3` double DEFAULT NULL, + `a4` bit(1) DEFAULT NULL, + `a5` tinyint(4) DEFAULT NULL, + `a6` bigint(20) DEFAULT NULL, + `a7` date DEFAULT NULL, + `a8` time DEFAULT NULL, + `a9` datetime DEFAULT NULL, + `a10` tinytext, + `a11` mediumtext, + `a12` longtext, + `a13` text, + `a14` blob, + PRIMARY KEY (`a1`), + KEY `a3_i` (`a3`) +) /*!50100 TABLESPACE ts STORAGE DISK */ ENGINE=ndbcluster DEFAULT CHARSET=latin1 +a1 Int PRIMARY KEY DISTRIBUTION KEY AT=FIXED ST=MEMORY +a2 Float NULL AT=FIXED ST=DISK +a3 Double NULL AT=FIXED ST=MEMORY +a4 Bit(1) NULL AT=FIXED ST=DISK +a5 Tinyint NULL AT=FIXED ST=DISK +a6 Bigint NULL AT=FIXED ST=DISK +a7 Date NULL AT=FIXED ST=DISK +a8 Time NULL AT=FIXED ST=DISK +a9 Datetime NULL AT=FIXED ST=DISK +a10 Text(256,0;0;latin1_swedish_ci) NULL AT=FIXED ST=MEMORY +a11 Text(256,4000;8;latin1_swedish_ci) NULL AT=FIXED ST=MEMORY +a12 Text(256,8000;4;latin1_swedish_ci) NULL AT=FIXED ST=MEMORY +a13 Text(256,2000;16;latin1_swedish_ci) NULL AT=FIXED ST=MEMORY +a14 Blob(256,2000;16) NULL AT=FIXED ST=MEMORY +ALTER TABLE test.t1 DROP a14; +ALTER TABLE test.t1 DROP a13; +ALTER TABLE test.t1 DROP a12; +ALTER TABLE test.t1 DROP a11; +ALTER TABLE test.t1 DROP a10; +ALTER TABLE test.t1 DROP a9; +ALTER TABLE test.t1 DROP a8; +ALTER TABLE test.t1 DROP a7; +ALTER TABLE test.t1 DROP a6; +ALTER TABLE test.t1 DROP PRIMARY KEY; +SHOW CREATE TABLE test.t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a1` int(11) NOT NULL, + `a2` float DEFAULT NULL, + `a3` double DEFAULT NULL, + `a4` bit(1) DEFAULT NULL, + `a5` tinyint(4) DEFAULT NULL, + KEY `a3_i` (`a3`) +) /*!50100 TABLESPACE ts STORAGE DISK */ ENGINE=ndbcluster DEFAULT CHARSET=latin1 +a1 Int NOT NULL AT=FIXED ST=DISK +a2 Float NULL AT=FIXED ST=DISK +a3 Double NULL AT=FIXED ST=MEMORY +a4 Bit(1) NULL AT=FIXED ST=DISK +a5 Tinyint NULL AT=FIXED ST=DISK +$PK Bigunsigned PRIMARY KEY DISTRIBUTION KEY AT=FIXED ST=MEMORY +DROP TABLE test.t1; +ALTER TABLESPACE ts +DROP DATAFILE './table_space/datafile.dat' + ENGINE NDB; +DROP TABLESPACE ts ENGINE NDB; +DROP LOGFILE GROUP lg ENGINE=NDB; diff --git a/mysql-test/suite/ndb/r/ndb_dd_backuprestore.result b/mysql-test/suite/ndb/r/ndb_dd_backuprestore.result new file mode 100644 index 00000000000..c82fe560121 --- /dev/null +++ b/mysql-test/suite/ndb/r/ndb_dd_backuprestore.result @@ -0,0 +1,487 @@ +DROP TABLE IF EXISTS test.t1; +DROP TABLE IF EXISTS test.t2; +DROP TABLE IF EXISTS test.t3; +DROP TABLE IF EXISTS test.t4; +DROP TABLE IF EXISTS test.t5; +DROP TABLE IF EXISTS test.t6; +**** Test 1 Simple DD backup and restore **** +CREATE LOGFILE GROUP log_group1 +ADD UNDOFILE './log_group1/undofile.dat' +INITIAL_SIZE 16M +UNDO_BUFFER_SIZE = 1M +ENGINE=NDB; +CREATE TABLESPACE table_space1 +ADD DATAFILE './table_space1/datafile.dat' +USE LOGFILE GROUP log_group1 +INITIAL_SIZE 12M +ENGINE NDB; +CREATE TABLE test.t1 +(pk1 MEDIUMINT NOT NULL AUTO_INCREMENT PRIMARY KEY, c2 CHAR(50) NOT NULL, c3 INT NOT NULL, c4 BIT NOT NULL) TABLESPACE table_space1 STORAGE DISK ENGINE=NDB; +SELECT COUNT(*) FROM test.t1; +COUNT(*) +500 +SELECT pk1, c2, c3, hex(c4) FROM test.t1 ORDER BY pk1 LIMIT 5; +pk1 c2 c3 hex(c4) +1 Sweden 500 1 +2 Sweden 499 1 +3 Sweden 498 1 +4 Sweden 497 1 +5 Sweden 496 1 +CREATE TEMPORARY TABLE IF NOT EXISTS test.backup_info (id INT, backup_id INT) ENGINE = HEAP; +DELETE FROM test.backup_info; +LOAD DATA INFILE '../tmp.dat' INTO TABLE test.backup_info FIELDS TERMINATED BY ','; +SELECT @the_backup_id:=backup_id FROM test.backup_info; +@the_backup_id:=backup_id +<the_backup_id> +DROP TABLE test.backup_info; +DROP TABLE test.t1; +ALTER TABLESPACE table_space1 +DROP DATAFILE './table_space1/datafile.dat' +ENGINE = NDB; +DROP TABLESPACE table_space1 +ENGINE = NDB; +DROP LOGFILE GROUP log_group1 +ENGINE =NDB; +SELECT COUNT(*) FROM test.t1; +COUNT(*) +500 +SELECT pk1, c2, c3, hex(c4) FROM test.t1 ORDER BY pk1 LIMIT 5; +pk1 c2 c3 hex(c4) +1 Sweden 500 1 +2 Sweden 499 1 +3 Sweden 498 1 +4 Sweden 497 1 +5 Sweden 496 1 +**** Test 2 Mixed Cluster Test backup and restore **** +CREATE TABLE test.t2 +(pk1 MEDIUMINT NOT NULL AUTO_INCREMENT PRIMARY KEY, c2 VARCHAR(200) NOT NULL, c3 INT NOT NULL, c4 BIT NOT NULL)ENGINE=NDB; +CREATE TABLE test.t3 (c1 int not null auto_increment, data LONGBLOB, PRIMARY KEY(c1))TABLESPACE table_space1 STORAGE DISK ENGINE=NDB; +CREATE TABLE test.t4 (c1 int not null auto_increment, data LONGBLOB, PRIMARY KEY(c1))ENGINE=NDB; +SELECT COUNT(*) FROM test.t1; +COUNT(*) +500 +SELECT pk1, c2, c3, hex(c4) FROM test.t1 ORDER BY pk1 LIMIT 5; +pk1 c2 c3 hex(c4) +1 Sweden 500 1 +2 Sweden 499 1 +3 Sweden 498 1 +4 Sweden 497 1 +5 Sweden 496 1 +SELECT COUNT(*) FROM test.t2; +COUNT(*) +500 +SELECT pk1, c2, c3, hex(c4) FROM test.t2 ORDER BY pk1 LIMIT 5; +pk1 c2 c3 hex(c4) +1 Sweden, Texas 500 0 +2 Sweden, Texas 499 0 +3 Sweden, Texas 498 0 +4 Sweden, Texas 497 0 +5 Sweden, Texas 496 0 +SELECT COUNT(*) FROM test.t3; +COUNT(*) +100 +SELECT LENGTH(data) FROM test.t3 WHERE c1 = 1; +LENGTH(data) +1024 +SELECT LENGTH(data) FROM test.t3 WHERE c1 = 2; +LENGTH(data) +16384 +SELECT COUNT(*) FROM test.t4; +COUNT(*) +100 +SELECT LENGTH(data) FROM test.t4 WHERE c1 = 1; +LENGTH(data) +1024 +SELECT LENGTH(data) FROM test.t4 WHERE c1 = 2; +LENGTH(data) +16384 +CREATE TEMPORARY TABLE IF NOT EXISTS test.backup_info (id INT, backup_id INT) ENGINE = HEAP; +DELETE FROM test.backup_info; +LOAD DATA INFILE '../tmp.dat' INTO TABLE test.backup_info FIELDS TERMINATED BY ','; +SELECT @the_backup_id:=backup_id FROM test.backup_info; +@the_backup_id:=backup_id +<the_backup_id> +DROP TABLE test.backup_info; +DROP TABLE test.t1; +DROP TABLE test.t2; +DROP TABLE test.t3; +DROP TABLE test.t4; +ALTER TABLESPACE table_space1 +DROP DATAFILE './table_space1/datafile.dat' +ENGINE = NDB; +DROP TABLESPACE table_space1 +ENGINE = NDB; +DROP LOGFILE GROUP log_group1 +ENGINE =NDB; +SELECT COUNT(*) FROM test.t1; +COUNT(*) +500 +SELECT pk1, c2, c3, hex(c4) FROM test.t1 ORDER BY pk1 LIMIT 5; +pk1 c2 c3 hex(c4) +1 Sweden 500 1 +2 Sweden 499 1 +3 Sweden 498 1 +4 Sweden 497 1 +5 Sweden 496 1 +SELECT COUNT(*) FROM test.t2; +COUNT(*) +500 +SELECT pk1, c2, c3, hex(c4) FROM test.t2 ORDER BY pk1 LIMIT 5; +pk1 c2 c3 hex(c4) +1 Sweden, Texas 500 0 +2 Sweden, Texas 499 0 +3 Sweden, Texas 498 0 +4 Sweden, Texas 497 0 +5 Sweden, Texas 496 0 +SELECT COUNT(*) FROM test.t3; +COUNT(*) +100 +SELECT LENGTH(data) FROM test.t3 WHERE c1 = 1; +LENGTH(data) +1024 +SELECT LENGTH(data) FROM test.t3 WHERE c1 = 2; +LENGTH(data) +16384 +SELECT COUNT(*) FROM test.t4; +COUNT(*) +100 +SELECT LENGTH(data) FROM test.t4 WHERE c1 = 1; +LENGTH(data) +1024 +SELECT LENGTH(data) FROM test.t4 WHERE c1 = 2; +LENGTH(data) +16384 +DROP TABLE test.t1; +DROP TABLE test.t2; +DROP TABLE test.t3; +DROP TABLE test.t4; +**** Test 3 Adding partition Test backup and restore **** +CREATE TABLESPACE table_space2 +ADD DATAFILE './table_space2/datafile.dat' +USE LOGFILE GROUP log_group1 +INITIAL_SIZE 12M +ENGINE NDB; +CREATE TABLE test.t1 (pk1 MEDIUMINT NOT NULL AUTO_INCREMENT, c2 VARCHAR(150) NOT NULL, c3 INT NOT NULL, c4 BIT NOT NULL, PRIMARY KEY(pk1,c3))TABLESPACE table_space1 STORAGE DISK ENGINE=NDB PARTITION BY HASH(c3) PARTITIONS 4; +CREATE TABLE test.t4 (pk1 MEDIUMINT NOT NULL AUTO_INCREMENT, c2 VARCHAR(180) NOT NULL, c3 INT NOT NULL, c4 BIT NOT NULL, PRIMARY KEY(pk1,c3))ENGINE=NDB PARTITION BY HASH(c3) PARTITIONS 2; +CREATE TABLE test.t2 (pk1 MEDIUMINT NOT NULL AUTO_INCREMENT, c2 TEXT NOT NULL, c3 INT NOT NULL, c4 BIT NOT NULL, PRIMARY KEY(pk1,c3))TABLESPACE table_space2 STORAGE DISK ENGINE=NDB PARTITION BY KEY(c3) (PARTITION p0 ENGINE = NDB, PARTITION p1 ENGINE = NDB); +CREATE TABLE test.t5 (pk1 MEDIUMINT NOT NULL AUTO_INCREMENT, c2 TEXT NOT NULL, c3 INT NOT NULL, c4 BIT NOT NULL, PRIMARY KEY(pk1,c3))ENGINE=NDB PARTITION BY KEY(pk1) (PARTITION p0 ENGINE = NDB, PARTITION p1 ENGINE = NDB); +CREATE TABLE test.t3 (pk1 MEDIUMINT NOT NULL AUTO_INCREMENT, c2 VARCHAR(202) NOT NULL, c3 INT NOT NULL, c4 BIT NOT NULL, PRIMARY KEY(pk1,c3))TABLESPACE table_space2 STORAGE DISK ENGINE=NDB PARTITION BY RANGE (c3) PARTITIONS 3 (PARTITION x1 VALUES LESS THAN (105), PARTITION x2 VALUES LESS THAN (333), PARTITION x3 VALUES LESS THAN (720)); +CREATE TABLE test.t6 (pk1 MEDIUMINT NOT NULL AUTO_INCREMENT, c2 VARCHAR(220) NOT NULL, c3 INT NOT NULL, c4 BIT NOT NULL, PRIMARY KEY(pk1,c3))ENGINE=NDB PARTITION BY RANGE (pk1) PARTITIONS 2 (PARTITION x1 VALUES LESS THAN (333), PARTITION x2 VALUES LESS THAN (720)); +SHOW CREATE TABLE test.t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `pk1` mediumint(9) NOT NULL AUTO_INCREMENT, + `c2` varchar(150) NOT NULL, + `c3` int(11) NOT NULL, + `c4` bit(1) NOT NULL, + PRIMARY KEY (`pk1`,`c3`) +) /*!50100 TABLESPACE table_space1 STORAGE DISK */ ENGINE=ndbcluster DEFAULT CHARSET=latin1 /*!50100 PARTITION BY HASH (c3) PARTITIONS 4 */ +SHOW CREATE TABLE test.t2; +Table Create Table +t2 CREATE TABLE `t2` ( + `pk1` mediumint(9) NOT NULL AUTO_INCREMENT, + `c2` text NOT NULL, + `c3` int(11) NOT NULL, + `c4` bit(1) NOT NULL, + PRIMARY KEY (`pk1`,`c3`) +) /*!50100 TABLESPACE table_space2 STORAGE DISK */ ENGINE=ndbcluster DEFAULT CHARSET=latin1 /*!50100 PARTITION BY KEY (c3) (PARTITION p0 ENGINE = ndbcluster, PARTITION p1 ENGINE = ndbcluster) */ +SHOW CREATE TABLE test.t3; +Table Create Table +t3 CREATE TABLE `t3` ( + `pk1` mediumint(9) NOT NULL AUTO_INCREMENT, + `c2` varchar(202) NOT NULL, + `c3` int(11) NOT NULL, + `c4` bit(1) NOT NULL, + PRIMARY KEY (`pk1`,`c3`) +) /*!50100 TABLESPACE table_space2 STORAGE DISK */ ENGINE=ndbcluster DEFAULT CHARSET=latin1 /*!50100 PARTITION BY RANGE (c3) (PARTITION x1 VALUES LESS THAN (105) ENGINE = ndbcluster, PARTITION x2 VALUES LESS THAN (333) ENGINE = ndbcluster, PARTITION x3 VALUES LESS THAN (720) ENGINE = ndbcluster) */ +SHOW CREATE TABLE test.t4; +Table Create Table +t4 CREATE TABLE `t4` ( + `pk1` mediumint(9) NOT NULL AUTO_INCREMENT, + `c2` varchar(180) NOT NULL, + `c3` int(11) NOT NULL, + `c4` bit(1) NOT NULL, + PRIMARY KEY (`pk1`,`c3`) +) ENGINE=ndbcluster DEFAULT CHARSET=latin1 /*!50100 PARTITION BY HASH (c3) PARTITIONS 2 */ +SHOW CREATE TABLE test.t5; +Table Create Table +t5 CREATE TABLE `t5` ( + `pk1` mediumint(9) NOT NULL AUTO_INCREMENT, + `c2` text NOT NULL, + `c3` int(11) NOT NULL, + `c4` bit(1) NOT NULL, + PRIMARY KEY (`pk1`,`c3`) +) ENGINE=ndbcluster DEFAULT CHARSET=latin1 /*!50100 PARTITION BY KEY (pk1) (PARTITION p0 ENGINE = ndbcluster, PARTITION p1 ENGINE = ndbcluster) */ +SHOW CREATE TABLE test.t6; +Table Create Table +t6 CREATE TABLE `t6` ( + `pk1` mediumint(9) NOT NULL AUTO_INCREMENT, + `c2` varchar(220) NOT NULL, + `c3` int(11) NOT NULL, + `c4` bit(1) NOT NULL, + PRIMARY KEY (`pk1`,`c3`) +) ENGINE=ndbcluster DEFAULT CHARSET=latin1 /*!50100 PARTITION BY RANGE (pk1) (PARTITION x1 VALUES LESS THAN (333) ENGINE = ndbcluster, PARTITION x2 VALUES LESS THAN (720) ENGINE = ndbcluster) */ +SELECT * FROM information_schema.partitions WHERE table_name= 't1'; +TABLE_CATALOG TABLE_SCHEMA TABLE_NAME PARTITION_NAME SUBPARTITION_NAME PARTITION_ORDINAL_POSITION SUBPARTITION_ORDINAL_POSITION PARTITION_METHOD SUBPARTITION_METHOD PARTITION_EXPRESSION SUBPARTITION_EXPRESSION PARTITION_DESCRIPTION TABLE_ROWS AVG_ROW_LENGTH DATA_LENGTH MAX_DATA_LENGTH INDEX_LENGTH DATA_FREE CREATE_TIME UPDATE_TIME CHECK_TIME CHECKSUM PARTITION_COMMENT NODEGROUP TABLESPACE_NAME +NULL test t1 p0 NULL 1 NULL HASH NULL c3 NULL NULL 0 0 0 NULL 0 0 NULL NULL NULL NULL default table_space1 +NULL test t1 p1 NULL 2 NULL HASH NULL c3 NULL NULL 0 0 0 NULL 0 0 NULL NULL NULL NULL default table_space1 +NULL test t1 p2 NULL 3 NULL HASH NULL c3 NULL NULL 0 0 0 NULL 0 0 NULL NULL NULL NULL default table_space1 +NULL test t1 p3 NULL 4 NULL HASH NULL c3 NULL NULL 0 0 0 NULL 0 0 NULL NULL NULL NULL default table_space1 +SELECT * FROM information_schema.partitions WHERE table_name= 't2'; +TABLE_CATALOG TABLE_SCHEMA TABLE_NAME PARTITION_NAME SUBPARTITION_NAME PARTITION_ORDINAL_POSITION SUBPARTITION_ORDINAL_POSITION PARTITION_METHOD SUBPARTITION_METHOD PARTITION_EXPRESSION SUBPARTITION_EXPRESSION PARTITION_DESCRIPTION TABLE_ROWS AVG_ROW_LENGTH DATA_LENGTH MAX_DATA_LENGTH INDEX_LENGTH DATA_FREE CREATE_TIME UPDATE_TIME CHECK_TIME CHECKSUM PARTITION_COMMENT NODEGROUP TABLESPACE_NAME +NULL test t2 p0 NULL 1 NULL KEY NULL c3 NULL NULL 0 0 0 NULL 0 0 NULL NULL NULL NULL default table_space2 +NULL test t2 p1 NULL 2 NULL KEY NULL c3 NULL NULL 0 0 0 NULL 0 0 NULL NULL NULL NULL default table_space2 +SELECT * FROM information_schema.partitions WHERE table_name= 't3'; +TABLE_CATALOG TABLE_SCHEMA TABLE_NAME PARTITION_NAME SUBPARTITION_NAME PARTITION_ORDINAL_POSITION SUBPARTITION_ORDINAL_POSITION PARTITION_METHOD SUBPARTITION_METHOD PARTITION_EXPRESSION SUBPARTITION_EXPRESSION PARTITION_DESCRIPTION TABLE_ROWS AVG_ROW_LENGTH DATA_LENGTH MAX_DATA_LENGTH INDEX_LENGTH DATA_FREE CREATE_TIME UPDATE_TIME CHECK_TIME CHECKSUM PARTITION_COMMENT NODEGROUP TABLESPACE_NAME +NULL test t3 x1 NULL 1 NULL RANGE NULL c3 NULL 105 0 0 0 NULL 0 0 NULL NULL NULL NULL default table_space2 +NULL test t3 x2 NULL 2 NULL RANGE NULL c3 NULL 333 0 0 0 NULL 0 0 NULL NULL NULL NULL default table_space2 +NULL test t3 x3 NULL 3 NULL RANGE NULL c3 NULL 720 0 0 0 NULL 0 0 NULL NULL NULL NULL default table_space2 +SELECT * FROM information_schema.partitions WHERE table_name= 't4'; +TABLE_CATALOG TABLE_SCHEMA TABLE_NAME PARTITION_NAME SUBPARTITION_NAME PARTITION_ORDINAL_POSITION SUBPARTITION_ORDINAL_POSITION PARTITION_METHOD SUBPARTITION_METHOD PARTITION_EXPRESSION SUBPARTITION_EXPRESSION PARTITION_DESCRIPTION TABLE_ROWS AVG_ROW_LENGTH DATA_LENGTH MAX_DATA_LENGTH INDEX_LENGTH DATA_FREE CREATE_TIME UPDATE_TIME CHECK_TIME CHECKSUM PARTITION_COMMENT NODEGROUP TABLESPACE_NAME +NULL test t4 p0 NULL 1 NULL HASH NULL c3 NULL NULL 0 0 0 NULL 0 0 NULL NULL NULL NULL default NULL +NULL test t4 p1 NULL 2 NULL HASH NULL c3 NULL NULL 0 0 0 NULL 0 0 NULL NULL NULL NULL default NULL +SELECT * FROM information_schema.partitions WHERE table_name= 't5'; +TABLE_CATALOG TABLE_SCHEMA TABLE_NAME PARTITION_NAME SUBPARTITION_NAME PARTITION_ORDINAL_POSITION SUBPARTITION_ORDINAL_POSITION PARTITION_METHOD SUBPARTITION_METHOD PARTITION_EXPRESSION SUBPARTITION_EXPRESSION PARTITION_DESCRIPTION TABLE_ROWS AVG_ROW_LENGTH DATA_LENGTH MAX_DATA_LENGTH INDEX_LENGTH DATA_FREE CREATE_TIME UPDATE_TIME CHECK_TIME CHECKSUM PARTITION_COMMENT NODEGROUP TABLESPACE_NAME +NULL test t5 p0 NULL 1 NULL KEY NULL pk1 NULL NULL 0 0 0 NULL 0 0 NULL NULL NULL NULL default NULL +NULL test t5 p1 NULL 2 NULL KEY NULL pk1 NULL NULL 0 0 0 NULL 0 0 NULL NULL NULL NULL default NULL +SELECT * FROM information_schema.partitions WHERE table_name= 't6'; +TABLE_CATALOG TABLE_SCHEMA TABLE_NAME PARTITION_NAME SUBPARTITION_NAME PARTITION_ORDINAL_POSITION SUBPARTITION_ORDINAL_POSITION PARTITION_METHOD SUBPARTITION_METHOD PARTITION_EXPRESSION SUBPARTITION_EXPRESSION PARTITION_DESCRIPTION TABLE_ROWS AVG_ROW_LENGTH DATA_LENGTH MAX_DATA_LENGTH INDEX_LENGTH DATA_FREE CREATE_TIME UPDATE_TIME CHECK_TIME CHECKSUM PARTITION_COMMENT NODEGROUP TABLESPACE_NAME +NULL test t6 x1 NULL 1 NULL RANGE NULL pk1 NULL 333 0 0 0 NULL 0 0 NULL NULL NULL NULL default NULL +NULL test t6 x2 NULL 2 NULL RANGE NULL pk1 NULL 720 0 0 0 NULL 0 0 NULL NULL NULL NULL default NULL +SELECT COUNT(*) FROM test.t1; +COUNT(*) +250 +SELECT pk1, c2, c3, hex(c4) FROM test.t1 ORDER BY c3 LIMIT 5; +pk1 c2 c3 hex(c4) +250 Sweden, Texas 2 0 +249 Sweden, Texas 4 0 +248 Sweden, Texas 6 0 +247 Sweden, Texas 8 0 +246 Sweden, Texas 10 0 +SELECT COUNT(*) FROM test.t2; +COUNT(*) +250 +SELECT pk1, c2, c3, hex(c4) FROM test.t2 ORDER BY c3 LIMIT 5; +pk1 c2 c3 hex(c4) +250 Sweden, Texas, ITALY, Kyle, JO, JBM,TU 1 1 +249 Sweden, Texas, ITALY, Kyle, JO, JBM,TU 3 1 +248 Sweden, Texas, ITALY, Kyle, JO, JBM,TU 5 1 +247 Sweden, Texas, ITALY, Kyle, JO, JBM,TU 7 1 +246 Sweden, Texas, ITALY, Kyle, JO, JBM,TU 9 1 +SELECT COUNT(*) FROM test.t3; +COUNT(*) +250 +SELECT pk1, c2, c3, hex(c4) FROM test.t3 ORDER BY c3 LIMIT 5; +pk1 c2 c3 hex(c4) +250 TEXASTEXASTEXASTEXASTEXASTEXASTEXASTEXASTEXASTEXAS, ITALY, Kyle, JO, JBM,TU 0 1 +249 TEXASTEXASTEXASTEXASTEXASTEXASTEXASTEXASTEXASTEXAS, ITALY, Kyle, JO, JBM,TU 2 1 +248 TEXASTEXASTEXASTEXASTEXASTEXASTEXASTEXASTEXASTEXAS, ITALY, Kyle, JO, JBM,TU 4 1 +247 TEXASTEXASTEXASTEXASTEXASTEXASTEXASTEXASTEXASTEXAS, ITALY, Kyle, JO, JBM,TU 6 1 +246 TEXASTEXASTEXASTEXASTEXASTEXASTEXASTEXASTEXASTEXAS, ITALY, Kyle, JO, JBM,TU 8 1 +SELECT COUNT(*) FROM test.t4; +COUNT(*) +250 +SELECT pk1, c2, c3, hex(c4) FROM test.t4 ORDER BY c3 LIMIT 5; +pk1 c2 c3 hex(c4) +250 Sweden, Texas 2 0 +249 Sweden, Texas 4 0 +248 Sweden, Texas 6 0 +247 Sweden, Texas 8 0 +246 Sweden, Texas 10 0 +SELECT COUNT(*) FROM test.t5; +COUNT(*) +250 +SELECT pk1, c2, c3, hex(c4) FROM test.t5 ORDER BY c3 LIMIT 5; +pk1 c2 c3 hex(c4) +250 Sweden, Texas, ITALY, Kyle, JO, JBM,TU 1 1 +249 Sweden, Texas, ITALY, Kyle, JO, JBM,TU 3 1 +248 Sweden, Texas, ITALY, Kyle, JO, JBM,TU 5 1 +247 Sweden, Texas, ITALY, Kyle, JO, JBM,TU 7 1 +246 Sweden, Texas, ITALY, Kyle, JO, JBM,TU 9 1 +SELECT COUNT(*) FROM test.t6; +COUNT(*) +250 +SELECT pk1, c2, c3, hex(c4) FROM test.t6 ORDER BY c3 LIMIT 5; +pk1 c2 c3 hex(c4) +250 TEXASTEXASTEXASTEXASTEXASTEXASTEXASTEXASTEXASTEXAS, ITALY, Kyle, JO, JBM,TU 0 1 +249 TEXASTEXASTEXASTEXASTEXASTEXASTEXASTEXASTEXASTEXAS, ITALY, Kyle, JO, JBM,TU 2 1 +248 TEXASTEXASTEXASTEXASTEXASTEXASTEXASTEXASTEXASTEXAS, ITALY, Kyle, JO, JBM,TU 4 1 +247 TEXASTEXASTEXASTEXASTEXASTEXASTEXASTEXASTEXASTEXAS, ITALY, Kyle, JO, JBM,TU 6 1 +246 TEXASTEXASTEXASTEXASTEXASTEXASTEXASTEXASTEXASTEXAS, ITALY, Kyle, JO, JBM,TU 8 1 +CREATE TEMPORARY TABLE IF NOT EXISTS test.backup_info (id INT, backup_id INT) ENGINE = HEAP; +DELETE FROM test.backup_info; +LOAD DATA INFILE '../tmp.dat' INTO TABLE test.backup_info FIELDS TERMINATED BY ','; +SELECT @the_backup_id:=backup_id FROM test.backup_info; +@the_backup_id:=backup_id +<the_backup_id> +DROP TABLE test.backup_info; +DROP TABLE test.t1; +DROP TABLE test.t2; +DROP TABLE test.t3; +DROP TABLE test.t4; +DROP TABLE test.t5; +DROP TABLE test.t6; +ALTER TABLESPACE table_space1 +DROP DATAFILE './table_space1/datafile.dat' +ENGINE = NDB; +ALTER TABLESPACE table_space2 +DROP DATAFILE './table_space2/datafile.dat' +ENGINE = NDB; +DROP TABLESPACE table_space1 +ENGINE = NDB; +DROP TABLESPACE table_space2 +ENGINE = NDB; +DROP LOGFILE GROUP log_group1 +ENGINE =NDB; +SHOW CREATE TABLE test.t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `pk1` mediumint(9) NOT NULL AUTO_INCREMENT, + `c2` varchar(150) NOT NULL, + `c3` int(11) NOT NULL, + `c4` bit(1) NOT NULL, + PRIMARY KEY (`pk1`,`c3`) +) /*!50100 TABLESPACE table_space1 STORAGE DISK */ ENGINE=ndbcluster DEFAULT CHARSET=latin1 /*!50100 PARTITION BY HASH (c3) PARTITIONS 4 */ +SHOW CREATE TABLE test.t2; +Table Create Table +t2 CREATE TABLE `t2` ( + `pk1` mediumint(9) NOT NULL AUTO_INCREMENT, + `c2` text NOT NULL, + `c3` int(11) NOT NULL, + `c4` bit(1) NOT NULL, + PRIMARY KEY (`pk1`,`c3`) +) /*!50100 TABLESPACE table_space2 STORAGE DISK */ ENGINE=ndbcluster DEFAULT CHARSET=latin1 /*!50100 PARTITION BY KEY (c3) (PARTITION p0 ENGINE = ndbcluster, PARTITION p1 ENGINE = ndbcluster) */ +SHOW CREATE TABLE test.t3; +Table Create Table +t3 CREATE TABLE `t3` ( + `pk1` mediumint(9) NOT NULL AUTO_INCREMENT, + `c2` varchar(202) NOT NULL, + `c3` int(11) NOT NULL, + `c4` bit(1) NOT NULL, + PRIMARY KEY (`pk1`,`c3`) +) /*!50100 TABLESPACE table_space2 STORAGE DISK */ ENGINE=ndbcluster DEFAULT CHARSET=latin1 /*!50100 PARTITION BY RANGE (c3) (PARTITION x1 VALUES LESS THAN (105) ENGINE = ndbcluster, PARTITION x2 VALUES LESS THAN (333) ENGINE = ndbcluster, PARTITION x3 VALUES LESS THAN (720) ENGINE = ndbcluster) */ +SHOW CREATE TABLE test.t4; +Table Create Table +t4 CREATE TABLE `t4` ( + `pk1` mediumint(9) NOT NULL AUTO_INCREMENT, + `c2` varchar(180) NOT NULL, + `c3` int(11) NOT NULL, + `c4` bit(1) NOT NULL, + PRIMARY KEY (`pk1`,`c3`) +) ENGINE=ndbcluster DEFAULT CHARSET=latin1 /*!50100 PARTITION BY HASH (c3) PARTITIONS 2 */ +SHOW CREATE TABLE test.t5; +Table Create Table +t5 CREATE TABLE `t5` ( + `pk1` mediumint(9) NOT NULL AUTO_INCREMENT, + `c2` text NOT NULL, + `c3` int(11) NOT NULL, + `c4` bit(1) NOT NULL, + PRIMARY KEY (`pk1`,`c3`) +) ENGINE=ndbcluster DEFAULT CHARSET=latin1 /*!50100 PARTITION BY KEY (pk1) (PARTITION p0 ENGINE = ndbcluster, PARTITION p1 ENGINE = ndbcluster) */ +SHOW CREATE TABLE test.t6; +Table Create Table +t6 CREATE TABLE `t6` ( + `pk1` mediumint(9) NOT NULL AUTO_INCREMENT, + `c2` varchar(220) NOT NULL, + `c3` int(11) NOT NULL, + `c4` bit(1) NOT NULL, + PRIMARY KEY (`pk1`,`c3`) +) ENGINE=ndbcluster DEFAULT CHARSET=latin1 /*!50100 PARTITION BY RANGE (pk1) (PARTITION x1 VALUES LESS THAN (333) ENGINE = ndbcluster, PARTITION x2 VALUES LESS THAN (720) ENGINE = ndbcluster) */ +SELECT * FROM information_schema.partitions WHERE table_name= 't1'; +TABLE_CATALOG TABLE_SCHEMA TABLE_NAME PARTITION_NAME SUBPARTITION_NAME PARTITION_ORDINAL_POSITION SUBPARTITION_ORDINAL_POSITION PARTITION_METHOD SUBPARTITION_METHOD PARTITION_EXPRESSION SUBPARTITION_EXPRESSION PARTITION_DESCRIPTION TABLE_ROWS AVG_ROW_LENGTH DATA_LENGTH MAX_DATA_LENGTH INDEX_LENGTH DATA_FREE CREATE_TIME UPDATE_TIME CHECK_TIME CHECKSUM PARTITION_COMMENT NODEGROUP TABLESPACE_NAME +NULL test t1 p0 NULL 1 NULL HASH NULL c3 NULL NULL 0 0 0 NULL 0 0 NULL NULL NULL NULL default table_space1 +NULL test t1 p1 NULL 2 NULL HASH NULL c3 NULL NULL 0 0 0 NULL 0 0 NULL NULL NULL NULL default table_space1 +NULL test t1 p2 NULL 3 NULL HASH NULL c3 NULL NULL 0 0 0 NULL 0 0 NULL NULL NULL NULL default table_space1 +NULL test t1 p3 NULL 4 NULL HASH NULL c3 NULL NULL 0 0 0 NULL 0 0 NULL NULL NULL NULL default table_space1 +SELECT * FROM information_schema.partitions WHERE table_name= 't2'; +TABLE_CATALOG TABLE_SCHEMA TABLE_NAME PARTITION_NAME SUBPARTITION_NAME PARTITION_ORDINAL_POSITION SUBPARTITION_ORDINAL_POSITION PARTITION_METHOD SUBPARTITION_METHOD PARTITION_EXPRESSION SUBPARTITION_EXPRESSION PARTITION_DESCRIPTION TABLE_ROWS AVG_ROW_LENGTH DATA_LENGTH MAX_DATA_LENGTH INDEX_LENGTH DATA_FREE CREATE_TIME UPDATE_TIME CHECK_TIME CHECKSUM PARTITION_COMMENT NODEGROUP TABLESPACE_NAME +NULL test t2 p0 NULL 1 NULL KEY NULL c3 NULL NULL 0 0 0 NULL 0 0 NULL NULL NULL NULL default table_space2 +NULL test t2 p1 NULL 2 NULL KEY NULL c3 NULL NULL 0 0 0 NULL 0 0 NULL NULL NULL NULL default table_space2 +SELECT * FROM information_schema.partitions WHERE table_name= 't3'; +TABLE_CATALOG TABLE_SCHEMA TABLE_NAME PARTITION_NAME SUBPARTITION_NAME PARTITION_ORDINAL_POSITION SUBPARTITION_ORDINAL_POSITION PARTITION_METHOD SUBPARTITION_METHOD PARTITION_EXPRESSION SUBPARTITION_EXPRESSION PARTITION_DESCRIPTION TABLE_ROWS AVG_ROW_LENGTH DATA_LENGTH MAX_DATA_LENGTH INDEX_LENGTH DATA_FREE CREATE_TIME UPDATE_TIME CHECK_TIME CHECKSUM PARTITION_COMMENT NODEGROUP TABLESPACE_NAME +NULL test t3 x1 NULL 1 NULL RANGE NULL c3 NULL 105 0 0 0 NULL 0 0 NULL NULL NULL NULL default table_space2 +NULL test t3 x2 NULL 2 NULL RANGE NULL c3 NULL 333 0 0 0 NULL 0 0 NULL NULL NULL NULL default table_space2 +NULL test t3 x3 NULL 3 NULL RANGE NULL c3 NULL 720 0 0 0 NULL 0 0 NULL NULL NULL NULL default table_space2 +SELECT * FROM information_schema.partitions WHERE table_name= 't4'; +TABLE_CATALOG TABLE_SCHEMA TABLE_NAME PARTITION_NAME SUBPARTITION_NAME PARTITION_ORDINAL_POSITION SUBPARTITION_ORDINAL_POSITION PARTITION_METHOD SUBPARTITION_METHOD PARTITION_EXPRESSION SUBPARTITION_EXPRESSION PARTITION_DESCRIPTION TABLE_ROWS AVG_ROW_LENGTH DATA_LENGTH MAX_DATA_LENGTH INDEX_LENGTH DATA_FREE CREATE_TIME UPDATE_TIME CHECK_TIME CHECKSUM PARTITION_COMMENT NODEGROUP TABLESPACE_NAME +NULL test t4 p0 NULL 1 NULL HASH NULL c3 NULL NULL 0 0 0 NULL 0 0 NULL NULL NULL NULL default NULL +NULL test t4 p1 NULL 2 NULL HASH NULL c3 NULL NULL 0 0 0 NULL 0 0 NULL NULL NULL NULL default NULL +SELECT * FROM information_schema.partitions WHERE table_name= 't5'; +TABLE_CATALOG TABLE_SCHEMA TABLE_NAME PARTITION_NAME SUBPARTITION_NAME PARTITION_ORDINAL_POSITION SUBPARTITION_ORDINAL_POSITION PARTITION_METHOD SUBPARTITION_METHOD PARTITION_EXPRESSION SUBPARTITION_EXPRESSION PARTITION_DESCRIPTION TABLE_ROWS AVG_ROW_LENGTH DATA_LENGTH MAX_DATA_LENGTH INDEX_LENGTH DATA_FREE CREATE_TIME UPDATE_TIME CHECK_TIME CHECKSUM PARTITION_COMMENT NODEGROUP TABLESPACE_NAME +NULL test t5 p0 NULL 1 NULL KEY NULL pk1 NULL NULL 0 0 0 NULL 0 0 NULL NULL NULL NULL default NULL +NULL test t5 p1 NULL 2 NULL KEY NULL pk1 NULL NULL 0 0 0 NULL 0 0 NULL NULL NULL NULL default NULL +SELECT * FROM information_schema.partitions WHERE table_name= 't6'; +TABLE_CATALOG TABLE_SCHEMA TABLE_NAME PARTITION_NAME SUBPARTITION_NAME PARTITION_ORDINAL_POSITION SUBPARTITION_ORDINAL_POSITION PARTITION_METHOD SUBPARTITION_METHOD PARTITION_EXPRESSION SUBPARTITION_EXPRESSION PARTITION_DESCRIPTION TABLE_ROWS AVG_ROW_LENGTH DATA_LENGTH MAX_DATA_LENGTH INDEX_LENGTH DATA_FREE CREATE_TIME UPDATE_TIME CHECK_TIME CHECKSUM PARTITION_COMMENT NODEGROUP TABLESPACE_NAME +NULL test t6 x1 NULL 1 NULL RANGE NULL pk1 NULL 333 0 0 0 NULL 0 0 NULL NULL NULL NULL default NULL +NULL test t6 x2 NULL 2 NULL RANGE NULL pk1 NULL 720 0 0 0 NULL 0 0 NULL NULL NULL NULL default NULL +SELECT COUNT(*) FROM test.t1; +COUNT(*) +250 +SELECT pk1, c2, c3, hex(c4) FROM test.t1 ORDER BY c3 LIMIT 5; +pk1 c2 c3 hex(c4) +250 Sweden, Texas 2 0 +249 Sweden, Texas 4 0 +248 Sweden, Texas 6 0 +247 Sweden, Texas 8 0 +246 Sweden, Texas 10 0 +SELECT COUNT(*) FROM test.t2; +COUNT(*) +250 +SELECT pk1, c2, c3, hex(c4) FROM test.t2 ORDER BY c3 LIMIT 5; +pk1 c2 c3 hex(c4) +250 Sweden, Texas, ITALY, Kyle, JO, JBM,TU 1 1 +249 Sweden, Texas, ITALY, Kyle, JO, JBM,TU 3 1 +248 Sweden, Texas, ITALY, Kyle, JO, JBM,TU 5 1 +247 Sweden, Texas, ITALY, Kyle, JO, JBM,TU 7 1 +246 Sweden, Texas, ITALY, Kyle, JO, JBM,TU 9 1 +SELECT COUNT(*) FROM test.t3; +COUNT(*) +250 +SELECT pk1, c2, c3, hex(c4) FROM test.t3 ORDER BY c3 LIMIT 5; +pk1 c2 c3 hex(c4) +250 TEXASTEXASTEXASTEXASTEXASTEXASTEXASTEXASTEXASTEXAS, ITALY, Kyle, JO, JBM,TU 0 1 +249 TEXASTEXASTEXASTEXASTEXASTEXASTEXASTEXASTEXASTEXAS, ITALY, Kyle, JO, JBM,TU 2 1 +248 TEXASTEXASTEXASTEXASTEXASTEXASTEXASTEXASTEXASTEXAS, ITALY, Kyle, JO, JBM,TU 4 1 +247 TEXASTEXASTEXASTEXASTEXASTEXASTEXASTEXASTEXASTEXAS, ITALY, Kyle, JO, JBM,TU 6 1 +246 TEXASTEXASTEXASTEXASTEXASTEXASTEXASTEXASTEXASTEXAS, ITALY, Kyle, JO, JBM,TU 8 1 +SELECT COUNT(*) FROM test.t4; +COUNT(*) +250 +SELECT pk1, c2, c3, hex(c4) FROM test.t4 ORDER BY c3 LIMIT 5; +pk1 c2 c3 hex(c4) +250 Sweden, Texas 2 0 +249 Sweden, Texas 4 0 +248 Sweden, Texas 6 0 +247 Sweden, Texas 8 0 +246 Sweden, Texas 10 0 +SELECT COUNT(*) FROM test.t5; +COUNT(*) +250 +SELECT pk1, c2, c3, hex(c4) FROM test.t5 ORDER BY c3 LIMIT 5; +pk1 c2 c3 hex(c4) +250 Sweden, Texas, ITALY, Kyle, JO, JBM,TU 1 1 +249 Sweden, Texas, ITALY, Kyle, JO, JBM,TU 3 1 +248 Sweden, Texas, ITALY, Kyle, JO, JBM,TU 5 1 +247 Sweden, Texas, ITALY, Kyle, JO, JBM,TU 7 1 +246 Sweden, Texas, ITALY, Kyle, JO, JBM,TU 9 1 +SELECT COUNT(*) FROM test.t6; +COUNT(*) +250 +SELECT pk1, c2, c3, hex(c4) FROM test.t6 ORDER BY c3 LIMIT 5; +pk1 c2 c3 hex(c4) +250 TEXASTEXASTEXASTEXASTEXASTEXASTEXASTEXASTEXASTEXAS, ITALY, Kyle, JO, JBM,TU 0 1 +249 TEXASTEXASTEXASTEXASTEXASTEXASTEXASTEXASTEXASTEXAS, ITALY, Kyle, JO, JBM,TU 2 1 +248 TEXASTEXASTEXASTEXASTEXASTEXASTEXASTEXASTEXASTEXAS, ITALY, Kyle, JO, JBM,TU 4 1 +247 TEXASTEXASTEXASTEXASTEXASTEXASTEXASTEXASTEXASTEXAS, ITALY, Kyle, JO, JBM,TU 6 1 +246 TEXASTEXASTEXASTEXASTEXASTEXASTEXASTEXASTEXASTEXAS, ITALY, Kyle, JO, JBM,TU 8 1 +DROP TABLE test.t1; +DROP TABLE test.t2; +DROP TABLE test.t3; +DROP TABLE test.t4; +DROP TABLE test.t5; +DROP TABLE test.t6; +ALTER TABLESPACE table_space1 DROP DATAFILE './table_space1/datafile.dat' ENGINE=NDB; +ALTER TABLESPACE table_space2 DROP DATAFILE './table_space2/datafile.dat' ENGINE=NDB; +DROP TABLESPACE table_space1 ENGINE = NDB; +DROP TABLESPACE table_space2 ENGINE = NDB; +DROP LOGFILE GROUP log_group1 ENGINE = NDB; diff --git a/mysql-test/suite/ndb/r/ndb_dd_basic.result b/mysql-test/suite/ndb/r/ndb_dd_basic.result new file mode 100644 index 00000000000..bc1762ce407 --- /dev/null +++ b/mysql-test/suite/ndb/r/ndb_dd_basic.result @@ -0,0 +1,510 @@ +DROP TABLE IF EXISTS t1; +CREATE LOGFILE GROUP lg1 +ADD UNDOFILE 'undofile.dat' +INITIAL_SIZE 16M +UNDO_BUFFER_SIZE = 1M +ENGINE=MYISAM; +Warnings: +Error 1475 Table storage engine 'MyISAM' does not support the create option 'TABLESPACE or LOGFILE GROUP' +ALTER LOGFILE GROUP lg1 +ADD UNDOFILE 'undofile02.dat' +INITIAL_SIZE = 4M +ENGINE=XYZ; +Warnings: +Warning 1286 Unknown table engine 'XYZ' +Error 1475 Table storage engine 'MyISAM' does not support the create option 'TABLESPACE or LOGFILE GROUP' +CREATE TABLESPACE ts1 +ADD DATAFILE 'datafile.dat' +USE LOGFILE GROUP lg1 +INITIAL_SIZE 12M; +Warnings: +Error 1475 Table storage engine 'MyISAM' does not support the create option 'TABLESPACE or LOGFILE GROUP' +set storage_engine=ndb; +CREATE LOGFILE GROUP lg1 +ADD UNDOFILE 'undofile.dat' +INITIAL_SIZE 16M +UNDO_BUFFER_SIZE = 1M; +ALTER LOGFILE GROUP lg1 +ADD UNDOFILE 'undofile02.dat' +INITIAL_SIZE = 4M +ENGINE=NDB; +set storage_engine=myisam; +CREATE TABLESPACE ts1 +ADD DATAFILE 'datafile.dat' +USE LOGFILE GROUP lg1 +INITIAL_SIZE 12M +ENGINE NDB; +ALTER TABLESPACE ts1 +ADD DATAFILE 'datafile02.dat' +INITIAL_SIZE = 4M +ENGINE=NDB; +CREATE TABLE t1 +(pk1 INT NOT NULL PRIMARY KEY, b INT NOT NULL, c INT NOT NULL) +TABLESPACE ts1 STORAGE DISK +ENGINE=NDB; +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `pk1` int(11) NOT NULL, + `b` int(11) NOT NULL, + `c` int(11) NOT NULL, + PRIMARY KEY (`pk1`) +) /*!50100 TABLESPACE ts1 STORAGE DISK */ ENGINE=ndbcluster DEFAULT CHARSET=latin1 +INSERT INTO t1 VALUES (0, 0, 0); +SELECT * FROM t1; +pk1 b c +0 0 0 +INSERT INTO t1 VALUES +(1,1,1),(2,2,2),(3,3,3),(4,4,4),(5,5,5), +(6,6,6),(7,7,7),(8,8,8),(9,9,9),(10,10,10), +(11,11,11),(12,12,12),(13,13,13),(14,14,14),(15,15,15), +(16,16,16),(17,17,17),(18,18,18),(19,19,19),(20,20,20), +(21,21,21),(22,22,22),(23,23,23),(24,24,24),(25,25,25), +(26,26,26),(27,27,27),(28,28,28),(29,29,29),(30,30,30), +(31,31,31),(32,32,32),(33,33,33),(34,34,34),(35,35,35), +(36,36,36),(37,37,37),(38,38,38),(39,39,39),(40,40,40), +(41,41,41),(42,42,42),(43,43,43),(44,44,44),(45,45,45), +(46,46,46),(47,47,47),(48,48,48),(49,49,49),(50,50,50), +(51,51,51),(52,52,52),(53,53,53),(54,54,54),(55,55,55), +(56,56,56),(57,57,57),(58,58,58),(59,59,59),(60,60,60), +(61,61,61),(62,62,62),(63,63,63),(64,64,64),(65,65,65), +(66,66,66),(67,67,67),(68,68,68),(69,69,69),(70,70,70), +(71,71,71),(72,72,72),(73,73,73),(74,74,74),(75,75,75), +(76,76,76),(77,77,77),(78,78,78),(79,79,79),(80,80,80), +(81,81,81),(82,82,82),(83,83,83),(84,84,84),(85,85,85), +(86,86,86),(87,87,87),(88,88,88),(89,89,89),(90,90,90), +(91,91,91),(92,92,92),(93,93,93),(94,94,94),(95,95,95), +(96,96,96),(97,97,97),(98,98,98),(99,99,99),(100,100,100), +(101,101,101),(102,102,102),(103,103,103),(104,104,104),(105,105,105), +(106,106,106),(107,107,107),(108,108,108),(109,109,109),(110,110,110), +(111,111,111),(112,112,112),(113,113,113),(114,114,114),(115,115,115), +(116,116,116),(117,117,117),(118,118,118),(119,119,119),(120,120,120), +(121,121,121),(122,122,122),(123,123,123),(124,124,124),(125,125,125), +(126,126,126),(127,127,127),(128,128,128),(129,129,129),(130,130,130), +(131,131,131),(132,132,132),(133,133,133),(134,134,134),(135,135,135), +(136,136,136),(137,137,137),(138,138,138),(139,139,139),(140,140,140), +(141,141,141),(142,142,142),(143,143,143),(144,144,144),(145,145,145), +(146,146,146),(147,147,147),(148,148,148),(149,149,149),(150,150,150), +(151,151,151),(152,152,152),(153,153,153),(154,154,154),(155,155,155), +(156,156,156),(157,157,157),(158,158,158),(159,159,159),(160,160,160), +(161,161,161),(162,162,162),(163,163,163),(164,164,164),(165,165,165), +(166,166,166),(167,167,167),(168,168,168),(169,169,169),(170,170,170), +(171,171,171),(172,172,172),(173,173,173),(174,174,174),(175,175,175), +(176,176,176),(177,177,177),(178,178,178),(179,179,179),(180,180,180), +(181,181,181),(182,182,182),(183,183,183),(184,184,184),(185,185,185), +(186,186,186),(187,187,187),(188,188,188),(189,189,189),(190,190,190), +(191,191,191),(192,192,192),(193,193,193),(194,194,194),(195,195,195), +(196,196,196),(197,197,197),(198,198,198),(199,199,199),(200,200,200), +(201,201,201),(202,202,202),(203,203,203),(204,204,204),(205,205,205), +(206,206,206),(207,207,207),(208,208,208),(209,209,209),(210,210,210), +(211,211,211),(212,212,212),(213,213,213),(214,214,214),(215,215,215), +(216,216,216),(217,217,217),(218,218,218),(219,219,219),(220,220,220), +(221,221,221),(222,222,222),(223,223,223),(224,224,224),(225,225,225), +(226,226,226),(227,227,227),(228,228,228),(229,229,229),(230,230,230), +(231,231,231),(232,232,232),(233,233,233),(234,234,234),(235,235,235), +(236,236,236),(237,237,237),(238,238,238),(239,239,239),(240,240,240), +(241,241,241),(242,242,242),(243,243,243),(244,244,244),(245,245,245), +(246,246,246),(247,247,247),(248,248,248),(249,249,249),(250,250,250), +(251,251,251),(252,252,252),(253,253,253),(254,254,254),(255,255,255), +(256,256,256),(257,257,257),(258,258,258),(259,259,259),(260,260,260), +(261,261,261),(262,262,262),(263,263,263),(264,264,264),(265,265,265), +(266,266,266),(267,267,267),(268,268,268),(269,269,269),(270,270,270), +(271,271,271),(272,272,272),(273,273,273),(274,274,274),(275,275,275), +(276,276,276),(277,277,277),(278,278,278),(279,279,279),(280,280,280), +(281,281,281),(282,282,282),(283,283,283),(284,284,284),(285,285,285), +(286,286,286),(287,287,287),(288,288,288),(289,289,289),(290,290,290), +(291,291,291),(292,292,292),(293,293,293),(294,294,294),(295,295,295), +(296,296,296),(297,297,297),(298,298,298),(299,299,299),(300,300,300), +(301,301,301),(302,302,302),(303,303,303),(304,304,304),(305,305,305), +(306,306,306),(307,307,307),(308,308,308),(309,309,309),(310,310,310), +(311,311,311),(312,312,312),(313,313,313),(314,314,314),(315,315,315), +(316,316,316),(317,317,317),(318,318,318),(319,319,319),(320,320,320), +(321,321,321),(322,322,322),(323,323,323),(324,324,324),(325,325,325), +(326,326,326),(327,327,327),(328,328,328),(329,329,329),(330,330,330), +(331,331,331),(332,332,332),(333,333,333),(334,334,334),(335,335,335), +(336,336,336),(337,337,337),(338,338,338),(339,339,339),(340,340,340), +(341,341,341),(342,342,342),(343,343,343),(344,344,344),(345,345,345), +(346,346,346),(347,347,347),(348,348,348),(349,349,349),(350,350,350), +(351,351,351),(352,352,352),(353,353,353),(354,354,354),(355,355,355), +(356,356,356),(357,357,357),(358,358,358),(359,359,359),(360,360,360), +(361,361,361),(362,362,362),(363,363,363),(364,364,364),(365,365,365), +(366,366,366),(367,367,367),(368,368,368),(369,369,369),(370,370,370), +(371,371,371),(372,372,372),(373,373,373),(374,374,374),(375,375,375), +(376,376,376),(377,377,377),(378,378,378),(379,379,379),(380,380,380), +(381,381,381),(382,382,382),(383,383,383),(384,384,384),(385,385,385), +(386,386,386),(387,387,387),(388,388,388),(389,389,389),(390,390,390), +(391,391,391),(392,392,392),(393,393,393),(394,394,394),(395,395,395), +(396,396,396),(397,397,397),(398,398,398),(399,399,399),(400,400,400), +(401,401,401),(402,402,402),(403,403,403),(404,404,404),(405,405,405), +(406,406,406),(407,407,407),(408,408,408),(409,409,409),(410,410,410), +(411,411,411),(412,412,412),(413,413,413),(414,414,414),(415,415,415), +(416,416,416),(417,417,417),(418,418,418),(419,419,419),(420,420,420), +(421,421,421),(422,422,422),(423,423,423),(424,424,424),(425,425,425), +(426,426,426),(427,427,427),(428,428,428),(429,429,429),(430,430,430), +(431,431,431),(432,432,432),(433,433,433),(434,434,434),(435,435,435), +(436,436,436),(437,437,437),(438,438,438),(439,439,439),(440,440,440), +(441,441,441),(442,442,442),(443,443,443),(444,444,444),(445,445,445), +(446,446,446),(447,447,447),(448,448,448),(449,449,449),(450,450,450), +(451,451,451),(452,452,452),(453,453,453),(454,454,454),(455,455,455), +(456,456,456),(457,457,457),(458,458,458),(459,459,459),(460,460,460), +(461,461,461),(462,462,462),(463,463,463),(464,464,464),(465,465,465), +(466,466,466),(467,467,467),(468,468,468),(469,469,469),(470,470,470), +(471,471,471),(472,472,472),(473,473,473),(474,474,474),(475,475,475), +(476,476,476),(477,477,477),(478,478,478),(479,479,479),(480,480,480), +(481,481,481),(482,482,482),(483,483,483),(484,484,484),(485,485,485), +(486,486,486),(487,487,487),(488,488,488),(489,489,489),(490,490,490), +(491,491,491),(492,492,492),(493,493,493),(494,494,494),(495,495,495), +(496,496,496),(497,497,497),(498,498,498),(499,499,499),(500, 500, 500); +SELECT COUNT(*) FROM t1; +COUNT(*) +501 +CREATE LOGFILE GROUP lg2 +ADD UNDOFILE 'x.dat' +INITIAL_SIZE 10y +ENGINE = NDB; +ERROR HY000: A size parameter was incorrectly specified, either number or on the form 10M +CREATE LOGFILE GROUP lg2 +ADD UNDOFILE 'x.dat' +INITIAL_SIZE 10MB +ENGINE = NDB; +ERROR HY000: A size parameter was incorrectly specified, either number or on the form 10M +CREATE LOGFILE GROUP lg2 +ADD UNDOFILE 'x.dat' +INITIAL_SIZE 10 MB +ENGINE = NDB; +ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'MB +ENGINE = NDB' at line 3 +CREATE LOGFILE GROUP lg2 +ADD UNDOFILE 'x.dat' +INITIAL_SIZE 10 M +ENGINE = NDB; +ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'M +ENGINE = NDB' at line 3 +CREATE LOGFILE GROUP lg2 +ADD UNDOFILE 'x.dat' +INITIAL_SIZE 1000000000000K +ENGINE = NDB; +ERROR HY000: The size number was correct but we don't allow the digit part to be more than 2 billion +DROP TABLE t1; +create tablespace ts2 +add datafile 'datafile2_1.dat' +use logfile group lg1 +initial_size 12M +engine ndb; +CREATE TABLE City ( +ID int(11) NOT NULL AUTO_INCREMENT, +Name char(35) NOT NULL, +CountryCode char(3) NOT NULL, +District char(20) NOT NULL, +Population int(11) NOT NULL, +PRIMARY KEY (ID) +) ENGINE=ndbcluster +tablespace ts2 +storage disk; +alter tablespace ts2 +drop datafile 'datafile2_1.dat' +engine ndb; +insert +into City (Name,CountryCode,District,Population) +values ('BeiJing','CN','Beijing',2000); +ERROR HY000: Got error 1602 'No datafile in tablespace' from NDBCLUSTER +drop tablespace ts2 +engine ndb; +ERROR HY000: Failed to drop TABLESPACE +drop table City; +drop tablespace ts2 +engine ndb; +CREATE TABLE t1 (a INT PRIMARY KEY, b CHAR(4) NOT NULL, c CHAR(4) NOT NULL, KEY(b)) TABLESPACE ts1 STORAGE DISK ENGINE = NDB; +INSERT INTO t1 VALUES (1,'1','1'), (2,'2','2'), (3,'3','3'); +BEGIN; +UPDATE t1 SET b = '2' WHERE a = 1; +SELECT b FROM t1 WHERE a = 1; +b +2 +SELECT * FROM t1 WHERE a = 1; +a b c +1 2 1 +UPDATE t1 SET c = '2' WHERE a = 1; +SELECT b FROM t1 WHERE a = 1; +b +2 +SELECT * FROM t1 WHERE a = 1; +a b c +1 2 2 +UPDATE t1 SET b = '3' WHERE a = 1; +SELECT b FROM t1 WHERE a = 1; +b +3 +SELECT * FROM t1 WHERE a = 1; +a b c +1 3 2 +COMMIT; +SELECT * FROM t1 ORDER BY 1; +a b c +1 3 2 +2 2 2 +3 3 3 +BEGIN; +UPDATE t1 SET c = '3' WHERE a = 1; +SELECT b FROM t1 WHERE a = 1; +b +3 +SELECT * FROM t1 WHERE a = 1; +a b c +1 3 3 +UPDATE t1 SET b = '4' WHERE a = 1; +SELECT b FROM t1 WHERE a = 1; +b +4 +SELECT * FROM t1 WHERE a = 1; +a b c +1 4 3 +UPDATE t1 SET c = '4' WHERE a = 1; +SELECT b FROM t1 WHERE a = 1; +b +4 +SELECT * FROM t1 WHERE a = 1; +a b c +1 4 4 +COMMIT; +SELECT * FROM t1 ORDER BY 1; +a b c +1 4 4 +2 2 2 +3 3 3 +UPDATE t1 SET b = '5' WHERE a = 1; +SELECT * FROM t1 ORDER BY 1; +a b c +1 5 4 +2 2 2 +3 3 3 +UPDATE t1 SET b = '6' WHERE b = '5'; +SELECT * FROM t1 ORDER BY 1; +a b c +1 6 4 +2 2 2 +3 3 3 +UPDATE t1 SET b = '7'WHERE c = '4'; +SELECT * FROM t1 ORDER BY 1; +a b c +1 7 4 +2 2 2 +3 3 3 +UPDATE t1 SET c = '5' WHERE a = 1; +SELECT * FROM t1 ORDER BY 1; +a b c +1 7 5 +2 2 2 +3 3 3 +UPDATE t1 SET c = '6' WHERE b = '7'; +SELECT * FROM t1 ORDER BY 1; +a b c +1 7 6 +2 2 2 +3 3 3 +UPDATE t1 SET c = '7' WHERE c = '6'; +SELECT * FROM t1 ORDER BY 1; +a b c +1 7 7 +2 2 2 +3 3 3 +DROP TABLE t1; +CREATE TABLE t1 (a INT PRIMARY KEY, b VARCHAR(4) NOT NULL, c CHAR(4) NOT NULL, KEY(b)) TABLESPACE ts1 STORAGE DISK ENGINE NDB; +INSERT INTO t1 VALUE (1,'1','1'), (2,'2','2'), (3,'3','3'); +BEGIN; +UPDATE t1 SET b = '2' WHERE a = 1; +SELECT b FROM t1 WHERE a = 1; +b +2 +SELECT * FROM t1 WHERE a = 1; +a b c +1 2 1 +UPDATE t1 SET c = '2' WHERE a = 1; +SELECT b FROM t1 WHERE a = 1; +b +2 +SELECT * FROM t1 WHERE a = 1; +a b c +1 2 2 +UPDATE t1 SET b = '3' WHERE a = 1; +SELECT b FROM t1 WHERE a = 1; +b +3 +SELECT * FROM t1 WHERE a = 1; +a b c +1 3 2 +COMMIT; +SELECT * FROM t1 ORDER BY 1; +a b c +1 3 2 +2 2 2 +3 3 3 +BEGIN; +UPDATE t1 SET c = '3' WHERE a = 1; +SELECT b FROM t1 WHERE a = 1; +b +3 +SELECT * FROM t1 WHERE a = 1; +a b c +1 3 3 +UPDATE t1 SET b = '4' WHERE a = 1; +SELECT b FROM t1 WHERE a = 1; +b +4 +SELECT * FROM t1 WHERE a = 1; +a b c +1 4 3 +UPDATE t1 SET c = '4' WHERE a = 1; +SELECT b FROM t1 WHERE a = 1; +b +4 +SELECT * FROM t1 WHERE a = 1; +a b c +1 4 4 +COMMIT; +SELECT * FROM t1 ORDER BY 1; +a b c +1 4 4 +2 2 2 +3 3 3 +UPDATE t1 SET b = '5' WHERE a = 1; +SELECT * FROM t1 ORDER BY 1; +a b c +1 5 4 +2 2 2 +3 3 3 +UPDATE t1 SET b = '6' WHERE b = '5'; +SELECT * FROM t1 ORDER BY 1; +a b c +1 6 4 +2 2 2 +3 3 3 +UPDATE t1 SET b = '7' WHERE c = '4'; +SELECT * FROM t1 ORDER BY 1; +a b c +1 7 4 +2 2 2 +3 3 3 +UPDATE t1 SET c = '5' WHERE a = 1; +SELECT * FROM t1 ORDER BY 1; +a b c +1 7 5 +2 2 2 +3 3 3 +UPDATE t1 SET c = '6' WHERE b = '7'; +SELECT * FROM t1 ORDER BY 1; +a b c +1 7 6 +2 2 2 +3 3 3 +UPDATE t1 SET c = '7' WHERE c = '6'; +SELECT * FROM t1 ORDER BY 1; +a b c +1 7 7 +2 2 2 +3 3 3 +DROP TABLE t1; +CREATE TABLE t1 ( +a INT NOT NULL PRIMARY KEY, +b TEXT NOT NULL +) TABLESPACE ts1 STORAGE DISK ENGINE=NDBCLUSTER; +set @x0 = '01234567012345670123456701234567'; +set @x0 = concat(@x0,@x0,@x0,@x0,@x0,@x0,@x0,@x0); +set @b1 = 'b1'; +set @b1 = concat(@b1,@b1,@b1,@b1,@b1,@b1,@b1,@b1,@b1,@b1); +set @b1 = concat(@b1,@b1,@b1,@b1,@b1,@b1,@b1,@b1,@b1,@b1); +set @b1 = concat(@b1,@b1,@b1,@b1,@b1,@b1,@b1,@b1,@b1,@b1); +set @b1 = concat(@b1,@x0); +set @b2 = 'b2'; +set @b2 = concat(@b2,@b2,@b2,@b2,@b2,@b2,@b2,@b2,@b2,@b2); +set @b2 = concat(@b2,@b2,@b2,@b2,@b2,@b2,@b2,@b2,@b2,@b2); +set @b2 = concat(@b2,@b2,@b2,@b2,@b2,@b2,@b2,@b2,@b2,@b2); +set @b2 = concat(@b2,@b2,@b2,@b2,@b2,@b2,@b2,@b2,@b2,@b2); +INSERT INTO t1 VALUES(1,@b1); +INSERT INTO t1 VALUES(2,@b2); +SELECT a,length(b),substr(b,1+2*900,2) FROM t1 WHERE a=1; +a length(b) substr(b,1+2*900,2) +1 2256 b1 +SELECT a,length(b),substr(b,1+2*9000,2) FROM t1 WHERE a=2; +a length(b) substr(b,1+2*9000,2) +2 20000 b2 +UPDATE t1 SET b=@b2 WHERE a=1; +UPDATE t1 SET b=@b1 WHERE a=2; +SELECT a,length(b),substr(b,1+2*9000,2) FROM t1 WHERE a=1; +a length(b) substr(b,1+2*9000,2) +1 20000 b2 +SELECT a,length(b),substr(b,1+2*900,2) FROM t1 WHERE a=2; +a length(b) substr(b,1+2*900,2) +2 2256 b1 +UPDATE t1 SET b=concat(b,b) WHERE a=1; +UPDATE t1 SET b=concat(b,b) WHERE a=2; +SELECT a,length(b),substr(b,1+4*9000,2) FROM t1 WHERE a=1; +a length(b) substr(b,1+4*9000,2) +1 40000 b2 +SELECT a,length(b),substr(b,1+4*900,2) FROM t1 WHERE a=2; +a length(b) substr(b,1+4*900,2) +2 4512 b1 +DELETE FROM t1 WHERE a=1; +DELETE FROM t1 WHERE a=2; +SELECT COUNT(*) FROM t1; +COUNT(*) +0 +DROP TABLE t1; +CREATE TABLE t1 ( +a int NOT NULL, +b varchar(4000), -- must use 2 pages undo +PRIMARY KEY using hash (a) +) +TABLESPACE ts1 STORAGE DISK ENGINE=NDBCLUSTER; +set autocommit = 0; +insert into t1 values(0,'x'); +insert into t1 values(1,'x'); +insert into t1 values(2,'x'); +insert into t1 values(3,'x'); +insert into t1 values(4,'x'); +insert into t1 values(5,'x'); +insert into t1 values(6,'x'); +insert into t1 values(7,'x'); +insert into t1 values(8,'x'); +delete from t1 where a = 0; +commit; +delete from t1; +begin; +insert into t1 values (1, 'x'); +select * from t1; +a b +1 x +rollback; +set autocommit = 1; +drop table t1; +create table test.t1 (f1 varchar(50) primary key, f2 text,f3 int) +TABLESPACE ts1 STORAGE DISK engine=NDB; +insert into test.t1 (f1,f2,f3)VALUES("111111","aaaaaa",1); +insert into test.t1 (f1,f2,f3)VALUES("222222","bbbbbb",2); +select * from test.t1 order by f1; +f1 f2 f3 +111111 aaaaaa 1 +222222 bbbbbb 2 +select f1,f2 from test.t1 order by f2; +f1 f2 +111111 aaaaaa +222222 bbbbbb +select f2 from test.t1 order by f2; +f2 +aaaaaa +bbbbbb +select f1,f2 from test.t1 order by f1; +f1 f2 +111111 aaaaaa +222222 bbbbbb +drop table test.t1; +ALTER TABLESPACE ts1 +DROP DATAFILE 'datafile.dat' +ENGINE = NDB; +ALTER TABLESPACE ts1 +DROP DATAFILE 'datafile02.dat' +ENGINE = NDB; +DROP TABLESPACE ts1 +ENGINE = NDB; +DROP LOGFILE GROUP lg1 +ENGINE =NDB; diff --git a/mysql-test/suite/ndb/r/ndb_dd_ddl.result b/mysql-test/suite/ndb/r/ndb_dd_ddl.result new file mode 100644 index 00000000000..55f1f56fd0c --- /dev/null +++ b/mysql-test/suite/ndb/r/ndb_dd_ddl.result @@ -0,0 +1,240 @@ +DROP TABLE IF EXISTS t1; +DROP DATABASE IF EXISTS mysqltest; +CREATE DATABASE mysqltest; +**** Begin Duplicate Statement Testing **** +CREATE LOGFILE GROUP lg1 +ADD UNDOFILE 'undofile.dat' +INITIAL_SIZE 1M +UNDO_BUFFER_SIZE = 1M +ENGINE=NDB; +CREATE LOGFILE GROUP lg2 +ADD UNDOFILE 'undofile2.dat' +INITIAL_SIZE 1M +UNDO_BUFFER_SIZE 1M +ENGINE NDB; +ERROR HY000: Failed to create LOGFILE GROUP +SHOW WARNINGS; +Level Code Message +Error 1296 Got error 1514 'Currently there is a limit of one logfile group' from NDB +Error 1525 Failed to create LOGFILE GROUP +CREATE LOGFILE GROUP lg1 +ADD UNDOFILE 'undofile.dat' +INITIAL_SIZE 1M +UNDO_BUFFER_SIZE = 1M +ENGINE=NDB; +ERROR HY000: Failed to create LOGFILE GROUP +ALTER LOGFILE GROUP lg1 +ADD UNDOFILE 'undofile02.dat' +INITIAL_SIZE 1M ENGINE NDB; +ALTER LOGFILE GROUP lg1 +ADD UNDOFILE 'undofile02.dat' +INITIAL_SIZE 1M ENGINE=NDB; +ERROR HY000: Failed to alter: CREATE UNDOFILE +CREATE TABLESPACE ts1 +ADD DATAFILE 'datafile.dat' +USE LOGFILE GROUP lg1 +INITIAL_SIZE 1M +ENGINE NDB; +CREATE TABLESPACE ts1 +ADD DATAFILE 'datafile.dat' +USE LOGFILE GROUP lg1 +INITIAL_SIZE 1M +ENGINE NDB; +ERROR HY000: Failed to create TABLESPACE +ALTER TABLESPACE ts1 +ADD DATAFILE 'datafile2.dat' +INITIAL_SIZE 1M +ENGINE=NDB; +ALTER TABLESPACE ts1 +ADD DATAFILE 'datafile2.dat' +INITIAL_SIZE 1M +ENGINE=NDB; +ERROR HY000: Failed to alter: CREATE DATAFILE +CREATE TABLE mysqltest.t1 +(pk1 INT NOT NULL PRIMARY KEY, b INT NOT NULL, c INT NOT NULL) +TABLESPACE ts1 STORAGE DISK +ENGINE=NDB; +CREATE TABLE mysqltest.t1 +(pk1 INT NOT NULL PRIMARY KEY, b INT NOT NULL, c INT NOT NULL) +TABLESPACE ts1 STORAGE DISK +ENGINE=NDB; +ERROR 42S01: Table 't1' already exists +CREATE TABLE mysqltest.t1 +(pk1 INT NOT NULL PRIMARY KEY, b INT NOT NULL, c INT NOT NULL) +ENGINE=NDB; +ERROR 42S01: Table 't1' already exists +DROP TABLE mysqltest.t1; +ALTER TABLESPACE ts1 +DROP DATAFILE 'datafile2.dat' +ENGINE=NDB; +ALTER TABLESPACE ts1 +DROP DATAFILE 'datafile2.dat' +ENGINE=NDB; +ERROR HY000: Failed to alter: NO SUCH FILE +ALTER TABLESPACE ts1 +DROP DATAFILE 'datafile.dat' +ENGINE=NDB; +ALTER TABLESPACE ts1 +DROP DATAFILE 'datafile.dat' +ENGINE=NDB; +ERROR HY000: Failed to alter: NO SUCH FILE +DROP TABLESPACE ts1 +ENGINE=NDB; +DROP TABLESPACE ts1 +ENGINE=NDB; +ERROR HY000: Failed to drop TABLESPACE +DROP LOGFILE GROUP lg1 +ENGINE=NDB; +DROP LOGFILE GROUP lg1 +ENGINE=NDB; +ERROR HY000: Failed to drop LOGFILE GROUP +DROP DATABASE IF EXISTS mysqltest; +**** End Duplicate Statement Testing **** + +**** Begin Statment CaSe Testing **** +creaTE LOgfilE GrOuP lg1 +adD undoFILE 'undofile.dat' +initiAL_siZE 1M +UnDo_BuFfEr_SiZe = 1M +ENGInE=NDb; +altER LOgFiLE GrOUp lg1 +AdD UnDOfILe 'uNdOfiLe02.daT' +INItIAl_SIzE 1M ENgINE nDB; +CrEAtE TABLEspaCE ts1 +ADD DATAfilE 'datafile.dat' +UsE LoGFiLE GRoUP lg1 +INITiaL_SizE 1M +ENGiNe NDb; +AlTeR tAbLeSpAcE ts1 +AdD DaTaFiLe 'dAtAfiLe2.daT' +InItIaL_SiZe 1M +EnGiNe=NDB; +CREATE TABLE t1 +(pk1 int not null primary key, b int not null, c int not null) +TABLEspace ts1 storAGE dISk +ENGine nDb; +DROP TABLE t1; +AlteR TAblespaCE ts1 +droP DATAfile 'dAtAfiLe2.daT' +ENGINE=NDB; +ALter tablesPACE ts1 +dROp dAtAfIlE 'datafile.dat' +ENGine=Ndb; +DrOp TaBleSpAcE ts1 +engINE=ndB; +DrOp lOgFiLe GrOuP lg1 +EnGiNe=nDb; +**** End Statment CaSe Testing **** + +**** Begin = And No = Testing **** +CREATE LOGFILE GROUP lg1 +ADD UNDOFILE 'undofile.dat' +INITIAL_SIZE=1M +UNDO_BUFFER_SIZE=1M +ENGINE=NDB; +ALTER LOGFILE GROUP lg1 +ADD UNDOFILE 'undofile02.dat' +INITIAL_SIZE=1M +ENGINE=NDB; +CREATE TABLESPACE ts1 +ADD DATAFILE 'datafile.dat' +USE LOGFILE GROUP lg1 +INITIAL_SIZE=1M +ENGINE=NDB; +ALTER TABLESPACE ts1 +ADD DATAFILE 'datafile2.dat' +INITIAL_SIZE=1M +ENGINE=NDB; +CREATE TABLE t1 +(pk1 INT NOT NULL PRIMARY KEY, b INT NOT NULL, c INT NOT NULL) +TABLESPACE ts1 STORAGE DISK +ENGINE=NDB; +DROP TABLE t1; +ALTER TABLESPACE ts1 +DROP DATAFILE 'datafile2.dat' +ENGINE=NDB; +ALTER TABLESPACE ts1 +DROP DATAFILE 'datafile.dat' +ENGINE=NDB; +DROP TABLESPACE ts1 +ENGINE=NDB; +DROP LOGFILE GROUP lg1 +ENGINE=NDB; + +**** End of = **** + +CREATE LOGFILE GROUP lg1 +ADD UNDOFILE 'undofile.dat' +INITIAL_SIZE 1M +UNDO_BUFFER_SIZE 1M +ENGINE NDB; +ALTER LOGFILE GROUP lg1 +ADD UNDOFILE 'undofile02.dat' +INITIAL_SIZE 1M +ENGINE NDB; +CREATE TABLESPACE ts1 +ADD DATAFILE 'datafile.dat' +USE LOGFILE GROUP lg1 +INITIAL_SIZE 1M +ENGINE NDB; +ALTER TABLESPACE ts1 +ADD DATAFILE 'datafile2.dat' +INITIAL_SIZE 1M +ENGINE NDB; +CREATE TABLE t1 +(pk1 INT NOT NULL PRIMARY KEY, b INT NOT NULL, c INT NOT NULL) +TABLESPACE ts1 STORAGE MEMORY +ENGINE NDB; +ERROR HY000: Can't create table 'test.t1' (errno: 138) +CREATE TABLE t1 +(pk1 INT NOT NULL PRIMARY KEY, b INT NOT NULL, c INT NOT NULL) +TABLESPACE ts1 STORAGE DISK +ENGINE NDB; +CREATE INDEX b_i on t1(b); +CREATE INDEX bc_i on t1(b, c); +DROP TABLE t1; +CREATE TABLESPACE ts2 +ADD DATAFILE 'datafile3.dat' +USE LOGFILE GROUP lg1 +INITIAL_SIZE 1M +ENGINE NDB; +ALTER TABLESPACE ts1 +DROP DATAFILE 'datafile3.dat' +ENGINE NDB; +ERROR HY000: Failed to alter: NO SUCH FILE +ALTER TABLESPACE ts2 +DROP DATAFILE 'datafile2.dat' +ENGINE NDB; +ERROR HY000: Failed to alter: NO SUCH FILE +ALTER TABLESPACE ts1 +DROP DATAFILE 'datafile2.dat' +ENGINE NDB; +ALTER TABLESPACE ts1 +DROP DATAFILE 'datafile.dat' +ENGINE NDB; +DROP TABLESPACE ts1 +ENGINE NDB; +ALTER TABLESPACE ts2 +DROP DATAFILE 'datafile3.dat' +ENGINE NDB; +DROP TABLESPACE ts2 +ENGINE NDB; +DROP LOGFILE GROUP lg1 +ENGINE NDB; +**** End = And No = **** +create table t1 (a int primary key) engine = myisam; +create logfile group lg1 add undofile 'MYSQLTEST_VARDIR/master-data/test/t1.frm' initial_size 1M undo_buffer_size = 1M engine=ndb;; +ERROR HY000: Failed to create UNDOFILE +create logfile group lg1 +add undofile 'undofile.dat' +initial_size 1M +undo_buffer_size = 1M +engine=ndb; +create tablespace ts1 add datafile 'MYSQLTEST_VARDIR/master-data/test/t1.frm' use logfile group lg1 initial_size 1M engine ndb;; +ERROR HY000: Failed to create DATAFILE +drop tablespace ts1 +engine ndb; +ERROR HY000: Failed to drop TABLESPACE +drop logfile group lg1 +engine ndb; +drop table t1; diff --git a/mysql-test/suite/ndb/r/ndb_dd_disk2memory.result b/mysql-test/suite/ndb/r/ndb_dd_disk2memory.result new file mode 100644 index 00000000000..46661f36d1b --- /dev/null +++ b/mysql-test/suite/ndb/r/ndb_dd_disk2memory.result @@ -0,0 +1,505 @@ +DROP TABLE IF EXISTS test.t1; +DROP TABLE IF EXISTS test.t2; +**** Test Setup Section **** +CREATE LOGFILE GROUP log_group1 +ADD UNDOFILE './log_group1/undofile.dat' +INITIAL_SIZE 16M +UNDO_BUFFER_SIZE = 1M +ENGINE=NDB; +CREATE TABLESPACE table_space1 +ADD DATAFILE './table_space1/datafile.dat' +USE LOGFILE GROUP log_group1 +INITIAL_SIZE 12M +ENGINE NDB; +CREATE TABLE test.t1 +(pk1 INT NOT NULL PRIMARY KEY, b INT NOT NULL, c INT NOT NULL) +TABLESPACE table_space1 STORAGE DISK +ENGINE=NDB; +CREATE TABLE test.t2 +(pk2 INT NOT NULL PRIMARY KEY, b2 INT NOT NULL, c2 INT NOT NULL) +ENGINE=NDB; + +**** Data load for first test **** +INSERT INTO test.t1 VALUES +(1,1,1),(2,2,2),(3,3,3),(4,4,4),(5,5,5), +(6,6,6),(7,7,7),(8,8,8),(9,9,9),(10,10,10), +(11,11,11),(12,12,12),(13,13,13),(14,14,14),(15,15,15), +(16,16,16),(17,17,17),(18,18,18),(19,19,19),(20,20,20), +(21,21,21),(22,22,22),(23,23,23),(24,24,24),(25,25,25), +(26,26,26),(27,27,27),(28,28,28),(29,29,29),(30,30,30), +(31,31,31),(32,32,32),(33,33,33),(34,34,34),(35,35,35), +(36,36,36),(37,37,37),(38,38,38),(39,39,39),(40,40,40), +(41,41,41),(42,42,42),(43,43,43),(44,44,44),(45,45,45), +(46,46,46),(47,47,47),(48,48,48),(49,49,49),(50,50,50), +(51,51,51),(52,52,52),(53,53,53),(54,54,54),(55,55,55), +(56,56,56),(57,57,57),(58,58,58),(59,59,59),(60,60,60), +(61,61,61),(62,62,62),(63,63,63),(64,64,64),(65,65,65), +(66,66,66),(67,67,67),(68,68,68),(69,69,69),(70,70,70), +(71,71,71),(72,72,72),(73,73,73),(74,74,74),(75,75,75); +INSERT INTO test.t2 VALUES +(1,1,1),(2,2,2),(3,3,3),(4,4,4),(5,5,5), +(6,6,6),(7,7,7),(8,8,8),(9,9,9),(10,10,10), +(11,11,11),(12,12,12),(13,13,13),(14,14,14),(15,15,15), +(16,16,16),(17,17,17),(18,18,18),(19,19,19),(20,20,20), +(21,21,21),(22,22,22),(23,23,23),(24,24,24),(25,25,25), +(26,26,26),(27,27,27),(28,28,28),(29,29,29),(30,30,30), +(31,31,31),(32,32,32),(33,33,33),(34,34,34),(35,35,35), +(36,36,36),(37,37,37),(38,38,38),(39,39,39),(40,40,40), +(41,41,41),(42,42,42),(43,43,43),(44,44,44),(45,45,45), +(46,46,46),(47,47,47),(48,48,48),(49,49,49),(50,50,50), +(51,51,51),(52,52,52),(53,53,53),(54,54,54),(55,55,55), +(56,56,56),(57,57,57),(58,58,58),(59,59,59),(60,60,60), +(61,61,61),(62,62,62),(63,63,63),(64,64,64),(65,65,65), +(66,66,66),(67,67,67),(68,68,68),(69,69,69),(70,70,70), +(71,71,71),(72,72,72),(73,73,73),(74,74,74),(75,75,75); + +*** Test 1 Section Begins *** +SELECT COUNT(*) FROM test.t2 LEFT JOIN test.t1 ON pk2=pk1 WHERE b2 IN (4); +COUNT(*) +1 +SELECT * FROM test.t2 LEFT JOIN test.t1 ON pk2=pk1 WHERE b2 IN (4); +pk2 b2 c2 pk1 b c +4 4 4 4 4 4 +SELECT COUNT(*) FROM test.t1 LEFT JOIN test.t2 ON pk1=pk2 WHERE b IN (4); +COUNT(*) +1 +SELECT COUNT(*) FROM test.t1 LEFT JOIN test.t2 ON b=b2 WHERE pk1 IN (75); +COUNT(*) +1 +SELECT b, c FROM test.t1 LEFT JOIN test.t2 ON pk1=pk2 ORDER BY b; +b c +1 1 +2 2 +3 3 +4 4 +5 5 +6 6 +7 7 +8 8 +9 9 +10 10 +11 11 +12 12 +13 13 +14 14 +15 15 +16 16 +17 17 +18 18 +19 19 +20 20 +21 21 +22 22 +23 23 +24 24 +25 25 +26 26 +27 27 +28 28 +29 29 +30 30 +31 31 +32 32 +33 33 +34 34 +35 35 +36 36 +37 37 +38 38 +39 39 +40 40 +41 41 +42 42 +43 43 +44 44 +45 45 +46 46 +47 47 +48 48 +49 49 +50 50 +51 51 +52 52 +53 53 +54 54 +55 55 +56 56 +57 57 +58 58 +59 59 +60 60 +61 61 +62 62 +63 63 +64 64 +65 65 +66 66 +67 67 +68 68 +69 69 +70 70 +71 71 +72 72 +73 73 +74 74 +75 75 + +*** Setup for test 2 **** +DELETE FROM test.t1; +INSERT INTO test.t1 VALUES +(1,1,1),(2,2,2),(3,3,3),(4,4,4),(5,5,5), +(6,6,6),(7,7,7),(8,8,8),(9,9,9),(10,10,10), +(11,11,11),(12,12,12),(13,13,13),(14,14,14),(15,15,15), +(16,16,16),(17,17,17),(18,18,18),(19,19,19),(20,20,20), +(21,21,21),(22,22,22),(23,23,23),(24,24,24),(25,25,25), +(26,26,26),(27,27,27),(28,28,28),(29,29,29),(30,30,30), +(31,31,31),(32,32,32),(33,33,33),(34,34,34),(35,35,35), +(36,36,36),(37,37,37),(38,38,38),(39,39,39),(40,40,40), +(41,41,41),(42,42,42),(43,43,43),(44,44,44),(45,45,45); + +**** Test Section 2 **** +SELECT b, c FROM test.t1 LEFT JOIN test.t2 ON pk1=pk2 ORDER BY b; +b c +1 1 +2 2 +3 3 +4 4 +5 5 +6 6 +7 7 +8 8 +9 9 +10 10 +11 11 +12 12 +13 13 +14 14 +15 15 +16 16 +17 17 +18 18 +19 19 +20 20 +21 21 +22 22 +23 23 +24 24 +25 25 +26 26 +27 27 +28 28 +29 29 +30 30 +31 31 +32 32 +33 33 +34 34 +35 35 +36 36 +37 37 +38 38 +39 39 +40 40 +41 41 +42 42 +43 43 +44 44 +45 45 +SELECT COUNT(*) FROM test.t1 LEFT JOIN test.t2 ON b=b2; +COUNT(*) +45 +SELECT COUNT(*) FROM test.t1 RIGHT JOIN test.t2 ON b=b2; +COUNT(*) +75 +SHOW CREATE TABLE test.t2; +Table Create Table +t2 CREATE TABLE `t2` ( + `pk2` int(11) NOT NULL, + `b2` int(11) NOT NULL, + `c2` int(11) NOT NULL, + PRIMARY KEY (`pk2`) +) ENGINE=ndbcluster DEFAULT CHARSET=latin1 +SHOW CREATE TABLE test.t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `pk1` int(11) NOT NULL, + `b` int(11) NOT NULL, + `c` int(11) NOT NULL, + PRIMARY KEY (`pk1`) +) /*!50100 TABLESPACE table_space1 STORAGE DISK */ ENGINE=ndbcluster DEFAULT CHARSET=latin1 +ALTER TABLE test.t2 TABLESPACE table_space1 STORAGE DISK +ENGINE=NDB; +SHOW CREATE TABLE test.t2; +Table Create Table +t2 CREATE TABLE `t2` ( + `pk2` int(11) NOT NULL, + `b2` int(11) NOT NULL, + `c2` int(11) NOT NULL, + PRIMARY KEY (`pk2`) +) /*!50100 TABLESPACE table_space1 STORAGE DISK */ ENGINE=ndbcluster DEFAULT CHARSET=latin1 +ALTER TABLE test.t1 STORAGE MEMORY ENGINE=NDBCLUSTER; +SHOW CREATE TABLE test.t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `pk1` int(11) NOT NULL, + `b` int(11) NOT NULL, + `c` int(11) NOT NULL, + PRIMARY KEY (`pk1`) +) ENGINE=ndbcluster DEFAULT CHARSET=latin1 + +DROP TABLE test.t1; +DROP TABLE test.t2; +*** Setup for Test Section 3 *** +CREATE TABLE test.t1 ( +usr_id INT unsigned NOT NULL, +uniq_id INT unsigned NOT NULL AUTO_INCREMENT, +start_num INT unsigned NOT NULL DEFAULT 1, +increment INT unsigned NOT NULL DEFAULT 1, +PRIMARY KEY (uniq_id), +INDEX usr_uniq_idx (usr_id, uniq_id), +INDEX uniq_usr_idx (uniq_id, usr_id)) +TABLESPACE table_space1 STORAGE DISK +ENGINE=NDB; +CREATE TABLE test.t2 ( +id INT unsigned NOT NULL DEFAULT 0, +usr2_id INT unsigned NOT NULL DEFAULT 0, +max INT unsigned NOT NULL DEFAULT 0, +c_amount INT unsigned NOT NULL DEFAULT 0, +d_max INT unsigned NOT NULL DEFAULT 0, +d_num INT unsigned NOT NULL DEFAULT 0, +orig_time INT unsigned NOT NULL DEFAULT 0, +c_time INT unsigned NOT NULL DEFAULT 0, +active ENUM ("no","yes") NOT NULL, +PRIMARY KEY (id,usr2_id), +INDEX id_idx (id), +INDEX usr2_idx (usr2_id)) +ENGINE=NDB; +INSERT INTO test.t1 VALUES (3,NULL,0,50),(3,NULL,0,200),(3,NULL,0,25),(3,NULL,0,84676),(3,NULL,0,235),(3,NULL,0,10),(3,NULL,0,3098),(3,NULL,0,2947),(3,NULL,0,8987),(3,NULL,0,8347654),(3,NULL,0,20398),(3,NULL,0,8976),(3,NULL,0,500),(3,NULL,0,198); + +**** Test Section 3 **** +SELECT test.t1.usr_id,test.t1.uniq_id,test.t1.increment, +test.t2.usr2_id,test.t2.c_amount,test.t2.max +FROM test.t1 +LEFT JOIN test.t2 ON test.t2.id = test.t1.uniq_id +WHERE test.t1.uniq_id = 4 +ORDER BY test.t2.c_amount; +usr_id uniq_id increment usr2_id c_amount max +3 4 84676 NULL NULL NULL +INSERT INTO test.t2 VALUES (2,3,3000,6000,0,0,746584,837484,'yes'); +INSERT INTO test.t2 VALUES (4,3,3000,6000,0,0,746584,837484,'yes'); +INSERT INTO test.t2 VALUES (7,3,1000,2000,0,0,746294,937484,'yes'); +SELECT test.t1.usr_id,test.t1.uniq_id,test.t1.increment, +test.t2.usr2_id,test.t2.c_amount,test.t2.max +FROM test.t1 +LEFT JOIN test.t2 ON test.t2.id = test.t1.uniq_id +WHERE test.t1.uniq_id = 4 +ORDER BY test.t2.c_amount; +usr_id uniq_id increment usr2_id c_amount max +3 4 84676 3 6000 3000 + +DROP TABLE test.t1; +DROP TABLE test.t2; +CREATE TABLE test.t1 ( +a1 smallint NOT NULL, +a2 int NOT NULL, +a3 bigint NOT NULL, +a4 char(10), +a5 decimal(5,1), +a6 time, +a7 date, +a8 datetime, +a9 VARCHAR(255), +a10 blob, +PRIMARY KEY(a1) +) TABLESPACE table_space1 STORAGE DISK ENGINE=NDB; +CREATE TABLE test.t2 ( +b1 smallint NOT NULL, +b2 int NOT NULL, +b3 bigint NOT NULL, +b4 char(10), +b5 decimal(5,1), +b6 time, +b7 date, +b8 datetime, +b9 VARCHAR(255), +b10 blob, +PRIMARY KEY(b1) +) ENGINE=NDB; +Table Create Table +t1 CREATE TABLE `t1` ( + `a1` smallint(6) NOT NULL, + `a2` int(11) NOT NULL, + `a3` bigint(20) NOT NULL, + `a4` char(10) DEFAULT NULL, + `a5` decimal(5,1) DEFAULT NULL, + `a6` time DEFAULT NULL, + `a7` date DEFAULT NULL, + `a8` datetime DEFAULT NULL, + `a9` varchar(255) DEFAULT NULL, + `a10` blob, + PRIMARY KEY (`a1`), + KEY `a2` (`a2`), + KEY `a3` (`a3`), + KEY `a8` (`a8`) +) /*!50100 TABLESPACE table_space1 STORAGE DISK */ ENGINE=ndbcluster DEFAULT CHARSET=latin1 +Table Create Table +t2 CREATE TABLE `t2` ( + `b1` smallint(6) NOT NULL, + `b2` int(11) NOT NULL, + `b3` bigint(20) NOT NULL, + `b4` char(10) DEFAULT NULL, + `b5` decimal(5,1) DEFAULT NULL, + `b6` time DEFAULT NULL, + `b7` date DEFAULT NULL, + `b8` datetime DEFAULT NULL, + `b9` varchar(255) DEFAULT NULL, + `b10` blob, + PRIMARY KEY (`b1`), + KEY `b2` (`b2`), + KEY `b3` (`b3`), + KEY `b8` (`b8`) +) ENGINE=ndbcluster DEFAULT CHARSET=latin1 +a1 a2 a3 a4 a5 a6 a7 a8 a9 a10 +1 2 2000000001 aaa1 34.2 04:03:02 2006-01-01 1971-05-28 16:55:03 bbbbbbbbbbbbb1 binary data +2 3 2000000002 aaa2 34.2 04:03:02 2006-01-01 1971-05-28 16:55:03 bbbbbbbbbbbbb2 binary data +3 4 2000000003 aaa3 34.2 04:03:02 2006-01-01 1971-05-28 16:55:03 bbbbbbbbbbbbb3 binary data +4 5 2000000004 aaa4 34.2 04:03:02 2006-01-01 1971-05-28 16:55:03 bbbbbbbbbbbbb4 binary data +5 6 2000000005 aaa5 34.2 04:03:02 2006-01-01 1971-05-28 16:55:03 bbbbbbbbbbbbb5 binary data +6 7 2000000006 aaa6 34.2 04:03:02 2006-01-01 1971-05-28 16:55:03 bbbbbbbbbbbbb6 binary data +7 8 2000000007 aaa7 34.2 04:03:02 2006-01-01 1971-05-28 16:55:03 bbbbbbbbbbbbb7 binary data +8 9 2000000008 aaa8 34.2 04:03:02 2006-01-01 1971-05-28 16:55:03 bbbbbbbbbbbbb8 binary data +9 10 2000000009 aaa9 34.2 04:03:02 2006-01-01 1971-05-28 16:55:03 bbbbbbbbbbbbb9 binary data +10 11 2000000010 aaa10 34.2 04:03:02 2006-01-01 1971-05-28 16:55:03 bbbbbbbbbbbbb10 binary data +11 12 2000000011 aaa11 34.2 04:03:02 2006-01-01 1971-05-28 16:55:03 bbbbbbbbbbbbb11 binary data +12 13 2000000012 aaa12 34.2 04:03:02 2006-01-01 1971-05-28 16:55:03 bbbbbbbbbbbbb12 binary data +13 14 2000000013 aaa13 34.2 04:03:02 2006-01-01 1971-05-28 16:55:03 bbbbbbbbbbbbb13 binary data +14 15 2000000014 aaa14 34.2 04:03:02 2006-01-01 1971-05-28 16:55:03 bbbbbbbbbbbbb14 binary data +15 16 2000000015 aaa15 34.2 04:03:02 2006-01-01 1971-05-28 16:55:03 bbbbbbbbbbbbb15 binary data +16 17 2000000016 aaa16 34.2 04:03:02 2006-01-01 1971-05-28 16:55:03 bbbbbbbbbbbbb16 binary data +17 18 2000000017 aaa17 34.2 04:03:02 2006-01-01 1971-05-28 16:55:03 bbbbbbbbbbbbb17 binary data +18 19 2000000018 aaa18 34.2 04:03:02 2006-01-01 1971-05-28 16:55:03 bbbbbbbbbbbbb18 binary data +19 20 2000000019 aaa19 34.2 04:03:02 2006-01-01 1971-05-28 16:55:03 bbbbbbbbbbbbb19 binary data +20 21 2000000020 aaa20 34.2 04:03:02 2006-01-01 1971-05-28 16:55:03 bbbbbbbbbbbbb20 binary data +b1 b2 b3 b4 b5 b6 b7 b8 b9 b10 +3 4 3000000001 aaa1 35.2 04:03:02 2006-01-01 1971-05-28 16:55:03 bbbbbbbbbbbbb1 binary data +4 5 3000000002 aaa2 35.2 04:03:02 2006-01-01 1971-05-28 16:55:03 bbbbbbbbbbbbb2 binary data +5 6 3000000003 aaa3 35.2 04:03:02 2006-01-01 1971-05-28 16:55:03 bbbbbbbbbbbbb3 binary data +6 7 3000000004 aaa4 35.2 04:03:02 2006-01-01 1971-05-28 16:55:03 bbbbbbbbbbbbb4 binary data +7 8 3000000005 aaa5 35.2 04:03:02 2006-01-01 1971-05-28 16:55:03 bbbbbbbbbbbbb5 binary data +8 9 3000000006 aaa6 35.2 04:03:02 2006-01-01 1971-05-28 16:55:03 bbbbbbbbbbbbb6 binary data +9 10 3000000007 aaa7 35.2 04:03:02 2006-01-01 1971-05-28 16:55:03 bbbbbbbbbbbbb7 binary data +10 11 3000000008 aaa8 35.2 04:03:02 2006-01-01 1971-05-28 16:55:03 bbbbbbbbbbbbb8 binary data +11 12 3000000009 aaa9 35.2 04:03:02 2006-01-01 1971-05-28 16:55:03 bbbbbbbbbbbbb9 binary data +12 13 3000000010 aaa10 35.2 04:03:02 2006-01-01 1971-05-28 16:55:03 bbbbbbbbbbbbb10 binary data +13 14 3000000011 aaa11 35.2 04:03:02 2006-01-01 1971-05-28 16:55:03 bbbbbbbbbbbbb11 binary data +14 15 3000000012 aaa12 35.2 04:03:02 2006-01-01 1971-05-28 16:55:03 bbbbbbbbbbbbb12 binary data +15 16 3000000013 aaa13 35.2 04:03:02 2006-01-01 1971-05-28 16:55:03 bbbbbbbbbbbbb13 binary data +16 17 3000000014 aaa14 35.2 04:03:02 2006-01-01 1971-05-28 16:55:03 bbbbbbbbbbbbb14 binary data +17 18 3000000015 aaa15 35.2 04:03:02 2006-01-01 1971-05-28 16:55:03 bbbbbbbbbbbbb15 binary data +18 19 3000000016 aaa16 35.2 04:03:02 2006-01-01 1971-05-28 16:55:03 bbbbbbbbbbbbb16 binary data +19 20 3000000017 aaa17 35.2 04:03:02 2006-01-01 1971-05-28 16:55:03 bbbbbbbbbbbbb17 binary data +20 21 3000000018 aaa18 35.2 04:03:02 2006-01-01 1971-05-28 16:55:03 bbbbbbbbbbbbb18 binary data +21 22 3000000019 aaa19 35.2 04:03:02 2006-01-01 1971-05-28 16:55:03 bbbbbbbbbbbbb19 binary data +22 23 3000000020 aaa20 35.2 04:03:02 2006-01-01 1971-05-28 16:55:03 bbbbbbbbbbbbb20 binary data +COUNT(a1) a1 COUNT(a1)*a1 +1 1 1 +1 2 2 +1 3 3 +1 4 4 +1 5 5 +1 6 6 +1 7 7 +1 8 8 +1 9 9 +1 10 10 +1 11 11 +1 12 12 +1 13 13 +1 14 14 +1 15 15 +1 16 16 +1 17 17 +1 18 18 +1 19 19 +1 20 20 +COUNT(a2) (a2+1) COUNT(a2)*(a2+0) +1 3 2 +1 4 3 +1 5 4 +1 6 5 +1 7 6 +1 8 7 +1 9 8 +1 10 9 +1 11 10 +1 12 11 +1 13 12 +1 14 13 +1 15 14 +1 16 15 +1 17 16 +1 18 17 +1 19 18 +1 20 19 +1 21 20 +1 22 21 +a +8 +7 +6 +5 +a c +8 Clavin +7 Serge +6 Jeb +5 Stewart +4 Martin +3 Pekka +a +2 +3 +4 +5 +6 +7 +8 +a c +4 Martin +5 Stewart +6 Jeb +7 Serge +8 Clavin +a +1 +1 +1 +2 +2 +3 +3 +a +3 +2 +1 +a +3 +2 +1 +a +1 +2 +3 +email shipcode +test1@testdomain.com Z001 +test2@testdomain.com R002 +test2@testdomain.com Z001 +test3@testdomain.com Z001 +email +test1@testdomain.com +test2@testdomain.com +test3@testdomain.com +email shipcode +test1@testdomain.com Z001 +test2@testdomain.com Z001 +test2@testdomain.com R002 +test3@testdomain.com Z001 diff --git a/mysql-test/suite/ndb/r/ndb_dd_dump.result b/mysql-test/suite/ndb/r/ndb_dd_dump.result new file mode 100644 index 00000000000..9b1a1295588 --- /dev/null +++ b/mysql-test/suite/ndb/r/ndb_dd_dump.result @@ -0,0 +1,218 @@ +DROP TABLE IF EXISTS t1, t2, t3; +CREATE LOGFILE GROUP lg1 +ADD UNDOFILE 'undofile_lg1_01.dat' +INITIAL_SIZE 2M +UNDO_BUFFER_SIZE = 1M +ENGINE NDB; +ALTER LOGFILE GROUP lg1 +ADD UNDOFILE 'undofile_lg1_02.dat' +INITIAL_SIZE = 4M +ENGINE NDB; +CREATE TABLESPACE ts1 +ADD DATAFILE 'datafile_ts1_01.dat' +USE LOGFILE GROUP lg1 +EXTENT_SIZE 1M +INITIAL_SIZE 2M +ENGINE NDB; +ALTER TABLESPACE ts1 +ADD DATAFILE 'datafile_ts1_02.dat' +INITIAL_SIZE = 1M +ENGINE=NDB; +CREATE TABLESPACE ts2 +ADD DATAFILE 'datafile_ts2_01.dat' +USE LOGFILE GROUP lg1 +INITIAL_SIZE 2M +ENGINE NDB; +CREATE TABLESPACE ts3 +ADD DATAFILE 'datafile_ts3_01.dat' +USE LOGFILE GROUP lg1 +INITIAL_SIZE 4M +ENGINE NDB; +CREATE TABLE t1 +(pk1 INT NOT NULL PRIMARY KEY, b INT NOT NULL, c INT NOT NULL) +TABLESPACE ts1 STORAGE DISK +ENGINE=NDB; +CREATE TABLE t2 +(pk1 INT NOT NULL PRIMARY KEY, b INT NOT NULL, c INT NOT NULL) +TABLESPACE ts2 STORAGE DISK +ENGINE=NDB; +CREATE TABLE t3 +(pk1 INT NOT NULL PRIMARY KEY, b INT NOT NULL, c INT NOT NULL) +TABLESPACE ts3 STORAGE DISK +ENGINE=NDB; +INSERT INTO t1 VALUES +(1,1,1),(2,2,2),(3,3,3),(4,4,4),(5,5,5), +(6,6,6),(7,7,7),(8,8,8),(9,9,9),(10,10,10), +(11,11,11),(12,12,12),(13,13,13),(14,14,14),(15,15,15), +(16,16,16),(17,17,17),(18,18,18),(19,19,19),(20,20,20), +(21,21,21),(22,22,22),(23,23,23),(24,24,24),(25,25,25), +(26,26,26),(27,27,27),(28,28,28),(29,29,29),(30,30,30), +(31,31,31),(32,32,32),(33,33,33),(34,34,34),(35,35,35), +(36,36,36),(37,37,37),(38,38,38),(39,39,39),(40,40,40), +(41,41,41),(42,42,42),(43,43,43),(44,44,44),(45,45,45), +(46,46,46),(47,47,47),(48,48,48),(49,49,49),(50,50,50), +(51,51,51),(52,52,52),(53,53,53),(54,54,54),(55,55,55), +(56,56,56),(57,57,57),(58,58,58),(59,59,59),(60,60,60), +(61,61,61),(62,62,62),(63,63,63),(64,64,64),(65,65,65), +(66,66,66),(67,67,67),(68,68,68),(69,69,69),(70,70,70), +(71,71,71),(72,72,72),(73,73,73),(74,74,74),(75,75,75), +(76,76,76),(77,77,77),(78,78,78),(79,79,79),(80,80,80), +(81,81,81),(82,82,82),(83,83,83),(84,84,84),(85,85,85), +(86,86,86),(87,87,87),(88,88,88),(89,89,89),(90,90,90), +(91,91,91),(92,92,92),(93,93,93),(94,94,94),(95,95,95), +(96,96,96),(97,97,97),(98,98,98),(99,99,99),(100,100,100), +(101,101,101),(102,102,102),(103,103,103),(104,104,104),(105,105,105), +(106,106,106),(107,107,107),(108,108,108),(109,109,109),(110,110,110), +(111,111,111),(112,112,112),(113,113,113),(114,114,114),(115,115,115), +(116,116,116),(117,117,117),(118,118,118),(119,119,119),(120,120,120), +(121,121,121),(122,122,122),(123,123,123),(124,124,124),(125,125,125), +(126,126,126),(127,127,127),(128,128,128),(129,129,129),(130,130,130), +(131,131,131),(132,132,132),(133,133,133),(134,134,134),(135,135,135), +(136,136,136),(137,137,137),(138,138,138),(139,139,139),(140,140,140), +(141,141,141),(142,142,142),(143,143,143),(144,144,144),(145,145,145), +(146,146,146),(147,147,147),(148,148,148),(149,149,149),(150,150,150), +(151,151,151),(152,152,152),(153,153,153),(154,154,154),(155,155,155), +(156,156,156),(157,157,157),(158,158,158),(159,159,159),(160,160,160), +(161,161,161),(162,162,162),(163,163,163),(164,164,164),(165,165,165), +(166,166,166),(167,167,167),(168,168,168),(169,169,169),(170,170,170), +(171,171,171),(172,172,172),(173,173,173),(174,174,174),(175,175,175), +(176,176,176),(177,177,177),(178,178,178),(179,179,179),(180,180,180), +(181,181,181),(182,182,182),(183,183,183),(184,184,184),(185,185,185), +(186,186,186),(187,187,187),(188,188,188),(189,189,189),(190,190,190), +(191,191,191),(192,192,192),(193,193,193),(194,194,194),(195,195,195), +(196,196,196),(197,197,197),(198,198,198),(199,199,199),(200,200,200), +(201,201,201),(202,202,202),(203,203,203),(204,204,204),(205,205,205), +(206,206,206),(207,207,207),(208,208,208),(209,209,209),(210,210,210), +(211,211,211),(212,212,212),(213,213,213),(214,214,214),(215,215,215), +(216,216,216),(217,217,217),(218,218,218),(219,219,219),(220,220,220), +(221,221,221),(222,222,222),(223,223,223),(224,224,224),(225,225,225), +(226,226,226),(227,227,227),(228,228,228),(229,229,229),(230,230,230), +(231,231,231),(232,232,232),(233,233,233),(234,234,234),(235,235,235), +(236,236,236),(237,237,237),(238,238,238),(239,239,239),(240,240,240), +(241,241,241),(242,242,242),(243,243,243),(244,244,244),(245,245,245), +(246,246,246),(247,247,247),(248,248,248),(249,249,249),(250,250,250), +(251,251,251),(252,252,252),(253,253,253),(254,254,254),(255,255,255), +(256,256,256),(257,257,257),(258,258,258),(259,259,259),(260,260,260), +(261,261,261),(262,262,262),(263,263,263),(264,264,264),(265,265,265), +(266,266,266),(267,267,267),(268,268,268),(269,269,269),(270,270,270), +(271,271,271),(272,272,272),(273,273,273),(274,274,274),(275,275,275), +(276,276,276),(277,277,277),(278,278,278),(279,279,279),(280,280,280), +(281,281,281),(282,282,282),(283,283,283),(284,284,284),(285,285,285), +(286,286,286),(287,287,287),(288,288,288),(289,289,289),(290,290,290), +(291,291,291),(292,292,292),(293,293,293),(294,294,294),(295,295,295), +(296,296,296),(297,297,297),(298,298,298),(299,299,299),(300,300,300), +(301,301,301),(302,302,302),(303,303,303),(304,304,304),(305,305,305), +(306,306,306),(307,307,307),(308,308,308),(309,309,309),(310,310,310), +(311,311,311),(312,312,312),(313,313,313),(314,314,314),(315,315,315), +(316,316,316),(317,317,317),(318,318,318),(319,319,319),(320,320,320), +(321,321,321),(322,322,322),(323,323,323),(324,324,324),(325,325,325), +(326,326,326),(327,327,327),(328,328,328),(329,329,329),(330,330,330), +(331,331,331),(332,332,332),(333,333,333),(334,334,334),(335,335,335), +(336,336,336),(337,337,337),(338,338,338),(339,339,339),(340,340,340), +(341,341,341),(342,342,342),(343,343,343),(344,344,344),(345,345,345), +(346,346,346),(347,347,347),(348,348,348),(349,349,349),(350,350,350), +(351,351,351),(352,352,352),(353,353,353),(354,354,354),(355,355,355), +(356,356,356),(357,357,357),(358,358,358),(359,359,359),(360,360,360), +(361,361,361),(362,362,362),(363,363,363),(364,364,364),(365,365,365), +(366,366,366),(367,367,367),(368,368,368),(369,369,369),(370,370,370), +(371,371,371),(372,372,372),(373,373,373),(374,374,374),(375,375,375), +(376,376,376),(377,377,377),(378,378,378),(379,379,379),(380,380,380), +(381,381,381),(382,382,382),(383,383,383),(384,384,384),(385,385,385), +(386,386,386),(387,387,387),(388,388,388),(389,389,389),(390,390,390), +(391,391,391),(392,392,392),(393,393,393),(394,394,394),(395,395,395), +(396,396,396),(397,397,397),(398,398,398),(399,399,399),(400,400,400), +(401,401,401),(402,402,402),(403,403,403),(404,404,404),(405,405,405), +(406,406,406),(407,407,407),(408,408,408),(409,409,409),(410,410,410), +(411,411,411),(412,412,412),(413,413,413),(414,414,414),(415,415,415), +(416,416,416),(417,417,417),(418,418,418),(419,419,419),(420,420,420), +(421,421,421),(422,422,422),(423,423,423),(424,424,424),(425,425,425), +(426,426,426),(427,427,427),(428,428,428),(429,429,429),(430,430,430), +(431,431,431),(432,432,432),(433,433,433),(434,434,434),(435,435,435), +(436,436,436),(437,437,437),(438,438,438),(439,439,439),(440,440,440), +(441,441,441),(442,442,442),(443,443,443),(444,444,444),(445,445,445), +(446,446,446),(447,447,447),(448,448,448),(449,449,449),(450,450,450), +(451,451,451),(452,452,452),(453,453,453),(454,454,454),(455,455,455), +(456,456,456),(457,457,457),(458,458,458),(459,459,459),(460,460,460), +(461,461,461),(462,462,462),(463,463,463),(464,464,464),(465,465,465), +(466,466,466),(467,467,467),(468,468,468),(469,469,469),(470,470,470), +(471,471,471),(472,472,472),(473,473,473),(474,474,474),(475,475,475), +(476,476,476),(477,477,477),(478,478,478),(479,479,479),(480,480,480), +(481,481,481),(482,482,482),(483,483,483),(484,484,484),(485,485,485), +(486,486,486),(487,487,487),(488,488,488),(489,489,489),(490,490,490), +(491,491,491),(492,492,492),(493,493,493),(494,494,494),(495,495,495), +(496,496,496),(497,497,497),(498,498,498),(499,499,499),(500, 500, 500); +INSERT INTO t2 VALUES +(1,1,1),(2,2,2),(3,3,3),(4,4,4),(5,5,5); +INSERT INTO t3 VALUES +(1,1,1); +DROP TABLE t1; +DROP TABLE t2; +DROP TABLE t3; +ALTER TABLESPACE ts1 +DROP DATAFILE 'datafile_ts1_01.dat' +ENGINE = NDB; +ALTER TABLESPACE ts1 +DROP DATAFILE 'datafile_ts1_02.dat' +ENGINE = NDB; +ALTER TABLESPACE ts2 +DROP DATAFILE 'datafile_ts2_01.dat' +ENGINE = NDB; +ALTER TABLESPACE ts3 +DROP DATAFILE 'datafile_ts3_01.dat' +ENGINE = NDB; +DROP TABLESPACE ts1 ENGINE = NDB; +DROP TABLESPACE ts2 ENGINE = NDB; +DROP TABLESPACE ts3 ENGINE = NDB; +DROP LOGFILE GROUP lg1 ENGINE = NDB; +SELECT DISTINCT +LOGFILE_GROUP_NAME, +FILE_NAME, +TOTAL_EXTENTS, +INITIAL_SIZE, +ENGINE +FROM INFORMATION_SCHEMA.FILES WHERE FILE_TYPE="UNDO LOG" ORDER BY FILE_NAME; +LOGFILE_GROUP_NAME FILE_NAME TOTAL_EXTENTS INITIAL_SIZE ENGINE +lg1 NULL NULL NULL ndbcluster +lg1 undofile_lg1_01.dat 524288 2097152 ndbcluster +lg1 undofile_lg1_02.dat 1048576 4194304 ndbcluster +SELECT DISTINCT +TABLESPACE_NAME, +LOGFILE_GROUP_NAME, +FILE_NAME, +EXTENT_SIZE, +INITIAL_SIZE, +ENGINE +FROM INFORMATION_SCHEMA.FILES WHERE FILE_TYPE="DATAFILE" ORDER BY FILE_NAME; +TABLESPACE_NAME LOGFILE_GROUP_NAME FILE_NAME EXTENT_SIZE INITIAL_SIZE ENGINE +ts1 lg1 datafile_ts1_01.dat 1048576 2097152 ndbcluster +ts1 lg1 datafile_ts1_02.dat 1048576 1048576 ndbcluster +ts2 lg1 datafile_ts2_01.dat 1048576 2097152 ndbcluster +ts3 lg1 datafile_ts3_01.dat 1048576 4194304 ndbcluster +SELECT COUNT(*) FROM t1; +COUNT(*) +500 +SELECT COUNT(*) FROM t2; +COUNT(*) +5 +SELECT COUNT(*) FROM t3; +COUNT(*) +1 +DROP TABLE t1; +DROP TABLE t2; +DROP TABLE t3; +ALTER TABLESPACE ts1 +DROP DATAFILE 'datafile_ts1_01.dat' +ENGINE = NDB; +ALTER TABLESPACE ts1 +DROP DATAFILE 'datafile_ts1_02.dat' +ENGINE = NDB; +ALTER TABLESPACE ts2 +DROP DATAFILE 'datafile_ts2_01.dat' +ENGINE = NDB; +ALTER TABLESPACE ts3 +DROP DATAFILE 'datafile_ts3_01.dat' +ENGINE = NDB; +DROP TABLESPACE ts1 ENGINE = NDB; +DROP TABLESPACE ts2 ENGINE = NDB; +DROP TABLESPACE ts3 ENGINE = NDB; +DROP LOGFILE GROUP lg1 ENGINE = NDB; diff --git a/mysql-test/suite/ndb/r/ndb_dd_sql_features.result b/mysql-test/suite/ndb/r/ndb_dd_sql_features.result new file mode 100644 index 00000000000..135250fe7e8 --- /dev/null +++ b/mysql-test/suite/ndb/r/ndb_dd_sql_features.result @@ -0,0 +1,599 @@ +DROP TABLE IF EXISTS test.t1; +DROP TABLE IF EXISTS test.t2; +DROP TABLE IF EXISTS test.t3; +***** +**** Copy data from table in one table space to table +**** in different table space +***** +CREATE LOGFILE GROUP lg +ADD UNDOFILE './lg_group/undofile.dat' + INITIAL_SIZE 16M +UNDO_BUFFER_SIZE = 1M +ENGINE=NDB; +CREATE TABLESPACE ts1 +ADD DATAFILE './table_space1/datafile.dat' + USE LOGFILE GROUP lg +INITIAL_SIZE 25M +ENGINE NDB; +CREATE TABLESPACE ts2 +ADD DATAFILE './table_space2/datafile.dat' + USE LOGFILE GROUP lg +INITIAL_SIZE 20M +ENGINE NDB; +CREATE TABLE test.t1 (a1 int NOT NULL PRIMARY KEY, a2 VARCHAR(256), a3 BLOB) +TABLESPACE ts1 STORAGE DISK ENGINE=NDB; +CREATE TABLE test.t2 (a1 int NOT NULL PRIMARY KEY, a2 VARCHAR(256), a3 BLOB) +TABLESPACE ts2 STORAGE DISK ENGINE=NDB; +SHOW CREATE TABLE test.t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a1` int(11) NOT NULL, + `a2` varchar(256) DEFAULT NULL, + `a3` blob, + PRIMARY KEY (`a1`) +) /*!50100 TABLESPACE ts1 STORAGE DISK */ ENGINE=ndbcluster DEFAULT CHARSET=latin1 +SHOW CREATE TABLE test.t2; +Table Create Table +t2 CREATE TABLE `t2` ( + `a1` int(11) NOT NULL, + `a2` varchar(256) DEFAULT NULL, + `a3` blob, + PRIMARY KEY (`a1`) +) /*!50100 TABLESPACE ts2 STORAGE DISK */ ENGINE=ndbcluster DEFAULT CHARSET=latin1 +INSERT INTO test.t1 VALUES (1,'111111','aaaaaaaa'); +INSERT INTO test.t1 VALUES (2,'222222','bbbbbbbb'); +SELECT * FROM test.t1 ORDER BY a1; +a1 a2 a3 +1 111111 aaaaaaaa +2 222222 bbbbbbbb +INSERT INTO test.t2(a1,a2,a3) SELECT * FROM test.t1; +SELECT * FROM test.t2 ORDER BY a1; +a1 a2 a3 +1 111111 aaaaaaaa +2 222222 bbbbbbbb +DROP TABLE test.t1, test.t2; +set @vc1 = repeat('a', 200); +set @vc2 = repeat('b', 500); +set @vc3 = repeat('c', 1000); +set @vc4 = repeat('d', 4000); +set @x0 = '01234567012345670123456701234567'; +set @x0 = concat(@x0,@x0,@x0,@x0,@x0,@x0,@x0,@x0); +set @b1 = 'b1'; +set @b1 = concat(@b1,@b1,@b1,@b1,@b1,@b1,@b1,@b1,@b1,@b1); +set @b1 = concat(@b1,@b1,@b1,@b1,@b1,@b1,@b1,@b1,@b1,@b1); +set @b1 = concat(@b1,@b1,@b1,@b1,@b1,@b1,@b1,@b1,@b1,@b1); +set @b1 = concat(@b1,@x0); +set @d1 = 'dd1'; +set @d1 = concat(@d1,@d1,@d1,@d1,@d1,@d1,@d1,@d1,@d1,@d1); +set @d1 = concat(@d1,@d1,@d1,@d1,@d1,@d1,@d1,@d1,@d1,@d1); +set @d1 = concat(@d1,@d1,@d1,@d1,@d1,@d1,@d1,@d1,@d1,@d1); +set @b2 = 'b2'; +set @b2 = concat(@b2,@b2,@b2,@b2,@b2,@b2,@b2,@b2,@b2,@b2); +set @b2 = concat(@b2,@b2,@b2,@b2,@b2,@b2,@b2,@b2,@b2,@b2); +set @b2 = concat(@b2,@b2,@b2,@b2,@b2,@b2,@b2,@b2,@b2,@b2); +set @b2 = concat(@b2,@b2,@b2,@b2,@b2,@b2,@b2,@b2,@b2,@b2); +set @d2 = 'dd2'; +set @d2 = concat(@d2,@d2,@d2,@d2,@d2,@d2,@d2,@d2,@d2,@d2); +set @d2 = concat(@d2,@d2,@d2,@d2,@d2,@d2,@d2,@d2,@d2,@d2); +set @d2 = concat(@d2,@d2,@d2,@d2,@d2,@d2,@d2,@d2,@d2,@d2); +set @d2 = concat(@d2,@d2,@d2,@d2,@d2,@d2,@d2,@d2,@d2,@d2); +select length(@x0),length(@b1),length(@d1) from dual; +length(@x0) length(@b1) length(@d1) +256 2256 3000 +select length(@x0),length(@b2),length(@d2) from dual; +length(@x0) length(@b2) length(@d2) +256 20000 30000 +CREATE TABLE test.t1 (a1 int NOT NULL PRIMARY KEY, a2 VARCHAR(5000), a3 BLOB) +TABLESPACE ts1 STORAGE DISK ENGINE=NDB; +CREATE TABLE test.t2 (a1 int NOT NULL PRIMARY KEY, a2 VARCHAR(5000), a3 BLOB) +TABLESPACE ts2 STORAGE DISK ENGINE=NDB; +SHOW CREATE TABLE test.t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a1` int(11) NOT NULL, + `a2` varchar(5000) DEFAULT NULL, + `a3` blob, + PRIMARY KEY (`a1`) +) /*!50100 TABLESPACE ts1 STORAGE DISK */ ENGINE=ndbcluster DEFAULT CHARSET=latin1 +SHOW CREATE TABLE test.t2; +Table Create Table +t2 CREATE TABLE `t2` ( + `a1` int(11) NOT NULL, + `a2` varchar(5000) DEFAULT NULL, + `a3` blob, + PRIMARY KEY (`a1`) +) /*!50100 TABLESPACE ts2 STORAGE DISK */ ENGINE=ndbcluster DEFAULT CHARSET=latin1 +INSERT INTO test.t1 VALUES (1,@vc1,@d1); +INSERT INTO test.t1 VALUES (2,@vc2,@b1); +INSERT INTO test.t1 VALUES (3,@vc3,@d2); +INSERT INTO test.t1 VALUES (4,@vc4,@b2); +SELECT a1,length(a2),substr(a2,180,2),length(a3),substr(a3,1+3*900,3) +FROM test.t1 WHERE a1=1; +a1 length(a2) substr(a2,180,2) length(a3) substr(a3,1+3*900,3) +1 200 aa 3000 dd1 +SELECT a1,length(a2),substr(a2,480,2),length(a3),substr(a3,1+2*900,3) +FROM test.t1 where a1=2; +a1 length(a2) substr(a2,480,2) length(a3) substr(a3,1+2*900,3) +2 500 bb 2256 b1b +INSERT INTO test.t2(a1,a2,a3) SELECT * FROM test.t1; +SELECT a1,length(a2),substr(a2,180,2),length(a3),substr(a3,1+3*900,3) +FROM test.t2 WHERE a1=1; +a1 length(a2) substr(a2,180,2) length(a3) substr(a3,1+3*900,3) +1 200 aa 3000 dd1 +SELECT a1,length(a2),substr(a2,480,2),length(a3),substr(a3,1+2*900,3) +FROM test.t2 where a1=2; +a1 length(a2) substr(a2,480,2) length(a3) substr(a3,1+2*900,3) +2 500 bb 2256 b1b +DROP TABLE test.t1, test.t2; +***** +**** Insert, Update, Delete from NDB table with BLOB fields +***** +set @vc1 = repeat('a', 200); +set @vc2 = repeat('b', 500); +set @vc3 = repeat('c', 1000); +set @vc4 = repeat('d', 4000); +set @vc5 = repeat('d', 5000); +set @bb1 = repeat('1', 2000); +set @bb2 = repeat('2', 5000); +set @bb3 = repeat('3', 10000); +set @bb4 = repeat('4', 40000); +set @bb5 = repeat('5', 50000); +select length(@vc1),length(@vc2),length(@vc3),length(@vc4),length(@vc5) +from dual; +length(@vc1) length(@vc2) length(@vc3) length(@vc4) length(@vc5) +200 500 1000 4000 5000 +select length(@bb1),length(@bb2),length(@bb3),length(@bb4),length(@bb5) +from dual; +length(@bb1) length(@bb2) length(@bb3) length(@bb4) length(@bb5) +2000 5000 10000 40000 50000 +CREATE TABLE test.t1 (a1 int NOT NULL PRIMARY KEY, a2 VARCHAR(5000), a3 BLOB) +TABLESPACE ts1 STORAGE DISK ENGINE=NDB; +INSERT INTO test.t1 VALUES (1,@vc1,@bb1); +INSERT INTO test.t1 VALUES (2,@vc2,@bb2); +INSERT INTO test.t1 VALUES (3,@vc3,@bb3); +INSERT INTO test.t1 VALUES (4,@vc4,@bb4); +INSERT INTO test.t1 VALUES (5,@vc5,@bb5); +UPDATE test.t1 SET a2=@vc5, a3=@bb5 WHERE a1=1; +SELECT a1,length(a2),substr(a2,4998,2),length(a3),substr(a3,49997,3) +FROM test.t1 WHERE a1=1; +a1 length(a2) substr(a2,4998,2) length(a3) substr(a3,49997,3) +1 5000 dd 50000 555 +UPDATE test.t1 SET a2=@vc4, a3=@bb4 WHERE a1=2; +SELECT a1,length(a2),substr(a2,3998,2),length(a3),substr(a3,39997,3) +FROM test.t1 WHERE a1=2; +a1 length(a2) substr(a2,3998,2) length(a3) substr(a3,39997,3) +2 4000 dd 40000 444 +UPDATE test.t1 SET a2=@vc2, a3=@bb2 WHERE a1=3; +SELECT a1,length(a2),substr(a2,498,2),length(a3),substr(a3,3997,3) +FROM test.t1 WHERE a1=3; +a1 length(a2) substr(a2,498,2) length(a3) substr(a3,3997,3) +3 500 bb 5000 222 +UPDATE test.t1 SET a2=@vc3, a3=@bb3 WHERE a1=4; +SELECT a1,length(a2),substr(a2,998,2),length(a3),substr(a3,9997,3) +FROM test.t1 WHERE a1=4; +a1 length(a2) substr(a2,998,2) length(a3) substr(a3,9997,3) +4 1000 cc 10000 333 +UPDATE test.t1 SET a2=@vc1, a3=@bb1 WHERE a1=5; +SELECT a1,length(a2),substr(a2,198,2),length(a3),substr(a3,1997,3) +FROM test.t1 WHERE a1=5; +a1 length(a2) substr(a2,198,2) length(a3) substr(a3,1997,3) +5 200 aa 2000 111 +DELETE FROM test.t1 where a1=5; +SELECT count(*) from test.t1; +count(*) +4 +DELETE FROM test.t1 where a1=4; +SELECT count(*) from test.t1; +count(*) +3 +DELETE FROM test.t1 where a1=3; +SELECT count(*) from test.t1; +count(*) +2 +DELETE FROM test.t1 where a1=2; +SELECT count(*) from test.t1; +count(*) +1 +DELETE FROM test.t1 where a1=1; +SELECT count(*) from test.t1; +count(*) +0 +DROP TABLE test.t1; +***** +**** Create Stored procedures that use disk based tables +***** +CREATE TABLE test.t1 (a1 int NOT NULL PRIMARY KEY, a2 VARCHAR(256), a3 BLOB) +TABLESPACE ts1 STORAGE DISK ENGINE=NDB// +CREATE PROCEDURE test.sp1() +BEGIN +INSERT INTO test.t1 values (1,'111111','aaaaaaaa'); +END// +CALL test.sp1(); +SELECT * FROM test.t1; +a1 a2 a3 +1 111111 aaaaaaaa +CREATE PROCEDURE test.sp2(n INT, vc VARCHAR(256), blb BLOB) +BEGIN +UPDATE test.t1 SET a2=vc, a3=blb where a1=n; +END// +CALL test.sp2(1,'222222','bbbbbbbb'); +SELECT * FROM test.t1; +a1 a2 a3 +1 222222 bbbbbbbb +DELETE FROM test.t1; +DROP PROCEDURE test.sp1; +DROP PROCEDURE test.sp2; +DROP TABLE test.t1; +***** +***** Create function that operate on disk based tables +***** +CREATE TABLE test.t1 (a1 int NOT NULL PRIMARY KEY, a2 VARCHAR(256), a3 BLOB) +TABLESPACE ts1 STORAGE DISK ENGINE=NDB; +CREATE FUNCTION test.fn1(n INT) RETURNS INT +BEGIN +DECLARE v INT; +SELECT a1 INTO v FROM test.t1 WHERE a1=n; +RETURN v; +END// +CREATE FUNCTION test.fn2(n INT, blb BLOB) RETURNS BLOB +BEGIN +DECLARE vv BLOB; +UPDATE test.t1 SET a3=blb where a1=n; +SELECT a3 INTO vv FROM test.t1 WHERE a1=n; +RETURN vv; +END// +SELECT test.fn1(10) FROM DUAL; +test.fn1(10) +10 +SELECT test.fn2(50, 'new BLOB content') FROM DUAL; +test.fn2(50, 'new BLOB content') +new BLOB content +DELETE FROM test.t1; +DROP FUNCTION test.fn1; +DROP FUNCTION test.fn2; +DROP TABLE test.t1; +***** +***** Create triggers that operate on disk based tables +***** +CREATE TABLE test.t1 (a1 int NOT NULL PRIMARY KEY, a2 VARCHAR(256), a3 BLOB) +TABLESPACE ts1 STORAGE DISK ENGINE=NDB; +CREATE TRIGGER test.trg1 BEFORE INSERT ON test.t1 FOR EACH ROW +BEGIN +if isnull(new.a2) then +set new.a2:= 'trg1 works on a2 field'; +end if; +if isnull(new.a3) then +set new.a3:= 'trg1 works on a3 field'; +end if; +end// +insert into test.t1 (a1) values (1)// +insert into test.t1 (a1,a2) values (2, 'ccccccc')// +select * from test.t1 order by a1// +a1 a2 a3 +1 trg1 works on a2 field trg1 works on a3 field +2 ccccccc trg1 works on a3 field +DELETE FROM test.t1; +DROP TRIGGER test.trg1; +DROP TABLE test.t1; +***** +***** Create, update views that operate on disk based tables +***** +CREATE TABLE test.t1 (a1 int NOT NULL PRIMARY KEY, a2 VARCHAR(256), a3 BLOB) +TABLESPACE ts1 STORAGE DISK ENGINE=NDB; +CREATE VIEW test.v1 AS SELECT * FROM test.t1; +SELECT * FROM test.v1 order by a1; +a1 a2 a3 +1 aaaaa1 bbbbb1 +2 aaaaa2 bbbbb2 +3 aaaaa3 bbbbb3 +4 aaaaa4 bbbbb4 +5 aaaaa5 bbbbb5 +6 aaaaa6 bbbbb6 +7 aaaaa7 bbbbb7 +8 aaaaa8 bbbbb8 +9 aaaaa9 bbbbb9 +10 aaaaa10 bbbbb10 +CHECK TABLE test.v1, test.t1; +Table Op Msg_type Msg_text +test.v1 check status OK +test.t1 check note The storage engine for the table doesn't support check +UPDATE test.v1 SET a2='zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz' WHERE a1=5; +SELECT * FROM test.v1 order by a1; +a1 a2 a3 +1 aaaaa1 bbbbb1 +2 aaaaa2 bbbbb2 +3 aaaaa3 bbbbb3 +4 aaaaa4 bbbbb4 +5 zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz bbbbb5 +6 aaaaa6 bbbbb6 +7 aaaaa7 bbbbb7 +8 aaaaa8 bbbbb8 +9 aaaaa9 bbbbb9 +10 aaaaa10 bbbbb10 +DROP VIEW test.v1; +DELETE FROM test.t1; +DROP TABLE test.t1; +***** +***** Create and use disk based table that use auto inc +***** +CREATE TABLE test.t1 (a1 INT NOT NULL AUTO_INCREMENT PRIMARY KEY, +a2 VARCHAR(256), a3 BLOB) +TABLESPACE ts1 STORAGE DISK ENGINE=NDB; +SELECT * FROM test.t1 ORDER BY a1; +a1 a2 a3 +1 aaaaa10 bbbbb10 +2 aaaaa9 bbbbb9 +3 aaaaa8 bbbbb8 +4 aaaaa7 bbbbb7 +5 aaaaa6 bbbbb6 +6 aaaaa5 bbbbb5 +7 aaaaa4 bbbbb4 +8 aaaaa3 bbbbb3 +9 aaaaa2 bbbbb2 +10 aaaaa1 bbbbb1 +DELETE FROM test.t1; +DROP TABLE test.t1; +***** +***** Create test that use transaction (commit, rollback) +***** +SET AUTOCOMMIT=0; +CREATE TABLE test.t1 (a1 INT NOT NULL AUTO_INCREMENT PRIMARY KEY, +a2 VARCHAR(256), a3 BLOB) +TABLESPACE ts1 STORAGE DISK ENGINE=NDB; +INSERT INTO test.t1 VALUES(NULL, "aaaaa1", "bbbbb1"); +COMMIT; +SELECT * FROM test.t1 ORDER BY a1; +a1 a2 a3 +1 aaaaa1 bbbbb1 +INSERT INTO test.t1 VALUES(NULL, "aaaaa2", "bbbbb2"); +ROLLBACK; +SELECT * FROM test.t1 ORDER BY a1; +a1 a2 a3 +1 aaaaa1 bbbbb1 +DELETE FROM test.t1; +DROP TABLE test.t1; +SET AUTOCOMMIT=1; +CREATE TABLE test.t1 (a1 INT NOT NULL AUTO_INCREMENT PRIMARY KEY, +a2 VARCHAR(256), a3 BLOB) +TABLESPACE ts1 STORAGE DISK ENGINE=NDB; +START TRANSACTION; +INSERT INTO test.t1 VALUES(NULL, "aaaaa1", "bbbbb1"); +COMMIT; +SELECT * FROM test.t1 ORDER BY a1; +a1 a2 a3 +1 aaaaa1 bbbbb1 +START TRANSACTION; +INSERT INTO test.t1 VALUES(NULL, "aaaaa2", "bbbbb2"); +ROLLBACK; +SELECT * FROM test.t1 ORDER BY a1; +a1 a2 a3 +1 aaaaa1 bbbbb1 +DELETE FROM test.t1; +DROP TABLE test.t1; +***** +***** Create test that uses locks +***** +drop table if exists test.t1; +CREATE TABLE test.t1 (a1 INT NOT NULL AUTO_INCREMENT PRIMARY KEY, +a2 VARCHAR(256), a3 BLOB) +TABLESPACE ts1 STORAGE DISK ENGINE=NDB; +LOCK TABLES test.t1 write; +INSERT INTO test.t1 VALUES(NULL, "aaaaa1", "bbbbb1"); +INSERT INTO test.t1 VALUES(NULL, "aaaaa2", "bbbbb2"); +SELECT * FROM test.t1 ORDER BY a1; +a1 a2 a3 +1 aaaaa1 bbbbb1 +2 aaaaa2 bbbbb2 +SELECT * FROM test.t1 ORDER BY a1; +a1 a2 a3 +1 aaaaa1 bbbbb1 +2 aaaaa2 bbbbb2 +INSERT INTO test.t1 VALUES(NULL, "aaaaa3", "bbbbb3"); +UNLOCK TABLES; +INSERT INTO test.t1 VALUES(NULL, "aaaaa3", "bbbbb3"); +SELECT * FROM test.t1 ORDER BY a1; +a1 a2 a3 +1 aaaaa1 bbbbb1 +2 aaaaa2 bbbbb2 +3 aaaaa3 bbbbb3 +4 aaaaa3 bbbbb3 +DELETE FROM test.t1; +DROP TABLE test.t1; +***** +***** Create large disk base table, do random queries, check cache hits +***** +set @vc1 = repeat('a', 200); +SELECT @vc1 FROM DUAL; +@vc1 +aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa +set @vc2 = repeat('b', 500); +set @vc3 = repeat('b', 998); +set @x0 = '01234567012345670123456701234567'; +set @x0 = concat(@x0,@x0,@x0,@x0,@x0,@x0,@x0,@x0); +set @b1 = 'b1'; +set @b1 = concat(@b1,@b1,@b1,@b1,@b1,@b1,@b1,@b1,@b1,@b1); +set @b1 = concat(@b1,@b1,@b1,@b1,@b1,@b1,@b1,@b1,@b1,@b1); +set @b1 = concat(@b1,@b1,@b1,@b1,@b1,@b1,@b1,@b1,@b1,@b1); +set @b1 = concat(@b1,@x0); +set @d1 = 'dd1'; +set @d1 = concat(@d1,@d1,@d1,@d1,@d1,@d1,@d1,@d1,@d1,@d1); +set @d1 = concat(@d1,@d1,@d1,@d1,@d1,@d1,@d1,@d1,@d1,@d1); +set @d1 = concat(@d1,@d1,@d1,@d1,@d1,@d1,@d1,@d1,@d1,@d1); +set @b2 = 'b2'; +set @b2 = concat(@b2,@b2,@b2,@b2,@b2,@b2,@b2,@b2,@b2,@b2); +set @b2 = concat(@b2,@b2,@b2,@b2,@b2,@b2,@b2,@b2,@b2,@b2); +set @b2 = concat(@b2,@b2,@b2,@b2,@b2,@b2,@b2,@b2,@b2,@b2); +set @b2 = concat(@b2,@b2,@b2,@b2,@b2,@b2,@b2,@b2,@b2,@b2); +set @d2 = 'dd2'; +set @d2 = concat(@d2,@d2,@d2,@d2,@d2,@d2,@d2,@d2,@d2,@d2); +set @d2 = concat(@d2,@d2,@d2,@d2,@d2,@d2,@d2,@d2,@d2,@d2); +set @d2 = concat(@d2,@d2,@d2,@d2,@d2,@d2,@d2,@d2,@d2,@d2); +set @d2 = concat(@d2,@d2,@d2,@d2,@d2,@d2,@d2,@d2,@d2,@d2); +select length(@x0),length(@b1),length(@d1) from dual; +length(@x0) length(@b1) length(@d1) +256 2256 3000 +select length(@x0),length(@b2),length(@d2) from dual; +length(@x0) length(@b2) length(@d2) +256 20000 30000 +CREATE TABLE test.t1 (a1 int NOT NULL PRIMARY KEY, a2 VARCHAR(1000), a3 BLOB) +TABLESPACE ts1 STORAGE DISK ENGINE=NDB; +INSERT INTO test.t1 values(1,@vc1,@d1); +INSERT INTO test.t1 values(2,@vc2,@d2); +explain SELECT * from test.t1 WHERE a1 = 1; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t1 const PRIMARY PRIMARY 4 const # +SELECT a1,length(a2),substr(a2,1+2*900,2),length(a3),substr(a3,1+3*900,3) +FROM test.t1 WHERE a1=1 ORDER BY a1; +a1 length(a2) substr(a2,1+2*900,2) length(a3) substr(a3,1+3*900,3) +1 200 3000 dd1 +SELECT a1,length(a2),substr(a2,1+2*9000,2),length(a3),substr(a3,1+3*9000,3) +FROM test.t1 where a1=2 ORDER BY a1; +a1 length(a2) substr(a2,1+2*9000,2) length(a3) substr(a3,1+3*9000,3) +2 500 30000 dd2 +UPDATE test.t1 set a2=@vc2,a3=@d2 where a1=1; +UPDATE test.t1 set a2=@vc1,a3=@d1 where a1=2; +SELECT a1,length(a2),substr(a2,1+2*9000,2),length(a3),substr(a3,1+3*9000,3) +FROM test.t1 where a1=1; +a1 length(a2) substr(a2,1+2*9000,2) length(a3) substr(a3,1+3*9000,3) +1 500 30000 dd2 +SELECT a1,length(a2),substr(a2,1+2*900,2),length(a3),substr(a3,1+3*900,3) +FROM test.t1 where a1=2; +a1 length(a2) substr(a2,1+2*900,2) length(a3) substr(a3,1+3*900,3) +2 200 3000 dd1 +DELETE FROM test.t1; +DROP TABLE test.t1; +***** +***** Create test that uses COUNT(), SUM(), MAX(), MIN(), NOW(), +***** USER(), TRUNCATE +***** +CREATE TABLE test.t1 (a1 int NOT NULL PRIMARY KEY, a2 VARCHAR(256), +a3 BLOB, a4 DATE, a5 CHAR(250)) +TABLESPACE ts1 STORAGE DISK ENGINE=NDB; +SELECT COUNT(*) from test.t1; +COUNT(*) +100 +SELECT SUM(a1) from test.t1; +SUM(a1) +5050 +SELECT MIN(a1) from test.t1; +MIN(a1) +1 +SELECT MAX(a1) from test.t1; +MAX(a1) +100 +SELECT a5 from test.t1 where a1=50; +a5 +root@localhost +SELECT * from test.t1 order by a1; +a1 a2 a3 a4 a5 +1 aaaaaaaaaaaaaaaa1 bbbbbbbbbbbbbbbbbb1 2006-06-20 root@localhost +2 aaaaaaaaaaaaaaaa2 bbbbbbbbbbbbbbbbbb2 2006-06-20 root@localhost +3 aaaaaaaaaaaaaaaa3 bbbbbbbbbbbbbbbbbb3 2006-06-20 root@localhost +4 aaaaaaaaaaaaaaaa4 bbbbbbbbbbbbbbbbbb4 2006-06-20 root@localhost +5 aaaaaaaaaaaaaaaa5 bbbbbbbbbbbbbbbbbb5 2006-06-20 root@localhost +6 aaaaaaaaaaaaaaaa6 bbbbbbbbbbbbbbbbbb6 2006-06-20 root@localhost +7 aaaaaaaaaaaaaaaa7 bbbbbbbbbbbbbbbbbb7 2006-06-20 root@localhost +8 aaaaaaaaaaaaaaaa8 bbbbbbbbbbbbbbbbbb8 2006-06-20 root@localhost +9 aaaaaaaaaaaaaaaa9 bbbbbbbbbbbbbbbbbb9 2006-06-20 root@localhost +10 aaaaaaaaaaaaaaaa10 bbbbbbbbbbbbbbbbbb10 2006-06-20 root@localhost +11 aaaaaaaaaaaaaaaa11 bbbbbbbbbbbbbbbbbb11 2006-06-20 root@localhost +12 aaaaaaaaaaaaaaaa12 bbbbbbbbbbbbbbbbbb12 2006-06-20 root@localhost +13 aaaaaaaaaaaaaaaa13 bbbbbbbbbbbbbbbbbb13 2006-06-20 root@localhost +14 aaaaaaaaaaaaaaaa14 bbbbbbbbbbbbbbbbbb14 2006-06-20 root@localhost +15 aaaaaaaaaaaaaaaa15 bbbbbbbbbbbbbbbbbb15 2006-06-20 root@localhost +16 aaaaaaaaaaaaaaaa16 bbbbbbbbbbbbbbbbbb16 2006-06-20 root@localhost +17 aaaaaaaaaaaaaaaa17 bbbbbbbbbbbbbbbbbb17 2006-06-20 root@localhost +18 aaaaaaaaaaaaaaaa18 bbbbbbbbbbbbbbbbbb18 2006-06-20 root@localhost +19 aaaaaaaaaaaaaaaa19 bbbbbbbbbbbbbbbbbb19 2006-06-20 root@localhost +20 aaaaaaaaaaaaaaaa20 bbbbbbbbbbbbbbbbbb20 2006-06-20 root@localhost +21 aaaaaaaaaaaaaaaa21 bbbbbbbbbbbbbbbbbb21 2006-06-20 root@localhost +22 aaaaaaaaaaaaaaaa22 bbbbbbbbbbbbbbbbbb22 2006-06-20 root@localhost +23 aaaaaaaaaaaaaaaa23 bbbbbbbbbbbbbbbbbb23 2006-06-20 root@localhost +24 aaaaaaaaaaaaaaaa24 bbbbbbbbbbbbbbbbbb24 2006-06-20 root@localhost +25 aaaaaaaaaaaaaaaa25 bbbbbbbbbbbbbbbbbb25 2006-06-20 root@localhost +26 aaaaaaaaaaaaaaaa26 bbbbbbbbbbbbbbbbbb26 2006-06-20 root@localhost +27 aaaaaaaaaaaaaaaa27 bbbbbbbbbbbbbbbbbb27 2006-06-20 root@localhost +28 aaaaaaaaaaaaaaaa28 bbbbbbbbbbbbbbbbbb28 2006-06-20 root@localhost +29 aaaaaaaaaaaaaaaa29 bbbbbbbbbbbbbbbbbb29 2006-06-20 root@localhost +30 aaaaaaaaaaaaaaaa30 bbbbbbbbbbbbbbbbbb30 2006-06-20 root@localhost +31 aaaaaaaaaaaaaaaa31 bbbbbbbbbbbbbbbbbb31 2006-06-20 root@localhost +32 aaaaaaaaaaaaaaaa32 bbbbbbbbbbbbbbbbbb32 2006-06-20 root@localhost +33 aaaaaaaaaaaaaaaa33 bbbbbbbbbbbbbbbbbb33 2006-06-20 root@localhost +34 aaaaaaaaaaaaaaaa34 bbbbbbbbbbbbbbbbbb34 2006-06-20 root@localhost +35 aaaaaaaaaaaaaaaa35 bbbbbbbbbbbbbbbbbb35 2006-06-20 root@localhost +36 aaaaaaaaaaaaaaaa36 bbbbbbbbbbbbbbbbbb36 2006-06-20 root@localhost +37 aaaaaaaaaaaaaaaa37 bbbbbbbbbbbbbbbbbb37 2006-06-20 root@localhost +38 aaaaaaaaaaaaaaaa38 bbbbbbbbbbbbbbbbbb38 2006-06-20 root@localhost +39 aaaaaaaaaaaaaaaa39 bbbbbbbbbbbbbbbbbb39 2006-06-20 root@localhost +40 aaaaaaaaaaaaaaaa40 bbbbbbbbbbbbbbbbbb40 2006-06-20 root@localhost +41 aaaaaaaaaaaaaaaa41 bbbbbbbbbbbbbbbbbb41 2006-06-20 root@localhost +42 aaaaaaaaaaaaaaaa42 bbbbbbbbbbbbbbbbbb42 2006-06-20 root@localhost +43 aaaaaaaaaaaaaaaa43 bbbbbbbbbbbbbbbbbb43 2006-06-20 root@localhost +44 aaaaaaaaaaaaaaaa44 bbbbbbbbbbbbbbbbbb44 2006-06-20 root@localhost +45 aaaaaaaaaaaaaaaa45 bbbbbbbbbbbbbbbbbb45 2006-06-20 root@localhost +46 aaaaaaaaaaaaaaaa46 bbbbbbbbbbbbbbbbbb46 2006-06-20 root@localhost +47 aaaaaaaaaaaaaaaa47 bbbbbbbbbbbbbbbbbb47 2006-06-20 root@localhost +48 aaaaaaaaaaaaaaaa48 bbbbbbbbbbbbbbbbbb48 2006-06-20 root@localhost +49 aaaaaaaaaaaaaaaa49 bbbbbbbbbbbbbbbbbb49 2006-06-20 root@localhost +50 aaaaaaaaaaaaaaaa50 bbbbbbbbbbbbbbbbbb50 2006-06-20 root@localhost +51 aaaaaaaaaaaaaaaa51 bbbbbbbbbbbbbbbbbb51 2006-06-20 root@localhost +52 aaaaaaaaaaaaaaaa52 bbbbbbbbbbbbbbbbbb52 2006-06-20 root@localhost +53 aaaaaaaaaaaaaaaa53 bbbbbbbbbbbbbbbbbb53 2006-06-20 root@localhost +54 aaaaaaaaaaaaaaaa54 bbbbbbbbbbbbbbbbbb54 2006-06-20 root@localhost +55 aaaaaaaaaaaaaaaa55 bbbbbbbbbbbbbbbbbb55 2006-06-20 root@localhost +56 aaaaaaaaaaaaaaaa56 bbbbbbbbbbbbbbbbbb56 2006-06-20 root@localhost +57 aaaaaaaaaaaaaaaa57 bbbbbbbbbbbbbbbbbb57 2006-06-20 root@localhost +58 aaaaaaaaaaaaaaaa58 bbbbbbbbbbbbbbbbbb58 2006-06-20 root@localhost +59 aaaaaaaaaaaaaaaa59 bbbbbbbbbbbbbbbbbb59 2006-06-20 root@localhost +60 aaaaaaaaaaaaaaaa60 bbbbbbbbbbbbbbbbbb60 2006-06-20 root@localhost +61 aaaaaaaaaaaaaaaa61 bbbbbbbbbbbbbbbbbb61 2006-06-20 root@localhost +62 aaaaaaaaaaaaaaaa62 bbbbbbbbbbbbbbbbbb62 2006-06-20 root@localhost +63 aaaaaaaaaaaaaaaa63 bbbbbbbbbbbbbbbbbb63 2006-06-20 root@localhost +64 aaaaaaaaaaaaaaaa64 bbbbbbbbbbbbbbbbbb64 2006-06-20 root@localhost +65 aaaaaaaaaaaaaaaa65 bbbbbbbbbbbbbbbbbb65 2006-06-20 root@localhost +66 aaaaaaaaaaaaaaaa66 bbbbbbbbbbbbbbbbbb66 2006-06-20 root@localhost +67 aaaaaaaaaaaaaaaa67 bbbbbbbbbbbbbbbbbb67 2006-06-20 root@localhost +68 aaaaaaaaaaaaaaaa68 bbbbbbbbbbbbbbbbbb68 2006-06-20 root@localhost +69 aaaaaaaaaaaaaaaa69 bbbbbbbbbbbbbbbbbb69 2006-06-20 root@localhost +70 aaaaaaaaaaaaaaaa70 bbbbbbbbbbbbbbbbbb70 2006-06-20 root@localhost +71 aaaaaaaaaaaaaaaa71 bbbbbbbbbbbbbbbbbb71 2006-06-20 root@localhost +72 aaaaaaaaaaaaaaaa72 bbbbbbbbbbbbbbbbbb72 2006-06-20 root@localhost +73 aaaaaaaaaaaaaaaa73 bbbbbbbbbbbbbbbbbb73 2006-06-20 root@localhost +74 aaaaaaaaaaaaaaaa74 bbbbbbbbbbbbbbbbbb74 2006-06-20 root@localhost +75 aaaaaaaaaaaaaaaa75 bbbbbbbbbbbbbbbbbb75 2006-06-20 root@localhost +76 aaaaaaaaaaaaaaaa76 bbbbbbbbbbbbbbbbbb76 2006-06-20 root@localhost +77 aaaaaaaaaaaaaaaa77 bbbbbbbbbbbbbbbbbb77 2006-06-20 root@localhost +78 aaaaaaaaaaaaaaaa78 bbbbbbbbbbbbbbbbbb78 2006-06-20 root@localhost +79 aaaaaaaaaaaaaaaa79 bbbbbbbbbbbbbbbbbb79 2006-06-20 root@localhost +80 aaaaaaaaaaaaaaaa80 bbbbbbbbbbbbbbbbbb80 2006-06-20 root@localhost +81 aaaaaaaaaaaaaaaa81 bbbbbbbbbbbbbbbbbb81 2006-06-20 root@localhost +82 aaaaaaaaaaaaaaaa82 bbbbbbbbbbbbbbbbbb82 2006-06-20 root@localhost +83 aaaaaaaaaaaaaaaa83 bbbbbbbbbbbbbbbbbb83 2006-06-20 root@localhost +84 aaaaaaaaaaaaaaaa84 bbbbbbbbbbbbbbbbbb84 2006-06-20 root@localhost +85 aaaaaaaaaaaaaaaa85 bbbbbbbbbbbbbbbbbb85 2006-06-20 root@localhost +86 aaaaaaaaaaaaaaaa86 bbbbbbbbbbbbbbbbbb86 2006-06-20 root@localhost +87 aaaaaaaaaaaaaaaa87 bbbbbbbbbbbbbbbbbb87 2006-06-20 root@localhost +88 aaaaaaaaaaaaaaaa88 bbbbbbbbbbbbbbbbbb88 2006-06-20 root@localhost +89 aaaaaaaaaaaaaaaa89 bbbbbbbbbbbbbbbbbb89 2006-06-20 root@localhost +90 aaaaaaaaaaaaaaaa90 bbbbbbbbbbbbbbbbbb90 2006-06-20 root@localhost +91 aaaaaaaaaaaaaaaa91 bbbbbbbbbbbbbbbbbb91 2006-06-20 root@localhost +92 aaaaaaaaaaaaaaaa92 bbbbbbbbbbbbbbbbbb92 2006-06-20 root@localhost +93 aaaaaaaaaaaaaaaa93 bbbbbbbbbbbbbbbbbb93 2006-06-20 root@localhost +94 aaaaaaaaaaaaaaaa94 bbbbbbbbbbbbbbbbbb94 2006-06-20 root@localhost +95 aaaaaaaaaaaaaaaa95 bbbbbbbbbbbbbbbbbb95 2006-06-20 root@localhost +96 aaaaaaaaaaaaaaaa96 bbbbbbbbbbbbbbbbbb96 2006-06-20 root@localhost +97 aaaaaaaaaaaaaaaa97 bbbbbbbbbbbbbbbbbb97 2006-06-20 root@localhost +98 aaaaaaaaaaaaaaaa98 bbbbbbbbbbbbbbbbbb98 2006-06-20 root@localhost +99 aaaaaaaaaaaaaaaa99 bbbbbbbbbbbbbbbbbb99 2006-06-20 root@localhost +100 aaaaaaaaaaaaaaaa100 bbbbbbbbbbbbbbbbbb100 2006-06-20 root@localhost +DROP TABLE test.t1; +ALTER TABLESPACE ts1 +DROP DATAFILE './table_space1/datafile.dat' + ENGINE=NDB; +DROP TABLESPACE ts1 ENGINE=NDB; +ALTER TABLESPACE ts2 +DROP DATAFILE './table_space2/datafile.dat' + ENGINE=NDB; +DROP TABLESPACE ts2 ENGINE=NDB; +DROP LOGFILE GROUP lg +ENGINE=NDB; diff --git a/mysql-test/suite/ndb/r/ndb_gis.result b/mysql-test/suite/ndb/r/ndb_gis.result new file mode 100644 index 00000000000..54f1fc23489 --- /dev/null +++ b/mysql-test/suite/ndb/r/ndb_gis.result @@ -0,0 +1,1100 @@ +SET storage_engine=ndbcluster; +DROP TABLE IF EXISTS t1, gis_point, gis_line, gis_polygon, gis_multi_point, gis_multi_line, gis_multi_polygon, gis_geometrycollection, gis_geometry; +CREATE TABLE gis_point (fid INTEGER PRIMARY KEY AUTO_INCREMENT, g POINT); +CREATE TABLE gis_line (fid INTEGER PRIMARY KEY AUTO_INCREMENT, g LINESTRING); +CREATE TABLE gis_polygon (fid INTEGER PRIMARY KEY AUTO_INCREMENT, g POLYGON); +CREATE TABLE gis_multi_point (fid INTEGER PRIMARY KEY AUTO_INCREMENT, g MULTIPOINT); +CREATE TABLE gis_multi_line (fid INTEGER PRIMARY KEY AUTO_INCREMENT, g MULTILINESTRING); +CREATE TABLE gis_multi_polygon (fid INTEGER PRIMARY KEY AUTO_INCREMENT, g MULTIPOLYGON); +CREATE TABLE gis_geometrycollection (fid INTEGER PRIMARY KEY AUTO_INCREMENT, g GEOMETRYCOLLECTION); +CREATE TABLE gis_geometry (fid INTEGER PRIMARY KEY AUTO_INCREMENT, g GEOMETRY); +SHOW CREATE TABLE gis_point; +Table Create Table +gis_point CREATE TABLE `gis_point` ( + `fid` int(11) NOT NULL AUTO_INCREMENT, + `g` point DEFAULT NULL, + PRIMARY KEY (`fid`) +) ENGINE=ndbcluster DEFAULT CHARSET=latin1 +SHOW FIELDS FROM gis_point; +Field Type Null Key Default Extra +fid int(11) NO PRI NULL auto_increment +g point YES NULL +SHOW FIELDS FROM gis_line; +Field Type Null Key Default Extra +fid int(11) NO PRI NULL auto_increment +g linestring YES NULL +SHOW FIELDS FROM gis_polygon; +Field Type Null Key Default Extra +fid int(11) NO PRI NULL auto_increment +g polygon YES NULL +SHOW FIELDS FROM gis_multi_point; +Field Type Null Key Default Extra +fid int(11) NO PRI NULL auto_increment +g multipoint YES NULL +SHOW FIELDS FROM gis_multi_line; +Field Type Null Key Default Extra +fid int(11) NO PRI NULL auto_increment +g multilinestring YES NULL +SHOW FIELDS FROM gis_multi_polygon; +Field Type Null Key Default Extra +fid int(11) NO PRI NULL auto_increment +g multipolygon YES NULL +SHOW FIELDS FROM gis_geometrycollection; +Field Type Null Key Default Extra +fid int(11) NO PRI NULL auto_increment +g geometrycollection YES NULL +SHOW FIELDS FROM gis_geometry; +Field Type Null Key Default Extra +fid int(11) NO PRI NULL auto_increment +g geometry YES NULL +INSERT INTO gis_point VALUES +(101, PointFromText('POINT(10 10)')), +(102, PointFromText('POINT(20 10)')), +(103, PointFromText('POINT(20 20)')), +(104, PointFromWKB(AsWKB(PointFromText('POINT(10 20)')))); +INSERT INTO gis_line VALUES +(105, LineFromText('LINESTRING(0 0,0 10,10 0)')), +(106, LineStringFromText('LINESTRING(10 10,20 10,20 20,10 20,10 10)')), +(107, LineStringFromWKB(LineString(Point(10, 10), Point(40, 10)))); +INSERT INTO gis_polygon VALUES +(108, PolygonFromText('POLYGON((10 10,20 10,20 20,10 20,10 10))')), +(109, PolyFromText('POLYGON((0 0,50 0,50 50,0 50,0 0), (10 10,20 10,20 20,10 20,10 10))')), +(110, PolyFromWKB(Polygon(LineString(Point(0, 0), Point(30, 0), Point(30, 30), Point(0, 0))))); +INSERT INTO gis_multi_point VALUES +(111, MultiPointFromText('MULTIPOINT(0 0,10 10,10 20,20 20)')), +(112, MPointFromText('MULTIPOINT(1 1,11 11,11 21,21 21)')), +(113, MPointFromWKB(MultiPoint(Point(3, 6), Point(4, 10)))); +INSERT INTO gis_multi_line VALUES +(114, MultiLineStringFromText('MULTILINESTRING((10 48,10 21,10 0),(16 0,16 23,16 48))')), +(115, MLineFromText('MULTILINESTRING((10 48,10 21,10 0))')), +(116, MLineFromWKB(MultiLineString(LineString(Point(1, 2), Point(3, 5)), LineString(Point(2, 5), Point(5, 8), Point(21, 7))))); +INSERT INTO gis_multi_polygon VALUES +(117, MultiPolygonFromText('MULTIPOLYGON(((28 26,28 0,84 0,84 42,28 26),(52 18,66 23,73 9,48 6,52 18)),((59 18,67 18,67 13,59 13,59 18)))')), +(118, MPolyFromText('MULTIPOLYGON(((28 26,28 0,84 0,84 42,28 26),(52 18,66 23,73 9,48 6,52 18)),((59 18,67 18,67 13,59 13,59 18)))')), +(119, MPolyFromWKB(MultiPolygon(Polygon(LineString(Point(0, 3), Point(3, 3), Point(3, 0), Point(0, 3)))))); +INSERT INTO gis_geometrycollection VALUES +(120, GeomCollFromText('GEOMETRYCOLLECTION(POINT(0 0), LINESTRING(0 0,10 10))')), +(121, GeometryFromWKB(GeometryCollection(Point(44, 6), LineString(Point(3, 6), Point(7, 9))))); +INSERT into gis_geometry SELECT * FROM gis_point; +INSERT into gis_geometry SELECT * FROM gis_line; +INSERT into gis_geometry SELECT * FROM gis_polygon; +INSERT into gis_geometry SELECT * FROM gis_multi_point; +INSERT into gis_geometry SELECT * FROM gis_multi_line; +INSERT into gis_geometry SELECT * FROM gis_multi_polygon; +INSERT into gis_geometry SELECT * FROM gis_geometrycollection; +SELECT fid, AsText(g) FROM gis_point ORDER by fid; +fid AsText(g) +101 POINT(10 10) +102 POINT(20 10) +103 POINT(20 20) +104 POINT(10 20) +SELECT fid, AsText(g) FROM gis_line ORDER by fid; +fid AsText(g) +105 LINESTRING(0 0,0 10,10 0) +106 LINESTRING(10 10,20 10,20 20,10 20,10 10) +107 LINESTRING(10 10,40 10) +SELECT fid, AsText(g) FROM gis_polygon ORDER by fid; +fid AsText(g) +108 POLYGON((10 10,20 10,20 20,10 20,10 10)) +109 POLYGON((0 0,50 0,50 50,0 50,0 0),(10 10,20 10,20 20,10 20,10 10)) +110 POLYGON((0 0,30 0,30 30,0 0)) +SELECT fid, AsText(g) FROM gis_multi_point ORDER by fid; +fid AsText(g) +111 MULTIPOINT(0 0,10 10,10 20,20 20) +112 MULTIPOINT(1 1,11 11,11 21,21 21) +113 MULTIPOINT(3 6,4 10) +SELECT fid, AsText(g) FROM gis_multi_line ORDER by fid; +fid AsText(g) +114 MULTILINESTRING((10 48,10 21,10 0),(16 0,16 23,16 48)) +115 MULTILINESTRING((10 48,10 21,10 0)) +116 MULTILINESTRING((1 2,3 5),(2 5,5 8,21 7)) +SELECT fid, AsText(g) FROM gis_multi_polygon ORDER by fid; +fid AsText(g) +117 MULTIPOLYGON(((28 26,28 0,84 0,84 42,28 26),(52 18,66 23,73 9,48 6,52 18)),((59 18,67 18,67 13,59 13,59 18))) +118 MULTIPOLYGON(((28 26,28 0,84 0,84 42,28 26),(52 18,66 23,73 9,48 6,52 18)),((59 18,67 18,67 13,59 13,59 18))) +119 MULTIPOLYGON(((0 3,3 3,3 0,0 3))) +SELECT fid, AsText(g) FROM gis_geometrycollection ORDER by fid; +fid AsText(g) +120 GEOMETRYCOLLECTION(POINT(0 0),LINESTRING(0 0,10 10)) +121 GEOMETRYCOLLECTION(POINT(44 6),LINESTRING(3 6,7 9)) +SELECT fid, AsText(g) FROM gis_geometry ORDER by fid; +fid AsText(g) +101 POINT(10 10) +102 POINT(20 10) +103 POINT(20 20) +104 POINT(10 20) +105 LINESTRING(0 0,0 10,10 0) +106 LINESTRING(10 10,20 10,20 20,10 20,10 10) +107 LINESTRING(10 10,40 10) +108 POLYGON((10 10,20 10,20 20,10 20,10 10)) +109 POLYGON((0 0,50 0,50 50,0 50,0 0),(10 10,20 10,20 20,10 20,10 10)) +110 POLYGON((0 0,30 0,30 30,0 0)) +111 MULTIPOINT(0 0,10 10,10 20,20 20) +112 MULTIPOINT(1 1,11 11,11 21,21 21) +113 MULTIPOINT(3 6,4 10) +114 MULTILINESTRING((10 48,10 21,10 0),(16 0,16 23,16 48)) +115 MULTILINESTRING((10 48,10 21,10 0)) +116 MULTILINESTRING((1 2,3 5),(2 5,5 8,21 7)) +117 MULTIPOLYGON(((28 26,28 0,84 0,84 42,28 26),(52 18,66 23,73 9,48 6,52 18)),((59 18,67 18,67 13,59 13,59 18))) +118 MULTIPOLYGON(((28 26,28 0,84 0,84 42,28 26),(52 18,66 23,73 9,48 6,52 18)),((59 18,67 18,67 13,59 13,59 18))) +119 MULTIPOLYGON(((0 3,3 3,3 0,0 3))) +120 GEOMETRYCOLLECTION(POINT(0 0),LINESTRING(0 0,10 10)) +121 GEOMETRYCOLLECTION(POINT(44 6),LINESTRING(3 6,7 9)) +SELECT fid, Dimension(g) FROM gis_geometry ORDER by fid; +fid Dimension(g) +101 0 +102 0 +103 0 +104 0 +105 1 +106 1 +107 1 +108 2 +109 2 +110 2 +111 0 +112 0 +113 0 +114 1 +115 1 +116 1 +117 2 +118 2 +119 2 +120 1 +121 1 +SELECT fid, GeometryType(g) FROM gis_geometry ORDER by fid; +fid GeometryType(g) +101 POINT +102 POINT +103 POINT +104 POINT +105 LINESTRING +106 LINESTRING +107 LINESTRING +108 POLYGON +109 POLYGON +110 POLYGON +111 MULTIPOINT +112 MULTIPOINT +113 MULTIPOINT +114 MULTILINESTRING +115 MULTILINESTRING +116 MULTILINESTRING +117 MULTIPOLYGON +118 MULTIPOLYGON +119 MULTIPOLYGON +120 GEOMETRYCOLLECTION +121 GEOMETRYCOLLECTION +SELECT fid, IsEmpty(g) FROM gis_geometry ORDER by fid; +fid IsEmpty(g) +101 0 +102 0 +103 0 +104 0 +105 0 +106 0 +107 0 +108 0 +109 0 +110 0 +111 0 +112 0 +113 0 +114 0 +115 0 +116 0 +117 0 +118 0 +119 0 +120 0 +121 0 +SELECT fid, AsText(Envelope(g)) FROM gis_geometry ORDER by fid; +fid AsText(Envelope(g)) +101 POLYGON((10 10,10 10,10 10,10 10,10 10)) +102 POLYGON((20 10,20 10,20 10,20 10,20 10)) +103 POLYGON((20 20,20 20,20 20,20 20,20 20)) +104 POLYGON((10 20,10 20,10 20,10 20,10 20)) +105 POLYGON((0 0,10 0,10 10,0 10,0 0)) +106 POLYGON((10 10,20 10,20 20,10 20,10 10)) +107 POLYGON((10 10,40 10,40 10,10 10,10 10)) +108 POLYGON((10 10,20 10,20 20,10 20,10 10)) +109 POLYGON((0 0,50 0,50 50,0 50,0 0)) +110 POLYGON((0 0,30 0,30 30,0 30,0 0)) +111 POLYGON((0 0,20 0,20 20,0 20,0 0)) +112 POLYGON((1 1,21 1,21 21,1 21,1 1)) +113 POLYGON((3 6,4 6,4 10,3 10,3 6)) +114 POLYGON((10 0,16 0,16 48,10 48,10 0)) +115 POLYGON((10 0,10 0,10 48,10 48,10 0)) +116 POLYGON((1 2,21 2,21 8,1 8,1 2)) +117 POLYGON((28 0,84 0,84 42,28 42,28 0)) +118 POLYGON((28 0,84 0,84 42,28 42,28 0)) +119 POLYGON((0 0,3 0,3 3,0 3,0 0)) +120 POLYGON((0 0,10 0,10 10,0 10,0 0)) +121 POLYGON((3 6,44 6,44 9,3 9,3 6)) +explain extended select Dimension(g), GeometryType(g), IsEmpty(g), AsText(Envelope(g)) from gis_geometry; +id select_type table type possible_keys key key_len ref rows filtered Extra +1 SIMPLE gis_geometry ALL NULL NULL NULL NULL 21 100.00 +Warnings: +Note 1003 select dimension(`test`.`gis_geometry`.`g`) AS `Dimension(g)`,geometrytype(`test`.`gis_geometry`.`g`) AS `GeometryType(g)`,isempty(`test`.`gis_geometry`.`g`) AS `IsEmpty(g)`,astext(envelope(`test`.`gis_geometry`.`g`)) AS `AsText(Envelope(g))` from `test`.`gis_geometry` +SELECT fid, X(g) FROM gis_point ORDER by fid; +fid X(g) +101 10 +102 20 +103 20 +104 10 +SELECT fid, Y(g) FROM gis_point ORDER by fid; +fid Y(g) +101 10 +102 10 +103 20 +104 20 +explain extended select X(g),Y(g) FROM gis_point; +id select_type table type possible_keys key key_len ref rows filtered Extra +1 SIMPLE gis_point ALL NULL NULL NULL NULL 4 100.00 +Warnings: +Note 1003 select x(`test`.`gis_point`.`g`) AS `X(g)`,y(`test`.`gis_point`.`g`) AS `Y(g)` from `test`.`gis_point` +SELECT fid, AsText(StartPoint(g)) FROM gis_line ORDER by fid; +fid AsText(StartPoint(g)) +105 POINT(0 0) +106 POINT(10 10) +107 POINT(10 10) +SELECT fid, AsText(EndPoint(g)) FROM gis_line ORDER by fid; +fid AsText(EndPoint(g)) +105 POINT(10 0) +106 POINT(10 10) +107 POINT(40 10) +SELECT fid, GLength(g) FROM gis_line ORDER by fid; +fid GLength(g) +105 24.142135623731 +106 40 +107 30 +SELECT fid, NumPoints(g) FROM gis_line ORDER by fid; +fid NumPoints(g) +105 3 +106 5 +107 2 +SELECT fid, AsText(PointN(g, 2)) FROM gis_line ORDER by fid; +fid AsText(PointN(g, 2)) +105 POINT(0 10) +106 POINT(20 10) +107 POINT(40 10) +SELECT fid, IsClosed(g) FROM gis_line ORDER by fid; +fid IsClosed(g) +105 0 +106 1 +107 0 +explain extended select AsText(StartPoint(g)),AsText(EndPoint(g)),GLength(g),NumPoints(g),AsText(PointN(g, 2)),IsClosed(g) FROM gis_line; +id select_type table type possible_keys key key_len ref rows filtered Extra +1 SIMPLE gis_line ALL NULL NULL NULL NULL 3 100.00 +Warnings: +Note 1003 select astext(startpoint(`test`.`gis_line`.`g`)) AS `AsText(StartPoint(g))`,astext(endpoint(`test`.`gis_line`.`g`)) AS `AsText(EndPoint(g))`,glength(`test`.`gis_line`.`g`) AS `GLength(g)`,numpoints(`test`.`gis_line`.`g`) AS `NumPoints(g)`,astext(pointn(`test`.`gis_line`.`g`,2)) AS `AsText(PointN(g, 2))`,isclosed(`test`.`gis_line`.`g`) AS `IsClosed(g)` from `test`.`gis_line` +SELECT fid, AsText(Centroid(g)) FROM gis_polygon ORDER by fid; +fid AsText(Centroid(g)) +108 POINT(15 15) +109 POINT(25.416666666667 25.416666666667) +110 POINT(20 10) +SELECT fid, Area(g) FROM gis_polygon ORDER by fid; +fid Area(g) +108 100 +109 2400 +110 450 +SELECT fid, AsText(ExteriorRing(g)) FROM gis_polygon ORDER by fid; +fid AsText(ExteriorRing(g)) +108 LINESTRING(10 10,20 10,20 20,10 20,10 10) +109 LINESTRING(0 0,50 0,50 50,0 50,0 0) +110 LINESTRING(0 0,30 0,30 30,0 0) +SELECT fid, NumInteriorRings(g) FROM gis_polygon ORDER by fid; +fid NumInteriorRings(g) +108 0 +109 1 +110 0 +SELECT fid, AsText(InteriorRingN(g, 1)) FROM gis_polygon ORDER by fid; +fid AsText(InteriorRingN(g, 1)) +108 NULL +109 LINESTRING(10 10,20 10,20 20,10 20,10 10) +110 NULL +explain extended select AsText(Centroid(g)),Area(g),AsText(ExteriorRing(g)),NumInteriorRings(g),AsText(InteriorRingN(g, 1)) FROM gis_polygon; +id select_type table type possible_keys key key_len ref rows filtered Extra +1 SIMPLE gis_polygon ALL NULL NULL NULL NULL 3 100.00 +Warnings: +Note 1003 select astext(centroid(`test`.`gis_polygon`.`g`)) AS `AsText(Centroid(g))`,area(`test`.`gis_polygon`.`g`) AS `Area(g)`,astext(exteriorring(`test`.`gis_polygon`.`g`)) AS `AsText(ExteriorRing(g))`,numinteriorrings(`test`.`gis_polygon`.`g`) AS `NumInteriorRings(g)`,astext(interiorringn(`test`.`gis_polygon`.`g`,1)) AS `AsText(InteriorRingN(g, 1))` from `test`.`gis_polygon` +SELECT fid, IsClosed(g) FROM gis_multi_line ORDER by fid; +fid IsClosed(g) +114 0 +115 0 +116 0 +SELECT fid, AsText(Centroid(g)) FROM gis_multi_polygon ORDER by fid; +fid AsText(Centroid(g)) +117 POINT(55.588527753042 17.426536064114) +118 POINT(55.588527753042 17.426536064114) +119 POINT(2 2) +SELECT fid, Area(g) FROM gis_multi_polygon ORDER by fid; +fid Area(g) +117 1684.5 +118 1684.5 +119 4.5 +SELECT fid, NumGeometries(g) from gis_multi_point ORDER by fid; +fid NumGeometries(g) +111 4 +112 4 +113 2 +SELECT fid, NumGeometries(g) from gis_multi_line ORDER by fid; +fid NumGeometries(g) +114 2 +115 1 +116 2 +SELECT fid, NumGeometries(g) from gis_multi_polygon ORDER by fid; +fid NumGeometries(g) +117 2 +118 2 +119 1 +SELECT fid, NumGeometries(g) from gis_geometrycollection ORDER by fid; +fid NumGeometries(g) +120 2 +121 2 +explain extended SELECT fid, NumGeometries(g) from gis_multi_point; +id select_type table type possible_keys key key_len ref rows filtered Extra +1 SIMPLE gis_multi_point ALL NULL NULL NULL NULL 3 100.00 +Warnings: +Note 1003 select `test`.`gis_multi_point`.`fid` AS `fid`,numgeometries(`test`.`gis_multi_point`.`g`) AS `NumGeometries(g)` from `test`.`gis_multi_point` +SELECT fid, AsText(GeometryN(g, 2)) from gis_multi_point ORDER by fid; +fid AsText(GeometryN(g, 2)) +111 POINT(10 10) +112 POINT(11 11) +113 POINT(4 10) +SELECT fid, AsText(GeometryN(g, 2)) from gis_multi_line ORDER by fid; +fid AsText(GeometryN(g, 2)) +114 LINESTRING(16 0,16 23,16 48) +115 NULL +116 LINESTRING(2 5,5 8,21 7) +SELECT fid, AsText(GeometryN(g, 2)) from gis_multi_polygon ORDER by fid; +fid AsText(GeometryN(g, 2)) +117 POLYGON((59 18,67 18,67 13,59 13,59 18)) +118 POLYGON((59 18,67 18,67 13,59 13,59 18)) +119 NULL +SELECT fid, AsText(GeometryN(g, 2)) from gis_geometrycollection ORDER by fid; +fid AsText(GeometryN(g, 2)) +120 LINESTRING(0 0,10 10) +121 LINESTRING(3 6,7 9) +SELECT fid, AsText(GeometryN(g, 1)) from gis_geometrycollection ORDER by fid; +fid AsText(GeometryN(g, 1)) +120 POINT(0 0) +121 POINT(44 6) +explain extended SELECT fid, AsText(GeometryN(g, 2)) from gis_multi_point; +id select_type table type possible_keys key key_len ref rows filtered Extra +1 SIMPLE gis_multi_point ALL NULL NULL NULL NULL 3 100.00 +Warnings: +Note 1003 select `test`.`gis_multi_point`.`fid` AS `fid`,astext(geometryn(`test`.`gis_multi_point`.`g`,2)) AS `AsText(GeometryN(g, 2))` from `test`.`gis_multi_point` +SELECT g1.fid as first, g2.fid as second, +Within(g1.g, g2.g) as w, Contains(g1.g, g2.g) as c, Overlaps(g1.g, g2.g) as o, +Equals(g1.g, g2.g) as e, Disjoint(g1.g, g2.g) as d, Touches(g1.g, g2.g) as t, +Intersects(g1.g, g2.g) as i, Crosses(g1.g, g2.g) as r +FROM gis_geometrycollection g1, gis_geometrycollection g2 ORDER BY first, second; +first second w c o e d t i r +120 120 1 1 0 1 0 0 1 0 +120 121 0 0 1 0 0 0 1 0 +121 120 0 0 1 0 0 0 1 0 +121 121 1 1 0 1 0 0 1 0 +explain extended SELECT g1.fid as first, g2.fid as second, +Within(g1.g, g2.g) as w, Contains(g1.g, g2.g) as c, Overlaps(g1.g, g2.g) as o, +Equals(g1.g, g2.g) as e, Disjoint(g1.g, g2.g) as d, Touches(g1.g, g2.g) as t, +Intersects(g1.g, g2.g) as i, Crosses(g1.g, g2.g) as r +FROM gis_geometrycollection g1, gis_geometrycollection g2 ORDER BY first, second; +id select_type table type possible_keys key key_len ref rows filtered Extra +1 SIMPLE g1 ALL NULL NULL NULL NULL 2 100.00 Using temporary; Using filesort +1 SIMPLE g2 ALL NULL NULL NULL NULL 2 100.00 Using join buffer +Warnings: +Note 1003 select `test`.`g1`.`fid` AS `first`,`test`.`g2`.`fid` AS `second`,within(`test`.`g1`.`g`,`test`.`g2`.`g`) AS `w`,contains(`test`.`g1`.`g`,`test`.`g2`.`g`) AS `c`,overlaps(`test`.`g1`.`g`,`test`.`g2`.`g`) AS `o`,equals(`test`.`g1`.`g`,`test`.`g2`.`g`) AS `e`,disjoint(`test`.`g1`.`g`,`test`.`g2`.`g`) AS `d`,touches(`test`.`g1`.`g`,`test`.`g2`.`g`) AS `t`,intersects(`test`.`g1`.`g`,`test`.`g2`.`g`) AS `i`,crosses(`test`.`g1`.`g`,`test`.`g2`.`g`) AS `r` from `test`.`gis_geometrycollection` `g1` join `test`.`gis_geometrycollection` `g2` order by `test`.`g1`.`fid`,`test`.`g2`.`fid` +DROP TABLE gis_point, gis_line, gis_polygon, gis_multi_point, gis_multi_line, gis_multi_polygon, gis_geometrycollection, gis_geometry; +CREATE TABLE t1 ( +a INTEGER PRIMARY KEY AUTO_INCREMENT, +gp point, +ln linestring, +pg polygon, +mp multipoint, +mln multilinestring, +mpg multipolygon, +gc geometrycollection, +gm geometry +); +SHOW FIELDS FROM t1; +Field Type Null Key Default Extra +a int(11) NO PRI NULL auto_increment +gp point YES NULL +ln linestring YES NULL +pg polygon YES NULL +mp multipoint YES NULL +mln multilinestring YES NULL +mpg multipolygon YES NULL +gc geometrycollection YES NULL +gm geometry YES NULL +ALTER TABLE t1 ADD fid INT; +SHOW FIELDS FROM t1; +Field Type Null Key Default Extra +a int(11) NO PRI NULL auto_increment +gp point YES NULL +ln linestring YES NULL +pg polygon YES NULL +mp multipoint YES NULL +mln multilinestring YES NULL +mpg multipolygon YES NULL +gc geometrycollection YES NULL +gm geometry YES NULL +fid int(11) YES NULL +DROP TABLE t1; +create table t1 (pk integer primary key auto_increment, a geometry not null); +insert into t1 (a) values (GeomFromText('Point(1 2)')); +insert into t1 (a) values ('Garbage'); +ERROR 22003: Cannot get geometry object from data you send to the GEOMETRY field +insert IGNORE into t1 (a) values ('Garbage'); +ERROR 22003: Cannot get geometry object from data you send to the GEOMETRY field +drop table t1; +create table t1 (pk integer primary key auto_increment, fl geometry not null); +insert into t1 (fl) values (1); +ERROR 22003: Cannot get geometry object from data you send to the GEOMETRY field +insert into t1 (fl) values (1.11); +ERROR 22003: Cannot get geometry object from data you send to the GEOMETRY field +insert into t1 (fl) values ("qwerty"); +ERROR 22003: Cannot get geometry object from data you send to the GEOMETRY field +insert into t1 (fl) values (pointfromtext('point(1,1)')); +ERROR 23000: Column 'fl' cannot be null +drop table t1; +End of 4.1 tests +CREATE TABLE t1 (name VARCHAR(100), square GEOMETRY); +Warnings: +Error 1475 Table storage engine 'ndbcluster' does not support the create option 'Binlog of table with BLOB attribute and no PK' +INSERT INTO t1 VALUES("center", GeomFromText('POLYGON (( 0 0, 0 2, 2 2, 2 0, 0 0))')); +INSERT INTO t1 VALUES("small", GeomFromText('POLYGON (( 0 0, 0 1, 1 1, 1 0, 0 0))')); +INSERT INTO t1 VALUES("big", GeomFromText('POLYGON (( 0 0, 0 3, 3 3, 3 0, 0 0))')); +INSERT INTO t1 VALUES("up", GeomFromText('POLYGON (( 0 1, 0 3, 2 3, 2 1, 0 1))')); +INSERT INTO t1 VALUES("up2", GeomFromText('POLYGON (( 0 2, 0 4, 2 4, 2 2, 0 2))')); +INSERT INTO t1 VALUES("up3", GeomFromText('POLYGON (( 0 3, 0 5, 2 5, 2 3, 0 3))')); +INSERT INTO t1 VALUES("down", GeomFromText('POLYGON (( 0 -1, 0 1, 2 1, 2 -1, 0 -1))')); +INSERT INTO t1 VALUES("down2", GeomFromText('POLYGON (( 0 -2, 0 0, 2 0, 2 -2, 0 -2))')); +INSERT INTO t1 VALUES("down3", GeomFromText('POLYGON (( 0 -3, 0 -1, 2 -1, 2 -3, 0 -3))')); +INSERT INTO t1 VALUES("right", GeomFromText('POLYGON (( 1 0, 1 2, 3 2, 3 0, 1 0))')); +INSERT INTO t1 VALUES("right2", GeomFromText('POLYGON (( 2 0, 2 2, 4 2, 4 0, 2 0))')); +INSERT INTO t1 VALUES("right3", GeomFromText('POLYGON (( 3 0, 3 2, 5 2, 5 0, 3 0))')); +INSERT INTO t1 VALUES("left", GeomFromText('POLYGON (( -1 0, -1 2, 1 2, 1 0, -1 0))')); +INSERT INTO t1 VALUES("left2", GeomFromText('POLYGON (( -2 0, -2 2, 0 2, 0 0, -2 0))')); +INSERT INTO t1 VALUES("left3", GeomFromText('POLYGON (( -3 0, -3 2, -1 2, -1 0, -3 0))')); +SELECT GROUP_CONCAT(a2.name ORDER BY a2.name) AS mbrcontains FROM t1 a1 JOIN t1 a2 ON MBRContains( a1.square, a2.square) WHERE a1.name = "center" GROUP BY a1.name; +mbrcontains +center,small +SELECT GROUP_CONCAT(a2.name ORDER BY a2.name) AS mbrdisjoint FROM t1 a1 JOIN t1 a2 ON MBRDisjoint( a1.square, a2.square) WHERE a1.name = "center" GROUP BY a1.name; +mbrdisjoint +down3,left3,right3,up3 +SELECT GROUP_CONCAT(a2.name ORDER BY a2.name) AS mbrequal FROM t1 a1 JOIN t1 a2 ON MBREqual( a1.square, a2.square) WHERE a1.name = "center" GROUP BY a1.name; +mbrequal +center +SELECT GROUP_CONCAT(a2.name ORDER BY a2.name) AS mbrintersect FROM t1 a1 JOIN t1 a2 ON MBRIntersects( a1.square, a2.square) WHERE a1.name = "center" GROUP BY a1.name; +mbrintersect +big,center,down,down2,left,left2,right,right2,small,up,up2 +SELECT GROUP_CONCAT(a2.name ORDER BY a2.name) AS mbroverlaps FROM t1 a1 JOIN t1 a2 ON MBROverlaps( a1.square, a2.square) WHERE a1.name = "center" GROUP BY a1.name; +mbroverlaps +down,left,right,up +SELECT GROUP_CONCAT(a2.name ORDER BY a2.name) AS mbrtouches FROM t1 a1 JOIN t1 a2 ON MBRTouches( a1.square, a2.square) WHERE a1.name = "center" GROUP BY a1.name; +mbrtouches +down2,left2,right2,up2 +SELECT GROUP_CONCAT(a2.name ORDER BY a2.name) AS mbrwithin FROM t1 a1 JOIN t1 a2 ON MBRWithin( a1.square, a2.square) WHERE a1.name = "center" GROUP BY a1.name; +mbrwithin +big,center +SELECT GROUP_CONCAT(a2.name ORDER BY a2.name) AS contains FROM t1 a1 JOIN t1 a2 ON Contains( a1.square, a2.square) WHERE a1.name = "center" GROUP BY a1.name; +contains +center,small +SELECT GROUP_CONCAT(a2.name ORDER BY a2.name) AS disjoint FROM t1 a1 JOIN t1 a2 ON Disjoint( a1.square, a2.square) WHERE a1.name = "center" GROUP BY a1.name; +disjoint +down3,left3,right3,up3 +SELECT GROUP_CONCAT(a2.name ORDER BY a2.name) AS equals FROM t1 a1 JOIN t1 a2 ON Equals( a1.square, a2.square) WHERE a1.name = "center" GROUP BY a1.name; +equals +center +SELECT GROUP_CONCAT(a2.name ORDER BY a2.name) AS intersect FROM t1 a1 JOIN t1 a2 ON Intersects( a1.square, a2.square) WHERE a1.name = "center" GROUP BY a1.name; +intersect +big,center,down,down2,left,left2,right,right2,small,up,up2 +SELECT GROUP_CONCAT(a2.name ORDER BY a2.name) AS overlaps FROM t1 a1 JOIN t1 a2 ON Overlaps( a1.square, a2.square) WHERE a1.name = "center" GROUP BY a1.name; +overlaps +down,left,right,up +SELECT GROUP_CONCAT(a2.name ORDER BY a2.name) AS touches FROM t1 a1 JOIN t1 a2 ON Touches( a1.square, a2.square) WHERE a1.name = "center" GROUP BY a1.name; +touches +down2,left2,right2,up2 +SELECT GROUP_CONCAT(a2.name ORDER BY a2.name) AS within FROM t1 a1 JOIN t1 a2 ON Within( a1.square, a2.square) WHERE a1.name = "center" GROUP BY a1.name; +within +big,center +SET @vert1 = GeomFromText('POLYGON ((0 -2, 0 2, 0 -2))'); +SET @horiz1 = GeomFromText('POLYGON ((-2 0, 2 0, -2 0))'); +SET @horiz2 = GeomFromText('POLYGON ((-1 0, 3 0, -1 0))'); +SET @horiz3 = GeomFromText('POLYGON ((2 0, 3 0, 2 0))'); +SET @point1 = GeomFromText('POLYGON ((0 0))'); +SET @point2 = GeomFromText('POLYGON ((-2 0))'); +SELECT GROUP_CONCAT(a1.name ORDER BY a1.name) AS overlaps FROM t1 a1 WHERE Overlaps(a1.square, @vert1) GROUP BY a1.name; +overlaps +SELECT GROUP_CONCAT(a1.name ORDER BY a1.name) AS overlaps FROM t1 a1 WHERE Overlaps(a1.square, @horiz1) GROUP BY a1.name; +overlaps +SELECT Overlaps(@horiz1, @vert1) FROM DUAL; +Overlaps(@horiz1, @vert1) +0 +SELECT Overlaps(@horiz1, @horiz2) FROM DUAL; +Overlaps(@horiz1, @horiz2) +1 +SELECT Overlaps(@horiz1, @horiz3) FROM DUAL; +Overlaps(@horiz1, @horiz3) +0 +SELECT Overlaps(@horiz1, @point1) FROM DUAL; +Overlaps(@horiz1, @point1) +0 +SELECT Overlaps(@horiz1, @point2) FROM DUAL; +Overlaps(@horiz1, @point2) +0 +DROP TABLE t1; +End of 5.0 tests +set engine_condition_pushdown = on; +DROP TABLE IF EXISTS t1, gis_point, gis_line, gis_polygon, gis_multi_point, gis_multi_line, gis_multi_polygon, gis_geometrycollection, gis_geometry; +CREATE TABLE gis_point (fid INTEGER PRIMARY KEY AUTO_INCREMENT, g POINT); +CREATE TABLE gis_line (fid INTEGER PRIMARY KEY AUTO_INCREMENT, g LINESTRING); +CREATE TABLE gis_polygon (fid INTEGER PRIMARY KEY AUTO_INCREMENT, g POLYGON); +CREATE TABLE gis_multi_point (fid INTEGER PRIMARY KEY AUTO_INCREMENT, g MULTIPOINT); +CREATE TABLE gis_multi_line (fid INTEGER PRIMARY KEY AUTO_INCREMENT, g MULTILINESTRING); +CREATE TABLE gis_multi_polygon (fid INTEGER PRIMARY KEY AUTO_INCREMENT, g MULTIPOLYGON); +CREATE TABLE gis_geometrycollection (fid INTEGER PRIMARY KEY AUTO_INCREMENT, g GEOMETRYCOLLECTION); +CREATE TABLE gis_geometry (fid INTEGER PRIMARY KEY AUTO_INCREMENT, g GEOMETRY); +SHOW CREATE TABLE gis_point; +Table Create Table +gis_point CREATE TABLE `gis_point` ( + `fid` int(11) NOT NULL AUTO_INCREMENT, + `g` point DEFAULT NULL, + PRIMARY KEY (`fid`) +) ENGINE=ndbcluster DEFAULT CHARSET=latin1 +SHOW FIELDS FROM gis_point; +Field Type Null Key Default Extra +fid int(11) NO PRI NULL auto_increment +g point YES NULL +SHOW FIELDS FROM gis_line; +Field Type Null Key Default Extra +fid int(11) NO PRI NULL auto_increment +g linestring YES NULL +SHOW FIELDS FROM gis_polygon; +Field Type Null Key Default Extra +fid int(11) NO PRI NULL auto_increment +g polygon YES NULL +SHOW FIELDS FROM gis_multi_point; +Field Type Null Key Default Extra +fid int(11) NO PRI NULL auto_increment +g multipoint YES NULL +SHOW FIELDS FROM gis_multi_line; +Field Type Null Key Default Extra +fid int(11) NO PRI NULL auto_increment +g multilinestring YES NULL +SHOW FIELDS FROM gis_multi_polygon; +Field Type Null Key Default Extra +fid int(11) NO PRI NULL auto_increment +g multipolygon YES NULL +SHOW FIELDS FROM gis_geometrycollection; +Field Type Null Key Default Extra +fid int(11) NO PRI NULL auto_increment +g geometrycollection YES NULL +SHOW FIELDS FROM gis_geometry; +Field Type Null Key Default Extra +fid int(11) NO PRI NULL auto_increment +g geometry YES NULL +INSERT INTO gis_point VALUES +(101, PointFromText('POINT(10 10)')), +(102, PointFromText('POINT(20 10)')), +(103, PointFromText('POINT(20 20)')), +(104, PointFromWKB(AsWKB(PointFromText('POINT(10 20)')))); +INSERT INTO gis_line VALUES +(105, LineFromText('LINESTRING(0 0,0 10,10 0)')), +(106, LineStringFromText('LINESTRING(10 10,20 10,20 20,10 20,10 10)')), +(107, LineStringFromWKB(LineString(Point(10, 10), Point(40, 10)))); +INSERT INTO gis_polygon VALUES +(108, PolygonFromText('POLYGON((10 10,20 10,20 20,10 20,10 10))')), +(109, PolyFromText('POLYGON((0 0,50 0,50 50,0 50,0 0), (10 10,20 10,20 20,10 20,10 10))')), +(110, PolyFromWKB(Polygon(LineString(Point(0, 0), Point(30, 0), Point(30, 30), Point(0, 0))))); +INSERT INTO gis_multi_point VALUES +(111, MultiPointFromText('MULTIPOINT(0 0,10 10,10 20,20 20)')), +(112, MPointFromText('MULTIPOINT(1 1,11 11,11 21,21 21)')), +(113, MPointFromWKB(MultiPoint(Point(3, 6), Point(4, 10)))); +INSERT INTO gis_multi_line VALUES +(114, MultiLineStringFromText('MULTILINESTRING((10 48,10 21,10 0),(16 0,16 23,16 48))')), +(115, MLineFromText('MULTILINESTRING((10 48,10 21,10 0))')), +(116, MLineFromWKB(MultiLineString(LineString(Point(1, 2), Point(3, 5)), LineString(Point(2, 5), Point(5, 8), Point(21, 7))))); +INSERT INTO gis_multi_polygon VALUES +(117, MultiPolygonFromText('MULTIPOLYGON(((28 26,28 0,84 0,84 42,28 26),(52 18,66 23,73 9,48 6,52 18)),((59 18,67 18,67 13,59 13,59 18)))')), +(118, MPolyFromText('MULTIPOLYGON(((28 26,28 0,84 0,84 42,28 26),(52 18,66 23,73 9,48 6,52 18)),((59 18,67 18,67 13,59 13,59 18)))')), +(119, MPolyFromWKB(MultiPolygon(Polygon(LineString(Point(0, 3), Point(3, 3), Point(3, 0), Point(0, 3)))))); +INSERT INTO gis_geometrycollection VALUES +(120, GeomCollFromText('GEOMETRYCOLLECTION(POINT(0 0), LINESTRING(0 0,10 10))')), +(121, GeometryFromWKB(GeometryCollection(Point(44, 6), LineString(Point(3, 6), Point(7, 9))))); +INSERT into gis_geometry SELECT * FROM gis_point; +INSERT into gis_geometry SELECT * FROM gis_line; +INSERT into gis_geometry SELECT * FROM gis_polygon; +INSERT into gis_geometry SELECT * FROM gis_multi_point; +INSERT into gis_geometry SELECT * FROM gis_multi_line; +INSERT into gis_geometry SELECT * FROM gis_multi_polygon; +INSERT into gis_geometry SELECT * FROM gis_geometrycollection; +SELECT fid, AsText(g) FROM gis_point ORDER by fid; +fid AsText(g) +101 POINT(10 10) +102 POINT(20 10) +103 POINT(20 20) +104 POINT(10 20) +SELECT fid, AsText(g) FROM gis_line ORDER by fid; +fid AsText(g) +105 LINESTRING(0 0,0 10,10 0) +106 LINESTRING(10 10,20 10,20 20,10 20,10 10) +107 LINESTRING(10 10,40 10) +SELECT fid, AsText(g) FROM gis_polygon ORDER by fid; +fid AsText(g) +108 POLYGON((10 10,20 10,20 20,10 20,10 10)) +109 POLYGON((0 0,50 0,50 50,0 50,0 0),(10 10,20 10,20 20,10 20,10 10)) +110 POLYGON((0 0,30 0,30 30,0 0)) +SELECT fid, AsText(g) FROM gis_multi_point ORDER by fid; +fid AsText(g) +111 MULTIPOINT(0 0,10 10,10 20,20 20) +112 MULTIPOINT(1 1,11 11,11 21,21 21) +113 MULTIPOINT(3 6,4 10) +SELECT fid, AsText(g) FROM gis_multi_line ORDER by fid; +fid AsText(g) +114 MULTILINESTRING((10 48,10 21,10 0),(16 0,16 23,16 48)) +115 MULTILINESTRING((10 48,10 21,10 0)) +116 MULTILINESTRING((1 2,3 5),(2 5,5 8,21 7)) +SELECT fid, AsText(g) FROM gis_multi_polygon ORDER by fid; +fid AsText(g) +117 MULTIPOLYGON(((28 26,28 0,84 0,84 42,28 26),(52 18,66 23,73 9,48 6,52 18)),((59 18,67 18,67 13,59 13,59 18))) +118 MULTIPOLYGON(((28 26,28 0,84 0,84 42,28 26),(52 18,66 23,73 9,48 6,52 18)),((59 18,67 18,67 13,59 13,59 18))) +119 MULTIPOLYGON(((0 3,3 3,3 0,0 3))) +SELECT fid, AsText(g) FROM gis_geometrycollection ORDER by fid; +fid AsText(g) +120 GEOMETRYCOLLECTION(POINT(0 0),LINESTRING(0 0,10 10)) +121 GEOMETRYCOLLECTION(POINT(44 6),LINESTRING(3 6,7 9)) +SELECT fid, AsText(g) FROM gis_geometry ORDER by fid; +fid AsText(g) +101 POINT(10 10) +102 POINT(20 10) +103 POINT(20 20) +104 POINT(10 20) +105 LINESTRING(0 0,0 10,10 0) +106 LINESTRING(10 10,20 10,20 20,10 20,10 10) +107 LINESTRING(10 10,40 10) +108 POLYGON((10 10,20 10,20 20,10 20,10 10)) +109 POLYGON((0 0,50 0,50 50,0 50,0 0),(10 10,20 10,20 20,10 20,10 10)) +110 POLYGON((0 0,30 0,30 30,0 0)) +111 MULTIPOINT(0 0,10 10,10 20,20 20) +112 MULTIPOINT(1 1,11 11,11 21,21 21) +113 MULTIPOINT(3 6,4 10) +114 MULTILINESTRING((10 48,10 21,10 0),(16 0,16 23,16 48)) +115 MULTILINESTRING((10 48,10 21,10 0)) +116 MULTILINESTRING((1 2,3 5),(2 5,5 8,21 7)) +117 MULTIPOLYGON(((28 26,28 0,84 0,84 42,28 26),(52 18,66 23,73 9,48 6,52 18)),((59 18,67 18,67 13,59 13,59 18))) +118 MULTIPOLYGON(((28 26,28 0,84 0,84 42,28 26),(52 18,66 23,73 9,48 6,52 18)),((59 18,67 18,67 13,59 13,59 18))) +119 MULTIPOLYGON(((0 3,3 3,3 0,0 3))) +120 GEOMETRYCOLLECTION(POINT(0 0),LINESTRING(0 0,10 10)) +121 GEOMETRYCOLLECTION(POINT(44 6),LINESTRING(3 6,7 9)) +SELECT fid, Dimension(g) FROM gis_geometry ORDER by fid; +fid Dimension(g) +101 0 +102 0 +103 0 +104 0 +105 1 +106 1 +107 1 +108 2 +109 2 +110 2 +111 0 +112 0 +113 0 +114 1 +115 1 +116 1 +117 2 +118 2 +119 2 +120 1 +121 1 +SELECT fid, GeometryType(g) FROM gis_geometry ORDER by fid; +fid GeometryType(g) +101 POINT +102 POINT +103 POINT +104 POINT +105 LINESTRING +106 LINESTRING +107 LINESTRING +108 POLYGON +109 POLYGON +110 POLYGON +111 MULTIPOINT +112 MULTIPOINT +113 MULTIPOINT +114 MULTILINESTRING +115 MULTILINESTRING +116 MULTILINESTRING +117 MULTIPOLYGON +118 MULTIPOLYGON +119 MULTIPOLYGON +120 GEOMETRYCOLLECTION +121 GEOMETRYCOLLECTION +SELECT fid, IsEmpty(g) FROM gis_geometry ORDER by fid; +fid IsEmpty(g) +101 0 +102 0 +103 0 +104 0 +105 0 +106 0 +107 0 +108 0 +109 0 +110 0 +111 0 +112 0 +113 0 +114 0 +115 0 +116 0 +117 0 +118 0 +119 0 +120 0 +121 0 +SELECT fid, AsText(Envelope(g)) FROM gis_geometry ORDER by fid; +fid AsText(Envelope(g)) +101 POLYGON((10 10,10 10,10 10,10 10,10 10)) +102 POLYGON((20 10,20 10,20 10,20 10,20 10)) +103 POLYGON((20 20,20 20,20 20,20 20,20 20)) +104 POLYGON((10 20,10 20,10 20,10 20,10 20)) +105 POLYGON((0 0,10 0,10 10,0 10,0 0)) +106 POLYGON((10 10,20 10,20 20,10 20,10 10)) +107 POLYGON((10 10,40 10,40 10,10 10,10 10)) +108 POLYGON((10 10,20 10,20 20,10 20,10 10)) +109 POLYGON((0 0,50 0,50 50,0 50,0 0)) +110 POLYGON((0 0,30 0,30 30,0 30,0 0)) +111 POLYGON((0 0,20 0,20 20,0 20,0 0)) +112 POLYGON((1 1,21 1,21 21,1 21,1 1)) +113 POLYGON((3 6,4 6,4 10,3 10,3 6)) +114 POLYGON((10 0,16 0,16 48,10 48,10 0)) +115 POLYGON((10 0,10 0,10 48,10 48,10 0)) +116 POLYGON((1 2,21 2,21 8,1 8,1 2)) +117 POLYGON((28 0,84 0,84 42,28 42,28 0)) +118 POLYGON((28 0,84 0,84 42,28 42,28 0)) +119 POLYGON((0 0,3 0,3 3,0 3,0 0)) +120 POLYGON((0 0,10 0,10 10,0 10,0 0)) +121 POLYGON((3 6,44 6,44 9,3 9,3 6)) +explain extended select Dimension(g), GeometryType(g), IsEmpty(g), AsText(Envelope(g)) from gis_geometry; +id select_type table type possible_keys key key_len ref rows filtered Extra +1 SIMPLE gis_geometry ALL NULL NULL NULL NULL 21 100.00 +Warnings: +Note 1003 select dimension(`test`.`gis_geometry`.`g`) AS `Dimension(g)`,geometrytype(`test`.`gis_geometry`.`g`) AS `GeometryType(g)`,isempty(`test`.`gis_geometry`.`g`) AS `IsEmpty(g)`,astext(envelope(`test`.`gis_geometry`.`g`)) AS `AsText(Envelope(g))` from `test`.`gis_geometry` +SELECT fid, X(g) FROM gis_point ORDER by fid; +fid X(g) +101 10 +102 20 +103 20 +104 10 +SELECT fid, Y(g) FROM gis_point ORDER by fid; +fid Y(g) +101 10 +102 10 +103 20 +104 20 +explain extended select X(g),Y(g) FROM gis_point; +id select_type table type possible_keys key key_len ref rows filtered Extra +1 SIMPLE gis_point ALL NULL NULL NULL NULL 4 100.00 +Warnings: +Note 1003 select x(`test`.`gis_point`.`g`) AS `X(g)`,y(`test`.`gis_point`.`g`) AS `Y(g)` from `test`.`gis_point` +SELECT fid, AsText(StartPoint(g)) FROM gis_line ORDER by fid; +fid AsText(StartPoint(g)) +105 POINT(0 0) +106 POINT(10 10) +107 POINT(10 10) +SELECT fid, AsText(EndPoint(g)) FROM gis_line ORDER by fid; +fid AsText(EndPoint(g)) +105 POINT(10 0) +106 POINT(10 10) +107 POINT(40 10) +SELECT fid, GLength(g) FROM gis_line ORDER by fid; +fid GLength(g) +105 24.142135623731 +106 40 +107 30 +SELECT fid, NumPoints(g) FROM gis_line ORDER by fid; +fid NumPoints(g) +105 3 +106 5 +107 2 +SELECT fid, AsText(PointN(g, 2)) FROM gis_line ORDER by fid; +fid AsText(PointN(g, 2)) +105 POINT(0 10) +106 POINT(20 10) +107 POINT(40 10) +SELECT fid, IsClosed(g) FROM gis_line ORDER by fid; +fid IsClosed(g) +105 0 +106 1 +107 0 +explain extended select AsText(StartPoint(g)),AsText(EndPoint(g)),GLength(g),NumPoints(g),AsText(PointN(g, 2)),IsClosed(g) FROM gis_line; +id select_type table type possible_keys key key_len ref rows filtered Extra +1 SIMPLE gis_line ALL NULL NULL NULL NULL 3 100.00 +Warnings: +Note 1003 select astext(startpoint(`test`.`gis_line`.`g`)) AS `AsText(StartPoint(g))`,astext(endpoint(`test`.`gis_line`.`g`)) AS `AsText(EndPoint(g))`,glength(`test`.`gis_line`.`g`) AS `GLength(g)`,numpoints(`test`.`gis_line`.`g`) AS `NumPoints(g)`,astext(pointn(`test`.`gis_line`.`g`,2)) AS `AsText(PointN(g, 2))`,isclosed(`test`.`gis_line`.`g`) AS `IsClosed(g)` from `test`.`gis_line` +SELECT fid, AsText(Centroid(g)) FROM gis_polygon ORDER by fid; +fid AsText(Centroid(g)) +108 POINT(15 15) +109 POINT(25.416666666667 25.416666666667) +110 POINT(20 10) +SELECT fid, Area(g) FROM gis_polygon ORDER by fid; +fid Area(g) +108 100 +109 2400 +110 450 +SELECT fid, AsText(ExteriorRing(g)) FROM gis_polygon ORDER by fid; +fid AsText(ExteriorRing(g)) +108 LINESTRING(10 10,20 10,20 20,10 20,10 10) +109 LINESTRING(0 0,50 0,50 50,0 50,0 0) +110 LINESTRING(0 0,30 0,30 30,0 0) +SELECT fid, NumInteriorRings(g) FROM gis_polygon ORDER by fid; +fid NumInteriorRings(g) +108 0 +109 1 +110 0 +SELECT fid, AsText(InteriorRingN(g, 1)) FROM gis_polygon ORDER by fid; +fid AsText(InteriorRingN(g, 1)) +108 NULL +109 LINESTRING(10 10,20 10,20 20,10 20,10 10) +110 NULL +explain extended select AsText(Centroid(g)),Area(g),AsText(ExteriorRing(g)),NumInteriorRings(g),AsText(InteriorRingN(g, 1)) FROM gis_polygon; +id select_type table type possible_keys key key_len ref rows filtered Extra +1 SIMPLE gis_polygon ALL NULL NULL NULL NULL 3 100.00 +Warnings: +Note 1003 select astext(centroid(`test`.`gis_polygon`.`g`)) AS `AsText(Centroid(g))`,area(`test`.`gis_polygon`.`g`) AS `Area(g)`,astext(exteriorring(`test`.`gis_polygon`.`g`)) AS `AsText(ExteriorRing(g))`,numinteriorrings(`test`.`gis_polygon`.`g`) AS `NumInteriorRings(g)`,astext(interiorringn(`test`.`gis_polygon`.`g`,1)) AS `AsText(InteriorRingN(g, 1))` from `test`.`gis_polygon` +SELECT fid, IsClosed(g) FROM gis_multi_line ORDER by fid; +fid IsClosed(g) +114 0 +115 0 +116 0 +SELECT fid, AsText(Centroid(g)) FROM gis_multi_polygon ORDER by fid; +fid AsText(Centroid(g)) +117 POINT(55.588527753042 17.426536064114) +118 POINT(55.588527753042 17.426536064114) +119 POINT(2 2) +SELECT fid, Area(g) FROM gis_multi_polygon ORDER by fid; +fid Area(g) +117 1684.5 +118 1684.5 +119 4.5 +SELECT fid, NumGeometries(g) from gis_multi_point ORDER by fid; +fid NumGeometries(g) +111 4 +112 4 +113 2 +SELECT fid, NumGeometries(g) from gis_multi_line ORDER by fid; +fid NumGeometries(g) +114 2 +115 1 +116 2 +SELECT fid, NumGeometries(g) from gis_multi_polygon ORDER by fid; +fid NumGeometries(g) +117 2 +118 2 +119 1 +SELECT fid, NumGeometries(g) from gis_geometrycollection ORDER by fid; +fid NumGeometries(g) +120 2 +121 2 +explain extended SELECT fid, NumGeometries(g) from gis_multi_point; +id select_type table type possible_keys key key_len ref rows filtered Extra +1 SIMPLE gis_multi_point ALL NULL NULL NULL NULL 3 100.00 +Warnings: +Note 1003 select `test`.`gis_multi_point`.`fid` AS `fid`,numgeometries(`test`.`gis_multi_point`.`g`) AS `NumGeometries(g)` from `test`.`gis_multi_point` +SELECT fid, AsText(GeometryN(g, 2)) from gis_multi_point ORDER by fid; +fid AsText(GeometryN(g, 2)) +111 POINT(10 10) +112 POINT(11 11) +113 POINT(4 10) +SELECT fid, AsText(GeometryN(g, 2)) from gis_multi_line ORDER by fid; +fid AsText(GeometryN(g, 2)) +114 LINESTRING(16 0,16 23,16 48) +115 NULL +116 LINESTRING(2 5,5 8,21 7) +SELECT fid, AsText(GeometryN(g, 2)) from gis_multi_polygon ORDER by fid; +fid AsText(GeometryN(g, 2)) +117 POLYGON((59 18,67 18,67 13,59 13,59 18)) +118 POLYGON((59 18,67 18,67 13,59 13,59 18)) +119 NULL +SELECT fid, AsText(GeometryN(g, 2)) from gis_geometrycollection ORDER by fid; +fid AsText(GeometryN(g, 2)) +120 LINESTRING(0 0,10 10) +121 LINESTRING(3 6,7 9) +SELECT fid, AsText(GeometryN(g, 1)) from gis_geometrycollection ORDER by fid; +fid AsText(GeometryN(g, 1)) +120 POINT(0 0) +121 POINT(44 6) +explain extended SELECT fid, AsText(GeometryN(g, 2)) from gis_multi_point; +id select_type table type possible_keys key key_len ref rows filtered Extra +1 SIMPLE gis_multi_point ALL NULL NULL NULL NULL 3 100.00 +Warnings: +Note 1003 select `test`.`gis_multi_point`.`fid` AS `fid`,astext(geometryn(`test`.`gis_multi_point`.`g`,2)) AS `AsText(GeometryN(g, 2))` from `test`.`gis_multi_point` +SELECT g1.fid as first, g2.fid as second, +Within(g1.g, g2.g) as w, Contains(g1.g, g2.g) as c, Overlaps(g1.g, g2.g) as o, +Equals(g1.g, g2.g) as e, Disjoint(g1.g, g2.g) as d, Touches(g1.g, g2.g) as t, +Intersects(g1.g, g2.g) as i, Crosses(g1.g, g2.g) as r +FROM gis_geometrycollection g1, gis_geometrycollection g2 ORDER BY first, second; +first second w c o e d t i r +120 120 1 1 0 1 0 0 1 0 +120 121 0 0 1 0 0 0 1 0 +121 120 0 0 1 0 0 0 1 0 +121 121 1 1 0 1 0 0 1 0 +explain extended SELECT g1.fid as first, g2.fid as second, +Within(g1.g, g2.g) as w, Contains(g1.g, g2.g) as c, Overlaps(g1.g, g2.g) as o, +Equals(g1.g, g2.g) as e, Disjoint(g1.g, g2.g) as d, Touches(g1.g, g2.g) as t, +Intersects(g1.g, g2.g) as i, Crosses(g1.g, g2.g) as r +FROM gis_geometrycollection g1, gis_geometrycollection g2 ORDER BY first, second; +id select_type table type possible_keys key key_len ref rows filtered Extra +1 SIMPLE g1 ALL NULL NULL NULL NULL 2 100.00 Using temporary; Using filesort +1 SIMPLE g2 ALL NULL NULL NULL NULL 2 100.00 Using join buffer +Warnings: +Note 1003 select `test`.`g1`.`fid` AS `first`,`test`.`g2`.`fid` AS `second`,within(`test`.`g1`.`g`,`test`.`g2`.`g`) AS `w`,contains(`test`.`g1`.`g`,`test`.`g2`.`g`) AS `c`,overlaps(`test`.`g1`.`g`,`test`.`g2`.`g`) AS `o`,equals(`test`.`g1`.`g`,`test`.`g2`.`g`) AS `e`,disjoint(`test`.`g1`.`g`,`test`.`g2`.`g`) AS `d`,touches(`test`.`g1`.`g`,`test`.`g2`.`g`) AS `t`,intersects(`test`.`g1`.`g`,`test`.`g2`.`g`) AS `i`,crosses(`test`.`g1`.`g`,`test`.`g2`.`g`) AS `r` from `test`.`gis_geometrycollection` `g1` join `test`.`gis_geometrycollection` `g2` order by `test`.`g1`.`fid`,`test`.`g2`.`fid` +DROP TABLE gis_point, gis_line, gis_polygon, gis_multi_point, gis_multi_line, gis_multi_polygon, gis_geometrycollection, gis_geometry; +CREATE TABLE t1 ( +a INTEGER PRIMARY KEY AUTO_INCREMENT, +gp point, +ln linestring, +pg polygon, +mp multipoint, +mln multilinestring, +mpg multipolygon, +gc geometrycollection, +gm geometry +); +SHOW FIELDS FROM t1; +Field Type Null Key Default Extra +a int(11) NO PRI NULL auto_increment +gp point YES NULL +ln linestring YES NULL +pg polygon YES NULL +mp multipoint YES NULL +mln multilinestring YES NULL +mpg multipolygon YES NULL +gc geometrycollection YES NULL +gm geometry YES NULL +ALTER TABLE t1 ADD fid INT; +SHOW FIELDS FROM t1; +Field Type Null Key Default Extra +a int(11) NO PRI NULL auto_increment +gp point YES NULL +ln linestring YES NULL +pg polygon YES NULL +mp multipoint YES NULL +mln multilinestring YES NULL +mpg multipolygon YES NULL +gc geometrycollection YES NULL +gm geometry YES NULL +fid int(11) YES NULL +DROP TABLE t1; +create table t1 (pk integer primary key auto_increment, a geometry not null); +insert into t1 (a) values (GeomFromText('Point(1 2)')); +insert into t1 (a) values ('Garbage'); +ERROR 22003: Cannot get geometry object from data you send to the GEOMETRY field +insert IGNORE into t1 (a) values ('Garbage'); +ERROR 22003: Cannot get geometry object from data you send to the GEOMETRY field +drop table t1; +create table t1 (pk integer primary key auto_increment, fl geometry not null); +insert into t1 (fl) values (1); +ERROR 22003: Cannot get geometry object from data you send to the GEOMETRY field +insert into t1 (fl) values (1.11); +ERROR 22003: Cannot get geometry object from data you send to the GEOMETRY field +insert into t1 (fl) values ("qwerty"); +ERROR 22003: Cannot get geometry object from data you send to the GEOMETRY field +insert into t1 (fl) values (pointfromtext('point(1,1)')); +ERROR 23000: Column 'fl' cannot be null +drop table t1; +End of 4.1 tests +CREATE TABLE t1 (name VARCHAR(100), square GEOMETRY); +Warnings: +Error 1475 Table storage engine 'ndbcluster' does not support the create option 'Binlog of table with BLOB attribute and no PK' +INSERT INTO t1 VALUES("center", GeomFromText('POLYGON (( 0 0, 0 2, 2 2, 2 0, 0 0))')); +INSERT INTO t1 VALUES("small", GeomFromText('POLYGON (( 0 0, 0 1, 1 1, 1 0, 0 0))')); +INSERT INTO t1 VALUES("big", GeomFromText('POLYGON (( 0 0, 0 3, 3 3, 3 0, 0 0))')); +INSERT INTO t1 VALUES("up", GeomFromText('POLYGON (( 0 1, 0 3, 2 3, 2 1, 0 1))')); +INSERT INTO t1 VALUES("up2", GeomFromText('POLYGON (( 0 2, 0 4, 2 4, 2 2, 0 2))')); +INSERT INTO t1 VALUES("up3", GeomFromText('POLYGON (( 0 3, 0 5, 2 5, 2 3, 0 3))')); +INSERT INTO t1 VALUES("down", GeomFromText('POLYGON (( 0 -1, 0 1, 2 1, 2 -1, 0 -1))')); +INSERT INTO t1 VALUES("down2", GeomFromText('POLYGON (( 0 -2, 0 0, 2 0, 2 -2, 0 -2))')); +INSERT INTO t1 VALUES("down3", GeomFromText('POLYGON (( 0 -3, 0 -1, 2 -1, 2 -3, 0 -3))')); +INSERT INTO t1 VALUES("right", GeomFromText('POLYGON (( 1 0, 1 2, 3 2, 3 0, 1 0))')); +INSERT INTO t1 VALUES("right2", GeomFromText('POLYGON (( 2 0, 2 2, 4 2, 4 0, 2 0))')); +INSERT INTO t1 VALUES("right3", GeomFromText('POLYGON (( 3 0, 3 2, 5 2, 5 0, 3 0))')); +INSERT INTO t1 VALUES("left", GeomFromText('POLYGON (( -1 0, -1 2, 1 2, 1 0, -1 0))')); +INSERT INTO t1 VALUES("left2", GeomFromText('POLYGON (( -2 0, -2 2, 0 2, 0 0, -2 0))')); +INSERT INTO t1 VALUES("left3", GeomFromText('POLYGON (( -3 0, -3 2, -1 2, -1 0, -3 0))')); +SELECT GROUP_CONCAT(a2.name ORDER BY a2.name) AS mbrcontains FROM t1 a1 JOIN t1 a2 ON MBRContains( a1.square, a2.square) WHERE a1.name = "center" GROUP BY a1.name; +mbrcontains +center,small +SELECT GROUP_CONCAT(a2.name ORDER BY a2.name) AS mbrdisjoint FROM t1 a1 JOIN t1 a2 ON MBRDisjoint( a1.square, a2.square) WHERE a1.name = "center" GROUP BY a1.name; +mbrdisjoint +down3,left3,right3,up3 +SELECT GROUP_CONCAT(a2.name ORDER BY a2.name) AS mbrequal FROM t1 a1 JOIN t1 a2 ON MBREqual( a1.square, a2.square) WHERE a1.name = "center" GROUP BY a1.name; +mbrequal +center +SELECT GROUP_CONCAT(a2.name ORDER BY a2.name) AS mbrintersect FROM t1 a1 JOIN t1 a2 ON MBRIntersects( a1.square, a2.square) WHERE a1.name = "center" GROUP BY a1.name; +mbrintersect +big,center,down,down2,left,left2,right,right2,small,up,up2 +SELECT GROUP_CONCAT(a2.name ORDER BY a2.name) AS mbroverlaps FROM t1 a1 JOIN t1 a2 ON MBROverlaps( a1.square, a2.square) WHERE a1.name = "center" GROUP BY a1.name; +mbroverlaps +down,left,right,up +SELECT GROUP_CONCAT(a2.name ORDER BY a2.name) AS mbrtouches FROM t1 a1 JOIN t1 a2 ON MBRTouches( a1.square, a2.square) WHERE a1.name = "center" GROUP BY a1.name; +mbrtouches +down2,left2,right2,up2 +SELECT GROUP_CONCAT(a2.name ORDER BY a2.name) AS mbrwithin FROM t1 a1 JOIN t1 a2 ON MBRWithin( a1.square, a2.square) WHERE a1.name = "center" GROUP BY a1.name; +mbrwithin +big,center +SELECT GROUP_CONCAT(a2.name ORDER BY a2.name) AS contains FROM t1 a1 JOIN t1 a2 ON Contains( a1.square, a2.square) WHERE a1.name = "center" GROUP BY a1.name; +contains +center,small +SELECT GROUP_CONCAT(a2.name ORDER BY a2.name) AS disjoint FROM t1 a1 JOIN t1 a2 ON Disjoint( a1.square, a2.square) WHERE a1.name = "center" GROUP BY a1.name; +disjoint +down3,left3,right3,up3 +SELECT GROUP_CONCAT(a2.name ORDER BY a2.name) AS equals FROM t1 a1 JOIN t1 a2 ON Equals( a1.square, a2.square) WHERE a1.name = "center" GROUP BY a1.name; +equals +center +SELECT GROUP_CONCAT(a2.name ORDER BY a2.name) AS intersect FROM t1 a1 JOIN t1 a2 ON Intersects( a1.square, a2.square) WHERE a1.name = "center" GROUP BY a1.name; +intersect +big,center,down,down2,left,left2,right,right2,small,up,up2 +SELECT GROUP_CONCAT(a2.name ORDER BY a2.name) AS overlaps FROM t1 a1 JOIN t1 a2 ON Overlaps( a1.square, a2.square) WHERE a1.name = "center" GROUP BY a1.name; +overlaps +down,left,right,up +SELECT GROUP_CONCAT(a2.name ORDER BY a2.name) AS touches FROM t1 a1 JOIN t1 a2 ON Touches( a1.square, a2.square) WHERE a1.name = "center" GROUP BY a1.name; +touches +down2,left2,right2,up2 +SELECT GROUP_CONCAT(a2.name ORDER BY a2.name) AS within FROM t1 a1 JOIN t1 a2 ON Within( a1.square, a2.square) WHERE a1.name = "center" GROUP BY a1.name; +within +big,center +SET @vert1 = GeomFromText('POLYGON ((0 -2, 0 2, 0 -2))'); +SET @horiz1 = GeomFromText('POLYGON ((-2 0, 2 0, -2 0))'); +SET @horiz2 = GeomFromText('POLYGON ((-1 0, 3 0, -1 0))'); +SET @horiz3 = GeomFromText('POLYGON ((2 0, 3 0, 2 0))'); +SET @point1 = GeomFromText('POLYGON ((0 0))'); +SET @point2 = GeomFromText('POLYGON ((-2 0))'); +SELECT GROUP_CONCAT(a1.name ORDER BY a1.name) AS overlaps FROM t1 a1 WHERE Overlaps(a1.square, @vert1) GROUP BY a1.name; +overlaps +SELECT GROUP_CONCAT(a1.name ORDER BY a1.name) AS overlaps FROM t1 a1 WHERE Overlaps(a1.square, @horiz1) GROUP BY a1.name; +overlaps +SELECT Overlaps(@horiz1, @vert1) FROM DUAL; +Overlaps(@horiz1, @vert1) +0 +SELECT Overlaps(@horiz1, @horiz2) FROM DUAL; +Overlaps(@horiz1, @horiz2) +1 +SELECT Overlaps(@horiz1, @horiz3) FROM DUAL; +Overlaps(@horiz1, @horiz3) +0 +SELECT Overlaps(@horiz1, @point1) FROM DUAL; +Overlaps(@horiz1, @point1) +0 +SELECT Overlaps(@horiz1, @point2) FROM DUAL; +Overlaps(@horiz1, @point2) +0 +DROP TABLE t1; +End of 5.0 tests diff --git a/mysql-test/suite/ndb/r/ndb_grant.result b/mysql-test/suite/ndb/r/ndb_grant.result new file mode 100644 index 00000000000..6192a7cace5 --- /dev/null +++ b/mysql-test/suite/ndb/r/ndb_grant.result @@ -0,0 +1,444 @@ +drop table if exists t1; +SET NAMES binary; +use mysql; +alter table columns_priv engine=ndb; +alter table db engine=ndb; +alter table func engine=ndb; +alter table help_category engine=ndb; +alter table help_keyword engine=ndb; +alter table help_relation engine=ndb; +alter table help_topic engine=ndb; +alter table host engine=ndb; +alter table tables_priv engine=ndb; +alter table time_zone engine=ndb; +alter table time_zone_leap_second engine=ndb; +alter table time_zone_name engine=ndb; +alter table time_zone_transition engine=ndb; +alter table time_zone_transition_type engine=ndb; +alter table user engine=ndb; +use test; +delete from mysql.user where user='mysqltest_1'; +delete from mysql.db where user='mysqltest_1'; +flush privileges; +begin; +grant select on mysqltest.* to mysqltest_1@localhost require cipher "EDH-RSA-DES-CBC3-SHA"; +commit; +show grants for mysqltest_1@localhost; +Grants for mysqltest_1@localhost +GRANT USAGE ON *.* TO 'mysqltest_1'@'localhost' REQUIRE CIPHER 'EDH-RSA-DES-CBC3-SHA' +GRANT SELECT ON `mysqltest`.* TO 'mysqltest_1'@'localhost' +begin; +grant delete on mysqltest.* to mysqltest_1@localhost; +commit; +select * from mysql.user where user="mysqltest_1"; +Host User Password Select_priv Insert_priv Update_priv Delete_priv Create_priv Drop_priv Reload_priv Shutdown_priv Process_priv File_priv Grant_priv References_priv Index_priv Alter_priv Show_db_priv Super_priv Create_tmp_table_priv Lock_tables_priv Execute_priv Repl_slave_priv Repl_client_priv Create_view_priv Show_view_priv ssl_type ssl_cipher x509_issuer x509_subject max_questions max_updates max_connections +localhost mysqltest_1 N N N N N N N N N N N N N N N N N N N N N 0 0 0 +show grants for mysqltest_1@localhost; +Grants for mysqltest_1@localhost +GRANT USAGE ON *.* TO 'mysqltest_1'@'localhost' REQUIRE CIPHER 'EDH-RSA-DES-CBC3-SHA' +GRANT SELECT, DELETE ON `mysqltest`.* TO 'mysqltest_1'@'localhost' +begin; +revoke delete on mysqltest.* from mysqltest_1@localhost; +commit; +show grants for mysqltest_1@localhost; +Grants for mysqltest_1@localhost +GRANT USAGE ON *.* TO 'mysqltest_1'@'localhost' REQUIRE CIPHER 'EDH-RSA-DES-CBC3-SHA' +GRANT SELECT ON `mysqltest`.* TO 'mysqltest_1'@'localhost' +begin; +grant select on mysqltest.* to mysqltest_1@localhost require NONE; +commit; +show grants for mysqltest_1@localhost; +Grants for mysqltest_1@localhost +GRANT USAGE ON *.* TO 'mysqltest_1'@'localhost' +GRANT SELECT ON `mysqltest`.* TO 'mysqltest_1'@'localhost' +begin; +grant USAGE on mysqltest.* to mysqltest_1@localhost require cipher "EDH-RSA-DES-CBC3-SHA" AND SUBJECT "testsubject" ISSUER "MySQL AB"; +commit; +show grants for mysqltest_1@localhost; +Grants for mysqltest_1@localhost +GRANT USAGE ON *.* TO 'mysqltest_1'@'localhost' REQUIRE ISSUER 'MySQL AB' SUBJECT 'testsubject' CIPHER 'EDH-RSA-DES-CBC3-SHA' +GRANT SELECT ON `mysqltest`.* TO 'mysqltest_1'@'localhost' +begin; +revoke all privileges on mysqltest.* from mysqltest_1@localhost; +commit; +show grants for mysqltest_1@localhost; +Grants for mysqltest_1@localhost +GRANT USAGE ON *.* TO 'mysqltest_1'@'localhost' REQUIRE ISSUER 'MySQL AB' SUBJECT 'testsubject' CIPHER 'EDH-RSA-DES-CBC3-SHA' +delete from mysql.user where user='mysqltest_1'; +flush privileges; +begin; +grant CREATE TEMPORARY TABLES, LOCK TABLES on mysqltest.* to mysqltest_1@localhost; +commit; +show grants for mysqltest_1@localhost; +Grants for mysqltest_1@localhost +GRANT USAGE ON *.* TO 'mysqltest_1'@'localhost' +GRANT CREATE TEMPORARY TABLES, LOCK TABLES ON `mysqltest`.* TO 'mysqltest_1'@'localhost' +flush privileges; +show grants for mysqltest_1@localhost; +Grants for mysqltest_1@localhost +GRANT USAGE ON *.* TO 'mysqltest_1'@'localhost' +GRANT CREATE TEMPORARY TABLES, LOCK TABLES ON `mysqltest`.* TO 'mysqltest_1'@'localhost' +begin; +revoke CREATE TEMPORARY TABLES on mysqltest.* from mysqltest_1@localhost; +commit; +show grants for mysqltest_1@localhost; +Grants for mysqltest_1@localhost +GRANT USAGE ON *.* TO 'mysqltest_1'@'localhost' +GRANT LOCK TABLES ON `mysqltest`.* TO 'mysqltest_1'@'localhost' +begin; +grant ALL PRIVILEGES on mysqltest.* to mysqltest_1@localhost with GRANT OPTION; +commit; +flush privileges; +show grants for mysqltest_1@localhost; +Grants for mysqltest_1@localhost +GRANT USAGE ON *.* TO 'mysqltest_1'@'localhost' +GRANT ALL PRIVILEGES ON `mysqltest`.* TO 'mysqltest_1'@'localhost' WITH GRANT OPTION +begin; +revoke LOCK TABLES, ALTER on mysqltest.* from mysqltest_1@localhost; +commit; +show grants for mysqltest_1@localhost; +Grants for mysqltest_1@localhost +GRANT USAGE ON *.* TO 'mysqltest_1'@'localhost' +GRANT SELECT, INSERT, UPDATE, DELETE, CREATE, DROP, REFERENCES, INDEX, CREATE TEMPORARY TABLES, CREATE VIEW, SHOW VIEW ON `mysqltest`.* TO 'mysqltest_1'@'localhost' WITH GRANT OPTION +begin; +revoke all privileges on mysqltest.* from mysqltest_1@localhost; +commit; +delete from mysql.user where user='mysqltest_1'; +flush privileges; +begin; +grant usage on test.* to mysqltest_1@localhost with grant option; +commit; +show grants for mysqltest_1@localhost; +Grants for mysqltest_1@localhost +GRANT USAGE ON *.* TO 'mysqltest_1'@'localhost' +GRANT USAGE ON `mysqltest`.* TO 'mysqltest_1'@'localhost' WITH GRANT OPTION +GRANT USAGE ON `test`.* TO 'mysqltest_1'@'localhost' WITH GRANT OPTION +delete from mysql.user where user='mysqltest_1'; +delete from mysql.db where user='mysqltest_1'; +delete from mysql.tables_priv where user='mysqltest_1'; +delete from mysql.columns_priv where user='mysqltest_1'; +flush privileges; +show grants for mysqltest_1@localhost; +ERROR 42000: There is no such grant defined for user 'mysqltest_1' on host 'localhost' +create table t1 (a int); +begin; +GRANT select,update,insert on t1 to mysqltest_1@localhost; +GRANT select (a), update (a),insert(a), references(a) on t1 to mysqltest_1@localhost; +commit; +show grants for mysqltest_1@localhost; +Grants for mysqltest_1@localhost +GRANT USAGE ON *.* TO 'mysqltest_1'@'localhost' +GRANT SELECT, SELECT (a), INSERT, INSERT (a), UPDATE, UPDATE (a), REFERENCES (a) ON `test`.`t1` TO 'mysqltest_1'@'localhost' +select table_priv,column_priv from mysql.tables_priv where user="mysqltest_1"; +table_priv column_priv +Select,Insert,Update Select,Insert,Update,References +begin; +REVOKE select (a), update on t1 from mysqltest_1@localhost; +commit; +show grants for mysqltest_1@localhost; +Grants for mysqltest_1@localhost +GRANT USAGE ON *.* TO 'mysqltest_1'@'localhost' +GRANT SELECT, INSERT, INSERT (a), REFERENCES (a) ON `test`.`t1` TO 'mysqltest_1'@'localhost' +begin; +REVOKE select,update,insert,insert (a) on t1 from mysqltest_1@localhost; +commit; +show grants for mysqltest_1@localhost; +Grants for mysqltest_1@localhost +GRANT USAGE ON *.* TO 'mysqltest_1'@'localhost' +GRANT REFERENCES (a) ON `test`.`t1` TO 'mysqltest_1'@'localhost' +begin; +GRANT select,references on t1 to mysqltest_1@localhost; +commit; +select table_priv,column_priv from mysql.tables_priv where user="mysqltest_1"; +table_priv column_priv +Select,References References +begin; +grant all on test.* to mysqltest_3@localhost with grant option; +revoke all on test.* from mysqltest_3@localhost; +commit; +show grants for mysqltest_3@localhost; +Grants for mysqltest_3@localhost +GRANT USAGE ON *.* TO 'mysqltest_3'@'localhost' +GRANT USAGE ON `test`.* TO 'mysqltest_3'@'localhost' WITH GRANT OPTION +begin; +revoke grant option on test.* from mysqltest_3@localhost; +commit; +show grants for mysqltest_3@localhost; +Grants for mysqltest_3@localhost +GRANT USAGE ON *.* TO 'mysqltest_3'@'localhost' +begin; +grant all on test.t1 to mysqltest_2@localhost with grant option; +revoke all on test.t1 from mysqltest_2@localhost; +commit; +show grants for mysqltest_2@localhost; +Grants for mysqltest_2@localhost +GRANT USAGE ON *.* TO 'mysqltest_2'@'localhost' +GRANT USAGE ON `test`.`t1` TO 'mysqltest_2'@'localhost' WITH GRANT OPTION +begin; +revoke grant option on test.t1 from mysqltest_2@localhost; +commit; +show grants for mysqltest_2@localhost; +Grants for mysqltest_2@localhost +GRANT USAGE ON *.* TO 'mysqltest_2'@'localhost' +delete from mysql.user where user='mysqltest_1' or user="mysqltest_2" or user="mysqltest_3"; +delete from mysql.db where user='mysqltest_1' or user="mysqltest_2" or user="mysqltest_3"; +delete from mysql.tables_priv where user='mysqltest_1' or user="mysqltest_2" or user="mysqltest_3"; +delete from mysql.columns_priv where user='mysqltest_1' or user="mysqltest_2" or user="mysqltest_3"; +flush privileges; +drop table t1; +begin; +GRANT FILE on mysqltest.* to mysqltest_1@localhost; +ERROR HY000: Incorrect usage of DB GRANT and GLOBAL PRIVILEGES +commit; +select 1; +1 +1 +create database mysqltest1; +begin; +grant usage on mysqltest1.* to test6123 identified by 'magic123'; +commit; +select host,db,user,select_priv,insert_priv from mysql.db where db="mysqltest1"; +host db user select_priv insert_priv +delete from mysql.user where user='test6123'; +drop database mysqltest1; +create table t1 (a int); +begin; +grant ALL PRIVILEGES on *.* to drop_user2@localhost with GRANT OPTION; +commit; +show grants for drop_user2@localhost; +Grants for drop_user2@localhost +GRANT ALL PRIVILEGES ON *.* TO 'drop_user2'@'localhost' WITH GRANT OPTION +begin; +revoke all privileges, grant option from drop_user2@localhost; +commit; +drop user drop_user2@localhost; +begin; +grant ALL PRIVILEGES on *.* to drop_user@localhost with GRANT OPTION; +grant ALL PRIVILEGES on test.* to drop_user@localhost with GRANT OPTION; +grant select(a) on test.t1 to drop_user@localhost; +commit; +show grants for drop_user@localhost; +Grants for drop_user@localhost +GRANT ALL PRIVILEGES ON *.* TO 'drop_user'@'localhost' WITH GRANT OPTION +GRANT ALL PRIVILEGES ON `test`.* TO 'drop_user'@'localhost' WITH GRANT OPTION +GRANT SELECT (a) ON `test`.`t1` TO 'drop_user'@'localhost' +set sql_mode=ansi_quotes; +show grants for drop_user@localhost; +Grants for drop_user@localhost +GRANT ALL PRIVILEGES ON *.* TO 'drop_user'@'localhost' WITH GRANT OPTION +GRANT ALL PRIVILEGES ON "test".* TO 'drop_user'@'localhost' WITH GRANT OPTION +GRANT SELECT (a) ON "test"."t1" TO 'drop_user'@'localhost' +set sql_mode=default; +set sql_quote_show_create=0; +show grants for drop_user@localhost; +Grants for drop_user@localhost +GRANT ALL PRIVILEGES ON *.* TO 'drop_user'@'localhost' WITH GRANT OPTION +GRANT ALL PRIVILEGES ON test.* TO 'drop_user'@'localhost' WITH GRANT OPTION +GRANT SELECT (a) ON test.t1 TO 'drop_user'@'localhost' +set sql_mode="ansi_quotes"; +show grants for drop_user@localhost; +Grants for drop_user@localhost +GRANT ALL PRIVILEGES ON *.* TO 'drop_user'@'localhost' WITH GRANT OPTION +GRANT ALL PRIVILEGES ON test.* TO 'drop_user'@'localhost' WITH GRANT OPTION +GRANT SELECT (a) ON test.t1 TO 'drop_user'@'localhost' +set sql_quote_show_create=1; +show grants for drop_user@localhost; +Grants for drop_user@localhost +GRANT ALL PRIVILEGES ON *.* TO 'drop_user'@'localhost' WITH GRANT OPTION +GRANT ALL PRIVILEGES ON "test".* TO 'drop_user'@'localhost' WITH GRANT OPTION +GRANT SELECT (a) ON "test"."t1" TO 'drop_user'@'localhost' +set sql_mode=""; +show grants for drop_user@localhost; +Grants for drop_user@localhost +GRANT ALL PRIVILEGES ON *.* TO 'drop_user'@'localhost' WITH GRANT OPTION +GRANT ALL PRIVILEGES ON `test`.* TO 'drop_user'@'localhost' WITH GRANT OPTION +GRANT SELECT (a) ON `test`.`t1` TO 'drop_user'@'localhost' +revoke all privileges, grant option from drop_user@localhost; +show grants for drop_user@localhost; +Grants for drop_user@localhost +GRANT USAGE ON *.* TO 'drop_user'@'localhost' +drop user drop_user@localhost; +begin; +revoke all privileges, grant option from drop_user@localhost; +ERROR HY000: Can't revoke all privileges, grant for one or more of the requested users +commit; +begin; +grant select(a) on test.t1 to drop_user1@localhost; +commit; +flush privileges; +begin; +grant select on test.t1 to drop_user2@localhost; +grant select on test.* to drop_user3@localhost; +grant select on *.* to drop_user4@localhost; +commit; +flush privileges; +drop user drop_user1@localhost, drop_user2@localhost, drop_user3@localhost, +drop_user4@localhost; +begin; +revoke all privileges, grant option from drop_user1@localhost, drop_user2@localhost, +drop_user3@localhost, drop_user4@localhost; +ERROR HY000: Can't revoke all privileges, grant for one or more of the requested users +commit; +flush privileges; +drop user drop_user1@localhost, drop_user2@localhost, drop_user3@localhost, +drop_user4@localhost; +drop table t1; +begin; +grant usage on *.* to mysqltest_1@localhost identified by "password"; +grant select, update, insert on test.* to mysqltest_1@localhost; +commit; +show grants for mysqltest_1@localhost; +Grants for mysqltest_1@localhost +GRANT USAGE ON *.* TO 'mysqltest_1'@'localhost' IDENTIFIED BY PASSWORD '*2470C0C06DEE42FD1618BB99005ADCA2EC9D1E19' +GRANT SELECT, INSERT, UPDATE ON `test`.* TO 'mysqltest_1'@'localhost' +drop user mysqltest_1@localhost; +SET NAMES koi8r; +CREATE DATABASE ÂÄ; +USE ÂÄ; +CREATE TABLE ÔÁ (ËÏÌ int); +begin; +GRANT SELECT ON ÂÄ.* TO ÀÚÅÒ@localhost; +commit; +SHOW GRANTS FOR ÀÚÅÒ@localhost; +Grants for ÀÚÅÒ@localhost +GRANT USAGE ON *.* TO 'ÀÚÅÒ'@'localhost' +GRANT SELECT ON `ÂÄ`.* TO 'ÀÚÅÒ'@'localhost' +begin; +REVOKE SELECT ON ÂÄ.* FROM ÀÚÅÒ@localhost; +commit; +begin; +GRANT SELECT ON ÂÄ.ÔÁ TO ÀÚÅÒ@localhost; +commit; +SHOW GRANTS FOR ÀÚÅÒ@localhost; +Grants for ÀÚÅÒ@localhost +GRANT USAGE ON *.* TO 'ÀÚÅÒ'@'localhost' +GRANT SELECT ON `ÂÄ`.`ÔÁÂ` TO 'ÀÚÅÒ'@'localhost' +begin; +REVOKE SELECT ON ÂÄ.ÔÁ FROM ÀÚÅÒ@localhost; +commit; +begin; +GRANT SELECT (ËÏÌ) ON ÂÄ.ÔÁ TO ÀÚÅÒ@localhost; +commit; +SHOW GRANTS FOR ÀÚÅÒ@localhost; +Grants for ÀÚÅÒ@localhost +GRANT USAGE ON *.* TO 'ÀÚÅÒ'@'localhost' +GRANT SELECT (ËÏÌ) ON `ÂÄ`.`ÔÁÂ` TO 'ÀÚÅÒ'@'localhost' +begin; +REVOKE SELECT (ËÏÌ) ON ÂÄ.ÔÁ FROM ÀÚÅÒ@localhost; +commit; +DROP DATABASE ÂÄ; +SET NAMES latin1; +USE test; +CREATE TABLE t1 (a int ); +CREATE TABLE t2 LIKE t1; +CREATE TABLE t3 LIKE t1; +CREATE TABLE t4 LIKE t1; +CREATE TABLE t5 LIKE t1; +CREATE TABLE t6 LIKE t1; +CREATE TABLE t7 LIKE t1; +CREATE TABLE t8 LIKE t1; +CREATE TABLE t9 LIKE t1; +CREATE TABLE t10 LIKE t1; +CREATE DATABASE testdb1; +CREATE DATABASE testdb2; +CREATE DATABASE testdb3; +CREATE DATABASE testdb4; +CREATE DATABASE testdb5; +CREATE DATABASE testdb6; +CREATE DATABASE testdb7; +CREATE DATABASE testdb8; +CREATE DATABASE testdb9; +CREATE DATABASE testdb10; +begin; +GRANT ALL ON testdb1.* TO testuser@localhost; +GRANT ALL ON testdb2.* TO testuser@localhost; +GRANT ALL ON testdb3.* TO testuser@localhost; +GRANT ALL ON testdb4.* TO testuser@localhost; +GRANT ALL ON testdb5.* TO testuser@localhost; +GRANT ALL ON testdb6.* TO testuser@localhost; +GRANT ALL ON testdb7.* TO testuser@localhost; +GRANT ALL ON testdb8.* TO testuser@localhost; +GRANT ALL ON testdb9.* TO testuser@localhost; +GRANT ALL ON testdb10.* TO testuser@localhost; +GRANT SELECT ON test.t1 TO testuser@localhost; +GRANT SELECT ON test.t2 TO testuser@localhost; +GRANT SELECT ON test.t3 TO testuser@localhost; +GRANT SELECT ON test.t4 TO testuser@localhost; +GRANT SELECT ON test.t5 TO testuser@localhost; +GRANT SELECT ON test.t6 TO testuser@localhost; +GRANT SELECT ON test.t7 TO testuser@localhost; +GRANT SELECT ON test.t8 TO testuser@localhost; +GRANT SELECT ON test.t9 TO testuser@localhost; +GRANT SELECT ON test.t10 TO testuser@localhost; +GRANT SELECT (a) ON test.t1 TO testuser@localhost; +GRANT SELECT (a) ON test.t2 TO testuser@localhost; +GRANT SELECT (a) ON test.t3 TO testuser@localhost; +GRANT SELECT (a) ON test.t4 TO testuser@localhost; +GRANT SELECT (a) ON test.t5 TO testuser@localhost; +GRANT SELECT (a) ON test.t6 TO testuser@localhost; +GRANT SELECT (a) ON test.t7 TO testuser@localhost; +GRANT SELECT (a) ON test.t8 TO testuser@localhost; +GRANT SELECT (a) ON test.t9 TO testuser@localhost; +GRANT SELECT (a) ON test.t10 TO testuser@localhost; +commit; +begin; +REVOKE ALL PRIVILEGES, GRANT OPTION FROM testuser@localhost; +commit; +SHOW GRANTS FOR testuser@localhost; +Grants for testuser@localhost +GRANT USAGE ON *.* TO 'testuser'@'localhost' +DROP USER testuser@localhost; +DROP TABLE t1,t2,t3,t4,t5,t6,t7,t8,t9,t10; +DROP DATABASE testdb1; +DROP DATABASE testdb2; +DROP DATABASE testdb3; +DROP DATABASE testdb4; +DROP DATABASE testdb5; +DROP DATABASE testdb6; +DROP DATABASE testdb7; +DROP DATABASE testdb8; +DROP DATABASE testdb9; +DROP DATABASE testdb10; +SHOW PRIVILEGES; +Privilege Context Comment +Alter Tables To alter the table +Create Databases,Tables,Indexes To create new databases and tables +Create temporary tables Databases To use CREATE TEMPORARY TABLE +Create view Tables To create new views +Delete Tables To delete existing rows +Drop Databases,Tables To drop databases, tables, and views +File File access on server To read and write files on the server +Grant option Databases,Tables To give to other users those privileges you possess +Index Tables To create or drop indexes +Insert Tables To insert data into tables +Lock tables Databases To use LOCK TABLES (together with SELECT privilege) +Process Server Admin To view the plain text of currently executing queries +References Databases,Tables To have references on tables +Reload Server Admin To reload or refresh tables, logs and privileges +Replication client Server Admin To ask where the slave or master servers are +Replication slave Server Admin To read binary log events from the master +Select Tables To retrieve rows from table +Show databases Server Admin To see all databases with SHOW DATABASES +Show view Tables To see views with SHOW CREATE VIEW +Shutdown Server Admin To shut down the server +Super Server Admin To use KILL thread, SET GLOBAL, CHANGE MASTER, etc. +Update Tables To update existing rows +Usage Server Admin No privileges - allow connect only +use mysql; +alter table columns_priv engine=myisam; +alter table db engine=myisam; +alter table func engine=myisam; +alter table help_category engine=myisam; +alter table help_keyword engine=myisam; +alter table help_relation engine=myisam; +alter table help_topic engine=myisam; +alter table host engine=myisam; +alter table tables_priv engine=myisam; +alter table time_zone engine=myisam; +alter table time_zone_leap_second engine=myisam; +alter table time_zone_name engine=myisam; +alter table time_zone_transition engine=myisam; +alter table time_zone_transition_type engine=myisam; +alter table user engine=myisam; +use test; +flush privileges; diff --git a/mysql-test/suite/ndb/r/ndb_index.result b/mysql-test/suite/ndb/r/ndb_index.result new file mode 100644 index 00000000000..5702552b0b5 --- /dev/null +++ b/mysql-test/suite/ndb/r/ndb_index.result @@ -0,0 +1,154 @@ +drop table if exists t1; +CREATE TABLE t1 ( +PORT varchar(16) NOT NULL, +ACCESSNODE varchar(16) NOT NULL, +POP varchar(48) NOT NULL, +ACCESSTYPE int unsigned NOT NULL, +CUSTOMER_ID varchar(20) collate latin1_bin NOT NULL, +PROVIDER varchar(16), +TEXPIRE int unsigned, +NUM_IP int unsigned, +LEASED_NUM_IP int unsigned, +LOCKED_IP int unsigned, +STATIC_DNS int unsigned, +SUSPENDED_SERVICE int unsigned, +SUSPENDED_REASON int unsigned, +BGP_COMMUNITY int unsigned, +INDEX CUSTOMER_ID_INDEX(CUSTOMER_ID), +INDEX FQPN_INDEX(POP,ACCESSNODE,PORT), +PRIMARY KEY(POP,ACCESSNODE,PORT,ACCESSTYPE) +) engine=ndbcluster; +INSERT INTO t1 VALUES ('port67', 'node78', 'pop98', 1, 'kllopmn', 'pr_43', 121212, 1, 2, 3, 8, NULL, NULL, NULL); +INSERT INTO t1 VALUES ('port67', 'node78', 'pop99', 2, 'klkighh', 'pr_44', 121213, 3, 3, 6, 7, NULL, NULL, NULL); +INSERT INTO t1 VALUES ('port79', 'node79', 'pop79', 2, 'kpongfaa', 'pr_44', 981213, 2, 4, 10, 11, 2, 99, 1278); +select port, accessnode, pop, accesstype from t1 where port='port67' order by accesstype; +port accessnode pop accesstype +port67 node78 pop98 1 +port67 node78 pop99 2 +select port, accessnode, pop, accesstype from t1 where port='foo'; +port accessnode pop accesstype +select port, accessnode, pop, accesstype from t1 where accessnode='node78' order by accesstype; +port accessnode pop accesstype +port67 node78 pop98 1 +port67 node78 pop99 2 +select port, accessnode, pop, accesstype from t1 where accessnode='foo'; +port accessnode pop accesstype +select port, accessnode, pop, accesstype from t1 where pop='pop98'; +port accessnode pop accesstype +port67 node78 pop98 1 +select port, accessnode, pop, accesstype from t1 where pop='pop98'; +port accessnode pop accesstype +port67 node78 pop98 1 +select port, accessnode, pop, accesstype from t1 where pop='pop98'; +port accessnode pop accesstype +port67 node78 pop98 1 +select port, accessnode, pop, accesstype from t1 where pop='pop98' order by accesstype; +port accessnode pop accesstype +port67 node78 pop98 1 +select port, accessnode, pop, accesstype from t1 where pop='foo'; +port accessnode pop accesstype +select port, accessnode, pop, accesstype from t1 where accesstype=1; +port accessnode pop accesstype +port67 node78 pop98 1 +select port, accessnode, pop, accesstype from t1 where accesstype=2 order by port; +port accessnode pop accesstype +port67 node78 pop99 2 +port79 node79 pop79 2 +select port, accessnode, pop, accesstype from t1 where accesstype=98 order by port; +port accessnode pop accesstype +select port, accessnode, pop, accesstype from t1 where customer_id='kllopmn'; +port accessnode pop accesstype +port67 node78 pop98 1 +select port, accessnode, pop, accesstype from t1 where customer_id='KLLOPMN'; +port accessnode pop accesstype +select port, accessnode, pop, accesstype from t1 where customer_id='kLLoPMn'; +port accessnode pop accesstype +select port, accessnode, pop, accesstype from t1 where customer_id='foo'; +port accessnode pop accesstype +select port, accessnode, pop, accesstype from t1 where provider='pr_43'; +port accessnode pop accesstype +port67 node78 pop98 1 +select port, accessnode, pop, accesstype from t1 where provider='foo'; +port accessnode pop accesstype +select port, accessnode from t1 where texpire=121212; +port accessnode +port67 node78 +select port, accessnode from t1 where texpire=2323; +port accessnode +select port, accessnode, pop, accesstype from t1 where num_ip=1; +port accessnode pop accesstype +port67 node78 pop98 1 +select port, accessnode, pop, accesstype from t1 where num_ip=89; +port accessnode pop accesstype +select port, accessnode, pop, accesstype from t1 where leased_num_ip=2; +port accessnode pop accesstype +port67 node78 pop98 1 +select port, accessnode, pop, accesstype from t1 where leased_num_ip=89; +port accessnode pop accesstype +select port, accessnode, pop, accesstype from t1 where locked_ip=3; +port accessnode pop accesstype +port67 node78 pop98 1 +select port, accessnode, pop, accesstype from t1 where locked_ip=89; +port accessnode pop accesstype +select port, accessnode, pop, accesstype from t1 where static_dns=8; +port accessnode pop accesstype +port67 node78 pop98 1 +select port, accessnode, pop, accesstype from t1 where static_dns=89; +port accessnode pop accesstype +select port, accessnode, pop, accesstype from t1 where suspended_service=8; +port accessnode pop accesstype +select port, accessnode, pop, accesstype from t1 where suspended_service=89; +port accessnode pop accesstype +select port, accessnode, pop, accesstype from t1 where suspended_reason=NULL; +port accessnode pop accesstype +select port, accessnode, pop, accesstype from t1 where suspended_reason=89; +port accessnode pop accesstype +select port, accessnode, pop, accesstype from t1 where suspended_reason=0; +port accessnode pop accesstype +select port, accessnode, pop, accesstype from t1 where bgp_community=NULL; +port accessnode pop accesstype +select port, accessnode, pop, accesstype from t1 where bgp_community=89; +port accessnode pop accesstype +select port, accessnode, pop, accesstype from t1 where bgp_community=0; +port accessnode pop accesstype +select port, accessnode, pop, accesstype from t1 where port='port67' and accessnode='node78' and pop='pop98' and accesstype=1; +port accessnode pop accesstype +port67 node78 pop98 1 +select port, accessnode, pop, accesstype from t1 where port='port67' and accesstype=1 and accessnode='node78' and pop='pop98'; +port accessnode pop accesstype +port67 node78 pop98 1 +select port, accessnode, pop, accesstype from t1 where pop='pop98' and port='port67' and accesstype=1 and accessnode='node78'; +port accessnode pop accesstype +port67 node78 pop98 1 +select port, accessnode from t1 where port='foo' and accessnode='foo' and pop='foo' and accesstype=99; +port accessnode +select port, accessnode, pop, accesstype from t1 where port='port67' and pop='pop98' and accesstype=1; +port accessnode pop accesstype +port67 node78 pop98 1 +select port, accessnode, pop, accesstype from t1 where accesstype=1 and accessnode='node78' and pop='pop98'; +port accessnode pop accesstype +port67 node78 pop98 1 +select port, accessnode, pop, accesstype from t1 where port='port67' and accesstype=1 and accessnode='node78'; +port accessnode pop accesstype +port67 node78 pop98 1 +select port, accessnode from t1 where port='foo' and accessnode='foo' and pop='foo'; +port accessnode +select port, accessnode, pop, accesstype from t1 where customer_id='kllopmn'; +port accessnode pop accesstype +port67 node78 pop98 1 +select port, accessnode, pop, accesstype from t1 where customer_id='kllopmn' and accesstype=1; +port accessnode pop accesstype +port67 node78 pop98 1 +select port, accessnode, pop, accesstype from t1 where customer_id='kllopmn' and accesstype=2; +port accessnode pop accesstype +select port, accessnode, pop, accesstype from t1 where accesstype=2 and customer_id='kllopmn'; +port accessnode pop accesstype +select port, accessnode, pop, accesstype from t1 where pop='pop98' and accessnode='node78' and port='port67'; +port accessnode pop accesstype +port67 node78 pop98 1 +select port, accessnode, pop, accesstype from t1 where pop='pop98' and accessnode='node78' and port='port67' and customer_id='kllopmn'; +port accessnode pop accesstype +port67 node78 pop98 1 +select port, accessnode, pop, accesstype from t1 where pop='pop98' and accessnode='node78' and port='port67' and customer_id='foo'; +port accessnode pop accesstype +drop table t1; diff --git a/mysql-test/suite/ndb/r/ndb_index_ordered.result b/mysql-test/suite/ndb/r/ndb_index_ordered.result new file mode 100644 index 00000000000..a29b5343d7c --- /dev/null +++ b/mysql-test/suite/ndb/r/ndb_index_ordered.result @@ -0,0 +1,854 @@ +drop table if exists t1, test1, test2; +CREATE TABLE t1 ( +a int unsigned NOT NULL PRIMARY KEY, +b int unsigned not null, +c int unsigned, +KEY(b) +) engine=ndbcluster; +insert t1 values(1, 2, 3), (2,3, 5), (3, 4, 6), (4, 5, 8), (5,6, 2), (6,7, 2); +select * from t1 order by b; +a b c +1 2 3 +2 3 5 +3 4 6 +4 5 8 +5 6 2 +6 7 2 +select * from t1 where b >= 4 order by b; +a b c +3 4 6 +4 5 8 +5 6 2 +6 7 2 +select * from t1 where b = 4 order by b; +a b c +3 4 6 +select * from t1 where b > 4 order by b; +a b c +4 5 8 +5 6 2 +6 7 2 +select * from t1 where b < 4 order by b; +a b c +1 2 3 +2 3 5 +select * from t1 where b <= 4 order by b; +a b c +1 2 3 +2 3 5 +3 4 6 +select tt1.* from t1 as tt1, t1 as tt2 use index(b) where tt1.b = tt2.b order by tt1.b; +a b c +1 2 3 +2 3 5 +3 4 6 +4 5 8 +5 6 2 +6 7 2 +select a, b, c from t1 where a!=2 and c=6; +a b c +3 4 6 +select a, b, c from t1 where a!=2 order by a; +a b c +1 2 3 +3 4 6 +4 5 8 +5 6 2 +6 7 2 +update t1 set c = 3 where b = 3; +select * from t1 order by a; +a b c +1 2 3 +2 3 3 +3 4 6 +4 5 8 +5 6 2 +6 7 2 +update t1 set c = 10 where b >= 6; +select * from t1 order by a; +a b c +1 2 3 +2 3 3 +3 4 6 +4 5 8 +5 6 10 +6 7 10 +update t1 set c = 11 where b < 5; +select * from t1 order by a; +a b c +1 2 11 +2 3 11 +3 4 11 +4 5 8 +5 6 10 +6 7 10 +update t1 set c = 12 where b > 0; +select * from t1 order by a; +a b c +1 2 12 +2 3 12 +3 4 12 +4 5 12 +5 6 12 +6 7 12 +update t1 set c = 13 where b <= 3; +select * from t1 order by a; +a b c +1 2 13 +2 3 13 +3 4 12 +4 5 12 +5 6 12 +6 7 12 +update t1 set b = b + 1 where b > 4 and b < 7; +select * from t1 order by a; +a b c +1 2 13 +2 3 13 +3 4 12 +4 6 12 +5 7 12 +6 7 12 +update t1 set a = a + 10 where b > 1 and b < 7; +select * from t1 order by a; +a b c +5 7 12 +6 7 12 +11 2 13 +12 3 13 +13 4 12 +14 6 12 +drop table t1; +CREATE TABLE t1 ( +a int unsigned NOT NULL PRIMARY KEY, +b int unsigned not null, +c int unsigned, +KEY(b) +) engine=ndbcluster; +insert t1 values(1, 2, 13), (2,3, 13), (3, 4, 12), (4, 5, 12), (5,6, 12), (6,7, 12); +delete from t1 where b = 3; +select * from t1 order by a; +a b c +1 2 13 +3 4 12 +4 5 12 +5 6 12 +6 7 12 +delete from t1 where b >= 6; +select * from t1 order by a; +a b c +1 2 13 +3 4 12 +4 5 12 +delete from t1 where b < 4; +select * from t1 order by a; +a b c +3 4 12 +4 5 12 +delete from t1 where b > 5; +select * from t1 order by a; +a b c +3 4 12 +4 5 12 +delete from t1 where b <= 4; +select * from t1 order by a; +a b c +4 5 12 +drop table t1; +CREATE TABLE t1 ( +a int unsigned NOT NULL PRIMARY KEY, +b int unsigned not null, +c int unsigned not null +) engine = ndb; +create index a1 on t1 (b, c); +insert into t1 values (1, 2, 13); +insert into t1 values (2,3, 13); +insert into t1 values (3, 4, 12); +insert into t1 values (4, 5, 12); +insert into t1 values (5,6, 12); +insert into t1 values (6,7, 12); +insert into t1 values (7, 2, 1); +insert into t1 values (8,3, 6); +insert into t1 values (9, 4, 12); +insert into t1 values (14, 5, 4); +insert into t1 values (15,5,5); +insert into t1 values (16,5, 6); +insert into t1 values (17,4,4); +insert into t1 values (18,1, 7); +select * from t1 order by a; +a b c +1 2 13 +2 3 13 +3 4 12 +4 5 12 +5 6 12 +6 7 12 +7 2 1 +8 3 6 +9 4 12 +14 5 4 +15 5 5 +16 5 6 +17 4 4 +18 1 7 +select * from t1 where b<=5 order by a; +a b c +1 2 13 +2 3 13 +3 4 12 +4 5 12 +7 2 1 +8 3 6 +9 4 12 +14 5 4 +15 5 5 +16 5 6 +17 4 4 +18 1 7 +select * from t1 where b<=5 and c=0; +a b c +insert into t1 values (19,4, 0); +select * from t1 where b<=5 and c=0; +a b c +19 4 0 +select * from t1 where b=4 and c<=5 order by a; +a b c +17 4 4 +19 4 0 +select * from t1 where b<=4 and c<=5 order by a; +a b c +7 2 1 +17 4 4 +19 4 0 +select * from t1 where b<=5 and c=0 or b<=5 and c=2; +a b c +19 4 0 +select count(*) from t1 where b = 0; +count(*) +0 +select count(*) from t1 where b = 1; +count(*) +1 +drop table t1; +CREATE TABLE t1 ( +a int unsigned NOT NULL PRIMARY KEY, +b int unsigned, +c int unsigned, +KEY bc(b,c) +) engine = ndb; +insert into t1 values(1,1,1),(2,NULL,2),(3,NULL,NULL),(4,4,NULL); +select * from t1 use index (bc) where b IS NULL order by a; +a b c +2 NULL 2 +3 NULL NULL +select * from t1 use index (bc)order by a; +a b c +1 1 1 +2 NULL 2 +3 NULL NULL +4 4 NULL +select * from t1 use index (bc) order by a; +a b c +1 1 1 +2 NULL 2 +3 NULL NULL +4 4 NULL +select * from t1 use index (PRIMARY) where b IS NULL order by a; +a b c +2 NULL 2 +3 NULL NULL +select * from t1 use index (bc) where b IS NULL order by a; +a b c +2 NULL 2 +3 NULL NULL +select * from t1 use index (bc) where b IS NULL and c IS NULL order by a; +a b c +3 NULL NULL +select * from t1 use index (bc) where b IS NULL and c = 2 order by a; +a b c +2 NULL 2 +select * from t1 use index (bc) where b < 4 order by a; +a b c +1 1 1 +select * from t1 use index (bc) where b IS NOT NULL order by a; +a b c +1 1 1 +4 4 NULL +drop table t1; +create table t1 ( +a int unsigned primary key, +b int unsigned, +c char(10), +key bc (b, c) +) engine=ndb; +insert into t1 values(1,1,'a'),(2,2,'b'),(3,3,'c'),(4,4,'d'),(5,5,'e'); +insert into t1 select a*7,10*b,'f' from t1; +insert into t1 select a*13,10*b,'g' from t1; +insert into t1 select a*17,10*b,'h' from t1; +insert into t1 select a*19,10*b,'i' from t1; +insert into t1 select a*23,10*b,'j' from t1; +insert into t1 select a*29,10*b,'k' from t1; +select b, c from t1 where b <= 10 and c <'f' order by b, c; +b c +1 a +2 b +3 c +4 d +5 e +select b, c from t1 where b <= 10 and c <'f' order by b desc, c desc; +b c +5 e +4 d +3 c +2 b +1 a +select b, c from t1 where b=4000 and c<'k' order by b, c; +b c +4000 h +4000 i +4000 i +4000 i +4000 j +4000 j +4000 j +4000 j +4000 j +4000 j +select b, c from t1 where b=4000 and c<'k' order by b desc, c desc; +b c +4000 j +4000 j +4000 j +4000 j +4000 j +4000 j +4000 i +4000 i +4000 i +4000 h +select b, c from t1 where 1000<=b and b<=100000 and c<'j' order by b, c; +b c +1000 h +1000 i +1000 i +1000 i +2000 h +2000 i +2000 i +2000 i +3000 h +3000 i +3000 i +3000 i +4000 h +4000 i +4000 i +4000 i +5000 h +5000 i +5000 i +5000 i +10000 i +20000 i +30000 i +40000 i +50000 i +select b, c from t1 where 1000<=b and b<=100000 and c<'j' order by b desc, c desc; +b c +50000 i +40000 i +30000 i +20000 i +10000 i +5000 i +5000 i +5000 i +5000 h +4000 i +4000 i +4000 i +4000 h +3000 i +3000 i +3000 i +3000 h +2000 i +2000 i +2000 i +2000 h +1000 i +1000 i +1000 i +1000 h +select min(b), max(b) from t1; +min(b) max(b) +1 5000000 +drop table t1; +CREATE TABLE test1 ( +SubscrID int(11) NOT NULL auto_increment, +UsrID int(11) NOT NULL default '0', +PRIMARY KEY (SubscrID), +KEY idx_usrid (UsrID) +) ENGINE=ndbcluster DEFAULT CHARSET=latin1; +INSERT INTO test1 VALUES (2,224),(3,224),(1,224); +CREATE TABLE test2 ( +SbclID int(11) NOT NULL auto_increment, +SbcrID int(11) NOT NULL default '0', +PRIMARY KEY (SbclID), +KEY idx_sbcrid (SbcrID) +) ENGINE=ndbcluster DEFAULT CHARSET=latin1; +INSERT INTO test2 VALUES (3,2),(1,1),(2,1),(4,2); +select * from test1 order by 1; +SubscrID UsrID +1 224 +2 224 +3 224 +select * from test2 order by 1; +SbclID SbcrID +1 1 +2 1 +3 2 +4 2 +SELECT s.SubscrID,l.SbclID FROM test1 s left JOIN test2 l ON +l.SbcrID=s.SubscrID WHERE s.UsrID=224 order by 1, 2; +SubscrID SbclID +1 1 +1 2 +2 3 +2 4 +3 NULL +drop table test1; +drop table test2; +create table t1 ( +pk int primary key, +dt datetime not null, +da date not null, +ye year not null, +ti time not null, +ts timestamp not null, +index(dt), +index(da), +index(ye), +index(ti), +index(ts) +) engine=ndb; +insert into t1 (pk,dt,da,ye,ti,ts) values +(1, '1901-05-05 23:00:59', '1901-05-05', '1901', '23:00:59', '2001-01-01 23:00:59'), +(2, '1912-09-05 13:00:59', '1912-09-05', '1912', '13:00:59', '2001-01-01 13:00:59'), +(3, '1945-12-31 00:00:00', '1945-12-31', '1945', '00:00:00', '2001-01-01 00:00:00'), +(4, '1955-12-31 00:00:00', '1955-12-31', '1955', '00:00:00', '2001-01-01 00:00:00'), +(5, '1963-06-06 06:06:06', '1963-06-06', '1963', '06:06:06', '2001-01-01 06:06:06'), +(6, '1993-06-06 06:06:06', '1993-06-06', '1993', '06:06:06', '2001-01-01 06:06:06'), +(7, '2001-01-01 10:11:10', '2001-01-01', '2001', '10:11:10', '2001-01-01 10:11:10'), +(8, '2001-01-01 10:11:11', '2001-01-01', '2001', '10:11:11', '2001-01-01 10:11:11'), +(9, '2005-01-31 23:59:59', '2005-01-31', '2005', '23:59:59', '2001-01-01 23:59:59'); +select count(*)-9 from t1 use index (dt) where dt > '1900-01-01 00:00:00'; +count(*)-9 +0 +select count(*)-6 from t1 use index (dt) where dt >= '1955-12-31 00:00:00'; +count(*)-6 +0 +select count(*)-5 from t1 use index (dt) where dt > '1955-12-31 00:00:00'; +count(*)-5 +0 +select count(*)-5 from t1 use index (dt) where dt < '1970-03-03 22:22:22'; +count(*)-5 +0 +select count(*)-7 from t1 use index (dt) where dt < '2001-01-01 10:11:11'; +count(*)-7 +0 +select count(*)-8 from t1 use index (dt) where dt <= '2001-01-01 10:11:11'; +count(*)-8 +0 +select count(*)-9 from t1 use index (dt) where dt <= '2055-01-01 00:00:00'; +count(*)-9 +0 +select count(*)-9 from t1 use index (da) where da > '1900-01-01'; +count(*)-9 +0 +select count(*)-6 from t1 use index (da) where da >= '1955-12-31'; +count(*)-6 +0 +select count(*)-5 from t1 use index (da) where da > '1955-12-31'; +count(*)-5 +0 +select count(*)-5 from t1 use index (da) where da < '1970-03-03'; +count(*)-5 +0 +select count(*)-6 from t1 use index (da) where da < '2001-01-01'; +count(*)-6 +0 +select count(*)-8 from t1 use index (da) where da <= '2001-01-02'; +count(*)-8 +0 +select count(*)-9 from t1 use index (da) where da <= '2055-01-01'; +count(*)-9 +0 +select count(*)-9 from t1 use index (ye) where ye > '1900'; +count(*)-9 +0 +select count(*)-6 from t1 use index (ye) where ye >= '1955'; +count(*)-6 +0 +select count(*)-5 from t1 use index (ye) where ye > '1955'; +count(*)-5 +0 +select count(*)-5 from t1 use index (ye) where ye < '1970'; +count(*)-5 +0 +select count(*)-6 from t1 use index (ye) where ye < '2001'; +count(*)-6 +0 +select count(*)-8 from t1 use index (ye) where ye <= '2001'; +count(*)-8 +0 +select count(*)-9 from t1 use index (ye) where ye <= '2055'; +count(*)-9 +0 +select count(*)-9 from t1 use index (ti) where ti >= '00:00:00'; +count(*)-9 +0 +select count(*)-7 from t1 use index (ti) where ti > '00:00:00'; +count(*)-7 +0 +select count(*)-7 from t1 use index (ti) where ti > '05:05:05'; +count(*)-7 +0 +select count(*)-5 from t1 use index (ti) where ti > '06:06:06'; +count(*)-5 +0 +select count(*)-5 from t1 use index (ti) where ti < '10:11:11'; +count(*)-5 +0 +select count(*)-6 from t1 use index (ti) where ti <= '10:11:11'; +count(*)-6 +0 +select count(*)-8 from t1 use index (ti) where ti < '23:59:59'; +count(*)-8 +0 +select count(*)-9 from t1 use index (ti) where ti <= '23:59:59'; +count(*)-9 +0 +select count(*)-9 from t1 use index (ts) where ts >= '2001-01-01 00:00:00'; +count(*)-9 +0 +select count(*)-7 from t1 use index (ts) where ts > '2001-01-01 00:00:00'; +count(*)-7 +0 +select count(*)-7 from t1 use index (ts) where ts > '2001-01-01 05:05:05'; +count(*)-7 +0 +select count(*)-5 from t1 use index (ts) where ts > '2001-01-01 06:06:06'; +count(*)-5 +0 +select count(*)-5 from t1 use index (ts) where ts < '2001-01-01 10:11:11'; +count(*)-5 +0 +select count(*)-6 from t1 use index (ts) where ts <= '2001-01-01 10:11:11'; +count(*)-6 +0 +select count(*)-8 from t1 use index (ts) where ts < '2001-01-01 23:59:59'; +count(*)-8 +0 +select count(*)-9 from t1 use index (ts) where ts <= '2001-01-01 23:59:59'; +count(*)-9 +0 +drop table t1; +create table t1 ( +a int primary key, +s decimal(12), +t decimal(12, 5), +u decimal(12) unsigned, +v decimal(12, 5) unsigned, +key (s), +key (t), +key (u), +key (v) +) engine=ndb; +insert into t1 values +( 0, -000000000007, -0000061.00003, 000000000061, 0000965.00042), +( 1, -000000000007, -0000061.00042, 000000000061, 0000965.00003), +( 2, -071006035767, 4210253.00024, 000000000001, 0000001.84488), +( 3, 000000007115, 0000000.77607, 000077350625, 0000018.00013), +( 4, -000000068391, -0346486.00000, 000000005071, 0005334.00002), +( 5, -521579890459, -1936874.00001, 000000000154, 0000003.00018), +( 6, -521579890459, -1936874.00018, 000000000154, 0000003.00001), +( 7, 000000000333, 0000051.39140, 000000907958, 0788643.08374), +( 8, 000042731229, 0000009.00000, 000000000009, 6428667.00000), +( 9, -000008159769, 0000918.00004, 000096951421, 7607730.00008); +select count(*)- 5 from t1 use index (s) where s < -000000000007; +count(*)- 5 +0 +select count(*)- 7 from t1 use index (s) where s <= -000000000007; +count(*)- 7 +0 +select count(*)- 2 from t1 use index (s) where s = -000000000007; +count(*)- 2 +0 +select count(*)- 5 from t1 use index (s) where s >= -000000000007; +count(*)- 5 +0 +select count(*)- 3 from t1 use index (s) where s > -000000000007; +count(*)- 3 +0 +select count(*)- 4 from t1 use index (t) where t < -0000061.00003; +count(*)- 4 +0 +select count(*)- 5 from t1 use index (t) where t <= -0000061.00003; +count(*)- 5 +0 +select count(*)- 1 from t1 use index (t) where t = -0000061.00003; +count(*)- 1 +0 +select count(*)- 6 from t1 use index (t) where t >= -0000061.00003; +count(*)- 6 +0 +select count(*)- 5 from t1 use index (t) where t > -0000061.00003; +count(*)- 5 +0 +select count(*)- 2 from t1 use index (u) where u < 000000000061; +count(*)- 2 +0 +select count(*)- 4 from t1 use index (u) where u <= 000000000061; +count(*)- 4 +0 +select count(*)- 2 from t1 use index (u) where u = 000000000061; +count(*)- 2 +0 +select count(*)- 8 from t1 use index (u) where u >= 000000000061; +count(*)- 8 +0 +select count(*)- 6 from t1 use index (u) where u > 000000000061; +count(*)- 6 +0 +select count(*)- 5 from t1 use index (v) where v < 0000965.00042; +count(*)- 5 +0 +select count(*)- 6 from t1 use index (v) where v <= 0000965.00042; +count(*)- 6 +0 +select count(*)- 1 from t1 use index (v) where v = 0000965.00042; +count(*)- 1 +0 +select count(*)- 5 from t1 use index (v) where v >= 0000965.00042; +count(*)- 5 +0 +select count(*)- 4 from t1 use index (v) where v > 0000965.00042; +count(*)- 4 +0 +drop table t1; +create table t1(a int primary key, b int not null, index(b)); +insert into t1 values (1,1), (2,2); +set autocommit=0; +begin; +select count(*) from t1; +count(*) +2 +ALTER TABLE t1 ADD COLUMN c int; +select a from t1 where b = 2; +a +2 +show tables; +Tables_in_test +t1 +drop table t1; +create table t1 (a int, c varchar(10), +primary key using hash (a), index(c)) engine=ndb; +insert into t1 (a, c) values (1,'aaa'),(3,'bbb'); +select count(*) from t1 where c<'bbb'; +count(*) +1 +drop table t1; +set autocommit=1; +show session variables like 'ndb_index_stat_%'; +Variable_name Value +ndb_index_stat_cache_entries 32 +ndb_index_stat_enable OFF +ndb_index_stat_update_freq 20 +set ndb_index_stat_enable = off; +show session variables like 'ndb_index_stat_%'; +Variable_name Value +ndb_index_stat_cache_entries 32 +ndb_index_stat_enable OFF +ndb_index_stat_update_freq 20 +create table t1 (a int, b int, c varchar(10) not null, +primary key using hash (a), index(b,c)) engine=ndb; +insert into t1 values +(1,10,'aaa'),(2,10,'bbb'),(3,10,'ccc'), +(4,20,'aaa'),(5,20,'bbb'),(6,20,'ccc'), +(7,30,'aaa'),(8,30,'bbb'),(9,30,'ccc'); +select count(*) from t1 where b < 10; +count(*) +0 +select count(*) from t1 where b >= 10 and c >= 'bbb'; +count(*) +6 +select count(*) from t1 where b > 10; +count(*) +6 +select count(*) from t1 where b <= 20 and c < 'ccc'; +count(*) +4 +select count(*) from t1 where b = 20 and c = 'ccc'; +count(*) +1 +select count(*) from t1 where b > 20; +count(*) +3 +select count(*) from t1 where b = 30 and c > 'aaa'; +count(*) +2 +select count(*) from t1 where b <= 20; +count(*) +6 +select count(*) from t1 where b >= 20 and c > 'aaa'; +count(*) +4 +drop table t1; +set ndb_index_stat_enable = on; +set ndb_index_stat_cache_entries = 0; +show session variables like 'ndb_index_stat_%'; +Variable_name Value +ndb_index_stat_cache_entries 0 +ndb_index_stat_enable ON +ndb_index_stat_update_freq 20 +create table t1 (a int, b int, c varchar(10) not null, +primary key using hash (a), index(b,c)) engine=ndb; +insert into t1 values +(1,10,'aaa'),(2,10,'bbb'),(3,10,'ccc'), +(4,20,'aaa'),(5,20,'bbb'),(6,20,'ccc'), +(7,30,'aaa'),(8,30,'bbb'),(9,30,'ccc'); +select count(*) from t1 where b < 10; +count(*) +0 +select count(*) from t1 where b >= 10 and c >= 'bbb'; +count(*) +6 +select count(*) from t1 where b > 10; +count(*) +6 +select count(*) from t1 where b <= 20 and c < 'ccc'; +count(*) +4 +select count(*) from t1 where b = 20 and c = 'ccc'; +count(*) +1 +select count(*) from t1 where b > 20; +count(*) +3 +select count(*) from t1 where b = 30 and c > 'aaa'; +count(*) +2 +select count(*) from t1 where b <= 20; +count(*) +6 +select count(*) from t1 where b >= 20 and c > 'aaa'; +count(*) +4 +drop table t1; +set ndb_index_stat_enable = on; +set ndb_index_stat_cache_entries = 4; +set ndb_index_stat_update_freq = 2; +show session variables like 'ndb_index_stat_%'; +Variable_name Value +ndb_index_stat_cache_entries 4 +ndb_index_stat_enable ON +ndb_index_stat_update_freq 2 +create table t1 (a int, b int, c varchar(10) not null, +primary key using hash (a), index(b,c)) engine=ndb; +insert into t1 values +(1,10,'aaa'),(2,10,'bbb'),(3,10,'ccc'), +(4,20,'aaa'),(5,20,'bbb'),(6,20,'ccc'), +(7,30,'aaa'),(8,30,'bbb'),(9,30,'ccc'); +select count(*) from t1 where b < 10; +count(*) +0 +select count(*) from t1 where b >= 10 and c >= 'bbb'; +count(*) +6 +select count(*) from t1 where b > 10; +count(*) +6 +select count(*) from t1 where b <= 20 and c < 'ccc'; +count(*) +4 +select count(*) from t1 where b = 20 and c = 'ccc'; +count(*) +1 +select count(*) from t1 where b > 20; +count(*) +3 +select count(*) from t1 where b = 30 and c > 'aaa'; +count(*) +2 +select count(*) from t1 where b <= 20; +count(*) +6 +select count(*) from t1 where b >= 20 and c > 'aaa'; +count(*) +4 +drop table t1; +set ndb_index_stat_enable = @@global.ndb_index_stat_enable; +set ndb_index_stat_cache_entries = @@global.ndb_index_stat_cache_entries; +set ndb_index_stat_update_freq = @@global.ndb_index_stat_update_freq; +show session variables like 'ndb_index_stat_%'; +Variable_name Value +ndb_index_stat_cache_entries 32 +ndb_index_stat_enable OFF +ndb_index_stat_update_freq 20 +create table t1 (a int primary key) engine = ndb; +insert into t1 values (1), (2), (3); +begin; +delete from t1 where a > 1; +rollback; +select * from t1 order by a; +a +1 +2 +3 +begin; +delete from t1 where a > 1; +rollback; +begin; +select * from t1 order by a; +a +1 +2 +3 +delete from t1 where a > 2; +select * from t1 order by a; +a +1 +2 +delete from t1 where a > 1; +select * from t1 order by a; +a +1 +delete from t1 where a > 0; +select * from t1 order by a; +a +rollback; +select * from t1 order by a; +a +1 +2 +3 +delete from t1; +drop table t1; +create table nationaldish (DishID int(10) unsigned NOT NULL AUTO_INCREMENT, +CountryCode char(3) NOT NULL, +DishTitle varchar(64) NOT NULL, +calories smallint(5) unsigned DEFAULT NULL, +PRIMARY KEY (DishID), +INDEX i USING HASH (countrycode,calories) +) ENGINE=ndbcluster; +ERROR HY000: Can't create table 'test.nationaldish' (errno: 138) +create table nationaldish (DishID int(10) unsigned NOT NULL AUTO_INCREMENT, +CountryCode char(3) NOT NULL, +DishTitle varchar(64) NOT NULL, +calories smallint(5) unsigned DEFAULT NULL, +PRIMARY KEY (DishID) +) ENGINE=ndbcluster; +create index i on nationaldish(countrycode,calories) using hash; +ERROR 42000: Table 'nationaldish' uses an extension that doesn't exist in this MySQL version +drop table nationaldish; diff --git a/mysql-test/suite/ndb/r/ndb_index_unique.result b/mysql-test/suite/ndb/r/ndb_index_unique.result new file mode 100644 index 00000000000..cc63ce69760 --- /dev/null +++ b/mysql-test/suite/ndb/r/ndb_index_unique.result @@ -0,0 +1,692 @@ +drop table if exists t1, t2, t3, t4, t5, t6, t7, t8; +CREATE TABLE t1 ( +a int NOT NULL PRIMARY KEY, +b int not null, +c int, +UNIQUE ib(b) +) engine=ndbcluster; +insert t1 values(1, 2, 3), (2, 3, 5), (3, 4, 6), (4, 5, 8), (5,6, 2), (6,7, 2); +select * from t1 order by b; +a b c +1 2 3 +2 3 5 +3 4 6 +4 5 8 +5 6 2 +6 7 2 +select * from t1 where b = 4 order by b; +a b c +3 4 6 +insert into t1 values(7,8,3); +select * from t1 where b = 4 order by a; +a b c +3 4 6 +insert into t1 values(8, 2, 3); +ERROR 23000: Duplicate entry '' for key '*UNKNOWN*' +select * from t1 order by a; +a b c +1 2 3 +2 3 5 +3 4 6 +4 5 8 +5 6 2 +6 7 2 +7 8 3 +delete from t1 where a = 1; +insert into t1 values(8, 2, 3); +select * from t1 order by a; +a b c +2 3 5 +3 4 6 +4 5 8 +5 6 2 +6 7 2 +7 8 3 +8 2 3 +alter table t1 drop index ib; +insert into t1 values(1, 2, 3); +create unique index ib on t1(b); +ERROR 23000: Can't write, because of unique constraint, to table 't1' +drop table t1; +CREATE TABLE t1 ( +a int unsigned NOT NULL PRIMARY KEY, +b int unsigned, +c int unsigned, +UNIQUE bc(b,c) +) engine = ndb; +insert into t1 values(1,1,1),(2,NULL,2),(3,NULL,NULL),(4,4,NULL); +select * from t1 use index (bc) where b IS NULL order by a; +a b c +2 NULL 2 +3 NULL NULL +select * from t1 use index (bc)order by a; +a b c +1 1 1 +2 NULL 2 +3 NULL NULL +4 4 NULL +select * from t1 use index (bc) order by a; +a b c +1 1 1 +2 NULL 2 +3 NULL NULL +4 4 NULL +select * from t1 use index (PRIMARY) where b IS NULL order by a; +a b c +2 NULL 2 +3 NULL NULL +select * from t1 use index (bc) where b IS NULL order by a; +a b c +2 NULL 2 +3 NULL NULL +select * from t1 use index (bc) where b IS NULL and c IS NULL order by a; +a b c +3 NULL NULL +select * from t1 use index (bc) where b IS NULL and c = 2 order by a; +a b c +2 NULL 2 +select * from t1 use index (bc) where b < 4 order by a; +a b c +1 1 1 +select * from t1 use index (bc) where b IS NOT NULL order by a; +a b c +1 1 1 +4 4 NULL +insert into t1 values(5,1,1); +ERROR 23000: Duplicate entry '' for key '*UNKNOWN*' +drop table t1; +CREATE TABLE t2 ( +a int unsigned NOT NULL PRIMARY KEY, +b int unsigned not null, +c int unsigned not null, +UNIQUE (b, c) USING HASH +) engine=ndbcluster; +insert t2 values(1, 2, 3), (2, 3, 5), (3, 4, 6), (4, 5, 8), (5,6, 2), (6,7, 2); +select * from t2 where a = 3; +a b c +3 4 6 +select * from t2 where b = 4; +a b c +3 4 6 +select * from t2 where c = 6; +a b c +3 4 6 +insert into t2 values(7,8,3); +select * from t2 where b = 4 order by a; +a b c +3 4 6 +insert into t2 values(8, 2, 3); +ERROR 23000: Duplicate entry '' for key '*UNKNOWN*' +select * from t2 order by a; +a b c +1 2 3 +2 3 5 +3 4 6 +4 5 8 +5 6 2 +6 7 2 +7 8 3 +delete from t2 where a = 1; +insert into t2 values(8, 2, 3); +select * from t2 order by a; +a b c +2 3 5 +3 4 6 +4 5 8 +5 6 2 +6 7 2 +7 8 3 +8 2 3 +create unique index bi using hash on t2(b); +insert into t2 values(9, 3, 1); +ERROR 23000: Duplicate entry '' for key '*UNKNOWN*' +alter table t2 drop index bi; +insert into t2 values(9, 3, 1); +select * from t2 order by a; +a b c +2 3 5 +3 4 6 +4 5 8 +5 6 2 +6 7 2 +7 8 3 +8 2 3 +9 3 1 +drop table t2; +CREATE TABLE t2 ( +a int unsigned NOT NULL PRIMARY KEY, +b int unsigned not null, +c int unsigned, +UNIQUE (b, c) USING HASH +) engine=ndbcluster; +Warnings: +Warning 1121 Ndb does not support unique index on NULL valued attributes, index access with NULL value will become full table scan +insert t2 values(1,1,NULL),(2,2,2),(3,3,NULL),(4,4,4),(5,5,NULL),(6,6,6),(7,7,NULL),(8,3,NULL),(9,3,NULL); +select * from t2 where c IS NULL order by a; +a b c +1 1 NULL +3 3 NULL +5 5 NULL +7 7 NULL +8 3 NULL +9 3 NULL +select * from t2 where b = 3 AND c IS NULL order by a; +a b c +3 3 NULL +8 3 NULL +9 3 NULL +select * from t2 where (b = 3 OR b = 5) AND c IS NULL order by a; +a b c +3 3 NULL +5 5 NULL +8 3 NULL +9 3 NULL +set @old_ecpd = @@session.engine_condition_pushdown; +set engine_condition_pushdown = true; +explain select * from t2 where (b = 3 OR b = 5) AND c IS NULL AND a < 9 order by a; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t2 range PRIMARY,b PRIMARY 4 NULL 1 Using where with pushed condition +select * from t2 where (b = 3 OR b = 5) AND c IS NULL AND a < 9 order by a; +a b c +3 3 NULL +5 5 NULL +8 3 NULL +set engine_condition_pushdown = @old_ecpd; +drop table t2; +CREATE TABLE t3 ( +a int unsigned NOT NULL, +b int unsigned not null, +c int unsigned, +PRIMARY KEY (a, b) USING HASH +) engine=ndbcluster; +insert t3 values(1, 2, 3), (2, 3, 5), (3, 4, 6), (4, 5, 8), (5,6, 2), (6,7, 2); +select * from t3 where a = 3; +a b c +3 4 6 +select * from t3 where b = 4; +a b c +3 4 6 +select * from t3 where c = 6; +a b c +3 4 6 +insert into t3 values(7,8,3); +select * from t3 where b = 4 order by a; +a b c +3 4 6 +drop table t3; +CREATE TABLE t1 ( +pk int NOT NULL PRIMARY KEY, +a int unsigned, +UNIQUE KEY (a) +) engine=ndbcluster; +insert into t1 values (-1,NULL), (0,0), (1,NULL),(2,2),(3,NULL),(4,4); +select * from t1 order by pk; +pk a +-1 NULL +0 0 +1 NULL +2 2 +3 NULL +4 4 +insert into t1 values (5,0); +ERROR 23000: Duplicate entry '' for key '*UNKNOWN*' +select * from t1 order by pk; +pk a +-1 NULL +0 0 +1 NULL +2 2 +3 NULL +4 4 +delete from t1 where a = 0; +insert into t1 values (5,0); +select * from t1 order by pk; +pk a +-1 NULL +1 NULL +2 2 +3 NULL +4 4 +5 0 +CREATE TABLE t2 ( +pk int NOT NULL PRIMARY KEY, +a int unsigned, +b tinyint NOT NULL, +c VARCHAR(10), +UNIQUE KEY si(a, c) +) engine=ndbcluster; +insert into t2 values (-1,1,17,NULL),(0,NULL,18,NULL),(1,3,19,'abc'); +select * from t2 order by pk; +pk a b c +-1 1 17 NULL +0 NULL 18 NULL +1 3 19 abc +insert into t2 values(2,3,19,'abc'); +ERROR 23000: Duplicate entry '' for key '*UNKNOWN*' +select * from t2 order by pk; +pk a b c +-1 1 17 NULL +0 NULL 18 NULL +1 3 19 abc +delete from t2 where c IS NOT NULL; +insert into t2 values(2,3,19,'abc'); +select * from t2 order by pk; +pk a b c +-1 1 17 NULL +0 NULL 18 NULL +2 3 19 abc +drop table t1, t2; +CREATE TABLE t1 ( +cid smallint(5) unsigned NOT NULL default '0', +cv varchar(250) NOT NULL default '', +PRIMARY KEY (cid), +UNIQUE KEY cv (cv) +) engine=ndbcluster; +INSERT INTO t1 VALUES (8,'dummy'); +CREATE TABLE t2 ( +cid bigint(20) unsigned NOT NULL auto_increment, +cap varchar(255) NOT NULL default '', +PRIMARY KEY (cid), +UNIQUE KEY (cid, cap) +) engine=ndbcluster; +INSERT INTO t2 VALUES (NULL,'another dummy'); +CREATE TABLE t3 ( +gid bigint(20) unsigned NOT NULL auto_increment, +gn varchar(255) NOT NULL default '', +must tinyint(4) default NULL, +PRIMARY KEY (gid) +) engine=ndbcluster; +INSERT INTO t3 VALUES (1,'V1',NULL); +CREATE TABLE t4 ( +uid bigint(20) unsigned NOT NULL default '0', +gid bigint(20) unsigned NOT NULL, +rid bigint(20) unsigned NOT NULL, +cid bigint(20) unsigned NOT NULL, +UNIQUE KEY m (uid,gid,rid,cid) +) engine=ndbcluster; +INSERT INTO t4 VALUES (1,1,2,4); +INSERT INTO t4 VALUES (1,1,2,3); +INSERT INTO t4 VALUES (1,1,5,7); +INSERT INTO t4 VALUES (1,1,10,8); +CREATE TABLE t5 ( +rid bigint(20) unsigned NOT NULL auto_increment, +rl varchar(255) NOT NULL default '', +PRIMARY KEY (rid) +) engine=ndbcluster; +CREATE TABLE t6 ( +uid bigint(20) unsigned NOT NULL auto_increment, +un varchar(250) NOT NULL default '', +uc smallint(5) unsigned NOT NULL default '0', +PRIMARY KEY (uid), +UNIQUE KEY nc (un,uc) +) engine=ndbcluster; +INSERT INTO t6 VALUES (1,'test',8); +INSERT INTO t6 VALUES (2,'test2',9); +INSERT INTO t6 VALUES (3,'tre',3); +CREATE TABLE t7 ( +mid bigint(20) unsigned NOT NULL PRIMARY KEY, +uid bigint(20) unsigned NOT NULL default '0', +gid bigint(20) unsigned NOT NULL, +rid bigint(20) unsigned NOT NULL, +cid bigint(20) unsigned NOT NULL, +UNIQUE KEY m (uid,gid,rid,cid) +) engine=ndbcluster; +INSERT INTO t7 VALUES(1, 1, 1, 1, 1); +INSERT INTO t7 VALUES(2, 2, 1, 1, 1); +INSERT INTO t7 VALUES(3, 3, 1, 1, 1); +INSERT INTO t7 VALUES(4, 4, 1, 1, 1); +INSERT INTO t7 VALUES(5, 5, 1, 1, 1); +INSERT INTO t7 VALUES(6, 1, 1, 1, 6); +INSERT INTO t7 VALUES(7, 2, 1, 1, 7); +INSERT INTO t7 VALUES(8, 3, 1, 1, 8); +INSERT INTO t7 VALUES(9, 4, 1, 1, 9); +INSERT INTO t7 VALUES(10, 5, 1, 1, 10); +select * from t1 where cv = 'dummy'; +cid cv +8 dummy +select * from t1 where cv = 'test'; +cid cv +select * from t2 where cap = 'another dummy'; +cid cap +1 another dummy +select * from t4 where uid = 1 and gid=1 and rid=2 and cid=4; +uid gid rid cid +1 1 2 4 +select * from t4 where uid = 1 and gid=1 and rid=1 and cid=4; +uid gid rid cid +select * from t4 where uid = 1 order by cid; +uid gid rid cid +1 1 2 3 +1 1 2 4 +1 1 5 7 +1 1 10 8 +select * from t4 where rid = 2 order by cid; +uid gid rid cid +1 1 2 3 +1 1 2 4 +select * from t6 where un='test' and uc=8; +uid un uc +1 test 8 +select * from t6 where un='test' and uc=7; +uid un uc +select * from t6 where un='test'; +uid un uc +1 test 8 +select * from t7 where mid = 8; +mid uid gid rid cid +8 3 1 1 8 +select * from t7 where uid = 8; +mid uid gid rid cid +select * from t7 where uid = 1 order by mid; +mid uid gid rid cid +1 1 1 1 1 +6 1 1 1 6 +select * from t7 where uid = 4 order by mid; +mid uid gid rid cid +4 4 1 1 1 +9 4 1 1 9 +select * from t7 where gid = 4; +mid uid gid rid cid +select * from t7 where gid = 1 order by mid; +mid uid gid rid cid +1 1 1 1 1 +2 2 1 1 1 +3 3 1 1 1 +4 4 1 1 1 +5 5 1 1 1 +6 1 1 1 6 +7 2 1 1 7 +8 3 1 1 8 +9 4 1 1 9 +10 5 1 1 10 +select * from t7 where cid = 4; +mid uid gid rid cid +select * from t7 where cid = 8; +mid uid gid rid cid +8 3 1 1 8 +select * from t4 where uid = 1 and gid=1 and rid=2 and cid=4; +uid gid rid cid +1 1 2 4 +select * from t4 where uid = 1 and gid=1 and rid=1 and cid=4; +uid gid rid cid +select * from t4 where uid = 1 order by gid,cid; +uid gid rid cid +1 1 2 3 +1 1 2 4 +1 1 5 7 +1 1 10 8 +1 1 5 12 +1 2 5 12 +1 3 9 11 +1 3 5 12 +1 4 5 12 +1 5 5 12 +1 6 5 12 +1 7 5 12 +1 8 5 12 +1 9 5 12 +1 10 5 12 +1 11 5 12 +1 12 5 12 +1 13 5 12 +1 14 5 12 +1 15 5 12 +1 16 5 12 +1 17 5 12 +1 18 5 12 +1 19 5 12 +1 20 5 12 +1 21 5 12 +1 22 5 12 +1 23 5 12 +1 24 5 12 +1 25 5 12 +1 26 5 12 +1 27 5 12 +1 28 5 12 +1 29 5 12 +1 30 5 12 +1 31 5 12 +1 32 5 12 +1 33 5 12 +1 34 5 12 +1 35 5 12 +1 36 5 12 +1 37 5 12 +1 38 5 12 +1 39 5 12 +1 40 5 12 +1 41 5 12 +1 42 5 12 +1 43 5 12 +1 44 5 12 +1 45 5 12 +1 46 5 12 +1 47 5 12 +1 48 5 12 +1 49 5 12 +1 50 5 12 +1 51 5 12 +1 52 5 12 +1 53 5 12 +1 54 5 12 +1 55 5 12 +1 56 5 12 +1 57 5 12 +1 58 5 12 +1 59 5 12 +1 60 5 12 +1 61 5 12 +1 62 5 12 +1 63 5 12 +1 64 5 12 +1 65 5 12 +1 66 5 12 +1 67 5 12 +1 68 5 12 +1 69 5 12 +1 70 5 12 +1 71 5 12 +1 72 5 12 +1 73 5 12 +1 74 5 12 +1 75 5 12 +1 76 5 12 +1 77 5 12 +1 78 5 12 +1 79 5 12 +1 80 5 12 +1 81 5 12 +1 82 5 12 +1 83 5 12 +1 84 5 12 +1 85 5 12 +1 86 5 12 +1 87 5 12 +1 88 5 12 +1 89 5 12 +1 90 5 12 +1 91 5 12 +1 92 5 12 +1 93 5 12 +1 94 5 12 +1 95 5 12 +1 96 5 12 +1 97 5 12 +1 98 5 12 +1 99 5 12 +1 100 5 12 +select * from t4 where uid = 1 order by gid,cid; +uid gid rid cid +1 1 2 3 +1 1 2 4 +1 1 5 7 +1 1 10 8 +1 1 5 12 +1 2 5 12 +1 3 9 11 +1 3 5 12 +1 4 5 12 +1 5 5 12 +1 6 5 12 +1 7 5 12 +1 8 5 12 +1 9 5 12 +1 10 5 12 +1 11 5 12 +1 12 5 12 +1 13 5 12 +1 14 5 12 +1 15 5 12 +1 16 5 12 +1 17 5 12 +1 18 5 12 +1 19 5 12 +1 20 5 12 +1 21 5 12 +1 22 5 12 +1 23 5 12 +1 24 5 12 +1 25 5 12 +1 26 5 12 +1 27 5 12 +1 28 5 12 +1 29 5 12 +1 30 5 12 +1 31 5 12 +1 32 5 12 +1 33 5 12 +1 34 5 12 +1 35 5 12 +1 36 5 12 +1 37 5 12 +1 38 5 12 +1 39 5 12 +1 40 5 12 +1 41 5 12 +1 42 5 12 +1 43 5 12 +1 44 5 12 +1 45 5 12 +1 46 5 12 +1 47 5 12 +1 48 5 12 +1 49 5 12 +1 50 5 12 +1 51 5 12 +1 52 5 12 +1 53 5 12 +1 54 5 12 +1 55 5 12 +1 56 5 12 +1 57 5 12 +1 58 5 12 +1 59 5 12 +1 60 5 12 +1 61 5 12 +1 62 5 12 +1 63 5 12 +1 64 5 12 +1 65 5 12 +1 66 5 12 +1 67 5 12 +1 68 5 12 +1 69 5 12 +1 70 5 12 +1 71 5 12 +1 72 5 12 +1 73 5 12 +1 74 5 12 +1 75 5 12 +1 76 5 12 +1 77 5 12 +1 78 5 12 +1 79 5 12 +1 80 5 12 +1 81 5 12 +1 82 5 12 +1 83 5 12 +1 84 5 12 +1 85 5 12 +1 86 5 12 +1 87 5 12 +1 88 5 12 +1 89 5 12 +1 90 5 12 +1 91 5 12 +1 92 5 12 +1 93 5 12 +1 94 5 12 +1 95 5 12 +1 96 5 12 +1 97 5 12 +1 98 5 12 +1 99 5 12 +1 100 5 12 +select * from t4 where rid = 2 order by cid; +uid gid rid cid +1 1 2 3 +1 1 2 4 +drop table t1,t2,t3,t4,t5,t6,t7; +CREATE TABLE t1 ( +a int unsigned NOT NULL PRIMARY KEY, +b int unsigned, +c int unsigned, +UNIQUE bc(b,c) ) engine = ndb; +insert into t1 values(1,1,1),(2,NULL,2),(3,NULL,NULL),(4,4,NULL); +select * from t1 where b=1 and c=1; +a b c +1 1 1 +select * from t1 where b is null and c is null; +a b c +3 NULL NULL +select * from t1 where b is null and c = 2; +a b c +2 NULL 2 +select * from t1 where b = 4 and c is null; +a b c +4 4 NULL +create table t8 as +select * from t1 where (b = 1 and c = 1) +or (b is null and c is null) +or (b is null and c = 2) +or (b = 4 and c is null); +select * from t8 order by a; +a b c +1 1 1 +2 NULL 2 +3 NULL NULL +4 4 NULL +select * from t1 order by a; +a b c +1 1 1 +2 NULL 2 +3 NULL NULL +4 4 NULL +drop table t1, t8; +create table t1( +id integer not null auto_increment, +month integer not null, +year integer not null, +code varchar( 2) not null, +primary key ( id), +unique idx_t1( month, code, year) +) engine=ndb; +INSERT INTO t1 (month, year, code) VALUES (4,2004,'12'); +INSERT INTO t1 (month, year, code) VALUES (5,2004,'12'); +select * from t1 where code = '12' and month = 4 and year = 2004 ; +id month year code +1 4 2004 12 +drop table t1; +create table t1 (a int primary key, b varchar(1000) not null, unique key (b)) +engine=ndb charset=utf8; +insert into t1 values (1, repeat(_utf8 0xe288ab6474, 200)); +insert into t1 values (2, repeat(_utf8 0xe288ab6474, 200)); +ERROR 23000: Duplicate entry '' for key '*UNKNOWN*' +select a, sha1(b) from t1; +a sha1(b) +1 08f5d02c8b8bc244f275bdfc22c42c5cab0d9d7d +drop table t1; +create table t1(id int not null) engine = NDB; +alter table t1 add constraint uk_test unique (id) using hash; +drop table t1; diff --git a/mysql-test/suite/ndb/r/ndb_insert.result b/mysql-test/suite/ndb/r/ndb_insert.result new file mode 100644 index 00000000000..51b346bbf7b --- /dev/null +++ b/mysql-test/suite/ndb/r/ndb_insert.result @@ -0,0 +1,828 @@ +DROP TABLE IF EXISTS t1; +CREATE TABLE t1 ( +pk1 INT NOT NULL PRIMARY KEY, +b INT NOT NULL, +c INT NOT NULL +) ENGINE=ndbcluster; +INSERT INTO t1 VALUES (0, 0, 0); +SELECT * FROM t1; +pk1 b c +0 0 0 +INSERT INTO t1 VALUES +(1,1,1),(2,2,2),(3,3,3),(4,4,4),(5,5,5), +(6,6,6),(7,7,7),(8,8,8),(9,9,9),(10,10,10), +(11,11,11),(12,12,12),(13,13,13),(14,14,14),(15,15,15), +(16,16,16),(17,17,17),(18,18,18),(19,19,19),(20,20,20), +(21,21,21),(22,22,22),(23,23,23),(24,24,24),(25,25,25), +(26,26,26),(27,27,27),(28,28,28),(29,29,29),(30,30,30), +(31,31,31),(32,32,32),(33,33,33),(34,34,34),(35,35,35), +(36,36,36),(37,37,37),(38,38,38),(39,39,39),(40,40,40), +(41,41,41),(42,42,42),(43,43,43),(44,44,44),(45,45,45), +(46,46,46),(47,47,47),(48,48,48),(49,49,49),(50,50,50), +(51,51,51),(52,52,52),(53,53,53),(54,54,54),(55,55,55), +(56,56,56),(57,57,57),(58,58,58),(59,59,59),(60,60,60), +(61,61,61),(62,62,62),(63,63,63),(64,64,64),(65,65,65), +(66,66,66),(67,67,67),(68,68,68),(69,69,69),(70,70,70), +(71,71,71),(72,72,72),(73,73,73),(74,74,74),(75,75,75), +(76,76,76),(77,77,77),(78,78,78),(79,79,79),(80,80,80), +(81,81,81),(82,82,82),(83,83,83),(84,84,84),(85,85,85), +(86,86,86),(87,87,87),(88,88,88),(89,89,89),(90,90,90), +(91,91,91),(92,92,92),(93,93,93),(94,94,94),(95,95,95), +(96,96,96),(97,97,97),(98,98,98),(99,99,99),(100,100,100), +(101,101,101),(102,102,102),(103,103,103),(104,104,104),(105,105,105), +(106,106,106),(107,107,107),(108,108,108),(109,109,109),(110,110,110), +(111,111,111),(112,112,112),(113,113,113),(114,114,114),(115,115,115), +(116,116,116),(117,117,117),(118,118,118),(119,119,119),(120,120,120), +(121,121,121),(122,122,122),(123,123,123),(124,124,124),(125,125,125), +(126,126,126),(127,127,127),(128,128,128),(129,129,129),(130,130,130), +(131,131,131),(132,132,132),(133,133,133),(134,134,134),(135,135,135), +(136,136,136),(137,137,137),(138,138,138),(139,139,139),(140,140,140), +(141,141,141),(142,142,142),(143,143,143),(144,144,144),(145,145,145), +(146,146,146),(147,147,147),(148,148,148),(149,149,149),(150,150,150), +(151,151,151),(152,152,152),(153,153,153),(154,154,154),(155,155,155), +(156,156,156),(157,157,157),(158,158,158),(159,159,159),(160,160,160), +(161,161,161),(162,162,162),(163,163,163),(164,164,164),(165,165,165), +(166,166,166),(167,167,167),(168,168,168),(169,169,169),(170,170,170), +(171,171,171),(172,172,172),(173,173,173),(174,174,174),(175,175,175), +(176,176,176),(177,177,177),(178,178,178),(179,179,179),(180,180,180), +(181,181,181),(182,182,182),(183,183,183),(184,184,184),(185,185,185), +(186,186,186),(187,187,187),(188,188,188),(189,189,189),(190,190,190), +(191,191,191),(192,192,192),(193,193,193),(194,194,194),(195,195,195), +(196,196,196),(197,197,197),(198,198,198),(199,199,199),(200,200,200), +(201,201,201),(202,202,202),(203,203,203),(204,204,204),(205,205,205), +(206,206,206),(207,207,207),(208,208,208),(209,209,209),(210,210,210), +(211,211,211),(212,212,212),(213,213,213),(214,214,214),(215,215,215), +(216,216,216),(217,217,217),(218,218,218),(219,219,219),(220,220,220), +(221,221,221),(222,222,222),(223,223,223),(224,224,224),(225,225,225), +(226,226,226),(227,227,227),(228,228,228),(229,229,229),(230,230,230), +(231,231,231),(232,232,232),(233,233,233),(234,234,234),(235,235,235), +(236,236,236),(237,237,237),(238,238,238),(239,239,239),(240,240,240), +(241,241,241),(242,242,242),(243,243,243),(244,244,244),(245,245,245), +(246,246,246),(247,247,247),(248,248,248),(249,249,249),(250,250,250), +(251,251,251),(252,252,252),(253,253,253),(254,254,254),(255,255,255), +(256,256,256),(257,257,257),(258,258,258),(259,259,259),(260,260,260), +(261,261,261),(262,262,262),(263,263,263),(264,264,264),(265,265,265), +(266,266,266),(267,267,267),(268,268,268),(269,269,269),(270,270,270), +(271,271,271),(272,272,272),(273,273,273),(274,274,274),(275,275,275), +(276,276,276),(277,277,277),(278,278,278),(279,279,279),(280,280,280), +(281,281,281),(282,282,282),(283,283,283),(284,284,284),(285,285,285), +(286,286,286),(287,287,287),(288,288,288),(289,289,289),(290,290,290), +(291,291,291),(292,292,292),(293,293,293),(294,294,294),(295,295,295), +(296,296,296),(297,297,297),(298,298,298),(299,299,299),(300,300,300), +(301,301,301),(302,302,302),(303,303,303),(304,304,304),(305,305,305), +(306,306,306),(307,307,307),(308,308,308),(309,309,309),(310,310,310), +(311,311,311),(312,312,312),(313,313,313),(314,314,314),(315,315,315), +(316,316,316),(317,317,317),(318,318,318),(319,319,319),(320,320,320), +(321,321,321),(322,322,322),(323,323,323),(324,324,324),(325,325,325), +(326,326,326),(327,327,327),(328,328,328),(329,329,329),(330,330,330), +(331,331,331),(332,332,332),(333,333,333),(334,334,334),(335,335,335), +(336,336,336),(337,337,337),(338,338,338),(339,339,339),(340,340,340), +(341,341,341),(342,342,342),(343,343,343),(344,344,344),(345,345,345), +(346,346,346),(347,347,347),(348,348,348),(349,349,349),(350,350,350), +(351,351,351),(352,352,352),(353,353,353),(354,354,354),(355,355,355), +(356,356,356),(357,357,357),(358,358,358),(359,359,359),(360,360,360), +(361,361,361),(362,362,362),(363,363,363),(364,364,364),(365,365,365), +(366,366,366),(367,367,367),(368,368,368),(369,369,369),(370,370,370), +(371,371,371),(372,372,372),(373,373,373),(374,374,374),(375,375,375), +(376,376,376),(377,377,377),(378,378,378),(379,379,379),(380,380,380), +(381,381,381),(382,382,382),(383,383,383),(384,384,384),(385,385,385), +(386,386,386),(387,387,387),(388,388,388),(389,389,389),(390,390,390), +(391,391,391),(392,392,392),(393,393,393),(394,394,394),(395,395,395), +(396,396,396),(397,397,397),(398,398,398),(399,399,399),(400,400,400), +(401,401,401),(402,402,402),(403,403,403),(404,404,404),(405,405,405), +(406,406,406),(407,407,407),(408,408,408),(409,409,409),(410,410,410), +(411,411,411),(412,412,412),(413,413,413),(414,414,414),(415,415,415), +(416,416,416),(417,417,417),(418,418,418),(419,419,419),(420,420,420), +(421,421,421),(422,422,422),(423,423,423),(424,424,424),(425,425,425), +(426,426,426),(427,427,427),(428,428,428),(429,429,429),(430,430,430), +(431,431,431),(432,432,432),(433,433,433),(434,434,434),(435,435,435), +(436,436,436),(437,437,437),(438,438,438),(439,439,439),(440,440,440), +(441,441,441),(442,442,442),(443,443,443),(444,444,444),(445,445,445), +(446,446,446),(447,447,447),(448,448,448),(449,449,449),(450,450,450), +(451,451,451),(452,452,452),(453,453,453),(454,454,454),(455,455,455), +(456,456,456),(457,457,457),(458,458,458),(459,459,459),(460,460,460), +(461,461,461),(462,462,462),(463,463,463),(464,464,464),(465,465,465), +(466,466,466),(467,467,467),(468,468,468),(469,469,469),(470,470,470), +(471,471,471),(472,472,472),(473,473,473),(474,474,474),(475,475,475), +(476,476,476),(477,477,477),(478,478,478),(479,479,479),(480,480,480), +(481,481,481),(482,482,482),(483,483,483),(484,484,484),(485,485,485), +(486,486,486),(487,487,487),(488,488,488),(489,489,489),(490,490,490), +(491,491,491),(492,492,492),(493,493,493),(494,494,494),(495,495,495), +(496,496,496),(497,497,497),(498,498,498),(499,499,499),(500, 500, 500); +SELECT COUNT(*) FROM t1; +COUNT(*) +501 +INSERT INTO t1 VALUES +(501,501,501),(502,502,502),(503,503,503),(504,504,504),(505,505,505), +(506,506,506),(507,507,507),(508,508,508),(509,509,509),(510,510,510), +(511,511,511),(512,512,512),(513,513,513),(514,514,514),(515,515,515), +(516,516,516),(517,517,517),(518,518,518),(519,519,519),(520,520,520), +(521,521,521),(522,522,522),(523,523,523),(524,524,524),(525,525,525), +(526,526,526),(527,527,527),(528,528,528),(529,529,529),(530,530,530), +(531,531,531),(532,532,532),(533,533,533),(534,534,534),(535,535,535), +(536,536,536),(537,537,537),(538,538,538),(539,539,539),(540,540,540), +(541,541,541),(542,542,542),(543,543,543),(544,544,544),(545,545,545), +(546,546,546),(547,547,547),(548,548,548),(549,549,549),(550,550,550), +(551,551,551),(552,552,552),(553,553,553),(554,554,554),(555,555,555), +(556,556,556),(557,557,557),(558,558,558),(559,559,559),(560,560,560), +(561,561,561),(562,562,562),(563,563,563),(564,564,564),(565,565,565), +(566,566,566),(567,567,567),(568,568,568),(569,569,569),(570,570,570), +(571,571,571),(572,572,572),(573,573,573),(574,574,574),(575,575,575), +(576,576,576),(577,577,577),(578,578,578),(579,579,579),(580,580,580), +(581,581,581),(582,582,582),(583,583,583),(584,584,584),(585,585,585), +(586,586,586),(587,587,587),(588,588,588),(589,589,589),(590,590,590), +(591,591,591),(592,592,592),(593,593,593),(594,594,594),(595,595,595), +(596,596,596),(597,597,597),(598,598,598),(599,599,599),(600,600,600), +(601,601,601),(602,602,602),(603,603,603),(604,604,604),(605,605,605), +(606,606,606),(607,607,607),(608,608,608),(609,609,609),(610,610,610), +(611,611,611),(612,612,612),(613,613,613),(614,614,614),(615,615,615), +(616,616,616),(617,617,617),(618,618,618),(619,619,619),(620,620,620), +(621,621,621),(622,622,622),(623,623,623),(624,624,624),(625,625,625), +(626,626,626),(627,627,627),(628,628,628),(629,629,629),(630,630,630), +(631,631,631),(632,632,632),(633,633,633),(634,634,634),(635,635,635), +(636,636,636),(637,637,637),(638,638,638),(639,639,639),(640,640,640), +(641,641,641),(642,642,642),(643,643,643),(644,644,644),(645,645,645), +(646,646,646),(647,647,647),(648,648,648),(649,649,649),(650,650,650), +(651,651,651),(652,652,652),(653,653,653),(654,654,654),(655,655,655), +(656,656,656),(657,657,657),(658,658,658),(659,659,659),(660,660,660), +(661,661,661),(662,662,662),(663,663,663),(664,664,664),(665,665,665), +(666,666,666),(667,667,667),(668,668,668),(669,669,669),(670,670,670), +(671,671,671),(672,672,672),(673,673,673),(674,674,674),(675,675,675), +(676,676,676),(677,677,677),(678,678,678),(679,679,679),(680,680,680), +(681,681,681),(682,682,682),(683,683,683),(684,684,684),(685,685,685), +(686,686,686),(687,687,687),(688,688,688),(689,689,689),(690,690,690), +(691,691,691),(692,692,692),(693,693,693),(694,694,694),(695,695,695), +(696,696,696),(697,697,697),(698,698,698),(699,699,699),(700,700,700), +(701,701,701),(702,702,702),(703,703,703),(704,704,704),(705,705,705), +(706,706,706),(707,707,707),(708,708,708),(709,709,709),(710,710,710), +(711,711,711),(712,712,712),(713,713,713),(714,714,714),(715,715,715), +(716,716,716),(717,717,717),(718,718,718),(719,719,719),(720,720,720), +(721,721,721),(722,722,722),(723,723,723),(724,724,724),(725,725,725), +(726,726,726),(727,727,727),(728,728,728),(729,729,729),(730,730,730), +(731,731,731),(732,732,732),(733,733,733),(734,734,734),(735,735,735), +(736,736,736),(737,737,737),(738,738,738),(739,739,739),(740,740,740), +(741,741,741),(742,742,742),(743,743,743),(744,744,744),(745,745,745), +(746,746,746),(747,747,747),(748,748,748),(749,749,749),(750,750,750), +(751,751,751),(752,752,752),(753,753,753),(754,754,754),(755,755,755), +(756,756,756),(757,757,757),(758,758,758),(759,759,759),(760,760,760), +(761,761,761),(762,762,762),(763,763,763),(764,764,764),(765,765,765), +(766,766,766),(767,767,767),(768,768,768),(769,769,769),(770,770,770), +(771,771,771),(772,772,772),(773,773,773),(774,774,774),(775,775,775), +(776,776,776),(777,777,777),(778,778,778),(779,779,779),(780,780,780), +(781,781,781),(782,782,782),(783,783,783),(784,784,784),(785,785,785), +(786,786,786),(787,787,787),(788,788,788),(789,789,789),(790,790,790), +(791,791,791),(792,792,792),(793,793,793),(794,794,794),(795,795,795), +(796,796,796),(797,797,797),(798,798,798),(799,799,799),(800,800,800), +(801,801,801),(802,802,802),(803,803,803),(804,804,804),(805,805,805), +(806,806,806),(807,807,807),(808,808,808),(809,809,809),(810,810,810), +(811,811,811),(812,812,812),(813,813,813),(814,814,814),(815,815,815), +(816,816,816),(817,817,817),(818,818,818),(819,819,819),(820,820,820), +(821,821,821),(822,822,822),(823,823,823),(824,824,824),(825,825,825), +(826,826,826),(827,827,827),(828,828,828),(829,829,829),(830,830,830), +(831,831,831),(832,832,832),(833,833,833),(834,834,834),(835,835,835), +(836,836,836),(837,837,837),(838,838,838),(839,839,839),(840,840,840), +(841,841,841),(842,842,842),(843,843,843),(844,844,844),(845,845,845), +(846,846,846),(847,847,847),(848,848,848),(849,849,849),(850,850,850), +(851,851,851),(852,852,852),(853,853,853),(854,854,854),(855,855,855), +(856,856,856),(857,857,857),(858,858,858),(859,859,859),(860,860,860), +(861,861,861),(862,862,862),(863,863,863),(864,864,864),(865,865,865), +(866,866,866),(867,867,867),(868,868,868),(869,869,869),(870,870,870), +(871,871,871),(872,872,872),(873,873,873),(874,874,874),(875,875,875), +(876,876,876),(877,877,877),(878,878,878),(879,879,879),(880,880,880), +(881,881,881),(882,882,882),(883,883,883),(884,884,884),(885,885,885), +(886,886,886),(887,887,887),(888,888,888),(889,889,889),(890,890,890), +(891,891,891),(892,892,892),(893,893,893),(894,894,894),(895,895,895), +(896,896,896),(897,897,897),(898,898,898),(899,899,899),(900,900,900), +(901,901,901),(902,902,902),(903,903,903),(904,904,904),(905,905,905), +(906,906,906),(907,907,907),(908,908,908),(909,909,909),(910,910,910), +(911,911,911),(912,912,912),(913,913,913),(914,914,914),(915,915,915), +(916,916,916),(917,917,917),(918,918,918),(919,919,919),(920,920,920), +(921,921,921),(922,922,922),(923,923,923),(924,924,924),(925,925,925), +(926,926,926),(927,927,927),(928,928,928),(929,929,929),(930,930,930), +(931,931,931),(932,932,932),(933,933,933),(934,934,934),(935,935,935), +(936,936,936),(937,937,937),(938,938,938),(939,939,939),(940,940,940), +(941,941,941),(942,942,942),(943,943,943),(944,944,944),(945,945,945), +(946,946,946),(947,947,947),(948,948,948),(949,949,949),(950,950,950), +(951,951,951),(952,952,952),(953,953,953),(954,954,954),(955,955,955), +(956,956,956),(957,957,957),(958,958,958),(959,959,959),(960,960,960), +(961,961,961),(962,962,962),(963,963,963),(964,964,964),(965,965,965), +(966,966,966),(967,967,967),(968,968,968),(969,969,969),(970,970,970), +(971,971,971),(972,972,972),(973,973,973),(974,974,974),(975,975,975), +(976,976,976),(977,977,977),(978,978,978),(979,979,979),(980,980,980), +(981,981,981),(982,982,982),(983,983,983),(984,984,984),(985,985,985), +(986,986,986),(987,987,987),(988,988,988),(989,989,989),(990,990,990), +(991,991,991),(992,992,992),(993,993,993),(994,994,994),(995,995,995), +(996,996,996),(997,997,997),(998,998,998),(999,999,999),(1000,1000,1000), +(1001,1001,1001),(1002,1002,1002),(1003,1003,1003),(1004,1004,1004),(1005,1005,1005), +(1006,1006,1006),(1007,1007,1007),(1008,1008,1008),(1009,1009,1009),(1010,1010,1010), +(1011,1011,1011),(1012,1012,1012),(1013,1013,1013),(1014,1014,1014),(1015,1015,1015), +(1016,1016,1016),(1017,1017,1017),(1018,1018,1018),(1019,1019,1019),(1020,1020,1020), +(1021,1021,1021),(1022,1022,1022),(1023,1023,1023),(1024,1024,1024),(1025,1025,1025), +(1026,1026,1026),(1027,1027,1027),(1028,1028,1028),(1029,1029,1029),(1030,1030,1030), +(1031,1031,1031),(1032,1032,1032),(1033,1033,1033),(1034,1034,1034),(1035,1035,1035), +(1036,1036,1036),(1037,1037,1037),(1038,1038,1038),(1039,1039,1039),(1040,1040,1040), +(1041,1041,1041),(1042,1042,1042),(1043,1043,1043),(1044,1044,1044),(1045,1045,1045), +(1046,1046,1046),(1047,1047,1047),(1048,1048,1048),(1049,1049,1049),(1050,1050,1050), +(1051,1051,1051),(1052,1052,1052),(1053,1053,1053),(1054,1054,1054),(1055,1055,1055), +(1056,1056,1056),(1057,1057,1057),(1058,1058,1058),(1059,1059,1059),(1060,1060,1060), +(1061,1061,1061),(1062,1062,1062),(1063,1063,1063),(1064,1064,1064),(1065,1065,1065), +(1066,1066,1066),(1067,1067,1067),(1068,1068,1068),(1069,1069,1069),(1070,1070,1070), +(1071,1071,1071),(1072,1072,1072),(1073,1073,1073),(1074,1074,1074),(1075,1075,1075), +(1076,1076,1076),(1077,1077,1077),(1078,1078,1078),(1079,1079,1079),(1080,1080,1080), +(1081,1081,1081),(1082,1082,1082),(1083,1083,1083),(1084,1084,1084),(1085,1085,1085), +(1086,1086,1086),(1087,1087,1087),(1088,1088,1088),(1089,1089,1089),(1090,1090,1090), +(1091,1091,1091),(1092,1092,1092),(1093,1093,1093),(1094,1094,1094),(1095,1095,1095), +(1096,1096,1096),(1097,1097,1097),(1098,1098,1098),(1099,1099,1099),(1100,1100,1100), +(1101,1101,1101),(1102,1102,1102),(1103,1103,1103),(1104,1104,1104),(1105,1105,1105), +(1106,1106,1106),(1107,1107,1107),(1108,1108,1108),(1109,1109,1109),(1110,1110,1110), +(1111,1111,1111),(1112,1112,1112),(1113,1113,1113),(1114,1114,1114),(1115,1115,1115), +(1116,1116,1116),(1117,1117,1117),(1118,1118,1118),(1119,1119,1119),(1120,1120,1120), +(1121,1121,1121),(1122,1122,1122),(1123,1123,1123),(1124,1124,1124),(1125,1125,1125), +(1126,1126,1126),(1127,1127,1127),(1128,1128,1128),(1129,1129,1129),(1130,1130,1130), +(1131,1131,1131),(1132,1132,1132),(1133,1133,1133),(1134,1134,1134),(1135,1135,1135), +(1136,1136,1136),(1137,1137,1137),(1138,1138,1138),(1139,1139,1139),(1140,1140,1140), +(1141,1141,1141),(1142,1142,1142),(1143,1143,1143),(1144,1144,1144),(1145,1145,1145), +(1146,1146,1146),(1147,1147,1147),(1148,1148,1148),(1149,1149,1149),(1150,1150,1150), +(1151,1151,1151),(1152,1152,1152),(1153,1153,1153),(1154,1154,1154),(1155,1155,1155), +(1156,1156,1156),(1157,1157,1157),(1158,1158,1158),(1159,1159,1159),(1160,1160,1160), +(1161,1161,1161),(1162,1162,1162),(1163,1163,1163),(1164,1164,1164),(1165,1165,1165), +(1166,1166,1166),(1167,1167,1167),(1168,1168,1168),(1169,1169,1169),(1170,1170,1170), +(1171,1171,1171),(1172,1172,1172),(1173,1173,1173),(1174,1174,1174),(1175,1175,1175), +(1176,1176,1176),(1177,1177,1177),(1178,1178,1178),(1179,1179,1179),(1180,1180,1180), +(1181,1181,1181),(1182,1182,1182),(1183,1183,1183),(1184,1184,1184),(1185,1185,1185), +(1186,1186,1186),(1187,1187,1187),(1188,1188,1188),(1189,1189,1189),(1190,1190,1190), +(1191,1191,1191),(1192,1192,1192),(1193,1193,1193),(1194,1194,1194),(1195,1195,1195), +(1196,1196,1196),(1197,1197,1197),(1198,1198,1198),(1199,1199,1199),(1200,1200,1200), +(1201,1201,1201),(1202,1202,1202),(1203,1203,1203),(1204,1204,1204),(1205,1205,1205), +(1206,1206,1206),(1207,1207,1207),(1208,1208,1208),(1209,1209,1209),(1210,1210,1210), +(1211,1211,1211),(1212,1212,1212),(1213,1213,1213),(1214,1214,1214),(1215,1215,1215), +(1216,1216,1216),(1217,1217,1217),(1218,1218,1218),(1219,1219,1219),(1220,1220,1220), +(1221,1221,1221),(1222,1222,1222),(1223,1223,1223),(1224,1224,1224),(1225,1225,1225), +(1226,1226,1226),(1227,1227,1227),(1228,1228,1228),(1229,1229,1229),(1230,1230,1230), +(1231,1231,1231),(1232,1232,1232),(1233,1233,1233),(1234,1234,1234),(1235,1235,1235), +(1236,1236,1236),(1237,1237,1237),(1238,1238,1238),(1239,1239,1239),(1240,1240,1240), +(1241,1241,1241),(1242,1242,1242),(1243,1243,1243),(1244,1244,1244),(1245,1245,1245), +(1246,1246,1246),(1247,1247,1247),(1248,1248,1248),(1249,1249,1249),(1250,1250,1250), +(1251,1251,1251),(1252,1252,1252),(1253,1253,1253),(1254,1254,1254),(1255,1255,1255), +(1256,1256,1256),(1257,1257,1257),(1258,1258,1258),(1259,1259,1259),(1260,1260,1260), +(1261,1261,1261),(1262,1262,1262),(1263,1263,1263),(1264,1264,1264),(1265,1265,1265), +(1266,1266,1266),(1267,1267,1267),(1268,1268,1268),(1269,1269,1269),(1270,1270,1270), +(1271,1271,1271),(1272,1272,1272),(1273,1273,1273),(1274,1274,1274),(1275,1275,1275), +(1276,1276,1276),(1277,1277,1277),(1278,1278,1278),(1279,1279,1279),(1280,1280,1280), +(1281,1281,1281),(1282,1282,1282),(1283,1283,1283),(1284,1284,1284),(1285,1285,1285), +(1286,1286,1286),(1287,1287,1287),(1288,1288,1288),(1289,1289,1289),(1290,1290,1290), +(1291,1291,1291),(1292,1292,1292),(1293,1293,1293),(1294,1294,1294),(1295,1295,1295), +(1296,1296,1296),(1297,1297,1297),(1298,1298,1298),(1299,1299,1299),(1300,1300,1300), +(1301,1301,1301),(1302,1302,1302),(1303,1303,1303),(1304,1304,1304),(1305,1305,1305), +(1306,1306,1306),(1307,1307,1307),(1308,1308,1308),(1309,1309,1309),(1310,1310,1310), +(1311,1311,1311),(1312,1312,1312),(1313,1313,1313),(1314,1314,1314),(1315,1315,1315), +(1316,1316,1316),(1317,1317,1317),(1318,1318,1318),(1319,1319,1319),(1320,1320,1320), +(1321,1321,1321),(1322,1322,1322),(1323,1323,1323),(1324,1324,1324),(1325,1325,1325), +(1326,1326,1326),(1327,1327,1327),(1328,1328,1328),(1329,1329,1329),(1330,1330,1330), +(1331,1331,1331),(1332,1332,1332),(1333,1333,1333),(1334,1334,1334),(1335,1335,1335), +(1336,1336,1336),(1337,1337,1337),(1338,1338,1338),(1339,1339,1339),(1340,1340,1340), +(1341,1341,1341),(1342,1342,1342),(1343,1343,1343),(1344,1344,1344),(1345,1345,1345), +(1346,1346,1346),(1347,1347,1347),(1348,1348,1348),(1349,1349,1349),(1350,1350,1350), +(1351,1351,1351),(1352,1352,1352),(1353,1353,1353),(1354,1354,1354),(1355,1355,1355), +(1356,1356,1356),(1357,1357,1357),(1358,1358,1358),(1359,1359,1359),(1360,1360,1360), +(1361,1361,1361),(1362,1362,1362),(1363,1363,1363),(1364,1364,1364),(1365,1365,1365), +(1366,1366,1366),(1367,1367,1367),(1368,1368,1368),(1369,1369,1369),(1370,1370,1370), +(1371,1371,1371),(1372,1372,1372),(1373,1373,1373),(1374,1374,1374),(1375,1375,1375), +(1376,1376,1376),(1377,1377,1377),(1378,1378,1378),(1379,1379,1379),(1380,1380,1380), +(1381,1381,1381),(1382,1382,1382),(1383,1383,1383),(1384,1384,1384),(1385,1385,1385), +(1386,1386,1386),(1387,1387,1387),(1388,1388,1388),(1389,1389,1389),(1390,1390,1390), +(1391,1391,1391),(1392,1392,1392),(1393,1393,1393),(1394,1394,1394),(1395,1395,1395), +(1396,1396,1396),(1397,1397,1397),(1398,1398,1398),(1399,1399,1399),(1400,1400,1400), +(1401,1401,1401),(1402,1402,1402),(1403,1403,1403),(1404,1404,1404),(1405,1405,1405), +(1406,1406,1406),(1407,1407,1407),(1408,1408,1408),(1409,1409,1409),(1410,1410,1410), +(1411,1411,1411),(1412,1412,1412),(1413,1413,1413),(1414,1414,1414),(1415,1415,1415), +(1416,1416,1416),(1417,1417,1417),(1418,1418,1418),(1419,1419,1419),(1420,1420,1420), +(1421,1421,1421),(1422,1422,1422),(1423,1423,1423),(1424,1424,1424),(1425,1425,1425), +(1426,1426,1426),(1427,1427,1427),(1428,1428,1428),(1429,1429,1429),(1430,1430,1430), +(1431,1431,1431),(1432,1432,1432),(1433,1433,1433),(1434,1434,1434),(1435,1435,1435), +(1436,1436,1436),(1437,1437,1437),(1438,1438,1438),(1439,1439,1439),(1440,1440,1440), +(1441,1441,1441),(1442,1442,1442),(1443,1443,1443),(1444,1444,1444),(1445,1445,1445), +(1446,1446,1446),(1447,1447,1447),(1448,1448,1448),(1449,1449,1449),(1450,1450,1450), +(1451,1451,1451),(1452,1452,1452),(1453,1453,1453),(1454,1454,1454),(1455,1455,1455), +(1456,1456,1456),(1457,1457,1457),(1458,1458,1458),(1459,1459,1459),(1460,1460,1460), +(1461,1461,1461),(1462,1462,1462),(1463,1463,1463),(1464,1464,1464),(1465,1465,1465), +(1466,1466,1466),(1467,1467,1467),(1468,1468,1468),(1469,1469,1469),(1470,1470,1470), +(1471,1471,1471),(1472,1472,1472),(1473,1473,1473),(1474,1474,1474),(1475,1475,1475), +(1476,1476,1476),(1477,1477,1477),(1478,1478,1478),(1479,1479,1479),(1480,1480,1480), +(1481,1481,1481),(1482,1482,1482),(1483,1483,1483),(1484,1484,1484),(1485,1485,1485), +(1486,1486,1486),(1487,1487,1487),(1488,1488,1488),(1489,1489,1489),(1490,1490,1490), +(1491,1491,1491),(1492,1492,1492),(1493,1493,1493),(1494,1494,1494),(1495,1495,1495), +(1496,1496,1496),(1497,1497,1497),(1498,1498,1498),(1499,1499,1499),(1500,1500,1500), +(1501,1501,1501),(1502,1502,1502),(1503,1503,1503),(1504,1504,1504),(1505,1505,1505), +(1506,1506,1506),(1507,1507,1507),(1508,1508,1508),(1509,1509,1509),(1510,1510,1510), +(1511,1511,1511),(1512,1512,1512),(1513,1513,1513),(1514,1514,1514),(1515,1515,1515), +(1516,1516,1516),(1517,1517,1517),(1518,1518,1518),(1519,1519,1519),(1520,1520,1520), +(1521,1521,1521),(1522,1522,1522),(1523,1523,1523),(1524,1524,1524),(1525,1525,1525), +(1526,1526,1526),(1527,1527,1527),(1528,1528,1528),(1529,1529,1529),(1530,1530,1530), +(1531,1531,1531),(1532,1532,1532),(1533,1533,1533),(1534,1534,1534),(1535,1535,1535), +(1536,1536,1536),(1537,1537,1537),(1538,1538,1538),(1539,1539,1539),(1540,1540,1540), +(1541,1541,1541),(1542,1542,1542),(1543,1543,1543),(1544,1544,1544),(1545,1545,1545), +(1546,1546,1546),(1547,1547,1547),(1548,1548,1548),(1549,1549,1549),(1550,1550,1550), +(1551,1551,1551),(1552,1552,1552),(1553,1553,1553),(1554,1554,1554),(1555,1555,1555), +(1556,1556,1556),(1557,1557,1557),(1558,1558,1558),(1559,1559,1559),(1560,1560,1560), +(1561,1561,1561),(1562,1562,1562),(1563,1563,1563),(1564,1564,1564),(1565,1565,1565), +(1566,1566,1566),(1567,1567,1567),(1568,1568,1568),(1569,1569,1569),(1570,1570,1570), +(1571,1571,1571),(1572,1572,1572),(1573,1573,1573),(1574,1574,1574),(1575,1575,1575), +(1576,1576,1576),(1577,1577,1577),(1578,1578,1578),(1579,1579,1579),(1580,1580,1580), +(1581,1581,1581),(1582,1582,1582),(1583,1583,1583),(1584,1584,1584),(1585,1585,1585), +(1586,1586,1586),(1587,1587,1587),(1588,1588,1588),(1589,1589,1589),(1590,1590,1590), +(1591,1591,1591),(1592,1592,1592),(1593,1593,1593),(1594,1594,1594),(1595,1595,1595), +(1596,1596,1596),(1597,1597,1597),(1598,1598,1598),(1599,1599,1599),(1600,1600,1600), +(1601,1601,1601),(1602,1602,1602),(1603,1603,1603),(1604,1604,1604),(1605,1605,1605), +(1606,1606,1606),(1607,1607,1607),(1608,1608,1608),(1609,1609,1609),(1610,1610,1610), +(1611,1611,1611),(1612,1612,1612),(1613,1613,1613),(1614,1614,1614),(1615,1615,1615), +(1616,1616,1616),(1617,1617,1617),(1618,1618,1618),(1619,1619,1619),(1620,1620,1620), +(1621,1621,1621),(1622,1622,1622),(1623,1623,1623),(1624,1624,1624),(1625,1625,1625), +(1626,1626,1626),(1627,1627,1627),(1628,1628,1628),(1629,1629,1629),(1630,1630,1630), +(1631,1631,1631),(1632,1632,1632),(1633,1633,1633),(1634,1634,1634),(1635,1635,1635), +(1636,1636,1636),(1637,1637,1637),(1638,1638,1638),(1639,1639,1639),(1640,1640,1640), +(1641,1641,1641),(1642,1642,1642),(1643,1643,1643),(1644,1644,1644),(1645,1645,1645), +(1646,1646,1646),(1647,1647,1647),(1648,1648,1648),(1649,1649,1649),(1650,1650,1650), +(1651,1651,1651),(1652,1652,1652),(1653,1653,1653),(1654,1654,1654),(1655,1655,1655), +(1656,1656,1656),(1657,1657,1657),(1658,1658,1658),(1659,1659,1659),(1660,1660,1660), +(1661,1661,1661),(1662,1662,1662),(1663,1663,1663),(1664,1664,1664),(1665,1665,1665), +(1666,1666,1666),(1667,1667,1667),(1668,1668,1668),(1669,1669,1669),(1670,1670,1670), +(1671,1671,1671),(1672,1672,1672),(1673,1673,1673),(1674,1674,1674),(1675,1675,1675), +(1676,1676,1676),(1677,1677,1677),(1678,1678,1678),(1679,1679,1679),(1680,1680,1680), +(1681,1681,1681),(1682,1682,1682),(1683,1683,1683),(1684,1684,1684),(1685,1685,1685), +(1686,1686,1686),(1687,1687,1687),(1688,1688,1688),(1689,1689,1689),(1690,1690,1690), +(1691,1691,1691),(1692,1692,1692),(1693,1693,1693),(1694,1694,1694),(1695,1695,1695), +(1696,1696,1696),(1697,1697,1697),(1698,1698,1698),(1699,1699,1699),(1700,1700,1700), +(1701,1701,1701),(1702,1702,1702),(1703,1703,1703),(1704,1704,1704),(1705,1705,1705), +(1706,1706,1706),(1707,1707,1707),(1708,1708,1708),(1709,1709,1709),(1710,1710,1710), +(1711,1711,1711),(1712,1712,1712),(1713,1713,1713),(1714,1714,1714),(1715,1715,1715), +(1716,1716,1716),(1717,1717,1717),(1718,1718,1718),(1719,1719,1719),(1720,1720,1720), +(1721,1721,1721),(1722,1722,1722),(1723,1723,1723),(1724,1724,1724),(1725,1725,1725), +(1726,1726,1726),(1727,1727,1727),(1728,1728,1728),(1729,1729,1729),(1730,1730,1730), +(1731,1731,1731),(1732,1732,1732),(1733,1733,1733),(1734,1734,1734),(1735,1735,1735), +(1736,1736,1736),(1737,1737,1737),(1738,1738,1738),(1739,1739,1739),(1740,1740,1740), +(1741,1741,1741),(1742,1742,1742),(1743,1743,1743),(1744,1744,1744),(1745,1745,1745), +(1746,1746,1746),(1747,1747,1747),(1748,1748,1748),(1749,1749,1749),(1750,1750,1750), +(1751,1751,1751),(1752,1752,1752),(1753,1753,1753),(1754,1754,1754),(1755,1755,1755), +(1756,1756,1756),(1757,1757,1757),(1758,1758,1758),(1759,1759,1759),(1760,1760,1760), +(1761,1761,1761),(1762,1762,1762),(1763,1763,1763),(1764,1764,1764),(1765,1765,1765), +(1766,1766,1766),(1767,1767,1767),(1768,1768,1768),(1769,1769,1769),(1770,1770,1770), +(1771,1771,1771),(1772,1772,1772),(1773,1773,1773),(1774,1774,1774),(1775,1775,1775), +(1776,1776,1776),(1777,1777,1777),(1778,1778,1778),(1779,1779,1779),(1780,1780,1780), +(1781,1781,1781),(1782,1782,1782),(1783,1783,1783),(1784,1784,1784),(1785,1785,1785), +(1786,1786,1786),(1787,1787,1787),(1788,1788,1788),(1789,1789,1789),(1790,1790,1790), +(1791,1791,1791),(1792,1792,1792),(1793,1793,1793),(1794,1794,1794),(1795,1795,1795), +(1796,1796,1796),(1797,1797,1797),(1798,1798,1798),(1799,1799,1799),(1800,1800,1800), +(1801,1801,1801),(1802,1802,1802),(1803,1803,1803),(1804,1804,1804),(1805,1805,1805), +(1806,1806,1806),(1807,1807,1807),(1808,1808,1808),(1809,1809,1809),(1810,1810,1810), +(1811,1811,1811),(1812,1812,1812),(1813,1813,1813),(1814,1814,1814),(1815,1815,1815), +(1816,1816,1816),(1817,1817,1817),(1818,1818,1818),(1819,1819,1819),(1820,1820,1820), +(1821,1821,1821),(1822,1822,1822),(1823,1823,1823),(1824,1824,1824),(1825,1825,1825), +(1826,1826,1826),(1827,1827,1827),(1828,1828,1828),(1829,1829,1829),(1830,1830,1830), +(1831,1831,1831),(1832,1832,1832),(1833,1833,1833),(1834,1834,1834),(1835,1835,1835), +(1836,1836,1836),(1837,1837,1837),(1838,1838,1838),(1839,1839,1839),(1840,1840,1840), +(1841,1841,1841),(1842,1842,1842),(1843,1843,1843),(1844,1844,1844),(1845,1845,1845), +(1846,1846,1846),(1847,1847,1847),(1848,1848,1848),(1849,1849,1849),(1850,1850,1850), +(1851,1851,1851),(1852,1852,1852),(1853,1853,1853),(1854,1854,1854),(1855,1855,1855), +(1856,1856,1856),(1857,1857,1857),(1858,1858,1858),(1859,1859,1859),(1860,1860,1860), +(1861,1861,1861),(1862,1862,1862),(1863,1863,1863),(1864,1864,1864),(1865,1865,1865), +(1866,1866,1866),(1867,1867,1867),(1868,1868,1868),(1869,1869,1869),(1870,1870,1870), +(1871,1871,1871),(1872,1872,1872),(1873,1873,1873),(1874,1874,1874),(1875,1875,1875), +(1876,1876,1876),(1877,1877,1877),(1878,1878,1878),(1879,1879,1879),(1880,1880,1880), +(1881,1881,1881),(1882,1882,1882),(1883,1883,1883),(1884,1884,1884),(1885,1885,1885), +(1886,1886,1886),(1887,1887,1887),(1888,1888,1888),(1889,1889,1889),(1890,1890,1890), +(1891,1891,1891),(1892,1892,1892),(1893,1893,1893),(1894,1894,1894),(1895,1895,1895), +(1896,1896,1896),(1897,1897,1897),(1898,1898,1898),(1899,1899,1899),(1900,1900,1900), +(1901,1901,1901),(1902,1902,1902),(1903,1903,1903),(1904,1904,1904),(1905,1905,1905), +(1906,1906,1906),(1907,1907,1907),(1908,1908,1908),(1909,1909,1909),(1910,1910,1910), +(1911,1911,1911),(1912,1912,1912),(1913,1913,1913),(1914,1914,1914),(1915,1915,1915), +(1916,1916,1916),(1917,1917,1917),(1918,1918,1918),(1919,1919,1919),(1920,1920,1920), +(1921,1921,1921),(1922,1922,1922),(1923,1923,1923),(1924,1924,1924),(1925,1925,1925), +(1926,1926,1926),(1927,1927,1927),(1928,1928,1928),(1929,1929,1929),(1930,1930,1930), +(1931,1931,1931),(1932,1932,1932),(1933,1933,1933),(1934,1934,1934),(1935,1935,1935), +(1936,1936,1936),(1937,1937,1937),(1938,1938,1938),(1939,1939,1939),(1940,1940,1940), +(1941,1941,1941),(1942,1942,1942),(1943,1943,1943),(1944,1944,1944),(1945,1945,1945), +(1946,1946,1946),(1947,1947,1947),(1948,1948,1948),(1949,1949,1949),(1950,1950,1950), +(1951,1951,1951),(1952,1952,1952),(1953,1953,1953),(1954,1954,1954),(1955,1955,1955), +(1956,1956,1956),(1957,1957,1957),(1958,1958,1958),(1959,1959,1959),(1960,1960,1960), +(1961,1961,1961),(1962,1962,1962),(1963,1963,1963),(1964,1964,1964),(1965,1965,1965), +(1966,1966,1966),(1967,1967,1967),(1968,1968,1968),(1969,1969,1969),(1970,1970,1970), +(1971,1971,1971),(1972,1972,1972),(1973,1973,1973),(1974,1974,1974),(1975,1975,1975), +(1976,1976,1976),(1977,1977,1977),(1978,1978,1978),(1979,1979,1979),(1980,1980,1980), +(1981,1981,1981),(1982,1982,1982),(1983,1983,1983),(1984,1984,1984),(1985,1985,1985), +(1986,1986,1986),(1987,1987,1987),(1988,1988,1988),(1989,1989,1989),(1990,1990,1990), +(1991,1991,1991),(1992,1992,1992),(1993,1993,1993),(1994,1994,1994),(1995,1995,1995), +(1996,1996,1996),(1997,1997,1997),(1998,1998,1998),(1999,1999,1999); +SELECT COUNT(*) FROM t1; +COUNT(*) +2000 +INSERT INTO t1 VALUES (1,1,1); +ERROR 23000: Duplicate entry '1' for key 'PRIMARY' +INSERT INTO t1 VALUES +(1,1,1),(2,2,2),(3,3,3),(4,4,4),(5,5,5), +(6,6,6),(7,7,7),(8,8,8),(9,9,9),(10,10,10); +ERROR 23000: Can't write; duplicate key in table 't1' +select count(*) from t1; +count(*) +2000 +begin; +SELECT COUNT(*) FROM t1; +COUNT(*) +2000 +INSERT INTO t1 VALUES +(2001,2001,2001),(2002,2002,2002),(2003,2003,2003),(2004,2004,2004),(2005,2005,2005); +SELECT COUNT(*) FROM t1; +COUNT(*) +2005 +rollback; +begin; +INSERT INTO t1 VALUES +(1,1,1),(2,2,2),(3,3,3),(4,4,4),(5,5,5), +(6,6,6),(7,7,7),(8,8,8),(9,9,9),(10,10,10); +ERROR 23000: Can't write; duplicate key in table 't1' +commit; +ERROR HY000: Got error 4350 'Transaction already aborted' from NDBCLUSTER +select * from t1 where pk1=1; +pk1 b c +1 1 1 +select * from t1 where pk1=10; +pk1 b c +10 10 10 +select count(*) from t1 where pk1 <= 10 order by pk1; +count(*) +11 +select count(*) from t1; +count(*) +2000 +begin; +INSERT INTO t1 VALUES +(1,1,1),(2,2,2),(3,3,3),(4,4,4),(5,5,5), +(6,6,6),(7,7,7),(8,8,8),(9,9,9),(10,10,10); +ERROR 23000: Can't write; duplicate key in table 't1' +rollback; +select * from t1 where pk1=1; +pk1 b c +1 1 1 +select * from t1 where pk1=10; +pk1 b c +10 10 10 +select count(*) from t1 where pk1 <= 10 order by pk1; +count(*) +11 +select count(*) from t1; +count(*) +2000 +begin; +INSERT INTO t1 VALUES +(1,1,1),(2,2,2),(3,3,3),(4,4,4),(5,5,5), +(6,6,6),(7,7,7),(8,8,8),(9,9,9),(10,10,10); +ERROR 23000: Can't write; duplicate key in table 't1' +SELECT * FROM t1 WHERE pk1=10; +ERROR HY000: Got error 4350 'Transaction already aborted' from NDBCLUSTER +rollback; +select * from t1 where pk1=1; +pk1 b c +1 1 1 +select * from t1 where pk1=10; +pk1 b c +10 10 10 +select count(*) from t1 where pk1 <= 10 order by pk1; +count(*) +11 +select count(*) from t1; +count(*) +2000 +begin; +INSERT INTO t1 VALUES +(1,1,1),(2,2,2),(3,3,3),(4,4,4),(5,5,5), +(6,6,6),(7,7,7),(8,8,8),(9,9,9),(10,10,10); +ERROR 23000: Can't write; duplicate key in table 't1' +SELECT * FROM t1 WHERE pk1=10; +ERROR HY000: Got error 4350 'Transaction already aborted' from NDBCLUSTER +SELECT * FROM t1 WHERE pk1=10; +ERROR HY000: Got error 4350 'Transaction already aborted' from NDBCLUSTER +commit; +ERROR HY000: Got error 4350 'Transaction already aborted' from NDBCLUSTER +select * from t1 where pk1=1; +pk1 b c +1 1 1 +select * from t1 where pk1=10; +pk1 b c +10 10 10 +select count(*) from t1 where pk1 <= 10 order by pk1; +count(*) +11 +select count(*) from t1; +count(*) +2000 +begin; +INSERT INTO t1 VALUES +(1,1,1),(2,2,2),(3,3,3),(4,4,4),(5,5,5), +(6,6,6),(7,7,7),(8,8,8),(9,9,9),(10,10,10); +ERROR 23000: Can't write; duplicate key in table 't1' +INSERT INTO t1 values (4000, 40, 44); +ERROR HY000: Got error 4350 'Transaction already aborted' from NDBCLUSTER +rollback; +select * from t1 where pk1=1; +pk1 b c +1 1 1 +select * from t1 where pk1=10; +pk1 b c +10 10 10 +select count(*) from t1 where pk1 <= 10 order by pk1; +count(*) +11 +select count(*) from t1; +count(*) +2000 +insert into t1 select * from t1 where b < 10 order by pk1; +ERROR 23000: Can't write; duplicate key in table 't1' +DELETE FROM t1 WHERE pk1=2; +begin; +INSERT IGNORE INTO t1 VALUES(1,2,3),(2,3,4); +select * from t1 where pk1 < 3 order by pk1; +pk1 b c +0 0 0 +1 1 1 +2 3 4 +rollback; +INSERT IGNORE INTO t1 VALUES(1,2,3),(2,3,4); +select * from t1 where pk1 < 3 order by pk1; +pk1 b c +0 0 0 +1 1 1 +2 3 4 +REPLACE INTO t1 values(1, 78, 3); +select * from t1 where pk1=1; +pk1 b c +1 78 3 +INSERT INTO t1 VALUES(1,1,1),(3,4,5) ON DUPLICATE KEY UPDATE b=79; +select * from t1 where pk1 < 4 order by pk1; +pk1 b c +0 0 0 +1 79 3 +2 3 4 +3 79 3 +INSERT INTO t1 VALUES(1,1,1),(3,4,5) ON DUPLICATE KEY UPDATE b=pk1+c; +select * from t1 where pk1 < 4 order by pk1; +pk1 b c +0 0 0 +1 4 3 +2 3 4 +3 6 3 +DELETE FROM t1 WHERE pk1 = 2 OR pk1 = 4 OR pk1 = 6; +INSERT INTO t1 VALUES(1,1,1),(2,2,17),(3,4,5) ON DUPLICATE KEY UPDATE pk1=b; +select * from t1 where pk1 = b and b != c order by pk1; +pk1 b c +2 2 17 +4 4 3 +6 6 3 +DELETE FROM t1; +CREATE UNIQUE INDEX bi ON t1(b); +INSERT INTO t1 VALUES +(1,1,1),(2,2,2),(3,3,3),(4,4,4),(5,5,5), +(6,6,6),(7,7,7),(8,8,8),(9,9,9),(10,10,10); +INSERT INTO t1 VALUES(0,1,0),(21,21,21) ON DUPLICATE KEY UPDATE pk1=b+10,b=b+10; +select * from t1 order by pk1; +pk1 b c +2 2 2 +3 3 3 +4 4 4 +5 5 5 +6 6 6 +7 7 7 +8 8 8 +9 9 9 +10 10 10 +11 11 1 +21 21 21 +DROP TABLE t1; +CREATE TABLE t1(a INT) ENGINE=ndb; +INSERT IGNORE INTO t1 VALUES (1); +INSERT IGNORE INTO t1 VALUES (1); +INSERT IGNORE INTO t1 SELECT a FROM t1; +INSERT IGNORE INTO t1 SELECT a FROM t1; +INSERT IGNORE INTO t1 SELECT a FROM t1; +INSERT IGNORE INTO t1 VALUES (1); +INSERT IGNORE INTO t1 VALUES (1); +SELECT * FROM t1 ORDER BY a; +a +1 +1 +1 +1 +1 +1 +1 +1 +1 +1 +1 +1 +1 +1 +1 +1 +1 +1 +DELETE FROM t1; +CREATE UNIQUE INDEX ai ON t1(a); +INSERT IGNORE INTO t1 VALUES (1); +INSERT IGNORE INTO t1 VALUES (1); +INSERT IGNORE INTO t1 VALUES (NULL),(2); +SELECT * FROM t1 ORDER BY a; +a +NULL +1 +2 +DROP TABLE t1; +CREATE TABLE t1(pk INT NOT NULL PRIMARY KEY, a INT, UNIQUE (a)) ENGINE=ndb; +INSERT IGNORE INTO t1 VALUES (1,1),(2,2),(3,3); +INSERT IGNORE INTO t1 VALUES (4,NULL),(5,NULL),(6,NULL),(7,4); +SELECT * FROM t1 ORDER BY pk; +pk a +1 1 +2 2 +3 3 +4 NULL +5 NULL +6 NULL +7 4 +DROP TABLE t1; +create table t1(a int primary key, b int, unique key(b)) engine=ndb; +insert ignore into t1 values (1,0), (2,0), (2,null), (3,null); +select * from t1 order by a; +a b +1 0 +2 NULL +3 NULL +drop table t1; +CREATE TABLE t1 ( +pk INT NOT NULL PRIMARY KEY AUTO_INCREMENT, +b INT NOT NULL, +c INT NOT NULL UNIQUE +) ENGINE=NDBCLUSTER; +CREATE TABLE t2 ( +pk INT NOT NULL PRIMARY KEY AUTO_INCREMENT, +b INT NOT NULL, +c INT NOT NULL UNIQUE +) ENGINE=MYISAM; +SET @@session.auto_increment_increment=10; +INSERT INTO t1 (b,c) VALUES (1,0),(2,1),(3,2); +INSERT INTO t2 (b,c) VALUES (1,0),(2,1),(3,2); +SELECT * FROM t1 ORDER BY pk; +pk b c +1 1 0 +11 2 1 +21 3 2 +SELECT COUNT(t1.pk) FROM t1, t2 WHERE t1.pk = t2.pk AND t1.b = t2.b AND t1.c = t1.c; +COUNT(t1.pk) +3 +TRUNCATE t1; +TRUNCATE t2; +SET @@session.auto_increment_offset=5; +INSERT INTO t1 (b,c) VALUES (1,0),(2,1),(3,2); +INSERT INTO t1 (pk,b,c) VALUES (27,4,3),(NULL,5,4),(99,6,5),(NULL,7,6); +INSERT INTO t2 (b,c) VALUES (1,0),(2,1),(3,2); +INSERT INTO t2 (pk,b,c) VALUES (27,4,3),(NULL,5,4),(99,6,5),(NULL,7,6); +SELECT * FROM t1 ORDER BY pk; +pk b c +5 1 0 +15 2 1 +25 3 2 +27 4 3 +35 5 4 +99 6 5 +105 7 6 +SELECT COUNT(t1.pk) FROM t1, t2 WHERE t1.pk = t2.pk AND t1.b = t2.b AND t1.c = t1.c; +COUNT(t1.pk) +7 +TRUNCATE t1; +TRUNCATE t2; +SET @@session.auto_increment_increment=2; +INSERT INTO t1 (b,c) VALUES (1,0),(2,1),(3,2); +INSERT INTO t2 (b,c) VALUES (1,0),(2,1),(3,2); +SELECT * FROM t1 ORDER BY pk; +pk b c +1 1 0 +3 2 1 +5 3 2 +SELECT COUNT(t1.pk) FROM t1, t2 WHERE t1.pk = t2.pk AND t1.b = t2.b AND t1.c = t1.c; +COUNT(t1.pk) +3 +DROP TABLE t1, t2; +CREATE TABLE t1 ( +pk INT NOT NULL PRIMARY KEY AUTO_INCREMENT, +b INT NOT NULL, +c INT NOT NULL UNIQUE +) ENGINE=NDBCLUSTER AUTO_INCREMENT = 7; +CREATE TABLE t2 ( +pk INT NOT NULL PRIMARY KEY AUTO_INCREMENT, +b INT NOT NULL, +c INT NOT NULL UNIQUE +) ENGINE=MYISAM AUTO_INCREMENT = 7; +SET @@session.auto_increment_offset=1; +SET @@session.auto_increment_increment=1; +INSERT INTO t1 (b,c) VALUES (1,0),(2,1),(3,2); +INSERT INTO t2 (b,c) VALUES (1,0),(2,1),(3,2); +SELECT * FROM t1 ORDER BY pk; +pk b c +7 1 0 +8 2 1 +9 3 2 +SELECT COUNT(t1.pk) FROM t1, t2 WHERE t1.pk = t2.pk AND t1.b = t2.b AND t1.c = t1.c; +COUNT(t1.pk) +3 +DROP TABLE t1, t2; +CREATE TABLE t1 ( +pk INT NOT NULL PRIMARY KEY AUTO_INCREMENT, +b INT NOT NULL, +c INT NOT NULL UNIQUE +) ENGINE=NDBCLUSTER AUTO_INCREMENT = 3; +CREATE TABLE t2 ( +pk INT NOT NULL PRIMARY KEY AUTO_INCREMENT, +b INT NOT NULL, +c INT NOT NULL UNIQUE +) ENGINE=MYISAM AUTO_INCREMENT = 3; +SET @@session.auto_increment_offset=5; +SET @@session.auto_increment_increment=10; +INSERT INTO t1 (b,c) VALUES (1,0),(2,1),(3,2); +INSERT INTO t2 (b,c) VALUES (1,0),(2,1),(3,2); +SELECT * FROM t1 ORDER BY pk; +pk b c +5 1 0 +15 2 1 +25 3 2 +SELECT COUNT(t1.pk) FROM t1, t2 WHERE t1.pk = t2.pk AND t1.b = t2.b AND t1.c = t1.c; +COUNT(t1.pk) +3 +DROP TABLE t1, t2; +CREATE TABLE t1 ( +pk INT NOT NULL PRIMARY KEY AUTO_INCREMENT, +b INT NOT NULL, +c INT NOT NULL UNIQUE +) ENGINE=NDBCLUSTER AUTO_INCREMENT = 7; +CREATE TABLE t2 ( +pk INT NOT NULL PRIMARY KEY AUTO_INCREMENT, +b INT NOT NULL, +c INT NOT NULL UNIQUE +) ENGINE=MYISAM AUTO_INCREMENT = 7; +SET @@session.auto_increment_offset=5; +SET @@session.auto_increment_increment=10; +INSERT INTO t1 (b,c) VALUES (1,0),(2,1),(3,2); +INSERT INTO t2 (b,c) VALUES (1,0),(2,1),(3,2); +SELECT * FROM t1 ORDER BY pk; +pk b c +15 1 0 +25 2 1 +35 3 2 +SELECT COUNT(t1.pk) FROM t1, t2 WHERE t1.pk = t2.pk AND t1.b = t2.b AND t1.c = t1.c; +COUNT(t1.pk) +3 +DROP TABLE t1, t2; +CREATE TABLE t1 ( +pk INT NOT NULL PRIMARY KEY AUTO_INCREMENT, +b INT NOT NULL, +c INT NOT NULL UNIQUE +) ENGINE=NDBCLUSTER AUTO_INCREMENT = 5; +CREATE TABLE t2 ( +pk INT NOT NULL PRIMARY KEY AUTO_INCREMENT, +b INT NOT NULL, +c INT NOT NULL UNIQUE +) ENGINE=MYISAM AUTO_INCREMENT = 5; +SET @@session.auto_increment_offset=5; +SET @@session.auto_increment_increment=10; +INSERT INTO t1 (b,c) VALUES (1,0),(2,1),(3,2); +INSERT INTO t2 (b,c) VALUES (1,0),(2,1),(3,2); +SELECT * FROM t1 ORDER BY pk; +pk b c +5 1 0 +15 2 1 +25 3 2 +SELECT COUNT(t1.pk) FROM t1, t2 WHERE t1.pk = t2.pk AND t1.b = t2.b AND t1.c = t1.c; +COUNT(t1.pk) +3 +DROP TABLE t1, t2; +CREATE TABLE t1 ( +pk INT NOT NULL PRIMARY KEY AUTO_INCREMENT, +b INT NOT NULL, +c INT NOT NULL UNIQUE +) ENGINE=NDBCLUSTER AUTO_INCREMENT = 100; +CREATE TABLE t2 ( +pk INT NOT NULL PRIMARY KEY AUTO_INCREMENT, +b INT NOT NULL, +c INT NOT NULL UNIQUE +) ENGINE=MYISAM AUTO_INCREMENT = 100; +SET @@session.auto_increment_offset=5; +SET @@session.auto_increment_increment=10; +INSERT INTO t1 (b,c) VALUES (1,0),(2,1),(3,2); +INSERT INTO t2 (b,c) VALUES (1,0),(2,1),(3,2); +SELECT * FROM t1 ORDER BY pk; +pk b c +105 1 0 +115 2 1 +125 3 2 +SELECT COUNT(t1.pk) FROM t1, t2 WHERE t1.pk = t2.pk AND t1.b = t2.b AND t1.c = t1.c; +COUNT(t1.pk) +3 +DROP TABLE t1, t2; diff --git a/mysql-test/suite/ndb/r/ndb_limit.result b/mysql-test/suite/ndb/r/ndb_limit.result new file mode 100644 index 00000000000..da1ec3b61c3 --- /dev/null +++ b/mysql-test/suite/ndb/r/ndb_limit.result @@ -0,0 +1,72 @@ +DROP TABLE IF EXISTS t2; +CREATE TABLE t2 ( +a bigint unsigned NOT NULL PRIMARY KEY, +b int unsigned not null, +c int unsigned +) engine=ndbcluster; +select count(*) from t2; +count(*) +10000 +delete from t2 limit 1; +select count(*) from t2; +count(*) +9999 +delete from t2 limit 100; +select count(*) from t2; +count(*) +9899 +delete from t2 limit 1000; +select count(*) from t2; +count(*) +8899 +update t2 set c=12345678 limit 100; +select count(*) from t2 where c=12345678; +count(*) +100 +select count(*) from t2 where c=12345678 limit 1000; +count(*) +100 +select * from t2 limit 0; +a b c +drop table t2; +CREATE TABLE `t2` ( +`views` int(11) NOT NULL default '0', +`clicks` int(11) NOT NULL default '0', +`day` date NOT NULL default '0000-00-00', +`hour` tinyint(4) NOT NULL default '0', +`bannerid` smallint(6) NOT NULL default '0', +`zoneid` smallint(6) NOT NULL default '0', +`source` varchar(50) NOT NULL default '', +PRIMARY KEY (`day`,`hour`,`bannerid`,`zoneid`,`source`), +KEY `bannerid_day` (`bannerid`,`day`), +KEY `zoneid` (`zoneid`) +) ENGINE=ndbcluster DEFAULT CHARSET=latin1; +INSERT INTO `t2` VALUES +( 1,0,'2004-09-17', 5,100,100,''), +( 1,0,'2004-09-18', 7,100,100,''), +( 17,0,'2004-09-27',20,132,100,''), +( 4,0,'2004-09-16',23,132,100,''), +( 86,0,'2004-09-18', 7,196,196,''), +( 11,0,'2004-09-16',16,132,100,''), +(140,0,'2004-09-18', 0,100,164,''), +( 2,0,'2004-09-17', 7,132,100,''), +(846,0,'2004-09-27',11,132,164,''), +( 1,0,'2004-09-18', 8,132,100,''), +( 22,0,'2004-09-27', 9,164,132,''), +(711,0,'2004-09-27', 9,100,164,''), +( 11,0,'2004-09-18', 0,196,132,''), +( 41,0,'2004-09-27',15,196,132,''), +( 57,0,'2004-09-18', 2,164,196,''); +SELECT DATE_FORMAT(day, '%Y%m%d') as date, DATE_FORMAT(day, '%d-%m-%Y') +as date_formatted FROM t2 GROUP BY day ORDER BY day DESC; +date date_formatted +20040927 27-09-2004 +20040918 18-09-2004 +20040917 17-09-2004 +20040916 16-09-2004 +SELECT DATE_FORMAT(day, '%Y%m%d') as date, DATE_FORMAT(day, '%d-%m-%Y') +as date_formatted FROM t2 GROUP BY day ORDER BY day DESC LIMIT 2; +date date_formatted +20040927 27-09-2004 +20040918 18-09-2004 +drop table t2; diff --git a/mysql-test/suite/ndb/r/ndb_load.result b/mysql-test/suite/ndb/r/ndb_load.result new file mode 100644 index 00000000000..416a350066b --- /dev/null +++ b/mysql-test/suite/ndb/r/ndb_load.result @@ -0,0 +1,80 @@ +DROP TABLE IF EXISTS t1; +CREATE TABLE t1 (word CHAR(20) NOT NULL PRIMARY KEY) ENGINE=NDB; +LOAD DATA INFILE '../std_data_ln/words.dat' INTO TABLE t1 ; +ERROR 23000: Can't write; duplicate key in table 't1' +DROP TABLE t1; +CREATE TABLE t1 (word CHAR(20) NOT NULL) ENGINE=NDB; +LOAD DATA INFILE '../std_data_ln/words.dat' INTO TABLE t1 ; +SELECT * FROM t1 ORDER BY word; +word +Aarhus +Aarhus +Aaron +Aaron +Ababa +Ababa +aback +aback +abaft +abaft +abandon +abandon +abandoned +abandoned +abandoning +abandoning +abandonment +abandonment +abandons +abandons +abase +abased +abasement +abasements +abases +abash +abashed +abashes +abashing +abasing +abate +abated +abatement +abatements +abater +abates +abating +Abba +abbe +abbey +abbeys +abbot +abbots +Abbott +abbreviate +abbreviated +abbreviates +abbreviating +abbreviation +abbreviations +Abby +abdomen +abdomens +abdominal +abduct +abducted +abduction +abductions +abductor +abductors +abducts +Abe +abed +Abel +Abelian +Abelson +Aberdeen +Abernathy +aberrant +aberration +DROP TABLE t1; diff --git a/mysql-test/suite/ndb/r/ndb_loaddatalocal.result b/mysql-test/suite/ndb/r/ndb_loaddatalocal.result new file mode 100644 index 00000000000..1d15c608f03 --- /dev/null +++ b/mysql-test/suite/ndb/r/ndb_loaddatalocal.result @@ -0,0 +1,46 @@ +DROP TABLE IF EXISTS t1; +create table t1(a int) engine=myisam; +select * into outfile 'MYSQLTEST_VARDIR/master-data/ndb_loaddatalocal.select_outfile' from t1; +drop table t1; +create table t1(a int) engine=ndb; +load data local infile 'MYSQLTEST_VARDIR/master-data/ndb_loaddatalocal.select_outfile' into table t1; +select count(*) from t1; +count(*) +10000 +drop table t1; +create table t1(a int) engine=myisam; +insert into t1 values (1), (2), (2), (3); +select * into outfile 'MYSQLTEST_VARDIR/master-data/ndb_loaddatalocal.select_outfile' from t1; +drop table t1; +create table t1(a int primary key) engine=ndb; +load data local infile 'MYSQLTEST_VARDIR/master-data/ndb_loaddatalocal.select_outfile' into table t1; +select * from t1 order by a; +a +1 +2 +3 +drop table t1; +create table t1(a int) engine=myisam; +insert into t1 values (1), (1), (2), (3); +select * into outfile 'MYSQLTEST_VARDIR/master-data/ndb_loaddatalocal.select_outfile' from t1; +drop table t1; +create table t1(a int primary key) engine=ndb; +load data local infile 'MYSQLTEST_VARDIR/master-data/ndb_loaddatalocal.select_outfile' into table t1; +select * from t1 order by a; +a +1 +2 +3 +drop table t1; +create table t1(a int) engine=myisam; +insert into t1 values (1), (2), (3), (3); +select * into outfile 'MYSQLTEST_VARDIR/master-data/ndb_loaddatalocal.select_outfile' from t1; +drop table t1; +create table t1(a int primary key) engine=ndb; +load data local infile 'MYSQLTEST_VARDIR/master-data/ndb_loaddatalocal.select_outfile' into table t1; +select * from t1 order by a; +a +1 +2 +3 +drop table t1; diff --git a/mysql-test/suite/ndb/r/ndb_lock.result b/mysql-test/suite/ndb/r/ndb_lock.result new file mode 100644 index 00000000000..9057731c3f4 --- /dev/null +++ b/mysql-test/suite/ndb/r/ndb_lock.result @@ -0,0 +1,200 @@ +DROP TABLE IF EXISTS t1,t2,t3,t4,t5,t6,t7; +create table t1 (x integer not null primary key, y varchar(32)) engine = ndb; +insert into t1 values (1,'one'), (2,'two'); +select * from t1 order by x; +x y +1 one +2 two +select * from t1 order by x; +x y +1 one +2 two +start transaction; +insert into t1 values (3,'three'); +select * from t1 order by x; +x y +1 one +2 two +3 three +start transaction; +select * from t1 order by x; +x y +1 one +2 two +commit; +select * from t1 order by x; +x y +1 one +2 two +3 three +commit; +drop table t1; +create table t1 (pk integer not null primary key, u int not null, o int not null, +unique(u), key(o)) engine = ndb; +insert into t1 values (1,1,1), (2,2,2), (3,3,3), (4,4,4), (5,5,5); +lock tables t1 write; +delete from t1 where pk = 1; +unlock tables; +select * from t1 order by pk; +pk u o +2 2 2 +3 3 3 +4 4 4 +5 5 5 +insert into t1 values (1,1,1); +lock tables t1 write; +delete from t1 where u = 1; +unlock tables; +select * from t1 order by pk; +pk u o +2 2 2 +3 3 3 +4 4 4 +5 5 5 +insert into t1 values (1,1,1); +lock tables t1 write; +delete from t1 where o = 1; +unlock tables; +select * from t1 order by pk; +pk u o +2 2 2 +3 3 3 +4 4 4 +5 5 5 +insert into t1 values (1,1,1); +drop table t1; +create table t1 (x integer not null primary key, y varchar(32), z integer, key(z)) engine = ndb; +insert into t1 values (1,'one',1); +begin; +select * from t1 where x = 1 for update; +x y z +1 one 1 +begin; +select * from t1 where x = 1 for update; +ERROR HY000: Lock wait timeout exceeded; try restarting transaction +rollback; +rollback; +insert into t1 values (2,'two',2),(3,"three",3); +begin; +select * from t1 where x = 1 for update; +x y z +1 one 1 +select * from t1 where x = 1 for update; +ERROR HY000: Lock wait timeout exceeded; try restarting transaction +select * from t1 where x = 2 for update; +x y z +2 two 2 +rollback; +commit; +begin; +select * from t1 where y = 'one' or y = 'three' for update; +x y z +# # # +# # # +begin; +select * from t1 where x = 2 for update; +x y z +2 two 2 +select * from t1 where x = 1 for update; +ERROR HY000: Lock wait timeout exceeded; try restarting transaction +rollback; +commit; +begin; +select * from t1 where y = 'one' or y = 'three' order by x for update; +x y z +1 one 1 +3 three 3 +begin; +select * from t1 where x = 2 for update; +x y z +2 two 2 +select * from t1 where x = 1 for update; +ERROR HY000: Lock wait timeout exceeded; try restarting transaction +rollback; +commit; +begin; +select * from t1 where z > 1 and z < 3 for update; +x y z +2 two 2 +begin; +select * from t1 where x = 1 for update; +x y z +1 one 1 +select * from t1 where x = 2 for update; +Got one of the listed errors +rollback; +commit; +begin; +select * from t1 where x = 1 lock in share mode; +x y z +1 one 1 +begin; +select * from t1 where x = 1 lock in share mode; +x y z +1 one 1 +select * from t1 where x = 2 for update; +x y z +2 two 2 +select * from t1 where x = 1 for update; +ERROR HY000: Lock wait timeout exceeded; try restarting transaction +rollback; +commit; +begin; +select * from t1 where y = 'one' or y = 'three' lock in share mode; +x y z +# # # +# # # +begin; +select * from t1 where y = 'one' lock in share mode; +x y z +1 one 1 +select * from t1 where x = 2 for update; +x y z +2 two 2 +select * from t1 where x = 1 for update; +ERROR HY000: Lock wait timeout exceeded; try restarting transaction +rollback; +commit; +begin; +select * from t1 where y = 'one' or y = 'three' order by x lock in share mode; +x y z +1 one 1 +3 three 3 +begin; +select * from t1 where y = 'one' lock in share mode; +x y z +1 one 1 +select * from t1 where x = 2 for update; +x y z +2 two 2 +select * from t1 where x = 1 for update; +ERROR HY000: Lock wait timeout exceeded; try restarting transaction +rollback; +commit; +begin; +select * from t1 where z > 1 and z < 3 lock in share mode; +x y z +2 two 2 +begin; +select * from t1 where z = 1 lock in share mode; +x y z +1 one 1 +select * from t1 where x = 1 for update; +x y z +1 one 1 +select * from t1 where x = 2 for update; +ERROR HY000: Lock wait timeout exceeded; try restarting transaction +rollback; +commit; +drop table t1; +create table t3 (id2 int) engine=ndb; +lock tables t3 write; +unlock tables; +drop table t3; +create table t2 (id int, j int) engine=ndb; +insert into t2 values (2, 2); +create table t3 (id int) engine=ndb; +lock tables t3 read; +delete t2 from t2, t3 where t2.id = t3.id; +unlock tables; +drop table t2, t3; diff --git a/mysql-test/suite/ndb/r/ndb_minmax.result b/mysql-test/suite/ndb/r/ndb_minmax.result new file mode 100644 index 00000000000..cc0c238ac6e --- /dev/null +++ b/mysql-test/suite/ndb/r/ndb_minmax.result @@ -0,0 +1,120 @@ +drop table if exists t1, t2; +CREATE TABLE t1 ( +a int PRIMARY KEY +) engine = ndb; +INSERT INTO t1 VALUES (1); +INSERT INTO t1 VALUES (2); +INSERT INTO t1 VALUES (3); +INSERT INTO t1 VALUES (4); +INSERT INTO t1 VALUES (5); +INSERT INTO t1 VALUES (6); +select MAX(a) from t1; +MAX(a) +6 +select MAX(a) from t1; +MAX(a) +6 +select MAX(a) from t1; +MAX(a) +6 +select MAX(a) from t1; +MAX(a) +6 +select MIN(a) from t1; +MIN(a) +1 +select MIN(a) from t1; +MIN(a) +1 +select MIN(a) from t1; +MIN(a) +1 +select * from t1 order by a; +a +1 +2 +3 +4 +5 +6 +select MIN(a) from t1; +MIN(a) +1 +select MAX(a) from t1; +MAX(a) +6 +select MAX(a) from t1; +MAX(a) +6 +select * from t1 order by a; +a +1 +2 +3 +4 +5 +6 +drop table t1; +CREATE TABLE t2 ( +a int PRIMARY KEY, +b int not null, +c int not null, +KEY(b), +UNIQUE(c) +) engine = ndb; +INSERT INTO t2 VALUES (1, 5, 1); +INSERT INTO t2 VALUES (2, 2, 7); +INSERT INTO t2 VALUES (3, 3, 3); +INSERT INTO t2 VALUES (4, 4, 4); +INSERT INTO t2 VALUES (5, 5, 5); +INSERT INTO t2 VALUES (6, 6, 6); +INSERT INTO t2 VALUES (7, 2, 10); +INSERT INTO t2 VALUES (8, 10, 2); +select MAX(a) from t2; +MAX(a) +8 +select MAX(b) from t2; +MAX(b) +10 +select MAX(c) from t2; +MAX(c) +10 +select MIN(a) from t2; +MIN(a) +1 +select MIN(b) from t2; +MIN(b) +2 +select MIN(c) from t2; +MIN(c) +1 +select * from t2 order by a; +a b c +1 5 1 +2 2 7 +3 3 3 +4 4 4 +5 5 5 +6 6 6 +7 2 10 +8 10 2 +select MIN(b) from t2; +MIN(b) +2 +select MAX(a) from t2; +MAX(a) +8 +select MAX(c) from t2; +MAX(c) +10 +select * from t2 order by a; +a b c +1 5 1 +2 2 7 +3 3 3 +4 4 4 +5 5 5 +6 6 6 +7 2 10 +8 10 2 +drop table t2; diff --git a/mysql-test/suite/ndb/r/ndb_multi.result b/mysql-test/suite/ndb/r/ndb_multi.result new file mode 100644 index 00000000000..2bc49bf9b45 --- /dev/null +++ b/mysql-test/suite/ndb/r/ndb_multi.result @@ -0,0 +1,123 @@ +drop table if exists t1, t2, t3, t4; +drop table if exists t1, t2, t3, t4; +flush status; +create table t1 (a int) engine=ndbcluster; +create table t2 (a int) engine=ndbcluster; +insert into t1 value (2); +insert into t2 value (3); +select * from t1; +a +2 +select * from t2; +a +3 +show status like 'handler_discover%'; +Variable_name Value +Handler_discover 0 +select * from t1; +a +2 +drop table t1; +create table t1 (a int) engine=ndbcluster; +insert into t1 value (2); +select * from t1; +a +2 +show status like 'handler_discover%'; +Variable_name Value +Handler_discover 0 +drop table t1; +create table t1 (a int) engine=ndbcluster; +insert into t1 value (2); +select * from t1; +a +2 +select * from t1; +a +2 +flush status; +select * from t1; +a +2 +update t1 set a=3 where a=2; +show status like 'handler_discover%'; +Variable_name Value +Handler_discover 0 +create table t3 (a int not null primary key, b varchar(22), +c int, last_col text) engine=ndb; +insert into t3 values(1, 'Hi!', 89, 'Longtext column'); +create table t4 (pk int primary key, b int) engine=ndb; +select * from t1; +a +3 +select * from t3; +a b c last_col +1 Hi! 89 Longtext column +show tables like 't4'; +Tables_in_test (t4) +t4 +show tables; +Tables_in_test +t1 +t2 +t3 +t4 +drop table t1, t2, t3, t4; +create table t1(c1 int key)ENGINE=MyISAM; +insert into t1 values(1),(3),(5); +select * from t1 order by c1; +c1 +1 +3 +5 +show tables; +Tables_in_test +create table t1(c1 int key)ENGINE=MyISAM; +insert into t1 values(100),(344),(533); +select * from t1 order by c1; +c1 +100 +344 +533 +alter table t1 engine=ndb; +show tables; +Tables_in_test +t1 +Warnings: +Warning 1050 Local table test.t1 shadows ndb table +select * from t1 order by c1; +c1 +100 +344 +533 +drop table t1; +select * from t1 order by c1; +c1 +1 +3 +5 +drop table t1; +create database db; +use db; +create table t1(x int) engine=ndb; +use db; +show tables; +Tables_in_db +t1 +drop database db; +show tables; +ERROR 42000: Unknown database 'db' +create database db; +use db; +create table t1(x int) engine=ndb; +use db; +create table t2(x int) engine=myisam; +show tables; +Tables_in_db +t1 +t2 +drop database db; +show tables; +Tables_in_db +t2 +drop database db; diff --git a/mysql-test/suite/ndb/r/ndb_multi_row.result b/mysql-test/suite/ndb/r/ndb_multi_row.result new file mode 100644 index 00000000000..cf5a76d6f01 --- /dev/null +++ b/mysql-test/suite/ndb/r/ndb_multi_row.result @@ -0,0 +1,67 @@ +drop table if exists t1, t2, t3, t4; +drop table if exists t1, t2, t3, t4; +flush status; +create table t1 (a int) engine=ndbcluster; +create table t2 (a int) engine=ndbcluster; +insert into t1 value (2); +insert into t2 value (3); +select * from t1; +a +2 +select * from t2; +a +3 +show status like 'handler_discover%'; +Variable_name Value +Handler_discover 0 +select * from t1; +a +2 +drop table t1; +create table t1 (a int) engine=ndbcluster; +insert into t1 value (2); +select * from t1; +a +2 +show status like 'handler_discover%'; +Variable_name Value +Handler_discover 0 +drop table t1; +create table t1 (a int) engine=ndbcluster; +insert into t1 value (2); +select * from t1; +a +2 +flush status; +select * from t1; +a +2 +update t1 set a=3 where a=2; +show status like 'handler_discover%'; +Variable_name Value +Handler_discover 0 +create table t3 (a int not null primary key, b varchar(22), +c int, last_col text) engine=ndb; +insert into t3 values(1, 'Hi!', 89, 'Longtext column'); +create table t4 (pk int primary key, b int) engine=ndb; +select * from t1; +a +3 +select * from t3; +a b c last_col +1 Hi! 89 Longtext column +show tables like 't4'; +Tables_in_test (t4) +t4 +show tables; +Tables_in_test +t1 +t2 +t3 +t4 +drop table t1, t2, t3, t4; +drop table if exists t1, t3, t4; +Warnings: +Error 155 Table 'test.t1' doesn't exist +Error 155 Table 'test.t3' doesn't exist +Error 155 Table 'test.t4' doesn't exist diff --git a/mysql-test/suite/ndb/r/ndb_partition_error.result b/mysql-test/suite/ndb/r/ndb_partition_error.result new file mode 100644 index 00000000000..d86dc382185 --- /dev/null +++ b/mysql-test/suite/ndb/r/ndb_partition_error.result @@ -0,0 +1,47 @@ +drop table if exists t1; +CREATE TABLE t1 ( +a int not null, +b int not null, +c int not null, +primary key(a,b), +index (a)) +engine = ndb +partition by range (a) +partitions 3 +(partition x1 values less than (5) nodegroup 12, +partition x2 values less than (10) nodegroup 13, +partition x3 values less than (20) nodegroup 14); +ERROR HY000: Can't create table 'test.t1' (errno: 140) +show warnings; +Level Code Message +Error 1296 Got error 771 'Given NODEGROUP doesn't exist in this cluster' from NDB +Error 1005 Can't create table 'test.t1' (errno: 140) +CREATE TABLE t1 ( +a int not null, +b int not null, +c int not null, +primary key(a)) +engine = ndb +partition by range (a) +partitions 3 +(partition x1 values less than (5), +partition x2 values less than (10), +partition x3 values less than (20)); +drop table t1; +CREATE TABLE t1 (id INT) ENGINE=NDB +PARTITION BY LIST(id) +(PARTITION p0 VALUES IN (2, 4), +PARTITION p1 VALUES IN (42, 142)); +INSERT INTO t1 VALUES (2); +UPDATE t1 SET id=5 WHERE id=2; +ERROR HY000: Table has no partition for value 5 +DROP TABLE t1; +create table t1 (a int,b int, c int) +engine = ndb +partition by list(a) +partitions 2 +(partition x123 values in (11, 12), +partition x234 values in (5, 1)); +insert into t1 values (NULL,1,1); +ERROR HY000: Table has no partition for value NULL +drop table t1; diff --git a/mysql-test/suite/ndb/r/ndb_partition_error2.result b/mysql-test/suite/ndb/r/ndb_partition_error2.result new file mode 100644 index 00000000000..a739ef3923c --- /dev/null +++ b/mysql-test/suite/ndb/r/ndb_partition_error2.result @@ -0,0 +1,3 @@ +drop table if exists t1; +create table t1 (s1 int) engine=ndbcluster; +ERROR HY000: For the partitioned engine it is necessary to define all partitions diff --git a/mysql-test/suite/ndb/r/ndb_partition_key.result b/mysql-test/suite/ndb/r/ndb_partition_key.result new file mode 100644 index 00000000000..60e96ce03b6 --- /dev/null +++ b/mysql-test/suite/ndb/r/ndb_partition_key.result @@ -0,0 +1,255 @@ +DROP TABLE IF EXISTS t1; +CREATE TABLE t1 (a int, b int, c int, d int, PRIMARY KEY(a,b,c)) +ENGINE = NDB +PARTITION BY KEY (a,b); +insert into t1 values (1,1,1,1); +select * from t1; +a b c d +1 1 1 1 +update t1 set d = 2 where a = 1 and b = 1 and c = 1; +select * from t1; +a b c d +1 1 1 2 +delete from t1; +select * from t1; +a b c d +drop table t1; +CREATE TABLE t1 (a int, b int, c int, d int, PRIMARY KEY(a,b)) +ENGINE = NDB +PARTITION BY KEY (c); +ERROR HY000: A PRIMARY KEY must include all columns in the table's partitioning function +CREATE TABLE t1 (a int, b int, c int, PRIMARY KEY(a,b)) +ENGINE = NDB +PARTITION BY KEY (a); +insert into t1 values +(1,1,3),(1,2,3),(1,3,3),(1,4,3),(1,5,3),(1,6,3), +(1,7,3),(1,8,3),(1,9,3),(1,10,3),(1,11,3),(1,12,3); +select * from t1 order by b; +a b c +1 1 3 +1 2 3 +1 3 3 +1 4 3 +1 5 3 +1 6 3 +1 7 3 +1 8 3 +1 9 3 +1 10 3 +1 11 3 +1 12 3 +DROP TABLE t1; +CREATE TABLE t1 (a INT, b CHAR(10) COLLATE latin1_bin, c INT, d INT, +PRIMARY KEY (a,b,c) USING HASH) +ENGINE=NDB +DEFAULT CHARSET=latin1 +PARTITION BY KEY (b); +insert into t1 values (1,"a",1,1),(2,"a",1,1),(3,"a",1,1); +-- t1 -- + +Fragment type: 5 +K Value: 6 +Min load factor: 78 +Max load factor: 80 +Temporary table: no +Number of attributes: 4 +Number of primary keys: 3 +Length of frm data: # +Row Checksum: 1 +Row GCI: 1 +SingleUserMode: 0 +ForceVarPart: 1 +TableStatus: Retrieved +-- Attributes -- +a Int PRIMARY KEY AT=FIXED ST=MEMORY +b Char(10;latin1_bin) PRIMARY KEY DISTRIBUTION KEY AT=FIXED ST=MEMORY +c Int PRIMARY KEY AT=FIXED ST=MEMORY +d Int NULL AT=FIXED ST=MEMORY + +-- Indexes -- +PRIMARY KEY(a, b, c) - UniqueHashIndex + + +NDBT_ProgramExit: 0 - OK + +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` int(11) NOT NULL DEFAULT '0', + `b` char(10) CHARACTER SET latin1 COLLATE latin1_bin NOT NULL DEFAULT '', + `c` int(11) NOT NULL DEFAULT '0', + `d` int(11) DEFAULT NULL, + PRIMARY KEY (`a`,`b`,`c`) USING HASH +) ENGINE=ndbcluster DEFAULT CHARSET=latin1 /*!50100 PARTITION BY KEY (b) */ +DROP TABLE t1; +CREATE TABLE t1 (a int not null primary key) +PARTITION BY KEY(a) +(PARTITION p0 ENGINE = NDB, PARTITION p1 ENGINE = NDB); +drop table t1; +CREATE TABLE t1 (a int not null primary key); +ALTER TABLE t1 +PARTITION BY KEY(a) +(PARTITION p0 ENGINE = NDB, PARTITION p1 ENGINE = NDB); +drop table t1; +create table t1 (a int) +engine=ndb +partition by key(a) +(partition p0, partition p1); +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` int(11) DEFAULT NULL +) ENGINE=ndbcluster DEFAULT CHARSET=latin1 /*!50100 PARTITION BY KEY (a) (PARTITION p0 ENGINE = ndbcluster, PARTITION p1 ENGINE = ndbcluster) */ +alter table t1 engine=heap; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` int(11) DEFAULT NULL +) ENGINE=MEMORY DEFAULT CHARSET=latin1 /*!50100 PARTITION BY KEY (a) (PARTITION p0 ENGINE = MEMORY, PARTITION p1 ENGINE = MEMORY) */ +alter table t1 engine=ndb; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` int(11) DEFAULT NULL +) ENGINE=ndbcluster DEFAULT CHARSET=latin1 /*!50100 PARTITION BY KEY (a) (PARTITION p0 ENGINE = ndbcluster, PARTITION p1 ENGINE = ndbcluster) */ +alter table t1 engine=heap remove partitioning; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` int(11) DEFAULT NULL +) ENGINE=MEMORY DEFAULT CHARSET=latin1 +alter table t1 engine=ndb +partition by key(a) +(partition p0, partition p1 engine = ndb); +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` int(11) DEFAULT NULL +) ENGINE=ndbcluster DEFAULT CHARSET=latin1 /*!50100 PARTITION BY KEY (a) (PARTITION p0 ENGINE = ndbcluster, PARTITION p1 ENGINE = ndbcluster) */ +alter table t1 +partition by key (a) +(partition p0 engine=ndb, partition p1 engine=ndb); +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` int(11) DEFAULT NULL +) ENGINE=ndbcluster DEFAULT CHARSET=latin1 /*!50100 PARTITION BY KEY (a) (PARTITION p0 ENGINE = ndbcluster, PARTITION p1 ENGINE = ndbcluster) */ +alter table t1 remove partitioning; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` int(11) DEFAULT NULL +) ENGINE=ndbcluster DEFAULT CHARSET=latin1 +alter table t1 +partition by key(a) +(partition p0 engine=ndb, partition p1); +ERROR HY000: The mix of handlers in the partitions is not allowed in this version of MySQL +alter table t1 +engine=ndb +partition by key(a) +(partition p0 engine=ndb, partition p1 engine = ndb); +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` int(11) DEFAULT NULL +) ENGINE=ndbcluster DEFAULT CHARSET=latin1 /*!50100 PARTITION BY KEY (a) (PARTITION p0 ENGINE = ndbcluster, PARTITION p1 ENGINE = ndbcluster) */ +drop table t1; +CREATE TABLE t1 ( +c1 MEDIUMINT NOT NULL AUTO_INCREMENT, +c2 TEXT NOT NULL, +c3 INT NOT NULL, +c4 BIT NOT NULL, +c5 FLOAT, +c6 VARCHAR(255), +c7 TIMESTAMP, +PRIMARY KEY(c1,c3)) +ENGINE=NDB +PARTITION BY KEY(c3) PARTITIONS 5; +ALTER TABLE t1 COALESCE PARTITION 4; +DROP TABLE t1; +CREATE TABLE t1 (a int primary key) +ENGINE=NDB +PARTITION BY KEY(a); +ALTER TABLE t1 OPTIMIZE PARTITION p0; +ERROR HY000: Table storage engine for 't1' doesn't have this option +ALTER TABLE t1 CHECK PARTITION p0; +ERROR HY000: Table storage engine for 't1' doesn't have this option +ALTER TABLE t1 REPAIR PARTITION p0; +ERROR HY000: Table storage engine for 't1' doesn't have this option +ALTER TABLE t1 ANALYZE PARTITION p0; +ERROR HY000: Table storage engine for 't1' doesn't have this option +ALTER TABLE t1 REBUILD PARTITION p0; +ERROR HY000: Table storage engine for 't1' doesn't have this option +DROP TABLE t1; +CREATE TABLE t1 ( +c1 MEDIUMINT NOT NULL AUTO_INCREMENT, +c2 TEXT NOT NULL, +c3 INT NOT NULL, +PRIMARY KEY(c1,c3)) +ENGINE=NDB +PARTITION BY KEY(c3) PARTITIONS 5; +ALTER TABLE t1 ADD COLUMN c4 INT AFTER c1; +DROP TABLE t1; +CREATE TABLE t1 ( +c1 MEDIUMINT NOT NULL AUTO_INCREMENT, +c2 TEXT NOT NULL, +c3 INT NOT NULL, +PRIMARY KEY(c1,c3)) +ENGINE=NDB +PARTITION BY KEY(c3) +(PARTITION p0 NODEGROUP 0, PARTITION p1 NODEGROUP 0); +ALTER TABLE t1 ADD COLUMN c4 INT AFTER c1; +SELECT NODEGROUP,PARTITION_NAME FROM information_schema.partitions WHERE +table_name = "t1"; +NODEGROUP PARTITION_NAME +0 p0 +0 p1 +DROP TABLE t1; +CREATE TABLE t1 ( +a tinyint unsigned NOT NULL, +b bigint(20) unsigned NOT NULL, +c char(12), +PRIMARY KEY (a,b) +) ENGINE ndb DEFAULT CHARSET=latin1 PARTITION BY KEY (a); +insert into t1 values(1,1,'1'), (2,2,'2'), (3,3,'3'), (4,4,'4'), (5,5,'5'); +select * from t1 where a = 1; +a b c +1 1 1 +select * from t1 where a = 2; +a b c +2 2 2 +select * from t1 where a = 3; +a b c +3 3 3 +select * from t1 where a = 4; +a b c +4 4 4 +select * from t1 where a = 5; +a b c +5 5 5 +delete from t1 where a = 1; +select * from t1 order by 1; +a b c +2 2 2 +3 3 3 +4 4 4 +5 5 5 +delete from t1 where a = 2; +select * from t1 order by 1; +a b c +3 3 3 +4 4 4 +5 5 5 +delete from t1 where a = 3; +select * from t1 order by 1; +a b c +4 4 4 +5 5 5 +delete from t1 where a = 4; +select * from t1 order by 1; +a b c +5 5 5 +delete from t1 where a = 5; +select * from t1 order by 1; +a b c +drop table t1; diff --git a/mysql-test/suite/ndb/r/ndb_partition_list.result b/mysql-test/suite/ndb/r/ndb_partition_list.result new file mode 100644 index 00000000000..ce2574ddcc4 --- /dev/null +++ b/mysql-test/suite/ndb/r/ndb_partition_list.result @@ -0,0 +1,51 @@ +drop table if exists t1; +CREATE TABLE t1 ( f_int1 INTEGER NOT NULL, f_int2 INTEGER NOT NULL, +f_char1 CHAR(10), +f_char2 CHAR(10), f_charbig VARCHAR(1000), +PRIMARY KEY (f_int1,f_int2)) +ENGINE = NDB +PARTITION BY LIST(MOD(f_int1 + f_int2,4)) +(PARTITION part_3 VALUES IN (-3), +PARTITION part_2 VALUES IN (-2), +PARTITION part_1 VALUES IN (-1), +PARTITION part0 VALUES IN (0), +PARTITION part1 VALUES IN (1), +PARTITION part2 VALUES IN (2), +PARTITION part3 VALUES IN (3,4,5)); +INSERT INTO t1 SET f_int1 = -2, f_int2 = 20, f_char1 = '20', f_char2 = '20', f_charbig = '===20==='; +INSERT INTO t1 SET f_int1 = 1, f_int2 = 1, f_char1 = '1', f_char2 = '1', f_charbig = '===1==='; +INSERT INTO t1 SET f_int1 = 2, f_int2 = 1, f_char1 = '1', f_char2 = '1', f_charbig = '===1==='; +INSERT INTO t1 SET f_int1 = 3, f_int2 = 1, f_char1 = '1', f_char2 = '1', f_charbig = '===1==='; +INSERT INTO t1 SET f_int1 = 4, f_int2 = 1, f_char1 = '1', f_char2 = '1', f_charbig = '===1==='; +INSERT INTO t1 SET f_int1 = 5, f_int2 = 1, f_char1 = '1', f_char2 = '1', f_charbig = '===1==='; +INSERT INTO t1 SET f_int1 = 20, f_int2 = 1, f_char1 = '1', f_char2 = '1', f_charbig = '===1==='; +SELECT * FROM t1 ORDER BY f_int1; +f_int1 f_int2 f_char1 f_char2 f_charbig +-2 20 20 20 ===20=== +1 1 1 1 ===1=== +2 1 1 1 ===1=== +3 1 1 1 ===1=== +4 1 1 1 ===1=== +5 1 1 1 ===1=== +20 1 1 1 ===1=== +DROP TABLE t1; +CREATE TABLE t1 ( f_int1 INTEGER, f_int2 INTEGER, f_char1 CHAR(10), +f_char2 CHAR(10), f_charbig VARCHAR(1000)) +ENGINE = NDB +PARTITION BY LIST(f_int1) +(PARTITION part_1 VALUES IN (-1), +PARTITION part0 VALUES IN (0,1), +PARTITION part1 VALUES IN (2)); +INSERT INTO t1 SET f_int1 = -1, f_int2 = 20, f_char1 = '20', f_char2 = '20', f_charbig = '===20==='; +INSERT INTO t1 SET f_int1 = 0, f_int2 = 20, f_char1 = '20', f_char2 = '20', f_charbig = '===20==='; +INSERT INTO t1 SET f_int1 = 1, f_int2 = 1, f_char1 = '1', f_char2 = '1', f_charbig = '===1==='; +INSERT INTO t1 SET f_int1 = 2, f_int2 = 1, f_char1 = '1', f_char2 = '1', f_charbig = '===1==='; +INSERT INTO t1 SET f_int1 = 20, f_int2 = 1, f_char1 = '1', f_char2 = '1', f_charbig = '===1==='; +ERROR HY000: Table has no partition for value 20 +SELECT * FROM t1 ORDER BY f_int1; +f_int1 f_int2 f_char1 f_char2 f_charbig +-1 20 20 20 ===20=== +0 20 20 20 ===20=== +1 1 1 1 ===1=== +2 1 1 1 ===1=== +DROP TABLE t1; diff --git a/mysql-test/suite/ndb/r/ndb_partition_range.result b/mysql-test/suite/ndb/r/ndb_partition_range.result new file mode 100644 index 00000000000..0c717ed55e9 --- /dev/null +++ b/mysql-test/suite/ndb/r/ndb_partition_range.result @@ -0,0 +1,263 @@ +drop table if exists t1; +CREATE TABLE t1 ( +a int not null, +b int not null, +c int not null, +primary key(a,b), +index (a)) +engine = ndb +partition by range (a) +partitions 3 +(partition x1 values less than (5), +partition x2 values less than (10), +partition x3 values less than (20)); +INSERT into t1 values (1, 1, 1); +INSERT into t1 values (6, 1, 1); +INSERT into t1 values (10, 1, 1); +INSERT into t1 values (15, 1, 1); +select * from information_schema.partitions where table_name= 't1'; +TABLE_CATALOG TABLE_SCHEMA TABLE_NAME PARTITION_NAME SUBPARTITION_NAME PARTITION_ORDINAL_POSITION SUBPARTITION_ORDINAL_POSITION PARTITION_METHOD SUBPARTITION_METHOD PARTITION_EXPRESSION SUBPARTITION_EXPRESSION PARTITION_DESCRIPTION TABLE_ROWS AVG_ROW_LENGTH DATA_LENGTH MAX_DATA_LENGTH INDEX_LENGTH DATA_FREE CREATE_TIME UPDATE_TIME CHECK_TIME CHECKSUM PARTITION_COMMENT NODEGROUP TABLESPACE_NAME +NULL test t1 x1 NULL 1 NULL RANGE NULL a NULL 5 0 0 0 # 0 0 # # NULL NULL default NULL +NULL test t1 x2 NULL 2 NULL RANGE NULL a NULL 10 0 0 0 # 0 0 # # NULL NULL default NULL +NULL test t1 x3 NULL 3 NULL RANGE NULL a NULL 20 0 0 0 # 0 0 # # NULL NULL default NULL +select * from t1 order by a; +a b c +1 1 1 +6 1 1 +10 1 1 +15 1 1 +select * from t1 where a=1 order by a; +a b c +1 1 1 +select * from t1 where a=15 and b=1 order by a; +a b c +15 1 1 +select * from t1 where a=21 and b=1 order by a; +a b c +select * from t1 where a=21 order by a; +a b c +select * from t1 where a in (1,6,10,21) order by a; +a b c +1 1 1 +6 1 1 +10 1 1 +select * from t1 where b=1 and a in (1,6,10,21) order by a; +a b c +1 1 1 +6 1 1 +10 1 1 +drop table t1; +CREATE TABLE t1 ( +a int not null, +b int not null, +c int not null, +primary key(b), +unique (a)) +engine = ndb +partition by range (b) +partitions 3 +(partition x1 values less than (5), +partition x2 values less than (10), +partition x3 values less than (20)); +INSERT into t1 values (1, 1, 1); +INSERT into t1 values (2, 6, 1); +INSERT into t1 values (3, 10, 1); +INSERT into t1 values (4, 15, 1); +select * from t1 order by a; +a b c +1 1 1 +2 6 1 +3 10 1 +4 15 1 +UPDATE t1 set a = 5 WHERE b = 15; +select * from t1 order by a; +a b c +1 1 1 +2 6 1 +3 10 1 +5 15 1 +UPDATE t1 set a = 6 WHERE a = 5; +select * from t1 order by a; +a b c +1 1 1 +2 6 1 +3 10 1 +6 15 1 +select * from t1 where b=1 order by b; +a b c +1 1 1 +select * from t1 where b=15 and a=1 order by b; +a b c +select * from t1 where b=21 and a=1 order by b; +a b c +select * from t1 where b=21 order by b; +a b c +select * from t1 where b in (1,6,10,21) order by b; +a b c +1 1 1 +2 6 1 +3 10 1 +select * from t1 where a in (1,2,5,6) order by b; +a b c +1 1 1 +2 6 1 +6 15 1 +select * from t1 where a=1 and b in (1,6,10,21) order by b; +a b c +1 1 1 +DELETE from t1 WHERE b = 6; +DELETE from t1 WHERE a = 6; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` int(11) NOT NULL, + `b` int(11) NOT NULL, + `c` int(11) NOT NULL, + PRIMARY KEY (`b`), + UNIQUE KEY `a` (`a`) +) ENGINE=ndbcluster DEFAULT CHARSET=latin1 /*!50100 PARTITION BY RANGE (b) (PARTITION x1 VALUES LESS THAN (5) ENGINE = ndbcluster, PARTITION x2 VALUES LESS THAN (10) ENGINE = ndbcluster, PARTITION x3 VALUES LESS THAN (20) ENGINE = ndbcluster) */ +drop table t1; +CREATE TABLE t1 +(id MEDIUMINT NOT NULL, +b1 BIT(8), +vc VARCHAR(255), +bc CHAR(255), +d DECIMAL(10,4) DEFAULT 0, +f FLOAT DEFAULT 0, +total BIGINT UNSIGNED, +y YEAR, +t DATE) ENGINE=NDB +PARTITION BY RANGE (YEAR(t)) +(PARTITION p0 VALUES LESS THAN (1901), +PARTITION p1 VALUES LESS THAN (1946), +PARTITION p2 VALUES LESS THAN (1966), +PARTITION p3 VALUES LESS THAN (1986), +PARTITION p4 VALUES LESS THAN (2005), +PARTITION p5 VALUES LESS THAN MAXVALUE); +INSERT INTO t1 VALUES (0,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL); +SELECT * FROM t1; +id b1 vc bc d f total y t +0 NULL NULL NULL NULL NULL NULL NULL NULL +ALTER TABLE t1 ENGINE=MYISAM; +SELECT * FROM t1; +id b1 vc bc d f total y t +0 NULL NULL NULL NULL NULL NULL NULL NULL +DROP TABLE t1; +CREATE LOGFILE GROUP lg1 +ADD UNDOFILE 'undofile.dat' + INITIAL_SIZE 16M +UNDO_BUFFER_SIZE=1M +ENGINE=NDB; +CREATE TABLESPACE ts1 +ADD DATAFILE 'datafile.dat' + USE LOGFILE GROUP lg1 +INITIAL_SIZE 12M +ENGINE NDB; +CREATE TABLE test.t1 ( +a1 INT, +a2 TEXT NOT NULL, +a3 BIT NOT NULL, +a4 DECIMAL(8,3), +a5 INT NOT NULL, +a6 INT, +PRIMARY KEY(a1)) +TABLESPACE ts1 STORAGE DISK ENGINE=NDB +PARTITION BY LIST (a1) +(PARTITION p0 VALUES IN (1,2,3,4,5), +PARTITION p1 VALUES IN (6,7,8,9, 10), +PARTITION p2 VALUES IN (11, 12, 13, 14, 15)); +ALTER TABLE test.t1 DROP COLUMN a6; +ALTER TABLE test.t1 ADD COLUMN a6 VARCHAR(255); +SELECT COUNT(*) FROM test.t1; +COUNT(*) +15 +ALTER TABLE test.t1 DROP COLUMN a4; +SELECT COUNT(*) FROM test.t1; +COUNT(*) +15 +DROP TABLE t1; +CREATE TABLE test.t1 ( +a1 INT, +a2 TEXT NOT NULL, +a3 BIT NOT NULL, +a4 DECIMAL(8,3), +a5 INT NOT NULL, +a6 VARCHAR(255), +PRIMARY KEY(a1)) +TABLESPACE ts1 STORAGE DISK ENGINE=NDB +PARTITION BY HASH(a1) +PARTITIONS 4; +SELECT COUNT(*) FROM test.t1; +COUNT(*) +15 +ALTER TABLE test.t1 DROP COLUMN a4; +SELECT COUNT(*) FROM test.t1; +COUNT(*) +15 +DROP TABLE t1; +ALTER TABLESPACE ts1 +DROP DATAFILE 'datafile.dat' +ENGINE=NDB; +DROP TABLESPACE ts1 ENGINE=NDB; +DROP LOGFILE GROUP lg1 ENGINE=NDB; +CREATE TABLE t1 +(id MEDIUMINT NOT NULL, +b1 BIT(8), +vc VARCHAR(255), +bc CHAR(255), +d DECIMAL(10,4) DEFAULT 0, +f FLOAT DEFAULT 0, +total BIGINT UNSIGNED, +y YEAR, +t DATE) ENGINE=NDB +PARTITION BY LIST(id) +(PARTITION p0 VALUES IN (2, 4), +PARTITION p1 VALUES IN (42, 142)); +INSERT INTO t1 VALUES (2,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL); +SELECT * FROM t1; +id b1 vc bc d f total y t +2 NULL NULL NULL NULL NULL NULL NULL NULL +ALTER TABLE t1 ADD PARTITION +(PARTITION p2 VALUES IN (412)); +SELECT * FROM t1; +id b1 vc bc d f total y t +2 NULL NULL NULL NULL NULL NULL NULL NULL +DROP TABLE t1; +CREATE TABLE t1 ( +a int not null, +b int not null, +c int not null) +partition by list(a) +partitions 2 +(partition x123 values in (1,5,6), +partition x234 values in (4,7,8)); +INSERT into t1 VALUES (5,1,1); +select * from t1; +a b c +5 1 1 +UPDATE t1 SET a=8 WHERE a=5 AND b=1; +select * from t1; +a b c +8 1 1 +drop table t1; +CREATE TABLE t1 ( f1 INTEGER, f2 char(20)) engine=ndb +PARTITION BY RANGE(f1) +( PARTITION part1 VALUES LESS THAN (2), +PARTITION part2 VALUES LESS THAN (1000)); +INSERT INTO t1 VALUES(1, '---1---'); +INSERT INTO t1 VALUES(2, '---2---'); +select * from t1 order by f1; +f1 f2 +1 ---1--- +2 ---2--- +UPDATE t1 SET f1 = f1 + 4 WHERE f1 = 2; +select * from t1 order by f1; +f1 f2 +1 ---1--- +6 ---2--- +UPDATE t1 SET f1 = f1 + 4 WHERE f1 = 1; +select * from t1 order by f1; +f1 f2 +5 ---1--- +6 ---2--- +drop table t1; diff --git a/mysql-test/suite/ndb/r/ndb_read_multi_range.result b/mysql-test/suite/ndb/r/ndb_read_multi_range.result new file mode 100644 index 00000000000..8443d0473a8 --- /dev/null +++ b/mysql-test/suite/ndb/r/ndb_read_multi_range.result @@ -0,0 +1,475 @@ +DROP TABLE IF EXISTS t1, t2, r1; +create table t1 ( +a int primary key, +b int not null, +c int not null, +index(b), unique index using hash(c) +) engine = ndb; +insert into t1 values +(1,2,1),(2,3,2),(3,4,3),(4,5,4), +(5,2,12),(6,3,11),(7,4,10),(8,5,9), +(9,2,8),(10,3,7),(11,4,6),(12,5,5); +create table r1 as select * from t1 where a in (2,8,12); +select * from r1 order by a; +a b c +2 3 2 +8 5 9 +12 5 5 +drop table r1; +create table r1 as select * from t1 where b in (1,2,5); +select * from r1 order by a; +a b c +1 2 1 +4 5 4 +5 2 12 +8 5 9 +9 2 8 +12 5 5 +drop table r1; +create table r1 as select * from t1 where c in (2,8,12); +select * from r1 order by a; +a b c +2 3 2 +5 2 12 +9 2 8 +drop table r1; +create table r1 as select * from t1 where a in (2,8) or (a > 11) or (a <= 1); +select * from r1 order by a; +a b c +1 2 1 +2 3 2 +8 5 9 +12 5 5 +drop table r1; +create table r1 as select * from t1 where a in (33,8,12); +select * from r1 order by a; +a b c +8 5 9 +12 5 5 +drop table r1; +create table r1 as select * from t1 where a in (2,33,8,12,34); +select * from r1 order by a; +a b c +2 3 2 +8 5 9 +12 5 5 +drop table r1; +create table r1 as select * from t1 where b in (1,33,5); +select * from r1 order by a; +a b c +4 5 4 +8 5 9 +12 5 5 +drop table r1; +select * from t1 where b in (1,33,5) order by a; +a b c +4 5 4 +8 5 9 +12 5 5 +create table r1 as select * from t1 where b in (45,1,33,5,44); +select * from r1 order by a; +a b c +4 5 4 +8 5 9 +12 5 5 +drop table r1; +select * from t1 where b in (45,22) order by a; +a b c +create table r1 as select * from t1 where c in (2,8,33); +select * from r1 order by a; +a b c +2 3 2 +9 2 8 +drop table r1; +create table r1 as select * from t1 where c in (13,2,8,33,12); +select * from r1 order by a; +a b c +2 3 2 +5 2 12 +9 2 8 +drop table r1; +select * from t1 where a in (33,8,12) order by a; +a b c +8 5 9 +12 5 5 +select * from t1 where a in (33,34,35) order by a; +a b c +select * from t1 where a in (2,8) or (a > 11) or (a <= 1) order by a; +a b c +1 2 1 +2 3 2 +8 5 9 +12 5 5 +select * from t1 where b in (6,7) or (b <= 5) or (b >= 10) order by b,a; +a b c +1 2 1 +5 2 12 +9 2 8 +2 3 2 +6 3 11 +10 3 7 +3 4 3 +7 4 10 +11 4 6 +4 5 4 +8 5 9 +12 5 5 +select * from t1 where c in (13,2,8,33,12) order by c,a; +a b c +2 3 2 +9 2 8 +5 2 12 +drop table t1; +create table t1 ( +a int not null, +b int not null, +c int not null, +d int not null, +e int not null, +primary key (a,b,c,d), index (d) +) engine = ndb; +insert into t1 values +(1,2,1,1,1),(2,3,2,3,1),(3,4,3,1,1),(4,5,4,7,1), +(5,2,12,12,1),(6,3,11,1,1),(7,4,10,3,1),(8,5,9,5,1), +(9,2,8,6,1),(10,3,7,5,1),(11,4,6,3,1),(12,5,5,2,1), +(1,2,1,2,1), +(1,2,1,3,1), +(1,2,1,4,1), +(1,2,1,5,1); +create table r1 as select * from t1 +where a=1 and b=2 and c=1 and d in (1,4,3,2); +select * from r1 order by a,b,c,d; +a b c d e +1 2 1 1 1 +1 2 1 2 1 +1 2 1 3 1 +1 2 1 4 1 +drop table r1; +update t1 set e = 100 +where d in (12,6,7); +select * from t1 where d in (12,6,7) order by a,b,c,d; +a b c d e +4 5 4 7 100 +5 2 12 12 100 +9 2 8 6 100 +select * from t1 where d not in (12,6,7) and e = 100; +a b c d e +update t1 +set e = 101 +where a=1 and +b=2 and +c=1 and +d in (1,4,3,2); +select * +from t1 +where a=1 and b=2 and c=1 and d in (1,4,3,2) +order by a,b,c,d; +a b c d e +1 2 1 1 101 +1 2 1 2 101 +1 2 1 3 101 +1 2 1 4 101 +select * +from t1 +where not (a=1 and b=2 and c=1 and d in (1,4,3,2)) +and e=101; +a b c d e +update t1 +set e = +(case d +when 12 then 112 +when 6 then 106 +when 7 then 107 +end) +where d in (12,6,7); +select * from t1 where d in (12,6,7) order by a,b,c,d; +a b c d e +4 5 4 7 107 +5 2 12 12 112 +9 2 8 6 106 +update t1 +set e = +(case d +when 1 then 111 +when 4 then 444 +when 3 then 333 +when 2 then 222 +end) +where a=1 and +b=2 and +c=1 and +d in (1,4,3,2); +select * +from t1 +where a=1 and b=2 and c=1 and d in (1,4,3,2) +order by a,b,c,d; +a b c d e +1 2 1 1 111 +1 2 1 2 222 +1 2 1 3 333 +1 2 1 4 444 +delete from t1 where d in (12,6,7); +select * from t1 where d in (12,6,7); +a b c d e +drop table t1; +create table t1 ( +a int not null primary key, +b int, +c int, +d int, +unique index (b), +index(c) +) engine = ndb; +insert into t1 values +(1,null,1,1), +(2,2,2,2), +(3,null,null,3), +(4,4,null,4), +(5,null,5,null), +(6,6,6,null), +(7,null,null,null), +(8,8,null,null), +(9,null,9,9), +(10,10,10,10), +(11,null,null,11), +(12,12,null,12), +(13,null,13,null), +(14,14,14,null), +(15,null,null,null), +(16,16,null,null); +create table t2 as select * from t1 where a in (5,6,7,8,9,10); +select * from t2 order by a; +a b c d +5 NULL 5 NULL +6 6 6 NULL +7 NULL NULL NULL +8 8 NULL NULL +9 NULL 9 9 +10 10 10 10 +drop table t2; +create table t2 as select * from t1 where b in (5,6,7,8,9,10); +select * from t2 order by a; +a b c d +6 6 6 NULL +8 8 NULL NULL +10 10 10 10 +drop table t2; +create table t2 as select * from t1 where c in (5,6,7,8,9,10); +select * from t2 order by a; +a b c d +5 NULL 5 NULL +6 6 6 NULL +9 NULL 9 9 +10 10 10 10 +drop table t2; +drop table t1; +CREATE TABLE t1 ( +a int(11) NOT NULL, +b int(11) NOT NULL, +c datetime default NULL, +PRIMARY KEY (a), +KEY idx_bc (b,c) +) ENGINE=ndbcluster; +INSERT INTO t1 VALUES +(406989,67,'2006-02-23 17:08:46'), (150078,67,'2005-10-26 11:17:45'), +(406993,67,'2006-02-27 11:20:57'), (245655,67,'2005-12-08 15:59:08'), +(406994,67,'2006-02-27 11:26:46'), (256,67,NULL), +(398341,67,'2006-02-20 04:48:44'), (254,67,NULL),(1120,67,NULL), +(406988,67,'2006-02-23 17:07:22'), (255,67,NULL), +(398340,67,'2006-02-20 04:38:53'),(406631,67,'2006-02-23 10:49:42'), +(245653,67,'2005-12-08 15:59:07'),(406992,67,'2006-02-24 16:47:18'), +(245654,67,'2005-12-08 15:59:08'),(406995,67,'2006-02-28 11:55:00'), +(127261,67,'2005-10-13 12:17:58'),(406991,67,'2006-02-24 16:42:32'), +(245652,67,'2005-12-08 15:58:27'),(398545,67,'2006-02-20 04:53:13'), +(154504,67,'2005-10-28 11:53:01'),(9199,67,NULL),(1,67,'2006-02-23 15:01:35'), +(223456,67,NULL),(4101,67,NULL),(1133,67,NULL), +(406990,67,'2006-02-23 18:01:45'),(148815,67,'2005-10-25 15:34:17'), +(148812,67,'2005-10-25 15:30:01'),(245651,67,'2005-12-08 15:58:27'), +(154503,67,'2005-10-28 11:52:38'); +create table t11 engine = ndbcluster select * from t1 where b = 67 AND (c IS NULL OR c > NOW()) order by 3 asc; +create table t12 engine = ndbcluster select * from t1 where b = 67 AND (c IS NULL OR c > NOW()) order by 3 desc; +create table t21 select * from t1 where b = 67 AND (c IS NULL OR c > '2005-12-08') order by 3 asc; +create table t22 engine = ndbcluster select * from t1 where b = 67 AND (c IS NULL OR c > '2005-12-08') order by 3 desc; +select * from t11 order by 1,2,3; +a b c +254 67 NULL +255 67 NULL +256 67 NULL +1120 67 NULL +1133 67 NULL +4101 67 NULL +9199 67 NULL +223456 67 NULL +select * from t12 order by 1,2,3; +a b c +254 67 NULL +255 67 NULL +256 67 NULL +1120 67 NULL +1133 67 NULL +4101 67 NULL +9199 67 NULL +223456 67 NULL +select * from t21 order by 1,2,3; +a b c +1 67 2006-02-23 15:01:35 +254 67 NULL +255 67 NULL +256 67 NULL +1120 67 NULL +1133 67 NULL +4101 67 NULL +9199 67 NULL +223456 67 NULL +245651 67 2005-12-08 15:58:27 +245652 67 2005-12-08 15:58:27 +245653 67 2005-12-08 15:59:07 +245654 67 2005-12-08 15:59:08 +245655 67 2005-12-08 15:59:08 +398340 67 2006-02-20 04:38:53 +398341 67 2006-02-20 04:48:44 +398545 67 2006-02-20 04:53:13 +406631 67 2006-02-23 10:49:42 +406988 67 2006-02-23 17:07:22 +406989 67 2006-02-23 17:08:46 +406990 67 2006-02-23 18:01:45 +406991 67 2006-02-24 16:42:32 +406992 67 2006-02-24 16:47:18 +406993 67 2006-02-27 11:20:57 +406994 67 2006-02-27 11:26:46 +406995 67 2006-02-28 11:55:00 +select * from t22 order by 1,2,3; +a b c +1 67 2006-02-23 15:01:35 +254 67 NULL +255 67 NULL +256 67 NULL +1120 67 NULL +1133 67 NULL +4101 67 NULL +9199 67 NULL +223456 67 NULL +245651 67 2005-12-08 15:58:27 +245652 67 2005-12-08 15:58:27 +245653 67 2005-12-08 15:59:07 +245654 67 2005-12-08 15:59:08 +245655 67 2005-12-08 15:59:08 +398340 67 2006-02-20 04:38:53 +398341 67 2006-02-20 04:48:44 +398545 67 2006-02-20 04:53:13 +406631 67 2006-02-23 10:49:42 +406988 67 2006-02-23 17:07:22 +406989 67 2006-02-23 17:08:46 +406990 67 2006-02-23 18:01:45 +406991 67 2006-02-24 16:42:32 +406992 67 2006-02-24 16:47:18 +406993 67 2006-02-27 11:20:57 +406994 67 2006-02-27 11:26:46 +406995 67 2006-02-28 11:55:00 +select t12.a from t11, t12 where t11.a in(255,256) and t11.a = t12.a and t11.c is null order by t12.a; +a +255 +256 +update t22 set c = '2005-12-08 15:58:27' where a = 255; +select * from t22 order by 1,2,3; +a b c +1 67 2006-02-23 15:01:35 +254 67 NULL +255 67 2005-12-08 15:58:27 +256 67 NULL +1120 67 NULL +1133 67 NULL +4101 67 NULL +9199 67 NULL +223456 67 NULL +245651 67 2005-12-08 15:58:27 +245652 67 2005-12-08 15:58:27 +245653 67 2005-12-08 15:59:07 +245654 67 2005-12-08 15:59:08 +245655 67 2005-12-08 15:59:08 +398340 67 2006-02-20 04:38:53 +398341 67 2006-02-20 04:48:44 +398545 67 2006-02-20 04:53:13 +406631 67 2006-02-23 10:49:42 +406988 67 2006-02-23 17:07:22 +406989 67 2006-02-23 17:08:46 +406990 67 2006-02-23 18:01:45 +406991 67 2006-02-24 16:42:32 +406992 67 2006-02-24 16:47:18 +406993 67 2006-02-27 11:20:57 +406994 67 2006-02-27 11:26:46 +406995 67 2006-02-28 11:55:00 +select t21.* from t21,t22 where t21.a = t22.a and +t22.a in (select t12.a from t11, t12 where t11.a in(255,256) and t11.a = t12.a and t11.c is null) and t22.c is null order by t21.a; +a b c +256 67 NULL +delete from t22 where a > 245651; +update t22 set b = a + 1; +select * from t22 order by 1,2,3; +a b c +1 2 2006-02-23 15:01:35 +254 255 NULL +255 256 2005-12-08 15:58:27 +256 257 NULL +1120 1121 NULL +1133 1134 NULL +4101 4102 NULL +9199 9200 NULL +223456 223457 NULL +245651 245652 2005-12-08 15:58:27 +select t21.c, count(*) +from t21 +inner join t22 using (a) +where t22.b in (2,256,257,1121,1134,4102,9200,223457,245652) +group by t21.c +order by t21.c; +c count(*) +NULL 7 +2005-12-08 15:58:27 1 +2006-02-23 15:01:35 1 +DROP TABLE t1, t11, t12, t21, t22; +CREATE TABLE t1 (id varchar(255) NOT NULL, +tag int(11) NOT NULL, +doc text NOT NULL, +type varchar(150) NOT NULL, +modified timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, +PRIMARY KEY (id) +) ENGINE=ndbcluster; +INSERT INTO t1 VALUES ('sakila',1,'Some text goes here','text',CURRENT_TIMESTAMP); +SELECT id, tag, doc, type FROM t1 WHERE id IN ('flipper','orka'); +id tag doc type +SELECT id, tag, doc, type FROM t1 WHERE id IN ('flipper','sakila'); +id tag doc type +sakila 1 Some text goes here text +DROP TABLE t1; +CREATE TABLE t1 ( +var1 int(2) NOT NULL, +var2 int(2) NOT NULL, +PRIMARY KEY (var1) +) ENGINE=ndbcluster DEFAULT CHARSET=ascii CHECKSUM=1; +CREATE TABLE t2 ( +var1 int(2) NOT NULL, +var2 int(2) NOT NULL, +PRIMARY KEY (var1) +) ENGINE=ndbcluster DEFAULT CHARSET=ascii CHECKSUM=1; +CREATE TRIGGER testtrigger +AFTER UPDATE ON t1 FOR EACH ROW BEGIN +REPLACE INTO t2 SELECT * FROM t1 WHERE t1.var1 = NEW.var1;END| +INSERT INTO t1 VALUES (1,1),(2,2),(3,3); +UPDATE t1 SET var2 = 9 WHERE var1 IN(1,2,3); +DROP TRIGGER testtrigger; +DROP TABLE t1, t2; +create table t1 (a int, b int, primary key (a), key ab (a,b)) engine=ndbcluster; +insert into t1 values (1,1), (10,10); +select * from t1 use index (ab) where a in(1,10) order by a; +a b +1 1 +10 10 +create table t2 (a int, b int, primary key (a,b)) engine=ndbcluster +partition by key(a); +insert into t2 values (1,1), (10,10); +select * from t2 where a in (1,10) order by a; +a b +1 1 +10 10 +drop table t1, t2; diff --git a/mysql-test/suite/ndb/r/ndb_rename.result b/mysql-test/suite/ndb/r/ndb_rename.result new file mode 100644 index 00000000000..2cc2dfb3ff1 --- /dev/null +++ b/mysql-test/suite/ndb/r/ndb_rename.result @@ -0,0 +1,24 @@ +DROP TABLE IF EXISTS t1,t2; +drop database if exists mysqltest; +CREATE TABLE t1 ( +pk1 INT NOT NULL PRIMARY KEY, +attr1 INT NOT NULL, +attr2 INT, +attr3 VARCHAR(10), +INDEX i1(attr1) +) ENGINE=ndbcluster; +INSERT INTO t1 VALUES (0,0,0,"zero"),(1,1,1,"one"),(2,2,2,"two"); +SELECT * FROM t1 WHERE attr1 = 1; +pk1 attr1 attr2 attr3 +1 1 1 one +alter table t1 rename t2; +SELECT * FROM t2 WHERE attr1 = 1; +pk1 attr1 attr2 attr3 +1 1 1 one +create database ndbtest; +alter table t2 rename ndbtest.t2; +SELECT * FROM ndbtest.t2 WHERE attr1 = 1; +pk1 attr1 attr2 attr3 +1 1 1 one +drop table ndbtest.t2; +drop database ndbtest; diff --git a/mysql-test/suite/ndb/r/ndb_replace.result b/mysql-test/suite/ndb/r/ndb_replace.result new file mode 100644 index 00000000000..23844ce3bff --- /dev/null +++ b/mysql-test/suite/ndb/r/ndb_replace.result @@ -0,0 +1,99 @@ +drop table if exists t1,t2; +CREATE TABLE t1 ( +gesuchnr int(11) DEFAULT '0' NOT NULL, +benutzer_id int(11) DEFAULT '0' NOT NULL, +PRIMARY KEY (gesuchnr,benutzer_id) +) engine=ndbcluster; +replace into t1 (gesuchnr,benutzer_id) values (2,1); +replace into t1 (gesuchnr,benutzer_id) values (1,1); +replace into t1 (gesuchnr,benutzer_id) values (1,1); +insert into t1 (gesuchnr, benutzer_id) value (3,2); +replace into t1 (gesuchnr,benutzer_id) values (1,1); +replace into t1 (gesuchnr,benutzer_id) values (1,1); +insert into t1 (gesuchnr,benutzer_id) values (1,1); +ERROR 23000: Duplicate entry '1-1' for key 'PRIMARY' +replace into t1 (gesuchnr,benutzer_id) values (1,1); +select * from t1 order by gesuchnr; +gesuchnr benutzer_id +1 1 +2 1 +3 2 +drop table t1; +CREATE TABLE t1(i INT PRIMARY KEY AUTO_INCREMENT, +j INT, +k INT, +UNIQUE INDEX(j) +) ENGINE = ndb; +INSERT INTO t1 VALUES (1,1,23),(2,2,24); +REPLACE INTO t1 (j,k) VALUES (1,42); +REPLACE INTO t1 (i,j) VALUES (17,2); +SELECT * from t1 ORDER BY i; +i j k +3 1 42 +17 2 NULL +DROP TABLE t1; +CREATE TABLE t2 (a INT(11) NOT NULL, +b INT(11) NOT NULL, +c INT(11) NOT NULL, +x TEXT, +y TEXT, +z TEXT, +id INT(10) unsigned NOT NULL AUTO_INCREMENT, +i INT(11) DEFAULT NULL, +PRIMARY KEY (id), +UNIQUE KEY a (a,b,c) +) ENGINE=ndbcluster; +REPLACE INTO t2 (a,b,c,x,y,z,i) VALUES (1,1,1,'a','a','a',1),(1,1,1,'b','b','b',2), (1,1,1,'c','c','c',3); +SELECT * FROM t2 ORDER BY id; +a b c x y z id i +1 1 1 c c c 3 3 +REPLACE INTO t2(a,b,c,x,y,z,i) values (1,1,1,'a','a','a',1); +REPLACE INTO t2(a,b,c,x,y,z,i) values (1,1,1,'b','b','b',2); +SELECT * FROM t2 ORDER BY id; +a b c x y z id i +1 1 1 b b b 5 2 +DROP TABLE t2; +drop table if exists t1; +create table t1 (pk int primary key, apk int unique, data int) engine=ndbcluster; +insert into t1 values (1, 1, 1), (2, 2, 2), (3, 3, 3); +replace into t1 (pk, apk) values (4, 1), (5, 2); +select * from t1 order by pk; +pk apk data +3 3 3 +4 1 NULL +5 2 NULL +delete from t1; +insert into t1 values (1, 1, 1), (2, 2, 2), (3, 3, 3); +replace into t1 (pk, apk) values (1, 4), (2, 5); +select * from t1 order by pk; +pk apk data +1 4 NULL +2 5 NULL +3 3 3 +delete from t1; +insert into t1 values (1, 1, 1), (4, 4, 4), (6, 6, 6); +load data infile '../std_data_ln/loaddata5.dat' replace into table t1 fields terminated by '' enclosed by '' ignore 1 lines (pk, apk); +select * from t1 order by pk; +pk apk data +1 1 1 +3 4 NULL +5 6 NULL +delete from t1; +insert into t1 values (1, 1, 1), (3, 3, 3), (5, 5, 5); +load data infile '../std_data_ln/loaddata5.dat' replace into table t1 fields terminated by '' enclosed by '' ignore 1 lines (pk, apk); +select * from t1 order by pk; +pk apk data +1 1 1 +3 4 NULL +5 6 NULL +delete from t1; +insert into t1 values (1, 1, 1), (2, 2, 2), (3, 3, 3); +replace into t1 (pk, apk) select 4, 1; +replace into t1 (pk, apk) select 2, 4; +select * from t1 order by pk; +pk apk data +2 4 NULL +3 3 3 +4 1 NULL +drop table t1; +End of 5.0 tests. diff --git a/mysql-test/suite/ndb/r/ndb_restore.result b/mysql-test/suite/ndb/r/ndb_restore.result new file mode 100644 index 00000000000..d1c76192cef --- /dev/null +++ b/mysql-test/suite/ndb/r/ndb_restore.result @@ -0,0 +1,485 @@ +use test; +drop table if exists t1,t2,t3,t4,t5,t6,t7,t8,t9,t10; +drop table if exists t1_c,t2_c,t3_c,t4_c,t5_c,t6_c,t7_c,t8_c,t9_c,t10_c; +CREATE TABLE `t1_c` ( +`capgoaledatta` mediumint(5) unsigned NOT NULL auto_increment, +`goaledatta` char(2) NOT NULL default '', +`maturegarbagefa` varchar(32) NOT NULL default '', +PRIMARY KEY (`capgoaledatta`,`goaledatta`,`maturegarbagefa`) +) ENGINE=ndbcluster DEFAULT CHARSET=latin1; +INSERT INTO `t1_c` VALUES (2,'3','q3plus.qt'),(400,'4','q3plus.qt'),(1,'3','q3.net'),(3,'4','q3.net'),(3000,'20','threetrees.qt'); +CREATE TABLE `t2_c` ( +`capgotod` smallint(5) unsigned NOT NULL auto_increment, +`gotod` smallint(5) unsigned NOT NULL default '0', +`goaledatta` char(2) default NULL, +`maturegarbagefa` varchar(32) default NULL, +`descrpooppo` varchar(64) default NULL, +`svcutonsa` varchar(64) NOT NULL default '', +PRIMARY KEY (`capgotod`), +KEY `i quadaddsvr` (`gotod`) +) ENGINE=ndbcluster DEFAULT CHARSET=latin1; +INSERT INTO `t2_c` VALUES (500,4,'','q3.net','addavp:MK_CASELECTOR=1','postorod rattoaa'),(2,1,'4','','addavp:MK_BRANDTAD=345','REDS Brandtad'),(3,2,'4','q3.net','execorder','fixedRatediPO REDS'),(1,1,'3','','addavp:MK_BRANDTAD=123','TEST Brandtad'),(6,5,'','told.q3.net','addavp:MK_BRANDTAD=123','Brandtad Toldzone'),(4,3,'3','q3.net','addavp:MK_POOLHINT=2','ratedi PO TEST'),(5,0,'',NULL,NULL,''); +CREATE TABLE `t3_c` ( +`CapGoaledatta` smallint(5) unsigned NOT NULL default '0', +`capgotod` smallint(5) unsigned NOT NULL default '0', +PRIMARY KEY (`capgotod`,`CapGoaledatta`) +) ENGINE=ndbcluster DEFAULT CHARSET=latin1 ROW_FORMAT=FIXED; +INSERT INTO `t3_c` VALUES (5,3),(2,4),(5,4),(1,3); +CREATE TABLE `t4_c` ( +`capfa` bigint(20) unsigned NOT NULL auto_increment, +`realm` varchar(32) NOT NULL default '', +`authpwchap` varchar(32) default NULL, +`fa` varchar(32) NOT NULL default '', +`payyingatta` tinyint(4) NOT NULL default '0', +`status` char(1) default NULL, +PRIMARY KEY (`fa`,`realm`), +KEY `capfa` (`capfa`), +KEY `i_quadentity` (`fa`,`realm`) +) ENGINE=ndbcluster DEFAULT CHARSET=latin1; +INSERT INTO `t4_c` VALUES (18,'john.smith','q3.net','dessjohn.smith',0,NULL),(21,'quad_katt_with_brandtad','q3.net','acne',0,NULL),(2200,'quad_katt_carattoaa','q3.net','acne',0,NULL),(26,'436462612809','sqasdt.q3.net','N/A',0,'6'),(19,'john','smith.qt','dessjohn',0,NULL),(33,'436643196120','sqasdt.q3.net','N/A',1,'6'),(28,'436642900019','sqasdt.q3.net','N/A',0,'6'),(30,'436462900209','sqasdt.q3.net','N/A',0,'6'),(16,'436640006666','sqasdt.q3.net','',0,NULL),(19,'dette','el-redun.com','dessdette',0,NULL),(12,'quad_kattPP','q3.net','acne',2,NULL),(14,'436640008888','sqasdt.q3.net','',0,NULL),(29,'463624900028','sqasdt.q3.net','N/A',0,'6'),(15,'436640099099','sqasdt.q3.net','',0,NULL),(13,'pap','q3plus.qt','acne',1,NULL),(19,'436642612091','sqasdt.q3.net','N/A',0,'6'),(12,'quad_katt','q3.net','acne',0,NULL),(11,'quad_kattVK','q3.net','acne',1,NULL),(32000,'463641969502','sqasdt.q3.net','N/A',1,'6'),(20,'joe','q3.net','joedesswd',0,NULL),(290000000,'436642900034','sqasdt.q3.net','N/A',0,'6'),(25,'contind','armerde.qt','acne',1,NULL); +CREATE TABLE `t5_c` ( +`capfa` bigint(20) unsigned NOT NULL default '0', +`gotod` smallint(5) unsigned NOT NULL default '0', +`orderutonsa` varchar(64) NOT NULL default '', +PRIMARY KEY (`capfa`,`gotod`,`orderutonsa`) +) ENGINE=ndbcluster DEFAULT CHARSET=latin1; +INSERT INTO `t5_c` VALUES (21,2,''),(21,1,''),(22,4,''); +CREATE TABLE `t6_c` ( +`capfa_parent` bigint(20) unsigned NOT NULL default '0', +`capfa_child` bigint(20) unsigned NOT NULL default '0', +`relatta` smallint(5) unsigned NOT NULL default '0', +PRIMARY KEY (`capfa_child`,`capfa_parent`,`relatta`) +) ENGINE=ndbcluster DEFAULT CHARSET=latin1; +INSERT INTO `t6_c` VALUES (15,16,0),(19,20,0),(18326932092909551615,30,0),(26,29,0),(18326932092909551615,29,0),(19,18,0),(26,28,0),(12,14,0); +CREATE TABLE `t7_c` ( +`dardpo` char(15) NOT NULL default '', +`dardtestard` tinyint(3) unsigned NOT NULL auto_increment, +`FastFA` char(5) NOT NULL default '', +`FastCode` char(6) NOT NULL default '', +`Fastca` char(1) NOT NULL default '', +`Fastmag` char(1) NOT NULL default '', +`Beareratta` char(2) NOT NULL default '', +PRIMARY KEY (`dardpo`,`dardtestard`) +) ENGINE=ndbcluster DEFAULT CHARSET=latin1; +INSERT INTO `t7_c` VALUES ('2.6.2.4',24,'CECHP','54545','0','0','5'),('2.2.5.4',26,'CANFA','33223','1','1','4'),('4.3.2.4',28,'ITALD','54222','1','0','5'),('129..0.0.eins',28,'G','99999','1','1','5'),('1.1.1.1',24,'AUTPT','32323','0','1','3'); +CREATE TABLE `t8_c` ( +`kattjame` varchar(32) NOT NULL default '', +`realm` varchar(32) NOT NULL default '', +`realm_entered` varchar(32) NOT NULL default '', +`maturegarbagefa` varchar(32) NOT NULL default '', +`hunderaaarbagefa_parent` varchar(32) NOT NULL default '', +`kattjame_entered` varchar(32) NOT NULL default '', +`hunderaaarbagefa` varchar(32) NOT NULL default '', +`gest` varchar(16) default NULL, +`hassetino` varchar(16) NOT NULL default '', +`aaaproxysessfa` varchar(255) default NULL, +`autologonallowed` char(1) default NULL, +`squardporoot` varchar(15) NOT NULL default '', +`naspo` varchar(15) default NULL, +`beareratta` char(2) default NULL, +`fastCode` varchar(6) default NULL, +`fastFA` varchar(5) default NULL, +`fastca` char(1) default NULL, +`fastmag` char(1) default NULL, +`lastupdate` datetime default NULL, +`hassetistart` datetime NOT NULL default '0000-00-00 00:00:00', +`accthassetitime` int(10) unsigned default NULL, +`acctoutputoctets` bigint(20) unsigned default NULL, +`acctinputoctets` bigint(20) unsigned default NULL, +PRIMARY KEY (`kattjame`,`hunderaaarbagefa`,`hassetistart`,`hassetino`), +KEY `squardporoot` (`squardporoot`) +) ENGINE=ndbcluster DEFAULT CHARSET=latin1; +INSERT INTO `t8_c` VALUES ('4tt45345235','pap','q3plus.qt','q3plus.qt','q3.net','436643196120','436643196929','8956234534568968','5524595699','uxasmt21.net.acne.qt/481889229462692422','','1.1.1.1','2.2.4.6','4','86989','34','x','x','2012-03-12 12:55:34','2012-12-05 11:20:04',3223433,3369,9565),('4545435545','john','q3.net','q3.net','acne.li','436643196120','436643196929','45345234568968','995696699','uxasmt21.net.acne.qt/481889229462692423','','1.1.1.1','2.2.9.8','2','86989','34','x','x','2012-03-12 11:35:03','2012-12-05 08:50:04',8821923,169,3565),('versteckter_q3net_katt','joe','q3.net','elredun.com','q3.net','436643196120','436643196939','91341234568968','695595699','uxasmt21.net.acne.qt/481889229462692421','','1.1.1.1','2.5.2.5','3','86989','34','x','x','2012-03-12 18:35:04','2012-12-05 12:35:04',1923123,9569,6565); +CREATE TABLE `t9_c` ( +`kattjame` varchar(32) NOT NULL default '', +`kattjame_entered` varchar(32) NOT NULL default '', +`realm` varchar(32) NOT NULL default '', +`realm_entered` varchar(32) NOT NULL default '', +`maturegarbagefa` varchar(32) NOT NULL default '', +`hunderaaarbagefa` varchar(32) NOT NULL default '', +`hunderaaarbagefa_parent` varchar(32) NOT NULL default '', +`gest` varchar(16) default NULL, +`hassetino` varchar(16) NOT NULL default '', +`squardporoot` varchar(15) NOT NULL default '', +`naspo` varchar(15) default NULL, +`beareratta` char(2) default NULL, +`fastCode` varchar(6) default NULL, +`fastFA` varchar(5) default NULL, +`fastca` char(1) default NULL, +`fastmag` char(1) default NULL, +`lastupdate` datetime default NULL, +`hassetistart` datetime NOT NULL default '0000-00-00 00:00:00', +`accthassetitime` int(10) unsigned default NULL, +`actcoutpuocttets` bigint(20) unsigned default NULL, +`actinputocctets` bigint(20) unsigned default NULL, +`terminateraste` tinyint(3) unsigned default NULL, +PRIMARY KEY (`kattjame`,`hunderaaarbagefa`,`hassetistart`,`hassetino`) +) ENGINE=ndbcluster DEFAULT CHARSET=latin1; +INSERT INTO `t9_c` VALUES ('3g4jh8gar2t','joe','q3.net','elredun.com','q3.net','436643316120','436643316939','91341234568968','695595699','1.1.1.1','2.2.6.2','3','86989','34','x','x','2012-03-12 18:35:04','2012-12-05 12:35:04',3123123,9569,6565,1),('4tt45345235','pap','q3plus.qt','q3plus.qt','q3.net','436643316120','436643316939','8956234534568968','5254595969','1.1.1.1','8.6.2.2','4','86989','34','x','x','2012-03-12 12:55:34','2012-12-05 11:20:04',3223433,3369,9565,2),('4545435545','john','q3.net','q3.net','acne.li','436643316120','436643316939','45345234568968','995696699','1.1.1.1','2.9.9.2','2','86998','34','x','x','2012-03-12 11:35:03','2012-12-05 08:50:04',8823123,169,3565,3); +CREATE TABLE t10_c (a INT AUTO_INCREMENT KEY) ENGINE=ndbcluster DEFAULT CHARSET=latin1; +INSERT INTO t10_c VALUES (1),(2),(3); +insert into t10_c values (10000),(2000),(3000); +create table t1 engine=myisam as select * from t1_c; +create table t2 engine=myisam as select * from t2_c; +create table t3 engine=myisam as select * from t3_c; +create table t4 engine=myisam as select * from t4_c; +create table t5 engine=myisam as select * from t5_c; +create table t6 engine=myisam as select * from t6_c; +create table t7 engine=myisam as select * from t7_c; +create table t8 engine=myisam as select * from t8_c; +create table t9 engine=myisam as select * from t9_c; +create table t10 engine=myisam as select * from t10_c; +ForceVarPart: 0 +ForceVarPart: 1 +CREATE TEMPORARY TABLE IF NOT EXISTS test.backup_info (id INT, backup_id INT) ENGINE = HEAP; +DELETE FROM test.backup_info; +LOAD DATA INFILE '../tmp.dat' INTO TABLE test.backup_info FIELDS TERMINATED BY ','; +SELECT @the_backup_id:=backup_id FROM test.backup_info; +@the_backup_id:=backup_id +<the_backup_id> +DROP TABLE test.backup_info; +drop table t1_c,t2_c,t3_c,t4_c,t5_c,t6_c,t7_c,t8_c,t9_c,t10_c; +ForceVarPart: 0 +ForceVarPart: 1 +select count(*) from t1; +count(*) +5 +select count(*) from t1_c; +count(*) +5 +select count(*) +from (select * from t1 union +select * from t1_c) a; +count(*) +5 +select count(*) from t2; +count(*) +7 +select count(*) from t2_c; +count(*) +7 +select count(*) +from (select * from t2 union +select * from t2_c) a; +count(*) +7 +select count(*) from t3; +count(*) +4 +select count(*) from t3_c; +count(*) +4 +select count(*) +from (select * from t3 union +select * from t3_c) a; +count(*) +4 +select count(*) from t4; +count(*) +22 +select count(*) from t4_c; +count(*) +22 +select count(*) +from (select * from t4 union +select * from t4_c) a; +count(*) +22 +select count(*) from t5; +count(*) +3 +select count(*) from t5_c; +count(*) +3 +select count(*) +from (select * from t5 union +select * from t5_c) a; +count(*) +3 +select count(*) from t6; +count(*) +8 +select count(*) from t6_c; +count(*) +8 +select count(*) +from (select * from t6 union +select * from t6_c) a; +count(*) +8 +select count(*) from t7; +count(*) +5 +select count(*) from t7_c; +count(*) +5 +select count(*) +from (select * from t7 union +select * from t7_c) a; +count(*) +5 +select count(*) from t8; +count(*) +3 +select count(*) from t8_c; +count(*) +3 +select count(*) +from (select * from t8 union +select * from t8_c) a; +count(*) +3 +select count(*) from t9; +count(*) +3 +select count(*) from t9_c; +count(*) +3 +select count(*) +from (select * from t9 union +select * from t9_c) a; +count(*) +3 +select * from t10_c order by a; +a +1 +2 +3 +2000 +3000 +10000 +show table status like 't1_c'; +Name Engine Version Row_format Rows Avg_row_length Data_length Max_data_length Index_length Data_free Auto_increment Create_time Update_time Check_time Collation Checksum Create_options Comment +X X X X X X X X X X 3001 X X X X X X X +show table status like 't2_c'; +Name Engine Version Row_format Rows Avg_row_length Data_length Max_data_length Index_length Data_free Auto_increment Create_time Update_time Check_time Collation Checksum Create_options Comment +X X X X X X X X X X 501 X X X X X X X +show table status like 't4_c'; +Name Engine Version Row_format Rows Avg_row_length Data_length Max_data_length Index_length Data_free Auto_increment Create_time Update_time Check_time Collation Checksum Create_options Comment +X X X X X X X X X X 290000001 X X X X X X X +show table status like 't7_c'; +Name Engine Version Row_format Rows Avg_row_length Data_length Max_data_length Index_length Data_free Auto_increment Create_time Update_time Check_time Collation Checksum Create_options Comment +X X X X X X X X X X 29 X X X X X X X +show table status like 't10_c'; +Name Engine Version Row_format Rows Avg_row_length Data_length Max_data_length Index_length Data_free Auto_increment Create_time Update_time Check_time Collation Checksum Create_options Comment +X X X X X X X X X X 10001 X X X X X X X +ALTER TABLE t7_c +PARTITION BY LINEAR KEY (`dardtestard`); +CREATE TEMPORARY TABLE IF NOT EXISTS test.backup_info (id INT, backup_id INT) ENGINE = HEAP; +DELETE FROM test.backup_info; +LOAD DATA INFILE '../tmp.dat' INTO TABLE test.backup_info FIELDS TERMINATED BY ','; +SELECT @the_backup_id:=backup_id FROM test.backup_info; +@the_backup_id:=backup_id +<the_backup_id> +DROP TABLE test.backup_info; +drop table t1_c,t2_c,t3_c,t4_c,t5_c,t6_c,t7_c,t8_c,t9_c,t10_c; +select count(*) from t1; +count(*) +5 +select count(*) from t1_c; +count(*) +5 +select count(*) +from (select * from t1 union +select * from t1_c) a; +count(*) +5 +select count(*) from t2; +count(*) +7 +select count(*) from t2_c; +count(*) +7 +select count(*) +from (select * from t2 union +select * from t2_c) a; +count(*) +7 +select count(*) from t3; +count(*) +4 +select count(*) from t3_c; +count(*) +4 +select count(*) +from (select * from t3 union +select * from t3_c) a; +count(*) +4 +select count(*) from t4; +count(*) +22 +select count(*) from t4_c; +count(*) +22 +select count(*) +from (select * from t4 union +select * from t4_c) a; +count(*) +22 +select count(*) from t5; +count(*) +3 +select count(*) from t5_c; +count(*) +3 +select count(*) +from (select * from t5 union +select * from t5_c) a; +count(*) +3 +select count(*) from t6; +count(*) +8 +select count(*) from t6_c; +count(*) +8 +select count(*) +from (select * from t6 union +select * from t6_c) a; +count(*) +8 +select count(*) from t7; +count(*) +5 +select count(*) from t7_c; +count(*) +5 +select count(*) +from (select * from t7 union +select * from t7_c) a; +count(*) +5 +select count(*) from t8; +count(*) +3 +select count(*) from t8_c; +count(*) +3 +select count(*) +from (select * from t8 union +select * from t8_c) a; +count(*) +3 +select count(*) from t9; +count(*) +3 +select count(*) from t9_c; +count(*) +3 +select count(*) +from (select * from t9 union +select * from t9_c) a; +count(*) +3 +drop table t1_c,t2_c,t3_c,t4_c,t5_c,t6_c,t7_c,t8_c,t9_c,t10_c; +select count(*) from t1; +count(*) +5 +select count(*) from t1_c; +count(*) +5 +select count(*) +from (select * from t1 union +select * from t1_c) a; +count(*) +5 +select count(*) from t2; +count(*) +7 +select count(*) from t2_c; +count(*) +7 +select count(*) +from (select * from t2 union +select * from t2_c) a; +count(*) +7 +select count(*) from t3; +count(*) +4 +select count(*) from t3_c; +count(*) +4 +select count(*) +from (select * from t3 union +select * from t3_c) a; +count(*) +4 +select count(*) from t4; +count(*) +22 +select count(*) from t4_c; +count(*) +22 +select count(*) +from (select * from t4 union +select * from t4_c) a; +count(*) +22 +select count(*) from t5; +count(*) +3 +select count(*) from t5_c; +count(*) +3 +select count(*) +from (select * from t5 union +select * from t5_c) a; +count(*) +3 +select count(*) from t6; +count(*) +8 +select count(*) from t6_c; +count(*) +8 +select count(*) +from (select * from t6 union +select * from t6_c) a; +count(*) +8 +select count(*) from t7; +count(*) +5 +select count(*) from t7_c; +count(*) +5 +select count(*) +from (select * from t7 union +select * from t7_c) a; +count(*) +5 +select count(*) from t8; +count(*) +3 +select count(*) from t8_c; +count(*) +3 +select count(*) +from (select * from t8 union +select * from t8_c) a; +count(*) +3 +select count(*) from t9; +count(*) +3 +select count(*) from t9_c; +count(*) +3 +select count(*) +from (select * from t9 union +select * from t9_c) a; +count(*) +3 +drop table t1_c,t3_c,t4_c,t5_c,t6_c,t7_c,t8_c,t9_c,t10_c; +CREATE TEMPORARY TABLE IF NOT EXISTS test.backup_info (id INT, backup_id INT) ENGINE = HEAP; +DELETE FROM test.backup_info; +LOAD DATA INFILE '../tmp.dat' INTO TABLE test.backup_info FIELDS TERMINATED BY ','; +SELECT @the_backup_id:=backup_id FROM test.backup_info; +@the_backup_id:=backup_id +<the_backup_id> +DROP TABLE test.backup_info; +drop table if exists t1,t2,t3,t4,t5,t6,t7,t8,t9,t10; +drop table if exists t2_c; +520093696,<the_backup_id> diff --git a/mysql-test/suite/ndb/r/ndb_restore_compat.result b/mysql-test/suite/ndb/r/ndb_restore_compat.result new file mode 100644 index 00000000000..db17f9af32b --- /dev/null +++ b/mysql-test/suite/ndb/r/ndb_restore_compat.result @@ -0,0 +1,114 @@ +DROP DATABASE IF EXISTS BANK; +CREATE DATABASE BANK default charset=latin1 default collate=latin1_bin; +USE BANK; +SHOW TABLES; +Tables_in_BANK +ACCOUNT +GL +ACCOUNT_TYPE +TRANSACTION +SYSTEM_VALUES +SELECT * FROM GL ORDER BY TIME,ACCOUNT_TYPE; +TIME ACCOUNT_TYPE BALANCE DEPOSIT_COUNT DEPOSIT_SUM WITHDRAWAL_COUNT WITHDRAWAL_SUM PURGED +0 0 10000000 0 0 0 0 1 +0 1 30000 0 0 0 0 1 +0 2 20000 0 0 0 0 1 +0 3 20000 0 0 0 0 1 +0 4 20000 0 0 0 0 1 +1 0 10000000 0 0 0 0 0 +1 1 30000 0 0 0 0 0 +1 2 20000 0 0 0 0 0 +1 3 20000 0 0 0 0 0 +1 4 20000 0 0 0 0 0 +2 0 9981761 17 80457 19 98696 0 +2 1 17823 55 203688 46 215865 0 +2 2 47056 33 159275 33 132219 0 +2 3 15719 26 126833 29 131114 0 +2 4 27641 32 133459 36 125818 0 +SELECT * FROM ACCOUNT ORDER BY ACCOUNT_ID; +ACCOUNT_ID OWNER BALANCE ACCOUNT_TYPE +0 0 9863546 0 +1 3001 12885 1 +2 3002 11012 2 +3 3003 32789 3 +4 3004 10992 4 +5 3005 2247 1 +6 3006 3170 1 +7 3007 60321 2 +8 3008 30508 3 +9 3009 62530 4 +SELECT COUNT(*) FROM TRANSACTION; +COUNT(*) +3444 +SELECT * FROM SYSTEM_VALUES ORDER BY SYSTEM_VALUES_ID; +SYSTEM_VALUES_ID VALUE +0 2039 +1 3 +SELECT * FROM mysql.ndb_apply_status WHERE server_id=0; +server_id epoch log_name start_pos end_pos +0 151 0 0 +ForceVarPart: 1 +ForceVarPart: 1 +ForceVarPart: 1 +ForceVarPart: 1 +ForceVarPart: 1 +TRUNCATE GL; +TRUNCATE ACCOUNT; +TRUNCATE TRANSACTION; +TRUNCATE SYSTEM_VALUES; +TRUNCATE ACCOUNT_TYPE; +ForceVarPart: 1 +ForceVarPart: 1 +ForceVarPart: 1 +ForceVarPart: 1 +ForceVarPart: 1 +SELECT * FROM GL ORDER BY TIME,ACCOUNT_TYPE; +TIME ACCOUNT_TYPE BALANCE DEPOSIT_COUNT DEPOSIT_SUM WITHDRAWAL_COUNT WITHDRAWAL_SUM PURGED +0 0 10000000 0 0 0 0 1 +0 1 30000 0 0 0 0 1 +0 2 20000 0 0 0 0 1 +0 3 20000 0 0 0 0 1 +0 4 20000 0 0 0 0 1 +1 0 10000000 0 0 0 0 1 +1 1 30000 0 0 0 0 1 +1 2 20000 0 0 0 0 1 +1 3 20000 0 0 0 0 1 +1 4 20000 0 0 0 0 1 +2 0 10000000 0 0 0 0 1 +2 1 30000 0 0 0 0 1 +2 2 20000 0 0 0 0 1 +2 3 20000 0 0 0 0 1 +2 4 20000 0 0 0 0 1 +3 0 9963591 14 59111 19 95520 0 +3 1 44264 49 255559 53 241295 0 +3 2 25515 39 177806 36 172291 0 +3 3 16779 26 129200 29 132421 0 +3 4 39851 43 182771 34 162920 0 +4 0 9733661 141 632616 162 862546 0 +4 1 63853 426 2005337 415 1985748 0 +4 2 140473 314 1548632 297 1433674 0 +4 3 13481 310 1528043 324 1531341 0 +4 4 138532 316 1540206 309 1441525 0 +SELECT * FROM ACCOUNT ORDER BY ACCOUNT_ID; +ACCOUNT_ID OWNER BALANCE ACCOUNT_TYPE +0 0 9679579 0 +1 3001 18130 1 +2 3002 12318 2 +3 3003 3049 3 +4 3004 39517 4 +5 3005 37051 1 +6 3006 144497 1 +7 3007 130670 2 +8 3008 13747 3 +9 3009 11442 4 +SELECT COUNT(*) FROM TRANSACTION; +COUNT(*) +4056 +SELECT * FROM SYSTEM_VALUES ORDER BY SYSTEM_VALUES_ID; +SYSTEM_VALUES_ID VALUE +0 2297 +1 5 +SELECT * FROM mysql.ndb_apply_status WHERE server_id=0; +server_id epoch log_name start_pos end_pos +0 331 0 0 +DROP DATABASE BANK; diff --git a/mysql-test/suite/ndb/r/ndb_restore_partition.result b/mysql-test/suite/ndb/r/ndb_restore_partition.result new file mode 100644 index 00000000000..7dc4057e615 --- /dev/null +++ b/mysql-test/suite/ndb/r/ndb_restore_partition.result @@ -0,0 +1,469 @@ +use test; +drop table if exists t1,t2,t3,t4,t5,t6,t7,t8,t9; +drop table if exists t1_c,t2_c,t3_c,t4_c,t5_c,t6_c,t7_c,t8_c,t9_c; +CREATE TABLE `t1_c` ( +`capgoaledatta` smallint(5) unsigned NOT NULL auto_increment, +`goaledatta` char(2) NOT NULL default '', +`maturegarbagefa` varchar(32) NOT NULL default '', +PRIMARY KEY (`capgoaledatta`,`goaledatta`,`maturegarbagefa`) +) ENGINE=ndbcluster DEFAULT CHARSET=latin1; +INSERT INTO `t1_c` VALUES (2,'3','q3plus.qt'),(4,'4','q3plus.qt'),(1,'3','q3.net'),(3,'4','q3.net'),(3,'20','threetrees.qt'); +CREATE TABLE `t2_c` ( +`capgotod` smallint(5) unsigned NOT NULL auto_increment, +`gotod` smallint(5) unsigned NOT NULL default '0', +`goaledatta` char(2) default NULL, +`maturegarbagefa` varchar(32) default NULL, +`descrpooppo` varchar(64) default NULL, +`svcutonsa` varchar(64) NOT NULL default '', +PRIMARY KEY (`capgotod`), +KEY `i_quadaddsvr` (`gotod`) +) ENGINE=ndbcluster DEFAULT CHARSET=latin1; +INSERT INTO `t2_c` VALUES (5,4,'','q3.net','addavp:MK_CASELECTOR=1','postorod rattoaa'),(2,1,'4','','addavp:MK_BRANDTAD=345','REDS Brandtad'),(3,2,'4','q3.net','execorder','fixedRatediPO REDS'),(1,1,'3','','addavp:MK_BRANDTAD=123','TEST Brandtad'),(6,5,'','told.q3.net','addavp:MK_BRANDTAD=123','Brandtad Toldzone'),(4,3,'3','q3.net','addavp:MK_POOLHINT=2','ratedi PO TEST'); +CREATE TABLE `t3_c` ( +`CapGoaledatta` smallint(5) unsigned NOT NULL default '0', +`capgotod` smallint(5) unsigned NOT NULL default '0', +PRIMARY KEY (`capgotod`,`CapGoaledatta`) +) ENGINE=ndbcluster DEFAULT CHARSET=latin1; +INSERT INTO `t3_c` VALUES (5,3),(2,4),(5,4),(1,3); +CREATE TABLE `t4_c` ( +`capfa` bigint(20) unsigned NOT NULL auto_increment, +`realm` varchar(32) NOT NULL default '', +`authpwchap` varchar(32) default NULL, +`fa` varchar(32) NOT NULL default '', +`payyingatta` tinyint(4) NOT NULL default '0', +`status` char(1) default NULL, +PRIMARY KEY (`fa`,`realm`), +KEY `capfa` (`capfa`), +KEY `i_quadentity` (`fa`,`realm`) +) ENGINE=ndbcluster DEFAULT CHARSET=latin1; +INSERT INTO `t4_c` VALUES (18,'john.smith','q3.net','dessjohn.smith',0,NULL),(21,'quad_katt_with_brandtad','q3.net','acne',0,NULL),(22,'quad_katt_carattoaa','q3.net','acne',0,NULL),(26,'436462612809','sqasdt.q3.net','N/A',0,'6'),(19,'john','smith.qt','dessjohn',0,NULL),(33,'436643196120','sqasdt.q3.net','N/A',1,'6'),(28,'436642900019','sqasdt.q3.net','N/A',0,'6'),(30,'436462900209','sqasdt.q3.net','N/A',0,'6'),(16,'436640006666','sqasdt.q3.net','',0,NULL),(19,'dette','el-redun.com','dessdette',0,NULL),(12,'quad_kattPP','q3.net','acne',2,NULL),(14,'436640008888','sqasdt.q3.net','',0,NULL),(29,'463624900028','sqasdt.q3.net','N/A',0,'6'),(15,'436640099099','sqasdt.q3.net','',0,NULL),(13,'pap','q3plus.qt','acne',1,NULL),(19,'436642612091','sqasdt.q3.net','N/A',0,'6'),(12,'quad_katt','q3.net','acne',0,NULL),(11,'quad_kattVK','q3.net','acne',1,NULL),(32,'463641969502','sqasdt.q3.net','N/A',1,'6'),(20,'joe','q3.net','joedesswd',0,NULL),(29,'436642900034','sqasdt.q3.net','N/A',0,'6'),(25,'contind','armerde.qt','acne',1,NULL); +CREATE TABLE `t5_c` ( +`capfa` bigint(20) unsigned NOT NULL default '0', +`gotod` smallint(5) unsigned NOT NULL default '0', +`orderutonsa` varchar(64) NOT NULL default '', +PRIMARY KEY (`capfa`,`gotod`,`orderutonsa`) +) ENGINE=ndbcluster DEFAULT CHARSET=latin1; +INSERT INTO `t5_c` VALUES (21,2,''),(21,1,''),(22,4,''); +CREATE TABLE `t6_c` ( +`capfa_parent` bigint(20) unsigned NOT NULL default '0', +`capfa_child` bigint(20) unsigned NOT NULL default '0', +`relatta` smallint(5) unsigned NOT NULL default '0', +PRIMARY KEY (`capfa_child`,`capfa_parent`,`relatta`) +) ENGINE=ndbcluster DEFAULT CHARSET=latin1; +INSERT INTO `t6_c` VALUES (15,16,0),(19,20,0),(18326932092909551615,30,0),(26,29,0),(18326932092909551615,29,0),(19,18,0),(26,28,0),(12,14,0); +CREATE TABLE `t7_c` ( +`dardpo` char(15) NOT NULL default '', +`dardtestard` tinyint(3) unsigned NOT NULL default '0', +`FastFA` char(5) NOT NULL default '', +`FastCode` char(6) NOT NULL default '', +`Fastca` char(1) NOT NULL default '', +`Fastmag` char(1) NOT NULL default '', +`Beareratta` char(2) NOT NULL default '', +PRIMARY KEY (`dardpo`,`dardtestard`) +) ENGINE=ndbcluster DEFAULT CHARSET=latin1; +INSERT INTO `t7_c` VALUES ('2.6.2.4',24,'CECHP','54545','0','0','5'),('2.2.5.4',26,'CANFA','33223','1','1','4'),('4.3.2.4',28,'ITALD','54222','1','0','5'),('129..0.0.eins',28,'G','99999','1','1','5'),('1.1.1.1',24,'AUTPT','32323','0','1','3'); +CREATE TABLE `t8_c` ( +`kattjame` varchar(32) NOT NULL default '', +`realm` varchar(32) NOT NULL default '', +`realm_entered` varchar(32) NOT NULL default '', +`maturegarbagefa` varchar(32) NOT NULL default '', +`hunderaaarbagefa_parent` varchar(32) NOT NULL default '', +`kattjame_entered` varchar(32) NOT NULL default '', +`hunderaaarbagefa` varchar(32) NOT NULL default '', +`gest` varchar(16) default NULL, +`hassetino` varchar(16) NOT NULL default '', +`aaaproxysessfa` varchar(255) default NULL, +`autologonallowed` char(1) default NULL, +`squardporoot` varchar(15) NOT NULL default '', +`naspo` varchar(15) default NULL, +`beareratta` char(2) default NULL, +`fastCode` varchar(6) default NULL, +`fastFA` varchar(5) default NULL, +`fastca` char(1) default NULL, +`fastmag` char(1) default NULL, +`lastupdate` datetime default NULL, +`hassetistart` datetime NOT NULL default '0000-00-00 00:00:00', +`accthassetitime` int(10) unsigned default NULL, +`acctoutputoctets` bigint(20) unsigned default NULL, +`acctinputoctets` bigint(20) unsigned default NULL, +PRIMARY KEY (`kattjame`,`hunderaaarbagefa`,`hassetistart`,`hassetino`), +KEY `squardporoot` (`squardporoot`) +) ENGINE=ndbcluster DEFAULT CHARSET=latin1; +INSERT INTO `t8_c` VALUES ('4tt45345235','pap','q3plus.qt','q3plus.qt','q3.net','436643196120','436643196929','8956234534568968','5524595699','uxasmt21.net.acne.qt/481889229462692422','','1.1.1.1','2.2.4.6','4','86989','34','x','x','2012-03-12 12:55:34','2012-12-05 11:20:04',3223433,3369,9565),('4545435545','john','q3.net','q3.net','acne.li','436643196120','436643196929','45345234568968','995696699','uxasmt21.net.acne.qt/481889229462692423','','1.1.1.1','2.2.9.8','2','86989','34','x','x','2012-03-12 11:35:03','2012-12-05 08:50:04',8821923,169,3565),('versteckter_q3net_katt','joe','q3.net','elredun.com','q3.net','436643196120','436643196939','91341234568968','695595699','uxasmt21.net.acne.qt/481889229462692421','','1.1.1.1','2.5.2.5','3','86989','34','x','x','2012-03-12 18:35:04','2012-12-05 12:35:04',1923123,9569,6565); +CREATE TABLE `t9_c` ( +`kattjame` varchar(32) NOT NULL default '', +`kattjame_entered` varchar(32) NOT NULL default '', +`realm` varchar(32) NOT NULL default '', +`realm_entered` varchar(32) NOT NULL default '', +`maturegarbagefa` varchar(32) NOT NULL default '', +`hunderaaarbagefa` varchar(32) NOT NULL default '', +`hunderaaarbagefa_parent` varchar(32) NOT NULL default '', +`gest` varchar(16) default NULL, +`hassetino` varchar(16) NOT NULL default '', +`squardporoot` varchar(15) NOT NULL default '', +`naspo` varchar(15) default NULL, +`beareratta` char(2) default NULL, +`fastCode` varchar(6) default NULL, +`fastFA` varchar(5) default NULL, +`fastca` char(1) default NULL, +`fastmag` char(1) default NULL, +`lastupdate` datetime default NULL, +`hassetistart` datetime NOT NULL default '0000-00-00 00:00:00', +`accthassetitime` int(10) unsigned default NULL, +`actcoutpuocttets` bigint(20) unsigned default NULL, +`actinputocctets` bigint(20) unsigned default NULL, +`terminateraste` tinyint(3) unsigned default NULL, +PRIMARY KEY (`kattjame`,`hunderaaarbagefa`,`hassetistart`,`hassetino`) +) ENGINE=ndbcluster DEFAULT CHARSET=latin1; +INSERT INTO `t9_c` VALUES ('3g4jh8gar2t','joe','q3.net','elredun.com','q3.net','436643316120','436643316939','91341234568968','695595699','1.1.1.1','2.2.6.2','3','86989','34','x','x','2012-03-12 18:35:04','2012-12-05 12:35:04',3123123,9569,6565,1),('4tt45345235','pap','q3plus.qt','q3plus.qt','q3.net','436643316120','436643316939','8956234534568968','5254595969','1.1.1.1','8.6.2.2','4','86989','34','x','x','2012-03-12 12:55:34','2012-12-05 11:20:04',3223433,3369,9565,2),('4545435545','john','q3.net','q3.net','acne.li','436643316120','436643316939','45345234568968','995696699','1.1.1.1','2.9.9.2','2','86998','34','x','x','2012-03-12 11:35:03','2012-12-05 08:50:04',8823123,169,3565,3); +create table t1 engine=myisam as select * from t1_c; +create table t2 engine=myisam as select * from t2_c; +create table t3 engine=myisam as select * from t3_c; +create table t4 engine=myisam as select * from t4_c; +create table t5 engine=myisam as select * from t5_c; +create table t6 engine=myisam as select * from t6_c; +create table t7 engine=myisam as select * from t7_c; +create table t8 engine=myisam as select * from t8_c; +create table t9 engine=myisam as select * from t9_c; +CREATE TEMPORARY TABLE IF NOT EXISTS test.backup_info (id INT, backup_id INT) ENGINE = HEAP; +DELETE FROM test.backup_info; +LOAD DATA INFILE '../tmp.dat' INTO TABLE test.backup_info FIELDS TERMINATED BY ','; +SELECT @the_backup_id:=backup_id FROM test.backup_info; +@the_backup_id:=backup_id +<the_backup_id> +DROP TABLE test.backup_info; +drop table t1_c,t2_c,t3_c,t4_c,t5_c,t6_c,t7_c,t8_c,t9_c; +select count(*) from t1; +count(*) +5 +select count(*) from t1_c; +count(*) +5 +select count(*) +from (select * from t1 union +select * from t1_c) a; +count(*) +5 +select count(*) from t2; +count(*) +6 +select count(*) from t2_c; +count(*) +6 +select count(*) +from (select * from t2 union +select * from t2_c) a; +count(*) +6 +select count(*) from t3; +count(*) +4 +select count(*) from t3_c; +count(*) +4 +select count(*) +from (select * from t3 union +select * from t3_c) a; +count(*) +4 +select count(*) from t4; +count(*) +22 +select count(*) from t4_c; +count(*) +22 +select count(*) +from (select * from t4 union +select * from t4_c) a; +count(*) +22 +select count(*) from t5; +count(*) +3 +select count(*) from t5_c; +count(*) +3 +select count(*) +from (select * from t5 union +select * from t5_c) a; +count(*) +3 +select count(*) from t6; +count(*) +8 +select count(*) from t6_c; +count(*) +8 +select count(*) +from (select * from t6 union +select * from t6_c) a; +count(*) +8 +select count(*) from t7; +count(*) +5 +select count(*) from t7_c; +count(*) +5 +select count(*) +from (select * from t7 union +select * from t7_c) a; +count(*) +5 +select count(*) from t8; +count(*) +3 +select count(*) from t8_c; +count(*) +3 +select count(*) +from (select * from t8 union +select * from t8_c) a; +count(*) +3 +select count(*) from t9; +count(*) +3 +select count(*) from t9_c; +count(*) +3 +select count(*) +from (select * from t9 union +select * from t9_c) a; +count(*) +3 +ALTER TABLE t1_c +PARTITION BY RANGE (`capgoaledatta`) +(PARTITION p0 VALUES LESS THAN MAXVALUE); +ALTER TABLE t2_c +PARTITION BY LIST(`capgotod`) +(PARTITION p0 VALUES IN (0,1,2,3,4,5,6)); +ALTER TABLE t3_c +PARTITION BY HASH (`CapGoaledatta`); +ALTER TABLE t5_c +PARTITION BY HASH (`capfa`) +PARTITIONS 4; +ALTER TABLE t6_c +PARTITION BY LINEAR HASH (`relatta`) +PARTITIONS 4; +ALTER TABLE t7_c +PARTITION BY LINEAR KEY (`dardtestard`); +CREATE TEMPORARY TABLE IF NOT EXISTS test.backup_info (id INT, backup_id INT) ENGINE = HEAP; +DELETE FROM test.backup_info; +LOAD DATA INFILE '../tmp.dat' INTO TABLE test.backup_info FIELDS TERMINATED BY ','; +SELECT @the_backup_id:=backup_id FROM test.backup_info; +@the_backup_id:=backup_id +<the_backup_id> +DROP TABLE test.backup_info; +drop table t1_c,t2_c,t3_c,t4_c,t5_c,t6_c,t7_c,t8_c,t9_c; +select count(*) from t1; +count(*) +5 +select count(*) from t1_c; +count(*) +5 +select count(*) +from (select * from t1 union +select * from t1_c) a; +count(*) +5 +select count(*) from t2; +count(*) +6 +select count(*) from t2_c; +count(*) +6 +select count(*) +from (select * from t2 union +select * from t2_c) a; +count(*) +6 +select count(*) from t3; +count(*) +4 +select count(*) from t3_c; +count(*) +4 +select count(*) +from (select * from t3 union +select * from t3_c) a; +count(*) +4 +select count(*) from t4; +count(*) +22 +select count(*) from t4_c; +count(*) +22 +select count(*) +from (select * from t4 union +select * from t4_c) a; +count(*) +22 +select count(*) from t5; +count(*) +3 +select count(*) from t5_c; +count(*) +3 +select count(*) +from (select * from t5 union +select * from t5_c) a; +count(*) +3 +select count(*) from t6; +count(*) +8 +select count(*) from t6_c; +count(*) +8 +select count(*) +from (select * from t6 union +select * from t6_c) a; +count(*) +8 +select count(*) from t7; +count(*) +5 +select count(*) from t7_c; +count(*) +5 +select count(*) +from (select * from t7 union +select * from t7_c) a; +count(*) +5 +select count(*) from t8; +count(*) +3 +select count(*) from t8_c; +count(*) +3 +select count(*) +from (select * from t8 union +select * from t8_c) a; +count(*) +3 +select count(*) from t9; +count(*) +3 +select count(*) from t9_c; +count(*) +3 +select count(*) +from (select * from t9 union +select * from t9_c) a; +count(*) +3 +drop table t1_c,t2_c,t3_c,t4_c,t5_c,t6_c,t7_c,t8_c,t9_c; +select count(*) from t1; +count(*) +5 +select count(*) from t1_c; +count(*) +5 +select count(*) +from (select * from t1 union +select * from t1_c) a; +count(*) +5 +select count(*) from t2; +count(*) +6 +select count(*) from t2_c; +count(*) +6 +select count(*) +from (select * from t2 union +select * from t2_c) a; +count(*) +6 +select count(*) from t3; +count(*) +4 +select count(*) from t3_c; +count(*) +4 +select count(*) +from (select * from t3 union +select * from t3_c) a; +count(*) +4 +select count(*) from t4; +count(*) +22 +select count(*) from t4_c; +count(*) +22 +select count(*) +from (select * from t4 union +select * from t4_c) a; +count(*) +22 +select count(*) from t5; +count(*) +3 +select count(*) from t5_c; +count(*) +3 +select count(*) +from (select * from t5 union +select * from t5_c) a; +count(*) +3 +select count(*) from t6; +count(*) +8 +select count(*) from t6_c; +count(*) +8 +select count(*) +from (select * from t6 union +select * from t6_c) a; +count(*) +8 +select count(*) from t7; +count(*) +5 +select count(*) from t7_c; +count(*) +5 +select count(*) +from (select * from t7 union +select * from t7_c) a; +count(*) +5 +select count(*) from t8; +count(*) +3 +select count(*) from t8_c; +count(*) +3 +select count(*) +from (select * from t8 union +select * from t8_c) a; +count(*) +3 +select count(*) from t9; +count(*) +3 +select count(*) from t9_c; +count(*) +3 +select count(*) +from (select * from t9 union +select * from t9_c) a; +count(*) +3 +drop table t1_c,t3_c,t4_c,t5_c,t6_c,t7_c,t8_c,t9_c; +CREATE TEMPORARY TABLE IF NOT EXISTS test.backup_info (id INT, backup_id INT) ENGINE = HEAP; +DELETE FROM test.backup_info; +LOAD DATA INFILE '../tmp.dat' INTO TABLE test.backup_info FIELDS TERMINATED BY ','; +SELECT @the_backup_id:=backup_id FROM test.backup_info; +@the_backup_id:=backup_id +<the_backup_id> +DROP TABLE test.backup_info; +Create table test/def/t2_c failed: Translate frm error +drop table if exists t1,t2,t3,t4,t5,t6,t7,t8,t9; +drop table if exists t2_c; +520093696,<the_backup_id> diff --git a/mysql-test/suite/ndb/r/ndb_restore_print.result b/mysql-test/suite/ndb/r/ndb_restore_print.result new file mode 100644 index 00000000000..e05f8e43d1a --- /dev/null +++ b/mysql-test/suite/ndb/r/ndb_restore_print.result @@ -0,0 +1,321 @@ +use test; +drop table if exists t1,t2,t3,t4,t5,t6,t7,t8,t9,t10; +create table t1 +(pk int key +,a1 BIT(1), a2 BIT(5), a3 BIT(33), a4 BIT(63), a5 BIT(64) +,b1 TINYINT, b2 TINYINT UNSIGNED +,c1 SMALLINT, c2 SMALLINT UNSIGNED +,d1 INT, d2 INT UNSIGNED +,e1 BIGINT, e2 BIGINT UNSIGNED +,f1 CHAR(1) BINARY, f2 CHAR(32) BINARY, f3 CHAR(255) BINARY +,g1 VARCHAR(32) BINARY, g2 VARCHAR(255) BINARY, g3 VARCHAR(1000) BINARY +,h1 BINARY(1), h2 BINARY(8), h3 BINARY(255) +,i1 VARBINARY(32), i2 VARBINARY(255), i3 VARBINARY(1000) +) engine myisam; +insert into t1 values +(1 +,0x1, 0x17, 0x789a, 0x789abcde, 0xfedc0001 +,127, 255 +,32767, 65535 +,2147483647, 4294967295 +,9223372036854775807, 18446744073709551615 +,'1','12345678901234567890123456789012','123456789' + ,'1','12345678901234567890123456789012','123456789' + ,0x12,0x123456789abcdef0, 0x012345 +,0x12,0x123456789abcdef0, 0x00123450 +); +insert into t1 values +(2 +,0, 0, 0, 0, 0 +,-128, 0 +,-32768, 0 +,-2147483648, 0 +,-9223372036854775808, 0 +,'','','' + ,'','','' + ,0x0,0x0,0x0 +,0x0,0x0,0x0 +); +insert into t1 values +(3 +,NULL,NULL,NULL,NULL,NULL +,NULL,NULL +,NULL,NULL +,NULL,NULL +,NULL,NULL +,NULL,NULL,NULL +,NULL,NULL,NULL +,NULL,NULL,NULL +,NULL,NULL,NULL +); +select pk +,hex(a1), hex(a2), hex(a3), hex(a4), hex(a5) +,b1, b2 +,c1 , c2 +,d1 , d2 +,e1 , e2 +,f1 , f2, f3 +,g1 , g2, g3 +,hex(h1), hex(h2), hex(h3) +,hex(i1), hex(i2), hex(i3) +from t1 order by pk; +pk 1 +hex(a1) 1 +hex(a2) 17 +hex(a3) 789A +hex(a4) 789ABCDE +hex(a5) FEDC0001 +b1 127 +b2 255 +c1 32767 +c2 65535 +d1 2147483647 +d2 4294967295 +e1 9223372036854775807 +e2 18446744073709551615 +f1 1 +f2 12345678901234567890123456789012 +f3 123456789 +g1 1 +g2 12345678901234567890123456789012 +g3 123456789 +hex(h1) 12 +hex(h2) 123456789ABCDEF0 +hex(h3) 012345000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 +hex(i1) 12 +hex(i2) 123456789ABCDEF0 +hex(i3) 00123450 +pk 2 +hex(a1) 0 +hex(a2) 0 +hex(a3) 0 +hex(a4) 0 +hex(a5) 0 +b1 -128 +b2 0 +c1 -32768 +c2 0 +d1 -2147483648 +d2 0 +e1 -9223372036854775808 +e2 0 +f1 +f2 +f3 +g1 +g2 +g3 +hex(h1) 00 +hex(h2) 0000000000000000 +hex(h3) 000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 +hex(i1) 00 +hex(i2) 00 +hex(i3) 00 +pk 3 +hex(a1) NULL +hex(a2) NULL +hex(a3) NULL +hex(a4) NULL +hex(a5) NULL +b1 NULL +b2 NULL +c1 NULL +c2 NULL +d1 NULL +d2 NULL +e1 NULL +e2 NULL +f1 NULL +f2 NULL +f3 NULL +g1 NULL +g2 NULL +g3 NULL +hex(h1) NULL +hex(h2) NULL +hex(h3) NULL +hex(i1) NULL +hex(i2) NULL +hex(i3) NULL +alter table t1 engine ndb; +select pk +,hex(a1), hex(a2), hex(a3), hex(a4), hex(a5) +,b1, b2 +,c1 , c2 +,d1 , d2 +,e1 , e2 +,f1 , f2, f3 +,g1 , g2, g3 +,hex(h1), hex(h2), hex(h3) +,hex(i1), hex(i2), hex(i3) +from t1 order by pk; +pk 1 +hex(a1) 1 +hex(a2) 17 +hex(a3) 789A +hex(a4) 789ABCDE +hex(a5) FEDC0001 +b1 127 +b2 255 +c1 32767 +c2 65535 +d1 2147483647 +d2 4294967295 +e1 9223372036854775807 +e2 18446744073709551615 +f1 1 +f2 12345678901234567890123456789012 +f3 123456789 +g1 1 +g2 12345678901234567890123456789012 +g3 123456789 +hex(h1) 12 +hex(h2) 123456789ABCDEF0 +hex(h3) 012345000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 +hex(i1) 12 +hex(i2) 123456789ABCDEF0 +hex(i3) 00123450 +pk 2 +hex(a1) 0 +hex(a2) 0 +hex(a3) 0 +hex(a4) 0 +hex(a5) 0 +b1 -128 +b2 0 +c1 -32768 +c2 0 +d1 -2147483648 +d2 0 +e1 -9223372036854775808 +e2 0 +f1 +f2 +f3 +g1 +g2 +g3 +hex(h1) 00 +hex(h2) 0000000000000000 +hex(h3) 000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 +hex(i1) 00 +hex(i2) 00 +hex(i3) 00 +pk 3 +hex(a1) NULL +hex(a2) NULL +hex(a3) NULL +hex(a4) NULL +hex(a5) NULL +b1 NULL +b2 NULL +c1 NULL +c2 NULL +d1 NULL +d2 NULL +e1 NULL +e2 NULL +f1 NULL +f2 NULL +f3 NULL +g1 NULL +g2 NULL +g3 NULL +hex(h1) NULL +hex(h2) NULL +hex(h3) NULL +hex(i1) NULL +hex(i2) NULL +hex(i3) NULL +CREATE TEMPORARY TABLE IF NOT EXISTS test.backup_info (id INT, backup_id INT) ENGINE = HEAP; +DELETE FROM test.backup_info; +LOAD DATA INFILE '../tmp.dat' INTO TABLE test.backup_info FIELDS TERMINATED BY ','; +SELECT @the_backup_id:=backup_id FROM test.backup_info; +@the_backup_id:=backup_id +<the_backup_id> +DROP TABLE test.backup_info; +1;0x1;0x17;0x789A;0x789ABCDE;0xFEDC0001;127;255;32767;65535;2147483647;4294967295;9223372036854775807;18446744073709551615;1;12345678901234567890123456789012;123456789;1;12345678901234567890123456789012;123456789;0x12;0x123456789ABCDEF0;0x012345;0x12;0x123456789ABCDEF0;0x00123450 +2;0x0;0x0;0x0;0x0;0x0;-128;0;-32768;0;-2147483648;0;-9223372036854775808;0;;;;;;;0x0;0x0;0x0;0x0;0x0;0x0 +3;\N;\N;\N;\N;\N;\N;\N;\N;\N;\N;\N;\N;\N;\N;\N;\N;\N;\N;\N;\N;\N;\N;\N;\N;\N +1,0x1,0x17,0x789A,0x789ABCDE,0xFEDC0001,127,255,32767,65535,2147483647,4294967295,9223372036854775807,18446744073709551615,'1','12345678901234567890123456789012','123456789','1','12345678901234567890123456789012','123456789',0x12,0x123456789ABCDEF0,0x012345,0x12,0x123456789ABCDEF0,0x00123450 +2,0x0,0x0,0x0,0x0,0x0,-128,0,-32768,0,-2147483648,0,-9223372036854775808,0,'','','','','','',0x0,0x0,0x0,0x0,0x0,0x0 +3,,,,,,,,,,,,,,,,,,,,,,,,, +drop table t1; +create table t1 +(pk int key +,f1 CHAR(1) BINARY, f2 CHAR(32) BINARY, f3 CHAR(255) BINARY +,g1 VARCHAR(32) BINARY, g2 VARCHAR(255) BINARY, g3 VARCHAR(1000) BINARY +,h1 BINARY(1), h2 BINARY(9), h3 BINARY(255) +,i1 VARBINARY(32), i2 VARBINARY(255), i3 VARBINARY(1000) +) engine ndb; +insert into t1 values +(1 +,'1','12345678901234567890123456789012','123456789 ' + ,'1 ','12345678901234567890123456789012 ','123456789 ' + ,0x20,0x123456789abcdef020, 0x012345000020 +,0x1200000020,0x123456789abcdef000000020, 0x00123450000020 +); +create table t2 (pk int key, a int) engine ndb; +create table t3 (pk int key, a int) engine ndb; +create table t4 (pk int key, a int) engine ndb; +insert into t2 values (1,11),(2,12),(3,13),(4,14),(5,15); +insert into t3 values (1,21),(2,22),(3,23),(4,24),(5,25); +insert into t4 values (1,31),(2,32),(3,33),(4,34),(5,35); +CREATE TEMPORARY TABLE IF NOT EXISTS test.backup_info (id INT, backup_id INT) ENGINE = HEAP; +DELETE FROM test.backup_info; +LOAD DATA INFILE '../tmp.dat' INTO TABLE test.backup_info FIELDS TERMINATED BY ','; +SELECT @the_backup_id:=backup_id FROM test.backup_info; +@the_backup_id:=backup_id +<the_backup_id> +DROP TABLE test.backup_info; +'1' '1' '12345678901234567890123456789012' '123456789' '1' '12345678901234567890123456789012' '123456789' '0x20' '0x123456789ABCDEF020' '0x012345000020' '0x1200000020' '0x123456789ABCDEF000000020' '0x00123450000020' + +t1 +-- +1 1 12345678901234567890123456789012 123456789 1 12345678901234567890123456789012 123456789 0x20 0x123456789ABCDEF020 0x012345000020 0x1200000020 0x123456789ABCDEF000000020 0x00123450000020 + +t2 +-- +1 11 +2 12 +3 13 +4 14 +5 15 + +t3 +-- +1 21 +2 22 +3 23 +4 24 +5 25 + +t4 +-- +1 31 +2 32 +3 33 +4 34 +5 35 +drop table t1; +create table t1 +(pk int key +,a1 MEDIUMINT, a2 MEDIUMINT UNSIGNED +) engine ndb; +insert into t1 values(1, 8388607, 16777215); +insert into t1 values(2, -8388608, 0); +insert into t1 values(3, -1, 1); +CREATE TEMPORARY TABLE IF NOT EXISTS test.backup_info (id INT, backup_id INT) ENGINE = HEAP; +DELETE FROM test.backup_info; +LOAD DATA INFILE '../tmp.dat' INTO TABLE test.backup_info FIELDS TERMINATED BY ','; +SELECT @the_backup_id:=backup_id FROM test.backup_info; +@the_backup_id:=backup_id +<the_backup_id> +DROP TABLE test.backup_info; +1;8388607;16777215 +2;-8388608;0 +3;-1;1 +drop table t1; +drop table t2; +drop table t3; +drop table t4; diff --git a/mysql-test/suite/ndb/r/ndb_row_format.result b/mysql-test/suite/ndb/r/ndb_row_format.result new file mode 100644 index 00000000000..37c239986f6 --- /dev/null +++ b/mysql-test/suite/ndb/r/ndb_row_format.result @@ -0,0 +1,65 @@ +DROP TABLE IF EXISTS t1,t2,t3,t4,t5,t6,t7; +drop database if exists mysqltest; +CREATE TABLE t1 +( a INT KEY, +b VARCHAR(10) ) +ROW_FORMAT=FIXED +ENGINE=NDB; +ERROR HY000: Can't create table 'test.t1' (errno: 138) +SHOW WARNINGS; +Level Code Message +Error 1475 Table storage engine 'ndbcluster' does not support the create option 'Row format FIXED incompatible with variable sized attribute' +Error 1005 Can't create table 'test.t1' (errno: 138) +CREATE TABLE t1 +( a INT KEY, +b INT ) +ENGINE=NDB; +ForceVarPart: 1 +DROP TABLE t1; +CREATE TABLE t1 +( a INT KEY, +b INT ) +ROW_FORMAT=DEFAULT +ENGINE=NDB; +ForceVarPart: 1 +DROP TABLE t1; +CREATE TABLE t1 +( a INT KEY, +b INT ) +ROW_FORMAT=FIXED +ENGINE=NDB; +ForceVarPart: 0 +DROP TABLE t1; +CREATE TABLE t1 +( a INT KEY, +b INT ) +ROW_FORMAT=DYNAMIC +ENGINE=NDB; +ForceVarPart: 1 +DROP TABLE t1; +create table t1 (a int auto_increment primary key, b varchar(1000)) engine = ndb; +insert into t1(b) values ('0123456789'); +insert into t1(b) select b from t1; +insert into t1(b) select b from t1; +insert into t1(b) select b from t1; +insert into t1(b) select b from t1; +insert into t1(b) select b from t1; +insert into t1(b) select b from t1; +insert into t1(b) select b from t1; +insert into t1(b) select b from t1; +insert into t1(b) select b from t1; +insert into t1(b) select b from t1; +select count(*) from t1; +count(*) +1024 +begin; +update t1 set b = concat(b,b); +update t1 set b = concat(b,b); +update t1 set b = concat(b,b); +update t1 set b = concat(b,b); +update t1 set b = concat(b,b); +rollback; +select count(*),b from t1 group by b; +count(*) b +1024 0123456789 +drop table t1; diff --git a/mysql-test/suite/ndb/r/ndb_single_user.result b/mysql-test/suite/ndb/r/ndb_single_user.result new file mode 100644 index 00000000000..f916422a509 --- /dev/null +++ b/mysql-test/suite/ndb/r/ndb_single_user.result @@ -0,0 +1,119 @@ +use test; +drop table if exists t1,t2,t3,t4,t5,t6,t7,t8,t9,t10; +create table t1 (a int key, b int unique, c int) engine ndb; +ERROR HY000: Can't create table 'test.t1' (errno: 299) +CREATE LOGFILE GROUP lg1 +ADD UNDOFILE 'undofile.dat' +INITIAL_SIZE 16M +UNDO_BUFFER_SIZE = 1M +ENGINE=NDB; +ERROR HY000: Failed to create LOGFILE GROUP +show warnings; +Level Code Message +Error 1296 Got error 299 'Operation not allowed or aborted due to single user mode' from NDB +Error 1525 Failed to create LOGFILE GROUP +create table t1 (a int key, b int unique, c int) engine ndb; +CREATE LOGFILE GROUP lg1 +ADD UNDOFILE 'undofile.dat' +INITIAL_SIZE 16M +UNDO_BUFFER_SIZE = 1M +ENGINE=NDB; +CREATE TABLESPACE ts1 +ADD DATAFILE 'datafile.dat' +USE LOGFILE GROUP lg1 +INITIAL_SIZE 12M +ENGINE NDB; +ERROR HY000: Failed to create TABLESPACE +show warnings; +Level Code Message +Error 1296 Got error 299 'Operation not allowed or aborted due to single user mode' from NDB +Error 1525 Failed to create TABLESPACE +DROP LOGFILE GROUP lg1 +ENGINE =NDB; +ERROR HY000: Failed to drop LOGFILE GROUP +show warnings; +Level Code Message +Error 1296 Got error 299 'Operation not allowed or aborted due to single user mode' from NDB +Error 1526 Failed to drop LOGFILE GROUP +CREATE TABLESPACE ts1 +ADD DATAFILE 'datafile.dat' +USE LOGFILE GROUP lg1 +INITIAL_SIZE 12M +ENGINE NDB; +ALTER TABLESPACE ts1 +DROP DATAFILE 'datafile.dat' +ENGINE NDB; +ERROR HY000: Failed to alter: DROP DATAFILE +show warnings; +Level Code Message +Error 1296 Got error 299 'Operation not allowed or aborted due to single user mode' from NDB +Error 1530 Failed to alter: DROP DATAFILE +ALTER TABLESPACE ts1 +DROP DATAFILE 'datafile.dat' +ENGINE NDB; +DROP TABLESPACE ts1 +ENGINE NDB; +ERROR HY000: Failed to drop TABLESPACE +show warnings; +Level Code Message +Error 1296 Got error 299 'Operation not allowed or aborted due to single user mode' from NDB +Error 1526 Failed to drop TABLESPACE +DROP TABLESPACE ts1 +ENGINE NDB; +DROP LOGFILE GROUP lg1 +ENGINE =NDB; +insert into t1 values (1,1,0),(2,2,0),(3,3,0),(4,4,0),(5,5,0),(6,6,0),(7,7,0),(8,8,0),(9,9,0),(10,10,0); +create table t2 as select * from t1; +select * from t1 where a = 1; +a b c +1 1 0 +select * from t1 where b = 4; +a b c +4 4 0 +select * from t1 where a > 4 order by a; +a b c +5 5 0 +6 6 0 +7 7 0 +8 8 0 +9 9 0 +10 10 0 +update t1 set b=102 where a = 2; +update t1 set b=103 where b = 3; +update t1 set b=b+100; +update t1 set b=b+100 where a > 7; +delete from t1; +insert into t1 select * from t2; +create unique index new_index on t1 (b,c); +drop table t1; +ERROR 42S02: Unknown table 't1' +create index new_index_fail on t1 (c); +ERROR HY000: Got error 299 'Operation not allowed or aborted due to single user mode' from NDBCLUSTER +insert into t1 values (21,21,0),(22,22,0),(23,23,0),(24,24,0),(25,25,0),(26,26,0),(27,27,0),(28,28,0),(29,29,0),(210,210,0); +ERROR HY000: Got error 299 'Operation not allowed or aborted due to single user mode' from NDBCLUSTER +select * from t1 where a = 1; +ERROR HY000: Got error 299 'Operation not allowed or aborted due to single user mode' from NDBCLUSTER +select * from t1 where b = 4; +ERROR HY000: Got error 299 'Operation not allowed or aborted due to single user mode' from NDBCLUSTER +update t1 set b=102 where a = 2; +ERROR HY000: Got error 299 'Operation not allowed or aborted due to single user mode' from NDBCLUSTER +update t1 set b=103 where b = 3; +ERROR HY000: Got error 299 'Operation not allowed or aborted due to single user mode' from NDBCLUSTER +update t1 set b=b+100; +ERROR HY000: Got error 299 'Operation not allowed or aborted due to single user mode' from NDBCLUSTER +update t1 set b=b+100 where a > 7; +ERROR HY000: Got error 299 'Operation not allowed or aborted due to single user mode' from NDBCLUSTER +BEGIN; +update t1 set b=b+100 where a=1; +BEGIN; +update t1 set b=b+100 where a=2; +update t1 set b=b+100 where a=3; +COMMIT; +update t1 set b=b+100 where a=4; +ERROR HY000: Got error 299 'Operation not allowed or aborted due to single user mode' from NDBCLUSTER +COMMIT; +ERROR HY000: Got error 4350 'Transaction already aborted' from NDBCLUSTER +create table t2 (a int) engine myisam; +alter table t2 add column (b int); +drop table t2; +drop table t1; diff --git a/mysql-test/suite/ndb/r/ndb_sp.result b/mysql-test/suite/ndb/r/ndb_sp.result new file mode 100644 index 00000000000..dbd0325044d --- /dev/null +++ b/mysql-test/suite/ndb/r/ndb_sp.result @@ -0,0 +1,44 @@ +drop table if exists t1; +create table t1 ( +a int not null primary key, +b int not null +) engine=ndb; +insert into t1 values (1,10), (2,20), (3,100), (4, 100); +create procedure test_proc1 (in var_in int) +begin +select * from t1 where a = var_in; +end; +create procedure test_proc2 (out var_out int) +begin +select b from t1 where a = 1 into var_out; +end; +create procedure test_proc3 (inout var_inout int) +begin +select b from t1 where a = var_inout into var_inout; +end; +// +call test_proc1(1); +a b +1 10 +call test_proc2(@test_var); +select @test_var; +@test_var +10 +set @test_var = 1; +call test_proc3(@test_var); +select @test_var; +@test_var +10 +alter procedure test_proc1 comment 'new comment'; +show create procedure test_proc1; +Procedure sql_mode Create Procedure character_set_client collation_connection Database Collation +test_proc1 CREATE DEFINER=`root`@`localhost` PROCEDURE `test_proc1`(in var_in int) + COMMENT 'new comment' +begin +select * from t1 where a = var_in; +end latin1 latin1_swedish_ci latin1_swedish_ci +drop procedure test_proc1; +drop procedure test_proc2; +drop procedure test_proc3; +drop table t1; +End of 5.1 tests diff --git a/mysql-test/suite/ndb/r/ndb_subquery.result b/mysql-test/suite/ndb/r/ndb_subquery.result new file mode 100644 index 00000000000..45662882d3a --- /dev/null +++ b/mysql-test/suite/ndb/r/ndb_subquery.result @@ -0,0 +1,92 @@ +drop table if exists t1, t2, t3, t4; +create table t1 (p int not null primary key, u int not null, o int not null, +unique (u), key(o)) engine=ndb; +create table t2 (p int not null primary key, u int not null, o int not null, +unique (u), key(o)) engine=ndb; +create table t3 (a int not null primary key, b int not null) engine=ndb; +create table t4 (c int not null primary key, d int not null) engine=ndb; +insert into t1 values (1,1,1),(2,2,2),(3,3,3); +insert into t2 values (1,1,1),(2,2,2),(3,3,3), (4,4,4), (5,5,5); +insert into t3 values (1,10), (2,10), (3,30), (4, 30); +insert into t4 values (1,10), (2,10), (3,30), (4, 30); +explain select * from t2 where p NOT IN (select p from t1); +id select_type table type possible_keys key key_len ref rows Extra +1 PRIMARY t2 ALL NULL NULL NULL NULL # Using where +2 DEPENDENT SUBQUERY t1 unique_subquery PRIMARY PRIMARY 4 func # +select * from t2 where p NOT IN (select p from t1) order by p; +p u o +4 4 4 +5 5 5 +explain select * from t2 where p NOT IN (select u from t1); +id select_type table type possible_keys key key_len ref rows Extra +1 PRIMARY t2 ALL NULL NULL NULL NULL # Using where +2 DEPENDENT SUBQUERY t1 unique_subquery u u 4 func # +select * from t2 where p NOT IN (select u from t1) order by p; +p u o +4 4 4 +5 5 5 +explain select * from t2 where p NOT IN (select o from t1); +id select_type table type possible_keys key key_len ref rows Extra +1 PRIMARY t2 ALL NULL NULL NULL NULL # Using where +2 DEPENDENT SUBQUERY t1 index_subquery o o 4 func # +select * from t2 where p NOT IN (select o from t1) order by p; +p u o +4 4 4 +5 5 5 +explain select * from t2 where p NOT IN (select p+0 from t1); +id select_type table type possible_keys key key_len ref rows Extra +1 PRIMARY t2 ALL NULL NULL NULL NULL # Using where +2 DEPENDENT SUBQUERY t1 ALL NULL NULL NULL NULL # Using where +select * from t2 where p NOT IN (select p+0 from t1) order by p; +p u o +4 4 4 +5 5 5 +drop table t1; +drop table t2; +create table t1 (p int not null primary key, u int not null) engine=ndb; +insert into t1 values (1,1),(2,2),(3,3); +create table t2 as +select t1.* +from t1 as t1, t1 as t2, t1 as t3, t1 as t4, t1 as t5, t1 as t6, t1 as t7, t1 as t8 +where t1.u = t2.u +and t2.u = t3.u +and t3.u = t4.u +and t4.u = t5.u +and t5.u = t6.u +and t6.u = t7.u +and t7.u = t8.u; +select * from t2 order by 1; +p u +1 1 +2 2 +3 3 +select * from t3 where a = any (select c from t4 where c = 1) order by a; +a b +1 10 +select * from t3 where a in (select c from t4 where c = 1) order by a; +a b +1 10 +select * from t3 where a <> some (select c from t4 where c = 1) order by a; +a b +2 10 +3 30 +4 30 +select * from t3 where a > all (select c from t4 where c = 1) order by a; +a b +2 10 +3 30 +4 30 +select * from t3 where row(1,10) = (select c,d from t4 where c = 1) order by a; +a b +1 10 +2 10 +3 30 +4 30 +select * from t3 where exists (select * from t4 where c = 1) order by a; +a b +1 10 +2 10 +3 30 +4 30 +drop table if exists t1, t2, t3, t4; +End of 5.1 tests diff --git a/mysql-test/suite/ndb/r/ndb_temporary.result b/mysql-test/suite/ndb/r/ndb_temporary.result new file mode 100644 index 00000000000..61fc1561e4f --- /dev/null +++ b/mysql-test/suite/ndb/r/ndb_temporary.result @@ -0,0 +1,21 @@ +DROP TABLE IF EXISTS t1; +create temporary table t1 (a int key) engine=ndb; +ERROR HY000: Table storage engine 'ndbcluster' does not support the create option 'TEMPORARY' +create temporary table t1 (a int key) engine=myisam; +alter table t1 engine=ndb; +ERROR HY000: Table storage engine 'ndbcluster' does not support the create option 'TEMPORARY' +drop table t1; +SET SESSION storage_engine=NDBCLUSTER; +create table t1 (a int key); +select engine from information_schema.tables where table_name = 't1'; +engine +NDBCLUSTER +drop table t1; +create temporary table t1 (a int key); +show create table t1; +Table Create Table +t1 CREATE TEMPORARY TABLE `t1` ( + `a` int(11) NOT NULL, + PRIMARY KEY (`a`) +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +drop table t1; diff --git a/mysql-test/suite/ndb/r/ndb_transaction.result b/mysql-test/suite/ndb/r/ndb_transaction.result new file mode 100644 index 00000000000..691b91b1d36 --- /dev/null +++ b/mysql-test/suite/ndb/r/ndb_transaction.result @@ -0,0 +1,257 @@ +DROP TABLE IF EXISTS t1,t2,t3,t4,t5,t6,t7; +drop database if exists mysqltest; +CREATE TABLE t1 ( +pk1 INT NOT NULL PRIMARY KEY, +attr1 INT NOT NULL +) ENGINE=ndbcluster; +begin; +insert into t1 values(1,1); +insert into t1 values(2,2); +select count(*) from t1; +count(*) +2 +select * from t1 where pk1 = 1; +pk1 attr1 +1 1 +select t1.attr1 from t1, t1 as t1x where t1.pk1 = t1x.pk1 + 1; +attr1 +2 +rollback; +select count(*) from t1; +count(*) +0 +select * from t1 where pk1 = 1; +pk1 attr1 +select t1.attr1 from t1, t1 as t1x where t1.pk1 = t1x.pk1 + 1; +attr1 +begin; +insert into t1 values(1,1); +insert into t1 values(2,2); +commit; +select count(*) from t1; +count(*) +2 +select * from t1 where pk1 = 1; +pk1 attr1 +1 1 +select t1.attr1 from t1, t1 as t1x where t1.pk1 = t1x.pk1 + 1; +attr1 +2 +begin; +update t1 set attr1 = attr1 * 2; +select count(*) from t1; +count(*) +2 +select * from t1 where pk1 = 1; +pk1 attr1 +1 2 +select * from t1, t1 as t1x where t1x.attr1 = t1.attr1 - 2; +pk1 attr1 pk1 attr1 +2 4 1 2 +rollback; +select count(*) from t1; +count(*) +2 +select * from t1 where pk1 = 1; +pk1 attr1 +1 1 +select * from t1, t1 as t1x where t1x.attr1 = t1.attr1 - 2; +pk1 attr1 pk1 attr1 +begin; +update t1 set attr1 = attr1 * 2; +commit; +select count(*) from t1; +count(*) +2 +select * from t1 where pk1 = 1; +pk1 attr1 +1 2 +select * from t1, t1 as t1x where t1x.attr1 = t1.attr1 - 2; +pk1 attr1 pk1 attr1 +2 4 1 2 +begin; +delete from t1 where attr1 = 2; +select count(*) from t1; +count(*) +1 +select * from t1 where pk1 = 1; +pk1 attr1 +select * from t1, t1 as t1x where t1x.attr1 = t1.attr1 - 2; +pk1 attr1 pk1 attr1 +rollback; +select count(*) from t1; +count(*) +2 +select * from t1 where pk1 = 1; +pk1 attr1 +1 2 +select * from t1, t1 as t1x where t1x.attr1 = t1.attr1 - 2; +pk1 attr1 pk1 attr1 +2 4 1 2 +begin; +delete from t1 where attr1 = 2; +commit; +select count(*) from t1; +count(*) +1 +select * from t1 where pk1 = 1; +pk1 attr1 +select * from t1, t1 as t1x where t1x.attr1 = t1.attr1 - 2; +pk1 attr1 pk1 attr1 +DROP TABLE t1; +CREATE TABLE t1 (id INT, id2 int) engine=ndbcluster; +begin; +insert into t1 values(1,1); +insert into t1 values(2,2); +select sum(id) from t1; +sum(id) +3 +select * from t1 where id = 1; +id id2 +1 1 +select t1.id from t1, t1 as t1x where t1.id2 = t1x.id2 + 1; +id +2 +rollback; +select sum(id) from t1; +sum(id) +NULL +select * from t1 where id = 1; +id id2 +select t1.id from t1, t1 as t1x where t1.id2 = t1x.id2 + 1; +id +begin; +insert into t1 values(1,1); +insert into t1 values(2,2); +commit; +select sum(id) from t1; +sum(id) +3 +select * from t1 where id = 1; +id id2 +1 1 +select t1.id from t1, t1 as t1x where t1.id2 = t1x.id2 + 1; +id +2 +begin; +update t1 set id = id * 2; +select sum(id) from t1; +sum(id) +6 +select * from t1 where id = 2; +id id2 +2 1 +select * from t1, t1 as t1x where t1x.id = t1.id - 2; +id id2 id id2 +4 2 2 1 +rollback; +select sum(id) from t1; +sum(id) +3 +select * from t1 where id = 2; +id id2 +2 2 +select * from t1, t1 as t1x where t1x.id = t1.id - 2; +id id2 id id2 +begin; +update t1 set id = id * 2; +commit; +select sum(id) from t1; +sum(id) +6 +select * from t1 where id = 2; +id id2 +2 1 +select * from t1, t1 as t1x where t1x.id = t1.id - 2; +id id2 id id2 +4 2 2 1 +DROP TABLE t1; +CREATE TABLE t2 ( +a bigint unsigned NOT NULL PRIMARY KEY, +b int unsigned not null, +c int unsigned +) engine=ndbcluster; +CREATE TABLE t3 ( +a bigint unsigned NOT NULL, +b bigint unsigned not null, +c bigint unsigned, +PRIMARY KEY(a) +) engine=ndbcluster; +CREATE TABLE t4 ( +a bigint unsigned NOT NULL, +b bigint unsigned not null, +c bigint unsigned NOT NULL, +d int unsigned, +PRIMARY KEY(a, b, c) +) engine=ndbcluster; +select count(*) from t2; +count(*) +0 +select count(*) from t3; +count(*) +0 +select count(*) from t4; +count(*) +0 +select count(*) from t2; +count(*) +100 +select count(*) from t3; +count(*) +100 +select count(*) from t4; +count(*) +100 +begin; +begin; +drop table t2; +drop table t3; +drop table t4; +CREATE TABLE t1 ( +pk1 INT NOT NULL PRIMARY KEY, +attr1 INT NOT NULL +) ENGINE=ndbcluster; +create database mysqltest; +use mysqltest; +CREATE TABLE t2 ( +a bigint unsigned NOT NULL PRIMARY KEY, +b int unsigned not null, +c int unsigned +) engine=ndbcluster; +begin; +insert into test.t1 values(1,1); +insert into t2 values(1,1,1); +insert into test.t1 values(2,2); +insert into t2 values(2,2,2); +select count(*) from test.t1; +count(*) +2 +select count(*) from t2; +count(*) +2 +select * from test.t1 where pk1 = 1; +pk1 attr1 +1 1 +select * from t2 where a = 1; +a b c +1 1 1 +select test.t1.attr1 +from test.t1, test.t1 as t1x where test.t1.pk1 = t1x.pk1 + 1; +attr1 +2 +select t2.a +from t2, t2 as t2x where t2.a = t2x.a + 1; +a +2 +select test.t1.pk1, a from test.t1,t2 where b > test.t1.attr1; +pk1 a +1 2 +rollback; +select count(*) from test.t1; +count(*) +0 +select count(*) from t2; +count(*) +0 +drop table test.t1, t2; +drop database mysqltest; diff --git a/mysql-test/suite/ndb/r/ndb_trigger.result b/mysql-test/suite/ndb/r/ndb_trigger.result new file mode 100644 index 00000000000..d074ad01c22 --- /dev/null +++ b/mysql-test/suite/ndb/r/ndb_trigger.result @@ -0,0 +1,315 @@ +drop table if exists t1, t2, t3, t4, t5; +create table t1 (id int primary key, a int not null, b decimal (63,30) default 0) engine=ndb; +create table t2 (op char(1), a int not null, b decimal (63,30)) engine=ndb; +create table t3 engine=ndb select 1 as i; +create table t4 (a int not null primary key, b int) engine=ndb; +create table t5 (a int not null primary key, b int) engine=ndb; +create trigger t1_bu before update on t1 for each row +begin +insert into t2 values ("u", old.a, old.b); +set new.b = old.b + 10; +end;// +create trigger t1_bd before delete on t1 for each row +begin +insert into t2 values ("d", old.a, old.b); +end;// +create trigger t4_au after update on t4 +for each row begin +update t5 set b = b+1; +end; +// +create trigger t4_ad after delete on t4 +for each row begin +update t5 set b = b+1; +end; +// +insert into t1 values (1, 1, 1.05), (2, 2, 2.05), (3, 3, 3.05), (4, 4, 4.05); +insert into t4 values (1,1), (2,2), (3,3), (4, 4); +insert into t5 values (1,0); +update t1 set a=5 where a != 3; +select * from t1 order by id; +id a b +1 5 11.050000000000000000000000000000 +2 5 12.050000000000000000000000000000 +3 3 3.050000000000000000000000000000 +4 5 14.050000000000000000000000000000 +select * from t2 order by op, a, b; +op a b +u 1 1.050000000000000000000000000000 +u 2 2.050000000000000000000000000000 +u 4 4.050000000000000000000000000000 +delete from t2; +update t1, t3 set a=6 where a = 5; +select * from t1 order by id; +id a b +1 6 21.050000000000000000000000000000 +2 6 22.050000000000000000000000000000 +3 3 3.050000000000000000000000000000 +4 6 24.050000000000000000000000000000 +select * from t2 order by op, a, b; +op a b +u 5 11.050000000000000000000000000000 +u 5 12.050000000000000000000000000000 +u 5 14.050000000000000000000000000000 +delete from t2; +delete from t1 where a != 3; +select * from t1 order by id; +id a b +3 3 3.050000000000000000000000000000 +select * from t2 order by op, a, b; +op a b +d 6 21.050000000000000000000000000000 +d 6 22.050000000000000000000000000000 +d 6 24.050000000000000000000000000000 +delete from t2; +insert into t1 values (1, 1, 1.05), (2, 2, 2.05), (4, 4, 4.05); +delete t1 from t1, t3 where a != 3; +select * from t1 order by id; +id a b +3 3 3.050000000000000000000000000000 +select * from t2 order by op, a, b; +op a b +d 1 1.050000000000000000000000000000 +d 2 2.050000000000000000000000000000 +d 4 4.050000000000000000000000000000 +delete from t2; +insert into t1 values (4, 4, 4.05); +insert into t1 (id, a) values (4, 1), (3, 1) on duplicate key update a= a + 1; +select * from t1 order by id; +id a b +3 4 13.050000000000000000000000000000 +4 5 14.050000000000000000000000000000 +select * from t2 order by op, a, b; +op a b +u 3 3.050000000000000000000000000000 +u 4 4.050000000000000000000000000000 +delete from t2; +delete from t3; +insert into t3 values (4), (3); +insert into t1 (id, a) (select i, 1 from t3) on duplicate key update a= a + 1; +select * from t1 order by id; +id a b +3 5 23.050000000000000000000000000000 +4 6 24.050000000000000000000000000000 +select * from t2 order by op, a, b; +op a b +u 4 13.050000000000000000000000000000 +u 5 14.050000000000000000000000000000 +delete from t2; +replace into t1 (id, a) values (4, 1), (3, 1); +select * from t1 order by id; +id a b +3 1 0.000000000000000000000000000000 +4 1 0.000000000000000000000000000000 +select * from t2 order by op, a, b; +op a b +d 5 23.050000000000000000000000000000 +d 6 24.050000000000000000000000000000 +delete from t1; +delete from t2; +insert into t1 values (3, 1, 1.05), (4, 1, 2.05); +replace into t1 (id, a) (select i, 2 from t3); +select * from t1 order by id; +id a b +3 2 0.000000000000000000000000000000 +4 2 0.000000000000000000000000000000 +select * from t2 order by op, a, b; +op a b +d 1 1.050000000000000000000000000000 +d 1 2.050000000000000000000000000000 +delete from t1; +delete from t2; +insert into t1 values (3, 1, 1.05), (5, 2, 2.05); +load data infile '../std_data_ln/loaddata5.dat' replace into table t1 fields terminated by '' enclosed by '' ignore 1 lines (id, a); +select * from t1 order by id; +id a b +3 4 0.000000000000000000000000000000 +5 6 0.000000000000000000000000000000 +select * from t2 order by op, a, b; +op a b +d 1 1.050000000000000000000000000000 +d 2 2.050000000000000000000000000000 +update t4 set b = 10 where a = 1; +select * from t5 order by a; +a b +1 1 +update t5 set b = 0; +delete from t4 where a = 1; +select * from t5 order by a; +a b +1 1 +drop trigger t4_au; +drop trigger t4_ad; +drop table t1, t2, t3, t4, t5; +CREATE TABLE t1 ( +id INT NOT NULL PRIMARY KEY, +xy INT +) ENGINE=ndbcluster; +INSERT INTO t1 VALUES (1, 0); +CREATE TRIGGER t1_update AFTER UPDATE ON t1 FOR EACH ROW BEGIN REPLACE INTO t2 SELECT * FROM t1 WHERE t1.id = NEW.id; END // +CREATE TABLE t2 ( +id INT NOT NULL PRIMARY KEY, +xy INT +) ENGINE=ndbcluster; +INSERT INTO t2 VALUES (2, 0); +CREATE TABLE t3 (id INT NOT NULL PRIMARY KEY) ENGINE=ndbcluster; +INSERT INTO t3 VALUES (1); +CREATE TABLE t4 LIKE t1; +CREATE TRIGGER t4_update AFTER UPDATE ON t4 FOR EACH ROW BEGIN REPLACE INTO t5 SELECT * FROM t4 WHERE t4.id = NEW.id; END // +CREATE TABLE t5 LIKE t2; +UPDATE t1 SET xy = 3 WHERE id = 1; +SELECT xy FROM t1 where id = 1; +xy +3 +SELECT xy FROM t2 where id = 1; +xy +3 +UPDATE t1 SET xy = 4 WHERE id IN (SELECT id FROM t3 WHERE id = 1); +SELECT xy FROM t1 where id = 1; +xy +4 +SELECT xy FROM t2 where id = 1; +xy +4 +INSERT INTO t4 SELECT * FROM t1; +INSERT INTO t5 SELECT * FROM t2; +UPDATE t1,t4 SET t1.xy = 3, t4.xy = 3 WHERE t1.id = 1 AND t4.id = 1; +SELECT xy FROM t1 where id = 1; +xy +3 +SELECT xy FROM t2 where id = 1; +xy +3 +SELECT xy FROM t4 where id = 1; +xy +3 +SELECT xy FROM t5 where id = 1; +xy +3 +UPDATE t1,t4 SET t1.xy = 4, t4.xy = 4 WHERE t1.id IN (SELECT id FROM t3 WHERE id = 1) AND t4.id IN (SELECT id FROM t3 WHERE id = 1); +SELECT xy FROM t1 where id = 1; +xy +4 +SELECT xy FROM t2 where id = 1; +xy +4 +SELECT xy FROM t4 where id = 1; +xy +4 +SELECT xy FROM t5 where id = 1; +xy +4 +INSERT INTO t1 VALUES (1,0) ON DUPLICATE KEY UPDATE xy = 5; +SELECT xy FROM t1 where id = 1; +xy +5 +SELECT xy FROM t2 where id = 1; +xy +5 +DROP TRIGGER t1_update; +DROP TRIGGER t4_update; +CREATE TRIGGER t1_delete AFTER DELETE ON t1 FOR EACH ROW BEGIN REPLACE INTO t2 SELECT * FROM t1 WHERE t1.id > 4; END // +CREATE TRIGGER t4_delete AFTER DELETE ON t4 FOR EACH ROW BEGIN REPLACE INTO t5 SELECT * FROM t4 WHERE t4.id > 4; END // +INSERT INTO t1 VALUES (5, 0),(6,0); +INSERT INTO t2 VALUES (5, 1),(6,1); +INSERT INTO t3 VALUES (5); +SELECT * FROM t1 order by id; +id xy +1 5 +5 0 +6 0 +SELECT * FROM t2 order by id; +id xy +1 5 +2 0 +5 1 +6 1 +DELETE FROM t1 WHERE id IN (SELECT id FROM t3 WHERE id = 5); +SELECT * FROM t1 order by id; +id xy +1 5 +6 0 +SELECT * FROM t2 order by id; +id xy +1 5 +2 0 +5 1 +6 0 +INSERT INTO t1 VALUES (5,0); +UPDATE t2 SET xy = 1 WHERE id = 6; +TRUNCATE t4; +INSERT INTO t4 SELECT * FROM t1; +TRUNCATE t5; +INSERT INTO t5 SELECT * FROM t2; +SELECT * FROM t1 order by id; +id xy +1 5 +5 0 +6 0 +SELECT * FROM t2 order by id; +id xy +1 5 +2 0 +5 1 +6 1 +SELECT * FROM t4 order by id; +id xy +1 5 +5 0 +6 0 +SELECT * FROM t5 order by id; +id xy +1 5 +2 0 +5 1 +6 1 +DELETE FROM t1,t4 USING t1,t3,t4 WHERE t1.id IN (SELECT id FROM t3 WHERE id = 5) AND t4.id IN (SELECT id FROM t3 WHERE id = 5); +SELECT * FROM t1 order by id; +id xy +1 5 +6 0 +SELECT * FROM t2 order by id; +id xy +1 5 +2 0 +5 1 +6 0 +SELECT * FROM t4 order by id; +id xy +1 5 +6 0 +SELECT * FROM t5 order by id; +id xy +1 5 +2 0 +5 1 +6 0 +INSERT INTO t1 VALUES (5, 0); +REPLACE INTO t2 VALUES (6,1); +SELECT * FROM t1 order by id; +id xy +1 5 +5 0 +6 0 +SELECT * FROM t2 order by id; +id xy +1 5 +2 0 +5 1 +6 1 +REPLACE INTO t1 VALUES (5, 1); +SELECT * FROM t1 order by id; +id xy +1 5 +5 1 +6 0 +SELECT * FROM t2 order by id; +id xy +1 5 +2 0 +5 1 +6 0 +DROP TRIGGER t1_delete; +DROP TRIGGER t4_delete; +DROP TABLE t1, t2, t3, t4, t5; +End of 5.1 tests diff --git a/mysql-test/suite/ndb/r/ndb_truncate.result b/mysql-test/suite/ndb/r/ndb_truncate.result new file mode 100644 index 00000000000..811e5e3afeb --- /dev/null +++ b/mysql-test/suite/ndb/r/ndb_truncate.result @@ -0,0 +1,23 @@ +DROP TABLE IF EXISTS t1, t2; +CREATE TABLE t1 ( +a bigint unsigned NOT NULL AUTO_INCREMENT PRIMARY KEY, +b int unsigned not null, +c int unsigned +) engine=ndbcluster; +select count(*) from t1; +count(*) +5000 +select * from t1 order by a limit 2; +a b c +1 509 2500 +2 510 7 +truncate table t1; +select count(*) from t1; +count(*) +0 +insert into t1 values(NULL,1,1),(NULL,2,2); +select * from t1 order by a; +a b c +1 1 1 +2 2 2 +drop table t1; diff --git a/mysql-test/suite/ndb/r/ndb_types.result b/mysql-test/suite/ndb/r/ndb_types.result new file mode 100644 index 00000000000..ec2858d818a --- /dev/null +++ b/mysql-test/suite/ndb/r/ndb_types.result @@ -0,0 +1,76 @@ +DROP TABLE IF EXISTS t1; +CREATE TABLE t1 ( +auto int(5) unsigned NOT NULL auto_increment, +string char(10) default "hello", +vstring varchar(10) default "hello", +bin binary(2), +vbin varbinary(7), +tiny tinyint(4) DEFAULT '0' NOT NULL , +short smallint(6) DEFAULT '1' NOT NULL , +medium mediumint(8) DEFAULT '0' NOT NULL, +long_int int(11) DEFAULT '0' NOT NULL, +longlong bigint(13) DEFAULT '0' NOT NULL, +real_float float(13,1) DEFAULT 0.0 NOT NULL, +real_double double(16,4), +real_decimal decimal(16,4), +utiny tinyint(3) unsigned DEFAULT '0' NOT NULL, +ushort smallint(5) unsigned zerofill DEFAULT '00000' NOT NULL, +umedium mediumint(8) unsigned DEFAULT '0' NOT NULL, +ulong int(11) unsigned DEFAULT '0' NOT NULL, +ulonglong bigint(13) unsigned DEFAULT '0' NOT NULL, +bits bit(3), +options enum('one','two','tree') not null, +flags set('one','two','tree') not null, +date_field date, +year_field year, +time_field time, +date_time datetime, +time_stamp timestamp not null default CURRENT_TIMESTAMP on update CURRENT_TIMESTAMP, +PRIMARY KEY (auto), +KEY (utiny), +KEY (tiny), +KEY (short), +KEY any_name (medium), +KEY (longlong), +KEY (real_float), +KEY (ushort), +KEY (umedium), +KEY (ulong), +KEY (ulonglong,ulong), +KEY (options,flags) +); +set @now = now(); +insert into t1 +(string,vstring,bin,vbin,tiny,short,medium,long_int,longlong, +real_float,real_double, real_decimal,utiny, ushort, umedium,ulong,ulonglong, +bits,options,flags,date_field,year_field,time_field,date_time) +values +("aaaa","aaaa",0xAAAA,0xAAAA,-1,-1,-1,-1,-1,1.1,1.1,1.1,1,1,1,1,1, +b'001','one','one', '1901-01-01','1901','01:01:01','1901-01-01 01:01:01'); +select auto,string,vstring,bin,vbin,tiny,short,medium,long_int,longlong, +real_float,real_double,real_decimal,utiny,ushort,umedium,ulong,ulonglong, +bits,options,flags,date_field,year_field,time_field,date_time +from t1; +auto string vstring bin vbin tiny short medium long_int longlong real_float real_double real_decimal utiny ushort umedium ulong ulonglong bits options flags date_field year_field time_field date_time +1 aaaa aaaa ªª ªª -1 -1 -1 -1 -1 1.1 1.1000 1.1000 1 00001 1 1 1 one one 1901-01-01 1901 01:01:01 1901-01-01 01:01:01 +select time_stamp>@now from t1; +time_stamp>@now +1 +set @now = now(); +update t1 set string="bbbb",vstring="bbbb",bin=0xBBBB,vbin=0xBBBB, +tiny=-2,short=-2,medium=-2,long_int=-2,longlong=-2,real_float=2.2, +real_double=2.2,real_decimal=2.2,utiny=2,ushort=2,umedium=2,ulong=2, +ulonglong=2, bits=b'010', +options='one',flags='one', date_field='1902-02-02',year_field='1902', +time_field='02:02:02',date_time='1902-02-02 02:02:02' where auto=1; +select auto,string,vstring,bin,vbin,tiny,short,medium,long_int,longlong, +real_float,real_double,real_decimal,utiny,ushort,umedium,ulong,ulonglong, +bits,options,flags,date_field,year_field,time_field,date_time +from t1; +auto string vstring bin vbin tiny short medium long_int longlong real_float real_double real_decimal utiny ushort umedium ulong ulonglong bits options flags date_field year_field time_field date_time +1 bbbb bbbb »» »» -2 -2 -2 -2 -2 2.2 2.2000 2.2000 2 00002 2 2 2 one one 1902-02-02 1902 02:02:02 1902-02-02 02:02:02 +select time_stamp>@now from t1; +time_stamp>@now +1 +drop table t1; +End of 4.1 tests diff --git a/mysql-test/suite/ndb/r/ndb_update.result b/mysql-test/suite/ndb/r/ndb_update.result new file mode 100644 index 00000000000..daea0e27a6a --- /dev/null +++ b/mysql-test/suite/ndb/r/ndb_update.result @@ -0,0 +1,88 @@ +DROP TABLE IF EXISTS t1; +DROP TABLE IF EXISTS t2; +DROP TABLE IF EXISTS t3; +CREATE TABLE t1 ( +pk1 INT NOT NULL PRIMARY KEY, +b INT NOT NULL, +c INT NOT NULL UNIQUE +) ENGINE=ndbcluster; +INSERT INTO t1 VALUES (0, 1, 0),(1,2,1),(2,3,2); +UPDATE t1 set b = c; +select * from t1 order by pk1; +pk1 b c +0 0 0 +1 1 1 +2 2 2 +UPDATE t1 set pk1 = 4 where pk1 = 1; +select * from t1 order by pk1; +pk1 b c +0 0 0 +2 2 2 +4 1 1 +UPDATE t1 set pk1 = 4 where pk1 = 2; +ERROR 23000: Duplicate entry '4' for key 'PRIMARY' +UPDATE IGNORE t1 set pk1 = 4 where pk1 = 2; +select * from t1 order by pk1; +pk1 b c +0 0 0 +2 2 2 +4 1 1 +UPDATE t1 set pk1 = 1, c = 2 where pk1 = 4; +ERROR 23000: Duplicate entry '' for key '*UNKNOWN*' +UPDATE IGNORE t1 set pk1 = 1, c = 2 where pk1 = 4; +select * from t1 order by pk1; +pk1 b c +0 0 0 +2 2 2 +4 1 1 +UPDATE t1 set pk1 = pk1 + 10; +select * from t1 order by pk1; +pk1 b c +10 0 0 +12 2 2 +14 1 1 +DROP TABLE IF EXISTS t1; +CREATE TABLE t1 (a int, b int, KEY (a, b)) ENGINE=ndbcluster; +CREATE TABLE t2 (a int, b int, UNIQUE KEY (a, b)) ENGINE=ndbcluster; +CREATE TABLE t3 (a int, b int, PRIMARY KEY (a, b)) ENGINE=ndbcluster; +INSERT INTO t1 VALUES (1, 2); +INSERT INTO t1 VALUES (2, 2); +INSERT INTO t2 VALUES (1, 2); +INSERT INTO t2 VALUES (2, 2); +INSERT INTO t3 VALUES (1, 2); +INSERT INTO t3 VALUES (2, 2); +UPDATE t1 SET a = 1; +UPDATE t1 SET a = 1 ORDER BY a; +UPDATE t2 SET a = 1; +ERROR 23000: Duplicate entry '' for key '*UNKNOWN*' +UPDATE t2 SET a = 1 ORDER BY a; +ERROR 23000: Duplicate entry '' for key '*UNKNOWN*' +UPDATE t3 SET a = 1; +ERROR 23000: Duplicate entry '1-2' for key 'PRIMARY' +UPDATE t3 SET a = 1 ORDER BY a; +ERROR 23000: Duplicate entry '1-2' for key 'PRIMARY' +SELECT count(*) FROM t1; +count(*) +2 +SELECT count(*) FROM t2; +count(*) +2 +SELECT count(*) FROM t3; +count(*) +2 +SELECT * FROM t1 ORDER by a; +a b +1 2 +1 2 +SELECT * FROM t2 ORDER by a; +a b +1 2 +2 2 +SELECT * FROM t3 ORDER by a; +a b +1 2 +2 2 +DROP TABLE IF EXISTS t1; +DROP TABLE IF EXISTS t2; +DROP TABLE IF EXISTS t3; +End of 5.1 tests diff --git a/mysql-test/suite/ndb/r/ndb_view.result b/mysql-test/suite/ndb/r/ndb_view.result new file mode 100644 index 00000000000..b7d1b6860c8 --- /dev/null +++ b/mysql-test/suite/ndb/r/ndb_view.result @@ -0,0 +1,24 @@ +DROP TABLE IF EXISTS t1,t2,t3; +DROP VIEW IF EXISTS v1,v2,v3; +create table t1 (a int, b int, c int, d int) engine=ndb; +insert into t1 values (1,2,3,4),(5,6,7,8); +create view v1 as select t1.c as a, t1.a as b, t1.d as c, t1.a+t1.b+t1.c as d from t1; +select * from v1 order by a,b,c; +a b c d +3 1 4 6 +7 5 8 18 +update v1 set a=a+100 where b=1; +select * from v1 order by a,b,c; +a b c d +7 5 8 18 +103 1 4 106 +drop view v1; +create view v1 as select t1.c as a from t1; +insert into v1 values (200); +select * from t1 order by a,b,c,d; +a b c d +NULL NULL 200 NULL +1 2 103 4 +5 6 7 8 +drop view v1; +drop table t1; diff --git a/mysql-test/suite/ndb/r/ndbapi.result b/mysql-test/suite/ndb/r/ndbapi.result new file mode 100644 index 00000000000..8e680391a81 --- /dev/null +++ b/mysql-test/suite/ndb/r/ndbapi.result @@ -0,0 +1,22 @@ +DROP TABLE IF EXISTS t0; +drop database if exists mysqltest; +Running ndbapi_simple +Running ndbapi_simple_index +Running ndbapi_scan +Running ndbapi_retries +Running ndbapi_async +Running ndbapi_async1 +use TEST_DB; +create table t0(c0 int, c1 int, c2 char(4), c3 char(4), c4 text, +primary key(c0, c2)) engine ndb charset latin1; +insert into t0 values (1, 2, 'a', 'b', null); +insert into t0 values (3, 4, 'c', 'd', null); +update t0 set c3 = 'e' where c0 = 1 and c2 = 'a'; +update t0 set c3 = 'f'; +update t0 set c3 = 'F'; +update t0 set c2 = 'g' where c0 = 1; +update t0 set c2 = 'G' where c0 = 1; +update t0 set c0 = 5, c2 = 'H' where c0 = 3; +delete from t0; +drop table t0; +Running mgmapi_logevent diff --git a/mysql-test/suite/ndb/r/partition_03ndb.result b/mysql-test/suite/ndb/r/partition_03ndb.result new file mode 100644 index 00000000000..28339cc7435 --- /dev/null +++ b/mysql-test/suite/ndb/r/partition_03ndb.result @@ -0,0 +1,1361 @@ +SET SESSION storage_engine='NDB' ; +SET @max_row = 200; +SET AUTOCOMMIT= 1; +#------------------------------------------------------------------------ +# 0. Creation of an auxiliary table needed in all testcases +#------------------------------------------------------------------------ +DROP TABLE IF EXISTS t0_template; +CREATE TABLE t0_template ( f1 INTEGER, f2 char(20), PRIMARY KEY(f1)) +ENGINE = MEMORY; +# Logging of 200 INSERTs into t0_template suppressed +#------------------------------------------------------------------------ +# 1. Some syntax checks +#------------------------------------------------------------------------ +# 1.1 Subpartioned table without subpartitioning rule must be rejected +DROP TABLE IF EXISTS t1; +#------------------------------------------------------------------------ +# 2. Checks where the engine is set on all supported CREATE TABLE +# statement positions + basic operations on the tables +#------------------------------------------------------------------------ +DROP TABLE IF EXISTS t1; +# 2.1 table (non partitioned) for comparison +CREATE TABLE t1 ( f1 INTEGER, f2 char(20)) ENGINE = 'NDB' ; +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `f1` int(11) default NULL, + `f2` char(20) default NULL +) ENGINE=ndbcluster DEFAULT CHARSET=latin1 PARTITION BY KEY () +SELECT COUNT(*) = 0 AS my_value FROM t1; +my_value +1 +INSERT INTO t1 SELECT * FROM t0_template WHERE f1 BETWEEN 1 AND 200; +SELECT (COUNT(*) = 200) AND (MIN(f1) = 1) AND (MAX(f1) = 200) +AS my_value FROM t1; +my_value +1 +UPDATE t1 SET f1 = f1 + 200 +WHERE f1 BETWEEN 100 - 50 AND 100 + 50; +SELECT (COUNT(*) = 200) AND (MIN(f1) = 1) AND (MAX(f1) = 100 + 50 + 200 ) +AS my_value FROM t1; +my_value +1 +DELETE FROM t1 +WHERE f1 BETWEEN 100 - 50 + 200 AND 100 + 50 + 200; +SELECT (COUNT(*) = 200 - 50 - 50 - 1) AND (MIN(f1) = 1) AND (MAX(f1) = 200) +AS my_value FROM t1; +my_value +1 +INSERT INTO t1 SET f1 = 0 , f2 = '#######'; +SELECT COUNT(*) = 1 AS my_value FROM t1 WHERE f1 = 0 AND f2 = '#######'; +my_value +1 +INSERT INTO t1 SET f1 = 200 + 1, f2 = '#######'; +SELECT COUNT(*) = 1 AS my_value FROM t1 WHERE f1 = 200 + 1 AND f2 = '#######'; +my_value +1 +UPDATE t1 SET f1 = 200 + 2, f2 = 'ZZZZZZZ' + WHERE f1 = 0 AND f2 = '#######'; +SELECT COUNT(*) = 1 AS my_value FROM t1 WHERE f1 = 200 + 2 AND f2 = 'ZZZZZZZ'; +my_value +1 +DELETE FROM t1 WHERE f1 = 200 + 2 AND f2 = 'ZZZZZZZ'; +SELECT COUNT(*) = 0 AS my_value FROM t1 WHERE f2 = 'ZZZZZZZ'; +my_value +1 +TRUNCATE t1; +SELECT COUNT(*) = 0 AS my_value FROM t1; +my_value +1 +DROP TABLE t1; +# 2.2 table with engine setting just after column list +CREATE TABLE t1 ( f1 INTEGER, f2 char(20)) ENGINE = 'NDB' +PARTITION BY HASH(f1) PARTITIONS 2; +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `f1` int(11) default NULL, + `f2` char(20) default NULL +) ENGINE=ndbcluster DEFAULT CHARSET=latin1 PARTITION BY HASH (f1) PARTITIONS 2 +SELECT COUNT(*) = 0 AS my_value FROM t1; +my_value +1 +INSERT INTO t1 SELECT * FROM t0_template WHERE f1 BETWEEN 1 AND 200; +SELECT (COUNT(*) = 200) AND (MIN(f1) = 1) AND (MAX(f1) = 200) +AS my_value FROM t1; +my_value +1 +UPDATE t1 SET f1 = f1 + 200 +WHERE f1 BETWEEN 100 - 50 AND 100 + 50; +SELECT (COUNT(*) = 200) AND (MIN(f1) = 1) AND (MAX(f1) = 100 + 50 + 200 ) +AS my_value FROM t1; +my_value +1 +DELETE FROM t1 +WHERE f1 BETWEEN 100 - 50 + 200 AND 100 + 50 + 200; +SELECT (COUNT(*) = 200 - 50 - 50 - 1) AND (MIN(f1) = 1) AND (MAX(f1) = 200) +AS my_value FROM t1; +my_value +1 +INSERT INTO t1 SET f1 = 0 , f2 = '#######'; +SELECT COUNT(*) = 1 AS my_value FROM t1 WHERE f1 = 0 AND f2 = '#######'; +my_value +1 +INSERT INTO t1 SET f1 = 200 + 1, f2 = '#######'; +SELECT COUNT(*) = 1 AS my_value FROM t1 WHERE f1 = 200 + 1 AND f2 = '#######'; +my_value +1 +UPDATE t1 SET f1 = 200 + 2, f2 = 'ZZZZZZZ' + WHERE f1 = 0 AND f2 = '#######'; +SELECT COUNT(*) = 1 AS my_value FROM t1 WHERE f1 = 200 + 2 AND f2 = 'ZZZZZZZ'; +my_value +1 +DELETE FROM t1 WHERE f1 = 200 + 2 AND f2 = 'ZZZZZZZ'; +SELECT COUNT(*) = 0 AS my_value FROM t1 WHERE f2 = 'ZZZZZZZ'; +my_value +1 +TRUNCATE t1; +SELECT COUNT(*) = 0 AS my_value FROM t1; +my_value +1 +DROP TABLE t1; +# 2.3 table with engine setting in the named partition part +CREATE TABLE t1 ( f1 INTEGER, f2 char(20)) +PARTITION BY HASH(f1) +( PARTITION part1 STORAGE ENGINE = 'NDB' , +PARTITION part2 STORAGE ENGINE = 'NDB' +); +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `f1` int(11) default NULL, + `f2` char(20) default NULL +) ENGINE=ndbcluster DEFAULT CHARSET=latin1 PARTITION BY HASH (f1) (PARTITION part1 ENGINE = ndbcluster, PARTITION part2 ENGINE = ndbcluster) +SELECT COUNT(*) = 0 AS my_value FROM t1; +my_value +1 +INSERT INTO t1 SELECT * FROM t0_template WHERE f1 BETWEEN 1 AND 200; +SELECT (COUNT(*) = 200) AND (MIN(f1) = 1) AND (MAX(f1) = 200) +AS my_value FROM t1; +my_value +1 +UPDATE t1 SET f1 = f1 + 200 +WHERE f1 BETWEEN 100 - 50 AND 100 + 50; +SELECT (COUNT(*) = 200) AND (MIN(f1) = 1) AND (MAX(f1) = 100 + 50 + 200 ) +AS my_value FROM t1; +my_value +1 +DELETE FROM t1 +WHERE f1 BETWEEN 100 - 50 + 200 AND 100 + 50 + 200; +SELECT (COUNT(*) = 200 - 50 - 50 - 1) AND (MIN(f1) = 1) AND (MAX(f1) = 200) +AS my_value FROM t1; +my_value +1 +INSERT INTO t1 SET f1 = 0 , f2 = '#######'; +SELECT COUNT(*) = 1 AS my_value FROM t1 WHERE f1 = 0 AND f2 = '#######'; +my_value +1 +INSERT INTO t1 SET f1 = 200 + 1, f2 = '#######'; +SELECT COUNT(*) = 1 AS my_value FROM t1 WHERE f1 = 200 + 1 AND f2 = '#######'; +my_value +1 +UPDATE t1 SET f1 = 200 + 2, f2 = 'ZZZZZZZ' + WHERE f1 = 0 AND f2 = '#######'; +SELECT COUNT(*) = 1 AS my_value FROM t1 WHERE f1 = 200 + 2 AND f2 = 'ZZZZZZZ'; +my_value +1 +DELETE FROM t1 WHERE f1 = 200 + 2 AND f2 = 'ZZZZZZZ'; +SELECT COUNT(*) = 0 AS my_value FROM t1 WHERE f2 = 'ZZZZZZZ'; +my_value +1 +TRUNCATE t1; +SELECT COUNT(*) = 0 AS my_value FROM t1; +my_value +1 +DROP TABLE t1; +# 2.4 table with engine setting in the named subpartition part +CREATE TABLE t1 ( f1 INTEGER, f2 char(20)) +PARTITION BY RANGE(f1) +SUBPARTITION BY HASH(f1) +( PARTITION part1 VALUES LESS THAN (1000) +(SUBPARTITION subpart11 STORAGE ENGINE = 'NDB' , +SUBPARTITION subpart12 STORAGE ENGINE = 'NDB' ), +PARTITION part2 VALUES LESS THAN (2000) +(SUBPARTITION subpart21 STORAGE ENGINE = 'NDB' , +SUBPARTITION subpart22 STORAGE ENGINE = 'NDB' ) +); +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `f1` int(11) default NULL, + `f2` char(20) default NULL +) ENGINE=ndbcluster DEFAULT CHARSET=latin1 PARTITION BY RANGE (f1) SUBPARTITION BY HASH (f1) (PARTITION part1 VALUES LESS THAN (1000) (SUBPARTITION subpart11 ENGINE = ndbcluster, SUBPARTITION subpart12 ENGINE = ndbcluster), PARTITION part2 VALUES LESS THAN (2000) (SUBPARTITION subpart21 ENGINE = ndbcluster, SUBPARTITION subpart22 ENGINE = ndbcluster)) +SELECT COUNT(*) = 0 AS my_value FROM t1; +my_value +1 +INSERT INTO t1 SELECT * FROM t0_template WHERE f1 BETWEEN 1 AND 200; +SELECT (COUNT(*) = 200) AND (MIN(f1) = 1) AND (MAX(f1) = 200) +AS my_value FROM t1; +my_value +1 +UPDATE t1 SET f1 = f1 + 200 +WHERE f1 BETWEEN 100 - 50 AND 100 + 50; +SELECT (COUNT(*) = 200) AND (MIN(f1) = 1) AND (MAX(f1) = 100 + 50 + 200 ) +AS my_value FROM t1; +my_value +1 +DELETE FROM t1 +WHERE f1 BETWEEN 100 - 50 + 200 AND 100 + 50 + 200; +SELECT (COUNT(*) = 200 - 50 - 50 - 1) AND (MIN(f1) = 1) AND (MAX(f1) = 200) +AS my_value FROM t1; +my_value +1 +INSERT INTO t1 SET f1 = 0 , f2 = '#######'; +SELECT COUNT(*) = 1 AS my_value FROM t1 WHERE f1 = 0 AND f2 = '#######'; +my_value +1 +INSERT INTO t1 SET f1 = 200 + 1, f2 = '#######'; +SELECT COUNT(*) = 1 AS my_value FROM t1 WHERE f1 = 200 + 1 AND f2 = '#######'; +my_value +1 +UPDATE t1 SET f1 = 200 + 2, f2 = 'ZZZZZZZ' + WHERE f1 = 0 AND f2 = '#######'; +SELECT COUNT(*) = 1 AS my_value FROM t1 WHERE f1 = 200 + 2 AND f2 = 'ZZZZZZZ'; +my_value +1 +DELETE FROM t1 WHERE f1 = 200 + 2 AND f2 = 'ZZZZZZZ'; +SELECT COUNT(*) = 0 AS my_value FROM t1 WHERE f2 = 'ZZZZZZZ'; +my_value +1 +TRUNCATE t1; +SELECT COUNT(*) = 0 AS my_value FROM t1; +my_value +1 +DROP TABLE t1; +# 2.5 Ugly "incomplete" storage engine assignments +CREATE TABLE t1 ( f1 INTEGER, f2 char(20)) +PARTITION BY HASH(f1) +( PARTITION part1 STORAGE ENGINE = 'NDB' , +PARTITION part2 +); +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `f1` int(11) default NULL, + `f2` char(20) default NULL +) ENGINE=ndbcluster DEFAULT CHARSET=latin1 PARTITION BY HASH (f1) (PARTITION part1 ENGINE = ndbcluster, PARTITION part2 ENGINE = ndbcluster) +SELECT COUNT(*) = 0 AS my_value FROM t1; +my_value +1 +INSERT INTO t1 SELECT * FROM t0_template WHERE f1 BETWEEN 1 AND 200; +SELECT (COUNT(*) = 200) AND (MIN(f1) = 1) AND (MAX(f1) = 200) +AS my_value FROM t1; +my_value +1 +UPDATE t1 SET f1 = f1 + 200 +WHERE f1 BETWEEN 100 - 50 AND 100 + 50; +SELECT (COUNT(*) = 200) AND (MIN(f1) = 1) AND (MAX(f1) = 100 + 50 + 200 ) +AS my_value FROM t1; +my_value +1 +DELETE FROM t1 +WHERE f1 BETWEEN 100 - 50 + 200 AND 100 + 50 + 200; +SELECT (COUNT(*) = 200 - 50 - 50 - 1) AND (MIN(f1) = 1) AND (MAX(f1) = 200) +AS my_value FROM t1; +my_value +1 +INSERT INTO t1 SET f1 = 0 , f2 = '#######'; +SELECT COUNT(*) = 1 AS my_value FROM t1 WHERE f1 = 0 AND f2 = '#######'; +my_value +1 +INSERT INTO t1 SET f1 = 200 + 1, f2 = '#######'; +SELECT COUNT(*) = 1 AS my_value FROM t1 WHERE f1 = 200 + 1 AND f2 = '#######'; +my_value +1 +UPDATE t1 SET f1 = 200 + 2, f2 = 'ZZZZZZZ' + WHERE f1 = 0 AND f2 = '#######'; +SELECT COUNT(*) = 1 AS my_value FROM t1 WHERE f1 = 200 + 2 AND f2 = 'ZZZZZZZ'; +my_value +1 +DELETE FROM t1 WHERE f1 = 200 + 2 AND f2 = 'ZZZZZZZ'; +SELECT COUNT(*) = 0 AS my_value FROM t1 WHERE f2 = 'ZZZZZZZ'; +my_value +1 +TRUNCATE t1; +SELECT COUNT(*) = 0 AS my_value FROM t1; +my_value +1 +DROP TABLE t1; +CREATE TABLE t1 ( f1 INTEGER, f2 char(20)) +PARTITION BY HASH(f1) +( PARTITION part1 , +PARTITION part2 STORAGE ENGINE = 'NDB' +); +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `f1` int(11) default NULL, + `f2` char(20) default NULL +) ENGINE=ndbcluster DEFAULT CHARSET=latin1 PARTITION BY HASH (f1) (PARTITION part1 ENGINE = ndbcluster, PARTITION part2 ENGINE = ndbcluster) +SELECT COUNT(*) = 0 AS my_value FROM t1; +my_value +1 +INSERT INTO t1 SELECT * FROM t0_template WHERE f1 BETWEEN 1 AND 200; +SELECT (COUNT(*) = 200) AND (MIN(f1) = 1) AND (MAX(f1) = 200) +AS my_value FROM t1; +my_value +1 +UPDATE t1 SET f1 = f1 + 200 +WHERE f1 BETWEEN 100 - 50 AND 100 + 50; +SELECT (COUNT(*) = 200) AND (MIN(f1) = 1) AND (MAX(f1) = 100 + 50 + 200 ) +AS my_value FROM t1; +my_value +1 +DELETE FROM t1 +WHERE f1 BETWEEN 100 - 50 + 200 AND 100 + 50 + 200; +SELECT (COUNT(*) = 200 - 50 - 50 - 1) AND (MIN(f1) = 1) AND (MAX(f1) = 200) +AS my_value FROM t1; +my_value +1 +INSERT INTO t1 SET f1 = 0 , f2 = '#######'; +SELECT COUNT(*) = 1 AS my_value FROM t1 WHERE f1 = 0 AND f2 = '#######'; +my_value +1 +INSERT INTO t1 SET f1 = 200 + 1, f2 = '#######'; +SELECT COUNT(*) = 1 AS my_value FROM t1 WHERE f1 = 200 + 1 AND f2 = '#######'; +my_value +1 +UPDATE t1 SET f1 = 200 + 2, f2 = 'ZZZZZZZ' + WHERE f1 = 0 AND f2 = '#######'; +SELECT COUNT(*) = 1 AS my_value FROM t1 WHERE f1 = 200 + 2 AND f2 = 'ZZZZZZZ'; +my_value +1 +DELETE FROM t1 WHERE f1 = 200 + 2 AND f2 = 'ZZZZZZZ'; +SELECT COUNT(*) = 0 AS my_value FROM t1 WHERE f2 = 'ZZZZZZZ'; +my_value +1 +TRUNCATE t1; +SELECT COUNT(*) = 0 AS my_value FROM t1; +my_value +1 +DROP TABLE t1; +CREATE TABLE t1 ( f1 INTEGER, f2 char(20)) +PARTITION BY RANGE(f1) +SUBPARTITION BY HASH(f1) +( PARTITION part1 VALUES LESS THAN (1000) +(SUBPARTITION subpart11, +SUBPARTITION subpart12 STORAGE ENGINE = 'NDB' ), +PARTITION part2 VALUES LESS THAN (2000) +(SUBPARTITION subpart21 STORAGE ENGINE = 'NDB' , +SUBPARTITION subpart22 STORAGE ENGINE = 'NDB' ) +); +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `f1` int(11) default NULL, + `f2` char(20) default NULL +) ENGINE=ndbcluster DEFAULT CHARSET=latin1 PARTITION BY RANGE (f1) SUBPARTITION BY HASH (f1) (PARTITION part1 VALUES LESS THAN (1000) (SUBPARTITION subpart11 ENGINE = ndbcluster, SUBPARTITION subpart12 ENGINE = ndbcluster), PARTITION part2 VALUES LESS THAN (2000) (SUBPARTITION subpart21 ENGINE = ndbcluster, SUBPARTITION subpart22 ENGINE = ndbcluster)) +SELECT COUNT(*) = 0 AS my_value FROM t1; +my_value +1 +INSERT INTO t1 SELECT * FROM t0_template WHERE f1 BETWEEN 1 AND 200; +SELECT (COUNT(*) = 200) AND (MIN(f1) = 1) AND (MAX(f1) = 200) +AS my_value FROM t1; +my_value +1 +UPDATE t1 SET f1 = f1 + 200 +WHERE f1 BETWEEN 100 - 50 AND 100 + 50; +SELECT (COUNT(*) = 200) AND (MIN(f1) = 1) AND (MAX(f1) = 100 + 50 + 200 ) +AS my_value FROM t1; +my_value +1 +DELETE FROM t1 +WHERE f1 BETWEEN 100 - 50 + 200 AND 100 + 50 + 200; +SELECT (COUNT(*) = 200 - 50 - 50 - 1) AND (MIN(f1) = 1) AND (MAX(f1) = 200) +AS my_value FROM t1; +my_value +1 +INSERT INTO t1 SET f1 = 0 , f2 = '#######'; +SELECT COUNT(*) = 1 AS my_value FROM t1 WHERE f1 = 0 AND f2 = '#######'; +my_value +1 +INSERT INTO t1 SET f1 = 200 + 1, f2 = '#######'; +SELECT COUNT(*) = 1 AS my_value FROM t1 WHERE f1 = 200 + 1 AND f2 = '#######'; +my_value +1 +UPDATE t1 SET f1 = 200 + 2, f2 = 'ZZZZZZZ' + WHERE f1 = 0 AND f2 = '#######'; +SELECT COUNT(*) = 1 AS my_value FROM t1 WHERE f1 = 200 + 2 AND f2 = 'ZZZZZZZ'; +my_value +1 +DELETE FROM t1 WHERE f1 = 200 + 2 AND f2 = 'ZZZZZZZ'; +SELECT COUNT(*) = 0 AS my_value FROM t1 WHERE f2 = 'ZZZZZZZ'; +my_value +1 +TRUNCATE t1; +SELECT COUNT(*) = 0 AS my_value FROM t1; +my_value +1 +DROP TABLE t1; +CREATE TABLE t1 ( f1 INTEGER, f2 char(20)) +PARTITION BY RANGE(f1) +SUBPARTITION BY HASH(f1) +( PARTITION part1 VALUES LESS THAN (1000) +(SUBPARTITION subpart11 STORAGE ENGINE = 'NDB' , +SUBPARTITION subpart12 STORAGE ENGINE = 'NDB' ), +PARTITION part2 VALUES LESS THAN (2000) +(SUBPARTITION subpart21 , +SUBPARTITION subpart22 ) +); +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `f1` int(11) default NULL, + `f2` char(20) default NULL +) ENGINE=ndbcluster DEFAULT CHARSET=latin1 PARTITION BY RANGE (f1) SUBPARTITION BY HASH (f1) (PARTITION part1 VALUES LESS THAN (1000) (SUBPARTITION subpart11 ENGINE = ndbcluster, SUBPARTITION subpart12 ENGINE = ndbcluster), PARTITION part2 VALUES LESS THAN (2000) (SUBPARTITION subpart21 ENGINE = ndbcluster, SUBPARTITION subpart22 ENGINE = ndbcluster)) +SELECT COUNT(*) = 0 AS my_value FROM t1; +my_value +1 +INSERT INTO t1 SELECT * FROM t0_template WHERE f1 BETWEEN 1 AND 200; +SELECT (COUNT(*) = 200) AND (MIN(f1) = 1) AND (MAX(f1) = 200) +AS my_value FROM t1; +my_value +1 +UPDATE t1 SET f1 = f1 + 200 +WHERE f1 BETWEEN 100 - 50 AND 100 + 50; +SELECT (COUNT(*) = 200) AND (MIN(f1) = 1) AND (MAX(f1) = 100 + 50 + 200 ) +AS my_value FROM t1; +my_value +1 +DELETE FROM t1 +WHERE f1 BETWEEN 100 - 50 + 200 AND 100 + 50 + 200; +SELECT (COUNT(*) = 200 - 50 - 50 - 1) AND (MIN(f1) = 1) AND (MAX(f1) = 200) +AS my_value FROM t1; +my_value +1 +INSERT INTO t1 SET f1 = 0 , f2 = '#######'; +SELECT COUNT(*) = 1 AS my_value FROM t1 WHERE f1 = 0 AND f2 = '#######'; +my_value +1 +INSERT INTO t1 SET f1 = 200 + 1, f2 = '#######'; +SELECT COUNT(*) = 1 AS my_value FROM t1 WHERE f1 = 200 + 1 AND f2 = '#######'; +my_value +1 +UPDATE t1 SET f1 = 200 + 2, f2 = 'ZZZZZZZ' + WHERE f1 = 0 AND f2 = '#######'; +SELECT COUNT(*) = 1 AS my_value FROM t1 WHERE f1 = 200 + 2 AND f2 = 'ZZZZZZZ'; +my_value +1 +DELETE FROM t1 WHERE f1 = 200 + 2 AND f2 = 'ZZZZZZZ'; +SELECT COUNT(*) = 0 AS my_value FROM t1 WHERE f2 = 'ZZZZZZZ'; +my_value +1 +TRUNCATE t1; +SELECT COUNT(*) = 0 AS my_value FROM t1; +my_value +1 +DROP TABLE t1; +# 2.6 Ugly "over determined" storage engine assignments +CREATE TABLE t1 ( f1 INTEGER, f2 char(20)) ENGINE = 'NDB' +PARTITION BY HASH(f1) +( PARTITION part1 STORAGE ENGINE = 'NDB' , +PARTITION part2 STORAGE ENGINE = 'NDB' +); +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `f1` int(11) default NULL, + `f2` char(20) default NULL +) ENGINE=ndbcluster DEFAULT CHARSET=latin1 PARTITION BY HASH (f1) (PARTITION part1 ENGINE = ndbcluster, PARTITION part2 ENGINE = ndbcluster) +SELECT COUNT(*) = 0 AS my_value FROM t1; +my_value +1 +INSERT INTO t1 SELECT * FROM t0_template WHERE f1 BETWEEN 1 AND 200; +SELECT (COUNT(*) = 200) AND (MIN(f1) = 1) AND (MAX(f1) = 200) +AS my_value FROM t1; +my_value +1 +UPDATE t1 SET f1 = f1 + 200 +WHERE f1 BETWEEN 100 - 50 AND 100 + 50; +SELECT (COUNT(*) = 200) AND (MIN(f1) = 1) AND (MAX(f1) = 100 + 50 + 200 ) +AS my_value FROM t1; +my_value +1 +DELETE FROM t1 +WHERE f1 BETWEEN 100 - 50 + 200 AND 100 + 50 + 200; +SELECT (COUNT(*) = 200 - 50 - 50 - 1) AND (MIN(f1) = 1) AND (MAX(f1) = 200) +AS my_value FROM t1; +my_value +1 +INSERT INTO t1 SET f1 = 0 , f2 = '#######'; +SELECT COUNT(*) = 1 AS my_value FROM t1 WHERE f1 = 0 AND f2 = '#######'; +my_value +1 +INSERT INTO t1 SET f1 = 200 + 1, f2 = '#######'; +SELECT COUNT(*) = 1 AS my_value FROM t1 WHERE f1 = 200 + 1 AND f2 = '#######'; +my_value +1 +UPDATE t1 SET f1 = 200 + 2, f2 = 'ZZZZZZZ' + WHERE f1 = 0 AND f2 = '#######'; +SELECT COUNT(*) = 1 AS my_value FROM t1 WHERE f1 = 200 + 2 AND f2 = 'ZZZZZZZ'; +my_value +1 +DELETE FROM t1 WHERE f1 = 200 + 2 AND f2 = 'ZZZZZZZ'; +SELECT COUNT(*) = 0 AS my_value FROM t1 WHERE f2 = 'ZZZZZZZ'; +my_value +1 +TRUNCATE t1; +SELECT COUNT(*) = 0 AS my_value FROM t1; +my_value +1 +DROP TABLE t1; +CREATE TABLE t1 ( f1 INTEGER, f2 char(20)) ENGINE = 'NDB' +PARTITION BY RANGE(f1) +SUBPARTITION BY HASH(f1) +( PARTITION part1 VALUES LESS THAN (1000) +(SUBPARTITION subpart11 STORAGE ENGINE = 'NDB' , +SUBPARTITION subpart12 STORAGE ENGINE = 'NDB' ), +PARTITION part2 VALUES LESS THAN (2000) +(SUBPARTITION subpart21 STORAGE ENGINE = 'NDB' , +SUBPARTITION subpart22 STORAGE ENGINE = 'NDB' ) +); +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `f1` int(11) default NULL, + `f2` char(20) default NULL +) ENGINE=ndbcluster DEFAULT CHARSET=latin1 PARTITION BY RANGE (f1) SUBPARTITION BY HASH (f1) (PARTITION part1 VALUES LESS THAN (1000) (SUBPARTITION subpart11 ENGINE = ndbcluster, SUBPARTITION subpart12 ENGINE = ndbcluster), PARTITION part2 VALUES LESS THAN (2000) (SUBPARTITION subpart21 ENGINE = ndbcluster, SUBPARTITION subpart22 ENGINE = ndbcluster)) +SELECT COUNT(*) = 0 AS my_value FROM t1; +my_value +1 +INSERT INTO t1 SELECT * FROM t0_template WHERE f1 BETWEEN 1 AND 200; +SELECT (COUNT(*) = 200) AND (MIN(f1) = 1) AND (MAX(f1) = 200) +AS my_value FROM t1; +my_value +1 +UPDATE t1 SET f1 = f1 + 200 +WHERE f1 BETWEEN 100 - 50 AND 100 + 50; +SELECT (COUNT(*) = 200) AND (MIN(f1) = 1) AND (MAX(f1) = 100 + 50 + 200 ) +AS my_value FROM t1; +my_value +1 +DELETE FROM t1 +WHERE f1 BETWEEN 100 - 50 + 200 AND 100 + 50 + 200; +SELECT (COUNT(*) = 200 - 50 - 50 - 1) AND (MIN(f1) = 1) AND (MAX(f1) = 200) +AS my_value FROM t1; +my_value +1 +INSERT INTO t1 SET f1 = 0 , f2 = '#######'; +SELECT COUNT(*) = 1 AS my_value FROM t1 WHERE f1 = 0 AND f2 = '#######'; +my_value +1 +INSERT INTO t1 SET f1 = 200 + 1, f2 = '#######'; +SELECT COUNT(*) = 1 AS my_value FROM t1 WHERE f1 = 200 + 1 AND f2 = '#######'; +my_value +1 +UPDATE t1 SET f1 = 200 + 2, f2 = 'ZZZZZZZ' + WHERE f1 = 0 AND f2 = '#######'; +SELECT COUNT(*) = 1 AS my_value FROM t1 WHERE f1 = 200 + 2 AND f2 = 'ZZZZZZZ'; +my_value +1 +DELETE FROM t1 WHERE f1 = 200 + 2 AND f2 = 'ZZZZZZZ'; +SELECT COUNT(*) = 0 AS my_value FROM t1 WHERE f2 = 'ZZZZZZZ'; +my_value +1 +TRUNCATE t1; +SELECT COUNT(*) = 0 AS my_value FROM t1; +my_value +1 +DROP TABLE t1; +CREATE TABLE t1 ( f1 INTEGER, f2 char(20)) +PARTITION BY RANGE(f1) +SUBPARTITION BY HASH(f1) +( PARTITION part1 VALUES LESS THAN (1000) STORAGE ENGINE = 'NDB' +(SUBPARTITION subpart11 STORAGE ENGINE = 'NDB' , +SUBPARTITION subpart12 STORAGE ENGINE = 'NDB' ), +PARTITION part2 VALUES LESS THAN (2000) +(SUBPARTITION subpart21 STORAGE ENGINE = 'NDB' , +SUBPARTITION subpart22 STORAGE ENGINE = 'NDB' ) +); +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `f1` int(11) default NULL, + `f2` char(20) default NULL +) ENGINE=ndbcluster DEFAULT CHARSET=latin1 PARTITION BY RANGE (f1) SUBPARTITION BY HASH (f1) (PARTITION part1 VALUES LESS THAN (1000) (SUBPARTITION subpart11 ENGINE = ndbcluster, SUBPARTITION subpart12 ENGINE = ndbcluster), PARTITION part2 VALUES LESS THAN (2000) (SUBPARTITION subpart21 ENGINE = ndbcluster, SUBPARTITION subpart22 ENGINE = ndbcluster)) +SELECT COUNT(*) = 0 AS my_value FROM t1; +my_value +1 +INSERT INTO t1 SELECT * FROM t0_template WHERE f1 BETWEEN 1 AND 200; +SELECT (COUNT(*) = 200) AND (MIN(f1) = 1) AND (MAX(f1) = 200) +AS my_value FROM t1; +my_value +1 +UPDATE t1 SET f1 = f1 + 200 +WHERE f1 BETWEEN 100 - 50 AND 100 + 50; +SELECT (COUNT(*) = 200) AND (MIN(f1) = 1) AND (MAX(f1) = 100 + 50 + 200 ) +AS my_value FROM t1; +my_value +1 +DELETE FROM t1 +WHERE f1 BETWEEN 100 - 50 + 200 AND 100 + 50 + 200; +SELECT (COUNT(*) = 200 - 50 - 50 - 1) AND (MIN(f1) = 1) AND (MAX(f1) = 200) +AS my_value FROM t1; +my_value +1 +INSERT INTO t1 SET f1 = 0 , f2 = '#######'; +SELECT COUNT(*) = 1 AS my_value FROM t1 WHERE f1 = 0 AND f2 = '#######'; +my_value +1 +INSERT INTO t1 SET f1 = 200 + 1, f2 = '#######'; +SELECT COUNT(*) = 1 AS my_value FROM t1 WHERE f1 = 200 + 1 AND f2 = '#######'; +my_value +1 +UPDATE t1 SET f1 = 200 + 2, f2 = 'ZZZZZZZ' + WHERE f1 = 0 AND f2 = '#######'; +SELECT COUNT(*) = 1 AS my_value FROM t1 WHERE f1 = 200 + 2 AND f2 = 'ZZZZZZZ'; +my_value +1 +DELETE FROM t1 WHERE f1 = 200 + 2 AND f2 = 'ZZZZZZZ'; +SELECT COUNT(*) = 0 AS my_value FROM t1 WHERE f2 = 'ZZZZZZZ'; +my_value +1 +TRUNCATE t1; +SELECT COUNT(*) = 0 AS my_value FROM t1; +my_value +1 +DROP TABLE t1; +# 2.7 Ugly storage engine assignments mixups +CREATE TABLE t1 ( f1 INTEGER, f2 char(20)) +PARTITION BY RANGE(f1) +SUBPARTITION BY HASH(f1) +( PARTITION part1 VALUES LESS THAN (1000) ENGINE = 'NDB' +(SUBPARTITION subpart11 , +SUBPARTITION subpart12 ), +PARTITION part2 VALUES LESS THAN (2000) +(SUBPARTITION subpart21 STORAGE ENGINE = 'NDB' , +SUBPARTITION subpart22 STORAGE ENGINE = 'NDB' ) +); +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `f1` int(11) default NULL, + `f2` char(20) default NULL +) ENGINE=ndbcluster DEFAULT CHARSET=latin1 PARTITION BY RANGE (f1) SUBPARTITION BY HASH (f1) (PARTITION part1 VALUES LESS THAN (1000) (SUBPARTITION subpart11 ENGINE = ndbcluster, SUBPARTITION subpart12 ENGINE = ndbcluster), PARTITION part2 VALUES LESS THAN (2000) (SUBPARTITION subpart21 ENGINE = ndbcluster, SUBPARTITION subpart22 ENGINE = ndbcluster)) +SELECT COUNT(*) = 0 AS my_value FROM t1; +my_value +1 +INSERT INTO t1 SELECT * FROM t0_template WHERE f1 BETWEEN 1 AND 200; +SELECT (COUNT(*) = 200) AND (MIN(f1) = 1) AND (MAX(f1) = 200) +AS my_value FROM t1; +my_value +1 +UPDATE t1 SET f1 = f1 + 200 +WHERE f1 BETWEEN 100 - 50 AND 100 + 50; +SELECT (COUNT(*) = 200) AND (MIN(f1) = 1) AND (MAX(f1) = 100 + 50 + 200 ) +AS my_value FROM t1; +my_value +1 +DELETE FROM t1 +WHERE f1 BETWEEN 100 - 50 + 200 AND 100 + 50 + 200; +SELECT (COUNT(*) = 200 - 50 - 50 - 1) AND (MIN(f1) = 1) AND (MAX(f1) = 200) +AS my_value FROM t1; +my_value +1 +INSERT INTO t1 SET f1 = 0 , f2 = '#######'; +SELECT COUNT(*) = 1 AS my_value FROM t1 WHERE f1 = 0 AND f2 = '#######'; +my_value +1 +INSERT INTO t1 SET f1 = 200 + 1, f2 = '#######'; +SELECT COUNT(*) = 1 AS my_value FROM t1 WHERE f1 = 200 + 1 AND f2 = '#######'; +my_value +1 +UPDATE t1 SET f1 = 200 + 2, f2 = 'ZZZZZZZ' + WHERE f1 = 0 AND f2 = '#######'; +SELECT COUNT(*) = 1 AS my_value FROM t1 WHERE f1 = 200 + 2 AND f2 = 'ZZZZZZZ'; +my_value +1 +DELETE FROM t1 WHERE f1 = 200 + 2 AND f2 = 'ZZZZZZZ'; +SELECT COUNT(*) = 0 AS my_value FROM t1 WHERE f2 = 'ZZZZZZZ'; +my_value +1 +TRUNCATE t1; +SELECT COUNT(*) = 0 AS my_value FROM t1; +my_value +1 +DROP TABLE t1; +CREATE TABLE t1 ( f1 INTEGER, f2 char(20)) +PARTITION BY RANGE(f1) +SUBPARTITION BY HASH(f1) +( PARTITION part1 VALUES LESS THAN (1000) +(SUBPARTITION subpart11 STORAGE ENGINE = 'NDB' , +SUBPARTITION subpart12 STORAGE ENGINE = 'NDB' ), +PARTITION part2 VALUES LESS THAN (2000) ENGINE = 'NDB' +(SUBPARTITION subpart21 , +SUBPARTITION subpart22 ) +); +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `f1` int(11) default NULL, + `f2` char(20) default NULL +) ENGINE=ndbcluster DEFAULT CHARSET=latin1 PARTITION BY RANGE (f1) SUBPARTITION BY HASH (f1) (PARTITION part1 VALUES LESS THAN (1000) (SUBPARTITION subpart11 ENGINE = ndbcluster, SUBPARTITION subpart12 ENGINE = ndbcluster), PARTITION part2 VALUES LESS THAN (2000) (SUBPARTITION subpart21 ENGINE = ndbcluster, SUBPARTITION subpart22 ENGINE = ndbcluster)) +SELECT COUNT(*) = 0 AS my_value FROM t1; +my_value +1 +INSERT INTO t1 SELECT * FROM t0_template WHERE f1 BETWEEN 1 AND 200; +SELECT (COUNT(*) = 200) AND (MIN(f1) = 1) AND (MAX(f1) = 200) +AS my_value FROM t1; +my_value +1 +UPDATE t1 SET f1 = f1 + 200 +WHERE f1 BETWEEN 100 - 50 AND 100 + 50; +SELECT (COUNT(*) = 200) AND (MIN(f1) = 1) AND (MAX(f1) = 100 + 50 + 200 ) +AS my_value FROM t1; +my_value +1 +DELETE FROM t1 +WHERE f1 BETWEEN 100 - 50 + 200 AND 100 + 50 + 200; +SELECT (COUNT(*) = 200 - 50 - 50 - 1) AND (MIN(f1) = 1) AND (MAX(f1) = 200) +AS my_value FROM t1; +my_value +1 +INSERT INTO t1 SET f1 = 0 , f2 = '#######'; +SELECT COUNT(*) = 1 AS my_value FROM t1 WHERE f1 = 0 AND f2 = '#######'; +my_value +1 +INSERT INTO t1 SET f1 = 200 + 1, f2 = '#######'; +SELECT COUNT(*) = 1 AS my_value FROM t1 WHERE f1 = 200 + 1 AND f2 = '#######'; +my_value +1 +UPDATE t1 SET f1 = 200 + 2, f2 = 'ZZZZZZZ' + WHERE f1 = 0 AND f2 = '#######'; +SELECT COUNT(*) = 1 AS my_value FROM t1 WHERE f1 = 200 + 2 AND f2 = 'ZZZZZZZ'; +my_value +1 +DELETE FROM t1 WHERE f1 = 200 + 2 AND f2 = 'ZZZZZZZ'; +SELECT COUNT(*) = 0 AS my_value FROM t1 WHERE f2 = 'ZZZZZZZ'; +my_value +1 +TRUNCATE t1; +SELECT COUNT(*) = 0 AS my_value FROM t1; +my_value +1 +DROP TABLE t1; +# 2.8 Session default engine differs from engine used within create table +SET SESSION storage_engine='MEMORY'; +SET SESSION storage_engine='NDB' ; +#------------------------------------------------------------------------ +# 3. Check number of partitions and subpartitions +#------------------------------------------------------------------------ +DROP TABLE IF EXISTS t1; +# 3.1 (positive) without partition/subpartition number assignment +# 3.1.1 no partition number, no named partitions, no subpartitions mentioned +CREATE TABLE t1 ( f1 INTEGER, f2 char(20)) +PARTITION BY HASH(f1); +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `f1` int(11) default NULL, + `f2` char(20) default NULL +) ENGINE=ndbcluster DEFAULT CHARSET=latin1 PARTITION BY HASH (f1) +SELECT COUNT(*) = 0 AS my_value FROM t1; +my_value +1 +INSERT INTO t1 SELECT * FROM t0_template WHERE f1 BETWEEN 1 AND 200; +SELECT (COUNT(*) = 200) AND (MIN(f1) = 1) AND (MAX(f1) = 200) +AS my_value FROM t1; +my_value +1 +UPDATE t1 SET f1 = f1 + 200 +WHERE f1 BETWEEN 100 - 50 AND 100 + 50; +SELECT (COUNT(*) = 200) AND (MIN(f1) = 1) AND (MAX(f1) = 100 + 50 + 200 ) +AS my_value FROM t1; +my_value +1 +DELETE FROM t1 +WHERE f1 BETWEEN 100 - 50 + 200 AND 100 + 50 + 200; +SELECT (COUNT(*) = 200 - 50 - 50 - 1) AND (MIN(f1) = 1) AND (MAX(f1) = 200) +AS my_value FROM t1; +my_value +1 +INSERT INTO t1 SET f1 = 0 , f2 = '#######'; +SELECT COUNT(*) = 1 AS my_value FROM t1 WHERE f1 = 0 AND f2 = '#######'; +my_value +1 +INSERT INTO t1 SET f1 = 200 + 1, f2 = '#######'; +SELECT COUNT(*) = 1 AS my_value FROM t1 WHERE f1 = 200 + 1 AND f2 = '#######'; +my_value +1 +UPDATE t1 SET f1 = 200 + 2, f2 = 'ZZZZZZZ' + WHERE f1 = 0 AND f2 = '#######'; +SELECT COUNT(*) = 1 AS my_value FROM t1 WHERE f1 = 200 + 2 AND f2 = 'ZZZZZZZ'; +my_value +1 +DELETE FROM t1 WHERE f1 = 200 + 2 AND f2 = 'ZZZZZZZ'; +SELECT COUNT(*) = 0 AS my_value FROM t1 WHERE f2 = 'ZZZZZZZ'; +my_value +1 +TRUNCATE t1; +SELECT COUNT(*) = 0 AS my_value FROM t1; +my_value +1 +DROP TABLE t1; +# 3.1.2 no partition number, named partitions, no subpartitions mentioned +CREATE TABLE t1 ( f1 INTEGER, f2 char(20)) +PARTITION BY HASH(f1) (PARTITION part1, PARTITION part2); +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `f1` int(11) default NULL, + `f2` char(20) default NULL +) ENGINE=ndbcluster DEFAULT CHARSET=latin1 PARTITION BY HASH (f1) (PARTITION part1 ENGINE = ndbcluster, PARTITION part2 ENGINE = ndbcluster) +SELECT COUNT(*) = 0 AS my_value FROM t1; +my_value +1 +INSERT INTO t1 SELECT * FROM t0_template WHERE f1 BETWEEN 1 AND 200; +SELECT (COUNT(*) = 200) AND (MIN(f1) = 1) AND (MAX(f1) = 200) +AS my_value FROM t1; +my_value +1 +UPDATE t1 SET f1 = f1 + 200 +WHERE f1 BETWEEN 100 - 50 AND 100 + 50; +SELECT (COUNT(*) = 200) AND (MIN(f1) = 1) AND (MAX(f1) = 100 + 50 + 200 ) +AS my_value FROM t1; +my_value +1 +DELETE FROM t1 +WHERE f1 BETWEEN 100 - 50 + 200 AND 100 + 50 + 200; +SELECT (COUNT(*) = 200 - 50 - 50 - 1) AND (MIN(f1) = 1) AND (MAX(f1) = 200) +AS my_value FROM t1; +my_value +1 +INSERT INTO t1 SET f1 = 0 , f2 = '#######'; +SELECT COUNT(*) = 1 AS my_value FROM t1 WHERE f1 = 0 AND f2 = '#######'; +my_value +1 +INSERT INTO t1 SET f1 = 200 + 1, f2 = '#######'; +SELECT COUNT(*) = 1 AS my_value FROM t1 WHERE f1 = 200 + 1 AND f2 = '#######'; +my_value +1 +UPDATE t1 SET f1 = 200 + 2, f2 = 'ZZZZZZZ' + WHERE f1 = 0 AND f2 = '#######'; +SELECT COUNT(*) = 1 AS my_value FROM t1 WHERE f1 = 200 + 2 AND f2 = 'ZZZZZZZ'; +my_value +1 +DELETE FROM t1 WHERE f1 = 200 + 2 AND f2 = 'ZZZZZZZ'; +SELECT COUNT(*) = 0 AS my_value FROM t1 WHERE f2 = 'ZZZZZZZ'; +my_value +1 +TRUNCATE t1; +SELECT COUNT(*) = 0 AS my_value FROM t1; +my_value +1 +DROP TABLE t1; +# 3.1.3 variations on no partition/subpartition number, named partitions, +# different subpartitions are/are not named +CREATE TABLE t1 ( f1 INTEGER, f2 char(20)) +PARTITION BY RANGE(f1) SUBPARTITION BY HASH(f1) (PARTITION part1 VALUES LESS THAN (1000), PARTITION part2 VALUES LESS THAN (2000), PARTITION part3 VALUES LESS THAN (2147483647)) ; +DROP TABLE t1; +# FIXME several subtestcases of 3.1.3 disabled because of server crashes +# Bug#15407 Partitions: crash if subpartition +CREATE TABLE t1 ( f1 INTEGER, f2 char(20)) +PARTITION BY RANGE(f1) SUBPARTITION BY HASH(f1) (PARTITION part1 VALUES LESS THAN (1000) +(SUBPARTITION subpart11 , SUBPARTITION subpart12 ), PARTITION part2 VALUES LESS THAN (2000) +(SUBPARTITION subpart21 , SUBPARTITION subpart22 ), PARTITION part3 VALUES LESS THAN (2147483647) +(SUBPARTITION subpart21 , SUBPARTITION subpart22 )) ; +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `f1` int(11) default NULL, + `f2` char(20) default NULL +) ENGINE=ndbcluster DEFAULT CHARSET=latin1 PARTITION BY RANGE (f1) SUBPARTITION BY HASH (f1) (PARTITION part1 VALUES LESS THAN (1000) (SUBPARTITION subpart11 ENGINE = ndbcluster, SUBPARTITION subpart12 ENGINE = ndbcluster), PARTITION part2 VALUES LESS THAN (2000) (SUBPARTITION subpart21 ENGINE = ndbcluster, SUBPARTITION subpart22 ENGINE = ndbcluster), PARTITION part3 VALUES LESS THAN (2147483647) (SUBPARTITION subpart21 ENGINE = ndbcluster, SUBPARTITION subpart22 ENGINE = ndbcluster)) +SELECT COUNT(*) = 0 AS my_value FROM t1; +my_value +1 +INSERT INTO t1 SELECT * FROM t0_template WHERE f1 BETWEEN 1 AND 200; +SELECT (COUNT(*) = 200) AND (MIN(f1) = 1) AND (MAX(f1) = 200) +AS my_value FROM t1; +my_value +1 +UPDATE t1 SET f1 = f1 + 200 +WHERE f1 BETWEEN 100 - 50 AND 100 + 50; +SELECT (COUNT(*) = 200) AND (MIN(f1) = 1) AND (MAX(f1) = 100 + 50 + 200 ) +AS my_value FROM t1; +my_value +1 +DELETE FROM t1 +WHERE f1 BETWEEN 100 - 50 + 200 AND 100 + 50 + 200; +SELECT (COUNT(*) = 200 - 50 - 50 - 1) AND (MIN(f1) = 1) AND (MAX(f1) = 200) +AS my_value FROM t1; +my_value +1 +INSERT INTO t1 SET f1 = 0 , f2 = '#######'; +SELECT COUNT(*) = 1 AS my_value FROM t1 WHERE f1 = 0 AND f2 = '#######'; +my_value +1 +INSERT INTO t1 SET f1 = 200 + 1, f2 = '#######'; +SELECT COUNT(*) = 1 AS my_value FROM t1 WHERE f1 = 200 + 1 AND f2 = '#######'; +my_value +1 +UPDATE t1 SET f1 = 200 + 2, f2 = 'ZZZZZZZ' + WHERE f1 = 0 AND f2 = '#######'; +SELECT COUNT(*) = 1 AS my_value FROM t1 WHERE f1 = 200 + 2 AND f2 = 'ZZZZZZZ'; +my_value +1 +DELETE FROM t1 WHERE f1 = 200 + 2 AND f2 = 'ZZZZZZZ'; +SELECT COUNT(*) = 0 AS my_value FROM t1 WHERE f2 = 'ZZZZZZZ'; +my_value +1 +TRUNCATE t1; +SELECT COUNT(*) = 0 AS my_value FROM t1; +my_value +1 +DROP TABLE t1; +# 3.2 partition/subpartition numbers good and bad values and notations +DROP TABLE IF EXISTS t1; +# 3.2.1 partition/subpartition numbers INTEGER notation +CREATE TABLE t1 ( f1 INTEGER, f2 char(20)) +PARTITION BY HASH(f1) PARTITIONS 2; +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `f1` int(11) default NULL, + `f2` char(20) default NULL +) ENGINE=ndbcluster DEFAULT CHARSET=latin1 PARTITION BY HASH (f1) PARTITIONS 2 +SELECT COUNT(*) = 0 AS my_value FROM t1; +my_value +1 +INSERT INTO t1 SELECT * FROM t0_template WHERE f1 BETWEEN 1 AND 200; +SELECT (COUNT(*) = 200) AND (MIN(f1) = 1) AND (MAX(f1) = 200) +AS my_value FROM t1; +my_value +1 +UPDATE t1 SET f1 = f1 + 200 +WHERE f1 BETWEEN 100 - 50 AND 100 + 50; +SELECT (COUNT(*) = 200) AND (MIN(f1) = 1) AND (MAX(f1) = 100 + 50 + 200 ) +AS my_value FROM t1; +my_value +1 +DELETE FROM t1 +WHERE f1 BETWEEN 100 - 50 + 200 AND 100 + 50 + 200; +SELECT (COUNT(*) = 200 - 50 - 50 - 1) AND (MIN(f1) = 1) AND (MAX(f1) = 200) +AS my_value FROM t1; +my_value +1 +INSERT INTO t1 SET f1 = 0 , f2 = '#######'; +SELECT COUNT(*) = 1 AS my_value FROM t1 WHERE f1 = 0 AND f2 = '#######'; +my_value +1 +INSERT INTO t1 SET f1 = 200 + 1, f2 = '#######'; +SELECT COUNT(*) = 1 AS my_value FROM t1 WHERE f1 = 200 + 1 AND f2 = '#######'; +my_value +1 +UPDATE t1 SET f1 = 200 + 2, f2 = 'ZZZZZZZ' + WHERE f1 = 0 AND f2 = '#######'; +SELECT COUNT(*) = 1 AS my_value FROM t1 WHERE f1 = 200 + 2 AND f2 = 'ZZZZZZZ'; +my_value +1 +DELETE FROM t1 WHERE f1 = 200 + 2 AND f2 = 'ZZZZZZZ'; +SELECT COUNT(*) = 0 AS my_value FROM t1 WHERE f2 = 'ZZZZZZZ'; +my_value +1 +TRUNCATE t1; +SELECT COUNT(*) = 0 AS my_value FROM t1; +my_value +1 +DROP TABLE t1; +CREATE TABLE t1 ( f1 INTEGER, f2 char(20)) +PARTITION BY RANGE(f1) SUBPARTITION BY HASH(f1) +SUBPARTITIONS 2 +(PARTITION part1 VALUES LESS THAN (1000), PARTITION part2 VALUES LESS THAN (2147483647)); +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `f1` int(11) default NULL, + `f2` char(20) default NULL +) ENGINE=ndbcluster DEFAULT CHARSET=latin1 PARTITION BY RANGE (f1) SUBPARTITION BY HASH (f1) SUBPARTITIONS 2 (PARTITION part1 VALUES LESS THAN (1000) , PARTITION part2 VALUES LESS THAN (2147483647) ) +SELECT COUNT(*) = 0 AS my_value FROM t1; +my_value +1 +INSERT INTO t1 SELECT * FROM t0_template WHERE f1 BETWEEN 1 AND 200; +SELECT (COUNT(*) = 200) AND (MIN(f1) = 1) AND (MAX(f1) = 200) +AS my_value FROM t1; +my_value +1 +UPDATE t1 SET f1 = f1 + 200 +WHERE f1 BETWEEN 100 - 50 AND 100 + 50; +SELECT (COUNT(*) = 200) AND (MIN(f1) = 1) AND (MAX(f1) = 100 + 50 + 200 ) +AS my_value FROM t1; +my_value +1 +DELETE FROM t1 +WHERE f1 BETWEEN 100 - 50 + 200 AND 100 + 50 + 200; +SELECT (COUNT(*) = 200 - 50 - 50 - 1) AND (MIN(f1) = 1) AND (MAX(f1) = 200) +AS my_value FROM t1; +my_value +1 +INSERT INTO t1 SET f1 = 0 , f2 = '#######'; +SELECT COUNT(*) = 1 AS my_value FROM t1 WHERE f1 = 0 AND f2 = '#######'; +my_value +1 +INSERT INTO t1 SET f1 = 200 + 1, f2 = '#######'; +SELECT COUNT(*) = 1 AS my_value FROM t1 WHERE f1 = 200 + 1 AND f2 = '#######'; +my_value +1 +UPDATE t1 SET f1 = 200 + 2, f2 = 'ZZZZZZZ' + WHERE f1 = 0 AND f2 = '#######'; +SELECT COUNT(*) = 1 AS my_value FROM t1 WHERE f1 = 200 + 2 AND f2 = 'ZZZZZZZ'; +my_value +1 +DELETE FROM t1 WHERE f1 = 200 + 2 AND f2 = 'ZZZZZZZ'; +SELECT COUNT(*) = 0 AS my_value FROM t1 WHERE f2 = 'ZZZZZZZ'; +my_value +1 +TRUNCATE t1; +SELECT COUNT(*) = 0 AS my_value FROM t1; +my_value +1 +DROP TABLE t1; +CREATE TABLE t1 ( f1 INTEGER, f2 char(20)) +PARTITION BY HASH(f1) PARTITIONS 1; +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `f1` int(11) default NULL, + `f2` char(20) default NULL +) ENGINE=ndbcluster DEFAULT CHARSET=latin1 PARTITION BY HASH (f1) PARTITIONS 1 +SELECT COUNT(*) = 0 AS my_value FROM t1; +my_value +1 +INSERT INTO t1 SELECT * FROM t0_template WHERE f1 BETWEEN 1 AND 200; +SELECT (COUNT(*) = 200) AND (MIN(f1) = 1) AND (MAX(f1) = 200) +AS my_value FROM t1; +my_value +1 +UPDATE t1 SET f1 = f1 + 200 +WHERE f1 BETWEEN 100 - 50 AND 100 + 50; +SELECT (COUNT(*) = 200) AND (MIN(f1) = 1) AND (MAX(f1) = 100 + 50 + 200 ) +AS my_value FROM t1; +my_value +1 +DELETE FROM t1 +WHERE f1 BETWEEN 100 - 50 + 200 AND 100 + 50 + 200; +SELECT (COUNT(*) = 200 - 50 - 50 - 1) AND (MIN(f1) = 1) AND (MAX(f1) = 200) +AS my_value FROM t1; +my_value +1 +INSERT INTO t1 SET f1 = 0 , f2 = '#######'; +SELECT COUNT(*) = 1 AS my_value FROM t1 WHERE f1 = 0 AND f2 = '#######'; +my_value +1 +INSERT INTO t1 SET f1 = 200 + 1, f2 = '#######'; +SELECT COUNT(*) = 1 AS my_value FROM t1 WHERE f1 = 200 + 1 AND f2 = '#######'; +my_value +1 +UPDATE t1 SET f1 = 200 + 2, f2 = 'ZZZZZZZ' + WHERE f1 = 0 AND f2 = '#######'; +SELECT COUNT(*) = 1 AS my_value FROM t1 WHERE f1 = 200 + 2 AND f2 = 'ZZZZZZZ'; +my_value +1 +DELETE FROM t1 WHERE f1 = 200 + 2 AND f2 = 'ZZZZZZZ'; +SELECT COUNT(*) = 0 AS my_value FROM t1 WHERE f2 = 'ZZZZZZZ'; +my_value +1 +TRUNCATE t1; +SELECT COUNT(*) = 0 AS my_value FROM t1; +my_value +1 +DROP TABLE t1; +CREATE TABLE t1 ( f1 INTEGER, f2 char(20)) +PARTITION BY RANGE(f1) SUBPARTITION BY HASH(f1) +SUBPARTITIONS 1 +(PARTITION part1 VALUES LESS THAN (1000), PARTITION part2 VALUES LESS THAN (2147483647)); +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `f1` int(11) default NULL, + `f2` char(20) default NULL +) ENGINE=ndbcluster DEFAULT CHARSET=latin1 PARTITION BY RANGE (f1) SUBPARTITION BY HASH (f1) SUBPARTITIONS 1 (PARTITION part1 VALUES LESS THAN (1000) , PARTITION part2 VALUES LESS THAN (2147483647) ) +SELECT COUNT(*) = 0 AS my_value FROM t1; +my_value +1 +INSERT INTO t1 SELECT * FROM t0_template WHERE f1 BETWEEN 1 AND 200; +SELECT (COUNT(*) = 200) AND (MIN(f1) = 1) AND (MAX(f1) = 200) +AS my_value FROM t1; +my_value +1 +UPDATE t1 SET f1 = f1 + 200 +WHERE f1 BETWEEN 100 - 50 AND 100 + 50; +SELECT (COUNT(*) = 200) AND (MIN(f1) = 1) AND (MAX(f1) = 100 + 50 + 200 ) +AS my_value FROM t1; +my_value +1 +DELETE FROM t1 +WHERE f1 BETWEEN 100 - 50 + 200 AND 100 + 50 + 200; +SELECT (COUNT(*) = 200 - 50 - 50 - 1) AND (MIN(f1) = 1) AND (MAX(f1) = 200) +AS my_value FROM t1; +my_value +1 +INSERT INTO t1 SET f1 = 0 , f2 = '#######'; +SELECT COUNT(*) = 1 AS my_value FROM t1 WHERE f1 = 0 AND f2 = '#######'; +my_value +1 +INSERT INTO t1 SET f1 = 200 + 1, f2 = '#######'; +SELECT COUNT(*) = 1 AS my_value FROM t1 WHERE f1 = 200 + 1 AND f2 = '#######'; +my_value +1 +UPDATE t1 SET f1 = 200 + 2, f2 = 'ZZZZZZZ' + WHERE f1 = 0 AND f2 = '#######'; +SELECT COUNT(*) = 1 AS my_value FROM t1 WHERE f1 = 200 + 2 AND f2 = 'ZZZZZZZ'; +my_value +1 +DELETE FROM t1 WHERE f1 = 200 + 2 AND f2 = 'ZZZZZZZ'; +SELECT COUNT(*) = 0 AS my_value FROM t1 WHERE f2 = 'ZZZZZZZ'; +my_value +1 +TRUNCATE t1; +SELECT COUNT(*) = 0 AS my_value FROM t1; +my_value +1 +DROP TABLE t1; +CREATE TABLE t1 ( f1 INTEGER, f2 char(20)) +PARTITION BY HASH(f1) PARTITIONS 0; +ERROR HY000: Number of partitions = 0 is not an allowed value +CREATE TABLE t1 ( f1 INTEGER, f2 char(20)) +PARTITION BY RANGE(f1) SUBPARTITION BY HASH(f1) +SUBPARTITIONS 0 +(PARTITION part1 VALUES LESS THAN (1000), PARTITION part2 VALUES LESS THAN (2147483647)); +ERROR HY000: Number of subpartitions = 0 is not an allowed value +CREATE TABLE t1 ( f1 INTEGER, f2 char(20)) +PARTITION BY HASH(f1) PARTITIONS -1; +ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '-1' at line 2 +CREATE TABLE t1 ( f1 INTEGER, f2 char(20)) +PARTITION BY RANGE(f1) SUBPARTITION BY HASH(f1) +SUBPARTITIONS -1 +(PARTITION part1 VALUES LESS THAN (1000), PARTITION part2 VALUES LESS THAN (2147483647)); +ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '-1 +(PARTITION part1 VALUES LESS THAN (1000), PARTITION part2 VALUES LESS THAN (2' at line 3 +CREATE TABLE t1 ( f1 INTEGER, f2 char(20)) +PARTITION BY HASH(f1) PARTITIONS 1000000; +ERROR HY000: Too many partitions were defined +CREATE TABLE t1 ( f1 INTEGER, f2 char(20)) +PARTITION BY RANGE(f1) SUBPARTITION BY HASH(f1) +SUBPARTITIONS 1000000 +(PARTITION part1 VALUES LESS THAN (1000), PARTITION part2 VALUES LESS THAN (2147483647)); +ERROR HY000: Too many partitions were defined +# 3.2.4 partition/subpartition numbers STRING notation +CREATE TABLE t1 ( f1 INTEGER, f2 char(20)) +PARTITION BY HASH(f1) PARTITIONS '2'; +ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ''2'' at line 2 +CREATE TABLE t1 ( f1 INTEGER, f2 char(20)) +PARTITION BY RANGE(f1) SUBPARTITION BY HASH(f1) +SUBPARTITIONS '2' +(PARTITION part1 VALUES LESS THAN (1000), PARTITION part2 VALUES LESS THAN (2147483647)); +ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ''2' +(PARTITION part1 VALUES LESS THAN (1000), PARTITION part2 VALUES LESS THAN (' at line 3 +CREATE TABLE t1 ( f1 INTEGER, f2 char(20)) +PARTITION BY HASH(f1) PARTITIONS '2.0'; +ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ''2.0'' at line 2 +CREATE TABLE t1 ( f1 INTEGER, f2 char(20)) +PARTITION BY RANGE(f1) SUBPARTITION BY HASH(f1) +SUBPARTITIONS '2.0' +(PARTITION part1 VALUES LESS THAN (1000), PARTITION part2 VALUES LESS THAN (2147483647)); +ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ''2.0' +(PARTITION part1 VALUES LESS THAN (1000), PARTITION part2 VALUES LESS THAN' at line 3 +CREATE TABLE t1 ( f1 INTEGER, f2 char(20)) +PARTITION BY HASH(f1) PARTITIONS '0.2E+1'; +ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ''0.2E+1'' at line 2 +CREATE TABLE t1 ( f1 INTEGER, f2 char(20)) +PARTITION BY RANGE(f1) SUBPARTITION BY HASH(f1) +SUBPARTITIONS '0.2E+1' +(PARTITION part1 VALUES LESS THAN (1000), PARTITION part2 VALUES LESS THAN (2147483647)); +ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ''0.2E+1' +(PARTITION part1 VALUES LESS THAN (1000), PARTITION part2 VALUES LESS T' at line 3 +CREATE TABLE t1 ( f1 INTEGER, f2 char(20)) +PARTITION BY HASH(f1) PARTITIONS '2A'; +ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ''2A'' at line 2 +CREATE TABLE t1 ( f1 INTEGER, f2 char(20)) +PARTITION BY RANGE(f1) SUBPARTITION BY HASH(f1) +SUBPARTITIONS '2A' +(PARTITION part1 VALUES LESS THAN (1000), PARTITION part2 VALUES LESS THAN (2147483647)); +ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ''2A' +(PARTITION part1 VALUES LESS THAN (1000), PARTITION part2 VALUES LESS THAN ' at line 3 +CREATE TABLE t1 ( f1 INTEGER, f2 char(20)) +PARTITION BY HASH(f1) PARTITIONS 'A2'; +ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ''A2'' at line 2 +CREATE TABLE t1 ( f1 INTEGER, f2 char(20)) +PARTITION BY RANGE(f1) SUBPARTITION BY HASH(f1) +SUBPARTITIONS 'A2' +(PARTITION part1 VALUES LESS THAN (1000), PARTITION part2 VALUES LESS THAN (2147483647)); +ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ''A2' +(PARTITION part1 VALUES LESS THAN (1000), PARTITION part2 VALUES LESS THAN ' at line 3 +CREATE TABLE t1 ( f1 INTEGER, f2 char(20)) +PARTITION BY HASH(f1) PARTITIONS ''; +ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '''' at line 2 +CREATE TABLE t1 ( f1 INTEGER, f2 char(20)) +PARTITION BY RANGE(f1) SUBPARTITION BY HASH(f1) +SUBPARTITIONS '' +(PARTITION part1 VALUES LESS THAN (1000), PARTITION part2 VALUES LESS THAN (2147483647)); +ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ''' +(PARTITION part1 VALUES LESS THAN (1000), PARTITION part2 VALUES LESS THAN (2' at line 3 +CREATE TABLE t1 ( f1 INTEGER, f2 char(20)) +PARTITION BY HASH(f1) PARTITIONS 'GARBAGE'; +ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ''GARBAGE'' at line 2 +CREATE TABLE t1 ( f1 INTEGER, f2 char(20)) +PARTITION BY RANGE(f1) SUBPARTITION BY HASH(f1) +SUBPARTITIONS 'GARBAGE' +(PARTITION part1 VALUES LESS THAN (1000), PARTITION part2 VALUES LESS THAN (2147483647)); +ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ''GARBAGE' +(PARTITION part1 VALUES LESS THAN (1000), PARTITION part2 VALUES LESS ' at line 3 +# 3.2.5 partition/subpartition numbers other notations +CREATE TABLE t1 ( f1 INTEGER, f2 char(20)) +PARTITION BY HASH(f1) PARTITIONS 2A; +ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '2A' at line 2 +CREATE TABLE t1 ( f1 INTEGER, f2 char(20)) +PARTITION BY RANGE(f1) SUBPARTITION BY HASH(f1) +SUBPARTITIONS 2A +(PARTITION part1 VALUES LESS THAN (1000), PARTITION part2 VALUES LESS THAN (2147483647)); +ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '2A +(PARTITION part1 VALUES LESS THAN (1000), PARTITION part2 VALUES LESS THAN (2' at line 3 +CREATE TABLE t1 ( f1 INTEGER, f2 char(20)) +PARTITION BY HASH(f1) PARTITIONS A2; +ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'A2' at line 2 +CREATE TABLE t1 ( f1 INTEGER, f2 char(20)) +PARTITION BY RANGE(f1) SUBPARTITION BY HASH(f1) +SUBPARTITIONS A2 +(PARTITION part1 VALUES LESS THAN (1000), PARTITION part2 VALUES LESS THAN (2147483647)); +ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'A2 +(PARTITION part1 VALUES LESS THAN (1000), PARTITION part2 VALUES LESS THAN (2' at line 3 +CREATE TABLE t1 ( f1 INTEGER, f2 char(20)) +PARTITION BY HASH(f1) PARTITIONS GARBAGE; +ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'GARBAGE' at line 2 +CREATE TABLE t1 ( f1 INTEGER, f2 char(20)) +PARTITION BY RANGE(f1) SUBPARTITION BY HASH(f1) +SUBPARTITIONS GARBAGE +(PARTITION part1 VALUES LESS THAN (1000), PARTITION part2 VALUES LESS THAN (2147483647)); +ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'GARBAGE +(PARTITION part1 VALUES LESS THAN (1000), PARTITION part2 VALUES LESS TH' at line 3 +CREATE TABLE t1 ( f1 INTEGER, f2 char(20)) +PARTITION BY HASH(f1) PARTITIONS "2"; +ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '"2"' at line 2 +CREATE TABLE t1 ( f1 INTEGER, f2 char(20)) +PARTITION BY RANGE(f1) SUBPARTITION BY HASH(f1) +SUBPARTITIONS "2" +(PARTITION part1 VALUES LESS THAN (1000), PARTITION part2 VALUES LESS THAN (2147483647)); +ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '"2" +(PARTITION part1 VALUES LESS THAN (1000), PARTITION part2 VALUES LESS THAN (' at line 3 +CREATE TABLE t1 ( f1 INTEGER, f2 char(20)) +PARTITION BY HASH(f1) PARTITIONS "2A"; +ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '"2A"' at line 2 +CREATE TABLE t1 ( f1 INTEGER, f2 char(20)) +PARTITION BY RANGE(f1) SUBPARTITION BY HASH(f1) +SUBPARTITIONS "2A" +(PARTITION part1 VALUES LESS THAN (1000), PARTITION part2 VALUES LESS THAN (2147483647)); +ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '"2A" +(PARTITION part1 VALUES LESS THAN (1000), PARTITION part2 VALUES LESS THAN ' at line 3 +CREATE TABLE t1 ( f1 INTEGER, f2 char(20)) +PARTITION BY HASH(f1) PARTITIONS "A2"; +ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '"A2"' at line 2 +CREATE TABLE t1 ( f1 INTEGER, f2 char(20)) +PARTITION BY RANGE(f1) SUBPARTITION BY HASH(f1) +SUBPARTITIONS "A2" +(PARTITION part1 VALUES LESS THAN (1000), PARTITION part2 VALUES LESS THAN (2147483647)); +ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '"A2" +(PARTITION part1 VALUES LESS THAN (1000), PARTITION part2 VALUES LESS THAN ' at line 3 +CREATE TABLE t1 ( f1 INTEGER, f2 char(20)) +PARTITION BY HASH(f1) PARTITIONS "GARBAGE"; +ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '"GARBAGE"' at line 2 +CREATE TABLE t1 ( f1 INTEGER, f2 char(20)) +PARTITION BY RANGE(f1) SUBPARTITION BY HASH(f1) +SUBPARTITIONS "GARBAGE" +(PARTITION part1 VALUES LESS THAN (1000), PARTITION part2 VALUES LESS THAN (2147483647)); +ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '"GARBAGE" +(PARTITION part1 VALUES LESS THAN (1000), PARTITION part2 VALUES LESS ' at line 3 +# 3.3 Mixups of number and names of partition/subpartition assigned +# 3.3.1 (positive) number of partition/subpartition = number of named partition/subpartition +CREATE TABLE t1 ( f1 INTEGER, f2 char(20)) +PARTITION BY HASH(f1) PARTITIONS 2 ( PARTITION part1, PARTITION part2 ) ; +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `f1` int(11) default NULL, + `f2` char(20) default NULL +) ENGINE=ndbcluster DEFAULT CHARSET=latin1 PARTITION BY HASH (f1) (PARTITION part1 ENGINE = ndbcluster, PARTITION part2 ENGINE = ndbcluster) +DROP TABLE t1; +CREATE TABLE t1 ( f1 INTEGER, f2 char(20)) +PARTITION BY RANGE(f1) PARTITIONS 2 +SUBPARTITION BY HASH(f1) SUBPARTITIONS 2 +( PARTITION part1 VALUES LESS THAN (1000) +(SUBPARTITION subpart11, SUBPARTITION subpart12), +PARTITION part2 VALUES LESS THAN (2147483647) +(SUBPARTITION subpart21, SUBPARTITION subpart22) +); +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `f1` int(11) default NULL, + `f2` char(20) default NULL +) ENGINE=ndbcluster DEFAULT CHARSET=latin1 PARTITION BY RANGE (f1) SUBPARTITION BY HASH (f1) (PARTITION part1 VALUES LESS THAN (1000) (SUBPARTITION subpart11 ENGINE = ndbcluster, SUBPARTITION subpart12 ENGINE = ndbcluster), PARTITION part2 VALUES LESS THAN (2147483647) (SUBPARTITION subpart21 ENGINE = ndbcluster, SUBPARTITION subpart22 ENGINE = ndbcluster)) +DROP TABLE t1; +# 3.3.2 (positive) number of partition/subpartition , 0 (= no) named partition/subpartition +# already checked above +# 3.3.3 (negative) number of partitions > number of named partitions +CREATE TABLE t1 ( f1 INTEGER, f2 char(20)) +PARTITION BY HASH(f1) PARTITIONS 2 ( PARTITION part1 ) ; +ERROR 42000: Wrong number of partitions defined, mismatch with previous setting near ')' at line 2 +CREATE TABLE t1 ( f1 INTEGER, f2 char(20)) +PARTITION BY RANGE(f1) +SUBPARTITION BY HASH(f1) SUBPARTITIONS 2 +( PARTITION part1 VALUES LESS THAN (1000) +(SUBPARTITION subpart11 ), +PARTITION part2 VALUES LESS THAN (2147483647) +(SUBPARTITION subpart21, SUBPARTITION subpart22) +); +ERROR 42000: Wrong number of subpartitions defined, mismatch with previous setting near '), +PARTITION part2 VALUES LESS THAN (2147483647) +(SUBPARTITION subpart21, SUBPAR' at line 5 +CREATE TABLE t1 ( f1 INTEGER, f2 char(20)) +PARTITION BY RANGE(f1) +SUBPARTITION BY HASH(f1) SUBPARTITIONS 2 +( PARTITION part1 VALUES LESS THAN (1000) +(SUBPARTITION subpart11, SUBPARTITION subpart12), +PARTITION part2 VALUES LESS THAN (2000) +(SUBPARTITION subpart21 ), +PARTITION part3 VALUES LESS THAN (2147483647) +(SUBPARTITION subpart31, SUBPARTITION subpart32) +); +ERROR 42000: Wrong number of subpartitions defined, mismatch with previous setting near '), +PARTITION part3 VALUES LESS THAN (2147483647) +(SUBPARTITION subpart31, SUBPAR' at line 7 +CREATE TABLE t1 ( f1 INTEGER, f2 char(20)) +PARTITION BY RANGE(f1) PARTITIONS 2 +SUBPARTITION BY HASH(f1) SUBPARTITIONS 2 +( PARTITION part1 VALUES LESS THAN (1000) +(SUBPARTITION subpart11, SUBPARTITION subpart12), +PARTITION part2 VALUES LESS THAN (2147483647) +(SUBPARTITION subpart21 ) +); +ERROR 42000: Wrong number of subpartitions defined, mismatch with previous setting near ') +)' at line 7 +#------------------------------------------------------------------------ +# 4. Checks of logical partition/subpartition name +# file name clashes during CREATE TABLE +#------------------------------------------------------------------------ +CREATE TABLE t1 ( f1 INTEGER, f2 char(20)) +PARTITION BY HASH(f1) (PARTITION part1, PARTITION part1); +ERROR HY000: Duplicate partition name part1 +#------------------------------------------------------------------------ +# 5. Alter table experiments +#------------------------------------------------------------------------ +# 5.1 alter table add partition +# 5.1.1 (negative) add partition to non partitioned table +CREATE TABLE t1 ( f1 INTEGER, f2 char(20)); +# FIXME Why does the error numbers of MyISAM(1482) and NDB(1005) differ ? +ALTER TABLE t1 ADD PARTITION (PARTITION part1); +Got one of the listed errors +DROP TABLE t1; +# 5.1.2 Add one partition to a table with one partition +CREATE TABLE t1 ( f1 INTEGER, f2 char(20)) +PARTITION BY HASH(f1); +INSERT INTO t1 SELECT * FROM t0_template WHERE f1 BETWEEN 1 AND 100; diff --git a/mysql-test/suite/ndb/r/ps_7ndb.result b/mysql-test/suite/ndb/r/ps_7ndb.result new file mode 100644 index 00000000000..82d2d14b075 --- /dev/null +++ b/mysql-test/suite/ndb/r/ps_7ndb.result @@ -0,0 +1,3127 @@ +use test; +drop table if exists t1, t9 ; +create table t1 +( +a int, b varchar(30), +primary key(a) +) engine = 'NDB' ; +create table t9 +( +c1 tinyint, c2 smallint, c3 mediumint, c4 int, +c5 integer, c6 bigint, c7 float, c8 double, +c9 double precision, c10 real, c11 decimal(7, 4), c12 numeric(8, 4), +c13 date, c14 datetime, c15 timestamp, c16 time, +c17 year, c18 tinyint, c19 bool, c20 char, +c21 char(10), c22 varchar(30), c23 tinyblob, c24 tinytext, +c25 blob, c26 text, c27 mediumblob, c28 mediumtext, +c29 longblob, c30 longtext, c31 enum('one', 'two', 'three'), +c32 set('monday', 'tuesday', 'wednesday'), +primary key(c1) +) engine = 'NDB' ; +delete from t1 ; +insert into t1 values (1,'one'); +insert into t1 values (2,'two'); +insert into t1 values (3,'three'); +insert into t1 values (4,'four'); +commit ; +delete from t9 ; +insert into t9 +set c1= 1, c2= 1, c3= 1, c4= 1, c5= 1, c6= 1, c7= 1, c8= 1, c9= 1, +c10= 1, c11= 1, c12 = 1, +c13= '2004-02-29', c14= '2004-02-29 11:11:11', c15= '2004-02-29 11:11:11', +c16= '11:11:11', c17= '2004', +c18= 1, c19=true, c20= 'a', c21= '123456789a', +c22= '123456789a123456789b123456789c', c23= 'tinyblob', c24= 'tinytext', +c25= 'blob', c26= 'text', c27= 'mediumblob', c28= 'mediumtext', +c29= 'longblob', c30= 'longtext', c31='one', c32= 'monday'; +insert into t9 +set c1= 9, c2= 9, c3= 9, c4= 9, c5= 9, c6= 9, c7= 9, c8= 9, c9= 9, +c10= 9, c11= 9, c12 = 9, +c13= '2004-02-29', c14= '2004-02-29 11:11:11', c15= '2004-02-29 11:11:11', +c16= '11:11:11', c17= '2004', +c18= 1, c19=false, c20= 'a', c21= '123456789a', +c22= '123456789a123456789b123456789c', c23= 'tinyblob', c24= 'tinytext', +c25= 'blob', c26= 'text', c27= 'mediumblob', c28= 'mediumtext', +c29= 'longblob', c30= 'longtext', c31='two', c32= 'tuesday'; +commit ; +test_sequence +------ simple select tests ------ +prepare stmt1 from ' select * from t9 order by c1 ' ; +execute stmt1; +Catalog Database Table Table_alias Column Column_alias Type Length Max length Is_null Flags Decimals Charsetnr +def test t9 t9 c1 c1 1 4 1 N 49155 0 63 +def test t9 t9 c2 c2 2 6 1 Y 32768 0 63 +def test t9 t9 c3 c3 9 9 1 Y 32768 0 63 +def test t9 t9 c4 c4 3 11 1 Y 32768 0 63 +def test t9 t9 c5 c5 3 11 1 Y 32768 0 63 +def test t9 t9 c6 c6 8 20 1 Y 32768 0 63 +def test t9 t9 c7 c7 4 12 1 Y 32768 31 63 +def test t9 t9 c8 c8 5 22 1 Y 32768 31 63 +def test t9 t9 c9 c9 5 22 1 Y 32768 31 63 +def test t9 t9 c10 c10 5 22 1 Y 32768 31 63 +def test t9 t9 c11 c11 246 9 6 Y 0 4 63 +def test t9 t9 c12 c12 246 10 6 Y 0 4 63 +def test t9 t9 c13 c13 10 10 10 Y 128 0 63 +def test t9 t9 c14 c14 12 19 19 Y 128 0 63 +def test t9 t9 c15 c15 7 19 19 N 1249 0 63 +def test t9 t9 c16 c16 11 8 8 Y 128 0 63 +def test t9 t9 c17 c17 13 4 4 Y 32864 0 63 +def test t9 t9 c18 c18 1 4 1 Y 32768 0 63 +def test t9 t9 c19 c19 1 1 1 Y 32768 0 63 +def test t9 t9 c20 c20 254 1 1 Y 0 0 8 +def test t9 t9 c21 c21 254 10 10 Y 0 0 8 +def test t9 t9 c22 c22 253 30 30 Y 0 0 8 +def test t9 t9 c23 c23 252 255 8 Y 144 0 63 +def test t9 t9 c24 c24 252 255 8 Y 16 0 8 +def test t9 t9 c25 c25 252 65535 4 Y 144 0 63 +def test t9 t9 c26 c26 252 65535 4 Y 16 0 8 +def test t9 t9 c27 c27 252 16777215 10 Y 144 0 63 +def test t9 t9 c28 c28 252 16777215 10 Y 16 0 8 +def test t9 t9 c29 c29 252 4294967295 8 Y 144 0 63 +def test t9 t9 c30 c30 252 4294967295 8 Y 16 0 8 +def test t9 t9 c31 c31 254 5 3 Y 256 0 8 +def test t9 t9 c32 c32 254 24 7 Y 2048 0 8 +c1 c2 c3 c4 c5 c6 c7 c8 c9 c10 c11 c12 c13 c14 c15 c16 c17 c18 c19 c20 c21 c22 c23 c24 c25 c26 c27 c28 c29 c30 c31 c32 +1 1 1 1 1 1 1 1 1 1 1.0000 1.0000 2004-02-29 2004-02-29 11:11:11 2004-02-29 11:11:11 11:11:11 2004 1 1 a 123456789a 123456789a123456789b123456789c tinyblob tinytext blob text mediumblob mediumtext longblob longtext one monday +9 9 9 9 9 9 9 9 9 9 9.0000 9.0000 2004-02-29 2004-02-29 11:11:11 2004-02-29 11:11:11 11:11:11 2004 1 0 a 123456789a 123456789a123456789b123456789c tinyblob tinytext blob text mediumblob mediumtext longblob longtext two tuesday +set @arg00='SELECT' ; +@arg00 a from t1 where a=1; +ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '@arg00 a from t1 where a=1' at line 1 +prepare stmt1 from ' ? a from t1 where a=1 '; +ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '? a from t1 where a=1' at line 1 +set @arg00=1 ; +select @arg00, b from t1 where a=1 ; +@arg00 b +1 one +prepare stmt1 from ' select ?, b from t1 where a=1 ' ; +execute stmt1 using @arg00 ; +? b +1 one +set @arg00='lion' ; +select @arg00, b from t1 where a=1 ; +@arg00 b +lion one +prepare stmt1 from ' select ?, b from t1 where a=1 ' ; +execute stmt1 using @arg00 ; +? b +lion one +set @arg00=NULL ; +select @arg00, b from t1 where a=1 ; +@arg00 b +NULL one +prepare stmt1 from ' select ?, b from t1 where a=1 ' ; +execute stmt1 using @arg00 ; +? b +NULL one +set @arg00=1 ; +select b, a - @arg00 from t1 where a=1 ; +b a - @arg00 +one 0 +prepare stmt1 from ' select b, a - ? from t1 where a=1 ' ; +execute stmt1 using @arg00 ; +b a - ? +one 0 +set @arg00=null ; +select @arg00 as my_col ; +my_col +NULL +prepare stmt1 from ' select ? as my_col'; +execute stmt1 using @arg00 ; +my_col +NULL +select @arg00 + 1 as my_col ; +my_col +NULL +prepare stmt1 from ' select ? + 1 as my_col'; +execute stmt1 using @arg00 ; +my_col +NULL +select 1 + @arg00 as my_col ; +my_col +NULL +prepare stmt1 from ' select 1 + ? as my_col'; +execute stmt1 using @arg00 ; +my_col +NULL +set @arg00='MySQL' ; +select substr(@arg00,1,2) from t1 where a=1 ; +substr(@arg00,1,2) +My +prepare stmt1 from ' select substr(?,1,2) from t1 where a=1 ' ; +execute stmt1 using @arg00 ; +substr(?,1,2) +My +set @arg00=3 ; +select substr('MySQL',@arg00,5) from t1 where a=1 ; +substr('MySQL',@arg00,5) +SQL +prepare stmt1 from ' select substr(''MySQL'',?,5) from t1 where a=1 ' ; +execute stmt1 using @arg00 ; +substr('MySQL',?,5) +SQL +select substr('MySQL',1,@arg00) from t1 where a=1 ; +substr('MySQL',1,@arg00) +MyS +prepare stmt1 from ' select substr(''MySQL'',1,?) from t1 where a=1 ' ; +execute stmt1 using @arg00 ; +substr('MySQL',1,?) +MyS +set @arg00='MySQL' ; +select a , concat(@arg00,b) from t1 order by a; +a concat(@arg00,b) +1 MySQLone +2 MySQLtwo +3 MySQLthree +4 MySQLfour +prepare stmt1 from ' select a , concat(?,b) from t1 order by a ' ; +execute stmt1 using @arg00; +a concat(?,b) +1 MySQLone +2 MySQLtwo +3 MySQLthree +4 MySQLfour +select a , concat(b,@arg00) from t1 order by a ; +a concat(b,@arg00) +1 oneMySQL +2 twoMySQL +3 threeMySQL +4 fourMySQL +prepare stmt1 from ' select a , concat(b,?) from t1 order by a ' ; +execute stmt1 using @arg00; +a concat(b,?) +1 oneMySQL +2 twoMySQL +3 threeMySQL +4 fourMySQL +set @arg00='MySQL' ; +select group_concat(@arg00,b order by a) from t1 +group by 'a' ; +group_concat(@arg00,b order by a) +MySQLone,MySQLtwo,MySQLthree,MySQLfour +prepare stmt1 from ' select group_concat(?,b order by a) from t1 +group by ''a'' ' ; +execute stmt1 using @arg00; +group_concat(?,b order by a) +MySQLone,MySQLtwo,MySQLthree,MySQLfour +select group_concat(b,@arg00 order by a) from t1 +group by 'a' ; +group_concat(b,@arg00 order by a) +oneMySQL,twoMySQL,threeMySQL,fourMySQL +prepare stmt1 from ' select group_concat(b,? order by a) from t1 +group by ''a'' ' ; +execute stmt1 using @arg00; +group_concat(b,? order by a) +oneMySQL,twoMySQL,threeMySQL,fourMySQL +set @arg00='first' ; +set @arg01='second' ; +set @arg02=NULL; +select @arg00, @arg01 from t1 where a=1 ; +@arg00 @arg01 +first second +prepare stmt1 from ' select ?, ? from t1 where a=1 ' ; +execute stmt1 using @arg00, @arg01 ; +? ? +first second +execute stmt1 using @arg02, @arg01 ; +? ? +NULL second +execute stmt1 using @arg00, @arg02 ; +? ? +first NULL +execute stmt1 using @arg02, @arg02 ; +? ? +NULL NULL +drop table if exists t5 ; +create table t5 (id1 int(11) not null default '0', +value2 varchar(100), value1 varchar(100)) ; +insert into t5 values (1,'hh','hh'),(2,'hh','hh'), +(1,'ii','ii'),(2,'ii','ii') ; +prepare stmt1 from ' select id1,value1 from t5 where id1=? or value1=? order by id1,value1 ' ; +set @arg00=1 ; +set @arg01='hh' ; +execute stmt1 using @arg00, @arg01 ; +id1 value1 +1 hh +1 ii +2 hh +drop table t5 ; +drop table if exists t5 ; +create table t5(session_id char(9) not null) ; +insert into t5 values ('abc') ; +prepare stmt1 from ' select * from t5 +where ?=''1111'' and session_id = ''abc'' ' ; +set @arg00='abc' ; +execute stmt1 using @arg00 ; +session_id +set @arg00='1111' ; +execute stmt1 using @arg00 ; +session_id +abc +set @arg00='abc' ; +execute stmt1 using @arg00 ; +session_id +drop table t5 ; +set @arg00='FROM' ; +select a @arg00 t1 where a=1 ; +ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '@arg00 t1 where a=1' at line 1 +prepare stmt1 from ' select a ? t1 where a=1 ' ; +ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '? t1 where a=1' at line 1 +set @arg00='t1' ; +select a from @arg00 where a=1 ; +ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '@arg00 where a=1' at line 1 +prepare stmt1 from ' select a from ? where a=1 ' ; +ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '? where a=1' at line 1 +set @arg00='WHERE' ; +select a from t1 @arg00 a=1 ; +ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '@arg00 a=1' at line 1 +prepare stmt1 from ' select a from t1 ? a=1 ' ; +ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '? a=1' at line 1 +set @arg00=1 ; +select a FROM t1 where a=@arg00 ; +a +1 +prepare stmt1 from ' select a FROM t1 where a=? ' ; +execute stmt1 using @arg00 ; +a +1 +set @arg00=1000 ; +execute stmt1 using @arg00 ; +a +set @arg00=NULL ; +select a FROM t1 where a=@arg00 ; +a +prepare stmt1 from ' select a FROM t1 where a=? ' ; +execute stmt1 using @arg00 ; +a +set @arg00=4 ; +select a FROM t1 where a=sqrt(@arg00) ; +a +2 +prepare stmt1 from ' select a FROM t1 where a=sqrt(?) ' ; +execute stmt1 using @arg00 ; +a +2 +set @arg00=NULL ; +select a FROM t1 where a=sqrt(@arg00) ; +a +prepare stmt1 from ' select a FROM t1 where a=sqrt(?) ' ; +execute stmt1 using @arg00 ; +a +set @arg00=2 ; +set @arg01=3 ; +select a FROM t1 where a in (@arg00,@arg01) order by a; +a +2 +3 +prepare stmt1 from ' select a FROM t1 where a in (?,?) order by a '; +execute stmt1 using @arg00, @arg01; +a +2 +3 +set @arg00= 'one' ; +set @arg01= 'two' ; +set @arg02= 'five' ; +prepare stmt1 from ' select b FROM t1 where b in (?,?,?) order by b ' ; +execute stmt1 using @arg00, @arg01, @arg02 ; +b +one +two +prepare stmt1 from ' select b FROM t1 where b like ? '; +set @arg00='two' ; +execute stmt1 using @arg00 ; +b +two +set @arg00='tw%' ; +execute stmt1 using @arg00 ; +b +two +set @arg00='%wo' ; +execute stmt1 using @arg00 ; +b +two +set @arg00=null ; +insert into t9 set c1= 0, c5 = NULL ; +select c5 from t9 where c5 > NULL ; +c5 +prepare stmt1 from ' select c5 from t9 where c5 > ? '; +execute stmt1 using @arg00 ; +c5 +select c5 from t9 where c5 < NULL ; +c5 +prepare stmt1 from ' select c5 from t9 where c5 < ? '; +execute stmt1 using @arg00 ; +c5 +select c5 from t9 where c5 = NULL ; +c5 +prepare stmt1 from ' select c5 from t9 where c5 = ? '; +execute stmt1 using @arg00 ; +c5 +select c5 from t9 where c5 <=> NULL ; +c5 +NULL +prepare stmt1 from ' select c5 from t9 where c5 <=> ? '; +execute stmt1 using @arg00 ; +c5 +NULL +delete from t9 where c1= 0 ; +set @arg00='>' ; +select a FROM t1 where a @arg00 1 ; +ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '@arg00 1' at line 1 +prepare stmt1 from ' select a FROM t1 where a ? 1 ' ; +ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '? 1' at line 1 +set @arg00=1 ; +select a,b FROM t1 where a is not NULL +AND b is not NULL group by a - @arg00 ; +a b +1 one +2 two +3 three +4 four +prepare stmt1 from ' select a,b FROM t1 where a is not NULL +AND b is not NULL group by a - ? ' ; +execute stmt1 using @arg00 ; +a b +1 one +2 two +3 three +4 four +set @arg00='two' ; +select a,b FROM t1 where a is not NULL +AND b is not NULL having b <> @arg00 order by a ; +a b +1 one +3 three +4 four +prepare stmt1 from ' select a,b FROM t1 where a is not NULL +AND b is not NULL having b <> ? order by a ' ; +execute stmt1 using @arg00 ; +a b +1 one +3 three +4 four +set @arg00=1 ; +select a,b FROM t1 where a is not NULL +AND b is not NULL order by a - @arg00 ; +a b +1 one +2 two +3 three +4 four +prepare stmt1 from ' select a,b FROM t1 where a is not NULL +AND b is not NULL order by a - ? ' ; +execute stmt1 using @arg00 ; +a b +1 one +2 two +3 three +4 four +set @arg00=2 ; +select a,b from t1 order by 2 ; +a b +4 four +1 one +3 three +2 two +prepare stmt1 from ' select a,b from t1 +order by ? '; +execute stmt1 using @arg00; +a b +4 four +1 one +3 three +2 two +set @arg00=1 ; +execute stmt1 using @arg00; +a b +1 one +2 two +3 three +4 four +set @arg00=0 ; +execute stmt1 using @arg00; +ERROR 42S22: Unknown column '?' in 'order clause' +set @arg00=1; +prepare stmt1 from ' select a,b from t1 order by a +limit 1 '; +execute stmt1 ; +a b +1 one +prepare stmt1 from ' select a,b from t1 order by a limit ? '; +execute stmt1 using @arg00; +a b +1 one +set @arg00='b' ; +set @arg01=0 ; +set @arg02=2 ; +set @arg03=2 ; +select sum(a), @arg00 from t1 where a > @arg01 +and b is not null group by substr(b,@arg02) +having sum(a) <> @arg03 ; +sum(a) @arg00 +3 b +1 b +4 b +prepare stmt1 from ' select sum(a), ? from t1 where a > ? +and b is not null group by substr(b,?) +having sum(a) <> ? '; +execute stmt1 using @arg00, @arg01, @arg02, @arg03; +sum(a) ? +3 b +1 b +4 b +test_sequence +------ join tests ------ +select first.a as a1, second.a as a2 +from t1 first, t1 second +where first.a = second.a order by a1 ; +a1 a2 +1 1 +2 2 +3 3 +4 4 +prepare stmt1 from ' select first.a as a1, second.a as a2 + from t1 first, t1 second + where first.a = second.a order by a1 '; +execute stmt1 ; +a1 a2 +1 1 +2 2 +3 3 +4 4 +set @arg00='ABC'; +set @arg01='two'; +set @arg02='one'; +select first.a, @arg00, second.a FROM t1 first, t1 second +where @arg01 = first.b or first.a = second.a or second.b = @arg02 +order by second.a, first.a; +a @arg00 a +1 ABC 1 +2 ABC 1 +3 ABC 1 +4 ABC 1 +2 ABC 2 +2 ABC 3 +3 ABC 3 +2 ABC 4 +4 ABC 4 +prepare stmt1 from ' select first.a, ?, second.a FROM t1 first, t1 second + where ? = first.b or first.a = second.a or second.b = ? + order by second.a, first.a'; +execute stmt1 using @arg00, @arg01, @arg02; +a ? a +1 ABC 1 +2 ABC 1 +3 ABC 1 +4 ABC 1 +2 ABC 2 +2 ABC 3 +3 ABC 3 +2 ABC 4 +4 ABC 4 +drop table if exists t2 ; +create table t2 as select * from t1 ; +set @query1= 'SELECT * FROM t2 join t1 on (t1.a=t2.a) order by t2.a ' ; +set @query2= 'SELECT * FROM t2 natural join t1 order by t2.a ' ; +set @query3= 'SELECT * FROM t2 join t1 using(a) order by t2.a ' ; +set @query4= 'SELECT * FROM t2 left join t1 on(t1.a=t2.a) order by t2.a ' ; +set @query5= 'SELECT * FROM t2 natural left join t1 order by t2.a ' ; +set @query6= 'SELECT * FROM t2 left join t1 using(a) order by t2.a ' ; +set @query7= 'SELECT * FROM t2 right join t1 on(t1.a=t2.a) order by t2.a ' ; +set @query8= 'SELECT * FROM t2 natural right join t1 order by t2.a ' ; +set @query9= 'SELECT * FROM t2 right join t1 using(a) order by t2.a ' ; +the join statement is: +SELECT * FROM t2 right join t1 using(a) order by t2.a +prepare stmt1 from @query9 ; +execute stmt1 ; +a b b +1 one one +2 two two +3 three three +4 four four +execute stmt1 ; +a b b +1 one one +2 two two +3 three three +4 four four +execute stmt1 ; +a b b +1 one one +2 two two +3 three three +4 four four +the join statement is: +SELECT * FROM t2 natural right join t1 order by t2.a +prepare stmt1 from @query8 ; +execute stmt1 ; +a b +1 one +2 two +3 three +4 four +execute stmt1 ; +a b +1 one +2 two +3 three +4 four +execute stmt1 ; +a b +1 one +2 two +3 three +4 four +the join statement is: +SELECT * FROM t2 right join t1 on(t1.a=t2.a) order by t2.a +prepare stmt1 from @query7 ; +execute stmt1 ; +a b a b +1 one 1 one +2 two 2 two +3 three 3 three +4 four 4 four +execute stmt1 ; +a b a b +1 one 1 one +2 two 2 two +3 three 3 three +4 four 4 four +execute stmt1 ; +a b a b +1 one 1 one +2 two 2 two +3 three 3 three +4 four 4 four +the join statement is: +SELECT * FROM t2 left join t1 using(a) order by t2.a +prepare stmt1 from @query6 ; +execute stmt1 ; +a b b +1 one one +2 two two +3 three three +4 four four +execute stmt1 ; +a b b +1 one one +2 two two +3 three three +4 four four +execute stmt1 ; +a b b +1 one one +2 two two +3 three three +4 four four +the join statement is: +SELECT * FROM t2 natural left join t1 order by t2.a +prepare stmt1 from @query5 ; +execute stmt1 ; +a b +1 one +2 two +3 three +4 four +execute stmt1 ; +a b +1 one +2 two +3 three +4 four +execute stmt1 ; +a b +1 one +2 two +3 three +4 four +the join statement is: +SELECT * FROM t2 left join t1 on(t1.a=t2.a) order by t2.a +prepare stmt1 from @query4 ; +execute stmt1 ; +a b a b +1 one 1 one +2 two 2 two +3 three 3 three +4 four 4 four +execute stmt1 ; +a b a b +1 one 1 one +2 two 2 two +3 three 3 three +4 four 4 four +execute stmt1 ; +a b a b +1 one 1 one +2 two 2 two +3 three 3 three +4 four 4 four +the join statement is: +SELECT * FROM t2 join t1 using(a) order by t2.a +prepare stmt1 from @query3 ; +execute stmt1 ; +a b b +1 one one +2 two two +3 three three +4 four four +execute stmt1 ; +a b b +1 one one +2 two two +3 three three +4 four four +execute stmt1 ; +a b b +1 one one +2 two two +3 three three +4 four four +the join statement is: +SELECT * FROM t2 natural join t1 order by t2.a +prepare stmt1 from @query2 ; +execute stmt1 ; +a b +1 one +2 two +3 three +4 four +execute stmt1 ; +a b +1 one +2 two +3 three +4 four +execute stmt1 ; +a b +1 one +2 two +3 three +4 four +the join statement is: +SELECT * FROM t2 join t1 on (t1.a=t2.a) order by t2.a +prepare stmt1 from @query1 ; +execute stmt1 ; +a b a b +1 one 1 one +2 two 2 two +3 three 3 three +4 four 4 four +execute stmt1 ; +a b a b +1 one 1 one +2 two 2 two +3 three 3 three +4 four 4 four +execute stmt1 ; +a b a b +1 one 1 one +2 two 2 two +3 three 3 three +4 four 4 four +drop table t2 ; +test_sequence +------ subquery tests ------ +prepare stmt1 from ' select a, b FROM t1 outer_table where + a = (select a from t1 where b = ''two'') '; +execute stmt1 ; +a b +2 two +set @arg00='two' ; +select a, b FROM t1 outer_table where +a = (select a from t1 where b = 'two' ) and b=@arg00 ; +a b +2 two +prepare stmt1 from ' select a, b FROM t1 outer_table where + a = (select a from t1 where b = ''two'') and b=? '; +execute stmt1 using @arg00; +a b +2 two +set @arg00='two' ; +select a, b FROM t1 outer_table where +a = (select a from t1 where b = @arg00 ) and b='two' ; +a b +2 two +prepare stmt1 from ' select a, b FROM t1 outer_table where + a = (select a from t1 where b = ? ) and b=''two'' ' ; +execute stmt1 using @arg00; +a b +2 two +set @arg00=3 ; +set @arg01='three' ; +select a,b FROM t1 where (a,b) in (select 3, 'three'); +a b +3 three +select a FROM t1 where (a,b) in (select @arg00,@arg01); +a +3 +prepare stmt1 from ' select a FROM t1 where (a,b) in (select ?, ?) '; +execute stmt1 using @arg00, @arg01; +a +3 +set @arg00=1 ; +set @arg01='two' ; +set @arg02=2 ; +set @arg03='two' ; +select a, @arg00, b FROM t1 outer_table where +b=@arg01 and a = (select @arg02 from t1 where b = @arg03 ) ; +a @arg00 b +2 1 two +prepare stmt1 from ' select a, ?, b FROM t1 outer_table where + b=? and a = (select ? from t1 where b = ? ) ' ; +execute stmt1 using @arg00, @arg01, @arg02, @arg03 ; +a ? b +2 1 two +prepare stmt1 from 'select c4 FROM t9 where + c13 = (select MAX(b) from t1 where a = ?) and c22 = ? ' ; +execute stmt1 using @arg01, @arg02; +c4 +prepare stmt1 from ' select a, b FROM t1 outer_table where + a = (select a from t1 where b = outer_table.b ) order by a '; +execute stmt1 ; +a b +1 one +2 two +3 three +4 four +prepare stmt1 from ' SELECT a as ccc from t1 where a+1= + (SELECT 1+ccc from t1 where ccc+1=a+1 and a=1) '; +execute stmt1 ; +ccc +1 +deallocate prepare stmt1 ; +prepare stmt1 from ' SELECT a as ccc from t1 where a+1= + (SELECT 1+ccc from t1 where ccc+1=a+1 and a=1) '; +execute stmt1 ; +ccc +1 +deallocate prepare stmt1 ; +prepare stmt1 from ' SELECT a as ccc from t1 where a+1= + (SELECT 1+ccc from t1 where ccc+1=a+1 and a=1) '; +execute stmt1 ; +ccc +1 +deallocate prepare stmt1 ; +set @arg00='two' ; +select a, b FROM t1 outer_table where +a = (select a from t1 where b = outer_table.b ) and b=@arg00 ; +a b +2 two +prepare stmt1 from ' select a, b FROM t1 outer_table where + a = (select a from t1 where b = outer_table.b) and b=? '; +execute stmt1 using @arg00; +a b +2 two +set @arg00=2 ; +select a, b FROM t1 outer_table where +a = (select a from t1 where a = @arg00 and b = outer_table.b) and b='two' ; +a b +2 two +prepare stmt1 from ' select a, b FROM t1 outer_table where + a = (select a from t1 where a = ? and b = outer_table.b) and b=''two'' ' ; +execute stmt1 using @arg00; +a b +2 two +set @arg00=2 ; +select a, b FROM t1 outer_table where +a = (select a from t1 where outer_table.a = @arg00 and a=2) and b='two' ; +a b +2 two +prepare stmt1 from ' select a, b FROM t1 outer_table where + a = (select a from t1 where outer_table.a = ? and a=2) and b=''two'' ' ; +execute stmt1 using @arg00; +a b +2 two +set @arg00=1 ; +set @arg01='two' ; +set @arg02=2 ; +set @arg03='two' ; +select a, @arg00, b FROM t1 outer_table where +b=@arg01 and a = (select @arg02 from t1 where outer_table.b = @arg03 +and outer_table.a=a ) ; +a @arg00 b +2 1 two +prepare stmt1 from ' select a, ?, b FROM t1 outer_table where + b=? and a = (select ? from t1 where outer_table.b = ? + and outer_table.a=a ) ' ; +execute stmt1 using @arg00, @arg01, @arg02, @arg03 ; +a ? b +2 1 two +set @arg00=1 ; +set @arg01=0 ; +select a, @arg00 +from ( select a - @arg00 as a from t1 where a=@arg00 ) as t2 +where a=@arg01; +a @arg00 +0 1 +prepare stmt1 from ' select a, ? + from ( select a - ? as a from t1 where a=? ) as t2 + where a=? '; +execute stmt1 using @arg00, @arg00, @arg00, @arg01 ; +a ? +0 1 +drop table if exists t2 ; +create table t2 as select * from t1; +prepare stmt1 from ' select a in (select a from t2) from t1 ' ; +execute stmt1 ; +a in (select a from t2) +1 +1 +1 +1 +drop table if exists t5, t6, t7 ; +create table t5 (a int , b int) ; +create table t6 like t5 ; +create table t7 like t5 ; +insert into t5 values (0, 100), (1, 2), (1, 3), (2, 2), (2, 7), +(2, -1), (3, 10) ; +insert into t6 values (0, 0), (1, 1), (2, 1), (3, 1), (4, 1) ; +insert into t7 values (3, 3), (2, 2), (1, 1) ; +prepare stmt1 from ' select a, (select count(distinct t5.b) as sum from t5, t6 + where t5.a=t6.a and t6.b > 0 and t5.a <= t7.b + group by t5.a order by sum limit 1) from t7 ' ; +execute stmt1 ; +a (select count(distinct t5.b) as sum from t5, t6 + where t5.a=t6.a and t6.b > 0 and t5.a <= t7.b + group by t5.a order by sum limit 1) +3 1 +2 2 +1 2 +execute stmt1 ; +a (select count(distinct t5.b) as sum from t5, t6 + where t5.a=t6.a and t6.b > 0 and t5.a <= t7.b + group by t5.a order by sum limit 1) +3 1 +2 2 +1 2 +execute stmt1 ; +a (select count(distinct t5.b) as sum from t5, t6 + where t5.a=t6.a and t6.b > 0 and t5.a <= t7.b + group by t5.a order by sum limit 1) +3 1 +2 2 +1 2 +drop table t5, t6, t7 ; +drop table if exists t2 ; +create table t2 as select * from t9; +set @stmt= ' SELECT + (SELECT SUM(c1 + c12 + 0.0) FROM t2 + where (t9.c2 - 0e-3) = t2.c2 + GROUP BY t9.c15 LIMIT 1) as scalar_s, + exists (select 1.0e+0 from t2 + where t2.c3 * 9.0000000000 = t9.c4) as exists_s, + c5 * 4 in (select c6 + 0.3e+1 from t2) as in_s, + (c7 - 4, c8 - 4) in (select c9 + 4.0, c10 + 40e-1 from t2) as in_row_s +FROM t9, +(select c25 x, c32 y from t2) tt WHERE x = c25 ' ; +prepare stmt1 from @stmt ; +execute stmt1 ; +execute stmt1 ; +set @stmt= concat('explain ',@stmt); +prepare stmt1 from @stmt ; +execute stmt1 ; +execute stmt1 ; +set @stmt= ' SELECT + (SELECT SUM(c1+c12+?) FROM t2 where (t9.c2-?)=t2.c2 + GROUP BY t9.c15 LIMIT 1) as scalar_s, + exists (select ? from t2 + where t2.c3*?=t9.c4) as exists_s, + c5*? in (select c6+? from t2) as in_s, + (c7-?, c8-?) in (select c9+?, c10+? from t2) as in_row_s +FROM t9, +(select c25 x, c32 y from t2) tt WHERE x =c25 ' ; +set @arg00= 0.0 ; +set @arg01= 0e-3 ; +set @arg02= 1.0e+0 ; +set @arg03= 9.0000000000 ; +set @arg04= 4 ; +set @arg05= 0.3e+1 ; +set @arg06= 4 ; +set @arg07= 4 ; +set @arg08= 4.0 ; +set @arg09= 40e-1 ; +prepare stmt1 from @stmt ; +execute stmt1 using @arg00, @arg01, @arg02, @arg03, @arg04, @arg05, @arg06, +@arg07, @arg08, @arg09 ; +execute stmt1 using @arg00, @arg01, @arg02, @arg03, @arg04, @arg05, @arg06, +@arg07, @arg08, @arg09 ; +set @stmt= concat('explain ',@stmt); +prepare stmt1 from @stmt ; +execute stmt1 using @arg00, @arg01, @arg02, @arg03, @arg04, @arg05, @arg06, +@arg07, @arg08, @arg09 ; +execute stmt1 using @arg00, @arg01, @arg02, @arg03, @arg04, @arg05, @arg06, +@arg07, @arg08, @arg09 ; +drop table t2 ; +select 1 < (select a from t1) ; +ERROR 21000: Subquery returns more than 1 row +prepare stmt1 from ' select 1 < (select a from t1) ' ; +execute stmt1 ; +ERROR 21000: Subquery returns more than 1 row +select 1 as my_col ; +my_col +1 +test_sequence +------ union tests ------ +prepare stmt1 from ' select a FROM t1 where a=1 + union distinct + select a FROM t1 where a=1 '; +execute stmt1 ; +a +1 +execute stmt1 ; +a +1 +prepare stmt1 from ' select a FROM t1 where a=1 + union all + select a FROM t1 where a=1 '; +execute stmt1 ; +a +1 +1 +prepare stmt1 from ' SELECT 1, 2 union SELECT 1 ' ; +ERROR 21000: The used SELECT statements have a different number of columns +prepare stmt1 from ' SELECT 1 union SELECT 1, 2 ' ; +ERROR 21000: The used SELECT statements have a different number of columns +prepare stmt1 from ' SELECT * from t1 union SELECT 1 ' ; +ERROR 21000: The used SELECT statements have a different number of columns +prepare stmt1 from ' SELECT 1 union SELECT * from t1 ' ; +ERROR 21000: The used SELECT statements have a different number of columns +set @arg00=1 ; +select @arg00 FROM t1 where a=1 +union distinct +select 1 FROM t1 where a=1; +@arg00 +1 +prepare stmt1 from ' select ? FROM t1 where a=1 + union distinct + select 1 FROM t1 where a=1 ' ; +execute stmt1 using @arg00; +? +1 +set @arg00=1 ; +select 1 FROM t1 where a=1 +union distinct +select @arg00 FROM t1 where a=1; +1 +1 +prepare stmt1 from ' select 1 FROM t1 where a=1 + union distinct + select ? FROM t1 where a=1 ' ; +execute stmt1 using @arg00; +1 +1 +set @arg00='a' ; +select @arg00 FROM t1 where a=1 +union distinct +select @arg00 FROM t1 where a=1; +@arg00 +a +prepare stmt1 from ' select ? FROM t1 where a=1 + union distinct + select ? FROM t1 where a=1 '; +execute stmt1 using @arg00, @arg00; +? +a +prepare stmt1 from ' select ? + union distinct + select ? '; +execute stmt1 using @arg00, @arg00; +? +a +set @arg00='a' ; +set @arg01=1 ; +set @arg02='a' ; +set @arg03=2 ; +select @arg00 FROM t1 where a=@arg01 +union distinct +select @arg02 FROM t1 where a=@arg03; +@arg00 +a +prepare stmt1 from ' select ? FROM t1 where a=? + union distinct + select ? FROM t1 where a=? ' ; +execute stmt1 using @arg00, @arg01, @arg02, @arg03; +? +a +set @arg00=1 ; +prepare stmt1 from ' select sum(a) + 200, ? from t1 +union distinct +select sum(a) + 200, 1 from t1 +group by b ' ; +execute stmt1 using @arg00; +sum(a) + 200 ? +210 1 +204 1 +201 1 +203 1 +202 1 +set @Oporto='Oporto' ; +set @Lisboa='Lisboa' ; +set @0=0 ; +set @1=1 ; +set @2=2 ; +set @3=3 ; +set @4=4 ; +select @Oporto,@Lisboa,@0,@1,@2,@3,@4 ; +@Oporto @Lisboa @0 @1 @2 @3 @4 +Oporto Lisboa 0 1 2 3 4 +select sum(a) + 200 as the_sum, @Oporto as the_town from t1 +group by b +union distinct +select sum(a) + 200, @Lisboa from t1 +group by b ; +the_sum the_town +204 Oporto +201 Oporto +203 Oporto +202 Oporto +204 Lisboa +201 Lisboa +203 Lisboa +202 Lisboa +prepare stmt1 from ' select sum(a) + 200 as the_sum, ? as the_town from t1 + group by b + union distinct + select sum(a) + 200, ? from t1 + group by b ' ; +execute stmt1 using @Oporto, @Lisboa; +the_sum the_town +204 Oporto +201 Oporto +203 Oporto +202 Oporto +204 Lisboa +201 Lisboa +203 Lisboa +202 Lisboa +select sum(a) + 200 as the_sum, @Oporto as the_town from t1 +where a > @1 +group by b +union distinct +select sum(a) + 200, @Lisboa from t1 +where a > @2 +group by b ; +the_sum the_town +204 Oporto +203 Oporto +202 Oporto +204 Lisboa +203 Lisboa +prepare stmt1 from ' select sum(a) + 200 as the_sum, ? as the_town from t1 + where a > ? + group by b + union distinct + select sum(a) + 200, ? from t1 + where a > ? + group by b ' ; +execute stmt1 using @Oporto, @1, @Lisboa, @2; +the_sum the_town +204 Oporto +203 Oporto +202 Oporto +204 Lisboa +203 Lisboa +select sum(a) + 200 as the_sum, @Oporto as the_town from t1 +where a > @1 +group by b +having avg(a) > @2 +union distinct +select sum(a) + 200, @Lisboa from t1 +where a > @2 +group by b +having avg(a) > @3; +the_sum the_town +204 Oporto +203 Oporto +204 Lisboa +prepare stmt1 from ' select sum(a) + 200 as the_sum, ? as the_town from t1 + where a > ? + group by b + having avg(a) > ? + union distinct + select sum(a) + 200, ? from t1 + where a > ? + group by b + having avg(a) > ? '; +execute stmt1 using @Oporto, @1, @2, @Lisboa, @2, @3; +the_sum the_town +204 Oporto +203 Oporto +204 Lisboa +test_sequence +------ explain select tests ------ +prepare stmt1 from ' explain select * from t9 ' ; +execute stmt1; +Catalog Database Table Table_alias Column Column_alias Type Length Max length Is_null Flags Decimals Charsetnr +def id 8 3 1 N 32929 0 63 +def select_type 253 19 6 N 1 31 8 +def table 253 64 2 Y 0 31 8 +def type 253 10 3 Y 0 31 8 +def possible_keys 253 4096 0 Y 0 31 8 +def key 253 64 0 Y 0 31 8 +def key_len 253 1365 0 Y 0 31 8 +def ref 253 1024 0 Y 0 31 8 +def rows 8 10 1 Y 32928 0 63 +def Extra 253 255 0 N 1 31 8 +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t9 ALL NULL NULL NULL NULL 2 +test_sequence +------ delete tests ------ +delete from t1 ; +insert into t1 values (1,'one'); +insert into t1 values (2,'two'); +insert into t1 values (3,'three'); +insert into t1 values (4,'four'); +commit ; +delete from t9 ; +insert into t9 +set c1= 1, c2= 1, c3= 1, c4= 1, c5= 1, c6= 1, c7= 1, c8= 1, c9= 1, +c10= 1, c11= 1, c12 = 1, +c13= '2004-02-29', c14= '2004-02-29 11:11:11', c15= '2004-02-29 11:11:11', +c16= '11:11:11', c17= '2004', +c18= 1, c19=true, c20= 'a', c21= '123456789a', +c22= '123456789a123456789b123456789c', c23= 'tinyblob', c24= 'tinytext', +c25= 'blob', c26= 'text', c27= 'mediumblob', c28= 'mediumtext', +c29= 'longblob', c30= 'longtext', c31='one', c32= 'monday'; +insert into t9 +set c1= 9, c2= 9, c3= 9, c4= 9, c5= 9, c6= 9, c7= 9, c8= 9, c9= 9, +c10= 9, c11= 9, c12 = 9, +c13= '2004-02-29', c14= '2004-02-29 11:11:11', c15= '2004-02-29 11:11:11', +c16= '11:11:11', c17= '2004', +c18= 1, c19=false, c20= 'a', c21= '123456789a', +c22= '123456789a123456789b123456789c', c23= 'tinyblob', c24= 'tinytext', +c25= 'blob', c26= 'text', c27= 'mediumblob', c28= 'mediumtext', +c29= 'longblob', c30= 'longtext', c31='two', c32= 'tuesday'; +commit ; +prepare stmt1 from 'delete from t1 where a=2' ; +execute stmt1; +select a,b from t1 where a=2; +a b +execute stmt1; +insert into t1 values(0,NULL); +set @arg00=NULL; +prepare stmt1 from 'delete from t1 where b=?' ; +execute stmt1 using @arg00; +select a,b from t1 where b is NULL ; +a b +0 NULL +set @arg00='one'; +execute stmt1 using @arg00; +select a,b from t1 where b=@arg00; +a b +prepare stmt1 from 'truncate table t1' ; +test_sequence +------ update tests ------ +delete from t1 ; +insert into t1 values (1,'one'); +insert into t1 values (2,'two'); +insert into t1 values (3,'three'); +insert into t1 values (4,'four'); +commit ; +delete from t9 ; +insert into t9 +set c1= 1, c2= 1, c3= 1, c4= 1, c5= 1, c6= 1, c7= 1, c8= 1, c9= 1, +c10= 1, c11= 1, c12 = 1, +c13= '2004-02-29', c14= '2004-02-29 11:11:11', c15= '2004-02-29 11:11:11', +c16= '11:11:11', c17= '2004', +c18= 1, c19=true, c20= 'a', c21= '123456789a', +c22= '123456789a123456789b123456789c', c23= 'tinyblob', c24= 'tinytext', +c25= 'blob', c26= 'text', c27= 'mediumblob', c28= 'mediumtext', +c29= 'longblob', c30= 'longtext', c31='one', c32= 'monday'; +insert into t9 +set c1= 9, c2= 9, c3= 9, c4= 9, c5= 9, c6= 9, c7= 9, c8= 9, c9= 9, +c10= 9, c11= 9, c12 = 9, +c13= '2004-02-29', c14= '2004-02-29 11:11:11', c15= '2004-02-29 11:11:11', +c16= '11:11:11', c17= '2004', +c18= 1, c19=false, c20= 'a', c21= '123456789a', +c22= '123456789a123456789b123456789c', c23= 'tinyblob', c24= 'tinytext', +c25= 'blob', c26= 'text', c27= 'mediumblob', c28= 'mediumtext', +c29= 'longblob', c30= 'longtext', c31='two', c32= 'tuesday'; +commit ; +prepare stmt1 from 'update t1 set b=''a=two'' where a=2' ; +execute stmt1; +select a,b from t1 where a=2; +a b +2 a=two +execute stmt1; +select a,b from t1 where a=2; +a b +2 a=two +set @arg00=NULL; +prepare stmt1 from 'update t1 set b=? where a=2' ; +execute stmt1 using @arg00; +select a,b from t1 where a=2; +a b +2 NULL +set @arg00='two'; +execute stmt1 using @arg00; +select a,b from t1 where a=2; +a b +2 two +set @arg00=2; +prepare stmt1 from 'update t1 set b=NULL where a=?' ; +execute stmt1 using @arg00; +select a,b from t1 where a=@arg00; +a b +2 NULL +update t1 set b='two' where a=@arg00; +set @arg00=2000; +execute stmt1 using @arg00; +select a,b from t1 where a=@arg00; +a b +set @arg00=2; +set @arg01=22; +prepare stmt1 from 'update t1 set a=? where a=?' ; +execute stmt1 using @arg00, @arg00; +select a,b from t1 where a=@arg00; +a b +2 two +execute stmt1 using @arg01, @arg00; +select a,b from t1 where a=@arg01; +a b +22 two +execute stmt1 using @arg00, @arg01; +select a,b from t1 where a=@arg00; +a b +2 two +set @arg00=NULL; +set @arg01=2; +execute stmt1 using @arg00, @arg01; +Warnings: +Warning 1048 Column 'a' cannot be null +select a,b from t1 order by a; +a b +0 two +1 one +3 three +4 four +set @arg00=0; +execute stmt1 using @arg01, @arg00; +select a,b from t1 order by a; +a b +1 one +2 two +3 three +4 four +set @arg00=23; +set @arg01='two'; +set @arg02=2; +set @arg03='two'; +set @arg04=2; +drop table if exists t2; +create table t2 as select a,b from t1 ; +prepare stmt1 from 'update t1 set a=? where b=? + and a in (select ? from t2 + where b = ? or a = ?)'; +execute stmt1 using @arg00, @arg01, @arg02, @arg03, @arg04 ; +affected rows: 1 +info: Rows matched: 1 Changed: 1 Warnings: 0 +select a,b from t1 where a = @arg00 ; +a b +23 two +prepare stmt1 from 'update t1 set a=? where b=? + and a not in (select ? from t2 + where b = ? or a = ?)'; +execute stmt1 using @arg04, @arg01, @arg02, @arg03, @arg00 ; +affected rows: 1 +info: Rows matched: 1 Changed: 1 Warnings: 0 +select a,b from t1 order by a ; +a b +1 one +2 two +3 three +4 four +drop table t2 ; +create table t2 +( +a int, b varchar(30), +primary key(a) +) engine = 'NDB' ; +insert into t2(a,b) select a, b from t1 ; +prepare stmt1 from 'update t1 set a=? where b=? + and a in (select ? from t2 + where b = ? or a = ?)'; +execute stmt1 using @arg00, @arg01, @arg02, @arg03, @arg04 ; +affected rows: 1 +info: Rows matched: 1 Changed: 1 Warnings: 0 +select a,b from t1 where a = @arg00 ; +a b +23 two +prepare stmt1 from 'update t1 set a=? where b=? + and a not in (select ? from t2 + where b = ? or a = ?)'; +execute stmt1 using @arg04, @arg01, @arg02, @arg03, @arg00 ; +affected rows: 1 +info: Rows matched: 1 Changed: 1 Warnings: 0 +select a,b from t1 order by a ; +a b +1 one +2 two +3 three +4 four +drop table t2 ; +set @arg00=1; +prepare stmt1 from 'update t1 set b=''bla'' +where a=2 +limit 1'; +execute stmt1 ; +select a,b from t1 where b = 'bla' ; +a b +2 bla +prepare stmt1 from 'update t1 set b=''bla'' where a=2 limit ?'; +execute stmt1 using @arg00; +test_sequence +------ insert tests ------ +delete from t1 ; +insert into t1 values (1,'one'); +insert into t1 values (2,'two'); +insert into t1 values (3,'three'); +insert into t1 values (4,'four'); +commit ; +delete from t9 ; +insert into t9 +set c1= 1, c2= 1, c3= 1, c4= 1, c5= 1, c6= 1, c7= 1, c8= 1, c9= 1, +c10= 1, c11= 1, c12 = 1, +c13= '2004-02-29', c14= '2004-02-29 11:11:11', c15= '2004-02-29 11:11:11', +c16= '11:11:11', c17= '2004', +c18= 1, c19=true, c20= 'a', c21= '123456789a', +c22= '123456789a123456789b123456789c', c23= 'tinyblob', c24= 'tinytext', +c25= 'blob', c26= 'text', c27= 'mediumblob', c28= 'mediumtext', +c29= 'longblob', c30= 'longtext', c31='one', c32= 'monday'; +insert into t9 +set c1= 9, c2= 9, c3= 9, c4= 9, c5= 9, c6= 9, c7= 9, c8= 9, c9= 9, +c10= 9, c11= 9, c12 = 9, +c13= '2004-02-29', c14= '2004-02-29 11:11:11', c15= '2004-02-29 11:11:11', +c16= '11:11:11', c17= '2004', +c18= 1, c19=false, c20= 'a', c21= '123456789a', +c22= '123456789a123456789b123456789c', c23= 'tinyblob', c24= 'tinytext', +c25= 'blob', c26= 'text', c27= 'mediumblob', c28= 'mediumtext', +c29= 'longblob', c30= 'longtext', c31='two', c32= 'tuesday'; +commit ; +prepare stmt1 from 'insert into t1 values(5, ''five'' )'; +execute stmt1; +select a,b from t1 where a = 5; +a b +5 five +set @arg00='six' ; +prepare stmt1 from 'insert into t1 values(6, ? )'; +execute stmt1 using @arg00; +select a,b from t1 where b = @arg00; +a b +6 six +execute stmt1 using @arg00; +ERROR 23000: Duplicate entry '6' for key 'PRIMARY' +set @arg00=NULL ; +prepare stmt1 from 'insert into t1 values(0, ? )'; +execute stmt1 using @arg00; +select a,b from t1 where b is NULL; +a b +0 NULL +set @arg00=8 ; +set @arg01='eight' ; +prepare stmt1 from 'insert into t1 values(?, ? )'; +execute stmt1 using @arg00, @arg01 ; +select a,b from t1 where b = @arg01; +a b +8 eight +set @NULL= null ; +set @arg00= 'abc' ; +execute stmt1 using @NULL, @NULL ; +ERROR 23000: Column 'a' cannot be null +execute stmt1 using @NULL, @NULL ; +ERROR 23000: Column 'a' cannot be null +execute stmt1 using @NULL, @arg00 ; +ERROR 23000: Column 'a' cannot be null +execute stmt1 using @NULL, @arg00 ; +ERROR 23000: Column 'a' cannot be null +set @arg01= 10000 + 2 ; +execute stmt1 using @arg01, @arg00 ; +set @arg01= 10000 + 1 ; +execute stmt1 using @arg01, @arg00 ; +select * from t1 where a > 10000 order by a ; +a b +10001 abc +10002 abc +delete from t1 where a > 10000 ; +set @arg01= 10000 + 2 ; +execute stmt1 using @arg01, @NULL ; +set @arg01= 10000 + 1 ; +execute stmt1 using @arg01, @NULL ; +select * from t1 where a > 10000 order by a ; +a b +10001 NULL +10002 NULL +delete from t1 where a > 10000 ; +set @arg01= 10000 + 10 ; +execute stmt1 using @arg01, @arg01 ; +set @arg01= 10000 + 9 ; +execute stmt1 using @arg01, @arg01 ; +set @arg01= 10000 + 8 ; +execute stmt1 using @arg01, @arg01 ; +set @arg01= 10000 + 7 ; +execute stmt1 using @arg01, @arg01 ; +set @arg01= 10000 + 6 ; +execute stmt1 using @arg01, @arg01 ; +set @arg01= 10000 + 5 ; +execute stmt1 using @arg01, @arg01 ; +set @arg01= 10000 + 4 ; +execute stmt1 using @arg01, @arg01 ; +set @arg01= 10000 + 3 ; +execute stmt1 using @arg01, @arg01 ; +set @arg01= 10000 + 2 ; +execute stmt1 using @arg01, @arg01 ; +set @arg01= 10000 + 1 ; +execute stmt1 using @arg01, @arg01 ; +select * from t1 where a > 10000 order by a ; +a b +10001 10001 +10002 10002 +10003 10003 +10004 10004 +10005 10005 +10006 10006 +10007 10007 +10008 10008 +10009 10009 +10010 10010 +delete from t1 where a > 10000 ; +set @arg00=81 ; +set @arg01='8-1' ; +set @arg02=82 ; +set @arg03='8-2' ; +prepare stmt1 from 'insert into t1 values(?,?),(?,?)'; +execute stmt1 using @arg00, @arg01, @arg02, @arg03 ; +select a,b from t1 where a in (@arg00,@arg02) ; +a b +81 8-1 +82 8-2 +set @arg00=9 ; +set @arg01='nine' ; +prepare stmt1 from 'insert into t1 set a=?, b=? '; +execute stmt1 using @arg00, @arg01 ; +select a,b from t1 where a = @arg00 ; +a b +9 nine +set @arg00=6 ; +set @arg01=1 ; +prepare stmt1 from 'insert into t1 set a=?, b=''sechs'' + on duplicate key update a=a + ?, b=concat(b,''modified'') '; +execute stmt1 using @arg00, @arg01; +select * from t1 order by a; +a b +0 NULL +1 one +2 two +3 three +4 four +5 five +7 sixmodified +8 eight +9 nine +81 8-1 +82 8-2 +set @arg00=81 ; +set @arg01=1 ; +execute stmt1 using @arg00, @arg01; +ERROR 23000: Duplicate entry '82' for key 'PRIMARY' +drop table if exists t2 ; +create table t2 (id int auto_increment primary key) +ENGINE= 'NDB' ; +prepare stmt1 from ' select last_insert_id() ' ; +insert into t2 values (NULL) ; +execute stmt1 ; +last_insert_id() +1 +insert into t2 values (NULL) ; +execute stmt1 ; +last_insert_id() +2 +drop table t2 ; +set @1000=1000 ; +set @x1000_2="x1000_2" ; +set @x1000_3="x1000_3" ; +set @x1000="x1000" ; +set @1100=1100 ; +set @x1100="x1100" ; +set @100=100 ; +set @updated="updated" ; +insert into t1 values(1000,'x1000_1') ; +insert into t1 values(@1000,@x1000_2),(@1000,@x1000_3) +on duplicate key update a = a + @100, b = concat(b,@updated) ; +select a,b from t1 where a >= 1000 order by a ; +a b +1000 x1000_3 +1100 x1000_1updated +delete from t1 where a >= 1000 ; +insert into t1 values(1000,'x1000_1') ; +prepare stmt1 from ' insert into t1 values(?,?),(?,?) + on duplicate key update a = a + ?, b = concat(b,?) '; +execute stmt1 using @1000, @x1000_2, @1000, @x1000_3, @100, @updated ; +select a,b from t1 where a >= 1000 order by a ; +a b +1000 x1000_3 +1100 x1000_1updated +delete from t1 where a >= 1000 ; +insert into t1 values(1000,'x1000_1') ; +execute stmt1 using @1000, @x1000_2, @1100, @x1000_3, @100, @updated ; +select a,b from t1 where a >= 1000 order by a ; +a b +1200 x1000_1updatedupdated +delete from t1 where a >= 1000 ; +prepare stmt1 from ' replace into t1 (a,b) select 100, ''hundred'' '; +execute stmt1; +execute stmt1; +execute stmt1; +test_sequence +------ multi table tests ------ +delete from t1 ; +delete from t9 ; +insert into t1(a,b) values (1, 'one'), (2, 'two'), (3, 'three') ; +insert into t9 (c1,c21) +values (1, 'one'), (2, 'two'), (3, 'three') ; +prepare stmt_delete from " delete t1, t9 + from t1, t9 where t1.a=t9.c1 and t1.b='updated' "; +prepare stmt_update from " update t1, t9 + set t1.b='updated', t9.c21='updated' + where t1.a=t9.c1 and t1.a=? "; +prepare stmt_select1 from " select a, b from t1 order by a" ; +prepare stmt_select2 from " select c1, c21 from t9 order by c1" ; +set @arg00= 1 ; +execute stmt_update using @arg00 ; +execute stmt_delete ; +execute stmt_select1 ; +a b +2 two +3 three +execute stmt_select2 ; +c1 c21 +2 two +3 three +set @arg00= @arg00 + 1 ; +execute stmt_update using @arg00 ; +execute stmt_delete ; +execute stmt_select1 ; +a b +3 three +execute stmt_select2 ; +c1 c21 +3 three +set @arg00= @arg00 + 1 ; +execute stmt_update using @arg00 ; +execute stmt_delete ; +execute stmt_select1 ; +a b +execute stmt_select2 ; +c1 c21 +set @arg00= @arg00 + 1 ; +delete from t1 ; +insert into t1 values (1,'one'); +insert into t1 values (2,'two'); +insert into t1 values (3,'three'); +insert into t1 values (4,'four'); +commit ; +delete from t9 ; +insert into t9 +set c1= 1, c2= 1, c3= 1, c4= 1, c5= 1, c6= 1, c7= 1, c8= 1, c9= 1, +c10= 1, c11= 1, c12 = 1, +c13= '2004-02-29', c14= '2004-02-29 11:11:11', c15= '2004-02-29 11:11:11', +c16= '11:11:11', c17= '2004', +c18= 1, c19=true, c20= 'a', c21= '123456789a', +c22= '123456789a123456789b123456789c', c23= 'tinyblob', c24= 'tinytext', +c25= 'blob', c26= 'text', c27= 'mediumblob', c28= 'mediumtext', +c29= 'longblob', c30= 'longtext', c31='one', c32= 'monday'; +insert into t9 +set c1= 9, c2= 9, c3= 9, c4= 9, c5= 9, c6= 9, c7= 9, c8= 9, c9= 9, +c10= 9, c11= 9, c12 = 9, +c13= '2004-02-29', c14= '2004-02-29 11:11:11', c15= '2004-02-29 11:11:11', +c16= '11:11:11', c17= '2004', +c18= 1, c19=false, c20= 'a', c21= '123456789a', +c22= '123456789a123456789b123456789c', c23= 'tinyblob', c24= 'tinytext', +c25= 'blob', c26= 'text', c27= 'mediumblob', c28= 'mediumtext', +c29= 'longblob', c30= 'longtext', c31='two', c32= 'tuesday'; +commit ; +insert into t1 values(0,NULL) ; +set @duplicate='duplicate ' ; +set @1000=1000 ; +set @5=5 ; +select a,b from t1 where a < 5 order by a ; +a b +0 NULL +1 one +2 two +3 three +4 four +insert into t1 select a + @1000, concat(@duplicate,b) from t1 +where a < @5 ; +affected rows: 5 +info: Records: 5 Duplicates: 0 Warnings: 0 +select a,b from t1 where a >= 1000 order by a ; +a b +1000 NULL +1001 duplicate one +1002 duplicate two +1003 duplicate three +1004 duplicate four +delete from t1 where a >= 1000 ; +prepare stmt1 from ' insert into t1 select a + ?, concat(?,b) from t1 +where a < ? ' ; +execute stmt1 using @1000, @duplicate, @5; +affected rows: 5 +info: Records: 5 Duplicates: 0 Warnings: 0 +select a,b from t1 where a >= 1000 order by a ; +a b +1000 NULL +1001 duplicate one +1002 duplicate two +1003 duplicate three +1004 duplicate four +delete from t1 where a >= 1000 ; +set @1=1 ; +set @2=2 ; +set @100=100 ; +set @float=1.00; +set @five='five' ; +drop table if exists t2; +create table t2 like t1 ; +insert into t2 (b,a) +select @duplicate, sum(first.a) from t1 first, t1 second +where first.a <> @5 and second.b = first.b +and second.b <> @five +group by second.b +having sum(second.a) > @2 +union +select b, a + @100 from t1 +where (a,b) in ( select sqrt(a+@1)+CAST(@float AS signed),b +from t1); +affected rows: 3 +info: Records: 3 Duplicates: 0 Warnings: 0 +select a,b from t2 order by a ; +a b +3 duplicate +4 duplicate +103 three +delete from t2 ; +prepare stmt1 from ' insert into t2 (b,a) +select ?, sum(first.a) + from t1 first, t1 second + where first.a <> ? and second.b = first.b and second.b <> ? + group by second.b + having sum(second.a) > ? +union +select b, a + ? from t1 + where (a,b) in ( select sqrt(a+?)+CAST(? AS signed),b + from t1 ) ' ; +execute stmt1 using @duplicate, @5, @five, @2, @100, @1, @float ; +affected rows: 3 +info: Records: 3 Duplicates: 0 Warnings: 0 +select a,b from t2 order by a ; +a b +3 duplicate +4 duplicate +103 three +drop table t2; +drop table if exists t5 ; +set @arg01= 8; +set @arg02= 8.0; +set @arg03= 80.00000000000e-1; +set @arg04= 'abc' ; +set @arg05= CAST('abc' as binary) ; +set @arg06= '1991-08-05' ; +set @arg07= CAST('1991-08-05' as date); +set @arg08= '1991-08-05 01:01:01' ; +set @arg09= CAST('1991-08-05 01:01:01' as datetime) ; +set @arg10= unix_timestamp('1991-01-01 01:01:01'); +set @arg11= YEAR('1991-01-01 01:01:01'); +set @arg12= 8 ; +set @arg12= NULL ; +set @arg13= 8.0 ; +set @arg13= NULL ; +set @arg14= 'abc'; +set @arg14= NULL ; +set @arg15= CAST('abc' as binary) ; +set @arg15= NULL ; +create table t5 as select +8 as const01, @arg01 as param01, +8.0 as const02, @arg02 as param02, +80.00000000000e-1 as const03, @arg03 as param03, +'abc' as const04, @arg04 as param04, +CAST('abc' as binary) as const05, @arg05 as param05, +'1991-08-05' as const06, @arg06 as param06, +CAST('1991-08-05' as date) as const07, @arg07 as param07, +'1991-08-05 01:01:01' as const08, @arg08 as param08, +CAST('1991-08-05 01:01:01' as datetime) as const09, @arg09 as param09, +unix_timestamp('1991-01-01 01:01:01') as const10, @arg10 as param10, +YEAR('1991-01-01 01:01:01') as const11, @arg11 as param11, +NULL as const12, @arg12 as param12, +@arg13 as param13, +@arg14 as param14, +@arg15 as param15; +show create table t5 ; +Table Create Table +t5 CREATE TABLE `t5` ( + `const01` int(1) NOT NULL DEFAULT '0', + `param01` bigint(20) DEFAULT NULL, + `const02` decimal(2,1) NOT NULL DEFAULT '0.0', + `param02` decimal(65,30) DEFAULT NULL, + `const03` double NOT NULL DEFAULT '0', + `param03` double DEFAULT NULL, + `const04` varchar(3) NOT NULL DEFAULT '', + `param04` longtext, + `const05` varbinary(3) NOT NULL DEFAULT '', + `param05` longblob, + `const06` varchar(10) NOT NULL DEFAULT '', + `param06` longtext, + `const07` date DEFAULT NULL, + `param07` longblob, + `const08` varchar(19) NOT NULL DEFAULT '', + `param08` longtext, + `const09` datetime DEFAULT NULL, + `param09` longblob, + `const10` int(10) NOT NULL DEFAULT '0', + `param10` bigint(20) DEFAULT NULL, + `const11` int(4) DEFAULT NULL, + `param11` bigint(20) DEFAULT NULL, + `const12` binary(0) DEFAULT NULL, + `param12` bigint(20) DEFAULT NULL, + `param13` decimal(65,30) DEFAULT NULL, + `param14` longtext, + `param15` longblob +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +select * from t5 ; +Catalog Database Table Table_alias Column Column_alias Type Length Max length Is_null Flags Decimals Charsetnr +def test t5 t5 const01 const01 3 1 1 N 32769 0 63 +def test t5 t5 param01 param01 8 20 1 Y 32768 0 63 +def test t5 t5 const02 const02 246 4 3 N 1 1 63 +def test t5 t5 param02 param02 246 67 32 Y 0 30 63 +def test t5 t5 const03 const03 5 17 1 N 32769 31 63 +def test t5 t5 param03 param03 5 23 1 Y 32768 31 63 +def test t5 t5 const04 const04 253 3 3 N 1 0 8 +def test t5 t5 param04 param04 252 4294967295 3 Y 16 0 8 +def test t5 t5 const05 const05 253 3 3 N 129 0 63 +def test t5 t5 param05 param05 252 4294967295 3 Y 144 0 63 +def test t5 t5 const06 const06 253 10 10 N 1 0 8 +def test t5 t5 param06 param06 252 4294967295 10 Y 16 0 8 +def test t5 t5 const07 const07 10 10 10 Y 128 0 63 +def test t5 t5 param07 param07 252 4294967295 10 Y 144 0 63 +def test t5 t5 const08 const08 253 19 19 N 1 0 8 +def test t5 t5 param08 param08 252 4294967295 19 Y 16 0 8 +def test t5 t5 const09 const09 12 19 19 Y 128 0 63 +def test t5 t5 param09 param09 252 4294967295 19 Y 144 0 63 +def test t5 t5 const10 const10 3 10 9 N 32769 0 63 +def test t5 t5 param10 param10 8 20 9 Y 32768 0 63 +def test t5 t5 const11 const11 3 4 4 Y 32768 0 63 +def test t5 t5 param11 param11 8 20 4 Y 32768 0 63 +def test t5 t5 const12 const12 254 0 0 Y 128 0 63 +def test t5 t5 param12 param12 8 20 0 Y 32768 0 63 +def test t5 t5 param13 param13 246 67 0 Y 0 30 63 +def test t5 t5 param14 param14 252 4294967295 0 Y 16 0 8 +def test t5 t5 param15 param15 252 4294967295 0 Y 144 0 63 +const01 8 +param01 8 +const02 8.0 +param02 8.000000000000000000000000000000 +const03 8 +param03 8 +const04 abc +param04 abc +const05 abc +param05 abc +const06 1991-08-05 +param06 1991-08-05 +const07 1991-08-05 +param07 1991-08-05 +const08 1991-08-05 01:01:01 +param08 1991-08-05 01:01:01 +const09 1991-08-05 01:01:01 +param09 1991-08-05 01:01:01 +const10 662680861 +param10 662680861 +const11 1991 +param11 1991 +const12 NULL +param12 NULL +param13 NULL +param14 NULL +param15 NULL +drop table t5 ; +test_sequence +------ data type conversion tests ------ +delete from t1 ; +insert into t1 values (1,'one'); +insert into t1 values (2,'two'); +insert into t1 values (3,'three'); +insert into t1 values (4,'four'); +commit ; +delete from t9 ; +insert into t9 +set c1= 1, c2= 1, c3= 1, c4= 1, c5= 1, c6= 1, c7= 1, c8= 1, c9= 1, +c10= 1, c11= 1, c12 = 1, +c13= '2004-02-29', c14= '2004-02-29 11:11:11', c15= '2004-02-29 11:11:11', +c16= '11:11:11', c17= '2004', +c18= 1, c19=true, c20= 'a', c21= '123456789a', +c22= '123456789a123456789b123456789c', c23= 'tinyblob', c24= 'tinytext', +c25= 'blob', c26= 'text', c27= 'mediumblob', c28= 'mediumtext', +c29= 'longblob', c30= 'longtext', c31='one', c32= 'monday'; +insert into t9 +set c1= 9, c2= 9, c3= 9, c4= 9, c5= 9, c6= 9, c7= 9, c8= 9, c9= 9, +c10= 9, c11= 9, c12 = 9, +c13= '2004-02-29', c14= '2004-02-29 11:11:11', c15= '2004-02-29 11:11:11', +c16= '11:11:11', c17= '2004', +c18= 1, c19=false, c20= 'a', c21= '123456789a', +c22= '123456789a123456789b123456789c', c23= 'tinyblob', c24= 'tinytext', +c25= 'blob', c26= 'text', c27= 'mediumblob', c28= 'mediumtext', +c29= 'longblob', c30= 'longtext', c31='two', c32= 'tuesday'; +commit ; +insert into t9 set c1= 0, c15= '1991-01-01 01:01:01' ; +select * from t9 order by c1 ; +c1 c2 c3 c4 c5 c6 c7 c8 c9 c10 c11 c12 c13 c14 c15 c16 c17 c18 c19 c20 c21 c22 c23 c24 c25 c26 c27 c28 c29 c30 c31 c32 +0 NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL 1991-01-01 01:01:01 NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL +1 1 1 1 1 1 1 1 1 1 1.0000 1.0000 2004-02-29 2004-02-29 11:11:11 2004-02-29 11:11:11 11:11:11 2004 1 1 a 123456789a 123456789a123456789b123456789c tinyblob tinytext blob text mediumblob mediumtext longblob longtext one monday +9 9 9 9 9 9 9 9 9 9 9.0000 9.0000 2004-02-29 2004-02-29 11:11:11 2004-02-29 11:11:11 11:11:11 2004 1 0 a 123456789a 123456789a123456789b123456789c tinyblob tinytext blob text mediumblob mediumtext longblob longtext two tuesday +test_sequence +------ select @parameter:= column ------ +prepare full_info from "select @arg01, @arg02, @arg03, @arg04, + @arg05, @arg06, @arg07, @arg08, + @arg09, @arg10, @arg11, @arg12, + @arg13, @arg14, @arg15, @arg16, + @arg17, @arg18, @arg19, @arg20, + @arg21, @arg22, @arg23, @arg24, + @arg25, @arg26, @arg27, @arg28, + @arg29, @arg30, @arg31, @arg32" ; +select @arg01:= c1, @arg02:= c2, @arg03:= c3, @arg04:= c4, +@arg05:= c5, @arg06:= c6, @arg07:= c7, @arg08:= c8, +@arg09:= c9, @arg10:= c10, @arg11:= c11, @arg12:= c12, +@arg13:= c13, @arg14:= c14, @arg15:= c15, @arg16:= c16, +@arg17:= c17, @arg18:= c18, @arg19:= c19, @arg20:= c20, +@arg21:= c21, @arg22:= c22, @arg23:= c23, @arg24:= c24, +@arg25:= c25, @arg26:= c26, @arg27:= c27, @arg28:= c28, +@arg29:= c29, @arg30:= c30, @arg31:= c31, @arg32:= c32 +from t9 where c1= 1 ; +@arg01:= c1 @arg02:= c2 @arg03:= c3 @arg04:= c4 @arg05:= c5 @arg06:= c6 @arg07:= c7 @arg08:= c8 @arg09:= c9 @arg10:= c10 @arg11:= c11 @arg12:= c12 @arg13:= c13 @arg14:= c14 @arg15:= c15 @arg16:= c16 @arg17:= c17 @arg18:= c18 @arg19:= c19 @arg20:= c20 @arg21:= c21 @arg22:= c22 @arg23:= c23 @arg24:= c24 @arg25:= c25 @arg26:= c26 @arg27:= c27 @arg28:= c28 @arg29:= c29 @arg30:= c30 @arg31:= c31 @arg32:= c32 +1 1 1 1 1 1 1 1 1 1 1.0000 1.0000 2004-02-29 2004-02-29 11:11:11 2004-02-29 11:11:11 11:11:11 2004 1 1 a 123456789a 123456789a123456789b123456789c tinyblob tinytext blob text mediumblob mediumtext longblob longtext one monday +execute full_info ; +Catalog Database Table Table_alias Column Column_alias Type Length Max length Is_null Flags Decimals Charsetnr +def @arg01 8 20 1 Y 32896 0 63 +def @arg02 8 20 1 Y 32896 0 63 +def @arg03 8 20 1 Y 32896 0 63 +def @arg04 8 20 1 Y 32896 0 63 +def @arg05 8 20 1 Y 32896 0 63 +def @arg06 8 20 1 Y 32896 0 63 +def @arg07 5 23 1 Y 32896 31 63 +def @arg08 5 23 1 Y 32896 31 63 +def @arg09 5 23 1 Y 32896 31 63 +def @arg10 5 23 1 Y 32896 31 63 +def @arg11 246 83 6 Y 128 30 63 +def @arg12 246 83 6 Y 128 30 63 +def @arg13 251 16777216 10 Y 128 31 63 +def @arg14 251 16777216 19 Y 128 31 63 +def @arg15 251 16777216 19 Y 128 31 63 +def @arg16 251 16777216 8 Y 128 31 63 +def @arg17 8 20 4 Y 32928 0 63 +def @arg18 8 20 1 Y 32896 0 63 +def @arg19 8 20 1 Y 32896 0 63 +def @arg20 251 16777216 1 Y 0 31 8 +def @arg21 251 16777216 10 Y 0 31 8 +def @arg22 251 16777216 30 Y 0 31 8 +def @arg23 251 16777216 8 Y 128 31 63 +def @arg24 251 16777216 8 Y 0 31 8 +def @arg25 251 16777216 4 Y 128 31 63 +def @arg26 251 16777216 4 Y 0 31 8 +def @arg27 251 16777216 10 Y 128 31 63 +def @arg28 251 16777216 10 Y 0 31 8 +def @arg29 251 16777216 8 Y 128 31 63 +def @arg30 251 16777216 8 Y 0 31 8 +def @arg31 251 16777216 3 Y 0 31 8 +def @arg32 251 16777216 6 Y 0 31 8 +@arg01 @arg02 @arg03 @arg04 @arg05 @arg06 @arg07 @arg08 @arg09 @arg10 @arg11 @arg12 @arg13 @arg14 @arg15 @arg16 @arg17 @arg18 @arg19 @arg20 @arg21 @arg22 @arg23 @arg24 @arg25 @arg26 @arg27 @arg28 @arg29 @arg30 @arg31 @arg32 +1 1 1 1 1 1 1 1 1 1 1.0000 1.0000 2004-02-29 2004-02-29 11:11:11 2004-02-29 11:11:11 11:11:11 2004 1 1 a 123456789a 123456789a123456789b123456789c tinyblob tinytext blob text mediumblob mediumtext longblob longtext one monday +select @arg01:= c1, @arg02:= c2, @arg03:= c3, @arg04:= c4, +@arg05:= c5, @arg06:= c6, @arg07:= c7, @arg08:= c8, +@arg09:= c9, @arg10:= c10, @arg11:= c11, @arg12:= c12, +@arg13:= c13, @arg14:= c14, @arg15:= c15, @arg16:= c16, +@arg17:= c17, @arg18:= c18, @arg19:= c19, @arg20:= c20, +@arg21:= c21, @arg22:= c22, @arg23:= c23, @arg24:= c24, +@arg25:= c25, @arg26:= c26, @arg27:= c27, @arg28:= c28, +@arg29:= c29, @arg30:= c30, @arg31:= c31, @arg32:= c32 +from t9 where c1= 0 ; +@arg01:= c1 @arg02:= c2 @arg03:= c3 @arg04:= c4 @arg05:= c5 @arg06:= c6 @arg07:= c7 @arg08:= c8 @arg09:= c9 @arg10:= c10 @arg11:= c11 @arg12:= c12 @arg13:= c13 @arg14:= c14 @arg15:= c15 @arg16:= c16 @arg17:= c17 @arg18:= c18 @arg19:= c19 @arg20:= c20 @arg21:= c21 @arg22:= c22 @arg23:= c23 @arg24:= c24 @arg25:= c25 @arg26:= c26 @arg27:= c27 @arg28:= c28 @arg29:= c29 @arg30:= c30 @arg31:= c31 @arg32:= c32 +0 NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL 1991-01-01 01:01:01 NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL +execute full_info ; +Catalog Database Table Table_alias Column Column_alias Type Length Max length Is_null Flags Decimals Charsetnr +def @arg01 8 20 1 Y 32896 0 63 +def @arg02 8 20 0 Y 32896 0 63 +def @arg03 8 20 0 Y 32896 0 63 +def @arg04 8 20 0 Y 32896 0 63 +def @arg05 8 20 0 Y 32896 0 63 +def @arg06 8 20 0 Y 32896 0 63 +def @arg07 5 23 0 Y 32896 31 63 +def @arg08 5 23 0 Y 32896 31 63 +def @arg09 5 23 0 Y 32896 31 63 +def @arg10 5 23 0 Y 32896 31 63 +def @arg11 246 83 0 Y 128 30 63 +def @arg12 246 83 0 Y 128 30 63 +def @arg13 251 16777216 0 Y 128 31 63 +def @arg14 251 16777216 0 Y 128 31 63 +def @arg15 251 16777216 19 Y 128 31 63 +def @arg16 251 16777216 0 Y 128 31 63 +def @arg17 8 20 0 Y 32928 0 63 +def @arg18 8 20 0 Y 32896 0 63 +def @arg19 8 20 0 Y 32896 0 63 +def @arg20 251 16777216 0 Y 0 31 8 +def @arg21 251 16777216 0 Y 0 31 8 +def @arg22 251 16777216 0 Y 0 31 8 +def @arg23 251 16777216 0 Y 128 31 63 +def @arg24 251 16777216 0 Y 0 31 8 +def @arg25 251 16777216 0 Y 128 31 63 +def @arg26 251 16777216 0 Y 0 31 8 +def @arg27 251 16777216 0 Y 128 31 63 +def @arg28 251 16777216 0 Y 0 31 8 +def @arg29 251 16777216 0 Y 128 31 63 +def @arg30 251 16777216 0 Y 0 31 8 +def @arg31 251 16777216 0 Y 0 31 8 +def @arg32 251 16777216 0 Y 0 31 8 +@arg01 @arg02 @arg03 @arg04 @arg05 @arg06 @arg07 @arg08 @arg09 @arg10 @arg11 @arg12 @arg13 @arg14 @arg15 @arg16 @arg17 @arg18 @arg19 @arg20 @arg21 @arg22 @arg23 @arg24 @arg25 @arg26 @arg27 @arg28 @arg29 @arg30 @arg31 @arg32 +0 NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL 1991-01-01 01:01:01 NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL +prepare stmt1 from "select + @arg01:= c1, @arg02:= c2, @arg03:= c3, @arg04:= c4, + @arg05:= c5, @arg06:= c6, @arg07:= c7, @arg08:= c8, + @arg09:= c9, @arg10:= c10, @arg11:= c11, @arg12:= c12, + @arg13:= c13, @arg14:= c14, @arg15:= c15, @arg16:= c16, + @arg17:= c17, @arg18:= c18, @arg19:= c19, @arg20:= c20, + @arg21:= c21, @arg22:= c22, @arg23:= c23, @arg24:= c24, + @arg25:= c25, @arg26:= c26, @arg27:= c27, @arg28:= c28, + @arg29:= c29, @arg30:= c30, @arg31:= c31, @arg32:= c32 +from t9 where c1= ?" ; +set @my_key= 1 ; +execute stmt1 using @my_key ; +@arg01:= c1 @arg02:= c2 @arg03:= c3 @arg04:= c4 @arg05:= c5 @arg06:= c6 @arg07:= c7 @arg08:= c8 @arg09:= c9 @arg10:= c10 @arg11:= c11 @arg12:= c12 @arg13:= c13 @arg14:= c14 @arg15:= c15 @arg16:= c16 @arg17:= c17 @arg18:= c18 @arg19:= c19 @arg20:= c20 @arg21:= c21 @arg22:= c22 @arg23:= c23 @arg24:= c24 @arg25:= c25 @arg26:= c26 @arg27:= c27 @arg28:= c28 @arg29:= c29 @arg30:= c30 @arg31:= c31 @arg32:= c32 +1 1 1 1 1 1 1 1 1 1 1.0000 1.0000 2004-02-29 2004-02-29 11:11:11 2004-02-29 11:11:11 11:11:11 2004 1 1 a 123456789a 123456789a123456789b123456789c tinyblob tinytext blob text mediumblob mediumtext longblob longtext one monday +execute full_info ; +Catalog Database Table Table_alias Column Column_alias Type Length Max length Is_null Flags Decimals Charsetnr +def @arg01 8 20 1 Y 32896 0 63 +def @arg02 8 20 1 Y 32896 0 63 +def @arg03 8 20 1 Y 32896 0 63 +def @arg04 8 20 1 Y 32896 0 63 +def @arg05 8 20 1 Y 32896 0 63 +def @arg06 8 20 1 Y 32896 0 63 +def @arg07 5 23 1 Y 32896 31 63 +def @arg08 5 23 1 Y 32896 31 63 +def @arg09 5 23 1 Y 32896 31 63 +def @arg10 5 23 1 Y 32896 31 63 +def @arg11 246 83 6 Y 128 30 63 +def @arg12 246 83 6 Y 128 30 63 +def @arg13 251 16777216 10 Y 128 31 63 +def @arg14 251 16777216 19 Y 128 31 63 +def @arg15 251 16777216 19 Y 128 31 63 +def @arg16 251 16777216 8 Y 128 31 63 +def @arg17 8 20 4 Y 32928 0 63 +def @arg18 8 20 1 Y 32896 0 63 +def @arg19 8 20 1 Y 32896 0 63 +def @arg20 251 16777216 1 Y 0 31 8 +def @arg21 251 16777216 10 Y 0 31 8 +def @arg22 251 16777216 30 Y 0 31 8 +def @arg23 251 16777216 8 Y 128 31 63 +def @arg24 251 16777216 8 Y 0 31 8 +def @arg25 251 16777216 4 Y 128 31 63 +def @arg26 251 16777216 4 Y 0 31 8 +def @arg27 251 16777216 10 Y 128 31 63 +def @arg28 251 16777216 10 Y 0 31 8 +def @arg29 251 16777216 8 Y 128 31 63 +def @arg30 251 16777216 8 Y 0 31 8 +def @arg31 251 16777216 3 Y 0 31 8 +def @arg32 251 16777216 6 Y 0 31 8 +@arg01 @arg02 @arg03 @arg04 @arg05 @arg06 @arg07 @arg08 @arg09 @arg10 @arg11 @arg12 @arg13 @arg14 @arg15 @arg16 @arg17 @arg18 @arg19 @arg20 @arg21 @arg22 @arg23 @arg24 @arg25 @arg26 @arg27 @arg28 @arg29 @arg30 @arg31 @arg32 +1 1 1 1 1 1 1 1 1 1 1.0000 1.0000 2004-02-29 2004-02-29 11:11:11 2004-02-29 11:11:11 11:11:11 2004 1 1 a 123456789a 123456789a123456789b123456789c tinyblob tinytext blob text mediumblob mediumtext longblob longtext one monday +set @my_key= 0 ; +execute stmt1 using @my_key ; +@arg01:= c1 @arg02:= c2 @arg03:= c3 @arg04:= c4 @arg05:= c5 @arg06:= c6 @arg07:= c7 @arg08:= c8 @arg09:= c9 @arg10:= c10 @arg11:= c11 @arg12:= c12 @arg13:= c13 @arg14:= c14 @arg15:= c15 @arg16:= c16 @arg17:= c17 @arg18:= c18 @arg19:= c19 @arg20:= c20 @arg21:= c21 @arg22:= c22 @arg23:= c23 @arg24:= c24 @arg25:= c25 @arg26:= c26 @arg27:= c27 @arg28:= c28 @arg29:= c29 @arg30:= c30 @arg31:= c31 @arg32:= c32 +0 NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL 1991-01-01 01:01:01 NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL +execute full_info ; +Catalog Database Table Table_alias Column Column_alias Type Length Max length Is_null Flags Decimals Charsetnr +def @arg01 8 20 1 Y 32896 0 63 +def @arg02 8 20 0 Y 32896 0 63 +def @arg03 8 20 0 Y 32896 0 63 +def @arg04 8 20 0 Y 32896 0 63 +def @arg05 8 20 0 Y 32896 0 63 +def @arg06 8 20 0 Y 32896 0 63 +def @arg07 5 23 0 Y 32896 31 63 +def @arg08 5 23 0 Y 32896 31 63 +def @arg09 5 23 0 Y 32896 31 63 +def @arg10 5 23 0 Y 32896 31 63 +def @arg11 246 83 0 Y 128 30 63 +def @arg12 246 83 0 Y 128 30 63 +def @arg13 251 16777216 0 Y 128 31 63 +def @arg14 251 16777216 0 Y 128 31 63 +def @arg15 251 16777216 19 Y 128 31 63 +def @arg16 251 16777216 0 Y 128 31 63 +def @arg17 8 20 0 Y 32928 0 63 +def @arg18 8 20 0 Y 32896 0 63 +def @arg19 8 20 0 Y 32896 0 63 +def @arg20 251 16777216 0 Y 0 31 8 +def @arg21 251 16777216 0 Y 0 31 8 +def @arg22 251 16777216 0 Y 0 31 8 +def @arg23 251 16777216 0 Y 128 31 63 +def @arg24 251 16777216 0 Y 0 31 8 +def @arg25 251 16777216 0 Y 128 31 63 +def @arg26 251 16777216 0 Y 0 31 8 +def @arg27 251 16777216 0 Y 128 31 63 +def @arg28 251 16777216 0 Y 0 31 8 +def @arg29 251 16777216 0 Y 128 31 63 +def @arg30 251 16777216 0 Y 0 31 8 +def @arg31 251 16777216 0 Y 0 31 8 +def @arg32 251 16777216 0 Y 0 31 8 +@arg01 @arg02 @arg03 @arg04 @arg05 @arg06 @arg07 @arg08 @arg09 @arg10 @arg11 @arg12 @arg13 @arg14 @arg15 @arg16 @arg17 @arg18 @arg19 @arg20 @arg21 @arg22 @arg23 @arg24 @arg25 @arg26 @arg27 @arg28 @arg29 @arg30 @arg31 @arg32 +0 NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL 1991-01-01 01:01:01 NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL +prepare stmt1 from "select ? := c1 from t9 where c1= 1" ; +ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ':= c1 from t9 where c1= 1' at line 1 +test_sequence +------ select column, .. into @parm,.. ------ +select c1, c2, c3, c4, c5, c6, c7, c8, c9, c10, c11, c12, +c13, c14, c15, c16, c17, c18, c19, c20, c21, c22, c23, c24, +c25, c26, c27, c28, c29, c30, c31, c32 +into @arg01, @arg02, @arg03, @arg04, @arg05, @arg06, @arg07, @arg08, +@arg09, @arg10, @arg11, @arg12, @arg13, @arg14, @arg15, @arg16, +@arg17, @arg18, @arg19, @arg20, @arg21, @arg22, @arg23, @arg24, +@arg25, @arg26, @arg27, @arg28, @arg29, @arg30, @arg31, @arg32 +from t9 where c1= 1 ; +execute full_info ; +Catalog Database Table Table_alias Column Column_alias Type Length Max length Is_null Flags Decimals Charsetnr +def @arg01 8 20 1 Y 32896 0 63 +def @arg02 8 20 1 Y 32896 0 63 +def @arg03 8 20 1 Y 32896 0 63 +def @arg04 8 20 1 Y 32896 0 63 +def @arg05 8 20 1 Y 32896 0 63 +def @arg06 8 20 1 Y 32896 0 63 +def @arg07 5 23 1 Y 32896 31 63 +def @arg08 5 23 1 Y 32896 31 63 +def @arg09 5 23 1 Y 32896 31 63 +def @arg10 5 23 1 Y 32896 31 63 +def @arg11 246 83 6 Y 128 30 63 +def @arg12 246 83 6 Y 128 30 63 +def @arg13 251 16777216 10 Y 128 31 63 +def @arg14 251 16777216 19 Y 128 31 63 +def @arg15 251 16777216 19 Y 128 31 63 +def @arg16 251 16777216 8 Y 128 31 63 +def @arg17 8 20 4 Y 32928 0 63 +def @arg18 8 20 1 Y 32896 0 63 +def @arg19 8 20 1 Y 32896 0 63 +def @arg20 251 16777216 1 Y 0 31 8 +def @arg21 251 16777216 10 Y 0 31 8 +def @arg22 251 16777216 30 Y 0 31 8 +def @arg23 251 16777216 8 Y 128 31 63 +def @arg24 251 16777216 8 Y 0 31 8 +def @arg25 251 16777216 4 Y 128 31 63 +def @arg26 251 16777216 4 Y 0 31 8 +def @arg27 251 16777216 10 Y 128 31 63 +def @arg28 251 16777216 10 Y 0 31 8 +def @arg29 251 16777216 8 Y 128 31 63 +def @arg30 251 16777216 8 Y 0 31 8 +def @arg31 251 16777216 3 Y 0 31 8 +def @arg32 251 16777216 6 Y 0 31 8 +@arg01 @arg02 @arg03 @arg04 @arg05 @arg06 @arg07 @arg08 @arg09 @arg10 @arg11 @arg12 @arg13 @arg14 @arg15 @arg16 @arg17 @arg18 @arg19 @arg20 @arg21 @arg22 @arg23 @arg24 @arg25 @arg26 @arg27 @arg28 @arg29 @arg30 @arg31 @arg32 +1 1 1 1 1 1 1 1 1 1 1.0000 1.0000 2004-02-29 2004-02-29 11:11:11 2004-02-29 11:11:11 11:11:11 2004 1 1 a 123456789a 123456789a123456789b123456789c tinyblob tinytext blob text mediumblob mediumtext longblob longtext one monday +select c1, c2, c3, c4, c5, c6, c7, c8, c9, c10, c11, c12, +c13, c14, c15, c16, c17, c18, c19, c20, c21, c22, c23, c24, +c25, c26, c27, c28, c29, c30, c31, c32 +into @arg01, @arg02, @arg03, @arg04, @arg05, @arg06, @arg07, @arg08, +@arg09, @arg10, @arg11, @arg12, @arg13, @arg14, @arg15, @arg16, +@arg17, @arg18, @arg19, @arg20, @arg21, @arg22, @arg23, @arg24, +@arg25, @arg26, @arg27, @arg28, @arg29, @arg30, @arg31, @arg32 +from t9 where c1= 0 ; +execute full_info ; +Catalog Database Table Table_alias Column Column_alias Type Length Max length Is_null Flags Decimals Charsetnr +def @arg01 8 20 1 Y 32896 0 63 +def @arg02 8 20 0 Y 32896 0 63 +def @arg03 8 20 0 Y 32896 0 63 +def @arg04 8 20 0 Y 32896 0 63 +def @arg05 8 20 0 Y 32896 0 63 +def @arg06 8 20 0 Y 32896 0 63 +def @arg07 5 23 0 Y 32896 31 63 +def @arg08 5 23 0 Y 32896 31 63 +def @arg09 5 23 0 Y 32896 31 63 +def @arg10 5 23 0 Y 32896 31 63 +def @arg11 246 83 0 Y 128 30 63 +def @arg12 246 83 0 Y 128 30 63 +def @arg13 251 16777216 0 Y 128 31 63 +def @arg14 251 16777216 0 Y 128 31 63 +def @arg15 251 16777216 19 Y 128 31 63 +def @arg16 251 16777216 0 Y 128 31 63 +def @arg17 8 20 0 Y 32928 0 63 +def @arg18 8 20 0 Y 32896 0 63 +def @arg19 8 20 0 Y 32896 0 63 +def @arg20 251 16777216 0 Y 0 31 8 +def @arg21 251 16777216 0 Y 0 31 8 +def @arg22 251 16777216 0 Y 0 31 8 +def @arg23 251 16777216 0 Y 128 31 63 +def @arg24 251 16777216 0 Y 0 31 8 +def @arg25 251 16777216 0 Y 128 31 63 +def @arg26 251 16777216 0 Y 0 31 8 +def @arg27 251 16777216 0 Y 128 31 63 +def @arg28 251 16777216 0 Y 0 31 8 +def @arg29 251 16777216 0 Y 128 31 63 +def @arg30 251 16777216 0 Y 0 31 8 +def @arg31 251 16777216 0 Y 0 31 8 +def @arg32 251 16777216 0 Y 0 31 8 +@arg01 @arg02 @arg03 @arg04 @arg05 @arg06 @arg07 @arg08 @arg09 @arg10 @arg11 @arg12 @arg13 @arg14 @arg15 @arg16 @arg17 @arg18 @arg19 @arg20 @arg21 @arg22 @arg23 @arg24 @arg25 @arg26 @arg27 @arg28 @arg29 @arg30 @arg31 @arg32 +0 NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL 1991-01-01 01:01:01 NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL +prepare stmt1 from "select c1, c2, c3, c4, c5, c6, c7, c8, c9, c10, c11, c12, + c13, c14, c15, c16, c17, c18, c19, c20, c21, c22, c23, c24, + c25, c26, c27, c28, c29, c30, c31, c32 +into @arg01, @arg02, @arg03, @arg04, @arg05, @arg06, @arg07, @arg08, + @arg09, @arg10, @arg11, @arg12, @arg13, @arg14, @arg15, @arg16, + @arg17, @arg18, @arg19, @arg20, @arg21, @arg22, @arg23, @arg24, + @arg25, @arg26, @arg27, @arg28, @arg29, @arg30, @arg31, @arg32 +from t9 where c1= ?" ; +set @my_key= 1 ; +execute stmt1 using @my_key ; +execute full_info ; +Catalog Database Table Table_alias Column Column_alias Type Length Max length Is_null Flags Decimals Charsetnr +def @arg01 8 20 1 Y 32896 0 63 +def @arg02 8 20 1 Y 32896 0 63 +def @arg03 8 20 1 Y 32896 0 63 +def @arg04 8 20 1 Y 32896 0 63 +def @arg05 8 20 1 Y 32896 0 63 +def @arg06 8 20 1 Y 32896 0 63 +def @arg07 5 23 1 Y 32896 31 63 +def @arg08 5 23 1 Y 32896 31 63 +def @arg09 5 23 1 Y 32896 31 63 +def @arg10 5 23 1 Y 32896 31 63 +def @arg11 246 83 6 Y 128 30 63 +def @arg12 246 83 6 Y 128 30 63 +def @arg13 251 16777216 10 Y 128 31 63 +def @arg14 251 16777216 19 Y 128 31 63 +def @arg15 251 16777216 19 Y 128 31 63 +def @arg16 251 16777216 8 Y 128 31 63 +def @arg17 8 20 4 Y 32928 0 63 +def @arg18 8 20 1 Y 32896 0 63 +def @arg19 8 20 1 Y 32896 0 63 +def @arg20 251 16777216 1 Y 0 31 8 +def @arg21 251 16777216 10 Y 0 31 8 +def @arg22 251 16777216 30 Y 0 31 8 +def @arg23 251 16777216 8 Y 128 31 63 +def @arg24 251 16777216 8 Y 0 31 8 +def @arg25 251 16777216 4 Y 128 31 63 +def @arg26 251 16777216 4 Y 0 31 8 +def @arg27 251 16777216 10 Y 128 31 63 +def @arg28 251 16777216 10 Y 0 31 8 +def @arg29 251 16777216 8 Y 128 31 63 +def @arg30 251 16777216 8 Y 0 31 8 +def @arg31 251 16777216 3 Y 0 31 8 +def @arg32 251 16777216 6 Y 0 31 8 +@arg01 @arg02 @arg03 @arg04 @arg05 @arg06 @arg07 @arg08 @arg09 @arg10 @arg11 @arg12 @arg13 @arg14 @arg15 @arg16 @arg17 @arg18 @arg19 @arg20 @arg21 @arg22 @arg23 @arg24 @arg25 @arg26 @arg27 @arg28 @arg29 @arg30 @arg31 @arg32 +1 1 1 1 1 1 1 1 1 1 1.0000 1.0000 2004-02-29 2004-02-29 11:11:11 2004-02-29 11:11:11 11:11:11 2004 1 1 a 123456789a 123456789a123456789b123456789c tinyblob tinytext blob text mediumblob mediumtext longblob longtext one monday +set @my_key= 0 ; +execute stmt1 using @my_key ; +execute full_info ; +Catalog Database Table Table_alias Column Column_alias Type Length Max length Is_null Flags Decimals Charsetnr +def @arg01 8 20 1 Y 32896 0 63 +def @arg02 8 20 0 Y 32896 0 63 +def @arg03 8 20 0 Y 32896 0 63 +def @arg04 8 20 0 Y 32896 0 63 +def @arg05 8 20 0 Y 32896 0 63 +def @arg06 8 20 0 Y 32896 0 63 +def @arg07 5 23 0 Y 32896 31 63 +def @arg08 5 23 0 Y 32896 31 63 +def @arg09 5 23 0 Y 32896 31 63 +def @arg10 5 23 0 Y 32896 31 63 +def @arg11 246 83 0 Y 128 30 63 +def @arg12 246 83 0 Y 128 30 63 +def @arg13 251 16777216 0 Y 128 31 63 +def @arg14 251 16777216 0 Y 128 31 63 +def @arg15 251 16777216 19 Y 128 31 63 +def @arg16 251 16777216 0 Y 128 31 63 +def @arg17 8 20 0 Y 32928 0 63 +def @arg18 8 20 0 Y 32896 0 63 +def @arg19 8 20 0 Y 32896 0 63 +def @arg20 251 16777216 0 Y 0 31 8 +def @arg21 251 16777216 0 Y 0 31 8 +def @arg22 251 16777216 0 Y 0 31 8 +def @arg23 251 16777216 0 Y 128 31 63 +def @arg24 251 16777216 0 Y 0 31 8 +def @arg25 251 16777216 0 Y 128 31 63 +def @arg26 251 16777216 0 Y 0 31 8 +def @arg27 251 16777216 0 Y 128 31 63 +def @arg28 251 16777216 0 Y 0 31 8 +def @arg29 251 16777216 0 Y 128 31 63 +def @arg30 251 16777216 0 Y 0 31 8 +def @arg31 251 16777216 0 Y 0 31 8 +def @arg32 251 16777216 0 Y 0 31 8 +@arg01 @arg02 @arg03 @arg04 @arg05 @arg06 @arg07 @arg08 @arg09 @arg10 @arg11 @arg12 @arg13 @arg14 @arg15 @arg16 @arg17 @arg18 @arg19 @arg20 @arg21 @arg22 @arg23 @arg24 @arg25 @arg26 @arg27 @arg28 @arg29 @arg30 @arg31 @arg32 +0 NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL 1991-01-01 01:01:01 NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL +prepare stmt1 from "select c1 into ? from t9 where c1= 1" ; +ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '? from t9 where c1= 1' at line 1 +test_sequence +-- insert into numeric columns -- +insert into t9 +( c1, c2, c3, c4, c5, c6, c7, c8, c9, c10, c12 ) +values +( 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20 ) ; +set @arg00= 21 ; +insert into t9 +( c1, c2, c3, c4, c5, c6, c7, c8, c9, c10, c12 ) +values +( @arg00, @arg00, @arg00, @arg00, @arg00, @arg00, +@arg00, @arg00, @arg00, @arg00, @arg00 ) ; +prepare stmt1 from "insert into t9 + ( c1, c2, c3, c4, c5, c6, c7, c8, c9, c10, c12 ) +values + ( 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22 )" ; +execute stmt1 ; +set @arg00= 23; +prepare stmt2 from "insert into t9 + ( c1, c2, c3, c4, c5, c6, c7, c8, c9, c10, c12 ) +values + ( ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ? )" ; +execute stmt2 using @arg00, @arg00, @arg00, @arg00, @arg00, @arg00, @arg00, +@arg00, @arg00, @arg00, @arg00 ; +insert into t9 +( c1, c2, c3, c4, c5, c6, c7, c8, c9, c10, c12 ) +values +( 30.0, 30.0, 30.0, 30.0, 30.0, 30.0, 30.0, 30.0, +30.0, 30.0, 30.0 ) ; +set @arg00= 31.0 ; +insert into t9 +( c1, c2, c3, c4, c5, c6, c7, c8, c9, c10, c12 ) +values +( @arg00, @arg00, @arg00, @arg00, @arg00, @arg00, +@arg00, @arg00, @arg00, @arg00, @arg00 ) ; +prepare stmt1 from "insert into t9 + ( c1, c2, c3, c4, c5, c6, c7, c8, c9, c10, c12 ) +values + ( 32.0, 32.0, 32.0, 32.0, 32.0, 32.0, 32.0, 32.0, + 32.0, 32.0, 32.0 )" ; +execute stmt1 ; +set @arg00= 33.0; +prepare stmt2 from "insert into t9 + ( c1, c2, c3, c4, c5, c6, c7, c8, c9, c10, c12 ) +values + ( ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ? )" ; +execute stmt2 using @arg00, @arg00, @arg00, @arg00, @arg00, @arg00, @arg00, +@arg00, @arg00, @arg00, @arg00 ; +insert into t9 +( c1, c2, c3, c4, c5, c6, c7, c8, c9, c10, c12 ) +values +( '40', '40', '40', '40', '40', '40', '40', '40', +'40', '40', '40' ) ; +set @arg00= '41' ; +insert into t9 +( c1, c2, c3, c4, c5, c6, c7, c8, c9, c10, c12 ) +values +( @arg00, @arg00, @arg00, @arg00, @arg00, @arg00, +@arg00, @arg00, @arg00, @arg00, @arg00 ) ; +prepare stmt1 from "insert into t9 + ( c1, c2, c3, c4, c5, c6, c7, c8, c9, c10, c12 ) +values + ( '42', '42', '42', '42', '42', '42', '42', '42', + '42', '42', '42' )" ; +execute stmt1 ; +set @arg00= '43'; +prepare stmt2 from "insert into t9 + ( c1, c2, c3, c4, c5, c6, c7, c8, c9, c10, c12 ) +values + ( ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ? )" ; +execute stmt2 using @arg00, @arg00, @arg00, @arg00, @arg00, @arg00, @arg00, +@arg00, @arg00, @arg00, @arg00 ; +insert into t9 +( c1, c2, c3, c4, c5, c6, c7, c8, c9, c10, c12 ) +values +( CAST('50' as binary), CAST('50' as binary), +CAST('50' as binary), CAST('50' as binary), CAST('50' as binary), +CAST('50' as binary), CAST('50' as binary), CAST('50' as binary), +CAST('50' as binary), CAST('50' as binary), CAST('50' as binary) ) ; +set @arg00= CAST('51' as binary) ; +insert into t9 +( c1, c2, c3, c4, c5, c6, c7, c8, c9, c10, c12 ) +values +( @arg00, @arg00, @arg00, @arg00, @arg00, @arg00, +@arg00, @arg00, @arg00, @arg00, @arg00 ) ; +prepare stmt1 from "insert into t9 + ( c1, c2, c3, c4, c5, c6, c7, c8, c9, c10, c12 ) +values + ( CAST('52' as binary), CAST('52' as binary), + CAST('52' as binary), CAST('52' as binary), CAST('52' as binary), + CAST('52' as binary), CAST('52' as binary), CAST('52' as binary), + CAST('52' as binary), CAST('52' as binary), CAST('52' as binary) )" ; +execute stmt1 ; +set @arg00= CAST('53' as binary) ; +prepare stmt2 from "insert into t9 + ( c1, c2, c3, c4, c5, c6, c7, c8, c9, c10, c12 ) +values + ( ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ? )" ; +execute stmt2 using @arg00, @arg00, @arg00, @arg00, @arg00, @arg00, @arg00, +@arg00, @arg00, @arg00, @arg00 ; +set @arg00= 2 ; +set @arg00= NULL ; +insert into t9 +( c1, c2, c3, c4, c5, c6, c7, c8, c9, c10, c12 ) +values +( 60, NULL, NULL, NULL, NULL, NULL, NULL, NULL, +NULL, NULL, NULL ) ; +insert into t9 +( c1, c2, c3, c4, c5, c6, c7, c8, c9, c10, c12 ) +values +( 61, @arg00, @arg00, @arg00, @arg00, @arg00, +@arg00, @arg00, @arg00, @arg00, @arg00 ) ; +prepare stmt1 from "insert into t9 + ( c1, c2, c3, c4, c5, c6, c7, c8, c9, c10, c12 ) +values + ( 62, NULL, NULL, NULL, NULL, NULL, NULL, NULL, + NULL, NULL, NULL )" ; +execute stmt1 ; +prepare stmt2 from "insert into t9 + ( c1, c2, c3, c4, c5, c6, c7, c8, c9, c10, c12 ) +values + ( 63, ?, ?, ?, ?, ?, ?, ?, ?, ?, ? )" ; +execute stmt2 using @arg00, @arg00, @arg00, @arg00, @arg00, @arg00, +@arg00, @arg00, @arg00, @arg00 ; +set @arg00= 8.0 ; +set @arg00= NULL ; +insert into t9 +( c1, c2, c3, c4, c5, c6, c7, c8, c9, c10, c12 ) +values +( 71, @arg00, @arg00, @arg00, @arg00, @arg00, +@arg00, @arg00, @arg00, @arg00, @arg00 ) ; +prepare stmt2 from "insert into t9 + ( c1, c2, c3, c4, c5, c6, c7, c8, c9, c10, c12 ) +values + ( 73, ?, ?, ?, ?, ?, ?, ?, ?, ?, ? )" ; +execute stmt2 using @arg00, @arg00, @arg00, @arg00, @arg00, @arg00, +@arg00, @arg00, @arg00, @arg00 ; +set @arg00= 'abc' ; +set @arg00= NULL ; +insert into t9 +( c1, c2, c3, c4, c5, c6, c7, c8, c9, c10, c12 ) +values +( 81, @arg00, @arg00, @arg00, @arg00, @arg00, +@arg00, @arg00, @arg00, @arg00, @arg00 ) ; +prepare stmt2 from "insert into t9 + ( c1, c2, c3, c4, c5, c6, c7, c8, c9, c10, c12 ) +values + ( 83, ?, ?, ?, ?, ?, ?, ?, ?, ?, ? )" ; +execute stmt2 using @arg00, @arg00, @arg00, @arg00, @arg00, @arg00, +@arg00, @arg00, @arg00, @arg00 ; +select c1, c2, c3, c4, c5, c6, c7, c8, c9, c10, c12 +from t9 where c1 >= 20 +order by c1 ; +c1 c2 c3 c4 c5 c6 c7 c8 c9 c10 c12 +20 20 20 20 20 20 20 20 20 20 20.0000 +21 21 21 21 21 21 21 21 21 21 21.0000 +22 22 22 22 22 22 22 22 22 22 22.0000 +23 23 23 23 23 23 23 23 23 23 23.0000 +30 30 30 30 30 30 30 30 30 30 30.0000 +31 31 31 31 31 31 31 31 31 31 31.0000 +32 32 32 32 32 32 32 32 32 32 32.0000 +33 33 33 33 33 33 33 33 33 33 33.0000 +40 40 40 40 40 40 40 40 40 40 40.0000 +41 41 41 41 41 41 41 41 41 41 41.0000 +42 42 42 42 42 42 42 42 42 42 42.0000 +43 43 43 43 43 43 43 43 43 43 43.0000 +50 50 50 50 50 50 50 50 50 50 50.0000 +51 51 51 51 51 51 51 51 51 51 51.0000 +52 52 52 52 52 52 52 52 52 52 52.0000 +53 53 53 53 53 53 53 53 53 53 53.0000 +60 NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL +61 NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL +62 NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL +63 NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL +71 NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL +73 NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL +81 NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL +83 NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL +test_sequence +-- select .. where numeric column = .. -- +set @arg00= 20; +select 'true' as found from t9 +where c1= 20 and c2= 20 and c3= 20 and c4= 20 and c5= 20 and c6= 20 and c7= 20 +and c8= 20 and c9= 20 and c10= 20 and c12= 20; +found +true +select 'true' as found from t9 +where c1= @arg00 and c2= @arg00 and c3= @arg00 and c4= @arg00 and c5= @arg00 +and c6= @arg00 and c7= @arg00 and c8= @arg00 and c9= @arg00 and c10= @arg00 +and c12= @arg00; +found +true +prepare stmt1 from "select 'true' as found from t9 +where c1= 20 and c2= 20 and c3= 20 and c4= 20 and c5= 20 and c6= 20 and c7= 20 + and c8= 20 and c9= 20 and c10= 20 and c12= 20 "; +execute stmt1 ; +found +true +prepare stmt1 from "select 'true' as found from t9 +where c1= ? and c2= ? and c3= ? and c4= ? and c5= ? + and c6= ? and c7= ? and c8= ? and c9= ? and c10= ? + and c12= ? "; +execute stmt1 using @arg00, @arg00, @arg00, @arg00, @arg00, @arg00, @arg00, +@arg00, @arg00, @arg00, @arg00 ; +found +true +set @arg00= 20.0; +select 'true' as found from t9 +where c1= 20.0 and c2= 20.0 and c3= 20.0 and c4= 20.0 and c5= 20.0 and c6= 20.0 +and c7= 20.0 and c8= 20.0 and c9= 20.0 and c10= 20.0 and c12= 20.0; +found +true +select 'true' as found from t9 +where c1= @arg00 and c2= @arg00 and c3= @arg00 and c4= @arg00 and c5= @arg00 +and c6= @arg00 and c7= @arg00 and c8= @arg00 and c9= @arg00 and c10= @arg00 +and c12= @arg00; +found +true +prepare stmt1 from "select 'true' as found from t9 +where c1= 20.0 and c2= 20.0 and c3= 20.0 and c4= 20.0 and c5= 20.0 and c6= 20.0 + and c7= 20.0 and c8= 20.0 and c9= 20.0 and c10= 20.0 and c12= 20.0 "; +execute stmt1 ; +found +true +prepare stmt1 from "select 'true' as found from t9 +where c1= ? and c2= ? and c3= ? and c4= ? and c5= ? + and c6= ? and c7= ? and c8= ? and c9= ? and c10= ? + and c12= ? "; +execute stmt1 using @arg00, @arg00, @arg00, @arg00, @arg00, @arg00, @arg00, +@arg00, @arg00, @arg00, @arg00 ; +found +true +select 'true' as found from t9 +where c1= '20' and c2= '20' and c3= '20' and c4= '20' and c5= '20' and c6= '20' + and c7= '20' and c8= '20' and c9= '20' and c10= '20' and c12= '20'; +found +true +prepare stmt1 from "select 'true' as found from t9 +where c1= '20' and c2= '20' and c3= '20' and c4= '20' and c5= '20' and c6= '20' + and c7= '20' and c8= '20' and c9= '20' and c10= '20' and c12= '20' "; +execute stmt1 ; +found +true +set @arg00= '20'; +select 'true' as found from t9 +where c1= @arg00 and c2= @arg00 and c3= @arg00 and c4= @arg00 and c5= @arg00 +and c6= @arg00 and c7= @arg00 and c8= @arg00 and c9= @arg00 and c10= @arg00 +and c12= @arg00; +found +true +prepare stmt1 from "select 'true' as found from t9 +where c1= ? and c2= ? and c3= ? and c4= ? and c5= ? + and c6= ? and c7= ? and c8= ? and c9= ? and c10= ? + and c12= ? "; +execute stmt1 using @arg00, @arg00, @arg00, @arg00, @arg00, @arg00, @arg00, +@arg00, @arg00, @arg00, @arg00 ; +found +true +select 'true' as found from t9 +where c1= CAST('20' as binary) and c2= CAST('20' as binary) and +c3= CAST('20' as binary) and c4= CAST('20' as binary) and +c5= CAST('20' as binary) and c6= CAST('20' as binary) and +c7= CAST('20' as binary) and c8= CAST('20' as binary) and +c9= CAST('20' as binary) and c10= CAST('20' as binary) and +c12= CAST('20' as binary); +found +true +prepare stmt1 from "select 'true' as found from t9 +where c1= CAST('20' as binary) and c2= CAST('20' as binary) and + c3= CAST('20' as binary) and c4= CAST('20' as binary) and + c5= CAST('20' as binary) and c6= CAST('20' as binary) and + c7= CAST('20' as binary) and c8= CAST('20' as binary) and + c9= CAST('20' as binary) and c10= CAST('20' as binary) and + c12= CAST('20' as binary) "; +execute stmt1 ; +found +true +set @arg00= CAST('20' as binary) ; +select 'true' as found from t9 +where c1= @arg00 and c2= @arg00 and c3= @arg00 and c4= @arg00 and c5= @arg00 +and c6= @arg00 and c7= @arg00 and c8= @arg00 and c9= @arg00 and c10= @arg00 +and c12= @arg00; +found +true +prepare stmt1 from "select 'true' as found from t9 +where c1= ? and c2= ? and c3= ? and c4= ? and c5= ? + and c6= ? and c7= ? and c8= ? and c9= ? and c10= ? + and c12= ? "; +execute stmt1 using @arg00, @arg00, @arg00, @arg00, @arg00, @arg00, @arg00, +@arg00, @arg00, @arg00, @arg00 ; +found +true +delete from t9 ; +test_sequence +-- some numeric overflow experiments -- +prepare my_insert from "insert into t9 + ( c21, c1, c2, c3, c4, c5, c6, c7, c8, c9, c10, c12 ) +values + ( 'O', ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ? )" ; +prepare my_select from "select c1, c2, c3, c4, c5, c6, c7, c8, c9, c10, c12 +from t9 where c21 = 'O' "; +prepare my_delete from "delete from t9 where c21 = 'O' "; +set @arg00= 9223372036854775807 ; +execute my_insert using @arg00, @arg00, @arg00, @arg00, @arg00, @arg00, +@arg00, @arg00, @arg00, @arg00, @arg00 ; +Warnings: +Warning 1264 Out of range value for column 'c1' at row 1 +Warning 1264 Out of range value for column 'c2' at row 1 +Warning 1264 Out of range value for column 'c3' at row 1 +Warning 1264 Out of range value for column 'c4' at row 1 +Warning 1264 Out of range value for column 'c5' at row 1 +Warning 1264 Out of range value for column 'c12' at row 1 +execute my_select ; +c1 127 +c2 32767 +c3 8388607 +c4 2147483647 +c5 2147483647 +c6 9223372036854775807 +c7 9.22337e+18 +c8 9.22337203685478e+18 +c9 9.22337203685478e+18 +c10 9.22337203685478e+18 +c12 9999.9999 +execute my_delete ; +set @arg00= '9223372036854775807' ; +execute my_insert using @arg00, @arg00, @arg00, @arg00, @arg00, @arg00, +@arg00, @arg00, @arg00, @arg00, @arg00 ; +Warnings: +Warning 1264 Out of range value for column 'c1' at row 1 +Warning 1264 Out of range value for column 'c2' at row 1 +Warning 1264 Out of range value for column 'c3' at row 1 +Warning 1264 Out of range value for column 'c4' at row 1 +Warning 1264 Out of range value for column 'c5' at row 1 +Warning 1264 Out of range value for column 'c12' at row 1 +execute my_select ; +c1 127 +c2 32767 +c3 8388607 +c4 2147483647 +c5 2147483647 +c6 9223372036854775807 +c7 9.22337e+18 +c8 9.22337203685478e+18 +c9 9.22337203685478e+18 +c10 9.22337203685478e+18 +c12 9999.9999 +execute my_delete ; +set @arg00= -9223372036854775808 ; +execute my_insert using @arg00, @arg00, @arg00, @arg00, @arg00, @arg00, +@arg00, @arg00, @arg00, @arg00, @arg00 ; +Warnings: +Warning 1264 Out of range value for column 'c1' at row 1 +Warning 1264 Out of range value for column 'c2' at row 1 +Warning 1264 Out of range value for column 'c3' at row 1 +Warning 1264 Out of range value for column 'c4' at row 1 +Warning 1264 Out of range value for column 'c5' at row 1 +Warning 1264 Out of range value for column 'c12' at row 1 +execute my_select ; +c1 -128 +c2 -32768 +c3 -8388608 +c4 -2147483648 +c5 -2147483648 +c6 -9223372036854775808 +c7 -9.22337e+18 +c8 -9.22337203685478e+18 +c9 -9.22337203685478e+18 +c10 -9.22337203685478e+18 +c12 -9999.9999 +execute my_delete ; +set @arg00= '-9223372036854775808' ; +execute my_insert using @arg00, @arg00, @arg00, @arg00, @arg00, @arg00, +@arg00, @arg00, @arg00, @arg00, @arg00 ; +Warnings: +Warning 1264 Out of range value for column 'c1' at row 1 +Warning 1264 Out of range value for column 'c2' at row 1 +Warning 1264 Out of range value for column 'c3' at row 1 +Warning 1264 Out of range value for column 'c4' at row 1 +Warning 1264 Out of range value for column 'c5' at row 1 +Warning 1264 Out of range value for column 'c12' at row 1 +execute my_select ; +c1 -128 +c2 -32768 +c3 -8388608 +c4 -2147483648 +c5 -2147483648 +c6 -9223372036854775808 +c7 -9.22337e+18 +c8 -9.22337203685478e+18 +c9 -9.22337203685478e+18 +c10 -9.22337203685478e+18 +c12 -9999.9999 +execute my_delete ; +set @arg00= 1.11111111111111111111e+50 ; +execute my_insert using @arg00, @arg00, @arg00, @arg00, @arg00, @arg00, +@arg00, @arg00, @arg00, @arg00, @arg00 ; +Warnings: +Warning 1264 Out of range value for column 'c1' at row 1 +Warning 1264 Out of range value for column 'c2' at row 1 +Warning 1264 Out of range value for column 'c3' at row 1 +Warning 1264 Out of range value for column 'c4' at row 1 +Warning 1264 Out of range value for column 'c5' at row 1 +Warning 1264 Out of range value for column 'c6' at row 1 +Warning 1264 Out of range value for column 'c7' at row 1 +Warning 1264 Out of range value for column 'c12' at row 1 +execute my_select ; +c1 127 +c2 32767 +c3 8388607 +c4 2147483647 +c5 2147483647 +c6 9223372036854775807 +c7 3.40282e+38 +c8 1.11111111111111e+50 +c9 1.11111111111111e+50 +c10 1.11111111111111e+50 +c12 9999.9999 +execute my_delete ; +set @arg00= '1.11111111111111111111e+50' ; +execute my_insert using @arg00, @arg00, @arg00, @arg00, @arg00, @arg00, +@arg00, @arg00, @arg00, @arg00, @arg00 ; +Warnings: +Warning 1264 Out of range value for column 'c1' at row 1 +Warning 1264 Out of range value for column 'c2' at row 1 +Warning 1264 Out of range value for column 'c3' at row 1 +Warning 1264 Out of range value for column 'c4' at row 1 +Warning 1264 Out of range value for column 'c5' at row 1 +Warning 1264 Out of range value for column 'c6' at row 1 +Warning 1264 Out of range value for column 'c7' at row 1 +Warning 1264 Out of range value for column 'c12' at row 1 +execute my_select ; +c1 127 +c2 32767 +c3 8388607 +c4 2147483647 +c5 2147483647 +c6 9223372036854775807 +c7 3.40282e+38 +c8 1.11111111111111e+50 +c9 1.11111111111111e+50 +c10 1.11111111111111e+50 +c12 9999.9999 +execute my_delete ; +set @arg00= -1.11111111111111111111e+50 ; +execute my_insert using @arg00, @arg00, @arg00, @arg00, @arg00, @arg00, +@arg00, @arg00, @arg00, @arg00, @arg00 ; +Warnings: +Warning 1264 Out of range value for column 'c1' at row 1 +Warning 1264 Out of range value for column 'c2' at row 1 +Warning 1264 Out of range value for column 'c3' at row 1 +Warning 1264 Out of range value for column 'c4' at row 1 +Warning 1264 Out of range value for column 'c5' at row 1 +Warning 1264 Out of range value for column 'c6' at row 1 +Warning 1264 Out of range value for column 'c7' at row 1 +Warning 1264 Out of range value for column 'c12' at row 1 +execute my_select ; +c1 -128 +c2 -32768 +c3 -8388608 +c4 -2147483648 +c5 -2147483648 +c6 -9223372036854775808 +c7 -3.40282e+38 +c8 -1.11111111111111e+50 +c9 -1.11111111111111e+50 +c10 -1.11111111111111e+50 +c12 -9999.9999 +execute my_delete ; +set @arg00= '-1.11111111111111111111e+50' ; +execute my_insert using @arg00, @arg00, @arg00, @arg00, @arg00, @arg00, +@arg00, @arg00, @arg00, @arg00, @arg00 ; +Warnings: +Warning 1264 Out of range value for column 'c1' at row 1 +Warning 1264 Out of range value for column 'c2' at row 1 +Warning 1264 Out of range value for column 'c3' at row 1 +Warning 1264 Out of range value for column 'c4' at row 1 +Warning 1264 Out of range value for column 'c5' at row 1 +Warning 1264 Out of range value for column 'c6' at row 1 +Warning 1264 Out of range value for column 'c7' at row 1 +Warning 1264 Out of range value for column 'c12' at row 1 +execute my_select ; +c1 -128 +c2 -32768 +c3 -8388608 +c4 -2147483648 +c5 -2147483648 +c6 -9223372036854775808 +c7 -3.40282e+38 +c8 -1.11111111111111e+50 +c9 -1.11111111111111e+50 +c10 -1.11111111111111e+50 +c12 -9999.9999 +execute my_delete ; +test_sequence +-- insert into string columns -- +Warnings: +Warning 1265 Data truncated for column 'c20' at row 1 +Warnings: +Warning 1265 Data truncated for column 'c20' at row 1 +Warnings: +Warning 1265 Data truncated for column 'c20' at row 1 +Warnings: +Warning 1265 Data truncated for column 'c20' at row 1 +Warnings: +Warning 1265 Data truncated for column 'c20' at row 1 +Warnings: +Warning 1265 Data truncated for column 'c20' at row 1 +Warnings: +Warning 1265 Data truncated for column 'c20' at row 1 +Warnings: +Warning 1265 Data truncated for column 'c20' at row 1 +Warnings: +Warning 1265 Data truncated for column 'c20' at row 1 +Warnings: +Warning 1265 Data truncated for column 'c20' at row 1 +Warnings: +Warning 1265 Data truncated for column 'c20' at row 1 +Warnings: +Warning 1265 Data truncated for column 'c20' at row 1 +Warnings: +Warning 1265 Data truncated for column 'c20' at row 1 +Warnings: +Warning 1265 Data truncated for column 'c20' at row 1 +Warnings: +Warning 1265 Data truncated for column 'c20' at row 1 +Warnings: +Warning 1265 Data truncated for column 'c20' at row 1 +Warnings: +Warning 1265 Data truncated for column 'c20' at row 1 +Warnings: +Warning 1265 Data truncated for column 'c20' at row 1 +Warnings: +Warning 1265 Data truncated for column 'c20' at row 1 +Warnings: +Warning 1265 Data truncated for column 'c20' at row 1 +select c1, c20, c21, c22, c23, c24, c25, c26, c27, c28, c29, c30 +from t9 where c1 >= 20 +order by c1 ; +c1 c20 c21 c22 c23 c24 c25 c26 c27 c28 c29 c30 +20 2 20 20 20 20 20 20 20 20 20 20 +21 2 21 21 21 21 21 21 21 21 21 21 +22 2 22 22 22 22 22 22 22 22 22 22 +23 2 23 23 23 23 23 23 23 23 23 23 +30 3 30 30 30 30 30 30 30 30 30 30 +31 3 31 31 31 31 31 31 31 31 31 31 +32 3 32 32 32 32 32 32 32 32 32 32 +33 3 33 33 33 33 33 33 33 33 33 33 +40 4 40 40 40 40 40 40 40 40 40 40 +41 4 41 41 41 41 41 41 41 41 41 41 +42 4 42 42 42 42 42 42 42 42 42 42 +43 4 43 43 43 43 43 43 43 43 43 43 +50 5 50.0 50.0 50.0 50.0 50.0 50.0 50.0 50.0 50.0 50.0 +51 5 51.0 51.0 51.0 51.0 51.0 51.0 51.0 51.0 51.0 51.0 +52 5 52.0 52.0 52.0 52.0 52.0 52.0 52.0 52.0 52.0 52.0 +53 5 53.0 53.0 53.0 53.0 53.0 53.0 53.0 53.0 53.0 53.0 +54 5 54 54 54.00 54.00 54.00 54.00 54.00 54.00 54.00 54.00 +55 5 55 55 55 55 55 55 55 55 55 55 +56 6 56 56 56.00 56.00 56.00 56.00 56.00 56.00 56.00 56.00 +57 6 57 57 57.00 57.00 57.00 57.00 57.00 57.00 57.00 57.00 +60 NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL +61 NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL +62 NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL +63 NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL +71 NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL +73 NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL +81 NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL +83 NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL +test_sequence +-- select .. where string column = .. -- +set @arg00= '20'; +select 'true' as found from t9 +where c1= 20 and concat(c20,substr('20',1+length(c20)))= '20' and c21= '20' and +c22= '20' and c23= '20' and c24= '20' and c25= '20' and c26= '20' and +c27= '20' and c28= '20' and c29= '20' and c30= '20' ; +found +true +select 'true' as found from t9 +where c1= 20 and concat(c20,substr(@arg00,1+length(c20)))= @arg00 and +c21= @arg00 and c22= @arg00 and c23= @arg00 and c25= @arg00 and +c26= @arg00 and c27= @arg00 and c28= @arg00 and c29= @arg00 and c30= @arg00; +found +true +prepare stmt1 from "select 'true' as found from t9 +where c1= 20 and concat(c20,substr('20',1+length(c20)))= '20' and c21= '20' and + c22= '20' and c23= '20' and c24= '20' and c25= '20' and c26= '20' and + c27= '20' and c28= '20' and c29= '20' and c30= '20'" ; +execute stmt1 ; +found +true +prepare stmt1 from "select 'true' as found from t9 +where c1= 20 and concat(c20,substr(?,1+length(c20)))= ? and + c21= ? and c22= ? and c23= ? and c25= ? and + c26= ? and c27= ? and c28= ? and c29= ? and c30= ?" ; +execute stmt1 using @arg00, @arg00, @arg00, @arg00, @arg00, @arg00, +@arg00, @arg00, @arg00, @arg00, @arg00 ; +found +true +set @arg00= CAST('20' as binary); +select 'true' as found from t9 +where c1= 20 and concat(c20,substr(CAST('20' as binary),1+length(c20))) += CAST('20' as binary) and c21= CAST('20' as binary) +and c22= CAST('20' as binary) and c23= CAST('20' as binary) and +c24= CAST('20' as binary) and c25= CAST('20' as binary) and +c26= CAST('20' as binary) and c27= CAST('20' as binary) and +c28= CAST('20' as binary) and c29= CAST('20' as binary) and +c30= CAST('20' as binary) ; +found +true +select 'true' as found from t9 +where c1= 20 and concat(c20,substr(@arg00,1+length(c20))) = @arg00 and +c21= @arg00 and c22= @arg00 and c23= @arg00 and c25= @arg00 and +c26= @arg00 and c27= @arg00 and c28= @arg00 and c29= @arg00 and +c30= @arg00; +found +true +prepare stmt1 from "select 'true' as found from t9 +where c1= 20 and concat(c20,substr(CAST('20' as binary),1+length(c20))) + = CAST('20' as binary) and c21= CAST('20' as binary) + and c22= CAST('20' as binary) and c23= CAST('20' as binary) and + c24= CAST('20' as binary) and c25= CAST('20' as binary) and + c26= CAST('20' as binary) and c27= CAST('20' as binary) and + c28= CAST('20' as binary) and c29= CAST('20' as binary) and + c30= CAST('20' as binary)" ; +execute stmt1 ; +found +true +prepare stmt1 from "select 'true' as found from t9 +where c1= 20 and concat(c20,substr(?,1+length(c20))) = ? and c21= ? and + c22= ? and c23= ? and c25= ? and c26= ? and c27= ? and c28= ? and + c29= ? and c30= ?"; +execute stmt1 using @arg00, @arg00, @arg00, @arg00, @arg00, @arg00, +@arg00, @arg00, @arg00, @arg00, @arg00 ; +found +true +set @arg00= 20; +select 'true' as found from t9 +where c1= 20 and concat(c20,substr(20,1+length(c20)))= 20 and c21= 20 and +c22= 20 and c23= 20 and c24= 20 and c25= 20 and c26= 20 and +c27= 20 and c28= 20 and c29= 20 and c30= 20 ; +found +true +select 'true' as found from t9 +where c1= 20 and concat(c20,substr(@arg00,1+length(c20)))= @arg00 and +c21= @arg00 and c22= @arg00 and c23= @arg00 and c25= @arg00 and +c26= @arg00 and c27= @arg00 and c28= @arg00 and c29= @arg00 and c30= @arg00; +found +true +prepare stmt1 from "select 'true' as found from t9 +where c1= 20 and concat(c20,substr(20,1+length(c20)))= 20 and c21= 20 and + c22= 20 and c23= 20 and c24= 20 and c25= 20 and c26= 20 and + c27= 20 and c28= 20 and c29= 20 and c30= 20" ; +execute stmt1 ; +found +true +prepare stmt1 from "select 'true' as found from t9 +where c1= 20 and concat(c20,substr(?,1+length(c20)))= ? and + c21= ? and c22= ? and c23= ? and c25= ? and + c26= ? and c27= ? and c28= ? and c29= ? and c30= ?" ; +execute stmt1 using @arg00, @arg00, @arg00, @arg00, @arg00, @arg00, +@arg00, @arg00, @arg00, @arg00, @arg00 ; +found +true +set @arg00= 20.0; +select 'true' as found from t9 +where c1= 20 and concat(c20,substr(20.0,1+length(c20)))= 20.0 and c21= 20.0 and +c22= 20.0 and c23= 20.0 and c24= 20.0 and c25= 20.0 and c26= 20.0 and +c27= 20.0 and c28= 20.0 and c29= 20.0 and c30= 20.0 ; +found +true +select 'true' as found from t9 +where c1= 20 and concat(c20,substr(@arg00,1+length(c20)))= @arg00 and +c21= @arg00 and c22= @arg00 and c23= @arg00 and c25= @arg00 and +c26= @arg00 and c27= @arg00 and c28= @arg00 and c29= @arg00 and c30= @arg00; +found +true +prepare stmt1 from "select 'true' as found from t9 +where c1= 20 and concat(c20,substr(20.0,1+length(c20)))= 20.0 and c21= 20.0 and + c22= 20.0 and c23= 20.0 and c24= 20.0 and c25= 20.0 and c26= 20.0 and + c27= 20.0 and c28= 20.0 and c29= 20.0 and c30= 20.0" ; +execute stmt1 ; +found +true +prepare stmt1 from "select 'true' as found from t9 +where c1= 20 and concat(c20,substr(?,1+length(c20)))= ? and + c21= ? and c22= ? and c23= ? and c25= ? and + c26= ? and c27= ? and c28= ? and c29= ? and c30= ?" ; +execute stmt1 using @arg00, @arg00, @arg00, @arg00, @arg00, @arg00, +@arg00, @arg00, @arg00, @arg00, @arg00 ; +found +true +delete from t9 ; +test_sequence +-- insert into date/time columns -- +Warnings: +Note 1265 Data truncated for column 'c13' at row 1 +Warning 1265 Data truncated for column 'c17' at row 1 +Warnings: +Note 1265 Data truncated for column 'c13' at row 1 +Warning 1265 Data truncated for column 'c17' at row 1 +Warnings: +Note 1265 Data truncated for column 'c13' at row 1 +Warning 1265 Data truncated for column 'c17' at row 1 +Warnings: +Note 1265 Data truncated for column 'c13' at row 1 +Warning 1265 Data truncated for column 'c17' at row 1 +Warnings: +Warning 1265 Data truncated for column 'c17' at row 1 +Warnings: +Note 1265 Data truncated for column 'c13' at row 1 +Warning 1265 Data truncated for column 'c17' at row 1 +Warnings: +Warning 1265 Data truncated for column 'c17' at row 1 +Warnings: +Note 1265 Data truncated for column 'c13' at row 1 +Warning 1265 Data truncated for column 'c17' at row 1 +Warnings: +Warning 1264 Out of range value for column 'c13' at row 1 +Warning 1264 Out of range value for column 'c14' at row 1 +Warning 1265 Data truncated for column 'c15' at row 1 +Warning 1264 Out of range value for column 'c16' at row 1 +Warning 1264 Out of range value for column 'c17' at row 1 +Warnings: +Warning 1264 Out of range value for column 'c13' at row 1 +Warning 1264 Out of range value for column 'c14' at row 1 +Warning 1265 Data truncated for column 'c15' at row 1 +Warning 1264 Out of range value for column 'c16' at row 1 +Warning 1264 Out of range value for column 'c17' at row 1 +Warnings: +Warning 1264 Out of range value for column 'c13' at row 1 +Warning 1264 Out of range value for column 'c14' at row 1 +Warning 1265 Data truncated for column 'c15' at row 1 +Warning 1264 Out of range value for column 'c16' at row 1 +Warning 1264 Out of range value for column 'c17' at row 1 +Warnings: +Warning 1264 Out of range value for column 'c13' at row 1 +Warning 1264 Out of range value for column 'c14' at row 1 +Warning 1265 Data truncated for column 'c15' at row 1 +Warning 1264 Out of range value for column 'c16' at row 1 +Warning 1264 Out of range value for column 'c17' at row 1 +Warnings: +Warning 1265 Data truncated for column 'c15' at row 1 +Warning 1264 Out of range value for column 'c16' at row 1 +Warning 1264 Out of range value for column 'c17' at row 1 +Warnings: +Note 1265 Data truncated for column 'c13' at row 1 +Warning 1265 Data truncated for column 'c15' at row 1 +Warning 1264 Out of range value for column 'c16' at row 1 +Warning 1264 Out of range value for column 'c17' at row 1 +Warnings: +Warning 1265 Data truncated for column 'c15' at row 1 +Warning 1264 Out of range value for column 'c16' at row 1 +Warning 1264 Out of range value for column 'c17' at row 1 +Warnings: +Warning 1265 Data truncated for column 'c15' at row 1 +Warning 1264 Out of range value for column 'c16' at row 1 +Warning 1264 Out of range value for column 'c17' at row 1 +select c1, c13, c14, c15, c16, c17 from t9 order by c1 ; +c1 c13 c14 c15 c16 c17 +20 1991-01-01 1991-01-01 01:01:01 1991-01-01 01:01:01 01:01:01 1991 +21 1991-01-01 1991-01-01 01:01:01 1991-01-01 01:01:01 01:01:01 1991 +22 1991-01-01 1991-01-01 01:01:01 1991-01-01 01:01:01 01:01:01 1991 +23 1991-01-01 1991-01-01 01:01:01 1991-01-01 01:01:01 01:01:01 1991 +30 1991-01-01 1991-01-01 01:01:01 1991-01-01 01:01:01 01:01:01 1991 +31 1991-01-01 1991-01-01 01:01:01 1991-01-01 01:01:01 01:01:01 1991 +32 1991-01-01 1991-01-01 01:01:01 1991-01-01 01:01:01 01:01:01 1991 +33 1991-01-01 1991-01-01 01:01:01 1991-01-01 01:01:01 01:01:01 1991 +40 0000-00-00 0000-00-00 00:00:00 0000-00-00 00:00:00 838:59:59 0000 +41 0000-00-00 0000-00-00 00:00:00 0000-00-00 00:00:00 838:59:59 0000 +42 0000-00-00 0000-00-00 00:00:00 0000-00-00 00:00:00 838:59:59 0000 +43 0000-00-00 0000-00-00 00:00:00 0000-00-00 00:00:00 838:59:59 0000 +50 2001-00-00 2001-00-00 00:00:00 0000-00-00 00:00:00 838:59:59 0000 +51 2010-00-00 2010-00-00 00:00:00 0000-00-00 00:00:00 838:59:59 0000 +52 2001-00-00 2001-00-00 00:00:00 0000-00-00 00:00:00 838:59:59 0000 +53 2001-00-00 2001-00-00 00:00:00 0000-00-00 00:00:00 838:59:59 0000 +60 NULL NULL 1991-01-01 01:01:01 NULL NULL +61 NULL NULL 1991-01-01 01:01:01 NULL NULL +62 NULL NULL 1991-01-01 01:01:01 NULL NULL +63 NULL NULL 1991-01-01 01:01:01 NULL NULL +71 NULL NULL 1991-01-01 01:01:01 NULL NULL +73 NULL NULL 1991-01-01 01:01:01 NULL NULL +81 NULL NULL 1991-01-01 01:01:01 NULL NULL +83 NULL NULL 1991-01-01 01:01:01 NULL NULL +test_sequence +-- select .. where date/time column = .. -- +set @arg00= '1991-01-01 01:01:01' ; +select 'true' as found from t9 +where c1= 20 and c13= CAST('1991-01-01 01:01:01' AS DATE) and c14= '1991-01-01 01:01:01' and +c15= '1991-01-01 01:01:01' and c16= '1991-01-01 01:01:01' and +c17= '1991-01-01 01:01:01' ; +found +true +select 'true' as found from t9 +where c1= 20 and c13= CAST(@arg00 AS DATE) and c14= @arg00 and c15= @arg00 and c16= @arg00 +and c17= @arg00 ; +found +true +prepare stmt1 from "select 'true' as found from t9 +where c1= 20 and c13= CAST('1991-01-01 01:01:01' AS DATE) and c14= '1991-01-01 01:01:01' and + c15= '1991-01-01 01:01:01' and c16= '1991-01-01 01:01:01' and + c17= '1991-01-01 01:01:01'" ; +execute stmt1 ; +found +true +prepare stmt1 from "select 'true' as found from t9 +where c1= 20 and c13= CAST(? AS DATE) and c14= ? and c15= ? and c16= ? and c17= ?" ; +execute stmt1 using @arg00, @arg00, @arg00, @arg00, @arg00 ; +found +true +set @arg00= CAST('1991-01-01 01:01:01' as datetime) ; +select 'true' as found from t9 +where c1= 20 and c13= CAST('1991-01-01 00:00:00' as datetime) and +c14= CAST('1991-01-01 01:01:01' as datetime) and +c15= CAST('1991-01-01 01:01:01' as datetime) and +c16= CAST('1991-01-01 01:01:01' as datetime) and +c17= CAST('1991-01-01 01:01:01' as datetime) ; +found +true +select 'true' as found from t9 +where c1= 20 and c13= CAST(@arg00 AS DATE) and c14= @arg00 and c15= @arg00 and c16= @arg00 +and c17= @arg00 ; +found +true +prepare stmt1 from "select 'true' as found from t9 +where c1= 20 and c13= CAST('1991-01-01 00:00:00' as datetime) and + c14= CAST('1991-01-01 01:01:01' as datetime) and + c15= CAST('1991-01-01 01:01:01' as datetime) and + c16= CAST('1991-01-01 01:01:01' as datetime) and + c17= CAST('1991-01-01 01:01:01' as datetime)" ; +execute stmt1 ; +found +true +prepare stmt1 from "select 'true' as found from t9 +where c1= 20 and c13= CAST(? AS DATE) and c14= ? and c15= ? and c16= ? and c17= ?" ; +execute stmt1 using @arg00, @arg00, @arg00, @arg00, @arg00 ; +found +true +set @arg00= 1991 ; +select 'true' as found from t9 +where c1= 20 and c17= 1991 ; +found +true +select 'true' as found from t9 +where c1= 20 and c17= @arg00 ; +found +true +prepare stmt1 from "select 'true' as found from t9 +where c1= 20 and c17= 1991" ; +execute stmt1 ; +found +true +prepare stmt1 from "select 'true' as found from t9 +where c1= 20 and c17= ?" ; +execute stmt1 using @arg00 ; +found +true +set @arg00= 1.991e+3 ; +select 'true' as found from t9 +where c1= 20 and abs(c17 - 1.991e+3) < 0.01 ; +found +true +select 'true' as found from t9 +where c1= 20 and abs(c17 - @arg00) < 0.01 ; +found +true +prepare stmt1 from "select 'true' as found from t9 +where c1= 20 and abs(c17 - 1.991e+3) < 0.01" ; +execute stmt1 ; +found +true +prepare stmt1 from "select 'true' as found from t9 +where c1= 20 and abs(c17 - ?) < 0.01" ; +execute stmt1 using @arg00 ; +found +true +drop table t1, t9; diff --git a/mysql-test/suite/ndb/r/strict_autoinc_5ndb.result b/mysql-test/suite/ndb/r/strict_autoinc_5ndb.result new file mode 100644 index 00000000000..ea6e5ffc741 --- /dev/null +++ b/mysql-test/suite/ndb/r/strict_autoinc_5ndb.result @@ -0,0 +1,28 @@ +drop table if exists t1; +set @org_mode=@@sql_mode; +create table t1 +( +`a` tinyint(4) NOT NULL auto_increment, +primary key (`a`) +) engine = 'NDB' ; +set @@sql_mode='strict_all_tables'; +insert into t1 values(1000); +ERROR 22003: Out of range value for column 'a' at row 1 +select count(*) from t1; +count(*) +0 +set auto_increment_increment=1000; +set auto_increment_offset=700; +insert into t1 values(null); +ERROR 22003: Out of range value for column 'a' at row 1 +select count(*) from t1; +count(*) +0 +set @@sql_mode=@org_mode; +insert into t1 values(null); +Warnings: +Warning 1264 Out of range value for column 'a' at row 1 +select * from t1; +a +127 +drop table t1; diff --git a/mysql-test/suite/ndb/t/disabled.def b/mysql-test/suite/ndb/t/disabled.def new file mode 100644 index 00000000000..023c9c47210 --- /dev/null +++ b/mysql-test/suite/ndb/t/disabled.def @@ -0,0 +1,25 @@ +############################################################################## +# +# List the test cases that are to be disabled temporarily. +# +# Separate the test case name and the comment with ':'. +# +# <testcasename> : BUG#<xxxx> <date disabled> <disabler> <comment> +# +# Do not use any TAB characters for whitespace. +# +############################################################################## +ndb_autodiscover : BUG#18952 2006-02-16 jmiller Needs to be fixed w.r.t binlog +ndb_autodiscover2 : BUG#18952 2006-02-16 jmiller Needs to be fixed w.r.t binlog +ndb_dd_sql_features : Bug#29102 ndb_dd_sql_features fails in pushbuild +ndb_load : BUG#17233 2006-05-04 tomas failed load data from infile causes mysqld dbug_assert, binlog not flushed + +partition_03ndb : BUG#16385 2006-03-24 mikael Partitions: crash when updating a range partitioned NDB table + +ndb_partition_error2 : HF is not sure if the test can work as internded on all the platforms + +# the below testcase have been reworked to avoid the bug, test contains comment, keep bug open +#ndb_binlog_ddl_multi : BUG#18976 2006-04-10 kent CRBR: multiple binlog, second binlog may miss schema log events +#ndb_binlog_discover : bug#21806 2006-08-24 +#ndb_autodiscover3 : bug#21806 +ndb_autodiscover3 : Bug#20872 2007-07-15 ingo master*.err: miscellaneous error messages diff --git a/mysql-test/suite/ndb/t/loaddata_autocom_ndb.test b/mysql-test/suite/ndb/t/loaddata_autocom_ndb.test new file mode 100644 index 00000000000..f4a6743aabe --- /dev/null +++ b/mysql-test/suite/ndb/t/loaddata_autocom_ndb.test @@ -0,0 +1,4 @@ +--source include/have_ndb.inc +let $engine_type=ndbcluster; + +--source include/loaddata_autocom.inc diff --git a/mysql-test/suite/ndb/t/ndb_alter_table.test b/mysql-test/suite/ndb/t/ndb_alter_table.test new file mode 100644 index 00000000000..082fe726927 --- /dev/null +++ b/mysql-test/suite/ndb/t/ndb_alter_table.test @@ -0,0 +1,438 @@ +-- source include/have_multi_ndb.inc +-- source include/not_embedded.inc + +--disable_warnings +DROP TABLE IF EXISTS t1, t2; +drop database if exists mysqltest; +--enable_warnings + +connect (con1,localhost,root,,test); +connect (con2,localhost,root,,test); + +connection con2; +-- sleep 2 +connection con1; + +# +# Basic test to show that the ALTER TABLE +# is working +# +CREATE TABLE t1 ( + a INT NOT NULL, + b INT NOT NULL +) ENGINE=ndbcluster; + +INSERT INTO t1 VALUES (9410,9412); + +ALTER TABLE t1 ADD COLUMN c int not null; +SELECT * FROM t1; + +DROP TABLE t1; + +# +# Verfify changing table names between databases +# +CREATE DATABASE mysqltest; +USE mysqltest; +CREATE TABLE t1 ( + a INT NOT NULL, + b INT NOT NULL +) ENGINE=ndbcluster; +RENAME TABLE t1 TO test.t1; +SHOW TABLES; +DROP DATABASE mysqltest; +USE test; +SHOW TABLES; +DROP TABLE t1; + +# +# More advanced test +# +create table t1 ( +col1 int not null auto_increment primary key, +col2 varchar(30) not null, +col3 varchar (20) not null, +col4 varchar(4) not null, +col5 enum('PENDING', 'ACTIVE', 'DISABLED') not null, +col6 int not null, to_be_deleted int) ENGINE=ndbcluster; +--replace_column 6 # 7 # 8 # 10 # 12 # 13 # 14 # 18 # +show table status; +SET SQL_MODE=NO_AUTO_VALUE_ON_ZERO; +insert into t1 values +(0,4,3,5,"PENDING",1,7),(NULL,4,3,5,"PENDING",1,7),(31,4,3,5,"PENDING",1,7), (7,4,3,5,"PENDING",1,7), (NULL,4,3,5,"PENDING",1,7), (100,4,3,5,"PENDING",1,7), (99,4,3,5,"PENDING",1,7), (8,4,3,5,"PENDING",1,7), (NULL,4,3,5,"PENDING",1,7); +--replace_column 6 # 7 # 8 # 10 # 12 # 13 # 14 # 18 # +show table status; +select * from t1 order by col1; +alter table t1 +add column col4_5 varchar(20) not null after col4, +add column col7 varchar(30) not null after col5, +add column col8 datetime not null, drop column to_be_deleted, +change column col2 fourth varchar(30) not null after col3, +modify column col6 int not null first; +--replace_column 6 # 7 # 8 # 10 # 12 # 13 # 14 # 18 # +show table status; +select * from t1 order by col1; +insert into t1 values (2, NULL,4,3,5,99,"PENDING","EXTRA",'2004-01-01 00:00:00'); +--replace_column 6 # 7 # 8 # 10 # 12 # 13 # 14 # 18 # +show table status; +select * from t1 order by col1; +delete from t1; +insert into t1 values (0,0,4,3,5,99,"PENDING","EXTRA",'2004-01-01 00:00:00'); +SET SQL_MODE=''; +insert into t1 values (1,0,4,3,5,99,"PENDING","EXTRA",'2004-01-01 00:00:00'); +select * from t1 order by col1; +alter table t1 drop column col4_5; +insert into t1 values (2,0,4,3,5,"PENDING","EXTRA",'2004-01-01 00:00:00'); +select * from t1 order by col1; +drop table t1; + + +# +# Check that invalidating dictionary cache works +# + +CREATE TABLE t1 ( + a INT NOT NULL, + b INT NOT NULL +) ENGINE=ndbcluster; + +INSERT INTO t1 VALUES (9410,9412); + +ALTER TABLE t1 ADD COLUMN c int not null; +select * from t1 order by a; + +connection con2; +select * from t1 order by a; +alter table t1 drop c; + +connection con1; +select * from t1 order by a; +drop table t1; + +connection con2; +--error 1146 +select * from t1 order by a; + +CREATE TABLE t1 ( + a INT NOT NULL PRIMARY KEY, + b INT NOT NULL +) ENGINE=ndbcluster; + +INSERT INTO t1 VALUES (0,1),(17,18); +select * from t1 order by a; +SET SQL_MODE=NO_AUTO_VALUE_ON_ZERO; +alter table t1 modify column a int not null auto_increment; +SET SQL_MODE=''; +select * from t1 order by a; +INSERT INTO t1 VALUES (0,19),(20,21); +select * from t1 order by a; +drop table t1; + +CREATE TABLE t1 ( + a INT NOT NULL PRIMARY KEY, + b INT NOT NULL +) ENGINE=ndbcluster; + +INSERT INTO t1 VALUES (0,1),(17,18); +select * from t1 order by a; +alter table t1 add c int not null unique auto_increment; +select c from t1 order by c; +INSERT INTO t1 VALUES (1,2,0),(18,19,4),(20,21,0); +select c from t1 order by c; +drop table t1; + +## Test moved to ndb_alter_table_row|stmt respectively as behaviour differs +#create table t1 ( a int primary key, b varchar(10), c varchar(10), index (b) ) +#engine=ndb; +#insert into t1 values (1,'one','one'), (2,'two','two'), (3,'three','three'); +#create index c on t1(c); +#connection server2; +#select * from t1 where c = 'two'; +#connection server1; +#alter table t1 drop index c; +#connection server2; +#select * from t1 where c = 'two'; +#connection server1; +#drop table t1; + +#--disable_warnings +#DROP TABLE IF EXISTS t2; +#--enable_warnings + +#create table t2 (a int NOT NULL PRIMARY KEY) engine=myisam; +#let $1=12001; +#disable_query_log; +#while ($1) +#{ +# eval insert into t2 values($1); +# dec $1; +#} +#enable_query_log; +#alter table t2 engine=ndbcluster; +#alter table t2 add c int; +#--error 1297 +#delete from t2; +#to make sure we do a full table scan +#select count(*) from t2 where a+0 > 0; +#truncate table t2; +#select count(*) from t2; +#drop table t2; + +## Test moved to ndb_alter_table_row|stmt respectively as behaviour differs +#connection server1; +#create table t3 (a int primary key) engine=ndbcluster; + +#connection server2; +#begin; +#insert into t3 values (1); + +#connection server1; +#alter table t3 rename t4; + +#connection server2; +## with rbr the below will not work as the "alter" event +## explicitly invalidates the dictionary cache. +### This should work as transaction is ongoing... +##delete from t3; +##insert into t3 values (1); +#commit; + +## This should fail as its a new transaction +#--error 1146 +#select * from t3; +#select * from t4; +#drop table t4; +#show tables; +#connection server1; + +create table t1 ( +ai bigint auto_increment, +c001 int(11) not null, +c002 int(11) not null, +c003 int(11) not null, +c004 int(11) not null, +c005 int(11) not null, +c006 int(11) not null, +c007 int(11) not null, +c008 int(11) not null, +c009 int(11) not null, +c010 int(11) not null, +c011 int(11) not null, +c012 int(11) not null, +c013 int(11) not null, +c014 int(11) not null, +c015 int(11) not null, +c016 int(11) not null, +c017 int(11) not null, +c018 int(11) not null, +c019 int(11) not null, +c020 int(11) not null, +c021 int(11) not null, +c022 int(11) not null, +c023 int(11) not null, +c024 int(11) not null, +c025 int(11) not null, +c026 int(11) not null, +c027 int(11) not null, +c028 int(11) not null, +c029 int(11) not null, +c030 int(11) not null, +c031 int(11) not null, +c032 int(11) not null, +c033 int(11) not null, +c034 int(11) not null, +c035 int(11) not null, +c036 int(11) not null, +c037 int(11) not null, +c038 int(11) not null, +c039 int(11) not null, +c040 int(11) not null, +c041 int(11) not null, +c042 int(11) not null, +c043 int(11) not null, +c044 int(11) not null, +c045 int(11) not null, +c046 int(11) not null, +c047 int(11) not null, +c048 int(11) not null, +c049 int(11) not null, +c050 int(11) not null, +c051 int(11) not null, +c052 int(11) not null, +c053 int(11) not null, +c054 int(11) not null, +c055 int(11) not null, +c056 int(11) not null, +c057 int(11) not null, +c058 int(11) not null, +c059 int(11) not null, +c060 int(11) not null, +c061 int(11) not null, +c062 int(11) not null, +c063 int(11) not null, +c064 int(11) not null, +c065 int(11) not null, +c066 int(11) not null, +c067 int(11) not null, +c068 int(11) not null, +c069 int(11) not null, +c070 int(11) not null, +c071 int(11) not null, +c072 int(11) not null, +c073 int(11) not null, +c074 int(11) not null, +c075 int(11) not null, +c076 int(11) not null, +c077 int(11) not null, +c078 int(11) not null, +c079 int(11) not null, +c080 int(11) not null, +c081 int(11) not null, +c082 int(11) not null, +c083 int(11) not null, +c084 int(11) not null, +c085 int(11) not null, +c086 int(11) not null, +c087 int(11) not null, +c088 int(11) not null, +c089 int(11) not null, +c090 int(11) not null, +c091 int(11) not null, +c092 int(11) not null, +c093 int(11) not null, +c094 int(11) not null, +c095 int(11) not null, +c096 int(11) not null, +c097 int(11) not null, +c098 int(11) not null, +c099 int(11) not null, +c100 int(11) not null, +c101 int(11) not null, +c102 int(11) not null, +c103 int(11) not null, +c104 int(11) not null, +c105 int(11) not null, +c106 int(11) not null, +c107 int(11) not null, +c108 int(11) not null, +c109 int(11) not null, +primary key (ai), +unique key tx1 (c002, c003, c004, c005)) engine=ndb; + +create index tx2 +on t1 (c010, c011, c012, c013); + +drop table t1; + +# End of 4.1 tests + +# On-line alter table + + +CREATE TABLE t1 ( + auto int(5) unsigned NOT NULL auto_increment, + string char(10), + vstring varchar(10), + bin binary(2), + vbin varbinary(7), + tiny tinyint(4) DEFAULT '0' NOT NULL , + short smallint(6) DEFAULT '1' NOT NULL , + medium mediumint(8) DEFAULT '0' NOT NULL, + long_int int(11) DEFAULT '0' NOT NULL, + longlong bigint(13) DEFAULT '0' NOT NULL, + real_float float(13,1) DEFAULT 0.0 NOT NULL, + real_double double(16,4), + real_decimal decimal(16,4), + utiny tinyint(3) unsigned DEFAULT '0' NOT NULL, + ushort smallint(5) unsigned zerofill DEFAULT '00000' NOT NULL, + umedium mediumint(8) unsigned DEFAULT '0' NOT NULL, + ulong int(11) unsigned DEFAULT '0' NOT NULL, + ulonglong bigint(13) unsigned DEFAULT '0' NOT NULL, + bits bit(3), + options enum('zero','one','two','three','four') not null, + flags set('zero','one','two','three','four') not null, + date_field date, + year_field year, + time_field time, + date_time datetime, + time_stamp timestamp, + PRIMARY KEY (auto) +) engine=ndb; + +CREATE TEMPORARY TABLE ndb_show_tables (id INT, type VARCHAR(20), state VARCHAR(20), logging VARCHAR(20), _database VARCHAR(255), _schema VARCHAR(20), name VARCHAR(255)); + +--disable_warnings +--exec $NDB_TOOLS_DIR/ndb_show_tables --p > $MYSQLTEST_VARDIR/master-data/test/tmp.dat +LOAD DATA INFILE 'tmp.dat' INTO TABLE ndb_show_tables; +--enable_warnings + +# Ndb doesn't support renaming attributes on-line +set @t1_id = (select id from ndb_show_tables where name like '%t1%'); +truncate ndb_show_tables; + +alter table t1 change tiny new_tiny tinyint(4) DEFAULT '0' NOT NULL; +--disable_warnings +--exec $NDB_TOOLS_DIR/ndb_show_tables --p > $MYSQLTEST_VARDIR/master-data/test/tmp.dat +LOAD DATA INFILE 'tmp.dat' INTO TABLE ndb_show_tables; +--enable_warnings + +select 'no_copy' from ndb_show_tables where id = @t1_id and name like '%t1%'; + +set @t1_id = (select id from ndb_show_tables where name like '%t1%'); +truncate ndb_show_tables; + +create index i1 on t1(medium); +alter table t1 add index i2(new_tiny); +drop index i1 on t1; + +--disable_warnings +--exec $NDB_TOOLS_DIR/ndb_show_tables --p > $MYSQLTEST_VARDIR/master-data/test/tmp.dat +LOAD DATA INFILE 'tmp.dat' INTO TABLE ndb_show_tables; +--exec rm $MYSQLTEST_VARDIR/master-data/test/tmp.dat || true +--enable_warnings + +select 'no_copy' from ndb_show_tables where id = @t1_id and name like '%t1%'; + +DROP TABLE t1, ndb_show_tables; + +# simple test that auto incr is not lost at rename or alter +create table t1 (a int primary key auto_increment, b int) engine=ndb; +insert into t1 (b) values (101),(102),(103); +select * from t1 where a = 3; +alter table t1 rename t2; +insert into t2 (b) values (201),(202),(203); +select * from t2 where a = 6; +alter table t2 add c int; +insert into t2 (b) values (301),(302),(303); +select * from t2 where a = 9; +alter table t2 rename t1; +insert into t1 (b) values (401),(402),(403); +select * from t1 where a = 12; +drop table t1; + +# some other ALTER combinations +# add/drop pk +create table t1 (a int not null, b varchar(10)) engine=ndb; +show index from t1; +alter table t1 add primary key (a); +show index from t1; +alter table t1 drop primary key; +show index from t1; +drop table t1; + +# alter .. alter +create table t1 (a int not null primary key, b int not null default 0, c varchar(254)) engine=ndb; +show create table t1; +alter table t1 alter b set default 1; +show create table t1; +drop table t1; + +# alter .. order by +create table t1 (a int not null, b int not null) engine=ndb; +insert into t1 values (1, 300), (2, 200), (3, 100); +select * from t1 order by a; +alter table t1 order by b; +select * from t1 order by b; +drop table t1; + +--echo End of 5.1 tests diff --git a/mysql-test/suite/ndb/t/ndb_alter_table2.test b/mysql-test/suite/ndb/t/ndb_alter_table2.test new file mode 100644 index 00000000000..f078ed6b479 --- /dev/null +++ b/mysql-test/suite/ndb/t/ndb_alter_table2.test @@ -0,0 +1,84 @@ +-- source include/have_multi_ndb.inc +-- source include/not_embedded.inc + +--disable_warnings +DROP TABLE IF EXISTS t1; +--enable_warnings + +connect (con1,localhost,root,,test); +connect (con2,localhost,root,,test); +connect (con3,localhost,root,,test); +connect (con4,localhost,root,,test); +connect (con5,localhost,root,,test); +connect (con6,localhost,root,,test); + +CREATE TABLE t1 ( + a INT NOT NULL PRIMARY KEY, + b INT NOT NULL +) ENGINE=ndbcluster; + +connection con1; +BEGIN; +INSERT INTO t1 VALUES (9410,9412); +connection con2; +BEGIN; +--send +INSERT INTO t1 VALUES (9411,9412); +connection con3; +BEGIN; +--send +INSERT INTO t1 VALUES (9412,9412); +connection con4; +BEGIN; +--send +INSERT INTO t1 VALUES (9413,9412); +connection con5; +BEGIN; +--send +INSERT INTO t1 VALUES (9414,9412); +connection con6; +BEGIN; +--send +INSERT INTO t1 VALUES (9415,9412); +connection con1; +sleep 1; + +ROLLBACK; +connection con2; +reap; +ROLLBACK; +connection con3; +reap; +ROLLBACK; +connection con4; +reap; +ROLLBACK; +connection con5; +reap; +ROLLBACK; +connection con6; +reap; +ROLLBACK; + +connection server2; + +drop table t1; +CREATE TABLE t1 ( + a INT NOT NULL PRIMARY KEY, + b INT NOT NULL, + c INT NOT NULL +) ENGINE=ndbcluster; + +connection server1; + +--disable_result_log +--error 0,1412 +select * from t1; +--enable_result_log +select * from t1; +select * from t1; +select * from t1; +select * from t1; +select * from t1; + +drop table t1; diff --git a/mysql-test/suite/ndb/t/ndb_alter_table3.test b/mysql-test/suite/ndb/t/ndb_alter_table3.test new file mode 100644 index 00000000000..86e664b23b0 --- /dev/null +++ b/mysql-test/suite/ndb/t/ndb_alter_table3.test @@ -0,0 +1,48 @@ +-- source include/have_multi_ndb.inc +-- source include/not_embedded.inc + +--disable_warnings +DROP TABLE IF EXISTS t1; +--enable_warnings + +connection server1; +create table t1 ( a int primary key, b varchar(10), c varchar(10), index (b) ) +engine=ndb; +insert into t1 values (1,'one','one'), (2,'two','two'), (3,'three','three'); +create index c on t1(c); +connection server2; +show indexes from t1; +select * from t1 where c = 'two'; +connection server1; +alter table t1 drop index c; +connection server2; +show indexes from t1; +select * from t1 where c = 'two'; +connection server1; +drop table t1; + +connection server1; +create table t3 (a int primary key) engine=ndbcluster; + +connection server2; +begin; +insert into t3 values (1); + +connection server1; +alter table t3 rename t4; + +connection server2; +# with rbr the below will not work as the "alter" event +# explicitly invalidates the dictionary cache. +## This should work as transaction is ongoing... +#delete from t3; +#insert into t3 values (1); +commit; + +# This should fail as its a new transaction +--error 1146 +select * from t3; +select * from t4; +drop table t4; +show tables; +connection server1; diff --git a/mysql-test/suite/ndb/t/ndb_autodiscover.test b/mysql-test/suite/ndb/t/ndb_autodiscover.test new file mode 100644 index 00000000000..06d47693c10 --- /dev/null +++ b/mysql-test/suite/ndb/t/ndb_autodiscover.test @@ -0,0 +1,548 @@ +-- source include/have_ndb.inc +-- source include/not_embedded.inc + +--disable_warnings +drop table if exists t1,t2,t3,t4,t5,t6,t7,t8,t9,t10; +--enable_warnings + +################################################ +# Test that a table that does not exist as a +# frm file on disk can be "discovered" from a +# connected NDB Cluster +# + +flush status; + +# +# Test discover + SELECT +# + +create table t1( + id int not null primary key, + name char(20) +) engine=ndb; + +insert into t1 values(1, "Autodiscover"); +flush tables; +--remove_file $MYSQLTEST_VARDIR/master-data/test/t1.frm +select * from t1; +show status like 'handler_discover%'; + +# +# Test discover + INSERT +# + +flush tables; +--remove_file $MYSQLTEST_VARDIR/master-data/test/t1.frm +insert into t1 values (2, "Auto 2"); +show status like 'handler_discover%'; +insert into t1 values (3, "Discover 3"); +show status like 'handler_discover%'; +flush tables; +--remove_file $MYSQLTEST_VARDIR/master-data/test/t1.frm +select * from t1 order by id; +show status like 'handler_discover%'; + +# +# Test discover + UPDATE +# + +flush tables; +--remove_file $MYSQLTEST_VARDIR/master-data/test/t1.frm +update t1 set name="Autodiscover" where id = 2; +show status like 'handler_discover%'; +select * from t1 order by id; +show status like 'handler_discover%'; + +# +# Test discover + DELETE +# + +flush tables; +--remove_file $MYSQLTEST_VARDIR/master-data/test/t1.frm +delete from t1 where id = 3; +select * from t1 order by id; +show status like 'handler_discover%'; + +drop table t1; + + + +###################################################### +# Test that a table that is outdated on disk +# can be "discovered" from a connected NDB Cluster +# + +flush status; + +create table t2( + id int not null primary key, + name char(22) +) engine=ndb; +insert into t2 values (1, "Discoverer"); +select * from t2; +show status like 'handler_discover%'; +flush tables; + +# Modify the frm file on disk +system echo "blaj" >> $MYSQLTEST_VARDIR/master-data/test/t2.frm ; +select * from t2; + +show status like 'handler_discover%'; + +drop table t2; + + +################################################## +# Test that a table that already exists in NDB +# is only discovered if CREATE TABLE IF NOT EXISTS +# is used +# + +flush status; + +create table t3( + id int not null primary key, + name char(255) +) engine=ndb; +insert into t3 values (1, "Explorer"); +select * from t3; +show status like 'handler_discover%'; +flush tables; + +# Remove the frm file from disk +--remove_file $MYSQLTEST_VARDIR/master-data/test/t3.frm + +--error 1050 +create table t3( + id int not null primary key, + name char(20), a int, b float, c char(24) +) engine=ndb; + +# The table shall not have been discovered since +# IF NOT EXISTS wasn't specified + +show status like 'handler_discover%'; + +# now it should be discovered +create table IF NOT EXISTS t3( + id int not null primary key, + id2 int not null, + name char(20) +) engine=ndb; + +# NOTE! the table called t3 have now been updated to +# use the same frm as in NDB, thus it's not certain that +# the table schema is the same as was stated in the +# CREATE TABLE statement above + +show status like 'handler_discover%'; + +SHOW CREATE TABLE t3; + +select * from t3; +show status like 'handler_discover%'; + +drop table t3; + +################################################## +# Test that a table that already exists in NDB +# is discovered when SHOW TABLES +# is used +# + +flush status; + +create table t7( + id int not null primary key, + name char(255) +) engine=ndb; +create table t6( + id int not null primary key, + name char(255) +) engine=MyISAM; +insert into t7 values (1, "Explorer"); +insert into t6 values (2, "MyISAM table"); +select * from t7; +show status like 'handler_discover%'; + +# Remove the frm file from disk +flush tables; +--remove_file $MYSQLTEST_VARDIR/master-data/test/t7.frm + +show tables from test; +show status like 'handler_discover%'; + +# Remove the frm file from disk again +flush tables; +--remove_file $MYSQLTEST_VARDIR/master-data/test/t7.frm + +--replace_column 6 # 7 # 8 # 9 # 12 # 13 # 15 # 18 # +show table status; +show status like 'handler_discover%'; + +drop table t6, t7; + + +####################################################### +# Test that a table that has been dropped from NDB +# but still exists on disk, get a consistent error message +# saying "No such table existed" +# + +flush status; + +create table t4( + id int not null primary key, + name char(27) +) engine=ndb; +insert into t4 values (1, "Automatic"); +select * from t4; + +# Remove the table from NDB +system exec $NDB_TOOLS_DIR/ndb_drop_table --no-defaults -d test t4 >> $NDB_TOOLS_OUTPUT ; + +# +# Test that correct error is returned +--error 1146 +select * from t4; +--error 1146 +select * from t4; + +show status like 'handler_discover%'; +--error 1051 +drop table t4; + +create table t4( + id int not null primary key, + name char(27) +) engine=ndb; +insert into t4 values (1, "Automatic"); +select * from t4; + +# Remove the table from NDB +system exec $NDB_TOOLS_DIR/ndb_drop_table --no-defaults -d test t4 >> $NDB_TOOLS_OUTPUT ; + +--error 1146 +select * from t4; + +drop table if exists t4; + +# Test that dropping a table that does not exists +# on disk or in NDB gives same result as above +--error 1051 +drop table t5; +drop table if exists t5; + + +####################################################### +# Test that a table that has been dropped from NDB +# but still exists on disk is deleted from disk +# when SHOW TABLES is called +# + +flush status; + +create table t4( + id int not null primary key, + id2 int, + name char(27) +) engine=ndb; +insert into t4 values (1, 76, "Automatic2"); +select * from t4; +flush tables; + +# Remove the table from NDB +system exec $NDB_TOOLS_DIR/ndb_drop_table --no-defaults -d test t4 >> $NDB_TOOLS_OUTPUT ; + +SHOW TABLES; + +--error 1146 +select * from t4; + +####################################################### +# Test SHOW TABLES ability to detect new and delete old +# tables. Test all at once using many tables +# + +flush status; + +# Create tables +create table t1(id int) engine=ndbcluster; +create table t2(id int, b char(255)) engine=myisam; +create table t3(id int, c char(255)) engine=ndbcluster; +create table t4(id int) engine=myisam; +create table t5(id int, d char(56)) engine=ndbcluster; +create table t6(id int) engine=ndbcluster; +create table t7(id int) engine=ndbcluster; +create table t8(id int, e char(34)) engine=myisam; +create table t9(id int) engine=myisam; + +# Populate tables +insert into t2 values (2, "myisam table 2"); +insert into t3 values (3, "ndb table 3"); +insert into t5 values (5, "ndb table 5"); +insert into t6 values (6); +insert into t8 values (8, "myisam table 8"); +insert into t9 values (9); + +# Remove t3, t5 from NDB +system exec $NDB_TOOLS_DIR/ndb_drop_table --no-defaults -d test t3 >> $NDB_TOOLS_OUTPUT ; +system exec $NDB_TOOLS_DIR/ndb_drop_table --no-defaults -d test t5 >> $NDB_TOOLS_OUTPUT ; +# Remove t6, t7 from disk +--remove_file $MYSQLTEST_VARDIR/master-data/test/t6.frm +--remove_file $MYSQLTEST_VARDIR/master-data/test/t7.frm + +SHOW TABLES; + +select * from t6; +select * from t7; + +show status like 'handler_discover%'; + +drop table t1, t2, t4, t6, t7, t8, t9; + +####################################################### +# Test SHOW TABLES LIKE ability to detect new and delete old +# tables. Test all at once using many tables. +# + +flush status; + +# Create tables +create table t1(id int) engine=ndbcluster; +create table t2(id int, b char(255)) engine=myisam; +create table t3(id int, c char(255)) engine=ndbcluster; +create table t4(id int) engine=myisam; +create table t5(id int, d char(56)) engine=ndbcluster; +create table t6(id int) engine=ndbcluster; +create table t7(id int) engine=ndbcluster; +create table t8(id int, e char(34)) engine=myisam; +create table t9(id int) engine=myisam; + +# Populate tables +insert into t2 values (2, "myisam table 2"); +insert into t3 values (3, "ndb table 3"); +insert into t5 values (5, "ndb table 5"); +insert into t6 values (6); +insert into t8 values (8, "myisam table 8"); +insert into t9 values (9); + +# Remove t3, t5 from NDB +system exec $NDB_TOOLS_DIR/ndb_drop_table --no-defaults -d test t3 > /dev/null ; +system exec $NDB_TOOLS_DIR/ndb_drop_table --no-defaults -d test t5 > /dev/null ; +# Remove t6, t7 from disk +--remove_file $MYSQLTEST_VARDIR/master-data/test/t6.frm +--remove_file $MYSQLTEST_VARDIR/master-data/test/t7.frm + + +SHOW TABLES LIKE 't6'; + +show status like 'handler_discover%'; + +# Check that t3 or t5 can't be created +# frm files for these tables is stilll on disk +--error 1050 +create table t3(a int); +--error 1050 +create table t5(a int); + +SHOW TABLES LIKE 't%'; + +show status like 'handler_discover%'; + +drop table t1, t2, t4, t6, t7, t8, t9; + + + +###################################################### +# Test that several tables can be discovered when +# one statement access several table at once. +# + +flush status; + +# Create tables +create table t1(id int) engine=ndbcluster; +create table t2(id int, b char(255)) engine=ndbcluster; +create table t3(id int, c char(255)) engine=ndbcluster; +create table t4(id int) engine=myisam; + +# Populate tables +insert into t1 values (1); +insert into t2 values (2, "table 2"); +insert into t3 values (3, "ndb table 3"); +insert into t4 values (4); + +# Remove t1, t2, t3 from disk +--remove_file $MYSQLTEST_VARDIR/master-data/test/t1.frm +--remove_file $MYSQLTEST_VARDIR/master-data/test/t2.frm +--remove_file $MYSQLTEST_VARDIR/master-data/test/t3.frm +flush tables; + +# Select from the table which only exists in NDB. +select * from t1, t2, t3, t4; + +# 3 table should have been discovered +show status like 'handler_discover%'; + +drop table t1, t2, t3, t4; + + +######################################################### +# Test that a table that has been changed in NDB +# since it's been opened will be refreshed and discovered +# again +# + +flush status; + +show status like 'handler_discover%'; + +create table t5( + id int not null primary key, + name char(200) +) engine=ndb; +insert into t5 values (1, "Magnus"); +select * from t5; + +ALTER TABLE t5 ADD COLUMN adress char(255) FIRST; + +select * from t5; + +insert into t5 values + ("Adress for record 2", 2, "Carl-Gustav"), + ("Adress for record 3", 3, "Karl-Emil"); +update t5 set name="Bertil" where id = 2; +select * from t5 order by id; + +show status like 'handler_discover%'; + +drop table t5; + + +################################################################ +# Test that a table that has been changed with ALTER TABLE +# can be used from the same thread +# + +flush status; + +show status like 'handler_discover%'; + +create table t6( + id int not null primary key, + name char(20) +) engine=ndb; +insert into t6 values (1, "Magnus"); +select * from t6; + +ALTER TABLE t6 ADD COLUMN adress char(255) FIRST; + +select * from t6; +insert into t6 values + ("Adress for record 2", 2, "Carl-Gustav"), + ("Adress for record 3", 3, "Karl-Emil"); +update t6 set name="Bertil" where id = 2; +select * from t6 order by id; + +show status like 'handler_discover%'; + +drop table t6; + +##################################################### +# Test that only tables in the current database shows +# up in SHOW TABLES +# + +show tables; + +create table t1 (a int,b longblob) engine=ndb; +show tables; +create database test2; +use test2; +show tables; +--error 1146 +select * from t1; +create table t2 (b int,c longblob) engine=ndb; +use test; +select * from t1; +show tables; +drop table t1; +use test2; +drop table t2; +drop database test2; +use test; + +######################################################### +# Bug#8035 +# mysqld would segfault on second select * before bug was fixed +# +--disable_warnings +drop database if exists test_only_ndb_tables; +--enable_warnings +create database test_only_ndb_tables; +use test_only_ndb_tables; +create table t1 (a int primary key) engine=ndb; +select * from t1; +--exec $NDB_MGM --no-defaults -e "all restart -n" > /dev/null +--exec $NDB_TOOLS_DIR/ndb_waiter --no-defaults --not-started > /dev/null +--error 1015 +select * from t1; +--exec $NDB_MGM --no-defaults -e "all start" > /dev/null +--exec $NDB_TOOLS_DIR/ndb_waiter --no-defaults > /dev/null +use test; +drop database test_only_ndb_tables; + +##################################################### +# Test that it's not possible to create tables +# with same name as NDB internal tables +# This will also test that it's not possible to create +# a table with tha same name as a table that can't be +# discovered( for example a table created via NDBAPI) + +# Test disabled since it doesn't work on case insensitive systems +#--error 1050 +#CREATE TABLE sys.SYSTAB_0 (a int); +#--error 1105 +#select * from sys.SYSTAB_0; + +#CREATE TABLE IF NOT EXISTS sys.SYSTAB_0 (a int); +#show warnings; +#--error 1105 +#select * from sys.SYSTAB_0; + +#--error 1051 +#drop table sys.SYSTAB_0; +#drop table IF EXISTS sys.SYSTAB_0; + +###################################################### +# Note! This should always be the last step in this +# file, the table t9 will be used and dropped +# by ndb_autodiscover2 +# + +CREATE TABLE t9 ( + a int NOT NULL PRIMARY KEY, + b int +) engine=ndb; + +insert t9 values(1, 2), (2,3), (3, 4), (4, 5); + +#Don't drop the table, instead remove the frm file +--remove_file $MYSQLTEST_VARDIR/master-data/test/t9.frm + +# Now leave test case, when ndb_autodiscover2 will run, this +# MySQL Server will have been restarted because it has a +# ndb_autodiscover2-master.opt file. + +create table t10 ( + a int not null primary key, + b blob +) engine=ndb; + +insert into t10 values (1, 'kalle'); + +--exec $NDB_TOOLS_DIR/ndb_drop_table --no-defaults -d test `$NDB_TOOLS_DIR/ndb_show_tables --no-defaults | grep BLOB | while read a b c d e f g; do echo $g; done` >> $NDB_TOOLS_OUTPUT 2>&1 || true + +# End of 4.1 tests diff --git a/mysql-test/suite/ndb/t/ndb_autodiscover2-master.opt b/mysql-test/suite/ndb/t/ndb_autodiscover2-master.opt new file mode 100644 index 00000000000..e0d075c3fbd --- /dev/null +++ b/mysql-test/suite/ndb/t/ndb_autodiscover2-master.opt @@ -0,0 +1 @@ +--skip-external-locking diff --git a/mysql-test/suite/ndb/t/ndb_autodiscover2.test b/mysql-test/suite/ndb/t/ndb_autodiscover2.test new file mode 100644 index 00000000000..ebe14696cd2 --- /dev/null +++ b/mysql-test/suite/ndb/t/ndb_autodiscover2.test @@ -0,0 +1,21 @@ +-- source include/have_ndb.inc +-- source include/not_embedded.inc + +# +# Simple test to show use of discover when the server has been restarted +# The previous step has simply removed the frm file +# from disk, but left the table in NDB +# +--sleep 3 +select * from t9 order by a; + +# handler_discover should be 1 +show status like 'handler_discover%'; + +drop table t9; + +--error 1296 +select * from t10; +drop table t10; + +# End of 4.1 tests diff --git a/mysql-test/suite/ndb/t/ndb_autodiscover3.test b/mysql-test/suite/ndb/t/ndb_autodiscover3.test new file mode 100644 index 00000000000..10416aee11f --- /dev/null +++ b/mysql-test/suite/ndb/t/ndb_autodiscover3.test @@ -0,0 +1,104 @@ +-- source include/have_multi_ndb.inc +-- source include/ndb_default_cluster.inc +-- source include/not_embedded.inc + +# see bug#21563 +-- source include/have_binlog_format_mixed_or_row.inc + +--disable_warnings +drop table if exists t1, t2; +--enable_warnings + +connect (con1,127.0.0.1,root,,test,$MASTER_MYPORT,); +connect (con2,127.0.0.1,root,,test,$MASTER_MYPORT1,); + +# Workaround for Bug#27644 +# ndb: connecting api node/mysqld may "steal" node_id from running mysqld +# - let ndb_waiter use a fixed node id so "steal" cannot happen +--let connect_str = "nodeid=6;$NDB_CONNECTSTRING" + +# +# Transaction ongoing while cluster is restarted +# +--connection server1 +create table t1 (a int key) engine=ndbcluster; + +begin; +insert into t1 values (1); + +--exec $NDB_MGM --no-defaults -e "all restart" >> $NDB_TOOLS_OUTPUT +--exec $NDB_TOOLS_DIR/ndb_waiter --no-defaults -c $connect_str >> $NDB_TOOLS_OUTPUT +# Wait for mysqld to reconnect and exit from readonly mode +--disable_query_log +--connection con1 +--source include/ndb_not_readonly.inc +--connection con2 +--source include/ndb_not_readonly.inc +--enable_query_log + +--connection server1 +--error 1297 +insert into t1 values (2); +--error 1296 +commit; + +drop table t1; + +# +# Stale cache after restart -i +# +--connection server1 +create table t2 (a int, b int, primary key(a,b)) engine=ndbcluster; +insert into t2 values (1,1),(2,1),(3,1),(4,1),(5,1),(6,1),(7,1),(8,1),(9,1),(10,1); +select * from t2 order by a limit 3; + +--exec $NDB_MGM --no-defaults -e "all restart -i" >> $NDB_TOOLS_OUTPUT +--exec $NDB_TOOLS_DIR/ndb_waiter --no-defaults -c $connect_str >> $NDB_TOOLS_OUTPUT +# to ensure mysqld has connected again, and recreated system tables +--disable_query_log +--connection con1 +--source include/ndb_not_readonly.inc +--connection con2 +--source include/ndb_not_readonly.inc +--enable_query_log + +--connection server2 +--error ER_NO_SUCH_TABLE +select * from t2; +show tables like 't2'; +reset master; +create table t2 (a int key) engine=ndbcluster; +insert into t2 values (1),(2),(3),(4),(5),(6),(7),(8),(9),(10); +select * from t2 order by a limit 3; + +# server 1 should have a stale cache, and in this case wrong frm, transaction must be retried +--connection server1 +select * from t2 order by a limit 3; +reset master; + +--exec $NDB_MGM --no-defaults -e "all restart -i" >> $NDB_TOOLS_OUTPUT +--exec $NDB_TOOLS_DIR/ndb_waiter --no-defaults -c $connect_str >> $NDB_TOOLS_OUTPUT +# to ensure mysqld has connected again, and recreated system tables +--disable_query_log +--connection con1 +--source include/ndb_not_readonly.inc +--connection con2 +--source include/ndb_not_readonly.inc +--enable_query_log + +--connection server1 +--error ER_NO_SUCH_TABLE +select * from t2; +show tables like 't2'; +reset master; +create table t2 (a int key) engine=ndbcluster; +insert into t2 values (1),(2),(3),(4),(5),(6),(7),(8),(9),(10); +select * from t2 order by a limit 3; + +# server 2 should have a stale cache, but with right frm, transaction need not be retried +--connection server2 +select * from t2 order by a limit 3; +reset master; + +drop table t2; +# End of 4.1 tests diff --git a/mysql-test/suite/ndb/t/ndb_backup_print.test b/mysql-test/suite/ndb/t/ndb_backup_print.test new file mode 100644 index 00000000000..cf869fd56f5 --- /dev/null +++ b/mysql-test/suite/ndb/t/ndb_backup_print.test @@ -0,0 +1,68 @@ +-- source include/have_ndb.inc +-- source include/ndb_default_cluster.inc +-- source include/not_embedded.inc + +--disable_warnings +use test; +drop table if exists t1,t2,t3,t4,t5,t6,t7,t8,t9,t10; +--enable_warnings + +#NO.1 test output of backup +--exec $NDB_MGM --no-defaults -e "start backup" |sed -e 's/[0-9]//g' |sed -e 's/localhost//g' |sed -e 's/\.\.\.*//g' + +create table t1 + (pk int key + ,a1 BIT(1), a2 BIT(5), a3 BIT(33), a4 BIT(63), a5 BIT(64) + ,b1 TINYINT, b2 TINYINT UNSIGNED + ,c1 SMALLINT, c2 SMALLINT UNSIGNED + ,d1 INT, d2 INT UNSIGNED + ,e1 BIGINT, e2 BIGINT UNSIGNED + ,f1 CHAR(1) BINARY, f2 CHAR(32) BINARY, f3 CHAR(255) BINARY + ,g1 VARCHAR(32) BINARY, g2 VARCHAR(255) BINARY, g3 VARCHAR(1000) BINARY + ,h1 BINARY(1), h2 BINARY(8), h3 BINARY(255) + ,i1 VARBINARY(32), i2 VARBINARY(255), i3 VARBINARY(1000) + ) engine ndb; + +insert into t1 values + (1 + ,0x1, 0x17, 0x789a, 0x789abcde, 0xfedc0001 + ,127, 255 + ,32767, 65535 + ,2147483647, 4294967295 + ,9223372036854775807, 18446744073709551615 + ,'1','12345678901234567890123456789012','123456789' + ,'1','12345678901234567890123456789012','123456789' + ,0x12,0x123456789abcdef0, 0x012345 + ,0x12,0x123456789abcdef0, 0x00123450 + ); + +insert into t1 values + (2 + ,0, 0, 0, 0, 0 + ,-128, 0 + ,-32768, 0 + ,-2147483648, 0 + ,-9223372036854775808, 0 + ,'','','' + ,'','','' + ,0x0,0x0,0x0 + ,0x0,0x0,0x0 + ); + +insert into t1 values + (3 + ,NULL,NULL,NULL,NULL,NULL + ,NULL,NULL + ,NULL,NULL + ,NULL,NULL + ,NULL,NULL + ,NULL,NULL,NULL + ,NULL,NULL,NULL + ,NULL,NULL,NULL + ,NULL,NULL,NULL + ); + +#NO.2 test output of backup after some simple SQL operations +--exec $NDB_MGM --no-defaults -e "start backup" |sed -e 's/[0-9]//g' |sed -e 's/localhost//g' |sed -e 's/\.\.\.*//g' + +drop table t1; diff --git a/mysql-test/suite/ndb/t/ndb_basic.test b/mysql-test/suite/ndb/t/ndb_basic.test new file mode 100644 index 00000000000..b9ccdf9fd0d --- /dev/null +++ b/mysql-test/suite/ndb/t/ndb_basic.test @@ -0,0 +1,843 @@ +-- source include/have_ndb.inc +-- source include/not_embedded.inc + +--disable_warnings +DROP TABLE IF EXISTS t1,t2,t3,t4,t5,t6,t7; +drop database if exists mysqltest; +--enable_warnings + +# workaround for bug#16445 +# remove to reproduce bug and run tests from ndb start +# and with ndb_autodiscover disabled. Fails on Linux 50 % of the times +CREATE TABLE t1 ( + pk1 INT NOT NULL PRIMARY KEY, + attr1 INT NOT NULL, + attr2 INT, + attr3 VARCHAR(10) +) ENGINE=ndbcluster; +drop table t1; + +# +# Basic test to show that the NDB +# table handler is working +# + +# +# Show status and variables +# +--replace_column 2 # +SHOW GLOBAL STATUS LIKE 'ndb%'; +--replace_column 2 # +SHOW GLOBAL VARIABLES LIKE 'ndb%'; + +# +# Create a normal table with primary key +# +CREATE TABLE t1 ( + pk1 INT NOT NULL PRIMARY KEY, + attr1 INT NOT NULL, + attr2 INT, + attr3 VARCHAR(10) +) ENGINE=ndbcluster; + +SHOW INDEX FROM t1; +INSERT INTO t1 VALUES (9410,9412, NULL, '9412'), (9411,9413, 17, '9413'); +SHOW INDEX FROM t1; +SELECT pk1 FROM t1 ORDER BY pk1; +SELECT * FROM t1 ORDER BY pk1; +SELECT t1.* FROM t1 ORDER BY pk1; + +# Update on record by primary key +UPDATE t1 SET attr1=1 WHERE pk1=9410; +SELECT * FROM t1 ORDER BY pk1; + +# Update primary key +UPDATE t1 SET pk1=2 WHERE attr1=1; +SELECT * FROM t1 ORDER BY pk1; +UPDATE t1 SET pk1=pk1 + 1; +SELECT * FROM t1 ORDER BY pk1; +UPDATE t1 SET pk1=4 WHERE pk1 = 3; +SELECT * FROM t1 ORDER BY pk1; + +# Delete the record +DELETE FROM t1; +SELECT * FROM t1; + +# Insert more records and update them all at once +INSERT INTO t1 VALUES (9410,9412, NULL, '9412'), (9408, 8765, NULL, '8765'), +(7,8, NULL, NULL), (8,9, NULL, NULL), (9,10, NULL, NULL), (10,11, NULL, NULL), (11,12, NULL, NULL), (12,13, NULL, NULL), (13,14, NULL, NULL); +UPDATE t1 SET attr1 = 9999; +SELECT * FROM t1 ORDER BY pk1; + +UPDATE t1 SET attr1 = 9998 WHERE pk1 < 1000; +SELECT * FROM t1 ORDER BY pk1; + +UPDATE t1 SET attr1 = 9997 WHERE attr1 = 9999; +SELECT * FROM t1 ORDER BY pk1; + +# Delete one record by specifying pk +DELETE FROM t1 WHERE pk1 = 9410; +SELECT * FROM t1 ORDER BY pk1; + +# Delete all from table +DELETE FROM t1; +SELECT * FROM t1; + +# Insert three records with attr1=4 and two with attr1=5 +# Delete all with attr1=4 +INSERT INTO t1 values (1, 4, NULL, NULL), (2, 4, NULL, NULL), (3, 5, NULL, NULL), (4, 4, NULL, NULL), (5, 5, NULL, NULL); +DELETE FROM t1 WHERE attr1=4; +SELECT * FROM t1 order by pk1; +DELETE FROM t1; + +# Insert two records and delete one +INSERT INTO t1 VALUES (9410,9412, NULL, NULL), (9411, 9413, NULL, NULL); +DELETE FROM t1 WHERE pk1 = 9410; +SELECT * FROM t1; +DROP TABLE t1; + +# +# Create table without primary key +# a hidden primary key column is created by handler +# +CREATE TABLE t1 (id INT, id2 int) engine=ndbcluster; +INSERT INTO t1 values(3456, 7890); +SELECT * FROM t1; +UPDATE t1 SET id=2 WHERE id2=12; +SELECT * FROM t1; +UPDATE t1 SET id=1234 WHERE id2=7890; +SELECT * FROM t1; +DELETE FROM t1; + +INSERT INTO t1 values(3456, 7890), (3456, 7890), (3456, 7890), (3454, 7890); +SELECT * FROM t1 ORDER BY id; +DELETE FROM t1 WHERE id = 3456; +SELECT * FROM t1 ORDER BY id; + +DROP TABLE t1; + +# test create with the keyword "engine=NDBCLUSTER" +CREATE TABLE t1 ( + pk1 INT NOT NULL PRIMARY KEY, + attr1 INT NOT NULL +) ENGINE=NDBCLUSTER; + +INSERT INTO t1 values(1, 9999); + +DROP TABLE t1; + +# test create with the keyword "engine=NDB" +CREATE TABLE t1 ( + pk1 INT NOT NULL PRIMARY KEY, + attr1 INT NOT NULL +) ENGINE=NDB; + +INSERT INTO t1 values(1, 9999); + +DROP TABLE t1; + + +# +# A more extensive test with a lot more records +# + +CREATE TABLE t2 ( + a bigint unsigned NOT NULL PRIMARY KEY, + b int unsigned not null, + c int unsigned +) engine=ndbcluster; + +CREATE TABLE t3 ( + a bigint unsigned NOT NULL, + b bigint unsigned not null, + c bigint unsigned, + PRIMARY KEY(a) +) engine=ndbcluster; + +CREATE TABLE t4 ( + a bigint unsigned NOT NULL, + b bigint unsigned not null, + c bigint unsigned NOT NULL, + d int unsigned, + PRIMARY KEY(a, b, c) +) engine=ndbcluster; + + +# +# insert more records into tables +# +let $1=1000; +disable_query_log; +while ($1) +{ + eval insert into t2 values($1, $1+9, 5); + eval insert into t3 values($1, $1+9, 5); + eval insert into t4 values($1, $1+9, 5, $1+26000); + dec $1; +} +enable_query_log; + + +# +# delete every other record in the tables +# +let $1=1000; +disable_query_log; +while ($1) +{ + eval delete from t2 where a=$1; + eval delete from t3 where a=$1; + eval delete from t4 where a=$1 and b=$1+9 and c=5; + dec $1; + dec $1; +} +enable_query_log; + + +select * from t2 where a = 7 order by b; +select * from t2 where a = 7 order by a; +select * from t2 where a = 7 order by 2; +select * from t2 where a = 7 order by c; + +select * from t2 where a = 7 and b = 16 order by b; +select * from t2 where a = 7 and b = 16 order by a; +select * from t2 where a = 7 and b = 17 order by a; +select * from t2 where a = 7 and b != 16 order by b; + +select * from t2 where a = 7 and b = 16 and c = 5 order by b; +select * from t2 where a = 7 and b = 16 and c = 5 order by a; +select * from t2 where a = 7 and b = 16 and c = 6 order by a; +select * from t2 where a = 7 and b != 16 and c = 5 order by b; + +select * from t3 where a = 7 order by b; +select * from t3 where a = 7 order by a; +select * from t3 where a = 7 order by 2; +select * from t3 where a = 7 order by c; + +select * from t3 where a = 7 and b = 16 order by b; +select * from t3 where a = 7 and b = 16 order by a; +select * from t3 where a = 7 and b = 17 order by a; +select * from t3 where a = 7 and b != 16 order by b; + +select * from t4 where a = 7 order by b; +select * from t4 where a = 7 order by a; +select * from t4 where a = 7 order by 2; +select * from t4 where a = 7 order by c; + +select * from t4 where a = 7 and b = 16 order by b; +select * from t4 where a = 7 and b = 16 order by a; +select * from t4 where a = 7 and b = 17 order by a; +select * from t4 where a = 7 and b != 16 order by b; + +# +# update records +# +let $1=1000; +disable_query_log; +while ($1) +{ + eval update t2 set c=$1 where a=$1; + eval update t3 set c=7 where a=$1 and b=$1+9 and c=5; + eval update t4 set d=$1+21987 where a=$1 and b=$1+9 and c=5; + dec $1; + dec $1; +} +enable_query_log; + +delete from t2 where a > 5; +select x1.a, x1.b from t2 x1, t2 x2 where x1.b = x2.b order by x1.a; +select a, b FROM t2 outer_table where +a = (select a from t2 where b = outer_table.b ) order by a; + + +delete from t2; +delete from t3; +delete from t4; + +drop table t2; +drop table t3; +drop table t4; + +# +# Test delete and update from table with 3 keys +# + +CREATE TABLE t5 ( + a bigint unsigned NOT NULL, + b bigint unsigned not null, + c bigint unsigned NOT NULL, + d int unsigned, + PRIMARY KEY(a, b, c) +) engine=ndbcluster; + +insert into t5 values(10, 19, 5, 26010); + +delete from t5 where a=10 and b=19 and c=5; + +select * from t5; + +insert into t5 values(10, 19, 5, 26010); + +update t5 set d=21997 where a=10 and b=19 and c=5; + +select * from t5; + +delete from t5; + +drop table t5; + +# +# Test using table with a char(255) column first in table +# + +CREATE TABLE t6 ( + adress char(255), + a int NOT NULL PRIMARY KEY, + b int +) engine = NDB; + +insert into t6 values + ("Nice road 3456", 1, 23), + ("Street Road 78", 3, 92), + ("Road street 89C", 5, 71), + (NULL, 7, NULL); +select * from t6 order by a; +select a, b from t6 order by a; + +update t6 set adress="End of road 09" where a=3; +update t6 set b=181, adress="Street 76" where a=7; +select * from t6 order by a; +select * from t6 where a=1; +delete from t6 where a=1; +select * from t6 order by a; +delete from t6 where b=71; +select * from t6 order by a; + +drop table t6; + +# +# Test using table with a char(255) column first in table and a +# primary key consisting of two columns +# + +CREATE TABLE t7 ( + adress char(255), + a int NOT NULL, + b int, + c int NOT NULL, + PRIMARY KEY(a, c) +) engine = NDB; + +insert into t7 values + ("Highway 3456", 1, 23, 2), + ("Street Road 78", 3, 92, 3), + ("Main street 89C", 5, 71, 4), + (NULL, 8, NULL, 12); +select * from t7 order by a; +select a, b from t7 order by a; + +update t7 set adress="End of road 09" where a=3; +update t7 set adress="Gatuvägen 90C" where a=5 and c=4; +update t7 set adress="No adress" where adress is NULL; +select * from t7 order by a; +select * from t7 where a=1 and c=2; +delete from t7 where a=1; +delete from t7 where a=3 and c=3; +delete from t7 where a=5 and c=4; +select * from t7; +delete from t7 where b=23; +select * from t7; + +drop table t7; + +# +# Test multiple databases in one statement +# + +CREATE TABLE t1 ( + pk1 INT NOT NULL PRIMARY KEY, + attr1 INT NOT NULL, + attr2 INT, + attr3 VARCHAR(10) +) ENGINE=ndbcluster; + +INSERT INTO t1 VALUES (9410,9412, NULL, '9412'), (9411,9413, 17, '9413'); + +create database mysqltest; +use mysqltest; + +CREATE TABLE t2 ( + a bigint unsigned NOT NULL PRIMARY KEY, + b int unsigned not null, + c int unsigned +) engine=ndbcluster; + +insert into t2 select pk1,attr1,attr2 from test.t1; +select * from t2 order by a; +select b from test.t1, t2 where c = test.t1.attr2; +select b,test.t1.attr1 from test.t1, t2 where test.t1.pk1 < a; + +drop table test.t1, t2; +drop database mysqltest; + +# +# BUG#6031 - DROP DATABASE doesn't drop database on first try +# + +--disable_warnings +drop database if exists ndbtest1; +--enable_warnings + +create database ndbtest1; +use ndbtest1; +create table t1(id int) engine=ndbcluster; +drop database ndbtest1; +--error 1008 +drop database ndbtest1; + +# +# test support of char(0) +# + +use test; +create table t1 (a int primary key, b char(0)); +insert into t1 values (1,""); +insert into t1 values (2,NULL); +select * from t1 order by a; +select * from t1 order by b; +select * from t1 where b IS NULL; +select * from t1 where b IS NOT NULL; +drop table t1; + +# +# test the limit of no of attributes in one table +# +# also tests bug#17179, more than 31 attributes in +# a partitioned table +# +create table t1 ( +c1 int, +c2 int, +c3 int, +c4 int, +c5 int, +c6 int, +c7 int, +c8 int, +c9 int, +c10 int, +c11 int, +c12 int, +c13 int, +c14 int, +c15 int, +c16 int, +c17 int, +c18 int, +c19 int, +c20 int, +c21 int, +c22 int, +c23 int, +c24 int, +c25 int, +c26 int, +c27 int, +c28 int, +c29 int, +c30 int, +c31 int, +c32 int, +c33 int, +c34 int, +c35 int, +c36 int, +c37 int, +c38 int, +c39 int, +c40 int, +c41 int, +c42 int, +c43 int, +c44 int, +c45 int, +c46 int, +c47 int, +c48 int, +c49 int, +c50 int, +c51 int, +c52 int, +c53 int, +c54 int, +c55 int, +c56 int, +c57 int, +c58 int, +c59 int, +c60 int, +c61 int, +c62 int, +c63 int, +c64 int, +c65 int, +c66 int, +c67 int, +c68 int, +c69 int, +c70 int, +c71 int, +c72 int, +c73 int, +c74 int, +c75 int, +c76 int, +c77 int, +c78 int, +c79 int, +c80 int, +c81 int, +c82 int, +c83 int, +c84 int, +c85 int, +c86 int, +c87 int, +c88 int, +c89 int, +c90 int, +c91 int, +c92 int, +c93 int, +c94 int, +c95 int, +c96 int, +c97 int, +c98 int, +c99 int, +c100 int, +c101 int, +c102 int, +c103 int, +c104 int, +c105 int, +c106 int, +c107 int, +c108 int, +c109 int, +c110 int, +c111 int, +c112 int, +c113 int, +c114 int, +c115 int, +c116 int, +c117 int, +c118 int, +c119 int, +c120 int, +c121 int, +c122 int, +c123 int, +c124 int, +c125 int, +c126 int, +c127 int, +c128 int, +primary key using hash(c1)) engine=ndb partition by key(c1); +drop table t1; + +# +# test max size of attribute name and truncation +# + +create table t1 ( +a1234567890123456789012345678901234567890 int primary key, +a12345678901234567890123456789a1234567890 int, +index(a12345678901234567890123456789a1234567890) +) engine=ndb; +show tables; +insert into t1 values (1,1),(2,1),(3,1),(4,1),(5,2),(6,1),(7,1); +--replace_column 9 # +explain select * from t1 where a12345678901234567890123456789a1234567890=2; +select * from t1 where a12345678901234567890123456789a1234567890=2; +drop table t1; + +# +# test fragment creation +# +# first a table with _many_ fragments per node group +# then a table with just one fragment per node group +# +create table t1 + (a bigint, b bigint, c bigint, d bigint, + primary key (a,b,c,d)) + engine=ndb + max_rows=800000000; +insert into t1 values + (1,2,3,4),(2,3,4,5),(3,4,5,6), + (3,2,3,4),(1,3,4,5),(2,4,5,6), + (1,2,3,5),(2,3,4,8),(3,4,5,9), + (3,2,3,5),(1,3,4,8),(2,4,5,9), + (1,2,3,6),(2,3,4,6),(3,4,5,7), + (3,2,3,6),(1,3,4,6),(2,4,5,7), + (1,2,3,7),(2,3,4,7),(3,4,5,8), + (3,2,3,7),(1,3,4,7),(2,4,5,8), + (1,3,3,4),(2,4,4,5),(3,5,5,6), + (3,3,3,4),(1,4,4,5),(2,5,5,6), + (1,3,3,5),(2,4,4,8),(3,5,5,9), + (3,3,3,5),(1,4,4,8),(2,5,5,9), + (1,3,3,6),(2,4,4,6),(3,5,5,7), + (3,3,3,6),(1,4,4,6),(2,5,5,7), + (1,3,3,7),(2,4,4,7),(3,5,5,8), + (3,3,3,7),(1,4,4,7),(2,5,5,8); +select count(*) from t1; +drop table t1; + +create table t1 + (a bigint, b bigint, c bigint, d bigint, + primary key (a)) + engine=ndb + max_rows=1; +drop table t1; + +# +# Test auto_increment +# + +connect (con1,localhost,root,,test); +connect (con2,localhost,root,,test); + +create table t1 + (counter int(64) NOT NULL auto_increment, + datavalue char(40) default 'XXXX', + primary key (counter) + ) ENGINE=ndbcluster; + +connection con1; +insert into t1 (datavalue) values ('newval'); +insert into t1 (datavalue) values ('newval'); +select * from t1 order by counter; +insert into t1 (datavalue) select datavalue from t1 where counter < 100; +insert into t1 (datavalue) select datavalue from t1 where counter < 100; +select * from t1 order by counter; +connection con2; +insert into t1 (datavalue) select datavalue from t1 where counter < 100; +insert into t1 (datavalue) select datavalue from t1 where counter < 100; +select * from t1 order by counter; + +drop table t1; + +# +# bug#27437 +connection con1; +create table t1 (a int primary key auto_increment) engine = ndb; +insert into t1() values (),(),(),(),(),(),(),(),(),(),(),(); +connection con2; +insert into t1(a) values (20),(28); +connection con1; +insert into t1() values (),(),(),(),(),(),(),(),(),(),(),(); +connection con2; +insert into t1() values (21), (22); +connection con1; + +drop table t1; + +# +# BUG#14514 Creating table with packed key fails silently +# + +CREATE TABLE t1 ( b INT ) PACK_KEYS = 0 ENGINE = ndb; +select * from t1; +drop table t1; + +# +# Bug #17249 delete statement with join where clause fails +# when table do not have pk + # + +create table t1 (a int) engine=ndb; +create table t2 (a int) engine=ndb; +insert into t1 values (1); +insert into t2 values (1); +delete t1.* from t1, t2 where t1.a = t2.a; +select * from t1; +select * from t2; +drop table t1; +drop table t2; + +# +# Bug #17257 update fails for inner joins if tables +# do not have Primary Key +# + +CREATE TABLE t1 ( + i INT, + j INT, + x INT, + y INT, + z INT +) engine=ndb; + +CREATE TABLE t2 ( + i INT, + k INT, + x INT, + y INT, + z INT +) engine=ndb; + +CREATE TABLE t3 ( + j INT, + k INT, + x INT, + y INT, + z INT +) engine=ndb; + +INSERT INTO t1 VALUES ( 1, 2,13,14,15); +INSERT INTO t2 VALUES ( 1, 3,23,24,25); +INSERT INTO t3 VALUES ( 2, 3, 1,34,35), ( 2, 3, 1,34,36); + +UPDATE t1 AS a +INNER JOIN t2 AS b + ON a.i = b.i +INNER JOIN t3 AS c + ON a.j = c.j AND b.k = c.k +SET a.x = b.x, + a.y = b.y, + a.z = ( + SELECT sum(z) + FROM t3 + WHERE y = 34 + ) +WHERE b.x = 23; +select * from t1; +drop table t1; +drop table t2; +drop table t3; + +# End of 4.1 tests + +# +# Test long table name +# +create table atablewithareallylongandirritatingname (a int); +insert into atablewithareallylongandirritatingname values (2); +select * from atablewithareallylongandirritatingname; +drop table atablewithareallylongandirritatingname; + +# +# Bug#15682 +# +create table t1 (f1 varchar(50), f2 text,f3 int, primary key(f1)) engine=NDB; +insert into t1 (f1,f2,f3)VALUES("111111","aaaaaa",1); +insert into t1 (f1,f2,f3)VALUES("222222","bbbbbb",2); +select * from t1 order by f1; +select * from t1 order by f2; +select * from t1 order by f3; +drop table t1; +# Bug#16561 Unknown ERROR msg "ERROR 1186 (HY000): Binlog closed" by perror +# + +# As long there is no error code 1186 defined by NDB +# we should get a message "Illegal ndb error code: 1186" +--error 1 +--exec $MY_PERROR --ndb 1186 2>&1 + +# +# Bug #25746 - VARCHAR UTF8 PK issue +# - prior to bugfix 4209, illegal length parameter would be +# returned in SELECT * + +CREATE TABLE t1 ( +a VARBINARY(40) NOT NULL, +b VARCHAR (256) CHARACTER SET UTF8 NOT NULL, +c VARCHAR(256) CHARACTER SET UTF8 NOT NULL, +PRIMARY KEY (b,c)) ENGINE=ndbcluster; +INSERT INTO t1 VALUES +("a","ab","abc"),("b","abc","abcd"),("c","abc","ab"),("d","ab","ab"),("e","abc","abc"); +SELECT * FROM t1 ORDER BY a; +DROP TABLE t1; + +# delete +create table t1 (a int not null primary key, b int not null) engine=ndb; +create table t2 (a int not null primary key, b int not null) engine=ndb; +insert into t1 values (1,10), (2,20), (3,30); +insert into t2 values (1,10), (2,20), (3,30); +select * from t1 order by a; +delete from t1 where a > 0 order by a desc limit 1; +select * from t1 order by a; +delete from t1,t2 using t1,t2 where t1.a = t2.a; +select * from t2 order by a; +drop table t1,t2; + +# insert ignore +create table t1 (a int not null primary key, b int not null) engine=ndb; +insert into t1 values (1,10), (2,20), (3,30); +--error ER_DUP_ENTRY +insert into t1 set a=1, b=100; +insert ignore into t1 set a=1, b=100; +select * from t1 order by a; +insert into t1 set a=1, b=1000 on duplicate key update b=b+1; +select * from t1 order by a; +drop table t1; + +# update +create table t1 (a int not null primary key, b int not null) engine=ndb; +create table t2 (c int not null primary key, d int not null) engine=ndb; +insert into t1 values (1,10), (2,10), (3,30), (4, 30); +insert into t2 values (1,10), (2,10), (3,30), (4, 30); +--error ER_DUP_ENTRY +update t1 set a = 1 where a = 3; +select * from t1 order by a; +update t1 set b = 1 where a > 1 order by a desc limit 1; +select * from t1 order by a; +--error ER_DUP_ENTRY +update t1,t2 set a = 1, c = 1 where a = 3 and c = 3; +select * from t1 order by a; +update ignore t1,t2 set a = 1, c = 1 where a = 3 and c = 3; +select * from t1 order by a; +drop table t1,t2; + +# End of 5.0 tests +--echo End of 5.0 tests + + +# +# Bug #18483 Cannot create table with FK constraint +# ndb does not support foreign key constraint, it is silently ignored +# in line with other storage engines +# +CREATE TABLE t1 (a VARCHAR(255) NOT NULL, + CONSTRAINT pk_a PRIMARY KEY (a))engine=ndb; +CREATE TABLE t2(a VARCHAR(255) NOT NULL, + b VARCHAR(255) NOT NULL, + c VARCHAR(255) NOT NULL, + CONSTRAINT pk_b_c_id PRIMARY KEY (b,c), + CONSTRAINT fk_a FOREIGN KEY(a) REFERENCES t1(a))engine=ndb; +drop table t1, t2; + +# bug#24301 +create table t1 (a int not null primary key, b int) engine=ndb; +insert into t1 values(1,1),(2,2),(3,3); +create table t2 like t1; +insert into t2 select * from t1; +select * from t1 order by a; +select * from t2 order by a; +drop table t1, t2; + +# create table if not exists +--disable_warnings +create table t1 (a int not null primary key, b int not null default 0, c varchar(254)) engine=ndb; +create table if not exists t1 (a int not null primary key, b int not null default 0, c varchar(254)) engine=ndb; +--enable_warnings + +# create like +create table t2 like t1; + +# multi rename +rename table t1 to t10, t2 to t20; +drop table t10,t20; + +--echo End of 5.1 tests diff --git a/mysql-test/suite/ndb/t/ndb_binlog_basic.test b/mysql-test/suite/ndb/t/ndb_binlog_basic.test new file mode 100644 index 00000000000..0f63ced0697 --- /dev/null +++ b/mysql-test/suite/ndb/t/ndb_binlog_basic.test @@ -0,0 +1,72 @@ +-- source include/have_ndb.inc +-- source include/have_binlog_format_mixed_or_row.inc + +--disable_warnings +drop table if exists t1, t2; +drop database if exists mysqltest; +create database mysqltest; +use mysqltest; +drop database mysqltest; +use test; +--enable_warnings + +# +# basic insert, update, delete test, alter, rename, drop +# check that ndb_binlog_index gets the right info +# + +create table t1 (a int primary key) engine=ndb; +insert into t1 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9); +save_master_pos; +--replace_column 1 # +select @max_epoch:=max(epoch)-1 from mysql.ndb_binlog_index; + +delete from t1; +alter table t1 add (b int); +insert into t1 values (3,3),(4,4); +alter table t1 rename t2; + +# get all in one epoch +begin; +insert into t2 values (1,1),(2,2); +update t2 set b=1 where a=3; +delete from t2 where a=4; +commit; +drop table t2; + +# check that above is ok +# (save_master_pos waits for last gcp to complete, ensuring that we have +# the expected data in the binlog) +save_master_pos; +select inserts from mysql.ndb_binlog_index where epoch > @max_epoch and inserts > 5; +select deletes from mysql.ndb_binlog_index where epoch > @max_epoch and deletes > 5; +select inserts,updates,deletes from + mysql.ndb_binlog_index where epoch > @max_epoch and updates > 0; + +# +# check that purge clears the ndb_binlog_index +# +flush logs; +--sleep 1 +purge master logs before now(); +select count(*) from mysql.ndb_binlog_index; + +# +# several tables in different databases +# check that same table name in different databases don't mix up +# +create table t1 (a int primary key, b int) engine=ndb; +create database mysqltest; +use mysqltest; +create table t1 (c int, d int primary key) engine=ndb; +use test; + +insert into mysqltest.t1 values (2,1),(2,2); +save_master_pos; +--replace_column 1 # +select @max_epoch:=max(epoch)-1 from mysql.ndb_binlog_index; + +drop table t1; +drop database mysqltest; +select inserts,updates,deletes from + mysql.ndb_binlog_index where epoch > @max_epoch and inserts > 0; diff --git a/mysql-test/suite/ndb/t/ndb_binlog_ddl_multi.test b/mysql-test/suite/ndb/t/ndb_binlog_ddl_multi.test new file mode 100644 index 00000000000..a70dbe2011f --- /dev/null +++ b/mysql-test/suite/ndb/t/ndb_binlog_ddl_multi.test @@ -0,0 +1,190 @@ +-- source include/have_multi_ndb.inc +-- source include/have_binlog_format_mixed_or_row.inc + +--disable_warnings +connection server2; +drop database if exists mysqltest; +drop table if exists t1,t2,t3; +connection server1; +drop database if exists mysqltest; +drop table if exists t1,t2,t3; +--connection server1 +reset master; +--connection server2 +reset master; +--enable_warnings + +# +# basic test to see if ddl distribution works across +# multiple binlogs +# + +# create database +--connection server1 +create database mysqltest; + +# create table +--connection server1 +use mysqltest; +create table t1 (a int primary key) engine=ndb; + +--connection server2 +create table t2 (a int primary key) engine=ndb; +--source include/show_binlog_events2.inc + +--connection server1 +--source include/show_binlog_events2.inc + +# alter table +--connection server1 +reset master; +--connection server2 +reset master; + +--connection server2 +alter table t2 add column (b int); + +--connection server1 +--source include/show_binlog_events2.inc + +# alter database +--connection server1 +reset master; +--connection server2 +reset master; + +--connection server2 +ALTER DATABASE mysqltest CHARACTER SET latin1; + + +# having drop here instead of below sometimes triggers bug#18976 +## drop table and drop should come after data events +--connection server2 +drop table mysqltest.t1; + +--connection server1 +--source include/show_binlog_events2.inc +# to track down bug#18976 +--real_sleep 10 +--source include/show_binlog_events2.inc + +#--connection server2 +#drop table mysqltest.t1; + +# drop database and drop should come after data events +--connection server1 +reset master; +--connection server2 +reset master; + +--connection server1 +use test; +insert into t2 values (1,2); +drop database mysqltest; +create table t1 (a int primary key) engine=ndb; + +--connection server2 +--source include/show_binlog_events2.inc + +--connection server2 +drop table t2; + +# logfile groups and table spaces +--connection server1 +reset master; +--connection server2 +reset master; + +--connection server1 +CREATE LOGFILE GROUP lg1 +ADD UNDOFILE 'undofile.dat' +INITIAL_SIZE 16M +UNDO_BUFFER_SIZE = 1M +ENGINE=NDB; + +ALTER LOGFILE GROUP lg1 +ADD UNDOFILE 'undofile02.dat' +INITIAL_SIZE = 4M +ENGINE=NDB; + +CREATE TABLESPACE ts1 +ADD DATAFILE 'datafile.dat' +USE LOGFILE GROUP lg1 +INITIAL_SIZE 12M +ENGINE NDB; + +ALTER TABLESPACE ts1 +ADD DATAFILE 'datafile02.dat' +INITIAL_SIZE = 4M +ENGINE=NDB; + +ALTER TABLESPACE ts1 +DROP DATAFILE 'datafile.dat' +ENGINE = NDB; + +ALTER TABLESPACE ts1 +DROP DATAFILE 'datafile02.dat' +ENGINE = NDB; + +DROP TABLESPACE ts1 +ENGINE = NDB; + +DROP LOGFILE GROUP lg1 +ENGINE =NDB; + +# having drop here instead of below sometimes triggers bug#18976 +#drop table t1; + +--connection server2 +--source include/show_binlog_events2.inc +# to track down bug#18976 +--real_sleep 10 +--source include/show_binlog_events2.inc + +drop table t1; + +# +# 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_events2.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 +drop table t2; +--source include/show_binlog_events2.inc diff --git a/mysql-test/suite/ndb/t/ndb_binlog_discover.test b/mysql-test/suite/ndb/t/ndb_binlog_discover.test new file mode 100644 index 00000000000..e842b57093a --- /dev/null +++ b/mysql-test/suite/ndb/t/ndb_binlog_discover.test @@ -0,0 +1,36 @@ +-- source include/have_ndb.inc +-- source include/have_binlog_format_mixed_or_row.inc + +--disable_warnings +drop table if exists t1; +--enable_warnings + +# +# Bug #14516 Restart of cluster can cause NDB API replication failure +# +create table t1 (a int key) engine=ndb; +reset master; +--exec $NDB_MGM --no-defaults -e "all restart -n" > /dev/null +--exec $NDB_TOOLS_DIR/ndb_waiter --no-defaults --not-started > /dev/null +--exec $NDB_MGM --no-defaults -e "all start" > /dev/null +--exec $NDB_TOOLS_DIR/ndb_waiter --no-defaults > /dev/null + +--disable_query_log +let $mysql_errno= 1; +while ($mysql_errno) +{ + # Table t1 is readonly until the mysqld has reconnected properly + --error 0,1036,1296 + insert into t1 values(1); + if ($mysql_errno) + { + --sleep 0.1 + } +} +--enable_query_log + +--source include/show_binlog_events2.inc +PURGE MASTER LOGS TO 'master-bin.000002'; + +--source include/show_binlog_events2.inc +drop table t1; diff --git a/mysql-test/suite/ndb/t/ndb_binlog_format.test b/mysql-test/suite/ndb/t/ndb_binlog_format.test new file mode 100644 index 00000000000..acb34bb388c --- /dev/null +++ b/mysql-test/suite/ndb/t/ndb_binlog_format.test @@ -0,0 +1,33 @@ +# +# test different behavior of ndb using different binlog formats +# + +-- source include/have_blackhole.inc +-- source include/have_ndb.inc +-- source include/have_log_bin.inc + +--disable_warnings +drop table if exists t1, t2, t3; +--enable_warnings + +# +# Bug #29222 Statement mode replicates both statement and +# rows when writing to an NDB table +# +CREATE TABLE t1 (m INT, n INT) ENGINE=MYISAM; +CREATE TABLE t2 (b INT, c INT) ENGINE=BLACKHOLE; +CREATE TABLE t3 (e INT, f INT) ENGINE=NDB; +RESET MASTER; +SET SESSION BINLOG_FORMAT=STATEMENT; +INSERT INTO t1 VALUES (1,1), (1,2), (2,1), (2,2); +INSERT INTO t2 VALUES (1,1), (1,2), (2,1), (2,2); +UPDATE t1, t2 SET m = 2, b = 3 WHERE n = c; +# A transaction here is not necessary, but I wanted to group the bad statements +START TRANSACTION; +INSERT INTO t3 VALUES (1,1), (1,2), (2,1), (2,2); +UPDATE t1, t3 SET m = 2, e = 3 WHERE n = f; +UPDATE t3, t2 SET e = 2, b = 3 WHERE f = c; +COMMIT; +--source include/show_binlog_events.inc +DROP TABLE t1, t2, t3; + diff --git a/mysql-test/suite/ndb/t/ndb_binlog_ignore_db-master.opt b/mysql-test/suite/ndb/t/ndb_binlog_ignore_db-master.opt new file mode 100644 index 00000000000..e3947c0eeed --- /dev/null +++ b/mysql-test/suite/ndb/t/ndb_binlog_ignore_db-master.opt @@ -0,0 +1 @@ +--binlog-ignore-db=mysqltest diff --git a/mysql-test/suite/ndb/t/ndb_binlog_ignore_db.test b/mysql-test/suite/ndb/t/ndb_binlog_ignore_db.test new file mode 100644 index 00000000000..013df54a76a --- /dev/null +++ b/mysql-test/suite/ndb/t/ndb_binlog_ignore_db.test @@ -0,0 +1,16 @@ +-- source include/have_ndb.inc +-- source include/have_binlog_format_mixed_or_row.inc +reset master; + +--disable_warnings +drop table if exists t1; +drop database if exists mysqltest; +--enable_warnings + +create database mysqltest; +use mysqltest; +create table t1 (a int primary key, b int) engine=ndb; +insert into t1 values (1, 1); +-- source include/show_binlog_events2.inc + +drop database mysqltest; diff --git a/mysql-test/suite/ndb/t/ndb_binlog_log_bin.test b/mysql-test/suite/ndb/t/ndb_binlog_log_bin.test new file mode 100644 index 00000000000..75ac766fd25 --- /dev/null +++ b/mysql-test/suite/ndb/t/ndb_binlog_log_bin.test @@ -0,0 +1,49 @@ +-- source include/have_multi_ndb.inc +-- source include/have_binlog_format_mixed_or_row.inc + +--disable_warnings +connection server2; +drop table if exists t1,t2,t3; +reset master; +connection server1; +drop table if exists t1,t2,t3; +reset master; +--enable_warnings + +# basic SQL_LOG_BIN functionality +# see updates from one thread but not the other +connect (con1,localhost,root,,); +connect (con2,localhost,root,,); +# do some stuff with SQL_LOG_BIN=0 +connection con2; +set SQL_LOG_BIN=0; +create database mysqltest; +use mysqltest; +create table t1 (a int key, b int) engine=ndb; +create table t2 (a int key, b int) engine=ndb; +insert into t1 values (1,1); +alter table t1 add c int; +# we should not see it in the local server +-- source include/show_binlog_events2.inc +reset master; +# we should not see it in another server +connection server2; +use mysqltest; +insert into t2 values (1,1); +-- source include/show_binlog_events2.inc +reset master; +# but if you do stuff in "default" client setting +connection con1; +use mysqltest; +drop table t1; +drop table t2; +create table t1 (d int key, e int) engine=ndb; +create table t2 (d int key, e int) engine=ndb; +insert into t1 values (1,1); +-- source include/show_binlog_events2.inc +# and in another server +connection server2; +use mysqltest; +insert into t2 values (1,1); +-- source include/show_binlog_events2.inc +drop database mysqltest; diff --git a/mysql-test/suite/ndb/t/ndb_binlog_multi.test b/mysql-test/suite/ndb/t/ndb_binlog_multi.test new file mode 100644 index 00000000000..c39034c71f6 --- /dev/null +++ b/mysql-test/suite/ndb/t/ndb_binlog_multi.test @@ -0,0 +1,82 @@ +-- source include/have_multi_ndb.inc +-- source include/have_binlog_format_mixed_or_row.inc + +--disable_warnings +connection server2; +drop table if exists t1,t2,t3; +connection server1; +drop table if exists t1,t2,t3; +--enable_warnings + +# Dummy table create/drop to avoid a race where table is created +# before event subscription is set up, causing test failure (BUG#20677). +connection server2; +CREATE TABLE t3 (dummy INT PRIMARY KEY) ENGINE = NDB; +connection server1; +DROP TABLE t3; + +# reset for test +connection server1; +reset master; +connection server2; +reset master; + +# +# basic test to see if one server sees the table from the other +# and sets up the replication correctly +# + +# create table on the other server +connection server2; +CREATE TABLE t2 (a INT PRIMARY KEY, b int) ENGINE = NDB; + +# insert something on server2 +INSERT INTO t2 VALUES (1,1),(2,2); +# verify that we get the data in the binlog +--source include/show_binlog_events2.inc +select * from t2 order by a; +--replace_column 1 <the_epoch> +SELECT @the_epoch:=epoch,inserts,updates,deletes,schemaops FROM + mysql.ndb_binlog_index ORDER BY epoch DESC LIMIT 1; +let $the_epoch= `SELECT @the_epoch`; + +# see if we got something on server1 +connection server1; +SELECT * FROM t2 ORDER BY a; +# doing drop table will ensure that all the events have been received +DROP TABLE t2; +# verify thar we have table and data in binlog +--source include/show_binlog_events2.inc +--replace_result $the_epoch <the_epoch> +eval SELECT inserts,updates,deletes,schemaops FROM + mysql.ndb_binlog_index WHERE epoch=$the_epoch; + +# reset for next test +connection server1; +reset master; +connection server2; +reset master; + +# single schema ops will not show +connection server2; +CREATE TABLE t1 (a INT PRIMARY KEY) ENGINE = NDB; +INSERT INTO t1 VALUES (1),(2); +--source include/show_binlog_events2.inc +--replace_column 1 <the_epoch2> +SELECT @the_epoch2:=epoch,inserts,updates,deletes,schemaops FROM + mysql.ndb_binlog_index ORDER BY epoch DESC LIMIT 1; +let $the_epoch2= `SELECT @the_epoch2`; + +--replace_result $the_epoch <the_epoch> $the_epoch2 <the_epoch2> +eval SELECT inserts,updates,deletes,schemaops FROM + mysql.ndb_binlog_index WHERE epoch > $the_epoch AND epoch <= $the_epoch2; + +# now see that we have the events on the other server +connection server2; +# doing drop table will ensure that all the events have been received +drop table t1; +# verify thar we have table and data in binlog +--source include/show_binlog_events2.inc +--replace_result $the_epoch <the_epoch> $the_epoch2 <the_epoch2> +eval SELECT inserts,updates,deletes,schemaops FROM + mysql.ndb_binlog_index WHERE epoch > $the_epoch AND epoch <= $the_epoch2; diff --git a/mysql-test/suite/ndb/t/ndb_bitfield.test b/mysql-test/suite/ndb/t/ndb_bitfield.test new file mode 100644 index 00000000000..de0ae23bfe6 --- /dev/null +++ b/mysql-test/suite/ndb/t/ndb_bitfield.test @@ -0,0 +1,124 @@ +-- source include/have_ndb.inc +-- source include/not_embedded.inc + +--disable_warnings +drop table if exists t1; +--enable_warnings + +create table t1 ( + pk1 int not null primary key, + b bit(64) +) engine=ndbcluster; + +show create table t1; +insert into t1 values +(0,b'1111111111111111111111111111111111111111111111111111111111111111'), +(1,b'1000000000000000000000000000000000000000000000000000000000000000'), +(2,b'0000000000000000000000000000000000000000000000000000000000000001'), +(3,b'1010101010101010101010101010101010101010101010101010101010101010'), +(4,b'0101010101010101010101010101010101010101010101010101010101010101'); +select hex(b) from t1 order by pk1; +drop table t1; + +create table t1 ( + pk1 int not null primary key, + b bit(9) +) engine=ndbcluster; +insert into t1 values +(0,b'000000000'), +(1,b'000000001'), +(2,b'000000010'), +(3,b'000000011'), +(4,b'000000100'); +select hex(b) from t1 order by pk1; +update t1 set b = b + b'101010101'; +select hex(b) from t1 order by pk1; +drop table t1; + +create table t1 (a bit(7), b bit(9)) engine = ndbcluster; +insert into t1 values +(94, 46), (31, 438), (61, 152), (78, 123), (88, 411), (122, 118), (0, 177), +(75, 42), (108, 67), (79, 349), (59, 188), (68, 206), (49, 345), (118, 380), +(111, 368), (94, 468), (56, 379), (77, 133), (29, 399), (9, 363), (23, 36), +(116, 390), (119, 368), (87, 351), (123, 411), (24, 398), (34, 202), (28, 499), +(30, 83), (5, 178), (60, 343), (4, 245), (104, 280), (106, 446), (127, 403), +(44, 307), (68, 454), (57, 135); +select a+0 from t1 order by a; +select b+0 from t1 order by b; +drop table t1; + +create table t1 ( + dummyKey INTEGER NOT NULL, + a001 TINYINT, + a010 TINYINT, + a012 TINYINT, + a015 TINYINT, + a016 TINYINT, + a017 TINYINT, + a019 TINYINT, + a029 TINYINT, + a030 TINYINT, + a031 TINYINT, + a032 TINYINT, + a042 TINYINT, + a043 TINYINT, + a044 TINYINT, + a3001 TINYINT, + a3002 TINYINT, + a3003 TINYINT, + a3004 TINYINT, + a3005 TINYINT, + a3021 TINYINT, + a3022 TINYINT, + a BIT(6), + b BIT(6), + c BIT(6), + d TINYINT, + e TINYINT, + f TINYINT, + g TINYINT, + h TINYINT, + i TINYINT, + j TINYINT, + k TINYINT, + l TINYINT, + m TINYINT, + n TINYINT, + o TINYINT, + a034 TINYINT, +PRIMARY KEY USING HASH (dummyKey) ) engine=ndb; +INSERT INTO `t1` VALUES +(1,1,1,1,1,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,b'000001',b'111111',b'111110',4,5,5,5,5,5,5,5,5,5,3,2,1), +(2,1,1,1,1,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,b'000010',b'000000',b'111101',4,5,5,5,5,5,5,5,5,5,3,2,1), +(3,1,1,1,1,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,b'000100',b'001111',b'111011',4,5,5,5,5,5,5,5,5,5,3,2,1), +(4,1,1,1,1,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,b'001000',b'110000',b'110111',4,5,5,5,5,5,5,5,5,5,3,2,1), +(5,1,1,1,1,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,b'010000',b'100001',b'101111',4,5,5,5,5,5,5,5,5,5,3,2,1), +(6,1,1,1,1,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,b'100000',b'010010',b'011111',4,5,5,5,5,5,5,5,5,5,3,2,1), +(7,1,1,1,1,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,b'000000',b'001100',b'111111',4,5,5,5,5,5,5,5,5,5,3,2,1), +(8,1,1,1,1,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,b'111111',b'000000',b'000000',4,5,5,5,5,5,5,5,5,5,3,2,1); +--exec $MYSQL_DUMP --hex-blob --compact --order-by-primary --skip-extended-insert --no-create-info test t1 +drop table t1; + +--error 1005 +create table t1 ( + pk1 bit(9) not null primary key, + b int +) engine=ndbcluster; +show warnings; + +--error 1005 +create table t1 ( + pk1 int not null primary key, + b bit(9), + key(b) +) engine=ndbcluster; +show warnings; + +# bug#16125 +create table t1 ( + pk1 int primary key, + b bit(32) not null +) engine=ndbcluster; + +insert into t1 values (1,1); +drop table t1; diff --git a/mysql-test/suite/ndb/t/ndb_blob.test b/mysql-test/suite/ndb/t/ndb_blob.test new file mode 100644 index 00000000000..b9a8c7e20ee --- /dev/null +++ b/mysql-test/suite/ndb/t/ndb_blob.test @@ -0,0 +1,499 @@ +--source include/have_ndb.inc +-- source include/not_embedded.inc + +--disable_warnings +drop table if exists t1; +drop database if exists test2; +--enable_warnings + +# +# Minimal NDB blobs test. +# +# On NDB API level there is an extensive test program "testBlobs". +# A prerequisite for this handler test is that "testBlobs" succeeds. +# + +# -- general test starts -- + +# make test harder with autocommit off +set autocommit=0; + +create table t1 ( + a int not null primary key, + b text not null, + c int not null, + d longblob, + key (c) +) engine=ndbcluster; + +# -- values -- + +# x0 size 256 (current inline size) +set @x0 = '01234567012345670123456701234567'; +set @x0 = concat(@x0,@x0,@x0,@x0,@x0,@x0,@x0,@x0); + +# b1 length 2000+256 (blob part aligned) +set @b1 = 'b1'; +set @b1 = concat(@b1,@b1,@b1,@b1,@b1,@b1,@b1,@b1,@b1,@b1); +set @b1 = concat(@b1,@b1,@b1,@b1,@b1,@b1,@b1,@b1,@b1,@b1); +set @b1 = concat(@b1,@b1,@b1,@b1,@b1,@b1,@b1,@b1,@b1,@b1); +set @b1 = concat(@b1,@x0); +# d1 length 3000 +set @d1 = 'dd1'; +set @d1 = concat(@d1,@d1,@d1,@d1,@d1,@d1,@d1,@d1,@d1,@d1); +set @d1 = concat(@d1,@d1,@d1,@d1,@d1,@d1,@d1,@d1,@d1,@d1); +set @d1 = concat(@d1,@d1,@d1,@d1,@d1,@d1,@d1,@d1,@d1,@d1); + +# b2 length 20000 +set @b2 = 'b2'; +set @b2 = concat(@b2,@b2,@b2,@b2,@b2,@b2,@b2,@b2,@b2,@b2); +set @b2 = concat(@b2,@b2,@b2,@b2,@b2,@b2,@b2,@b2,@b2,@b2); +set @b2 = concat(@b2,@b2,@b2,@b2,@b2,@b2,@b2,@b2,@b2,@b2); +set @b2 = concat(@b2,@b2,@b2,@b2,@b2,@b2,@b2,@b2,@b2,@b2); +# d2 length 30000 +set @d2 = 'dd2'; +set @d2 = concat(@d2,@d2,@d2,@d2,@d2,@d2,@d2,@d2,@d2,@d2); +set @d2 = concat(@d2,@d2,@d2,@d2,@d2,@d2,@d2,@d2,@d2,@d2); +set @d2 = concat(@d2,@d2,@d2,@d2,@d2,@d2,@d2,@d2,@d2,@d2); +set @d2 = concat(@d2,@d2,@d2,@d2,@d2,@d2,@d2,@d2,@d2,@d2); + +select length(@x0),length(@b1),length(@d1) from dual; +select length(@x0),length(@b2),length(@d2) from dual; + +# -- pk ops -- + +insert into t1 values(1,@b1,111,@d1); +insert into t1 values(2,@b2,222,@d2); +commit; +--replace_column 9 # +explain select * from t1 where a = 1; + +# pk read +select a,length(b),substr(b,1+2*900,2),length(d),substr(d,1+3*900,3) +from t1 where a=1; +select a,length(b),substr(b,1+2*9000,2),length(d),substr(d,1+3*9000,3) +from t1 where a=2; + +# pk update +update t1 set b=@b2,d=@d2 where a=1; +update t1 set b=@b1,d=@d1 where a=2; +commit; +select a,length(b),substr(b,1+2*9000,2),length(d),substr(d,1+3*9000,3) +from t1 where a=1; +select a,length(b),substr(b,1+2*900,2),length(d),substr(d,1+3*900,3) +from t1 where a=2; + +# pk update +update t1 set b=concat(b,b),d=concat(d,d) where a=1; +update t1 set b=concat(b,b),d=concat(d,d) where a=2; +commit; +select a,length(b),substr(b,1+4*9000,2),length(d),substr(d,1+6*9000,3) +from t1 where a=1; +select a,length(b),substr(b,1+4*900,2),length(d),substr(d,1+6*900,3) +from t1 where a=2; + +# pk update to null +update t1 set d=null where a=1; +commit; +select a from t1 where d is null; + +# bug#24028 - does not occur on MySQL level +# bug#17986 - not seen by us anymore but could show as warning here +delete from t1 where a=45567; +commit; + +# pk delete +delete from t1 where a=1; +delete from t1 where a=2; +commit; +select count(*) from t1; + +# -- replace ( bug-6018 ) -- + +# insert +replace t1 set a=1,b=@b1,c=111,d=@d1; +replace t1 set a=2,b=@b2,c=222,d=@d2; +commit; +--replace_column 9 # +explain select * from t1 where a = 1; + +# pk read +select a,length(b),substr(b,1+2*900,2),length(d),substr(d,1+3*900,3) +from t1 where a=1; +select a,length(b),substr(b,1+2*9000,2),length(d),substr(d,1+3*9000,3) +from t1 where a=2; + +# update +replace t1 set a=1,b=@b2,c=111,d=@d2; +replace t1 set a=2,b=@b1,c=222,d=@d1; +commit; +select a,length(b),substr(b,1+2*9000,2),length(d),substr(d,1+3*9000,3) +from t1 where a=1; +select a,length(b),substr(b,1+2*900,2),length(d),substr(d,1+3*900,3) +from t1 where a=2; + +# update +replace t1 set a=1,b=concat(@b2,@b2),c=111,d=concat(@d2,@d2); +replace t1 set a=2,b=concat(@b1,@b1),c=222,d=concat(@d1,@d1); +commit; +select a,length(b),substr(b,1+4*9000,2),length(d),substr(d,1+6*9000,3) +from t1 where a=1; +select a,length(b),substr(b,1+4*900,2),length(d),substr(d,1+6*900,3) +from t1 where a=2; + +# update to null +replace t1 set a=1,b='xyz',c=111,d=null; +commit; +select a,b from t1 where d is null; + +# pk delete +delete from t1 where a=1; +delete from t1 where a=2; +commit; +select count(*) from t1; + +# -- hash index ops -- + +insert into t1 values(1,@b1,111,@d1); +insert into t1 values(2,@b2,222,@d2); +commit; +--replace_column 9 # +explain select * from t1 where c = 111; + +# hash key read +select a,length(b),substr(b,1+2*900,2),length(d),substr(d,1+3*900,3) +from t1 where c=111; +select a,length(b),substr(b,1+2*9000,2),length(d),substr(d,1+3*9000,3) +from t1 where c=222; + +# hash key update +update t1 set b=@b2,d=@d2 where c=111; +update t1 set b=@b1,d=@d1 where c=222; +commit; +select a,length(b),substr(b,1+2*9000,2),length(d),substr(d,1+3*9000,3) +from t1 where c=111; +select a,length(b),substr(b,1+2*900,2),length(d),substr(d,1+3*900,3) +from t1 where c=222; + +# hash key update to null +update t1 set d=null where c=111; +commit; +select a from t1 where d is null; + +# hash key delete +delete from t1 where c=111; +delete from t1 where c=222; +commit; +select count(*) from t1; + +# -- table scan ops, short values -- + +insert into t1 values(1,'b1',111,'dd1'); +insert into t1 values(2,'b2',222,'dd2'); +insert into t1 values(3,'b3',333,'dd3'); +insert into t1 values(4,'b4',444,'dd4'); +insert into t1 values(5,'b5',555,'dd5'); +insert into t1 values(6,'b6',666,'dd6'); +insert into t1 values(7,'b7',777,'dd7'); +insert into t1 values(8,'b8',888,'dd8'); +insert into t1 values(9,'b9',999,'dd9'); +commit; +--replace_column 9 # +explain select * from t1; + +# table scan read +select * from t1 order by a; + +# table scan update +update t1 set b=concat(a,'x',b),d=concat(a,'x',d); +commit; +select * from t1 order by a; + +# table scan delete +delete from t1; +commit; +select count(*) from t1; + +# -- table scan ops, long values -- + +insert into t1 values(1,@b1,111,@d1); +insert into t1 values(2,@b2,222,@d2); +commit; +--replace_column 9 # +explain select * from t1; + +# table scan read +select a,length(b),substr(b,1+2*900,2),length(d),substr(d,1+3*900,3) +from t1 order by a; + +# table scan update +update t1 set b=concat(b,b),d=concat(d,d); +commit; +select a,length(b),substr(b,1+4*9000,2),length(d),substr(d,1+6*9000,3) +from t1 order by a; + +# table scan delete +delete from t1; +commit; +select count(*) from t1; + +# -- range scan ops, short values -- + +insert into t1 values(1,'b1',111,'dd1'); +insert into t1 values(2,'b2',222,'dd2'); +insert into t1 values(3,'b3',333,'dd3'); +insert into t1 values(4,'b4',444,'dd4'); +insert into t1 values(5,'b5',555,'dd5'); +insert into t1 values(6,'b6',666,'dd6'); +insert into t1 values(7,'b7',777,'dd7'); +insert into t1 values(8,'b8',888,'dd8'); +insert into t1 values(9,'b9',999,'dd9'); +commit; +--replace_column 9 # +explain select * from t1 where c >= 100 order by a; + +# range scan read +select * from t1 where c >= 100 order by a; + +# range scan update +update t1 set b=concat(a,'x',b),d=concat(a,'x',d) +where c >= 100; +commit; +select * from t1 where c >= 100 order by a; + +# range scan delete +delete from t1 where c >= 100; +commit; +select count(*) from t1; + +# -- range scan ops, long values -- + +insert into t1 values(1,@b1,111,@d1); +insert into t1 values(2,@b2,222,@d2); +commit; +--replace_column 9 # +explain select * from t1 where c >= 100 order by a; + +# range scan read +select a,length(b),substr(b,1+2*900,2),length(d),substr(d,1+3*900,3) +from t1 where c >= 100 order by a; + +# range scan update +update t1 set b=concat(b,b),d=concat(d,d); +commit; +select a,length(b),substr(b,1+4*9000,2),length(d),substr(d,1+6*9000,3) +from t1 where c >= 100 order by a; + +# range scan delete +delete from t1 where c >= 100; +commit; +select count(*) from t1; + +# -- rollback -- + +insert into t1 values(1,@b1,111,@d1); +insert into t1 values(2,@b2,222,@d2); +# 626 +select a,length(b),substr(b,1+2*900,2),length(d),substr(d,1+3*900,3) +from t1 where a = 0; +select a,length(b),substr(b,1+2*900,2),length(d),substr(d,1+3*900,3) +from t1 where a = 1; +select a,length(b),substr(b,1+2*900,2),length(d),substr(d,1+3*900,3) +from t1 where a = 2; +select a,length(b),substr(b,1+2*900,2),length(d),substr(d,1+3*900,3) +from t1 order by a; +rollback; +select count(*) from t1; + +# -- alter table and multi db -- + +insert into t1 values(1,'b1',111,'dd1'); +insert into t1 values(2,'b2',222,'dd2'); +insert into t1 values(3,'b3',333,'dd3'); +insert into t1 values(4,'b4',444,'dd4'); +insert into t1 values(5,'b5',555,'dd5'); +insert into t1 values(6,'b6',666,'dd6'); +insert into t1 values(7,'b7',777,'dd7'); +insert into t1 values(8,'b8',888,'dd8'); +insert into t1 values(9,'b9',999,'dd9'); +commit; + +select * from t1 order by a; +alter table t1 add x int; +select * from t1 order by a; +alter table t1 drop x; +select * from t1 order by a; + +create database test2; +use test2; + +CREATE TABLE t2 ( + a bigint unsigned NOT NULL PRIMARY KEY, + b int unsigned not null, + c int unsigned +) engine=ndbcluster; + +insert into t2 values (1,1,1),(2,2,2); +select * from test.t1,t2 where test.t1.a = t2.a order by test.t1.a; + +drop table t2; +use test; + +select * from t1 order by a; +alter table t1 add x int; +select * from t1 order by a; +alter table t1 drop x; +select * from t1 order by a; + +# -- end general test -- + +drop table t1; +drop database test2; + +# -- bug-5252 tinytext crashes + no-commit result + replace -- + +set autocommit=0; +create table t1 ( + a int not null primary key, + b tinytext +) engine=ndbcluster; + +insert into t1 values(1, 'x'); +update t1 set b = 'y'; +select * from t1; +delete from t1; +select * from t1; +commit; +replace t1 set a=2, b='y'; +select * from t1; +delete from t1; +select * from t1; +drop table t1; + +# -- bug-5013 insert empty string to text -- + +set autocommit=0; +create table t1 ( + a int not null primary key, + b text not null +) engine=ndbcluster; + +insert into t1 values(1, ''); +select * from t1; +commit; +drop table t1; + +# -- bug #5349 -- +set autocommit=1; +use test; +CREATE TABLE t1 ( + a int, + b text, + PRIMARY KEY (a) +) ENGINE=MyISAM DEFAULT CHARSET=latin1; + +INSERT INTO t1 VALUES +(1,'AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA'); +INSERT INTO t1 VALUES +(2,'BBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBB'); + +select * from t1 order by a; +alter table t1 engine=ndb; +select * from t1 order by a; + +# -- bug #5872 -- +set autocommit=1; +alter table t1 engine=myisam; +select * from t1 order by a; +drop table t1; + +# -- bug #7340 -- +create table t1 ( + id int(11) unsigned primary key NOT NULL auto_increment, + msg text NOT NULL +) engine=ndbcluster default charset=utf8; +insert into t1 (msg) values( +'Tries to validate (8 byte length + inline bytes) as UTF8 :( +Fast fix: removed validation for Text. It is not yet indexable +so bad data will not crash kernel.'); +select * from t1; +drop table t1; + +# -- bug #19201 +create table t1 ( + a int primary key not null auto_increment, + b text +) engine=ndbcluster; +--disable_query_log +set autocommit=1; +# more rows than batch size (64) +# for this bug no blob parts would be necessary +let $1 = 500; +while ($1) +{ + insert into t1 (b) values (repeat('x',4000)); + dec $1; +} +--enable_query_log +select count(*) from t1; +truncate t1; +select count(*) from t1; +drop table t1; + +# -- bug#19956 - var* key, complex key + +create table t1 ( + a varchar(40) not null, + b mediumint not null, + t text, + c varchar(2) not null, + d bigint not null, + primary key (a,b,c), + key (c,a), + unique key (d) +) engine=ndb; + +--disable_query_log +set @s1 = 'rggurloniukyehuxdbfkkyzlceixzrehqhvxvxbpwizzvjzpucqmzrhzxzfau'; +set @s2 = 'ykyymbzqgqlcjhlhmyqelfoaaohvtbekvifukdtnvcrrjveevfakxarxexomz'; +set @s3 = 'dbnfqyzgtqxalcrwtfsqabknvtfcbpoonxsjiqvmhnfikxxhcgoexlkoezvah'; +set @v1 = repeat(@s1,123); +set @v2 = repeat(@s2,234); +set @v3 = repeat(@s3,345); +set @v4 = NULL; +--enable_query_log + +insert into t1 (a,b,c,d,t) values ('a',1110,'a',1,@v1); +insert into t1 (a,b,c,d,t) values ('b',1110,'a',2,@v2); +insert into t1 (a,b,c,d,t) values ('a',1110,'b',3,@v3); +insert into t1 (a,b,c,d,t) values ('b',1110,'b',4,@v4); +select a,b,c,d,sha1(t) from t1 order by c,a; + +select a,b,c,d,sha1(t) from t1 where a='a' and b=1110 and c='a'; +select a,b,c,d,sha1(t) from t1 where a='a' and b=1110 and c='b'; + +update t1 set t=@v4 where a='b' and b=1110 and c='a'; +update t1 set t=@v2 where a='b' and b=1110 and c='b'; +select a,b,c,d,sha1(t) from t1 order by c,a; + +update t1 set t=@v2 where d=2; +update t1 set t=@v4 where d=4; +select a,b,c,d,sha1(t) from t1 order by c,a; + +update t1 set t=@v4 where a='b' and c='a'; +update t1 set t=@v2 where a='b' and c='b'; +select a,b,c,d,sha1(t) from t1 order by c,a; + +update t1 set t=@v2 where b+d=1112; +update t1 set t=@v4 where b+d=1114; +select a,b,c,d,sha1(t) from t1 order by c,a; + +delete from t1 where a='a' and b=1110 and c='a'; +delete from t1 where a='b' and c='a'; +delete from t1 where d=3; +delete from t1 where b+d=1114; +select count(*) from t1; + +drop table t1; + +# End of 4.1 tests diff --git a/mysql-test/suite/ndb/t/ndb_blob_partition.test b/mysql-test/suite/ndb/t/ndb_blob_partition.test new file mode 100644 index 00000000000..35df57b96ba --- /dev/null +++ b/mysql-test/suite/ndb/t/ndb_blob_partition.test @@ -0,0 +1,97 @@ +--source include/have_ndb.inc +-- source include/not_embedded.inc + +--disable_query_log +set new=on; +--enable_query_log + +--disable_warnings +drop table if exists t1; +--enable_warnings + +# +# Minimal NDB blobs test with range partitions. +# + +create table t1 ( + a mediumint not null, + b text not null, + c int not null, + d longblob, + primary key using hash (a,c), + unique key (c) +) + engine=ndb + partition by range (c) + partitions 3 + ( partition p1 values less than (200), + partition p2 values less than (300), + partition p3 values less than (400)); + +--disable_query_log +sleep 1; + +# length 61 +set @s0 = 'rggurloniukyehuxdbfkkyzlceixzrehqhvxvxbpwizzvjzpucqmzrhzxzfau'; +set @s1 = 'ykyymbzqgqlcjhlhmyqelfoaaohvtbekvifukdtnvcrrjveevfakxarxexomz'; +set @s2 = 'dbnfqyzgtqxalcrwtfsqabknvtfcbpoonxsjiqvmhnfikxxhcgoexlkoezvah'; + +set @v1 = repeat(@s0, 100); # 1d42dd9090cf78314a06665d4ea938c35cc760f4 +set @v2 = repeat(@s1, 200); # 10d3c783026b310218d10b7188da96a2401648c6 +set @v3 = repeat(@s2, 300); # a33549d9844092289a58ac348dd59f09fc28406a +set @v4 = repeat(@s0, 400); # daa61c6de36a0526f0d47dc29d6b9de7e6d2630c +set @v5 = repeat(@s1, 500); # 70fc9a7d08beebc522258bfb02000a30c77a8f1d +set @v6 = repeat(@s2, 600); # 090565c580809efed3d369481a4bbb168b20713e +set @v7 = repeat(@s0, 700); # 1e0070bec426871a46291de27b9bd6e4255ab4e5 +set @v8 = repeat(@s1, 800); # acbaba01bc2e682f015f40e79d9cbe475db3002e +set @v9 = repeat(@s2, 900); # 9ee30d99162574f79c66ae95cdf132dcf9cbc259 +--enable_query_log + +# -- insert -- +insert into t1 values (1, @v1, 101, @v2); +insert into t1 values (1, @v2, 102, @v3); +insert into t1 values (1, @v3, 103, @v4); +insert into t1 values (2, @v4, 201, @v5); +insert into t1 values (2, @v5, 202, @v6); +insert into t1 values (2, @v6, 203, @v7); +insert into t1 values (3, @v7, 301, @v8); +insert into t1 values (3, @v8, 302, @v9); +insert into t1 values (3, @v9, 303, @v1); +select a, sha1(b), c, sha1(d) from t1 order by a; + +# -- pk read -- +select a, sha1(b), c, sha1(d) from t1 where a = 1 and c = 101; +select a, sha1(b), c, sha1(d) from t1 where a = 2 and c = 201; +select a, sha1(b), c, sha1(d) from t1 where a = 3 and c = 301; + +# -- pk update -- +update t1 set b = @v3, d = @v4 where a = 1 and c = 102; +update t1 set b = @v6, d = @v7 where a = 2 and c = 202; +update t1 set b = @v9, d = @v1 where a = 3 and c = 302; +select a, sha1(b), c, sha1(d) from t1 order by a; + +# -- hash index update -- +update t1 set b = @v4, d = @v5 where c = 103; +update t1 set b = @v7, d = @v8 where c = 203; +update t1 set b = @v1, d = @v2 where c = 303; +select a, sha1(b), c, sha1(d) from t1 order by a; + +# -- full scan update -- +update t1 set b = @v5, d = @v6; +select a, sha1(b), c, sha1(d) from t1 order by a; + +# -- range scan update +update t1 set b = @v1, d = @v2 where 100 < c and c < 200; +update t1 set b = @v4, d = @v5 where 200 < c and c < 300; +update t1 set b = @v7, d = @v8 where 300 < c and c < 400; +select a, sha1(b), c, sha1(d) from t1 order by a; + +# -- delete -- +delete from t1 where a = 1 and c = 101; +delete from t1 where c = 102; +# delete from t1 where c < 300; # XXX coredump +delete from t1; +select a, sha1(b), c, sha1(d) from t1 order by a; + +# -- clean up -- +drop table t1; diff --git a/mysql-test/suite/ndb/t/ndb_cache.test b/mysql-test/suite/ndb/t/ndb_cache.test new file mode 100644 index 00000000000..9c299b61c24 --- /dev/null +++ b/mysql-test/suite/ndb/t/ndb_cache.test @@ -0,0 +1,122 @@ +-- source include/have_query_cache.inc +-- source include/have_ndb.inc +-- source include/not_embedded.inc + +--disable_warnings +drop table if exists t1; +--enable_warnings + +# Turn on and reset query cache +set GLOBAL query_cache_type=on; +set GLOBAL query_cache_size=1355776; +reset query cache; +flush status; + +# Create test table in NDB +CREATE TABLE t1 ( pk int not null primary key, + a int, b int not null, c varchar(20)) ENGINE=ndbcluster; +insert into t1 value (1, 2, 3, 'First row'); + +# Perform one query which should be inerted in query cache +select * from t1; +show status like "Qcache_queries_in_cache"; +show status like "Qcache_inserts"; +show status like "Qcache_hits"; + +# Perform the same query and make sure the query cache is hit +select * from t1; +show status like "Qcache_hits"; + +# Update the table and make sure the correct data is returned +update t1 set a=3 where pk=1; +select * from t1; +show status like "Qcache_inserts"; +show status like "Qcache_hits"; + +# Insert a new record and make sure the correct data is returned +insert into t1 value (2, 7, 8, 'Second row'); +insert into t1 value (4, 5, 6, 'Fourth row'); +select * from t1 order by pk; +show status like "Qcache_inserts"; +show status like "Qcache_hits"; +select * from t1 order by pk; +show status like "Qcache_hits"; + +# Perform a "new" query and make sure the query cache is not hit +select * from t1 where b=3; +show status like "Qcache_queries_in_cache"; +show status like "Qcache_hits"; + +# Same query again... +select * from t1 where b=3; +show status like "Qcache_hits"; + +# Delete from the table +delete from t1 where c='Fourth row'; +show status like "Qcache_queries_in_cache"; +select * from t1 where b=3; +show status like "Qcache_hits"; + +# Start another connection and check that the query cache is hit +connect (con1,localhost,root,,); +connection con1; +use test; +select * from t1 order by pk; +select * from t1 where b=3; +show status like "Qcache_hits"; + +# Update the table and switch to other connection +update t1 set a=4 where b=3; +connect (con2,localhost,root,,); +connection con2; +use test; +show status like "Qcache_queries_in_cache"; +select * from t1 order by pk desc; +select * from t1 order by pk desc; +show status like "Qcache_inserts"; +show status like "Qcache_hits"; +connection con1; +select * from t1 order by pk desc; +select * from t1 order by pk desc; +show status like "Qcache_queries_in_cache"; +show status like "Qcache_inserts"; +show status like "Qcache_hits"; + +# Use transactions and make sure the query cache is not updated until +# transaction is commited +begin; +update t1 set a=5 where pk=1; +# Note!! the below test shows that table is invalidated +# before transaction is committed +# TODO Fix so that cache is not invalidated HERE! +show status like "Qcache_queries_in_cache"; +show status like "Qcache_inserts"; +show status like "Qcache_hits"; +connection con2; +select * from t1 order by pk desc; +show status like "Qcache_queries_in_cache"; +show status like "Qcache_inserts"; +show status like "Qcache_hits"; +connection con1; +commit; +# TODO Here query is invalidated once again, commit count in NDB has changed +show status like "Qcache_queries_in_cache"; +show status like "Qcache_inserts"; +show status like "Qcache_hits"; +connection con2; +select * from t1 order by pk desc; +show status like "Qcache_inserts"; +show status like "Qcache_hits"; +connection con1; +select * from t1 order by pk desc; +show status like "Qcache_queries_in_cache"; +show status like "Qcache_inserts"; +show status like "Qcache_hits"; + +drop table t1; + +show status like "Qcache_queries_in_cache"; + +SET GLOBAL query_cache_size=0; + +# End of 4.1 tests diff --git a/mysql-test/suite/ndb/t/ndb_cache2.test b/mysql-test/suite/ndb/t/ndb_cache2.test new file mode 100644 index 00000000000..352b01ef73f --- /dev/null +++ b/mysql-test/suite/ndb/t/ndb_cache2.test @@ -0,0 +1,361 @@ +-- source include/have_query_cache.inc +-- source include/have_ndb.inc +-- source include/not_embedded.inc + +--disable_warnings +drop table if exists t1, t2, t3, t4, t5; +--enable_warnings + + +# Turn on and reset query cache +set GLOBAL query_cache_type=on; +set GLOBAL query_cache_size=1355776; +# Turn on thread that will fetch commit count for open tables +set GLOBAL ndb_cache_check_time=100; +reset query cache; +flush status; + +# Create test tables in NDB +CREATE TABLE t1 ( + pk int not null primary key, + a1 int, + b1 int not null, + c1 varchar(20) +) ENGINE=ndb; +CREATE TABLE t2 ( + pk int not null primary key, + a2 int, + b2 int not null +) ENGINE=ndb; +CREATE TABLE t3 ( + pk int not null primary key, + a3 int, + b3 int not null, + c3 int not null, + d3 varchar(20) +) ENGINE=ndb; +CREATE TABLE t4 ( + a4 int, + b4 int not null, + c4 char(20) +) ENGINE=ndbcluster; +CREATE TABLE t5 ( + pk int not null primary key, + a5 int, + b5 int not null, + c5 varchar(255) +) ENGINE=ndbcluster; +insert into t1 value (1, 2, 3, 'First row'); +insert into t2 value (1, 2, 3); +insert into t3 value (1, 2, 3, 4, '3 - First row'); +insert into t4 value (2, 3, '4 - First row'); +insert into t5 value (1, 2, 3, '5 - First row'); + +# Perform one query which should be inserted in query cache +select * from t1; +show status like "Qcache_queries_in_cache"; +show status like "Qcache_inserts"; +show status like "Qcache_hits"; + +# Perform the same query and make sure the query cache is hit +select * from t1; +show status like "Qcache_hits"; + +# Update the table and make sure the correct data is returned +update t1 set a1=3 where pk=1; +select * from t1; +show status like "Qcache_inserts"; +show status like "Qcache_hits"; + +# Insert a new record and make sure the correct data is returned +insert into t1 value (2, 7, 8, 'Second row'); +insert into t1 value (4, 5, 6, 'Fourth row'); +select * from t1 order by pk desc; +show status like "Qcache_inserts"; +show status like "Qcache_hits"; +select * from t1 order by pk desc; +show status like "Qcache_hits"; + +# Perform a "new" query and make sure the query cache is not hit +select * from t1 where b1=3; +show status like "Qcache_queries_in_cache"; +show status like "Qcache_hits"; + +# Same query again... +select * from t1 where b1=3; +show status like "Qcache_hits"; + +# Delete from the table +delete from t1 where c1='Fourth row'; +show status like "Qcache_queries_in_cache"; +select * from t1 where b1=3; +show status like "Qcache_hits"; + +# Start another connection and check that the query cache is hit +connect (con1,localhost,root,,); +connection con1; +use test; +select * from t1 order by pk desc; +select * from t1 where b1=3; +show status like "Qcache_hits"; + +# Update the table and switch to other connection +update t1 set a1=4 where b1=3; +connect (con2,localhost,root,,); +connection con2; +use test; +show status like "Qcache_queries_in_cache"; +select * from t1 order by pk desc; +select * from t1 order by pk desc; +show status like "Qcache_inserts"; +show status like "Qcache_hits"; +connection con1; +select * from t1 order by pk desc; +select * from t1 order by pk desc; +show status like "Qcache_queries_in_cache"; +show status like "Qcache_inserts"; +show status like "Qcache_hits"; + +# Load all tables into cache +select * from t2; +select * from t3; +select * from t4; +select * from t5; +show status like "Qcache_queries_in_cache"; + +##################################################################### +# Start transaction and perform update +# Switch to other transaction and check that update does not show up +# Switch back and commit transaction +# Switch to other transaction and check that update shows up +##################################################################### +connection con1; +flush status; +begin; +update t1 set a1=5 where pk=1; +show status like "Qcache_queries_in_cache"; +show status like "Qcache_inserts"; +show status like "Qcache_hits"; +connection con2; +select * from t1 order by pk desc; +show status like "Qcache_queries_in_cache"; +show status like "Qcache_inserts"; +show status like "Qcache_hits"; +connection con1; +commit; +show status like "Qcache_queries_in_cache"; +show status like "Qcache_inserts"; +show status like "Qcache_hits"; +connection con2; +select * from t1 order by pk desc; +show status like "Qcache_inserts"; +show status like "Qcache_hits"; +connection con1; +select * from t1 order by pk desc; +show status like "Qcache_queries_in_cache"; +show status like "Qcache_inserts"; +show status like "Qcache_hits"; + +##################################################################### +# Start transaction and perform update +# Switch to other transaction and check that update does not show up +# Switch back, perform selects and commit transaction +# Switch to other transaction and check that update shows up +##################################################################### +connection con1; +flush status; +begin; +update t1 set a1=6 where pk=1; +show status like "Qcache_queries_in_cache"; +show status like "Qcache_inserts"; +show status like "Qcache_hits"; +connection con2; +select * from t1 order by pk desc; +select * from t1 order by pk desc; +show status like "Qcache_queries_in_cache"; +show status like "Qcache_inserts"; +show status like "Qcache_hits"; +connection con1; +# The two queries below will not hit cache since transaction is ongoing +select * from t1 order by pk desc; +select * from t1 order by pk desc; +show status like "Qcache_queries_in_cache"; +show status like "Qcache_inserts"; +show status like "Qcache_hits"; +commit; + +show status like "Qcache_queries_in_cache"; +show status like "Qcache_inserts"; +show status like "Qcache_hits"; +connection con2; +select * from t1 order by pk desc; +show status like "Qcache_inserts"; +show status like "Qcache_hits"; +connection con1; +select * from t1 order by pk desc; +show status like "Qcache_queries_in_cache"; +show status like "Qcache_inserts"; +show status like "Qcache_hits"; + +##################################################################### +# Start transaction and perform insert +# Switch to other transaction and check that insert does not show up +# Switch back, perform selects and commit transaction +# Switch to other transaction and check that update shows up +##################################################################### +connection con1; +flush status; +begin; +insert into t1 set pk=5, a1=6, b1=3, c1="New row"; +show status like "Qcache_queries_in_cache"; +show status like "Qcache_inserts"; +show status like "Qcache_hits"; +connection con2; +select * from t1 where pk=5; +select * from t1 order by pk desc; +show status like "Qcache_queries_in_cache"; +show status like "Qcache_inserts"; +show status like "Qcache_hits"; +connection con1; +# The below four queries will not be cached, trans is ongoing +select * from t1 where pk=5; +select * from t1 where pk=5; +select * from t1 order by pk desc; +select * from t1 order by pk desc; +show status like "Qcache_queries_in_cache"; +show status like "Qcache_inserts"; +show status like "Qcache_hits"; +commit; + +connection con2; +select * from t1 order by pk desc; +show status like "Qcache_queries_in_cache"; +show status like "Qcache_inserts"; +show status like "Qcache_hits"; + +connection con1; + +##################################################################### +# Start transaction and perform delete +# Switch to other transaction and check that delete does not show up +# Switch back, perform selects and commit transaction +# Switch to other transaction and check that update shows up +##################################################################### +connection con1; +flush status; +begin; +delete from t1 where pk=2; +show status like "Qcache_queries_in_cache"; +show status like "Qcache_inserts"; +show status like "Qcache_hits"; +connection con2; +select * from t1 where pk=2; +select * from t1 order by pk desc; +show status like "Qcache_queries_in_cache"; +show status like "Qcache_inserts"; +show status like "Qcache_hits"; +connection con1; +# The below four queries will not be cached, trans is ongoing +select * from t1 where pk=2; +select * from t1 order by pk desc; +select * from t1 order by pk desc; +select * from t1 where pk=2; +show status like "Qcache_queries_in_cache"; +show status like "Qcache_inserts"; +show status like "Qcache_hits"; +commit; + +connection con2; +select * from t1 order by pk desc; +select * from t1 where pk=2; +show status like "Qcache_queries_in_cache"; +show status like "Qcache_inserts"; +show status like "Qcache_hits"; + +connection con1; + +##################################################################### +# Start a transaction which updates all tables +# Switch to other transaction and check updates does not show up +# Switch back, perform selects and commit transaction +# Switch to other transaction and check that update shows up +##################################################################### +flush status; +begin; +update t1 set a1=9 where pk=1; +update t2 set a2=9 where pk=1; +update t3 set a3=9 where pk=1; +update t4 set a4=9 where a4=2; +update t5 set a5=9 where pk=1; +show status like "Qcache_queries_in_cache"; +show status like "Qcache_inserts"; +show status like "Qcache_hits"; +connection con2; +select * from t1 order by pk desc; +select * from t2; +select * from t3; +select * from t4; +select * from t5; +show status like "Qcache_queries_in_cache"; +show status like "Qcache_inserts"; +show status like "Qcache_hits"; +connection con1; +# The below five queries will not be cached, trans is ongoing +select * from t1 order by pk desc; +select * from t1 order by pk desc; +select * from t2; +select * from t3; +select * from t4; +select * from t5; +show status like "Qcache_queries_in_cache"; +show status like "Qcache_inserts"; +show status like "Qcache_hits"; +commit; + +connection con2; +select * from t1 order by pk desc; +select * from t2; +select * from t3; +select * from t4; +select * from t5; +show status like "Qcache_queries_in_cache"; +show status like "Qcache_inserts"; +show status like "Qcache_hits"; + +connection con1; +select * from t1 order by pk desc; +select * from t2; +select * from t3; +select * from t4; +select * from t5; +show status like "Qcache_queries_in_cache"; +show status like "Qcache_inserts"; +show status like "Qcache_hits"; +select * from t1 order by pk desc; +select * from t2; +select * from t3; +select * from t4; +select * from t5; +show status like "Qcache_queries_in_cache"; +show status like "Qcache_inserts"; +show status like "Qcache_hits"; + +connection con2; +select * from t1 order by pk desc; +select * from t2; +select * from t3; +select * from t4; +select * from t5; +show status like "Qcache_queries_in_cache"; +show status like "Qcache_inserts"; +show status like "Qcache_hits"; + +drop table t1, t2, t3, t4, t5; + +# There should be no queries in cache, when tables have been dropped +show status like "Qcache_queries_in_cache"; + +SET GLOBAL query_cache_size=0; +SET GLOBAL ndb_cache_check_time=0; + + diff --git a/mysql-test/suite/ndb/t/ndb_cache_multi.test b/mysql-test/suite/ndb/t/ndb_cache_multi.test new file mode 100644 index 00000000000..8c7f186b866 --- /dev/null +++ b/mysql-test/suite/ndb/t/ndb_cache_multi.test @@ -0,0 +1,71 @@ +-- source include/have_query_cache.inc +-- source include/have_multi_ndb.inc +-- source include/not_embedded.inc + +--disable_warnings +drop table if exists t1, t2; +--enable_warnings + + +# Turn on and reset query cache on server1 +connection server1; +set GLOBAL query_cache_type=on; +set GLOBAL query_cache_size=1355776; +reset query cache; +flush status; + +# Turn on and reset query cache on server2 +connection server2; +set GLOBAL query_cache_type=on; +set GLOBAL query_cache_size=1355776; +reset query cache; +flush status; + + + +# Create test tables in NDB and load them into cache +# on server1 +connection server1; +create table t1 (a int) engine=ndbcluster; +create table t2 (a int) engine=ndbcluster; +insert into t1 value (2); +insert into t2 value (3); +select * from t1; +select * from t2; +show status like "Qcache_queries_in_cache"; +show status like "Qcache_inserts"; +show status like "Qcache_hits"; + + +# Connect server2, load table in to cache, then update the table +connection server2; +show status like "Qcache_queries_in_cache"; +show status like "Qcache_inserts"; +show status like "Qcache_hits"; +select * from t1; +show status like "Qcache_queries_in_cache"; +show status like "Qcache_inserts"; +show status like "Qcache_hits"; +update t1 set a=3 where a=2; + +# Connect to server1 and check that cache is invalidated +# and correct data is returned +connection server1; +show status like "Qcache_queries_in_cache"; +show status like "Qcache_inserts"; +show status like "Qcache_hits"; +select * from t1; +show status like "Qcache_queries_in_cache"; +show status like "Qcache_inserts"; +show status like "Qcache_hits"; + +drop table t1, t2; + + +# Turn off query cache on server1 +connection server1; +set GLOBAL query_cache_size=0; + +# Turn off query cache on server2 +connection server2; +set GLOBAL query_cache_size=0; diff --git a/mysql-test/suite/ndb/t/ndb_cache_multi2.test b/mysql-test/suite/ndb/t/ndb_cache_multi2.test new file mode 100644 index 00000000000..853e4090193 --- /dev/null +++ b/mysql-test/suite/ndb/t/ndb_cache_multi2.test @@ -0,0 +1,125 @@ +-- source include/have_query_cache.inc +-- source include/have_multi_ndb.inc +-- source include/not_embedded.inc + +--disable_warnings +drop table if exists t1, t2; +--enable_warnings + + +# Turn on and reset query cache on server1 +connection server1; +echo == Connected to server1 ==; +set GLOBAL query_cache_type=on; +set GLOBAL query_cache_size=1355776; +set GLOBAL ndb_cache_check_time=1; +reset query cache; +flush status; + +# Turn on and reset query cache on server2 +connection server2; +echo == Connected to server2 ==; +set GLOBAL query_cache_type=on; +set GLOBAL query_cache_size=1355776; +set GLOBAL ndb_cache_check_time=1; +reset query cache; +flush status; + +# Create test tables in NDB and load them into cache +# on server1 +connection server1; +echo == Connected to server1 ==; +create table t1 (a int) engine=ndbcluster; +create table t2 (a int) engine=ndbcluster; +insert into t1 value (2); +insert into t2 value (3); +select * from t1; +# Run the check query once to load it into qc on server1 +# See at the end of this test why we need to disable ps-protocol for +# this query (*) +--disable_ps_protocol +select a != 3 from t1; +--enable_ps_protocol +select * from t2; +show status like "Qcache_queries_in_cache"; +show status like "Qcache_inserts"; +show status like "Qcache_hits"; + + +# Connect server2, load table in to cache, then update the table +connection server2; +echo == Connected to server2 ==; +show status like "Qcache_queries_in_cache"; +show status like "Qcache_inserts"; +show status like "Qcache_hits"; +select * from t1; +show status like "Qcache_queries_in_cache"; +show status like "Qcache_inserts"; +show status like "Qcache_hits"; +update t1 set a=3 where a=2; + +# Connect to server1 and check that cache is invalidated +# and correct data is returned +connection server1; +echo == Connected to server1 ==; + +# Loop and wait for max 10 seconds until query cache thread +# has invalidated the cache and the column a in t1 is equal to 3 +let $retries=20; +while (`select a != 3 from t1`) +{ + dec $retries; + if (!$retries) + { + The query_cache thread failed to invalidate query_cache in 10 seconds; + } + sleep 0.5; +} + +# Select from t1 one last time for the result file +# Column a should be 3 +select * from t1; + +# There should now be three queries in the cache +show status like "Qcache_queries_in_cache"; + +drop table t1, t2; + +# Turn off and reset query cache on server1 and server2 +connection server1; +set GLOBAL query_cache_size=0; +set GLOBAL ndb_cache_check_time=0; +reset query cache; +flush status; +connection server2; +set GLOBAL query_cache_size=0; +set GLOBAL ndb_cache_check_time=0; +reset query cache; +flush status; + +# (*) Why we need to execute the query in non-ps mode. +# The principle of this test is: two mysqlds connected to one cluster, +# both using their query cache. Queries are cached in server1 +# ("select a!=3 from t1", "select * from t1"), +# table t1 is modified in server2, we want to see that this invalidates +# the query cache of server1. Invalidation with NDB works like this: +# when a query is found in the query cache, NDB is asked if the tables +# have changed. In this test, ha_ndbcluster calls NDB every millisecond +# to collect change information about tables. +# Due to this millisecond delay, there is need for a loop ("while...") +# in this test, which waits until a query1 ("select a!=3 from t1") is +# invalidated (which is equivalent to it returning +# up-to-date results), and then expects query2 ("select * from t1") +# to have been invalidated (see up-to-date results). +# But when enabling --ps-protocol in this test, the logic breaks, +# because query1 is still done via mysql_real_query() (see mysqltest.c: +# eval_expr() always uses mysql_real_query()). So, query1 returning +# up-to-date results is not a sign of it being invalidated in the cache, +# because it was NOT in the cache ("select a!=3 from t1" on line 39 +# was done with prep stmts, while `select a!=3 from t1` is not, +# thus the second does not see the first in the cache). Thus, we may run +# query2 when cache still has not been invalidated. +# The solution is to make the initial "select a!=3 from t1" run +# as a normal query, this repairs the broken logic. +# But note, "select * from t1" is still using prepared statements +# which was the goal of this test with --ps-protocol. diff --git a/mysql-test/suite/ndb/t/ndb_charset.test b/mysql-test/suite/ndb/t/ndb_charset.test new file mode 100644 index 00000000000..2d9f66564bc --- /dev/null +++ b/mysql-test/suite/ndb/t/ndb_charset.test @@ -0,0 +1,257 @@ +--source include/have_ndb.inc +-- source include/not_embedded.inc + +--disable_warnings +drop table if exists t1; +--enable_warnings + +# +# Minimal NDB charset test. +# + +# pk - binary + +create table t1 ( + a char(3) character set latin1 collate latin1_bin primary key +) engine=ndb; +# ok +insert into t1 values('aAa'); +insert into t1 values('aaa'); +insert into t1 values('AAA'); +# 3 +select * from t1 order by a; +# 1 +select * from t1 where a = 'aAa'; +# 1 +select * from t1 where a = 'aaa'; +# 0 +select * from t1 where a = 'AaA'; +# 1 +select * from t1 where a = 'AAA'; +drop table t1; + +# pk - case insensitive + +create table t1 ( + a char(3) character set latin1 collate latin1_swedish_ci primary key +) engine=ndb; +# ok +insert into t1 values('aAa'); +# fail +--error ER_DUP_ENTRY +insert into t1 values('aaa'); +--error ER_DUP_ENTRY +insert into t1 values('AAA'); +# 1 +select * from t1 order by a; +# 1 +select * from t1 where a = 'aAa'; +# 1 +select * from t1 where a = 'aaa'; +# 1 +select * from t1 where a = 'AaA'; +# 1 +select * from t1 where a = 'AAA'; +drop table t1; + +# pk - varchar + +create table t1 ( + a varchar(20) character set latin1 collate latin1_swedish_ci primary key +) engine=ndb; +# +insert into t1 values ('A'),('b '),('C '),('d '),('E'),('f'); +-- error ER_DUP_ENTRY +insert into t1 values('b'); +-- error ER_DUP_ENTRY +insert into t1 values('a '); +# +select a,length(a) from t1 order by a; +select a,length(a) from t1 order by a desc; +select * from t1 where a = 'a'; +select * from t1 where a = 'a '; +select * from t1 where a = 'd'; +drop table t1; + +# unique hash index - binary + +create table t1 ( + p int primary key, + a char(3) character set latin1 collate latin1_bin not null, + unique key(a) +) engine=ndb; +# ok +insert into t1 values(1, 'aAa'); +insert into t1 values(2, 'aaa'); +insert into t1 values(3, 'AAA'); +# 3 +select * from t1 order by p; +# 1 +select * from t1 where a = 'aAa'; +# 1 +select * from t1 where a = 'aaa'; +# 0 +select * from t1 where a = 'AaA'; +# 1 +select * from t1 where a = 'AAA'; +drop table t1; + +# unique hash index - case insensitive + +create table t1 ( + p int primary key, + a char(3) character set latin1 collate latin1_swedish_ci not null, + unique key(a) +) engine=ndb; +# ok +insert into t1 values(1, 'aAa'); +# fail +--error ER_DUP_ENTRY +insert into t1 values(2, 'aaa'); +--error ER_DUP_ENTRY +insert into t1 values(3, 'AAA'); +# 1 +select * from t1 order by p; +# 1 +select * from t1 where a = 'aAa'; +# 1 +select * from t1 where a = 'aaa'; +# 1 +select * from t1 where a = 'AaA'; +# 1 +select * from t1 where a = 'AAA'; +drop table t1; + +# unique hash index - varchar + +create table t1 ( + p int primary key, + a varchar(20) character set latin1 collate latin1_swedish_ci not null, + unique key(a) +) engine=ndb; +# +insert into t1 values (1,'A'),(2,'b '),(3,'C '),(4,'d '),(5,'E'),(6,'f'); +-- error ER_DUP_ENTRY +insert into t1 values(99,'b'); +-- error ER_DUP_ENTRY +insert into t1 values(99,'a '); +# +select a,length(a) from t1 order by a; +select a,length(a) from t1 order by a desc; +select * from t1 where a = 'a'; +select * from t1 where a = 'a '; +select * from t1 where a = 'd'; +drop table t1; + +# ordered index - binary + +create table t1 ( + p int primary key, + a char(3) character set latin1 collate latin1_bin not null, + index(a) +) engine=ndb; +# ok +insert into t1 values(1, 'aAa'); +insert into t1 values(2, 'aaa'); +insert into t1 values(3, 'AAA'); +insert into t1 values(4, 'aAa'); +insert into t1 values(5, 'aaa'); +insert into t1 values(6, 'AAA'); +# 6 +select * from t1 order by p; +# plan too flaky +#--replace_column 9 # +#explain select * from t1 where a = 'zZz' order by p; +# 2 +select * from t1 where a = 'aAa' order by p; +# 2 +select * from t1 where a = 'aaa' order by p; +# 0 +select * from t1 where a = 'AaA' order by p; +# 2 +select * from t1 where a = 'AAA' order by p; +drop table t1; + +# ordered index - case insensitive + +create table t1 ( + p int primary key, + a char(3) character set latin1 collate latin1_swedish_ci not null, + index(a) +) engine=ndb; +# ok +insert into t1 values(1, 'aAa'); +insert into t1 values(2, 'aaa'); +insert into t1 values(3, 'AAA'); +insert into t1 values(4, 'aAa'); +insert into t1 values(5, 'aaa'); +insert into t1 values(6, 'AAA'); +# 6 +select * from t1 order by p; +# plan too flaky +#--replace_column 9 # +#explain select * from t1 where a = 'zZz' order by p; +# 6 +select * from t1 where a = 'aAa' order by p; +# 6 +select * from t1 where a = 'aaa' order by p; +# 6 +select * from t1 where a = 'AaA' order by p; +# 6 +select * from t1 where a = 'AAA' order by p; +drop table t1; + +# ordered index - varchar + +create table t1 ( + p int primary key, + a varchar(20) character set latin1 collate latin1_swedish_ci not null, + index(a, p) +) engine=ndb; +# +insert into t1 values (1,'A'),(2,'b '),(3,'C '),(4,'d '),(5,'E'),(6,'f'); +insert into t1 values (7,'a'),(8,'B '),(9,'c '),(10,'D'),(11,'e'),(12,'F '); +select p,a,length(a) from t1 order by a, p; +select * from t1 where a = 'a ' order by a desc, p desc; +select * from t1 where a >= 'D' order by a, p; +select * from t1 where a < 'D' order by a, p; +# +select count(*) from t1 x, t1 y, t1 z where x.a = y.a and y.a = z.a; +drop table t1; + +# minimal multi-byte test +# removed by jonas as this requires a configure --with-extra-charsets +#create table t1 ( +# a char(5) character set ucs2, +# b varchar(7) character set utf8, +# primary key(a, b) +#) engine=ndb; +# +#insert into t1 values +# ('a','A '),('B ','b'),('c','C '),('D','d'),('e ','E'),('F','f '), +# ('A','b '),('b ','C'),('C','d '),('d','E'),('E ','f'), +# ('a','C '),('B ','d'),('c','E '),('D','f'); +#-- error ER_DUP_ENTRY +#insert into t1 values('d','f'); +# +#select a,b,length(a),length(b) from t1 order by a,b limit 3; +#select a,b,length(a),length(b) from t1 order by a desc, b desc limit 3; +#select a,b,length(a),length(b) from t1 where a='c' and b='c'; +#drop table t1; + +# bug#14007 +create table t1 ( + a char(10) primary key +) engine=ndbcluster default charset=latin1; + +insert into t1 values ('aaabb'); +select * from t1; +replace into t1 set a = 'AAABB'; +select * from t1; +replace into t1 set a = 'aAaBb'; +select * from t1; +replace into t1 set a = 'aaabb'; +select * from t1; +drop table t1; + +# End of 4.1 tests diff --git a/mysql-test/suite/ndb/t/ndb_condition_pushdown.test b/mysql-test/suite/ndb/t/ndb_condition_pushdown.test new file mode 100644 index 00000000000..ab56430ac1d --- /dev/null +++ b/mysql-test/suite/ndb/t/ndb_condition_pushdown.test @@ -0,0 +1,1756 @@ +-- source include/have_ndb.inc +-- source include/not_embedded.inc + +--disable_warnings +DROP TABLE IF EXISTS t1,t2,t3,t4; +--enable_warnings + +# +# Test of condition pushdown to storage engine +# +CREATE TABLE t1 ( + auto int(5) unsigned NOT NULL auto_increment, + string char(10), + vstring varchar(10), + bin binary(2), + vbin varbinary(7), + tiny tinyint(4) DEFAULT '0' NOT NULL , + short smallint(6) DEFAULT '1' NOT NULL , + medium mediumint(8) DEFAULT '0' NOT NULL, + long_int int(11) DEFAULT '0' NOT NULL, + longlong bigint(13) DEFAULT '0' NOT NULL, + real_float float(13,1) DEFAULT 0.0 NOT NULL, + real_double double(16,4), + real_decimal decimal(16,4), + utiny tinyint(3) unsigned DEFAULT '0' NOT NULL, + ushort smallint(5) unsigned zerofill DEFAULT '00000' NOT NULL, + umedium mediumint(8) unsigned DEFAULT '0' NOT NULL, + ulong int(11) unsigned DEFAULT '0' NOT NULL, + ulonglong bigint(13) unsigned DEFAULT '0' NOT NULL, + bits bit(3), + options enum('zero','one','two','three','four') not null, + flags set('zero','one','two','three','four') not null, + date_field date, + year_field year, + time_field time, + date_time datetime, + time_stamp timestamp, + PRIMARY KEY (auto) +) engine=ndb; + +insert into t1 values +(NULL,"aaaa","aaaa",0xAAAA,0xAAAA,-1,-1,-1,-1,-1,1.1,1.1,1.1,1,1,1,1,1, + b'001','one','one', + '1901-01-01','1901', +'01:01:01','1901-01-01 01:01:01',NULL), +(NULL,"bbbb","bbbb",0xBBBB,0xBBBB,-2,-2,-2,-2,-2,2.2,2.2,2.2,2,2,2,2,2, + b'010','two','one,two', + '1902-02-02','1902', +'02:02:02','1902-02-02 02:02:02',NULL), +(NULL,"cccc","cccc",0xCCCC,0xCCCC,-3,-3,-3,-3,-3,3.3,3.3,3.3,3,3,3,3,3, + b'011','three','one,two,three', + '1903-03-03','1903', +'03:03:03','1903-03-03 03:03:03',NULL), +(NULL,"dddd","dddd",0xDDDD,0xDDDD,-4,-4,-4,-4,-4,4.4,4.4,4.4,4,4,4,4,4, + b'100','four','one,two,three,four', + '1904-04-04','1904', +'04:04:04','1904-04-04 04:04:04',NULL); + +CREATE TABLE t2 (pk1 int unsigned NOT NULL PRIMARY KEY, attr1 int unsigned NOT NULL, attr2 int unsigned, attr3 VARCHAR(10) ) ENGINE=ndbcluster; + +insert into t2 values (0,0,0, "a"),(1,1,1,"b"),(2,2,NULL,NULL),(3,3,3,"d"),(4,4,4,"e"),(5,5,5,"f"); + +CREATE TABLE t3 (pk1 int unsigned NOT NULL PRIMARY KEY, attr1 int unsigned NOT NULL, attr2 bigint unsigned, attr3 tinyint unsigned, attr4 VARCHAR(10) ) ENGINE=ndbcluster; + +insert into t3 values (0,0,0,0,"a"),(1,1,9223372036854775803,1,"b"),(2,2,9223372036854775804,2,"c"),(3,3,9223372036854775805,3,"d"),(4,4,9223372036854775806,4,"e"),(5,5,9223372036854775807,5,"f"); + +CREATE TABLE t4 (pk1 int unsigned NOT NULL PRIMARY KEY, attr1 int unsigned NOT NULL, attr2 bigint unsigned, attr3 tinyint unsigned, attr4 VARCHAR(10) , KEY (attr1)) ENGINE=ndbcluster; + +insert into t4 values (0,0,0,0,"a"),(1,1,9223372036854775803,1,"b"),(2,2,9223372036854775804,2,"c"),(3,3,9223372036854775805,3,"d"),(4,4,9223372036854775806,4,"e"),(5,5,9223372036854775807,5,"f"); + +set @old_ecpd = @@session.engine_condition_pushdown; +set engine_condition_pushdown = off; + +# Test all types and compare operators +select auto from t1 where +string = "aaaa" and +vstring = "aaaa" and +bin = 0xAAAA and +vbin = 0xAAAA and +tiny = -1 and +short = -1 and +medium = -1 and +long_int = -1 and +longlong = -1 and +real_float > 1.0 and real_float < 2.0 and +real_double > 1.0 and real_double < 2.0 and +real_decimal > 1.0 and real_decimal < 2.0 and +utiny = 1 and +ushort = 1 and +umedium = 1 and +ulong = 1 and +ulonglong = 1 and +bits = b'001' and +options = 'one' and +flags = 'one' and +date_field = '1901-01-01' and +year_field = '1901' and +time_field = '01:01:01' and +date_time = '1901-01-01 01:01:01' +order by auto; + +select auto from t1 where +string != "aaaa" and +vstring != "aaaa" and +bin != 0xAAAA and +vbin != 0xAAAA and +tiny != -1 and +short != -1 and +medium != -1 and +long_int != -1 and +longlong != -1 and +(real_float < 1.0 or real_float > 2.0) and +(real_double < 1.0 or real_double > 2.0) and +(real_decimal < 1.0 or real_decimal > 2.0) and +utiny != 1 and +ushort != 1 and +umedium != 1 and +ulong != 1 and +ulonglong != 1 and +bits != b'001' and +options != 'one' and +flags != 'one' and +date_field != '1901-01-01' and +year_field != '1901' and +time_field != '01:01:01' and +date_time != '1901-01-01 01:01:01' +order by auto; + +select auto from t1 where +string > "aaaa" and +vstring > "aaaa" and +bin > 0xAAAA and +vbin > 0xAAAA and +tiny < -1 and +short < -1 and +medium < -1 and +long_int < -1 and +longlong < -1 and +real_float > 1.1 and +real_double > 1.1 and +real_decimal > 1.1 and +utiny > 1 and +ushort > 1 and +umedium > 1 and +ulong > 1 and +ulonglong > 1 and +bits > b'001' and +(options = 'two' or options = 'three' or options = 'four') and +(flags = 'one,two' or flags = 'one,two,three' or flags = 'one,two,three,four') and +date_field > '1901-01-01' and +year_field > '1901' and +time_field > '01:01:01' and +date_time > '1901-01-01 01:01:01' +order by auto; + +select auto from t1 where +string >= "aaaa" and +vstring >= "aaaa" and +bin >= 0xAAAA and +vbin >= 0xAAAA and +tiny <= -1 and +short <= -1 and +medium <= -1 and +long_int <= -1 and +longlong <= -1 and +real_float >= 1.0 and +real_double >= 1.0 and +real_decimal >= 1.0 and +utiny >= 1 and +ushort >= 1 and +umedium >= 1 and +ulong >= 1 and +ulonglong >= 1 and +bits >= b'001' and +(options = 'one' or options = 'two' or options = 'three' or options = 'four') and +(flags = 'one' or flags = 'one,two' or flags = 'one,two,three' or flags = 'one,two,three,four') and +date_field >= '1901-01-01' and +year_field >= '1901' and +time_field >= '01:01:01' and +date_time >= '1901-01-01 01:01:01' +order by auto; + +select auto from t1 where +string < "dddd" and +vstring < "dddd" and +bin < 0xDDDD and +vbin < 0xDDDD and +tiny > -4 and +short > -4 and +medium > -4 and +long_int > -4 and +longlong > -4 and +real_float < 4.4 and +real_double < 4.4 and +real_decimal < 4.4 and +utiny < 4 and +ushort < 4 and +umedium < 4 and +ulong < 4 and +ulonglong < 4 and +bits < b'100' and +(options = 'one' or options = 'two' or options = 'three') and +(flags = 'one' or flags = 'one,two' or flags = 'one,two,three') and +date_field < '1904-01-01' and +year_field < '1904' and +time_field < '04:04:04' and +date_time < '1904-04-04 04:04:04' +order by auto; + +select auto from t1 where +string <= "dddd" and +vstring <= "dddd" and +bin <= 0xDDDD and +vbin <= 0xDDDD and +tiny >= -4 and +short >= -4 and +medium >= -4 and +long_int >= -4 and +longlong >= -4 and +real_float <= 4.5 and +real_double <= 4.5 and +real_decimal <= 4.5 and +utiny <= 4 and +ushort <= 4 and +umedium <= 4 and +ulong <= 4 and +ulonglong <= 4 and +bits <= b'100' and +(options = 'one' or options = 'two' or options = 'three' or options = 'four') and +(flags = 'one' or flags = 'one,two' or flags = 'one,two,three' or flags = 'one,two,three,four') and +date_field <= '1904-04-04' and +year_field <= '1904' and +time_field <= '04:04:04' and +date_time <= '1904-04-04 04:04:04' +order by auto; + +# Test LIKE/NOT LIKE +select auto from t1 where +string like "b%" and +vstring like "b%" and +bin like concat(0xBB, '%') and +vbin like concat(0xBB, '%') +order by auto; + +select auto from t1 where +string not like "b%" and +vstring not like "b%" and +bin not like concat(0xBB, '%') and +vbin not like concat(0xBB, '%') +order by auto; + +# BETWEEN +select auto from t1 where +(string between "aaaa" and "cccc") and +(vstring between "aaaa" and "cccc") and +(bin between 0xAAAA and 0xCCCC) and +(vbin between 0xAAAA and 0xCCCC) and +(tiny between -3 and -1) and +(short between -3 and -1) and +(medium between -3 and -1) and +(long_int between -3 and -1) and +(longlong between -3 and -1) and +(utiny between 1 and 3) and +(ushort between 1 and 3) and +(umedium between 1 and 3) and +(ulong between 1 and 3) and +(ulonglong between 1 and 3) and +(bits between b'001' and b'011') and +(options between 'one' and 'three') and +(flags between 'one' and 'one,two,three') and +(date_field between '1901-01-01' and '1903-03-03') and +(year_field between '1901' and '1903') and +(time_field between '01:01:01' and '03:03:03') and +(date_time between '1901-01-01 01:01:01' and '1903-03-03 03:03:03') +order by auto; + +select auto from t1 where +("aaaa" between string and string) and +("aaaa" between vstring and vstring) and +(0xAAAA between bin and bin) and +(0xAAAA between vbin and vbin) and +(-1 between tiny and tiny) and +(-1 between short and short) and +(-1 between medium and medium) and +(-1 between long_int and long_int) and +(-1 between longlong and longlong) and +(1 between utiny and utiny) and +(1 between ushort and ushort) and +(1 between umedium and umedium) and +(1 between ulong and ulong) and +(1 between ulonglong and ulonglong) and +(b'001' between bits and bits) and +('one' between options and options) and +('one' between flags and flags) and +('1901-01-01' between date_field and date_field) and +('1901' between year_field and year_field) and +('01:01:01' between time_field and time_field) and +('1901-01-01 01:01:01' between date_time and date_time) +order by auto; + +# NOT BETWEEN +select auto from t1 where +(string not between "aaaa" and "cccc") and +(vstring not between "aaaa" and "cccc") and +(bin not between 0xAAAA and 0xCCCC) and +(vbin not between 0xAAAA and 0xCCCC) and +(tiny not between -3 and -1) and +(short not between -3 and -1) and +(medium not between -3 and -1) and +(long_int not between -3 and -1) and +(longlong not between -3 and -1) and +(utiny not between 1 and 3) and +(ushort not between 1 and 3) and +(umedium not between 1 and 3) and +(ulong not between 1 and 3) and +(ulonglong not between 1 and 3) and +(bits not between b'001' and b'011') and +(options not between 'one' and 'three') and +(flags not between 'one' and 'one,two,three') and +(date_field not between '1901-01-01' and '1903-03-03') and +(year_field not between '1901' and '1903') and +(time_field not between '01:01:01' and '03:03:03') and +(date_time not between '1901-01-01 01:01:01' and '1903-03-03 03:03:03') +order by auto; + +select auto from t1 where +("aaaa" not between string and string) and +("aaaa" not between vstring and vstring) and +(0xAAAA not between bin and bin) and +(0xAAAA not between vbin and vbin) and +(-1 not between tiny and tiny) and +(-1 not between short and short) and +(-1 not between medium and medium) and +(-1 not between long_int and long_int) and +(-1 not between longlong and longlong) and +(1 not between utiny and utiny) and +(1 not between ushort and ushort) and +(1 not between umedium and umedium) and +(1 not between ulong and ulong) and +(1 not between ulonglong and ulonglong) and +(b'001' not between bits and bits) and +('one' not between options and options) and +('one' not between flags and flags) and +('1901-01-01' not between date_field and date_field) and +('1901' not between year_field and year_field) and +('01:01:01' not between time_field and time_field) and +('1901-01-01 01:01:01' not between date_time and date_time) +order by auto; + +# IN +select auto from t1 where +string in("aaaa","cccc") and +vstring in("aaaa","cccc") and +bin in(0xAAAA,0xCCCC) and +vbin in(0xAAAA,0xCCCC) and +tiny in(-1,-3) and +short in(-1,-3) and +medium in(-1,-3) and +long_int in(-1,-3) and +longlong in(-1,-3) and +utiny in(1,3) and +ushort in(1,3) and +umedium in(1,3) and +ulong in(1,3) and +ulonglong in(1,3) and +bits in(b'001',b'011') and +options in('one','three') and +flags in('one','one,two,three') and +date_field in('1901-01-01','1903-03-03') and +year_field in('1901','1903') and +time_field in('01:01:01','03:03:03') and +date_time in('1901-01-01 01:01:01','1903-03-03 03:03:03') +order by auto; + +select auto from t1 where +"aaaa" in(string) and +"aaaa" in(vstring) and +0xAAAA in(bin) and +0xAAAA in(vbin) and +(-1 in(tiny)) and +(-1 in(short)) and +(-1 in(medium)) and +(-1 in(long_int)) and +(-1 in(longlong)) and +1 in(utiny) and +1 in(ushort) and +1 in(umedium) and +1 in(ulong) and +1 in(ulonglong) and +b'001' in(bits) and +'one' in(options) and +'one' in(flags) and +'1901-01-01' in(date_field) and +'1901' in(year_field) and +'01:01:01' in(time_field) and +'1901-01-01 01:01:01' in(date_time) +order by auto; + +# NOT IN +select auto from t1 where +string not in("aaaa","cccc") and +vstring not in("aaaa","cccc") and +bin not in(0xAAAA,0xCCCC) and +vbin not in(0xAAAA,0xCCCC) and +tiny not in(-1,-3) and +short not in(-1,-3) and +medium not in(-1,-3) and +long_int not in(-1,-3) and +longlong not in(-1,-3) and +utiny not in(1,3) and +ushort not in(1,3) and +umedium not in(1,3) and +ulong not in(1,3) and +ulonglong not in(1,3) and +bits not in(b'001',b'011') and +options not in('one','three') and +flags not in('one','one,two,three') and +date_field not in('1901-01-01','1903-03-03') and +year_field not in('1901','1903') and +time_field not in('01:01:01','03:03:03') and +date_time not in('1901-01-01 01:01:01','1903-03-03 03:03:03') +order by auto; + +select auto from t1 where +"aaaa" not in(string) and +"aaaa" not in(vstring) and +0xAAAA not in(bin) and +0xAAAA not in(vbin) and +(-1 not in(tiny)) and +(-1 not in(short)) and +(-1 not in(medium)) and +(-1 not in(long_int)) and +(-1 not in(longlong)) and +1 not in(utiny) and +1 not in(ushort) and +1 not in(umedium) and +1 not in(ulong) and +1 not in(ulonglong) and +b'001' not in(bits) and +'one' not in(options) and +'one' not in(flags) and +'1901-01-01' not in(date_field) and +'1901' not in(year_field) and +'01:01:01' not in(time_field) and +'1901-01-01 01:01:01' not in(date_time) +order by auto; + +# Various tests +select * from t2 where attr3 is null or attr1 > 2 and pk1= 3 order by pk1; +select * from t2 where attr3 is not null and attr1 > 2 order by pk1; +select * from t3 where attr2 > 9223372036854775803 and attr3 != 3 order by pk1; +select * from t2,t3 where t2.attr1 < 1 and t2.attr2 = t3.attr2 and t3.attr1 < 5 order by t2.pk1; +select * from t4 where attr1 < 5 and attr2 > 9223372036854775803 and attr3 != 3 order by t4.pk1; +select * from t3,t4 where t4.attr1 > 1 and t4.attr2 = t3.attr2 and t4.attr3 < 5 order by t4.pk1; + +set engine_condition_pushdown = on; + +# Test all types and compare operators +--replace_column 9 # +explain +select auto from t1 where +string = "aaaa" and +vstring = "aaaa" and +bin = 0xAAAA and +vbin = 0xAAAA and +tiny = -1 and +short = -1 and +medium = -1 and +long_int = -1 and +longlong = -1 and +real_float > 1.0 and real_float < 2.0 and +real_double > 1.0 and real_double < 2.0 and +real_decimal > 1.0 and real_decimal < 2.0 and +utiny = 1 and +ushort = 1 and +umedium = 1 and +ulong = 1 and +ulonglong = 1 and +/* bits = b'001' and */ +options = 'one' and +flags = 'one' and +date_field = '1901-01-01' and +year_field = '1901' and +time_field = '01:01:01' and +date_time = '1901-01-01 01:01:01' +order by auto; + +select auto from t1 where +string = "aaaa" and +vstring = "aaaa" and +bin = 0xAAAA and +vbin = 0xAAAA and +tiny = -1 and +short = -1 and +medium = -1 and +long_int = -1 and +longlong = -1 and +real_float > 1.0 and real_float < 2.0 and +real_double > 1.0 and real_double < 2.0 and +real_decimal > 1.0 and real_decimal < 2.0 and +utiny = 1 and +ushort = 1 and +umedium = 1 and +ulong = 1 and +ulonglong = 1 and +/* bits = b'001' and */ +options = 'one' and +flags = 'one' and +date_field = '1901-01-01' and +year_field = '1901' and +time_field = '01:01:01' and +date_time = '1901-01-01 01:01:01' +order by auto; + +--replace_column 9 # +explain +select auto from t1 where +string != "aaaa" and +vstring != "aaaa" and +bin != 0xAAAA and +vbin != 0xAAAA and +tiny != -1 and +short != -1 and +medium != -1 and +long_int != -1 and +longlong != -1 and +(real_float < 1.0 or real_float > 2.0) and +(real_double < 1.0 or real_double > 2.0) and +(real_decimal < 1.0 or real_decimal > 2.0) and +utiny != 1 and +ushort != 1 and +umedium != 1 and +ulong != 1 and +ulonglong != 1 and +/* bits != b'001' and */ +options != 'one' and +flags != 'one' and +date_field != '1901-01-01' and +year_field != '1901' and +time_field != '01:01:01' and +date_time != '1901-01-01 01:01:01' +order by auto; + +select auto from t1 where +string != "aaaa" and +vstring != "aaaa" and +bin != 0xAAAA and +vbin != 0xAAAA and +tiny != -1 and +short != -1 and +medium != -1 and +long_int != -1 and +longlong != -1 and +(real_float < 1.0 or real_float > 2.0) and +(real_double < 1.0 or real_double > 2.0) and +(real_decimal < 1.0 or real_decimal > 2.0) and +utiny != 1 and +ushort != 1 and +umedium != 1 and +ulong != 1 and +ulonglong != 1 and +/* bits != b'001' and */ +options != 'one' and +flags != 'one' and +date_field != '1901-01-01' and +year_field != '1901' and +time_field != '01:01:01' and +date_time != '1901-01-01 01:01:01' +order by auto; + +--replace_column 9 # +explain +select auto from t1 where +string > "aaaa" and +vstring > "aaaa" and +bin > 0xAAAA and +vbin > 0xAAAA and +tiny < -1 and +short < -1 and +medium < -1 and +long_int < -1 and +longlong < -1 and +real_float > 1.1 and +real_double > 1.1 and +real_decimal > 1.1 and +utiny > 1 and +ushort > 1 and +umedium > 1 and +ulong > 1 and +ulonglong > 1 and +/* bits > b'001' and */ +(options = 'two' or options = 'three' or options = 'four') and +(flags = 'one,two' or flags = 'one,two,three' or flags = 'one,two,three,four') and +date_field > '1901-01-01' and +year_field > '1901' and +time_field > '01:01:01' and +date_time > '1901-01-01 01:01:01' +order by auto; + +select auto from t1 where +string > "aaaa" and +vstring > "aaaa" and +bin > 0xAAAA and +vbin > 0xAAAA and +tiny < -1 and +short < -1 and +medium < -1 and +long_int < -1 and +longlong < -1 and +real_float > 1.1 and +real_double > 1.1 and +real_decimal > 1.1 and +utiny > 1 and +ushort > 1 and +umedium > 1 and +ulong > 1 and +ulonglong > 1 and +/* bits > b'001' and */ +(options = 'two' or options = 'three' or options = 'four') and +(flags = 'one,two' or flags = 'one,two,three' or flags = 'one,two,three,four') and +date_field > '1901-01-01' and +year_field > '1901' and +time_field > '01:01:01' and +date_time > '1901-01-01 01:01:01' +order by auto; + +--replace_column 9 # +explain +select auto from t1 where +string >= "aaaa" and +vstring >= "aaaa" and +bin >= 0xAAAA and +vbin >= 0xAAAA and +tiny <= -1 and +short <= -1 and +medium <= -1 and +long_int <= -1 and +longlong <= -1 and +real_float >= 1.0 and +real_double >= 1.0 and +real_decimal >= 1.0 and +utiny >= 1 and +ushort >= 1 and +umedium >= 1 and +ulong >= 1 and +ulonglong >= 1 and +/* bits >= b'001' and */ +(options = 'one' or options = 'two' or options = 'three' or options = 'four') and +(flags = 'one' or flags = 'one,two' or flags = 'one,two,three' or flags = 'one,two,three,four') and +date_field >= '1901-01-01' and +year_field >= '1901' and +time_field >= '01:01:01' and +date_time >= '1901-01-01 01:01:01' +order by auto; + +select auto from t1 where +string >= "aaaa" and +vstring >= "aaaa" and +bin >= 0xAAAA and +vbin >= 0xAAAA and +tiny <= -1 and +short <= -1 and +medium <= -1 and +long_int <= -1 and +longlong <= -1 and +real_float >= 1.0 and +real_double >= 1.0 and +real_decimal >= 1.0 and +utiny >= 1 and +ushort >= 1 and +umedium >= 1 and +ulong >= 1 and +ulonglong >= 1 and +/* bits >= b'001' and */ +(options = 'one' or options = 'two' or options = 'three' or options = 'four') and +(flags = 'one' or flags = 'one,two' or flags = 'one,two,three' or flags = 'one,two,three,four') and +date_field >= '1901-01-01' and +year_field >= '1901' and +time_field >= '01:01:01' and +date_time >= '1901-01-01 01:01:01' +order by auto; + +--replace_column 9 # +explain +select auto from t1 where +string < "dddd" and +vstring < "dddd" and +bin < 0xDDDD and +vbin < 0xDDDD and +tiny > -4 and +short > -4 and +medium > -4 and +long_int > -4 and +longlong > -4 and +real_float < 4.4 and +real_double < 4.4 and +real_decimal < 4.4 and +utiny < 4 and +ushort < 4 and +umedium < 4 and +ulong < 4 and +ulonglong < 4 and +/* bits < b'100' and */ +(options = 'one' or options = 'two' or options = 'three') and +(flags = 'one' or flags = 'one,two' or flags = 'one,two,three') and +date_field < '1904-01-01' and +year_field < '1904' and +time_field < '04:04:04' and +date_time < '1904-04-04 04:04:04' +order by auto; + +select auto from t1 where +string < "dddd" and +vstring < "dddd" and +bin < 0xDDDD and +vbin < 0xDDDD and +tiny > -4 and +short > -4 and +medium > -4 and +long_int > -4 and +longlong > -4 and +real_float < 4.4 and +real_double < 4.4 and +real_decimal < 4.4 and +utiny < 4 and +ushort < 4 and +umedium < 4 and +ulong < 4 and +ulonglong < 4 and +/* bits < b'100' and */ +(options = 'one' or options = 'two' or options = 'three') and +(flags = 'one' or flags = 'one,two' or flags = 'one,two,three') and +date_field < '1904-01-01' and +year_field < '1904' and +time_field < '04:04:04' and +date_time < '1904-04-04 04:04:04' +order by auto; + +--replace_column 9 # +explain +select auto from t1 where +string <= "dddd" and +vstring <= "dddd" and +bin <= 0xDDDD and +vbin <= 0xDDDD and +tiny >= -4 and +short >= -4 and +medium >= -4 and +long_int >= -4 and +longlong >= -4 and +real_float <= 4.5 and +real_double <= 4.5 and +real_decimal <= 4.5 and +utiny <= 4 - 1 + 1 and /* Checking function composition */ +ushort <= 4 and +umedium <= 4 and +ulong <= 4 and +ulonglong <= 4 and +/* bits <= b'100' and */ +(options = 'one' or options = 'two' or options = 'three' or options = 'four') and +(flags = 'one' or flags = 'one,two' or flags = 'one,two,three' or flags = 'one,two,three,four') and +date_field <= '1904-04-04' and +year_field <= '1904' and +time_field <= '04:04:04' and +date_time <= '1904-04-04 04:04:04' +order by auto; + +select auto from t1 where +string <= "dddd" and +vstring <= "dddd" and +bin <= 0xDDDD and +vbin <= 0xDDDD and +tiny >= -4 and +short >= -4 and +medium >= -4 and +long_int >= -4 and +longlong >= -4 and +real_float <= 4.5 and +real_double <= 4.5 and +real_decimal <= 4.5 and +utiny <= 4 - 1 + 1 and /* Checking function composition */ +ushort <= 4 and +umedium <= 4 and +ulong <= 4 and +ulonglong <= 4 and +/* bits <= b'100' and */ +(options = 'one' or options = 'two' or options = 'three' or options = 'four') and +(flags = 'one' or flags = 'one,two' or flags = 'one,two,three' or flags = 'one,two,three,four') and +date_field <= '1904-04-04' and +year_field <= '1904' and +time_field <= '04:04:04' and +date_time <= '1904-04-04 04:04:04' +order by auto; + +# Test index scan with filter +create index medium_index on t1(medium); + +# Test all types and compare operators +--replace_column 9 # +explain +select auto from t1 where +string = "aaaa" and +vstring = "aaaa" and +bin = 0xAAAA and +vbin = 0xAAAA and +tiny = -1 and +short = -1 and +medium = -1 and +long_int = -1 and +longlong = -1 and +real_float > 1.0 and real_float < 2.0 and +real_double > 1.0 and real_double < 2.0 and +real_decimal > 1.0 and real_decimal < 2.0 and +utiny = 1 and +ushort = 1 and +umedium = 1 and +ulong = 1 and +ulonglong = 1 and +/* bits = b'001' and */ +options = 'one' and +flags = 'one' and +date_field = '1901-01-01' and +year_field = '1901' and +time_field = '01:01:01' and +date_time = '1901-01-01 01:01:01' +order by auto; + +select auto from t1 where +string = "aaaa" and +vstring = "aaaa" and +bin = 0xAAAA and +vbin = 0xAAAA and +tiny = -1 and +short = -1 and +medium = -1 and +long_int = -1 and +longlong = -1 and +real_float > 1.0 and real_float < 2.0 and +real_double > 1.0 and real_double < 2.0 and +real_decimal > 1.0 and real_decimal < 2.0 and +utiny = 1 and +ushort = 1 and +umedium = 1 and +ulong = 1 and +ulonglong = 1 and +/* bits = b'001' and */ +options = 'one' and +flags = 'one' and +date_field = '1901-01-01' and +year_field = '1901' and +time_field = '01:01:01' and +date_time = '1901-01-01 01:01:01' +order by auto; + +--replace_column 9 # +explain +select auto from t1 where +string != "aaaa" and +vstring != "aaaa" and +bin != 0xAAAA and +vbin != 0xAAAA and +tiny != -1 and +short != -1 and +medium != -1 and +long_int != -1 and +longlong != -1 and +(real_float < 1.0 or real_float > 2.0) and +(real_double < 1.0 or real_double > 2.0) and +(real_decimal < 1.0 or real_decimal > 2.0) and +utiny != 1 and +ushort != 1 and +umedium != 1 and +ulong != 1 and +ulonglong != 1 and +/* bits != b'001' and */ +options != 'one' and +flags != 'one' and +date_field != '1901-01-01' and +year_field != '1901' and +time_field != '01:01:01' and +date_time != '1901-01-01 01:01:01' +order by auto; + +select auto from t1 where +string != "aaaa" and +vstring != "aaaa" and +bin != 0xAAAA and +vbin != 0xAAAA and +tiny != -1 and +short != -1 and +medium != -1 and +long_int != -1 and +longlong != -1 and +(real_float < 1.0 or real_float > 2.0) and +(real_double < 1.0 or real_double > 2.0) and +(real_decimal < 1.0 or real_decimal > 2.0) and +utiny != 1 and +ushort != 1 and +umedium != 1 and +ulong != 1 and +ulonglong != 1 and +/* bits != b'001' and */ +options != 'one' and +flags != 'one' and +date_field != '1901-01-01' and +year_field != '1901' and +time_field != '01:01:01' and +date_time != '1901-01-01 01:01:01' +order by auto; + +--replace_column 9 # +explain +select auto from t1 where +string > "aaaa" and +vstring > "aaaa" and +bin > 0xAAAA and +vbin > 0xAAAA and +tiny < -1 and +short < -1 and +medium < -1 and +long_int < -1 and +longlong < -1 and +real_float > 1.1 and +real_double > 1.1 and +real_decimal > 1.1 and +utiny > 1 and +ushort > 1 and +umedium > 1 and +ulong > 1 and +ulonglong > 1 and +/* bits > b'001' and */ +(options = 'two' or options = 'three' or options = 'four') and +(flags = 'one,two' or flags = 'one,two,three' or flags = 'one,two,three,four') and +date_field > '1901-01-01' and +year_field > '1901' and +time_field > '01:01:01' and +date_time > '1901-01-01 01:01:01' +order by auto; + +select auto from t1 where +string > "aaaa" and +vstring > "aaaa" and +bin > 0xAAAA and +vbin > 0xAAAA and +tiny < -1 and +short < -1 and +medium < -1 and +long_int < -1 and +longlong < -1 and +real_float > 1.1 and +real_double > 1.1 and +real_decimal > 1.1 and +utiny > 1 and +ushort > 1 and +umedium > 1 and +ulong > 1 and +ulonglong > 1 and +/* bits > b'001' and */ +(options = 'two' or options = 'three' or options = 'four') and +(flags = 'one,two' or flags = 'one,two,three' or flags = 'one,two,three,four') and +date_field > '1901-01-01' and +year_field > '1901' and +time_field > '01:01:01' and +date_time > '1901-01-01 01:01:01' +order by auto; + +--replace_column 9 # +explain +select auto from t1 where +string >= "aaaa" and +vstring >= "aaaa" and +bin >= 0xAAAA and +vbin >= 0xAAAA and +tiny <= -1 and +short <= -1 and +medium <= -1 and +long_int <= -1 and +longlong <= -1 and +real_float >= 1.0 and +real_double >= 1.0 and +real_decimal >= 1.0 and +utiny >= 1 and +ushort >= 1 and +umedium >= 1 and +ulong >= 1 and +ulonglong >= 1 and +/* bits >= b'001' and */ +(options = 'one' or options = 'two' or options = 'three' or options = 'four') and +(flags = 'one' or flags = 'one,two' or flags = 'one,two,three' or flags = 'one,two,three,four') and +date_field >= '1901-01-01' and +year_field >= '1901' and +time_field >= '01:01:01' and +date_time >= '1901-01-01 01:01:01' +order by auto; + +select auto from t1 where +string >= "aaaa" and +vstring >= "aaaa" and +bin >= 0xAAAA and +vbin >= 0xAAAA and +tiny <= -1 and +short <= -1 and +medium <= -1 and +long_int <= -1 and +longlong <= -1 and +real_float >= 1.0 and +real_double >= 1.0 and +real_decimal >= 1.0 and +utiny >= 1 and +ushort >= 1 and +umedium >= 1 and +ulong >= 1 and +ulonglong >= 1 and +/* bits >= b'001' and */ +(options = 'one' or options = 'two' or options = 'three' or options = 'four') and +(flags = 'one' or flags = 'one,two' or flags = 'one,two,three' or flags = 'one,two,three,four') and +date_field >= '1901-01-01' and +year_field >= '1901' and +time_field >= '01:01:01' and +date_time >= '1901-01-01 01:01:01' +order by auto; + +--replace_column 9 # +explain +select auto from t1 where +string < "dddd" and +vstring < "dddd" and +bin < 0xDDDD and +vbin < 0xDDDD and +tiny > -4 and +short > -4 and +medium > -4 and +long_int > -4 and +longlong > -4 and +real_float < 4.4 and +real_double < 4.4 and +real_decimal < 4.4 and +utiny < 4 and +ushort < 4 and +umedium < 4 and +ulong < 4 and +ulonglong < 4 and +/* bits < b'100' and */ +(options = 'one' or options = 'two' or options = 'three') and +(flags = 'one' or flags = 'one,two' or flags = 'one,two,three') and +date_field < '1904-01-01' and +year_field < '1904' and +time_field < '04:04:04' and +date_time < '1904-04-04 04:04:04' +order by auto; + +select auto from t1 where +string < "dddd" and +vstring < "dddd" and +bin < 0xDDDD and +vbin < 0xDDDD and +tiny > -4 and +short > -4 and +medium > -4 and +long_int > -4 and +longlong > -4 and +real_float < 4.4 and +real_double < 4.4 and +real_decimal < 4.4 and +utiny < 4 and +ushort < 4 and +umedium < 4 and +ulong < 4 and +ulonglong < 4 and +/* bits < b'100' and */ +(options = 'one' or options = 'two' or options = 'three') and +(flags = 'one' or flags = 'one,two' or flags = 'one,two,three') and +date_field < '1904-01-01' and +year_field < '1904' and +time_field < '04:04:04' and +date_time < '1904-04-04 04:04:04' +order by auto; + +--replace_column 9 # +explain +select auto from t1 where +string <= "dddd" and +vstring <= "dddd" and +bin <= 0xDDDD and +vbin <= 0xDDDD and +tiny >= -4 and +short >= -4 and +medium >= -4 and +long_int >= -4 and +longlong >= -4 and +real_float <= 4.5 and +real_double <= 4.5 and +real_decimal <= 4.5 and +utiny <= 4 - 1 + 1 and /* Checking function composition */ +ushort <= 4 and +umedium <= 4 and +ulong <= 4 and +ulonglong <= 4 and +/* bits <= b'100' and */ +(options = 'one' or options = 'two' or options = 'three' or options = 'four') and +(flags = 'one' or flags = 'one,two' or flags = 'one,two,three' or flags = 'one,two,three,four') and +date_field <= '1904-04-04' and +year_field <= '1904' and +time_field <= '04:04:04' and +date_time <= '1904-04-04 04:04:04' +order by auto; + +select auto from t1 where +string <= "dddd" and +vstring <= "dddd" and +bin <= 0xDDDD and +vbin <= 0xDDDD and +tiny >= -4 and +short >= -4 and +medium >= -4 and +long_int >= -4 and +longlong >= -4 and +real_float <= 4.5 and +real_double <= 4.5 and +real_decimal <= 4.5 and +utiny <= 4 - 1 + 1 and /* Checking function composition */ +ushort <= 4 and +umedium <= 4 and +ulong <= 4 and +ulonglong <= 4 and +/* bits <= b'100' and */ +(options = 'one' or options = 'two' or options = 'three' or options = 'four') and +(flags = 'one' or flags = 'one,two' or flags = 'one,two,three' or flags = 'one,two,three,four') and +date_field <= '1904-04-04' and +year_field <= '1904' and +time_field <= '04:04:04' and +date_time <= '1904-04-04 04:04:04' +order by auto; + +# Test LIKE/NOT LIKE +--replace_column 9 # +explain +select auto from t1 where +string like "b%" and +vstring like "b%" and +bin like concat(0xBB, '%') and +vbin like concat(0xBB, '%') +order by auto; + +select auto from t1 where +string like "b%" and +vstring like "b%" and +bin like concat(0xBB, '%') and +vbin like concat(0xBB, '%') +order by auto; + +--replace_column 9 # +explain +select auto from t1 where +string not like "b%" and +vstring not like "b%" and +bin not like concat(0xBB, '%') and +vbin not like concat(0xBB, '%') +order by auto; + +select auto from t1 where +string not like "b%" and +vstring not like "b%" and +bin not like concat(0xBB, '%') and +vbin not like concat(0xBB, '%') +order by auto; + +# BETWEEN +--replace_column 9 # +explain +select auto from t1 where +(string between "aaaa" and "cccc") and +(vstring between "aaaa" and "cccc") and +(bin between 0xAAAA and 0xCCCC) and +(vbin between 0xAAAA and 0xCCCC) and +(tiny between -3 and -1) and +(short between -3 and -1) and +(medium between -3 and -1) and +(long_int between -3 and -1) and +(longlong between -3 and -1) and +(utiny between 1 and 3) and +(ushort between 1 and 3) and +(umedium between 1 and 3) and +(ulong between 1 and 3) and +(ulonglong between 1 and 3) and +/* (bits between b'001' and b'011') and */ +(options between 'one' and 'three') and +(flags between 'one' and 'one,two,three') and +(date_field between '1901-01-01' and '1903-03-03') and +(year_field between '1901' and '1903') and +(time_field between '01:01:01' and '03:03:03') and +(date_time between '1901-01-01 01:01:01' and '1903-03-03 03:03:03') +order by auto; + +select auto from t1 where +(string between "aaaa" and "cccc") and +(vstring between "aaaa" and "cccc") and +(bin between 0xAAAA and 0xCCCC) and +(vbin between 0xAAAA and 0xCCCC) and +(tiny between -3 and -1) and +(short between -3 and -1) and +(medium between -3 and -1) and +(long_int between -3 and -1) and +(longlong between -3 and -1) and +(utiny between 1 and 3) and +(ushort between 1 and 3) and +(umedium between 1 and 3) and +(ulong between 1 and 3) and +(ulonglong between 1 and 3) and +/* (bits between b'001' and b'011') and */ +(options between 'one' and 'three') and +(flags between 'one' and 'one,two,three') and +(date_field between '1901-01-01' and '1903-03-03') and +(year_field between '1901' and '1903') and +(time_field between '01:01:01' and '03:03:03') and +(date_time between '1901-01-01 01:01:01' and '1903-03-03 03:03:03') +order by auto; + +--replace_column 9 # +explain +select auto from t1 where +("aaaa" between string and string) and +("aaaa" between vstring and vstring) and +(0xAAAA between bin and bin) and +(0xAAAA between vbin and vbin) and +(-1 between tiny and tiny) and +(-1 between short and short) and +(-1 between medium and medium) and +(-1 between long_int and long_int) and +(-1 between longlong and longlong) and +(1 between utiny and utiny) and +(1 between ushort and ushort) and +(1 between umedium and umedium) and +(1 between ulong and ulong) and +(1 between ulonglong and ulonglong) and +/* (b'001' between bits and bits) and */ +('one' between options and options) and +('one' between flags and flags) and +('1901-01-01' between date_field and date_field) and +('1901' between year_field and year_field) and +('01:01:01' between time_field and time_field) and +('1901-01-01 01:01:01' between date_time and date_time) +order by auto; + +select auto from t1 where +("aaaa" between string and string) and +("aaaa" between vstring and vstring) and +(0xAAAA between bin and bin) and +(0xAAAA between vbin and vbin) and +(-1 between tiny and tiny) and +(-1 between short and short) and +(-1 between medium and medium) and +(-1 between long_int and long_int) and +(-1 between longlong and longlong) and +(1 between utiny and utiny) and +(1 between ushort and ushort) and +(1 between umedium and umedium) and +(1 between ulong and ulong) and +(1 between ulonglong and ulonglong) and +/* (b'001' between bits and bits) and */ +('one' between options and options) and +('one' between flags and flags) and +('1901-01-01' between date_field and date_field) and +('1901' between year_field and year_field) and +('01:01:01' between time_field and time_field) and +('1901-01-01 01:01:01' between date_time and date_time) +order by auto; + +# NOT BETWEEN +--replace_column 9 # +explain +select auto from t1 where +(string not between "aaaa" and "cccc") and +(vstring not between "aaaa" and "cccc") and +(bin not between 0xAAAA and 0xCCCC) and +(vbin not between 0xAAAA and 0xCCCC) and +(tiny not between -3 and -1) and +(short not between -3 and -1) and +(medium not between -3 and -1) and +(long_int not between -3 and -1) and +(longlong not between -3 and -1) and +(utiny not between 1 and 3) and +(ushort not between 1 and 3) and +(umedium not between 1 and 3) and +(ulong not between 1 and 3) and +(ulonglong not between 1 and 3) and +/* (bits not between b'001' and b'011') and */ +(options not between 'one' and 'three') and +(flags not between 'one' and 'one,two,three') and +(date_field not between '1901-01-01' and '1903-03-03') and +(year_field not between '1901' and '1903') and +(time_field not between '01:01:01' and '03:03:03') and +(date_time not between '1901-01-01 01:01:01' and '1903-03-03 03:03:03') +order by auto; + +select auto from t1 where +(string not between "aaaa" and "cccc") and +(vstring not between "aaaa" and "cccc") and +(bin not between 0xAAAA and 0xCCCC) and +(vbin not between 0xAAAA and 0xCCCC) and +(tiny not between -3 and -1) and +(short not between -3 and -1) and +(medium not between -3 and -1) and +(long_int not between -3 and -1) and +(longlong not between -3 and -1) and +(utiny not between 1 and 3) and +(ushort not between 1 and 3) and +(umedium not between 1 and 3) and +(ulong not between 1 and 3) and +(ulonglong not between 1 and 3) and +/* (bits not between b'001' and b'011') and */ +(options not between 'one' and 'three') and +(flags not between 'one' and 'one,two,three') and +(date_field not between '1901-01-01' and '1903-03-03') and +(year_field not between '1901' and '1903') and +(time_field not between '01:01:01' and '03:03:03') and +(date_time not between '1901-01-01 01:01:01' and '1903-03-03 03:03:03') +order by auto; + +--replace_column 9 # +explain +select auto from t1 where +("aaaa" not between string and string) and +("aaaa" not between vstring and vstring) and +(0xAAAA not between bin and bin) and +(0xAAAA not between vbin and vbin) and +(-1 not between tiny and tiny) and +(-1 not between short and short) and +(-1 not between medium and medium) and +(-1 not between long_int and long_int) and +(-1 not between longlong and longlong) and +(1 not between utiny and utiny) and +(1 not between ushort and ushort) and +(1 not between umedium and umedium) and +(1 not between ulong and ulong) and +(1 not between ulonglong and ulonglong) and +/* (b'001' not between bits and bits) and */ +('one' not between options and options) and +('one' not between flags and flags) and +('1901-01-01' not between date_field and date_field) and +('1901' not between year_field and year_field) and +('01:01:01' not between time_field and time_field) and +('1901-01-01 01:01:01' not between date_time and date_time) +order by auto; + +select auto from t1 where +("aaaa" not between string and string) and +("aaaa" not between vstring and vstring) and +(0xAAAA not between bin and bin) and +(0xAAAA not between vbin and vbin) and +(-1 not between tiny and tiny) and +(-1 not between short and short) and +(-1 not between medium and medium) and +(-1 not between long_int and long_int) and +(-1 not between longlong and longlong) and +(1 not between utiny and utiny) and +(1 not between ushort and ushort) and +(1 not between umedium and umedium) and +(1 not between ulong and ulong) and +(1 not between ulonglong and ulonglong) and +/* (b'001' not between bits and bits) and */ +('one' not between options and options) and +('one' not between flags and flags) and +('1901-01-01' not between date_field and date_field) and +('1901' not between year_field and year_field) and +('01:01:01' not between time_field and time_field) and +('1901-01-01 01:01:01' not between date_time and date_time) +order by auto; + +# IN +--replace_column 9 # +explain +select auto from t1 where +string in("aaaa","cccc") and +vstring in("aaaa","cccc") and +bin in(0xAAAA,0xCCCC) and +vbin in(0xAAAA,0xCCCC) and +tiny in(-1,-3) and +short in(-1,-3) and +medium in(-1,-3) and +long_int in(-1,-3) and +longlong in(-1,-3) and +utiny in(1,3) and +ushort in(1,3) and +umedium in(1,3) and +ulong in(1,3) and +ulonglong in(1,3) and +/* bits in(b'001',b'011') and */ +options in('one','three') and +flags in('one','one,two,three') and +date_field in('1901-01-01','1903-03-03') and +year_field in('1901','1903') and +time_field in('01:01:01','03:03:03') and +date_time in('1901-01-01 01:01:01','1903-03-03 03:03:03') +order by auto; + +select auto from t1 where +string in("aaaa","cccc") and +vstring in("aaaa","cccc") and +bin in(0xAAAA,0xCCCC) and +vbin in(0xAAAA,0xCCCC) and +tiny in(-1,-3) and +short in(-1,-3) and +medium in(-1,-3) and +long_int in(-1,-3) and +longlong in(-1,-3) and +utiny in(1,3) and +ushort in(1,3) and +umedium in(1,3) and +ulong in(1,3) and +ulonglong in(1,3) and +/* bits in(b'001',b'011') and */ +options in('one','three') and +flags in('one','one,two,three') and +date_field in('1901-01-01','1903-03-03') and +year_field in('1901','1903') and +time_field in('01:01:01','03:03:03') and +date_time in('1901-01-01 01:01:01','1903-03-03 03:03:03') +order by auto; + +--replace_column 9 # +explain +select auto from t1 where +"aaaa" in(string) and +"aaaa" in(vstring) and +0xAAAA in(bin) and +0xAAAA in(vbin) and +(-1 in(tiny)) and +(-1 in (short)) and +(-1 in(medium)) and +(-1 in(long_int)) and +(-1 in(longlong)) and +1 in(utiny) and +1 in(ushort) and +1 in(umedium) and +1 in(ulong) and +1 in(ulonglong) and +/* b'001' in(bits) and */ +'one' in(options) and +'one' in(flags) and +'1901-01-01' in(date_field) and +'1901' in(year_field) and +'01:01:01' in(time_field) and +'1901-01-01 01:01:01' in(date_time) +order by auto; + +select auto from t1 where +"aaaa" in(string) and +"aaaa" in(vstring) and +0xAAAA in(bin) and +0xAAAA in(vbin) and +(-1 in(tiny)) and +(-1 in (short)) and +(-1 in(medium)) and +(-1 in(long_int)) and +(-1 in(longlong)) and +1 in(utiny) and +1 in(ushort) and +1 in(umedium) and +1 in(ulong) and +1 in(ulonglong) and +/* b'001' in(bits) and */ +'one' in(options) and +'one' in(flags) and +'1901-01-01' in(date_field) and +'1901' in(year_field) and +'01:01:01' in(time_field) and +'1901-01-01 01:01:01' in(date_time) +order by auto; + +# NOT IN +--replace_column 9 # +explain +select auto from t1 where +string not in("aaaa","cccc") and +vstring not in("aaaa","cccc") and +bin not in(0xAAAA,0xCCCC) and +vbin not in(0xAAAA,0xCCCC) and +tiny not in(-1,-3) and +short not in(-1,-3) and +medium not in(-1,-3) and +long_int not in(-1,-3) and +longlong not in(-1,-3) and +utiny not in(1,3) and +ushort not in(1,3) and +umedium not in(1,3) and +ulong not in(1,3) and +ulonglong not in(1,3) and +/* bits not in(b'001',b'011') and */ +options not in('one','three') and +flags not in('one','one,two,three') and +date_field not in('1901-01-01','1903-03-03') and +year_field not in('1901','1903') and +time_field not in('01:01:01','03:03:03') and +date_time not in('1901-01-01 01:01:01','1903-03-03 03:03:03') +order by auto; + +select auto from t1 where +string not in("aaaa","cccc") and +vstring not in("aaaa","cccc") and +bin not in(0xAAAA,0xCCCC) and +vbin not in(0xAAAA,0xCCCC) and +tiny not in(-1,-3) and +short not in(-1,-3) and +medium not in(-1,-3) and +long_int not in(-1,-3) and +longlong not in(-1,-3) and +utiny not in(1,3) and +ushort not in(1,3) and +umedium not in(1,3) and +ulong not in(1,3) and +ulonglong not in(1,3) and +/* bits not in(b'001',b'011') and */ +options not in('one','three') and +flags not in('one','one,two,three') and +date_field not in('1901-01-01','1903-03-03') and +year_field not in('1901','1903') and +time_field not in('01:01:01','03:03:03') and +date_time not in('1901-01-01 01:01:01','1903-03-03 03:03:03') +order by auto; + +--replace_column 9 # +explain +select auto from t1 where +"aaaa" not in(string) and +"aaaa" not in(vstring) and +0xAAAA not in(bin) and +0xAAAA not in(vbin) and +(-1 not in(tiny)) and +(-1 not in(short)) and +(-1 not in(medium)) and +(-1 not in(long_int)) and +(-1 not in(longlong)) and +1 not in(utiny) and +1 not in(ushort) and +1 not in(umedium) and +1 not in(ulong) and +1 not in(ulonglong) and +/* b'001' not in(bits) and */ +'one' not in(options) and +'one' not in(flags) and +'1901-01-01' not in(date_field) and +'1901' not in(year_field) and +'01:01:01' not in(time_field) and +'1901-01-01 01:01:01' not in(date_time) +order by auto; + +select auto from t1 where +"aaaa" not in(string) and +"aaaa" not in(vstring) and +0xAAAA not in(bin) and +0xAAAA not in(vbin) and +(-1 not in(tiny)) and +(-1 not in(short)) and +(-1 not in(medium)) and +(-1 not in(long_int)) and +(-1 not in(longlong)) and +1 not in(utiny) and +1 not in(ushort) and +1 not in(umedium) and +1 not in(ulong) and +1 not in(ulonglong) and +/* b'001' not in(bits) and */ +'one' not in(options) and +'one' not in(flags) and +'1901-01-01' not in(date_field) and +'1901' not in(year_field) and +'01:01:01' not in(time_field) and +'1901-01-01 01:01:01' not in(date_time) +order by auto; + +# Update test +update t1 +set medium = 17 +where +string = "aaaa" and +vstring = "aaaa" and +bin = 0xAAAA and +vbin = 0xAAAA and +tiny = -1 and +short = -1 and +medium = -1 and +long_int = -1 and +longlong = -1 and +real_float > 1.0 and real_float < 2.0 and +real_double > 1.0 and real_double < 2.0 and +real_decimal > 1.0 and real_decimal < 2.0 and +utiny = 1 and +ushort = 1 and +umedium = 1 and +ulong = 1 and +ulonglong = 1 and +/* bits = b'001' and */ +options = 'one' and +flags = 'one' and +date_field = '1901-01-01' and +year_field = '1901' and +time_field = '01:01:01' and +date_time = '1901-01-01 01:01:01'; + +# Delete test +delete from t1 +where +string = "aaaa" and +vstring = "aaaa" and +bin = 0xAAAA and +vbin = 0xAAAA and +tiny = -1 and +short = -1 and +medium = 17 and +long_int = -1 and +longlong = -1 and +real_float > 1.0 and real_float < 2.0 and +real_double > 1.0 and real_double < 2.0 and +real_decimal > 1.0 and real_decimal < 2.0 and +utiny = 1 and +ushort = 1 and +umedium = 1 and +ulong = 1 and +ulonglong = 1 and +/* bits = b'001' and */ +options = 'one' and +flags = 'one' and +date_field = '1901-01-01' and +year_field = '1901' and +time_field = '01:01:01' and +date_time = '1901-01-01 01:01:01'; + +select count(*) from t1; + +# Various tests +--replace_column 9 # +explain +select * from t2 where attr3 is null or attr1 > 2 and pk1= 3 order by pk1; +select * from t2 where attr3 is null or attr1 > 2 and pk1= 3 order by pk1; + +--replace_column 9 # +explain +select * from t2 where attr3 is not null and attr1 > 2 order by pk1; +select * from t2 where attr3 is not null and attr1 > 2 order by pk1; + +--replace_column 9 # +explain +select * from t3 where attr2 > 9223372036854775803 and attr3 != 3 order by pk1; +select * from t3 where attr2 > 9223372036854775803 and attr3 != 3 order by pk1; + +--replace_column 9 # +explain +select * from t2,t3 where t2.attr1 < 1 and t2.attr2 = t3.attr2 and t3.attr1 < 5 order by t2.pk1; +select * from t2,t3 where t2.attr1 < 1 and t2.attr2 = t3.attr2 and t3.attr1 < 5 order by t2.pk1; + +--replace_column 9 # +explain +select * from t4 where attr1 < 5 and attr2 > 9223372036854775803 and attr3 != 3 order by t4.pk1; +select * from t4 where attr1 < 5 and attr2 > 9223372036854775803 and attr3 != 3 order by t4.pk1; + +--replace_column 9 # +explain +select * from t3,t4 where t4.attr1 > 1 and t4.attr2 = t3.attr2 and t4.attr3 < 5 order by t4.pk1; +select * from t3,t4 where t4.attr1 > 1 and t4.attr2 = t3.attr2 and t4.attr3 < 5 order by t4.pk1; + +# Some tests that are currently not supported and should not push condition +--replace_column 9 # +explain +select auto from t1 where string = "aaaa" collate latin1_general_ci order by auto; +--replace_column 9 # +explain +select * from t2 where (attr1 < 2) = (attr2 < 2) order by pk1; +--replace_column 9 # +explain +select * from t3 left join t4 on t4.attr2 = t3.attr2 where t4.attr1 > 1 and t4.attr3 < 5 or t4.attr1 is null order by t4.pk1; + +# bug#15722 +create table t5 (a int primary key auto_increment, b tinytext not null) +engine = ndb; +insert into t5 (b) values ('jonas'), ('jensing'), ('johan'); +set engine_condition_pushdown = off; +select * from t5 where b like '%jo%' order by a; +set engine_condition_pushdown = on; +--replace_column 9 # +explain select * from t5 where b like '%jo%'; +select * from t5 where b like '%jo%' order by a; + +# bug#21056 ndb pushdown equal/setValue error on datetime +set engine_condition_pushdown = off; +select auto from t1 where date_time like '1902-02-02 %' order by auto; +select auto from t1 where date_time not like '1902-02-02 %' order by auto; +set engine_condition_pushdown = on; +--replace_column 9 # +explain select auto from t1 where date_time like '1902-02-02 %'; +select auto from t1 where date_time like '1902-02-02 %' order by auto; +--replace_column 9 # +explain select auto from t1 where date_time not like '1902-02-02 %'; +select auto from t1 where date_time not like '1902-02-02 %' order by auto; + +# bug#17421 -1 +drop table t1; +create table t1 (a int, b varchar(3), primary key using hash(a)) +engine=ndb; +insert into t1 values (1,'a'), (2,'ab'), (3,'abc'); +# in TUP the constants 'ab' 'abc' were expected in varchar format +# "like" returned error which became "false" +# scan filter negates "or" which exposes the bug +set engine_condition_pushdown = off; +select * from t1 where b like 'ab'; +select * from t1 where b like 'ab' or b like 'ab'; +select * from t1 where b like 'abc'; +select * from t1 where b like 'abc' or b like 'abc'; +set engine_condition_pushdown = on; +select * from t1 where b like 'ab'; +select * from t1 where b like 'ab' or b like 'ab'; +select * from t1 where b like 'abc'; +select * from t1 where b like 'abc' or b like 'abc'; + +# bug#17421 -2 +drop table t1; +create table t1 (a int, b char(3), primary key using hash(a)) +engine=ndb; +insert into t1 values (1,'a'), (2,'ab'), (3,'abc'); +# test that incorrect MySQL behaviour is preserved +# 'ab ' LIKE 'ab' is true in MySQL +set engine_condition_pushdown = off; +select * from t1 where b like 'ab'; +select * from t1 where b like 'ab' or b like 'ab'; +select * from t1 where b like 'abc'; +select * from t1 where b like 'abc' or b like 'abc'; +set engine_condition_pushdown = on; +select * from t1 where b like 'ab'; +select * from t1 where b like 'ab' or b like 'ab'; +select * from t1 where b like 'abc'; +select * from t1 where b like 'abc' or b like 'abc'; + +# bug#20406 (maybe same as bug#17421 -1, not seen on 32-bit x86) +drop table t1; +create table t1 ( fname varchar(255), lname varchar(255) ) +engine=ndbcluster; +insert into t1 values ("Young","Foo"); + +set engine_condition_pushdown = 0; +SELECT fname, lname FROM t1 WHERE (fname like 'Y%') or (lname like 'F%'); +set engine_condition_pushdown = 1; +SELECT fname, lname FROM t1 WHERE (fname like 'Y%') or (lname like 'F%'); + +# make sure optimizer does not do some crazy shortcut +insert into t1 values ("aaa", "aaa"); +insert into t1 values ("bbb", "bbb"); +insert into t1 values ("ccc", "ccc"); +insert into t1 values ("ddd", "ddd"); + +set engine_condition_pushdown = 0; +SELECT fname, lname FROM t1 WHERE (fname like 'Y%') or (lname like 'F%'); +set engine_condition_pushdown = 1; +SELECT fname, lname FROM t1 WHERE (fname like 'Y%') or (lname like 'F%'); + +set engine_condition_pushdown = @old_ecpd; +DROP TABLE t1,t2,t3,t4,t5; diff --git a/mysql-test/suite/ndb/t/ndb_config.test b/mysql-test/suite/ndb/t/ndb_config.test new file mode 100644 index 00000000000..f63c0087c1e --- /dev/null +++ b/mysql-test/suite/ndb/t/ndb_config.test @@ -0,0 +1,23 @@ +-- source include/have_ndb.inc +-- source include/ndb_default_cluster.inc +-- source include/not_embedded.inc + +--exec $NDB_TOOLS_DIR/ndb_config --no-defaults --query=type,nodeid,host 2> /dev/null +--exec $NDB_TOOLS_DIR/ndb_config --no-defaults --query=nodeid,host,DataMemory,IndexMemory --type=ndbd 2> /dev/null +--exec $NDB_TOOLS_DIR/ndb_config --no-defaults -r \\\n -f " " --query=nodeid,host,DataMemory,IndexMemory --type=ndbd 2> /dev/null +--exec $NDB_TOOLS_DIR/ndb_config --no-defaults --query=nodeid --type=ndbd --host=localhost 2> /dev/null +--exec $NDB_TOOLS_DIR/ndb_config --no-defaults --query=type,nodeid,host --config-file=$NDB_BACKUP_DIR/config.ini 2> /dev/null + +# End of 4.1 tests + +--exec $NDB_TOOLS_DIR/ndb_config --defaults-group-suffix=.jonas --defaults-file=$MYSQL_TEST_DIR/std_data/ndb_config_mycnf1.cnf --query=type,nodeid,host,IndexMemory,DataMemory --mycnf 2> /dev/null + +--exec $NDB_TOOLS_DIR/ndb_config --defaults-group-suffix=.cluster0 --defaults-file=$MYSQL_TEST_DIR/std_data/ndb_config_mycnf2.cnf --query=type,nodeid,host --mycnf 2> /dev/null +--exec $NDB_TOOLS_DIR/ndb_config --defaults-group-suffix=.cluster1 --defaults-file=$MYSQL_TEST_DIR/std_data/ndb_config_mycnf2.cnf --query=type,nodeid,host --mycnf 2> /dev/null +--exec $NDB_TOOLS_DIR/ndb_config --defaults-group-suffix=.cluster2 --defaults-file=$MYSQL_TEST_DIR/std_data/ndb_config_mycnf2.cnf --query=type,nodeid,host --mycnf 2> /dev/null +--exec $NDB_TOOLS_DIR/ndb_config --defaults-group-suffix=.cluster2 --defaults-file=$MYSQL_TEST_DIR/std_data/ndb_config_mycnf2.cnf --ndb-shm --connections --query=type,nodeid1,nodeid2,group,nodeidserver --mycnf 2> /dev/null + + +--exec $NDB_TOOLS_DIR/ndb_config --no-defaults --query=nodeid --host=localhost --config-file=$NDB_BACKUP_DIR/config.ini 2> /dev/null +--exec $NDB_TOOLS_DIR/ndb_config --no-defaults --query=nodeid --host=1.2.3.4 --config-file=$NDB_BACKUP_DIR/config.ini 2> /dev/null +--exec $NDB_TOOLS_DIR/ndb_config --no-defaults --query=nodeid --host=127.0.0.1 --config-file=$NDB_BACKUP_DIR/config.ini 2> /dev/null diff --git a/mysql-test/suite/ndb/t/ndb_config2.test b/mysql-test/suite/ndb/t/ndb_config2.test new file mode 100644 index 00000000000..170f1b2e5e7 --- /dev/null +++ b/mysql-test/suite/ndb/t/ndb_config2.test @@ -0,0 +1,7 @@ +-- source include/have_ndb.inc +-- source include/ndb_default_cluster.inc +-- source include/not_embedded.inc + +# Following doesn't work in all configurations (if shm is not defined) + +--exec $NDB_TOOLS_DIR/ndb_config --defaults-group-suffix=.cluster2 --defaults-file=$MYSQL_TEST_DIR/std_data/ndb_config_mycnf2.cnf --ndb-shm --connections --query=type,nodeid1,nodeid2,group,nodeidserver --mycnf 2> /dev/null diff --git a/mysql-test/suite/ndb/t/ndb_cursor.test b/mysql-test/suite/ndb/t/ndb_cursor.test new file mode 100644 index 00000000000..406f8629cfe --- /dev/null +++ b/mysql-test/suite/ndb/t/ndb_cursor.test @@ -0,0 +1,47 @@ +-- source include/have_ndb.inc +-- source include/not_embedded.inc + +--disable_warnings +drop table if exists t1; +drop table if exists t2; +--enable_warnings + +create table t1 ( + a int not null primary key, + b int not null +) engine=ndb; + +create table t2 ( + a int not null primary key, + b int not null +) engine=ndb; + +insert into t1 values (1,10), (2,20), (3,30), (4, 40); + +delimiter //; +create procedure test_cursor () +begin + declare done int default 0; + declare temp_a int; + declare temp_b int; + declare cur1 cursor for select a,b from t1; + declare continue handler for sqlstate '02000' set done = 1; + open cur1; + repeat + fetch cur1 into temp_a, temp_b; + if not done then + insert into t2 values (temp_a, temp_b); + end if; + until done end repeat; + close cur1; +end; +// +delimiter ;// + +select * from t2 order by a; +call test_cursor(); +select * from t2 order by a; +drop procedure test_cursor; +drop table t1,t2; + +--echo end of 5.1 tests diff --git a/mysql-test/suite/ndb/t/ndb_database.test b/mysql-test/suite/ndb/t/ndb_database.test new file mode 100644 index 00000000000..8bfdf40de88 --- /dev/null +++ b/mysql-test/suite/ndb/t/ndb_database.test @@ -0,0 +1,24 @@ +-- source include/have_ndb.inc +-- source include/not_embedded.inc + +--disable_warnings +drop database if exists mysqltest; +--enable_warnings + +# +# Check that all tables in a database are dropped when database is dropped +# + +create database mysqltest; +create table mysqltest.t1 (a int primary key, b int) engine=ndb; +use mysqltest; +show tables; + +drop database mysqltest; +create database mysqltest; +use mysqltest; +show tables; + +drop database mysqltest; + +# End of 4.1 tests diff --git a/mysql-test/suite/ndb/t/ndb_dd_alter.test b/mysql-test/suite/ndb/t/ndb_dd_alter.test new file mode 100644 index 00000000000..7635a8944da --- /dev/null +++ b/mysql-test/suite/ndb/t/ndb_dd_alter.test @@ -0,0 +1,274 @@ +############################################################## +# Author: JBM +# Date: 2006-01-12 +# Purpose: To test using ndb memory and disk tables together. +############################################################## + +############################################################## +# Author: Nikolay +# Date: 2006-05-12 +# Purpose: To test using ndb memory and disk tables together. +# +# Select from disk into memory table +# Select from disk into memory table +# Create test that loads data, use mysql dump to dump data, drop table, +# create table and load from mysql dump. +# Use group by asc and dec; Use having; Use order by +# ALTER Tests (Meta data testing): +# ALTER from InnoDB to Cluster Disk Data +# ALTER from MyISAM to Cluster Disk Data +# ALTER from Cluster Disk Data to InnoDB +# ALTER from Cluster Disk Data to MyISAM +# ALTER DD Tables and add columns +# ALTER DD Tables and add Indexes +# ALTER DD Tables and drop columns +# +############################################################## +# Author: Jonathan +# Date 2006-08-28 +# Purpose: To take out some of the test that are already +# Covered by other tests. Per Jonas +# The new purpose of this test is testing "Alter" +# Statements. Therefore the name is changed to +# ndb_dd_alter.test +# Removed tests include: +# Select from disk into memory table +# Select from disk into memory table +# Create test that loads data, use mysql dump to dump data, drop table, +# create table and load from mysql dump. +# Use group by asc and dec; Use having; Use order by +############################################################## + +-- source include/have_ndb.inc +-- source include/have_innodb.inc +-- source include/not_embedded.inc + +--disable_warnings +DROP TABLE IF EXISTS test.t1; +DROP TABLE IF EXISTS test.t2; +--enable_warnings + +############ Test Setup Section ############# +-- echo **** Test Setup Section **** +################## ALTER Tests (Meta data testing) #################### + + CREATE LOGFILE GROUP lg + ADD UNDOFILE './lg_group/undofile.dat' + INITIAL_SIZE 16M + UNDO_BUFFER_SIZE = 1M + ENGINE=NDB; + + CREATE TABLESPACE ts + ADD DATAFILE './table_space/datafile.dat' + USE LOGFILE GROUP lg + INITIAL_SIZE 12M + ENGINE NDB; + +#### Try to ALTER from InnoDB to Cluster Disk Data + +CREATE TABLE test.t1 ( + a1 smallint NOT NULL, + a2 int NOT NULL, + a3 bigint NOT NULL, + a4 char(10), + a5 decimal(5,1), + a6 time, + a7 date, + a8 datetime, + a9 VARCHAR(255), + a10 blob, + PRIMARY KEY(a1) +) ENGINE=InnoDB; + +let $1=20; +disable_query_log; +while ($1) +{ + eval insert into test.t1 values($1, $1+1, $1+2000000000, "aaa$1", 34.2, '4:3:2', '2006-1-1', '1971-5-28 16:55:03', "bbbbbbbbbbbbb$1", "binary data"); + dec $1; +} +enable_query_log; + +SHOW CREATE TABLE test.t1; +SELECT * FROM test.t1 ORDER BY a1; +ALTER TABLE test.t1 TABLESPACE ts STORAGE DISK ENGINE=NDB; +SHOW CREATE TABLE test.t1; +# Check column storage +--exec $NDB_TOOLS_DIR/ndb_desc --no-defaults -d test t1 | grep 'ST=' +SELECT * FROM test.t1 ORDER BY a1; +DROP TABLE test.t1; + +#### Try to ALTER from MyISAM to Cluster Disk Data + +CREATE TABLE test.t1 ( + a1 smallint NOT NULL, + a2 int NOT NULL, + a3 bigint NOT NULL, + a4 char(10), + a5 decimal(5,1), + a6 time, + a7 date, + a8 datetime, + a9 VARCHAR(255), + a10 blob, + PRIMARY KEY(a1) +) ENGINE=MyISAM; + +let $1=20; +disable_query_log; +while ($1) +{ + eval insert into test.t1 values($1, $1+1, $1+2000000000, "aaa$1", 34.2, '4:3:2', '2006-1-1', '1971-5-28 16:55:03', "bbbbbbbbbbbbb$1", "binary data"); + dec $1; +} +enable_query_log; + +SHOW CREATE TABLE test.t1; +SELECT * FROM test.t1 ORDER BY a1; +ALTER TABLE test.t1 TABLESPACE ts STORAGE DISK ENGINE=NDB; +SHOW CREATE TABLE test.t1; +# Check column storage +--exec $NDB_TOOLS_DIR/ndb_desc --no-defaults -d test t1 | grep 'ST=' +SELECT * FROM test.t1 ORDER BY a1; + +#### Try to ALTER from Cluster Disk Data to InnoDB + +ALTER TABLE test.t1 ENGINE=InnoDB; +SHOW CREATE TABLE test.t1; +SELECT * FROM test.t1 ORDER BY a1; +ALTER TABLE test.t1 TABLESPACE ts STORAGE DISK ENGINE=NDB; +SHOW CREATE TABLE test.t1; +# Check column storage +--exec $NDB_TOOLS_DIR/ndb_desc --no-defaults -d test t1 | grep 'ST=' + +#### Try to ALTER from Cluster Disk Data to MyISAM + +ALTER TABLE test.t1 ENGINE=MyISAM; +SHOW CREATE TABLE test.t1; +DROP TABLE test.t1; + +#### Try to ALTER DD Tables and add columns + +CREATE TABLE test.t1 (a1 INT PRIMARY KEY) TABLESPACE ts STORAGE DISK ENGINE=NDB; + +let $1=20; +disable_query_log; +while ($1) +{ + eval insert into test.t1 values($1); + dec $1; +} +enable_query_log; + +SELECT * FROM test.t1 ORDER BY a1; + +SELECT * FROM information_schema.partitions WHERE table_name= 't1' AND partition_name = 'p0'; + +ALTER TABLE test.t1 ADD a2 FLOAT, ADD a3 DOUBLE; + +SELECT * FROM information_schema.partitions WHERE table_name= 't1' AND partition_name = 'p0'; + +let $1=20; +disable_query_log; +while ($1) +{ + eval update test.t1 set a2 = $1+1.2345, a3 = $1+20000000.00 where a1 = $1; + dec $1; +} +enable_query_log; + +SELECT * FROM test.t1 ORDER BY a1; + +ALTER TABLE test.t1 ADD a4 BIT, ADD a5 TINYINT, ADD a6 BIGINT, ADD a7 DATE, ADD a8 TIME; + +let $1=20; +disable_query_log; +while ($1) +{ + eval update test.t1 set a4 = 0, a5 = 1, a6 = $1+23456, a7 = '2006-1-1', + a8 = '07:04:00' where a1 = $1; + dec $1; +} +enable_query_log; + +SELECT a1,a2,a3,hex(a4), a5,a6,a7,a8 FROM test.t1 ORDER BY a1; + +ALTER TABLE test.t1 ADD a9 DATETIME, ADD a10 TINYTEXT, ADD a11 MEDIUMTEXT, ADD a12 LONGTEXT, ADD a13 TEXT, ADD a14 BLOB; +SHOW CREATE TABLE test.t1; +# Check column storage +--exec $NDB_TOOLS_DIR/ndb_desc --no-defaults -d test t1 | grep 'ST=' + +disable_query_log; +set @d2 = 'dd2'; +set @d2 = concat(@d2,@d2,@d2,@d2,@d2,@d2,@d2,@d2,@d2,@d2); +set @d2 = concat(@d2,@d2,@d2,@d2,@d2,@d2,@d2,@d2,@d2,@d2); +set @d2 = concat(@d2,@d2,@d2,@d2,@d2,@d2,@d2,@d2,@d2,@d2); +set @d2 = concat(@d2,@d2,@d2,@d2,@d2,@d2,@d2,@d2,@d2,@d2); +enable_query_log; + +let $1=20; +disable_query_log; +while ($1) +{ + eval update test.t1 set a9 = '1971-5-28 16:55:03', a10 = 'abc', a11 = 'abcdefg', + a12 = 'LLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLL', a13 = 'Text Field', + a14 = @d2 where a1 = $1; + dec $1; +} +enable_query_log; + +SELECT a1, a2,a3,hex(a4),a5,a6,a7,a8,a9,a10,a11,a12,a13 FROM test.t1 ORDER BY a1; + +#### Try to ALTER DD Tables and add Indexes + +ALTER TABLE test.t1 ADD INDEX a2_i (a2), ADD INDEX a3_i (a3); + +SHOW CREATE TABLE test.t1; + +# Check column storage +--exec $NDB_TOOLS_DIR/ndb_desc --no-defaults -d test t1 | grep 'ST=' + +ALTER TABLE test.t1 DROP INDEX a2_i; + +SHOW CREATE TABLE test.t1; + +# Check column storage +--exec $NDB_TOOLS_DIR/ndb_desc --no-defaults -d test t1 | grep 'ST=' + +TRUNCATE TABLE test.t1; + +SHOW CREATE TABLE test.t1; + +# Check column storage +--exec $NDB_TOOLS_DIR/ndb_desc --no-defaults -d test t1 | grep 'ST=' + +#### Try to ALTER DD Tables and drop columns + + +ALTER TABLE test.t1 DROP a14; +ALTER TABLE test.t1 DROP a13; +ALTER TABLE test.t1 DROP a12; +ALTER TABLE test.t1 DROP a11; +ALTER TABLE test.t1 DROP a10; +ALTER TABLE test.t1 DROP a9; +ALTER TABLE test.t1 DROP a8; +ALTER TABLE test.t1 DROP a7; +ALTER TABLE test.t1 DROP a6; +ALTER TABLE test.t1 DROP PRIMARY KEY; + +SHOW CREATE TABLE test.t1; + +# Check column storage +--exec $NDB_TOOLS_DIR/ndb_desc --no-defaults -d test t1 | grep 'ST=' + +DROP TABLE test.t1; + + ALTER TABLESPACE ts + DROP DATAFILE './table_space/datafile.dat' + ENGINE NDB; + DROP TABLESPACE ts ENGINE NDB; + DROP LOGFILE GROUP lg ENGINE=NDB; + +####################### End section 4 ######################### +#End 5.1 test case + diff --git a/mysql-test/suite/ndb/t/ndb_dd_backuprestore.test b/mysql-test/suite/ndb/t/ndb_dd_backuprestore.test new file mode 100644 index 00000000000..48db8ec3e0b --- /dev/null +++ b/mysql-test/suite/ndb/t/ndb_dd_backuprestore.test @@ -0,0 +1,349 @@ +######################################## +# Author: JBM +# Date: 2006-01-24 +# Purpose: Test CDD backup and restore +######################################## + +-- source include/have_ndb.inc +-- source include/ndb_default_cluster.inc +-- source include/not_embedded.inc + +--disable_query_log +set new=on; +--enable_query_log + +--disable_warnings +DROP TABLE IF EXISTS test.t1; +DROP TABLE IF EXISTS test.t2; +DROP TABLE IF EXISTS test.t3; +DROP TABLE IF EXISTS test.t4; +DROP TABLE IF EXISTS test.t5; +DROP TABLE IF EXISTS test.t6; +--enable_warnings + +############ Test 1 Simple DD backup and restore ############# +-- echo **** Test 1 Simple DD backup and restore **** + +CREATE LOGFILE GROUP log_group1 +ADD UNDOFILE './log_group1/undofile.dat' +INITIAL_SIZE 16M +UNDO_BUFFER_SIZE = 1M +ENGINE=NDB; + +CREATE TABLESPACE table_space1 +ADD DATAFILE './table_space1/datafile.dat' +USE LOGFILE GROUP log_group1 +INITIAL_SIZE 12M +ENGINE NDB; + + +CREATE TABLE test.t1 +(pk1 MEDIUMINT NOT NULL AUTO_INCREMENT PRIMARY KEY, c2 CHAR(50) NOT NULL, c3 INT NOT NULL, c4 BIT NOT NULL) TABLESPACE table_space1 STORAGE DISK ENGINE=NDB; + +let $j= 500; +--disable_query_log +while ($j) +{ + eval INSERT INTO test.t1 VALUES (NULL, "Sweden", $j, b'1'); + dec $j; +} +--enable_query_log +SELECT COUNT(*) FROM test.t1; +SELECT pk1, c2, c3, hex(c4) FROM test.t1 ORDER BY pk1 LIMIT 5; + +-- source include/ndb_backup.inc + +DROP TABLE test.t1; + +ALTER TABLESPACE table_space1 +DROP DATAFILE './table_space1/datafile.dat' +ENGINE = NDB; + +DROP TABLESPACE table_space1 +ENGINE = NDB; + +DROP LOGFILE GROUP log_group1 +ENGINE =NDB; + +-- source include/ndb_restore_master.inc + +SELECT COUNT(*) FROM test.t1; + +SELECT pk1, c2, c3, hex(c4) FROM test.t1 ORDER BY pk1 LIMIT 5; + +################# Mixed Cluster Test ############################ +-- echo **** Test 2 Mixed Cluster Test backup and restore **** + +CREATE TABLE test.t2 +(pk1 MEDIUMINT NOT NULL AUTO_INCREMENT PRIMARY KEY, c2 VARCHAR(200) NOT NULL, c3 INT NOT NULL, c4 BIT NOT NULL)ENGINE=NDB; + +let $j= 500; +--disable_query_log +while ($j) +{ + eval INSERT INTO test.t2 VALUES (NULL, "Sweden, Texas", $j, b'0'); + dec $j; +} +--enable_query_log + +CREATE TABLE test.t3 (c1 int not null auto_increment, data LONGBLOB, PRIMARY KEY(c1))TABLESPACE table_space1 STORAGE DISK ENGINE=NDB; + +CREATE TABLE test.t4 (c1 int not null auto_increment, data LONGBLOB, PRIMARY KEY(c1))ENGINE=NDB; + +let $j= 50; +--disable_query_log +while ($j) +{ + INSERT INTO test.t3 VALUES (NULL, repeat('a',1*1024)); + INSERT INTO test.t3 VALUES (NULL, repeat('b',16*1024)); + INSERT INTO test.t4 VALUES (NULL, repeat('a',1*1024)); + INSERT INTO test.t4 VALUES (NULL, repeat('b',16*1024)); + dec $j; +} +--enable_query_log + +SELECT COUNT(*) FROM test.t1; + +SELECT pk1, c2, c3, hex(c4) FROM test.t1 ORDER BY pk1 LIMIT 5; + +SELECT COUNT(*) FROM test.t2; + +SELECT pk1, c2, c3, hex(c4) FROM test.t2 ORDER BY pk1 LIMIT 5; + +SELECT COUNT(*) FROM test.t3; + +SELECT LENGTH(data) FROM test.t3 WHERE c1 = 1; + +SELECT LENGTH(data) FROM test.t3 WHERE c1 = 2; + +SELECT COUNT(*) FROM test.t4; + +SELECT LENGTH(data) FROM test.t4 WHERE c1 = 1; + +SELECT LENGTH(data) FROM test.t4 WHERE c1 = 2; + +-- source include/ndb_backup.inc + +DROP TABLE test.t1; +DROP TABLE test.t2; +DROP TABLE test.t3; +DROP TABLE test.t4; + +ALTER TABLESPACE table_space1 +DROP DATAFILE './table_space1/datafile.dat' +ENGINE = NDB; + +DROP TABLESPACE table_space1 +ENGINE = NDB; + +DROP LOGFILE GROUP log_group1 +ENGINE =NDB; + +-- source include/ndb_restore_master.inc + +SELECT COUNT(*) FROM test.t1; + +SELECT pk1, c2, c3, hex(c4) FROM test.t1 ORDER BY pk1 LIMIT 5; + +SELECT COUNT(*) FROM test.t2; + +SELECT pk1, c2, c3, hex(c4) FROM test.t2 ORDER BY pk1 LIMIT 5; + +SELECT COUNT(*) FROM test.t3; + +SELECT LENGTH(data) FROM test.t3 WHERE c1 = 1; + +SELECT LENGTH(data) FROM test.t3 WHERE c1 = 2; + +SELECT COUNT(*) FROM test.t4; + +SELECT LENGTH(data) FROM test.t4 WHERE c1 = 1; + +SELECT LENGTH(data) FROM test.t4 WHERE c1 = 2; + +DROP TABLE test.t1; +DROP TABLE test.t2; +DROP TABLE test.t3; +DROP TABLE test.t4; +###################### Adding partition ################################# +-- echo **** Test 3 Adding partition Test backup and restore **** + +CREATE TABLESPACE table_space2 +ADD DATAFILE './table_space2/datafile.dat' +USE LOGFILE GROUP log_group1 +INITIAL_SIZE 12M +ENGINE NDB; + +CREATE TABLE test.t1 (pk1 MEDIUMINT NOT NULL AUTO_INCREMENT, c2 VARCHAR(150) NOT NULL, c3 INT NOT NULL, c4 BIT NOT NULL, PRIMARY KEY(pk1,c3))TABLESPACE table_space1 STORAGE DISK ENGINE=NDB PARTITION BY HASH(c3) PARTITIONS 4; + +CREATE TABLE test.t4 (pk1 MEDIUMINT NOT NULL AUTO_INCREMENT, c2 VARCHAR(180) NOT NULL, c3 INT NOT NULL, c4 BIT NOT NULL, PRIMARY KEY(pk1,c3))ENGINE=NDB PARTITION BY HASH(c3) PARTITIONS 2; + +CREATE TABLE test.t2 (pk1 MEDIUMINT NOT NULL AUTO_INCREMENT, c2 TEXT NOT NULL, c3 INT NOT NULL, c4 BIT NOT NULL, PRIMARY KEY(pk1,c3))TABLESPACE table_space2 STORAGE DISK ENGINE=NDB PARTITION BY KEY(c3) (PARTITION p0 ENGINE = NDB, PARTITION p1 ENGINE = NDB); + +CREATE TABLE test.t5 (pk1 MEDIUMINT NOT NULL AUTO_INCREMENT, c2 TEXT NOT NULL, c3 INT NOT NULL, c4 BIT NOT NULL, PRIMARY KEY(pk1,c3))ENGINE=NDB PARTITION BY KEY(pk1) (PARTITION p0 ENGINE = NDB, PARTITION p1 ENGINE = NDB); + +CREATE TABLE test.t3 (pk1 MEDIUMINT NOT NULL AUTO_INCREMENT, c2 VARCHAR(202) NOT NULL, c3 INT NOT NULL, c4 BIT NOT NULL, PRIMARY KEY(pk1,c3))TABLESPACE table_space2 STORAGE DISK ENGINE=NDB PARTITION BY RANGE (c3) PARTITIONS 3 (PARTITION x1 VALUES LESS THAN (105), PARTITION x2 VALUES LESS THAN (333), PARTITION x3 VALUES LESS THAN (720)); + +CREATE TABLE test.t6 (pk1 MEDIUMINT NOT NULL AUTO_INCREMENT, c2 VARCHAR(220) NOT NULL, c3 INT NOT NULL, c4 BIT NOT NULL, PRIMARY KEY(pk1,c3))ENGINE=NDB PARTITION BY RANGE (pk1) PARTITIONS 2 (PARTITION x1 VALUES LESS THAN (333), PARTITION x2 VALUES LESS THAN (720)); + +SHOW CREATE TABLE test.t1; + +SHOW CREATE TABLE test.t2; + +SHOW CREATE TABLE test.t3; + +SHOW CREATE TABLE test.t4; + +SHOW CREATE TABLE test.t5; + +SHOW CREATE TABLE test.t6; + +SELECT * FROM information_schema.partitions WHERE table_name= 't1'; + +SELECT * FROM information_schema.partitions WHERE table_name= 't2'; + +SELECT * FROM information_schema.partitions WHERE table_name= 't3'; + +SELECT * FROM information_schema.partitions WHERE table_name= 't4'; + +SELECT * FROM information_schema.partitions WHERE table_name= 't5'; + +SELECT * FROM information_schema.partitions WHERE table_name= 't6'; + + +let $j= 500; +--disable_query_log +while ($j) +{ + eval INSERT INTO test.t1 VALUES (NULL, "Sweden, Texas", $j, b'0'); + eval INSERT INTO test.t4 VALUES (NULL, "Sweden, Texas", $j, b'0'); + dec $j; + eval INSERT INTO test.t2 VALUES (NULL, "Sweden, Texas, ITALY, Kyle, JO, JBM,TU", $j, b'1'); + eval INSERT INTO test.t5 VALUES (NULL, "Sweden, Texas, ITALY, Kyle, JO, JBM,TU", $j, b'1'); + dec $j; + eval INSERT INTO test.t3 VALUES (NULL, "TEXASTEXASTEXASTEXASTEXASTEXASTEXASTEXASTEXASTEXAS, ITALY, Kyle, JO, JBM,TU", $j, b'1'); + eval INSERT INTO test.t6 VALUES (NULL, "TEXASTEXASTEXASTEXASTEXASTEXASTEXASTEXASTEXASTEXAS, ITALY, Kyle, JO, JBM,TU", $j, b'1'); } --enable_query_log + +SELECT COUNT(*) FROM test.t1; + +SELECT pk1, c2, c3, hex(c4) FROM test.t1 ORDER BY c3 LIMIT 5; + +SELECT COUNT(*) FROM test.t2; + +SELECT pk1, c2, c3, hex(c4) FROM test.t2 ORDER BY c3 LIMIT 5; + +SELECT COUNT(*) FROM test.t3; + +SELECT pk1, c2, c3, hex(c4) FROM test.t3 ORDER BY c3 LIMIT 5; + +SELECT COUNT(*) FROM test.t4; + +SELECT pk1, c2, c3, hex(c4) FROM test.t4 ORDER BY c3 LIMIT 5; + +SELECT COUNT(*) FROM test.t5; + +SELECT pk1, c2, c3, hex(c4) FROM test.t5 ORDER BY c3 LIMIT 5; + +SELECT COUNT(*) FROM test.t6; + +SELECT pk1, c2, c3, hex(c4) FROM test.t6 ORDER BY c3 LIMIT 5; + +-- source include/ndb_backup.inc + +DROP TABLE test.t1; +DROP TABLE test.t2; +DROP TABLE test.t3; +DROP TABLE test.t4; +DROP TABLE test.t5; +DROP TABLE test.t6; + +ALTER TABLESPACE table_space1 +DROP DATAFILE './table_space1/datafile.dat' +ENGINE = NDB; + +ALTER TABLESPACE table_space2 +DROP DATAFILE './table_space2/datafile.dat' +ENGINE = NDB; + +DROP TABLESPACE table_space1 +ENGINE = NDB; + +DROP TABLESPACE table_space2 +ENGINE = NDB; + +DROP LOGFILE GROUP log_group1 +ENGINE =NDB; + +-- source include/ndb_restore_master.inc + + +SHOW CREATE TABLE test.t1; + +SHOW CREATE TABLE test.t2; + +SHOW CREATE TABLE test.t3; + +SHOW CREATE TABLE test.t4; + +SHOW CREATE TABLE test.t5; + +SHOW CREATE TABLE test.t6; + +SELECT * FROM information_schema.partitions WHERE table_name= 't1'; + +SELECT * FROM information_schema.partitions WHERE table_name= 't2'; + +SELECT * FROM information_schema.partitions WHERE table_name= 't3'; + +SELECT * FROM information_schema.partitions WHERE table_name= 't4'; + +SELECT * FROM information_schema.partitions WHERE table_name= 't5'; + +SELECT * FROM information_schema.partitions WHERE table_name= 't6'; + +SELECT COUNT(*) FROM test.t1; + +SELECT pk1, c2, c3, hex(c4) FROM test.t1 ORDER BY c3 LIMIT 5; + +SELECT COUNT(*) FROM test.t2; + +SELECT pk1, c2, c3, hex(c4) FROM test.t2 ORDER BY c3 LIMIT 5; + +SELECT COUNT(*) FROM test.t3; + +SELECT pk1, c2, c3, hex(c4) FROM test.t3 ORDER BY c3 LIMIT 5; + +SELECT COUNT(*) FROM test.t4; + +SELECT pk1, c2, c3, hex(c4) FROM test.t4 ORDER BY c3 LIMIT 5; + +SELECT COUNT(*) FROM test.t5; + +SELECT pk1, c2, c3, hex(c4) FROM test.t5 ORDER BY c3 LIMIT 5; + +SELECT COUNT(*) FROM test.t6; + +SELECT pk1, c2, c3, hex(c4) FROM test.t6 ORDER BY c3 LIMIT 5; + +# Cleanup + +DROP TABLE test.t1; +DROP TABLE test.t2; +DROP TABLE test.t3; +DROP TABLE test.t4; +DROP TABLE test.t5; +DROP TABLE test.t6; + +ALTER TABLESPACE table_space1 DROP DATAFILE './table_space1/datafile.dat' ENGINE=NDB; + +ALTER TABLESPACE table_space2 DROP DATAFILE './table_space2/datafile.dat' ENGINE=NDB; + +DROP TABLESPACE table_space1 ENGINE = NDB; + +DROP TABLESPACE table_space2 ENGINE = NDB; + +DROP LOGFILE GROUP log_group1 ENGINE = NDB; + +#End 5.1 test case + + diff --git a/mysql-test/suite/ndb/t/ndb_dd_basic.test b/mysql-test/suite/ndb/t/ndb_dd_basic.test new file mode 100644 index 00000000000..3acf4669868 --- /dev/null +++ b/mysql-test/suite/ndb/t/ndb_dd_basic.test @@ -0,0 +1,454 @@ +################################# +# Author: JO +# Org Date: ? +# Purpose: To test basic Cluster Disk Data +################################# +# Change Author: JBM +# Change Date: 2006-01-11 +# Change: Cleanup and test rename +################################# +# Change Author: Guangbao Ni +# Change Date: 2007-03-20 +# Change: Test insert data when no datafile in spacetable +################################# + +-- source include/have_ndb.inc + +--disable_warnings +DROP TABLE IF EXISTS t1; +--enable_warnings + +# some negative tests +CREATE LOGFILE GROUP lg1 +ADD UNDOFILE 'undofile.dat' +INITIAL_SIZE 16M +UNDO_BUFFER_SIZE = 1M +ENGINE=MYISAM; + +ALTER LOGFILE GROUP lg1 +ADD UNDOFILE 'undofile02.dat' +INITIAL_SIZE = 4M +ENGINE=XYZ; + +CREATE TABLESPACE ts1 +ADD DATAFILE 'datafile.dat' +USE LOGFILE GROUP lg1 +INITIAL_SIZE 12M; + +################################## +# Basic test of disk tables for NDB +# Start by creating a logfile group +################################## + +set storage_engine=ndb; +CREATE LOGFILE GROUP lg1 +ADD UNDOFILE 'undofile.dat' +INITIAL_SIZE 16M +UNDO_BUFFER_SIZE = 1M; + +ALTER LOGFILE GROUP lg1 +ADD UNDOFILE 'undofile02.dat' +INITIAL_SIZE = 4M +ENGINE=NDB; + +################################################### +# Create a tablespace connected to the logfile group +################################################### + +set storage_engine=myisam; +CREATE TABLESPACE ts1 +ADD DATAFILE 'datafile.dat' +USE LOGFILE GROUP lg1 +INITIAL_SIZE 12M +ENGINE NDB; + +ALTER TABLESPACE ts1 +ADD DATAFILE 'datafile02.dat' +INITIAL_SIZE = 4M +ENGINE=NDB; + +######################################## +# Create a table using this tablespace +######################################## + +CREATE TABLE t1 +(pk1 INT NOT NULL PRIMARY KEY, b INT NOT NULL, c INT NOT NULL) +TABLESPACE ts1 STORAGE DISK +ENGINE=NDB; + +SHOW CREATE TABLE t1; + +INSERT INTO t1 VALUES (0, 0, 0); +SELECT * FROM t1; + +INSERT INTO t1 VALUES +(1,1,1),(2,2,2),(3,3,3),(4,4,4),(5,5,5), +(6,6,6),(7,7,7),(8,8,8),(9,9,9),(10,10,10), +(11,11,11),(12,12,12),(13,13,13),(14,14,14),(15,15,15), +(16,16,16),(17,17,17),(18,18,18),(19,19,19),(20,20,20), +(21,21,21),(22,22,22),(23,23,23),(24,24,24),(25,25,25), +(26,26,26),(27,27,27),(28,28,28),(29,29,29),(30,30,30), +(31,31,31),(32,32,32),(33,33,33),(34,34,34),(35,35,35), +(36,36,36),(37,37,37),(38,38,38),(39,39,39),(40,40,40), +(41,41,41),(42,42,42),(43,43,43),(44,44,44),(45,45,45), +(46,46,46),(47,47,47),(48,48,48),(49,49,49),(50,50,50), +(51,51,51),(52,52,52),(53,53,53),(54,54,54),(55,55,55), +(56,56,56),(57,57,57),(58,58,58),(59,59,59),(60,60,60), +(61,61,61),(62,62,62),(63,63,63),(64,64,64),(65,65,65), +(66,66,66),(67,67,67),(68,68,68),(69,69,69),(70,70,70), +(71,71,71),(72,72,72),(73,73,73),(74,74,74),(75,75,75), +(76,76,76),(77,77,77),(78,78,78),(79,79,79),(80,80,80), +(81,81,81),(82,82,82),(83,83,83),(84,84,84),(85,85,85), +(86,86,86),(87,87,87),(88,88,88),(89,89,89),(90,90,90), +(91,91,91),(92,92,92),(93,93,93),(94,94,94),(95,95,95), +(96,96,96),(97,97,97),(98,98,98),(99,99,99),(100,100,100), +(101,101,101),(102,102,102),(103,103,103),(104,104,104),(105,105,105), +(106,106,106),(107,107,107),(108,108,108),(109,109,109),(110,110,110), +(111,111,111),(112,112,112),(113,113,113),(114,114,114),(115,115,115), +(116,116,116),(117,117,117),(118,118,118),(119,119,119),(120,120,120), +(121,121,121),(122,122,122),(123,123,123),(124,124,124),(125,125,125), +(126,126,126),(127,127,127),(128,128,128),(129,129,129),(130,130,130), +(131,131,131),(132,132,132),(133,133,133),(134,134,134),(135,135,135), +(136,136,136),(137,137,137),(138,138,138),(139,139,139),(140,140,140), +(141,141,141),(142,142,142),(143,143,143),(144,144,144),(145,145,145), +(146,146,146),(147,147,147),(148,148,148),(149,149,149),(150,150,150), +(151,151,151),(152,152,152),(153,153,153),(154,154,154),(155,155,155), +(156,156,156),(157,157,157),(158,158,158),(159,159,159),(160,160,160), +(161,161,161),(162,162,162),(163,163,163),(164,164,164),(165,165,165), +(166,166,166),(167,167,167),(168,168,168),(169,169,169),(170,170,170), +(171,171,171),(172,172,172),(173,173,173),(174,174,174),(175,175,175), +(176,176,176),(177,177,177),(178,178,178),(179,179,179),(180,180,180), +(181,181,181),(182,182,182),(183,183,183),(184,184,184),(185,185,185), +(186,186,186),(187,187,187),(188,188,188),(189,189,189),(190,190,190), +(191,191,191),(192,192,192),(193,193,193),(194,194,194),(195,195,195), +(196,196,196),(197,197,197),(198,198,198),(199,199,199),(200,200,200), +(201,201,201),(202,202,202),(203,203,203),(204,204,204),(205,205,205), +(206,206,206),(207,207,207),(208,208,208),(209,209,209),(210,210,210), +(211,211,211),(212,212,212),(213,213,213),(214,214,214),(215,215,215), +(216,216,216),(217,217,217),(218,218,218),(219,219,219),(220,220,220), +(221,221,221),(222,222,222),(223,223,223),(224,224,224),(225,225,225), +(226,226,226),(227,227,227),(228,228,228),(229,229,229),(230,230,230), +(231,231,231),(232,232,232),(233,233,233),(234,234,234),(235,235,235), +(236,236,236),(237,237,237),(238,238,238),(239,239,239),(240,240,240), +(241,241,241),(242,242,242),(243,243,243),(244,244,244),(245,245,245), +(246,246,246),(247,247,247),(248,248,248),(249,249,249),(250,250,250), +(251,251,251),(252,252,252),(253,253,253),(254,254,254),(255,255,255), +(256,256,256),(257,257,257),(258,258,258),(259,259,259),(260,260,260), +(261,261,261),(262,262,262),(263,263,263),(264,264,264),(265,265,265), +(266,266,266),(267,267,267),(268,268,268),(269,269,269),(270,270,270), +(271,271,271),(272,272,272),(273,273,273),(274,274,274),(275,275,275), +(276,276,276),(277,277,277),(278,278,278),(279,279,279),(280,280,280), +(281,281,281),(282,282,282),(283,283,283),(284,284,284),(285,285,285), +(286,286,286),(287,287,287),(288,288,288),(289,289,289),(290,290,290), +(291,291,291),(292,292,292),(293,293,293),(294,294,294),(295,295,295), +(296,296,296),(297,297,297),(298,298,298),(299,299,299),(300,300,300), +(301,301,301),(302,302,302),(303,303,303),(304,304,304),(305,305,305), +(306,306,306),(307,307,307),(308,308,308),(309,309,309),(310,310,310), +(311,311,311),(312,312,312),(313,313,313),(314,314,314),(315,315,315), +(316,316,316),(317,317,317),(318,318,318),(319,319,319),(320,320,320), +(321,321,321),(322,322,322),(323,323,323),(324,324,324),(325,325,325), +(326,326,326),(327,327,327),(328,328,328),(329,329,329),(330,330,330), +(331,331,331),(332,332,332),(333,333,333),(334,334,334),(335,335,335), +(336,336,336),(337,337,337),(338,338,338),(339,339,339),(340,340,340), +(341,341,341),(342,342,342),(343,343,343),(344,344,344),(345,345,345), +(346,346,346),(347,347,347),(348,348,348),(349,349,349),(350,350,350), +(351,351,351),(352,352,352),(353,353,353),(354,354,354),(355,355,355), +(356,356,356),(357,357,357),(358,358,358),(359,359,359),(360,360,360), +(361,361,361),(362,362,362),(363,363,363),(364,364,364),(365,365,365), +(366,366,366),(367,367,367),(368,368,368),(369,369,369),(370,370,370), +(371,371,371),(372,372,372),(373,373,373),(374,374,374),(375,375,375), +(376,376,376),(377,377,377),(378,378,378),(379,379,379),(380,380,380), +(381,381,381),(382,382,382),(383,383,383),(384,384,384),(385,385,385), +(386,386,386),(387,387,387),(388,388,388),(389,389,389),(390,390,390), +(391,391,391),(392,392,392),(393,393,393),(394,394,394),(395,395,395), +(396,396,396),(397,397,397),(398,398,398),(399,399,399),(400,400,400), +(401,401,401),(402,402,402),(403,403,403),(404,404,404),(405,405,405), +(406,406,406),(407,407,407),(408,408,408),(409,409,409),(410,410,410), +(411,411,411),(412,412,412),(413,413,413),(414,414,414),(415,415,415), +(416,416,416),(417,417,417),(418,418,418),(419,419,419),(420,420,420), +(421,421,421),(422,422,422),(423,423,423),(424,424,424),(425,425,425), +(426,426,426),(427,427,427),(428,428,428),(429,429,429),(430,430,430), +(431,431,431),(432,432,432),(433,433,433),(434,434,434),(435,435,435), +(436,436,436),(437,437,437),(438,438,438),(439,439,439),(440,440,440), +(441,441,441),(442,442,442),(443,443,443),(444,444,444),(445,445,445), +(446,446,446),(447,447,447),(448,448,448),(449,449,449),(450,450,450), +(451,451,451),(452,452,452),(453,453,453),(454,454,454),(455,455,455), +(456,456,456),(457,457,457),(458,458,458),(459,459,459),(460,460,460), +(461,461,461),(462,462,462),(463,463,463),(464,464,464),(465,465,465), +(466,466,466),(467,467,467),(468,468,468),(469,469,469),(470,470,470), +(471,471,471),(472,472,472),(473,473,473),(474,474,474),(475,475,475), +(476,476,476),(477,477,477),(478,478,478),(479,479,479),(480,480,480), +(481,481,481),(482,482,482),(483,483,483),(484,484,484),(485,485,485), +(486,486,486),(487,487,487),(488,488,488),(489,489,489),(490,490,490), +(491,491,491),(492,492,492),(493,493,493),(494,494,494),(495,495,495), +(496,496,496),(497,497,497),(498,498,498),(499,499,499),(500, 500, 500); + +SELECT COUNT(*) FROM t1; + +#################################### +# Test error cases with size numbers +#################################### +--error ER_WRONG_SIZE_NUMBER +CREATE LOGFILE GROUP lg2 +ADD UNDOFILE 'x.dat' +INITIAL_SIZE 10y +ENGINE = NDB; + +--error ER_WRONG_SIZE_NUMBER +CREATE LOGFILE GROUP lg2 +ADD UNDOFILE 'x.dat' +INITIAL_SIZE 10MB +ENGINE = NDB; + +--error 1064 +CREATE LOGFILE GROUP lg2 +ADD UNDOFILE 'x.dat' +INITIAL_SIZE 10 MB +ENGINE = NDB; + +--error 1064 +CREATE LOGFILE GROUP lg2 +ADD UNDOFILE 'x.dat' +INITIAL_SIZE 10 M +ENGINE = NDB; + +--error ER_SIZE_OVERFLOW_ERROR +CREATE LOGFILE GROUP lg2 +ADD UNDOFILE 'x.dat' +INITIAL_SIZE 1000000000000K +ENGINE = NDB; + +DROP TABLE t1; + +create tablespace ts2 +add datafile 'datafile2_1.dat' +use logfile group lg1 +initial_size 12M +engine ndb; + +CREATE TABLE City ( + ID int(11) NOT NULL AUTO_INCREMENT, + Name char(35) NOT NULL, + CountryCode char(3) NOT NULL, + District char(20) NOT NULL, + Population int(11) NOT NULL, + PRIMARY KEY (ID) +) ENGINE=ndbcluster +tablespace ts2 +storage disk; + +alter tablespace ts2 +drop datafile 'datafile2_1.dat' +engine ndb; + +#It will give error messages: NoDatafile in tablespace +--error ER_GET_ERRMSG +insert +into City (Name,CountryCode,District,Population) +values ('BeiJing','CN','Beijing',2000); + +--error ER_DROP_FILEGROUP_FAILED +drop tablespace ts2 +engine ndb; + +drop table City; + +drop tablespace ts2 +engine ndb; + +############################ +# Test update of mm/dd part +############################ + +CREATE TABLE t1 (a INT PRIMARY KEY, b CHAR(4) NOT NULL, c CHAR(4) NOT NULL, KEY(b)) TABLESPACE ts1 STORAGE DISK ENGINE = NDB; +INSERT INTO t1 VALUES (1,'1','1'), (2,'2','2'), (3,'3','3'); +BEGIN; +UPDATE t1 SET b = '2' WHERE a = 1; +SELECT b FROM t1 WHERE a = 1; +SELECT * FROM t1 WHERE a = 1; +UPDATE t1 SET c = '2' WHERE a = 1; +SELECT b FROM t1 WHERE a = 1; +SELECT * FROM t1 WHERE a = 1; +UPDATE t1 SET b = '3' WHERE a = 1; +SELECT b FROM t1 WHERE a = 1; +SELECT * FROM t1 WHERE a = 1; +COMMIT; +SELECT * FROM t1 ORDER BY 1; +BEGIN; +UPDATE t1 SET c = '3' WHERE a = 1; +SELECT b FROM t1 WHERE a = 1; +SELECT * FROM t1 WHERE a = 1; +UPDATE t1 SET b = '4' WHERE a = 1; +SELECT b FROM t1 WHERE a = 1; +SELECT * FROM t1 WHERE a = 1; +UPDATE t1 SET c = '4' WHERE a = 1; +SELECT b FROM t1 WHERE a = 1; +SELECT * FROM t1 WHERE a = 1; +COMMIT; +SELECT * FROM t1 ORDER BY 1; +UPDATE t1 SET b = '5' WHERE a = 1; +SELECT * FROM t1 ORDER BY 1; +UPDATE t1 SET b = '6' WHERE b = '5'; +SELECT * FROM t1 ORDER BY 1; +UPDATE t1 SET b = '7'WHERE c = '4'; +SELECT * FROM t1 ORDER BY 1; +UPDATE t1 SET c = '5' WHERE a = 1; +SELECT * FROM t1 ORDER BY 1; +UPDATE t1 SET c = '6' WHERE b = '7'; +SELECT * FROM t1 ORDER BY 1; +UPDATE t1 SET c = '7' WHERE c = '6'; +SELECT * FROM t1 ORDER BY 1; +DROP TABLE t1; + +##### + +CREATE TABLE t1 (a INT PRIMARY KEY, b VARCHAR(4) NOT NULL, c CHAR(4) NOT NULL, KEY(b)) TABLESPACE ts1 STORAGE DISK ENGINE NDB; +INSERT INTO t1 VALUE (1,'1','1'), (2,'2','2'), (3,'3','3'); +BEGIN; +UPDATE t1 SET b = '2' WHERE a = 1; +SELECT b FROM t1 WHERE a = 1; +SELECT * FROM t1 WHERE a = 1; +UPDATE t1 SET c = '2' WHERE a = 1; +SELECT b FROM t1 WHERE a = 1; +SELECT * FROM t1 WHERE a = 1; +UPDATE t1 SET b = '3' WHERE a = 1; +SELECT b FROM t1 WHERE a = 1; +SELECT * FROM t1 WHERE a = 1; +COMMIT; +SELECT * FROM t1 ORDER BY 1; +BEGIN; +UPDATE t1 SET c = '3' WHERE a = 1; +SELECT b FROM t1 WHERE a = 1; +SELECT * FROM t1 WHERE a = 1; +UPDATE t1 SET b = '4' WHERE a = 1; +SELECT b FROM t1 WHERE a = 1; +SELECT * FROM t1 WHERE a = 1; +UPDATE t1 SET c = '4' WHERE a = 1; +SELECT b FROM t1 WHERE a = 1; +SELECT * FROM t1 WHERE a = 1; +COMMIT; +SELECT * FROM t1 ORDER BY 1; +UPDATE t1 SET b = '5' WHERE a = 1; +SELECT * FROM t1 ORDER BY 1; +UPDATE t1 SET b = '6' WHERE b = '5'; +SELECT * FROM t1 ORDER BY 1; +UPDATE t1 SET b = '7' WHERE c = '4'; +SELECT * FROM t1 ORDER BY 1; +UPDATE t1 SET c = '5' WHERE a = 1; +SELECT * FROM t1 ORDER BY 1; +UPDATE t1 SET c = '6' WHERE b = '7'; +SELECT * FROM t1 ORDER BY 1; +UPDATE t1 SET c = '7' WHERE c = '6'; +SELECT * FROM t1 ORDER BY 1; +DROP TABLE t1; + +######################## +# Test for blobs... +######################## + +CREATE TABLE t1 ( + a INT NOT NULL PRIMARY KEY, + b TEXT NOT NULL +) TABLESPACE ts1 STORAGE DISK ENGINE=NDBCLUSTER; + +# b1 length 2000+256 (blob part aligned) +######################################### +set @x0 = '01234567012345670123456701234567'; +set @x0 = concat(@x0,@x0,@x0,@x0,@x0,@x0,@x0,@x0); +set @b1 = 'b1'; +set @b1 = concat(@b1,@b1,@b1,@b1,@b1,@b1,@b1,@b1,@b1,@b1); +set @b1 = concat(@b1,@b1,@b1,@b1,@b1,@b1,@b1,@b1,@b1,@b1); +set @b1 = concat(@b1,@b1,@b1,@b1,@b1,@b1,@b1,@b1,@b1,@b1); +set @b1 = concat(@b1,@x0); +# b2 length 20000 +########################################## +set @b2 = 'b2'; +set @b2 = concat(@b2,@b2,@b2,@b2,@b2,@b2,@b2,@b2,@b2,@b2); +set @b2 = concat(@b2,@b2,@b2,@b2,@b2,@b2,@b2,@b2,@b2,@b2); +set @b2 = concat(@b2,@b2,@b2,@b2,@b2,@b2,@b2,@b2,@b2,@b2); +set @b2 = concat(@b2,@b2,@b2,@b2,@b2,@b2,@b2,@b2,@b2,@b2); + +INSERT INTO t1 VALUES(1,@b1); +INSERT INTO t1 VALUES(2,@b2); +SELECT a,length(b),substr(b,1+2*900,2) FROM t1 WHERE a=1; +SELECT a,length(b),substr(b,1+2*9000,2) FROM t1 WHERE a=2; +UPDATE t1 SET b=@b2 WHERE a=1; +UPDATE t1 SET b=@b1 WHERE a=2; +SELECT a,length(b),substr(b,1+2*9000,2) FROM t1 WHERE a=1; +SELECT a,length(b),substr(b,1+2*900,2) FROM t1 WHERE a=2; +UPDATE t1 SET b=concat(b,b) WHERE a=1; +UPDATE t1 SET b=concat(b,b) WHERE a=2; +SELECT a,length(b),substr(b,1+4*9000,2) FROM t1 WHERE a=1; +SELECT a,length(b),substr(b,1+4*900,2) FROM t1 WHERE a=2; +DELETE FROM t1 WHERE a=1; +DELETE FROM t1 WHERE a=2; +SELECT COUNT(*) FROM t1; +DROP TABLE t1; + +# bug#20612 INS-DEL bug (not pgman bug) +# found via disk data assert but is not pgman or disk data related + +CREATE TABLE t1 ( + a int NOT NULL, + b varchar(4000), -- must use 2 pages undo + PRIMARY KEY using hash (a) +) +TABLESPACE ts1 STORAGE DISK ENGINE=NDBCLUSTER; + +set autocommit = 0; +insert into t1 values(0,'x'); +insert into t1 values(1,'x'); +insert into t1 values(2,'x'); +insert into t1 values(3,'x'); +insert into t1 values(4,'x'); +insert into t1 values(5,'x'); +insert into t1 values(6,'x'); +insert into t1 values(7,'x'); +insert into t1 values(8,'x'); +delete from t1 where a = 0; +commit; + +delete from t1; +begin; +insert into t1 values (1, 'x'); +select * from t1; +rollback; + +set autocommit = 1; + + +drop table t1; +############################# +# Customer posted order by test case +# Org in ndb_dd_advance.test +############################# + +create table test.t1 (f1 varchar(50) primary key, f2 text,f3 int) +TABLESPACE ts1 STORAGE DISK engine=NDB; +insert into test.t1 (f1,f2,f3)VALUES("111111","aaaaaa",1); +insert into test.t1 (f1,f2,f3)VALUES("222222","bbbbbb",2); +select * from test.t1 order by f1; +select f1,f2 from test.t1 order by f2; +select f2 from test.t1 order by f2; +select f1,f2 from test.t1 order by f1; +drop table test.t1; + +################### +# Test Cleanup +################### + +ALTER TABLESPACE ts1 +DROP DATAFILE 'datafile.dat' +ENGINE = NDB; + +ALTER TABLESPACE ts1 +DROP DATAFILE 'datafile02.dat' +ENGINE = NDB; + +DROP TABLESPACE ts1 +ENGINE = NDB; + +DROP LOGFILE GROUP lg1 +ENGINE =NDB; + +#End 5.1 test case diff --git a/mysql-test/suite/ndb/t/ndb_dd_ddl.test b/mysql-test/suite/ndb/t/ndb_dd_ddl.test new file mode 100644 index 00000000000..aa692385b07 --- /dev/null +++ b/mysql-test/suite/ndb/t/ndb_dd_ddl.test @@ -0,0 +1,363 @@ +######################################### +# Author: JBM +# Date: 2006-01-03 +# Purpose: Test the NDB engine reaction to duplicate +# Table spaces and log groups. Also to test +# Statement mixed case. +############################################ +# Change Author:JBM +# Change Date 2006-01-19 +# Change: Adding to test cases feedback from OB +# 1) The 'duplicate' tests. +# a) The test is using the default (test) database and is not +# attempting to create databases (only logs, table spaces and +# tables). Is this intentional? +# b) What about a duplication of table name when one exists on disk and +# you are trying to create it again in memory? +# +#2) 'CaSE SensiTiVE' tests +# a) Suggest you include a test case where the case difference is in +# the file name. I know this is not an issue for *nix systems but +# will be when we expand to Windows and Mac. Better put it in now. +############################################ +# +# Jonas 2006-03-10 +# Add verification that ndb currently is limited to 1 logfile group +# + + +-- source include/have_ndb.inc + +--disable_warnings +DROP TABLE IF EXISTS t1; +DROP DATABASE IF EXISTS mysqltest; +CREATE DATABASE mysqltest; +--enable_warnings + +############## Duplcate Statement Testing ######### + +--echo **** Begin Duplicate Statement Testing **** + +CREATE LOGFILE GROUP lg1 +ADD UNDOFILE 'undofile.dat' +INITIAL_SIZE 1M +UNDO_BUFFER_SIZE = 1M +ENGINE=NDB; + +# Verify that one currently can create only 1 logfile group +--error ER_CREATE_FILEGROUP_FAILED +CREATE LOGFILE GROUP lg2 +ADD UNDOFILE 'undofile2.dat' +INITIAL_SIZE 1M +UNDO_BUFFER_SIZE 1M +ENGINE NDB; +SHOW WARNINGS; + +--error ER_CREATE_FILEGROUP_FAILED +CREATE LOGFILE GROUP lg1 +ADD UNDOFILE 'undofile.dat' +INITIAL_SIZE 1M +UNDO_BUFFER_SIZE = 1M +ENGINE=NDB; + +ALTER LOGFILE GROUP lg1 +ADD UNDOFILE 'undofile02.dat' +INITIAL_SIZE 1M ENGINE NDB; + +--error ER_ALTER_FILEGROUP_FAILED +ALTER LOGFILE GROUP lg1 +ADD UNDOFILE 'undofile02.dat' +INITIAL_SIZE 1M ENGINE=NDB; + +CREATE TABLESPACE ts1 +ADD DATAFILE 'datafile.dat' +USE LOGFILE GROUP lg1 +INITIAL_SIZE 1M +ENGINE NDB; + +--error ER_CREATE_FILEGROUP_FAILED +CREATE TABLESPACE ts1 +ADD DATAFILE 'datafile.dat' +USE LOGFILE GROUP lg1 +INITIAL_SIZE 1M +ENGINE NDB; + + +ALTER TABLESPACE ts1 +ADD DATAFILE 'datafile2.dat' +INITIAL_SIZE 1M +ENGINE=NDB; + +--error ER_ALTER_FILEGROUP_FAILED +ALTER TABLESPACE ts1 +ADD DATAFILE 'datafile2.dat' +INITIAL_SIZE 1M +ENGINE=NDB; + +CREATE TABLE mysqltest.t1 +(pk1 INT NOT NULL PRIMARY KEY, b INT NOT NULL, c INT NOT NULL) +TABLESPACE ts1 STORAGE DISK +ENGINE=NDB; + +--error ER_TABLE_EXISTS_ERROR +CREATE TABLE mysqltest.t1 +(pk1 INT NOT NULL PRIMARY KEY, b INT NOT NULL, c INT NOT NULL) +TABLESPACE ts1 STORAGE DISK +ENGINE=NDB; + +--error ER_TABLE_EXISTS_ERROR +CREATE TABLE mysqltest.t1 +(pk1 INT NOT NULL PRIMARY KEY, b INT NOT NULL, c INT NOT NULL) +ENGINE=NDB; + + +DROP TABLE mysqltest.t1; + +ALTER TABLESPACE ts1 +DROP DATAFILE 'datafile2.dat' +ENGINE=NDB; + +--error ER_ALTER_FILEGROUP_FAILED +ALTER TABLESPACE ts1 +DROP DATAFILE 'datafile2.dat' +ENGINE=NDB; + +ALTER TABLESPACE ts1 +DROP DATAFILE 'datafile.dat' +ENGINE=NDB; + +--error ER_ALTER_FILEGROUP_FAILED +ALTER TABLESPACE ts1 +DROP DATAFILE 'datafile.dat' +ENGINE=NDB; + +DROP TABLESPACE ts1 +ENGINE=NDB; + +--error ER_DROP_FILEGROUP_FAILED +DROP TABLESPACE ts1 +ENGINE=NDB; + +DROP LOGFILE GROUP lg1 +ENGINE=NDB; + +--error ER_DROP_FILEGROUP_FAILED +DROP LOGFILE GROUP lg1 +ENGINE=NDB; + +DROP DATABASE IF EXISTS mysqltest; + +--echo **** End Duplicate Statement Testing **** +############# End Duplicate Statments ############ +--echo +############ Begin CaSe Testing ################## +--echo **** Begin Statment CaSe Testing **** + +creaTE LOgfilE GrOuP lg1 +adD undoFILE 'undofile.dat' +initiAL_siZE 1M +UnDo_BuFfEr_SiZe = 1M +ENGInE=NDb; + +altER LOgFiLE GrOUp lg1 +AdD UnDOfILe 'uNdOfiLe02.daT' +INItIAl_SIzE 1M ENgINE nDB; + +CrEAtE TABLEspaCE ts1 +ADD DATAfilE 'datafile.dat' +UsE LoGFiLE GRoUP lg1 +INITiaL_SizE 1M +ENGiNe NDb; + +AlTeR tAbLeSpAcE ts1 +AdD DaTaFiLe 'dAtAfiLe2.daT' +InItIaL_SiZe 1M +EnGiNe=NDB; + +CREATE TABLE t1 +(pk1 int not null primary key, b int not null, c int not null) +TABLEspace ts1 storAGE dISk +ENGine nDb; + +DROP TABLE t1; + +AlteR TAblespaCE ts1 +droP DATAfile 'dAtAfiLe2.daT' +ENGINE=NDB; + +ALter tablesPACE ts1 +dROp dAtAfIlE 'datafile.dat' +ENGine=Ndb; + +DrOp TaBleSpAcE ts1 +engINE=ndB; + +DrOp lOgFiLe GrOuP lg1 +EnGiNe=nDb; + +--echo **** End Statment CaSe Testing **** +############ End CaSe Testing ################## +--echo +############ Begin = and no = Testing ########## +--echo **** Begin = And No = Testing **** + +CREATE LOGFILE GROUP lg1 +ADD UNDOFILE 'undofile.dat' +INITIAL_SIZE=1M +UNDO_BUFFER_SIZE=1M +ENGINE=NDB; + +ALTER LOGFILE GROUP lg1 +ADD UNDOFILE 'undofile02.dat' +INITIAL_SIZE=1M +ENGINE=NDB; + +CREATE TABLESPACE ts1 +ADD DATAFILE 'datafile.dat' +USE LOGFILE GROUP lg1 +INITIAL_SIZE=1M +ENGINE=NDB; + +ALTER TABLESPACE ts1 +ADD DATAFILE 'datafile2.dat' +INITIAL_SIZE=1M +ENGINE=NDB; + +CREATE TABLE t1 +(pk1 INT NOT NULL PRIMARY KEY, b INT NOT NULL, c INT NOT NULL) +TABLESPACE ts1 STORAGE DISK +ENGINE=NDB; + +DROP TABLE t1; + +ALTER TABLESPACE ts1 +DROP DATAFILE 'datafile2.dat' +ENGINE=NDB; + +ALTER TABLESPACE ts1 +DROP DATAFILE 'datafile.dat' +ENGINE=NDB; + +DROP TABLESPACE ts1 +ENGINE=NDB; + +DROP LOGFILE GROUP lg1 +ENGINE=NDB; + +--echo +--echo **** End of = **** +--echo + +CREATE LOGFILE GROUP lg1 +ADD UNDOFILE 'undofile.dat' +INITIAL_SIZE 1M +UNDO_BUFFER_SIZE 1M +ENGINE NDB; + +ALTER LOGFILE GROUP lg1 +ADD UNDOFILE 'undofile02.dat' +INITIAL_SIZE 1M +ENGINE NDB; + +CREATE TABLESPACE ts1 +ADD DATAFILE 'datafile.dat' +USE LOGFILE GROUP lg1 +INITIAL_SIZE 1M +ENGINE NDB; + +ALTER TABLESPACE ts1 +ADD DATAFILE 'datafile2.dat' +INITIAL_SIZE 1M +ENGINE NDB; + +--error 1005 +CREATE TABLE t1 +(pk1 INT NOT NULL PRIMARY KEY, b INT NOT NULL, c INT NOT NULL) +TABLESPACE ts1 STORAGE MEMORY +ENGINE NDB; + +CREATE TABLE t1 +(pk1 INT NOT NULL PRIMARY KEY, b INT NOT NULL, c INT NOT NULL) +TABLESPACE ts1 STORAGE DISK +ENGINE NDB; + + +CREATE INDEX b_i on t1(b); +CREATE INDEX bc_i on t1(b, c); + +DROP TABLE t1; + +# bug#20053 + +CREATE TABLESPACE ts2 +ADD DATAFILE 'datafile3.dat' +USE LOGFILE GROUP lg1 +INITIAL_SIZE 1M +ENGINE NDB; + +--error ER_ALTER_FILEGROUP_FAILED +ALTER TABLESPACE ts1 +DROP DATAFILE 'datafile3.dat' +ENGINE NDB; + +--error ER_ALTER_FILEGROUP_FAILED +ALTER TABLESPACE ts2 +DROP DATAFILE 'datafile2.dat' +ENGINE NDB; +# bug#20053 + +ALTER TABLESPACE ts1 +DROP DATAFILE 'datafile2.dat' +ENGINE NDB; + +ALTER TABLESPACE ts1 +DROP DATAFILE 'datafile.dat' +ENGINE NDB; + +DROP TABLESPACE ts1 +ENGINE NDB; + +ALTER TABLESPACE ts2 +DROP DATAFILE 'datafile3.dat' +ENGINE NDB; + +DROP TABLESPACE ts2 +ENGINE NDB; + +DROP LOGFILE GROUP lg1 +ENGINE NDB; + +--echo **** End = And No = **** +############ End = And No = ################## + +### +# +# bug#16341 +create table t1 (a int primary key) engine = myisam; + +--replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR +--error ER_CREATE_FILEGROUP_FAILED +--eval create logfile group lg1 add undofile '$MYSQLTEST_VARDIR/master-data/test/t1.frm' initial_size 1M undo_buffer_size = 1M engine=ndb; + +create logfile group lg1 +add undofile 'undofile.dat' +initial_size 1M +undo_buffer_size = 1M +engine=ndb; + +--replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR +--error ER_CREATE_FILEGROUP_FAILED +--eval create tablespace ts1 add datafile '$MYSQLTEST_VARDIR/master-data/test/t1.frm' use logfile group lg1 initial_size 1M engine ndb; + +--error ER_DROP_FILEGROUP_FAILED +drop tablespace ts1 +engine ndb; + +drop logfile group lg1 +engine ndb; + +drop table t1; + + + +# End 5.1 test diff --git a/mysql-test/suite/ndb/t/ndb_dd_disk2memory.test b/mysql-test/suite/ndb/t/ndb_dd_disk2memory.test new file mode 100644 index 00000000000..5975f44e087 --- /dev/null +++ b/mysql-test/suite/ndb/t/ndb_dd_disk2memory.test @@ -0,0 +1,292 @@ +######################################## +# Author: JBM +# Date: 2006-01-12 +# Purpose: To test using ndb memory and +# disk tables together. +######################################## + +-- source include/have_ndb.inc + +--disable_warnings +DROP TABLE IF EXISTS test.t1; +DROP TABLE IF EXISTS test.t2; +--enable_warnings + +############ Test Setup Section ############# +-- echo **** Test Setup Section **** + +CREATE LOGFILE GROUP log_group1 +ADD UNDOFILE './log_group1/undofile.dat' +INITIAL_SIZE 16M +UNDO_BUFFER_SIZE = 1M +ENGINE=NDB; + +CREATE TABLESPACE table_space1 +ADD DATAFILE './table_space1/datafile.dat' +USE LOGFILE GROUP log_group1 +INITIAL_SIZE 12M +ENGINE NDB; + + +CREATE TABLE test.t1 +(pk1 INT NOT NULL PRIMARY KEY, b INT NOT NULL, c INT NOT NULL) +TABLESPACE table_space1 STORAGE DISK +ENGINE=NDB; + +CREATE TABLE test.t2 +(pk2 INT NOT NULL PRIMARY KEY, b2 INT NOT NULL, c2 INT NOT NULL) +ENGINE=NDB; + +--echo +##################### Data load for first test #################### +--echo **** Data load for first test **** + +INSERT INTO test.t1 VALUES +(1,1,1),(2,2,2),(3,3,3),(4,4,4),(5,5,5), +(6,6,6),(7,7,7),(8,8,8),(9,9,9),(10,10,10), +(11,11,11),(12,12,12),(13,13,13),(14,14,14),(15,15,15), +(16,16,16),(17,17,17),(18,18,18),(19,19,19),(20,20,20), +(21,21,21),(22,22,22),(23,23,23),(24,24,24),(25,25,25), +(26,26,26),(27,27,27),(28,28,28),(29,29,29),(30,30,30), +(31,31,31),(32,32,32),(33,33,33),(34,34,34),(35,35,35), +(36,36,36),(37,37,37),(38,38,38),(39,39,39),(40,40,40), +(41,41,41),(42,42,42),(43,43,43),(44,44,44),(45,45,45), +(46,46,46),(47,47,47),(48,48,48),(49,49,49),(50,50,50), +(51,51,51),(52,52,52),(53,53,53),(54,54,54),(55,55,55), +(56,56,56),(57,57,57),(58,58,58),(59,59,59),(60,60,60), +(61,61,61),(62,62,62),(63,63,63),(64,64,64),(65,65,65), +(66,66,66),(67,67,67),(68,68,68),(69,69,69),(70,70,70), +(71,71,71),(72,72,72),(73,73,73),(74,74,74),(75,75,75); + + +INSERT INTO test.t2 VALUES +(1,1,1),(2,2,2),(3,3,3),(4,4,4),(5,5,5), +(6,6,6),(7,7,7),(8,8,8),(9,9,9),(10,10,10), +(11,11,11),(12,12,12),(13,13,13),(14,14,14),(15,15,15), +(16,16,16),(17,17,17),(18,18,18),(19,19,19),(20,20,20), +(21,21,21),(22,22,22),(23,23,23),(24,24,24),(25,25,25), +(26,26,26),(27,27,27),(28,28,28),(29,29,29),(30,30,30), +(31,31,31),(32,32,32),(33,33,33),(34,34,34),(35,35,35), +(36,36,36),(37,37,37),(38,38,38),(39,39,39),(40,40,40), +(41,41,41),(42,42,42),(43,43,43),(44,44,44),(45,45,45), +(46,46,46),(47,47,47),(48,48,48),(49,49,49),(50,50,50), +(51,51,51),(52,52,52),(53,53,53),(54,54,54),(55,55,55), +(56,56,56),(57,57,57),(58,58,58),(59,59,59),(60,60,60), +(61,61,61),(62,62,62),(63,63,63),(64,64,64),(65,65,65), +(66,66,66),(67,67,67),(68,68,68),(69,69,69),(70,70,70), +(71,71,71),(72,72,72),(73,73,73),(74,74,74),(75,75,75); + +--echo +##################### Test 1 Section Begins ############### +--echo *** Test 1 Section Begins *** +SELECT COUNT(*) FROM test.t2 LEFT JOIN test.t1 ON pk2=pk1 WHERE b2 IN (4); +SELECT * FROM test.t2 LEFT JOIN test.t1 ON pk2=pk1 WHERE b2 IN (4); +SELECT COUNT(*) FROM test.t1 LEFT JOIN test.t2 ON pk1=pk2 WHERE b IN (4); +SELECT COUNT(*) FROM test.t1 LEFT JOIN test.t2 ON b=b2 WHERE pk1 IN (75); +SELECT b, c FROM test.t1 LEFT JOIN test.t2 ON pk1=pk2 ORDER BY b; +--echo +####################### Test 1 Section End ################ + +##################### Setup for test 2 #################### +--echo *** Setup for test 2 **** +DELETE FROM test.t1; +INSERT INTO test.t1 VALUES +(1,1,1),(2,2,2),(3,3,3),(4,4,4),(5,5,5), +(6,6,6),(7,7,7),(8,8,8),(9,9,9),(10,10,10), +(11,11,11),(12,12,12),(13,13,13),(14,14,14),(15,15,15), +(16,16,16),(17,17,17),(18,18,18),(19,19,19),(20,20,20), +(21,21,21),(22,22,22),(23,23,23),(24,24,24),(25,25,25), +(26,26,26),(27,27,27),(28,28,28),(29,29,29),(30,30,30), +(31,31,31),(32,32,32),(33,33,33),(34,34,34),(35,35,35), +(36,36,36),(37,37,37),(38,38,38),(39,39,39),(40,40,40), +(41,41,41),(42,42,42),(43,43,43),(44,44,44),(45,45,45); +--echo +############################# Test Section 2 ############### +--echo **** Test Section 2 **** +SELECT b, c FROM test.t1 LEFT JOIN test.t2 ON pk1=pk2 ORDER BY b; +SELECT COUNT(*) FROM test.t1 LEFT JOIN test.t2 ON b=b2; +SELECT COUNT(*) FROM test.t1 RIGHT JOIN test.t2 ON b=b2; +SHOW CREATE TABLE test.t2; +SHOW CREATE TABLE test.t1; +ALTER TABLE test.t2 TABLESPACE table_space1 STORAGE DISK +ENGINE=NDB; +SHOW CREATE TABLE test.t2; +ALTER TABLE test.t1 STORAGE MEMORY ENGINE=NDBCLUSTER; +SHOW CREATE TABLE test.t1; +--echo +######################### End Test Section 2 ################# +DROP TABLE test.t1; +DROP TABLE test.t2; +##################### Setup for Test Section 3 ############### +--echo *** Setup for Test Section 3 *** +CREATE TABLE test.t1 ( + usr_id INT unsigned NOT NULL, + uniq_id INT unsigned NOT NULL AUTO_INCREMENT, + start_num INT unsigned NOT NULL DEFAULT 1, + increment INT unsigned NOT NULL DEFAULT 1, + PRIMARY KEY (uniq_id), + INDEX usr_uniq_idx (usr_id, uniq_id), + INDEX uniq_usr_idx (uniq_id, usr_id)) +TABLESPACE table_space1 STORAGE DISK +ENGINE=NDB; + + +CREATE TABLE test.t2 ( + id INT unsigned NOT NULL DEFAULT 0, + usr2_id INT unsigned NOT NULL DEFAULT 0, + max INT unsigned NOT NULL DEFAULT 0, + c_amount INT unsigned NOT NULL DEFAULT 0, + d_max INT unsigned NOT NULL DEFAULT 0, + d_num INT unsigned NOT NULL DEFAULT 0, + orig_time INT unsigned NOT NULL DEFAULT 0, + c_time INT unsigned NOT NULL DEFAULT 0, + active ENUM ("no","yes") NOT NULL, + PRIMARY KEY (id,usr2_id), + INDEX id_idx (id), + INDEX usr2_idx (usr2_id)) +ENGINE=NDB; + +INSERT INTO test.t1 VALUES (3,NULL,0,50),(3,NULL,0,200),(3,NULL,0,25),(3,NULL,0,84676),(3,NULL,0,235),(3,NULL,0,10),(3,NULL,0,3098),(3,NULL,0,2947),(3,NULL,0,8987),(3,NULL,0,8347654),(3,NULL,0,20398),(3,NULL,0,8976),(3,NULL,0,500),(3,NULL,0,198); + +--echo +###################### Test Section 3 ###################### +--echo **** Test Section 3 **** +SELECT test.t1.usr_id,test.t1.uniq_id,test.t1.increment, +test.t2.usr2_id,test.t2.c_amount,test.t2.max +FROM test.t1 +LEFT JOIN test.t2 ON test.t2.id = test.t1.uniq_id +WHERE test.t1.uniq_id = 4 +ORDER BY test.t2.c_amount; + +INSERT INTO test.t2 VALUES (2,3,3000,6000,0,0,746584,837484,'yes'); +INSERT INTO test.t2 VALUES (4,3,3000,6000,0,0,746584,837484,'yes'); +INSERT INTO test.t2 VALUES (7,3,1000,2000,0,0,746294,937484,'yes'); + +SELECT test.t1.usr_id,test.t1.uniq_id,test.t1.increment, +test.t2.usr2_id,test.t2.c_amount,test.t2.max +FROM test.t1 +LEFT JOIN test.t2 ON test.t2.id = test.t1.uniq_id +WHERE test.t1.uniq_id = 4 +ORDER BY test.t2.c_amount; +--echo +####################### End Section 3 ######################### +DROP TABLE test.t1; +DROP TABLE test.t2; + +########## Test that use to be in ndb_dd_advance.test ######### +########## ndb_dd_advance.test is now ndb_dd_alter.test ####### +#### Use group by asc and dec; Use having; Use order by. #### + +CREATE TABLE test.t1 ( + a1 smallint NOT NULL, + a2 int NOT NULL, + a3 bigint NOT NULL, + a4 char(10), + a5 decimal(5,1), + a6 time, + a7 date, + a8 datetime, + a9 VARCHAR(255), + a10 blob, + PRIMARY KEY(a1) +) TABLESPACE table_space1 STORAGE DISK ENGINE=NDB; + +CREATE TABLE test.t2 ( + b1 smallint NOT NULL, + b2 int NOT NULL, + b3 bigint NOT NULL, + b4 char(10), + b5 decimal(5,1), + b6 time, + b7 date, + b8 datetime, + b9 VARCHAR(255), + b10 blob, + PRIMARY KEY(b1) +) ENGINE=NDB; + +### ADD Some DATA to tables ###### + + +let $1=20; +disable_query_log; +while ($1) +{ + eval insert into test.t1 values($1, $1+1, $1+2000000000, "aaa$1", 34.2, '4:3:2', '2006-1-1', '1971-5-28 16:55:03', "bbbbbbbbbbbbb$1", "binary data"); + eval insert into test.t2 values($1+2, $1+3, $1+3000000000, "aaa$1", 35.2, '4:3:2', '2006-1-1', '1971-5-28 16:55:03', "bbbbbbbbbbbbb$1", "binary data"); + dec $1; +} + +ALTER TABLE test.t1 ADD INDEX (a2), ADD INDEX (a3), ADD INDEX (a8); +ALTER TABLE test.t2 ADD INDEX (b2), ADD INDEX (b3), ADD INDEX (b8); +SHOW CREATE TABLE test.t1; +SHOW CREATE TABLE test.t2; +SELECT * FROM test.t1 order by a1; +SELECT * FROM test.t2 order by b1; +SELECT COUNT(a1), a1, COUNT(a1)*a1 FROM test.t1 GROUP BY a1; +SELECT COUNT(a2), (a2+1), COUNT(a2)*(a2+0) FROM test.t1 GROUP BY a2; + +DROP TABLE test.t1; +DROP TABLE test.t2; + +CREATE TABLE test.t1 (a INT NOT NULL, +b CHAR(5), c TEXT, d INT NOT NULL PRIMARY KEY) TABLESPACE +table_space1 STORAGE DISK ENGINE=NDB; + +insert into test.t1 (a,b,c,d) values (1,'a','Jonas',1),(2,'b','Tomas',2), +(3,'c','Pekka',3),(4,'d','Martin',4),(5,'e','Stewart',5),(6,'f','Jeb',6), +(7,'g','Serge',7),(8,'h','Clavin',8); +select distinct a from test.t1 group by b,a having a > 4 order by a desc; +select distinct a,c from test.t1 group by b,c,a having a > 2 order by a desc; +select distinct a from test.t1 group by b,a having a > 1 order by a asc; +select distinct a,c from test.t1 group by b,c,a having a > 3 order by a asc; +drop table test.t1; + +create table test.t1 (a char(1), key(a)) TABLESPACE table_space1 +STORAGE DISK ENGINE=NDB; +insert into test.t1 values('1'),('1'),('1'),('2'),('2'),('3'),('3'); +select * from test.t1 where a >= '1' order by a; +select distinct a from test.t1 order by a desc; +select distinct a from test.t1 where a >= '1' order by a desc; +select distinct a from test.t1 where a >= '1' order by a asc; +drop table test.t1; + +CREATE TABLE test.t1 (email varchar(50), infoID BIGINT, dateentered DATETIME) +TABLESPACE table_space1 STORAGE DISK ENGINE=NDB; +CREATE TABLE test.t2 (infoID BIGINT, shipcode varchar(10)) ENGINE=NDB; + +INSERT INTO test.t1 (email, infoID, dateentered) VALUES + ('test1@testdomain.com', 1, '2002-07-30 22:56:38'), + ('test1@testdomain.com', 1, '2002-07-27 22:58:16'), + ('test2@testdomain.com', 1, '2002-06-19 15:22:19'), + ('test2@testdomain.com', 2, '2002-06-18 14:23:47'), + ('test3@testdomain.com', 1, '2002-05-19 22:17:32'); + +INSERT INTO test.t2(infoID, shipcode) VALUES + (1, 'Z001'), + (2, 'R002'); + +SELECT DISTINCTROW email, shipcode FROM test.t1, test.t2 +WHERE t1.infoID=t2.infoID order by email, shipcode; +SELECT DISTINCTROW email FROM test.t1 ORDER BY dateentered DESC; +SELECT DISTINCTROW email, shipcode FROM test.t1, test.t2 +WHERE test.t1.infoID=test.t2.infoID ORDER BY dateentered DESC; + +DROP TABLE test.t1,test.t2; + +################# +# Test Cleanup +################# + +ALTER TABLESPACE table_space1 +DROP DATAFILE './table_space1/datafile.dat' +ENGINE = NDB; + +DROP TABLESPACE table_space1 +ENGINE = NDB; + +DROP LOGFILE GROUP log_group1 +ENGINE =NDB; + +#End 5.1 test case + diff --git a/mysql-test/suite/ndb/t/ndb_dd_dump.test b/mysql-test/suite/ndb/t/ndb_dd_dump.test new file mode 100644 index 00000000000..38ceafb7d80 --- /dev/null +++ b/mysql-test/suite/ndb/t/ndb_dd_dump.test @@ -0,0 +1,288 @@ +-- source include/have_ndb.inc + +--disable_warnings +DROP TABLE IF EXISTS t1, t2, t3; +--enable_warnings + +CREATE LOGFILE GROUP lg1 +ADD UNDOFILE 'undofile_lg1_01.dat' +INITIAL_SIZE 2M +UNDO_BUFFER_SIZE = 1M +ENGINE NDB; + +ALTER LOGFILE GROUP lg1 +ADD UNDOFILE 'undofile_lg1_02.dat' +INITIAL_SIZE = 4M +ENGINE NDB; + +CREATE TABLESPACE ts1 +ADD DATAFILE 'datafile_ts1_01.dat' +USE LOGFILE GROUP lg1 +EXTENT_SIZE 1M +INITIAL_SIZE 2M +ENGINE NDB; + +ALTER TABLESPACE ts1 +ADD DATAFILE 'datafile_ts1_02.dat' +INITIAL_SIZE = 1M +ENGINE=NDB; + +CREATE TABLESPACE ts2 +ADD DATAFILE 'datafile_ts2_01.dat' +USE LOGFILE GROUP lg1 +INITIAL_SIZE 2M +ENGINE NDB; + +CREATE TABLESPACE ts3 +ADD DATAFILE 'datafile_ts3_01.dat' +USE LOGFILE GROUP lg1 +INITIAL_SIZE 4M +ENGINE NDB; + +######################################## +# Create a table using this tablespace +######################################## + +CREATE TABLE t1 +(pk1 INT NOT NULL PRIMARY KEY, b INT NOT NULL, c INT NOT NULL) +TABLESPACE ts1 STORAGE DISK +ENGINE=NDB; + +CREATE TABLE t2 +(pk1 INT NOT NULL PRIMARY KEY, b INT NOT NULL, c INT NOT NULL) +TABLESPACE ts2 STORAGE DISK +ENGINE=NDB; + +CREATE TABLE t3 +(pk1 INT NOT NULL PRIMARY KEY, b INT NOT NULL, c INT NOT NULL) +TABLESPACE ts3 STORAGE DISK +ENGINE=NDB; + +INSERT INTO t1 VALUES +(1,1,1),(2,2,2),(3,3,3),(4,4,4),(5,5,5), +(6,6,6),(7,7,7),(8,8,8),(9,9,9),(10,10,10), +(11,11,11),(12,12,12),(13,13,13),(14,14,14),(15,15,15), +(16,16,16),(17,17,17),(18,18,18),(19,19,19),(20,20,20), +(21,21,21),(22,22,22),(23,23,23),(24,24,24),(25,25,25), +(26,26,26),(27,27,27),(28,28,28),(29,29,29),(30,30,30), +(31,31,31),(32,32,32),(33,33,33),(34,34,34),(35,35,35), +(36,36,36),(37,37,37),(38,38,38),(39,39,39),(40,40,40), +(41,41,41),(42,42,42),(43,43,43),(44,44,44),(45,45,45), +(46,46,46),(47,47,47),(48,48,48),(49,49,49),(50,50,50), +(51,51,51),(52,52,52),(53,53,53),(54,54,54),(55,55,55), +(56,56,56),(57,57,57),(58,58,58),(59,59,59),(60,60,60), +(61,61,61),(62,62,62),(63,63,63),(64,64,64),(65,65,65), +(66,66,66),(67,67,67),(68,68,68),(69,69,69),(70,70,70), +(71,71,71),(72,72,72),(73,73,73),(74,74,74),(75,75,75), +(76,76,76),(77,77,77),(78,78,78),(79,79,79),(80,80,80), +(81,81,81),(82,82,82),(83,83,83),(84,84,84),(85,85,85), +(86,86,86),(87,87,87),(88,88,88),(89,89,89),(90,90,90), +(91,91,91),(92,92,92),(93,93,93),(94,94,94),(95,95,95), +(96,96,96),(97,97,97),(98,98,98),(99,99,99),(100,100,100), +(101,101,101),(102,102,102),(103,103,103),(104,104,104),(105,105,105), +(106,106,106),(107,107,107),(108,108,108),(109,109,109),(110,110,110), +(111,111,111),(112,112,112),(113,113,113),(114,114,114),(115,115,115), +(116,116,116),(117,117,117),(118,118,118),(119,119,119),(120,120,120), +(121,121,121),(122,122,122),(123,123,123),(124,124,124),(125,125,125), +(126,126,126),(127,127,127),(128,128,128),(129,129,129),(130,130,130), +(131,131,131),(132,132,132),(133,133,133),(134,134,134),(135,135,135), +(136,136,136),(137,137,137),(138,138,138),(139,139,139),(140,140,140), +(141,141,141),(142,142,142),(143,143,143),(144,144,144),(145,145,145), +(146,146,146),(147,147,147),(148,148,148),(149,149,149),(150,150,150), +(151,151,151),(152,152,152),(153,153,153),(154,154,154),(155,155,155), +(156,156,156),(157,157,157),(158,158,158),(159,159,159),(160,160,160), +(161,161,161),(162,162,162),(163,163,163),(164,164,164),(165,165,165), +(166,166,166),(167,167,167),(168,168,168),(169,169,169),(170,170,170), +(171,171,171),(172,172,172),(173,173,173),(174,174,174),(175,175,175), +(176,176,176),(177,177,177),(178,178,178),(179,179,179),(180,180,180), +(181,181,181),(182,182,182),(183,183,183),(184,184,184),(185,185,185), +(186,186,186),(187,187,187),(188,188,188),(189,189,189),(190,190,190), +(191,191,191),(192,192,192),(193,193,193),(194,194,194),(195,195,195), +(196,196,196),(197,197,197),(198,198,198),(199,199,199),(200,200,200), +(201,201,201),(202,202,202),(203,203,203),(204,204,204),(205,205,205), +(206,206,206),(207,207,207),(208,208,208),(209,209,209),(210,210,210), +(211,211,211),(212,212,212),(213,213,213),(214,214,214),(215,215,215), +(216,216,216),(217,217,217),(218,218,218),(219,219,219),(220,220,220), +(221,221,221),(222,222,222),(223,223,223),(224,224,224),(225,225,225), +(226,226,226),(227,227,227),(228,228,228),(229,229,229),(230,230,230), +(231,231,231),(232,232,232),(233,233,233),(234,234,234),(235,235,235), +(236,236,236),(237,237,237),(238,238,238),(239,239,239),(240,240,240), +(241,241,241),(242,242,242),(243,243,243),(244,244,244),(245,245,245), +(246,246,246),(247,247,247),(248,248,248),(249,249,249),(250,250,250), +(251,251,251),(252,252,252),(253,253,253),(254,254,254),(255,255,255), +(256,256,256),(257,257,257),(258,258,258),(259,259,259),(260,260,260), +(261,261,261),(262,262,262),(263,263,263),(264,264,264),(265,265,265), +(266,266,266),(267,267,267),(268,268,268),(269,269,269),(270,270,270), +(271,271,271),(272,272,272),(273,273,273),(274,274,274),(275,275,275), +(276,276,276),(277,277,277),(278,278,278),(279,279,279),(280,280,280), +(281,281,281),(282,282,282),(283,283,283),(284,284,284),(285,285,285), +(286,286,286),(287,287,287),(288,288,288),(289,289,289),(290,290,290), +(291,291,291),(292,292,292),(293,293,293),(294,294,294),(295,295,295), +(296,296,296),(297,297,297),(298,298,298),(299,299,299),(300,300,300), +(301,301,301),(302,302,302),(303,303,303),(304,304,304),(305,305,305), +(306,306,306),(307,307,307),(308,308,308),(309,309,309),(310,310,310), +(311,311,311),(312,312,312),(313,313,313),(314,314,314),(315,315,315), +(316,316,316),(317,317,317),(318,318,318),(319,319,319),(320,320,320), +(321,321,321),(322,322,322),(323,323,323),(324,324,324),(325,325,325), +(326,326,326),(327,327,327),(328,328,328),(329,329,329),(330,330,330), +(331,331,331),(332,332,332),(333,333,333),(334,334,334),(335,335,335), +(336,336,336),(337,337,337),(338,338,338),(339,339,339),(340,340,340), +(341,341,341),(342,342,342),(343,343,343),(344,344,344),(345,345,345), +(346,346,346),(347,347,347),(348,348,348),(349,349,349),(350,350,350), +(351,351,351),(352,352,352),(353,353,353),(354,354,354),(355,355,355), +(356,356,356),(357,357,357),(358,358,358),(359,359,359),(360,360,360), +(361,361,361),(362,362,362),(363,363,363),(364,364,364),(365,365,365), +(366,366,366),(367,367,367),(368,368,368),(369,369,369),(370,370,370), +(371,371,371),(372,372,372),(373,373,373),(374,374,374),(375,375,375), +(376,376,376),(377,377,377),(378,378,378),(379,379,379),(380,380,380), +(381,381,381),(382,382,382),(383,383,383),(384,384,384),(385,385,385), +(386,386,386),(387,387,387),(388,388,388),(389,389,389),(390,390,390), +(391,391,391),(392,392,392),(393,393,393),(394,394,394),(395,395,395), +(396,396,396),(397,397,397),(398,398,398),(399,399,399),(400,400,400), +(401,401,401),(402,402,402),(403,403,403),(404,404,404),(405,405,405), +(406,406,406),(407,407,407),(408,408,408),(409,409,409),(410,410,410), +(411,411,411),(412,412,412),(413,413,413),(414,414,414),(415,415,415), +(416,416,416),(417,417,417),(418,418,418),(419,419,419),(420,420,420), +(421,421,421),(422,422,422),(423,423,423),(424,424,424),(425,425,425), +(426,426,426),(427,427,427),(428,428,428),(429,429,429),(430,430,430), +(431,431,431),(432,432,432),(433,433,433),(434,434,434),(435,435,435), +(436,436,436),(437,437,437),(438,438,438),(439,439,439),(440,440,440), +(441,441,441),(442,442,442),(443,443,443),(444,444,444),(445,445,445), +(446,446,446),(447,447,447),(448,448,448),(449,449,449),(450,450,450), +(451,451,451),(452,452,452),(453,453,453),(454,454,454),(455,455,455), +(456,456,456),(457,457,457),(458,458,458),(459,459,459),(460,460,460), +(461,461,461),(462,462,462),(463,463,463),(464,464,464),(465,465,465), +(466,466,466),(467,467,467),(468,468,468),(469,469,469),(470,470,470), +(471,471,471),(472,472,472),(473,473,473),(474,474,474),(475,475,475), +(476,476,476),(477,477,477),(478,478,478),(479,479,479),(480,480,480), +(481,481,481),(482,482,482),(483,483,483),(484,484,484),(485,485,485), +(486,486,486),(487,487,487),(488,488,488),(489,489,489),(490,490,490), +(491,491,491),(492,492,492),(493,493,493),(494,494,494),(495,495,495), +(496,496,496),(497,497,497),(498,498,498),(499,499,499),(500, 500, 500); + +INSERT INTO t2 VALUES +(1,1,1),(2,2,2),(3,3,3),(4,4,4),(5,5,5); + +INSERT INTO t3 VALUES +(1,1,1); + +--exec $MYSQL_DUMP --skip-comments --compact -Y test > $MYSQLTEST_VARDIR/tmp/ndb_dd_dump.sql + +DROP TABLE t1; +DROP TABLE t2; +DROP TABLE t3; + +ALTER TABLESPACE ts1 +DROP DATAFILE 'datafile_ts1_01.dat' +ENGINE = NDB; + +ALTER TABLESPACE ts1 +DROP DATAFILE 'datafile_ts1_02.dat' +ENGINE = NDB; + +ALTER TABLESPACE ts2 +DROP DATAFILE 'datafile_ts2_01.dat' +ENGINE = NDB; + +ALTER TABLESPACE ts3 +DROP DATAFILE 'datafile_ts3_01.dat' +ENGINE = NDB; + +DROP TABLESPACE ts1 ENGINE = NDB; +DROP TABLESPACE ts2 ENGINE = NDB; +DROP TABLESPACE ts3 ENGINE = NDB; + +DROP LOGFILE GROUP lg1 ENGINE = NDB; + +--exec $MYSQL test < $MYSQLTEST_VARDIR/tmp/ndb_dd_dump.sql + +SELECT DISTINCT + LOGFILE_GROUP_NAME, + FILE_NAME, + TOTAL_EXTENTS, + INITIAL_SIZE, + ENGINE +FROM INFORMATION_SCHEMA.FILES WHERE FILE_TYPE="UNDO LOG" ORDER BY FILE_NAME; + +SELECT DISTINCT + TABLESPACE_NAME, + LOGFILE_GROUP_NAME, + FILE_NAME, + EXTENT_SIZE, + INITIAL_SIZE, + ENGINE +FROM INFORMATION_SCHEMA.FILES WHERE FILE_TYPE="DATAFILE" ORDER BY FILE_NAME; + +SELECT COUNT(*) FROM t1; +SELECT COUNT(*) FROM t2; +SELECT COUNT(*) FROM t3; + +DROP TABLE t1; +DROP TABLE t2; +DROP TABLE t3; + +#### BUG 18856 test case comented out +##### Use "SELECT * INTO OUTFILE" to dump data and "LOAD DATA INFILE" to load ##### data back to the data file. + +#CREATE TABLE test.t ( +# a smallint NOT NULL, +# b int NOT NULL, +# c bigint NOT NULL, +# d char(10), +# e TEXT, +# f VARCHAR(255), +# PRIMARY KEY(a) +#) TABLESPACE ts1 STORAGE DISK ENGINE=NDB; + +# ALTER TABLE test.t ADD INDEX (d), ADD INDEX (f); +# SHOW CREATE TABLE test.t; + +# insert records into tables + +# let $1=100; +# disable_query_log; +# while ($1) +# { +# eval insert into test.t values($1, $1+1, $1+2, "aaa$1", "bbb$1", "ccccc$1"); +# dec $1; +# } +# enable_query_log; + +# SELECT * FROM test.t order by a; + +# SELECT * INTO OUTFILE 't_backup' FROM test.t; +# TRUNCATE test.t; + +#'TRUNCATE test.t' failed: 1205: Lock wait timeout exceeded; try restarting #transaction. TABLESPACE ts STORAGE DISK ENGINE=NDB; + +# SELECT count(*) FROM test.t; +# LOAD DATA INFILE 't_backup' INTO TABLE test.t; + +# SELECT * FROM test.t order by a; + +# DROP TABLE test.t; + + +ALTER TABLESPACE ts1 +DROP DATAFILE 'datafile_ts1_01.dat' +ENGINE = NDB; + +ALTER TABLESPACE ts1 +DROP DATAFILE 'datafile_ts1_02.dat' +ENGINE = NDB; + +ALTER TABLESPACE ts2 +DROP DATAFILE 'datafile_ts2_01.dat' +ENGINE = NDB; + +ALTER TABLESPACE ts3 +DROP DATAFILE 'datafile_ts3_01.dat' +ENGINE = NDB; + +DROP TABLESPACE ts1 ENGINE = NDB; +DROP TABLESPACE ts2 ENGINE = NDB; +DROP TABLESPACE ts3 ENGINE = NDB; + +DROP LOGFILE GROUP lg1 ENGINE = NDB; + +#End 5.1 test case diff --git a/mysql-test/suite/ndb/t/ndb_dd_sql_features.test b/mysql-test/suite/ndb/t/ndb_dd_sql_features.test new file mode 100644 index 00000000000..f46cb217ab4 --- /dev/null +++ b/mysql-test/suite/ndb/t/ndb_dd_sql_features.test @@ -0,0 +1,551 @@ +############################################################## +# Author: Nikolay +# Date: 2006-04-01 +# Purpose: Specific Blob and Varchar testing using disk tables. +############################################################## +# Create Stored procedures that use disk based tables. +# Create function that operate on disk based tables. +# Create triggers that operate on disk based tables. +# Create views that operate on disk based tables. +# Try to create FK constraints on disk based tables. +# Create and use disk based table that use auto inc. +# Create test that use transaction (commit, rollback) +# Create large disk base table, do random queries, check cache hits, +# do same query 10 times check cache hits. +# Create test that uses COUNT(), SUM(), MAX(), MIN(), +# NOW(), USER(), ... other built in # SQL functions +# Create test that uses locks. +# Create test using truncate. +############################################################## +# Author: Jonathan +# Date: 2006-08-28 +# Change: Remove all the create and drop LFG and TS except +# The first create and the last drop to make test +# run faster. +# In addition, renamed test to be to a name that +# gives a better idea of what the test is about +########################################################### +-- source include/have_ndb.inc + +--disable_warnings +DROP TABLE IF EXISTS test.t1; +DROP TABLE IF EXISTS test.t2; +DROP TABLE IF EXISTS test.t3; +--enable_warnings + +#### Copy data from table in one table space to table in ### +#### different table space. #### +--echo ***** +--echo **** Copy data from table in one table space to table +--echo **** in different table space +--echo ***** + + CREATE LOGFILE GROUP lg + ADD UNDOFILE './lg_group/undofile.dat' + INITIAL_SIZE 16M + UNDO_BUFFER_SIZE = 1M + ENGINE=NDB; + + CREATE TABLESPACE ts1 + ADD DATAFILE './table_space1/datafile.dat' + USE LOGFILE GROUP lg + INITIAL_SIZE 25M + ENGINE NDB; + + CREATE TABLESPACE ts2 + ADD DATAFILE './table_space2/datafile.dat' + USE LOGFILE GROUP lg + INITIAL_SIZE 20M + ENGINE NDB; + + CREATE TABLE test.t1 (a1 int NOT NULL PRIMARY KEY, a2 VARCHAR(256), a3 BLOB) + TABLESPACE ts1 STORAGE DISK ENGINE=NDB; + CREATE TABLE test.t2 (a1 int NOT NULL PRIMARY KEY, a2 VARCHAR(256), a3 BLOB) + TABLESPACE ts2 STORAGE DISK ENGINE=NDB; + + SHOW CREATE TABLE test.t1; + SHOW CREATE TABLE test.t2; + + INSERT INTO test.t1 VALUES (1,'111111','aaaaaaaa'); + INSERT INTO test.t1 VALUES (2,'222222','bbbbbbbb'); + SELECT * FROM test.t1 ORDER BY a1; + INSERT INTO test.t2(a1,a2,a3) SELECT * FROM test.t1; + SELECT * FROM test.t2 ORDER BY a1; + + DROP TABLE test.t1, test.t2; + + # populate BLOB field with large data + +set @vc1 = repeat('a', 200); +set @vc2 = repeat('b', 500); +set @vc3 = repeat('c', 1000); +set @vc4 = repeat('d', 4000); + +# x0 size 256 +set @x0 = '01234567012345670123456701234567'; +set @x0 = concat(@x0,@x0,@x0,@x0,@x0,@x0,@x0,@x0); + +# b1 length 2000+256 +set @b1 = 'b1'; +set @b1 = concat(@b1,@b1,@b1,@b1,@b1,@b1,@b1,@b1,@b1,@b1); +set @b1 = concat(@b1,@b1,@b1,@b1,@b1,@b1,@b1,@b1,@b1,@b1); +set @b1 = concat(@b1,@b1,@b1,@b1,@b1,@b1,@b1,@b1,@b1,@b1); +set @b1 = concat(@b1,@x0); +# d1 length 3000 +set @d1 = 'dd1'; +set @d1 = concat(@d1,@d1,@d1,@d1,@d1,@d1,@d1,@d1,@d1,@d1); +set @d1 = concat(@d1,@d1,@d1,@d1,@d1,@d1,@d1,@d1,@d1,@d1); +set @d1 = concat(@d1,@d1,@d1,@d1,@d1,@d1,@d1,@d1,@d1,@d1); + +# b2 length 20000 +set @b2 = 'b2'; +set @b2 = concat(@b2,@b2,@b2,@b2,@b2,@b2,@b2,@b2,@b2,@b2); +set @b2 = concat(@b2,@b2,@b2,@b2,@b2,@b2,@b2,@b2,@b2,@b2); +set @b2 = concat(@b2,@b2,@b2,@b2,@b2,@b2,@b2,@b2,@b2,@b2); +set @b2 = concat(@b2,@b2,@b2,@b2,@b2,@b2,@b2,@b2,@b2,@b2); +# d2 length 30000 +set @d2 = 'dd2'; +set @d2 = concat(@d2,@d2,@d2,@d2,@d2,@d2,@d2,@d2,@d2,@d2); +set @d2 = concat(@d2,@d2,@d2,@d2,@d2,@d2,@d2,@d2,@d2,@d2); +set @d2 = concat(@d2,@d2,@d2,@d2,@d2,@d2,@d2,@d2,@d2,@d2); +set @d2 = concat(@d2,@d2,@d2,@d2,@d2,@d2,@d2,@d2,@d2,@d2); + +select length(@x0),length(@b1),length(@d1) from dual; +select length(@x0),length(@b2),length(@d2) from dual; + + CREATE TABLE test.t1 (a1 int NOT NULL PRIMARY KEY, a2 VARCHAR(5000), a3 BLOB) + TABLESPACE ts1 STORAGE DISK ENGINE=NDB; + CREATE TABLE test.t2 (a1 int NOT NULL PRIMARY KEY, a2 VARCHAR(5000), a3 BLOB) + TABLESPACE ts2 STORAGE DISK ENGINE=NDB; + + SHOW CREATE TABLE test.t1; + SHOW CREATE TABLE test.t2; + + INSERT INTO test.t1 VALUES (1,@vc1,@d1); + INSERT INTO test.t1 VALUES (2,@vc2,@b1); + INSERT INTO test.t1 VALUES (3,@vc3,@d2); + INSERT INTO test.t1 VALUES (4,@vc4,@b2); + + SELECT a1,length(a2),substr(a2,180,2),length(a3),substr(a3,1+3*900,3) + FROM test.t1 WHERE a1=1; + SELECT a1,length(a2),substr(a2,480,2),length(a3),substr(a3,1+2*900,3) + FROM test.t1 where a1=2; + + INSERT INTO test.t2(a1,a2,a3) SELECT * FROM test.t1; + SELECT a1,length(a2),substr(a2,180,2),length(a3),substr(a3,1+3*900,3) + FROM test.t2 WHERE a1=1; + SELECT a1,length(a2),substr(a2,480,2),length(a3),substr(a3,1+2*900,3) + FROM test.t2 where a1=2; + + + DROP TABLE test.t1, test.t2; + +#### Insert, Update, Delete from NDB table with BLOB fields #### +--echo ***** +--echo **** Insert, Update, Delete from NDB table with BLOB fields +--echo ***** + +set @vc1 = repeat('a', 200); +set @vc2 = repeat('b', 500); +set @vc3 = repeat('c', 1000); +set @vc4 = repeat('d', 4000); +set @vc5 = repeat('d', 5000); + +set @bb1 = repeat('1', 2000); +set @bb2 = repeat('2', 5000); +set @bb3 = repeat('3', 10000); +set @bb4 = repeat('4', 40000); +set @bb5 = repeat('5', 50000); + +select length(@vc1),length(@vc2),length(@vc3),length(@vc4),length(@vc5) +from dual; +select length(@bb1),length(@bb2),length(@bb3),length(@bb4),length(@bb5) +from dual; + + CREATE TABLE test.t1 (a1 int NOT NULL PRIMARY KEY, a2 VARCHAR(5000), a3 BLOB) + TABLESPACE ts1 STORAGE DISK ENGINE=NDB; +# CREATE TABLE test.t2 (a1 int NOT NULL, a2 VARCHAR(5000), a3 BLOB) +# TABLESPACE ts2 STORAGE DISK ENGINE=NDB; + + INSERT INTO test.t1 VALUES (1,@vc1,@bb1); + INSERT INTO test.t1 VALUES (2,@vc2,@bb2); + INSERT INTO test.t1 VALUES (3,@vc3,@bb3); + INSERT INTO test.t1 VALUES (4,@vc4,@bb4); + INSERT INTO test.t1 VALUES (5,@vc5,@bb5); + + UPDATE test.t1 SET a2=@vc5, a3=@bb5 WHERE a1=1; + SELECT a1,length(a2),substr(a2,4998,2),length(a3),substr(a3,49997,3) + FROM test.t1 WHERE a1=1; + + UPDATE test.t1 SET a2=@vc4, a3=@bb4 WHERE a1=2; + SELECT a1,length(a2),substr(a2,3998,2),length(a3),substr(a3,39997,3) + FROM test.t1 WHERE a1=2; + + UPDATE test.t1 SET a2=@vc2, a3=@bb2 WHERE a1=3; + SELECT a1,length(a2),substr(a2,498,2),length(a3),substr(a3,3997,3) + FROM test.t1 WHERE a1=3; + + UPDATE test.t1 SET a2=@vc3, a3=@bb3 WHERE a1=4; + SELECT a1,length(a2),substr(a2,998,2),length(a3),substr(a3,9997,3) + FROM test.t1 WHERE a1=4; + + UPDATE test.t1 SET a2=@vc1, a3=@bb1 WHERE a1=5; + SELECT a1,length(a2),substr(a2,198,2),length(a3),substr(a3,1997,3) + FROM test.t1 WHERE a1=5; + + DELETE FROM test.t1 where a1=5; + SELECT count(*) from test.t1; + DELETE FROM test.t1 where a1=4; + SELECT count(*) from test.t1; + DELETE FROM test.t1 where a1=3; + SELECT count(*) from test.t1; + DELETE FROM test.t1 where a1=2; + SELECT count(*) from test.t1; + DELETE FROM test.t1 where a1=1; + SELECT count(*) from test.t1; + + DROP TABLE test.t1; + +##### Create Stored procedures that use disk based tables ##### +--echo ***** +--echo **** Create Stored procedures that use disk based tables +--echo ***** + +delimiter //; + CREATE TABLE test.t1 (a1 int NOT NULL PRIMARY KEY, a2 VARCHAR(256), a3 BLOB) + TABLESPACE ts1 STORAGE DISK ENGINE=NDB// + CREATE PROCEDURE test.sp1() + BEGIN + INSERT INTO test.t1 values (1,'111111','aaaaaaaa'); + END// +delimiter ;// + + CALL test.sp1(); + SELECT * FROM test.t1; + +delimiter //; + CREATE PROCEDURE test.sp2(n INT, vc VARCHAR(256), blb BLOB) + BEGIN + UPDATE test.t1 SET a2=vc, a3=blb where a1=n; + END// +delimiter ;// + + CALL test.sp2(1,'222222','bbbbbbbb'); + SELECT * FROM test.t1; + + DELETE FROM test.t1; + DROP PROCEDURE test.sp1; + DROP PROCEDURE test.sp2; + DROP TABLE test.t1; + + +#### Create function that operate on disk based tables #### +--echo ***** +--echo ***** Create function that operate on disk based tables +--echo ***** + + CREATE TABLE test.t1 (a1 int NOT NULL PRIMARY KEY, a2 VARCHAR(256), a3 BLOB) + TABLESPACE ts1 STORAGE DISK ENGINE=NDB; + let $1=100; + disable_query_log; + while ($1) + { + eval insert into test.t1 values($1, "aaaaa$1", "bbbbb$1"); + dec $1; + } + enable_query_log; + + delimiter //; + CREATE FUNCTION test.fn1(n INT) RETURNS INT + BEGIN + DECLARE v INT; + SELECT a1 INTO v FROM test.t1 WHERE a1=n; + RETURN v; + END// + delimiter ;// + +delimiter //; + CREATE FUNCTION test.fn2(n INT, blb BLOB) RETURNS BLOB + BEGIN + DECLARE vv BLOB; + UPDATE test.t1 SET a3=blb where a1=n; + SELECT a3 INTO vv FROM test.t1 WHERE a1=n; + RETURN vv; + END// + delimiter ;// + + SELECT test.fn1(10) FROM DUAL; + SELECT test.fn2(50, 'new BLOB content') FROM DUAL; + + DELETE FROM test.t1; + DROP FUNCTION test.fn1; + DROP FUNCTION test.fn2; + DROP TABLE test.t1; + +#### Create triggers that operate on disk based tables #### +--echo ***** +--echo ***** Create triggers that operate on disk based tables +--echo ***** + + CREATE TABLE test.t1 (a1 int NOT NULL PRIMARY KEY, a2 VARCHAR(256), a3 BLOB) + TABLESPACE ts1 STORAGE DISK ENGINE=NDB; + + delimiter //; + CREATE TRIGGER test.trg1 BEFORE INSERT ON test.t1 FOR EACH ROW + BEGIN + if isnull(new.a2) then + set new.a2:= 'trg1 works on a2 field'; + end if; + if isnull(new.a3) then + set new.a3:= 'trg1 works on a3 field'; + end if; + end// + insert into test.t1 (a1) values (1)// + insert into test.t1 (a1,a2) values (2, 'ccccccc')// + select * from test.t1 order by a1// + delimiter ;// + + DELETE FROM test.t1; + DROP TRIGGER test.trg1; + DROP TABLE test.t1; + +#### Create, update views that operate on disk based tables #### +--echo ***** +--echo ***** Create, update views that operate on disk based tables +--echo ***** + + + CREATE TABLE test.t1 (a1 int NOT NULL PRIMARY KEY, a2 VARCHAR(256), a3 BLOB) + TABLESPACE ts1 STORAGE DISK ENGINE=NDB; + let $1=10; + disable_query_log; + while ($1) + { + eval insert into test.t1 values($1, "aaaaa$1", "bbbbb$1"); + dec $1; + } + enable_query_log; + CREATE VIEW test.v1 AS SELECT * FROM test.t1; + SELECT * FROM test.v1 order by a1; + CHECK TABLE test.v1, test.t1; + + UPDATE test.v1 SET a2='zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz' WHERE a1=5; + SELECT * FROM test.v1 order by a1; + + DROP VIEW test.v1; + DELETE FROM test.t1; + DROP TABLE test.t1; + +#### Create and use disk based table that use auto inc #### +--echo ***** +--echo ***** Create and use disk based table that use auto inc +--echo ***** + + CREATE TABLE test.t1 (a1 INT NOT NULL AUTO_INCREMENT PRIMARY KEY, + a2 VARCHAR(256), a3 BLOB) + TABLESPACE ts1 STORAGE DISK ENGINE=NDB; + let $1=10; + disable_query_log; + while ($1) + { + eval insert into test.t1 values(NULL, "aaaaa$1", "bbbbb$1"); + dec $1; + } + enable_query_log; + SELECT * FROM test.t1 ORDER BY a1; + DELETE FROM test.t1; + DROP TABLE test.t1; + + +#### Create test that use transaction (commit, rollback) #### +--echo ***** +--echo ***** Create test that use transaction (commit, rollback) +--echo ***** + + SET AUTOCOMMIT=0; + CREATE TABLE test.t1 (a1 INT NOT NULL AUTO_INCREMENT PRIMARY KEY, + a2 VARCHAR(256), a3 BLOB) + TABLESPACE ts1 STORAGE DISK ENGINE=NDB; + + INSERT INTO test.t1 VALUES(NULL, "aaaaa1", "bbbbb1"); + COMMIT; + SELECT * FROM test.t1 ORDER BY a1; + INSERT INTO test.t1 VALUES(NULL, "aaaaa2", "bbbbb2"); + ROLLBACK; + SELECT * FROM test.t1 ORDER BY a1; + + DELETE FROM test.t1; + DROP TABLE test.t1; + SET AUTOCOMMIT=1; + +# Now do the same thing with START TRANSACTION without using AUTOCOMMIT. + + CREATE TABLE test.t1 (a1 INT NOT NULL AUTO_INCREMENT PRIMARY KEY, + a2 VARCHAR(256), a3 BLOB) + TABLESPACE ts1 STORAGE DISK ENGINE=NDB; + + START TRANSACTION; + INSERT INTO test.t1 VALUES(NULL, "aaaaa1", "bbbbb1"); + COMMIT; + SELECT * FROM test.t1 ORDER BY a1; + + START TRANSACTION; + INSERT INTO test.t1 VALUES(NULL, "aaaaa2", "bbbbb2"); + ROLLBACK; + SELECT * FROM test.t1 ORDER BY a1; + + DELETE FROM test.t1; + DROP TABLE test.t1; + +#### Create test that uses locks #### +--echo ***** +--echo ***** Create test that uses locks +--echo ***** + + connect (con1,localhost,root,,); + connect (con2,localhost,root,,); + +# connection con1; +--disable_warnings + drop table if exists test.t1; + CREATE TABLE test.t1 (a1 INT NOT NULL AUTO_INCREMENT PRIMARY KEY, + a2 VARCHAR(256), a3 BLOB) + TABLESPACE ts1 STORAGE DISK ENGINE=NDB; +--enable_warnings + + LOCK TABLES test.t1 write; + INSERT INTO test.t1 VALUES(NULL, "aaaaa1", "bbbbb1"); + INSERT INTO test.t1 VALUES(NULL, "aaaaa2", "bbbbb2"); + SELECT * FROM test.t1 ORDER BY a1; + + connection con2; + SELECT * FROM test.t1 ORDER BY a1; + INSERT INTO test.t1 VALUES(NULL, "aaaaa3", "bbbbb3"); + + connection con1; + UNLOCK TABLES; + + connection con2; + INSERT INTO test.t1 VALUES(NULL, "aaaaa3", "bbbbb3"); + SELECT * FROM test.t1 ORDER BY a1; + DELETE FROM test.t1; + DROP TABLE test.t1; + + #connection defualt; + +#### Create large disk base table, do random queries, check cache hits #### +--echo ***** +--echo ***** Create large disk base table, do random queries, check cache hits +--echo ***** + +set @vc1 = repeat('a', 200); +SELECT @vc1 FROM DUAL; +set @vc2 = repeat('b', 500); +set @vc3 = repeat('b', 998); + +# x0 size 256 +set @x0 = '01234567012345670123456701234567'; +set @x0 = concat(@x0,@x0,@x0,@x0,@x0,@x0,@x0,@x0); + +# b1 length 2000+256 (blob part aligned) +set @b1 = 'b1'; +set @b1 = concat(@b1,@b1,@b1,@b1,@b1,@b1,@b1,@b1,@b1,@b1); +set @b1 = concat(@b1,@b1,@b1,@b1,@b1,@b1,@b1,@b1,@b1,@b1); +set @b1 = concat(@b1,@b1,@b1,@b1,@b1,@b1,@b1,@b1,@b1,@b1); +set @b1 = concat(@b1,@x0); +# d1 length 3000 +set @d1 = 'dd1'; +set @d1 = concat(@d1,@d1,@d1,@d1,@d1,@d1,@d1,@d1,@d1,@d1); +set @d1 = concat(@d1,@d1,@d1,@d1,@d1,@d1,@d1,@d1,@d1,@d1); +set @d1 = concat(@d1,@d1,@d1,@d1,@d1,@d1,@d1,@d1,@d1,@d1); + +# b2 length 20000 +set @b2 = 'b2'; +set @b2 = concat(@b2,@b2,@b2,@b2,@b2,@b2,@b2,@b2,@b2,@b2); +set @b2 = concat(@b2,@b2,@b2,@b2,@b2,@b2,@b2,@b2,@b2,@b2); +set @b2 = concat(@b2,@b2,@b2,@b2,@b2,@b2,@b2,@b2,@b2,@b2); +set @b2 = concat(@b2,@b2,@b2,@b2,@b2,@b2,@b2,@b2,@b2,@b2); +# d2 length 30000 +set @d2 = 'dd2'; +set @d2 = concat(@d2,@d2,@d2,@d2,@d2,@d2,@d2,@d2,@d2,@d2); +set @d2 = concat(@d2,@d2,@d2,@d2,@d2,@d2,@d2,@d2,@d2,@d2); +set @d2 = concat(@d2,@d2,@d2,@d2,@d2,@d2,@d2,@d2,@d2,@d2); +set @d2 = concat(@d2,@d2,@d2,@d2,@d2,@d2,@d2,@d2,@d2,@d2); + +select length(@x0),length(@b1),length(@d1) from dual; +select length(@x0),length(@b2),length(@d2) from dual; + + CREATE TABLE test.t1 (a1 int NOT NULL PRIMARY KEY, a2 VARCHAR(1000), a3 BLOB) + TABLESPACE ts1 STORAGE DISK ENGINE=NDB; + + INSERT INTO test.t1 values(1,@vc1,@d1); + INSERT INTO test.t1 values(2,@vc2,@d2); + --replace_column 9 # + explain SELECT * from test.t1 WHERE a1 = 1; + + SELECT a1,length(a2),substr(a2,1+2*900,2),length(a3),substr(a3,1+3*900,3) + FROM test.t1 WHERE a1=1 ORDER BY a1; + SELECT a1,length(a2),substr(a2,1+2*9000,2),length(a3),substr(a3,1+3*9000,3) + FROM test.t1 where a1=2 ORDER BY a1; + + UPDATE test.t1 set a2=@vc2,a3=@d2 where a1=1; + UPDATE test.t1 set a2=@vc1,a3=@d1 where a1=2; + + SELECT a1,length(a2),substr(a2,1+2*9000,2),length(a3),substr(a3,1+3*9000,3) + FROM test.t1 where a1=1; + SELECT a1,length(a2),substr(a2,1+2*900,2),length(a3),substr(a3,1+3*900,3) + FROM test.t1 where a1=2; + + #SHOW VARIABLES LIKE 'have_query_cache'; + #SHOW STATUS LIKE 'Qcache%'; + + DELETE FROM test.t1; + DROP TABLE test.t1; + +#### Create test that uses COUNT(), SUM(), MAX(), #### +##### MIN(), NOW(), USER(), TRUNCATE #### +--echo ***** +--echo ***** Create test that uses COUNT(), SUM(), MAX(), MIN(), NOW(), +--echo ***** USER(), TRUNCATE +--echo ***** + + CREATE TABLE test.t1 (a1 int NOT NULL PRIMARY KEY, a2 VARCHAR(256), + a3 BLOB, a4 DATE, a5 CHAR(250)) + TABLESPACE ts1 STORAGE DISK ENGINE=NDB; + let $1=100; + disable_query_log; + while ($1) + { + eval insert into test.t1 values($1, "aaaaaaaaaaaaaaaa$1", + "bbbbbbbbbbbbbbbbbb$1", '2006-06-20' , USER()); + dec $1; + } + enable_query_log; + + SELECT COUNT(*) from test.t1; + SELECT SUM(a1) from test.t1; + SELECT MIN(a1) from test.t1; + SELECT MAX(a1) from test.t1; + SELECT a5 from test.t1 where a1=50; + + + SELECT * from test.t1 order by a1; + + DROP TABLE test.t1; + + ALTER TABLESPACE ts1 + DROP DATAFILE './table_space1/datafile.dat' + ENGINE=NDB; + DROP TABLESPACE ts1 ENGINE=NDB; + + ALTER TABLESPACE ts2 + DROP DATAFILE './table_space2/datafile.dat' + ENGINE=NDB; + DROP TABLESPACE ts2 ENGINE=NDB; + + DROP LOGFILE GROUP lg + ENGINE=NDB; + + +#End 5.1 test case + diff --git a/mysql-test/suite/ndb/t/ndb_gis.test b/mysql-test/suite/ndb/t/ndb_gis.test new file mode 100644 index 00000000000..e14f462c32d --- /dev/null +++ b/mysql-test/suite/ndb/t/ndb_gis.test @@ -0,0 +1,5 @@ +--source include/have_ndb.inc +SET storage_engine=ndbcluster; +--source include/gis_generic.inc +set engine_condition_pushdown = on; +--source include/gis_generic.inc diff --git a/mysql-test/suite/ndb/t/ndb_grant.later b/mysql-test/suite/ndb/t/ndb_grant.later new file mode 100644 index 00000000000..5431d94e1f8 --- /dev/null +++ b/mysql-test/suite/ndb/t/ndb_grant.later @@ -0,0 +1,385 @@ +-- source include/have_ndb.inc +# Test of GRANT commands + +# Cleanup +--disable_warnings +drop table if exists t1; +--enable_warnings + +SET NAMES binary; + +# +# Alter mysql system tables to ndb +# make sure you alter all back in the end +# +use mysql; +alter table columns_priv engine=ndb; +alter table db engine=ndb; +alter table func engine=ndb; +alter table help_category engine=ndb; +alter table help_keyword engine=ndb; +alter table help_relation engine=ndb; +alter table help_topic engine=ndb; +alter table host engine=ndb; +alter table tables_priv engine=ndb; +alter table time_zone engine=ndb; +alter table time_zone_leap_second engine=ndb; +alter table time_zone_name engine=ndb; +alter table time_zone_transition engine=ndb; +alter table time_zone_transition_type engine=ndb; +alter table user engine=ndb; +use test; + +# +# Test that SSL options works properly +# +delete from mysql.user where user='mysqltest_1'; +delete from mysql.db where user='mysqltest_1'; +flush privileges; +begin; +grant select on mysqltest.* to mysqltest_1@localhost require cipher "EDH-RSA-DES-CBC3-SHA"; +commit; +show grants for mysqltest_1@localhost; +begin; +grant delete on mysqltest.* to mysqltest_1@localhost; +commit; +select * from mysql.user where user="mysqltest_1"; +show grants for mysqltest_1@localhost; +begin; +revoke delete on mysqltest.* from mysqltest_1@localhost; +commit; +show grants for mysqltest_1@localhost; +begin; +grant select on mysqltest.* to mysqltest_1@localhost require NONE; +commit; +show grants for mysqltest_1@localhost; +begin; +grant USAGE on mysqltest.* to mysqltest_1@localhost require cipher "EDH-RSA-DES-CBC3-SHA" AND SUBJECT "testsubject" ISSUER "MySQL AB"; +commit; +show grants for mysqltest_1@localhost; +begin; +revoke all privileges on mysqltest.* from mysqltest_1@localhost; +commit; +show grants for mysqltest_1@localhost; +delete from mysql.user where user='mysqltest_1'; +flush privileges; + +# +# Test that the new db privileges are stored/retrieved correctly +# + +begin; +grant CREATE TEMPORARY TABLES, LOCK TABLES on mysqltest.* to mysqltest_1@localhost; +commit; +show grants for mysqltest_1@localhost; +flush privileges; +show grants for mysqltest_1@localhost; +begin; +revoke CREATE TEMPORARY TABLES on mysqltest.* from mysqltest_1@localhost; +commit; +show grants for mysqltest_1@localhost; +begin; +grant ALL PRIVILEGES on mysqltest.* to mysqltest_1@localhost with GRANT OPTION; +commit; +flush privileges; +show grants for mysqltest_1@localhost; +begin; +revoke LOCK TABLES, ALTER on mysqltest.* from mysqltest_1@localhost; +commit; +show grants for mysqltest_1@localhost; +begin; +revoke all privileges on mysqltest.* from mysqltest_1@localhost; +commit; +delete from mysql.user where user='mysqltest_1'; +flush privileges; +begin; +grant usage on test.* to mysqltest_1@localhost with grant option; +commit; +show grants for mysqltest_1@localhost; +delete from mysql.user where user='mysqltest_1'; +delete from mysql.db where user='mysqltest_1'; +delete from mysql.tables_priv where user='mysqltest_1'; +delete from mysql.columns_priv where user='mysqltest_1'; +flush privileges; +--error 1141 +show grants for mysqltest_1@localhost; + +# +# Test what happens when you have same table and colum level grants +# + +create table t1 (a int); +begin; +GRANT select,update,insert on t1 to mysqltest_1@localhost; +GRANT select (a), update (a),insert(a), references(a) on t1 to mysqltest_1@localhost; +commit; +show grants for mysqltest_1@localhost; +select table_priv,column_priv from mysql.tables_priv where user="mysqltest_1"; +begin; +REVOKE select (a), update on t1 from mysqltest_1@localhost; +commit; +show grants for mysqltest_1@localhost; +begin; +REVOKE select,update,insert,insert (a) on t1 from mysqltest_1@localhost; +commit; +show grants for mysqltest_1@localhost; +begin; +GRANT select,references on t1 to mysqltest_1@localhost; +commit; +select table_priv,column_priv from mysql.tables_priv where user="mysqltest_1"; +begin; +grant all on test.* to mysqltest_3@localhost with grant option; +revoke all on test.* from mysqltest_3@localhost; +commit; +show grants for mysqltest_3@localhost; +begin; +revoke grant option on test.* from mysqltest_3@localhost; +commit; +show grants for mysqltest_3@localhost; +begin; +grant all on test.t1 to mysqltest_2@localhost with grant option; +revoke all on test.t1 from mysqltest_2@localhost; +commit; +show grants for mysqltest_2@localhost; +begin; +revoke grant option on test.t1 from mysqltest_2@localhost; +commit; +show grants for mysqltest_2@localhost; +delete from mysql.user where user='mysqltest_1' or user="mysqltest_2" or user="mysqltest_3"; +delete from mysql.db where user='mysqltest_1' or user="mysqltest_2" or user="mysqltest_3"; +delete from mysql.tables_priv where user='mysqltest_1' or user="mysqltest_2" or user="mysqltest_3"; +delete from mysql.columns_priv where user='mysqltest_1' or user="mysqltest_2" or user="mysqltest_3"; +flush privileges; +drop table t1; + +# +# Test some error conditions +# +begin; +--error 1221 +GRANT FILE on mysqltest.* to mysqltest_1@localhost; +commit; +select 1; -- To test that the previous command didn't cause problems + +# +# Bug#6123: GRANT USAGE inserts useless Db row +# +create database mysqltest1; +begin; +grant usage on mysqltest1.* to test6123 identified by 'magic123'; +commit; +select host,db,user,select_priv,insert_priv from mysql.db where db="mysqltest1"; +delete from mysql.user where user='test6123'; +drop database mysqltest1; + +# +# Test for 'drop user', 'revoke privileges, grant' +# + +create table t1 (a int); +begin; +grant ALL PRIVILEGES on *.* to drop_user2@localhost with GRANT OPTION; +commit; +show grants for drop_user2@localhost; +begin; +revoke all privileges, grant option from drop_user2@localhost; +commit; +drop user drop_user2@localhost; + +begin; +grant ALL PRIVILEGES on *.* to drop_user@localhost with GRANT OPTION; +grant ALL PRIVILEGES on test.* to drop_user@localhost with GRANT OPTION; +grant select(a) on test.t1 to drop_user@localhost; +commit; +show grants for drop_user@localhost; + +# +# Bug3086 +# +set sql_mode=ansi_quotes; +show grants for drop_user@localhost; +set sql_mode=default; + +set sql_quote_show_create=0; +show grants for drop_user@localhost; +set sql_mode="ansi_quotes"; +show grants for drop_user@localhost; +set sql_quote_show_create=1; +show grants for drop_user@localhost; +set sql_mode=""; +show grants for drop_user@localhost; + +revoke all privileges, grant option from drop_user@localhost; +show grants for drop_user@localhost; +drop user drop_user@localhost; +begin; +--error 1269 +revoke all privileges, grant option from drop_user@localhost; +commit; + +begin; +grant select(a) on test.t1 to drop_user1@localhost; +commit; +flush privileges; +begin; +grant select on test.t1 to drop_user2@localhost; +grant select on test.* to drop_user3@localhost; +grant select on *.* to drop_user4@localhost; +commit; +flush privileges; +# Drop user now implicitly revokes all privileges. +drop user drop_user1@localhost, drop_user2@localhost, drop_user3@localhost, +drop_user4@localhost; +begin; +--error 1269 +revoke all privileges, grant option from drop_user1@localhost, drop_user2@localhost, +drop_user3@localhost, drop_user4@localhost; +commit; +flush privileges; +#--error 1268 +drop user drop_user1@localhost, drop_user2@localhost, drop_user3@localhost, +drop_user4@localhost; +drop table t1; +begin; +grant usage on *.* to mysqltest_1@localhost identified by "password"; +grant select, update, insert on test.* to mysqltest_1@localhost; +commit; +show grants for mysqltest_1@localhost; +drop user mysqltest_1@localhost; + +# +# Bug #3403 Wrong encodin in SHOW GRANTS output +# +SET NAMES koi8r; +CREATE DATABASE ÂÄ; +USE ÂÄ; +CREATE TABLE ÔÁÂ (ËÏÌ int); + +begin; +GRANT SELECT ON ÂÄ.* TO ÀÚÅÒ@localhost; +commit; +SHOW GRANTS FOR ÀÚÅÒ@localhost; +begin; +REVOKE SELECT ON ÂÄ.* FROM ÀÚÅÒ@localhost; +commit; + +begin; +GRANT SELECT ON ÂÄ.ÔÁÂ TO ÀÚÅÒ@localhost; +commit; +SHOW GRANTS FOR ÀÚÅÒ@localhost; +begin; +REVOKE SELECT ON ÂÄ.ÔÁÂ FROM ÀÚÅÒ@localhost; +commit; + +begin; +GRANT SELECT (ËÏÌ) ON ÂÄ.ÔÁÂ TO ÀÚÅÒ@localhost; +commit; +SHOW GRANTS FOR ÀÚÅÒ@localhost; +begin; +REVOKE SELECT (ËÏÌ) ON ÂÄ.ÔÁÂ FROM ÀÚÅÒ@localhost; +commit; + +DROP DATABASE ÂÄ; +SET NAMES latin1; + +# +# Bug #5831: REVOKE ALL PRIVILEGES, GRANT OPTION does not revoke everything +# +USE test; +CREATE TABLE t1 (a int ); +CREATE TABLE t2 LIKE t1; +CREATE TABLE t3 LIKE t1; +CREATE TABLE t4 LIKE t1; +CREATE TABLE t5 LIKE t1; +CREATE TABLE t6 LIKE t1; +CREATE TABLE t7 LIKE t1; +CREATE TABLE t8 LIKE t1; +CREATE TABLE t9 LIKE t1; +CREATE TABLE t10 LIKE t1; +CREATE DATABASE testdb1; +CREATE DATABASE testdb2; +CREATE DATABASE testdb3; +CREATE DATABASE testdb4; +CREATE DATABASE testdb5; +CREATE DATABASE testdb6; +CREATE DATABASE testdb7; +CREATE DATABASE testdb8; +CREATE DATABASE testdb9; +CREATE DATABASE testdb10; +begin; +GRANT ALL ON testdb1.* TO testuser@localhost; +GRANT ALL ON testdb2.* TO testuser@localhost; +GRANT ALL ON testdb3.* TO testuser@localhost; +GRANT ALL ON testdb4.* TO testuser@localhost; +GRANT ALL ON testdb5.* TO testuser@localhost; +GRANT ALL ON testdb6.* TO testuser@localhost; +GRANT ALL ON testdb7.* TO testuser@localhost; +GRANT ALL ON testdb8.* TO testuser@localhost; +GRANT ALL ON testdb9.* TO testuser@localhost; +GRANT ALL ON testdb10.* TO testuser@localhost; +GRANT SELECT ON test.t1 TO testuser@localhost; +GRANT SELECT ON test.t2 TO testuser@localhost; +GRANT SELECT ON test.t3 TO testuser@localhost; +GRANT SELECT ON test.t4 TO testuser@localhost; +GRANT SELECT ON test.t5 TO testuser@localhost; +GRANT SELECT ON test.t6 TO testuser@localhost; +GRANT SELECT ON test.t7 TO testuser@localhost; +GRANT SELECT ON test.t8 TO testuser@localhost; +GRANT SELECT ON test.t9 TO testuser@localhost; +GRANT SELECT ON test.t10 TO testuser@localhost; +GRANT SELECT (a) ON test.t1 TO testuser@localhost; +GRANT SELECT (a) ON test.t2 TO testuser@localhost; +GRANT SELECT (a) ON test.t3 TO testuser@localhost; +GRANT SELECT (a) ON test.t4 TO testuser@localhost; +GRANT SELECT (a) ON test.t5 TO testuser@localhost; +GRANT SELECT (a) ON test.t6 TO testuser@localhost; +GRANT SELECT (a) ON test.t7 TO testuser@localhost; +GRANT SELECT (a) ON test.t8 TO testuser@localhost; +GRANT SELECT (a) ON test.t9 TO testuser@localhost; +GRANT SELECT (a) ON test.t10 TO testuser@localhost; +commit; +begin; +REVOKE ALL PRIVILEGES, GRANT OPTION FROM testuser@localhost; +commit; +SHOW GRANTS FOR testuser@localhost; +DROP USER testuser@localhost; +DROP TABLE t1,t2,t3,t4,t5,t6,t7,t8,t9,t10; +DROP DATABASE testdb1; +DROP DATABASE testdb2; +DROP DATABASE testdb3; +DROP DATABASE testdb4; +DROP DATABASE testdb5; +DROP DATABASE testdb6; +DROP DATABASE testdb7; +DROP DATABASE testdb8; +DROP DATABASE testdb9; +DROP DATABASE testdb10; + +# +# just SHOW PRIVILEGES test +# +SHOW PRIVILEGES; + +# +# Alter mysql system tables back to myisam +# +use mysql; +alter table columns_priv engine=myisam; +alter table db engine=myisam; +alter table func engine=myisam; +alter table help_category engine=myisam; +alter table help_keyword engine=myisam; +alter table help_relation engine=myisam; +alter table help_topic engine=myisam; +alter table host engine=myisam; +alter table tables_priv engine=myisam; +alter table time_zone engine=myisam; +alter table time_zone_leap_second engine=myisam; +alter table time_zone_name engine=myisam; +alter table time_zone_transition engine=myisam; +alter table time_zone_transition_type engine=myisam; +alter table user engine=myisam; +use test; +flush privileges; + +# End of 4.1 tests diff --git a/mysql-test/suite/ndb/t/ndb_index.test b/mysql-test/suite/ndb/t/ndb_index.test new file mode 100644 index 00000000000..272f30e3e6f --- /dev/null +++ b/mysql-test/suite/ndb/t/ndb_index.test @@ -0,0 +1,131 @@ +-- source include/have_ndb.inc +-- source include/not_embedded.inc + +--disable_warnings +drop table if exists t1; +--enable_warnings + +CREATE TABLE t1 ( + PORT varchar(16) NOT NULL, + ACCESSNODE varchar(16) NOT NULL, + POP varchar(48) NOT NULL, + ACCESSTYPE int unsigned NOT NULL, + CUSTOMER_ID varchar(20) collate latin1_bin NOT NULL, + PROVIDER varchar(16), + TEXPIRE int unsigned, + NUM_IP int unsigned, + LEASED_NUM_IP int unsigned, + LOCKED_IP int unsigned, + STATIC_DNS int unsigned, + SUSPENDED_SERVICE int unsigned, + SUSPENDED_REASON int unsigned, + BGP_COMMUNITY int unsigned, + INDEX CUSTOMER_ID_INDEX(CUSTOMER_ID), + INDEX FQPN_INDEX(POP,ACCESSNODE,PORT), + PRIMARY KEY(POP,ACCESSNODE,PORT,ACCESSTYPE) +) engine=ndbcluster; + +INSERT INTO t1 VALUES ('port67', 'node78', 'pop98', 1, 'kllopmn', 'pr_43', 121212, 1, 2, 3, 8, NULL, NULL, NULL); +INSERT INTO t1 VALUES ('port67', 'node78', 'pop99', 2, 'klkighh', 'pr_44', 121213, 3, 3, 6, 7, NULL, NULL, NULL); +INSERT INTO t1 VALUES ('port79', 'node79', 'pop79', 2, 'kpongfaa', 'pr_44', 981213, 2, 4, 10, 11, 2, 99, 1278); + + +# Test select using port +select port, accessnode, pop, accesstype from t1 where port='port67' order by accesstype; +select port, accessnode, pop, accesstype from t1 where port='foo'; + +# Test select using accessnode +select port, accessnode, pop, accesstype from t1 where accessnode='node78' order by accesstype; +select port, accessnode, pop, accesstype from t1 where accessnode='foo'; + +# Test select using pop +select port, accessnode, pop, accesstype from t1 where pop='pop98'; +select port, accessnode, pop, accesstype from t1 where pop='pop98'; +select port, accessnode, pop, accesstype from t1 where pop='pop98'; +select port, accessnode, pop, accesstype from t1 where pop='pop98' order by accesstype; +# The following two querys will not return any rows since +# the index used for access is case sensitive +# They are thus disabled for now +#select port, accessnode, pop, accesstype from t1 where pop='POP98'; +#select port, accessnode, pop, accesstype from t1 where pop='POP98' order by accesstype; +select port, accessnode, pop, accesstype from t1 where pop='foo'; + +# Test select using accesstype +select port, accessnode, pop, accesstype from t1 where accesstype=1; +select port, accessnode, pop, accesstype from t1 where accesstype=2 order by port; +select port, accessnode, pop, accesstype from t1 where accesstype=98 order by port; + +# Test select using customer_id +# NOTE! customer_id has a INDEX (ordered index in NDB), it's case sensitive! +select port, accessnode, pop, accesstype from t1 where customer_id='kllopmn'; +select port, accessnode, pop, accesstype from t1 where customer_id='KLLOPMN'; +select port, accessnode, pop, accesstype from t1 where customer_id='kLLoPMn'; +select port, accessnode, pop, accesstype from t1 where customer_id='foo'; + +# Test select using provider +select port, accessnode, pop, accesstype from t1 where provider='pr_43'; +select port, accessnode, pop, accesstype from t1 where provider='foo'; + +# Test select using texpire +select port, accessnode from t1 where texpire=121212; +select port, accessnode from t1 where texpire=2323; + +# Test select using num_ip +select port, accessnode, pop, accesstype from t1 where num_ip=1; +select port, accessnode, pop, accesstype from t1 where num_ip=89; + +# Test select using leased_num_ip +select port, accessnode, pop, accesstype from t1 where leased_num_ip=2; +select port, accessnode, pop, accesstype from t1 where leased_num_ip=89; + +# Test select using locked_ip +select port, accessnode, pop, accesstype from t1 where locked_ip=3; +select port, accessnode, pop, accesstype from t1 where locked_ip=89; + +# Test select using static_dns +select port, accessnode, pop, accesstype from t1 where static_dns=8; +select port, accessnode, pop, accesstype from t1 where static_dns=89; + +# Test select using suspended_service +select port, accessnode, pop, accesstype from t1 where suspended_service=8; +select port, accessnode, pop, accesstype from t1 where suspended_service=89; + +# Test select using suspended_reason +select port, accessnode, pop, accesstype from t1 where suspended_reason=NULL; +select port, accessnode, pop, accesstype from t1 where suspended_reason=89; +select port, accessnode, pop, accesstype from t1 where suspended_reason=0; + +# Test select using bgp_community +select port, accessnode, pop, accesstype from t1 where bgp_community=NULL; +select port, accessnode, pop, accesstype from t1 where bgp_community=89; +select port, accessnode, pop, accesstype from t1 where bgp_community=0; + +# Test select using full primary key +select port, accessnode, pop, accesstype from t1 where port='port67' and accessnode='node78' and pop='pop98' and accesstype=1; +select port, accessnode, pop, accesstype from t1 where port='port67' and accesstype=1 and accessnode='node78' and pop='pop98'; +select port, accessnode, pop, accesstype from t1 where pop='pop98' and port='port67' and accesstype=1 and accessnode='node78'; +select port, accessnode from t1 where port='foo' and accessnode='foo' and pop='foo' and accesstype=99; + +# Test select using partial primary key +select port, accessnode, pop, accesstype from t1 where port='port67' and pop='pop98' and accesstype=1; +select port, accessnode, pop, accesstype from t1 where accesstype=1 and accessnode='node78' and pop='pop98'; +select port, accessnode, pop, accesstype from t1 where port='port67' and accesstype=1 and accessnode='node78'; +select port, accessnode from t1 where port='foo' and accessnode='foo' and pop='foo'; + +# Test select using CUSTOMER_ID_INDEX +select port, accessnode, pop, accesstype from t1 where customer_id='kllopmn'; +select port, accessnode, pop, accesstype from t1 where customer_id='kllopmn' and accesstype=1; +select port, accessnode, pop, accesstype from t1 where customer_id='kllopmn' and accesstype=2; +select port, accessnode, pop, accesstype from t1 where accesstype=2 and customer_id='kllopmn'; + +# Test select using FQPN_INDEX +select port, accessnode, pop, accesstype from t1 where pop='pop98' and accessnode='node78' and port='port67'; +#select port, accessnode, pop, accesstype from t1 where pop='pop98' and accessnode='node78' and port='port67' order by accesstype; +#select port, accessnode, pop, accesstype from t1 where accessnode='node78' and port='port67' and pop='pop98' order by accesstype; +#select port, accessnode, pop, accesstype from t1 where port='port67' and pop='pop98' and accessnode='node78' order by accesstype; +select port, accessnode, pop, accesstype from t1 where pop='pop98' and accessnode='node78' and port='port67' and customer_id='kllopmn'; +select port, accessnode, pop, accesstype from t1 where pop='pop98' and accessnode='node78' and port='port67' and customer_id='foo'; + +drop table t1; + +# End of 4.1 tests diff --git a/mysql-test/suite/ndb/t/ndb_index_ordered.test b/mysql-test/suite/ndb/t/ndb_index_ordered.test new file mode 100644 index 00000000000..782f17ca5b2 --- /dev/null +++ b/mysql-test/suite/ndb/t/ndb_index_ordered.test @@ -0,0 +1,480 @@ +-- source include/have_ndb.inc +-- source include/not_embedded.inc + +--disable_warnings +drop table if exists t1, test1, test2; +--enable_warnings + +# +# Simple test to show use of ordered indexes +# + +CREATE TABLE t1 ( + a int unsigned NOT NULL PRIMARY KEY, + b int unsigned not null, + c int unsigned, + KEY(b) +) engine=ndbcluster; + +insert t1 values(1, 2, 3), (2,3, 5), (3, 4, 6), (4, 5, 8), (5,6, 2), (6,7, 2); +select * from t1 order by b; +select * from t1 where b >= 4 order by b; +select * from t1 where b = 4 order by b; +select * from t1 where b > 4 order by b; +select * from t1 where b < 4 order by b; +select * from t1 where b <= 4 order by b; + +# Test of reset_bounds +select tt1.* from t1 as tt1, t1 as tt2 use index(b) where tt1.b = tt2.b order by tt1.b; +select a, b, c from t1 where a!=2 and c=6; +select a, b, c from t1 where a!=2 order by a; + +# +# Here we should add some "explain select" to verify that the ordered index is +# used for these queries. +# + +# +# Update using ordered index scan +# + +update t1 set c = 3 where b = 3; +select * from t1 order by a; +update t1 set c = 10 where b >= 6; +select * from t1 order by a; +update t1 set c = 11 where b < 5; +select * from t1 order by a; +update t1 set c = 12 where b > 0; +select * from t1 order by a; +update t1 set c = 13 where b <= 3; +select * from t1 order by a; +update t1 set b = b + 1 where b > 4 and b < 7; +select * from t1 order by a; +# Update primary key +update t1 set a = a + 10 where b > 1 and b < 7; +select * from t1 order by a; + +# +# Delete using ordered index scan +# + +drop table t1; + +CREATE TABLE t1 ( + a int unsigned NOT NULL PRIMARY KEY, + b int unsigned not null, + c int unsigned, + KEY(b) +) engine=ndbcluster; + +insert t1 values(1, 2, 13), (2,3, 13), (3, 4, 12), (4, 5, 12), (5,6, 12), (6,7, 12); + +delete from t1 where b = 3; +select * from t1 order by a; +delete from t1 where b >= 6; +select * from t1 order by a; +delete from t1 where b < 4; +select * from t1 order by a; +delete from t1 where b > 5; +select * from t1 order by a; +delete from t1 where b <= 4; +select * from t1 order by a; + +drop table t1; + + +# +#multi part key +# +CREATE TABLE t1 ( + a int unsigned NOT NULL PRIMARY KEY, + b int unsigned not null, + c int unsigned not null +) engine = ndb; + +create index a1 on t1 (b, c); + +insert into t1 values (1, 2, 13); +insert into t1 values (2,3, 13); +insert into t1 values (3, 4, 12); +insert into t1 values (4, 5, 12); +insert into t1 values (5,6, 12); +insert into t1 values (6,7, 12); +insert into t1 values (7, 2, 1); +insert into t1 values (8,3, 6); +insert into t1 values (9, 4, 12); +insert into t1 values (14, 5, 4); +insert into t1 values (15,5,5); +insert into t1 values (16,5, 6); +insert into t1 values (17,4,4); +insert into t1 values (18,1, 7); + + + +select * from t1 order by a; +select * from t1 where b<=5 order by a; +select * from t1 where b<=5 and c=0; +insert into t1 values (19,4, 0); +select * from t1 where b<=5 and c=0; +select * from t1 where b=4 and c<=5 order by a; +select * from t1 where b<=4 and c<=5 order by a; +select * from t1 where b<=5 and c=0 or b<=5 and c=2; + +select count(*) from t1 where b = 0; +select count(*) from t1 where b = 1; +drop table t1; + +# +# Indexing NULL values +# + +CREATE TABLE t1 ( + a int unsigned NOT NULL PRIMARY KEY, + b int unsigned, + c int unsigned, + KEY bc(b,c) +) engine = ndb; + +insert into t1 values(1,1,1),(2,NULL,2),(3,NULL,NULL),(4,4,NULL); +select * from t1 use index (bc) where b IS NULL order by a; + +select * from t1 use index (bc)order by a; +select * from t1 use index (bc) order by a; +select * from t1 use index (PRIMARY) where b IS NULL order by a; +select * from t1 use index (bc) where b IS NULL order by a; +select * from t1 use index (bc) where b IS NULL and c IS NULL order by a; +select * from t1 use index (bc) where b IS NULL and c = 2 order by a; +select * from t1 use index (bc) where b < 4 order by a; +select * from t1 use index (bc) where b IS NOT NULL order by a; +drop table t1; + +# +# Order by again, including descending. +# + +create table t1 ( + a int unsigned primary key, + b int unsigned, + c char(10), + key bc (b, c) +) engine=ndb; + +insert into t1 values(1,1,'a'),(2,2,'b'),(3,3,'c'),(4,4,'d'),(5,5,'e'); +insert into t1 select a*7,10*b,'f' from t1; +insert into t1 select a*13,10*b,'g' from t1; +insert into t1 select a*17,10*b,'h' from t1; +insert into t1 select a*19,10*b,'i' from t1; +insert into t1 select a*23,10*b,'j' from t1; +insert into t1 select a*29,10*b,'k' from t1; +# +select b, c from t1 where b <= 10 and c <'f' order by b, c; +select b, c from t1 where b <= 10 and c <'f' order by b desc, c desc; +# +select b, c from t1 where b=4000 and c<'k' order by b, c; +select b, c from t1 where b=4000 and c<'k' order by b desc, c desc; +select b, c from t1 where 1000<=b and b<=100000 and c<'j' order by b, c; +select b, c from t1 where 1000<=b and b<=100000 and c<'j' order by b desc, c desc; +# +select min(b), max(b) from t1; +# +drop table t1; + +# +# Bug #6435 +CREATE TABLE test1 ( +SubscrID int(11) NOT NULL auto_increment, +UsrID int(11) NOT NULL default '0', +PRIMARY KEY (SubscrID), +KEY idx_usrid (UsrID) +) ENGINE=ndbcluster DEFAULT CHARSET=latin1; + +INSERT INTO test1 VALUES (2,224),(3,224),(1,224); + +CREATE TABLE test2 ( +SbclID int(11) NOT NULL auto_increment, +SbcrID int(11) NOT NULL default '0', +PRIMARY KEY (SbclID), +KEY idx_sbcrid (SbcrID) +) ENGINE=ndbcluster DEFAULT CHARSET=latin1; + +INSERT INTO test2 VALUES (3,2),(1,1),(2,1),(4,2); +select * from test1 order by 1; +select * from test2 order by 1; +SELECT s.SubscrID,l.SbclID FROM test1 s left JOIN test2 l ON +l.SbcrID=s.SubscrID WHERE s.UsrID=224 order by 1, 2; +drop table test1; +drop table test2; + +# bug#7424 + bug#7725 + +create table t1 ( + pk int primary key, + dt datetime not null, + da date not null, + ye year not null, + ti time not null, + ts timestamp not null, + index(dt), + index(da), + index(ye), + index(ti), + index(ts) +) engine=ndb; + +insert into t1 (pk,dt,da,ye,ti,ts) values + (1, '1901-05-05 23:00:59', '1901-05-05', '1901', '23:00:59', '2001-01-01 23:00:59'), + (2, '1912-09-05 13:00:59', '1912-09-05', '1912', '13:00:59', '2001-01-01 13:00:59'), + (3, '1945-12-31 00:00:00', '1945-12-31', '1945', '00:00:00', '2001-01-01 00:00:00'), + (4, '1955-12-31 00:00:00', '1955-12-31', '1955', '00:00:00', '2001-01-01 00:00:00'), + (5, '1963-06-06 06:06:06', '1963-06-06', '1963', '06:06:06', '2001-01-01 06:06:06'), + (6, '1993-06-06 06:06:06', '1993-06-06', '1993', '06:06:06', '2001-01-01 06:06:06'), + (7, '2001-01-01 10:11:10', '2001-01-01', '2001', '10:11:10', '2001-01-01 10:11:10'), + (8, '2001-01-01 10:11:11', '2001-01-01', '2001', '10:11:11', '2001-01-01 10:11:11'), + (9, '2005-01-31 23:59:59', '2005-01-31', '2005', '23:59:59', '2001-01-01 23:59:59'); + +# datetime +select count(*)-9 from t1 use index (dt) where dt > '1900-01-01 00:00:00'; +select count(*)-6 from t1 use index (dt) where dt >= '1955-12-31 00:00:00'; +select count(*)-5 from t1 use index (dt) where dt > '1955-12-31 00:00:00'; +select count(*)-5 from t1 use index (dt) where dt < '1970-03-03 22:22:22'; +select count(*)-7 from t1 use index (dt) where dt < '2001-01-01 10:11:11'; +select count(*)-8 from t1 use index (dt) where dt <= '2001-01-01 10:11:11'; +select count(*)-9 from t1 use index (dt) where dt <= '2055-01-01 00:00:00'; + +# date +select count(*)-9 from t1 use index (da) where da > '1900-01-01'; +select count(*)-6 from t1 use index (da) where da >= '1955-12-31'; +select count(*)-5 from t1 use index (da) where da > '1955-12-31'; +select count(*)-5 from t1 use index (da) where da < '1970-03-03'; +select count(*)-6 from t1 use index (da) where da < '2001-01-01'; +select count(*)-8 from t1 use index (da) where da <= '2001-01-02'; +select count(*)-9 from t1 use index (da) where da <= '2055-01-01'; + +# year +select count(*)-9 from t1 use index (ye) where ye > '1900'; +select count(*)-6 from t1 use index (ye) where ye >= '1955'; +select count(*)-5 from t1 use index (ye) where ye > '1955'; +select count(*)-5 from t1 use index (ye) where ye < '1970'; +select count(*)-6 from t1 use index (ye) where ye < '2001'; +select count(*)-8 from t1 use index (ye) where ye <= '2001'; +select count(*)-9 from t1 use index (ye) where ye <= '2055'; + +# time +select count(*)-9 from t1 use index (ti) where ti >= '00:00:00'; +select count(*)-7 from t1 use index (ti) where ti > '00:00:00'; +select count(*)-7 from t1 use index (ti) where ti > '05:05:05'; +select count(*)-5 from t1 use index (ti) where ti > '06:06:06'; +select count(*)-5 from t1 use index (ti) where ti < '10:11:11'; +select count(*)-6 from t1 use index (ti) where ti <= '10:11:11'; +select count(*)-8 from t1 use index (ti) where ti < '23:59:59'; +select count(*)-9 from t1 use index (ti) where ti <= '23:59:59'; + +# timestamp +select count(*)-9 from t1 use index (ts) where ts >= '2001-01-01 00:00:00'; +select count(*)-7 from t1 use index (ts) where ts > '2001-01-01 00:00:00'; +select count(*)-7 from t1 use index (ts) where ts > '2001-01-01 05:05:05'; +select count(*)-5 from t1 use index (ts) where ts > '2001-01-01 06:06:06'; +select count(*)-5 from t1 use index (ts) where ts < '2001-01-01 10:11:11'; +select count(*)-6 from t1 use index (ts) where ts <= '2001-01-01 10:11:11'; +select count(*)-8 from t1 use index (ts) where ts < '2001-01-01 23:59:59'; +select count(*)-9 from t1 use index (ts) where ts <= '2001-01-01 23:59:59'; + +drop table t1; + +# decimal (not the new 5.0 thing) + +create table t1 ( + a int primary key, + s decimal(12), + t decimal(12, 5), + u decimal(12) unsigned, + v decimal(12, 5) unsigned, + key (s), + key (t), + key (u), + key (v) +) engine=ndb; +# +insert into t1 values + ( 0, -000000000007, -0000061.00003, 000000000061, 0000965.00042), + ( 1, -000000000007, -0000061.00042, 000000000061, 0000965.00003), + ( 2, -071006035767, 4210253.00024, 000000000001, 0000001.84488), + ( 3, 000000007115, 0000000.77607, 000077350625, 0000018.00013), + ( 4, -000000068391, -0346486.00000, 000000005071, 0005334.00002), + ( 5, -521579890459, -1936874.00001, 000000000154, 0000003.00018), + ( 6, -521579890459, -1936874.00018, 000000000154, 0000003.00001), + ( 7, 000000000333, 0000051.39140, 000000907958, 0788643.08374), + ( 8, 000042731229, 0000009.00000, 000000000009, 6428667.00000), + ( 9, -000008159769, 0000918.00004, 000096951421, 7607730.00008); +# +select count(*)- 5 from t1 use index (s) where s < -000000000007; +select count(*)- 7 from t1 use index (s) where s <= -000000000007; +select count(*)- 2 from t1 use index (s) where s = -000000000007; +select count(*)- 5 from t1 use index (s) where s >= -000000000007; +select count(*)- 3 from t1 use index (s) where s > -000000000007; +# +select count(*)- 4 from t1 use index (t) where t < -0000061.00003; +select count(*)- 5 from t1 use index (t) where t <= -0000061.00003; +select count(*)- 1 from t1 use index (t) where t = -0000061.00003; +select count(*)- 6 from t1 use index (t) where t >= -0000061.00003; +select count(*)- 5 from t1 use index (t) where t > -0000061.00003; +# +select count(*)- 2 from t1 use index (u) where u < 000000000061; +select count(*)- 4 from t1 use index (u) where u <= 000000000061; +select count(*)- 2 from t1 use index (u) where u = 000000000061; +select count(*)- 8 from t1 use index (u) where u >= 000000000061; +select count(*)- 6 from t1 use index (u) where u > 000000000061; +# +select count(*)- 5 from t1 use index (v) where v < 0000965.00042; +select count(*)- 6 from t1 use index (v) where v <= 0000965.00042; +select count(*)- 1 from t1 use index (v) where v = 0000965.00042; +select count(*)- 5 from t1 use index (v) where v >= 0000965.00042; +select count(*)- 4 from t1 use index (v) where v > 0000965.00042; + +drop table t1; + +# bug#7798 +create table t1(a int primary key, b int not null, index(b)); +insert into t1 values (1,1), (2,2); +connect (con1,localhost,root,,test); +connect (con2,localhost,root,,test); +connection con1; +set autocommit=0; +begin; +select count(*) from t1; +connection con2; +ALTER TABLE t1 ADD COLUMN c int; +connection con1; +select a from t1 where b = 2; +show tables; +drop table t1; + +# mysqld 5.0.13 crash, no bug# +create table t1 (a int, c varchar(10), + primary key using hash (a), index(c)) engine=ndb; +insert into t1 (a, c) values (1,'aaa'),(3,'bbb'); +select count(*) from t1 where c<'bbb'; +drop table t1; + +# -- index statistics -- + +set autocommit=1; +show session variables like 'ndb_index_stat_%'; + +set ndb_index_stat_enable = off; +show session variables like 'ndb_index_stat_%'; + +create table t1 (a int, b int, c varchar(10) not null, + primary key using hash (a), index(b,c)) engine=ndb; +insert into t1 values + (1,10,'aaa'),(2,10,'bbb'),(3,10,'ccc'), + (4,20,'aaa'),(5,20,'bbb'),(6,20,'ccc'), + (7,30,'aaa'),(8,30,'bbb'),(9,30,'ccc'); +select count(*) from t1 where b < 10; +select count(*) from t1 where b >= 10 and c >= 'bbb'; +select count(*) from t1 where b > 10; +select count(*) from t1 where b <= 20 and c < 'ccc'; +select count(*) from t1 where b = 20 and c = 'ccc'; +select count(*) from t1 where b > 20; +select count(*) from t1 where b = 30 and c > 'aaa'; +select count(*) from t1 where b <= 20; +select count(*) from t1 where b >= 20 and c > 'aaa'; +drop table t1; + +set ndb_index_stat_enable = on; +set ndb_index_stat_cache_entries = 0; +show session variables like 'ndb_index_stat_%'; + +create table t1 (a int, b int, c varchar(10) not null, + primary key using hash (a), index(b,c)) engine=ndb; +insert into t1 values + (1,10,'aaa'),(2,10,'bbb'),(3,10,'ccc'), + (4,20,'aaa'),(5,20,'bbb'),(6,20,'ccc'), + (7,30,'aaa'),(8,30,'bbb'),(9,30,'ccc'); +select count(*) from t1 where b < 10; +select count(*) from t1 where b >= 10 and c >= 'bbb'; +select count(*) from t1 where b > 10; +select count(*) from t1 where b <= 20 and c < 'ccc'; +select count(*) from t1 where b = 20 and c = 'ccc'; +select count(*) from t1 where b > 20; +select count(*) from t1 where b = 30 and c > 'aaa'; +select count(*) from t1 where b <= 20; +select count(*) from t1 where b >= 20 and c > 'aaa'; +drop table t1; + +set ndb_index_stat_enable = on; +set ndb_index_stat_cache_entries = 4; +set ndb_index_stat_update_freq = 2; +show session variables like 'ndb_index_stat_%'; + +create table t1 (a int, b int, c varchar(10) not null, + primary key using hash (a), index(b,c)) engine=ndb; +insert into t1 values + (1,10,'aaa'),(2,10,'bbb'),(3,10,'ccc'), + (4,20,'aaa'),(5,20,'bbb'),(6,20,'ccc'), + (7,30,'aaa'),(8,30,'bbb'),(9,30,'ccc'); +select count(*) from t1 where b < 10; +select count(*) from t1 where b >= 10 and c >= 'bbb'; +select count(*) from t1 where b > 10; +select count(*) from t1 where b <= 20 and c < 'ccc'; +select count(*) from t1 where b = 20 and c = 'ccc'; +select count(*) from t1 where b > 20; +select count(*) from t1 where b = 30 and c > 'aaa'; +select count(*) from t1 where b <= 20; +select count(*) from t1 where b >= 20 and c > 'aaa'; +drop table t1; + +set ndb_index_stat_enable = @@global.ndb_index_stat_enable; +set ndb_index_stat_cache_entries = @@global.ndb_index_stat_cache_entries; +set ndb_index_stat_update_freq = @@global.ndb_index_stat_update_freq; +show session variables like 'ndb_index_stat_%'; + +# End of 4.1 tests + +# bug#24039 + +create table t1 (a int primary key) engine = ndb; +insert into t1 values (1), (2), (3); +begin; +delete from t1 where a > 1; +rollback; +select * from t1 order by a; +begin; +delete from t1 where a > 1; +rollback; + +begin; +select * from t1 order by a; +delete from t1 where a > 2; +select * from t1 order by a; +delete from t1 where a > 1; +select * from t1 order by a; +delete from t1 where a > 0; +select * from t1 order by a; +rollback; +select * from t1 order by a; +delete from t1; +drop table t1; + +# bug#24820 CREATE INDEX ....USING HASH on NDB table creates ordered index, not HASH index + +--error ER_CANT_CREATE_TABLE +create table nationaldish (DishID int(10) unsigned NOT NULL AUTO_INCREMENT, + CountryCode char(3) NOT NULL, + DishTitle varchar(64) NOT NULL, + calories smallint(5) unsigned DEFAULT NULL, + PRIMARY KEY (DishID), + INDEX i USING HASH (countrycode,calories) + ) ENGINE=ndbcluster; + +create table nationaldish (DishID int(10) unsigned NOT NULL AUTO_INCREMENT, + CountryCode char(3) NOT NULL, + DishTitle varchar(64) NOT NULL, + calories smallint(5) unsigned DEFAULT NULL, + PRIMARY KEY (DishID) + ) ENGINE=ndbcluster; + +--error ER_UNSUPPORTED_EXTENSION +create index i on nationaldish(countrycode,calories) using hash; + +drop table nationaldish; diff --git a/mysql-test/suite/ndb/t/ndb_index_unique.test b/mysql-test/suite/ndb/t/ndb_index_unique.test new file mode 100644 index 00000000000..78757c3bcf7 --- /dev/null +++ b/mysql-test/suite/ndb/t/ndb_index_unique.test @@ -0,0 +1,361 @@ +-- source include/have_ndb.inc +-- source include/not_embedded.inc + +--disable_warnings +drop table if exists t1, t2, t3, t4, t5, t6, t7, t8; +--enable_warnings + +# +# Simple test to show use of UNIQUE indexes +# + +CREATE TABLE t1 ( + a int NOT NULL PRIMARY KEY, + b int not null, + c int, + UNIQUE ib(b) +) engine=ndbcluster; + +insert t1 values(1, 2, 3), (2, 3, 5), (3, 4, 6), (4, 5, 8), (5,6, 2), (6,7, 2); +select * from t1 order by b; +select * from t1 where b = 4 order by b; +insert into t1 values(7,8,3); +select * from t1 where b = 4 order by a; + +-- error ER_DUP_ENTRY +insert into t1 values(8, 2, 3); +select * from t1 order by a; +delete from t1 where a = 1; +insert into t1 values(8, 2, 3); +select * from t1 order by a; + +alter table t1 drop index ib; +insert into t1 values(1, 2, 3); +# Bug# #18129 +--error 1169 +create unique index ib on t1(b); + +drop table t1; + +# +# Indexing NULL values +# + +CREATE TABLE t1 ( + a int unsigned NOT NULL PRIMARY KEY, + b int unsigned, + c int unsigned, + UNIQUE bc(b,c) +) engine = ndb; + +insert into t1 values(1,1,1),(2,NULL,2),(3,NULL,NULL),(4,4,NULL); +select * from t1 use index (bc) where b IS NULL order by a; + +select * from t1 use index (bc)order by a; +select * from t1 use index (bc) order by a; +select * from t1 use index (PRIMARY) where b IS NULL order by a; +select * from t1 use index (bc) where b IS NULL order by a; +select * from t1 use index (bc) where b IS NULL and c IS NULL order by a; +select * from t1 use index (bc) where b IS NULL and c = 2 order by a; +select * from t1 use index (bc) where b < 4 order by a; +select * from t1 use index (bc) where b IS NOT NULL order by a; +-- error ER_DUP_ENTRY +insert into t1 values(5,1,1); +drop table t1; + + +# +# Show use of UNIQUE USING HASH indexes +# + +CREATE TABLE t2 ( + a int unsigned NOT NULL PRIMARY KEY, + b int unsigned not null, + c int unsigned not null, + UNIQUE (b, c) USING HASH +) engine=ndbcluster; + +insert t2 values(1, 2, 3), (2, 3, 5), (3, 4, 6), (4, 5, 8), (5,6, 2), (6,7, 2); +select * from t2 where a = 3; +select * from t2 where b = 4; +select * from t2 where c = 6; +insert into t2 values(7,8,3); +select * from t2 where b = 4 order by a; + +-- error ER_DUP_ENTRY +insert into t2 values(8, 2, 3); +select * from t2 order by a; +delete from t2 where a = 1; +insert into t2 values(8, 2, 3); +select * from t2 order by a; + +# Bug #24818 CREATE UNIQUE INDEX (...) USING HASH on a NDB table crashes mysqld +create unique index bi using hash on t2(b); +-- error ER_DUP_ENTRY +insert into t2 values(9, 3, 1); +alter table t2 drop index bi; +insert into t2 values(9, 3, 1); +select * from t2 order by a; + +drop table t2; + +CREATE TABLE t2 ( + a int unsigned NOT NULL PRIMARY KEY, + b int unsigned not null, + c int unsigned, + UNIQUE (b, c) USING HASH +) engine=ndbcluster; + + +insert t2 values(1,1,NULL),(2,2,2),(3,3,NULL),(4,4,4),(5,5,NULL),(6,6,6),(7,7,NULL),(8,3,NULL),(9,3,NULL); + +select * from t2 where c IS NULL order by a; +select * from t2 where b = 3 AND c IS NULL order by a; +select * from t2 where (b = 3 OR b = 5) AND c IS NULL order by a; +set @old_ecpd = @@session.engine_condition_pushdown; +set engine_condition_pushdown = true; +explain select * from t2 where (b = 3 OR b = 5) AND c IS NULL AND a < 9 order by a; +select * from t2 where (b = 3 OR b = 5) AND c IS NULL AND a < 9 order by a; +set engine_condition_pushdown = @old_ecpd; + +drop table t2; + +# +# Show use of PRIMARY KEY USING HASH indexes +# + +CREATE TABLE t3 ( + a int unsigned NOT NULL, + b int unsigned not null, + c int unsigned, + PRIMARY KEY (a, b) USING HASH +) engine=ndbcluster; + +insert t3 values(1, 2, 3), (2, 3, 5), (3, 4, 6), (4, 5, 8), (5,6, 2), (6,7, 2); +select * from t3 where a = 3; +select * from t3 where b = 4; +select * from t3 where c = 6; +insert into t3 values(7,8,3); +select * from t3 where b = 4 order by a; + +drop table t3; + +# +# Indexes on NULL-able columns +# + +CREATE TABLE t1 ( + pk int NOT NULL PRIMARY KEY, + a int unsigned, + UNIQUE KEY (a) +) engine=ndbcluster; + +insert into t1 values (-1,NULL), (0,0), (1,NULL),(2,2),(3,NULL),(4,4); + +select * from t1 order by pk; + +--error ER_DUP_ENTRY +insert into t1 values (5,0); +select * from t1 order by pk; +delete from t1 where a = 0; +insert into t1 values (5,0); +select * from t1 order by pk; + +CREATE TABLE t2 ( + pk int NOT NULL PRIMARY KEY, + a int unsigned, + b tinyint NOT NULL, + c VARCHAR(10), + UNIQUE KEY si(a, c) +) engine=ndbcluster; + +insert into t2 values (-1,1,17,NULL),(0,NULL,18,NULL),(1,3,19,'abc'); + +select * from t2 order by pk; + +--error ER_DUP_ENTRY +insert into t2 values(2,3,19,'abc'); +select * from t2 order by pk; +delete from t2 where c IS NOT NULL; +insert into t2 values(2,3,19,'abc'); +select * from t2 order by pk; + +drop table t1, t2; + +# +# More complex tables +# + +CREATE TABLE t1 ( + cid smallint(5) unsigned NOT NULL default '0', + cv varchar(250) NOT NULL default '', + PRIMARY KEY (cid), + UNIQUE KEY cv (cv) +) engine=ndbcluster; +INSERT INTO t1 VALUES (8,'dummy'); +CREATE TABLE t2 ( + cid bigint(20) unsigned NOT NULL auto_increment, + cap varchar(255) NOT NULL default '', + PRIMARY KEY (cid), + UNIQUE KEY (cid, cap) +) engine=ndbcluster; +INSERT INTO t2 VALUES (NULL,'another dummy'); +CREATE TABLE t3 ( + gid bigint(20) unsigned NOT NULL auto_increment, + gn varchar(255) NOT NULL default '', + must tinyint(4) default NULL, + PRIMARY KEY (gid) +) engine=ndbcluster; +INSERT INTO t3 VALUES (1,'V1',NULL); +CREATE TABLE t4 ( + uid bigint(20) unsigned NOT NULL default '0', + gid bigint(20) unsigned NOT NULL, + rid bigint(20) unsigned NOT NULL, + cid bigint(20) unsigned NOT NULL, + UNIQUE KEY m (uid,gid,rid,cid) +) engine=ndbcluster; +INSERT INTO t4 VALUES (1,1,2,4); +INSERT INTO t4 VALUES (1,1,2,3); +INSERT INTO t4 VALUES (1,1,5,7); +INSERT INTO t4 VALUES (1,1,10,8); +CREATE TABLE t5 ( + rid bigint(20) unsigned NOT NULL auto_increment, + rl varchar(255) NOT NULL default '', + PRIMARY KEY (rid) +) engine=ndbcluster; +CREATE TABLE t6 ( + uid bigint(20) unsigned NOT NULL auto_increment, + un varchar(250) NOT NULL default '', + uc smallint(5) unsigned NOT NULL default '0', + PRIMARY KEY (uid), + UNIQUE KEY nc (un,uc) +) engine=ndbcluster; +INSERT INTO t6 VALUES (1,'test',8); +INSERT INTO t6 VALUES (2,'test2',9); +INSERT INTO t6 VALUES (3,'tre',3); +CREATE TABLE t7 ( + mid bigint(20) unsigned NOT NULL PRIMARY KEY, + uid bigint(20) unsigned NOT NULL default '0', + gid bigint(20) unsigned NOT NULL, + rid bigint(20) unsigned NOT NULL, + cid bigint(20) unsigned NOT NULL, + UNIQUE KEY m (uid,gid,rid,cid) +) engine=ndbcluster; +INSERT INTO t7 VALUES(1, 1, 1, 1, 1); +INSERT INTO t7 VALUES(2, 2, 1, 1, 1); +INSERT INTO t7 VALUES(3, 3, 1, 1, 1); +INSERT INTO t7 VALUES(4, 4, 1, 1, 1); +INSERT INTO t7 VALUES(5, 5, 1, 1, 1); +INSERT INTO t7 VALUES(6, 1, 1, 1, 6); +INSERT INTO t7 VALUES(7, 2, 1, 1, 7); +INSERT INTO t7 VALUES(8, 3, 1, 1, 8); +INSERT INTO t7 VALUES(9, 4, 1, 1, 9); +INSERT INTO t7 VALUES(10, 5, 1, 1, 10); + +select * from t1 where cv = 'dummy'; +select * from t1 where cv = 'test'; +select * from t2 where cap = 'another dummy'; +select * from t4 where uid = 1 and gid=1 and rid=2 and cid=4; +select * from t4 where uid = 1 and gid=1 and rid=1 and cid=4; +select * from t4 where uid = 1 order by cid; +select * from t4 where rid = 2 order by cid; +select * from t6 where un='test' and uc=8; +select * from t6 where un='test' and uc=7; +select * from t6 where un='test'; +select * from t7 where mid = 8; +select * from t7 where uid = 8; +select * from t7 where uid = 1 order by mid; +select * from t7 where uid = 4 order by mid; +select * from t7 where gid = 4; +select * from t7 where gid = 1 order by mid; +select * from t7 where cid = 4; +select * from t7 where cid = 8; + +# +# insert more records into t4 +# +let $1=100; +disable_query_log; +while ($1) +{ + eval insert into t4 values(1, $1, 5, 12); + eval insert into t4 values($1, 3, 9, 11); + dec $1; +} +enable_query_log; + +select * from t4 where uid = 1 and gid=1 and rid=2 and cid=4; +select * from t4 where uid = 1 and gid=1 and rid=1 and cid=4; +select * from t4 where uid = 1 order by gid,cid; +select * from t4 where uid = 1 order by gid,cid; +select * from t4 where rid = 2 order by cid; + + +drop table t1,t2,t3,t4,t5,t6,t7; + +# test null in indexes +CREATE TABLE t1 ( + a int unsigned NOT NULL PRIMARY KEY, + b int unsigned, + c int unsigned, + UNIQUE bc(b,c) ) engine = ndb; + +insert into t1 values(1,1,1),(2,NULL,2),(3,NULL,NULL),(4,4,NULL); +select * from t1 where b=1 and c=1; +select * from t1 where b is null and c is null; +select * from t1 where b is null and c = 2; +select * from t1 where b = 4 and c is null; +create table t8 as +select * from t1 where (b = 1 and c = 1) + or (b is null and c is null) + or (b is null and c = 2) + or (b = 4 and c is null); +select * from t8 order by a; +select * from t1 order by a; +drop table t1, t8; + +############################### +# Bug 8101 +# +# Unique index not specified in the same order as in table +# + +create table t1( + id integer not null auto_increment, + month integer not null, + year integer not null, + code varchar( 2) not null, + primary key ( id), + unique idx_t1( month, code, year) +) engine=ndb; + +INSERT INTO t1 (month, year, code) VALUES (4,2004,'12'); +INSERT INTO t1 (month, year, code) VALUES (5,2004,'12'); + +select * from t1 where code = '12' and month = 4 and year = 2004 ; + +drop table t1; + +# bug#15918 Unique Key Limit in NDB Engine + +create table t1 (a int primary key, b varchar(1000) not null, unique key (b)) +engine=ndb charset=utf8; + +insert into t1 values (1, repeat(_utf8 0xe288ab6474, 200)); +--error ER_DUP_ENTRY +insert into t1 values (2, repeat(_utf8 0xe288ab6474, 200)); +select a, sha1(b) from t1; + +# perl -e 'print pack("H2000","e288ab6474"x200)' | sha1sum + +drop table t1; + +# bug#21873 MySQLD Crash on ALTER...ADD..UNIQUE..USING HASH statement for NDB backed table + +create table t1(id int not null) engine = NDB; + +alter table t1 add constraint uk_test unique (id) using hash; + +drop table t1; + +# End of 4.1 tests diff --git a/mysql-test/suite/ndb/t/ndb_insert.test b/mysql-test/suite/ndb/t/ndb_insert.test new file mode 100644 index 00000000000..5b74cc9202c --- /dev/null +++ b/mysql-test/suite/ndb/t/ndb_insert.test @@ -0,0 +1,779 @@ +-- source include/have_ndb.inc +-- source include/not_embedded.inc + +--disable_warnings +DROP TABLE IF EXISTS t1; +--enable_warnings + +# +# Basic test of INSERT in NDB +# + +# +# Create a normal table with primary key +# +CREATE TABLE t1 ( + pk1 INT NOT NULL PRIMARY KEY, + b INT NOT NULL, + c INT NOT NULL +) ENGINE=ndbcluster; + +INSERT INTO t1 VALUES (0, 0, 0); +SELECT * FROM t1; + +INSERT INTO t1 VALUES +(1,1,1),(2,2,2),(3,3,3),(4,4,4),(5,5,5), +(6,6,6),(7,7,7),(8,8,8),(9,9,9),(10,10,10), +(11,11,11),(12,12,12),(13,13,13),(14,14,14),(15,15,15), +(16,16,16),(17,17,17),(18,18,18),(19,19,19),(20,20,20), +(21,21,21),(22,22,22),(23,23,23),(24,24,24),(25,25,25), +(26,26,26),(27,27,27),(28,28,28),(29,29,29),(30,30,30), +(31,31,31),(32,32,32),(33,33,33),(34,34,34),(35,35,35), +(36,36,36),(37,37,37),(38,38,38),(39,39,39),(40,40,40), +(41,41,41),(42,42,42),(43,43,43),(44,44,44),(45,45,45), +(46,46,46),(47,47,47),(48,48,48),(49,49,49),(50,50,50), +(51,51,51),(52,52,52),(53,53,53),(54,54,54),(55,55,55), +(56,56,56),(57,57,57),(58,58,58),(59,59,59),(60,60,60), +(61,61,61),(62,62,62),(63,63,63),(64,64,64),(65,65,65), +(66,66,66),(67,67,67),(68,68,68),(69,69,69),(70,70,70), +(71,71,71),(72,72,72),(73,73,73),(74,74,74),(75,75,75), +(76,76,76),(77,77,77),(78,78,78),(79,79,79),(80,80,80), +(81,81,81),(82,82,82),(83,83,83),(84,84,84),(85,85,85), +(86,86,86),(87,87,87),(88,88,88),(89,89,89),(90,90,90), +(91,91,91),(92,92,92),(93,93,93),(94,94,94),(95,95,95), +(96,96,96),(97,97,97),(98,98,98),(99,99,99),(100,100,100), +(101,101,101),(102,102,102),(103,103,103),(104,104,104),(105,105,105), +(106,106,106),(107,107,107),(108,108,108),(109,109,109),(110,110,110), +(111,111,111),(112,112,112),(113,113,113),(114,114,114),(115,115,115), +(116,116,116),(117,117,117),(118,118,118),(119,119,119),(120,120,120), +(121,121,121),(122,122,122),(123,123,123),(124,124,124),(125,125,125), +(126,126,126),(127,127,127),(128,128,128),(129,129,129),(130,130,130), +(131,131,131),(132,132,132),(133,133,133),(134,134,134),(135,135,135), +(136,136,136),(137,137,137),(138,138,138),(139,139,139),(140,140,140), +(141,141,141),(142,142,142),(143,143,143),(144,144,144),(145,145,145), +(146,146,146),(147,147,147),(148,148,148),(149,149,149),(150,150,150), +(151,151,151),(152,152,152),(153,153,153),(154,154,154),(155,155,155), +(156,156,156),(157,157,157),(158,158,158),(159,159,159),(160,160,160), +(161,161,161),(162,162,162),(163,163,163),(164,164,164),(165,165,165), +(166,166,166),(167,167,167),(168,168,168),(169,169,169),(170,170,170), +(171,171,171),(172,172,172),(173,173,173),(174,174,174),(175,175,175), +(176,176,176),(177,177,177),(178,178,178),(179,179,179),(180,180,180), +(181,181,181),(182,182,182),(183,183,183),(184,184,184),(185,185,185), +(186,186,186),(187,187,187),(188,188,188),(189,189,189),(190,190,190), +(191,191,191),(192,192,192),(193,193,193),(194,194,194),(195,195,195), +(196,196,196),(197,197,197),(198,198,198),(199,199,199),(200,200,200), +(201,201,201),(202,202,202),(203,203,203),(204,204,204),(205,205,205), +(206,206,206),(207,207,207),(208,208,208),(209,209,209),(210,210,210), +(211,211,211),(212,212,212),(213,213,213),(214,214,214),(215,215,215), +(216,216,216),(217,217,217),(218,218,218),(219,219,219),(220,220,220), +(221,221,221),(222,222,222),(223,223,223),(224,224,224),(225,225,225), +(226,226,226),(227,227,227),(228,228,228),(229,229,229),(230,230,230), +(231,231,231),(232,232,232),(233,233,233),(234,234,234),(235,235,235), +(236,236,236),(237,237,237),(238,238,238),(239,239,239),(240,240,240), +(241,241,241),(242,242,242),(243,243,243),(244,244,244),(245,245,245), +(246,246,246),(247,247,247),(248,248,248),(249,249,249),(250,250,250), +(251,251,251),(252,252,252),(253,253,253),(254,254,254),(255,255,255), +(256,256,256),(257,257,257),(258,258,258),(259,259,259),(260,260,260), +(261,261,261),(262,262,262),(263,263,263),(264,264,264),(265,265,265), +(266,266,266),(267,267,267),(268,268,268),(269,269,269),(270,270,270), +(271,271,271),(272,272,272),(273,273,273),(274,274,274),(275,275,275), +(276,276,276),(277,277,277),(278,278,278),(279,279,279),(280,280,280), +(281,281,281),(282,282,282),(283,283,283),(284,284,284),(285,285,285), +(286,286,286),(287,287,287),(288,288,288),(289,289,289),(290,290,290), +(291,291,291),(292,292,292),(293,293,293),(294,294,294),(295,295,295), +(296,296,296),(297,297,297),(298,298,298),(299,299,299),(300,300,300), +(301,301,301),(302,302,302),(303,303,303),(304,304,304),(305,305,305), +(306,306,306),(307,307,307),(308,308,308),(309,309,309),(310,310,310), +(311,311,311),(312,312,312),(313,313,313),(314,314,314),(315,315,315), +(316,316,316),(317,317,317),(318,318,318),(319,319,319),(320,320,320), +(321,321,321),(322,322,322),(323,323,323),(324,324,324),(325,325,325), +(326,326,326),(327,327,327),(328,328,328),(329,329,329),(330,330,330), +(331,331,331),(332,332,332),(333,333,333),(334,334,334),(335,335,335), +(336,336,336),(337,337,337),(338,338,338),(339,339,339),(340,340,340), +(341,341,341),(342,342,342),(343,343,343),(344,344,344),(345,345,345), +(346,346,346),(347,347,347),(348,348,348),(349,349,349),(350,350,350), +(351,351,351),(352,352,352),(353,353,353),(354,354,354),(355,355,355), +(356,356,356),(357,357,357),(358,358,358),(359,359,359),(360,360,360), +(361,361,361),(362,362,362),(363,363,363),(364,364,364),(365,365,365), +(366,366,366),(367,367,367),(368,368,368),(369,369,369),(370,370,370), +(371,371,371),(372,372,372),(373,373,373),(374,374,374),(375,375,375), +(376,376,376),(377,377,377),(378,378,378),(379,379,379),(380,380,380), +(381,381,381),(382,382,382),(383,383,383),(384,384,384),(385,385,385), +(386,386,386),(387,387,387),(388,388,388),(389,389,389),(390,390,390), +(391,391,391),(392,392,392),(393,393,393),(394,394,394),(395,395,395), +(396,396,396),(397,397,397),(398,398,398),(399,399,399),(400,400,400), +(401,401,401),(402,402,402),(403,403,403),(404,404,404),(405,405,405), +(406,406,406),(407,407,407),(408,408,408),(409,409,409),(410,410,410), +(411,411,411),(412,412,412),(413,413,413),(414,414,414),(415,415,415), +(416,416,416),(417,417,417),(418,418,418),(419,419,419),(420,420,420), +(421,421,421),(422,422,422),(423,423,423),(424,424,424),(425,425,425), +(426,426,426),(427,427,427),(428,428,428),(429,429,429),(430,430,430), +(431,431,431),(432,432,432),(433,433,433),(434,434,434),(435,435,435), +(436,436,436),(437,437,437),(438,438,438),(439,439,439),(440,440,440), +(441,441,441),(442,442,442),(443,443,443),(444,444,444),(445,445,445), +(446,446,446),(447,447,447),(448,448,448),(449,449,449),(450,450,450), +(451,451,451),(452,452,452),(453,453,453),(454,454,454),(455,455,455), +(456,456,456),(457,457,457),(458,458,458),(459,459,459),(460,460,460), +(461,461,461),(462,462,462),(463,463,463),(464,464,464),(465,465,465), +(466,466,466),(467,467,467),(468,468,468),(469,469,469),(470,470,470), +(471,471,471),(472,472,472),(473,473,473),(474,474,474),(475,475,475), +(476,476,476),(477,477,477),(478,478,478),(479,479,479),(480,480,480), +(481,481,481),(482,482,482),(483,483,483),(484,484,484),(485,485,485), +(486,486,486),(487,487,487),(488,488,488),(489,489,489),(490,490,490), +(491,491,491),(492,492,492),(493,493,493),(494,494,494),(495,495,495), +(496,496,496),(497,497,497),(498,498,498),(499,499,499),(500, 500, 500); + +SELECT COUNT(*) FROM t1; + +INSERT INTO t1 VALUES +(501,501,501),(502,502,502),(503,503,503),(504,504,504),(505,505,505), +(506,506,506),(507,507,507),(508,508,508),(509,509,509),(510,510,510), +(511,511,511),(512,512,512),(513,513,513),(514,514,514),(515,515,515), +(516,516,516),(517,517,517),(518,518,518),(519,519,519),(520,520,520), +(521,521,521),(522,522,522),(523,523,523),(524,524,524),(525,525,525), +(526,526,526),(527,527,527),(528,528,528),(529,529,529),(530,530,530), +(531,531,531),(532,532,532),(533,533,533),(534,534,534),(535,535,535), +(536,536,536),(537,537,537),(538,538,538),(539,539,539),(540,540,540), +(541,541,541),(542,542,542),(543,543,543),(544,544,544),(545,545,545), +(546,546,546),(547,547,547),(548,548,548),(549,549,549),(550,550,550), +(551,551,551),(552,552,552),(553,553,553),(554,554,554),(555,555,555), +(556,556,556),(557,557,557),(558,558,558),(559,559,559),(560,560,560), +(561,561,561),(562,562,562),(563,563,563),(564,564,564),(565,565,565), +(566,566,566),(567,567,567),(568,568,568),(569,569,569),(570,570,570), +(571,571,571),(572,572,572),(573,573,573),(574,574,574),(575,575,575), +(576,576,576),(577,577,577),(578,578,578),(579,579,579),(580,580,580), +(581,581,581),(582,582,582),(583,583,583),(584,584,584),(585,585,585), +(586,586,586),(587,587,587),(588,588,588),(589,589,589),(590,590,590), +(591,591,591),(592,592,592),(593,593,593),(594,594,594),(595,595,595), +(596,596,596),(597,597,597),(598,598,598),(599,599,599),(600,600,600), +(601,601,601),(602,602,602),(603,603,603),(604,604,604),(605,605,605), +(606,606,606),(607,607,607),(608,608,608),(609,609,609),(610,610,610), +(611,611,611),(612,612,612),(613,613,613),(614,614,614),(615,615,615), +(616,616,616),(617,617,617),(618,618,618),(619,619,619),(620,620,620), +(621,621,621),(622,622,622),(623,623,623),(624,624,624),(625,625,625), +(626,626,626),(627,627,627),(628,628,628),(629,629,629),(630,630,630), +(631,631,631),(632,632,632),(633,633,633),(634,634,634),(635,635,635), +(636,636,636),(637,637,637),(638,638,638),(639,639,639),(640,640,640), +(641,641,641),(642,642,642),(643,643,643),(644,644,644),(645,645,645), +(646,646,646),(647,647,647),(648,648,648),(649,649,649),(650,650,650), +(651,651,651),(652,652,652),(653,653,653),(654,654,654),(655,655,655), +(656,656,656),(657,657,657),(658,658,658),(659,659,659),(660,660,660), +(661,661,661),(662,662,662),(663,663,663),(664,664,664),(665,665,665), +(666,666,666),(667,667,667),(668,668,668),(669,669,669),(670,670,670), +(671,671,671),(672,672,672),(673,673,673),(674,674,674),(675,675,675), +(676,676,676),(677,677,677),(678,678,678),(679,679,679),(680,680,680), +(681,681,681),(682,682,682),(683,683,683),(684,684,684),(685,685,685), +(686,686,686),(687,687,687),(688,688,688),(689,689,689),(690,690,690), +(691,691,691),(692,692,692),(693,693,693),(694,694,694),(695,695,695), +(696,696,696),(697,697,697),(698,698,698),(699,699,699),(700,700,700), +(701,701,701),(702,702,702),(703,703,703),(704,704,704),(705,705,705), +(706,706,706),(707,707,707),(708,708,708),(709,709,709),(710,710,710), +(711,711,711),(712,712,712),(713,713,713),(714,714,714),(715,715,715), +(716,716,716),(717,717,717),(718,718,718),(719,719,719),(720,720,720), +(721,721,721),(722,722,722),(723,723,723),(724,724,724),(725,725,725), +(726,726,726),(727,727,727),(728,728,728),(729,729,729),(730,730,730), +(731,731,731),(732,732,732),(733,733,733),(734,734,734),(735,735,735), +(736,736,736),(737,737,737),(738,738,738),(739,739,739),(740,740,740), +(741,741,741),(742,742,742),(743,743,743),(744,744,744),(745,745,745), +(746,746,746),(747,747,747),(748,748,748),(749,749,749),(750,750,750), +(751,751,751),(752,752,752),(753,753,753),(754,754,754),(755,755,755), +(756,756,756),(757,757,757),(758,758,758),(759,759,759),(760,760,760), +(761,761,761),(762,762,762),(763,763,763),(764,764,764),(765,765,765), +(766,766,766),(767,767,767),(768,768,768),(769,769,769),(770,770,770), +(771,771,771),(772,772,772),(773,773,773),(774,774,774),(775,775,775), +(776,776,776),(777,777,777),(778,778,778),(779,779,779),(780,780,780), +(781,781,781),(782,782,782),(783,783,783),(784,784,784),(785,785,785), +(786,786,786),(787,787,787),(788,788,788),(789,789,789),(790,790,790), +(791,791,791),(792,792,792),(793,793,793),(794,794,794),(795,795,795), +(796,796,796),(797,797,797),(798,798,798),(799,799,799),(800,800,800), +(801,801,801),(802,802,802),(803,803,803),(804,804,804),(805,805,805), +(806,806,806),(807,807,807),(808,808,808),(809,809,809),(810,810,810), +(811,811,811),(812,812,812),(813,813,813),(814,814,814),(815,815,815), +(816,816,816),(817,817,817),(818,818,818),(819,819,819),(820,820,820), +(821,821,821),(822,822,822),(823,823,823),(824,824,824),(825,825,825), +(826,826,826),(827,827,827),(828,828,828),(829,829,829),(830,830,830), +(831,831,831),(832,832,832),(833,833,833),(834,834,834),(835,835,835), +(836,836,836),(837,837,837),(838,838,838),(839,839,839),(840,840,840), +(841,841,841),(842,842,842),(843,843,843),(844,844,844),(845,845,845), +(846,846,846),(847,847,847),(848,848,848),(849,849,849),(850,850,850), +(851,851,851),(852,852,852),(853,853,853),(854,854,854),(855,855,855), +(856,856,856),(857,857,857),(858,858,858),(859,859,859),(860,860,860), +(861,861,861),(862,862,862),(863,863,863),(864,864,864),(865,865,865), +(866,866,866),(867,867,867),(868,868,868),(869,869,869),(870,870,870), +(871,871,871),(872,872,872),(873,873,873),(874,874,874),(875,875,875), +(876,876,876),(877,877,877),(878,878,878),(879,879,879),(880,880,880), +(881,881,881),(882,882,882),(883,883,883),(884,884,884),(885,885,885), +(886,886,886),(887,887,887),(888,888,888),(889,889,889),(890,890,890), +(891,891,891),(892,892,892),(893,893,893),(894,894,894),(895,895,895), +(896,896,896),(897,897,897),(898,898,898),(899,899,899),(900,900,900), +(901,901,901),(902,902,902),(903,903,903),(904,904,904),(905,905,905), +(906,906,906),(907,907,907),(908,908,908),(909,909,909),(910,910,910), +(911,911,911),(912,912,912),(913,913,913),(914,914,914),(915,915,915), +(916,916,916),(917,917,917),(918,918,918),(919,919,919),(920,920,920), +(921,921,921),(922,922,922),(923,923,923),(924,924,924),(925,925,925), +(926,926,926),(927,927,927),(928,928,928),(929,929,929),(930,930,930), +(931,931,931),(932,932,932),(933,933,933),(934,934,934),(935,935,935), +(936,936,936),(937,937,937),(938,938,938),(939,939,939),(940,940,940), +(941,941,941),(942,942,942),(943,943,943),(944,944,944),(945,945,945), +(946,946,946),(947,947,947),(948,948,948),(949,949,949),(950,950,950), +(951,951,951),(952,952,952),(953,953,953),(954,954,954),(955,955,955), +(956,956,956),(957,957,957),(958,958,958),(959,959,959),(960,960,960), +(961,961,961),(962,962,962),(963,963,963),(964,964,964),(965,965,965), +(966,966,966),(967,967,967),(968,968,968),(969,969,969),(970,970,970), +(971,971,971),(972,972,972),(973,973,973),(974,974,974),(975,975,975), +(976,976,976),(977,977,977),(978,978,978),(979,979,979),(980,980,980), +(981,981,981),(982,982,982),(983,983,983),(984,984,984),(985,985,985), +(986,986,986),(987,987,987),(988,988,988),(989,989,989),(990,990,990), +(991,991,991),(992,992,992),(993,993,993),(994,994,994),(995,995,995), +(996,996,996),(997,997,997),(998,998,998),(999,999,999),(1000,1000,1000), +(1001,1001,1001),(1002,1002,1002),(1003,1003,1003),(1004,1004,1004),(1005,1005,1005), +(1006,1006,1006),(1007,1007,1007),(1008,1008,1008),(1009,1009,1009),(1010,1010,1010), +(1011,1011,1011),(1012,1012,1012),(1013,1013,1013),(1014,1014,1014),(1015,1015,1015), +(1016,1016,1016),(1017,1017,1017),(1018,1018,1018),(1019,1019,1019),(1020,1020,1020), +(1021,1021,1021),(1022,1022,1022),(1023,1023,1023),(1024,1024,1024),(1025,1025,1025), +(1026,1026,1026),(1027,1027,1027),(1028,1028,1028),(1029,1029,1029),(1030,1030,1030), +(1031,1031,1031),(1032,1032,1032),(1033,1033,1033),(1034,1034,1034),(1035,1035,1035), +(1036,1036,1036),(1037,1037,1037),(1038,1038,1038),(1039,1039,1039),(1040,1040,1040), +(1041,1041,1041),(1042,1042,1042),(1043,1043,1043),(1044,1044,1044),(1045,1045,1045), +(1046,1046,1046),(1047,1047,1047),(1048,1048,1048),(1049,1049,1049),(1050,1050,1050), +(1051,1051,1051),(1052,1052,1052),(1053,1053,1053),(1054,1054,1054),(1055,1055,1055), +(1056,1056,1056),(1057,1057,1057),(1058,1058,1058),(1059,1059,1059),(1060,1060,1060), +(1061,1061,1061),(1062,1062,1062),(1063,1063,1063),(1064,1064,1064),(1065,1065,1065), +(1066,1066,1066),(1067,1067,1067),(1068,1068,1068),(1069,1069,1069),(1070,1070,1070), +(1071,1071,1071),(1072,1072,1072),(1073,1073,1073),(1074,1074,1074),(1075,1075,1075), +(1076,1076,1076),(1077,1077,1077),(1078,1078,1078),(1079,1079,1079),(1080,1080,1080), +(1081,1081,1081),(1082,1082,1082),(1083,1083,1083),(1084,1084,1084),(1085,1085,1085), +(1086,1086,1086),(1087,1087,1087),(1088,1088,1088),(1089,1089,1089),(1090,1090,1090), +(1091,1091,1091),(1092,1092,1092),(1093,1093,1093),(1094,1094,1094),(1095,1095,1095), +(1096,1096,1096),(1097,1097,1097),(1098,1098,1098),(1099,1099,1099),(1100,1100,1100), +(1101,1101,1101),(1102,1102,1102),(1103,1103,1103),(1104,1104,1104),(1105,1105,1105), +(1106,1106,1106),(1107,1107,1107),(1108,1108,1108),(1109,1109,1109),(1110,1110,1110), +(1111,1111,1111),(1112,1112,1112),(1113,1113,1113),(1114,1114,1114),(1115,1115,1115), +(1116,1116,1116),(1117,1117,1117),(1118,1118,1118),(1119,1119,1119),(1120,1120,1120), +(1121,1121,1121),(1122,1122,1122),(1123,1123,1123),(1124,1124,1124),(1125,1125,1125), +(1126,1126,1126),(1127,1127,1127),(1128,1128,1128),(1129,1129,1129),(1130,1130,1130), +(1131,1131,1131),(1132,1132,1132),(1133,1133,1133),(1134,1134,1134),(1135,1135,1135), +(1136,1136,1136),(1137,1137,1137),(1138,1138,1138),(1139,1139,1139),(1140,1140,1140), +(1141,1141,1141),(1142,1142,1142),(1143,1143,1143),(1144,1144,1144),(1145,1145,1145), +(1146,1146,1146),(1147,1147,1147),(1148,1148,1148),(1149,1149,1149),(1150,1150,1150), +(1151,1151,1151),(1152,1152,1152),(1153,1153,1153),(1154,1154,1154),(1155,1155,1155), +(1156,1156,1156),(1157,1157,1157),(1158,1158,1158),(1159,1159,1159),(1160,1160,1160), +(1161,1161,1161),(1162,1162,1162),(1163,1163,1163),(1164,1164,1164),(1165,1165,1165), +(1166,1166,1166),(1167,1167,1167),(1168,1168,1168),(1169,1169,1169),(1170,1170,1170), +(1171,1171,1171),(1172,1172,1172),(1173,1173,1173),(1174,1174,1174),(1175,1175,1175), +(1176,1176,1176),(1177,1177,1177),(1178,1178,1178),(1179,1179,1179),(1180,1180,1180), +(1181,1181,1181),(1182,1182,1182),(1183,1183,1183),(1184,1184,1184),(1185,1185,1185), +(1186,1186,1186),(1187,1187,1187),(1188,1188,1188),(1189,1189,1189),(1190,1190,1190), +(1191,1191,1191),(1192,1192,1192),(1193,1193,1193),(1194,1194,1194),(1195,1195,1195), +(1196,1196,1196),(1197,1197,1197),(1198,1198,1198),(1199,1199,1199),(1200,1200,1200), +(1201,1201,1201),(1202,1202,1202),(1203,1203,1203),(1204,1204,1204),(1205,1205,1205), +(1206,1206,1206),(1207,1207,1207),(1208,1208,1208),(1209,1209,1209),(1210,1210,1210), +(1211,1211,1211),(1212,1212,1212),(1213,1213,1213),(1214,1214,1214),(1215,1215,1215), +(1216,1216,1216),(1217,1217,1217),(1218,1218,1218),(1219,1219,1219),(1220,1220,1220), +(1221,1221,1221),(1222,1222,1222),(1223,1223,1223),(1224,1224,1224),(1225,1225,1225), +(1226,1226,1226),(1227,1227,1227),(1228,1228,1228),(1229,1229,1229),(1230,1230,1230), +(1231,1231,1231),(1232,1232,1232),(1233,1233,1233),(1234,1234,1234),(1235,1235,1235), +(1236,1236,1236),(1237,1237,1237),(1238,1238,1238),(1239,1239,1239),(1240,1240,1240), +(1241,1241,1241),(1242,1242,1242),(1243,1243,1243),(1244,1244,1244),(1245,1245,1245), +(1246,1246,1246),(1247,1247,1247),(1248,1248,1248),(1249,1249,1249),(1250,1250,1250), +(1251,1251,1251),(1252,1252,1252),(1253,1253,1253),(1254,1254,1254),(1255,1255,1255), +(1256,1256,1256),(1257,1257,1257),(1258,1258,1258),(1259,1259,1259),(1260,1260,1260), +(1261,1261,1261),(1262,1262,1262),(1263,1263,1263),(1264,1264,1264),(1265,1265,1265), +(1266,1266,1266),(1267,1267,1267),(1268,1268,1268),(1269,1269,1269),(1270,1270,1270), +(1271,1271,1271),(1272,1272,1272),(1273,1273,1273),(1274,1274,1274),(1275,1275,1275), +(1276,1276,1276),(1277,1277,1277),(1278,1278,1278),(1279,1279,1279),(1280,1280,1280), +(1281,1281,1281),(1282,1282,1282),(1283,1283,1283),(1284,1284,1284),(1285,1285,1285), +(1286,1286,1286),(1287,1287,1287),(1288,1288,1288),(1289,1289,1289),(1290,1290,1290), +(1291,1291,1291),(1292,1292,1292),(1293,1293,1293),(1294,1294,1294),(1295,1295,1295), +(1296,1296,1296),(1297,1297,1297),(1298,1298,1298),(1299,1299,1299),(1300,1300,1300), +(1301,1301,1301),(1302,1302,1302),(1303,1303,1303),(1304,1304,1304),(1305,1305,1305), +(1306,1306,1306),(1307,1307,1307),(1308,1308,1308),(1309,1309,1309),(1310,1310,1310), +(1311,1311,1311),(1312,1312,1312),(1313,1313,1313),(1314,1314,1314),(1315,1315,1315), +(1316,1316,1316),(1317,1317,1317),(1318,1318,1318),(1319,1319,1319),(1320,1320,1320), +(1321,1321,1321),(1322,1322,1322),(1323,1323,1323),(1324,1324,1324),(1325,1325,1325), +(1326,1326,1326),(1327,1327,1327),(1328,1328,1328),(1329,1329,1329),(1330,1330,1330), +(1331,1331,1331),(1332,1332,1332),(1333,1333,1333),(1334,1334,1334),(1335,1335,1335), +(1336,1336,1336),(1337,1337,1337),(1338,1338,1338),(1339,1339,1339),(1340,1340,1340), +(1341,1341,1341),(1342,1342,1342),(1343,1343,1343),(1344,1344,1344),(1345,1345,1345), +(1346,1346,1346),(1347,1347,1347),(1348,1348,1348),(1349,1349,1349),(1350,1350,1350), +(1351,1351,1351),(1352,1352,1352),(1353,1353,1353),(1354,1354,1354),(1355,1355,1355), +(1356,1356,1356),(1357,1357,1357),(1358,1358,1358),(1359,1359,1359),(1360,1360,1360), +(1361,1361,1361),(1362,1362,1362),(1363,1363,1363),(1364,1364,1364),(1365,1365,1365), +(1366,1366,1366),(1367,1367,1367),(1368,1368,1368),(1369,1369,1369),(1370,1370,1370), +(1371,1371,1371),(1372,1372,1372),(1373,1373,1373),(1374,1374,1374),(1375,1375,1375), +(1376,1376,1376),(1377,1377,1377),(1378,1378,1378),(1379,1379,1379),(1380,1380,1380), +(1381,1381,1381),(1382,1382,1382),(1383,1383,1383),(1384,1384,1384),(1385,1385,1385), +(1386,1386,1386),(1387,1387,1387),(1388,1388,1388),(1389,1389,1389),(1390,1390,1390), +(1391,1391,1391),(1392,1392,1392),(1393,1393,1393),(1394,1394,1394),(1395,1395,1395), +(1396,1396,1396),(1397,1397,1397),(1398,1398,1398),(1399,1399,1399),(1400,1400,1400), +(1401,1401,1401),(1402,1402,1402),(1403,1403,1403),(1404,1404,1404),(1405,1405,1405), +(1406,1406,1406),(1407,1407,1407),(1408,1408,1408),(1409,1409,1409),(1410,1410,1410), +(1411,1411,1411),(1412,1412,1412),(1413,1413,1413),(1414,1414,1414),(1415,1415,1415), +(1416,1416,1416),(1417,1417,1417),(1418,1418,1418),(1419,1419,1419),(1420,1420,1420), +(1421,1421,1421),(1422,1422,1422),(1423,1423,1423),(1424,1424,1424),(1425,1425,1425), +(1426,1426,1426),(1427,1427,1427),(1428,1428,1428),(1429,1429,1429),(1430,1430,1430), +(1431,1431,1431),(1432,1432,1432),(1433,1433,1433),(1434,1434,1434),(1435,1435,1435), +(1436,1436,1436),(1437,1437,1437),(1438,1438,1438),(1439,1439,1439),(1440,1440,1440), +(1441,1441,1441),(1442,1442,1442),(1443,1443,1443),(1444,1444,1444),(1445,1445,1445), +(1446,1446,1446),(1447,1447,1447),(1448,1448,1448),(1449,1449,1449),(1450,1450,1450), +(1451,1451,1451),(1452,1452,1452),(1453,1453,1453),(1454,1454,1454),(1455,1455,1455), +(1456,1456,1456),(1457,1457,1457),(1458,1458,1458),(1459,1459,1459),(1460,1460,1460), +(1461,1461,1461),(1462,1462,1462),(1463,1463,1463),(1464,1464,1464),(1465,1465,1465), +(1466,1466,1466),(1467,1467,1467),(1468,1468,1468),(1469,1469,1469),(1470,1470,1470), +(1471,1471,1471),(1472,1472,1472),(1473,1473,1473),(1474,1474,1474),(1475,1475,1475), +(1476,1476,1476),(1477,1477,1477),(1478,1478,1478),(1479,1479,1479),(1480,1480,1480), +(1481,1481,1481),(1482,1482,1482),(1483,1483,1483),(1484,1484,1484),(1485,1485,1485), +(1486,1486,1486),(1487,1487,1487),(1488,1488,1488),(1489,1489,1489),(1490,1490,1490), +(1491,1491,1491),(1492,1492,1492),(1493,1493,1493),(1494,1494,1494),(1495,1495,1495), +(1496,1496,1496),(1497,1497,1497),(1498,1498,1498),(1499,1499,1499),(1500,1500,1500), +(1501,1501,1501),(1502,1502,1502),(1503,1503,1503),(1504,1504,1504),(1505,1505,1505), +(1506,1506,1506),(1507,1507,1507),(1508,1508,1508),(1509,1509,1509),(1510,1510,1510), +(1511,1511,1511),(1512,1512,1512),(1513,1513,1513),(1514,1514,1514),(1515,1515,1515), +(1516,1516,1516),(1517,1517,1517),(1518,1518,1518),(1519,1519,1519),(1520,1520,1520), +(1521,1521,1521),(1522,1522,1522),(1523,1523,1523),(1524,1524,1524),(1525,1525,1525), +(1526,1526,1526),(1527,1527,1527),(1528,1528,1528),(1529,1529,1529),(1530,1530,1530), +(1531,1531,1531),(1532,1532,1532),(1533,1533,1533),(1534,1534,1534),(1535,1535,1535), +(1536,1536,1536),(1537,1537,1537),(1538,1538,1538),(1539,1539,1539),(1540,1540,1540), +(1541,1541,1541),(1542,1542,1542),(1543,1543,1543),(1544,1544,1544),(1545,1545,1545), +(1546,1546,1546),(1547,1547,1547),(1548,1548,1548),(1549,1549,1549),(1550,1550,1550), +(1551,1551,1551),(1552,1552,1552),(1553,1553,1553),(1554,1554,1554),(1555,1555,1555), +(1556,1556,1556),(1557,1557,1557),(1558,1558,1558),(1559,1559,1559),(1560,1560,1560), +(1561,1561,1561),(1562,1562,1562),(1563,1563,1563),(1564,1564,1564),(1565,1565,1565), +(1566,1566,1566),(1567,1567,1567),(1568,1568,1568),(1569,1569,1569),(1570,1570,1570), +(1571,1571,1571),(1572,1572,1572),(1573,1573,1573),(1574,1574,1574),(1575,1575,1575), +(1576,1576,1576),(1577,1577,1577),(1578,1578,1578),(1579,1579,1579),(1580,1580,1580), +(1581,1581,1581),(1582,1582,1582),(1583,1583,1583),(1584,1584,1584),(1585,1585,1585), +(1586,1586,1586),(1587,1587,1587),(1588,1588,1588),(1589,1589,1589),(1590,1590,1590), +(1591,1591,1591),(1592,1592,1592),(1593,1593,1593),(1594,1594,1594),(1595,1595,1595), +(1596,1596,1596),(1597,1597,1597),(1598,1598,1598),(1599,1599,1599),(1600,1600,1600), +(1601,1601,1601),(1602,1602,1602),(1603,1603,1603),(1604,1604,1604),(1605,1605,1605), +(1606,1606,1606),(1607,1607,1607),(1608,1608,1608),(1609,1609,1609),(1610,1610,1610), +(1611,1611,1611),(1612,1612,1612),(1613,1613,1613),(1614,1614,1614),(1615,1615,1615), +(1616,1616,1616),(1617,1617,1617),(1618,1618,1618),(1619,1619,1619),(1620,1620,1620), +(1621,1621,1621),(1622,1622,1622),(1623,1623,1623),(1624,1624,1624),(1625,1625,1625), +(1626,1626,1626),(1627,1627,1627),(1628,1628,1628),(1629,1629,1629),(1630,1630,1630), +(1631,1631,1631),(1632,1632,1632),(1633,1633,1633),(1634,1634,1634),(1635,1635,1635), +(1636,1636,1636),(1637,1637,1637),(1638,1638,1638),(1639,1639,1639),(1640,1640,1640), +(1641,1641,1641),(1642,1642,1642),(1643,1643,1643),(1644,1644,1644),(1645,1645,1645), +(1646,1646,1646),(1647,1647,1647),(1648,1648,1648),(1649,1649,1649),(1650,1650,1650), +(1651,1651,1651),(1652,1652,1652),(1653,1653,1653),(1654,1654,1654),(1655,1655,1655), +(1656,1656,1656),(1657,1657,1657),(1658,1658,1658),(1659,1659,1659),(1660,1660,1660), +(1661,1661,1661),(1662,1662,1662),(1663,1663,1663),(1664,1664,1664),(1665,1665,1665), +(1666,1666,1666),(1667,1667,1667),(1668,1668,1668),(1669,1669,1669),(1670,1670,1670), +(1671,1671,1671),(1672,1672,1672),(1673,1673,1673),(1674,1674,1674),(1675,1675,1675), +(1676,1676,1676),(1677,1677,1677),(1678,1678,1678),(1679,1679,1679),(1680,1680,1680), +(1681,1681,1681),(1682,1682,1682),(1683,1683,1683),(1684,1684,1684),(1685,1685,1685), +(1686,1686,1686),(1687,1687,1687),(1688,1688,1688),(1689,1689,1689),(1690,1690,1690), +(1691,1691,1691),(1692,1692,1692),(1693,1693,1693),(1694,1694,1694),(1695,1695,1695), +(1696,1696,1696),(1697,1697,1697),(1698,1698,1698),(1699,1699,1699),(1700,1700,1700), +(1701,1701,1701),(1702,1702,1702),(1703,1703,1703),(1704,1704,1704),(1705,1705,1705), +(1706,1706,1706),(1707,1707,1707),(1708,1708,1708),(1709,1709,1709),(1710,1710,1710), +(1711,1711,1711),(1712,1712,1712),(1713,1713,1713),(1714,1714,1714),(1715,1715,1715), +(1716,1716,1716),(1717,1717,1717),(1718,1718,1718),(1719,1719,1719),(1720,1720,1720), +(1721,1721,1721),(1722,1722,1722),(1723,1723,1723),(1724,1724,1724),(1725,1725,1725), +(1726,1726,1726),(1727,1727,1727),(1728,1728,1728),(1729,1729,1729),(1730,1730,1730), +(1731,1731,1731),(1732,1732,1732),(1733,1733,1733),(1734,1734,1734),(1735,1735,1735), +(1736,1736,1736),(1737,1737,1737),(1738,1738,1738),(1739,1739,1739),(1740,1740,1740), +(1741,1741,1741),(1742,1742,1742),(1743,1743,1743),(1744,1744,1744),(1745,1745,1745), +(1746,1746,1746),(1747,1747,1747),(1748,1748,1748),(1749,1749,1749),(1750,1750,1750), +(1751,1751,1751),(1752,1752,1752),(1753,1753,1753),(1754,1754,1754),(1755,1755,1755), +(1756,1756,1756),(1757,1757,1757),(1758,1758,1758),(1759,1759,1759),(1760,1760,1760), +(1761,1761,1761),(1762,1762,1762),(1763,1763,1763),(1764,1764,1764),(1765,1765,1765), +(1766,1766,1766),(1767,1767,1767),(1768,1768,1768),(1769,1769,1769),(1770,1770,1770), +(1771,1771,1771),(1772,1772,1772),(1773,1773,1773),(1774,1774,1774),(1775,1775,1775), +(1776,1776,1776),(1777,1777,1777),(1778,1778,1778),(1779,1779,1779),(1780,1780,1780), +(1781,1781,1781),(1782,1782,1782),(1783,1783,1783),(1784,1784,1784),(1785,1785,1785), +(1786,1786,1786),(1787,1787,1787),(1788,1788,1788),(1789,1789,1789),(1790,1790,1790), +(1791,1791,1791),(1792,1792,1792),(1793,1793,1793),(1794,1794,1794),(1795,1795,1795), +(1796,1796,1796),(1797,1797,1797),(1798,1798,1798),(1799,1799,1799),(1800,1800,1800), +(1801,1801,1801),(1802,1802,1802),(1803,1803,1803),(1804,1804,1804),(1805,1805,1805), +(1806,1806,1806),(1807,1807,1807),(1808,1808,1808),(1809,1809,1809),(1810,1810,1810), +(1811,1811,1811),(1812,1812,1812),(1813,1813,1813),(1814,1814,1814),(1815,1815,1815), +(1816,1816,1816),(1817,1817,1817),(1818,1818,1818),(1819,1819,1819),(1820,1820,1820), +(1821,1821,1821),(1822,1822,1822),(1823,1823,1823),(1824,1824,1824),(1825,1825,1825), +(1826,1826,1826),(1827,1827,1827),(1828,1828,1828),(1829,1829,1829),(1830,1830,1830), +(1831,1831,1831),(1832,1832,1832),(1833,1833,1833),(1834,1834,1834),(1835,1835,1835), +(1836,1836,1836),(1837,1837,1837),(1838,1838,1838),(1839,1839,1839),(1840,1840,1840), +(1841,1841,1841),(1842,1842,1842),(1843,1843,1843),(1844,1844,1844),(1845,1845,1845), +(1846,1846,1846),(1847,1847,1847),(1848,1848,1848),(1849,1849,1849),(1850,1850,1850), +(1851,1851,1851),(1852,1852,1852),(1853,1853,1853),(1854,1854,1854),(1855,1855,1855), +(1856,1856,1856),(1857,1857,1857),(1858,1858,1858),(1859,1859,1859),(1860,1860,1860), +(1861,1861,1861),(1862,1862,1862),(1863,1863,1863),(1864,1864,1864),(1865,1865,1865), +(1866,1866,1866),(1867,1867,1867),(1868,1868,1868),(1869,1869,1869),(1870,1870,1870), +(1871,1871,1871),(1872,1872,1872),(1873,1873,1873),(1874,1874,1874),(1875,1875,1875), +(1876,1876,1876),(1877,1877,1877),(1878,1878,1878),(1879,1879,1879),(1880,1880,1880), +(1881,1881,1881),(1882,1882,1882),(1883,1883,1883),(1884,1884,1884),(1885,1885,1885), +(1886,1886,1886),(1887,1887,1887),(1888,1888,1888),(1889,1889,1889),(1890,1890,1890), +(1891,1891,1891),(1892,1892,1892),(1893,1893,1893),(1894,1894,1894),(1895,1895,1895), +(1896,1896,1896),(1897,1897,1897),(1898,1898,1898),(1899,1899,1899),(1900,1900,1900), +(1901,1901,1901),(1902,1902,1902),(1903,1903,1903),(1904,1904,1904),(1905,1905,1905), +(1906,1906,1906),(1907,1907,1907),(1908,1908,1908),(1909,1909,1909),(1910,1910,1910), +(1911,1911,1911),(1912,1912,1912),(1913,1913,1913),(1914,1914,1914),(1915,1915,1915), +(1916,1916,1916),(1917,1917,1917),(1918,1918,1918),(1919,1919,1919),(1920,1920,1920), +(1921,1921,1921),(1922,1922,1922),(1923,1923,1923),(1924,1924,1924),(1925,1925,1925), +(1926,1926,1926),(1927,1927,1927),(1928,1928,1928),(1929,1929,1929),(1930,1930,1930), +(1931,1931,1931),(1932,1932,1932),(1933,1933,1933),(1934,1934,1934),(1935,1935,1935), +(1936,1936,1936),(1937,1937,1937),(1938,1938,1938),(1939,1939,1939),(1940,1940,1940), +(1941,1941,1941),(1942,1942,1942),(1943,1943,1943),(1944,1944,1944),(1945,1945,1945), +(1946,1946,1946),(1947,1947,1947),(1948,1948,1948),(1949,1949,1949),(1950,1950,1950), +(1951,1951,1951),(1952,1952,1952),(1953,1953,1953),(1954,1954,1954),(1955,1955,1955), +(1956,1956,1956),(1957,1957,1957),(1958,1958,1958),(1959,1959,1959),(1960,1960,1960), +(1961,1961,1961),(1962,1962,1962),(1963,1963,1963),(1964,1964,1964),(1965,1965,1965), +(1966,1966,1966),(1967,1967,1967),(1968,1968,1968),(1969,1969,1969),(1970,1970,1970), +(1971,1971,1971),(1972,1972,1972),(1973,1973,1973),(1974,1974,1974),(1975,1975,1975), +(1976,1976,1976),(1977,1977,1977),(1978,1978,1978),(1979,1979,1979),(1980,1980,1980), +(1981,1981,1981),(1982,1982,1982),(1983,1983,1983),(1984,1984,1984),(1985,1985,1985), +(1986,1986,1986),(1987,1987,1987),(1988,1988,1988),(1989,1989,1989),(1990,1990,1990), +(1991,1991,1991),(1992,1992,1992),(1993,1993,1993),(1994,1994,1994),(1995,1995,1995), +(1996,1996,1996),(1997,1997,1997),(1998,1998,1998),(1999,1999,1999); + +SELECT COUNT(*) FROM t1; + + +# +# Insert duplicate rows +# +--error ER_DUP_ENTRY +INSERT INTO t1 VALUES (1,1,1); + +--error 1022 +INSERT INTO t1 VALUES +(1,1,1),(2,2,2),(3,3,3),(4,4,4),(5,5,5), +(6,6,6),(7,7,7),(8,8,8),(9,9,9),(10,10,10); + +select count(*) from t1; + + +# +# Test that select count(*) can see inserts made in the same transaction +# +begin; +SELECT COUNT(*) FROM t1; +INSERT INTO t1 VALUES +(2001,2001,2001),(2002,2002,2002),(2003,2003,2003),(2004,2004,2004),(2005,2005,2005); +SELECT COUNT(*) FROM t1; +rollback; + +# +# Insert duplicate rows, inside transaction +# try to commit +# +begin; + +--error 1022 +INSERT INTO t1 VALUES +(1,1,1),(2,2,2),(3,3,3),(4,4,4),(5,5,5), +(6,6,6),(7,7,7),(8,8,8),(9,9,9),(10,10,10); + +--error 1296 +commit; + +select * from t1 where pk1=1; +select * from t1 where pk1=10; +select count(*) from t1 where pk1 <= 10 order by pk1; +select count(*) from t1; + + +# +# Insert duplicate rows, inside transaction +# rollback +# +begin; + +--error 1022 +INSERT INTO t1 VALUES +(1,1,1),(2,2,2),(3,3,3),(4,4,4),(5,5,5), +(6,6,6),(7,7,7),(8,8,8),(9,9,9),(10,10,10); + +rollback; + +select * from t1 where pk1=1; +select * from t1 where pk1=10; +select count(*) from t1 where pk1 <= 10 order by pk1; +select count(*) from t1; + + +# +# Insert duplicate rows, inside transaction +# then try to select, finally rollback +# +begin; + +--error 1022 +INSERT INTO t1 VALUES +(1,1,1),(2,2,2),(3,3,3),(4,4,4),(5,5,5), +(6,6,6),(7,7,7),(8,8,8),(9,9,9),(10,10,10); +--error 1296 +SELECT * FROM t1 WHERE pk1=10; + +rollback; + +select * from t1 where pk1=1; +select * from t1 where pk1=10; +select count(*) from t1 where pk1 <= 10 order by pk1; +select count(*) from t1; + + +# +# Insert duplicate rows, inside transaction +# then try to select, finally commit +# +begin; + +--error 1022 +INSERT INTO t1 VALUES +(1,1,1),(2,2,2),(3,3,3),(4,4,4),(5,5,5), +(6,6,6),(7,7,7),(8,8,8),(9,9,9),(10,10,10); + +--error 1296 +SELECT * FROM t1 WHERE pk1=10; + +--error 1296 +SELECT * FROM t1 WHERE pk1=10; + +--error 1296 +commit; + +select * from t1 where pk1=1; +select * from t1 where pk1=10; +select count(*) from t1 where pk1 <= 10 order by pk1; +select count(*) from t1; + + +# +# Insert duplicate rows, inside transaction +# then try to do another insert +# +begin; + +--error 1022 +INSERT INTO t1 VALUES +(1,1,1),(2,2,2),(3,3,3),(4,4,4),(5,5,5), +(6,6,6),(7,7,7),(8,8,8),(9,9,9),(10,10,10); + +--error 1296 +INSERT INTO t1 values (4000, 40, 44); + +rollback; + +select * from t1 where pk1=1; +select * from t1 where pk1=10; +select count(*) from t1 where pk1 <= 10 order by pk1; +select count(*) from t1; + +# +# Insert duplicate rows using "insert .. select" + +# +--error 1022 +insert into t1 select * from t1 where b < 10 order by pk1; + +DELETE FROM t1 WHERE pk1=2; + +begin; +INSERT IGNORE INTO t1 VALUES(1,2,3),(2,3,4); +select * from t1 where pk1 < 3 order by pk1; +rollback; + +INSERT IGNORE INTO t1 VALUES(1,2,3),(2,3,4); +select * from t1 where pk1 < 3 order by pk1; + +REPLACE INTO t1 values(1, 78, 3); +select * from t1 where pk1=1; + +INSERT INTO t1 VALUES(1,1,1),(3,4,5) ON DUPLICATE KEY UPDATE b=79; +select * from t1 where pk1 < 4 order by pk1; + +INSERT INTO t1 VALUES(1,1,1),(3,4,5) ON DUPLICATE KEY UPDATE b=pk1+c; +select * from t1 where pk1 < 4 order by pk1; + +DELETE FROM t1 WHERE pk1 = 2 OR pk1 = 4 OR pk1 = 6; +INSERT INTO t1 VALUES(1,1,1),(2,2,17),(3,4,5) ON DUPLICATE KEY UPDATE pk1=b; +select * from t1 where pk1 = b and b != c order by pk1; + +# Test handling of duplicate unique +DELETE FROM t1; +CREATE UNIQUE INDEX bi ON t1(b); +INSERT INTO t1 VALUES +(1,1,1),(2,2,2),(3,3,3),(4,4,4),(5,5,5), +(6,6,6),(7,7,7),(8,8,8),(9,9,9),(10,10,10); +INSERT INTO t1 VALUES(0,1,0),(21,21,21) ON DUPLICATE KEY UPDATE pk1=b+10,b=b+10; +select * from t1 order by pk1; + +DROP TABLE t1; + +# +# Bug #6331: problem with 'insert ignore' +# + +CREATE TABLE t1(a INT) ENGINE=ndb; +INSERT IGNORE INTO t1 VALUES (1); +INSERT IGNORE INTO t1 VALUES (1); +INSERT IGNORE INTO t1 SELECT a FROM t1; +INSERT IGNORE INTO t1 SELECT a FROM t1; +INSERT IGNORE INTO t1 SELECT a FROM t1; +INSERT IGNORE INTO t1 VALUES (1); +INSERT IGNORE INTO t1 VALUES (1); +SELECT * FROM t1 ORDER BY a; +DELETE FROM t1; +CREATE UNIQUE INDEX ai ON t1(a); +INSERT IGNORE INTO t1 VALUES (1); +INSERT IGNORE INTO t1 VALUES (1); +INSERT IGNORE INTO t1 VALUES (NULL),(2); +SELECT * FROM t1 ORDER BY a; +DROP TABLE t1; + +# Ignore and NULL values +CREATE TABLE t1(pk INT NOT NULL PRIMARY KEY, a INT, UNIQUE (a)) ENGINE=ndb; +INSERT IGNORE INTO t1 VALUES (1,1),(2,2),(3,3); +INSERT IGNORE INTO t1 VALUES (4,NULL),(5,NULL),(6,NULL),(7,4); +SELECT * FROM t1 ORDER BY pk; +DROP TABLE t1; + +# +# Bug #27980 INSERT IGNORE wrongly ignores NULLs in unique index +# + +create table t1(a int primary key, b int, unique key(b)) engine=ndb; +insert ignore into t1 values (1,0), (2,0), (2,null), (3,null); +select * from t1 order by a; +drop table t1; + +# Bug#26342 auto_increment_increment AND auto_increment_offset REALLY REALLY anger NDB cluster + +CREATE TABLE t1 ( + pk INT NOT NULL PRIMARY KEY AUTO_INCREMENT, + b INT NOT NULL, + c INT NOT NULL UNIQUE +) ENGINE=NDBCLUSTER; + +CREATE TABLE t2 ( + pk INT NOT NULL PRIMARY KEY AUTO_INCREMENT, + b INT NOT NULL, + c INT NOT NULL UNIQUE +) ENGINE=MYISAM; + +SET @@session.auto_increment_increment=10; +INSERT INTO t1 (b,c) VALUES (1,0),(2,1),(3,2); +INSERT INTO t2 (b,c) VALUES (1,0),(2,1),(3,2); +SELECT * FROM t1 ORDER BY pk; +SELECT COUNT(t1.pk) FROM t1, t2 WHERE t1.pk = t2.pk AND t1.b = t2.b AND t1.c = t1.c; +TRUNCATE t1; +TRUNCATE t2; +SET @@session.auto_increment_offset=5; +INSERT INTO t1 (b,c) VALUES (1,0),(2,1),(3,2); +INSERT INTO t1 (pk,b,c) VALUES (27,4,3),(NULL,5,4),(99,6,5),(NULL,7,6); +INSERT INTO t2 (b,c) VALUES (1,0),(2,1),(3,2); +INSERT INTO t2 (pk,b,c) VALUES (27,4,3),(NULL,5,4),(99,6,5),(NULL,7,6); +SELECT * FROM t1 ORDER BY pk; +SELECT COUNT(t1.pk) FROM t1, t2 WHERE t1.pk = t2.pk AND t1.b = t2.b AND t1.c = t1.c; +TRUNCATE t1; +TRUNCATE t2; +SET @@session.auto_increment_increment=2; +INSERT INTO t1 (b,c) VALUES (1,0),(2,1),(3,2); +INSERT INTO t2 (b,c) VALUES (1,0),(2,1),(3,2); +SELECT * FROM t1 ORDER BY pk; +SELECT COUNT(t1.pk) FROM t1, t2 WHERE t1.pk = t2.pk AND t1.b = t2.b AND t1.c = t1.c; +DROP TABLE t1, t2; + +CREATE TABLE t1 ( + pk INT NOT NULL PRIMARY KEY AUTO_INCREMENT, + b INT NOT NULL, + c INT NOT NULL UNIQUE +) ENGINE=NDBCLUSTER AUTO_INCREMENT = 7; + +CREATE TABLE t2 ( + pk INT NOT NULL PRIMARY KEY AUTO_INCREMENT, + b INT NOT NULL, + c INT NOT NULL UNIQUE +) ENGINE=MYISAM AUTO_INCREMENT = 7; + +SET @@session.auto_increment_offset=1; +SET @@session.auto_increment_increment=1; +INSERT INTO t1 (b,c) VALUES (1,0),(2,1),(3,2); +INSERT INTO t2 (b,c) VALUES (1,0),(2,1),(3,2); +SELECT * FROM t1 ORDER BY pk; +SELECT COUNT(t1.pk) FROM t1, t2 WHERE t1.pk = t2.pk AND t1.b = t2.b AND t1.c = t1.c; +DROP TABLE t1, t2; + +CREATE TABLE t1 ( + pk INT NOT NULL PRIMARY KEY AUTO_INCREMENT, + b INT NOT NULL, + c INT NOT NULL UNIQUE +) ENGINE=NDBCLUSTER AUTO_INCREMENT = 3; + +CREATE TABLE t2 ( + pk INT NOT NULL PRIMARY KEY AUTO_INCREMENT, + b INT NOT NULL, + c INT NOT NULL UNIQUE +) ENGINE=MYISAM AUTO_INCREMENT = 3; + +SET @@session.auto_increment_offset=5; +SET @@session.auto_increment_increment=10; +INSERT INTO t1 (b,c) VALUES (1,0),(2,1),(3,2); +INSERT INTO t2 (b,c) VALUES (1,0),(2,1),(3,2); +SELECT * FROM t1 ORDER BY pk; +SELECT COUNT(t1.pk) FROM t1, t2 WHERE t1.pk = t2.pk AND t1.b = t2.b AND t1.c = t1.c; +DROP TABLE t1, t2; + +CREATE TABLE t1 ( + pk INT NOT NULL PRIMARY KEY AUTO_INCREMENT, + b INT NOT NULL, + c INT NOT NULL UNIQUE +) ENGINE=NDBCLUSTER AUTO_INCREMENT = 7; + +CREATE TABLE t2 ( + pk INT NOT NULL PRIMARY KEY AUTO_INCREMENT, + b INT NOT NULL, + c INT NOT NULL UNIQUE +) ENGINE=MYISAM AUTO_INCREMENT = 7; + +SET @@session.auto_increment_offset=5; +SET @@session.auto_increment_increment=10; +INSERT INTO t1 (b,c) VALUES (1,0),(2,1),(3,2); +INSERT INTO t2 (b,c) VALUES (1,0),(2,1),(3,2); +SELECT * FROM t1 ORDER BY pk; +SELECT COUNT(t1.pk) FROM t1, t2 WHERE t1.pk = t2.pk AND t1.b = t2.b AND t1.c = t1.c; +DROP TABLE t1, t2; + +CREATE TABLE t1 ( + pk INT NOT NULL PRIMARY KEY AUTO_INCREMENT, + b INT NOT NULL, + c INT NOT NULL UNIQUE +) ENGINE=NDBCLUSTER AUTO_INCREMENT = 5; + +CREATE TABLE t2 ( + pk INT NOT NULL PRIMARY KEY AUTO_INCREMENT, + b INT NOT NULL, + c INT NOT NULL UNIQUE +) ENGINE=MYISAM AUTO_INCREMENT = 5; + +SET @@session.auto_increment_offset=5; +SET @@session.auto_increment_increment=10; +INSERT INTO t1 (b,c) VALUES (1,0),(2,1),(3,2); +INSERT INTO t2 (b,c) VALUES (1,0),(2,1),(3,2); +SELECT * FROM t1 ORDER BY pk; +SELECT COUNT(t1.pk) FROM t1, t2 WHERE t1.pk = t2.pk AND t1.b = t2.b AND t1.c = t1.c; +DROP TABLE t1, t2; + +CREATE TABLE t1 ( + pk INT NOT NULL PRIMARY KEY AUTO_INCREMENT, + b INT NOT NULL, + c INT NOT NULL UNIQUE +) ENGINE=NDBCLUSTER AUTO_INCREMENT = 100; + +CREATE TABLE t2 ( + pk INT NOT NULL PRIMARY KEY AUTO_INCREMENT, + b INT NOT NULL, + c INT NOT NULL UNIQUE +) ENGINE=MYISAM AUTO_INCREMENT = 100; + +SET @@session.auto_increment_offset=5; +SET @@session.auto_increment_increment=10; +INSERT INTO t1 (b,c) VALUES (1,0),(2,1),(3,2); +INSERT INTO t2 (b,c) VALUES (1,0),(2,1),(3,2); +SELECT * FROM t1 ORDER BY pk; +SELECT COUNT(t1.pk) FROM t1, t2 WHERE t1.pk = t2.pk AND t1.b = t2.b AND t1.c = t1.c; +DROP TABLE t1, t2; + +# End of 4.1 tests diff --git a/mysql-test/suite/ndb/t/ndb_limit.test b/mysql-test/suite/ndb/t/ndb_limit.test new file mode 100644 index 00000000000..01613606d66 --- /dev/null +++ b/mysql-test/suite/ndb/t/ndb_limit.test @@ -0,0 +1,85 @@ +-- source include/have_ndb.inc +-- source include/not_embedded.inc + +--disable_warnings +DROP TABLE IF EXISTS t2; +--enable_warnings + + +CREATE TABLE t2 ( + a bigint unsigned NOT NULL PRIMARY KEY, + b int unsigned not null, + c int unsigned +) engine=ndbcluster; + + +# +# insert records into table +# +let $1=1000; +disable_query_log; +while ($1) +{ + eval insert into t2 values($1*10, $1+9, 5*$1), ($1*10+1, $1+10, 7),($1*10+2, $1+10, 7*$1), ($1*10+3, $1+10, 10+$1), ($1*10+4, $1+10, 70*$1), ($1*10+5, $1+10, 7), ($1*10+6, $1+10, 9), ($1*10+7, $1+299, 899), ($1*10+8, $1+10, 12), ($1*10+9, $1+10, 14*$1); + dec $1; +} +enable_query_log; + +select count(*) from t2; + +delete from t2 limit 1; +select count(*) from t2; + +delete from t2 limit 100; +select count(*) from t2; + +delete from t2 limit 1000; +select count(*) from t2; + +update t2 set c=12345678 limit 100; +select count(*) from t2 where c=12345678; +select count(*) from t2 where c=12345678 limit 1000; + +select * from t2 limit 0; + +drop table t2; + +CREATE TABLE `t2` ( + `views` int(11) NOT NULL default '0', + `clicks` int(11) NOT NULL default '0', + `day` date NOT NULL default '0000-00-00', + `hour` tinyint(4) NOT NULL default '0', + `bannerid` smallint(6) NOT NULL default '0', + `zoneid` smallint(6) NOT NULL default '0', + `source` varchar(50) NOT NULL default '', + PRIMARY KEY (`day`,`hour`,`bannerid`,`zoneid`,`source`), + KEY `bannerid_day` (`bannerid`,`day`), + KEY `zoneid` (`zoneid`) +) ENGINE=ndbcluster DEFAULT CHARSET=latin1; + +INSERT INTO `t2` VALUES +( 1,0,'2004-09-17', 5,100,100,''), +( 1,0,'2004-09-18', 7,100,100,''), +( 17,0,'2004-09-27',20,132,100,''), +( 4,0,'2004-09-16',23,132,100,''), +( 86,0,'2004-09-18', 7,196,196,''), +( 11,0,'2004-09-16',16,132,100,''), +(140,0,'2004-09-18', 0,100,164,''), +( 2,0,'2004-09-17', 7,132,100,''), +(846,0,'2004-09-27',11,132,164,''), +( 1,0,'2004-09-18', 8,132,100,''), +( 22,0,'2004-09-27', 9,164,132,''), +(711,0,'2004-09-27', 9,100,164,''), +( 11,0,'2004-09-18', 0,196,132,''), +( 41,0,'2004-09-27',15,196,132,''), +( 57,0,'2004-09-18', 2,164,196,''); + +SELECT DATE_FORMAT(day, '%Y%m%d') as date, DATE_FORMAT(day, '%d-%m-%Y') +as date_formatted FROM t2 GROUP BY day ORDER BY day DESC; + +SELECT DATE_FORMAT(day, '%Y%m%d') as date, DATE_FORMAT(day, '%d-%m-%Y') +as date_formatted FROM t2 GROUP BY day ORDER BY day DESC LIMIT 2; + +drop table t2; + +# End of 4.1 tests diff --git a/mysql-test/suite/ndb/t/ndb_load.test b/mysql-test/suite/ndb/t/ndb_load.test new file mode 100644 index 00000000000..af2df70b74e --- /dev/null +++ b/mysql-test/suite/ndb/t/ndb_load.test @@ -0,0 +1,24 @@ +-- source include/have_ndb.inc +-- source include/not_embedded.inc + +--disable_warnings +DROP TABLE IF EXISTS t1; +--enable_warnings + +# +# Basic test for different types of loading data +# + +# should give duplicate key +CREATE TABLE t1 (word CHAR(20) NOT NULL PRIMARY KEY) ENGINE=NDB; +--error 1022 +LOAD DATA INFILE '../std_data_ln/words.dat' INTO TABLE t1 ; +DROP TABLE t1; + +# now without a primary key we should be ok +CREATE TABLE t1 (word CHAR(20) NOT NULL) ENGINE=NDB; +LOAD DATA INFILE '../std_data_ln/words.dat' INTO TABLE t1 ; +SELECT * FROM t1 ORDER BY word; +DROP TABLE t1; + +# End of 4.1 tests diff --git a/mysql-test/suite/ndb/t/ndb_loaddatalocal.test b/mysql-test/suite/ndb/t/ndb_loaddatalocal.test new file mode 100644 index 00000000000..3eae3891f43 --- /dev/null +++ b/mysql-test/suite/ndb/t/ndb_loaddatalocal.test @@ -0,0 +1,70 @@ +-- source include/have_ndb.inc +-- source include/not_embedded.inc + +--disable_warnings +DROP TABLE IF EXISTS t1; +--enable_warnings + +create table t1(a int) engine=myisam; +let $1=10000; +disable_query_log; +set SQL_LOG_BIN=0; +while ($1) +{ + insert into t1 values(1); + dec $1; +} +set SQL_LOG_BIN=1; +enable_query_log; +--replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR +eval select * into outfile '$MYSQLTEST_VARDIR/master-data/ndb_loaddatalocal.select_outfile' from t1; +#This will generate a 20KB file, now test LOAD DATA LOCAL +drop table t1; + +create table t1(a int) engine=ndb; +--replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR +eval load data local infile '$MYSQLTEST_VARDIR/master-data/ndb_loaddatalocal.select_outfile' into table t1; +select count(*) from t1; +--remove_file $MYSQLTEST_VARDIR/master-data/ndb_loaddatalocal.select_outfile +drop table t1; + +create table t1(a int) engine=myisam; +insert into t1 values (1), (2), (2), (3); +--replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR +eval select * into outfile '$MYSQLTEST_VARDIR/master-data/ndb_loaddatalocal.select_outfile' from t1; +drop table t1; + +create table t1(a int primary key) engine=ndb; +--replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR +eval load data local infile '$MYSQLTEST_VARDIR/master-data/ndb_loaddatalocal.select_outfile' into table t1; +--remove_file $MYSQLTEST_VARDIR/master-data/ndb_loaddatalocal.select_outfile +select * from t1 order by a; +drop table t1; + +create table t1(a int) engine=myisam; +insert into t1 values (1), (1), (2), (3); +--replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR +eval select * into outfile '$MYSQLTEST_VARDIR/master-data/ndb_loaddatalocal.select_outfile' from t1; +drop table t1; + +create table t1(a int primary key) engine=ndb; +--replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR +eval load data local infile '$MYSQLTEST_VARDIR/master-data/ndb_loaddatalocal.select_outfile' into table t1; +--remove_file $MYSQLTEST_VARDIR/master-data/ndb_loaddatalocal.select_outfile +select * from t1 order by a; +drop table t1; + +create table t1(a int) engine=myisam; +insert into t1 values (1), (2), (3), (3); +--replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR +eval select * into outfile '$MYSQLTEST_VARDIR/master-data/ndb_loaddatalocal.select_outfile' from t1; +drop table t1; + +create table t1(a int primary key) engine=ndb; +--replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR +eval load data local infile '$MYSQLTEST_VARDIR/master-data/ndb_loaddatalocal.select_outfile' into table t1; +--remove_file $MYSQLTEST_VARDIR/master-data/ndb_loaddatalocal.select_outfile +select * from t1 order by a; +drop table t1; + +# End of 4.1 tests diff --git a/mysql-test/suite/ndb/t/ndb_lock.test b/mysql-test/suite/ndb/t/ndb_lock.test new file mode 100644 index 00000000000..b6cd1ca7eb4 --- /dev/null +++ b/mysql-test/suite/ndb/t/ndb_lock.test @@ -0,0 +1,269 @@ +-- source include/have_ndb.inc +-- source include/not_embedded.inc + +connect (con1,localhost,root,,); +connect (con2,localhost,root,,); + +--disable_warnings +DROP TABLE IF EXISTS t1,t2,t3,t4,t5,t6,t7; +--enable_warnings + +# +# Transaction lock test to show that the NDB +# table handler is working properly with +# transaction locks +# + +# +# Testing of scan isolation +# +connection con1; +create table t1 (x integer not null primary key, y varchar(32)) engine = ndb; +insert into t1 values (1,'one'), (2,'two'); +select * from t1 order by x; + +connection con2; +select * from t1 order by x; + +connection con1; +start transaction; +insert into t1 values (3,'three'); +select * from t1 order by x; + +connection con2; +start transaction; +select * from t1 order by x; + +connection con1; +commit; + +connection con2; +select * from t1 order by x; +commit; + +drop table t1; + +### +# Bug#6020 +create table t1 (pk integer not null primary key, u int not null, o int not null, + unique(u), key(o)) engine = ndb; +insert into t1 values (1,1,1), (2,2,2), (3,3,3), (4,4,4), (5,5,5); + +lock tables t1 write; +delete from t1 where pk = 1; +unlock tables; +select * from t1 order by pk; +insert into t1 values (1,1,1); + +lock tables t1 write; +delete from t1 where u = 1; +unlock tables; +select * from t1 order by pk; +insert into t1 values (1,1,1); + +lock tables t1 write; +delete from t1 where o = 1; +unlock tables; +select * from t1 order by pk; +insert into t1 values (1,1,1); + +drop table t1; + +# Lock for update + +create table t1 (x integer not null primary key, y varchar(32), z integer, key(z)) engine = ndb; + +insert into t1 values (1,'one',1); + +# PK access +connection con1; +begin; +select * from t1 where x = 1 for update; + +connection con2; +begin; +--error 1205 +select * from t1 where x = 1 for update; +rollback; + +connection con1; +rollback; +insert into t1 values (2,'two',2),(3,"three",3); +begin; +select * from t1 where x = 1 for update; + +connection con2; +--error 1205 +select * from t1 where x = 1 for update; +select * from t1 where x = 2 for update; +rollback; + +connection con1; +commit; + +# table scan +# +# Note that there are two distinct execution paths in which we unlock +# non-matching rows inspected during table scan - one that is used in +# case of filesort and one that used in rest of cases. Below we cover +# the latter (Bug #20390 "SELECT FOR UPDATE does not release locks of +# untouched rows in full table scans"). +connection con1; +begin; +# We can't use "order by x" here as it will cause filesort +--replace_column 1 # 2 # 3 # +select * from t1 where y = 'one' or y = 'three' for update; + +connection con2; +begin; +# Have to check with pk access here since scans take locks on +# all rows and then release them in chunks +select * from t1 where x = 2 for update; +--error 1205 +select * from t1 where x = 1 for update; +rollback; + +connection con1; +commit; + +# And now the test for case with filesort +begin; +select * from t1 where y = 'one' or y = 'three' order by x for update; +connection con2; +begin; +select * from t1 where x = 2 for update; +--error 1205 +select * from t1 where x = 1 for update; +rollback; + +connection con1; +commit; + +# index scan +connection con1; +begin; +select * from t1 where z > 1 and z < 3 for update; + +connection con2; +begin; +# Have to check with pk access here since scans take locks on +# all rows and then release them in chunks +select * from t1 where x = 1 for update; +--error 1105,1205 +select * from t1 where x = 2 for update; +rollback; + +connection con1; +commit; + +# share locking + +# PK access +connection con1; +begin; +select * from t1 where x = 1 lock in share mode; + +connection con2; +begin; +select * from t1 where x = 1 lock in share mode; +select * from t1 where x = 2 for update; +--error 1205 +select * from t1 where x = 1 for update; +rollback; + +connection con1; +commit; + +# table scan +connection con1; +begin; +# We can't use "order by x" here as it will cause filesort +--replace_column 1 # 2 # 3 # +select * from t1 where y = 'one' or y = 'three' lock in share mode; + +connection con2; +begin; +select * from t1 where y = 'one' lock in share mode; +# Have to check with pk access here since scans take locks on +# all rows and then release them in chunks +select * from t1 where x = 2 for update; +--error 1205 +select * from t1 where x = 1 for update; +rollback; + +connection con1; +commit; + +# And the same test for case with filesort +connection con1; +begin; +select * from t1 where y = 'one' or y = 'three' order by x lock in share mode; + +connection con2; +begin; +select * from t1 where y = 'one' lock in share mode; +select * from t1 where x = 2 for update; +--error 1205 +select * from t1 where x = 1 for update; +rollback; + +connection con1; +commit; + +# index scan +connection con1; +begin; +select * from t1 where z > 1 and z < 3 lock in share mode; + +connection con2; +begin; +select * from t1 where z = 1 lock in share mode; +# Have to check with pk access here since scans take locks on +# all rows and then release them in chunks +select * from t1 where x = 1 for update; +--error 1205 +select * from t1 where x = 2 for update; +rollback; + +connection con1; +commit; + +drop table t1; + +# End of 4.1 tests + +# +# Bug #17812 Previous lock table for write causes "stray" lock +# although table is recreated +# +# this creating, locking, and dropping causes a subsequent hang +# on the delete below waiting for table t2 the locking in the +# "other" connection is relevant, as without it there is no problem +# +connection con1; +create table t3 (id2 int) engine=ndb; + +connection con2; +lock tables t3 write; +unlock tables; + +connection con1; +drop table t3; + +connection con1; +create table t2 (id int, j int) engine=ndb; +insert into t2 values (2, 2); +create table t3 (id int) engine=ndb; + +connection con2; +lock tables t3 read; + +connection con1; +# here we get a hang before bugfix although we shouldn't +delete t2 from t2, t3 where t2.id = t3.id; + +connection con2; +unlock tables; + +connection con1; +drop table t2, t3; diff --git a/mysql-test/suite/ndb/t/ndb_minmax.test b/mysql-test/suite/ndb/t/ndb_minmax.test new file mode 100644 index 00000000000..a3ac677cd2a --- /dev/null +++ b/mysql-test/suite/ndb/t/ndb_minmax.test @@ -0,0 +1,65 @@ +-- source include/have_ndb.inc +-- source include/not_embedded.inc + +--disable_warnings +drop table if exists t1, t2; +--enable_warnings + +CREATE TABLE t1 ( + a int PRIMARY KEY +) engine = ndb; + +INSERT INTO t1 VALUES (1); +INSERT INTO t1 VALUES (2); +INSERT INTO t1 VALUES (3); +INSERT INTO t1 VALUES (4); +INSERT INTO t1 VALUES (5); +INSERT INTO t1 VALUES (6); + +select MAX(a) from t1; +select MAX(a) from t1; +select MAX(a) from t1; +select MAX(a) from t1; +select MIN(a) from t1; +select MIN(a) from t1; +select MIN(a) from t1; +select * from t1 order by a; +select MIN(a) from t1; +select MAX(a) from t1; +select MAX(a) from t1; +select * from t1 order by a; +drop table t1; + + +CREATE TABLE t2 ( + a int PRIMARY KEY, + b int not null, + c int not null, + KEY(b), + UNIQUE(c) +) engine = ndb; + +INSERT INTO t2 VALUES (1, 5, 1); +INSERT INTO t2 VALUES (2, 2, 7); +INSERT INTO t2 VALUES (3, 3, 3); +INSERT INTO t2 VALUES (4, 4, 4); +INSERT INTO t2 VALUES (5, 5, 5); +INSERT INTO t2 VALUES (6, 6, 6); +INSERT INTO t2 VALUES (7, 2, 10); +INSERT INTO t2 VALUES (8, 10, 2); + + +select MAX(a) from t2; +select MAX(b) from t2; +select MAX(c) from t2; +select MIN(a) from t2; +select MIN(b) from t2; +select MIN(c) from t2; +select * from t2 order by a; +select MIN(b) from t2; +select MAX(a) from t2; +select MAX(c) from t2; +select * from t2 order by a; +drop table t2; + +# End of 4.1 tests diff --git a/mysql-test/suite/ndb/t/ndb_multi.test b/mysql-test/suite/ndb/t/ndb_multi.test new file mode 100644 index 00000000000..b8e052d606b --- /dev/null +++ b/mysql-test/suite/ndb/t/ndb_multi.test @@ -0,0 +1,125 @@ +-- source include/have_multi_ndb.inc +-- source include/not_embedded.inc + +--disable_warnings +connection server2; +drop table if exists t1, t2, t3, t4; +connection server1; +drop table if exists t1, t2, t3, t4; +--enable_warnings + +flush status; + +# Create test tables on server1 +create table t1 (a int) engine=ndbcluster; +create table t2 (a int) engine=ndbcluster; +insert into t1 value (2); +insert into t2 value (3); +select * from t1; +select * from t2; +show status like 'handler_discover%'; + +# Check dropping and recreating table on same server +connect (con1,localhost,root,,test); +connect (con2,localhost,root,,test); +connection con1; +select * from t1; +connection con2; +drop table t1; +create table t1 (a int) engine=ndbcluster; +insert into t1 value (2); +connection con1; +select * from t1; + +# Check dropping and recreating table on different server +connection server2; +show status like 'handler_discover%'; +drop table t1; +create table t1 (a int) engine=ndbcluster; +insert into t1 value (2); +connection server1; +select * from t1; +select * from t1; + +# Connect to server2 and use the tables from there +connection server2; +flush status; +select * from t1; +update t1 set a=3 where a=2; +show status like 'handler_discover%'; + +# Create a new table on server2 +create table t3 (a int not null primary key, b varchar(22), +c int, last_col text) engine=ndb; +insert into t3 values(1, 'Hi!', 89, 'Longtext column'); +create table t4 (pk int primary key, b int) engine=ndb; + +# Check that the tables are accessible from server1 +connection server1; +select * from t1; +select * from t3; +show tables like 't4'; +show tables; + +drop table t1, t2, t3, t4; +# bug#21378 +connection server1; +create table t1(c1 int key)ENGINE=MyISAM; +insert into t1 values(1),(3),(5); +select * from t1 order by c1; + +connection server2; +show tables; +create table t1(c1 int key)ENGINE=MyISAM; +insert into t1 values(100),(344),(533); +select * from t1 order by c1; + +connection server1; +alter table t1 engine=ndb; + +connection server2; +show tables; +select * from t1 order by c1; +drop table t1; + +connection server1; +select * from t1 order by c1; +drop table t1; +# End of 4.1 tests + +# Check distributed drop of database in 5.1 +create database db; +use db; +create table t1(x int) engine=ndb; + +connection server2; +use db; +show tables; + +connection server1; +drop database db; + +connection server2; +--error 1049 +show tables; + +connection server1; + +# bug#21495 +create database db; +use db; +create table t1(x int) engine=ndb; + +connection server2; +use db; +create table t2(x int) engine=myisam; +show tables; + +connection server1; +drop database db; + +connection server2; +show tables; +drop database db; + +connection server1; diff --git a/mysql-test/suite/ndb/t/ndb_multi_row.test b/mysql-test/suite/ndb/t/ndb_multi_row.test new file mode 100644 index 00000000000..c82307839f4 --- /dev/null +++ b/mysql-test/suite/ndb/t/ndb_multi_row.test @@ -0,0 +1,75 @@ +-- source include/have_multi_ndb.inc +-- source include/not_embedded.inc +-- source include/have_binlog_format_mixed_or_row.inc + + +--disable_warnings +connection server2; +drop table if exists t1, t2, t3, t4; +connection server1; +drop table if exists t1, t2, t3, t4; +--enable_warnings + +flush status; + +# Create test tables on server1 +create table t1 (a int) engine=ndbcluster; +create table t2 (a int) engine=ndbcluster; +insert into t1 value (2); +insert into t2 value (3); +select * from t1; +select * from t2; +show status like 'handler_discover%'; + +# Check dropping and recreating table on same server +connect (con1,localhost,root,,test); +connect (con2,localhost,root,,test); +connection con1; +select * from t1; +connection con2; +drop table t1; +create table t1 (a int) engine=ndbcluster; +insert into t1 value (2); +connection con1; +select * from t1; + +# Check dropping and recreating table on different server +connection server2; +show status like 'handler_discover%'; +drop table t1; +create table t1 (a int) engine=ndbcluster; +insert into t1 value (2); +connection server1; +## Currently a retry is required remotely +#--error 1412 +#select * from t1; +#show warnings; +#flush table t1; +# Table definition change should be propagated automatically +select * from t1; + +# Connect to server2 and use the tables from there +connection server2; +flush status; +select * from t1; +update t1 set a=3 where a=2; +show status like 'handler_discover%'; + +# Create a new table on server2 +create table t3 (a int not null primary key, b varchar(22), +c int, last_col text) engine=ndb; +insert into t3 values(1, 'Hi!', 89, 'Longtext column'); +create table t4 (pk int primary key, b int) engine=ndb; + +# Check that the tables are accessible from server1 +connection server1; +select * from t1; +select * from t3; +show tables like 't4'; +show tables; + +drop table t1, t2, t3, t4; +connection server2; +drop table if exists t1, t3, t4; + +# End of 4.1 tests diff --git a/mysql-test/suite/ndb/t/ndb_partition_error.test b/mysql-test/suite/ndb/t/ndb_partition_error.test new file mode 100644 index 00000000000..9db2a6a6f6d --- /dev/null +++ b/mysql-test/suite/ndb/t/ndb_partition_error.test @@ -0,0 +1,74 @@ +-- source include/have_ndb.inc +#--disable_abort_on_error +# +# Simple test for the partition storage engine +# Focuses on range partitioning tests +# +#-- source include/have_partition.inc + +--disable_warnings +drop table if exists t1; +--enable_warnings + +--disable_query_log +set new=on; +--enable_query_log +# +# Partition by range, generate node group error +# +--error 1005 +CREATE TABLE t1 ( +a int not null, +b int not null, +c int not null, +primary key(a,b), +index (a)) +engine = ndb +partition by range (a) +partitions 3 +(partition x1 values less than (5) nodegroup 12, + partition x2 values less than (10) nodegroup 13, + partition x3 values less than (20) nodegroup 14); +show warnings; + +# +# Partition by range, create normal valid table +# +CREATE TABLE t1 ( +a int not null, +b int not null, +c int not null, +primary key(a)) +engine = ndb +partition by range (a) +partitions 3 +(partition x1 values less than (5), + partition x2 values less than (10), + partition x3 values less than (20)); + +drop table t1; + +# +# Bug #17763 mysqld cores with list partitioning if update to missing partition +# +CREATE TABLE t1 (id INT) ENGINE=NDB + PARTITION BY LIST(id) + (PARTITION p0 VALUES IN (2, 4), + PARTITION p1 VALUES IN (42, 142)); +INSERT INTO t1 VALUES (2); +--error ER_NO_PARTITION_FOR_GIVEN_VALUE +UPDATE t1 SET id=5 WHERE id=2; +DROP TABLE t1; + +# +# NULL for LIST partition +# +create table t1 (a int,b int, c int) +engine = ndb +partition by list(a) +partitions 2 +(partition x123 values in (11, 12), + partition x234 values in (5, 1)); +--error ER_NO_PARTITION_FOR_GIVEN_VALUE +insert into t1 values (NULL,1,1); +drop table t1; diff --git a/mysql-test/suite/ndb/t/ndb_partition_error2-master.opt b/mysql-test/suite/ndb/t/ndb_partition_error2-master.opt new file mode 100644 index 00000000000..955f7692c8b --- /dev/null +++ b/mysql-test/suite/ndb/t/ndb_partition_error2-master.opt @@ -0,0 +1 @@ +--ndbcluster diff --git a/mysql-test/suite/ndb/t/ndb_partition_error2.test b/mysql-test/suite/ndb/t/ndb_partition_error2.test new file mode 100644 index 00000000000..afedd0e3c5c --- /dev/null +++ b/mysql-test/suite/ndb/t/ndb_partition_error2.test @@ -0,0 +1,14 @@ +disable_query_log; +--require r/true.require +select support = 'Enabled' as `TRUE` from information_schema.engines where engine = 'ndbcluster'; +enable_query_log; + +--disable_warnings +drop table if exists t1; +--enable_warnings +# +# Bug #27359 Partitions: memory allocation error message +# +--error ER_PARTITION_NOT_DEFINED_ERROR +create table t1 (s1 int) engine=ndbcluster; + diff --git a/mysql-test/suite/ndb/t/ndb_partition_key.test b/mysql-test/suite/ndb/t/ndb_partition_key.test new file mode 100644 index 00000000000..78e2c9d15c2 --- /dev/null +++ b/mysql-test/suite/ndb/t/ndb_partition_key.test @@ -0,0 +1,229 @@ +-- source include/have_ndb.inc + +--disable_warnings +DROP TABLE IF EXISTS t1; +--enable_warnings + +# +# Basic syntax test +# + +# Support for partition key verified +CREATE TABLE t1 (a int, b int, c int, d int, PRIMARY KEY(a,b,c)) + ENGINE = NDB + PARTITION BY KEY (a,b); + +insert into t1 values (1,1,1,1); +select * from t1; +update t1 set d = 2 where a = 1 and b = 1 and c = 1; +select * from t1; +delete from t1; +select * from t1; + +drop table t1; + +# only support for partition key on primary key +--error ER_UNIQUE_KEY_NEED_ALL_FIELDS_IN_PF +CREATE TABLE t1 (a int, b int, c int, d int, PRIMARY KEY(a,b)) + ENGINE = NDB + PARTITION BY KEY (c); + +CREATE TABLE t1 (a int, b int, c int, PRIMARY KEY(a,b)) + ENGINE = NDB + PARTITION BY KEY (a); + +insert into t1 values + (1,1,3),(1,2,3),(1,3,3),(1,4,3),(1,5,3),(1,6,3), + (1,7,3),(1,8,3),(1,9,3),(1,10,3),(1,11,3),(1,12,3); + +select * from t1 order by b; + +DROP TABLE t1; + +# +# Test partition and char support +# + +CREATE TABLE t1 (a INT, b CHAR(10) COLLATE latin1_bin, c INT, d INT, + PRIMARY KEY (a,b,c) USING HASH) + ENGINE=NDB + DEFAULT CHARSET=latin1 + PARTITION BY KEY (b); + +insert into t1 values (1,"a",1,1),(2,"a",1,1),(3,"a",1,1); + +# should show only one attribute with DISTRIBUTION KEY +--exec $NDB_TOOLS_DIR/ndb_desc --no-defaults -d test t1 | sed 's/Version: [0-9]*//' | sed 's/\(Length of frm data: \)[0-9]*/\1#/' + +# +# Test that explicit partition info is not shown in show create table +# result should not contain (PARTITION P0 ... etc) since this is what shows up in +# mysqldump, and we don't want that info there +# +show create table t1; + +DROP TABLE t1; + +# +# Bug #13155: Problem in Create Table using SHOW CREATE TABLE syntax +# +CREATE TABLE t1 (a int not null primary key) +PARTITION BY KEY(a) +(PARTITION p0 ENGINE = NDB, PARTITION p1 ENGINE = NDB); + +drop table t1; + +CREATE TABLE t1 (a int not null primary key); +ALTER TABLE t1 +PARTITION BY KEY(a) +(PARTITION p0 ENGINE = NDB, PARTITION p1 ENGINE = NDB); + +drop table t1; + +# +# Bug #17754 Improper handling of removal of partitioning in ALTER TABLE +# Also added a number of general test cases in the same area +# +create table t1 (a int) +engine=ndb +partition by key(a) +(partition p0, partition p1); +show create table t1; + +alter table t1 engine=heap; +show create table t1; + +alter table t1 engine=ndb; +show create table t1; + +alter table t1 engine=heap remove partitioning; +show create table t1; + +alter table t1 engine=ndb +partition by key(a) +(partition p0, partition p1 engine = ndb); +show create table t1; + +alter table t1 +partition by key (a) +(partition p0 engine=ndb, partition p1 engine=ndb); +show create table t1; + +alter table t1 remove partitioning; +show create table t1; + +--error ER_MIX_HANDLER_ERROR +alter table t1 +partition by key(a) +(partition p0 engine=ndb, partition p1); + +alter table t1 +engine=ndb +partition by key(a) +(partition p0 engine=ndb, partition p1 engine = ndb); +show create table t1; + +drop table t1; + +# +# BUG 16810 Out of memory when coalesce partition +# +CREATE TABLE t1 ( + c1 MEDIUMINT NOT NULL AUTO_INCREMENT, + c2 TEXT NOT NULL, + c3 INT NOT NULL, + c4 BIT NOT NULL, + c5 FLOAT, + c6 VARCHAR(255), + c7 TIMESTAMP, + PRIMARY KEY(c1,c3)) + ENGINE=NDB + PARTITION BY KEY(c3) PARTITIONS 5; + +let $j= 11; +--disable_query_log +while ($j) +{ + eval INSERT INTO t1 VALUES (NULL, "Tested Remotely from Texas, USA", $j, +b'0', + $j.00,"By JBM $j","2006-01-26"); + dec $j; +} +--enable_query_log +ALTER TABLE t1 COALESCE PARTITION 4; + +DROP TABLE t1; + +# +# Bug 16822: OPTIMIZE TABLE hangs test +# +CREATE TABLE t1 (a int primary key) +ENGINE=NDB +PARTITION BY KEY(a); +--error 1031 +ALTER TABLE t1 OPTIMIZE PARTITION p0; +--error 1031 +ALTER TABLE t1 CHECK PARTITION p0; +--error 1031 +ALTER TABLE t1 REPAIR PARTITION p0; +--error 1031 +ALTER TABLE t1 ANALYZE PARTITION p0; +--error 1031 +ALTER TABLE t1 REBUILD PARTITION p0; +DROP TABLE t1; + +# +# BUG 16806: ALTER TABLE fails +# +CREATE TABLE t1 ( + c1 MEDIUMINT NOT NULL AUTO_INCREMENT, + c2 TEXT NOT NULL, + c3 INT NOT NULL, + PRIMARY KEY(c1,c3)) + ENGINE=NDB + PARTITION BY KEY(c3) PARTITIONS 5; + +ALTER TABLE t1 ADD COLUMN c4 INT AFTER c1; +DROP TABLE t1; + +CREATE TABLE t1 ( + c1 MEDIUMINT NOT NULL AUTO_INCREMENT, + c2 TEXT NOT NULL, + c3 INT NOT NULL, + PRIMARY KEY(c1,c3)) + ENGINE=NDB + PARTITION BY KEY(c3) + (PARTITION p0 NODEGROUP 0, PARTITION p1 NODEGROUP 0); + +ALTER TABLE t1 ADD COLUMN c4 INT AFTER c1; +SELECT NODEGROUP,PARTITION_NAME FROM information_schema.partitions WHERE +table_name = "t1"; +DROP TABLE t1; + +# bug#25587 + +CREATE TABLE t1 ( +a tinyint unsigned NOT NULL, +b bigint(20) unsigned NOT NULL, +c char(12), +PRIMARY KEY (a,b) +) ENGINE ndb DEFAULT CHARSET=latin1 PARTITION BY KEY (a); + +insert into t1 values(1,1,'1'), (2,2,'2'), (3,3,'3'), (4,4,'4'), (5,5,'5'); +select * from t1 where a = 1; +select * from t1 where a = 2; +select * from t1 where a = 3; +select * from t1 where a = 4; +select * from t1 where a = 5; +delete from t1 where a = 1; +select * from t1 order by 1; +delete from t1 where a = 2; +select * from t1 order by 1; +delete from t1 where a = 3; +select * from t1 order by 1; +delete from t1 where a = 4; +select * from t1 order by 1; +delete from t1 where a = 5; +select * from t1 order by 1; + +drop table t1; diff --git a/mysql-test/suite/ndb/t/ndb_partition_list.test b/mysql-test/suite/ndb/t/ndb_partition_list.test new file mode 100644 index 00000000000..ccfcdbc84f4 --- /dev/null +++ b/mysql-test/suite/ndb/t/ndb_partition_list.test @@ -0,0 +1,68 @@ +--source include/have_ndb.inc +# +# Simple test for the partition storage engine +# Focuses on range partitioning tests +# +#-- source include/have_partition.inc + +--disable_query_log +set new=on; +--enable_query_log + +--disable_warnings +drop table if exists t1; +--enable_warnings + +# +# Partition by list, basic +# + +CREATE TABLE t1 ( f_int1 INTEGER NOT NULL, f_int2 INTEGER NOT NULL, + f_char1 CHAR(10), + f_char2 CHAR(10), f_charbig VARCHAR(1000), +PRIMARY KEY (f_int1,f_int2)) +ENGINE = NDB +PARTITION BY LIST(MOD(f_int1 + f_int2,4)) +(PARTITION part_3 VALUES IN (-3), + PARTITION part_2 VALUES IN (-2), + PARTITION part_1 VALUES IN (-1), + PARTITION part0 VALUES IN (0), + PARTITION part1 VALUES IN (1), + PARTITION part2 VALUES IN (2), + PARTITION part3 VALUES IN (3,4,5)); + +INSERT INTO t1 SET f_int1 = -2, f_int2 = 20, f_char1 = '20', f_char2 = '20', f_charbig = '===20==='; +INSERT INTO t1 SET f_int1 = 1, f_int2 = 1, f_char1 = '1', f_char2 = '1', f_charbig = '===1==='; +INSERT INTO t1 SET f_int1 = 2, f_int2 = 1, f_char1 = '1', f_char2 = '1', f_charbig = '===1==='; +INSERT INTO t1 SET f_int1 = 3, f_int2 = 1, f_char1 = '1', f_char2 = '1', f_charbig = '===1==='; +INSERT INTO t1 SET f_int1 = 4, f_int2 = 1, f_char1 = '1', f_char2 = '1', f_charbig = '===1==='; +INSERT INTO t1 SET f_int1 = 5, f_int2 = 1, f_char1 = '1', f_char2 = '1', f_charbig = '===1==='; +INSERT INTO t1 SET f_int1 = 20, f_int2 = 1, f_char1 = '1', f_char2 = '1', f_charbig = '===1==='; + +SELECT * FROM t1 ORDER BY f_int1; + +DROP TABLE t1; + +# +# Partition by list, no pk +# + +CREATE TABLE t1 ( f_int1 INTEGER, f_int2 INTEGER, f_char1 CHAR(10), + f_char2 CHAR(10), f_charbig VARCHAR(1000)) +ENGINE = NDB +PARTITION BY LIST(f_int1) +(PARTITION part_1 VALUES IN (-1), + PARTITION part0 VALUES IN (0,1), + PARTITION part1 VALUES IN (2)); + +INSERT INTO t1 SET f_int1 = -1, f_int2 = 20, f_char1 = '20', f_char2 = '20', f_charbig = '===20==='; +INSERT INTO t1 SET f_int1 = 0, f_int2 = 20, f_char1 = '20', f_char2 = '20', f_charbig = '===20==='; +INSERT INTO t1 SET f_int1 = 1, f_int2 = 1, f_char1 = '1', f_char2 = '1', f_charbig = '===1==='; +INSERT INTO t1 SET f_int1 = 2, f_int2 = 1, f_char1 = '1', f_char2 = '1', f_charbig = '===1==='; +--error ER_NO_PARTITION_FOR_GIVEN_VALUE +INSERT INTO t1 SET f_int1 = 20, f_int2 = 1, f_char1 = '1', f_char2 = '1', f_charbig = '===1==='; + +SELECT * FROM t1 ORDER BY f_int1; + +DROP TABLE t1; + diff --git a/mysql-test/suite/ndb/t/ndb_partition_range.test b/mysql-test/suite/ndb/t/ndb_partition_range.test new file mode 100644 index 00000000000..7952ba502d2 --- /dev/null +++ b/mysql-test/suite/ndb/t/ndb_partition_range.test @@ -0,0 +1,264 @@ +-- source include/have_ndb.inc +#--disable_abort_on_error +# +# Simple test for the partition storage engine +# Focuses on range partitioning tests +# +#-- source include/have_partition.inc + +--disable_query_log +set new=on; +--enable_query_log + +--disable_warnings +drop table if exists t1; +--enable_warnings + +# +# Partition by range, basic +# +CREATE TABLE t1 ( +a int not null, +b int not null, +c int not null, +primary key(a,b), +index (a)) +engine = ndb +partition by range (a) +partitions 3 +(partition x1 values less than (5), + partition x2 values less than (10), + partition x3 values less than (20)); + +# Simple insert and verify test +INSERT into t1 values (1, 1, 1); +INSERT into t1 values (6, 1, 1); +INSERT into t1 values (10, 1, 1); +INSERT into t1 values (15, 1, 1); + +--replace_column 16 # 19 # 20 # +select * from information_schema.partitions where table_name= 't1'; + +select * from t1 order by a; + +select * from t1 where a=1 order by a; +select * from t1 where a=15 and b=1 order by a; +select * from t1 where a=21 and b=1 order by a; +select * from t1 where a=21 order by a; +select * from t1 where a in (1,6,10,21) order by a; +select * from t1 where b=1 and a in (1,6,10,21) order by a; + +drop table t1; + +# +# Partition by range, basic +# +CREATE TABLE t1 ( +a int not null, +b int not null, +c int not null, +primary key(b), +unique (a)) +engine = ndb +partition by range (b) +partitions 3 +(partition x1 values less than (5), + partition x2 values less than (10), + partition x3 values less than (20)); + +# Simple insert and verify test +INSERT into t1 values (1, 1, 1); +INSERT into t1 values (2, 6, 1); +INSERT into t1 values (3, 10, 1); +INSERT into t1 values (4, 15, 1); + +select * from t1 order by a; +UPDATE t1 set a = 5 WHERE b = 15; +select * from t1 order by a; +UPDATE t1 set a = 6 WHERE a = 5; +select * from t1 order by a; + +select * from t1 where b=1 order by b; +select * from t1 where b=15 and a=1 order by b; +select * from t1 where b=21 and a=1 order by b; +select * from t1 where b=21 order by b; +select * from t1 where b in (1,6,10,21) order by b; +select * from t1 where a in (1,2,5,6) order by b; +select * from t1 where a=1 and b in (1,6,10,21) order by b; + +DELETE from t1 WHERE b = 6; +DELETE from t1 WHERE a = 6; + +# +# Test that explicit partition info _is_ shown in show create table +# result _should_ contain (PARTITION x1 ... etc) +# +show create table t1; + +drop table t1; + +# +# Bug #17499, #17687 +# Alter partitioned NDB table causes mysqld to core +# + +CREATE TABLE t1 + (id MEDIUMINT NOT NULL, + b1 BIT(8), + vc VARCHAR(255), + bc CHAR(255), + d DECIMAL(10,4) DEFAULT 0, + f FLOAT DEFAULT 0, + total BIGINT UNSIGNED, + y YEAR, + t DATE) ENGINE=NDB + PARTITION BY RANGE (YEAR(t)) + (PARTITION p0 VALUES LESS THAN (1901), + PARTITION p1 VALUES LESS THAN (1946), + PARTITION p2 VALUES LESS THAN (1966), + PARTITION p3 VALUES LESS THAN (1986), + PARTITION p4 VALUES LESS THAN (2005), + PARTITION p5 VALUES LESS THAN MAXVALUE); + +INSERT INTO t1 VALUES (0,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL); +SELECT * FROM t1; +ALTER TABLE t1 ENGINE=MYISAM; +SELECT * FROM t1; +DROP TABLE t1; + +CREATE LOGFILE GROUP lg1 + ADD UNDOFILE 'undofile.dat' + INITIAL_SIZE 16M + UNDO_BUFFER_SIZE=1M + ENGINE=NDB; + +CREATE TABLESPACE ts1 + ADD DATAFILE 'datafile.dat' + USE LOGFILE GROUP lg1 + INITIAL_SIZE 12M + ENGINE NDB; + +CREATE TABLE test.t1 ( + a1 INT, + a2 TEXT NOT NULL, + a3 BIT NOT NULL, + a4 DECIMAL(8,3), + a5 INT NOT NULL, + a6 INT, + PRIMARY KEY(a1)) + TABLESPACE ts1 STORAGE DISK ENGINE=NDB + PARTITION BY LIST (a1) + (PARTITION p0 VALUES IN (1,2,3,4,5), + PARTITION p1 VALUES IN (6,7,8,9, 10), + PARTITION p2 VALUES IN (11, 12, 13, 14, 15)); + +# Alter table directly without any statements inbetween +ALTER TABLE test.t1 DROP COLUMN a6; +ALTER TABLE test.t1 ADD COLUMN a6 VARCHAR(255); + +let $j= 15; +--disable_query_log +while ($j) +{ +eval INSERT INTO test.t1 VALUES ($j, "Tested Remotely from Texas, USA", +b'1',$j.00,$j+1,"By NIK $j"); +dec $j; +} +--enable_query_log +SELECT COUNT(*) FROM test.t1; + +ALTER TABLE test.t1 DROP COLUMN a4; +SELECT COUNT(*) FROM test.t1; + +DROP TABLE t1; + +CREATE TABLE test.t1 ( + a1 INT, + a2 TEXT NOT NULL, + a3 BIT NOT NULL, + a4 DECIMAL(8,3), + a5 INT NOT NULL, + a6 VARCHAR(255), + PRIMARY KEY(a1)) + TABLESPACE ts1 STORAGE DISK ENGINE=NDB + PARTITION BY HASH(a1) + PARTITIONS 4; + +let $j= 15; +--disable_query_log +while ($j) +{ +eval INSERT INTO test.t1 VALUES ($j, "Tested Remotely from Texas, USA", +b'1',$j.00,$j+1,"By NIK $j"); +dec $j; +} +--enable_query_log +SELECT COUNT(*) FROM test.t1; + +ALTER TABLE test.t1 DROP COLUMN a4; +SELECT COUNT(*) FROM test.t1; + +DROP TABLE t1; + +ALTER TABLESPACE ts1 + DROP DATAFILE 'datafile.dat' + ENGINE=NDB; +DROP TABLESPACE ts1 ENGINE=NDB; +DROP LOGFILE GROUP lg1 ENGINE=NDB; + + +# +# Bug #17701 ALTER TABLE t1 ADD PARTITION for PARTITION BY LIST hangs test +# + +CREATE TABLE t1 + (id MEDIUMINT NOT NULL, + b1 BIT(8), + vc VARCHAR(255), + bc CHAR(255), + d DECIMAL(10,4) DEFAULT 0, + f FLOAT DEFAULT 0, + total BIGINT UNSIGNED, + y YEAR, + t DATE) ENGINE=NDB + PARTITION BY LIST(id) + (PARTITION p0 VALUES IN (2, 4), + PARTITION p1 VALUES IN (42, 142)); + +INSERT INTO t1 VALUES (2,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL); +SELECT * FROM t1; +ALTER TABLE t1 ADD PARTITION + (PARTITION p2 VALUES IN (412)); +SELECT * FROM t1; +DROP TABLE t1; + +# +# Bug #17806 Update on NDB table with list partition causes mysqld to core +# Bug #16385 Partitions: crash when updating a range partitioned NDB table +# +CREATE TABLE t1 ( +a int not null, +b int not null, +c int not null) +partition by list(a) +partitions 2 +(partition x123 values in (1,5,6), + partition x234 values in (4,7,8)); +INSERT into t1 VALUES (5,1,1); +select * from t1; +UPDATE t1 SET a=8 WHERE a=5 AND b=1; +select * from t1; +drop table t1; + +CREATE TABLE t1 ( f1 INTEGER, f2 char(20)) engine=ndb +PARTITION BY RANGE(f1) +( PARTITION part1 VALUES LESS THAN (2), +PARTITION part2 VALUES LESS THAN (1000)); +INSERT INTO t1 VALUES(1, '---1---'); +INSERT INTO t1 VALUES(2, '---2---'); +select * from t1 order by f1; +UPDATE t1 SET f1 = f1 + 4 WHERE f1 = 2; +select * from t1 order by f1; +UPDATE t1 SET f1 = f1 + 4 WHERE f1 = 1; +select * from t1 order by f1; +drop table t1; diff --git a/mysql-test/suite/ndb/t/ndb_read_multi_range.test b/mysql-test/suite/ndb/t/ndb_read_multi_range.test new file mode 100644 index 00000000000..ecca1f9862c --- /dev/null +++ b/mysql-test/suite/ndb/t/ndb_read_multi_range.test @@ -0,0 +1,319 @@ +-- source include/have_ndb.inc +-- source include/not_embedded.inc + +--disable_warnings +DROP TABLE IF EXISTS t1, t2, r1; +--enable_warnings + +# +# Basic test to see that batching is working +# + +create table t1 ( + a int primary key, + b int not null, + c int not null, + index(b), unique index using hash(c) +) engine = ndb; +insert into t1 values + (1,2,1),(2,3,2),(3,4,3),(4,5,4), + (5,2,12),(6,3,11),(7,4,10),(8,5,9), + (9,2,8),(10,3,7),(11,4,6),(12,5,5); + +# batch on primary key +create table r1 as select * from t1 where a in (2,8,12); +select * from r1 order by a; +drop table r1; + +# batch on ordered index +create table r1 as select * from t1 where b in (1,2,5); +select * from r1 order by a; +drop table r1; + +# batch on unique hash index +create table r1 as select * from t1 where c in (2,8,12); +select * from r1 order by a; +drop table r1; + +# batch mixed +create table r1 as select * from t1 where a in (2,8) or (a > 11) or (a <= 1); +select * from r1 order by a; +drop table r1; + +# batch on primary key, missing values +create table r1 as select * from t1 where a in (33,8,12); +select * from r1 order by a; +drop table r1; +create table r1 as select * from t1 where a in (2,33,8,12,34); +select * from r1 order by a; +drop table r1; + +# batch on ordered index, missing values +create table r1 as select * from t1 where b in (1,33,5); +select * from r1 order by a; +drop table r1; +select * from t1 where b in (1,33,5) order by a; +create table r1 as select * from t1 where b in (45,1,33,5,44); +select * from r1 order by a; +drop table r1; +select * from t1 where b in (45,22) order by a; + +# batch on unique hash index, missing values +create table r1 as select * from t1 where c in (2,8,33); +select * from r1 order by a; +drop table r1; +create table r1 as select * from t1 where c in (13,2,8,33,12); +select * from r1 order by a; +drop table r1; + +select * from t1 where a in (33,8,12) order by a; +select * from t1 where a in (33,34,35) order by a; +select * from t1 where a in (2,8) or (a > 11) or (a <= 1) order by a; +select * from t1 where b in (6,7) or (b <= 5) or (b >= 10) order by b,a; +select * from t1 where c in (13,2,8,33,12) order by c,a; +drop table t1; + +# +# Somewhat more complicated +# + +create table t1 ( + a int not null, + b int not null, + c int not null, + d int not null, + e int not null, + primary key (a,b,c,d), index (d) +) engine = ndb; + +insert into t1 values + (1,2,1,1,1),(2,3,2,3,1),(3,4,3,1,1),(4,5,4,7,1), + (5,2,12,12,1),(6,3,11,1,1),(7,4,10,3,1),(8,5,9,5,1), + (9,2,8,6,1),(10,3,7,5,1),(11,4,6,3,1),(12,5,5,2,1), + (1,2,1,2,1), + (1,2,1,3,1), + (1,2,1,4,1), + (1,2,1,5,1); + +# batch on primary key +create table r1 as select * from t1 + where a=1 and b=2 and c=1 and d in (1,4,3,2); +select * from r1 order by a,b,c,d; +drop table r1; + +# batched update ordered index, one value for all +update t1 set e = 100 + where d in (12,6,7); +select * from t1 where d in (12,6,7) order by a,b,c,d; +select * from t1 where d not in (12,6,7) and e = 100; + +# batched update primary key, one value for all +update t1 + set e = 101 + where a=1 and + b=2 and + c=1 and + d in (1,4,3,2); +select * + from t1 + where a=1 and b=2 and c=1 and d in (1,4,3,2) + order by a,b,c,d; +select * + from t1 + where not (a=1 and b=2 and c=1 and d in (1,4,3,2)) + and e=101; + + +# batched update ordered index, different values +update t1 + set e = + (case d + when 12 then 112 + when 6 then 106 + when 7 then 107 + end) + where d in (12,6,7); +select * from t1 where d in (12,6,7) order by a,b,c,d; + +# batched update primary key, different values +update t1 + set e = + (case d + when 1 then 111 + when 4 then 444 + when 3 then 333 + when 2 then 222 + end) + where a=1 and + b=2 and + c=1 and + d in (1,4,3,2); +select * + from t1 + where a=1 and b=2 and c=1 and d in (1,4,3,2) + order by a,b,c,d; + +# batched delete +delete from t1 where d in (12,6,7); +select * from t1 where d in (12,6,7); + +drop table t1; + +# null handling +create table t1 ( + a int not null primary key, + b int, + c int, + d int, + unique index (b), + index(c) +) engine = ndb; + +insert into t1 values + (1,null,1,1), + (2,2,2,2), + (3,null,null,3), + (4,4,null,4), + (5,null,5,null), + (6,6,6,null), + (7,null,null,null), + (8,8,null,null), + (9,null,9,9), + (10,10,10,10), + (11,null,null,11), + (12,12,null,12), + (13,null,13,null), + (14,14,14,null), + (15,null,null,null), + (16,16,null,null); + +create table t2 as select * from t1 where a in (5,6,7,8,9,10); +select * from t2 order by a; +drop table t2; + +create table t2 as select * from t1 where b in (5,6,7,8,9,10); +select * from t2 order by a; +drop table t2; + +create table t2 as select * from t1 where c in (5,6,7,8,9,10); +select * from t2 order by a; +drop table t2; + +drop table t1; + +# bug17729 + +CREATE TABLE t1 ( + a int(11) NOT NULL, + b int(11) NOT NULL, + c datetime default NULL, + PRIMARY KEY (a), + KEY idx_bc (b,c) +) ENGINE=ndbcluster; + +INSERT INTO t1 VALUES +(406989,67,'2006-02-23 17:08:46'), (150078,67,'2005-10-26 11:17:45'), +(406993,67,'2006-02-27 11:20:57'), (245655,67,'2005-12-08 15:59:08'), +(406994,67,'2006-02-27 11:26:46'), (256,67,NULL), +(398341,67,'2006-02-20 04:48:44'), (254,67,NULL),(1120,67,NULL), +(406988,67,'2006-02-23 17:07:22'), (255,67,NULL), +(398340,67,'2006-02-20 04:38:53'),(406631,67,'2006-02-23 10:49:42'), +(245653,67,'2005-12-08 15:59:07'),(406992,67,'2006-02-24 16:47:18'), +(245654,67,'2005-12-08 15:59:08'),(406995,67,'2006-02-28 11:55:00'), +(127261,67,'2005-10-13 12:17:58'),(406991,67,'2006-02-24 16:42:32'), +(245652,67,'2005-12-08 15:58:27'),(398545,67,'2006-02-20 04:53:13'), +(154504,67,'2005-10-28 11:53:01'),(9199,67,NULL),(1,67,'2006-02-23 15:01:35'), +(223456,67,NULL),(4101,67,NULL),(1133,67,NULL), +(406990,67,'2006-02-23 18:01:45'),(148815,67,'2005-10-25 15:34:17'), +(148812,67,'2005-10-25 15:30:01'),(245651,67,'2005-12-08 15:58:27'), +(154503,67,'2005-10-28 11:52:38'); + +create table t11 engine = ndbcluster select * from t1 where b = 67 AND (c IS NULL OR c > NOW()) order by 3 asc; +create table t12 engine = ndbcluster select * from t1 where b = 67 AND (c IS NULL OR c > NOW()) order by 3 desc; +create table t21 select * from t1 where b = 67 AND (c IS NULL OR c > '2005-12-08') order by 3 asc; +create table t22 engine = ndbcluster select * from t1 where b = 67 AND (c IS NULL OR c > '2005-12-08') order by 3 desc; + +select * from t11 order by 1,2,3; +select * from t12 order by 1,2,3; +select * from t21 order by 1,2,3; +select * from t22 order by 1,2,3; + +# join tests +select t12.a from t11, t12 where t11.a in(255,256) and t11.a = t12.a and t11.c is null order by t12.a; + +update t22 set c = '2005-12-08 15:58:27' where a = 255; +select * from t22 order by 1,2,3; +select t21.* from t21,t22 where t21.a = t22.a and +t22.a in (select t12.a from t11, t12 where t11.a in(255,256) and t11.a = t12.a and t11.c is null) and t22.c is null order by t21.a; + +delete from t22 where a > 245651; +update t22 set b = a + 1; +select * from t22 order by 1,2,3; +select t21.c, count(*) +from t21 +inner join t22 using (a) +where t22.b in (2,256,257,1121,1134,4102,9200,223457,245652) +group by t21.c +order by t21.c; + +DROP TABLE t1, t11, t12, t21, t22; + +# bug#19956 +CREATE TABLE t1 (id varchar(255) NOT NULL, + tag int(11) NOT NULL, + doc text NOT NULL, + type varchar(150) NOT NULL, + modified timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, + PRIMARY KEY (id) + ) ENGINE=ndbcluster; + +INSERT INTO t1 VALUES ('sakila',1,'Some text goes here','text',CURRENT_TIMESTAMP); +SELECT id, tag, doc, type FROM t1 WHERE id IN ('flipper','orka'); +SELECT id, tag, doc, type FROM t1 WHERE id IN ('flipper','sakila'); + +DROP TABLE t1; + +#bug#25522 +CREATE TABLE t1 ( + var1 int(2) NOT NULL, + var2 int(2) NOT NULL, + PRIMARY KEY (var1) + ) ENGINE=ndbcluster DEFAULT CHARSET=ascii CHECKSUM=1; + + +CREATE TABLE t2 ( + var1 int(2) NOT NULL, + var2 int(2) NOT NULL, + PRIMARY KEY (var1) + ) ENGINE=ndbcluster DEFAULT CHARSET=ascii CHECKSUM=1; + + +DELIMITER |; +CREATE TRIGGER testtrigger + AFTER UPDATE ON t1 FOR EACH ROW BEGIN + REPLACE INTO t2 SELECT * FROM t1 WHERE t1.var1 = NEW.var1;END| +DELIMITER ;| + +INSERT INTO t1 VALUES (1,1),(2,2),(3,3); + +UPDATE t1 SET var2 = 9 WHERE var1 IN(1,2,3); + +DROP TRIGGER testtrigger; + +DROP TABLE t1, t2; + +#bug#25821 +create table t1 (a int, b int, primary key (a), key ab (a,b)) engine=ndbcluster; + +insert into t1 values (1,1), (10,10); + +select * from t1 use index (ab) where a in(1,10) order by a; + +create table t2 (a int, b int, primary key (a,b)) engine=ndbcluster +partition by key(a); + +insert into t2 values (1,1), (10,10); + +select * from t2 where a in (1,10) order by a; + +drop table t1, t2; diff --git a/mysql-test/suite/ndb/t/ndb_rename.test b/mysql-test/suite/ndb/t/ndb_rename.test new file mode 100644 index 00000000000..7f9fd0e6984 --- /dev/null +++ b/mysql-test/suite/ndb/t/ndb_rename.test @@ -0,0 +1,36 @@ +-- source include/have_ndb.inc +-- source include/not_embedded.inc + +--disable_warnings +DROP TABLE IF EXISTS t1,t2; +drop database if exists mysqltest; +--enable_warnings + +# +# Table rename tests +# + +# +# Create a normal table with primary key +# +CREATE TABLE t1 ( + pk1 INT NOT NULL PRIMARY KEY, + attr1 INT NOT NULL, + attr2 INT, + attr3 VARCHAR(10), + INDEX i1(attr1) +) ENGINE=ndbcluster; + +INSERT INTO t1 VALUES (0,0,0,"zero"),(1,1,1,"one"),(2,2,2,"two"); +SELECT * FROM t1 WHERE attr1 = 1; +alter table t1 rename t2; +SELECT * FROM t2 WHERE attr1 = 1; + +create database ndbtest; +alter table t2 rename ndbtest.t2; +SELECT * FROM ndbtest.t2 WHERE attr1 = 1; + +drop table ndbtest.t2; +drop database ndbtest; + +# End of 4.1 tests diff --git a/mysql-test/suite/ndb/t/ndb_replace.test b/mysql-test/suite/ndb/t/ndb_replace.test new file mode 100644 index 00000000000..aa2072b98dd --- /dev/null +++ b/mysql-test/suite/ndb/t/ndb_replace.test @@ -0,0 +1,104 @@ +-- source include/have_ndb.inc +-- source include/not_embedded.inc + +# +# Test of REPLACE with NDB +# + +--disable_warnings +drop table if exists t1,t2; +--enable_warnings + +CREATE TABLE t1 ( + gesuchnr int(11) DEFAULT '0' NOT NULL, + benutzer_id int(11) DEFAULT '0' NOT NULL, + PRIMARY KEY (gesuchnr,benutzer_id) +) engine=ndbcluster; + +replace into t1 (gesuchnr,benutzer_id) values (2,1); +replace into t1 (gesuchnr,benutzer_id) values (1,1); +replace into t1 (gesuchnr,benutzer_id) values (1,1); +insert into t1 (gesuchnr, benutzer_id) value (3,2); +replace into t1 (gesuchnr,benutzer_id) values (1,1); +replace into t1 (gesuchnr,benutzer_id) values (1,1); +--error ER_DUP_ENTRY +insert into t1 (gesuchnr,benutzer_id) values (1,1); +replace into t1 (gesuchnr,benutzer_id) values (1,1); +select * from t1 order by gesuchnr; +drop table t1; + +# End of 4.1 tests + +# bug#17431 +CREATE TABLE t1(i INT PRIMARY KEY AUTO_INCREMENT, + j INT, + k INT, + UNIQUE INDEX(j) + ) ENGINE = ndb; +INSERT INTO t1 VALUES (1,1,23),(2,2,24); +REPLACE INTO t1 (j,k) VALUES (1,42); +REPLACE INTO t1 (i,j) VALUES (17,2); +SELECT * from t1 ORDER BY i; +DROP TABLE t1; + +# bug#19906 +CREATE TABLE t2 (a INT(11) NOT NULL, + b INT(11) NOT NULL, + c INT(11) NOT NULL, + x TEXT, + y TEXT, + z TEXT, + id INT(10) unsigned NOT NULL AUTO_INCREMENT, + i INT(11) DEFAULT NULL, + PRIMARY KEY (id), + UNIQUE KEY a (a,b,c) +) ENGINE=ndbcluster; + +REPLACE INTO t2 (a,b,c,x,y,z,i) VALUES (1,1,1,'a','a','a',1),(1,1,1,'b','b','b',2), (1,1,1,'c','c','c',3); + +SELECT * FROM t2 ORDER BY id; + +REPLACE INTO t2(a,b,c,x,y,z,i) values (1,1,1,'a','a','a',1); +REPLACE INTO t2(a,b,c,x,y,z,i) values (1,1,1,'b','b','b',2); + +SELECT * FROM t2 ORDER BY id; + +DROP TABLE t2; + +# +# Bug #20728 "REPLACE does not work correctly for NDB table with PK and +# unique index" +# +--disable_warnings +drop table if exists t1; +--enable_warnings +create table t1 (pk int primary key, apk int unique, data int) engine=ndbcluster; +# Test for plain replace which updates pk +insert into t1 values (1, 1, 1), (2, 2, 2), (3, 3, 3); +replace into t1 (pk, apk) values (4, 1), (5, 2); +select * from t1 order by pk; +delete from t1; +# Another test for plain replace which doesn't touch pk +insert into t1 values (1, 1, 1), (2, 2, 2), (3, 3, 3); +replace into t1 (pk, apk) values (1, 4), (2, 5); +select * from t1 order by pk; +delete from t1; +# Test for load data replace which updates pk +insert into t1 values (1, 1, 1), (4, 4, 4), (6, 6, 6); +load data infile '../std_data_ln/loaddata5.dat' replace into table t1 fields terminated by '' enclosed by '' ignore 1 lines (pk, apk); +select * from t1 order by pk; +delete from t1; +# Now test for load data replace which doesn't touch pk +insert into t1 values (1, 1, 1), (3, 3, 3), (5, 5, 5); +load data infile '../std_data_ln/loaddata5.dat' replace into table t1 fields terminated by '' enclosed by '' ignore 1 lines (pk, apk); +select * from t1 order by pk; +delete from t1; +# Finally test for both types of replace ... select +insert into t1 values (1, 1, 1), (2, 2, 2), (3, 3, 3); +replace into t1 (pk, apk) select 4, 1; +replace into t1 (pk, apk) select 2, 4; +select * from t1 order by pk; +# Clean-up +drop table t1; + +--echo End of 5.0 tests. diff --git a/mysql-test/suite/ndb/t/ndb_restore.test b/mysql-test/suite/ndb/t/ndb_restore.test new file mode 100644 index 00000000000..7f0cafdfd77 --- /dev/null +++ b/mysql-test/suite/ndb/t/ndb_restore.test @@ -0,0 +1,403 @@ +-- source include/have_ndb.inc +-- source include/ndb_default_cluster.inc +-- source include/not_embedded.inc + +--disable_warnings +use test; +drop table if exists t1,t2,t3,t4,t5,t6,t7,t8,t9,t10; +drop table if exists t1_c,t2_c,t3_c,t4_c,t5_c,t6_c,t7_c,t8_c,t9_c,t10_c; +--enable_warnings + +# Bug #27775 - mediumint auto inc not restored correctly +# - check mediumint +CREATE TABLE `t1_c` ( + `capgoaledatta` mediumint(5) unsigned NOT NULL auto_increment, + `goaledatta` char(2) NOT NULL default '', + `maturegarbagefa` varchar(32) NOT NULL default '', + PRIMARY KEY (`capgoaledatta`,`goaledatta`,`maturegarbagefa`) +) ENGINE=ndbcluster DEFAULT CHARSET=latin1; +INSERT INTO `t1_c` VALUES (2,'3','q3plus.qt'),(400,'4','q3plus.qt'),(1,'3','q3.net'),(3,'4','q3.net'),(3000,'20','threetrees.qt'); +# +# Bug #27758 Restoring NDB backups makes table usable in SQL nodes +# - space in key made table unusable after restore +# +# Bug #27775 - mediumint auto inc not restored correctly +# - check smallint +CREATE TABLE `t2_c` ( + `capgotod` smallint(5) unsigned NOT NULL auto_increment, + `gotod` smallint(5) unsigned NOT NULL default '0', + `goaledatta` char(2) default NULL, + `maturegarbagefa` varchar(32) default NULL, + `descrpooppo` varchar(64) default NULL, + `svcutonsa` varchar(64) NOT NULL default '', + PRIMARY KEY (`capgotod`), + KEY `i quadaddsvr` (`gotod`) +) ENGINE=ndbcluster DEFAULT CHARSET=latin1; +INSERT INTO `t2_c` VALUES (500,4,'','q3.net','addavp:MK_CASELECTOR=1','postorod rattoaa'),(2,1,'4','','addavp:MK_BRANDTAD=345','REDS Brandtad'),(3,2,'4','q3.net','execorder','fixedRatediPO REDS'),(1,1,'3','','addavp:MK_BRANDTAD=123','TEST Brandtad'),(6,5,'','told.q3.net','addavp:MK_BRANDTAD=123','Brandtad Toldzone'),(4,3,'3','q3.net','addavp:MK_POOLHINT=2','ratedi PO TEST'),(5,0,'',NULL,NULL,''); + +# Added ROW_FORMAT=FIXED to use below to see that setting is preserved +# by restore +CREATE TABLE `t3_c` ( + `CapGoaledatta` smallint(5) unsigned NOT NULL default '0', + `capgotod` smallint(5) unsigned NOT NULL default '0', + PRIMARY KEY (`capgotod`,`CapGoaledatta`) +) ENGINE=ndbcluster DEFAULT CHARSET=latin1 ROW_FORMAT=FIXED; +INSERT INTO `t3_c` VALUES (5,3),(2,4),(5,4),(1,3); + +# Bug #27775 - mediumint auto inc not restored correctly +# - check bigint +CREATE TABLE `t4_c` ( + `capfa` bigint(20) unsigned NOT NULL auto_increment, + `realm` varchar(32) NOT NULL default '', + `authpwchap` varchar(32) default NULL, + `fa` varchar(32) NOT NULL default '', + `payyingatta` tinyint(4) NOT NULL default '0', + `status` char(1) default NULL, + PRIMARY KEY (`fa`,`realm`), + KEY `capfa` (`capfa`), + KEY `i_quadentity` (`fa`,`realm`) +) ENGINE=ndbcluster DEFAULT CHARSET=latin1; +INSERT INTO `t4_c` VALUES (18,'john.smith','q3.net','dessjohn.smith',0,NULL),(21,'quad_katt_with_brandtad','q3.net','acne',0,NULL),(2200,'quad_katt_carattoaa','q3.net','acne',0,NULL),(26,'436462612809','sqasdt.q3.net','N/A',0,'6'),(19,'john','smith.qt','dessjohn',0,NULL),(33,'436643196120','sqasdt.q3.net','N/A',1,'6'),(28,'436642900019','sqasdt.q3.net','N/A',0,'6'),(30,'436462900209','sqasdt.q3.net','N/A',0,'6'),(16,'436640006666','sqasdt.q3.net','',0,NULL),(19,'dette','el-redun.com','dessdette',0,NULL),(12,'quad_kattPP','q3.net','acne',2,NULL),(14,'436640008888','sqasdt.q3.net','',0,NULL),(29,'463624900028','sqasdt.q3.net','N/A',0,'6'),(15,'436640099099','sqasdt.q3.net','',0,NULL),(13,'pap','q3plus.qt','acne',1,NULL),(19,'436642612091','sqasdt.q3.net','N/A',0,'6'),(12,'quad_katt','q3.net','acne',0,NULL),(11,'quad_kattVK','q3.net','acne',1,NULL),(32000,'463641969502','sqasdt.q3.net','N/A',1,'6'),(20,'joe','q3.net','joedesswd',0,NULL),(290000000,'436642900034','sqasdt.q3.net','N/A',0,'6'),(25,'contind','armerde.qt','acne',1,NULL); + +CREATE TABLE `t5_c` ( + `capfa` bigint(20) unsigned NOT NULL default '0', + `gotod` smallint(5) unsigned NOT NULL default '0', + `orderutonsa` varchar(64) NOT NULL default '', + PRIMARY KEY (`capfa`,`gotod`,`orderutonsa`) +) ENGINE=ndbcluster DEFAULT CHARSET=latin1; +INSERT INTO `t5_c` VALUES (21,2,''),(21,1,''),(22,4,''); + +CREATE TABLE `t6_c` ( + `capfa_parent` bigint(20) unsigned NOT NULL default '0', + `capfa_child` bigint(20) unsigned NOT NULL default '0', + `relatta` smallint(5) unsigned NOT NULL default '0', + PRIMARY KEY (`capfa_child`,`capfa_parent`,`relatta`) +) ENGINE=ndbcluster DEFAULT CHARSET=latin1; +INSERT INTO `t6_c` VALUES (15,16,0),(19,20,0),(18326932092909551615,30,0),(26,29,0),(18326932092909551615,29,0),(19,18,0),(26,28,0),(12,14,0); + +# Bug #27775 - mediumint auto inc not restored correctly +# - check tinyint +CREATE TABLE `t7_c` ( + `dardpo` char(15) NOT NULL default '', + `dardtestard` tinyint(3) unsigned NOT NULL auto_increment, + `FastFA` char(5) NOT NULL default '', + `FastCode` char(6) NOT NULL default '', + `Fastca` char(1) NOT NULL default '', + `Fastmag` char(1) NOT NULL default '', + `Beareratta` char(2) NOT NULL default '', + PRIMARY KEY (`dardpo`,`dardtestard`) +) ENGINE=ndbcluster DEFAULT CHARSET=latin1; +INSERT INTO `t7_c` VALUES ('2.6.2.4',24,'CECHP','54545','0','0','5'),('2.2.5.4',26,'CANFA','33223','1','1','4'),('4.3.2.4',28,'ITALD','54222','1','0','5'),('129..0.0.eins',28,'G','99999','1','1','5'),('1.1.1.1',24,'AUTPT','32323','0','1','3'); + +CREATE TABLE `t8_c` ( + `kattjame` varchar(32) NOT NULL default '', + `realm` varchar(32) NOT NULL default '', + `realm_entered` varchar(32) NOT NULL default '', + `maturegarbagefa` varchar(32) NOT NULL default '', + `hunderaaarbagefa_parent` varchar(32) NOT NULL default '', + `kattjame_entered` varchar(32) NOT NULL default '', + `hunderaaarbagefa` varchar(32) NOT NULL default '', + `gest` varchar(16) default NULL, + `hassetino` varchar(16) NOT NULL default '', + `aaaproxysessfa` varchar(255) default NULL, + `autologonallowed` char(1) default NULL, + `squardporoot` varchar(15) NOT NULL default '', + `naspo` varchar(15) default NULL, + `beareratta` char(2) default NULL, + `fastCode` varchar(6) default NULL, + `fastFA` varchar(5) default NULL, + `fastca` char(1) default NULL, + `fastmag` char(1) default NULL, + `lastupdate` datetime default NULL, + `hassetistart` datetime NOT NULL default '0000-00-00 00:00:00', + `accthassetitime` int(10) unsigned default NULL, + `acctoutputoctets` bigint(20) unsigned default NULL, + `acctinputoctets` bigint(20) unsigned default NULL, + PRIMARY KEY (`kattjame`,`hunderaaarbagefa`,`hassetistart`,`hassetino`), + KEY `squardporoot` (`squardporoot`) +) ENGINE=ndbcluster DEFAULT CHARSET=latin1; +INSERT INTO `t8_c` VALUES ('4tt45345235','pap','q3plus.qt','q3plus.qt','q3.net','436643196120','436643196929','8956234534568968','5524595699','uxasmt21.net.acne.qt/481889229462692422','','1.1.1.1','2.2.4.6','4','86989','34','x','x','2012-03-12 12:55:34','2012-12-05 11:20:04',3223433,3369,9565),('4545435545','john','q3.net','q3.net','acne.li','436643196120','436643196929','45345234568968','995696699','uxasmt21.net.acne.qt/481889229462692423','','1.1.1.1','2.2.9.8','2','86989','34','x','x','2012-03-12 11:35:03','2012-12-05 08:50:04',8821923,169,3565),('versteckter_q3net_katt','joe','q3.net','elredun.com','q3.net','436643196120','436643196939','91341234568968','695595699','uxasmt21.net.acne.qt/481889229462692421','','1.1.1.1','2.5.2.5','3','86989','34','x','x','2012-03-12 18:35:04','2012-12-05 12:35:04',1923123,9569,6565); + +CREATE TABLE `t9_c` ( + `kattjame` varchar(32) NOT NULL default '', + `kattjame_entered` varchar(32) NOT NULL default '', + `realm` varchar(32) NOT NULL default '', + `realm_entered` varchar(32) NOT NULL default '', + `maturegarbagefa` varchar(32) NOT NULL default '', + `hunderaaarbagefa` varchar(32) NOT NULL default '', + `hunderaaarbagefa_parent` varchar(32) NOT NULL default '', + `gest` varchar(16) default NULL, + `hassetino` varchar(16) NOT NULL default '', + `squardporoot` varchar(15) NOT NULL default '', + `naspo` varchar(15) default NULL, + `beareratta` char(2) default NULL, + `fastCode` varchar(6) default NULL, + `fastFA` varchar(5) default NULL, + `fastca` char(1) default NULL, + `fastmag` char(1) default NULL, + `lastupdate` datetime default NULL, + `hassetistart` datetime NOT NULL default '0000-00-00 00:00:00', + `accthassetitime` int(10) unsigned default NULL, + `actcoutpuocttets` bigint(20) unsigned default NULL, + `actinputocctets` bigint(20) unsigned default NULL, + `terminateraste` tinyint(3) unsigned default NULL, + PRIMARY KEY (`kattjame`,`hunderaaarbagefa`,`hassetistart`,`hassetino`) +) ENGINE=ndbcluster DEFAULT CHARSET=latin1; +INSERT INTO `t9_c` VALUES ('3g4jh8gar2t','joe','q3.net','elredun.com','q3.net','436643316120','436643316939','91341234568968','695595699','1.1.1.1','2.2.6.2','3','86989','34','x','x','2012-03-12 18:35:04','2012-12-05 12:35:04',3123123,9569,6565,1),('4tt45345235','pap','q3plus.qt','q3plus.qt','q3.net','436643316120','436643316939','8956234534568968','5254595969','1.1.1.1','8.6.2.2','4','86989','34','x','x','2012-03-12 12:55:34','2012-12-05 11:20:04',3223433,3369,9565,2),('4545435545','john','q3.net','q3.net','acne.li','436643316120','436643316939','45345234568968','995696699','1.1.1.1','2.9.9.2','2','86998','34','x','x','2012-03-12 11:35:03','2012-12-05 08:50:04',8823123,169,3565,3); + +# Bug #20820 +# auto inc table not handled correctly when restored from cluster backup +# - before fix ndb_restore would not set auto inc value correct, +# seen by select below +CREATE TABLE t10_c (a INT AUTO_INCREMENT KEY) ENGINE=ndbcluster DEFAULT CHARSET=latin1; +INSERT INTO t10_c VALUES (1),(2),(3); +# Bug #27775 - mediumint auto inc not restored correctly +# - check int +insert into t10_c values (10000),(2000),(3000); + +create table t1 engine=myisam as select * from t1_c; +create table t2 engine=myisam as select * from t2_c; +create table t3 engine=myisam as select * from t3_c; +create table t4 engine=myisam as select * from t4_c; +create table t5 engine=myisam as select * from t5_c; +create table t6 engine=myisam as select * from t6_c; +create table t7 engine=myisam as select * from t7_c; +create table t8 engine=myisam as select * from t8_c; +create table t9 engine=myisam as select * from t9_c; +create table t10 engine=myisam as select * from t10_c; + +# check that force varpart is preserved by ndb_restore +# t3_c has ROW_FORMAT=FIXED i.e. ForceVarPart=0 +--exec $NDB_TOOLS_DIR/ndb_desc --no-defaults -d test t3_c | grep ForceVarPart +--exec $NDB_TOOLS_DIR/ndb_desc --no-defaults -d test t2_c | grep ForceVarPart + +--source include/ndb_backup.inc +drop table t1_c,t2_c,t3_c,t4_c,t5_c,t6_c,t7_c,t8_c,t9_c,t10_c; +--exec $NDB_TOOLS_DIR/ndb_restore --no-defaults -b $the_backup_id -n 1 -m -r --print --print_meta $NDB_BACKUP_DIR/BACKUP/BACKUP-$the_backup_id >> $NDB_TOOLS_OUTPUT +--exec $NDB_TOOLS_DIR/ndb_restore --no-defaults -b $the_backup_id -n 2 -r --print --print_meta $NDB_BACKUP_DIR/BACKUP/BACKUP-$the_backup_id >> $NDB_TOOLS_OUTPUT +# check that force varpart is preserved by ndb_restore +# t3_c has ROW_FORMAT=FIXED i.e. ForceVarPart=0 +--exec $NDB_TOOLS_DIR/ndb_desc --no-defaults -d test t3_c | grep ForceVarPart +--exec $NDB_TOOLS_DIR/ndb_desc --no-defaults -d test t2_c | grep ForceVarPart + +# random output order?? +#show tables; + +select count(*) from t1; +select count(*) from t1_c; +select count(*) + from (select * from t1 union + select * from t1_c) a; + +select count(*) from t2; +select count(*) from t2_c; +select count(*) + from (select * from t2 union + select * from t2_c) a; + +select count(*) from t3; +select count(*) from t3_c; +select count(*) + from (select * from t3 union + select * from t3_c) a; + +select count(*) from t4; +select count(*) from t4_c; +select count(*) + from (select * from t4 union + select * from t4_c) a; + +select count(*) from t5; +select count(*) from t5_c; +select count(*) + from (select * from t5 union + select * from t5_c) a; + +select count(*) from t6; +select count(*) from t6_c; +select count(*) + from (select * from t6 union + select * from t6_c) a; + +select count(*) from t7; +select count(*) from t7_c; +select count(*) + from (select * from t7 union + select * from t7_c) a; + +select count(*) from t8; +select count(*) from t8_c; +select count(*) + from (select * from t8 union + select * from t8_c) a; + +select count(*) from t9; +select count(*) from t9_c; +select count(*) + from (select * from t9 union + select * from t9_c) a; + +# Bug #20820 cont'd +select * from t10_c order by a; +# Bug #27775 cont'd +# - auto inc info should be correct +--replace_column 1 X 2 X 3 X 4 X 5 X 6 X 7 X 8 X 9 X 10 X 12 X 13 X 14 X 15 X 16 X 17 X 18 X +show table status like 't1_c'; +--replace_column 1 X 2 X 3 X 4 X 5 X 6 X 7 X 8 X 9 X 10 X 12 X 13 X 14 X 15 X 16 X 17 X 18 X +show table status like 't2_c'; +--replace_column 1 X 2 X 3 X 4 X 5 X 6 X 7 X 8 X 9 X 10 X 12 X 13 X 14 X 15 X 16 X 17 X 18 X +show table status like 't4_c'; +--replace_column 1 X 2 X 3 X 4 X 5 X 6 X 7 X 8 X 9 X 10 X 12 X 13 X 14 X 15 X 16 X 17 X 18 X +show table status like 't7_c'; +--replace_column 1 X 2 X 3 X 4 X 5 X 6 X 7 X 8 X 9 X 10 X 12 X 13 X 14 X 15 X 16 X 17 X 18 X +show table status like 't10_c'; + +# +# Try Partitioned tables as well +# +ALTER TABLE t7_c +PARTITION BY LINEAR KEY (`dardtestard`); + +--source include/ndb_backup.inc +drop table t1_c,t2_c,t3_c,t4_c,t5_c,t6_c,t7_c,t8_c,t9_c,t10_c; +--exec $NDB_TOOLS_DIR/ndb_restore --no-defaults -b $the_backup_id -n 1 -m -r --print --print_meta $NDB_BACKUP_DIR/BACKUP/BACKUP-$the_backup_id >> $NDB_TOOLS_OUTPUT +--exec $NDB_TOOLS_DIR/ndb_restore --no-defaults -b $the_backup_id -n 2 -r --print --print_meta $NDB_BACKUP_DIR/BACKUP/BACKUP-$the_backup_id >> $NDB_TOOLS_OUTPUT + +select count(*) from t1; +select count(*) from t1_c; +select count(*) + from (select * from t1 union + select * from t1_c) a; + +select count(*) from t2; +select count(*) from t2_c; +select count(*) + from (select * from t2 union + select * from t2_c) a; + +select count(*) from t3; +select count(*) from t3_c; +select count(*) + from (select * from t3 union + select * from t3_c) a; + +select count(*) from t4; +select count(*) from t4_c; +select count(*) + from (select * from t4 union + select * from t4_c) a; + +select count(*) from t5; +select count(*) from t5_c; +select count(*) + from (select * from t5 union + select * from t5_c) a; + +select count(*) from t6; +select count(*) from t6_c; +select count(*) + from (select * from t6 union + select * from t6_c) a; + +select count(*) from t7; +select count(*) from t7_c; +select count(*) + from (select * from t7 union + select * from t7_c) a; + +select count(*) from t8; +select count(*) from t8_c; +select count(*) + from (select * from t8 union + select * from t8_c) a; + +select count(*) from t9; +select count(*) from t9_c; +select count(*) + from (select * from t9 union + select * from t9_c) a; + +drop table t1_c,t2_c,t3_c,t4_c,t5_c,t6_c,t7_c,t8_c,t9_c,t10_c; +--exec $NDB_TOOLS_DIR/ndb_restore --no-defaults -b $the_backup_id -n 1 -m -r --ndb-nodegroup_map '(0,0)' --print --print_meta $NDB_BACKUP_DIR/BACKUP/BACKUP-$the_backup_id >> $NDB_TOOLS_OUTPUT +--exec $NDB_TOOLS_DIR/ndb_restore --no-defaults -b $the_backup_id -n 2 -r --print --print_meta $NDB_BACKUP_DIR/BACKUP/BACKUP-$the_backup_id >> $NDB_TOOLS_OUTPUT + +select count(*) from t1; +select count(*) from t1_c; +select count(*) + from (select * from t1 union + select * from t1_c) a; + +select count(*) from t2; +select count(*) from t2_c; +select count(*) + from (select * from t2 union + select * from t2_c) a; + +select count(*) from t3; +select count(*) from t3_c; +select count(*) + from (select * from t3 union + select * from t3_c) a; + +select count(*) from t4; +select count(*) from t4_c; +select count(*) + from (select * from t4 union + select * from t4_c) a; + +select count(*) from t5; +select count(*) from t5_c; +select count(*) + from (select * from t5 union + select * from t5_c) a; + +select count(*) from t6; +select count(*) from t6_c; +select count(*) + from (select * from t6 union + select * from t6_c) a; + +select count(*) from t7; +select count(*) from t7_c; +select count(*) + from (select * from t7 union + select * from t7_c) a; + +select count(*) from t8; +select count(*) from t8_c; +select count(*) + from (select * from t8 union + select * from t8_c) a; + +select count(*) from t9; +select count(*) from t9_c; +select count(*) + from (select * from t9 union + select * from t9_c) a; + +# +# Drop all table except t2_c +# This to make sure that error returned from ndb_restore above is +# guaranteed to be from t2_c, this since order of tables in backup +# is none deterministic +# +drop table t1_c,t3_c,t4_c,t5_c,t6_c,t7_c,t8_c,t9_c,t10_c; +--source include/ndb_backup.inc +--exec $NDB_TOOLS_DIR/ndb_restore --no-defaults --core=0 -b $the_backup_id -n 1 -m -r --ndb-nodegroup_map '(0,1)' $NDB_BACKUP_DIR/BACKUP/BACKUP-$the_backup_id 2>&1 | grep Translate || true + +# +# Cleanup +# + +--disable_warnings +drop table if exists t1,t2,t3,t4,t5,t6,t7,t8,t9,t10; +drop table if exists t2_c; +--enable_warnings + +# +# Test BUG#10287 +# + +--exec $NDB_TOOLS_DIR/ndb_select_all --no-defaults -d sys -D , SYSTAB_0 | grep 520093696, | sed "s/,$the_backup_id/,<the_backup_id>/" + +# End of 5.0 tests (4.1 test intermixed to save test time) diff --git a/mysql-test/suite/ndb/t/ndb_restore_compat.test b/mysql-test/suite/ndb/t/ndb_restore_compat.test new file mode 100644 index 00000000000..2622aec1d50 --- /dev/null +++ b/mysql-test/suite/ndb/t/ndb_restore_compat.test @@ -0,0 +1,61 @@ +-- source include/have_ndb.inc +-- source include/not_embedded.inc +-- source include/have_case_sensitive_file_system.inc + +# This test currently requires case sensitive file system as the tables +# are originally stored with uppercase + +# +# Bug #18594 ndb_restore log boken in 5.1 +# + +--disable_warnings +DROP DATABASE IF EXISTS BANK; +--enable_warnings +CREATE DATABASE BANK default charset=latin1 default collate=latin1_bin; +--exec $NDB_TOOLS_DIR/ndb_restore --no-defaults -b 1 -n 1 -p 1 -m -r $MYSQL_TEST_DIR/std_data/ndb_backup51 >> $NDB_TOOLS_OUTPUT +--exec $NDB_TOOLS_DIR/ndb_restore --no-defaults -e -b 1 -n 2 -p 1 -r $MYSQL_TEST_DIR/std_data/ndb_backup51 >> $NDB_TOOLS_OUTPUT +USE BANK; +SHOW TABLES; +SELECT * FROM GL ORDER BY TIME,ACCOUNT_TYPE; +SELECT * FROM ACCOUNT ORDER BY ACCOUNT_ID; +SELECT COUNT(*) FROM TRANSACTION; +SELECT * FROM SYSTEM_VALUES ORDER BY SYSTEM_VALUES_ID; +SELECT * FROM mysql.ndb_apply_status WHERE server_id=0; + +# Check that force varpart is set by ndb_restore +--exec $NDB_TOOLS_DIR/ndb_desc --no-defaults -d BANK GL | grep ForceVarPart +--exec $NDB_TOOLS_DIR/ndb_desc --no-defaults -d BANK ACCOUNT | grep ForceVarPart +--exec $NDB_TOOLS_DIR/ndb_desc --no-defaults -d BANK TRANSACTION | grep ForceVarPart +--exec $NDB_TOOLS_DIR/ndb_desc --no-defaults -d BANK SYSTEM_VALUES | grep ForceVarPart +--exec $NDB_TOOLS_DIR/ndb_desc --no-defaults -d BANK ACCOUNT_TYPE | grep ForceVarPart + +# +# verify restore of 5.0 backup +# here we must use the already created tables as restoring the old +# table definitions will not work +# +TRUNCATE GL; +TRUNCATE ACCOUNT; +TRUNCATE TRANSACTION; +TRUNCATE SYSTEM_VALUES; +TRUNCATE ACCOUNT_TYPE; + +# Check that force varpart is not changed by truncate +--exec $NDB_TOOLS_DIR/ndb_desc --no-defaults -d BANK GL | grep ForceVarPart +--exec $NDB_TOOLS_DIR/ndb_desc --no-defaults -d BANK ACCOUNT | grep ForceVarPart +--exec $NDB_TOOLS_DIR/ndb_desc --no-defaults -d BANK TRANSACTION | grep ForceVarPart +--exec $NDB_TOOLS_DIR/ndb_desc --no-defaults -d BANK SYSTEM_VALUES | grep ForceVarPart +--exec $NDB_TOOLS_DIR/ndb_desc --no-defaults -d BANK ACCOUNT_TYPE | grep ForceVarPart + +# Restore data +--exec $NDB_TOOLS_DIR/ndb_restore --no-defaults -b 1 -n 1 -p 1 -r $MYSQL_TEST_DIR/std_data/ndb_backup50 >> $NDB_TOOLS_OUTPUT +--exec $NDB_TOOLS_DIR/ndb_restore --no-defaults -e -b 1 -n 2 -p 1 -r $MYSQL_TEST_DIR/std_data/ndb_backup50 >> $NDB_TOOLS_OUTPUT + +# Check data +SELECT * FROM GL ORDER BY TIME,ACCOUNT_TYPE; +SELECT * FROM ACCOUNT ORDER BY ACCOUNT_ID; +SELECT COUNT(*) FROM TRANSACTION; +SELECT * FROM SYSTEM_VALUES ORDER BY SYSTEM_VALUES_ID; +SELECT * FROM mysql.ndb_apply_status WHERE server_id=0; +DROP DATABASE BANK; diff --git a/mysql-test/suite/ndb/t/ndb_restore_partition-master.opt b/mysql-test/suite/ndb/t/ndb_restore_partition-master.opt new file mode 100644 index 00000000000..075c6392dde --- /dev/null +++ b/mysql-test/suite/ndb/t/ndb_restore_partition-master.opt @@ -0,0 +1 @@ +--new diff --git a/mysql-test/suite/ndb/t/ndb_restore_partition.test b/mysql-test/suite/ndb/t/ndb_restore_partition.test new file mode 100644 index 00000000000..f11324492c2 --- /dev/null +++ b/mysql-test/suite/ndb/t/ndb_restore_partition.test @@ -0,0 +1,375 @@ +-- source include/have_ndb.inc +-- source include/ndb_default_cluster.inc +-- source include/not_embedded.inc + +--disable_warnings +use test; +drop table if exists t1,t2,t3,t4,t5,t6,t7,t8,t9; +drop table if exists t1_c,t2_c,t3_c,t4_c,t5_c,t6_c,t7_c,t8_c,t9_c; +--enable_warnings + +CREATE TABLE `t1_c` ( + `capgoaledatta` smallint(5) unsigned NOT NULL auto_increment, + `goaledatta` char(2) NOT NULL default '', + `maturegarbagefa` varchar(32) NOT NULL default '', + PRIMARY KEY (`capgoaledatta`,`goaledatta`,`maturegarbagefa`) +) ENGINE=ndbcluster DEFAULT CHARSET=latin1; +INSERT INTO `t1_c` VALUES (2,'3','q3plus.qt'),(4,'4','q3plus.qt'),(1,'3','q3.net'),(3,'4','q3.net'),(3,'20','threetrees.qt'); + +CREATE TABLE `t2_c` ( + `capgotod` smallint(5) unsigned NOT NULL auto_increment, + `gotod` smallint(5) unsigned NOT NULL default '0', + `goaledatta` char(2) default NULL, + `maturegarbagefa` varchar(32) default NULL, + `descrpooppo` varchar(64) default NULL, + `svcutonsa` varchar(64) NOT NULL default '', + PRIMARY KEY (`capgotod`), + KEY `i_quadaddsvr` (`gotod`) +) ENGINE=ndbcluster DEFAULT CHARSET=latin1; +INSERT INTO `t2_c` VALUES (5,4,'','q3.net','addavp:MK_CASELECTOR=1','postorod rattoaa'),(2,1,'4','','addavp:MK_BRANDTAD=345','REDS Brandtad'),(3,2,'4','q3.net','execorder','fixedRatediPO REDS'),(1,1,'3','','addavp:MK_BRANDTAD=123','TEST Brandtad'),(6,5,'','told.q3.net','addavp:MK_BRANDTAD=123','Brandtad Toldzone'),(4,3,'3','q3.net','addavp:MK_POOLHINT=2','ratedi PO TEST'); + +CREATE TABLE `t3_c` ( + `CapGoaledatta` smallint(5) unsigned NOT NULL default '0', + `capgotod` smallint(5) unsigned NOT NULL default '0', + PRIMARY KEY (`capgotod`,`CapGoaledatta`) +) ENGINE=ndbcluster DEFAULT CHARSET=latin1; +INSERT INTO `t3_c` VALUES (5,3),(2,4),(5,4),(1,3); + +CREATE TABLE `t4_c` ( + `capfa` bigint(20) unsigned NOT NULL auto_increment, + `realm` varchar(32) NOT NULL default '', + `authpwchap` varchar(32) default NULL, + `fa` varchar(32) NOT NULL default '', + `payyingatta` tinyint(4) NOT NULL default '0', + `status` char(1) default NULL, + PRIMARY KEY (`fa`,`realm`), + KEY `capfa` (`capfa`), + KEY `i_quadentity` (`fa`,`realm`) +) ENGINE=ndbcluster DEFAULT CHARSET=latin1; +INSERT INTO `t4_c` VALUES (18,'john.smith','q3.net','dessjohn.smith',0,NULL),(21,'quad_katt_with_brandtad','q3.net','acne',0,NULL),(22,'quad_katt_carattoaa','q3.net','acne',0,NULL),(26,'436462612809','sqasdt.q3.net','N/A',0,'6'),(19,'john','smith.qt','dessjohn',0,NULL),(33,'436643196120','sqasdt.q3.net','N/A',1,'6'),(28,'436642900019','sqasdt.q3.net','N/A',0,'6'),(30,'436462900209','sqasdt.q3.net','N/A',0,'6'),(16,'436640006666','sqasdt.q3.net','',0,NULL),(19,'dette','el-redun.com','dessdette',0,NULL),(12,'quad_kattPP','q3.net','acne',2,NULL),(14,'436640008888','sqasdt.q3.net','',0,NULL),(29,'463624900028','sqasdt.q3.net','N/A',0,'6'),(15,'436640099099','sqasdt.q3.net','',0,NULL),(13,'pap','q3plus.qt','acne',1,NULL),(19,'436642612091','sqasdt.q3.net','N/A',0,'6'),(12,'quad_katt','q3.net','acne',0,NULL),(11,'quad_kattVK','q3.net','acne',1,NULL),(32,'463641969502','sqasdt.q3.net','N/A',1,'6'),(20,'joe','q3.net','joedesswd',0,NULL),(29,'436642900034','sqasdt.q3.net','N/A',0,'6'),(25,'contind','armerde.qt','acne',1,NULL); + +CREATE TABLE `t5_c` ( + `capfa` bigint(20) unsigned NOT NULL default '0', + `gotod` smallint(5) unsigned NOT NULL default '0', + `orderutonsa` varchar(64) NOT NULL default '', + PRIMARY KEY (`capfa`,`gotod`,`orderutonsa`) +) ENGINE=ndbcluster DEFAULT CHARSET=latin1; +INSERT INTO `t5_c` VALUES (21,2,''),(21,1,''),(22,4,''); + +CREATE TABLE `t6_c` ( + `capfa_parent` bigint(20) unsigned NOT NULL default '0', + `capfa_child` bigint(20) unsigned NOT NULL default '0', + `relatta` smallint(5) unsigned NOT NULL default '0', + PRIMARY KEY (`capfa_child`,`capfa_parent`,`relatta`) +) ENGINE=ndbcluster DEFAULT CHARSET=latin1; +INSERT INTO `t6_c` VALUES (15,16,0),(19,20,0),(18326932092909551615,30,0),(26,29,0),(18326932092909551615,29,0),(19,18,0),(26,28,0),(12,14,0); + +CREATE TABLE `t7_c` ( + `dardpo` char(15) NOT NULL default '', + `dardtestard` tinyint(3) unsigned NOT NULL default '0', + `FastFA` char(5) NOT NULL default '', + `FastCode` char(6) NOT NULL default '', + `Fastca` char(1) NOT NULL default '', + `Fastmag` char(1) NOT NULL default '', + `Beareratta` char(2) NOT NULL default '', + PRIMARY KEY (`dardpo`,`dardtestard`) +) ENGINE=ndbcluster DEFAULT CHARSET=latin1; +INSERT INTO `t7_c` VALUES ('2.6.2.4',24,'CECHP','54545','0','0','5'),('2.2.5.4',26,'CANFA','33223','1','1','4'),('4.3.2.4',28,'ITALD','54222','1','0','5'),('129..0.0.eins',28,'G','99999','1','1','5'),('1.1.1.1',24,'AUTPT','32323','0','1','3'); + +CREATE TABLE `t8_c` ( + `kattjame` varchar(32) NOT NULL default '', + `realm` varchar(32) NOT NULL default '', + `realm_entered` varchar(32) NOT NULL default '', + `maturegarbagefa` varchar(32) NOT NULL default '', + `hunderaaarbagefa_parent` varchar(32) NOT NULL default '', + `kattjame_entered` varchar(32) NOT NULL default '', + `hunderaaarbagefa` varchar(32) NOT NULL default '', + `gest` varchar(16) default NULL, + `hassetino` varchar(16) NOT NULL default '', + `aaaproxysessfa` varchar(255) default NULL, + `autologonallowed` char(1) default NULL, + `squardporoot` varchar(15) NOT NULL default '', + `naspo` varchar(15) default NULL, + `beareratta` char(2) default NULL, + `fastCode` varchar(6) default NULL, + `fastFA` varchar(5) default NULL, + `fastca` char(1) default NULL, + `fastmag` char(1) default NULL, + `lastupdate` datetime default NULL, + `hassetistart` datetime NOT NULL default '0000-00-00 00:00:00', + `accthassetitime` int(10) unsigned default NULL, + `acctoutputoctets` bigint(20) unsigned default NULL, + `acctinputoctets` bigint(20) unsigned default NULL, + PRIMARY KEY (`kattjame`,`hunderaaarbagefa`,`hassetistart`,`hassetino`), + KEY `squardporoot` (`squardporoot`) +) ENGINE=ndbcluster DEFAULT CHARSET=latin1; +INSERT INTO `t8_c` VALUES ('4tt45345235','pap','q3plus.qt','q3plus.qt','q3.net','436643196120','436643196929','8956234534568968','5524595699','uxasmt21.net.acne.qt/481889229462692422','','1.1.1.1','2.2.4.6','4','86989','34','x','x','2012-03-12 12:55:34','2012-12-05 11:20:04',3223433,3369,9565),('4545435545','john','q3.net','q3.net','acne.li','436643196120','436643196929','45345234568968','995696699','uxasmt21.net.acne.qt/481889229462692423','','1.1.1.1','2.2.9.8','2','86989','34','x','x','2012-03-12 11:35:03','2012-12-05 08:50:04',8821923,169,3565),('versteckter_q3net_katt','joe','q3.net','elredun.com','q3.net','436643196120','436643196939','91341234568968','695595699','uxasmt21.net.acne.qt/481889229462692421','','1.1.1.1','2.5.2.5','3','86989','34','x','x','2012-03-12 18:35:04','2012-12-05 12:35:04',1923123,9569,6565); + +CREATE TABLE `t9_c` ( + `kattjame` varchar(32) NOT NULL default '', + `kattjame_entered` varchar(32) NOT NULL default '', + `realm` varchar(32) NOT NULL default '', + `realm_entered` varchar(32) NOT NULL default '', + `maturegarbagefa` varchar(32) NOT NULL default '', + `hunderaaarbagefa` varchar(32) NOT NULL default '', + `hunderaaarbagefa_parent` varchar(32) NOT NULL default '', + `gest` varchar(16) default NULL, + `hassetino` varchar(16) NOT NULL default '', + `squardporoot` varchar(15) NOT NULL default '', + `naspo` varchar(15) default NULL, + `beareratta` char(2) default NULL, + `fastCode` varchar(6) default NULL, + `fastFA` varchar(5) default NULL, + `fastca` char(1) default NULL, + `fastmag` char(1) default NULL, + `lastupdate` datetime default NULL, + `hassetistart` datetime NOT NULL default '0000-00-00 00:00:00', + `accthassetitime` int(10) unsigned default NULL, + `actcoutpuocttets` bigint(20) unsigned default NULL, + `actinputocctets` bigint(20) unsigned default NULL, + `terminateraste` tinyint(3) unsigned default NULL, + PRIMARY KEY (`kattjame`,`hunderaaarbagefa`,`hassetistart`,`hassetino`) +) ENGINE=ndbcluster DEFAULT CHARSET=latin1; +INSERT INTO `t9_c` VALUES ('3g4jh8gar2t','joe','q3.net','elredun.com','q3.net','436643316120','436643316939','91341234568968','695595699','1.1.1.1','2.2.6.2','3','86989','34','x','x','2012-03-12 18:35:04','2012-12-05 12:35:04',3123123,9569,6565,1),('4tt45345235','pap','q3plus.qt','q3plus.qt','q3.net','436643316120','436643316939','8956234534568968','5254595969','1.1.1.1','8.6.2.2','4','86989','34','x','x','2012-03-12 12:55:34','2012-12-05 11:20:04',3223433,3369,9565,2),('4545435545','john','q3.net','q3.net','acne.li','436643316120','436643316939','45345234568968','995696699','1.1.1.1','2.9.9.2','2','86998','34','x','x','2012-03-12 11:35:03','2012-12-05 08:50:04',8823123,169,3565,3); + +create table t1 engine=myisam as select * from t1_c; +create table t2 engine=myisam as select * from t2_c; +create table t3 engine=myisam as select * from t3_c; +create table t4 engine=myisam as select * from t4_c; +create table t5 engine=myisam as select * from t5_c; +create table t6 engine=myisam as select * from t6_c; +create table t7 engine=myisam as select * from t7_c; +create table t8 engine=myisam as select * from t8_c; +create table t9 engine=myisam as select * from t9_c; + + +--source include/ndb_backup.inc +drop table t1_c,t2_c,t3_c,t4_c,t5_c,t6_c,t7_c,t8_c,t9_c; +--exec $NDB_TOOLS_DIR/ndb_restore --no-defaults -b $the_backup_id -n 1 -m -r --print --print_meta $NDB_BACKUP_DIR/BACKUP/BACKUP-$the_backup_id >> $NDB_TOOLS_OUTPUT +--exec $NDB_TOOLS_DIR/ndb_restore --no-defaults -b $the_backup_id -n 2 -r --print --print_meta $NDB_BACKUP_DIR/BACKUP/BACKUP-$the_backup_id >> $NDB_TOOLS_OUTPUT + +# random output order?? +#show tables; + +select count(*) from t1; +select count(*) from t1_c; +select count(*) + from (select * from t1 union + select * from t1_c) a; + +select count(*) from t2; +select count(*) from t2_c; +select count(*) + from (select * from t2 union + select * from t2_c) a; + +select count(*) from t3; +select count(*) from t3_c; +select count(*) + from (select * from t3 union + select * from t3_c) a; + +select count(*) from t4; +select count(*) from t4_c; +select count(*) + from (select * from t4 union + select * from t4_c) a; + +select count(*) from t5; +select count(*) from t5_c; +select count(*) + from (select * from t5 union + select * from t5_c) a; + +select count(*) from t6; +select count(*) from t6_c; +select count(*) + from (select * from t6 union + select * from t6_c) a; + +select count(*) from t7; +select count(*) from t7_c; +select count(*) + from (select * from t7 union + select * from t7_c) a; + +select count(*) from t8; +select count(*) from t8_c; +select count(*) + from (select * from t8 union + select * from t8_c) a; + +select count(*) from t9; +select count(*) from t9_c; +select count(*) + from (select * from t9 union + select * from t9_c) a; + +# +# Try Partitioned tables as well +# +ALTER TABLE t1_c +PARTITION BY RANGE (`capgoaledatta`) +(PARTITION p0 VALUES LESS THAN MAXVALUE); + +ALTER TABLE t2_c +PARTITION BY LIST(`capgotod`) +(PARTITION p0 VALUES IN (0,1,2,3,4,5,6)); + +ALTER TABLE t3_c +PARTITION BY HASH (`CapGoaledatta`); + +ALTER TABLE t5_c +PARTITION BY HASH (`capfa`) +PARTITIONS 4; + +ALTER TABLE t6_c +PARTITION BY LINEAR HASH (`relatta`) +PARTITIONS 4; + +ALTER TABLE t7_c +PARTITION BY LINEAR KEY (`dardtestard`); + +--source include/ndb_backup.inc +drop table t1_c,t2_c,t3_c,t4_c,t5_c,t6_c,t7_c,t8_c,t9_c; +--exec $NDB_TOOLS_DIR/ndb_restore --no-defaults -b $the_backup_id -n 1 -m -r --print --print_meta $NDB_BACKUP_DIR/BACKUP/BACKUP-$the_backup_id >> $NDB_TOOLS_OUTPUT +--exec $NDB_TOOLS_DIR/ndb_restore --no-defaults -b $the_backup_id -n 2 -r --print --print_meta $NDB_BACKUP_DIR/BACKUP/BACKUP-$the_backup_id >> $NDB_TOOLS_OUTPUT + +select count(*) from t1; +select count(*) from t1_c; +select count(*) + from (select * from t1 union + select * from t1_c) a; + +select count(*) from t2; +select count(*) from t2_c; +select count(*) + from (select * from t2 union + select * from t2_c) a; + +select count(*) from t3; +select count(*) from t3_c; +select count(*) + from (select * from t3 union + select * from t3_c) a; + +select count(*) from t4; +select count(*) from t4_c; +select count(*) + from (select * from t4 union + select * from t4_c) a; + +select count(*) from t5; +select count(*) from t5_c; +select count(*) + from (select * from t5 union + select * from t5_c) a; + +select count(*) from t6; +select count(*) from t6_c; +select count(*) + from (select * from t6 union + select * from t6_c) a; + +select count(*) from t7; +select count(*) from t7_c; +select count(*) + from (select * from t7 union + select * from t7_c) a; + +select count(*) from t8; +select count(*) from t8_c; +select count(*) + from (select * from t8 union + select * from t8_c) a; + +select count(*) from t9; +select count(*) from t9_c; +select count(*) + from (select * from t9 union + select * from t9_c) a; + +drop table t1_c,t2_c,t3_c,t4_c,t5_c,t6_c,t7_c,t8_c,t9_c; +--exec $NDB_TOOLS_DIR/ndb_restore --no-defaults -b $the_backup_id -n 1 -m -r --ndb-nodegroup_map '(0,0)' --print --print_meta $NDB_BACKUP_DIR/BACKUP/BACKUP-$the_backup_id >> $NDB_TOOLS_OUTPUT +--exec $NDB_TOOLS_DIR/ndb_restore --no-defaults -b $the_backup_id -n 2 -r --print --print_meta $NDB_BACKUP_DIR/BACKUP/BACKUP-$the_backup_id >> $NDB_TOOLS_OUTPUT + +select count(*) from t1; +select count(*) from t1_c; +select count(*) + from (select * from t1 union + select * from t1_c) a; + +select count(*) from t2; +select count(*) from t2_c; +select count(*) + from (select * from t2 union + select * from t2_c) a; + +select count(*) from t3; +select count(*) from t3_c; +select count(*) + from (select * from t3 union + select * from t3_c) a; + +select count(*) from t4; +select count(*) from t4_c; +select count(*) + from (select * from t4 union + select * from t4_c) a; + +select count(*) from t5; +select count(*) from t5_c; +select count(*) + from (select * from t5 union + select * from t5_c) a; + +select count(*) from t6; +select count(*) from t6_c; +select count(*) + from (select * from t6 union + select * from t6_c) a; + +select count(*) from t7; +select count(*) from t7_c; +select count(*) + from (select * from t7 union + select * from t7_c) a; + +select count(*) from t8; +select count(*) from t8_c; +select count(*) + from (select * from t8 union + select * from t8_c) a; + +select count(*) from t9; +select count(*) from t9_c; +select count(*) + from (select * from t9 union + select * from t9_c) a; + +# +# Drop all table except t2_c +# This to make sure that error returned from ndb_restore above is +# guaranteed to be from t2_c, this since order of tables in backup +# is none deterministic +# +drop table t1_c,t3_c,t4_c,t5_c,t6_c,t7_c,t8_c,t9_c; +--source include/ndb_backup.inc +--exec $NDB_TOOLS_DIR/ndb_restore --no-defaults --core=0 -b $the_backup_id -n 1 -m -r --ndb-nodegroup_map '(0,1)' $NDB_BACKUP_DIR/BACKUP/BACKUP-$the_backup_id 2>&1 | grep Translate || true + +# +# Cleanup +# + +--disable_warnings +drop table if exists t1,t2,t3,t4,t5,t6,t7,t8,t9; +drop table if exists t2_c; +--enable_warnings + +# +# Test BUG#10287 +# + +--exec $NDB_TOOLS_DIR/ndb_select_all --no-defaults -d sys -D , SYSTAB_0 | grep 520093696, | sed "s/,$the_backup_id/,<the_backup_id>/" + +# End of 4.1 tests diff --git a/mysql-test/suite/ndb/t/ndb_restore_print.test b/mysql-test/suite/ndb/t/ndb_restore_print.test new file mode 100644 index 00000000000..6dbbfdf5933 --- /dev/null +++ b/mysql-test/suite/ndb/t/ndb_restore_print.test @@ -0,0 +1,189 @@ +-- source include/have_ndb.inc +-- source include/ndb_default_cluster.inc +-- source include/not_embedded.inc + +--disable_warnings +use test; +drop table if exists t1,t2,t3,t4,t5,t6,t7,t8,t9,t10; +--enable_warnings + +# basic datatypes +create table t1 + (pk int key + ,a1 BIT(1), a2 BIT(5), a3 BIT(33), a4 BIT(63), a5 BIT(64) + ,b1 TINYINT, b2 TINYINT UNSIGNED + ,c1 SMALLINT, c2 SMALLINT UNSIGNED + ,d1 INT, d2 INT UNSIGNED + ,e1 BIGINT, e2 BIGINT UNSIGNED + ,f1 CHAR(1) BINARY, f2 CHAR(32) BINARY, f3 CHAR(255) BINARY + ,g1 VARCHAR(32) BINARY, g2 VARCHAR(255) BINARY, g3 VARCHAR(1000) BINARY + ,h1 BINARY(1), h2 BINARY(8), h3 BINARY(255) + ,i1 VARBINARY(32), i2 VARBINARY(255), i3 VARBINARY(1000) + ) engine myisam; + +# max values +insert into t1 values + (1 + ,0x1, 0x17, 0x789a, 0x789abcde, 0xfedc0001 + ,127, 255 + ,32767, 65535 + ,2147483647, 4294967295 + ,9223372036854775807, 18446744073709551615 + ,'1','12345678901234567890123456789012','123456789' + ,'1','12345678901234567890123456789012','123456789' + ,0x12,0x123456789abcdef0, 0x012345 + ,0x12,0x123456789abcdef0, 0x00123450 + ); + +# min values +insert into t1 values + (2 + ,0, 0, 0, 0, 0 + ,-128, 0 + ,-32768, 0 + ,-2147483648, 0 + ,-9223372036854775808, 0 + ,'','','' + ,'','','' + ,0x0,0x0,0x0 + ,0x0,0x0,0x0 + ); + +# null values +insert into t1 values + (3 + ,NULL,NULL,NULL,NULL,NULL + ,NULL,NULL + ,NULL,NULL + ,NULL,NULL + ,NULL,NULL + ,NULL,NULL,NULL + ,NULL,NULL,NULL + ,NULL,NULL,NULL + ,NULL,NULL,NULL + ); + +--vertical_results +select pk + ,hex(a1), hex(a2), hex(a3), hex(a4), hex(a5) + ,b1, b2 + ,c1 , c2 + ,d1 , d2 + ,e1 , e2 + ,f1 , f2, f3 + ,g1 , g2, g3 + ,hex(h1), hex(h2), hex(h3) + ,hex(i1), hex(i2), hex(i3) + from t1 order by pk; + +alter table t1 engine ndb; + +select pk + ,hex(a1), hex(a2), hex(a3), hex(a4), hex(a5) + ,b1, b2 + ,c1 , c2 + ,d1 , d2 + ,e1 , e2 + ,f1 , f2, f3 + ,g1 , g2, g3 + ,hex(h1), hex(h2), hex(h3) + ,hex(i1), hex(i2), hex(i3) + from t1 order by pk; +--horizontal_results + +--source include/ndb_backup.inc + +--let ndb_restore_filter=test t1 +--let ndb_restore_opts=--verbose=0 --print_data --hex --fields-terminated-by=";" +--source include/ndb_backup_print.inc + +--let ndb_restore_filter=test t1 +--let ndb_restore_opts=--verbose=0 --print_data --hex --fields-terminated-by="," --fields-optionally-enclosed-by="'" +--source include/ndb_backup_print.inc + + +drop table t1; + +# some binary char tests with trailing spaces +create table t1 + (pk int key + ,f1 CHAR(1) BINARY, f2 CHAR(32) BINARY, f3 CHAR(255) BINARY + ,g1 VARCHAR(32) BINARY, g2 VARCHAR(255) BINARY, g3 VARCHAR(1000) BINARY + ,h1 BINARY(1), h2 BINARY(9), h3 BINARY(255) + ,i1 VARBINARY(32), i2 VARBINARY(255), i3 VARBINARY(1000) + ) engine ndb; + +insert into t1 values + (1 + ,'1','12345678901234567890123456789012','123456789 ' + ,'1 ','12345678901234567890123456789012 ','123456789 ' + ,0x20,0x123456789abcdef020, 0x012345000020 + ,0x1200000020,0x123456789abcdef000000020, 0x00123450000020 + ); + +create table t2 (pk int key, a int) engine ndb; +create table t3 (pk int key, a int) engine ndb; +create table t4 (pk int key, a int) engine ndb; + +insert into t2 values (1,11),(2,12),(3,13),(4,14),(5,15); +insert into t3 values (1,21),(2,22),(3,23),(4,24),(5,25); +insert into t4 values (1,31),(2,32),(3,33),(4,34),(5,35); + +--source include/ndb_backup.inc +--let ndb_restore_opts=--verbose=0 --print_data --hex --fields-enclosed-by="'" --fields-optionally-enclosed-by="X" +--let ndb_restore_filter=test t1 +--source include/ndb_backup_print.inc + +--exec rm -f $MYSQLTEST_VARDIR/tmp/t1.txt +--exec rm -f $MYSQLTEST_VARDIR/tmp/t2.txt +--exec rm -f $MYSQLTEST_VARDIR/tmp/t3.txt +--exec rm -f $MYSQLTEST_VARDIR/tmp/t4.txt + +--let ndb_restore_opts=--verbose=0 --print_data --hex --tab $MYSQLTEST_VARDIR/tmp --append +--let ndb_restore_filter=test +--source include/ndb_backup_print.inc + +--let $message= t1 +--source include/show_msg.inc +--exec sort $MYSQLTEST_VARDIR/tmp/t1.txt +--let $message= t2 +--source include/show_msg.inc +--exec sort $MYSQLTEST_VARDIR/tmp/t2.txt +--let $message= t3 +--source include/show_msg.inc +--exec sort $MYSQLTEST_VARDIR/tmp/t3.txt +--let $message= t4 +--source include/show_msg.inc +--exec sort $MYSQLTEST_VARDIR/tmp/t4.txt + +--exec rm -f $MYSQLTEST_VARDIR/tmp/t1.txt +--exec rm -f $MYSQLTEST_VARDIR/tmp/t2.txt +--exec rm -f $MYSQLTEST_VARDIR/tmp/t3.txt +--exec rm -f $MYSQLTEST_VARDIR/tmp/t4.txt + +# now test some other datatypes +drop table t1; +create table t1 + (pk int key + ,a1 MEDIUMINT, a2 MEDIUMINT UNSIGNED + ) engine ndb; + +# max values +insert into t1 values(1, 8388607, 16777215); +# min values +insert into t1 values(2, -8388608, 0); +# small values +insert into t1 values(3, -1, 1); + +# backup and print +--source include/ndb_backup.inc + +--let ndb_restore_filter=test t1 +--let ndb_restore_opts=--verbose=0 --print_data --hex --fields-terminated-by=";" +--source include/ndb_backup_print.inc + +# clean up +drop table t1; +drop table t2; +drop table t3; +drop table t4; diff --git a/mysql-test/suite/ndb/t/ndb_row_format.test b/mysql-test/suite/ndb/t/ndb_row_format.test new file mode 100644 index 00000000000..b1582cbe339 --- /dev/null +++ b/mysql-test/suite/ndb/t/ndb_row_format.test @@ -0,0 +1,86 @@ +-- source include/have_ndb.inc +-- source include/not_embedded.inc + +--disable_warnings +DROP TABLE IF EXISTS t1,t2,t3,t4,t5,t6,t7; +drop database if exists mysqltest; +--enable_warnings + +# +# some negative tests +# + +# cannot have ROW_FORMAT=FIXED and var attrs mixed +--error 1005 +CREATE TABLE t1 + ( a INT KEY, + b VARCHAR(10) ) + ROW_FORMAT=FIXED + ENGINE=NDB; + +# warnings give more detail on the error +SHOW WARNINGS; + + +# +# Check force var part for different ROW_FORMAT +# + +# default => ForceVarPart: 1 +CREATE TABLE t1 + ( a INT KEY, + b INT ) + ENGINE=NDB; +--exec $NDB_TOOLS_DIR/ndb_desc --no-defaults -d test t1 | grep ForceVarPart +DROP TABLE t1; + +# explicit DEFAULT => ForceVarPart: 1 +CREATE TABLE t1 + ( a INT KEY, + b INT ) + ROW_FORMAT=DEFAULT + ENGINE=NDB; +--exec $NDB_TOOLS_DIR/ndb_desc --no-defaults -d test t1 | grep ForceVarPart +DROP TABLE t1; + +# FIXED => ForceVarPart: 0 +CREATE TABLE t1 + ( a INT KEY, + b INT ) + ROW_FORMAT=FIXED + ENGINE=NDB; +--exec $NDB_TOOLS_DIR/ndb_desc --no-defaults -d test t1 | grep ForceVarPart +DROP TABLE t1; + +# DYNAMIC => ForceVarPart: 1 +CREATE TABLE t1 + ( a INT KEY, + b INT ) + ROW_FORMAT=DYNAMIC + ENGINE=NDB; +--exec $NDB_TOOLS_DIR/ndb_desc --no-defaults -d test t1 | grep ForceVarPart +DROP TABLE t1; + +# test of bug +create table t1 (a int auto_increment primary key, b varchar(1000)) engine = ndb; +insert into t1(b) values ('0123456789'); +insert into t1(b) select b from t1; +insert into t1(b) select b from t1; +insert into t1(b) select b from t1; +insert into t1(b) select b from t1; +insert into t1(b) select b from t1; +insert into t1(b) select b from t1; +insert into t1(b) select b from t1; +insert into t1(b) select b from t1; +insert into t1(b) select b from t1; +insert into t1(b) select b from t1; +select count(*) from t1; +begin; +update t1 set b = concat(b,b); +update t1 set b = concat(b,b); +update t1 set b = concat(b,b); +update t1 set b = concat(b,b); +update t1 set b = concat(b,b); +rollback; +select count(*),b from t1 group by b; +drop table t1; diff --git a/mysql-test/suite/ndb/t/ndb_single_user.test b/mysql-test/suite/ndb/t/ndb_single_user.test new file mode 100644 index 00000000000..07925b25917 --- /dev/null +++ b/mysql-test/suite/ndb/t/ndb_single_user.test @@ -0,0 +1,173 @@ +-- source include/have_multi_ndb.inc +-- source include/ndb_default_cluster.inc +-- source include/not_embedded.inc + +--disable_warnings +use test; +drop table if exists t1,t2,t3,t4,t5,t6,t7,t8,t9,t10; +--enable_warnings + +# operations allowed while cluster is in single user mode + +--connection server1 +--let $node_id= `SHOW STATUS LIKE 'Ndb_cluster_node_id'` +--disable_query_log +--eval set @node_id= SUBSTRING('$node_id', 20)+0 +--enable_query_log +--let $node_id= `SELECT @node_id` +--exec $NDB_MGM --no-defaults --ndb-connectstring="localhost:$NDBCLUSTER_PORT" -e "enter single user mode $node_id" >> $NDB_TOOLS_OUTPUT +--exec $NDB_TOOLS_DIR/ndb_waiter --no-defaults --ndb-connectstring="localhost:$NDBCLUSTER_PORT" --single-user >> $NDB_TOOLS_OUTPUT + +# verify that we are indeed in single user mode +# and test that some operations give correct errors +--connection server2 +--error 1005 +create table t1 (a int key, b int unique, c int) engine ndb; +# Bug #27712 Single user mode. Creating logfile group and tablespace is allowed +# - before bug fix these would succeed +--error ER_CREATE_FILEGROUP_FAILED +CREATE LOGFILE GROUP lg1 +ADD UNDOFILE 'undofile.dat' +INITIAL_SIZE 16M +UNDO_BUFFER_SIZE = 1M +ENGINE=NDB; +show warnings; + +# test some sql on first mysqld +--connection server1 +create table t1 (a int key, b int unique, c int) engine ndb; +# Check that we can create logfile group +CREATE LOGFILE GROUP lg1 +ADD UNDOFILE 'undofile.dat' +INITIAL_SIZE 16M +UNDO_BUFFER_SIZE = 1M +ENGINE=NDB; +--connection server2 +--error ER_CREATE_FILEGROUP_FAILED +CREATE TABLESPACE ts1 +ADD DATAFILE 'datafile.dat' +USE LOGFILE GROUP lg1 +INITIAL_SIZE 12M +ENGINE NDB; +show warnings; +--error ER_DROP_FILEGROUP_FAILED +DROP LOGFILE GROUP lg1 +ENGINE =NDB; +show warnings; +--connection server1 +CREATE TABLESPACE ts1 +ADD DATAFILE 'datafile.dat' +USE LOGFILE GROUP lg1 +INITIAL_SIZE 12M +ENGINE NDB; +--connection server2 +--error ER_ALTER_FILEGROUP_FAILED +ALTER TABLESPACE ts1 +DROP DATAFILE 'datafile.dat' +ENGINE NDB; +show warnings; +--connection server1 +ALTER TABLESPACE ts1 +DROP DATAFILE 'datafile.dat' +ENGINE NDB; +--connection server2 +--error ER_DROP_FILEGROUP_FAILED +DROP TABLESPACE ts1 +ENGINE NDB; +show warnings; +--connection server1 +DROP TABLESPACE ts1 +ENGINE NDB; +DROP LOGFILE GROUP lg1 +ENGINE =NDB; +insert into t1 values (1,1,0),(2,2,0),(3,3,0),(4,4,0),(5,5,0),(6,6,0),(7,7,0),(8,8,0),(9,9,0),(10,10,0); +create table t2 as select * from t1; +# read with pk +select * from t1 where a = 1; +# read with unique index +select * from t1 where b = 4; +# read with ordered index +select * from t1 where a > 4 order by a; +# update with pk +update t1 set b=102 where a = 2; +# update with unique index +update t1 set b=103 where b = 3; +# update with full table scan +update t1 set b=b+100; +# update with ordered insex scan +update t1 set b=b+100 where a > 7; +# delete with full table scan +delete from t1; +insert into t1 select * from t2; +# Bug #27710 Creating unique index fails during single user mode +# - prior to bugfix this would fail +create unique index new_index on t1 (b,c); + +# test some sql on other mysqld +--connection server2 +--error 1051 +drop table t1; +--error 1296 +create index new_index_fail on t1 (c); +--error 1296 +insert into t1 values (21,21,0),(22,22,0),(23,23,0),(24,24,0),(25,25,0),(26,26,0),(27,27,0),(28,28,0),(29,29,0),(210,210,0); +--error 1296 +select * from t1 where a = 1; +--error 1296 +select * from t1 where b = 4; +--error 1296 +update t1 set b=102 where a = 2; +--error 1296 +update t1 set b=103 where b = 3; +--error 1296 +update t1 set b=b+100; +--error 1296 +update t1 set b=b+100 where a > 7; + +--exec $NDB_MGM --no-defaults --ndb-connectstring="localhost:$NDBCLUSTER_PORT" -e "exit single user mode" >> $NDB_TOOLS_OUTPUT +--exec $NDB_TOOLS_DIR/ndb_waiter --no-defaults >> $NDB_TOOLS_OUTPUT + +# +# we should be able to run transaction while in single user mode +# +--connection server1 +BEGIN; +update t1 set b=b+100 where a=1; + +--connection server2 +BEGIN; +update t1 set b=b+100 where a=2; + +# enter single user mode +--exec $NDB_MGM --no-defaults --ndb-connectstring="localhost:$NDBCLUSTER_PORT" -e "enter single user mode $node_id" >> $NDB_TOOLS_OUTPUT +--exec $NDB_TOOLS_DIR/ndb_waiter --no-defaults --ndb-connectstring="localhost:$NDBCLUSTER_PORT" --single-user >> $NDB_TOOLS_OUTPUT + +--connection server1 +update t1 set b=b+100 where a=3; +COMMIT; + +# while on other mysqld it should be aborted +--connection server2 +--error 1296 +update t1 set b=b+100 where a=4; +--error 1296 +COMMIT; + +# Bug #25275 SINGLE USER MODE prevents ALTER on non-ndb +# tables for other mysqld nodes +--connection server2 +create table t2 (a int) engine myisam; +alter table t2 add column (b int); + +# exit single user mode +--exec $NDB_MGM --no-defaults --ndb-connectstring="localhost:$NDBCLUSTER_PORT" -e "exit single user mode" >> $NDB_TOOLS_OUTPUT +--exec $NDB_TOOLS_DIR/ndb_waiter --no-defaults >> $NDB_TOOLS_OUTPUT + +# cleanup +--connection server2 +drop table t2; +--connection server1 +drop table t1; + +# End of 5.0 tests + diff --git a/mysql-test/suite/ndb/t/ndb_sp.test b/mysql-test/suite/ndb/t/ndb_sp.test new file mode 100644 index 00000000000..b833869cad0 --- /dev/null +++ b/mysql-test/suite/ndb/t/ndb_sp.test @@ -0,0 +1,42 @@ +-- source include/have_ndb.inc +-- source include/not_embedded.inc + +--disable_warnings +drop table if exists t1; +--enable_warnings + +create table t1 ( + a int not null primary key, + b int not null +) engine=ndb; +insert into t1 values (1,10), (2,20), (3,100), (4, 100); + +delimiter //; +create procedure test_proc1 (in var_in int) +begin + select * from t1 where a = var_in; +end; +create procedure test_proc2 (out var_out int) +begin + select b from t1 where a = 1 into var_out; +end; +create procedure test_proc3 (inout var_inout int) +begin + select b from t1 where a = var_inout into var_inout; +end; +// +delimiter ;// +call test_proc1(1); +call test_proc2(@test_var); +select @test_var; +set @test_var = 1; +call test_proc3(@test_var); +select @test_var; +alter procedure test_proc1 comment 'new comment'; +show create procedure test_proc1; +drop procedure test_proc1; +drop procedure test_proc2; +drop procedure test_proc3; +drop table t1; + +--echo End of 5.1 tests diff --git a/mysql-test/suite/ndb/t/ndb_subquery.test b/mysql-test/suite/ndb/t/ndb_subquery.test new file mode 100644 index 00000000000..6282c31c922 --- /dev/null +++ b/mysql-test/suite/ndb/t/ndb_subquery.test @@ -0,0 +1,79 @@ +-- source include/have_ndb.inc +-- source include/not_embedded.inc + +--disable_warnings +drop table if exists t1, t2, t3, t4; +--enable_warnings + +########## +# bug#5367 +create table t1 (p int not null primary key, u int not null, o int not null, +unique (u), key(o)) engine=ndb; + +create table t2 (p int not null primary key, u int not null, o int not null, +unique (u), key(o)) engine=ndb; + +create table t3 (a int not null primary key, b int not null) engine=ndb; +create table t4 (c int not null primary key, d int not null) engine=ndb; + +insert into t1 values (1,1,1),(2,2,2),(3,3,3); +insert into t2 values (1,1,1),(2,2,2),(3,3,3), (4,4,4), (5,5,5); +insert into t3 values (1,10), (2,10), (3,30), (4, 30); +insert into t4 values (1,10), (2,10), (3,30), (4, 30); + +# Use pk +--replace_column 9 # +explain select * from t2 where p NOT IN (select p from t1); +select * from t2 where p NOT IN (select p from t1) order by p; + +# Use unique index +--replace_column 9 # +explain select * from t2 where p NOT IN (select u from t1); +select * from t2 where p NOT IN (select u from t1) order by p; + +# Use ordered index +--replace_column 9 # +explain select * from t2 where p NOT IN (select o from t1); +select * from t2 where p NOT IN (select o from t1) order by p; + +# Use scan +--replace_column 9 # +explain select * from t2 where p NOT IN (select p+0 from t1); +select * from t2 where p NOT IN (select p+0 from t1) order by p; + +drop table t1; +drop table t2; +# bug#5367 +########## + +# End of 4.1 tests + +# +# bug#11205 +# +create table t1 (p int not null primary key, u int not null) engine=ndb; +insert into t1 values (1,1),(2,2),(3,3); + +create table t2 as +select t1.* +from t1 as t1, t1 as t2, t1 as t3, t1 as t4, t1 as t5, t1 as t6, t1 as t7, t1 as t8 +where t1.u = t2.u + and t2.u = t3.u + and t3.u = t4.u + and t4.u = t5.u + and t5.u = t6.u + and t6.u = t7.u + and t7.u = t8.u; + +select * from t2 order by 1; + +select * from t3 where a = any (select c from t4 where c = 1) order by a; +select * from t3 where a in (select c from t4 where c = 1) order by a; +select * from t3 where a <> some (select c from t4 where c = 1) order by a; +select * from t3 where a > all (select c from t4 where c = 1) order by a; +select * from t3 where row(1,10) = (select c,d from t4 where c = 1) order by a; +select * from t3 where exists (select * from t4 where c = 1) order by a; + +drop table if exists t1, t2, t3, t4; + +--echo End of 5.1 tests diff --git a/mysql-test/suite/ndb/t/ndb_temporary.test b/mysql-test/suite/ndb/t/ndb_temporary.test new file mode 100644 index 00000000000..7f6902bf745 --- /dev/null +++ b/mysql-test/suite/ndb/t/ndb_temporary.test @@ -0,0 +1,38 @@ +-- source include/have_ndb.inc +-- source include/not_embedded.inc + +--disable_warnings +DROP TABLE IF EXISTS t1; +--enable_warnings + +# +# creating a temporary table with engine=ndb should give an error +# +--error ER_ILLEGAL_HA_CREATE_OPTION +create temporary table t1 (a int key) engine=ndb; + + +# +# alter temporary table to engine=ndb should give an error +# +create temporary table t1 (a int key) engine=myisam; +--error ER_ILLEGAL_HA_CREATE_OPTION +alter table t1 engine=ndb; +drop table t1; + + +# +# if default storage engine=ndb, temporary tables +# without explicit engine= should be created as myisam +# +SET SESSION storage_engine=NDBCLUSTER; +create table t1 (a int key); + +# verify that we have a ndb table +select engine from information_schema.tables where table_name = 't1'; +drop table t1; + +# verify that we have a myisam table +create temporary table t1 (a int key); +show create table t1; +drop table t1; diff --git a/mysql-test/suite/ndb/t/ndb_transaction.test b/mysql-test/suite/ndb/t/ndb_transaction.test new file mode 100644 index 00000000000..d3ebadb1a78 --- /dev/null +++ b/mysql-test/suite/ndb/t/ndb_transaction.test @@ -0,0 +1,298 @@ +-- source include/have_ndb.inc +-- source include/not_embedded.inc + +--disable_warnings +DROP TABLE IF EXISTS t1,t2,t3,t4,t5,t6,t7; +drop database if exists mysqltest; +--enable_warnings + +# +# Transactionc test to show that the NDB +# table handler is working properly with +# transactions +# + +# +# Create a normal table with primary key +# +CREATE TABLE t1 ( + pk1 INT NOT NULL PRIMARY KEY, + attr1 INT NOT NULL +) ENGINE=ndbcluster; + +# insert +begin; +insert into t1 values(1,1); +insert into t1 values(2,2); +select count(*) from t1; +select * from t1 where pk1 = 1; +select t1.attr1 from t1, t1 as t1x where t1.pk1 = t1x.pk1 + 1; +rollback; + +select count(*) from t1; +select * from t1 where pk1 = 1; +select t1.attr1 from t1, t1 as t1x where t1.pk1 = t1x.pk1 + 1; + +begin; +insert into t1 values(1,1); +insert into t1 values(2,2); +commit; + +select count(*) from t1; +select * from t1 where pk1 = 1; +select t1.attr1 from t1, t1 as t1x where t1.pk1 = t1x.pk1 + 1; + +# update +begin; +update t1 set attr1 = attr1 * 2; +select count(*) from t1; +select * from t1 where pk1 = 1; +select * from t1, t1 as t1x where t1x.attr1 = t1.attr1 - 2; +rollback; + +select count(*) from t1; +select * from t1 where pk1 = 1; +select * from t1, t1 as t1x where t1x.attr1 = t1.attr1 - 2; + +begin; +update t1 set attr1 = attr1 * 2; +commit; + +select count(*) from t1; +select * from t1 where pk1 = 1; +select * from t1, t1 as t1x where t1x.attr1 = t1.attr1 - 2; + +# delete +begin; +delete from t1 where attr1 = 2; +select count(*) from t1; +select * from t1 where pk1 = 1; +select * from t1, t1 as t1x where t1x.attr1 = t1.attr1 - 2; +rollback; + +select count(*) from t1; +select * from t1 where pk1 = 1; +select * from t1, t1 as t1x where t1x.attr1 = t1.attr1 - 2; + +begin; +delete from t1 where attr1 = 2; +commit; + +select count(*) from t1; +select * from t1 where pk1 = 1; +select * from t1, t1 as t1x where t1x.attr1 = t1.attr1 - 2; + +DROP TABLE t1; + +# +# Create table without primary key +# a hidden primary key column is created by handler +# +CREATE TABLE t1 (id INT, id2 int) engine=ndbcluster; + +# insert +begin; +insert into t1 values(1,1); +insert into t1 values(2,2); +select sum(id) from t1; +select * from t1 where id = 1; +select t1.id from t1, t1 as t1x where t1.id2 = t1x.id2 + 1; +rollback; + +select sum(id) from t1; +select * from t1 where id = 1; +select t1.id from t1, t1 as t1x where t1.id2 = t1x.id2 + 1; + +begin; +insert into t1 values(1,1); +insert into t1 values(2,2); +commit; + +select sum(id) from t1; +select * from t1 where id = 1; +select t1.id from t1, t1 as t1x where t1.id2 = t1x.id2 + 1; + +# update +begin; +update t1 set id = id * 2; +select sum(id) from t1; +select * from t1 where id = 2; +select * from t1, t1 as t1x where t1x.id = t1.id - 2; +rollback; + +select sum(id) from t1; +select * from t1 where id = 2; +select * from t1, t1 as t1x where t1x.id = t1.id - 2; + +begin; +update t1 set id = id * 2; +commit; + +select sum(id) from t1; +select * from t1 where id = 2; +select * from t1, t1 as t1x where t1x.id = t1.id - 2; + +# delete + +DROP TABLE t1; + +# +# A more extensive test with a lot more records +# + +CREATE TABLE t2 ( + a bigint unsigned NOT NULL PRIMARY KEY, + b int unsigned not null, + c int unsigned +) engine=ndbcluster; + +CREATE TABLE t3 ( + a bigint unsigned NOT NULL, + b bigint unsigned not null, + c bigint unsigned, + PRIMARY KEY(a) +) engine=ndbcluster; + +CREATE TABLE t4 ( + a bigint unsigned NOT NULL, + b bigint unsigned not null, + c bigint unsigned NOT NULL, + d int unsigned, + PRIMARY KEY(a, b, c) +) engine=ndbcluster; + + +# +# insert records into tables and rollback +# +let $1=100; +disable_query_log; +begin; +while ($1) +{ + eval insert into t2 values($1, $1+9, 5); + eval insert into t3 values($1, $1+9, 5); + eval insert into t4 values($1, $1+9, 5, $1+26000); + dec $1; +} +rollback; +enable_query_log; + +select count(*) from t2; +select count(*) from t3; +select count(*) from t4; + +# +# insert records into tables and commit; +# +let $1=100; +disable_query_log; +begin; +while ($1) +{ + eval insert into t2 values($1, $1+9, 5); + eval insert into t3 values($1, $1+9, 5); + eval insert into t4 values($1, $1+9, 5, $1+26000); + dec $1; +} +commit; +enable_query_log; + +select count(*) from t2; +select count(*) from t3; +select count(*) from t4; + +# +# delete every other record in the tables +# +let $1=100; +disable_query_log; +while ($1) +{ + eval delete from t2 where a=$1; + eval delete from t3 where a=$1; + eval delete from t4 where a=$1 and b=$1+9 and c=5; + dec $1; + dec $1; +} +enable_query_log; + +# +# update records and rollback +# +begin; +let $1=100; +disable_query_log; +while ($1) +{ + eval update t2 set c=$1 where a=$1; + eval update t3 set c=7 where a=$1 and b=$1+9 and c=5; + eval update t4 set d=$1+21987 where a=$1 and b=$1+9 and c=5; + dec $1; + dec $1; +} +rollback; +enable_query_log; + +# +# update records and commit +# +begin; +let $1=100; +disable_query_log; +while ($1) +{ + eval update t2 set c=$1 where a=$1; + eval update t3 set c=7 where a=$1 and b=$1+9 and c=5; + eval update t4 set d=$1+21987 where a=$1 and b=$1+9 and c=5; + dec $1; + dec $1; +} +rollback; +enable_query_log; + +drop table t2; +drop table t3; +drop table t4; + +# +# Test multiple databases in one transaction +# + +CREATE TABLE t1 ( + pk1 INT NOT NULL PRIMARY KEY, + attr1 INT NOT NULL +) ENGINE=ndbcluster; + +create database mysqltest; +use mysqltest; + +CREATE TABLE t2 ( + a bigint unsigned NOT NULL PRIMARY KEY, + b int unsigned not null, + c int unsigned +) engine=ndbcluster; + +begin; +insert into test.t1 values(1,1); +insert into t2 values(1,1,1); +insert into test.t1 values(2,2); +insert into t2 values(2,2,2); +select count(*) from test.t1; +select count(*) from t2; +select * from test.t1 where pk1 = 1; +select * from t2 where a = 1; +select test.t1.attr1 +from test.t1, test.t1 as t1x where test.t1.pk1 = t1x.pk1 + 1; +select t2.a +from t2, t2 as t2x where t2.a = t2x.a + 1; +select test.t1.pk1, a from test.t1,t2 where b > test.t1.attr1; +rollback; + +select count(*) from test.t1; +select count(*) from t2; + +drop table test.t1, t2; +drop database mysqltest; + +# End of 4.1 tests diff --git a/mysql-test/suite/ndb/t/ndb_trigger.test b/mysql-test/suite/ndb/t/ndb_trigger.test new file mode 100644 index 00000000000..2e944174fd0 --- /dev/null +++ b/mysql-test/suite/ndb/t/ndb_trigger.test @@ -0,0 +1,221 @@ +# Tests which involve triggers and NDB storage engine +--source include/have_ndb.inc +--source include/not_embedded.inc + +# +# Test for bug#18437 "Wrong values inserted with a before update +# trigger on NDB table". SQL-layer didn't properly inform handler +# about fields which were read and set in triggers. In some cases +# this resulted in incorrect (garbage) values of OLD variables and +# lost changes to NEW variables. +# You can find similar tests for ON INSERT triggers in federated.test +# since this engine so far is the only engine in MySQL which cares +# about field mark-up during handler::write_row() operation. +# + +--disable_warnings +drop table if exists t1, t2, t3, t4, t5; +--enable_warnings + +create table t1 (id int primary key, a int not null, b decimal (63,30) default 0) engine=ndb; +create table t2 (op char(1), a int not null, b decimal (63,30)) engine=ndb; +create table t3 engine=ndb select 1 as i; +create table t4 (a int not null primary key, b int) engine=ndb; +create table t5 (a int not null primary key, b int) engine=ndb; + +delimiter //; +create trigger t1_bu before update on t1 for each row +begin + insert into t2 values ("u", old.a, old.b); + set new.b = old.b + 10; +end;// +create trigger t1_bd before delete on t1 for each row +begin + insert into t2 values ("d", old.a, old.b); +end;// +create trigger t4_au after update on t4 + for each row begin + update t5 set b = b+1; + end; +// +create trigger t4_ad after delete on t4 + for each row begin + update t5 set b = b+1; + end; +// +delimiter ;// + +insert into t1 values (1, 1, 1.05), (2, 2, 2.05), (3, 3, 3.05), (4, 4, 4.05); +insert into t4 values (1,1), (2,2), (3,3), (4, 4); +insert into t5 values (1,0); + +# Check that usual update works as it should +update t1 set a=5 where a != 3; +select * from t1 order by id; +select * from t2 order by op, a, b; +delete from t2; +# Check that everything works for multi-update +update t1, t3 set a=6 where a = 5; +select * from t1 order by id; +select * from t2 order by op, a, b; +delete from t2; +# Check for delete +delete from t1 where a != 3; +select * from t1 order by id; +select * from t2 order by op, a, b; +delete from t2; +# Check for multi-delete +insert into t1 values (1, 1, 1.05), (2, 2, 2.05), (4, 4, 4.05); +delete t1 from t1, t3 where a != 3; +select * from t1 order by id; +select * from t2 order by op, a, b; +delete from t2; +# Check for insert ... on duplicate key update +insert into t1 values (4, 4, 4.05); +insert into t1 (id, a) values (4, 1), (3, 1) on duplicate key update a= a + 1; +select * from t1 order by id; +select * from t2 order by op, a, b; +delete from t2; +# Check for insert ... select ... on duplicate key update +delete from t3; +insert into t3 values (4), (3); +insert into t1 (id, a) (select i, 1 from t3) on duplicate key update a= a + 1; +select * from t1 order by id; +select * from t2 order by op, a, b; +delete from t2; +# Check for replace +replace into t1 (id, a) values (4, 1), (3, 1); +select * from t1 order by id; +select * from t2 order by op, a, b; +delete from t1; +delete from t2; +# Check for replace ... select ... +insert into t1 values (3, 1, 1.05), (4, 1, 2.05); +replace into t1 (id, a) (select i, 2 from t3); +select * from t1 order by id; +select * from t2 order by op, a, b; +delete from t1; +delete from t2; +# Check for load data replace +insert into t1 values (3, 1, 1.05), (5, 2, 2.05); +load data infile '../std_data_ln/loaddata5.dat' replace into table t1 fields terminated by '' enclosed by '' ignore 1 lines (id, a); +select * from t1 order by id; +select * from t2 order by op, a, b; +update t4 set b = 10 where a = 1; +select * from t5 order by a; +update t5 set b = 0; +delete from t4 where a = 1; +select * from t5 order by a; +drop trigger t4_au; +drop trigger t4_ad; + +drop table t1, t2, t3, t4, t5; +# Test for bug#26242 +# Verify that AFTER UPDATE/DELETE triggers are executed +# after the change has actually taken place + +CREATE TABLE t1 ( + id INT NOT NULL PRIMARY KEY, + xy INT +) ENGINE=ndbcluster; + +INSERT INTO t1 VALUES (1, 0); + +DELIMITER //; +CREATE TRIGGER t1_update AFTER UPDATE ON t1 FOR EACH ROW BEGIN REPLACE INTO t2 SELECT * FROM t1 WHERE t1.id = NEW.id; END // +DELIMITER ;// + +CREATE TABLE t2 ( + id INT NOT NULL PRIMARY KEY, + xy INT +) ENGINE=ndbcluster; + +INSERT INTO t2 VALUES (2, 0); + +CREATE TABLE t3 (id INT NOT NULL PRIMARY KEY) ENGINE=ndbcluster; + +INSERT INTO t3 VALUES (1); + +CREATE TABLE t4 LIKE t1; + +DELIMITER //; +CREATE TRIGGER t4_update AFTER UPDATE ON t4 FOR EACH ROW BEGIN REPLACE INTO t5 SELECT * FROM t4 WHERE t4.id = NEW.id; END // +DELIMITER ;// + +CREATE TABLE t5 LIKE t2; + +UPDATE t1 SET xy = 3 WHERE id = 1; +SELECT xy FROM t1 where id = 1; +SELECT xy FROM t2 where id = 1; + +UPDATE t1 SET xy = 4 WHERE id IN (SELECT id FROM t3 WHERE id = 1); +SELECT xy FROM t1 where id = 1; +SELECT xy FROM t2 where id = 1; + +INSERT INTO t4 SELECT * FROM t1; +INSERT INTO t5 SELECT * FROM t2; +UPDATE t1,t4 SET t1.xy = 3, t4.xy = 3 WHERE t1.id = 1 AND t4.id = 1; +SELECT xy FROM t1 where id = 1; +SELECT xy FROM t2 where id = 1; +SELECT xy FROM t4 where id = 1; +SELECT xy FROM t5 where id = 1; + +UPDATE t1,t4 SET t1.xy = 4, t4.xy = 4 WHERE t1.id IN (SELECT id FROM t3 WHERE id = 1) AND t4.id IN (SELECT id FROM t3 WHERE id = 1); +SELECT xy FROM t1 where id = 1; +SELECT xy FROM t2 where id = 1; +SELECT xy FROM t4 where id = 1; +SELECT xy FROM t5 where id = 1; + +INSERT INTO t1 VALUES (1,0) ON DUPLICATE KEY UPDATE xy = 5; +SELECT xy FROM t1 where id = 1; +SELECT xy FROM t2 where id = 1; + +DROP TRIGGER t1_update; +DROP TRIGGER t4_update; + +DELIMITER //; +CREATE TRIGGER t1_delete AFTER DELETE ON t1 FOR EACH ROW BEGIN REPLACE INTO t2 SELECT * FROM t1 WHERE t1.id > 4; END // +DELIMITER ;// + +DELIMITER //; +CREATE TRIGGER t4_delete AFTER DELETE ON t4 FOR EACH ROW BEGIN REPLACE INTO t5 SELECT * FROM t4 WHERE t4.id > 4; END // +DELIMITER ;// + +INSERT INTO t1 VALUES (5, 0),(6,0); +INSERT INTO t2 VALUES (5, 1),(6,1); +INSERT INTO t3 VALUES (5); +SELECT * FROM t1 order by id; +SELECT * FROM t2 order by id; +DELETE FROM t1 WHERE id IN (SELECT id FROM t3 WHERE id = 5); +SELECT * FROM t1 order by id; +SELECT * FROM t2 order by id; + +INSERT INTO t1 VALUES (5,0); +UPDATE t2 SET xy = 1 WHERE id = 6; +TRUNCATE t4; +INSERT INTO t4 SELECT * FROM t1; +TRUNCATE t5; +INSERT INTO t5 SELECT * FROM t2; +SELECT * FROM t1 order by id; +SELECT * FROM t2 order by id; +SELECT * FROM t4 order by id; +SELECT * FROM t5 order by id; +DELETE FROM t1,t4 USING t1,t3,t4 WHERE t1.id IN (SELECT id FROM t3 WHERE id = 5) AND t4.id IN (SELECT id FROM t3 WHERE id = 5); +SELECT * FROM t1 order by id; +SELECT * FROM t2 order by id; +SELECT * FROM t4 order by id; +SELECT * FROM t5 order by id; + +INSERT INTO t1 VALUES (5, 0); +REPLACE INTO t2 VALUES (6,1); +SELECT * FROM t1 order by id; +SELECT * FROM t2 order by id; +REPLACE INTO t1 VALUES (5, 1); +SELECT * FROM t1 order by id; +SELECT * FROM t2 order by id; + +DROP TRIGGER t1_delete; +DROP TRIGGER t4_delete; +DROP TABLE t1, t2, t3, t4, t5; + +--echo End of 5.1 tests diff --git a/mysql-test/suite/ndb/t/ndb_truncate.test b/mysql-test/suite/ndb/t/ndb_truncate.test new file mode 100644 index 00000000000..a1ef4be0d48 --- /dev/null +++ b/mysql-test/suite/ndb/t/ndb_truncate.test @@ -0,0 +1,41 @@ +-- source include/have_ndb.inc +-- source include/not_embedded.inc + +--disable_warnings +DROP TABLE IF EXISTS t1, t2; +--enable_warnings + +CREATE TABLE t1 ( + a bigint unsigned NOT NULL AUTO_INCREMENT PRIMARY KEY, + b int unsigned not null, + c int unsigned +) engine=ndbcluster; + + +# +# insert records into table +# +let $1=500; +disable_query_log; +while ($1) +{ + eval insert into t1 values(NULL, $1+9, 5*$1), (NULL, $1+10, 7),(NULL, $1+10, 7*$1), (NULL, $1+10, 10+$1), (NULL, $1+10, 70*$1), (NULL, $1+10, 7), (NULL, $1+10, 9), (NULL, $1+299, 899), (NULL, $1+10, 12), (NULL, $1+10, 14*$1); + dec $1; +} +enable_query_log; + +select count(*) from t1; + +select * from t1 order by a limit 2; + +truncate table t1; + +select count(*) from t1; + +insert into t1 values(NULL,1,1),(NULL,2,2); + +select * from t1 order by a; + +drop table t1; + +# End of 4.1 tests diff --git a/mysql-test/suite/ndb/t/ndb_types.test b/mysql-test/suite/ndb/t/ndb_types.test new file mode 100644 index 00000000000..ab18817132e --- /dev/null +++ b/mysql-test/suite/ndb/t/ndb_types.test @@ -0,0 +1,85 @@ +--source include/have_ndb.inc +--source include/not_embedded.inc + +--disable_warnings +DROP TABLE IF EXISTS t1; +--enable_warnings + +# +# Test creation of different column types in NDB +# +CREATE TABLE t1 ( + auto int(5) unsigned NOT NULL auto_increment, + string char(10) default "hello", + vstring varchar(10) default "hello", + bin binary(2), + vbin varbinary(7), + tiny tinyint(4) DEFAULT '0' NOT NULL , + short smallint(6) DEFAULT '1' NOT NULL , + medium mediumint(8) DEFAULT '0' NOT NULL, + long_int int(11) DEFAULT '0' NOT NULL, + longlong bigint(13) DEFAULT '0' NOT NULL, + real_float float(13,1) DEFAULT 0.0 NOT NULL, + real_double double(16,4), + real_decimal decimal(16,4), + utiny tinyint(3) unsigned DEFAULT '0' NOT NULL, + ushort smallint(5) unsigned zerofill DEFAULT '00000' NOT NULL, + umedium mediumint(8) unsigned DEFAULT '0' NOT NULL, + ulong int(11) unsigned DEFAULT '0' NOT NULL, + ulonglong bigint(13) unsigned DEFAULT '0' NOT NULL, + bits bit(3), + options enum('one','two','tree') not null, + flags set('one','two','tree') not null, + date_field date, + year_field year, + time_field time, + date_time datetime, + time_stamp timestamp not null default CURRENT_TIMESTAMP on update CURRENT_TIMESTAMP, + PRIMARY KEY (auto), + KEY (utiny), + KEY (tiny), + KEY (short), + KEY any_name (medium), + KEY (longlong), + KEY (real_float), + KEY (ushort), + KEY (umedium), + KEY (ulong), + KEY (ulonglong,ulong), + KEY (options,flags) +); + +set @now = now(); +--sleep 1.5 +insert into t1 +(string,vstring,bin,vbin,tiny,short,medium,long_int,longlong, + real_float,real_double, real_decimal,utiny, ushort, umedium,ulong,ulonglong, + bits,options,flags,date_field,year_field,time_field,date_time) +values +("aaaa","aaaa",0xAAAA,0xAAAA,-1,-1,-1,-1,-1,1.1,1.1,1.1,1,1,1,1,1, + b'001','one','one', '1901-01-01','1901','01:01:01','1901-01-01 01:01:01'); + +select auto,string,vstring,bin,vbin,tiny,short,medium,long_int,longlong, + real_float,real_double,real_decimal,utiny,ushort,umedium,ulong,ulonglong, + bits,options,flags,date_field,year_field,time_field,date_time +from t1; +select time_stamp>@now from t1; + +set @now = now(); +--sleep 1.5 +update t1 set string="bbbb",vstring="bbbb",bin=0xBBBB,vbin=0xBBBB, +tiny=-2,short=-2,medium=-2,long_int=-2,longlong=-2,real_float=2.2, +real_double=2.2,real_decimal=2.2,utiny=2,ushort=2,umedium=2,ulong=2, +ulonglong=2, bits=b'010', +options='one',flags='one', date_field='1902-02-02',year_field='1902', +time_field='02:02:02',date_time='1902-02-02 02:02:02' where auto=1; + +select auto,string,vstring,bin,vbin,tiny,short,medium,long_int,longlong, + real_float,real_double,real_decimal,utiny,ushort,umedium,ulong,ulonglong, + bits,options,flags,date_field,year_field,time_field,date_time +from t1; +select time_stamp>@now from t1; + +drop table t1; + +--echo End of 4.1 tests diff --git a/mysql-test/suite/ndb/t/ndb_update.test b/mysql-test/suite/ndb/t/ndb_update.test new file mode 100644 index 00000000000..c45f990edcc --- /dev/null +++ b/mysql-test/suite/ndb/t/ndb_update.test @@ -0,0 +1,89 @@ +-- source include/have_ndb.inc +-- source include/not_embedded.inc + +--disable_warnings +DROP TABLE IF EXISTS t1; +DROP TABLE IF EXISTS t2; +DROP TABLE IF EXISTS t3; +--enable_warnings + +# +# Basic test of UPDATE in NDB +# + +# +# Create a normal table with primary key +# +CREATE TABLE t1 ( + pk1 INT NOT NULL PRIMARY KEY, + b INT NOT NULL, + c INT NOT NULL UNIQUE +) ENGINE=ndbcluster; + +INSERT INTO t1 VALUES (0, 1, 0),(1,2,1),(2,3,2); +UPDATE t1 set b = c; +select * from t1 order by pk1; +UPDATE t1 set pk1 = 4 where pk1 = 1; +select * from t1 order by pk1; +--error ER_DUP_ENTRY +UPDATE t1 set pk1 = 4 where pk1 = 2; +UPDATE IGNORE t1 set pk1 = 4 where pk1 = 2; +select * from t1 order by pk1; +--error ER_DUP_ENTRY +UPDATE t1 set pk1 = 1, c = 2 where pk1 = 4; +UPDATE IGNORE t1 set pk1 = 1, c = 2 where pk1 = 4; +select * from t1 order by pk1; +UPDATE t1 set pk1 = pk1 + 10; +select * from t1 order by pk1; + +--disable_warnings +DROP TABLE IF EXISTS t1; +--enable_warnings + +# End of 4.1 tests + +# +# Bug#28158: table->read_set is set incorrectly, +# causing wrong error message in Falcon +# +CREATE TABLE t1 (a int, b int, KEY (a, b)) ENGINE=ndbcluster; +CREATE TABLE t2 (a int, b int, UNIQUE KEY (a, b)) ENGINE=ndbcluster; +CREATE TABLE t3 (a int, b int, PRIMARY KEY (a, b)) ENGINE=ndbcluster; +# +INSERT INTO t1 VALUES (1, 2); +INSERT INTO t1 VALUES (2, 2); +# +INSERT INTO t2 VALUES (1, 2); +INSERT INTO t2 VALUES (2, 2); +# +INSERT INTO t3 VALUES (1, 2); +INSERT INTO t3 VALUES (2, 2); +# +UPDATE t1 SET a = 1; +UPDATE t1 SET a = 1 ORDER BY a; +# +--error ER_DUP_ENTRY +UPDATE t2 SET a = 1; +--error ER_DUP_ENTRY +UPDATE t2 SET a = 1 ORDER BY a; +# +--error ER_DUP_ENTRY +UPDATE t3 SET a = 1; +--error ER_DUP_ENTRY +UPDATE t3 SET a = 1 ORDER BY a; +# +SELECT count(*) FROM t1; +SELECT count(*) FROM t2; +SELECT count(*) FROM t3; +SELECT * FROM t1 ORDER by a; +SELECT * FROM t2 ORDER by a; +SELECT * FROM t3 ORDER by a; +# +--disable_warnings +DROP TABLE IF EXISTS t1; +DROP TABLE IF EXISTS t2; +DROP TABLE IF EXISTS t3; +--enable_warnings + +--echo End of 5.1 tests + diff --git a/mysql-test/suite/ndb/t/ndb_view.test b/mysql-test/suite/ndb/t/ndb_view.test new file mode 100644 index 00000000000..3b8fc330b40 --- /dev/null +++ b/mysql-test/suite/ndb/t/ndb_view.test @@ -0,0 +1,29 @@ +-- source include/have_ndb.inc +-- source include/not_embedded.inc + +--disable_warnings +DROP TABLE IF EXISTS t1,t2,t3; +DROP VIEW IF EXISTS v1,v2,v3; +--enable_warnings + +# +# simple operations via view +# + +create table t1 (a int, b int, c int, d int) engine=ndb; +insert into t1 values (1,2,3,4),(5,6,7,8); + +create view v1 as select t1.c as a, t1.a as b, t1.d as c, t1.a+t1.b+t1.c as d from t1; +select * from v1 order by a,b,c; + +update v1 set a=a+100 where b=1; +select * from v1 order by a,b,c; + +drop view v1; + +create view v1 as select t1.c as a from t1; +insert into v1 values (200); +select * from t1 order by a,b,c,d; + +drop view v1; +drop table t1; diff --git a/mysql-test/suite/ndb/t/ndbapi.test b/mysql-test/suite/ndb/t/ndbapi.test new file mode 100644 index 00000000000..3424513f8af --- /dev/null +++ b/mysql-test/suite/ndb/t/ndbapi.test @@ -0,0 +1,44 @@ +-- source include/have_ndb.inc +-- source include/have_ndbapi_examples.inc + +--disable_warnings +DROP TABLE IF EXISTS t0; +drop database if exists mysqltest; +--enable_warnings + +--exec echo Running ndbapi_simple +--exec $NDB_EXAMPLES_DIR/ndbapi_simple/ndbapi_simple $MASTER_MYSOCK "localhost:$NDBCLUSTER_PORT" >> $NDB_EXAMPLES_OUTPUT + +--exec echo Running ndbapi_simple_index +--exec $NDB_EXAMPLES_DIR/ndbapi_simple_index/ndbapi_simple_index $MASTER_MYSOCK "localhost:$NDBCLUSTER_PORT" >> $NDB_EXAMPLES_OUTPUT + +--exec echo Running ndbapi_scan +--exec $NDB_EXAMPLES_DIR/ndbapi_scan/ndbapi_scan $MASTER_MYSOCK "localhost:$NDBCLUSTER_PORT" >> $NDB_EXAMPLES_OUTPUT + +--exec echo Running ndbapi_retries +--exec $NDB_EXAMPLES_DIR/ndbapi_retries/ndbapi_retries $MASTER_MYSOCK "localhost:$NDBCLUSTER_PORT" >> $NDB_EXAMPLES_OUTPUT + +--exec echo Running ndbapi_async +--exec $NDB_EXAMPLES_DIR/ndbapi_async/ndbapi_async $MASTER_MYSOCK "localhost:$NDBCLUSTER_PORT" >> $NDB_EXAMPLES_OUTPUT + +--exec echo Running ndbapi_async1 +--exec $NDB_EXAMPLES_DIR/ndbapi_async1/ndbapi_async1 $MASTER_MYSOCK "localhost:$NDBCLUSTER_PORT" >> $NDB_EXAMPLES_OUTPUT + +use TEST_DB; +create table t0(c0 int, c1 int, c2 char(4), c3 char(4), c4 text, + primary key(c0, c2)) engine ndb charset latin1; +#--exec echo Running ndbapi_event +#--exec $NDB_EXAMPLES_DIR/ndbapi_event/ndbapi_event "localhost:$NDBCLUSTER_PORT" 1 >> $NDB_EXAMPLES_OUTPUT +insert into t0 values (1, 2, 'a', 'b', null); +insert into t0 values (3, 4, 'c', 'd', null); +update t0 set c3 = 'e' where c0 = 1 and c2 = 'a'; -- use pk +update t0 set c3 = 'f'; -- use scan +update t0 set c3 = 'F'; -- use scan update to 'same' +update t0 set c2 = 'g' where c0 = 1; -- update pk part +update t0 set c2 = 'G' where c0 = 1; -- update pk part to 'same' +update t0 set c0 = 5, c2 = 'H' where c0 = 3; -- update full PK +delete from t0; +drop table t0; + +--exec echo Running mgmapi_logevent +--exec $NDB_EXAMPLES_DIR/mgmapi_logevent/mgmapi_logevent "localhost:$NDBCLUSTER_PORT" 1 >> $NDB_EXAMPLES_OUTPUT diff --git a/mysql-test/suite/ndb/t/partition_03ndb.test b/mysql-test/suite/ndb/t/partition_03ndb.test new file mode 100644 index 00000000000..3190ab9dfc7 --- /dev/null +++ b/mysql-test/suite/ndb/t/partition_03ndb.test @@ -0,0 +1,26 @@ +############################################### +# # +# Partition tests NDB tables # +# # +############################################### + +# +# NOTE: PLEASE DO NOT ADD NOT NDB SPECIFIC TESTCASES HERE ! +# NON STORAGE SPECIFIC TESTCASES SHOULD BE ADDED IN +# THE SOURCED FIELS ONLY. +# + +# Storage engine to be tested +let $engine= 'NDB' ; +-- source include/have_ndb.inc +eval SET SESSION storage_engine=$engine; + + +# Other storage engine <> storage engine to be tested +let $engine_other= 'MEMORY'; +# number of rows for the INSERT/UPDATE/DELETE/SELECT experiments +# on partioned tables +# Attention: In the moment the result files fit to @max_row = 200 only +SET @max_row = 200; + +-- source include/partition_1.inc diff --git a/mysql-test/suite/ndb/t/ps_7ndb.test b/mysql-test/suite/ndb/t/ps_7ndb.test new file mode 100644 index 00000000000..e3f65ec2c4e --- /dev/null +++ b/mysql-test/suite/ndb/t/ps_7ndb.test @@ -0,0 +1,25 @@ +############################################### +# # +# Prepared Statements test on NDB tables # +# # +############################################### + +# +# NOTE: PLEASE SEE ps_1general.test (bottom) +# BEFORE ADDING NEW TEST CASES HERE !!! + +use test; + +-- source include/have_ndb.inc +let $type= 'NDB' ; +-- source include/ps_create.inc +-- source include/ps_renew.inc + +-- source include/ps_query.inc +-- source include/ps_modify.inc +-- source include/ps_modify1.inc +-- source include/ps_conv.inc + +drop table t1, t9; + +# End of 4.1 tests diff --git a/mysql-test/suite/ndb/t/strict_autoinc_5ndb.test b/mysql-test/suite/ndb/t/strict_autoinc_5ndb.test new file mode 100644 index 00000000000..9e2090fddef --- /dev/null +++ b/mysql-test/suite/ndb/t/strict_autoinc_5ndb.test @@ -0,0 +1,10 @@ +-- source include/have_ndb.inc + +# +# Bug#20573 Strict mode auto-increment +# + +let $type= 'NDB' ; +--source include/strict_autoinc.inc + +# end of test |