diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-05-04 18:00:34 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-05-04 18:00:34 +0000 |
commit | 3f619478f796eddbba6e39502fe941b285dd97b1 (patch) | |
tree | e2c7b5777f728320e5b5542b6213fd3591ba51e2 /mysql-test/main/func_bit.test | |
parent | Initial commit. (diff) | |
download | mariadb-3f619478f796eddbba6e39502fe941b285dd97b1.tar.xz mariadb-3f619478f796eddbba6e39502fe941b285dd97b1.zip |
Adding upstream version 1:10.11.6.upstream/1%10.11.6upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'mysql-test/main/func_bit.test')
-rw-r--r-- | mysql-test/main/func_bit.test | 97 |
1 files changed, 97 insertions, 0 deletions
diff --git a/mysql-test/main/func_bit.test b/mysql-test/main/func_bit.test new file mode 100644 index 00000000..e4f3189e --- /dev/null +++ b/mysql-test/main/func_bit.test @@ -0,0 +1,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 # |