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
Merge branch 'develop' of https://github.com/mariadb-corporation/mariadb-columnstore-engine into MCOL-3474
This commit is contained in:
@ -36,18 +36,25 @@ using namespace execplan;
|
||||
|
||||
namespace
|
||||
{
|
||||
int64_t hex_to_int(char c)
|
||||
inline int hex_to_int(char c, bool& isNull)
|
||||
{
|
||||
if (c <= '9' && c >= '0')
|
||||
return c - '0';
|
||||
|
||||
c = toupper(c);
|
||||
c |= 32;
|
||||
|
||||
if (c <= 'F' && c >= 'A')
|
||||
return c - 'A' + 10;
|
||||
if (c <= 'f' && c >= 'a')
|
||||
return c - 'a' + 10;
|
||||
|
||||
isNull = true;
|
||||
return -1;
|
||||
}
|
||||
|
||||
inline string cleanup(char *to)
|
||||
{
|
||||
delete[] to;
|
||||
return "";
|
||||
}
|
||||
}
|
||||
|
||||
namespace funcexp
|
||||
@ -65,48 +72,46 @@ string Func_unhex::getStrVal(rowgroup::Row& row,
|
||||
CalpontSystemCatalog::ColType& op_ct)
|
||||
{
|
||||
const string& from = parm[0]->data()->getStrVal(row, isNull);
|
||||
char* to = new char[2 + from.length() / 2];
|
||||
|
||||
if (!to)
|
||||
{
|
||||
isNull = true;
|
||||
if (isNull)
|
||||
return "";
|
||||
}
|
||||
|
||||
char* to = new char[2 + from.size() / 2];
|
||||
|
||||
uint64_t from_pos = 0, to_pos = 0;
|
||||
int64_t hex_char = 0;
|
||||
int hex_char = 0;
|
||||
|
||||
if (strlen(from.c_str()) % 2)
|
||||
if (from.size() % 2)
|
||||
{
|
||||
hex_char = hex_to_int(from[from_pos++]);
|
||||
to[to_pos++] = hex_char;
|
||||
hex_char = hex_to_int(from[from_pos++], isNull);
|
||||
|
||||
if (hex_char == -1)
|
||||
goto nullHandling;
|
||||
return cleanup(to);
|
||||
|
||||
to[to_pos++] = hex_char;
|
||||
}
|
||||
|
||||
for (; from_pos < strlen(from.c_str()); from_pos += 2)
|
||||
for (; from_pos < from.size(); from_pos += 2)
|
||||
{
|
||||
hex_char = hex_to_int(from[from_pos]) << 4;
|
||||
hex_char = hex_to_int(from[from_pos], isNull) << 4;
|
||||
|
||||
if (hex_char == -1)
|
||||
goto nullHandling;
|
||||
return cleanup(to);
|
||||
|
||||
to[to_pos] = hex_char;
|
||||
hex_char = hex_to_int(from[from_pos + 1]);
|
||||
hex_char = hex_to_int(from[from_pos + 1], isNull);
|
||||
|
||||
if (hex_char == -1)
|
||||
goto nullHandling;
|
||||
return cleanup(to);
|
||||
|
||||
to[to_pos++] |= hex_char;
|
||||
}
|
||||
|
||||
to[to_pos] = 0;
|
||||
return string(to);
|
||||
string tmp = string(to);
|
||||
delete[] to;
|
||||
|
||||
nullHandling:
|
||||
isNull = true;
|
||||
return "";
|
||||
return tmp;
|
||||
}
|
||||
|
||||
|
||||
|
@ -209,7 +209,7 @@ FuncExp::FuncExp()
|
||||
fFuncMap["trim"] = new Func_trim(); //dlh
|
||||
fFuncMap["truncate"] = new Func_truncate(); //dlh
|
||||
fFuncMap["ucase"] = new Func_ucase(); //dlh
|
||||
//fFuncMap["unhex"] = new Func_unhex();
|
||||
fFuncMap["unhex"] = new Func_unhex();
|
||||
fFuncMap["unix_timestamp"] = new Func_unix_timestamp();
|
||||
fFuncMap["upper"] = new Func_ucase(); //dlh
|
||||
fFuncMap["week"] = new Func_week(); //dlh
|
||||
|
Reference in New Issue
Block a user