File: type_binary.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 (298 lines) | stat: -rw-r--r-- 9,992 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
create table t1 (s1 binary(3));
insert into t1 values (0x61), (0x6120), (0x612020);
select hex(s1) from t1;
hex(s1)
610000
612000
612020
drop table t1;
create table t1 (s1 binary(2), s2 varbinary(2));
insert into t1 values (0x4100,0x4100);
select length(concat('*',s1,'*',s2,'*')) from t1;
length(concat('*',s1,'*',s2,'*'))
7
delete from t1;
insert into t1 values (0x4120,0x4120);
select length(concat('*',s1,'*',s2,'*')) from t1;
length(concat('*',s1,'*',s2,'*'))
7
drop table t1;
create table t1 (s1 varbinary(20), s2 varbinary(20));
show create table t1;
Table	Create Table
t1	CREATE TABLE `t1` (
  `s1` varbinary(20) DEFAULT NULL,
  `s2` varbinary(20) DEFAULT NULL
) ENGINE=ENGINE DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci
insert into t1 values (0x41,0x4100),(0x41,0x4120),(0x4100,0x4120);
select hex(s1), hex(s2) from t1;
hex(s1)	hex(s2)
41	4100
41	4120
4100	4120
select count(*) from t1 where s1 < s2;
count(*)
3
drop table t1;
create table t1 (s1 varbinary(2), s2 varchar(1));
insert into t1 values (0x41,'a'), (0x4100,'b'), (0x41,'c'), (0x4100,'d');
select hex(s1),s2 from t1 order by s1,s2;
hex(s1)	s2
41	a
41	c
4100	b
4100	d
drop table t1;
create table t1 (s1 binary(2) primary key);
insert into t1 values (0x01);
insert into t1 values (0x0120);
insert into t1 values (0x0100);
ERROR 23000: Duplicate entry '\x01' for key 't1.PRIMARY'
select hex(s1) from t1 order by s1;
hex(s1)
0100
0120
select hex(s1) from t1 where s1=0x01;
hex(s1)
select hex(s1) from t1 where s1=0x0120;
hex(s1)
0120
select hex(s1) from t1 where s1=0x0100;
hex(s1)
0100
select count(distinct s1) from t1;
count(distinct s1)
2
alter table t1 drop primary key;
select hex(s1) from t1 where s1=0x01;
hex(s1)
select hex(s1) from t1 where s1=0x0120;
hex(s1)
0120
select hex(s1) from t1 where s1=0x0100;
hex(s1)
0100
select count(distinct s1) from t1;
count(distinct s1)
2
drop table t1;
create table t1 (s1 varbinary(2) primary key);
insert into t1 values (0x01);
insert into t1 values (0x0120);
insert into t1 values (0x0100);
select hex(s1) from t1 order by s1;
hex(s1)
01
0100
0120
select hex(s1) from t1 where s1=0x01;
hex(s1)
01
select hex(s1) from t1 where s1=0x0120;
hex(s1)
0120
select hex(s1) from t1 where s1=0x0100;
hex(s1)
0100
select count(distinct s1) from t1;
count(distinct s1)
3
alter table t1 drop primary key;
select hex(s1) from t1 where s1=0x01;
hex(s1)
01
select hex(s1) from t1 where s1=0x0120;
hex(s1)
0120
select hex(s1) from t1 where s1=0x0100;
hex(s1)
0100
select count(distinct s1) from t1;
count(distinct s1)
3
drop table t1;
select hex(cast(0x10 as binary(2)));
hex(cast(0x10 as binary(2)))
1000
create table t1 (b binary(2), vb varbinary(2));
insert into t1 values(0x4120, 0x4120);
insert ignore into t1 values(0x412020, 0x412020);
Warnings:
Warning	1265	Data truncated for column 'b' at row 1
Warning	1265	Data truncated for column 'vb' at row 1
drop table t1;
create table t1 (c char(2), vc varchar(2));
insert into t1 values(0x4120, 0x4120);
insert into t1 values(0x412020, 0x412020);
Warnings:
Note	1265	Data truncated for column 'vc' at row 1
drop table t1;
set @old_sql_mode= @@sql_mode, sql_mode= 'traditional';
create table t1 (b binary(2), vb varbinary(2));
insert into t1 values(0x4120, 0x4120);
insert into t1 values(0x412020, NULL);
ERROR 22001: Data too long for column 'b' at row 1
insert into t1 values(NULL, 0x412020);
ERROR 22001: Data too long for column 'vb' at row 1
drop table t1;
set @@sql_mode= @old_sql_mode;
create table t1(f1 int, f2 binary(2) not null, f3 char(2) not null);
insert ignore into t1 set f1=1;
Warnings:
Warning	1364	Field 'f2' doesn't have a default value
Warning	1364	Field 'f3' doesn't have a default value
select hex(f2), hex(f3) from t1;
hex(f2)	hex(f3)
0000	
drop table t1;
End of 5.0 tests
#
# Bug#21922414 CAST OF TOO BIG HEX LITERAL TO BIGINT UNSIGNED: BAD RESULT AND NO WARNING
#
# Those casts overflow and must send a warning
select convert(9999999999999999999999999999999999999999999,unsigned);
convert(9999999999999999999999999999999999999999999,unsigned)
18446744073709551615
Warnings:
Warning	1292	Truncated incorrect DECIMAL value: '9999999999999999999999999999999999999999999'
select convert('9999999999999999999999999999999999999999999',unsigned);
convert('9999999999999999999999999999999999999999999',unsigned)
18446744073709551615
Warnings:
Warning	1292	Truncated incorrect INTEGER value: '9999999999999999999999999999999999999999999'
select convert(0x9999999999999999999999999999999999999999999,unsigned);
convert(0x9999999999999999999999999999999999999999999,unsigned)
0
Warnings:
Warning	1292	Truncated incorrect BINARY value: 'x'09999999999999999999999999999999999999999999''
# and an error in strict mode
create table t1
select convert(0x9999999999999999999999999999999999999999999,unsigned);
ERROR 22007: Truncated incorrect BINARY value: 'x'09999999999999999999999999999999999999999999''
# Same here
select 9999999999999999999999999999999999999999999 | 0;
9999999999999999999999999999999999999999999 | 0
9223372036854775807
Warnings:
Warning	1292	Truncated incorrect DECIMAL value: '9999999999999999999999999999999999999999999'
select '9999999999999999999999999999999999999999999' | 0;
'9999999999999999999999999999999999999999999' | 0
18446744073709551615
Warnings:
Warning	1292	Truncated incorrect INTEGER value: '9999999999999999999999999999999999999999999'
select 0x9999999999999999999999999999999999999999999 | 0;
0x9999999999999999999999999999999999999999999 | 0
0
Warnings:
Warning	1292	Truncated incorrect BINARY value: 'x'09999999999999999999999999999999999999999999''
# DECIMAL addition, no warning
select 9999999999999999999999999999999999999999999 + 0;
9999999999999999999999999999999999999999999 + 0
9999999999999999999999999999999999999999999
# DOUBLE addition, no warning
select '9999999999999999999999999999999999999999999' + 0;
'9999999999999999999999999999999999999999999' + 0
1e43
# BIGINT UNSIGNED addition, warning
select 0x9999999999999999999999999999999999999999999 + 0;
0x9999999999999999999999999999999999999999999 + 0
0
Warnings:
Warning	1292	Truncated incorrect BINARY value: 'x'09999999999999999999999999999999999999999999''
# Test truncation inside error message
select 0x9999999999999999999999999999999999999999999888888888888888888888888888888888888888888888888888888888888888888888888877777777777777777777777777777777777777777777777777777777777776666666666666666666666666666666666666666 + 0;
0x9999999999999999999999999999999999999999999888888888888888888888888888888888888888888888888888888888888888888888888877777777777777777777777777777777777777777777777777777777777776666666666666666666666666666666666666666 + 0
0
Warnings:
Warning	1292	Truncated incorrect BINARY value: 'x'099999999999999999999999999999999999999999998888888888888888888888888888888888888888888888888888888888888888888888888777777777'
create table t1 select 0x9999 + 0;
desc t1;
Field	Type	Null	Key	Default	Extra
0x9999 + 0	int unsigned	NO		0	
select * from t1;
0x9999 + 0
39321
drop table t1;
#
# Bug#11757477 ARITHMETIC ERROR WHEN DEALING WITH BIGINT
#
SELECT HEX(0xfffffffffffff+1);
HEX(0xfffffffffffff+1)
10000000000000
SELECT HEX(0xfffffffffffff+2);
HEX(0xfffffffffffff+2)
10000000000001
SELECT 0x20000000000000+0;
0x20000000000000+0
9007199254740992
SELECT 0x20000000000000+1;
0x20000000000000+1
9007199254740993
SELECT 0x20000000000000+2;
0x20000000000000+2
9007199254740994
SELECT 0x20000000000000+3;
0x20000000000000+3
9007199254740995
SELECT 0xfffffffffffff+2;
0xfffffffffffff+2
4503599627370497
SELECT 0xfffffffffffff+1;
0xfffffffffffff+1
4503599627370496
#
# Bug#22268110 VIEW USING HEXADECIMAL OR BIT LITERAL GIVES WRONG RESULTS
#
# Literals with more than 8 bytes.
CREATE VIEW v1 AS SELECT
x'7f9d04ae61b34468ac798ffcc984ab68'=x'7f9d04ae61b34468ac798ffcc984ab68'
AS a,
x'7f9d04ae61b34468ac798ffcc984ab68'=x'7f9d04ae61b34468ac798ffcc984ab60'
AS b,
x'7f9d04ae61b34468ac798ffcc984ab68'=x'0f9d04ae61b34468ac798ffcc984ab68'
AS c,
b'111111111111111111111111111111111111111111111111111111111111111111'=
b'111111111111111111111111111111111111111111111111111111111111111111'
AS d,
b'111111111111111111111111111111111111111111111111111111111111111111'=
b'111111111111111111111111111111111111111111111111111111111111111110'
AS e,
b'111111111111111111111111111111111111111111111111111111111111111111'=
b'011111111111111111111111111111111111111111111111111111111111111111'
AS f;
# Both should give same result:
SELECT
x'7f9d04ae61b34468ac798ffcc984ab68'=x'7f9d04ae61b34468ac798ffcc984ab68'
AS a,
x'7f9d04ae61b34468ac798ffcc984ab68'=x'7f9d04ae61b34468ac798ffcc984ab60'
AS b,
x'7f9d04ae61b34468ac798ffcc984ab68'=x'0f9d04ae61b34468ac798ffcc984ab68'
AS c,
b'111111111111111111111111111111111111111111111111111111111111111111'=
b'111111111111111111111111111111111111111111111111111111111111111111'
AS d,
b'111111111111111111111111111111111111111111111111111111111111111111'=
b'111111111111111111111111111111111111111111111111111111111111111110'
AS e,
b'111111111111111111111111111111111111111111111111111111111111111111'=
b'011111111111111111111111111111111111111111111111111111111111111111'
AS f;
a	b	c	d	e	f
1	0	0	1	0	0
SELECT * FROM v1;
a	b	c	d	e	f
1	0	0	1	0	0
# Literals should be entirely printed:
SHOW CREATE VIEW v1;
View	Create View	character_set_client	collation_connection
v1	CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v1` AS select (0x7f9d04ae61b34468ac798ffcc984ab68 = 0x7f9d04ae61b34468ac798ffcc984ab68) AS `a`,(0x7f9d04ae61b34468ac798ffcc984ab68 = 0x7f9d04ae61b34468ac798ffcc984ab60) AS `b`,(0x7f9d04ae61b34468ac798ffcc984ab68 = 0x0f9d04ae61b34468ac798ffcc984ab68) AS `c`,(0x03ffffffffffffffff = 0x03ffffffffffffffff) AS `d`,(0x03ffffffffffffffff = 0x03fffffffffffffffe) AS `e`,(0x03ffffffffffffffff = 0x01ffffffffffffffff) AS `f`	utf8mb4	utf8mb4_0900_ai_ci
DROP VIEW v1;
#
# Bug#35507763: Assertion `to->field_ptr() != from->field_ptr()' failed.
#
CREATE TABLE t (x BINARY(0), y BINARY(0));
INSERT INTO t VALUES ('', x);
SELECT * FROM t;
x	y
	
DROP TABLE t;