summaryrefslogtreecommitdiff
path: root/mysql-test/r/type_binary.result
blob: 9d44d718a02974ae46a3a4acea99d6aeda76cf38 (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
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=MyISAM DEFAULT CHARSET=latin1
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 '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 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 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
#
# Start of 10.0 tests
#
#
# MDEV-8472 BINARY, VARBINARY and BLOB return different warnings on CAST to DECIMAL
#
SET NAMES utf8;
CREATE TABLE t1 (a BINARY(30));
INSERT INTO t1 VALUES ('1äÖüß@µ*$');
SELECT CAST(a AS DECIMAL) FROM t1;
CAST(a AS DECIMAL)
1
Warnings:
Warning	1292	Truncated incorrect DECIMAL value: '1\xC3\xA4\xC3\x96\xC3\xBC\xC3\x9F@\xC2\xB5*$\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00'
DROP TABLE t1;
CREATE TABLE t1 (a VARBINARY(30));
INSERT INTO t1 VALUES ('1äÖüß@µ*$');
SELECT CAST(a AS DECIMAL) FROM t1;
CAST(a AS DECIMAL)
1
Warnings:
Warning	1292	Truncated incorrect DECIMAL value: '1\xC3\xA4\xC3\x96\xC3\xBC\xC3\x9F@\xC2\xB5*$'
DROP TABLE t1;
CREATE TABLE t1 (a BLOB);
INSERT INTO t1 VALUES ('1äÖüß@µ*$');
SELECT CAST(a AS DECIMAL) FROM t1;
CAST(a AS DECIMAL)
1
Warnings:
Warning	1292	Truncated incorrect DECIMAL value: '1\xC3\xA4\xC3\x96\xC3\xBC\xC3\x9F@\xC2\xB5*$'
DROP TABLE t1;
#
# End of 10.0 tests
#