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
@ -260,8 +260,6 @@ void storeNumericField(Field** f, int64_t value, CalpontSystemCatalog::ColType&
|
|||||||
{
|
{
|
||||||
case MYSQL_TYPE_NEWDECIMAL:
|
case MYSQL_TYPE_NEWDECIMAL:
|
||||||
{
|
{
|
||||||
Field_new_decimal* f2 = (Field_new_decimal*)*f;
|
|
||||||
|
|
||||||
// @bug4388 stick to InfiniDB's scale in case mysql gives wrong scale due
|
// @bug4388 stick to InfiniDB's scale in case mysql gives wrong scale due
|
||||||
// to create vtable limitation.
|
// to create vtable limitation.
|
||||||
//if (f2->dec < ct.scale)
|
//if (f2->dec < ct.scale)
|
||||||
@ -269,7 +267,7 @@ void storeNumericField(Field** f, int64_t value, CalpontSystemCatalog::ColType&
|
|||||||
|
|
||||||
char buf[256];
|
char buf[256];
|
||||||
dataconvert::DataConvert::decimalToString(value, (unsigned)ct.scale, buf, 256, ct.colDataType);
|
dataconvert::DataConvert::decimalToString(value, (unsigned)ct.scale, buf, 256, ct.colDataType);
|
||||||
f2->store(buf, strlen(buf), f2->charset());
|
(*f)->store(buf, strlen(buf), (*f)->charset());
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -277,7 +275,7 @@ void storeNumericField(Field** f, int64_t value, CalpontSystemCatalog::ColType&
|
|||||||
{
|
{
|
||||||
Field_tiny* f2 = (Field_tiny*)*f;
|
Field_tiny* f2 = (Field_tiny*)*f;
|
||||||
longlong int_val = (longlong)value;
|
longlong int_val = (longlong)value;
|
||||||
f2->store(int_val, f2->unsigned_flag);
|
(*f)->store(int_val, f2->unsigned_flag);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -285,7 +283,7 @@ void storeNumericField(Field** f, int64_t value, CalpontSystemCatalog::ColType&
|
|||||||
{
|
{
|
||||||
Field_short* f2 = (Field_short*)*f;
|
Field_short* f2 = (Field_short*)*f;
|
||||||
longlong int_val = (longlong)value;
|
longlong int_val = (longlong)value;
|
||||||
f2->store(int_val, f2->unsigned_flag);
|
(*f)->store(int_val, f2->unsigned_flag);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -293,7 +291,7 @@ void storeNumericField(Field** f, int64_t value, CalpontSystemCatalog::ColType&
|
|||||||
{
|
{
|
||||||
Field_medium* f2 = (Field_medium*)*f;
|
Field_medium* f2 = (Field_medium*)*f;
|
||||||
longlong int_val = (longlong)value;
|
longlong int_val = (longlong)value;
|
||||||
f2->store(int_val, f2->unsigned_flag);
|
(*f)->store(int_val, f2->unsigned_flag);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -301,7 +299,7 @@ void storeNumericField(Field** f, int64_t value, CalpontSystemCatalog::ColType&
|
|||||||
{
|
{
|
||||||
Field_long* f2 = (Field_long*)*f;
|
Field_long* f2 = (Field_long*)*f;
|
||||||
longlong int_val = (longlong)value;
|
longlong int_val = (longlong)value;
|
||||||
f2->store(int_val, f2->unsigned_flag);
|
(*f)->store(int_val, f2->unsigned_flag);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -309,37 +307,33 @@ void storeNumericField(Field** f, int64_t value, CalpontSystemCatalog::ColType&
|
|||||||
{
|
{
|
||||||
Field_longlong* f2 = (Field_longlong*)*f;
|
Field_longlong* f2 = (Field_longlong*)*f;
|
||||||
longlong int_val = (longlong)value;
|
longlong int_val = (longlong)value;
|
||||||
f2->store(int_val, f2->unsigned_flag);
|
(*f)->store(int_val, f2->unsigned_flag);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
case MYSQL_TYPE_FLOAT: // FLOAT type
|
case MYSQL_TYPE_FLOAT: // FLOAT type
|
||||||
{
|
{
|
||||||
Field_float* f2 = (Field_float*)*f;
|
|
||||||
float float_val = *(float*)(&value);
|
float float_val = *(float*)(&value);
|
||||||
f2->store(float_val);
|
(*f)->store(float_val);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
case MYSQL_TYPE_DOUBLE: // DOUBLE type
|
case MYSQL_TYPE_DOUBLE: // DOUBLE type
|
||||||
{
|
{
|
||||||
Field_double* f2 = (Field_double*)*f;
|
|
||||||
double double_val = *(double*)(&value);
|
double double_val = *(double*)(&value);
|
||||||
f2->store(double_val);
|
(*f)->store(double_val);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
case MYSQL_TYPE_VARCHAR:
|
case MYSQL_TYPE_VARCHAR:
|
||||||
{
|
{
|
||||||
Field_varstring* f2 = (Field_varstring*)*f;
|
|
||||||
char tmp[25];
|
char tmp[25];
|
||||||
|
|
||||||
if (ct.colDataType == CalpontSystemCatalog::DECIMAL)
|
if (ct.colDataType == CalpontSystemCatalog::DECIMAL)
|
||||||
dataconvert::DataConvert::decimalToString(value, (unsigned)ct.scale, tmp, 25, ct.colDataType);
|
dataconvert::DataConvert::decimalToString(value, (unsigned)ct.scale, tmp, 25, ct.colDataType);
|
||||||
else
|
else
|
||||||
snprintf(tmp, 25, "%lld", (long long)value);
|
snprintf(tmp, 25, "%lld", (long long)value);
|
||||||
|
|
||||||
f2->store(tmp, strlen(tmp), f2->charset());
|
(*f)->store(tmp, strlen(tmp), (*f)->charset());
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -347,7 +341,7 @@ void storeNumericField(Field** f, int64_t value, CalpontSystemCatalog::ColType&
|
|||||||
{
|
{
|
||||||
Field_longlong* f2 = (Field_longlong*)*f;
|
Field_longlong* f2 = (Field_longlong*)*f;
|
||||||
longlong int_val = (longlong)value;
|
longlong int_val = (longlong)value;
|
||||||
f2->store(int_val, f2->unsigned_flag);
|
(*f)->store(int_val, f2->unsigned_flag);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -550,8 +544,7 @@ int fetchNextRow(uchar* buf, cal_table_info& ti, cal_connection_info* ci, bool h
|
|||||||
colType.colDataType == CalpontSystemCatalog::VARCHAR ||
|
colType.colDataType == CalpontSystemCatalog::VARCHAR ||
|
||||||
colType.colDataType == CalpontSystemCatalog::VARBINARY)
|
colType.colDataType == CalpontSystemCatalog::VARBINARY)
|
||||||
{
|
{
|
||||||
Field_varstring* f2 = (Field_varstring*)*f;
|
(*f)->store(tmp, 0, (*f)->charset());
|
||||||
f2->store(tmp, 0, f2->charset());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
continue;
|
continue;
|
||||||
@ -567,8 +560,7 @@ int fetchNextRow(uchar* buf, cal_table_info& ti, cal_connection_info* ci, bool h
|
|||||||
|
|
||||||
intColVal = row.getUintField<4>(s);
|
intColVal = row.getUintField<4>(s);
|
||||||
DataConvert::dateToString(intColVal, tmp, 255);
|
DataConvert::dateToString(intColVal, tmp, 255);
|
||||||
Field_varstring* f2 = (Field_varstring*)*f;
|
(*f)->store(tmp, strlen(tmp), (*f)->charset());
|
||||||
f2->store(tmp, strlen(tmp), f2->charset());
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -579,16 +571,7 @@ int fetchNextRow(uchar* buf, cal_table_info& ti, cal_connection_info* ci, bool h
|
|||||||
|
|
||||||
intColVal = row.getUintField<8>(s);
|
intColVal = row.getUintField<8>(s);
|
||||||
DataConvert::datetimeToString(intColVal, tmp, 255, colType.precision);
|
DataConvert::datetimeToString(intColVal, tmp, 255, colType.precision);
|
||||||
|
(*f)->store(tmp, strlen(tmp), (*f)->charset());
|
||||||
/* setting the field_length is a sort-of hack. The length
|
|
||||||
* at this point can be long enough to include mseconds.
|
|
||||||
* ColumnStore doesn't fully support mseconds yet so if
|
|
||||||
* they are requested, trim them off.
|
|
||||||
* At a later date we should set this more intelligently
|
|
||||||
* based on the result set.
|
|
||||||
*/
|
|
||||||
Field_varstring* f2 = (Field_varstring*)*f;
|
|
||||||
f2->store(tmp, strlen(tmp), f2->charset());
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -599,9 +582,7 @@ int fetchNextRow(uchar* buf, cal_table_info& ti, cal_connection_info* ci, bool h
|
|||||||
|
|
||||||
intColVal = row.getUintField<8>(s);
|
intColVal = row.getUintField<8>(s);
|
||||||
DataConvert::timeToString(intColVal, tmp, 255, colType.precision);
|
DataConvert::timeToString(intColVal, tmp, 255, colType.precision);
|
||||||
|
(*f)->store(tmp, strlen(tmp), (*f)->charset());
|
||||||
Field_varstring* f2 = (Field_varstring*)*f;
|
|
||||||
f2->store(tmp, strlen(tmp), f2->charset());
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -612,32 +593,28 @@ int fetchNextRow(uchar* buf, cal_table_info& ti, cal_connection_info* ci, bool h
|
|||||||
|
|
||||||
intColVal = row.getUintField<8>(s);
|
intColVal = row.getUintField<8>(s);
|
||||||
DataConvert::timestampToString(intColVal, tmp, 255, current_thd->variables.time_zone->get_name()->ptr(), colType.precision);
|
DataConvert::timestampToString(intColVal, tmp, 255, current_thd->variables.time_zone->get_name()->ptr(), colType.precision);
|
||||||
|
(*f)->store(tmp, strlen(tmp), (*f)->charset());
|
||||||
Field_varstring* f2 = (Field_varstring*)*f;
|
|
||||||
f2->store(tmp, strlen(tmp), f2->charset());
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
case CalpontSystemCatalog::CHAR:
|
case CalpontSystemCatalog::CHAR:
|
||||||
case CalpontSystemCatalog::VARCHAR:
|
case CalpontSystemCatalog::VARCHAR:
|
||||||
{
|
{
|
||||||
Field_varstring* f2 = (Field_varstring*)*f;
|
|
||||||
|
|
||||||
switch (colType.colWidth)
|
switch (colType.colWidth)
|
||||||
{
|
{
|
||||||
case 1:
|
case 1:
|
||||||
intColVal = row.getUintField<1>(s);
|
intColVal = row.getUintField<1>(s);
|
||||||
f2->store((char*)(&intColVal), strlen((char*)(&intColVal)), f2->charset());
|
(*f)->store((char*)(&intColVal), strlen((char*)(&intColVal)), (*f)->charset());
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 2:
|
case 2:
|
||||||
intColVal = row.getUintField<2>(s);
|
intColVal = row.getUintField<2>(s);
|
||||||
f2->store((char*)(&intColVal), strlen((char*)(&intColVal)), f2->charset());
|
(*f)->store((char*)(&intColVal), strlen((char*)(&intColVal)), (*f)->charset());
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 4:
|
case 4:
|
||||||
intColVal = row.getUintField<4>(s);
|
intColVal = row.getUintField<4>(s);
|
||||||
f2->store((char*)(&intColVal), strlen((char*)(&intColVal)), f2->charset());
|
(*f)->store((char*)(&intColVal), strlen((char*)(&intColVal)), (*f)->charset());
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 8:
|
case 8:
|
||||||
@ -645,11 +622,11 @@ int fetchNextRow(uchar* buf, cal_table_info& ti, cal_connection_info* ci, bool h
|
|||||||
intColVal = row.getUintField<8>(s);
|
intColVal = row.getUintField<8>(s);
|
||||||
memcpy(tmp, &intColVal, 8);
|
memcpy(tmp, &intColVal, 8);
|
||||||
tmp[8] = 0;
|
tmp[8] = 0;
|
||||||
f2->store(tmp, strlen(tmp), f2->charset());
|
(*f)->store(tmp, strlen(tmp), (*f)->charset());
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
f2->store((const char*)row.getStringPointer(s), row.getStringLength(s), f2->charset());
|
(*f)->store((const char*)row.getStringPointer(s), row.getStringLength(s), (*f)->charset());
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((*f)->null_ptr)
|
if ((*f)->null_ptr)
|
||||||
@ -660,8 +637,6 @@ int fetchNextRow(uchar* buf, cal_table_info& ti, cal_connection_info* ci, bool h
|
|||||||
|
|
||||||
case CalpontSystemCatalog::VARBINARY:
|
case CalpontSystemCatalog::VARBINARY:
|
||||||
{
|
{
|
||||||
Field_varstring* f2 = (Field_varstring*)*f;
|
|
||||||
|
|
||||||
if (get_varbin_always_hex(current_thd))
|
if (get_varbin_always_hex(current_thd))
|
||||||
{
|
{
|
||||||
uint32_t l;
|
uint32_t l;
|
||||||
@ -669,10 +644,10 @@ int fetchNextRow(uchar* buf, cal_table_info& ti, cal_connection_info* ci, bool h
|
|||||||
uint32_t ll = l * 2;
|
uint32_t ll = l * 2;
|
||||||
boost::scoped_array<char> sca(new char[ll]);
|
boost::scoped_array<char> sca(new char[ll]);
|
||||||
vbin2hex(p, l, sca.get());
|
vbin2hex(p, l, sca.get());
|
||||||
f2->store(sca.get(), ll, f2->charset());
|
(*f)->store(sca.get(), ll, (*f)->charset());
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
f2->store((const char*)row.getVarBinaryField(s), row.getVarBinaryLength(s), f2->charset());
|
(*f)->store((const char*)row.getVarBinaryField(s), row.getVarBinaryLength(s), (*f)->charset());
|
||||||
|
|
||||||
if ((*f)->null_ptr)
|
if ((*f)->null_ptr)
|
||||||
*(*f)->null_ptr &= ~(*f)->null_bit;
|
*(*f)->null_ptr &= ~(*f)->null_bit;
|
||||||
@ -748,13 +723,11 @@ int fetchNextRow(uchar* buf, cal_table_info& ti, cal_connection_info* ci, bool h
|
|||||||
if (dl == std::numeric_limits<float>::infinity())
|
if (dl == std::numeric_limits<float>::infinity())
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
Field_float* f2 = (Field_float*)*f;
|
|
||||||
// bug 3485, reserve enough space for the longest float value
|
// bug 3485, reserve enough space for the longest float value
|
||||||
// -3.402823466E+38 to -1.175494351E-38, 0, and
|
// -3.402823466E+38 to -1.175494351E-38, 0, and
|
||||||
// 1.175494351E-38 to 3.402823466E+38.
|
// 1.175494351E-38 to 3.402823466E+38.
|
||||||
(*f)->field_length = 40;
|
(*f)->field_length = 40;
|
||||||
|
(*f)->store(dl);
|
||||||
f2->store(dl);
|
|
||||||
|
|
||||||
if ((*f)->null_ptr)
|
if ((*f)->null_ptr)
|
||||||
*(*f)->null_ptr &= ~(*f)->null_bit;
|
*(*f)->null_ptr &= ~(*f)->null_bit;
|
||||||
@ -781,11 +754,11 @@ int fetchNextRow(uchar* buf, cal_table_info& ti, cal_connection_info* ci, bool h
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
// The server converts dl=-0 to dl=0 in f2->store().
|
// The server converts dl=-0 to dl=0 in (*f)->store().
|
||||||
// This happens in the call to truncate_double().
|
// This happens in the call to truncate_double().
|
||||||
// This is an unexpected behaviour, so we directly store the
|
// This is an unexpected behaviour, so we directly store the
|
||||||
// double value using the lower level float8store() function.
|
// double value using the lower level float8store() function.
|
||||||
// TODO Remove this when f2->store() handles this properly.
|
// TODO Remove this when (*f)->store() handles this properly.
|
||||||
(*f)->field_length = 310;
|
(*f)->field_length = 310;
|
||||||
if (dl == 0)
|
if (dl == 0)
|
||||||
float8store((*f)->ptr,dl);
|
float8store((*f)->ptr,dl);
|
||||||
|
@ -143,8 +143,10 @@ int64_t Func_ceil::getIntVal(Row& row,
|
|||||||
|
|
||||||
case CalpontSystemCatalog::DATE:
|
case CalpontSystemCatalog::DATE:
|
||||||
{
|
{
|
||||||
|
// For some reason, MDB doesn't return this as a date,
|
||||||
|
// but datetime is returned as a datetime. Expect
|
||||||
|
// this to change in the future.
|
||||||
Date d (parm[0]->data()->getDateIntVal(row, isNull));
|
Date d (parm[0]->data()->getDateIntVal(row, isNull));
|
||||||
|
|
||||||
if (!isNull)
|
if (!isNull)
|
||||||
ret = d.convertToMySQLint();
|
ret = d.convertToMySQLint();
|
||||||
}
|
}
|
||||||
@ -152,28 +154,19 @@ int64_t Func_ceil::getIntVal(Row& row,
|
|||||||
|
|
||||||
case CalpontSystemCatalog::DATETIME:
|
case CalpontSystemCatalog::DATETIME:
|
||||||
{
|
{
|
||||||
DateTime dt(parm[0]->data()->getDatetimeIntVal(row, isNull));
|
ret = parm[0]->data()->getDatetimeIntVal(row, isNull);
|
||||||
|
|
||||||
if (!isNull)
|
|
||||||
ret = dt.convertToMySQLint();
|
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case CalpontSystemCatalog::TIMESTAMP:
|
case CalpontSystemCatalog::TIMESTAMP:
|
||||||
{
|
{
|
||||||
TimeStamp dt(parm[0]->data()->getTimestampIntVal(row, isNull));
|
ret = parm[0]->data()->getTimestampIntVal(row, isNull);
|
||||||
|
|
||||||
if (!isNull)
|
|
||||||
ret = dt.convertToMySQLint(timeZone());
|
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case CalpontSystemCatalog::TIME:
|
case CalpontSystemCatalog::TIME:
|
||||||
{
|
{
|
||||||
Time dt(parm[0]->data()->getTimeIntVal(row, isNull));
|
ret = parm[0]->data()->getTimeIntVal(row, isNull);
|
||||||
|
|
||||||
if (!isNull)
|
|
||||||
ret = dt.convertToMySQLint();
|
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
@ -248,8 +241,10 @@ uint64_t Func_ceil::getUintVal(Row& row,
|
|||||||
|
|
||||||
case CalpontSystemCatalog::DATE:
|
case CalpontSystemCatalog::DATE:
|
||||||
{
|
{
|
||||||
|
// For some reason, MDB doesn't return this as a date,
|
||||||
|
// but datetime is returned as a datetime. Expect
|
||||||
|
// this to change in the future.
|
||||||
Date d (parm[0]->data()->getDateIntVal(row, isNull));
|
Date d (parm[0]->data()->getDateIntVal(row, isNull));
|
||||||
|
|
||||||
if (!isNull)
|
if (!isNull)
|
||||||
ret = d.convertToMySQLint();
|
ret = d.convertToMySQLint();
|
||||||
}
|
}
|
||||||
@ -257,28 +252,19 @@ uint64_t Func_ceil::getUintVal(Row& row,
|
|||||||
|
|
||||||
case CalpontSystemCatalog::DATETIME:
|
case CalpontSystemCatalog::DATETIME:
|
||||||
{
|
{
|
||||||
DateTime dt(parm[0]->data()->getDatetimeIntVal(row, isNull));
|
ret = parm[0]->data()->getDatetimeIntVal(row, isNull);
|
||||||
|
|
||||||
if (!isNull)
|
|
||||||
ret = dt.convertToMySQLint();
|
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case CalpontSystemCatalog::TIMESTAMP:
|
case CalpontSystemCatalog::TIMESTAMP:
|
||||||
{
|
{
|
||||||
TimeStamp dt(parm[0]->data()->getTimestampIntVal(row, isNull));
|
ret = parm[0]->data()->getTimestampIntVal(row, isNull);
|
||||||
|
|
||||||
if (!isNull)
|
|
||||||
ret = dt.convertToMySQLint(timeZone());
|
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case CalpontSystemCatalog::TIME:
|
case CalpontSystemCatalog::TIME:
|
||||||
{
|
{
|
||||||
Time dt(parm[0]->data()->getTimeIntVal(row, isNull));
|
ret = parm[0]->data()->getTimeIntVal(row, isNull);
|
||||||
|
|
||||||
if (!isNull)
|
|
||||||
ret = dt.convertToMySQLint();
|
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user