1
0
mirror of https://github.com/mariadb-corporation/mariadb-columnstore-engine.git synced 2025-07-30 19:23:07 +03:00

MCOL-537, cleanup compiler warnings. Checkpointing a bunch of fixes.

Work in progress...
This commit is contained in:
Patrick LeBlanc
2018-11-19 13:19:15 -06:00
committed by Roman Nozdrin
parent f4f053dd8c
commit cbbf267e88
24 changed files with 85 additions and 159 deletions

View File

@ -83,19 +83,6 @@ bool from_string(T& t, const std::string& s, std::ios_base & (*f)(std::ios_base&
return !(iss >> f >> t).fail();
}
uint64_t pow10_(int32_t scale)
{
if (scale <= 0) return 1;
idbassert(scale < 20);
uint64_t res = 1;
for (int32_t i = 0; i < scale; i++)
res *= 10;
return res;
}
bool number_value ( const string& data )
{
for (unsigned int i = 0; i < strlen(data.c_str()); i++)
@ -872,7 +859,6 @@ bool mysql_str_to_datetime( const string& input, DateTime& output, bool& isDate
bool mysql_str_to_time( const string& input, Time& output, long decimals )
{
// int32_t datesepct = 0;
uint32_t dtend = 0;
bool isNeg = false;
@ -2157,7 +2143,8 @@ std::string DataConvert::datetimeToString1( long long datetimevalue )
{
// @bug 4703 abandon multiple ostringstream's for conversion
DateTime dt(datetimevalue);
const int DATETIMETOSTRING1_LEN = 22; // YYYYMMDDHHMMSSmmmmmm\0
// Interesting, gcc 7 says the sprintf below generates between 21 and 23 bytes of output.
const int DATETIMETOSTRING1_LEN = 23; // YYYYMMDDHHMMSSmmmmmm\0
char buf[DATETIMETOSTRING1_LEN];
sprintf(buf, "%04d%02d%02d%02d%02d%02d%06d", dt.year, dt.month, dt.day, dt.hour, dt.minute, dt.second, dt.msecond);
@ -2422,11 +2409,10 @@ int64_t DataConvert::stringToDatetime(const string& data, bool* date)
return -1;
}
/* This is really painful and expensive b/c it seems the input is not normalized or
sanitized. That should really be done on ingestion. */
int64_t DataConvert::intToDate(int64_t data)
{
//char buf[10] = {0};
//snprintf( buf, 10, "%llu", (long long unsigned int)data);
//string date = buf;
char buf[21] = {0};
Date aday;
@ -2438,7 +2424,11 @@ int64_t DataConvert::intToDate(int64_t data)
return *(reinterpret_cast<uint32_t*>(&aday));
}
// this snprintf call causes a compiler warning b/c we're potentially copying a 20-digit #
// into 15 bytes, however, that appears to be intentional.
#pragma GCC diagnostic ignored "-Wformat-truncation="
snprintf( buf, 15, "%llu", (long long unsigned int)data);
#pragma GCC diagnostic pop
string year, month, day, hour, min, sec, msec;
int64_t y = 0, m = 0, d = 0, h = 0, minute = 0, s = 0, ms = 0;
@ -2541,6 +2531,8 @@ int64_t DataConvert::intToDate(int64_t data)
return *(reinterpret_cast<uint32_t*>(&aday));
}
/* This is really painful and expensive b/c it seems the input is not normalized or
sanitized. That should really be done on ingestion. */
int64_t DataConvert::intToDatetime(int64_t data, bool* date)
{
bool isDate = false;
@ -2563,7 +2555,12 @@ int64_t DataConvert::intToDatetime(int64_t data, bool* date)
return *(reinterpret_cast<uint64_t*>(&adaytime));
}
// this snprintf call causes a compiler warning b/c we're potentially copying a 20-digit #
// into 15 bytes, however, that appears to be intentional.
#pragma GCC diagnostic ignored "-Wformat-truncation="
snprintf( buf, 15, "%llu", (long long unsigned int)data);
#pragma GCC diagnostic pop
//string date = buf;
string year, month, day, hour, min, sec, msec;
int64_t y = 0, m = 0, d = 0, h = 0, minute = 0, s = 0, ms = 0;
@ -2671,6 +2668,8 @@ int64_t DataConvert::intToDatetime(int64_t data, bool* date)
return *(reinterpret_cast<uint64_t*>(&adaytime));
}
/* This is really painful and expensive b/c it seems the input is not normalized or
sanitized. That should really be done on ingestion. */
int64_t DataConvert::intToTime(int64_t data, bool fromString)
{
char buf[21] = {0};
@ -2689,7 +2688,12 @@ int64_t DataConvert::intToTime(int64_t data, bool fromString)
return *(reinterpret_cast<int64_t*>(&atime));
}
// this snprintf call causes a compiler warning b/c we're potentially copying a 20-digit #
// into 15 bytes, however, that appears to be intentional.
#pragma GCC diagnostic ignored "-Wformat-truncation="
snprintf( buf, 15, "%llu", (long long unsigned int)data);
#pragma GCC diagnostic pop
//string date = buf;
string hour, min, sec, msec;
int64_t h = 0, minute = 0, s = 0, ms = 0;