Commit dcc35b66 authored by Sergei Golubchik's avatar Sergei Golubchik

extract privilege tests from delete_returning.test into delete_returning_grant.test

that is not run for embedded server
parent 1989ae9e
......@@ -167,72 +167,6 @@ a b
5 EEEEE
7 GGGGGGG
DEALLOCATE PREPARE stmt;
DELETE FROM t1;
INSERT INTO t1 SELECT * FROM t1c;
FLUSH PRIVILEGES;
CREATE DATABASE mysqltest;
CREATE TABLE mysqltest.t1 SELECT * FROM t1;
GRANT DELETE ON mysqltest.* TO mysqltest_1@localhost;
GRANT SELECT(b) ON mysqltest.t1 TO mysqltest_1@localhost;
DELETE FROM mysqltest.t1 WHERE a=2 RETURNING b;
ERROR 42000: SELECT command denied to user 'mysqltest_1'@'localhost' for column 'a' in table 't1'
DELETE FROM mysqltest.t1 RETURNING b;
b
ggggggg
a
ccc
dddd
A
BB
DDDD
EEEEE
GGGGGGG
bb
SELECT * FROM mysqltest.t1;
a b
INSERT INTO mysqltest.t1 SELECT * FROM t1;
GRANT SELECT(a) ON mysqltest.t1 TO mysqltest_1@localhost;
DELETE FROM mysqltest.t1 WHERE a=2 RETURNING b;
b
bb
BB
SELECT * FROM mysqltest.t1;
a b
7 GGGGGGG
5 EEEEE
4 DDDD
1 A
4 dddd
3 ccc
1 a
7 ggggggg
INSERT INTO mysqltest.t1 SELECT * FROM t1;
CREATE VIEW mysqltest.v1(a) AS SELECT a FROM mysqltest.t1;
GRANT SELECT, INSERT ON mysqltest.t1 TO mysqltest_1@localhost;
DELETE FROM mysqltest.v1;
SELECT * FROM mysqltest.t1;
a b
INSERT INTO mysqltest.t1 SELECT * FROM t1;
DELETE FROM mysqltest.v1 RETURNING a;
ERROR 42000: SELECT command denied to user 'mysqltest_1'@'localhost' for column 'a' in table 'v1'
GRANT SELECT ON mysqltest.* TO mysqltest_1@localhost;
DELETE FROM mysqltest.v1 RETURNING a;
a
7
1
3
4
1
2
4
5
7
2
SELECT * FROM mysqltest.t1;
a b
INSERT INTO mysqltest.t1 SELECT * FROM t1;
DROP DATABASE mysqltest;
DROP USER mysqltest_1@localhost;
DROP VIEW v1;
DROP TABLE t1,t2;
DROP TABLE t1c,t2c;
......
CREATE TABLE t1 (a int(11), b varchar(32));
INSERT INTO t1 VALUES (7,'ggggggg'),(1,'a'),(3,'ccc'),(4,'dddd'),(1,'A'),
(2,'BB'),(4,'DDDD'),(5,'EEEEE'),(7,'GGGGGGG'),(2,'bb');
CREATE VIEW v1 AS SELECT a, UPPER(b) FROM t1;
CREATE DATABASE mysqltest;
CREATE TABLE mysqltest.t1 SELECT * FROM t1;
GRANT DELETE ON mysqltest.* TO mysqltest_1@localhost;
GRANT SELECT(b) ON mysqltest.t1 TO mysqltest_1@localhost;
DELETE FROM mysqltest.t1 WHERE a=2 RETURNING b;
ERROR 42000: SELECT command denied to user 'mysqltest_1'@'localhost' for column 'a' in table 't1'
DELETE FROM mysqltest.t1 RETURNING b;
b
ggggggg
a
ccc
dddd
A
BB
DDDD
EEEEE
GGGGGGG
bb
SELECT * FROM mysqltest.t1;
a b
INSERT INTO mysqltest.t1 SELECT * FROM t1;
GRANT SELECT(a) ON mysqltest.t1 TO mysqltest_1@localhost;
DELETE FROM mysqltest.t1 WHERE a=2 RETURNING b;
b
bb
BB
SELECT * FROM mysqltest.t1;
a b
7 GGGGGGG
5 EEEEE
4 DDDD
1 A
4 dddd
3 ccc
1 a
7 ggggggg
INSERT INTO mysqltest.t1 SELECT * FROM t1;
CREATE VIEW mysqltest.v1(a) AS SELECT a FROM mysqltest.t1;
GRANT SELECT, INSERT ON mysqltest.t1 TO mysqltest_1@localhost;
DELETE FROM mysqltest.v1;
SELECT * FROM mysqltest.t1;
a b
INSERT INTO mysqltest.t1 SELECT * FROM t1;
DELETE FROM mysqltest.v1 RETURNING a;
ERROR 42000: SELECT command denied to user 'mysqltest_1'@'localhost' for column 'a' in table 'v1'
GRANT SELECT ON mysqltest.* TO mysqltest_1@localhost;
DELETE FROM mysqltest.v1 RETURNING a;
a
7
1
3
4
1
2
4
5
7
2
SELECT * FROM mysqltest.t1;
a b
INSERT INTO mysqltest.t1 SELECT * FROM t1;
DROP DATABASE mysqltest;
DROP USER mysqltest_1@localhost;
DROP VIEW v1;
DROP TABLE t1;
......@@ -117,75 +117,6 @@ EXECUTE stmt;
SELECT * FROM t1;
DEALLOCATE PREPARE stmt;
DELETE FROM t1;
INSERT INTO t1 SELECT * FROM t1c;
# DELETE FROM <table> ... RETURNING ... with checking privileges
FLUSH PRIVILEGES;
connect (root,localhost,root,,test);
connection root;
--disable_warnings
CREATE DATABASE mysqltest;
--enable_warnings
CREATE TABLE mysqltest.t1 SELECT * FROM t1;
GRANT DELETE ON mysqltest.* TO mysqltest_1@localhost;
GRANT SELECT(b) ON mysqltest.t1 TO mysqltest_1@localhost;
connect (user1,localhost,mysqltest_1,,test);
connection user1;
--error ER_COLUMNACCESS_DENIED_ERROR
DELETE FROM mysqltest.t1 WHERE a=2 RETURNING b;
DELETE FROM mysqltest.t1 RETURNING b;
connection root;
SELECT * FROM mysqltest.t1;
INSERT INTO mysqltest.t1 SELECT * FROM t1;
GRANT SELECT(a) ON mysqltest.t1 TO mysqltest_1@localhost;
DELETE FROM mysqltest.t1 WHERE a=2 RETURNING b;
SELECT * FROM mysqltest.t1;
INSERT INTO mysqltest.t1 SELECT * FROM t1;
connection root;
CREATE VIEW mysqltest.v1(a) AS SELECT a FROM mysqltest.t1;
GRANT SELECT, INSERT ON mysqltest.t1 TO mysqltest_1@localhost;
connection user1;
DELETE FROM mysqltest.v1;
SELECT * FROM mysqltest.t1;
INSERT INTO mysqltest.t1 SELECT * FROM t1;
--error ER_COLUMNACCESS_DENIED_ERROR
DELETE FROM mysqltest.v1 RETURNING a;
connection root;
GRANT SELECT ON mysqltest.* TO mysqltest_1@localhost;
connection user1;
DELETE FROM mysqltest.v1 RETURNING a;
SELECT * FROM mysqltest.t1;
INSERT INTO mysqltest.t1 SELECT * FROM t1;
connection root;
--disable_warnings
DROP DATABASE mysqltest;
--enable_warnings
disconnect user1;
DROP USER mysqltest_1@localhost;
# Cleanup
DROP VIEW v1;
DROP TABLE t1,t2;
......
#
# Tests for DELETE FROM <table> ... RETURNING <expr>,...
#
--source include/not_embedded.inc
CREATE TABLE t1 (a int(11), b varchar(32));
INSERT INTO t1 VALUES (7,'ggggggg'),(1,'a'),(3,'ccc'),(4,'dddd'),(1,'A'),
(2,'BB'),(4,'DDDD'),(5,'EEEEE'),(7,'GGGGGGG'),(2,'bb');
CREATE VIEW v1 AS SELECT a, UPPER(b) FROM t1;
# DELETE FROM <table> ... RETURNING ... with checking privileges
connect (root,localhost,root,,test);
connection root;
--disable_warnings
CREATE DATABASE mysqltest;
--enable_warnings
CREATE TABLE mysqltest.t1 SELECT * FROM t1;
GRANT DELETE ON mysqltest.* TO mysqltest_1@localhost;
GRANT SELECT(b) ON mysqltest.t1 TO mysqltest_1@localhost;
connect (user1,localhost,mysqltest_1,,test);
connection user1;
--error ER_COLUMNACCESS_DENIED_ERROR
DELETE FROM mysqltest.t1 WHERE a=2 RETURNING b;
DELETE FROM mysqltest.t1 RETURNING b;
connection root;
SELECT * FROM mysqltest.t1;
INSERT INTO mysqltest.t1 SELECT * FROM t1;
GRANT SELECT(a) ON mysqltest.t1 TO mysqltest_1@localhost;
DELETE FROM mysqltest.t1 WHERE a=2 RETURNING b;
SELECT * FROM mysqltest.t1;
INSERT INTO mysqltest.t1 SELECT * FROM t1;
connection root;
CREATE VIEW mysqltest.v1(a) AS SELECT a FROM mysqltest.t1;
GRANT SELECT, INSERT ON mysqltest.t1 TO mysqltest_1@localhost;
connection user1;
DELETE FROM mysqltest.v1;
SELECT * FROM mysqltest.t1;
INSERT INTO mysqltest.t1 SELECT * FROM t1;
--error ER_COLUMNACCESS_DENIED_ERROR
DELETE FROM mysqltest.v1 RETURNING a;
connection root;
GRANT SELECT ON mysqltest.* TO mysqltest_1@localhost;
connection user1;
DELETE FROM mysqltest.v1 RETURNING a;
SELECT * FROM mysqltest.t1;
INSERT INTO mysqltest.t1 SELECT * FROM t1;
connection root;
--disable_warnings
DROP DATABASE mysqltest;
--enable_warnings
disconnect user1;
DROP USER mysqltest_1@localhost;
# Cleanup
DROP VIEW v1;
DROP TABLE t1;
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment