You've already forked mariadb-columnstore-engine
mirror of
https://github.com/mariadb-corporation/mariadb-columnstore-engine.git
synced 2025-07-29 08:21:15 +03:00
MCOL-3756 Implement IS(NOT)TRUE() and IS(NOT)FALSE() functions.
This commit is contained in:
@ -141,6 +141,10 @@ FuncExp::FuncExp()
|
|||||||
fFuncMap["instr"] = new Func_instr();
|
fFuncMap["instr"] = new Func_instr();
|
||||||
fFuncMap["isnull"] = new Func_isnull(false);
|
fFuncMap["isnull"] = new Func_isnull(false);
|
||||||
fFuncMap["isnotnull"] = new Func_isnull(true);
|
fFuncMap["isnotnull"] = new Func_isnull(true);
|
||||||
|
fFuncMap["istrue"] = new Func_IsTrue();
|
||||||
|
fFuncMap["isnottrue"] = new Func_IsNotTrue();
|
||||||
|
fFuncMap["isfalse"] = new Func_IsFalse();
|
||||||
|
fFuncMap["isnotfalse"] = new Func_IsNotFalse();
|
||||||
fFuncMap["last_day"] = new Func_last_day();
|
fFuncMap["last_day"] = new Func_last_day();
|
||||||
fFuncMap["lcase"] = new Func_lcase(); //dlh
|
fFuncMap["lcase"] = new Func_lcase(); //dlh
|
||||||
fFuncMap["least"] = new Func_least(); //dlh
|
fFuncMap["least"] = new Func_least(); //dlh
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
/* Copyright (C) 2014 InfiniDB, Inc.
|
/* Copyright (C) 2014 InfiniDB, Inc.
|
||||||
|
Copyright (C) 2020 MariaDB Corporation
|
||||||
|
|
||||||
This program is free software; you can redistribute it and/or
|
This program is free software; you can redistribute it and/or
|
||||||
modify it under the terms of the GNU General Public License
|
modify it under the terms of the GNU General Public License
|
||||||
@ -241,6 +242,88 @@ private:
|
|||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
/** @brief Func_Truth class
|
||||||
|
*/
|
||||||
|
class Func_Truth : public Func_Bool
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
Func_Truth(const std::string& funcName, bool a_value, bool a_affirmative) :
|
||||||
|
Func_Bool(funcName), value(a_value), affirmative(a_affirmative) {}
|
||||||
|
|
||||||
|
virtual ~Func_Truth() {}
|
||||||
|
|
||||||
|
execplan::CalpontSystemCatalog::ColType operationType(FunctionParm& fp, execplan::CalpontSystemCatalog::ColType& resultType)
|
||||||
|
{
|
||||||
|
assert (fp.size() == 1);
|
||||||
|
return fp[0]->data()->resultType();
|
||||||
|
}
|
||||||
|
|
||||||
|
bool getBoolVal(rowgroup::Row& row,
|
||||||
|
FunctionParm& fp,
|
||||||
|
bool& isNull,
|
||||||
|
execplan::CalpontSystemCatalog::ColType& op_ct)
|
||||||
|
{
|
||||||
|
bool val = fp[0]->data()->getBoolVal(row, isNull);
|
||||||
|
|
||||||
|
/*
|
||||||
|
NULL val IS {TRUE, FALSE} --> FALSE
|
||||||
|
NULL val IS NOT {TRUE, FALSE} --> TRUE
|
||||||
|
{TRUE, FALSE} val IS {TRUE, FALSE} value --> val == value
|
||||||
|
{TRUE, FALSE} val IS NOT {TRUE, FALSE} value --> val != value
|
||||||
|
These cases can be reduced to the following bitwise operation.
|
||||||
|
*/
|
||||||
|
bool ret = (isNull & (!affirmative)) | ((!isNull) & (affirmative ^ (value ^ val)));
|
||||||
|
|
||||||
|
isNull = false;
|
||||||
|
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
private:
|
||||||
|
const bool value, affirmative;
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
/** @brief Func_IsTrue class
|
||||||
|
*/
|
||||||
|
class Func_IsTrue : public Func_Truth
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
Func_IsTrue() : Func_Truth("istrue", true, true) {}
|
||||||
|
~Func_IsTrue() {}
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
/** @brief Func_IsNotTrue class
|
||||||
|
*/
|
||||||
|
class Func_IsNotTrue : public Func_Truth
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
Func_IsNotTrue() : Func_Truth("isnottrue", true, false) {}
|
||||||
|
~Func_IsNotTrue() {}
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
/** @brief Func_IsFalse class
|
||||||
|
*/
|
||||||
|
class Func_IsFalse : public Func_Truth
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
Func_IsFalse() : Func_Truth("isfalse", false, true) {}
|
||||||
|
~Func_IsFalse() {}
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
/** @brief Func_IsNotFalse class
|
||||||
|
*/
|
||||||
|
class Func_IsNotFalse : public Func_Truth
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
Func_IsNotFalse() : Func_Truth("isnotfalse", false, false) {}
|
||||||
|
~Func_IsNotFalse() {}
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
Reference in New Issue
Block a user