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

SELECT LAST_INSERT_ID() appears to be limited to 32 bits... #1090

Closed
jbreen opened this issue Jul 13, 2017 · 5 comments
Closed

SELECT LAST_INSERT_ID() appears to be limited to 32 bits... #1090

jbreen opened this issue Jul 13, 2017 · 5 comments
Assignees
Milestone

Comments

@jbreen
Copy link

jbreen commented Jul 13, 2017

MySQL environment innodb_version = 5.6.32-78.0
ProxySQL version 1.3.7

Our auto_increment columns are BIGINT values.
One table has definitely already cleared the 32 bit max value..

The following code is hitting ProxySQL...

INSERT INTO usr_activity (activity_id, user_id, acct_id, sid, start_time, activity_type, usr_activity_type_id, activity_query, caller_id, ref_data_1, ref_data_2, ref_data_3, ref_data_4, ref_data_5) VALUES (NULL, '0', '917', 'james', CURRENT_TIMESTAMP, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL);

SELECT LAST_INSERT_ID();

values returned when hitting proxySQL
1915171621 -> 0x72273325

when bypassing proxySQL and executing the same two queries, the returned values are ....
1234570785583 -> 0x11F7227332F (auto_increment_increment = 10)

Which is a BIGINT 64 number ...

@renecannao
Copy link
Contributor

John,

Issue confirmed.
According to new documentation, last_insert_id is encoded as a variable length integer.

@renecannao
Copy link
Contributor

Working on it:

mysql> insert into test values (256*256*256*256*256+101);
Query OK, 1 row affected (0.14 sec)

mysql> select 256*256*256*256*256+101;
+-------------------------+
| 256*256*256*256*256+101 |
+-------------------------+
|           1099511627877 |
+-------------------------+
1 row in set (0.00 sec)

mysql> select last_insert_id();
+------------------+
| LAST_INSERT_ID() |
+------------------+
|    1099511627877 |
+------------------+
1 row in set (0.00 sec)

@jbreen
Copy link
Author

jbreen commented Jul 14, 2017 via email

renecannao added a commit that referenced this issue Jul 14, 2017
* 64 bits LAST_INSERT_ID() #1090
* return LAST_INSERT_ID() as type LONGLONG #1092
* set charset as `binary` #1092
renecannao added a commit that referenced this issue Jul 14, 2017
* 64 bits LAST_INSERT_ID() #1090
* return LAST_INSERT_ID() as type LONGLONG #1092
* set charset as `binary` #1092
@renecannao
Copy link
Contributor

Thank you for the report.
Now available in branch 1.3.9 and 1.4.1

@renecannao
Copy link
Contributor

Fixed in 1.3.9 and 1.4.1

@renecannao renecannao self-assigned this Jul 19, 2017
@renecannao renecannao added this to the 1.3.9 milestone Jul 19, 2017
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

No branches or pull requests

2 participants