dolthub / go-mysql-server

A MySQL-compatible relational database with a storage agnostic query engine. Implemented in pure Go.
Apache License 2.0
2.32k stars 199 forks source link

update `LAST_INSERT_ID` when auto incrementing from `empty`, `NULL`, and `DEFAULT` #2614

Closed jycor closed 1 month ago

jycor commented 1 month ago

Our logic for determining whether or not we needed to update last insert id only looked at the insertSource schema. This does not take into consideration empty, NULL or DEFAULT values. Additionally, the value that last insert id is set to depends on what the auto increment value will be.

This PR addresses those issues. Also, has some refactoring for readability.

fixes: https://github.com/dolthub/dolt/issues/7565