mirror of
https://github.com/MariaDB/server.git
synced 2025-07-29 05:21:33 +03:00
Fixed bug#21261: Wrong access rights was required for an insert into a view
SELECT right instead of INSERT right was required for an insert into to a view. This wrong behaviour appeared after the fix for bug #20989. Its intention was to ask only SELECT right for all tables except the very first for a complex INSERT query. But that patch has done it in a wrong way and lead to asking a wrong access right for an insert into a view. The setup_tables_and_check_access() function now accepts two want_access parameters. One will be used for the first table and the second for other tables. mysql-test/t/view.test: Added a test case for bug#21261: Wrong access rights was required for an insert into a view mysql-test/r/view.result: Added a test case for bug#21261: Wrong access rights was required for an insert into a view sql/sql_update.cc: Fixed bug#21261: Wrong access rights was required for an insert into a view Modified to use updated setup_tables_and_check_access() function. sql/sql_select.cc: Fixed bug#21261: Wrong access rights was required for an insert into a view Modified to use updated setup_tables_and_check_access() function. sql/sql_load.cc: Fixed bug#21261: Wrong access rights was required for an insert into a view Modified to use updated setup_tables_and_check_access() function. sql/sql_insert.cc: Fixed bug#21261: Wrong access rights was required for an insert into a view Modified to use updated setup_tables_and_check_access() function. sql/sql_delete.cc: Fixed bug#21261: Wrong access rights was required for an insert into a view Modified to use updated setup_tables_and_check_access() function. sql/sql_base.cc: Fixed bug#21261: Wrong access rights was required for an insert into a view The setup_tables_and_check_access() function now accepts two want_access parameters. One will be used for the first table and the second for other tables. sql/mysql_priv.h: Fixed bug#21261: Wrong access rights was required for an insert into a view The setup_tables_and_check_access() function now accepts two want_access parameters.
This commit is contained in:
@ -2850,3 +2850,22 @@ Tables_in_test
|
||||
t1
|
||||
DROP TABLE t1;
|
||||
DROP VIEW IF EXISTS v1;
|
||||
CREATE DATABASE bug21261DB;
|
||||
CREATE TABLE t1 (x INT);
|
||||
CREATE SQL SECURITY INVOKER VIEW v1 AS SELECT x FROM t1;
|
||||
GRANT INSERT, UPDATE ON v1 TO 'user21261'@'localhost';
|
||||
GRANT INSERT, UPDATE ON t1 TO 'user21261'@'localhost';
|
||||
CREATE TABLE t2 (y INT);
|
||||
GRANT SELECT ON t2 TO 'user21261'@'localhost';
|
||||
INSERT INTO v1 (x) VALUES (5);
|
||||
UPDATE v1 SET x=1;
|
||||
GRANT SELECT ON v1 TO 'user21261'@'localhost';
|
||||
UPDATE v1,t2 SET x=1 WHERE x=y;
|
||||
SELECT * FROM t1;
|
||||
x
|
||||
1
|
||||
REVOKE ALL PRIVILEGES, GRANT OPTION FROM 'user21261'@'localhost';
|
||||
DROP USER 'user21261'@'localhost';
|
||||
DROP VIEW v1;
|
||||
DROP TABLE t1;
|
||||
DROP DATABASE bug21261DB;
|
||||
|
@ -2718,3 +2718,33 @@ DROP TABLE t1;
|
||||
--disable_warnings
|
||||
DROP VIEW IF EXISTS v1;
|
||||
--enable_warnings
|
||||
|
||||
#
|
||||
# Bug #21261: Wrong access rights was required for an insert to a view
|
||||
#
|
||||
CREATE DATABASE bug21261DB;
|
||||
CONNECT (root,localhost,root,,bug21261DB);
|
||||
CONNECTION root;
|
||||
|
||||
CREATE TABLE t1 (x INT);
|
||||
CREATE SQL SECURITY INVOKER VIEW v1 AS SELECT x FROM t1;
|
||||
GRANT INSERT, UPDATE ON v1 TO 'user21261'@'localhost';
|
||||
GRANT INSERT, UPDATE ON t1 TO 'user21261'@'localhost';
|
||||
CREATE TABLE t2 (y INT);
|
||||
GRANT SELECT ON t2 TO 'user21261'@'localhost';
|
||||
|
||||
CONNECT (user21261, localhost, user21261,, bug21261DB);
|
||||
CONNECTION user21261;
|
||||
INSERT INTO v1 (x) VALUES (5);
|
||||
UPDATE v1 SET x=1;
|
||||
CONNECTION root;
|
||||
GRANT SELECT ON v1 TO 'user21261'@'localhost';
|
||||
CONNECTION user21261;
|
||||
UPDATE v1,t2 SET x=1 WHERE x=y;
|
||||
CONNECTION root;
|
||||
SELECT * FROM t1;
|
||||
REVOKE ALL PRIVILEGES, GRANT OPTION FROM 'user21261'@'localhost';
|
||||
DROP USER 'user21261'@'localhost';
|
||||
DROP VIEW v1;
|
||||
DROP TABLE t1;
|
||||
DROP DATABASE bug21261DB;
|
||||
|
Reference in New Issue
Block a user