diff --git a/dbcon/mysql/ha_mcs_impl.cpp b/dbcon/mysql/ha_mcs_impl.cpp index 29884004e..7cd602f9d 100644 --- a/dbcon/mysql/ha_mcs_impl.cpp +++ b/dbcon/mysql/ha_mcs_impl.cpp @@ -260,8 +260,6 @@ void storeNumericField(Field** f, int64_t value, CalpontSystemCatalog::ColType& { 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 // to create vtable limitation. //if (f2->dec < ct.scale) @@ -269,7 +267,7 @@ void storeNumericField(Field** f, int64_t value, CalpontSystemCatalog::ColType& char buf[256]; 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; } @@ -277,7 +275,7 @@ void storeNumericField(Field** f, int64_t value, CalpontSystemCatalog::ColType& { Field_tiny* f2 = (Field_tiny*)*f; longlong int_val = (longlong)value; - f2->store(int_val, f2->unsigned_flag); + (*f)->store(int_val, f2->unsigned_flag); break; } @@ -285,7 +283,7 @@ void storeNumericField(Field** f, int64_t value, CalpontSystemCatalog::ColType& { Field_short* f2 = (Field_short*)*f; longlong int_val = (longlong)value; - f2->store(int_val, f2->unsigned_flag); + (*f)->store(int_val, f2->unsigned_flag); break; } @@ -293,7 +291,7 @@ void storeNumericField(Field** f, int64_t value, CalpontSystemCatalog::ColType& { Field_medium* f2 = (Field_medium*)*f; longlong int_val = (longlong)value; - f2->store(int_val, f2->unsigned_flag); + (*f)->store(int_val, f2->unsigned_flag); break; } @@ -301,7 +299,7 @@ void storeNumericField(Field** f, int64_t value, CalpontSystemCatalog::ColType& { Field_long* f2 = (Field_long*)*f; longlong int_val = (longlong)value; - f2->store(int_val, f2->unsigned_flag); + (*f)->store(int_val, f2->unsigned_flag); break; } @@ -309,37 +307,33 @@ void storeNumericField(Field** f, int64_t value, CalpontSystemCatalog::ColType& { Field_longlong* f2 = (Field_longlong*)*f; longlong int_val = (longlong)value; - f2->store(int_val, f2->unsigned_flag); + (*f)->store(int_val, f2->unsigned_flag); break; } case MYSQL_TYPE_FLOAT: // FLOAT type { - Field_float* f2 = (Field_float*)*f; float float_val = *(float*)(&value); - f2->store(float_val); + (*f)->store(float_val); break; } case MYSQL_TYPE_DOUBLE: // DOUBLE type { - Field_double* f2 = (Field_double*)*f; double double_val = *(double*)(&value); - f2->store(double_val); + (*f)->store(double_val); break; } case MYSQL_TYPE_VARCHAR: { - Field_varstring* f2 = (Field_varstring*)*f; char tmp[25]; - if (ct.colDataType == CalpontSystemCatalog::DECIMAL) dataconvert::DataConvert::decimalToString(value, (unsigned)ct.scale, tmp, 25, ct.colDataType); else snprintf(tmp, 25, "%lld", (long long)value); - f2->store(tmp, strlen(tmp), f2->charset()); + (*f)->store(tmp, strlen(tmp), (*f)->charset()); break; } @@ -347,7 +341,7 @@ void storeNumericField(Field** f, int64_t value, CalpontSystemCatalog::ColType& { Field_longlong* f2 = (Field_longlong*)*f; longlong int_val = (longlong)value; - f2->store(int_val, f2->unsigned_flag); + (*f)->store(int_val, f2->unsigned_flag); 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::VARBINARY) { - Field_varstring* f2 = (Field_varstring*)*f; - f2->store(tmp, 0, f2->charset()); + (*f)->store(tmp, 0, (*f)->charset()); } continue; @@ -567,8 +560,7 @@ int fetchNextRow(uchar* buf, cal_table_info& ti, cal_connection_info* ci, bool h intColVal = row.getUintField<4>(s); DataConvert::dateToString(intColVal, tmp, 255); - Field_varstring* f2 = (Field_varstring*)*f; - f2->store(tmp, strlen(tmp), f2->charset()); + (*f)->store(tmp, strlen(tmp), (*f)->charset()); break; } @@ -579,16 +571,7 @@ int fetchNextRow(uchar* buf, cal_table_info& ti, cal_connection_info* ci, bool h intColVal = row.getUintField<8>(s); DataConvert::datetimeToString(intColVal, tmp, 255, colType.precision); - - /* 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()); + (*f)->store(tmp, strlen(tmp), (*f)->charset()); break; } @@ -599,9 +582,7 @@ int fetchNextRow(uchar* buf, cal_table_info& ti, cal_connection_info* ci, bool h intColVal = row.getUintField<8>(s); DataConvert::timeToString(intColVal, tmp, 255, colType.precision); - - Field_varstring* f2 = (Field_varstring*)*f; - f2->store(tmp, strlen(tmp), f2->charset()); + (*f)->store(tmp, strlen(tmp), (*f)->charset()); break; } @@ -612,32 +593,28 @@ int fetchNextRow(uchar* buf, cal_table_info& ti, cal_connection_info* ci, bool h intColVal = row.getUintField<8>(s); DataConvert::timestampToString(intColVal, tmp, 255, current_thd->variables.time_zone->get_name()->ptr(), colType.precision); - - Field_varstring* f2 = (Field_varstring*)*f; - f2->store(tmp, strlen(tmp), f2->charset()); + (*f)->store(tmp, strlen(tmp), (*f)->charset()); break; } case CalpontSystemCatalog::CHAR: case CalpontSystemCatalog::VARCHAR: { - Field_varstring* f2 = (Field_varstring*)*f; - switch (colType.colWidth) { case 1: intColVal = row.getUintField<1>(s); - f2->store((char*)(&intColVal), strlen((char*)(&intColVal)), f2->charset()); + (*f)->store((char*)(&intColVal), strlen((char*)(&intColVal)), (*f)->charset()); break; case 2: intColVal = row.getUintField<2>(s); - f2->store((char*)(&intColVal), strlen((char*)(&intColVal)), f2->charset()); + (*f)->store((char*)(&intColVal), strlen((char*)(&intColVal)), (*f)->charset()); break; case 4: intColVal = row.getUintField<4>(s); - f2->store((char*)(&intColVal), strlen((char*)(&intColVal)), f2->charset()); + (*f)->store((char*)(&intColVal), strlen((char*)(&intColVal)), (*f)->charset()); break; 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); memcpy(tmp, &intColVal, 8); tmp[8] = 0; - f2->store(tmp, strlen(tmp), f2->charset()); + (*f)->store(tmp, strlen(tmp), (*f)->charset()); break; 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) @@ -660,8 +637,6 @@ int fetchNextRow(uchar* buf, cal_table_info& ti, cal_connection_info* ci, bool h case CalpontSystemCatalog::VARBINARY: { - Field_varstring* f2 = (Field_varstring*)*f; - if (get_varbin_always_hex(current_thd)) { 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; boost::scoped_array sca(new char[ll]); vbin2hex(p, l, sca.get()); - f2->store(sca.get(), ll, f2->charset()); + (*f)->store(sca.get(), ll, (*f)->charset()); } 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) *(*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::infinity()) continue; - Field_float* f2 = (Field_float*)*f; // bug 3485, reserve enough space for the longest float value // -3.402823466E+38 to -1.175494351E-38, 0, and // 1.175494351E-38 to 3.402823466E+38. (*f)->field_length = 40; - - f2->store(dl); + (*f)->store(dl); if ((*f)->null_ptr) *(*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 { - // 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 is an unexpected behaviour, so we directly store the // 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; if (dl == 0) float8store((*f)->ptr,dl); diff --git a/utils/funcexp/func_ceil.cpp b/utils/funcexp/func_ceil.cpp index f9f9c1891..967989c74 100644 --- a/utils/funcexp/func_ceil.cpp +++ b/utils/funcexp/func_ceil.cpp @@ -143,8 +143,10 @@ int64_t Func_ceil::getIntVal(Row& row, 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)); - if (!isNull) ret = d.convertToMySQLint(); } @@ -152,28 +154,19 @@ int64_t Func_ceil::getIntVal(Row& row, case CalpontSystemCatalog::DATETIME: { - DateTime dt(parm[0]->data()->getDatetimeIntVal(row, isNull)); - - if (!isNull) - ret = dt.convertToMySQLint(); + ret = parm[0]->data()->getDatetimeIntVal(row, isNull); } break; case CalpontSystemCatalog::TIMESTAMP: { - TimeStamp dt(parm[0]->data()->getTimestampIntVal(row, isNull)); - - if (!isNull) - ret = dt.convertToMySQLint(timeZone()); + ret = parm[0]->data()->getTimestampIntVal(row, isNull); } break; case CalpontSystemCatalog::TIME: { - Time dt(parm[0]->data()->getTimeIntVal(row, isNull)); - - if (!isNull) - ret = dt.convertToMySQLint(); + ret = parm[0]->data()->getTimeIntVal(row, isNull); } break; @@ -248,8 +241,10 @@ uint64_t Func_ceil::getUintVal(Row& row, 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)); - if (!isNull) ret = d.convertToMySQLint(); } @@ -257,28 +252,19 @@ uint64_t Func_ceil::getUintVal(Row& row, case CalpontSystemCatalog::DATETIME: { - DateTime dt(parm[0]->data()->getDatetimeIntVal(row, isNull)); - - if (!isNull) - ret = dt.convertToMySQLint(); + ret = parm[0]->data()->getDatetimeIntVal(row, isNull); } break; case CalpontSystemCatalog::TIMESTAMP: { - TimeStamp dt(parm[0]->data()->getTimestampIntVal(row, isNull)); - - if (!isNull) - ret = dt.convertToMySQLint(timeZone()); + ret = parm[0]->data()->getTimestampIntVal(row, isNull); } break; case CalpontSystemCatalog::TIME: { - Time dt(parm[0]->data()->getTimeIntVal(row, isNull)); - - if (!isNull) - ret = dt.convertToMySQLint(); + ret = parm[0]->data()->getTimeIntVal(row, isNull); } break;