Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions mysql-test/r/check_constraints.result
Original file line number Diff line number Diff line change
Expand Up @@ -1259,6 +1259,16 @@ ERROR 0A000: ALGORITHM=INPLACE is not supported for this operation. Try ALGORITH
ALTER TABLE t1 MODIFY COLUMN f1 INT DEFAULT 20, algorithm=copy;
ERROR HY000: Check constraint 't1_chk_1' is violated.
DROP TABLE t1;
#
# Bug#121124 - An unrelated CHECK constraint on DATETIME should not
# prevent an online ENUM extension.
#
CREATE TABLE t1 (e ENUM('a','b') NOT NULL, d DATETIME(6),
CONSTRAINT ck CHECK (d IS NULL));
ALTER TABLE t1 MODIFY e ENUM('a','b','c') NOT NULL, ALGORITHM=INSTANT;
ALTER TABLE t1 MODIFY e ENUM('a','b','c','d') NOT NULL, ALGORITHM=INPLACE;
ALTER TABLE t1 MODIFY d DATETIME(6) DEFAULT NULL, ALGORITHM=INPLACE;
DROP TABLE t1;
#-----------------------------------------------------------------------
# Test case to verify check constraint with CHANGE COLUMN syntax.
#-----------------------------------------------------------------------
Expand Down
12 changes: 12 additions & 0 deletions mysql-test/t/check_constraints.test
Original file line number Diff line number Diff line change
Expand Up @@ -789,6 +789,18 @@ ALTER TABLE t1 MODIFY COLUMN f1 INT DEFAULT 20, algorithm=copy;
DROP TABLE t1;


--echo #
--echo # Bug#121124 - An unrelated CHECK constraint on DATETIME should not
--echo # prevent an online ENUM extension.
--echo #
CREATE TABLE t1 (e ENUM('a','b') NOT NULL, d DATETIME(6),
CONSTRAINT ck CHECK (d IS NULL));
ALTER TABLE t1 MODIFY e ENUM('a','b','c') NOT NULL, ALGORITHM=INSTANT;
ALTER TABLE t1 MODIFY e ENUM('a','b','c','d') NOT NULL, ALGORITHM=INPLACE;
ALTER TABLE t1 MODIFY d DATETIME(6) DEFAULT NULL, ALGORITHM=INPLACE;
DROP TABLE t1;


--echo #-----------------------------------------------------------------------
--echo # Test case to verify check constraint with CHANGE COLUMN syntax.
--echo #-----------------------------------------------------------------------
Expand Down
5 changes: 3 additions & 2 deletions sql/sql_table.cc
Original file line number Diff line number Diff line change
Expand Up @@ -20916,9 +20916,10 @@ static bool is_any_check_constraints_evaluation_required(
continue;

// Check if data type is changed.
if (!my_strcasecmp(system_charset_info, itm_fld->field_name,
if (fld.change &&
!my_strcasecmp(system_charset_info, itm_fld->field_name,
fld.field_name) &&
(itm_fld->data_type() != fld.sql_type))
(itm_fld->data_type() != real_type_to_type(fld.sql_type)))
return true;
}

Expand Down
Loading