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

last_insert_id is broken #5417

Open
systay opened this issue Nov 7, 2019 · 2 comments · May be fixed by #5451
Open

last_insert_id is broken #5417

systay opened this issue Nov 7, 2019 · 2 comments · May be fixed by #5451
Assignees
Labels

Comments

@systay
Copy link
Collaborator

@systay systay commented Nov 7, 2019

When filing a bug, please include the following headings if
possible. Any example text in this template can be deleted.

Overview of the Issue

The following query was recently made illegal in Vitess (since the merge of #5268)

SELECT last_insert_id()

Reproduction Steps

Steps to reproduce this issue, example:

  1. Deploy the following vschema:
{
	"sharded": false,
	"tables": {
		"messages": {},
		"tokens": {}
	}
}
  1. Deploy the following schema:
CREATE TABLE t (id INTEGER AUTO_INCREMENT PRIMARY KEY, f VARCHAR(1));
  1. Insert data using this query:
INSERT INTO t(f) VALUES('a');
  1. Try to view the inserted auto incremented id:
SELECT last_insert_id()

you'll see the error: unsupported: LAST_INSERT_ID is only allowed for unsharded keyspaces

I believe this is not the correct behaviour. I did a little writeup of how LII() is supposed to work here: https://gist.github.com/systay/09240a11ec12d3c63c48b39e1b47969b

@morgo

This comment has been minimized.

Copy link
Collaborator

@morgo morgo commented Nov 7, 2019

I believe this is a duplicate of: #3668

I would love to see it fixed too.

@morgo morgo added the Type: Bug label Nov 7, 2019
@systay

This comment has been minimized.

Copy link
Collaborator Author

@systay systay commented Nov 7, 2019

It's not strictly a duplicate - the last_insert_id situation took a turn for the worse last week with the change of how it is handled against dual.

@systay systay self-assigned this Nov 26, 2019
@systay systay linked a pull request that will close this issue Dec 12, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
2 participants
You can’t perform that action at this time.