File: type_bit_innodb.result

package info (click to toggle)
mysql-8.0 8.0.43-3
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 1,273,924 kB
  • sloc: cpp: 4,684,605; ansic: 412,450; pascal: 108,398; java: 83,641; perl: 30,221; cs: 27,067; sql: 26,594; sh: 24,181; python: 21,816; yacc: 17,169; php: 11,522; xml: 7,388; javascript: 7,076; makefile: 2,194; lex: 1,075; awk: 670; asm: 520; objc: 183; ruby: 97; lisp: 86
file content (440 lines) | stat: -rw-r--r-- 9,091 bytes parent folder | download
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
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
select 0 + b'1';
0 + b'1'
1
select 0 + b'0';
0 + b'0'
0
select 0 + b'000001';
0 + b'000001'
1
select 0 + b'000011';
0 + b'000011'
3
select 0 + b'000101';
0 + b'000101'
5
select 0 + b'000000';
0 + b'000000'
0
select 0 + b'10000000';
0 + b'10000000'
128
select 0 + b'11111111';
0 + b'11111111'
255
select 0 + b'10000001';
0 + b'10000001'
129
select 0 + b'1000000000000000';
0 + b'1000000000000000'
32768
select 0 + b'1111111111111111';
0 + b'1111111111111111'
65535
select 0 + b'1000000000000001';
0 + b'1000000000000001'
32769
drop table if exists t1;
create table t1 (a bit(65)) engine=innodb;
ERROR 42000: Display width out of range for column 'a' (max = 64)
create table t1 (a bit(0)) engine=innodb;
ERROR HY000: Invalid size for column 'a'.
create table t1 (a bit(64)) engine=innodb;
insert into t1 values 
(b'1111111111111111111111111111111111111111111111111111111111111111'),
(b'1000000000000000000000000000000000000000000000000000000000000000'),
(b'0000000000000000000000000000000000000000000000000000000000000001'),
(b'1010101010101010101010101010101010101010101010101010101010101010'),
(b'0101010101010101010101010101010101010101010101010101010101010101');
select hex(a) from t1;
hex(a)
FFFFFFFFFFFFFFFF
8000000000000000
1
AAAAAAAAAAAAAAAA
5555555555555555
drop table t1;
create table t1 (a bit) engine=innodb;
insert ignore into t1 values (b'0'), (b'1'), (b'000'), (b'100'), (b'001');
Warnings:
Warning	1406	Data too long for column 'a' at row 4
select hex(a) from t1;
hex(a)
0
1
0
1
1
alter table t1 add unique (a);
ERROR 23000: Duplicate entry '\x01' for key 't1.a'
drop table t1;
create table t1 (a bit(2)) engine=innodb;
insert ignore into t1 values (b'00'), (b'01'), (b'10'), (b'100');
Warnings:
Warning	1406	Data too long for column 'a' at row 4
select a+0 from t1;
a+0
0
1
2
3
alter table t1 add key (a);
analyze table t1;
explain select a+0 from t1;
id	select_type	table	partitions	type	possible_keys	key	key_len	ref	rows	filtered	Extra
1	SIMPLE	t1	NULL	index	NULL	a	2	NULL	4	100.00	Using index
Warnings:
Note	1003	/* select#1 */ select (`test`.`t1`.`a` + 0) AS `a+0` from `test`.`t1`
select a+0 from t1;
a+0
0
1
2
3
drop table t1;
create table t1 (a bit(7), b bit(9), key(a, b)) engine=innodb;
insert into t1 values 
(94, 46), (31, 438), (61, 152), (78, 123), (88, 411), (122, 118), (0, 177),    
(75, 42), (108, 67), (79, 349), (59, 188), (68, 206), (49, 345), (118, 380),   
(111, 368), (94, 468), (56, 379), (77, 133), (29, 399), (9, 363), (23, 36),    
(116, 390), (119, 368), (87, 351), (123, 411), (24, 398), (34, 202), (28, 499),
(30, 83), (5, 178), (60, 343), (4, 245), (104, 280), (106, 446), (127, 403),   
(44, 307), (68, 454), (57, 135);
analyze table t1;
explain select a+0 from t1;
id	select_type	table	partitions	type	possible_keys	key	key_len	ref	rows	filtered	Extra
1	SIMPLE	t1	NULL	index	NULL	a	5	NULL	38	100.00	Using index
Warnings:
Note	1003	/* select#1 */ select (`test`.`t1`.`a` + 0) AS `a+0` from `test`.`t1`
select a+0 from t1;
a+0
0
104
106
108
111
116
118
119
122
123
127
23
24
28
29
30
31
34
4
44
49
5
56
57
59
60
61
68
68
75
77
78
79
87
88
9
94
94
explain select b+0 from t1;
id	select_type	table	partitions	type	possible_keys	key	key_len	ref	rows	filtered	Extra
1	SIMPLE	t1	NULL	index	NULL	a	5	NULL	38	100.00	Using index
Note	1003	/* select#1 */ select (`test`.`t1`.`b` + 0) AS `b+0` from `test`.`t1`
Warnings:
select b+0 from t1;
b+0
118
123
133
135
152
177
178
188
202
206
245
280
307
343
345
349
351
36
363
368
368
379
380
390
398
399
403
411
411
42
438
446
454
46
468
499
67
83
explain select a+0, b+0 from t1;
id	select_type	table	partitions	type	possible_keys	key	key_len	ref	rows	filtered	Extra
1	SIMPLE	t1	NULL	index	NULL	a	5	NULL	38	100.00	Using index
Warnings:
Note	1003	/* select#1 */ select (`test`.`t1`.`a` + 0) AS `a+0`,(`test`.`t1`.`b` + 0) AS `b+0` from `test`.`t1`
select a+0, b+0 from t1;
a+0	b+0
0	177
104	280
106	446
108	67
111	368
116	390
118	380
119	368
122	118
123	411
127	403
23	36
24	398
28	499
29	399
30	83
31	438
34	202
4	245
44	307
49	345
5	178
56	379
57	135
59	188
60	343
61	152
68	206
68	454
75	42
77	133
78	123
79	349
87	351
88	411
9	363
94	46
94	468
explain select a+0, b+0 from t1 where a > 40 and b > 200 order by 1;
id	select_type	table	partitions	type	possible_keys	key	key_len	ref	rows	filtered	Extra
1	SIMPLE	t1	NULL	range	a	a	2	NULL	27	33.33	Using where; Using index; Using filesort
Warnings:
Note	1003	/* select#1 */ select (`test`.`t1`.`a` + 0) AS `a+0`,(`test`.`t1`.`b` + 0) AS `b+0` from `test`.`t1` where ((`test`.`t1`.`a` > 40) and (`test`.`t1`.`b` > 200)) order by (`test`.`t1`.`a` + 0)
select a+0, b+0 from t1 where a > 40 and b > 200 order by 1;
a+0	b+0
44	307
49	345
56	379
60	343
68	206
68	454
79	349
87	351
88	411
94	468
104	280
106	446
111	368
116	390
118	380
119	368
123	411
127	403
explain select a+0, b+0 from t1 where a > 40 and a < 70 order by 2;
id	select_type	table	partitions	type	possible_keys	key	key_len	ref	rows	filtered	Extra
1	SIMPLE	t1	NULL	range	a	a	2	NULL	9	100.00	Using where; Using index; Using filesort
Warnings:
Note	1003	/* select#1 */ select (`test`.`t1`.`a` + 0) AS `a+0`,(`test`.`t1`.`b` + 0) AS `b+0` from `test`.`t1` where ((`test`.`t1`.`a` > 40) and (`test`.`t1`.`a` < 70)) order by (`test`.`t1`.`b` + 0)
select a+0, b+0 from t1 where a > 40 and a < 70 order by 2;
a+0	b+0
57	135
61	152
59	188
68	206
44	307
60	343
49	345
56	379
68	454
select hex(min(a)) from t1;
hex(min(a))
0
select hex(min(b)) from t1;
hex(min(b))
24
select hex(min(a)), hex(max(a)), hex(min(b)), hex(max(b)) from t1;
hex(min(a))	hex(max(a))	hex(min(b))	hex(max(b))
0	7F	24	1F3
drop table t1;
create table t1 (a int not null, b bit, c bit(9), key(a, b, c)) engine=innodb;
insert into t1 values
(4, NULL, 1), (4, 0, 3), (2, 1, 4), (1, 1, 100), (4, 0, 23), (4, 0, 54),
(56, 0, 22), (4, 1, 100), (23, 0, 1), (4, 0, 34);
select a+0, b+0, c+0 from t1;
a+0	b+0	c+0
1	1	100
2	1	4
23	0	1
4	0	23
4	0	3
4	0	34
4	0	54
4	1	100
4	NULL	1
56	0	22
select hex(min(b)) from t1 where a = 4;
hex(min(b))
0
select hex(min(c)) from t1 where a = 4 and b = 0;
hex(min(c))
3
select hex(max(b)) from t1;
hex(max(b))
1
select a+0, b+0, c+0 from t1 where a = 4 and b = 0 limit 2;
a+0	b+0	c+0
4	0	3
4	0	23
select a+0, b+0, c+0 from t1 where a = 4 and b = 1;
a+0	b+0	c+0
4	1	100
select a+0, b+0, c+0 from t1 where a = 4 and b = 1 and c=100;
a+0	b+0	c+0
4	1	100
select b+0, a+0, c+0 from t1 order by b desc;
b+0	a+0	c+0
1	1	100
1	2	4
1	4	100
0	23	1
0	4	23
0	4	3
0	4	34
0	4	54
0	56	22
NULL	4	1
select c+0, a+0, b+0 from t1 order by c;
c+0	a+0	b+0
1	23	0
1	4	NULL
3	4	0
4	2	1
22	56	0
23	4	0
34	4	0
54	4	0
100	1	1
100	4	1
drop table t1;
create table t1(a bit(2), b bit(2)) engine=innodb;
insert into t1 (a) values (0x01), (0x03), (0x02);
update t1 set b= concat(a);
select a+0, b+0 from t1;
a+0	b+0
1	1
3	3
2	2
drop table t1;
create table t1 (a bit(7), key(a)) engine=innodb;
insert into t1 values (44), (57);
select a+0 from t1;
a+0
44
57
drop table t1;
create table t1 (a bit(3), b bit(12)) engine=innodb;
insert into t1 values (7,(1<<12)-2), (0x01,0x01ff);
select hex(a),hex(b) from t1;
hex(a)	hex(b)
7	FFE
1	1FF
select hex(concat(a)),hex(concat(b)) from t1;
hex(concat(a))	hex(concat(b))
07	0FFE
01	01FF
drop table t1;
create table t1(a int, b bit not null) engine=innodb;
alter table t1 add primary key (a);
drop table t1;
create table t1 (a bit, b bit(10)) engine=innodb;
show create table t1;
Table	Create Table
t1	CREATE TABLE `t1` (
  `a` bit(1) DEFAULT NULL,
  `b` bit(10) DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci
alter table t1 engine=heap;
show create table t1;
Table	Create Table
t1	CREATE TABLE `t1` (
  `a` bit(1) DEFAULT NULL,
  `b` bit(10) DEFAULT NULL
) ENGINE=MEMORY DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci
alter table t1 engine=innodb;
show create table t1;
Table	Create Table
t1	CREATE TABLE `t1` (
  `a` bit(1) DEFAULT NULL,
  `b` bit(10) DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci
drop table t1;
create table t1 (a bit(7)) engine=innodb;
insert into t1 values (0x60);
select * from t1;
Catalog	Database	Table	Table_alias	Column	Column_alias	Type	Length	Max length	Is_null	Flags	Decimals	Charsetnr
def	test	t1	t1	a	a	16	7	1	Y	32	0	63
a
`
drop table t1;
End of 5.0 tests
#
# Bug #31564742 	LOST ULLONG_MAX VALUE IN TABLE WITH TYPE OF BIT(64)
#
CREATE TABLE t1 (a BIT(64));
INSERT INTO t1 VALUES
(b'1111111111111111111111111111111111111111111111111111111111111111');
SELECT HEX(a) FROM t1 WHERE a =
b'1111111111111111111111111111111111111111111111111111111111111111';
HEX(a)
FFFFFFFFFFFFFFFF
DROP TABLE t1;
#
# Bug #31019130 CASTING DOUBLE TO LONGLONG CAUSES UB
#               IN FIELD_*::STORE(DOUBLE)
#
CREATE TABLE t_double (a double not null);
INSERT INTO t_double (a) VALUES
(-20000000000000000000000000000.0001), (20000000000000000000000000000.0001);
CREATE TABLE t_bit (
b bit(3)
);
INSERT IGNORE INTO t_bit (b) SELECT a from t_double;
Warnings:
Warning	1406	Data too long for column 'b' at row 1
Warning	1406	Data too long for column 'b' at row 2
SELECT HEX(b) FROM t_bit;
HEX(b)
7
7
DROP TABLE t_double, t_bit;