From 9ac217221c51a057ea0dd9f40261586070ac2ced Mon Sep 17 00:00:00 2001 From: "Akhmad O." Date: Tue, 5 May 2026 17:37:50 +0200 Subject: [PATCH 1/4] MCOL-4627 add tests --- .../columnstore/bugfixes/mcol_4627.result | 32 ++++++++++++++ .../columnstore/bugfixes/mcol_4627.test | 42 +++++++++++++++++++ 2 files changed, 74 insertions(+) create mode 100644 mysql-test/columnstore/bugfixes/mcol_4627.result create mode 100644 mysql-test/columnstore/bugfixes/mcol_4627.test diff --git a/mysql-test/columnstore/bugfixes/mcol_4627.result b/mysql-test/columnstore/bugfixes/mcol_4627.result new file mode 100644 index 000000000..5f8ff591c --- /dev/null +++ b/mysql-test/columnstore/bugfixes/mcol_4627.result @@ -0,0 +1,32 @@ +DROP DATABASE IF EXISTS mcol_4627; +CREATE DATABASE mcol_4627; +USE mcol_4627; +DROP TABLE IF EXISTS t1; +CREATE TABLE t1 (i INT, d DECIMAL(10,1)) ENGINE=ColumnStore; +INSERT INTO t1 VALUES (0, 1.5); +UPDATE t1 SET i=d; +SELECT * FROM t1; +i d +2 1.5 +DROP TABLE IF EXISTS t1; +CREATE TABLE t1 (i INT, d DECIMAL(10,1)) ENGINE=ColumnStore; +INSERT INTO t1 VALUES (0, 1.4); +UPDATE t1 SET i=d; +SELECT * FROM t1; +i d +1 1.4 +DROP TABLE IF EXISTS t1; +CREATE TABLE t1 (i INT, d DECIMAL(10,1)) ENGINE=ColumnStore; +INSERT INTO t1 VALUES (0, -0.5); +UPDATE t1 SET i=d; +SELECT * FROM t1; +i d +0 -0.5 +DROP TABLE IF EXISTS t1; +CREATE TABLE t1 (i INT UNSIGNED, d DECIMAL(10,1)) ENGINE=ColumnStore; +INSERT INTO t1 VALUES (0, 0.5); +UPDATE t1 SET i=d; +SELECT * FROM t1; +i d +1 0.5 +DROP DATABASE mcol_4627; diff --git a/mysql-test/columnstore/bugfixes/mcol_4627.test b/mysql-test/columnstore/bugfixes/mcol_4627.test new file mode 100644 index 000000000..e03a7ada3 --- /dev/null +++ b/mysql-test/columnstore/bugfixes/mcol_4627.test @@ -0,0 +1,42 @@ +-- source ../include/have_columnstore.inc +--disable_warnings +DROP DATABASE IF EXISTS mcol_4627; +--enable_warnings +CREATE DATABASE mcol_4627; +USE mcol_4627; + +--disable_warnings +DROP TABLE IF EXISTS t1; +--enable_warnings +CREATE TABLE t1 (i INT, d DECIMAL(10,1)) ENGINE=ColumnStore; +INSERT INTO t1 VALUES (0, 1.5); +UPDATE t1 SET i=d; +SELECT * FROM t1; + +--disable_warnings +DROP TABLE IF EXISTS t1; +--enable_warnings +CREATE TABLE t1 (i INT, d DECIMAL(10,1)) ENGINE=ColumnStore; +INSERT INTO t1 VALUES (0, 1.4); +UPDATE t1 SET i=d; +SELECT * FROM t1; + +--disable_warnings +DROP TABLE IF EXISTS t1; +--enable_warnings +CREATE TABLE t1 (i INT, d DECIMAL(10,1)) ENGINE=ColumnStore; +INSERT INTO t1 VALUES (0, -0.5); +UPDATE t1 SET i=d; +SELECT * FROM t1; + +--disable_warnings +DROP TABLE IF EXISTS t1; +--enable_warnings +CREATE TABLE t1 (i INT UNSIGNED, d DECIMAL(10,1)) ENGINE=ColumnStore; +INSERT INTO t1 VALUES (0, 0.5); +UPDATE t1 SET i=d; +SELECT * FROM t1; + +--disable_warnings +DROP DATABASE mcol_4627; +--enable_warnings From 4cd0dd0e00e0630df299709c7554d0035194c982 Mon Sep 17 00:00:00 2001 From: "Akhmad O." Date: Tue, 5 May 2026 17:53:46 +0200 Subject: [PATCH 2/4] Update rounding logic to be sign-based --- utils/dataconvert/dataconvert.cpp | 12 +++--------- 1 file changed, 3 insertions(+), 9 deletions(-) diff --git a/utils/dataconvert/dataconvert.cpp b/utils/dataconvert/dataconvert.cpp index 7c9cbdb03..79ca8f510 100644 --- a/utils/dataconvert/dataconvert.cpp +++ b/utils/dataconvert/dataconvert.cpp @@ -279,15 +279,9 @@ void number_int_value(const string& data, cscDataType typeCode, intVal = dataconvert::string_to_ll(intStr, pushwarning); - if (intVal == 0 && isNegative) - { - if (roundup == 1) - roundup = 0; - } - else - { - intVal += intVal >= 0 ? roundup : -roundup; - } + // Apply rounding direction from the original sign, including "-0.x". + // This keeps behavior consistent with InnoDB for boundary cases like -0.5 -> -1. + intVal += isNegative ? -roundup : roundup; switch (typeCode) { From f00dcc456a1bbe835169269efc7edac24331f5e3 Mon Sep 17 00:00:00 2001 From: "Akhmad O." Date: Tue, 5 May 2026 17:54:24 +0200 Subject: [PATCH 3/4] Fix and extend testcase --- mysql-test/columnstore/bugfixes/mcol_4627.result | 16 +++++++++++++++- mysql-test/columnstore/bugfixes/mcol_4627.test | 16 ++++++++++++++++ mysql-test/columnstore/bugfixes/mcol_4628.result | 2 +- 3 files changed, 32 insertions(+), 2 deletions(-) diff --git a/mysql-test/columnstore/bugfixes/mcol_4627.result b/mysql-test/columnstore/bugfixes/mcol_4627.result index 5f8ff591c..f8c6feee2 100644 --- a/mysql-test/columnstore/bugfixes/mcol_4627.result +++ b/mysql-test/columnstore/bugfixes/mcol_4627.result @@ -21,7 +21,21 @@ INSERT INTO t1 VALUES (0, -0.5); UPDATE t1 SET i=d; SELECT * FROM t1; i d -0 -0.5 +-1 -0.5 +DROP TABLE IF EXISTS t1; +CREATE TABLE t1 (i INT, d DECIMAL(10,1)) ENGINE=ColumnStore; +INSERT INTO t1 VALUES (0, -1.5); +UPDATE t1 SET i=d; +SELECT * FROM t1; +i d +-2 -1.5 +DROP TABLE IF EXISTS t1; +CREATE TABLE t1 (i INT, d DECIMAL(10,1)) ENGINE=ColumnStore; +INSERT INTO t1 VALUES (7, NULL); +UPDATE t1 SET i=d; +SELECT * FROM t1; +i d +NULL NULL DROP TABLE IF EXISTS t1; CREATE TABLE t1 (i INT UNSIGNED, d DECIMAL(10,1)) ENGINE=ColumnStore; INSERT INTO t1 VALUES (0, 0.5); diff --git a/mysql-test/columnstore/bugfixes/mcol_4627.test b/mysql-test/columnstore/bugfixes/mcol_4627.test index e03a7ada3..381f753ce 100644 --- a/mysql-test/columnstore/bugfixes/mcol_4627.test +++ b/mysql-test/columnstore/bugfixes/mcol_4627.test @@ -29,6 +29,22 @@ INSERT INTO t1 VALUES (0, -0.5); UPDATE t1 SET i=d; SELECT * FROM t1; +--disable_warnings +DROP TABLE IF EXISTS t1; +--enable_warnings +CREATE TABLE t1 (i INT, d DECIMAL(10,1)) ENGINE=ColumnStore; +INSERT INTO t1 VALUES (0, -1.5); +UPDATE t1 SET i=d; +SELECT * FROM t1; + +--disable_warnings +DROP TABLE IF EXISTS t1; +--enable_warnings +CREATE TABLE t1 (i INT, d DECIMAL(10,1)) ENGINE=ColumnStore; +INSERT INTO t1 VALUES (7, NULL); +UPDATE t1 SET i=d; +SELECT * FROM t1; + --disable_warnings DROP TABLE IF EXISTS t1; --enable_warnings diff --git a/mysql-test/columnstore/bugfixes/mcol_4628.result b/mysql-test/columnstore/bugfixes/mcol_4628.result index 35348f734..1ad1b84e5 100644 --- a/mysql-test/columnstore/bugfixes/mcol_4628.result +++ b/mysql-test/columnstore/bugfixes/mcol_4628.result @@ -28,7 +28,7 @@ INSERT INTO t1 VALUES (0, -0.5); UPDATE t1 SET i=d; SELECT * FROM t1; i d -0 -0.5 +-1 -0.5 DROP TABLE IF EXISTS t1; CREATE TABLE t1 (i INT UNSIGNED, d DOUBLE) ENGINE=ColumnStore; INSERT INTO t1 VALUES (0, 0.5); From 48b682541ed2db5e6478467ae198d3f1a6a0ca3e Mon Sep 17 00:00:00 2001 From: "Akhmad O." Date: Fri, 15 May 2026 20:49:54 +0200 Subject: [PATCH 4/4] Add --sorted_result flag before SELECTs for row order consistency --- mysql-test/columnstore/bugfixes/mcol_4627.test | 6 ++++++ mysql-test/columnstore/bugfixes/mcol_4628.result | 4 ++-- mysql-test/columnstore/bugfixes/mcol_4628.test | 9 +++++++++ 3 files changed, 17 insertions(+), 2 deletions(-) diff --git a/mysql-test/columnstore/bugfixes/mcol_4627.test b/mysql-test/columnstore/bugfixes/mcol_4627.test index 381f753ce..8ac1d5b88 100644 --- a/mysql-test/columnstore/bugfixes/mcol_4627.test +++ b/mysql-test/columnstore/bugfixes/mcol_4627.test @@ -11,6 +11,7 @@ DROP TABLE IF EXISTS t1; CREATE TABLE t1 (i INT, d DECIMAL(10,1)) ENGINE=ColumnStore; INSERT INTO t1 VALUES (0, 1.5); UPDATE t1 SET i=d; +--sorted_result SELECT * FROM t1; --disable_warnings @@ -19,6 +20,7 @@ DROP TABLE IF EXISTS t1; CREATE TABLE t1 (i INT, d DECIMAL(10,1)) ENGINE=ColumnStore; INSERT INTO t1 VALUES (0, 1.4); UPDATE t1 SET i=d; +--sorted_result SELECT * FROM t1; --disable_warnings @@ -27,6 +29,7 @@ DROP TABLE IF EXISTS t1; CREATE TABLE t1 (i INT, d DECIMAL(10,1)) ENGINE=ColumnStore; INSERT INTO t1 VALUES (0, -0.5); UPDATE t1 SET i=d; +--sorted_result SELECT * FROM t1; --disable_warnings @@ -35,6 +38,7 @@ DROP TABLE IF EXISTS t1; CREATE TABLE t1 (i INT, d DECIMAL(10,1)) ENGINE=ColumnStore; INSERT INTO t1 VALUES (0, -1.5); UPDATE t1 SET i=d; +--sorted_result SELECT * FROM t1; --disable_warnings @@ -43,6 +47,7 @@ DROP TABLE IF EXISTS t1; CREATE TABLE t1 (i INT, d DECIMAL(10,1)) ENGINE=ColumnStore; INSERT INTO t1 VALUES (7, NULL); UPDATE t1 SET i=d; +--sorted_result SELECT * FROM t1; --disable_warnings @@ -51,6 +56,7 @@ DROP TABLE IF EXISTS t1; CREATE TABLE t1 (i INT UNSIGNED, d DECIMAL(10,1)) ENGINE=ColumnStore; INSERT INTO t1 VALUES (0, 0.5); UPDATE t1 SET i=d; +--sorted_result SELECT * FROM t1; --disable_warnings diff --git a/mysql-test/columnstore/bugfixes/mcol_4628.result b/mysql-test/columnstore/bugfixes/mcol_4628.result index 1ad1b84e5..3f90395e1 100644 --- a/mysql-test/columnstore/bugfixes/mcol_4628.result +++ b/mysql-test/columnstore/bugfixes/mcol_4628.result @@ -58,8 +58,8 @@ INSERT INTO t1 VALUES (761); INSERT INTO t1 VALUES (762); SELECT * FROM t1 WHERE i > -762.5; i --762 -761 +-762 761 762 DROP TABLE IF EXISTS t1; @@ -70,8 +70,8 @@ INSERT INTO t1 VALUES (761); INSERT INTO t1 VALUES (762); SELECT * FROM t1 WHERE i > -762.2; i --762 -761 +-762 761 762 DROP TABLE IF EXISTS t1; diff --git a/mysql-test/columnstore/bugfixes/mcol_4628.test b/mysql-test/columnstore/bugfixes/mcol_4628.test index 7bd90198c..b38266061 100644 --- a/mysql-test/columnstore/bugfixes/mcol_4628.test +++ b/mysql-test/columnstore/bugfixes/mcol_4628.test @@ -11,6 +11,7 @@ DROP TABLE IF EXISTS t1; CREATE TABLE t1 (i INT, d DOUBLE) ENGINE=ColumnStore; INSERT INTO t1 VALUES (0, 1.5); UPDATE t1 SET i=d; +--sorted_result SELECT * FROM t1; --disable_warnings @@ -19,6 +20,7 @@ DROP TABLE IF EXISTS t1; CREATE TABLE t1 (i INT, d DOUBLE) ENGINE=ColumnStore; INSERT INTO t1 VALUES (0, 1.7); UPDATE t1 SET i=d; +--sorted_result SELECT * FROM t1; --disable_warnings @@ -27,6 +29,7 @@ DROP TABLE IF EXISTS t1; CREATE TABLE t1 (i INT, d DOUBLE) ENGINE=ColumnStore; INSERT INTO t1 VALUES (0, 1.4); UPDATE t1 SET i=d; +--sorted_result SELECT * FROM t1; --disable_warnings @@ -35,6 +38,7 @@ DROP TABLE IF EXISTS t1; CREATE TABLE t1 (i INT, d DOUBLE) ENGINE=ColumnStore; INSERT INTO t1 VALUES (0, -0.5); UPDATE t1 SET i=d; +--sorted_result SELECT * FROM t1; --disable_warnings @@ -43,6 +47,7 @@ DROP TABLE IF EXISTS t1; CREATE TABLE t1 (i INT UNSIGNED, d DOUBLE) ENGINE=ColumnStore; INSERT INTO t1 VALUES (0, 0.5); UPDATE t1 SET i=d; +--sorted_result SELECT * FROM t1; --disable_warnings @@ -51,6 +56,7 @@ DROP TABLE IF EXISTS t1; CREATE TABLE t1 (i INT UNSIGNED, d DOUBLE) ENGINE=ColumnStore; INSERT INTO t1 VALUES (0, 1.5); UPDATE t1 SET i=d; +--sorted_result SELECT * FROM t1; --disable_warnings @@ -59,6 +65,7 @@ DROP TABLE IF EXISTS t1; CREATE TABLE t1 (i INT UNSIGNED, d DOUBLE) ENGINE=ColumnStore; INSERT INTO t1 VALUES (0, 1.4); UPDATE t1 SET i=d; +--sorted_result SELECT * FROM t1; --disable_warnings @@ -69,6 +76,7 @@ INSERT INTO t1 VALUES (-762); INSERT INTO t1 VALUES (-761); INSERT INTO t1 VALUES (761); INSERT INTO t1 VALUES (762); +--sorted_result SELECT * FROM t1 WHERE i > -762.5; --disable_warnings @@ -79,6 +87,7 @@ INSERT INTO t1 VALUES (-762); INSERT INTO t1 VALUES (-761); INSERT INTO t1 VALUES (761); INSERT INTO t1 VALUES (762); +--sorted_result SELECT * FROM t1 WHERE i > -762.2; --disable_warnings