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

Inconsistent LAST_INSERT_ID(x) behavior for ordered queries #17495

Open
systay opened this issue Jan 9, 2025 · 0 comments
Open

Inconsistent LAST_INSERT_ID(x) behavior for ordered queries #17495

systay opened this issue Jan 9, 2025 · 0 comments

Comments

@systay
Copy link
Collaborator

systay commented Jan 9, 2025

Description

In MySQL, when executing an ordered query such as:

SELECT last_insert_id(col) 
FROM some_table 
ORDER BY some_col;

the session’s LAST_INSERT_ID gets set to the value from the final row returned. Currently, Vitess does not guarantee that the last row sets LAST_INSERT_ID, resulting in a discrepancy compared to native MySQL behavior.

Steps to Reproduce

  1. Run an ordered query that includes LAST_INSERT_ID(x) in its select list.
  2. Observe that MySQL’s last-insert-id value is always set to the last row, whereas Vitess may not set it in a predictable way.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant