Skip to content

fix insert id#2616

Merged
jycor merged 3 commits intomainfrom
james/insertid
Aug 2, 2024
Merged

fix insert id#2616
jycor merged 3 commits intomainfrom
james/insertid

Conversation

@jycor
Copy link
Copy Markdown
Contributor

@jycor jycor commented Aug 1, 2024

The logic setting the InsertID in OkResult, did not match results returned from last_insert_id().
This was made apparent due to changes from #2614.
For a single insert statement, MySQL sets InsertID exactly once when the AutoIncrement on the column is first triggered.
While the linked PR fixes that issue and properly sets the session variable, our insertRowHandler (which is responsible for returning OkResult structs) was setting InsertID incorrectly.

The fix is to just read the LastInsertID from the session, since it is already set to the right value.

Copy link
Copy Markdown
Contributor

@max-hoffman max-hoffman left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, so basically we just defer to the session to tell us? Any sort of documentation you can think of to elaborate in the PR comment or in the code to describe what's happening and why would be helpful

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants