@@ -4010,6 +4010,10 @@ CREATE TABLE t1(fld1 INT PRIMARY KEY, fld2 INT) ENGINE=INNODB;
4010
4010
CREATE TABLE t2(fld1 INT PRIMARY KEY, fld2 INT, CONSTRAINT fk2
4011
4011
FOREIGN KEY (fld1) REFERENCES t1 (fld1)) ENGINE=InnoDB;
4012
4012
CREATE TABLE t3(fld1 INT PRIMARY KEY, fld2 INT) ENGINE=InnoDB;
4013
+ CREATE TABLE parent (id INT NOT NULL, PRIMARY KEY (id)) ENGINE=INNODB;
4014
+ CREATE TABLE child (id INT, parent_id INT, INDEX par_ind (parent_id), FOREIGN KEY (parent_id) REFERENCES parent(id)) ENGINE=INNODB;
4015
+ INSERT INTO parent (id) VALUES(1);
4016
+ INSERT INTO child (id,parent_id) VALUES(1,1);
4013
4017
4014
4018
--echo # Set up stored routines
4015
4019
CREATE PROCEDURE p1() SQL SECURITY INVOKER INSERT INTO t2 (fld1, fld2) VALUES (1, 2);
@@ -4037,6 +4041,10 @@ CREATE SQL SECURITY DEFINER VIEW v2 AS SELECT * FROM t2;
4037
4041
CREATE USER user1@localhost;
4038
4042
CREATE USER user2@localhost;
4039
4043
CREATE USER user3@localhost;
4044
+ CREATE USER user4@localhost;
4045
+ CREATE USER user5@localhost;
4046
+ CREATE USER user6@localhost;
4047
+ CREATE USER user7@localhost;
4040
4048
GRANT INSERT (fld1, fld2) ON t2 TO user1@localhost;
4041
4049
GRANT INSERT ON v1 TO user2@localhost;
4042
4050
GRANT INSERT ON v2 TO user2@localhost;
@@ -4046,12 +4054,18 @@ GRANT EXECUTE ON PROCEDURE p1 TO user2@localhost;
4046
4054
GRANT EXECUTE ON PROCEDURE p2 TO user2@localhost;
4047
4055
GRANT EXECUTE ON FUNCTION f1 TO user2@localhost;
4048
4056
GRANT EXECUTE ON FUNCTION f2 TO user2@localhost;
4057
+ GRANT SELECT, DELETE, INSERT, UPDATE on wl8910db.* to user4@localhost;
4058
+ GRANT SELECT, DELETE, INSERT, UPDATE on wl8910db.parent to user5@localhost;
4059
+ GRANT SELECT, DELETE, INSERT, UPDATE on wl8910db.parent to user6@localhost;
4060
+ GRANT SELECT, DELETE, INSERT, UPDATE on wl8910db.child to user6@localhost;
4061
+ GRANT SELECT ON wl8910db.* TO user7@localhost;
4062
+ GRANT DELETE ON wl8910db.parent TO user7@localhost;
4049
4063
4050
4064
--enable_connect_log
4051
4065
4052
4066
connect (con1, localhost, user1,,wl8910db);
4053
4067
--echo # Without patch, reveals parent table's information.
4054
- --error ER_NO_REFERENCED_ROW
4068
+ --error ER_NO_REFERENCED_ROW_2
4055
4069
INSERT INTO t2 (fld1, fld2) VALUES (1, 2);
4056
4070
4057
4071
--echo # Warning displayed does not reveal parent table information.
@@ -4070,7 +4084,7 @@ ALTER TABLE t2 ADD CONSTRAINT fk3 FOREIGN KEY (fld2) REFERENCES t3(fld1);
4070
4084
4071
4085
connection con1;
4072
4086
--echo # Without patch, reveals parent table's information.
4073
- --error ER_NO_REFERENCED_ROW
4087
+ --error ER_NO_REFERENCED_ROW_2
4074
4088
INSERT INTO t2 (fld1, fld2) VALUES (1, 2);
4075
4089
4076
4090
--echo # Warning displayed does not reveal parent table information.
@@ -4087,14 +4101,13 @@ INSERT INTO t2 (fld1, fld2) VALUES (1, 2);
4087
4101
connection default;
4088
4102
GRANT INSERT (fld1, fld2) ON t2 TO user2@localhost;
4089
4103
GRANT CREATE ROUTINE ON wl8910db.* TO user2@localhost;
4090
- GRANT CREATE VIEW ON wl8910db.* TO user2@localhost;
4091
4104
4092
4105
--echo # Tests where DML reports FK constraint failure within Stored Routines.
4093
4106
connect (con2, localhost, user2,,wl8910db);
4094
4107
4095
4108
--echo # The SQL security for p1 is invoker where invoker lacks permission
4096
4109
--echo # to parent table, hence parent table information is not displayed.
4097
- --error ER_NO_REFERENCED_ROW
4110
+ --error ER_NO_REFERENCED_ROW_2
4098
4111
CALL p1();
4099
4112
4100
4113
--echo # The SQL security p2 is definer, where the definer has access privilege
@@ -4104,7 +4117,7 @@ CALL p2();
4104
4117
4105
4118
--echo # The SQL security for f1 is invoker where invoker lacks permission
4106
4119
--echo # to parent table, hence parent table information is not displayed.
4107
- --error ER_NO_REFERENCED_ROW
4120
+ --error ER_NO_REFERENCED_ROW_2
4108
4121
SELECT f1();
4109
4122
4110
4123
--echo # The SQL security f2 is definer, where the definer has access privilege
@@ -4116,20 +4129,23 @@ SELECT f2();
4116
4129
4117
4130
--echo # The invoker does not have access to the parent table, hence the parent
4118
4131
--echo # table information is not displayed.
4119
- --error ER_NO_REFERENCED_ROW
4132
+ --error ER_NO_REFERENCED_ROW_2
4120
4133
INSERT INTO v1 VALUES (1, 2);
4121
4134
4122
4135
--echo # DML on view executed within the definer context where the invoker does
4123
4136
--echo # not have access to the parent table, hence the parent table information
4124
4137
--echo # is not displayed.
4125
- --error ER_NO_REFERENCED_ROW
4138
+ --error ER_NO_REFERENCED_ROW_2
4126
4139
INSERT INTO v2 VALUES (1, 2);
4127
4140
4128
4141
connection default;
4129
4142
GRANT SELECT ON t1 TO user2@localhost;
4130
4143
GRANT SELECT ON t3 TO user2@localhost;
4144
+ GRANT CREATE VIEW ON wl8910db.* TO user2@localhost;
4145
+
4146
+ disconnect con2;
4147
+ connect (con2, localhost, user2,,wl8910db);
4131
4148
4132
- connection con2;
4133
4149
--echo # DML on view executed within the definer context where the invoker
4134
4150
--echo # has access to the parent table, hence the parent table information
4135
4151
--echo # is displayed.
@@ -4178,16 +4194,48 @@ SELECT f3();
4178
4194
--error ER_NO_REFERENCED_ROW_2
4179
4195
INSERT INTO v3 VALUES(4, 5);
4180
4196
4197
+ --echo # user4 have access to the child table, hence the child table
4198
+ --echo # information is displayed.
4199
+ connect (con4, localhost, user4,,wl8910db);
4200
+ --error ER_ROW_IS_REFERENCED_2
4201
+ DELETE FROM parent WHERE id = 1;
4202
+
4203
+ --echo # user5 do not have access to the child table, hence the child table
4204
+ --echo # information is not displayed.
4205
+ connect (con5, localhost, user5,,wl8910db);
4206
+ --error ER_ROW_IS_REFERENCED_2
4207
+ DELETE FROM parent WHERE id = 1;
4208
+
4209
+ --echo # user6 have access to the child table, hence the child table
4210
+ --echo # information is displayed.
4211
+ connect (con6, localhost, user6,,wl8910db);
4212
+ --error ER_ROW_IS_REFERENCED_2
4213
+ DELETE FROM parent WHERE id = 1;
4214
+
4215
+ --echo # user7 have access to the child table, hence the child table
4216
+ --echo # information is displayed.
4217
+ connect (con7, localhost, user7,,wl8910db);
4218
+ --error ER_ROW_IS_REFERENCED_2
4219
+ DELETE FROM parent WHERE id = 1;
4220
+
4181
4221
--echo # Cleanup
4182
4222
connection default;
4183
4223
disconnect con1;
4184
4224
disconnect con2;
4185
4225
disconnect con3;
4226
+ disconnect con4;
4227
+ disconnect con5;
4228
+ disconnect con6;
4229
+ disconnect con7;
4186
4230
DROP VIEW v1, v2, v3;
4187
- DROP TABLE t2, t3, t1;
4231
+ DROP TABLE t2, t3, t1, parent, child ;
4188
4232
DROP USER user1@localhost;
4189
4233
DROP USER user2@localhost;
4190
4234
DROP USER user3@localhost;
4235
+ DROP USER user4@localhost;
4236
+ DROP USER user5@localhost;
4237
+ DROP USER user6@localhost;
4238
+ DROP USER user7@localhost;
4191
4239
DROP PROCEDURE p1;
4192
4240
DROP PROCEDURE p2;
4193
4241
DROP PROCEDURE p3;
0 commit comments