diff options
author | Jon Olav Hauglid <jon.hauglid@oracle.com> | 2011-01-04 14:36:37 +0100 |
---|---|---|
committer | Jon Olav Hauglid <jon.hauglid@oracle.com> | 2011-01-04 14:36:37 +0100 |
commit | 405ac384f54c58bc207f257a7bf6cfe2bb7b1445 (patch) | |
tree | 8110ed4542d3ed5def510e365965487d562168c1 /mysql-test/r/auto_increment.result | |
parent | 3997d4c694eeafb631831b639f84f29479b0eba7 (diff) | |
download | mariadb-git-405ac384f54c58bc207f257a7bf6cfe2bb7b1445.tar.gz |
Bug #50619 assert in handler::update_auto_increment
This assert could be triggered if -1 was inserted into
an auto increment column by a statement writing more than
one row.
Unless explicitly given, an interval of auto increment values
is generated when a statement first needs an auto increment
value. The triggered assert checks that the auto increment
counter is equal to or higher than the lower bound of this
interval.
Generally, the auto increment counter starts at 1 and is
incremented by 1 each time it is used. However, inserting an
explicit value into the auto increment column, sets the auto
increment counter to this value + 1 if this value is higher
than the current value of the auto increment counter.
This bug was triggered if the explicit value was -1. Since the
value was converted to unsigned before any comparisons were made,
it was found to be higher than the current vale of the auto
increment counter and the counter was set to -1 + 1. This value
was below the reserved interval and caused the assert to be
triggered the next time the statement tried to write a row.
With the patch for Bug#39828, this bug is no longer repeatable.
Now, -1 + 1 is detected as an "overflow" which causes the auto
increment counter to be set to ULONGLONG_MAX. This avoids hitting
the assert for the next insert and causes a new interval of
auto increment values to be generated. This resolves the issue.
This patch therefore only contains a regression test and no code
changes. Test case added to auto_increment.test.
Diffstat (limited to 'mysql-test/r/auto_increment.result')
-rw-r--r-- | mysql-test/r/auto_increment.result | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/mysql-test/r/auto_increment.result b/mysql-test/r/auto_increment.result index 5fae14e2c07..edd23050294 100644 --- a/mysql-test/r/auto_increment.result +++ b/mysql-test/r/auto_increment.result @@ -497,3 +497,22 @@ SET @@SESSION.AUTO_INCREMENT_INCREMENT=default; SET @@SESSION.AUTO_INCREMENT_OFFSET=default; DROP TABLE t1; End of 5.1 tests +# +# Bug#50619 assert in handler::update_auto_increment +# +CREATE TABLE t1 (pk INT AUTO_INCREMENT, PRIMARY KEY (pk)); +INSERT INTO t1 VALUES (NULL), (-1), (NULL); +SELECT * FROM t1; +pk +-1 +1 +2 +DROP TABLE t1; +CREATE TABLE t1 (pk BIGINT UNSIGNED AUTO_INCREMENT, PRIMARY KEY (pk)); +INSERT INTO t1 VALUES (NULL), (18446744073709551615-1), (NULL); +ERROR HY000: Failed to read auto-increment value from storage engine +SELECT * FROM t1; +pk +1 +18446744073709551614 +DROP TABLE t1; |