summaryrefslogtreecommitdiffstats
path: root/mysql-test/suite/innodb/t/alter_table.test
blob: 67ada081d467d08df286d271e1b38b85f3127434 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
--source include/have_innodb.inc
--source include/have_sequence.inc
#
# MDEV-11995 ALTER TABLE proceeds despite reporting ER_TOO_LONG_KEY error
#
set @@sql_mode=strict_trans_tables;
create table t1(a text not null) row_format=dynamic engine=innodb;
create index idx1 on t1(a(3073));
show create table t1;
drop table t1;
set @@sql_mode=default;

#
# MDEV-14081 ALTER TABLE CHANGE COLUMN Corrupts Index Leading to Crashes in 10.2
#
create table t1 (
  id1    int(11)      not null auto_increment,
  id2    varchar(30)  not null,
  id3    datetime     not null default current_timestamp,
  primary key (id1),
  unique key unique_id2 (id2)
) engine=innodb;
alter table t1 change column id2 id4 varchar(100) not null;
select * from t1 where id4 like 'a';
drop table t1;

--echo #
--echo # MDEV-17725 Assertion `!is_set() || (m_status == DA_OK_BULK && is_bulk_op())' failed in Diagnostics_area::set_ok_status upon ALTER failing due to error from engine
--echo #

SET sql_mode=STRICT_ALL_TABLES;
CREATE TABLE t1 (pk INT PRIMARY KEY) ENGINE=InnoDB;
ALTER TABLE t1 ORDER BY a;
DROP TABLE t1;

SET sql_mode='';
CREATE TABLE t1 (pk INT PRIMARY KEY) ENGINE=InnoDB;
ALTER TABLE t1 ORDER BY a;
DROP TABLE t1;

SET sql_mode=DEFAULT;

--echo #
--echo # MDEV-18775 Server crashes in dict_table_t::instant_column
--echo # upon ADD COLUMN
--echo #

CREATE TABLE tx (pk INT PRIMARY KEY) ENGINE=InnoDB;
CREATE TABLE t1 (pk INT, a INT, PRIMARY KEY (pk), KEY (a), FOREIGN KEY (a) REFERENCES tx (pk)) ENGINE=InnoDB;

SET FOREIGN_KEY_CHECKS=OFF;

--error ER_FK_COLUMN_CANNOT_DROP
ALTER TABLE t1 DROP a;

SET FOREIGN_KEY_CHECKS=ON;

ALTER TABLE t1 ADD b INT;
--error ER_DROP_INDEX_FK
ALTER TABLE t1 DROP a;
ALTER TABLE t1 ADD c INT;
DROP TABLE t1, tx;

--echo #
--echo # MDEV-14119 Assertion cmp_rec_rec() on ALTER TABLE
--echo #
CREATE TABLE t1(a INT NOT NULL UNIQUE) ENGINE=InnoDB;
INSERT INTO t1 SELECT * FROM seq_1_to_128;
ALTER TABLE t1 ADD b TINYINT AUTO_INCREMENT PRIMARY KEY, DROP KEY a;
DROP TABLE t1;

--echo #
--echo # MDEV-22939 Server crashes in row_make_new_pathname()
--echo #
CREATE TABLE t (a INT) ENGINE=INNODB;
ALTER TABLE t DISCARD TABLESPACE;
--error ER_TABLESPACE_DISCARDED
ALTER TABLE t ENGINE INNODB;
--error ER_TABLESPACE_DISCARDED
ALTER TABLE t FORCE;
DROP TABLE t;

--echo #
--echo # MDEV-24763 ALTER TABLE fails to rename a column in SYS_FIELDS
--echo #
CREATE TABLE t1 (a INT, b TEXT, c INT, PRIMARY KEY(b(9)), INDEX(c,a))
ENGINE=InnoDB;
ALTER TABLE t1 CHANGE COLUMN a u INT;
--replace_column 1 ID
SELECT sf.* FROM information_schema.innodb_sys_fields sf
INNER JOIN information_schema.innodb_sys_indexes si ON sf.index_id=si.index_id
INNER JOIN information_schema.innodb_sys_tables st ON si.table_id=st.table_id
WHERE st.name='test/t1' ORDER BY sf.index_id,sf.pos;
DROP TABLE t1;

--echo #
--echo # End of 10.2 tests
--echo #

--echo #
--echo # Check that innodb supports transactional=1
--echo #

create table t1 (a int) transactional=1 engine=aria;
create table t2 (a int) transactional=1 engine=innodb;
show create table t1;
show create table t2;
alter table t1 engine=innodb;
alter table t1 add column b int;
drop table t1,t2;

--echo #
--echo # MDEV-19272 Assertion unireg_check...Field::NEXT_NUMBER failed
--echo #
CREATE TABLE t1 (c INT AUTO_INCREMENT NULL UNIQUE) ENGINE=InnoDB;
ALTER TABLE t1 MODIFY c INT NOT NULL, ALGORITHM=INPLACE;
DROP TABLE t1;
--error ER_WRONG_FIELD_SPEC
CREATE TABLE t1 (c TIMESTAMP AUTO_INCREMENT UNIQUE) ENGINE=InnoDB;
--error ER_WRONG_FIELD_SPEC
CREATE TABLE t1 (c DATETIME AUTO_INCREMENT UNIQUE) ENGINE=InnoDB;

--echo #
--echo # End of 10.4 tests
--echo #

--echo #
--echo # MDEV-21748 ASAN use-after-poison in PageBulk::insertPage()
--echo #
CREATE TABLE t1 (pk TIMESTAMP PRIMARY KEY, a TIMESTAMP NULL UNIQUE)
ENGINE=InnoDB;
INSERT INTO t1 VALUES
  ('2020-03-10 10:21:00', NULL),
  ('0000-00-00 00:00:00', '0000-00-00 00:00:00');
ALTER TABLE t1 FORCE, ALGORITHM=INPLACE;
DROP TABLE t1;
--echo #
--echo # MDEV-21850 ASAN use-after-poison in page_cur_insert_rec_low()
--echo #
CREATE TABLE t1 (id INT PRIMARY KEY, a YEAR, INDEX(id,a)) ENGINE=InnoDB;
INSERT INTO t1 VALUES (1,NULL),(2,NULL);
UPDATE t1 SET a=0;
DROP TABLE t1;