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

MCOL-43 - Function Join Fails. Added support for MYSQL_TYPE_DATETIME2

This commit is contained in:
David Hall
2016-05-16 15:39:38 -05:00
parent e1b63c4f9e
commit e28242a885
2 changed files with 39 additions and 16 deletions

View File

@ -132,7 +132,8 @@ int buildBuffer(uchar* buf, string& buffer, int& columns, TABLE* table)
(*field)->type() == MYSQL_TYPE_VAR_STRING ||
(*field)->type() == MYSQL_TYPE_STRING ||
(*field)->type() == MYSQL_TYPE_DATE ||
(*field)->type() == MYSQL_TYPE_DATETIME )
(*field)->type() == MYSQL_TYPE_DATETIME ||
(*field)->type() == MYSQL_TYPE_DATETIME2 )
vals.append("'");
while (ptr < end_ptr)
{
@ -159,7 +160,8 @@ int buildBuffer(uchar* buf, string& buffer, int& columns, TABLE* table)
(*field)->type() == MYSQL_TYPE_VAR_STRING ||
(*field)->type() == MYSQL_TYPE_STRING ||
(*field)->type() == MYSQL_TYPE_DATE ||
(*field)->type() == MYSQL_TYPE_DATETIME )
(*field)->type() == MYSQL_TYPE_DATETIME ||
(*field)->type() == MYSQL_TYPE_DATETIME2 )
vals.append("'");
}
}
@ -768,23 +770,39 @@ int ha_calpont_impl_write_batch_row_(uchar *buf, TABLE* table, cal_impl_if::cal_
if (nullVal && (ci.columnTypes[colpos].constraintType != CalpontSystemCatalog::NOTNULL_CONSTRAINT))
{
fprintf(ci.filePtr, "%c", ci.delimiter);
buf += 8;
}
else
{
long long value = *((long long*) buf);
long datePart = (long) (value/1000000ll);
int day = datePart % 100;
int month = (datePart/100) % 100;
int year = datePart/10000;
fprintf(ci.filePtr, "%04d-%02d-%02d ", year,month,day);
if (table->field[colpos]->real_type() == MYSQL_TYPE_DATETIME2)
{
// mariadb 10.1 compatibility -- MYSQL_TYPE_DATETIME2 introduced in mysql 5.6
MYSQL_TIME ltime;
const uchar *pos = buf;
longlong tmp= my_datetime_packed_from_binary(pos, 0);
TIME_from_longlong_datetime_packed(&ltime, tmp);
fprintf(ci.filePtr, "%04d-%02d-%02d %02d:%02d:%02d%c",
ltime.year,ltime.month, ltime.day,
ltime.hour,ltime.minute,ltime.second, ci.delimiter);
buf += table->field[colpos]->pack_length();
}
else
{
long long value = *((long long*) buf);
long datePart = (long) (value/1000000ll);
int day = datePart % 100;
int month = (datePart/100) % 100;
int year = datePart/10000;
fprintf(ci.filePtr, "%04d-%02d-%02d ", year,month,day);
long timePart = (long) (value - (long long) datePart*1000000ll);
int second = timePart % 100;
int min = (timePart/100) % 100;
int hour = timePart/10000;
fprintf(ci.filePtr, "%02d:%02d:%02d%c", hour,min,second, ci.delimiter);
long timePart = (long) (value - (long long) datePart*1000000ll);
int second = timePart % 100;
int min = (timePart/100) % 100;
int hour = timePart/10000;
fprintf(ci.filePtr, "%02d:%02d:%02d%c", hour,min,second, ci.delimiter);
buf += 8;
}
}
buf += 8;
break;
}
case CalpontSystemCatalog::CHAR:

View File

@ -2092,7 +2092,10 @@ CalpontSystemCatalog::ColType colType_MysqlToIDB (const Item* item)
ct.colWidth = 4;
}
else if (item->field_type() == MYSQL_TYPE_DATETIME ||
item->field_type() == MYSQL_TYPE_TIMESTAMP)
item->field_type() == MYSQL_TYPE_DATETIME2 ||
item->field_type() == MYSQL_TYPE_TIMESTAMP ||
item->field_type() == MYSQL_TYPE_TIMESTAMP2
)
{
ct.colDataType = CalpontSystemCatalog::DATETIME;
ct.colWidth = 8;
@ -2822,7 +2825,9 @@ ReturnedColumn* buildFunctionColumn(Item_func* ifp, gp_walk_info& gwi, bool& non
// MySQL give string result type for date function, but has the flag set.
// we should set the result type to be datetime for comparision.
if (ifp->field_type() == MYSQL_TYPE_DATETIME ||
ifp->field_type() == MYSQL_TYPE_DATETIME2 ||
ifp->field_type() == MYSQL_TYPE_TIMESTAMP ||
ifp->field_type() == MYSQL_TYPE_TIMESTAMP2 ||
funcName == "add_time")
{
CalpontSystemCatalog::ColType ct;