summaryrefslogtreecommitdiffstats
path: root/mysql-test/suite/archive/partition_archive.test
blob: dff6ec598d0516cfaee0a80204ac237f65c74ece (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
# Tests for the partition storage engine in connection with the
# storage engine ARCHIVE.
#
# Creation:
# 2007-10-18 mleich  - Move ARCHIVE related sub tests of partition.test to
#                      this test. Reason: ARCHIVE is not everytime available.
#                    - Minor cleanup
#

--source include/have_partition.inc
--source include/have_archive.inc

let $MYSQLD_DATADIR= `select @@datadir`;

#
# Bug#44622: Using PARTITIONs with ARCHIVE engine reports 0 bytes in i_s.TABLES
#
CREATE TABLE t1 (f1 DATE NOT NULL) 
ENGINE = ARCHIVE PARTITION BY RANGE (TO_DAYS(f1)) 
(partition p1 values less than (733751), 
 partition p2 values less than MAXVALUE); 

INSERT INTO t1 VALUES(CURRENT_DATE); 

SELECT DATA_LENGTH, INDEX_LENGTH FROM information_schema.TABLES WHERE TABLE_SCHEMA='test' AND TABLE_NAME='t1';
SELECT DATA_LENGTH, INDEX_LENGTH FROM information_schema.TABLES WHERE TABLE_SCHEMA='test' AND TABLE_NAME='t1';
DROP TABLE t1;
CREATE TABLE t1 (f1 DATE NOT NULL) 
ENGINE = ARCHIVE;
INSERT INTO t1 VALUES(CURRENT_DATE); 
SELECT DATA_LENGTH, INDEX_LENGTH FROM information_schema.TABLES WHERE TABLE_SCHEMA='test' AND TABLE_NAME='t1';
SELECT DATA_LENGTH, INDEX_LENGTH FROM information_schema.TABLES WHERE TABLE_SCHEMA='test' AND TABLE_NAME='t1';
DROP TABLE t1;

#
# Bug 17310 Partitions: Bugs with archived partitioned tables
#
--disable_warnings
drop database if exists db99;
drop table if exists t1;
--enable_warnings

create database db99;
use db99;
create table t1 (a int not null)
engine=archive
partition by list (a)
(partition p0 values in (1), partition p1 values in (2));
insert into t1 values (1), (2);
--replace_regex /Not owner/Operation not permitted/
--error ER_CANT_CREATE_TABLE
create index inx on t1 (a);
alter table t1 add partition (partition p2 values in (3));
alter table t1 drop partition p2;
use test;
drop database db99;

create table t1 (f1 integer) engine= ARCHIVE partition by list(f1)
(
 partition p1 values in (1),
 partition p2 values in (NULL),
 partition p3 values in (2),
 partition p4 values in (3),
 partition p5 values in (4)
);

insert into t1 values (1),(2),(3),(4),(null);
select * from t1;
select * from t1 where f1 < 3;
drop table t1;

CREATE TABLE t1 (
a int not null,
b int not null,
c int not null) engine=ARCHIVE
partition by hash (a + 2)
partitions 3
(partition x1 tablespace ts1,
 partition x2 tablespace ts2,
 partition x3 tablespace ts3);

insert into t1 values (1,1,1);
insert into t1 values (2,1,1);
insert into t1 values (3,1,1);
insert into t1 values (4,1,1);
insert into t1 values (5,1,1);

select * from t1;

drop table t1;

#
# Bug #32247 Test reports wrong value of "AUTO_INCREMENT" (on a partitioned InnoDB table)
#   (though reported as InnoDB bug, requires some ARCHIVE tests

create table t1 (a int) engine=archive partition by hash(a);
show create table t1;
drop table t1;

CREATE TABLE t1(id MEDIUMINT NOT NULL AUTO_INCREMENT,
                f1 VARCHAR(25),
                PRIMARY KEY(id)) ENGINE=ARCHIVE
                     PARTITION BY RANGE(id)
                     SUBPARTITION BY hash(id) subpartitions 2
                     (PARTITION pa1 values less than (10),
                      PARTITION pa2 values less than (20),
                      PARTITION pa3 values less than (30),
                      PARTITION pa4 values less than (40),
                      PARTITION pa5 values less than (50),
                      PARTITION pa6 values less than (60),
                      PARTITION pa7 values less than (70),
                      PARTITION pa8 values less than (80),
                      PARTITION pa9 values less than (90),
                      PARTITION pa10 values less than (100),
                      PARTITION pa11 values less than MAXVALUE);

--disable_query_log
let $n= 100;
begin;
while ($n)
{
  insert into t1 (f1) values (repeat('a',25));
  dec $n;
}
commit;
--enable_query_log

show create table t1;
select count(*) from t1;
drop table t1;


--echo #
--echo #BUG 18618561: FAILED ALTER TABLE ENGINE CHANGE WITH PARTITIONS
--echo #              CORRUPTS FRM

CREATE TABLE t1 (fld1 INT PRIMARY KEY) ENGINE= MYISAM PARTITION BY HASH(fld1)
PARTITIONS 5;
SHOW CREATE TABLE t1;

--error ER_CANT_CREATE_TABLE
ALTER TABLE t1 ENGINE= ARCHIVE;

--echo #After the patch, the ENGINE is correctly displayed as MyISAM
SHOW CREATE TABLE t1;

--echo #Cleanup.
DROP TABLE t1;

create database mysqltest1;
create table mysqltest1.t1 (a int not null, b int not null) engine=archive
  partition by list(a) subpartition by hash(b)
  (partition p1 values in (1),
   partition p2 values in (2));
drop database mysqltest1;