File: type_float.result

package info (click to toggle)
mariadb 1%3A11.8.3-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 772,520 kB
  • sloc: ansic: 2,414,714; cpp: 1,791,394; asm: 381,336; perl: 62,905; sh: 49,647; pascal: 40,897; java: 39,363; python: 20,791; yacc: 20,432; sql: 17,907; xml: 12,344; ruby: 8,544; cs: 6,542; makefile: 6,145; ada: 1,879; lex: 1,193; javascript: 996; objc: 80; tcl: 73; awk: 46; php: 22
file content (1797 lines) | stat: -rw-r--r-- 55,849 bytes parent folder | download | duplicates (2)
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
drop table if exists t1,t2;
SELECT 10,10.0,10.,.1e+2,100.0e-1;
10	10.0	10.	.1e+2	100.0e-1
10	10.0	10	10	10
SELECT 6e-16, -6e-16, --6e-16, -6e-16+1.000000;
6e-16	-6e-16	--6e-16	-6e-16+1.000000
6e-16	-6e-16	6e-16	0.9999999999999994
SELECT 1e1,1.e1,1.0e1,1e+1,1.e+1,1.0e+1,1e-1,1.e-1,1.0e-1;
1e1	1.e1	1.0e1	1e+1	1.e+1	1.0e+1	1e-1	1.e-1	1.0e-1
10	10	10	10	10	10	0.1	0.1	0.1
SELECT 0.001e+1,0.001e-1, -0.001e+01,-0.001e-01;
0.001e+1	0.001e-1	-0.001e+01	-0.001e-01
0.01	0.0001	-0.01	-0.0001
SELECT 123.23E+02,-123.23E-02,"123.23E+02"+0.0,"-123.23E-02"+0.0;
123.23E+02	-123.23E-02	"123.23E+02"+0.0	"-123.23E-02"+0.0
12323	-1.2323	12323	-1.2323
SELECT 2147483647E+02,21474836.47E+06;
2147483647E+02	21474836.47E+06
214748364700	21474836470000
create table t1 (f1 float(24),f2 float(52));
show full columns from t1;
Field	Type	Collation	Null	Key	Default	Extra	Privileges	Comment
f1	float	NULL	YES		NULL		#	
f2	double	NULL	YES		NULL		#	
insert into t1 values(10,10),(1e+5,1e+5),(1234567890,1234567890),(1e+10,1e+10),(1e+15,1e+15),(1e+20,1e+20),(1e+50,1e+50),(1e+150,1e+150);
Warnings:
Warning	1264	Out of range value for column 'f1' at row 7
Warning	1264	Out of range value for column 'f1' at row 8
insert into t1 values(-10,-10),(1e-5,1e-5),(1e-10,1e-10),(1e-15,1e-15),(1e-20,1e-20),(1e-50,1e-50),(1e-150,1e-150);
select * from t1;
f1	f2
10	10
100000	100000
1234570000	1234567890
10000000000	10000000000
1e15	1e15
1e20	1e20
3.40282e38	1e50
3.40282e38	1e150
-10	-10
0.00001	0.00001
0.0000000001	0.0000000001
0.000000000000001	0.000000000000001
1e-20	1e-20
0	1e-50
0	1e-150
drop table t1;
create table t1 (datum double);
insert into t1 values (0.5),(1.0),(1.5),(2.0),(2.5);
select * from t1;
datum
0.5
1
1.5
2
2.5
select * from t1 where datum < 1.5;
datum
0.5
1
select * from t1 where datum > 1.5;
datum
2
2.5
select * from t1 where datum = 1.5;
datum
1.5
drop table t1;
create table t1 (a  decimal(7,3) not null, key (a));
insert into t1 values ("0"),("-0.00"),("-0.01"),("-0.002"),("1");
select a from t1 order by a;
a
-0.010
-0.002
0.000
0.000
1.000
select min(a) from t1;
min(a)
-0.010
drop table t1;
create table t1 (c1 double, c2 varchar(20));
insert t1 values (121,"16");
select c1 + c1 * (c2 / 100) as col from t1;
col
140.36
create table t2 select c1 + c1 * (c2 / 100) as col1, round(c1, 5) as col2, round(c1, 35) as col3, sqrt(c1*1e-15) col4 from t1;
select * from t2;
col1	col2	col3	col4
140.36	121.00000	121	0.00000034785054261852176
show create table t2;
Table	Create Table
t2	CREATE TABLE `t2` (
  `col1` double DEFAULT NULL,
  `col2` double(22,5) DEFAULT NULL,
  `col3` double DEFAULT NULL,
  `col4` double DEFAULT NULL
) ENGINE=MyISAM DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_uca1400_ai_ci
drop table t1,t2;
create table t1 (a float);
insert into t1 values (1);
select max(a),min(a),avg(a) from t1;
max(a)	min(a)	avg(a)
1	1	1
drop table t1;
create table t1 (f float, f2 float(24), f3 float(6,2), d double, d2 float(53), d3 double(10,3), de decimal, de2 decimal(6), de3 decimal(5,2), n numeric, n2 numeric(8), n3 numeric(7,6));
show full columns from t1;
Field	Type	Collation	Null	Key	Default	Extra	Privileges	Comment
f	float	NULL	YES		NULL		#	
f2	float	NULL	YES		NULL		#	
f3	float(6,2)	NULL	YES		NULL		#	
d	double	NULL	YES		NULL		#	
d2	double	NULL	YES		NULL		#	
d3	double(10,3)	NULL	YES		NULL		#	
de	decimal(10,0)	NULL	YES		NULL		#	
de2	decimal(6,0)	NULL	YES		NULL		#	
de3	decimal(5,2)	NULL	YES		NULL		#	
n	decimal(10,0)	NULL	YES		NULL		#	
n2	decimal(8,0)	NULL	YES		NULL		#	
n3	decimal(7,6)	NULL	YES		NULL		#	
drop table t1;
create table t1 (a  decimal(7,3) not null, key (a));
insert into t1 values ("0"),("-0.00"),("-0.01"),("-0.002"),("1");
select a from t1 order by a;
a
-0.010
-0.002
0.000
0.000
1.000
select min(a) from t1;
min(a)
-0.010
drop table t1;
create table t1 (a float(200,100), b double(200,100));
ERROR 42000: Too big scale specified for 'a'. Maximum is 30
create table t1 (c20 char);
insert ignore into t1 values (5000.0);
Warnings:
Warning	1265	Data truncated for column 'c20' at row 1
insert ignore into t1 values (0.5e4);
Warnings:
Warning	1265	Data truncated for column 'c20' at row 1
drop table t1;
create table t1 (f float(54));
ERROR 42000: Incorrect column specifier for column 'f'
drop table if exists t1;
create table t1 (d1 double, d2 double unsigned);
insert into t1 set d1 = -1.0;
update ignore t1 set d2 = d1;
Warnings:
Warning	1264	Out of range value for column 'd2' at row 1
select * from t1;
d1	d2
-1	0
drop table t1;
create table t1 (f float(4,3));
insert ignore into t1 values (-11.0),(-11),("-11"),(11.0),(11),("11");
Warnings:
Warning	1264	Out of range value for column 'f' at row 1
Warning	1264	Out of range value for column 'f' at row 2
Warning	1264	Out of range value for column 'f' at row 3
Warning	1264	Out of range value for column 'f' at row 4
Warning	1264	Out of range value for column 'f' at row 5
Warning	1264	Out of range value for column 'f' at row 6
select * from t1;
f
-9.999
-9.999
-9.999
9.999
9.999
9.999
drop table if exists t1;
create table t1 (f double(4,3));
insert ignore into t1 values (-11.0),(-11),("-11"),(11.0),(11),("11");
Warnings:
Warning	1264	Out of range value for column 'f' at row 1
Warning	1264	Out of range value for column 'f' at row 2
Warning	1264	Out of range value for column 'f' at row 3
Warning	1264	Out of range value for column 'f' at row 4
Warning	1264	Out of range value for column 'f' at row 5
Warning	1264	Out of range value for column 'f' at row 6
select * from t1;
f
-9.999
-9.999
-9.999
9.999
9.999
9.999
drop table if exists t1;
create table t1 (c char(20));
insert into t1 values (5e-28);
select * from t1;
c
5e-28
drop table t1;
create table t1 (c char(6));
insert into t1 values (2e5),(2e6),(2e-4),(2e-5);
select * from t1;
c
200000
2e6
0.0002
2e-5
drop table t1;
CREATE TABLE t1 (
reckey int unsigned NOT NULL,
recdesc varchar(50) NOT NULL,
PRIMARY KEY  (reckey)
) ENGINE=MyISAM DEFAULT CHARSET=latin1;
INSERT INTO t1 VALUES (108, 'Has 108 as key');
INSERT INTO t1 VALUES (109, 'Has 109 as key');
select * from t1 where reckey=108;
reckey	recdesc
108	Has 108 as key
select * from t1 where reckey=1.08E2;
reckey	recdesc
108	Has 108 as key
select * from t1 where reckey=109;
reckey	recdesc
109	Has 109 as key
select * from t1 where reckey=1.09E2;
reckey	recdesc
109	Has 109 as key
drop table t1;
create table t1 (d double(10,1));
create table t2 (d double(10,9));
insert into t1 values ("100000000.0");
insert into t2 values ("1.23456780");
create table t3 select * from t2 union select * from t1;
select * from t3;
d
1.234567800
100000000.000000000
show create table t3;
Table	Create Table
t3	CREATE TABLE `t3` (
  `d` double(18,9) DEFAULT NULL
) ENGINE=MyISAM DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_uca1400_ai_ci
drop table t1, t2, t3;
create table t1 select  105213674794682365.00 + 0.0 x;
show warnings;
Level	Code	Message
desc  t1;
Field	Type	Null	Key	Default	Extra
x	decimal(21,2)	NO		NULL	
drop table t1;
create table t1 select 0.0 x;
desc t1;
Field	Type	Null	Key	Default	Extra
x	decimal(2,1)	NO		NULL	
create table t2 select 105213674794682365.00 y;
desc t2;
Field	Type	Null	Key	Default	Extra
y	decimal(20,2)	NO		NULL	
create table t3 select x+y a from t1,t2;
show warnings;
Level	Code	Message
desc t3;
Field	Type	Null	Key	Default	Extra
a	decimal(21,2)	NO		NULL	
drop table t1,t2,t3;
select 1e-308, 1.00000001e-300, 100000000e-300;
1e-308	1.00000001e-300	100000000e-300
1e-308	1.00000001e-300	1e-292
select 10e307;
10e307
1e308
create table t1(a int, b double(8, 2));
insert into t1 values
(1, 28.50), (1, 121.85), (1, 157.23), (1, 1351.00), (1, -1965.35), (1, 81.75), 
(1, 217.08), (1, 7.94), (4, 96.07), (4, 6404.65), (4, -6500.72), (2, 100.00),
(5, 5.00), (5, -2104.80), (5, 2033.80), (5, 0.07), (5, 65.93),
(3, -4986.24), (3, 5.00), (3, 4857.34), (3, 123.74), (3,  0.16),
(6, -1695.31), (6, 1003.77), (6, 499.72), (6, 191.82);
explain select sum(b) s from t1 group by a;
id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
1	SIMPLE	t1	ALL	NULL	NULL	NULL	NULL	26	Using temporary; Using filesort
select sum(b) s from t1 group by a;
s
0.00
100.00
0.00
-0.00
-0.00
0.00
select sum(b) s from t1 group by a having s <> 0;
s
100.00
select sum(b) s from t1 group by a having s <> 0 order by s;
s
100.00
select sum(b) s from t1 group by a having s <=> 0;
s
0.00
0.00
-0.00
-0.00
0.00
select sum(b) s from t1 group by a having s <=> 0 order by s;
s
-0.00
-0.00
0.00
0.00
0.00
alter table t1 add key (a, b);
explain select sum(b) s from t1 group by a;
id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
1	SIMPLE	t1	index	NULL	a	14	NULL	26	Using index
select sum(b) s from t1 group by a;
s
0.00
100.00
0.00
-0.00
0.00
0.00
select sum(b) s from t1 group by a having s <> 0;
s
100.00
select sum(b) s from t1 group by a having s <> 0 order by s;
s
100.00
select sum(b) s from t1 group by a having s <=> 0;
s
0.00
0.00
-0.00
0.00
0.00
select sum(b) s from t1 group by a having s <=> 0 order by s;
s
-0.00
0.00
0.00
0.00
0.00
drop table t1;
End of 4.1 tests
create table t1 (s1 float(0,2));
ERROR 42000: For float(M,D), double(M,D) or decimal(M,D), M must be >= D (column 's1')
create table t1 (s1 float(1,2));
ERROR 42000: For float(M,D), double(M,D) or decimal(M,D), M must be >= D (column 's1')
CREATE TABLE t1 (
f1 real zerofill,
f2 double zerofill,
f3 float zerofill);
INSERT INTO t1 VALUES ( 0.314152e+1, 0.314152e+1, 0.314152e+1);
PREPARE stmt1 FROM 'select f1, f2, f3 FROM t1';
select f1, f2, f3 FROM t1;
f1	f2	f3
0000000000000003.14152	0000000000000003.14152	000003.14152
select f1, f2, f3 FROM t1;
f1	f2	f3
0000000000000003.14152	0000000000000003.14152	000003.14152
EXECUTE stmt1;
f1	f2	f3
0000000000000003.14152	0000000000000003.14152	000003.14152
DROP TABLE t1;
create table t1 (f1 double(200, 0));
insert into t1 values (1e199), (-1e199);
insert into t1 values (1e200), (-1e200);
insert ignore into t1 values (2e200), (-2e200);
Warnings:
Warning	1264	Out of range value for column 'f1' at row 1
Warning	1264	Out of range value for column 'f1' at row 2
select f1 + 0e0 from t1;
f1 + 0e0
1e199
-1e199
1e200
-1e200
1e200
-1e200
drop table t1;
create table t1 (f1 float(30, 0));
insert into t1 values (1e29), (-1e29);
insert into t1 values (1e30), (-1e30);
insert ignore into t1 values (2e30), (-2e30);
Warnings:
Warning	1264	Out of range value for column 'f1' at row 1
Warning	1264	Out of range value for column 'f1' at row 2
select f1 + 0e0 from t1;
f1 + 0e0
1.0000000150474662e29
-1.0000000150474662e29
1.0000000150474662e30
-1.0000000150474662e30
1.0000000150474662e30
-1.0000000150474662e30
drop table t1;
create table t1 (c char(6));
insert into t1 values (2e6),(2e-5);
select * from t1;
c
2e6
2e-5
drop table t1;
CREATE TABLE d1 (d DOUBLE);
INSERT INTO d1 VALUES (1.7976931348623157E+308);
SELECT * FROM d1;
d
1.7976931348623157e308
INSERT INTO d1 VALUES (1.79769313486232e+308);
ERROR 22007: Illegal double '1.79769313486232e+308' value found during parsing
SELECT * FROM d1;
d
1.7976931348623157e308
DROP TABLE d1;
create table t1 (a char(20));
insert into t1 values (1.225e-05);
select a+0 from t1;
a+0
0.00001225
drop table t1;
create table t1(d double, u bigint unsigned);
insert into t1(d) values (9.22337203685479e18),
(1.84e19);
update t1 set u = d;
select u from t1;
u
9223372036854790144
18400000000000000000
drop table t1;
CREATE TABLE t1 (f1 DOUBLE);
INSERT INTO t1 VALUES(-1.79769313486231e+308);
SELECT f1 FROM t1;
f1
-1.79769313486231e308
DROP TABLE t1;
#
# Bug#12406055 BUFFER OVERFLOW OF VARIABLE 'BUFF' IN STRING::SET_REAL
# 
# Ignoring output from misc. float operations
select format(-1.7976931348623157E+307,256) as foo;
select least(-1.1111111111111111111111111,
- group_concat(1.7976931348623157E+308)) as foo;
select concat((truncate((-1.7976931348623157E+307),(0x1e))),
(99999999999999999999999999999999999999999999999999999999999999999)) into @a;
End of 5.0 tests
#
# Bug#12368853 FORMAT() CRASHES WITH LARGE NUMBERS AFTER TRUNCATE...
#
select format(truncate('1.7976931348623157E+308',-12),1,'fr_BE') as foo;
foo
0
#
# MDEV-17249 MAKETIME(-1e50,0,0) returns a wrong result
#
SELECT LEFT('a',EXP(50));
LEFT('a',EXP(50))
a
SELECT LEFT('a', COALESCE(1e30));
LEFT('a', COALESCE(1e30))
a
CREATE TABLE t1 (a FLOAT);
INSERT INTO t1 VALUES (1e30);
SELECT LEFT('a',a), LEFT('a',1e30) FROM t1;
LEFT('a',a)	LEFT('a',1e30)
a	a
DROP TABLE t1;
PREPARE stmt FROM 'SELECT LEFT(111,?)';
SET @a=1e30;
EXECUTE stmt USING @a;
LEFT(111,?)
111
DEALLOCATE PREPARE stmt;
CREATE TABLE t1 (a INT);
INSERT INTO t1 VALUES (1),(2),(3);
SELECT LEFT('a',(SELECT 1e30 FROM t1 LIMIT 1));
LEFT('a',(SELECT 1e30 FROM t1 LIMIT 1))
a
DROP TABLE t1;
CREATE TABLE t1 (a DOUBLE);
INSERT INTO t1 VALUES (1e30),(0);
SELECT LEFT('a', SUM(a)) FROM t1;
LEFT('a', SUM(a))
a
Warnings:
Warning	1916	Got overflow when converting '1e30' to INT. Value truncated
SELECT LEFT('a', AVG(a)) FROM t1;
LEFT('a', AVG(a))
a
Warnings:
Warning	1916	Got overflow when converting '5e29' to INT. Value truncated
DROP TABLE t1;
#
# Bug #13500371 63704: CONVERSION OF '1.' TO A NUMBER GIVES ERROR 1265
# (WARN_DATA_TRUNCATED)
#
CREATE TABLE t1 (f FLOAT);
INSERT INTO t1 VALUES ('1.');
INSERT IGNORE INTO t1 VALUES ('2.0.');
Warnings:
Warning	1265	Data truncated for column 'f' at row 1
INSERT IGNORE INTO t1 VALUES ('.');
Warnings:
Warning	1366	Incorrect double value: '.' for column `test`.`t1`.`f` at row 1
SELECT * FROM t1 ORDER BY f;
f
0
1
2
DROP TABLE t1;
#
# Start of 10.0 tests
#
#
# MDEV-6950 Bad results with joins comparing DATE/DATETIME and INT/DECIMAL/DOUBLE/ENUM/VARCHAR columns
#
CREATE TABLE t1 (a DATETIME PRIMARY KEY);
INSERT INTO t1 VALUES ('1999-01-01 00:00:00');
CREATE TABLE t2 (a DOUBLE);
INSERT INTO t2 VALUES (19990101000000);
INSERT INTO t2 VALUES (990101000000);
SELECT t1.* FROM t1,t2 WHERE t1.a=t2.a;
a
1999-01-01 00:00:00
1999-01-01 00:00:00
SELECT t1.* FROM t1 LEFT JOIN t2 ON t1.a=t2.a;
a
1999-01-01 00:00:00
1999-01-01 00:00:00
ALTER TABLE t2 ADD PRIMARY KEY(a);
SELECT t1.* FROM t1,t2 WHERE t1.a=t2.a;
a
1999-01-01 00:00:00
1999-01-01 00:00:00
SELECT t1.* FROM t1 LEFT JOIN t2 ON t1.a=t2.a;
a
1999-01-01 00:00:00
1999-01-01 00:00:00
# t2 should NOT be eliminated
EXPLAIN SELECT t1.* FROM t1 LEFT JOIN t2 ON t1.a=t2.a;
id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
1	SIMPLE	t1	system	NULL	NULL	NULL	NULL	1	
1	SIMPLE	t2	index	PRIMARY	PRIMARY	8	NULL	2	Using where; Using index
Warnings:
Note	1105	Cannot use key `PRIMARY` part[0] for lookup: `test`.`t2`.`a` of type `double` = "`t1`.`a`" of type `datetime`
DROP TABLE t1,t2;
#
# MDEV-6971 Bad results with joins comparing TIME and DOUBLE/DECIMAL columns
#
CREATE TABLE t1 (a TIME(6) PRIMARY KEY);
INSERT INTO t1 VALUES ('10:20:30');
CREATE TABLE t2 (a DOUBLE);
INSERT INTO t2 VALUES (102030),(102030.000000001);
SELECT t1.* FROM t1 JOIN t2 USING(a);
a
10:20:30.000000
10:20:30.000000
SELECT t1.* FROM t1 LEFT JOIN t2 USING(a);
a
10:20:30.000000
10:20:30.000000
ALTER TABLE t2 ADD PRIMARY KEY(a);
SELECT t1.* FROM t1 JOIN t2 USING(a);
a
10:20:30.000000
10:20:30.000000
SELECT t1.* FROM t1 LEFT JOIN t2 USING(a);
a
10:20:30.000000
10:20:30.000000
# t2 should NOT be elimitated
EXPLAIN SELECT t1.* FROM t1 LEFT JOIN t2 USING(a);
id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
1	SIMPLE	t1	system	NULL	NULL	NULL	NULL	1	
1	SIMPLE	t2	index	PRIMARY	PRIMARY	8	NULL	2	Using where; Using index
Warnings:
Note	1105	Cannot use key `PRIMARY` part[0] for lookup: `test`.`t2`.`a` of type `double` = "`t1`.`a`" of type `time`
DROP TABLE t1,t2;
#
# End of 10.0 tests
#
#
# MDEV-8704 Wrong result for SELECT..WHERE LENGTH(double_column)!=6 AND double_column=100e0
#
CREATE TABLE t1 (a DOUBLE(9,2));
INSERT INTO t1 VALUES (100),(110);
SELECT * FROM t1 WHERE LENGTH(a)!=6;
a
SELECT * FROM t1 WHERE LENGTH(a)!=6 AND a=100e0;
a
DROP TABLE t1;
CREATE TABLE t1 (a DOUBLE);
INSERT INTO t1 VALUES (100),(110);
SELECT * FROM t1 WHERE LENGTH(a)!=6;
a
100
110
SELECT * FROM t1 WHERE LENGTH(a)!=6 AND a=100e0;
a
100
EXPLAIN EXTENDED
SELECT * FROM t1 WHERE LENGTH(a)!=6 AND a=100e0;
id	select_type	table	type	possible_keys	key	key_len	ref	rows	filtered	Extra
1	SIMPLE	t1	ALL	NULL	NULL	NULL	NULL	2	100.00	Using where
Warnings:
Note	1003	select `test`.`t1`.`a` AS `a` from `test`.`t1` where `test`.`t1`.`a` = 100e0
EXPLAIN EXTENDED
SELECT * FROM t1 WHERE LENGTH(a)!=RAND() AND a=100e0;
id	select_type	table	type	possible_keys	key	key_len	ref	rows	filtered	Extra
1	SIMPLE	t1	ALL	NULL	NULL	NULL	NULL	2	100.00	Using where
Warnings:
Note	1003	select `test`.`t1`.`a` AS `a` from `test`.`t1` where `test`.`t1`.`a` = 100e0 and <cache>(octet_length(100)) <> rand()
DROP TABLE t1;
CREATE TABLE t1 (a DOUBLE(10,1));
INSERT INTO t1 VALUES (1.1),(1.2),(1.3);
SELECT * FROM t1 WHERE LENGTH(a)!=3;
a
SELECT * FROM t1 WHERE LENGTH(a)!=3 AND a=1.10e0;
a
EXPLAIN EXTENDED
SELECT * FROM t1 WHERE LENGTH(a)!=3 AND a=1.10e0;
id	select_type	table	type	possible_keys	key	key_len	ref	rows	filtered	Extra
1	SIMPLE	NULL	NULL	NULL	NULL	NULL	NULL	NULL	NULL	Impossible WHERE
Warnings:
Note	1003	select `test`.`t1`.`a` AS `a` from `test`.`t1` where 0
# Notice 1.1 instead of 1.10 in the final WHERE condition
EXPLAIN EXTENDED
SELECT * FROM t1 WHERE LENGTH(a)!=RAND() AND a=1.10e0;
id	select_type	table	type	possible_keys	key	key_len	ref	rows	filtered	Extra
1	SIMPLE	t1	ALL	NULL	NULL	NULL	NULL	3	100.00	Using where
Warnings:
Note	1003	select `test`.`t1`.`a` AS `a` from `test`.`t1` where `test`.`t1`.`a` = 1.10e0 and <cache>(octet_length(1.1)) <> rand()
DROP TABLE t1;
CREATE TABLE t1 (a DOUBLE(10,2));
INSERT INTO t1 VALUES (1.1),(1.2),(1.3);
SELECT * FROM t1 WHERE LENGTH(a)!=4;
a
SELECT * FROM t1 WHERE LENGTH(a)!=4 AND a=1.10e0;
a
EXPLAIN EXTENDED
SELECT * FROM t1 WHERE LENGTH(a)!=4 AND a=1.10e0;
id	select_type	table	type	possible_keys	key	key_len	ref	rows	filtered	Extra
1	SIMPLE	NULL	NULL	NULL	NULL	NULL	NULL	NULL	NULL	Impossible WHERE
Warnings:
Note	1003	select `test`.`t1`.`a` AS `a` from `test`.`t1` where 0
# Notice 1.10 in the final WHERE condition
EXPLAIN EXTENDED
SELECT * FROM t1 WHERE LENGTH(a)!=RAND() AND a=1.10e0;
id	select_type	table	type	possible_keys	key	key_len	ref	rows	filtered	Extra
1	SIMPLE	t1	ALL	NULL	NULL	NULL	NULL	3	100.00	Using where
Warnings:
Note	1003	select `test`.`t1`.`a` AS `a` from `test`.`t1` where `test`.`t1`.`a` = 1.10e0 and <cache>(octet_length(1.10)) <> rand()
DROP TABLE t1;
CREATE TABLE t1 (a DOUBLE(10,3));
INSERT INTO t1 VALUES (1.1),(1.2),(1.3);
SELECT * FROM t1 WHERE LENGTH(a)!=5;
a
SELECT * FROM t1 WHERE LENGTH(a)!=5 AND a=1.10e0;
a
EXPLAIN EXTENDED
SELECT * FROM t1 WHERE LENGTH(a)!=5 AND a=1.10e0;
id	select_type	table	type	possible_keys	key	key_len	ref	rows	filtered	Extra
1	SIMPLE	NULL	NULL	NULL	NULL	NULL	NULL	NULL	NULL	Impossible WHERE
Warnings:
Note	1003	select `test`.`t1`.`a` AS `a` from `test`.`t1` where 0
# Notice 1.100 rather than 1.10 in the final WHERE condition
EXPLAIN EXTENDED
SELECT * FROM t1 WHERE LENGTH(a)!=RAND() AND a=1.10e0;
id	select_type	table	type	possible_keys	key	key_len	ref	rows	filtered	Extra
1	SIMPLE	t1	ALL	NULL	NULL	NULL	NULL	3	100.00	Using where
Warnings:
Note	1003	select `test`.`t1`.`a` AS `a` from `test`.`t1` where `test`.`t1`.`a` = 1.10e0 and <cache>(octet_length(1.100)) <> rand()
DROP TABLE t1;
#
# MDEV-8741 Equal field propagation leaves some remainders after simplifying WHERE zerofill_column=2010 AND zerofill_column>=2010
#
CREATE TABLE t1 (a DOUBLE ZEROFILL);
INSERT INTO t1 VALUES (2010),(2020);
EXPLAIN EXTENDED SELECT * FROM t1 WHERE a=2010e0 AND a>=2010e0;
id	select_type	table	type	possible_keys	key	key_len	ref	rows	filtered	Extra
1	SIMPLE	t1	ALL	NULL	NULL	NULL	NULL	2	100.00	Using where
Warnings:
Note	1003	select `test`.`t1`.`a` AS `a` from `test`.`t1` where `test`.`t1`.`a` = 2010e0
DROP TABLE t1;
#
# MDEV-23282 FLOAT(53,0) badly handles out-of-range values
#
CREATE OR REPLACE TABLE t1 (c1 FLOAT NOT NULL, c2 FLOAT NOT NULL);
INSERT IGNORE INTO t1 VALUES (1e+40, -1e+40);
Warnings:
Warning	1264	Out of range value for column 'c1' at row 1
Warning	1264	Out of range value for column 'c2' at row 1
SELECT c1, c2 FROM t1;
c1	c2
3.40282e38	-3.40282e38
DROP TABLE t1;
CREATE OR REPLACE TABLE t1 (c1 FLOAT(53,0) NOT NULL, c2 FLOAT(53,0) NOT NULL);
INSERT IGNORE INTO t1 VALUES (1e+40, -1e+40);
Warnings:
Warning	1264	Out of range value for column 'c1' at row 1
Warning	1264	Out of range value for column 'c2' at row 1
SELECT c1, c2 FROM t1;
c1	c2
340282346638528860000000000000000000000	-340282346638528860000000000000000000000
DROP TABLE t1;
#
# End of 10.1 tests
#
#
# Start of 10.2 tests
#
#
# MDEV-4102 Limitation on DOUBLE or REAL length is ignored with INSERT .. SELECT
#
CREATE TABLE t1 (d1 DOUBLE(5,2), d2 DOUBLE(10,2));
INSERT IGNORE INTO t1 VALUES (10000000.55, 10000000.55);
Warnings:
Warning	1264	Out of range value for column 'd1' at row 1
INSERT IGNORE INTO t1 SELECT d2, d2 FROM t1;
Warnings:
Warning	1264	Out of range value for column 'd1' at row 1
SELECT * FROM t1;
d1	d2
999.99	10000000.55
999.99	10000000.55
DROP TABLE t1;
#
# MDEV-9709 Unexpected modification of value and warning about out of range value upon ALTER
#
CREATE TABLE t1 (
f FLOAT,
d10_10 DOUBLE PRECISION (10,10),
d53_10 DOUBLE(53,10)
);
INSERT IGNORE INTO t1 (f,d10_10,d53_10) VALUES (
-9999999999999999999999999999999999999999999.9999999999,
-9999999999999999999999999999999999999999999.9999999999,
-9999999999999999999999999999999999999999999.9999999999
);
Warnings:
Warning	1264	Out of range value for column 'f' at row 1
Warning	1264	Out of range value for column 'd10_10' at row 1
SELECT * FROM t1;
f	-3.40282e38
d10_10	-0.9999999999
d53_10	-10000000000000000000000000000000000000000000.0000000000
INSERT IGNORE INTO t1 (f,d10_10,d53_10) SELECT d53_10, d53_10, d53_10 FROM t1;
Warnings:
Level	Warning
Code	1264
Message	Out of range value for column 'f' at row 1
Level	Warning
Code	1264
Message	Out of range value for column 'd10_10' at row 1
SELECT * FROM t1;
f	-3.40282e38
d10_10	-0.9999999999
d53_10	-10000000000000000000000000000000000000000000.0000000000
f	-3.40282e38
d10_10	-0.9999999999
d53_10	-10000000000000000000000000000000000000000000.0000000000
ALTER TABLE t1 ADD COLUMN i INT;
SELECT * FROM t1;
f	-3.40282e38
d10_10	-0.9999999999
d53_10	-10000000000000000000000000000000000000000000.0000000000
i	NULL
f	-3.40282e38
d10_10	-0.9999999999
d53_10	-10000000000000000000000000000000000000000000.0000000000
i	NULL
DROP TABLE t1;
CREATE TABLE t1 (d10_10 DOUBLE (10,10));
CREATE TABLE t2 (d53_10 DOUBLE (53,10));
INSERT INTO t2 VALUES (-9999999999999999999999999999999999999999999.9999999999);
INSERT IGNORE INTO t1 (d10_10) SELECT d53_10 FROM t2;
Warnings:
Warning	1264	Out of range value for column 'd10_10' at row 1
SELECT * FROM t1;
d10_10
-0.9999999999
DROP TABLE t1,t2;
CREATE TABLE t1 (d2_2 FLOAT (2,2));
CREATE TABLE t2 (d4_2 FLOAT (4,2));
INSERT INTO t2 VALUES (99.99);
INSERT IGNORE INTO t1 (d2_2) SELECT d4_2 FROM t2;
Warnings:
Warning	1264	Out of range value for column 'd2_2' at row 1
SELECT * FROM t1;
d2_2
0.99
DROP TABLE t1,t2;
#
# Test of using wrong scale
#
create or replace table t1 (a double(40,30));
create or replace table t1 (a double(40,31));
ERROR 42000: Too big scale specified for 'a'. Maximum is 30
create or replace table t1 as select 1.01e1;
show create table t1;
Table	Create Table
t1	CREATE TABLE `t1` (
  `1.01e1` double NOT NULL
) ENGINE=MyISAM DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_uca1400_ai_ci
create or replace table t1 as select truncate(10.000000000001e1, 30) as t;
show create table t1;
Table	Create Table
t1	CREATE TABLE `t1` (
  `t` double(47,30) NOT NULL
) ENGINE=MyISAM DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_uca1400_ai_ci
create or replace table t1 as select truncate(10.000000000001e1, 31) as t;
show create table t1;
Table	Create Table
t1	CREATE TABLE `t1` (
  `t` double NOT NULL
) ENGINE=MyISAM DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_uca1400_ai_ci
create or replace table t1 as select truncate(10.000000000001e1, 39) as t;
show create table t1;
Table	Create Table
t1	CREATE TABLE `t1` (
  `t` double NOT NULL
) ENGINE=MyISAM DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_uca1400_ai_ci
create or replace table t1 as select truncate(10.000000000001e1, 51) as t;
show create table t1;
Table	Create Table
t1	CREATE TABLE `t1` (
  `t` double NOT NULL
) ENGINE=MyISAM DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_uca1400_ai_ci
create or replace table t1 as select truncate(10.000000000001e1, 20)/2 as t;
show create table t1;
Table	Create Table
t1	CREATE TABLE `t1` (
  `t` double(41,24) DEFAULT NULL
) ENGINE=MyISAM DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_uca1400_ai_ci
create or replace table t1 as select truncate(10.000000000001e1, 28)/2 as t;
show create table t1;
Table	Create Table
t1	CREATE TABLE `t1` (
  `t` double DEFAULT NULL
) ENGINE=MyISAM DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_uca1400_ai_ci
drop table if exists t1;
#
# MDEV-11586 UNION of FLOAT type results in erroneous precision
#
CREATE TABLE t1 (f FLOAT);
INSERT INTO t1 VALUES (1.1);
SELECT f FROM t1 UNION SELECT 1;
f
1.100000023841858
1
SELECT 1 UNION SELECT f FROM t1;
1
1
1.100000023841858
SELECT f FROM t1 UNION SELECT 2147483647;
f
1.100000023841858
2147483647
SELECT 2147483647 UNION SELECT f FROM t1;
2147483647
2147483647
1.100000023841858
SELECT CASE WHEN 0 THEN (SELECT f FROM t1) ELSE 2147483647 END AS c1,
CASE WHEN 1 THEN 2147483647 ELSE (SELECT f FROM t1) END AS c2;
c1	c2
2147483647	2147483647
DROP TABLE t1;
#
# End of 10.2 tests
#
#
# MDEV-19468 Hybrid type expressions return wrong format for FLOAT
#
CREATE TABLE t1 (a FLOAT);
INSERT INTO t1 VALUES (0.671437);
SELECT a, COALESCE(a), MAX(a), LEAST(a,a), (SELECT a FROM t1) AS c FROM t1;
a	COALESCE(a)	MAX(a)	LEAST(a,a)	c
0.671437	0.671437	0.671437	0.671437	0.671437
DROP TABLE t1;
CREATE TABLE t1 (a FLOAT);
INSERT INTO t1 VALUES (0.671437);
SELECT
CONCAT(a),
CONCAT(COALESCE(a)),
CONCAT(LEAST(a,a)),
CONCAT(MAX(a)),
CONCAT((SELECT a FROM t1)) AS c
FROM t1;
CONCAT(a)	CONCAT(COALESCE(a))	CONCAT(LEAST(a,a))	CONCAT(MAX(a))	c
0.671437	0.671437	0.671437	0.671437	0.671437
CREATE TABLE t2 AS SELECT
CONCAT(a),
CONCAT(COALESCE(a)),
CONCAT(LEAST(a,a)),
CONCAT(MAX(a)),
CONCAT((SELECT a FROM t1)) AS c
FROM t1;
SELECT * FROM t2;
CONCAT(a)	CONCAT(COALESCE(a))	CONCAT(LEAST(a,a))	CONCAT(MAX(a))	c
0.671437	0.671437	0.671437	0.671437	0.671437
DROP TABLE t1, t2;
#
# MDEV-16872 Add CAST(expr AS FLOAT)
#
SELECT CAST(0.671437 AS FLOAT), CONCAT(CAST(0.671437 AS FLOAT));
CAST(0.671437 AS FLOAT)	CONCAT(CAST(0.671437 AS FLOAT))
0.671437	0.671437
SELECT CAST(1e40 AS FLOAT), CONCAT(CAST(1e40 AS FLOAT));
CAST(1e40 AS FLOAT)	CONCAT(CAST(1e40 AS FLOAT))
3.40282e38	3.40282e38
Warnings:
Note	1264	Out of range value for column 'CAST(1e40 AS FLOAT)' at row 1
Note	1264	Out of range value for column 'CAST(1e40 AS FLOAT)' at row 1
SELECT CAST(-1e40 AS FLOAT), CONCAT(CAST(-1e40 AS FLOAT));
CAST(-1e40 AS FLOAT)	CONCAT(CAST(-1e40 AS FLOAT))
-3.40282e38	-3.40282e38
Warnings:
Note	1264	Out of range value for column 'CAST(-1e40 AS FLOAT)' at row 1
Note	1264	Out of range value for column 'CAST(-1e40 AS FLOAT)' at row 1
SET sql_mode='STRICT_ALL_TABLES,STRICT_TRANS_TABLES';
CREATE TABLE t1 (a FLOAT);
INSERT INTO t1 VALUES (CAST(1e40 AS FLOAT));
Warnings:
Note	1264	Out of range value for column 'CAST(1e40 AS FLOAT)' at row 1
SELECT * FROM t1;
a
3.40282e38
DROP TABLE t1;
SET sql_mode=DEFAULT;
EXPLAIN EXTENDED SELECT CAST(0.671437 AS FLOAT);
id	select_type	table	type	possible_keys	key	key_len	ref	rows	filtered	Extra
1	SIMPLE	NULL	NULL	NULL	NULL	NULL	NULL	NULL	NULL	No tables used
Warnings:
Note	1003	select cast(0.671437 as float) AS `CAST(0.671437 AS FLOAT)`
CREATE TABLE t1 AS SELECT CAST(0.671437 AS FLOAT) AS c1;
SHOW CREATE TABLE t1;
Table	Create Table
t1	CREATE TABLE `t1` (
  `c1` float DEFAULT NULL
) ENGINE=MyISAM DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_uca1400_ai_ci
SELECT * FROM t1;
c1
0.671437
DROP TABLE t1;
CREATE TABLE t1 (a FLOAT);
CREATE TABLE t2 AS SELECT CONCAT(a) AS c1, CONCAT(CAST(a AS FLOAT)) AS c2 FROM t1;
SHOW CREATE TABLE t2;
Table	Create Table
t2	CREATE TABLE `t2` (
  `c1` varchar(12) CHARACTER SET latin1 COLLATE latin1_swedish_ci DEFAULT NULL,
  `c2` varchar(12) CHARACTER SET latin1 COLLATE latin1_swedish_ci DEFAULT NULL
) ENGINE=MyISAM DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_uca1400_ai_ci
DROP TABLE t1, t2;
CREATE TABLE t1 (a FLOAT DEFAULT CAST(0.671437 AS FLOAT));
SHOW CREATE TABLE t1;
Table	Create Table
t1	CREATE TABLE `t1` (
  `a` float DEFAULT (cast(0.671437 as float))
) ENGINE=MyISAM DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_uca1400_ai_ci
DROP TABLE t1;
CREATE TABLE t1 (id INT NOT NULL PRIMARY KEY, a FLOAT);
INSERT INTO t1 VALUES (1, 0.671437),(2, 0.671437);
DELETE FROM t1 WHERE a=0.671437;
SELECT * FROM t1;
id	a
1	0.671437
2	0.671437
DELETE FROM t1 WHERE a=CAST(0.671437 AS FLOAT);
DROP TABLE t1;
#
# MDEV-29473 UBSAN: Signed integer overflow: X * Y cannot be represented in type 'int' in strings/dtoa.c
#
CREATE TABLE t1 (c DOUBLE);
INSERT INTO t1 VALUES ('1e4294967297');
ERROR 22003: Out of range value for column 'c' at row 1
DROP TABLE t1;
#
# End of 10.3 tests
#
#
# MDEV-11362 True condition elimination does not work for DECIMAL and temporal dynamic SQL parameters
#
CREATE TABLE t1 (a DOUBLE);
INSERT INTO t1 VALUES (1),(2),(3);
EXPLAIN EXTENDED SELECT * FROM t1 WHERE 1e0+a<=>1e0+a;
id	select_type	table	type	possible_keys	key	key_len	ref	rows	filtered	Extra
1	SIMPLE	t1	ALL	NULL	NULL	NULL	NULL	3	100.00	
Warnings:
Note	1003	select `test`.`t1`.`a` AS `a` from `test`.`t1` where 1
EXECUTE IMMEDIATE 'EXPLAIN EXTENDED SELECT * FROM t1 WHERE ?+a<=>?+a' USING 1e0,1e0;
id	select_type	table	type	possible_keys	key	key_len	ref	rows	filtered	Extra
1	SIMPLE	t1	ALL	NULL	NULL	NULL	NULL	3	100.00	
Warnings:
Note	1003	select `test`.`t1`.`a` AS `a` from `test`.`t1` where 1
EXECUTE IMMEDIATE 'EXPLAIN EXTENDED SELECT * FROM t1 WHERE ?+a<=>1e0+a' USING 1e0;
id	select_type	table	type	possible_keys	key	key_len	ref	rows	filtered	Extra
1	SIMPLE	t1	ALL	NULL	NULL	NULL	NULL	3	100.00	
Warnings:
Note	1003	select `test`.`t1`.`a` AS `a` from `test`.`t1` where 1
EXECUTE IMMEDIATE 'EXPLAIN EXTENDED SELECT * FROM t1 WHERE 1e0+a<=>?+a' USING 1e0;
id	select_type	table	type	possible_keys	key	key_len	ref	rows	filtered	Extra
1	SIMPLE	t1	ALL	NULL	NULL	NULL	NULL	3	100.00	
Warnings:
Note	1003	select `test`.`t1`.`a` AS `a` from `test`.`t1` where 1
DROP TABLE t1;
#
# MDEV-23415 Server crash or Assertion `dec_length <= str_length' failed in Item_func_format::val_str_ascii
#
SELECT FORMAT('0', 50, 'de_DE');
FORMAT('0', 50, 'de_DE')
0,00000000000000000000000000000000000000
SELECT FORMAT(0e0, 50, 'de_DE');
FORMAT(0e0, 50, 'de_DE')
0,00000000000000000000000000000000000000
FOR d IN 0..50
DO
SELECT
d,
FORMAT(123456789.123456789e0, d, 'de_DE') AS fdbl,
FORMAT(123456789.123456789, d, 'de_DE') AS fdec;
END FOR;
$$
d	0
fdbl	123.456.789
fdec	123.456.789
d	1
fdbl	123.456.789,1
fdec	123.456.789,1
d	2
fdbl	123.456.789,12
fdec	123.456.789,12
d	3
fdbl	123.456.789,123
fdec	123.456.789,123
d	4
fdbl	123.456.789,1235
fdec	123.456.789,1235
d	5
fdbl	123.456.789,12346
fdec	123.456.789,12346
d	6
fdbl	123.456.789,123457
fdec	123.456.789,123457
d	7
fdbl	123.456.789,1234568
fdec	123.456.789,1234568
d	8
fdbl	123.456.789,12345680
fdec	123.456.789,12345679
d	9
fdbl	123.456.789,123456790
fdec	123.456.789,123456789
d	10
fdbl	123.456.789,1234567900
fdec	123.456.789,1234567890
d	11
fdbl	123.456.789,12345680000
fdec	123.456.789,12345678900
d	12
fdbl	123.456.789,123456790000
fdec	123.456.789,123456789000
d	13
fdbl	123.456.789,1234568000000
fdec	123.456.789,1234567890000
d	14
fdbl	123.456.789,12345679000000
fdec	123.456.789,12345678900000
d	15
fdbl	123.456.789,123456790000000
fdec	123.456.789,123456789000000
d	16
fdbl	123.456.789,1234567800000000
fdec	123.456.789,1234567890000000
d	17
fdbl	123.456.789,12345679000000000
fdec	123.456.789,12345678900000000
d	18
fdbl	123.456.789,123456790000000000
fdec	123.456.789,123456789000000000
d	19
fdbl	123.456.789,1234567900000000000
fdec	123.456.789,1234567890000000000
d	20
fdbl	123.456.789,12345679000000000000
fdec	123.456.789,12345678900000000000
d	21
fdbl	123.456.789,123456800000000000000
fdec	123.456.789,123456789000000000000
d	22
fdbl	123.456.789,1234567900000000000000
fdec	123.456.789,1234567890000000000000
d	23
fdbl	123.456.789,12345680000000000000000
fdec	123.456.789,12345678900000000000000
d	24
fdbl	123.456.789,123456790000000000000000
fdec	123.456.789,123456789000000000000000
d	25
fdbl	123.456.789,1234567900000000000000000
fdec	123.456.789,1234567890000000000000000
d	26
fdbl	123.456.789,12345679000000000000000000
fdec	123.456.789,12345678900000000000000000
d	27
fdbl	123.456.789,123456780000000000000000000
fdec	123.456.789,123456789000000000000000000
d	28
fdbl	123.456.789,1234567900000000000000000000
fdec	123.456.789,1234567890000000000000000000
d	29
fdbl	123.456.789,12345678000000000000000000000
fdec	123.456.789,12345678900000000000000000000
d	30
fdbl	123.456.789,123456790000000000000000000000
fdec	123.456.789,123456789000000000000000000000
d	31
fdbl	123.456.789,1234567900000000000000000000000
fdec	123.456.789,1234567890000000000000000000000
d	32
fdbl	123.456.789,12345679000000000000000000000000
fdec	123.456.789,12345678900000000000000000000000
d	33
fdbl	123.456.789,123456790000000000000000000000000
fdec	123.456.789,123456789000000000000000000000000
d	34
fdbl	123.456.789,1234567900000000000000000000000000
fdec	123.456.789,1234567890000000000000000000000000
d	35
fdbl	123.456.789,12345679000000000000000000000000000
fdec	123.456.789,12345678900000000000000000000000000
d	36
fdbl	123.456.789,123456790000000000000000000000000000
fdec	123.456.789,123456789000000000000000000000000000
d	37
fdbl	123.456.789,1234567900000000000000000000000000000
fdec	123.456.789,1234567890000000000000000000000000000
d	38
fdbl	123.456.789,12345678000000000000000000000000000000
fdec	123.456.789,12345678900000000000000000000000000000
d	39
fdbl	123.456.789,12345678000000000000000000000000000000
fdec	123.456.789,12345678900000000000000000000000000000
d	40
fdbl	123.456.789,12345678000000000000000000000000000000
fdec	123.456.789,12345678900000000000000000000000000000
d	41
fdbl	123.456.789,12345678000000000000000000000000000000
fdec	123.456.789,12345678900000000000000000000000000000
d	42
fdbl	123.456.789,12345678000000000000000000000000000000
fdec	123.456.789,12345678900000000000000000000000000000
d	43
fdbl	123.456.789,12345678000000000000000000000000000000
fdec	123.456.789,12345678900000000000000000000000000000
d	44
fdbl	123.456.789,12345678000000000000000000000000000000
fdec	123.456.789,12345678900000000000000000000000000000
d	45
fdbl	123.456.789,12345678000000000000000000000000000000
fdec	123.456.789,12345678900000000000000000000000000000
d	46
fdbl	123.456.789,12345678000000000000000000000000000000
fdec	123.456.789,12345678900000000000000000000000000000
d	47
fdbl	123.456.789,12345678000000000000000000000000000000
fdec	123.456.789,12345678900000000000000000000000000000
d	48
fdbl	123.456.789,12345678000000000000000000000000000000
fdec	123.456.789,12345678900000000000000000000000000000
d	49
fdbl	123.456.789,12345678000000000000000000000000000000
fdec	123.456.789,12345678900000000000000000000000000000
d	50
fdbl	123.456.789,12345678000000000000000000000000000000
fdec	123.456.789,12345678900000000000000000000000000000
#
# MDEV-32645 CAST(AS UNSIGNED) fails with --view-protocol
#
SELECT
CAST(-1e0 AS UNSIGNED),
CAST(--2e0 AS UNSIGNED),
CAST(---3e0 AS UNSIGNED),
CAST(----4e0 AS UNSIGNED);
CAST(-1e0 AS UNSIGNED)	CAST(--2e0 AS UNSIGNED)	CAST(---3e0 AS UNSIGNED)	CAST(----4e0 AS UNSIGNED)
0	2	0	4
Warnings:
Note	1916	Got overflow when converting '-1' to UNSIGNED BIGINT. Value truncated
Note	1916	Got overflow when converting '-3' to UNSIGNED BIGINT. Value truncated
EXPLAIN EXTENDED SELECT
CAST(-1e0 AS UNSIGNED),
CAST(--2e0 AS UNSIGNED),
CAST(---3e0 AS UNSIGNED),
CAST(----4e0 AS UNSIGNED);
id	select_type	table	type	possible_keys	key	key_len	ref	rows	filtered	Extra
1	SIMPLE	NULL	NULL	NULL	NULL	NULL	NULL	NULL	NULL	No tables used
Warnings:
Note	1003	select cast(-1e0 as unsigned) AS `CAST(-1e0 AS UNSIGNED)`,cast(2e0 as unsigned) AS `CAST(--2e0 AS UNSIGNED)`,cast(-3e0 as unsigned) AS `CAST(---3e0 AS UNSIGNED)`,cast(4e0 as unsigned) AS `CAST(----4e0 AS UNSIGNED)`
CREATE VIEW v1 AS SELECT
CAST(-1e0 AS UNSIGNED),
CAST(--2e0 AS UNSIGNED),
CAST(---3e0 AS UNSIGNED),
CAST(----4e0 AS UNSIGNED);
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(-1e0 as unsigned) AS `CAST(-1e0 AS UNSIGNED)`,cast(2e0 as unsigned) AS `CAST(--2e0 AS UNSIGNED)`,cast(-3e0 as unsigned) AS `CAST(---3e0 AS UNSIGNED)`,cast(4e0 as unsigned) AS `CAST(----4e0 AS UNSIGNED)`	latin1	latin1_swedish_ci
SELECT * FROM v1;
CAST(-1e0 AS UNSIGNED)	CAST(--2e0 AS UNSIGNED)	CAST(---3e0 AS UNSIGNED)	CAST(----4e0 AS UNSIGNED)
0	2	0	4
Warnings:
Note	1916	Got overflow when converting '-1' to UNSIGNED BIGINT. Value truncated
Note	1916	Got overflow when converting '-3' to UNSIGNED BIGINT. Value truncated
DROP VIEW v1;
#
# End of 10.4 tests
#
#
# Start of 10.5 tests
#
#
# MDEV-20548 Unexpected error on CREATE..SELECT HEX(num)
#
SET sql_mode=STRICT_ALL_TABLES;
CREATE TABLE t1 AS SELECT HEX(-2e0) AS h;
SELECT * FROM t1;
h
FFFFFFFFFFFFFFFE
SHOW COLUMNS IN t1;
Field	Type	Null	Key	Default	Extra
h	varchar(16)	YES		NULL	
DROP TABLE t1;
CREATE TABLE t1 AS SELECT HEX(-1e0) AS h;
SELECT * FROM t1;
h
FFFFFFFFFFFFFFFF
SHOW COLUMNS IN t1;
Field	Type	Null	Key	Default	Extra
h	varchar(16)	YES		NULL	
DROP TABLE t1;
CREATE TABLE t1 AS SELECT HEX(1e0) AS h;
SELECT * FROM t1;
h
1
SHOW COLUMNS IN t1;
Field	Type	Null	Key	Default	Extra
h	varchar(16)	YES		NULL	
DROP TABLE t1;
CREATE TABLE t1 AS SELECT HEX(2e0) AS h;
SELECT * FROM t1;
h
2
SHOW COLUMNS IN t1;
Field	Type	Null	Key	Default	Extra
h	varchar(16)	YES		NULL	
DROP TABLE t1;
CREATE TABLE t1 (a FLOAT);
INSERT INTO t1 VALUES (-1e38),(-255),(-2),(-1),(+1),(+2),(255),(1e38);
CREATE TABLE t2 AS SELECT a, HEX(a) AS h FROM t1;
SELECT * FROM t2 ORDER BY a;
a	h
-1e38	FFFFFFFFFFFFFFFF
-255	FFFFFFFFFFFFFF01
-2	FFFFFFFFFFFFFFFE
-1	FFFFFFFFFFFFFFFF
1	1
2	2
255	FF
1e38	FFFFFFFFFFFFFFFF
SHOW COLUMNS IN t2;
Field	Type	Null	Key	Default	Extra
a	float	YES		NULL	
h	varchar(16)	YES		NULL	
DROP TABLE t1, t2;
CREATE TABLE t1 (a DOUBLE);
INSERT INTO t1 VALUES (-1e308),(-255),(-2),(-1),(+1),(+2),(255),(1e308);
CREATE TABLE t2 AS SELECT a, HEX(a) AS h FROM t1;
SELECT * FROM t2 ORDER BY a;
a	h
-1e308	FFFFFFFFFFFFFFFF
-255	FFFFFFFFFFFFFF01
-2	FFFFFFFFFFFFFFFE
-1	FFFFFFFFFFFFFFFF
1	1
2	2
255	FF
1e308	FFFFFFFFFFFFFFFF
SHOW COLUMNS IN t2;
Field	Type	Null	Key	Default	Extra
a	double	YES		NULL	
h	varchar(16)	YES		NULL	
DROP TABLE t1, t2;
SET sql_mode=DEFAULT;
#
# MDEV-25174 DOUBLE columns do not accept large hex hybrids
#
CREATE TABLE t1 (a DOUBLE);
INSERT INTO t1 VALUES (0x7FFFFFFFFFFFFFFF);
INSERT INTO t1 VALUES (0x8000000000000000);
INSERT INTO t1 VALUES (0xFFFFFFFFFFFFFFFF);
SELECT * FROM t1 ORDER BY a;
a
9.223372036854776e18
9.223372036854776e18
1.8446744073709552e19
DROP TABLE t1;
#
# End of 10.5 tests
#
#
# MDEV-32203 Raise notes when an index cannot be used on data type mismatch
#
SET note_verbosity=unusable_keys;
CREATE TABLE t1 (indexed_col FLOAT, KEY(indexed_col));
FOR i IN 1..31
DO
INSERT INTO t1 VALUES (MAKEDATE(2023, i));
END FOR;
$$
SELECT * FROM t1 WHERE indexed_col=20230101;
indexed_col
SELECT * FROM t1 WHERE indexed_col=20230101102030;
indexed_col
SELECT * FROM t1 WHERE indexed_col=20230101102030.1;
indexed_col
SELECT * FROM t1 WHERE indexed_col=20230101102030.1e0;
indexed_col
SELECT * FROM t1 WHERE indexed_col='10:20:30';
indexed_col
SELECT * FROM t1 WHERE indexed_col='2001-01-01';
indexed_col
SELECT * FROM t1 WHERE indexed_col='2001-01-01 10:20:30';
indexed_col
SELECT * FROM t1 WHERE indexed_col=DATE'2001-01-01';
indexed_col
Warnings:
Note	1105	Cannot use key `indexed_col` part[0] for lookup: `test`.`t1`.`indexed_col` of type `float` = "DATE'2001-01-01'" of type `date`
Warning	1292	Incorrect datetime value: '20230132' for column `test`.`t1`.`indexed_col` at row 31
SELECT * FROM t1 WHERE indexed_col=TIME'10:20:30';
indexed_col
Warnings:
Note	1105	Cannot use key `indexed_col` part[0] for lookup: `test`.`t1`.`indexed_col` of type `float` = "TIME'10:20:30'" of type `time`
Warning	1292	Incorrect time value: '20230132' for column `test`.`t1`.`indexed_col` at row 31
SELECT * FROM t1 WHERE indexed_col=TIMESTAMP'2001-01-01 10:20:30';
indexed_col
Warnings:
Note	1105	Cannot use key `indexed_col` part[0] for lookup: `test`.`t1`.`indexed_col` of type `float` = "TIMESTAMP'2001-01-01 10:20:30'" of type `datetime`
Warning	1292	Incorrect datetime value: '20230132' for column `test`.`t1`.`indexed_col` at row 31
SELECT * FROM t1 WHERE indexed_col=0x00;
indexed_col
SELECT * FROM t1 WHERE indexed_col=_utf8mb3'0' COLLATE utf8mb3_bin;
indexed_col
CREATE TABLE t2 (not_indexed_col INT);
INSERT INTO t2 VALUES (20230101),(20230102);
SELECT * FROM t1, t2 WHERE indexed_col=not_indexed_col;
indexed_col	not_indexed_col
20230100	20230102
DROP TABLE t2;
CREATE TABLE t2 (not_indexed_col INT UNSIGNED);
INSERT INTO t2 VALUES (20230101),(20230102);
SELECT * FROM t1, t2 WHERE indexed_col=not_indexed_col;
indexed_col	not_indexed_col
20230100	20230102
DROP TABLE t2;
CREATE TABLE t2 (not_indexed_col BIGINT);
INSERT INTO t2 VALUES (20230101102030),(20230101102031);
SELECT * FROM t1, t2 WHERE indexed_col=not_indexed_col;
indexed_col	not_indexed_col
DROP TABLE t2;
CREATE TABLE t2 (not_indexed_col BIGINT UNSIGNED);
INSERT INTO t2 VALUES (20230101102030),(20230101102031);
SELECT * FROM t1, t2 WHERE indexed_col=not_indexed_col;
indexed_col	not_indexed_col
DROP TABLE t2;
CREATE TABLE t2 (not_indexed_col DECIMAL(30,6));
INSERT INTO t2 VALUES (20230101102030),(20230101102031);
SELECT * FROM t1, t2 WHERE indexed_col=not_indexed_col;
indexed_col	not_indexed_col
DROP TABLE t2;
CREATE TABLE t2 (not_indexed_col FLOAT);
INSERT INTO t2 VALUES (20230101102030),(20230101102031);
SELECT * FROM t1, t2 WHERE indexed_col=not_indexed_col;
indexed_col	not_indexed_col
DROP TABLE t2;
CREATE TABLE t2 (not_indexed_col DOUBLE);
INSERT INTO t2 VALUES (20230101102030),(20230101102031);
SELECT * FROM t1, t2 WHERE indexed_col=not_indexed_col;
indexed_col	not_indexed_col
DROP TABLE t2;
CREATE TABLE t2 (not_indexed_col DATE);
INSERT INTO t2 VALUES ('2023-01-01'),('2023-01-02');
SELECT * FROM t1, t2 WHERE indexed_col=not_indexed_col;
indexed_col	not_indexed_col
20230100	2023-01-02
Warnings:
Note	1105	Cannot use key `indexed_col` part[0] for lookup: `test`.`t1`.`indexed_col` of type `float` = "`t2`.`not_indexed_col`" of type `date`
Warning	1292	Incorrect datetime value: '20230132' for column `test`.`t1`.`indexed_col` at row 31
Warning	1292	Incorrect datetime value: '20230132' for column `test`.`t1`.`indexed_col` at row 31
DROP TABLE t2;
CREATE TABLE t2 (not_indexed_col DATETIME);
INSERT INTO t2 VALUES ('2023-01-01 00:00:00'),('2023-01-01 00:00:01');
SELECT * FROM t1, t2 WHERE indexed_col=not_indexed_col;
indexed_col	not_indexed_col
Warnings:
Note	1105	Cannot use key `indexed_col` part[0] for lookup: `test`.`t1`.`indexed_col` of type `float` = "`t2`.`not_indexed_col`" of type `datetime`
Warning	1292	Incorrect datetime value: '20230132' for column `test`.`t1`.`indexed_col` at row 31
Warning	1292	Incorrect datetime value: '20230132' for column `test`.`t1`.`indexed_col` at row 31
DROP TABLE t2;
CREATE TABLE t2 (not_indexed_col TIMESTAMP);
INSERT INTO t2 VALUES ('2023-01-01 00:00:00'),('2023-01-01 00:00:01');
SELECT * FROM t1, t2 WHERE indexed_col=not_indexed_col;
indexed_col	not_indexed_col
Warnings:
Note	1105	Cannot use key `indexed_col` part[0] for lookup: `test`.`t1`.`indexed_col` of type `float` = "`t2`.`not_indexed_col`" of type `timestamp`
Warning	1292	Incorrect datetime value: '20230132' for column `test`.`t1`.`indexed_col` at row 31
Warning	1292	Incorrect datetime value: '20230132' for column `test`.`t1`.`indexed_col` at row 31
DROP TABLE t2;
CREATE TABLE t2 (not_indexed_col VARBINARY(32));
INSERT INTO t2 VALUES (0x30),(0x31);
SELECT * FROM t1, t2 WHERE indexed_col=not_indexed_col;
indexed_col	not_indexed_col
DROP TABLE t2;
CREATE TABLE t2 (not_indexed_col VARCHAR(32)) CHARACTER SET latin1;
INSERT INTO t2 VALUES ('2001-01-01'),('2001-01-02');
SELECT * FROM t1, t2 WHERE indexed_col=not_indexed_col;
indexed_col	not_indexed_col
Warnings:
Warning	1292	Truncated incorrect DOUBLE value: '2001-01-01'
Warning	1292	Truncated incorrect DOUBLE value: '2001-01-02'
DROP TABLE t2;
CREATE TABLE t2 (not_indexed_col VARCHAR(32) CHARACTER SET utf8mb3);
INSERT INTO t2 VALUES ('2001-01-01'),('2001-01-02');
SELECT * FROM t1, t2 WHERE indexed_col=not_indexed_col;
indexed_col	not_indexed_col
Warnings:
Warning	1292	Truncated incorrect DOUBLE value: '2001-01-01'
Warning	1292	Truncated incorrect DOUBLE value: '2001-01-02'
DROP TABLE t2;
DROP TABLE t1;
SET note_verbosity=DEFAULT;
SET note_verbosity=unusable_keys;
CREATE TABLE t1 (indexed_col DOUBLE, KEY(indexed_col));
FOR i IN 1..31
DO
INSERT INTO t1 VALUES (MAKEDATE(2023, i));
END FOR;
$$
SELECT * FROM t1 WHERE indexed_col=20230101;
indexed_col
20230101
SELECT * FROM t1 WHERE indexed_col=20230101102030;
indexed_col
SELECT * FROM t1 WHERE indexed_col=20230101102030.1;
indexed_col
SELECT * FROM t1 WHERE indexed_col=20230101102030.1e0;
indexed_col
SELECT * FROM t1 WHERE indexed_col='10:20:30';
indexed_col
SELECT * FROM t1 WHERE indexed_col='2001-01-01';
indexed_col
SELECT * FROM t1 WHERE indexed_col='2001-01-01 10:20:30';
indexed_col
SELECT * FROM t1 WHERE indexed_col=DATE'2001-01-01';
indexed_col
Warnings:
Note	1105	Cannot use key `indexed_col` part[0] for lookup: `test`.`t1`.`indexed_col` of type `double` = "DATE'2001-01-01'" of type `date`
SELECT * FROM t1 WHERE indexed_col=TIME'10:20:30';
indexed_col
Warnings:
Note	1105	Cannot use key `indexed_col` part[0] for lookup: `test`.`t1`.`indexed_col` of type `double` = "TIME'10:20:30'" of type `time`
SELECT * FROM t1 WHERE indexed_col=TIMESTAMP'2001-01-01 10:20:30';
indexed_col
Warnings:
Note	1105	Cannot use key `indexed_col` part[0] for lookup: `test`.`t1`.`indexed_col` of type `double` = "TIMESTAMP'2001-01-01 10:20:30'" of type `datetime`
SELECT * FROM t1 WHERE indexed_col=0x00;
indexed_col
SELECT * FROM t1 WHERE indexed_col=_utf8mb3'0' COLLATE utf8mb3_bin;
indexed_col
CREATE TABLE t2 (not_indexed_col INT);
INSERT INTO t2 VALUES (20230101),(20230102);
SELECT * FROM t1, t2 WHERE indexed_col=not_indexed_col;
indexed_col	not_indexed_col
20230101	20230101
20230102	20230102
DROP TABLE t2;
CREATE TABLE t2 (not_indexed_col INT UNSIGNED);
INSERT INTO t2 VALUES (20230101),(20230102);
SELECT * FROM t1, t2 WHERE indexed_col=not_indexed_col;
indexed_col	not_indexed_col
20230101	20230101
20230102	20230102
DROP TABLE t2;
CREATE TABLE t2 (not_indexed_col BIGINT);
INSERT INTO t2 VALUES (20230101102030),(20230101102031);
SELECT * FROM t1, t2 WHERE indexed_col=not_indexed_col;
indexed_col	not_indexed_col
DROP TABLE t2;
CREATE TABLE t2 (not_indexed_col BIGINT UNSIGNED);
INSERT INTO t2 VALUES (20230101102030),(20230101102031);
SELECT * FROM t1, t2 WHERE indexed_col=not_indexed_col;
indexed_col	not_indexed_col
DROP TABLE t2;
CREATE TABLE t2 (not_indexed_col DECIMAL(30,6));
INSERT INTO t2 VALUES (20230101102030),(20230101102031);
SELECT * FROM t1, t2 WHERE indexed_col=not_indexed_col;
indexed_col	not_indexed_col
DROP TABLE t2;
CREATE TABLE t2 (not_indexed_col FLOAT);
INSERT INTO t2 VALUES (20230101102030),(20230101102031);
SELECT * FROM t1, t2 WHERE indexed_col=not_indexed_col;
indexed_col	not_indexed_col
DROP TABLE t2;
CREATE TABLE t2 (not_indexed_col DOUBLE);
INSERT INTO t2 VALUES (20230101102030),(20230101102031);
SELECT * FROM t1, t2 WHERE indexed_col=not_indexed_col;
indexed_col	not_indexed_col
DROP TABLE t2;
CREATE TABLE t2 (not_indexed_col DATE);
INSERT INTO t2 VALUES ('2023-01-01'),('2023-01-02');
SELECT * FROM t1, t2 WHERE indexed_col=not_indexed_col;
indexed_col	not_indexed_col
20230101	2023-01-01
20230102	2023-01-02
Warnings:
Note	1105	Cannot use key `indexed_col` part[0] for lookup: `test`.`t1`.`indexed_col` of type `double` = "`t2`.`not_indexed_col`" of type `date`
DROP TABLE t2;
CREATE TABLE t2 (not_indexed_col DATETIME);
INSERT INTO t2 VALUES ('2023-01-01 00:00:00'),('2023-01-01 00:00:01');
SELECT * FROM t1, t2 WHERE indexed_col=not_indexed_col;
indexed_col	not_indexed_col
20230101	2023-01-01 00:00:00
Warnings:
Note	1105	Cannot use key `indexed_col` part[0] for lookup: `test`.`t1`.`indexed_col` of type `double` = "`t2`.`not_indexed_col`" of type `datetime`
DROP TABLE t2;
CREATE TABLE t2 (not_indexed_col TIMESTAMP);
INSERT INTO t2 VALUES ('2023-01-01 00:00:00'),('2023-01-01 00:00:01');
SELECT * FROM t1, t2 WHERE indexed_col=not_indexed_col;
indexed_col	not_indexed_col
20230101	2023-01-01 00:00:00
Warnings:
Note	1105	Cannot use key `indexed_col` part[0] for lookup: `test`.`t1`.`indexed_col` of type `double` = "`t2`.`not_indexed_col`" of type `timestamp`
DROP TABLE t2;
CREATE TABLE t2 (not_indexed_col VARBINARY(32));
INSERT INTO t2 VALUES (0x30),(0x31);
SELECT * FROM t1, t2 WHERE indexed_col=not_indexed_col;
indexed_col	not_indexed_col
DROP TABLE t2;
CREATE TABLE t2 (not_indexed_col VARCHAR(32)) CHARACTER SET latin1;
INSERT INTO t2 VALUES ('2001-01-01'),('2001-01-02');
SELECT * FROM t1, t2 WHERE indexed_col=not_indexed_col;
indexed_col	not_indexed_col
Warnings:
Warning	1292	Truncated incorrect DOUBLE value: '2001-01-01'
Warning	1292	Truncated incorrect DOUBLE value: '2001-01-02'
DROP TABLE t2;
CREATE TABLE t2 (not_indexed_col VARCHAR(32) CHARACTER SET utf8mb3);
INSERT INTO t2 VALUES ('2001-01-01'),('2001-01-02');
SELECT * FROM t1, t2 WHERE indexed_col=not_indexed_col;
indexed_col	not_indexed_col
Warnings:
Warning	1292	Truncated incorrect DOUBLE value: '2001-01-01'
Warning	1292	Truncated incorrect DOUBLE value: '2001-01-02'
DROP TABLE t2;
DROP TABLE t1;
SET note_verbosity=DEFAULT;
#
# MDEV-34123 CONCAT Function Returns Unexpected Empty Set in Query
#
CREATE TABLE t0 (c DOUBLE);
INSERT INTO t0 VALUES (0.0),(0.4),(0.6);
#
# WHERE <search condition>
#
CREATE TABLE t1 AS SELECT * FROM t0;
SELECT * FROM t1 WHERE c;
c
0.4
0.6
SELECT * FROM t1 WHERE c IS FALSE;
c
0
SELECT * FROM t1 WHERE c IS TRUE;
c
0.4
0.6
SELECT * FROM t1 WHERE COALESCE(c);
c
0.4
0.6
DROP TABLE t1;
#
# HAVING <search condition>
#
CREATE TABLE t1 AS SELECT * FROM t0;
SELECT COALESCE(c,c) AS c2 FROM t1 GROUP BY c2 HAVING c2;
c2
0.4
0.6
SELECT COALESCE(c,c) AS c2 FROM t1 GROUP BY c2 HAVING c2 IS FALSE;
c2
0
SELECT COALESCE(c,c) AS c2 FROM t1 GROUP BY c2 HAVING c2 IS TRUE;
c2
0.4
0.6
SELECT COALESCE(c,c) AS c2 FROM t1 GROUP BY c2 HAVING COALESCE(c2);
c2
0.4
0.6
DROP TABLE t1;
#
# <join condition> :=  ON <search condition>
#
CREATE TABLE t1 AS SELECT * FROM t0;
SELECT t1.c FROM t1 JOIN t1 AS t2 ON (t1.c);
c
0.4
0.6
0.4
0.6
0.4
0.6
SELECT t1.c FROM t1 JOIN t1 AS t2 ON (t1.c IS FALSE);
c
0
0
0
SELECT t1.c FROM t1 JOIN t1 AS t2 ON (t1.c IS TRUE);
c
0.4
0.6
0.4
0.6
0.4
0.6
SELECT t1.c FROM t1 JOIN t1 AS t2 ON (COALESCE(t1.c));
c
0.4
0.6
0.4
0.6
0.4
0.6
DROP TABLE t1;
#
# <delete statement: searched>
#   DELETE FROM <target table> [ WHERE <search condition> ]
#
CREATE TABLE t1 AS SELECT * FROM t0;
DELETE FROM t1 WHERE c;
SELECT * FROM t1;
c
0
DROP TABLE t1;
CREATE TABLE t1 AS SELECT * FROM t0;
DELETE FROM t1 WHERE c IS FALSE;
SELECT * FROM t1;
c
0.4
0.6
DROP TABLE t1;
CREATE TABLE t1 AS SELECT * FROM t0;
DELETE FROM t1 WHERE c IS TRUE;
SELECT * FROM t1;
c
0
DROP TABLE t1;
CREATE TABLE t1 AS SELECT * FROM t0;
DELETE FROM t1 WHERE COALESCE(c);
SELECT * FROM t1;
c
0
DROP TABLE t1;
#
# <update statement: searched>
#   UPDATE <target table> SET <set clause list> [ WHERE <search condition> ]
CREATE TABLE t1 AS SELECT * FROM t0;
UPDATE t1 SET c=c+11 WHERE c;
SELECT * FROM t1;
c
0
11.4
11.6
DROP TABLE t1;
CREATE TABLE t1 AS SELECT * FROM t0;
UPDATE t1 SET c=c+11 WHERE c IS FALSE;
SELECT * FROM t1;
c
11
0.4
0.6
DROP TABLE t1;
CREATE TABLE t1 AS SELECT * FROM t0;
UPDATE t1 SET c=c+11 WHERE c IS TRUE;
SELECT * FROM t1;
c
0
11.4
11.6
DROP TABLE t1;
CREATE TABLE t1 AS SELECT * FROM t0;
UPDATE t1 SET c=c+11 WHERE COALESCE(c);
SELECT * FROM t1;
c
0
11.4
11.6
DROP TABLE t1;
#
# <check constraint definition>
#   CHECK <left paren> <search condition> <right paren>
CREATE TABLE t1 LIKE t0;
ALTER TABLE t1 ADD CONSTRAINT check0 CHECK(c);
INSERT INTO t1 SELECT * FROM t0 WHERE NOT c;
ERROR 23000: CONSTRAINT `check0` failed for `test`.`t1`
INSERT INTO t1 SELECT * FROM t0 WHERE c;
SELECT * FROM t1;
c
0.4
0.6
DROP TABLE t1;
CREATE TABLE t1 LIKE t0;
ALTER TABLE t1 ADD CONSTRAINT check0 CHECK(c IS FALSE);
INSERT INTO t1 SELECT * FROM t0 WHERE c IS FALSE;
INSERT INTO t1 SELECT * FROM t0 WHERE c IS TRUE;
ERROR 23000: CONSTRAINT `check0` failed for `test`.`t1`
SELECT * FROM t1;
c
0
DROP TABLE t1;
CREATE TABLE t1 LIKE t0;
ALTER TABLE t1 ADD CONSTRAINT check0 CHECK(c IS TRUE);
INSERT INTO t1 SELECT * FROM t0 WHERE c IS FALSE;
ERROR 23000: CONSTRAINT `check0` failed for `test`.`t1`
INSERT INTO t1 SELECT * FROM t0 WHERE c IS TRUE;
SELECT * FROM t1;
c
0.4
0.6
DROP TABLE t1;
CREATE TABLE t1 LIKE t0;
ALTER TABLE t1 ADD CONSTRAINT check0 CHECK(COALESCE(c));
INSERT INTO t1 SELECT * FROM t0 WHERE c IS FALSE;
ERROR 23000: CONSTRAINT `check0` failed for `test`.`t1`
INSERT INTO t1 SELECT * FROM t0 WHERE c IS TRUE;
SELECT * FROM t1;
c
0.4
0.6
DROP TABLE t1;
#
# <case expression>
#   WHEN <search condition> THEN <result>
CREATE TABLE t1 AS SELECT * FROM t0;
SELECT c, CASE WHEN c THEN 'true' ELSE 'false' END AS c2 FROM t1;
c	c2
0	false
0.4	true
0.6	true
SELECT c, CASE WHEN COALESCE(c) THEN 'true' ELSE 'false' END AS c2 FROM t1;
c	c2
0	false
0.4	true
0.6	true
DROP TABLE t1;
DROP TABLE t0;
#
# End of 10.6 tests
#
#
# Start of 10.9 tests
#
#
# MDEV-27712 Reduce the size of Lex_length_and_dec_st from 16 to 8
#
CREATE TABLE t1 (a DOUBLE(1000,1000));
ERROR 42000: Too big scale specified for 'a'. Maximum is 30
CREATE TABLE t1 (a DOUBLE(1000,0));
ERROR 42000: Display width out of range for 'a' (max = 255)
CREATE TABLE t1 (a DOUBLE(0,1000));
ERROR 42000: For float(M,D), double(M,D) or decimal(M,D), M must be >= D (column 'a')
CREATE TABLE t1 (a DOUBLE(2147483647,2147483647));
ERROR 42000: Too big scale specified for 'a'. Maximum is 30
CREATE TABLE t1 (a DOUBLE(2147483647,0));
ERROR 42000: Display width out of range for 'a' (max = 255)
CREATE TABLE t1 (a DOUBLE(0,2147483647));
ERROR 42000: For float(M,D), double(M,D) or decimal(M,D), M must be >= D (column 'a')
CREATE TABLE t1 (a DOUBLE(2147483648,2147483648));
ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near '2147483648,2147483648))' at line 1
CREATE TABLE t1 (a DOUBLE(2147483648,0));
ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near '2147483648,0))' at line 1
CREATE TABLE t1 (a DOUBLE(0,2147483648));
ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near '2147483648))' at line 1
CREATE TABLE t1 (a DOUBLE(999999999999999999999999999999,999999999999999999999999999999));
ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near '999999999999999999999999999999,999999999999999999999999999999))' at line 1
CREATE TABLE t1 (a DOUBLE(999999999999999999999999999999,0));
ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near '999999999999999999999999999999,0))' at line 1
CREATE TABLE t1 (a DOUBLE(0,999999999999999999999999999999));
ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near '999999999999999999999999999999))' at line 1
#
# End of 10.9 tests
#