stonedb icon indicating copy to clipboard operation
stonedb copied to clipboard

bug: incorrect result set,Trigger which assigns value selected from table to field of row,being inserted/updated.Test results are wrong

Open shangyanwen opened this issue 1 year ago • 0 comments

Describe the problem

create table t1 (id int primary key, copy int)engine=tianmu;
create table t2 (id int primary key, data int)engine=tianmu;
insert into t2 values (1,1), (2,2);
create trigger t1_bi before insert on t1 for each row
  set new.copy= (select data from t2 where id = new.id);
create trigger t1_bu before update on t1 for each row
  set new.copy= (select data from t2 where id = new.id);
insert into t1 values (1,3), (2,4), (3,3);
update t1 set copy= 1 where id = 2;
select * from t1;

### Incorrect test results ###
+----+------+
| id | copy |
+----+------+
|  1 | NULL |
|  2 | NULL |
|  3 | NULL |
+----+------+

drop table t1, t2;

Expected behavior

#Correct test results(note:Innodb test verification, test results are as follows)
select * from t1;
+----+------+
| id | copy |
+----+------+
|  1 |    1 |
|  2 |    2 |
|  3 | NULL |
+----+------+

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 avatar Sep 27 '22 06:09 shangyanwen