summaryrefslogtreecommitdiff
path: root/mysql-test/r/func_set.result
blob: 46be54ca6a4cbd1250cbe63013ae0b8d0ed122fd (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
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
select interval(55,10,20,30,40,50,60,70,80,90,100),interval(3,1,1+1,1+1+1+1),field("IBM","NCA","ICL","SUN","IBM","DIGITAL"),field("A","B","C"),elt(2,"ONE","TWO","THREE"),interval(0,1,2,3,4),elt(1,1,2,3)|0,elt(1,1.1,1.2,1.3)+0;
interval(55,10,20,30,40,50,60,70,80,90,100)	interval(3,1,1+1,1+1+1+1)	field("IBM","NCA","ICL","SUN","IBM","DIGITAL")	field("A","B","C")	elt(2,"ONE","TWO","THREE")	interval(0,1,2,3,4)	elt(1,1,2,3)|0	elt(1,1.1,1.2,1.3)+0
5	2	4	0	TWO	0	1	1.1
explain extended select INTERVAL(55,10,20,30,40,50,60,70,80,90,100),interval(3,1,1+1,1+1+1+1),field("IBM","NCA","ICL","SUN","IBM","DIGITAL"),field("A","B","C"),elt(2,"ONE","TWO","THREE"),interval(0,1,2,3,4),elt(1,1,2,3)|0,elt(1,1.1,1.2,1.3)+0;
id	select_type	table	type	possible_keys	key	key_len	ref	rows	filtered	Extra
1	SIMPLE	NULL	NULL	NULL	NULL	NULL	NULL	NULL	NULL	No tables used
Warnings:
Note	1003	select interval(55,10,20,30,40,50,60,70,80,90,100) AS `INTERVAL(55,10,20,30,40,50,60,70,80,90,100)`,interval(3,1,1 + 1,1 + 1 + 1 + 1) AS `interval(3,1,1+1,1+1+1+1)`,field('IBM','NCA','ICL','SUN','IBM','DIGITAL') AS `field("IBM","NCA","ICL","SUN","IBM","DIGITAL")`,field('A','B','C') AS `field("A","B","C")`,elt(2,'ONE','TWO','THREE') AS `elt(2,"ONE","TWO","THREE")`,interval(0,1,2,3,4) AS `interval(0,1,2,3,4)`,elt(1,1,2,3) | 0 AS `elt(1,1,2,3)|0`,elt(1,1.1,1.2,1.3) + 0 AS `elt(1,1.1,1.2,1.3)+0`
SELECT INTERVAL(13, 7, 14, 21, 28, 35, 42, 49, 56);
INTERVAL(13, 7, 14, 21, 28, 35, 42, 49, 56)
1
SELECT INTERVAL(13, 7, 14, 21, 28, 35, 42, 49, 56, 77);
INTERVAL(13, 7, 14, 21, 28, 35, 42, 49, 56, 77)
1
select find_in_set("b","a,b,c"),find_in_set("c","a,b,c"),find_in_set("dd","a,bbb,dd"),find_in_set("bbb","a,bbb,dd");
find_in_set("b","a,b,c")	find_in_set("c","a,b,c")	find_in_set("dd","a,bbb,dd")	find_in_set("bbb","a,bbb,dd")
2	3	3	2
select find_in_set("d","a,b,c"),find_in_set("dd","a,bbb,d"),find_in_set("bb","a,bbb,dd");
find_in_set("d","a,b,c")	find_in_set("dd","a,bbb,d")	find_in_set("bb","a,bbb,dd")
0	0	0
select make_set(0,'a','b','c'),make_set(-1,'a','b','c'),make_set(1,'a','b','c'),make_set(2,'a','b','c'),make_set(1+2,concat('a','b'),'c');
make_set(0,'a','b','c')	make_set(-1,'a','b','c')	make_set(1,'a','b','c')	make_set(2,'a','b','c')	make_set(1+2,concat('a','b'),'c')
	a,b,c	a	b	ab,c
select make_set(NULL,'a','b','c'),make_set(1|4,'a',NULL,'c'),make_set(1+2,'a',NULL,'c');
make_set(NULL,'a','b','c')	make_set(1|4,'a',NULL,'c')	make_set(1+2,'a',NULL,'c')
NULL	a,c	a
select export_set(9,"Y","N","-",5),export_set(9,"Y","N"),export_set(9,"Y","N","");
export_set(9,"Y","N","-",5)	export_set(9,"Y","N")	export_set(9,"Y","N","")
Y-N-N-Y-N	Y,N,N,Y,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N	YNNYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN
select elt(2,1),field(NULL,"a","b","c");
elt(2,1)	field(NULL,"a","b","c")
NULL	0
select field("b","a",NULL),field(1,0,NULL)+0,field(1.0,0.0,NULL)+0.0,field(1.0e1,0.0e1,NULL)+0.0e1;
field("b","a",NULL)	field(1,0,NULL)+0	field(1.0,0.0,NULL)+0.0	field(1.0e1,0.0e1,NULL)+0.0e1
0	0	0.0	0
select field(NULL,"a",NULL),field(NULL,0,NULL)+0,field(NULL,0.0,NULL)+0.0,field(NULL,0.0e1,NULL)+0.0e1;
field(NULL,"a",NULL)	field(NULL,0,NULL)+0	field(NULL,0.0,NULL)+0.0	field(NULL,0.0e1,NULL)+0.0e1
0	0	0.0	0
select find_in_set("","a,b,c"),find_in_set("","a,b,c,"),find_in_set("",",a,b,c");
find_in_set("","a,b,c")	find_in_set("","a,b,c,")	find_in_set("",",a,b,c")
0	4	1
select find_in_set("abc","abc"),find_in_set("ab","abc"),find_in_set("abcd","abc");
find_in_set("abc","abc")	find_in_set("ab","abc")	find_in_set("abcd","abc")
1	0	0
select interval(null, 1, 10, 100);
interval(null, 1, 10, 100)
-1
drop table if exists t1,t2;
create  table t1 (id int(10) not null unique);
create  table t2 (id int(10) not null primary key, val int(10) not null);
insert into t1 values (1),(2),(4);
insert into t2 values (1,1),(2,1),(3,1),(4,2);
select one.id, elt(two.val,'one','two') from t1 one, t2 two where two.id=one.id;
id	elt(two.val,'one','two')
1	one
2	one
4	two
select one.id, elt(two.val,'one','two') from t1 one, t2 two where two.id=one.id order by one.id;
id	elt(two.val,'one','two')
1	one
2	one
4	two
drop table t1,t2;
select find_in_set(binary 'a',binary 'A,B,C');
find_in_set(binary 'a',binary 'A,B,C')
0
select find_in_set('a',binary 'A,B,C');
find_in_set('a',binary 'A,B,C')
0
select find_in_set(binary 'a', 'A,B,C');
find_in_set(binary 'a', 'A,B,C')
0
select find_in_set('1','3,1,');
find_in_set('1','3,1,')
2
End of 4.1 tests
SELECT INTERVAL(0.0, NULL);
INTERVAL(0.0, NULL)
1
SELECT INTERVAL(0.0, CAST(NULL AS DECIMAL));
INTERVAL(0.0, CAST(NULL AS DECIMAL))
1
SELECT INTERVAL(0.0, CAST(DATE(NULL) AS DECIMAL));
INTERVAL(0.0, CAST(DATE(NULL) AS DECIMAL))
1
SELECT INTERVAL(0.0, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL);
INTERVAL(0.0, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL)
8
SELECT INTERVAL(0.0, CAST(NULL AS DECIMAL), CAST(NULL AS DECIMAL), 
CAST(NULL AS DECIMAL), CAST(NULL AS DECIMAL), CAST(NULL AS DECIMAL), 
CAST(NULL AS DECIMAL), CAST(NULL AS DECIMAL), CAST(NULL AS DECIMAL));
INTERVAL(0.0, CAST(NULL AS DECIMAL), CAST(NULL AS DECIMAL), 
CAST(NULL AS DECIMAL), CAST(NULL AS DECIMAL), CAST(NULL AS DECIMAL), 
CAST(NULL AS DECIMAL), CAST(NULL AS DECIMAL), CAST(NULL AS DECIMAL))
8
SELECT INTERVAL(0.0, CAST(DATE(NULL) AS DECIMAL), CAST(DATE(NULL) AS DECIMAL),
CAST(DATE(NULL) AS DECIMAL), CAST(DATE(NULL) AS DECIMAL),
CAST(DATE(NULL) AS DECIMAL), CAST(DATE(NULL) AS DECIMAL),
CAST(DATE(NULL) AS DECIMAL), CAST(DATE(NULL) AS DECIMAL));
INTERVAL(0.0, CAST(DATE(NULL) AS DECIMAL), CAST(DATE(NULL) AS DECIMAL),
CAST(DATE(NULL) AS DECIMAL), CAST(DATE(NULL) AS DECIMAL),
CAST(DATE(NULL) AS DECIMAL), CAST(DATE(NULL) AS DECIMAL),
CAST(DATE(NULL) AS DECIMAL), CAST(DATE(NULL) AS DECIMAL))
8
End of 5.0 tests
drop table if exists t1;
create table t1 (f1 set('test1','test2','test3') character set utf8 default null)
engine=myisam default charset=latin1;
insert into t1 values (''),(null),(null),(''),(''),('');
select find_in_set(f1,f1) as a from t1,(select find_in_set(f1,f1) as b from t1) a;
a
0
NULL
NULL
0
0
0
0
NULL
NULL
0
0
0
0
NULL
NULL
0
0
0
0
NULL
NULL
0
0
0
0
NULL
NULL
0
0
0
0
NULL
NULL
0
0
0
drop table t1;
CREATE TABLE t1( a SET('a', 'b', 'c') );
CREATE TABLE t2( a SET('a', 'b', 'c') );
INSERT IGNORE INTO t1 VALUES ('d');
Warnings:
Warning	1265	Data truncated for column 'a' at row 1
INSERT INTO t2 VALUES ('');
SELECT CONVERT( a USING latin1 ) FROM t1;
CONVERT( a USING latin1 )

SELECT CONVERT( a USING latin1 ) FROM t2;
CONVERT( a USING latin1 )

DROP TABLE t1, t2;
#
# Start of 5.3 tests
#
#
# MDEV-4512 Valgrind warnings in my_long10_to_str_8bit on INTERVAL and DATE_ADD with incorrect types
#
CREATE TABLE t1 (pk INT PRIMARY KEY);
INSERT INTO t1 VALUES (10),(11);
SELECT INTERVAL( 9, 1, DATE_ADD( pk, INTERVAL pk MINUTE_SECOND ), 9, 8, 3, 5, 2, 1 ) FROM t1;
INTERVAL( 9, 1, DATE_ADD( pk, INTERVAL pk MINUTE_SECOND ), 9, 8, 3, 5, 2, 1 )
8
8
Warnings:
Warning	1292	Incorrect datetime value: '10' for column 'pk' at row 1
Warning	1292	Incorrect datetime value: '11' for column 'pk' at row 2
DROP TABLE t1;
#
# End of 5.3 tests
#
#
# BUG#59405: FIND_IN_SET won't work normaly after upgrade from 5.1 to 5.5
#
CREATE TABLE t1(days set('1','2','3','4','5','6','7'));
INSERT INTO t1 VALUES('1,2,3,4,5,6,7'), (NULL), ('1,2,3,4,5,6,7');

SELECT * FROM t1 WHERE FIND_IN_SET(DAYOFWEEK(CURRENT_DATE()), days);
days
1,2,3,4,5,6,7
1,2,3,4,5,6,7
SELECT * FROM t1 WHERE FIND_IN_SET(DAYOFWEEK(CURRENT_DATE()), days) IS UNKNOWN;
days
NULL
SELECT * FROM t1 WHERE FIND_IN_SET(DAYOFWEEK(CURRENT_DATE()), NULL);
days
SELECT * FROM t1 WHERE FIND_IN_SET(DAYOFWEEK(CURRENT_DATE()), NULL) IS UNKNOWN;
days
1,2,3,4,5,6,7
NULL
1,2,3,4,5,6,7
SELECT * FROM t1 WHERE FIND_IN_SET(7, days);
days
1,2,3,4,5,6,7
1,2,3,4,5,6,7
SELECT * FROM t1 WHERE FIND_IN_SET(8, days);
days
SELECT * FROM t1 WHERE FIND_IN_SET(NULL, days);
days
SELECT * FROM t1 WHERE FIND_IN_SET(NULL, days) IS UNKNOWN;
days
1,2,3,4,5,6,7
NULL
1,2,3,4,5,6,7
SELECT * FROM t1 WHERE FIND_IN_SET(NULL, NULL);
days
SELECT * FROM t1 WHERE FIND_IN_SET(NULL, NULL) IS UNKNOWN;
days
1,2,3,4,5,6,7
NULL
1,2,3,4,5,6,7

DROP TABLE t1;
#
# Start of 5.3 tests
#
#
# MDEV-4512 Valgrind warnings in my_long10_to_str_8bit on INTERVAL and DATE_ADD with incorrect types
#
CREATE TABLE t1 (pk INT PRIMARY KEY);
INSERT INTO t1 VALUES (10),(11);
SELECT INTERVAL( 9, 1, DATE_ADD( pk, INTERVAL pk MINUTE_SECOND ), 9, 8, 3, 5, 2, 1 ) FROM t1;
INTERVAL( 9, 1, DATE_ADD( pk, INTERVAL pk MINUTE_SECOND ), 9, 8, 3, 5, 2, 1 )
8
8
Warnings:
Warning	1292	Incorrect datetime value: '10' for column 'pk' at row 1
Warning	1292	Incorrect datetime value: '11' for column 'pk' at row 2
DROP TABLE t1;
#
# End of 5.3 tests
#