You've already forked mariadb-columnstore-engine
mirror of
https://github.com/mariadb-corporation/mariadb-columnstore-engine.git
synced 2025-08-08 14:22:09 +03:00
MCOL-392 Add initial TIME datatype support
This commit is contained in:
@@ -174,6 +174,10 @@ uint32_t convertDataType(int dataType)
|
||||
calpontDataType = CalpontSystemCatalog::DATETIME;
|
||||
break;
|
||||
|
||||
case ddlpackage::DDL_TIME:
|
||||
calpontDataType = CalpontSystemCatalog::TIME;
|
||||
break;
|
||||
|
||||
case ddlpackage::DDL_CLOB:
|
||||
calpontDataType = CalpontSystemCatalog::CLOB;
|
||||
break;
|
||||
|
@@ -136,7 +136,8 @@ int buildBuffer(uchar* buf, string& buffer, int& columns, TABLE* table)
|
||||
(*field)->type() == MYSQL_TYPE_STRING ||
|
||||
(*field)->type() == MYSQL_TYPE_DATE ||
|
||||
(*field)->type() == MYSQL_TYPE_DATETIME ||
|
||||
(*field)->type() == MYSQL_TYPE_DATETIME2 )
|
||||
(*field)->type() == MYSQL_TYPE_DATETIME2 ||
|
||||
(*field)->type() == MYSQL_TYPE_TIME )
|
||||
vals.append("'");
|
||||
|
||||
while (ptr < end_ptr)
|
||||
@@ -166,7 +167,8 @@ int buildBuffer(uchar* buf, string& buffer, int& columns, TABLE* table)
|
||||
(*field)->type() == MYSQL_TYPE_STRING ||
|
||||
(*field)->type() == MYSQL_TYPE_DATE ||
|
||||
(*field)->type() == MYSQL_TYPE_DATETIME ||
|
||||
(*field)->type() == MYSQL_TYPE_DATETIME2 )
|
||||
(*field)->type() == MYSQL_TYPE_DATETIME2 ||
|
||||
(*field)->type() == MYSQL_TYPE_TIME )
|
||||
vals.append("'");
|
||||
}
|
||||
}
|
||||
@@ -876,6 +878,37 @@ int ha_calpont_impl_write_batch_row_(uchar* buf, TABLE* table, cal_impl_if::cal_
|
||||
break;
|
||||
}
|
||||
|
||||
case CalpontSystemCatalog::TIME:
|
||||
{
|
||||
if (nullVal && (ci.columnTypes[colpos].constraintType != CalpontSystemCatalog::NOTNULL_CONSTRAINT))
|
||||
{
|
||||
fprintf(ci.filePtr, "%c", ci.delimiter);
|
||||
|
||||
buf += table->field[colpos]->pack_length();
|
||||
}
|
||||
else
|
||||
{
|
||||
MYSQL_TIME ltime;
|
||||
const uchar* pos = buf;
|
||||
longlong tmp = my_time_packed_from_binary(pos, table->field[colpos]->decimals());
|
||||
TIME_from_longlong_time_packed(<ime, tmp);
|
||||
if (!ltime.second_part)
|
||||
{
|
||||
fprintf(ci.filePtr, "%02d:%02d:%02d%c",
|
||||
ltime.hour, ltime.minute, ltime.second, ci.delimiter);
|
||||
}
|
||||
else
|
||||
{
|
||||
fprintf(ci.filePtr, "%02d:%02d:%02d.%ld%c",
|
||||
ltime.hour, ltime.minute, ltime.second,
|
||||
ltime.second_part, ci.delimiter);
|
||||
}
|
||||
buf += table->field[colpos]->pack_length();
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
case CalpontSystemCatalog::CHAR:
|
||||
{
|
||||
if (nullVal && (ci.columnTypes[colpos].constraintType != CalpontSystemCatalog::NOTNULL_CONSTRAINT))
|
||||
|
@@ -2657,6 +2657,11 @@ CalpontSystemCatalog::ColType colType_MysqlToIDB (const Item* item)
|
||||
ct.colDataType = CalpontSystemCatalog::DATETIME;
|
||||
ct.colWidth = 8;
|
||||
}
|
||||
else if (item->field_type() == MYSQL_TYPE_TIME)
|
||||
{
|
||||
ct.colDataType = CalpontSystemCatalog::TIME;
|
||||
ct.colWidth = 8;
|
||||
}
|
||||
|
||||
if (item->field_type() == MYSQL_TYPE_BLOB)
|
||||
{
|
||||
@@ -3528,6 +3533,13 @@ ReturnedColumn* buildFunctionColumn(Item_func* ifp, gp_walk_info& gwi, bool& non
|
||||
ct.colWidth = 4;
|
||||
fc->resultType(ct);
|
||||
}
|
||||
else if (ifp->field_type() == MYSQL_TYPE_TIME)
|
||||
{
|
||||
CalpontSystemCatalog::ColType ct;
|
||||
ct.colDataType = CalpontSystemCatalog::TIME;
|
||||
ct.colWidth = 8;
|
||||
fc->resultType(ct);
|
||||
}
|
||||
|
||||
#if 0
|
||||
|
||||
|
@@ -494,6 +494,19 @@ int fetchNextRow(uchar* buf, cal_table_info& ti, cal_connection_info* ci)
|
||||
break;
|
||||
}
|
||||
|
||||
case CalpontSystemCatalog::TIME:
|
||||
{
|
||||
if ((*f)->null_ptr)
|
||||
*(*f)->null_ptr &= ~(*f)->null_bit;
|
||||
|
||||
intColVal = row.getUintField<8>(s);
|
||||
DataConvert::timeToString(intColVal, tmp, 255);
|
||||
|
||||
Field_varstring* f2 = (Field_varstring*)*f;
|
||||
f2->store(tmp, strlen(tmp), f2->charset());
|
||||
break;
|
||||
}
|
||||
|
||||
case CalpontSystemCatalog::CHAR:
|
||||
case CalpontSystemCatalog::VARCHAR:
|
||||
{
|
||||
|
@@ -125,6 +125,9 @@ string name(CalpontSystemCatalog::ColType& ct)
|
||||
case CalpontSystemCatalog::DATETIME:
|
||||
return "DATETIME";
|
||||
|
||||
case CalpontSystemCatalog::TIME:
|
||||
return "TIME";
|
||||
|
||||
case CalpontSystemCatalog::DECIMAL:
|
||||
return "DECIMAL";
|
||||
|
||||
@@ -201,6 +204,7 @@ bool CP_type(CalpontSystemCatalog::ColType& ct)
|
||||
ct.colDataType == CalpontSystemCatalog::BIGINT ||
|
||||
ct.colDataType == CalpontSystemCatalog::DATE ||
|
||||
ct.colDataType == CalpontSystemCatalog::DATETIME ||
|
||||
ct.colDataType == CalpontSystemCatalog::TIME ||
|
||||
ct.colDataType == CalpontSystemCatalog::DECIMAL ||
|
||||
ct.colDataType == CalpontSystemCatalog::UTINYINT ||
|
||||
ct.colDataType == CalpontSystemCatalog::USMALLINT ||
|
||||
@@ -261,6 +265,9 @@ const string format(int64_t v, CalpontSystemCatalog::ColType& ct)
|
||||
oss << DataConvert::datetimeToString(v);
|
||||
break;
|
||||
|
||||
case CalpontSystemCatalog::TIME:
|
||||
oss << DataConvert::timeToString(v);
|
||||
|
||||
case CalpontSystemCatalog::CHAR:
|
||||
case CalpontSystemCatalog::VARCHAR:
|
||||
{
|
||||
@@ -387,6 +394,10 @@ const int64_t IDB_format(char* str, CalpontSystemCatalog::ColType& ct, uint8_t&
|
||||
v = boost::any_cast<uint64_t>(anyVal);
|
||||
break;
|
||||
|
||||
case CalpontSystemCatalog::TIME:
|
||||
v = boost::any_cast<int64_t>(anyVal);
|
||||
break;
|
||||
|
||||
case CalpontSystemCatalog::DECIMAL:
|
||||
case CalpontSystemCatalog::UDECIMAL:
|
||||
if (ct.colWidth == execplan::CalpontSystemCatalog::ONE_BYTE)
|
||||
|
@@ -590,6 +590,7 @@ ReturnedColumn* buildWindowFunctionColumn(Item* item, gp_walk_info& gwi, bool& n
|
||||
|
||||
case CalpontSystemCatalog::DATE:
|
||||
case CalpontSystemCatalog::DATETIME:
|
||||
case CalpontSystemCatalog::TIME:
|
||||
if (!frm.fIsRange)
|
||||
boundTypeErr = true;
|
||||
else if (dynamic_cast<IntervalColumn*>(frm.fStart.fVal.get()) == NULL)
|
||||
@@ -641,6 +642,7 @@ ReturnedColumn* buildWindowFunctionColumn(Item* item, gp_walk_info& gwi, bool& n
|
||||
|
||||
case CalpontSystemCatalog::DATE:
|
||||
case CalpontSystemCatalog::DATETIME:
|
||||
case CalpontSystemCatalog::TIME:
|
||||
if (!frm.fIsRange)
|
||||
boundTypeErr = true;
|
||||
else if (dynamic_cast<IntervalColumn*>(frm.fEnd.fVal.get()) == NULL)
|
||||
|
Reference in New Issue
Block a user