# Additional tests for WL#5217 by QA, testplan 1.1
INSERT INTO t1 PARTITION (pNeg, subp0) VALUES (-4, '(pNeg-)subp0');
INSERT INTO t1 PARTITION (pNeg, subp0) VALUES (-3, '(pNeg-)subp0');
INSERT INTO t1 PARTITION (pNeg, subp0) VALUES (-2, '(pNeg-)subp0');
INSERT INTO t1 PARTITION (pNeg, subp0) VALUES (-1, '(pNeg-)subp0');
INSERT INTO t1 PARTITION (`p0-29`, subp3) VALUES (4, '(p0-29-)subp3');
INSERT INTO t1 PARTITION (`p0-29`, subp3) VALUES (3, '(p0-29-)subp3');
INSERT INTO t1 PARTITION (`p0-29`, subp3) VALUES (2, '(p0-29-)subp3');
INSERT INTO t1 PARTITION (`p0-29`, subp3) VALUES (1, '(p0-29-)subp3');
INSERT INTO t1 PARTITION (`p0-29`, subp5) VALUES (24, '(p0-29-)subp5');
INSERT INTO t1 PARTITION (`p0-29`, subp5) VALUES (23, '(p0-29-)subp5');
INSERT INTO t1 PARTITION (`p0-29`, subp5) VALUES (22, '(p0-29-)subp5');
INSERT INTO t1 PARTITION (`p0-29`, subp5) VALUES (21, '(p0-29-)subp5');
INSERT INTO t1 PARTITION (`p30-299`, subp9) VALUES (34, '(p30-299-)subp6');
INSERT INTO t1 PARTITION (`p30-299`, subp9) VALUES (33, '(p30-299-)subp6');
INSERT INTO t1 PARTITION (`p30-299`, subp9) VALUES (32, '(p30-299-)subp6');
INSERT INTO t1 PARTITION (`p30-299`, subp9) VALUES (31, '(p30-299-)subp6');
INSERT INTO t1 PARTITION (`p30-299`, subp8) VALUES (234, '(p30-299-)subp8');
INSERT INTO t1 PARTITION (`p30-299`, subp8) VALUES (233, '(p30-299-)subp8');
INSERT INTO t1 PARTITION (`p30-299`, subp8) VALUES (232, '(p30-299-)subp8');
INSERT INTO t1 PARTITION (`p30-299`, subp8) VALUES (231, '(p30-299-)subp8');
INSERT INTO t1 PARTITION (`p300-2999`, subp8) VALUES (304, '(p300-2999-)subp8');
INSERT INTO t1 PARTITION (`p300-2999`, subp8) VALUES (303, '(p300-2999-)subp8');
INSERT INTO t1 PARTITION (`p300-2999`, subp8) VALUES (302, '(p300-2999-)subp8');
INSERT INTO t1 PARTITION (`p300-2999`, subp8) VALUES (301, '(p300-2999-)subp8');
INSERT INTO t1 PARTITION (`p3000-299999`, subp12) VALUES (3004, '(p3000-299999-)subp12');
INSERT INTO t1 PARTITION (`p3000-299999`, subp12) VALUES (3003, '(p3000-299999-)subp12');
INSERT INTO t1 PARTITION (`p3000-299999`, subp12) VALUES (3002, '(p3000-299999-)subp12');
INSERT INTO t1 PARTITION (`p3000-299999`, subp12) VALUES (3001, '(p3000-299999-)subp12');
INSERT INTO t1 PARTITION (`p3000-299999`, subp14) VALUES (299996, '(p3000-299999-)subp14');
INSERT INTO t1 PARTITION (`p3000-299999`, subp14) VALUES (299997, '(p3000-299999-)subp14');
INSERT INTO t1 PARTITION (`p3000-299999`, subp14) VALUES (299998, '(p3000-299999-)subp14');
INSERT INTO t1 PARTITION (`p3000-299999`, subp14) VALUES (299999, '(p3000-299999-)subp14');
GRANT ALL PRIVILEGES ON test.* TO test_user_1 IDENTIFIED BY 'testpw';
GRANT ALL PRIVILEGES ON test.* TO test_user_2 IDENTIFIED BY 'testpw';
# FILE is needed to use the DATA DIRECTORY or INDEX DIRECTORY option
GRANT FILE ON *.* TO test_user_2 IDENTIFIED BY 'testpw';
connect  session1, localhost, test_user_1,'testpw',test;
SELECT * FROM t1 PARTITION (`p0-29`);
a	b
1	(p0-29-)subp3
2	(p0-29-)subp3
21	(p0-29-)subp5
22	(p0-29-)subp5
23	(p0-29-)subp5
24	(p0-29-)subp5
3	(p0-29-)subp3
4	(p0-29-)subp3
send
UPDATE t1 PARTITION (`p0-29`) SET b='p0-29-upd-1' WHERE a BETWEEN 0 AND 9;
connect  session2, localhost, test_user_2,'testpw',test;
SELECT * FROM t1 PARTITION (`p30-299`);
a	b
231	(p30-299-)subp8
232	(p30-299-)subp8
233	(p30-299-)subp8
234	(p30-299-)subp8
31	(p30-299-)subp6
32	(p30-299-)subp6
33	(p30-299-)subp6
34	(p30-299-)subp6
UPDATE t1 PARTITION (`p30-299`) SET b='p30-299-upd' WHERE a BETWEEN 30 AND 39;
SELECT * FROM t1 PARTITION (`p30-299`);
a	b
231	(p30-299-)subp8
232	(p30-299-)subp8
233	(p30-299-)subp8
234	(p30-299-)subp8
31	p30-299-upd
32	p30-299-upd
33	p30-299-upd
34	p30-299-upd
SELECT * FROM t1 PARTITION (`p300-2999`);
a	b
301	(p300-2999-)subp8
302	(p300-2999-)subp8
303	(p300-2999-)subp8
304	(p300-2999-)subp8
UPDATE t1 PARTITION (`p300-2999`) SET b='p300-2999-upd' WHERE a BETWEEN 300 AND 309;
SELECT * FROM t1 PARTITION (`p300-2999`);
a	b
301	p300-2999-upd
302	p300-2999-upd
303	p300-2999-upd
304	p300-2999-upd
SELECT * FROM t1 PARTITION (`p3000-299999`);
a	b
299996	(p3000-299999-)subp14
299997	(p3000-299999-)subp14
299998	(p3000-299999-)subp14
299999	(p3000-299999-)subp14
3001	(p3000-299999-)subp12
3002	(p3000-299999-)subp12
3003	(p3000-299999-)subp12
3004	(p3000-299999-)subp12
UPDATE t1 PARTITION (`p3000-299999`) SET b='p3000-299999-upd' WHERE a BETWEEN 3000 AND 3009;
SELECT * FROM t1 PARTITION (`p3000-299999`);
a	b
299996	(p3000-299999-)subp14
299997	(p3000-299999-)subp14
299998	(p3000-299999-)subp14
299999	(p3000-299999-)subp14
3001	p3000-299999-upd
3002	p3000-299999-upd
3003	p3000-299999-upd
3004	p3000-299999-upd
UPDATE t1 PARTITION (`p0-29`) SET b='p0-29-upd-2' WHERE a BETWEEN 0 AND 9;
SELECT * FROM t1 PARTITION (`p0-29`);
a	b
1	p0-29-upd-2
2	p0-29-upd-2
21	(p0-29-)subp5
22	(p0-29-)subp5
23	(p0-29-)subp5
24	(p0-29-)subp5
3	p0-29-upd-2
4	p0-29-upd-2
UPDATE t1 PARTITION (subp3) SET b='subp3-upd';
UPDATE t1 PARTITION (subp4) SET b='subp4-upd';
UPDATE t1 PARTITION (subp5) SET b='subp5-upd';
SELECT * FROM t1 PARTITION (subp3);
a	b
21	subp3-upd
24	subp3-upd
3	subp3-upd
SELECT * FROM t1 PARTITION (subp4);
a	b
1	subp4-upd
22	subp4-upd
4	subp4-upd
SELECT * FROM t1 PARTITION (subp5);
a	b
2	subp5-upd
23	subp5-upd
SELECT * FROM t1 PARTITION (subp4,subp5,subp3) order by b,a;
a	b
3	subp3-upd
21	subp3-upd
24	subp3-upd
1	subp4-upd
4	subp4-upd
22	subp4-upd
2	subp5-upd
23	subp5-upd
connection session1;
reap
SELECT * FROM t1 PARTITION (`p0-29`);
a	b
1	subp4-upd
2	subp5-upd
21	subp3-upd
22	subp4-upd
23	subp5-upd
24	subp3-upd
3	subp3-upd
4	subp4-upd
connection session2;
SELECT * FROM t1 PARTITION (`p0-29`);
a	b
1	subp4-upd
2	subp5-upd
21	subp3-upd
22	subp4-upd
23	subp5-upd
24	subp3-upd
3	subp3-upd
4	subp4-upd
SELECT 
(SELECT count(*) FROM t1 PARTITION (pneg,`p0-29`,`p30-299`,`p300-2999`,`p3000-299999`)) = 
(SELECT count(*) FROM t1) as `MUST BE TRUE (1)` ;
MUST BE TRUE (1)
1
SELECT * FROM t2 PARTITION (`p30-299`);
a	b
UPDATE t2 PARTITION (`p30-299`) SET b='p30-299-upd' WHERE a BETWEEN 30 AND 39;
DELETE FROM t2 PARTITION (`p30-299`) WHERE a BETWEEN 30 AND 39;
SELECT * FROM t2 PARTITION (`p300-2999`);
a	b
UPDATE t2 PARTITION (`p300-2999`) SET b='p300-2999-upd' WHERE a BETWEEN 300 AND 309;
DELETE FROM t2 PARTITION (`p300-2999`) WHERE a BETWEEN 300 AND 309;
SELECT * FROM t2 PARTITION (`p3000-299999`);
a	b
UPDATE t2 PARTITION (`p3000-299999`) SET b='p3000-299999-upd' WHERE a BETWEEN 3000 AND 3009;
DELETE FROM t2 PARTITION (`p3000-299999`) WHERE a BETWEEN 3000 AND 3009;
SELECT * FROM t2 PARTITION (`p0-29`);
a	b
UPDATE t2 PARTITION (`p0-29`) SET b='p0-29-upd-2' WHERE a BETWEEN 0 AND 9;
DELETE FROM t2 PARTITION (`p0-29`) WHERE a BETWEEN 0 AND 9;
UPDATE t2 PARTITION (subp3) SET b='subp3-upd';
DELETE FROM t2 PARTITION (subp3);
UPDATE t2 PARTITION (subp4) SET b='subp4-upd';
DELETE FROM t2 PARTITION (subp4);
UPDATE t2 PARTITION (subp5) SET b='subp5-upd';
DELETE FROM t2 PARTITION (subp5);
UPDATE t2 PARTITION (subp4,subp5,subp3) SET b='subp-upd';
DELETE FROM t2 PARTITION (subp4,subp5,subp3);
SELECT * FROM t2 PARTITION (subp3);
a	b
SELECT * FROM t2 PARTITION (subp4);
a	b
SELECT * FROM t2 PARTITION (subp5);
a	b
disconnect session1;
disconnect session2;
connection default;
DROP TABLE t1, t2;
DROP USER test_user_1;
DROP USER test_user_2;
