File: cast.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 (2294 lines) | stat: -rw-r--r-- 109,131 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
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428
1429
1430
1431
1432
1433
1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
1448
1449
1450
1451
1452
1453
1454
1455
1456
1457
1458
1459
1460
1461
1462
1463
1464
1465
1466
1467
1468
1469
1470
1471
1472
1473
1474
1475
1476
1477
1478
1479
1480
1481
1482
1483
1484
1485
1486
1487
1488
1489
1490
1491
1492
1493
1494
1495
1496
1497
1498
1499
1500
1501
1502
1503
1504
1505
1506
1507
1508
1509
1510
1511
1512
1513
1514
1515
1516
1517
1518
1519
1520
1521
1522
1523
1524
1525
1526
1527
1528
1529
1530
1531
1532
1533
1534
1535
1536
1537
1538
1539
1540
1541
1542
1543
1544
1545
1546
1547
1548
1549
1550
1551
1552
1553
1554
1555
1556
1557
1558
1559
1560
1561
1562
1563
1564
1565
1566
1567
1568
1569
1570
1571
1572
1573
1574
1575
1576
1577
1578
1579
1580
1581
1582
1583
1584
1585
1586
1587
1588
1589
1590
1591
1592
1593
1594
1595
1596
1597
1598
1599
1600
1601
1602
1603
1604
1605
1606
1607
1608
1609
1610
1611
1612
1613
1614
1615
1616
1617
1618
1619
1620
1621
1622
1623
1624
1625
1626
1627
1628
1629
1630
1631
1632
1633
1634
1635
1636
1637
1638
1639
1640
1641
1642
1643
1644
1645
1646
1647
1648
1649
1650
1651
1652
1653
1654
1655
1656
1657
1658
1659
1660
1661
1662
1663
1664
1665
1666
1667
1668
1669
1670
1671
1672
1673
1674
1675
1676
1677
1678
1679
1680
1681
1682
1683
1684
1685
1686
1687
1688
1689
1690
1691
1692
1693
1694
1695
1696
1697
1698
1699
1700
1701
1702
1703
1704
1705
1706
1707
1708
1709
1710
1711
1712
1713
1714
1715
1716
1717
1718
1719
1720
1721
1722
1723
1724
1725
1726
1727
1728
1729
1730
1731
1732
1733
1734
1735
1736
1737
1738
1739
1740
1741
1742
1743
1744
1745
1746
1747
1748
1749
1750
1751
1752
1753
1754
1755
1756
1757
1758
1759
1760
1761
1762
1763
1764
1765
1766
1767
1768
1769
1770
1771
1772
1773
1774
1775
1776
1777
1778
1779
1780
1781
1782
1783
1784
1785
1786
1787
1788
1789
1790
1791
1792
1793
1794
1795
1796
1797
1798
1799
1800
1801
1802
1803
1804
1805
1806
1807
1808
1809
1810
1811
1812
1813
1814
1815
1816
1817
1818
1819
1820
1821
1822
1823
1824
1825
1826
1827
1828
1829
1830
1831
1832
1833
1834
1835
1836
1837
1838
1839
1840
1841
1842
1843
1844
1845
1846
1847
1848
1849
1850
1851
1852
1853
1854
1855
1856
1857
1858
1859
1860
1861
1862
1863
1864
1865
1866
1867
1868
1869
1870
1871
1872
1873
1874
1875
1876
1877
1878
1879
1880
1881
1882
1883
1884
1885
1886
1887
1888
1889
1890
1891
1892
1893
1894
1895
1896
1897
1898
1899
1900
1901
1902
1903
1904
1905
1906
1907
1908
1909
1910
1911
1912
1913
1914
1915
1916
1917
1918
1919
1920
1921
1922
1923
1924
1925
1926
1927
1928
1929
1930
1931
1932
1933
1934
1935
1936
1937
1938
1939
1940
1941
1942
1943
1944
1945
1946
1947
1948
1949
1950
1951
1952
1953
1954
1955
1956
1957
1958
1959
1960
1961
1962
1963
1964
1965
1966
1967
1968
1969
1970
1971
1972
1973
1974
1975
1976
1977
1978
1979
1980
1981
1982
1983
1984
1985
1986
1987
1988
1989
1990
1991
1992
1993
1994
1995
1996
1997
1998
1999
2000
2001
2002
2003
2004
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
2026
2027
2028
2029
2030
2031
2032
2033
2034
2035
2036
2037
2038
2039
2040
2041
2042
2043
2044
2045
2046
2047
2048
2049
2050
2051
2052
2053
2054
2055
2056
2057
2058
2059
2060
2061
2062
2063
2064
2065
2066
2067
2068
2069
2070
2071
2072
2073
2074
2075
2076
2077
2078
2079
2080
2081
2082
2083
2084
2085
2086
2087
2088
2089
2090
2091
2092
2093
2094
2095
2096
2097
2098
2099
2100
2101
2102
2103
2104
2105
2106
2107
2108
2109
2110
2111
2112
2113
2114
2115
2116
2117
2118
2119
2120
2121
2122
2123
2124
2125
2126
2127
2128
2129
2130
2131
2132
2133
2134
2135
2136
2137
2138
2139
2140
2141
2142
2143
2144
2145
2146
2147
2148
2149
2150
2151
2152
2153
2154
2155
2156
2157
2158
2159
2160
2161
2162
2163
2164
2165
2166
2167
2168
2169
2170
2171
2172
2173
2174
2175
2176
2177
2178
2179
2180
2181
2182
2183
2184
2185
2186
2187
2188
2189
2190
2191
2192
2193
2194
2195
2196
2197
2198
2199
2200
2201
2202
2203
2204
2205
2206
2207
2208
2209
2210
2211
2212
2213
2214
2215
2216
2217
2218
2219
2220
2221
2222
2223
2224
2225
2226
2227
2228
2229
2230
2231
2232
2233
2234
2235
2236
2237
2238
2239
2240
2241
2242
2243
2244
2245
2246
2247
2248
2249
2250
2251
2252
2253
2254
2255
2256
2257
2258
2259
2260
2261
2262
2263
2264
2265
2266
2267
2268
2269
2270
2271
2272
2273
2274
2275
2276
2277
2278
2279
2280
2281
2282
2283
2284
2285
2286
2287
2288
2289
2290
2291
2292
2293
2294
select CAST(1-2 AS UNSIGNED);
CAST(1-2 AS UNSIGNED)
18446744073709551615
select CAST(CAST(1-2 AS UNSIGNED) AS SIGNED INTEGER);
CAST(CAST(1-2 AS UNSIGNED) AS SIGNED INTEGER)
-1
select CAST('10 ' as unsigned integer);
CAST('10 ' as unsigned integer)
10
select CAST('10x' as unsigned integer);
CAST('10x' as unsigned integer)
10
Warnings:
Warning	1292	Truncated incorrect INTEGER value: '10x'
select cast(-5 as unsigned) | 1, cast(-5 as unsigned) & -1;
cast(-5 as unsigned) | 1	cast(-5 as unsigned) & -1
18446744073709551611	18446744073709551611
select cast(-5 as unsigned) -1, cast(-5 as unsigned) + 1;
cast(-5 as unsigned) -1	cast(-5 as unsigned) + 1
18446744073709551610	18446744073709551612
select ~5, cast(~5 as signed);
~5	cast(~5 as signed)
18446744073709551610	-6
explain select ~5, cast(~5 as signed);
id	select_type	table	partitions	type	possible_keys	key	key_len	ref	rows	filtered	Extra
1	SIMPLE	NULL	NULL	NULL	NULL	NULL	NULL	NULL	NULL	NULL	No tables used
Warnings:
Note	1003	/* select#1 */ select ~(5) AS `~5`,cast(~(5) as signed) AS `cast(~5 as signed)`
select cast(5 as unsigned) -6.0;
cast(5 as unsigned) -6.0
-1.0
select cast(NULL as signed), cast(1/0 as signed);
cast(NULL as signed)	cast(1/0 as signed)
NULL	NULL
Warnings:
Warning	1365	Division by 0
select cast(NULL as unsigned), cast(1/0 as unsigned);
cast(NULL as unsigned)	cast(1/0 as unsigned)
NULL	NULL
Warnings:
Warning	1365	Division by 0
select cast("A" as binary) = "a", cast(BINARY "a" as CHAR) = "A";
cast("A" as binary) = "a"	cast(BINARY "a" as CHAR) = "A"
0	1
Warnings:
Warning	1287	'BINARY expr' is deprecated and will be removed in a future release. Please use CAST instead
select cast("2001-1-1" as DATE), cast("2001-1-1" as DATETIME);
cast("2001-1-1" as DATE)	cast("2001-1-1" as DATETIME)
2001-01-01	2001-01-01 00:00:00
select cast("1:2:3" as TIME);
cast("1:2:3" as TIME)
01:02:03
select CONVERT("2004-01-22 21:45:33",DATE);
CONVERT("2004-01-22 21:45:33",DATE)
2004-01-22
select 10+'10';
10+'10'
20
select 10.0+'10';
10.0+'10'
20
select 10E+0+'10';
10E+0+'10'
20
SELECT CONVERT(TIMESTAMP "2004-01-22 21:45:33" USING latin1);
CONVERT(TIMESTAMP "2004-01-22 21:45:33" USING latin1)
2004-01-22 21:45:33
SELECT CONVERT(TIMESTAMP "2004-01-22 21:45:33", CHAR);
CONVERT(TIMESTAMP "2004-01-22 21:45:33", CHAR)
2004-01-22 21:45:33
SELECT CONVERT(TIMESTAMP "2004-01-22 21:45:33", CHAR(4));
CONVERT(TIMESTAMP "2004-01-22 21:45:33", CHAR(4))
2004
Warnings:
Warning	1292	Truncated incorrect CHAR(4) value: '2004-01-22 21:45:33'
SELECT CONVERT(TIMESTAMP "2004-01-22 21:45:33", BINARY(4));
CONVERT(TIMESTAMP "2004-01-22 21:45:33", BINARY(4))
2004
Warnings:
Warning	1292	Truncated incorrect BINARY(4) value: '2004-01-22 21:45:33'
select CAST(TIMESTAMP "2004-01-22 21:45:33" AS BINARY(4));
CAST(TIMESTAMP "2004-01-22 21:45:33" AS BINARY(4))
2004
Warnings:
Warning	1292	Truncated incorrect BINARY(4) value: '2004-01-22 21:45:33'
select CAST(0xb3 as signed);
CAST(0xb3 as signed)
179
select CAST(0x8fffffffffffffff as signed);
CAST(0x8fffffffffffffff as signed)
-8070450532247928833
select CAST(0xffffffffffffffff as unsigned);
CAST(0xffffffffffffffff as unsigned)
18446744073709551615
select CAST(0xfffffffffffffffe as signed);
CAST(0xfffffffffffffffe as signed)
-2
select cast('-10a' as signed integer);
cast('-10a' as signed integer)
-10
Warnings:
Warning	1292	Truncated incorrect INTEGER value: '-10a'
select cast('a10' as unsigned integer);
cast('a10' as unsigned integer)
0
Warnings:
Warning	1292	Truncated incorrect INTEGER value: 'a10'
select 10+'a';
10+'a'
10
Warnings:
Warning	1292	Truncated incorrect DOUBLE value: 'a'
select 10.0+cast('a' as decimal);
10.0+cast('a' as decimal)
10.0
Warnings:
Warning	1292	Truncated incorrect DECIMAL value: 'a'
select 10E+0+'a';
10E+0+'a'
10
Warnings:
Warning	1292	Truncated incorrect DOUBLE value: 'a'
select cast('18446744073709551616' as unsigned);
cast('18446744073709551616' as unsigned)
18446744073709551615
Warnings:
Warning	1292	Truncated incorrect INTEGER value: '18446744073709551616'
select cast('18446744073709551616' as signed);
cast('18446744073709551616' as signed)
-1
Warnings:
Warning	1292	Truncated incorrect INTEGER value: '18446744073709551616'
select cast('9223372036854775809' as signed);
cast('9223372036854775809' as signed)
-9223372036854775807
Warnings:
Warning	1105	Cast to signed converted positive out-of-range integer to its negative complement
select cast('-1' as unsigned);
cast('-1' as unsigned)
18446744073709551615
Warnings:
Warning	1105	Cast to unsigned converted negative integer to its positive complement
select cast('abc' as signed);
cast('abc' as signed)
0
Warnings:
Warning	1292	Truncated incorrect INTEGER value: 'abc'
select cast('1a' as signed);
cast('1a' as signed)
1
Warnings:
Warning	1292	Truncated incorrect INTEGER value: '1a'
select cast('' as signed);
cast('' as signed)
0
Warnings:
Warning	1292	Truncated incorrect INTEGER value: ''
select hex(cast(_latin1'test' as char character set latin2));
hex(cast(_latin1'test' as char character set latin2))
74657374
select hex(cast(_koi8r x'D4C5D3D4' as char character set cp1251));
hex(cast(_koi8r x'D4C5D3D4' as char character set cp1251))
F2E5F1F2
create table t1 select cast(_koi8r x'D4C5D3D4' as char character set cp1251) as t;
show create table t1;
Table	Create Table
t1	CREATE TABLE `t1` (
  `t` varchar(4) CHARACTER SET cp1251 DEFAULT NULL
) ENGINE=ENGINE DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci
drop table t1;
select
cast(_latin1'ab'  AS char charset binary)    as c1,
cast(_latin1'a '  AS char charset binary)    as c2,
cast(_latin1'abc' AS char(2) charset binary) as c3,
cast(_latin1'a  ' AS char(2) charset binary) as c4,
hex(cast(_latin1'a'   AS char(2) charset binary)) as c5;
c1	c2	c3	c4	c5
ab	a 	ab	a 	6100
Warnings:
Warning	1292	Truncated incorrect BINARY(2) value: 'abc'
Warning	1292	Truncated incorrect BINARY(2) value: 'a  '
select cast(1000 as CHAR(3) charset binary);
cast(1000 as CHAR(3) charset binary)
100
Warnings:
Warning	1292	Truncated incorrect BINARY(3) value: '1000'
SET sql_mode = 'NO_ENGINE_SUBSTITUTION';
create table t1 select
cast(_latin1'ab'  AS char charset binary)    as c1,
cast(_latin1'a '  AS char charset binary)    as c2,
cast(_latin1'abc' AS char(2) charset binary) as c3,
cast(_latin1'a  ' AS char(2) charset binary) as c4,
cast(_latin1'a'   AS char(2) charset binary) as c5;
Warnings:
Warning	1292	Truncated incorrect BINARY(2) value: 'abc'
Warning	1292	Truncated incorrect BINARY(2) value: 'a  '
select c1,c2,c3,c4,hex(c5) from t1;
c1	c2	c3	c4	hex(c5)
ab	a 	ab	a 	6100
show create table t1;
Table	Create Table
t1	CREATE TABLE `t1` (
  `c1` varbinary(2) NOT NULL DEFAULT '',
  `c2` varbinary(2) NOT NULL DEFAULT '',
  `c3` varbinary(2) NOT NULL DEFAULT '',
  `c4` varbinary(2) NOT NULL DEFAULT '',
  `c5` varbinary(2) NOT NULL DEFAULT ''
) ENGINE=ENGINE DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci
drop table t1;
select
cast(_koi8r x'C6C7'   AS nchar)    as c1,
cast(_koi8r x'C620'   AS nchar)    as c2,
cast(_koi8r x'C6C7C8' AS nchar(2)) as c3,
cast(_koi8r x'C62020' AS nchar(2)) as c4,
cast(_koi8r x'C6'     AS nchar(2)) as c5;
c1	c2	c3	c4	c5
фг	ф 	фг	ф 	ф
Warnings:
Warning	3720	NATIONAL/NCHAR/NVARCHAR implies the character set UTF8MB3, which will be replaced by UTF8MB4 in a future release. Please consider using CHAR(x) CHARACTER SET UTF8MB4 in order to be unambiguous.
Warning	3720	NATIONAL/NCHAR/NVARCHAR implies the character set UTF8MB3, which will be replaced by UTF8MB4 in a future release. Please consider using CHAR(x) CHARACTER SET UTF8MB4 in order to be unambiguous.
Warning	3720	NATIONAL/NCHAR/NVARCHAR implies the character set UTF8MB3, which will be replaced by UTF8MB4 in a future release. Please consider using CHAR(x) CHARACTER SET UTF8MB4 in order to be unambiguous.
Warning	3720	NATIONAL/NCHAR/NVARCHAR implies the character set UTF8MB3, which will be replaced by UTF8MB4 in a future release. Please consider using CHAR(x) CHARACTER SET UTF8MB4 in order to be unambiguous.
Warning	3720	NATIONAL/NCHAR/NVARCHAR implies the character set UTF8MB3, which will be replaced by UTF8MB4 in a future release. Please consider using CHAR(x) CHARACTER SET UTF8MB4 in order to be unambiguous.
Warning	1292	Truncated incorrect CHAR(4) value: 'фгх'
Warning	1292	Truncated incorrect CHAR(3) value: 'ф  '
create table t1 select
cast(_koi8r x'C6C7'   AS nchar)    as c1,
cast(_koi8r x'C620'   AS nchar)    as c2,
cast(_koi8r x'C6C7C8' AS nchar(2)) as c3,
cast(_koi8r x'C62020' AS nchar(2)) as c4,
cast(_koi8r x'C6'     AS nchar(2)) as c5;
Warnings:
Warning	3720	NATIONAL/NCHAR/NVARCHAR implies the character set UTF8MB3, which will be replaced by UTF8MB4 in a future release. Please consider using CHAR(x) CHARACTER SET UTF8MB4 in order to be unambiguous.
Warning	3720	NATIONAL/NCHAR/NVARCHAR implies the character set UTF8MB3, which will be replaced by UTF8MB4 in a future release. Please consider using CHAR(x) CHARACTER SET UTF8MB4 in order to be unambiguous.
Warning	3720	NATIONAL/NCHAR/NVARCHAR implies the character set UTF8MB3, which will be replaced by UTF8MB4 in a future release. Please consider using CHAR(x) CHARACTER SET UTF8MB4 in order to be unambiguous.
Warning	3720	NATIONAL/NCHAR/NVARCHAR implies the character set UTF8MB3, which will be replaced by UTF8MB4 in a future release. Please consider using CHAR(x) CHARACTER SET UTF8MB4 in order to be unambiguous.
Warning	3720	NATIONAL/NCHAR/NVARCHAR implies the character set UTF8MB3, which will be replaced by UTF8MB4 in a future release. Please consider using CHAR(x) CHARACTER SET UTF8MB4 in order to be unambiguous.
Warning	1292	Truncated incorrect CHAR(4) value: 'фгх'
Warning	1292	Truncated incorrect CHAR(3) value: 'ф  '
select * from t1;
c1	c2	c3	c4	c5
фг	ф 	фг	ф 	ф
show create table t1;
Table	Create Table
t1	CREATE TABLE `t1` (
  `c1` varchar(2) CHARACTER SET utf8mb3 NOT NULL DEFAULT '',
  `c2` varchar(2) CHARACTER SET utf8mb3 NOT NULL DEFAULT '',
  `c3` varchar(2) CHARACTER SET utf8mb3 NOT NULL DEFAULT '',
  `c4` varchar(2) CHARACTER SET utf8mb3 NOT NULL DEFAULT '',
  `c5` varchar(2) CHARACTER SET utf8mb3 NOT NULL DEFAULT ''
) ENGINE=ENGINE DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci
drop table t1;
#
# Bug #24934161: FAILURE OF SYNONYMY OF NCHAR AND NATIONAL CHAR
#
SELECT
CAST(_gb2312 x'CAFDBEDD'     AS NATIONAL CHAR)    AS c1,
CAST(_gb2312 x'CAFD20'       AS NATIONAL CHAR)    AS c2,
CAST(_gb2312 x'CAFDBEDDBFE2' AS NATIONAL CHAR(2)) AS c3,
CAST(_gb2312 x'CAFD2020'     AS NATIONAL CHAR(2)) AS c4,
CAST(_gb2312 x'CAFD'         AS NATIONAL CHAR(2)) AS c5;
c1	c2	c3	c4	c5
数据	数 	数据	数 	数
Warnings:
Warning	3720	NATIONAL/NCHAR/NVARCHAR implies the character set UTF8MB3, which will be replaced by UTF8MB4 in a future release. Please consider using CHAR(x) CHARACTER SET UTF8MB4 in order to be unambiguous.
Warning	3720	NATIONAL/NCHAR/NVARCHAR implies the character set UTF8MB3, which will be replaced by UTF8MB4 in a future release. Please consider using CHAR(x) CHARACTER SET UTF8MB4 in order to be unambiguous.
Warning	3720	NATIONAL/NCHAR/NVARCHAR implies the character set UTF8MB3, which will be replaced by UTF8MB4 in a future release. Please consider using CHAR(x) CHARACTER SET UTF8MB4 in order to be unambiguous.
Warning	3720	NATIONAL/NCHAR/NVARCHAR implies the character set UTF8MB3, which will be replaced by UTF8MB4 in a future release. Please consider using CHAR(x) CHARACTER SET UTF8MB4 in order to be unambiguous.
Warning	3720	NATIONAL/NCHAR/NVARCHAR implies the character set UTF8MB3, which will be replaced by UTF8MB4 in a future release. Please consider using CHAR(x) CHARACTER SET UTF8MB4 in order to be unambiguous.
Warning	1292	Truncated incorrect CHAR(6) value: '数据库'
Warning	1292	Truncated incorrect CHAR(4) value: '数  '
CREATE TABLE t1 SELECT
CAST(_gb2312 x'CAFDBEDD'     AS NATIONAL CHAR)    AS c1,
CAST(_gb2312 x'CAFD20'       AS NATIONAL CHAR)    AS c2,
CAST(_gb2312 x'CAFDBEDDBFE2' AS NATIONAL CHAR(2)) AS c3,
CAST(_gb2312 x'CAFD2020'     AS NATIONAL CHAR(2)) AS c4,
CAST(_gb2312 x'CAFD'         AS NATIONAL CHAR(2)) AS c5;
Warnings:
Warning	3720	NATIONAL/NCHAR/NVARCHAR implies the character set UTF8MB3, which will be replaced by UTF8MB4 in a future release. Please consider using CHAR(x) CHARACTER SET UTF8MB4 in order to be unambiguous.
Warning	3720	NATIONAL/NCHAR/NVARCHAR implies the character set UTF8MB3, which will be replaced by UTF8MB4 in a future release. Please consider using CHAR(x) CHARACTER SET UTF8MB4 in order to be unambiguous.
Warning	3720	NATIONAL/NCHAR/NVARCHAR implies the character set UTF8MB3, which will be replaced by UTF8MB4 in a future release. Please consider using CHAR(x) CHARACTER SET UTF8MB4 in order to be unambiguous.
Warning	3720	NATIONAL/NCHAR/NVARCHAR implies the character set UTF8MB3, which will be replaced by UTF8MB4 in a future release. Please consider using CHAR(x) CHARACTER SET UTF8MB4 in order to be unambiguous.
Warning	3720	NATIONAL/NCHAR/NVARCHAR implies the character set UTF8MB3, which will be replaced by UTF8MB4 in a future release. Please consider using CHAR(x) CHARACTER SET UTF8MB4 in order to be unambiguous.
Warning	1292	Truncated incorrect CHAR(6) value: '数据库'
Warning	1292	Truncated incorrect CHAR(4) value: '数  '
SELECT * FROM t1;
c1	c2	c3	c4	c5
数据	数 	数据	数 	数
SHOW CREATE TABLE t1;
Table	Create Table
t1	CREATE TABLE `t1` (
  `c1` varchar(2) CHARACTER SET utf8mb3 NOT NULL DEFAULT '',
  `c2` varchar(2) CHARACTER SET utf8mb3 NOT NULL DEFAULT '',
  `c3` varchar(2) CHARACTER SET utf8mb3 NOT NULL DEFAULT '',
  `c4` varchar(2) CHARACTER SET utf8mb3 NOT NULL DEFAULT '',
  `c5` varchar(2) CHARACTER SET utf8mb3 NOT NULL DEFAULT ''
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci
DROP TABLE t1;
SET sql_mode = default;
create table t1 (a binary(4), b char(4) character set koi8r);
insert into t1 values (_binary x'D4C5D3D4',_binary x'D4C5D3D4');
select hex(a),hex(b),hex(cast(a as char character set cp1251)),hex(cast(b as binary)) from t1;
hex(a)	hex(b)	hex(cast(a as char character set cp1251))	hex(cast(b as binary))
D4C5D3D4	D4C5D3D4	D4C5D3D4	D4C5D3D4
drop table t1;
select cast("2001-1-1" as date) = "2001-01-01";
cast("2001-1-1" as date) = "2001-01-01"
1
select cast("2001-1-1" as datetime) = "2001-01-01 00:00:00";
cast("2001-1-1" as datetime) = "2001-01-01 00:00:00"
1
select cast("1:2:3" as TIME) = "1:02:03";
cast("1:2:3" as TIME) = "1:02:03"
0
select cast(NULL as DATE);
cast(NULL as DATE)
NULL
select cast(NULL as BINARY);
cast(NULL as BINARY)
NULL
CREATE TABLE t1 (a enum ('aac','aab','aaa') not null);
INSERT INTO t1 VALUES ('aaa'),('aab'),('aac');
SELECT a, CAST(a AS CHAR charset binary) FROM t1 ORDER BY CAST(a AS UNSIGNED) ;
a	CAST(a AS CHAR charset binary)
aac	aac
aab	aab
aaa	aaa
SELECT a, CAST(a AS CHAR(3) charset binary) FROM t1 ORDER BY CAST(a AS CHAR(2) charset binary), a;
a	CAST(a AS CHAR(3) charset binary)
aac	aac
aab	aab
aaa	aaa
Warnings:
Warning	1292	Truncated incorrect BINARY(2) value: 'aaa'
Warning	1292	Truncated incorrect BINARY(2) value: 'aab'
Warning	1292	Truncated incorrect BINARY(2) value: 'aac'
SELECT a, CAST(a AS UNSIGNED) FROM t1 ORDER BY CAST(a AS CHAR charset binary) ;
a	CAST(a AS UNSIGNED)
aaa	3
aab	2
aac	1
SELECT a, CAST(a AS CHAR(2) charset binary ) FROM t1 ORDER BY CAST(a AS CHAR(3) charset binary), a;
a	CAST(a AS CHAR(2) charset binary )
aaa	aa
aab	aa
aac	aa
Warnings:
Warning	1292	Truncated incorrect BINARY(2) value: 'aaa'
Warning	1292	Truncated incorrect BINARY(2) value: 'aab'
Warning	1292	Truncated incorrect BINARY(2) value: 'aac'
DROP TABLE t1;
select date_add(cast('2004-12-30 12:00:00' as date), interval 0 hour);
date_add(cast('2004-12-30 12:00:00' as date), interval 0 hour)
2004-12-30 00:00:00
select timediff(cast('2004-12-30 12:00:00' as time), '12:00:00');
timediff(cast('2004-12-30 12:00:00' as time), '12:00:00')
00:00:00
select timediff(cast('1 12:00:00' as time), '12:00:00');
timediff(cast('1 12:00:00' as time), '12:00:00')
24:00:00
select cast(18446744073709551615 as unsigned);
cast(18446744073709551615 as unsigned)
18446744073709551615
select cast(18446744073709551615 as signed);
cast(18446744073709551615 as signed)
-1
select cast('18446744073709551615' as unsigned);
cast('18446744073709551615' as unsigned)
18446744073709551615
select cast('18446744073709551615' as signed);
cast('18446744073709551615' as signed)
-1
Warnings:
Warning	1105	Cast to signed converted positive out-of-range integer to its negative complement
select cast('9223372036854775807' as signed);
cast('9223372036854775807' as signed)
9223372036854775807
select cast(concat('184467440','73709551615') as unsigned);
cast(concat('184467440','73709551615') as unsigned)
18446744073709551615
select cast(concat('184467440','73709551615') as signed);
cast(concat('184467440','73709551615') as signed)
-1
Warnings:
Warning	1105	Cast to signed converted positive out-of-range integer to its negative complement
select cast(repeat('1',20) as unsigned);
cast(repeat('1',20) as unsigned)
11111111111111111111
select cast(repeat('1',20) as signed);
cast(repeat('1',20) as signed)
-7335632962598440505
Warnings:
Warning	1105	Cast to signed converted positive out-of-range integer to its negative complement
select cast(1.0e+300 as signed int);
cast(1.0e+300 as signed int)
9223372036854775807
CREATE TABLE t1 (f1 double);
INSERT INTO t1 SET f1 = -1.0e+30 ;
INSERT INTO t1 SET f1 = +1.0e+30 ;
SELECT f1 AS double_val, CAST(f1 AS SIGNED INT) AS cast_val FROM t1;
double_val	cast_val
-1e30	-9223372036854775808
1e30	9223372036854775807
Warnings:
Warning	1292	Truncated incorrect INTEGER value: '-1e30'
Warning	1292	Truncated incorrect INTEGER value: '1e30'
DROP TABLE t1;
select isnull(date(NULL)), isnull(cast(NULL as DATE));
isnull(date(NULL))	isnull(cast(NULL as DATE))
1	1
SELECT CAST(cast('01-01-01' as date) AS UNSIGNED);
CAST(cast('01-01-01' as date) AS UNSIGNED)
20010101
SELECT CAST(cast('01-01-01' as date) AS SIGNED);
CAST(cast('01-01-01' as date) AS SIGNED)
20010101
End of 4.1 tests
select cast('1.2' as decimal(3,2));
cast('1.2' as decimal(3,2))
1.20
select 1e18 * cast('1.2' as decimal(3,2));
1e18 * cast('1.2' as decimal(3,2))
1.2e18
select cast(cast('1.2' as decimal(3,2)) as signed);
cast(cast('1.2' as decimal(3,2)) as signed)
1
set @v1=1e18;
select cast(@v1 as decimal(22, 2));
cast(@v1 as decimal(22, 2))
1000000000000000000.00
select cast(-1e18 as decimal(22,2));
cast(-1e18 as decimal(22,2))
-1000000000000000000.00
create table t1(s1 time);
insert into t1 values ('11:11:11');
select cast(s1 as decimal(7,2)) from t1;
cast(s1 as decimal(7,2))
99999.99
Warnings:
Warning	1264	Out of range value for column 'cast(s1 as decimal(7,2))' at row 1
drop table t1;
CREATE TABLE t1 (v varchar(10), tt tinytext, t text,
mt mediumtext, lt longtext);
INSERT INTO t1 VALUES ('1.01', '2.02', '3.03', '4.04', '5.05');
SELECT CAST(v AS DECIMAL), CAST(tt AS DECIMAL), CAST(t AS DECIMAL),
CAST(mt AS DECIMAL), CAST(lt AS DECIMAL) from t1;
CAST(v AS DECIMAL)	CAST(tt AS DECIMAL)	CAST(t AS DECIMAL)	CAST(mt AS DECIMAL)	CAST(lt AS DECIMAL)
1	2	3	4	5
DROP TABLE t1;
select cast(NULL as decimal(6)) as t1;
t1
NULL
set names latin1;
select hex(cast('a' as char(2) binary));
hex(cast('a' as char(2) binary))
61
Warnings:
Warning	1287	'BINARY as attribute of a type' is deprecated and will be removed in a future release. Please use a CHARACTER SET clause with _bin collation instead
select hex(cast('a' as binary(2)));
hex(cast('a' as binary(2)))
6100
select hex(cast('a' as char(2) binary));
hex(cast('a' as char(2) binary))
61
Warnings:
Warning	1287	'BINARY as attribute of a type' is deprecated and will be removed in a future release. Please use a CHARACTER SET clause with _bin collation instead
CREATE TABLE t1 (d1 datetime);
INSERT INTO t1(d1) VALUES ('2007-07-19 08:30:00'), (NULL),
('2007-07-19 08:34:00'), (NULL), ('2007-07-19 08:36:00');
SELECT cast(date(d1) as signed) FROM t1;
cast(date(d1) as signed)
20070719
NULL
20070719
NULL
20070719
drop table t1;
CREATE TABLE t1 (f1 DATE);
INSERT INTO t1 VALUES ('2007-07-19'), (NULL);
SELECT HOUR(f1),
MINUTE(f1),
SECOND(f1) FROM t1;
HOUR(f1)	MINUTE(f1)	SECOND(f1)
0	0	0
NULL	NULL	NULL
SELECT HOUR(CAST('2007-07-19' AS DATE)),
MINUTE(CAST('2007-07-19' AS DATE)),
SECOND(CAST('2007-07-19' AS DATE));
HOUR(CAST('2007-07-19' AS DATE))	MINUTE(CAST('2007-07-19' AS DATE))	SECOND(CAST('2007-07-19' AS DATE))
0	0	0
SELECT HOUR(CAST(NULL AS DATE)),
MINUTE(CAST(NULL AS DATE)),
SECOND(CAST(NULL AS DATE));
HOUR(CAST(NULL AS DATE))	MINUTE(CAST(NULL AS DATE))	SECOND(CAST(NULL AS DATE))
NULL	NULL	NULL
SELECT HOUR(NULL),
MINUTE(NULL),
SECOND(NULL);
HOUR(NULL)	MINUTE(NULL)	SECOND(NULL)
NULL	NULL	NULL
DROP TABLE t1;
End of 5.0 tests
#
#  Bug #44766: valgrind error when using convert() in a subquery
#
CREATE TABLE t1(a tinyint);
INSERT INTO t1 VALUES (127);
SELECT 1 FROM
(
SELECT CONVERT(t2.a USING UTF8) FROM t1, t1 t2 LIMIT 1
) AS s LIMIT 1;
1
1
Warnings:
Warning	3719	'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous.
DROP TABLE t1;
#
# Bug #11765023: 57934: DOS POSSIBLE SINCE BINARY CASTING 
#   DOESN'T ADHERE TO MAX_ALLOWED_PACKET
SET @@GLOBAL.max_allowed_packet=2048;
Warnings:
Warning	1708	The value of 'max_allowed_packet' should be no less than the value of 'net_buffer_length'
SELECT CONVERT('a', BINARY(2049));
CONVERT('a', BINARY(2049))
NULL
Warnings:
Warning	1301	Result of cast_as_binary() was larger than max_allowed_packet (2048) - truncated
SELECT CONVERT('a', CHAR(2049));
CONVERT('a', CHAR(2049))
NULL
Warnings:
Warning	1301	Result of cast_as_char() was larger than max_allowed_packet (2048) - truncated
SET @@GLOBAL.max_allowed_packet=default;
#
# Bug#13519724 63793: CRASH IN DTCOLLATION::SET(DTCOLLATION &SET)
#
CREATE TABLE t1 (a VARCHAR(50));
SELECT a FROM t1 
WHERE CAST(a as BINARY)=x'62736D697468' 
AND CAST(a AS BINARY)=x'65736D697468';
a
DROP TABLE t1;
End of 5.1 tests
#
# Bug#22885819: CAST( .. AS BINARY(N)) GETS UNEXPECTED NULL
#
SELECT CAST( 'a' AS BINARY(429496729));
CAST( 'a' AS BINARY(429496729))
NULL
Warnings:
Warning	1301	Result of cast_as_binary() was larger than max_allowed_packet (67108864) - truncated
SELECT CAST( 'a' AS BINARY(4294967294));
CAST( 'a' AS BINARY(4294967294))
NULL
Warnings:
Warning	1301	Result of cast_as_binary() was larger than max_allowed_packet (67108864) - truncated
SELECT CAST( 'a' AS BINARY(4294967295));
CAST( 'a' AS BINARY(4294967295))
NULL
Warnings:
Warning	1301	Result of cast_as_binary() was larger than max_allowed_packet (67108864) - truncated
SELECT CAST( 'a' AS BINARY(4294967296));
ERROR 42000: Display width out of range for column 'cast as char' (max = 4294967295)
SELECT CAST( 'a' AS BINARY(4294967296784564));
ERROR 42000: Display width out of range for column 'cast as char' (max = 4294967295)
#
# Bug#13581962 HIGH MEMORY USAGE ATTEMPT, THEN CRASH WITH LONGTEXT, UNION, USER VARIABLE
#
SET sql_mode = 'NO_ENGINE_SUBSTITUTION';
CREATE TABLE t1 AS SELECT CONCAT(CAST(REPEAT('9', 1000) AS SIGNED)),
CONCAT(CAST(REPEAT('9', 1000) AS UNSIGNED));
Warnings:
Warning	1292	Truncated incorrect INTEGER value: '99999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999'
Warning	1292	Truncated incorrect INTEGER value: '99999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999'
SHOW CREATE TABLE t1;
Table	Create Table
t1	CREATE TABLE `t1` (
  `CONCAT(CAST(REPEAT('9', 1000) AS SIGNED))` varchar(21) CHARACTER SET latin1 NOT NULL DEFAULT '',
  `CONCAT(CAST(REPEAT('9', 1000) AS UNSIGNED))` varchar(21) CHARACTER SET latin1 NOT NULL DEFAULT ''
) ENGINE=ENGINE DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci
DROP TABLE t1;
SET sql_mode = default;
End of 5.5 tests
#
# Bug#28547906 ENUM TYPE CASTING WORKS WRONG WITH SUBQUERIES
#
CREATE TABLE t (c1 ENUM('a','b','c'));
INSERT INTO t VALUES ('a'), ('b'), ('c');
SELECT CAST(c1 AS UNSIGNED) AS c5 FROM t;
c5
1
2
3
SELECT CAST(c1 AS UNSIGNED) AS c5 FROM (SELECT c1 FROM t) t;
c5
1
2
3
DROP TABLE t;
#
# CAST as DOUBLE/FLOAT/REAL
#
SELECT CAST(1/3 AS FLOAT) as float_col,
CAST(1/3 AS DOUBLE) as double_col,
CAST(1/3 AS DOUBLE PRECISION) as double_prec_col,
CAST(1/3 AS REAL) as real_col;
float_col	double_col	double_prec_col	real_col
0.333333	0.333333333	0.333333333	0.333333333
SELECT CAST(1/3 AS FLOAT(10)), CAST(1/3 AS FLOAT(53));
CAST(1/3 AS FLOAT(10))	CAST(1/3 AS FLOAT(53))
0.333333	0.333333333
SELECT CAST(1/3 AS FLOAT(-1));
ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '-1))' at line 1
SELECT CAST(1/3 AS FLOAT(54));
ERROR 42000: Too-big precision 54 specified for 'CAST'. Maximum is 53.
SELECT CAST(1/3 AS DOUBLE(52));
ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '(52))' at line 1
SELECT CAST(1/3 AS REAL(34));
ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '(34))' at line 1
SELECT CAST(999.00009 AS FLOAT(7,4)) as float_col;
ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ',4)) as float_col' at line 1
SELECT CAST(999.00009 AS DOUBLE(7,4)) as double_col;
ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '(7,4)) as double_col' at line 1
SELECT CAST(999.00009 AS REAL(7,4)) as real_col;
ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '(7,4)) as real_col' at line 1
SELECT ADDDATE(CAST("20010101235959.9" AS DOUBLE), INTERVAL 1 DAY);
ADDDATE(CAST("20010101235959.9" AS DOUBLE), INTERVAL 1 DAY)
2001-01-02 23:59:59.898438
SELECT TIMEDIFF(CAST("101112" AS DOUBLE), TIME'101010');
TIMEDIFF(CAST("101112" AS DOUBLE), TIME'101010')
00:01:02.000000
SELECT CAST(DATE'2000-01-01' AS FLOAT), CAST(DATE'2000-01-01' AS DOUBLE);
CAST(DATE'2000-01-01' AS FLOAT)	CAST(DATE'2000-01-01' AS DOUBLE)
20000100	20000101
SELECT CAST(TIME'23:59:59' AS FLOAT), CAST(TIME'23:59:59' AS DOUBLE);
CAST(TIME'23:59:59' AS FLOAT)	CAST(TIME'23:59:59' AS DOUBLE)
235959	235959
SELECT CAST(TIME'23:59:59.123456' AS FLOAT),
CAST(TIME'23:59:59.123456' AS DOUBLE);
CAST(TIME'23:59:59.123456' AS FLOAT)	CAST(TIME'23:59:59.123456' AS DOUBLE)
235959	235959.123456
SELECT CAST(TIMESTAMP'2000-01-01 23:59:59' AS FLOAT),
CAST(TIMESTAMP'2000-01-01 23:59:59' AS DOUBLE);
CAST(TIMESTAMP'2000-01-01 23:59:59' AS FLOAT)	CAST(TIMESTAMP'2000-01-01 23:59:59' AS DOUBLE)
20000100000000	20000101235959
SELECT CAST(TIMESTAMP'2000-01-01 23:59:59.123456' AS FLOAT),
CAST(TIMESTAMP'2000-01-01 23:59:59.123456' AS DOUBLE);
CAST(TIMESTAMP'2000-01-01 23:59:59.123456' AS FLOAT)	CAST(TIMESTAMP'2000-01-01 23:59:59.123456' AS DOUBLE)
20000100000000	20000101235959.125
CREATE TABLE t1 as SELECT CAST(1/3 AS FLOAT) as float_col,
CAST(1/3 AS DOUBLE) as double_col,
CAST(CAST(999.00009 AS DECIMAL(7,4)) AS DOUBLE) as d2;
SHOW CREATE TABLE t1;
Table	Create Table
t1	CREATE TABLE `t1` (
  `float_col` float DEFAULT NULL,
  `double_col` double DEFAULT NULL,
  `d2` double NOT NULL DEFAULT '0'
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci
DROP TABLE t1;
SELECT PERIOD_ADD(200905, CAST(3.14e19 AS DOUBLE));
ERROR 22003: BIGINT value is out of range in 'cast(3.14e19 as double)'
SELECT -1.0 *  CAST(3.14e19 AS DOUBLE);
-1.0 *  CAST(3.14e19 AS DOUBLE)
-3.14e19
SELECT CAST("3.14e100" AS FLOAT);
ERROR 22003: DOUBLE value is out of range in 'cast('3.14e100' as float)'
SELECT CAST(-1e308 as FLOAT);
ERROR 22003: DOUBLE value is out of range in 'cast(-(1e308) as float)'
SELECT CONCAT("value=", CAST("3.4e5" AS FLOAT));
CONCAT("value=", CAST("3.4e5" AS FLOAT))
value=340000
CREATE VIEW v1 AS SELECT CAST(1/3 AS REAL), CAST(1/3 AS FLOAT(2)), CAST(1/3 AS FLOAT(50));
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 cast((1 / 3) as double) AS `CAST(1/3 AS REAL)`,cast((1 / 3) as float) AS `CAST(1/3 AS FLOAT(2))`,cast((1 / 3) as double) AS `CAST(1/3 AS FLOAT(50))`	latin1	latin1_swedish_ci
DROP VIEW v1;
SELECT CAST(NULL AS REAL), CAST(NULL AS FLOAT), CAST(NULL AS DOUBLE);
CAST(NULL AS REAL)	CAST(NULL AS FLOAT)	CAST(NULL AS DOUBLE)
NULL	NULL	NULL
SET @OLD_SQL_MODE=@@SQL_MODE, @@SQL_MODE=REAL_AS_FLOAT;
CREATE TABLE t AS SELECT CAST(34 AS REAL);
SHOW CREATE TABLE t;
Table	Create Table
t	CREATE TABLE `t` (
  `CAST(34 AS REAL)` float NOT NULL DEFAULT '0'
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci
DROP TABLE t;
SET @@SQL_MODE=@OLD_SQL_MODE;
CREATE TABLE t AS SELECT CAST(34 AS REAL);
SHOW CREATE TABLE t;
Table	Create Table
t	CREATE TABLE `t` (
  `CAST(34 AS REAL)` double NOT NULL DEFAULT '0'
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci
DROP TABLE t;
SELECT MAKETIME(1, 2, CAST("1.6" AS FLOAT));
MAKETIME(1, 2, CAST("1.6" AS FLOAT))
01:02:01.600000
#
# WL#12108: Inject type cast nodes into the item tree to avoid data
# type mismatches.
#
CREATE TABLE dt_t (dt DATETIME, d DATE, t TIME);
CREATE TABLE n_t (i INT, d DECIMAL, f FLOAT, dc DECIMAL);
#
# DATETIME + NUMERICS
#
EXPLAIN SELECT * from dt_t JOIN n_t ON dt_t.dt = n_t.i;
id	select_type	table	partitions	type	possible_keys	key	key_len	ref	rows	filtered	Extra
1	SIMPLE	dt_t	NULL	ALL	NULL	NULL	NULL	NULL	1	100.00	NULL
1	SIMPLE	n_t	NULL	ALL	NULL	NULL	NULL	NULL	1	100.00	Using where; Using join buffer (hash join)
Warnings:
Note	1003	/* select#1 */ select `test`.`dt_t`.`dt` AS `dt`,`test`.`dt_t`.`d` AS `d`,`test`.`dt_t`.`t` AS `t`,`test`.`n_t`.`i` AS `i`,`test`.`n_t`.`d` AS `d`,`test`.`n_t`.`f` AS `f`,`test`.`n_t`.`dc` AS `dc` from `test`.`dt_t` join `test`.`n_t` where (cast(`test`.`dt_t`.`dt` as double) = cast(`test`.`n_t`.`i` as double))
EXPLAIN SELECT * from dt_t JOIN n_t ON dt_t.dt = n_t.d;
id	select_type	table	partitions	type	possible_keys	key	key_len	ref	rows	filtered	Extra
1	SIMPLE	dt_t	NULL	ALL	NULL	NULL	NULL	NULL	1	100.00	NULL
1	SIMPLE	n_t	NULL	ALL	NULL	NULL	NULL	NULL	1	100.00	Using where; Using join buffer (hash join)
Warnings:
Note	1003	/* select#1 */ select `test`.`dt_t`.`dt` AS `dt`,`test`.`dt_t`.`d` AS `d`,`test`.`dt_t`.`t` AS `t`,`test`.`n_t`.`i` AS `i`,`test`.`n_t`.`d` AS `d`,`test`.`n_t`.`f` AS `f`,`test`.`n_t`.`dc` AS `dc` from `test`.`dt_t` join `test`.`n_t` where (cast(`test`.`dt_t`.`dt` as double) = cast(`test`.`n_t`.`d` as double))
EXPLAIN SELECT * from dt_t JOIN n_t ON dt_t.dt = n_t.f;
id	select_type	table	partitions	type	possible_keys	key	key_len	ref	rows	filtered	Extra
1	SIMPLE	dt_t	NULL	ALL	NULL	NULL	NULL	NULL	1	100.00	NULL
1	SIMPLE	n_t	NULL	ALL	NULL	NULL	NULL	NULL	1	100.00	Using where; Using join buffer (hash join)
Warnings:
Note	1003	/* select#1 */ select `test`.`dt_t`.`dt` AS `dt`,`test`.`dt_t`.`d` AS `d`,`test`.`dt_t`.`t` AS `t`,`test`.`n_t`.`i` AS `i`,`test`.`n_t`.`d` AS `d`,`test`.`n_t`.`f` AS `f`,`test`.`n_t`.`dc` AS `dc` from `test`.`dt_t` join `test`.`n_t` where (cast(`test`.`dt_t`.`dt` as double) = `test`.`n_t`.`f`)
#
# DATE + NUMERICS
#
EXPLAIN SELECT * from dt_t JOIN n_t ON dt_t.d = n_t.i;
id	select_type	table	partitions	type	possible_keys	key	key_len	ref	rows	filtered	Extra
1	SIMPLE	dt_t	NULL	ALL	NULL	NULL	NULL	NULL	1	100.00	NULL
1	SIMPLE	n_t	NULL	ALL	NULL	NULL	NULL	NULL	1	100.00	Using where; Using join buffer (hash join)
Warnings:
Note	1003	/* select#1 */ select `test`.`dt_t`.`dt` AS `dt`,`test`.`dt_t`.`d` AS `d`,`test`.`dt_t`.`t` AS `t`,`test`.`n_t`.`i` AS `i`,`test`.`n_t`.`d` AS `d`,`test`.`n_t`.`f` AS `f`,`test`.`n_t`.`dc` AS `dc` from `test`.`dt_t` join `test`.`n_t` where (cast(`test`.`dt_t`.`d` as double) = cast(`test`.`n_t`.`i` as double))
EXPLAIN SELECT * from dt_t JOIN n_t ON dt_t.d = n_t.d;
id	select_type	table	partitions	type	possible_keys	key	key_len	ref	rows	filtered	Extra
1	SIMPLE	dt_t	NULL	ALL	NULL	NULL	NULL	NULL	1	100.00	NULL
1	SIMPLE	n_t	NULL	ALL	NULL	NULL	NULL	NULL	1	100.00	Using where; Using join buffer (hash join)
Warnings:
Note	1003	/* select#1 */ select `test`.`dt_t`.`dt` AS `dt`,`test`.`dt_t`.`d` AS `d`,`test`.`dt_t`.`t` AS `t`,`test`.`n_t`.`i` AS `i`,`test`.`n_t`.`d` AS `d`,`test`.`n_t`.`f` AS `f`,`test`.`n_t`.`dc` AS `dc` from `test`.`dt_t` join `test`.`n_t` where (cast(`test`.`dt_t`.`d` as double) = cast(`test`.`n_t`.`d` as double))
EXPLAIN SELECT * from dt_t JOIN n_t ON dt_t.d = n_t.f;
id	select_type	table	partitions	type	possible_keys	key	key_len	ref	rows	filtered	Extra
1	SIMPLE	dt_t	NULL	ALL	NULL	NULL	NULL	NULL	1	100.00	NULL
1	SIMPLE	n_t	NULL	ALL	NULL	NULL	NULL	NULL	1	100.00	Using where; Using join buffer (hash join)
Warnings:
Note	1003	/* select#1 */ select `test`.`dt_t`.`dt` AS `dt`,`test`.`dt_t`.`d` AS `d`,`test`.`dt_t`.`t` AS `t`,`test`.`n_t`.`i` AS `i`,`test`.`n_t`.`d` AS `d`,`test`.`n_t`.`f` AS `f`,`test`.`n_t`.`dc` AS `dc` from `test`.`dt_t` join `test`.`n_t` where (cast(`test`.`dt_t`.`d` as double) = `test`.`n_t`.`f`)
EXPLAIN SELECT * from dt_t JOIN n_t on dt_t.d = n_t.dc;
id	select_type	table	partitions	type	possible_keys	key	key_len	ref	rows	filtered	Extra
1	SIMPLE	dt_t	NULL	ALL	NULL	NULL	NULL	NULL	1	100.00	NULL
1	SIMPLE	n_t	NULL	ALL	NULL	NULL	NULL	NULL	1	100.00	Using where; Using join buffer (hash join)
Warnings:
Note	1003	/* select#1 */ select `test`.`dt_t`.`dt` AS `dt`,`test`.`dt_t`.`d` AS `d`,`test`.`dt_t`.`t` AS `t`,`test`.`n_t`.`i` AS `i`,`test`.`n_t`.`d` AS `d`,`test`.`n_t`.`f` AS `f`,`test`.`n_t`.`dc` AS `dc` from `test`.`dt_t` join `test`.`n_t` where (cast(`test`.`dt_t`.`d` as double) = cast(`test`.`n_t`.`dc` as double))
#
# TIME + NUMERICS
#
EXPLAIN SELECT * from dt_t JOIN n_t ON dt_t.t = n_t.i;
id	select_type	table	partitions	type	possible_keys	key	key_len	ref	rows	filtered	Extra
1	SIMPLE	dt_t	NULL	ALL	NULL	NULL	NULL	NULL	1	100.00	NULL
1	SIMPLE	n_t	NULL	ALL	NULL	NULL	NULL	NULL	1	100.00	Using where; Using join buffer (hash join)
Warnings:
Note	1003	/* select#1 */ select `test`.`dt_t`.`dt` AS `dt`,`test`.`dt_t`.`d` AS `d`,`test`.`dt_t`.`t` AS `t`,`test`.`n_t`.`i` AS `i`,`test`.`n_t`.`d` AS `d`,`test`.`n_t`.`f` AS `f`,`test`.`n_t`.`dc` AS `dc` from `test`.`dt_t` join `test`.`n_t` where (cast(`test`.`dt_t`.`t` as double) = cast(`test`.`n_t`.`i` as double))
EXPLAIN SELECT * from dt_t JOIN n_t ON dt_t.t = n_t.d;
id	select_type	table	partitions	type	possible_keys	key	key_len	ref	rows	filtered	Extra
1	SIMPLE	dt_t	NULL	ALL	NULL	NULL	NULL	NULL	1	100.00	NULL
1	SIMPLE	n_t	NULL	ALL	NULL	NULL	NULL	NULL	1	100.00	Using where; Using join buffer (hash join)
Warnings:
Note	1003	/* select#1 */ select `test`.`dt_t`.`dt` AS `dt`,`test`.`dt_t`.`d` AS `d`,`test`.`dt_t`.`t` AS `t`,`test`.`n_t`.`i` AS `i`,`test`.`n_t`.`d` AS `d`,`test`.`n_t`.`f` AS `f`,`test`.`n_t`.`dc` AS `dc` from `test`.`dt_t` join `test`.`n_t` where (cast(`test`.`dt_t`.`t` as double) = cast(`test`.`n_t`.`d` as double))
EXPLAIN SELECT * from dt_t JOIN n_t ON dt_t.t = n_t.f;
id	select_type	table	partitions	type	possible_keys	key	key_len	ref	rows	filtered	Extra
1	SIMPLE	dt_t	NULL	ALL	NULL	NULL	NULL	NULL	1	100.00	NULL
1	SIMPLE	n_t	NULL	ALL	NULL	NULL	NULL	NULL	1	100.00	Using where; Using join buffer (hash join)
Warnings:
Note	1003	/* select#1 */ select `test`.`dt_t`.`dt` AS `dt`,`test`.`dt_t`.`d` AS `d`,`test`.`dt_t`.`t` AS `t`,`test`.`n_t`.`i` AS `i`,`test`.`n_t`.`d` AS `d`,`test`.`n_t`.`f` AS `f`,`test`.`n_t`.`dc` AS `dc` from `test`.`dt_t` join `test`.`n_t` where (cast(`test`.`dt_t`.`t` as double) = `test`.`n_t`.`f`)
#
# DATETIME + DATE
#
EXPLAIN SELECT * from dt_t dt1 JOIN dt_t dt2 ON dt1.dt = dt2.d;
id	select_type	table	partitions	type	possible_keys	key	key_len	ref	rows	filtered	Extra
1	SIMPLE	dt1	NULL	ALL	NULL	NULL	NULL	NULL	1	100.00	NULL
1	SIMPLE	dt2	NULL	ALL	NULL	NULL	NULL	NULL	1	100.00	Using where; Using join buffer (hash join)
Warnings:
Note	1003	/* select#1 */ select `test`.`dt1`.`dt` AS `dt`,`test`.`dt1`.`d` AS `d`,`test`.`dt1`.`t` AS `t`,`test`.`dt2`.`dt` AS `dt`,`test`.`dt2`.`d` AS `d`,`test`.`dt2`.`t` AS `t` from `test`.`dt_t` `dt1` join `test`.`dt_t` `dt2` where (`test`.`dt1`.`dt` = cast(`test`.`dt2`.`d` as datetime))
#
# DATETIME + TIME
#
EXPLAIN SELECT * from dt_t dt1 JOIN dt_t dt2 ON dt1.dt = dt2.t;
id	select_type	table	partitions	type	possible_keys	key	key_len	ref	rows	filtered	Extra
1	SIMPLE	dt1	NULL	ALL	NULL	NULL	NULL	NULL	1	100.00	NULL
1	SIMPLE	dt2	NULL	ALL	NULL	NULL	NULL	NULL	1	100.00	Using where; Using join buffer (hash join)
Warnings:
Note	1003	/* select#1 */ select `test`.`dt1`.`dt` AS `dt`,`test`.`dt1`.`d` AS `d`,`test`.`dt1`.`t` AS `t`,`test`.`dt2`.`dt` AS `dt`,`test`.`dt2`.`d` AS `d`,`test`.`dt2`.`t` AS `t` from `test`.`dt_t` `dt1` join `test`.`dt_t` `dt2` where (`test`.`dt1`.`dt` = cast(`test`.`dt2`.`t` as datetime))
#
# DATE + TIME
#
EXPLAIN SELECT * from dt_t dt1 JOIN dt_t dt2 ON dt1.d = dt2.t;
id	select_type	table	partitions	type	possible_keys	key	key_len	ref	rows	filtered	Extra
1	SIMPLE	dt1	NULL	ALL	NULL	NULL	NULL	NULL	1	100.00	NULL
1	SIMPLE	dt2	NULL	ALL	NULL	NULL	NULL	NULL	1	100.00	Using where; Using join buffer (hash join)
Warnings:
Note	1003	/* select#1 */ select `test`.`dt1`.`dt` AS `dt`,`test`.`dt1`.`d` AS `d`,`test`.`dt1`.`t` AS `t`,`test`.`dt2`.`dt` AS `dt`,`test`.`dt2`.`d` AS `d`,`test`.`dt2`.`t` AS `t` from `test`.`dt_t` `dt1` join `test`.`dt_t` `dt2` where (cast(`test`.`dt1`.`d` as datetime) = cast(`test`.`dt2`.`t` as datetime))
EXPLAIN SELECT * FROM dt_t dt1 JOIN dt_t dt2 ON dt1.d = dt2.d;
id	select_type	table	partitions	type	possible_keys	key	key_len	ref	rows	filtered	Extra
1	SIMPLE	dt1	NULL	ALL	NULL	NULL	NULL	NULL	1	100.00	NULL
1	SIMPLE	dt2	NULL	ALL	NULL	NULL	NULL	NULL	1	100.00	Using where; Using join buffer (hash join)
Warnings:
Note	1003	/* select#1 */ select `test`.`dt1`.`dt` AS `dt`,`test`.`dt1`.`d` AS `d`,`test`.`dt1`.`t` AS `t`,`test`.`dt2`.`dt` AS `dt`,`test`.`dt2`.`d` AS `d`,`test`.`dt2`.`t` AS `t` from `test`.`dt_t` `dt1` join `test`.`dt_t` `dt2` where (`test`.`dt2`.`d` = `test`.`dt1`.`d`)
EXPLAIN SELECT dt_t.dt = n_t.i from dt_t, n_t;
id	select_type	table	partitions	type	possible_keys	key	key_len	ref	rows	filtered	Extra
1	SIMPLE	dt_t	NULL	ALL	NULL	NULL	NULL	NULL	1	100.00	NULL
1	SIMPLE	n_t	NULL	ALL	NULL	NULL	NULL	NULL	1	100.00	Using join buffer (hash join)
Warnings:
Note	1003	/* select#1 */ select (cast(`test`.`dt_t`.`dt` as double) = cast(`test`.`n_t`.`i` as double)) AS `dt_t.dt = n_t.i` from `test`.`dt_t` join `test`.`n_t`
EXPLAIN SELECT MAX(dt_t.d) AS max_d, MAX(n_t.i) AS max_i
FROM dt_t, n_t HAVING max_d = max_i;
id	select_type	table	partitions	type	possible_keys	key	key_len	ref	rows	filtered	Extra
1	SIMPLE	dt_t	NULL	ALL	NULL	NULL	NULL	NULL	1	100.00	NULL
1	SIMPLE	n_t	NULL	ALL	NULL	NULL	NULL	NULL	1	100.00	Using join buffer (hash join)
Warnings:
Note	1003	/* select#1 */ select max(`test`.`dt_t`.`d`) AS `max_d`,max(`test`.`n_t`.`i`) AS `max_i` from `test`.`dt_t` join `test`.`n_t` having (cast(`max_d` as double) = cast(`max_i` as double))
EXPLAIN SELECT dt=d from dt_t ORDER BY dt = d;
id	select_type	table	partitions	type	possible_keys	key	key_len	ref	rows	filtered	Extra
1	SIMPLE	dt_t	NULL	ALL	NULL	NULL	NULL	NULL	1	100.00	Using filesort
Warnings:
Note	1003	/* select#1 */ select (`test`.`dt_t`.`dt` = cast(`test`.`dt_t`.`d` as datetime)) AS `dt=d` from `test`.`dt_t` order by (`test`.`dt_t`.`dt` = cast(`test`.`dt_t`.`d` as datetime))
EXPLAIN SELECT * from dt_t ORDER BY dt = d;
id	select_type	table	partitions	type	possible_keys	key	key_len	ref	rows	filtered	Extra
1	SIMPLE	dt_t	NULL	ALL	NULL	NULL	NULL	NULL	1	100.00	Using filesort
Warnings:
Note	1003	/* select#1 */ select `test`.`dt_t`.`dt` AS `dt`,`test`.`dt_t`.`d` AS `d`,`test`.`dt_t`.`t` AS `t` from `test`.`dt_t` order by (`test`.`dt_t`.`dt` = cast(`test`.`dt_t`.`d` as datetime))
EXPLAIN SELECT d=t, LEAD(d,1) OVER w FROM dt_t WINDOW w AS (ORDER BY d=t);
id	select_type	table	partitions	type	possible_keys	key	key_len	ref	rows	filtered	Extra
1	SIMPLE	dt_t	NULL	ALL	NULL	NULL	NULL	NULL	1	100.00	Using filesort
Warnings:
Note	3598	To get information about window functions use EXPLAIN FORMAT=JSON
Note	1003	/* select#1 */ select (cast(`test`.`dt_t`.`d` as datetime) = cast(`test`.`dt_t`.`t` as datetime)) AS `d=t`,lead(`test`.`dt_t`.`d`,1) OVER `w` AS `LEAD(d,1) OVER w` from `test`.`dt_t` window `w` AS (ORDER BY (cast(`test`.`dt_t`.`d` as datetime) = cast(`test`.`dt_t`.`t` as datetime)) ) 
EXPLAIN SELECT LEAD(d,1) OVER w FROM dt_t WINDOW w AS (ORDER BY d=t);
id	select_type	table	partitions	type	possible_keys	key	key_len	ref	rows	filtered	Extra
1	SIMPLE	dt_t	NULL	ALL	NULL	NULL	NULL	NULL	1	100.00	Using filesort
Warnings:
Note	3598	To get information about window functions use EXPLAIN FORMAT=JSON
Note	1003	/* select#1 */ select lead(`test`.`dt_t`.`d`,1) OVER `w` AS `LEAD(d,1) OVER w` from `test`.`dt_t` window `w` AS (ORDER BY (cast(`test`.`dt_t`.`d` as datetime) = cast(`test`.`dt_t`.`t` as datetime)) ) 
DROP TABLE dt_t, n_t;
CREATE TABLE t1 (spID int, userID int, date date);
INSERT INTO t1 VALUES (1,1,'1998-01-01');
INSERT INTO t1 VALUES (2,2,'2001-02-03');
INSERT INTO t1 VALUES (3,1,'1988-12-20');
INSERT INTO t1 VALUES (4,2,'1972-12-12');
EXPLAIN SELECT MIN(t1.userID) = MIN(date) FROM t1  GROUP BY userid;
id	select_type	table	partitions	type	possible_keys	key	key_len	ref	rows	filtered	Extra
1	SIMPLE	t1	NULL	ALL	NULL	NULL	NULL	NULL	4	100.00	Using temporary
Warnings:
Note	1003	/* select#1 */ select (cast(min(`test`.`t1`.`userID`) as double) = cast(min(`test`.`t1`.`date`) as double)) AS `MIN(t1.userID) = MIN(date)` from `test`.`t1` group by `test`.`t1`.`userID`
EXPLAIN SELECT FIRST_VALUE(date) OVER (ORDER BY spID = date) FROM t1;
id	select_type	table	partitions	type	possible_keys	key	key_len	ref	rows	filtered	Extra
1	SIMPLE	t1	NULL	ALL	NULL	NULL	NULL	NULL	4	100.00	Using filesort
Warnings:
Note	3598	To get information about window functions use EXPLAIN FORMAT=JSON
Note	1003	/* select#1 */ select first_value(`test`.`t1`.`date`) OVER (ORDER BY (cast(`test`.`t1`.`spID` as double) = cast(`test`.`t1`.`date` as double)) )  AS `FIRST_VALUE(date) OVER (ORDER BY spID = date)` from `test`.`t1`
EXPLAIN SELECT date, spid = FIRST_VALUE(date) OVER (ORDER BY date ) FROM t1;
id	select_type	table	partitions	type	possible_keys	key	key_len	ref	rows	filtered	Extra
1	SIMPLE	t1	NULL	ALL	NULL	NULL	NULL	NULL	4	100.00	Using filesort
Warnings:
Note	3598	To get information about window functions use EXPLAIN FORMAT=JSON
Note	1003	/* select#1 */ select `test`.`t1`.`date` AS `date`,(cast(`test`.`t1`.`spid` as double) = cast(first_value(`test`.`t1`.`date`) OVER (ORDER BY `test`.`t1`.`date` )  as double)) AS `spid = FIRST_VALUE(date) OVER (ORDER BY date )` from `test`.`t1`
#
# No casts when constants or constant functions are involved
#
EXPLAIN SELECT * from t1 WHERE userID = DATE'2012-02-20';
id	select_type	table	partitions	type	possible_keys	key	key_len	ref	rows	filtered	Extra
1	SIMPLE	t1	NULL	ALL	NULL	NULL	NULL	NULL	4	25.00	Using where
Warnings:
Note	1003	/* select#1 */ select `test`.`t1`.`spID` AS `spID`,`test`.`t1`.`userID` AS `userID`,`test`.`t1`.`date` AS `date` from `test`.`t1` where (`test`.`t1`.`userID` = DATE'2012-02-20')
EXPLAIN SELECT * FROM t1 WHERE date = NULL;
id	select_type	table	partitions	type	possible_keys	key	key_len	ref	rows	filtered	Extra
1	SIMPLE	t1	NULL	ALL	NULL	NULL	NULL	NULL	4	25.00	Using where
Warnings:
Note	1003	/* select#1 */ select `test`.`t1`.`spID` AS `spID`,`test`.`t1`.`userID` AS `userID`,`test`.`t1`.`date` AS `date` from `test`.`t1` where (`test`.`t1`.`date` = NULL)
EXPLAIN SELECT * FROM t1 WHERE date = CAST('20:21:22' AS TIME);
id	select_type	table	partitions	type	possible_keys	key	key_len	ref	rows	filtered	Extra
1	SIMPLE	t1	NULL	ALL	NULL	NULL	NULL	NULL	4	25.00	Using where
Warnings:
Note	1003	/* select#1 */ select `test`.`t1`.`spID` AS `spID`,`test`.`t1`.`userID` AS `userID`,`test`.`t1`.`date` AS `date` from `test`.`t1` where (`test`.`t1`.`date` = <cache>(cast('20:21:22' as time)))
DROP TABLE t1;
#
# WL#13456: Inject CAST nodes for comparisons with STRING non-const expressions. 
# 
CREATE TABLE t(c CHAR(64), v VARCHAR(256), txt TEXT, b BINARY(64), vb VARBINARY(32),
e ENUM ("v1", "v2"), set1 SET('101', '102'), bl  BLOB, i INT,
si SMALLINT, ti TINYINT, mi MEDIUMINT, bi BIGINT, bt BIT,
d DECIMAL, f FLOAT, dbl DOUBLE, dt DATETIME, dd  DATE, t TIME,
y YEAR);
INSERT INTO t
VALUES ("char", "vchar","text", "binary", "varbinary", "v1", '101,102', "blob", 
2001, 2, 3, 4, 200000002, 0x01, 2001.0, 2001.0, 2001.2,
"2001-01-02 22:00", "2001-01-02", "20:01", 2010);
# String vs INT
EXPLAIN SELECT v = i FROM t;
id	select_type	table	partitions	type	possible_keys	key	key_len	ref	rows	filtered	Extra
1	SIMPLE	t	NULL	ALL	NULL	NULL	NULL	NULL	1	100.00	NULL
Warnings:
Note	1003	/* select#1 */ select (cast(`test`.`t`.`v` as double) = cast(`test`.`t`.`i` as double)) AS `v = i` from `test`.`t`
# String vs SMALLINT
EXPLAIN SELECT v = si FROM t;
id	select_type	table	partitions	type	possible_keys	key	key_len	ref	rows	filtered	Extra
1	SIMPLE	t	NULL	ALL	NULL	NULL	NULL	NULL	1	100.00	NULL
Warnings:
Note	1003	/* select#1 */ select (cast(`test`.`t`.`v` as double) = cast(`test`.`t`.`si` as double)) AS `v = si` from `test`.`t`
# String vs TINYINT
EXPLAIN SELECT v = ti FROM t;
id	select_type	table	partitions	type	possible_keys	key	key_len	ref	rows	filtered	Extra
1	SIMPLE	t	NULL	ALL	NULL	NULL	NULL	NULL	1	100.00	NULL
Warnings:
Note	1003	/* select#1 */ select (cast(`test`.`t`.`v` as double) = cast(`test`.`t`.`ti` as double)) AS `v = ti` from `test`.`t`
# String vs MEDIUMINT
EXPLAIN SELECT v = mi FROM t;
id	select_type	table	partitions	type	possible_keys	key	key_len	ref	rows	filtered	Extra
1	SIMPLE	t	NULL	ALL	NULL	NULL	NULL	NULL	1	100.00	NULL
Warnings:
Note	1003	/* select#1 */ select (cast(`test`.`t`.`v` as double) = cast(`test`.`t`.`mi` as double)) AS `v = mi` from `test`.`t`
# String vs BIGINT
EXPLAIN SELECT v = bi FROM t;
id	select_type	table	partitions	type	possible_keys	key	key_len	ref	rows	filtered	Extra
1	SIMPLE	t	NULL	ALL	NULL	NULL	NULL	NULL	1	100.00	NULL
Warnings:
Note	1003	/* select#1 */ select (cast(`test`.`t`.`v` as double) = cast(`test`.`t`.`bi` as double)) AS `v = bi` from `test`.`t`
# String vs BIT
EXPLAIN SELECT v = bt FROM t;
id	select_type	table	partitions	type	possible_keys	key	key_len	ref	rows	filtered	Extra
1	SIMPLE	t	NULL	ALL	NULL	NULL	NULL	NULL	1	100.00	NULL
Warnings:
Note	1003	/* select#1 */ select (cast(`test`.`t`.`v` as double) = cast(`test`.`t`.`bt` as double)) AS `v = bt` from `test`.`t`
# String vs YEAR
EXPLAIN SELECT v = y FROM t;
id	select_type	table	partitions	type	possible_keys	key	key_len	ref	rows	filtered	Extra
1	SIMPLE	t	NULL	ALL	NULL	NULL	NULL	NULL	1	100.00	NULL
Warnings:
Note	1003	/* select#1 */ select (cast(`test`.`t`.`v` as double) = cast(`test`.`t`.`y` as double)) AS `v = y` from `test`.`t`
# String vs DECIMAL 
EXPLAIN SELECT v = d FROM t;
id	select_type	table	partitions	type	possible_keys	key	key_len	ref	rows	filtered	Extra
1	SIMPLE	t	NULL	ALL	NULL	NULL	NULL	NULL	1	100.00	NULL
Warnings:
Note	1003	/* select#1 */ select (cast(`test`.`t`.`v` as double) = cast(`test`.`t`.`d` as double)) AS `v = d` from `test`.`t`
# String vs FLOAT 
EXPLAIN SELECT v = f FROM t;
id	select_type	table	partitions	type	possible_keys	key	key_len	ref	rows	filtered	Extra
1	SIMPLE	t	NULL	ALL	NULL	NULL	NULL	NULL	1	100.00	NULL
Warnings:
Note	1003	/* select#1 */ select (cast(`test`.`t`.`v` as double) = `test`.`t`.`f`) AS `v = f` from `test`.`t`
# String vs DOUBLE
EXPLAIN SELECT v = dbl FROM t;
id	select_type	table	partitions	type	possible_keys	key	key_len	ref	rows	filtered	Extra
1	SIMPLE	t	NULL	ALL	NULL	NULL	NULL	NULL	1	100.00	NULL
Warnings:
Note	1003	/* select#1 */ select (cast(`test`.`t`.`v` as double) = `test`.`t`.`dbl`) AS `v = dbl` from `test`.`t`
# String vs DATETIME
EXPLAIN SELECT v = dt FROM t;
id	select_type	table	partitions	type	possible_keys	key	key_len	ref	rows	filtered	Extra
1	SIMPLE	t	NULL	ALL	NULL	NULL	NULL	NULL	1	100.00	NULL
Warnings:
Note	1003	/* select#1 */ select (cast(`test`.`t`.`v` as datetime(6)) = `test`.`t`.`dt`) AS `v = dt` from `test`.`t`
# String vs DATE
EXPLAIN SELECT v = dd FROM t;
id	select_type	table	partitions	type	possible_keys	key	key_len	ref	rows	filtered	Extra
1	SIMPLE	t	NULL	ALL	NULL	NULL	NULL	NULL	1	100.00	NULL
Warnings:
Note	1003	/* select#1 */ select (cast(`test`.`t`.`v` as date) = `test`.`t`.`dd`) AS `v = dd` from `test`.`t`
# String vs TIME
EXPLAIN SELECT v = t FROM t;
id	select_type	table	partitions	type	possible_keys	key	key_len	ref	rows	filtered	Extra
1	SIMPLE	t	NULL	ALL	NULL	NULL	NULL	NULL	1	100.00	NULL
Warnings:
Note	1003	/* select#1 */ select (`test`.`t`.`v` = `test`.`t`.`t`) AS `v = t` from `test`.`t`
# String vs another equality 
EXPLAIN SELECT v = (v = y) FROM t;
id	select_type	table	partitions	type	possible_keys	key	key_len	ref	rows	filtered	Extra
1	SIMPLE	t	NULL	ALL	NULL	NULL	NULL	NULL	1	100.00	NULL
Warnings:
Note	1003	/* select#1 */ select (cast(`test`.`t`.`v` as double) = cast((cast(`test`.`t`.`v` as double) = cast(`test`.`t`.`y` as double)) as double)) AS `v = (v = y)` from `test`.`t`
# String vs expression
EXPLAIN SELECT v = 1 * i FROM t;
id	select_type	table	partitions	type	possible_keys	key	key_len	ref	rows	filtered	Extra
1	SIMPLE	t	NULL	ALL	NULL	NULL	NULL	NULL	1	100.00	NULL
Warnings:
Note	1003	/* select#1 */ select (cast(`test`.`t`.`v` as double) = cast((1 * `test`.`t`.`i`) as double)) AS `v = 1 * i` from `test`.`t`
# Other operators
EXPLAIN SELECT v <=> i FROM t;
id	select_type	table	partitions	type	possible_keys	key	key_len	ref	rows	filtered	Extra
1	SIMPLE	t	NULL	ALL	NULL	NULL	NULL	NULL	1	100.00	NULL
Warnings:
Note	1003	/* select#1 */ select (cast(`test`.`t`.`v` as double) <=> cast(`test`.`t`.`i` as double)) AS `v <=> i` from `test`.`t`
EXPLAIN SELECT v <> i FROM t;
id	select_type	table	partitions	type	possible_keys	key	key_len	ref	rows	filtered	Extra
1	SIMPLE	t	NULL	ALL	NULL	NULL	NULL	NULL	1	100.00	NULL
Warnings:
Note	1003	/* select#1 */ select (cast(`test`.`t`.`v` as double) <> cast(`test`.`t`.`i` as double)) AS `v <> i` from `test`.`t`
EXPLAIN SELECT v > i FROM t;
id	select_type	table	partitions	type	possible_keys	key	key_len	ref	rows	filtered	Extra
1	SIMPLE	t	NULL	ALL	NULL	NULL	NULL	NULL	1	100.00	NULL
Warnings:
Note	1003	/* select#1 */ select (cast(`test`.`t`.`v` as double) > cast(`test`.`t`.`i` as double)) AS `v > i` from `test`.`t`
EXPLAIN SELECT v >= i FROM t;
id	select_type	table	partitions	type	possible_keys	key	key_len	ref	rows	filtered	Extra
1	SIMPLE	t	NULL	ALL	NULL	NULL	NULL	NULL	1	100.00	NULL
Warnings:
Note	1003	/* select#1 */ select (cast(`test`.`t`.`v` as double) >= cast(`test`.`t`.`i` as double)) AS `v >= i` from `test`.`t`
EXPLAIN SELECT v <= i FROM t;
id	select_type	table	partitions	type	possible_keys	key	key_len	ref	rows	filtered	Extra
1	SIMPLE	t	NULL	ALL	NULL	NULL	NULL	NULL	1	100.00	NULL
Warnings:
Note	1003	/* select#1 */ select (cast(`test`.`t`.`v` as double) <= cast(`test`.`t`.`i` as double)) AS `v <= i` from `test`.`t`
EXPLAIN SELECT v < i FROM t;
id	select_type	table	partitions	type	possible_keys	key	key_len	ref	rows	filtered	Extra
1	SIMPLE	t	NULL	ALL	NULL	NULL	NULL	NULL	1	100.00	NULL
Warnings:
Note	1003	/* select#1 */ select (cast(`test`.`t`.`v` as double) < cast(`test`.`t`.`i` as double)) AS `v < i` from `test`.`t`
# Test data type combinations
EXPLAIN SELECT c = i FROM t;
id	select_type	table	partitions	type	possible_keys	key	key_len	ref	rows	filtered	Extra
1	SIMPLE	t	NULL	ALL	NULL	NULL	NULL	NULL	1	100.00	NULL
Warnings:
Note	1003	/* select#1 */ select (cast(`test`.`t`.`c` as double) = cast(`test`.`t`.`i` as double)) AS `c = i` from `test`.`t`
EXPLAIN SELECT c = si FROM t;
id	select_type	table	partitions	type	possible_keys	key	key_len	ref	rows	filtered	Extra
1	SIMPLE	t	NULL	ALL	NULL	NULL	NULL	NULL	1	100.00	NULL
Warnings:
Note	1003	/* select#1 */ select (cast(`test`.`t`.`c` as double) = cast(`test`.`t`.`si` as double)) AS `c = si` from `test`.`t`
EXPLAIN SELECT c = ti FROM t;
id	select_type	table	partitions	type	possible_keys	key	key_len	ref	rows	filtered	Extra
1	SIMPLE	t	NULL	ALL	NULL	NULL	NULL	NULL	1	100.00	NULL
Warnings:
Note	1003	/* select#1 */ select (cast(`test`.`t`.`c` as double) = cast(`test`.`t`.`ti` as double)) AS `c = ti` from `test`.`t`
EXPLAIN SELECT c = mi FROM t;
id	select_type	table	partitions	type	possible_keys	key	key_len	ref	rows	filtered	Extra
1	SIMPLE	t	NULL	ALL	NULL	NULL	NULL	NULL	1	100.00	NULL
Warnings:
Note	1003	/* select#1 */ select (cast(`test`.`t`.`c` as double) = cast(`test`.`t`.`mi` as double)) AS `c = mi` from `test`.`t`
EXPLAIN SELECT c = bi FROM t;
id	select_type	table	partitions	type	possible_keys	key	key_len	ref	rows	filtered	Extra
1	SIMPLE	t	NULL	ALL	NULL	NULL	NULL	NULL	1	100.00	NULL
Warnings:
Note	1003	/* select#1 */ select (cast(`test`.`t`.`c` as double) = cast(`test`.`t`.`bi` as double)) AS `c = bi` from `test`.`t`
EXPLAIN SELECT c = bt FROM t;
id	select_type	table	partitions	type	possible_keys	key	key_len	ref	rows	filtered	Extra
1	SIMPLE	t	NULL	ALL	NULL	NULL	NULL	NULL	1	100.00	NULL
Warnings:
Note	1003	/* select#1 */ select (cast(`test`.`t`.`c` as double) = cast(`test`.`t`.`bt` as double)) AS `c = bt` from `test`.`t`
EXPLAIN SELECT c = y FROM t;
id	select_type	table	partitions	type	possible_keys	key	key_len	ref	rows	filtered	Extra
1	SIMPLE	t	NULL	ALL	NULL	NULL	NULL	NULL	1	100.00	NULL
Warnings:
Note	1003	/* select#1 */ select (cast(`test`.`t`.`c` as double) = cast(`test`.`t`.`y` as double)) AS `c = y` from `test`.`t`
EXPLAIN SELECT c = d FROM t;
id	select_type	table	partitions	type	possible_keys	key	key_len	ref	rows	filtered	Extra
1	SIMPLE	t	NULL	ALL	NULL	NULL	NULL	NULL	1	100.00	NULL
Warnings:
Note	1003	/* select#1 */ select (cast(`test`.`t`.`c` as double) = cast(`test`.`t`.`d` as double)) AS `c = d` from `test`.`t`
EXPLAIN SELECT c = f FROM t;
id	select_type	table	partitions	type	possible_keys	key	key_len	ref	rows	filtered	Extra
1	SIMPLE	t	NULL	ALL	NULL	NULL	NULL	NULL	1	100.00	NULL
Warnings:
Note	1003	/* select#1 */ select (cast(`test`.`t`.`c` as double) = `test`.`t`.`f`) AS `c = f` from `test`.`t`
EXPLAIN SELECT c = dbl FROM t;
id	select_type	table	partitions	type	possible_keys	key	key_len	ref	rows	filtered	Extra
1	SIMPLE	t	NULL	ALL	NULL	NULL	NULL	NULL	1	100.00	NULL
Warnings:
Note	1003	/* select#1 */ select (cast(`test`.`t`.`c` as double) = `test`.`t`.`dbl`) AS `c = dbl` from `test`.`t`
EXPLAIN SELECT c = dt FROM t;
id	select_type	table	partitions	type	possible_keys	key	key_len	ref	rows	filtered	Extra
1	SIMPLE	t	NULL	ALL	NULL	NULL	NULL	NULL	1	100.00	NULL
Warnings:
Note	1003	/* select#1 */ select (cast(`test`.`t`.`c` as datetime(6)) = `test`.`t`.`dt`) AS `c = dt` from `test`.`t`
EXPLAIN SELECT c = dd FROM t;
id	select_type	table	partitions	type	possible_keys	key	key_len	ref	rows	filtered	Extra
1	SIMPLE	t	NULL	ALL	NULL	NULL	NULL	NULL	1	100.00	NULL
Warnings:
Note	1003	/* select#1 */ select (cast(`test`.`t`.`c` as date) = `test`.`t`.`dd`) AS `c = dd` from `test`.`t`
EXPLAIN SELECT c = t FROM t;
id	select_type	table	partitions	type	possible_keys	key	key_len	ref	rows	filtered	Extra
1	SIMPLE	t	NULL	ALL	NULL	NULL	NULL	NULL	1	100.00	NULL
Warnings:
Note	1003	/* select#1 */ select (`test`.`t`.`c` = `test`.`t`.`t`) AS `c = t` from `test`.`t`
EXPLAIN SELECT txt = i FROM t;
id	select_type	table	partitions	type	possible_keys	key	key_len	ref	rows	filtered	Extra
1	SIMPLE	t	NULL	ALL	NULL	NULL	NULL	NULL	1	100.00	NULL
Warnings:
Note	1003	/* select#1 */ select (cast(`test`.`t`.`txt` as double) = cast(`test`.`t`.`i` as double)) AS `txt = i` from `test`.`t`
EXPLAIN SELECT txt = si FROM t;
id	select_type	table	partitions	type	possible_keys	key	key_len	ref	rows	filtered	Extra
1	SIMPLE	t	NULL	ALL	NULL	NULL	NULL	NULL	1	100.00	NULL
Warnings:
Note	1003	/* select#1 */ select (cast(`test`.`t`.`txt` as double) = cast(`test`.`t`.`si` as double)) AS `txt = si` from `test`.`t`
EXPLAIN SELECT txt = ti FROM t;
id	select_type	table	partitions	type	possible_keys	key	key_len	ref	rows	filtered	Extra
1	SIMPLE	t	NULL	ALL	NULL	NULL	NULL	NULL	1	100.00	NULL
Warnings:
Note	1003	/* select#1 */ select (cast(`test`.`t`.`txt` as double) = cast(`test`.`t`.`ti` as double)) AS `txt = ti` from `test`.`t`
EXPLAIN SELECT txt = mi FROM t;
id	select_type	table	partitions	type	possible_keys	key	key_len	ref	rows	filtered	Extra
1	SIMPLE	t	NULL	ALL	NULL	NULL	NULL	NULL	1	100.00	NULL
Warnings:
Note	1003	/* select#1 */ select (cast(`test`.`t`.`txt` as double) = cast(`test`.`t`.`mi` as double)) AS `txt = mi` from `test`.`t`
EXPLAIN SELECT txt = bi FROM t;
id	select_type	table	partitions	type	possible_keys	key	key_len	ref	rows	filtered	Extra
1	SIMPLE	t	NULL	ALL	NULL	NULL	NULL	NULL	1	100.00	NULL
Warnings:
Note	1003	/* select#1 */ select (cast(`test`.`t`.`txt` as double) = cast(`test`.`t`.`bi` as double)) AS `txt = bi` from `test`.`t`
EXPLAIN SELECT txt = bt FROM t;
id	select_type	table	partitions	type	possible_keys	key	key_len	ref	rows	filtered	Extra
1	SIMPLE	t	NULL	ALL	NULL	NULL	NULL	NULL	1	100.00	NULL
Warnings:
Note	1003	/* select#1 */ select (cast(`test`.`t`.`txt` as double) = cast(`test`.`t`.`bt` as double)) AS `txt = bt` from `test`.`t`
EXPLAIN SELECT txt = y FROM t;
id	select_type	table	partitions	type	possible_keys	key	key_len	ref	rows	filtered	Extra
1	SIMPLE	t	NULL	ALL	NULL	NULL	NULL	NULL	1	100.00	NULL
Warnings:
Note	1003	/* select#1 */ select (cast(`test`.`t`.`txt` as double) = cast(`test`.`t`.`y` as double)) AS `txt = y` from `test`.`t`
EXPLAIN SELECT txt = d FROM t;
id	select_type	table	partitions	type	possible_keys	key	key_len	ref	rows	filtered	Extra
1	SIMPLE	t	NULL	ALL	NULL	NULL	NULL	NULL	1	100.00	NULL
Warnings:
Note	1003	/* select#1 */ select (cast(`test`.`t`.`txt` as double) = cast(`test`.`t`.`d` as double)) AS `txt = d` from `test`.`t`
EXPLAIN SELECT txt = f FROM t;
id	select_type	table	partitions	type	possible_keys	key	key_len	ref	rows	filtered	Extra
1	SIMPLE	t	NULL	ALL	NULL	NULL	NULL	NULL	1	100.00	NULL
Warnings:
Note	1003	/* select#1 */ select (cast(`test`.`t`.`txt` as double) = `test`.`t`.`f`) AS `txt = f` from `test`.`t`
EXPLAIN SELECT txt = dbl FROM t;
id	select_type	table	partitions	type	possible_keys	key	key_len	ref	rows	filtered	Extra
1	SIMPLE	t	NULL	ALL	NULL	NULL	NULL	NULL	1	100.00	NULL
Warnings:
Note	1003	/* select#1 */ select (cast(`test`.`t`.`txt` as double) = `test`.`t`.`dbl`) AS `txt = dbl` from `test`.`t`
EXPLAIN SELECT txt = dt FROM t;
id	select_type	table	partitions	type	possible_keys	key	key_len	ref	rows	filtered	Extra
1	SIMPLE	t	NULL	ALL	NULL	NULL	NULL	NULL	1	100.00	NULL
Warnings:
Note	1003	/* select#1 */ select (cast(`test`.`t`.`txt` as datetime(6)) = `test`.`t`.`dt`) AS `txt = dt` from `test`.`t`
EXPLAIN SELECT txt = dd FROM t;
id	select_type	table	partitions	type	possible_keys	key	key_len	ref	rows	filtered	Extra
1	SIMPLE	t	NULL	ALL	NULL	NULL	NULL	NULL	1	100.00	NULL
Warnings:
Note	1003	/* select#1 */ select (cast(`test`.`t`.`txt` as date) = `test`.`t`.`dd`) AS `txt = dd` from `test`.`t`
EXPLAIN SELECT txt = t FROM t;
id	select_type	table	partitions	type	possible_keys	key	key_len	ref	rows	filtered	Extra
1	SIMPLE	t	NULL	ALL	NULL	NULL	NULL	NULL	1	100.00	NULL
Warnings:
Note	1003	/* select#1 */ select (`test`.`t`.`txt` = `test`.`t`.`t`) AS `txt = t` from `test`.`t`
EXPLAIN SELECT b = i FROM t;
id	select_type	table	partitions	type	possible_keys	key	key_len	ref	rows	filtered	Extra
1	SIMPLE	t	NULL	ALL	NULL	NULL	NULL	NULL	1	100.00	NULL
Warnings:
Note	1003	/* select#1 */ select (cast(`test`.`t`.`b` as double) = cast(`test`.`t`.`i` as double)) AS `b = i` from `test`.`t`
EXPLAIN SELECT b = si FROM t;
id	select_type	table	partitions	type	possible_keys	key	key_len	ref	rows	filtered	Extra
1	SIMPLE	t	NULL	ALL	NULL	NULL	NULL	NULL	1	100.00	NULL
Warnings:
Note	1003	/* select#1 */ select (cast(`test`.`t`.`b` as double) = cast(`test`.`t`.`si` as double)) AS `b = si` from `test`.`t`
EXPLAIN SELECT b = ti FROM t;
id	select_type	table	partitions	type	possible_keys	key	key_len	ref	rows	filtered	Extra
1	SIMPLE	t	NULL	ALL	NULL	NULL	NULL	NULL	1	100.00	NULL
Warnings:
Note	1003	/* select#1 */ select (cast(`test`.`t`.`b` as double) = cast(`test`.`t`.`ti` as double)) AS `b = ti` from `test`.`t`
EXPLAIN SELECT b = mi FROM t;
id	select_type	table	partitions	type	possible_keys	key	key_len	ref	rows	filtered	Extra
1	SIMPLE	t	NULL	ALL	NULL	NULL	NULL	NULL	1	100.00	NULL
Warnings:
Note	1003	/* select#1 */ select (cast(`test`.`t`.`b` as double) = cast(`test`.`t`.`mi` as double)) AS `b = mi` from `test`.`t`
EXPLAIN SELECT b = bi FROM t;
id	select_type	table	partitions	type	possible_keys	key	key_len	ref	rows	filtered	Extra
1	SIMPLE	t	NULL	ALL	NULL	NULL	NULL	NULL	1	100.00	NULL
Warnings:
Note	1003	/* select#1 */ select (cast(`test`.`t`.`b` as double) = cast(`test`.`t`.`bi` as double)) AS `b = bi` from `test`.`t`
EXPLAIN SELECT b = bt FROM t;
id	select_type	table	partitions	type	possible_keys	key	key_len	ref	rows	filtered	Extra
1	SIMPLE	t	NULL	ALL	NULL	NULL	NULL	NULL	1	100.00	NULL
Warnings:
Note	1003	/* select#1 */ select (cast(`test`.`t`.`b` as double) = cast(`test`.`t`.`bt` as double)) AS `b = bt` from `test`.`t`
EXPLAIN SELECT b = y FROM t;
id	select_type	table	partitions	type	possible_keys	key	key_len	ref	rows	filtered	Extra
1	SIMPLE	t	NULL	ALL	NULL	NULL	NULL	NULL	1	100.00	NULL
Warnings:
Note	1003	/* select#1 */ select (cast(`test`.`t`.`b` as double) = cast(`test`.`t`.`y` as double)) AS `b = y` from `test`.`t`
EXPLAIN SELECT b = d FROM t;
id	select_type	table	partitions	type	possible_keys	key	key_len	ref	rows	filtered	Extra
1	SIMPLE	t	NULL	ALL	NULL	NULL	NULL	NULL	1	100.00	NULL
Warnings:
Note	1003	/* select#1 */ select (cast(`test`.`t`.`b` as double) = cast(`test`.`t`.`d` as double)) AS `b = d` from `test`.`t`
EXPLAIN SELECT b = f FROM t;
id	select_type	table	partitions	type	possible_keys	key	key_len	ref	rows	filtered	Extra
1	SIMPLE	t	NULL	ALL	NULL	NULL	NULL	NULL	1	100.00	NULL
Warnings:
Note	1003	/* select#1 */ select (cast(`test`.`t`.`b` as double) = `test`.`t`.`f`) AS `b = f` from `test`.`t`
EXPLAIN SELECT b = dbl FROM t;
id	select_type	table	partitions	type	possible_keys	key	key_len	ref	rows	filtered	Extra
1	SIMPLE	t	NULL	ALL	NULL	NULL	NULL	NULL	1	100.00	NULL
Warnings:
Note	1003	/* select#1 */ select (cast(`test`.`t`.`b` as double) = `test`.`t`.`dbl`) AS `b = dbl` from `test`.`t`
EXPLAIN SELECT b = dt FROM t;
id	select_type	table	partitions	type	possible_keys	key	key_len	ref	rows	filtered	Extra
1	SIMPLE	t	NULL	ALL	NULL	NULL	NULL	NULL	1	100.00	NULL
Warnings:
Note	1003	/* select#1 */ select (cast(`test`.`t`.`b` as datetime(6)) = `test`.`t`.`dt`) AS `b = dt` from `test`.`t`
EXPLAIN SELECT b = dd FROM t;
id	select_type	table	partitions	type	possible_keys	key	key_len	ref	rows	filtered	Extra
1	SIMPLE	t	NULL	ALL	NULL	NULL	NULL	NULL	1	100.00	NULL
Warnings:
Note	1003	/* select#1 */ select (cast(`test`.`t`.`b` as date) = `test`.`t`.`dd`) AS `b = dd` from `test`.`t`
EXPLAIN SELECT b = t FROM t;
id	select_type	table	partitions	type	possible_keys	key	key_len	ref	rows	filtered	Extra
1	SIMPLE	t	NULL	ALL	NULL	NULL	NULL	NULL	1	100.00	NULL
Warnings:
Note	1003	/* select#1 */ select (`test`.`t`.`b` = `test`.`t`.`t`) AS `b = t` from `test`.`t`
EXPLAIN SELECT vb = i FROM t;
id	select_type	table	partitions	type	possible_keys	key	key_len	ref	rows	filtered	Extra
1	SIMPLE	t	NULL	ALL	NULL	NULL	NULL	NULL	1	100.00	NULL
Warnings:
Note	1003	/* select#1 */ select (cast(`test`.`t`.`vb` as double) = cast(`test`.`t`.`i` as double)) AS `vb = i` from `test`.`t`
EXPLAIN SELECT vb = si FROM t;
id	select_type	table	partitions	type	possible_keys	key	key_len	ref	rows	filtered	Extra
1	SIMPLE	t	NULL	ALL	NULL	NULL	NULL	NULL	1	100.00	NULL
Warnings:
Note	1003	/* select#1 */ select (cast(`test`.`t`.`vb` as double) = cast(`test`.`t`.`si` as double)) AS `vb = si` from `test`.`t`
EXPLAIN SELECT vb = ti FROM t;
id	select_type	table	partitions	type	possible_keys	key	key_len	ref	rows	filtered	Extra
1	SIMPLE	t	NULL	ALL	NULL	NULL	NULL	NULL	1	100.00	NULL
Warnings:
Note	1003	/* select#1 */ select (cast(`test`.`t`.`vb` as double) = cast(`test`.`t`.`ti` as double)) AS `vb = ti` from `test`.`t`
EXPLAIN SELECT vb = mi FROM t;
id	select_type	table	partitions	type	possible_keys	key	key_len	ref	rows	filtered	Extra
1	SIMPLE	t	NULL	ALL	NULL	NULL	NULL	NULL	1	100.00	NULL
Warnings:
Note	1003	/* select#1 */ select (cast(`test`.`t`.`vb` as double) = cast(`test`.`t`.`mi` as double)) AS `vb = mi` from `test`.`t`
EXPLAIN SELECT vb = bi FROM t;
id	select_type	table	partitions	type	possible_keys	key	key_len	ref	rows	filtered	Extra
1	SIMPLE	t	NULL	ALL	NULL	NULL	NULL	NULL	1	100.00	NULL
Warnings:
Note	1003	/* select#1 */ select (cast(`test`.`t`.`vb` as double) = cast(`test`.`t`.`bi` as double)) AS `vb = bi` from `test`.`t`
EXPLAIN SELECT vb = bt FROM t;
id	select_type	table	partitions	type	possible_keys	key	key_len	ref	rows	filtered	Extra
1	SIMPLE	t	NULL	ALL	NULL	NULL	NULL	NULL	1	100.00	NULL
Warnings:
Note	1003	/* select#1 */ select (cast(`test`.`t`.`vb` as double) = cast(`test`.`t`.`bt` as double)) AS `vb = bt` from `test`.`t`
EXPLAIN SELECT vb = y FROM t;
id	select_type	table	partitions	type	possible_keys	key	key_len	ref	rows	filtered	Extra
1	SIMPLE	t	NULL	ALL	NULL	NULL	NULL	NULL	1	100.00	NULL
Warnings:
Note	1003	/* select#1 */ select (cast(`test`.`t`.`vb` as double) = cast(`test`.`t`.`y` as double)) AS `vb = y` from `test`.`t`
EXPLAIN SELECT vb = d FROM t;
id	select_type	table	partitions	type	possible_keys	key	key_len	ref	rows	filtered	Extra
1	SIMPLE	t	NULL	ALL	NULL	NULL	NULL	NULL	1	100.00	NULL
Warnings:
Note	1003	/* select#1 */ select (cast(`test`.`t`.`vb` as double) = cast(`test`.`t`.`d` as double)) AS `vb = d` from `test`.`t`
EXPLAIN SELECT vb = f FROM t;
id	select_type	table	partitions	type	possible_keys	key	key_len	ref	rows	filtered	Extra
1	SIMPLE	t	NULL	ALL	NULL	NULL	NULL	NULL	1	100.00	NULL
Warnings:
Note	1003	/* select#1 */ select (cast(`test`.`t`.`vb` as double) = `test`.`t`.`f`) AS `vb = f` from `test`.`t`
EXPLAIN SELECT vb = dbl FROM t;
id	select_type	table	partitions	type	possible_keys	key	key_len	ref	rows	filtered	Extra
1	SIMPLE	t	NULL	ALL	NULL	NULL	NULL	NULL	1	100.00	NULL
Warnings:
Note	1003	/* select#1 */ select (cast(`test`.`t`.`vb` as double) = `test`.`t`.`dbl`) AS `vb = dbl` from `test`.`t`
EXPLAIN SELECT vb = dt FROM t;
id	select_type	table	partitions	type	possible_keys	key	key_len	ref	rows	filtered	Extra
1	SIMPLE	t	NULL	ALL	NULL	NULL	NULL	NULL	1	100.00	NULL
Warnings:
Note	1003	/* select#1 */ select (cast(`test`.`t`.`vb` as datetime(6)) = `test`.`t`.`dt`) AS `vb = dt` from `test`.`t`
EXPLAIN SELECT vb = dd FROM t;
id	select_type	table	partitions	type	possible_keys	key	key_len	ref	rows	filtered	Extra
1	SIMPLE	t	NULL	ALL	NULL	NULL	NULL	NULL	1	100.00	NULL
Warnings:
Note	1003	/* select#1 */ select (cast(`test`.`t`.`vb` as date) = `test`.`t`.`dd`) AS `vb = dd` from `test`.`t`
EXPLAIN SELECT vb = t FROM t;
id	select_type	table	partitions	type	possible_keys	key	key_len	ref	rows	filtered	Extra
1	SIMPLE	t	NULL	ALL	NULL	NULL	NULL	NULL	1	100.00	NULL
Warnings:
Note	1003	/* select#1 */ select (`test`.`t`.`vb` = `test`.`t`.`t`) AS `vb = t` from `test`.`t`
EXPLAIN SELECT e = i FROM t;
id	select_type	table	partitions	type	possible_keys	key	key_len	ref	rows	filtered	Extra
1	SIMPLE	t	NULL	ALL	NULL	NULL	NULL	NULL	1	100.00	NULL
Warnings:
Note	1003	/* select#1 */ select (cast(`test`.`t`.`e` as double) = cast(`test`.`t`.`i` as double)) AS `e = i` from `test`.`t`
EXPLAIN SELECT e = si FROM t;
id	select_type	table	partitions	type	possible_keys	key	key_len	ref	rows	filtered	Extra
1	SIMPLE	t	NULL	ALL	NULL	NULL	NULL	NULL	1	100.00	NULL
Warnings:
Note	1003	/* select#1 */ select (cast(`test`.`t`.`e` as double) = cast(`test`.`t`.`si` as double)) AS `e = si` from `test`.`t`
EXPLAIN SELECT e = ti FROM t;
id	select_type	table	partitions	type	possible_keys	key	key_len	ref	rows	filtered	Extra
1	SIMPLE	t	NULL	ALL	NULL	NULL	NULL	NULL	1	100.00	NULL
Warnings:
Note	1003	/* select#1 */ select (cast(`test`.`t`.`e` as double) = cast(`test`.`t`.`ti` as double)) AS `e = ti` from `test`.`t`
EXPLAIN SELECT e = mi FROM t;
id	select_type	table	partitions	type	possible_keys	key	key_len	ref	rows	filtered	Extra
1	SIMPLE	t	NULL	ALL	NULL	NULL	NULL	NULL	1	100.00	NULL
Warnings:
Note	1003	/* select#1 */ select (cast(`test`.`t`.`e` as double) = cast(`test`.`t`.`mi` as double)) AS `e = mi` from `test`.`t`
EXPLAIN SELECT e = bi FROM t;
id	select_type	table	partitions	type	possible_keys	key	key_len	ref	rows	filtered	Extra
1	SIMPLE	t	NULL	ALL	NULL	NULL	NULL	NULL	1	100.00	NULL
Warnings:
Note	1003	/* select#1 */ select (cast(`test`.`t`.`e` as double) = cast(`test`.`t`.`bi` as double)) AS `e = bi` from `test`.`t`
EXPLAIN SELECT e = bt FROM t;
id	select_type	table	partitions	type	possible_keys	key	key_len	ref	rows	filtered	Extra
1	SIMPLE	t	NULL	ALL	NULL	NULL	NULL	NULL	1	100.00	NULL
Warnings:
Note	1003	/* select#1 */ select (cast(`test`.`t`.`e` as double) = cast(`test`.`t`.`bt` as double)) AS `e = bt` from `test`.`t`
EXPLAIN SELECT e = y FROM t;
id	select_type	table	partitions	type	possible_keys	key	key_len	ref	rows	filtered	Extra
1	SIMPLE	t	NULL	ALL	NULL	NULL	NULL	NULL	1	100.00	NULL
Warnings:
Note	1003	/* select#1 */ select (cast(`test`.`t`.`e` as double) = cast(`test`.`t`.`y` as double)) AS `e = y` from `test`.`t`
EXPLAIN SELECT e = d FROM t;
id	select_type	table	partitions	type	possible_keys	key	key_len	ref	rows	filtered	Extra
1	SIMPLE	t	NULL	ALL	NULL	NULL	NULL	NULL	1	100.00	NULL
Warnings:
Note	1003	/* select#1 */ select (cast(`test`.`t`.`e` as double) = cast(`test`.`t`.`d` as double)) AS `e = d` from `test`.`t`
EXPLAIN SELECT e = f FROM t;
id	select_type	table	partitions	type	possible_keys	key	key_len	ref	rows	filtered	Extra
1	SIMPLE	t	NULL	ALL	NULL	NULL	NULL	NULL	1	100.00	NULL
Warnings:
Note	1003	/* select#1 */ select (cast(`test`.`t`.`e` as double) = `test`.`t`.`f`) AS `e = f` from `test`.`t`
EXPLAIN SELECT e = dbl FROM t;
id	select_type	table	partitions	type	possible_keys	key	key_len	ref	rows	filtered	Extra
1	SIMPLE	t	NULL	ALL	NULL	NULL	NULL	NULL	1	100.00	NULL
Warnings:
Note	1003	/* select#1 */ select (cast(`test`.`t`.`e` as double) = `test`.`t`.`dbl`) AS `e = dbl` from `test`.`t`
EXPLAIN SELECT e = dt FROM t;
id	select_type	table	partitions	type	possible_keys	key	key_len	ref	rows	filtered	Extra
1	SIMPLE	t	NULL	ALL	NULL	NULL	NULL	NULL	1	100.00	NULL
Warnings:
Note	1003	/* select#1 */ select (cast(`test`.`t`.`e` as datetime(6)) = `test`.`t`.`dt`) AS `e = dt` from `test`.`t`
EXPLAIN SELECT e = dd FROM t;
id	select_type	table	partitions	type	possible_keys	key	key_len	ref	rows	filtered	Extra
1	SIMPLE	t	NULL	ALL	NULL	NULL	NULL	NULL	1	100.00	NULL
Warnings:
Note	1003	/* select#1 */ select (cast(`test`.`t`.`e` as date) = `test`.`t`.`dd`) AS `e = dd` from `test`.`t`
EXPLAIN SELECT e = t FROM t;
id	select_type	table	partitions	type	possible_keys	key	key_len	ref	rows	filtered	Extra
1	SIMPLE	t	NULL	ALL	NULL	NULL	NULL	NULL	1	100.00	NULL
Warnings:
Note	1003	/* select#1 */ select (`test`.`t`.`e` = `test`.`t`.`t`) AS `e = t` from `test`.`t`
EXPLAIN SELECT set1 = i FROM t;
id	select_type	table	partitions	type	possible_keys	key	key_len	ref	rows	filtered	Extra
1	SIMPLE	t	NULL	ALL	NULL	NULL	NULL	NULL	1	100.00	NULL
Warnings:
Note	1003	/* select#1 */ select (cast(`test`.`t`.`set1` as double) = cast(`test`.`t`.`i` as double)) AS `set1 = i` from `test`.`t`
EXPLAIN SELECT set1 = si FROM t;
id	select_type	table	partitions	type	possible_keys	key	key_len	ref	rows	filtered	Extra
1	SIMPLE	t	NULL	ALL	NULL	NULL	NULL	NULL	1	100.00	NULL
Warnings:
Note	1003	/* select#1 */ select (cast(`test`.`t`.`set1` as double) = cast(`test`.`t`.`si` as double)) AS `set1 = si` from `test`.`t`
EXPLAIN SELECT set1 = ti FROM t;
id	select_type	table	partitions	type	possible_keys	key	key_len	ref	rows	filtered	Extra
1	SIMPLE	t	NULL	ALL	NULL	NULL	NULL	NULL	1	100.00	NULL
Warnings:
Note	1003	/* select#1 */ select (cast(`test`.`t`.`set1` as double) = cast(`test`.`t`.`ti` as double)) AS `set1 = ti` from `test`.`t`
EXPLAIN SELECT set1 = mi FROM t;
id	select_type	table	partitions	type	possible_keys	key	key_len	ref	rows	filtered	Extra
1	SIMPLE	t	NULL	ALL	NULL	NULL	NULL	NULL	1	100.00	NULL
Warnings:
Note	1003	/* select#1 */ select (cast(`test`.`t`.`set1` as double) = cast(`test`.`t`.`mi` as double)) AS `set1 = mi` from `test`.`t`
EXPLAIN SELECT set1 = bi FROM t;
id	select_type	table	partitions	type	possible_keys	key	key_len	ref	rows	filtered	Extra
1	SIMPLE	t	NULL	ALL	NULL	NULL	NULL	NULL	1	100.00	NULL
Warnings:
Note	1003	/* select#1 */ select (cast(`test`.`t`.`set1` as double) = cast(`test`.`t`.`bi` as double)) AS `set1 = bi` from `test`.`t`
EXPLAIN SELECT set1 = bt FROM t;
id	select_type	table	partitions	type	possible_keys	key	key_len	ref	rows	filtered	Extra
1	SIMPLE	t	NULL	ALL	NULL	NULL	NULL	NULL	1	100.00	NULL
Warnings:
Note	1003	/* select#1 */ select (cast(`test`.`t`.`set1` as double) = cast(`test`.`t`.`bt` as double)) AS `set1 = bt` from `test`.`t`
EXPLAIN SELECT set1 = y FROM t;
id	select_type	table	partitions	type	possible_keys	key	key_len	ref	rows	filtered	Extra
1	SIMPLE	t	NULL	ALL	NULL	NULL	NULL	NULL	1	100.00	NULL
Warnings:
Note	1003	/* select#1 */ select (cast(`test`.`t`.`set1` as double) = cast(`test`.`t`.`y` as double)) AS `set1 = y` from `test`.`t`
EXPLAIN SELECT set1 = d FROM t;
id	select_type	table	partitions	type	possible_keys	key	key_len	ref	rows	filtered	Extra
1	SIMPLE	t	NULL	ALL	NULL	NULL	NULL	NULL	1	100.00	NULL
Warnings:
Note	1003	/* select#1 */ select (cast(`test`.`t`.`set1` as double) = cast(`test`.`t`.`d` as double)) AS `set1 = d` from `test`.`t`
EXPLAIN SELECT set1 = f FROM t;
id	select_type	table	partitions	type	possible_keys	key	key_len	ref	rows	filtered	Extra
1	SIMPLE	t	NULL	ALL	NULL	NULL	NULL	NULL	1	100.00	NULL
Warnings:
Note	1003	/* select#1 */ select (cast(`test`.`t`.`set1` as double) = `test`.`t`.`f`) AS `set1 = f` from `test`.`t`
EXPLAIN SELECT set1 = dbl FROM t;
id	select_type	table	partitions	type	possible_keys	key	key_len	ref	rows	filtered	Extra
1	SIMPLE	t	NULL	ALL	NULL	NULL	NULL	NULL	1	100.00	NULL
Warnings:
Note	1003	/* select#1 */ select (cast(`test`.`t`.`set1` as double) = `test`.`t`.`dbl`) AS `set1 = dbl` from `test`.`t`
EXPLAIN SELECT set1 = dt FROM t;
id	select_type	table	partitions	type	possible_keys	key	key_len	ref	rows	filtered	Extra
1	SIMPLE	t	NULL	ALL	NULL	NULL	NULL	NULL	1	100.00	NULL
Warnings:
Note	1003	/* select#1 */ select (cast(`test`.`t`.`set1` as datetime(6)) = `test`.`t`.`dt`) AS `set1 = dt` from `test`.`t`
EXPLAIN SELECT set1 = dd FROM t;
id	select_type	table	partitions	type	possible_keys	key	key_len	ref	rows	filtered	Extra
1	SIMPLE	t	NULL	ALL	NULL	NULL	NULL	NULL	1	100.00	NULL
Warnings:
Note	1003	/* select#1 */ select (cast(`test`.`t`.`set1` as date) = `test`.`t`.`dd`) AS `set1 = dd` from `test`.`t`
EXPLAIN SELECT set1 = t FROM t;
id	select_type	table	partitions	type	possible_keys	key	key_len	ref	rows	filtered	Extra
1	SIMPLE	t	NULL	ALL	NULL	NULL	NULL	NULL	1	100.00	NULL
Warnings:
Note	1003	/* select#1 */ select (`test`.`t`.`set1` = `test`.`t`.`t`) AS `set1 = t` from `test`.`t`
EXPLAIN SELECT bl = i FROM t;
id	select_type	table	partitions	type	possible_keys	key	key_len	ref	rows	filtered	Extra
1	SIMPLE	t	NULL	ALL	NULL	NULL	NULL	NULL	1	100.00	NULL
Warnings:
Note	1003	/* select#1 */ select (cast(`test`.`t`.`bl` as double) = cast(`test`.`t`.`i` as double)) AS `bl = i` from `test`.`t`
EXPLAIN SELECT bl = si FROM t;
id	select_type	table	partitions	type	possible_keys	key	key_len	ref	rows	filtered	Extra
1	SIMPLE	t	NULL	ALL	NULL	NULL	NULL	NULL	1	100.00	NULL
Warnings:
Note	1003	/* select#1 */ select (cast(`test`.`t`.`bl` as double) = cast(`test`.`t`.`si` as double)) AS `bl = si` from `test`.`t`
EXPLAIN SELECT bl = ti FROM t;
id	select_type	table	partitions	type	possible_keys	key	key_len	ref	rows	filtered	Extra
1	SIMPLE	t	NULL	ALL	NULL	NULL	NULL	NULL	1	100.00	NULL
Warnings:
Note	1003	/* select#1 */ select (cast(`test`.`t`.`bl` as double) = cast(`test`.`t`.`ti` as double)) AS `bl = ti` from `test`.`t`
EXPLAIN SELECT bl = mi FROM t;
id	select_type	table	partitions	type	possible_keys	key	key_len	ref	rows	filtered	Extra
1	SIMPLE	t	NULL	ALL	NULL	NULL	NULL	NULL	1	100.00	NULL
Warnings:
Note	1003	/* select#1 */ select (cast(`test`.`t`.`bl` as double) = cast(`test`.`t`.`mi` as double)) AS `bl = mi` from `test`.`t`
EXPLAIN SELECT bl = bi FROM t;
id	select_type	table	partitions	type	possible_keys	key	key_len	ref	rows	filtered	Extra
1	SIMPLE	t	NULL	ALL	NULL	NULL	NULL	NULL	1	100.00	NULL
Warnings:
Note	1003	/* select#1 */ select (cast(`test`.`t`.`bl` as double) = cast(`test`.`t`.`bi` as double)) AS `bl = bi` from `test`.`t`
EXPLAIN SELECT bl = bt FROM t;
id	select_type	table	partitions	type	possible_keys	key	key_len	ref	rows	filtered	Extra
1	SIMPLE	t	NULL	ALL	NULL	NULL	NULL	NULL	1	100.00	NULL
Warnings:
Note	1003	/* select#1 */ select (cast(`test`.`t`.`bl` as double) = cast(`test`.`t`.`bt` as double)) AS `bl = bt` from `test`.`t`
EXPLAIN SELECT bl = y FROM t;
id	select_type	table	partitions	type	possible_keys	key	key_len	ref	rows	filtered	Extra
1	SIMPLE	t	NULL	ALL	NULL	NULL	NULL	NULL	1	100.00	NULL
Warnings:
Note	1003	/* select#1 */ select (cast(`test`.`t`.`bl` as double) = cast(`test`.`t`.`y` as double)) AS `bl = y` from `test`.`t`
EXPLAIN SELECT bl = d FROM t;
id	select_type	table	partitions	type	possible_keys	key	key_len	ref	rows	filtered	Extra
1	SIMPLE	t	NULL	ALL	NULL	NULL	NULL	NULL	1	100.00	NULL
Warnings:
Note	1003	/* select#1 */ select (cast(`test`.`t`.`bl` as double) = cast(`test`.`t`.`d` as double)) AS `bl = d` from `test`.`t`
EXPLAIN SELECT bl = f FROM t;
id	select_type	table	partitions	type	possible_keys	key	key_len	ref	rows	filtered	Extra
1	SIMPLE	t	NULL	ALL	NULL	NULL	NULL	NULL	1	100.00	NULL
Warnings:
Note	1003	/* select#1 */ select (cast(`test`.`t`.`bl` as double) = `test`.`t`.`f`) AS `bl = f` from `test`.`t`
EXPLAIN SELECT bl = dbl FROM t;
id	select_type	table	partitions	type	possible_keys	key	key_len	ref	rows	filtered	Extra
1	SIMPLE	t	NULL	ALL	NULL	NULL	NULL	NULL	1	100.00	NULL
Warnings:
Note	1003	/* select#1 */ select (cast(`test`.`t`.`bl` as double) = `test`.`t`.`dbl`) AS `bl = dbl` from `test`.`t`
EXPLAIN SELECT bl = dt FROM t;
id	select_type	table	partitions	type	possible_keys	key	key_len	ref	rows	filtered	Extra
1	SIMPLE	t	NULL	ALL	NULL	NULL	NULL	NULL	1	100.00	NULL
Warnings:
Note	1003	/* select#1 */ select (cast(`test`.`t`.`bl` as datetime(6)) = `test`.`t`.`dt`) AS `bl = dt` from `test`.`t`
EXPLAIN SELECT bl = dd FROM t;
id	select_type	table	partitions	type	possible_keys	key	key_len	ref	rows	filtered	Extra
1	SIMPLE	t	NULL	ALL	NULL	NULL	NULL	NULL	1	100.00	NULL
Warnings:
Note	1003	/* select#1 */ select (cast(`test`.`t`.`bl` as date) = `test`.`t`.`dd`) AS `bl = dd` from `test`.`t`
EXPLAIN SELECT bl = t FROM t;
id	select_type	table	partitions	type	possible_keys	key	key_len	ref	rows	filtered	Extra
1	SIMPLE	t	NULL	ALL	NULL	NULL	NULL	NULL	1	100.00	NULL
Warnings:
Note	1003	/* select#1 */ select (`test`.`t`.`bl` = `test`.`t`.`t`) AS `bl = t` from `test`.`t`
# YEAR vs data types
EXPLAIN SELECT y = i FROM t;
id	select_type	table	partitions	type	possible_keys	key	key_len	ref	rows	filtered	Extra
1	SIMPLE	t	NULL	ALL	NULL	NULL	NULL	NULL	1	100.00	NULL
Warnings:
Note	1003	/* select#1 */ select (`test`.`t`.`y` = `test`.`t`.`i`) AS `y = i` from `test`.`t`
EXPLAIN SELECT y = si FROM t;
id	select_type	table	partitions	type	possible_keys	key	key_len	ref	rows	filtered	Extra
1	SIMPLE	t	NULL	ALL	NULL	NULL	NULL	NULL	1	100.00	NULL
Warnings:
Note	1003	/* select#1 */ select (`test`.`t`.`y` = `test`.`t`.`si`) AS `y = si` from `test`.`t`
EXPLAIN SELECT y = ti FROM t;
id	select_type	table	partitions	type	possible_keys	key	key_len	ref	rows	filtered	Extra
1	SIMPLE	t	NULL	ALL	NULL	NULL	NULL	NULL	1	100.00	NULL
Warnings:
Note	1003	/* select#1 */ select (`test`.`t`.`y` = `test`.`t`.`ti`) AS `y = ti` from `test`.`t`
EXPLAIN SELECT y = mi FROM t;
id	select_type	table	partitions	type	possible_keys	key	key_len	ref	rows	filtered	Extra
1	SIMPLE	t	NULL	ALL	NULL	NULL	NULL	NULL	1	100.00	NULL
Warnings:
Note	1003	/* select#1 */ select (`test`.`t`.`y` = `test`.`t`.`mi`) AS `y = mi` from `test`.`t`
EXPLAIN SELECT y = bi FROM t;
id	select_type	table	partitions	type	possible_keys	key	key_len	ref	rows	filtered	Extra
1	SIMPLE	t	NULL	ALL	NULL	NULL	NULL	NULL	1	100.00	NULL
Warnings:
Note	1003	/* select#1 */ select (`test`.`t`.`y` = `test`.`t`.`bi`) AS `y = bi` from `test`.`t`
EXPLAIN SELECT y = bt FROM t;
id	select_type	table	partitions	type	possible_keys	key	key_len	ref	rows	filtered	Extra
1	SIMPLE	t	NULL	ALL	NULL	NULL	NULL	NULL	1	100.00	NULL
Warnings:
Note	1003	/* select#1 */ select (`test`.`t`.`y` = `test`.`t`.`bt`) AS `y = bt` from `test`.`t`
EXPLAIN SELECT y = y FROM t;
id	select_type	table	partitions	type	possible_keys	key	key_len	ref	rows	filtered	Extra
1	SIMPLE	t	NULL	ALL	NULL	NULL	NULL	NULL	1	100.00	NULL
Warnings:
Note	1003	/* select#1 */ select (`test`.`t`.`y` = `test`.`t`.`y`) AS `y = y` from `test`.`t`
EXPLAIN SELECT y = d FROM t;
id	select_type	table	partitions	type	possible_keys	key	key_len	ref	rows	filtered	Extra
1	SIMPLE	t	NULL	ALL	NULL	NULL	NULL	NULL	1	100.00	NULL
Warnings:
Note	1003	/* select#1 */ select (`test`.`t`.`y` = `test`.`t`.`d`) AS `y = d` from `test`.`t`
EXPLAIN SELECT y = f FROM t;
id	select_type	table	partitions	type	possible_keys	key	key_len	ref	rows	filtered	Extra
1	SIMPLE	t	NULL	ALL	NULL	NULL	NULL	NULL	1	100.00	NULL
Warnings:
Note	1003	/* select#1 */ select (`test`.`t`.`y` = `test`.`t`.`f`) AS `y = f` from `test`.`t`
EXPLAIN SELECT y = dbl FROM t;
id	select_type	table	partitions	type	possible_keys	key	key_len	ref	rows	filtered	Extra
1	SIMPLE	t	NULL	ALL	NULL	NULL	NULL	NULL	1	100.00	NULL
Warnings:
Note	1003	/* select#1 */ select (`test`.`t`.`y` = `test`.`t`.`dbl`) AS `y = dbl` from `test`.`t`
EXPLAIN SELECT y = dt FROM t;
id	select_type	table	partitions	type	possible_keys	key	key_len	ref	rows	filtered	Extra
1	SIMPLE	t	NULL	ALL	NULL	NULL	NULL	NULL	1	100.00	NULL
Warnings:
Note	1003	/* select#1 */ select (`test`.`t`.`y` = `test`.`t`.`dt`) AS `y = dt` from `test`.`t`
EXPLAIN SELECT y = dd FROM t;
id	select_type	table	partitions	type	possible_keys	key	key_len	ref	rows	filtered	Extra
1	SIMPLE	t	NULL	ALL	NULL	NULL	NULL	NULL	1	100.00	NULL
Warnings:
Note	1003	/* select#1 */ select (`test`.`t`.`y` = `test`.`t`.`dd`) AS `y = dd` from `test`.`t`
EXPLAIN SELECT y = t FROM t;
id	select_type	table	partitions	type	possible_keys	key	key_len	ref	rows	filtered	Extra
1	SIMPLE	t	NULL	ALL	NULL	NULL	NULL	NULL	1	100.00	NULL
Warnings:
Note	1003	/* select#1 */ select (`test`.`t`.`y` = `test`.`t`.`t`) AS `y = t` from `test`.`t`
# cleanup
DROP TABLE t;
#
# Bug#31023252: RESULTSET MISMATCH USING STRCMP() WITH DATE AND STRING DATATYPE
#
CREATE TABLE t1(a YEAR, b VARCHAR(10));
INSERT INTO t1 VALUES ('1997','random_str');
SELECT STRCMP(a, b) FROM t1;
STRCMP(a, b)
-1
DROP TABLE t1;
#
# Bug#30626100: WL13456 RESULTSET DISTINCT DIFFERENCE
#
CREATE TABLE t (col_datetime datetime, col_date date, col_time time, col_char char);
insert into t values ('2013-03-15 18:35:20', '2013-03-15', '18:35:20','L'),
('2003-01-10 00:00:23', '2003-01-10', '00:00:23', NULL);
SELECT CAST(col_char AS DATETIME) FROM t;
CAST(col_char AS DATETIME)
NULL
NULL
Warnings:
Warning	1292	Incorrect datetime value: 'L'

SELECT col_char /*CAST(col_char as datetime)*/ <> col_datetime FROM t;
col_char /*CAST(col_char as datetime)*/ <> col_datetime
1
NULL
Warnings:
Warning	1292	Incorrect datetime value: 'L'

SELECT CAST(col_char AS DATE) FROM t;
CAST(col_char AS DATE)
NULL
NULL
Warnings:
Warning	1292	Incorrect datetime value: 'L'

SELECT col_char <> col_date FROM t;
col_char <> col_date
1
NULL
Warnings:
Warning	1292	Incorrect datetime value: 'L'
SELECT CAST(col_char as TIME) FROM t;
CAST(col_char as TIME)
NULL
NULL
Warnings:
Warning	1292	Truncated incorrect time value: 'L'
SELECT col_char <> col_time FROM t;
col_char <> col_time
1
NULL
DROP TABLE t;
#
# Bug#31095719 WL13456 RESULT SET COMPARISON DIFFERENCE WITH JOINS
#
CREATE TABLE `BB` (`col_char_key` char(1));
CREATE TABLE `CC` ( `pk` int, `col_datetime_key` datetime,
KEY `idx_CC_col_datetime_key` (`col_datetime_key`));
INSERT INTO `BB` VALUES ('X');
INSERT INTO `CC` VALUES (1,'2027-03-17 00:10:00'), (2,'2004-11-14 12:46:43');
SELECT COUNT(table1.pk) FROM CC table1 JOIN BB table3 JOIN CC table2
WHERE (table3.col_char_key < table2.col_datetime_key);
COUNT(table1.pk)
4
Warnings:
Warning	1292	Incorrect datetime value: 'X'
Warning	1292	Incorrect datetime value: 'X'
Warning	1292	Incorrect datetime value: 'X'
Warning	1292	Incorrect datetime value: 'X'
DROP TABLE `BB`;
DROP TABLE `CC`;
#
# CAST AS YEAR
#
SELECT CAST(CAST(-1 AS SIGNED) AS YEAR);
CAST(CAST(-1 AS SIGNED) AS YEAR)
NULL
Warnings:
Warning	1292	Truncated incorrect YEAR value: '-1'
SELECT CAST(CAST(-99 AS SIGNED) AS YEAR);
CAST(CAST(-99 AS SIGNED) AS YEAR)
NULL
Warnings:
Warning	1292	Truncated incorrect YEAR value: '-99'
SELECT CAST(CAST(0 AS SIGNED) AS YEAR);
CAST(CAST(0 AS SIGNED) AS YEAR)
0
SELECT CAST(CAST(69 AS SIGNED) AS YEAR);
CAST(CAST(69 AS SIGNED) AS YEAR)
2069
SELECT CAST(CAST(70 AS SIGNED) AS YEAR);
CAST(CAST(70 AS SIGNED) AS YEAR)
1970
SELECT CAST(CAST(99 AS SIGNED) AS YEAR);
CAST(CAST(99 AS SIGNED) AS YEAR)
1999
SELECT CAST(CAST(100 AS SIGNED) AS YEAR);
CAST(CAST(100 AS SIGNED) AS YEAR)
NULL
Warnings:
Warning	1292	Truncated incorrect YEAR value: '100'
SELECT CAST(CAST(2010 AS SIGNED) AS YEAR);
CAST(CAST(2010 AS SIGNED) AS YEAR)
2010
SELECT CAST(-1.1 AS YEAR);
CAST(-1.1 AS YEAR)
NULL
Warnings:
Warning	1292	Truncated incorrect YEAR value: '-1'
SELECT CAST(1.1 AS YEAR);
CAST(1.1 AS YEAR)
2001
SELECT CAST(0.0 AS YEAR);
CAST(0.0 AS YEAR)
0
SELECT CAST(69.1 AS YEAR);
CAST(69.1 AS YEAR)
2069
SELECT CAST(70.1 AS YEAR);
CAST(70.1 AS YEAR)
1970
SELECT CAST(100.1 AS YEAR);
CAST(100.1 AS YEAR)
NULL
Warnings:
Warning	1292	Truncated incorrect YEAR value: '100'
SELECT CAST(2010.9 AS YEAR);
CAST(2010.9 AS YEAR)
2011
SELECT CAST(CAST(-1.1 AS DECIMAL) AS YEAR);
CAST(CAST(-1.1 AS DECIMAL) AS YEAR)
NULL
Warnings:
Warning	1292	Truncated incorrect YEAR value: '-1'
SELECT CAST(CAST(1.1 AS DECIMAL) AS YEAR);
CAST(CAST(1.1 AS DECIMAL) AS YEAR)
2001
SELECT CAST(CAST(0.0 AS DECIMAL) AS YEAR);
CAST(CAST(0.0 AS DECIMAL) AS YEAR)
0
SELECT CAST(CAST(69.1 AS DECIMAL) AS YEAR);
CAST(CAST(69.1 AS DECIMAL) AS YEAR)
2069
SELECT CAST(CAST(70.1 AS DECIMAL) AS YEAR);
CAST(CAST(70.1 AS DECIMAL) AS YEAR)
1970
SELECT CAST(CAST(100.1 AS DECIMAL) AS YEAR);
CAST(CAST(100.1 AS DECIMAL) AS YEAR)
NULL
Warnings:
Warning	1292	Truncated incorrect YEAR value: '100'
SELECT CAST(CAST(2010.9 AS DECIMAL) AS YEAR);
CAST(CAST(2010.9 AS DECIMAL) AS YEAR)
2011
SELECT CAST("-1" AS YEAR);
CAST("-1" AS YEAR)
NULL
Warnings:
Warning	1525	Incorrect YEAR value: '-1'
SELECT CAST("-99" AS YEAR);
CAST("-99" AS YEAR)
NULL
Warnings:
Warning	1525	Incorrect YEAR value: '-99'
SELECT CAST("0" AS YEAR);
CAST("0" AS YEAR)
2000
SELECT CAST("69" AS YEAR);
CAST("69" AS YEAR)
2069
SELECT CAST("70" AS YEAR);
CAST("70" AS YEAR)
1970
SELECT CAST("99" AS YEAR);
CAST("99" AS YEAR)
1999
SELECT CAST("100" AS YEAR);
CAST("100" AS YEAR)
NULL
Warnings:
Warning	1292	Truncated incorrect YEAR value: '100'
SELECT CAST("2010" AS YEAR);
CAST("2010" AS YEAR)
2010
SELECT CAST("extra" AS YEAR);
CAST("extra" AS YEAR)
NULL
Warnings:
Warning	1525	Incorrect YEAR value: 'extra'
SELECT CAST("22extra" AS YEAR);
CAST("22extra" AS YEAR)
2022
Warnings:
Warning	1292	Truncated incorrect YEAR value: '22extra'
SELECT CAST("2020extra" AS YEAR);
CAST("2020extra" AS YEAR)
2020
Warnings:
Warning	1292	Truncated incorrect YEAR value: '2020extra'
SET timestamp = UNIX_TIMESTAMP('2020-12-22 03:30:00');
SELECT CAST(TIMESTAMP'2010-01-01 00:00' AS YEAR);
CAST(TIMESTAMP'2010-01-01 00:00' AS YEAR)
2010
SET SQL_MODE = "";
SELECT CAST(TIMESTAMP'0000-00-00 00:00' AS YEAR);
CAST(TIMESTAMP'0000-00-00 00:00' AS YEAR)
0
SET SQL_MODE = default;
SELECT CAST(TIMESTAMP'2010-01-01 08:09:10' AS YEAR);
CAST(TIMESTAMP'2010-01-01 08:09:10' AS YEAR)
2010
SELECT CAST(TIME'08:09:10' AS YEAR);
CAST(TIME'08:09:10' AS YEAR)
2020
SELECT CAST(TIME'00:00:00' AS YEAR);
CAST(TIME'00:00:00' AS YEAR)
2020
SET timestamp = DEFAULT;
SELECT CAST(ST_PointFromText('POINT(10 10)') AS YEAR);
ERROR HY000: Incorrect arguments to cast_as_year
CREATE TABLE t AS SELECT CAST("2010" AS YEAR);
SHOW CREATE TABLE t;
Table	Create Table
t	CREATE TABLE `t` (
  `CAST("2010" AS YEAR)` year DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci
DROP TABLE t;
SELECT CAST(JSON_EXTRACT('{"key_year":1934}', '$.key_year') AS YEAR);
CAST(JSON_EXTRACT('{"key_year":1934}', '$.key_year') AS YEAR)
1934
SELECT CAST(CAST('{"_id":"192312412512"}' AS JSON) AS YEAR);
CAST(CAST('{"_id":"192312412512"}' AS JSON) AS YEAR)
0
Warnings:
Warning	3156	Invalid JSON value for CAST to INTEGER from column cast_as_json at row 1
CREATE TABLE t1 (i INT, j JSON) CHARSET utf8mb4;
INSERT INTO t1 VALUES (0, NULL);
INSERT INTO t1 VALUES (1, '"1901"');
INSERT INTO t1 VALUES (2, 'true');
INSERT INTO t1 VALUES (3, 'false');
INSERT INTO t1 VALUES (4, 'null');
INSERT INTO t1 VALUES (5, '-1');
INSERT INTO t1 VALUES (6, CAST(CAST(1 AS UNSIGNED) AS JSON));
INSERT INTO t1 VALUES (7, '1901');
INSERT INTO t1 VALUES (8, '-1901');
INSERT INTO t1 VALUES (9, '2147483647');
INSERT INTO t1 VALUES (10, '2147483648');
INSERT INTO t1 VALUES (11, '-2147483648');
INSERT INTO t1 VALUES (12, '-2147483649');
INSERT INTO t1 VALUES (13, '3.14');
INSERT INTO t1 VALUES (14, '{}');
INSERT INTO t1 VALUES (15, '[]');
INSERT INTO t1 VALUES (16, CAST(CAST('2015-01-15 23:24:25' AS DATETIME) AS JSON));
INSERT INTO t1 VALUES (17, CAST(CAST('23:24:25' AS TIME) AS JSON));
INSERT INTO t1 VALUES (18, CAST(CAST('2015-01-15' AS DATE) AS JSON));
INSERT INTO t1 VALUES (19, CAST(TIMESTAMP'2015-01-15 23:24:25' AS JSON));
INSERT INTO t1 VALUES (20, CAST(ST_GeomFromText('POINT(1 1)') AS JSON));
INSERT INTO t1 VALUES (21, CAST('1988' AS CHAR CHARACTER SET 'ascii'));
INSERT INTO t1 VALUES (22, CAST(x'07C4' AS JSON));
INSERT INTO t1 VALUES (23, CAST(x'07C407C4' AS JSON));
SELECT i, CAST(j AS YEAR), CAST(j AS SIGNED) FROM t1 ORDER BY i;
i	CAST(j AS YEAR)	CAST(j AS SIGNED)
0	NULL	NULL
1	1901	1901
2	2001	1
3	0	0
4	0	0
5	NULL	-1
6	2001	1
7	1901	1901
8	NULL	-1901
9	NULL	2147483647
10	NULL	2147483648
11	NULL	-2147483648
12	NULL	-2147483649
13	2003	3
14	0	0
15	0	0
16	0	0
17	0	0
18	0	0
19	0	0
20	0	0
21	1988	1988
22	0	0
23	0	0
Warnings:
Warning	3156	Invalid JSON value for CAST to INTEGER from column j at row 5
Warning	3156	Invalid JSON value for CAST to INTEGER from column j at row 5
Warning	1292	Truncated incorrect YEAR value: '-1'
Warning	1292	Truncated incorrect YEAR value: '-1901'
Warning	1292	Truncated incorrect YEAR value: '2147483647'
Warning	1292	Truncated incorrect YEAR value: '2147483648'
Warning	1292	Truncated incorrect YEAR value: '-2147483648'
Warning	1292	Truncated incorrect YEAR value: '-2147483649'
Warning	3156	Invalid JSON value for CAST to INTEGER from column j at row 15
Warning	3156	Invalid JSON value for CAST to INTEGER from column j at row 15
Warning	3156	Invalid JSON value for CAST to INTEGER from column j at row 16
Warning	3156	Invalid JSON value for CAST to INTEGER from column j at row 16
Warning	3156	Invalid JSON value for CAST to INTEGER from column j at row 17
Warning	3156	Invalid JSON value for CAST to INTEGER from column j at row 17
Warning	3156	Invalid JSON value for CAST to INTEGER from column j at row 18
Warning	3156	Invalid JSON value for CAST to INTEGER from column j at row 18
Warning	3156	Invalid JSON value for CAST to INTEGER from column j at row 19
Warning	3156	Invalid JSON value for CAST to INTEGER from column j at row 19
Warning	3156	Invalid JSON value for CAST to INTEGER from column j at row 20
Warning	3156	Invalid JSON value for CAST to INTEGER from column j at row 20
Warning	3156	Invalid JSON value for CAST to INTEGER from column j at row 21
Warning	3156	Invalid JSON value for CAST to INTEGER from column j at row 21
Warning	3156	Invalid JSON value for CAST to INTEGER from column j at row 23
Warning	3156	Invalid JSON value for CAST to INTEGER from column j at row 23
Warning	3156	Invalid JSON value for CAST to INTEGER from column j at row 24
Warning	3156	Invalid JSON value for CAST to INTEGER from column j at row 24
DROP TABLE t1;
CREATE TABLE t(numbers ENUM('0','1','2020'), colors ENUM('red', 'green', 'blue'));
INSERT INTO t values('2020', 'blue');
SELECT CAST(numbers AS YEAR), CAST(colors AS YEAR) FROM t;
CAST(numbers AS YEAR)	CAST(colors AS YEAR)
2003	2003
DROP TABLE t;
CREATE TABLE t(y YEAR);
INSERT INTO t values(CAST("2020extra" AS YEAR));
ERROR 22007: Truncated incorrect YEAR value: '2020extra'
INSERT INTO t values(CAST(20201 AS YEAR));
ERROR 22007: Truncated incorrect YEAR value: '20201'
SET SQL_MODE = "";
INSERT INTO t values(CAST("2020extra" AS YEAR));
Warnings:
Warning	1292	Truncated incorrect YEAR value: '2020extra'
INSERT INTO t values(CAST(20201 AS YEAR));
Warnings:
Warning	1292	Truncated incorrect YEAR value: '20201'
SELECT * FROM t;
y
2020
NULL
SET SQL_MODE = default;
DROP TABLE t;
SELECT CAST(1988 AS YEAR), REPEAT(CAST(1988 AS YEAR), 3) AS c2;
CAST(1988 AS YEAR)	c2
1988	198819881988
SELECT CONCAT('x', CAST(1988 AS YEAR));
CONCAT('x', CAST(1988 AS YEAR))
x1988
SELECT CAST(1988 AS YEAR) + 1.5e0;
CAST(1988 AS YEAR) + 1.5e0
1989.5
SELECT CAST(CAST(1988 AS YEAR) AS DECIMAL);
CAST(CAST(1988 AS YEAR) AS DECIMAL)
1988
SELECT DATE_ADD(CAST(1988 AS YEAR), INTERVAL 1 DAY);
DATE_ADD(CAST(1988 AS YEAR), INTERVAL 1 DAY)
NULL
Warnings:
Warning	1292	Incorrect datetime value: '1988'
SELECT TIME_TO_SEC(CAST('2030' AS YEAR));
TIME_TO_SEC(CAST('2030' AS YEAR))
1230
SELECT TIMESTAMPADD(MINUTE, 1, CAST(1988 AS YEAR));
TIMESTAMPADD(MINUTE, 1, CAST(1988 AS YEAR))
NULL
Warnings:
Warning	1292	Incorrect datetime value: '1988'
SELECT CAST(CAST(1988 AS YEAR) AS SIGNED);
CAST(CAST(1988 AS YEAR) AS SIGNED)
1988
SELECT CAST(CAST(1988 AS YEAR) AS UNSIGNED);
CAST(CAST(1988 AS YEAR) AS UNSIGNED)
1988
SELECT CAST(TIMESTAMP'579-10-10 10:10:10' AS YEAR);
CAST(TIMESTAMP'579-10-10 10:10:10' AS YEAR)
NULL
Warnings:
Warning	1292	Truncated incorrect YEAR value: '579'
SELECT CAST(STR_TO_DATE('nope','%d-%m-%Y') AS YEAR);
CAST(STR_TO_DATE('nope','%d-%m-%Y') AS YEAR)
NULL
Warnings:
Warning	1411	Incorrect datetime value: 'nope' for function str_to_date
# WL#14109: Implement a consistent comparison type rule matrix
SET @zero_date = '0000-00-00';
SET @zero_day = '2000-01-00';
SET @zero_month = '2000-00-01';
SET @zero_year = '0000-01-01';
SET @invalid_date = '2000-02-31';
SET @bad_date = 'YYYY-MM-DD';
SET @zero_datetime = '0000-00-00 00:00:00.000000';
SET @zero_day_dt = '2000-01-00 00:00:00.000000';
SET @zero_month_dt = '2000-00-01 00:00:00.000000';
SET @zero_year_dt = '0000-01-01 00:00:00.000000';
SET @invalid_datetime = '2000-02-31 00:00:00.000000';
SET @bad_datetime = 'YYYY-MM-DD HH:MM:SS.ffffff';
SET SQL_MODE=DEFAULT;
SELECT CAST('0000-00-00' AS DATE) AS d1,
CAST(@zero_date AS DATE) AS d2,
CAST('0000-00-00 00:00:00.000000' AS DATETIME(6)) AS dt1,
CAST(@zero_datetime AS DATETIME(6)) AS dt2;
d1	d2	dt1	dt2
NULL	NULL	NULL	NULL
Warnings:
Warning	1292	Incorrect datetime value: '0000-00-00'
Warning	1292	Incorrect datetime value: '0000-00-00'
Warning	1292	Incorrect datetime value: '0000-00-00 00:00:00.000000'
Warning	1292	Incorrect datetime value: '0000-00-00 00:00:00.000000'
SELECT CAST('2000-01-00' AS DATE) AS d1,
CAST(@zero_day AS DATE) AS d2,
CAST('2000-01-00 00:00:00.000000' AS DATETIME(6)) AS dt1,
CAST(@zero_day_dt AS DATETIME(6)) AS dt2;
d1	d2	dt1	dt2
NULL	NULL	NULL	NULL
Warnings:
Warning	1292	Incorrect datetime value: '2000-01-00'
Warning	1292	Incorrect datetime value: '2000-01-00'
Warning	1292	Incorrect datetime value: '2000-01-00 00:00:00.000000'
Warning	1292	Incorrect datetime value: '2000-01-00 00:00:00.000000'
SELECT CAST('2000-00-01' AS DATE) AS d1,
CAST(@zero_month AS DATE) AS d2,
CAST('2000-00-01 00:00:00.000000' AS DATETIME(6)) AS dt1,
CAST(@zero_month_dt AS DATETIME(6)) AS dt2;
d1	d2	dt1	dt2
NULL	NULL	NULL	NULL
Warnings:
Warning	1292	Incorrect datetime value: '2000-00-01'
Warning	1292	Incorrect datetime value: '2000-00-01'
Warning	1292	Incorrect datetime value: '2000-00-01 00:00:00.000000'
Warning	1292	Incorrect datetime value: '2000-00-01 00:00:00.000000'
SELECT CAST('0000-01-01' AS DATE) AS d1,
CAST(@zero_year AS DATE) AS d2,
CAST('0000-01-01 00:00:00.000000' AS DATETIME(6)) AS dt1,
CAST(@zero_year_dt AS DATETIME(6)) AS dt2;
d1	d2	dt1	dt2
0000-01-01	0000-01-01	0000-01-01 00:00:00.000000	0000-01-01 00:00:00.000000
SELECT CAST('2000-02-31' AS DATE) AS d1,
CAST(@invalid_date AS DATE) AS d2,
CAST('2000-02-31 00:00:00.000000' AS DATETIME(6)) AS dt1,
CAST(@invalid_datetime AS DATETIME(6)) AS dt2;
d1	d2	dt1	dt2
NULL	NULL	NULL	NULL
Warnings:
Warning	1292	Incorrect datetime value: '2000-02-31'
Warning	1292	Incorrect datetime value: '2000-02-31'
Warning	1292	Incorrect datetime value: '2000-02-31 00:00:00.000000'
Warning	1292	Incorrect datetime value: '2000-02-31 00:00:00.000000'
SELECT CAST('YYYY-MM-DD' AS DATE) AS d1,
CAST(@bad_date AS DATE) AS d2,
CAST('YYYY-MM-DD HH:MM:SS.ffffff' AS DATETIME(6)) AS dt1,
CAST(@bad_datetime AS DATETIME(6)) AS dt2;
d1	d2	dt1	dt2
NULL	NULL	NULL	NULL
Warnings:
Warning	1292	Incorrect datetime value: 'YYYY-MM-DD'
Warning	1292	Incorrect datetime value: 'YYYY-MM-DD'
Warning	1292	Incorrect datetime value: 'YYYY-MM-DD HH:MM:SS.ffffff'
Warning	1292	Incorrect datetime value: 'YYYY-MM-DD HH:MM:SS.ffffff'
SET SQL_MODE='NO_ZERO_DATE';
Warnings:
Warning	3135	'NO_ZERO_DATE', 'NO_ZERO_IN_DATE' and 'ERROR_FOR_DIVISION_BY_ZERO' sql modes should be used with strict mode. They will be merged with strict mode in a future release.
SELECT CAST('0000-00-00' AS DATE) AS d1,
CAST(@zero_date AS DATE) AS d2,
CAST('0000-00-00 00:00:00.000000' AS DATETIME(6)) AS dt1,
CAST(@zero_datetime AS DATETIME(6)) AS dt2;
d1	d2	dt1	dt2
NULL	NULL	NULL	NULL
Warnings:
Warning	1292	Incorrect datetime value: '0000-00-00'
Warning	1292	Incorrect datetime value: '0000-00-00'
Warning	1292	Incorrect datetime value: '0000-00-00 00:00:00.000000'
Warning	1292	Incorrect datetime value: '0000-00-00 00:00:00.000000'
SELECT CAST('2000-01-00' AS DATE) AS d1,
CAST(@zero_day AS DATE) AS d2,
CAST('2000-01-00 00:00:00.000000' AS DATETIME(6)) AS dt1,
CAST(@zero_day_dt AS DATETIME(6)) AS dt2;
d1	d2	dt1	dt2
2000-01-00	2000-01-00	2000-01-00 00:00:00.000000	2000-01-00 00:00:00.000000
SELECT CAST('2000-00-01' AS DATE) AS d1,
CAST(@zero_month AS DATE) AS d2,
CAST('2000-00-01 00:00:00.000000' AS DATETIME(6)) AS dt1,
CAST(@zero_month_dt AS DATETIME(6)) AS dt2;
d1	d2	dt1	dt2
2000-00-01	2000-00-01	2000-00-01 00:00:00.000000	2000-00-01 00:00:00.000000
SELECT CAST('0000-01-01' AS DATE) AS d1,
CAST(@zero_year AS DATE) AS d2,
CAST('0000-01-01 00:00:00.000000' AS DATETIME(6)) AS dt1,
CAST(@zero_year_dt AS DATETIME(6)) AS dt2;
d1	d2	dt1	dt2
0000-01-01	0000-01-01	0000-01-01 00:00:00.000000	0000-01-01 00:00:00.000000
SELECT CAST('2000-02-31' AS DATE) AS d1,
CAST(@invalid_date AS DATE) AS d2,
CAST('2000-02-31 00:00:00.000000' AS DATETIME(6)) AS dt1,
CAST(@invalid_datetime AS DATETIME(6)) AS dt2;
d1	d2	dt1	dt2
NULL	NULL	NULL	NULL
Warnings:
Warning	1292	Incorrect datetime value: '2000-02-31'
Warning	1292	Incorrect datetime value: '2000-02-31'
Warning	1292	Incorrect datetime value: '2000-02-31 00:00:00.000000'
Warning	1292	Incorrect datetime value: '2000-02-31 00:00:00.000000'
SELECT CAST('YYYY-MM-DD' AS DATE) AS d1,
CAST(@bad_date AS DATE) AS d2,
CAST('YYYY-MM-DD HH:MM:SS.ffffff' AS DATETIME(6)) AS dt1,
CAST(@bad_datetime AS DATETIME(6)) AS dt2;
d1	d2	dt1	dt2
NULL	NULL	NULL	NULL
Warnings:
Warning	1292	Incorrect datetime value: 'YYYY-MM-DD'
Warning	1292	Incorrect datetime value: 'YYYY-MM-DD'
Warning	1292	Incorrect datetime value: 'YYYY-MM-DD HH:MM:SS.ffffff'
Warning	1292	Incorrect datetime value: 'YYYY-MM-DD HH:MM:SS.ffffff'
SET SQL_MODE='NO_ZERO_IN_DATE';
Warnings:
Warning	3135	'NO_ZERO_DATE', 'NO_ZERO_IN_DATE' and 'ERROR_FOR_DIVISION_BY_ZERO' sql modes should be used with strict mode. They will be merged with strict mode in a future release.
SELECT CAST('0000-00-00' AS DATE) AS d1,
CAST(@zero_date AS DATE) AS d2,
CAST('0000-00-00 00:00:00.000000' AS DATETIME(6)) AS dt1,
CAST(@zero_datetime AS DATETIME(6)) AS dt2;
d1	d2	dt1	dt2
0000-00-00	0000-00-00	0000-00-00 00:00:00.000000	0000-00-00 00:00:00.000000
SELECT CAST('2000-01-00' AS DATE) AS d1,
CAST(@zero_day AS DATE) AS d2,
CAST('2000-01-00 00:00:00.000000' AS DATETIME(6)) AS dt1,
CAST(@zero_day_dt AS DATETIME(6)) AS dt2;
d1	d2	dt1	dt2
NULL	NULL	NULL	NULL
Warnings:
Warning	1292	Incorrect datetime value: '2000-01-00'
Warning	1292	Incorrect datetime value: '2000-01-00'
Warning	1292	Incorrect datetime value: '2000-01-00 00:00:00.000000'
Warning	1292	Incorrect datetime value: '2000-01-00 00:00:00.000000'
SELECT CAST('2000-00-01' AS DATE) AS d1,
CAST(@zero_month AS DATE) AS d2,
CAST('2000-00-01 00:00:00.000000' AS DATETIME(6)) AS dt1,
CAST(@zero_month_dt AS DATETIME(6)) AS dt2;
d1	d2	dt1	dt2
NULL	NULL	NULL	NULL
Warnings:
Warning	1292	Incorrect datetime value: '2000-00-01'
Warning	1292	Incorrect datetime value: '2000-00-01'
Warning	1292	Incorrect datetime value: '2000-00-01 00:00:00.000000'
Warning	1292	Incorrect datetime value: '2000-00-01 00:00:00.000000'
SELECT CAST('0000-01-01' AS DATE) AS d1,
CAST(@zero_year AS DATE) AS d2,
CAST('0000-01-01 00:00:00.000000' AS DATETIME(6)) AS dt1,
CAST(@zero_year_dt AS DATETIME(6)) AS dt2;
d1	d2	dt1	dt2
0000-01-01	0000-01-01	0000-01-01 00:00:00.000000	0000-01-01 00:00:00.000000
SELECT CAST('2000-02-31' AS DATE) AS d1,
CAST(@invalid_date AS DATE) AS d2,
CAST('2000-02-31 00:00:00.000000' AS DATETIME(6)) AS dt1,
CAST(@invalid_datetime AS DATETIME(6)) AS dt2;
d1	d2	dt1	dt2
NULL	NULL	NULL	NULL
Warnings:
Warning	1292	Incorrect datetime value: '2000-02-31'
Warning	1292	Incorrect datetime value: '2000-02-31'
Warning	1292	Incorrect datetime value: '2000-02-31 00:00:00.000000'
Warning	1292	Incorrect datetime value: '2000-02-31 00:00:00.000000'
SELECT CAST('YYYY-MM-DD' AS DATE) AS d1,
CAST(@bad_date AS DATE) AS d2,
CAST('YYYY-MM-DD HH:MM:SS.ffffff' AS DATETIME(6)) AS dt1,
CAST(@bad_datetime AS DATETIME(6)) AS dt2;
d1	d2	dt1	dt2
NULL	NULL	NULL	NULL
Warnings:
Warning	1292	Incorrect datetime value: 'YYYY-MM-DD'
Warning	1292	Incorrect datetime value: 'YYYY-MM-DD'
Warning	1292	Incorrect datetime value: 'YYYY-MM-DD HH:MM:SS.ffffff'
Warning	1292	Incorrect datetime value: 'YYYY-MM-DD HH:MM:SS.ffffff'
SET SQL_MODE='ALLOW_INVALID_DATES';
SELECT CAST('0000-00-00' AS DATE) AS d1,
CAST(@zero_date AS DATE) AS d2,
CAST('0000-00-00 00:00:00.000000' AS DATETIME(6)) AS dt1,
CAST(@zero_datetime AS DATETIME(6)) AS dt2;
d1	d2	dt1	dt2
0000-00-00	0000-00-00	0000-00-00 00:00:00.000000	0000-00-00 00:00:00.000000
SELECT CAST('2000-01-00' AS DATE) AS d1,
CAST(@zero_day AS DATE) AS d2,
CAST('2000-01-00 00:00:00.000000' AS DATETIME(6)) AS dt1,
CAST(@zero_day_dt AS DATETIME(6)) AS dt2;
d1	d2	dt1	dt2
2000-01-00	2000-01-00	2000-01-00 00:00:00.000000	2000-01-00 00:00:00.000000
SELECT CAST('2000-00-01' AS DATE) AS d1,
CAST(@zero_month AS DATE) AS d2,
CAST('2000-00-01 00:00:00.000000' AS DATETIME(6)) AS dt1,
CAST(@zero_month_dt AS DATETIME(6)) AS dt2;
d1	d2	dt1	dt2
2000-00-01	2000-00-01	2000-00-01 00:00:00.000000	2000-00-01 00:00:00.000000
SELECT CAST('0000-01-01' AS DATE) AS d1,
CAST(@zero_year AS DATE) AS d2,
CAST('0000-01-01 00:00:00.000000' AS DATETIME(6)) AS dt1,
CAST(@zero_year_dt AS DATETIME(6)) AS dt2;
d1	d2	dt1	dt2
0000-01-01	0000-01-01	0000-01-01 00:00:00.000000	0000-01-01 00:00:00.000000
SELECT CAST('2000-02-31' AS DATE) AS d1,
CAST(@invalid_date AS DATE) AS d2,
CAST('2000-02-31 00:00:00.000000' AS DATETIME(6)) AS dt1,
CAST(@invalid_datetime AS DATETIME(6)) AS dt2;
d1	d2	dt1	dt2
2000-02-31	2000-02-31	2000-02-31 00:00:00.000000	2000-02-31 00:00:00.000000
SELECT CAST('YYYY-MM-DD' AS DATE) AS d1,
CAST(@bad_date AS DATE) AS d2,
CAST('YYYY-MM-DD HH:MM:SS.ffffff' AS DATETIME(6)) AS dt1,
CAST(@bad_datetime AS DATETIME(6)) AS dt2;
d1	d2	dt1	dt2
NULL	NULL	NULL	NULL
Warnings:
Warning	1292	Incorrect datetime value: 'YYYY-MM-DD'
Warning	1292	Incorrect datetime value: 'YYYY-MM-DD'
Warning	1292	Incorrect datetime value: 'YYYY-MM-DD HH:MM:SS.ffffff'
Warning	1292	Incorrect datetime value: 'YYYY-MM-DD HH:MM:SS.ffffff'
SET SQL_MODE=DEFAULT;
#
# Bug#32371039: ITEM->MAX_LENGTH FIELD IS NOT ACCURATE FOR
#               FROM_BASE64 FUNCTION
#
CREATE TABLE t AS
SELECT CONCAT(CAST(-1 AS UNSIGNED)) AS col1,
1.0 + CAST(-1 AS UNSIGNED) AS col2,
CONCAT(CAST(9223372036854775808 AS SIGNED)) AS col3;
SHOW CREATE TABLE t;
Table	Create Table
t	CREATE TABLE `t` (
  `col1` varchar(21) CHARACTER SET latin1 DEFAULT NULL,
  `col2` decimal(23,1) NOT NULL DEFAULT '0.0',
  `col3` varchar(21) CHARACTER SET latin1 DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci
SELECT * FROM t;
col1	col2	col3
18446744073709551615	18446744073709551616.0	-9223372036854775808
DROP TABLE t;
#
# Bug#32942327: CAST: ITEM_TYPECAST_UNSIGNED:
#               ASSERTION `!NULL_VALUE || IS_NULLABLE()' FAILED
#
CREATE TABLE t (x VARCHAR(10) NOT NULL);
INSERT INTO t VALUES ('');
SELECT CAST(x <= 0x4891f642 AS UNSIGNED) FROM t;
ERROR HY000: Cannot convert string 'H\x91\xF6B' from binary to utf8mb4
SELECT CAST(STRCMP(x, 0x4891f642) AS UNSIGNED) FROM t;
ERROR HY000: Cannot convert string 'H\x91\xF6B' from binary to utf8mb4
DROP TABLE t;
#
# Bug#33199145: CONVERT(.. USING charset) gets wrong max_length
#
CREATE TABLE tmp(beer CHAR(1));
INSERT INTO tmp VALUES (CONVERT(X'F09F8DBA' USING utf8mb4));
SELECT HEX(beer), beer FROM tmp;
HEX(beer)	beer
F09F8DBA	?
# Used this round-about way originally to get a utfmb4 character to
# convert in next DML/DDL query to avoid change encoding of this file
# and to avoid bug in max_length of CONVERT(X'F09F8DBA' USING UTF8MB4)
# which (used to) set to 4 instead of one (beer), fixed now, though,
# see round-trip test below.
CREATE TABLE t AS
SELECT CONVERT((SELECT beer FROM tmp) USING binary) AS beer;
SHOW CREATE TABLE t;
Table	Create Table
t	CREATE TABLE `t` (
  `beer` varbinary(4) DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci
SELECT HEX(beer) FROM t;
HEX(beer)
F09F8DBA
DROP TABLE t, tmp;
CREATE TABLE t AS
SELECT CONVERT(X'F09F8DBA' USING utf8mb4) AS beer;
SHOW CREATE TABLE t;
Table	Create Table
t	CREATE TABLE `t` (
  `beer` varchar(4) DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci
SELECT HEX(beer) FROM t;
HEX(beer)
F09F8DBA
DROP TABLE t;
# Check round trip.
CREATE TABLE t AS
SELECT CONVERT(CONVERT(X'F09F8DBA' USING utf8mb4) USING binary) AS beer;
SHOW CREATE TABLE t;
Table	Create Table
t	CREATE TABLE `t` (
  `beer` varbinary(16) DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci
SELECT HEX(beer) FROM t;
HEX(beer)
F09F8DBA
DROP TABLE t;
# Check round trip.
CREATE TABLE t AS
SELECT CONVERT(CONVERT(X'F09F8DBA', CHAR(1) CHARACTER SET utf8mb4) USING binary) AS beer;
SHOW CREATE TABLE t;
Table	Create Table
t	CREATE TABLE `t` (
  `beer` varbinary(4) DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci
SELECT HEX(beer) FROM t;
HEX(beer)
F09F8DBA
DROP TABLE t;
# Check round trip: should stay VARCHAR(1).
CREATE TABLE t AS
SELECT CONVERT(CONVERT(_utf8mb3'a' USING utf8mb4) USING utf8mb3) AS a;
Warnings:
Warning	1287	'utf8mb3' is deprecated and will be removed in a future release. Please use utf8mb4 instead
Warning	1287	'utf8mb3' is deprecated and will be removed in a future release. Please use utf8mb4 instead
SHOW CREATE TABLE t;
Table	Create Table
t	CREATE TABLE `t` (
  `a` varchar(1) CHARACTER SET utf8mb3 DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci
SELECT a FROM t;
a
a
DROP TABLE t;
# Character set with different min char size (utf-16: 2):
CREATE TABLE t AS
SELECT CONVERT(X'D83CDF7A' USING utf16) as beer;
SHOW CREATE TABLE t;
Table	Create Table
t	CREATE TABLE `t` (
  `beer` varchar(2) CHARACTER SET utf16 DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci
SELECT HEX(beer), CHAR_LENGTH(beer) FROM t;
HEX(beer)	CHAR_LENGTH(beer)
D83CDF7A	1
DROP TABLE t;
#
# Bug #33406728 Item_charset_conversion::compute_max_char_length:
#     Assertion `from->max_length == from->max_char_length()' failed.
#
set @a:= st_aswkb(st_astext(@b:=log10(0.0)));
Warnings:
Warning	1287	Setting user variables within expressions is deprecated and will be removed in a future release. Consider alternatives: 'SET variable=expression, ...', or 'SELECT expression(s) INTO variables(s)'.
Warning	3020	Invalid argument for logarithm
set @a:= @b;
do convert(@a using latin1);
#
# Bug#34554755: DISTINCT on FLOAT values gives duplicates
#               with SQL_BIG_RESULT
#
SELECT CAST(1111111111111111 AS FLOAT) = CAST(1111111111111110 AS FLOAT) AS eq;
eq
1
SELECT CAST(CAST(1111111111111111 AS FLOAT) AS CHAR) AS v;
v
1.11111e15
SELECT CAST(CAST(1111111111111111 AS FLOAT) AS SIGNED) AS v;
v
1111111126482944
SELECT CAST(CAST(1111111111111111 AS FLOAT) AS DECIMAL(20,2)) AS v;
v
1111111126482944.00