1
0
mirror of https://github.com/mariadb-corporation/mariadb-columnstore-engine.git synced 2025-07-29 08:21:15 +03:00

MCOL-98: Added error message for functions returning out of range values.

This commit is contained in:
Ben Thompson
2016-10-10 16:52:47 -05:00
parent 9606375939
commit d0e9cde782
5 changed files with 38 additions and 5 deletions

View File

@ -34,6 +34,11 @@ using namespace std;
#include "rowgroup.h" #include "rowgroup.h"
using namespace execplan; using namespace execplan;
#include "errorcodes.h"
#include "idberrorinfo.h"
#include "errorids.h"
using namespace logging;
#include "dataconvert.h" #include "dataconvert.h"
namespace funcexp namespace funcexp
@ -55,7 +60,7 @@ int64_t Func_div::getIntVal(rowgroup::Row& row,
if (int_val2 == 0) if (int_val2 == 0)
{ {
isNull = true; isNull = true;
return 0; return NULL;
} }
int64_t int_val1 = (int64_t)(val1 > 0 ? val1 + 0.5 : val1 - 0.5); int64_t int_val1 = (int64_t)(val1 > 0 ? val1 + 0.5 : val1 - 0.5);
// MCOL-176 If abs(int_val2) is small enough (like -1), then, this may cause overflow. // MCOL-176 If abs(int_val2) is small enough (like -1), then, this may cause overflow.
@ -78,7 +83,7 @@ uint64_t Func_div::getUintVal(rowgroup::Row& row,
if (val2 == 0) if (val2 == 0)
{ {
isNull = true; isNull = true;
return 0; return NULL;
} }
return val1 / val2; return val1 / val2;
} }

View File

@ -33,6 +33,11 @@ using namespace execplan;
#include "rowgroup.h" #include "rowgroup.h"
using namespace rowgroup; using namespace rowgroup;
#include "errorcodes.h"
#include "idberrorinfo.h"
#include "errorids.h"
using namespace logging;
namespace funcexp namespace funcexp
{ {
@ -58,7 +63,14 @@ double Func_exp::getDoubleVal(Row& row,
if (errno == ERANGE) // display NULL for out range value if (errno == ERANGE) // display NULL for out range value
{ {
if (x > 0) if (x > 0)
{
isNull = true; isNull = true;
Message::Args args;
args.add("exp");
args.add(x);
unsigned errcode = ERR_FUNC_OUT_OF_RANGE_RESULT;
throw IDBExcept(IDBErrorInfo::instance()->errorMsg(errcode, args), errcode);
}
else else
ret = 0.0; ret = 0.0;
} }

View File

@ -497,7 +497,7 @@ double Func_cot::getDoubleVal(Row& row,
Message::Args args; Message::Args args;
args.add("cot"); args.add("cot");
args.add(value); args.add(value);
unsigned errcode = ERR_INCORRECT_VALUE; unsigned errcode = ERR_FUNC_OUT_OF_RANGE_RESULT;
throw IDBExcept(IDBErrorInfo::instance()->errorMsg(errcode, args), errcode); throw IDBExcept(IDBErrorInfo::instance()->errorMsg(errcode, args), errcode);
} }
if (isNull) if (isNull)
@ -518,7 +518,7 @@ double Func_cot::getDoubleVal(Row& row,
Message::Args args; Message::Args args;
args.add("cot"); args.add("cot");
args.add(value); args.add(value);
unsigned errcode = ERR_INCORRECT_VALUE; unsigned errcode = ERR_FUNC_OUT_OF_RANGE_RESULT;
throw IDBExcept(IDBErrorInfo::instance()->errorMsg(errcode, args), errcode); throw IDBExcept(IDBErrorInfo::instance()->errorMsg(errcode, args), errcode);
} }
@ -540,7 +540,7 @@ double Func_cot::getDoubleVal(Row& row,
Message::Args args; Message::Args args;
args.add("cot"); args.add("cot");
args.add((uint64_t)value); args.add((uint64_t)value);
unsigned errcode = ERR_INCORRECT_VALUE; unsigned errcode = ERR_FUNC_OUT_OF_RANGE_RESULT;
throw IDBExcept(IDBErrorInfo::instance()->errorMsg(errcode, args), errcode); throw IDBExcept(IDBErrorInfo::instance()->errorMsg(errcode, args), errcode);
} }
if (isNull) if (isNull)

View File

@ -37,6 +37,11 @@ using namespace execplan;
#include "rowgroup.h" #include "rowgroup.h"
using namespace rowgroup; using namespace rowgroup;
#include "errorcodes.h"
#include "idberrorinfo.h"
#include "errorids.h"
using namespace logging;
namespace funcexp namespace funcexp
{ {
@ -65,7 +70,16 @@ double Func_pow::getDoubleVal(Row& row,
// @bug3490, 4461, rule out domain error, pole error and overflow range error. // @bug3490, 4461, rule out domain error, pole error and overflow range error.
if (!isfinite(x)) if (!isfinite(x))
{
isNull = true; isNull = true;
Message::Args args;
args.add("pow");
args.add(base);
args.add(exponent);
unsigned errcode = ERR_FUNC_OUT_OF_RANGE_RESULT;
throw IDBExcept(IDBErrorInfo::instance()->errorMsg(errcode, args), errcode);
}
return x; return x;
} }

View File

@ -95,6 +95,8 @@
2051 ERR_DBJ_DATA_DISTRIBUTION The data distribution in this query overflowed a disk-based join bucket. If possible, raise infinidb_diskjoin_bucketsize and try again. 2051 ERR_DBJ_DATA_DISTRIBUTION The data distribution in this query overflowed a disk-based join bucket. If possible, raise infinidb_diskjoin_bucketsize and try again.
2052 INFO_SWITCHING_TO_DJS Out of UM memory, switching to disk-based join. 2052 INFO_SWITCHING_TO_DJS Out of UM memory, switching to disk-based join.
2053 ERR_FUNC_OUT_OF_RANGE_RESULT The result is out of range for function %1% using value(s): %2% %3%
# Sub-query errors # Sub-query errors
3001 ERR_NON_SUPPORT_SUB_QUERY_TYPE This subquery type is not supported yet. 3001 ERR_NON_SUPPORT_SUB_QUERY_TYPE This subquery type is not supported yet.
3002 ERR_MORE_THAN_1_ROW Subquery returns more than 1 row. 3002 ERR_MORE_THAN_1_ROW Subquery returns more than 1 row.