mirror of
https://github.com/MariaDB/server.git
synced 2025-01-19 05:22:25 +01:00
branches/5.1: In the last round of AUTOINC cleanup we assumed that AUTOINC
is only defined for integer columns. This caused an assertion failure when we checked for the maximum value of a column type. We now calculate the max value for floating-point autoinc columns too. Fix Bug#42400 - InnoDB autoinc code can't handle floating-point columns rb://84 and Mantis issue://162
This commit is contained in:
parent
de14b0d1ee
commit
5a4789be8d
3 changed files with 85 additions and 2 deletions
|
@ -3405,7 +3405,7 @@ skip_field:
|
|||
}
|
||||
|
||||
/************************************************************************
|
||||
Get the upper limit of the MySQL integral type. */
|
||||
Get the upper limit of the MySQL integral and floating-point type. */
|
||||
|
||||
ulonglong
|
||||
ha_innobase::innobase_get_int_col_max_value(
|
||||
|
@ -3444,12 +3444,20 @@ ha_innobase::innobase_get_int_col_max_value(
|
|||
max_value = 0x7FFFFFFFULL;
|
||||
break;
|
||||
/* BIG */
|
||||
case HA_KEYTYPE_ULONGLONG:
|
||||
case HA_KEYTYPE_ULONGLONG:
|
||||
max_value = 0xFFFFFFFFFFFFFFFFULL;
|
||||
break;
|
||||
case HA_KEYTYPE_LONGLONG:
|
||||
max_value = 0x7FFFFFFFFFFFFFFFULL;
|
||||
break;
|
||||
case HA_KEYTYPE_FLOAT:
|
||||
/* We use the maximum as per IEEE754-2008 standard, 2^24 */
|
||||
max_value = 0x1000000;
|
||||
break;
|
||||
case HA_KEYTYPE_DOUBLE:
|
||||
/* We use the maximum as per IEEE754-2008 standard, 2^53 */
|
||||
max_value = 0x20000000000000;
|
||||
break;
|
||||
default:
|
||||
ut_error;
|
||||
}
|
||||
|
|
|
@ -581,3 +581,51 @@ c1
|
|||
18446744073709551610
|
||||
18446744073709551615
|
||||
DROP TABLE t1;
|
||||
SET @@SESSION.AUTO_INCREMENT_INCREMENT=1, @@SESSION.AUTO_INCREMENT_OFFSET=1;
|
||||
SET @@INSERT_ID=1;
|
||||
SHOW VARIABLES LIKE "%auto_inc%";
|
||||
Variable_name Value
|
||||
auto_increment_increment 1
|
||||
auto_increment_offset 1
|
||||
CREATE TABLE t1 (c1 DOUBLE NOT NULL AUTO_INCREMENT, c2 INT, PRIMARY KEY (c1)) ENGINE=InnoDB;
|
||||
INSERT INTO t1 VALUES(NULL, 1);
|
||||
INSERT INTO t1 VALUES(NULL, 2);
|
||||
SELECT * FROM t1;
|
||||
c1 c2
|
||||
1 1
|
||||
2 2
|
||||
ALTER TABLE t1 CHANGE c1 c1 SERIAL;
|
||||
SELECT * FROM t1;
|
||||
c1 c2
|
||||
1 1
|
||||
2 2
|
||||
INSERT INTO t1 VALUES(NULL, 3);
|
||||
INSERT INTO t1 VALUES(NULL, 4);
|
||||
SELECT * FROM t1;
|
||||
c1 c2
|
||||
1 1
|
||||
2 2
|
||||
3 3
|
||||
4 4
|
||||
DROP TABLE IF EXISTS t1;
|
||||
CREATE TABLE t1 (c1 FLOAT NOT NULL AUTO_INCREMENT, c2 INT, PRIMARY KEY (c1)) ENGINE=InnoDB;
|
||||
INSERT INTO t1 VALUES(NULL, 1);
|
||||
INSERT INTO t1 VALUES(NULL, 2);
|
||||
SELECT * FROM t1;
|
||||
c1 c2
|
||||
1 1
|
||||
2 2
|
||||
ALTER TABLE t1 CHANGE c1 c1 SERIAL;
|
||||
SELECT * FROM t1;
|
||||
c1 c2
|
||||
1 1
|
||||
2 2
|
||||
INSERT INTO t1 VALUES(NULL, 3);
|
||||
INSERT INTO t1 VALUES(NULL, 4);
|
||||
SELECT * FROM t1;
|
||||
c1 c2
|
||||
1 1
|
||||
2 2
|
||||
3 3
|
||||
4 4
|
||||
DROP TABLE t1;
|
||||
|
|
|
@ -371,3 +371,30 @@ SHOW VARIABLES LIKE "%auto_inc%";
|
|||
INSERT INTO t1 VALUES (NULL),(NULL), (NULL);
|
||||
SELECT * FROM t1;
|
||||
DROP TABLE t1;
|
||||
|
||||
#
|
||||
# Check for floating point autoinc column handling
|
||||
#
|
||||
SET @@SESSION.AUTO_INCREMENT_INCREMENT=1, @@SESSION.AUTO_INCREMENT_OFFSET=1;
|
||||
SET @@INSERT_ID=1;
|
||||
SHOW VARIABLES LIKE "%auto_inc%";
|
||||
CREATE TABLE t1 (c1 DOUBLE NOT NULL AUTO_INCREMENT, c2 INT, PRIMARY KEY (c1)) ENGINE=InnoDB;
|
||||
INSERT INTO t1 VALUES(NULL, 1);
|
||||
INSERT INTO t1 VALUES(NULL, 2);
|
||||
SELECT * FROM t1;
|
||||
ALTER TABLE t1 CHANGE c1 c1 SERIAL;
|
||||
SELECT * FROM t1;
|
||||
INSERT INTO t1 VALUES(NULL, 3);
|
||||
INSERT INTO t1 VALUES(NULL, 4);
|
||||
SELECT * FROM t1;
|
||||
DROP TABLE IF EXISTS t1;
|
||||
CREATE TABLE t1 (c1 FLOAT NOT NULL AUTO_INCREMENT, c2 INT, PRIMARY KEY (c1)) ENGINE=InnoDB;
|
||||
INSERT INTO t1 VALUES(NULL, 1);
|
||||
INSERT INTO t1 VALUES(NULL, 2);
|
||||
SELECT * FROM t1;
|
||||
ALTER TABLE t1 CHANGE c1 c1 SERIAL;
|
||||
SELECT * FROM t1;
|
||||
INSERT INTO t1 VALUES(NULL, 3);
|
||||
INSERT INTO t1 VALUES(NULL, 4);
|
||||
SELECT * FROM t1;
|
||||
DROP TABLE t1;
|
||||
|
|
Loading…
Reference in a new issue