MySQL 5.6.14 Source Code Document
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
part_exch_qa_5.inc
1 --source include/not_embedded.inc
2 
3 CREATE USER test1@localhost;
4 CREATE USER test2@localhost;
5 GRANT USAGE ON *.* TO test1@localhost;
6 GRANT USAGE ON *.* TO test2@localhost;
7 GRANT CREATE, DROP, INSERT, SELECT ON test.* TO test1@localhost;
8 GRANT CREATE, DROP, ALTER, UPDATE, INSERT, SELECT ON test.* TO test2@localhost;
9 
10 --echo connect (test1,localhost,test1,,test,MASTER_MYPORT,MASTER_MYSOCK);
11 connect (test1,localhost,test1,,test,$MASTER_MYPORT,$MASTER_MYSOCK);
12 SELECT current_user();
13 SHOW GRANTS FOR CURRENT_USER;
14 --disable_result_log
15 --disable_query_log
16 --source suite/parts/inc/part_exch_tabs.inc
17 --enable_result_log
18 --enable_query_log
19 --error ER_TABLEACCESS_DENIED_ERROR
20 ALTER TABLE tp EXCHANGE PARTITION p0 WITH TABLE t_10;
21 --echo disconnect test1;
22 disconnect test1;
23 
24 
25 --echo connect (test2,localhost,test2,,test,MASTER_MYPORT,MASTER_MYSOCK);
26 connect (test2,localhost,test2,,test,$MASTER_MYPORT,$MASTER_MYSOCK);
27 USE test;
28 SELECT current_user();
29 SHOW GRANTS FOR CURRENT_USER;
30 
31 # 9) Exchanges with different owner.
32 # Privilege for ALTER and SELECT
33 ALTER TABLE tp EXCHANGE PARTITION p0 WITH TABLE t_10;
34 --sorted_result
35 SELECT * FROM t_10;
36 --sorted_result
37 SELECT * FROM tp WHERE a BETWEEN 0 AND 10;
38 # Back to former values.
39 ALTER TABLE tp EXCHANGE PARTITION p0 WITH TABLE t_10;
40 --sorted_result
41 SELECT * FROM t_10;
42 --sorted_result
43 SELECT * FROM tp WHERE a BETWEEN 0 AND 10;
44 ALTER TABLE tsp EXCHANGE PARTITION sp00 WITH TABLE tsp_00;
45 --sorted_result
46 SELECT * FROM tsp_00;
47 --sorted_result
48 SELECT * FROM tsp WHERE a BETWEEN 0 AND 10;
49 # Back to former values.
50 ALTER TABLE tsp EXCHANGE PARTITION sp00 WITH TABLE tsp_00;
51 --sorted_result
52 SELECT * FROM tsp_00;
53 --sorted_result
54 SELECT * FROM tsp WHERE a BETWEEN 0 AND 10;
55 --echo disconnect test2;
56 disconnect test2;
57 
58 --echo connection default;
59 connection default;
60 REVOKE ALTER ON test.* FROM test2@localhost;
61 
62 --echo connect (test2,localhost,test2,,test,MASTER_MYPORT,MASTER_MYSOCK);
63 connect (test2,localhost,test2,,test,$MASTER_MYPORT,$MASTER_MYSOCK);
64 USE test;
65 SELECT current_user();
66 SHOW GRANTS FOR CURRENT_USER;
67 # Privilege for ALTER and SELECT
68 --error ER_TABLEACCESS_DENIED_ERROR
69 ALTER TABLE tp EXCHANGE PARTITION p0 WITH TABLE t_10;
70 SELECT * FROM tp WHERE a BETWEEN 0 AND 10;
71 # Back to former values.
72 --error ER_TABLEACCESS_DENIED_ERROR
73 ALTER TABLE tp EXCHANGE PARTITION p0 WITH TABLE t_10;
74 --error ER_TABLEACCESS_DENIED_ERROR
75 ALTER TABLE tsp EXCHANGE PARTITION sp00 WITH TABLE tsp_00;
76 # Back to former values.
77 --error ER_TABLEACCESS_DENIED_ERROR
78 ALTER TABLE tsp EXCHANGE PARTITION sp00 WITH TABLE tsp_00;
79 
80 --echo connection default;
81 connection default;
82 --echo disconnect test2;
83 disconnect test2;
84 
85 --source suite/parts/inc/part_exch_drop_tabs.inc
86 
87 DROP USER test1@localhost;
88 DROP USER test2@localhost;
89