1
0
mirror of https://github.com/mariadb-corporation/mariadb-columnstore-engine.git synced 2025-05-27 01:57:30 +03:00
Gagan Goel 86dcf92d56 MCOL-5215 Fix overflow of UNION operation involving DECIMAL datatypes.
When a UNION operation involving DECIMAL datatypes with scale and digits
before the decimal exceeds the currently supported maximum precision
of 38, we throw an error to the user:
"MCS-2060: Union operation exceeds maximum DECIMAL precision of 38".

This is until MCOL-5417 is implemented where ColumnStore will have
full parity with MariaDB server in terms of maximum supported DECIMAL
precision and scale of 65 and 38 digits respectively.
2023-02-27 06:38:31 -05:00

65 lines
5.2 KiB
Plaintext

# MCOL-641 Union Test Cases
# Once MCOL-5417 is supported, the errored out queries below should be fixed.
DROP DATABASE IF EXISTS mcol641_union_db;
CREATE DATABASE mcol641_union_db;
USE mcol641_union_db;
SET SQL_MODE='ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION';
CREATE TABLE cs1 (d1 DECIMAL(38), d2 DECIMAL(38,10), d3 DECIMAL(38,38)) ENGINE=columnstore;
CREATE TABLE cs2 (d1 DECIMAL(38) UNSIGNED, d2 DECIMAL(38,10) UNSIGNED, d3 DECIMAL(38,38) UNSIGNED) ENGINE=columnstore;
INSERT INTO cs1 VALUES (125, 1.25, 0.125);
INSERT INTO cs1 VALUES (-125, -1.25, -0.125);
INSERT INTO cs1 values (99999999999999999999999999999999999998, 9999999999999999999999999999.9999999998, 0.99999999999999999999999999999999999998);
INSERT INTO cs1 values (99999999999999999999999999999999999999, 9999999999999999999999999999.9999999999, 0.99999999999999999999999999999999999999);
INSERT INTO cs1 values (-99999999999999999999999999999999999998, -9999999999999999999999999999.9999999998, -0.99999999999999999999999999999999999998);
INSERT INTO cs1 values (-99999999999999999999999999999999999999, -9999999999999999999999999999.9999999999, -0.99999999999999999999999999999999999999);
SELECT d1, d1, d2 FROM cs1 UNION SELECT d2, d3, d3 FROM cs1;
ERROR 42000: The storage engine for the table doesn't support MCS-2060: Union operation exceeds maximum DECIMAL precision of 38.
SELECT d2, d3, d3 FROM cs1 UNION SELECT d1, d1, d2 FROM cs1;
ERROR 42000: The storage engine for the table doesn't support MCS-2060: Union operation exceeds maximum DECIMAL precision of 38.
SELECT d1, d2, d3 FROM cs1 UNION SELECT d1, d2, d3 FROM cs1;
d1 d2 d3
-125 -1.2500000000 -0.12500000000000000000000000000000000000
-99999999999999999999999999999999999998 -9999999999999999999999999999.9999999998 -0.99999999999999999999999999999999999998
-99999999999999999999999999999999999999 -9999999999999999999999999999.9999999999 -0.99999999999999999999999999999999999999
125 1.2500000000 0.12500000000000000000000000000000000000
99999999999999999999999999999999999998 9999999999999999999999999999.9999999998 0.99999999999999999999999999999999999998
99999999999999999999999999999999999999 9999999999999999999999999999.9999999999 0.99999999999999999999999999999999999999
INSERT INTO cs2 VALUES (125, 1.25, 0.125);
INSERT INTO cs2 values (99999999999999999999999999999999999998, 9999999999999999999999999999.9999999998, 0.99999999999999999999999999999999999998);
INSERT INTO cs2 values (99999999999999999999999999999999999999, 9999999999999999999999999999.9999999999, 0.99999999999999999999999999999999999999);
SELECT d1, d1, d2 FROM cs2 UNION SELECT d2, d3, d3 FROM cs2;
ERROR 42000: The storage engine for the table doesn't support MCS-2060: Union operation exceeds maximum DECIMAL precision of 38.
SELECT d2, d3, d3 FROM cs2 UNION SELECT d1, d1, d2 FROM cs2;
ERROR 42000: The storage engine for the table doesn't support MCS-2060: Union operation exceeds maximum DECIMAL precision of 38.
SELECT d1, d2, d3 FROM cs2 UNION SELECT d1, d2, d3 FROM cs2;
d1 d2 d3
125 1.2500000000 0.12500000000000000000000000000000000000
99999999999999999999999999999999999998 9999999999999999999999999999.9999999998 0.99999999999999999999999999999999999998
99999999999999999999999999999999999999 9999999999999999999999999999.9999999999 0.99999999999999999999999999999999999999
DROP TABLE cs1, cs2;
CREATE TABLE cs1 (d1 DECIMAL(20, 0), d2 DECIMAL(20, 18), d3 DECIMAL(18, 18)) ENGINE=columnstore;
CREATE TABLE cs2 (d1 DECIMAL(20, 0) UNSIGNED, d2 DECIMAL(20, 18) UNSIGNED, d3 DECIMAL(18, 18) UNSIGNED) ENGINE=columnstore;
INSERT INTO cs1 VALUES (12345678901234567890, 12.345678901234567891, 0.123456789012345678);
INSERT INTO cs1 VALUES (-12345678901234567890, -12.345678901234567891, -0.123456789012345678);
INSERT INTO cs1 VALUES (99999999999999999999, 99.999999999999999999, 0.999999999999999999);
INSERT INTO cs1 VALUES (-99999999999999999999, -99.999999999999999999, -0.999999999999999999);
INSERT INTO cs2 VALUES (12345678901234567890, 12.345678901234567891, 0.123456789012345678);
INSERT INTO cs2 VALUES (99999999999999999999, 99.999999999999999999, 0.999999999999999999);
SELECT d1, d1, d2 FROM cs1 UNION SELECT d2, d3, d3 FROM cs1;
d1 d1 d2
-12.345678901234567891 -0.123456789012345678 -0.123456789012345678
-12345678901234567890.000000000000000000 -12345678901234567890.000000000000000000 -12.345678901234567891
-99.999999999999999999 -0.999999999999999999 -0.999999999999999999
-99999999999999999999.000000000000000000 -99999999999999999999.000000000000000000 -99.999999999999999999
12.345678901234567891 0.123456789012345678 0.123456789012345678
12345678901234567890.000000000000000000 12345678901234567890.000000000000000000 12.345678901234567891
99.999999999999999999 0.999999999999999999 0.999999999999999999
99999999999999999999.000000000000000000 99999999999999999999.000000000000000000 99.999999999999999999
SELECT d1, d1, d2 FROM cs2 UNION SELECT d2, d3, d3 FROM cs2;
d1 d1 d2
12.345678901234567891 0.123456789012345678 0.123456789012345678
12345678901234567890.000000000000000000 12345678901234567890.000000000000000000 12.345678901234567891
99.999999999999999999 0.999999999999999999 0.999999999999999999
99999999999999999999.000000000000000000 99999999999999999999.000000000000000000 99.999999999999999999
DROP DATABASE mcol641_union_db;