You've already forked mariadb-columnstore-engine
mirror of
https://github.com/mariadb-corporation/mariadb-columnstore-engine.git
synced 2025-07-30 19:23:07 +03:00
MCOL-5992: fix NULLIF if first param is NULL
This commit is contained in:
committed by
Leonid Fedorov
parent
16904ab97d
commit
1fdeb740c9
@ -97,7 +97,7 @@ c NULL
|
||||
d d
|
||||
SELECT b, NULLIF(b, 15) FROM t1;
|
||||
b NULLIF(b, 15)
|
||||
NULL -2147483648
|
||||
NULL NULL
|
||||
12 12
|
||||
13 13
|
||||
14 14
|
||||
|
9
mysql-test/columnstore/bugfixes/mcol-5992.result
Normal file
9
mysql-test/columnstore/bugfixes/mcol-5992.result
Normal file
@ -0,0 +1,9 @@
|
||||
DROP DATABASE IF EXISTS mcol5992;
|
||||
CREATE DATABASE mcol5992;
|
||||
USE mcol5992;
|
||||
CREATE TABLE `CS_LEG` (`ID` bigint(20) DEFAULT NULL, `sess_count` smallint(6) DEFAULT NULL) ENGINE=Columnstore;
|
||||
insert into CS_LEG(ID) values(1);
|
||||
select NULLIF(sess_count,0) from CS_LEG;
|
||||
NULLIF(sess_count,0)
|
||||
NULL
|
||||
DROP DATABASE mcol5992;
|
16
mysql-test/columnstore/bugfixes/mcol-5992.test
Normal file
16
mysql-test/columnstore/bugfixes/mcol-5992.test
Normal file
@ -0,0 +1,16 @@
|
||||
# MCOL-5992: NULLIF() returns NULL when NULL is the first argument
|
||||
--source ../include/have_columnstore.inc
|
||||
|
||||
--disable_warnings
|
||||
DROP DATABASE IF EXISTS mcol5992;
|
||||
--enable_warnings
|
||||
|
||||
CREATE DATABASE mcol5992;
|
||||
USE mcol5992;
|
||||
|
||||
CREATE TABLE `CS_LEG` (`ID` bigint(20) DEFAULT NULL, `sess_count` smallint(6) DEFAULT NULL) ENGINE=Columnstore;
|
||||
|
||||
insert into CS_LEG(ID) values(1);
|
||||
select NULLIF(sess_count,0) from CS_LEG;
|
||||
|
||||
DROP DATABASE mcol5992;
|
@ -56,8 +56,15 @@ int64_t Func_nullif::getIntVal(rowgroup::Row& row, FunctionParm& parm, bool& isN
|
||||
execplan::CalpontSystemCatalog::ColType& op_ct)
|
||||
{
|
||||
int64_t exp1 = parm[0]->data()->getIntVal(row, isNull);
|
||||
|
||||
// NULL equals anything is NULL, so we return NULL as a value of parm[0]
|
||||
if (isNull)
|
||||
return exp1;
|
||||
|
||||
|
||||
int64_t exp2 = 0;
|
||||
|
||||
|
||||
switch (parm[1]->data()->resultType().colDataType)
|
||||
{
|
||||
case execplan::CalpontSystemCatalog::BIGINT:
|
||||
@ -236,6 +243,11 @@ uint64_t Func_nullif::getUintVal(rowgroup::Row& row, FunctionParm& parm, bool& i
|
||||
execplan::CalpontSystemCatalog::ColType& op_ct)
|
||||
{
|
||||
uint64_t exp1 = parm[0]->data()->getUintVal(row, isNull);
|
||||
|
||||
// NULL equals anything is NULL, so we return NULL as a value of parm[0]
|
||||
if (isNull)
|
||||
return exp1;
|
||||
|
||||
uint64_t exp2 = 0;
|
||||
|
||||
switch (parm[1]->data()->resultType().colDataType)
|
||||
@ -349,6 +361,11 @@ string Func_nullif::getStrVal(rowgroup::Row& row, FunctionParm& parm, bool& isNu
|
||||
CalpontSystemCatalog::ColType& op_ct)
|
||||
{
|
||||
string exp1 = parm[0]->data()->getStrVal(row, isNull).safeString("");
|
||||
|
||||
// NULL equals anything is NULL, so we return NULL as a value of parm[0]
|
||||
if (isNull)
|
||||
return exp1;
|
||||
|
||||
CHARSET_INFO* cs = parm[0]->data()->resultType().getCharset();
|
||||
|
||||
if (isNull)
|
||||
@ -395,6 +412,11 @@ int32_t Func_nullif::getDateIntVal(rowgroup::Row& row, FunctionParm& parm, bool&
|
||||
CalpontSystemCatalog::ColType& ct)
|
||||
{
|
||||
int64_t exp1 = parm[0]->data()->getDateIntVal(row, isNull);
|
||||
|
||||
// NULL equals anything is NULL, so we return NULL as a value of parm[0]
|
||||
if (isNull)
|
||||
return exp1;
|
||||
|
||||
int64_t exp2 = 0;
|
||||
|
||||
switch (parm[1]->data()->resultType().colDataType)
|
||||
@ -482,6 +504,11 @@ int64_t Func_nullif::getDatetimeIntVal(rowgroup::Row& row, FunctionParm& parm, b
|
||||
CalpontSystemCatalog::ColType& ct)
|
||||
{
|
||||
int64_t exp1 = parm[0]->data()->getDatetimeIntVal(row, isNull);
|
||||
|
||||
// NULL equals anything is NULL, so we return NULL as a value of parm[0]
|
||||
if (isNull)
|
||||
return exp1;
|
||||
|
||||
int64_t exp2 = 0;
|
||||
|
||||
switch (parm[1]->data()->resultType().colDataType)
|
||||
@ -547,6 +574,11 @@ int64_t Func_nullif::getTimeIntVal(rowgroup::Row& row, FunctionParm& parm, bool&
|
||||
CalpontSystemCatalog::ColType& ct)
|
||||
{
|
||||
int64_t exp1 = parm[0]->data()->getTimeIntVal(row, isNull);
|
||||
|
||||
// NULL equals anything is NULL, so we return NULL as a value of parm[0]
|
||||
if (isNull)
|
||||
return exp1;
|
||||
|
||||
int64_t exp2 = 0;
|
||||
|
||||
switch (parm[1]->data()->resultType().colDataType)
|
||||
@ -598,6 +630,11 @@ int64_t Func_nullif::getTimestampIntVal(rowgroup::Row& row, FunctionParm& parm,
|
||||
CalpontSystemCatalog::ColType& ct)
|
||||
{
|
||||
int64_t exp1 = parm[0]->data()->getTimestampIntVal(row, isNull);
|
||||
|
||||
// NULL equals anything is NULL, so we return NULL as a value of parm[0]
|
||||
if (isNull)
|
||||
return exp1;
|
||||
|
||||
int64_t exp2 = 0;
|
||||
|
||||
switch (parm[1]->data()->resultType().colDataType)
|
||||
@ -649,6 +686,11 @@ double Func_nullif::getDoubleVal(rowgroup::Row& row, FunctionParm& parm, bool& i
|
||||
execplan::CalpontSystemCatalog::ColType& op_ct)
|
||||
{
|
||||
double exp1 = parm[0]->data()->getDoubleVal(row, isNull);
|
||||
|
||||
// NULL equals anything is NULL, so we return NULL as a value of parm[0]
|
||||
if (isNull)
|
||||
return exp1;
|
||||
|
||||
double exp2 = 0;
|
||||
|
||||
switch (parm[1]->data()->resultType().colDataType)
|
||||
@ -737,6 +779,11 @@ long double Func_nullif::getLongDoubleVal(rowgroup::Row& row, FunctionParm& parm
|
||||
execplan::CalpontSystemCatalog::ColType& op_ct)
|
||||
{
|
||||
long double exp1 = parm[0]->data()->getLongDoubleVal(row, isNull);
|
||||
|
||||
// NULL equals anything is NULL, so we return NULL as a value of parm[0]
|
||||
if (isNull)
|
||||
return exp1;
|
||||
|
||||
long double exp2 = 0;
|
||||
|
||||
switch (parm[1]->data()->resultType().colDataType)
|
||||
@ -838,6 +885,11 @@ execplan::IDB_Decimal Func_nullif::getDecimalVal(rowgroup::Row& row, FunctionPar
|
||||
execplan::CalpontSystemCatalog::ColType& op_ct)
|
||||
{
|
||||
IDB_Decimal exp1 = parm[0]->data()->getDecimalVal(row, isNull);
|
||||
|
||||
// NULL equals anything is NULL, so we return NULL as a value of parm[0]
|
||||
if (isNull)
|
||||
return exp1;
|
||||
|
||||
IDB_Decimal exp2;
|
||||
|
||||
switch (parm[1]->data()->resultType().colDataType)
|
||||
|
Reference in New Issue
Block a user