stonedb icon indicating copy to clipboard operation
stonedb copied to clipboard

bug: The tianmu unable to get last_insert_id.

Open haitaoguan opened this issue 1 year ago • 1 comments

Have you read the Contributing Guidelines on issues?

Please confirm if bug report does NOT exists already ?

  • [X] I confirm there is no existing issue for this

Describe the problem

mysql> create table ttt(id int auto_increment primary key,name varchar(10));
Query OK, 0 rows affected (0.03 sec)

mysql> insert into ttt(name) values('AAA');
Query OK, 1 row affected (0.00 sec)

mysql> select id,name,last_insert_id() from ttt;
+----+------+------------------+
| id | name | last_insert_id() |
+----+------+------------------+
|  1 | AAA  |                0 |
+----+------+------------------+
1 row in set (0.00 sec)

mysql> insert into ttt(name) values('BBB');
Query OK, 1 row affected (0.00 sec)

mysql> select id,name,last_insert_id() from ttt;
+----+------+------------------+
| id | name | last_insert_id() |
+----+------+------------------+
|  1 | AAA  |                0 |
|  2 | BBB  |                0 |
+----+------+------------------+
2 rows in set (0.01 sec)

Expected behavior

mysql> insert into ttt(name) values('AAA');
Query OK, 1 row affected (0.00 sec)

mysql> select id,name,last_insert_id() from ttt;
+----+------+------------------+
| id | name | last_insert_id() |
+----+------+------------------+
|  1 | AAA  |                1 |
+----+------+------------------+
1 row in set (0.00 sec)

mysql> insert into ttt(name) values('BBB');
Query OK, 1 row affected (0.00 sec)

mysql> select id,name,last_insert_id() from ttt;
+----+------+------------------+
| id | name | last_insert_id() |
+----+------+------------------+
|  1 | AAA  |                2 |
|  2 | BBB  |                2 |
+----+------+------------------+
2 rows in set (0.00 sec)

How To Reproduce

No response

Environment

./mysqld Ver 5.7.36-StoneDB-v1.0.3 for Linux on x86_64 (build-) build information as follow: Repository address: https://github.com/stoneatom/stonedb:stonedb-5.7-dev Branch name: stonedb-5.7-dev Last commit ID: 05db04de4 Last commit time: Date: Wed Mar 22 21:09:55 2023 +0800 Build time: Date: Thu 23 Mar 2023 04:39:21 AM UTC

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

  • [X] Yes, I will!

haitaoguan avatar Mar 29 '23 08:03 haitaoguan

If the predicate condition using the function last_insert_id, maybe return wrong result.

haitaoguan avatar Mar 29 '23 08:03 haitaoguan