Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

should skip privilege check when execute foreign key cascade #39529

Closed
crazycs520 opened this issue Dec 1, 2022 · 0 comments · Fixed by #39508
Closed

should skip privilege check when execute foreign key cascade #39529

crazycs520 opened this issue Dec 1, 2022 · 0 comments · Fixed by #39508
Labels
feature/developing the related feature is in development sig/execution SIG execution type/new-feature

Comments

@crazycs520
Copy link
Contributor

Issue

Reproduce

set @@global.tidb_enable_foreign_key=1;
set @@foreign_key_checks=1;
create table t1 (id int key);
create table t2 (id int key, foreign key fk (id) references t1(id) ON DELETE CASCADE ON UPDATE CASCADE);
insert into t1 values (1), (2), (3);
insert into t2 values (1), (2), (3);

create user 'u1'@'%' identified by '';
grant select, delete on test.t1 to 'u1'@'%';

Then use user u1 to execute following SQL:

set @@foreign_key_checks=1;
delete from t1 where id=1;

Current TiDB will return error:

> delete from t1 where id=1;
(1142, "SELECT command denied to user 'u1'@'%' for table 't2'")

But MySQL will execute success:

> delete from t1 where id=1;
Query OK, 1 row affected
Time: 0.021s
t> select version();
+-----------+
| version() |
+-----------+
| 8.0.30    |
+-----------+
1 row in set

TiDB version:

***************************[ 1. row ]***************************
tidb_version() | Release Version: v6.5.0-alpha-206-gfa7cf31eff
Edition: Community
Git Commit Hash: fa7cf31eff6952408b023a634ccb403710b5de89
Git Branch: master
UTC Build Time: 2022-12-01 04:32:26
GoVersion: go1.19.3
Race Enabled: false
TiKV Min Version: 6.2.0-alpha
Check Table Before Drop: false
Store: unistore
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature/developing the related feature is in development sig/execution SIG execution type/new-feature
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant