tidb
tidb copied to clipboard
Support the definition of `null` change to `not null` using `alter table`
Refer to https://dev.mysql.com/doc/refman/5.7/en/alter-table.html.
If we have no global lock on the table, it is not a trivial work.
Relate to PR #6217 .
I have verified two test cases, behavior is the same as MySQL:
DROP TABLE IF EXISTS t1;
CREATE TABLE t1 (a int not null primary key auto_increment, b INT NULL);
INSERT INTO t1 (b) VALUES (1);
ALTER TABLE t1 CHANGE b b INT NOT NULL;
And an error:
DROP TABLE IF EXISTS t1;
CREATE TABLE t1 (a int not null primary key auto_increment, b INT NULL);
INSERT INTO t1 (b) VALUES (NULL);
ALTER TABLE t1 CHANGE b b INT NOT NULL;
# Result:
ERROR 1138 (22004): Invalid use of NULL value
I am going to close this task now.