summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--mysql-test/suite/innodb/r/innodb-alter-nullable.result34
-rw-r--r--mysql-test/suite/innodb/t/innodb-alter-nullable.test26
-rw-r--r--storage/innobase/handler/handler0alter.cc2
-rw-r--r--storage/xtradb/handler/handler0alter.cc2
4 files changed, 62 insertions, 2 deletions
diff --git a/mysql-test/suite/innodb/r/innodb-alter-nullable.result b/mysql-test/suite/innodb/r/innodb-alter-nullable.result
index 2769bfdf1f5..3b96bac7a71 100644
--- a/mysql-test/suite/innodb/r/innodb-alter-nullable.result
+++ b/mysql-test/suite/innodb/r/innodb-alter-nullable.result
@@ -55,3 +55,37 @@ CREATE TABLE t1(c1 INT) ENGINE=InnoDB;
ALTER TABLE t1 ADD CONSTRAINT UNIQUE KEY i1(c1);
ALTER TABLE t1 CHANGE c1 c1 INT NOT NULL,ADD KEY(c1);
DROP TABLE t1;
+#
+# MDEV-18732 InnoDB: ALTER IGNORE returns error for NULL
+#
+SET @mode = @@sql_mode;
+SET sql_mode = STRICT_TRANS_TABLES;
+CREATE TABLE t1(c INT) ENGINE=InnoDB;
+INSERT INTO t1 VALUES (NULL);
+ALTER IGNORE TABLE t1 MODIFY c INT NOT NULL;
+affected rows: 1
+info: Records: 1 Duplicates: 0 Warnings: 1
+Warnings:
+Warning 1265 Data truncated for column 'c' at row 1
+INSERT INTO t1 VALUES (NULL);
+ERROR 23000: Column 'c' cannot be null
+SELECT * FROM t1;
+c
+0
+DROP TABLE t1;
+CREATE TABLE t1(c INT) ENGINE=InnoDB;
+INSERT INTO t1 VALUES (NULL),(1),(1);
+ALTER IGNORE TABLE t1 ADD UNIQUE(c);
+affected rows: 3
+info: Records: 3 Duplicates: 1 Warnings: 0
+ALTER IGNORE TABLE t1 ADD PRIMARY KEY(c);
+affected rows: 2
+info: Records: 2 Duplicates: 0 Warnings: 1
+Warnings:
+Warning 1265 Data truncated for column 'c' at row 1
+SELECT * FROM t1;
+c
+0
+1
+DROP TABLE t1;
+SET sql_mode = @mode;
diff --git a/mysql-test/suite/innodb/t/innodb-alter-nullable.test b/mysql-test/suite/innodb/t/innodb-alter-nullable.test
index d039459f91f..81e464eddac 100644
--- a/mysql-test/suite/innodb/t/innodb-alter-nullable.test
+++ b/mysql-test/suite/innodb/t/innodb-alter-nullable.test
@@ -76,6 +76,32 @@ ALTER TABLE t1 ADD CONSTRAINT UNIQUE KEY i1(c1);
ALTER TABLE t1 CHANGE c1 c1 INT NOT NULL,ADD KEY(c1);
DROP TABLE t1;
+--echo #
+--echo # MDEV-18732 InnoDB: ALTER IGNORE returns error for NULL
+--echo #
+
+SET @mode = @@sql_mode;
+SET sql_mode = STRICT_TRANS_TABLES;
+CREATE TABLE t1(c INT) ENGINE=InnoDB;
+INSERT INTO t1 VALUES (NULL);
+--enable_info
+ALTER IGNORE TABLE t1 MODIFY c INT NOT NULL;
+--disable_info
+--error ER_BAD_NULL_ERROR
+INSERT INTO t1 VALUES (NULL);
+SELECT * FROM t1;
+DROP TABLE t1;
+
+CREATE TABLE t1(c INT) ENGINE=InnoDB;
+INSERT INTO t1 VALUES (NULL),(1),(1);
+--enable_info
+ALTER IGNORE TABLE t1 ADD UNIQUE(c);
+ALTER IGNORE TABLE t1 ADD PRIMARY KEY(c);
+--disable_info
+SELECT * FROM t1;
+DROP TABLE t1;
+SET sql_mode = @mode;
+
# Check that all connections opened by test cases in this file are really
# gone so execution of other tests won't be affected by their presence.
--source include/wait_until_count_sessions.inc
diff --git a/storage/innobase/handler/handler0alter.cc b/storage/innobase/handler/handler0alter.cc
index b3d9faf0680..2bcec2ce51f 100644
--- a/storage/innobase/handler/handler0alter.cc
+++ b/storage/innobase/handler/handler0alter.cc
@@ -328,7 +328,7 @@ ha_innobase::check_if_supported_inplace_alter(
NULL to a NOT NULL value. */
if ((ha_alter_info->handler_flags
& Alter_inplace_info::ALTER_COLUMN_NOT_NULLABLE)
- && !thd_is_strict_mode(user_thd)) {
+ && (ha_alter_info->ignore || !thd_is_strict_mode(user_thd))) {
ha_alter_info->unsupported_reason = innobase_get_err_msg(
ER_ALTER_OPERATION_NOT_SUPPORTED_REASON_NOT_NULL);
DBUG_RETURN(HA_ALTER_INPLACE_NOT_SUPPORTED);
diff --git a/storage/xtradb/handler/handler0alter.cc b/storage/xtradb/handler/handler0alter.cc
index 43df8b04201..fa41c963464 100644
--- a/storage/xtradb/handler/handler0alter.cc
+++ b/storage/xtradb/handler/handler0alter.cc
@@ -332,7 +332,7 @@ ha_innobase::check_if_supported_inplace_alter(
NULL to a NOT NULL value. */
if ((ha_alter_info->handler_flags
& Alter_inplace_info::ALTER_COLUMN_NOT_NULLABLE)
- && !thd_is_strict_mode(user_thd)) {
+ && (ha_alter_info->ignore || !thd_is_strict_mode(user_thd))) {
ha_alter_info->unsupported_reason = innobase_get_err_msg(
ER_ALTER_OPERATION_NOT_SUPPORTED_REASON_NOT_NULL);
DBUG_RETURN(HA_ALTER_INPLACE_NOT_SUPPORTED);