mirror of
https://github.com/MariaDB/server.git
synced 2025-01-31 02:51:44 +01:00
01b2e773ef
While the test case crashes a MariaDB 10.2 debug build only, let us apply the fix to the earliest applicable MariaDB series (10.0) to avoid any data corruption on a table-rebuilding ALTER TABLE using ALGORITHM=INPLACE. innobase_create_key_defs(): Use altered_table->s->primary_key when a new primary key is being created.
81 lines
2.1 KiB
Text
81 lines
2.1 KiB
Text
--source include/innodb_page_size.inc
|
|
|
|
# Save the initial number of concurrent sessions.
|
|
--source include/count_sessions.inc
|
|
|
|
CREATE TABLE t (c1 INT PRIMARY KEY, c2 INT NOT NULL, c3 INT) ENGINE=InnoDB;
|
|
INSERT INTO t VALUES (1,2,3),(4,5,6),(7,8,9);
|
|
|
|
--enable_info
|
|
# This one will be a no-op.
|
|
# MySQL should perhaps issue an error, because it refuses to modify
|
|
# the PRIMARY KEY column c1 from NOT NULL to NULL.
|
|
ALTER TABLE t CHANGE c1 c1 INT NULL FIRST, ALGORITHM=INPLACE;
|
|
|
|
# NULL -> NOT NULL only allowed INPLACE if strict sql_mode is on.
|
|
--disable_info
|
|
set @old_sql_mode = @@sql_mode;
|
|
set @@sql_mode = 'STRICT_TRANS_TABLES';
|
|
--enable_info
|
|
ALTER TABLE t MODIFY c3 INT NOT NULL, ALGORITHM=INPLACE;
|
|
--disable_info
|
|
set @@sql_mode = @old_sql_mode;
|
|
--enable_info
|
|
|
|
# Request some conflicting changes for a single column.
|
|
--error ER_BAD_FIELD_ERROR
|
|
ALTER TABLE t CHANGE c2 c2 INT, CHANGE c2 c2 INT NOT NULL;
|
|
--error ER_BAD_FIELD_ERROR
|
|
ALTER TABLE t MODIFY c2 INT, MODIFY c2 INT NOT NULL;
|
|
--error ER_BAD_FIELD_ERROR
|
|
ALTER TABLE t MODIFY c2 INT UNSIGNED, MODIFY c2 INT;
|
|
--error ER_BAD_FIELD_ERROR
|
|
ALTER TABLE t MODIFY c2 CHAR(1) NOT NULL, MODIFY c2 INT NOT NULL;
|
|
|
|
# No-ops.
|
|
ALTER TABLE t CHANGE c2 c2 INT NOT NULL;
|
|
ALTER TABLE t MODIFY c2 INT NOT NULL;
|
|
--disable_info
|
|
|
|
connect (con1,localhost,root,,);
|
|
connection con1;
|
|
|
|
SET SQL_MODE='STRICT_ALL_TABLES';
|
|
|
|
--error ER_BAD_NULL_ERROR
|
|
UPDATE t SET c2=NULL;
|
|
|
|
SELECT * FROM t;
|
|
|
|
connection default;
|
|
|
|
# This should change the column to NULL.
|
|
ALTER TABLE t MODIFY c2 INT, ALGORITHM=INPLACE;
|
|
|
|
connection con1;
|
|
BEGIN;
|
|
UPDATE t SET c2=NULL;
|
|
SELECT * FROM t;
|
|
ROLLBACK;
|
|
SELECT * FROM t;
|
|
|
|
disconnect con1;
|
|
connection default;
|
|
|
|
# This should be no-op.
|
|
ALTER TABLE t MODIFY c2 INT NULL, ALGORITHM=INPLACE;
|
|
|
|
--replace_column 1 # 5 #
|
|
SELECT * FROM INFORMATION_SCHEMA.INNODB_SYS_TABLES
|
|
WHERE NAME='test/t';
|
|
|
|
DROP TABLE t;
|
|
|
|
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;
|
|
|
|
# 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
|