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 with primary key which assigns value selected from table to field of row,being inserted/updated.Test results are wrong #581

Closed
1 task
shangyanwen opened this issue Sep 27, 2022 · 2 comments · Fixed by #1068
Assignees
Labels
A-bug Something isn't working prio: high High priority

Comments

@shangyanwen
Copy link
Contributor

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 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 assigns value selected from table to field of row,being inserted/updated.Test results are wrong bug: incorrect result set,Trigger which assigns value selected from table to field of row,being inserted/updated.Test results are wrong Sep 29, 2022
@RingsC RingsC added the prio: high High priority label Oct 18, 2022
@RingsC RingsC assigned adofsauron and unassigned duanfuxiang0 Nov 29, 2022
@adofsauron
Copy link
Collaborator

ACK

@adofsauron
Copy link
Collaborator

The trigger logic branch when inserting data:

(gdb) bt
#0  fill_record_n_invoke_before_triggers (thd=0x7fd764000e10, ptr=0x7fd76498b910, values=..., table=0x7fd7640ac780, event=TRG_EVENT_INSERT, num_fields=2)
    at /home/jenkins/workspace/stonedb5.7-zsl-centos7.9-75-133/sql/sql_base.cc:9845
#1  0x00000000025c7ff2 in Sql_cmd_insert::mysql_insert (this=0x7fd764006038, thd=0x7fd764000e10, table_list=0x7fd764005aa8)
    at /home/jenkins/workspace/stonedb5.7-zsl-centos7.9-75-133/sql/sql_insert.cc:760
#2  0x00000000025cea87 in Sql_cmd_insert::execute (this=0x7fd764006038, thd=0x7fd764000e10) at /home/jenkins/workspace/stonedb5.7-zsl-centos7.9-75-133/sql/sql_insert.cc:3151
#3  0x00000000023aa84e in mysql_execute_command (thd=0x7fd764000e10, first_level=true) at /home/jenkins/workspace/stonedb5.7-zsl-centos7.9-75-133/sql/sql_parse.cc:3645
#4  0x00000000023b06fd in mysql_parse (thd=0x7fd764000e10, parser_state=0x7fd962dd1f90) at /home/jenkins/workspace/stonedb5.7-zsl-centos7.9-75-133/sql/sql_parse.cc:5655
#5  0x00000000023a5694 in dispatch_command (thd=0x7fd764000e10, com_data=0x7fd962dd2730, command=COM_QUERY) at /home/jenkins/workspace/stonedb5.7-zsl-centos7.9-75-133/sql/sql_parse.cc:1495
#6  0x00000000023a44d5 in do_command (thd=0x7fd764000e10) at /home/jenkins/workspace/stonedb5.7-zsl-centos7.9-75-133/sql/sql_parse.cc:1034
#7  0x00000000024d5cf3 in handle_connection (arg=0x98dd2a0) at /home/jenkins/workspace/stonedb5.7-zsl-centos7.9-75-133/sql/conn_handler/connection_handler_per_thread.cc:313
#8  0x0000000002ba303c in pfs_spawn_thread (arg=0x92b7840) at /home/jenkins/workspace/stonedb5.7-zsl-centos7.9-75-133/storage/perfschema/pfs.cc:2197
#9  0x00007fd96d4891ca in start_thread () from /lib64/libpthread.so.0
#10 0x00007fd96a7dbe73 in clone () from /lib64/libc.so.6

@mergify mergify bot closed this as completed in #1068 Dec 5, 2022
@adofsauron adofsauron changed the title bug: incorrect result set,Trigger which assigns value selected from table to field of row,being inserted/updated.Test results are wrong bug: incorrect result set,Trigger with primary key which assigns value selected from table to field of row,being inserted/updated.Test results are wrong Jan 9, 2023
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 prio: high High priority
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants