summaryrefslogtreecommitdiffstats
path: root/mysql-test/suite/innodb/r/innodb-alter-nullable.result
blob: 1d481cf2bfeda2fa103ac077229b9887483aff71 (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
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
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);
ALTER TABLE t CHANGE c1 c1 INT NULL FIRST, ALGORITHM=INPLACE;
affected rows: 0
info: Records: 0  Duplicates: 0  Warnings: 0
ALTER TABLE t MODIFY c3 INT NOT NULL, ALGORITHM=INPLACE;
affected rows: 0
info: Records: 0  Duplicates: 0  Warnings: 0
ALTER TABLE t CHANGE c2 c2 INT, CHANGE c2 c2 INT NOT NULL;
ERROR 42S22: Unknown column 'c2' in 't'
ALTER TABLE t MODIFY c2 INT, MODIFY c2 INT NOT NULL;
ERROR 42S22: Unknown column 'c2' in 't'
ALTER TABLE t MODIFY c2 INT UNSIGNED, MODIFY c2 INT;
ERROR 42S22: Unknown column 'c2' in 't'
ALTER TABLE t MODIFY c2 CHAR(1) NOT NULL, MODIFY c2 INT NOT NULL;
ERROR 42S22: Unknown column 'c2' in 't'
ALTER TABLE t CHANGE c2 c2 INT NOT NULL;
affected rows: 0
info: Records: 0  Duplicates: 0  Warnings: 0
ALTER TABLE t MODIFY c2 INT NOT NULL;
affected rows: 0
info: Records: 0  Duplicates: 0  Warnings: 0
connect  con1,localhost,root,,;
UPDATE t SET c2=NULL;
ERROR 23000: Column 'c2' cannot be null
SELECT * FROM t;
c1	c2	c3
1	2	3
4	5	6
7	8	9
connection default;
ALTER TABLE t MODIFY c2 INT, ALGORITHM=INPLACE;
connection con1;
BEGIN;
UPDATE t SET c2=NULL;
SELECT * FROM t;
c1	c2	c3
1	NULL	3
4	NULL	6
7	NULL	9
ROLLBACK;
SELECT * FROM t;
c1	c2	c3
1	2	3
4	5	6
7	8	9
disconnect con1;
connection default;
ALTER TABLE t MODIFY c2 INT NULL, ALGORITHM=INPLACE;
SELECT * FROM INFORMATION_SCHEMA.INNODB_SYS_TABLES
WHERE NAME='test/t';
TABLE_ID	NAME	FLAG	N_COLS	SPACE	ROW_FORMAT	ZIP_PAGE_SIZE	SPACE_TYPE
#	test/t	33	6	#	Dynamic	0	Single
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;
#
# MDEV-18732 InnoDB: ALTER IGNORE returns error for NULL
#
CREATE TABLE t1(c INT) ENGINE=InnoDB;
INSERT INTO t1 VALUES (NULL);
ALTER IGNORE TABLE t1 MODIFY c INT NOT NULL;
affected rows: 0
info: Records: 0  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;
CREATE TABLE t1(c INT, g INT AS (c) PERSISTENT) ENGINE=InnoDB;
CREATE TABLE t2(c INT, v INT AS (c) VIRTUAL) ENGINE=InnoDB;
CREATE TABLE t3(c INT, v INT AS (c) VIRTUAL, INDEX(v)) ENGINE=InnoDB;
INSERT INTO t1 SET c=NULL;
INSERT INTO t2 SET c=NULL;
INSERT INTO t3 SET c=NULL;
SET @old_sql_mode = @@sql_mode;
SET sql_mode = '';
ALTER 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
ALTER TABLE t2 MODIFY c INT NOT NULL;
affected rows: 0
info: Records: 0  Duplicates: 0  Warnings: 1
Warnings:
Warning	1265	Data truncated for column 'c' at row 1
ALTER TABLE t3 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
SET sql_mode = @old_sql_mode;
SELECT * FROM t1;
c	g
0	0
SELECT * FROM t2;
c	v
0	0
SELECT * FROM t3;
c	v
0	0
SELECT v FROM t3 FORCE INDEX(v);
v
0
CHECK TABLE t1,t2,t3;
Table	Op	Msg_type	Msg_text
test.t1	check	status	OK
test.t2	check	status	OK
test.t3	check	status	OK
DROP TABLE t1,t2,t3;
CREATE TABLE t1(c INT, g INT AS (c) PERSISTENT) ENGINE=InnoDB;
CREATE TABLE t2(c INT, v INT AS (c) VIRTUAL) ENGINE=InnoDB;
CREATE TABLE t3(c INT, v INT AS (c) VIRTUAL, INDEX(v)) ENGINE=InnoDB;
INSERT INTO t1 SET c=NULL;
INSERT INTO t2 SET c=NULL;
INSERT INTO t3 SET c=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
ALTER IGNORE TABLE t2 MODIFY c INT NOT NULL;
affected rows: 0
info: Records: 0  Duplicates: 0  Warnings: 1
Warnings:
Warning	1265	Data truncated for column 'c' at row 1
ALTER IGNORE TABLE t3 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
SELECT * FROM t1;
c	g
0	0
SELECT * FROM t2;
c	v
0	0
SELECT * FROM t3;
c	v
0	0
SELECT v FROM t3 FORCE INDEX(v);
v
0
CHECK TABLE t1,t2,t3;
Table	Op	Msg_type	Msg_text
test.t1	check	status	OK
test.t2	check	status	OK
test.t3	check	status	OK
DROP TABLE t1,t2,t3;
CREATE TABLE t1(c INT, g INT AS (c) PERSISTENT) ENGINE=InnoDB;
CREATE TABLE t2(c INT, v INT AS (c) VIRTUAL) ENGINE=InnoDB;
CREATE TABLE t3(c INT, v INT AS (c) VIRTUAL, INDEX(v)) ENGINE=InnoDB;
INSERT INTO t1 SET c=NULL;
INSERT INTO t2 SET c=NULL;
INSERT INTO t3 SET c=NULL;
ALTER TABLE t1 MODIFY c INT NOT NULL;
ERROR 01000: Data truncated for column 'c' at row 1
ALTER TABLE t2 MODIFY c INT NOT NULL;
ERROR 01000: Data truncated for column 'c' at row 1
ALTER TABLE t3 MODIFY c INT NOT NULL;
ERROR 01000: Data truncated for column 'c' at row 1
UPDATE t1 SET c=0;
UPDATE t2 SET c=0;
UPDATE t3 SET c=0;
ALTER TABLE t1 MODIFY c INT NOT NULL;
affected rows: 1
info: Records: 1  Duplicates: 0  Warnings: 0
ALTER TABLE t2 MODIFY c INT NOT NULL;
affected rows: 0
info: Records: 0  Duplicates: 0  Warnings: 0
ALTER TABLE t3 MODIFY c INT NOT NULL;
affected rows: 1
info: Records: 1  Duplicates: 0  Warnings: 0
SELECT * FROM t1;
c	g
0	0
SELECT * FROM t2;
c	v
0	0
SELECT * FROM t3;
c	v
0	0
DROP TABLE t1,t2,t3;