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

bug: incorrect result set.Trigger which forces invocation of another trigger,emulation of FK on delete cascade policy,Delete does not take effect #580

Closed
1 task done
shangyanwen opened this issue Sep 27, 2022 · 2 comments · Fixed by #647
Assignees
Labels
A-bug Something isn't working

Comments

@shangyanwen
Copy link
Contributor

shangyanwen commented Sep 27, 2022

Describe the problem

create table t1 (id int primary key, fk_t2 int)engine=tianmu;
create table t2 (id int primary key, fk_t3 int)engine=tianmu;
create table t3 (id int primary key)engine=tianmu;
insert into t1 values (1,1), (2,1), (3,2);
insert into t2 values (1,1), (2,2);
insert into t3 values (1), (2);
create trigger t3_ad after delete on t3 for each row
  delete from t2 where fk_t3=old.id;
create trigger t2_ad after delete on t2 for each row
  delete from t1 where fk_t2=old.id;
delete from t3 where id = 1;
select * from t1 left join (t2 left join t3 on t2.fk_t3 = t3.id) on t1.fk_t2 = t2.id;

#Incorrect test results
+----+-------+------+-------+------+
| id | fk_t2 | id   | fk_t3 | id   |
+----+-------+------+-------+------+
|  1 |     1 |    2 |     2 |    2 |
|  2 |     1 |    2 |     2 |    2 |
|  3 |     2 |    2 |     2 |    2 |
+----+-------+------+-------+------+
drop table t1, t2, t3;

Expected behavior

select * from t1 left join (t2 left join t3 on t2.fk_t3 = t3.id) on t1.fk_t2 = t2.id;
+----+-------+------+-------+------+
| id | fk_t2 | id   | fk_t3 | id   |
+----+-------+------+-------+------+
|  3 |     2 |    2 |     2 |    2 |
+----+-------+------+-------+------+
1 row in set (0.00 sec)

How To Reproduce

Follow the test steps above

Environment

./mysqld  Ver 5.7.36_v1.0.1_beta-StoneDB for Linux on x86_64 (build-)
build information as follow: 
        Repository address: https://github.com/stoneatom/stonedb.git:stonedb-5.7-dev
        Branch name: stonedb-5.7-dev
        Last commit ID: 208f79d
        Last commit time: Date:   Sat Sep 17 16:19:42 2022 +0800
        Build time: Date: Sat Sep 17 17:59:04 CST 2022

Are you interested in submitting a PR to solve the problem?

  • Yes, I will!
@shangyanwen shangyanwen added the A-bug Something isn't working label Sep 27, 2022
@shangyanwen shangyanwen added this to the stonedb_5.7_v1.0.1 milestone Sep 27, 2022
@shangyanwen shangyanwen changed the title bug: Trigger which forces invocation of another trigger,emulation of FK on delete cascade policy,Delete does not take effect bug: incorrect result set.Trigger which forces invocation of another trigger,emulation of FK on delete cascade policy,Delete does not take effect Sep 29, 2022
duanfuxiang0 added a commit to duanfuxiang0/stonedb that referenced this issue Oct 8, 2022
@mergify mergify bot closed this as completed in #647 Oct 13, 2022
@shangyanwen
Copy link
Contributor Author

#test version
Ver 14.14 Distrib 5.7.36-StoneDB, for Linux (x86_64) using  EditLine wrapper
#test result
mysql> select * from t1 left join (t2 left join t3 on t2.fk_t3 = t3.id) on t1.fk_t2 = t2.id;
+----+-------+------+-------+------+
| id | fk_t2 | id   | fk_t3 | id   |
+----+-------+------+-------+------+
|  3 |     2 | NULL |  NULL | NULL |
|  3 |     2 |    2 |     2 |    2 |
| NULL |  NULL | NULL |  NULL | NULL |
| NULL |  NULL | NULL |  NULL | NULL |
+----+-------+------+-------+------+

@shangyanwen shangyanwen reopened this Oct 17, 2022
@shangyanwen
Copy link
Contributor Author

The test pass

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-bug Something isn't working
Projects
None yet
3 participants