stoneatom / stonedb

StoneDB is an Open-Source MySQL HTAP and MySQL-Native DataBase for OLTP, Real-Time Analytics, a counterpart of MySQLHeatWave. (https://stonedb.io)
https://stonedb.io/
GNU General Public License v2.0
862 stars 139 forks source link

bug: The tianmu unable to get last_insert_id. #1486

Open haitaoguan opened 1 year ago

haitaoguan commented 1 year ago

Have you read the Contributing Guidelines on issues?

Please confirm if bug report does NOT exists already ?

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?

haitaoguan commented 1 year ago

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