mirror of
https://github.com/MariaDB/server.git
synced 2025-07-27 18:02:13 +03:00
MDEV-18732 InnoDB: ALTER IGNORE returns error for NULL
Only starting with MariaDB 10.3.8 (MDEV-16365), InnoDB can actually handle ALTER IGNORE TABLE correctly when introducing a NOT NULL attribute to a column that contains a NULL value. Between MariaDB Server 10.0 and 10.2, we would incorrectly return an error for ALTER IGNORE TABLE when the column contains a NULL value.
This commit is contained in:
@ -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;
|
||||
|
Reference in New Issue
Block a user