MySQL 5.6.14 Source Code Document
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
ctype_numconv.inc
1 --echo #
2 --echo # Start of WL#2649 Number-to-string conversions
3 --echo #
4 #
5 # Basic constants
6 #
7 select hex(concat(1));
8 create table t1 as select concat(1) as c1;
9 show create table t1;
10 select hex(c1) from t1;
11 drop table t1;
12 
13 select hex(concat(18446744073709551615));
14 create table t1 as select concat(18446744073709551615) as c1;
15 show create table t1;
16 select hex(c1) from t1;
17 drop table t1;
18 
19 select hex(concat(1.1));
20 create table t1 as select concat(1.1) as c1;
21 show create table t1;
22 select hex(c1) from t1;
23 drop table t1;
24 
25 
26 #
27 # Arithmetic operators
28 #
29 
30 select hex(concat('a', 1+2)), charset(concat(1+2));
31 create table t1 as select concat(1+2) as c1;
32 show create table t1;
33 drop table t1;
34 
35 select hex(concat(1-2));
36 create table t1 as select concat(1-2) as c1;
37 show create table t1;
38 drop table t1;
39 
40 select hex(concat(1*2));
41 create table t1 as select concat(1*2) as c1;
42 show create table t1;
43 drop table t1;
44 
45 select hex(concat(1/2));
46 create table t1 as select concat(1/2) as c1;
47 show create table t1;
48 drop table t1;
49 
50 select hex(concat(1 div 2));
51 create table t1 as select concat(1 div 2) as c1;
52 show create table t1;
53 drop table t1;
54 
55 select hex(concat(1 % 2));
56 create table t1 as select concat(1 % 2) as c1;
57 show create table t1;
58 drop table t1;
59 
60 select hex(concat(-1));
61 create table t1 as select concat(-1) as c1;
62 show create table t1;
63 drop table t1;
64 
65 select hex(concat(-(1+2)));
66 create table t1 as select concat(-(1+2)) as c1;
67 show create table t1;
68 drop table t1;
69 
70 
71 #
72 # Bit functions
73 #
74 
75 select hex(concat(1|2));
76 create table t1 as select concat(1|2) as c1;
77 show create table t1;
78 drop table t1;
79 
80 select hex(concat(1&2));
81 create table t1 as select concat(1&2) as c1;
82 show create table t1;
83 drop table t1;
84 
85 select hex(concat(bit_count(12)));
86 create table t1 as select concat(bit_count(12)) as c1;
87 show create table t1;
88 drop table t1;
89 
90 select hex(concat(2<<1));
91 create table t1 as select concat(2<<1) as c1;
92 show create table t1;
93 drop table t1;
94 
95 select hex(concat(2>>1));
96 create table t1 as select concat(2>>1) as c1;
97 show create table t1;
98 drop table t1;
99 
100 select hex(concat(~0));
101 create table t1 as select concat(~0) as c1;
102 show create table t1;
103 drop table t1;
104 
105 select hex(concat(3^2));
106 create table t1 as select concat(3^2) as c1;
107 show create table t1;
108 drop table t1;
109 
110 
111 
112 #
113 # Math functions
114 #
115 # Note, some tests use LEFT(func(),1) to avoid
116 # non-deterministic results on various platforms.
117 #
118 
119 select hex(concat(abs(-2)));
120 create table t1 as select concat(abs(-2)) as c1;
121 show create table t1;
122 drop table t1;
123 
124 select hex(left(concat(exp(2)),1));
125 create table t1 as select concat(exp(2)) as c1;
126 show create table t1;
127 drop table t1;
128 
129 select hex(left(concat(log(2)),1));
130 create table t1 as select concat(log(2)) as c1;
131 show create table t1;
132 drop table t1;
133 
134 select hex(left(concat(log2(2)),1));
135 create table t1 as select concat(log2(2)) as c1;
136 show create table t1;
137 drop table t1;
138 
139 select hex(left(concat(log10(2)),1));
140 create table t1 as select concat(log10(2)) as c1;
141 show create table t1;
142 drop table t1;
143 
144 select hex(left(concat(sqrt(2)),1));
145 create table t1 as select concat(sqrt(2)) as c1;
146 show create table t1;
147 drop table t1;
148 
149 select hex(left(concat(pow(2,2)),1));
150 create table t1 as select concat(pow(2,2)) as c1;
151 show create table t1;
152 drop table t1;
153 
154 select hex(left(concat(acos(0.5)),1));
155 create table t1 as select concat(acos(0.5)) as c1;
156 show create table t1;
157 drop table t1;
158 
159 select hex(left(concat(asin(0.5)),1));
160 create table t1 as select concat(asin(0.5)) as c1;
161 show create table t1;
162 drop table t1;
163 
164 select hex(left(concat(atan(0.5)),1));
165 create table t1 as select concat(atan(0.5)) as c1;
166 show create table t1;
167 drop table t1;
168 
169 select hex(left(concat(cos(0.5)),1));
170 create table t1 as select concat(cos(0.5)) as c1;
171 show create table t1;
172 drop table t1;
173 
174 select hex(left(concat(sin(0.5)),1));
175 create table t1 as select concat(sin(0.5)) as c1;
176 show create table t1;
177 drop table t1;
178 
179 select hex(left(concat(tan(0.5)),1));
180 create table t1 as select concat(tan(0.5)) as c1;
181 show create table t1;
182 drop table t1;
183 
184 select hex(concat(degrees(0)));
185 create table t1 as select concat(degrees(0)) as c1;
186 show create table t1;
187 drop table t1;
188 
189 select hex(concat(radians(0)));
190 create table t1 as select concat(radians(0)) as c1;
191 show create table t1;
192 drop table t1;
193 
194 select hex(concat(ceiling(0.5)));
195 create table t1 as select concat(ceiling(0.5)) as c1;
196 show create table t1;
197 drop table t1;
198 
199 select hex(concat(floor(0.5)));
200 create table t1 as select concat(floor(0.5)) as c1;
201 show create table t1;
202 drop table t1;
203 
204 select hex(concat(round(0.5)));
205 create table t1 as select concat(round(0.5)) as c1;
206 show create table t1;
207 drop table t1;
208 
209 select hex(concat(sign(0.5)));
210 create table t1 as select concat(sign(0.5)) as c1;
211 show create table t1;
212 drop table t1;
213 
214 create table t1 as select concat(rand()) as c1;
215 show create table t1;
216 drop table t1;
217 
218 
219 #
220 # String functions
221 #
222 
223 select hex(concat(length('a')));
224 create table t1 as select concat(length('a')) as c1;
225 show create table t1;
226 drop table t1;
227 
228 select hex(concat(char_length('a')));
229 create table t1 as select concat(char_length('a')) as c1;
230 show create table t1;
231 drop table t1;
232 
233 select hex(concat(bit_length('a')));
234 create table t1 as select concat(bit_length('a')) as c1;
235 show create table t1;
236 drop table t1;
237 
238 select hex(concat(coercibility('a')));
239 create table t1 as select concat(coercibility('a')) as c1;
240 show create table t1;
241 drop table t1;
242 
243 select hex(concat(locate('a','a')));
244 create table t1 as select concat(locate('a','a')) as c1;
245 show create table t1;
246 drop table t1;
247 
248 select hex(concat(field('c','a','b','c')));
249 create table t1 as select concat(field('c','a','b','c')) as c1;
250 show create table t1;
251 drop table t1;
252 
253 select hex(concat(ascii(61)));
254 create table t1 as select concat(ascii(61)) as c1;
255 show create table t1;
256 drop table t1;
257 
258 select hex(concat(ord(61)));
259 create table t1 as select concat(ord(61)) as c1;
260 show create table t1;
261 drop table t1;
262 
263 select hex(concat(find_in_set('b','a,b,c,d')));
264 create table t1 as select concat(find_in_set('b','a,b,c,d')) as c1;
265 show create table t1;
266 drop table t1;
267 
268 
269 #
270 # String hash functions
271 #
272 
273 select md5('a'), hex(md5('a'));
274 create table t1 as select md5('a') as c1;
275 show create table t1;
276 drop table t1;
277 
278 select old_password('a'), hex(old_password('a'));
279 create table t1 as select old_password('a') as c1;
280 show create table t1;
281 drop table t1;
282 
283 select password('a'), hex(password('a'));
284 create table t1 as select password('a') as c1;
285 show create table t1;
286 drop table t1;
287 
288 select sha('a'), hex(sha('a'));
289 create table t1 as select sha('a') as c1;
290 show create table t1;
291 drop table t1;
292 
293 select sha1('a'), hex(sha1('a'));
294 create table t1 as select sha1('a') as c1;
295 show create table t1;
296 drop table t1;
297 
298 #select sha2('a',224), hex(sha2('a',224));
299 #create table t1 as select sha2('a',224) as c1;
300 #show create table t1;
301 #drop table t1;
302 
303 
304 
305 #
306 # CAST
307 #
308 
309 select hex(concat(cast('-1' as signed)));
310 create table t1 as select concat(cast('-1' as signed)) as c1;
311 show create table t1;
312 drop table t1;
313 
314 select hex(concat(cast('1' as unsigned)));
315 create table t1 as select concat(cast('1' as unsigned)) as c1;
316 show create table t1;
317 drop table t1;
318 
319 select hex(concat(cast(1/2 as decimal(5,5))));
320 create table t1 as select concat(cast(1/2 as decimal(5,5))) as c1;
321 show create table t1;
322 drop table t1;
323 
324 select hex(concat(cast('2001-01-02 03:04:05' as date)));
325 create table t1 as select concat(cast('2001-01-02 03:04:05' as date)) as c1;
326 show create table t1;
327 select * from t1;
328 drop table t1;
329 
330 select hex(concat(cast('2001-01-02 03:04:05' as time)));
331 create table t1 as select concat(cast('2001-01-02 03:04:05' as time)) as c1;
332 show create table t1;
333 select * from t1;
334 drop table t1;
335 
336 select hex(concat(cast('2001-01-02' as datetime)));
337 create table t1 as select concat(cast('2001-01-02' as datetime)) as c1;
338 show create table t1;
339 select * from t1;
340 drop table t1;
341 
342 
343 #
344 # Aggregation: LEAST, GREATEST
345 #
346 select hex(concat(least(1,2)));
347 create table t1 as select concat(least(1,2)) as c1;
348 show create table t1;
349 drop table t1;
350 
351 select hex(concat(greatest(1,2)));
352 create table t1 as select concat(greatest(1,2)) as c1;
353 show create table t1;
354 drop table t1;
355 
356 
357 #
358 # Aggregation: CASE
359 #
360 select hex(concat(case when 11 then 22 else 33 end));
361 create table t1 as select concat(case when 11 then 22 else 33 end) as c1;
362 show create table t1;
363 drop table t1;
364 
365 
366 #
367 # Aggregation: COALESCE
368 #
369 select hex(concat(coalesce(1,2)));
370 create table t1 as select concat(coalesce(1,2)) as c1;
371 show create table t1;
372 drop table t1;
373 
374 
375 #
376 # Aggregation: CONCAT_WS, GROUP_CONCAT
377 #
378 select hex(concat_ws(1,2,3));
379 create table t1 as select concat_ws(1,2,3) as c1;
380 show create table t1;
381 drop table t1;
382 
383 select hex(group_concat(1,2,3));
384 create table t1 as select group_concat(1,2,3) as c1;
385 show create table t1;
386 drop table t1;
387 
388 #
389 # Aggregation: UNION
390 #
391 create table t1 as select 1 as c1 union select 'a';
392 show create table t1;
393 select hex(c1) from t1 order by c1;
394 drop table t1;
395 
396 
397 #
398 # Miscelaneous functions
399 #
400 
401 create table t1 as select concat(last_insert_id()) as c1;
402 show create table t1;
403 drop table t1;
404 
405 select hex(concat(benchmark(0,0)));
406 create table t1 as select concat(benchmark(0,0)) as c1;
407 show create table t1;
408 drop table t1;
409 
410 select hex(concat(sleep(0)));
411 create table t1 as select concat(sleep(0)) as c1;
412 show create table t1;
413 drop table t1;
414 
415 # Fails with "mtr --ps-protocol" for some reasons.
416 #select hex(concat(get_lock('a',0)));
417 #select hex(concat(release_lock('a')));
418 #create table t1 as select concat(get_lock('a',0)) as c1;
419 #show create table t1;
420 #drop table t1;
421 
422 select hex(concat(is_free_lock('xxxx')));
423 create table t1 as select concat(is_free_lock('xxxx')) as c1;
424 show create table t1;
425 drop table t1;
426 
427 create table t1 as select concat(is_used_lock('a')) as c1;
428 show create table t1;
429 drop table t1;
430 
431 create table t1 as select concat(release_lock('a')) as c1;
432 show create table t1;
433 drop table t1;
434 
435 select hex(concat(crc32('')));
436 create table t1 as select concat(crc32('')) as c1;
437 show create table t1;
438 drop table t1;
439 
440 select hex(concat(uncompressed_length('')));
441 create table t1 as select concat(uncompressed_length('')) as c1;
442 show create table t1;
443 drop table t1;
444 
445 create table t1 as select concat(connection_id()) as c1;
446 show create table t1;
447 drop table t1;
448 
449 select hex(concat(inet_aton('127.1.1.1')));
450 create table t1 as select concat(inet_aton('127.1.1.1')) as c1;
451 show create table t1;
452 drop table t1;
453 
454 select hex(concat(inet_ntoa(2130772225)));
455 create table t1 as select concat(inet_ntoa(2130772225)) as c1;
456 select * from t1;
457 show create table t1;
458 drop table t1;
459 
460 # Ensure that row_count() value is reset after drop table.
461 select 1;
462 select hex(concat(row_count()));
463 create table t1 as select concat(row_count()) as c1;
464 show create table t1;
465 drop table t1;
466 
467 select hex(concat(found_rows()));
468 create table t1 as select concat(found_rows()) as c1;
469 show create table t1;
470 drop table t1;
471 
472 create table t1 as select concat(uuid_short()) as c1;
473 show create table t1;
474 drop table t1;
475 
476 create table t1 as select concat(uuid()) as c1;
477 show create table t1;
478 drop table t1;
479 
480 #
481 # Make sure we can mix uuid() to a latin1 object
482 # with DERIVATION_IMPLICIT (and higher):
483 # (DERIVATION_COERCIBLE + MY_REPERTOIRE_ASCII allow to do so)
484 #
485 select coercibility(uuid()), coercibility(cast('a' as char character set latin1));
486 select charset(concat(uuid(), cast('a' as char character set latin1)));
487 create table t1 as select concat(uuid(), cast('a' as char character set latin1)) as c1;
488 show create table t1;
489 drop table t1;
490 
491 create table t1 as select concat(master_pos_wait('non-existent',0,2)) as c1;
492 show create table t1;
493 drop table t1;
494 
495 
496 #
497 # User and system variable functions
498 #
499 
500 # User variables: INT
501 select hex(concat(@a1:=1));
502 create table t1 as select concat(@a2:=2) as c1, @a3:=3 as c2;
503 select hex(c1) from t1;
504 show create table t1;
505 drop table t1;
506 
507 set @a2=1;
508 select hex(concat(@a2));
509 create table t1 as select concat(@a2) as c1, @a2 as c2;
510 select hex(c1) from t1;
511 show create table t1;
512 drop table t1;
513 
514 # User variables: REAL
515 select hex(concat(@a1:=sqrt(1)));
516 create table t1 as select concat(@a2:=sqrt(1)) as c1, @a3:=sqrt(1) as c2;
517 select hex(c1) from t1;
518 show create table t1;
519 drop table t1;
520 
521 set @a2=sqrt(1);
522 select hex(concat(@a2));
523 create table t1 as select concat(@a2) as c1, @a2 as c2;
524 select hex(c1) from t1;
525 show create table t1;
526 drop table t1;
527 
528 # User variables: DECIMAL
529 select hex(concat(@a1:=1.1));
530 create table t1 as select concat(@a2:=1.1) as c1, @a3:=1.1 as c2;
531 select hex(c1) from t1;
532 show create table t1;
533 drop table t1;
534 
535 set @a2=1.1;
536 select hex(concat(@a2));
537 create table t1 as select concat(@a2) as c1, @a2 as c2;
538 select hex(c1) from t1;
539 show create table t1;
540 drop table t1;
541 
542 
543 select hex(concat(@@ft_max_word_len));
544 create table t1 as select concat(@@ft_max_word_len) as c1;
545 select hex(c1) from t1;
546 show create table t1;
547 drop table t1;
548 
549 #
550 # Comparison functions
551 #
552 
553 select hex(concat('a'='a' IS TRUE));
554 create table t1 as select concat('a'='a' IS TRUE) as c1;
555 show create table t1;
556 drop table t1;
557 
558 select hex(concat('a'='a' IS NOT TRUE));
559 create table t1 as select concat('a'='a' IS NOT TRUE) as c1;
560 show create table t1;
561 drop table t1;
562 
563 select hex(concat(NOT 'a'='a'));
564 create table t1 as select concat(NOT 'a'='a') as c1;
565 show create table t1;
566 drop table t1;
567 
568 select hex(concat('a' IS NULL));
569 create table t1 as select concat('a' IS NULL) as c1;
570 show create table t1;
571 drop table t1;
572 
573 select hex(concat('a' IS NOT NULL));
574 create table t1 as select concat('a' IS NOT NULL) as c1;
575 show create table t1;
576 drop table t1;
577 
578 select hex(concat('a' rlike 'a'));
579 create table t1 as select concat('a' IS NOT NULL) as c1;
580 show create table t1;
581 drop table t1;
582 
583 select hex(concat(strcmp('a','b')));
584 create table t1 as select concat(strcmp('a','b')) as c1;
585 show create table t1;
586 drop table t1;
587 
588 select hex(concat('a' like 'a'));
589 create table t1 as select concat('a' like 'b') as c1;
590 show create table t1;
591 drop table t1;
592 
593 select hex(concat('a' between 'b' and 'c'));
594 create table t1 as select concat('a' between 'b' and 'c') as c1;
595 show create table t1;
596 drop table t1;
597 
598 select hex(concat('a' in ('a','b')));
599 create table t1 as select concat('a' in ('a','b')) as c1;
600 show create table t1;
601 drop table t1;
602 
603 select hex(concat(interval(23, 1, 15, 17, 30, 44, 200)));
604 create table t1 as select concat(interval(23, 1, 15, 17, 30, 44, 200)) as c1;
605 show create table t1;
606 drop table t1;
607 
608 create table t1 (a varchar(10), fulltext key(a));
609 insert into t1 values ('a');
610 select hex(concat(match (a) against ('a'))) from t1;
611 create table t2 as select concat(match (a) against ('a')) as a from t1;
612 show create table t2;
613 drop table t1, t2;
614 
615 select hex(ifnull(1,'a'));
616 create table t1 as select ifnull(1,'a') as c1;
617 show create table t1;
618 drop table t1;
619 
620 select hex(concat(ifnull(1,1)));
621 create table t1 as select concat(ifnull(1,1)) as c1;
622 show create table t1;
623 drop table t1;
624 
625 select hex(concat(ifnull(1.1,1.1)));
626 create table t1 as select concat(ifnull(1.1,1.1)) as c1;
627 show create table t1;
628 drop table t1;
629 
630 select hex(if(1,'b',1));
631 create table t1 as select if(1,'b',1) as c1;
632 show create table t1;
633 drop table t1;
634 
635 select hex(if(1,1,'b'));
636 create table t1 as select if(1,1,'b') as c1;
637 show create table t1;
638 drop table t1;
639 
640 select hex(concat(if(1,1,1)));
641 create table t1 as select concat(if(1,1,1)) as c1;
642 show create table t1;
643 drop table t1;
644 
645 select hex(concat(nullif(1,2)));
646 create table t1 as select concat(nullif(1,2)) as c1;
647 show create table t1;
648 drop table t1;
649 
650 #
651 # GIS functions
652 #
653 
654 select hex(concat(Dimension(GeomFromText('LINESTRING(0 0,10 10)'))));
655 create table t1 as select concat(Dimension(GeomFromText('LINSTRING(0 0,10 10)'))) as c1;
656 show create table t1;
657 drop table t1;
658 
659 select hex(concat(NumGeometries(MultiPointFromText('MULTIPOINT(0 0,10 10)'))));
660 create table t1 as select concat(NumGeometries(MultiPointFromText('MULTIPOINT(0 0,10 10)'))) as c1;
661 show create table t1;
662 drop table t1;
663 
664 select hex(concat(NumPoints(MultiPointFromText('LINESTRING(0 0,10 10)'))));
665 create table t1 as select concat(NumPoints(MultiPointFromText('LINESTRING(0 0,10 10)'))) as c1;
666 show create table t1;
667 drop table t1;
668 
669 select hex(concat(SRID(MultiPointFromText('MULTIPOINT(0 0,10 10)'))));
670 create table t1 as select concat(SRID(MultiPointFromText('MULTIPOINT(0 0,10 10)'))) as c1;
671 show create table t1;
672 drop table t1;
673 
674 select hex(concat(NumInteriorRings(PolygonFromText('POLYGON((0 0,50 0,50 50,0 50,0 0), (10 10,20 10,20 20,10 20,10 10))'))));
675 create table t1 as select concat(NumInteriorRings(PolygonFromText('POLYGON((0 0,50 0,50 50,0 50,0 0), (10 10,20 10,20 20,10 20,10 10))'))) as c1;
676 show create table t1;
677 drop table t1;
678 
679 select hex(concat(IsEmpty(GeomFromText('POINT(1 1)'))));
680 create table t1 as select concat(IsEmpty(GeomFromText('Point(1 1)'))) as c1;
681 show create table t1;
682 drop table t1;
683 
684 select hex(concat(IsSimple(GeomFromText('POINT(1 1)'))));
685 create table t1 as select concat(IsSimple(GeomFromText('Point(1 1)'))) as c1;
686 show create table t1;
687 drop table t1;
688 
689 select hex(concat(IsClosed(GeomFromText('LineString(1 1,2 2)'))));
690 create table t1 as select concat(IsClosed(GeomFromText('LineString(1 1,2 2)'))) as c1;
691 show create table t1;
692 drop table t1;
693 
694 select hex(concat(Equals(GeomFromText('Point(1 1)'),GeomFromText('Point(1 1)'))));
695 create table t1 as select concat(Equals(GeomFromText('Point(1 1)'),GeomFromText('Point(1 1)'))) as c1;
696 drop table t1;
697 
698 select hex(concat(x(GeomFromText('Point(1 2)'))));
699 create table t1 as select concat(x(GeomFromText('Point(1 2)'))) as c1;
700 show create table t1;
701 drop table t1;
702 
703 select hex(concat(y(GeomFromText('Point(1 2)'))));
704 create table t1 as select concat(x(GeomFromText('Point(1 2)'))) as c1;
705 show create table t1;
706 drop table t1;
707 
708 select hex(concat(GLength(GeomFromText('LineString(1 2,2 2)'))));
709 create table t1 as select concat(GLength(GeomFromText('LineString(1 2, 2 2)'))) as c1;
710 show create table t1;
711 drop table t1;
712 
713 select hex(concat(Area(GeomFromText('Polygon((0 0,1 0,1 1,0 1,0 0))'))));
714 create table t1 as select concat(Area(GeomFromText('Polygon((0 0,1 0,1 1,0 1,0 0))'))) as c1;
715 show create table t1;
716 drop table t1;
717 
718 select hex(concat(GeometryType(GeomFromText('Point(1 2)'))));
719 create table t1 as select concat(GeometryType(GeomFromText('Point(1 2)'))) as c1;
720 show create table t1;
721 drop table t1;
722 
723 select hex(concat(AsText(GeomFromText('Point(1 2)'))));
724 create table t1 as select concat(AsText(GeomFromText('Point(1 2)'))) as c1;
725 show create table t1;
726 drop table t1;
727 
728 
729 
730 #
731 # Date/Time functions
732 #
733 
734 select hex(concat(period_add(200902, 2)));
735 create table t1 as select concat(period_add(200902, 2)) as c1;
736 show create table t1;
737 drop table t1;
738 
739 select hex(concat(period_diff(200902, 200802)));
740 create table t1 as select concat(period_add(200902, 200802)) as c1;
741 show create table t1;
742 drop table t1;
743 
744 select hex(concat(to_days(20090224)));
745 create table t1 as select concat(to_days(20090224)) as c1;
746 show create table t1;
747 drop table t1;
748 
749 select hex(concat(dayofmonth(20090224)));
750 create table t1 as select concat(dayofmonth(20090224)) as c1;
751 show create table t1;
752 drop table t1;
753 
754 select hex(concat(dayofyear(20090224)));
755 create table t1 as select concat(dayofyear(20090224)) as c1;
756 show create table t1;
757 drop table t1;
758 
759 select hex(concat(hour('10:11:12')));
760 create table t1 as select concat(hour('10:11:12')) as c1;
761 show create table t1;
762 drop table t1;
763 
764 select hex(concat(minute('10:11:12')));
765 create table t1 as select concat(minute('10:11:12')) as c1;
766 show create table t1;
767 drop table t1;
768 
769 select hex(concat(second('10:11:12')));
770 create table t1 as select concat(second('10:11:12')) as c1;
771 show create table t1;
772 drop table t1;
773 
774 select hex(concat(quarter(20090224)));
775 create table t1 as select concat(quarter(20090224)) as c1;
776 show create table t1;
777 drop table t1;
778 
779 select hex(concat(week(20090224)));
780 create table t1 as select concat(week(20090224)) as c1;
781 show create table t1;
782 drop table t1;
783 
784 select hex(concat(yearweek(20090224)));
785 create table t1 as select concat(yearweek(20090224)) as c1;
786 show create table t1;
787 drop table t1;
788 
789 select hex(concat(year(20090224)));
790 create table t1 as select concat(year(20090224)) as c1;
791 show create table t1;
792 drop table t1;
793 
794 select hex(concat(weekday(20090224)));
795 create table t1 as select concat(weekday(20090224)) as c1;
796 show create table t1;
797 drop table t1;
798 
799 select hex(concat(dayofweek(20090224)));
800 create table t1 as select concat(dayofweek(20090224)) as c1;
801 show create table t1;
802 drop table t1;
803 
804 select hex(concat(unix_timestamp(20090224)));
805 create table t1 as select concat(unix_timestamp(20090224)) as c1;
806 show create table t1;
807 drop table t1;
808 
809 select hex(concat(time_to_sec('10:11:12')));
810 create table t1 as select concat(time_to_sec('10:11:12')) as c1;
811 show create table t1;
812 drop table t1;
813 
814 select hex(concat(extract(year from 20090702)));
815 create table t1 as select concat(extract(year from 20090702)) as c1;
816 show create table t1;
817 drop table t1;
818 
819 select hex(concat(microsecond('12:00:00.123456')));
820 create table t1 as select concat(microsecond('12:00:00.123456')) as c1;
821 show create table t1;
822 drop table t1;
823 
824 select hex(concat(month(20090224)));
825 create table t1 as select concat(month(20090224)) as c1;
826 show create table t1;
827 drop table t1;
828 
829 
830 create table t1 as select concat(last_day('2003-02-05')) as c1;
831 show create table t1;
832 select c1, hex(c1) from t1;
833 drop table t1;
834 
835 create table t1 as select concat(from_days(730669)) as c1;
836 show create table t1;
837 select c1, hex(c1) from t1;
838 drop table t1;
839 
840 create table t1 as select concat(curdate()) as c1;
841 show create table t1;
842 drop table t1;
843 
844 create table t1 as select concat(utc_date()) as c1;
845 show create table t1;
846 drop table t1;
847 
848 create table t1 as select concat(curtime()) as c1;
849 show create table t1;
850 drop table t1;
851 
852 create table t1 as select repeat('a',20) as c1 limit 0;
853 set timestamp=1216359724;
854 insert into t1 values (current_date);
855 insert into t1 values (current_time);
856 select c1, hex(c1) from t1;
857 drop table t1;
858 
859 create table t1 as select concat(utc_time()) as c1;
860 show create table t1;
861 drop table t1;
862 
863 select hex(concat(sec_to_time(2378)));
864 create table t1 as select concat(sec_to_time(2378)) as c1;
865 show create table t1;
866 drop table t1;
867 
868 select hex(concat(timediff('2001-01-02 00:00:00', '2001-01-01 00:00:00')));
869 create table t1 as select concat(timediff('2001-01-02 00:00:00', '2001-01-01 00:00:00')) as c1;
870 show create table t1;
871 drop table t1;
872 
873 select hex(concat(maketime(10,11,12)));
874 create table t1 as select concat(maketime(10,11,12)) as c1;
875 show create table t1;
876 drop table t1;
877 
878 select hex(get_format(DATE,'USA'));
879 create table t1 as select get_format(DATE,'USA') as c1;
880 show create table t1;
881 drop table t1;
882 
883 select hex(left(concat(from_unixtime(1111885200)),4));
884 create table t1 as select concat(from_unixtime(1111885200)) as c1;
885 show create table t1;
886 drop table t1;
887 
888 select hex(concat(convert_tz('2004-01-01 12:00:00','+10:00','-6:00')));
889 create table t1 as select concat(convert_tz('2004-01-01 12:00:00','+10:00','-6:00')) as c1;
890 show create table t1;
891 drop table t1;
892 
893 select hex(concat(date_add('2004-01-01 12:00:00', interval 1 day)));
894 create table t1 as select concat(date_add('2004-01-01 12:00:00', interval 1 day)) as c1;
895 show create table t1;
896 select * from t1;
897 drop table t1;
898 
899 select hex(concat(makedate(2009,1)));
900 create table t1 as select concat(makedate(2009,1)) as c1;
901 show create table t1;
902 select * from t1;
903 drop table t1;
904 
905 create table t1 as select concat(now()) as c1;
906 show create table t1;
907 drop table t1;
908 
909 create table t1 as select concat(utc_timestamp()) as c1;
910 show create table t1;
911 drop table t1;
912 
913 create table t1 as select concat(sysdate()) as c1;
914 show create table t1;
915 drop table t1;
916 
917 select hex(concat(addtime('00:00:00','11:22:33')));
918 create table t1 as select concat(addtime('00:00:00','11:22:33')) as c1;
919 show create table t1;
920 drop table t1;
921 
922 select hex(concat(subtime('23:59:59','11:22:33')));
923 create table t1 as select concat(subtime('23:59:59','11:22:33')) as c1;
924 show create table t1;
925 drop table t1;
926 
927 
928 #
929 # Other string functions with numeric input
930 #
931 select hex(elt(1,2,3));
932 create table t1 as select elt(1,2,3) as c1;
933 show create table t1;
934 drop table t1;
935 
936 select hex(export_set(1,2,3,4,2));
937 create table t1 as select export_set(1,2,3,4,2) as c1;
938 show create table t1;
939 drop table t1;
940 
941 select hex(insert(1133,3,0,22));
942 create table t1 as select insert(1133,3,0,22) as c1;
943 show create table t1;
944 drop table t1;
945 
946 select hex(lcase(123));
947 create table t1 as select lcase(123) as c1;
948 show create table t1;
949 drop table t1;
950 
951 select hex(left(123,1));
952 create table t1 as select left(123,1) as c1;
953 show create table t1;
954 drop table t1;
955 
956 select hex(lower(123));
957 create table t1 as select lower(123) as c1;
958 show create table t1;
959 drop table t1;
960 
961 select hex(lpad(1,2,0));
962 create table t1 as select lpad(1,2,0) as c1;
963 show create table t1;
964 drop table t1;
965 
966 select hex(ltrim(1));
967 create table t1 as select ltrim(1) as c1;
968 show create table t1;
969 drop table t1;
970 
971 select hex(mid(1,1,1));
972 create table t1 as select mid(1,1,1) as c1;
973 show create table t1;
974 drop table t1;
975 
976 select hex(repeat(1,2));
977 create table t1 as select repeat(1,2) as c1;
978 show create table t1;
979 drop table t1;
980 
981 select hex(replace(1,1,2));
982 create table t1 as select replace(1,1,2) as c1;
983 show create table t1;
984 drop table t1;
985 
986 select hex(reverse(12));
987 create table t1 as select reverse(12) as c1;
988 show create table t1;
989 drop table t1;
990 
991 select hex(right(123,1));
992 create table t1 as select right(123,1) as c1;
993 show create table t1;
994 drop table t1;
995 
996 select hex(rpad(1,2,0));
997 create table t1 as select rpad(1,2,0) as c1;
998 show create table t1;
999 drop table t1;
1000 
1001 select hex(rtrim(1));
1002 create table t1 as select rtrim(1) as c1;
1003 show create table t1;
1004 drop table t1;
1005 
1006 select hex(soundex(1));
1007 create table t1 as select soundex(1) as c1;
1008 show create table t1;
1009 drop table t1;
1010 
1011 select hex(substring(1,1,1));
1012 create table t1 as select substring(1,1,1) as c1;
1013 show create table t1;
1014 drop table t1;
1015 
1016 select hex(trim(1));
1017 create table t1 as select trim(1) as c1;
1018 show create table t1;
1019 drop table t1;
1020 
1021 select hex(ucase(1));
1022 create table t1 as select ucase(1) as c1;
1023 show create table t1;
1024 drop table t1;
1025 
1026 select hex(upper(1));
1027 create table t1 as select upper(1) as c1;
1028 show create table t1;
1029 drop table t1;
1030 
1031 
1032 #
1033 # Bug#8204
1034 #
1035 create table t1 as select repeat(' ', 64) as a limit 0;
1036 show create table t1;
1037 insert into t1 values ("1.1"), ("2.1");
1038 select a, hex(a) from t1;
1039 update t1 set a= a + 0.1;
1040 select a, hex(a) from t1;
1041 drop table t1;
1042 
1043 
1044 #
1045 # Columns
1046 #
1047 create table t1 (a tinyint);
1048 insert into t1 values (1);
1049 select hex(concat(a)) from t1;
1050 create table t2 as select concat(a) from t1;
1051 show create table t2;
1052 drop table t1, t2;
1053 
1054 create table t1 (a tinyint zerofill);
1055 insert into t1 values (1), (10), (100);
1056 select hex(concat(a)), a from t1;
1057 drop table t1;
1058 
1059 create table t1 (a tinyint(4) zerofill);
1060 insert into t1 values (1), (10), (100);
1061 select hex(concat(a)), a from t1;
1062 drop table t1;
1063 
1064 create table t1 (a decimal(10,2));
1065 insert into t1 values (123.45);
1066 select hex(concat(a)) from t1;
1067 create table t2 as select concat(a) from t1;
1068 show create table t2;
1069 drop table t1, t2;
1070 
1071 create table t1 (a smallint);
1072 insert into t1 values (1);
1073 select hex(concat(a)) from t1;
1074 create table t2 as select concat(a) from t1;
1075 show create table t2;
1076 drop table t1, t2;
1077 
1078 create table t1 (a smallint zerofill);
1079 insert into t1 values (1), (10), (100), (1000), (10000);
1080 select hex(concat(a)), a from t1;
1081 drop table t1;
1082 
1083 create table t1 (a mediumint);
1084 insert into t1 values (1);
1085 select hex(concat(a)) from t1;
1086 create table t2 as select concat(a) from t1;
1087 show create table t2;
1088 drop table t1, t2;
1089 
1090 create table t1 (a mediumint zerofill);
1091 insert into t1 values (1), (10), (100), (1000), (10000);
1092 select hex(concat(a)), a from t1;
1093 drop table t1;
1094 
1095 create table t1 (a int);
1096 insert into t1 values (1);
1097 select hex(concat(a)) from t1;
1098 create table t2 as select concat(a) from t1;
1099 show create table t2;
1100 drop table t1, t2;
1101 
1102 create table t1 (a int zerofill);
1103 insert into t1 values (1), (10), (100), (1000), (10000);
1104 select hex(concat(a)), a from t1;
1105 drop table t1;
1106 
1107 create table t1 (a bigint);
1108 insert into t1 values (1);
1109 select hex(concat(a)) from t1;
1110 create table t2 as select concat(a) from t1;
1111 show create table t2;
1112 drop table t1, t2;
1113 
1114 create table t1 (a bigint zerofill);
1115 insert into t1 values (1), (10), (100), (1000), (10000);
1116 select hex(concat(a)), a from t1;
1117 drop table t1;
1118 
1119 create table t1 (a float);
1120 insert into t1 values (123.456);
1121 select hex(concat(a)) from t1;
1122 select concat(a) from t1;
1123 create table t2 as select concat(a) from t1;
1124 show create table t2;
1125 drop table t1, t2;
1126 
1127 create table t1 (a float zerofill);
1128 insert into t1 values (1.1), (10.1), (100.1), (1000.1), (10000.1);
1129 select hex(concat(a)), a from t1;
1130 drop table t1;
1131 
1132 create table t1 (a double);
1133 insert into t1 values (123.456);
1134 select hex(concat(a)) from t1;
1135 select concat(a) from t1;
1136 create table t2 as select concat(a) from t1;
1137 show create table t2;
1138 drop table t1, t2;
1139 
1140 create table t1 (a double zerofill);
1141 insert into t1 values (1.1), (10.1), (100.1), (1000.1), (10000.1);
1142 select hex(concat(a)), a from t1;
1143 drop table t1;
1144 
1145 create table t1 (a year(2));
1146 insert into t1 values (1);
1147 select hex(concat(a)) from t1;
1148 create table t2 as select concat(a) from t1;
1149 show create table t2;
1150 drop table t1, t2;
1151 
1152 create table t1 (a year);
1153 insert into t1 values (1);
1154 select hex(concat(a)) from t1;
1155 create table t2 as select concat(a) from t1;
1156 show create table t2;
1157 drop table t1, t2;
1158 
1159 create table t1 (a bit(64));
1160 # BIT is always BINARY
1161 insert into t1 values (1);
1162 select hex(concat(a)) from t1;
1163 create table t2 as select concat(a) from t1;
1164 show create table t2;
1165 drop table t1, t2;
1166 
1167 create table t1 (a timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP);
1168 insert into t1 values (0);
1169 insert into t1 values (20010203040506);
1170 insert into t1 values (19800203040506);
1171 insert into t1 values ('2001-02-03 04:05:06');
1172 select hex(concat(a)) from t1;
1173 select concat(a) from t1;
1174 create table t2 as select concat(a) from t1;
1175 show create table t2;
1176 drop table t1, t2;
1177 
1178 create table t1 (a date);
1179 insert into t1 values ('2001-02-03');
1180 insert into t1 values (20010203);
1181 select hex(concat(a)) from t1;
1182 create table t2 as select concat(a) from t1;
1183 show create table t2;
1184 drop table t1, t2;
1185 
1186 create table t1 (a time);
1187 insert into t1 values (1);
1188 insert into t1 values ('01:02:03');
1189 select hex(concat(a)) from t1;
1190 select concat(a) from t1;
1191 create table t2 as select concat(a) from t1;
1192 show create table t2;
1193 drop table t1, t2;
1194 
1195 create table t1 (a datetime);
1196 insert into t1 values ('2001-02-03 04:05:06');
1197 insert into t1 values (20010203040506);
1198 select hex(concat(a)) from t1;
1199 create table t2 as select concat(a) from t1;
1200 show create table t2;
1201 drop table t1, t2;
1202 
1203 
1204 #
1205 # create view with string functions with numeric input
1206 #
1207 # Switched off in ucs tests due to bug#50716
1208 if ($not_ucs)
1209 {
1210 create view v1 as select concat(1,2,3) as c1;
1211 show columns from v1;
1212 select hex(c1) from v1;
1213 drop view v1;
1214 
1215 create view v1 as select concat_ws(',',1,2,3) as c1;
1216 show columns from v1;
1217 select hex(c1) from v1;
1218 drop view v1;
1219 
1220 create view v1 as select elt(1,2,3) as c1;
1221 show columns from v1;
1222 select hex(c1) from v1;
1223 drop view v1;
1224 
1225 create view v1 as select export_set(1,2,3,4,2) as c1;
1226 show columns from v1;
1227 select hex(c1) from v1;
1228 drop view v1;
1229 
1230 create view v1 as select insert(1133,3,0,22) as c1;
1231 show columns from v1;
1232 select hex(c1) from v1;
1233 drop view v1;
1234 
1235 create view v1 as select lcase(123) as c1;
1236 show columns from v1;
1237 select hex(c1) from v1;
1238 drop view v1;
1239 
1240 create view v1 as select left(123,1) as c1;
1241 show columns from v1;
1242 select hex(c1) from v1;
1243 drop view v1;
1244 
1245 create view v1 as select lower(123) as c1;
1246 show columns from v1;
1247 select hex(c1) from v1;
1248 drop view v1;
1249 
1250 create view v1 as select lpad(1,2,0) as c1;
1251 show columns from v1;
1252 select hex(c1) from v1;
1253 drop view v1;
1254 
1255 create view v1 as select ltrim(1) as c1;
1256 show columns from v1;
1257 select hex(c1) from v1;
1258 drop view v1;
1259 
1260 create view v1 as select mid(1,1,1) as c1;
1261 show columns from v1;
1262 select hex(c1) from v1;
1263 drop view v1;
1264 
1265 create view v1 as select repeat(1,2) as c1;
1266 show columns from v1;
1267 select hex(c1) from v1;
1268 drop view v1;
1269 
1270 create view v1 as select replace(1,1,2) as c1;
1271 show columns from v1;
1272 select hex(c1) from v1;
1273 drop view v1;
1274 
1275 create view v1 as select reverse(12) as c1;
1276 show columns from v1;
1277 select hex(c1) from v1;
1278 drop view v1;
1279 
1280 create view v1 as select right(123,1) as c1;
1281 show columns from v1;
1282 select hex(c1) from v1;
1283 drop view v1;
1284 
1285 create view v1 as select rpad(1,2,0) as c1;
1286 show columns from v1;
1287 select hex(c1) from v1;
1288 drop view v1;
1289 
1290 create view v1 as select rtrim(1) as c1;
1291 show columns from v1;
1292 select hex(c1) from v1;
1293 drop view v1;
1294 
1295 create view v1 as select soundex(1) as c1;
1296 show columns from v1;
1297 select hex(c1) from v1;
1298 drop view v1;
1299 
1300 create view v1 as select substring(1,1,1) as c1;
1301 show columns from v1;
1302 select hex(c1) from v1;
1303 drop view v1;
1304 
1305 create view v1 as select trim(1) as c1;
1306 show columns from v1;
1307 select hex(c1) from v1;
1308 drop view v1;
1309 
1310 create view v1 as select ucase(1) as c1;
1311 show columns from v1;
1312 select hex(c1) from v1;
1313 drop view v1;
1314 
1315 create view v1 as select upper(1) as c1;
1316 show columns from v1;
1317 select hex(c1) from v1;
1318 drop view v1;
1319 }
1320 
1321 
1322 #
1323 # Views from tables with numeric columns
1324 #
1325 create table t1 (a tinyint);
1326 insert into t1 values (1);
1327 create view v1(a) as select concat(a) from t1;
1328 show columns from v1;
1329 select hex(a) from v1;
1330 drop table t1;
1331 drop view v1;
1332 
1333 create table t1 (a tinyint zerofill);
1334 insert into t1 values (1), (10), (100);
1335 create view v1(a) as select concat(a) from t1;
1336 show columns from v1;
1337 select hex(a) from v1;
1338 drop table t1;
1339 drop view v1;
1340 
1341 create table t1 (a tinyint(30) zerofill);
1342 insert into t1 values (1), (10), (100);
1343 create view v1(a) as select concat(a) from t1;
1344 show columns from v1;
1345 select hex(a) from v1;
1346 drop table t1;
1347 drop view v1;
1348 
1349 create table t1 (a decimal(10,2));
1350 insert into t1 values (123.45);
1351 create view v1(a) as select concat(a) from t1;
1352 show columns from v1;
1353 select hex(a) from v1;
1354 drop table t1;
1355 drop view v1;
1356 
1357 create table t1 (a smallint);
1358 insert into t1 values (1);
1359 create view v1(a) as select concat(a) from t1;
1360 show columns from v1;
1361 select hex(a) from v1;
1362 drop table t1;
1363 drop view v1;
1364 
1365 create table t1 (a smallint zerofill);
1366 insert into t1 values (1), (10), (100), (1000), (10000);
1367 create view v1(a) as select concat(a) from t1;
1368 show columns from v1;
1369 select hex(a) from v1;
1370 drop table t1;
1371 drop view v1;
1372 
1373 create table t1 (a mediumint);
1374 insert into t1 values (1);
1375 create view v1(a) as select concat(a) from t1;
1376 show columns from v1;
1377 select hex(a) from v1;
1378 drop table t1;
1379 drop view v1;
1380 
1381 create table t1 (a mediumint zerofill);
1382 insert into t1 values (1), (10), (100), (1000), (10000);
1383 create view v1(a) as select concat(a) from t1;
1384 show columns from v1;
1385 select hex(a) from v1;
1386 drop table t1;
1387 drop view v1;
1388 
1389 create table t1 (a int);
1390 insert into t1 values (1);
1391 create view v1(a) as select concat(a) from t1;
1392 show columns from v1;
1393 select hex(a) from v1;
1394 drop table t1;
1395 drop view v1;
1396 
1397 create table t1 (a int zerofill);
1398 insert into t1 values (1), (10), (100), (1000), (10000);
1399 create view v1(a) as select concat(a) from t1;
1400 show columns from v1;
1401 select hex(a) from v1;
1402 drop table t1;
1403 drop view v1;
1404 
1405 create table t1 (a bigint);
1406 insert into t1 values (1);
1407 create view v1(a) as select concat(a) from t1;
1408 show columns from v1;
1409 select hex(a) from v1;
1410 drop table t1;
1411 drop view v1;
1412 
1413 create table t1 (a bigint zerofill);
1414 insert into t1 values (1), (10), (100), (1000), (10000);
1415 create view v1(a) as select concat(a) from t1;
1416 show columns from v1;
1417 select hex(a) from v1;
1418 drop table t1;
1419 drop view v1;
1420 
1421 create table t1 (a float);
1422 insert into t1 values (123.456);
1423 create view v1(a) as select concat(a) from t1;
1424 show columns from v1;
1425 select hex(a) from v1;
1426 drop table t1;
1427 drop view v1;
1428 
1429 create table t1 (a float zerofill);
1430 insert into t1 values (1.1), (10.1), (100.1), (1000.1), (10000.1);
1431 create view v1(a) as select concat(a) from t1;
1432 show columns from v1;
1433 select hex(a) from v1;
1434 drop table t1;
1435 drop view v1;
1436 
1437 create table t1 (a double);
1438 insert into t1 values (123.456);
1439 select concat(a) from t1;
1440 create view v1(a) as select concat(a) from t1;
1441 show columns from v1;
1442 select hex(a) from v1;
1443 drop table t1;
1444 drop view v1;
1445 
1446 create table t1 (a double zerofill);
1447 insert into t1 values (1.1), (10.1), (100.1), (1000.1), (10000.1);
1448 create view v1(a) as select concat(a) from t1;
1449 show columns from v1;
1450 select hex(a) from v1;
1451 drop table t1;
1452 drop view v1;
1453 
1454 create table t1 (a year(2));
1455 insert into t1 values (1);
1456 create view v1(a) as select concat(a) from t1;
1457 show columns from v1;
1458 select hex(a) from v1;
1459 drop table t1;
1460 drop view v1;
1461 
1462 create table t1 (a year);
1463 insert into t1 values (1);
1464 create view v1(a) as select concat(a) from t1;
1465 show columns from v1;
1466 select hex(a) from v1;
1467 drop table t1;
1468 drop view v1;
1469 
1470 create table t1 (a bit(64));
1471 # BIT is always BINARY
1472 insert into t1 values (1);
1473 create view v1(a) as select concat(a) from t1;
1474 show columns from v1;
1475 select hex(a) from v1;
1476 drop table t1;
1477 drop view v1;
1478 
1479 create table t1 (a timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP);
1480 insert into t1 values (0);
1481 insert into t1 values (20010203040506);
1482 insert into t1 values (19800203040506);
1483 insert into t1 values ('2001-02-03 04:05:06');
1484 create view v1(a) as select concat(a) from t1;
1485 show columns from v1;
1486 select hex(a) from v1;
1487 drop table t1;
1488 drop view v1;
1489 
1490 create table t1 (a date);
1491 insert into t1 values ('2001-02-03');
1492 insert into t1 values (20010203);
1493 create view v1(a) as select concat(a) from t1;
1494 show columns from v1;
1495 select hex(a) from v1;
1496 drop table t1;
1497 drop view v1;
1498 
1499 create table t1 (a time);
1500 insert into t1 values (1);
1501 insert into t1 values ('01:02:03');
1502 create view v1(a) as select concat(a) from t1;
1503 show columns from v1;
1504 select hex(a) from v1;
1505 drop table t1;
1506 drop view v1;
1507 
1508 create table t1 (a datetime);
1509 insert into t1 values ('2001-02-03 04:05:06');
1510 insert into t1 values (20010203040506);
1511 create view v1(a) as select concat(a) from t1;
1512 show columns from v1;
1513 select hex(a) from v1;
1514 drop table t1;
1515 drop view v1;
1516 
1517 #
1518 # User defined function returning numeric result
1519 #
1520 delimiter |;
1521 create function f1 (par1 int) returns int
1522 begin
1523 return concat(par1);
1524 end|
1525 delimiter ;|
1526 
1527 set @a= f1(1);
1528 select hex(@a);
1529 select hex(concat(f1(1)));
1530 create table t1 as select f1(1) as c1;
1531 show create table t1;
1532 drop table t1;
1533 create table t1 as select concat(f1(1)) as c1;
1534 show create table t1;
1535 create view v1 as select concat(f1(1)) as c1;
1536 show columns from v1;
1537 drop table t1;
1538 drop view v1;
1539 drop function f1;
1540 
1541 delimiter |;
1542 create function f1 (par1 decimal(18,2)) returns decimal(18,2)
1543 begin
1544 return concat(par1);
1545 end|
1546 delimiter ;|
1547 
1548 set @a= f1(123.45);
1549 select hex(@a);
1550 select hex(concat(f1(123.45)));
1551 create table t1 as select f1(123.45) as c1;
1552 show create table t1;
1553 drop table t1;
1554 create table t1 as select concat(f1(123.45)) as c1;
1555 show create table t1;
1556 create view v1 as select concat(f1(123.45)) as c1;
1557 show columns from v1;
1558 drop table t1;
1559 drop view v1;
1560 drop function f1;
1561 
1562 delimiter |;
1563 create function f1 (par1 float) returns float
1564 begin
1565 return concat(par1);
1566 end|
1567 delimiter ;|
1568 
1569 set @a= f1(123.45);
1570 select hex(@a);
1571 select hex(concat(f1(123.45)));
1572 create table t1 as select f1(123.45) as c1;
1573 show create table t1;
1574 drop table t1;
1575 create table t1 as select concat(f1(123.45)) as c1;
1576 show create table t1;
1577 create view v1 as select concat(f1(123.45)) as c1;
1578 show columns from v1;
1579 drop table t1;
1580 drop view v1;
1581 drop function f1;
1582 
1583 delimiter |;
1584 create function f1 (par1 date) returns date
1585 begin
1586 return concat(par1);
1587 end|
1588 delimiter ;|
1589 
1590 set @a= f1(cast('2001-01-02' as date));
1591 select hex(@a);
1592 select hex(concat(f1(cast('2001-01-02' as date))));
1593 create table t1 as select f1(cast('2001-01-02' as date)) as c1;
1594 show create table t1;
1595 drop table t1;
1596 create table t1 as select concat(f1(cast('2001-01-02' as date))) as c1;
1597 show create table t1;
1598 create view v1 as select concat(f1(cast('2001-01-02' as date))) as c1;
1599 show columns from v1;
1600 drop table t1;
1601 drop view v1;
1602 drop function f1;
1603 
1604 
1605 --echo #
1606 --echo # End of WL#2649 Number-to-string conversions
1607 --echo #
1608 
1609 --echo #
1610 --echo # Bug#54668 User variable assignments get wrong type
1611 --echo #
1612 SET @x=md5('a');
1613 SELECT charset(@x), collation(@x);
1614 SET @x=old_password('a');
1615 SELECT charset(@x), collation(@x);
1616 SET @x=password('a');
1617 SELECT charset(@x), collation(@x);
1618 SET @x=sha('a');
1619 SELECT charset(@x), collation(@x);
1620 SET @x=sha1('a');
1621 SELECT charset(@x), collation(@x);
1622 SET @x=astext(point(1,2));
1623 SELECT charset(@x), collation(@x);
1624 SET @x=aswkt(point(1,2));
1625 SELECT charset(@x), collation(@x);
1626 
1627 
1628 --echo #
1629 --echo # Bug#54916 GROUP_CONCAT + IFNULL truncates output
1630 --echo #
1631 SELECT @@collation_connection;
1632 # ENGINE=MYISAM is very important to make sure "SYSTEM" join type
1633 # is in use, which will create instances of Item_copy.
1634 CREATE TABLE t1 (a MEDIUMINT NULL) ENGINE=MYISAM;
1635 INSERT INTO t1 VALUES (1234567);
1636 SELECT GROUP_CONCAT(IFNULL(a,'')) FROM t1;
1637 SELECT GROUP_CONCAT(IF(a,a,'')) FROM t1;
1638 SELECT GROUP_CONCAT(CASE WHEN a THEN a ELSE '' END) FROM t1;
1639 --enable_metadata
1640 SELECT COALESCE(a,'') FROM t1 GROUP BY 1;
1641 --disable_metadata
1642 --echo # All columns must be VARCHAR(9) with the same length:
1643 --disable_warnings
1644 CREATE TABLE t2 AS
1645 SELECT
1646  CONCAT(a),
1647  IFNULL(a,''),
1648  IF(a,a,''),
1649  CASE WHEN a THEN a ELSE '' END,
1650  COALESCE(a,'')
1651 FROM t1;
1652 --enable_warnings
1653 # The above query is expected to send a warning
1654 # in case of ucs2 character set, until Bug#55744 is fixed.
1655 SHOW CREATE TABLE t2;
1656 DROP TABLE t2;
1657 
1658 CREATE TABLE t2 AS SELECT CONCAT_WS(1,2,3) FROM t1;
1659 SHOW CREATE TABLE t2;
1660 DROP TABLE t2;
1661 
1662 CREATE TABLE t2 AS SELECT INSERT(1133,3,0,22) FROM t1;
1663 SHOW CREATE TABLE t2;
1664 DROP TABLE t2;
1665 
1666 CREATE TABLE t2 AS SELECT LCASE(a) FROM t1;
1667 SHOW CREATE TABLE t2;
1668 DROP TABLE t2;
1669 
1670 CREATE TABLE t2 AS SELECT UCASE(a) FROM t1;
1671 SHOW CREATE TABLE t2;
1672 DROP TABLE t2;
1673 
1674 CREATE TABLE t2 AS SELECT REPEAT(1,2) FROM t1;
1675 SHOW CREATE TABLE t2;
1676 DROP TABLE t2;
1677 
1678 CREATE TABLE t2 AS SELECT LEFT(123,2) FROM t1;
1679 SHOW CREATE TABLE t2;
1680 DROP TABLE t2;
1681 
1682 CREATE TABLE t2 AS SELECT RIGHT(123,2) FROM t1;
1683 SHOW CREATE TABLE t2;
1684 DROP TABLE t2;
1685 
1686 CREATE TABLE t2 AS SELECT LTRIM(123) FROM t1;
1687 SHOW CREATE TABLE t2;
1688 DROP TABLE t2;
1689 
1690 CREATE TABLE t2 AS SELECT RTRIM(123) FROM t1;
1691 SHOW CREATE TABLE t2;
1692 DROP TABLE t2;
1693 
1694 CREATE TABLE t2 AS SELECT ELT(1,111,222,333) FROM t1;
1695 SHOW CREATE TABLE t2;
1696 DROP TABLE t2;
1697 
1698 CREATE TABLE t2 AS SELECT REPLACE(111,2,3) FROM t1;
1699 SHOW CREATE TABLE t2;
1700 DROP TABLE t2;
1701 
1702 CREATE TABLE t2 AS SELECT SUBSTRING_INDEX(111,111,1) FROM t1;
1703 SHOW CREATE TABLE t2;
1704 DROP TABLE t2;
1705 
1706 CREATE TABLE t2 AS SELECT MAKE_SET(111,222,3) FROM t1;
1707 SHOW CREATE TABLE t2;
1708 DROP TABLE t2;
1709 
1710 CREATE TABLE t2 AS SELECT SOUNDEX(1) FROM t1;
1711 SHOW CREATE TABLE t2;
1712 DROP TABLE t2;
1713 
1714 CREATE TABLE t2 AS SELECT EXPORT_SET(1,'Y','N','',8);
1715 SHOW CREATE TABLE t2;
1716 DROP TABLE t2;
1717 
1718 DROP TABLE t1;
1719 
1720 --echo #
1721 --echo # End of Bug#54916
1722 --echo #
1723 
1724 --echo #
1725 --echo # WL#5510 Functions to_base64 and from_base64
1726 --echo #
1727 CREATE TABLE t1 AS SELECT TO_BASE64('test') AS to_base64;
1728 SHOW CREATE TABLE t1;
1729 SELECT to_base64, LENGTH(to_base64), HEX(to_base64) FROM t1;
1730 CREATE TABLE t2 AS SELECT FROM_BASE64(to_base64) AS from_base64 FROM t1;
1731 SHOW CREATE TABLE t2;
1732 SELECT CAST(from_base64 AS CHAR), LENGTH(from_base64), HEX(from_base64) FROM t2;
1733 DROP TABLE t2;
1734 DROP TABLE t1;
1735 
1736 
1737 --echo #
1738 --echo # Bug#58190 BETWEEN no longer uses indexes for date or datetime fields
1739 --echo #
1740 SELECT @@collation_connection;
1741 CREATE TABLE t1 (
1742  id INT(11) DEFAULT NULL,
1743  date_column DATE DEFAULT NULL,
1744  KEY(date_column));
1745 INSERT INTO t1 VALUES (1,'2010-09-01'),(2,'2010-10-01');
1746 EXPLAIN SELECT * FROM t1 WHERE date_column BETWEEN '2010-09-01' AND '2010-10-01';
1747 ALTER TABLE t1 MODIFY date_column DATETIME DEFAULT NULL;
1748 EXPLAIN SELECT * FROM t1 WHERE date_column BETWEEN '2010-09-01' AND '2010-10-01';
1749 DROP TABLE t1;
1750 
1751 
1752 --echo #
1753 --echo # Bug #31384 DATE_ADD() and DATE_SUB() return binary data
1754 --echo #
1755 SELECT @@collation_connection, @@character_set_results;
1756 CREATE TABLE t1 AS
1757 SELECT
1758  DATE_SUB('2007-08-03', INTERVAL 1 MINUTE) AS field_str1,
1759  DATE_SUB('2007-08-03 17:33:00', INTERVAL 1 MINUTE) AS field1_str2,
1760  DATE_SUB(DATE('2007-08-03'), INTERVAL 1 DAY) AS field_date,
1761  DATE_SUB(CAST('2007-08-03 17:33:00' AS DATETIME), INTERVAL 1 MINUTE) AS field_datetime;
1762 SHOW CREATE TABLE t1;
1763 DROP TABLE t1;
1764 --enable_metadata
1765 # PS protocol gives different "Max length" value for DATETIME.
1766 --disable_ps_protocol
1767 SELECT
1768  DATE_SUB('2007-08-03', INTERVAL 1 DAY) AS field_str1,
1769  DATE_SUB('2007-08-03 17:33:00', INTERVAL 1 MINUTE) AS field1_str2,
1770  DATE_SUB(DATE('2007-08-03'), INTERVAL 1 DAY) AS field_date,
1771  DATE_SUB(CAST('2007-08-03 17:33:00' AS DATETIME), INTERVAL 1 MINUTE) AS field_datetime;
1772 --disable_metadata
1773 --enable_ps_protocol
1774 SELECT
1775  HEX(DATE_SUB('2007-08-03', INTERVAL 1 MINUTE)) AS field_str1,
1776  HEX(DATE_SUB('2007-08-03 17:33:00', INTERVAL 1 MINUTE)) AS field1_str2,
1777  HEX(DATE_SUB(DATE('2007-08-03'), INTERVAL 1 DAY)) AS field_date,
1778  HEX(DATE_SUB(CAST('2007-08-03 17:33:00' AS DATETIME), INTERVAL 1 MINUTE)) AS field_datetime;
1779 
1780 --echo #
1781 --echo # Bug#11926811 / Bug#60625 Illegal mix of collations
1782 --echo #
1783 SELECT @@collation_connection;
1784 DELIMITER //;
1785 CREATE PROCEDURE p1()
1786 BEGIN
1787  DECLARE v_LastPaymentDate DATETIME DEFAULT NULL;
1788  SELECT v_LastPaymentDate < NOW();
1789  EXPLAIN EXTENDED SELECT v_LastPaymentDate < NOW();
1790  SHOW WARNINGS;
1791  EXPLAIN EXTENDED SELECT CONCAT(v_LastPaymentDate, NOW());
1792 END//
1793 DELIMITER ;//
1794 CALL p1;
1795 DROP PROCEDURE p1;
1796 
1797 --echo #
1798 --echo # Bug#52159 returning time type from function and empty left join causes debug assertion
1799 --echo #
1800 CREATE FUNCTION f1() RETURNS TIME RETURN 1;
1801 CREATE TABLE t1 (b INT);
1802 INSERT INTO t1 VALUES (0);
1803 SELECT f1() FROM t1 LEFT JOIN (SELECT 1 AS a FROM t1 LIMIT 0) AS d ON 1 GROUP BY a;
1804 DROP FUNCTION f1;
1805 DROP TABLE t1;
1806 
1807 SET NAMES latin1;
1808 SET sql_mode='';
1809 CREATE TABLE t1(a char(215) CHARACTER SET utf8 NOT NULL DEFAULT '', KEY(a));
1810 INSERT INTO t1 VALUES ();
1811 --disable_warnings
1812 SELECT maketime(`a`,`a`,`a`) FROM t1 GROUP BY 1;
1813 --enable_warnings
1814 DROP TABLE t1;
1815 SET sql_mode=default;