128 lines
4.0 KiB
Plaintext
128 lines
4.0 KiB
Plaintext
drop table if exists t1,t2;
|
|
# Tests for MyX + partitioning
|
|
#
|
|
# MyX Issue #70: Server crashes in Rdb_key_def::get_primary_key_tuple
|
|
#
|
|
CREATE TABLE t1 (pk INT PRIMARY KEY, f1 INT, f2 INT, KEY(f2)) ENGINE=XEngine
|
|
PARTITION BY HASH(pk) PARTITIONS 2;
|
|
INSERT INTO t1 VALUES (1, 6, NULL), (2, NULL, 1);
|
|
CREATE TABLE t2 (pk INT PRIMARY KEY, f1 INT) ENGINE=XEngine;
|
|
INSERT INTO t2 VALUES (1, 1), (2, 1);
|
|
SELECT f1 FROM t1 WHERE f2 = ( SELECT f1 FROM t2 WHERE pk = 2 );
|
|
f1
|
|
NULL
|
|
drop table t1,t2;
|
|
#
|
|
# Issue#105: key_info[secondary_key].actual_key_parts does not include primary key on partitioned tables
|
|
#
|
|
CREATE TABLE t1 (
|
|
id INT PRIMARY KEY,
|
|
a set ('a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z') CHARACTER SET utf8,
|
|
b set ('a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z') CHARACTER SET utf8 default null,
|
|
c set ('a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z') CHARACTER SET utf8 not null,
|
|
INDEX (a),
|
|
INDEX (b),
|
|
INDEX (c)
|
|
) ENGINE=XEngine PARTITION BY key (id) partitions 2;
|
|
INSERT INTO t1 (id, b) VALUES (28, 3);
|
|
Warnings:
|
|
Warning 1364 Field 'c' doesn't have a default value
|
|
UPDATE t1 SET id=8 WHERE c < 8 LIMIT 1;
|
|
check table t1;
|
|
Table Op Msg_type Msg_text
|
|
test.t1 check status OK
|
|
drop table t1;
|
|
#
|
|
# Issue #105, another testcase
|
|
#
|
|
create table t1 (
|
|
pk int primary key,
|
|
col1 int,
|
|
col2 int,
|
|
key (col1) comment 'cf_issue105'
|
|
) engine=xengine partition by hash(pk) partitions 2;
|
|
insert into t1 values (1,10,10);
|
|
insert into t1 values (2,10,10);
|
|
insert into t1 values (11,20,20);
|
|
insert into t1 values (12,20,20);
|
|
explain select * from t1 force index(col1) where col1=10;
|
|
id select_type table partitions type possible_keys key key_len ref rows filtered Extra
|
|
1 SIMPLE t1 p0,p1 ref col1 col1 5 const 2000 100.00 NULL
|
|
Warnings:
|
|
Note 1003 /* select#1 */ select `test`.`t1`.`pk` AS `pk`,`test`.`t1`.`col1` AS `col1`,`test`.`t1`.`col2` AS `col2` from `test`.`t1` FORCE INDEX (`col1`) where (`test`.`t1`.`col1` = 10)
|
|
select * from t1 force index(col1) where col1=10;
|
|
pk col1 col2
|
|
2 10 10
|
|
1 10 10
|
|
select * from t1 use index () where col1=10;
|
|
pk col1 col2
|
|
2 10 10
|
|
1 10 10
|
|
drop table t1;
|
|
#
|
|
# Issue #108: Index-only scans do not work for partitioned tables and extended keys
|
|
#
|
|
create table t1 (
|
|
pk int primary key,
|
|
col1 int,
|
|
col2 int,
|
|
key (col1)
|
|
) engine=xengine partition by hash(pk) partitions 2;
|
|
insert into t1 values (1,10,10);
|
|
insert into t1 values (2,10,10);
|
|
insert into t1 values (11,20,20);
|
|
insert into t1 values (12,20,20);
|
|
# The following must use "Using index"
|
|
explain select pk from t1 force index(col1) where col1=10;
|
|
id select_type table partitions type possible_keys key key_len ref rows filtered Extra
|
|
1 SIMPLE t1 p0,p1 ref col1 col1 5 const 2000 100.00 NULL
|
|
Warnings:
|
|
Note 1003 /* select#1 */ select `test`.`t1`.`pk` AS `pk` from `test`.`t1` FORCE INDEX (`col1`) where (`test`.`t1`.`col1` = 10)
|
|
drop table t1;
|
|
#
|
|
# Issue #214: subqueries cause crash
|
|
#
|
|
create TABLE t1(a int,b int,c int,primary key(a,b))
|
|
partition by list (b*a) (partition x1 values in (1) tablespace ts1,
|
|
partition x2 values in (3,11,5,7) tablespace ts2,
|
|
partition x3 values in (16,8,5+19,70-43) tablespace ts3);
|
|
create table t2(b binary(2));
|
|
set session optimizer_switch=5;
|
|
insert into t1(a,b) values(1,7);
|
|
select a from t1 where a in (select a from t1 where a in (select b from t2));
|
|
a
|
|
drop table t1, t2;
|
|
#
|
|
# Issue #260: altering name to invalid value leaves table unaccessible
|
|
#
|
|
CREATE TABLE t1 (c1 INT NOT NULL, c2 CHAR(5)) PARTITION BY HASH(c1) PARTITIONS 4;
|
|
INSERT INTO t1 VALUES(1,'a');
|
|
RENAME TABLE t1 TO db3.t3;
|
|
ERROR HY000: Error on rename of './test/t1' to './db3/t3' (errno: 122 - Internal (unspecified) error in handler)
|
|
SELECT * FROM t1;
|
|
c1 c2
|
|
1 a
|
|
SHOW TABLES;
|
|
Tables_in_test
|
|
t1
|
|
RENAME TABLE t1 TO test.t3;
|
|
SELECT * FROM t3;
|
|
c1 c2
|
|
1 a
|
|
SHOW TABLES;
|
|
Tables_in_test
|
|
t3
|
|
CREATE DATABASE db3;
|
|
USE test;
|
|
RENAME TABLE t3 to db3.t2;
|
|
USE db3;
|
|
SELECT * FROM t2;
|
|
c1 c2
|
|
1 a
|
|
SHOW TABLES;
|
|
Tables_in_db3
|
|
t2
|
|
DROP TABLE t2;
|
|
use test;
|
|
DROP DATABASE db3;
|