summaryrefslogtreecommitdiff
path: root/mysql-test/t/cte_grant.test
diff options
context:
space:
mode:
Diffstat (limited to 'mysql-test/t/cte_grant.test')
-rw-r--r--mysql-test/t/cte_grant.test53
1 files changed, 52 insertions, 1 deletions
diff --git a/mysql-test/t/cte_grant.test b/mysql-test/t/cte_grant.test
index 44fd4a0bc6e..c6627c05829 100644
--- a/mysql-test/t/cte_grant.test
+++ b/mysql-test/t/cte_grant.test
@@ -76,4 +76,55 @@ select * from mysqltest.v3;
connection root;
revoke all privileges on mysqltest.v1 from mysqltest_1@localhost;
drop user mysqltest_1@localhost;
-drop database mysqltest; \ No newline at end of file
+drop database mysqltest;
+
+--echo #
+--echo # MDEV-13453: privileges checking for CTE
+--echo #
+
+create database db;
+use db;
+create table t1 (i int);
+insert into t1
+ values (3), (7), (1), (4), (2), (3), (1);
+
+create table t2 (a int, b int);
+insert into t2
+ values (3,10), (7,11), (1,17), (4,15), (2,11), (3,10), (1,15);
+
+create user foo@localhost;
+grant SELECT on db.t1 to foo@localhost;
+grant SELECT(a) on db.t2 to foo@localhost;
+
+--connect (con1,localhost,foo,,)
+use db;
+with cte as (select * from t1 where i < 4)
+ select * from cte;
+with cte as (select * from t1 where i < 4 group by i)
+ select * from cte;
+with cte as (select * from t1 where i < 4)
+ select * from cte cte1 where i < 2 union select * from cte cte2 where i > 2;
+with cte as (select * from t1 where i < 4 group by i)
+ select * from cte cte1 where i < 2 union select * from cte cte2 where i > 2;
+
+--error ER_COLUMNACCESS_DENIED_ERROR
+with cte as (select b from t2 where a < 4)
+ select * from cte cte1 where b < 15 union select * from cte cte2 where b > 15;
+with cte as (select a from t2 where a < 4)
+ select * from cte cte1 where a < 2 union select * from cte cte2 where a > 2;
+
+--connection default
+revoke SELECT on db.t1 from foo@localhost;
+
+--connection con1
+
+--error ER_TABLEACCESS_DENIED_ERROR
+with cte as (select * from t1 where i < 4)
+ select * from cte;
+
+# Cleanup
+--disconnect con1
+
+--connection default
+drop database db;
+drop user foo@localhost;