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-1427 Fix microsecond padding for display
We were padding from right, we needed to pad from left.
This commit is contained in:
@ -582,7 +582,7 @@ int fetchNextRow(uchar* buf, cal_table_info& ti, cal_connection_info* ci, bool h
|
||||
*(*f)->null_ptr &= ~(*f)->null_bit;
|
||||
|
||||
intColVal = row.getUintField<8>(s);
|
||||
DataConvert::datetimeToString(intColVal, tmp, 255);
|
||||
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.
|
||||
@ -606,7 +606,7 @@ int fetchNextRow(uchar* buf, cal_table_info& ti, cal_connection_info* ci, bool h
|
||||
*(*f)->null_ptr &= ~(*f)->null_bit;
|
||||
|
||||
intColVal = row.getUintField<8>(s);
|
||||
DataConvert::timeToString(intColVal, tmp, 255);
|
||||
DataConvert::timeToString(intColVal, tmp, 255, colType.precision);
|
||||
|
||||
Field_varstring* f2 = (Field_varstring*)*f;
|
||||
f2->store(tmp, strlen(tmp), f2->charset());
|
||||
|
@ -2082,13 +2082,8 @@ std::string DataConvert::datetimeToString( long long datetimevalue, long decima
|
||||
|
||||
if (dt.msecond && decimals)
|
||||
{
|
||||
snprintf(buf + strlen(buf), 21 + decimals, ".%d", dt.msecond);
|
||||
|
||||
// Pad end with zeros
|
||||
if (strlen(buf) < (size_t)(21 + decimals))
|
||||
{
|
||||
sprintf(buf + strlen(buf), "%0*d", (int)(21 + decimals - strlen(buf)), 0);
|
||||
}
|
||||
// Pad start with zeros
|
||||
sprintf(buf + strlen(buf), ".%0*d", (int)decimals, dt.msecond);
|
||||
}
|
||||
|
||||
return buf;
|
||||
@ -2118,14 +2113,8 @@ std::string DataConvert::timeToString( long long timevalue, long decimals )
|
||||
|
||||
if (dt.msecond && decimals)
|
||||
{
|
||||
size_t start = strlen(buf);
|
||||
snprintf(buf + strlen(buf), 12 + decimals, ".%d", dt.msecond);
|
||||
|
||||
// Pad end with zeros
|
||||
if (strlen(buf) - start < (size_t)decimals)
|
||||
{
|
||||
sprintf(buf + strlen(buf), "%0*d", (int)(decimals - (strlen(buf) - start) + 1), 0);
|
||||
}
|
||||
// Pad start with zeros
|
||||
sprintf(buf + strlen(buf), ".%0*d", (int)decimals, dt.msecond);
|
||||
}
|
||||
|
||||
return buf;
|
||||
|
@ -587,14 +587,7 @@ inline void DataConvert::datetimeToString( long long datetimevalue, char* buf, u
|
||||
|
||||
if (msec || decimals)
|
||||
{
|
||||
size_t start = strlen(buf);
|
||||
snprintf(buf + strlen(buf), buflen - start, ".%d", msec);
|
||||
|
||||
// Pad end with zeros
|
||||
if (strlen(buf) - start < (size_t)decimals)
|
||||
{
|
||||
snprintf(buf + strlen(buf), buflen - strlen(buf), "%0*d", (int)(decimals - (strlen(buf) - start) + 1), 0);
|
||||
}
|
||||
snprintf(buf + strlen(buf), buflen - strlen(buf), ".%0*d", (int)decimals, msec);
|
||||
}
|
||||
}
|
||||
|
||||
@ -636,14 +629,8 @@ inline void DataConvert::timeToString( long long timevalue, char* buf, unsigned
|
||||
|
||||
if (msec || decimals)
|
||||
{
|
||||
size_t start = strlen(buf);
|
||||
snprintf(buf + strlen(buf), buflen - start, ".%d", msec);
|
||||
|
||||
// Pad end with zeros
|
||||
if (strlen(buf) - start < (size_t)decimals)
|
||||
{
|
||||
snprintf(buf + strlen(buf), buflen - strlen(buf), "%0*d", (int)(decimals - (strlen(buf) - start) + 1), 0);
|
||||
}
|
||||
// Pad start with zeros
|
||||
snprintf(buf + strlen(buf), buflen - strlen(buf), ".%0*d", (int)decimals, msec);
|
||||
}
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user