1
0
mirror of https://github.com/mariadb-corporation/mariadb-columnstore-engine.git synced 2025-05-28 13:01:26 +03:00
Sergey Zefirov 84148cbe4c
fix(datatypes, funcexp): Overflow detection for MCOL-5568 use case (and some other) (#2987)
We add intermediate calculations in int128_t when target is UBIGINT and
check for overflow before converting into the UBIGINT. This is so
because we can overflow on addition and multiplication, with (some)
signed operands or both unsigned.
2023-10-16 16:55:02 +03:00

110 lines
2.3 KiB
Plaintext

--disable_warnings
DROP DATABASE IF EXISTS MCOL5568;
--enable_warnings
CREATE DATABASE MCOL5568;
USE MCOL5568;
CREATE TABLE test_mult (
indemnity_paid INT(11),
n_clms TINYINT(3) UNSIGNED
) ENGINE=COLUMNSTORE;
INSERT INTO test_mult (indemnity_paid, n_clms) VALUES (-10, 1);
# an error.
--error 1815
SELECT indemnity_paid, n_clms, indemnity_paid * n_clms FROM test_mult;
# an error.
--error 1815
SELECT indemnity_paid, n_clms, indemnity_paid + n_clms FROM test_mult;
# not an error.
SELECT indemnity_paid, n_clms, (indemnity_paid + 9) + n_clms FROM test_mult;
CREATE TABLE test_mult2 (
indemnity_paid TINYINT,
n_clms TINYINT UNSIGNED
) ENGINE=COLUMNSTORE;
INSERT INTO test_mult2 (indemnity_paid, n_clms) VALUES (-10, 1);
# an error.
--error 1815
SELECT indemnity_paid, n_clms, indemnity_paid * n_clms FROM test_mult2;
# an error.
--error 1815
SELECT indemnity_paid, n_clms, indemnity_paid + n_clms FROM test_mult2;
# not an error.
SELECT indemnity_paid, n_clms, (indemnity_paid + 9) + n_clms FROM test_mult2;
CREATE TABLE test_mult3 (
indemnity_paid SMALLINT,
n_clms TINYINT UNSIGNED
) ENGINE=COLUMNSTORE;
INSERT INTO test_mult3 (indemnity_paid, n_clms) VALUES (-10, 1);
# an error.
--error 1815
SELECT indemnity_paid, n_clms, indemnity_paid * n_clms FROM test_mult3;
# an error.
--error 1815
SELECT indemnity_paid, n_clms, indemnity_paid + n_clms FROM test_mult3;
# not an error.
SELECT indemnity_paid, n_clms, (indemnity_paid + 9) + n_clms FROM test_mult3;
CREATE TABLE test_mult4 (
indemnity_paid INTEGER,
n_clms TINYINT UNSIGNED
) ENGINE=COLUMNSTORE;
INSERT INTO test_mult4 (indemnity_paid, n_clms) VALUES (-10, 1);
# an error.
--error 1815
SELECT indemnity_paid, n_clms, indemnity_paid * n_clms FROM test_mult4;
# an error.
--error 1815
SELECT indemnity_paid, n_clms, indemnity_paid + n_clms FROM test_mult4;
# not an error.
SELECT indemnity_paid, n_clms, (indemnity_paid + 9) + n_clms FROM test_mult4;
# an error.
--error 1815
SELECT indemnity_paid, n_clms, n_clms * indemnity_paid FROM test_mult4;
# an error.
--error 1815
SELECT indemnity_paid, n_clms, n_clms + indemnity_paid FROM test_mult4;
# not an error.
SELECT indemnity_paid, n_clms, n_clms + (indemnity_paid + 9) FROM test_mult4;
# an error again.
--error 1815
SELECT indemnity_paid, n_clms, n_clms - 2 FROM test_mult4;
DROP DATABASE MCOL5568;