1DROP TABLE IF EXISTS t1, t2;
2#
3# BUG#11933226 - 60681: CHECKSUM TABLE RETURNS 0 FOR PARTITIONED TABLE
4#
5CREATE TABLE t1 (
6i INT
7)
8ENGINE=MyISAM
9PARTITION BY RANGE (i)
10(PARTITION p3 VALUES LESS THAN (3),
11PARTITION p5 VALUES LESS THAN (5),
12PARTITION pMax VALUES LESS THAN MAXVALUE);
13INSERT INTO t1 VALUES (1), (2), (3), (4), (5), (6);
14CHECKSUM TABLE t1;
15Table	Checksum
16test.t1	2653438147
17ALTER TABLE t1 CHECKSUM = 1;
18CHECKSUM TABLE t1 EXTENDED;
19Table	Checksum
20test.t1	2653438147
21# Before patch this returned 0!
22CHECKSUM TABLE t1;
23Table	Checksum
24test.t1	2653438147
25SHOW CREATE TABLE t1;
26Table	Create Table
27t1	CREATE TABLE `t1` (
28  `i` int(11) DEFAULT NULL
29) ENGINE=MyISAM DEFAULT CHARSET=latin1 CHECKSUM=1
30 PARTITION BY RANGE (`i`)
31(PARTITION `p3` VALUES LESS THAN (3) ENGINE = MyISAM,
32 PARTITION `p5` VALUES LESS THAN (5) ENGINE = MyISAM,
33 PARTITION `pMax` VALUES LESS THAN MAXVALUE ENGINE = MyISAM)
34DROP TABLE t1;
35# Same test without partitioning
36CREATE TABLE t1 (
37i INT
38) ENGINE=MyISAM;
39SHOW CREATE TABLE t1;
40Table	Create Table
41t1	CREATE TABLE `t1` (
42  `i` int(11) DEFAULT NULL
43) ENGINE=MyISAM DEFAULT CHARSET=latin1
44INSERT INTO t1 VALUES (1), (2), (3), (4), (5), (6);
45CHECKSUM TABLE t1;
46Table	Checksum
47test.t1	2653438147
48ALTER TABLE t1 CHECKSUM = 1;
49CHECKSUM TABLE t1 EXTENDED;
50Table	Checksum
51test.t1	2653438147
52CHECKSUM TABLE t1;
53Table	Checksum
54test.t1	2653438147
55SHOW CREATE TABLE t1;
56Table	Create Table
57t1	CREATE TABLE `t1` (
58  `i` int(11) DEFAULT NULL
59) ENGINE=MyISAM DEFAULT CHARSET=latin1 CHECKSUM=1
60DROP TABLE t1;
61#
62# Bug#31931: Mix of handlers error message
63#
64CREATE TABLE t1 (a INT)
65PARTITION BY HASH (a)
66( PARTITION p0 ENGINE=MyISAM,
67PARTITION p1);
68ERROR HY000: The mix of handlers in the partitions is not allowed in this version of MariaDB
69CREATE TABLE t1 (a INT)
70PARTITION BY LIST (a)
71SUBPARTITION BY HASH (a)
72( PARTITION p0 VALUES IN (0)
73( SUBPARTITION s0, SUBPARTITION s1 ENGINE=MyISAM, SUBPARTITION s2),
74PARTITION p1 VALUES IN (1)
75( SUBPARTITION s3 ENGINE=MyISAM, SUBPARTITION s4, SUBPARTITION s5 ENGINE=MyISAM));
76ERROR HY000: The mix of handlers in the partitions is not allowed in this version of MariaDB
77#
78# Bug#49161: Out of memory; restart server and try again (needed 2 bytes)
79#
80CREATE TABLE t1 (a INT)
81ENGINE = MyISAM
82PARTITION BY HASH (a);
83FLUSH TABLES;
84CHECK TABLE t1;
85Table	Op	Msg_type	Msg_text
86test.t1	check	Error	Failed to read from the .par file
87test.t1	check	error	Corrupt
88SELECT * FROM t1;
89ERROR HY000: Failed to read from the .par file
90# Note that it is currently impossible to drop a partitioned table
91# without the .par file
92DROP TABLE t1;
93ERROR HY000: Got error 1 "Operation not permitted" from storage engine partition
94#
95# Bug#50392: insert_id is not reset for partitioned tables
96#            auto_increment on duplicate entry
97CREATE TABLE t1 (a INT AUTO_INCREMENT PRIMARY KEY)
98ENGINE = MyISAM;
99SET INSERT_ID= 13;
100INSERT INTO t1 VALUES (NULL);
101SET INSERT_ID= 12;
102# For transactional engines, 12 will not be inserted, since the failing
103# statement is rolled back.
104INSERT INTO t1 VALUES (NULL), (NULL), (NULL);
105ERROR 23000: Duplicate entry '13' for key 'PRIMARY'
106SHOW CREATE TABLE t1;
107Table	Create Table
108t1	CREATE TABLE `t1` (
109  `a` int(11) NOT NULL AUTO_INCREMENT,
110  PRIMARY KEY (`a`)
111) ENGINE=MyISAM AUTO_INCREMENT=14 DEFAULT CHARSET=latin1
112INSERT INTO t1 VALUES (NULL);
113# NOTE: 12 exists only in non transactional engines!
114SELECT * FROM t1;
115a
11612
11713
11814
119DROP TABLE t1;
120CREATE TABLE t1 (a INT AUTO_INCREMENT PRIMARY KEY)
121ENGINE = MyISAM
122PARTITION BY KEY(a);
123SET INSERT_ID= 13;
124INSERT INTO t1 VALUES (NULL);
125SET INSERT_ID= 12;
126INSERT INTO t1 VALUES (NULL), (NULL), (NULL);
127ERROR 23000: Duplicate entry '13' for key 'PRIMARY'
128SHOW CREATE TABLE t1;
129Table	Create Table
130t1	CREATE TABLE `t1` (
131  `a` int(11) NOT NULL AUTO_INCREMENT,
132  PRIMARY KEY (`a`)
133) ENGINE=MyISAM AUTO_INCREMENT=14 DEFAULT CHARSET=latin1
134 PARTITION BY KEY (`a`)
135INSERT INTO t1 VALUES (NULL);
136SELECT * FROM t1;
137a
13812
13913
14014
141DROP TABLE t1;
142# Bug#30102 test
143CREATE TABLE t1 (a INT)
144ENGINE = MyISAM
145PARTITION BY RANGE (a)
146(PARTITION p0 VALUES LESS THAN (6),
147PARTITION `p1....................` VALUES LESS THAN (9),
148PARTITION p2 VALUES LESS THAN MAXVALUE);
149# List of files in database `test`, all original t1-files here
150t1#P#p0.MYD
151t1#P#p0.MYI
152t1#P#p1@002e@002e@002e@002e@002e@002e@002e@002e@002e@002e@002e@002e@002e@002e@002e@002e@002e@002e@002e@002e.MYD
153t1#P#p1@002e@002e@002e@002e@002e@002e@002e@002e@002e@002e@002e@002e@002e@002e@002e@002e@002e@002e@002e@002e.MYI
154t1#P#p2.MYD
155t1#P#p2.MYI
156t1.frm
157t1.par
158INSERT INTO t1 VALUES (1), (2), (3), (4), (5), (6), (7), (8), (9), (10);
159# Renaming to a file name where the first partition is 250 chars
160# and the second partition is 350 chars
161RENAME TABLE t1 TO `t2_new..............................................end`;
162Got one of the listed errors
163# List of files in database `test`, should not be any t2-files here
164# List of files in database `test`, should be all t1-files here
165t1#P#p0.MYD
166t1#P#p0.MYI
167t1#P#p1@002e@002e@002e@002e@002e@002e@002e@002e@002e@002e@002e@002e@002e@002e@002e@002e@002e@002e@002e@002e.MYD
168t1#P#p1@002e@002e@002e@002e@002e@002e@002e@002e@002e@002e@002e@002e@002e@002e@002e@002e@002e@002e@002e@002e.MYI
169t1#P#p2.MYD
170t1#P#p2.MYI
171t1.frm
172t1.par
173SELECT * FROM t1;
174a
1751
17610
1772
1783
1794
1805
1816
1827
1838
1849
185# List of files in database `test`, should be all t1-files here
186t1#P#p0.MYD
187t1#P#p0.MYI
188t1#P#p1@002e@002e@002e@002e@002e@002e@002e@002e@002e@002e@002e@002e@002e@002e@002e@002e@002e@002e@002e@002e.MYD
189t1#P#p1@002e@002e@002e@002e@002e@002e@002e@002e@002e@002e@002e@002e@002e@002e@002e@002e@002e@002e@002e@002e.MYI
190t1#P#p2.MYD
191t1#P#p2.MYI
192t1.frm
193t1.par
194# Renaming to a file name where the first partition is 156 chars
195# and the second partition is 256 chars
196RENAME TABLE t1 TO `t2_............................_end`;
197Got one of the listed errors
198# List of files in database `test`, should not be any t2-files here
199# List of files in database `test`, should be all t1-files here
200t1#P#p0.MYD
201t1#P#p0.MYI
202t1#P#p1@002e@002e@002e@002e@002e@002e@002e@002e@002e@002e@002e@002e@002e@002e@002e@002e@002e@002e@002e@002e.MYD
203t1#P#p1@002e@002e@002e@002e@002e@002e@002e@002e@002e@002e@002e@002e@002e@002e@002e@002e@002e@002e@002e@002e.MYI
204t1#P#p2.MYD
205t1#P#p2.MYI
206t1.frm
207t1.par
208SELECT * FROM t1;
209a
2101
21110
2122
2133
2144
2155
2166
2177
2188
2199
220DROP TABLE t1;
221# Should not be any files left here
222# End of bug#30102 test.
223# Test of post-push fix for bug#11766249/59316
224CREATE TABLE t1 (a INT, b VARCHAR(255), PRIMARY KEY (a))
225ENGINE = MyISAM
226PARTITION BY RANGE (a)
227(PARTITION p0 VALUES LESS THAN (0) MAX_ROWS=100,
228PARTITION p1 VALUES LESS THAN (100) MAX_ROWS=100,
229PARTITION pMax VALUES LESS THAN MAXVALUE);
230INSERT INTO t1 VALUES (1, "Partition p1, first row");
231DROP TABLE t1;
232#
233# MDEV-10418 Assertion `m_extra_cache' failed
234#    in ha_partition::late_extra_cache(uint)
235#
236CREATE TABLE t1 (f1 INT) ENGINE=MyISAM;
237INSERT INTO t1 VALUES (1),(2);
238CREATE TABLE t2 (f2 INT) ENGINE=MyISAM PARTITION BY RANGE(f2) (PARTITION pmax VALUES LESS THAN MAXVALUE);
239INSERT INTO t2 VALUES (8);
240CREATE ALGORITHM = MERGE VIEW v AS SELECT f2 FROM t2, t1;
241UPDATE v SET f2 = 1;
242SELECT * FROM t2;
243f2
2441
245DROP VIEW v;
246DROP TABLE t2;
247DROP TABLE t1;
248#
249# bug#11760213-52599: ALTER TABLE REMOVE PARTITIONING ON NON-PARTITIONED
250#                                 TABLE CORRUPTS MYISAM
251DROP TABLE if exists `t1`;
252CREATE TABLE  `t1`(`a` INT)ENGINE=myisam;
253ALTER TABLE `t1` ADD COLUMN `b` INT;
254CREATE UNIQUE INDEX `i1` ON `t1`(`b`);
255CREATE UNIQUE INDEX `i2` ON `t1`(`a`);
256ALTER TABLE `t1` ADD PRIMARY KEY  (`a`);
257ALTER TABLE `t1` REMOVE PARTITIONING;
258ERROR HY000: Partition management on a not partitioned table is not possible
259CHECK TABLE `t1` EXTENDED;
260Table	Op	Msg_type	Msg_text
261test.t1	check	status	OK
262DROP TABLE t1;
263