@@ -1000,14 +1000,14 @@ t2 CREATE TABLE `t2` (
1000
1000
`least____a_a` int(11) DEFAULT NULL,
1001
1001
`greatest_a_a` int(11) DEFAULT NULL,
1002
1002
`___________b` bit(8) DEFAULT NULL,
1003
- `case_______b` int (8) unsigned DEFAULT NULL,
1004
- `case_____b_b` int (8) unsigned DEFAULT NULL,
1005
- `coalesce___b` int (8) unsigned DEFAULT NULL,
1006
- `coalesce_b_b` int (8) unsigned DEFAULT NULL,
1007
- `if_______b_b` int (8) unsigned DEFAULT NULL,
1003
+ `case_______b` bit (8) DEFAULT NULL,
1004
+ `case_____b_b` bit (8) DEFAULT NULL,
1005
+ `coalesce___b` bit (8) DEFAULT NULL,
1006
+ `coalesce_b_b` bit (8) DEFAULT NULL,
1007
+ `if_______b_b` bit (8) DEFAULT NULL,
1008
1008
`ifnull___b_b` bit(8) DEFAULT NULL,
1009
- `least____b_b` int (8) unsigned DEFAULT NULL,
1010
- `greatest_b_b` int (8) unsigned DEFAULT NULL
1009
+ `least____b_b` bit (8) DEFAULT NULL,
1010
+ `greatest_b_b` bit (8) DEFAULT NULL
1011
1011
) ENGINE=MyISAM DEFAULT CHARSET=latin1
1012
1012
DROP TABLE t2;
1013
1013
SET STATEMENT sql_mode = 'NO_ENGINE_SUBSTITUTION' FOR
@@ -1119,18 +1119,18 @@ GREATEST(a, b) AS greatest_a_b,
1119
1119
GREATEST(b, a) AS greatest_b_a
1120
1120
FROM t1;
1121
1121
Catalog Database Table Table_alias Column Column_alias Type Length Max length Is_null Flags Decimals Charsetnr
1122
- def case_____a_b 8 10 10 Y 32928 0 63
1123
- def case_____b_a 8 10 2 Y 32928 0 63
1124
- def coalesce_a_b 8 10 10 Y 32928 0 63
1125
- def coalesce_b_a 8 10 2 Y 32928 0 63
1126
- def if_______a_b 8 10 2 Y 32928 0 63
1127
- def if_______b_a 8 10 10 Y 32928 0 63
1128
- def ifnull___a_b 8 10 10 Y 32928 0 63
1129
- def ifnull___b_a 8 10 2 Y 32928 0 63
1130
- def least____a_b 8 10 2 Y 32928 0 63
1131
- def least____b_a 8 10 2 Y 32928 0 63
1132
- def greatest_a_b 8 10 10 Y 32928 0 63
1133
- def greatest_b_a 8 10 10 Y 32928 0 63
1122
+ def case_____a_b 3 10 10 Y 32928 0 63
1123
+ def case_____b_a 3 10 2 Y 32928 0 63
1124
+ def coalesce_a_b 3 10 10 Y 32928 0 63
1125
+ def coalesce_b_a 3 10 2 Y 32928 0 63
1126
+ def if_______a_b 3 10 2 Y 32928 0 63
1127
+ def if_______b_a 3 10 10 Y 32928 0 63
1128
+ def ifnull___a_b 3 10 10 Y 32928 0 63
1129
+ def ifnull___b_a 3 10 2 Y 32928 0 63
1130
+ def least____a_b 3 10 2 Y 32928 0 63
1131
+ def least____b_a 3 10 2 Y 32928 0 63
1132
+ def greatest_a_b 3 10 10 Y 32928 0 63
1133
+ def greatest_b_a 3 10 10 Y 32928 0 63
1134
1134
case_____a_b 4294967295
1135
1135
case_____b_a 50
1136
1136
coalesce_a_b 4294967295
@@ -1177,14 +1177,14 @@ t2 CREATE TABLE `t2` (
1177
1177
`least____a_a` int(10) unsigned DEFAULT NULL,
1178
1178
`greatest_a_a` int(10) unsigned DEFAULT NULL,
1179
1179
`___________b` bit(8) DEFAULT NULL,
1180
- `case_______b` int (8) unsigned DEFAULT NULL,
1181
- `case_____b_b` int (8) unsigned DEFAULT NULL,
1182
- `coalesce___b` int (8) unsigned DEFAULT NULL,
1183
- `coalesce_b_b` int (8) unsigned DEFAULT NULL,
1184
- `if_______b_b` int (8) unsigned DEFAULT NULL,
1180
+ `case_______b` bit (8) DEFAULT NULL,
1181
+ `case_____b_b` bit (8) DEFAULT NULL,
1182
+ `coalesce___b` bit (8) DEFAULT NULL,
1183
+ `coalesce_b_b` bit (8) DEFAULT NULL,
1184
+ `if_______b_b` bit (8) DEFAULT NULL,
1185
1185
`ifnull___b_b` bit(8) DEFAULT NULL,
1186
- `least____b_b` int (8) unsigned DEFAULT NULL,
1187
- `greatest_b_b` int (8) unsigned DEFAULT NULL
1186
+ `least____b_b` bit (8) DEFAULT NULL,
1187
+ `greatest_b_b` bit (8) DEFAULT NULL
1188
1188
) ENGINE=MyISAM DEFAULT CHARSET=latin1
1189
1189
DROP TABLE t2;
1190
1190
SET STATEMENT sql_mode = 'NO_ENGINE_SUBSTITUTION' FOR
@@ -1212,8 +1212,8 @@ t2 CREATE TABLE `t2` (
1212
1212
`coalesce_b_a` int(10) unsigned DEFAULT NULL,
1213
1213
`if_______a_b` int(10) unsigned DEFAULT NULL,
1214
1214
`if_______b_a` int(10) unsigned DEFAULT NULL,
1215
- `ifnull___a_b` bigint (10) unsigned DEFAULT NULL,
1216
- `ifnull___b_a` bigint (10) unsigned DEFAULT NULL,
1215
+ `ifnull___a_b` int (10) unsigned DEFAULT NULL,
1216
+ `ifnull___b_a` int (10) unsigned DEFAULT NULL,
1217
1217
`least____a_b` int(10) unsigned DEFAULT NULL,
1218
1218
`least____b_a` int(10) unsigned DEFAULT NULL,
1219
1219
`greatest_a_b` int(10) unsigned DEFAULT NULL,
@@ -1345,23 +1345,23 @@ SHOW CREATE TABLE t2;
1345
1345
Table Create Table
1346
1346
t2 CREATE TABLE `t2` (
1347
1347
`___________a` bit(7) DEFAULT NULL,
1348
- `case_______a` int (7) unsigned DEFAULT NULL,
1349
- `case_____a_a` int (7) unsigned DEFAULT NULL,
1350
- `coalesce___a` int (7) unsigned DEFAULT NULL,
1351
- `coalesce_a_a` int (7) unsigned DEFAULT NULL,
1352
- `if_______a_a` int (7) unsigned DEFAULT NULL,
1348
+ `case_______a` bit (7) DEFAULT NULL,
1349
+ `case_____a_a` bit (7) DEFAULT NULL,
1350
+ `coalesce___a` bit (7) DEFAULT NULL,
1351
+ `coalesce_a_a` bit (7) DEFAULT NULL,
1352
+ `if_______a_a` bit (7) DEFAULT NULL,
1353
1353
`ifnull___a_a` bit(7) DEFAULT NULL,
1354
- `least____a_a` int (7) unsigned DEFAULT NULL,
1355
- `greatest_a_a` int (7) unsigned DEFAULT NULL,
1354
+ `least____a_a` bit (7) DEFAULT NULL,
1355
+ `greatest_a_a` bit (7) DEFAULT NULL,
1356
1356
`___________b` bit(8) DEFAULT NULL,
1357
- `case_______b` int (8) unsigned DEFAULT NULL,
1358
- `case_____b_b` int (8) unsigned DEFAULT NULL,
1359
- `coalesce___b` int (8) unsigned DEFAULT NULL,
1360
- `coalesce_b_b` int (8) unsigned DEFAULT NULL,
1361
- `if_______b_b` int (8) unsigned DEFAULT NULL,
1357
+ `case_______b` bit (8) DEFAULT NULL,
1358
+ `case_____b_b` bit (8) DEFAULT NULL,
1359
+ `coalesce___b` bit (8) DEFAULT NULL,
1360
+ `coalesce_b_b` bit (8) DEFAULT NULL,
1361
+ `if_______b_b` bit (8) DEFAULT NULL,
1362
1362
`ifnull___b_b` bit(8) DEFAULT NULL,
1363
- `least____b_b` int (8) unsigned DEFAULT NULL,
1364
- `greatest_b_b` int (8) unsigned DEFAULT NULL
1363
+ `least____b_b` bit (8) DEFAULT NULL,
1364
+ `greatest_b_b` bit (8) DEFAULT NULL
1365
1365
) ENGINE=MyISAM DEFAULT CHARSET=latin1
1366
1366
DROP TABLE t2;
1367
1367
SET STATEMENT sql_mode = 'NO_ENGINE_SUBSTITUTION' FOR
@@ -1383,18 +1383,18 @@ FROM t1;
1383
1383
SHOW CREATE TABLE t2;
1384
1384
Table Create Table
1385
1385
t2 CREATE TABLE `t2` (
1386
- `case_____a_b` int (8) unsigned DEFAULT NULL,
1387
- `case_____b_a` int (8) unsigned DEFAULT NULL,
1388
- `coalesce_a_b` int (8) unsigned DEFAULT NULL,
1389
- `coalesce_b_a` int (8) unsigned DEFAULT NULL,
1390
- `if_______a_b` int (8) unsigned DEFAULT NULL,
1391
- `if_______b_a` int (8) unsigned DEFAULT NULL,
1386
+ `case_____a_b` bit (8) DEFAULT NULL,
1387
+ `case_____b_a` bit (8) DEFAULT NULL,
1388
+ `coalesce_a_b` bit (8) DEFAULT NULL,
1389
+ `coalesce_b_a` bit (8) DEFAULT NULL,
1390
+ `if_______a_b` bit (8) DEFAULT NULL,
1391
+ `if_______b_a` bit (8) DEFAULT NULL,
1392
1392
`ifnull___a_b` bit(8) DEFAULT NULL,
1393
1393
`ifnull___b_a` bit(8) DEFAULT NULL,
1394
- `least____a_b` int (8) unsigned DEFAULT NULL,
1395
- `least____b_a` int (8) unsigned DEFAULT NULL,
1396
- `greatest_a_b` int (8) unsigned DEFAULT NULL,
1397
- `greatest_b_a` int (8) unsigned DEFAULT NULL
1394
+ `least____a_b` bit (8) DEFAULT NULL,
1395
+ `least____b_a` bit (8) DEFAULT NULL,
1396
+ `greatest_a_b` bit (8) DEFAULT NULL,
1397
+ `greatest_b_a` bit (8) DEFAULT NULL
1398
1398
) ENGINE=MyISAM DEFAULT CHARSET=latin1
1399
1399
DROP TABLE t2;
1400
1400
DROP TABLE t1;
@@ -1429,8 +1429,8 @@ def coalesce___a 4 12 1 Y 32896 31 63
1429
1429
def coalesce_a_a 4 12 1 Y 32896 31 63
1430
1430
def if_______a_a 4 12 1 Y 32896 31 63
1431
1431
def ifnull___a_a 4 12 1 Y 32896 31 63
1432
- def least____a_a 5 23 1 Y 32896 31 63
1433
- def greatest_a_a 5 23 1 Y 32896 31 63
1432
+ def least____a_a 4 23 1 Y 32896 31 63
1433
+ def greatest_a_a 4 23 1 Y 32896 31 63
1434
1434
def test t1 t1 b ___________b 2 6 6 Y 32768 0 63
1435
1435
def case_______b 2 6 6 Y 32896 0 63
1436
1436
def case_____b_b 2 6 6 Y 32896 0 63
@@ -1522,23 +1522,23 @@ SHOW CREATE TABLE t2;
1522
1522
Table Create Table
1523
1523
t2 CREATE TABLE `t2` (
1524
1524
`___________a` float DEFAULT NULL,
1525
- `case_______a` double DEFAULT NULL,
1526
- `case_____a_a` double DEFAULT NULL,
1527
- `coalesce___a` double DEFAULT NULL,
1528
- `coalesce_a_a` double DEFAULT NULL,
1529
- `if_______a_a` double DEFAULT NULL,
1525
+ `case_______a` float DEFAULT NULL,
1526
+ `case_____a_a` float DEFAULT NULL,
1527
+ `coalesce___a` float DEFAULT NULL,
1528
+ `coalesce_a_a` float DEFAULT NULL,
1529
+ `if_______a_a` float DEFAULT NULL,
1530
1530
`ifnull___a_a` float DEFAULT NULL,
1531
- `least____a_a` double DEFAULT NULL,
1532
- `greatest_a_a` double DEFAULT NULL,
1531
+ `least____a_a` float DEFAULT NULL,
1532
+ `greatest_a_a` float DEFAULT NULL,
1533
1533
`___________b` smallint(6) DEFAULT NULL,
1534
- `case_______b` int (6) DEFAULT NULL,
1535
- `case_____b_b` int (6) DEFAULT NULL,
1536
- `coalesce___b` int (6) DEFAULT NULL,
1537
- `coalesce_b_b` int (6) DEFAULT NULL,
1538
- `if_______b_b` int (6) DEFAULT NULL,
1534
+ `case_______b` smallint (6) DEFAULT NULL,
1535
+ `case_____b_b` smallint (6) DEFAULT NULL,
1536
+ `coalesce___b` smallint (6) DEFAULT NULL,
1537
+ `coalesce_b_b` smallint (6) DEFAULT NULL,
1538
+ `if_______b_b` smallint (6) DEFAULT NULL,
1539
1539
`ifnull___b_b` smallint(6) DEFAULT NULL,
1540
- `least____b_b` int (6) DEFAULT NULL,
1541
- `greatest_b_b` int (6) DEFAULT NULL
1540
+ `least____b_b` smallint (6) DEFAULT NULL,
1541
+ `greatest_b_b` smallint (6) DEFAULT NULL
1542
1542
) ENGINE=MyISAM DEFAULT CHARSET=latin1
1543
1543
DROP TABLE t2;
1544
1544
SET STATEMENT sql_mode = 'NO_ENGINE_SUBSTITUTION' FOR
@@ -1560,12 +1560,12 @@ FROM t1;
1560
1560
SHOW CREATE TABLE t2;
1561
1561
Table Create Table
1562
1562
t2 CREATE TABLE `t2` (
1563
- `case_____a_b` double DEFAULT NULL,
1564
- `case_____b_a` double DEFAULT NULL,
1565
- `coalesce_a_b` double DEFAULT NULL,
1566
- `coalesce_b_a` double DEFAULT NULL,
1567
- `if_______a_b` double DEFAULT NULL,
1568
- `if_______b_a` double DEFAULT NULL,
1563
+ `case_____a_b` float DEFAULT NULL,
1564
+ `case_____b_a` float DEFAULT NULL,
1565
+ `coalesce_a_b` float DEFAULT NULL,
1566
+ `coalesce_b_a` float DEFAULT NULL,
1567
+ `if_______a_b` float DEFAULT NULL,
1568
+ `if_______b_a` float DEFAULT NULL,
1569
1569
`ifnull___a_b` float DEFAULT NULL,
1570
1570
`ifnull___b_a` float DEFAULT NULL,
1571
1571
`least____a_b` double DEFAULT NULL,
@@ -1885,14 +1885,14 @@ t2 CREATE TABLE `t2` (
1885
1885
`least____a_a` int(11) DEFAULT NULL,
1886
1886
`greatest_a_a` int(11) DEFAULT NULL,
1887
1887
`___________b` year(4) DEFAULT NULL,
1888
- `case_______b` int (4) unsigned DEFAULT NULL,
1889
- `case_____b_b` int (4) unsigned DEFAULT NULL,
1890
- `coalesce___b` int (4) unsigned DEFAULT NULL,
1891
- `coalesce_b_b` int (4) unsigned DEFAULT NULL,
1892
- `if_______b_b` int (4) unsigned DEFAULT NULL,
1888
+ `case_______b` year (4) DEFAULT NULL,
1889
+ `case_____b_b` year (4) DEFAULT NULL,
1890
+ `coalesce___b` year (4) DEFAULT NULL,
1891
+ `coalesce_b_b` year (4) DEFAULT NULL,
1892
+ `if_______b_b` year (4) DEFAULT NULL,
1893
1893
`ifnull___b_b` year(4) DEFAULT NULL,
1894
- `least____b_b` int (4) unsigned DEFAULT NULL,
1895
- `greatest_b_b` int (4) unsigned DEFAULT NULL
1894
+ `least____b_b` year (4) DEFAULT NULL,
1895
+ `greatest_b_b` year (4) DEFAULT NULL
1896
1896
) ENGINE=MyISAM DEFAULT CHARSET=latin1
1897
1897
DROP TABLE t2;
1898
1898
SET STATEMENT sql_mode = 'NO_ENGINE_SUBSTITUTION' FOR
@@ -2062,14 +2062,14 @@ t2 CREATE TABLE `t2` (
2062
2062
`least____a_a` int(10) unsigned DEFAULT NULL,
2063
2063
`greatest_a_a` int(10) unsigned DEFAULT NULL,
2064
2064
`___________b` year(4) DEFAULT NULL,
2065
- `case_______b` int (4) unsigned DEFAULT NULL,
2066
- `case_____b_b` int (4) unsigned DEFAULT NULL,
2067
- `coalesce___b` int (4) unsigned DEFAULT NULL,
2068
- `coalesce_b_b` int (4) unsigned DEFAULT NULL,
2069
- `if_______b_b` int (4) unsigned DEFAULT NULL,
2065
+ `case_______b` year (4) DEFAULT NULL,
2066
+ `case_____b_b` year (4) DEFAULT NULL,
2067
+ `coalesce___b` year (4) DEFAULT NULL,
2068
+ `coalesce_b_b` year (4) DEFAULT NULL,
2069
+ `if_______b_b` year (4) DEFAULT NULL,
2070
2070
`ifnull___b_b` year(4) DEFAULT NULL,
2071
- `least____b_b` int (4) unsigned DEFAULT NULL,
2072
- `greatest_b_b` int (4) unsigned DEFAULT NULL
2071
+ `least____b_b` year (4) DEFAULT NULL,
2072
+ `greatest_b_b` year (4) DEFAULT NULL
2073
2073
) ENGINE=MyISAM DEFAULT CHARSET=latin1
2074
2074
DROP TABLE t2;
2075
2075
SET STATEMENT sql_mode = 'NO_ENGINE_SUBSTITUTION' FOR
@@ -3512,5 +3512,40 @@ t2 CREATE TABLE `t2` (
3512
3512
DROP TABLE t2;
3513
3513
DROP TABLE t1;
3514
3514
#
3515
+ # MDEV-12617 CASE and CASE-alike hybrid functions do not preserve exact data types
3516
+ #
3517
+ CREATE TABLE t1 (a FLOAT(10,2));
3518
+ CREATE TABLE t2 AS SELECT COALESCE(a) FROM t1;
3519
+ SHOW CREATE TABLE t2;
3520
+ Table Create Table
3521
+ t2 CREATE TABLE `t2` (
3522
+ `COALESCE(a)` float(10,2) DEFAULT NULL
3523
+ ) ENGINE=MyISAM DEFAULT CHARSET=latin1
3524
+ DROP TABLE t2, t1;
3525
+ CREATE TABLE t1 (a FLOAT(10,2));
3526
+ CREATE TABLE t2 AS SELECT LEAST(a,a) FROM t1;
3527
+ SHOW CREATE TABLE t2;
3528
+ Table Create Table
3529
+ t2 CREATE TABLE `t2` (
3530
+ `LEAST(a,a)` float(19,2) DEFAULT NULL
3531
+ ) ENGINE=MyISAM DEFAULT CHARSET=latin1
3532
+ DROP TABLE t2, t1;
3533
+ CREATE TABLE t1 (a TINYINT(1));
3534
+ CREATE TABLE t2 AS SELECT COALESCE(a) FROM t1;
3535
+ SHOW CREATE TABLE t2;
3536
+ Table Create Table
3537
+ t2 CREATE TABLE `t2` (
3538
+ `COALESCE(a)` tinyint(4) DEFAULT NULL
3539
+ ) ENGINE=MyISAM DEFAULT CHARSET=latin1
3540
+ DROP TABLE t2, t1;
3541
+ CREATE TABLE t1 (a TINYINT(1));
3542
+ CREATE TABLE t2 AS SELECT LEAST(a,a) FROM t1;
3543
+ SHOW CREATE TABLE t2;
3544
+ Table Create Table
3545
+ t2 CREATE TABLE `t2` (
3546
+ `LEAST(a,a)` tinyint(4) DEFAULT NULL
3547
+ ) ENGINE=MyISAM DEFAULT CHARSET=latin1
3548
+ DROP TABLE t2, t1;
3549
+ #
3515
3550
# End of 10.3 tests
3516
3551
#
0 commit comments