diff options
author | Thirunarayanan Balathandayuthapani <thiru@mariadb.com> | 2018-05-07 14:54:58 +0530 |
---|---|---|
committer | Thirunarayanan Balathandayuthapani <thiru@mariadb.com> | 2018-05-07 14:58:11 +0530 |
commit | 85cc6b70bd7e5db2c96c4f58344bab269343cf85 (patch) | |
tree | ffa0ab7a6a75996497ce75b65fe9d5d3b02c9bd0 /mysql-test | |
parent | a0bc3b7eeef6a3bfd0e7eae1cceabcc73071a61a (diff) | |
download | mariadb-git-85cc6b70bd7e5db2c96c4f58344bab269343cf85.tar.gz |
MDEV-13134 Introduce ALTER TABLE attributes ALGORITHM=NOCOPY and ALGORITHM=INSTANT
Introduced new alter algorithm type called NOCOPY & INSTANT for
inplace alter operation.
NOCOPY - Algorithm refuses any alter operation that would
rebuild the clustered index. It is a subset of INPLACE algorithm.
INSTANT - Algorithm allow any alter operation that would
modify only meta data. It is a subset of NOCOPY algorithm.
Introduce new variable called alter_algorithm. The values are
DEFAULT(0), COPY(1), INPLACE(2), NOCOPY(3), INSTANT(4)
Message to deprecate old_alter_table variable and make it alias
for alter_algorithm variable.
alter_algorithm variable for slave is always set to default.
Diffstat (limited to 'mysql-test')
29 files changed, 814 insertions, 78 deletions
diff --git a/mysql-test/main/alter_table.result b/mysql-test/main/alter_table.result index 9b394926489..5f41e0d7a08 100644 --- a/mysql-test/main/alter_table.result +++ b/mysql-test/main/alter_table.result @@ -1810,9 +1810,7 @@ affected rows: 2 info: Records: 2 Duplicates: 0 Warnings: 0 ALTER TABLE ti1 ADD FULLTEXT INDEX ii3 (d); affected rows: 0 -info: Records: 0 Duplicates: 0 Warnings: 1 -Warnings: -Warning 124 InnoDB rebuilding table to add column FTS_DOC_ID +info: Records: 0 Duplicates: 0 Warnings: 0 ALTER TABLE tm1 ADD FULLTEXT INDEX im3 (d); affected rows: 2 info: Records: 2 Duplicates: 0 Warnings: 0 diff --git a/mysql-test/main/alter_table_online.result b/mysql-test/main/alter_table_online.result index d5a2a028acc..2e3de2c0635 100644 --- a/mysql-test/main/alter_table_online.result +++ b/mysql-test/main/alter_table_online.result @@ -112,7 +112,7 @@ create table t1 (a int not null primary key, b int, c varchar(80)); create table t2 (a int not null primary key, b int, c varchar(80)); create table t3 (a int not null primary key, b int, c varchar(80)) engine=merge UNION=(t1); alter online table t3 union=(t1,t2); -ERROR 0A000: LOCK=NONE/SHARED is not supported for this operation. Try LOCK=EXCLUSIVE +ERROR 0A000: LOCK=NONE is not supported for this operation. Try LOCK=EXCLUSIVE drop table t1,t2,t3; create table t1 (i int) partition by hash(i) partitions 2; alter online table t1 comment 'test'; diff --git a/mysql-test/main/mysqld--help.result b/mysql-test/main/mysqld--help.result index 356546a287b..9da52106f91 100644 --- a/mysql-test/main/mysqld--help.result +++ b/mysql-test/main/mysqld--help.result @@ -12,6 +12,9 @@ The following specify which files/extra groups are read (specified before remain without corresponding xxx_init() or xxx_deinit(). That also means that one can load any function from any library, for example exit() from libc.so + --alter-algorithm[=name] + Specify the alter table algorithm. One of: DEFAULT, COPY, + INPLACE, NOCOPY, INSTANT -a, --ansi Use ANSI SQL syntax instead of MySQL syntax. This mode will also set transaction isolation level 'serializable'. --auto-increment-increment[=#] @@ -617,7 +620,10 @@ The following specify which files/extra groups are read (specified before remain connection before aborting the write --old Use compatible behavior from previous MariaDB version. See also --old-mode - --old-alter-table Use old, non-optimized alter table + --old-alter-table[=name] + Alias for alter_algorithm. Deprecated. Use + --alter-algorithm instead.. One of: DEFAULT, COPY, + INPLACE, NOCOPY, INSTANT --old-mode=name Used to emulate old behavior from earlier MariaDB or MySQL versions. Any combination of: NO_DUP_KEY_WARNINGS_WITH_IGNORE, NO_PROGRESS_INFO, @@ -1334,6 +1340,7 @@ The following specify which files/extra groups are read (specified before remain Variables (--variable-name=value) allow-suspicious-udfs FALSE +alter-algorithm DEFAULT auto-increment-increment 1 auto-increment-offset 1 autocommit TRUE @@ -1509,7 +1516,7 @@ net-read-timeout 30 net-retry-count 10 net-write-timeout 60 old FALSE -old-alter-table FALSE +old-alter-table DEFAULT old-mode old-passwords FALSE old-style-user-limits FALSE diff --git a/mysql-test/suite/innodb/include/alter_instant.inc b/mysql-test/suite/innodb/include/alter_instant.inc new file mode 100644 index 00000000000..cf0c082416b --- /dev/null +++ b/mysql-test/suite/innodb/include/alter_instant.inc @@ -0,0 +1,33 @@ +CREATE TABLE t1(f1 INT NOT NULL, + f2 INT NOT NULL, + f3 INT AS (f2 * f2) VIRTUAL)engine=innodb; + +INSERT INTO t1(f1, f2) VALUES(1, 1); + +--echo # +--echo # ALGORITHM=$algorithm_type +--echo # + +--enable_info +--echo # Add column at the end of the table +--error $error_code +--eval ALTER TABLE t1 ADD COLUMN f4 char(100) default "BIG WALL", ALGORITHM=$algorithm_type + +--echo # Change virtual column expression +--error $error_code +--eval ALTER TABLE t1 CHANGE f3 f3 INT AS (f2 * f2) VIRTUAL, ALGORITHM=$algorithm_type + +--echo # Add virtual column +--error $error_code +--eval ALTER TABLE t1 ADD COLUMN f5 INT AS (f2) VIRTUAL, ALGORITHM=$algorithm_type + +--echo # Rename Column +--error $error_code +--eval ALTER TABLE t1 CHANGE f3 vcol INT AS (f2) VIRTUAL, ALGORITHM=$algorithm_type + +--echo # Rename table +--error $error_code +--eval ALTER TABLE t1 RENAME t2, algorithm=$algorithm_type + +DROP TABLE t2; +--disable_info diff --git a/mysql-test/suite/innodb/include/alter_nocopy.inc b/mysql-test/suite/innodb/include/alter_nocopy.inc new file mode 100644 index 00000000000..6b19d244bd9 --- /dev/null +++ b/mysql-test/suite/innodb/include/alter_nocopy.inc @@ -0,0 +1,33 @@ +CREATE TABLE t1(f1 INT PRIMARY KEY, f2 INT NOT NULL, + f3 INT AS (f2 * f2) VIRTUAL, + f4 INT NOT NULL UNIQUE, + f5 INT NOT NULL, + INDEX`idx`(f2))ENGINE=INNODB; + +CREATE TABLE t2(f1 INT NOT NULL, f2 INT NOT NULL, + INDEX(f1), + FOREIGN KEY `fidx` (f1) REFERENCES t1(f1))ENGINE=INNODB; + +INSERT INTO t1(f1, f2, f4, f5) VALUES(1, 2, 3, 4); + +SELECT @@alter_algorithm; + +--enable_info +--error $error_code +--eval ALTER TABLE t1 ADD INDEX idx1(f4) + +--error $error_code +--eval ALTER TABLE t1 DROP INDEX idx + +--error $error_code +--eval ALTER TABLE t1 ADD UNIQUE INDEX u1(f2) + +--error $error_code +--eval ALTER TABLE t1 DROP INDEX f4 + +SET foreign_key_checks = 0; +--error $error_code +--eval ALTER TABLE t1 ADD FOREIGN KEY(f5) REFERENCES t2(f1) + +DROP TABLE t2, t1; +--disable_info diff --git a/mysql-test/suite/innodb/include/alter_nocopy_fail.inc b/mysql-test/suite/innodb/include/alter_nocopy_fail.inc new file mode 100644 index 00000000000..a075cf96e3c --- /dev/null +++ b/mysql-test/suite/innodb/include/alter_nocopy_fail.inc @@ -0,0 +1,51 @@ +CREATE TABLE t1(f1 INT NOT NULL, + f2 INT NOT NULL, + f3 INT NULL, + f4 INT as (f2) STORED, + f5 INT as (f3) STORED, + PRIMARY KEY(f1))ROW_FORMAT=COMPRESSED, ENGINE=INNODB; +INSERT INTO t1(f1, f2, f3) VALUES(1, 1, 1); + +SELECT @@alter_algorithm; + +--enable_info +--echo # All the following cases needs table rebuild + +--echo # Add and Drop primary key +--error $error_code +--eval ALTER TABLE t1 ADD COLUMN col1 INT NOT NULL,DROP PRIMARY KEY,ADD PRIMARY KEY(col1) + +--echo # Make existing column NULLABLE +--error $error_code +--eval ALTER TABLE t1 MODIFY f2 INT + +--echo # Make existing column NON-NULLABLE +--error $error_code +--eval ALTER TABLE t1 MODIFY f3 INT NOT NULL + +--echo # Drop Stored Column +--error $error_code +--eval ALTER TABLE t1 DROP COLUMN f5 + +--echo # Add base non-generated column as a last column in the compressed table +--error $error_code +--eval ALTER TABLE t1 ADD COLUMN f6 INT NOT NULL + +--echo # Add base non-generated column but not in the last position +--error $error_code +--eval ALTER TABLE t1 ADD COLUMN f7 INT NOT NULL after f3 + +--echo # Force the table to rebuild +--error $error_code +--eval ALTER TABLE t1 FORCE + +--echo # Row format changes +--error $error_code +--eval ALTER TABLE t1 ROW_FORMAT=COMPRESSED + +--echo # Engine table +--error $error_code +--eval ALTER TABLE t1 ENGINE=INNODB + +DROP TABLE t1; +--disable_info diff --git a/mysql-test/suite/innodb/r/alter_algorithm,COPY.rdiff b/mysql-test/suite/innodb/r/alter_algorithm,COPY.rdiff new file mode 100644 index 00000000000..be71e125e22 --- /dev/null +++ b/mysql-test/suite/innodb/r/alter_algorithm,COPY.rdiff @@ -0,0 +1,92 @@ +--- alter_algorithm.result 2018-05-06 23:42:08.022302601 +0530 ++++ alter_algorithm.reject 2018-05-06 23:42:16.382634082 +0530 +@@ -7,35 +7,44 @@ + INSERT INTO t1(f1, f2, f3) VALUES(1, 1, 1); + SELECT @@alter_algorithm; + @@alter_algorithm +-NOCOPY ++COPY + # All the following cases needs table rebuild + # Add and Drop primary key + ALTER TABLE t1 ADD COLUMN col1 INT NOT NULL,DROP PRIMARY KEY,ADD PRIMARY KEY(col1); +-ERROR 0A000: ALGORITHM=NOCOPY is not supported for this operation. Try ALGORITHM=INPLACE ++affected rows: 1 ++info: Records: 1 Duplicates: 0 Warnings: 0 + # Make existing column NULLABLE + ALTER TABLE t1 MODIFY f2 INT; +-ERROR 0A000: ALGORITHM=NOCOPY is not supported for this operation. Try ALGORITHM=INPLACE ++affected rows: 1 ++info: Records: 1 Duplicates: 0 Warnings: 0 + # Make existing column NON-NULLABLE + ALTER TABLE t1 MODIFY f3 INT NOT NULL; +-ERROR 0A000: ALGORITHM=NOCOPY is not supported for this operation. Try ALGORITHM=INPLACE ++affected rows: 1 ++info: Records: 1 Duplicates: 0 Warnings: 0 + # Drop Stored Column + ALTER TABLE t1 DROP COLUMN f5; +-ERROR 0A000: ALGORITHM=NOCOPY is not supported for this operation. Try ALGORITHM=INPLACE ++affected rows: 1 ++info: Records: 1 Duplicates: 0 Warnings: 0 + # Add base non-generated column as a last column in the compressed table + ALTER TABLE t1 ADD COLUMN f6 INT NOT NULL; +-ERROR 0A000: ALGORITHM=NOCOPY is not supported for this operation. Try ALGORITHM=INPLACE ++affected rows: 1 ++info: Records: 1 Duplicates: 0 Warnings: 0 + # Add base non-generated column but not in the last position + ALTER TABLE t1 ADD COLUMN f7 INT NOT NULL after f3; +-ERROR 0A000: ALGORITHM=NOCOPY is not supported for this operation. Try ALGORITHM=INPLACE ++affected rows: 1 ++info: Records: 1 Duplicates: 0 Warnings: 0 + # Force the table to rebuild + ALTER TABLE t1 FORCE; +-ERROR 0A000: ALGORITHM=NOCOPY is not supported for this operation. Try ALGORITHM=INPLACE ++affected rows: 1 ++info: Records: 1 Duplicates: 0 Warnings: 0 + # Row format changes + ALTER TABLE t1 ROW_FORMAT=COMPRESSED; +-ERROR 0A000: ALGORITHM=NOCOPY is not supported for this operation. Try ALGORITHM=INPLACE ++affected rows: 1 ++info: Records: 1 Duplicates: 0 Warnings: 0 + # Engine table + ALTER TABLE t1 ENGINE=INNODB; +-ERROR 0A000: ALGORITHM=NOCOPY is not supported for this operation. Try ALGORITHM=INPLACE ++affected rows: 1 ++info: Records: 1 Duplicates: 0 Warnings: 0 + DROP TABLE t1; + affected rows: 0 + CREATE TABLE t1(f1 INT PRIMARY KEY, f2 INT NOT NULL, +@@ -49,23 +58,23 @@ + INSERT INTO t1(f1, f2, f4, f5) VALUES(1, 2, 3, 4); + SELECT @@alter_algorithm; + @@alter_algorithm +-NOCOPY ++COPY + ALTER TABLE t1 ADD INDEX idx1(f4); +-affected rows: 0 +-info: Records: 0 Duplicates: 0 Warnings: 0 ++affected rows: 1 ++info: Records: 1 Duplicates: 0 Warnings: 0 + ALTER TABLE t1 DROP INDEX idx; +-affected rows: 0 +-info: Records: 0 Duplicates: 0 Warnings: 0 ++affected rows: 1 ++info: Records: 1 Duplicates: 0 Warnings: 0 + ALTER TABLE t1 ADD UNIQUE INDEX u1(f2); +-affected rows: 0 +-info: Records: 0 Duplicates: 0 Warnings: 0 ++affected rows: 1 ++info: Records: 1 Duplicates: 0 Warnings: 0 + ALTER TABLE t1 DROP INDEX f4; +-affected rows: 0 +-info: Records: 0 Duplicates: 0 Warnings: 0 ++affected rows: 1 ++info: Records: 1 Duplicates: 0 Warnings: 0 + SET foreign_key_checks = 0; + affected rows: 0 + ALTER TABLE t1 ADD FOREIGN KEY(f5) REFERENCES t2(f1); +-affected rows: 0 +-info: Records: 0 Duplicates: 0 Warnings: 0 ++affected rows: 1 ++info: Records: 1 Duplicates: 0 Warnings: 0 + DROP TABLE t2, t1; + affected rows: 0 diff --git a/mysql-test/suite/innodb/r/alter_algorithm,INPLACE.rdiff b/mysql-test/suite/innodb/r/alter_algorithm,INPLACE.rdiff new file mode 100644 index 00000000000..71891bbf473 --- /dev/null +++ b/mysql-test/suite/innodb/r/alter_algorithm,INPLACE.rdiff @@ -0,0 +1,66 @@ +--- alter_algorithm.result 2018-05-06 23:42:08.022302601 +0530 ++++ alter_algorithm.reject 2018-05-06 23:45:23.813346814 +0530 +@@ -7,35 +7,44 @@ + INSERT INTO t1(f1, f2, f3) VALUES(1, 1, 1); + SELECT @@alter_algorithm; + @@alter_algorithm +-NOCOPY ++INPLACE + # All the following cases needs table rebuild + # Add and Drop primary key + ALTER TABLE t1 ADD COLUMN col1 INT NOT NULL,DROP PRIMARY KEY,ADD PRIMARY KEY(col1); +-ERROR 0A000: ALGORITHM=NOCOPY is not supported for this operation. Try ALGORITHM=INPLACE ++affected rows: 0 ++info: Records: 0 Duplicates: 0 Warnings: 0 + # Make existing column NULLABLE + ALTER TABLE t1 MODIFY f2 INT; +-ERROR 0A000: ALGORITHM=NOCOPY is not supported for this operation. Try ALGORITHM=INPLACE ++affected rows: 0 ++info: Records: 0 Duplicates: 0 Warnings: 0 + # Make existing column NON-NULLABLE + ALTER TABLE t1 MODIFY f3 INT NOT NULL; +-ERROR 0A000: ALGORITHM=NOCOPY is not supported for this operation. Try ALGORITHM=INPLACE ++affected rows: 0 ++info: Records: 0 Duplicates: 0 Warnings: 0 + # Drop Stored Column + ALTER TABLE t1 DROP COLUMN f5; +-ERROR 0A000: ALGORITHM=NOCOPY is not supported for this operation. Try ALGORITHM=INPLACE ++affected rows: 0 ++info: Records: 0 Duplicates: 0 Warnings: 0 + # Add base non-generated column as a last column in the compressed table + ALTER TABLE t1 ADD COLUMN f6 INT NOT NULL; +-ERROR 0A000: ALGORITHM=NOCOPY is not supported for this operation. Try ALGORITHM=INPLACE ++affected rows: 0 ++info: Records: 0 Duplicates: 0 Warnings: 0 + # Add base non-generated column but not in the last position + ALTER TABLE t1 ADD COLUMN f7 INT NOT NULL after f3; +-ERROR 0A000: ALGORITHM=NOCOPY is not supported for this operation. Try ALGORITHM=INPLACE ++affected rows: 0 ++info: Records: 0 Duplicates: 0 Warnings: 0 + # Force the table to rebuild + ALTER TABLE t1 FORCE; +-ERROR 0A000: ALGORITHM=NOCOPY is not supported for this operation. Try ALGORITHM=INPLACE ++affected rows: 0 ++info: Records: 0 Duplicates: 0 Warnings: 0 + # Row format changes + ALTER TABLE t1 ROW_FORMAT=COMPRESSED; +-ERROR 0A000: ALGORITHM=NOCOPY is not supported for this operation. Try ALGORITHM=INPLACE ++affected rows: 0 ++info: Records: 0 Duplicates: 0 Warnings: 0 + # Engine table + ALTER TABLE t1 ENGINE=INNODB; +-ERROR 0A000: ALGORITHM=NOCOPY is not supported for this operation. Try ALGORITHM=INPLACE ++affected rows: 0 ++info: Records: 0 Duplicates: 0 Warnings: 0 + DROP TABLE t1; + affected rows: 0 + CREATE TABLE t1(f1 INT PRIMARY KEY, f2 INT NOT NULL, +@@ -49,7 +58,7 @@ + INSERT INTO t1(f1, f2, f4, f5) VALUES(1, 2, 3, 4); + SELECT @@alter_algorithm; + @@alter_algorithm +-NOCOPY ++INPLACE + ALTER TABLE t1 ADD INDEX idx1(f4); + affected rows: 0 + info: Records: 0 Duplicates: 0 Warnings: 0 diff --git a/mysql-test/suite/innodb/r/alter_algorithm,INSTANT.rdiff b/mysql-test/suite/innodb/r/alter_algorithm,INSTANT.rdiff new file mode 100644 index 00000000000..6e12b78fb9d --- /dev/null +++ b/mysql-test/suite/innodb/r/alter_algorithm,INSTANT.rdiff @@ -0,0 +1,78 @@ +--- alter_algorithm.result 2018-05-06 23:42:08.022302601 +0530 ++++ alter_algorithm.reject 2018-05-06 23:46:08.482772800 +0530 +@@ -7,35 +7,35 @@ + INSERT INTO t1(f1, f2, f3) VALUES(1, 1, 1); + SELECT @@alter_algorithm; + @@alter_algorithm +-NOCOPY ++INSTANT + # All the following cases needs table rebuild + # Add and Drop primary key + ALTER TABLE t1 ADD COLUMN col1 INT NOT NULL,DROP PRIMARY KEY,ADD PRIMARY KEY(col1); +-ERROR 0A000: ALGORITHM=NOCOPY is not supported for this operation. Try ALGORITHM=INPLACE ++Got one of the listed errors + # Make existing column NULLABLE + ALTER TABLE t1 MODIFY f2 INT; +-ERROR 0A000: ALGORITHM=NOCOPY is not supported for this operation. Try ALGORITHM=INPLACE ++Got one of the listed errors + # Make existing column NON-NULLABLE + ALTER TABLE t1 MODIFY f3 INT NOT NULL; +-ERROR 0A000: ALGORITHM=NOCOPY is not supported for this operation. Try ALGORITHM=INPLACE ++Got one of the listed errors + # Drop Stored Column + ALTER TABLE t1 DROP COLUMN f5; +-ERROR 0A000: ALGORITHM=NOCOPY is not supported for this operation. Try ALGORITHM=INPLACE ++Got one of the listed errors + # Add base non-generated column as a last column in the compressed table + ALTER TABLE t1 ADD COLUMN f6 INT NOT NULL; +-ERROR 0A000: ALGORITHM=NOCOPY is not supported for this operation. Try ALGORITHM=INPLACE ++Got one of the listed errors + # Add base non-generated column but not in the last position + ALTER TABLE t1 ADD COLUMN f7 INT NOT NULL after f3; +-ERROR 0A000: ALGORITHM=NOCOPY is not supported for this operation. Try ALGORITHM=INPLACE ++Got one of the listed errors + # Force the table to rebuild + ALTER TABLE t1 FORCE; +-ERROR 0A000: ALGORITHM=NOCOPY is not supported for this operation. Try ALGORITHM=INPLACE ++Got one of the listed errors + # Row format changes + ALTER TABLE t1 ROW_FORMAT=COMPRESSED; +-ERROR 0A000: ALGORITHM=NOCOPY is not supported for this operation. Try ALGORITHM=INPLACE ++Got one of the listed errors + # Engine table + ALTER TABLE t1 ENGINE=INNODB; +-ERROR 0A000: ALGORITHM=NOCOPY is not supported for this operation. Try ALGORITHM=INPLACE ++Got one of the listed errors + DROP TABLE t1; + affected rows: 0 + CREATE TABLE t1(f1 INT PRIMARY KEY, f2 INT NOT NULL, +@@ -49,23 +49,18 @@ + INSERT INTO t1(f1, f2, f4, f5) VALUES(1, 2, 3, 4); + SELECT @@alter_algorithm; + @@alter_algorithm +-NOCOPY ++INSTANT + ALTER TABLE t1 ADD INDEX idx1(f4); +-affected rows: 0 +-info: Records: 0 Duplicates: 0 Warnings: 0 ++ERROR 0A000: ALGORITHM=INSTANT is not supported. Reason: ADD INDEX. Try ALGORITHM=NOCOPY + ALTER TABLE t1 DROP INDEX idx; +-affected rows: 0 +-info: Records: 0 Duplicates: 0 Warnings: 0 ++ERROR 0A000: ALGORITHM=INSTANT is not supported. Reason: DROP INDEX. Try ALGORITHM=NOCOPY + ALTER TABLE t1 ADD UNIQUE INDEX u1(f2); +-affected rows: 0 +-info: Records: 0 Duplicates: 0 Warnings: 0 ++ERROR 0A000: ALGORITHM=INSTANT is not supported. Reason: ADD INDEX. Try ALGORITHM=NOCOPY + ALTER TABLE t1 DROP INDEX f4; +-affected rows: 0 +-info: Records: 0 Duplicates: 0 Warnings: 0 ++ERROR 0A000: ALGORITHM=INSTANT is not supported. Reason: DROP INDEX. Try ALGORITHM=NOCOPY + SET foreign_key_checks = 0; + affected rows: 0 + ALTER TABLE t1 ADD FOREIGN KEY(f5) REFERENCES t2(f1); +-affected rows: 0 +-info: Records: 0 Duplicates: 0 Warnings: 0 ++ERROR 0A000: ALGORITHM=INSTANT is not supported. Reason: ADD INDEX. Try ALGORITHM=NOCOPY + DROP TABLE t2, t1; + affected rows: 0 diff --git a/mysql-test/suite/innodb/r/alter_algorithm.result b/mysql-test/suite/innodb/r/alter_algorithm.result new file mode 100644 index 00000000000..ee91159bf7a --- /dev/null +++ b/mysql-test/suite/innodb/r/alter_algorithm.result @@ -0,0 +1,71 @@ +CREATE TABLE t1(f1 INT NOT NULL, +f2 INT NOT NULL, +f3 INT NULL, +f4 INT as (f2) STORED, +f5 INT as (f3) STORED, +PRIMARY KEY(f1))ROW_FORMAT=COMPRESSED, ENGINE=INNODB; +INSERT INTO t1(f1, f2, f3) VALUES(1, 1, 1); +SELECT @@alter_algorithm; +@@alter_algorithm +NOCOPY +# All the following cases needs table rebuild +# Add and Drop primary key +ALTER TABLE t1 ADD COLUMN col1 INT NOT NULL,DROP PRIMARY KEY,ADD PRIMARY KEY(col1); +ERROR 0A000: ALGORITHM=NOCOPY is not supported for this operation. Try ALGORITHM=INPLACE +# Make existing column NULLABLE +ALTER TABLE t1 MODIFY f2 INT; +ERROR 0A000: ALGORITHM=NOCOPY is not supported for this operation. Try ALGORITHM=INPLACE +# Make existing column NON-NULLABLE +ALTER TABLE t1 MODIFY f3 INT NOT NULL; +ERROR 0A000: ALGORITHM=NOCOPY is not supported for this operation. Try ALGORITHM=INPLACE +# Drop Stored Column +ALTER TABLE t1 DROP COLUMN f5; +ERROR 0A000: ALGORITHM=NOCOPY is not supported for this operation. Try ALGORITHM=INPLACE +# Add base non-generated column as a last column in the compressed table +ALTER TABLE t1 ADD COLUMN f6 INT NOT NULL; +ERROR 0A000: ALGORITHM=NOCOPY is not supported for this operation. Try ALGORITHM=INPLACE +# Add base non-generated column but not in the last position +ALTER TABLE t1 ADD COLUMN f7 INT NOT NULL after f3; +ERROR 0A000: ALGORITHM=NOCOPY is not supported for this operation. Try ALGORITHM=INPLACE +# Force the table to rebuild +ALTER TABLE t1 FORCE; +ERROR 0A000: ALGORITHM=NOCOPY is not supported for this operation. Try ALGORITHM=INPLACE +# Row format changes +ALTER TABLE t1 ROW_FORMAT=COMPRESSED; +ERROR 0A000: ALGORITHM=NOCOPY is not supported for this operation. Try ALGORITHM=INPLACE +# Engine table +ALTER TABLE t1 ENGINE=INNODB; +ERROR 0A000: ALGORITHM=NOCOPY is not supported for this operation. Try ALGORITHM=INPLACE +DROP TABLE t1; +affected rows: 0 +CREATE TABLE t1(f1 INT PRIMARY KEY, f2 INT NOT NULL, +f3 INT AS (f2 * f2) VIRTUAL, +f4 INT NOT NULL UNIQUE, +f5 INT NOT NULL, +INDEX`idx`(f2))ENGINE=INNODB; +CREATE TABLE t2(f1 INT NOT NULL, f2 INT NOT NULL, +INDEX(f1), +FOREIGN KEY `fidx` (f1) REFERENCES t1(f1))ENGINE=INNODB; +INSERT INTO t1(f1, f2, f4, f5) VALUES(1, 2, 3, 4); +SELECT @@alter_algorithm; +@@alter_algorithm +NOCOPY +ALTER TABLE t1 ADD INDEX idx1(f4); +affected rows: 0 +info: Records: 0 Duplicates: 0 Warnings: 0 +ALTER TABLE t1 DROP INDEX idx; +affected rows: 0 +info: Records: 0 Duplicates: 0 Warnings: 0 +ALTER TABLE t1 ADD UNIQUE INDEX u1(f2); +affected rows: 0 +info: Records: 0 Duplicates: 0 Warnings: 0 +ALTER TABLE t1 DROP INDEX f4; +affected rows: 0 +info: Records: 0 Duplicates: 0 Warnings: 0 +SET foreign_key_checks = 0; +affected rows: 0 +ALTER TABLE t1 ADD FOREIGN KEY(f5) REFERENCES t2(f1); +affected rows: 0 +info: Records: 0 Duplicates: 0 Warnings: 0 +DROP TABLE t2, t1; +affected rows: 0 diff --git a/mysql-test/suite/innodb/r/alter_instant,COPY.rdiff b/mysql-test/suite/innodb/r/alter_instant,COPY.rdiff new file mode 100644 index 00000000000..cb4a72614b9 --- /dev/null +++ b/mysql-test/suite/innodb/r/alter_instant,COPY.rdiff @@ -0,0 +1,61 @@ +--- alter_instant.result 2018-04-10 11:19:46.299868465 +0530 ++++ alter_instant.reject 2018-04-10 11:21:19.648918489 +0530 +@@ -8,30 +8,30 @@ + INSERT INTO t1(f1, f2) VALUES(1, 1); + select @@alter_algorithm; + @@alter_algorithm +-NOCOPY ++COPY + # Add column at the end of the table + ALTER TABLE t1 ADD COLUMN f4 char(100) default "BIG WALL"; +-affected rows: 0 +-info: Records: 0 Duplicates: 0 Warnings: 0 ++affected rows: 1 ++info: Records: 1 Duplicates: 0 Warnings: 0 + # Change virtual column expression + ALTER TABLE t1 CHANGE f3 f3 INT AS (f2 * f2) VIRTUAL; +-affected rows: 0 +-info: Records: 0 Duplicates: 0 Warnings: 0 ++affected rows: 1 ++info: Records: 1 Duplicates: 0 Warnings: 0 + # Add virtual column + ALTER TABLE t1 ADD COLUMN f5 INT AS (f2) VIRTUAL; +-affected rows: 0 +-info: Records: 0 Duplicates: 0 Warnings: 0 ++affected rows: 1 ++info: Records: 1 Duplicates: 0 Warnings: 0 + # Rename Column + ALTER TABLE t1 CHANGE f3 vcol INT AS (f2) VIRTUAL; +-affected rows: 0 +-info: Records: 0 Duplicates: 0 Warnings: 0 ++affected rows: 1 ++info: Records: 1 Duplicates: 0 Warnings: 0 + # Rename table + ALTER TABLE t1 RENAME t3; + affected rows: 0 + # Drop Virtual Column + ALTER TABLE t3 DROP COLUMN vcol; +-affected rows: 0 +-info: Records: 0 Duplicates: 0 Warnings: 0 ++affected rows: 1 ++info: Records: 1 Duplicates: 0 Warnings: 0 + # Column length varies + ALTER TABLE t2 CHANGE f3 f3 VARCHAR(20); + affected rows: 0 +@@ -39,12 +39,12 @@ + SET foreign_key_checks = 0; + affected rows: 0 + ALTER TABLE t3 ADD FOREIGN KEY `fidx`(f2) REFERENCES t2(f1); +-affected rows: 0 +-info: Records: 0 Duplicates: 0 Warnings: 0 ++affected rows: 1 ++info: Records: 1 Duplicates: 0 Warnings: 0 + SET foreign_key_checks = 1; + affected rows: 0 + ALTER TABLE t3 DROP FOREIGN KEY `fidx`; +-affected rows: 0 +-info: Records: 0 Duplicates: 0 Warnings: 0 ++affected rows: 1 ++info: Records: 1 Duplicates: 0 Warnings: 0 + DROP TABLE t3, t2; + affected rows: 0 diff --git a/mysql-test/suite/innodb/r/alter_instant,INPLACE.rdiff b/mysql-test/suite/innodb/r/alter_instant,INPLACE.rdiff new file mode 100644 index 00000000000..ec80e1d8ef0 --- /dev/null +++ b/mysql-test/suite/innodb/r/alter_instant,INPLACE.rdiff @@ -0,0 +1,11 @@ +--- alter_instant.result 2018-04-10 11:19:46.299868465 +0530 ++++ alter_instant.reject 2018-04-10 11:22:19.433617807 +0530 +@@ -8,7 +8,7 @@ + INSERT INTO t1(f1, f2) VALUES(1, 1); + select @@alter_algorithm; + @@alter_algorithm +-NOCOPY ++INPLACE + # Add column at the end of the table + ALTER TABLE t1 ADD COLUMN f4 char(100) default "BIG WALL"; + affected rows: 0 diff --git a/mysql-test/suite/innodb/r/alter_instant,INSTANT.rdiff b/mysql-test/suite/innodb/r/alter_instant,INSTANT.rdiff new file mode 100644 index 00000000000..cf2f8a2d719 --- /dev/null +++ b/mysql-test/suite/innodb/r/alter_instant,INSTANT.rdiff @@ -0,0 +1,11 @@ +--- alter_instant.result 2018-04-10 11:19:46.299868465 +0530 ++++ alter_instant.reject 2018-04-10 11:22:47.281949905 +0530 +@@ -8,7 +8,7 @@ + INSERT INTO t1(f1, f2) VALUES(1, 1); + select @@alter_algorithm; + @@alter_algorithm +-NOCOPY ++INSTANT + # Add column at the end of the table + ALTER TABLE t1 ADD COLUMN f4 char(100) default "BIG WALL"; + affected rows: 0 diff --git a/mysql-test/suite/innodb/r/alter_instant.result b/mysql-test/suite/innodb/r/alter_instant.result new file mode 100644 index 00000000000..ec64e41cd01 --- /dev/null +++ b/mysql-test/suite/innodb/r/alter_instant.result @@ -0,0 +1,50 @@ +CREATE TABLE t1(f1 INT NOT NULL, +f2 INT NOT NULL, +f3 INT AS (f2 * f2) VIRTUAL, +INDEX idx (f2))engine=innodb; +CREATE TABLE t2(f1 INT NOT NULL, f2 INT NOT NULL, +f3 VARCHAR(10), +INDEX(f1))ENGINE=INNODB; +INSERT INTO t1(f1, f2) VALUES(1, 1); +select @@alter_algorithm; +@@alter_algorithm +NOCOPY +# Add column at the end of the table +ALTER TABLE t1 ADD COLUMN f4 char(100) default "BIG WALL"; +affected rows: 0 +info: Records: 0 Duplicates: 0 Warnings: 0 +# Change virtual column expression +ALTER TABLE t1 CHANGE f3 f3 INT AS (f2 * f2) VIRTUAL; +affected rows: 0 +info: Records: 0 Duplicates: 0 Warnings: 0 +# Add virtual column +ALTER TABLE t1 ADD COLUMN f5 INT AS (f2) VIRTUAL; +affected rows: 0 +info: Records: 0 Duplicates: 0 Warnings: 0 +# Rename Column +ALTER TABLE t1 CHANGE f3 vcol INT AS (f2) VIRTUAL; +affected rows: 0 +info: Records: 0 Duplicates: 0 Warnings: 0 +# Rename table +ALTER TABLE t1 RENAME t3; +affected rows: 0 +# Drop Virtual Column +ALTER TABLE t3 DROP COLUMN vcol; +affected rows: 0 +info: Records: 0 Duplicates: 0 Warnings: 0 +# Column length varies +ALTER TABLE t2 CHANGE f3 f3 VARCHAR(20); +affected rows: 0 +info: Records: 0 Duplicates: 0 Warnings: 0 +SET foreign_key_checks = 0; +affected rows: 0 +ALTER TABLE t3 ADD FOREIGN KEY `fidx`(f2) REFERENCES t2(f1); +affected rows: 0 +info: Records: 0 Duplicates: 0 Warnings: 0 +SET foreign_key_checks = 1; +affected rows: 0 +ALTER TABLE t3 DROP FOREIGN KEY `fidx`; +affected rows: 0 +info: Records: 0 Duplicates: 0 Warnings: 0 +DROP TABLE t3, t2; +affected rows: 0 diff --git a/mysql-test/suite/innodb/r/innodb-online-alter-gis.result b/mysql-test/suite/innodb/r/innodb-online-alter-gis.result index 79c0f2386aa..faf6ab7fa4a 100644 --- a/mysql-test/suite/innodb/r/innodb-online-alter-gis.result +++ b/mysql-test/suite/innodb/r/innodb-online-alter-gis.result @@ -1,13 +1,13 @@ create table t1(a int not null primary key, b geometry not null) engine=innodb; -ALTER ONLINE TABLE t1 ADD SPATIAL INDEX new(b); -ERROR 0A000: LOCK=NONE is not supported. Reason: Do not support online operation on table with GIS index. Try LOCK=SHARED +ALTER ONLINE TABLE t1 ADD SPATIAL INDEX new(b), ALGORITHM=INSTANT; +ERROR 0A000: ALGORITHM=INSTANT is not supported. Reason: Do not support online operation on table with GIS index. Try ALGORITHM=NOCOPY show warnings; Level Code Message -Error 1846 LOCK=NONE is not supported. Reason: Do not support online operation on table with GIS index. Try LOCK=SHARED +Error 1846 ALGORITHM=INSTANT is not supported. Reason: Do not support online operation on table with GIS index. Try ALGORITHM=NOCOPY show errors; Level Code Message -Error 1846 LOCK=NONE is not supported. Reason: Do not support online operation on table with GIS index. Try LOCK=SHARED -ALTER ONLINE TABLE t1 ADD SPATIAL INDEX new(b), LOCK=SHARED; +Error 1846 ALGORITHM=INSTANT is not supported. Reason: Do not support online operation on table with GIS index. Try ALGORITHM=NOCOPY +ALTER ONLINE TABLE t1 ADD SPATIAL INDEX new(b), LOCK=SHARED, ALGORITHM=NOCOPY; show warnings; Level Code Message show errors; diff --git a/mysql-test/suite/innodb/r/instant_alter_debug.result b/mysql-test/suite/innodb/r/instant_alter_debug.result index 5f2a10f82a9..389a04007e2 100644 --- a/mysql-test/suite/innodb/r/instant_alter_debug.result +++ b/mysql-test/suite/innodb/r/instant_alter_debug.result @@ -36,14 +36,7 @@ SELECT COUNT(*)>0 FROM INFORMATION_SCHEMA.COLUMNS LEFT JOIN t4 ON (NUMERIC_SCALE = pk); COUNT(*)>0 1 -SET DEBUG_SYNC='innodb_inplace_alter_table_enter SIGNAL enter WAIT_FOR delete'; ALTER TABLE t4 ADD COLUMN c INT; -connect dml,localhost,root,,; -SET DEBUG_SYNC='now WAIT_FOR enter'; -DELETE FROM t4; -InnoDB 0 transactions not purged -SET DEBUG_SYNC='now SIGNAL delete'; -connection default; CREATE TABLE t5 (i INT, KEY(i)) ENGINE=InnoDB; INSERT INTO t5 VALUES (-42); ALTER TABLE t5 ADD UNIQUE ui(i); @@ -61,7 +54,7 @@ INSERT INTO t8 VALUES (NULL); ALTER TABLE t8 ADD c CHAR(3); SET DEBUG_SYNC='row_log_table_apply1_before SIGNAL rebuilt WAIT_FOR dml'; ALTER TABLE t8 FORCE; -connection dml; +connect dml,localhost,root,,; SET DEBUG_SYNC='now WAIT_FOR rebuilt'; BEGIN; INSERT INTO t8 SET i=1; diff --git a/mysql-test/suite/innodb/t/alter_algorithm.combinations b/mysql-test/suite/innodb/t/alter_algorithm.combinations new file mode 100644 index 00000000000..197748d168e --- /dev/null +++ b/mysql-test/suite/innodb/t/alter_algorithm.combinations @@ -0,0 +1,11 @@ +[COPY] +--alter_algorithm=copy + +[INPLACE] +--alter_algorithm=inplace + +[NOCOPY] +--alter_algorithm=nocopy + +[INSTANT] +--alter_algorithm=instant diff --git a/mysql-test/suite/innodb/t/alter_algorithm.inc b/mysql-test/suite/innodb/t/alter_algorithm.inc new file mode 100644 index 00000000000..1aa3caf7d66 --- /dev/null +++ b/mysql-test/suite/innodb/t/alter_algorithm.inc @@ -0,0 +1,2 @@ +# See also alter_algorithm.combinations +--source include/have_innodb.inc diff --git a/mysql-test/suite/innodb/t/alter_algorithm.test b/mysql-test/suite/innodb/t/alter_algorithm.test new file mode 100644 index 00000000000..5a720489281 --- /dev/null +++ b/mysql-test/suite/innodb/t/alter_algorithm.test @@ -0,0 +1,22 @@ +--source include/have_innodb.inc +let $algorithm = `SELECT @@ALTER_ALGORITHM`; +let $error_code = 0; + +if ($algorithm == "NOCOPY") { + let $error_code = ER_ALTER_OPERATION_NOT_SUPPORTED; +} + +if ($algorithm == "INSTANT") { + let $error_code = ER_ALTER_OPERATION_NOT_SUPPORTED, ER_ALTER_OPERATION_NOT_SUPPORTED_REASON; +} + +--source include/alter_nocopy_fail.inc + +if ($algorithm == "NOCOPY") { + let $error_code = 0; +} + +if ($algorithm == "INSTANT") { + let $error_code = ER_ALTER_OPERATION_NOT_SUPPORTED_REASON; +} +--source include/alter_nocopy.inc diff --git a/mysql-test/suite/innodb/t/alter_instant.test b/mysql-test/suite/innodb/t/alter_instant.test new file mode 100644 index 00000000000..dddb7b8ce27 --- /dev/null +++ b/mysql-test/suite/innodb/t/alter_instant.test @@ -0,0 +1,45 @@ +--source alter_algorithm.inc + +CREATE TABLE t1(f1 INT NOT NULL, + f2 INT NOT NULL, + f3 INT AS (f2 * f2) VIRTUAL, + INDEX idx (f2))engine=innodb; + +CREATE TABLE t2(f1 INT NOT NULL, f2 INT NOT NULL, + f3 VARCHAR(10), + INDEX(f1))ENGINE=INNODB; + +INSERT INTO t1(f1, f2) VALUES(1, 1); + +select @@alter_algorithm; + +--enable_info +--echo # Add column at the end of the table +--eval ALTER TABLE t1 ADD COLUMN f4 char(100) default "BIG WALL" + +--echo # Change virtual column expression +--eval ALTER TABLE t1 CHANGE f3 f3 INT AS (f2 * f2) VIRTUAL + +--echo # Add virtual column +--eval ALTER TABLE t1 ADD COLUMN f5 INT AS (f2) VIRTUAL + +--echo # Rename Column +--eval ALTER TABLE t1 CHANGE f3 vcol INT AS (f2) VIRTUAL + +--echo # Rename table +--eval ALTER TABLE t1 RENAME t3 + +--echo # Drop Virtual Column +--eval ALTER TABLE t3 DROP COLUMN vcol + +--echo # Column length varies +--eval ALTER TABLE t2 CHANGE f3 f3 VARCHAR(20) + +SET foreign_key_checks = 0; +--eval ALTER TABLE t3 ADD FOREIGN KEY `fidx`(f2) REFERENCES t2(f1) + +SET foreign_key_checks = 1; +--eval ALTER TABLE t3 DROP FOREIGN KEY `fidx` + +DROP TABLE t3, t2; +--disable_info diff --git a/mysql-test/suite/innodb/t/innodb-online-alter-gis.test b/mysql-test/suite/innodb/t/innodb-online-alter-gis.test index 2cb88d398bb..570e22d5dd1 100644 --- a/mysql-test/suite/innodb/t/innodb-online-alter-gis.test +++ b/mysql-test/suite/innodb/t/innodb-online-alter-gis.test @@ -2,10 +2,10 @@ create table t1(a int not null primary key, b geometry not null) engine=innodb; --error 1846 -ALTER ONLINE TABLE t1 ADD SPATIAL INDEX new(b); +ALTER ONLINE TABLE t1 ADD SPATIAL INDEX new(b), ALGORITHM=INSTANT; show warnings; show errors; -ALTER ONLINE TABLE t1 ADD SPATIAL INDEX new(b), LOCK=SHARED; +ALTER ONLINE TABLE t1 ADD SPATIAL INDEX new(b), LOCK=SHARED, ALGORITHM=NOCOPY; show warnings; show errors; drop table t1; diff --git a/mysql-test/suite/innodb/t/instant_alter_debug.test b/mysql-test/suite/innodb/t/instant_alter_debug.test index b4b64392245..9d85d281361 100644 --- a/mysql-test/suite/innodb/t/instant_alter_debug.test +++ b/mysql-test/suite/innodb/t/instant_alter_debug.test @@ -40,16 +40,7 @@ INSERT INTO t4 VALUES (0); ALTER TABLE t4 ADD COLUMN b INT; SELECT COUNT(*)>0 FROM INFORMATION_SCHEMA.COLUMNS LEFT JOIN t4 ON (NUMERIC_SCALE = pk); -SET DEBUG_SYNC='innodb_inplace_alter_table_enter SIGNAL enter WAIT_FOR delete'; ---send ALTER TABLE t4 ADD COLUMN c INT; -connect (dml,localhost,root,,); -SET DEBUG_SYNC='now WAIT_FOR enter'; -DELETE FROM t4; ---source include/wait_all_purged.inc -SET DEBUG_SYNC='now SIGNAL delete'; -connection default; -reap; CREATE TABLE t5 (i INT, KEY(i)) ENGINE=InnoDB; INSERT INTO t5 VALUES (-42); @@ -72,7 +63,7 @@ ALTER TABLE t8 ADD c CHAR(3); SET DEBUG_SYNC='row_log_table_apply1_before SIGNAL rebuilt WAIT_FOR dml'; --send ALTER TABLE t8 FORCE; -connection dml; +connect (dml,localhost,root,,); SET DEBUG_SYNC='now WAIT_FOR rebuilt'; BEGIN; INSERT INTO t8 SET i=1; diff --git a/mysql-test/suite/innodb_fts/r/innodb-fts-ddl.result b/mysql-test/suite/innodb_fts/r/innodb-fts-ddl.result index 3bf15bd98b5..c5c549f67a1 100644 --- a/mysql-test/suite/innodb_fts/r/innodb-fts-ddl.result +++ b/mysql-test/suite/innodb_fts/r/innodb-fts-ddl.result @@ -10,7 +10,9 @@ INSERT INTO fts_test (title,body) VALUES ('1001 MySQL Tricks','1. Never run mysqld as root. 2. ...'), ('MySQL vs. YourSQL','In the following database comparison ...'), ('MySQL Security','When configured properly, MySQL ...'); -CREATE FULLTEXT INDEX idx on fts_test (title, body); +ALTER TABLE fts_test ADD FULLTEXT `idx` (title, body), ALGORITHM=NOCOPY; +ERROR 0A000: ALGORITHM=NOCOPY is not supported for this operation. Try ALGORITHM=INPLACE +ALTER TABLE fts_test ADD FULLTEXT `idx` (title, body), ALGORITHM=INPLACE; Warnings: Warning 124 InnoDB rebuilding table to add column FTS_DOC_ID SELECT * FROM fts_test WHERE MATCH (title, body) @@ -26,7 +28,7 @@ INSERT INTO fts_test (title,body) VALUES ('1001 MySQL Tricks','1. Never run mysqld as root. 2. ...'), ('MySQL vs. YourSQL','In the following database comparison ...'), ('MySQL Security','When configured properly, MySQL ...'); -CREATE FULLTEXT INDEX idx on fts_test (title, body); +ALTER TABLE fts_test ADD FULLTEXT `idx` (title, body), ALGORITHM=NOCOPY; SELECT * FROM fts_test WHERE MATCH (title, body) AGAINST ('Tutorial' IN NATURAL LANGUAGE MODE); id title body @@ -68,7 +70,6 @@ FTS_DOC_ID BIGINT UNSIGNED AUTO_INCREMENT NOT NULL PRIMARY KEY, title VARCHAR(200), body TEXT ) ENGINE=InnoDB; -create unique index FTS_DOC_ID_INDEX on fts_test(FTS_DOC_ID); INSERT INTO fts_test (title,body) VALUES ('MySQL Tutorial','DBMS stands for DataBase ...') , ('How To Use MySQL Well','After you went through a ...'), @@ -78,7 +79,7 @@ INSERT INTO fts_test (title,body) VALUES ('MySQL Security','When configured properly, MySQL ...'); CREATE FULLTEXT INDEX idx on fts_test (title, body) LOCK=NONE; ERROR 0A000: LOCK=NONE is not supported. Reason: Fulltext index creation requires a lock. Try LOCK=SHARED -CREATE FULLTEXT INDEX idx on fts_test (title, body); +ALTER TABLE fts_test ADD FULLTEXT `idx` (title, body), ALGORITHM=NOCOPY; ALTER TABLE fts_test ROW_FORMAT=REDUNDANT, LOCK=NONE; ERROR 0A000: LOCK=NONE is not supported. Reason: InnoDB presently supports one FULLTEXT index creation at a time. Try LOCK=SHARED ALTER TABLE fts_test ROW_FORMAT=REDUNDANT; @@ -95,7 +96,6 @@ FTS_DOC_ID title body 1 MySQL Tutorial DBMS stands for DataBase ... 3 Optimizing MySQL In this tutorial we will show ... drop index idx on fts_test; -drop index FTS_DOC_ID_INDEX on fts_test; CREATE FULLTEXT INDEX idx on fts_test (title, body); SELECT * FROM fts_test WHERE MATCH (title, body) AGAINST ('Tutorial' IN NATURAL LANGUAGE MODE); @@ -202,7 +202,7 @@ FTS_DOC_ID title body DROP TABLE articles; create table articles(`FTS_DOC_ID` serial, `col32` timestamp not null,`col115` text) engine=innodb; -create fulltext index `idx5` on articles(`col115`) ; +create fulltext index `idx5` on articles(`col115`) ; alter ignore table articles add primary key (`col32`) ; drop table articles; CREATE TABLE articles ( diff --git a/mysql-test/suite/innodb_fts/t/innodb-fts-ddl.test b/mysql-test/suite/innodb_fts/t/innodb-fts-ddl.test index 58282809083..ddd92556772 100644 --- a/mysql-test/suite/innodb_fts/t/innodb-fts-ddl.test +++ b/mysql-test/suite/innodb_fts/t/innodb-fts-ddl.test @@ -18,14 +18,17 @@ INSERT INTO fts_test (title,body) VALUES ('MySQL vs. YourSQL','In the following database comparison ...'), ('MySQL Security','When configured properly, MySQL ...'); +# Table does rebuild when fts index builds for the first time +--error ER_ALTER_OPERATION_NOT_SUPPORTED +ALTER TABLE fts_test ADD FULLTEXT `idx` (title, body), ALGORITHM=NOCOPY; + # Create the FTS index -CREATE FULLTEXT INDEX idx on fts_test (title, body); +ALTER TABLE fts_test ADD FULLTEXT `idx` (title, body), ALGORITHM=INPLACE; # Select word "tutorial" in the table SELECT * FROM fts_test WHERE MATCH (title, body) AGAINST ('Tutorial' IN NATURAL LANGUAGE MODE); - # Drop the FTS idx DROP INDEX idx ON fts_test; @@ -38,9 +41,8 @@ INSERT INTO fts_test (title,body) VALUES ('MySQL vs. YourSQL','In the following database comparison ...'), ('MySQL Security','When configured properly, MySQL ...'); - -# Recreate the FTS index -CREATE FULLTEXT INDEX idx on fts_test (title, body); +# FTS_DOC_ID hidden column and FTS_DOC_ID index exist +ALTER TABLE fts_test ADD FULLTEXT `idx` (title, body), ALGORITHM=NOCOPY; # Select word "tutorial" in the table SELECT * FROM fts_test WHERE MATCH (title, body) @@ -81,8 +83,6 @@ CREATE TABLE fts_test ( body TEXT ) ENGINE=InnoDB; -create unique index FTS_DOC_ID_INDEX on fts_test(FTS_DOC_ID); - # Insert six rows INSERT INTO fts_test (title,body) VALUES ('MySQL Tutorial','DBMS stands for DataBase ...') , @@ -97,7 +97,7 @@ INSERT INTO fts_test (title,body) VALUES # column already exists. This has not been implemented yet. --error ER_ALTER_OPERATION_NOT_SUPPORTED_REASON CREATE FULLTEXT INDEX idx on fts_test (title, body) LOCK=NONE; -CREATE FULLTEXT INDEX idx on fts_test (title, body); +ALTER TABLE fts_test ADD FULLTEXT `idx` (title, body), ALGORITHM=NOCOPY; --error ER_ALTER_OPERATION_NOT_SUPPORTED_REASON ALTER TABLE fts_test ROW_FORMAT=REDUNDANT, LOCK=NONE; @@ -117,8 +117,6 @@ SELECT * FROM fts_test WHERE MATCH (title, body) # Drop the FTS_DOC_ID_INDEX and try again drop index idx on fts_test; -drop index FTS_DOC_ID_INDEX on fts_test; - CREATE FULLTEXT INDEX idx on fts_test (title, body); SELECT * FROM fts_test WHERE MATCH (title, body) @@ -232,7 +230,7 @@ DROP TABLE articles; create table articles(`FTS_DOC_ID` serial, `col32` timestamp not null,`col115` text) engine=innodb; -create fulltext index `idx5` on articles(`col115`) ; +create fulltext index `idx5` on articles(`col115`) ; alter ignore table articles add primary key (`col32`) ; diff --git a/mysql-test/suite/sys_vars/r/old_alter_table_basic.result b/mysql-test/suite/sys_vars/r/old_alter_table_basic.result index 5cc17917242..8b668340d1a 100644 --- a/mysql-test/suite/sys_vars/r/old_alter_table_basic.result +++ b/mysql-test/suite/sys_vars/r/old_alter_table_basic.result @@ -1,45 +1,105 @@ SET @start_global_value = @@global.old_alter_table; SELECT @start_global_value; @start_global_value -0 +DEFAULT select @@global.old_alter_table; @@global.old_alter_table -0 +DEFAULT select @@session.old_alter_table; @@session.old_alter_table -0 +DEFAULT show global variables like 'old_alter_table'; Variable_name Value -old_alter_table OFF +old_alter_table DEFAULT show session variables like 'old_alter_table'; Variable_name Value -old_alter_table OFF +old_alter_table DEFAULT select * from information_schema.global_variables where variable_name='old_alter_table'; VARIABLE_NAME VARIABLE_VALUE -OLD_ALTER_TABLE OFF +OLD_ALTER_TABLE DEFAULT select * from information_schema.session_variables where variable_name='old_alter_table'; VARIABLE_NAME VARIABLE_VALUE -OLD_ALTER_TABLE OFF +OLD_ALTER_TABLE DEFAULT set global old_alter_table=1; -set session old_alter_table=ON; +set session old_alter_table=1; select @@global.old_alter_table; @@global.old_alter_table -1 +COPY select @@session.old_alter_table; @@session.old_alter_table -1 +COPY show global variables like 'old_alter_table'; Variable_name Value -old_alter_table ON +old_alter_table COPY show session variables like 'old_alter_table'; Variable_name Value -old_alter_table ON +old_alter_table COPY select * from information_schema.global_variables where variable_name='old_alter_table'; VARIABLE_NAME VARIABLE_VALUE -OLD_ALTER_TABLE ON +OLD_ALTER_TABLE COPY select * from information_schema.session_variables where variable_name='old_alter_table'; VARIABLE_NAME VARIABLE_VALUE -OLD_ALTER_TABLE ON +OLD_ALTER_TABLE COPY +set global old_alter_table=2; +set session old_alter_table=2; +select @@global.old_alter_table; +@@global.old_alter_table +INPLACE +select @@session.old_alter_table; +@@session.old_alter_table +INPLACE +show global variables like 'old_alter_table'; +Variable_name Value +old_alter_table INPLACE +show session variables like 'old_alter_table'; +Variable_name Value +old_alter_table INPLACE +select * from information_schema.global_variables where variable_name='old_alter_table'; +VARIABLE_NAME VARIABLE_VALUE +OLD_ALTER_TABLE INPLACE +select * from information_schema.session_variables where variable_name='old_alter_table'; +VARIABLE_NAME VARIABLE_VALUE +OLD_ALTER_TABLE INPLACE +set global old_alter_table=3; +set session old_alter_table=3; +select @@global.old_alter_table; +@@global.old_alter_table +NOCOPY +select @@session.old_alter_table; +@@session.old_alter_table +NOCOPY +show global variables like 'old_alter_table'; +Variable_name Value +old_alter_table NOCOPY +show session variables like 'old_alter_table'; +Variable_name Value +old_alter_table NOCOPY +select * from information_schema.global_variables where variable_name='old_alter_table'; +VARIABLE_NAME VARIABLE_VALUE +OLD_ALTER_TABLE NOCOPY +select * from information_schema.session_variables where variable_name='old_alter_table'; +VARIABLE_NAME VARIABLE_VALUE +OLD_ALTER_TABLE NOCOPY +set global old_alter_table=4; +set session old_alter_table=4; +select @@global.old_alter_table; +@@global.old_alter_table +INSTANT +select @@session.old_alter_table; +@@session.old_alter_table +INSTANT +show global variables like 'old_alter_table'; +Variable_name Value +old_alter_table INSTANT +show session variables like 'old_alter_table'; +Variable_name Value +old_alter_table INSTANT +select * from information_schema.global_variables where variable_name='old_alter_table'; +VARIABLE_NAME VARIABLE_VALUE +OLD_ALTER_TABLE INSTANT +select * from information_schema.session_variables where variable_name='old_alter_table'; +VARIABLE_NAME VARIABLE_VALUE +OLD_ALTER_TABLE INSTANT set global old_alter_table=1.1; ERROR 42000: Incorrect argument type to variable 'old_alter_table' set global old_alter_table=1e1; @@ -49,4 +109,4 @@ ERROR 42000: Variable 'old_alter_table' can't be set to the value of 'foo' SET @@global.old_alter_table = @start_global_value; SELECT @@global.old_alter_table; @@global.old_alter_table -0 +DEFAULT diff --git a/mysql-test/suite/sys_vars/r/sysvars_server_embedded.result b/mysql-test/suite/sys_vars/r/sysvars_server_embedded.result index b81a1ac58dd..89b7b5c97cf 100644 --- a/mysql-test/suite/sys_vars/r/sysvars_server_embedded.result +++ b/mysql-test/suite/sys_vars/r/sysvars_server_embedded.result @@ -26,6 +26,20 @@ variable_name not in ( 'version_malloc_library', 'version_ssl_library', 'version' ) order by variable_name; +VARIABLE_NAME ALTER_ALGORITHM +SESSION_VALUE DEFAULT +GLOBAL_VALUE DEFAULT +GLOBAL_VALUE_ORIGIN COMPILE-TIME +DEFAULT_VALUE DEFAULT +VARIABLE_SCOPE SESSION +VARIABLE_TYPE ENUM +VARIABLE_COMMENT Specify the alter table algorithm +NUMERIC_MIN_VALUE NULL +NUMERIC_MAX_VALUE NULL +NUMERIC_BLOCK_SIZE NULL +ENUM_VALUE_LIST DEFAULT,COPY,INPLACE,NOCOPY,INSTANT +READ_ONLY NO +COMMAND_LINE_ARGUMENT OPTIONAL VARIABLE_NAME AUTOCOMMIT SESSION_VALUE ON GLOBAL_VALUE ON @@ -2589,17 +2603,17 @@ ENUM_VALUE_LIST OFF,ON READ_ONLY NO COMMAND_LINE_ARGUMENT OPTIONAL VARIABLE_NAME OLD_ALTER_TABLE -SESSION_VALUE OFF -GLOBAL_VALUE OFF +SESSION_VALUE DEFAULT +GLOBAL_VALUE DEFAULT GLOBAL_VALUE_ORIGIN COMPILE-TIME -DEFAULT_VALUE OFF +DEFAULT_VALUE DEFAULT VARIABLE_SCOPE SESSION -VARIABLE_TYPE BOOLEAN -VARIABLE_COMMENT Use old, non-optimized alter table +VARIABLE_TYPE ENUM +VARIABLE_COMMENT Alias for alter_algorithm. Deprecated. Use --alter-algorithm instead. NUMERIC_MIN_VALUE NULL NUMERIC_MAX_VALUE NULL NUMERIC_BLOCK_SIZE NULL -ENUM_VALUE_LIST OFF,ON +ENUM_VALUE_LIST DEFAULT,COPY,INPLACE,NOCOPY,INSTANT READ_ONLY NO COMMAND_LINE_ARGUMENT OPTIONAL VARIABLE_NAME OLD_MODE diff --git a/mysql-test/suite/sys_vars/r/sysvars_server_notembedded.result b/mysql-test/suite/sys_vars/r/sysvars_server_notembedded.result index 388bd485c71..3246d00d20e 100644 --- a/mysql-test/suite/sys_vars/r/sysvars_server_notembedded.result +++ b/mysql-test/suite/sys_vars/r/sysvars_server_notembedded.result @@ -26,6 +26,20 @@ variable_name not in ( 'version_malloc_library', 'version_ssl_library', 'version' ) order by variable_name; +VARIABLE_NAME ALTER_ALGORITHM +SESSION_VALUE DEFAULT +GLOBAL_VALUE DEFAULT +GLOBAL_VALUE_ORIGIN COMPILE-TIME +DEFAULT_VALUE DEFAULT +VARIABLE_SCOPE SESSION +VARIABLE_TYPE ENUM +VARIABLE_COMMENT Specify the alter table algorithm +NUMERIC_MIN_VALUE NULL +NUMERIC_MAX_VALUE NULL +NUMERIC_BLOCK_SIZE NULL +ENUM_VALUE_LIST DEFAULT,COPY,INPLACE,NOCOPY,INSTANT +READ_ONLY NO +COMMAND_LINE_ARGUMENT OPTIONAL VARIABLE_NAME AUTOCOMMIT SESSION_VALUE ON GLOBAL_VALUE ON @@ -2799,17 +2813,17 @@ ENUM_VALUE_LIST OFF,ON READ_ONLY NO COMMAND_LINE_ARGUMENT OPTIONAL VARIABLE_NAME OLD_ALTER_TABLE -SESSION_VALUE OFF -GLOBAL_VALUE OFF +SESSION_VALUE DEFAULT +GLOBAL_VALUE DEFAULT GLOBAL_VALUE_ORIGIN COMPILE-TIME -DEFAULT_VALUE OFF +DEFAULT_VALUE DEFAULT VARIABLE_SCOPE SESSION -VARIABLE_TYPE BOOLEAN -VARIABLE_COMMENT Use old, non-optimized alter table +VARIABLE_TYPE ENUM +VARIABLE_COMMENT Alias for alter_algorithm. Deprecated. Use --alter-algorithm instead. NUMERIC_MIN_VALUE NULL NUMERIC_MAX_VALUE NULL NUMERIC_BLOCK_SIZE NULL -ENUM_VALUE_LIST OFF,ON +ENUM_VALUE_LIST DEFAULT,COPY,INPLACE,NOCOPY,INSTANT READ_ONLY NO COMMAND_LINE_ARGUMENT OPTIONAL VARIABLE_NAME OLD_MODE diff --git a/mysql-test/suite/sys_vars/t/old_alter_table_basic.test b/mysql-test/suite/sys_vars/t/old_alter_table_basic.test index cce180fea67..9a6cb4779e5 100644 --- a/mysql-test/suite/sys_vars/t/old_alter_table_basic.test +++ b/mysql-test/suite/sys_vars/t/old_alter_table_basic.test @@ -20,7 +20,7 @@ select * from information_schema.session_variables where variable_name='old_alte # show that it's writable # set global old_alter_table=1; -set session old_alter_table=ON; +set session old_alter_table=1; select @@global.old_alter_table; select @@session.old_alter_table; show global variables like 'old_alter_table'; @@ -28,6 +28,32 @@ show session variables like 'old_alter_table'; select * from information_schema.global_variables where variable_name='old_alter_table'; select * from information_schema.session_variables where variable_name='old_alter_table'; +set global old_alter_table=2; +set session old_alter_table=2; +select @@global.old_alter_table; +select @@session.old_alter_table; +show global variables like 'old_alter_table'; +show session variables like 'old_alter_table'; +select * from information_schema.global_variables where variable_name='old_alter_table'; +select * from information_schema.session_variables where variable_name='old_alter_table'; + +set global old_alter_table=3; +set session old_alter_table=3; +select @@global.old_alter_table; +select @@session.old_alter_table; +show global variables like 'old_alter_table'; +show session variables like 'old_alter_table'; +select * from information_schema.global_variables where variable_name='old_alter_table'; +select * from information_schema.session_variables where variable_name='old_alter_table'; + +set global old_alter_table=4; +set session old_alter_table=4; +select @@global.old_alter_table; +select @@session.old_alter_table; +show global variables like 'old_alter_table'; +show session variables like 'old_alter_table'; +select * from information_schema.global_variables where variable_name='old_alter_table'; +select * from information_schema.session_variables where variable_name='old_alter_table'; # # incorrect types # diff --git a/mysql-test/suite/versioning/r/alter.result b/mysql-test/suite/versioning/r/alter.result index a6f1bb38a76..fc9d225d388 100644 --- a/mysql-test/suite/versioning/r/alter.result +++ b/mysql-test/suite/versioning/r/alter.result @@ -454,8 +454,6 @@ t CREATE TABLE `t` ( `c` text DEFAULT NULL ) ENGINE=InnoDB DEFAULT CHARSET=latin1 WITH SYSTEM VERSIONING alter table t add fulltext key (c); -Warnings: -Warning 124 InnoDB rebuilding table to add column FTS_DOC_ID create or replace table t (a int) with system versioning; alter table t drop column a; ERROR HY000: Table `t` must have at least one versioned column |