diff --git a/mysql-test/suite/innodb/include/alter_non_null.inc b/mysql-test/suite/innodb/include/alter_not_null.inc similarity index 73% rename from mysql-test/suite/innodb/include/alter_non_null.inc rename to mysql-test/suite/innodb/include/alter_not_null.inc index 8acecfb08dc..109fad38d16 100644 --- a/mysql-test/suite/innodb/include/alter_non_null.inc +++ b/mysql-test/suite/innodb/include/alter_not_null.inc @@ -60,6 +60,18 @@ ALTER TABLE t1 CHANGE b b TINYINT NOT NULL DEFAULT if(unix_timestamp()>1,1000,0) SELECT * FROM t1; DROP TABLE t1; +CREATE TABLE t1(a INT, v INT AS (a), c INT, d INT NOT NULL, e INT) ENGINE=InnoDB; +--enable_info +ALTER TABLE t1 DROP COLUMN c, CHANGE COLUMN e e INT NOT NULL; +--disable_info +DROP TABLE t1; + +CREATE TABLE t1 (a INT, v INT AS (a), d INT NOT NULL, e INT) ENGINE=InnoDB; +--enable_info +ALTER TABLE t1 FORCE; +--disable_info +DROP TABLE t1; + # Alter ignore should work irrespective of sql mode CREATE TABLE t1(c1 INT NOT NULL, c2 INT, PRIMARY KEY(c1))ENGINE=INNODB; @@ -69,3 +81,14 @@ ALTER IGNORE TABLE t1 CHANGE c2 c2 INT NOT NULL DEFAULT 2; --disable_info SELECT * FROM t1; DROP TABLE t1; + +--echo # +--echo # MDEV-16126 Crash or ASAN heap-buffer-overflow in +--echo # mach_read_from_n_little_endian upon ALTER TABLE with blob +--echo # + +CREATE TABLE t1(a INT, v INT AS (a), b INT, c BLOB) ENGINE=InnoDB; +--enable_info +ALTER TABLE t1 ADD PRIMARY KEY(b); +--disable_info +DROP TABLE t1; diff --git a/mysql-test/suite/innodb/r/alter_non_null.result b/mysql-test/suite/innodb/r/alter_non_null.result deleted file mode 100644 index 15ea6a38b5b..00000000000 --- a/mysql-test/suite/innodb/r/alter_non_null.result +++ /dev/null @@ -1,95 +0,0 @@ -CREATE TABLE t1(f1 INT)ENGINE=INNODB; -INSERT INTO t1 VALUES(NULL); -SELECT * FROM t1; -f1 -NULL -ALTER TABLE t1 CHANGE f1 f1 INT NOT NULL; -affected rows: 0 -info: Records: 0 Duplicates: 0 Warnings: 1 -Warnings: -Warning 1265 Data truncated for column 'f1' at row 1 -SELECT * FROM t1; -f1 -0 -DROP TABLE t1; -CREATE TABLE t1(f1 CHAR(10))ENGINE=INNODB; -INSERT INTO t1 VALUES(NULL); -SELECT * FROM t1; -f1 -NULL -ALTER TABLE t1 CHANGE f1 f1 CHAR(10) NOT NULL; -affected rows: 0 -info: Records: 0 Duplicates: 0 Warnings: 1 -Warnings: -Warning 1265 Data truncated for column 'f1' at row 1 -SELECT * FROM t1; -f1 - -DROP TABLE t1; -CREATE TABLE t1(f1 VARCHAR(10))ENGINE=INNODB; -INSERT INTO t1 VALUES(NULL); -SELECT * FROM t1; -f1 -NULL -ALTER TABLE t1 CHANGE f1 f1 VARCHAR(20) NOT NULL; -affected rows: 0 -info: Records: 0 Duplicates: 0 Warnings: 1 -Warnings: -Warning 1265 Data truncated for column 'f1' at row 1 -SELECT * FROM t1; -f1 - -DROP TABLE t1; -CREATE TABLE t1(f1 TEXT)ENGINE=INNODB; -INSERT INTO t1 VALUES(NULL); -SELECT * FROM t1; -f1 -NULL -ALTER TABLE t1 CHANGE f1 f1 TEXT NOT NULL DEFAULT 'abc'; -affected rows: 0 -info: Records: 0 Duplicates: 0 Warnings: 1 -Warnings: -Warning 1265 Data truncated for column 'f1' at row 1 -SELECT * FROM t1; -f1 - -DROP TABLE t1; -CREATE TABLE t1(f1 INT NOT NULL, f2 INT NOT NULL, f3 INT)ENGINE=INNODB; -INSERT INTO t1 VALUES(2, 2, NULL); -SELECT * FROM t1; -f1 f2 f3 -2 2 NULL -ALTER TABLE t1 CHANGE f3 f3 INT NOT NULL DEFAULT (f1 + f2); -affected rows: 0 -info: Records: 0 Duplicates: 0 Warnings: 1 -Warnings: -Warning 1265 Data truncated for column 'f3' at row 1 -SELECT * FROM t1; -f1 f2 f3 -2 2 0 -DROP TABLE t1; -CREATE TABLE t1(f1 INT NOT NULL DEFAULT 0, b TINYINT)ENGINE=InnoDB; -INSERT INTO t1 VALUES(10, NULL); -SELECT * FROM t1; -f1 b -10 NULL -ALTER TABLE t1 CHANGE b b TINYINT NOT NULL DEFAULT if(unix_timestamp()>1,1000,0); -affected rows: 0 -info: Records: 0 Duplicates: 0 Warnings: 1 -Warnings: -Warning 1265 Data truncated for column 'b' at row 1 -SELECT * FROM t1; -f1 b -10 0 -DROP TABLE t1; -CREATE TABLE t1(c1 INT NOT NULL, c2 INT, PRIMARY KEY(c1))ENGINE=INNODB; -INSERT INTO t1 VALUES(1, NULL); -ALTER IGNORE TABLE t1 CHANGE c2 c2 INT NOT NULL DEFAULT 2; -affected rows: 0 -info: Records: 0 Duplicates: 0 Warnings: 1 -Warnings: -Warning 1265 Data truncated for column 'c2' at row 1 -SELECT * FROM t1; -c1 c2 -1 0 -DROP TABLE t1; diff --git a/mysql-test/suite/innodb/r/alter_non_null,COPY,NON-STRICT.rdiff b/mysql-test/suite/innodb/r/alter_not_null,COPY,NON-STRICT.rdiff similarity index 98% rename from mysql-test/suite/innodb/r/alter_non_null,COPY,NON-STRICT.rdiff rename to mysql-test/suite/innodb/r/alter_not_null,COPY,NON-STRICT.rdiff index ee1ee3fd8d7..01db97e59f8 100644 --- a/mysql-test/suite/innodb/r/alter_non_null,COPY,NON-STRICT.rdiff +++ b/mysql-test/suite/innodb/r/alter_not_null,COPY,NON-STRICT.rdiff @@ -34,7 +34,7 @@ --- > affected rows: 1 > info: Records: 1 Duplicates: 0 Warnings: 1 -88,89c88,89 +98,99c98,99 < affected rows: 0 < info: Records: 0 Duplicates: 0 Warnings: 1 --- diff --git a/mysql-test/suite/innodb/r/alter_non_null,COPY,STRICT.rdiff b/mysql-test/suite/innodb/r/alter_not_null,COPY,STRICT.rdiff similarity index 99% rename from mysql-test/suite/innodb/r/alter_non_null,COPY,STRICT.rdiff rename to mysql-test/suite/innodb/r/alter_not_null,COPY,STRICT.rdiff index d8094c4d2be..e02d235cb72 100644 --- a/mysql-test/suite/innodb/r/alter_non_null,COPY,STRICT.rdiff +++ b/mysql-test/suite/innodb/r/alter_not_null,COPY,STRICT.rdiff @@ -64,7 +64,7 @@ < 10 0 --- > 10 NULL -88,89c70,71 +98,99c80,81 < affected rows: 0 < info: Records: 0 Duplicates: 0 Warnings: 1 --- diff --git a/mysql-test/suite/innodb/r/alter_non_null,INPLACE,STRICT.rdiff b/mysql-test/suite/innodb/r/alter_not_null,INPLACE,STRICT.rdiff similarity index 100% rename from mysql-test/suite/innodb/r/alter_non_null,INPLACE,STRICT.rdiff rename to mysql-test/suite/innodb/r/alter_not_null,INPLACE,STRICT.rdiff diff --git a/mysql-test/suite/innodb/r/alter_not_null.result b/mysql-test/suite/innodb/r/alter_not_null.result index aab9ffa0592..688493351b8 100644 --- a/mysql-test/suite/innodb/r/alter_not_null.result +++ b/mysql-test/suite/innodb/r/alter_not_null.result @@ -1,9 +1,107 @@ -set @@sql_mode = 'STRICT_TRANS_TABLES'; +CREATE TABLE t1(f1 INT)ENGINE=INNODB; +INSERT INTO t1 VALUES(NULL); +SELECT * FROM t1; +f1 +NULL +ALTER TABLE t1 CHANGE f1 f1 INT NOT NULL; +affected rows: 0 +info: Records: 0 Duplicates: 0 Warnings: 1 +Warnings: +Warning 1265 Data truncated for column 'f1' at row 1 +SELECT * FROM t1; +f1 +0 +DROP TABLE t1; +CREATE TABLE t1(f1 CHAR(10))ENGINE=INNODB; +INSERT INTO t1 VALUES(NULL); +SELECT * FROM t1; +f1 +NULL +ALTER TABLE t1 CHANGE f1 f1 CHAR(10) NOT NULL; +affected rows: 0 +info: Records: 0 Duplicates: 0 Warnings: 1 +Warnings: +Warning 1265 Data truncated for column 'f1' at row 1 +SELECT * FROM t1; +f1 + +DROP TABLE t1; +CREATE TABLE t1(f1 VARCHAR(10))ENGINE=INNODB; +INSERT INTO t1 VALUES(NULL); +SELECT * FROM t1; +f1 +NULL +ALTER TABLE t1 CHANGE f1 f1 VARCHAR(20) NOT NULL; +affected rows: 0 +info: Records: 0 Duplicates: 0 Warnings: 1 +Warnings: +Warning 1265 Data truncated for column 'f1' at row 1 +SELECT * FROM t1; +f1 + +DROP TABLE t1; +CREATE TABLE t1(f1 TEXT)ENGINE=INNODB; +INSERT INTO t1 VALUES(NULL); +SELECT * FROM t1; +f1 +NULL +ALTER TABLE t1 CHANGE f1 f1 TEXT NOT NULL DEFAULT 'abc'; +affected rows: 0 +info: Records: 0 Duplicates: 0 Warnings: 1 +Warnings: +Warning 1265 Data truncated for column 'f1' at row 1 +SELECT * FROM t1; +f1 + +DROP TABLE t1; +CREATE TABLE t1(f1 INT NOT NULL, f2 INT NOT NULL, f3 INT)ENGINE=INNODB; +INSERT INTO t1 VALUES(2, 2, NULL); +SELECT * FROM t1; +f1 f2 f3 +2 2 NULL +ALTER TABLE t1 CHANGE f3 f3 INT NOT NULL DEFAULT (f1 + f2); +affected rows: 0 +info: Records: 0 Duplicates: 0 Warnings: 1 +Warnings: +Warning 1265 Data truncated for column 'f3' at row 1 +SELECT * FROM t1; +f1 f2 f3 +2 2 0 +DROP TABLE t1; +CREATE TABLE t1(f1 INT NOT NULL DEFAULT 0, b TINYINT)ENGINE=InnoDB; +INSERT INTO t1 VALUES(10, NULL); +SELECT * FROM t1; +f1 b +10 NULL +ALTER TABLE t1 CHANGE b b TINYINT NOT NULL DEFAULT if(unix_timestamp()>1,1000,0); +affected rows: 0 +info: Records: 0 Duplicates: 0 Warnings: 1 +Warnings: +Warning 1265 Data truncated for column 'b' at row 1 +SELECT * FROM t1; +f1 b +10 0 +DROP TABLE t1; CREATE TABLE t1(a INT, v INT AS (a), c INT, d INT NOT NULL, e INT) ENGINE=InnoDB; -ALTER TABLE t1 DROP COLUMN c, CHANGE COLUMN e e INT NOT NULL, ALGORITHM=INPLACE; +ALTER TABLE t1 DROP COLUMN c, CHANGE COLUMN e e INT NOT NULL; +affected rows: 0 +info: Records: 0 Duplicates: 0 Warnings: 0 DROP TABLE t1; CREATE TABLE t1 (a INT, v INT AS (a), d INT NOT NULL, e INT) ENGINE=InnoDB; -ALTER TABLE t1 FORCE, ALGORITHM=INPLACE; +ALTER TABLE t1 FORCE; +affected rows: 0 +info: Records: 0 Duplicates: 0 Warnings: 0 +DROP TABLE t1; +CREATE TABLE t1(c1 INT NOT NULL, c2 INT, PRIMARY KEY(c1))ENGINE=INNODB; +INSERT INTO t1 VALUES(1, NULL); +ALTER IGNORE TABLE t1 CHANGE c2 c2 INT NOT NULL DEFAULT 2; +affected rows: 0 +info: Records: 0 Duplicates: 0 Warnings: 1 +Warnings: +Warning 1265 Data truncated for column 'c2' at row 1 +SELECT * FROM t1; +c1 c2 +1 0 DROP TABLE t1; # # MDEV-16126 Crash or ASAN heap-buffer-overflow in @@ -11,4 +109,6 @@ DROP TABLE t1; # CREATE TABLE t1(a INT, v INT AS (a), b INT, c BLOB) ENGINE=InnoDB; ALTER TABLE t1 ADD PRIMARY KEY(b); +affected rows: 0 +info: Records: 0 Duplicates: 0 Warnings: 0 DROP TABLE t1; diff --git a/mysql-test/suite/innodb/r/alter_non_null_debug,STRICT.rdiff b/mysql-test/suite/innodb/r/alter_not_null_debug,STRICT.rdiff similarity index 100% rename from mysql-test/suite/innodb/r/alter_non_null_debug,STRICT.rdiff rename to mysql-test/suite/innodb/r/alter_not_null_debug,STRICT.rdiff diff --git a/mysql-test/suite/innodb/r/alter_non_null_debug.result b/mysql-test/suite/innodb/r/alter_not_null_debug.result similarity index 100% rename from mysql-test/suite/innodb/r/alter_non_null_debug.result rename to mysql-test/suite/innodb/r/alter_not_null_debug.result diff --git a/mysql-test/suite/innodb/t/alter_non_null.test b/mysql-test/suite/innodb/t/alter_non_null.test deleted file mode 100644 index bfa159922b4..00000000000 --- a/mysql-test/suite/innodb/t/alter_non_null.test +++ /dev/null @@ -1,10 +0,0 @@ ---source alter_sql_mode.inc - -let $sql_mode = `SELECT @@SQL_MODE`; -let $error_code = 0; - -if ($sql_mode == "STRICT_TRANS_TABLES") { - let $error_code = WARN_DATA_TRUNCATED; -} - ---source include/alter_non_null.inc diff --git a/mysql-test/suite/innodb/t/alter_non_null_debug.test b/mysql-test/suite/innodb/t/alter_non_null_debug.test deleted file mode 100644 index 8bfa7a4bee4..00000000000 --- a/mysql-test/suite/innodb/t/alter_non_null_debug.test +++ /dev/null @@ -1,10 +0,0 @@ ---source alter_sql_mode.inc - -let $sql_mode = `SELECT @@SQL_MODE`; -let $error_code = 0; - -if ($sql_mode == "STRICT_TRANS_TABLES") { - let $error_code = WARN_DATA_TRUNCATED; -} - ---source include/alter_non_null_debug.inc diff --git a/mysql-test/suite/innodb/t/alter_non_null.combinations b/mysql-test/suite/innodb/t/alter_not_null.combinations similarity index 100% rename from mysql-test/suite/innodb/t/alter_non_null.combinations rename to mysql-test/suite/innodb/t/alter_not_null.combinations diff --git a/mysql-test/suite/innodb/t/alter_not_null.test b/mysql-test/suite/innodb/t/alter_not_null.test index 696df34df68..839d7f18a5e 100644 --- a/mysql-test/suite/innodb/t/alter_not_null.test +++ b/mysql-test/suite/innodb/t/alter_not_null.test @@ -1,19 +1,10 @@ ---source include/have_innodb.inc -set @@sql_mode = 'STRICT_TRANS_TABLES'; +--source alter_sql_mode.inc -CREATE TABLE t1(a INT, v INT AS (a), c INT, d INT NOT NULL, e INT) ENGINE=InnoDB; -ALTER TABLE t1 DROP COLUMN c, CHANGE COLUMN e e INT NOT NULL, ALGORITHM=INPLACE; -DROP TABLE t1; +let $sql_mode = `SELECT @@SQL_MODE`; +let $error_code = 0; -CREATE TABLE t1 (a INT, v INT AS (a), d INT NOT NULL, e INT) ENGINE=InnoDB; -ALTER TABLE t1 FORCE, ALGORITHM=INPLACE; -DROP TABLE t1; +if ($sql_mode == "STRICT_TRANS_TABLES") { + let $error_code = WARN_DATA_TRUNCATED; +} ---echo # ---echo # MDEV-16126 Crash or ASAN heap-buffer-overflow in ---echo # mach_read_from_n_little_endian upon ALTER TABLE with blob ---echo # - -CREATE TABLE t1(a INT, v INT AS (a), b INT, c BLOB) ENGINE=InnoDB; -ALTER TABLE t1 ADD PRIMARY KEY(b); -DROP TABLE t1; +--source include/alter_not_null.inc diff --git a/mysql-test/suite/innodb/include/alter_non_null_debug.inc b/mysql-test/suite/innodb/t/alter_not_null_debug.test similarity index 91% rename from mysql-test/suite/innodb/include/alter_non_null_debug.inc rename to mysql-test/suite/innodb/t/alter_not_null_debug.test index f5989391723..058f0fc02a5 100644 --- a/mysql-test/suite/innodb/include/alter_non_null_debug.inc +++ b/mysql-test/suite/innodb/t/alter_not_null_debug.test @@ -1,6 +1,15 @@ --source include/have_innodb.inc --source include/have_debug.inc --source include/have_debug_sync.inc +--source alter_sql_mode.inc + +let $sql_mode = `SELECT @@SQL_MODE`; +let $error_code = 0; + +if ($sql_mode == "STRICT_TRANS_TABLES") { + let $error_code = WARN_DATA_TRUNCATED; +} + # Alter table should fail for strict sql mode