Commit 869c132
committed
Bug #14483484 INSERT ... ON DUPLICATE KEY UPDATE + INNODB_AUTOINC_LOCK_MODE=1
IS BROKEN
Problem:
When a multi-row INSERT ... ON DUPLICATE KEY UPDATE statement begins
execution it reserves the required number of auto increment values.
When one of the insert fails because of duplicate key error, then it
will become an update operation. The auto increment value of this
update operation will determine the auto increment values
used for subsequent inserts. This can result in duplicate auto increment
values.
Solution:
When an insert operation of a multi-row INSERT ... ON DUPLICATE KEY
UPDATE statement fails, check if the update clause explicitly updates
the auto increment value. If an explicit value is given for an
auto increment field, then check if it will conflict with the values
that we have reserved. If it might conflict then return an error.
Also, the update clause will not bump the auto increment value for
the rows inserted in the multi-row INSERT ... ON DUPLICATE KEY.
rb#2219 approved by Guilhem and Dmitry Shulga.1 parent c49e0df commit 869c132
4 files changed
Lines changed: 44 additions & 7 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
233 | 233 | | |
234 | 234 | | |
235 | 235 | | |
| 236 | + | |
236 | 237 | | |
237 | | - | |
238 | 238 | | |
239 | 239 | | |
240 | 240 | | |
241 | 241 | | |
| 242 | + | |
242 | 243 | | |
243 | | - | |
244 | 244 | | |
245 | 245 | | |
246 | 246 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
7057 | 7057 | | |
7058 | 7058 | | |
7059 | 7059 | | |
| 7060 | + | |
| 7061 | + | |
| 7062 | + | |
7060 | 7063 | | |
7061 | 7064 | | |
7062 | 7065 | | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1712 | 1712 | | |
1713 | 1713 | | |
1714 | 1714 | | |
| 1715 | + | |
| 1716 | + | |
| 1717 | + | |
| 1718 | + | |
| 1719 | + | |
| 1720 | + | |
| 1721 | + | |
| 1722 | + | |
| 1723 | + | |
| 1724 | + | |
| 1725 | + | |
| 1726 | + | |
| 1727 | + | |
| 1728 | + | |
| 1729 | + | |
| 1730 | + | |
| 1731 | + | |
| 1732 | + | |
| 1733 | + | |
| 1734 | + | |
| 1735 | + | |
| 1736 | + | |
| 1737 | + | |
| 1738 | + | |
| 1739 | + | |
| 1740 | + | |
| 1741 | + | |
| 1742 | + | |
| 1743 | + | |
| 1744 | + | |
| 1745 | + | |
1715 | 1746 | | |
1716 | 1747 | | |
1717 | 1748 | | |
| |||
1726 | 1757 | | |
1727 | 1758 | | |
1728 | 1759 | | |
1729 | | - | |
1730 | 1760 | | |
1731 | 1761 | | |
1732 | 1762 | | |
| |||
1763 | 1793 | | |
1764 | 1794 | | |
1765 | 1795 | | |
1766 | | - | |
1767 | | - | |
1768 | | - | |
1769 | 1796 | | |
1770 | 1797 | | |
1771 | 1798 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | 2 | | |
3 | 3 | | |
4 | | - | |
| 4 | + | |
5 | 5 | | |
6 | 6 | | |
7 | 7 | | |
| |||
292 | 292 | | |
293 | 293 | | |
294 | 294 | | |
| 295 | + | |
| 296 | + | |
| 297 | + | |
| 298 | + | |
| 299 | + | |
| 300 | + | |
| 301 | + | |
295 | 302 | | |
296 | 303 | | |
297 | 304 | | |
| |||
0 commit comments