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-1983 Reject non-numeric arguments for regr_*** functions that require numeric
This commit is contained in:
@ -57,6 +57,13 @@ mcsv1_UDAF::ReturnCode corr::init(mcsv1Context* context,
|
||||
context->setErrorMessage("corr() with other than 2 arguments");
|
||||
return mcsv1_UDAF::ERROR;
|
||||
}
|
||||
if (!(isNumeric(colTypes[0].dataType) && isNumeric(colTypes[1].dataType)))
|
||||
{
|
||||
// The error message will be prepended with
|
||||
// "The storage engine for the table doesn't support "
|
||||
context->setErrorMessage("corr() with non-numeric arguments");
|
||||
return mcsv1_UDAF::ERROR;
|
||||
}
|
||||
|
||||
context->setUserDataSize(sizeof(corr_data));
|
||||
context->setResultType(CalpontSystemCatalog::DOUBLE);
|
||||
|
@ -55,6 +55,13 @@ mcsv1_UDAF::ReturnCode covar_pop::init(mcsv1Context* context,
|
||||
context->setErrorMessage("covar_pop() with other than 2 arguments");
|
||||
return mcsv1_UDAF::ERROR;
|
||||
}
|
||||
if (!(isNumeric(colTypes[0].dataType) && isNumeric(colTypes[1].dataType)))
|
||||
{
|
||||
// The error message will be prepended with
|
||||
// "The storage engine for the table doesn't support "
|
||||
context->setErrorMessage("covar_pop() with non-numeric arguments");
|
||||
return mcsv1_UDAF::ERROR;
|
||||
}
|
||||
|
||||
context->setUserDataSize(sizeof(covar_pop_data));
|
||||
context->setResultType(CalpontSystemCatalog::DOUBLE);
|
||||
|
@ -55,6 +55,13 @@ mcsv1_UDAF::ReturnCode covar_samp::init(mcsv1Context* context,
|
||||
context->setErrorMessage("covar_samp() with other than 2 arguments");
|
||||
return mcsv1_UDAF::ERROR;
|
||||
}
|
||||
if (!(isNumeric(colTypes[0].dataType) && isNumeric(colTypes[1].dataType)))
|
||||
{
|
||||
// The error message will be prepended with
|
||||
// "The storage engine for the table doesn't support "
|
||||
context->setErrorMessage("covar_samp() with non-numeric arguments");
|
||||
return mcsv1_UDAF::ERROR;
|
||||
}
|
||||
|
||||
context->setUserDataSize(sizeof(covar_samp_data));
|
||||
context->setResultType(CalpontSystemCatalog::DOUBLE);
|
||||
|
@ -63,6 +63,13 @@ mcsv1_UDAF::ReturnCode regr_avgx::init(mcsv1Context* context,
|
||||
context->setErrorMessage("regr_avgx() with a non-numeric x argument");
|
||||
return mcsv1_UDAF::ERROR;
|
||||
}
|
||||
if (!(isNumeric(colTypes[1].dataType)))
|
||||
{
|
||||
// The error message will be prepended with
|
||||
// "The storage engine for the table doesn't support "
|
||||
context->setErrorMessage("regr_avgx() with a non-numeric independant (second) argument");
|
||||
return mcsv1_UDAF::ERROR;
|
||||
}
|
||||
|
||||
context->setUserDataSize(sizeof(regr_avgx_data));
|
||||
context->setResultType(CalpontSystemCatalog::DOUBLE);
|
||||
|
@ -63,6 +63,13 @@ mcsv1_UDAF::ReturnCode regr_avgy::init(mcsv1Context* context,
|
||||
context->setErrorMessage("regr_avgy() with a non-numeric x argument");
|
||||
return mcsv1_UDAF::ERROR;
|
||||
}
|
||||
if (!(isNumeric(colTypes[0].dataType)))
|
||||
{
|
||||
// The error message will be prepended with
|
||||
// "The storage engine for the table doesn't support "
|
||||
context->setErrorMessage("regr_avgy() with a non-numeric dependant (first) argument");
|
||||
return mcsv1_UDAF::ERROR;
|
||||
}
|
||||
|
||||
context->setUserDataSize(sizeof(regr_avgy_data));
|
||||
context->setResultType(CalpontSystemCatalog::DOUBLE);
|
||||
|
@ -56,6 +56,13 @@ mcsv1_UDAF::ReturnCode regr_intercept::init(mcsv1Context* context,
|
||||
context->setErrorMessage("regr_intercept() with other than 2 arguments");
|
||||
return mcsv1_UDAF::ERROR;
|
||||
}
|
||||
if (!(isNumeric(colTypes[0].dataType) && isNumeric(colTypes[1].dataType)))
|
||||
{
|
||||
// The error message will be prepended with
|
||||
// "The storage engine for the table doesn't support "
|
||||
context->setErrorMessage("regr_intercept() with non-numeric arguments");
|
||||
return mcsv1_UDAF::ERROR;
|
||||
}
|
||||
|
||||
context->setUserDataSize(sizeof(regr_intercept_data));
|
||||
context->setResultType(CalpontSystemCatalog::DOUBLE);
|
||||
|
@ -57,6 +57,13 @@ mcsv1_UDAF::ReturnCode regr_r2::init(mcsv1Context* context,
|
||||
context->setErrorMessage("regr_r2() with other than 2 arguments");
|
||||
return mcsv1_UDAF::ERROR;
|
||||
}
|
||||
if (!(isNumeric(colTypes[0].dataType) && isNumeric(colTypes[1].dataType)))
|
||||
{
|
||||
// The error message will be prepended with
|
||||
// "The storage engine for the table doesn't support "
|
||||
context->setErrorMessage("regr_r2() with non-numeric arguments");
|
||||
return mcsv1_UDAF::ERROR;
|
||||
}
|
||||
|
||||
context->setUserDataSize(sizeof(regr_r2_data));
|
||||
context->setResultType(CalpontSystemCatalog::DOUBLE);
|
||||
|
@ -56,7 +56,13 @@ mcsv1_UDAF::ReturnCode regr_slope::init(mcsv1Context* context,
|
||||
context->setErrorMessage("regr_slope() with other than 2 arguments");
|
||||
return mcsv1_UDAF::ERROR;
|
||||
}
|
||||
|
||||
if (!(isNumeric(colTypes[0].dataType) && isNumeric(colTypes[1].dataType)))
|
||||
{
|
||||
// The error message will be prepended with
|
||||
// "The storage engine for the table doesn't support "
|
||||
context->setErrorMessage("regr_slope() with non-numeric arguments");
|
||||
return mcsv1_UDAF::ERROR;
|
||||
}
|
||||
context->setUserDataSize(sizeof(regr_slope_data));
|
||||
context->setResultType(CalpontSystemCatalog::DOUBLE);
|
||||
context->setColWidth(8);
|
||||
|
@ -54,6 +54,13 @@ mcsv1_UDAF::ReturnCode regr_sxx::init(mcsv1Context* context,
|
||||
context->setErrorMessage("regr_sxx() with other than 2 arguments");
|
||||
return mcsv1_UDAF::ERROR;
|
||||
}
|
||||
if (!(isNumeric(colTypes[1].dataType)))
|
||||
{
|
||||
// The error message will be prepended with
|
||||
// "The storage engine for the table doesn't support "
|
||||
context->setErrorMessage("regr_sxx() with a non-numeric independant (second) argument");
|
||||
return mcsv1_UDAF::ERROR;
|
||||
}
|
||||
|
||||
context->setUserDataSize(sizeof(regr_sxx_data));
|
||||
context->setResultType(CalpontSystemCatalog::DOUBLE);
|
||||
|
@ -55,6 +55,13 @@ mcsv1_UDAF::ReturnCode regr_sxy::init(mcsv1Context* context,
|
||||
context->setErrorMessage("regr_sxy() with other than 2 arguments");
|
||||
return mcsv1_UDAF::ERROR;
|
||||
}
|
||||
if (!(isNumeric(colTypes[0].dataType) && isNumeric(colTypes[1].dataType)))
|
||||
{
|
||||
// The error message will be prepended with
|
||||
// "The storage engine for the table doesn't support "
|
||||
context->setErrorMessage("regr_sxy() with non-numeric arguments");
|
||||
return mcsv1_UDAF::ERROR;
|
||||
}
|
||||
|
||||
context->setUserDataSize(sizeof(regr_sxy_data));
|
||||
context->setResultType(CalpontSystemCatalog::DOUBLE);
|
||||
|
@ -54,6 +54,13 @@ mcsv1_UDAF::ReturnCode regr_syy::init(mcsv1Context* context,
|
||||
context->setErrorMessage("regr_syy() with other than 2 arguments");
|
||||
return mcsv1_UDAF::ERROR;
|
||||
}
|
||||
if (!(isNumeric(colTypes[0].dataType)))
|
||||
{
|
||||
// The error message will be prepended with
|
||||
// "The storage engine for the table doesn't support "
|
||||
context->setErrorMessage("regr_syy() with a non-numeric dependant (first) argument");
|
||||
return mcsv1_UDAF::ERROR;
|
||||
}
|
||||
|
||||
context->setUserDataSize(sizeof(regr_syy_data));
|
||||
context->setResultType(CalpontSystemCatalog::DOUBLE);
|
||||
|
@ -2,12 +2,30 @@
|
||||
#include <cmath>
|
||||
#include <iostream>
|
||||
#include <sstream>
|
||||
#include <string.h>
|
||||
using namespace std;
|
||||
|
||||
#include "idb_mysql.h"
|
||||
|
||||
namespace
|
||||
{
|
||||
inline bool isNumeric(int type, const char* attr)
|
||||
{
|
||||
if (type == INT_RESULT || type == REAL_RESULT || type == DECIMAL_RESULT)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
#if _MSC_VER
|
||||
if (_strnicmp("NULL", attr, 4) == 0))
|
||||
#else
|
||||
if (strncasecmp("NULL", attr, 4) == 0)
|
||||
#endif
|
||||
{
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
inline double cvtArgToDouble(int t, const char* v)
|
||||
{
|
||||
double d = 0.0;
|
||||
@ -144,6 +162,11 @@ extern "C"
|
||||
strcpy(message,"regr_avgx() requires two arguments");
|
||||
return 1;
|
||||
}
|
||||
if (!(isNumeric(args->arg_type[1], args->attributes[1])))
|
||||
{
|
||||
strcpy(message,"regr_avgx() with a non-numeric independant (second) argument");
|
||||
return 1;
|
||||
}
|
||||
|
||||
if (!(data = (struct regr_avgx_data*) malloc(sizeof(struct regr_avgx_data))))
|
||||
{
|
||||
@ -228,6 +251,11 @@ extern "C"
|
||||
strcpy(message,"regr_avgy() requires two arguments");
|
||||
return 1;
|
||||
}
|
||||
if (!(isNumeric(args->arg_type[0], args->attributes[0])))
|
||||
{
|
||||
strcpy(message,"regr_avgy() with a non-numeric dependant (first) argument");
|
||||
return 1;
|
||||
}
|
||||
|
||||
if (!(data = (struct regr_avgy_data*) malloc(sizeof(struct regr_avgy_data))))
|
||||
{
|
||||
@ -394,6 +422,11 @@ extern "C"
|
||||
strcpy(message,"regr_slope() requires two arguments");
|
||||
return 1;
|
||||
}
|
||||
if (!(isNumeric(args->arg_type[0], args->attributes[0]) && isNumeric(args->arg_type[1], args->attributes[1])))
|
||||
{
|
||||
strcpy(message,"regr_slope() with non-numeric arguments");
|
||||
return 1;
|
||||
}
|
||||
|
||||
if (!(data = (struct regr_slope_data*) malloc(sizeof(struct regr_slope_data))))
|
||||
{
|
||||
@ -505,6 +538,11 @@ extern "C"
|
||||
strcpy(message,"regr_intercept() requires two arguments");
|
||||
return 1;
|
||||
}
|
||||
if (!(isNumeric(args->arg_type[0], args->attributes[0]) && isNumeric(args->arg_type[1], args->attributes[1])))
|
||||
{
|
||||
strcpy(message,"regr_intercept() with non-numeric arguments");
|
||||
return 1;
|
||||
}
|
||||
|
||||
if (!(data = (struct regr_intercept_data*) malloc(sizeof(struct regr_intercept_data))))
|
||||
{
|
||||
@ -619,6 +657,11 @@ extern "C"
|
||||
strcpy(message,"regr_r2() requires two arguments");
|
||||
return 1;
|
||||
}
|
||||
if (!(isNumeric(args->arg_type[0], args->attributes[0]) && isNumeric(args->arg_type[1], args->attributes[1])))
|
||||
{
|
||||
strcpy(message,"regr_r2() with non-numeric arguments");
|
||||
return 1;
|
||||
}
|
||||
|
||||
if (!(data = (struct regr_r2_data*) malloc(sizeof(struct regr_r2_data))))
|
||||
{
|
||||
@ -748,6 +791,11 @@ extern "C"
|
||||
strcpy(message,"corr() requires two arguments");
|
||||
return 1;
|
||||
}
|
||||
if (!(isNumeric(args->arg_type[0], args->attributes[0]) && isNumeric(args->arg_type[1], args->attributes[1])))
|
||||
{
|
||||
strcpy(message,"corr() with non-numeric arguments");
|
||||
return 1;
|
||||
}
|
||||
|
||||
if (!(data = (struct corr_data*) malloc(sizeof(struct corr_data))))
|
||||
{
|
||||
@ -874,6 +922,11 @@ extern "C"
|
||||
strcpy(message,"regr_sxx() requires two arguments");
|
||||
return 1;
|
||||
}
|
||||
if (!(isNumeric(args->arg_type[1], args->attributes[1])))
|
||||
{
|
||||
strcpy(message,"regr_avgx() with a non-numeric independant (second) argument");
|
||||
return 1;
|
||||
}
|
||||
|
||||
if (!(data = (struct regr_sxx_data*) malloc(sizeof(struct regr_sxx_data))))
|
||||
{
|
||||
@ -970,6 +1023,11 @@ extern "C"
|
||||
strcpy(message,"regr_syy() requires two arguments");
|
||||
return 1;
|
||||
}
|
||||
if (!(isNumeric(args->arg_type[0], args->attributes[0])))
|
||||
{
|
||||
strcpy(message,"regr_syy() with a non-numeric dependant (first) argument");
|
||||
return 1;
|
||||
}
|
||||
|
||||
if (!(data = (struct regr_syy_data*) malloc(sizeof(struct regr_syy_data))))
|
||||
{
|
||||
@ -1068,6 +1126,11 @@ extern "C"
|
||||
strcpy(message,"regr_sxy() requires two arguments");
|
||||
return 1;
|
||||
}
|
||||
if (!(isNumeric(args->arg_type[0], args->attributes[0]) && isNumeric(args->arg_type[1], args->attributes[1])))
|
||||
{
|
||||
strcpy(message,"regr_sxy() with non-numeric arguments");
|
||||
return 1;
|
||||
}
|
||||
|
||||
if (!(data = (struct regr_sxy_data*) malloc(sizeof(struct regr_sxy_data))))
|
||||
{
|
||||
@ -1171,6 +1234,11 @@ extern "C"
|
||||
strcpy(message,"covar_pop() requires two arguments");
|
||||
return 1;
|
||||
}
|
||||
if (!(isNumeric(args->arg_type[0], args->attributes[0]) && isNumeric(args->arg_type[1], args->attributes[1])))
|
||||
{
|
||||
strcpy(message,"covar_pop() with non-numeric arguments");
|
||||
return 1;
|
||||
}
|
||||
|
||||
if (!(data = (struct covar_pop_data*) malloc(sizeof(struct covar_pop_data))))
|
||||
{
|
||||
@ -1273,6 +1341,11 @@ extern "C"
|
||||
strcpy(message,"covar_samp() requires two arguments");
|
||||
return 1;
|
||||
}
|
||||
if (!(isNumeric(args->arg_type[0], args->attributes[0]) && isNumeric(args->arg_type[1], args->attributes[1])))
|
||||
{
|
||||
strcpy(message,"covar_samp() with non-numeric arguments");
|
||||
return 1;
|
||||
}
|
||||
|
||||
if (!(data = (struct covar_samp_data*) malloc(sizeof(struct covar_samp_data))))
|
||||
{
|
||||
|
@ -976,7 +976,7 @@ inline mcsv1_UDAF::ReturnCode mcsv1_UDAF::createUserData(UserData*& userData, in
|
||||
template<typename T>
|
||||
inline T mcsv1_UDAF::convertAnyTo(static_any::any& valIn)
|
||||
{
|
||||
T val;
|
||||
T val = 0;
|
||||
if (valIn.compatible(longTypeId))
|
||||
{
|
||||
val = valIn.cast<long>();
|
||||
|
Reference in New Issue
Block a user