1
0
mirror of https://github.com/mariadb-corporation/mariadb-columnstore-engine.git synced 2025-08-01 06:46:55 +03:00

MCOL-392 Fix negative time handling

This commit is contained in:
Andrew Hutchings
2018-04-26 14:28:17 +01:00
parent 3c1ebd8b94
commit edb2e2f36d
4 changed files with 44 additions and 9 deletions

View File

@ -566,10 +566,19 @@ inline void DataConvert::datetimeToString( long long datetimevalue, char* buf, u
inline void DataConvert::timeToString( long long timevalue, char* buf, unsigned int buflen )
{
// Handle negative correctly
int hour = 0;
if ((timevalue >> 40) & 0xf00)
{
hour = 0xfffff000;
}
hour |= ((timevalue >> 40) & 0xfff);
if ((timevalue & 0xffffff) > 0)
{
snprintf( buf, buflen, "%02d:%02d:%02d.%d",
(unsigned)((timevalue >> 40) & 0xfff),
hour,
(unsigned)((timevalue >> 32) & 0xff),
(unsigned)((timevalue >> 24) & 0xff),
(unsigned)((timevalue) & 0xffffff)
@ -578,7 +587,7 @@ inline void DataConvert::timeToString( long long timevalue, char* buf, unsigned
else
{
snprintf( buf, buflen, "%02d:%02d:%02d",
(unsigned)((timevalue >> 40) & 0xfff),
hour,
(unsigned)((timevalue >> 32) & 0xff),
(unsigned)((timevalue >> 24) & 0xff)
);
@ -608,8 +617,17 @@ inline void DataConvert::datetimeToString1( long long datetimevalue, char* buf,
inline void DataConvert::timeToString1( long long timevalue, char* buf, unsigned int buflen )
{
// Handle negative correctly
int hour = 0;
if ((timevalue >> 40) & 0xf00)
{
hour = 0xfffff000;
}
hour |= ((timevalue >> 40) & 0xfff);
snprintf( buf, buflen, "%02d%02d%02d",
(unsigned)((timevalue >> 40) & 0xfff),
hour,
(unsigned)((timevalue >> 32) & 0xff),
(unsigned)((timevalue >> 14) & 0xff)
);