You've already forked mariadb-columnstore-engine
mirror of
https://github.com/mariadb-corporation/mariadb-columnstore-engine.git
synced 2025-07-30 19:23:07 +03:00
MCOL-392 Apply astyle
Make this branch apply our style guidelines
This commit is contained in:
@ -1020,10 +1020,11 @@ bool mysql_str_to_time( const string& input, Time& output )
|
||||
{
|
||||
output.reset();
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
output.hour = isNeg ? 0-hour : hour;
|
||||
output.hour = isNeg ? 0 - hour : hour;
|
||||
output.minute = min;
|
||||
output.second = sec;
|
||||
output.msecond = usec;
|
||||
@ -1416,7 +1417,7 @@ DataConvert::convertColumnData(const CalpontSystemCatalog::ColType& colType,
|
||||
|
||||
if (stringToTimeStruct(data, aTime))
|
||||
{
|
||||
value = (int64_t) *(reinterpret_cast<int64_t*>(&aTime));
|
||||
value = (int64_t) * (reinterpret_cast<int64_t*>(&aTime));
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -1918,6 +1919,7 @@ int64_t DataConvert::convertColumnTime(
|
||||
inSecond = 0;
|
||||
inMicrosecond = 0;
|
||||
bool isNeg = false;
|
||||
|
||||
if ( datetimeFormat != CALPONTTIME_ENUM )
|
||||
{
|
||||
status = -1;
|
||||
@ -1941,6 +1943,7 @@ int64_t DataConvert::convertColumnTime(
|
||||
}
|
||||
|
||||
p = strtok_r(NULL, ":.", &savePoint);
|
||||
|
||||
if (p == NULL)
|
||||
{
|
||||
status = -1;
|
||||
@ -1976,6 +1979,7 @@ int64_t DataConvert::convertColumnTime(
|
||||
if (p != NULL)
|
||||
{
|
||||
inMicrosecond = strtol(p, 0, 10);
|
||||
|
||||
if (errno)
|
||||
{
|
||||
status = -1;
|
||||
@ -2017,6 +2021,7 @@ int64_t DataConvert::convertColumnTime(
|
||||
atime.is_neg = false;
|
||||
memcpy( &value, &atime, 8);
|
||||
}
|
||||
|
||||
// If neither of the above match then we return a 0 time
|
||||
|
||||
status = -1;
|
||||
@ -2067,21 +2072,25 @@ std::string DataConvert::datetimeToString( long long datetimevalue, long decima
|
||||
{
|
||||
decimals = 0;
|
||||
}
|
||||
|
||||
// @bug 4703 abandon multiple ostringstream's for conversion
|
||||
DateTime dt(datetimevalue);
|
||||
const int DATETIMETOSTRING_LEN = 28; // YYYY-MM-DD HH:MM:SS.mmmmmm\0
|
||||
char buf[DATETIMETOSTRING_LEN];
|
||||
|
||||
sprintf(buf, "%04d-%02d-%02d %02d:%02d:%02d", dt.year, dt.month, dt.day, dt.hour, dt.minute, dt.second);
|
||||
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
return buf;
|
||||
}
|
||||
|
||||
@ -2092,6 +2101,7 @@ std::string DataConvert::timeToString( long long timevalue, long decimals )
|
||||
{
|
||||
decimals = 0;
|
||||
}
|
||||
|
||||
// @bug 4703 abandon multiple ostringstream's for conversion
|
||||
Time dt(timevalue);
|
||||
const int TIMETOSTRING_LEN = 19; // (-H)HH:MM:SS.mmmmmm\0
|
||||
@ -2105,16 +2115,19 @@ std::string DataConvert::timeToString( long long timevalue, long decimals )
|
||||
}
|
||||
|
||||
sprintf(outbuf, "%02d:%02d:%02d", dt.hour, dt.minute, dt.second);
|
||||
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
return buf;
|
||||
}
|
||||
|
||||
|
@ -277,6 +277,7 @@ inline uint32_t getDaysInMonth(uint32_t month, int year)
|
||||
return 0;
|
||||
|
||||
uint32_t days = daysInMonth[month - 1];
|
||||
|
||||
if ((month == 2) && isLeapYear(year))
|
||||
days++;
|
||||
|
||||
@ -567,11 +568,14 @@ inline void DataConvert::datetimeToString( long long datetimevalue, char* buf, u
|
||||
{
|
||||
decimals = 0;
|
||||
}
|
||||
|
||||
int msec = 0;
|
||||
|
||||
if ((datetimevalue & 0xfffff) > 0)
|
||||
{
|
||||
msec = (unsigned)((datetimevalue) & 0xfffff);
|
||||
}
|
||||
|
||||
snprintf( buf, buflen, "%04d-%02d-%02d %02d:%02d:%02d",
|
||||
(unsigned)((datetimevalue >> 48) & 0xffff),
|
||||
(unsigned)((datetimevalue >> 44) & 0xf),
|
||||
@ -585,6 +589,7 @@ inline void DataConvert::datetimeToString( long long datetimevalue, char* buf, u
|
||||
{
|
||||
size_t start = strlen(buf);
|
||||
snprintf(buf + strlen(buf), buflen - start, ".%d", msec);
|
||||
|
||||
// Pad end with zeros
|
||||
if (strlen(buf) - start < (size_t)decimals)
|
||||
{
|
||||
@ -600,8 +605,10 @@ inline void DataConvert::timeToString( long long timevalue, char* buf, unsigned
|
||||
{
|
||||
decimals = 0;
|
||||
}
|
||||
|
||||
// Handle negative correctly
|
||||
int hour = 0, msec = 0;
|
||||
|
||||
if ((timevalue >> 40) & 0x800)
|
||||
{
|
||||
hour = 0xfffff000;
|
||||
@ -613,12 +620,14 @@ inline void DataConvert::timeToString( long long timevalue, char* buf, unsigned
|
||||
{
|
||||
msec = (unsigned)((timevalue) & 0xffffff);
|
||||
}
|
||||
|
||||
if ((hour >= 0) && (timevalue >> 63))
|
||||
{
|
||||
buf[0] = '-';
|
||||
buf++;
|
||||
buflen--;
|
||||
}
|
||||
|
||||
snprintf( buf, buflen, "%02d:%02d:%02d",
|
||||
hour,
|
||||
(unsigned)((timevalue >> 32) & 0xff),
|
||||
@ -629,6 +638,7 @@ inline void DataConvert::timeToString( long long timevalue, char* buf, unsigned
|
||||
{
|
||||
size_t start = strlen(buf);
|
||||
snprintf(buf + strlen(buf), buflen - start, ".%d", msec);
|
||||
|
||||
// Pad end with zeros
|
||||
if (strlen(buf) - start < (size_t)decimals)
|
||||
{
|
||||
@ -662,6 +672,7 @@ inline void DataConvert::timeToString1( long long timevalue, char* buf, unsigned
|
||||
{
|
||||
// Handle negative correctly
|
||||
int hour = 0;
|
||||
|
||||
if ((timevalue >> 40) & 0x800)
|
||||
{
|
||||
hour = 0xfffff000;
|
||||
|
Reference in New Issue
Block a user