Commit 0924601f authored by sunny's avatar sunny

Fix for Bug# 31860, in the Bug 16979 fix there was an erroneous assertion that

autoincrement columns can't contain negative values. With the fix, the
autoincrement table counter is set to 0 if the maximum value read from
the autoinc column index is negative.

Add test for the bug fix but the test is not really useful as the server
needs to be restarted half way through the test. It has been added for 
reference only.
parent d2568034
......@@ -3223,6 +3223,22 @@ c25 CHAR(255), c26 CHAR(255), c27 CHAR(255), c28 CHAR(255),
c29 CHAR(255), c30 CHAR(255), c31 CHAR(255), c32 CHAR(255)
) ENGINE = InnoDB;
ERROR 42000: Row size too large. The maximum row size for the used table type, not counting BLOBs, is 8126. You have to change some columns to TEXT or BLOBs
DROP TABLE IF EXISTS t1;
Warnings:
Note 1051 Unknown table 't1'
CREATE TABLE t1(
id BIGINT(20) NOT NULL AUTO_INCREMENT PRIMARY KEY
) ENGINE=InnoDB;
INSERT INTO t1 VALUES(-10);
SELECT * FROM t1;
id
-10
INSERT INTO t1 VALUES(NULL);
SELECT * FROM t1;
id
-10
1
DROP TABLE t1;
SET TX_ISOLATION='read-committed';
SET AUTOCOMMIT=0;
DROP TABLE IF EXISTS t1, t2;
......
......@@ -2367,6 +2367,25 @@ CREATE TABLE t1 (
c29 CHAR(255), c30 CHAR(255), c31 CHAR(255), c32 CHAR(255)
) ENGINE = InnoDB;
#
# Bug #31860 InnoDB assumes AUTOINC values can only be positive.
#
DROP TABLE IF EXISTS t1;
CREATE TABLE t1(
id BIGINT(20) NOT NULL AUTO_INCREMENT PRIMARY KEY
) ENGINE=InnoDB;
INSERT INTO t1 VALUES(-10);
SELECT * FROM t1;
#
# NOTE: The server really needs to be restarted at this point
# for the test to be useful.
#
# Without the fix InnoDB would trip over an assertion here.
INSERT INTO t1 VALUES(NULL);
# The next value should be 1 and not -9 or a -ve number
SELECT * FROM t1;
DROP TABLE t1;
#
# Bug #21409 Incorrect result returned when in READ-COMMITTED with
# query_cache ON
......
......@@ -4526,7 +4526,8 @@ row_search_check_if_query_cache_permitted(
}
/***********************************************************************
Read the AUTOINC column from the current row. */
Read the AUTOINC column from the current row. If the value is less than
0 and the type is not unsigned then we reset the value to 0. */
static
ib_longlong
row_search_autoinc_read_column(
......@@ -4594,7 +4595,9 @@ row_search_autoinc_read_column(
mem_heap_free(heap);
}
ut_a(value >= 0);
if (!unsigned_type && value < 0) {
value = 0;
}
return(value);
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment