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-43 - Function Join Fails. Added support for MYSQL_TYPE_DATETIME2
This commit is contained in:
@ -132,7 +132,8 @@ int buildBuffer(uchar* buf, string& buffer, int& columns, TABLE* table)
|
|||||||
(*field)->type() == MYSQL_TYPE_VAR_STRING ||
|
(*field)->type() == MYSQL_TYPE_VAR_STRING ||
|
||||||
(*field)->type() == MYSQL_TYPE_STRING ||
|
(*field)->type() == MYSQL_TYPE_STRING ||
|
||||||
(*field)->type() == MYSQL_TYPE_DATE ||
|
(*field)->type() == MYSQL_TYPE_DATE ||
|
||||||
(*field)->type() == MYSQL_TYPE_DATETIME )
|
(*field)->type() == MYSQL_TYPE_DATETIME ||
|
||||||
|
(*field)->type() == MYSQL_TYPE_DATETIME2 )
|
||||||
vals.append("'");
|
vals.append("'");
|
||||||
while (ptr < end_ptr)
|
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_VAR_STRING ||
|
||||||
(*field)->type() == MYSQL_TYPE_STRING ||
|
(*field)->type() == MYSQL_TYPE_STRING ||
|
||||||
(*field)->type() == MYSQL_TYPE_DATE ||
|
(*field)->type() == MYSQL_TYPE_DATE ||
|
||||||
(*field)->type() == MYSQL_TYPE_DATETIME )
|
(*field)->type() == MYSQL_TYPE_DATETIME ||
|
||||||
|
(*field)->type() == MYSQL_TYPE_DATETIME2 )
|
||||||
vals.append("'");
|
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))
|
if (nullVal && (ci.columnTypes[colpos].constraintType != CalpontSystemCatalog::NOTNULL_CONSTRAINT))
|
||||||
{
|
{
|
||||||
fprintf(ci.filePtr, "%c", ci.delimiter);
|
fprintf(ci.filePtr, "%c", ci.delimiter);
|
||||||
|
buf += 8;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
long long value = *((long long*) buf);
|
if (table->field[colpos]->real_type() == MYSQL_TYPE_DATETIME2)
|
||||||
long datePart = (long) (value/1000000ll);
|
{
|
||||||
int day = datePart % 100;
|
// mariadb 10.1 compatibility -- MYSQL_TYPE_DATETIME2 introduced in mysql 5.6
|
||||||
int month = (datePart/100) % 100;
|
MYSQL_TIME ltime;
|
||||||
int year = datePart/10000;
|
const uchar *pos = buf;
|
||||||
fprintf(ci.filePtr, "%04d-%02d-%02d ", year,month,day);
|
longlong tmp= my_datetime_packed_from_binary(pos, 0);
|
||||||
|
TIME_from_longlong_datetime_packed(<ime, tmp);
|
||||||
long timePart = (long) (value - (long long) datePart*1000000ll);
|
fprintf(ci.filePtr, "%04d-%02d-%02d %02d:%02d:%02d%c",
|
||||||
int second = timePart % 100;
|
ltime.year,ltime.month, ltime.day,
|
||||||
int min = (timePart/100) % 100;
|
ltime.hour,ltime.minute,ltime.second, ci.delimiter);
|
||||||
int hour = timePart/10000;
|
buf += table->field[colpos]->pack_length();
|
||||||
fprintf(ci.filePtr, "%02d:%02d:%02d%c", hour,min,second, ci.delimiter);
|
}
|
||||||
|
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);
|
||||||
|
buf += 8;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
buf += 8;
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case CalpontSystemCatalog::CHAR:
|
case CalpontSystemCatalog::CHAR:
|
||||||
|
@ -2092,7 +2092,10 @@ CalpontSystemCatalog::ColType colType_MysqlToIDB (const Item* item)
|
|||||||
ct.colWidth = 4;
|
ct.colWidth = 4;
|
||||||
}
|
}
|
||||||
else if (item->field_type() == MYSQL_TYPE_DATETIME ||
|
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.colDataType = CalpontSystemCatalog::DATETIME;
|
||||||
ct.colWidth = 8;
|
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.
|
// MySQL give string result type for date function, but has the flag set.
|
||||||
// we should set the result type to be datetime for comparision.
|
// we should set the result type to be datetime for comparision.
|
||||||
if (ifp->field_type() == MYSQL_TYPE_DATETIME ||
|
if (ifp->field_type() == MYSQL_TYPE_DATETIME ||
|
||||||
|
ifp->field_type() == MYSQL_TYPE_DATETIME2 ||
|
||||||
ifp->field_type() == MYSQL_TYPE_TIMESTAMP ||
|
ifp->field_type() == MYSQL_TYPE_TIMESTAMP ||
|
||||||
|
ifp->field_type() == MYSQL_TYPE_TIMESTAMP2 ||
|
||||||
funcName == "add_time")
|
funcName == "add_time")
|
||||||
{
|
{
|
||||||
CalpontSystemCatalog::ColType ct;
|
CalpontSystemCatalog::ColType ct;
|
||||||
|
Reference in New Issue
Block a user