mariadb/mysql-test/suite/innodb/r/innodb-alter-autoinc.result
Marko Mäkelä a36c369bda Merge 10.1 into 10.2
For running the Galera tests, the variable my_disable_leak_check
was set to true in order to avoid assertions due to memory leaks
at shutdown.

Some adjustments due to MDEV-13625 (merge InnoDB tests from MySQL 5.6)
were performed. The most notable behaviour changes from 10.0 and 10.1
are the following:

* innodb.innodb-table-online: adjustments for the DROP COLUMN
behaviour change (MDEV-11114, MDEV-13613)

* innodb.innodb-index-online-fk: the removal of a (1,NULL) record
from the result; originally removed in MySQL 5.7 in the
Oracle Bug #16244691 fix
377774689b

* innodb.create-index-debug: disabled due to MDEV-13680
(the MySQL Bug #77497 fix was not merged from 5.6 to 5.7.10)

* innodb.innodb-alter-autoinc: MariaDB 10.2 behaves like MySQL 5.6/5.7,
while MariaDB 10.0 and 10.1 assign different values when
auto_increment_increment or auto_increment_offset are used.
Also MySQL 5.6/5.7 exhibit different behaviour between
LGORITHM=INPLACE and ALGORITHM=COPY, so something needs to be tested
and fixed in both MariaDB 10.0 and 10.2.

* innodb.innodb-wl5980-alter: disabled because it would trigger an
InnoDB assertion failure (MDEV-13668 may need additional effort in 10.2)
2017-08-31 09:30:40 +03:00

174 lines
4.4 KiB
Text

CREATE TABLE t1 (a INT) ENGINE=InnoDB;
INSERT INTO t1 VALUES(347),(33101),(123),(45),(6);
SET @old_sql_mode = @@sql_mode;
SET @@sql_mode = 'STRICT_TRANS_TABLES';
ALTER TABLE t1 ADD PRIMARY KEY(a);
SET @@sql_mode = @old_sql_mode;
ALTER TABLE t1 DROP PRIMARY KEY, ADD id INT AUTO_INCREMENT PRIMARY KEY,
LOCK=NONE;
ERROR 0A000: LOCK=NONE is not supported. Reason: Adding an auto-increment column requires a lock. Try LOCK=SHARED
ALTER TABLE t1 ADD id INT AUTO_INCREMENT;
ERROR 42000: Incorrect table definition; there can be only one auto column and it must be defined as a key
ALTER TABLE t1 ADD id INT AUTO_INCREMENT, ADD INDEX(a, id);
ERROR 42000: Incorrect table definition; there can be only one auto column and it must be defined as a key
ALTER TABLE t1 ADD id INT NOT NULL, ADD INDEX(id, a);
SELECT * FROM t1;
a id
6 0
45 0
123 0
347 0
33101 0
SET AUTO_INCREMENT_INCREMENT = 5, AUTO_INCREMENT_OFFSET = 30;
ALTER TABLE t1 DROP PRIMARY KEY, ADD id INT AUTO_INCREMENT PRIMARY KEY,
DROP COLUMN id, AUTO_INCREMENT = 42, ALGORITHM=COPY;
SHOW CREATE TABLE t1;
Table Create Table
t1 CREATE TABLE `t1` (
`a` int(11) NOT NULL,
`id` int(11) NOT NULL AUTO_INCREMENT,
PRIMARY KEY (`id`),
KEY `id` (`id`,`a`)
) ENGINE=InnoDB AUTO_INCREMENT=70 DEFAULT CHARSET=latin1
BEGIN;
INSERT INTO t1 VALUES(7,0);
SELECT * FROM t1;
a id
6 45
45 50
123 55
347 60
33101 65
7 70
ROLLBACK;
SHOW CREATE TABLE t1;
Table Create Table
t1 CREATE TABLE `t1` (
`a` int(11) NOT NULL,
`id` int(11) NOT NULL AUTO_INCREMENT,
PRIMARY KEY (`id`),
KEY `id` (`id`,`a`)
) ENGINE=InnoDB AUTO_INCREMENT=75 DEFAULT CHARSET=latin1
ALTER TABLE t1 DROP PRIMARY KEY, ADD id INT AUTO_INCREMENT PRIMARY KEY,
DROP COLUMN id, AUTO_INCREMENT = 42, LOCK=NONE;
ERROR 0A000: LOCK=NONE is not supported. Reason: Adding an auto-increment column requires a lock. Try LOCK=SHARED
ALTER TABLE t1 DROP PRIMARY KEY, ADD id INT AUTO_INCREMENT PRIMARY KEY,
DROP COLUMN id, AUTO_INCREMENT = 42, ALGORITHM=INPLACE;
SELECT * FROM t1;
a id
6 45
45 50
123 55
347 60
33101 65
SHOW CREATE TABLE t1;
Table Create Table
t1 CREATE TABLE `t1` (
`a` int(11) NOT NULL,
`id` int(11) NOT NULL AUTO_INCREMENT,
PRIMARY KEY (`id`),
KEY `id` (`id`,`a`)
) ENGINE=InnoDB AUTO_INCREMENT=70 DEFAULT CHARSET=latin1
INSERT INTO t1 SET a=123;
INSERT INTO t1 VALUES(-123,-45);
ALTER TABLE t1 AUTO_INCREMENT = 75;
INSERT INTO t1 SET a=123;
SELECT * FROM t1;
a id
-123 -45
6 45
45 50
123 55
347 60
33101 65
123 70
123 75
SHOW CREATE TABLE t1;
Table Create Table
t1 CREATE TABLE `t1` (
`a` int(11) NOT NULL,
`id` int(11) NOT NULL AUTO_INCREMENT,
PRIMARY KEY (`id`),
KEY `id` (`id`,`a`)
) ENGINE=InnoDB AUTO_INCREMENT=80 DEFAULT CHARSET=latin1
DROP TABLE t1;
CREATE TABLE t1 (a INT) ENGINE=InnoDB;
INSERT INTO t1 VALUES(347),(33101),(123),(45),(6);
ALTER TABLE t1 ADD PRIMARY KEY(a);
ALTER TABLE t1 ADD id INT NOT NULL, ADD INDEX(id, a);
SELECT * FROM t1;
a id
6 0
45 0
123 0
347 0
33101 0
ALTER TABLE t1 DROP PRIMARY KEY, ADD id INT AUTO_INCREMENT PRIMARY KEY,
DROP COLUMN id, AUTO_INCREMENT = 42, ALGORITHM=INPLACE;
SHOW CREATE TABLE t1;
Table Create Table
t1 CREATE TABLE `t1` (
`a` int(11) NOT NULL,
`id` int(11) NOT NULL AUTO_INCREMENT,
PRIMARY KEY (`id`),
KEY `id` (`id`,`a`)
) ENGINE=InnoDB AUTO_INCREMENT=70 DEFAULT CHARSET=latin1
BEGIN;
INSERT INTO t1 VALUES(7,0);
SELECT * FROM t1;
a id
6 45
45 50
123 55
347 60
33101 65
7 70
ROLLBACK;
SHOW CREATE TABLE t1;
Table Create Table
t1 CREATE TABLE `t1` (
`a` int(11) NOT NULL,
`id` int(11) NOT NULL AUTO_INCREMENT,
PRIMARY KEY (`id`),
KEY `id` (`id`,`a`)
) ENGINE=InnoDB AUTO_INCREMENT=75 DEFAULT CHARSET=latin1
ALTER TABLE t1 DROP PRIMARY KEY, ADD id INT AUTO_INCREMENT PRIMARY KEY,
DROP COLUMN id, AUTO_INCREMENT = 42, ALGORITHM=COPY;
SELECT * FROM t1;
a id
6 45
45 50
123 55
347 60
33101 65
SHOW CREATE TABLE t1;
Table Create Table
t1 CREATE TABLE `t1` (
`a` int(11) NOT NULL,
`id` int(11) NOT NULL AUTO_INCREMENT,
PRIMARY KEY (`id`),
KEY `id` (`id`,`a`)
) ENGINE=InnoDB AUTO_INCREMENT=70 DEFAULT CHARSET=latin1
INSERT INTO t1 SET a=123;
INSERT INTO t1 VALUES(-123,-45);
ALTER TABLE t1 AUTO_INCREMENT = 75;
INSERT INTO t1 SET a=123;
SELECT * FROM t1;
a id
-123 -45
6 45
45 50
123 55
347 60
33101 65
123 70
123 75
SHOW CREATE TABLE t1;
Table Create Table
t1 CREATE TABLE `t1` (
`a` int(11) NOT NULL,
`id` int(11) NOT NULL AUTO_INCREMENT,
PRIMARY KEY (`id`),
KEY `id` (`id`,`a`)
) ENGINE=InnoDB AUTO_INCREMENT=80 DEFAULT CHARSET=latin1
DROP TABLE t1;