From d61690748e926f63683b78f7462143cf36a9617a Mon Sep 17 00:00:00 2001 From: Alexander Barkov Date: Wed, 2 Jun 2021 15:08:20 +0400 Subject: [PATCH] MCOL-4743 Regression: TIME_TO_SEC(const_expr) erroneosly returns 0 --- dbcon/execplan/constantcolumn.cpp | 4 +--- dbcon/joblist/tupleconstantstep.cpp | 5 ++++- mysql-test/columnstore/basic/disabled.def | 1 - .../basic/r/mcs251_time_to_sec_function.result | 10 ++++++++++ .../basic/t/mcs251_time_to_sec_function.test | 12 ++++++++++++ 5 files changed, 27 insertions(+), 5 deletions(-) diff --git a/dbcon/execplan/constantcolumn.cpp b/dbcon/execplan/constantcolumn.cpp index 22be5bee8..f40ccc344 100644 --- a/dbcon/execplan/constantcolumn.cpp +++ b/dbcon/execplan/constantcolumn.cpp @@ -192,9 +192,7 @@ ConstantColumn::ConstantColumn(const string& sql, const IDB_Decimal& val) : fResult.longDoubleVal = strtold(sql.c_str(), NULL); fResult.decimalVal = val; fResultType.colDataType = CalpontSystemCatalog::DECIMAL; - fResultType.colWidth = 8; - fResultType.scale = val.scale; - fResultType.precision = val.precision; + fResultType.setDecimalScalePrecision(val.precision, val.scale); } ConstantColumn::ConstantColumn( const ConstantColumn& rhs): diff --git a/dbcon/joblist/tupleconstantstep.cpp b/dbcon/joblist/tupleconstantstep.cpp index ccbff89c7..bf58e4da5 100644 --- a/dbcon/joblist/tupleconstantstep.cpp +++ b/dbcon/joblist/tupleconstantstep.cpp @@ -238,7 +238,10 @@ void TupleConstantStep::constructContanstRow(const JobInfo& jobInfo) case CalpontSystemCatalog::DECIMAL: case CalpontSystemCatalog::UDECIMAL: { - fRowConst.setIntField(c.decimalVal.value, *i); + if (fRowGroupOut.getColWidths()[*i] > datatypes::MAXLEGACYWIDTH) + fRowConst.setInt128Field(c.decimalVal.TSInt128::getValue(), *i); + else + fRowConst.setIntField(c.decimalVal.value, *i); break; } diff --git a/mysql-test/columnstore/basic/disabled.def b/mysql-test/columnstore/basic/disabled.def index e6cdfaa56..25ad575d3 100644 --- a/mysql-test/columnstore/basic/disabled.def +++ b/mysql-test/columnstore/basic/disabled.def @@ -1,4 +1,3 @@ mcs80_set_operations : BUG#MCOL-4273 2020-08-27 susil.behera@mariadb.com -mcs251_time_to_sec_function : BUG#MCOL-4414 2020-11-30 bharath.bokka@maridb.com mcs212_idbExtentMax_function : 2020-11-30 bharath.bokka@mariadb.com mcs213_idbExtentMin_function : 2020-11-30 bharath.bokka@mariadb.com diff --git a/mysql-test/columnstore/basic/r/mcs251_time_to_sec_function.result b/mysql-test/columnstore/basic/r/mcs251_time_to_sec_function.result index a3e3b7bbe..41eb4edbb 100644 --- a/mysql-test/columnstore/basic/r/mcs251_time_to_sec_function.result +++ b/mysql-test/columnstore/basic/r/mcs251_time_to_sec_function.result @@ -29,4 +29,14 @@ t1_DATETIME TIME_TO_SEC(t1_DATETIME) 1997-12-12 22:12:02 79922 2001-01-01 23:59:59 86399 2009-12-11 01:08:59 4139 +DROP TABLE t1; +# +# MCOL-4743 Regression: TIME_TO_SEC(const_expr) erroneosly returns 0 +# +CREATE TABLE t1 (a INT) ENGINE=ColumnStore; +INSERT INTO t1 VALUES (1); +SELECT TIME_TO_SEC('10:50:40.9999') FROM t1; +TIME_TO_SEC('10:50:40.9999') +39040.9999 +DROP TABLE t1; DROP DATABASE mcs251_db; diff --git a/mysql-test/columnstore/basic/t/mcs251_time_to_sec_function.test b/mysql-test/columnstore/basic/t/mcs251_time_to_sec_function.test index 6ff49a1c1..07c6de815 100644 --- a/mysql-test/columnstore/basic/t/mcs251_time_to_sec_function.test +++ b/mysql-test/columnstore/basic/t/mcs251_time_to_sec_function.test @@ -28,5 +28,17 @@ SELECT TIME_TO_SEC('10:50:40.9999') FROM t1 LIMIT 1; SELECT t1_TIME, TIME_TO_SEC(t1_TIME) FROM t1 ORDER BY 1; SELECT t1_DATETIME, TIME_TO_SEC(t1_DATETIME) FROM t1 ORDER BY 1; +DROP TABLE t1; + +--echo # +--echo # MCOL-4743 Regression: TIME_TO_SEC(const_expr) erroneosly returns 0 +--echo # + +CREATE TABLE t1 (a INT) ENGINE=ColumnStore; +INSERT INTO t1 VALUES (1); +SELECT TIME_TO_SEC('10:50:40.9999') FROM t1; +DROP TABLE t1; + # Clean UP DROP DATABASE mcs251_db; +