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
|
--echo #
--echo # Start of 10.5 tests
--echo #
--echo #
--echo # MDEV-20305 Data loss on DOUBLE and DECIMAL conversion to INT
--echo #
DELIMITER $$;
CREATE PROCEDURE p1(type VARCHAR(64), val VARCHAR(64))
BEGIN
EXECUTE IMMEDIATE CONCAT('CREATE TABLE t1 (a ', type, ')');
SHOW CREATE TABLE t1;
EXECUTE IMMEDIATE CONCAT('INSERT INTO t1 VALUES (', val, ')');
SELECT
a,
~a,
a & 18446744073709551615,
18446744073709551615 & a,
0 | a,
a | 0,
a << 0,
a >> 0,
a ^ 1,
1 ^ a,
BIT_COUNT(a)
FROM t1;
SHOW WARNINGS;
DROP TABLE t1;
END;
$$
DELIMITER ;$$
--vertical_results
CALL p1('BIGINT UNSIGNED', 18446744073709551615);
CALL p1('DOUBLE', 18446744073709551615);
CALL p1('DECIMAL(30,0)', 18446744073709551615);
CALL p1('BIGINT', -1);
CALL p1('DOUBLE', -1);
CALL p1('DECIMAL(30,0)', -1);
CALL p1('BIGINT', -9223372036854775808);
CALL p1('DOUBLE', -9223372036854775808);
CALL p1('DECIMAL(30,0)', -9223372036854775808);
--horizontal_results
DROP PROCEDURE p1;
SELECT CAST(CAST(18446744073709551615 AS UNSIGNED) AS DECIMAL(32))<<0 AS c1;
SELECT CAST(CAST(18446744073709551615 AS UNSIGNED) AS DOUBLE)<<0 AS c1;
SELECT COALESCE(CAST(CAST(0xFFFFFFFFFFFFFFFF AS UNSIGNED) AS DECIMAL(32))) << 0 AS c1;
SELECT COALESCE(CAST(CAST(0xFFFFFFFFFFFFFFFF AS UNSIGNED) AS DOUBLE)) << 0 AS c1;
SELECT 18446744073709551615 ^ 1 AS c1;
SELECT 18446744073709551615.0 ^ 1 AS c1;
SELECT 18446744073709551615e0 ^ 1 AS c1;
SELECT LAST_VALUE(18446744073709551615) ^ 1 AS c1;
SELECT LAST_VALUE(18446744073709551615.0) ^ 1 AS c1;
SELECT LAST_VALUE(18446744073709551615e0) ^ 1 AS c1;
SELECT 18446744073709551615 & 18446744073709551615 AS c1;
SELECT 18446744073709551615 & 18446744073709551615.0 AS c1;
SELECT 18446744073709551615 & 18446744073709551615e0 AS c1;
SELECT 18446744073709551615.0 & 18446744073709551615 AS c1;
SELECT 18446744073709551615.0 & 18446744073709551615.0 AS c1;
SELECT 18446744073709551615.0 & 18446744073709551615e0 AS c1;
SELECT 18446744073709551615e0 & 18446744073709551615 AS c1;
SELECT 18446744073709551615e0 & 18446744073709551615.0 AS c1;
SELECT 18446744073709551615e0 & 18446744073709551615e0 AS c1;
SELECT 0 | 18446744073709551615 AS c1;
SELECT 0 | 18446744073709551615.0 AS c1;
SELECT 0 | 18446744073709551615e0 AS c1;
SELECT 18446744073709551615 | 0 AS c1;
SELECT 18446744073709551615.0 | 0 AS c1;
SELECT 18446744073709551615e0 | 0 AS c1;
SELECT ~18446744073709551615 AS c1;
SELECT ~18446744073709551615.0 AS c1;
SELECT ~18446744073709551615e0 AS c1;
SELECT BIT_COUNT(18446744073709551615) AS c1;
SELECT BIT_COUNT(18446744073709551615.0) AS c1;
SELECT BIT_COUNT(18446744073709551615e0) AS c1;
SELECT BIT_COUNT(-9223372036854775808) AS c1;
SELECT BIT_COUNT(-9223372036854775808.0) AS c1;
SELECT BIT_COUNT(-9223372036854775808e0) AS c1;
--echo #
--echo # End of 10.5 tests
--echo #
|