[MDEV-16847] bulk insert: LAST_INSERT_ID() returns wrong value Created: 2018-07-30 Updated: 2018-12-13 Resolved: 2018-12-13 |
|
| Status: | Closed |
| Project: | MariaDB Server |
| Component/s: | Data Manipulation - Insert, Prepared Statements |
| Affects Version/s: | 10.2.13 |
| Fix Version/s: | 10.2.20 |
| Type: | Bug | Priority: | Critical |
| Reporter: | Georg Richter | Assignee: | Oleksandr Byelkin |
| Resolution: | Not a Bug | Votes: | 0 |
| Labels: | None | ||
| Description |
|
This might be related to After bulk insert the function LAST_INSERT_ID() returns wrong value.
|
| Comments |
| Comment by Oleksandr Byelkin [ 2018-09-07 ] | ||||||||||||||||||||||||||||||
|
usual test suite by Georg;
| ||||||||||||||||||||||||||||||
| Comment by Oleksandr Byelkin [ 2018-12-13 ] | ||||||||||||||||||||||||||||||
|
As example above shows it has nothing to do with bulk... | ||||||||||||||||||||||||||||||
| Comment by Oleksandr Byelkin [ 2018-12-13 ] | ||||||||||||||||||||||||||||||
|
It even has nothing to do with prepare:
so the question is why it behave so strange | ||||||||||||||||||||||||||||||
| Comment by Oleksandr Byelkin [ 2018-12-13 ] | ||||||||||||||||||||||||||||||
|
I think this behaviour is documented here: The currently executing statement does not affect the value of LAST_INSERT_ID(). Suppose that you generate an AUTO_INCREMENT value with one statement, and then refer to LAST_INSERT_ID() in a multiple-row INSERT statement that inserts rows into a table with its own AUTO_INCREMENT column. The value of LAST_INSERT_ID() will remain stable in the second statement; its value for the second and later rows is not affected by the earlier row insertions. (However, if you mix references to LAST_INSERT_ID() and LAST_INSERT_ID(expr), the effect is undefined.) |