Current Path : /usr/opt/mysql57/mysql-test/suite/ndb/r/ |
FreeBSD hs32.drive.ne.jp 9.1-RELEASE FreeBSD 9.1-RELEASE #1: Wed Jan 14 12:18:08 JST 2015 root@hs32.drive.ne.jp:/sys/amd64/compile/hs32 amd64 |
Current File : //usr/opt/mysql57/mysql-test/suite/ndb/r/ndb_partition_key.result |
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); ALTER TABLE t1 ALGORITHM=INPLACE, REORGANIZE PARTITION; 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 select max(b) from t1 where a = 1; max(b) 12 select b from t1 where a = 1 order by b desc; b 12 11 10 9 8 7 6 5 4 3 2 1 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); 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 show create table t1; Table Create Table t1 CREATE TABLE `t1` ( `a` int(11) NOT NULL, `b` char(10) CHARACTER SET latin1 COLLATE latin1_bin NOT NULL, `c` int(11) NOT NULL, `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 ALGORITHM=COPY, ENGINE = NDB PARTITION BY KEY(a) (PARTITION p0 ENGINE = NDB, PARTITION p1 ENGINE = NDB); drop table t1; CREATE TABLE t1 (a int not null primary key) ENGINE = NDB; ALTER TABLE t1 PARTITION BY KEY(a) (PARTITION p0 ENGINE = NDB, PARTITION p1 ENGINE = NDB); drop table t1; create table t1 (a int primary key) engine=ndb partition by key(a) (partition p0, partition p1); show create table t1; Table Create Table t1 CREATE TABLE `t1` ( `a` int(11) NOT NULL, PRIMARY KEY (`a`) ) 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) NOT NULL, PRIMARY KEY (`a`) ) 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) NOT NULL, PRIMARY KEY (`a`) ) 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) NOT NULL, PRIMARY KEY (`a`) ) 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) NOT NULL, PRIMARY KEY (`a`) ) 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) NOT NULL, PRIMARY KEY (`a`) ) 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) NOT NULL, PRIMARY KEY (`a`) ) ENGINE=ndbcluster DEFAULT CHARSET=latin1 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; Table Create Table t1 CREATE TABLE `t1` ( `a` int(11) NOT NULL, PRIMARY KEY (`a`) ) 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 ALGORITHM=COPY, COALESCE PARTITION 4; DROP TABLE t1; CREATE TABLE t1 (a int primary key) ENGINE=NDB PARTITION BY KEY(a); ANALYZE TABLE t1; Table Op Msg_type Msg_text test.t1 analyze status OK CHECK TABLE t1; Table Op Msg_type Msg_text test.t1 check note The storage engine for the table doesn't support check OPTIMIZE TABLE t1; Table Op Msg_type Msg_text test.t1 optimize status OK REPAIR TABLE t1; Table Op Msg_type Msg_text test.t1 repair note The storage engine for the table doesn't support repair ALTER TABLE t1 ALGORITHM=INPLACE, OPTIMIZE PARTITION p0; Table Op Msg_type Msg_text test.t1 optimize status OK ALTER TABLE t1 ALGORITHM=INPLACE, CHECK PARTITION p0; Table Op Msg_type Msg_text test.t1 check note The storage engine for the table doesn't support check ALTER TABLE t1 ALGORITHM=INPLACE, REPAIR PARTITION p0; Table Op Msg_type Msg_text test.t1 repair note The storage engine for the table doesn't support repair ALTER TABLE t1 ALGORITHM=INPLACE, ANALYZE PARTITION p0; Table Op Msg_type Msg_text test.t1 analyze status OK ALTER TABLE t1 ALGORITHM=INPLACE, 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; create table nott1 (a int, b int, c int, primary key(a,b)) engine=ndb partition by key(a); insert into nott1 values (0,0,0); insert into nott1 values (0,1,1); insert into nott1 values (0,2,2); insert into nott1 values (0,3,3); insert into nott1 values (1,0,4); insert into nott1 values (1,1,5); insert into nott1 values (1,2,6); insert into nott1 values (2,22,7); All partitions scan select * from nott1 order by c; a b c 0 0 0 0 1 1 0 2 2 0 3 3 1 0 4 1 1 5 1 2 6 2 22 7 ndb_scan_count 1 ndb_pruned_scan_count 0 Single partition scan select * from nott1 where a=0 order by c; a b c 0 0 0 0 1 1 0 2 2 0 3 3 ndb_scan_count 1 ndb_pruned_scan_count 1 Single partition scan select * from nott1 where a=4 order by c; a b c ndb_scan_count 1 ndb_pruned_scan_count 1 MRR scan on one partition select * from nott1 where a=0 and (( b > 0 and b < 3) or ( b > 5 and b < 10) or ( b > 22 and b < 50)) order by c; a b c 0 1 1 0 2 2 ndb_scan_count 1 ndb_pruned_scan_count 1 drop table nott1; CREATE TABLE t1 ( a char(10) NOT NULL, b char(1) NOT NULL, PRIMARY KEY (a,b) ) ENGINE ndb DEFAULT CHARSET=latin1 COLLATE=latin1_german2_ci PARTITION BY KEY (a); insert into t1 values ('a', 'a'), ('b', 'b'); select * from t1 where a = 'a'; a b a a drop table t1; CREATE TABLE t1 ( a varchar(3000) NOT NULL, b char(1) NOT NULL, PRIMARY KEY (a,b) ) ENGINE ndb DEFAULT CHARSET=latin1 COLLATE=latin1_german2_ci PARTITION BY KEY (a); insert into t1 values ('a', 'a'), ('b', 'b'); select * from t1 where a = 'a'; a b a a drop table t1;