mirror of
https://github.com/MariaDB/server.git
synced 2025-01-31 19:11:46 +01:00
Merge jamppa@bk-internal.mysql.com:/home/bk/mysql-5.1-new
into a193-229-222-105.elisa-laajakaista.fi:/home/my/bk/mysql-5.1-new-merge_060509 sql/sql_select.cc: Auto merged
This commit is contained in:
commit
781e22d70d
31 changed files with 246 additions and 1812 deletions
|
@ -147,3 +147,15 @@ set autocommit=1;
|
|||
--replace_column 2 # 5 #
|
||||
--replace_regex /table_id: [0-9]+/table_id: #/
|
||||
show binlog events;
|
||||
|
||||
#
|
||||
# BUG#10952 - alter table ... lost data without errors and warnings
|
||||
#
|
||||
drop table if exists t1;
|
||||
create table t1 (c char(20)) engine=MyISAM;
|
||||
insert into t1 values ("Monty"),("WAX"),("Walrus");
|
||||
--error 1031
|
||||
alter table t1 engine=blackhole;
|
||||
drop table t1;
|
||||
|
||||
# End of 5.0 tests
|
||||
|
|
|
@ -156,3 +156,9 @@ master-bin.000001 # Query 1 # use `test`; BEGIN
|
|||
master-bin.000001 # Table_map 1 # table_id: # (test.t1)
|
||||
master-bin.000001 # Write_rows 1 # table_id: # flags: STMT_END_F
|
||||
master-bin.000001 # Query 1 # use `test`; COMMIT
|
||||
drop table if exists t1;
|
||||
create table t1 (c char(20)) engine=MyISAM;
|
||||
insert into t1 values ("Monty"),("WAX"),("Walrus");
|
||||
alter table t1 engine=blackhole;
|
||||
ERROR HY000: Table storage engine for 't1' doesn't have this option
|
||||
drop table t1;
|
||||
|
|
|
@ -149,3 +149,9 @@ master-bin.000001 # Query 1 # use `test`; create table t1 (a int) engine=blackho
|
|||
master-bin.000001 # Query 1 # use `test`; BEGIN
|
||||
master-bin.000001 # Query 1 # use `test`; insert into t1 values(1)
|
||||
master-bin.000001 # Query 1 # use `test`; COMMIT
|
||||
drop table if exists t1;
|
||||
create table t1 (c char(20)) engine=MyISAM;
|
||||
insert into t1 values ("Monty"),("WAX"),("Walrus");
|
||||
alter table t1 engine=blackhole;
|
||||
ERROR HY000: Table storage engine for 't1' doesn't have this option
|
||||
drop table t1;
|
||||
|
|
|
@ -771,3 +771,11 @@ Table Op Msg_type Msg_text
|
|||
test.t1 check status OK
|
||||
test.t2 check status OK
|
||||
drop table t1, t2, t3;
|
||||
drop table if exists t1;
|
||||
Warnings:
|
||||
Note 1051 Unknown table 't1'
|
||||
create table t1 (c char(20)) engine=MyISAM;
|
||||
insert into t1 values ("Monty"),("WAX"),("Walrus");
|
||||
alter table t1 engine=MERGE;
|
||||
ERROR HY000: Table storage engine for 't1' doesn't have this option
|
||||
drop table t1;
|
||||
|
|
|
@ -1,104 +0,0 @@
|
|||
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;
|
|
@ -1,47 +0,0 @@
|
|||
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;
|
|
@ -1,240 +0,0 @@
|
|||
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 need to include all fields in the partition 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
|
||||
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 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 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 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 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 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 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 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);
|
||||
ALTER TABLE t1 ADD COLUMN c4 INT AFTER c1;
|
||||
DROP TABLE t1;
|
||||
create table t1 (a int) engine = ndb;
|
||||
show create table t1;
|
||||
Table Create Table
|
||||
t1 CREATE TABLE `t1` (
|
||||
`a` int(11) DEFAULT NULL
|
||||
) ENGINE=ndbcluster DEFAULT CHARSET=latin1
|
||||
alter table t1 add column b int;
|
||||
show create table t1;
|
||||
Table Create Table
|
||||
t1 CREATE TABLE `t1` (
|
||||
`a` int(11) DEFAULT NULL,
|
||||
`b` int(11) DEFAULT NULL
|
||||
) ENGINE=ndbcluster DEFAULT CHARSET=latin1
|
||||
alter table t1 engine = myisam;
|
||||
alter table t1 engine = ndb;
|
||||
show create table t1;
|
||||
Table Create Table
|
||||
t1 CREATE TABLE `t1` (
|
||||
`a` int(11) DEFAULT NULL,
|
||||
`b` int(11) DEFAULT NULL
|
||||
) ENGINE=ndbcluster DEFAULT CHARSET=latin1
|
||||
alter table t1 coalesce partition 1;
|
||||
show create table t1;
|
||||
Table Create Table
|
||||
t1 CREATE TABLE `t1` (
|
||||
`a` int(11) DEFAULT NULL,
|
||||
`b` int(11) DEFAULT NULL
|
||||
) ENGINE=ndbcluster DEFAULT CHARSET=latin1 PARTITION BY KEY () PARTITIONS 1
|
||||
drop table t1 ;
|
||||
create table t1 (a int) engine = ndb;
|
||||
alter table t1 add partition partitions 1;
|
||||
show create table t1;
|
||||
Table Create Table
|
||||
t1 CREATE TABLE `t1` (
|
||||
`a` int(11) DEFAULT NULL
|
||||
) ENGINE=ndbcluster DEFAULT CHARSET=latin1 PARTITION BY KEY () PARTITIONS 3
|
||||
drop table t1;
|
||||
CREATE TABLE t1 (a int)
|
||||
PARTITION BY KEY(a)
|
||||
(PARTITION p0 ENGINE = NDB);
|
||||
DROP TABLE t1;
|
|
@ -1,51 +0,0 @@
|
|||
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;
|
|
@ -1,263 +0,0 @@
|
|||
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 0 default
|
||||
NULL test t1 x2 NULL 2 NULL RANGE NULL a NULL 10 0 0 0 # 0 0 # # NULL NULL default 0 default
|
||||
NULL test t1 x3 NULL 3 NULL RANGE NULL a NULL 20 0 0 0 # 0 0 # # NULL NULL default 0 default
|
||||
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 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;
|
|
@ -1,4 +1,8 @@
|
|||
drop table if exists t1;
|
||||
create table t1 (a int)
|
||||
partition by key(a)
|
||||
(partition p0 engine = MEMORY);
|
||||
drop table t1;
|
||||
CREATE TABLE t1 (
|
||||
a int not null,
|
||||
b int not null,
|
||||
|
@ -886,6 +890,11 @@ s1
|
|||
2
|
||||
3
|
||||
drop table t1;
|
||||
create table t1 (a int) engine=memory
|
||||
partition by key(a);
|
||||
insert into t1 values (1);
|
||||
create index inx1 on t1(a);
|
||||
drop table t1;
|
||||
create table t1 (a varchar(1))
|
||||
partition by key (a)
|
||||
as select 'a';
|
||||
|
@ -913,9 +922,4 @@ CREATE TABLE t1 (a int, index(a)) PARTITION BY KEY(a);
|
|||
ALTER TABLE t1 DISABLE KEYS;
|
||||
ALTER TABLE t1 ENABLE KEYS;
|
||||
DROP TABLE t1;
|
||||
create table t1 (a int) engine=memory
|
||||
partition by key(a);
|
||||
insert into t1 values (1);
|
||||
create index inx1 on t1(a);
|
||||
drop table t1;
|
||||
End of 5.1 tests
|
||||
|
|
|
@ -3411,3 +3411,19 @@ SELECT * FROM t1;
|
|||
i
|
||||
255
|
||||
DROP TABLE t1;
|
||||
create table t1 (a int);
|
||||
insert into t1 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9);
|
||||
create table t2 (a int, b int, c int, e int, primary key(a,b,c));
|
||||
insert into t2 select A.a, B.a, C.a, C.a from t1 A, t1 B, t1 C;
|
||||
analyze table t2;
|
||||
Table Op Msg_type Msg_text
|
||||
test.t2 analyze status OK
|
||||
select 'In next EXPLAIN, B.rows must be exactly 10:' Z;
|
||||
Z
|
||||
In next EXPLAIN, B.rows must be exactly 10:
|
||||
explain select * from t2 A, t2 B where A.a=5 and A.b=5 and A.C<5
|
||||
and B.a=5 and B.b=A.e and (B.b =1 or B.b = 3 or B.b=5);
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE A range PRIMARY PRIMARY 12 NULL 3 Using where
|
||||
1 SIMPLE B ref PRIMARY PRIMARY 8 const,test.A.e 10
|
||||
drop table t1, t2;
|
||||
|
|
|
@ -1480,7 +1480,7 @@ Note 1003 select `test`.`t1`.`s1` AS `s1`,not(<in_optimizer>(`test`.`t1`.`s1`,<e
|
|||
explain extended select s1, s1 NOT IN (SELECT s1 FROM t2 WHERE s1 < 'a2') from t1;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 PRIMARY t1 index NULL s1 6 NULL 3 Using index
|
||||
2 DEPENDENT SUBQUERY t2 index_subquery s1 s1 6 func 1 Using index; Using where
|
||||
2 DEPENDENT SUBQUERY t2 index_subquery s1 s1 6 func 2 Using index; Using where
|
||||
Warnings:
|
||||
Note 1003 select `test`.`t1`.`s1` AS `s1`,not(<in_optimizer>(`test`.`t1`.`s1`,<exists>(<index_lookup>(<cache>(`test`.`t1`.`s1`) in t2 on s1 checking NULL where (`test`.`t2`.`s1` < _latin1'a2'))))) AS `s1 NOT IN (SELECT s1 FROM t2 WHERE s1 < 'a2')` from `test`.`t1`
|
||||
drop table t1,t2;
|
||||
|
|
|
@ -382,3 +382,15 @@ check table t1, t2;
|
|||
drop table t1, t2, t3;
|
||||
|
||||
# End of 4.1 tests
|
||||
|
||||
#
|
||||
# BUG#10952 - alter table ... lost data without errors and warnings
|
||||
#
|
||||
drop table if exists t1;
|
||||
create table t1 (c char(20)) engine=MyISAM;
|
||||
insert into t1 values ("Monty"),("WAX"),("Walrus");
|
||||
--error 1031
|
||||
alter table t1 engine=MERGE;
|
||||
drop table t1;
|
||||
|
||||
# End of 5.0 tests
|
||||
|
|
|
@ -1,93 +0,0 @@
|
|||
--source include/have_ndb.inc
|
||||
-- source include/not_embedded.inc
|
||||
|
||||
--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;
|
|
@ -1,71 +0,0 @@
|
|||
-- 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
|
||||
|
||||
#
|
||||
# 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;
|
|
@ -1,224 +0,0 @@
|
|||
-- 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);
|
||||
|
||||
ALTER TABLE t1 ADD COLUMN c4 INT AFTER c1;
|
||||
DROP TABLE t1;
|
||||
|
||||
#
|
||||
# BUG 19010: ALTER TABLE from NDB to other engine without primary key
|
||||
# doesn't work.
|
||||
#
|
||||
create table t1 (a int) engine = ndb;
|
||||
show create table t1;
|
||||
alter table t1 add column b int;
|
||||
show create table t1;
|
||||
alter table t1 engine = myisam;
|
||||
alter table t1 engine = ndb;
|
||||
show create table t1;
|
||||
alter table t1 coalesce partition 1;
|
||||
show create table t1;
|
||||
drop table t1 ;
|
||||
create table t1 (a int) engine = ndb;
|
||||
alter table t1 add partition partitions 1;
|
||||
show create table t1;
|
||||
drop table t1;
|
||||
|
||||
CREATE TABLE t1 (a int)
|
||||
PARTITION BY KEY(a)
|
||||
(PARTITION p0 ENGINE = NDB);
|
||||
DROP TABLE t1;
|
||||
|
||||
|
|
@ -1,64 +0,0 @@
|
|||
--source include/have_ndb.inc
|
||||
#
|
||||
# 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
|
||||
|
||||
#
|
||||
# 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;
|
||||
|
|
@ -1,260 +0,0 @@
|
|||
-- 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
|
||||
|
||||
#
|
||||
# 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;
|
|
@ -2886,3 +2886,16 @@ SELECT * FROM t1;
|
|||
UPDATE t1 SET i = i - 1;
|
||||
SELECT * FROM t1;
|
||||
DROP TABLE t1;
|
||||
|
||||
# BUG#17379
|
||||
|
||||
create table t1 (a int);
|
||||
insert into t1 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9);
|
||||
create table t2 (a int, b int, c int, e int, primary key(a,b,c));
|
||||
insert into t2 select A.a, B.a, C.a, C.a from t1 A, t1 B, t1 C;
|
||||
analyze table t2;
|
||||
select 'In next EXPLAIN, B.rows must be exactly 10:' Z;
|
||||
|
||||
explain select * from t2 A, t2 B where A.a=5 and A.b=5 and A.C<5
|
||||
and B.a=5 and B.b=A.e and (B.b =1 or B.b = 3 or B.b=5);
|
||||
drop table t1, t2;
|
||||
|
|
|
@ -74,7 +74,7 @@ handlerton myisammrg_hton= {
|
|||
NULL, /* Alter table flags */
|
||||
NULL, /* Alter Tablespace */
|
||||
NULL, /* Fill Files Table */
|
||||
HTON_CAN_RECREATE,
|
||||
HTON_CAN_RECREATE | HTON_ALTER_CANNOT_CREATE,
|
||||
NULL, /* binlog_func */
|
||||
NULL, /* binlog_log_query */
|
||||
NULL /* release_temporary_latches */
|
||||
|
|
|
@ -603,6 +603,7 @@ struct show_table_alias_st {
|
|||
#define HTON_FLUSH_AFTER_RENAME (1 << 4)
|
||||
#define HTON_NOT_USER_SELECTABLE (1 << 5)
|
||||
#define HTON_TEMPORARY_NOT_SUPPORTED (1 << 6) //Having temporary tables not supported
|
||||
#define HTON_ALTER_CANNOT_CREATE (1 << 7) //Cannot use alter to create
|
||||
|
||||
typedef struct st_thd_trans
|
||||
{
|
||||
|
|
|
@ -450,6 +450,8 @@ public:
|
|||
|
||||
/* TRUE if last checked tree->key can be used for ROR-scan */
|
||||
bool is_ror_scan;
|
||||
/* Number of ranges in the last checked tree->key */
|
||||
uint n_ranges;
|
||||
};
|
||||
|
||||
class TABLE_READ_PLAN;
|
||||
|
@ -6582,6 +6584,7 @@ check_quick_select(PARAM *param,uint idx,SEL_ARG *tree)
|
|||
param->table->file->primary_key_is_clustered());
|
||||
param->is_ror_scan= !cpk_scan;
|
||||
}
|
||||
param->n_ranges= 0;
|
||||
|
||||
records=check_quick_keys(param,idx,tree,param->min_key,0,param->max_key,0);
|
||||
if (records != HA_POS_ERROR)
|
||||
|
@ -6589,7 +6592,7 @@ check_quick_select(PARAM *param,uint idx,SEL_ARG *tree)
|
|||
param->table->quick_keys.set_bit(key);
|
||||
param->table->quick_rows[key]=records;
|
||||
param->table->quick_key_parts[key]=param->max_key_part+1;
|
||||
|
||||
param->table->quick_n_ranges[key]= param->n_ranges;
|
||||
if (cpk_scan)
|
||||
param->is_ror_scan= TRUE;
|
||||
}
|
||||
|
@ -6725,7 +6728,10 @@ check_quick_keys(PARAM *param,uint idx,SEL_ARG *key_tree,
|
|||
HA_NOSAME &&
|
||||
min_key_length == max_key_length &&
|
||||
!memcmp(param->min_key,param->max_key,min_key_length))
|
||||
{
|
||||
tmp=1; // Max one record
|
||||
param->n_ranges++;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (param->is_ror_scan)
|
||||
|
@ -6745,6 +6751,7 @@ check_quick_keys(PARAM *param,uint idx,SEL_ARG *key_tree,
|
|||
is_key_scan_ror(param, keynr, key_tree->part + 1)))
|
||||
param->is_ror_scan= FALSE;
|
||||
}
|
||||
param->n_ranges++;
|
||||
|
||||
if (tmp_min_flag & GEOM_FLAG)
|
||||
{
|
||||
|
|
|
@ -315,14 +315,16 @@ sp_prepare_func_item(THD* thd, Item **it_addr)
|
|||
*/
|
||||
|
||||
bool
|
||||
sp_eval_expr(THD *thd, Field *result_field, Item *expr_item)
|
||||
sp_eval_expr(THD *thd, Field *result_field, Item **expr_item_ptr)
|
||||
{
|
||||
Item *expr_item;
|
||||
|
||||
DBUG_ENTER("sp_eval_expr");
|
||||
|
||||
if (!expr_item)
|
||||
if (!*expr_item_ptr)
|
||||
DBUG_RETURN(TRUE);
|
||||
|
||||
if (!(expr_item= sp_prepare_func_item(thd, &expr_item)))
|
||||
if (!(expr_item= sp_prepare_func_item(thd, expr_item_ptr)))
|
||||
DBUG_RETURN(TRUE);
|
||||
|
||||
bool err_status= FALSE;
|
||||
|
@ -1284,7 +1286,7 @@ sp_head::execute_function(THD *thd, Item **argp, uint argcount,
|
|||
param_values[i]= Item_cache::get_cache(argp[i]->result_type());
|
||||
param_values[i]->store(argp[i]);
|
||||
|
||||
if (nctx->set_variable(thd, i, param_values[i]))
|
||||
if (nctx->set_variable(thd, i, (struct Item **)&(param_values[i])))
|
||||
{
|
||||
err_status= TRUE;
|
||||
break;
|
||||
|
@ -1490,7 +1492,7 @@ sp_head::execute_procedure(THD *thd, List<Item> *args)
|
|||
Item_null *null_item= new Item_null();
|
||||
|
||||
if (!null_item ||
|
||||
nctx->set_variable(thd, i, null_item))
|
||||
nctx->set_variable(thd, i, (struct Item **)&null_item))
|
||||
{
|
||||
err_status= TRUE;
|
||||
break;
|
||||
|
@ -1498,7 +1500,7 @@ sp_head::execute_procedure(THD *thd, List<Item> *args)
|
|||
}
|
||||
else
|
||||
{
|
||||
if (nctx->set_variable(thd, i, *it_args.ref()))
|
||||
if (nctx->set_variable(thd, i, it_args.ref()))
|
||||
{
|
||||
err_status= TRUE;
|
||||
break;
|
||||
|
@ -1570,7 +1572,7 @@ sp_head::execute_procedure(THD *thd, List<Item> *args)
|
|||
{
|
||||
if (octx->set_variable(thd,
|
||||
((Item_splocal*) arg_item)->get_var_idx(),
|
||||
nctx->get_item(i)))
|
||||
nctx->get_item_addr(i)))
|
||||
{
|
||||
err_status= TRUE;
|
||||
break;
|
||||
|
@ -1582,15 +1584,15 @@ sp_head::execute_procedure(THD *thd, List<Item> *args)
|
|||
|
||||
if (guv)
|
||||
{
|
||||
Item *item= nctx->get_item(i);
|
||||
Item **item= nctx->get_item_addr(i);
|
||||
Item_func_set_user_var *suv;
|
||||
|
||||
suv= new Item_func_set_user_var(guv->get_name(), item);
|
||||
suv= new Item_func_set_user_var(guv->get_name(), *item);
|
||||
/*
|
||||
Item_func_set_user_var is not fixed after construction,
|
||||
call fix_fields().
|
||||
*/
|
||||
if ((err_status= test(!suv || suv->fix_fields(thd, &item) ||
|
||||
if ((err_status= test(!suv || suv->fix_fields(thd, item) ||
|
||||
suv->check() || suv->update())))
|
||||
break;
|
||||
}
|
||||
|
@ -2372,7 +2374,7 @@ sp_instr_set::execute(THD *thd, uint *nextp)
|
|||
int
|
||||
sp_instr_set::exec_core(THD *thd, uint *nextp)
|
||||
{
|
||||
int res= thd->spcont->set_variable(thd, m_offset, m_value);
|
||||
int res= thd->spcont->set_variable(thd, m_offset, &m_value);
|
||||
|
||||
if (res && thd->spcont->found_handler_here())
|
||||
{
|
||||
|
@ -2647,7 +2649,7 @@ sp_instr_freturn::exec_core(THD *thd, uint *nextp)
|
|||
do it in scope of execution the current context/block.
|
||||
*/
|
||||
|
||||
return thd->spcont->set_return_value(thd, m_value);
|
||||
return thd->spcont->set_return_value(thd, &m_value);
|
||||
}
|
||||
|
||||
void
|
||||
|
@ -3091,7 +3093,7 @@ sp_instr_set_case_expr::execute(THD *thd, uint *nextp)
|
|||
int
|
||||
sp_instr_set_case_expr::exec_core(THD *thd, uint *nextp)
|
||||
{
|
||||
int res= thd->spcont->set_case_expr(thd, m_case_expr_id, m_case_expr);
|
||||
int res= thd->spcont->set_case_expr(thd, m_case_expr_id, &m_case_expr);
|
||||
|
||||
if (res &&
|
||||
!thd->spcont->get_case_expr(m_case_expr_id) &&
|
||||
|
@ -3105,7 +3107,7 @@ sp_instr_set_case_expr::exec_core(THD *thd, uint *nextp)
|
|||
Item *null_item= new Item_null();
|
||||
|
||||
if (!null_item ||
|
||||
thd->spcont->set_case_expr(thd, m_case_expr_id, null_item))
|
||||
thd->spcont->set_case_expr(thd, m_case_expr_id, &null_item))
|
||||
{
|
||||
/* If this also failed, we have to abort. */
|
||||
|
||||
|
|
|
@ -1170,6 +1170,6 @@ Item *
|
|||
sp_prepare_func_item(THD* thd, Item **it_addr);
|
||||
|
||||
bool
|
||||
sp_eval_expr(THD *thd, Field *result_field, Item *expr_item);
|
||||
sp_eval_expr(THD *thd, Field *result_field, Item **expr_item_ptr);
|
||||
|
||||
#endif /* _SP_HEAD_H_ */
|
||||
|
|
|
@ -150,7 +150,7 @@ sp_rcontext::init_var_items()
|
|||
|
||||
|
||||
bool
|
||||
sp_rcontext::set_return_value(THD *thd, Item *return_value_item)
|
||||
sp_rcontext::set_return_value(THD *thd, Item **return_value_item)
|
||||
{
|
||||
DBUG_ASSERT(m_return_value_fld);
|
||||
|
||||
|
@ -279,14 +279,14 @@ sp_rcontext::pop_cursors(uint count)
|
|||
|
||||
|
||||
int
|
||||
sp_rcontext::set_variable(THD *thd, uint var_idx, Item *value)
|
||||
sp_rcontext::set_variable(THD *thd, uint var_idx, Item **value)
|
||||
{
|
||||
return set_variable(thd, m_var_table->field[var_idx], value);
|
||||
}
|
||||
|
||||
|
||||
int
|
||||
sp_rcontext::set_variable(THD *thd, Field *field, Item *value)
|
||||
sp_rcontext::set_variable(THD *thd, Field *field, Item **value)
|
||||
{
|
||||
if (!value)
|
||||
{
|
||||
|
@ -478,9 +478,10 @@ sp_rcontext::create_case_expr_holder(THD *thd, Item_result result_type)
|
|||
*/
|
||||
|
||||
int
|
||||
sp_rcontext::set_case_expr(THD *thd, int case_expr_id, Item *case_expr_item)
|
||||
sp_rcontext::set_case_expr(THD *thd, int case_expr_id, Item **case_expr_item_ptr)
|
||||
{
|
||||
if (!(case_expr_item= sp_prepare_func_item(thd, &case_expr_item)))
|
||||
Item *case_expr_item= sp_prepare_func_item(thd, case_expr_item_ptr);
|
||||
if (!case_expr_item)
|
||||
return TRUE;
|
||||
|
||||
if (!m_case_expr_holders[case_expr_id] ||
|
||||
|
@ -542,7 +543,7 @@ bool Select_fetch_into_spvars::send_data(List<Item> &items)
|
|||
*/
|
||||
for (; spvar= spvar_iter++, item= item_iter++; )
|
||||
{
|
||||
if (thd->spcont->set_variable(thd, spvar->offset, item))
|
||||
if (thd->spcont->set_variable(thd, spvar->offset, &item))
|
||||
return TRUE;
|
||||
}
|
||||
return FALSE;
|
||||
|
|
|
@ -91,7 +91,7 @@ class sp_rcontext : public Sql_alloc
|
|||
~sp_rcontext();
|
||||
|
||||
int
|
||||
set_variable(THD *thd, uint var_idx, Item *value);
|
||||
set_variable(THD *thd, uint var_idx, Item **value);
|
||||
|
||||
Item *
|
||||
get_item(uint var_idx);
|
||||
|
@ -100,7 +100,7 @@ class sp_rcontext : public Sql_alloc
|
|||
get_item_addr(uint var_idx);
|
||||
|
||||
bool
|
||||
set_return_value(THD *thd, Item *return_value_item);
|
||||
set_return_value(THD *thd, Item **return_value_item);
|
||||
|
||||
inline bool
|
||||
is_return_value_set() const
|
||||
|
@ -200,7 +200,7 @@ class sp_rcontext : public Sql_alloc
|
|||
*/
|
||||
|
||||
int
|
||||
set_case_expr(THD *thd, int case_expr_id, Item *case_expr_item);
|
||||
set_case_expr(THD *thd, int case_expr_id, Item **case_expr_item_ptr);
|
||||
|
||||
Item *
|
||||
get_case_expr(int case_expr_id);
|
||||
|
@ -254,7 +254,7 @@ private:
|
|||
|
||||
Item_cache *create_case_expr_holder(THD *thd, Item_result result_type);
|
||||
|
||||
int set_variable(THD *thd, Field *field, Item *value);
|
||||
int set_variable(THD *thd, Field *field, Item **value);
|
||||
}; // class sp_rcontext : public Sql_alloc
|
||||
|
||||
|
||||
|
|
|
@ -1925,7 +1925,7 @@ bool select_dumpvar::send_data(List<Item> &items)
|
|||
if ((yy=var_li++))
|
||||
{
|
||||
if (thd->spcont->set_variable(current_thd, yy->get_var_idx(),
|
||||
*it.ref()))
|
||||
it.ref()))
|
||||
DBUG_RETURN(1);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -3377,7 +3377,10 @@ best_access_path(JOIN *join,
|
|||
uint key= keyuse->key;
|
||||
KEY *keyinfo= table->key_info+key;
|
||||
bool ft_key= (keyuse->keypart == FT_KEYPART);
|
||||
uint found_ref_or_null= 0;
|
||||
/* Bitmap of keyparts where the ref access is over 'keypart=const': */
|
||||
key_part_map const_part= 0;
|
||||
/* The or-null keypart in ref-or-null access: */
|
||||
key_part_map ref_or_null_part= 0;
|
||||
|
||||
/* Calculate how many key segments of the current key we can use */
|
||||
start_key= keyuse;
|
||||
|
@ -3389,12 +3392,14 @@ best_access_path(JOIN *join,
|
|||
do
|
||||
{
|
||||
if (!(remaining_tables & keyuse->used_tables) &&
|
||||
!(found_ref_or_null & keyuse->optimize))
|
||||
!(ref_or_null_part && (keyuse->optimize &
|
||||
KEY_OPTIMIZE_REF_OR_NULL)))
|
||||
{
|
||||
found_part|= keyuse->keypart_map;
|
||||
double tmp= prev_record_reads(join,
|
||||
(found_ref |
|
||||
keyuse->used_tables));
|
||||
if (!(keyuse->used_tables & ~join->const_table_map))
|
||||
const_part|= keyuse->keypart_map;
|
||||
double tmp= prev_record_reads(join, (found_ref |
|
||||
keyuse->used_tables));
|
||||
if (tmp < best_prev_record_reads)
|
||||
{
|
||||
best_part_found_ref= keyuse->used_tables;
|
||||
|
@ -3406,8 +3411,8 @@ best_access_path(JOIN *join,
|
|||
If there is one 'key_column IS NULL' expression, we can
|
||||
use this ref_or_null optimisation of this field
|
||||
*/
|
||||
found_ref_or_null|= (keyuse->optimize &
|
||||
KEY_OPTIMIZE_REF_OR_NULL);
|
||||
if (keyuse->optimize & KEY_OPTIMIZE_REF_OR_NULL)
|
||||
ref_or_null_part |= keyuse->keypart_map;
|
||||
}
|
||||
keyuse++;
|
||||
} while (keyuse->table == table && keyuse->key == key &&
|
||||
|
@ -3443,7 +3448,7 @@ best_access_path(JOIN *join,
|
|||
Check if we found full key
|
||||
*/
|
||||
if (found_part == PREV_BITS(uint,keyinfo->key_parts) &&
|
||||
!found_ref_or_null)
|
||||
!ref_or_null_part)
|
||||
{ /* use eq key */
|
||||
max_key_part= (uint) ~0;
|
||||
if ((keyinfo->flags & (HA_NOSAME | HA_NULL_PART_KEY)) == HA_NOSAME)
|
||||
|
@ -3455,6 +3460,23 @@ best_access_path(JOIN *join,
|
|||
{
|
||||
if (!found_ref)
|
||||
{ /* We found a const key */
|
||||
/*
|
||||
ReuseRangeEstimateForRef-1:
|
||||
We get here if we've found a ref(const) (c_i are constants):
|
||||
"(keypart1=c1) AND ... AND (keypartN=cN)" [ref_const_cond]
|
||||
|
||||
If range optimizer was able to construct a "range"
|
||||
access on this index, then its condition "quick_cond" was
|
||||
eqivalent to ref_const_cond (*), and we can re-use E(#rows)
|
||||
from the range optimizer.
|
||||
|
||||
Proof of (*): By properties of range and ref optimizers
|
||||
quick_cond will be equal or tighther than ref_const_cond.
|
||||
ref_const_cond already covers "smallest" possible interval -
|
||||
a singlepoint interval over all keyparts. Therefore,
|
||||
quick_cond is equivalent to ref_const_cond (if it was an
|
||||
empty interval we wouldn't have got here).
|
||||
*/
|
||||
if (table->quick_keys.is_set(key))
|
||||
records= (double) table->quick_rows[key];
|
||||
else
|
||||
|
@ -3475,6 +3497,23 @@ best_access_path(JOIN *join,
|
|||
if (records < 2.0)
|
||||
records=2.0; /* Can't be as good as a unique */
|
||||
}
|
||||
/*
|
||||
ReuseRangeEstimateForRef-2: We get here if we could not reuse
|
||||
E(#rows) from range optimizer. Make another try:
|
||||
|
||||
If range optimizer produced E(#rows) for a prefix of the ref
|
||||
access we're considering, and that E(#rows) is lower then our
|
||||
current estimate, make an adjustment. The criteria of when we
|
||||
can make an adjustment is a special case of the criteria used
|
||||
in ReuseRangeEstimateForRef-3.
|
||||
*/
|
||||
if (table->quick_keys.is_set(key) &&
|
||||
const_part & (1 << table->quick_key_parts[key]) &&
|
||||
table->quick_n_ranges[key] == 1 &&
|
||||
records > (double) table->quick_rows[key])
|
||||
{
|
||||
records= (double) table->quick_rows[key];
|
||||
}
|
||||
}
|
||||
/* Limit the number of matched rows */
|
||||
tmp= records;
|
||||
|
@ -3503,12 +3542,50 @@ best_access_path(JOIN *join,
|
|||
{
|
||||
max_key_part= max_part_bit(found_part);
|
||||
/*
|
||||
Check if quick_range could determinate how many rows we
|
||||
will match
|
||||
ReuseRangeEstimateForRef-3:
|
||||
We're now considering a ref[or_null] access via
|
||||
(t.keypart1=e1 AND ... AND t.keypartK=eK) [ OR
|
||||
(same-as-above but with one cond replaced
|
||||
with "t.keypart_i IS NULL")] (**)
|
||||
|
||||
Try re-using E(#rows) from "range" optimizer:
|
||||
We can do so if "range" optimizer used the same intervals as
|
||||
in (**). The intervals used by range optimizer may be not
|
||||
available at this point (as "range" access might have choosen to
|
||||
create quick select over another index), so we can't compare
|
||||
them to (**). We'll make indirect judgements instead.
|
||||
The sufficient conditions for re-use are:
|
||||
(C1) All e_i in (**) are constants, i.e. found_ref==FALSE. (if
|
||||
this is not satisfied we have no way to know which ranges
|
||||
will be actually scanned by 'ref' until we execute the
|
||||
join)
|
||||
(C2) max #key parts in 'range' access == K == max_key_part (this
|
||||
is apparently a necessary requirement)
|
||||
|
||||
We also have a property that "range optimizer produces equal or
|
||||
tighter set of scan intervals than ref(const) optimizer". Each
|
||||
of the intervals in (**) are "tightest possible" intervals when
|
||||
one limits itself to using keyparts 1..K (which we do in #2).
|
||||
From here it follows that range access used either one, or
|
||||
both of the (I1) and (I2) intervals:
|
||||
|
||||
(t.keypart1=c1 AND ... AND t.keypartK=eK) (I1)
|
||||
(same-as-above but with one cond replaced
|
||||
with "t.keypart_i IS NULL") (I2)
|
||||
|
||||
The remaining part is to exclude the situation where range
|
||||
optimizer used one interval while we're considering
|
||||
ref-or-null and looking for estimate for two intervals. This
|
||||
is done by last limitation:
|
||||
|
||||
(C3) "range optimizer used (have ref_or_null?2:1) intervals"
|
||||
*/
|
||||
if (table->quick_keys.is_set(key) &&
|
||||
table->quick_key_parts[key] == max_key_part)
|
||||
if (table->quick_keys.is_set(key) && !found_ref && //(C1)
|
||||
table->quick_key_parts[key] == max_key_part && //(C2)
|
||||
table->quick_n_ranges[key] == 1+test(ref_or_null_part)) //(C3)
|
||||
{
|
||||
tmp= records= (double) table->quick_rows[key];
|
||||
}
|
||||
else
|
||||
{
|
||||
/* Check if we have statistic about the distribution */
|
||||
|
@ -3552,21 +3629,37 @@ best_access_path(JOIN *join,
|
|||
}
|
||||
records = (ulong) tmp;
|
||||
}
|
||||
/*
|
||||
If quick_select was used on a part of this key, we know
|
||||
the maximum number of rows that the key can match.
|
||||
*/
|
||||
if (table->quick_keys.is_set(key) &&
|
||||
table->quick_key_parts[key] <= max_key_part &&
|
||||
records > (double) table->quick_rows[key])
|
||||
tmp= records= (double) table->quick_rows[key];
|
||||
else if (found_ref_or_null)
|
||||
|
||||
if (ref_or_null_part)
|
||||
{
|
||||
/* We need to do two key searches to find key */
|
||||
tmp *= 2.0;
|
||||
records *= 2.0;
|
||||
}
|
||||
|
||||
/*
|
||||
ReuseRangeEstimateForRef-4: We get here if we could not reuse
|
||||
E(#rows) from range optimizer. Make another try:
|
||||
|
||||
If range optimizer produced E(#rows) for a prefix of the ref
|
||||
access we're considering, and that E(#rows) is lower then our
|
||||
current estimate, make the adjustment.
|
||||
|
||||
The decision whether we can re-use the estimate from the range
|
||||
optimizer is the same as in ReuseRangeEstimateForRef-3,
|
||||
applied to first table->quick_key_parts[key] key parts.
|
||||
*/
|
||||
if (table->quick_keys.is_set(key) &&
|
||||
table->quick_key_parts[key] <= max_key_part &&
|
||||
const_part & (1 << table->quick_key_parts[key]) &&
|
||||
table->quick_n_ranges[key] == 1 + test(ref_or_null_part &
|
||||
const_part) &&
|
||||
records > (double) table->quick_rows[key])
|
||||
{
|
||||
tmp= records= (double) table->quick_rows[key];
|
||||
}
|
||||
}
|
||||
|
||||
/* Limit the number of matched rows */
|
||||
set_if_smaller(tmp, (double) thd->variables.max_seeks_for_key);
|
||||
if (table->used_keys.is_set(key))
|
||||
|
@ -4382,344 +4475,11 @@ find_best(JOIN *join,table_map rest_tables,uint idx,double record_count,
|
|||
if ((rest_tables & real_table_bit) && !(rest_tables & s->dependent) &&
|
||||
(!idx|| !check_interleaving_with_nj(join->positions[idx-1].table, s)))
|
||||
{
|
||||
double best,best_time,records;
|
||||
best=best_time=records=DBL_MAX;
|
||||
KEYUSE *best_key=0;
|
||||
uint best_max_key_part=0;
|
||||
my_bool found_constraint= 0;
|
||||
|
||||
if (s->keyuse)
|
||||
{ /* Use key if possible */
|
||||
TABLE *table=s->table;
|
||||
KEYUSE *keyuse,*start_key=0;
|
||||
double best_records=DBL_MAX;
|
||||
uint max_key_part=0;
|
||||
|
||||
/* Test how we can use keys */
|
||||
rec= s->records/MATCHING_ROWS_IN_OTHER_TABLE; // Assumed records/key
|
||||
for (keyuse=s->keyuse ; keyuse->table == table ;)
|
||||
{
|
||||
key_part_map found_part=0;
|
||||
table_map found_ref=0;
|
||||
uint key=keyuse->key;
|
||||
KEY *keyinfo=table->key_info+key;
|
||||
bool ft_key=(keyuse->keypart == FT_KEYPART);
|
||||
uint found_ref_or_null= 0;
|
||||
|
||||
/* Calculate how many key segments of the current key we can use */
|
||||
start_key=keyuse;
|
||||
do
|
||||
{
|
||||
uint keypart=keyuse->keypart;
|
||||
table_map best_part_found_ref= 0;
|
||||
double best_prev_record_reads= DBL_MAX;
|
||||
do
|
||||
{
|
||||
if (!(rest_tables & keyuse->used_tables) &&
|
||||
!(found_ref_or_null & keyuse->optimize))
|
||||
{
|
||||
found_part|=keyuse->keypart_map;
|
||||
double tmp= prev_record_reads(join,
|
||||
(found_ref |
|
||||
keyuse->used_tables));
|
||||
if (tmp < best_prev_record_reads)
|
||||
{
|
||||
best_part_found_ref= keyuse->used_tables;
|
||||
best_prev_record_reads= tmp;
|
||||
}
|
||||
if (rec > keyuse->ref_table_rows)
|
||||
rec= keyuse->ref_table_rows;
|
||||
/*
|
||||
If there is one 'key_column IS NULL' expression, we can
|
||||
use this ref_or_null optimisation of this field
|
||||
*/
|
||||
found_ref_or_null|= (keyuse->optimize &
|
||||
KEY_OPTIMIZE_REF_OR_NULL);
|
||||
}
|
||||
keyuse++;
|
||||
} while (keyuse->table == table && keyuse->key == key &&
|
||||
keyuse->keypart == keypart);
|
||||
found_ref|= best_part_found_ref;
|
||||
} while (keyuse->table == table && keyuse->key == key);
|
||||
|
||||
/*
|
||||
Assume that that each key matches a proportional part of table.
|
||||
*/
|
||||
if (!found_part && !ft_key)
|
||||
continue; // Nothing usable found
|
||||
if (rec < MATCHING_ROWS_IN_OTHER_TABLE)
|
||||
rec= MATCHING_ROWS_IN_OTHER_TABLE; // Fix for small tables
|
||||
|
||||
/*
|
||||
ft-keys require special treatment
|
||||
*/
|
||||
if (ft_key)
|
||||
{
|
||||
/*
|
||||
Really, there should be records=0.0 (yes!)
|
||||
but 1.0 would be probably safer
|
||||
*/
|
||||
tmp=prev_record_reads(join,found_ref);
|
||||
records=1.0;
|
||||
}
|
||||
else
|
||||
{
|
||||
found_constraint= 1;
|
||||
/*
|
||||
Check if we found full key
|
||||
*/
|
||||
if (found_part == PREV_BITS(uint,keyinfo->key_parts) &&
|
||||
!found_ref_or_null)
|
||||
{ /* use eq key */
|
||||
max_key_part= (uint) ~0;
|
||||
if ((keyinfo->flags & (HA_NOSAME | HA_NULL_PART_KEY |
|
||||
HA_END_SPACE_KEY)) == HA_NOSAME)
|
||||
{
|
||||
tmp=prev_record_reads(join,found_ref);
|
||||
records=1.0;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (!found_ref)
|
||||
{ // We found a const key
|
||||
if (table->quick_keys.is_set(key))
|
||||
records= (double) table->quick_rows[key];
|
||||
else
|
||||
{
|
||||
/* quick_range couldn't use key! */
|
||||
records= (double) s->records/rec;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (!(records=keyinfo->rec_per_key[keyinfo->key_parts-1]))
|
||||
{ // Prefere longer keys
|
||||
records=
|
||||
((double) s->records / (double) rec *
|
||||
(1.0 +
|
||||
((double) (table->s->max_key_length-keyinfo->key_length) /
|
||||
(double) table->s->max_key_length)));
|
||||
if (records < 2.0)
|
||||
records=2.0; // Can't be as good as a unique
|
||||
}
|
||||
}
|
||||
/* Limit the number of matched rows */
|
||||
tmp= records;
|
||||
set_if_smaller(tmp, (double) thd->variables.max_seeks_for_key);
|
||||
if (table->used_keys.is_set(key))
|
||||
{
|
||||
/* we can use only index tree */
|
||||
uint keys_per_block= table->file->block_size/2/
|
||||
(keyinfo->key_length+table->file->ref_length)+1;
|
||||
tmp=record_count*(tmp+keys_per_block-1)/keys_per_block;
|
||||
}
|
||||
else
|
||||
tmp=record_count*min(tmp,s->worst_seeks);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
/*
|
||||
Use as much key-parts as possible and a uniq key is better
|
||||
than a not unique key
|
||||
Set tmp to (previous record count) * (records / combination)
|
||||
*/
|
||||
if ((found_part & 1) &&
|
||||
(!(table->file->index_flags(key,0,0) & HA_ONLY_WHOLE_INDEX) ||
|
||||
found_part == PREV_BITS(uint,keyinfo->key_parts)))
|
||||
{
|
||||
max_key_part=max_part_bit(found_part);
|
||||
/*
|
||||
Check if quick_range could determinate how many rows we
|
||||
will match
|
||||
*/
|
||||
if (table->quick_keys.is_set(key) &&
|
||||
table->quick_key_parts[key] == max_key_part)
|
||||
tmp=records= (double) table->quick_rows[key];
|
||||
else
|
||||
{
|
||||
/* Check if we have statistic about the distribution */
|
||||
if ((records=keyinfo->rec_per_key[max_key_part-1]))
|
||||
tmp=records;
|
||||
else
|
||||
{
|
||||
/*
|
||||
Assume that the first key part matches 1% of the file
|
||||
and that the whole key matches 10 (duplicates) or 1
|
||||
(unique) records.
|
||||
Assume also that more key matches proportionally more
|
||||
records
|
||||
This gives the formula:
|
||||
records= (x * (b-a) + a*c-b)/(c-1)
|
||||
|
||||
b = records matched by whole key
|
||||
a = records matched by first key part (10% of all records?)
|
||||
c = number of key parts in key
|
||||
x = used key parts (1 <= x <= c)
|
||||
*/
|
||||
double rec_per_key;
|
||||
rec_per_key= keyinfo->rec_per_key[keyinfo->key_parts-1] ?
|
||||
(double) keyinfo->rec_per_key[keyinfo->key_parts-1] :
|
||||
(double) s->records/rec+1;
|
||||
if (!s->records)
|
||||
tmp=0;
|
||||
else if (rec_per_key/(double) s->records >= 0.01)
|
||||
tmp=rec_per_key;
|
||||
else
|
||||
{
|
||||
double a=s->records*0.01;
|
||||
tmp=(max_key_part * (rec_per_key - a) +
|
||||
a*keyinfo->key_parts - rec_per_key)/
|
||||
(keyinfo->key_parts-1);
|
||||
set_if_bigger(tmp,1.0);
|
||||
}
|
||||
records=(ulong) tmp;
|
||||
}
|
||||
/*
|
||||
If quick_select was used on a part of this key, we know
|
||||
the maximum number of rows that the key can match.
|
||||
*/
|
||||
if (table->quick_keys.is_set(key) &&
|
||||
table->quick_key_parts[key] <= max_key_part &&
|
||||
records > (double) table->quick_rows[key])
|
||||
tmp= records= (double) table->quick_rows[key];
|
||||
else if (found_ref_or_null)
|
||||
{
|
||||
/* We need to do two key searches to find key */
|
||||
tmp*= 2.0;
|
||||
records*= 2.0;
|
||||
}
|
||||
}
|
||||
/* Limit the number of matched rows */
|
||||
set_if_smaller(tmp, (double) thd->variables.max_seeks_for_key);
|
||||
if (table->used_keys.is_set(key))
|
||||
{
|
||||
/* we can use only index tree */
|
||||
uint keys_per_block= table->file->block_size/2/
|
||||
(keyinfo->key_length+table->file->ref_length)+1;
|
||||
tmp=record_count*(tmp+keys_per_block-1)/keys_per_block;
|
||||
}
|
||||
else
|
||||
tmp=record_count*min(tmp,s->worst_seeks);
|
||||
}
|
||||
else
|
||||
tmp=best_time; // Do nothing
|
||||
}
|
||||
} /* not ft_key */
|
||||
if (tmp < best_time - records/(double) TIME_FOR_COMPARE)
|
||||
{
|
||||
best_time=tmp + records/(double) TIME_FOR_COMPARE;
|
||||
best=tmp;
|
||||
best_records=records;
|
||||
best_key=start_key;
|
||||
best_max_key_part=max_key_part;
|
||||
}
|
||||
}
|
||||
records=best_records;
|
||||
}
|
||||
|
||||
/*
|
||||
Don't test table scan if it can't be better.
|
||||
Prefer key lookup if we would use the same key for scanning.
|
||||
|
||||
Don't do a table scan on InnoDB tables, if we can read the used
|
||||
parts of the row from any of the used index.
|
||||
This is because table scans uses index and we would not win
|
||||
anything by using a table scan.
|
||||
(see comment in best_access_path() for more details on the below
|
||||
condition)
|
||||
*/
|
||||
if ((records >= s->found_records || best > s->read_time) &&
|
||||
!(s->quick && best_key && s->quick->index == best_key->key &&
|
||||
best_max_key_part >= s->table->quick_key_parts[best_key->key]) &&
|
||||
!((s->table->file->table_flags() & HA_TABLE_SCAN_ON_INDEX) &&
|
||||
! s->table->used_keys.is_clear_all() && best_key) &&
|
||||
!(s->table->force_index && best_key && !s->quick))
|
||||
{ // Check full join
|
||||
ha_rows rnd_records= s->found_records;
|
||||
/*
|
||||
If there is a restriction on the table, assume that 25% of the
|
||||
rows can be skipped on next part.
|
||||
This is to force tables that this table depends on before this
|
||||
table
|
||||
*/
|
||||
if (found_constraint)
|
||||
rnd_records-= rnd_records/4;
|
||||
|
||||
/*
|
||||
Range optimizer never proposes a RANGE if it isn't better
|
||||
than FULL: so if RANGE is present, it's always preferred to FULL.
|
||||
Here we estimate its cost.
|
||||
*/
|
||||
if (s->quick)
|
||||
{
|
||||
/*
|
||||
For each record we:
|
||||
- read record range through 'quick'
|
||||
- skip rows which does not satisfy WHERE constraints
|
||||
*/
|
||||
tmp= record_count *
|
||||
(s->quick->read_time +
|
||||
(s->found_records - rnd_records)/(double) TIME_FOR_COMPARE);
|
||||
}
|
||||
else
|
||||
{
|
||||
/* Estimate cost of reading table. */
|
||||
tmp= s->table->file->scan_time();
|
||||
if (s->table->map & join->outer_join) // Can't use join cache
|
||||
{
|
||||
/*
|
||||
For each record we have to:
|
||||
- read the whole table record
|
||||
- skip rows which does not satisfy join condition
|
||||
*/
|
||||
tmp= record_count *
|
||||
(tmp +
|
||||
(s->records - rnd_records)/(double) TIME_FOR_COMPARE);
|
||||
}
|
||||
else
|
||||
{
|
||||
/* We read the table as many times as join buffer becomes full. */
|
||||
tmp*= (1.0 + floor((double) cache_record_length(join,idx) *
|
||||
record_count /
|
||||
(double) thd->variables.join_buff_size));
|
||||
/*
|
||||
We don't make full cartesian product between rows in the scanned
|
||||
table and existing records because we skip all rows from the
|
||||
scanned table, which does not satisfy join condition when
|
||||
we read the table (see flush_cached_records for details). Here we
|
||||
take into account cost to read and skip these records.
|
||||
*/
|
||||
tmp+= (s->records - rnd_records)/(double) TIME_FOR_COMPARE;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
We estimate the cost of evaluating WHERE clause for found records
|
||||
as record_count * rnd_records / TIME_FOR_COMPARE. This cost plus
|
||||
tmp give us total cost of using TABLE SCAN
|
||||
*/
|
||||
if (best == DBL_MAX ||
|
||||
(tmp + record_count/(double) TIME_FOR_COMPARE*rnd_records <
|
||||
best + record_count/(double) TIME_FOR_COMPARE*records))
|
||||
{
|
||||
/*
|
||||
If the table has a range (s->quick is set) make_join_select()
|
||||
will ensure that this will be used
|
||||
*/
|
||||
best=tmp;
|
||||
records= rows2double(rnd_records);
|
||||
best_key=0;
|
||||
}
|
||||
}
|
||||
join->positions[idx].records_read= records;
|
||||
join->positions[idx].key=best_key;
|
||||
join->positions[idx].table= s;
|
||||
if (!best_key && idx == join->const_tables &&
|
||||
s->table == join->sort_by_table &&
|
||||
join->unit->select_limit_cnt >= records)
|
||||
join->sort_by_table= (TABLE*) 1; // Must use temporary table
|
||||
|
||||
double records, best;
|
||||
best_access_path(join, s, thd, rest_tables, idx, record_count,
|
||||
read_time);
|
||||
records= join->positions[idx].records_read;
|
||||
best= join->positions[idx].read_time;
|
||||
/*
|
||||
Go to the next level only if there hasn't been a better key on
|
||||
this level! This will cut down the search for a lot simple cases!
|
||||
|
|
|
@ -5105,7 +5105,9 @@ bool mysql_alter_table(THD *thd,char *new_db, char *new_name,
|
|||
ha_resolve_storage_engine_name(old_db_type),
|
||||
ha_resolve_storage_engine_name(new_db_type)));
|
||||
if (ha_check_storage_engine_flag(old_db_type, HTON_ALTER_NOT_SUPPORTED) ||
|
||||
ha_check_storage_engine_flag(new_db_type, HTON_ALTER_NOT_SUPPORTED))
|
||||
ha_check_storage_engine_flag(new_db_type, HTON_ALTER_NOT_SUPPORTED) ||
|
||||
(old_db_type != new_db_type &&
|
||||
ha_check_storage_engine_flag(new_db_type, HTON_ALTER_CANNOT_CREATE)))
|
||||
{
|
||||
DBUG_PRINT("info", ("doesn't support alter"));
|
||||
my_error(ER_ILLEGAL_HA, MYF(0), table_name);
|
||||
|
|
|
@ -264,6 +264,7 @@ struct st_table {
|
|||
ha_rows quick_rows[MAX_KEY];
|
||||
key_part_map const_key_parts[MAX_KEY];
|
||||
uint quick_key_parts[MAX_KEY];
|
||||
uint quick_n_ranges[MAX_KEY];
|
||||
|
||||
/*
|
||||
If this table has TIMESTAMP field with auto-set property (pointed by
|
||||
|
|
|
@ -67,7 +67,7 @@ handlerton blackhole_hton= {
|
|||
NULL, /* Alter table flags */
|
||||
NULL, /* Alter Tablespace */
|
||||
NULL, /* Fill FILES table */
|
||||
HTON_CAN_RECREATE,
|
||||
HTON_CAN_RECREATE | HTON_ALTER_CANNOT_CREATE,
|
||||
NULL, /* binlog_func */
|
||||
NULL, /* binlog_log_query */
|
||||
NULL /* release_temporary_latches */
|
||||
|
|
Loading…
Add table
Reference in a new issue