You've already forked mariadb-columnstore-engine
mirror of
https://github.com/mariadb-corporation/mariadb-columnstore-engine.git
synced 2025-07-29 08:21:15 +03:00
clang format apply
This commit is contained in:
@ -28,66 +28,61 @@ using namespace execplan;
|
||||
|
||||
namespace funcexp
|
||||
{
|
||||
|
||||
void Func_encode::hash_password(ulong *result, const char *password, uint password_len)
|
||||
void Func_encode::hash_password(ulong* result, const char* password, uint password_len)
|
||||
{
|
||||
ulong nr=1345345333L, add=7, nr2=0x12345671L;
|
||||
ulong nr = 1345345333L, add = 7, nr2 = 0x12345671L;
|
||||
ulong tmp;
|
||||
const char *password_end= password + password_len;
|
||||
const char* password_end = password + password_len;
|
||||
for (; password < password_end; password++)
|
||||
{
|
||||
if (*password == ' ' || *password == '\t')
|
||||
continue;
|
||||
tmp= (ulong) (unsigned char) *password;
|
||||
nr^= (((nr & 63)+add)*tmp)+ (nr << 8);
|
||||
nr2+=(nr2 << 8) ^ nr;
|
||||
add+=tmp;
|
||||
tmp = (ulong)(unsigned char)*password;
|
||||
nr ^= (((nr & 63) + add) * tmp) + (nr << 8);
|
||||
nr2 += (nr2 << 8) ^ nr;
|
||||
add += tmp;
|
||||
}
|
||||
result[0]=nr & (((ulong) 1L << 31) -1L);
|
||||
result[1]=nr2 & (((ulong) 1L << 31) -1L);
|
||||
result[0] = nr & (((ulong)1L << 31) - 1L);
|
||||
result[1] = nr2 & (((ulong)1L << 31) - 1L);
|
||||
}
|
||||
|
||||
CalpontSystemCatalog::ColType Func_encode::operationType( FunctionParm& fp, CalpontSystemCatalog::ColType& resultType )
|
||||
CalpontSystemCatalog::ColType Func_encode::operationType(FunctionParm& fp,
|
||||
CalpontSystemCatalog::ColType& resultType)
|
||||
{
|
||||
return resultType;
|
||||
return resultType;
|
||||
}
|
||||
|
||||
string Func_encode::getStrVal(rowgroup::Row& row,
|
||||
FunctionParm& parm,
|
||||
bool& isNull,
|
||||
CalpontSystemCatalog::ColType&)
|
||||
string Func_encode::getStrVal(rowgroup::Row& row, FunctionParm& parm, bool& isNull,
|
||||
CalpontSystemCatalog::ColType&)
|
||||
{
|
||||
const string& str = parm[0]->data()->getStrVal(row, isNull);
|
||||
if (isNull)
|
||||
{
|
||||
return "";
|
||||
}
|
||||
const string& password = parm[1]->data()->getStrVal(row, isNull);
|
||||
if (isNull)
|
||||
{
|
||||
return "";
|
||||
}
|
||||
|
||||
int nStrLen = str.length();
|
||||
int nPassLen = password.length();
|
||||
utils::VLArray<char> res(nStrLen + 1);
|
||||
memset(res.data(), 0, nStrLen + 1);
|
||||
|
||||
const string& str = parm[0]->data()->getStrVal(row, isNull);
|
||||
if (isNull)
|
||||
{
|
||||
return "";
|
||||
}
|
||||
const string& password = parm[1]->data()->getStrVal(row, isNull);
|
||||
if (isNull)
|
||||
{
|
||||
return "";
|
||||
}
|
||||
if (!fSeeded)
|
||||
{
|
||||
hash_password(fSeeds, password.c_str(), nPassLen);
|
||||
sql_crypt.init(fSeeds);
|
||||
fSeeded = true;
|
||||
}
|
||||
|
||||
int nStrLen = str.length();
|
||||
int nPassLen = password.length();
|
||||
utils::VLArray<char> res(nStrLen + 1);
|
||||
memset(res.data(),0,nStrLen+1);
|
||||
memcpy(res.data(), str.c_str(), nStrLen);
|
||||
sql_crypt.encode(res.data(), nStrLen);
|
||||
sql_crypt.reinit();
|
||||
|
||||
|
||||
if (!fSeeded)
|
||||
{
|
||||
hash_password(fSeeds, password.c_str(), nPassLen);
|
||||
sql_crypt.init(fSeeds);
|
||||
fSeeded = true;
|
||||
}
|
||||
|
||||
memcpy(res.data(),str.c_str(),nStrLen);
|
||||
sql_crypt.encode(res.data(),nStrLen);
|
||||
sql_crypt.reinit();
|
||||
|
||||
return res.data();
|
||||
return res.data();
|
||||
}
|
||||
|
||||
}
|
||||
} // namespace funcexp
|
||||
|
Reference in New Issue
Block a user