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
|
-- source include/not_embedded.inc
--echo #
--echo # MDEV-20751: query using many CTEs with grant_tables enabled
--echo #
--connection default
CREATE DATABASE db;
USE db;
CREATE TABLE t1 (a int) ENGINE=MYISAM;
INSERT INTO t1 VALUES (3), (7), (1);
CREATE TABLE t2 (a int) ENGINE=MYISAM;
INSERT INTO t2 VALUES (2), (8), (4);
CREATE USER 'u1'@'localhost';
GRANT USAGE ON db.* TO 'u1'@'localhost';
GRANT SELECT ON db.t1 TO 'u1'@'localhost';
FLUSH PRIVILEGES;
--connect (u1,'localhost',u1,,)
--connection u1
USE db;
WITH
cte1 AS
(SELECT a FROM t1),
cte2 AS
(SELECT cte1.a FROM t1,cte1 WHERE cte1.a = t1.a),
cte3 AS
(SELECT cte2.a FROM t1,cte1,cte2 WHERE cte1.a = t1.a AND t1.a = cte2.a),
cte4 AS
(SELECT cte2.a FROM t1,cte2 WHERE cte2.a = t1.a)
SELECT * FROM cte4 as r;
--error ER_TABLEACCESS_DENIED_ERROR
WITH
cte1 AS
(SELECT a FROM t2),
cte2 AS
(SELECT cte1.a FROM t2,cte1 WHERE cte1.a = t2.a),
cte3 AS
(SELECT cte2.a FROM t2,cte1,cte2 WHERE cte1.a = t2.a AND t2.a = cte2.a),
cte4 AS
(SELECT cte2.a FROM t2,cte2 WHERE cte2.a = t2.a)
SELECT * FROM cte4 as r;
--disconnect u1
--connection default
DROP USER 'u1'@'localhost';
DROP DATABASE db;
USE test;
--echo # End of 10.2 tests
|