2011-07-02 22:08:51 +02:00
|
|
|
set global default_storage_engine='innodb';
|
|
|
|
set session default_storage_engine='innodb';
|
2010-03-04 12:29:22 +01:00
|
|
|
drop table if exists t1, t2;
|
|
|
|
#
|
2012-02-22 23:13:36 +01:00
|
|
|
# Bug#13694811: THE OPTIMIZER WRONGLY USES THE FIRST
|
|
|
|
# INNODB PARTITION STATISTICS
|
|
|
|
#
|
|
|
|
CREATE TABLE t1
|
|
|
|
(a INT,
|
|
|
|
b varchar(64),
|
|
|
|
PRIMARY KEY (a),
|
|
|
|
KEY (b))
|
|
|
|
ENGINE = InnoDB
|
|
|
|
PARTITION BY RANGE (a)
|
|
|
|
SUBPARTITION BY HASH (a) SUBPARTITIONS 10
|
|
|
|
(PARTITION pNeg VALUES LESS THAN (0),
|
|
|
|
PARTITION p0 VALUES LESS THAN (1000),
|
|
|
|
PARTITION pMAX VALUES LESS THAN MAXVALUE);
|
|
|
|
# Only one row in the first 10 subpartitions
|
|
|
|
INSERT INTO t1 VALUES (-1, 'Only negative pk value');
|
|
|
|
INSERT INTO t1 VALUES (0, 'Mod Zero'), (1, 'One'), (2, 'Two'), (3, 'Three'),
|
|
|
|
(10, 'Zero'), (11, 'Mod One'), (12, 'Mod Two'), (13, 'Mod Three'),
|
|
|
|
(20, '0'), (21, '1'), (22, '2'), (23, '3'),
|
|
|
|
(4, '4'), (5, '5'), (6, '6'), (7, '7'), (8, '8'), (9, '9');
|
|
|
|
INSERT INTO t1 SELECT a + 30, b FROM t1 WHERE a >= 0;
|
|
|
|
ANALYZE TABLE t1;
|
|
|
|
Table Op Msg_type Msg_text
|
|
|
|
test.t1 analyze status OK
|
|
|
|
EXPLAIN SELECT b FROM t1 WHERE b between 'L' and 'N' AND a > -100;
|
|
|
|
id select_type table type possible_keys key key_len ref rows Extra
|
|
|
|
1 SIMPLE t1 range PRIMARY,b b 67 NULL 18 Using where; Using index
|
|
|
|
DROP TABLE t1;
|
|
|
|
#
|
2013-07-17 18:51:12 +02:00
|
|
|
# Bug#13007154: Crash in keys_to_use_for_scanning with ORDER BY
|
|
|
|
# and PARTITIONING
|
|
|
|
#
|
|
|
|
CREATE TABLE t1 (a INT, KEY(a))
|
|
|
|
ENGINE = InnoDB
|
|
|
|
PARTITION BY KEY (a) PARTITIONS 1;
|
|
|
|
SELECT 1 FROM t1 WHERE a > (SELECT LAST_INSERT_ID() FROM t1 LIMIT 0)
|
|
|
|
ORDER BY a;
|
|
|
|
1
|
|
|
|
DROP TABLE t1;
|
|
|
|
#
|
2010-09-16 11:01:06 +02:00
|
|
|
# Bug#56287: crash when using Partition datetime in sub in query
|
|
|
|
#
|
|
|
|
CREATE TABLE t1
|
|
|
|
(c1 bigint(20) unsigned NOT NULL AUTO_INCREMENT,
|
|
|
|
c2 varchar(40) not null default '',
|
|
|
|
c3 datetime not NULL,
|
|
|
|
PRIMARY KEY (c1,c3),
|
|
|
|
KEY partidx(c3))
|
|
|
|
ENGINE=InnoDB
|
|
|
|
PARTITION BY RANGE (TO_DAYS(c3))
|
|
|
|
(PARTITION p200912 VALUES LESS THAN (to_days('2010-01-01')),
|
|
|
|
PARTITION p201103 VALUES LESS THAN (to_days('2011-04-01')),
|
|
|
|
PARTITION p201912 VALUES LESS THAN MAXVALUE);
|
|
|
|
insert into t1(c2,c3) values ("Test row",'2010-01-01 00:00:00');
|
|
|
|
SELECT PARTITION_NAME, TABLE_ROWS FROM INFORMATION_SCHEMA.PARTITIONS WHERE TABLE_NAME = 't1' AND TABLE_SCHEMA = 'test';
|
|
|
|
PARTITION_NAME TABLE_ROWS
|
|
|
|
p200912 0
|
|
|
|
p201103 1
|
|
|
|
p201912 0
|
|
|
|
SELECT count(*) FROM t1 p where c3 in
|
2013-07-10 10:12:27 +02:00
|
|
|
(select c3 from t1 t where t.c3 < timestamp '2011-04-26 19:19:44'
|
|
|
|
and t.c3 > timestamp '2011-04-26 19:18:44') ;
|
2010-09-16 11:01:06 +02:00
|
|
|
count(*)
|
|
|
|
0
|
|
|
|
DROP TABLE t1;
|
|
|
|
#
|
2010-08-20 19:15:48 +02:00
|
|
|
# Bug#54747: Deadlock between REORGANIZE PARTITION and
|
|
|
|
# SELECT is not detected
|
|
|
|
#
|
2013-07-17 18:51:12 +02:00
|
|
|
SET @old_innodb_thread_concurrency := @@innodb_thread_concurrency;
|
2012-08-17 15:46:34 +02:00
|
|
|
SET @old_innodb_thread_sleep_delay := @@innodb_thread_sleep_delay;
|
2010-08-20 19:15:48 +02:00
|
|
|
SET GLOBAL innodb_thread_concurrency = 1;
|
|
|
|
CREATE TABLE t1
|
|
|
|
(user_num BIGINT,
|
|
|
|
hours SMALLINT,
|
|
|
|
KEY user_num (user_num))
|
|
|
|
ENGINE = InnoDB
|
|
|
|
PARTITION BY RANGE COLUMNS (hours)
|
|
|
|
(PARTITION hour_003 VALUES LESS THAN (3),
|
|
|
|
PARTITION hour_004 VALUES LESS THAN (4),
|
|
|
|
PARTITION hour_005 VALUES LESS THAN (5),
|
|
|
|
PARTITION hour_last VALUES LESS THAN (MAXVALUE));
|
|
|
|
INSERT INTO t1 VALUES (1, 1), (2, 2), (3, 3), (4, 4), (5, 5);
|
|
|
|
BEGIN;
|
|
|
|
SELECT COUNT(*) FROM t1;
|
|
|
|
COUNT(*)
|
|
|
|
5
|
|
|
|
# con1
|
|
|
|
# SEND a ALTER PARTITION which waits on the ongoing transaction.
|
|
|
|
ALTER TABLE t1
|
|
|
|
REORGANIZE PARTITION hour_003, hour_004 INTO
|
|
|
|
(PARTITION oldest VALUES LESS THAN (4));
|
|
|
|
# Connection default wait until the ALTER is in 'waiting for table...'
|
|
|
|
# state and then continue the transaction by trying a SELECT
|
|
|
|
SELECT COUNT(*) FROM t1;
|
|
|
|
COUNT(*)
|
|
|
|
5
|
|
|
|
COMMIT;
|
|
|
|
# con1, reaping ALTER.
|
|
|
|
# Disconnecting con1 and switching to default. Cleaning up.
|
|
|
|
SET GLOBAL innodb_thread_concurrency = @old_innodb_thread_concurrency;
|
2012-08-17 15:46:34 +02:00
|
|
|
SET GLOBAL innodb_thread_sleep_delay = @old_innodb_thread_sleep_delay;
|
2010-08-20 19:15:48 +02:00
|
|
|
DROP TABLE t1;
|
|
|
|
#
|
2010-08-13 09:50:25 +02:00
|
|
|
# Bug#50418: DROP PARTITION does not interact with transactions
|
|
|
|
#
|
|
|
|
CREATE TABLE t1 (
|
|
|
|
id INT AUTO_INCREMENT NOT NULL,
|
|
|
|
name CHAR(50) NOT NULL,
|
|
|
|
myDate DATE NOT NULL,
|
|
|
|
PRIMARY KEY (id, myDate),
|
|
|
|
INDEX idx_date (myDate)
|
|
|
|
) ENGINE=InnoDB
|
|
|
|
PARTITION BY RANGE ( TO_DAYS(myDate) ) (
|
|
|
|
PARTITION p0 VALUES LESS THAN (734028),
|
|
|
|
PARTITION p1 VALUES LESS THAN (734029),
|
|
|
|
PARTITION p2 VALUES LESS THAN (734030),
|
|
|
|
PARTITION p3 VALUES LESS THAN MAXVALUE
|
|
|
|
) ;
|
|
|
|
INSERT INTO t1 VALUES
|
|
|
|
(NULL, 'Lachlan', '2009-09-13'),
|
|
|
|
(NULL, 'Clint', '2009-09-13'),
|
|
|
|
(NULL, 'John', '2009-09-14'),
|
|
|
|
(NULL, 'Dave', '2009-09-14'),
|
|
|
|
(NULL, 'Jeremy', '2009-09-15'),
|
|
|
|
(NULL, 'Scott', '2009-09-15'),
|
|
|
|
(NULL, 'Jeff', '2009-09-16'),
|
|
|
|
(NULL, 'Joe', '2009-09-16');
|
|
|
|
SET AUTOCOMMIT=0;
|
|
|
|
SELECT * FROM t1 FOR UPDATE;
|
|
|
|
id name myDate
|
|
|
|
1 Lachlan 2009-09-13
|
|
|
|
2 Clint 2009-09-13
|
|
|
|
3 John 2009-09-14
|
|
|
|
4 Dave 2009-09-14
|
|
|
|
5 Jeremy 2009-09-15
|
|
|
|
6 Scott 2009-09-15
|
|
|
|
7 Jeff 2009-09-16
|
|
|
|
8 Joe 2009-09-16
|
|
|
|
UPDATE t1 SET name = 'Mattias' WHERE id = 7;
|
|
|
|
SELECT * FROM t1 WHERE id = 7;
|
|
|
|
id name myDate
|
|
|
|
7 Mattias 2009-09-16
|
|
|
|
# Connection con1
|
|
|
|
SET lock_wait_timeout = 1;
|
|
|
|
# After the patch it will wait and fail on timeout.
|
|
|
|
ALTER TABLE t1 DROP PARTITION p3;
|
|
|
|
ERROR HY000: Lock wait timeout exceeded; try restarting transaction
|
|
|
|
SHOW WARNINGS;
|
|
|
|
Level Code Message
|
|
|
|
Error 1205 Lock wait timeout exceeded; try restarting transaction
|
|
|
|
# Connection default
|
|
|
|
SELECT * FROM t1;
|
|
|
|
id name myDate
|
|
|
|
1 Lachlan 2009-09-13
|
|
|
|
2 Clint 2009-09-13
|
|
|
|
3 John 2009-09-14
|
|
|
|
4 Dave 2009-09-14
|
|
|
|
5 Jeremy 2009-09-15
|
|
|
|
6 Scott 2009-09-15
|
|
|
|
7 Mattias 2009-09-16
|
|
|
|
8 Joe 2009-09-16
|
|
|
|
# No changes.
|
|
|
|
COMMIT;
|
|
|
|
DROP TABLE t1;
|
|
|
|
#
|
2010-03-10 12:56:05 +01:00
|
|
|
# Bug#51830: Incorrect partition pruning on range partition (regression)
|
|
|
|
#
|
|
|
|
CREATE TABLE t1 (a INT NOT NULL)
|
|
|
|
ENGINE = InnoDB
|
|
|
|
PARTITION BY RANGE(a)
|
|
|
|
(PARTITION p10 VALUES LESS THAN (10),
|
|
|
|
PARTITION p30 VALUES LESS THAN (30),
|
|
|
|
PARTITION p50 VALUES LESS THAN (50),
|
|
|
|
PARTITION p70 VALUES LESS THAN (70),
|
|
|
|
PARTITION p90 VALUES LESS THAN (90));
|
|
|
|
INSERT INTO t1 VALUES (10),(30),(50);
|
|
|
|
INSERT INTO t1 VALUES (70);
|
|
|
|
INSERT INTO t1 VALUES (80);
|
|
|
|
INSERT INTO t1 VALUES (89);
|
|
|
|
INSERT INTO t1 VALUES (90);
|
|
|
|
ERROR HY000: Table has no partition for value 90
|
|
|
|
INSERT INTO t1 VALUES (100);
|
|
|
|
ERROR HY000: Table has no partition for value 100
|
|
|
|
insert INTO t1 VALUES (110);
|
|
|
|
ERROR HY000: Table has no partition for value 110
|
|
|
|
EXPLAIN PARTITIONS SELECT * FROM t1 WHERE a > 90;
|
|
|
|
id select_type table partitions type possible_keys key key_len ref rows Extra
|
2012-04-03 23:14:07 +02:00
|
|
|
1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables
|
2010-03-10 12:56:05 +01:00
|
|
|
EXPLAIN PARTITIONS SELECT * FROM t1 WHERE a >= 90;
|
|
|
|
id select_type table partitions type possible_keys key key_len ref rows Extra
|
2012-04-03 23:14:07 +02:00
|
|
|
1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables
|
2010-03-10 12:56:05 +01:00
|
|
|
EXPLAIN PARTITIONS SELECT * FROM t1 WHERE a = 90;
|
|
|
|
id select_type table partitions type possible_keys key key_len ref rows Extra
|
2012-04-03 23:14:07 +02:00
|
|
|
1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables
|
2010-03-10 12:56:05 +01:00
|
|
|
EXPLAIN PARTITIONS SELECT * FROM t1 WHERE a = 89;
|
|
|
|
id select_type table partitions type possible_keys key key_len ref rows Extra
|
2010-08-27 10:43:51 +02:00
|
|
|
1 SIMPLE t1 p90 ALL NULL NULL NULL NULL 3 Using where
|
2010-03-10 12:56:05 +01:00
|
|
|
EXPLAIN PARTITIONS SELECT * FROM t1 WHERE a >= 89;
|
|
|
|
id select_type table partitions type possible_keys key key_len ref rows Extra
|
2010-08-27 10:43:51 +02:00
|
|
|
1 SIMPLE t1 p90 ALL NULL NULL NULL NULL 3 Using where
|
2010-03-10 12:56:05 +01:00
|
|
|
EXPLAIN PARTITIONS SELECT * FROM t1 WHERE a > 89;
|
|
|
|
id select_type table partitions type possible_keys key key_len ref rows Extra
|
2012-04-03 23:14:07 +02:00
|
|
|
1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables
|
2010-03-10 12:56:05 +01:00
|
|
|
EXPLAIN PARTITIONS SELECT * FROM t1 WHERE a = 100;
|
|
|
|
id select_type table partitions type possible_keys key key_len ref rows Extra
|
2012-04-03 23:14:07 +02:00
|
|
|
1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables
|
2010-03-10 12:56:05 +01:00
|
|
|
EXPLAIN PARTITIONS SELECT * FROM t1 WHERE a >= 100;
|
|
|
|
id select_type table partitions type possible_keys key key_len ref rows Extra
|
2012-04-03 23:14:07 +02:00
|
|
|
1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables
|
2010-03-10 12:56:05 +01:00
|
|
|
EXPLAIN PARTITIONS SELECT * FROM t1 WHERE a > 100;
|
|
|
|
id select_type table partitions type possible_keys key key_len ref rows Extra
|
2012-04-03 23:14:07 +02:00
|
|
|
1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables
|
2010-03-10 12:56:05 +01:00
|
|
|
DROP TABLE t1;
|
2010-03-12 11:52:38 +01:00
|
|
|
#
|
2010-03-04 12:29:22 +01:00
|
|
|
# Bug#50104: Partitioned table with just 1 partion works with fk
|
|
|
|
#
|
|
|
|
CREATE TABLE t2 (
|
|
|
|
id INT,
|
|
|
|
PRIMARY KEY (id)
|
|
|
|
) ENGINE=InnoDB ;
|
|
|
|
CREATE TABLE t1 (
|
|
|
|
id INT NOT NULL AUTO_INCREMENT,
|
|
|
|
parent_id INT DEFAULT NULL,
|
|
|
|
PRIMARY KEY (id),
|
|
|
|
KEY parent_id (parent_id)
|
|
|
|
) ENGINE=InnoDB;
|
|
|
|
ALTER TABLE t1 PARTITION BY HASH (id) PARTITIONS 1;
|
|
|
|
ALTER TABLE t1 ADD CONSTRAINT test_ibfk_1 FOREIGN KEY (parent_id) REFERENCES t2 (id);
|
|
|
|
ERROR HY000: Foreign key clause is not yet supported in conjunction with partitioning
|
|
|
|
ALTER TABLE t1 PARTITION BY HASH (id) PARTITIONS 2;
|
|
|
|
ALTER TABLE t1 ADD CONSTRAINT test_ibfk_1 FOREIGN KEY (parent_id) REFERENCES t2 (id);
|
|
|
|
ERROR HY000: Foreign key clause is not yet supported in conjunction with partitioning
|
|
|
|
DROP TABLE t1, t2;
|
2009-11-05 15:42:03 +01:00
|
|
|
create table t1 (a varchar(5), b int signed, c varchar(10), d datetime)
|
|
|
|
partition by range columns(b,c)
|
|
|
|
subpartition by hash(to_seconds(d))
|
|
|
|
( partition p0 values less than (2, 'b'),
|
|
|
|
partition p1 values less than (4, 'd'),
|
|
|
|
partition p2 values less than (10, 'za'));
|
|
|
|
insert into t1 values ('a', 3, 'w', '2001-10-27 04:34:00');
|
|
|
|
insert into t1 values ('r', 7, 'w', '2001-10-27 05:34:00');
|
|
|
|
insert into t1 values ('g', 10, 'w', '2001-10-27 06:34:00');
|
|
|
|
update t1 set a = 'c' where a > 'f';
|
|
|
|
drop table t1;
|
2009-10-05 16:10:18 +02:00
|
|
|
create table t1 (a varchar(5))
|
|
|
|
engine=memory
|
2009-10-29 18:04:23 +01:00
|
|
|
partition by range columns(a)
|
2009-10-16 16:16:06 +02:00
|
|
|
( partition p0 values less than ('m'),
|
|
|
|
partition p1 values less than ('za'));
|
2009-10-05 16:10:18 +02:00
|
|
|
insert into t1 values ('j');
|
|
|
|
update t1 set a = 'z' where (a >= 'j');
|
|
|
|
drop table t1;
|
|
|
|
create table t1 (a varchar(5))
|
|
|
|
engine=myisam
|
2009-10-29 18:04:23 +01:00
|
|
|
partition by range columns(a)
|
2009-10-16 16:16:06 +02:00
|
|
|
( partition p0 values less than ('m'),
|
|
|
|
partition p1 values less than ('za'));
|
2009-10-05 16:10:18 +02:00
|
|
|
insert into t1 values ('j');
|
|
|
|
update t1 set a = 'z' where (a >= 'j');
|
|
|
|
drop table t1;
|
|
|
|
create table t1 (a varchar(5))
|
|
|
|
engine=innodb
|
2009-10-29 18:04:23 +01:00
|
|
|
partition by range columns(a)
|
2009-10-16 16:16:06 +02:00
|
|
|
( partition p0 values less than ('m'),
|
|
|
|
partition p1 values less than ('za'));
|
2009-10-05 16:10:18 +02:00
|
|
|
insert into t1 values ('j');
|
|
|
|
update t1 set a = 'z' where (a >= 'j');
|
|
|
|
drop table t1;
|
2009-09-07 10:37:54 +02:00
|
|
|
create table t1 (a int not null,
|
|
|
|
b datetime not null,
|
|
|
|
primary key (a,b))
|
|
|
|
engine=innodb
|
|
|
|
partition by range (to_days(b))
|
|
|
|
subpartition by hash (a)
|
|
|
|
subpartitions 2
|
|
|
|
( partition p0 values less than (to_days('2009-01-01')),
|
|
|
|
partition p1 values less than (to_days('2009-02-01')),
|
|
|
|
partition p2 values less than (to_days('2009-03-01')),
|
|
|
|
partition p3 values less than maxvalue);
|
|
|
|
alter table t1 reorganize partition p1,p2 into
|
|
|
|
( partition p2 values less than (to_days('2009-03-01')));
|
|
|
|
drop table t1;
|
2008-11-10 21:13:24 +01:00
|
|
|
CREATE TABLE t1 (id INT PRIMARY KEY, data INT) ENGINE = InnoDB
|
|
|
|
PARTITION BY RANGE(id) (
|
|
|
|
PARTITION p0 VALUES LESS THAN (5),
|
|
|
|
PARTITION p1 VALUES LESS THAN (10),
|
|
|
|
PARTITION p2 VALUES LESS THAN MAXVALUE
|
|
|
|
);
|
|
|
|
INSERT INTO t1 VALUES (1,1), (2,2), (3,3), (4,4), (5,5), (6,6), (7,7), (8,8),
|
|
|
|
(9,9), (10,10), (11,11);
|
|
|
|
SET @old_tx_isolation := @@session.tx_isolation;
|
|
|
|
SET SESSION TRANSACTION ISOLATION LEVEL READ COMMITTED;
|
|
|
|
SET autocommit = 0;
|
|
|
|
UPDATE t1 SET DATA = data*2 WHERE id = 3;
|
|
|
|
UPDATE t1 SET data = data*2 WHERE data = 2;
|
|
|
|
SET @@session.tx_isolation = @old_tx_isolation;
|
|
|
|
DROP TABLE t1;
|
2008-10-10 12:01:01 +02:00
|
|
|
# Bug#37721, test of ORDER BY on PK and WHERE on INDEX
|
|
|
|
CREATE TABLE t1 (
|
|
|
|
a INT,
|
|
|
|
b INT,
|
|
|
|
PRIMARY KEY (a),
|
|
|
|
INDEX (b))
|
|
|
|
ENGINE InnoDB
|
|
|
|
PARTITION BY HASH(a)
|
|
|
|
PARTITIONS 3;
|
|
|
|
INSERT INTO t1 VALUES (0,0),(4,0),(2,0);
|
|
|
|
SELECT a FROM t1 WHERE b = 0 ORDER BY a ASC;
|
|
|
|
a
|
|
|
|
0
|
|
|
|
2
|
|
|
|
4
|
|
|
|
SELECT a FROM t1 WHERE b = 0 ORDER BY a DESC;
|
|
|
|
a
|
|
|
|
4
|
|
|
|
2
|
|
|
|
0
|
|
|
|
ALTER TABLE t1 DROP INDEX b;
|
|
|
|
SELECT a FROM t1 WHERE b = 0 ORDER BY a ASC;
|
|
|
|
a
|
|
|
|
0
|
|
|
|
2
|
|
|
|
4
|
|
|
|
SELECT a FROM t1 WHERE b = 0 ORDER BY a DESC;
|
|
|
|
a
|
|
|
|
4
|
|
|
|
2
|
|
|
|
0
|
|
|
|
DROP TABLE t1;
|
|
|
|
CREATE TABLE t1 (
|
|
|
|
a VARCHAR(600),
|
|
|
|
b VARCHAR(600),
|
|
|
|
PRIMARY KEY (a),
|
|
|
|
INDEX (b))
|
|
|
|
ENGINE InnoDB
|
|
|
|
PARTITION BY KEY(a)
|
|
|
|
PARTITIONS 3;
|
|
|
|
INSERT INTO t1 VALUES (concat(repeat('MySQL',100),'1'),repeat('0',257));
|
|
|
|
INSERT INTO t1 VALUES (concat(repeat('MySQL',100),'3'),repeat('0',257));
|
|
|
|
INSERT INTO t1 VALUES (concat(repeat('MySQL',100),'2'),repeat('0',257));
|
|
|
|
SELECT right(a,1) FROM t1 WHERE b = repeat('0',257) ORDER BY a ASC;
|
|
|
|
right(a,1)
|
|
|
|
1
|
|
|
|
2
|
|
|
|
3
|
|
|
|
SELECT right(a,1) FROM t1 WHERE b = repeat('0',257) ORDER BY a DESC;
|
|
|
|
right(a,1)
|
|
|
|
3
|
|
|
|
2
|
|
|
|
1
|
|
|
|
ALTER TABLE t1 DROP INDEX b;
|
|
|
|
SELECT right(a,1) FROM t1 WHERE b = repeat('0',257) ORDER BY a ASC;
|
|
|
|
right(a,1)
|
|
|
|
1
|
|
|
|
2
|
|
|
|
3
|
|
|
|
SELECT right(a,1) FROM t1 WHERE b = repeat('0',257) ORDER BY a DESC;
|
|
|
|
right(a,1)
|
|
|
|
3
|
|
|
|
2
|
|
|
|
1
|
|
|
|
DROP TABLE t1;
|
2007-12-06 14:43:06 +01:00
|
|
|
# Bug#32948
|
|
|
|
CREATE TABLE t1 (c1 INT, PRIMARY KEY (c1)) ENGINE=INNODB;
|
|
|
|
CREATE TABLE t2 (c1 INT, PRIMARY KEY (c1),
|
|
|
|
FOREIGN KEY (c1) REFERENCES t1 (c1)
|
|
|
|
ON DELETE CASCADE)
|
|
|
|
ENGINE=INNODB;
|
|
|
|
ALTER TABLE t1 PARTITION BY HASH(c1) PARTITIONS 5;
|
|
|
|
ERROR 23000: Cannot delete or update a parent row: a foreign key constraint fails
|
|
|
|
ALTER TABLE t1 ENGINE=MyISAM;
|
|
|
|
ERROR 23000: Cannot delete or update a parent row: a foreign key constraint fails
|
|
|
|
DROP TABLE t2;
|
|
|
|
DROP TABLE t1;
|
2006-05-18 19:16:51 +02:00
|
|
|
create table t1 (a int) engine=innodb partition by hash(a) ;
|
|
|
|
show table status like 't1';
|
|
|
|
Name Engine Version Row_format Rows Avg_row_length Data_length Max_data_length Index_length Data_free Auto_increment Create_time Update_time Check_time Collation Checksum Create_options Comment
|
2015-04-06 08:57:12 +02:00
|
|
|
t1 InnoDB 10 Compact 2 8192 16384 0 0 # NULL # NULL NULL latin1_swedish_ci NULL partitioned
|
2006-05-18 19:16:51 +02:00
|
|
|
drop table t1;
|
2006-09-08 09:18:05 +02:00
|
|
|
create table t1 (a int)
|
|
|
|
engine = innodb
|
|
|
|
partition by key (a);
|
|
|
|
show table status;
|
|
|
|
Name Engine Version Row_format Rows Avg_row_length Data_length Max_data_length Index_length Data_free Auto_increment Create_time Update_time Check_time Collation Checksum Create_options Comment
|
2015-04-06 08:57:12 +02:00
|
|
|
t1 InnoDB 10 Compact 2 8192 16384 0 0 # NULL # NULL NULL latin1_swedish_ci NULL partitioned
|
2006-09-08 09:18:05 +02:00
|
|
|
insert into t1 values (0), (1), (2), (3);
|
|
|
|
show table status;
|
|
|
|
Name Engine Version Row_format Rows Avg_row_length Data_length Max_data_length Index_length Data_free Auto_increment Create_time Update_time Check_time Collation Checksum Create_options Comment
|
2015-04-06 08:57:12 +02:00
|
|
|
t1 InnoDB 10 Compact 4 4096 16384 0 0 # NULL # NULL NULL latin1_swedish_ci NULL partitioned
|
2006-09-08 09:18:05 +02:00
|
|
|
drop table t1;
|
|
|
|
create table t1 (a int auto_increment primary key)
|
|
|
|
engine = innodb
|
|
|
|
partition by key (a);
|
|
|
|
show table status;
|
|
|
|
Name Engine Version Row_format Rows Avg_row_length Data_length Max_data_length Index_length Data_free Auto_increment Create_time Update_time Check_time Collation Checksum Create_options Comment
|
2015-04-06 08:57:12 +02:00
|
|
|
t1 InnoDB 10 Compact 2 8192 16384 0 0 # 1 # NULL NULL latin1_swedish_ci NULL partitioned
|
2006-09-08 09:18:05 +02:00
|
|
|
insert into t1 values (NULL), (NULL), (NULL), (NULL);
|
|
|
|
show table status;
|
|
|
|
Name Engine Version Row_format Rows Avg_row_length Data_length Max_data_length Index_length Data_free Auto_increment Create_time Update_time Check_time Collation Checksum Create_options Comment
|
2015-04-06 08:57:12 +02:00
|
|
|
t1 InnoDB 10 Compact 4 4096 16384 0 0 # 5 # NULL NULL latin1_swedish_ci NULL partitioned
|
2006-09-08 09:18:05 +02:00
|
|
|
insert into t1 values (NULL), (NULL), (NULL), (NULL);
|
|
|
|
show table status;
|
|
|
|
Name Engine Version Row_format Rows Avg_row_length Data_length Max_data_length Index_length Data_free Auto_increment Create_time Update_time Check_time Collation Checksum Create_options Comment
|
2015-04-06 08:57:12 +02:00
|
|
|
t1 InnoDB 10 Compact 8 2048 16384 0 0 # 9 # NULL NULL latin1_swedish_ci NULL partitioned
|
2006-09-08 09:18:05 +02:00
|
|
|
drop table t1;
|
|
|
|
create table t1 (a int)
|
|
|
|
partition by key (a)
|
|
|
|
(partition p1 engine = innodb);
|
|
|
|
alter table t1 rebuild partition p1;
|
|
|
|
alter table t1 rebuild partition p1;
|
|
|
|
alter table t1 rebuild partition p1;
|
|
|
|
alter table t1 rebuild partition p1;
|
|
|
|
alter table t1 rebuild partition p1;
|
|
|
|
alter table t1 rebuild partition p1;
|
|
|
|
alter table t1 rebuild partition p1;
|
|
|
|
drop table t1;
|
|
|
|
create table t1 (a date)
|
|
|
|
engine = innodb
|
|
|
|
partition by range (year(a))
|
|
|
|
(partition p0 values less than (2006),
|
|
|
|
partition p1 values less than (2007));
|
|
|
|
explain partitions select * from t1
|
|
|
|
where a between '2006-01-01' and '2007-06-01';
|
|
|
|
id select_type table partitions type possible_keys key key_len ref rows Extra
|
|
|
|
1 SIMPLE t1 p1 ALL NULL NULL NULL NULL 2 Using where
|
|
|
|
drop table t1;
|
|
|
|
create table t1 (a int)
|
|
|
|
engine = x
|
|
|
|
partition by key (a);
|
|
|
|
Warnings:
|
2009-12-22 12:02:52 +01:00
|
|
|
Warning 1286 Unknown storage engine 'x'
|
2010-06-17 22:51:35 +02:00
|
|
|
Warning 1266 Using storage engine InnoDB for table 't1'
|
2006-09-08 09:18:05 +02:00
|
|
|
show create table t1;
|
|
|
|
Table Create Table
|
|
|
|
t1 CREATE TABLE `t1` (
|
|
|
|
`a` int(11) DEFAULT NULL
|
2010-06-17 22:51:35 +02:00
|
|
|
) ENGINE=InnoDB DEFAULT CHARSET=latin1
|
2008-11-04 08:43:21 +01:00
|
|
|
/*!50100 PARTITION BY KEY (a) */
|
2006-09-08 09:18:05 +02:00
|
|
|
drop table t1;
|
|
|
|
create table t1 (a int)
|
|
|
|
engine = innodb
|
|
|
|
partition by list (a)
|
|
|
|
(partition p0 values in (0));
|
|
|
|
alter table t1 engine = x;
|
2009-11-24 12:08:04 +01:00
|
|
|
Warnings:
|
2009-12-22 12:02:52 +01:00
|
|
|
Warning 1286 Unknown storage engine 'x'
|
2006-09-08 09:18:05 +02:00
|
|
|
show create table t1;
|
|
|
|
Table Create Table
|
|
|
|
t1 CREATE TABLE `t1` (
|
|
|
|
`a` int(11) DEFAULT NULL
|
2008-11-04 08:43:21 +01:00
|
|
|
) ENGINE=InnoDB DEFAULT CHARSET=latin1
|
|
|
|
/*!50100 PARTITION BY LIST (a)
|
|
|
|
(PARTITION p0 VALUES IN (0) ENGINE = InnoDB) */
|
2006-09-08 09:18:05 +02:00
|
|
|
drop table t1;
|
2007-02-27 20:01:03 +01:00
|
|
|
create table t1
|
|
|
|
(
|
|
|
|
id int unsigned auto_increment,
|
|
|
|
time datetime not null,
|
|
|
|
first_name varchar(40),
|
|
|
|
last_name varchar(50),
|
|
|
|
primary key (id, time),
|
|
|
|
index first_index (first_name),
|
|
|
|
index last_index (last_name)
|
|
|
|
) engine=Innodb partition by range (to_days(time)) (
|
|
|
|
partition p1 values less than (to_days('2007-02-07')),
|
|
|
|
partition p2 values less than (to_days('2007-02-08')),
|
|
|
|
partition p3 values less than MAXVALUE
|
|
|
|
);
|
|
|
|
insert into t1 (time, first_name, last_name) values ('2007-02-07', 'Q', 'Robert'),
|
|
|
|
('2007-02-07', 'Mark', 'Nate'), ('2007-02-07', 'Nate', 'Oscar'),
|
|
|
|
('2007-02-07', 'Zack', 'Alice'), ('2007-02-07', 'Jack', 'Kathy'),
|
|
|
|
('2007-02-06', 'Alice', 'Alice'), ('2007-02-06', 'Brian', 'Charles'),
|
|
|
|
('2007-02-06', 'Charles', 'David'), ('2007-02-06', 'David', 'Eric'),
|
|
|
|
('2007-02-07', 'Hector', 'Isaac'), ('2007-02-07', 'Oscar', 'Patricia'),
|
|
|
|
('2007-02-07', 'Patricia', 'Q'), ('2007-02-07', 'X', 'Yuri'),
|
|
|
|
('2007-02-07', 'Robert', 'Shawn'), ('2007-02-07', 'Kathy', 'Lois'),
|
|
|
|
('2007-02-07', 'Eric', 'Francis'), ('2007-02-06', 'Shawn', 'Theron'),
|
|
|
|
('2007-02-06', 'U', 'Vincent'), ('2007-02-06', 'Francis', 'George'),
|
|
|
|
('2007-02-06', 'George', 'Hector'), ('2007-02-06', 'Vincent', 'Walter'),
|
|
|
|
('2007-02-06', 'Walter', 'X'), ('2007-02-07', 'Lois', 'Mark'),
|
|
|
|
('2007-02-07', 'Yuri', 'Zack'), ('2007-02-07', 'Isaac', 'Jack'),
|
|
|
|
('2007-02-07', 'Sharon', 'Mark'), ('2007-02-07', 'Michael', 'Michelle'),
|
|
|
|
('2007-02-07', 'Derick', 'Nathan'), ('2007-02-07', 'Peter', 'Xavier'),
|
|
|
|
('2007-02-07', 'Fred', 'Harold'), ('2007-02-07', 'Katherine', 'Lisa'),
|
|
|
|
('2007-02-07', 'Tom', 'Rina'), ('2007-02-07', 'Jerry', 'Victor'),
|
|
|
|
('2007-02-07', 'Alexander', 'Terry'), ('2007-02-07', 'Justin', 'John'),
|
|
|
|
('2007-02-07', 'Greg', 'Ernest'), ('2007-02-07', 'Robert', 'Q'),
|
|
|
|
('2007-02-07', 'Nate', 'Mark'), ('2007-02-07', 'Oscar', 'Nate'),
|
|
|
|
('2007-02-07', 'Alice', 'Zack'), ('2007-02-07', 'Kathy', 'Jack'),
|
|
|
|
('2007-02-06', 'Alice', 'Alice'), ('2007-02-06', 'Charles', 'Brian'),
|
|
|
|
('2007-02-06', 'David', 'Charles'), ('2007-02-06', 'Eric', 'David'),
|
|
|
|
('2007-02-07', 'Isaac', 'Hector'), ('2007-02-07', 'Patricia', 'Oscar'),
|
|
|
|
('2007-02-07', 'Q', 'Patricia'), ('2007-02-07', 'Yuri', 'X'),
|
|
|
|
('2007-02-07', 'Shawn', 'Robert'), ('2007-02-07', 'Lois', 'Kathy'),
|
|
|
|
('2007-02-07', 'Francis', 'Eric'), ('2007-02-06', 'Theron', 'Shawn'),
|
|
|
|
('2007-02-06', 'Vincent', 'U'), ('2007-02-06', 'George', 'Francis'),
|
|
|
|
('2007-02-06', 'Hector', 'George'), ('2007-02-06', 'Walter', 'Vincent'),
|
|
|
|
('2007-02-06', 'X', 'Walter'), ('2007-02-07', 'Mark', 'Lois'),
|
|
|
|
('2007-02-07', 'Zack', 'Yuri'), ('2007-02-07', 'Jack', 'Isaac'),
|
|
|
|
('2007-02-07', 'Mark', 'Sharon'), ('2007-02-07', 'Michelle', 'Michael'),
|
|
|
|
('2007-02-07', 'Nathan', 'Derick'), ('2007-02-07', 'Xavier', 'Peter'),
|
|
|
|
('2007-02-07', 'Harold', 'Fred'), ('2007-02-07', 'Lisa', 'Katherine'),
|
|
|
|
('2007-02-07', 'Rina', 'Tom'), ('2007-02-07', 'Victor', 'Jerry'),
|
|
|
|
('2007-02-07', 'Terry', 'Alexander'), ('2007-02-07', 'John', 'Justin'),
|
|
|
|
('2007-02-07', 'Ernest', 'Greg');
|
|
|
|
SELECT * FROM t1 WHERE first_name='Andy' OR last_name='Jake';
|
|
|
|
id time first_name last_name
|
|
|
|
drop table t1;
|
2007-09-13 15:33:40 +02:00
|
|
|
CREATE TABLE t1 (a DOUBLE NOT NULL, KEY(a)) ENGINE=InnoDB
|
|
|
|
PARTITION BY KEY(a) PARTITIONS 10;
|
|
|
|
INSERT INTO t1 VALUES(1),(2);
|
|
|
|
SELECT COUNT(*) FROM t1;
|
|
|
|
COUNT(*)
|
|
|
|
2
|
|
|
|
DROP TABLE t1;
|
2007-11-12 11:26:09 +01:00
|
|
|
create table t1 (int_column int, char_column char(5))
|
2007-11-13 06:41:59 +01:00
|
|
|
PARTITION BY RANGE (int_column) subpartition by key (char_column) subpartitions 2
|
2007-11-12 11:26:09 +01:00
|
|
|
(PARTITION p1 VALUES LESS THAN (5) ENGINE = InnoDB);
|
2008-01-09 13:15:50 +01:00
|
|
|
alter table t1
|
|
|
|
ENGINE = MyISAM
|
|
|
|
PARTITION BY RANGE (int_column)
|
2007-11-13 06:41:59 +01:00
|
|
|
subpartition by key (char_column) subpartitions 2
|
2008-01-09 13:15:50 +01:00
|
|
|
(PARTITION p1 VALUES LESS THAN (5));
|
2007-11-12 11:26:09 +01:00
|
|
|
show create table t1;
|
|
|
|
Table Create Table
|
|
|
|
t1 CREATE TABLE `t1` (
|
|
|
|
`int_column` int(11) DEFAULT NULL,
|
|
|
|
`char_column` char(5) DEFAULT NULL
|
2008-11-04 08:43:21 +01:00
|
|
|
) ENGINE=MyISAM DEFAULT CHARSET=latin1
|
|
|
|
/*!50100 PARTITION BY RANGE (int_column)
|
|
|
|
SUBPARTITION BY KEY (char_column)
|
|
|
|
SUBPARTITIONS 2
|
|
|
|
(PARTITION p1 VALUES LESS THAN (5) ENGINE = MyISAM) */
|
2007-11-12 11:26:09 +01:00
|
|
|
drop table t1;
|
2009-09-02 13:19:28 +02:00
|
|
|
CREATE TABLE t1 (a INT) ENGINE=InnoDB
|
|
|
|
PARTITION BY list(a) (PARTITION p1 VALUES IN (1));
|
|
|
|
CREATE INDEX i1 ON t1 (a);
|
|
|
|
DROP TABLE t1;
|
2010-07-06 19:38:03 +02:00
|
|
|
#
|
|
|
|
# Bug#54783: optimize table crashes with invalid timestamp default value and NO_ZERO_DATE
|
|
|
|
#
|
|
|
|
DROP TABLE IF EXISTS t1;
|
|
|
|
CREATE TABLE t1 (a INT, b TIMESTAMP DEFAULT '0000-00-00 00:00:00')
|
|
|
|
ENGINE=INNODB PARTITION BY LINEAR HASH (a) PARTITIONS 1;
|
|
|
|
SET @old_mode = @@sql_mode;
|
|
|
|
SET SESSION sql_mode = 'NO_ZERO_DATE';
|
|
|
|
OPTIMIZE TABLE t1;
|
|
|
|
Table Op Msg_type Msg_text
|
|
|
|
test.t1 optimize note Table does not support optimize, doing recreate + analyze instead
|
|
|
|
test.t1 optimize error Invalid default value for 'b'
|
|
|
|
test.t1 optimize status Operation failed
|
|
|
|
Warnings:
|
|
|
|
Warning 1265 Data truncated for column 'b' at row 1
|
|
|
|
Error 1067 Invalid default value for 'b'
|
|
|
|
SET SESSION sql_mode = @old_mode;
|
|
|
|
DROP TABLE t1;
|
2010-11-19 08:26:09 +01:00
|
|
|
#
|
|
|
|
# Bug#57985 "ONLINE/FAST ALTER PARTITION can fail and leave the
|
|
|
|
# table unusable".
|
|
|
|
#
|
|
|
|
DROP TABLE IF EXISTS t1;
|
|
|
|
CREATE TABLE t1 (a bigint not null, b int not null, PRIMARY KEY (a))
|
|
|
|
ENGINE = InnoDB PARTITION BY KEY(a) PARTITIONS 2;
|
|
|
|
INSERT INTO t1 values (0,1), (1,2);
|
|
|
|
# The below ALTER should fail. It should leave the
|
|
|
|
# table in its original, non-corrupted, usable state.
|
|
|
|
ALTER TABLE t1 ADD UNIQUE KEY (b);
|
|
|
|
ERROR HY000: A UNIQUE INDEX must include all columns in the table's partitioning function
|
|
|
|
# The below statements should succeed, as ALTER should
|
|
|
|
# have left table intact.
|
|
|
|
SHOW CREATE TABLE t1;
|
|
|
|
Table Create Table
|
|
|
|
t1 CREATE TABLE `t1` (
|
|
|
|
`a` bigint(20) NOT NULL,
|
|
|
|
`b` int(11) NOT NULL,
|
|
|
|
PRIMARY KEY (`a`)
|
|
|
|
) ENGINE=InnoDB DEFAULT CHARSET=latin1
|
|
|
|
/*!50100 PARTITION BY KEY (a)
|
|
|
|
PARTITIONS 2 */
|
|
|
|
SELECT * FROM t1;
|
|
|
|
a b
|
|
|
|
1 2
|
|
|
|
0 1
|
|
|
|
DROP TABLE t1;
|
2012-11-03 09:24:36 +01:00
|
|
|
#
|
2015-04-06 08:57:12 +02:00
|
|
|
# Bug #17299181 CREATE_TIME AND UPDATE_TIME ARE
|
|
|
|
# WRONG FOR PARTITIONED TABLES
|
|
|
|
#
|
|
|
|
CREATE TABLE t1 (a int, PRIMARY KEY (a)) ENGINE=InnoDB
|
|
|
|
PARTITION BY HASH (a) PARTITIONS 2;
|
|
|
|
SELECT COUNT(*) FROM INFORMATION_SCHEMA.TABLES WHERE
|
|
|
|
CREATE_TIME IS NOT NULL AND TABLE_NAME='t1';
|
|
|
|
COUNT(*)
|
|
|
|
1
|
|
|
|
DROP TABLE t1;
|
2015-06-05 02:06:51 +02:00
|
|
|
#
|
2012-11-03 09:24:36 +01:00
|
|
|
# BUG#12912171 - ASSERTION FAILED: QUICK->HEAD->READ_SET ==
|
|
|
|
# SAVE_READ_SET
|
|
|
|
#
|
|
|
|
CREATE TABLE t1 (
|
|
|
|
a INT,
|
|
|
|
b INT,
|
|
|
|
c INT,
|
|
|
|
PRIMARY KEY (c,a), KEY (a),KEY (a)
|
|
|
|
) ENGINE=INNODB PARTITION BY KEY () PARTITIONS 2;
|
2013-09-20 21:30:19 +02:00
|
|
|
Warnings:
|
|
|
|
Note 1831 Duplicate index 'a_2' defined on the table 'test.t1'. This is deprecated and will be disallowed in a future release.
|
2012-11-03 09:24:36 +01:00
|
|
|
INSERT INTO t1 VALUES (1,5,1),(2,4,1),(3,3,1),(4,2,1),(5,1,1);
|
|
|
|
UPDATE t1 SET b = 0, c=1 WHERE a <=>0;
|
|
|
|
SELECT * FROM t1;
|
|
|
|
a b c
|
|
|
|
1 5 1
|
|
|
|
2 4 1
|
|
|
|
3 3 1
|
|
|
|
4 2 1
|
|
|
|
5 1 1
|
|
|
|
DROP TABLE t1;
|
2013-10-24 09:24:37 +02:00
|
|
|
#
|
|
|
|
# MDEV-5102 : MySQL Bug 69851
|
|
|
|
#
|
|
|
|
CREATE TABLE t1 (
|
|
|
|
`col1` bigint(20) unsigned NOT NULL ,
|
|
|
|
`col2` bigint(20) unsigned NOT NULL ,
|
|
|
|
`col3` datetime NOT NULL ,
|
|
|
|
PRIMARY KEY (`col3`),
|
|
|
|
KEY (`col1`),
|
|
|
|
KEY (`col2`)
|
|
|
|
) ENGINE=InnoDB DEFAULT CHARSET=latin1
|
|
|
|
PARTITION BY RANGE (TO_DAYS(col3))
|
|
|
|
(
|
|
|
|
PARTITION p_20130310 VALUES LESS THAN (735303) ENGINE = InnoDB,
|
|
|
|
PARTITION p_20130311 VALUES LESS THAN (735304) ENGINE = InnoDB,
|
|
|
|
PARTITION p_20130312 VALUES LESS THAN (735305) ENGINE = InnoDB
|
|
|
|
);
|
|
|
|
INSERT INTO `t1` VALUES (2,96,'2013-03-08 16:28:05');
|
|
|
|
INSERT INTO `t1` VALUES (1,2,'2013-03-08 16:47:39');
|
|
|
|
INSERT INTO `t1` VALUES (1,2,'2013-03-08 16:50:27');
|
|
|
|
INSERT INTO `t1` VALUES (1,2,'2013-03-11 16:33:04');
|
|
|
|
INSERT INTO `t1` VALUES (1,2,'2013-03-11 16:33:24');
|
|
|
|
INSERT INTO `t1` VALUES (2,2,'2013-03-12 10:11:48');
|
|
|
|
SELECT * FROM t1 WHERE col1 = 1 AND col2 = 2
|
|
|
|
AND col3 BETWEEN '2013-03-08 00:00:00' AND '2013-03-12 12:00:00'
|
|
|
|
GROUP BY 1, 2, 3;
|
|
|
|
col1 col2 col3
|
|
|
|
1 2 2013-03-08 16:47:39
|
|
|
|
1 2 2013-03-08 16:50:27
|
|
|
|
1 2 2013-03-11 16:33:04
|
|
|
|
1 2 2013-03-11 16:33:24
|
|
|
|
EXPLAIN SELECT * FROM t1 WHERE col1 = 1 AND col2 = 2
|
|
|
|
AND col3 BETWEEN '2013-03-08 00:00:00' AND '2013-03-12 12:00:00'
|
|
|
|
GROUP BY 1, 2, 3;
|
|
|
|
id select_type table type possible_keys key key_len ref rows Extra
|
|
|
|
1 SIMPLE t1 index_merge PRIMARY,col1,col2 col1,col2 8,8 NULL # Using intersect(col1,col2); Using where; Using index; Using filesort
|
|
|
|
SELECT * FROM t1 USE INDEX () WHERE col1 = 1 AND col2 = 2
|
|
|
|
AND col3 BETWEEN '2013-03-08 00:00:00' AND '2013-03-12 12:00:00'
|
|
|
|
GROUP BY 1, 2, 3;
|
|
|
|
col1 col2 col3
|
|
|
|
1 2 2013-03-08 16:47:39
|
|
|
|
1 2 2013-03-08 16:50:27
|
|
|
|
1 2 2013-03-11 16:33:04
|
|
|
|
1 2 2013-03-11 16:33:24
|
|
|
|
DROP TABLE t1;
|
2014-03-11 16:45:08 +01:00
|
|
|
#
|
|
|
|
# MDEV-5177: ha_partition and innodb index intersection produce fewer rows (MySQL Bug#70703)
|
|
|
|
#
|
|
|
|
create table t1 (
|
|
|
|
a int not null,
|
|
|
|
b int not null,
|
|
|
|
pk int not null,
|
|
|
|
primary key (pk),
|
|
|
|
key(a),
|
|
|
|
key(b)
|
|
|
|
) engine=innodb partition by hash(pk) partitions 10;
|
|
|
|
insert into t1 values (1,2,4);
|
|
|
|
insert into t1 values (1,0,17);
|
|
|
|
insert into t1 values (1,2,25);
|
|
|
|
insert into t1 values (10,20,122);
|
|
|
|
insert into t1 values (10,20,123);
|
|
|
|
create table t2 (a int);
|
|
|
|
insert into t2 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9);
|
|
|
|
insert into t1 select 1,2, 200 + A.a + 10*B.a + 100*C.a from t2 A, t2 B, t2 C;
|
|
|
|
insert into t1 select 10+A.a + 10*B.a + 100*C.a + 1000*D.a,
|
|
|
|
10+A.a + 10*B.a + 100*C.a + 1000*D.a,
|
|
|
|
2000 + A.a + 10*B.a + 100*C.a + 1000*D.a
|
|
|
|
from t2 A, t2 B, t2 C ,t2 D;
|
|
|
|
explain select * from t1 where a=1 and b=2 and pk between 1 and 999999 ;
|
|
|
|
id select_type table type possible_keys key key_len ref rows Extra
|
|
|
|
1 SIMPLE t1 index_merge PRIMARY,a,b b,a 4,4 NULL # Using intersect(b,a); Using where; Using index
|
|
|
|
create temporary table t3 as
|
|
|
|
select * from t1 where a=1 and b=2 and pk between 1 and 999 ;
|
|
|
|
select count(*) from t3;
|
|
|
|
count(*)
|
|
|
|
802
|
|
|
|
drop table t3;
|
|
|
|
create temporary table t3 as
|
|
|
|
select * from t1 ignore index(a,b) where a=1 and b=2 and pk between 1 and 999 ;
|
|
|
|
select count(*) from t3;
|
|
|
|
count(*)
|
|
|
|
802
|
|
|
|
drop table t3;
|
|
|
|
drop table t1,t2;
|
2014-04-18 12:07:54 +02:00
|
|
|
#
|
2014-07-23 20:48:31 +02:00
|
|
|
# MySQL Bug#71095: Wrong results with PARTITION BY LIST COLUMNS()
|
|
|
|
#
|
|
|
|
create table t1(c1 int, c2 int, c3 int, c4 int,
|
|
|
|
primary key(c1,c2)) engine=InnoDB
|
|
|
|
partition by list columns(c2)
|
|
|
|
(partition p1 values in (1,2) engine=InnoDB,
|
|
|
|
partition p2 values in (3,4) engine=InnoDB);
|
|
|
|
insert into t1 values (1,1,1,1),(2,3,1,1);
|
|
|
|
select * from t1 where c1=2 and c2=3;
|
|
|
|
c1 c2 c3 c4
|
|
|
|
2 3 1 1
|
|
|
|
drop table t1;
|
|
|
|
#
|
|
|
|
# MySQL Bug#72803: Wrong "Impossible where" with LIST partitioning
|
|
|
|
# also MDEV-6240: Wrong "Impossible where" with LIST partitioning
|
|
|
|
#
|
|
|
|
CREATE TABLE t1 ( d DATE) ENGINE = InnoDB
|
|
|
|
PARTITION BY LIST COLUMNS (d)
|
|
|
|
(
|
|
|
|
PARTITION p0 VALUES IN ('1990-01-01','1991-01-01'),
|
|
|
|
PARTITION p1 VALUES IN ('1981-01-01')
|
|
|
|
);
|
|
|
|
INSERT INTO t1 (d) VALUES ('1991-01-01');
|
|
|
|
SELECT * FROM t1 WHERE d = '1991-01-01';
|
|
|
|
d
|
|
|
|
1991-01-01
|
|
|
|
DROP TABLE t1;
|
2014-08-07 18:06:56 +02:00
|
|
|
#
|
2014-04-18 12:07:54 +02:00
|
|
|
# MDEV-5963: InnoDB: Assertion failure in file row0sel.cc line 2503,
|
|
|
|
# Failing assertion: 0 with "key ptr now exceeds key end by 762 bytes"
|
|
|
|
# (independent testcase for Oracle Bug#13947868)
|
|
|
|
#
|
|
|
|
CREATE TABLE t1 (f1 VARCHAR(512) CHARACTER SET utf8) ENGINE=InnoDB;
|
|
|
|
INSERT INTO t1 VALUES ('j');
|
|
|
|
CREATE TABLE t2 (
|
|
|
|
f2 VARCHAR(5) CHARACTER SET latin1,
|
|
|
|
f3 VARCHAR(5) CHARACTER SET utf8,
|
|
|
|
f4 INT,
|
|
|
|
f5 VARCHAR(512) CHARACTER SET utf8,
|
|
|
|
f6 VARCHAR(256) CHARACTER SET utf8,
|
|
|
|
key (f2),
|
|
|
|
key (f3),
|
|
|
|
key (f5)
|
|
|
|
) ENGINE=InnoDB PARTITION BY LIST COLUMNS (f4)
|
|
|
|
SUBPARTITION BY KEY(f6) SUBPARTITIONS 4 (
|
|
|
|
PARTITION p0 VALUES IN (1,3,9,null),
|
|
|
|
PARTITION p1 VALUES IN (2,4,0)
|
|
|
|
);
|
|
|
|
Warnings:
|
|
|
|
Warning 1071 Specified key was too long; max key length is 767 bytes
|
|
|
|
INSERT INTO t2 VALUES
|
|
|
|
('k','s',3,'b','j'),('a','b',NULL,'v','j'),('c','m',9,'t',NULL),
|
|
|
|
('b','l',9,'b',NULL),('i','y',3,'o','w'),('c','m',NULL,'a','m'),
|
|
|
|
('f','o',9,'m','w'),('f','q',NULL,'o','a');
|
|
|
|
CREATE TABLE t3 LIKE t2;
|
|
|
|
SELECT * FROM t1 INNER JOIN t2 ON ( f5 = f1 );
|
|
|
|
f1 f2 f3 f4 f5 f6
|
|
|
|
INSERT INTO t3 SELECT * FROM t2 WHERE f3 = 'm' AND f2 ='c';
|
|
|
|
DROP TABLE t1,t2,t3;
|
2011-04-25 17:22:25 +02:00
|
|
|
set global default_storage_engine=default;
|