config root man

Current Path : /usr/opt/mysql57/mysql-test/suite/innodb/t/

FreeBSD hs32.drive.ne.jp 9.1-RELEASE FreeBSD 9.1-RELEASE #1: Wed Jan 14 12:18:08 JST 2015 root@hs32.drive.ne.jp:/sys/amd64/compile/hs32 amd64
Upload File :
Current File : //usr/opt/mysql57/mysql-test/suite/innodb/t/innodb-alter-autoinc.test

--source include/have_innodb.inc

CREATE TABLE t1 (a INT) ENGINE=InnoDB;
INSERT INTO t1 VALUES(347),(33101),(123),(45),(6);
# NULL -> NOT NULL only allowed INPLACE if strict sql_mode is on.
ALTER TABLE t1 ADD PRIMARY KEY(a);

# We cannot assign AUTO_INCREMENT values during online index creation.
--error ER_ALTER_OPERATION_NOT_SUPPORTED_REASON
ALTER TABLE t1 DROP PRIMARY KEY, ADD id INT AUTO_INCREMENT PRIMARY KEY,
	LOCK=NONE;

--error ER_WRONG_AUTO_KEY
ALTER TABLE t1 ADD id INT AUTO_INCREMENT;

--error ER_WRONG_AUTO_KEY
ALTER TABLE t1 ADD id INT AUTO_INCREMENT, ADD INDEX(a, id);

ALTER TABLE t1 ADD id INT NOT NULL, ADD INDEX(id, a);

SELECT * FROM t1;

# Test with a non-default increment and offset
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;

# The autoinc next value should increase. It is not rolled back.
BEGIN;
INSERT INTO t1 VALUES(7,0);
SELECT * FROM t1;
ROLLBACK;

SHOW CREATE TABLE t1;

# We cannot assign AUTO_INCREMENT values during online index creation.
--error ER_ALTER_OPERATION_NOT_SUPPORTED_REASON
ALTER TABLE t1 DROP PRIMARY KEY, ADD id INT AUTO_INCREMENT PRIMARY KEY,
	DROP COLUMN id, AUTO_INCREMENT = 42, LOCK=NONE;

ALTER TABLE t1 DROP PRIMARY KEY, ADD id INT AUTO_INCREMENT PRIMARY KEY,
	DROP COLUMN id, AUTO_INCREMENT = 42, ALGORITHM=INPLACE;

SELECT * FROM t1;
SHOW CREATE TABLE t1;

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;

SHOW CREATE TABLE t1;

DROP TABLE t1;

# ALGORITHM=INPLACE should deliver identical results to ALGORITHM=COPY.
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;

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;

# The autoinc next value should increase. It is not rolled back.
BEGIN;
INSERT INTO t1 VALUES(7,0);
SELECT * FROM t1;
ROLLBACK;

SHOW CREATE TABLE t1;

ALTER TABLE t1 DROP PRIMARY KEY, ADD id INT AUTO_INCREMENT PRIMARY KEY,
	DROP COLUMN id, AUTO_INCREMENT = 42, ALGORITHM=COPY;

SELECT * FROM t1;

SHOW CREATE TABLE t1;

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;

SHOW CREATE TABLE t1;

DROP TABLE t1;

Man Man